Merge pull request #462 from liyunfan1223/fix-trade

Handle command and trade check for summoned bot
This commit is contained in:
Yunfan Li
2024-08-11 23:46:55 +08:00
committed by GitHub
4 changed files with 26 additions and 26 deletions

View File

@@ -655,11 +655,7 @@ void PlayerbotAI::HandleCommand(uint32 type, std::string const text, Player* fro
}
if (!IsAllowedCommand(filtered) &&
(master != fromPlayer ||
!GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer)))
return;
if (!IsAllowedCommand(filtered) && master != fromPlayer)
(!GetSecurity()->CheckLevelFor(PLAYERBOT_SECURITY_ALLOW_ALL, type != CHAT_MSG_WHISPER, fromPlayer)))
return;
if (type == CHAT_MSG_RAID_WARNING && filtered.find(bot->GetName()) != std::string::npos &&

View File

@@ -55,14 +55,16 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
// }
Group* group = from->GetGroup();
if (group)
if (group && group == bot->GetGroup() && !ignoreGroup && botAI->GetMaster() == from)
{
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{
Player* player = gref->GetSource();
if (player == bot && !ignoreGroup)
return PLAYERBOT_SECURITY_ALLOW_ALL;
}
return PLAYERBOT_SECURITY_ALLOW_ALL;
}
if (group && group == bot->GetGroup() && !ignoreGroup && botAI->GetMaster() != from)
{
if (reason)
*reason = PLAYERBOT_DENY_NOT_YOURS;
return PLAYERBOT_SECURITY_TALK;
}
if (sPlayerbotAIConfig->groupInvitationPermission <= 0)
@@ -137,13 +139,6 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
return PLAYERBOT_SECURITY_INVITE;
}
for (GroupReference* gref = group->GetFirstMember(); gref; gref = gref->next())
{
Player* player = gref->GetSource();
if (player == from)
return PLAYERBOT_SECURITY_ALLOW_ALL;
}
if (group->IsFull())
{
if (reason)
@@ -169,11 +164,17 @@ PlayerbotSecurityLevel PlayerbotSecurity::LevelFor(Player* from, DenyReason* rea
if (reason)
*reason = PLAYERBOT_DENY_INVITE;
return PLAYERBOT_SECURITY_INVITE;
}
return PLAYERBOT_SECURITY_ALLOW_ALL;
if (botAI->GetMaster() == from)
return PLAYERBOT_SECURITY_ALLOW_ALL;
if (reason)
*reason = PLAYERBOT_DENY_NOT_YOURS;
return PLAYERBOT_SECURITY_INVITE;
}
bool PlayerbotSecurity::CheckLevelFor(PlayerbotSecurityLevel level, bool silent, Player* from, bool ignoreGroup)

View File

@@ -1215,9 +1215,6 @@ void RandomPlayerbotMgr::Revive(Player* player)
void RandomPlayerbotMgr::RandomTeleport(Player* bot, std::vector<WorldLocation>& locs, bool hearth)
{
if (bot->IsBeingTeleported())
return;
if (bot->InBattleground())
return;

View File

@@ -10,8 +10,10 @@
#include "GuildTaskMgr.h"
#include "ItemUsageValue.h"
#include "ItemVisitors.h"
#include "PlayerbotMgr.h"
#include "PlayerbotSecurity.h"
#include "Playerbots.h"
#include "RandomPlayerbotMgr.h"
#include "SetCraftAction.h"
bool TradeStatusAction::Execute(Event event)
@@ -180,8 +182,12 @@ bool TradeStatusAction::CheckTrade()
}
return isGettingItem;
}
if (!sRandomPlayerbotMgr->IsRandomBot(bot))
if (!bot->GetSession())
{
return false;
}
uint32 accountId = bot->GetSession()->GetAccountId();
if (!sPlayerbotAIConfig->IsInRandomAccountList(accountId))
{
int32 botItemsMoney = CalculateCost(bot, true);
int32 botMoney = bot->GetTradeData()->GetMoney() + botItemsMoney;