File diff r3490:2997e05fe018 → r3491:10ed78e15d31
ship_cmd.c
Show inline comments
 
@@ -806,22 +806,21 @@ void ShipsYearlyLoop(void)
 
			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		}
 
	}
 
}
 

	
 
/** Build a ship.
 
 * @param x,y tile coordinates of depot where ship is built
 
 * @param tile tile of depot where ship is built
 
 * @param p1 ship type being built (engine)
 
 * @param p2 unused
 
 */
 
int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 value;
 
	Vehicle *v;
 
	UnitID unit_num;
 
	TileIndex tile = TileVirtXY(x, y);
 
	Engine *e;
 

	
 
	if (!IsEngineBuildable(p1, VEH_Ship)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 

	
 
@@ -836,12 +835,15 @@ int32 CmdBuildShip(int x, int y, uint32 
 
	v = AllocateVehicle();
 
	if (v == NULL || IsOrderPoolFull() ||
 
			(unit_num = GetFreeUnitNumber(VEH_Ship)) > _patches.max_ships)
 
		return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
 

	
 
	if (flags & DC_EXEC) {
 
		int x;
 
		int y;
 

	
 
		const ShipVehicleInfo *svi = ShipVehInfo(p1);
 

	
 
		v->unitnumber = unit_num;
 

	
 
		v->owner = _current_player;
 
		v->tile = tile;
 
@@ -894,17 +896,17 @@ int32 CmdBuildShip(int x, int y, uint32 
 
	}
 

	
 
	return value;
 
}
 

	
 
/** Sell a ship.
 
 * @param x,y unused
 
 * @param tile unused
 
 * @param p1 vehicle ID to be sold
 
 * @param p2 unused
 
 */
 
int32 CmdSellShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
int32 CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
@@ -927,17 +929,17 @@ int32 CmdSellShip(int x, int y, uint32 f
 
	}
 

	
 
	return -(int32)v->value;
 
}
 

	
 
/** Start/Stop a ship.
 
 * @param x,y unused
 
 * @param tile unused
 
 * @param p1 ship ID to start/stop
 
 * @param p2 unused
 
 */
 
int32 CmdStartStopShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
int32 CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
@@ -956,17 +958,17 @@ int32 CmdStartStopShip(int x, int y, uin
 
	}
 

	
 
	return 0;
 
}
 

	
 
/** Send a ship to the depot.
 
 * @param x,y unused
 
 * @param tile unused
 
 * @param p1 vehicle ID to send to the depot
 
 * @param p2 unused
 
 */
 
int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	const Depot *dep;
 

	
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;
 

	
 
@@ -1005,18 +1007,18 @@ int32 CmdSendShipToDepot(int x, int y, u
 

	
 
	return 0;
 
}
 

	
 

	
 
/** Refits a ship to the specified cargo type.
 
 * @param x,y unused
 
 * @param tile unused
 
 * @param p1 vehicle ID of the ship to refit
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
 
 */
 
int32 CmdRefitShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	int32 cost;
 
	CargoID new_cid = p2 & 0xFF; //gets the cargo number
 

	
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;