Skip to content

Commit b5f6d65

Browse files
committed
[ZH] Fix iterator errors for Zero Hour build (TheSuperHackers#426)
1 parent c6b4924 commit b5f6d65

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RailroadGuideAIUpdate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ class RailroadBehavior : public PhysicsBehavior
265265
void FindPosByPathDistance( Coord3D *pos, const Real dist, const Real length, Bool setState = FALSE );
266266
void playImpactSound(Object *victim, const Coord3D *impactPosition);
267267

268-
TemplateNameIterator m_carriageTemplateNameIterator;
269268
StationTask m_nextStationTask;
270269
ObjectID m_trailerID; ///< the ID of the object I am directly pulling
271270
PullInfo conductorPullInfo;

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,9 @@ ObjectID CountermeasuresBehavior::calculateCountermeasureToDivertTo( const Objec
166166

167167
//Start at the end of the list and go towards the beginning.
168168
CountermeasuresVec::iterator it = m_counterMeasures.end();
169+
DEBUG_ASSERTCRASH(iteratorMax <= (Int)m_counterMeasures.size(), ("Unsafe size"));
169170
//end is actually the end so advance the iterator.
170-
if( it )
171+
if( it != m_counterMeasures.begin() )
171172
{
172173
--it;
173174
while( iteratorMax-- )

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ FlightDeckBehavior::FlightDeckInfo* FlightDeckBehavior::findPPI(ObjectID id)
405405
for (std::vector<FlightDeckInfo>::iterator it = m_spaces.begin(); it != m_spaces.end(); ++it)
406406
{
407407
if (it->m_objectInSpace == id)
408-
return it;
408+
return &(*it);
409409
}
410410

411411
return NULL;
@@ -420,7 +420,7 @@ FlightDeckBehavior::FlightDeckInfo* FlightDeckBehavior::findEmptyPPI()
420420
for (std::vector<FlightDeckInfo>::iterator it = m_spaces.begin(); it != m_spaces.end(); ++it)
421421
{
422422
if( it->m_objectInSpace == INVALID_ID )
423-
return it;
423+
return &(*it);
424424
}
425425

426426
return NULL;
@@ -880,7 +880,7 @@ Bool FlightDeckBehavior::calcBestParkingAssignment( ObjectID id, Coord3D *pos, I
880880
//the back and keep looking at empty spaces until we find one with a plane blocking.
881881

882882
Bool checkForPlaneInWay = FALSE;
883-
std::vector<FlightDeckInfo>::iterator bestIt = NULL;
883+
std::vector<FlightDeckInfo>::iterator bestIt = m_spaces.end();
884884
Object *bestJet = NULL;
885885
Int bestIndex = 0, index = 0;
886886
for( std::vector<FlightDeckInfo>::iterator thatIt = m_spaces.begin(); thatIt != m_spaces.end(); thatIt++, index++ )
@@ -889,7 +889,7 @@ Bool FlightDeckBehavior::calcBestParkingAssignment( ObjectID id, Coord3D *pos, I
889889
if( myIt == thatIt )
890890
{
891891
//Done, don't look at my spot, nor spots behind me.
892-
if( bestIt )
892+
if( bestIt != m_spaces.end() )
893893
{
894894
myIt->m_objectInSpace = bestJet ? bestJet->getID() : INVALID_ID;
895895
bestIt->m_objectInSpace = id;
@@ -941,7 +941,7 @@ Bool FlightDeckBehavior::calcBestParkingAssignment( ObjectID id, Coord3D *pos, I
941941
if( pos )
942942
{
943943
pos->set( &myIt->m_prep ); //reset the original position.
944-
bestIt = NULL;
944+
bestIt = m_spaces.end();
945945
}
946946
}
947947
}
@@ -1356,7 +1356,7 @@ void FlightDeckBehavior::exitObjectViaDoor( Object *newObj, ExitDoorType exitDoo
13561356
return;
13571357
}
13581358

1359-
newObj->setPosition( pCreationLocations->begin() );
1359+
newObj->setPosition( &(*pCreationLocations)[0] );
13601360
newObj->setOrientation( m_runways[ ppi->m_runway ].m_startOrient );
13611361
TheAI->pathfinder()->addObjectToPathfindMap( newObj );
13621362

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ class JetOrHeliTaxiState : public AIMoveOutOfTheWayState
549549
std::vector<Coord3D>::const_iterator it;
550550
for( it = pTaxiLocations->begin(); it != pTaxiLocations->end(); it++ )
551551
{
552-
movePath->appendNode( it, LAYER_GROUND );
552+
movePath->appendNode( &(*it), LAYER_GROUND );
553553
}
554554
}
555555

@@ -617,7 +617,7 @@ class JetOrHeliTaxiState : public AIMoveOutOfTheWayState
617617
firstNode = FALSE;
618618
continue;
619619
}
620-
movePath->appendNode( it, LAYER_GROUND );
620+
movePath->appendNode( &(*it), LAYER_GROUND );
621621
}
622622
movePath->appendNode( &ppinfo.runwayPrep, LAYER_GROUND );
623623
}

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ RailroadBehavior::RailroadBehavior( Thing *thing, const ModuleData *moduleData )
107107
{
108108
const RailroadBehaviorModuleData *modData = getRailroadBehaviorModuleData();
109109

110-
m_carriageTemplateNameIterator = 0;
111-
112110
m_nextStationTask = DO_NOTHING;
113111
m_trailerID = INVALID_ID;
114112

0 commit comments

Comments
 (0)