File diff r6942:db62dc24a576 → r6943:a727ca1f1062
src/aircraft_cmd.cpp
Show inline comments
 
@@ -224,13 +224,13 @@ void GetAircraftSpriteSize(EngineID engi
 
	const Sprite *spr = GetSprite(sprite);
 

	
 
	width  = spr->width ;
 
	height = spr->height;
 
}
 

	
 
static int32 EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi)
 
static CommandCost EstimateAircraftCost(EngineID engine, const AircraftVehicleInfo *avi)
 
{
 
	return GetEngineProperty(engine, 0x0B, avi->base_cost) * (_price.aircraft_base >> 3) >> 5;
 
}
 

	
 

	
 
/**
 
@@ -262,18 +262,18 @@ uint16 AircraftDefaultCargoCapacity(Carg
 
 * @param tile tile of depot where aircraft is built
 
 * @param flags for command
 
 * @param p1 aircraft type being built (engine)
 
 * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
 
 * return result of operation.  Could be cost, error
 
 */
 
int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_player)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE);
 

	
 
	const AircraftVehicleInfo *avi = AircraftVehInfo(p1);
 
	int32 value = EstimateAircraftCost(p1, avi);
 
	CommandCost value = EstimateAircraftCost(p1, avi);
 

	
 
	/* to just query the cost, it is not neccessary to have a valid tile (automation/AI) */
 
	if (flags & DC_QUERY_COST) return value;
 

	
 
	if (!IsHangarTile(tile) || !IsTileOwner(tile, _current_player)) return CMD_ERROR;
 

	
 
@@ -473,13 +473,13 @@ static void DoDeleteAircraft(Vehicle *v)
 
 * @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
 
 */
 
int32 CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 

	
 
	if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
 
@@ -500,13 +500,13 @@ int32 CmdSellAircraft(TileIndex tile, ui
 
 * @param tile unused
 
 * @param flags for command type
 
 * @param p1 aircraft ID to start/stop
 
 * @param p2 unused
 
 * @return result of operation.  Nothing if everything went well
 
 */
 
int32 CmdStartStopAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdStartStopAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 

	
 
	if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
 
@@ -543,13 +543,13 @@ int32 CmdStartStopAircraft(TileIndex til
 
 * @param p1 vehicle ID to send to the hangar
 
 * @param p2 various bitmasked elements
 
 * - 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
 
 */
 
int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	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_player, (p2 & VLW_MASK), p1);
 
	}
 
@@ -620,13 +620,13 @@ int32 CmdSendAircraftToHangar(TileIndex 
 
 * @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
 
 */
 
int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	byte new_subtype = GB(p2, 8, 8);
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
@@ -665,13 +665,13 @@ int32 CmdRefitAircraft(TileIndex tile, u
 
		pass = AircraftDefaultCargoCapacity(new_cid, avi);
 
	} else {
 
		pass = callback;
 
	}
 
	_returned_refit_capacity = pass;
 

	
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
 
		cost = GetRefitCost(v->engine_type);
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		v->cargo_cap = pass;
 
@@ -741,13 +741,13 @@ void OnNewDay_Aircraft(Vehicle *v)
 
	CheckVehicleBreakdown(v);
 
	AgeVehicle(v);
 
	CheckIfAircraftNeedsService(v);
 

	
 
	if (v->vehstatus & VS_STOPPED) return;
 

	
 
	int32 cost = GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364;
 
	CommandCost cost = GetVehicleProperty(v, 0x0E, AircraftVehInfo(v->engine_type)->running_cost) * _price.aircraft_running / 364;
 

	
 
	v->profit_this_year -= cost >> 8;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
 
	SubtractMoneyFromPlayerFract(v->owner, cost);
 

	
 
@@ -1376,13 +1376,13 @@ static void ProcessAircraftOrder(Vehicle
 
		 *    example a depot. However, when we have a current order to
 
		 *    go to a depot, we have to keep that order so the aircraft
 
		 *    actually stops.
 
		 */
 
		const Station *st = GetStation(v->u.air.targetairport);
 
		if (!st->IsValid() || st->airport_tile == 0) {
 
			int32 ret;
 
			CommandCost ret;
 
			PlayerID old_player = _current_player;
 

	
 
			_current_player = v->owner;
 
			ret = DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
 
			_current_player = old_player;