Fixed PCH warnings and bot add command

This commit is contained in:
Foereaper 2015-04-04 13:53:00 +02:00
parent 7fb0d3631e
commit dab1c06b4e
29 changed files with 89 additions and 108 deletions

View File

@ -1,4 +1,4 @@
#include "ConsumableCategory.h" #include "ConsumableCategory.h"
#include "ItemBag.h" //#include "ItemBag.h"
using namespace ahbot; using namespace ahbot;

View File

@ -1,4 +1,4 @@
#include "TradeCategory.h" #include "TradeCategory.h"
#include "ItemBag.h" //#include "ItemBag.h"
using namespace ahbot; using namespace ahbot;

View File

@ -291,7 +291,6 @@ void PlayerbotAI::HandleBotOutgoingPacket(const WorldPacket& packet)
if (casterGuid != bot->GetObjectGuid()) if (casterGuid != bot->GetObjectGuid())
return; return;
uint8 castCount;
uint32 spellId; uint32 spellId;
p >> spellId; p >> spellId;
SpellInterrupted(spellId); SpellInterrupted(spellId);
@ -332,7 +331,7 @@ void PlayerbotAI::SpellInterrupted(uint32 spellid)
uint32 castTimeSpent = 1000 * (now - lastSpell.time); uint32 castTimeSpent = 1000 * (now - lastSpell.time);
int32 globalCooldown = CalculateGlobalCooldown(lastSpell.id); uint32 globalCooldown = CalculateGlobalCooldown(lastSpell.id);
if (castTimeSpent < globalCooldown) if (castTimeSpent < globalCooldown)
SetNextCheckDelay(globalCooldown - castTimeSpent); SetNextCheckDelay(globalCooldown - castTimeSpent);
else else
@ -341,7 +340,7 @@ void PlayerbotAI::SpellInterrupted(uint32 spellid)
lastSpell.id = 0; lastSpell.id = 0;
} }
int32 PlayerbotAI::CalculateGlobalCooldown(uint32 spellid) uint32 PlayerbotAI::CalculateGlobalCooldown(uint32 spellid)
{ {
if (!spellid) if (!spellid)
return 0; return 0;

View File

@ -133,7 +133,7 @@ public:
bool TellMaster(string text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); bool TellMaster(string text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
bool TellMasterNoFacing(string text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL); bool TellMasterNoFacing(string text, PlayerbotSecurityLevel securityLevel = PLAYERBOT_SECURITY_ALLOW_ALL);
void SpellInterrupted(uint32 spellid); void SpellInterrupted(uint32 spellid);
int32 CalculateGlobalCooldown(uint32 spellid); uint32 CalculateGlobalCooldown(uint32 spellid);
void InterruptSpell(); void InterruptSpell();
void RemoveAura(string name); void RemoveAura(string name);
void RemoveShapeshift(); void RemoveShapeshift();

View File

@ -67,8 +67,8 @@ bool PlayerbotAIConfig::Initialize()
lowMana = config.GetIntDefault("AiPlayerbot.LowMana", 15); lowMana = config.GetIntDefault("AiPlayerbot.LowMana", 15);
mediumMana = config.GetIntDefault("AiPlayerbot.MediumMana", 40); mediumMana = config.GetIntDefault("AiPlayerbot.MediumMana", 40);
randomGearLoweringChance = config.GetFloatDefault("AiPlayerbot.RandomGearLoweringChance", 0.15); randomGearLoweringChance = config.GetFloatDefault("AiPlayerbot.RandomGearLoweringChance", 0.15f);
randomBotMaxLevelChance = config.GetFloatDefault("AiPlayerbot.RandomBotMaxLevelChance", 0.4); randomBotMaxLevelChance = config.GetFloatDefault("AiPlayerbot.RandomBotMaxLevelChance", 0.4f);
iterationsPerTick = config.GetIntDefault("AiPlayerbot.IterationsPerTick", 4); iterationsPerTick = config.GetIntDefault("AiPlayerbot.IterationsPerTick", 4);
@ -220,7 +220,7 @@ void PlayerbotAIConfig::SetValue(string name, string value)
void PlayerbotAIConfig::CreateRandomBots() void PlayerbotAIConfig::CreateRandomBots()
{ {
string randomBotAccountPrefix = config.GetStringDefault("AiPlayerbot.RandomBotAccountPrefix", "rndbot"); string randomBotAccountPrefix = config.GetStringDefault("AiPlayerbot.RandomBotAccountPrefix", "rndbot");
uint32 randomBotAccountCount = config.GetIntDefault("AiPlayerbot.RandomBotAccountCount", 50); int32 randomBotAccountCount = config.GetIntDefault("AiPlayerbot.RandomBotAccountCount", 50);
if (config.GetBoolDefault("AiPlayerbot.DeleteRandomBotAccounts", false)) if (config.GetBoolDefault("AiPlayerbot.DeleteRandomBotAccounts", false))
{ {

View File

@ -802,7 +802,7 @@ void PlayerbotFactory::EnchantItem(Item* item)
int32 itemLevel = proto->ItemLevel; int32 itemLevel = proto->ItemLevel;
vector<uint32> ids; vector<uint32> ids;
for (int id = 0; id < sSpellStore.GetNumRows(); ++id) for (uint32 id = 0; id < sSpellStore.GetNumRows(); ++id)
{ {
SpellEntry const *entry = sSpellStore.LookupEntry(id); SpellEntry const *entry = sSpellStore.LookupEntry(id);
if (!entry) if (!entry)

View File

@ -120,51 +120,39 @@ void PlayerbotHolder::OnBotLogin(Player * const bot)
ai->TellMaster("Hello!"); ai->TellMaster("Hello!");
} }
string PlayerbotHolder::ProcessBotCommand(string cmd, ObjectGuid guid, bool admin, uint32 masterAccountId, uint32 masterGuildId) bool PlayerbotHolder::ProcessBotCommand(string cmd, ObjectGuid guid, bool admin, uint32 masterAccountId)
{ {
if (!sPlayerbotAIConfig.enabled || guid.IsEmpty()) if (!sPlayerbotAIConfig.enabled || guid.IsEmpty())
return "bot system is disabled"; return false;
uint32 botAccount = sObjectMgr.GetPlayerAccountIdByGUID(guid);
bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(guid); bool isRandomBot = sRandomPlayerbotMgr.IsRandomBot(guid);
bool isRandomAccount = sPlayerbotAIConfig.IsInRandomAccountList(botAccount); bool isRandomAccount = sPlayerbotAIConfig.IsInRandomAccountList(sObjectMgr.GetPlayerAccountIdByGUID(guid));
bool isMasterAccount = (masterAccountId == botAccount);
if (isRandomAccount && !isRandomBot && !admin) if (isRandomAccount && !isRandomBot && !admin)
{ return false;
Player* bot = sObjectMgr.GetPlayer(guid, false);
if (bot->GetGuildId() != masterGuildId)
return "not in your guild";
}
if (!isRandomAccount && !isMasterAccount && !admin)
return "not in your account";
if (cmd == "add" || cmd == "login") if (cmd == "add" || cmd == "login")
{ {
if (sObjectMgr.GetPlayer(guid, true)) if (sObjectMgr.GetPlayer(guid))
return "player already logged in"; return false;
AddPlayerBot(guid.GetRawValue(), masterAccountId); AddPlayerBot(guid.GetRawValue(), masterAccountId);
return "ok"; return true;
} }
else if (cmd == "remove" || cmd == "logout" || cmd == "rm") else if (cmd == "remove" || cmd == "logout" || cmd == "rm")
{ {
if (!sObjectMgr.GetPlayer(guid, true))
return "player is offline";
if (!GetPlayerBot(guid.GetRawValue())) if (!GetPlayerBot(guid.GetRawValue()))
return "not your bot"; return false;
LogoutPlayerBot(guid.GetRawValue()); LogoutPlayerBot(guid.GetRawValue());
return "ok"; return true;
} }
if (admin) if (admin)
{ {
Player* bot = GetPlayerBot(guid.GetRawValue()); Player* bot = GetPlayerBot(guid.GetRawValue());
if (!bot) if (!bot)
return "bot not found"; return false;
Player* master = bot->GetPlayerbotAI()->GetMaster(); Player* master = bot->GetPlayerbotAI()->GetMaster();
if (master) if (master)
@ -173,25 +161,25 @@ string PlayerbotHolder::ProcessBotCommand(string cmd, ObjectGuid guid, bool admi
{ {
PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_NORMAL); PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_NORMAL);
factory.CleanRandomize(); factory.CleanRandomize();
return "ok"; return true;
} }
else if (cmd == "init=green" || cmd == "init=uncommon") else if (cmd == "init=green" || cmd == "init=uncommon")
{ {
PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_UNCOMMON); PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_UNCOMMON);
factory.CleanRandomize(); factory.CleanRandomize();
return "ok"; return true;
} }
else if (cmd == "init=blue" || cmd == "init=rare") else if (cmd == "init=blue" || cmd == "init=rare")
{ {
PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_RARE); PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_RARE);
factory.CleanRandomize(); factory.CleanRandomize();
return "ok"; return true;
} }
else if (cmd == "init=epic" || cmd == "init=purple") else if (cmd == "init=epic" || cmd == "init=purple")
{ {
PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_EPIC); PlayerbotFactory factory(bot, master->getLevel(), ITEM_QUALITY_EPIC);
factory.CleanRandomize(); factory.CleanRandomize();
return "ok"; return true;
} }
} }
@ -199,16 +187,16 @@ string PlayerbotHolder::ProcessBotCommand(string cmd, ObjectGuid guid, bool admi
{ {
PlayerbotFactory factory(bot, bot->getLevel()); PlayerbotFactory factory(bot, bot->getLevel());
factory.Refresh(); factory.Refresh();
return "ok"; return true;
} }
else if (cmd == "random") else if (cmd == "random")
{ {
sRandomPlayerbotMgr.Randomize(bot); sRandomPlayerbotMgr.Randomize(bot);
return "ok"; return true;
} }
} }
return "unknown command"; return false;
} }
bool ChatHandler::HandlePlayerbotCommand(char* args) bool ChatHandler::HandlePlayerbotCommand(char* args)
@ -338,23 +326,17 @@ list<string> PlayerbotHolder::HandlePlayerbotCommand(char* args, Player* master)
out << cmdStr << ": " << bot << " - "; out << cmdStr << ": " << bot << " - ";
ObjectGuid member = sObjectMgr.GetPlayerGuidByName(bot); ObjectGuid member = sObjectMgr.GetPlayerGuidByName(bot);
if (!member) bool result = false;
if (master && member != master->GetObjectGuid()) if (master && member != master->GetObjectGuid())
{ {
out << "character not found"; result = ProcessBotCommand(cmdStr, member, master->GetSession()->GetSecurity() >= SEC_GAMEMASTER, master->GetSession()->GetAccountId());
}
else if (master && member != master->GetObjectGuid())
{
out << ProcessBotCommand(cmdStr, member,
master->GetSession()->GetSecurity() >= SEC_GAMEMASTER,
master->GetSession()->GetAccountId(),
master->GetGuildId());
} }
else if (!master) else if (!master)
{ {
out << ProcessBotCommand(cmdStr, member, true, -1, -1); result = ProcessBotCommand(cmdStr, member, true, -1);
} }
out << (result ? "ok" : "not allowed");
messages.push_back(out.str()); messages.push_back(out.str());
} }

View File

@ -31,7 +31,7 @@ public:
void OnBotLogin(Player * const bot); void OnBotLogin(Player * const bot);
list<string> HandlePlayerbotCommand(char* args, Player* master = NULL); list<string> HandlePlayerbotCommand(char* args, Player* master = NULL);
string ProcessBotCommand(string cmd, ObjectGuid guid, bool admin, uint32 masterAccountId, uint32 masterGuildId); bool ProcessBotCommand(string cmd, ObjectGuid guid, bool admin, uint32 masterAccountId);
uint32 GetAccountId(string name); uint32 GetAccountId(string name);
protected: protected:

View File

@ -1,5 +1,5 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "GenericActions.h" //#include "GenericActions.h"
using namespace ai; using namespace ai;

View File

@ -45,7 +45,7 @@ bool GossipHelloAction::Execute(Event event)
ai->TellMasterNoFacing(out.str()); ai->TellMasterNoFacing(out.str());
GossipMenu& menu = bot->PlayerTalkClass->GetGossipMenu(); GossipMenu& menu = bot->PlayerTalkClass->GetGossipMenu();
int i = 0, loops = 0; unsigned int i = 0, loops = 0;
set<uint32> alreadyTalked; set<uint32> alreadyTalked;
while (i < menu.MenuItemCount() && loops++ < 100) while (i < menu.MenuItemCount() && loops++ < 100)
{ {

View File

@ -1,8 +1,8 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "GuildBankAction.h" //#include "GuildBankAction.h"
#include "../values/ItemCountValue.h" //#include "../values/ItemCountValue.h"
using namespace std; using namespace std;
using namespace ai; using namespace ai;

View File

@ -1,10 +1,10 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "LfgActions.h" //#include "LfgActions.h"
#include "../../AiFactory.h" //#include "../../AiFactory.h"
#include "../../PlayerbotAIConfig.h" //#include "../../PlayerbotAIConfig.h"
#include "../ItemVisitors.h" //#include "../ItemVisitors.h"
#include "../../RandomPlayerbotMgr.h" //#include "../../RandomPlayerbotMgr.h"
//#include "../../../../game/LFGMgr.h" //#include "../../../../game/LFGMgr.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "NonCombatActions.h" //#include "NonCombatActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "DruidMultipliers.h" //#include "DruidMultipliers.h"
#include "DruidActions.h" //#include "DruidActions.h"
using namespace ai; using namespace ai;

View File

@ -1,7 +1,7 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "DruidTriggers.h" //#include "DruidTriggers.h"
#include "DruidActions.h" //#include "DruidActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "MageMultipliers.h" //#include "MageMultipliers.h"
#include "MageActions.h" //#include "MageActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "PaladinActions.h" //#include "PaladinActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "PaladinMultipliers.h" //#include "PaladinMultipliers.h"
#include "PaladinActions.h" //#include "PaladinActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "PriestMultipliers.h" //#include "PriestMultipliers.h"
#include "PriestActions.h" //#include "PriestActions.h"
using namespace ai; using namespace ai;

View File

@ -1,7 +1,7 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "PriestTriggers.h" //#include "PriestTriggers.h"
#include "PriestActions.h" //#include "PriestActions.h"
using namespace ai; using namespace ai;

View File

@ -1,5 +1,5 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "RogueActions.h" //#include "RogueActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "RogueMultipliers.h" //#include "RogueMultipliers.h"
#include "RogueActions.h" //#include "RogueActions.h"
using namespace ai; using namespace ai;

View File

@ -1,7 +1,7 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "RogueTriggers.h" //#include "RogueTriggers.h"
#include "RogueActions.h" //#include "RogueActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "ShamanActions.h" //#include "ShamanActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "ShamanMultipliers.h" //#include "ShamanMultipliers.h"
#include "ShamanActions.h" //#include "ShamanActions.h"
using namespace ai; using namespace ai;

View File

@ -1,5 +1,5 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "WarlockActions.h" //#include "WarlockActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "WarlockMultipliers.h" //#include "WarlockMultipliers.h"
#include "WarlockActions.h" //#include "WarlockActions.h"
using namespace ai; using namespace ai;

View File

@ -1,6 +1,6 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "WarriorMultipliers.h" //#include "WarriorMultipliers.h"
#include "WarriorActions.h" //#include "WarriorActions.h"
using namespace ai; using namespace ai;

View File

@ -1,7 +1,7 @@
#include "botpch.h" #include "botpch.h"
#include "../../playerbot.h" //#include "../../playerbot.h"
#include "WarriorTriggers.h" //#include "WarriorTriggers.h"
#include "WarriorActions.h" //#include "WarriorActions.h"
using namespace ai; using namespace ai;