equal
deleted
inserted
replaced
148 value = EstimateAircraftCost(p1); |
148 value = EstimateAircraftCost(p1); |
149 |
149 |
150 // to just query the cost, it is not neccessary to have a valid tile (automation/AI) |
150 // to just query the cost, it is not neccessary to have a valid tile (automation/AI) |
151 if (flags & DC_QUERY_COST) return value; |
151 if (flags & DC_QUERY_COST) return value; |
152 |
152 |
153 if (!IsAircraftHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR; |
153 if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR; |
154 |
154 |
155 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
155 SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); |
156 |
156 |
157 avi = AircraftVehInfo(p1); |
157 avi = AircraftVehInfo(p1); |
158 // allocate 2 or 3 vehicle structs, depending on type |
158 // allocate 2 or 3 vehicle structs, depending on type |
303 } |
303 } |
304 |
304 |
305 return value; |
305 return value; |
306 } |
306 } |
307 |
307 |
308 bool IsAircraftHangarTile(TileIndex tile) |
|
309 { |
|
310 // 0x56 - hangar facing other way international airport (86) |
|
311 // 0x20 - hangar large airport (32) |
|
312 // 0x41 - hangar small airport (65) |
|
313 return IsTileType(tile, MP_STATION) && |
|
314 (_m[tile].m5 == 32 || _m[tile].m5 == 65 || _m[tile].m5 == 86); |
|
315 } |
|
316 |
308 |
317 bool CheckStoppedInHangar(const Vehicle* v) |
309 bool CheckStoppedInHangar(const Vehicle* v) |
318 { |
310 { |
319 return v->vehstatus & VS_STOPPED && IsAircraftHangarTile(v->tile); |
311 return v->vehstatus & VS_STOPPED && IsHangarTile(v->tile); |
320 } |
312 } |
321 |
313 |
322 |
314 |
323 static void DoDeleteAircraft(Vehicle *v) |
315 static void DoDeleteAircraft(Vehicle *v) |
324 { |
316 { |
376 // cannot stop airplane when in flight, or when taking off / landing |
368 // cannot stop airplane when in flight, or when taking off / landing |
377 if (v->u.air.state >= STARTTAKEOFF) |
369 if (v->u.air.state >= STARTTAKEOFF) |
378 return_cmd_error(STR_A017_AIRCRAFT_IS_IN_FLIGHT); |
370 return_cmd_error(STR_A017_AIRCRAFT_IS_IN_FLIGHT); |
379 |
371 |
380 if (flags & DC_EXEC) { |
372 if (flags & DC_EXEC) { |
381 if (v->vehstatus & VS_STOPPED && IsAircraftHangarTile(v->tile)) { |
373 if (v->vehstatus & VS_STOPPED && IsHangarTile(v->tile)) { |
382 DeleteVehicleNews(p1, STR_A014_AIRCRAFT_IS_WAITING_IN); |
374 DeleteVehicleNews(p1, STR_A014_AIRCRAFT_IS_WAITING_IN); |
383 } |
375 } |
384 |
376 |
385 v->vehstatus ^= VS_STOPPED; |
377 v->vehstatus ^= VS_STOPPED; |
386 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |
378 InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); |