Changeset - r6943:a727ca1f1062
[Not reviewed]
src/ai/ai.cpp
Show inline comments
 
@@ -81,10 +81,10 @@ static void AI_PutCommandInQueue(PlayerI
 
/**
 
 * Executes a raw DoCommand for the AI.
 
 */
 
int32 AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback)
 
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback)
 
{
 
	PlayerID old_lp;
 
	int32 res = 0;
 
	CommandCost res = 0;
 
	const char* tmp_cmdtext;
 

	
 
	/* If you enable DC_EXEC with DC_QUERY_COST you are a really strange
 
@@ -135,7 +135,7 @@ int32 AI_DoCommandCc(TileIndex tile, uin
 
}
 

	
 

	
 
int32 AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
 
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
 
{
 
	return AI_DoCommandCc(tile, p1, p2, flags, procc, NULL);
 
}
src/ai/ai.h
Show inline comments
 
@@ -43,8 +43,8 @@ void AI_PlayerDied(PlayerID player);
 
void AI_RunGameLoop();
 
void AI_Initialize();
 
void AI_Uninitialize();
 
int32 AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
 
int32 AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback);
 
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
 
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback);
 

	
 
/** Is it allowed to start a new AI.
 
 * This function checks some boundries to see if we should launch a new AI.
src/ai/default/default.cpp
Show inline comments
 
@@ -136,7 +136,7 @@ static EngineID AiChooseTrainToBuild(Rai
 
{
 
	EngineID best_veh_index = INVALID_ENGINE;
 
	byte best_veh_score = 0;
 
	int32 ret;
 
	CommandCost ret;
 
	EngineID i;
 

	
 
	for (i = 0; i < NUM_TRAIN_ENGINES; i++) {
 
@@ -172,7 +172,7 @@ static EngineID AiChooseRoadVehToBuild(C
 
		const RoadVehicleInfo *rvi = RoadVehInfo(i);
 
		const Engine* e = GetEngine(i);
 
		int32 rating;
 
		int32 ret;
 
		CommandCost ret;
 

	
 
		if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D) {
 
			continue;
 
@@ -207,7 +207,7 @@ static EngineID AiChooseAircraftToBuild(
 

	
 
	for (i = AIRCRAFT_ENGINES_INDEX; i != AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) {
 
		const Engine* e = GetEngine(i);
 
		int32 ret;
 
		CommandCost ret;
 

	
 
		if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D) {
 
			continue;
 
@@ -1638,10 +1638,10 @@ static bool AiCheckTrackResources(TileIn
 
	return true;
 
}
 

	
 
static int32 AiDoBuildDefaultRailTrack(TileIndex tile, const AiDefaultBlockData* p, RailType railtype, byte flag)
 
static CommandCost AiDoBuildDefaultRailTrack(TileIndex tile, const AiDefaultBlockData* p, RailType railtype, byte flag)
 
{
 
	int32 ret;
 
	int32 total_cost = 0;
 
	CommandCost ret;
 
	CommandCost total_cost = 0;
 
	Town *t = NULL;
 
	int rating = 0;
 
	int i, j, k;
 
@@ -1734,7 +1734,7 @@ clear_town_stuff:;
 
}
 

	
 
// Returns rule and cost
 
static int AiBuildDefaultRailTrack(TileIndex tile, byte p0, byte p1, byte p2, byte p3, byte dir, byte cargo, RailType railtype, int32* cost)
 
static int AiBuildDefaultRailTrack(TileIndex tile, byte p0, byte p1, byte p2, byte p3, byte dir, byte cargo, RailType railtype, CommandCost* cost)
 
{
 
	int i;
 
	const AiDefaultRailBlock *p;
 
@@ -1821,7 +1821,7 @@ static void AiStateBuildDefaultRailBlock
 
	int j;
 
	AiBuildRec *aib;
 
	int rule;
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	// time out?
 
	if (++p->ai.timeout_counter == 1388) {
 
@@ -2067,7 +2067,7 @@ static inline void AiCheckBuildRailTunne
 
	uint z;
 

	
 
	if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
 
		int32 cost = DoCommand(tile, arf->player->ai.railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
 
		CommandCost cost = DoCommand(tile, arf->player->ai.railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
 

	
 
		if (!CmdFailed(cost) && cost <= (arf->player->player_money >> 4)) {
 
			AiBuildRailRecursive(arf, _build_tunnel_endtile, p[0] & 3);
 
@@ -2465,7 +2465,7 @@ static void AiStateBuildRailVeh(Player *
 
	EngineID veh;
 
	int i;
 
	CargoID cargo;
 
	int32 cost;
 
	CommandCost cost;
 
	Vehicle *v;
 
	VehicleID loco_id;
 

	
 
@@ -2605,10 +2605,10 @@ static bool AiCheckRoadResources(TileInd
 
}
 

	
 
static bool _want_road_truck_station;
 
static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag);
 
static CommandCost AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag);
 

	
 
// Returns rule and cost
 
static int AiFindBestDefaultRoadBlock(TileIndex tile, byte direction, byte cargo, int32 *cost)
 
static int AiFindBestDefaultRoadBlock(TileIndex tile, byte direction, byte cargo, CommandCost *cost)
 
{
 
	int i;
 
	const AiDefaultRoadBlock *p;
 
@@ -2626,10 +2626,10 @@ static int AiFindBestDefaultRoadBlock(Ti
 
	return -1;
 
}
 

	
 
static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag)
 
static CommandCost AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag)
 
{
 
	int32 ret;
 
	int32 total_cost = 0;
 
	CommandCost ret;
 
	CommandCost total_cost = 0;
 
	Town *t = NULL;
 
	int rating = 0;
 
	int roadflag = 0;
 
@@ -2721,7 +2721,7 @@ static void AiStateBuildDefaultRoadBlock
 
	int j;
 
	AiBuildRec *aib;
 
	int rule;
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	// time out?
 
	if (++p->ai.timeout_counter == 1388) {
 
@@ -2758,7 +2758,7 @@ static void AiStateBuildDefaultRoadBlock
 
					p->ai.state_mode = -p->ai.state_mode;
 
				}
 
			} else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p, aib->use_tile)) {
 
				int32 r;
 
				CommandCost r;
 

	
 
				// player has money, build it.
 
				aib->cur_building_rule = rule;
 
@@ -2967,7 +2967,7 @@ static inline void AiCheckBuildRoadTunne
 
	uint z;
 

	
 
	if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
 
		int32 cost = DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
 
		CommandCost cost = DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
 

	
 
		if (!CmdFailed(cost) && cost <= (arf->player->player_money >> 4)) {
 
			AiBuildRoadRecursive(arf, _build_tunnel_endtile, p[0] & 3);
 
@@ -3101,7 +3101,7 @@ do_some_terraform:
 
		 */
 
		for (i = 10; i != 0; i--) {
 
			if (CheckBridge_Stuff(i, bridge_len)) {
 
				int32 cost = DoCommand(tile, p->ai.cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE);
 
				CommandCost cost = DoCommand(tile, p->ai.cur_tile_a, i + ((0x80 | ROADTYPES_ROAD) << 8), DC_AUTO, CMD_BUILD_BRIDGE);
 
				if (!CmdFailed(cost) && cost < (p->player_money >> 5)) break;
 
			}
 
		}
 
@@ -3387,10 +3387,10 @@ static void AiStateAirportStuff(Player *
 
	p->ai.state_counter = 0;
 
}
 

	
 
static int32 AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag)
 
static CommandCost AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockData *p, byte flag)
 
{
 
	uint32 avail_airports = GetValidAirports();
 
	int32 total_cost = 0, ret;
 
	CommandCost total_cost = 0, ret;
 

	
 
	for (; p->mode == 0; p++) {
 
		if (!HASBIT(avail_airports, p->attr)) return CMD_ERROR;
 
@@ -3424,7 +3424,7 @@ static bool AiCheckAirportResources(Tile
 
	return true;
 
}
 

	
 
static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli, int32 *cost)
 
static int AiFindBestDefaultAirportBlock(TileIndex tile, byte cargo, byte heli, CommandCost *cost)
 
{
 
	const AiDefaultBlockData *p;
 
	uint i;
 
@@ -3446,7 +3446,7 @@ static void AiStateBuildDefaultAirportBl
 
	int i, j;
 
	AiBuildRec *aib;
 
	int rule;
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	// time out?
 
	if (++p->ai.timeout_counter == 1388) {
 
@@ -3485,7 +3485,7 @@ static void AiStateBuildDefaultAirportBl
 
				}
 
			} else if (CheckPlayerHasMoney(cost) && AiCheckBlockDistances(p, aib->use_tile)) {
 
				// player has money, build it.
 
				int32 r;
 
				CommandCost r;
 

	
 
				aib->cur_building_rule = rule;
 

	
src/ai/trolly/build.cpp
Show inline comments
 
@@ -36,7 +36,7 @@ bool AiNew_Build_CompanyHQ(Player *p, Ti
 
//    numtracks : in case of AI_TRAIN: tracks of station
 
//    direction : the direction of the station
 
//    flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
 
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
 
CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
 
{
 
	if (type == AI_TRAIN)
 
		return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
 
@@ -53,7 +53,7 @@ int AiNew_Build_Station(Player *p, byte 
 
//   tile_a : starting point
 
//   tile_b : end point
 
//   flag : flag passed to DoCommand
 
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
 
CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
 
{
 
	int bridge_type, bridge_len, type, type2;
 

	
 
@@ -90,15 +90,15 @@ int AiNew_Build_Bridge(Player *p, TileIn
 
//   part : Which part we need to build
 
//
 
// TODO: skip already builded road-pieces (e.g.: cityroad)
 
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag)
 
CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag)
 
{
 
	int part = PathFinderInfo->position;
 
	byte *route_extra = PathFinderInfo->route_extra;
 
	TileIndex *route = PathFinderInfo->route;
 
	int dir;
 
	int old_dir = -1;
 
	int cost = 0;
 
	int res;
 
	CommandCost cost = 0;
 
	CommandCost res;
 
	// We need to calculate the direction with the parent of the parent.. so we skip
 
	//  the first pieces and the last piece
 
	if (part < 1) part = 1;
 
@@ -243,7 +243,7 @@ EngineID AiNew_PickVehicle(Player *p)
 
			const RoadVehicleInfo *rvi = RoadVehInfo(i);
 
			const Engine* e = GetEngine(i);
 
			int32 rating;
 
			int32 ret;
 
			CommandCost ret;
 

	
 
			/* Skip vehicles which can't take our cargo type */
 
			if (rvi->cargo_type != p->ainew.cargo && !CanRefitTo(i, p->ainew.cargo)) continue;
 
@@ -293,7 +293,7 @@ void CcAI(bool success, TileIndex tile, 
 

	
 

	
 
// Builds the best vehicle possible
 
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
 
CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
 
{
 
	EngineID i = AiNew_PickVehicle(p);
 

	
 
@@ -307,9 +307,9 @@ int AiNew_Build_Vehicle(Player *p, TileI
 
	}
 
}
 

	
 
int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
 
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
 
{
 
	int ret, ret2;
 
	CommandCost ret, ret2;
 
	if (p->ainew.tbt == AI_TRAIN) {
 
		return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
 
	} else {
src/ai/trolly/pathfinder.cpp
Show inline comments
 
@@ -23,7 +23,7 @@ static bool TestCanBuildStationHere(Tile
 
	Player *p = GetPlayer(_current_player);
 

	
 
	if (dir == TEST_STATION_NO_DIR) {
 
		int32 ret;
 
		CommandCost ret;
 
		// TODO: currently we only allow spots that can be access from al 4 directions...
 
		//  should be fixed!!!
 
		for (dir = 0; dir < 4; dir++) {
 
@@ -214,7 +214,7 @@ static void AyStar_AiPathFinder_FoundEnd
 
// What tiles are around us.
 
static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *current)
 
{
 
	int ret;
 
	CommandCost ret;
 
	int dir;
 

	
 
	Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
src/ai/trolly/trolly.cpp
Show inline comments
 
@@ -642,7 +642,7 @@ static void AiNew_State_FindStation(Play
 

	
 
	if (new_tile == 0 && p->ainew.tbt == AI_BUS) {
 
		uint x, y, i = 0;
 
		int r;
 
		CommandCost r;
 
		uint best;
 
		uint accepts[NUM_CARGO];
 
		TileIndex found_spot[AI_FINDSTATION_TILE_RANGE*AI_FINDSTATION_TILE_RANGE * 4];
 
@@ -788,7 +788,8 @@ static void AiNew_State_FindDepot(Player
 
	// To make the depot stand in the middle of the route, we start from the center..
 
	// But first we walk through the route see if we can find a depot that is ours
 
	//  this keeps things nice ;)
 
	int g, i, r;
 
	int g, i;
 
	CommandCost r;
 
	DiagDirection j;
 
	TileIndex tile;
 
	assert(p->ainew.state == AI_STATE_FIND_DEPOT);
 
@@ -984,7 +985,7 @@ static void AiNew_State_VerifyRoute(Play
 
// Build the stations
 
static void AiNew_State_BuildStation(Player *p)
 
{
 
	int res = 0;
 
	CommandCost res = 0;
 
	assert(p->ainew.state == AI_STATE_BUILD_STATION);
 
	if (p->ainew.temp == 0) {
 
		if (!IsTileType(p->ainew.from_tile, MP_STATION))
 
@@ -1037,8 +1038,8 @@ static void AiNew_State_BuildPath(Player
 
			// We don't want that, so try building some road left or right of the station
 
			int dir1, dir2, dir3;
 
			TileIndex tile;
 
			int i, ret;
 
			for (i=0;i<2;i++) {
 
			CommandCost ret;
 
			for (int i = 0; i < 2; i++) {
 
				if (i == 0) {
 
					tile = p->ainew.from_tile + TileOffsByDiagDir(p->ainew.from_direction);
 
					dir1 = p->ainew.from_direction - 1;
 
@@ -1102,7 +1103,7 @@ static void AiNew_State_BuildPath(Player
 
// Builds the depot
 
static void AiNew_State_BuildDepot(Player *p)
 
{
 
	int res = 0;
 
	CommandCost res = 0;
 
	assert(p->ainew.state == AI_STATE_BUILD_DEPOT);
 

	
 
	if (IsTileType(p->ainew.depot_tile, MP_STREET) && GetRoadTileType(p->ainew.depot_tile) == ROAD_TILE_DEPOT) {
 
@@ -1137,7 +1138,7 @@ static void AiNew_State_BuildDepot(Playe
 
// Build vehicles
 
static void AiNew_State_BuildVehicle(Player *p)
 
{
 
	int res;
 
	CommandCost res;
 
	assert(p->ainew.state == AI_STATE_BUILD_VEHICLE);
 

	
 
	// Check if we need to build a vehicle
 
@@ -1277,7 +1278,7 @@ static void AiNew_CheckVehicle(Player *p
 

	
 
			if (!AiNew_SetSpecialVehicleFlag(p, v, AI_VEHICLEFLAG_SELL)) return;
 
			{
 
				int ret = 0;
 
				CommandCost ret = 0;
 
				if (v->type == VEH_ROAD)
 
					ret = AI_DoCommand(0, v->index, 0, DC_EXEC, CMD_SEND_ROADVEH_TO_DEPOT);
 
				// This means we can not find a depot :s
src/ai/trolly/trolly.h
Show inline comments
 
@@ -252,11 +252,11 @@ uint AiNew_GetSpecialVehicleFlag(Player 
 

	
 
// ai_build.c
 
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile);
 
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
 
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
 
int AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
 
CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
 
CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
 
CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
 
EngineID AiNew_PickVehicle(Player *p);
 
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
 
int AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
 
CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
 
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
 

	
 
#endif /* AI_TROLLY_H */
src/aircraft_cmd.cpp
Show inline comments
 
@@ -227,7 +227,7 @@ void GetAircraftSpriteSize(EngineID engi
 
	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;
 
}
 
@@ -265,12 +265,12 @@ uint16 AircraftDefaultCargoCapacity(Carg
 
 * @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;
 
@@ -476,7 +476,7 @@ static void DoDeleteAircraft(Vehicle *v)
 
 * @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;
 

	
 
@@ -503,7 +503,7 @@ int32 CmdSellAircraft(TileIndex tile, ui
 
 * @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;
 

	
 
@@ -546,7 +546,7 @@ int32 CmdStartStopAircraft(TileIndex til
 
 * - 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 */
 
@@ -623,7 +623,7 @@ int32 CmdSendAircraftToHangar(TileIndex 
 
 * - 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);
 

	
 
@@ -668,7 +668,7 @@ int32 CmdRefitAircraft(TileIndex tile, u
 
	}
 
	_returned_refit_capacity = pass;
 

	
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
 
		cost = GetRefitCost(v->engine_type);
 
	}
 
@@ -744,7 +744,7 @@ void OnNewDay_Aircraft(Vehicle *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;
 

	
 
@@ -1379,7 +1379,7 @@ static void ProcessAircraftOrder(Vehicle
 
		 */
 
		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;
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -124,10 +124,10 @@ static CargoID GetNewCargoTypeForReplace
 
 * @param flags is the flags to use when calling DoCommand(). Mainly DC_EXEC counts
 
 * @return value is cost of the replacement or CMD_ERROR
 
 */
 
static int32 ReplaceVehicle(Vehicle **w, byte flags, int32 total_cost)
 
static CommandCost ReplaceVehicle(Vehicle **w, byte flags, int32 total_cost)
 
{
 
	int32 cost;
 
	int32 sell_value;
 
	CommandCost cost;
 
	CommandCost sell_value;
 
	Vehicle *old_v = *w;
 
	const Player *p = GetPlayer(old_v->owner);
 
	EngineID new_engine_type;
 
@@ -173,7 +173,7 @@ static int32 ReplaceVehicle(Vehicle **w,
 

	
 
	if (replacement_cargo_type != CT_NO_REFIT) {
 
		/* add refit cost */
 
		int32 refit_cost = GetRefitCost(new_engine_type);
 
		CommandCost refit_cost = GetRefitCost(new_engine_type);
 
		if (old_v->type == VEH_TRAIN && IsMultiheaded(old_v)) refit_cost += refit_cost; // pay for both ends
 
		cost += refit_cost;
 
	}
 
@@ -246,7 +246,7 @@ static int32 ReplaceVehicle(Vehicle **w,
 
			GetName(vehicle_name, old_v->string_id & 0x7FF, lastof(vehicle_name));
 
		}
 
	} else { // flags & DC_EXEC not set
 
		int32 tmp_move = 0;
 
		CommandCost tmp_move = 0;
 
		if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v) && old_v->next != NULL) {
 
			/* Verify that the wagons can be placed on the engine in question.
 
			 * This is done by building an engine, test if the wagons can be added and then sell the test engine. */
 
@@ -295,12 +295,12 @@ static int32 ReplaceVehicle(Vehicle **w,
 
 * @param display_costs If set, a cost animation is shown (only if check is false)
 
 * @return CMD_ERROR if something went wrong. Otherwise the price of the replace
 
 */
 
int32 MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
 
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs)
 
{
 
	Vehicle *w;
 
	const Player *p = GetPlayer(v->owner);
 
	byte flags = 0;
 
	int32 cost, temp_cost = 0;
 
	CommandCost cost, temp_cost = 0;
 
	bool stopped;
 

	
 
	/* Remember the length in case we need to trim train later on
src/bridge_gui.cpp
Show inline comments
 
@@ -113,7 +113,7 @@ static const WindowDesc _build_road_brid
 
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
 
{
 
	uint j = 0;
 
	int32 ret;
 
	CommandCost ret;
 
	StringID errmsg;
 

	
 
	DeleteWindowById(WC_BUILD_BRIDGE, 0);
src/clear_cmd.cpp
Show inline comments
 
@@ -36,7 +36,7 @@ struct TerraformerState {
 
	int modheight_count;
 
	int tile_table_count;
 

	
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	TileIndex *tile_table;
 
	TerraformerHeightMod *modheight;
 
@@ -97,7 +97,7 @@ static void TerraformAddDirtyTileAround(
 
static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
 
{
 
	int r;
 
	int32 ret;
 
	CommandCost ret;
 

	
 
	assert(tile < MapSize());
 

	
 
@@ -232,7 +232,7 @@ static bool TerraformTileHeight(Terrafor
 
 * @param p2 direction; eg up or down
 
 * @return error or cost of terraforming
 
 */
 
int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TerraformerState ts;
 
	TileIndex t;
 
@@ -357,14 +357,16 @@ int32 CmdTerraformLand(TileIndex tile, u
 
 * @param p2 unused
 
 * @return  error or cost of terraforming
 
 */
 
int32 CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int size_x, size_y;
 
	int ex;
 
	int ey;
 
	int sx, sy;
 
	uint h, curh;
 
	int32 ret, cost, money;
 
	int32 money;
 
	CommandCost ret;
 
	CommandCost cost;
 

	
 
	if (p1 >= MapSize()) return CMD_ERROR;
 

	
 
@@ -418,9 +420,9 @@ int32 CmdLevelLand(TileIndex tile, uint3
 
 * @param p2 unused
 
 * @return error of cost of operation
 
 */
 
int32 CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -442,7 +444,7 @@ int32 CmdPurchaseLandArea(TileIndex tile
 
}
 

	
 

	
 
static int32 ClearTile_Clear(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Clear(TileIndex tile, byte flags)
 
{
 
	static const int32* clear_price_table[] = {
 
		&_price.clear_1,
 
@@ -453,7 +455,7 @@ static int32 ClearTile_Clear(TileIndex t
 
		&_price.purchase_land,
 
		&_price.clear_2, // XXX unused?
 
	};
 
	int32 price;
 
	CommandCost price;
 

	
 
	if (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) == 0) {
 
		price = 0;
 
@@ -474,7 +476,7 @@ static int32 ClearTile_Clear(TileIndex t
 
 * @param p2 unused
 
 * @return error or cost of operation
 
 */
 
int32 CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
src/command.cpp
Show inline comments
 
@@ -17,7 +17,7 @@
 

	
 
const char* _cmd_text = NULL;
 

	
 
#define DEF_COMMAND(yyyy) int32 yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
#define DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 

	
 
DEF_COMMAND(CmdBuildRailroadTrack);
 
DEF_COMMAND(CmdRemoveRailroadTrack);
 
@@ -351,9 +351,9 @@ byte GetCommandFlags(uint cmd)
 

	
 
static int _docommand_recursive;
 

	
 
int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
 
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
 
{
 
	int32 res;
 
	CommandCost res;
 
	CommandProc *proc;
 

	
 
	/* Do not even think about executing out-of-bounds tile-commands */
 
@@ -425,7 +425,7 @@ int32 GetAvailableMoneyForCommand()
 
 * the callback is called when the command succeeded or failed. */
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd)
 
{
 
	int32 res = 0, res2;
 
	CommandCost res = 0, res2;
 
	CommandProc *proc;
 
	uint32 flags;
 
	bool notest;
src/command.h
Show inline comments
 
@@ -184,7 +184,7 @@ enum {
 
	CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
 
};
 

	
 
typedef int32 CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
 
typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
 

	
 
struct Command {
 
	CommandProc *proc;
 
@@ -199,7 +199,7 @@ struct Command {
 
 * @param res the resulting value from the command to be checked
 
 * @return Return true if the command failed, false otherwise
 
 */
 
static inline bool CmdFailed(int32 res)
 
static inline bool CmdFailed(CommandCost res)
 
{
 
	/* lower 16bits are the StringID of the possible error */
 
	return res <= (CMD_ERROR | INVALID_STRING_ID);
 
@@ -207,7 +207,7 @@ static inline bool CmdFailed(int32 res)
 

	
 
/* command.cpp */
 
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
 
int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
 
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
 

	
 
#ifdef ENABLE_NETWORK
src/dummy_land.cpp
Show inline comments
 
@@ -26,7 +26,7 @@ static Slope GetSlopeTileh_Dummy(TileInd
 
	return SLOPE_FLAT;
 
}
 

	
 
static int32 ClearTile_Dummy(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Dummy(TileIndex tile, byte flags)
 
{
 
	return_cmd_error(STR_0001_OFF_EDGE_OF_MAP);
 
}
src/economy.cpp
Show inline comments
 
@@ -259,7 +259,7 @@ void ChangeOwnershipOfPlayerItems(Player
 
			for (i = 0; i < 4; i++) {
 
				if (p->share_owners[i] == old_player) {
 
					/* Sell his shares */
 
					int32 res = DoCommand(0, p->index, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
 
					CommandCost res = DoCommand(0, p->index, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
 
					/* Because we are in a DoCommand, we can't just execute an other one and
 
					 *  expect the money to be removed. We need to do it ourself! */
 
					SubtractMoneyFromPlayer(res);
 
@@ -273,7 +273,7 @@ void ChangeOwnershipOfPlayerItems(Player
 
			_current_player = p->share_owners[i];
 
			if (_current_player != PLAYER_SPECTATOR) {
 
				/* Sell the shares */
 
				int32 res = DoCommand(0, old_player, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
 
				CommandCost res = DoCommand(0, old_player, 0, DC_EXEC, CMD_SELL_SHARE_IN_COMPANY);
 
				/* Because we are in a DoCommand, we can't just execute an other one and
 
				 *  expect the money to be removed. We need to do it ourself! */
 
				SubtractMoneyFromPlayer(res);
 
@@ -1808,10 +1808,10 @@ extern int GetAmountOwnedBy(const Player
 
 * @param p1 player to buy the shares from
 
 * @param p2 unused
 
 */
 
int32 CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	int64 cost;
 
	CommandCost cost;
 

	
 
	/* Check if buying shares is allowed (protection against modified clients */
 
	if (!IsValidPlayer((PlayerID)p1) || !_patches.allow_shares) return CMD_ERROR;
 
@@ -1854,7 +1854,7 @@ int32 CmdBuyShareInCompany(TileIndex til
 
 * @param p1 player to sell the shares from
 
 * @param p2 unused
 
 */
 
int32 CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	int64 cost;
 
@@ -1890,7 +1890,7 @@ int32 CmdSellShareInCompany(TileIndex ti
 
 * @param p1 player/company to buy up
 
 * @param p2 unused
 
 */
 
int32 CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	PlayerID pid = (PlayerID)p1;
src/engine.cpp
Show inline comments
 
@@ -266,7 +266,7 @@ void EnginesDailyLoop()
 
 * @param p1 engine-prototype offered
 
 * @param p2 unused
 
 */
 
int32 CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Engine *e;
 

	
 
@@ -374,7 +374,7 @@ void EnginesMonthlyLoop()
 
 * @param p1 engine ID to rename
 
 * @param p2 unused
 
 */
 
int32 CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str;
 

	
 
@@ -533,7 +533,7 @@ EngineID EngineReplacement(EngineRenewLi
 
	return er == NULL ? INVALID_ENGINE : er->to;
 
}
 

	
 
int32 AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
 
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags)
 
{
 
	EngineRenew *er;
 

	
 
@@ -560,7 +560,7 @@ int32 AddEngineReplacement(EngineRenewLi
 
	return 0;
 
}
 

	
 
int32 RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags)
 
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, uint32 flags)
 
{
 
	EngineRenew *er = (EngineRenew *)(*erl);
 
	EngineRenew *prev = NULL;
src/engine.h
Show inline comments
 
@@ -328,7 +328,7 @@ EngineID EngineReplacement(EngineRenewLi
 
 * @param flags The calling command flags.
 
 * @return 0 on success, CMD_ERROR on failure.
 
 */
 
int32 AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
 
CommandCost AddEngineReplacement(EngineRenewList* erl, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags);
 

	
 
/**
 
 * Remove an engine replacement from a given renewlist.
 
@@ -337,7 +337,7 @@ int32 AddEngineReplacement(EngineRenewLi
 
 * @param flags The calling command flags.
 
 * @return 0 on success, CMD_ERROR on failure.
 
 */
 
int32 RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, GroupID group, uint32 flags);
 
CommandCost RemoveEngineReplacement(EngineRenewList* erl, EngineID engine, GroupID group, uint32 flags);
 

	
 
/** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
 
 * @param type The type of engine
src/functions.h
Show inline comments
 
@@ -20,9 +20,9 @@ void DrawShipDepotSprite(int x, int y, i
 
void TileLoop_Water(TileIndex tile);
 

	
 
/* players.cpp */
 
bool CheckPlayerHasMoney(int32 cost);
 
void SubtractMoneyFromPlayer(int32 cost);
 
void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost);
 
bool CheckPlayerHasMoney(CommandCost cost);
 
void SubtractMoneyFromPlayer(CommandCost cost);
 
void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cost);
 
bool CheckOwnership(Owner owner);
 
bool CheckTileOwnership(TileIndex tile);
 
StringID GetPlayerNameString(PlayerID player, uint index);
src/group_cmd.cpp
Show inline comments
 
@@ -93,7 +93,7 @@ static WindowClass GetWCForVT(VehicleTyp
 
 * @param p1   vehicle type
 
 * @param p2   unused
 
 */
 
int32 CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	VehicleType vt = (VehicleType)p1;
 
	if (!IsPlayerBuildableVehicleType(vt)) return CMD_ERROR;
 
@@ -121,7 +121,7 @@ int32 CmdCreateGroup(TileIndex tile, uin
 
 *      - p1 bit 0-15 : GroupID
 
 * @param p2   unused
 
 */
 
int32 CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidGroupID(p1)) return CMD_ERROR;
 

	
 
@@ -167,7 +167,7 @@ int32 CmdDeleteGroup(TileIndex tile, uin
 
 *   - p1 bit 0-15 : GroupID
 
 * @param p2   unused
 
 */
 
int32 CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidGroupID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
 

	
 
@@ -199,7 +199,7 @@ int32 CmdRenameGroup(TileIndex tile, uin
 
 * @param p2   vehicle to add to a group
 
 *   - p2 bit 0-15 : VehicleID
 
 */
 
int32 CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	GroupID new_g = p1;
 

	
 
@@ -245,7 +245,7 @@ int32 CmdAddVehicleGroup(TileIndex tile,
 
 *  - p1 bit 0-15 : GroupID
 
 * @param p2   type of vehicles
 
 */
 
int32 CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	VehicleType type = (VehicleType)p2;
 
	if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
 
@@ -282,7 +282,7 @@ int32 CmdAddSharedVehicleGroup(TileIndex
 
 * - p1 bit 0-15 : GroupID
 
 * @param p2   type of vehicles
 
 */
 
int32 CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	VehicleType type = (VehicleType)p2;
 
	if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
 
@@ -319,7 +319,7 @@ int32 CmdRemoveAllVehiclesGroup(TileInde
 
 * @param p2
 
 * - p2 bit 0    : 1 to set or 0 to clear protection.
 
 */
 
int32 CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidGroupID(p1)) return CMD_ERROR;
 

	
src/industry_cmd.cpp
Show inline comments
 
@@ -336,7 +336,7 @@ static void GetTileDesc_Industry(TileInd
 
	}
 
}
 

	
 
static int32 ClearTile_Industry(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Industry(TileIndex tile, byte flags)
 
{
 
	Industry *i = GetIndustryByTile(tile);
 
	const IndustrySpec *indspec = GetIndustrySpec(i->type);
 
@@ -1469,7 +1469,7 @@ static Industry *CreateNewIndustryHelper
 
 * @param p2 unused
 
 * @return index of the newly create industry, or CMD_ERROR if it failed
 
 */
 
int32 CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int num;
 
	const IndustryTileTable * const *itt;
src/landscape.cpp
Show inline comments
 
@@ -367,7 +367,7 @@ void ClearSnowLine(void)
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
int32 CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -380,9 +380,9 @@ int32 CmdLandscapeClear(TileIndex tile, 
 
 * @param flags of operation to conduct
 
 * @param p2 unused
 
 */
 
int32 CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost, ret, money;
 
	CommandCost cost, ret, money;
 
	int ex;
 
	int ey;
 
	int sx, sy;
src/misc_cmd.cpp
Show inline comments
 
@@ -24,7 +24,7 @@
 
 * @param p1 unused
 
 * @param p2 face bitmasked
 
 */
 
int32 CmdSetPlayerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSetPlayerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	PlayerFace pf = (PlayerFace)p2;
 

	
 
@@ -45,7 +45,7 @@ int32 CmdSetPlayerFace(TileIndex tile, u
 
 * p1 bits 8-9 set in use state or first/second colour
 
 * @param p2 new colour for vehicles, property, etc.
 
 */
 
int32 CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p, *pp;
 
	byte colour;
 
@@ -124,7 +124,7 @@ int32 CmdSetPlayerColor(TileIndex tile, 
 
 * @param p2 when 0: loans LOAN_INTERVAL
 
 *           when 1: loans the maximum loan permitting money (press CTRL),
 
 */
 
int32 CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p = GetPlayer(_current_player);
 

	
 
@@ -161,7 +161,7 @@ int32 CmdIncreaseLoan(TileIndex tile, ui
 
 * @param p2 when 0: pays back LOAN_INTERVAL
 
 *           when 1: pays back the maximum loan permitting money (press CTRL),
 
 */
 
int32 CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p = GetPlayer(_current_player);
 

	
 
@@ -199,7 +199,7 @@ int32 CmdDecreaseLoan(TileIndex tile, ui
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
int32 CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str;
 
	Player *p;
 
@@ -227,7 +227,7 @@ int32 CmdChangeCompanyName(TileIndex til
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
int32 CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str;
 
	Player *p;
 
@@ -266,7 +266,7 @@ int32 CmdChangePresidentName(TileIndex t
 
 * @param p1 0 = decrease pause counter; 1 = increase pause counter
 
 * @param p2 unused
 
 */
 
int32 CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (flags & DC_EXEC) {
 
		_pause_game += (p1 == 1) ? 1 : -1;
 
@@ -285,7 +285,7 @@ int32 CmdPause(TileIndex tile, uint32 fl
 
 * @param p1 the amount of money to receive (if negative), or spend (if positive)
 
 * @param p2 unused
 
 */
 
int32 CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
#ifndef _DEBUG
 
	if (_networking) return CMD_ERROR;
 
@@ -303,10 +303,10 @@ int32 CmdMoneyCheat(TileIndex tile, uint
 
 * @param p1 the amount of money to transfer; max 20.000.000
 
 * @param p2 the player to transfer the money to
 
 */
 
int32 CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	const Player *p = GetPlayer(_current_player);
 
	int32 amount = min((int32)p1, 20000000);
 
	CommandCost amount = min((int32)p1, 20000000);
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 

	
 
@@ -336,7 +336,7 @@ int32 CmdGiveMoney(TileIndex tile, uint3
 
 *           itself is changed. The new value is inside p2
 
 * @param p2 new value for a difficulty setting or difficulty level
 
 */
 
int32 CmdChangeDifficultyLevel(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdChangeDifficultyLevel(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (p1 != (uint32)-1L && ((int32)p1 >= GAME_DIFFICULTY_NUM || (int32)p1 < 0)) return CMD_ERROR;
 

	
src/openttd.h
Show inline comments
 
@@ -67,6 +67,7 @@ typedef uint16 SignID;
 
typedef uint16 GroupID;
 
typedef uint16 EngineRenewID;
 
typedef uint16 DestinationID;
 
typedef int32 CommandCost;
 

	
 
/* DestinationID must be at least as large as every these below, because it can
 
 * be any of them
src/order_cmd.cpp
Show inline comments
 
@@ -190,7 +190,7 @@ static TileIndex GetOrderLocation(const 
 
 *                        only the first 8 bits used currently (bit 16 - 23) (max 255)
 
 * @param p2 packed order to insert
 
 */
 
int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	VehicleID veh   = GB(p1,  0, 16);
 
@@ -448,7 +448,7 @@ int32 CmdInsertOrder(TileIndex tile, uin
 
 * @param *dst delete the orders of this vehicle
 
 * @param flags execution flags
 
 */
 
static int32 DecloneOrder(Vehicle *dst, uint32 flags)
 
static CommandCost DecloneOrder(Vehicle *dst, uint32 flags)
 
{
 
	if (flags & DC_EXEC) {
 
		DeleteVehicleOrders(dst);
 
@@ -483,7 +483,7 @@ static void RemoveSharedOrderVehicleList
 
 * @param p1 the ID of the vehicle
 
 * @param p2 the order to delete (max 255)
 
 */
 
int32 CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v, *u;
 
	VehicleID veh_id = p1;
 
@@ -563,7 +563,7 @@ int32 CmdDeleteOrder(TileIndex tile, uin
 
 * @param p1 The ID of the vehicle which order is skipped
 
 * @param p2 the selected order to which we want to skip
 
 */
 
int32 CmdSkipToOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSkipToOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	VehicleID veh_id = p1;
 
@@ -608,7 +608,7 @@ int32 CmdSkipToOrder(TileIndex tile, uin
 
 * @note The target order will move one place down in the orderlist
 
 *  if you move the order upwards else it'll move it one place down
 
 */
 
int32 CmdMoveOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdMoveOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	VehicleID veh = p1;
 
	VehicleOrderID moving_order = GB(p2,  0, 16);
 
@@ -694,7 +694,7 @@ int32 CmdMoveOrder(TileIndex tile, uint3
 
 *                        only the first 8 bits used currently (bit 16 - 23) (max 255)
 
 * @param p2 mode to change the order to (always set)
 
 */
 
int32 CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	Order *order;
 
@@ -774,7 +774,7 @@ int32 CmdModifyOrder(TileIndex tile, uin
 
 * - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)
 
 * @param p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE
 
 */
 
int32 CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *dst;
 
	VehicleID veh_src = GB(p1, 16, 16);
 
@@ -908,7 +908,7 @@ int32 CmdCloneOrder(TileIndex tile, uint
 
 *   - bit 8-15 Cargo subtype
 
 *   - bit 16-23 number of order to modify
 
 */
 
int32 CmdOrderRefit(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdOrderRefit(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	const Vehicle *v;
 
	Order *order;
 
@@ -1039,7 +1039,7 @@ void RestoreVehicleOrders(const Vehicle*
 
 * If we do want to backup/restore it, just add UnitID uid to BackuppedOrders, and
 
 * restore it as parameter 'y' (ugly hack I know) for example. "v->unitnumber = y;"
 
 */
 
int32 CmdRestoreOrderIndex(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRestoreOrderIndex(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	VehicleOrderID cur_ord = GB(p2,  0, 16);
src/player.h
Show inline comments
 
@@ -337,7 +337,7 @@ static inline bool EngineHasReplacementF
 
 * @param flags The calling command flags.
 
 * @return 0 on success, CMD_ERROR on failure.
 
 */
 
static inline int32 AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags) { return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags); }
 
static inline CommandCost AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags) { return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags); }
 

	
 
/**
 
 * Remove an engine replacement for the player.
 
@@ -346,7 +346,7 @@ static inline int32 AddEngineReplacement
 
 * @param flags The calling command flags.
 
 * @return 0 on success, CMD_ERROR on failure.
 
 */
 
static inline int32 RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags) {return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags); }
 
static inline CommandCost RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags) {return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags); }
 

	
 
/**
 
 * Reset the livery schemes to the player's primary colour.
src/players.cpp
Show inline comments
 
@@ -173,7 +173,7 @@ void InvalidatePlayerWindows(const Playe
 
	InvalidateWindow(WC_FINANCES, pid);
 
}
 

	
 
bool CheckPlayerHasMoney(int32 cost)
 
bool CheckPlayerHasMoney(CommandCost cost)
 
{
 
	if (cost > 0) {
 
		PlayerID pid = _current_player;
 
@@ -186,7 +186,7 @@ bool CheckPlayerHasMoney(int32 cost)
 
	return true;
 
}
 

	
 
static void SubtractMoneyFromAnyPlayer(Player *p, int32 cost)
 
static void SubtractMoneyFromAnyPlayer(Player *p, CommandCost cost)
 
{
 
	p->money64 -= cost;
 
	UpdatePlayerMoney32(p);
 
@@ -210,14 +210,14 @@ static void SubtractMoneyFromAnyPlayer(P
 
	InvalidatePlayerWindows(p);
 
}
 

	
 
void SubtractMoneyFromPlayer(int32 cost)
 
void SubtractMoneyFromPlayer(CommandCost cost)
 
{
 
	PlayerID pid = _current_player;
 

	
 
	if (IsValidPlayer(pid)) SubtractMoneyFromAnyPlayer(GetPlayer(pid), cost);
 
}
 

	
 
void SubtractMoneyFromPlayerFract(PlayerID player, int32 cost)
 
void SubtractMoneyFromPlayerFract(PlayerID player, CommandCost cost)
 
{
 
	Player *p = GetPlayer(player);
 
	byte m = p->player_money_fraction;
 
@@ -676,7 +676,7 @@ static void DeletePlayerStuff(PlayerID p
 
 * if p1 = 5, then
 
 * - p2 = enable renew_keep_length
 
 */
 
int32 CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	if (!IsValidPlayer(_current_player)) return CMD_ERROR;
 
@@ -723,7 +723,7 @@ int32 CmdSetAutoReplace(TileIndex tile, 
 
			EngineID old_engine_type = GB(p2, 0, 16);
 
			EngineID new_engine_type = GB(p2, 16, 16);
 
			GroupID id_g = GB(p1, 16, 16);
 
			int32 cost;
 
			CommandCost cost;
 

	
 
			if (!IsValidGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR;
 
			if (new_engine_type != INVALID_ENGINE) {
 
@@ -805,7 +805,7 @@ int32 CmdSetAutoReplace(TileIndex tile, 
 
 * @arg - network_server.c:838 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)@n
 
 * @arg - network_client.c:536 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) from where the map has been received
 
 */
 
int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (flags & DC_EXEC) _current_player = OWNER_NONE;
 

	
src/rail_cmd.cpp
Show inline comments
 
@@ -189,7 +189,7 @@ uint GetRailFoundation(Slope tileh, Trac
 
}
 

	
 

	
 
static uint32 CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile)
 
static CommandCost CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile)
 
{
 
	if (IsSteepSlope(tileh)) {
 
		if (_patches.build_on_slopes && existing == 0) {
 
@@ -231,14 +231,14 @@ static inline bool ValParamTrackOrientat
 
 * @param p1 railtype of being built piece (normal, mono, maglev)
 
 * @param p2 rail track to build
 
 */
 
int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Slope tileh;
 
	RailType railtype;
 
	Track track;
 
	TrackBits trackbit;
 
	int32 cost = 0;
 
	int32 ret;
 
	CommandCost cost = 0;
 
	CommandCost ret;
 

	
 
	if (!ValParamRailtype(p1) || !ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
 
	railtype = (RailType)p1;
 
@@ -355,11 +355,11 @@ int32 CmdBuildSingleRail(TileIndex tile,
 
 * @param p1 unused
 
 * @param p2 rail orientation
 
 */
 
int32 CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Track track = (Track)p2;
 
	TrackBits trackbit;
 
	int32 cost = _price.remove_rail;
 
	CommandCost cost = _price.remove_rail;
 
	bool crossing = false;
 

	
 
	if (!ValParamTrackOrientation((Track)p2)) return CMD_ERROR;
 
@@ -444,7 +444,7 @@ static const TileIndexDiffC _trackdelta[
 
};
 

	
 

	
 
static int32 ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileIndex end)
 
static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileIndex end)
 
{
 
	int x = TileX(start);
 
	int y = TileY(start);
 
@@ -504,9 +504,9 @@ static int32 ValidateAutoDrag(Trackdir *
 
 * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
 
 * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
 
 */
 
static int32 CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 ret, total_cost = 0;
 
	CommandCost ret, total_cost = 0;
 
	Track track = (Track)GB(p2, 4, 3);
 
	Trackdir trackdir;
 
	byte mode = HASBIT(p2, 7);
 
@@ -556,7 +556,7 @@ static int32 CmdRailTrackHelper(TileInde
 
 * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
 
 * @see CmdRailTrackHelper
 
 */
 
int32 CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	return CmdRailTrackHelper(tile, flags, p1, CLRBIT(p2, 7));
 
}
 
@@ -572,7 +572,7 @@ int32 CmdBuildRailroadTrack(TileIndex ti
 
 * - p2 = (bit 7)   - 0 = build, 1 = remove tracks
 
 * @see CmdRailTrackHelper
 
 */
 
int32 CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	return CmdRailTrackHelper(tile, flags, p1, SETBIT(p2, 7));
 
}
 
@@ -586,10 +586,10 @@ int32 CmdRemoveRailroadTrack(TileIndex t
 
 * @todo When checking for the tile slope,
 
 * distingush between "Flat land required" and "land sloped in wrong direction"
 
 */
 
int32 CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Depot *d;
 
	int32 cost, ret;
 
	CommandCost cost, ret;
 
	Slope tileh;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
@@ -653,12 +653,12 @@ int32 CmdBuildTrainDepot(TileIndex tile,
 
 * @param p2 used for CmdBuildManySignals() to copy direction of first signal
 
 * TODO: p2 should be replaced by two bits for "along" and "against" the track.
 
 */
 
int32 CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Track track = (Track)GB(p1, 0, 3);
 
	bool pre_signal = HASBIT(p1, 3);
 
	SignalVariant sigvar = (pre_signal ^ HASBIT(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC;
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicleOnGround(tile))
 
		return CMD_ERROR;
 
@@ -750,9 +750,10 @@ int32 CmdBuildSingleSignal(TileIndex til
 
 * - p2 = (bit  5)    - 0 = build, 1 = remove signals
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 */
 
static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 ret, total_cost, signal_ctr;
 
	CommandCost ret, total_cost;
 
	int signal_ctr;
 
	byte signals;
 
	bool error = true;
 
	TileIndex end_tile;
 
@@ -840,7 +841,7 @@ static int32 CmdSignalTrackHelper(TileIn
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @see CmdSignalTrackHelper
 
 */
 
int32 CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	return CmdSignalTrackHelper(tile, flags, p1, p2);
 
}
 
@@ -854,7 +855,7 @@ int32 CmdBuildSignalTrack(TileIndex tile
 
 *           - (bit  4)    - 0 = signals, 1 = semaphores
 
 * @param p2 unused
 
 */
 
int32 CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Track track = (Track)GB(p1, 0, 3);
 

	
 
@@ -903,12 +904,12 @@ int32 CmdRemoveSingleSignal(TileIndex ti
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @see CmdSignalTrackHelper
 
 */
 
int32 CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	return CmdSignalTrackHelper(tile, flags, p1, SETBIT(p2, 5)); // bit 5 is remove bit
 
}
 

	
 
typedef int32 DoConvertRailProc(TileIndex tile, RailType totype, bool exec);
 
typedef CommandCost DoConvertRailProc(TileIndex tile, RailType totype, bool exec);
 

	
 
/**
 
 * Switches the rail type.
 
@@ -920,7 +921,7 @@ typedef int32 DoConvertRailProc(TileInde
 
 * @return            The cost and state of the operation
 
 * @retval CMD_ERROR  An error occured during the operation.
 
 */
 
static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec)
 
static CommandCost DoConvertRail(TileIndex tile, RailType totype, bool exec)
 
{
 
	if (!CheckTileOwnership(tile)) return CMD_ERROR;
 

	
 
@@ -960,9 +961,9 @@ static int32 DoConvertRail(TileIndex til
 
	return _price.build_rail / 2;
 
}
 

	
 
extern int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec);
 
extern int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec);
 
extern int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec);
 
extern CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec);
 
extern CommandCost DoConvertStreetRail(TileIndex tile, RailType totype, bool exec);
 
extern CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec);
 

	
 
/** Convert one rail type to the other. You can convert normal rail to
 
 * monorail/maglev easily or vice-versa.
 
@@ -971,9 +972,10 @@ extern int32 DoConvertTunnelBridgeRail(T
 
 * @param p1 start tile of drag
 
 * @param p2 new railtype to convert to
 
 */
 
int32 CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 ret, cost, money;
 
	CommandCost ret, cost;
 
	int32 money;
 
	int ex;
 
	int ey;
 
	int sx, sy, x, y;
 
@@ -1026,7 +1028,7 @@ int32 CmdConvertRail(TileIndex tile, uin
 
	return (cost == 0) ? ret : cost;
 
}
 

	
 
static int32 RemoveTrainDepot(TileIndex tile, uint32 flags)
 
static CommandCost RemoveTrainDepot(TileIndex tile, uint32 flags)
 
{
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 
@@ -1045,10 +1047,10 @@ static int32 RemoveTrainDepot(TileIndex 
 
	return _price.remove_train_depot;
 
}
 

	
 
static int32 ClearTile_Track(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Track(TileIndex tile, byte flags)
 
{
 
	int32 cost;
 
	int32 ret;
 
	CommandCost cost;
 
	CommandCost ret;
 

	
 
	if (flags & DC_AUTO) {
 
		if (!IsTileOwner(tile, _current_player))
src/road_cmd.cpp
Show inline comments
 
@@ -107,7 +107,7 @@ static bool CheckAllowRemoveRoad(TileInd
 
 *                    removing the tram bits before the test.
 
 * @param p2 unused
 
 */
 
int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	/* cost for removing inner/edge -roads */
 
	static const uint16 road_remove_cost[2] = {50, 18};
 
@@ -166,7 +166,7 @@ int32 CmdRemoveRoad(TileIndex tile, uint
 
		/* If it's the last roadtype, just clear the whole tile */
 
		if (rts == RoadTypeToRoadTypes(rt)) return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 

	
 
		int32 cost;
 
		CommandCost cost;
 
		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
			TileIndex other_end = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
 
			/* Pay for *every* tile of the bridge or tunnel */
 
@@ -301,7 +301,7 @@ static const RoadBits _valid_tileh_slope
 
};
 

	
 

	
 
static uint32 CheckRoadSlope(Slope tileh, RoadBits* pieces, RoadBits existing)
 
static CommandCost CheckRoadSlope(Slope tileh, RoadBits* pieces, RoadBits existing)
 
{
 
	RoadBits road_bits;
 

	
 
@@ -346,10 +346,10 @@ static uint32 CheckRoadSlope(Slope tileh
 
 *           bit 6..7 disallowed directions to toggle
 
 * @param p2 the town that is building the road (0 if not applicable)
 
 */
 
int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost = 0;
 
	int32 ret;
 
	CommandCost cost = 0;
 
	CommandCost ret;
 
	RoadBits existing = ROAD_NONE;
 
	RoadBits all_bits = ROAD_NONE;
 
	Slope tileh;
 
@@ -553,7 +553,7 @@ do_clear:;
 
 * @return            The cost and state of the operation
 
 * @retval CMD_ERROR  An error occured during the operation.
 
 */
 
int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
 
CommandCost DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
 
{
 
	/* not a railroad crossing? */
 
	if (!IsLevelCrossing(tile)) return CMD_ERROR;
 
@@ -587,10 +587,10 @@ int32 DoConvertStreetRail(TileIndex tile
 
 * - p2 = (bit 3 + 4) - road type
 
 * - p2 = (bit 5) - set road direction
 
 */
 
int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex start_tile, tile;
 
	int32 cost, ret;
 
	CommandCost cost, ret;
 
	bool had_bridge = false;
 
	bool had_success = false;
 
	DisallowedRoadDirections drd = DRD_NORTHBOUND;
 
@@ -667,10 +667,10 @@ int32 CmdBuildLongRoad(TileIndex end_til
 
 * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
 
 * - p2 = (bit 3 + 4) - road type
 
 */
 
int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex start_tile, tile;
 
	int32 cost, ret;
 
	CommandCost cost, ret;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -725,9 +725,9 @@ int32 CmdRemoveLongRoad(TileIndex end_ti
 
 * @todo When checking for the tile slope,
 
 * distingush between "Flat land required" and "land sloped in wrong direction"
 
 */
 
int32 CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost;
 
	CommandCost cost;
 
	Depot *dep;
 
	Slope tileh;
 

	
 
@@ -765,7 +765,7 @@ int32 CmdBuildRoadDepot(TileIndex tile, 
 
	return cost + _price.build_road_depot;
 
}
 

	
 
static int32 RemoveRoadDepot(TileIndex tile, uint32 flags)
 
static CommandCost RemoveRoadDepot(TileIndex tile, uint32 flags)
 
{
 
	if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
 
		return CMD_ERROR;
 
@@ -777,7 +777,7 @@ static int32 RemoveRoadDepot(TileIndex t
 
	return _price.remove_road_depot;
 
}
 

	
 
static int32 ClearTile_Road(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Road(TileIndex tile, byte flags)
 
{
 
	switch (GetRoadTileType(tile)) {
 
		case ROAD_TILE_NORMAL: {
 
@@ -791,10 +791,10 @@ static int32 ClearTile_Road(TileIndex ti
 
			    !(flags & DC_AUTO)
 
				) {
 
				RoadTypes rts = GetRoadTypes(tile);
 
				int32 ret = 0;
 
				CommandCost ret = 0;
 
				for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
 
					if (HASBIT(rts, rt)) {
 
						int32 tmp_ret = DoCommand(tile, rt << 4 | GetRoadBits(tile, rt), 0, flags, CMD_REMOVE_ROAD);
 
						CommandCost tmp_ret = DoCommand(tile, rt << 4 | GetRoadBits(tile, rt), 0, flags, CMD_REMOVE_ROAD);
 
						if (CmdFailed(tmp_ret)) return tmp_ret;
 
						ret += tmp_ret;
 
					}
 
@@ -807,7 +807,7 @@ static int32 ClearTile_Road(TileIndex ti
 

	
 
		case ROAD_TILE_CROSSING: {
 
			RoadTypes rts = GetRoadTypes(tile);
 
			int32 ret = 0;
 
			CommandCost ret = 0;
 

	
 
			if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
 

	
 
@@ -815,7 +815,7 @@ static int32 ClearTile_Road(TileIndex ti
 
			 * tram tracks must be removed before the road bits. */
 
			for (RoadType rt = ROADTYPE_HWAY; rt >= ROADTYPE_ROAD; rt--) {
 
				if (HASBIT(rts, rt)) {
 
					int32 tmp_ret = DoCommand(tile, 1 << 6 | rt << 4 | GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD);
 
					CommandCost tmp_ret = DoCommand(tile, 1 << 6 | rt << 4 | GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD);
 
					if (CmdFailed(tmp_ret)) return tmp_ret;
 
					ret += tmp_ret;
 
				}
src/roadveh_cmd.cpp
Show inline comments
 
@@ -116,7 +116,7 @@ void DrawRoadVehEngine(int x, int y, Eng
 
	DrawSprite(6 + _roadveh_images[spritenum], pal, x, y);
 
}
 

	
 
static int32 EstimateRoadVehCost(EngineID engine_type)
 
static CommandCost EstimateRoadVehCost(EngineID engine_type)
 
{
 
	return ((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->base_cost)) >> 5;
 
}
 
@@ -156,9 +156,9 @@ void RoadVehUpdateCache(Vehicle *v)
 
 * @param p1 bus/truck type being built (engine)
 
 * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
 
 */
 
int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost;
 
	CommandCost cost;
 
	Vehicle *v;
 
	UnitID unit_num;
 
	Engine *e;
 
@@ -282,7 +282,7 @@ int32 CmdBuildRoadVeh(TileIndex tile, ui
 
 * @param p1 road vehicle ID to start/stop
 
 * @param p2 unused
 
 */
 
int32 CmdStartStopRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdStartStopRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	uint16 callback;
 
@@ -347,7 +347,7 @@ static bool CheckRoadVehInDepotStopped(c
 
 * @param p1 vehicle ID to be sold
 
 * @param p2 unused
 
 */
 
int32 CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
@@ -447,7 +447,7 @@ static const Depot* FindClosestRoadDepot
 
 * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
 
 * - p2 bit 8-10 - VLW flag (for mass goto depot)
 
 */
 
int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	const Depot *dep;
 
@@ -520,7 +520,7 @@ int32 CmdSendRoadVehToDepot(TileIndex ti
 
 * @param p1 vehicle ID to turn
 
 * @param p2 unused
 
 */
 
int32 CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
@@ -1886,7 +1886,7 @@ static void CheckIfRoadVehNeedsService(V
 

	
 
void OnNewDay_RoadVeh(Vehicle *v)
 
{
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	if (!IsRoadVehFront(v)) return;
 

	
 
@@ -2001,10 +2001,10 @@ void RoadVehiclesYearlyLoop()
 
 * - p2 = (bit 16) - refit only this vehicle (ignored)
 
 * @return cost of refit or error
 
 */
 
int32 CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	int32 cost;
 
	CommandCost cost;
 
	CargoID new_cid = GB(p2, 0, 8);
 
	byte new_subtype = GB(p2, 8, 8);
 
	uint16 capacity = CALLBACK_FAILED;
src/settings.cpp
Show inline comments
 
@@ -1766,7 +1766,7 @@ static const SettingDesc *GetSettingDesc
 
 * The new value is properly clamped to its minimum/maximum when setting
 
 * @see _patch_settings
 
 */
 
int32 CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	const SettingDesc *sd = GetSettingDescription(p1);
 

	
src/settings_gui.cpp
Show inline comments
 
@@ -251,7 +251,7 @@ static void GameOptionsWndProc(Window *w
 
 * @param p1 the side of the road; 0 = left side and 1 = right side
 
 * @param p2 unused
 
 */
 
int32 CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	/* Check boundaries and you can only change this if NO vehicles have been built yet,
 
	 * except in the intro-menu where of course it's always possible to do so. */
src/ship_cmd.cpp
Show inline comments
 
@@ -175,7 +175,7 @@ static void CheckIfShipNeedsService(Vehi
 

	
 
void OnNewDay_Ship(Vehicle *v)
 
{
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	if ((++v->day_counter & 7) == 0)
 
		DecreaseVehicleValue(v);
 
@@ -403,9 +403,9 @@ static bool ShipAccelerate(Vehicle *v)
 
	return (t < v->progress);
 
}
 

	
 
static int32 EstimateShipCost(EngineID engine_type)
 
static CommandCost EstimateShipCost(EngineID engine_type)
 
{
 
	return GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base>>3)>>5;
 
	return GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base >> 3) >> 5;
 
}
 

	
 
static void ShipArrivesAt(const Vehicle* v, Station* st)
 
@@ -809,9 +809,9 @@ void ShipsYearlyLoop()
 
 * @param p1 ship type being built (engine)
 
 * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
 
 */
 
int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 value;
 
	CommandCost value;
 
	Vehicle *v;
 
	UnitID unit_num;
 
	Engine *e;
 
@@ -904,7 +904,7 @@ int32 CmdBuildShip(TileIndex tile, uint3
 
 * @param p1 vehicle ID to be sold
 
 * @param p2 unused
 
 */
 
int32 CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 

	
 
@@ -938,7 +938,7 @@ int32 CmdSellShip(TileIndex tile, uint32
 
 * @param p1 ship ID to start/stop
 
 * @param p2 unused
 
 */
 
int32 CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	uint16 callback;
 
@@ -979,7 +979,7 @@ int32 CmdStartStopShip(TileIndex tile, u
 
 * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
 
 * - p2 bit 8-10 - VLW flag (for mass goto depot)
 
 */
 
int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	const Depot *dep;
 
@@ -1056,10 +1056,10 @@ int32 CmdSendShipToDepot(TileIndex tile,
 
 * - p2 = (bit 16) - refit only this vehicle (ignored)
 
 * @return cost of refit or error
 
 */
 
int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	int32 cost;
 
	CommandCost cost;
 
	CargoID new_cid = GB(p2, 0, 8); //gets the cargo number
 
	byte new_subtype = GB(p2, 8, 8);
 
	uint16 capacity = CALLBACK_FAILED;
src/signs.cpp
Show inline comments
 
@@ -122,7 +122,7 @@ void DestroySign(Sign *si)
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Sign *si;
 

	
 
@@ -159,7 +159,7 @@ int32 CmdPlaceSign(TileIndex tile, uint3
 
 * @param p2 unused
 
 * @return 0 if succesfull, otherwise CMD_ERROR
 
 */
 
int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidSignID(p1)) return CMD_ERROR;
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -612,13 +612,13 @@ static void DeleteStationIfEmpty(Station
 
	UpdateStationSignCoord(st);
 
}
 

	
 
static int32 ClearTile_Station(TileIndex tile, byte flags);
 
static CommandCost ClearTile_Station(TileIndex tile, byte flags);
 

	
 
// Tries to clear the given area. Returns the cost in case of success.
 
// Or an error code if it failed.
 
int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true)
 
CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true)
 
{
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	int allowed_z = -1;
 

	
 
	BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
 
@@ -680,7 +680,7 @@ int32 CheckFlatLandBelow(TileIndex tile,
 
				}
 
			}
 
		} else if (check_clear) {
 
			int32 ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
			CommandCost ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
			if (CmdFailed(ret)) return ret;
 
			cost += ret;
 
		}
 
@@ -801,10 +801,10 @@ static void GetStationLayout(byte *layou
 
 * - p2 = (bit  8-15) - custom station class
 
 * - p2 = (bit 16-23) - custom station id
 
 */
 
int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int w_org, h_org;
 
	int32 ret;
 
	CommandCost ret;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -838,7 +838,7 @@ int32 CmdBuildRailroadStation(TileIndex 
 
	//  for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365
 
	ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
 
	if (CmdFailed(ret)) return ret;
 
	int32 cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len;
 
	CommandCost cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len;
 

	
 
	Station *st = NULL;
 
	bool check_surrounding = true;
 
@@ -1054,7 +1054,7 @@ restart:
 
 * @param p1 start_tile
 
 * @param p2 unused
 
 */
 
int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex start = p1 == 0 ? tile : p1;
 

	
 
@@ -1125,7 +1125,7 @@ int32 CmdRemoveFromRailroadStation(TileI
 
}
 

	
 

	
 
static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
 
static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
 
{
 
	/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
 
	if (_current_player == OWNER_WATER && _patches.nonuniform_stations)
 
@@ -1142,7 +1142,7 @@ static int32 RemoveRailroadStation(Stati
 

	
 
	assert(w != 0 && h != 0);
 

	
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	/* clear all areas of the station */
 
	do {
 
		int w_bak = w;
 
@@ -1191,7 +1191,7 @@ static int32 RemoveRailroadStation(Stati
 
 * @return            The cost and state of the operation
 
 * @retval CMD_ERROR  An error occured during the operation.
 
 */
 
int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
 
CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
 
{
 
	const Station* st = GetStationByTile(tile);
 

	
 
@@ -1243,7 +1243,7 @@ static RoadStop **FindRoadStopSpot(bool 
 
 *           bit 2..4: the roadtypes
 
 *           bit 5: allow stations directly adjacent to other stations.
 
 */
 
int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	bool type = HASBIT(p2, 0);
 
	bool is_drive_through = HASBIT(p2, 1);
 
@@ -1267,7 +1267,7 @@ int32 CmdBuildRoadStop(TileIndex tile, u
 

	
 
	if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
 

	
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 

	
 
	/* Not allowed to build over this road */
 
	if (build_over_road) {
 
@@ -1371,7 +1371,7 @@ int32 CmdBuildRoadStop(TileIndex tile, u
 
}
 

	
 
// Remove a bus station
 
static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
 
static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
 
{
 
	if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
 
		return CMD_ERROR;
 
@@ -1425,7 +1425,7 @@ static int32 RemoveRoadStop(Station *st,
 
 * @param p1 not used
 
 * @param p2 bit 0: 0 for Bus stops, 1 for truck stops
 
 */
 
int32 CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	/* Make sure the specified tile is a road stop of the correct type */
 
	if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != p2) return CMD_ERROR;
 
@@ -1438,7 +1438,7 @@ int32 CmdRemoveRoadStop(TileIndex tile, 
 
			DiagDirToRoadBits(GetRoadStopDir(tile));
 
	bool is_towns_road = is_drive_through && GetStopBuiltOnTownRoad(tile);
 

	
 
	int32 ret = RemoveRoadStop(st, flags, tile);
 
	CommandCost ret = RemoveRoadStop(st, flags, tile);
 

	
 
	/* If the stop was a drive-through stop replace the road */
 
	if ((flags & DC_EXEC) && !CmdFailed(ret) && is_drive_through) {
 
@@ -1550,7 +1550,7 @@ static const byte * const _airport_secti
 
 * @param p1 airport type, @see airport.h
 
 * @param p2 (bit 0) - allow airports directly adjacent to other airports.
 
 */
 
int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	bool airport_upgrade = true;
 

	
 
@@ -1582,9 +1582,9 @@ int32 CmdBuildAirport(TileIndex tile, ui
 
	int w = afc->size_x;
 
	int h = afc->size_y;
 

	
 
	int32 ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
 
	CommandCost ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
 
	if (CmdFailed(ret)) return ret;
 
	int32 cost = ret;
 
	CommandCost cost = ret;
 

	
 
	Station *st = NULL;
 

	
 
@@ -1676,7 +1676,7 @@ int32 CmdBuildAirport(TileIndex tile, ui
 
	return cost;
 
}
 

	
 
static int32 RemoveAirport(Station *st, uint32 flags)
 
static CommandCost RemoveAirport(Station *st, uint32 flags)
 
{
 
	if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
 
		return CMD_ERROR;
 
@@ -1687,7 +1687,7 @@ static int32 RemoveAirport(Station *st, 
 
	int w = afc->size_x;
 
	int h = afc->size_y;
 

	
 
	int32 cost = w * h * _price.remove_airport;
 
	CommandCost cost = w * h * _price.remove_airport;
 

	
 
	Vehicle *v;
 
	FOR_ALL_VEHICLES(v) {
 
@@ -1730,7 +1730,7 @@ static int32 RemoveAirport(Station *st, 
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
int32 CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -1789,7 +1789,7 @@ static bool CheckShipsOnBuoy(Station *st
 
	return false;
 
}
 

	
 
static int32 RemoveBuoy(Station *st, uint32 flags)
 
static CommandCost RemoveBuoy(Station *st, uint32 flags)
 
{
 
	/* XXX: strange stuff */
 
	if (!IsValidPlayer(_current_player))  return_cmd_error(INVALID_STRING_ID);
 
@@ -1839,9 +1839,9 @@ static const byte _dock_h_chk[4] = { 1, 
 
 * @param p1 (bit 0) - allow docks directly adjacent to other docks.
 
 * @param p2 unused
 
 */
 
int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost;
 
	CommandCost cost;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
@@ -1938,7 +1938,7 @@ int32 CmdBuildDock(TileIndex tile, uint3
 
	return _price.build_dock;
 
}
 

	
 
static int32 RemoveDock(Station *st, uint32 flags)
 
static CommandCost RemoveDock(Station *st, uint32 flags)
 
{
 
	if (!CheckOwnership(st->owner)) return CMD_ERROR;
 

	
 
@@ -2494,7 +2494,7 @@ static void UpdateStationWaiting(Station
 
 * @param p1 station ID that is to be renamed
 
 * @param p2 unused
 
 */
 
int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidStationID(p1) || _cmd_text[0] == '\0') return CMD_ERROR;
 
	Station *st = GetStation(p1);
 
@@ -2748,7 +2748,7 @@ static bool CanRemoveRoadWithStop(TileIn
 
				CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_TRAM), OWNER_TOWN, &edge_road, ROADTYPE_TRAM);
 
}
 

	
 
static int32 ClearTile_Station(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Station(TileIndex tile, byte flags)
 
{
 
	if (flags & DC_AUTO) {
 
		switch (GetStationType(tile)) {
src/town_cmd.cpp
Show inline comments
 
@@ -478,10 +478,10 @@ static void ClickTile_Town(TileIndex til
 
	/* not used */
 
}
 

	
 
static int32 ClearTile_Town(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Town(TileIndex tile, byte flags)
 
{
 
	int rating;
 
	int32 cost;
 
	CommandCost cost;
 
	Town *t;
 
	HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
 

	
 
@@ -708,7 +708,7 @@ no_slope:
 
			uint32 r = Random();
 

	
 
			if (CHANCE16I(1, 8, r) && !_generating_world) {
 
				int32 res;
 
				CommandCost res;
 

	
 
				if (CHANCE16I(1, 16, r)) {
 
					res = DoCommand(tile, slope, 0, DC_EXEC | DC_AUTO | DC_NO_WATER,
 
@@ -730,7 +730,7 @@ no_slope:
 

	
 
static bool TerraformTownTile(TileIndex tile, int edges, int dir)
 
{
 
	int32 r;
 
	CommandCost r;
 

	
 
	TILE_ASSERT(tile);
 

	
 
@@ -1464,7 +1464,7 @@ static Town *AllocateTown()
 
 * @param p1 size of the town (0 = small, 1 = medium, 2 = large)
 
 * @param p2 size mode (@see TownSizeMode)
 
 */
 
int32 CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Town *t;
 
	uint32 townnameparts;
 
@@ -1770,7 +1770,7 @@ static void DoBuildTownHouse(Town *t, Ti
 

	
 
static bool BuildTownHouse(Town *t, TileIndex tile)
 
{
 
	int32 r;
 
	CommandCost r;
 

	
 
	if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
 
	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
 
@@ -1846,7 +1846,7 @@ void ClearTownHouse(Town *t, TileIndex t
 
 * @param p1 town ID to rename
 
 * @param p2 unused
 
 */
 
int32 CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID str;
 
	Town *t;
 
@@ -1932,7 +1932,7 @@ static void TownActionRoadRebuild(Town* 
 
static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
 
{
 
	PlayerID old;
 
	int32 r;
 
	CommandCost r;
 

	
 
	if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return false;
 

	
 
@@ -2050,9 +2050,9 @@ extern uint GetMaskOfTownActions(int *nu
 
 * @param p1 town to do the action at
 
 * @param p2 action to perform, @see _town_action_proc for the list of available actions
 
 */
 
int32 CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost;
 
	CommandCost cost;
 
	Town *t;
 

	
 
	if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR;
src/train_cmd.cpp
Show inline comments
 
@@ -502,12 +502,12 @@ void DrawTrainEngine(int x, int y, Engin
 
	DrawSprite(image, pal, x, y);
 
}
 

	
 
static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
 
static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
 
{
 
	SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
 

	
 
	const RailVehicleInfo *rvi = RailVehInfo(engine);
 
	int32 value = (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8;
 
	CommandCost value = (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8;
 

	
 
	uint num_vehicles = 1 + CountArticulatedParts(engine);
 

	
 
@@ -611,7 +611,7 @@ static void NormalizeTrainVehInDepot(con
 
	}
 
}
 

	
 
static int32 EstimateTrainCost(EngineID engine, const RailVehicleInfo* rvi)
 
static CommandCost EstimateTrainCost(EngineID engine, const RailVehicleInfo* rvi)
 
{
 
	return GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5;
 
}
 
@@ -651,7 +651,7 @@ static void AddRearEngineToMultiheadedTr
 
 * @param p2 bit 0 when set, the train will get number 0, otherwise it will get a free number
 
 *           bit 1 prevents any free cars from being added to the train
 
 */
 
int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	/* Check if the engine-type is valid (for the player) */
 
	if (!IsEngineBuildable(p1, VEH_TRAIN, _current_player)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
 
@@ -673,7 +673,7 @@ int32 CmdBuildRailVehicle(TileIndex tile
 

	
 
	if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
 

	
 
	int32 value = EstimateTrainCost(p1, rvi);
 
	CommandCost value = EstimateTrainCost(p1, rvi);
 

	
 
	uint num_vehicles =
 
		(rvi->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1) +
 
@@ -909,7 +909,7 @@ static void NormaliseTrainConsist(Vehicl
 
 * - p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
 
 * @param p2 (bit 0) move all vehicles following the source vehicle
 
 */
 
int32 CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	VehicleID s = GB(p1, 0, 16);
 
	VehicleID d = GB(p1, 16, 16);
 
@@ -1162,7 +1162,7 @@ int32 CmdMoveRailVehicle(TileIndex tile,
 
 * @param p1 train to start/stop
 
 * @param p2 unused
 
 */
 
int32 CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
@@ -1203,7 +1203,7 @@ int32 CmdStartStopTrain(TileIndex tile, 
 
 * - p2 = 2: when selling attached locos, rearrange all vehicles after it to separate lines;
 
 *           all wagons of the same type will go on the same line. Used by the AI currently
 
 */
 
int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	/* Check if we deleted a vehicle window */
 
	Window *w = NULL;
 
@@ -1235,7 +1235,7 @@ int32 CmdSellRailWagon(TileIndex tile, u
 
		RebuildVehicleLists();
 
	}
 

	
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	switch (p2) {
 
		case 0: case 2: { /* Delete given wagon */
 
			bool switch_engine = false;    // update second wagon to engine?
 
@@ -1616,7 +1616,7 @@ static void ReverseTrainDirection(Vehicl
 
 * @param p1 train to reverse
 
 * @param p2 if true, reverse a unit in a train (needs to be in a depot)
 
 */
 
int32 CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
@@ -1665,7 +1665,7 @@ int32 CmdReverseTrainDirection(TileIndex
 
 * @param p1 train to ignore the red signal
 
 * @param p2 unused
 
 */
 
int32 CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
@@ -1688,7 +1688,7 @@ int32 CmdForceTrainProceed(TileIndex til
 
 * - p2 = (bit 16) - refit only this vehicle
 
 * @return cost of refit or error
 
 */
 
int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	CargoID new_cid = GB(p2, 0, 8);
 
	byte new_subtype = GB(p2, 8, 8);
 
@@ -1706,7 +1706,7 @@ int32 CmdRefitRailVehicle(TileIndex tile
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN);
 

	
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	uint num = 0;
 

	
 
	do {
 
@@ -1872,7 +1872,7 @@ static TrainFindDepotData FindClosestTra
 
 * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
 
 * - p2 bit 8-10 - VLW flag (for mass goto depot)
 
 */
 
int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	if (p2 & DEPOT_MASS_SEND) {
 
		/* Mass goto depot requested */
 
@@ -3389,7 +3389,7 @@ void OnNewDay_Train(Vehicle *v)
 

	
 
		if ((v->vehstatus & VS_STOPPED) == 0) {
 
			/* running costs */
 
			int32 cost = GetTrainRunningCost(v) / 364;
 
			CommandCost cost = GetTrainRunningCost(v) / 364;
 

	
 
			v->profit_this_year -= cost >> 8;
 

	
src/tree_cmd.cpp
Show inline comments
 
@@ -213,10 +213,10 @@ void GenerateTrees()
 
 * @param p1 tree type, -1 means random.
 
 * @param p2 end tile of area-drag
 
 */
 
int32 CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	StringID msg = INVALID_STRING_ID;
 
	int32 cost;
 
	CommandCost cost;
 
	int ex;
 
	int ey;
 
	int sx, sy, x, y;
 
@@ -428,7 +428,7 @@ static Slope GetSlopeTileh_Trees(TileInd
 
	return tileh;
 
}
 

	
 
static int32 ClearTile_Trees(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Trees(TileIndex tile, byte flags)
 
{
 
	uint num;
 

	
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -110,7 +110,7 @@ static inline byte GetBridgeFlags(int in
 
 * - rest is invalid
 
 */
 
#define M(x) (1 << (x))
 
static int32 CheckBridgeSlopeNorth(Axis axis, Slope tileh)
 
static CommandCost CheckBridgeSlopeNorth(Axis axis, Slope tileh)
 
{
 
	uint32 valid;
 

	
 
@@ -125,7 +125,7 @@ static int32 CheckBridgeSlopeNorth(Axis 
 
	return CMD_ERROR;
 
}
 

	
 
static int32 CheckBridgeSlopeSouth(Axis axis, Slope tileh)
 
static CommandCost CheckBridgeSlopeSouth(Axis axis, Slope tileh)
 
{
 
	uint32 valid;
 

	
 
@@ -175,7 +175,7 @@ bool CheckBridge_Stuff(byte bridge_type,
 
 * - p2 = (bit 8-..) - rail type or road types.
 
 * - p2 = (bit 15  ) - set means road bridge.
 
 */
 
int32 CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	uint bridge_type;
 
	RailType railtype;
 
@@ -194,7 +194,7 @@ int32 CmdBuildBridge(TileIndex end_tile,
 
	TileIndexDiff delta;
 
	uint bridge_len;
 
	Axis direction;
 
	int32 cost, terraformcost, ret;
 
	CommandCost cost, terraformcost, ret;
 
	bool allow_on_slopes;
 
	bool replace_bridge = false;
 
	uint replaced_bridge_type;
 
@@ -453,7 +453,7 @@ not_valid_below:;
 
 * @param p1 railtype or roadtypes. bit 9 set means road tunnel
 
 * @param p2 unused
 
 */
 
int32 CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndexDiff delta;
 
	TileIndex end_tile;
 
@@ -462,8 +462,8 @@ int32 CmdBuildTunnel(TileIndex start_til
 
	Slope end_tileh;
 
	uint start_z;
 
	uint end_z;
 
	int32 cost;
 
	int32 ret;
 
	CommandCost cost;
 
	CommandCost ret;
 

	
 
	_build_tunnel_endtile = 0;
 
	if (!HASBIT(p1, 9)) {
 
@@ -578,7 +578,7 @@ static inline bool CheckAllowRemoveTunne
 
	return false;
 
}
 

	
 
static int32 DoClearTunnel(TileIndex tile, uint32 flags)
 
static CommandCost DoClearTunnel(TileIndex tile, uint32 flags)
 
{
 
	Town *t = NULL;
 
	TileIndex endtile;
 
@@ -638,7 +638,7 @@ static bool IsVehicleOnBridge(TileIndex 
 
	return false;
 
}
 

	
 
static int32 DoClearBridge(TileIndex tile, uint32 flags)
 
static CommandCost DoClearBridge(TileIndex tile, uint32 flags)
 
{
 
	DiagDirection direction;
 
	TileIndexDiff delta;
 
@@ -698,7 +698,7 @@ static int32 DoClearBridge(TileIndex til
 
	return (DistanceManhattan(tile, endtile) + 1) * _price.clear_bridge;
 
}
 

	
 
static int32 ClearTile_TunnelBridge(TileIndex tile, byte flags)
 
static CommandCost ClearTile_TunnelBridge(TileIndex tile, byte flags)
 
{
 
	if (IsTunnel(tile)) {
 
		if (flags & DC_AUTO) return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST);
 
@@ -721,7 +721,7 @@ static int32 ClearTile_TunnelBridge(Tile
 
 * @return            The cost and state of the operation
 
 * @retval CMD_ERROR  An error occured during the operation.
 
 */
 
int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
 
CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
 
{
 
	TileIndex endtile;
 

	
src/unmovable_cmd.cpp
Show inline comments
 
@@ -31,7 +31,7 @@
 
 * @param flags docommand flags of calling function
 
 * @return cost of the operation
 
 */
 
static int32 DestroyCompanyHQ(PlayerID pid, uint32 flags)
 
static CommandCost DestroyCompanyHQ(PlayerID pid, uint32 flags)
 
{
 
	Player* p = GetPlayer(pid);
 

	
 
@@ -73,7 +73,7 @@ void UpdateCompanyHQ(Player *p, uint sco
 
	MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
 
}
 

	
 
extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true);
 
extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true);
 

	
 
/** Build or relocate the HQ. This depends if the HQ is already built or not
 
 * @param tile tile where the HQ will be built or relocated to
 
@@ -81,11 +81,11 @@ extern int32 CheckFlatLandBelow(TileInde
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
int32 CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p = GetPlayer(_current_player);
 
	int cost;
 
	int32 ret;
 
	CommandCost cost;
 
	CommandCost ret;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
 

	
 
@@ -216,7 +216,7 @@ static Slope GetSlopeTileh_Unmovable(Til
 
	return IsOwnedLand(tile) ? tileh : SLOPE_FLAT;
 
}
 

	
 
static int32 ClearTile_Unmovable(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Unmovable(TileIndex tile, byte flags)
 
{
 
	if (IsCompanyHQ(tile)) {
 
		if (_current_player == OWNER_WATER) {
src/vehicle.cpp
Show inline comments
 
@@ -845,9 +845,9 @@ CargoID FindFirstRefittableCargo(EngineI
 
* @param engine_type Which engine to refit
 
* @return Price for refitting
 
*/
 
int32 GetRefitCost(EngineID engine_type)
 
CommandCost GetRefitCost(EngineID engine_type)
 
{
 
	int32 base_cost = 0;
 
	CommandCost base_cost = 0;
 

	
 
	switch (GetEngine(engine_type)->type) {
 
		case VEH_SHIP: base_cost = _price.ship_base; break;
 
@@ -1679,12 +1679,12 @@ void AgeVehicle(Vehicle *v)
 
 *   - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
 
 *   - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)
 
 */
 
int32 CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle **vl = NULL;
 
	uint16 engine_list_length = 0;
 
	uint16 engine_count = 0;
 
	int32 return_value = CMD_ERROR;
 
	CommandCost return_value = CMD_ERROR;
 
	uint i;
 
	uint stop_command;
 
	VehicleType vehicle_type = (VehicleType)GB(p2, 0, 5);
 
@@ -1711,7 +1711,7 @@ int32 CmdMassStartStopVehicle(TileIndex 
 

	
 
	for (i = 0; i < engine_count; i++) {
 
		const Vehicle *v = vl[i];
 
		int32 ret;
 
		CommandCost ret;
 

	
 
		if (!!(v->vehstatus & VS_STOPPED) != start_stop) continue;
 

	
 
@@ -1743,7 +1743,7 @@ int32 CmdMassStartStopVehicle(TileIndex 
 
 * @param p1 Vehicle type
 
 * @param p2 unused
 
 */
 
int32 CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle **engines = NULL;
 
	Vehicle **wagons = NULL;
 
@@ -1752,7 +1752,7 @@ int32 CmdDepotSellAllVehicles(TileIndex 
 
	uint16 wagon_list_length = 0;
 
	uint16 wagon_count = 0;
 

	
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	uint i, sell_command, total_number_vehicles;
 
	VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
 

	
 
@@ -1771,7 +1771,7 @@ int32 CmdDepotSellAllVehicles(TileIndex 
 
	total_number_vehicles = engine_count + wagon_count;
 
	for (i = 0; i < total_number_vehicles; i++) {
 
		const Vehicle *v;
 
		int32 ret;
 
		CommandCost ret;
 

	
 
		if (i < engine_count) {
 
			v = engines[i];
 
@@ -1796,13 +1796,13 @@ int32 CmdDepotSellAllVehicles(TileIndex 
 
 * @param p1 Type of vehicle
 
 * @param p2 Unused
 
 */
 
int32 CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle **vl = NULL;
 
	uint16 engine_list_length = 0;
 
	uint16 engine_count = 0;
 
	uint i, x = 0, y = 0, z = 0;
 
	int32 cost = 0;
 
	CommandCost cost = 0;
 
	VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
 

	
 
	if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
 
@@ -1814,7 +1814,7 @@ int32 CmdDepotMassAutoReplace(TileIndex 
 
	for (i = 0; i < engine_count; i++) {
 
		Vehicle *v = vl[i];
 
		bool stopped = !(v->vehstatus & VS_STOPPED);
 
		int32 ret;
 
		CommandCost ret;
 

	
 
		/* Ensure that the vehicle completely in the depot */
 
		if (!IsVehicleInDepot(v)) continue;
 
@@ -1862,11 +1862,11 @@ int32 CmdDepotMassAutoReplace(TileIndex 
 
 * @param p1 the original vehicle's index
 
 * @param p2 1 = shared orders, else copied orders
 
 */
 
int32 CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v_front, *v;
 
	Vehicle *w_front, *w, *w_rear;
 
	int32 cost, total_cost = 0;
 
	CommandCost cost, total_cost = 0;
 
	uint32 build_argument = 2;
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 
@@ -1926,7 +1926,7 @@ int32 CmdCloneVehicle(TileIndex tile, ui
 
			if (v->type == VEH_TRAIN && !IsFrontEngine(v)) {
 
				/* this s a train car
 
				 * add this unit to the end of the train */
 
				int32 result = DoCommand(0, (w_rear->index << 16) | w->index, 1, flags, CMD_MOVE_RAIL_VEHICLE);
 
				CommandCost result = DoCommand(0, (w_rear->index << 16) | w->index, 1, flags, CMD_MOVE_RAIL_VEHICLE);
 
				if (CmdFailed(result)) {
 
					/* The train can't be joined to make the same consist as the original.
 
					 * Sell what we already made (clean up) and return an error.           */
 
@@ -2223,7 +2223,7 @@ uint GenerateVehicleSortList(const Vehic
 
 * @param vlw_flag tells what kind of list requested the goto depot
 
 * @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
 
 */
 
int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
 
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
 
{
 
	const Vehicle **sort_list = NULL;
 
	uint n, i;
 
@@ -2234,7 +2234,7 @@ int32 SendAllVehiclesToDepot(VehicleType
 
	/* Send all the vehicles to a depot */
 
	for (i = 0; i < n; i++) {
 
		const Vehicle *v = sort_list[i];
 
		int32 ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type));
 
		CommandCost ret = DoCommand(v->tile, v->index, (service ? 1 : 0) | DEPOT_DONT_CANCEL, flags, GetCmdSendToDepot(type));
 

	
 
		/* Return 0 if DC_EXEC is not set this is a valid goto depot command)
 
			* In this case we know that at least one vehicle can be sent to a depot
 
@@ -2314,7 +2314,7 @@ void VehicleEnterDepot(Vehicle *v)
 
		v->current_order.flags = 0;
 

	
 
		if (t.refit_cargo < NUM_CARGO) {
 
			int32 cost;
 
			CommandCost cost;
 

	
 
			_current_player = v->owner;
 
			cost = DoCommand(v->tile, v->index, t.refit_cargo | t.refit_subtype << 8, DC_EXEC, GetCmdRefitVeh(v));
 
@@ -2362,7 +2362,7 @@ void VehicleEnterDepot(Vehicle *v)
 
 * @param p1 vehicle ID to name
 
 * @param p2 unused
 
 */
 
int32 CmdNameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdNameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	StringID str;
 
@@ -2396,7 +2396,7 @@ int32 CmdNameVehicle(TileIndex tile, uin
 
 * @param p1 vehicle ID that is being service-interval-changed
 
 * @param p2 new service interval
 
 */
 
int32 CmdChangeServiceInt(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdChangeServiceInt(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle* v;
 
	uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */
src/vehicle.h
Show inline comments
 
@@ -509,7 +509,7 @@ void ResetVehiclePosHash();
 

	
 
bool CanRefitTo(EngineID engine_type, CargoID cid_to);
 
CargoID FindFirstRefittableCargo(EngineID engine_type);
 
int32 GetRefitCost(EngineID engine_type);
 
CommandCost GetRefitCost(EngineID engine_type);
 

	
 
void ViewportAddVehicles(DrawPixelInfo *dpi);
 

	
 
@@ -556,13 +556,13 @@ bool VehicleNeedsService(const Vehicle *
 

	
 
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
 
void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
 
int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
 
CommandCost SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
 
bool IsVehicleInDepot(const Vehicle *v);
 
void VehicleEnterDepot(Vehicle *v);
 

	
 
void InvalidateAutoreplaceWindow(EngineID e);
 

	
 
int32 MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
 
CommandCost MaybeReplaceVehicle(Vehicle *v, bool check, bool display_costs);
 

	
 
/* Flags to add to p2 for goto depot commands */
 
/* Note: bits 8-10 are used for VLW flags */
src/vehicle_gui.cpp
Show inline comments
 
@@ -338,7 +338,7 @@ static void VehicleRefitWndProc(Window *
 
			WP(w, refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height);
 

	
 
			if (WP(w, refit_d).cargo != NULL) {
 
				int32 cost;
 
				CommandCost cost;
 

	
 
				cost = DoCommand(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8,
 
								 DC_QUERY_COST, GetCmdRefitVeh(GetVehicle(w->window_number)->type));
src/water_cmd.cpp
Show inline comments
 
@@ -56,11 +56,11 @@ static void FloodVehicle(Vehicle *v);
 
 * @param p1 bit 0 depot orientation (Axis)
 
 * @param p2 unused
 
 */
 
int32 CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	TileIndex tile2;
 

	
 
	int32 cost, ret;
 
	CommandCost cost, ret;
 
	Depot *depot;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
@@ -101,7 +101,7 @@ int32 CmdBuildShipDepot(TileIndex tile, 
 
	return cost + _price.build_ship_depot;
 
}
 

	
 
static int32 RemoveShipDepot(TileIndex tile, uint32 flags)
 
static CommandCost RemoveShipDepot(TileIndex tile, uint32 flags)
 
{
 
	TileIndex tile2;
 

	
 
@@ -127,9 +127,9 @@ static int32 RemoveShipDepot(TileIndex t
 
}
 

	
 
/** build a shiplift */
 
static int32 DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
 
static CommandCost DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
 
{
 
	int32 ret;
 
	CommandCost ret;
 
	int delta;
 

	
 
	/* middle tile */
 
@@ -167,7 +167,7 @@ static int32 DoBuildShiplift(TileIndex t
 
	return _price.clear_water * 22 >> 3;
 
}
 

	
 
static int32 RemoveShiplift(TileIndex tile, uint32 flags)
 
static CommandCost RemoveShiplift(TileIndex tile, uint32 flags)
 
{
 
	TileIndexDiff delta = TileOffsByDiagDir(GetLockDirection(tile));
 

	
 
@@ -200,7 +200,7 @@ static void MarkTilesAroundDirty(TileInd
 
 * @param p1 unused
 
 * @param p2 unused
 
 */
 
int32 CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	DiagDirection dir;
 

	
 
@@ -222,9 +222,9 @@ int32 CmdBuildLock(TileIndex tile, uint3
 
 * @param p1 start tile of stretch-dragging
 
 * @param p2 ctrl pressed - toggles ocean / canals at sealevel (ocean only allowed in the scenario editor)
 
 */
 
int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost;
 
	CommandCost cost;
 
	int size_x, size_y;
 
	int x;
 
	int y;
 
@@ -251,7 +251,7 @@ int32 CmdBuildCanal(TileIndex tile, uint
 

	
 
	cost = 0;
 
	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
 
		int32 ret;
 
		CommandCost ret;
 

	
 
		if (GetTileSlope(tile, NULL) != SLOPE_FLAT) {
 
			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
@@ -284,7 +284,7 @@ int32 CmdBuildCanal(TileIndex tile, uint
 
	}
 
}
 

	
 
static int32 ClearTile_Water(TileIndex tile, byte flags)
 
static CommandCost ClearTile_Water(TileIndex tile, byte flags)
 
{
 
	switch (GetWaterTileType(tile)) {
 
		case WATER_TILE_CLEAR:
src/waypoint.cpp
Show inline comments
 
@@ -201,7 +201,7 @@ void AfterLoadWaypoints()
 
 * @todo When checking for the tile slope,
 
 * distingush between "Flat land required" and "land sloped in wrong direction"
 
 */
 
int32 CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Waypoint *wp;
 
	Slope tileh;
 
@@ -295,7 +295,7 @@ void WaypointsDailyLoop()
 
 * @param justremove will indicate if it is removed from rail or if rails are removed too
 
 * @return cost of operation or error
 
 */
 
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
 
CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
 
{
 
	Waypoint *wp;
 

	
 
@@ -335,7 +335,7 @@ int32 RemoveTrainWaypoint(TileIndex tile
 
 * @param p2 unused
 
 * @return cost of operation or error
 
 */
 
int32 CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
	return RemoveTrainWaypoint(tile, flags, true);
 
@@ -349,7 +349,7 @@ int32 CmdRemoveTrainWaypoint(TileIndex t
 
 * @param p2 unused
 
 * @return cost of operation or error
 
 */
 
int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
CommandCost CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Waypoint *wp;
 

	
src/waypoint.h
Show inline comments
 
@@ -66,7 +66,7 @@ static inline Waypoint *GetWaypointByTil
 
	return GetWaypoint(GetWaypointIndex(tile));
 
}
 

	
 
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
 
CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
 
Station *ComposeWaypointStation(TileIndex tile);
 
void ShowRenameWaypointWindow(const Waypoint *cp);
 
void DrawWaypointSprite(int x, int y, int image, RailType railtype);
0 comments (0 inline, 0 general)