mirror of
https://github.com/mod-playerbots/mod-playerbots.git
synced 2026-01-14 17:39:09 +00:00
Engine optimization for better performance and mem usage (#1462)
* Optimize loot * World channel talk * General improvement * Engine rebuild for performance and memory usage * Fix crash with AutoDoQuest = 0
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "Playerbots.h"
|
||||
#include "Queue.h"
|
||||
#include "Strategy.h"
|
||||
#include "Timer.h"
|
||||
|
||||
Engine::Engine(PlayerbotAI* botAI, AiObjectContext* factory) : PlayerbotAIAware(botAI), aiObjectContext(factory)
|
||||
{
|
||||
@@ -108,6 +109,8 @@ void Engine::Reset()
|
||||
}
|
||||
|
||||
multipliers.clear();
|
||||
|
||||
actionNodeFactories.creators.clear();
|
||||
}
|
||||
|
||||
void Engine::Init()
|
||||
@@ -120,9 +123,10 @@ void Engine::Init()
|
||||
strategyTypeMask |= strategy->GetType();
|
||||
strategy->InitMultipliers(multipliers);
|
||||
strategy->InitTriggers(triggers);
|
||||
|
||||
Event emptyEvent;
|
||||
MultiplyAndPush(strategy->getDefaultActions(), 0.0f, false, emptyEvent, "default");
|
||||
for (auto &iter : strategy->actionNodeFactories.creators)
|
||||
{
|
||||
actionNodeFactories.creators[iter.first] = iter.second;
|
||||
}
|
||||
}
|
||||
|
||||
if (testMode)
|
||||
@@ -248,11 +252,9 @@ bool Engine::DoNextAction(Unit* unit, uint32 depth, bool minimal)
|
||||
|
||||
ActionNode* Engine::CreateActionNode(std::string const name)
|
||||
{
|
||||
for (std::map<std::string, Strategy*>::iterator i = strategies.begin(); i != strategies.end(); i++)
|
||||
{
|
||||
if (ActionNode* node = i->second->GetAction(name))
|
||||
return node;
|
||||
}
|
||||
ActionNode* node = actionNodeFactories.GetContextObject(name, botAI);
|
||||
if (node)
|
||||
return node;
|
||||
|
||||
return new ActionNode(name,
|
||||
/*P*/ nullptr,
|
||||
@@ -432,6 +434,7 @@ bool Engine::HasStrategy(std::string const name) { return strategies.find(name)
|
||||
void Engine::ProcessTriggers(bool minimal)
|
||||
{
|
||||
std::unordered_map<Trigger*, Event> fires;
|
||||
uint32 now = getMSTime();
|
||||
for (std::vector<TriggerNode*>::iterator i = triggers.begin(); i != triggers.end(); i++)
|
||||
{
|
||||
TriggerNode* node = *i;
|
||||
@@ -451,7 +454,7 @@ void Engine::ProcessTriggers(bool minimal)
|
||||
if (fires.find(trigger) != fires.end())
|
||||
continue;
|
||||
|
||||
if (testMode || trigger->needCheck())
|
||||
if (testMode || trigger->needCheck(now))
|
||||
{
|
||||
if (minimal && node->getFirstRelevance() < 100)
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user