(svn r10850) [NewGRF_ports] -Feature: Update aircraft positions for old savegames.
Either bounce aircraft into air or stay in hangar.
--- a/src/aircraft_cmd.cpp Fri Aug 10 18:51:28 2007 +0000
+++ b/src/aircraft_cmd.cpp Fri Aug 10 23:40:47 2007 +0000
@@ -1095,7 +1095,7 @@
int y = TileY(tile) * TILE_SIZE;
/* Helicopter raise */
- if ((v->subtype == AIR_HELICOPTER) && (((v->z_pos - GetTileZ(st->airport_tile))-1 ) < amd.z)) {
+ if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileZ(st->airport_tile))-1 ) < amd.z)) {
Vehicle *u = v->next->next;
/* Make sure the rotors don't rotate too fast */
@@ -1120,7 +1120,7 @@
}
/* Helicopter landing. */
- if ((v->subtype == AIR_HELICOPTER) && (((v->z_pos - GetTileZ(st->airport_tile))-1 ) > amd.z)) {
+ if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileZ(st->airport_tile))-1 ) > amd.z)) {
count = UpdateAircraftSpeed(v);
if (count > 0) {
if (st->airport_tile == 0) {
@@ -2166,24 +2166,34 @@
/* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor)
* skip those */
if (v_oldstyle->type == VEH_AIRCRAFT && IsNormalAircraft(v_oldstyle)) {
- /* airplane in terminal stopped doesn't hurt anyone, so goto next */
- if (v_oldstyle->vehstatus & VS_STOPPED && v_oldstyle->u.air.state == 0) {
+ GetNewVehiclePosResult gp;
+ Station *st = GetStation(v_oldstyle->u.air.targetairport);
+ const AirportFTAClass *apc = st->Airport();
+ int z_offset = 0;
+
+ if (IsAircraftInHangar(v_oldstyle)) {
+ /* airplane in hangar, ensure stopped, and safe state */
+ v_oldstyle->u.air.pos = 0;
+ z_offset = (int)TilePixelHeight(v_oldstyle->tile) + 1;
+ v_oldstyle->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
v_oldstyle->u.air.state = HANGAR;
- continue;
+ } else {
+ /* airplane anywhere else, bounce into air, at the airport entry point */
+ AircraftLeaveHangar(v_oldstyle); // make airplane visible if it was in a depot for example
+ v_oldstyle->vehstatus &= ~VS_STOPPED; // make airplane moving
+ v_oldstyle->u.air.state = FLYING;
+ AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport
+ v_oldstyle->tile = 0; // aircraft in air is tile=0
+
+ /* correct speed of helicopter-rotors */
+ if (v_oldstyle->subtype == AIR_HELICOPTER) v_oldstyle->next->next->cur_speed = 32;
}
- AircraftLeaveHangar(v_oldstyle); // make airplane visible if it was in a depot for example
- v_oldstyle->vehstatus &= ~VS_STOPPED; // make airplane moving
- v_oldstyle->u.air.state = FLYING;
- AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport
- GetNewVehiclePosResult gp = GetNewVehiclePos(v_oldstyle);
- v_oldstyle->tile = 0; // aircraft in air is tile=0
-
- /* correct speed of helicopter-rotors */
- if (v_oldstyle->subtype == AIR_HELICOPTER) v_oldstyle->next->next->cur_speed = 32;
+ gp = GetNewVehiclePos(v_oldstyle);
/* set new position x,y,z */
- SetAircraftPosition(v_oldstyle, gp.x, gp.y, GetAircraftFlyingAltitude(v_oldstyle));
+ SetAircraftPosition(v_oldstyle, gp.x, gp.y, apc->MovingData(v_oldstyle->u.air.pos)->z + z_offset);
+ v_oldstyle->u.air.owned_blocks.ResetAll();
}
}
}
--- a/src/openttd.cpp Fri Aug 10 18:51:28 2007 +0000
+++ b/src/openttd.cpp Fri Aug 10 23:40:47 2007 +0000
@@ -1338,9 +1338,6 @@
UpdateAllWaypointSigns();
- /* in version 2.2 of the savegame, we have new airports */
- if (CheckSavegameVersionOldStyle(2, 2)) UpdateOldAircraft();
-
UpdateAllStationVirtCoord();
/* Setup town coords */
@@ -1522,6 +1519,9 @@
}
}
+ /* after savegame version 74, we have newgrf airports. make aircraft safe (either to hangar or bounce into air) */
+ if (CheckSavegameVersion(74)) UpdateOldAircraft();
+
/* In version 6.1 we put the town index in the map-array. To do this, we need
* to use m2 (16bit big), so we need to clean m2, and that is where this is
* all about ;) */