Changeset - r26092:d96f469449f6
[Not reviewed]
src/ai/ai_instance.cpp
Show inline comments
 
@@ -98,7 +98,7 @@ ScriptInfo *AIInstance::FindLibrary(cons
 
 * @param p2 p2 as given to DoCommandPInternal.
 
 * @param cmd cmd as given to DoCommandPInternal.
 
 */
 
void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	/*
 
	 * The company might not exist anymore. Check for this.
src/airport_gui.cpp
Show inline comments
 
@@ -40,7 +40,7 @@ static void ShowBuildAirportPicker(Windo
 

	
 
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
 

	
 
void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -60,7 +60,7 @@ static void PlaceAirport(TileIndex tile)
 

	
 
	uint32 p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex();
 
	p1 |= _selected_airport_layout << 8;
 
	CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport, "" };
 
	CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_AIRPORT, STR_ERROR_CAN_T_BUILD_AIRPORT_HERE, CcBuildAirport, "" };
 
	ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE));
 
}
 

	
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -340,7 +340,7 @@ static CommandCost BuildReplacementVehic
 
	}
 

	
 
	/* Build the new vehicle */
 
	cost = DoCommand(DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh), old_veh->tile, e | (CT_INVALID << 24), 0);
 
	cost = DoCommand(DC_EXEC | DC_AUTOREPLACE, CMD_BUILD_VEHICLE, old_veh->tile, e | (CT_INVALID << 24), 0);
 
	if (cost.Failed()) return cost;
 

	
 
	Vehicle *new_veh = Vehicle::Get(_new_vehicle_id);
 
@@ -350,7 +350,7 @@ static CommandCost BuildReplacementVehic
 
	if (refit_cargo != CT_NO_REFIT) {
 
		byte subtype = GetBestFittingSubType(old_veh, new_veh, refit_cargo);
 

	
 
		cost.AddCost(DoCommand(DC_EXEC, GetCmdRefitVeh(new_veh), 0, new_veh->index, refit_cargo | (subtype << 8)));
 
		cost.AddCost(DoCommand(DC_EXEC, CMD_REFIT_VEHICLE, 0, new_veh->index, refit_cargo | (subtype << 8)));
 
		assert(cost.Succeeded()); // This should be ensured by GetNewCargoTypeForReplace()
 
	}
 

	
 
@@ -466,11 +466,11 @@ static CommandCost ReplaceFreeUnit(Vehic
 
		}
 

	
 
		/* Sell the old vehicle */
 
		cost.AddCost(DoCommand(flags, GetCmdSellVeh(old_v), 0, old_v->index, 0));
 
		cost.AddCost(DoCommand(flags, CMD_SELL_VEHICLE, 0, old_v->index, 0));
 

	
 
		/* If we are not in DC_EXEC undo everything */
 
		if ((flags & DC_EXEC) == 0) {
 
			DoCommand(DC_EXEC, GetCmdSellVeh(new_v), 0, new_v->index, 0);
 
			DoCommand(DC_EXEC, CMD_SELL_VEHICLE, 0, new_v->index, 0);
 
		}
 
	}
 

	
 
@@ -597,7 +597,7 @@ static CommandCost ReplaceChain(Vehicle 
 
					assert(RailVehInfo(wagon->engine_type)->railveh_type == RAILVEH_WAGON);
 

	
 
					/* Sell wagon */
 
					[[maybe_unused]] CommandCost ret = DoCommand(DC_EXEC, GetCmdSellVeh(wagon), 0, wagon->index, 0);
 
					[[maybe_unused]] CommandCost ret = DoCommand(DC_EXEC, CMD_SELL_VEHICLE, 0, wagon->index, 0);
 
					assert(ret.Succeeded());
 
					new_vehs[i] = nullptr;
 

	
 
@@ -629,7 +629,7 @@ static CommandCost ReplaceChain(Vehicle 
 
					/* Sell the vehicle.
 
					 * Note: This might temporarily construct new trains, so use DC_AUTOREPLACE to prevent
 
					 *       it from failing due to engine limits. */
 
					cost.AddCost(DoCommand(flags | DC_AUTOREPLACE, GetCmdSellVeh(w), 0, w->index, 0));
 
					cost.AddCost(DoCommand(flags | DC_AUTOREPLACE, CMD_SELL_VEHICLE, 0, w->index, 0));
 
					if ((flags & DC_EXEC) != 0) {
 
						old_vehs[i] = nullptr;
 
						if (i == 0) old_head = nullptr;
 
@@ -660,7 +660,7 @@ static CommandCost ReplaceChain(Vehicle 
 
		if ((flags & DC_EXEC) == 0) {
 
			for (int i = num_units - 1; i >= 0; i--) {
 
				if (new_vehs[i] != nullptr) {
 
					DoCommand(DC_EXEC, GetCmdSellVeh(new_vehs[i]), 0, new_vehs[i]->index, 0);
 
					DoCommand(DC_EXEC, CMD_SELL_VEHICLE, 0, new_vehs[i]->index, 0);
 
					new_vehs[i] = nullptr;
 
				}
 
			}
 
@@ -691,12 +691,12 @@ static CommandCost ReplaceChain(Vehicle 
 
				}
 

	
 
				/* Sell the old vehicle */
 
				cost.AddCost(DoCommand(flags, GetCmdSellVeh(old_head), 0, old_head->index, 0));
 
				cost.AddCost(DoCommand(flags, CMD_SELL_VEHICLE, 0, old_head->index, 0));
 
			}
 

	
 
			/* If we are not in DC_EXEC undo everything */
 
			if ((flags & DC_EXEC) == 0) {
 
				DoCommand(DC_EXEC, GetCmdSellVeh(new_head), 0, new_head->index, 0);
 
				DoCommand(DC_EXEC, CMD_SELL_VEHICLE, 0, new_head->index, 0);
 
			}
 
		}
 
	}
src/bridge_gui.cpp
Show inline comments
 
@@ -58,7 +58,7 @@ typedef GUIList<BuildBridgeData> GUIBrid
 
 * - p2 = (bit 15-16) - transport type.
 
 * @param cmd unused
 
 */
 
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 
	if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile);
 
@@ -117,7 +117,7 @@ private:
 
			case TRANSPORT_ROAD: _last_roadbridge_type = this->bridges->at(i).index; break;
 
			default: break;
 
		}
 
		DoCommandP(CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge,
 
		DoCommandP(CMD_BUILD_BRIDGE, STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge,
 
					this->end_tile, this->start_tile, this->type | this->bridges->at(i).index);
 
	}
 

	
 
@@ -383,7 +383,7 @@ void ShowBuildBridgeWindow(TileIndex sta
 
		default: break; // water ways and air routes don't have bridge types
 
	}
 
	if (_ctrl_pressed && CheckBridgeAvailability(last_bridge_type, bridge_len).Succeeded()) {
 
		DoCommandP(CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge, end, start, type | last_bridge_type);
 
		DoCommandP(CMD_BUILD_BRIDGE, STR_ERROR_CAN_T_BUILD_BRIDGE_HERE, CcBuildBridge, end, start, type | last_bridge_type);
 
		return;
 
	}
 

	
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1226,7 +1226,7 @@ struct BuildVehicleWindow : Window {
 

	
 
		if (!this->listview_mode) {
 
			/* Query for cost and refitted capacity */
 
			CommandCost ret = DoCommand(DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type), this->window_number, this->sel_engine | (cargo << 24), 0);
 
			CommandCost ret = DoCommand(DC_QUERY_COST, CMD_BUILD_VEHICLE, this->window_number, this->sel_engine | (cargo << 24), 0);
 
			if (ret.Succeeded()) {
 
				this->te.cost          = ret.GetCost() - e->GetCost();
 
				this->te.capacity      = _returned_refit_capacity;
 
@@ -1469,7 +1469,7 @@ struct BuildVehicleWindow : Window {
 
					CommandCallback *callback = (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildPrimaryVehicle;
 
					CargoID cargo = this->cargo_filter[this->cargo_filter_criteria];
 
					if (cargo == CF_ANY || cargo == CF_ENGINES) cargo = CF_NONE;
 
					DoCommandP(GetCmdBuildVeh(this->vehicle_type), callback, this->window_number, sel_eng | (cargo << 24), 0);
 
					DoCommandP(CMD_BUILD_VEHICLE, GetCmdBuildVehMsg(this->vehicle_type), callback, this->window_number, sel_eng | (cargo << 24), 0);
 
				}
 
				break;
 
			}
 
@@ -1634,7 +1634,7 @@ struct BuildVehicleWindow : Window {
 
	{
 
		if (str == nullptr) return;
 

	
 
		DoCommandP(CMD_RENAME_ENGINE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type), 0, this->rename_engine, 0, str);
 
		DoCommandP(CMD_RENAME_ENGINE, STR_ERROR_CAN_T_RENAME_TRAIN_TYPE + this->vehicle_type, 0, this->rename_engine, 0, str);
 
	}
 

	
 
	void OnDropdownSelect(int widget, int index) override
src/command.cpp
Show inline comments
 
@@ -378,8 +378,6 @@ static const Command _command_proc_table
 
 */
 
bool IsValidCommand(uint32 cmd)
 
{
 
	cmd &= CMD_ID_MASK;
 

	
 
	return cmd < lengthof(_command_proc_table) && _command_proc_table[cmd].proc != nullptr;
 
}
 

	
 
@@ -390,11 +388,11 @@ bool IsValidCommand(uint32 cmd)
 
 * @param cmd The integer value of the command
 
 * @return The flags for this command
 
 */
 
CommandFlags GetCommandFlags(uint32 cmd)
 
CommandFlags GetCommandFlags(Commands cmd)
 
{
 
	assert(IsValidCommand(cmd));
 

	
 
	return _command_proc_table[cmd & CMD_ID_MASK].flags;
 
	return _command_proc_table[cmd].flags;
 
}
 

	
 
/*!
 
@@ -404,11 +402,11 @@ CommandFlags GetCommandFlags(uint32 cmd)
 
 * @param cmd The integer value of the command
 
 * @return The name for this command
 
 */
 
const char *GetCommandName(uint32 cmd)
 
const char *GetCommandName(Commands cmd)
 
{
 
	assert(IsValidCommand(cmd));
 

	
 
	return _command_proc_table[cmd & CMD_ID_MASK].name;
 
	return _command_proc_table[cmd].name;
 
}
 

	
 
/**
 
@@ -433,7 +431,7 @@ bool IsCommandAllowedWhilePaused(uint32 
 
	static_assert(lengthof(command_type_lookup) == CMDT_END);
 

	
 
	assert(IsValidCommand(cmd));
 
	return _game_mode == GM_EDITOR || command_type_lookup[_command_proc_table[cmd & CMD_ID_MASK].type] <= _settings_game.construction.command_pause_level;
 
	return _game_mode == GM_EDITOR || command_type_lookup[_command_proc_table[cmd].type] <= _settings_game.construction.command_pause_level;
 
}
 

	
 

	
 
@@ -449,7 +447,7 @@ static int _docommand_recursive = 0;
 
 */
 
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
 
{
 
	return DoCommand(flags, container->cmd & CMD_ID_MASK, container->tile, container->p1, container->p2, container->text);
 
	return DoCommand(flags, container->cmd, container->tile, container->p1, container->p2, container->text);
 
}
 

	
 
/*!
 
@@ -465,7 +463,7 @@ CommandCost DoCommand(const CommandConta
 
 * @see CommandProc
 
 * @return the cost
 
 */
 
CommandCost DoCommand(DoCommandFlag flags, uint32 cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
CommandCost DoCommand(DoCommandFlag flags, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost res;
 

	
 
@@ -473,7 +471,7 @@ CommandCost DoCommand(DoCommandFlag flag
 
	if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (flags & DC_ALL_TILES) == 0))) return CMD_ERROR;
 

	
 
	/* Chop of any CMD_MSG or other flags; we don't need those here */
 
	CommandProc *proc = _command_proc_table[cmd & CMD_ID_MASK].proc;
 
	CommandProc *proc = _command_proc_table[cmd].proc;
 

	
 
	_docommand_recursive++;
 

	
 
@@ -542,13 +540,14 @@ Money GetAvailableMoneyForCommand()
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param callback A callback function to call after the command is finished
 
 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
 
 * @param network_command execute the command without sending it on the network
 
 * @param tile The tile to perform a command on (see #CommandProc)
 
 * @param p1 Additional data for the command (see #CommandProc)
 
 * @param p2 Additional data for the command (see #CommandProc)
 
 * @param text The text to pass
 
 * @return \c true if the command succeeded, else \c false.
 
 */
 
static bool DoCommandP(uint32 cmd, CommandCallback *callback, bool my_cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
static bool DoCommandP(Commands cmd, StringID err_message, CommandCallback *callback, bool my_cmd, bool network_command, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* Cost estimation is generally only done when the
 
	 * local user presses shift while doing something.
 
@@ -557,31 +556,30 @@ static bool DoCommandP(uint32 cmd, Comma
 
	 * to execute. */
 
	bool estimate_only = _shift_pressed && IsLocalCompany() &&
 
			!_generating_world &&
 
			!(cmd & CMD_NETWORK_COMMAND) &&
 
			!network_command &&
 
			!(GetCommandFlags(cmd) & CMD_NO_EST);
 

	
 
	/* We're only sending the command, so don't do
 
	 * fancy things for 'success'. */
 
	bool only_sending = _networking && !(cmd & CMD_NETWORK_COMMAND);
 
	bool only_sending = _networking && !network_command;
 

	
 
	/* Where to show the message? */
 
	int x = TileX(tile) * TILE_SIZE;
 
	int y = TileY(tile) * TILE_SIZE;
 

	
 
	if (_pause_mode != PM_UNPAUSED && !IsCommandAllowedWhilePaused(cmd) && !estimate_only) {
 
		ShowErrorMessage(GB(cmd, 16, 16), STR_ERROR_NOT_ALLOWED_WHILE_PAUSED, WL_INFO, x, y);
 
		ShowErrorMessage(err_message, STR_ERROR_NOT_ALLOWED_WHILE_PAUSED, WL_INFO, x, y);
 
		return false;
 
	}
 

	
 
	/* Only set p2 when the command does not come from the network. */
 
	if (!(cmd & CMD_NETWORK_COMMAND) && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER;
 
	if (!network_command && GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = CLIENT_ID_SERVER;
 

	
 
	CommandCost res = DoCommandPInternal(cmd, callback, my_cmd, estimate_only, tile, p1, p2, text);
 
	CommandCost res = DoCommandPInternal(cmd, err_message, callback, my_cmd, estimate_only, network_command, tile, p1, p2, text);
 
	if (res.Failed()) {
 
		/* Only show the error when it's for us. */
 
		StringID error_part1 = GB(cmd, 16, 16);
 
		if (estimate_only || (IsLocalCompany() && error_part1 != 0 && my_cmd)) {
 
			ShowErrorMessage(error_part1, res.GetErrorMessage(), WL_INFO, x, y, res.GetTextRefStackGRF(), res.GetTextRefStackSize(), res.GetTextRefStack());
 
		if (estimate_only || (IsLocalCompany() && err_message != 0 && my_cmd)) {
 
			ShowErrorMessage(err_message, res.GetErrorMessage(), WL_INFO, x, y, res.GetTextRefStackGRF(), res.GetTextRefStackSize(), res.GetTextRefStack());
 
		}
 
	} else if (estimate_only) {
 
		ShowEstimatedCostOrIncome(res.GetCost(), x, y);
 
@@ -605,15 +603,16 @@ static bool DoCommandP(uint32 cmd, Comma
 
 * Shortcut for the long DoCommandP when having a container with the data.
 
 * @param container the container with information.
 
 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
 
 * @param network_command execute the command without sending it on the network
 
 * @return true if the command succeeded, else false
 
 */
 
bool DoCommandP(const CommandContainer *container, bool my_cmd)
 
bool DoCommandP(const CommandContainer *container, bool my_cmd, bool network_command)
 
{
 
	return DoCommandP(container->cmd, container->callback, my_cmd, container->tile, container->p1, container->p2, container->text);
 
	return DoCommandP(container->cmd, container->err_msg, container->callback, my_cmd, network_command, container->tile, container->p1, container->p2, container->text);
 
}
 

	
 
/**
 
 * Shortcut for the long DoCommandP when not using a callback.
 
 * Shortcut for the long DoCommandP when not using a callback or error message.
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param tile The tile to perform a command on (see #CommandProc)
 
 * @param p1 Additional data for the command (see #CommandProc)
 
@@ -621,9 +620,39 @@ bool DoCommandP(const CommandContainer *
 
 * @param text The text to pass
 
 * @return \c true if the command succeeded, else \c false.
 
 */
 
bool DoCommandP(uint32 cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
bool DoCommandP(Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return DoCommandP(cmd, STR_NULL, nullptr, true, false, tile, p1, p2, text);
 
}
 

	
 
/**
 
 * Shortcut for the long DoCommandP when not using an error message.
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param callback A callback function to call after the command is finished
 
 * @param tile The tile to perform a command on (see #CommandProc)
 
 * @param p1 Additional data for the command (see #CommandProc)
 
 * @param p2 Additional data for the command (see #CommandProc)
 
 * @param text The text to pass
 
 * @return \c true if the command succeeded, else \c false.
 
 */
 
bool DoCommandP(Commands cmd, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return DoCommandP(cmd, nullptr, true, tile, p1, p2, text);
 
	return DoCommandP(cmd, STR_NULL, callback, true, false, tile, p1, p2, text);
 
}
 

	
 
/**
 
 * Shortcut for the long DoCommandP when not using a callback.
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param err_message Message prefix to show on error
 
 * @param tile The tile to perform a command on (see #CommandProc)
 
 * @param p1 Additional data for the command (see #CommandProc)
 
 * @param p2 Additional data for the command (see #CommandProc)
 
 * @param text The text to pass
 
 * @return \c true if the command succeeded, else \c false.
 
 */
 
bool DoCommandP(Commands cmd, StringID err_message, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return DoCommandP(cmd, err_message, nullptr, true, false, tile, p1, p2, text);
 
}
 

	
 
/*!
 
@@ -632,6 +661,7 @@ bool DoCommandP(uint32 cmd, TileIndex ti
 
 * \a tile, \a p1, and \a p2 are from the #CommandProc function. The parameter \a cmd is the command to execute.
 
 *
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param err_message Message prefix to show on error
 
 * @param callback A callback function to call after the command is finished
 
 * @param tile The tile to perform a command on (see #CommandProc)
 
 * @param p1 Additional data for the command (see #CommandProc)
 
@@ -639,9 +669,9 @@ bool DoCommandP(uint32 cmd, TileIndex ti
 
 * @param text The text to pass
 
 * @return \c true if the command succeeded, else \c false.
 
 */
 
bool DoCommandP(uint32 cmd, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
bool DoCommandP(Commands cmd, StringID err_message, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return DoCommandP(cmd, callback, true, tile, p1, p2, text);
 
	return DoCommandP(cmd, err_message, callback, true, false, tile, p1, p2, text);
 
}
 

	
 
/**
 
@@ -654,6 +684,7 @@ bool DoCommandP(uint32 cmd, CommandCallb
 
 * Helper function for the toplevel network safe docommand function for the current company.
 
 *
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param err_message Message prefix to show on error
 
 * @param callback A callback function to call after the command is finished
 
 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
 
 * @param estimate_only whether to give only the estimate or also execute the command
 
@@ -663,7 +694,7 @@ bool DoCommandP(uint32 cmd, CommandCallb
 
 * @param text The text to pass
 
 * @return the command cost of this function.
 
 */
 
CommandCost DoCommandPInternal(uint32 cmd, CommandCallback *callback, bool my_cmd, bool estimate_only, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
CommandCost DoCommandPInternal(Commands cmd, StringID err_message, CommandCallback *callback, bool my_cmd, bool estimate_only, bool network_command, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* Prevent recursion; it gives a mess over the network */
 
	assert(_docommand_recursive == 0);
 
@@ -673,10 +704,8 @@ CommandCost DoCommandPInternal(uint32 cm
 
	_additional_cash_required = 0;
 

	
 
	/* Get pointer to command handler */
 
	byte cmd_id = cmd & CMD_ID_MASK;
 
	assert(cmd_id < lengthof(_command_proc_table));
 

	
 
	CommandProc *proc = _command_proc_table[cmd_id].proc;
 
	assert(cmd < lengthof(_command_proc_table));
 
	CommandProc *proc = _command_proc_table[cmd].proc;
 
	/* Shouldn't happen, but you never know when someone adds
 
	 * NULLs to the _command_proc_table. */
 
	assert(proc != nullptr);
 
@@ -725,10 +754,10 @@ CommandCost DoCommandPInternal(uint32 cm
 
	 * we bail out here. */
 
	if (res.Failed() || estimate_only ||
 
			(!test_and_exec_can_differ && !CheckCompanyHasMoney(res))) {
 
		if (!_networking || _generating_world || (cmd & CMD_NETWORK_COMMAND) != 0) {
 
		if (!_networking || _generating_world || network_command) {
 
			/* Log the failed command as well. Just to be able to be find
 
			 * causes of desyncs due to bad command test implementations. */
 
			Debug(desync, 1, "cmdf: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
 
			Debug(desync, 1, "cmdf: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd, err_message, text, GetCommandName(cmd));
 
		}
 
		cur_company.Restore();
 
		return_dcpi(res);
 
@@ -738,8 +767,8 @@ CommandCost DoCommandPInternal(uint32 cm
 
	 * If we are in network, and the command is not from the network
 
	 * send it to the command-queue and abort execution
 
	 */
 
	if (_networking && !_generating_world && !(cmd & CMD_NETWORK_COMMAND)) {
 
		NetworkSendCommand(cmd & ~CMD_FLAGS_MASK, callback, _current_company, tile, p1, p2, text);
 
	if (_networking && !_generating_world && !network_command) {
 
		NetworkSendCommand(cmd, err_message, callback, _current_company, tile, p1, p2, text);
 
		cur_company.Restore();
 

	
 
		/* Don't return anything special here; no error, no costs.
 
@@ -748,7 +777,7 @@ CommandCost DoCommandPInternal(uint32 cm
 
		 * reset the storages as we've not executed the command. */
 
		return_dcpi(CommandCost());
 
	}
 
	Debug(desync, 1, "cmd: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
 
	Debug(desync, 1, "cmd: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd, err_message, text, GetCommandName(cmd));
 

	
 
	/* Actually try and execute the command. If no cost-type is given
 
	 * use the construction one */
 
@@ -757,7 +786,7 @@ CommandCost DoCommandPInternal(uint32 cm
 
	CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
 
	BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND);
 

	
 
	if (cmd_id == CMD_COMPANY_CTRL) {
 
	if (cmd == CMD_COMPANY_CTRL) {
 
		cur_company.Trash();
 
		/* We are a new company                  -> Switch to new local company.
 
		 * We were closed down                   -> Switch to spectator
src/command_func.h
Show inline comments
 
@@ -32,22 +32,24 @@ static const CommandCost CMD_ERROR = Com
 
 */
 
#define return_cmd_error(errcode) return CommandCost(errcode);
 

	
 
CommandCost DoCommand(DoCommandFlag flags, uint32 cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
CommandCost DoCommand(DoCommandFlag flags, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
 

	
 
bool DoCommandP(uint32 cmd, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
bool DoCommandP(uint32 cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
 
bool DoCommandP(Commands cmd, StringID err_message, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
bool DoCommandP(Commands cmd, StringID err_message, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
bool DoCommandP(Commands cmd, CommandCallback *callback, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
bool DoCommandP(Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text = {});
 
bool DoCommandP(const CommandContainer *container, bool my_cmd = true, bool network_command = false);
 

	
 
CommandCost DoCommandPInternal(uint32 cmd, CommandCallback *callback, bool my_cmd, bool estimate_only, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
 
CommandCost DoCommandPInternal(Commands cmd, StringID err_message, CommandCallback *callback, bool my_cmd, bool estimate_only, bool network_command, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
 

	
 
void NetworkSendCommand(uint32 cmd, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
 
void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
 

	
 
extern Money _additional_cash_required;
 

	
 
bool IsValidCommand(uint32 cmd);
 
CommandFlags GetCommandFlags(uint32 cmd);
 
const char *GetCommandName(uint32 cmd);
 
CommandFlags GetCommandFlags(Commands cmd);
 
const char *GetCommandName(Commands cmd);
 
Money GetAvailableMoneyForCommand();
 
bool IsCommandAllowedWhilePaused(uint32 cmd);
 

	
src/command_type.h
Show inline comments
 
@@ -172,7 +172,7 @@ public:
 
 *
 
 * @see _command_proc_table
 
 */
 
enum Commands {
 
enum Commands : uint16 {
 
	CMD_BUILD_RAILROAD_TRACK,         ///< build a rail track
 
	CMD_REMOVE_RAILROAD_TRACK,        ///< remove a rail track
 
	CMD_BUILD_SINGLE_RAIL,            ///< build a single rail track
 
@@ -361,28 +361,6 @@ enum DoCommandFlag {
 
DECLARE_ENUM_AS_BIT_SET(DoCommandFlag)
 

	
 
/**
 
 * Used to combine a StringID with the command.
 
 *
 
 * This macro can be used to add a StringID (the error message to show) on a command-id
 
 * (CMD_xxx). Use the binary or-operator "|" to combine the command with the result from
 
 * this macro.
 
 *
 
 * @param x The StringID to combine with a command-id
 
 */
 
#define CMD_MSG(x) ((x) << 16)
 

	
 
/**
 
 * Defines some flags.
 
 *
 
 * This enumeration defines some flags which are binary-or'ed on a command.
 
 */
 
enum FlaggedCommands {
 
	CMD_NETWORK_COMMAND       = 0x0100, ///< execute the command without sending it on the network
 
	CMD_FLAGS_MASK            = 0xFF00, ///< mask for all command flags
 
	CMD_ID_MASK               = 0x00FF, ///< mask for the command ID
 
};
 

	
 
/**
 
 * Command flags for the command table _command_proc_table.
 
 *
 
 * This enumeration defines flags for the _command_proc_table.
 
@@ -471,7 +449,7 @@ struct Command {
 
 * @param p1 Additional data of the command
 
 * @see CommandProc
 
 */
 
typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd);
 
typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
 

	
 
/**
 
 * Structure for buffering the build command when selecting a station to join.
 
@@ -480,7 +458,8 @@ struct CommandContainer {
 
	TileIndex tile;                  ///< tile command being executed on.
 
	uint32 p1;                       ///< parameter p1.
 
	uint32 p2;                       ///< parameter p2.
 
	uint32 cmd;                      ///< command being executed.
 
	Commands cmd;                    ///< command being executed.
 
	StringID err_msg;                ///< string ID of error message to use.
 
	CommandCallback *callback;       ///< any callback function executed upon successful completion of the command.
 
	std::string text;                ///< possible text sent for name changes etc.
 
};
src/company_gui.cpp
Show inline comments
 
@@ -435,11 +435,11 @@ struct CompanyFinancesWindow : Window {
 
				break;
 

	
 
			case WID_CF_INCREASE_LOAN: // increase loan
 
				DoCommandP(CMD_INCREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY), 0, 0, _ctrl_pressed);
 
				DoCommandP(CMD_INCREASE_LOAN, STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY, 0, 0, _ctrl_pressed);
 
				break;
 

	
 
			case WID_CF_REPAY_LOAN: // repay loan
 
				DoCommandP(CMD_DECREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_REPAY_LOAN), 0, 0, _ctrl_pressed);
 
				DoCommandP(CMD_DECREASE_LOAN, STR_ERROR_CAN_T_REPAY_LOAN, 0, 0, _ctrl_pressed);
 
				break;
 

	
 
			case WID_CF_INFRASTRUCTURE: // show infrastructure details
 
@@ -2576,11 +2576,11 @@ struct CompanyWindow : Window
 
				break;
 

	
 
			case WID_C_BUY_SHARE:
 
				DoCommandP(CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS), 0, this->window_number, 0);
 
				DoCommandP(CMD_BUY_SHARE_IN_COMPANY, STR_ERROR_CAN_T_BUY_25_SHARE_IN_THIS, 0, this->window_number, 0);
 
				break;
 

	
 
			case WID_C_SELL_SHARE:
 
				DoCommandP(CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_ERROR_CAN_T_SELL_25_SHARE_IN), 0, this->window_number, 0);
 
				DoCommandP(CMD_SELL_SHARE_IN_COMPANY, STR_ERROR_CAN_T_SELL_25_SHARE_IN, 0, this->window_number, 0);
 
				break;
 

	
 
			case WID_C_COMPANY_PASSWORD:
 
@@ -2613,7 +2613,7 @@ struct CompanyWindow : Window
 

	
 
	void OnPlaceObject(Point pt, TileIndex tile) override
 
	{
 
		if (DoCommandP(CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS), tile, OBJECT_HQ, 0) && !_shift_pressed) {
 
		if (DoCommandP(CMD_BUILD_OBJECT, STR_ERROR_CAN_T_BUILD_COMPANY_HEADQUARTERS, tile, OBJECT_HQ, 0) && !_shift_pressed) {
 
			ResetObjectToPlace();
 
			this->RaiseButtons();
 
		}
 
@@ -2635,16 +2635,16 @@ struct CompanyWindow : Window
 
				Money money = (Money)(strtoull(str, nullptr, 10) / _currency->rate);
 
				uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
 

	
 
				DoCommandP(CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_CAN_T_GIVE_MONEY), 0, money_c, this->window_number);
 
				DoCommandP(CMD_GIVE_MONEY, STR_ERROR_CAN_T_GIVE_MONEY, 0, money_c, this->window_number);
 
				break;
 
			}
 

	
 
			case WID_C_PRESIDENT_NAME:
 
				DoCommandP(CMD_RENAME_PRESIDENT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_PRESIDENT), 0, 0, 0, str);
 
				DoCommandP(CMD_RENAME_PRESIDENT, STR_ERROR_CAN_T_CHANGE_PRESIDENT, 0, 0, 0, str);
 
				break;
 

	
 
			case WID_C_COMPANY_NAME:
 
				DoCommandP(CMD_RENAME_COMPANY | CMD_MSG(STR_ERROR_CAN_T_CHANGE_COMPANY_NAME), 0, 0, 0, str);
 
				DoCommandP(CMD_RENAME_COMPANY, STR_ERROR_CAN_T_CHANGE_COMPANY_NAME, 0, 0, 0, str);
 
				break;
 

	
 
			case WID_C_COMPANY_JOIN:
 
@@ -2771,7 +2771,7 @@ struct BuyCompanyWindow : Window {
 
				break;
 

	
 
			case WID_BC_YES:
 
				DoCommandP(CMD_BUY_COMPANY | CMD_MSG(STR_ERROR_CAN_T_BUY_COMPANY), 0, this->window_number, 0);
 
				DoCommandP(CMD_BUY_COMPANY, STR_ERROR_CAN_T_BUY_COMPANY, 0, this->window_number, 0);
 
				break;
 
		}
 
	}
src/depot_gui.cpp
Show inline comments
 
@@ -117,7 +117,7 @@ extern void DepotSortList(VehicleList *l
 
 * @param p2 unused
 
 * @param cmd unused
 
 */
 
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -141,7 +141,7 @@ static void TrainDepotMoveVehicle(const 
 

	
 
	if (wagon == v) return;
 

	
 
	DoCommandP(CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_MOVE_VEHICLE), v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index);
 
	DoCommandP(CMD_MOVE_RAIL_VEHICLE, STR_ERROR_CAN_T_MOVE_VEHICLE, v->tile, v->index | (_ctrl_pressed ? 1 : 0) << 20, wagon == nullptr ? INVALID_VEHICLE : wagon->index);
 
}
 

	
 
static VehicleCellSize _base_block_sizes_depot[VEH_COMPANY_END];    ///< Cell size for vehicle images in the depot view.
 
@@ -836,7 +836,7 @@ struct DepotWindow : Window {
 
		if (str == nullptr) return;
 

	
 
		/* Do depot renaming */
 
		DoCommandP(CMD_RENAME_DEPOT | CMD_MSG(STR_ERROR_CAN_T_RENAME_DEPOT), 0, this->GetDepotIndex(), 0, str);
 
		DoCommandP(CMD_RENAME_DEPOT, STR_ERROR_CAN_T_RENAME_DEPOT, 0, this->GetDepotIndex(), 0, str);
 
	}
 

	
 
	bool OnRightClick(Point pt, int widget) override
 
@@ -904,10 +904,10 @@ struct DepotWindow : Window {
 
	{
 
		if (_ctrl_pressed) {
 
			/* Share-clone, do not open new viewport, and keep tool active */
 
			DoCommandP(CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), this->window_number, v->index, 1);
 
			DoCommandP(CMD_CLONE_VEHICLE, STR_ERROR_CAN_T_BUY_TRAIN + v->type, this->window_number, v->index, 1);
 
		} else {
 
			/* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to changs things on new vehicle) */
 
			if (DoCommandP(CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN + v->type), CcCloneVehicle, this->window_number, v->index, 0)) {
 
			if (DoCommandP(CMD_CLONE_VEHICLE, STR_ERROR_CAN_T_BUY_TRAIN + v->type, CcCloneVehicle, this->window_number, v->index, 0)) {
 
				ResetObjectToPlace();
 
			}
 
		}
 
@@ -1001,8 +1001,7 @@ struct DepotWindow : Window {
 

	
 
					if (this->GetVehicleFromDepotWndPt(pt.x - nwi->pos_x, pt.y - nwi->pos_y, &v, &gdvp) == MODE_DRAG_VEHICLE && sel != INVALID_VEHICLE) {
 
						if (gdvp.wagon != nullptr && gdvp.wagon->index == sel && _ctrl_pressed) {
 
							DoCommandP(CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE),
 
									Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true);
 
							DoCommandP(CMD_REVERSE_TRAIN_DIRECTION, STR_ERROR_CAN_T_REVERSE_DIRECTION_RAIL_VEHICLE, Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true);
 
						} else if (gdvp.wagon == nullptr || gdvp.wagon->index != sel) {
 
							this->vehicle_over = INVALID_VEHICLE;
 
							TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
 
@@ -1027,7 +1026,7 @@ struct DepotWindow : Window {
 
				this->SetDirty();
 

	
 
				int sell_cmd = (v->type == VEH_TRAIN && (widget == WID_D_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
 
				DoCommandP(GetCmdSellVeh(v->type), v->tile, v->index | sell_cmd << 20 | MAKE_ORDER_BACKUP_FLAG, 0);
 
				DoCommandP(CMD_SELL_VEHICLE, GetCmdSellVehMsg(v->type), v->tile, v->index | sell_cmd << 20 | MAKE_ORDER_BACKUP_FLAG, 0);
 
				break;
 
			}
 

	
src/dock_gui.cpp
Show inline comments
 
@@ -38,7 +38,7 @@ static void ShowBuildDocksDepotPicker(Wi
 

	
 
static Axis _ship_depot_direction;
 

	
 
void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -46,7 +46,7 @@ void CcBuildDocks(const CommandCost &res
 
	if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
 
}
 

	
 
void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile);
 
}
 
@@ -191,7 +191,7 @@ struct BuildDocksToolbarWindow : Window 
 
				break;
 

	
 
			case WID_DT_LOCK: // Build lock button
 
				DoCommandP(CMD_BUILD_LOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_LOCKS), CcBuildDocks, tile, 0, 0);
 
				DoCommandP(CMD_BUILD_LOCK, STR_ERROR_CAN_T_BUILD_LOCKS, CcBuildDocks, tile, 0, 0);
 
				break;
 

	
 
			case WID_DT_DEMOLISH: // Demolish aka dynamite button
 
@@ -199,14 +199,14 @@ struct BuildDocksToolbarWindow : Window 
 
				break;
 

	
 
			case WID_DT_DEPOT: // Build depot button
 
				DoCommandP(CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_SHIP_DEPOT), CcBuildDocks, tile, _ship_depot_direction, 0);
 
				DoCommandP(CMD_BUILD_SHIP_DEPOT, STR_ERROR_CAN_T_BUILD_SHIP_DEPOT, CcBuildDocks, tile, _ship_depot_direction, 0);
 
				break;
 

	
 
			case WID_DT_STATION: { // Build station button
 
				uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join
 

	
 
				/* tile is always the land tile, so need to evaluate _thd.pos */
 
				CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks, "" };
 
				CommandContainer cmdcont = { tile, _ctrl_pressed, p2, CMD_BUILD_DOCK, STR_ERROR_CAN_T_BUILD_DOCK_HERE, CcBuildDocks, "" };
 

	
 
				/* Determine the watery part of the dock. */
 
				DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
 
@@ -217,7 +217,7 @@ struct BuildDocksToolbarWindow : Window 
 
			}
 

	
 
			case WID_DT_BUOY: // Build buoy button
 
				DoCommandP(CMD_BUILD_BUOY | CMD_MSG(STR_ERROR_CAN_T_POSITION_BUOY_HERE), CcBuildDocks, tile, 0, 0);
 
				DoCommandP(CMD_BUILD_BUOY, STR_ERROR_CAN_T_POSITION_BUOY_HERE, CcBuildDocks, tile, 0, 0);
 
				break;
 

	
 
			case WID_DT_RIVER: // Build river button (in scenario editor)
 
@@ -225,7 +225,7 @@ struct BuildDocksToolbarWindow : Window 
 
				break;
 

	
 
			case WID_DT_BUILD_AQUEDUCT: // Build aqueduct button
 
				DoCommandP(CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER << 15);
 
				DoCommandP(CMD_BUILD_BRIDGE, STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE, CcBuildBridge, tile, GetOtherAqueductEnd(tile), TRANSPORT_WATER << 15);
 
				break;
 

	
 
			default: NOT_REACHED();
 
@@ -245,10 +245,10 @@ struct BuildDocksToolbarWindow : Window 
 
					GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
 
					break;
 
				case DDSP_CREATE_WATER:
 
					DoCommandP(CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_BUILD_CANALS), CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
 
					DoCommandP(CMD_BUILD_CANAL, STR_ERROR_CAN_T_BUILD_CANALS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, (_game_mode == GM_EDITOR && _ctrl_pressed) ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
 
					break;
 
				case DDSP_CREATE_RIVER:
 
					DoCommandP(CMD_BUILD_CANAL | CMD_MSG(STR_ERROR_CAN_T_PLACE_RIVERS), CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER | (_ctrl_pressed ? 1 << 2 : 0));
 
					DoCommandP(CMD_BUILD_CANAL, STR_ERROR_CAN_T_PLACE_RIVERS, CcPlaySound_CONSTRUCTION_WATER, end_tile, start_tile, WATER_CLASS_RIVER | (_ctrl_pressed ? 1 << 2 : 0));
 
					break;
 

	
 
				default: break;
src/economy.cpp
Show inline comments
 
@@ -1485,7 +1485,7 @@ static void HandleStationRefit(Vehicle *
 
			if (st->goods[cid].cargo.HasCargoFor(next_station)) {
 
				/* Try to find out if auto-refitting would succeed. In case the refit is allowed,
 
				 * the returned refit capacity will be greater than zero. */
 
				DoCommand(DC_QUERY_COST, GetCmdRefitVeh(v_start), v_start->tile, v_start->index, cid | 1U << 24 | 0xFF << 8 | 1U << 16); // Auto-refit and only this vehicle including artic parts.
 
				DoCommand(DC_QUERY_COST, CMD_REFIT_VEHICLE, v_start->tile, v_start->index, cid | 1U << 24 | 0xFF << 8 | 1U << 16); // Auto-refit and only this vehicle including artic parts.
 
				/* Try to balance different loadable cargoes between parts of the consist, so that
 
				 * all of them can be loaded. Avoid a situation where all vehicles suddenly switch
 
				 * to the first loadable cargo for which there is only one packet. If the capacities
 
@@ -1508,7 +1508,7 @@ static void HandleStationRefit(Vehicle *
 
		 * "via any station" before reserving. We rather produce some more "any station" cargo than
 
		 * misrouting it. */
 
		IterateVehicleParts(v_start, ReturnCargoAction(st, INVALID_STATION));
 
		CommandCost cost = DoCommand(DC_EXEC, GetCmdRefitVeh(v_start), v_start->tile, v_start->index, new_cid | 1U << 24 | 0xFF << 8 | 1U << 16); // Auto-refit and only this vehicle including artic parts.
 
		CommandCost cost = DoCommand(DC_EXEC, CMD_REFIT_VEHICLE, v_start->tile, v_start->index, new_cid | 1U << 24 | 0xFF << 8 | 1U << 16); // Auto-refit and only this vehicle including artic parts.
 
		if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
 
	}
 

	
src/game/game_instance.cpp
Show inline comments
 
@@ -87,7 +87,7 @@ void GameInstance::Died()
 
 * @param p2 p2 as given to DoCommandPInternal.
 
 * @param cmd cmd as given to DoCommandPInternal.
 
 */
 
void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (Game::GetGameInstance()->DoCommandCallback(result, tile, p1, p2, cmd)) {
 
		Game::GetGameInstance()->Continue();
src/group_gui.cpp
Show inline comments
 
@@ -640,7 +640,7 @@ public:
 
		if (confirmed) {
 
			VehicleGroupWindow *w = (VehicleGroupWindow*)win;
 
			w->vli.index = ALL_GROUP;
 
			DoCommandP(CMD_DELETE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_DELETE), 0, w->group_confirm, 0);
 
			DoCommandP(CMD_DELETE_GROUP, STR_ERROR_GROUP_CAN_T_DELETE, 0, w->group_confirm, 0);
 
		}
 
	}
 

	
 
@@ -771,7 +771,7 @@ public:
 
			}
 

	
 
			case WID_GL_CREATE_GROUP: { // Create a new group
 
				DoCommandP(CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup, 0, this->vli.vtype, this->vli.index);
 
				DoCommandP(CMD_CREATE_GROUP, STR_ERROR_GROUP_CAN_T_CREATE, CcCreateGroup, 0, this->vli.vtype, this->vli.index);
 
				break;
 
			}
 

	
 
@@ -822,7 +822,7 @@ public:
 
			case WID_GL_ALL_VEHICLES: // All vehicles
 
			case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
 
				if (g->parent != INVALID_GROUP) {
 
					DoCommandP(CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT), 0, this->group_sel | (1 << 16), INVALID_GROUP);
 
					DoCommandP(CMD_ALTER_GROUP, STR_ERROR_GROUP_CAN_T_SET_PARENT, 0, this->group_sel | (1 << 16), INVALID_GROUP);
 
				}
 

	
 
				this->group_sel = INVALID_GROUP;
 
@@ -835,7 +835,7 @@ public:
 
				GroupID new_g = id_g >= this->groups.size() ? INVALID_GROUP : this->groups[id_g]->index;
 

	
 
				if (this->group_sel != new_g && g->parent != new_g) {
 
					DoCommandP(CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_SET_PARENT), 0, this->group_sel | (1 << 16), new_g);
 
					DoCommandP(CMD_ALTER_GROUP, STR_ERROR_GROUP_CAN_T_SET_PARENT, 0, this->group_sel | (1 << 16), new_g);
 
				}
 

	
 
				this->group_sel = INVALID_GROUP;
 
@@ -850,7 +850,7 @@ public:
 
	{
 
		switch (widget) {
 
			case WID_GL_DEFAULT_VEHICLES: // Ungrouped vehicles
 
				DoCommandP(CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), 0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0));
 
				DoCommandP(CMD_ADD_VEHICLE_GROUP, STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, 0, DEFAULT_GROUP, this->vehicle_sel | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0));
 

	
 
				this->vehicle_sel = INVALID_VEHICLE;
 
				this->group_over = INVALID_GROUP;
 
@@ -867,7 +867,7 @@ public:
 
				uint id_g = this->group_sb->GetScrolledRowFromWidget(pt.y, this, WID_GL_LIST_GROUP);
 
				GroupID new_g = id_g >= this->groups.size() ? NEW_GROUP : this->groups[id_g]->index;
 

	
 
				DoCommandP(CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_VEHICLE), new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, 0, new_g, vindex | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0));
 
				DoCommandP(CMD_ADD_VEHICLE_GROUP, STR_ERROR_GROUP_CAN_T_ADD_VEHICLE, new_g == NEW_GROUP ? CcAddVehicleNewGroup : nullptr, 0, new_g, vindex | (_ctrl_pressed || this->grouping == GB_SHARED_ORDERS ? 1 << 31 : 0));
 
				break;
 
			}
 

	
 
@@ -922,7 +922,7 @@ public:
 

	
 
	void OnQueryTextFinished(char *str) override
 
	{
 
		if (str != nullptr) DoCommandP(CMD_ALTER_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_RENAME), 0, this->group_rename, 0, str);
 
		if (str != nullptr) DoCommandP(CMD_ALTER_GROUP, STR_ERROR_GROUP_CAN_T_RENAME, 0, this->group_rename, 0, str);
 
		this->group_rename = INVALID_GROUP;
 
	}
 

	
 
@@ -952,19 +952,19 @@ public:
 
						break;
 
					case ADI_SERVICE: // Send for servicing
 
					case ADI_DEPOT: { // Send to Depots
 
						DoCommandP(GetCmdSendToDepot(this->vli.vtype), 0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : 0U), this->vli.Pack());
 
						DoCommandP(CMD_SEND_VEHICLE_TO_DEPOT, GetCmdSendToDepotMsg(this->vli.vtype), 0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : 0U), this->vli.Pack());
 
						break;
 
					}
 

	
 
					case ADI_ADD_SHARED: // Add shared Vehicles
 
						assert(Group::IsValidID(this->vli.index));
 

	
 
						DoCommandP(CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE), 0, this->vli.index, this->vli.vtype);
 
						DoCommandP(CMD_ADD_SHARED_VEHICLE_GROUP, STR_ERROR_GROUP_CAN_T_ADD_SHARED_VEHICLE, 0, this->vli.index, this->vli.vtype);
 
						break;
 
					case ADI_REMOVE_ALL: // Remove all Vehicles from the selected group
 
						assert(Group::IsValidID(this->vli.index));
 

	
 
						DoCommandP(CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES), 0, this->vli.index, 0);
 
						DoCommandP(CMD_REMOVE_ALL_VEHICLES_GROUP, STR_ERROR_GROUP_CAN_T_REMOVE_ALL_VEHICLES, 0, this->vli.index, 0);
 
						break;
 
					default: NOT_REACHED();
 
				}
 
@@ -1146,7 +1146,7 @@ static inline VehicleGroupWindow *FindVe
 
 * @param cmd Unused.
 
 * @see CmdCreateGroup
 
 */
 
void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 
	assert(p1 <= VEH_AIRCRAFT);
 
@@ -1163,7 +1163,7 @@ void CcCreateGroup(const CommandCost &re
 
 * @param p2 Bit 0-19: Vehicle ID.
 
 * @param cmd Unused.
 
 */
 
void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 
	assert(Vehicle::IsValidID(GB(p2, 0, 20)));
src/industry_gui.cpp
Show inline comments
 
@@ -224,7 +224,7 @@ void SortIndustryTypes()
 
 * @param p2     Additional data of the #CMD_BUILD_INDUSTRY command.
 
 * @param cmd    Unused.
 
 */
 
void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded()) return;
 

	
 
@@ -678,7 +678,7 @@ public:
 
			case WID_DPI_FUND_WIDGET: {
 
				if (this->selected_type != INVALID_INDUSTRYTYPE) {
 
					if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
 
						DoCommandP(CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), 0, this->selected_type, InteractiveRandom());
 
						DoCommandP(CMD_BUILD_INDUSTRY, STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, 0, this->selected_type, InteractiveRandom());
 
						this->HandleButtonClick(WID_DPI_FUND_WIDGET);
 
					} else {
 
						HandlePlacePushButton(this, WID_DPI_FUND_WIDGET, SPR_CURSOR_INDUSTRY, HT_RECT);
 
@@ -715,13 +715,13 @@ public:
 
			Backup<bool> old_generating_world(_generating_world, true, FILE_LINE);
 
			_ignore_restrictions = true;
 

	
 
			DoCommandP(CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), &CcBuildIndustry, tile, (layout_index << 8) | this->selected_type, seed);
 
			DoCommandP(CMD_BUILD_INDUSTRY, STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, &CcBuildIndustry, tile, (layout_index << 8) | this->selected_type, seed);
 

	
 
			cur_company.Restore();
 
			old_generating_world.Restore();
 
			_ignore_restrictions = false;
 
		} else {
 
			success = DoCommandP(CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY), tile, (layout_index << 8) | this->selected_type, seed);
 
			success = DoCommandP(CMD_BUILD_INDUSTRY, STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY, tile, (layout_index << 8) | this->selected_type, seed);
 
		}
 

	
 
		/* If an industry has been built, just reset the cursor and the system */
src/main_gui.cpp
Show inline comments
 
@@ -76,7 +76,7 @@ bool HandlePlacePushButton(Window *w, in
 
}
 

	
 

	
 
void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile);
 
}
src/network/network.cpp
Show inline comments
 
@@ -1064,7 +1064,7 @@ void NetworkGameLoop()
 
		while (f != nullptr && !feof(f)) {
 
			if (_date == next_date && _date_fract == next_date_fract) {
 
				if (cp != nullptr) {
 
					NetworkSendCommand(cp->cmd & ~CMD_FLAGS_MASK, nullptr, cp->company, cp->tile, cp->p1, cp->p2, cp->text);
 
					NetworkSendCommand(cp->cmd, cp->err_msg, nullptr, cp->company, cp->tile, cp->p1, cp->p2, cp->text);
 
					Debug(desync, 0, "Injecting: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text, GetCommandName(cp->cmd));
 
					delete cp;
 
					cp = nullptr;
 
@@ -1103,14 +1103,16 @@ void NetworkGameLoop()
 
				if (*p == ' ') p++;
 
				cp = new CommandPacket();
 
				int company;
 
				uint cmd;
 
				char buffer[128];
 
				int ret = sscanf(p, "%x; %x; %x; %x; %x; %x; %x; \"%127[^\"]\"", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cp->cmd, buffer);
 
				int ret = sscanf(p, "%x; %x; %x; %x; %x; %x; %x; %x; \"%127[^\"]\"", &next_date, &next_date_fract, &company, &cp->tile, &cp->p1, &cp->p2, &cmd, &cp->err_msg, buffer);
 
				cp->text = buffer;
 
				/* There are 8 pieces of data to read, however the last is a
 
				 * string that might or might not exist. Ignore it if that
 
				 * string misses because in 99% of the time it's not used. */
 
				assert(ret == 8 || ret == 7);
 
				assert(ret == 9 || ret == 8);
 
				cp->company = (CompanyID)company;
 
				cp->cmd = (Commands)cmd;
 
			} else if (strncmp(p, "join: ", 6) == 0) {
 
				/* Manually insert a pause when joining; this way the client can join at the exact right time. */
 
				int ret = sscanf(p + 6, "%x; %x", &next_date, &next_date_fract);
src/network/network_admin.cpp
Show inline comments
 
@@ -593,8 +593,8 @@ NetworkRecvStatus ServerNetworkAdminSock
 
{
 
	Packet *p = new Packet(ADMIN_PACKET_SERVER_CMD_NAMES);
 

	
 
	for (uint i = 0; i < CMD_END; i++) {
 
		const char *cmdname = GetCommandName(i);
 
	for (uint16 i = 0; i < CMD_END; i++) {
 
		const char *cmdname = GetCommandName(static_cast<Commands>(i));
 

	
 
		/* Should COMPAT_MTU be exceeded, start a new packet
 
		 * (magic 5: 1 bool "more data" and one uint16 "command id", one
 
@@ -629,7 +629,7 @@ NetworkRecvStatus ServerNetworkAdminSock
 

	
 
	p->Send_uint32(client_id);
 
	p->Send_uint8 (cp->company);
 
	p->Send_uint16(cp->cmd & CMD_ID_MASK);
 
	p->Send_uint16(cp->cmd);
 
	p->Send_uint32(cp->p1);
 
	p->Send_uint32(cp->p2);
 
	p->Send_uint32(cp->tile);
src/network/network_client.cpp
Show inline comments
 
@@ -839,7 +839,7 @@ NetworkRecvStatus ClientNetworkGameSocke
 
			 * the server will give us a client-id and let us in */
 
			_network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
 
			ShowJoinStatusWindow();
 
			NetworkSendCommand(CMD_COMPANY_CTRL, nullptr, _local_company, 0, CCA_NEW, 0, {});
 
			NetworkSendCommand(CMD_COMPANY_CTRL, STR_NULL, nullptr, _local_company, 0, CCA_NEW, 0, {});
 
		}
 
	} else {
 
		/* take control over an existing company */
src/network/network_command.cpp
Show inline comments
 
@@ -126,6 +126,7 @@ static CommandQueue _local_execution_que
 
/**
 
 * Prepare a DoCommand to be send over the network
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param err_message Message prefix to show on error
 
 * @param callback A callback function to call after the command is finished
 
 * @param company The company that wants to send the command
 
 * @param tile The tile to perform a command on (see #CommandProc)
 
@@ -133,16 +134,15 @@ static CommandQueue _local_execution_que
 
 * @param p2 Additional data for the command (see #CommandProc)
 
 * @param text The text to pass
 
 */
 
void NetworkSendCommand(uint32 cmd, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	assert((cmd & CMD_FLAGS_MASK) == 0);
 

	
 
	CommandPacket c;
 
	c.company  = company;
 
	c.tile     = tile;
 
	c.p1       = p1;
 
	c.p2       = p2;
 
	c.cmd      = cmd;
 
	c.err_msg  = err_message;
 
	c.callback = callback;
 
	c.text     = text;
 

	
 
@@ -207,8 +207,7 @@ void NetworkExecuteLocalCommandQueue()
 

	
 
		/* We can execute this command */
 
		_current_company = cp->company;
 
		cp->cmd |= CMD_NETWORK_COMMAND;
 
		DoCommandP(cp, cp->my_cmd);
 
		DoCommandP(cp, cp->my_cmd, true);
 

	
 
		queue.Pop();
 
		delete cp;
 
@@ -295,10 +294,10 @@ void NetworkDistributeCommands()
 
const char *NetworkGameSocketHandler::ReceiveCommand(Packet *p, CommandPacket *cp)
 
{
 
	cp->company = (CompanyID)p->Recv_uint8();
 
	cp->cmd     = p->Recv_uint32();
 
	cp->cmd     = static_cast<Commands>(p->Recv_uint16());
 
	if (!IsValidCommand(cp->cmd))               return "invalid command";
 
	if (GetCommandFlags(cp->cmd) & CMD_OFFLINE) return "single-player only command";
 
	if ((cp->cmd & CMD_FLAGS_MASK) != 0)        return "invalid command flag";
 
	cp->err_msg = p->Recv_uint16();
 

	
 
	cp->p1      = p->Recv_uint32();
 
	cp->p2      = p->Recv_uint32();
 
@@ -320,7 +319,8 @@ const char *NetworkGameSocketHandler::Re
 
void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp)
 
{
 
	p->Send_uint8 (cp->company);
 
	p->Send_uint32(cp->cmd);
 
	p->Send_uint16(cp->cmd);
 
	p->Send_uint16(cp->err_msg);
 
	p->Send_uint32(cp->p1);
 
	p->Send_uint32(cp->p2);
 
	p->Send_uint32(cp->tile);
src/network/network_gui.cpp
Show inline comments
 
@@ -1537,7 +1537,7 @@ private:
 
		if (_network_server) {
 
			DoCommandP(CMD_COMPANY_CTRL, 0, CCA_NEW, _network_own_client_id);
 
		} else {
 
			NetworkSendCommand(CMD_COMPANY_CTRL, nullptr, _local_company, 0, CCA_NEW, 0, {});
 
			NetworkSendCommand(CMD_COMPANY_CTRL, STR_NULL, nullptr, _local_company, 0, CCA_NEW, 0, {});
 
		}
 
	}
 

	
src/network/network_server.cpp
Show inline comments
 
@@ -1034,12 +1034,12 @@ NetworkRecvStatus ServerNetworkGameSocke
 

	
 

	
 
	if ((GetCommandFlags(cp.cmd) & CMD_SERVER) && ci->client_id != CLIENT_ID_SERVER) {
 
		IConsolePrint(CC_WARNING, "Kicking client #{} (IP: {}) due to calling a server only command {}.", ci->client_id, this->GetClientIP(), cp.cmd & CMD_ID_MASK);
 
		IConsolePrint(CC_WARNING, "Kicking client #{} (IP: {}) due to calling a server only command {}.", ci->client_id, this->GetClientIP(), cp.cmd);
 
		return this->SendError(NETWORK_ERROR_KICKED);
 
	}
 

	
 
	if ((GetCommandFlags(cp.cmd) & CMD_SPECTATOR) == 0 && !Company::IsValidID(cp.company) && ci->client_id != CLIENT_ID_SERVER) {
 
		IConsolePrint(CC_WARNING, "Kicking client #{} (IP: {}) due to calling a non-spectator command {}.", ci->client_id, this->GetClientIP(), cp.cmd & CMD_ID_MASK);
 
		IConsolePrint(CC_WARNING, "Kicking client #{} (IP: {}) due to calling a non-spectator command {}.", ci->client_id, this->GetClientIP(), cp.cmd);
 
		return this->SendError(NETWORK_ERROR_KICKED);
 
	}
 

	
 
@@ -2078,7 +2078,7 @@ void NetworkServerNewCompany(const Compa
 
		/* ci is nullptr when replaying, or for AIs. In neither case there is a client. */
 
		ci->client_playas = c->index;
 
		NetworkUpdateClientInfo(ci->client_id);
 
		NetworkSendCommand(CMD_RENAME_PRESIDENT, nullptr, c->index, 0, 0, 0, ci->client_name);
 
		NetworkSendCommand(CMD_RENAME_PRESIDENT, STR_NULL, nullptr, c->index, 0, 0, 0, ci->client_name);
 
	}
 

	
 
	/* Announce new company on network. */
src/object_gui.cpp
Show inline comments
 
@@ -541,7 +541,7 @@ public:
 
	void OnPlaceObject(Point pt, TileIndex tile) override
 
	{
 
		ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
 
		DoCommandP(CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_OBJECT), CcTerraform,
 
		DoCommandP(CMD_BUILD_OBJECT, STR_ERROR_CAN_T_BUILD_OBJECT, CcTerraform,
 
				tile, objclass->GetSpec(_selected_object_index)->Index(), _selected_object_view);
 
	}
 

	
src/order_backup.cpp
Show inline comments
 
@@ -198,7 +198,7 @@ CommandCost CmdClearOrderBackup(TileInde
 
			/* We need to circumvent the "prevention" from this command being executed
 
			 * while the game is paused, so use the internal method. Nor do we want
 
			 * this command to get its cost estimated when shift is pressed. */
 
			DoCommandPInternal(CMD_CLEAR_ORDER_BACKUP, nullptr, true, false, ob->tile, 0, user, {});
 
			DoCommandPInternal(CMD_CLEAR_ORDER_BACKUP, STR_NULL, nullptr, true, false, false, ob->tile, 0, user, {});
 
		} else {
 
			/* The command came from the game logic, i.e. the clearing of a tile.
 
			 * In that case we have no need to actually sync this, just do it. */
src/order_gui.cpp
Show inline comments
 
@@ -591,7 +591,7 @@ private:
 
		}
 
		if (order->GetLoadType() == load_type) return; // If we still match, do nothing
 

	
 
		DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4));
 
		DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_LOAD | (load_type << 4));
 
	}
 

	
 
	/**
 
@@ -606,7 +606,7 @@ private:
 
			if (order == nullptr) return;
 
			i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
 
		}
 
		DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4));
 
		DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_DEPOT_ACTION | (i << 4));
 
	}
 

	
 
	/**
 
@@ -621,7 +621,7 @@ private:
 
				_settings_client.gui.new_nonstop && this->vehicle->IsGroundVehicle() ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
		order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
 

	
 
		DoCommandP(CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack());
 
		DoCommandP(CMD_INSERT_ORDER, STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack());
 
	}
 

	
 
	/**
 
@@ -641,7 +641,7 @@ private:
 
		}
 
		if (order->GetUnloadType() == unload_type) return; // If we still match, do nothing
 

	
 
		DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4));
 
		DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_UNLOAD | (unload_type << 4));
 

	
 
		/* Transfer and unload orders with leave empty as default */
 
		if (unload_type == OUFB_TRANSFER || unload_type == OUFB_UNLOAD) {
 
@@ -669,7 +669,7 @@ private:
 
		}
 

	
 
		this->SetWidgetDirty(WID_O_NON_STOP);
 
		DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_NON_STOP | non_stop << 4);
 
		DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index + (sel_ord << 20), MOF_NON_STOP | non_stop << 4);
 
	}
 

	
 
	/**
 
@@ -682,7 +682,7 @@ private:
 
		if (_ctrl_pressed && this->vehicle->cur_implicit_order_index == this->OrderGetSel()) return;
 
		if (this->vehicle->GetNumOrders() <= 1) return;
 

	
 
		DoCommandP(CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER),
 
		DoCommandP(CMD_SKIP_TO_ORDER, _ctrl_pressed ? STR_ERROR_CAN_T_SKIP_TO_ORDER : STR_ERROR_CAN_T_SKIP_ORDER,
 
				this->vehicle->tile, this->vehicle->index, _ctrl_pressed ? this->OrderGetSel() : ((this->vehicle->cur_implicit_order_index + 1) % this->vehicle->GetNumOrders()));
 
	}
 

	
 
@@ -694,7 +694,7 @@ private:
 
		/* When networking, move one order lower */
 
		int selected = this->selected_order + (int)_networking;
 

	
 
		if (DoCommandP(CMD_DELETE_ORDER | CMD_MSG(STR_ERROR_CAN_T_DELETE_THIS_ORDER), this->vehicle->tile, this->vehicle->index, this->OrderGetSel())) {
 
		if (DoCommandP(CMD_DELETE_ORDER, STR_ERROR_CAN_T_DELETE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, this->OrderGetSel())) {
 
			this->selected_order = selected >= this->vehicle->GetNumOrders() ? -1 : selected;
 
			this->UpdateButtonState();
 
		}
 
@@ -719,7 +719,7 @@ private:
 
		/* Get another vehicle that share orders with this vehicle. */
 
		Vehicle *other_shared = (this->vehicle->FirstShared() == this->vehicle) ? this->vehicle->NextShared() : this->vehicle->PreviousShared();
 
		/* Copy the order list of the other vehicle. */
 
		if (DoCommandP(CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST), this->vehicle->tile, this->vehicle->index | CO_COPY << 30, other_shared->index)) {
 
		if (DoCommandP(CMD_CLONE_ORDER, STR_ERROR_CAN_T_STOP_SHARING_ORDER_LIST, this->vehicle->tile, this->vehicle->index | CO_COPY << 30, other_shared->index)) {
 
			this->UpdateButtonState();
 
		}
 
	}
 
@@ -1159,7 +1159,7 @@ public:
 
						order.index = 0;
 
						order.MakeConditional(order_id);
 

	
 
						DoCommandP(CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack());
 
						DoCommandP(CMD_INSERT_ORDER, STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), order.Pack());
 
					}
 
					ResetObjectToPlace();
 
					break;
 
@@ -1182,7 +1182,7 @@ public:
 
					this->selected_order = -1;
 
				} else if (sel == this->selected_order) {
 
					if (this->vehicle->type == VEH_TRAIN && sel < this->vehicle->GetNumOrders()) {
 
						DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER),
 
						DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER,
 
								this->vehicle->tile, this->vehicle->index + (sel << 20),
 
								MOF_STOP_LOCATION | ((this->vehicle->GetOrder(sel)->GetStopLocation() + 1) % OSL_END) << 4);
 
					}
 
@@ -1331,7 +1331,7 @@ public:
 
				default:
 
					break;
 
			}
 
			DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (sel << 20), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4);
 
			DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index + (sel << 20), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4);
 
		}
 
	}
 

	
 
@@ -1369,11 +1369,11 @@ public:
 
				break;
 

	
 
			case WID_O_COND_VARIABLE:
 
				DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4);
 
				DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_VARIABLE | index << 4);
 
				break;
 

	
 
			case WID_O_COND_COMPARATOR:
 
				DoCommandP(CMD_MODIFY_ORDER | CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_COMPARATOR | index << 4);
 
				DoCommandP(CMD_MODIFY_ORDER, STR_ERROR_CAN_T_MODIFY_THIS_ORDER, this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), MOF_COND_COMPARATOR | index << 4);
 
				break;
 
		}
 
	}
 
@@ -1386,7 +1386,7 @@ public:
 
				VehicleOrderID to_order = this->GetOrderFromPt(pt.y);
 

	
 
				if (!(from_order == to_order || from_order == INVALID_VEH_ORDER_ID || from_order > this->vehicle->GetNumOrders() || to_order == INVALID_VEH_ORDER_ID || to_order > this->vehicle->GetNumOrders()) &&
 
						DoCommandP(CMD_MOVE_ORDER | CMD_MSG(STR_ERROR_CAN_T_MOVE_THIS_ORDER), this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16))) {
 
						DoCommandP(CMD_MOVE_ORDER, STR_ERROR_CAN_T_MOVE_THIS_ORDER, this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16))) {
 
					this->selected_order = -1;
 
					this->UpdateButtonState();
 
				}
 
@@ -1438,7 +1438,7 @@ public:
 
			const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
 
			if (cmd.IsType(OT_NOTHING)) return;
 

	
 
			if (DoCommandP(CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack())) {
 
			if (DoCommandP(CMD_INSERT_ORDER, STR_ERROR_CAN_T_INSERT_NEW_ORDER, this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 20), cmd.Pack())) {
 
				/* With quick goto the Go To button stays active */
 
				if (!_settings_client.gui.quick_goto) ResetObjectToPlace();
 
			}
 
@@ -1455,7 +1455,7 @@ public:
 
		bool share_order = _ctrl_pressed || this->goto_type == OPOS_SHARE;
 
		if (this->vehicle->GetNumOrders() != 0 && !share_order) return false;
 

	
 
		if (DoCommandP(share_order ? CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_ERROR_CAN_T_COPY_ORDER_LIST),
 
		if (DoCommandP(CMD_CLONE_ORDER, share_order ? STR_ERROR_CAN_T_SHARE_ORDER_LIST : STR_ERROR_CAN_T_COPY_ORDER_LIST,
 
				this->vehicle->tile, this->vehicle->index | (share_order ? CO_SHARE : CO_COPY) << 30, v->index)) {
 
			this->selected_order = -1;
 
			ResetObjectToPlace();
src/rail_gui.cpp
Show inline comments
 
@@ -85,16 +85,15 @@ static bool IsStationAvailable(const Sta
 
	return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
 
}
 

	
 
void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
 
}
 

	
 
static void GenericPlaceRail(TileIndex tile, int cmd)
 
{
 
	DoCommandP(_remove_button_clicked ?
 
			CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
 
			CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
 
	DoCommandP(_remove_button_clicked ? CMD_REMOVE_SINGLE_RAIL : CMD_BUILD_SINGLE_RAIL,
 
			_remove_button_clicked ? STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK : STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK,
 
			CcPlaySound_CONSTRUCTION_RAIL,
 
			tile, _cur_railtype, cmd | (_settings_client.gui.auto_remove_signals << 3));
 
}
 
@@ -129,7 +128,7 @@ static const DiagDirection _place_depot_
 
	DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
 
};
 

	
 
void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -166,11 +165,11 @@ static void PlaceRail_Waypoint(TileIndex
 
	} else {
 
		/* Tile where we can't build rail waypoints. This is always going to fail,
 
		 * but provides the user with a proper error message. */
 
		DoCommandP(CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), tile, 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16);
 
		DoCommandP(CMD_BUILD_RAIL_WAYPOINT, STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT, tile, 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16);
 
	}
 
}
 

	
 
void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -199,7 +198,7 @@ static void PlaceRail_Station(TileIndex 
 
		int h = _settings_client.gui.station_platlength;
 
		if (!_railstation.orientation) Swap(w, h);
 

	
 
		CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
 
		CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAIL_STATION, STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, "" };
 
		ShowSelectStationIfNeeded(cmdcont, TileArea(tile, w, h));
 
	}
 
}
 
@@ -224,7 +223,7 @@ static void GenericPlaceSignals(TileInde
 
	Track track = FindFirstTrack(trackbits);
 

	
 
	if (_remove_button_clicked) {
 
		DoCommandP(CMD_REMOVE_SIGNALS | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound_CONSTRUCTION_RAIL,  tile, track, 0);
 
		DoCommandP(CMD_REMOVE_SIGNALS, STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL,  tile, track, 0);
 
	} else {
 
		const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
 

	
 
@@ -255,7 +254,7 @@ static void GenericPlaceSignals(TileInde
 
			SB(p1, 9, 6, cycle_types);
 
		}
 

	
 
		DoCommandP(CMD_BUILD_SIGNALS | CMD_MSG((w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
 
		DoCommandP(CMD_BUILD_SIGNALS, (w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE,
 
				CcPlaySound_CONSTRUCTION_RAIL, tile, p1, 0);
 
	}
 
}
 
@@ -277,7 +276,7 @@ static void PlaceRail_Bridge(TileIndex t
 
}
 

	
 
/** Command callback for building a tunnel */
 
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded()) {
 
		if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
 
@@ -358,9 +357,8 @@ static void BuildRailClick_Remove(Window
 
static void DoRailroadTrack(int mode)
 
{
 
	uint32 p2 = _cur_railtype | (mode << 6) | (_settings_client.gui.auto_remove_signals << 11);
 
	DoCommandP(_remove_button_clicked ?
 
			CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
 
			CMD_BUILD_RAILROAD_TRACK  | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
 
	DoCommandP(_remove_button_clicked ? CMD_REMOVE_RAILROAD_TRACK : CMD_BUILD_RAILROAD_TRACK,
 
			_remove_button_clicked ? STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK : STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK,
 
			CcPlaySound_CONSTRUCTION_RAIL,
 
			TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2);
 
}
 
@@ -413,9 +411,8 @@ static void HandleAutoSignalPlacement()
 

	
 
	/* _settings_client.gui.drag_signals_density is given as a parameter such that each user
 
	 * in a network game can specify their own signal density */
 
	DoCommandP(_remove_button_clicked ?
 
			CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM) :
 
			CMD_BUILD_SIGNAL_TRACK  | CMD_MSG(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
 
	DoCommandP(_remove_button_clicked ? CMD_REMOVE_SIGNAL_TRACK : CMD_BUILD_SIGNAL_TRACK,
 
			_remove_button_clicked ? STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE,
 
			CcPlaySound_CONSTRUCTION_RAIL,
 
			TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2);
 
}
 
@@ -643,7 +640,7 @@ struct BuildRailToolbarWindow : Window {
 
				break;
 

	
 
			case WID_RAT_BUILD_DEPOT:
 
				DoCommandP(CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT),
 
				DoCommandP(CMD_BUILD_TRAIN_DEPOT, STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT,
 
						CcRailDepot, tile, _cur_railtype, _build_depot_direction);
 
				break;
 

	
 
@@ -664,7 +661,7 @@ struct BuildRailToolbarWindow : Window {
 
				break;
 

	
 
			case WID_RAT_BUILD_TUNNEL:
 
				DoCommandP(CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel, tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0);
 
				DoCommandP(CMD_BUILD_TUNNEL, STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRailTunnel, tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0);
 
				break;
 

	
 
			case WID_RAT_CONVERT_RAIL:
 
@@ -706,7 +703,7 @@ struct BuildRailToolbarWindow : Window {
 
					break;
 

	
 
				case DDSP_CONVERT_RAIL:
 
					DoCommandP(CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 1 << 6 : 0));
 
					DoCommandP(CMD_CONVERT_RAIL, STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 1 << 6 : 0));
 
					break;
 

	
 
				case DDSP_REMOVE_STATION:
 
@@ -714,20 +711,20 @@ struct BuildRailToolbarWindow : Window {
 
					if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) {
 
						/* Station */
 
						if (_remove_button_clicked) {
 
							DoCommandP(CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _ctrl_pressed ? 0 : 1);
 
							DoCommandP(CMD_REMOVE_FROM_RAIL_STATION, STR_ERROR_CAN_T_REMOVE_PART_OF_STATION, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _ctrl_pressed ? 0 : 1);
 
						} else {
 
							HandleStationPlacement(start_tile, end_tile);
 
						}
 
					} else {
 
						/* Waypoint */
 
						if (_remove_button_clicked) {
 
							DoCommandP(CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _ctrl_pressed ? 0 : 1);
 
							DoCommandP(CMD_REMOVE_FROM_RAIL_WAYPOINT, STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _ctrl_pressed ? 0 : 1);
 
						} else {
 
							TileArea ta(start_tile, end_tile);
 
							uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24;
 
							uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16;
 

	
 
							CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL, "" };
 
							CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT, STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT, CcPlaySound_CONSTRUCTION_RAIL, "" };
 
							ShowSelectWaypointIfNeeded(cmdcont, ta);
 
						}
 
					}
 
@@ -886,7 +883,7 @@ static void HandleStationPlacement(TileI
 
	uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
 
	uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
 

	
 
	CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
 
	CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION, STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, "" };
 
	ShowSelectStationIfNeeded(cmdcont, ta);
 
}
 

	
src/road_gui.cpp
Show inline comments
 
@@ -66,7 +66,7 @@ static RoadType _cur_roadtype;
 
static DiagDirection _road_depot_orientation;
 
static DiagDirection _road_station_picker_orientation;
 

	
 
void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
 
}
 
@@ -96,7 +96,7 @@ static void PlaceRoad_Bridge(TileIndex t
 
 * @param p2 unused
 
 * @param cmd unused
 
 */
 
void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded()) {
 
		if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
 
@@ -129,7 +129,7 @@ void ConnectRoadToStructure(TileIndex ti
 
	}
 
}
 

	
 
void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -155,7 +155,7 @@ void CcRoadDepot(const CommandCost &resu
 
 * @param cmd Unused.
 
 * @see CmdBuildRoadStop
 
 */
 
void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -178,9 +178,10 @@ void CcRoadStop(const CommandCost &resul
 
 *           bit 2: Allow stations directly adjacent to other stations.
 
 *           bit 5..10: The roadtypes.
 
 * @param cmd Command to use.
 
 * @param err_msg Error message to show.
 
 * @see CcRoadStop()
 
 */
 
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 cmd)
 
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, Commands cmd, StringID err_msg)
 
{
 
	uint8 ddir = _road_station_picker_orientation;
 
	SB(p2, 16, 16, INVALID_STATION); // no station to join
 
@@ -192,7 +193,7 @@ static void PlaceRoadStop(TileIndex star
 
	p2 |= ddir << 3; // Set the DiagDirecion into p2 bits 3 and 4.
 

	
 
	TileArea ta(start_tile, end_tile);
 
	CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" };
 
	CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, err_msg, CcRoadStop, "" };
 
	ShowSelectStationIfNeeded(cmdcont, ta);
 
}
 

	
 
@@ -550,7 +551,7 @@ struct BuildRoadToolbarWindow : Window {
 
				break;
 

	
 
			case WID_ROT_DEPOT:
 
				DoCommandP(CMD_BUILD_ROAD_DEPOT | CMD_MSG(this->rti->strings.err_depot), CcRoadDepot,
 
				DoCommandP(CMD_BUILD_ROAD_DEPOT, this->rti->strings.err_depot, CcRoadDepot,
 
						tile, _cur_roadtype << 2 | _road_depot_orientation, 0);
 
				break;
 

	
 
@@ -567,7 +568,7 @@ struct BuildRoadToolbarWindow : Window {
 
				break;
 

	
 
			case WID_ROT_BUILD_TUNNEL:
 
				DoCommandP(CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel,
 
				DoCommandP(CMD_BUILD_TUNNEL, STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel,
 
						tile, _cur_roadtype | (TRANSPORT_ROAD << 8), 0);
 
				break;
 

	
 
@@ -669,9 +670,8 @@ struct BuildRoadToolbarWindow : Window {
 
					 * flags */
 
					_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
 

	
 
					DoCommandP(_remove_button_clicked ?
 
							CMD_REMOVE_LONG_ROAD | CMD_MSG(this->rti->strings.err_remove_road) :
 
							CMD_BUILD_LONG_ROAD | CMD_MSG(this->rti->strings.err_build_road), CcPlaySound_CONSTRUCTION_OTHER,
 
					DoCommandP(_remove_button_clicked ? CMD_REMOVE_LONG_ROAD : CMD_BUILD_LONG_ROAD,
 
							_remove_button_clicked ? this->rti->strings.err_remove_road : this->rti->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER,
 
							start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 10));
 
					break;
 

	
 
@@ -680,9 +680,9 @@ struct BuildRoadToolbarWindow : Window {
 
					if (this->IsWidgetLowered(WID_ROT_BUS_STATION)) {
 
						if (_remove_button_clicked) {
 
							TileArea ta(start_tile, end_tile);
 
							DoCommandP(CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_BUS]), CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS);
 
							DoCommandP(CMD_REMOVE_ROAD_STOP, this->rti->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS);
 
						} else {
 
							PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_BUS]));
 
							PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP, this->rti->strings.err_build_station[ROADSTOP_BUS]);
 
						}
 
					}
 
					break;
 
@@ -692,15 +692,15 @@ struct BuildRoadToolbarWindow : Window {
 
					if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION)) {
 
						if (_remove_button_clicked) {
 
							TileArea ta(start_tile, end_tile);
 
							DoCommandP(CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK);
 
							DoCommandP(CMD_REMOVE_ROAD_STOP, this->rti->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK);
 
						} else {
 
							PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_TRUCK]));
 
							PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP, this->rti->strings.err_build_station[ROADSTOP_TRUCK]);
 
						}
 
					}
 
					break;
 

	
 
				case DDSP_CONVERT_ROAD:
 
					DoCommandP(CMD_CONVERT_ROAD | CMD_MSG(rti->strings.err_convert_road), CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
 
					DoCommandP(CMD_CONVERT_ROAD, rti->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
 
					break;
 
			}
 
		}
src/script/api/script_object.cpp
Show inline comments
 
@@ -82,24 +82,24 @@ ScriptObject::ActiveInstance::~ActiveIns
 
	return GetStorage()->mode_instance;
 
}
 

	
 
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	ScriptStorage *s = GetStorage();
 
	Debug(script, 6, "SetLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
 
	s->last_tile = tile;
 
	s->last_p1 = p1;
 
	s->last_p2 = p2;
 
	s->last_cmd = cmd & CMD_ID_MASK;
 
	s->last_cmd = cmd;
 
}
 

	
 
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	ScriptStorage *s = GetStorage();
 
	Debug(script, 6, "CheckLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
 
	if (s->last_tile != tile) return false;
 
	if (s->last_p1 != p1) return false;
 
	if (s->last_p2 != p2) return false;
 
	if (s->last_cmd != (cmd & CMD_ID_MASK)) return false;
 
	if (s->last_cmd != cmd) return false;
 
	return true;
 
}
 

	
 
@@ -298,7 +298,7 @@ ScriptObject::ActiveInstance::~ActiveIns
 
	return GetStorage()->callback_value[index];
 
}
 

	
 
/* static */ bool ScriptObject::DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text, Script_SuspendCallbackProc *callback)
 
/* static */ bool ScriptObject::DoCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd, const char *text, Script_SuspendCallbackProc *callback)
 
{
 
	if (!ScriptObject::CanSuspend()) {
 
		throw Script_FatalError("You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator.");
 
@@ -329,7 +329,7 @@ ScriptObject::ActiveInstance::~ActiveIns
 
	if (!estimate_only && _networking && !_generating_world) SetLastCommand(tile, p1, p2, cmd);
 

	
 
	/* Try to perform the command. */
 
	CommandCost res = ::DoCommandPInternal(cmd, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : nullptr, false, estimate_only, tile, p1, p2, command_text);
 
	CommandCost res = ::DoCommandPInternal(cmd, STR_NULL, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : nullptr, false, estimate_only, false, tile, p1, p2, command_text);
 

	
 
	/* We failed; set the error and bail out */
 
	if (res.Failed()) {
src/script/api/script_object.hpp
Show inline comments
 
@@ -13,6 +13,7 @@
 
#include "../../misc/countedptr.hpp"
 
#include "../../road_type.h"
 
#include "../../rail_type.h"
 
#include "../../command_type.h"
 

	
 
#include "script_types.hpp"
 
#include "../script_suspend.hpp"
 
@@ -69,17 +70,17 @@ protected:
 
	/**
 
	 * Executes a raw DoCommand for the script.
 
	 */
 
	static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text = nullptr, Script_SuspendCallbackProc *callback = nullptr);
 
	static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd, const char *text = nullptr, Script_SuspendCallbackProc *callback = nullptr);
 

	
 
	/**
 
	 * Store the latest command executed by the script.
 
	 */
 
	static void SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd);
 
	static void SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
 

	
 
	/**
 
	 * Check if it's the latest command executed by the script.
 
	 */
 
	static bool CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd);
 
	static bool CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
 

	
 
	/**
 
	 * Sets the DoCommand costs counter to a value.
src/script/api/script_vehicle.cpp
Show inline comments
 
@@ -69,7 +69,7 @@
 

	
 
	EnforcePreconditionCustomError(VEHICLE_INVALID, !ScriptGameSettings::IsDisabledVehicleType((ScriptVehicle::VehicleType)type), ScriptVehicle::ERR_VEHICLE_BUILD_DISABLED);
 

	
 
	if (!ScriptObject::DoCommand(depot, engine_id | (cargo << 24), 0, ::GetCmdBuildVeh(type), nullptr, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
 
	if (!ScriptObject::DoCommand(depot, engine_id | (cargo << 24), 0, CMD_BUILD_VEHICLE, nullptr, &ScriptInstance::DoCommandReturnVehicleID)) return VEHICLE_INVALID;
 

	
 
	/* In case of test-mode, we return VehicleID 0 */
 
	return 0;
 
@@ -91,9 +91,7 @@
 
	if (!ScriptEngine::IsBuildable(engine_id)) return -1;
 
	if (!ScriptCargo::IsValidCargo(cargo)) return -1;
 

	
 
	::VehicleType type = ::Engine::Get(engine_id)->type;
 

	
 
	CommandCost res = ::DoCommand(DC_QUERY_COST, ::GetCmdBuildVeh(type), depot, engine_id | (cargo << 24), 0);
 
	CommandCost res = ::DoCommand(DC_QUERY_COST, CMD_BUILD_VEHICLE, depot, engine_id | (cargo << 24), 0);
 
	return res.Succeeded() ? _returned_refit_capacity : -1;
 
}
 

	
 
@@ -142,7 +140,7 @@
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 
	if (!ScriptCargo::IsValidCargo(cargo)) return -1;
 

	
 
	CommandCost res = ::DoCommand(DC_QUERY_COST, GetCmdRefitVeh(::Vehicle::Get(vehicle_id)), 0, vehicle_id, cargo);
 
	CommandCost res = ::DoCommand(DC_QUERY_COST, CMD_REFIT_VEHICLE, 0, vehicle_id, cargo);
 
	return res.Succeeded() ? _returned_refit_capacity : -1;
 
}
 

	
 
@@ -151,7 +149,7 @@
 
	EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id) && ScriptCargo::IsValidCargo(cargo));
 

	
 
	return ScriptObject::DoCommand(0, vehicle_id, cargo, GetCmdRefitVeh(::Vehicle::Get(vehicle_id)));
 
	return ScriptObject::DoCommand(0, vehicle_id, cargo, CMD_REFIT_VEHICLE);
 
}
 

	
 

	
 
@@ -161,7 +159,7 @@
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id));
 

	
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	return ScriptObject::DoCommand(0, vehicle_id | (v->type == VEH_TRAIN ? 1 : 0) << 20, 0, GetCmdSellVeh(v));
 
	return ScriptObject::DoCommand(0, vehicle_id | (v->type == VEH_TRAIN ? 1 : 0) << 20, 0, CMD_SELL_VEHICLE);
 
}
 

	
 
/* static */ bool ScriptVehicle::_SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons)
 
@@ -191,7 +189,7 @@
 
	EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id));
 

	
 
	return ScriptObject::DoCommand(0, vehicle_id, 0, GetCmdSendToDepot(::Vehicle::Get(vehicle_id)));
 
	return ScriptObject::DoCommand(0, vehicle_id, 0, CMD_SEND_VEHICLE_TO_DEPOT);
 
}
 

	
 
/* static */ bool ScriptVehicle::SendVehicleToDepotForServicing(VehicleID vehicle_id)
 
@@ -199,7 +197,7 @@
 
	EnforcePrecondition(false, ScriptObject::GetCompany() != OWNER_DEITY);
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id));
 

	
 
	return ScriptObject::DoCommand(0, vehicle_id | DEPOT_SERVICE, 0, GetCmdSendToDepot(::Vehicle::Get(vehicle_id)));
 
	return ScriptObject::DoCommand(0, vehicle_id | DEPOT_SERVICE, 0, CMD_SEND_VEHICLE_TO_DEPOT);
 
}
 

	
 
/* static */ bool ScriptVehicle::IsInDepot(VehicleID vehicle_id)
src/script/script_instance.cpp
Show inline comments
 
@@ -687,7 +687,7 @@ SQInteger ScriptInstance::GetOpsTillSusp
 
	return this->engine->GetOpsTillSuspend();
 
}
 

	
 
bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	ScriptObject::ActiveInstance active(this);
 

	
src/script/script_instance.hpp
Show inline comments
 
@@ -183,7 +183,7 @@ public:
 
	 * @param cmd cmd as given to DoCommandPInternal.
 
	 * @return true if we handled result.
 
	 */
 
	bool DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd);
 
	bool DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
 

	
 
	/**
 
	 * Insert an event for this script.
src/script/script_storage.hpp
Show inline comments
 
@@ -47,7 +47,7 @@ private:
 
	TileIndex last_tile;             ///< The last tile passed to a command.
 
	uint32 last_p1;                  ///< The last p1 passed to a command.
 
	uint32 last_p2;                  ///< The last p2 passed to a command.
 
	uint32 last_cmd;                 ///< The last cmd passed to a command.
 
	Commands last_cmd;               ///< The last cmd passed to a command.
 

	
 
	VehicleID new_vehicle_id;        ///< The ID of the new Vehicle.
 
	SignID new_sign_id;              ///< The ID of the new Sign.
src/settings.cpp
Show inline comments
 
@@ -1603,7 +1603,7 @@ void SyncCompanySettings()
 
		const SettingDesc *sd = GetSettingDesc(desc);
 
		uint32 old_value = (uint32)sd->AsIntSetting()->Read(new_object);
 
		uint32 new_value = (uint32)sd->AsIntSetting()->Read(old_object);
 
		if (old_value != new_value) NetworkSendCommand(CMD_CHANGE_COMPANY_SETTING, nullptr, _local_company, 0, 0, new_value, sd->GetName());
 
		if (old_value != new_value) NetworkSendCommand(CMD_CHANGE_COMPANY_SETTING, STR_NULL, nullptr, _local_company, 0, 0, new_value, sd->GetName());
 
	}
 
}
 

	
src/signs_cmd.cpp
Show inline comments
 
@@ -114,7 +114,7 @@ CommandCost CmdRenameSign(TileIndex tile
 
 * @param p2 unused
 
 * @param cmd unused
 
 */
 
void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -130,5 +130,5 @@ void CcPlaceSign(const CommandCost &resu
 
 */
 
void PlaceProc_Sign(TileIndex tile)
 
{
 
	DoCommandP(CMD_PLACE_SIGN | CMD_MSG(STR_ERROR_CAN_T_PLACE_SIGN_HERE), CcPlaceSign, tile, 0, 0);
 
	DoCommandP(CMD_PLACE_SIGN, STR_ERROR_CAN_T_PLACE_SIGN_HERE, CcPlaceSign, tile, 0, 0);
 
}
src/signs_gui.cpp
Show inline comments
 
@@ -413,7 +413,7 @@ Window *ShowSignList()
 
static bool RenameSign(SignID index, const char *text)
 
{
 
	bool remove = StrEmpty(text);
 
	DoCommandP(CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_ERROR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_ERROR_CAN_T_CHANGE_SIGN_NAME)), 0, index, 0, text);
 
	DoCommandP(CMD_RENAME_SIGN, StrEmpty(text) ? STR_ERROR_CAN_T_DELETE_SIGN : STR_ERROR_CAN_T_CHANGE_SIGN_NAME, 0, index, 0, text);
 
	return remove;
 
}
 

	
src/station_gui.cpp
Show inline comments
 
@@ -2084,7 +2084,7 @@ struct StationViewWindow : public Window
 
	{
 
		if (str == nullptr) return;
 

	
 
		DoCommandP(CMD_RENAME_STATION | CMD_MSG(STR_ERROR_CAN_T_RENAME_STATION), 0, this->window_number, 0, str);
 
		DoCommandP(CMD_RENAME_STATION, STR_ERROR_CAN_T_RENAME_STATION, 0, this->window_number, 0, str);
 
	}
 

	
 
	void OnResize() override
src/terraform_gui.cpp
Show inline comments
 
@@ -39,7 +39,7 @@
 

	
 
#include "safeguards.h"
 

	
 
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded()) {
 
		if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
 
@@ -115,16 +115,16 @@ bool GUIPlaceProcDragXY(ViewportDragDrop
 

	
 
	switch (proc) {
 
		case DDSP_DEMOLISH_AREA:
 
			DoCommandP(CMD_CLEAR_AREA | CMD_MSG(STR_ERROR_CAN_T_CLEAR_THIS_AREA), CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed ? 1 : 0);
 
			DoCommandP(CMD_CLEAR_AREA, STR_ERROR_CAN_T_CLEAR_THIS_AREA, CcPlaySound_EXPLOSION, end_tile, start_tile, _ctrl_pressed ? 1 : 0);
 
			break;
 
		case DDSP_RAISE_AND_LEVEL_AREA:
 
			DoCommandP(CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_RAISE_LAND_HERE), CcTerraform, end_tile, start_tile, LM_RAISE << 1 | (_ctrl_pressed ? 1 : 0));
 
			DoCommandP(CMD_LEVEL_LAND, STR_ERROR_CAN_T_RAISE_LAND_HERE, CcTerraform, end_tile, start_tile, LM_RAISE << 1 | (_ctrl_pressed ? 1 : 0));
 
			break;
 
		case DDSP_LOWER_AND_LEVEL_AREA:
 
			DoCommandP(CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LOWER_LAND_HERE), CcTerraform, end_tile, start_tile, LM_LOWER << 1 | (_ctrl_pressed ? 1 : 0));
 
			DoCommandP(CMD_LEVEL_LAND, STR_ERROR_CAN_T_LOWER_LAND_HERE, CcTerraform, end_tile, start_tile, LM_LOWER << 1 | (_ctrl_pressed ? 1 : 0));
 
			break;
 
		case DDSP_LEVEL_AREA:
 
			DoCommandP(CMD_LEVEL_LAND | CMD_MSG(STR_ERROR_CAN_T_LEVEL_LAND_HERE), CcTerraform, end_tile, start_tile, LM_LEVEL << 1 | (_ctrl_pressed ? 1 : 0));
 
			DoCommandP(CMD_LEVEL_LAND, STR_ERROR_CAN_T_LEVEL_LAND_HERE, CcTerraform, end_tile, start_tile, LM_LEVEL << 1 | (_ctrl_pressed ? 1 : 0));
 
			break;
 
		case DDSP_CREATE_ROCKS:
 
			GenerateRockyArea(end_tile, start_tile);
 
@@ -238,7 +238,7 @@ struct TerraformToolbarWindow : Window {
 
				break;
 

	
 
			case WID_TT_BUY_LAND: // Buy land button
 
				DoCommandP(CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound_CONSTRUCTION_RAIL, tile, OBJECT_OWNED_LAND, 0);
 
				DoCommandP(CMD_BUILD_OBJECT, STR_ERROR_CAN_T_PURCHASE_THIS_LAND, CcPlaySound_CONSTRUCTION_RAIL, tile, OBJECT_OWNED_LAND, 0);
 
				break;
 

	
 
			case WID_TT_PLACE_SIGN: // Place sign button
 
@@ -395,7 +395,7 @@ static void CommonRaiseLowerBigLand(Tile
 
		StringID msg =
 
			mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE;
 

	
 
		DoCommandP(CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform, tile, SLOPE_N, (uint32)mode);
 
		DoCommandP(CMD_TERRAFORM_LAND, msg, CcTerraform, tile, SLOPE_N, (uint32)mode);
 
	} else {
 
		assert(_terraform_size != 0);
 
		TileArea ta(tile, _terraform_size, _terraform_size);
src/timetable_gui.cpp
Show inline comments
 
@@ -142,7 +142,7 @@ static void FillTimetableArrivalDepartur
 
 */
 
static void ChangeTimetableStartCallback(const Window *w, Date date)
 
{
 
	DoCommandP(CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, w->window_number, date);
 
	DoCommandP(CMD_SET_TIMETABLE_START, STR_ERROR_CAN_T_TIMETABLE_VEHICLE, 0, w->window_number, date);
 
}
 

	
 

	
 
@@ -578,25 +578,25 @@ struct TimetableWindow : Window {
 

	
 
			case WID_VT_CLEAR_TIME: { // Clear waiting time.
 
				uint32 p1 = PackTimetableArgs(v, this->sel_index, false);
 
				DoCommandP(CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, p1, 0);
 
				DoCommandP(CMD_CHANGE_TIMETABLE, STR_ERROR_CAN_T_TIMETABLE_VEHICLE, 0, p1, 0);
 
				break;
 
			}
 

	
 
			case WID_VT_CLEAR_SPEED: { // Clear max speed button.
 
				uint32 p1 = PackTimetableArgs(v, this->sel_index, true);
 
				DoCommandP(CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, p1, UINT16_MAX);
 
				DoCommandP(CMD_CHANGE_TIMETABLE, STR_ERROR_CAN_T_TIMETABLE_VEHICLE, 0, p1, UINT16_MAX);
 
				break;
 
			}
 

	
 
			case WID_VT_RESET_LATENESS: // Reset the vehicle's late counter.
 
				DoCommandP(CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, v->index, 0);
 
				DoCommandP(CMD_SET_VEHICLE_ON_TIME, STR_ERROR_CAN_T_TIMETABLE_VEHICLE, 0, v->index, 0);
 
				break;
 

	
 
			case WID_VT_AUTOFILL: { // Autofill the timetable.
 
				uint32 p2 = 0;
 
				if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0);
 
				if (_ctrl_pressed) SetBit(p2, 1);
 
				DoCommandP(CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, v->index, p2);
 
				DoCommandP(CMD_AUTOFILL_TIMETABLE, STR_ERROR_CAN_T_TIMETABLE_VEHICLE, 0, v->index, p2);
 
				break;
 
			}
 

	
 
@@ -629,7 +629,7 @@ struct TimetableWindow : Window {
 

	
 
		uint32 p2 = std::min<uint32>(val, UINT16_MAX);
 

	
 
		DoCommandP(CMD_CHANGE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), 0, p1, p2);
 
		DoCommandP(CMD_CHANGE_TIMETABLE, STR_ERROR_CAN_T_TIMETABLE_VEHICLE, 0, p1, p2);
 
	}
 

	
 
	void OnResize() override
src/town_gui.cpp
Show inline comments
 
@@ -287,7 +287,7 @@ public:
 
			}
 

	
 
			case WID_TA_EXECUTE:
 
				DoCommandP(CMD_DO_TOWN_ACTION | CMD_MSG(STR_ERROR_CAN_T_DO_THIS), this->town->xy, this->window_number, this->sel_index);
 
				DoCommandP(CMD_DO_TOWN_ACTION, STR_ERROR_CAN_T_DO_THIS, this->town->xy, this->window_number, this->sel_index);
 
				break;
 
		}
 
	}
 
@@ -474,12 +474,12 @@ public:
 
					_warn_town_no_roads = true;
 
				}
 

	
 
				DoCommandP(CMD_EXPAND_TOWN | CMD_MSG(STR_ERROR_CAN_T_EXPAND_TOWN), 0, this->window_number, 0);
 
				DoCommandP(CMD_EXPAND_TOWN, STR_ERROR_CAN_T_EXPAND_TOWN, 0, this->window_number, 0);
 
				break;
 
			}
 

	
 
			case WID_TV_DELETE: // delete town - only available on Scenario editor
 
				DoCommandP(CMD_DELETE_TOWN | CMD_MSG(STR_ERROR_TOWN_CAN_T_DELETE), 0, this->window_number, 0);
 
				DoCommandP(CMD_DELETE_TOWN, STR_ERROR_TOWN_CAN_T_DELETE, 0, this->window_number, 0);
 
				break;
 
		}
 
	}
 
@@ -561,7 +561,7 @@ public:
 
	{
 
		if (str == nullptr) return;
 

	
 
		DoCommandP(CMD_RENAME_TOWN | CMD_MSG(STR_ERROR_CAN_T_RENAME_TOWN), 0, this->window_number, 0, str);
 
		DoCommandP(CMD_RENAME_TOWN, STR_ERROR_CAN_T_RENAME_TOWN, 0, this->window_number, 0, str);
 
	}
 
};
 

	
 
@@ -1008,7 +1008,7 @@ void ShowTownDirectory()
 
	new TownDirectoryWindow(&_town_directory_desc);
 
}
 

	
 
void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -1016,7 +1016,7 @@ void CcFoundTown(const CommandCost &resu
 
	if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
 
}
 

	
 
void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy);
 
}
 
@@ -1162,7 +1162,7 @@ public:
 
			if (strcmp(buf, this->townname_editbox.text.buf) != 0) name = this->townname_editbox.text.buf;
 
		}
 

	
 
		bool success = DoCommandP(CMD_FOUND_TOWN | CMD_MSG(errstr), cc,
 
		bool success = DoCommandP(CMD_FOUND_TOWN, errstr, cc,
 
				tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6, townnameparts, name);
 

	
 
		/* Rerandomise name, if success and no cost-estimation. */
src/train_gui.cpp
Show inline comments
 
@@ -27,7 +27,7 @@
 
 * @param p2 Additional data for the command (for the #CommandProc)
 
 * @param cmd Unused.
 
 */
 
void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
src/tree_gui.cpp
Show inline comments
 
@@ -240,7 +240,7 @@ public:
 
	void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
 
	{
 
		if (_game_mode != GM_EDITOR && this->mode == PM_NORMAL && pt.x != -1 && select_proc == DDSP_PLANT_TREES) {
 
			DoCommandP(CMD_PLANT_TREE | CMD_MSG(STR_ERROR_CAN_T_PLANT_TREE_HERE), end_tile, this->tree_to_plant, start_tile);
 
			DoCommandP(CMD_PLANT_TREE, STR_ERROR_CAN_T_PLANT_TREE_HERE, end_tile, this->tree_to_plant, start_tile);
 
		}
 
	}
 

	
src/vehicle.cpp
Show inline comments
 
@@ -1561,7 +1561,7 @@ void VehicleEnterDepot(Vehicle *v)
 

	
 
		if (v->current_order.IsRefit()) {
 
			Backup<CompanyID> cur_company(_current_company, v->owner, FILE_LINE);
 
			CommandCost cost = DoCommand(DC_EXEC, GetCmdRefitVeh(v), v->tile, v->index, v->current_order.GetRefitCargo() | 0xFF << 8);
 
			CommandCost cost = DoCommand(DC_EXEC, CMD_REFIT_VEHICLE, v->tile, v->index, v->current_order.GetRefitCargo() | 0xFF << 8);
 
			cur_company.Restore();
 

	
 
			if (cost.Failed()) {
src/vehicle_cmd.cpp
Show inline comments
 
@@ -37,33 +37,33 @@
 

	
 
#include "safeguards.h"
 

	
 
/* Tables used in vehicle.h to find the right command for a certain vehicle type */
 
const uint32 _veh_build_proc_table[] = {
 
	CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN),
 
	CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_ROAD_VEHICLE),
 
	CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_SHIP),
 
	CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_AIRCRAFT),
 
/* Tables used in vehicle_func.h to find the right error message for a certain vehicle type */
 
const StringID _veh_build_msg_table[] = {
 
	STR_ERROR_CAN_T_BUY_TRAIN,
 
	STR_ERROR_CAN_T_BUY_ROAD_VEHICLE,
 
	STR_ERROR_CAN_T_BUY_SHIP,
 
	STR_ERROR_CAN_T_BUY_AIRCRAFT,
 
};
 

	
 
const uint32 _veh_sell_proc_table[] = {
 
	CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_TRAIN),
 
	CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_ROAD_VEHICLE),
 
	CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_SHIP),
 
	CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_AIRCRAFT),
 
const StringID _veh_sell_msg_table[] = {
 
	STR_ERROR_CAN_T_SELL_TRAIN,
 
	STR_ERROR_CAN_T_SELL_ROAD_VEHICLE,
 
	STR_ERROR_CAN_T_SELL_SHIP,
 
	STR_ERROR_CAN_T_SELL_AIRCRAFT,
 
};
 

	
 
const uint32 _veh_refit_proc_table[] = {
 
	CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_TRAIN),
 
	CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_ROAD_VEHICLE),
 
	CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_SHIP),
 
	CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_AIRCRAFT),
 
const StringID _veh_refit_msg_table[] = {
 
	STR_ERROR_CAN_T_REFIT_TRAIN,
 
	STR_ERROR_CAN_T_REFIT_ROAD_VEHICLE,
 
	STR_ERROR_CAN_T_REFIT_SHIP,
 
	STR_ERROR_CAN_T_REFIT_AIRCRAFT,
 
};
 

	
 
const uint32 _send_to_depot_proc_table[] = {
 
	CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT),
 
	CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT),
 
	CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT),
 
	CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR),
 
const StringID _send_to_depot_msg_table[] = {
 
	STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT,
 
	STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT,
 
	STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT,
 
	STR_ERROR_CAN_T_SEND_AIRCRAFT_TO_HANGAR,
 
};
 

	
 

	
 
@@ -182,7 +182,7 @@ CommandCost CmdBuildVehicle(TileIndex ti
 

	
 
		/* If we are not in DC_EXEC undo everything */
 
		if (flags != subflags) {
 
			DoCommand(DC_EXEC, GetCmdSellVeh(v), 0, v->index, 0);
 
			DoCommand(DC_EXEC, CMD_SELL_VEHICLE, 0, v->index, 0);
 
		}
 
	}
 

	
 
@@ -689,15 +689,13 @@ CommandCost CmdDepotSellAllVehicles(Tile
 

	
 
	if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
 

	
 
	uint sell_command = GetCmdSellVeh(vehicle_type);
 

	
 
	/* Get the list of vehicles in the depot */
 
	BuildDepotVehicleList(vehicle_type, tile, &list, &list);
 

	
 
	CommandCost last_error = CMD_ERROR;
 
	bool had_success = false;
 
	for (uint i = 0; i < list.size(); i++) {
 
		CommandCost ret = DoCommand(flags, sell_command, tile, list[i]->index | (1 << 20), 0);
 
		CommandCost ret = DoCommand(flags, CMD_SELL_VEHICLE, tile, list[i]->index | (1 << 20), 0);
 
		if (ret.Succeeded()) {
 
			cost.AddCost(ret);
 
			had_success = true;
 
@@ -875,11 +873,11 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
		DoCommandFlag build_flags = flags;
 
		if ((flags & DC_EXEC) && !v->IsPrimaryVehicle()) build_flags |= DC_AUTOREPLACE;
 

	
 
		CommandCost cost = DoCommand(build_flags, GetCmdBuildVeh(v), tile, v->engine_type | (1 << 16) | (CT_INVALID << 24), 0);
 
		CommandCost cost = DoCommand(build_flags, CMD_BUILD_VEHICLE, tile, v->engine_type | (1 << 16) | (CT_INVALID << 24), 0);
 

	
 
		if (cost.Failed()) {
 
			/* Can't build a part, then sell the stuff we already made; clear up the mess */
 
			if (w_front != nullptr) DoCommand(flags, GetCmdSellVeh(w_front), w_front->tile, w_front->index | (1 << 20), 0);
 
			if (w_front != nullptr) DoCommand(flags, CMD_SELL_VEHICLE, w_front->tile, w_front->index | (1 << 20), 0);
 
			return cost;
 
		}
 

	
 
@@ -899,8 +897,8 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
				if (result.Failed()) {
 
					/* The train can't be joined to make the same consist as the original.
 
					 * Sell what we already made (clean up) and return an error.           */
 
					DoCommand(flags, GetCmdSellVeh(w_front), w_front->tile, w_front->index | 1 << 20, 0);
 
					DoCommand(flags, GetCmdSellVeh(w)      , w_front->tile, w->index       | 1 << 20, 0);
 
					DoCommand(flags, CMD_SELL_VEHICLE, w_front->tile, w_front->index | 1 << 20, 0);
 
					DoCommand(flags, CMD_SELL_VEHICLE, w_front->tile, w->index       | 1 << 20, 0);
 
					return result; // return error and the message returned from CMD_MOVE_RAIL_VEHICLE
 
				}
 
			} else {
 
@@ -943,7 +941,7 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
				/* Find out what's the best sub type */
 
				byte subtype = GetBestFittingSubType(v, w, v->cargo_type);
 
				if (w->cargo_type != v->cargo_type || w->cargo_subtype != subtype) {
 
					CommandCost cost = DoCommand(flags, GetCmdRefitVeh(v), 0, w->index, v->cargo_type | 1U << 25 | (subtype << 8));
 
					CommandCost cost = DoCommand(flags, CMD_REFIT_VEHICLE, 0, w->index, v->cargo_type | 1U << 25 | (subtype << 8));
 
					if (cost.Succeeded()) total_cost.AddCost(cost);
 
				}
 

	
 
@@ -981,7 +979,7 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
		CommandCost result = DoCommand(flags, CMD_CLONE_ORDER, 0, w_front->index | (p2 & 1 ? CO_SHARE : CO_COPY) << 30, v_front->index);
 
		if (result.Failed()) {
 
			/* The vehicle has already been bought, so now it must be sold again. */
 
			DoCommand(flags, GetCmdSellVeh(w_front), w_front->tile, w_front->index | 1 << 20, 0);
 
			DoCommand(flags, CMD_SELL_VEHICLE, w_front->tile, w_front->index | 1 << 20, 0);
 
			return result;
 
		}
 

	
 
@@ -992,7 +990,7 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
		 * check whether the company has enough money manually. */
 
		if (!CheckCompanyHasMoney(total_cost)) {
 
			/* The vehicle has already been bought, so now it must be sold again. */
 
			DoCommand(flags, GetCmdSellVeh(w_front), w_front->tile, w_front->index | 1 << 20, 0);
 
			DoCommand(flags, CMD_SELL_VEHICLE, w_front->tile, w_front->index | 1 << 20, 0);
 
			return total_cost;
 
		}
 
	}
 
@@ -1017,7 +1015,7 @@ static CommandCost SendAllVehiclesToDepo
 
	bool had_success = false;
 
	for (uint i = 0; i < list.size(); i++) {
 
		const Vehicle *v = list[i];
 
		CommandCost ret = DoCommand(flags, GetCmdSendToDepot(vli.vtype), v->tile, v->index | (service ? DEPOT_SERVICE : 0U) | DEPOT_DONT_CANCEL, 0);
 
		CommandCost ret = DoCommand(flags, CMD_SEND_VEHICLE_TO_DEPOT, v->tile, v->index | (service ? DEPOT_SERVICE : 0U) | DEPOT_DONT_CANCEL, 0);
 

	
 
		if (ret.Succeeded()) {
 
			had_success = true;
src/vehicle_func.h
Show inline comments
 
@@ -115,50 +115,50 @@ const struct Livery *GetEngineLivery(Eng
 
SpriteID GetEnginePalette(EngineID engine_type, CompanyID company);
 
SpriteID GetVehiclePalette(const Vehicle *v);
 

	
 
extern const uint32 _veh_build_proc_table[];
 
extern const uint32 _veh_sell_proc_table[];
 
extern const uint32 _veh_refit_proc_table[];
 
extern const uint32 _send_to_depot_proc_table[];
 
extern const StringID _veh_build_msg_table[];
 
extern const StringID _veh_sell_msg_table[];
 
extern const StringID _veh_refit_msg_table[];
 
extern const StringID _send_to_depot_msg_table[];
 

	
 
/* Functions to find the right command for certain vehicle type */
 
static inline uint32 GetCmdBuildVeh(VehicleType type)
 
static inline StringID GetCmdBuildVehMsg(VehicleType type)
 
{
 
	return _veh_build_proc_table[type];
 
	return _veh_build_msg_table[type];
 
}
 

	
 
static inline uint32 GetCmdBuildVeh(const BaseVehicle *v)
 
static inline StringID GetCmdBuildVehMsg(const BaseVehicle *v)
 
{
 
	return GetCmdBuildVeh(v->type);
 
	return GetCmdBuildVehMsg(v->type);
 
}
 

	
 
static inline uint32 GetCmdSellVeh(VehicleType type)
 
static inline StringID GetCmdSellVehMsg(VehicleType type)
 
{
 
	return _veh_sell_proc_table[type];
 
	return _veh_sell_msg_table[type];
 
}
 

	
 
static inline uint32 GetCmdSellVeh(const BaseVehicle *v)
 
static inline StringID GetCmdSellVehMsg(const BaseVehicle *v)
 
{
 
	return GetCmdSellVeh(v->type);
 
	return GetCmdSellVehMsg(v->type);
 
}
 

	
 
static inline uint32 GetCmdRefitVeh(VehicleType type)
 
static inline StringID GetCmdRefitVehMsg(VehicleType type)
 
{
 
	return _veh_refit_proc_table[type];
 
	return _veh_refit_msg_table[type];
 
}
 

	
 
static inline uint32 GetCmdRefitVeh(const BaseVehicle *v)
 
static inline StringID GetCmdRefitVehMsg(const BaseVehicle *v)
 
{
 
	return GetCmdRefitVeh(v->type);
 
	return GetCmdRefitVehMsg(v->type);
 
}
 

	
 
static inline uint32 GetCmdSendToDepot(VehicleType type)
 
static inline StringID GetCmdSendToDepotMsg(VehicleType type)
 
{
 
	return _send_to_depot_proc_table[type];
 
	return _send_to_depot_msg_table[type];
 
}
 

	
 
static inline uint32 GetCmdSendToDepot(const BaseVehicle *v)
 
static inline StringID GetCmdSendToDepotMsg(const BaseVehicle *v)
 
{
 
	return GetCmdSendToDepot(v->type);
 
	return GetCmdSendToDepotMsg(v->type);
 
}
 

	
 
CommandCost EnsureNoVehicleOnGround(TileIndex tile);
src/vehicle_gui.cpp
Show inline comments
 
@@ -772,7 +772,7 @@ struct RefitWindow : public Window {
 
	{
 
		assert(_current_company == _local_company);
 
		Vehicle *v = Vehicle::Get(this->window_number);
 
		CommandCost cost = DoCommand(DC_QUERY_COST, GetCmdRefitVeh(v->type), v->tile, this->selected_vehicle, option->cargo |
 
		CommandCost cost = DoCommand(DC_QUERY_COST, CMD_REFIT_VEHICLE, v->tile, this->selected_vehicle, option->cargo |
 
				option->subtype << 8 | this->num_vehicles << 16 | (int)this->auto_refit << 24);
 

	
 
		if (cost.Failed()) return INVALID_STRING_ID;
 
@@ -1033,7 +1033,7 @@ struct RefitWindow : public Window {
 

	
 
					if (this->order == INVALID_VEH_ORDER_ID) {
 
						bool delete_window = this->selected_vehicle == v->index && this->num_vehicles == UINT8_MAX;
 
						if (DoCommandP(GetCmdRefitVeh(v), v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16) && delete_window) this->Close();
 
						if (DoCommandP(CMD_REFIT_VEHICLE, GetCmdRefitVehMsg(v), v->tile, this->selected_vehicle, this->cargo->cargo | this->cargo->subtype << 8 | this->num_vehicles << 16) && delete_window) this->Close();
 
					} else {
 
						if (DoCommandP(CMD_ORDER_REFIT, v->tile, v->index, this->cargo->cargo | this->order << 16)) this->Close();
 
					}
 
@@ -1919,7 +1919,7 @@ public:
 
						break;
 
					case ADI_SERVICE: // Send for servicing
 
					case ADI_DEPOT: // Send to Depots
 
						DoCommandP(GetCmdSendToDepot(this->vli.vtype), 0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : (DepotCommand)0), this->window_number);
 
						DoCommandP(CMD_SEND_VEHICLE_TO_DEPOT, GetCmdSendToDepotMsg(this->vli.vtype), 0, DEPOT_MASS_SEND | (index == ADI_SERVICE ? DEPOT_SERVICE : (DepotCommand)0), this->window_number);
 
						break;
 

	
 
					default: NOT_REACHED();
 
@@ -2422,7 +2422,7 @@ struct VehicleDetailsWindow : Window {
 
				mod = GetServiceIntervalClamped(mod + v->GetServiceInterval(), v->ServiceIntervalIsPercent());
 
				if (mod == v->GetServiceInterval()) return;
 

	
 
				DoCommandP(CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING), v->tile, v->index, mod | (1 << 16) | (v->ServiceIntervalIsPercent() << 17));
 
				DoCommandP(CMD_CHANGE_SERVICE_INT, STR_ERROR_CAN_T_CHANGE_SERVICING, v->tile, v->index, mod | (1 << 16) | (v->ServiceIntervalIsPercent() << 17));
 
				break;
 
			}
 

	
 
@@ -2458,7 +2458,7 @@ struct VehicleDetailsWindow : Window {
 
				bool iscustom = index != 0;
 
				bool ispercent = iscustom ? (index == 2) : Company::Get(v->owner)->settings.vehicle.servint_ispercent;
 
				uint16 interval = GetServiceIntervalClamped(v->GetServiceInterval(), ispercent);
 
				DoCommandP(CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING), v->tile, v->index, interval | (iscustom << 16) | (ispercent << 17));
 
				DoCommandP(CMD_CHANGE_SERVICE_INT, STR_ERROR_CAN_T_CHANGE_SERVICING, v->tile, v->index, interval | (iscustom << 16) | (ispercent << 17));
 
				break;
 
			}
 
		}
 
@@ -2591,24 +2591,24 @@ enum VehicleCommandTranslation {
 
};
 

	
 
/** Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type. */
 
static const uint32 _vehicle_command_translation_table[][4] = {
 
static const StringID _vehicle_msg_translation_table[][4] = {
 
	{ // VCT_CMD_START_STOP
 
		CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_TRAIN),
 
		CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE),
 
		CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_SHIP),
 
		CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_AIRCRAFT)
 
		STR_ERROR_CAN_T_STOP_START_TRAIN,
 
		STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE,
 
		STR_ERROR_CAN_T_STOP_START_SHIP,
 
		STR_ERROR_CAN_T_STOP_START_AIRCRAFT
 
	},
 
	{ // VCT_CMD_CLONE_VEH
 
		CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN),
 
		CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_ROAD_VEHICLE),
 
		CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_SHIP),
 
		CMD_CLONE_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_AIRCRAFT)
 
		STR_ERROR_CAN_T_BUY_TRAIN,
 
		STR_ERROR_CAN_T_BUY_ROAD_VEHICLE,
 
		STR_ERROR_CAN_T_BUY_SHIP,
 
		STR_ERROR_CAN_T_BUY_AIRCRAFT
 
	},
 
	{ // VCT_CMD_TURN_AROUND
 
		CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN),
 
		CMD_TURN_ROADVEH            | CMD_MSG(STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN),
 
		0xffffffff, // invalid for ships
 
		0xffffffff  // invalid for aircraft
 
		STR_ERROR_CAN_T_REVERSE_DIRECTION_TRAIN,
 
		STR_ERROR_CAN_T_MAKE_ROAD_VEHICLE_TURN,
 
		INVALID_STRING_ID, // invalid for ships
 
		INVALID_STRING_ID  // invalid for aircraft
 
	},
 
};
 

	
 
@@ -2619,7 +2619,7 @@ static const uint32 _vehicle_command_tra
 
 * @param p1 vehicle ID
 
 * @param p2 unused
 
 */
 
void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
 
@@ -2639,7 +2639,7 @@ void CcStartStopVehicle(const CommandCos
 
void StartStopVehicle(const Vehicle *v, bool texteffect)
 
{
 
	assert(v->IsPrimaryVehicle());
 
	DoCommandP(_vehicle_command_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr, v->tile, v->index, 0);
 
	DoCommandP(CMD_START_STOP_VEHICLE, _vehicle_msg_translation_table[VCT_CMD_START_STOP][v->type], texteffect ? CcStartStopVehicle : nullptr, v->tile, v->index, 0);
 
}
 

	
 
/** Checks whether the vehicle may be refitted at the moment.*/
 
@@ -2963,7 +2963,7 @@ public:
 
				break;
 

	
 
			case WID_VV_GOTO_DEPOT: // goto hangar
 
				DoCommandP(GetCmdSendToDepot(v), v->tile, v->index | (_ctrl_pressed ? DEPOT_SERVICE : 0U), 0);
 
				DoCommandP(CMD_SEND_VEHICLE_TO_DEPOT, GetCmdSendToDepotMsg(v), v->tile, v->index | (_ctrl_pressed ? DEPOT_SERVICE : 0U), 0);
 
				break;
 
			case WID_VV_REFIT: // refit
 
				ShowVehicleRefitWindow(v, INVALID_VEH_ORDER_ID, this);
 
@@ -2987,17 +2987,21 @@ public:
 
				 * There is no point to it except for starting the vehicle.
 
				 * For starting the vehicle the player has to open the depot GUI, which is
 
				 * most likely already open, but is also visible in the vehicle viewport. */
 
				DoCommandP(_vehicle_command_translation_table[VCT_CMD_CLONE_VEH][v->type],
 
				DoCommandP(CMD_CLONE_VEHICLE, _vehicle_msg_translation_table[VCT_CMD_CLONE_VEH][v->type],
 
										_ctrl_pressed ? nullptr : CcCloneVehicle,
 
										v->tile, v->index, _ctrl_pressed ? 1 : 0);
 
				break;
 
			case WID_VV_TURN_AROUND: // turn around
 
				assert(v->IsGroundVehicle());
 
				DoCommandP(_vehicle_command_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, 0);
 
				if (v->type == VEH_ROAD) {
 
					DoCommandP(CMD_TURN_ROADVEH, _vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, 0);
 
				} else {
 
					DoCommandP(CMD_REVERSE_TRAIN_DIRECTION, _vehicle_msg_translation_table[VCT_CMD_TURN_AROUND][v->type], v->tile, v->index, 0);
 
				}
 
				break;
 
			case WID_VV_FORCE_PROCEED: // force proceed
 
				assert(v->type == VEH_TRAIN);
 
				DoCommandP(CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL), v->tile, v->index, 0);
 
				DoCommandP(CMD_FORCE_TRAIN_PROCEED, STR_ERROR_CAN_T_MAKE_TRAIN_PASS_SIGNAL, v->tile, v->index, 0);
 
				break;
 
		}
 
	}
 
@@ -3006,7 +3010,7 @@ public:
 
	{
 
		if (str == nullptr) return;
 

	
 
		DoCommandP(CMD_RENAME_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type), 0, this->window_number, 0, str);
 
		DoCommandP(CMD_RENAME_VEHICLE, STR_ERROR_CAN_T_RENAME_TRAIN + Vehicle::Get(this->window_number)->type, 0, this->window_number, 0, str);
 
	}
 

	
 
	void OnMouseOver(Point pt, int widget) override
 
@@ -3119,7 +3123,7 @@ void StopGlobalFollowVehicle(const Vehic
 
 * @param p2 unused
 
 * @param cmd unused
 
 */
 
void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
 
void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
 
{
 
	if (result.Failed()) return;
 

	
src/waypoint_gui.cpp
Show inline comments
 
@@ -138,7 +138,7 @@ public:
 
	{
 
		if (str == nullptr) return;
 

	
 
		DoCommandP(CMD_RENAME_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME), 0, this->window_number, 0, str);
 
		DoCommandP(CMD_RENAME_WAYPOINT, STR_ERROR_CAN_T_CHANGE_WAYPOINT_NAME, 0, this->window_number, 0, str);
 
	}
 

	
 
};
0 comments (0 inline, 0 general)