summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ai/ai.hpp2
-rw-r--r--src/ai/ai_core.cpp11
-rw-r--r--src/ai/api/ai_object.hpp2
-rw-r--r--src/airport_gui.cpp10
-rw-r--r--src/bridge_gui.cpp6
-rw-r--r--src/build_vehicle_gui.cpp2
-rw-r--r--src/callback_table.cpp48
-rw-r--r--src/command.cpp4
-rw-r--r--src/command_func.h46
-rw-r--r--src/command_type.h4
-rw-r--r--src/depot_gui.cpp6
-rw-r--r--src/dock_gui.cpp15
-rw-r--r--src/group_gui.cpp5
-rw-r--r--src/gui.h2
-rw-r--r--src/main_gui.cpp8
-rw-r--r--src/rail_gui.cpp42
-rw-r--r--src/road_gui.cpp26
-rw-r--r--src/signs_cmd.cpp12
-rw-r--r--src/terraform_gui.cpp6
-rw-r--r--src/terraform_gui.h2
-rw-r--r--src/town_gui.cpp14
-rw-r--r--src/train.h2
-rw-r--r--src/train_gui.cpp4
-rw-r--r--src/vehicle_func.h2
-rw-r--r--src/vehicle_gui.cpp6
25 files changed, 137 insertions, 150 deletions
diff --git a/src/ai/ai.hpp b/src/ai/ai.hpp
index a23c411af..04eb7b16d 100644
--- a/src/ai/ai.hpp
+++ b/src/ai/ai.hpp
@@ -20,8 +20,6 @@
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
-void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
class AI {
public:
/**
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index baf738920..eb93ecff3 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -218,14 +218,15 @@
event->Release();
}
-void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- AIObject::SetLastCommandRes(success);
+ AIObject::SetLastCommandRes(result.Succeeded());
- if (!success) {
- AIObject::SetLastError(AIError::StringToError(_error_message));
+ if (result.Failed()) {
+ AIObject::SetLastError(AIError::StringToError(result.GetErrorMessage()));
} else {
- AIObject::IncreaseDoCommandCosts(AIObject::GetLastCost());
+ AIObject::IncreaseDoCommandCosts(result.GetCost());
+ AIObject::SetLastCost(result.GetCost());
}
Company::Get(_current_company)->ai_instance->Continue();
diff --git a/src/ai/api/ai_object.hpp b/src/ai/api/ai_object.hpp
index 98343e870..77e9fe885 100644
--- a/src/ai/api/ai_object.hpp
+++ b/src/ai/api/ai_object.hpp
@@ -36,7 +36,7 @@ typedef bool (AIModeProc)();
* command processing, and command-validation checks.
*/
class AIObject : public SimpleCountedObject {
-friend void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
+friend void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2);
friend class AIInstance;
protected:
/**
diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp
index bb0fb6ef3..02b2bc627 100644
--- a/src/airport_gui.cpp
+++ b/src/airport_gui.cpp
@@ -31,12 +31,12 @@ static byte _selected_airport_type;
static void ShowBuildAirportPicker(Window *parent);
-void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
- SndPlayTileFx(SND_1F_SPLAT, tile);
- if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
- }
+ if (result.Failed()) return;
+
+ SndPlayTileFx(SND_1F_SPLAT, tile);
+ if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
static void PlaceAirport(TileIndex tile)
diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp
index e64fcd8ff..d94369232 100644
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -44,14 +44,14 @@ typedef GUIList<BuildBridgeData> GUIBridgeList;
/**
* Callback executed after a build Bridge CMD has been called
*
- * @param success True if the build succeded
+ * @param result Whether the build succeded
* @param tile The tile where the command has been executed
* @param p1 not used
* @param p2 not used
*/
-void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildBridge(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
+ if (result.Succeeded()) SndPlayTileFx(SND_27_BLACKSMITH_ANVIL, tile);
}
/* Names of the build bridge selection window */
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index a0660d4ed..cfb7cd1bf 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1034,7 +1034,7 @@ struct BuildVehicleWindow : Window {
case BUILD_VEHICLE_WIDGET_BUILD: {
EngineID sel_eng = this->sel_engine;
if (sel_eng != INVALID_ENGINE) {
- CommandCallback *callback = (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? CcBuildWagon : CcBuildPrimaryVehicle;
+ CommandCallback *callback = (this->vehicle_type == VEH_TRAIN && RailVehInfo(sel_eng)->railveh_type == RAILVEH_WAGON) ? NULL : CcBuildPrimaryVehicle;
DoCommandP(this->window_number, sel_eng, 0, GetCmdBuildVeh(this->vehicle_type), callback);
}
break;
diff --git a/src/callback_table.cpp b/src/callback_table.cpp
index ff369d076..001c6cb34 100644
--- a/src/callback_table.cpp
+++ b/src/callback_table.cpp
@@ -11,58 +11,12 @@
#include "stdafx.h"
#include "callback_table.h"
-#include "command_type.h"
+#include "command_func.h"
/* If you add a callback for DoCommandP, also add the callback in here
* see below for the full list!
* If you don't do it, it won't work across the network!! */
-/* ai/ai_core.cpp */
-CommandCallback CcAI;
-
-/* airport_gui.cpp */
-CommandCallback CcBuildAirport;
-
-/* bridge_gui.cpp */
-CommandCallback CcBuildBridge;
-
-/* dock_gui.cpp */
-CommandCallback CcBuildDocks;
-CommandCallback CcBuildCanal;
-
-/* depot_gui.cpp */
-CommandCallback CcCloneVehicle;
-
-/* group_gui.cpp */
-CommandCallback CcCreateGroup;
-
-/* main_gui.cpp */
-CommandCallback CcPlaySound10;
-CommandCallback CcPlaceSign;
-CommandCallback CcTerraform;
-CommandCallback CcGiveMoney;
-
-/* rail_gui.cpp */
-CommandCallback CcPlaySound1E;
-CommandCallback CcRailDepot;
-CommandCallback CcStation;
-CommandCallback CcBuildRailTunnel;
-
-/* road_gui.cpp */
-CommandCallback CcPlaySound1D;
-CommandCallback CcBuildRoadTunnel;
-CommandCallback CcRoadDepot;
-
-/* train_gui.cpp */
-CommandCallback CcBuildWagon;
-
-/* town_gui.cpp */
-CommandCallback CcFoundTown;
-CommandCallback CcFoundRandomTown;
-
-/* vehicle_gui.cpp */
-CommandCallback CcBuildPrimaryVehicle;
-
CommandCallback * const _callback_table[] = {
/* 0x00 */ NULL,
/* 0x01 */ CcBuildPrimaryVehicle,
diff --git a/src/command.cpp b/src/command.cpp
index 35e27577b..430be00c6 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -635,7 +635,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
_docommand_recursive = 0;
- if (callback) callback(true, tile, p1, p2);
+ if (callback) callback(res2, tile, p1, p2);
ClearStorageChanges(true);
return true;
@@ -648,7 +648,7 @@ show_error:
callb_err:
_docommand_recursive = 0;
- if (callback) callback(false, tile, p1, p2);
+ if (callback) callback(CMD_ERROR, tile, p1, p2);
ClearStorageChanges(false);
return false;
}
diff --git a/src/command_func.h b/src/command_func.h
index 5f6bf910e..14a683623 100644
--- a/src/command_func.h
+++ b/src/command_func.h
@@ -107,6 +107,52 @@ static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
return flags;
}
+/*** All command callbacks that exist ***/
+
+/* ai/ai_core.cpp */
+CommandCallback CcAI;
+
+/* airport_gui.cpp */
+CommandCallback CcBuildAirport;
+
+/* bridge_gui.cpp */
+CommandCallback CcBuildBridge;
+
+/* dock_gui.cpp */
+CommandCallback CcBuildDocks;
+CommandCallback CcBuildCanal;
+
+/* depot_gui.cpp */
+CommandCallback CcCloneVehicle;
+
+/* group_gui.cpp */
+CommandCallback CcCreateGroup;
+
+/* main_gui.cpp */
+CommandCallback CcPlaySound10;
+CommandCallback CcPlaceSign;
+CommandCallback CcTerraform;
+CommandCallback CcGiveMoney;
+
+/* rail_gui.cpp */
+CommandCallback CcPlaySound1E;
+CommandCallback CcRailDepot;
+CommandCallback CcStation;
+CommandCallback CcBuildRailTunnel;
+
+/* road_gui.cpp */
+CommandCallback CcPlaySound1D;
+CommandCallback CcBuildRoadTunnel;
+CommandCallback CcRoadDepot;
+
+/* train_gui.cpp */
+CommandCallback CcBuildWagon;
+
+/* town_gui.cpp */
+CommandCallback CcFoundTown;
+CommandCallback CcFoundRandomTown;
+
+/* vehicle_gui.cpp */
CommandCallback CcBuildPrimaryVehicle;
#endif /* COMMAND_FUNC_H */
diff --git a/src/command_type.h b/src/command_type.h
index 1a48f287a..0bff05003 100644
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -392,13 +392,13 @@ struct Command {
* are from the #CommandProc callback type. The boolean parameter indicates if the
* command succeeded or failed.
*
- * @param success If the command succeeded or not.
+ * @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
* @see CommandProc
*/
-typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
+typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2);
/**
* Structure for buffering the build command when selecting a station to join.
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 9c918a4e1..2f3a57940 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -121,14 +121,14 @@ extern void DepotSortList(VehicleList *list);
/**
* This is the Callback method after the cloning attempt of a vehicle
- * @param success indicates completion (or not) of the operation
+ * @param result the result of the cloning command
* @param tile unused
* @param p1 unused
* @param p2 unused
*/
-void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (!success) return;
+ if (result.Failed()) return;
const Vehicle *v = Vehicle::Get(_new_vehicle_id);
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 1d15f2142..59a17b512 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -35,17 +35,17 @@ static void ShowBuildDocksDepotPicker(Window *parent);
static Axis _ship_depot_direction;
-void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
- SndPlayTileFx(SND_02_SPLAT, tile);
- if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
- }
+ if (result.Failed()) return;
+
+ SndPlayTileFx(SND_02_SPLAT, tile);
+ if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
-void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildCanal(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) SndPlayTileFx(SND_02_SPLAT, tile);
+ if (result.Succeeded()) SndPlayTileFx(SND_02_SPLAT, tile);
}
@@ -218,7 +218,6 @@ struct BuildDocksToolbarWindow : Window {
switch (select_proc) {
case DDSP_BUILD_BRIDGE:
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
- extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2);
DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CMD_BUILD_BRIDGE | CMD_MSG(STR_ERROR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge);
case DDSP_DEMOLISH_AREA:
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 318a2972e..be0326465 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -485,7 +485,6 @@ public:
}
case GRP_WIDGET_CREATE_GROUP: { // Create a new group
- extern void CcCreateGroup(bool success, TileIndex tile, uint32 p1, uint32 p2);
DoCommandP(0, this->vehicle_type, 0, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup);
break;
}
@@ -725,9 +724,9 @@ static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner o
* @param p2 unused
* @see CmdCreateGroup
*/
-void CcCreateGroup(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (!success) return;
+ if (result.Failed()) return;
assert(p1 <= VEH_AIRCRAFT);
VehicleGroupWindow *w = FindVehicleGroupWindow((VehicleType)p1, _current_company);
diff --git a/src/gui.h b/src/gui.h
index 5e7fc5354..744ae02c2 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -21,8 +21,6 @@
#include "transport_type.h"
/* main_gui.cpp */
-void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2);
-void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
void HandleOnEditText(const char *str);
void InitializeGUI();
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 5ba32dfac..64f7cebad 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -43,10 +43,10 @@
static int _rename_id = 1;
static int _rename_what = -1;
-void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
#ifdef ENABLE_NETWORK
- if (!success || !_settings_game.economy.give_money) return;
+ if (result.Failed() || !_settings_game.economy.give_money) return;
/* Inform the company of the action of one of it's clients (controllers). */
char msg[64];
@@ -112,9 +112,9 @@ bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyl
}
-void CcPlaySound10(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcPlaySound10(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
+ if (result.Succeeded()) SndPlayTileFx(SND_12_EXPLOSION, tile);
}
#ifdef ENABLE_NETWORK
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 4eadad6c0..3c9127a9f 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -66,9 +66,9 @@ static void ShowBuildWaypointPicker(Window *parent);
static void ShowStationBuilder(Window *parent);
static void ShowSignalBuilder(Window *parent);
-void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcPlaySound1E(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) SndPlayTileFx(SND_20_SPLAT_2, tile);
+ if (result.Succeeded()) SndPlayTileFx(SND_20_SPLAT_2, tile);
}
static void GenericPlaceRail(TileIndex tile, int cmd)
@@ -128,21 +128,21 @@ static const uint16 _place_depot_extra[12] = {
};
-void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
- DiagDirection dir = (DiagDirection)p2;
+ if (result.Failed()) return;
- SndPlayTileFx(SND_20_SPLAT_2, tile);
- if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
+ DiagDirection dir = (DiagDirection)p2;
- tile += TileOffsByDiagDir(dir);
+ SndPlayTileFx(SND_20_SPLAT_2, tile);
+ if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
- if (IsTileType(tile, MP_RAILWAY)) {
- PlaceExtraDepotRail(tile, _place_depot_extra[dir]);
- PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
- PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
- }
+ tile += TileOffsByDiagDir(dir);
+
+ if (IsTileType(tile, MP_RAILWAY)) {
+ PlaceExtraDepotRail(tile, _place_depot_extra[dir]);
+ PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
+ PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
}
}
@@ -171,13 +171,13 @@ static void PlaceRail_Waypoint(TileIndex tile)
}
}
-void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
- SndPlayTileFx(SND_20_SPLAT_2, tile);
- /* Only close the station builder window if the default station and non persistent building is chosen. */
- if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
- }
+ if (result.Failed()) return;
+
+ SndPlayTileFx(SND_20_SPLAT_2, tile);
+ /* Only close the station builder window if the default station and non persistent building is chosen. */
+ if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
static void PlaceRail_Station(TileIndex tile)
@@ -258,9 +258,9 @@ static void PlaceRail_Bridge(TileIndex tile)
}
/** Command callback for building a tunnel */
-void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
+ if (result.Succeeded()) {
SndPlayTileFx(SND_20_SPLAT_2, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
} else {
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 41ce1f7ab..9c8f5f67d 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -62,9 +62,9 @@ static RoadType _cur_roadtype;
static DiagDirection _road_depot_orientation;
static DiagDirection _road_station_picker_orientation;
-void CcPlaySound1D(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcPlaySound1D(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) SndPlayTileFx(SND_1F_SPLAT, tile);
+ if (result.Succeeded()) SndPlayTileFx(SND_1F_SPLAT, tile);
}
/**
@@ -119,9 +119,9 @@ static void PlaceRoad_Bridge(TileIndex tile)
}
-void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildRoadTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
+ if (result.Succeeded()) {
SndPlayTileFx(SND_20_SPLAT_2, tile);
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
} else {
@@ -191,16 +191,16 @@ static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
}
}
-void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
- DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
- SndPlayTileFx(SND_1F_SPLAT, tile);
- if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
- BuildRoadOutsideStation(tile, dir);
- /* For a drive-through road stop build connecting road for other entrance */
- if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
- }
+ if (result.Failed()) return;
+
+ DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
+ SndPlayTileFx(SND_1F_SPLAT, tile);
+ if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
+ BuildRoadOutsideStation(tile, dir);
+ /* For a drive-through road stop build connecting road for other entrance */
+ if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
}
static void PlaceRoad_Depot(TileIndex tile)
diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp
index dff599b65..90ccb89f8 100644
--- a/src/signs_cmd.cpp
+++ b/src/signs_cmd.cpp
@@ -105,17 +105,17 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/**
* Callback function that is called after a sign is placed
- * @param success of the operation
+ * @param result of the operation
* @param tile unused
* @param p1 unused
* @param p2 unused
*/
-void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
- ShowRenameSignWindow(Sign::Get(_new_sign_id));
- ResetObjectToPlace();
- }
+ if (result.Failed()) return;
+
+ ShowRenameSignWindow(Sign::Get(_new_sign_id));
+ ResetObjectToPlace();
}
/**
diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp
index 7ce150317..9b8d3b37e 100644
--- a/src/terraform_gui.cpp
+++ b/src/terraform_gui.cpp
@@ -36,9 +36,9 @@
#include "table/sprites.h"
#include "table/strings.h"
-void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
+ if (result.Succeeded()) {
SndPlayTileFx(SND_1F_SPLAT, tile);
} else {
extern TileIndex _terraform_err_tile;
@@ -145,8 +145,6 @@ static const uint16 _terraform_keycodes[] = {
'O',
};
-void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
static void PlaceProc_BuyLand(TileIndex tile)
{
DoCommandP(tile, 0, 0, CMD_PURCHASE_LAND_AREA | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E);
diff --git a/src/terraform_gui.h b/src/terraform_gui.h
index 8cf29cb7f..c6ea5f51e 100644
--- a/src/terraform_gui.h
+++ b/src/terraform_gui.h
@@ -14,8 +14,6 @@
#include "window_type.h"
-void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
Window *ShowTerraformToolbar(Window *link = NULL);
void ShowTerraformToolbarWithTool(uint16 key, uint16 keycode);
Window *ShowEditorTerraformToolbar();
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index bd19ec39e..aed340c41 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -885,17 +885,17 @@ void ShowTownDirectory()
new TownDirectoryWindow(&_town_directory_desc);
}
-void CcFoundTown(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) {
- SndPlayTileFx(SND_1F_SPLAT, tile);
- if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
- }
+ if (result.Failed()) return;
+
+ SndPlayTileFx(SND_1F_SPLAT, tile);
+ if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
}
-void CcFoundRandomTown(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (success) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy);
+ if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy);
}
/** Widget numbers of town scenario editor window. */
diff --git a/src/train.h b/src/train.h
index d8979e29d..66a42dfd9 100644
--- a/src/train.h
+++ b/src/train.h
@@ -44,8 +44,6 @@ enum VehicleRailFlags {
VRF_TRAIN_STUCK = 8,
};
-void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
byte FreightWagonMult(CargoID cargo);
void UpdateTrainAcceleration(Train *v);
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 40be8f10f..1f923a79c 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -23,9 +23,9 @@
#include "table/sprites.h"
#include "table/strings.h"
-void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (!success) return;
+ if (result.Failed()) return;
/* find a locomotive in the depot. */
const Vehicle *found = NULL;
diff --git a/src/vehicle_func.h b/src/vehicle_func.h
index b37f8e56e..5b58a8fef 100644
--- a/src/vehicle_func.h
+++ b/src/vehicle_func.h
@@ -65,8 +65,6 @@ void VehicleEnterDepot(Vehicle *v);
bool CanBuildVehicleInfrastructure(VehicleType type);
-void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
-
/** Position information of a vehicle after it moved */
struct GetNewVehiclePosResult {
int x, y; ///< x and y position of the vehicle after moving
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index ee42e15e8..1415b0d7a 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -2145,14 +2145,14 @@ void StopGlobalFollowVehicle(const Vehicle *v)
/**
* This is the Callback method after the construction attempt of a primary vehicle
- * @param success indicates completion (or not) of the operation
+ * @param result indicates completion (or not) of the operation
* @param tile unused
* @param p1 unused
* @param p2 unused
*/
-void CcBuildPrimaryVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
+void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
- if (!success) return;
+ if (result.Failed()) return;
const Vehicle *v = Vehicle::Get(_new_vehicle_id);
if (v->tile == _backup_orders_tile) {