Changeset - r25562:30716ba6a396
[Not reviewed]
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -712,13 +712,13 @@ static CommandCost ReplaceChain(Vehicle 
 
 * @param flags type of operation
 
 * @param p1 Index of vehicle
 
 * @param p2 not used
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Vehicle *v = Vehicle::GetIfValid(p1);
 
	if (v == nullptr) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 
@@ -805,13 +805,13 @@ CommandCost CmdAutoreplaceVehicle(TileIn
 
 * @param p2 packed data
 
 *   - bits  0-15 = old engine type
 
 *   - bits 16-31 = new engine type
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Company *c = Company::GetIfValid(_current_company);
 
	if (c == nullptr) return CMD_ERROR;
 

	
 
	EngineID old_engine_type = GB(p2, 0, 16);
 
	EngineID new_engine_type = GB(p2, 16, 16);
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1227,13 +1227,13 @@ struct BuildVehicleWindow : Window {
 
			this->te.cargo = CT_INVALID;
 
			return;
 
		}
 

	
 
		if (!this->listview_mode) {
 
			/* Query for cost and refitted capacity */
 
			CommandCost ret = DoCommand(this->window_number, this->sel_engine | (cargo << 24), 0, DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type), nullptr);
 
			CommandCost ret = DoCommand(this->window_number, this->sel_engine | (cargo << 24), 0, DC_QUERY_COST, GetCmdBuildVeh(this->vehicle_type));
 
			if (ret.Succeeded()) {
 
				this->te.cost          = ret.GetCost() - e->GetCost();
 
				this->te.capacity      = _returned_refit_capacity;
 
				this->te.mail_capacity = _returned_mail_refit_capacity;
 
				this->te.cargo         = (cargo == CT_INVALID) ? e->GetDefaultCargoType() : cargo;
 
				return;
src/command.cpp
Show inline comments
 
@@ -462,13 +462,13 @@ CommandCost DoCommand(const CommandConta
 
 * @param flags Flags for the command and how to execute the command
 
 * @param cmd The command-id to execute (a value of the CMD_* enums)
 
 * @param text The text to pass
 
 * @see CommandProc
 
 * @return the cost
 
 */
 
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text)
 
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const std::string &text)
 
{
 
	CommandCost res;
 

	
 
	/* Do not even think about executing out-of-bounds tile-commands */
 
	if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (flags & DC_ALL_TILES) == 0))) return CMD_ERROR;
 

	
 
@@ -555,13 +555,13 @@ bool DoCommandP(const CommandContainer *
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param callback A callback function to call after the command is finished
 
 * @param text The text to pass
 
 * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
 
 * @return \c true if the command succeeded, else \c false.
 
 */
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd)
 
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd)
 
{
 
	/* Cost estimation is generally only done when the
 
	 * local user presses shift while doing something.
 
	 * However, in case of incoming network commands,
 
	 * map generation or the pause button we do want
 
	 * to execute. */
 
@@ -628,13 +628,13 @@ bool DoCommandP(TileIndex tile, uint32 p
 
 * @param callback A callback function to call after the command is finished
 
 * @param text The text to pass
 
 * @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
 
 * @return the command cost of this function.
 
 */
 
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only)
 
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, bool my_cmd, bool estimate_only)
 
{
 
	/* Prevent recursion; it gives a mess over the network */
 
	assert(_docommand_recursive == 0);
 
	_docommand_recursive = 1;
 

	
 
	/* Reset the state. */
 
@@ -693,13 +693,13 @@ CommandCost DoCommandPInternal(TileIndex
 
	 * 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) {
 
			/* 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; \"%s\" (%s)", _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; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text.c_str(), GetCommandName(cmd));
 
		}
 
		cur_company.Restore();
 
		return_dcpi(res);
 
	}
 

	
 
	/*
 
@@ -713,13 +713,13 @@ CommandCost DoCommandPInternal(TileIndex
 
		/* Don't return anything special here; no error, no costs.
 
		 * This way it's not handled by DoCommand and only the
 
		 * actual execution of the command causes messages. Also
 
		 * reset the storages as we've not executed the command. */
 
		return_dcpi(CommandCost());
 
	}
 
	DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _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; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text.c_str(), GetCommandName(cmd));
 

	
 
	/* Actually try and execute the command. If no cost-type is given
 
	 * use the construction one */
 
	_cleared_object_areas.clear();
 
	BasePersistentStorageArray::SwitchMode(PSM_ENTER_COMMAND);
 
	CommandCost res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
src/command_func.h
Show inline comments
 
@@ -29,21 +29,21 @@ static const CommandCost CMD_ERROR = Com
 
 * StringID which will be returned.
 
 *
 
 * @param errcode The StringID to return
 
 */
 
#define return_cmd_error(errcode) return CommandCost(errcode);
 

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

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

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

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

	
 
extern Money _additional_cash_required;
 

	
 
bool IsValidCommand(uint32 cmd);
 
CommandFlags GetCommandFlags(uint32 cmd);
 
const char *GetCommandName(uint32 cmd);
src/command_type.h
Show inline comments
 
@@ -440,13 +440,13 @@ enum CommandPauseLevel {
 
 * @param flags Flags for the command, from the DC_* enumeration
 
 * @param p1 Additional data for the command
 
 * @param p2 Additional data for the command
 
 * @param text Additional text
 
 * @return The CommandCost of the command, which can be succeeded or failed.
 
 */
 
typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
 
typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text);
 

	
 
/**
 
 * Define a command with the flags which belongs to it.
 
 *
 
 * This struct connect a command handler function with the flags created with
 
 * the #CMD_AUTO, #CMD_OFFLINE and #CMD_SERVER values.
src/company_cmd.cpp
Show inline comments
 
@@ -804,13 +804,13 @@ void CompanyAdminRemove(CompanyID compan
 
 * - bits 16..23: CompanyID
 
 * - bits 24..31: CompanyRemoveReason (with CCA_DELETE)
 
 * @param p2 ClientID
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0);
 
	CompanyID company_id = (CompanyID)GB(p1, 16, 8);
 

	
 
	switch ((CompanyCtrlAction)GB(p1, 0, 16)) {
 
		case CCA_NEW: { // Create a new company
 
@@ -929,13 +929,13 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
 * @param flags operation to perform
 
 * @param p1 unused
 
 * @param p2 face bitmasked
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyManagerFace cmf = (CompanyManagerFace)p2;
 

	
 
	if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -953,13 +953,13 @@ CommandCost CmdSetCompanyManagerFace(Til
 
 * p1 bits 0-7 scheme to set
 
 * p1 bit 8 set first/second colour
 
 * @param p2 new colour for vehicles, property, etc.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Colours colour = Extract<Colours, 0, 8>(p2);
 
	LiveryScheme scheme = Extract<LiveryScheme, 0, 8>(p1);
 
	bool second = HasBit(p1, 8);
 

	
 
	if (scheme >= LS_END || (colour >= COLOUR_END && colour != INVALID_COLOUR)) return CMD_ERROR;
 
@@ -1064,15 +1064,15 @@ static bool IsUniqueCompanyName(const st
 
 * @param flags operation to perform
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_COMPANY_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueCompanyName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
@@ -1110,15 +1110,15 @@ static bool IsUniquePresidentName(const 
 
 * @param flags operation to perform
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_PRESIDENT_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniquePresidentName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
@@ -1128,16 +1128,13 @@ CommandCost CmdRenamePresident(TileIndex
 
		if (reset) {
 
			c->president_name.clear();
 
		} else {
 
			c->president_name = text;
 

	
 
			if (c->name_1 == STR_SV_UNNAMED && c->name.empty()) {
 
				char buf[80];
 

	
 
				seprintf(buf, lastof(buf), "%s Transport", text);
 
				DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, buf);
 
				DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, text + " Transport");
 
			}
 
		}
 

	
 
		MarkWholeScreenDirty();
 
		CompanyAdminUpdate(c);
 
	}
 
@@ -1198,13 +1195,13 @@ uint32 CompanyInfrastructure::GetTramTot
 
 * @param flags operation to perform
 
 * @param p1 the amount of money to transfer; max 20.000.000
 
 * @param p2 the company to transfer the money to
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (!_settings_game.economy.give_money) return CMD_ERROR;
 

	
 
	const Company *c = Company::Get(_current_company);
 
	CommandCost amount(EXPENSES_OTHER, std::min<Money>(p1, 20000000LL));
 
	CompanyID dest_company = (CompanyID)p2;
src/depot_cmd.cpp
Show inline comments
 
@@ -41,21 +41,21 @@ static bool IsUniqueDepotName(const std:
 
 * @param flags type of operation
 
 * @param p1 id of depot
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Depot *d = Depot::GetIfValid(p1);
 
	if (d == nullptr) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckTileOwnership(d->xy);
 
	if (ret.Failed()) return ret;
 

	
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_DEPOT_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueDepotName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
src/economy.cpp
Show inline comments
 
@@ -2014,13 +2014,13 @@ extern int GetAmountOwnedBy(const Compan
 
 * @param flags type of operation
 
 * @param p1 company to buy the shares from
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost cost(EXPENSES_OTHER);
 
	CompanyID target_company = (CompanyID)p1;
 
	Company *c = Company::GetIfValid(target_company);
 

	
 
	/* Check if buying shares is allowed (protection against modified clients)
 
@@ -2066,13 +2066,13 @@ CommandCost CmdBuyShareInCompany(TileInd
 
 * @param flags type of operation
 
 * @param p1 company to sell the shares from
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyID target_company = (CompanyID)p1;
 
	Company *c = Company::GetIfValid(target_company);
 

	
 
	/* Cannot sell own shares */
 
	if (c == nullptr || _current_company == target_company) return CMD_ERROR;
 
@@ -2107,13 +2107,13 @@ CommandCost CmdSellShareInCompany(TileIn
 
 * @param flags type of operation
 
 * @param p1 company to buy up
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyID target_company = (CompanyID)p1;
 
	Company *c = Company::GetIfValid(target_company);
 
	if (c == nullptr) return CMD_ERROR;
 

	
 
	/* Disable takeovers when not asked */
src/engine.cpp
Show inline comments
 
@@ -879,13 +879,13 @@ void ClearEnginesHiddenFlagOfCompany(Com
 
 * @param flags Operation to perform.
 
 * @param p1 Unused.
 
 * @param p2 Bit 31: 0=visible, 1=hidden, other bits for the #EngineID.
 
 * @param text Unused.
 
 * @return The cost of this operation or an error.
 
 */
 
CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Engine *e = Engine::GetIfValid(GB(p2, 0, 31));
 
	if (e == nullptr || _current_company >= MAX_COMPANIES) return CMD_ERROR;
 
	if (!IsEngineBuildable(e->index, e->type, _current_company)) return CMD_ERROR;
 

	
 
	if ((flags & DC_EXEC) != 0) {
 
@@ -903,13 +903,13 @@ CommandCost CmdSetVehicleVisibility(Tile
 
 * @param flags operation to perform
 
 * @param p1 engine-prototype offered
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Engine *e = Engine::GetIfValid(p1);
 
	if (e == nullptr || !(e->flags & ENGINE_EXCLUSIVE_PREVIEW) || e->preview_company != _current_company) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company);
 

	
 
@@ -924,13 +924,13 @@ CommandCost CmdWantEnginePreview(TileInd
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit  0 - 7) - Company to allow/forbid the use of an engine.
 
 * - p2 = (bit 31) - 0 to forbid, 1 to allow.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdEngineCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdEngineCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	EngineID engine_id = (EngineID)p1;
 
	CompanyID company_id = (CompanyID)GB(p2, 0, 8);
 
	bool allow = HasBit(p2, 31);
 

	
 
@@ -1076,18 +1076,18 @@ static bool IsUniqueEngineName(const std
 
 * @param flags operation to perform
 
 * @param p1 engine ID to rename
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Engine *e = Engine::GetIfValid(p1);
 
	if (e == nullptr) return CMD_ERROR;
 

	
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_ENGINE_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueEngineName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
src/goal.cpp
Show inline comments
 
@@ -40,21 +40,21 @@ INSTANTIATE_POOL_METHODS(Goal)
 
 * - p1 = (bit  0 -  7) - GoalType of destination.
 
 * - p1 = (bit  8 - 15) - Company for which this goal is.
 
 * @param p2 GoalTypeID of destination.
 
 * @param text Text of the goal.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (!Goal::CanAllocateItem()) return CMD_ERROR;
 

	
 
	GoalType type = (GoalType)GB(p1, 0, 8);
 
	CompanyID company = (CompanyID)GB(p1, 8, 8);
 

	
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (StrEmpty(text)) return CMD_ERROR;
 
	if (text.empty()) return CMD_ERROR;
 
	if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
 

	
 
	switch (type) {
 
		case GT_NONE:
 
			if (p2 != 0) return CMD_ERROR;
 
			break;
 
@@ -87,13 +87,13 @@ CommandCost CmdCreateGoal(TileIndex tile
 

	
 
	if (flags & DC_EXEC) {
 
		Goal *g = new Goal();
 
		g->type = type;
 
		g->dst = p2;
 
		g->company = company;
 
		g->text = stredup(text);
 
		g->text = stredup(text.c_str());
 
		g->progress = nullptr;
 
		g->completed = false;
 

	
 
		if (g->company == INVALID_COMPANY) {
 
			InvalidateWindowClassesData(WC_GOALS_LIST);
 
		} else {
 
@@ -113,13 +113,13 @@ CommandCost CmdCreateGoal(TileIndex tile
 
 * @param flags type of operation
 
 * @param p1 GoalID to remove.
 
 * @param p2 unused.
 
 * @param text unused.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (!Goal::IsValidID(p1)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		Goal *g = Goal::Get(p1);
 
@@ -143,22 +143,22 @@ CommandCost CmdRemoveGoal(TileIndex tile
 
 * @param flags type of operation
 
 * @param p1 GoalID to update.
 
 * @param p2 unused
 
 * @param text Text of the goal.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetGoalText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetGoalText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (!Goal::IsValidID(p1)) return CMD_ERROR;
 
	if (StrEmpty(text)) return CMD_ERROR;
 
	if (text.empty()) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		Goal *g = Goal::Get(p1);
 
		free(g->text);
 
		g->text = stredup(text);
 
		g->text = stredup(text.c_str());
 

	
 
		if (g->company == INVALID_COMPANY) {
 
			InvalidateWindowClassesData(WC_GOALS_LIST);
 
		} else {
 
			InvalidateWindowData(WC_GOALS_LIST, g->company);
 
		}
 
@@ -173,24 +173,24 @@ CommandCost CmdSetGoalText(TileIndex til
 
 * @param flags type of operation
 
 * @param p1 GoalID to update.
 
 * @param p2 unused
 
 * @param text Progress text of the goal.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetGoalProgress(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetGoalProgress(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (!Goal::IsValidID(p1)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		Goal *g = Goal::Get(p1);
 
		free(g->progress);
 
		if (StrEmpty(text)) {
 
		if (text.empty()) {
 
			g->progress = nullptr;
 
		} else {
 
			g->progress = stredup(text);
 
			g->progress = stredup(text.c_str());
 
		}
 

	
 
		if (g->company == INVALID_COMPANY) {
 
			InvalidateWindowClassesData(WC_GOALS_LIST);
 
		} else {
 
			InvalidateWindowData(WC_GOALS_LIST, g->company);
 
@@ -206,13 +206,13 @@ CommandCost CmdSetGoalProgress(TileIndex
 
 * @param flags type of operation
 
 * @param p1 GoalID to update.
 
 * @param p2 completed state. If goal is completed, set to 1, otherwise 0.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetGoalCompleted(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetGoalCompleted(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (!Goal::IsValidID(p1)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		Goal *g = Goal::Get(p1);
 
@@ -239,25 +239,25 @@ CommandCost CmdSetGoalCompleted(TileInde
 
 * - p2 = (bit 0 - 17) - Buttons of the question.
 
 * - p2 = (bit 29 - 30) - Question type.
 
 * - p2 = (bit 31) - Question target: 0 - company, 1 - client.
 
 * @param text Text of the question.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	uint16 uniqueid = (uint16)GB(p1, 0, 16);
 
	CompanyID company = (CompanyID)GB(p1, 16, 8);
 
	ClientID client = (ClientID)GB(p1, 16, 16);
 

	
 
	static_assert(GOAL_QUESTION_BUTTON_COUNT < 29);
 
	uint32 button_mask = GB(p2, 0, GOAL_QUESTION_BUTTON_COUNT);
 
	byte type = GB(p2, 29, 2);
 
	bool is_client = HasBit(p2, 31);
 

	
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (StrEmpty(text)) return CMD_ERROR;
 
	if (text.empty()) return CMD_ERROR;
 
	if (is_client) {
 
		/* Only check during pre-flight; the client might have left between
 
		 * testing and executing. In that case it is fine to just ignore the
 
		 * fact the client is no longer here. */
 
		if (!(flags & DC_EXEC) && _network_server && NetworkClientInfo::GetByClientID(client) == nullptr) return CMD_ERROR;
 
	} else {
 
@@ -271,13 +271,13 @@ CommandCost CmdGoalQuestion(TileIndex ti
 
		if (is_client) {
 
			if (client != _network_own_client_id) return CommandCost();
 
		} else {
 
			if (company == INVALID_COMPANY && !Company::IsValidID(_local_company)) return CommandCost();
 
			if (company != INVALID_COMPANY && company != _local_company) return CommandCost();
 
		}
 
		ShowGoalQuestion(uniqueid, type, button_mask, text);
 
		ShowGoalQuestion(uniqueid, type, button_mask, text.c_str());
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
/**
 
@@ -286,13 +286,13 @@ CommandCost CmdGoalQuestion(TileIndex ti
 
 * @param flags type of operation
 
 * @param p1 Unique ID to use for this question.
 
 * @param p2 Button the company pressed
 
 * @param text Text of the question.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdGoalQuestionAnswer(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdGoalQuestionAnswer(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (p1 > UINT16_MAX) return CMD_ERROR;
 
	if (p2 >= GOAL_QUESTION_BUTTON_COUNT) return CMD_ERROR;
 

	
 
	if (_current_company == OWNER_DEITY) {
 
		/* It has been requested to close this specific question on all clients */
src/group_cmd.cpp
Show inline comments
 
@@ -297,13 +297,13 @@ Group::Group(Owner owner)
 
 * @param flags type of operation
 
 * @param p1   vehicle type
 
 * @param p2   parent groupid
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleType vt = Extract<VehicleType, 0, 3>(p1);
 
	if (!IsCompanyBuildableVehicleType(vt)) return CMD_ERROR;
 

	
 
	if (!Group::CanAllocateItem()) return CMD_ERROR;
 

	
 
@@ -347,13 +347,13 @@ CommandCost CmdCreateGroup(TileIndex til
 
 * @param p1   index of array group
 
 *      - p1 bit 0-15 : GroupID
 
 * @param p2   unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Group *g = Group::GetIfValid(p1);
 
	if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
 

	
 
	/* Remove all vehicles from the group */
 
	DoCommand(0, p1, 0, flags, CMD_REMOVE_ALL_VEHICLES_GROUP);
 
@@ -401,20 +401,20 @@ CommandCost CmdDeleteGroup(TileIndex til
 
 *   - p1 bit 16: 0 - Rename grouop
 
 *                1 - Set group parent
 
 * @param p2   parent group index
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Group *g = Group::GetIfValid(GB(p1, 0, 16));
 
	if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
 

	
 
	if (!HasBit(p1, 16)) {
 
		/* Rename group */
 
		bool reset = StrEmpty(text);
 
		bool reset = text.empty();
 

	
 
		if (!reset) {
 
			if (Utf8StringLength(text) >= MAX_LENGTH_GROUP_NAME_CHARS) return CMD_ERROR;
 
		}
 

	
 
		if (flags & DC_EXEC) {
 
@@ -505,13 +505,13 @@ static void AddVehicleToGroup(Vehicle *v
 
 * @param p2   vehicle to add to a group
 
 *   - p2 bit 0-19 : VehicleID
 
 *   - p2 bit   31 : Add shared vehicles as well.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Vehicle *v = Vehicle::GetIfValid(GB(p2, 0, 20));
 
	GroupID new_g = p1;
 

	
 
	if (v == nullptr || (!Group::IsValidID(new_g) && !IsDefaultGroupID(new_g) && new_g != NEW_GROUP)) return CMD_ERROR;
 

	
 
@@ -521,13 +521,13 @@ CommandCost CmdAddVehicleGroup(TileIndex
 
	}
 

	
 
	if (v->owner != _current_company || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	if (new_g == NEW_GROUP) {
 
		/* Create new group. */
 
		CommandCost ret = CmdCreateGroup(0, flags, v->type, INVALID_GROUP, nullptr);
 
		CommandCost ret = CmdCreateGroup(0, flags, v->type, INVALID_GROUP, {});
 
		if (ret.Failed()) return ret;
 

	
 
		new_g = _new_group_id;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
@@ -562,13 +562,13 @@ CommandCost CmdAddVehicleGroup(TileIndex
 
 * @param p1   index of group array
 
 *  - p1 bit 0-15 : GroupID
 
 * @param p2   type of vehicles
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleType type = Extract<VehicleType, 0, 3>(p2);
 
	GroupID id_g = p1;
 
	if (!Group::IsValidID(id_g) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -599,13 +599,13 @@ CommandCost CmdAddSharedVehicleGroup(Til
 
 * @param p1   index of group array
 
 * - p1 bit 0-15 : GroupID
 
 * @param p2   unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	GroupID old_g = p1;
 
	Group *g = Group::GetIfValid(old_g);
 

	
 
	if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
 

	
 
@@ -633,13 +633,13 @@ CommandCost CmdRemoveAllVehiclesGroup(Ti
 
 * @param p1
 
 * - p1 bit  0-15   Group ID.
 
 * @param p2
 
 * - p2 bit  8      Set secondary instead of primary colour
 
 * - p2 bit 16-23   Colour.
 
 */
 
CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Group *g = Group::GetIfValid(p1);
 
	bool primary = !HasBit(p2, 8);
 
	Colours colour = Extract<Colours, 16, 8>(p2);
 

	
 
	if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
 
@@ -694,13 +694,13 @@ static void SetGroupFlag(Group *g, Group
 
 * @param p2
 
 * - p2 bit 0    : 1 to set or 0 to clear protection.
 
 * - p2 bit 1    : 1 to apply to sub-groups.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetGroupFlag(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetGroupFlag(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Group *g = Group::GetIfValid(GB(p1, 0, 16));
 
	if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
 

	
 
	/* GroupFlags are stored in as an 8 bit bitfield but passed here by value,
 
	 * so 3 bits is sufficient to cover each possible value. */
src/industry_cmd.cpp
Show inline comments
 
@@ -1979,13 +1979,13 @@ static CommandCost CreateNewIndustryHelp
 
 * - p1 = (bit  8 - 15) - first layout to try
 
 * - p1 = (bit 16     ) - 0 = prospect, 1 = fund (only valid if current company is DEITY)
 
 * @param p2 seed to use for desyncfree randomisations
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	IndustryType it = GB(p1, 0, 8);
 
	if (it >= NUM_INDUSTRYTYPES) return CMD_ERROR;
 

	
 
	const IndustrySpec *indspec = GetIndustrySpec(it);
 

	
 
@@ -2071,13 +2071,13 @@ CommandCost CmdBuildIndustry(TileIndex t
 
 * - p2 = (bit 16 - 23) - CompanyID to set or INVALID_OWNER (available to everyone) or
 
 *                        OWNER_NONE (neutral stations only) or OWNER_DEITY (no one)
 
 *                        (only used with set exclusive supplier / consumer)
 
 * @param text - Additional industry text (only used with set text action)
 
 * @return Empty cost or an error.
 
 */
 
CommandCost CmdIndustryCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdIndustryCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 

	
 
	Industry *ind = Industry::GetIfValid(p1);
 
	if (ind == nullptr) return CMD_ERROR;
 

	
 
@@ -2109,13 +2109,13 @@ CommandCost CmdIndustryCtrl(TileIndex ti
 

	
 
			break;
 
		}
 

	
 
		case IndustryAction::SetText: {
 
			ind->text.clear();
 
			if (!StrEmpty(text)) ind->text = text;
 
			if (!text.empty()) ind->text = text;
 
			InvalidateWindowData(WC_INDUSTRY_VIEW, ind->index);
 
			break;
 
		}
 

	
 
		default:
 
			NOT_REACHED();
src/landscape.cpp
Show inline comments
 
@@ -687,13 +687,13 @@ void ClearSnowLine()
 
 * @param flags of operation to conduct
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	bool do_clear = false;
 
	/* Test for stuff which results in water when cleared. Then add the cost to also clear the water. */
 
	if ((flags & DC_FORCE_CLEAR_TILE) && HasTileWaterClass(tile) && IsTileOnWater(tile) && !IsWaterTile(tile) && !IsCoastTile(tile)) {
 
		if ((flags & DC_AUTO) && GetWaterClass(tile) == WATER_CLASS_CANAL) return_cmd_error(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST);
 
@@ -737,13 +737,13 @@ CommandCost CmdLandscapeClear(TileIndex 
 
 * @param p1 start tile of area dragging
 
 * @param p2 various bitstuffed data.
 
 *  bit      0: Whether to use the Orthogonal (0) or Diagonal (1) iterator.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (p1 >= MapSize()) return CMD_ERROR;
 

	
 
	Money money = GetAvailableMoneyForCommand();
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	CommandCost last_error = CMD_ERROR;
src/misc_cmd.cpp
Show inline comments
 
@@ -39,13 +39,13 @@ static_assert((LOAN_INTERVAL & 3) == 0);
 
 *           (bit 0-1)  - when 0: loans LOAN_INTERVAL
 
 *                        when 1: loans the maximum loan permitting money (press CTRL),
 
 *                        when 2: loans the amount specified in p1 and p2
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Company *c = Company::Get(_current_company);
 

	
 
	if (c->current_loan >= _economy.max_loan) {
 
		SetDParam(0, _economy.max_loan);
 
		return_cmd_error(STR_ERROR_MAXIMUM_PERMITTED_LOAN);
 
@@ -87,13 +87,13 @@ CommandCost CmdIncreaseLoan(TileIndex ti
 
 *           (bit 0-1)  - when 0: pays back LOAN_INTERVAL
 
 *                        when 1: pays back the maximum loan permitting money (press CTRL),
 
 *                        when 2: pays back the amount specified in p1 and p2
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Company *c = Company::Get(_current_company);
 

	
 
	if (c->current_loan == 0) return_cmd_error(STR_ERROR_LOAN_ALREADY_REPAYED);
 

	
 
	Money loan;
 
@@ -147,13 +147,13 @@ static void AskUnsafeUnpauseCallback(Win
 
 * @param flags operation to perform
 
 * @param p1 the pause mode to change
 
 * @param p2 1 pauses, 0 unpauses this mode
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	switch (p1) {
 
		case PM_PAUSED_SAVELOAD:
 
		case PM_PAUSED_ERROR:
 
		case PM_PAUSED_NORMAL:
 
		case PM_PAUSED_GAME_SCRIPT:
 
@@ -199,13 +199,13 @@ CommandCost CmdPause(TileIndex tile, DoC
 
 * @param flags operation to perform
 
 * @param p1 the amount of money to receive (if positive), or spend (if negative)
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CommandCost(EXPENSES_OTHER, -(int32)p1);
 
}
 

	
 
/**
 
 * Change the bank bank balance of a company by inserting or removing money without affecting the loan.
 
@@ -214,13 +214,13 @@ CommandCost CmdMoneyCheat(TileIndex tile
 
 * @param p1 the amount of money to receive (if positive), or spend (if negative)
 
 * @param p2 (bit 0-7)  - the company ID.
 
 *           (bit 8-15) - the expenses type which should register the cost/income @see ExpensesType.
 
 * @param text unused
 
 * @return zero cost or an error
 
 */
 
CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	int32 delta = (int32)p1;
 
	CompanyID company = (CompanyID) GB(p2, 0, 8);
 
	ExpensesType expenses_type = Extract<ExpensesType, 8, 8>(p2);
 

	
 
	if (!Company::IsValidID(company)) return CMD_ERROR;
src/network/network_command.cpp
Show inline comments
 
@@ -130,25 +130,25 @@ static CommandQueue _local_execution_que
 
 * @param p2 Additional data for the command (see #CommandProc)
 
 * @param cmd The command to execute (a CMD_* value)
 
 * @param callback A callback function to call after the command is finished
 
 * @param text The text to pass
 
 * @param company The company that wants to send the command
 
 */
 
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company)
 
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const std::string &text, CompanyID company)
 
{
 
	assert((cmd & CMD_FLAGS_MASK) == 0);
 

	
 
	CommandPacket c;
 
	c.company  = company;
 
	c.tile     = tile;
 
	c.p1       = p1;
 
	c.p2       = p2;
 
	c.cmd      = cmd;
 
	c.callback = callback;
 

	
 
	strecpy(c.text, (text != nullptr) ? text : "", lastof(c.text));
 
	strecpy(c.text, text.c_str(), lastof(c.text));
 

	
 
	if (_network_server) {
 
		/* If we are the server, we queue the command in our 'special' queue.
 
		 *   In theory, we could execute the command right away, but then the
 
		 *   client on the server can do everything 1 tick faster than others.
 
		 *   So to keep the game fair, we delay the command with 1 tick
src/news_gui.cpp
Show inline comments
 
@@ -837,23 +837,23 @@ void AddNewsItem(StringID string, NewsTy
 
 * - p1 = (bit  8 - 15) - NewsReferenceType of first reference.
 
 * - p1 = (bit 16 - 23) - Company this news message is for.
 
 * @param p2 First reference of the news message.
 
 * @param text The text of the news message.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 

	
 
	NewsType type = (NewsType)GB(p1, 0, 8);
 
	NewsReferenceType reftype1 = (NewsReferenceType)GB(p1, 8, 8);
 
	CompanyID company = (CompanyID)GB(p1, 16, 8);
 

	
 
	if (company != INVALID_OWNER && !Company::IsValidID(company)) return CMD_ERROR;
 
	if (type >= NT_END) return CMD_ERROR;
 
	if (StrEmpty(text)) return CMD_ERROR;
 
	if (text.empty()) return CMD_ERROR;
 

	
 
	switch (reftype1) {
 
		case NR_NONE: break;
 
		case NR_TILE:
 
			if (!IsValidTile(p2)) return CMD_ERROR;
 
			break;
 
@@ -881,13 +881,13 @@ CommandCost CmdCustomNewsItem(TileIndex 
 
		default: return CMD_ERROR;
 
	}
 

	
 
	if (company != INVALID_OWNER && company != _local_company) return CommandCost();
 

	
 
	if (flags & DC_EXEC) {
 
		char *news = stredup(text);
 
		char *news = stredup(text.c_str());
 
		SetDParamStr(0, news);
 
		AddNewsItem(STR_NEWS_CUSTOM_ITEM, type, NF_NORMAL, reftype1, p2, NR_NONE, UINT32_MAX, news);
 
	}
 

	
 
	return CommandCost();
 
}
src/object_cmd.cpp
Show inline comments
 
@@ -196,13 +196,13 @@ static CommandCost ClearTile_Object(Tile
 
 * @param flags type of operation
 
 * @param p1 the object type to build
 
 * @param p2 the view for the object
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost cost(EXPENSES_PROPERTY);
 

	
 
	ObjectType type = (ObjectType)GB(p1, 0, 16);
 
	if (type >= NUM_OBJECTS) return CMD_ERROR;
 
	uint8 view = GB(p2, 0, 2);
 
@@ -766,13 +766,13 @@ void GenerateObjects()
 
				case OBJECT_LIGHTHOUSE:
 
					if (TryBuildLightHouse()) amount--;
 
					break;
 

	
 
				default:
 
					uint8 view = RandomRange(spec->views);
 
					if (CmdBuildObject(RandomTile(), DC_EXEC | DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, i, view, nullptr).Succeeded()) amount--;
 
					if (CmdBuildObject(RandomTile(), DC_EXEC | DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, i, view, {}).Succeeded()) amount--;
 
					break;
 
			}
 
		}
 
		IncreaseGeneratingWorldProgress(GWP_OBJECT);
 
	}
 
}
src/order_backup.cpp
Show inline comments
 
@@ -144,13 +144,13 @@ void OrderBackup::DoRestore(Vehicle *v)
 
 * @param flags For command.
 
 * @param p1    Unused.
 
 * @param p2    User that had the OrderBackup.
 
 * @param text  Unused.
 
 * @return The cost of this operation or an error.
 
 */
 
CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* No need to check anything. If the tile or user don't exist we just ignore it. */
 
	if (flags & DC_EXEC) OrderBackup::ResetOfUser(tile == 0 ? INVALID_TILE : tile, p2);
 

	
 
	return CommandCost();
 
}
src/order_cmd.cpp
Show inline comments
 
@@ -732,13 +732,13 @@ uint GetOrderDistance(const Order *prev,
 
 *                        the order will be inserted before that one
 
 *                        the maximum vehicle order id is 254.
 
 * @param p2 packed order to insert
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh          = GB(p1,  0, 20);
 
	VehicleOrderID sel_ord = GB(p1, 20, 8);
 
	Order new_order(p2);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
@@ -1007,13 +1007,13 @@ static CommandCost DecloneOrder(Vehicle 
 
 * @param flags operation to perform
 
 * @param p1 the ID of the vehicle
 
 * @param p2 the order to delete (max 255)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh_id = GB(p1, 0, 20);
 
	VehicleOrderID sel_ord = GB(p2, 0, 8);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh_id);
 

	
 
@@ -1112,13 +1112,13 @@ void DeleteOrder(Vehicle *v, VehicleOrde
 
 * @param flags operation to perform
 
 * @param p1 The ID of the vehicle which order is skipped
 
 * @param p2 the selected order to which we want to skip
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh_id = GB(p1, 0, 20);
 
	VehicleOrderID sel_ord = GB(p2, 0, 8);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh_id);
 

	
 
@@ -1153,13 +1153,13 @@ CommandCost CmdSkipToOrder(TileIndex til
 
 *           bit 16-31 : the target order
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @note The target order will move one place down in the orderlist
 
 *  if you move the order upwards else it'll move it one place down
 
 */
 
CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh = GB(p1, 0, 20);
 
	VehicleOrderID moving_order = GB(p2,  0, 16);
 
	VehicleOrderID target_order = GB(p2, 16, 16);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
@@ -1256,13 +1256,13 @@ CommandCost CmdMoveOrder(TileIndex tile,
 
 * @param p2 various bitstuffed elements
 
 *  - p2 = (bit 0 -  3) - what data to modify (@see ModifyOrderFlags)
 
 *  - p2 = (bit 4 - 15) - the data to modify
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleOrderID sel_ord = GB(p1, 20,  8);
 
	VehicleID veh          = GB(p1,  0, 20);
 
	ModifyOrderFlags mof   = Extract<ModifyOrderFlags, 0, 4>(p2);
 
	uint16 data            = GB(p2,  4, 11);
 

	
 
@@ -1525,13 +1525,13 @@ static bool CheckAircraftOrderDistance(c
 
 * - p1 = (bit  0-19) - destination vehicle to clone orders to
 
 * - p1 = (bit 30-31) - action to perform
 
 * @param p2 source vehicle to clone orders from, if any (none for CO_UNSHARE)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh_src = GB(p2, 0, 20);
 
	VehicleID veh_dst = GB(p1, 0, 20);
 

	
 
	Vehicle *dst = Vehicle::GetIfValid(veh_dst);
 
	if (dst == nullptr || !dst->IsPrimaryVehicle()) return CMD_ERROR;
 
@@ -1672,13 +1672,13 @@ CommandCost CmdCloneOrder(TileIndex tile
 
 * @param p2 bitmask
 
 *   - bit 0-7 CargoID
 
 *   - bit 16-23 number of order to modify
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh = GB(p1, 0, 20);
 
	VehicleOrderID order_number  = GB(p2, 16, 8);
 
	CargoID cargo = GB(p2, 0, 8);
 

	
 
	if (cargo >= NUM_CARGO && cargo != CT_NO_REFIT && cargo != CT_AUTO_REFIT) return CMD_ERROR;
src/rail_cmd.cpp
Show inline comments
 
@@ -431,13 +431,13 @@ static inline bool ValParamTrackOrientat
 
 * @param p2 various bitstuffed elements
 
 *           - (bit  0- 2) - track-orientation, valid values: 0-5 (@see Track)
 
 *           - (bit  3)    - 0 = error on signal in the way, 1 = auto remove signals when in the way
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	RailType railtype = Extract<RailType, 0, 6>(p1);
 
	Track track = Extract<Track, 0, 3>(p2);
 
	bool auto_remove_signals = HasBit(p2, 3);
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

	
 
@@ -619,13 +619,13 @@ CommandCost CmdBuildSingleRail(TileIndex
 
 * @param flags operation to perform
 
 * @param p1 unused
 
 * @param p2 rail orientation
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Track track = Extract<Track, 0, 3>(p2);
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	bool crossing = false;
 

	
 
	if (!ValParamTrackOrientation(track)) return CMD_ERROR;
 
@@ -881,13 +881,13 @@ static CommandCost ValidateAutoDrag(Trac
 
 * - p2 = (bit 9)   - 0 = build, 1 = remove tracks
 
 * - p2 = (bit 10)  - 0 = build up to an obstacle, 1 = fail if an obstacle is found (used for AIs).
 
 * - p2 = (bit 11)  - 0 = error on signal in the way, 1 = auto remove signals when in the way
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 
	Track track = Extract<Track, 6, 3>(p2);
 
	bool remove = HasBit(p2, 9);
 
	bool auto_remove_signals = HasBit(p2, 11);
 
	RailType railtype = Extract<RailType, 0, 6>(p2);
 
@@ -942,13 +942,13 @@ static CommandCost CmdRailTrackHelper(Ti
 
 * - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
 
 * - p2 = (bit 9)   - 0 = build, 1 = remove tracks
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdRailTrackHelper
 
 */
 
CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 9), text);
 
}
 

	
 
/**
 
 * Build rail on a stretch of track.
 
@@ -961,13 +961,13 @@ CommandCost CmdBuildRailroadTrack(TileIn
 
 * - p2 = (bit 6-8) - track-orientation, valid values: 0-5 (Track enum)
 
 * - p2 = (bit 9)   - 0 = build, 1 = remove tracks
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdRailTrackHelper
 
 */
 
CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 9), text);
 
}
 

	
 
/**
 
 * Build a train depot
 
@@ -978,13 +978,13 @@ CommandCost CmdRemoveRailroadTrack(TileI
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 *
 
 * @todo When checking for the tile slope,
 
 * distinguish between "Flat land required" and "land sloped in wrong direction"
 
 */
 
CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* check railtype and valid direction for depot (0 through 3), 4 in total */
 
	RailType railtype = Extract<RailType, 0, 6>(p1);
 
	if (!ValParamRailtype(railtype)) return CMD_ERROR;
 

	
 
	Slope tileh = GetTileSlope(tile);
 
@@ -1052,13 +1052,13 @@ CommandCost CmdBuildTrainDepot(TileIndex
 
 * - p1 = (bit 17)  - 1 = don't modify an existing signal but don't fail either, 0 = always set new signal type
 
 * @param p2 used for CmdBuildManySignals() to copy direction of first signal
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @todo p2 should be replaced by two bits for "along" and "against" the track.
 
 */
 
CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Track track = Extract<Track, 0, 3>(p1);
 
	bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed
 
	SignalVariant sigvar = (ctrl_pressed ^ HasBit(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC; // the signal variant of the new signal
 
	SignalType sigtype = Extract<SignalType, 5, 3>(p1); // the signal type of the new signal
 
	bool convert_signal = HasBit(p1, 8); // convert button pressed
 
@@ -1278,13 +1278,13 @@ static bool CheckSignalAutoFill(TileInde
 
 * - p2 = (bit  7- 9) - default signal type
 
 * - p2 = (bit 10)    - 0 = keep fixed distance, 1 = minimise gaps between signals
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 
	TileIndex start_tile = tile;
 

	
 
	Track track = Extract<Track, 0, 3>(p2);
 
	bool mode = HasBit(p2, 3);
 
@@ -1448,13 +1448,13 @@ static CommandCost CmdSignalTrackHelper(
 
 * - p2 = (bit  7- 9) - default signal type
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdSignalTrackHelper
 
 */
 
CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdSignalTrackHelper(tile, flags, p1, p2, text);
 
}
 

	
 
/**
 
 * Remove signals
 
@@ -1465,13 +1465,13 @@ CommandCost CmdBuildSignalTrack(TileInde
 
 *           - (bit  3)    - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
 
 *           - (bit  4)    - 0 = signals, 1 = semaphores
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Track track = Extract<Track, 0, 3>(p1);
 

	
 
	if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) || !HasTrack(tile, track)) {
 
		return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
 
	}
 
@@ -1540,13 +1540,13 @@ CommandCost CmdRemoveSingleSignal(TileIn
 
 * - p2 = (bit  7- 9) - default signal type
 
 * - p2 = (bit 24-31) - user defined signals_density
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see CmdSignalTrackHelper
 
 */
 
CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	return CmdSignalTrackHelper(tile, flags, p1, SetBit(p2, 5), text); // bit 5 is remove bit
 
}
 

	
 
/** Update power of train under which is the railtype being converted */
 
static Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
 
@@ -1568,13 +1568,13 @@ static Vehicle *UpdateTrainPowerProc(Veh
 
 * @param p2 various bitstuffed elements:
 
 * - p2 = (bit  0- 5) new railtype to convert to.
 
 * - p2 = (bit  6)    build diagonally or not.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	RailType totype = Extract<RailType, 0, 6>(p2);
 
	TileIndex area_start = p1;
 
	TileIndex area_end = tile;
 
	bool diagonal = HasBit(p2, 6);
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -607,13 +607,13 @@ static CommandCost CheckRoadSlope(Slope 
 
 *           bit 4..9 road type
 
 *           bit 11..12 disallowed directions to toggle
 
 * @param p2 the town that is building the road (0 if not applicable)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyID company = _current_company;
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

	
 
	RoadBits existing = ROAD_NONE;
 
	RoadBits other_bits = ROAD_NONE;
 
@@ -978,13 +978,13 @@ static bool CanConnectToRoad(TileIndex t
 
 * - p2 = (bit 11) - defines two different behaviors for this command:
 
 *      - 0 = Build up to an obstacle. Do not build the first and last roadbits unless they can be connected to something, or if we are building a single tile
 
 *      - 1 = Fail if an obstacle is found. Always take into account bit 0 and 1. This behavior is used for scripts
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	DisallowedRoadDirections drd = DRD_NORTHBOUND;
 

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

	
 
@@ -1083,13 +1083,13 @@ CommandCost CmdBuildLongRoad(TileIndex s
 
 * - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
 
 * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
 
 * - p2 = (bit 3 - 8) - road type
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

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

	
 
	TileIndex end_tile = p1;
 
@@ -1160,13 +1160,13 @@ CommandCost CmdRemoveLongRoad(TileIndex 
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 *
 
 * @todo When checking for the tile slope,
 
 * distinguish between "Flat land required" and "land sloped in wrong direction"
 
 */
 
CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	DiagDirection dir = Extract<DiagDirection, 0, 2>(p1);
 

	
 
	RoadType rt = Extract<RoadType, 2, 6>(p1);
 
	if (!ValParamRoadType(rt)) return CMD_ERROR;
 

	
 
@@ -2347,13 +2347,13 @@ static void ConvertRoadTypeOwner(TileInd
 
 * @param p1 start tile of drag
 
 * @param p2 various bitstuffed elements:
 
 * - p2 = (bit  0..5) new roadtype to convert to.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	RoadType to_type = Extract<RoadType, 0, 6>(p2);
 

	
 
	TileIndex area_start = p1;
 
	TileIndex area_end = tile;
 

	
src/roadveh_cmd.cpp
Show inline comments
 
@@ -363,13 +363,13 @@ bool RoadVehicle::FindClosestDepot(TileI
 
 * @param flags operation to perform
 
 * @param p1 vehicle ID to turn
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	RoadVehicle *v = RoadVehicle::GetIfValid(p1);
 
	if (v == nullptr) return CMD_ERROR;
 

	
 
	if (!v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
src/script/api/script_object.cpp
Show inline comments
 
@@ -326,13 +326,13 @@ ScriptObject::ActiveInstance::~ActiveIns
 
	if (GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = UINT32_MAX;
 

	
 
	/* Store the command for command callback validation. */
 
	if (!estimate_only && _networking && !_generating_world) SetLastCommand(tile, p1, p2, cmd);
 

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

	
 
	/* We failed; set the error and bail out */
 
	if (res.Failed()) {
 
		SetLastError(ScriptError::StringToError(res.GetErrorMessage()));
 
		return false;
 
	}
src/settings.cpp
Show inline comments
 
@@ -1717,13 +1717,13 @@ void IntSettingDesc::ChangeValue(const v
 
 * @param p2 the new value for the setting
 
 * The new value is properly clamped to its minimum/maximum when setting
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 * @see _settings
 
 */
 
CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	const SettingDesc *sd = GetSettingDescription(p1);
 

	
 
	if (sd == nullptr) return CMD_ERROR;
 
	if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR;
 
	if (!sd->IsIntSetting()) return CMD_ERROR;
 
@@ -1744,13 +1744,13 @@ CommandCost CmdChangeSetting(TileIndex t
 
 * @param p1 the index of the setting in the _company_settings array which identifies it
 
 * @param p2 the new value for the setting
 
 * The new value is properly clamped to its minimum/maximum when setting
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	const SettingDesc *sd = GetCompanySettingDescription(p1);
 
	if (sd == nullptr) return CMD_ERROR;
 
	if (!sd->IsIntSetting()) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
src/signs_cmd.cpp
Show inline comments
 
@@ -33,30 +33,30 @@ SignID _new_sign_id;
 
 * @param flags type of operation
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* Try to locate a new sign */
 
	if (!Sign::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_SIGNS);
 

	
 
	/* Check sign text length if any */
 
	if (!StrEmpty(text) && Utf8StringLength(text) >= MAX_LENGTH_SIGN_NAME_CHARS) return CMD_ERROR;
 
	if (Utf8StringLength(text) >= MAX_LENGTH_SIGN_NAME_CHARS) return CMD_ERROR;
 

	
 
	/* When we execute, really make the sign */
 
	if (flags & DC_EXEC) {
 
		Sign *si = new Sign(_game_mode == GM_EDITOR ? OWNER_DEITY : _current_company);
 
		int x = TileX(tile) * TILE_SIZE;
 
		int y = TileY(tile) * TILE_SIZE;
 

	
 
		si->x = x;
 
		si->y = y;
 
		si->z = GetSlopePixelZ(x, y);
 
		if (!StrEmpty(text)) {
 
		if (!text.empty()) {
 
			si->name = text;
 
		}
 
		si->UpdateVirtCoord();
 
		InvalidateWindowData(WC_SIGN_LIST, 0, 0);
 
		_new_sign_id = si->index;
 
	}
 
@@ -72,20 +72,20 @@ CommandCost CmdPlaceSign(TileIndex tile,
 
 * @param flags type of operation
 
 * @param p1 index of the sign to be renamed/removed
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Sign *si = Sign::GetIfValid(p1);
 
	if (si == nullptr) return CMD_ERROR;
 
	if (si->owner == OWNER_DEITY && _current_company != OWNER_DEITY && _game_mode != GM_EDITOR) return CMD_ERROR;
 

	
 
	/* Rename the signs when empty, otherwise remove it */
 
	if (!StrEmpty(text)) {
 
	if (!text.empty()) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_SIGN_NAME_CHARS) return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
			/* Assign the new one */
 
			si->name = text;
 
			if (_game_mode != GM_EDITOR) si->owner = _current_company;
src/station_cmd.cpp
Show inline comments
 
@@ -1247,13 +1247,13 @@ static void RestoreTrainReservation(Trai
 
 * - p2 = (bit  0- 7) - custom station class
 
 * - p2 = (bit  8-15) - custom station id
 
 * - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* Unpack parameters */
 
	RailType rt    = Extract<RailType, 0, 6>(p1);
 
	Axis axis      = Extract<Axis, 6, 1>(p1);
 
	byte numtracks = GB(p1,  8, 8);
 
	byte plat_len  = GB(p1, 16, 8);
 
@@ -1656,13 +1656,13 @@ CommandCost RemoveFromRailBaseStation(Ti
 
 * @param p1 start_tile
 
 * @param p2 various bitstuffed elements
 
 * - p2 = bit 0 - if set keep the rail
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	TileIndex end = p1 == 0 ? start : p1;
 
	if (start >= MapSize() || end >= MapSize()) return CMD_ERROR;
 

	
 
	TileArea ta(start, end);
 
	std::vector<Station *> affected_stations;
 
@@ -1690,13 +1690,13 @@ CommandCost CmdRemoveFromRailStation(Til
 
 * @param p1 start_tile
 
 * @param p2 various bitstuffed elements
 
 * - p2 = bit 0 - if set keep the rail
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	TileIndex end = p1 == 0 ? start : p1;
 
	if (start >= MapSize() || end >= MapSize()) return CMD_ERROR;
 

	
 
	TileArea ta(start, end);
 
	std::vector<Waypoint *> affected_stations;
 
@@ -1829,13 +1829,13 @@ static CommandCost FindJoiningRoadStop(S
 
 *           bit 3: #Axis of the road for drive-through stops.
 
 *           bit 5..10: The roadtype.
 
 *           bit 16..31: Station ID to join (NEW_STATION if build new one).
 
 * @param text Unused.
 
 * @return The cost of this operation or an error.
 
 */
 
CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	bool type = HasBit(p2, 0);
 
	bool is_drive_through = HasBit(p2, 1);
 
	RoadType rt = Extract<RoadType, 5, 6>(p2);
 
	if (!ValParamRoadType(rt)) return CMD_ERROR;
 
	StationID station_to_join = GB(p2, 16, 16);
 
@@ -2079,13 +2079,13 @@ static CommandCost RemoveRoadStop(TileIn
 
 *           bit 8..15: Height of the removal area.
 
 * @param p2 bit 0: 0 For bus stops, 1 for truck stops.
 
 * @param p2 bit 1: 0 to keep roads of all drive-through stops, 1 to remove them.
 
 * @param text Unused.
 
 * @return The cost of this operation or an error.
 
 */
 
CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	uint8 width = (uint8)GB(p1, 0, 8);
 
	uint8 height = (uint8)GB(p1, 8, 8);
 
	bool keep_drive_through_roads = !HasBit(p2, 1);
 

	
 
	/* Check for incorrect width / height. */
 
@@ -2238,13 +2238,13 @@ void UpdateAirportsNoise()
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit     0) - allow airports directly adjacent to other airports.
 
 * - p2 = (bit 16-31) - station ID to join (NEW_STATION if build new one)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	StationID station_to_join = GB(p2, 16, 16);
 
	bool reuse = (station_to_join != NEW_STATION);
 
	if (!reuse) station_to_join = INVALID_STATION;
 
	bool distant_join = (station_to_join != INVALID_STATION);
 
	byte airport_type = GB(p1, 0, 8);
 
@@ -2455,13 +2455,13 @@ static CommandCost RemoveAirport(TileInd
 
 * @param flags Operation to perform.
 
 * @param p1 Station ID of the airport.
 
 * @param p2 Unused.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (!Station::IsValidID(p1)) return CMD_ERROR;
 
	Station *st = Station::Get(p1);
 

	
 
	if (!(st->facilities & FACIL_AIRPORT) || st->owner == OWNER_NONE) return CMD_ERROR;
 

	
 
@@ -2510,13 +2510,13 @@ static const byte _dock_h_chk[4] = { 1, 
 
 * @param flags operation to perform
 
 * @param p1 (bit 0) - allow docks directly adjacent to other docks.
 
 * @param p2 bit 16-31: station ID to join (NEW_STATION if build new one)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	StationID station_to_join = GB(p2, 16, 16);
 
	bool reuse = (station_to_join != NEW_STATION);
 
	if (!reuse) station_to_join = INVALID_STATION;
 
	bool distant_join = (station_to_join != INVALID_STATION);
 

	
 
@@ -3930,21 +3930,21 @@ static bool IsUniqueStationName(const st
 
 * @param flags operation to perform
 
 * @param p1 station ID that is to be renamed
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Station *st = Station::GetIfValid(p1);
 
	if (st == nullptr) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(st->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_STATION_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueStationName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
src/story.cpp
Show inline comments
 
@@ -201,13 +201,13 @@ bool StoryPageButtonData::ValidateVehicl
 
 * @param p1 various bitstuffed elements
 
 * - p1 = (bit  0 -  7) - Company for which this story page belongs to.
 
 * @param p2 unused.
 
 * @param text Title of the story page. Null is allowed in which case a generic page title is provided by OpenTTD.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (!StoryPage::CanAllocateItem()) return CMD_ERROR;
 

	
 
	CompanyID company = (CompanyID)GB(p1, 0, 8);
 

	
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
@@ -220,16 +220,16 @@ CommandCost CmdCreateStoryPage(TileIndex
 
		}
 

	
 
		StoryPage *s = new StoryPage();
 
		s->sort_value = _story_page_next_sort_value;
 
		s->date = _date;
 
		s->company = company;
 
		if (StrEmpty(text)) {
 
		if (text.empty()) {
 
			s->title = nullptr;
 
		} else {
 
			s->title = stredup(text);
 
			s->title = stredup(text.c_str());
 
		}
 

	
 
		InvalidateWindowClassesData(WC_STORY_BOOK, -1);
 
		if (StoryPage::GetNumItems() == 1) InvalidateWindowData(WC_MAIN_TOOLBAR, 0);
 

	
 
		_new_story_page_id = s->index;
 
@@ -247,13 +247,13 @@ CommandCost CmdCreateStoryPage(TileIndex
 
 * - p1 = (bit  0 -  15) - The page which the element belongs to.
 
 *        (bit  16 -  23) - Page element type
 
 * @param p2 Id of referenced object
 
 * @param text Text content in case it is a text or location page element
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (!StoryPageElement::CanAllocateItem()) return CMD_ERROR;
 

	
 
	StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
 
	StoryPageElementType type = Extract<StoryPageElementType, 16, 8>(p1);
 

	
 
@@ -263,25 +263,25 @@ CommandCost CmdCreateStoryPageElement(Ti
 
		if (iter->page == page_id) element_count++;
 
	}
 
	if (element_count >= 128) return CMD_ERROR;
 

	
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
 
	if (!VerifyElementContentParameters(page_id, type, tile, p2, text)) return CMD_ERROR;
 
	if (!VerifyElementContentParameters(page_id, type, tile, p2, text.c_str())) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		if (_story_page_element_pool.items == 0) {
 
			/* Initialize the next sort value variable. */
 
			_story_page_element_next_sort_value = 0;
 
		}
 

	
 
		StoryPageElement *pe = new StoryPageElement();
 
		pe->sort_value = _story_page_element_next_sort_value;
 
		pe->type = type;
 
		pe->page = page_id;
 
		UpdateElement(*pe, tile, p2, text);
 
		UpdateElement(*pe, tile, p2, text.c_str());
 

	
 
		InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
 

	
 
		_new_story_page_element_id = pe->index;
 
		_story_page_element_next_sort_value++;
 
	}
 
@@ -297,27 +297,27 @@ CommandCost CmdCreateStoryPageElement(Ti
 
 * - p1 = (bit  0 -  15) - The page element to update.
 
 *        (bit  16 -  31) - unused
 
 * @param p2 Id of referenced object
 
 * @param text Text content in case it is a text or location page element
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16);
 

	
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
 

	
 
	StoryPageElement *pe = StoryPageElement::Get(page_element_id);
 
	StoryPageID page_id = pe->page;
 
	StoryPageElementType type = pe->type;
 

	
 
	if (!VerifyElementContentParameters(page_id, type, tile, p2, text)) return CMD_ERROR;
 
	if (!VerifyElementContentParameters(page_id, type, tile, p2, text.c_str())) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		UpdateElement(*pe, tile, p2, text);
 
		UpdateElement(*pe, tile, p2, text.c_str());
 
		InvalidateWindowClassesData(WC_STORY_BOOK, pe->page);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
@@ -327,25 +327,25 @@ CommandCost CmdUpdateStoryPageElement(Ti
 
 * @param flags type of operation
 
 * @param p1 = (bit 0 - 15) - StoryPageID to update.
 
 * @param p2 unused
 
 * @param text title text of the story page.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
 
	if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		StoryPage *p = StoryPage::Get(page_id);
 
		free(p->title);
 
		if (StrEmpty(text)) {
 
		if (text.empty()) {
 
			p->title = nullptr;
 
		} else {
 
			p->title = stredup(text);
 
			p->title = stredup(text.c_str());
 
		}
 

	
 
		InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
 
	}
 

	
 
	return CommandCost();
 
@@ -357,13 +357,13 @@ CommandCost CmdSetStoryPageTitle(TileInd
 
 * @param flags type of operation
 
 * @param p1 = (bit 0 - 15) - StoryPageID to update.
 
 * @param p2 = (bit 0 - 31) - date
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
 
	if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
 
	Date date = (Date)p2;
 

	
 
@@ -384,13 +384,13 @@ CommandCost CmdSetStoryPageDate(TileInde
 
 * @param flags type of operation
 
 * @param p1 = (bit 0 - 15) - StoryPageID to show.
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	StoryPageID page_id = (StoryPageID)GB(p1, 0, 16);
 
	if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -406,13 +406,13 @@ CommandCost CmdShowStoryPage(TileIndex t
 
 * @param flags type of operation
 
 * @param p1 = (bit 0 - 15) - StoryPageID to remove.
 
 * @param p2 unused.
 
 * @param text unused.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	StoryPageID page_id = (StoryPageID)p1;
 
	if (!StoryPage::IsValidID(page_id)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -439,13 +439,13 @@ CommandCost CmdRemoveStoryPage(TileIndex
 
 * @param flags type of operation
 
 * @param p1 = (bit 0 - 15) - StoryPageElementID to remove.
 
 * @param p2 unused.
 
 * @param text unused.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	StoryPageElementID page_element_id = (StoryPageElementID)p1;
 
	if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -466,13 +466,13 @@ CommandCost CmdRemoveStoryPageElement(Ti
 
 * @param flags  Type of operation.
 
 * @param p1     Bit 0..15 = story page element id of button.
 
 * @param p2     ID of selected item for buttons that select an item (e.g. vehicle), otherwise unused.
 
 * @param text   Unused.
 
 * @return The cost of the operation, or an error.
 
 */
 
CommandCost CmdStoryPageButton(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdStoryPageButton(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16);
 

	
 
	if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR;
 
	const StoryPageElement *const pe = StoryPageElement::Get(page_element_id);
 

	
src/subsidy.cpp
Show inline comments
 
@@ -237,13 +237,13 @@ void CreateSubsidy(CargoID cid, SourceTy
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit  0 -  7) - SourceType of destination.
 
 * - p2 = (bit  8 - 23) - SourceID of destination.
 
 * @param text unused.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCreateSubsidy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCreateSubsidy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (!Subsidy::CanAllocateItem()) return CMD_ERROR;
 

	
 
	CargoID cid = GB(p1, 24, 8);
 
	SourceType src_type = (SourceType)GB(p1, 0, 8);
 
	SourceID src = GB(p1, 8, 16);
src/terraform_cmd.cpp
Show inline comments
 
@@ -181,13 +181,13 @@ static CommandCost TerraformTileHeight(T
 
 * @param flags for this command type
 
 * @param p1 corners to terraform (SLOPE_xxx)
 
 * @param p2 direction; eg up (non-zero) or down (zero)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	_terraform_err_tile = INVALID_TILE;
 

	
 
	CommandCost total_cost(EXPENSES_CONSTRUCTION);
 
	int direction = (p2 != 0 ? 1 : -1);
 
	TerraformerState ts;
 
@@ -338,13 +338,13 @@ CommandCost CmdTerraformLand(TileIndex t
 
 * @param p2 various bitstuffed data.
 
 *  bit      0: Whether to use the Orthogonal (0) or Diagonal (1) iterator.
 
 *  bits 1 - 2: Mode of leveling \c LevelMode.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (p1 >= MapSize()) return CMD_ERROR;
 

	
 
	_terraform_err_tile = INVALID_TILE;
 

	
 
	/* remember level height */
src/timetable_cmd.cpp
Show inline comments
 
@@ -94,13 +94,13 @@ static void ChangeTimetable(Vehicle *v, 
 
 * @param p2 The amount of time to wait.
 
 * - p2 = (bit  0-15) - The data to modify as specified by p1 bits 28-29.
 
 *                      0 to clear times, UINT16_MAX to clear speed limit.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh = GB(p1, 0, 20);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
	if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
@@ -188,13 +188,13 @@ CommandCost CmdChangeTimetable(TileIndex
 
 * @param p1 Various bitstuffed elements
 
 * - p1 = (bit  0-19) - Vehicle with the orders to change.
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh = GB(p1, 0, 20);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
	if (v == nullptr || !v->IsPrimaryVehicle() || v->orders.list == nullptr) return CMD_ERROR;
 

	
 
@@ -255,13 +255,13 @@ static bool VehicleTimetableSorter(Vehic
 
 * - p2 = (bit 0-19) - Vehicle ID.
 
 * - p2 = (bit 20)   - Set to 1 to set timetable start for all vehicles sharing this order
 
 * @param p2 The timetable start date.
 
 * @param text Not used.
 
 * @return The error or cost of the operation.
 
 */
 
CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	bool timetable_all = HasBit(p1, 20);
 
	Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
 
	if (v == nullptr || !v->IsPrimaryVehicle() || v->orders.list == nullptr) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
@@ -320,13 +320,13 @@ CommandCost CmdSetTimetableStart(TileInd
 
 * @param p2 Various bitstuffed elements
 
 * - p2 = (bit 0) - Set to 1 to enable, 0 to disable autofill.
 
 * - p2 = (bit 1) - Set to 1 to preserve waiting times in non-destructive mode
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID veh = GB(p1, 0, 20);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
	if (v == nullptr || !v->IsPrimaryVehicle() || v->orders.list == nullptr) return CMD_ERROR;
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -1925,13 +1925,13 @@ static bool IsUniqueTownName(const std::
 
 *            3..5 town road layout (@see TownLayout)
 
 *               6 use random location (randomize \c tile )
 
 * @param p2 town name parts
 
 * @param text Custom name for the town. If empty, the town name parts will be used.
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	TownSize size = Extract<TownSize, 0, 2>(p1);
 
	bool city = HasBit(p1, 2);
 
	TownLayout layout = Extract<TownLayout, 3, 3>(p1);
 
	TownNameParams par(_settings_game.game_creation.town_name);
 
	bool random = HasBit(p1, 6);
 
@@ -1950,13 +1950,13 @@ CommandCost CmdFoundTown(TileIndex tile,
 
		}
 
	} else if (_current_company == OWNER_DEITY && random) {
 
		/* Random parameter is not allowed for Game Scripts. */
 
		return CMD_ERROR;
 
	}
 

	
 
	if (StrEmpty(text)) {
 
	if (text.empty()) {
 
		/* If supplied name is empty, townnameparts has to generate unique automatic name */
 
		if (!VerifyTownName(townnameparts, &par)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	} else {
 
		/* If name is not empty, it has to be unique custom name */
 
		if (Utf8StringLength(text) >= MAX_LENGTH_TOWN_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueTownName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
@@ -2000,13 +2000,13 @@ CommandCost CmdFoundTown(TileIndex tile,
 
			t = new Town(tile);
 
			DoCreateTown(t, tile, townnameparts, size, city, layout, true);
 
		}
 
		UpdateNearestTownForRoadTiles(false);
 
		old_generating_world.Restore();
 

	
 
		if (t != nullptr && !StrEmpty(text)) {
 
		if (t != nullptr && !text.empty()) {
 
			t->name = text;
 
			t->UpdateVirtCoord();
 
		}
 

	
 
		if (_game_mode != GM_EDITOR) {
 
			/* 't' can't be nullptr since 'random' is false outside scenedit */
 
@@ -2740,18 +2740,18 @@ void ClearTownHouse(Town *t, TileIndex t
 
 * @param flags type of operation
 
 * @param p1 town ID to rename
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Town *t = Town::GetIfValid(p1);
 
	if (t == nullptr) return CMD_ERROR;
 

	
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_TOWN_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueTownName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
@@ -2793,13 +2793,13 @@ const CargoSpec *FindFirstCargoWithTownE
 
 * - p1 = (bit  0 - 15) - Town ID to cargo game of.
 
 * - p1 = (bit 16 - 23) - TownEffect to change the game of.
 
 * @param p2 The new goal value.
 
 * @param text Unused.
 
 * @return Empty cost or an error.
 
 */
 
CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 

	
 
	TownEffect te = (TownEffect)GB(p1, 16, 8);
 
	if (te < TE_BEGIN || te >= TE_END) return CMD_ERROR;
 

	
 
@@ -2826,21 +2826,21 @@ CommandCost CmdTownCargoGoal(TileIndex t
 
 * @param flags Type of operation.
 
 * @param p1 Town ID to change the text of.
 
 * @param p2 Unused.
 
 * @param text The new text (empty to remove the text).
 
 * @return Empty cost or an error.
 
 */
 
CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	Town *t = Town::GetIfValid(p1);
 
	if (t == nullptr) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		t->text.clear();
 
		if (!StrEmpty(text)) t->text = text;
 
		if (!text.empty()) t->text = text;
 
		InvalidateWindowData(WC_TOWN_VIEW, p1);
 
	}
 

	
 
	return CommandCost();
 
}
 

	
 
@@ -2850,13 +2850,13 @@ CommandCost CmdTownSetText(TileIndex til
 
 * @param flags Type of operation.
 
 * @param p1 Town ID to cargo game of.
 
 * @param p2 Amount of days between growth, or TOWN_GROWTH_RATE_NONE, or 0 to reset custom growth rate.
 
 * @param text Unused.
 
 * @return Empty cost or an error.
 
 */
 
CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	if (GB(p2, 16, 16) != 0) return CMD_ERROR;
 

	
 
	Town *t = Town::GetIfValid(p1);
 
	if (t == nullptr) return CMD_ERROR;
 
@@ -2890,13 +2890,13 @@ CommandCost CmdTownGrowthRate(TileIndex 
 
 * @param flags Type of operation.
 
 * @param p1 Bit 0..15 = Town ID to change, bit 16..23 = Company ID to change.
 
 * @param p2 Bit 0..15 = New rating of company (signed int16).
 
 * @param text Unused.
 
 * @return Empty cost or an error.
 
 */
 
CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 

	
 
	TownID town_id = (TownID)GB(p1, 0, 16);
 
	Town *t = Town::GetIfValid(town_id);
 
	if (t == nullptr) return CMD_ERROR;
 
@@ -2919,13 +2919,13 @@ CommandCost CmdTownRating(TileIndex tile
 
 * @param flags Type of operation.
 
 * @param p1 Town ID to expand.
 
 * @param p2 Amount to grow, or 0 to grow a random size up to the current amount of houses.
 
 * @param text Unused.
 
 * @return Empty cost or an error.
 
 */
 
CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY) return CMD_ERROR;
 
	Town *t = Town::GetIfValid(p1);
 
	if (t == nullptr) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -2959,13 +2959,13 @@ CommandCost CmdExpandTown(TileIndex tile
 
 * @param flags Type of operation.
 
 * @param p1 Town ID to delete.
 
 * @param p2 Unused.
 
 * @param text Unused.
 
 * @return Empty cost or an error.
 
 */
 
CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_game_mode != GM_EDITOR && !_generating_world) return CMD_ERROR;
 
	Town *t = Town::GetIfValid(p1);
 
	if (t == nullptr) return CMD_ERROR;
 

	
 
	/* Stations refer to towns. */
 
@@ -3348,13 +3348,13 @@ uint GetMaskOfTownActions(int *nump, Com
 
 * @param flags type of operation
 
 * @param p1 town to do the action at
 
 * @param p2 action to perform, @see _town_action_proc for the list of available actions
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Town *t = Town::GetIfValid(p1);
 
	if (t == nullptr || p2 >= lengthof(_town_action_proc)) return CMD_ERROR;
 

	
 
	if (!HasBit(GetMaskOfTownActions(nullptr, _current_company, t), p2)) return CMD_ERROR;
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -1157,13 +1157,13 @@ static void NormaliseTrainHead(Train *he
 
 * - p1 (bit  0 - 19) source vehicle index
 
 * - p1 (bit      20) move all vehicles following the source vehicle
 
 * @param p2 what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleID s = GB(p1, 0, 20);
 
	VehicleID d = GB(p2, 0, 20);
 
	bool move_chain = HasBit(p1, 20);
 

	
 
	Train *src = Train::GetIfValid(s);
 
@@ -1895,13 +1895,13 @@ void ReverseTrainDirection(Train *v)
 
 * @param flags type of operation
 
 * @param p1 train to reverse
 
 * @param p2 if true, reverse a unit in a train (needs to be in a depot)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Train *v = Train::GetIfValid(p1);
 
	if (v == nullptr) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 
@@ -1968,13 +1968,13 @@ CommandCost CmdReverseTrainDirection(Til
 
 * @param flags type of operation
 
 * @param p1 train to ignore the red signal
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Train *t = Train::GetIfValid(p1);
 
	if (t == nullptr) return CMD_ERROR;
 

	
 
	if (!t->IsPrimaryVehicle()) return CMD_ERROR;
 

	
src/tree_cmd.cpp
Show inline comments
 
@@ -375,13 +375,13 @@ void GenerateTrees()
 
 * @param flags type of operation
 
 * @param p1 tree type, TREE_INVALID means random.
 
 * @param p2 start tile of area-drag of tree plantation
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdPlantTree(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	StringID msg = INVALID_STRING_ID;
 
	CommandCost cost(EXPENSES_OTHER);
 
	const byte tree_to_plant = GB(p1, 0, 8); // We cannot use Extract as min and max are climate specific.
 

	
 
	if (p2 >= MapSize()) return CMD_ERROR;
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -254,13 +254,13 @@ static Money TunnelBridgeClearCost(TileI
 
 * - p2 = (bit  0- 7) - bridge type (hi bh)
 
 * - p2 = (bit  8-13) - rail type or road types.
 
 * - p2 = (bit 15-16) - transport type.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyID company = _current_company;
 

	
 
	RailType railtype = INVALID_RAILTYPE;
 
	RoadType roadtype = INVALID_ROADTYPE;
 

	
 
@@ -627,13 +627,13 @@ CommandCost CmdBuildBridge(TileIndex end
 
 * @param p1 bit 0-5 railtype or roadtype
 
 *           bit 8-9 transport type
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CompanyID company = _current_company;
 

	
 
	TransportType transport_type = Extract<TransportType, 8, 2>(p1);
 
	RailType railtype = INVALID_RAILTYPE;
 
	RoadType roadtype = INVALID_ROADTYPE;
src/vehicle_cmd.cpp
Show inline comments
 
@@ -69,13 +69,13 @@ const uint32 _send_to_depot_proc_table[]
 

	
 
CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v);
 
CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v);
 
CommandCost CmdBuildShip       (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v);
 
CommandCost CmdBuildAircraft   (TileIndex tile, DoCommandFlag flags, const Engine *e, uint16 data, Vehicle **v);
 

	
 
CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
 
CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text);
 

	
 
/**
 
 * Build a vehicle.
 
 * @param tile tile of depot where the vehicle is built
 
 * @param flags for command
 
 * @param p1 various bitstuffed data
 
@@ -83,13 +83,13 @@ CommandCost CmdRefitVehicle(TileIndex ti
 
 *  bits 16-23: vehicle type specific bits passed on to the vehicle build functions.
 
 *  bits 24-31: refit cargo type.
 
 * @param p2 User
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* Elementary check for valid location. */
 
	if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return CMD_ERROR;
 

	
 
	VehicleType type = GetDepotVehicleType(tile);
 

	
 
@@ -151,13 +151,13 @@ CommandCost CmdBuildVehicle(TileIndex ti
 
			v->unitnumber = unit_num;
 
			v->value      = value.GetCost();
 
		}
 

	
 
		if (refitting) {
 
			/* Refit only one vehicle. If we purchased an engine, it may have gained free wagons. */
 
			value.AddCost(CmdRefitVehicle(tile, flags, v->index, cargo | (1 << 16), nullptr));
 
			value.AddCost(CmdRefitVehicle(tile, flags, v->index, cargo | (1 << 16), {}));
 
		} else {
 
			/* Fill in non-refitted capacities */
 
			_returned_refit_capacity = e->GetDisplayDefaultCapacity(&_returned_mail_refit_capacity);
 
		}
 

	
 
		if (flags & DC_EXEC) {
 
@@ -203,13 +203,13 @@ CommandCost CmdSellRailWagon(DoCommandFl
 
 *  bits 20-30: vehicle type specific bits passed on to the vehicle build functions.
 
 *  bit     31: make a backup of the vehicle's order (if an engine).
 
 * @param p2 User.
 
 * @param text unused.
 
 * @return the cost of this operation or an error.
 
 */
 
CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
 
	if (v == nullptr) return CMD_ERROR;
 

	
 
	Vehicle *front = v->First();
 

	
 
@@ -465,13 +465,13 @@ static CommandCost RefitVehicle(Vehicle 
 
 *                      Only used if "refit only this vehicle" is false.
 
 * - p2 = (bit 24)     - Automatic refitting.
 
 * - p2 = (bit 25)     - Refit only this vehicle. Used only for cloning vehicles.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Vehicle *v = Vehicle::GetIfValid(p1);
 
	if (v == nullptr) return CMD_ERROR;
 

	
 
	/* Don't allow disasters and sparks and such to be refitted.
 
	 * We cannot check for IsPrimaryVehicle as autoreplace also refits in free wagon chains. */
 
@@ -553,13 +553,13 @@ CommandCost CmdRefitVehicle(TileIndex ti
 
 * @param flags type of operation
 
 * @param p1 vehicle to start/stop, don't forget to change CcStartStopVehicle if you modify this!
 
 * @param p2 bit 0: Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety)
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* Disable the effect of p2 bit 0, when DC_AUTOREPLACE is not set */
 
	if ((flags & DC_AUTOREPLACE) == 0) SetBit(p2, 0);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(p1);
 
	if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
 
@@ -637,13 +637,13 @@ CommandCost CmdStartStopVehicle(TileInde
 
 *   - bit 0 set = start vehicles, unset = stop vehicles
 
 *   - bit 1 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
 
 * @param p2 packed VehicleListIdentifier
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleList list;
 
	bool do_start = HasBit(p1, 0);
 
	bool vehicle_list_window = HasBit(p1, 1);
 

	
 
	VehicleListIdentifier vli;
 
@@ -677,13 +677,13 @@ CommandCost CmdMassStartStopVehicle(Tile
 
 * @param flags type of operation
 
 * @param p1 Vehicle type
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleList list;
 

	
 
	CommandCost cost(EXPENSES_NEW_VEHICLES);
 
	VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
 

	
 
@@ -715,13 +715,13 @@ CommandCost CmdDepotSellAllVehicles(Tile
 
 * @param flags type of operation
 
 * @param p1 Type of vehicle
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	VehicleList list;
 
	CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES);
 
	VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
 

	
 
	if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
 
@@ -819,13 +819,13 @@ static void CloneVehicleName(const Vehic
 
 * @param flags type of operation
 
 * @param p1 the original vehicle's index
 
 * @param p2 1 = shared orders, else copied orders
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	CommandCost total_cost(EXPENSES_NEW_VEHICLES);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(p1);
 
	if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
 
	Vehicle *v_front = v;
 
@@ -1041,13 +1041,13 @@ static CommandCost SendAllVehiclesToDepo
 
 * - p1 0-20: bitvehicle ID to send to the depot
 
 * - p1 bits 25-8  - DEPOT_ flags (see vehicle_type.h)
 
 * @param p2 packed VehicleListIdentifier.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (p1 & DEPOT_MASS_SEND) {
 
		/* Mass goto depot requested */
 
		VehicleListIdentifier vli;
 
		if (!vli.UnpackIfValid(p2)) return CMD_ERROR;
 
		return SendAllVehiclesToDepot(flags, (p1 & DEPOT_SERVICE) != 0, vli);
 
@@ -1066,21 +1066,21 @@ CommandCost CmdSendVehicleToDepot(TileIn
 
 * @param flags type of operation
 
 * @param p1 vehicle ID to name
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Vehicle *v = Vehicle::GetIfValid(p1);
 
	if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_VEHICLE_NAME_CHARS) return CMD_ERROR;
 
		if (!(flags & DC_AUTOREPLACE) && !IsUniqueVehicleName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
 
@@ -1107,13 +1107,13 @@ CommandCost CmdRenameVehicle(TileIndex t
 
 * - p2 = (bit  0-15) - new service interval
 
 * - p2 = (bit 16)    - service interval is custom flag
 
 * - p2 = (bit 17)    - service interval is percentage flag
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Vehicle *v = Vehicle::GetIfValid(p1);
 
	if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
src/viewport.cpp
Show inline comments
 
@@ -3469,13 +3469,13 @@ void InitializeSpriteSorter()
 
 * @param flags type of operation
 
 * @param p1 ViewportScrollTarget of scroll target
 
 * @param p2 company or client id depending on the target
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (_current_company != OWNER_DEITY) return CMD_ERROR;
 
	ViewportScrollTarget target = (ViewportScrollTarget)p1;
 
	switch (target) {
 
		case VST_EVERYONE:
 
			break;
src/water_cmd.cpp
Show inline comments
 
@@ -95,13 +95,13 @@ static void MarkCanalsAndRiversAroundDir
 
 * @param flags type of operation
 
 * @param p1 bit 0 depot orientation (Axis)
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Axis axis = Extract<Axis, 0, 1>(p1);
 

	
 
	TileIndex tile2 = tile + (axis == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1));
 

	
 
	if (!HasTileWaterGround(tile) || !HasTileWaterGround(tile2)) {
 
@@ -414,13 +414,13 @@ static CommandCost RemoveLock(TileIndex 
 
 * @param flags type of operation
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile));
 
	if (dir == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION);
 

	
 
	return DoBuildLock(tile, dir, flags);
 
}
 
@@ -440,13 +440,13 @@ bool RiverModifyDesertZone(TileIndex til
 
 * @param p2 various bitstuffed data
 
 *  bits  0-1: waterclass to build. sea and river can only be built in scenario editor
 
 *  bit     2: Whether to use the Orthogonal (0) or Diagonal (1) iterator.
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	WaterClass wc = Extract<WaterClass, 0, 2>(p2);
 
	if (p1 >= MapSize() || wc == WATER_CLASS_INVALID) return CMD_ERROR;
 

	
 
	/* Outside of the editor you can only build canals, not oceans */
 
	if (wc != WATER_CLASS_CANAL && _game_mode != GM_EDITOR) return CMD_ERROR;
src/waypoint_cmd.cpp
Show inline comments
 
@@ -171,13 +171,13 @@ extern CommandCost CanExpandRailStation(
 
 * @param p2 various bitstuffed elements
 
 * - p2 = (bit  0- 7) - custom station class
 
 * - p2 = (bit  8-15) - custom station id
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	/* Unpack parameters */
 
	Axis axis      = Extract<Axis, 6, 1>(p1);
 
	byte width     = GB(p1,  8, 8);
 
	byte height    = GB(p1, 16, 8);
 
	bool adjacent  = HasBit(p1, 24);
 
@@ -299,13 +299,13 @@ CommandCost CmdBuildRailWaypoint(TileInd
 
 * @param flags operation to perform
 
 * @param p1 unused
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	if (tile == 0 || !HasTileWaterGround(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 
	if (IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
 

	
 
	if (!IsTileFlat(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
 

	
 
@@ -410,23 +410,23 @@ static bool IsUniqueWaypointName(const s
 
 * @param flags type of operation
 
 * @param p1 id of waypoint
 
 * @param p2 unused
 
 * @param text the new name or an empty string when resetting to the default
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const std::string &text)
 
{
 
	Waypoint *wp = Waypoint::GetIfValid(p1);
 
	if (wp == nullptr) return CMD_ERROR;
 

	
 
	if (wp->owner != OWNER_NONE) {
 
		CommandCost ret = CheckOwnership(wp->owner);
 
		if (ret.Failed()) return ret;
 
	}
 

	
 
	bool reset = StrEmpty(text);
 
	bool reset = text.empty();
 

	
 
	if (!reset) {
 
		if (Utf8StringLength(text) >= MAX_LENGTH_STATION_NAME_CHARS) return CMD_ERROR;
 
		if (!IsUniqueWaypointName(text)) return_cmd_error(STR_ERROR_NAME_MUST_BE_UNIQUE);
 
	}
 

	
0 comments (0 inline, 0 general)