From 4211553c4b3e6ddc80dabe4ef8018372e6a4e36f Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sun, 4 Oct 2026 23:22:49 +0200 Subject: [PATCH 1/3] Added zero initialization. --- Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 151fc16bec3..2761cd5c46c 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3491,9 +3491,12 @@ void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) Player::PlayerTeamList::const_iterator it; Bool firstObject = true; Bool firstStructure = true; - bounds->hi.x = bounds->lo.x = bounds->hi.y = bounds->lo.x = 0; +#if RTS_GENERALS && RETAIL_COMPATIBLE_CRC + // TheSuperHackers @info In the Generals code, lo.y used to be uninitialized for both Region2D variables in this function. +#endif + bounds->zero(); Region2D objBounds; - objBounds.hi.x = objBounds.lo.x = objBounds.hi.y = objBounds.lo.x = 0; + objBounds.zero(); Player* pPlayer = ThePlayerList->getNthPlayer(playerNdx); if (pPlayer == nullptr) return; From 25a6cc5022d1fe0e00bd775380fdad6566ea6f85 Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sun, 4 Oct 2026 23:25:52 +0200 Subject: [PATCH 2/3] Refactored surrounding code. --- .../GameEngine/Source/GameLogic/AI/AIPlayer.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 2761cd5c46c..a52eec59dae 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3486,21 +3486,24 @@ void WorkOrder::loadPostProcess() /** * Get the bounds for a player's structure. */ -void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx ) +void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx) { - Player::PlayerTeamList::const_iterator it; - Bool firstObject = true; - Bool firstStructure = true; #if RTS_GENERALS && RETAIL_COMPATIBLE_CRC // TheSuperHackers @info In the Generals code, lo.y used to be uninitialized for both Region2D variables in this function. #endif bounds->zero(); + + Player* pPlayer = ThePlayerList->getNthPlayer(playerNdx); + if (pPlayer == nullptr) + return; + + Bool firstObject = true; + Bool firstStructure = true; Region2D objBounds; objBounds.zero(); - Player* pPlayer = ThePlayerList->getNthPlayer(playerNdx); - if (pPlayer == nullptr) return; - for (it = pPlayer->getPlayerTeams()->begin(); it != pPlayer->getPlayerTeams()->end(); ++it) { + const Player::PlayerTeamList& list = *pPlayer->getPlayerTeams(); + for (Player::PlayerTeamList::const_iterator it = list.begin(); it != list.end(); ++it) { for (DLINK_ITERATOR iter = (*it)->iterate_TeamInstanceList(); !iter.done(); iter.advance()) { Team *team = iter.cur(); if (!team) continue; From fac88a190b3252fd6b9d33a6e6e193a896c079ae Mon Sep 17 00:00:00 2001 From: Caball009 <82909616+Caball009@users.noreply.github.com> Date: Sun, 4 Oct 2026 23:26:31 +0200 Subject: [PATCH 3/3] Replicated to Zero Hour. --- .../Source/GameLogic/AI/AIPlayer.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 0e98e434910..221345d9f81 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3819,19 +3819,24 @@ void WorkOrder::loadPostProcess() /** * Get the bounds for a player's structure. */ -void AIPlayer::getPlayerStructureBounds( Region2D *bounds, Int playerNdx, Bool conservative ) +void AIPlayer::getPlayerStructureBounds(Region2D *bounds, Int playerNdx, Bool conservative) { - Player::PlayerTeamList::const_iterator it; - Bool firstObject = true; - Bool firstStructure = true; - bounds->hi.x = bounds->lo.x = bounds->hi.y = bounds->lo.y = 0; - Region2D objBounds; - objBounds.hi.x = objBounds.lo.x = objBounds.hi.y = objBounds.lo.y = 0; +#if RTS_GENERALS && RETAIL_COMPATIBLE_CRC + // TheSuperHackers @info In the Generals code, lo.y used to be uninitialized for both Region2D variables in this function. +#endif + bounds->zero(); Player* pPlayer = ThePlayerList->getNthPlayer(playerNdx); if (pPlayer == nullptr) return; - for (it = pPlayer->getPlayerTeams()->begin(); it != pPlayer->getPlayerTeams()->end(); ++it) + + Bool firstObject = true; + Bool firstStructure = true; + Region2D objBounds; + objBounds.zero(); + + const Player::PlayerTeamList& list = *pPlayer->getPlayerTeams(); + for (Player::PlayerTeamList::const_iterator it = list.begin(); it != list.end(); ++it) { for (DLINK_ITERATOR iter = (*it)->iterate_TeamInstanceList(); !iter.done(); iter.advance()) {