Skip to content

Commit

Permalink
Codestyle Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PargeLenis committed Jan 22, 2023
1 parent d84baca commit 77b01bd
Show file tree
Hide file tree
Showing 33 changed files with 32 additions and 71 deletions.
4 changes: 0 additions & 4 deletions src/modules/Bots/ahbot/AhBotConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ using namespace std;

INSTANTIATE_SINGLETON_1(AhBotConfig);

AhBotConfig::AhBotConfig()
{
}

template <class T>
void LoadSet(string value, T &res)
{
Expand Down
1 change: 0 additions & 1 deletion src/modules/Bots/ahbot/AhBotConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ using namespace std;
class AhBotConfig
{
public:
AhBotConfig();
static AhBotConfig& instance()
{
static AhBotConfig instance;
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Bots/ahbot/PricingStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ uint32 PricingStrategy::GetDefaultBuyPrice(ItemPrototype const* proto)
uint32 level = max(proto->ItemLevel, proto->RequiredLevel);
if (proto->Class == ITEM_CLASS_QUEST)
{
double result = 1.0;

QueryResult* results = WorldDatabase.PQuery(
"select max(QuestLevel), max(MinLevel) from quest_template where ReqItemId1 = %u or ReqItemId2 = %u or ReqItemId3 = %u or ReqItemId4 = %u",
proto->ItemId, proto->ItemId, proto->ItemId, proto->ItemId);
Expand Down
1 change: 0 additions & 1 deletion src/modules/Bots/playerbot/GuildTaskMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,6 @@ bool GuildTaskMgr::HandleConsoleCommand(ChatHandler* handler, char const* args)

} while (result->NextRow());

Field* fields = result->Fetch();
delete result;
}

Expand Down
10 changes: 2 additions & 8 deletions src/modules/Bots/playerbot/LootObjectStack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ LootTarget::LootTarget(ObjectGuid guid) : guid(guid), asOfTime(time(0))
{
}

LootTarget::LootTarget(LootTarget const& other)
LootTarget::LootTarget(LootTarget const& other) : guid(other.guid), asOfTime(other.asOfTime)
{
guid = other.guid;
asOfTime = other.asOfTime;
}

LootTarget& LootTarget::operator=(LootTarget const& other)
Expand Down Expand Up @@ -145,12 +143,8 @@ WorldObject* LootObject::GetWorldObject(Player* bot)
return NULL;
}

LootObject::LootObject(const LootObject& other)
LootObject::LootObject(const LootObject& other) : guid(other.guid), skillId(other.skillId), reqSkillValue(other.reqSkillValue), reqItem(other.reqItem)
{
guid = other.guid;
skillId = other.skillId;
reqSkillValue = other.reqSkillValue;
reqItem = other.reqItem;
}

bool LootObject::IsLootPossible(Player* bot)
Expand Down
19 changes: 8 additions & 11 deletions src/modules/Bots/playerbot/strategy/actions/BankAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,19 @@ void BankAction::ListItems()
map<uint32, bool> soulbound;
for (int i = BANK_SLOT_ITEM_START; i < BANK_SLOT_ITEM_END; ++i)
if (Item* pItem = bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (pItem)
{
{
items[pItem->GetProto()->ItemId] += pItem->GetCount();
soulbound[pItem->GetProto()->ItemId] = pItem->IsSoulBound();
}
}

for (int i = BANK_SLOT_BAG_START; i < BANK_SLOT_BAG_END; ++i)
if (Bag* pBag = (Bag*)bot->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
if (pBag)
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
if (Item* pItem = pBag->GetItemByPos(j))
if (pItem)
{
items[pItem->GetProto()->ItemId] += pItem->GetCount();
soulbound[pItem->GetProto()->ItemId] = pItem->IsSoulBound();
}
for (uint32 j = 0; j < pBag->GetBagSize(); ++j)
if (Item* pItem = pBag->GetItemByPos(j))
{
items[pItem->GetProto()->ItemId] += pItem->GetCount();
soulbound[pItem->GetProto()->ItemId] = pItem->IsSoulBound();
}

TellItems(items, soulbound);
}
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Bots/playerbot/strategy/actions/BuffAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ void BuffAction::TellHeader(uint32 subClass)

bool BuffAction::Execute(Event event)
{
string text = event.getParam();

FindBuffVisitor visitor(bot);
IterateItems(&visitor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ bool CustomStrategyEditAction::Execute(Event event)
string text = event.getParam();
int pos = text.find(" ");
if (pos == string::npos) return PrintHelp();
{
string name = text.substr(0, pos);
}

string name = text.substr(0, pos);

text = text.substr(pos + 1);

pos = text.find(" ");
Expand Down Expand Up @@ -115,7 +115,7 @@ bool CustomStrategyEditAction::Edit(string name, uint32 idx, string command)
return true;
}

bool CustomStrategyEditAction::PrintActionLine(uint32 idx, string command)
bool CustomStrategyEditAction::PrintActionLine(uint32 idx, string& command)
{
ostringstream out; out << "#" << idx << " " << command;
ai->TellMaster(out.str());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ai

private:
bool PrintHelp();
bool PrintActionLine(uint32 idx, string command);
bool PrintActionLine(uint32 idx, string& command);
bool Print(string name);
bool Edit(string name, uint32 idx, string command);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ bool EmoteAction::Execute(Event event)

uint32 emote = 0;

time_t lastEmote = AI_VALUE2(time_t, "last emote", qualifier);
ai->GetAiObjectContext()->GetValue<time_t>("last emote", qualifier)->Set(time(0) + urand(1, 60));

string param = event.getParam();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ string LogLevelAction::logLevel2string(LogLevel level)
return "debug";
}
}
LogLevel LogLevelAction::string2logLevel(string level)
LogLevel LogLevelAction::string2logLevel(string& level)
{
if (level == "debug")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace ai

public:
static string logLevel2string(LogLevel level);
static LogLevel string2logLevel(string level);
static LogLevel string2logLevel(string& level);
};

}
2 changes: 1 addition & 1 deletion src/modules/Bots/playerbot/strategy/actions/MailAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class TakeMailProcessor : public MailProcessor
private:
bool CheckBagSpace(Player* bot)
{
uint32 totalused = 0, total = 16;
uint32 totalused = 0;
for (uint8 slot = INVENTORY_SLOT_ITEM_START; slot < INVENTORY_SLOT_ITEM_END; slot++)
{
if (bot->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ bool MovementAction::MoveTo(Unit* target, float distance)

float bx = bot->GetPositionX();
float by = bot->GetPositionY();
float bz = bot->GetPositionZ();

float tx = target->GetPositionX();
float ty = target->GetPositionY();
float tz = target->GetPositionZ();

Expand Down
6 changes: 3 additions & 3 deletions src/modules/Bots/playerbot/strategy/actions/OutfitAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bool OutfitAction::Execute(Event event)
return true;
}

void OutfitAction::Save(string name, ItemIds items)
void OutfitAction::Save(string& name, ItemIds items)
{
list<string>& outfits = AI_VALUE(list<string>&, "outfit list");
for (list<string>::iterator i = outfits.begin(); i != outfits.end(); ++i)
Expand Down Expand Up @@ -125,7 +125,7 @@ void OutfitAction::Save(string name, ItemIds items)
outfits.push_back(out.str());
}

ItemIds OutfitAction::Find(string name)
ItemIds OutfitAction::Find(string& name)
{
list<string>& outfits = AI_VALUE(list<string>&, "outfit list");
for (list<string>::iterator i = outfits.begin(); i != outfits.end(); ++i)
Expand Down Expand Up @@ -197,7 +197,7 @@ ItemIds OutfitAction::parseItems(string text)
return itemIds;
}

void OutfitAction::Update(string name)
void OutfitAction::Update(string& name)
{
ListItemsVisitor visitor;
IterateItems(&visitor, ITERATE_ITEMS_IN_EQUIP);
Expand Down
6 changes: 3 additions & 3 deletions src/modules/Bots/playerbot/strategy/actions/OutfitAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ namespace ai
ItemIds parseItems(string outfit);

void List();
ItemIds Find(string name);
void Save(string name, ItemIds outfit);
void Update(string name);
ItemIds Find(string& name);
void Save(string& name, ItemIds outfit);
void Update(string& name);
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ bool RepairAllAction::Execute(Event event)
}

bot->SetFacingToObject(unit);
float discountMod = bot->GetReputationPriceDiscount(unit);
uint32 totalCost = bot->DurabilityRepairAll(true, 1.0f, false);

ostringstream out;
Expand Down
3 changes: 0 additions & 3 deletions src/modules/Bots/playerbot/strategy/actions/RewardAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ bool RewardAction::Reward(uint32 itemId, Object* questGiver)
{
bot->RewardQuest(pQuest, rewardIdx, questGiver, false);

string questTitle = pQuest->GetTitle();
string itemName = pRewardItem->Name1;

ostringstream out; out << chat->formatItem(pRewardItem) << " rewarded";
ai->TellMaster(out);
return true;
Expand Down
1 change: 0 additions & 1 deletion src/modules/Bots/playerbot/strategy/actions/SayAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ bool SayAction::Execute(Event event)
vector<string> &strings = stringTable[qualifier];
if (strings.empty()) return false;

time_t lastSaid = AI_VALUE2(time_t, "last said", qualifier);
ai->GetAiObjectContext()->GetValue<time_t>("last said", qualifier)->Set(time(0) + urand(1, 60));

uint32 probability = probabilityTable[qualifier];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ bool SendMailAction::Execute(Event event)
continue;
}

ItemPrototype const *proto = item->GetProto();
bot->MoveItemFromInventory(item->GetBagSlot(), item->GetSlot(), true);
item->DeleteFromInventoryDB();
item->SetOwnerGuid(master->GetObjectGuid());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ bool SummonAction::Summon(Player *summoner, Player *player)

bool SummonAction::Teleport(Player *summoner, Player *player)
{
Player* master = GetMaster();
if (!summoner->IsBeingTeleported() && !player->IsBeingTeleported())
{
float followAngle = GetFollowAngle();
Expand Down
3 changes: 1 addition & 2 deletions src/modules/Bots/playerbot/strategy/actions/WhoAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ string WhoAction::QuerySkill(string text)
return out.str();
}

string WhoAction::QuerySpec(string text)
string WhoAction::QuerySpec(string& text)
{
ostringstream out;

Expand Down Expand Up @@ -142,7 +142,6 @@ string WhoAction::QuerySpec(string text)
{
out << "|h|cff00ff00" << visitor.count[ITEM_QUALITY_UNCOMMON] << "|h|cffffffff";
}
needSlash = true;
}

out << ")";
Expand Down
2 changes: 1 addition & 1 deletion src/modules/Bots/playerbot/strategy/actions/WhoAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ai
private:
string QueryTrade(string text);
string QuerySkill(string text);
string QuerySpec(string text);
string QuerySpec(string& text);
};

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ float ConserveManaMultiplier::GetValue(Action* action)
bool hasMana = AI_VALUE2(bool, "has mana", "self target");
bool mediumMana = hasMana && mana < sPlayerbotAIConfig.mediumMana;

string name = action->getName();

if (health < sPlayerbotAIConfig.lowHealth)
{
return 1.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace ai;
class MagePullMultiplier : public PassiveMultiplier
{
public:
MagePullMultiplier(PlayerbotAI* ai, string action) : PassiveMultiplier(ai)
MagePullMultiplier(PlayerbotAI* ai, string& action) : PassiveMultiplier(ai)
{
this->action = action;
}
Expand Down
3 changes: 0 additions & 3 deletions src/modules/Bots/playerbot/strategy/values/Arrow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ WorldLocation ArrowFormation::GetLocationInternal()
int tankLines = 1 + tanks.Size() / 6;
int meleeLines = 1 + melee.Size() / 6;
int rangedLines = 1 + ranged.Size() / 6;
int healerLines = 1 + healers.Size() / 6;
float offset = 0;

Player* master = ai->GetMaster();
Expand Down Expand Up @@ -150,8 +149,6 @@ UnitPosition MultiLineUnitPlacer::Place(FormationUnit *unit, uint32 index, uint3
int lineNo = index / 6;
int indexInLine = index % 6;
int lineSize = max(count - lineNo * 6, uint32(6));
float x = cos(orientation) * sPlayerbotAIConfig.followDistance * lineNo;
float y = sin(orientation) * sPlayerbotAIConfig.followDistance * lineNo;
return placer.Place(unit, indexInLine, lineSize);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace ai;
class FindTargetForCcStrategy : public FindTargetStrategy
{
public:
FindTargetForCcStrategy(PlayerbotAI* ai, string spell) : FindTargetStrategy(ai)
FindTargetForCcStrategy(PlayerbotAI* ai, string& spell) : FindTargetStrategy(ai)
{
this->spell = spell;
maxDistance = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace ai;
class FindCurrentCcTargetStrategy : public FindTargetStrategy
{
public:
FindCurrentCcTargetStrategy(PlayerbotAI* ai, string spell) : FindTargetStrategy(ai)
FindCurrentCcTargetStrategy(PlayerbotAI* ai, string& spell) : FindTargetStrategy(ai)
{
this->spell = spell;
}
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Bots/playerbot/strategy/values/ItemCountValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ list<Item*> InventoryItemValueBase::Find(string qualifier)
{
list<Item*> result;

Player* bot = InventoryAction::ai->GetBot();

list<Item*> items = InventoryAction::parseItems(qualifier);
for (list<Item*>::iterator i = items.begin(); i != items.end(); i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ LootStrategy *LootStrategyValue::gray = new GrayLootStrategy();
LootStrategy *LootStrategyValue::disenchant = new DisenchantLootStrategy();
LootStrategy *LootStrategyValue::all = new AllLootStrategy();

LootStrategy* LootStrategyValue::instance(string strategy)
LootStrategy* LootStrategyValue::instance(string& strategy)
{
if (strategy == "*" || strategy == "all")
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ namespace ai
virtual ~LootStrategyValue() { delete defaultValue; }

static LootStrategy *normal, *gray, *all, *disenchant;
static LootStrategy* instance(string name);
static LootStrategy* instance(string& name);
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ using namespace ai;
class PlayerWithoutAuraPredicate : public FindPlayerPredicate, public PlayerbotAIAware
{
public:
PlayerWithoutAuraPredicate(PlayerbotAI* ai, string aura) :
PlayerWithoutAuraPredicate(PlayerbotAI* ai, string& aura) :
PlayerbotAIAware(ai), FindPlayerPredicate(), aura(aura) {}

public:
Expand Down
2 changes: 0 additions & 2 deletions src/modules/Bots/playerbot/strategy/values/StatsValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ uint8 BagSpaceValue::Calculate()
}
}

uint32 totalfree = 16 - totalused;
for (uint8 bag = INVENTORY_SLOT_BAG_START; bag < INVENTORY_SLOT_BAG_END; ++bag)
{
const Bag* const pBag = (Bag*) bot->GetItemByPos(INVENTORY_SLOT_BAG_0, bag);
Expand All @@ -154,7 +153,6 @@ uint8 BagSpaceValue::Calculate()
if (pBagProto->Class == ITEM_CLASS_CONTAINER && pBagProto->SubClass == ITEM_SUBCLASS_CONTAINER)
{
total += pBag->GetBagSize();
totalfree += pBag->GetFreeSlots();
}
}

Expand Down

0 comments on commit 77b01bd

Please sign in to comment.