Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions Generals/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +3491 to +3493

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you went a bit wrong here, shouldn't it be like

#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.
bounds->hi.x = bounds->lo.x = bounds->hi.y = bounds->lo.x = 0;
objBounds.hi.x = objBounds.lo.x = objBounds.hi.y = objBounds.lo.x = 0;
else
bounds.zero();
objBounds.zero();
#endif

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That leaves lo.y uninitialized with retail compatibility enabled and that's not the intention here.

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) {
Comment thread
Caball009 marked this conversation as resolved.
for (DLINK_ITERATOR<Team> iter = (*it)->iterate_TeamInstanceList(); !iter.done(); iter.advance()) {
Team *team = iter.cur();
if (!team) continue;
Expand Down
21 changes: 13 additions & 8 deletions GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Team> iter = (*it)->iterate_TeamInstanceList(); !iter.done(); iter.advance())
{
Expand Down
Loading