mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
Fix merge conflict
This commit is contained in:
@@ -78,13 +78,13 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
|
|||||||
switch (i->first)
|
switch (i->first)
|
||||||
{
|
{
|
||||||
case PERF_MON_TRIGGER:
|
case PERF_MON_TRIGGER:
|
||||||
key = "T";
|
key = "Trigger";
|
||||||
break;
|
break;
|
||||||
case PERF_MON_VALUE:
|
case PERF_MON_VALUE:
|
||||||
key = "V";
|
key = "Value";
|
||||||
break;
|
break;
|
||||||
case PERF_MON_ACTION:
|
case PERF_MON_ACTION:
|
||||||
key = "A";
|
key = "Action";
|
||||||
break;
|
break;
|
||||||
case PERF_MON_RNDBOT:
|
case PERF_MON_RNDBOT:
|
||||||
key = "RndBot";
|
key = "RndBot";
|
||||||
@@ -152,8 +152,8 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float fullTickCount = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->count;
|
float fullTickCount = data[PERF_MON_TOTAL]["PlayerbotAIBase::FullTick"]->count;
|
||||||
float fullTickTotalTime = data[PERF_MON_TOTAL]["RandomPlayerbotMgr::FullTick"]->totalTime;
|
float fullTickTotalTime = data[PERF_MON_TOTAL]["PlayerbotAIBase::FullTick"]->totalTime;
|
||||||
|
|
||||||
LOG_INFO(
|
LOG_INFO(
|
||||||
"playerbots",
|
"playerbots",
|
||||||
@@ -173,13 +173,13 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
|
|||||||
switch (i->first)
|
switch (i->first)
|
||||||
{
|
{
|
||||||
case PERF_MON_TRIGGER:
|
case PERF_MON_TRIGGER:
|
||||||
key = "T";
|
key = "Trigger";
|
||||||
break;
|
break;
|
||||||
case PERF_MON_VALUE:
|
case PERF_MON_VALUE:
|
||||||
key = "V";
|
key = "Value";
|
||||||
break;
|
break;
|
||||||
case PERF_MON_ACTION:
|
case PERF_MON_ACTION:
|
||||||
key = "A";
|
key = "Action";
|
||||||
break;
|
break;
|
||||||
case PERF_MON_RNDBOT:
|
case PERF_MON_RNDBOT:
|
||||||
key = "RndBot";
|
key = "RndBot";
|
||||||
@@ -231,7 +231,7 @@ void PerformanceMonitor::PrintStats(bool perTick, bool fullStack)
|
|||||||
time, minTime, maxTime, avg, amount, key.c_str(), disName.c_str());
|
time, minTime, maxTime, avg, amount, key.c_str(), disName.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PERF_MON_TOTAL != i->first)
|
if (i->first != PERF_MON_TOTAL)
|
||||||
{
|
{
|
||||||
float tPerc = (float)typeTotalTime / (float)fullTickTotalTime * 100.0f;
|
float tPerc = (float)typeTotalTime / (float)fullTickTotalTime * 100.0f;
|
||||||
float tTime = (float)typeTotalTime / fullTickCount / 1000.0f;
|
float tTime = (float)typeTotalTime / fullTickCount / 1000.0f;
|
||||||
@@ -278,7 +278,7 @@ void PerformanceMonitorOperation::finish()
|
|||||||
std::chrono::microseconds finished =
|
std::chrono::microseconds finished =
|
||||||
(std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()))
|
(std::chrono::time_point_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now()))
|
||||||
.time_since_epoch();
|
.time_since_epoch();
|
||||||
uint64_t elapsed = (finished - started).count();
|
uint64 elapsed = (finished - started).count();
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(data->lock);
|
std::lock_guard<std::mutex> guard(data->lock);
|
||||||
if (elapsed > 0)
|
if (elapsed > 0)
|
||||||
|
|||||||
@@ -4758,40 +4758,50 @@ Item* PlayerbotAI::FindStoneFor(Item* weapon) const
|
|||||||
return stone;
|
return stone;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::vector<WizardOilDisplayId> uPriorizedWizardOilIds =
|
|
||||||
{
|
|
||||||
MINOR_WIZARD_OIL, LESSER_WIZARD_OIL, BRILLIANT_WIZARD_OIL, WIZARD_OIL, SUPERIOR_WIZARD_OIL
|
|
||||||
};
|
|
||||||
|
|
||||||
static const std::vector<ManaOilDisplayId> uPriorizedManaOilIds =
|
|
||||||
{
|
|
||||||
MINOR_MANA_OIL, LESSER_MANA_OIL, BRILLIANT_MANA_OIL, SUPERIOR_MANA_OIL,
|
|
||||||
};
|
|
||||||
|
|
||||||
Item* PlayerbotAI::FindOilFor(Item* weapon) const
|
Item* PlayerbotAI::FindOilFor(Item* weapon) const
|
||||||
{
|
{
|
||||||
|
if (!weapon)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const ItemTemplate* item_template = weapon->GetTemplate();
|
||||||
|
if (!item_template)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
// static const will only get created once whatever the call amout
|
||||||
|
static const std::vector<uint32_t> uPriorizedWizardOilIds =
|
||||||
|
{
|
||||||
|
MINOR_WIZARD_OIL, MINOR_MANA_OIL,
|
||||||
|
LESSER_WIZARD_OIL, LESSER_MANA_OIL,
|
||||||
|
BRILLIANT_WIZARD_OIL, BRILLIANT_MANA_OIL,
|
||||||
|
WIZARD_OIL, SUPERIOR_MANA_OIL, SUPERIOR_WIZARD_OIL
|
||||||
|
};
|
||||||
|
|
||||||
|
// static const will only get created once whatever the call amout
|
||||||
|
static const std::vector<uint32_t> uPriorizedManaOilIds =
|
||||||
|
{
|
||||||
|
MINOR_MANA_OIL, MINOR_WIZARD_OIL,
|
||||||
|
LESSER_MANA_OIL, LESSER_WIZARD_OIL,
|
||||||
|
BRILLIANT_MANA_OIL, BRILLIANT_WIZARD_OIL,
|
||||||
|
SUPERIOR_MANA_OIL, WIZARD_OIL, SUPERIOR_WIZARD_OIL
|
||||||
|
};
|
||||||
|
|
||||||
Item* oil = nullptr;
|
Item* oil = nullptr;
|
||||||
ItemTemplate const* pProto = weapon->GetTemplate();
|
if (item_template->SubClass == ITEM_SUBCLASS_WEAPON_SWORD ||
|
||||||
if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_SWORD || pProto->SubClass == ITEM_SUBCLASS_WEAPON_STAFF ||
|
item_template->SubClass == ITEM_SUBCLASS_WEAPON_STAFF ||
|
||||||
pProto->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER))
|
item_template->SubClass == ITEM_SUBCLASS_WEAPON_DAGGER)
|
||||||
{
|
{
|
||||||
for (const auto& id : uPriorizedWizardOilIds)
|
for (const auto& id : uPriorizedWizardOilIds)
|
||||||
{
|
{
|
||||||
oil = FindConsumable(uPriorizedWizardOilIds[id]);
|
if (oil = FindConsumable(id))
|
||||||
if (!oil)
|
|
||||||
oil = FindConsumable(uPriorizedManaOilIds[id]);
|
|
||||||
if (oil)
|
|
||||||
return oil;
|
return oil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE2))
|
else if (item_template->SubClass == ITEM_SUBCLASS_WEAPON_MACE ||
|
||||||
|
item_template->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)
|
||||||
{
|
{
|
||||||
for (const auto& id : uPriorizedManaOilIds)
|
for (const auto& id : uPriorizedManaOilIds)
|
||||||
{
|
{
|
||||||
oil = FindConsumable(uPriorizedManaOilIds[id]);
|
if (oil = FindConsumable(id))
|
||||||
if (!oil)
|
|
||||||
oil = FindConsumable(uPriorizedWizardOilIds[id]);
|
|
||||||
if (oil)
|
|
||||||
return oil;
|
return oil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5493,6 +5503,7 @@ uint8 PlayerbotAI::FindEquipSlot(ItemTemplate const* proto, uint32 slot, bool sw
|
|||||||
// no free position
|
// no free position
|
||||||
return NULL_SLOT;
|
return NULL_SLOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerbotAI::IsSafe(Player* player)
|
bool PlayerbotAI::IsSafe(Player* player)
|
||||||
{
|
{
|
||||||
return player && player->GetMapId() == bot->GetMapId() && player->GetInstanceId() == bot->GetInstanceId() && !player->IsBeingTeleported();
|
return player && player->GetMapId() == bot->GetMapId() && player->GetInstanceId() == bot->GetInstanceId() && !player->IsBeingTeleported();
|
||||||
@@ -5676,3 +5687,4 @@ std::set<uint32> PlayerbotAI::GetCurrentIncompleteQuestIds()
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,11 @@ PlayerbotAIBase::PlayerbotAIBase(bool isBotAI) : nextAICheckDelay(0), _isBotAI(i
|
|||||||
|
|
||||||
void PlayerbotAIBase::UpdateAI(uint32 elapsed, bool minimal)
|
void PlayerbotAIBase::UpdateAI(uint32 elapsed, bool minimal)
|
||||||
{
|
{
|
||||||
|
if (totalPmo)
|
||||||
|
totalPmo->finish();
|
||||||
|
|
||||||
|
totalPmo = sPerformanceMonitor->start(PERF_MON_TOTAL, "PlayerbotAIBase::FullTick");
|
||||||
|
|
||||||
if (nextAICheckDelay > elapsed)
|
if (nextAICheckDelay > elapsed)
|
||||||
nextAICheckDelay -= elapsed;
|
nextAICheckDelay -= elapsed;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32 nextAICheckDelay;
|
uint32 nextAICheckDelay;
|
||||||
|
class PerformanceMonitorOperation* totalPmo = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _isBotAI;
|
bool _isBotAI;
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ double botPIDImpl::calculate(double setpoint, double pv)
|
|||||||
|
|
||||||
botPIDImpl::~botPIDImpl() {}
|
botPIDImpl::~botPIDImpl() {}
|
||||||
|
|
||||||
RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder(), processTicks(0), totalPmo(nullptr)
|
RandomPlayerbotMgr::RandomPlayerbotMgr() : PlayerbotHolder(), processTicks(0)
|
||||||
{
|
{
|
||||||
playersLevel = sPlayerbotAIConfig->randombotStartingLevel;
|
playersLevel = sPlayerbotAIConfig->randombotStartingLevel;
|
||||||
|
|
||||||
|
|||||||
@@ -204,7 +204,6 @@ private:
|
|||||||
std::list<uint32> currentBots;
|
std::list<uint32> currentBots;
|
||||||
uint32 bgBotsCount;
|
uint32 bgBotsCount;
|
||||||
uint32 playersLevel;
|
uint32 playersLevel;
|
||||||
PerformanceMonitorOperation* totalPmo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define sRandomPlayerbotMgr RandomPlayerbotMgr::instance()
|
#define sRandomPlayerbotMgr RandomPlayerbotMgr::instance()
|
||||||
|
|||||||
@@ -83,6 +83,16 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strcmp(args, "toggle"))
|
||||||
|
{
|
||||||
|
sPlayerbotAIConfig->perfMonEnabled = !sPlayerbotAIConfig->perfMonEnabled;
|
||||||
|
if (sPlayerbotAIConfig->perfMonEnabled)
|
||||||
|
LOG_INFO("playerbots", "Performance monitor enabled");
|
||||||
|
else
|
||||||
|
LOG_INFO("playerbots", "Performance monitor disabled");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
sPerformanceMonitor->PrintStats();
|
sPerformanceMonitor->PrintStats();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user