1093 |
1093 |
1094 int x = TileX(tile) * TILE_SIZE; |
1094 int x = TileX(tile) * TILE_SIZE; |
1095 int y = TileY(tile) * TILE_SIZE; |
1095 int y = TileY(tile) * TILE_SIZE; |
1096 |
1096 |
1097 /* Helicopter raise */ |
1097 /* Helicopter raise */ |
1098 if ((v->subtype == AIR_HELICOPTER) && (((v->z_pos - GetTileZ(st->airport_tile))-1 ) < amd.z)) { |
1098 if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileZ(st->airport_tile))-1 ) < amd.z)) { |
1099 Vehicle *u = v->next->next; |
1099 Vehicle *u = v->next->next; |
1100 |
1100 |
1101 /* Make sure the rotors don't rotate too fast */ |
1101 /* Make sure the rotors don't rotate too fast */ |
1102 if (u->cur_speed > 32) { |
1102 if (u->cur_speed > 32) { |
1103 v->cur_speed = 0; |
1103 v->cur_speed = 0; |
1118 } |
1118 } |
1119 return false; |
1119 return false; |
1120 } |
1120 } |
1121 |
1121 |
1122 /* Helicopter landing. */ |
1122 /* Helicopter landing. */ |
1123 if ((v->subtype == AIR_HELICOPTER) && (((v->z_pos - GetTileZ(st->airport_tile))-1 ) > amd.z)) { |
1123 if ((v->subtype == AIR_HELICOPTER) && ((int)((v->z_pos - GetTileZ(st->airport_tile))-1 ) > amd.z)) { |
1124 count = UpdateAircraftSpeed(v); |
1124 count = UpdateAircraftSpeed(v); |
1125 if (count > 0) { |
1125 if (count > 0) { |
1126 if (st->airport_tile == 0) { |
1126 if (st->airport_tile == 0) { |
1127 /* FIXME - AircraftController -> if station no longer exists, do not land |
1127 /* FIXME - AircraftController -> if station no longer exists, do not land |
1128 * helicopter will circle until sign disappears, then go to next order |
1128 * helicopter will circle until sign disappears, then go to next order |
2164 Vehicle *v_oldstyle; |
2164 Vehicle *v_oldstyle; |
2165 FOR_ALL_VEHICLES(v_oldstyle) { |
2165 FOR_ALL_VEHICLES(v_oldstyle) { |
2166 /* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor) |
2166 /* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor) |
2167 * skip those */ |
2167 * skip those */ |
2168 if (v_oldstyle->type == VEH_AIRCRAFT && IsNormalAircraft(v_oldstyle)) { |
2168 if (v_oldstyle->type == VEH_AIRCRAFT && IsNormalAircraft(v_oldstyle)) { |
2169 /* airplane in terminal stopped doesn't hurt anyone, so goto next */ |
2169 GetNewVehiclePosResult gp; |
2170 if (v_oldstyle->vehstatus & VS_STOPPED && v_oldstyle->u.air.state == 0) { |
2170 Station *st = GetStation(v_oldstyle->u.air.targetairport); |
|
2171 const AirportFTAClass *apc = st->Airport(); |
|
2172 int z_offset = 0; |
|
2173 |
|
2174 if (IsAircraftInHangar(v_oldstyle)) { |
|
2175 /* airplane in hangar, ensure stopped, and safe state */ |
|
2176 v_oldstyle->u.air.pos = 0; |
|
2177 z_offset = (int)TilePixelHeight(v_oldstyle->tile) + 1; |
|
2178 v_oldstyle->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL; |
2171 v_oldstyle->u.air.state = HANGAR; |
2179 v_oldstyle->u.air.state = HANGAR; |
2172 continue; |
2180 } else { |
2173 } |
2181 /* airplane anywhere else, bounce into air, at the airport entry point */ |
2174 |
2182 AircraftLeaveHangar(v_oldstyle); // make airplane visible if it was in a depot for example |
2175 AircraftLeaveHangar(v_oldstyle); // make airplane visible if it was in a depot for example |
2183 v_oldstyle->vehstatus &= ~VS_STOPPED; // make airplane moving |
2176 v_oldstyle->vehstatus &= ~VS_STOPPED; // make airplane moving |
2184 v_oldstyle->u.air.state = FLYING; |
2177 v_oldstyle->u.air.state = FLYING; |
2185 AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport |
2178 AircraftNextAirportPos_and_Order(v_oldstyle); // move it to the entry point of the airport |
2186 v_oldstyle->tile = 0; // aircraft in air is tile=0 |
2179 GetNewVehiclePosResult gp = GetNewVehiclePos(v_oldstyle); |
2187 |
2180 v_oldstyle->tile = 0; // aircraft in air is tile=0 |
2188 /* correct speed of helicopter-rotors */ |
2181 |
2189 if (v_oldstyle->subtype == AIR_HELICOPTER) v_oldstyle->next->next->cur_speed = 32; |
2182 /* correct speed of helicopter-rotors */ |
2190 } |
2183 if (v_oldstyle->subtype == AIR_HELICOPTER) v_oldstyle->next->next->cur_speed = 32; |
2191 |
|
2192 gp = GetNewVehiclePos(v_oldstyle); |
2184 |
2193 |
2185 /* set new position x,y,z */ |
2194 /* set new position x,y,z */ |
2186 SetAircraftPosition(v_oldstyle, gp.x, gp.y, GetAircraftFlyingAltitude(v_oldstyle)); |
2195 SetAircraftPosition(v_oldstyle, gp.x, gp.y, apc->MovingData(v_oldstyle->u.air.pos)->z + z_offset); |
|
2196 v_oldstyle->u.air.owned_blocks.ResetAll(); |
2187 } |
2197 } |
2188 } |
2198 } |
2189 } |
2199 } |
2190 |
2200 |
2191 /** |
2201 /** |