summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-04-10 07:15:58 +0000
committertron <tron@openttd.org>2006-04-10 07:15:58 +0000
commit81e6d68f95e7dea5c0d7dd105d67980d64af71e0 (patch)
treef8613338e934555520fd9b45b411e8a946c5be7a
parent6926bd55fd4f1d36745082b668b052c1b6691ad8 (diff)
downloadopenttd-81e6d68f95e7dea5c0d7dd105d67980d64af71e0.tar.xz
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
Remove DoCommandByTile(), because now it does the same as DoCommand()
-rw-r--r--ai/ai.c2
-rw-r--r--ai/default/default.c162
-rw-r--r--aircraft_cmd.c24
-rw-r--r--aircraft_gui.c2
-rw-r--r--bridge_gui.c2
-rw-r--r--clear_cmd.c43
-rw-r--r--command.c25
-rw-r--r--command.h5
-rw-r--r--disaster_cmd.c2
-rw-r--r--economy.c12
-rw-r--r--engine.c8
-rw-r--r--industry_cmd.c11
-rw-r--r--landscape.c18
-rw-r--r--misc_cmd.c42
-rw-r--r--misc_gui.c2
-rw-r--r--openttd.h1
-rw-r--r--order_cmd.c22
-rw-r--r--players.c8
-rw-r--r--rail_cmd.c93
-rw-r--r--rail_gui.c2
-rw-r--r--road_cmd.c50
-rw-r--r--road_gui.c2
-rw-r--r--roadveh_cmd.c24
-rw-r--r--settings.c2
-rw-r--r--settings_gui.c4
-rw-r--r--ship_cmd.c24
-rw-r--r--ship_gui.c2
-rw-r--r--signs.c11
-rw-r--r--station_cmd.c50
-rw-r--r--town_cmd.c45
-rw-r--r--train_cmd.c52
-rw-r--r--train_gui.c2
-rw-r--r--tree_cmd.c10
-rw-r--r--tunnelbridge_cmd.c28
-rw-r--r--unmovable_cmd.c7
-rw-r--r--vehicle.c40
-rw-r--r--water_cmd.c41
-rw-r--r--waypoint.c14
38 files changed, 434 insertions, 460 deletions
diff --git a/ai/ai.c b/ai/ai.c
index 7beb5b1d3..06c4c88ff 100644
--- a/ai/ai.c
+++ b/ai/ai.c
@@ -96,7 +96,7 @@ int32 AI_DoCommand(uint tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
tmp_cmdtext = strdup(_cmd_text);
/* First, do a test-run to see if we can do this */
- res = DoCommandByTile(tile, p1, p2, flags & ~DC_EXEC, procc);
+ res = DoCommand(tile, p1, p2, flags & ~DC_EXEC, procc);
/* The command failed, or you didn't want to execute, or you are quering, return */
if ((CmdFailed(res)) || !(flags & DC_EXEC) || (flags & DC_QUERY_COST)) {
if (tmp_cmdtext != NULL)
diff --git a/ai/default/default.c b/ai/default/default.c
index 4d12f6248..d286fbc31 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -146,7 +146,7 @@ static EngineID AiChooseTrainToBuild(RailType railtype, int32 money, byte flag,
continue;
}
- ret = DoCommandByTile(tile, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
+ ret = DoCommand(tile, i, 0, 0, CMD_BUILD_RAIL_VEHICLE);
if (!CmdFailed(ret) && ret <= money &&
rvi->ai_rank >= best_veh_score) {
best_veh_score = rvi->ai_rank;
@@ -172,7 +172,7 @@ static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex til
if (!HASBIT(e->player_avail, _current_player) || e->reliability < 0x8A3D)
continue;
- ret = DoCommandByTile(tile, i, 0, 0, CMD_BUILD_ROAD_VEH);
+ ret = DoCommand(tile, i, 0, 0, CMD_BUILD_ROAD_VEH);
if (!CmdFailed(ret) && ret <= money && ret >= best_veh_cost) {
best_veh_cost = ret;
best_veh_index = i;
@@ -203,7 +203,7 @@ static EngineID AiChooseAircraftToBuild(int32 money, byte flag)
if (i>=253) continue;
}
- ret = DoCommandByTile(0, i, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT);
+ ret = DoCommand(0, i, 0, DC_QUERY_COST, CMD_BUILD_AIRCRAFT);
if (!CmdFailed(ret) && ret <= money && ret >= best_veh_cost) {
best_veh_cost = ret;
best_veh_index = i;
@@ -271,7 +271,7 @@ static EngineID AiChooseShipToReplaceWith(Player* p, Vehicle* v)
static void AiHandleGotoDepot(Player *p, int cmd)
{
if (p->ai.cur_veh->current_order.type != OT_GOTO_DEPOT)
- DoCommandByTile(0, p->ai.cur_veh->index, 0, DC_EXEC, cmd);
+ DoCommand(0, p->ai.cur_veh->index, 0, DC_EXEC, cmd);
if (++p->ai.state_counter <= 1387) {
p->ai.state = AIS_VEH_DO_REPLACE_VEHICLE;
@@ -314,13 +314,13 @@ static void AiHandleReplaceTrain(Player *p)
BackupVehicleOrders(v, orderbak);
tile = v->tile;
- if (!CmdFailed(DoCommandByTile(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON)) &&
- !CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE)) ) {
+ if (!CmdFailed(DoCommand(0, v->index, 2, DC_EXEC, CMD_SELL_RAIL_WAGON)) &&
+ !CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE)) ) {
VehicleID veh = _new_train_id;
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
- DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN);
+ DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN);
- DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
+ DoCommand(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
}
}
}
@@ -343,13 +343,13 @@ static void AiHandleReplaceRoadVeh(Player *p)
BackupVehicleOrders(v, orderbak);
tile = v->tile;
- if (!CmdFailed(DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH)) &&
- !CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH)) ) {
+ if (!CmdFailed(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH)) &&
+ !CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH)) ) {
VehicleID veh = _new_roadveh_id;
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
- DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
+ DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
- DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
+ DoCommand(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
}
}
}
@@ -372,13 +372,13 @@ static void AiHandleReplaceAircraft(Player *p)
BackupVehicleOrders(v, orderbak);
tile = v->tile;
- if (!CmdFailed(DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT)) &&
- !CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT)) ) {
+ if (!CmdFailed(DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT)) &&
+ !CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT)) ) {
VehicleID veh = _new_aircraft_id;
AiRestoreVehicleOrders(GetVehicle(veh), orderbak);
- DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
+ DoCommand(0, veh, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
- DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
+ DoCommand(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
}
}
}
@@ -1552,10 +1552,10 @@ static int32 AiDoBuildDefaultRailTrack(TileIndex tile, const AiDefaultBlockData
if (p->mode < 2) {
if (p->mode == 0) {
// Depot
- ret = DoCommandByTile(c, _cur_ai_player->ai.railtype_to_use, p->attr, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_TRAIN_DEPOT);
+ ret = DoCommand(c, _cur_ai_player->ai.railtype_to_use, p->attr, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_TRAIN_DEPOT);
} else {
// Station
- ret = DoCommandByTile(c, (p->attr&1) | (p->attr>>4)<<8 | (p->attr>>1&7)<<16, _cur_ai_player->ai.railtype_to_use, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_RAILROAD_STATION);
+ ret = DoCommand(c, (p->attr&1) | (p->attr>>4)<<8 | (p->attr>>1&7)<<16, _cur_ai_player->ai.railtype_to_use, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_RAILROAD_STATION);
}
if (CmdFailed(ret)) return CMD_ERROR;
@@ -1579,7 +1579,7 @@ clear_town_stuff:;
for (i = 0; i != 6; i++, j >>= 1) {
if (j&1) {
k = i;
- ret = DoCommandByTile(c, _cur_ai_player->ai.railtype_to_use, i, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
+ ret = DoCommand(c, _cur_ai_player->ai.railtype_to_use, i, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_SINGLE_RAIL);
if (CmdFailed(ret)) return CMD_ERROR;
total_cost += ret;
}
@@ -1593,7 +1593,7 @@ clear_town_stuff:;
if (flag & DC_EXEC) {
j = 4 - j;
do {
- ret = DoCommandByTile(c, k, 0, flag, CMD_BUILD_SIGNALS);
+ ret = DoCommand(c, k, 0, flag, CMD_BUILD_SIGNALS);
} while (--j);
} else {
ret = _price.build_signals;
@@ -1605,12 +1605,12 @@ clear_town_stuff:;
//Clear stuff and then build single rail.
if (GetTileSlope(c,NULL) != 0)
return CMD_ERROR;
- ret = DoCommandByTile(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
total_cost += ret + _price.build_rail;
if (flag & DC_EXEC) {
- DoCommandByTile(c, _cur_ai_player->ai.railtype_to_use, p->attr&1, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_SINGLE_RAIL);
+ DoCommand(c, _cur_ai_player->ai.railtype_to_use, p->attr&1, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_SINGLE_RAIL);
}
goto clear_town_stuff;
@@ -1701,11 +1701,11 @@ static void AiDoTerraformLand(TileIndex tile, int dir, int unk, int mode)
if (slope != 0) {
if (mode > 0 || (mode == 0 && !(r & 0xC))) {
// Terraform up
- DoCommandByTile(tile, _terraform_up_flags[slope - 1], 1,
+ DoCommand(tile, _terraform_up_flags[slope - 1], 1,
DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
} else if (h != 0) {
// Terraform down
- DoCommandByTile(tile, _terraform_down_flags[slope - 1], 0,
+ DoCommand(tile, _terraform_down_flags[slope - 1], 0,
DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
}
}
@@ -1947,7 +1947,7 @@ static inline void AiCheckBuildRailBridgeHere(AiRailFinder *arf, TileIndex tile,
}
// Is building a (rail)bridge possible at this place (type doesn't matter)?
- if (CmdFailed(DoCommandByTile(tile_new, tile, 0 | arf->player->ai.railtype_to_use << 8,
+ if (CmdFailed(DoCommand(tile_new, tile, 0 | arf->player->ai.railtype_to_use << 8,
DC_AUTO, CMD_BUILD_BRIDGE)) )
return;
AiBuildRailRecursive(arf, tile_new, dir2);
@@ -1965,7 +1965,7 @@ static inline void AiCheckBuildRailTunnelHere(AiRailFinder *arf, TileIndex tile,
uint z;
if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
- int32 cost = DoCommandByTile(tile, arf->player->ai.railtype_to_use, 0, DC_AUTO, CMD_BUILD_TUNNEL);
+ int32 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);
@@ -2024,7 +2024,7 @@ static void AiBuildRailRecursive(AiRailFinder *arf, TileIndex tile, int dir)
do {
// Make sure the tile is not in the list of banned tiles and that a rail can be built here.
if (!AiIsTileBanned(arf->player, tile, p[0]) &&
- !CmdFailed(DoCommandByTile(tile, arf->player->ai.railtype_to_use, p[0], DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL))) {
+ !CmdFailed(DoCommand(tile, arf->player->ai.railtype_to_use, p[0], DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL))) {
AiBuildRailRecursive(arf, tile, p[1]);
}
@@ -2111,26 +2111,26 @@ static void AiBuildRailConstruct(Player *p)
*/
for (i = MAX_BRIDGES - 1; i != 0; i--) {
if (CheckBridge_Stuff(i, bridge_len)) {
- int32 cost = DoCommandByTile(arf.bridge_end_tile, p->ai.cur_tile_a, i | (p->ai.railtype_to_use << 8), DC_AUTO, CMD_BUILD_BRIDGE);
+ int32 cost = DoCommand(arf.bridge_end_tile, p->ai.cur_tile_a, i | (p->ai.railtype_to_use << 8), DC_AUTO, CMD_BUILD_BRIDGE);
if (!CmdFailed(cost) && cost < (p->player_money >> 5))
break;
}
}
// Build it
- DoCommandByTile(arf.bridge_end_tile, p->ai.cur_tile_a, i | (p->ai.railtype_to_use << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
+ DoCommand(arf.bridge_end_tile, p->ai.cur_tile_a, i | (p->ai.railtype_to_use << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
p->ai.cur_tile_a = arf.bridge_end_tile;
p->ai.state_counter = 0;
} else if (arf.best_ptr[0]&0x40) {
// tunnel
- DoCommandByTile(p->ai.cur_tile_a, p->ai.railtype_to_use, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
+ DoCommand(p->ai.cur_tile_a, p->ai.railtype_to_use, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
p->ai.cur_tile_a = _build_tunnel_endtile;
p->ai.state_counter = 0;
} else {
// rail
p->ai.cur_dir_a = arf.best_ptr[1];
- DoCommandByTile(p->ai.cur_tile_a, p->ai.railtype_to_use, arf.best_ptr[0],
+ DoCommand(p->ai.cur_tile_a, p->ai.railtype_to_use, arf.best_ptr[0],
DC_EXEC | DC_AUTO | DC_NO_WATER | DC_NO_RAIL_OVERLAP, CMD_BUILD_SINGLE_RAIL);
p->ai.state_counter = 0;
}
@@ -2153,7 +2153,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
if (IsTunnel(tile)) {
// Clear the tunnel and continue at the other side of it.
- if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR)))
+ if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR)))
return false;
p->ai.cur_tile_a = TILE_MASK(_build_tunnel_endtile - TileOffsByDir(p->ai.cur_dir_a));
return true;
@@ -2168,7 +2168,7 @@ static bool AiRemoveTileAndGoForward(Player *p)
tilenew = TILE_MASK(tile - TileOffsByDir(p->ai.cur_dir_a));
// And clear the bridge.
- if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR)))
+ if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR)))
return false;
p->ai.cur_tile_a = tilenew;
return true;
@@ -2185,11 +2185,11 @@ static bool AiRemoveTileAndGoForward(Player *p)
// Then remove and signals if there are any.
if (IsTileType(tile, MP_RAILWAY) &&
GetRailTileType(tile) == RAIL_TYPE_SIGNALS) {
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_REMOVE_SIGNALS);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_SIGNALS);
}
// And also remove the rail.
- if (CmdFailed(DoCommandByTile(tile, 0, bit, DC_EXEC, CMD_REMOVE_SINGLE_RAIL)))
+ if (CmdFailed(DoCommand(tile, 0, bit, DC_EXEC, CMD_REMOVE_SINGLE_RAIL)))
return false;
// Find the direction at the other edge of the rail.
@@ -2294,7 +2294,7 @@ static void AiStateBuildRail(Player *p)
p->ai.cur_tile_a = tile;
p->ai.start_dir_a = dir;
p->ai.cur_dir_a = dir;
- DoCommandByTile(TILE_MASK(tile + TileOffsByDir(dir)), 0, (dir&1)?1:0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
+ DoCommand(TILE_MASK(tile + TileOffsByDir(dir)), 0, (dir&1)?1:0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
assert(TILE_MASK(tile) != 0xFF00);
@@ -2305,7 +2305,7 @@ static void AiStateBuildRail(Player *p)
p->ai.cur_tile_b = tile;
p->ai.start_dir_b = dir;
p->ai.cur_dir_b = dir;
- DoCommandByTile(TILE_MASK(tile + TileOffsByDir(dir)), 0, (dir&1)?1:0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
+ DoCommand(TILE_MASK(tile + TileOffsByDir(dir)), 0, (dir&1)?1:0, DC_EXEC, CMD_REMOVE_SINGLE_RAIL);
assert(TILE_MASK(tile) != 0xFF00);
@@ -2381,7 +2381,7 @@ static void AiStateBuildRailVeh(Player *p)
/* veh will return INVALID_ENGINE if no suitable wagon is available.
* We shall treat this in the same way as having no money */
if (veh == INVALID_ENGINE) goto handle_nocash;
- cost = DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE);
+ cost = DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE);
if (CmdFailed(cost)) goto handle_nocash;
p->ai.wagon_list[i] = _new_wagon_id;
p->ai.wagon_list[i + 1] = INVALID_VEHICLE;
@@ -2400,7 +2400,7 @@ handle_nocash:
// after a while, if AI still doesn't have cash, get out of this block by selling the wagons.
if (++p->ai.state_counter == 1000) {
for (i = 0; p->ai.wagon_list[i] != INVALID_VEHICLE; i++) {
- cost = DoCommandByTile(tile, p->ai.wagon_list[i], 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
+ cost = DoCommand(tile, p->ai.wagon_list[i], 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
assert(!CmdFailed(cost));
}
p->ai.state = AIS_0;
@@ -2409,7 +2409,7 @@ handle_nocash:
}
// Try to build the locomotive
- cost = DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE);
+ cost = DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_RAIL_VEHICLE);
assert(!CmdFailed(cost));
loco_id = _new_train_id;
@@ -2418,12 +2418,12 @@ handle_nocash:
if (v->next != NULL) {
i = p->ai.wagon_list[p->ai.num_wagons * 2 - 2];
p->ai.wagon_list[p->ai.num_wagons * 2 - 2] = INVALID_VEHICLE;
- DoCommandByTile(tile, i, 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
+ DoCommand(tile, i, 0, DC_EXEC, CMD_SELL_RAIL_WAGON);
}
// Move the wagons onto the train
for (i = 0; p->ai.wagon_list[i] != INVALID_VEHICLE; i++) {
- DoCommandByTile(tile, p->ai.wagon_list[i] | (loco_id << 16), 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ DoCommand(tile, p->ai.wagon_list[i] | (loco_id << 16), 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
}
for (i = 0; p->ai.order_list_blocks[i] != 0xFF; i++) {
@@ -2443,12 +2443,12 @@ handle_nocash:
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
order.flags |= OF_FULL_LOAD;
- DoCommandByTile(0, loco_id + (i << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
+ DoCommand(0, loco_id + (i << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
}
- DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_TRAIN);
+ DoCommand(0, loco_id, 0, DC_EXEC, CMD_START_STOP_TRAIN);
- DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
+ DoCommand(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
if (p->ai.num_want_fullload != 0) p->ai.num_want_fullload--;
@@ -2472,7 +2472,7 @@ static void AiStateDeleteRailBlocks(Player *p)
if (aib->cur_building_rule != 255) {
b = _default_rail_track_data[aib->cur_building_rule]->data;
while (b->mode != 4) {
- DoCommandByTile(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
b++;
}
}
@@ -2554,7 +2554,7 @@ static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData
if ((GetRoadBits(c) & p->attr) == p->attr) continue;
}
- ret = DoCommandByTile(c, p->attr, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
+ ret = DoCommand(c, p->attr, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD);
if (CmdFailed(ret)) return CMD_ERROR;
total_cost += ret;
@@ -2563,15 +2563,15 @@ static int32 AiDoBuildDefaultRoadBlock(TileIndex tile, const AiDefaultBlockData
if (p->mode == 0) {
// Depot
- ret = DoCommandByTile(c, p->attr, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_DEPOT);
+ ret = DoCommand(c, p->attr, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_DEPOT);
goto clear_town_stuff;
} else if (p->mode == 1) {
if (_want_road_truck_station) {
// Truck station
- ret = DoCommandByTile(c, p->attr, RS_TRUCK, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
+ ret = DoCommand(c, p->attr, RS_TRUCK, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
} else {
// Bus station
- ret = DoCommandByTile(c, p->attr, RS_BUS, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
+ ret = DoCommand(c, p->attr, RS_BUS, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_BUILD_ROAD_STOP);
}
clear_town_stuff:;
@@ -2589,7 +2589,7 @@ clear_town_stuff:;
if (GetTileSlope(c, NULL) != 0) return CMD_ERROR;
if (!IsTileType(c, MP_STREET) || GetRoadType(c) != ROAD_NORMAL) {
- ret = DoCommandByTile(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(c, 0, 0, flag | DC_AUTO | DC_NO_WATER | DC_AI_BUILDING, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
}
@@ -2822,7 +2822,7 @@ static bool AiBuildRoadHelper(TileIndex tile, int flags, int type)
1+2,
8+4,
};
- return !CmdFailed(DoCommandByTile(tile, _road_bits[type], 0, flags, CMD_BUILD_ROAD));
+ return !CmdFailed(DoCommand(tile, _road_bits[type], 0, flags, CMD_BUILD_ROAD));
}
static inline void AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex tile, const byte *p)
@@ -2857,7 +2857,7 @@ static inline void AiCheckBuildRoadBridgeHere(AiRoadFinder *arf, TileIndex tile,
}
// Is building a (rail)bridge possible at this place (type doesn't matter)?
- if (CmdFailed(DoCommandByTile(tile_new, tile, 0x8000, DC_AUTO, CMD_BUILD_BRIDGE)))
+ if (CmdFailed(DoCommand(tile_new, tile, 0x8000, DC_AUTO, CMD_BUILD_BRIDGE)))
return;
AiBuildRoadRecursive(arf, tile_new, dir2);
@@ -2873,7 +2873,7 @@ static inline void AiCheckBuildRoadTunnelHere(AiRoadFinder *arf, TileIndex tile,
uint z;
if (GetTileSlope(tile, &z) == _dir_table_2[p[0] & 3] && z != 0) {
- int32 cost = DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
+ int32 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);
@@ -3009,18 +3009,18 @@ do_some_terraform:
*/
for (i = 10; i != 0; i--) {
if (CheckBridge_Stuff(i, bridge_len)) {
- int32 cost = DoCommandByTile(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO, CMD_BUILD_BRIDGE);
+ int32 cost = DoCommand(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO, CMD_BUILD_BRIDGE);
if (!CmdFailed(cost) && cost < (p->player_money >> 5)) break;
}
}
// Build it
- DoCommandByTile(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
+ DoCommand(tile, p->ai.cur_tile_a, i + (0x80 << 8), DC_AUTO | DC_EXEC, CMD_BUILD_BRIDGE);
p->ai.state_counter = 0;
} else if (arf.best_ptr[0]&0x40) {
// tunnel
- DoCommandByTile(tile, 0x200, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
+ DoCommand(tile, 0x200, 0, DC_AUTO | DC_EXEC, CMD_BUILD_TUNNEL);
p->ai.cur_tile_a = _build_tunnel_endtile;
p->ai.state_counter = 0;
} else {
@@ -3162,7 +3162,7 @@ static void AiStateBuildRoadVehicles(Player *p)
return;
}
- if (CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH))) return;
+ if (CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH))) return;
loco_id = _new_roadveh_id;
@@ -3183,11 +3183,11 @@ static void AiStateBuildRoadVehicles(Player *p)
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
order.flags |= OF_FULL_LOAD;
- DoCommandByTile(0, loco_id + (i << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
+ DoCommand(0, loco_id + (i << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
}
- DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
- DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
+ DoCommand(0, loco_id, 0, DC_EXEC, CMD_START_STOP_ROADVEH);
+ DoCommand(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
if (p->ai.num_want_fullload != 0) p->ai.num_want_fullload--;
if (--p->ai.num_loco_to_build == 0) p->ai.state = AIS_0;
@@ -3206,7 +3206,7 @@ static void AiStateDeleteRoadBlocks(Player *p)
b = _road_default_block_data[aib->cur_building_rule]->data;
while (b->mode != 4) {
if (b->mode <= 1) {
- DoCommandByTile(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(TILE_ADD(aib->use_tile, ToTileIndexDiff(b->tileoffs)), 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
b++;
}
@@ -3306,7 +3306,7 @@ static int32 AiDoBuildDefaultAirportBlock(TileIndex tile, const AiDefaultBlockDa
for (; p->mode == 0; p++) {
if (!HASBIT(_avail_aircraft, p->attr)) return CMD_ERROR;
- ret = DoCommandByTile(TILE_MASK(tile + ToTileIndexDiff(p->tileoffs)), p->attr,0,flag | DC_AUTO | DC_NO_WATER,CMD_BUILD_AIRPORT);
+ ret = DoCommand(TILE_MASK(tile + ToTileIndexDiff(p->tileoffs)), p->attr,0,flag | DC_AUTO | DC_NO_WATER,CMD_BUILD_AIRPORT);
if (CmdFailed(ret)) return CMD_ERROR;
total_cost += ret;
}
@@ -3464,7 +3464,7 @@ static void AiStateBuildAircraftVehicles(Player *p)
/* XXX - Have the AI pick the hangar terminal in an airport. Eg get airport-type
* and offset to the FIRST depot because the AI picks the st->xy tile */
tile += ToTileIndexDiff(GetAirport(GetStationByTile(tile)->airport_type)->airport_depots[0]);
- if (CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
+ if (CmdFailed(DoCommand(tile, veh, 0, DC_EXEC, CMD_BUILD_AIRCRAFT))) return;
loco_id = _new_aircraft_id;
for (i=0; p->ai.order_list_blocks[i] != 0xFF; i++) {
@@ -3480,12 +3480,12 @@ static void AiStateBuildAircraftVehicles(Player *p)
if (p->ai.num_want_fullload != 0 && (is_pass || i == 0))
order.flags |= OF_FULL_LOAD;
- DoCommandByTile(0, loco_id + (i << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
+ DoCommand(0, loco_id + (i << 16), PackOrder(&order), DC_EXEC, CMD_INSERT_ORDER);
}
- DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
+ DoCommand(0, loco_id, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT);
- DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
+ DoCommand(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT);
if (p->ai.num_want_fullload != 0) p->ai.num_want_fullload--;
@@ -3519,29 +3519,29 @@ static void AiStateSellVeh(Player *p)
if (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
if (v->current_order.type != OT_GOTO_DEPOT)
- DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_TRAIN_GOTO_DEPOT);
+ DoCommand(0, v->index, 0, DC_EXEC, CMD_TRAIN_GOTO_DEPOT);
goto going_to_depot;
}
// Sell whole train
- DoCommandByTile(v->tile, v->index, 1, DC_EXEC, CMD_SELL_RAIL_WAGON);
+ DoCommand(v->tile, v->index, 1, DC_EXEC, CMD_SELL_RAIL_WAGON);
} else if (v->type == VEH_Road) {
if (!IsTileDepotType(v->tile, TRANSPORT_ROAD) || v->u.road.state != 254 || !(v->vehstatus&VS_STOPPED)) {
if (v->current_order.type != OT_GOTO_DEPOT)
- DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SEND_ROADVEH_TO_DEPOT);
+ DoCommand(0, v->index, 0, DC_EXEC, CMD_SEND_ROADVEH_TO_DEPOT);
goto going_to_depot;
}
- DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
+ DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
} else if (v->type == VEH_Aircraft) {
if (!IsHangarTile(v->tile) || !(v->vehstatus & VS_STOPPED)) {
if (v->current_order.type != OT_GOTO_DEPOT)
- DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
+ DoCommand(0, v->index, 0, DC_EXEC, CMD_SEND_AIRCRAFT_TO_HANGAR);
goto going_to_depot;
}
- DoCommandByTile(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT);
+ DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_AIRCRAFT);
} else if (v->type == VEH_Ship) {
// XXX: not implemented
error("!v->type == VEH_Ship");
@@ -3589,7 +3589,7 @@ static void AiStateRemoveStation(Player *p)
(tile = st->train_tile) != 0 ||
(tile = st->dock_tile) != 0 ||
(tile = st->airport_tile) != 0)) {
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
used++;
}
@@ -3657,7 +3657,7 @@ pos_3:
if (GetRailTrackStatus(tile + TileOffsByDir(dir)) & _depot_bits[dir])
return;
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
} else if (IsTileType(tile, MP_STREET)) {
if (!IsTileOwner(tile, _current_player)) return;
@@ -3690,8 +3690,8 @@ pos_3:
dir = GetRoadDepotDirection(tile);
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
- DoCommandByTile(
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(
TILE_MASK(tile + TileOffsByDir(dir)),
DiagDirToRoadBits(ReverseDiagDir(dir)),
0,
@@ -3833,7 +3833,7 @@ static void AiHandleTakeover(Player *p)
// Computer wants to buy it.
old_p = _current_player;
_current_player = p->index;
- DoCommandByTile(0, old_p, 0, DC_EXEC, CMD_BUY_COMPANY);
+ DoCommand(0, old_p, 0, DC_EXEC, CMD_BUY_COMPANY);
_current_player = old_p;
}
}
@@ -3846,14 +3846,14 @@ static void AiAdjustLoan(Player *p)
if (p->player_money > base * 1400) {
// Decrease loan
if (p->current_loan != 0) {
- DoCommandByTile(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
+ DoCommand(0, 0, 0, DC_EXEC, CMD_DECREASE_LOAN);
}
} else if (p->player_money < base * 500) {
// Increase loan
if (p->current_loan < _economy.max_loan &&
p->num_valid_stat_ent >= 2 &&
-(p->old_economy[0].expenses+p->old_economy[1].expenses) < base * 60) {
- DoCommandByTile(0, 0, 0, DC_EXEC, CMD_INCREASE_LOAN);
+ DoCommand(0, 0, 0, DC_EXEC, CMD_INCREASE_LOAN);
}
}
}
@@ -3865,7 +3865,7 @@ static void AiBuildCompanyHQ(Player *p)
if (p->location_of_house == 0 &&
p->last_build_coordinate != 0) {
tile = AdjustTileCoordRandomly(p->last_build_coordinate, 8);
- DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
+ DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
}
}
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 86b62beaf..13c0bc4a0 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -130,16 +130,15 @@ static int32 EstimateAircraftCost(EngineID engine_type)
/** Build an aircraft.
- * @param x,y tile coordinates of depot where aircraft is built
+ * @param tile tile of depot where aircraft is built
* @param p1 aircraft type being built (engine)
* @param p2 unused
*/
-int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 value;
Vehicle *vl[3], *v, *u, *w;
UnitID unit_num;
- TileIndex tile = TileVirtXY(x, y);
const AircraftVehicleInfo *avi;
Engine *e;
@@ -166,6 +165,9 @@ int32 CmdBuildAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
+ uint x;
+ uint y;
+
v = vl[0];
u = vl[1];
@@ -322,11 +324,11 @@ static void DoDeleteAircraft(Vehicle *v)
}
/** Sell an aircraft.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to be sold
* @param p2 unused
*/
-int32 CmdSellAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -351,11 +353,11 @@ int32 CmdSellAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Start/Stop an aircraft.
- * @param x,y unused
+ * @param tile unused
* @param p1 aircraft ID to start/stop
* @param p2 unused
*/
-int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdStartStopAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -384,14 +386,14 @@ int32 CmdStartStopAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Send an aircraft to the hangar.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to send to the hangar
* @param p2 various bitmasked elements
* - p2 = 0 - aircraft goes to the depot and stays there (user command)
* - p2 non-zero - aircraft will try to goto a depot, but not stop there (eg forced servicing)
* - p2 (bit 17) - aircraft will try to goto a depot at the next airport
*/
-int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -447,12 +449,12 @@ int32 CmdSendAircraftToHangar(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Refits an aircraft to the specified cargo type.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID of the aircraft to refit
* @param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to
*/
-int32 CmdRefitAircraft(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
int pass, mail;
diff --git a/aircraft_gui.c b/aircraft_gui.c
index a2d11bdc3..cb3e9671c 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -244,7 +244,7 @@ static void AircraftRefitWndProc(Window *w, WindowEvent *e)
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel);
if (WP(w,refit_d).cargo != CT_INVALID) {
- int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT);
+ int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_AIRCRAFT);
if (!CmdFailed(cost)) {
SetDParam(2, cost);
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
diff --git a/bridge_gui.c b/bridge_gui.c
index 778c7b93a..fab13c39d 100644
--- a/bridge_gui.c
+++ b/bridge_gui.c
@@ -128,7 +128,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, byte bridge_type)
// only query bridge building possibility once, result is the same for all bridges!
// returns CMD_ERROR on failure, and price on success
- ret = DoCommandByTile(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
+ ret = DoCommand(end, start, (bridge_type << 8), DC_AUTO | DC_QUERY_COST, CMD_BUILD_BRIDGE);
if (CmdFailed(ret)) {
errmsg = _error_message;
diff --git a/clear_cmd.c b/clear_cmd.c
index 766182cba..074cb28c4 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -96,7 +96,7 @@ static int TerraformProc(TerraformerState *ts, TileIndex tile, int mode)
return r;
if (!IsTileType(tile, MP_RAILWAY)) {
- int32 ret = DoCommandByTile(tile, 0,0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ int32 ret = DoCommand(tile, 0,0, ts->flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) {
_terraform_err_tile = tile;
@@ -183,14 +183,13 @@ static bool TerraformTileHeight(TerraformerState *ts, TileIndex tile, int height
}
/** Terraform land
- * @param x,y coordinates to terraform
+ * @param tile tile to terraform
* @param p1 corners to terraform.
* @param p2 direction; eg up or down
*/
-int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
TerraformerState ts;
- TileIndex tile;
int direction;
TerraformerHeightMod modheight_data[576];
@@ -208,8 +207,6 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
ts.modheight = modheight_data;
ts.tile_table = tile_table_data;
- tile = TileVirtXY(x, y);
-
/* Make an extra check for map-bounds cause we add tiles to the originating tile */
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
@@ -275,7 +272,7 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int count;
TileIndex *ti = ts.tile_table;
for (count = ts.tile_table_count; count != 0; count--, ti++) {
- DoCommandByTile(*ti, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ DoCommand(*ti, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
}
@@ -307,16 +304,17 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Levels a selected (rectangle) area of land
- * @param x,y end tile of area-drag
+ * @param tile end tile of area-drag
* @param p1 start tile of area drag
* @param p2 unused
*/
-int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int size_x, size_y;
+ int ex;
+ int ey;
int sx, sy;
uint h, curh;
- TileIndex tile;
int32 ret, cost, money;
if (p1 >= MapSize()) return CMD_ERROR;
@@ -326,9 +324,9 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
// remember level height
h = TileHeight(p1);
- ex >>= 4; ey >>= 4;
-
// make sure sx,sy are smaller than ex,ey
+ ex = TileX(tile);
+ ey = TileY(tile);
sx = TileX(p1);
sy = TileY(p1);
if (ex < sx) intswap(ex, sx);
@@ -344,7 +342,7 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
curh = TileHeight(tile2);
while (curh != h) {
- ret = DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
+ ret = DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND);
if (CmdFailed(ret)) break;
cost += ret;
@@ -353,7 +351,7 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
_additional_cash_required = ret;
return cost - ret;
}
- DoCommandByTile(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
+ DoCommand(tile2, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND);
}
curh += (curh > h) ? -1 : 1;
@@ -365,26 +363,23 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
/** Purchase a land area. Actually you only purchase one tile, so
* the name is a bit confusing ;p
- * @param x,y the tile the player is purchasing
+ * @param tile the tile the player is purchasing
* @param p1 unused
* @param p2 unused
*/
-int32 CmdPurchaseLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile;
int32 cost;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- tile = TileVirtXY(x, y);
-
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
if (IsOwnedLandTile(tile) && IsTileOwner(tile, _current_player)) {
return_cmd_error(STR_5807_YOU_ALREADY_OWN_IT);
}
- cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
if (flags & DC_EXEC) {
@@ -422,18 +417,14 @@ static int32 ClearTile_Clear(TileIndex tile, byte flags)
/** Sell a land area. Actually you only sell one tile, so
* the name is a bit confusing ;p
- * @param x,y the tile the player is selling
+ * @param tile the tile the player is selling
* @param p1 unused
* @param p2 unused
*/
-int32 CmdSellLandArea(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile;
-
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- tile = TileVirtXY(x, y);
-
if (!IsOwnedLandTile(tile)) return CMD_ERROR;
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) return CMD_ERROR;
diff --git a/command.c b/command.c
index d7436be00..5ba07db29 100644
--- a/command.c
+++ b/command.c
@@ -13,7 +13,7 @@
const char* _cmd_text = NULL;
-#define DEF_COMMAND(yyyy) int32 yyyy(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+#define DEF_COMMAND(yyyy) int32 yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
DEF_COMMAND(CmdBuildRailroadTrack);
DEF_COMMAND(CmdRemoveRailroadTrack);
@@ -315,21 +315,16 @@ bool IsValidCommand(uint cmd)
byte GetCommandFlags(uint cmd) {return _command_proc_table[cmd & 0xFF].flags;}
-int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
-{
- return DoCommand(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, p1, p2, flags, procc);
-}
-
static int _docommand_recursive;
-int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
+int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
{
int32 res;
CommandProc *proc;
/* Do not even think about executing out-of-bounds tile-commands */
- if (TileVirtXY(x, y) >= MapSize()) {
+ if (tile >= MapSize()) {
_cmd_text = NULL;
return CMD_ERROR;
}
@@ -342,7 +337,7 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
// only execute the test call if it's toplevel, or we're not execing.
if (_docommand_recursive == 1 || !(flags & DC_EXEC) || (flags & DC_FORCETEST) ) {
- res = proc(x, y, flags&~DC_EXEC, p1, p2);
+ res = proc(tile, flags & ~DC_EXEC, p1, p2);
if (CmdFailed(res)) {
if (res & 0xFFFF) _error_message = res & 0xFFFF;
goto error;
@@ -362,7 +357,7 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
/* Execute the command here. All cost-relevant functions set the expenses type
* themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
- res = proc(x, y, flags, p1, p2);
+ res = proc(tile, flags, p1, p2);
if (CmdFailed(res)) {
if (res & 0xFFFF) _error_message = res & 0xFFFF;
error:
@@ -375,8 +370,8 @@ error:
if (--_docommand_recursive == 0) {
SubtractMoneyFromPlayer(res);
// XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of player
- if ( (x|y) != 0 && _current_player < MAX_PLAYERS) {
- GetPlayer(_current_player)->last_build_coordinate = TileVirtXY(x, y);
+ if (tile != 0 && _current_player < MAX_PLAYERS) {
+ GetPlayer(_current_player)->last_build_coordinate = tile;
}
}
@@ -457,7 +452,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
// cost estimation only?
if (_shift_pressed && IsLocalPlayer() && !(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR))) {
// estimate the cost.
- res = proc(x, y, flags, p1, p2);
+ res = proc(tile, flags, p1, p2);
if (CmdFailed(res)) {
if (res & 0xFFFF) _error_message = res & 0xFFFF;
ShowErrorMessage(_error_message, error_part1, x, y);
@@ -473,7 +468,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
// first test if the command can be executed.
- res = proc(x,y, flags, p1, p2);
+ res = proc(tile, flags, p1, p2);
if (CmdFailed(res)) {
if (res & 0xFFFF) _error_message = res & 0xFFFF;
goto show_error;
@@ -505,7 +500,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/* Actually try and execute the command. If no cost-type is given
* use the construction one */
_yearly_expenses_type = EXPENSES_CONSTRUCTION;
- res2 = proc(x,y, flags|DC_EXEC, p1, p2);
+ res2 = proc(tile, flags|DC_EXEC, p1, p2);
// If notest is on, it means the result of the test can be different than
// the real command.. so ignore the test
diff --git a/command.h b/command.h
index 249a6a072..db12972f5 100644
--- a/command.h
+++ b/command.h
@@ -169,6 +169,8 @@ 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 struct Command {
CommandProc *proc;
byte flags;
@@ -189,8 +191,7 @@ static inline bool CmdFailed(int32 res)
}
/* command.c */
-int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc);
-int32 DoCommandByTile(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
+int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
extern const char* _cmd_text; // Text, which gets sent with a command
diff --git a/disaster_cmd.c b/disaster_cmd.c
index 94a03810f..b11afbb63 100644
--- a/disaster_cmd.c
+++ b/disaster_cmd.c
@@ -33,7 +33,7 @@ static void DisasterClearSquare(TileIndex tile)
case MP_HOUSE: {
PlayerID p = _current_player;
_current_player = OWNER_NONE;
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
_current_player = p;
break;
}
diff --git a/economy.c b/economy.c
index 1bc1d3e93..2d4d30aad 100644
--- a/economy.c
+++ b/economy.c
@@ -1531,11 +1531,11 @@ static void DoAcquireCompany(Player *p)
extern int GetAmountOwnedBy(Player *p, byte owner);
/** Acquire shares in an opposing company.
- * @param x,y unused
+ * @param tile unused
* @param p1 player to buy the shares from
* @param p2 unused
*/
-int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
int64 cost;
@@ -1576,11 +1576,11 @@ int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Sell shares in an opposing company.
- * @param x,y unused
+ * @param tile unused
* @param p1 player to sell the shares from
* @param p2 unused
*/
-int32 CmdSellShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
int64 cost;
@@ -1611,11 +1611,11 @@ int32 CmdSellShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* When a competing company is gone bankrupt you get the chance to purchase
* that company.
* @todo currently this only works for AI players
- * @param x,y unused
+ * @param tile unused
* @param p1 player/company to buy up
* @param p2 unused
*/
-int32 CmdBuyCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
diff --git a/engine.c b/engine.c
index 17a7f1088..78f895bb1 100644
--- a/engine.c
+++ b/engine.c
@@ -334,11 +334,11 @@ void EnginesDailyLoop(void)
/** Accept an engine prototype. XXX - it is possible that the top-player
* changes while you are waiting to accept the offer? Then it becomes invalid
- * @param x,y unused
+ * @param tile unused
* @param p1 engine-prototype offered
* @param p2 unused
*/
-int32 CmdWantEnginePreview(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Engine *e;
@@ -445,11 +445,11 @@ void EnginesMonthlyLoop(void)
}
/** Rename an engine.
- * @param x,y unused
+ * @param tile unused
* @param p1 engine ID to rename
* @param p2 unused
*/
-int32 CmdRenameEngine(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
StringID str;
diff --git a/industry_cmd.c b/industry_cmd.c
index e7973df87..a52c5371e 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -1030,7 +1030,7 @@ static void ChopLumberMillTrees(Industry *i)
_industry_sound_tile = tile;
SndPlayTileFx(SND_38_CHAINSAW, tile);
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
SetTropicZone(tile, TROPICZONE_INVALID);
i->cargo_waiting[0] = min(0xffff, i->cargo_waiting[0] + 45);
@@ -1348,7 +1348,7 @@ static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable*
}
} else {
do_clear:
- if (CmdFailed(DoCommandByTile(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR)))
+ if (CmdFailed(DoCommand(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR)))
return false;
}
}
@@ -1474,7 +1474,7 @@ static void DoCreateNewIndustry(Industry* i, TileIndex tile, int type, const Ind
size = it->ti.y;
if (size > i->height)i->height = size;
- DoCommandByTile(cur_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(cur_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
MakeIndustry(cur_tile, i->index, it->gfx);
if (_generating_world) _m[cur_tile].m1 = 0x1E; /* maturity */
@@ -1499,15 +1499,14 @@ static void DoCreateNewIndustry(Industry* i, TileIndex tile, int type, const Ind
}
/** Build/Fund an industry
- * @param x,y coordinates where industry is built
+ * @param tile tile where industry is built
* @param p1 industry type @see build_industry.h and @see industry.h
* @param p2 unused
*/
-int32 CmdBuildIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
const Town* t;
Industry *i;
- TileIndex tile = TileVirtXY(x, y);
int num;
const IndustryTileTable * const *itt;
const IndustryTileTable *it;
diff --git a/landscape.c b/landscape.c
index b8853671a..e163a9abb 100644
--- a/landscape.c
+++ b/landscape.c
@@ -272,27 +272,27 @@ void GetTileDesc(TileIndex tile, TileDesc *td)
}
/** Clear a piece of landscape
- * @param x,y coordinates of clearance
+ * @param tile tile to clear
* @param p1 unused
* @param p2 unused
*/
-int32 CmdLandscapeClear(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
-
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
}
/** Clear a big piece of landscape
- * @param x,y end coordinates of area dragging
+ * @param tile end tile of area dragging
* @param p1 start tile of area dragging
* @param p2 unused
*/
-int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 cost, ret, money;
+ int ex;
+ int ey;
int sx,sy;
int x,y;
bool success = false;
@@ -302,6 +302,8 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
// make sure sx,sy are smaller than ex,ey
+ ex = TileX(tile) * TILE_SIZE;
+ ey = TileY(tile) * TILE_SIZE;
sx = TileX(p1) * TILE_SIZE;
sy = TileY(p1) * TILE_SIZE;
if (ex < sx) intswap(ex, sx);
@@ -312,7 +314,7 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
for (x = sx; x <= ex; x += TILE_SIZE) {
for (y = sy; y <= ey; y += TILE_SIZE) {
- ret = DoCommandByTile(TileVirtXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(TileVirtXY(x, y), 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) continue;
cost += ret;
success = true;
@@ -322,7 +324,7 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
_additional_cash_required = ret;
return cost - ret;
}
- DoCommandByTile(TileVirtXY(x, y), 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ DoCommand(TileVirtXY(x, y), 0, 0, flags, CMD_LANDSCAPE_CLEAR);
// draw explosion animation...
if ((x == sx || x == ex) && (y == sy || y == ey)) {
diff --git a/misc_cmd.c b/misc_cmd.c
index b8ab9b836..5df0e94fb 100644
--- a/misc_cmd.c
+++ b/misc_cmd.c
@@ -15,11 +15,11 @@
#include "variables.h"
/** Change the player's face.
- * @param x,y unused
+ * @param tile unused
* @param p1 unused
* @param p2 face bitmasked
*/
-int32 CmdSetPlayerFace(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSetPlayerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
GetPlayer(_current_player)->face = p2;
@@ -29,11 +29,11 @@ int32 CmdSetPlayerFace(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Change the player's company-colour
- * @param x,y unused
+ * @param tile unused
* @param p1 unused
* @param p2 new colour for vehicles, property, etc.
*/
-int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSetPlayerColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p, *pp;
byte colour;
@@ -58,11 +58,11 @@ int32 CmdSetPlayerColor(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Increase the loan of your company.
- * @param x,y unused
+ * @param tile unused
* @param p1 unused
* @param p2 when set, loans the maximum amount in one go (press CTRL)
*/
-int32 CmdIncreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
@@ -87,11 +87,11 @@ int32 CmdIncreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Decrease the loan of your company.
- * @param x,y unused
+ * @param tile unused
* @param p1 unused
* @param p2 when set, pays back the maximum loan permitting money (press CTRL)
*/
-int32 CmdDecreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
int32 loan;
@@ -127,11 +127,11 @@ int32 CmdDecreaseLoan(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Change the name of the company.
- * @param x,y unused
+ * @param tile unused
* @param p1 unused
* @param p2 unused
*/
-int32 CmdChangeCompanyName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdChangeCompanyName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
StringID str;
Player *p;
@@ -153,11 +153,11 @@ int32 CmdChangeCompanyName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Change the name of the president.
- * @param x,y unused
+ * @param tile unused
* @param p1 unused
* @param p2 unused
*/
-int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdChangePresidentName(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
StringID str;
Player *p;
@@ -177,7 +177,7 @@ int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
snprintf(buf, lengthof(buf), "%s Transport", _cmd_text);
_cmd_text = buf;
- DoCommandByTile(0, 0, 0, DC_EXEC, CMD_CHANGE_COMPANY_NAME);
+ DoCommand(0, 0, 0, DC_EXEC, CMD_CHANGE_COMPANY_NAME);
}
MarkWholeScreenDirty();
} else
@@ -190,11 +190,11 @@ int32 CmdChangePresidentName(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* Increase or decrease the pause counter. If the counter is zero,
* the game is unpaused. A counter is used instead of a boolean value
* to have more control over the game when saving/loading, etc.
- * @param x,y unused
+ * @param tile unused
* @param p1 0 = decrease pause counter; 1 = increase pause counter
* @param p2 unused
*/
-int32 CmdPause(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
_pause += (p1 == 1) ? 1 : -1;
@@ -208,11 +208,11 @@ int32 CmdPause(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Change the financial flow of your company.
* This is normally only enabled in offline mode, but if there is a debug
* build, you can cheat (to test).
- * @param x,y unused
+ * @param tile unused
* @param p1 the amount of money to receive (if negative), or spend (if positive)
* @param p2 unused
*/
-int32 CmdMoneyCheat(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
#ifndef _DEBUG
if (_networking) return CMD_ERROR;
@@ -225,11 +225,11 @@ int32 CmdMoneyCheat(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* To prevent abuse in multiplayer games you can only send money to other
* players if you have paid off your loan (either explicitely, or implicitely
* given the fact that you have more money than loan).
- * @param x,y unused
+ * @param tile unused
* @param p1 the amount of money to transfer; max 20.000.000
* @param p2 the player to transfer the money to
*/
-int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
const Player *p = GetPlayer(_current_player);
int32 amount = min((int32)p1, 20000000);
@@ -256,12 +256,12 @@ int32 CmdGiveMoney(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* We cannot really check for valid values of p2 (too much work mostly); stored
* in file 'settings_gui.c' _game_setting_info[]; we'll just trust the server it knows
* what to do and does this correctly
- * @param x,y unused
+ * @param tile unused
* @param p1 the difficulty setting being changed. If it is -1, the difficulty level
* itself is changed. The new value is inside p2
* @param p2 new value for a difficulty setting or difficulty level
*/
-int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdChangeDifficultyLevel(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (p1 != (uint32)-1L && ((int32)p1 >= GAME_DIFFICULTY_NUM || (int32)p1 < 0)) return CMD_ERROR;
diff --git a/misc_gui.c b/misc_gui.c
index 402940d2f..3f4e8161a 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -147,7 +147,7 @@ static void Place_LandInfo(TileIndex tile)
old_money = p->money64;
p->money64 = p->player_money = 0x7fffffff;
- lid.costclear = DoCommandByTile(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
+ lid.costclear = DoCommand(tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR);
p->money64 = old_money;
UpdatePlayerMoney32(p);
diff --git a/openttd.h b/openttd.h
index d0db98e81..1038d3bbf 100644
--- a/openttd.h
+++ b/openttd.h
@@ -295,7 +295,6 @@ typedef struct {
byte width_1, width_2;
} ViewportSign;
-typedef int32 CommandProc(int x, int y, uint32 flags, uint32 p1, uint32 p2);
typedef void DrawTileProc(TileInfo *ti);
typedef uint GetSlopeZProc(const TileInfo* ti);
diff --git a/order_cmd.c b/order_cmd.c
index 620639342..109eae836 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -160,7 +160,7 @@ static void DeleteOrderWarnings(const Vehicle* v)
/** Add an order to the orderlist of a vehicle.
- * @param x,y unused
+ * @param tile unused
* @param p1 various bitstuffed elements
* - p1 = (bit 0 - 15) - ID of the vehicle
* - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given,
@@ -168,7 +168,7 @@ static void DeleteOrderWarnings(const Vehicle* v)
* only the first 8 bits used currently (bit 16 - 23) (max 255)
* @param p2 packed order to insert
*/
-int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
VehicleID veh = GB(p1, 0, 16);
@@ -427,11 +427,11 @@ static int32 DecloneOrder(Vehicle *dst, uint32 flags)
}
/** Delete an order from the orderlist of a vehicle.
- * @param x,y unused
+ * @param tile unused
* @param p1 the ID of the vehicle
* @param p2 the order to delete (max 255)
*/
-int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v, *u;
VehicleID veh_id = p1;
@@ -501,11 +501,11 @@ int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Goto next order of order-list.
- * @param x,y unused
+ * @param tile unused
* @param p1 The ID of the vehicle which order is skipped
* @param p2 unused
*/
-int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSkipOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
VehicleID veh_id = p1;
@@ -542,7 +542,7 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Modify an order in the orderlist of a vehicle.
- * @param x,y unused
+ * @param tile unused
* @param p1 various bitstuffed elements
* - p1 = (bit 0 - 15) - ID of the vehicle
* - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given,
@@ -550,7 +550,7 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* only the first 8 bits used currently (bit 16 - 23) (max 255)
* @param p2 mode to change the order to (always set)
*/
-int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
Order *order;
@@ -617,7 +617,7 @@ int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* - 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(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *dst;
VehicleID veh_src = GB(p1, 16, 16);
@@ -821,7 +821,7 @@ void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* bak)
}
/** Restore the current order-index of a vehicle and sets service-interval.
- * @param x,y unused
+ * @param tile unused
* @param p1 the ID of the vehicle
* @param p2 various bistuffed elements
* - p2 = (bit 0-15) - current order-index (p2 & 0xFFFF)
@@ -833,7 +833,7 @@ void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* bak)
* 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(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRestoreOrderIndex(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
OrderID cur_ord = GB(p2, 0, 16);
diff --git a/players.c b/players.c
index bdf8df98a..4e92fda9b 100644
--- a/players.c
+++ b/players.c
@@ -651,7 +651,7 @@ static void DeletePlayerStuff(PlayerID pi)
}
/** Change engine renewal parameters
- * @param x,y unused
+ * @param tile unused
* @param p1 bits 0-3 command
* - p1 = 0 - change auto renew bool
* - p1 = 1 - change auto renew months
@@ -676,7 +676,7 @@ static void DeletePlayerStuff(PlayerID pi)
* if p1 = 5, then
* - p2 = enable renew_keep_length
*/
-int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdReplaceVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p;
if (!(_current_player < MAX_PLAYERS))
@@ -784,7 +784,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Control the players: add, delete, etc.
- * @param x,y unused
+ * @param tile unused
* @param p1 various functionality
* - p1 = 0 - create a new player, Which player (network) it will be is in p2
* - p1 = 1 - create a new AI player
@@ -802,7 +802,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* @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(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdPlayerCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) _current_player = OWNER_NONE;
diff --git a/rail_cmd.c b/rail_cmd.c
index 1012cca7a..f7ed7ea37 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -230,13 +230,12 @@ static uint32 CheckRailSlope(uint tileh, TrackBits rail_bits, TrackBits existing
static inline bool ValParamTrackOrientation(Track track) {return IsValidTrack(track);}
/** Build a single piece of rail
- * @param x,y coordinates on where to build
+ * @param tile tile to build on
* @param p1 railtype of being built piece (normal, mono, maglev)
* @param p2 rail track to build
*/
-int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile;
uint tileh;
Track track = (Track)p2;
TrackBits trackbit;
@@ -245,7 +244,6 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!ValParamRailtype(p1) || !ValParamTrackOrientation(track)) return CMD_ERROR;
- tile = TileVirtXY(x, y);
tileh = GetTileSlope(tile, NULL);
trackbit = TrackToTrackBits(track);
@@ -257,7 +255,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
!IsBridgeMiddle(tile) ||
(GetBridgeAxis(tile) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X) != trackbit) {
// Get detailed error message
- return DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
if (IsClearUnderBridge(tile)) {
@@ -271,7 +269,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_1007_ALREADY_BUILT);
} else {
// Get detailed error message
- return DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
break;
@@ -284,7 +282,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
!IsTileOwner(tile, _current_player) ||
GetRailType(tile) != p1) {
// Get detailed error message
- return DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile);
@@ -327,7 +325,7 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (CmdFailed(ret)) return ret;
cost += ret;
- ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost += ret;
@@ -344,15 +342,14 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Remove a single piece of track
- * @param x,y coordinates for removal of track
+ * @param tile tile to remove track from
* @param p1 unused
* @param p2 rail orientation
*/
-int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Track track = (Track)p2;
TrackBits trackbit;
- TileIndex tile;
int32 cost = _price.remove_rail;
bool crossing = false;
@@ -361,8 +358,6 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- tile = TileVirtXY(x, y);
-
switch (GetTileType(tile)) {
case MP_TUNNELBRIDGE:
if (!IsBridge(tile) ||
@@ -407,7 +402,7 @@ int32 CmdRemoveSingleRail(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* Charge extra to remove signals on the track, if they are there */
if (HasSignalOnTrack(tile, track))
- cost += DoCommand(x, y, track, 0, flags, CMD_REMOVE_SIGNALS);
+ cost += DoCommand(tile, track, 0, flags, CMD_REMOVE_SIGNALS);
if (flags & DC_EXEC) {
present ^= trackbit;
@@ -499,15 +494,17 @@ static int32 ValidateAutoDrag(Trackdir *trackdir, int x, int y, int ex, int ey)
}
/** Build a stretch of railroad tracks.
- * @param x,y start tile of drag
+ * @param tile start tile of drag
* @param p1 end tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
* - p2 = (bit 7) - 0 = build, 1 = remove tracks
*/
-static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+static int32 CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
+ int x;
+ int y;
int ex, ey;
int32 ret, total_cost = 0;
Track track = (Track)GB(p2, 4, 3);
@@ -520,6 +517,8 @@ static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2
trackdir = TrackToTrackdir(track);
/* unpack end point */
+ x = TileX(tile) * TILE_SIZE;
+ y = TileY(tile) * TILE_SIZE;
ex = TileX(p1) * TILE_SIZE;
ey = TileY(p1) * TILE_SIZE;
@@ -530,7 +529,7 @@ static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2
if (flags & DC_EXEC) SndPlayTileFx(SND_20_SPLAT_2, TileVirtXY(x, y));
for (;;) {
- ret = DoCommand(x, y, railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL);
+ ret = DoCommand(TileVirtXY(x, y), railtype, TrackdirToTrack(trackdir), flags, (mode == 0) ? CMD_BUILD_SINGLE_RAIL : CMD_REMOVE_SINGLE_RAIL);
if (CmdFailed(ret)) {
if ((_error_message != STR_1007_ALREADY_BUILT) && (mode == 0))
@@ -555,32 +554,31 @@ static int32 CmdRailTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2
* Stub for the unified rail builder/remover
* @see CmdRailTrackHelper
*/
-int32 CmdBuildRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- return CmdRailTrackHelper(x, y, flags, p1, CLRBIT(p2, 7));
+ return CmdRailTrackHelper(tile, flags, p1, CLRBIT(p2, 7));
}
/** Build rail on a stretch of track.
* Stub for the unified rail builder/remover
* @see CmdRailTrackHelper
*/
-int32 CmdRemoveRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- return CmdRailTrackHelper(x, y, flags, p1, SETBIT(p2, 7));
+ return CmdRailTrackHelper(tile, flags, p1, SETBIT(p2, 7));
}
/** Build a train depot
- * @param x,y position of the train depot
+ * @param tile position of the train depot
* @param p1 rail type
* @param p2 entrance direction (DiagDirection)
*
* @todo When checking for the tile slope,
* distingush between "Flat land required" and "land sloped in wrong direction"
*/
-int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Depot *d;
- TileIndex tile = TileVirtXY(x, y);
int32 cost, ret;
uint tileh;
@@ -610,7 +608,7 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
- ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
cost = ret;
@@ -634,16 +632,15 @@ int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Build signals, alternate between double/single, signal/semaphore,
* pre/exit/combo-signals, and what-else not
- * @param x,y coordinates where signals is being built
+ * @param tile tile where to build the signals
* @param p1 various bitstuffed elements
* - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
* - p1 = (bit 3) - choose semaphores/signals or cycle normal/pre/exit/combo depending on context
* @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(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
SignalVariant sigvar;
bool pre_signal;
Track track = (Track)(p1 & 0x7);
@@ -750,7 +747,7 @@ int32 CmdBuildSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Build many signals by dragging; AutoSignals
- * @param x,y start tile of drag
+ * @param tile start tile of drag
* @param p1 end tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0) - 0 = build, 1 = remove signals
@@ -758,12 +755,13 @@ int32 CmdBuildSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* - p2 = (bit 4- 6) - track-orientation, valid values: 0-5 (Track enum)
* - p2 = (bit 24-31) - user defined signals_density
*/
-static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
+ int x;
+ int y;
int ex, ey;
int32 ret, total_cost, signal_ctr;
byte signals;
- TileIndex tile = TileVirtXY(x, y);
bool error = true;
int mode = p2 & 0x1;
@@ -785,6 +783,8 @@ static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32
signal_density *= 2;
// unpack end tile
+ x = TileX(tile) * TILE_SIZE;
+ y = TileY(tile) * TILE_SIZE;
ex = TileX(p1) * TILE_SIZE;
ey = TileY(p1) * TILE_SIZE;
@@ -814,7 +814,7 @@ static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32
for (;;) {
// only build/remove signals with the specified density
if ((signal_ctr % signal_density) == 0 ) {
- ret = DoCommand(x, y, TrackdirToTrack(trackdir) | semaphores, signals, flags, (mode == 1) ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS);
+ ret = DoCommand(TileVirtXY(x, y), TrackdirToTrack(trackdir) | semaphores, signals, flags, (mode == 1) ? CMD_REMOVE_SIGNALS : CMD_BUILD_SIGNALS);
/* Abort placement for any other error than NOT_SUITABLE_TRACK
* This includes vehicles on track, competitor's tracks, etc. */
@@ -843,18 +843,17 @@ static int32 CmdSignalTrackHelper(int x, int y, uint32 flags, uint32 p1, uint32
* Stub for the unified signal builder/remover
* @see CmdSignalTrackHelper
*/
-int32 CmdBuildSignalTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- return CmdSignalTrackHelper(x, y, flags, p1, p2);
+ return CmdSignalTrackHelper(tile, flags, p1, p2);
}
/** Remove signals
- * @param x,y coordinates where signal is being deleted from
+ * @param tile coordinates where signal is being deleted from
* @param p1 track to remove signal from (Track enum)
*/
-int32 CmdRemoveSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
Track track = (Track)(p1 & 0x7);
if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile))
@@ -891,9 +890,9 @@ int32 CmdRemoveSingleSignal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* Stub for the unified signal builder/remover
* @see CmdSignalTrackHelper
*/
-int32 CmdRemoveSignalTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- return CmdSignalTrackHelper(x, y, flags, p1, SETBIT(p2, 0));
+ return CmdSignalTrackHelper(tile, flags, p1, SETBIT(p2, 0));
}
typedef int32 DoConvertRailProc(TileIndex tile, RailType totype, bool exec);
@@ -922,13 +921,15 @@ extern int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exe
/** Convert one rail type to the other. You can convert normal rail to
* monorail/maglev easily or vice-versa.
- * @param ex,ey end tile of rail conversion drag
+ * @param tile end tile of rail conversion drag
* @param p1 start tile of drag
* @param p2 new railtype to convert to
*/
-int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 ret, cost, money;
+ int ex;
+ int ey;
int sx, sy, x, y;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -937,6 +938,8 @@ int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
if (p1 >= MapSize()) return CMD_ERROR;
// make sure sx,sy are smaller than ex,ey
+ ex = TileX(tile) * TILE_SIZE;
+ ey = TileY(tile) * TILE_SIZE;
sx = TileX(p1) * TILE_SIZE;
sy = TileY(p1) * TILE_SIZE;
if (ex < sx) intswap(ex, sx);
@@ -1019,12 +1022,12 @@ static int32 ClearTile_Track(TileIndex tile, byte flags)
/* XXX: Why the fuck do we remove these thow signals first? */
case RAIL_TYPE_SIGNALS:
if (HasSignalOnTrack(tile, TRACK_X)) {
- ret = DoCommandByTile(tile, TRACK_X, 0, flags, CMD_REMOVE_SIGNALS);
+ ret = DoCommand(tile, TRACK_X, 0, flags, CMD_REMOVE_SIGNALS);
if (CmdFailed(ret)) return CMD_ERROR;
cost += ret;
}
if (HasSignalOnTrack(tile, TRACK_LOWER)) {
- ret = DoCommandByTile(tile, TRACK_LOWER, 0, flags, CMD_REMOVE_SIGNALS);
+ ret = DoCommand(tile, TRACK_LOWER, 0, flags, CMD_REMOVE_SIGNALS);
if (CmdFailed(ret)) return CMD_ERROR;
cost += ret;
}
@@ -1041,7 +1044,7 @@ static int32 ClearTile_Track(TileIndex tile, byte flags)
for (i = 0; m5 != 0; i++, m5 >>= 1) {
if (m5 & 1) {
- ret = DoCommandByTile(tile, 0, i, flags, CMD_REMOVE_SINGLE_RAIL);
+ ret = DoCommand(tile, 0, i, flags, CMD_REMOVE_SINGLE_RAIL);
if (CmdFailed(ret)) return CMD_ERROR;
cost += ret;
}
@@ -2001,7 +2004,7 @@ static void ChangeTileOwner_Track(TileIndex tile, PlayerID old_player, PlayerID
if (new_player != OWNER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
}
diff --git a/rail_gui.c b/rail_gui.c
index f641a551e..82182afb2 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -480,7 +480,7 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e)
case WE_PLACE_PRESIZE: {
TileIndex tile = e->place.tile;
- DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
+ DoCommand(tile, 0, 0, DC_AUTO, CMD_BUILD_TUNNEL);
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
} break;
diff --git a/road_cmd.c b/road_cmd.c
index 2614c842c..154968421 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -88,16 +88,15 @@ static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool* edge_roa
/** Delete a piece of road.
- * @param x,y tile coordinates for road construction
+ * @param tile tile where to remove road from
* @param p1 road piece flags
* @param p2 unused
*/
-int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
// cost for removing inner/edge -roads
static const uint16 road_remove_cost[2] = {50, 18};
- TileIndex tile;
PlayerID owner;
Town *t;
/* true if the roadpiece was always removeable,
@@ -111,8 +110,6 @@ int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p1 >> 4) return CMD_ERROR;
pieces = p1;
- tile = TileVirtXY(x, y);
-
if (!IsTileType(tile, MP_STREET) && !IsTileType(tile, MP_TUNNELBRIDGE)) return CMD_ERROR;
owner = IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
@@ -271,17 +268,16 @@ static uint32 CheckRoadSlope(int tileh, RoadBits* pieces, RoadBits existing)
}
/** Build a piece of road.
- * @param x,y tile coordinates for road construction
+ * @param tile tile where to build road
* @param p1 road piece flags
* @param p2 the town that is building the road (0 if not applicable)
*/
-int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 cost = 0;
int32 ret;
RoadBits existing = 0;
RoadBits pieces;
- TileIndex tile;
byte tileh;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -291,7 +287,6 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if ((p1 >> 4) || (_current_player < MAX_PLAYERS && p2 != 0) || !IsTownIndex(p2)) return CMD_ERROR;
pieces = p1;
- tile = TileVirtXY(x, y);
tileh = GetTileSlope(tile, NULL);
switch (GetTileType(tile)) {
@@ -388,7 +383,7 @@ int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
default:
do_clear:;
- ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost += ret;
}
@@ -439,16 +434,16 @@ int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
/** Build a long piece of road.
- * @param x,y end tile of drag
+ * @param end_tile end tile of drag
* @param p1 start tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
* - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
*/
-int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex start_tile, end_tile, tile;
+ TileIndex start_tile, tile;
int32 cost, ret;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -456,7 +451,6 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p1 >= MapSize()) return CMD_ERROR;
start_tile = p1;
- end_tile = TileVirtXY(x, y);
/* Only drag in X or Y direction dictated by the direction variable */
if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis
@@ -479,7 +473,7 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (tile == end_tile && !HASBIT(p2, 1)) bits &= ROAD_NW | ROAD_NE;
if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW;
- ret = DoCommandByTile(tile, bits, 0, flags, CMD_BUILD_ROAD);
+ ret = DoCommand(tile, bits, 0, flags, CMD_BUILD_ROAD);
if (CmdFailed(ret)) {
if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR;
} else {
@@ -495,16 +489,16 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Remove a long piece of road.
- * @param x,y end tile of drag
+ * @param end_tile end tile of drag
* @param p1 start tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
* - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
*/
-int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex start_tile, end_tile, tile;
+ TileIndex start_tile, tile;
int32 cost, ret;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -512,7 +506,6 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p1 >= MapSize()) return CMD_ERROR;
start_tile = p1;
- end_tile = TileVirtXY(x, y);
/* Only drag in X or Y direction dictated by the direction variable */
if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis
@@ -537,7 +530,7 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// try to remove the halves.
if (bits != 0) {
- ret = DoCommandByTile(tile, bits, 0, flags, CMD_REMOVE_ROAD);
+ ret = DoCommand(tile, bits, 0, flags, CMD_REMOVE_ROAD);
if (!CmdFailed(ret)) cost += ret;
}
@@ -550,26 +543,23 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Build a road depot.
- * @param x,y tile coordinates where the depot will be built
+ * @param tile tile where to build the depot
* @param p1 entrance direction (DiagDirection)
* @param p2 unused
*
* @todo When checking for the tile slope,
* distingush between "Flat land required" and "land sloped in wrong direction"
*/
-int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 cost;
Depot *dep;
- TileIndex tile;
uint tileh;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (p1 > 3) return CMD_ERROR; // check direction
- tile = TileVirtXY(x, y);
-
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
tileh = GetTileSlope(tile, NULL);
@@ -581,7 +571,7 @@ int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
- cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
dep = AllocateDepot();
@@ -624,7 +614,7 @@ static int32 ClearTile_Road(TileIndex tile, byte flags)
flags & DC_AUTO) {
return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
}
- return DoCommandByTile(tile, b, 0, flags, CMD_REMOVE_ROAD);
+ return DoCommand(tile, b, 0, flags, CMD_REMOVE_ROAD);
}
case ROAD_CROSSING: {
@@ -632,11 +622,11 @@ static int32 ClearTile_Road(TileIndex tile, byte flags)
if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
- ret = DoCommandByTile(tile, GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD);
+ ret = DoCommand(tile, GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD);
if (CmdFailed(ret)) return CMD_ERROR;
if (flags & DC_EXEC) {
- DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
return ret;
}
@@ -1092,7 +1082,7 @@ static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID n
default:
case ROAD_DEPOT:
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
break;
}
}
diff --git a/road_gui.c b/road_gui.c
index 73ce819cd..2f5d2514b 100644
--- a/road_gui.c
+++ b/road_gui.c
@@ -270,7 +270,7 @@ static void BuildRoadToolbWndProc(Window* w, WindowEvent* e)
case WE_PLACE_PRESIZE: {
TileIndex tile = e->place.tile;
- DoCommandByTile(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
+ DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
VpSetPresizeRange(tile, _build_tunnel_endtile==0?tile:_build_tunnel_endtile);
break;
}
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 96e3c8099..76fa480ca 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -101,16 +101,15 @@ static int32 EstimateRoadVehCost(EngineID engine_type)
}
/** Build a road vehicle.
- * @param x,y tile coordinates of depot where road vehicle is built
+ * @param tile tile of depot where road vehicle is built
* @param p1 bus/truck type being built (engine)
* @param p2 unused
*/
-int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 cost;
Vehicle *v;
UnitID unit_num;
- TileIndex tile = TileVirtXY(x, y);
Engine *e;
if (!IsEngineBuildable(p1, VEH_Road)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
@@ -135,6 +134,9 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
+ int x;
+ int y;
+
const RoadVehicleInfo *rvi = RoadVehInfo(p1);
v->unitnumber = unit_num;
@@ -200,11 +202,11 @@ int32 CmdBuildRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Start/Stop a road vehicle.
- * @param x,y unused
+ * @param tile unused
* @param p1 road vehicle ID to start/stop
* @param p2 unused
*/
-int32 CmdStartStopRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdStartStopRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -242,11 +244,11 @@ void ClearSlot(Vehicle *v)
}
/** Sell a road vehicle.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to be sold
* @param p2 unused
*/
-int32 CmdSellRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -342,11 +344,11 @@ static const Depot* FindClosestRoadDepot(const Vehicle* v)
}
/** Send a road vehicle to the depot.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to send to the depot
* @param p2 unused
*/
-int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
const Depot *dep;
@@ -390,11 +392,11 @@ int32 CmdSendRoadVehToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Turn a roadvehicle around.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to turn
* @param p2 unused
*/
-int32 CmdTurnRoadVeh(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
diff --git a/settings.c b/settings.c
index fa478b567..6672d5420 100644
--- a/settings.c
+++ b/settings.c
@@ -1403,7 +1403,7 @@ static const SettingDesc *GetSettingDescription(uint index)
* The new value is properly clamped to its minimum/maximum when setting
* @see _patch_settings
*/
-int32 CmdChangePatchSetting(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
const SettingDesc *sd = GetSettingDescription(p1);
diff --git a/settings_gui.c b/settings_gui.c
index d667a0e12..9c00b70e8 100644
--- a/settings_gui.c
+++ b/settings_gui.c
@@ -218,11 +218,11 @@ static void GameOptionsWndProc(Window *w, WindowEvent *e)
}
/** Change the side of the road vehicles drive on (server only).
- * @param x,y unused
+ * @param tile unused
* @param p1 the side of the road; 0 = left side and 1 = right side
* @param p2 unused
*/
-int32 CmdSetRoadDriveSide(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 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. */
diff --git a/ship_cmd.c b/ship_cmd.c
index 190c32b83..c76a39e4a 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -809,16 +809,15 @@ void ShipsYearlyLoop(void)
}
/** Build a ship.
- * @param x,y tile coordinates of depot where ship is built
+ * @param tile tile of depot where ship is built
* @param p1 ship type being built (engine)
* @param p2 unused
*/
-int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 value;
Vehicle *v;
UnitID unit_num;
- TileIndex tile = TileVirtXY(x, y);
Engine *e;
if (!IsEngineBuildable(p1, VEH_Ship)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
@@ -839,6 +838,9 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
+ int x;
+ int y;
+
const ShipVehicleInfo *svi = ShipVehInfo(p1);
v->unitnumber = unit_num;
@@ -897,11 +899,11 @@ int32 CmdBuildShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Sell a ship.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to be sold
* @param p2 unused
*/
-int32 CmdSellShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -930,11 +932,11 @@ int32 CmdSellShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Start/Stop a ship.
- * @param x,y unused
+ * @param tile unused
* @param p1 ship ID to start/stop
* @param p2 unused
*/
-int32 CmdStartStopShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdStartStopShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -959,11 +961,11 @@ int32 CmdStartStopShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Send a ship to the depot.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to send to the depot
* @param p2 unused
*/
-int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
const Depot *dep;
@@ -1008,12 +1010,12 @@ int32 CmdSendShipToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Refits a ship to the specified cargo type.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID of the ship to refit
* @param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
*/
-int32 CmdRefitShip(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
int32 cost;
diff --git a/ship_gui.c b/ship_gui.c
index c724493e2..e4eec8efc 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -88,7 +88,7 @@ static void ShipRefitWndProc(Window *w, WindowEvent *e)
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel);;
if (WP(w,refit_d).cargo != CT_INVALID) {
- int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_SHIP);
+ int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_SHIP);
if (!CmdFailed(cost)) {
SetDParam(2, cost);
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
diff --git a/signs.c b/signs.c
index a7a2016b8..eb108a596 100644
--- a/signs.c
+++ b/signs.c
@@ -104,11 +104,11 @@ static SignStruct *AllocateSign(void)
/** Place a sign at the given coordinates. Ownership of sign has
* no effect whatsoever except for the colour the sign gets for easy recognition,
* but everybody is able to rename/remove it.
- * @param x,y coordinates to place sign at
+ * @param tile tile to place sign at
* @param p1 unused
* @param p2 unused
*/
-int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
SignStruct *ss;
@@ -118,6 +118,9 @@ int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* When we execute, really make the sign */
if (flags & DC_EXEC) {
+ int x = TileX(tile) * TILE_SIZE;
+ int y = TileY(tile) * TILE_SIZE;
+
ss->str = STR_280A_SIGN;
ss->x = x;
ss->y = y;
@@ -136,11 +139,11 @@ int32 CmdPlaceSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Rename a sign. If the new name of the sign is empty, we assume
* the user wanted to delete it. So delete it. Ownership of signs
* has no meaning/effect whatsoever except for eyecandy
- * @param x,y unused
+ * @param tile unused
* @param p1 index of the sign to be renamed/removed
* @param p2 unused
*/
-int32 CmdRenameSign(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
if (!IsSignIndex(p1)) return CMD_ERROR;
diff --git a/station_cmd.c b/station_cmd.c
index c37829b3b..c9c2aefe8 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -804,7 +804,7 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
}
}
} else {
- ret = DoCommandByTile(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost += ret;
}
@@ -912,7 +912,7 @@ static void GetStationLayout(byte *layout, int numtracks, int plat_len, const St
}
/** Build railroad station
- * @param x,y starting position of station dragging/placement
+ * @param tile_org starting position of station dragging/placement
* @param p1 various bitstuffed elements
* - p1 = (bit 0) - orientation (p1 & 1)
* - p1 = (bit 8-15) - number of tracks
@@ -922,10 +922,9 @@ static void GetStationLayout(byte *layout, int numtracks, int plat_len, const St
* - p2 = (bit 4) - set for custom station (p2 & 0x10)
* - p2 = (bit 8-..) - custom station id (p2 >> 8)
*/
-int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
{
Station *st;
- TileIndex tile_org;
int w_org, h_org;
int32 cost, ret;
StationID est;
@@ -935,8 +934,6 @@ int32 CmdBuildRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- tile_org = TileVirtXY(x, y);
-
/* Does the authority allow this? */
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR;
if (!ValParamRailtype(p2 & 0xF)) return CMD_ERROR;
@@ -1124,13 +1121,12 @@ restart:
/** Remove a single tile from a railroad station.
* This allows for custom-built station with holes and weird layouts
- * @param x,y tile coordinates to remove
+ * @param tile tile of station piece to remove
* @param p1 unused
* @param p2 unused
*/
-int32 CmdRemoveFromRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
Station *st;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -1196,7 +1192,7 @@ static int32 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)
- return DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION);
+ return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION);
/* Current player owns the station? */
if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
@@ -1284,17 +1280,16 @@ static void FindRoadStationSpot(bool truck_station, Station* st, RoadStop*** cur
}
/** Build a bus station
- * @param x,y coordinates to build bus station at
+ * @param tile tile to build bus station at
* @param p1 entrance direction (DiagDirection)
* @param p2 0 for Bus stops, 1 for truck stops
*/
-int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Station *st;
RoadStop *road_stop;
RoadStop **currstop;
RoadStop *prev = NULL;
- TileIndex tile;
int32 cost;
int32 ret;
bool type = !!p2;
@@ -1304,8 +1299,6 @@ int32 CmdBuildRoadStop(int x, int y, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- tile = TileVirtXY(x, y);
-
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
return CMD_ERROR;
@@ -1500,13 +1493,12 @@ static const byte * const _airport_sections[] = {
};
/** Place an Airport.
- * @param x,y tile coordinates where airport will be built
+ * @param tile tile where airport will be built
* @param p1 airport type, @see airport.h
* @param p2 unused
*/
-int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile;
Town *t;
Station *st;
int32 cost;
@@ -1519,8 +1511,6 @@ int32 CmdBuildAirport(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* Check if a valid, buildable airport was chosen for construction */
if (p1 > lengthof(_airport_sections) || !HASBIT(GetValidAirports(), p1)) return CMD_ERROR;
- tile = TileVirtXY(x, y);
-
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
return CMD_ERROR;
@@ -1673,13 +1663,12 @@ static int32 RemoveAirport(Station *st, uint32 flags)
}
/** Build a buoy.
- * @param x,y tile coordinates of bouy construction
+ * @param tile tile where to place the bouy
* @param p1 unused
* @param p2 unused
*/
-int32 CmdBuildBuoy(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
Station *st;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -1774,13 +1763,12 @@ static const byte _dock_w_chk[4] = { 2,1,2,1 };
static const byte _dock_h_chk[4] = { 1,2,1,2 };
/** Build a dock/haven.
- * @param x,y tile coordinates where dock will be built
+ * @param tile tile where dock will be built
* @param p1 unused
* @param p2 unused
*/
-int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
TileIndex tile_cur;
DiagDirection direction;
int32 cost;
@@ -1798,7 +1786,7 @@ int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
- cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
tile_cur = tile + TileOffsByDir(direction);
@@ -1809,7 +1797,7 @@ int32 CmdBuildDock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_304B_SITE_UNSUITABLE);
}
- cost = DoCommandByTile(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ cost = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(cost)) return CMD_ERROR;
tile_cur = tile_cur + TileOffsByDir(direction);
@@ -2427,11 +2415,11 @@ static void UpdateStationWaiting(Station *st, int type, uint amount)
}
/** Rename a station
- * @param x,y unused
+ * @param tile unused
* @param p1 station ID that is to be renamed
* @param p2 unused
*/
-int32 CmdRenameStation(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
StringID str;
Station *st;
@@ -2672,7 +2660,7 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI
_global_station_sort_dirty = true; // transfer ownership of station to another player
InvalidateWindowClasses(WC_STATION_LIST);
} else {
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
}
diff --git a/town_cmd.c b/town_cmd.c
index 76a326ecf..b78096253 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -471,8 +471,8 @@ static bool IsRoadAllowedHere(TileIndex tile, int dir)
// No, try to build one in the direction.
// if that fails clear the land, and if that fails exit.
// This is to make sure that we can build a road here later.
- if (CmdFailed(DoCommandByTile(tile, (dir & 1 ? ROAD_X : ROAD_Y), 0, DC_AUTO, CMD_BUILD_ROAD)) &&
- CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR)))
+ if (CmdFailed(DoCommand(tile, (dir & 1 ? ROAD_X : ROAD_Y), 0, DC_AUTO, CMD_BUILD_ROAD)) &&
+ CmdFailed(DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR)))
return false;
}
@@ -500,10 +500,10 @@ no_slope:
int32 res;
if (CHANCE16I(1, 16, r)) {
- res = DoCommandByTile(tile, slope, 0, DC_EXEC | DC_AUTO | DC_NO_WATER,
+ res = DoCommand(tile, slope, 0, DC_EXEC | DC_AUTO | DC_NO_WATER,
CMD_TERRAFORM_LAND);
} else {
- res = DoCommandByTile(tile, slope^0xF, 1, DC_EXEC | DC_AUTO | DC_NO_WATER,
+ res = DoCommand(tile, slope ^ 0xF, 1, DC_EXEC | DC_AUTO | DC_NO_WATER,
CMD_TERRAFORM_LAND);
}
if (CmdFailed(res) && CHANCE16I(1, 3, r)) {
@@ -523,9 +523,9 @@ static bool TerraformTownTile(TileIndex tile, int edges, int dir)
TILE_ASSERT(tile);
- r = DoCommandByTile(tile, edges, dir, DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
+ r = DoCommand(tile, edges, dir, DC_AUTO | DC_NO_WATER, CMD_TERRAFORM_LAND);
if (CmdFailed(r) || r >= 126 * 16) return false;
- DoCommandByTile(tile, edges, dir, DC_AUTO | DC_NO_WATER | DC_EXEC, CMD_TERRAFORM_LAND);
+ DoCommand(tile, edges, dir, DC_AUTO | DC_NO_WATER | DC_EXEC, CMD_TERRAFORM_LAND);
return true;
}
@@ -654,7 +654,7 @@ static void GrowTownInTile(TileIndex* tile_ptr, RoadBits mask, int block, Town*
default:
build_road_and_exit:
- if (!CmdFailed(DoCommandByTile(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) {
+ if (!CmdFailed(DoCommand(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) {
_grow_town_result = -1;
}
return;
@@ -681,7 +681,7 @@ build_road_and_exit:
do {
byte bridge_type = RandomRange(MAX_BRIDGES - 1);
if (CheckBridge_Stuff(bridge_type, bridge_len)) {
- if (!CmdFailed(DoCommandByTile(tile, tmptile, 0x8000 + bridge_type, DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
+ if (!CmdFailed(DoCommand(tile, tmptile, 0x8000 + bridge_type, DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
_grow_town_result = -1;
// obviously, if building any bridge would fail, there is no need to try other bridge-types
@@ -795,8 +795,8 @@ static bool GrowTown(Town *t)
// Only work with plain land that not already has a house with GetHouseConstructionTick=0
if ((!IsTileType(tile, MP_HOUSE) || GetHouseConstructionTick(tile) != 0) &&
GetTileSlope(tile, NULL) == 0) {
- if (!CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) {
- DoCommandByTile(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
+ if (!CmdFailed(DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) {
+ DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
_current_player = old_player;
return true;
}
@@ -994,13 +994,12 @@ static Town *AllocateTown(void)
/** Create a new town.
* This obviously only works in the scenario editor. Function not removed
* as it might be possible in the future to fund your own town :)
- * @param x,y coordinates where town is built
+ * @param tile coordinates where town is built
* @param p1 unused
* @param p2 unused
*/
-int32 CmdBuildTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
Town *t;
uint32 townnameparts;
@@ -1114,7 +1113,7 @@ static bool CheckBuildHouseMode(TileIndex tile, uint tileh, int mode)
if (b)
return false;
- return !CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
+ return !CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
}
int GetTownRadiusGroup(const Town *t, TileIndex tile)
@@ -1151,7 +1150,7 @@ static bool CheckFree2x2Area(TileIndex tile)
if (GetTileSlope(tile, NULL)) return false;
- if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR)))
+ if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR)))
return false;
}
@@ -1286,7 +1285,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile)
if (!EnsureNoVehicle(tile)) return false;
if (GetTileSlope(tile, NULL) & 0x10) return false;
- r = DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR);
+ r = DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(r)) return false;
DoBuildTownHouse(t, tile);
@@ -1358,11 +1357,11 @@ static void ClearTownHouse(Town *t, TileIndex tile)
}
/** Rename a town (server-only).
- * @param x,y unused
+ * @param tile unused
* @param p1 town ID to rename
* @param p2 unused
*/
-int32 CmdRenameTown(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
StringID str;
Town *t;
@@ -1410,14 +1409,14 @@ void DeleteTown(Town *t)
switch (GetTileType(tile)) {
case MP_HOUSE:
if (GetTownByTile(tile) == t)
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
break;
case MP_STREET:
case MP_TUNNELBRIDGE:
if (IsTileOwner(tile, OWNER_TOWN) &&
ClosestTownFromTile(tile, (uint)-1) == t)
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
break;
default:
@@ -1499,7 +1498,7 @@ static bool DoBuildStatueOfCompany(TileIndex tile)
old = _current_player;
_current_player = OWNER_NONE;
- r = DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ r = DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
_current_player = old;
if (CmdFailed(r)) return false;
@@ -1611,11 +1610,11 @@ extern uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t);
/** Do a town action.
* This performs an action such as advertising, building a statue, funding buildings,
* but also bribing the town-council
- * @param x,y unused
+ * @param tile unused
* @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(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 cost;
Town *t;
diff --git a/train_cmd.c b/train_cmd.c
index b8523272b..633167415 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -655,7 +655,7 @@ static void NormalizeTrainVehInDepot(const Vehicle* u)
if (v->type == VEH_Train && IsFreeWagon(v) &&
v->tile == u->tile &&
v->u.rail.track == 0x80) {
- if (CmdFailed(DoCommandByTile(0, v->index | (u->index << 16), 1, DC_EXEC,
+ if (CmdFailed(DoCommand(0, v->index | (u->index << 16), 1, DC_EXEC,
CMD_MOVE_RAIL_VEHICLE)))
break;
}
@@ -696,18 +696,17 @@ static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool buildin
}
/** Build a railroad vehicle.
- * @param x,y tile coordinates (depot) where rail-vehicle is built
+ * @param tile tile of the depot where rail-vehicle is built
* @param p1 engine type id
* @param p2 bit 0 prevents any free cars from being added to the train
*/
-int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
const RailVehicleInfo *rvi;
int value;
Vehicle *v;
UnitID unit_num;
Engine *e;
- TileIndex tile = TileVirtXY(x, y);
uint num_vehicles;
/* Check if the engine-type is valid (for the player) */
@@ -748,17 +747,16 @@ int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
if (flags & DC_EXEC) {
- DiagDirection dir;
+ DiagDirection dir = GetRailDepotDirection(tile);
+ int x = TileX(tile) * TILE_SIZE + _vehicle_initial_x_fract[dir];
+ int y = TileY(tile) * TILE_SIZE + _vehicle_initial_y_fract[dir];
v->unitnumber = unit_num;
-
- dir = GetRailDepotDirection(tile);
-
v->direction = DiagDirToDir(dir);
v->tile = tile;
v->owner = _current_player;
- v->x_pos = (x |= _vehicle_initial_x_fract[dir]);
- v->y_pos = (y |= _vehicle_initial_y_fract[dir]);
+ v->x_pos = x;
+ v->y_pos = y;
v->z_pos = GetSlopeZ(x,y);
v->z_height = 6;
v->u.rail.track = 0x80;
@@ -938,13 +936,13 @@ static void NormaliseTrainConsist(Vehicle *v)
}
/** Move a rail vehicle around inside the depot.
- * @param x,y unused
+ * @param tile unused
* @param p1 various bitstuffed elements
* - p1 (bit 0 - 15) source vehicle index
* - 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(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
VehicleID s = GB(p1, 0, 16);
VehicleID d = GB(p1, 16, 16);
@@ -1171,7 +1169,7 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* To do this, CmdMoveRailVehicle must be called once more
* we can't loop forever here because next time we reach this line we will have a front engine */
if (src_head != NULL && !IsFrontEngine(src_head) && IsTrainEngine(src_head)) {
- CmdMoveRailVehicle(x, y, flags, src_head->index | (INVALID_VEHICLE << 16), 1);
+ CmdMoveRailVehicle(0, flags, src_head->index | (INVALID_VEHICLE << 16), 1);
src_head = NULL; // don't do anything more to this train since the new call will do it
}
@@ -1210,11 +1208,11 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Start/Stop a train.
- * @param x,y unused
+ * @param tile unused
* @param p1 train to start/stop
* @param p2 unused
*/
-int32 CmdStartStopTrain(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdStartStopTrain(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -1238,7 +1236,7 @@ int32 CmdStartStopTrain(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Sell a (single) train wagon/engine.
- * @param x,y unused
+ * @param tile unused
* @param p1 the wagon/engine index
* @param p2 the selling mode
* - p2 = 0: only sell the single dragged wagon/engine (and any belonging rear-engines)
@@ -1247,7 +1245,7 @@ int32 CmdStartStopTrain(int x, int y, uint32 flags, uint32 p1, uint32 p2)
* - 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(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v, *tmp, *first;
Vehicle *new_f = NULL;
@@ -1355,7 +1353,7 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p2 == 2 && HASBIT(ori_subtype, Train_Front)) {
for (v = first; v != NULL; v = tmp) {
tmp = GetNextVehicle(v);
- DoCommandByTile(v->tile, v->index | INVALID_VEHICLE << 16, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ DoCommand(v->tile, v->index | INVALID_VEHICLE << 16, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
}
}
}
@@ -1632,11 +1630,11 @@ static void ReverseTrainDirection(Vehicle *v)
}
/** Reverse train.
- * @param x,y unused
+ * @param tile unused
* @param p1 train to reverse
* @param p2 if true, reverse a unit in a train (needs to be in a depot)
*/
- int32 CmdReverseTrainDirection(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -1681,11 +1679,11 @@ static void ReverseTrainDirection(Vehicle *v)
}
/** Force a train through a red signal
- * @param x,y unused
+ * @param tile unused
* @param p1 train to ignore the red signal
* @param p2 unused
*/
-int32 CmdForceTrainProceed(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
@@ -1701,11 +1699,11 @@ int32 CmdForceTrainProceed(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Refits a train to the specified cargo type.
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID of the train to refit
* @param p2 the new cargo type to refit to (p2 & 0xFF)
*/
-int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
CargoID new_cid = GB(p2, 0, 8);
Vehicle *v;
@@ -1873,11 +1871,11 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v)
}
/** Send a train to a depot
- * @param x,y unused
+ * @param tile unused
* @param p1 train to send to the depot
* @param p2 unused
*/
-int32 CmdSendTrainToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
TrainFindDepotData tfdd;
@@ -1916,7 +1914,7 @@ int32 CmdSendTrainToDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
/* If there is no depot in front, reverse automatically */
if (tfdd.reverse)
- DoCommandByTile(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
+ DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
}
return 0;
diff --git a/train_gui.c b/train_gui.c
index dc6e0f7da..7c86a4d65 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -810,7 +810,7 @@ static void RailVehicleRefitWndProc(Window *w, WindowEvent *e)
WP(w,refit_d).cargo = DrawVehicleRefitWindow(v, WP(w, refit_d).sel);
if (WP(w,refit_d).cargo != CT_INVALID) {
- int32 cost = DoCommandByTile(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_RAIL_VEHICLE);
+ int32 cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo, DC_QUERY_COST, CMD_REFIT_RAIL_VEHICLE);
if (!CmdFailed(cost)) {
SetDParam(2, cost);
SetDParam(0, _cargoc.names_long[WP(w,refit_d).cargo]);
diff --git a/tree_cmd.c b/tree_cmd.c
index 114554d12..7b38f6358 100644
--- a/tree_cmd.c
+++ b/tree_cmd.c
@@ -124,14 +124,16 @@ void GenerateTrees(void)
}
/** Plant a tree.
- * @param x,y start tile of area-drag of tree plantation
+ * @param tile start tile of area-drag of tree plantation
* @param p1 tree type, -1 means random.
* @param p2 end tile of area-drag
*/
-int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
StringID msg = INVALID_STRING_ID;
int32 cost;
+ int ex;
+ int ey;
int sx, sy, x, y;
if (p2 >= MapSize()) return CMD_ERROR;
@@ -141,10 +143,10 @@ int32 CmdPlantTree(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_OTHER);
// make sure sx,sy are smaller than ex,ey
+ ex = TileX(tile);
+ ey = TileY(tile);
sx = TileX(p2);
sy = TileY(p2);
- ex /= TILE_SIZE;
- ey /= TILE_SIZE;
if (ex < sx) intswap(ex, sx);
if (ey < sy) intswap(ey, sy);
diff --git a/tunnelbridge_cmd.c b/tunnelbridge_cmd.c
index b53388f2b..712cfef6f 100644
--- a/tunnelbridge_cmd.c
+++ b/tunnelbridge_cmd.c
@@ -170,17 +170,19 @@ bool CheckBridge_Stuff(byte bridge_type, uint bridge_len)
}
/** Build a Bridge
- * @param x,y end tile coord
+ * @param end_tile end tile
* @param p1 packed start tile coords (~ dx)
* @param p2 various bitstuffed elements
* - p2 = (bit 0- 7) - bridge type (hi bh)
* - p2 = (bit 8-..) - rail type. bit15 ((x>>8)&0x80) means road bridge.
*/
-int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
{
int bridge_type;
TransportType transport;
RailType railtype;
+ int x;
+ int y;
int sx,sy;
TileIndex tile_start;
TileIndex tile_end;
@@ -214,6 +216,8 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
transport = TRANSPORT_RAIL;
}
+ x = TileX(end_tile) * TILE_SIZE;
+ y = TileY(end_tile) * TILE_SIZE;
sx = TileX(p1) * TILE_SIZE;
sy = TileY(p1) * TILE_SIZE;
@@ -268,7 +272,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* Try and clear the start landscape */
- ret = DoCommandByTile(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile_start, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost = ret;
@@ -280,7 +284,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/* Try and clear the end landscape */
- ret = DoCommandByTile(tile_end, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile_end, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost += ret;
@@ -352,7 +356,7 @@ int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2)
default:
not_valid_below:;
/* try and clear the middle landscape */
- ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost += ret;
transport_under = INVALID_TRANSPORT;
@@ -425,14 +429,13 @@ not_valid_below:;
/** Build Tunnel.
- * @param x,y start tile coord of tunnel
+ * @param tile start tile of tunnel
* @param p1 railtype, 0x200 for road tunnel
* @param p2 unused
*/
-int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2)
{
TileIndexDiff delta;
- TileIndex start_tile;
TileIndex end_tile;
DiagDirection direction;
uint start_tileh;
@@ -446,7 +449,6 @@ int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p1 != 0x200 && !ValParamRailtype(p1)) return CMD_ERROR;
- start_tile = TileVirtXY(x, y);
start_tileh = GetTileSlope(start_tile, &start_z);
switch (start_tileh) {
@@ -457,7 +459,7 @@ int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
default: return_cmd_error(STR_500B_SITE_UNSUITABLE_FOR_TUNNEL);
}
- ret = DoCommandByTile(start_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(start_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost = _price.build_tunnel + ret;
@@ -483,10 +485,10 @@ int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// slope of end tile must be complementary to the slope of the start tile
if (end_tileh != (15 ^ start_tileh)) {
- ret = DoCommandByTile(end_tile, end_tileh & start_tileh, 0, flags, CMD_TERRAFORM_LAND);
+ ret = DoCommand(end_tile, end_tileh & start_tileh, 0, flags, CMD_TERRAFORM_LAND);
if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND);
} else {
- ret = DoCommandByTile(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
}
cost += _price.build_tunnel + ret;
@@ -1297,7 +1299,7 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, Pl
SetTileOwner(tile, OWNER_NONE);
}
} else {
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
}
}
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index 06055f3bd..a2518fd98 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -82,14 +82,13 @@ void UpdateCompanyHQ(Player *p, uint score)
}
/** Build or relocate the HQ. This depends if the HQ is already built or not
- * @param x,y the coordinates where the HQ will be built or relocated to
+ * @param tile tile where the HQ will be built or relocated to
* @param p1 unused
* @param p2 unused
*/
extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, int *);
-int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
Player *p = GetPlayer(_current_player);
int cost;
int32 ret;
@@ -219,7 +218,7 @@ static int32 ClearTile_Unmovable(TileIndex tile, byte flags)
}
if (IsOwnedLand(tile)) {
- return DoCommandByTile(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
+ return DoCommand(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
}
// checks if you're allowed to remove unmovable things
diff --git a/vehicle.c b/vehicle.c
index 4f1894322..0007b991d 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1493,11 +1493,11 @@ void AgeVehicle(Vehicle *v)
}
/** Clone a vehicle. If it is a train, it will clone all the cars too
-* @param x,y depot where the cloned vehicle is build
+* @param tile tile of the depot where the cloned vehicle is build
* @param p1 the original vehicle's index
* @param p2 1 = shared orders, else copied orders
*/
-int32 CmdCloneVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v_front, *v;
Vehicle *w_front, *w, *w_rear;
@@ -1544,7 +1544,7 @@ int32 CmdCloneVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
continue;
}
- cost = DoCommand(x, y, v->engine_type, 1, flags, CMD_BUILD_VEH(v->type));
+ cost = DoCommand(tile, v->engine_type, 1, flags, CMD_BUILD_VEH(v->type));
if (CmdFailed(cost)) return cost;
@@ -1557,18 +1557,18 @@ int32 CmdCloneVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (v->cargo_type != w->cargo_type) {
// we can't pay for refitting because we can't estimate refitting costs for a vehicle before it's build
// if we pay for it anyway, the cost and the estimated cost will not be the same and we will have an assert
- DoCommand(x, y, w->index, v->cargo_type, flags, CMD_REFIT_VEH(v->type));
+ DoCommand(0, w->index, v->cargo_type, flags, CMD_REFIT_VEH(v->type));
}
}
if (v->type == VEH_Train && !IsFrontEngine(v)) {
// this s a train car
// add this unit to the end of the train
- DoCommand(x, y, (w_rear->index << 16) | w->index, 1, flags, CMD_MOVE_RAIL_VEHICLE);
+ DoCommand(0, (w_rear->index << 16) | w->index, 1, flags, CMD_MOVE_RAIL_VEHICLE);
} else {
// this is a front engine or not a train. It need orders
w_front = w;
- DoCommand(x, y, (v->index << 16) | w->index, p2 & 1 ? CO_SHARE : CO_COPY, flags, CMD_CLONE_ORDER);
+ DoCommand(0, (v->index << 16) | w->index, p2 & 1 ? CO_SHARE : CO_COPY, flags, CMD_CLONE_ORDER);
}
w_rear = w; // trains needs to know the last car in the train, so they can add more in next loop
}
@@ -1633,7 +1633,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
new_engine_type = EngineReplacementForPlayer(p, old_v->engine_type);
if (new_engine_type == INVALID_ENGINE) new_engine_type = old_v->engine_type;
- cost = DoCommand(old_v->x_pos, old_v->y_pos, new_engine_type, 1, flags, CMD_BUILD_VEH(old_v->type));
+ cost = DoCommand(old_v->tile, new_engine_type, 1, flags, CMD_BUILD_VEH(old_v->type));
if (CmdFailed(cost)) return cost;
if (flags & DC_EXEC) {
@@ -1646,7 +1646,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
// we add the refit cost to cost, so it's added to the cost animation
// it's not in the calculation of having enough money to actually do the replace since it's rather hard to do by design, but since
// we pay for it, it's nice to make the cost animation include it
- int32 temp_cost = DoCommand(0, 0, new_v->index, old_v->cargo_type, DC_EXEC, CMD_REFIT_VEH(new_v->type));
+ int32 temp_cost = DoCommand(0, new_v->index, old_v->cargo_type, DC_EXEC, CMD_REFIT_VEH(new_v->type));
if (!CmdFailed(temp_cost)) cost += temp_cost;
}
}
@@ -1657,12 +1657,12 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
* We add the new engine after the old one instead of replacing it. It will give the same result anyway when we
* sell the old engine in a moment
*/
- DoCommand(0, 0, (GetPrevVehicleInChain(old_v)->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ DoCommand(0, (GetPrevVehicleInChain(old_v)->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
/* Now we move the old one out of the train */
- DoCommand(0, 0, (INVALID_VEHICLE << 16) | old_v->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ DoCommand(0, (INVALID_VEHICLE << 16) | old_v->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
} else {
// copy/clone the orders
- DoCommand(0, 0, (old_v->index << 16) | new_v->index, IsOrderListShared(old_v) ? CO_SHARE : CO_COPY, DC_EXEC, CMD_CLONE_ORDER);
+ DoCommand(0, (old_v->index << 16) | new_v->index, IsOrderListShared(old_v) ? CO_SHARE : CO_COPY, DC_EXEC, CMD_CLONE_ORDER);
new_v->cur_order_index = old_v->cur_order_index;
ChangeVehicleViewWindow(old_v, new_v);
new_v->profit_this_year = old_v->profit_this_year;
@@ -1680,7 +1680,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
}
if (temp_v != NULL) {
- DoCommand(0, 0, (new_v->index << 16) | temp_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ DoCommand(0, (new_v->index << 16) | temp_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
}
}
}
@@ -1696,7 +1696,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
}
// sell the engine/ find out how much you get for the old engine
- cost += DoCommand(0, 0, old_v->index, 0, flags, CMD_SELL_VEH(old_v->type));
+ cost += DoCommand(0, old_v->index, 0, flags, CMD_SELL_VEH(old_v->type));
if (new_front) {
// now we assign the old unitnumber to the new vehicle
@@ -1706,7 +1706,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags)
// Transfer the name of the old vehicle.
if ((flags & DC_EXEC) && vehicle_name[0] != '\0') {
_cmd_text = vehicle_name;
- DoCommand(0, 0, new_v->index, 0, DC_EXEC, CMD_NAME_VEHICLE);
+ DoCommand(0, new_v->index, 0, DC_EXEC, CMD_NAME_VEHICLE);
}
return cost;
@@ -1836,9 +1836,9 @@ static void MaybeReplaceVehicle(Vehicle *v)
}
temp = w;
w = GetNextVehicle(w);
- DoCommand(0, 0, (INVALID_VEHICLE << 16) | temp->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
+ DoCommand(0, (INVALID_VEHICLE << 16) | temp->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE);
MoveVehicleCargo(v, temp);
- cost += DoCommand(0, 0, temp->index, 0, flags, CMD_SELL_VEH(temp->type));
+ cost += DoCommand(0, temp->index, 0, flags, CMD_SELL_VEH(temp->type));
}
}
@@ -1850,11 +1850,11 @@ static void MaybeReplaceVehicle(Vehicle *v)
/** Give a custom name to your vehicle
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID to name
* @param p2 unused
*/
-int32 CmdNameVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdNameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle *v;
StringID str;
@@ -1883,11 +1883,11 @@ int32 CmdNameVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
/** Change the service interval of a vehicle
- * @param x,y unused
+ * @param tile unused
* @param p1 vehicle ID that is being service-interval-changed
* @param p2 new service interval
*/
-int32 CmdChangeServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 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 */
diff --git a/water_cmd.c b/water_cmd.c
index 9abcc7fd9..a56e5e626 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -42,13 +42,13 @@ const SpriteID _water_shore_sprites[15] = {
static void FloodVehicle(Vehicle *v);
/** Build a ship depot.
- * @param x,y tile coordinates where ship depot is built
+ * @param tile tile where ship depot is built
* @param p1 depot direction (0 == X or 1 == Y)
* @param p2 unused
*/
-int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile, tile2;
+ TileIndex tile2;
int32 cost, ret;
Depot *depot;
@@ -57,7 +57,6 @@ int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (p1 > 1) return CMD_ERROR;
- tile = TileVirtXY(x, y);
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
tile2 = tile + (p1 ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
@@ -66,9 +65,9 @@ int32 CmdBuildShipDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2))
return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER);
- ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
- ret = DoCommandByTile(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
// pretend that we're not making land from the water even though we actually are.
@@ -123,17 +122,17 @@ static int32 DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
int delta;
// middle tile
- ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
delta = TileOffsByDir(dir);
// lower tile
- ret = DoCommandByTile(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
if (GetTileSlope(tile - delta, NULL)) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
// upper tile
- ret = DoCommandByTile(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
if (GetTileSlope(tile + delta, NULL)) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
@@ -173,13 +172,12 @@ static void MarkTilesAroundDirty(TileIndex tile)
}
/** Builds a lock (ship-lift)
- * @param x,y tile coordinates where to place the lock
+ * @param tile tile where to place the lock
* @param p1 unused
* @param p2 unused
*/
-int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
DiagDirection dir;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -195,23 +193,24 @@ int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
}
/** Build a piece of canal.
- * @param x,y end tile of stretch-dragging
+ * @param tile end tile of stretch-dragging
* @param p1 start tile of stretch-dragging
* @param p2 unused
*/
-int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
int32 cost;
int size_x, size_y;
+ int x;
+ int y;
int sx, sy;
if (p1 >= MapSize()) return CMD_ERROR;
+ x = TileX(tile);
+ y = TileY(tile);
sx = TileX(p1);
sy = TileY(p1);
- /* x,y are in pixel-coordinates, transform to tile-coordinates
- * to be able to use the BEGIN_TILE_LOOP() macro */
- x >>= 4; y >>= 4;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -241,7 +240,7 @@ int32 CmdBuildCanal(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) SetWaterUnderBridge(tile);
} else {
/* no bridge, try to clear it. */
- int32 ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+ int32 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return ret;
cost += ret;
@@ -524,7 +523,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
case MP_CLEAR:
case MP_TREES:
_current_player = OWNER_WATER;
- if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
+ if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
MakeShore(target);
MarkTileDirtyByTile(target);
}
@@ -557,7 +556,7 @@ static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
if (v != NULL) FloodVehicle(v);
}
- if (!CmdFailed(DoCommandByTile(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
+ if (!CmdFailed(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
MakeWater(target);
MarkTileDirtyByTile(target);
}
@@ -684,7 +683,7 @@ static void ChangeTileOwner_Water(TileIndex tile, PlayerID old_player, PlayerID
if (new_player != OWNER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
- DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
}
}
diff --git a/waypoint.c b/waypoint.c
index dbd583e84..715c530b3 100644
--- a/waypoint.c
+++ b/waypoint.c
@@ -163,16 +163,15 @@ void UpdateAllWaypointCustomGraphics(void)
/** Convert existing rail to waypoint. Eg build a waypoint station over
* piece of rail
- * @param x,y coordinates where waypoint will be built
+ * @param tile tile where waypoint will be built
* @param p1 graphics for waypoint type, 0 indicates standard graphics
* @param p2 unused
*
* @todo When checking for the tile slope,
* distingush between "Flat land required" and "land sloped in wrong direction"
*/
-int32 CmdBuildTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
Waypoint *wp;
uint tileh;
Axis axis;
@@ -311,23 +310,22 @@ int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
}
/** Delete a waypoint
- * @param x,y coordinates where waypoint is to be deleted
+ * @param tile tile where waypoint is to be deleted
* @param p1 unused
* @param p2 unused
*/
-int32 CmdRemoveTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- TileIndex tile = TileVirtXY(x, y);
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
return RemoveTrainWaypoint(tile, flags, true);
}
/** Rename a waypoint.
- * @param x,y unused
+ * @param tile unused
* @param p1 id of waypoint
* @param p2 unused
*/
-int32 CmdRenameWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
+int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Waypoint *wp;
StringID str;