src/aircraft_cmd.cpp
branchNewGRF_ports
changeset 6870 ca3fd1fbe311
parent 6869 76282d3b748d
child 6871 5a9dc001e1ad
equal deleted inserted replaced
6869:76282d3b748d 6870:ca3fd1fbe311
   310 	if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
   310 	if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
   311 
   311 
   312 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
   312 	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
   313 
   313 
   314 	/* Prevent building aircraft types at places which can't handle them */
   314 	/* Prevent building aircraft types at places which can't handle them */
   315 	if (!IsAircraftBuildableAtStation(p1, tile)) return CMD_ERROR;
   315 	if (!CanAircraftUseStation(p1, tile)) return CMD_ERROR;
   316 
   316 
   317 	/* Allocate 2 or 3 vehicle structs, depending on type
   317 	/* Allocate 2 or 3 vehicle structs, depending on type
   318 	 * vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
   318 	 * vl[0] = aircraft, vl[1] = shadow, [vl[2] = rotor] */
   319 	Vehicle *vl[3];
   319 	Vehicle *vl[3];
   320 	if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) {
   320 	if (!Vehicle::AllocateList(vl, avi->subtype & AIR_CTOL ? 2 : 3)) {
   383 		if (cargo != CT_INVALID && cargo != CT_PASSENGERS) {
   383 		if (cargo != CT_INVALID && cargo != CT_PASSENGERS) {
   384 			uint16 callback = CALLBACK_FAILED;
   384 			uint16 callback = CALLBACK_FAILED;
   385 
   385 
   386 			v->cargo_type = cargo;
   386 			v->cargo_type = cargo;
   387 
   387 
   388 			if (HASBIT(EngInfo(p1)->callbackmask, CBM_REFIT_CAPACITY)) {
   388 			if (HASBIT(EngInfo(p1)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
   389 				callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
   389 				callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
   390 			}
   390 			}
   391 
   391 
   392 			if (callback == CALLBACK_FAILED) {
   392 			if (callback == CALLBACK_FAILED) {
   393 				/* Callback failed, or not executed; use the default cargo capacity */
   393 				/* Callback failed, or not executed; use the default cargo capacity */
   607 		if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
   607 		if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
   608 			/* We called with a different DEPOT_SERVICE setting.
   608 			/* We called with a different DEPOT_SERVICE setting.
   609 			 * Now we change the setting to apply the new one and let the vehicle head for the same hangar.
   609 			 * Now we change the setting to apply the new one and let the vehicle head for the same hangar.
   610 			 * Note: the if is (true for requesting service == true for ordered to stop in hangar) */
   610 			 * Note: the if is (true for requesting service == true for ordered to stop in hangar) */
   611 			if (flags & DC_EXEC) {
   611 			if (flags & DC_EXEC) {
       
   612 				CLRBIT(v->current_order.flags, OFB_PART_OF_ORDERS);
   612 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
   613 				TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
   613 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   614 				InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
   614 			}
   615 			}
   615 			return CommandCost();
   616 			return CommandCost();
   616 		}
   617 		}
   683 
   684 
   684 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
   685 	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
   685 
   686 
   686 	/* Check the refit capacity callback */
   687 	/* Check the refit capacity callback */
   687 	uint16 callback = CALLBACK_FAILED;
   688 	uint16 callback = CALLBACK_FAILED;
   688 	if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
   689 	if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
   689 		/* Back up the existing cargo type */
   690 		/* Back up the existing cargo type */
   690 		CargoID temp_cid = v->cargo_type;
   691 		CargoID temp_cid = v->cargo_type;
   691 		byte temp_subtype = v->cargo_subtype;
   692 		byte temp_subtype = v->cargo_subtype;
   692 		v->cargo_type = new_cid;
   693 		v->cargo_type = new_cid;
   693 		v->cargo_subtype = new_subtype;
   694 		v->cargo_subtype = new_subtype;
  2280 			}
  2281 			}
  2281 
  2282 
  2282 			gp = GetNewVehiclePos(v_oldstyle);
  2283 			gp = GetNewVehiclePos(v_oldstyle);
  2283 
  2284 
  2284 			/* set new position x,y,z */
  2285 			/* set new position x,y,z */
  2285 			SetAircraftPosition(v_oldstyle, gp.x, gp.y, apc->MovingData(v_oldstyle->u.air.pos)->z + z_offset);
  2286 			SetAircraftPosition(v_oldstyle, gp.x, gp.y, apc->MovingData(min(v_oldstyle->u.air.pos, apc->num_positions - 1))->z + z_offset);
  2286 			v_oldstyle->u.air.owned_blocks.ResetAll();
  2287 			v_oldstyle->u.air.owned_blocks.ResetAll();
  2287 		}
  2288 		}
  2288 	}
  2289 	}
  2289 }
  2290 }
  2290 
  2291