(svn r14754) -Codechange: get rid of _cmd_text and just pass it as (optional) parameter.

pull/155/head
rubidium 16 years ago
parent 9c2c1dea06
commit e83cca7d13

@ -40,8 +40,7 @@ static void AI_DequeueCommands(CompanyID company)
while ((com = entry_com) != NULL) { while ((com = entry_com) != NULL) {
_current_company = company; _current_company = company;
_cmd_text = com->text; DoCommandP(com->tile, com->p1, com->p2, com->cmd, com->callback, com->text);
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
/* Free item */ /* Free item */
entry_com = com->next; entry_com = com->next;
@ -54,7 +53,7 @@ static void AI_DequeueCommands(CompanyID company)
* Needed for SP; we need to delay DoCommand with 1 tick, because else events * Needed for SP; we need to delay DoCommand with 1 tick, because else events
* will make infinite loops (AIScript). * will make infinite loops (AIScript).
*/ */
static void AI_PutCommandInQueue(CompanyID company, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback) static void AI_PutCommandInQueue(CompanyID company, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback* callback, const char *text = NULL)
{ {
AICommand *com; AICommand *com;
@ -75,44 +74,31 @@ static void AI_PutCommandInQueue(CompanyID company, TileIndex tile, uint32 p1, u
com->tile = tile; com->tile = tile;
com->p1 = p1; com->p1 = p1;
com->p2 = p2; com->p2 = p2;
com->procc = procc; com->cmd = cmd;
com->callback = callback; com->callback = callback;
com->next = NULL; com->next = NULL;
com->text = NULL; com->text = text == NULL ? NULL : strdup(text);
/* Copy the cmd_text, if needed */
if (_cmd_text != NULL) {
com->text = strdup(_cmd_text);
_cmd_text = NULL;
}
} }
/** /**
* Executes a raw DoCommand for the AI. * Executes a raw DoCommand for the AI.
*/ */
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc, CommandCallback* callback) CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 cmd, CommandCallback* callback, const char *text)
{ {
CompanyID old_local_company; CompanyID old_local_company;
CommandCost res; CommandCost res;
const char* tmp_cmdtext;
/* If you enable DC_EXEC with DC_QUERY_COST you are a really strange /* If you enable DC_EXEC with DC_QUERY_COST you are a really strange
* person.. should we check for those funny jokes? * person.. should we check for those funny jokes?
*/ */
/* The test already resets _cmd_text, so backup the pointer */
tmp_cmdtext = _cmd_text;
/* First, do a test-run to see if we can do this */ /* First, do a test-run to see if we can do this */
res = DoCommand(tile, p1, p2, flags & ~DC_EXEC, procc); res = DoCommand(tile, p1, p2, flags & ~DC_EXEC, cmd, text);
/* The command failed, or you didn't want to execute, or you are quering, return */ /* The command failed, or you didn't want to execute, or you are quering, return */
if (CmdFailed(res) || !(flags & DC_EXEC) || (flags & DC_QUERY_COST)) { if (CmdFailed(res) || !(flags & DC_EXEC) || (flags & DC_QUERY_COST)) {
return res; return res;
} }
/* Restore _cmd_text */
_cmd_text = tmp_cmdtext;
/* NetworkSend_Command needs _local_company to be set correctly, so /* NetworkSend_Command needs _local_company to be set correctly, so
* adjust it, and put it back right after the function */ * adjust it, and put it back right after the function */
old_local_company = _local_company; old_local_company = _local_company;
@ -122,14 +108,14 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
/* Send the command */ /* Send the command */
if (_networking) { if (_networking) {
/* Network is easy, send it to his handler */ /* Network is easy, send it to his handler */
NetworkSend_Command(tile, p1, p2, procc, callback); NetworkSend_Command(tile, p1, p2, cmd, callback, text);
} else { } else {
#else #else
{ {
#endif #endif
/* If we execute BuildCommands directly in SP, we have a big problem with events /* If we execute BuildCommands directly in SP, we have a big problem with events
* so we need to delay is for 1 tick */ * so we need to delay is for 1 tick */
AI_PutCommandInQueue(_current_company, tile, p1, p2, procc, callback); AI_PutCommandInQueue(_current_company, tile, p1, p2, cmd, callback, text);
} }
/* Set _local_company back */ /* Set _local_company back */
@ -139,9 +125,9 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
} }
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc) CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 cmd, const char *text)
{ {
return AI_DoCommandCc(tile, p1, p2, flags, procc, NULL); return AI_DoCommandCc(tile, p1, p2, flags, cmd, NULL, text);
} }

@ -15,7 +15,7 @@ struct AICommand {
uint32 tile; uint32 tile;
uint32 p1; uint32 p1;
uint32 p2; uint32 p2;
uint32 procc; uint32 cmd;
CommandCallback *callback; CommandCallback *callback;
char *text; char *text;
@ -47,8 +47,8 @@ void AI_CompanyDied(CompanyID company);
void AI_RunGameLoop(); void AI_RunGameLoop();
void AI_Initialize(); void AI_Initialize();
void AI_Uninitialize(); void AI_Uninitialize();
CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, const char *text = NULL);
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback); CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, CommandCallback* callback, const char *text = NULL);
/** Is it allowed to start a new AI. /** Is it allowed to start a new AI.
* This function checks some boundries to see if we should launch a new AI. * This function checks some boundries to see if we should launch a new AI.

@ -320,7 +320,7 @@ static void AiRestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
if (bak->order == NULL) return; if (bak->order == NULL) return;
for (uint i = 0; !bak->order[i].IsType(OT_NOTHING); i++) { for (uint i = 0; !bak->order[i].IsType(OT_NOTHING); i++) {
if (!DoCommandP(0, v->index + (i << 16), bak->order[i].Pack(), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) if (!DoCommandP(0, v->index + (i << 16), bak->order[i].Pack(), CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
break; break;
} }
} }

@ -264,7 +264,7 @@ uint16 AircraftDefaultCargoCapacity(CargoID cid, const AircraftVehicleInfo *avi)
* @param p2 unused * @param p2 unused
* return result of operation. Could be cost, error * return result of operation. Could be cost, error
*/ */
CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_company)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE); if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_company)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE);
@ -467,7 +467,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p2 unused * @param p2 unused
* @return result of operation. Error or sold value * @return result of operation. Error or sold value
*/ */
CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidVehicleID(p1)) return CMD_ERROR; if (!IsValidVehicleID(p1)) return CMD_ERROR;
@ -515,7 +515,7 @@ bool Aircraft::FindClosestDepot(TileIndex *location, DestinationID *destination,
* - p2 bit 8-10 - VLW flag (for mass goto depot) * - p2 bit 8-10 - VLW flag (for mass goto depot)
* @return o if everything went well * @return o if everything went well
*/ */
CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p2 & DEPOT_MASS_SEND) { if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */ /* Mass goto depot requested */
@ -543,7 +543,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uin
* - p2 = (bit 16) - refit only this vehicle (ignored) * - p2 = (bit 16) - refit only this vehicle (ignored)
* @return cost of refit or error * @return cost of refit or error
*/ */
CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
byte new_subtype = GB(p2, 8, 8); byte new_subtype = GB(p2, 8, 8);

@ -40,7 +40,7 @@ void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceAirport(TileIndex tile) static void PlaceAirport(TileIndex tile)
{ {
DoCommandP(tile, _selected_airport_type, _ctrl_pressed, CcBuildAirport, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE)); DoCommandP(tile, _selected_airport_type, _ctrl_pressed, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport);
} }

@ -330,9 +330,7 @@ static CommandCost CopyHeadSpecificThings(Vehicle *old_head, Vehicle *new_head,
if (cost.Succeeded() && old_head != new_head && (flags & DC_EXEC) != 0) { if (cost.Succeeded() && old_head != new_head && (flags & DC_EXEC) != 0) {
/* Copy vehicle name */ /* Copy vehicle name */
if (old_head->name != NULL) { if (old_head->name != NULL) {
_cmd_text = old_head->name; DoCommand(0, new_head->index, 0, DC_EXEC | DC_AUTOREPLACE, CMD_RENAME_VEHICLE, old_head->name);
DoCommand(0, new_head->index, 0, DC_EXEC | DC_AUTOREPLACE, CMD_RENAME_VEHICLE);
_cmd_text = NULL;
} }
/* Copy other things which cannot be copied by a command and which shall not stay resetted from the build vehicle command */ /* Copy other things which cannot be copied by a command and which shall not stay resetted from the build vehicle command */
@ -607,7 +605,7 @@ static CommandCost ReplaceChain(Vehicle **chain, uint32 flags, bool wagon_remova
* @param p1 Index of vehicle * @param p1 Index of vehicle
* @param p2 not used * @param p2 not used
*/ */
CommandCost CmdAutoreplaceVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdAutoreplaceVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, 0); CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES, 0);
bool nothing_to_do = true; bool nothing_to_do = true;

@ -370,19 +370,19 @@ public:
} }
case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: /* toggle renew_keep_length */ case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: /* toggle renew_keep_length */
DoCommandP(0, 5, GetCompany(_local_company)->renew_keep_length ? 0 : 1, NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, 5, GetCompany(_local_company)->renew_keep_length ? 0 : 1, CMD_SET_AUTOREPLACE);
break; break;
case RVW_WIDGET_START_REPLACE: { /* Start replacing */ case RVW_WIDGET_START_REPLACE: { /* Start replacing */
EngineID veh_from = this->sel_engine[0]; EngineID veh_from = this->sel_engine[0];
EngineID veh_to = this->sel_engine[1]; EngineID veh_to = this->sel_engine[1];
DoCommandP(0, 3 + (this->sel_group << 16) , veh_from + (veh_to << 16), NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, 3 + (this->sel_group << 16) , veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE);
this->SetDirty(); this->SetDirty();
} break; } break;
case RVW_WIDGET_STOP_REPLACE: { /* Stop replacing */ case RVW_WIDGET_STOP_REPLACE: { /* Stop replacing */
EngineID veh_from = this->sel_engine[0]; EngineID veh_from = this->sel_engine[0];
DoCommandP(0, 3 + (this->sel_group << 16), veh_from + (INVALID_ENGINE << 16), NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, 3 + (this->sel_group << 16), veh_from + (INVALID_ENGINE << 16), CMD_SET_AUTOREPLACE);
this->SetDirty(); this->SetDirty();
} break; } break;

@ -94,7 +94,7 @@ private:
void BuildBridge(uint8 i) void BuildBridge(uint8 i)
{ {
DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index, DoCommandP(this->end_tile, this->start_tile, this->type | this->bridges->Get(i)->index,
CcBuildBridge, CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE)); CMD_BUILD_BRIDGE | CMD_MSG(STR_5015_CAN_T_BUILD_BRIDGE_HERE), CcBuildBridge);
} }
/** Sort the builable bridges */ /** Sort the builable bridges */

@ -1055,17 +1055,18 @@ struct BuildVehicleWindow : Window {
switch (this->vehicle_type) { switch (this->vehicle_type) {
default: NOT_REACHED(); default: NOT_REACHED();
case VEH_TRAIN: case VEH_TRAIN:
DoCommandP(this->window_number, sel_eng, 0, (RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildLoco, DoCommandP(this->window_number, sel_eng, 0,
CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE)); CMD_BUILD_RAIL_VEHICLE | CMD_MSG(STR_882B_CAN_T_BUILD_RAILROAD_VEHICLE),
(RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildLoco);
break; break;
case VEH_ROAD: case VEH_ROAD:
DoCommandP(this->window_number, sel_eng, 0, CcBuildRoadVeh, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE)); DoCommandP(this->window_number, sel_eng, 0, CMD_BUILD_ROAD_VEH | CMD_MSG(STR_9009_CAN_T_BUILD_ROAD_VEHICLE), CcBuildRoadVeh);
break; break;
case VEH_SHIP: case VEH_SHIP:
DoCommandP(this->window_number, sel_eng, 0, CcBuildShip, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP)); DoCommandP(this->window_number, sel_eng, 0, CMD_BUILD_SHIP | CMD_MSG(STR_980D_CAN_T_BUILD_SHIP), CcBuildShip);
break; break;
case VEH_AIRCRAFT: case VEH_AIRCRAFT:
DoCommandP(this->window_number, sel_eng, 0, CcBuildAircraft, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT)); DoCommandP(this->window_number, sel_eng, 0, CMD_BUILD_AIRCRAFT | CMD_MSG(STR_A008_CAN_T_BUILD_AIRCRAFT), CcBuildAircraft);
break; break;
} }
} }
@ -1151,7 +1152,6 @@ struct BuildVehicleWindow : Window {
if (str == NULL) return; if (str == NULL) return;
StringID err_str = STR_NULL; StringID err_str = STR_NULL;
_cmd_text = str;
switch (this->vehicle_type) { switch (this->vehicle_type) {
default: NOT_REACHED(); default: NOT_REACHED();
case VEH_TRAIN: err_str = STR_886B_CAN_T_RENAME_TRAIN_VEHICLE; break; case VEH_TRAIN: err_str = STR_886B_CAN_T_RENAME_TRAIN_VEHICLE; break;
@ -1159,7 +1159,7 @@ struct BuildVehicleWindow : Window {
case VEH_SHIP: err_str = STR_9839_CAN_T_RENAME_SHIP_TYPE; break; case VEH_SHIP: err_str = STR_9839_CAN_T_RENAME_SHIP_TYPE; break;
case VEH_AIRCRAFT: err_str = STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE; break; case VEH_AIRCRAFT: err_str = STR_A03A_CAN_T_RENAME_AIRCRAFT_TYPE; break;
} }
DoCommandP(0, this->rename_engine, 0, NULL, CMD_RENAME_ENGINE | CMD_MSG(err_str)); DoCommandP(0, this->rename_engine, 0, CMD_RENAME_ENGINE | CMD_MSG(err_str), NULL, str);
} }
virtual void OnDropdownSelect(int widget, int index) virtual void OnDropdownSelect(int widget, int index)

@ -34,7 +34,7 @@ static int32 _money_cheat_amount = 10000000;
static int32 ClickMoneyCheat(int32 p1, int32 p2) static int32 ClickMoneyCheat(int32 p1, int32 p2)
{ {
DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, NULL, CMD_MONEY_CHEAT); DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, CMD_MONEY_CHEAT);
return _money_cheat_amount; return _money_cheat_amount;
} }

@ -24,7 +24,6 @@
#include "table/strings.h" #include "table/strings.h"
const char *_cmd_text = NULL;
StringID _error_message; StringID _error_message;
/** /**
@ -36,7 +35,7 @@ StringID _error_message;
* *
* @param yyyy The desired function name of the new command handler function. * @param yyyy The desired function name of the new command handler function.
*/ */
#define DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) #define DEF_COMMAND(yyyy) CommandCost yyyy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
DEF_COMMAND(CmdBuildRailroadTrack); DEF_COMMAND(CmdBuildRailroadTrack);
DEF_COMMAND(CmdRemoveRailroadTrack); DEF_COMMAND(CmdRemoveRailroadTrack);
@ -382,20 +381,17 @@ static int _docommand_recursive = 0;
* @param p1 Additional data for the command (for the #CommandProc) * @param p1 Additional data for the command (for the #CommandProc)
* @param p2 Additional data for the command (for the #CommandProc) * @param p2 Additional data for the command (for the #CommandProc)
* @param flags Flags for the command and how to execute the command * @param flags Flags for the command and how to execute the command
* @param procc The command-id to execute (a value of the CMD_* enums) * @param cmd The command-id to execute (a value of the CMD_* enums)
* @see CommandProc * @see CommandProc
*/ */
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc) CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 cmd, const char *text)
{ {
CommandCost res; CommandCost res;
/* Do not even think about executing out-of-bounds tile-commands */ /* Do not even think about executing out-of-bounds tile-commands */
if (!IsValidTile(tile)) { if (!IsValidTile(tile)) return CMD_ERROR;
_cmd_text = NULL;
return CMD_ERROR;
}
CommandProc *proc = _command_proc_table[procc].proc; CommandProc *proc = _command_proc_table[cmd].proc;
if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID; if (_docommand_recursive == 0) _error_message = INVALID_STRING_ID;
@ -404,7 +400,7 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32
/* only execute the test call if it's toplevel, or we're not execing. */ /* only execute the test call if it's toplevel, or we're not execing. */
if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) { if (_docommand_recursive == 1 || !(flags & DC_EXEC) ) {
SetTownRatingTestMode(true); SetTownRatingTestMode(true);
res = proc(tile, flags & ~DC_EXEC, p1, p2); res = proc(tile, flags & ~DC_EXEC, p1, p2, text);
SetTownRatingTestMode(false); SetTownRatingTestMode(false);
if (CmdFailed(res)) { if (CmdFailed(res)) {
res.SetGlobalErrorMessage(); res.SetGlobalErrorMessage();
@ -421,32 +417,29 @@ CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32
if (!(flags & DC_EXEC)) { if (!(flags & DC_EXEC)) {
_docommand_recursive--; _docommand_recursive--;
_cmd_text = NULL;
return res; return res;
} }
} }
/* Execute the command here. All cost-relevant functions set the expenses type /* Execute the command here. All cost-relevant functions set the expenses type
* themselves to the cost object at some point */ * themselves to the cost object at some point */
res = proc(tile, flags, p1, p2); res = proc(tile, flags, p1, p2, text);
if (CmdFailed(res)) { if (CmdFailed(res)) {
res.SetGlobalErrorMessage(); res.SetGlobalErrorMessage();
error: error:
_docommand_recursive--; _docommand_recursive--;
_cmd_text = NULL;
return CMD_ERROR; return CMD_ERROR;
} }
/* if toplevel, subtract the money. */ /* if toplevel, subtract the money. */
if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) { if (--_docommand_recursive == 0 && !(flags & DC_BANKRUPT)) {
SubtractMoneyFromCompany(res); SubtractMoneyFromCompany(res);
/* XXX - Old AI hack which doesn't use DoCommandDP; update last build coord of company */ /* XXX - Old AI hack which doesn't use DoCommandP; update last build coord of company */
if (tile != 0 && IsValidCompanyID(_current_company)) { if (tile != 0 && IsValidCompanyID(_current_company)) {
GetCompany(_current_company)->last_build_coordinate = tile; GetCompany(_current_company)->last_build_coordinate = tile;
} }
} }
_cmd_text = NULL;
return res; return res;
} }
@ -473,12 +466,13 @@ Money GetAvailableMoneyForCommand()
* @param tile The tile to perform a command on (see #CommandProc) * @param tile The tile to perform a command on (see #CommandProc)
* @param p1 Additional data for the command (see #CommandProc) * @param p1 Additional data for the command (see #CommandProc)
* @param p2 Additional data for the command (see #CommandProc) * @param p2 Additional data for the command (see #CommandProc)
* @param callback A callback function to call after the command is finished
* @param cmd The command to execute (a CMD_* value) * @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) * @param my_cmd indicator if the command is from a company or server (to display error messages for a user)
* @return true if the command succeeded, else false * @return true if the command succeeded, else false
*/ */
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd) bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd)
{ {
CommandCost res, res2; CommandCost res, res2;
CommandProc *proc; CommandProc *proc;
@ -490,10 +484,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
int y = TileY(tile) * TILE_SIZE; int y = TileY(tile) * TILE_SIZE;
/* Do not even think about executing out-of-bounds tile-commands */ /* Do not even think about executing out-of-bounds tile-commands */
if (!IsValidTile(tile)) { if (!IsValidTile(tile)) return false;
_cmd_text = NULL;
return false;
}
assert(_docommand_recursive == 0); assert(_docommand_recursive == 0);
@ -505,7 +496,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
* is/can be a spectator but as the server it can do anything */ * is/can be a spectator but as the server it can do anything */
if (_current_company == COMPANY_SPECTATOR && !_network_server) { if (_current_company == COMPANY_SPECTATOR && !_network_server) {
if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y); if (my_cmd) ShowErrorMessage(_error_message, error_part1, x, y);
_cmd_text = NULL;
return false; return false;
} }
@ -515,10 +505,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/* get pointer to command handler */ /* get pointer to command handler */
assert((cmd & 0xFF) < lengthof(_command_proc_table)); assert((cmd & 0xFF) < lengthof(_command_proc_table));
proc = _command_proc_table[cmd & 0xFF].proc; proc = _command_proc_table[cmd & 0xFF].proc;
if (proc == NULL) { if (proc == NULL) return false;
_cmd_text = NULL;
return false;
}
if (GetCommandFlags(cmd) & CMD_AUTO) flags |= DC_AUTO; if (GetCommandFlags(cmd) & CMD_AUTO) flags |= DC_AUTO;
@ -550,7 +537,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
(cmd & 0xFF) != CMD_PAUSE) { (cmd & 0xFF) != CMD_PAUSE) {
/* estimate the cost. */ /* estimate the cost. */
SetTownRatingTestMode(true); SetTownRatingTestMode(true);
res = proc(tile, flags, p1, p2); res = proc(tile, flags, p1, p2, text);
SetTownRatingTestMode(false); SetTownRatingTestMode(false);
if (CmdFailed(res)) { if (CmdFailed(res)) {
res.SetGlobalErrorMessage(); res.SetGlobalErrorMessage();
@ -560,7 +547,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
} }
_docommand_recursive = 0; _docommand_recursive = 0;
_cmd_text = NULL;
ClearStorageChanges(false); ClearStorageChanges(false);
return false; return false;
} }
@ -569,7 +555,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) { if (!((cmd & CMD_NO_TEST_IF_IN_NETWORK) && _networking)) {
/* first test if the command can be executed. */ /* first test if the command can be executed. */
SetTownRatingTestMode(true); SetTownRatingTestMode(true);
res = proc(tile, flags, p1, p2); res = proc(tile, flags, p1, p2, text);
SetTownRatingTestMode(false); SetTownRatingTestMode(false);
if (CmdFailed(res)) { if (CmdFailed(res)) {
res.SetGlobalErrorMessage(); res.SetGlobalErrorMessage();
@ -590,15 +576,14 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
if (_networking && !(cmd & CMD_NETWORK_COMMAND)) { if (_networking && !(cmd & CMD_NETWORK_COMMAND)) {
CompanyID bck = _local_company; CompanyID bck = _local_company;
if (_network_dedicated || (_network_server && bck == COMPANY_SPECTATOR)) _local_company = COMPANY_FIRST; if (_network_dedicated || (_network_server && bck == COMPANY_SPECTATOR)) _local_company = COMPANY_FIRST;
NetworkSend_Command(tile, p1, p2, cmd, callback); NetworkSend_Command(tile, p1, p2, cmd, callback, text);
if (_network_dedicated || (_network_server && bck == COMPANY_SPECTATOR)) _local_company = bck; if (_network_dedicated || (_network_server && bck == COMPANY_SPECTATOR)) _local_company = bck;
_docommand_recursive = 0; _docommand_recursive = 0;
_cmd_text = NULL;
ClearStorageChanges(false); ClearStorageChanges(false);
return true; return true;
} }
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd, _cmd_text); DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd, text);
/* update last build coordinate of company. */ /* update last build coordinate of company. */
if (tile != 0 && IsValidCompanyID(_current_company)) { if (tile != 0 && IsValidCompanyID(_current_company)) {
@ -607,7 +592,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
/* Actually try and execute the command. If no cost-type is given /* Actually try and execute the command. If no cost-type is given
* use the construction one */ * use the construction one */
res2 = proc(tile, flags | DC_EXEC, p1, p2); res2 = proc(tile, flags | DC_EXEC, p1, p2, text);
/* If notest is on, it means the result of the test can be different than /* If notest is on, it means the result of the test can be different than
* the real command.. so ignore the test */ * the real command.. so ignore the test */
@ -637,7 +622,6 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
_docommand_recursive = 0; _docommand_recursive = 0;
if (callback) callback(true, tile, p1, p2); if (callback) callback(true, tile, p1, p2);
_cmd_text = NULL;
ClearStorageChanges(true); ClearStorageChanges(true);
return true; return true;
@ -651,7 +635,6 @@ callb_err:
_docommand_recursive = 0; _docommand_recursive = 0;
if (callback) callback(false, tile, p1, p2); if (callback) callback(false, tile, p1, p2);
_cmd_text = NULL;
ClearStorageChanges(false); ClearStorageChanges(false);
return false; return false;
} }

@ -53,29 +53,21 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
/** /**
* Execute a command * Execute a command
*/ */
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc); CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 cmd, const char *text = NULL);
/** /**
* Execute a network safe DoCommand function * Execute a network safe DoCommand function
*/ */
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd, bool my_cmd = true); bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true);
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
/** /**
* Send a command over the network * Send a command over the network
*/ */
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback); void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text);
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
/**
* Text, which gets sent with a command
*
* This variable contains a string (be specific a pointer of the first
* char of this string) which will be send with a command. This is
* used for user input data like names or chat messages.
*/
extern const char *_cmd_text;
extern Money _additional_cash_required; extern Money _additional_cash_required;
extern StringID _error_message; extern StringID _error_message;

@ -356,9 +356,10 @@ enum {
* @param flags Flags for the command, from the DC_* enumeration * @param flags Flags for the command, from the DC_* enumeration
* @param p1 Additional data for the command * @param p1 Additional data for the command
* @param p2 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. * @return The CommandCost of the command, which can be succeeded or failed.
*/ */
typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2); typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text);
/** /**
* Define a command with the flags which belongs to it. * Define a command with the flags which belongs to it.

@ -564,7 +564,7 @@ static void MaybeStartNewCompany()
)) { )) {
/* Send a command to all clients to start up a new AI. /* Send a command to all clients to start up a new AI.
* Works fine for Multiplayer and Singleplayer */ * Works fine for Multiplayer and Singleplayer */
DoCommandP(0, 1, 0, NULL, CMD_COMPANY_CTRL); DoCommandP(0, 1, 0, CMD_COMPANY_CTRL);
} }
/* The next AI starts like the difficulty setting said, with +2 month max */ /* The next AI starts like the difficulty setting said, with +2 month max */
@ -645,7 +645,7 @@ void CompaniesYearlyLoop()
* if p1 = 5, then * if p1 = 5, then
* - p2 = enable renew_keep_length * - p2 = enable renew_keep_length
*/ */
CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSetAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidCompanyID(_current_company)) return CMD_ERROR; if (!IsValidCompanyID(_current_company)) return CMD_ERROR;
@ -788,7 +788,7 @@ void CompanyNewsInformation::FillData(const Company *c, const Company *other)
* @arg - network_server.c:838 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)@n * @arg - network_server.c:838 DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND)@n
* @arg - network_client.c:536 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) from where the map has been received * @arg - network_client.c:536 DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP) from where the map has been received
*/ */
CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (flags & DC_EXEC) _current_company = OWNER_NONE; if (flags & DC_EXEC) _current_company = OWNER_NONE;
@ -848,6 +848,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
(_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4,
_settings_client.gui.autorenew_money, _settings_client.gui.autorenew_money,
CMD_SET_AUTOREPLACE, CMD_SET_AUTOREPLACE,
NULL,
NULL NULL
); );
@ -876,9 +877,8 @@ CommandCost CmdCompanyCtrl(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* TODO: Perhaps this could be improved by when the client is ready * TODO: Perhaps this could be improved by when the client is ready
* with joining to let it send itself the command, and not the server? * with joining to let it send itself the command, and not the server?
* For example in network_client.c:534? */ * For example in network_client.c:534? */
_cmd_text = ci->client_name;
_local_company = ci->client_playas; _local_company = ci->client_playas;
NetworkSend_Command(0, 0, 0, CMD_RENAME_PRESIDENT, NULL); NetworkSend_Command(0, 0, 0, CMD_RENAME_PRESIDENT, NULL, ci->client_name);
_local_company = company_backup; _local_company = company_backup;
} }
} }

@ -215,11 +215,11 @@ struct CompanyFinancesWindow : Window {
break; break;
case CFW_WIDGET_INCREASE_LOAN: /* increase loan */ case CFW_WIDGET_INCREASE_LOAN: /* increase loan */
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY)); DoCommandP(0, 0, _ctrl_pressed, CMD_INCREASE_LOAN | CMD_MSG(STR_702C_CAN_T_BORROW_ANY_MORE_MONEY));
break; break;
case CFW_WIDGET_REPAY_LOAN: /* repay loan */ case CFW_WIDGET_REPAY_LOAN: /* repay loan */
DoCommandP(0, 0, _ctrl_pressed, NULL, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN)); DoCommandP(0, 0, _ctrl_pressed, CMD_DECREASE_LOAN | CMD_MSG(STR_702F_CAN_T_REPAY_LOAN));
break; break;
} }
} }
@ -485,7 +485,7 @@ public:
/* If clicking on the left edge, toggle using the livery */ /* If clicking on the left edge, toggle using the livery */
if (pt.x < 10) { if (pt.x < 10) {
DoCommandP(0, j | (2 << 8), !GetCompany((CompanyID)this->window_number)->livery[j].in_use, NULL, CMD_SET_COMPANY_COLOR); DoCommandP(0, j | (2 << 8), !GetCompany((CompanyID)this->window_number)->livery[j].in_use, CMD_SET_COMPANY_COLOR);
} }
if (_ctrl_pressed) { if (_ctrl_pressed) {
@ -503,7 +503,7 @@ public:
{ {
for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) { for (LiveryScheme scheme = LS_DEFAULT; scheme < LS_END; scheme++) {
if (HasBit(this->sel, scheme)) { if (HasBit(this->sel, scheme)) {
DoCommandP(0, scheme | (widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, NULL, CMD_SET_COMPANY_COLOR); DoCommandP(0, scheme | (widget == SCLW_WIDGET_PRI_COL_DROPDOWN ? 0 : 256), index, CMD_SET_COMPANY_COLOR);
} }
} }
} }
@ -879,7 +879,7 @@ public:
/* Toggle size, advanced/simple face selection */ /* Toggle size, advanced/simple face selection */
case SCMFW_WIDGET_TOGGLE_LARGE_SMALL: case SCMFW_WIDGET_TOGGLE_LARGE_SMALL:
case SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: { case SCMFW_WIDGET_TOGGLE_LARGE_SMALL_BUTTON: {
DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE); DoCommandP(0, 0, this->face, CMD_SET_COMPANY_MANAGER_FACE);
/* Backup some data before deletion */ /* Backup some data before deletion */
int oldtop = this->top; ///< current top position of the window before closing it int oldtop = this->top; ///< current top position of the window before closing it
@ -896,7 +896,7 @@ public:
/* OK button */ /* OK button */
case SCMFW_WIDGET_ACCEPT: case SCMFW_WIDGET_ACCEPT:
DoCommandP(0, 0, this->face, NULL, CMD_SET_COMPANY_MANAGER_FACE); DoCommandP(0, 0, this->face, CMD_SET_COMPANY_MANAGER_FACE);
/* Fall-Through */ /* Fall-Through */
/* Cancel button */ /* Cancel button */
@ -1287,11 +1287,11 @@ struct CompanyWindow : Window
break; break;
case CW_WIDGET_BUY_SHARE: case CW_WIDGET_BUY_SHARE:
DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS)); DoCommandP(0, this->window_number, 0, CMD_BUY_SHARE_IN_COMPANY | CMD_MSG(STR_707B_CAN_T_BUY_25_SHARE_IN_THIS));
break; break;
case CW_WIDGET_SELL_SHARE: case CW_WIDGET_SELL_SHARE:
DoCommandP(0, this->window_number, 0, NULL, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN)); DoCommandP(0, this->window_number, 0, CMD_SELL_SHARE_IN_COMPANY | CMD_MSG(STR_707C_CAN_T_SELL_25_SHARE_IN));
break; break;
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
@ -1310,7 +1310,7 @@ struct CompanyWindow : Window
virtual void OnPlaceObject(Point pt, TileIndex tile) virtual void OnPlaceObject(Point pt, TileIndex tile)
{ {
if (DoCommandP(tile, 0, 0, NULL, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) if (DoCommandP(tile, 0, 0, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
ResetObjectToPlace(); ResetObjectToPlace();
this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
this->RaiseButtons(); this->RaiseButtons();
@ -1325,16 +1325,15 @@ struct CompanyWindow : Window
{ {
if (str == NULL) return; if (str == NULL) return;
_cmd_text = str;
switch (this->query_widget) { switch (this->query_widget) {
default: NOT_REACHED(); default: NOT_REACHED();
case CW_WIDGET_PRESIDENT_NAME: case CW_WIDGET_PRESIDENT_NAME:
DoCommandP(0, 0, 0, NULL, CMD_RENAME_PRESIDENT | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT)); DoCommandP(0, 0, 0, CMD_RENAME_PRESIDENT | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT), NULL, str);
break; break;
case CW_WIDGET_COMPANY_NAME: case CW_WIDGET_COMPANY_NAME:
DoCommandP(0, 0, 0, NULL, CMD_RENAME_COMPANY | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME)); DoCommandP(0, 0, 0, CMD_RENAME_COMPANY | CMD_MSG(STR_700C_CAN_T_CHANGE_COMPANY_NAME), NULL, str);
break; break;
} }
} }
@ -1384,7 +1383,7 @@ struct BuyCompanyWindow : Window {
break; break;
case 4: case 4:
DoCommandP(0, this->window_number, 0, NULL, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY)); DoCommandP(0, this->window_number, 0, CMD_BUY_COMPANY | CMD_MSG(STR_7060_CAN_T_BUY_COMPANY));
break; break;
} }
} }
@ -1456,7 +1455,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
EndGameWindow(const WindowDesc *desc) : EndGameHighScoreBaseWindow(desc) EndGameWindow(const WindowDesc *desc) : EndGameHighScoreBaseWindow(desc)
{ {
/* Pause in single-player to have a look at the highscore at your own leisure */ /* Pause in single-player to have a look at the highscore at your own leisure */
if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); if (!_networking) DoCommandP(0, 1, 0, CMD_PAUSE);
this->background_img = SPR_TYCOON_IMG1_BEGIN; this->background_img = SPR_TYCOON_IMG1_BEGIN;
@ -1484,7 +1483,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
~EndGameWindow() ~EndGameWindow()
{ {
if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause if (!_networking) DoCommandP(0, 0, 0, CMD_PAUSE); // unpause
ShowHighscoreTable(this->window_number, this->rank); ShowHighscoreTable(this->window_number, this->rank);
} }
@ -1518,7 +1517,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow
HighScoreWindow(const WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc) HighScoreWindow(const WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc)
{ {
/* pause game to show the chart */ /* pause game to show the chart */
if (!_networking) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); if (!_networking) DoCommandP(0, 1, 0, CMD_PAUSE);
/* Close all always on-top windows to get a clean screen */ /* Close all always on-top windows to get a clean screen */
if (_game_mode != GM_MENU) HideVitalWindows(); if (_game_mode != GM_MENU) HideVitalWindows();
@ -1533,7 +1532,7 @@ struct HighScoreWindow : EndGameHighScoreBaseWindow
{ {
if (_game_mode != GM_MENU) ShowVitalWindows(); if (_game_mode != GM_MENU) ShowVitalWindows();
if (!_networking) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); // unpause if (!_networking) DoCommandP(0, 0, 0, CMD_PAUSE); // unpause
} }
virtual void OnPaint() virtual void OnPaint()

@ -483,7 +483,7 @@ DEF_CONSOLE_CMD(ConPauseGame)
} }
if (_pause_game == 0) { if (_pause_game == 0) {
DoCommandP(0, 1, 0, NULL, CMD_PAUSE); DoCommandP(0, 1, 0, CMD_PAUSE);
IConsolePrint(CC_DEFAULT, "Game paused."); IConsolePrint(CC_DEFAULT, "Game paused.");
} else { } else {
IConsolePrint(CC_DEFAULT, "Game is already paused."); IConsolePrint(CC_DEFAULT, "Game is already paused.");
@ -500,7 +500,7 @@ DEF_CONSOLE_CMD(ConUnPauseGame)
} }
if (_pause_game != 0) { if (_pause_game != 0) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); DoCommandP(0, 0, 0, CMD_PAUSE);
IConsolePrint(CC_DEFAULT, "Game unpaused."); IConsolePrint(CC_DEFAULT, "Game unpaused.");
} else { } else {
IConsolePrint(CC_DEFAULT, "Game is already unpaused."); IConsolePrint(CC_DEFAULT, "Game is already unpaused.");
@ -631,7 +631,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
} }
/* It is safe to remove this company */ /* It is safe to remove this company */
DoCommandP(0, 2, index, NULL, CMD_COMPANY_CTRL); DoCommandP(0, 2, index, CMD_COMPANY_CTRL);
IConsolePrint(CC_DEFAULT, "Company deleted."); IConsolePrint(CC_DEFAULT, "Company deleted.");
return true; return true;

@ -165,7 +165,7 @@ static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Veh
if (wagon == v) return; if (wagon == v) return;
DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, NULL, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE)); DoCommandP(v->tile, v->index + ((wagon == NULL ? INVALID_VEHICLE : wagon->index) << 16), _ctrl_pressed ? 1 : 0, CMD_MOVE_RAIL_VEHICLE | CMD_MSG(STR_8837_CAN_T_MOVE_VEHICLE));
} }
/* Array to hold the block sizes /* Array to hold the block sizes
@ -545,7 +545,7 @@ struct DepotWindow : Window {
case VEH_AIRCRAFT: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT); break; case VEH_AIRCRAFT: command = CMD_START_STOP_VEHICLE | CMD_MSG(STR_A016_CAN_T_STOP_START_AIRCRAFT); break;
default: NOT_REACHED(); command = 0; default: NOT_REACHED(); command = 0;
} }
DoCommandP(v->tile, v->index, 0, NULL, command); DoCommandP(v->tile, v->index, 0, command);
} break; } break;
default: NOT_REACHED(); default: NOT_REACHED();
@ -577,7 +577,7 @@ struct DepotWindow : Window {
default: return; default: return;
} }
DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, CMD_CLONE_VEHICLE | error_str); DoCommandP(this->window_number, v->index, _ctrl_pressed ? 1 : 0, CMD_CLONE_VEHICLE | error_str, CcCloneVehicle);
ResetObjectToPlace(); ResetObjectToPlace();
} }
@ -802,7 +802,7 @@ struct DepotWindow : Window {
case DEPOT_WIDGET_STOP_ALL: case DEPOT_WIDGET_STOP_ALL:
case DEPOT_WIDGET_START_ALL: case DEPOT_WIDGET_START_ALL:
DoCommandP(this->window_number, 0, this->type | (widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), NULL, CMD_MASS_START_STOP); DoCommandP(this->window_number, 0, this->type | (widget == DEPOT_WIDGET_START_ALL ? (1 << 5) : 0), CMD_MASS_START_STOP);
break; break;
case DEPOT_WIDGET_SELL_ALL: case DEPOT_WIDGET_SELL_ALL:
@ -832,7 +832,7 @@ struct DepotWindow : Window {
break; break;
case DEPOT_WIDGET_AUTOREPLACE: case DEPOT_WIDGET_AUTOREPLACE:
DoCommandP(this->window_number, this->type, 0, NULL, CMD_DEPOT_MASS_AUTOREPLACE); DoCommandP(this->window_number, this->type, 0, CMD_DEPOT_MASS_AUTOREPLACE);
break; break;
} }
@ -951,7 +951,7 @@ struct DepotWindow : Window {
if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE && if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
sel != INVALID_VEHICLE) { sel != INVALID_VEHICLE) {
if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) { if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, NULL, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN)); DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_9033_CAN_T_MAKE_VEHICLE_TURN));
} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) { } else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head); TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) { } else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
@ -996,7 +996,7 @@ struct DepotWindow : Window {
default: NOT_REACHED(); command = 0; default: NOT_REACHED(); command = 0;
} }
if (!DoCommandP(v->tile, v->index, sell_cmd, NULL, command) && is_engine) _backup_orders_tile = 0; if (!DoCommandP(v->tile, v->index, sell_cmd, command) && is_engine) _backup_orders_tile = 0;
} }
break; break;
default: default:
@ -1032,7 +1032,7 @@ static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
DepotWindow *w = (DepotWindow*)win; DepotWindow *w = (DepotWindow*)win;
TileIndex tile = w->window_number; TileIndex tile = w->window_number;
byte vehtype = w->type; byte vehtype = w->type;
DoCommandP(tile, vehtype, 0, NULL, CMD_DEPOT_SELL_ALL_VEHICLES); DoCommandP(tile, vehtype, 0, CMD_DEPOT_SELL_ALL_VEHICLES);
} }
} }

@ -47,17 +47,17 @@ void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceDocks_Dock(TileIndex tile) static void PlaceDocks_Dock(TileIndex tile)
{ {
DoCommandP(tile, _ctrl_pressed, 0, CcBuildDocks, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE)); DoCommandP(tile, _ctrl_pressed, 0, CMD_BUILD_DOCK | CMD_MSG(STR_9802_CAN_T_BUILD_DOCK_HERE), CcBuildDocks);
} }
static void PlaceDocks_Depot(TileIndex tile) static void PlaceDocks_Depot(TileIndex tile)
{ {
DoCommandP(tile, _ship_depot_direction, 0, CcBuildDocks, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT)); DoCommandP(tile, _ship_depot_direction, 0, CMD_BUILD_SHIP_DEPOT | CMD_MSG(STR_3802_CAN_T_BUILD_SHIP_DEPOT), CcBuildDocks);
} }
static void PlaceDocks_Buoy(TileIndex tile) static void PlaceDocks_Buoy(TileIndex tile)
{ {
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_BUOY | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE)); DoCommandP(tile, 0, 0, CMD_BUILD_BUOY | CMD_MSG(STR_9835_CAN_T_POSITION_BUOY_HERE), CcBuildDocks);
} }
static void PlaceDocks_BuildCanal(TileIndex tile) static void PlaceDocks_BuildCanal(TileIndex tile)
@ -67,7 +67,7 @@ static void PlaceDocks_BuildCanal(TileIndex tile)
static void PlaceDocks_BuildLock(TileIndex tile) static void PlaceDocks_BuildLock(TileIndex tile)
{ {
DoCommandP(tile, 0, 0, CcBuildDocks, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS)); DoCommandP(tile, 0, 0, CMD_BUILD_LOCK | CMD_MSG(STR_CANT_BUILD_LOCKS), CcBuildDocks);
} }
static void PlaceDocks_BuildRiver(TileIndex tile) static void PlaceDocks_BuildRiver(TileIndex tile)
@ -217,16 +217,16 @@ struct BuildDocksToolbarWindow : Window {
case DDSP_BUILD_BRIDGE: case DDSP_BUILD_BRIDGE:
ResetObjectToPlace(); ResetObjectToPlace();
extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2); extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2);
DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CcBuildBridge, CMD_BUILD_BRIDGE | CMD_MSG(STR_CAN_T_BUILD_AQUEDUCT_HERE)); DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CMD_BUILD_BRIDGE | CMD_MSG(STR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge);
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
GUIPlaceProcDragXY(select_proc, start_tile, end_tile); GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
break; break;
case DDSP_CREATE_WATER: case DDSP_CREATE_WATER:
DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR ? _ctrl_pressed : 0), CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS)); DoCommandP(end_tile, start_tile, (_game_mode == GM_EDITOR ? _ctrl_pressed : 0), CMD_BUILD_CANAL | CMD_MSG(STR_CANT_BUILD_CANALS), CcBuildCanal);
break; break;
case DDSP_CREATE_RIVER: case DDSP_CREATE_RIVER:
DoCommandP(end_tile, start_tile, 2, CcBuildCanal, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_PLACE_RIVERS)); DoCommandP(end_tile, start_tile, 2, CMD_BUILD_CANAL | CMD_MSG(STR_CANT_PLACE_RIVERS), CcBuildCanal);
break; break;
default: break; default: break;

@ -1886,7 +1886,7 @@ extern int GetAmountOwnedBy(const Company *c, Owner owner);
* @param p1 company to buy the shares from * @param p1 company to buy the shares from
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost(EXPENSES_OTHER); CommandCost cost(EXPENSES_OTHER);
@ -1931,7 +1931,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32
* @param p1 company to sell the shares from * @param p1 company to sell the shares from
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Check if selling shares is allowed (protection against modified clients) */ /* Check if selling shares is allowed (protection against modified clients) */
/* Cannot sell own shares */ /* Cannot sell own shares */
@ -1964,7 +1964,7 @@ CommandCost CmdSellShareInCompany(TileIndex tile, uint32 flags, uint32 p1, uint3
* @param p1 company to buy up * @param p1 company to buy up
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuyCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CompanyID cid = (CompanyID)p1; CompanyID cid = (CompanyID)p1;

@ -378,7 +378,7 @@ void EnginesDailyLoop()
* @param p1 engine-prototype offered * @param p1 engine-prototype offered
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Engine *e; Engine *e;
@ -493,15 +493,15 @@ static bool IsUniqueEngineName(const char *name)
* @param p1 engine ID to rename * @param p1 engine ID to rename
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsEngineIndex(p1)) return CMD_ERROR; if (!IsEngineIndex(p1)) return CMD_ERROR;
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_ENGINE_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_ENGINE_NAME_BYTES) return CMD_ERROR;
if (!IsUniqueEngineName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!IsUniqueEngineName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -519,7 +519,7 @@ CommandCost CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
} }
} }
} else { } else {
e->name = strdup(_cmd_text); e->name = strdup(text);
_vehicle_design_names |= 3; _vehicle_design_names |= 3;
} }

@ -91,7 +91,7 @@ struct EnginePreviewWindow : Window {
{ {
switch (widget) { switch (widget) {
case 4: case 4:
DoCommandP(0, this->window_number, 0, NULL, CMD_WANT_ENGINE_PREVIEW); DoCommandP(0, this->window_number, 0, CMD_WANT_ENGINE_PREVIEW);
/* Fallthrough */ /* Fallthrough */
case 3: case 3:
delete this; delete this;

@ -164,7 +164,7 @@ static void _GenerateWorld(void *arg)
if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game"); if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game");
if (_settings_client.gui.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); if (_settings_client.gui.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, CMD_PAUSE);
} catch (...) { } catch (...) {
_generating_world = false; _generating_world = false;
throw; throw;

@ -80,7 +80,7 @@ void InitializeGroup(void)
* @param p1 vehicle type * @param p1 vehicle type
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleType vt = (VehicleType)p1; VehicleType vt = (VehicleType)p1;
if (!IsCompanyBuildableVehicleType(vt)) return CMD_ERROR; if (!IsCompanyBuildableVehicleType(vt)) return CMD_ERROR;
@ -106,7 +106,7 @@ CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* - p1 bit 0-15 : GroupID * - p1 bit 0-15 : GroupID
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidGroupID(p1)) return CMD_ERROR; if (!IsValidGroupID(p1)) return CMD_ERROR;
@ -168,25 +168,25 @@ static bool IsUniqueGroupName(const char *name)
* - p1 bit 0-15 : GroupID * - p1 bit 0-15 : GroupID
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidGroupID(p1)) return CMD_ERROR; if (!IsValidGroupID(p1)) return CMD_ERROR;
Group *g = GetGroup(p1); Group *g = GetGroup(p1);
if (g->owner != _current_company) return CMD_ERROR; if (g->owner != _current_company) return CMD_ERROR;
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_GROUP_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_GROUP_NAME_BYTES) return CMD_ERROR;
if (!IsUniqueGroupName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!IsUniqueGroupName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
/* Delete the old name */ /* Delete the old name */
free(g->name); free(g->name);
/* Assign the new one */ /* Assign the new one */
g->name = reset ? NULL : strdup(_cmd_text); g->name = reset ? NULL : strdup(text);
InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_company); InvalidateWindowData(GetWindowClassForVehicleType(g->vehicle_type), (g->vehicle_type << 11) | VLW_GROUP_LIST | _current_company);
} }
@ -203,7 +203,7 @@ CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p2 vehicle to add to a group * @param p2 vehicle to add to a group
* - p2 bit 0-15 : VehicleID * - p2 bit 0-15 : VehicleID
*/ */
CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
GroupID new_g = p1; GroupID new_g = p1;
@ -250,7 +250,7 @@ CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* - p1 bit 0-15 : GroupID * - p1 bit 0-15 : GroupID
* @param p2 type of vehicles * @param p2 type of vehicles
*/ */
CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleType type = (VehicleType)p2; VehicleType type = (VehicleType)p2;
if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR; if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
@ -268,7 +268,7 @@ CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, ui
/* For each shared vehicles add it to the group */ /* For each shared vehicles add it to the group */
for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) { for (Vehicle *v2 = v->FirstShared(); v2 != NULL; v2 = v2->NextShared()) {
if (v2->group_id != id_g) CmdAddVehicleGroup(tile, flags, id_g, v2->index); if (v2->group_id != id_g) CmdAddVehicleGroup(tile, flags, id_g, v2->index, text);
} }
} }
} }
@ -287,7 +287,7 @@ CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, ui
* - p1 bit 0-15 : GroupID * - p1 bit 0-15 : GroupID
* @param p2 type of vehicles * @param p2 type of vehicles
*/ */
CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleType type = (VehicleType)p2; VehicleType type = (VehicleType)p2;
if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR; if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
@ -305,7 +305,7 @@ CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, u
if (v->group_id != old_g) continue; if (v->group_id != old_g) continue;
/* Add The Vehicle to the default group */ /* Add The Vehicle to the default group */
CmdAddVehicleGroup(tile, flags, DEFAULT_GROUP, v->index); CmdAddVehicleGroup(tile, flags, DEFAULT_GROUP, v->index, text);
} }
} }
@ -324,7 +324,7 @@ CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, u
* @param p2 * @param p2
* - p2 bit 0 : 1 to set or 0 to clear protection. * - p2 bit 0 : 1 to set or 0 to clear protection.
*/ */
CommandCost CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidGroupID(p1)) return CMD_ERROR; if (!IsValidGroupID(p1)) return CMD_ERROR;

@ -513,14 +513,14 @@ public:
} }
case GRP_WIDGET_CREATE_GROUP: // Create a new group case GRP_WIDGET_CREATE_GROUP: // Create a new group
DoCommandP(0, this->vehicle_type, 0, NULL, CMD_CREATE_GROUP | CMD_MSG(STR_GROUP_CAN_T_CREATE)); DoCommandP(0, this->vehicle_type, 0, CMD_CREATE_GROUP | CMD_MSG(STR_GROUP_CAN_T_CREATE));
break; break;
case GRP_WIDGET_DELETE_GROUP: { // Delete the selected group case GRP_WIDGET_DELETE_GROUP: { // Delete the selected group
GroupID group = this->group_sel; GroupID group = this->group_sel;
this->group_sel = ALL_GROUP; this->group_sel = ALL_GROUP;
DoCommandP(0, group, 0, NULL, CMD_DELETE_GROUP | CMD_MSG(STR_GROUP_CAN_T_DELETE)); DoCommandP(0, group, 0, CMD_DELETE_GROUP | CMD_MSG(STR_GROUP_CAN_T_DELETE));
break; break;
} }
@ -547,7 +547,7 @@ public:
DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
| (1 << 6) | (1 << 6)
| (widget == GRP_WIDGET_START_ALL ? (1 << 5) : 0) | (widget == GRP_WIDGET_START_ALL ? (1 << 5) : 0)
| this->vehicle_type, NULL, CMD_MASS_START_STOP); | this->vehicle_type, CMD_MASS_START_STOP);
break; break;
} }
@ -556,7 +556,7 @@ public:
if (IsValidGroupID(this->group_sel)) { if (IsValidGroupID(this->group_sel)) {
const Group *g = GetGroup(this->group_sel); const Group *g = GetGroup(this->group_sel);
DoCommandP(0, this->group_sel, !g->replace_protection, NULL, CMD_SET_GROUP_REPLACE_PROTECTION); DoCommandP(0, this->group_sel, !g->replace_protection, CMD_SET_GROUP_REPLACE_PROTECTION);
} }
break; break;
} }
@ -567,7 +567,7 @@ public:
switch (widget) { switch (widget) {
case GRP_WIDGET_ALL_VEHICLES: // All vehicles case GRP_WIDGET_ALL_VEHICLES: // All vehicles
case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles case GRP_WIDGET_DEFAULT_VEHICLES: // Ungrouped vehicles
DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE)); DoCommandP(0, DEFAULT_GROUP, this->vehicle_sel, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
this->vehicle_sel = INVALID_VEHICLE; this->vehicle_sel = INVALID_VEHICLE;
@ -589,7 +589,7 @@ public:
if (id_g >= this->groups.Length()) return; if (id_g >= this->groups.Length()) return;
DoCommandP(0, this->groups[id_g]->index, vindex, NULL, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE)); DoCommandP(0, this->groups[id_g]->index, vindex, CMD_ADD_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_VEHICLE));
break; break;
} }
@ -625,8 +625,7 @@ public:
{ {
if (str == NULL) return; if (str == NULL) return;
_cmd_text = str; DoCommandP(0, this->group_sel, 0, CMD_RENAME_GROUP | CMD_MSG(STR_GROUP_CAN_T_RENAME), NULL, str);
DoCommandP(0, this->group_sel, 0, NULL, CMD_RENAME_GROUP | CMD_MSG(STR_GROUP_CAN_T_RENAME));
} }
virtual void OnResize(Point new_size, Point delta) virtual void OnResize(Point new_size, Point delta)
@ -655,21 +654,21 @@ public:
case GALF_SERVICE: // Send for servicing case GALF_SERVICE: // Send for servicing
DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
| DEPOT_MASS_SEND | DEPOT_MASS_SEND
| DEPOT_SERVICE, NULL, GetCmdSendToDepot(this->vehicle_type)); | DEPOT_SERVICE, GetCmdSendToDepot(this->vehicle_type));
break; break;
case GALF_DEPOT: // Send to Depots case GALF_DEPOT: // Send to Depots
DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK) DoCommandP(0, this->group_sel, ((IsAllGroupID(this->group_sel) ? VLW_STANDARD : VLW_GROUP_LIST) & VLW_MASK)
| DEPOT_MASS_SEND, NULL, GetCmdSendToDepot(this->vehicle_type)); | DEPOT_MASS_SEND, GetCmdSendToDepot(this->vehicle_type));
break; break;
case GALF_ADD_SHARED: // Add shared Vehicles case GALF_ADD_SHARED: // Add shared Vehicles
assert(IsValidGroupID(this->group_sel)); assert(IsValidGroupID(this->group_sel));
DoCommandP(0, this->group_sel, this->vehicle_type, NULL, CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_SHARED_VEHICLE)); DoCommandP(0, this->group_sel, this->vehicle_type, CMD_ADD_SHARED_VEHICLE_GROUP | CMD_MSG(STR_GROUP_CAN_T_ADD_SHARED_VEHICLE));
break; break;
case GALF_REMOVE_ALL: // Remove all Vehicles from the selected group case GALF_REMOVE_ALL: // Remove all Vehicles from the selected group
assert(IsValidGroupID(this->group_sel)); assert(IsValidGroupID(this->group_sel));
DoCommandP(0, this->group_sel, this->vehicle_type, NULL, CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_GROUP_CAN_T_REMOVE_ALL_VEHICLES)); DoCommandP(0, this->group_sel, this->vehicle_type, CMD_REMOVE_ALL_VEHICLES_GROUP | CMD_MSG(STR_GROUP_CAN_T_REMOVE_ALL_VEHICLES));
break; break;
default: NOT_REACHED(); default: NOT_REACHED();
} }

@ -1653,7 +1653,7 @@ static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, uint
* @param p2 seed to use for variable 8F * @param p2 seed to use for variable 8F
* @return index of the newly create industry, or CMD_ERROR if it failed * @return index of the newly create industry, or CMD_ERROR if it failed
*/ */
CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
const IndustrySpec *indspec = GetIndustrySpec(GB(p1, 0, 16)); const IndustrySpec *indspec = GetIndustrySpec(GB(p1, 0, 16));
const Industry *ind = NULL; const Industry *ind = NULL;

@ -328,7 +328,7 @@ public:
_generating_world = false; _generating_world = false;
} }
} else if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) { } else if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
DoCommandP(0, this->selected_type, InteractiveRandom(), NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)); DoCommandP(0, this->selected_type, InteractiveRandom(), CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
this->HandleButtonClick(DPIW_FUND_WIDGET); this->HandleButtonClick(DPIW_FUND_WIDGET);
} else { } else {
HandlePlacePushButton(this, DPIW_FUND_WIDGET, SPR_CURSOR_INDUSTRY, VHM_RECT, NULL); HandlePlacePushButton(this, DPIW_FUND_WIDGET, SPR_CURSOR_INDUSTRY, VHM_RECT, NULL);
@ -362,7 +362,7 @@ public:
_current_company = OWNER_NONE; _current_company = OWNER_NONE;
_generating_world = true; _generating_world = true;
_ignore_restrictions = true; _ignore_restrictions = true;
success = DoCommandP(tile, (InteractiveRandomRange(indsp->num_table) << 16) | this->selected_type, seed, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)); success = DoCommandP(tile, (InteractiveRandomRange(indsp->num_table) << 16) | this->selected_type, seed, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
if (!success) { if (!success) {
SetDParam(0, indsp->name); SetDParam(0, indsp->name);
ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, pt.x, pt.y); ShowErrorMessage(_error_message, STR_0285_CAN_T_BUILD_HERE, pt.x, pt.y);
@ -371,7 +371,7 @@ public:
_ignore_restrictions = false; _ignore_restrictions = false;
_generating_world = false; _generating_world = false;
} else { } else {
success = DoCommandP(tile, (InteractiveRandomRange(indsp->num_table) << 16) | this->selected_type, seed, NULL, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY)); success = DoCommandP(tile, (InteractiveRandomRange(indsp->num_table) << 16) | this->selected_type, seed, CMD_BUILD_INDUSTRY | CMD_MSG(STR_4830_CAN_T_CONSTRUCT_THIS_INDUSTRY));
} }
/* If an industry has been built, just reset the cursor and the system */ /* If an industry has been built, just reset the cursor and the system */

@ -596,7 +596,7 @@ void ClearSnowLine(void)
* @param p1 unused * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags); return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
} }
@ -607,7 +607,7 @@ CommandCost CmdLandscapeClear(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
* @param flags of operation to conduct * @param flags of operation to conduct
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdClearArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p1 >= MapSize()) return CMD_ERROR; if (p1 >= MapSize()) return CMD_ERROR;

@ -63,8 +63,6 @@ void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
void HandleOnEditText(const char *str) void HandleOnEditText(const char *str)
{ {
_cmd_text = str;
switch (_rename_what) { switch (_rename_what) {
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
case 3: { // Give money, you can only give money in excess of loan case 3: { // Give money, you can only give money in excess of loan
@ -74,7 +72,7 @@ void HandleOnEditText(const char *str)
uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0 uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
/* Give 'id' the money, and substract it from ourself */ /* Give 'id' the money, and substract it from ourself */
DoCommandP(0, money_c, _rename_id, CcGiveMoney, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS)); DoCommandP(0, money_c, _rename_id, CMD_GIVE_MONEY | CMD_MSG(STR_INSUFFICIENT_FUNDS), CcGiveMoney, str);
} break; } break;
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
default: NOT_REACHED(); default: NOT_REACHED();
@ -271,7 +269,7 @@ struct MainWindow : Window
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
if (!_networking || !_network_server || !_settings_client.network.server_advertise) if (!_networking || !_network_server || !_settings_client.network.server_advertise)
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */
DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT); DoCommandP(0, 10000000, 0, CMD_MONEY_CHEAT);
break; break;
case '2' | WKC_ALT: // Update the coordinates of all station signs case '2' | WKC_ALT: // Update the coordinates of all station signs

@ -31,7 +31,7 @@
* @param p1 unused * @param p1 unused
* @param p2 face bitmasked * @param p2 face bitmasked
*/ */
CommandCost CmdSetCompanyManagerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSetCompanyManagerFace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CompanyManagerFace cmf = (CompanyManagerFace)p2; CompanyManagerFace cmf = (CompanyManagerFace)p2;
@ -52,7 +52,7 @@ CommandCost CmdSetCompanyManagerFace(TileIndex tile, uint32 flags, uint32 p1, ui
* p1 bits 8-9 set in use state or first/second colour * p1 bits 8-9 set in use state or first/second colour
* @param p2 new colour for vehicles, property, etc. * @param p2 new colour for vehicles, property, etc.
*/ */
CommandCost CmdSetCompanyColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSetCompanyColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p2 >= 16) return CMD_ERROR; // max 16 colours if (p2 >= 16) return CMD_ERROR; // max 16 colours
@ -132,7 +132,7 @@ CommandCost CmdSetCompanyColor(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* @param p2 when 0: loans LOAN_INTERVAL * @param p2 when 0: loans LOAN_INTERVAL
* when 1: loans the maximum loan permitting money (press CTRL), * when 1: loans the maximum loan permitting money (press CTRL),
*/ */
CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Company *c = GetCompany(_current_company); Company *c = GetCompany(_current_company);
@ -171,7 +171,7 @@ CommandCost CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p2 when 0: pays back LOAN_INTERVAL * @param p2 when 0: pays back LOAN_INTERVAL
* when 1: pays back the maximum loan permitting money (press CTRL), * when 1: pays back the maximum loan permitting money (press CTRL),
*/ */
CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdDecreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Company *c = GetCompany(_current_company); Company *c = GetCompany(_current_company);
@ -222,19 +222,19 @@ static bool IsUniqueCompanyName(const char *name)
* @param p1 unused * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRenameCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameCompany(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_COMPANY_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_COMPANY_NAME_BYTES) return CMD_ERROR;
if (!IsUniqueCompanyName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!IsUniqueCompanyName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Company *c = GetCompany(_current_company); Company *c = GetCompany(_current_company);
free(c->name); free(c->name);
c->name = reset ? NULL : strdup(_cmd_text); c->name = reset ? NULL : strdup(text);
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
@ -261,13 +261,13 @@ static bool IsUniquePresidentName(const char *name)
* @param p1 unused * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRenamePresident(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenamePresident(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_PRESIDENT_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_PRESIDENT_NAME_BYTES) return CMD_ERROR;
if (!IsUniquePresidentName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!IsUniquePresidentName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -277,14 +277,13 @@ CommandCost CmdRenamePresident(TileIndex tile, uint32 flags, uint32 p1, uint32 p
if (reset) { if (reset) {
c->president_name = NULL; c->president_name = NULL;
} else { } else {
c->president_name = strdup(_cmd_text); c->president_name = strdup(text);
if (c->name_1 == STR_SV_UNNAMED && c->name == NULL) { if (c->name_1 == STR_SV_UNNAMED && c->name == NULL) {
char buf[80]; char buf[80];
snprintf(buf, lengthof(buf), "%s Transport", _cmd_text); snprintf(buf, lengthof(buf), "%s Transport", text);
_cmd_text = buf; DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY, buf);
DoCommand(0, 0, 0, DC_EXEC, CMD_RENAME_COMPANY);
} }
} }
@ -302,7 +301,7 @@ CommandCost CmdRenamePresident(TileIndex tile, uint32 flags, uint32 p1, uint32 p
*/ */
static void AskUnsafeUnpauseCallback(Window *w, bool confirmed) static void AskUnsafeUnpauseCallback(Window *w, bool confirmed)
{ {
DoCommandP(0, confirmed ? 0 : 1, 0, NULL, CMD_PAUSE); DoCommandP(0, confirmed ? 0 : 1, 0, CMD_PAUSE);
} }
/** Pause/Unpause the game (server-only). /** Pause/Unpause the game (server-only).
@ -314,7 +313,7 @@ static void AskUnsafeUnpauseCallback(Window *w, bool confirmed)
* @param p1 0 = decrease pause counter; 1 = increase pause counter * @param p1 0 = decrease pause counter; 1 = increase pause counter
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
_pause_game += (p1 == 0) ? -1 : 1; _pause_game += (p1 == 0) ? -1 : 1;
@ -350,7 +349,7 @@ CommandCost CmdPause(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p1 the amount of money to receive (if negative), or spend (if positive) * @param p1 the amount of money to receive (if negative), or spend (if positive)
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
#ifndef _DEBUG #ifndef _DEBUG
if (_networking) return CMD_ERROR; if (_networking) return CMD_ERROR;
@ -367,7 +366,7 @@ CommandCost CmdMoneyCheat(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p1 the amount of money to transfer; max 20.000.000 * @param p1 the amount of money to transfer; max 20.000.000
* @param p2 the company to transfer the money to * @param p2 the company to transfer the money to
*/ */
CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdGiveMoney(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!_settings_game.economy.give_money) return CMD_ERROR; if (!_settings_game.economy.give_money) return CMD_ERROR;

@ -1467,7 +1467,7 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
/* pause is only used in single-player, non-editor mode, non-menu mode. It /* pause is only used in single-player, non-editor mode, non-menu mode. It
* will be unpaused in the WE_DESTROY event handler. */ * will be unpaused in the WE_DESTROY event handler. */
if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) { if (_game_mode != GM_MENU && !_networking && _game_mode != GM_EDITOR) {
if (_pause_game >= 0) DoCommandP(0, 1, 0, NULL, CMD_PAUSE); if (_pause_game >= 0) DoCommandP(0, 1, 0, CMD_PAUSE);
} }
BuildFileList(); BuildFileList();
@ -1505,7 +1505,7 @@ struct SaveLoadWindow : public QueryStringBaseWindow {
{ {
/* pause is only used in single-player, non-editor mode, non menu mode */ /* pause is only used in single-player, non-editor mode, non menu mode */
if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { if (!_networking && _game_mode != GM_EDITOR && _game_mode != GM_MENU) {
if (_pause_game >= 0) DoCommandP(0, 0, 0, NULL, CMD_PAUSE); if (_pause_game >= 0) DoCommandP(0, 0, 0, CMD_PAUSE);
} }
FiosFreeSavegameList(); FiosFreeSavegameList();
} }

@ -375,13 +375,13 @@ void CheckMinActiveClients()
if (_min_active_clients_paused) return; if (_min_active_clients_paused) return;
_min_active_clients_paused = true; _min_active_clients_paused = true;
DoCommandP(0, 1, 0, NULL, CMD_PAUSE); DoCommandP(0, 1, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (not enough players)", CLIENT_ID_SERVER); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (not enough players)", CLIENT_ID_SERVER);
} else { } else {
if (!_min_active_clients_paused) return; if (!_min_active_clients_paused) return;
_min_active_clients_paused = false; _min_active_clients_paused = false;
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); DoCommandP(0, 0, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (enough players)", CLIENT_ID_SERVER); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (enough players)", CLIENT_ID_SERVER);
} }
} }
@ -470,7 +470,7 @@ void NetworkCloseClient(NetworkClientSocket *cs)
/* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */ /* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */
if (cs->status == STATUS_PRE_ACTIVE && _settings_client.network.pause_on_join) { if (cs->status == STATUS_PRE_ACTIVE && _settings_client.network.pause_on_join) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); DoCommandP(0, 0, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused", CLIENT_ID_SERVER); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused", CLIENT_ID_SERVER);
} }
@ -1057,8 +1057,7 @@ void NetworkGameLoop()
while (f != NULL && !feof(f)) { while (f != NULL && !feof(f)) {
if (cp != NULL && _date == next_date && _date_fract == next_date_fract) { if (cp != NULL && _date == next_date && _date_fract == next_date_fract) {
_current_company = cp->company; _current_company = cp->company;
_cmd_text = cp->text; DoCommandP(cp->tile, cp->p1, cp->p2, cp->cmd, NULL, cp->text);
DoCommandP(cp->tile, cp->p1, cp->p2, NULL, cp->cmd);
free(cp); free(cp);
cp = NULL; cp = NULL;
} }

@ -620,7 +620,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
* the server will give us a client-id and let us in */ * the server will give us a client-id and let us in */
_network_join_status = NETWORK_JOIN_STATUS_REGISTERING; _network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
ShowJoinStatusWindow(); ShowJoinStatusWindow();
NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL); NetworkSend_Command(0, 0, 0, CMD_COMPANY_CTRL, NULL, NULL);
} }
} else { } else {
// take control over an existing company // take control over an existing company

@ -32,7 +32,7 @@ void NetworkAddCommandQueue(NetworkClientSocket *cs, CommandPacket *cp)
} }
// Prepare a DoCommand to be send over the network // Prepare a DoCommand to be send over the network
void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback) void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text)
{ {
CommandPacket c; CommandPacket c;
@ -53,7 +53,7 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
c.callback = 0; // _callback_table[0] == NULL c.callback = 0; // _callback_table[0] == NULL
} }
strecpy(c.text, (_cmd_text != NULL) ? _cmd_text : "", lastof(c.text)); strecpy(c.text, (text != NULL) ? text : "", lastof(c.text));
if (_network_server) { if (_network_server) {
/* If we are the server, we queue the command in our 'special' queue. /* If we are the server, we queue the command in our 'special' queue.
@ -96,7 +96,6 @@ void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comma
void NetworkExecuteCommand(CommandPacket *cp) void NetworkExecuteCommand(CommandPacket *cp)
{ {
_current_company = cp->company; _current_company = cp->company;
_cmd_text = cp->text;
/* cp->callback is unsigned. so we don't need to do lower bounds checking. */ /* cp->callback is unsigned. so we don't need to do lower bounds checking. */
if (cp->callback > _callback_table_count) { if (cp->callback > _callback_table_count) {
DEBUG(net, 0, "Received out-of-bounds callback (%d)", cp->callback); DEBUG(net, 0, "Received out-of-bounds callback (%d)", cp->callback);
@ -105,7 +104,7 @@ void NetworkExecuteCommand(CommandPacket *cp)
DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text); DebugDumpCommands("ddc:cmd:%d;%d;%d;%d;%d;%d;%d;%s\n", _date, _date_fract, (int)cp->company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text);
DoCommandP(cp->tile, cp->p1, cp->p2, _callback_table[cp->callback], cp->cmd | CMD_NETWORK_COMMAND, cp->my_cmd); DoCommandP(cp->tile, cp->p1, cp->p2, cp->cmd | CMD_NETWORK_COMMAND, _callback_table[cp->callback], cp->text, cp->my_cmd);
} }
#endif /* ENABLE_NETWORK */ #endif /* ENABLE_NETWORK */

@ -804,7 +804,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MAP_OK)
if (_settings_client.network.pause_on_join) { if (_settings_client.network.pause_on_join) {
/* Now pause the game till the client is in sync */ /* Now pause the game till the client is in sync */
DoCommandP(0, 1, 0, NULL, CMD_PAUSE); DoCommandP(0, 1, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (incoming client)", CLIENT_ID_SERVER); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game paused (incoming client)", CLIENT_ID_SERVER);
} }
@ -1030,7 +1030,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_ACK)
cs->status = STATUS_ACTIVE; cs->status = STATUS_ACTIVE;
if (_settings_client.network.pause_on_join) { if (_settings_client.network.pause_on_join) {
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); DoCommandP(0, 0, 0, CMD_PAUSE);
NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (client connected)", CLIENT_ID_SERVER); NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "Game unpaused (client connected)", CLIENT_ID_SERVER);
} }
@ -1392,7 +1392,7 @@ static void NetworkAutoCleanCompanies()
/* Is the company empty for autoclean_unprotected-months, and is there no protection? */ /* Is the company empty for autoclean_unprotected-months, and is there no protection? */
if (_settings_client.network.autoclean_unprotected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_states[c->index].password)) { if (_settings_client.network.autoclean_unprotected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_states[c->index].password)) {
/* Shut the company down */ /* Shut the company down */
DoCommandP(0, 2, c->index, NULL, CMD_COMPANY_CTRL); DoCommandP(0, 2, c->index, CMD_COMPANY_CTRL);
IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", c->index + 1); IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d", c->index + 1);
} }
/* Is the company empty for autoclean_protected-months, and there is a protection? */ /* Is the company empty for autoclean_protected-months, and there is a protection? */

@ -737,7 +737,7 @@ static void MakeNewGameDone()
SetLocalCompany(COMPANY_FIRST); SetLocalCompany(COMPANY_FIRST);
_current_company = _local_company; _current_company = _local_company;
DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE);
InitializeRailGUI(); InitializeRailGUI();
@ -829,7 +829,7 @@ static void StartScenario()
SetLocalCompany(COMPANY_FIRST); SetLocalCompany(COMPANY_FIRST);
_current_company = _local_company; _current_company = _local_company;
DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, (_settings_client.gui.autorenew << 15 ) | (_settings_client.gui.autorenew_months << 16) | 4, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE);
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
@ -937,7 +937,7 @@ void SwitchMode(int new_mode)
* company #1 (eg 0) or in the case of a dedicated server a spectator */ * company #1 (eg 0) or in the case of a dedicated server a spectator */
SetLocalCompany(_network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST); SetLocalCompany(_network_dedicated ? COMPANY_SPECTATOR : COMPANY_FIRST);
/* Decrease pause counter (was increased from opening load dialog) */ /* Decrease pause counter (was increased from opening load dialog) */
DoCommandP(0, 0, 0, NULL, CMD_PAUSE); DoCommandP(0, 0, 0, CMD_PAUSE);
#ifdef ENABLE_NETWORK #ifdef ENABLE_NETWORK
if (_network_server) { if (_network_server) {
snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title); snprintf(_network_game_info.map_name, lengthof(_network_game_info.map_name), "%s (Loaded game)", _file_to_saveload.title);

@ -332,7 +332,7 @@ static uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle
* only the first 8 bits used currently (bit 16 - 23) (max 255) * only the first 8 bits used currently (bit 16 - 23) (max 255)
* @param p2 packed order to insert * @param p2 packed order to insert
*/ */
CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
VehicleID veh = GB(p1, 0, 16); VehicleID veh = GB(p1, 0, 16);
@ -613,7 +613,7 @@ static CommandCost DecloneOrder(Vehicle *dst, uint32 flags)
* @param p1 the ID of the vehicle * @param p1 the ID of the vehicle
* @param p2 the order to delete (max 255) * @param p2 the order to delete (max 255)
*/ */
CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
VehicleID veh_id = p1; VehicleID veh_id = p1;
@ -703,7 +703,7 @@ CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p1 The ID of the vehicle which order is skipped * @param p1 The ID of the vehicle which order is skipped
* @param p2 the selected order to which we want to skip * @param p2 the selected order to which we want to skip
*/ */
CommandCost CmdSkipToOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSkipToOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
VehicleID veh_id = p1; VehicleID veh_id = p1;
@ -743,7 +743,7 @@ CommandCost CmdSkipToOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @note The target order will move one place down in the orderlist * @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 * if you move the order upwards else it'll move it one place down
*/ */
CommandCost CmdMoveOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdMoveOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleID veh = p1; VehicleID veh = p1;
VehicleOrderID moving_order = GB(p2, 0, 16); VehicleOrderID moving_order = GB(p2, 0, 16);
@ -847,7 +847,7 @@ CommandCost CmdMoveOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* - p2 = (bit 0 - 3) - what data to modify (@see ModifyOrderFlags) * - p2 = (bit 0 - 3) - what data to modify (@see ModifyOrderFlags)
* - p2 = (bit 4 - 15) - the data to modify * - p2 = (bit 4 - 15) - the data to modify
*/ */
CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleOrderID sel_ord = GB(p1, 16, 16); // XXX - automatically truncated to 8 bits. VehicleOrderID sel_ord = GB(p1, 16, 16); // XXX - automatically truncated to 8 bits.
VehicleID veh = GB(p1, 0, 16); VehicleID veh = GB(p1, 0, 16);
@ -1064,7 +1064,7 @@ CommandCost CmdModifyOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE) * - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)
* @param p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE * @param p2 mode of cloning: CO_SHARE, CO_COPY, or CO_UNSHARE
*/ */
CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *dst; Vehicle *dst;
VehicleID veh_src = GB(p1, 16, 16); VehicleID veh_src = GB(p1, 16, 16);
@ -1190,7 +1190,7 @@ CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* - bit 8-15 Cargo subtype * - bit 8-15 Cargo subtype
* - bit 16-23 number of order to modify * - bit 16-23 number of order to modify
*/ */
CommandCost CmdOrderRefit(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdOrderRefit(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
const Vehicle *v; const Vehicle *v;
Order *order; Order *order;
@ -1285,14 +1285,11 @@ void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *bak)
void RestoreVehicleOrders(const Vehicle *v, const BackuppedOrders *bak) void RestoreVehicleOrders(const Vehicle *v, const BackuppedOrders *bak)
{ {
/* If we have a custom name, process that */ /* If we have a custom name, process that */
if (bak->name != NULL) { if (bak->name != NULL) DoCommandP(0, v->index, 0, CMD_RENAME_VEHICLE, NULL, bak->name);
_cmd_text = bak->name;
DoCommandP(0, v->index, 0, NULL, CMD_RENAME_VEHICLE);
}
/* If we had shared orders, recover that */ /* If we had shared orders, recover that */
if (bak->clone != INVALID_VEHICLE) { if (bak->clone != INVALID_VEHICLE) {
DoCommandP(0, v->index | (bak->clone << 16), CO_SHARE, NULL, CMD_CLONE_ORDER); DoCommandP(0, v->index | (bak->clone << 16), CO_SHARE, CMD_CLONE_ORDER);
} else { } else {
/* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the /* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
@ -1304,14 +1301,14 @@ void RestoreVehicleOrders(const Vehicle *v, const BackuppedOrders *bak)
/* Conditional orders need to have their destination to be valid on insertion. */ /* Conditional orders need to have their destination to be valid on insertion. */
if (o.IsType(OT_CONDITIONAL)) o.SetConditionSkipToOrder(0); if (o.IsType(OT_CONDITIONAL)) o.SetConditionSkipToOrder(0);
if (!DoCommandP(0, v->index + (i << 16), o.Pack(), NULL, if (!DoCommandP(0, v->index + (i << 16), o.Pack(),
CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) { CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) {
break; break;
} }
/* Copy timetable if enabled */ /* Copy timetable if enabled */
if (_settings_game.order.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25), if (_settings_game.order.timetabling && !DoCommandP(0, v->index | (i << 16) | (1 << 25),
o.wait_time << 16 | o.travel_time, NULL, o.wait_time << 16 | o.travel_time,
CMD_CHANGE_TIMETABLE | CMD_NO_TEST_IF_IN_NETWORK)) { CMD_CHANGE_TIMETABLE | CMD_NO_TEST_IF_IN_NETWORK)) {
break; break;
} }
@ -1321,7 +1318,7 @@ void RestoreVehicleOrders(const Vehicle *v, const BackuppedOrders *bak)
for (uint i = 0; bak->order[i].IsValid(); i++) { for (uint i = 0; bak->order[i].IsValid(); i++) {
if (!bak->order[i].IsType(OT_CONDITIONAL)) continue; if (!bak->order[i].IsType(OT_CONDITIONAL)) continue;
if (!DoCommandP(0, v->index + (i << 16), MOF_LOAD | (bak->order[i].GetConditionSkipToOrder() << 4), NULL, if (!DoCommandP(0, v->index + (i << 16), MOF_LOAD | (bak->order[i].GetConditionSkipToOrder() << 4),
CMD_MODIFY_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) { CMD_MODIFY_ORDER | CMD_NO_TEST_IF_IN_NETWORK)) {
break; break;
} }
@ -1329,10 +1326,10 @@ void RestoreVehicleOrders(const Vehicle *v, const BackuppedOrders *bak)
} }
/* Restore vehicle order-index and service interval */ /* Restore vehicle order-index and service interval */
DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , NULL, CMD_RESTORE_ORDER_INDEX); DoCommandP(0, v->index, bak->orderindex | (bak->service_interval << 16) , CMD_RESTORE_ORDER_INDEX);
/* Restore vehicle group */ /* Restore vehicle group */
DoCommandP(0, bak->group, v->index, NULL, CMD_ADD_VEHICLE_GROUP); DoCommandP(0, bak->group, v->index, CMD_ADD_VEHICLE_GROUP);
} }
/** Restore the current order-index of a vehicle and sets service-interval. /** Restore the current order-index of a vehicle and sets service-interval.
@ -1349,7 +1346,7 @@ void RestoreVehicleOrders(const Vehicle *v, const BackuppedOrders *bak)
* If we do want to backup/restore it, just add UnitID uid to BackuppedOrders, and * If we do want to backup/restore it, just add UnitID uid to BackuppedOrders, and
* restore it as parameter 'y' (ugly hack I know) for example. "v->unitnumber = y;" * restore it as parameter 'y' (ugly hack I know) for example. "v->unitnumber = y;"
*/ */
CommandCost CmdRestoreOrderIndex(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRestoreOrderIndex(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
VehicleOrderID cur_ord = GB(p2, 0, 16); VehicleOrderID cur_ord = GB(p2, 0, 16);

@ -435,7 +435,7 @@ private:
* obviously if you press CTRL on a non-empty orders vehicle you know what you are doing */ * obviously if you press CTRL on a non-empty orders vehicle you know what you are doing */
if (this->vehicle->num_orders != 0 && _ctrl_pressed == 0) return false; if (this->vehicle->num_orders != 0 && _ctrl_pressed == 0) return false;
if (DoCommandP(this->vehicle->tile, this->vehicle->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY, NULL, if (DoCommandP(this->vehicle->tile, this->vehicle->index | (u->index << 16), _ctrl_pressed ? CO_SHARE : CO_COPY,
_ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) { _ctrl_pressed ? CMD_CLONE_ORDER | CMD_MSG(STR_CANT_SHARE_ORDER_LIST) : CMD_CLONE_ORDER | CMD_MSG(STR_CANT_COPY_ORDER_LIST))) {
this->selected_order = -1; this->selected_order = -1;
ResetObjectToPlace(); ResetObjectToPlace();
@ -478,7 +478,7 @@ private:
if (load_type < 0) { if (load_type < 0) {
load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE; load_type = order->GetLoadType() == OLF_LOAD_IF_POSSIBLE ? OLF_FULL_LOAD_ANY : OLF_LOAD_IF_POSSIBLE;
} }
DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_LOAD | (load_type << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_LOAD | (load_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
} }
/** /**
@ -495,7 +495,7 @@ private:
if (order == NULL) return; if (order == NULL) return;
i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE; i = (order->GetDepotOrderType() & ODTFB_SERVICE) ? DA_ALWAYS_GO : DA_SERVICE;
} }
DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_DEPOT_ACTION | (i << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_DEPOT_ACTION | (i << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
} }
/** /**
@ -511,7 +511,7 @@ private:
order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS); order.MakeGoToDepot(0, ODTFB_PART_OF_ORDERS);
order.SetDepotActionType(ODATFB_NEAREST_DEPOT); order.SetDepotActionType(ODATFB_NEAREST_DEPOT);
DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER)); DoCommandP(w->vehicle->tile, w->vehicle->index + (w->OrderGetSel() << 16), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER));
} }
/** /**
@ -543,7 +543,7 @@ private:
unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE; unload_type = order->GetUnloadType() == OUF_UNLOAD_IF_POSSIBLE ? OUFB_UNLOAD : OUF_UNLOAD_IF_POSSIBLE;
} }
DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_UNLOAD | (unload_type << 4), NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_UNLOAD | (unload_type << 4), CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
} }
/** /**
@ -565,7 +565,7 @@ private:
} }
w->InvalidateWidget(ORDER_WIDGET_NON_STOP); w->InvalidateWidget(ORDER_WIDGET_NON_STOP);
DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_NON_STOP | non_stop << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); DoCommandP(w->vehicle->tile, w->vehicle->index + (sel_ord << 16), MOF_NON_STOP | non_stop << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
} }
/** /**
@ -582,7 +582,7 @@ private:
if (w->vehicle->num_orders <= 1) return; if (w->vehicle->num_orders <= 1) return;
DoCommandP(w->vehicle->tile, w->vehicle->index, _ctrl_pressed ? w->OrderGetSel() : ((w->vehicle->cur_order_index + 1) % w->vehicle->num_orders), DoCommandP(w->vehicle->tile, w->vehicle->index, _ctrl_pressed ? w->OrderGetSel() : ((w->vehicle->cur_order_index + 1) % w->vehicle->num_orders),
NULL, CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_CAN_T_SKIP_TO_ORDER : STR_CAN_T_SKIP_ORDER)); CMD_SKIP_TO_ORDER | CMD_MSG(_ctrl_pressed ? STR_CAN_T_SKIP_TO_ORDER : STR_CAN_T_SKIP_ORDER));
} }
/** /**
@ -595,7 +595,7 @@ private:
/* When networking, move one order lower */ /* When networking, move one order lower */
int selected = w->selected_order + (int)_networking; int selected = w->selected_order + (int)_networking;
if (DoCommandP(w->vehicle->tile, w->vehicle->index, w->OrderGetSel(), NULL, CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER))) { if (DoCommandP(w->vehicle->tile, w->vehicle->index, w->OrderGetSel(), CMD_DELETE_ORDER | CMD_MSG(STR_8834_CAN_T_DELETE_THIS_ORDER))) {
w->selected_order = selected >= w->vehicle->num_orders ? -1 : selected; w->selected_order = selected >= w->vehicle->num_orders ? -1 : selected;
} }
} }
@ -611,7 +611,7 @@ private:
{ {
if (_ctrl_pressed) { if (_ctrl_pressed) {
/* Cancel refitting */ /* Cancel refitting */
DoCommandP(w->vehicle->tile, w->vehicle->index, (w->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, NULL, CMD_ORDER_REFIT); DoCommandP(w->vehicle->tile, w->vehicle->index, (w->OrderGetSel() << 16) | (CT_NO_REFIT << 8) | CT_NO_REFIT, CMD_ORDER_REFIT);
} else { } else {
ShowVehicleRefitWindow(w->vehicle, w->OrderGetSel(), w); ShowVehicleRefitWindow(w->vehicle, w->OrderGetSel(), w);
} }
@ -973,7 +973,7 @@ public:
default: default:
break; break;
} }
DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 16), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); DoCommandP(this->vehicle->tile, this->vehicle->index + (sel << 16), MOF_COND_VALUE | Clamp(value, 0, 2047) << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
} }
} }
@ -1006,11 +1006,11 @@ public:
break; break;
case ORDER_WIDGET_COND_VARIABLE: case ORDER_WIDGET_COND_VARIABLE:
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), MOF_COND_VARIABLE | index << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), MOF_COND_VARIABLE | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
break; break;
case ORDER_WIDGET_COND_COMPARATOR: case ORDER_WIDGET_COND_COMPARATOR:
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), MOF_COND_COMPARATOR | index << 4, NULL, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER)); DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), MOF_COND_COMPARATOR | index << 4, CMD_MODIFY_ORDER | CMD_MSG(STR_8835_CAN_T_MODIFY_THIS_ORDER));
break; break;
} }
} }
@ -1023,7 +1023,7 @@ public:
int to_order = this->GetOrderFromPt(pt.y); int to_order = this->GetOrderFromPt(pt.y);
if (!(from_order == to_order || from_order == INVALID_ORDER || from_order > this->vehicle->num_orders || to_order == INVALID_ORDER || to_order > this->vehicle->num_orders) && if (!(from_order == to_order || from_order == INVALID_ORDER || from_order > this->vehicle->num_orders || to_order == INVALID_ORDER || to_order > this->vehicle->num_orders) &&
DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), NULL, CMD_MOVE_ORDER | CMD_MSG(STR_CAN_T_MOVE_THIS_ORDER))) { DoCommandP(this->vehicle->tile, this->vehicle->index, from_order | (to_order << 16), CMD_MOVE_ORDER | CMD_MSG(STR_CAN_T_MOVE_THIS_ORDER))) {
this->selected_order = -1; this->selected_order = -1;
} }
} break; } break;
@ -1069,7 +1069,7 @@ public:
const Order cmd = GetOrderCmdFromTile(this->vehicle, tile); const Order cmd = GetOrderCmdFromTile(this->vehicle, tile);
if (!cmd.IsValid()) return; if (!cmd.IsValid()) return;
if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), cmd.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) { if (DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), cmd.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
ResetObjectToPlace(); ResetObjectToPlace();
} }
} }
@ -1090,7 +1090,7 @@ public:
order.index = 0; order.index = 0;
order.MakeConditional(order_id); order.MakeConditional(order_id);
DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), order.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER)); DoCommandP(this->vehicle->tile, this->vehicle->index + (this->OrderGetSel() << 16), order.Pack(), CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER));
} }
} }
} }

@ -325,7 +325,7 @@ static inline bool ValParamTrackOrientation(Track track) {return IsValidTrack(tr
* @param p1 railtype of being built piece (normal, mono, maglev) * @param p1 railtype of being built piece (normal, mono, maglev)
* @param p2 rail track to build * @param p2 rail track to build
*/ */
CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Slope tileh; Slope tileh;
RailType railtype = (RailType)p1; RailType railtype = (RailType)p1;
@ -464,7 +464,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* @param p1 unused * @param p1 unused
* @param p2 rail orientation * @param p2 rail orientation
*/ */
CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Track track = (Track)p2; Track track = (Track)p2;
TrackBits trackbit; TrackBits trackbit;
@ -690,7 +690,7 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd
* - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum) * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
* - p2 = (bit 7) - 0 = build, 1 = remove tracks * - p2 = (bit 7) - 0 = build, 1 = remove tracks
*/ */
static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost ret, total_cost(EXPENSES_CONSTRUCTION); CommandCost ret, total_cost(EXPENSES_CONSTRUCTION);
Track track = (Track)GB(p2, 4, 3); Track track = (Track)GB(p2, 4, 3);
@ -740,9 +740,9 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, uint32 flags, uint32 p1, u
* - p2 = (bit 7) - 0 = build, 1 = remove tracks * - p2 = (bit 7) - 0 = build, 1 = remove tracks
* @see CmdRailTrackHelper * @see CmdRailTrackHelper
*/ */
CommandCost CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 7)); return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 7), text);
} }
/** Build rail on a stretch of track. /** Build rail on a stretch of track.
@ -756,9 +756,9 @@ CommandCost CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint3
* - p2 = (bit 7) - 0 = build, 1 = remove tracks * - p2 = (bit 7) - 0 = build, 1 = remove tracks
* @see CmdRailTrackHelper * @see CmdRailTrackHelper
*/ */
CommandCost CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 7)); return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 7), text);
} }
/** Build a train depot /** Build a train depot
@ -770,7 +770,7 @@ CommandCost CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint
* @todo When checking for the tile slope, * @todo When checking for the tile slope,
* distingush between "Flat land required" and "land sloped in wrong direction" * distingush between "Flat land required" and "land sloped in wrong direction"
*/ */
CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Slope tileh; Slope tileh;
@ -836,7 +836,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* @param p2 used for CmdBuildManySignals() to copy direction of first signal * @param p2 used for CmdBuildManySignals() to copy direction of first signal
* TODO: p2 should be replaced by two bits for "along" and "against" the track. * TODO: p2 should be replaced by two bits for "along" and "against" the track.
*/ */
CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Track track = (Track)GB(p1, 0, 3); Track track = (Track)GB(p1, 0, 3);
bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed
@ -1048,7 +1048,7 @@ static bool CheckSignalAutoFill(TileIndex &tile, Trackdir &trackdir, int &signal
* - p2 = (bit 7- 9) - default signal type * - p2 = (bit 7- 9) - default signal type
* - p2 = (bit 24-31) - user defined signals_density * - p2 = (bit 24-31) - user defined signals_density
*/ */
static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost ret, total_cost(EXPENSES_CONSTRUCTION); CommandCost ret, total_cost(EXPENSES_CONSTRUCTION);
int signal_ctr; int signal_ctr;
@ -1174,9 +1174,9 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1,
* - p2 = (bit 24-31) - user defined signals_density * - p2 = (bit 24-31) - user defined signals_density
* @see CmdSignalTrackHelper * @see CmdSignalTrackHelper
*/ */
CommandCost CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
return CmdSignalTrackHelper(tile, flags, p1, p2); return CmdSignalTrackHelper(tile, flags, p1, p2,text);
} }
/** Remove signals /** Remove signals
@ -1188,7 +1188,7 @@ CommandCost CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32
* - (bit 4) - 0 = signals, 1 = semaphores * - (bit 4) - 0 = signals, 1 = semaphores
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Track track = (Track)GB(p1, 0, 3); Track track = (Track)GB(p1, 0, 3);
@ -1243,9 +1243,9 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint3
* - p2 = (bit 24-31) - user defined signals_density * - p2 = (bit 24-31) - user defined signals_density
* @see CmdSignalTrackHelper * @see CmdSignalTrackHelper
*/ */
CommandCost CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
return CmdSignalTrackHelper(tile, flags, p1, SetBit(p2, 5)); // bit 5 is remove bit 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 */ /** Update power of train under which is the railtype being converted */
@ -1268,7 +1268,7 @@ Vehicle *UpdateTrainPowerProc(Vehicle *v, void *data)
* @param p1 start tile of drag * @param p1 start tile of drag
* @param p2 new railtype to convert to * @param p2 new railtype to convert to
*/ */
CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdConvertRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost cost(EXPENSES_CONSTRUCTION);
RailType totype = (RailType)p2; RailType totype = (RailType)p2;

@ -82,10 +82,11 @@ void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void GenericPlaceRail(TileIndex tile, int cmd) static void GenericPlaceRail(TileIndex tile, int cmd)
{ {
DoCommandP(tile, _cur_railtype, cmd, CcPlaySound1E, DoCommandP(tile, _cur_railtype, cmd,
_remove_button_clicked ? _remove_button_clicked ?
CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_NO_WATER : CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_NO_WATER :
CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_NO_WATER CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_NO_WATER,
CcPlaySound1E
); );
} }
@ -127,7 +128,7 @@ static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return; if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return;
if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return; if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return;
DoCommandP(tile, _cur_railtype, extra & 0xFF, NULL, CMD_BUILD_SINGLE_RAIL | CMD_NO_WATER); DoCommandP(tile, _cur_railtype, extra & 0xFF, CMD_BUILD_SINGLE_RAIL | CMD_NO_WATER);
} }
/** Additional pieces of track to add at the entrance of a depot. */ /** Additional pieces of track to add at the entrance of a depot. */
@ -158,16 +159,17 @@ void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRail_Depot(TileIndex tile) static void PlaceRail_Depot(TileIndex tile)
{ {
DoCommandP(tile, _cur_railtype, _build_depot_direction, CcRailDepot, DoCommandP(tile, _cur_railtype, _build_depot_direction,
CMD_BUILD_TRAIN_DEPOT | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT)); CMD_BUILD_TRAIN_DEPOT | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT),
CcRailDepot);
} }
static void PlaceRail_Waypoint(TileIndex tile) static void PlaceRail_Waypoint(TileIndex tile)
{ {
if (_remove_button_clicked) { if (_remove_button_clicked) {
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT)); DoCommandP(tile, 0, 0, CMD_REMOVE_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_REMOVE_TRAIN_WAYPOINT), CcPlaySound1E);
} else { } else {
DoCommandP(tile, _cur_waypoint_type, 0, CcPlaySound1E, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT)); DoCommandP(tile, _cur_waypoint_type, 0, CMD_BUILD_TRAIN_WAYPOINT | CMD_MSG(STR_CANT_BUILD_TRAIN_WAYPOINT), CcPlaySound1E);
} }
} }
@ -191,8 +193,8 @@ static void PlaceRail_Station(TileIndex tile)
} else { } else {
DoCommandP(tile, DoCommandP(tile,
_railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24), _railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24),
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16),
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION), CcStation);
} }
} }
@ -216,8 +218,7 @@ static void GenericPlaceSignals(TileIndex tile)
Track track = FindFirstTrack(trackbits); Track track = FindFirstTrack(trackbits);
if (_remove_button_clicked) { if (_remove_button_clicked) {
DoCommandP(tile, track, 0, CcPlaySound1E, DoCommandP(tile, track, 0, CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound1E);
CMD_REMOVE_SIGNALS | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM));
} else { } else {
const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
@ -242,8 +243,9 @@ static void GenericPlaceSignals(TileIndex tile)
SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]); SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
} }
DoCommandP(tile, p1, 0, CcPlaySound1E, CMD_BUILD_SIGNALS | DoCommandP(tile, p1, 0, CMD_BUILD_SIGNALS |
CMD_MSG((w != NULL && _convert_signal_button) ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE)); CMD_MSG((w != NULL && _convert_signal_button) ? STR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_1010_CAN_T_BUILD_SIGNALS_HERE),
CcPlaySound1E);
} }
} }
@ -265,8 +267,7 @@ void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRail_Tunnel(TileIndex tile) static void PlaceRail_Tunnel(TileIndex tile)
{ {
DoCommandP(tile, _cur_railtype, 0, CcBuildRailTunnel, DoCommandP(tile, _cur_railtype, 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel);
CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
} }
static void PlaceRail_ConvertRail(TileIndex tile) static void PlaceRail_ConvertRail(TileIndex tile)
@ -514,7 +515,7 @@ static void BuildRailClick_Convert(Window *w)
static void DoRailroadTrack(int mode) static void DoRailroadTrack(int mode)
{ {
DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), NULL, DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4),
_remove_button_clicked ? _remove_button_clicked ?
CMD_REMOVE_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_REMOVE_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) :
CMD_BUILD_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) CMD_BUILD_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK)
@ -573,11 +574,10 @@ static void HandleAutoSignalPlacement()
TileVirtXY(thd->selstart.x, thd->selstart.y), TileVirtXY(thd->selstart.x, thd->selstart.y),
TileVirtXY(thd->selend.x, thd->selend.y), TileVirtXY(thd->selend.x, thd->selend.y),
p2, p2,
CcPlaySound1E,
_remove_button_clicked ? _remove_button_clicked ?
CMD_REMOVE_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : CMD_REMOVE_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) :
CMD_BUILD_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE) CMD_BUILD_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE),
); CcPlaySound1E);
} }
@ -727,13 +727,13 @@ struct BuildRailToolbarWindow : Window {
break; break;
case DDSP_CONVERT_RAIL: case DDSP_CONVERT_RAIL:
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL)); DoCommandP(end_tile, start_tile, _cur_railtype, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL), CcPlaySound10);
break; break;
case DDSP_REMOVE_STATION: case DDSP_REMOVE_STATION:
case DDSP_BUILD_STATION: case DDSP_BUILD_STATION:
if (_remove_button_clicked) { if (_remove_button_clicked) {
DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION)); DoCommandP(end_tile, start_tile, 0, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION), CcPlaySound1E);
break; break;
} }
HandleStationPlacement(start_tile, end_tile); HandleStationPlacement(start_tile, end_tile);
@ -880,8 +880,8 @@ static void HandleStationPlacement(TileIndex start, TileIndex end)
DoCommandP(TileXY(sx, sy), DoCommandP(TileXY(sx, sy),
_railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24), _railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24),
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation, _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16),
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION)); CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION), CcStation);
} }
struct BuildRailStationWindow : public PickerWindowBase { struct BuildRailStationWindow : public PickerWindowBase {

@ -65,7 +65,7 @@ bool RoadVehiclesAreBuilt()
* @param p1 the side of the road; 0 = left side and 1 = right side * @param p1 the side of the road; 0 = left side and 1 = right side
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Check boundaries and you can only change this if NO vehicles have been built yet, /* Check boundaries and you can only change this if NO vehicles have been built yet,
* except in the intro-menu where of course it's always possible to do so. */ * except in the intro-menu where of course it's always possible to do so. */
@ -382,7 +382,7 @@ static CommandCost RemoveRoad(TileIndex tile, uint32 flags, RoadBits pieces, Roa
* bit 4..5 road type * bit 4..5 road type
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
RoadType rt = (RoadType)GB(p1, 4, 2); RoadType rt = (RoadType)GB(p1, 4, 2);
if (!IsValidRoadType(rt)) return CMD_ERROR; if (!IsValidRoadType(rt)) return CMD_ERROR;
@ -476,7 +476,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
* bit 6..7 disallowed directions to toggle * bit 6..7 disallowed directions to toggle
* @param p2 the town that is building the road (0 if not applicable) * @param p2 the town that is building the road (0 if not applicable)
*/ */
CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost cost(EXPENSES_CONSTRUCTION);
@ -719,7 +719,7 @@ do_clear:;
* - p2 = (bit 3 + 4) - road type * - p2 = (bit 3 + 4) - road type
* - p2 = (bit 5) - set road direction * - p2 = (bit 5) - set road direction
*/ */
CommandCost CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost cost(EXPENSES_CONSTRUCTION);
bool had_bridge = false; bool had_bridge = false;
@ -805,7 +805,7 @@ CommandCost CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
* - p2 = (bit 3 + 4) - road type * - p2 = (bit 3 + 4) - road type
*/ */
CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost cost(EXPENSES_CONSTRUCTION);
@ -870,7 +870,7 @@ CommandCost CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint3
* @todo When checking for the tile slope, * @todo When checking for the tile slope,
* distingush between "Flat land required" and "land sloped in wrong direction" * distingush between "Flat land required" and "land sloped in wrong direction"
*/ */
CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
DiagDirection dir = Extract<DiagDirection, 0>(p1); DiagDirection dir = Extract<DiagDirection, 0>(p1);
RoadType rt = (RoadType)GB(p1, 2, 2); RoadType rt = (RoadType)GB(p1, 2, 2);

@ -172,7 +172,7 @@ static const RoadTypeInfo _road_type_infos[] = {
static void PlaceRoad_Tunnel(TileIndex tile) static void PlaceRoad_Tunnel(TileIndex tile)
{ {
DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE)); DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel);
} }
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction) static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
@ -181,7 +181,7 @@ static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
/* if there is a roadpiece just outside of the station entrance, build a connecting route */ /* if there is a roadpiece just outside of the station entrance, build a connecting route */
if (IsNormalRoadTile(tile)) { if (IsNormalRoadTile(tile)) {
if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) { if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD); DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, CMD_BUILD_ROAD);
} }
} }
} }
@ -200,7 +200,7 @@ void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRoad_Depot(TileIndex tile) static void PlaceRoad_Depot(TileIndex tile)
{ {
DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot)); DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CMD_BUILD_ROAD_DEPOT | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot), CcRoadDepot);
} }
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd) static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
@ -211,13 +211,13 @@ static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
SetBit(p2, 1); // It's a drive-through stop SetBit(p2, 1); // It's a drive-through stop
p1 -= DIAGDIR_END; // Adjust picker result to actual direction p1 -= DIAGDIR_END; // Adjust picker result to actual direction
} }
DoCommandP(tile, p1, p2, CcRoadDepot, cmd); DoCommandP(tile, p1, p2, cmd, CcRoadDepot);
} }
static void PlaceRoad_BusStation(TileIndex tile) static void PlaceRoad_BusStation(TileIndex tile)
{ {
if (_remove_button_clicked) { if (_remove_button_clicked) {
DoCommandP(tile, 0, ROADSTOP_BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS])); DoCommandP(tile, 0, ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]), CcPlaySound1D);
} else { } else {
PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS])); PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS]));
} }
@ -226,7 +226,7 @@ static void PlaceRoad_BusStation(TileIndex tile)
static void PlaceRoad_TruckStation(TileIndex tile) static void PlaceRoad_TruckStation(TileIndex tile)
{ {
if (_remove_button_clicked) { if (_remove_button_clicked) {
DoCommandP(tile, 0, ROADSTOP_TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK])); DoCommandP(tile, 0, ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]), CcPlaySound1D);
} else { } else {
PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK])); PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK]));
} }
@ -596,10 +596,10 @@ struct BuildRoadToolbarWindow : Window {
* not the 3rd bit set) */ * not the 3rd bit set) */
_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3)); _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), CcPlaySound1D, DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5),
(_ctrl_pressed || _remove_button_clicked) ? (_ctrl_pressed || _remove_button_clicked) ?
CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) : CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road)); CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D);
break; break;
} }
} }

@ -173,7 +173,7 @@ void RoadVehUpdateCache(Vehicle *v)
* @param p1 bus/truck type being built (engine) * @param p1 bus/truck type being built (engine)
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost; CommandCost cost;
Vehicle *v; Vehicle *v;
@ -325,7 +325,7 @@ bool RoadVehicle::IsStoppedInDepot() const
* @param p1 vehicle ID to be sold * @param p1 vehicle ID to be sold
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
@ -430,7 +430,7 @@ bool RoadVehicle::FindClosestDepot(TileIndex *location, DestinationID *destinati
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h) * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
* - p2 bit 8-10 - VLW flag (for mass goto depot) * - p2 bit 8-10 - VLW flag (for mass goto depot)
*/ */
CommandCost CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p2 & DEPOT_MASS_SEND) { if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */ /* Mass goto depot requested */
@ -453,7 +453,7 @@ CommandCost CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint3
* @param p1 vehicle ID to turn * @param p1 vehicle ID to turn
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdTurnRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
@ -2005,7 +2005,7 @@ void RoadVehiclesYearlyLoop()
* - p2 = (bit 16) - refit only this vehicle * - p2 = (bit 16) - refit only this vehicle
* @return cost of refit or error * @return cost of refit or error
*/ */
CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
CommandCost cost(EXPENSES_ROADVEH_RUN); CommandCost cost(EXPENSES_ROADVEH_RUN);

@ -926,19 +926,19 @@ static int32 CheckInterval(int32 p1)
static int32 EngineRenewUpdate(int32 p1) static int32 EngineRenewUpdate(int32 p1)
{ {
DoCommandP(0, 0, _settings_client.gui.autorenew, NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, 0, _settings_client.gui.autorenew, CMD_SET_AUTOREPLACE);
return 0; return 0;
} }
static int32 EngineRenewMonthsUpdate(int32 p1) static int32 EngineRenewMonthsUpdate(int32 p1)
{ {
DoCommandP(0, 1, _settings_client.gui.autorenew_months, NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, 1, _settings_client.gui.autorenew_months, CMD_SET_AUTOREPLACE);
return 0; return 0;
} }
static int32 EngineRenewMoneyUpdate(int32 p1) static int32 EngineRenewMoneyUpdate(int32 p1)
{ {
DoCommandP(0, 2, _settings_client.gui.autorenew_money, NULL, CMD_SET_AUTOREPLACE); DoCommandP(0, 2, _settings_client.gui.autorenew_money, CMD_SET_AUTOREPLACE);
return 0; return 0;
} }
@ -1857,7 +1857,7 @@ static const SettingDesc *GetSettingDescription(uint index)
* The new value is properly clamped to its minimum/maximum when setting * The new value is properly clamped to its minimum/maximum when setting
* @see _patch_settings * @see _patch_settings
*/ */
CommandCost CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdChangePatchSetting(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
const SettingDesc *sd = GetSettingDescription(p1); const SettingDesc *sd = GetSettingDescription(p1);
@ -1921,7 +1921,7 @@ bool SetPatchValue(uint index, int32 value)
/* send non-company-based settings over the network */ /* send non-company-based settings over the network */
if (!_networking || (_networking && _network_server)) { if (!_networking || (_networking && _network_server)) {
return DoCommandP(0, index, value, NULL, CMD_CHANGE_PATCH_SETTING); return DoCommandP(0, index, value, CMD_CHANGE_PATCH_SETTING);
} }
return false; return false;
} }

@ -277,7 +277,7 @@ struct GameOptionsWindow : Window {
case GAMEOPT_ROADSIDE_BTN: // Road side case GAMEOPT_ROADSIDE_BTN: // Road side
if (this->opt->vehicle.road_side != index) { // only change if setting changed if (this->opt->vehicle.road_side != index) { // only change if setting changed
DoCommandP(0, index, 0, NULL, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); DoCommandP(0, index, 0, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
break; break;
@ -547,12 +547,12 @@ public:
int32 cur_val = (int32)ReadValue(GetVariableAddress(opt_ptr, &sd->save), sd->save.conv); int32 cur_val = (int32)ReadValue(GetVariableAddress(opt_ptr, &sd->save), sd->save.conv);
/* if setting has changed, change it */ /* if setting has changed, change it */
if (new_val != cur_val) { if (new_val != cur_val) {
DoCommandP(0, i + btn, new_val, NULL, CMD_CHANGE_PATCH_SETTING); DoCommandP(0, i + btn, new_val, CMD_CHANGE_PATCH_SETTING);
} }
} }
GetPatchFromName("difficulty.diff_level", &i); GetPatchFromName("difficulty.diff_level", &i);
DoCommandP(0, i, this->opt_mod_temp.difficulty.diff_level, NULL, CMD_CHANGE_PATCH_SETTING); DoCommandP(0, i, this->opt_mod_temp.difficulty.diff_level, CMD_CHANGE_PATCH_SETTING);
delete this; delete this;
/* If we are in the editor, we should reload the economy. /* If we are in the editor, we should reload the economy.
* This way when you load a game, the max loan and interest rate * This way when you load a game, the max loan and interest rate

@ -751,7 +751,7 @@ void ShipsYearlyLoop()
* @param p1 ship type being built (engine) * @param p1 ship type being built (engine)
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost value; CommandCost value;
UnitID unit_num; UnitID unit_num;
@ -844,7 +844,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p1 vehicle ID to be sold * @param p1 vehicle ID to be sold
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
@ -889,7 +889,7 @@ bool Ship::FindClosestDepot(TileIndex *location, DestinationID *destination, boo
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h) * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
* - p2 bit 8-10 - VLW flag (for mass goto depot) * - p2 bit 8-10 - VLW flag (for mass goto depot)
*/ */
CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p2 & DEPOT_MASS_SEND) { if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */ /* Mass goto depot requested */
@ -917,7 +917,7 @@ CommandCost CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* - p2 = (bit 16) - refit only this vehicle (ignored) * - p2 = (bit 16) - refit only this vehicle (ignored)
* @return cost of refit or error * @return cost of refit or error
*/ */
CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Vehicle *v; Vehicle *v;
CommandCost cost(EXPENSES_SHIP_RUN); CommandCost cost(EXPENSES_SHIP_RUN);

@ -98,7 +98,7 @@ static void MarkSignDirty(Sign *si)
* @param p1 unused * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Try to locate a new sign */ /* Try to locate a new sign */
if (!Sign::CanAllocateItem()) return_cmd_error(STR_2808_TOO_MANY_SIGNS); if (!Sign::CanAllocateItem()) return_cmd_error(STR_2808_TOO_MANY_SIGNS);
@ -130,14 +130,13 @@ CommandCost CmdPlaceSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p2 unused * @param p2 unused
* @return 0 if succesfull, otherwise CMD_ERROR * @return 0 if succesfull, otherwise CMD_ERROR
*/ */
CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidSignID(p1)) return CMD_ERROR; if (!IsValidSignID(p1)) return CMD_ERROR;
/* If _cmd_text 0 means the new text for the sign is non-empty. /* Rename the signs when empty, otherwise remove it */
* So rename the sign. If it is empty, it has no name, so delete it */ if (!StrEmpty(text)) {
if (!StrEmpty(_cmd_text)) { if (strlen(text) >= MAX_LENGTH_SIGN_NAME_BYTES) return CMD_ERROR;
if (strlen(_cmd_text) >= MAX_LENGTH_SIGN_NAME_BYTES) return CMD_ERROR;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Sign *si = GetSign(p1); Sign *si = GetSign(p1);
@ -145,7 +144,7 @@ CommandCost CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Delete the old name */ /* Delete the old name */
free(si->name); free(si->name);
/* Assign the new one */ /* Assign the new one */
si->name = strdup(_cmd_text); si->name = strdup(text);
si->owner = _current_company; si->owner = _current_company;
/* Update; mark sign dirty twice, because it can either becom longer, or shorter */ /* Update; mark sign dirty twice, because it can either becom longer, or shorter */
@ -191,7 +190,7 @@ void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
*/ */
void PlaceProc_Sign(TileIndex tile) void PlaceProc_Sign(TileIndex tile)
{ {
DoCommandP(tile, 0, 0, CcPlaceSign, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE)); DoCommandP(tile, 0, 0, CMD_PLACE_SIGN | CMD_MSG(STR_2809_CAN_T_PLACE_SIGN_HERE), CcPlaceSign);
} }
/** /**

@ -180,8 +180,7 @@ void ShowSignList()
static bool RenameSign(SignID index, const char *text) static bool RenameSign(SignID index, const char *text)
{ {
bool remove = StrEmpty(text); bool remove = StrEmpty(text);
_cmd_text = text; DoCommandP(0, index, 0, CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)), NULL, text);
DoCommandP(0, index, 0, NULL, CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)));
return remove; return remove;
} }

@ -913,7 +913,7 @@ static void GetStationLayout(byte *layout, int numtracks, int plat_len, const St
* - p2 = (bit 8-15) - custom station class * - p2 = (bit 8-15) - custom station class
* - p2 = (bit 16-23) - custom station id * - p2 = (bit 16-23) - custom station id
*/ */
CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Does the authority allow this? */ /* Does the authority allow this? */
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR; if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR;
@ -1192,7 +1192,7 @@ restart:
* @param p1 start_tile * @param p1 start_tile
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
TileIndex start = p1 == 0 ? tile : p1; TileIndex start = p1 == 0 ? tile : p1;
@ -1394,7 +1394,7 @@ static RoadStop **FindRoadStopSpot(bool truck_station, Station *st)
* bit 2..4: the roadtypes * bit 2..4: the roadtypes
* bit 5: allow stations directly adjacent to other stations. * bit 5: allow stations directly adjacent to other stations.
*/ */
CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
bool type = HasBit(p2, 0); bool type = HasBit(p2, 0);
bool is_drive_through = HasBit(p2, 1); bool is_drive_through = HasBit(p2, 1);
@ -1608,7 +1608,7 @@ static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
* @param p1 not used * @param p1 not used
* @param p2 bit 0: 0 for Bus stops, 1 for truck stops * @param p2 bit 0: 0 for Bus stops, 1 for truck stops
*/ */
CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Make sure the specified tile is a road stop of the correct type */ /* Make sure the specified tile is a road stop of the correct type */
if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != GB(p2, 0, 1)) return CMD_ERROR; if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != GB(p2, 0, 1)) return CMD_ERROR;
@ -1816,7 +1816,7 @@ void UpdateAirportsNoise()
* @param p1 airport type, @see airport.h * @param p1 airport type, @see airport.h
* @param p2 (bit 0) - allow airports directly adjacent to other airports. * @param p2 (bit 0) - allow airports directly adjacent to other airports.
*/ */
CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
bool airport_upgrade = true; bool airport_upgrade = true;
@ -2013,7 +2013,7 @@ static CommandCost RemoveAirport(Station *st, uint32 flags)
* @param p1 unused * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE); if (!IsWaterTile(tile) || tile == 0) return_cmd_error(STR_304B_SITE_UNSUITABLE);
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
@ -2123,7 +2123,7 @@ static const byte _dock_h_chk[4] = { 1, 2, 1, 2 };
* @param p1 (bit 0) - allow docks directly adjacent to other docks. * @param p1 (bit 0) - allow docks directly adjacent to other docks.
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile, NULL)); DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
if (direction == INVALID_DIAGDIR) return_cmd_error(STR_304B_SITE_UNSUITABLE); if (direction == INVALID_DIAGDIR) return_cmd_error(STR_304B_SITE_UNSUITABLE);
@ -2865,23 +2865,23 @@ static bool IsUniqueStationName(const char *name)
* @param p1 station ID that is to be renamed * @param p1 station ID that is to be renamed
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidStationID(p1)) return CMD_ERROR; if (!IsValidStationID(p1)) return CMD_ERROR;
Station *st = GetStation(p1); Station *st = GetStation(p1);
if (!CheckOwnership(st->owner)) return CMD_ERROR; if (!CheckOwnership(st->owner)) return CMD_ERROR;
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_STATION_NAME_BYTES) return CMD_ERROR;
if (!IsUniqueStationName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!IsUniqueStationName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
free(st->name); free(st->name);
st->name = reset ? NULL : strdup(_cmd_text); st->name = reset ? NULL : strdup(text);
UpdateStationVirtCoord(st); UpdateStationVirtCoord(st);
InvalidateWindowData(WC_STATION_LIST, st->owner, 1); InvalidateWindowData(WC_STATION_LIST, st->owner, 1);

@ -949,8 +949,7 @@ struct StationViewWindow : public Window {
{ {
if (str == NULL) return; if (str == NULL) return;
_cmd_text = str; DoCommandP(0, this->window_number, 0, CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION), NULL, str);
DoCommandP(0, this->window_number, 0, NULL, CMD_RENAME_STATION | CMD_MSG(STR_3031_CAN_T_RENAME_STATION));
} }
virtual void OnResize(Point new_size, Point delta) virtual void OnResize(Point new_size, Point delta)

@ -223,7 +223,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int
* @param p2 direction; eg up (non-zero) or down (zero) * @param p2 direction; eg up (non-zero) or down (zero)
* @return error or cost of terraforming * @return error or cost of terraforming
*/ */
CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Make an extra check for map-bounds cause we add tiles to the originating tile */ /* Make an extra check for map-bounds cause we add tiles to the originating tile */
if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR; if (tile + TileDiffXY(1, 1) >= MapSize()) return CMD_ERROR;
@ -347,7 +347,7 @@ CommandCost CmdTerraformLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p2 height difference; eg raise (+1), lower (-1) or level (0) * @param p2 height difference; eg raise (+1), lower (-1) or level (0)
* @return error or cost of terraforming * @return error or cost of terraforming
*/ */
CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdLevelLand(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p1 >= MapSize()) return CMD_ERROR; if (p1 >= MapSize()) return CMD_ERROR;

@ -60,7 +60,7 @@ static void GenerateDesertArea(TileIndex end, TileIndex start)
BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) { BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
if (GetTileType(tile) != MP_WATER) { if (GetTileType(tile) != MP_WATER) {
SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT); SetTropicZone(tile, (_ctrl_pressed) ? TROPICZONE_NORMAL : TROPICZONE_DESERT);
DoCommandP(tile, 0, 0, NULL, CMD_LANDSCAPE_CLEAR); DoCommandP(tile, 0, 0, CMD_LANDSCAPE_CLEAR);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
} END_TILE_LOOP(tile, size_x, size_y, 0); } END_TILE_LOOP(tile, size_x, size_y, 0);
@ -114,16 +114,16 @@ bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_t
{ {
switch (proc) { switch (proc) {
case DDSP_DEMOLISH_AREA: case DDSP_DEMOLISH_AREA:
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA)); DoCommandP(end_tile, start_tile, 0, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA), CcPlaySound10);
break; break;
case DDSP_RAISE_AND_LEVEL_AREA: case DDSP_RAISE_AND_LEVEL_AREA:
DoCommandP(end_tile, start_tile, 1, CcTerraform, CMD_LEVEL_LAND | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE)); DoCommandP(end_tile, start_tile, 1, CMD_LEVEL_LAND | CMD_MSG(STR_0808_CAN_T_RAISE_LAND_HERE), CcTerraform);
break; break;
case DDSP_LOWER_AND_LEVEL_AREA: case DDSP_LOWER_AND_LEVEL_AREA:
DoCommandP(end_tile, start_tile, (uint32)-1, CcTerraform, CMD_LEVEL_LAND | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE)); DoCommandP(end_tile, start_tile, (uint32)-1, CMD_LEVEL_LAND | CMD_MSG(STR_0809_CAN_T_LOWER_LAND_HERE), CcTerraform);
break; break;
case DDSP_LEVEL_AREA: case DDSP_LEVEL_AREA:
DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_MSG(STR_CAN_T_LEVEL_LAND_HERE)); DoCommandP(end_tile, start_tile, 0, CMD_LEVEL_LAND | CMD_MSG(STR_CAN_T_LEVEL_LAND_HERE), CcPlaySound10);
break; break;
case DDSP_CREATE_ROCKS: case DDSP_CREATE_ROCKS:
GenerateRockyArea(end_tile, start_tile); GenerateRockyArea(end_tile, start_tile);
@ -154,7 +154,7 @@ void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2);
static void PlaceProc_BuyLand(TileIndex tile) static void PlaceProc_BuyLand(TileIndex tile)
{ {
DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_PURCHASE_LAND_AREA | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND)); DoCommandP(tile, 0, 0, CMD_PURCHASE_LAND_AREA | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E);
} }
void PlaceProc_DemolishArea(TileIndex tile) void PlaceProc_DemolishArea(TileIndex tile)
@ -360,7 +360,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
StringID msg = StringID msg =
mode ? STR_0808_CAN_T_RAISE_LAND_HERE : STR_0809_CAN_T_LOWER_LAND_HERE; mode ? STR_0808_CAN_T_RAISE_LAND_HERE : STR_0809_CAN_T_LOWER_LAND_HERE;
DoCommandP(tile, SLOPE_N, (uint32)mode, CcTerraform, CMD_TERRAFORM_LAND | CMD_MSG(msg)); DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform);
} else { } else {
assert(_terraform_size != 0); assert(_terraform_size != 0);
/* check out for map overflows */ /* check out for map overflows */
@ -387,7 +387,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode)
BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) { BEGIN_TILE_LOOP(tile2, sizex, sizey, tile) {
if (TileHeight(tile2) == h) { if (TileHeight(tile2) == h) {
DoCommandP(tile2, SLOPE_N, (uint32)mode, NULL, CMD_TERRAFORM_LAND); DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND);
} }
} END_TILE_LOOP(tile2, sizex, sizey, tile) } END_TILE_LOOP(tile2, sizex, sizey, tile)
} }

@ -51,7 +51,7 @@ static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 time
* Travelling time if p1 bit 25 is set. * Travelling time if p1 bit 25 is set.
* - p2 = (bit 16-31) - Waiting time if p1 bit 25 is set * - p2 = (bit 16-31) - Waiting time if p1 bit 25 is set
*/ */
CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!_settings_game.order.timetabling) return CMD_ERROR; if (!_settings_game.order.timetabling) return CMD_ERROR;
@ -109,7 +109,7 @@ CommandCost CmdChangeTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* @param p1 Various bitstuffed elements * @param p1 Various bitstuffed elements
* - p1 = (bit 0-15) - Vehicle with the orders to change. * - p1 = (bit 0-15) - Vehicle with the orders to change.
*/ */
CommandCost CmdSetVehicleOnTime(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSetVehicleOnTime(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!_settings_game.order.timetabling) return CMD_ERROR; if (!_settings_game.order.timetabling) return CMD_ERROR;
@ -137,7 +137,7 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, uint32 flags, uint32 p1, uint32
* - p2 = (bit 0) - Set to 1 to enable, 0 to disable autofill. * - 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 * - p2 = (bit 1) - Set to 1 to preserve waiting times in non-destructive mode
*/ */
CommandCost CmdAutofillTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdAutofillTimetable(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!_settings_game.order.timetabling) return CMD_ERROR; if (!_settings_game.order.timetabling) return CMD_ERROR;

@ -294,18 +294,18 @@ struct TimetableWindow : Window {
case TTV_CLEAR_TIME: { /* Clear waiting time button. */ case TTV_CLEAR_TIME: { /* Clear waiting time button. */
uint32 p1 = PackTimetableArgs(v, this->sel_index); uint32 p1 = PackTimetableArgs(v, this->sel_index);
DoCommandP(0, p1, 0, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); DoCommandP(0, p1, 0, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
} break; } break;
case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */ case TTV_RESET_LATENESS: /* Reset the vehicle's late counter. */
DoCommandP(0, v->index, 0, NULL, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); DoCommandP(0, v->index, 0, CMD_SET_VEHICLE_ON_TIME | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
break; break;
case TTV_AUTOFILL: { /* Autofill the timetable. */ case TTV_AUTOFILL: { /* Autofill the timetable. */
uint32 p2 = 0; uint32 p2 = 0;
if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0); if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0);
if (_ctrl_pressed) SetBit(p2, 1); if (_ctrl_pressed) SetBit(p2, 1);
DoCommandP(0, v->index, p2, NULL, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); DoCommandP(0, v->index, p2, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
} break; } break;
} }
@ -325,7 +325,7 @@ struct TimetableWindow : Window {
uint32 p2 = minu(time, UINT16_MAX); uint32 p2 = minu(time, UINT16_MAX);
DoCommandP(0, p1, p2, NULL, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE)); DoCommandP(0, p1, p2, CMD_CHANGE_TIMETABLE | CMD_MSG(STR_CAN_T_TIMETABLE_VEHICLE));
} }
virtual void OnResize(Point new_size, Point delta) virtual void OnResize(Point new_size, Point delta)

@ -238,7 +238,7 @@ static void ToolbarPauseClick(Window *w)
{ {
if (_networking && !_network_server) return; // only server can pause the game if (_networking && !_network_server) return; // only server can pause the game
if (DoCommandP(0, _pause_game ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP); if (DoCommandP(0, _pause_game ? 0 : 1, 0, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
} }
/* --- Fast forwarding --- */ /* --- Fast forwarding --- */

@ -1534,7 +1534,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
* @param p1 size of the town (0 = small, 1 = medium, 2 = large) * @param p1 size of the town (0 = small, 1 = medium, 2 = large)
* @param p2 size mode (@see TownSizeMode) * @param p2 size mode (@see TownSizeMode)
*/ */
CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Only in the scenario editor */ /* Only in the scenario editor */
if (_game_mode != GM_EDITOR) return CMD_ERROR; if (_game_mode != GM_EDITOR) return CMD_ERROR;
@ -2110,22 +2110,22 @@ static bool IsUniqueTownName(const char *name)
* @param p1 town ID to rename * @param p1 town ID to rename
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidTownID(p1)) return CMD_ERROR; if (!IsValidTownID(p1)) return CMD_ERROR;
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_TOWN_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_TOWN_NAME_BYTES) return CMD_ERROR;
if (!IsUniqueTownName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!IsUniqueTownName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
Town *t = GetTown(p1); Town *t = GetTown(p1);
free(t->name); free(t->name);
t->name = reset ? NULL : strdup(_cmd_text); t->name = reset ? NULL : strdup(text);
UpdateTownVirtCoord(t); UpdateTownVirtCoord(t);
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1); InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
@ -2314,7 +2314,7 @@ extern uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t);
* @param p1 town to do the action at * @param p1 town to do the action at
* @param p2 action to perform, @see _town_action_proc for the list of available actions * @param p2 action to perform, @see _town_action_proc for the list of available actions
*/ */
CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR; if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR;

@ -254,7 +254,7 @@ public:
} }
case TWA_EXECUTE: case TWA_EXECUTE:
DoCommandP(this->town->xy, this->window_number, this->sel_index, NULL, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS)); DoCommandP(this->town->xy, this->window_number, this->sel_index, CMD_DO_TOWN_ACTION | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
break; break;
} }
} }
@ -404,8 +404,7 @@ public:
{ {
if (str == NULL) return; if (str == NULL) return;
_cmd_text = str; DoCommandP(0, this->window_number, 0, CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN), NULL, str);
DoCommandP(0, this->window_number, 0, NULL, CMD_RENAME_TOWN | CMD_MSG(STR_2008_CAN_T_RENAME_TOWN));
} }
}; };
@ -667,7 +666,7 @@ static void PlaceProc_Town(TileIndex tile)
{ {
uint32 size = min(_scengen_town_size, (int)TSM_CITY); uint32 size = min(_scengen_town_size, (int)TSM_CITY);
uint32 mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED; uint32 mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED;
DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); DoCommandP(tile, size, mode, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE), CcBuildTown);
} }
static const Widget _scen_edit_town_gen_widgets[] = { static const Widget _scen_edit_town_gen_widgets[] = {

@ -757,7 +757,7 @@ static void AddRearEngineToMultiheadedTrain(Vehicle *v, Vehicle *u, bool buildin
* @param p1 engine type id * @param p1 engine type id
* @param p2 bit 1 prevents any free cars from being added to the train * @param p2 bit 1 prevents any free cars from being added to the train
*/ */
CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Check if the engine-type is valid (for the company) */ /* Check if the engine-type is valid (for the company) */
if (!IsEngineBuildable(p1, VEH_TRAIN, _current_company)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE); if (!IsEngineBuildable(p1, VEH_TRAIN, _current_company)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
@ -1018,7 +1018,7 @@ static void NormaliseTrainConsist(Vehicle *v)
* - p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line * - p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
* @param p2 (bit 0) move all vehicles following the source vehicle * @param p2 (bit 0) move all vehicles following the source vehicle
*/ */
CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleID s = GB(p1, 0, 16); VehicleID s = GB(p1, 0, 16);
VehicleID d = GB(p1, 16, 16); VehicleID d = GB(p1, 16, 16);
@ -1324,7 +1324,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
/* As in CmdMoveRailVehicle src_head->group_id will be equal to DEFAULT_GROUP /* As in CmdMoveRailVehicle src_head->group_id will be equal to DEFAULT_GROUP
* we need to save the group and reaffect it to src_head */ * we need to save the group and reaffect it to src_head */
const GroupID tmp_g = src_head->group_id; const GroupID tmp_g = src_head->group_id;
CmdMoveRailVehicle(0, flags, src_head->index | (INVALID_VEHICLE << 16), 1); CmdMoveRailVehicle(0, flags, src_head->index | (INVALID_VEHICLE << 16), 1, text);
SetTrainGroupID(src_head, tmp_g); SetTrainGroupID(src_head, tmp_g);
src_head = NULL; // don't do anything more to this train since the new call will do it src_head = NULL; // don't do anything more to this train since the new call will do it
} }
@ -1372,7 +1372,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
* - p2 = 2: when selling attached locos, rearrange all vehicles after it to separate lines; * - p2 = 2: when selling attached locos, rearrange all vehicles after it to separate lines;
* all wagons of the same type will go on the same line. Used by the AI currently * all wagons of the same type will go on the same line. Used by the AI currently
*/ */
CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Check if we deleted a vehicle window */ /* Check if we deleted a vehicle window */
Window *w = NULL; Window *w = NULL;
@ -1940,7 +1940,7 @@ static void ReverseTrainDirection(Vehicle *v)
* @param p1 train to reverse * @param p1 train to reverse
* @param p2 if true, reverse a unit in a train (needs to be in a depot) * @param p2 if true, reverse a unit in a train (needs to be in a depot)
*/ */
CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidVehicleID(p1)) return CMD_ERROR; if (!IsValidVehicleID(p1)) return CMD_ERROR;
@ -1990,7 +1990,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, uint32 flags, uint32 p1, ui
* @param p1 train to ignore the red signal * @param p1 train to ignore the red signal
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidVehicleID(p1)) return CMD_ERROR; if (!IsValidVehicleID(p1)) return CMD_ERROR;
@ -2013,7 +2013,7 @@ CommandCost CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32
* - p2 = (bit 16) - refit only this vehicle * - p2 = (bit 16) - refit only this vehicle
* @return cost of refit or error * @return cost of refit or error
*/ */
CommandCost CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CargoID new_cid = GB(p2, 0, 8); CargoID new_cid = GB(p2, 0, 8);
byte new_subtype = GB(p2, 8, 8); byte new_subtype = GB(p2, 8, 8);
@ -2217,7 +2217,7 @@ bool Train::FindClosestDepot(TileIndex *location, DestinationID *destination, bo
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h) * - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
* - p2 bit 8-10 - VLW flag (for mass goto depot) * - p2 bit 8-10 - VLW flag (for mass goto depot)
*/ */
CommandCost CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (p2 & DEPOT_MASS_SEND) { if (p2 & DEPOT_MASS_SEND) {
/* Mass goto depot requested */ /* Mass goto depot requested */

@ -43,7 +43,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
if (found != NULL) { if (found != NULL) {
found = GetLastVehicleInChain(found); found = GetLastVehicleInChain(found);
/* put the new wagon at the end of the loco. */ /* put the new wagon at the end of the loco. */
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE); DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, CMD_MOVE_RAIL_VEHICLE);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0); InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
} }
} }

@ -323,7 +323,7 @@ void GenerateTrees()
* @param p1 tree type, -1 means random. * @param p1 tree type, -1 means random.
* @param p2 end tile of area-drag * @param p2 end tile of area-drag
*/ */
CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdPlantTree(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
StringID msg = INVALID_STRING_ID; StringID msg = INVALID_STRING_ID;
CommandCost cost(EXPENSES_OTHER); CommandCost cost(EXPENSES_OTHER);

@ -133,7 +133,7 @@ public:
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
{ {
if (pt.x != -1 && select_proc == DDSP_PLANT_TREES) { if (pt.x != -1 && select_proc == DDSP_PLANT_TREES) {
DoCommandP(end_tile, this->tree_to_plant, start_tile, NULL, DoCommandP(end_tile, this->tree_to_plant, start_tile,
CMD_PLANT_TREE | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE)); CMD_PLANT_TREE | CMD_MSG(STR_2805_CAN_T_PLANT_TREE_HERE));
} }
} }

@ -186,7 +186,7 @@ bool CheckBridge_Stuff(BridgeType bridge_type, uint bridge_len, uint32 flags)
* - p2 = (bit 8-14) - rail type or road types. * - p2 = (bit 8-14) - rail type or road types.
* - p2 = (bit 15-16) - transport type. * - p2 = (bit 15-16) - transport type.
*/ */
CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
BridgeType bridge_type; BridgeType bridge_type;
RailType railtype = INVALID_RAILTYPE; RailType railtype = INVALID_RAILTYPE;
@ -473,7 +473,7 @@ not_valid_below:;
* @param p1 railtype or roadtypes. bit 9 set means road tunnel * @param p1 railtype or roadtypes. bit 9 set means road tunnel
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
TileIndexDiff delta; TileIndexDiff delta;
TileIndex end_tile; TileIndex end_tile;

@ -88,7 +88,7 @@ extern CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags
* @param p1 unused * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Company *c = GetCompany(_current_company); Company *c = GetCompany(_current_company);
CommandCost cost(EXPENSES_PROPERTY); CommandCost cost(EXPENSES_PROPERTY);
@ -122,7 +122,7 @@ CommandCost CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
* @param p2 unused * @param p2 unused
* @return error of cost of operation * @return error of cost of operation
*/ */
CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost cost(EXPENSES_CONSTRUCTION);
@ -149,7 +149,7 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32
* @param p2 unused * @param p2 unused
* @return error or cost of operation * @return error or cost of operation
*/ */
CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdSellLandArea(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsOwnedLandTile(tile)) return CMD_ERROR; if (!IsOwnedLandTile(tile)) return CMD_ERROR;
if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR; if (!CheckTileOwnership(tile) && _current_company != OWNER_WATER) return CMD_ERROR;

@ -1081,7 +1081,7 @@ void AgeVehicle(Vehicle *v)
* @param p2 bit 0: Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety) * @param p2 bit 0: Shall the start/stop newgrf callback be evaluated (only valid with DC_AUTOREPLACE for network safety)
* @return result of operation. Nothing if everything went well * @return result of operation. Nothing if everything went well
*/ */
CommandCost CmdStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
/* Disable the effect of p2 bit 0, when DC_AUTOREPLACE is not set */ /* Disable the effect of p2 bit 0, when DC_AUTOREPLACE is not set */
if ((flags & DC_AUTOREPLACE) == 0) SetBit(p2, 0); if ((flags & DC_AUTOREPLACE) == 0) SetBit(p2, 0);
@ -1154,7 +1154,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
* - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case * - bit 6 if set, then it's a vehicle list window, not a depot and Tile is ignored in this case
* - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set) * - bit 8-11 Vehicle List Window type (ignored unless bit 1 is set)
*/ */
CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleList list; VehicleList list;
CommandCost return_value = CMD_ERROR; CommandCost return_value = CMD_ERROR;
@ -1204,7 +1204,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, uint32 flags, uint32 p1, uin
* @param p1 Vehicle type * @param p1 Vehicle type
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleList list; VehicleList list;
@ -1241,7 +1241,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uin
* @param p1 Type of vehicle * @param p1 Type of vehicle
* @param p2 If bit 0 is set, then either replace all or nothing (instead of replacing until money runs out) * @param p2 If bit 0 is set, then either replace all or nothing (instead of replacing until money runs out)
*/ */
CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
VehicleList list; VehicleList list;
CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES); CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES);
@ -1293,7 +1293,7 @@ CommandCost CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uin
* @param p1 the original vehicle's index * @param p1 the original vehicle's index
* @param p2 1 = shared orders, else copied orders * @param p2 1 = shared orders, else copied orders
*/ */
CommandCost CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost total_cost(EXPENSES_NEW_VEHICLES); CommandCost total_cost(EXPENSES_NEW_VEHICLES);
uint32 build_argument = 2; uint32 build_argument = 2;
@ -1666,23 +1666,23 @@ static bool IsUniqueVehicleName(const char *name)
* @param p1 vehicle ID to name * @param p1 vehicle ID to name
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdRenameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidVehicleID(p1)) return CMD_ERROR; if (!IsValidVehicleID(p1)) return CMD_ERROR;
Vehicle *v = GetVehicle(p1); Vehicle *v = GetVehicle(p1);
if (!CheckOwnership(v->owner)) return CMD_ERROR; if (!CheckOwnership(v->owner)) return CMD_ERROR;
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_VEHICLE_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_VEHICLE_NAME_BYTES) return CMD_ERROR;
if (!(flags & DC_AUTOREPLACE) && !IsUniqueVehicleName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!(flags & DC_AUTOREPLACE) && !IsUniqueVehicleName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
free(v->name); free(v->name);
v->name = reset ? NULL : strdup(_cmd_text); v->name = reset ? NULL : strdup(text);
InvalidateWindowClassesData(WC_TRAINS_LIST, 1); InvalidateWindowClassesData(WC_TRAINS_LIST, 1);
MarkWholeScreenDirty(); MarkWholeScreenDirty();
} }
@ -1697,7 +1697,7 @@ CommandCost CmdRenameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p1 vehicle ID that is being service-interval-changed * @param p1 vehicle ID that is being service-interval-changed
* @param p2 new service interval * @param p2 new service interval
*/ */
CommandCost CmdChangeServiceInt(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdChangeServiceInt(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */ uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */

@ -393,9 +393,9 @@ struct RefitWindow : public Window {
case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break; case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break;
case VEH_AIRCRAFT: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break; case VEH_AIRCRAFT: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break;
} }
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8, NULL, command)) delete this; if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8, command)) delete this;
} else { } else {
if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8 | this->order << 16, NULL, CMD_ORDER_REFIT)) delete this; if (DoCommandP(v->tile, v->index, this->cargo->cargo | this->cargo->subtype << 8 | this->order << 16, CMD_ORDER_REFIT)) delete this;
} }
} }
break; break;
@ -1063,7 +1063,7 @@ struct VehicleListWindow : public BaseVehicleListWindow {
case VLW_WIDGET_STOP_ALL: case VLW_WIDGET_STOP_ALL:
case VLW_WIDGET_START_ALL: case VLW_WIDGET_START_ALL:
DoCommandP(0, GB(this->window_number, 16, 16), (this->window_number & VLW_MASK) | (1 << 6) | (widget == VLW_WIDGET_START_ALL ? (1 << 5) : 0) | this->vehicle_type, NULL, CMD_MASS_START_STOP); DoCommandP(0, GB(this->window_number, 16, 16), (this->window_number & VLW_MASK) | (1 << 6) | (widget == VLW_WIDGET_START_ALL ? (1 << 5) : 0) | this->vehicle_type, CMD_MASS_START_STOP);
break; break;
} }
} }
@ -1084,13 +1084,11 @@ struct VehicleListWindow : public BaseVehicleListWindow {
case 1: /* Send for servicing */ case 1: /* Send for servicing */
DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */, DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
(this->window_number & VLW_MASK) | DEPOT_MASS_SEND | DEPOT_SERVICE, (this->window_number & VLW_MASK) | DEPOT_MASS_SEND | DEPOT_SERVICE,
NULL,
GetCmdSendToDepot(this->vehicle_type)); GetCmdSendToDepot(this->vehicle_type));
break; break;
case 2: /* Send to Depots */ case 2: /* Send to Depots */
DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */, DoCommandP(0, GB(this->window_number, 16, 16) /* StationID or OrderID (depending on VLW) */,
(this->window_number & VLW_MASK) | DEPOT_MASS_SEND, (this->window_number & VLW_MASK) | DEPOT_MASS_SEND,
NULL,
GetCmdSendToDepot(this->vehicle_type)); GetCmdSendToDepot(this->vehicle_type));
break; break;
@ -1497,7 +1495,7 @@ struct VehicleDetailsWindow : Window {
mod = GetServiceIntervalClamped(mod + v->service_interval); mod = GetServiceIntervalClamped(mod + v->service_interval);
if (mod == v->service_interval) return; if (mod == v->service_interval) return;
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); DoCommandP(v->tile, v->index, mod, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
} break; } break;
case VLD_WIDGET_DETAILS_CARGO_CARRIED: case VLD_WIDGET_DETAILS_CARGO_CARRIED:
@ -1530,8 +1528,7 @@ struct VehicleDetailsWindow : Window {
if (str == NULL) return; if (str == NULL) return;
_cmd_text = str; DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(_name_vehicle_error[GetVehicle(this->window_number)->type]), NULL, str);
DoCommandP(0, this->window_number, 0, NULL, CMD_RENAME_VEHICLE | CMD_MSG(_name_vehicle_error[GetVehicle(this->window_number)->type]));
} }
virtual void OnResize(Point new_size, Point delta) virtual void OnResize(Point new_size, Point delta)
@ -1952,7 +1949,7 @@ struct VehicleViewWindow : Window {
switch (widget) { switch (widget) {
case VVW_WIDGET_START_STOP_VEH: // start stop case VVW_WIDGET_START_STOP_VEH: // start stop
DoCommandP(v->tile, v->index, 0, NULL, DoCommandP(v->tile, v->index, 0,
_vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]); _vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]);
break; break;
case VVW_WIDGET_CENTER_MAIN_VIEH: {/* center main view */ case VVW_WIDGET_CENTER_MAIN_VIEH: {/* center main view */
@ -1966,7 +1963,7 @@ struct VehicleViewWindow : Window {
} break; } break;
case VVW_WIDGET_GOTO_DEPOT: // goto hangar case VVW_WIDGET_GOTO_DEPOT: // goto hangar
DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0, NULL, DoCommandP(v->tile, v->index, _ctrl_pressed ? DEPOT_SERVICE : 0,
_vehicle_command_translation_table[VCT_CMD_GOTO_DEPOT][v->type]); _vehicle_command_translation_table[VCT_CMD_GOTO_DEPOT][v->type]);
break; break;
case VVW_WIDGET_REFIT_VEH: // refit case VVW_WIDGET_REFIT_VEH: // refit
@ -1983,17 +1980,18 @@ struct VehicleViewWindow : Window {
ShowVehicleDetailsWindow(v); ShowVehicleDetailsWindow(v);
break; break;
case VVW_WIDGET_CLONE_VEH: // clone vehicle case VVW_WIDGET_CLONE_VEH: // clone vehicle
DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0, CcCloneVehicle, DoCommandP(v->tile, v->index, _ctrl_pressed ? 1 : 0,
_vehicle_command_translation_table[VCT_CMD_CLONE_VEH][v->type]); _vehicle_command_translation_table[VCT_CMD_CLONE_VEH][v->type],
CcCloneVehicle);
break; break;
case VVW_WIDGET_TURN_AROUND: // turn around case VVW_WIDGET_TURN_AROUND: // turn around
assert(v->type == VEH_TRAIN || v->type == VEH_ROAD); assert(v->type == VEH_TRAIN || v->type == VEH_ROAD);
DoCommandP(v->tile, v->index, 0, NULL, DoCommandP(v->tile, v->index, 0,
_vehicle_command_translation_table[VCT_CMD_TURN_AROUND][v->type]); _vehicle_command_translation_table[VCT_CMD_TURN_AROUND][v->type]);
break; break;
case VVW_WIDGET_FORCE_PROCEED: // force proceed case VVW_WIDGET_FORCE_PROCEED: // force proceed
assert(v->type == VEH_TRAIN); assert(v->type == VEH_TRAIN);
DoCommandP(v->tile, v->index, 0, NULL, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL)); DoCommandP(v->tile, v->index, 0, CMD_FORCE_TRAIN_PROCEED | CMD_MSG(STR_8862_CAN_T_MAKE_TRAIN_PASS_SIGNAL));
break; break;
} }
} }

@ -190,7 +190,7 @@ void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_wate
* @param p1 bit 0 depot orientation (Axis) * @param p1 bit 0 depot orientation (Axis)
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildShipDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
TileIndex tile2; TileIndex tile2;
@ -354,7 +354,7 @@ static CommandCost RemoveShiplift(TileIndex tile, uint32 flags)
* @param p1 unused * @param p1 unused
* @param p2 unused * @param p2 unused
*/ */
CommandCost CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL)); DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
if (dir == INVALID_DIAGDIR) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); if (dir == INVALID_DIAGDIR) return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
@ -371,7 +371,7 @@ CommandCost CmdBuildLock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p1 start tile of stretch-dragging * @param p1 start tile of stretch-dragging
* @param p2 specifies canal (0), water (1) or river (2); last two can only be built in scenario editor * @param p2 specifies canal (0), water (1) or river (2); last two can only be built in scenario editor
*/ */
CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
CommandCost cost(EXPENSES_CONSTRUCTION); CommandCost cost(EXPENSES_CONSTRUCTION);
int size_x, size_y; int size_x, size_y;

@ -190,7 +190,7 @@ void AfterLoadWaypoints()
* @todo When checking for the tile slope, * @todo When checking for the tile slope,
* distingush between "Flat land required" and "land sloped in wrong direction" * distingush between "Flat land required" and "land sloped in wrong direction"
*/ */
CommandCost CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdBuildTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
Waypoint *wp; Waypoint *wp;
Slope tileh; Slope tileh;
@ -352,7 +352,7 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
* @param p2 unused * @param p2 unused
* @return cost of operation or error * @return cost of operation or error
*/ */
CommandCost CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
return RemoveTrainWaypoint(tile, flags, true); return RemoveTrainWaypoint(tile, flags, true);
} }
@ -379,18 +379,18 @@ static bool IsUniqueWaypointName(const char *name)
* @param p2 unused * @param p2 unused
* @return cost of operation or error * @return cost of operation or error
*/ */
CommandCost CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) CommandCost CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
{ {
if (!IsValidWaypointID(p1)) return CMD_ERROR; if (!IsValidWaypointID(p1)) return CMD_ERROR;
Waypoint *wp = GetWaypoint(p1); Waypoint *wp = GetWaypoint(p1);
if (!CheckOwnership(wp->owner)) return CMD_ERROR; if (!CheckOwnership(wp->owner)) return CMD_ERROR;
bool reset = StrEmpty(_cmd_text); bool reset = StrEmpty(text);
if (!reset) { if (!reset) {
if (strlen(_cmd_text) >= MAX_LENGTH_WAYPOINT_NAME_BYTES) return CMD_ERROR; if (strlen(text) >= MAX_LENGTH_WAYPOINT_NAME_BYTES) return CMD_ERROR;
if (!IsUniqueWaypointName(_cmd_text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE); if (!IsUniqueWaypointName(text)) return_cmd_error(STR_NAME_MUST_BE_UNIQUE);
} }
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
@ -399,7 +399,7 @@ CommandCost CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
if (reset) { if (reset) {
MakeDefaultWaypointName(wp); // sets wp->name = NULL MakeDefaultWaypointName(wp); // sets wp->name = NULL
} else { } else {
wp->name = strdup(_cmd_text); wp->name = strdup(text);
} }
UpdateWaypointSign(wp); UpdateWaypointSign(wp);

@ -94,8 +94,7 @@ public:
{ {
if (str == NULL) return; if (str == NULL) return;
_cmd_text = str; DoCommandP(0, this->window_number, 0, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME), NULL, str);
DoCommandP(0, this->window_number, 0, NULL, CMD_RENAME_WAYPOINT | CMD_MSG(STR_CANT_CHANGE_WAYPOINT_NAME));
} }
}; };

Loading…
Cancel
Save