Mercurial > hg > openttd
changeset 6906:c67a063b99bf draft
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Thu, 14 Jun 2007 08:39:27 +0000 |
parents | bf5912475e5e |
children | 8a7c4b1f39ea |
files | src/water_cmd.cpp |
diffstat | 1 files changed, 43 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -618,6 +618,21 @@ */ static Vehicle *FindFloodableVehicleOnTile(TileIndex tile) { + if (IsTileType(tile, MP_STATION) && IsAirport(tile)) { + const Station *st = GetStationByTile(tile); + const AirportFTAClass *airport = st->Airport(); + for (uint x = 0; x < airport->size_x; x++) { + for (uint y = 0; y < airport->size_y; y++) { + tile = TILE_ADDXY(st->airport_tile, x, y); + Vehicle *v = FindVehicleOnTileZ(tile, 1 + airport->delta_z); + if (v != NULL && (v->vehstatus & VS_CRASHED) == 0) return v; + } + } + + /* No vehicle could be flooded on this airport anymore */ + return NULL; + } + if (!IsBridgeTile(tile)) return FindVehicleOnTileZ(tile, 0); TileIndex end = GetOtherBridgeEnd(tile); @@ -642,10 +657,20 @@ if (!(v->vehstatus & VS_CRASHED)) { uint16 pass = 0; - if (v->type == VEH_TRAIN || v->type == VEH_ROAD) { + if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_AIRCRAFT) { + if (v->type == VEH_AIRCRAFT) { + /* Crashing aircraft are always at z_pos == 1, never on z_pos == 0, + * because that's always the shadow. Except for the heliport, because + * that station has a big z_offset for the aircraft. */ + if (!IsTileType(v->tile, MP_STATION) || !IsAirport(v->tile) || GetTileMaxZ(v->tile) != 0) return; + const Station *st = GetStationByTile(v->tile); + const AirportFTAClass *airport = st->Airport(); + + if (v->z_pos != airport->delta_z + 1) return; + } Vehicle *u; - v = GetFirstVehicleInChain(v); + if (v->type != VEH_AIRCRAFT) v = GetFirstVehicleInChain(v); u = v; /* crash all wagons, and count passengers */ @@ -657,12 +682,22 @@ v = u; - if (v->type == VEH_TRAIN) { - if (IsFrontEngine(v)) pass += 4; // driver - v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast - } else { - if (IsRoadVehFront(v)) pass += 1; // driver - v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast + switch (v->type) { + default: NOT_REACHED(); + case VEH_TRAIN: + if (IsFrontEngine(v)) pass += 4; // driver + v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast + break; + + case VEH_ROAD: + if (IsRoadVehFront(v)) pass += 1; // driver + v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast + break; + + case VEH_AIRCRAFT: + pass += 2; // driver + v->u.air.crashed_counter = 9000; // max 10000, disappear pretty fast + break; } RebuildVehicleLists();