Skip to content

Commit 98de109

Browse files
committed
bugfix(ghostobject): Fix crash in W3DGhostObjectManager::updateOrphanedObjects (#1569)
1 parent 9ee190c commit 98de109

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Generals/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,12 +977,14 @@ void W3DGhostObjectManager::updateOrphanedObjects(int *playerIndexList, int play
977977

978978
if (playerIndexList != NULL && playerIndexCount > 0)
979979
{
980-
for (int i=0; i<playerIndexCount; i++, playerIndexList++)
980+
int* playerIndex = playerIndexList;
981+
int* const playerIndexEnd = playerIndexList + playerIndexCount;
982+
for (; playerIndex < playerIndexEnd; ++playerIndex)
981983
{
982-
if (mod->m_parentSnapshots[*playerIndexList])
983-
mod->getShroudStatus(*playerIndexList);
984+
if (mod->m_parentSnapshots[*playerIndex])
985+
mod->getShroudStatus(*playerIndex);
984986

985-
if (mod->m_parentSnapshots[*playerIndexList])
987+
if (mod->m_parentSnapshots[*playerIndex])
986988
numStoredSnapshots++;
987989
}
988990
}

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,12 +981,14 @@ void W3DGhostObjectManager::updateOrphanedObjects(int *playerIndexList, int play
981981

982982
if (playerIndexList != NULL && playerIndexCount > 0)
983983
{
984-
for (int i=0; i<playerIndexCount; i++, playerIndexList++)
984+
int* playerIndex = playerIndexList;
985+
int* const playerIndexEnd = playerIndexList + playerIndexCount;
986+
for (; playerIndex < playerIndexEnd; ++playerIndex)
985987
{
986-
if (mod->m_parentSnapshots[*playerIndexList])
987-
mod->getShroudStatus(*playerIndexList);
988+
if (mod->m_parentSnapshots[*playerIndex])
989+
mod->getShroudStatus(*playerIndex);
988990

989-
if (mod->m_parentSnapshots[*playerIndexList])
991+
if (mod->m_parentSnapshots[*playerIndex])
990992
numStoredSnapshots++;
991993
}
992994
}

0 commit comments

Comments
 (0)