Skip to content

Commit b620e21

Browse files
authored
bugfix(object): Check whether a bike still has a rider before sniping it to prevent crashing the game (#1537)
1 parent 07be406 commit b620e21

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,13 @@ Bool ActionManager::canSnipeVehicle( const Object *obj, const Object *objectToSn
14311431
return FALSE;
14321432
}
14331433

1434+
// TheSuperHackers @bugfix Caball009 04/09/2025 Disabled bikes may not have a rider to snipe.
1435+
ContainModuleInterface* contain = objectToSnipe->getContain();
1436+
if ( contain && contain->isRiderChangeContain() && contain->getContainedItemsList()->empty() )
1437+
{
1438+
return FALSE;
1439+
}
1440+
14341441
return TRUE;
14351442
}
14361443

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,19 @@ void ActiveBody::attemptDamage( DamageInfo *damageInfo )
405405
}
406406
else
407407
{
408-
//Removing the rider will scuttle the bike.
409-
Object *rider = *(contain->getContainedItemsList()->begin());
410-
ai->aiEvacuateInstantly( TRUE, CMD_FROM_AI );
408+
// TheSuperHackers @bugfix Caball009 04/09/2025 Check whether a bike still has a rider.
409+
// A rider may dismount or be sniped off a bike when it's disabled, resulting in a bike object with an empty contain list.
410+
if ( !contain->getContainedItemsList()->empty() )
411+
{
412+
//Removing the rider will scuttle the bike.
413+
Object* rider = *(contain->getContainedItemsList()->begin());
414+
ai->aiEvacuateInstantly(TRUE, CMD_FROM_AI);
411415

412-
//Kill the rider.
413-
if (damager)
414-
damager->scoreTheKill( rider );
415-
rider->kill();
416+
//Kill the rider.
417+
if (damager)
418+
damager->scoreTheKill(rider);
419+
rider->kill();
420+
}
416421
}
417422
}
418423
else

0 commit comments

Comments
 (0)