mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Align parameter order of command callbacks to command handlers.
This commit is contained in:
parent
123c7f99c3
commit
4fc055d6e9
|
@ -93,12 +93,13 @@ 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 tile The tile on which the command was executed.
|
||||
* @param p1 p1 as given to DoCommandPInternal.
|
||||
* @param p2 p2 as given to DoCommandPInternal.
|
||||
* @param cmd cmd as given to DoCommandPInternal.
|
||||
* @param text text as given to DoCommandPInternal.
|
||||
*/
|
||||
void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcAI(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
/*
|
||||
* The company might not exist anymore. Check for this.
|
||||
|
|
|
@ -41,7 +41,7 @@ static void ShowBuildAirportPicker(Window *parent);
|
|||
|
||||
SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout);
|
||||
|
||||
void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildAirport(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
|
|
@ -50,15 +50,16 @@ typedef GUIList<BuildBridgeData> GUIBridgeList; ///< List of bridges, used in #B
|
|||
* Callback executed after a build Bridge CMD has been called
|
||||
*
|
||||
* @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 cmd unused
|
||||
* @param text unused
|
||||
*/
|
||||
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildBridge(const CommandCost &result, Commands cmd, TileIndex end_tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile);
|
||||
|
|
|
@ -318,7 +318,7 @@ static bool DoCommandP(Commands cmd, StringID err_message, CommandCallback *call
|
|||
}
|
||||
|
||||
if (!estimate_only && !only_sending && callback != nullptr) {
|
||||
callback(res, tile, p1, p2, cmd);
|
||||
callback(res, cmd, tile, p1, p2, text);
|
||||
}
|
||||
|
||||
return res.Succeeded();
|
||||
|
|
|
@ -443,12 +443,14 @@ template <Commands Tcmd> struct CommandTraits;
|
|||
* command succeeded or failed.
|
||||
*
|
||||
* @param result The result of the executed command
|
||||
* @param cmd The command that was executed
|
||||
* @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
|
||||
* @see CommandProc
|
||||
*/
|
||||
typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd);
|
||||
typedef void CommandCallback(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text);
|
||||
|
||||
/**
|
||||
* Structure for buffering the build command when selecting a station to join.
|
||||
|
|
|
@ -112,12 +112,13 @@ extern void DepotSortList(VehicleList *list);
|
|||
/**
|
||||
* This is the Callback method after the cloning attempt of a vehicle
|
||||
* @param result the result of the cloning command
|
||||
* @param cmd unused
|
||||
* @param tile unused
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
* @param cmd unused
|
||||
* @param text unused
|
||||
*/
|
||||
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcCloneVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ static void ShowBuildDocksDepotPicker(Window *parent);
|
|||
|
||||
static Axis _ship_depot_direction;
|
||||
|
||||
void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildDocks(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
@ -48,7 +48,7 @@ void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p
|
|||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||
}
|
||||
|
||||
void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile);
|
||||
}
|
||||
|
|
|
@ -82,12 +82,13 @@ 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 tile The tile on which the command was executed.
|
||||
* @param p1 p1 as given to DoCommandPInternal.
|
||||
* @param p2 p2 as given to DoCommandPInternal.
|
||||
* @param cmd cmd as given to DoCommandPInternal.
|
||||
* @param text text as given to DoCommandPInternal.
|
||||
*/
|
||||
void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcGame(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (Game::GetGameInstance()->DoCommandCallback(result, tile, p1, p2, cmd)) {
|
||||
Game::GetGameInstance()->Continue();
|
||||
|
|
|
@ -1141,13 +1141,14 @@ 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 cmd Unused.
|
||||
* @param text Unused.
|
||||
* @see CmdCreateGroup
|
||||
*/
|
||||
void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcCreateGroup(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
assert(p1 <= VEH_AIRCRAFT);
|
||||
|
@ -1159,17 +1160,18 @@ void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32
|
|||
/**
|
||||
* Open rename window after adding a vehicle to a new group via drag and drop.
|
||||
* @param result Did command succeed?
|
||||
* @param cmd Unused.
|
||||
* @param tile Unused.
|
||||
* @param p1 Unused.
|
||||
* @param p2 Bit 0-19: Vehicle ID.
|
||||
* @param cmd Unused.
|
||||
* @param text Unused.
|
||||
*/
|
||||
void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcAddVehicleNewGroup(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
assert(Vehicle::IsValidID(GB(p2, 0, 20)));
|
||||
|
||||
CcCreateGroup(result, 0, Vehicle::Get(GB(p2, 0, 20))->type, 0, cmd);
|
||||
CcCreateGroup(result, cmd, 0, Vehicle::Get(GB(p2, 0, 20))->type, 0, text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -219,12 +219,13 @@ 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 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 cmd Unused.
|
||||
* @param text Unused.
|
||||
*/
|
||||
void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildIndustry(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded()) return;
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl
|
|||
}
|
||||
|
||||
|
||||
void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcPlaySound_EXPLOSION(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile);
|
||||
}
|
||||
|
|
|
@ -85,7 +85,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, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ static const DiagDirection _place_depot_extra_dir[12] = {
|
|||
DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
|
||||
};
|
||||
|
||||
void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcRailDepot(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
@ -169,7 +169,7 @@ static void PlaceRail_Waypoint(TileIndex tile)
|
|||
}
|
||||
}
|
||||
|
||||
void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcStation(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
@ -276,7 +276,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w)
|
|||
}
|
||||
|
||||
/** Command callback for building a tunnel */
|
||||
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildRailTunnel(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded()) {
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
|
||||
|
|
|
@ -66,7 +66,7 @@ static RoadType _cur_roadtype;
|
|||
static DiagDirection _road_depot_orientation;
|
||||
static DiagDirection _road_station_picker_orientation;
|
||||
|
||||
void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
|
||||
}
|
||||
|
@ -90,13 +90,14 @@ 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 start_tile Starting tile of the tunnel.
|
||||
* @param p1 bit 0-3 railtype or roadtypes
|
||||
* bit 8-9 transport type
|
||||
* @param p2 unused
|
||||
* @param cmd unused
|
||||
* @param text unused
|
||||
*/
|
||||
void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildRoadTunnel(const CommandCost &result, Commands cmd, TileIndex start_tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded()) {
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
|
||||
|
@ -129,7 +130,7 @@ void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
|
|||
}
|
||||
}
|
||||
|
||||
void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcRoadDepot(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
@ -142,6 +143,7 @@ void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2
|
|||
/**
|
||||
* Command callback for building road stops.
|
||||
* @param result Result of the build road stop command.
|
||||
* @param cmd Unused.
|
||||
* @param tile Start tile.
|
||||
* @param p1 bit 0..7: Width of the road stop.
|
||||
* bit 8..15: Length of the road stop.
|
||||
|
@ -152,10 +154,10 @@ void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2
|
|||
* bit 3: #Axis of the road for drive-through stops.
|
||||
* bit 5..9: The roadtype.
|
||||
* bit 16..31: Station ID to join (NEW_STATION if build new one).
|
||||
* @param cmd Unused.
|
||||
* @param text Unused.
|
||||
* @see CmdBuildRoadStop
|
||||
*/
|
||||
void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcRoadStop(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
|
|
@ -110,12 +110,13 @@ CommandCost CmdRenameSign(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32
|
|||
/**
|
||||
* Callback function that is called after a sign is placed
|
||||
* @param result of the operation
|
||||
* @param cmd unused
|
||||
* @param tile unused
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
* @param cmd unused
|
||||
* @param text unused
|
||||
*/
|
||||
void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcPlaceSign(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
#include "safeguards.h"
|
||||
|
||||
void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcTerraform(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded()) {
|
||||
if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
|
||||
|
|
|
@ -1008,7 +1008,7 @@ void ShowTownDirectory()
|
|||
new TownDirectoryWindow(&_town_directory_desc);
|
||||
}
|
||||
|
||||
void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcFoundTown(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
@ -1016,7 +1016,7 @@ void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2
|
|||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||
}
|
||||
|
||||
void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcFoundRandomTown(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy);
|
||||
}
|
||||
|
|
|
@ -22,12 +22,13 @@
|
|||
/**
|
||||
* Callback for building wagons.
|
||||
* @param result The result of the command.
|
||||
* @param cmd Unused.
|
||||
* @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 cmd Unused.
|
||||
* @param text Unused.
|
||||
*/
|
||||
void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildWagon(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
|
|
@ -2616,11 +2616,13 @@ static const StringID _vehicle_msg_translation_table[][4] = {
|
|||
/**
|
||||
* This is the Callback method after attempting to start/stop a vehicle
|
||||
* @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
|
||||
*/
|
||||
void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcStartStopVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
@ -3119,12 +3121,13 @@ void StopGlobalFollowVehicle(const Vehicle *v)
|
|||
/**
|
||||
* This is the Callback method after the construction attempt of a primary vehicle
|
||||
* @param result indicates completion (or not) of the operation
|
||||
* @param cmd unused
|
||||
* @param tile unused
|
||||
* @param p1 unused
|
||||
* @param p2 unused
|
||||
* @param cmd unused
|
||||
* @param text unused
|
||||
*/
|
||||
void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, Commands cmd)
|
||||
void CcBuildPrimaryVehicle(const CommandCost &result, Commands cmd, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
|
||||
{
|
||||
if (result.Failed()) return;
|
||||
|
||||
|
|
Loading…
Reference in New Issue