Fix #7611: keeps news about accidents around after vehicle is cleaned up (#8497)

When a vehicle is cleaned up, all news that points to the news is
also removed. This was a bit evil, as it would also remove any
news related to crashed, acting like the crash never happened.
This left players a bit in the dark what was going on exactly.
pull/217/head
Patric Stout 4 years ago committed by GitHub
parent 0fd2108f7f
commit dff7ee8e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1333,7 +1333,7 @@ static void CrashAirplane(Aircraft *v)
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING)); AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING)); Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
AddVehicleNewsItem(newsitem, NT_ACCIDENT, v->index, st != nullptr ? st->index : INVALID_STATION); AddTileNewsItem(newsitem, NT_ACCIDENT, v->tile, nullptr, st != nullptr ? st->index : INVALID_STATION);
ModifyStationRatingAround(v->tile, v->owner, -160, 30); ModifyStationRatingAround(v->tile, v->owner, -160, 30);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);

@ -243,7 +243,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
v->age = 0; v->age = 0;
SetDParam(0, GetStationIndex(v->tile)); SetDParam(0, GetStationIndex(v->tile));
AddVehicleNewsItem(STR_NEWS_DISASTER_ZEPPELIN, NT_ACCIDENT, v->index); // Delete the news, when the zeppelin is gone AddTileNewsItem(STR_NEWS_DISASTER_ZEPPELIN, NT_ACCIDENT, v->tile);
AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCrashed(GetStationIndex(v->tile))); AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCrashed(GetStationIndex(v->tile)));
} }
} }
@ -377,7 +377,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
if (u->crashed_ctr == 0) { if (u->crashed_ctr == 0) {
u->Crash(); u->Crash();
AddVehicleNewsItem(STR_NEWS_DISASTER_SMALL_UFO, NT_ACCIDENT, u->index); // delete the news, when the roadvehicle is gone AddTileNewsItem(STR_NEWS_DISASTER_SMALL_UFO, NT_ACCIDENT, u->tile);
AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO)); AI::NewEvent(u->owner, new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO)); Game::NewEvent(new ScriptEventVehicleCrashed(u->index, u->tile, ScriptEventVehicleCrashed::CRASH_RV_UFO));
@ -456,7 +456,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo
DestructIndustry(i); DestructIndustry(i);
SetDParam(0, i->town->index); SetDParam(0, i->town->index);
AddIndustryNewsItem(news_message, NT_ACCIDENT, i->index); // delete the news, when the industry closes AddTileNewsItem(news_message, NT_ACCIDENT, v->dest_tile);
if (_settings_client.sound.disaster) SndPlayTileFx(SND_12_EXPLOSION, i->location.tile); if (_settings_client.sound.disaster) SndPlayTileFx(SND_12_EXPLOSION, i->location.tile);
} }
} else if (v->current_order.GetDestination() == 0) { } else if (v->current_order.GetDestination() == 0) {

@ -42,9 +42,9 @@ static inline void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle)
AddNewsItem(string, NT_ADVICE, NF_INCOLOUR | NF_SMALL | NF_VEHICLE_PARAM0, NR_VEHICLE, vehicle); AddNewsItem(string, NT_ADVICE, NF_INCOLOUR | NF_SMALL | NF_VEHICLE_PARAM0, NR_VEHICLE, vehicle);
} }
static inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, void *free_data = nullptr) static inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, void *free_data = nullptr, StationID station = INVALID_STATION)
{ {
AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_TILE, tile, NR_NONE, UINT32_MAX, free_data); AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_TILE, tile, station == INVALID_STATION ? NR_NONE : NR_STATION, station, free_data);
} }
static inline void AddIndustryNewsItem(StringID string, NewsType type, IndustryID industry) static inline void AddIndustryNewsItem(StringID string, NewsType type, IndustryID industry)

@ -552,12 +552,8 @@ static void RoadVehCrash(RoadVehicle *v)
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING)); Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
SetDParam(0, pass); SetDParam(0, pass);
AddVehicleNewsItem( StringID newsitem = (pass == 1) ? STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH;
(pass == 1) ? AddTileNewsItem(newsitem, NT_ACCIDENT, v->tile);
STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH,
NT_ACCIDENT,
v->index
);
ModifyStationRatingAround(v->tile, v->owner, -160, 22); ModifyStationRatingAround(v->tile, v->owner, -160, 22);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);

@ -3052,7 +3052,7 @@ static bool CheckTrainCollision(Train *v)
if (tcc.num == 0) return false; if (tcc.num == 0) return false;
SetDParam(0, tcc.num); SetDParam(0, tcc.num);
AddVehicleNewsItem(STR_NEWS_TRAIN_CRASH, NT_ACCIDENT, v->index); AddTileNewsItem(STR_NEWS_TRAIN_CRASH, NT_ACCIDENT, v->tile);
ModifyStationRatingAround(v->tile, v->owner, -160, 30); ModifyStationRatingAround(v->tile, v->owner, -160, 30);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_13_BIG_CRASH, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_13_BIG_CRASH, v);

@ -977,7 +977,7 @@ static void FloodVehicle(Vehicle *v)
AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED)); AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED));
Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED)); Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED));
SetDParam(0, pass); SetDParam(0, pass);
AddVehicleNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE, NT_ACCIDENT, v->index); AddTileNewsItem(STR_NEWS_DISASTER_FLOOD_VEHICLE, NT_ACCIDENT, v->tile);
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v); if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
} }

Loading…
Cancel
Save