mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-20 02:42:42 +01:00
Add: [Script] Include number of victims in ScriptEventVehicleCrashed (#12861)
This commit is contained in:
@@ -3086,9 +3086,9 @@ void Train::ReserveTrackUnderConsist() const
|
||||
*/
|
||||
uint Train::Crash(bool flooded)
|
||||
{
|
||||
uint pass = 0;
|
||||
uint victims = 0;
|
||||
if (this->IsFrontEngine()) {
|
||||
pass += 2; // driver
|
||||
victims += 2; // driver
|
||||
|
||||
/* Remove the reserved path in front of the train if it is not stuck.
|
||||
* Also clear all reserved tracks the train is currently on. */
|
||||
@@ -3111,10 +3111,10 @@ uint Train::Crash(bool flooded)
|
||||
HideFillingPercent(&this->fill_percent_te_id);
|
||||
}
|
||||
|
||||
pass += this->GroundVehicleBase::Crash(flooded);
|
||||
victims += this->GroundVehicleBase::Crash(flooded);
|
||||
|
||||
this->crash_anim_pos = flooded ? 4000 : 1; // max 4440, disappear pretty fast when flooded
|
||||
return pass;
|
||||
return victims;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3125,20 +3125,20 @@ uint Train::Crash(bool flooded)
|
||||
*/
|
||||
static uint TrainCrashed(Train *v)
|
||||
{
|
||||
uint num = 0;
|
||||
uint victims = 0;
|
||||
|
||||
/* do not crash train twice */
|
||||
if (!(v->vehstatus & VS_CRASHED)) {
|
||||
num = v->Crash();
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN));
|
||||
victims = v->Crash();
|
||||
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN, victims));
|
||||
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN, victims));
|
||||
}
|
||||
|
||||
/* Try to re-reserve track under already crashed train too.
|
||||
* Crash() clears the reservation! */
|
||||
v->ReserveTrackUnderConsist();
|
||||
|
||||
return num;
|
||||
return victims;
|
||||
}
|
||||
|
||||
/** Temporary data storage for testing collisions. */
|
||||
|
||||
Reference in New Issue
Block a user