summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aircraft_cmd.cpp4
-rw-r--r--src/autoreplace_cmd.cpp6
-rw-r--r--src/command_type.h17
-rw-r--r--src/roadveh_cmd.cpp4
-rw-r--r--src/ship_cmd.cpp4
-rw-r--r--src/train_cmd.cpp7
6 files changed, 21 insertions, 21 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 7ad8486a4..dbdf6bd89 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -261,7 +261,7 @@ uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi)
* @param tile tile of depot where aircraft is built
* @param flags for command
* @param p1 aircraft type being built (engine)
- * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
+ * @param p2 unused
* return result of operation. Could be cost, error
*/
CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -286,7 +286,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
}
- UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
+ UnitID unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_AIRCRAFT);
if (unit_num > _settings_game.vehicle.max_aircraft)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 59cb0ac75..c2a3eaaea 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -128,7 +128,7 @@ static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type)
* @param new_engine_type The EngineID to replace to
* @return value is cost of the replacement or CMD_ERROR
*/
-static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost, const Player *p, EngineID new_engine_type)
+static CommandCost ReplaceVehicle(Vehicle **w, uint32 flags, Money total_cost, const Player *p, EngineID new_engine_type)
{
CommandCost cost;
CommandCost sell_value;
@@ -151,7 +151,7 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost, con
* We take it back if building fails or when we really sell the old engine */
SubtractMoneyFromPlayer(sell_value);
- cost = DoCommand(old_v->tile, new_engine_type, 3, flags, GetCmdBuildVeh(old_v));
+ cost = DoCommand(old_v->tile, new_engine_type, 0, flags | DC_AUTOREPLACE, GetCmdBuildVeh(old_v));
if (CmdFailed(cost)) {
/* Take back the money we just gave the player */
sell_value.MultiplyCost(-1);
@@ -259,7 +259,7 @@ static CommandCost ReplaceVehicle(Vehicle **w, byte flags, Money total_cost, con
if (next_veh != NULL) {
/* Verify that the wagons can be placed on the engine in question.
* This is done by building an engine, test if the wagons can be added and then sell the test engine. */
- DoCommand(old_v->tile, new_engine_type, 3, DC_EXEC, GetCmdBuildVeh(old_v));
+ DoCommand(old_v->tile, new_engine_type, 0, DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_v));
Vehicle *temp = GetVehicle(_new_vehicle_id);
tmp_move = DoCommand(0, (temp->index << 16) | next_veh->index, 1, 0, CMD_MOVE_RAIL_VEHICLE);
DoCommand(0, temp->index, 0, DC_EXEC, GetCmdSellVeh(old_v));
diff --git a/src/command_type.h b/src/command_type.h
index 742bdd9ba..cdd94dabd 100644
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -286,14 +286,15 @@ enum {
* This enums defines some flags which can be used for the commands.
*/
enum {
- DC_EXEC = 0x01, ///< execute the given command
- DC_AUTO = 0x02, ///< don't allow building on structures
- DC_QUERY_COST = 0x04, ///< query cost only, don't build.
- DC_NO_WATER = 0x08, ///< don't allow building on water
- DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail)
- DC_AI_BUILDING = 0x20, ///< special building rules for AI
- DC_NO_TOWN_RATING = 0x40, ///< town rating does not disallow you from building
- DC_BANKRUPT = 0x80, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
+ DC_EXEC = 0x001, ///< execute the given command
+ DC_AUTO = 0x002, ///< don't allow building on structures
+ DC_QUERY_COST = 0x004, ///< query cost only, don't build.
+ DC_NO_WATER = 0x008, ///< don't allow building on water
+ DC_NO_RAIL_OVERLAP = 0x010, ///< don't allow overlap of rails (used in buildrail)
+ DC_AI_BUILDING = 0x020, ///< special building rules for AI
+ DC_NO_TOWN_RATING = 0x040, ///< town rating does not disallow you from building
+ DC_BANKRUPT = 0x080, ///< company bankrupts, skip money check, skip vehicle on tile check in some cases
+ DC_AUTOREPLACE = 0x100, ///< autoreplace/autorenew is in progress
};
/**
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 21bfb7df5..0da65c5cb 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -170,7 +170,7 @@ void RoadVehUpdateCache(Vehicle *v)
* @param tile tile of depot where road vehicle is built
* @param flags operation to perform
* @param p1 bus/truck type being built (engine)
- * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
+ * @param p2 unused
*/
CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -204,7 +204,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v = vl[0];
/* find the first free roadveh id */
- unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_ROAD);
+ unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_ROAD);
if (unit_num > _settings_game.vehicle.max_roadveh)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 2af35c307..98f718a80 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -748,7 +748,7 @@ void ShipsYearlyLoop()
* @param tile tile of depot where ship is built
* @param flags type of operation
* @param p1 ship type being built (engine)
- * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
+ * @param p2 unused
*/
CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -766,7 +766,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!IsShipDepotTile(tile)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
- unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
+ unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_SHIP);
if (!Vehicle::AllocateList(NULL, 1) || unit_num > _settings_game.vehicle.max_ships)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 88fa3d194..cb923e81d 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -685,8 +685,7 @@ static void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool buildin
* @param tile tile of the depot where rail-vehicle is built
* @param flags type of operation
* @param p1 engine type id
- * @param p2 bit 0 when set, the train will get number 0, otherwise it will get a free number
- * bit 1 prevents any free cars from being added to the train
+ * @param p2 bit 1 prevents any free cars from being added to the train
*/
CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -725,7 +724,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
Vehicle *v = vl[0];
- UnitID unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_TRAIN);
+ UnitID unit_num = (flags & DC_AUTOREPLACE) ? 0 : GetFreeUnitNumber(VEH_TRAIN);
if (unit_num > _settings_game.vehicle.max_trains)
return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
@@ -798,7 +797,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
TrainConsistChanged(v);
UpdateTrainGroupID(v);
- if (!HasBit(p2, 1)) { // check if the cars should be added to the new vehicle
+ if (!HasBit(p2, 1) && !(flags & DC_AUTOREPLACE)) { // check if the cars should be added to the new vehicle
NormalizeTrainVehInDepot(v);
}