diff options
author | rubidium <rubidium@openttd.org> | 2007-06-14 08:39:27 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-06-14 08:39:27 +0000 |
commit | 0e5a6661f7054c554d006f78c50123c8887b6f85 (patch) | |
tree | 33f410644a51e5ab4cbda8eaa5dd9e8f22f39427 /src | |
parent | 3b5203dbc6972daf7b8e0d4006a22f2d3c6ddd85 (diff) | |
download | openttd-0e5a6661f7054c554d006f78c50123c8887b6f85.tar.xz |
(svn r10155) -Fix [FS#601]: Airports didn't flood when there are aircraft on the airport.
Diffstat (limited to 'src')
-rw-r--r-- | src/water_cmd.cpp | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index e7841196a..fd4099569 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -618,6 +618,21 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs) */ 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 @@ static void FloodVehicle(Vehicle *v) 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 @@ static void FloodVehicle(Vehicle *v) 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(); |