diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/aircraft_cmd.cpp | 3 | ||||
-rw-r--r-- | src/disaster_vehicle.cpp | 23 | ||||
-rw-r--r-- | src/disaster_vehicle.h | 1 | ||||
-rw-r--r-- | src/saveload/vehicle_sl.cpp | 1 |
4 files changed, 16 insertions, 12 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 1d96bb34e..2d3d8cf3e 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -36,6 +36,7 @@ #include "core/random_func.hpp" #include "core/backup_type.hpp" #include "zoom_func.h" +#include "disaster_vehicle.h" #include "table/strings.h" @@ -763,6 +764,8 @@ int GetAircraftFlightLevel(T *v, bool takeoff) return z; } +template int GetAircraftFlightLevel(DisasterVehicle *v, bool takeoff = false); + /** * Find the entry point to an airport depending on direction which * the airport is being approached from. Each airport can have up to diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index 703893d63..90c016fca 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -55,8 +55,6 @@ /** Delay counter for considering the next disaster. */ uint16 _disaster_delay; -static const uint INITIAL_DISASTER_VEHICLE_ZPOS = 135; ///< Initial Z position of flying disaster vehicles. - static void DisasterClearSquare(TileIndex tile) { if (EnsureNoVehicleOnGround(tile).Failed()) return; @@ -137,11 +135,12 @@ DisasterVehicle::DisasterVehicle(int x, int y, Direction direction, DisasterSubT case ST_HELICOPTER: case ST_BIG_UFO: case ST_BIG_UFO_DESTROYER: - this->z_pos = INITIAL_DISASTER_VEHICLE_ZPOS; + GetAircraftFlightLevelBounds(this, &this->z_pos, NULL); break; case ST_HELICOPTER_ROTORS: - this->z_pos = INITIAL_DISASTER_VEHICLE_ZPOS + ROTOR_Z_OFFSET; + GetAircraftFlightLevelBounds(this, &this->z_pos, NULL); + this->z_pos += ROTOR_Z_OFFSET; break; case ST_SMALL_SUBMARINE: @@ -229,7 +228,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v) GetNewVehiclePosResult gp = GetNewVehiclePos(v); - v->UpdatePosition(gp.x, gp.y, v->z_pos); + v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v)); if (v->current_order.GetDestination() == 1) { if (++v->age == 38) { @@ -267,7 +266,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v) AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCleared(st->index)); } - v->UpdatePosition(v->x_pos, v->y_pos, v->z_pos); + v->UpdatePosition(v->x_pos, v->y_pos, GetAircraftFlightLevel(v)); delete v; return false; } @@ -323,7 +322,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v) if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); GetNewVehiclePosResult gp = GetNewVehiclePos(v); - v->UpdatePosition(gp.x, gp.y, v->z_pos); + v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v)); return true; } if (++v->age < 6) { @@ -426,7 +425,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo v->image_override = (v->current_order.GetDestination() == 1 && HasBit(v->tick_counter, 2)) ? image_override : 0; GetNewVehiclePosResult gp = GetNewVehiclePos(v); - v->UpdatePosition(gp.x, gp.y, v->z_pos); + v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v)); if ((leave_at_top && gp.x < (-10 * (int)TILE_SIZE)) || (!leave_at_top && gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1)) { delete v; @@ -523,7 +522,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v) v->direction = GetDirectionTowards(v, x, y); GetNewVehiclePosResult gp = GetNewVehiclePos(v); - v->UpdatePosition(gp.x, gp.y, v->z_pos); + v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v)); return true; } @@ -568,7 +567,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v) if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) { v->direction = GetDirectionTowards(v, x, y); GetNewVehiclePosResult gp = GetNewVehiclePos(v); - v->UpdatePosition(gp.x, gp.y, v->z_pos); + v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v)); return true; } @@ -603,7 +602,7 @@ static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v) v->tick_counter++; GetNewVehiclePosResult gp = GetNewVehiclePos(v); - v->UpdatePosition(gp.x, gp.y, v->z_pos); + v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v)); if (gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1) { delete v; @@ -965,7 +964,7 @@ void ReleaseDisastersTargetingVehicle(VehicleID vehicle) /* Revert to target-searching */ v->current_order.SetDestination(0); v->dest_tile = RandomTile(); - v->z_pos = INITIAL_DISASTER_VEHICLE_ZPOS; + GetAircraftFlightLevelBounds(v, &v->z_pos, NULL); v->age = 0; } } diff --git a/src/disaster_vehicle.h b/src/disaster_vehicle.h index 0b2005d92..06fb36c1e 100644 --- a/src/disaster_vehicle.h +++ b/src/disaster_vehicle.h @@ -39,6 +39,7 @@ enum DisasterSubType { struct DisasterVehicle FINAL : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> { SpriteID image_override; ///< Override for the default disaster vehicle sprite. VehicleID big_ufo_destroyer_target; ///< The big UFO that this destroyer is supposed to bomb. + byte flags; ///< Flags about the state of the vehicle, @see AirVehicleFlags /** For use by saveload. */ DisasterVehicle() : SpecializedVehicleBase() {} diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 2d5ff7d51..ebc5fc421 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -845,6 +845,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt) SLE_CONDVAR(DisasterVehicle, image_override, SLE_UINT32, 191, SL_MAX_VERSION), SLE_CONDVAR(DisasterVehicle, big_ufo_destroyer_target, SLE_FILE_U16 | SLE_VAR_U32, 0, 190), SLE_CONDVAR(DisasterVehicle, big_ufo_destroyer_target, SLE_UINT32, 191, SL_MAX_VERSION), + SLE_CONDVAR(DisasterVehicle, flags, SLE_UINT8, 194, SL_MAX_VERSION), SLE_CONDNULL(16, 2, 143), // old reserved space |