aircraft_cmd.c
changeset 2630 7206058a7e82
parent 2618 9691753519ac
child 2635 7ed07303448d
equal deleted inserted replaced
2629:78f87f273407 2630:7206058a7e82
   542 	ShowAircraftViewWindow(v);
   542 	ShowAircraftViewWindow(v);
   543 }
   543 }
   544 
   544 
   545 static void CheckIfAircraftNeedsService(Vehicle *v)
   545 static void CheckIfAircraftNeedsService(Vehicle *v)
   546 {
   546 {
   547 	Station *st;
   547 	const Station* st;
   548 
   548 
   549 	if (_patches.servint_aircraft == 0)
   549 	if (_patches.servint_aircraft == 0)
   550 		return;
   550 		return;
   551 
   551 
   552 	if (!VehicleNeedsService(v))
   552 	if (!VehicleNeedsService(v))
  1267 	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
  1267 	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
  1268 }
  1268 }
  1269 
  1269 
  1270 static bool ValidateAircraftInHangar( uint data_a, uint data_b )
  1270 static bool ValidateAircraftInHangar( uint data_a, uint data_b )
  1271 {
  1271 {
  1272 	Vehicle *v = GetVehicle(data_a);
  1272 	const Vehicle* v = GetVehicle(data_a);
  1273 
  1273 
  1274 	return (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_STOPPED));
  1274 	return (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_STOPPED));
  1275 }
  1275 }
  1276 
  1276 
  1277 static void AircraftEnterHangar(Vehicle *v)
  1277 static void AircraftEnterHangar(Vehicle *v)
  1322 }
  1322 }
  1323 
  1323 
  1324 // set the right pos when heading to other airports after takeoff
  1324 // set the right pos when heading to other airports after takeoff
  1325 static void AircraftNextAirportPos_and_Order(Vehicle *v)
  1325 static void AircraftNextAirportPos_and_Order(Vehicle *v)
  1326 {
  1326 {
  1327 	Station *st;
  1327 	const Station* st;
  1328 	const AirportFTAClass *Airport;
  1328 	const AirportFTAClass *Airport;
  1329 
  1329 
  1330 	if (v->current_order.type == OT_GOTO_STATION ||
  1330 	if (v->current_order.type == OT_GOTO_STATION ||
  1331 			v->current_order.type == OT_GOTO_DEPOT)
  1331 			v->current_order.type == OT_GOTO_DEPOT)
  1332 		v->u.air.targetairport = v->current_order.station;
  1332 		v->u.air.targetairport = v->current_order.station;
  1632 	AircraftEventHandler_EndLanding,		// ENDLANDING     = 16
  1632 	AircraftEventHandler_EndLanding,		// ENDLANDING     = 16
  1633 	AircraftEventHandler_HeliLanding,		// HELILANDING    = 17
  1633 	AircraftEventHandler_HeliLanding,		// HELILANDING    = 17
  1634 	AircraftEventHandler_HeliEndLanding,// HELIENDLANDING = 18
  1634 	AircraftEventHandler_HeliEndLanding,// HELIENDLANDING = 18
  1635 };
  1635 };
  1636 
  1636 
  1637 static void AirportClearBlock(Vehicle *v, const AirportFTAClass *Airport)
  1637 static void AirportClearBlock(const Vehicle* v, const AirportFTAClass* Airport)
  1638 {
  1638 {
  1639 	Station *st;
  1639 	Station *st;
  1640 	// we have left the previous block, and entered the new one. Free the previous block
  1640 	// we have left the previous block, and entered the new one. Free the previous block
  1641 	if (Airport->layout[v->u.air.previous_pos].block != Airport->layout[v->u.air.pos].block) {
  1641 	if (Airport->layout[v->u.air.previous_pos].block != Airport->layout[v->u.air.pos].block) {
  1642 		st = GetStation(v->u.air.targetairport);
  1642 		st = GetStation(v->u.air.targetairport);
  1704 }
  1704 }
  1705 
  1705 
  1706 // returns true if the road ahead is busy, eg. you must wait before proceeding
  1706 // returns true if the road ahead is busy, eg. you must wait before proceeding
  1707 static bool AirportHasBlock(Vehicle *v, AirportFTA *current_pos, const AirportFTAClass *Airport)
  1707 static bool AirportHasBlock(Vehicle *v, AirportFTA *current_pos, const AirportFTAClass *Airport)
  1708 {
  1708 {
  1709 	Station *st;
  1709 	const AirportFTA* reference = &Airport->layout[v->u.air.pos];
  1710 	uint32 airport_flags;
  1710 	const AirportFTA* next = &Airport->layout[current_pos->next_position];
  1711 	AirportFTA *next, *reference;
       
  1712 	reference = &Airport->layout[v->u.air.pos];
       
  1713 	next = &Airport->layout[current_pos->next_position];
       
  1714 
  1711 
  1715 	// same block, then of course we can move
  1712 	// same block, then of course we can move
  1716 	if (Airport->layout[current_pos->position].block != next->block) {
  1713 	if (Airport->layout[current_pos->position].block != next->block) {
  1717 		airport_flags = next->block;
  1714 		const Station* st = GetStation(v->u.air.targetairport);
  1718 		st = GetStation(v->u.air.targetairport);
  1715 		uint32 airport_flags = next->block;
       
  1716 
  1719 		// check additional possible extra blocks
  1717 		// check additional possible extra blocks
  1720 		if (current_pos != reference && current_pos->block != NOTHING_block) {
  1718 		if (current_pos != reference && current_pos->block != NOTHING_block) {
  1721 			airport_flags |= current_pos->block;
  1719 			airport_flags |= current_pos->block;
  1722 		}
  1720 		}
  1723 
  1721