|
@@ -431,28 +431,27 @@ CommandCost CmdBuildAircraft(TileIndex t
|
|
|
}
|
|
|
|
|
|
|
|
|
/** Sell an aircraft.
|
|
|
* @param tile unused
|
|
|
* @param flags for command type
|
|
|
* @param p1 vehicle ID to be sold
|
|
|
* @param p2 unused
|
|
|
* @return result of operation. Error or sold value
|
|
|
*/
|
|
|
CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
{
|
|
|
Vehicle *v = Vehicle::GetIfValid(p1);
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
Aircraft *v = Aircraft::GetIfValid(p1);
|
|
|
|
|
|
if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
|
|
|
|
|
|
if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE);
|
|
|
|
|
|
CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value);
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
delete v;
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
@@ -484,51 +483,47 @@ bool Aircraft::FindClosestDepot(TileInde
|
|
|
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
|
|
|
* - p2 bit 8-10 - VLW flag (for mass goto depot)
|
|
|
* @return o if everything went well
|
|
|
*/
|
|
|
CommandCost CmdSendAircraftToHangar(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
{
|
|
|
if (p2 & DEPOT_MASS_SEND) {
|
|
|
/* Mass goto depot requested */
|
|
|
if (!ValidVLWFlags(p2 & VLW_MASK)) return CMD_ERROR;
|
|
|
return SendAllVehiclesToDepot(VEH_AIRCRAFT, flags, p2 & DEPOT_SERVICE, _current_company, (p2 & VLW_MASK), p1);
|
|
|
}
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(p1);
|
|
|
Aircraft *v = Aircraft::GetIfValid(p1);
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
|
if (v->type != VEH_AIRCRAFT) return CMD_ERROR;
|
|
|
|
|
|
return v->SendToDepot(flags, (DepotCommand)(p2 & DEPOT_COMMAND_MASK));
|
|
|
}
|
|
|
|
|
|
|
|
|
/** Refits an aircraft to the specified cargo type.
|
|
|
* @param tile unused
|
|
|
* @param flags for command type
|
|
|
* @param p1 vehicle ID of the aircraft to refit
|
|
|
* @param p2 various bitstuffed elements
|
|
|
* - p2 = (bit 0-7) - the new cargo type to refit to
|
|
|
* - p2 = (bit 8-15) - the new cargo subtype to refit to
|
|
|
* - p2 = (bit 16) - refit only this vehicle (ignored)
|
|
|
* @return cost of refit or error
|
|
|
*/
|
|
|
CommandCost CmdRefitAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
|
|
{
|
|
|
byte new_subtype = GB(p2, 8, 8);
|
|
|
|
|
|
Vehicle *v = Vehicle::GetIfValid(p1);
|
|
|
if (v == NULL) return CMD_ERROR;
|
|
|
|
|
|
if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
Aircraft *v = Aircraft::GetIfValid(p1);
|
|
|
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
|
|
|
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
|
|
|
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_REFIT_DESTROYED_VEHICLE);
|
|
|
|
|
|
/* Check cargo */
|
|
|
CargoID new_cid = GB(p2, 0, 8);
|
|
|
if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
|
|
|
|
|
|
/* Check the refit capacity callback */
|
|
|
uint16 callback = CALLBACK_FAILED;
|
|
|
if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
|
|
|
/* Back up the existing cargo type */
|
|
|
CargoID temp_cid = v->cargo_type;
|