src/aircraft_cmd.cpp
changeset 8846 f3e877a92e2b
parent 8825 38acac2cd7c8
child 8865 1884a11b74de
equal deleted inserted replaced
8845:e0eac76d3d16 8846:f3e877a92e2b
   535 			DeleteVehicleNews(p1, STR_A014_AIRCRAFT_IS_WAITING_IN);
   535 			DeleteVehicleNews(p1, STR_A014_AIRCRAFT_IS_WAITING_IN);
   536 		}
   536 		}
   537 
   537 
   538 		v->vehstatus ^= VS_STOPPED;
   538 		v->vehstatus ^= VS_STOPPED;
   539 		v->cur_speed = 0;
   539 		v->cur_speed = 0;
   540 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   540 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   541 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   541 		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
   542 		InvalidateWindowClasses(WC_AIRCRAFT_LIST);
   542 		InvalidateWindowClasses(WC_AIRCRAFT_LIST);
   543 	}
   543 	}
   544 
   544 
   545 	return CommandCost();
   545 	return CommandCost();
   574 			 * Now we change the setting to apply the new one and let the vehicle head for the same hangar.
   574 			 * Now we change the setting to apply the new one and let the vehicle head for the same hangar.
   575 			 * Note: the if is (true for requesting service == true for ordered to stop in hangar) */
   575 			 * Note: the if is (true for requesting service == true for ordered to stop in hangar) */
   576 			if (flags & DC_EXEC) {
   576 			if (flags & DC_EXEC) {
   577 				ClrBit(v->current_order.flags, OF_PART_OF_ORDERS);
   577 				ClrBit(v->current_order.flags, OF_PART_OF_ORDERS);
   578 				ToggleBit(v->current_order.flags, OF_HALT_IN_DEPOT);
   578 				ToggleBit(v->current_order.flags, OF_HALT_IN_DEPOT);
   579 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   579 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   580 			}
   580 			}
   581 			return CommandCost();
   581 			return CommandCost();
   582 		}
   582 		}
   583 
   583 
   584 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of hangar orders
   584 		if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of hangar orders
   585 		if (flags & DC_EXEC) {
   585 		if (flags & DC_EXEC) {
   586 			if (v->current_order.flags & OFB_UNLOAD) v->cur_order_index++;
   586 			if (v->current_order.flags & OFB_UNLOAD) v->cur_order_index++;
   587 			v->current_order.type = OT_DUMMY;
   587 			v->current_order.type = OT_DUMMY;
   588 			v->current_order.flags = 0;
   588 			v->current_order.flags = 0;
   589 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   589 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   590 		}
   590 		}
   591 	} else {
   591 	} else {
   592 		bool next_airport_has_hangar = true;
   592 		bool next_airport_has_hangar = true;
   593 		StationID next_airport_index = v->u.air.targetairport;
   593 		StationID next_airport_index = v->u.air.targetairport;
   594 		const Station *st = GetStation(next_airport_index);
   594 		const Station *st = GetStation(next_airport_index);
   608 			v->current_order.type = OT_GOTO_DEPOT;
   608 			v->current_order.type = OT_GOTO_DEPOT;
   609 			v->current_order.flags = OFB_NON_STOP;
   609 			v->current_order.flags = OFB_NON_STOP;
   610 			if (!(p2 & DEPOT_SERVICE)) SetBit(v->current_order.flags, OF_HALT_IN_DEPOT);
   610 			if (!(p2 & DEPOT_SERVICE)) SetBit(v->current_order.flags, OF_HALT_IN_DEPOT);
   611 			v->current_order.refit_cargo = CT_INVALID;
   611 			v->current_order.refit_cargo = CT_INVALID;
   612 			v->current_order.dest = next_airport_index;
   612 			v->current_order.dest = next_airport_index;
   613 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   613 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   614 			if (v->u.air.state == FLYING && !next_airport_has_hangar) {
   614 			if (v->u.air.state == FLYING && !next_airport_has_hangar) {
   615 				/* The aircraft is now heading for a different hangar than the next in the orders */
   615 				/* The aircraft is now heading for a different hangar than the next in the orders */
   616 				AircraftNextAirportPos_and_Order(v);
   616 				AircraftNextAirportPos_and_Order(v);
   617 			}
   617 			}
   618 		}
   618 		}
   713 	if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) {
   713 	if (st->IsValid() && st->airport_tile != 0 && st->Airport()->terminals != NULL) {
   714 //		printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
   714 //		printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
   715 //		v->u.air.targetairport = st->index;
   715 //		v->u.air.targetairport = st->index;
   716 		v->current_order.type = OT_GOTO_DEPOT;
   716 		v->current_order.type = OT_GOTO_DEPOT;
   717 		v->current_order.flags = OFB_NON_STOP;
   717 		v->current_order.flags = OFB_NON_STOP;
   718 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   718 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   719 	} else if (v->current_order.type == OT_GOTO_DEPOT) {
   719 	} else if (v->current_order.type == OT_GOTO_DEPOT) {
   720 		v->current_order.type = OT_DUMMY;
   720 		v->current_order.type = OT_DUMMY;
   721 		v->current_order.flags = 0;
   721 		v->current_order.flags = 0;
   722 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   722 		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   723 	}
   723 	}
   724 }
   724 }
   725 
   725 
   726 void OnNewDay_Aircraft(Vehicle *v)
   726 void OnNewDay_Aircraft(Vehicle *v)
   727 {
   727 {
   939 
   939 
   940 	/* updates statusbar only if speed have changed to save CPU time */
   940 	/* updates statusbar only if speed have changed to save CPU time */
   941 	if (spd != v->cur_speed) {
   941 	if (spd != v->cur_speed) {
   942 		v->cur_speed = spd;
   942 		v->cur_speed = spd;
   943 		if (_patches.vehicle_speed)
   943 		if (_patches.vehicle_speed)
   944 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   944 			InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
   945 	}
   945 	}
   946 
   946 
   947 	if (!(v->direction & 1)) spd = spd * 3 / 4;
   947 	if (!(v->direction & 1)) spd = spd * 3 / 4;
   948 
   948 
   949 	spd += v->progress;
   949 	spd += v->progress;