diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp index 151fc16bec3..a52eec59dae 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp @@ -3486,18 +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; +#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; - bounds->hi.x = bounds->lo.x = bounds->hi.y = bounds->lo.x = 0; 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; - 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; 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()) {