Bots: one click on Trade accepts a trade with a bot (SIN's fix)
SIN's Bot Trading fix for 0.1.36, as he wrote it. The add-on puts its own button over the stock Trade button; when a bot is the trader it asks the server for a view of the trade, and a click sends that view back, so the server accepts only the trade the player saw. Solo players send the request as a hidden whisper to themselves; grouped players use the add-on channel. Code by SIN (1amcoff1n). Applied unchanged; only the add-on version is set to 0.6.22.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "Session/AddonControl.h"
|
||||
// Playerbot V2 - script registration
|
||||
// The module hangs off ScriptMgr: every core event it reacts to arrives through a WorldScript / PlayerScript /
|
||||
// UnitScript / GroupScript / GuildScript hook and is forwarded to the matching Module handler. AddSC_playerbot_v2 is
|
||||
@@ -242,6 +243,21 @@ public:
|
||||
|
||||
void OnChatSent(Player* player, uint32 /*type*/, uint32 /*lang*/, std::string const& msg, Player* receiver) override
|
||||
{
|
||||
if (player == receiver && msg.starts_with("FBTrade ") && msg.size() < 140)
|
||||
{
|
||||
auto split = msg.find(' ', 8);
|
||||
if (split == std::string::npos)
|
||||
return;
|
||||
std::string seq = msg.substr(8, split - 8);
|
||||
if (seq.empty() || seq.size() > 8 || seq.find_first_not_of("0123456789abcdef") != std::string::npos)
|
||||
return;
|
||||
std::string token = msg.substr(split + 1);
|
||||
if (token != "view" && (token.empty() || token.find_first_not_of("0123456789:") != std::string::npos))
|
||||
return;
|
||||
Playerbot::V2::AddonControl::OnAddonWhisper(player, receiver, "PBC", "1|" + seq +
|
||||
(token == "view" ? "|1|1|BOT_TRADE_VIEW|" : "|1|1|BOT_TRADE_ACCEPT|" + token));
|
||||
return;
|
||||
}
|
||||
Module::instance().OnWhisperReceived(player, receiver, msg);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user