From 44e3f28cb0f8dddc4aafd97bcef8949049431a99 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Mon, 2 Sep 2019 03:44:03 -0500 Subject: [PATCH] Logs::AI to LogAI --- zone/bot.cpp | 4 ++-- zone/botspellsai.cpp | 10 +++++----- zone/merc.cpp | 6 +++--- zone/mob_ai.cpp | 35 ++++++++++++++--------------------- zone/spells.cpp | 10 +++++----- zone/waypoints.cpp | 26 +++++++++----------------- 6 files changed, 38 insertions(+), 53 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 8e63d1d9e..9244f08d2 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -2872,7 +2872,7 @@ void Bot::AI_Process() { else { // To far away to fight (GetTarget() validity can be iffy below this point - including outer scopes) if (AI_movement_timer->Check() && (!spellend_timer.Enabled() || GetClass() == BARD)) { // Pursue processing if (GetTarget() && !IsRooted()) { - Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); + LogAI("Pursuing [{}] while engaged", GetTarget()->GetCleanName()); Goal = GetTarget()->GetPosition(); @@ -3177,7 +3177,7 @@ void Bot::PetAIProcess() { else if (botPet->GetTarget() && botPet->GetAIMovementTimer()->Check()) { botPet->SetRunAnimSpeed(0); if(!botPet->IsRooted()) { - Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", botPet->GetTarget()->GetCleanName()); + LogAI("Pursuing [{}] while engaged", botPet->GetTarget()->GetCleanName()); botPet->RunTo(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ()); return; } else { diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index 3ec7e7202..1839e91e4 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -1134,7 +1134,7 @@ bool Bot::AI_PursueCastCheck() { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log(Logs::Detail, Logs::AI, "Bot Engaged (pursuing) autocast check triggered. Trying to cast offensive spells."); + LogAI("Bot Engaged (pursuing) autocast check triggered. Trying to cast offensive spells"); if(!AICastSpell(GetTarget(), 100, SpellType_Snare)) { if(!AICastSpell(GetTarget(), 100, SpellType_Lifetap)) { @@ -1162,7 +1162,7 @@ bool Bot::AI_IdleCastCheck() { if (AIautocastspell_timer->Check(false)) { #if BotAI_DEBUG_Spells >= 25 - Log(Logs::Detail, Logs::AI, "Bot Non-Engaged autocast check triggered: %s", this->GetCleanName()); + LogAI("Bot Non-Engaged autocast check triggered: [{}]", this->GetCleanName()); #endif AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. @@ -1310,7 +1310,7 @@ bool Bot::AI_EngagedCastCheck() { EQEmu::constants::StanceType botStance = GetBotStance(); bool mayGetAggro = HasOrMayGetAggro(); - Log(Logs::Detail, Logs::AI, "Engaged autocast check triggered (BOTS). Trying to cast healing spells then maybe offensive spells."); + LogAI("Engaged autocast check triggered (BOTS). Trying to cast healing spells then maybe offensive spells"); if(botClass == CLERIC) { if(!AICastSpell(GetTarget(), GetChanceToCastBySpellType(SpellType_Escape), SpellType_Escape)) { @@ -1560,11 +1560,11 @@ bool Bot::AIHealRotation(Mob* tar, bool useFastHeals) { } #if BotAI_DEBUG_Spells >= 10 - Log(Logs::Detail, Logs::AI, "Bot::AIHealRotation: heal spellid = %u, fastheals = %c, casterlevel = %u", + LogAI("Bot::AIHealRotation: heal spellid = [{}], fastheals = [{}], casterlevel = [{}]", botSpell.SpellId, ((useFastHeals) ? ('T') : ('F')), GetLevel()); #endif #if BotAI_DEBUG_Spells >= 25 - Log(Logs::Detail, Logs::AI, "Bot::AIHealRotation: target = %s, current_time = %u, donthealmebefore = %u", tar->GetCleanName(), Timer::GetCurrentTime(), tar->DontHealMeBefore()); + LogAI("Bot::AIHealRotation: target = [{}], current_time = [{}], donthealmebefore = [{}]", tar->GetCleanName(), Timer::GetCurrentTime(), tar->DontHealMeBefore()); #endif // If there is still no spell id, then there isn't going to be one so we are done diff --git a/zone/merc.cpp b/zone/merc.cpp index 86db4a16d..365e442ee 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1688,7 +1688,7 @@ void Merc::AI_Process() { if (AI_movement_timer->Check()) { if(!IsRooted()) { - Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName()); + LogAI("Pursuing [{}] while engaged", GetTarget()->GetCleanName()); RunTo(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ()); return; } @@ -1807,7 +1807,7 @@ bool Merc::AI_EngagedCastCheck() { { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log(Logs::Detail, Logs::AI, "Merc Engaged autocast check triggered"); + LogAI("Merc Engaged autocast check triggered"); int8 mercClass = GetClass(); @@ -1862,7 +1862,7 @@ bool Merc::AI_IdleCastCheck() { if (AIautocastspell_timer->Check(false)) { #if MercAI_DEBUG_Spells >= 25 - Log(Logs::Detail, Logs::AI, "Merc Non-Engaged autocast check triggered: %s", this->GetCleanName()); + LogAI("Merc Non-Engaged autocast check triggered: [{}]", this->GetCleanName()); #endif AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index cc00db01a..4546b5c45 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -127,7 +127,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes, bool bInnates ) { #if MobAI_DEBUG_Spells >= 21 - Log(Logs::Detail, Logs::AI, "Mob::AICastSpell: Casting: spellid=%u, tar=%s, dist2[%f]<=%f, mana_cost[%i]<=%i, cancast[%u]<=%u, type=%u", + LogAI("Mob::AICastSpell: Casting: spellid=[{}], tar=[{}], dist2[[{}]]<=[{}], mana_cost[[{}]]<=[{}], cancast[[{}]]<=[{}], type=[{}]", AIspells[i].spellid, tar->GetName(), dist2, (spells[AIspells[i].spellid].range * spells[AIspells[i].spellid].range), mana_cost, GetMana(), AIspells[i].time_cancast, Timer::GetCurrentTime(), AIspells[i].type); #endif @@ -360,7 +360,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes, bool bInnates } #if MobAI_DEBUG_Spells >= 21 else { - Log(Logs::Detail, Logs::AI, "Mob::AICastSpell: NotCasting: spellid=%u, tar=%s, dist2[%f]<=%f, mana_cost[%i]<=%i, cancast[%u]<=%u, type=%u", + LogAI("Mob::AICastSpell: NotCasting: spellid=[{}], tar=[{}], dist2[[{}]]<=[{}], mana_cost[[{}]]<=[{}], cancast[[{}]]<=[{}], type=[{}]", AIspells[i].spellid, tar->GetName(), dist2, (spells[AIspells[i].spellid].range * spells[AIspells[i].spellid].range), mana_cost, GetMana(), AIspells[i].time_cancast, Timer::GetCurrentTime(), AIspells[i].type); } #endif @@ -371,7 +371,7 @@ bool NPC::AICastSpell(Mob* tar, uint8 iChance, uint32 iSpellTypes, bool bInnates bool NPC::AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgainBefore) { #if MobAI_DEBUG_Spells >= 1 - Log(Logs::Detail, Logs::AI, "Mob::AIDoSpellCast: spellid = %u, tar = %s, mana = %i, Name: '%s'", AIspells[i].spellid, tar->GetName(), mana_cost, spells[AIspells[i].spellid].name); + LogAI("Mob::AIDoSpellCast: spellid = [{}], tar = [{}], mana = [{}], Name: [{}]", AIspells[i].spellid, tar->GetName(), mana_cost, spells[AIspells[i].spellid].name); #endif casting_spell_AIindex = i; @@ -1356,7 +1356,7 @@ void Mob::AI_Process() { } else if (AI_movement_timer->Check() && target) { if (!IsRooted()) { - Log(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", target->GetName()); + LogAI("Pursuing [{}] while engaged", target->GetName()); RunTo(target->GetX(), target->GetY(), target->GetZ()); } @@ -1721,9 +1721,7 @@ void NPC::AI_DoMovement() { else if (!(AI_walking_timer->Enabled())) { // currently moving bool doMove = true; if(IsPositionEqual(glm::vec2(m_CurrentWayPoint.x, m_CurrentWayPoint.y), glm::vec2(GetX(), GetY()))) { - Log(Logs::Detail, - Logs::AI, - "We have reached waypoint %d (%.3f,%.3f,%.3f) on grid %d", + LogAI("We have reached waypoint [{}] ({},{},{}) on grid [{}]", cur_wp, GetX(), GetY(), @@ -1790,12 +1788,7 @@ void NPC::AI_DoMovement() { if (at_gp) { if (moved) { - Log(Logs::Detail, - Logs::AI, - "Reached guard point (%.3f,%.3f,%.3f)", - m_GuardPoint.x, - m_GuardPoint.y, - m_GuardPoint.z); + LogAI("Reached guard point ({},{},{})", m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z); ClearFeignMemory(); moved = false; @@ -1983,7 +1976,7 @@ bool NPC::AI_EngagedCastCheck() { if (AIautocastspell_timer->Check(false)) { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log(Logs::Detail, Logs::AI, "Engaged autocast check triggered. Trying to cast healing spells then maybe offensive spells."); + LogAI("Engaged autocast check triggered. Trying to cast healing spells then maybe offensive spells"); // first try innate (spam) spells if(!AICastSpell(GetTarget(), 0, SpellType_Nuke | SpellType_Lifetap | SpellType_DOT | SpellType_Dispel | SpellType_Mez | SpellType_Slow | SpellType_Debuff | SpellType_Charm | SpellType_Root, true)) { @@ -2012,7 +2005,7 @@ bool NPC::AI_PursueCastCheck() { if (AIautocastspell_timer->Check(false)) { AIautocastspell_timer->Disable(); //prevent the timer from going off AGAIN while we are casting. - Log(Logs::Detail, Logs::AI, "Engaged (pursuing) autocast check triggered. Trying to cast offensive spells."); + LogAI("Engaged (pursuing) autocast check triggered. Trying to cast offensive spells"); // checking innate (spam) spells first if(!AICastSpell(GetTarget(), AISpellVar.pursue_detrimental_chance, SpellType_Root | SpellType_Nuke | SpellType_Lifetap | SpellType_Snare | SpellType_DOT | SpellType_Dispel | SpellType_Mez | SpellType_Slow | SpellType_Debuff, true)) { if(!AICastSpell(GetTarget(), AISpellVar.pursue_detrimental_chance, SpellType_Root | SpellType_Nuke | SpellType_Lifetap | SpellType_Snare | SpellType_DOT | SpellType_Dispel | SpellType_Mez | SpellType_Slow | SpellType_Debuff)) { @@ -2507,21 +2500,21 @@ bool NPC::AI_AddNPCSpells(uint32 iDBSpellsID) { else { debug_msg.append(" (not found)"); } - Log(Logs::Detail, Logs::AI, "%s", debug_msg.c_str()); + LogAI("[{}]", debug_msg.c_str()); #ifdef MobAI_DEBUG_Spells >= 25 if (parentlist) { for (const auto &iter : parentlist->entries) { - Log(Logs::Detail, Logs::AI, "(%i) %s", iter.spellid, spells[iter.spellid].name); + LogAI("([{}]) [{}]", iter.spellid, spells[iter.spellid].name); } } - Log(Logs::Detail, Logs::AI, "fin (parent list)"); + LogAI("fin (parent list)"); if (spell_list) { for (const auto &iter : spell_list->entries) { - Log(Logs::Detail, Logs::AI, "(%i) %s", iter.spellid, spells[iter.spellid].name); + LogAI("([{}]) [{}]", iter.spellid, spells[iter.spellid].name); } } - Log(Logs::Detail, Logs::AI, "fin (spell list)"); + LogAI("fin (spell list)"); #endif #endif @@ -2682,7 +2675,7 @@ bool NPC::AI_AddNPCSpellsEffects(uint32 iDBSpellsEffectsID) { else { debug_msg.append(" (not found)"); } - Log(Logs::Detail, Logs::AI, "%s", debug_msg.c_str()); + LogAI("[{}]", debug_msg.c_str()); #endif if (parentlist) { diff --git a/zone/spells.cpp b/zone/spells.cpp index d4abd2057..4518a7419 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -395,7 +395,7 @@ bool Mob::DoCastSpell(uint16 spell_id, uint16 target_id, CastingSlot slot, } SaveSpellLoc(); - LogSpells("Casting [{}] Started at (%.3f,%.3f,%.3f)", spell_id, m_SpellLocation.x, m_SpellLocation.y, m_SpellLocation.z); + LogSpells("Casting [{}] Started at ({},{},{})", spell_id, m_SpellLocation.x, m_SpellLocation.y, m_SpellLocation.z); // if this spell doesn't require a target, or if it's an optional target // and a target wasn't provided, then it's us; unless TGB is on and this @@ -3358,7 +3358,7 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite) { int i, ret, firstfree = -2; - Log(Logs::Detail, Logs::AI, "Checking if buff %d cast at level %d can stack on me.%s", spellid, caster_level, iFailIfOverwrite?" failing if we would overwrite something":""); + LogAI("Checking if buff [{}] cast at level [{}] can stack on me.[{}]", spellid, caster_level, iFailIfOverwrite?" failing if we would overwrite something":""); int buff_count = GetMaxTotalSlots(); for (i=0; i < buff_count; i++) @@ -3382,7 +3382,7 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite) if(ret == 1) { // should overwrite current slot if(iFailIfOverwrite) { - Log(Logs::Detail, Logs::AI, "Buff %d would overwrite %d in slot %d, reporting stack failure", spellid, curbuf.spellid, i); + LogAI("Buff [{}] would overwrite [{}] in slot [{}], reporting stack failure", spellid, curbuf.spellid, i); return(-1); } if(firstfree == -2) @@ -3390,12 +3390,12 @@ int Mob::CanBuffStack(uint16 spellid, uint8 caster_level, bool iFailIfOverwrite) } if(ret == -1) { - Log(Logs::Detail, Logs::AI, "Buff %d would conflict with %d in slot %d, reporting stack failure", spellid, curbuf.spellid, i); + LogAI("Buff [{}] would conflict with [{}] in slot [{}], reporting stack failure", spellid, curbuf.spellid, i); return -1; // stop the spell, can't stack it } } - Log(Logs::Detail, Logs::AI, "Reporting that buff %d could successfully be placed into slot %d", spellid, firstfree); + LogAI("Reporting that buff [{}] could successfully be placed into slot [{}]", spellid, firstfree); return firstfree; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 0c6c97180..4942bdb11 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -179,19 +179,14 @@ void NPC::MoveTo(const glm::vec4 &position, bool saveguardspot) if (IsNPC() && GetGrid() != 0) { // he is on a grid if (GetGrid() < 0) { // currently stopped by a quest command SetGrid(0 - GetGrid()); // get him moving again - Log(Logs::Detail, - Logs::AI, - "MoveTo during quest wandering. Canceling quest wandering and going back to grid %d when MoveTo is done.", - GetGrid()); + LogAI("MoveTo during quest wandering. Canceling quest wandering and going back to grid [{}] when MoveTo is done", GetGrid()); } AI_walking_timer->Disable(); // disable timer in case he is paused at a wp if (cur_wp >= 0) { // we've not already done a MoveTo() save_wp = cur_wp; // save the current waypoint cur_wp = EQEmu::WaypointStatus::QuestControlGrid; } - Log(Logs::Detail, - Logs::AI, - "MoveTo %s, pausing regular grid wandering. Grid %d, save_wp %d", + LogAI("MoveTo [{}], pausing regular grid wandering. Grid [{}], save_wp [{}]", to_string(static_cast(position)).c_str(), -GetGrid(), save_wp); @@ -200,7 +195,7 @@ void NPC::MoveTo(const glm::vec4 &position, bool saveguardspot) roamer = true; save_wp = 0; cur_wp = EQEmu::WaypointStatus::QuestControlNoGrid; - Log(Logs::Detail, Logs::AI, "MoveTo %s without a grid.", to_string(static_cast(position)).c_str()); + LogAI("MoveTo [{}] without a grid", to_string(static_cast(position)).c_str()); } glm::vec3 dest(position); @@ -218,10 +213,7 @@ void NPC::MoveTo(const glm::vec4 &position, bool saveguardspot) if (m_GuardPoint.w == -1) m_GuardPoint.w = this->CalculateHeadingToTarget(position.x, position.y); - Log(Logs::Detail, - Logs::AI, - "Setting guard position to %s", - to_string(static_cast(m_GuardPoint)).c_str()); + LogAI("Setting guard position to [{}]", to_string(static_cast(m_GuardPoint)).c_str()); } cur_wp_pause = 0; @@ -234,7 +226,7 @@ void NPC::MoveTo(const glm::vec4 &position, bool saveguardspot) void NPC::UpdateWaypoint(int wp_index) { if (wp_index >= static_cast(Waypoints.size())) { - Log(Logs::Detail, Logs::AI, "Update to waypoint %d failed. Not found.", wp_index); + LogAI("Update to waypoint [{}] failed. Not found", wp_index); return; } std::vector::iterator cur; @@ -243,7 +235,7 @@ void NPC::UpdateWaypoint(int wp_index) m_CurrentWayPoint = glm::vec4(cur->x, cur->y, cur->z, cur->heading); cur_wp_pause = cur->pause; - Log(Logs::Detail, Logs::AI, "Next waypoint %d: (%.3f, %.3f, %.3f, %.3f)", wp_index, m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, m_CurrentWayPoint.w); + LogAI("Next waypoint [{}]: ({}, {}, {}, {})", wp_index, m_CurrentWayPoint.x, m_CurrentWayPoint.y, m_CurrentWayPoint.z, m_CurrentWayPoint.w); } @@ -431,7 +423,7 @@ void NPC::SaveGuardSpot(const glm::vec4 &pos) if (m_GuardPoint.w == 0) m_GuardPoint.w = 0.0001; //hack to make IsGuarding simpler - LogF(Logs::Detail, Logs::AI, "Setting guard position to {0}", to_string(static_cast(m_GuardPoint))); + LogAI("Setting guard position to {0}", to_string(static_cast(m_GuardPoint))); } void NPC::NextGuardPosition() { @@ -565,7 +557,7 @@ void Mob::SendTo(float new_x, float new_y, float new_z) { m_Position.x = new_x; m_Position.y = new_y; m_Position.z = new_z; - Log(Logs::Detail, Logs::AI, "Sent To (%.3f, %.3f, %.3f)", new_x, new_y, new_z); + LogAI("Sent To ({}, {}, {})", new_x, new_y, new_z); if (flymode == GravityBehavior::Flying) return; @@ -581,7 +573,7 @@ void Mob::SendTo(float new_x, float new_y, float new_z) { float newz = zone->zonemap->FindBestZ(dest, nullptr); - Log(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz, m_Position.x, m_Position.y, m_Position.z); + LogAI("BestZ returned {} at {}, {}, {}", newz, m_Position.x, m_Position.y, m_Position.z); if ((newz > -2000) && std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaSendTo)) // Sanity check. m_Position.z = newz + 1;