From a4fe45afbbbb9f5fec3fbc4d74732fd095e747b8 Mon Sep 17 00:00:00 2001 From: valsan-azerty-boi <52854501+valsan-azerty-boi@users.noreply.github.com> Date: Tue, 4 Mar 2025 20:35:36 +0100 Subject: [PATCH] Fix server crash when bots apply strategies on a custom naxx raid (#1052) --- .../updates/db_playerbots/2025_03_03_00.sql | 12 ++++++++++++ .../raids/naxxramas/RaidNaxxActions.cpp | 18 +++++++++++++++--- .../raids/naxxramas/RaidNaxxMultipliers.cpp | 5 ++++- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 data/sql/playerbots/updates/db_playerbots/2025_03_03_00.sql diff --git a/data/sql/playerbots/updates/db_playerbots/2025_03_03_00.sql b/data/sql/playerbots/updates/db_playerbots/2025_03_03_00.sql new file mode 100644 index 00000000..cc1f4f0e --- /dev/null +++ b/data/sql/playerbots/updates/db_playerbots/2025_03_03_00.sql @@ -0,0 +1,12 @@ +INSERT INTO `playerbots_travelnode` (`id`, `name`, `map_id`, `x`, `y`, `z`, `linked`) VALUES +(3780, 'Highlord Mograine', 533, 2524.32, -2951.28, 245.633, 1); + +INSERT INTO `playerbots_travelnode_path` (`node_id`, `to_node_id`, `nr`, `map_id`, `x`, `y`, `z`) VALUES +(3780, 472, 0, 533, 2524.32, -2951.28, 245.633), +(3780, 472, 1, 533, 2528.79, -2948.58, 245.633), +(3780, 757, 0, 533, 2524.32, -2951.28, 245.633), +(3780, 757, 1, 533, 2517.62, -2959.38, 245.636); + +INSERT INTO `playerbots_travelnode_link` (`node_id`, `to_node_id`, `type`, `object`, `distance`, `swim_distance`, `extra_cost`, `calculated`, `max_creature_0`, `max_creature_1`, `max_creature_2`) VALUES +(3780, 472, 1, 0, 5.3221, 0, 0, 1, 83, 0, 0), +(3780, 757, 1, 0, 10.6118, 0, 0, 1, 83, 0, 0); diff --git a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp index 59ae048e..cf12bb8e 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxActions.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxActions.cpp @@ -52,6 +52,10 @@ uint32 GrobbulusRotateAction::GetCurrWaypoint() return false; } auto* boss_ai = dynamic_cast(boss->GetAI()); + if (!boss_ai || boss_ai->events.Empty()) + { + return false; + } EventMap* eventMap = &boss_ai->events; const uint32 event_time = eventMap->GetNextEventTime(2); return (event_time / 15000) % intervals; @@ -65,6 +69,10 @@ bool HeiganDanceAction::CalculateSafe() return false; } auto* boss_ai = dynamic_cast(boss->GetAI()); + if (!boss_ai || boss_ai->events.Empty()) + { + return false; + } EventMap* eventMap = &boss_ai->events; uint32 curr_phase = boss_ai->currentPhase; uint32 curr_erupt = eventMap->GetNextEventTime(3); @@ -423,17 +431,21 @@ bool HorsemanAttactInOrderAction::Execute(Event event) } Unit* target = nullptr; Unit* thane = AI_VALUE2(Unit*, "find target", "thane korth'azz"); - Unit* baron = AI_VALUE2(Unit*, "find target", "baron rivendare"); Unit* lady = AI_VALUE2(Unit*, "find target", "lady blaumeux"); Unit* sir = AI_VALUE2(Unit*, "find target", "sir zeliek"); + Unit* fourth = AI_VALUE2(Unit*, "find target", "baron rivendare"); + if (!fourth) + { + fourth = AI_VALUE2(Unit*, "find target", "highlord mograine"); + } std::vector attack_order; if (botAI->IsAssistTank(bot)) { - attack_order = {baron, thane, lady, sir}; + attack_order = {fourth, thane, lady, sir}; } else { - attack_order = {thane, baron, lady, sir}; + attack_order = {thane, fourth, lady, sir}; } for (Unit* t : attack_order) { diff --git a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp index ac758559..78ceaefc 100644 --- a/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp +++ b/src/strategy/raids/naxxramas/RaidNaxxMultipliers.cpp @@ -41,8 +41,11 @@ float HeiganDanceMultiplier::GetValue(Action* action) { return 1.0f; } - auto* boss_ai = dynamic_cast(boss->GetAI()); + if (!boss_ai || boss_ai->events.Empty()) + { + return 1.0f; + } EventMap* eventMap = &boss_ai->events; uint32 curr_phase = boss_ai->currentPhase; uint32 curr_dance = eventMap->GetNextEventTime(4);