From 3b82a3d903e108c2b105bcb0e5a723d19a1d8bf0 Mon Sep 17 00:00:00 2001 From: Alan Date: Sun, 7 Apr 2019 08:19:45 -0300 Subject: [PATCH] fix(Core/Battlegrounds): log errors about creatures not found (#1587) --- src/server/game/AI/SmartScripts/SmartScript.cpp | 6 ++---- .../game/Battlegrounds/Zones/BattlegroundAV.cpp | 2 +- .../game/Battlegrounds/Zones/BattlegroundIC.cpp | 17 ++++++++--------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 3aca8fd9c..4a17a872a 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -4295,6 +4295,8 @@ void SmartScript::OnUpdate(uint32 const diff) void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTrigger const* at) { + (void)at; // ensure that the variable is referenced even if extra logs are disabled in order to pass compiler checks + if (e.empty()) { #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) @@ -4326,10 +4328,6 @@ void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTrigger c } mEvents.push_back((*i));//NOTE: 'world(0)' events still get processed in ANY instance mode } - if (mEvents.empty() && obj) - sLog->outErrorDb("SmartScript: Entry %u has events but no events added to list because of instance flags.", obj->GetEntry()); - if (mEvents.empty() && at) - sLog->outErrorDb("SmartScript: AreaTrigger %u has events but no events added to list because of instance flags. NOTE: triggers can not handle any instance flags.", at->entry); } void SmartScript::GetScript() diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 9fe959232..67c01114a 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -782,7 +782,7 @@ void BattlegroundAV::PopulateNode(BG_AV_Nodes node) if (node >= BG_AV_NODES_MAX)//fail safe return; - Creature* trigger = GetBGCreature(node + 302);//0-302 other creatures + Creature* trigger = GetBgMap()->GetCreature(BgCreatures[node + 302]);//0-302 other creatures if (!trigger) { trigger = AddCreature(WORLD_TRIGGER, diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp index fc2a6fcb1..62ff8c717 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp @@ -122,7 +122,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) for (uint8 j = 0; j < MAX_CATAPULTS_SPAWNS_PER_FACTION; ++j) { uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+j; - if (Creature* catapult = GetBGCreature(type)) + if (Creature* catapult = GetBgMap()->GetCreature(BgCreatures[type])) if (!catapult->IsAlive()) { // Check if creature respawn time is properly saved @@ -140,7 +140,7 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) for (uint8 j = 0; j < MAX_GLAIVE_THROWERS_SPAWNS_PER_FACTION; ++j) { uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+j; - if (Creature* glaiveThrower = GetBGCreature(type)) + if (Creature* glaiveThrower = GetBgMap()->GetCreature(BgCreatures[type])) if (!glaiveThrower->IsAlive()) { // Check if creature respawn time is properly saved @@ -185,9 +185,8 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff) // we need to confirm this, i am not sure if this every 3 minutes for (uint8 u = 0; u < MAX_DEMOLISHERS_SPAWNS_PER_FACTION; ++u) { - uint8 type = (nodePoint[i].faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H)+u; - if (Creature* demolisher = GetBGCreature(type)) + if (Creature* demolisher = GetBgMap()->GetCreature(BgCreatures[type])) if (!demolisher->IsAlive()) { // Check if creature respawn time is properly saved @@ -802,7 +801,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) { uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_GLAIVE_THROWER_1_A : BG_IC_NPC_GLAIVE_THROWER_1_H)+i; - if (GetBGCreature(type)) + if (GetBgMap()->GetCreature(BgCreatures[type])) continue; if (AddCreature(nodePoint->faction == TEAM_ALLIANCE ? NPC_GLAIVE_THROWER_A : NPC_GLAIVE_THROWER_H, type, @@ -817,7 +816,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) { uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_CATAPULT_1_A : BG_IC_NPC_CATAPULT_1_H)+i; - if (GetBGCreature(type)) + if (GetBgMap()->GetCreature(BgCreatures[type])) continue; if (AddCreature(NPC_CATAPULT, type, @@ -838,7 +837,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) { uint8 type = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_DEMOLISHER_1_A : BG_IC_NPC_DEMOLISHER_1_H)+i; - if (GetBGCreature(type)) + if (GetBgMap()->GetCreature(BgCreatures[type])) continue; if (AddCreature(NPC_DEMOLISHER, type, @@ -849,7 +848,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) } uint8 siegeType = (nodePoint->faction == TEAM_ALLIANCE ? BG_IC_NPC_SIEGE_ENGINE_A : BG_IC_NPC_SIEGE_ENGINE_H); - if (!GetBGCreature(siegeType)) + if (!GetBgMap()->GetCreature(BgCreatures[siegeType])) { AddCreature((nodePoint->faction == TEAM_ALLIANCE ? NPC_SIEGE_ENGINE_A : NPC_SIEGE_ENGINE_H), siegeType, BG_IC_WorkshopVehicles[4].GetPositionX(), BG_IC_WorkshopVehicles[4].GetPositionY(), @@ -857,7 +856,7 @@ void BattlegroundIC::HandleCapturedNodes(ICNodePoint* nodePoint, bool recapture) RESPAWN_ONE_DAY); } - if (Creature* siegeEngine = GetBGCreature(siegeType)) + if (Creature* siegeEngine = GetBgMap()->GetCreature(BgCreatures[siegeType])) { siegeEngine->setFaction(BG_IC_Factions[(nodePoint->faction == TEAM_ALLIANCE ? 0 : 1)]); siegeEngine->SetCorpseDelay(5*MINUTE);