Codechange: Pass additional data as byte stream to command callbacks.

This commit is contained in:
Michael Lutz 2021-10-31 22:07:22 +01:00
parent 0f64ee5ce1
commit eab18f06a4
23 changed files with 98 additions and 112 deletions

View File

@ -92,14 +92,12 @@ ScriptInfo *AIInstance::FindLibrary(const char *library, int version)
/**
* DoCommand callback function for all commands executed by AIs.
* @param result The result of the command.
* @param cmd cmd as given to DoCommandPInternal.
* @param result The result of the command.
* @param tile The tile on which the command was executed.
* @param p1 p1 as given to DoCommandPInternal.
* @param p2 p2 as given to DoCommandPInternal.
* @param text text as given to DoCommandPInternal.
* @param data Command data as given to Command<>::Post.
*/
void CcAI(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcAI(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
/*
* The company might not exist anymore. Check for this.
@ -110,7 +108,7 @@ void CcAI(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, ui
const Company *c = Company::GetIfValid(_current_company);
if (c == nullptr || c->ai_instance == nullptr) return;
if (c->ai_instance->DoCommandCallback(result, tile, p1, p2, cmd)) {
if (c->ai_instance->DoCommandCallback(result, tile, data, cmd)) {
c->ai_instance->Continue();
}
}

View File

@ -43,7 +43,7 @@ static void ShowBuildAirportPicker(Window *parent);
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
void CcBuildAirport(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildAirport(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Failed()) return;

View File

@ -53,18 +53,15 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
* @param result Whether the build succeeded
* @param cmd unused
* @param end_tile End tile of the bridge.
* @param p1 packed start tile coords (~ dx)
* @param p2 various bitstuffed elements
* - p2 = (bit 0- 7) - bridge type (hi bh)
* - p2 = (bit 8-13) - rail type or road types.
* - p2 = (bit 15-16) - transport type.
* @param text unused
* @param data Additional bitstuffed command data.
*/
void CcBuildBridge(const CommandCost &result, Commands cmd, TileIndex end_tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildBridge(Commands cmd, const CommandCost &result, TileIndex end_tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile);
auto [tile, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_BRIDGE>::Args>(data);
TransportType transport_type = Extract<TransportType, 15, 2>(p2);
if (transport_type == TRANSPORT_ROAD) {

View File

@ -12,7 +12,7 @@
#include "command_type.h"
#include "company_type.h"
#include <vector>
#include "misc/endian_buffer.hpp"
#include "tile_map.h"
/**
@ -34,9 +34,6 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
*/
#define return_cmd_error(errcode) return CommandCost(errcode);
/** Storage buffer for serialized command data. */
typedef std::vector<byte> CommandDataBuffer;
CommandCost DoCommandPInternal(Commands cmd, StringID err_message, CommandCallback *callback, bool my_cmd, bool estimate_only, bool network_command, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
void NetworkSendCommand(Commands cmd, StringID err_message, CommandCallback *callback, CompanyID company, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
@ -213,7 +210,7 @@ protected:
InternalPostResult(res, tile, estimate_only, only_sending, err_message, my_cmd);
if (!estimate_only && !only_sending && callback != nullptr) {
std::apply(callback, std::tuple_cat(std::tuple<const CommandCost &, Commands>{ res, Tcmd }, args));
callback(Tcmd, res, tile, EndianBufferWriter<CommandDataBuffer>::FromValue(args));
}
return res.Succeeded();

View File

@ -13,6 +13,7 @@
#include "economy_type.h"
#include "strings_type.h"
#include "tile_type.h"
#include <vector>
struct GRFFile;
@ -444,6 +445,9 @@ template <Commands Tcmd> struct CommandTraits;
static inline constexpr const char *name = #proc_; \
};
/** Storage buffer for serialized command data. */
typedef std::vector<byte> CommandDataBuffer;
/**
* Define a callback function for the client, after the command is finished.
*
@ -451,14 +455,12 @@ template <Commands Tcmd> struct CommandTraits;
* are from the #CommandProc callback type. The boolean parameter indicates if the
* command succeeded or failed.
*
* @param result The result of the executed command
* @param cmd The command that was executed
* @param result The result of the executed command
* @param tile The tile of the command action
* @param p1 Additional data of the command
* @param p1 Additional data of the command
* @param text Text of the command
* @param data Additional data of the command
* @see CommandProc
*/
typedef void CommandCallback(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
typedef void CommandCallback(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data);
#endif /* COMMAND_TYPE_H */

View File

@ -117,11 +117,8 @@ extern void DepotSortList(VehicleList *list);
* @param result the result of the cloning command
* @param cmd unused
* @param tile unused
* @param p1 unused
* @param p2 unused
* @param text unused
*/
void CcCloneVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcCloneVehicle(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Failed()) return;

View File

@ -43,7 +43,7 @@ static void ShowBuildDocksDepotPicker(Window *parent);
static Axis _ship_depot_direction;
void CcBuildDocks(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildDocks(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Failed()) return;
@ -51,7 +51,7 @@ void CcBuildDocks(const CommandCost &result, Commands cmd, TileIndex tile, uint3
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcPlaySound_CONSTRUCTION_WATER(Commands cmd, const CommandCost &result,TileIndex tile, const CommandDataBuffer &)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile);
}

View File

@ -81,16 +81,14 @@ void GameInstance::Died()
/**
* DoCommand callback function for all commands executed by Game Scripts.
* @param result The result of the command.
* @param cmd cmd as given to DoCommandPInternal.
* @param result The result of the command.
* @param tile The tile on which the command was executed.
* @param p1 p1 as given to DoCommandPInternal.
* @param p2 p2 as given to DoCommandPInternal.
* @param text text as given to DoCommandPInternal.
* @param data Command data as given to Command<>::Post.
*/
void CcGame(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcGame(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (Game::GetGameInstance()->DoCommandCallback(result, tile, p1, p2, cmd)) {
if (Game::GetGameInstance()->DoCommandCallback(result, tile, data, cmd)) {
Game::GetGameInstance()->Continue();
}
}

View File

@ -1141,38 +1141,47 @@ static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner o
/**
* Opens a 'Rename group' window for newly created group.
* @param result Did command succeed?
* @param cmd Unused.
* @param tile Unused.
* @param p1 Vehicle type.
* @param p2 Unused.
* @param text Unused.
* @see CmdCreateGroup
* @param veh_type Vehicle type.
*/
void CcCreateGroup(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
static void CcCreateGroup(VehicleType veh_type)
{
if (result.Failed()) return;
assert(p1 <= VEH_AIRCRAFT);
VehicleGroupWindow *w = FindVehicleGroupWindow((VehicleType)p1, _current_company);
VehicleGroupWindow *w = FindVehicleGroupWindow(veh_type, _current_company);
if (w != nullptr) w->ShowRenameGroupWindow(_new_group_id, true);
}
/**
* Open rename window after adding a vehicle to a new group via drag and drop.
* @param result Did command succeed?
* Opens a 'Rename group' window for newly created group.
* @param cmd Unused.
* @param result Did command succeed?
* @param tile Unused.
* @param p1 Unused.
* @param p2 Bit 0-19: Vehicle ID.
* @param text Unused.
* @param data Command data.
* @see CmdCreateGroup
*/
void CcAddVehicleNewGroup(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcCreateGroup(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_CREATE_GROUP>::Args>(data);
assert(p1 <= VEH_AIRCRAFT);
CcCreateGroup((VehicleType)p1);
}
/**
* Open rename window after adding a vehicle to a new group via drag and drop.
* @param cmd Unused.
* @param result Did command succeed?
* @param tile Unused.
* @param data Command data.
*/
void CcAddVehicleNewGroup(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_ADD_VEHICLE_GROUP>::Args>(data);
assert(Vehicle::IsValidID(GB(p2, 0, 20)));
CcCreateGroup(result, cmd, 0, Vehicle::Get(GB(p2, 0, 20))->type, 0, text);
CcCreateGroup(Vehicle::Get(GB(p2, 0, 20))->type);
}
/**

View File

@ -219,17 +219,16 @@ void SortIndustryTypes()
/**
* Command callback. In case of failure to build an industry, show an error message.
* @param result Result of the command.
* @param cmd Unused.
* @param result Result of the command.
* @param tile Tile where the industry is placed.
* @param p1 Additional data of the #CMD_BUILD_INDUSTRY command.
* @param p2 Additional data of the #CMD_BUILD_INDUSTRY command.
* @param text Unused.
* @param data Additional data of the #CMD_BUILD_INDUSTRY command.
*/
void CcBuildIndustry(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Succeeded()) return;
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_INDUSTRY>::Args>(data);
uint8 indtype = GB(p1, 0, 8);
if (indtype < NUM_INDUSTRYTYPES) {
const IndustrySpec *indsp = GetIndustrySpec(indtype);

View File

@ -77,7 +77,7 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl
}
void CcPlaySound_EXPLOSION(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcPlaySound_EXPLOSION(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile);
}

View File

@ -89,7 +89,7 @@ static bool IsStationAvailable(const StationSpec *statspec)
return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
}
void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcPlaySound_CONSTRUCTION_RAIL(Commands cmd, const CommandCost &result,TileIndex tile, const CommandDataBuffer &)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
}
@ -135,10 +135,11 @@ static const DiagDirection _place_depot_extra_dir[12] = {
DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
};
void CcRailDepot(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcRailDepot(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_TRAIN_DEPOT>::Args>(data);
DiagDirection dir = (DiagDirection)p2;
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
@ -176,7 +177,7 @@ static void PlaceRail_Waypoint(TileIndex tile)
}
}
void CcStation(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcStation(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Failed()) return;
@ -293,7 +294,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w)
}
/** Command callback for building a tunnel */
void CcBuildRailTunnel(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildRailTunnel(Commands cmd, const CommandCost &result,TileIndex tile, const CommandDataBuffer &)
{
if (result.Succeeded()) {
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);

View File

@ -69,7 +69,7 @@ static RoadType _cur_roadtype;
static DiagDirection _road_depot_orientation;
static DiagDirection _road_station_picker_orientation;
void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcPlaySound_CONSTRUCTION_OTHER(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
}
@ -92,15 +92,11 @@ static void PlaceRoad_Bridge(TileIndex tile, Window *w)
/**
* Callback executed after a build road tunnel command has been called.
*
* @param result Whether the build succeeded.
* @param cmd unused
* @param result Whether the build succeeded.
* @param start_tile Starting tile of the tunnel.
* @param p1 bit 0-3 railtype or roadtypes
* bit 8-9 transport type
* @param p2 unused
* @param text unused
*/
void CcBuildRoadTunnel(const CommandCost &result, Commands cmd, TileIndex start_tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildRoadTunnel(Commands cmd, const CommandCost &result, TileIndex start_tile, const CommandDataBuffer &)
{
if (result.Succeeded()) {
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
@ -133,10 +129,12 @@ void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
}
}
void CcRoadDepot(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_ROAD_DEPOT>::Args>(data);
DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
@ -160,10 +158,12 @@ void CcRoadDepot(const CommandCost &result, Commands cmd, TileIndex tile, uint32
* @param text Unused.
* @see CmdBuildRoadStop
*/
void CcRoadStop(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_BUILD_ROAD_STOP>::Args>(data);
DiagDirection dir = (DiagDirection)GB(p2, 3, 2);
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();

View File

@ -82,24 +82,22 @@ ScriptObject::ActiveInstance::~ActiveInstance()
return GetStorage()->mode_instance;
}
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd)
{
ScriptStorage *s = GetStorage();
Debug(script, 6, "SetLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
Debug(script, 6, "SetLastCommand company={:02d} tile={:06x} cmd={} data={}", s->root_company, tile, cmd, FormatArrayAsHex(data));
s->last_tile = tile;
s->last_p1 = p1;
s->last_p2 = p2;
s->last_data = data;
s->last_cmd = cmd;
}
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd)
{
ScriptStorage *s = GetStorage();
Debug(script, 6, "CheckLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
Debug(script, 6, "CheckLastCommand company={:02d} tile={:06x} cmd={} data={}", s->root_company, tile, cmd, FormatArrayAsHex(data));
if (s->last_tile != tile) return false;
if (s->last_p1 != p1) return false;
if (s->last_p2 != p2) return false;
if (s->last_cmd != cmd) return false;
if (s->last_data != data) return false;
return true;
}
@ -326,7 +324,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
if (GetCommandFlags(cmd) & CMD_CLIENT_ID && p2 == 0) p2 = UINT32_MAX;
/* Store the command for command callback validation. */
if (!estimate_only && _networking && !_generating_world) SetLastCommand(tile, p1, p2, cmd);
if (!estimate_only && _networking && !_generating_world) SetLastCommand(tile, EndianBufferWriter<CommandDataBuffer>::FromValue(std::make_tuple(tile, p1, p2, command_text)), cmd);
/* Try to perform the command. */
CommandCost res = ::DoCommandPInternal(cmd, STR_NULL, (_networking && !_generating_world) ? ScriptObject::GetActiveInstance()->GetDoCommandCallback() : nullptr, false, estimate_only, false, tile, p1, p2, command_text);

View File

@ -75,12 +75,12 @@ protected:
/**
* Store the latest command executed by the script.
*/
static void SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
static void SetLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd);
/**
* Check if it's the latest command executed by the script.
*/
static bool CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
static bool CheckLastCommand(TileIndex tile, const CommandDataBuffer &data, Commands cmd);
/**
* Sets the DoCommand costs counter to a value.

View File

@ -687,11 +687,11 @@ SQInteger ScriptInstance::GetOpsTillSuspend()
return this->engine->GetOpsTillSuspend();
}
bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile, const CommandDataBuffer &data, Commands cmd)
{
ScriptObject::ActiveInstance active(this);
if (!ScriptObject::CheckLastCommand(tile, p1, p2, cmd)) {
if (!ScriptObject::CheckLastCommand(tile, data, cmd)) {
Debug(script, 1, "DoCommandCallback terminating a script, last command does not match expected command");
return false;
}
@ -705,7 +705,7 @@ bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile
ScriptObject::SetLastCost(result.GetCost());
}
ScriptObject::SetLastCommand(INVALID_TILE, 0, 0, CMD_END);
ScriptObject::SetLastCommand(INVALID_TILE, {}, CMD_END);
return true;
}

View File

@ -178,12 +178,11 @@ public:
* DoCommand callback function for all commands executed by scripts.
* @param result The result of the command.
* @param tile The tile on which the command was executed.
* @param p1 p1 as given to DoCommandPInternal.
* @param p2 p2 as given to DoCommandPInternal.
* @param data Command data as given to DoCommandPInternal.
* @param cmd cmd as given to DoCommandPInternal.
* @return true if we handled result.
*/
bool DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
bool DoCommandCallback(const CommandCost &result, TileIndex tile, const CommandDataBuffer &data, Commands cmd);
/**
* Insert an event for this script.

View File

@ -45,8 +45,7 @@ private:
bool last_command_res; ///< The last result of the command.
TileIndex last_tile; ///< The last tile passed to a command.
uint32 last_p1; ///< The last p1 passed to a command.
uint32 last_p2; ///< The last p2 passed to a command.
CommandDataBuffer last_data; ///< The last data passed to a command.
Commands last_cmd; ///< The last cmd passed to a command.
VehicleID new_vehicle_id; ///< The ID of the new Vehicle.
@ -77,8 +76,6 @@ public:
last_error (STR_NULL),
last_command_res (true),
last_tile (INVALID_TILE),
last_p1 (0),
last_p2 (0),
last_cmd (CMD_END),
new_vehicle_id (0),
new_sign_id (0),

View File

@ -116,7 +116,7 @@ CommandCost CmdRenameSign(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32
* @param p2 unused
* @param text unused
*/
void CcPlaceSign(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcPlaceSign(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Failed()) return;

View File

@ -44,7 +44,7 @@
#include "safeguards.h"
void CcTerraform(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcTerraform(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Succeeded()) {
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);

View File

@ -1009,7 +1009,7 @@ void ShowTownDirectory()
new TownDirectoryWindow(&_town_directory_desc);
}
void CcFoundTown(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcFoundTown(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Failed()) return;
@ -1017,7 +1017,7 @@ void CcFoundTown(const CommandCost &result, Commands cmd, TileIndex tile, uint32
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
void CcFoundRandomTown(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcFoundRandomTown(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy);
}

View File

@ -22,14 +22,11 @@
/**
* Callback for building wagons.
* @param result The result of the command.
* @param cmd Unused.
* @param result The result of the command.
* @param tile The tile the command was executed on.
* @param p1 Additional data for the command (for the #CommandProc)
* @param p2 Additional data for the command (for the #CommandProc)
* @param text Unused.
*/
void CcBuildWagon(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildWagon(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &)
{
if (result.Failed()) return;

View File

@ -2622,14 +2622,13 @@ static const StringID _vehicle_msg_translation_table[][4] = {
* @param result the result of the start/stop command
* @param cmd unused
* @param tile unused
* @param p1 vehicle ID
* @param p2 unused
* @param text unused
* @param data Command data
*/
void CcStartStopVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcStartStopVehicle(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;
auto [tile_, p1, p2, text] = EndianBufferReader::ToValue<CommandTraits<CMD_START_STOP_VEHICLE>::Args>(data);
const Vehicle *v = Vehicle::GetIfValid(p1);
if (v == nullptr || !v->IsPrimaryVehicle() || v->owner != _local_company) return;
@ -3127,11 +3126,9 @@ void StopGlobalFollowVehicle(const Vehicle *v)
* @param result indicates completion (or not) of the operation
* @param cmd unused
* @param tile unused
* @param p1 unused
* @param p2 unused
* @param text unused
* @param data unused
*/
void CcBuildPrimaryVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, TileIndex tile, const CommandDataBuffer &data)
{
if (result.Failed()) return;