summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-03-09 20:29:22 +0100
committerGitHub <noreply@github.com>2021-03-09 20:29:22 +0100
commit68e92d215a865f9e3420d0a6bfb8ccbc1241c63e (patch)
tree47900763e33921f6a4af9264267bdd21bb7e24ba /src
parent65f558d6df6d4885372e57cdda0f55b9cdb42286 (diff)
downloadopenttd-68e92d215a865f9e3420d0a6bfb8ccbc1241c63e.tar.xz
Fix #8810: "aircraft out of fuel" news was looking in the wrong place (#8832)
v->tile for aircrafts is always zero when in the air. Only when it starts its landing (or take-off) patterns it becomes a sane value. So instead, base the news on the last x/y coordinates of the plane.
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_cmd.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index f4542bacd..2d47b560f 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -1328,19 +1328,22 @@ static void CrashAirplane(Aircraft *v)
v->Next()->cargo.Truncate();
const Station *st = GetTargetAirportIfValid(v);
StringID newsitem;
+ TileIndex vt;
if (st == nullptr) {
newsitem = STR_NEWS_PLANE_CRASH_OUT_OF_FUEL;
+ vt = TileVirtXY(v->x_pos, v->y_pos);
} else {
SetDParam(1, st->index);
newsitem = STR_NEWS_AIRCRAFT_CRASH;
+ vt = v->tile;
}
- 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));
+ AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
+ Game::NewEvent(new ScriptEventVehicleCrashed(v->index, vt, st == nullptr ? ScriptEventVehicleCrashed::CRASH_AIRCRAFT_NO_AIRPORT : ScriptEventVehicleCrashed::CRASH_PLANE_LANDING));
- AddTileNewsItem(newsitem, NT_ACCIDENT, v->tile, nullptr, st != nullptr ? st->index : INVALID_STATION);
+ AddTileNewsItem(newsitem, NT_ACCIDENT, vt, nullptr, st != nullptr ? st->index : INVALID_STATION);
- ModifyStationRatingAround(v->tile, v->owner, -160, 30);
+ ModifyStationRatingAround(vt, v->owner, -160, 30);
if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
}