fix warning & misc

This commit is contained in:
Yunfan Li
2023-05-24 23:23:14 +08:00
parent 637f1dd909
commit edf942c96a
10 changed files with 40 additions and 44 deletions

View File

@@ -98,7 +98,7 @@ void PlayerbotFactory::Prepare()
if (!sPlayerbotAIConfig->disableRandomLevels)
{
bot->SetLevel(level);
bot->GiveLevel(level);
}
else if (bot->getLevel() < sPlayerbotAIConfig->randombotStartingLevel)
{
@@ -125,7 +125,7 @@ void PlayerbotFactory::Randomize(bool incremental)
LOG_INFO("playerbots", "Preparing to {} randomize...", (incremental ? "incremental" : "full"));
Prepare();
bot->SaveToDB(false, false);
LOG_INFO("playerbots", "Resetting player...");
PerformanceMonitorOperation* pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Reset");
bot->resetTalents(true);
@@ -143,6 +143,8 @@ void PlayerbotFactory::Randomize(bool incremental)
if (pmo)
pmo->finish();
bot->resetTalents(true);
bot->SaveToDB(false, false);
/*
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Immersive");
LOG_INFO("playerbots", "Initializing immersive...");
@@ -178,7 +180,7 @@ void PlayerbotFactory::Randomize(bool incremental)
pmo = sPerformanceMonitor->start(PERF_MON_RNDBOT, "PlayerbotFactory_Spells1");
LOG_INFO("playerbots", "Initializing spells (step 1)...");
// InitClassSpells();
InitClassSpells();
InitAvailableSpells();
if (pmo)
pmo->finish();
@@ -1344,44 +1346,19 @@ void PlayerbotFactory::InitSecondEquipmentSet()
void PlayerbotFactory::InitBags()
{
std::vector<uint32> ids;
ItemTemplateContainer const* itemTemplates = sObjectMgr->GetItemTemplateStore();
for (auto const& itr : *itemTemplates)
{
ItemTemplate const* proto = &itr.second;
if (!proto || proto->Class != ITEM_CLASS_CONTAINER)
continue;
if (!CanEquipItem(proto, ITEM_QUALITY_NORMAL))
continue;
ids.push_back(itr.first);
}
if (ids.empty())
{
LOG_ERROR("playerbots", "{}: no bags found", bot->GetName().c_str());
return;
}
for (uint8 slot = INVENTORY_SLOT_BAG_START; slot < INVENTORY_SLOT_BAG_END; ++slot)
{
for (uint32 attempts = 0; attempts < 15; attempts++)
uint32 newItemId = 23162;
uint16 dest;
if (!CanEquipUnseenItem(slot, dest, newItemId))
continue;
Item* newItem = bot->EquipNewItem(dest, newItemId, true);
if (newItem)
{
uint32 index = urand(0, ids.size() - 1);
uint32 newItemId = ids[index];
uint16 dest;
if (!CanEquipUnseenItem(slot, dest, newItemId))
continue;
if (Item* newItem = bot->EquipNewItem(dest, newItemId, true))
{
newItem->AddToWorld();
newItem->AddToUpdateQueueOf(bot);
break;
}
newItem->AddToWorld();
newItem->AddToUpdateQueueOf(bot);
}
}
}
@@ -1791,8 +1768,8 @@ void PlayerbotFactory::InitAvailableSpells()
bot->learnSpell(tSpell->spell);
}
}
if (bot->IsSpellFitByClassAndRace(20271) && !bot->HasSpell(20271)) // judgement missing
bot->learnSpell(20271, false);
// if (bot->IsSpellFitByClassAndRace(20271) && !bot->HasSpell(20271)) // judgement missing
// bot->learnSpell(20271, false);
}
void PlayerbotFactory::InitClassSpells()

View File

@@ -1525,7 +1525,7 @@ std::string const RandomPlayerbotMgr::GetEventData(uint32 bot, std::string const
data = e.data;
}
return std::move(data);
return data;
}
uint32 RandomPlayerbotMgr::SetEventValue(uint32 bot, std::string const event, uint32 value, uint32 validIn, std::string const data)

View File

@@ -32,6 +32,7 @@ class TalentSpec
};
TalentSpec() { };
virtual ~TalentSpec() { }
TalentSpec(uint32 classMask);
TalentSpec(TalentSpec* base, std::string const link);
TalentSpec(Player* bot);

View File

@@ -85,3 +85,8 @@ bool FindItemUsageVisitor::Accept(ItemTemplate const* proto)
return false;
}
bool FindUsableNamedItemVisitor::Accept(ItemTemplate const* proto)
{
return true;
}

View File

@@ -411,4 +411,12 @@ class FindItemUsageVisitor : public FindUsableItemVisitor
ItemUsage usage;
};
class FindUsableNamedItemVisitor : public FindUsableItemVisitor
{
public:
FindUsableNamedItemVisitor(Player* bot): FindUsableItemVisitor(bot) {}
bool Accept(ItemTemplate const* proto) override;
};
#endif

View File

@@ -20,6 +20,7 @@ class UntypedValue : public AiNamedObject
{
public:
UntypedValue(PlayerbotAI* botAI, std::string const name) : AiNamedObject(botAI, name) { }
virtual ~UntypedValue() { }
virtual void Update() { }
virtual void Reset() { }
virtual std::string const Format() { return "?"; }

View File

@@ -43,7 +43,7 @@ class FreeBGJoinAction : public BGJoinAction
class BGLeaveAction : public Action
{
public:
BGLeaveAction(PlayerbotAI* botAI, std::string const name = "bg leave") : Action(botAI) { }
BGLeaveAction(PlayerbotAI* botAI, std::string const name = "bg leave") : Action(botAI, name) { }
bool Execute(Event event) override;
};

View File

@@ -282,6 +282,10 @@ std::vector<Item*> InventoryAction::parseItems(std::string const text, IterateIt
IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS);
found.insert(visitor.GetResult().begin(), visitor.GetResult().end());
}
FindUsableNamedItemVisitor visitor(bot);
IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS);
found.insert(visitor.GetResult().begin(), visitor.GetResult().end());
uint32 quality = chat->parseItemQuality(text);
if (quality != MAX_ITEM_QUALITY)

View File

@@ -16,7 +16,7 @@ class GrindingStrategy : public NonCombatStrategy
std::string const getName() override { return "grind"; }
uint32 GetType() const override { return STRATEGY_TYPE_DPS; }
NextAction** getDefaultActions();
NextAction** getDefaultActions() override;
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
};

View File

@@ -15,7 +15,7 @@ class GuardStrategy : public NonCombatStrategy
GuardStrategy(PlayerbotAI* botAI) : NonCombatStrategy(botAI) { }
std::string const getName() override { return "guard"; }
NextAction** getDefaultActions();
NextAction** getDefaultActions() override;
void InitTriggers(std::vector<TriggerNode*>& triggers) override;
};