Skip to content

Commit 30c2289

Browse files
authored
[GEN][ZH] Fix crash when using a Civilian Ferry that has no waypoint path (#1222)
1 parent ee9debf commit 30c2289

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailedTransportAIUpdate.cpp

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,28 @@ UpdateSleepTime RailedTransportAIUpdate::update( void )
229229
// sanity
230230
DEBUG_ASSERTCRASH( waypoint, ("RailedTransportAIUpdate: Invalid target waypoint\n") );
231231

232-
// how far away are we from the target waypoint
233-
const Coord3D *start = us->getPosition();
234-
const Coord3D *end = waypoint->getLocation();
235-
Coord3D v;
236-
v.x = end->x - start->x;
237-
v.y = end->y - start->y;
238-
v.z = end->z - start->z;
239-
Real dist = v.length();
240-
if( dist <= 5.0f || isIdle() )
232+
if (waypoint)
241233
{
234+
// how far away are we from the target waypoint
235+
const Coord3D *start = us->getPosition();
236+
const Coord3D *end = waypoint->getLocation();
237+
Coord3D v;
238+
v.x = end->x - start->x;
239+
v.y = end->y - start->y;
240+
v.z = end->z - start->z;
241+
Real dist = v.length();
242+
if( dist <= 5.0f || isIdle() )
243+
{
242244

243-
// we are no longer in transit
244-
setInTransit( FALSE );
245+
// we are no longer in transit
246+
setInTransit( FALSE );
245247

246-
} // end if
248+
} // end if
249+
}
250+
else
251+
{
252+
setInTransit( FALSE );
253+
}
247254

248255
} // end if
249256

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -229,21 +229,28 @@ UpdateSleepTime RailedTransportAIUpdate::update( void )
229229
// sanity
230230
DEBUG_ASSERTCRASH( waypoint, ("RailedTransportAIUpdate: Invalid target waypoint\n") );
231231

232-
// how far away are we from the target waypoint
233-
const Coord3D *start = us->getPosition();
234-
const Coord3D *end = waypoint->getLocation();
235-
Coord3D v;
236-
v.x = end->x - start->x;
237-
v.y = end->y - start->y;
238-
v.z = end->z - start->z;
239-
Real dist = v.length();
240-
if( dist <= 5.0f || isIdle() )
232+
if (waypoint)
241233
{
234+
// how far away are we from the target waypoint
235+
const Coord3D *start = us->getPosition();
236+
const Coord3D *end = waypoint->getLocation();
237+
Coord3D v;
238+
v.x = end->x - start->x;
239+
v.y = end->y - start->y;
240+
v.z = end->z - start->z;
241+
Real dist = v.length();
242+
if( dist <= 5.0f || isIdle() )
243+
{
242244

243-
// we are no longer in transit
244-
setInTransit( FALSE );
245+
// we are no longer in transit
246+
setInTransit( FALSE );
245247

246-
} // end if
248+
} // end if
249+
}
250+
else
251+
{
252+
setInTransit( FALSE );
253+
}
247254

248255
} // end if
249256

0 commit comments

Comments
 (0)