Changeset - r9628:c2c21f333b85
[Not reviewed]
master
0 6 0
smatz - 16 years ago 2008-07-09 20:55:47
smatz@openttd.org
(svn r13691) -Codechange: make it easier to determine whether a command is ran in the context of autoreplace or not
6 files changed with 21 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -261,7 +261,7 @@ uint16 AircraftDefaultCargoCapacity(Carg
 
 * @param tile tile of depot where aircraft is built
 
 * @param flags for command
 
 * @param p1 aircraft type being built (engine)
 
 * @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
 
 * @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 t
 
		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);
 

	
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -128,7 +128,7 @@ static CargoID GetNewCargoTypeForReplace
 
 * @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(Vehicl
 
	 * 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(Vehicl
 
			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));
src/command_type.h
Show inline comments
 
@@ -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
 
};
 

	
 
/**
src/roadveh_cmd.cpp
Show inline comments
 
@@ -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 ti
 
	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);
 

	
src/ship_cmd.cpp
Show inline comments
 
@@ -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,
 
	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);
src/train_cmd.cpp
Show inline comments
 
@@ -685,8 +685,7 @@ static void AddRearEngineToMultiheadedTr
 
 * @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(TileInde
 

	
 
		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(TileInde
 
			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);
 
			}
 

	
0 comments (0 inline, 0 general)