mirror of https://github.com/OpenTTD/OpenTTD
(svn r18781) -Codechange: pass the CommandCost to the callback instead of whether it succeeded or not.
-Fix: AIs did update their last cost incorrectly in network games if the cost of the DC_EXEC phase differed from the ~DC_EXEC phase.release/1.0
parent
48df0d4e06
commit
2b97f38cd1
|
@ -20,8 +20,6 @@
|
||||||
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
|
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
|
||||||
|
|
||||||
|
|
||||||
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
|
||||||
|
|
||||||
class AI {
|
class AI {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -218,14 +218,15 @@
|
||||||
event->Release();
|
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) {
|
if (result.Failed()) {
|
||||||
AIObject::SetLastError(AIError::StringToError(_error_message));
|
AIObject::SetLastError(AIError::StringToError(result.GetErrorMessage()));
|
||||||
} else {
|
} else {
|
||||||
AIObject::IncreaseDoCommandCosts(AIObject::GetLastCost());
|
AIObject::IncreaseDoCommandCosts(result.GetCost());
|
||||||
|
AIObject::SetLastCost(result.GetCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
Company::Get(_current_company)->ai_instance->Continue();
|
Company::Get(_current_company)->ai_instance->Continue();
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef bool (AIModeProc)();
|
||||||
* command processing, and command-validation checks.
|
* command processing, and command-validation checks.
|
||||||
*/
|
*/
|
||||||
class AIObject : public SimpleCountedObject {
|
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;
|
friend class AIInstance;
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -31,12 +31,12 @@ static byte _selected_airport_type;
|
||||||
static void ShowBuildAirportPicker(Window *parent);
|
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) {
|
if (result.Failed()) return;
|
||||||
|
|
||||||
SndPlayTileFx(SND_1F_SPLAT, tile);
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
||||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceAirport(TileIndex tile)
|
static void PlaceAirport(TileIndex tile)
|
||||||
|
|
|
@ -44,14 +44,14 @@ typedef GUIList<BuildBridgeData> GUIBridgeList;
|
||||||
/**
|
/**
|
||||||
* Callback executed after a build Bridge CMD has been called
|
* 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 tile The tile where the command has been executed
|
||||||
* @param p1 not used
|
* @param p1 not used
|
||||||
* @param p2 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 */
|
/* Names of the build bridge selection window */
|
||||||
|
|
|
@ -1034,7 +1034,7 @@ struct BuildVehicleWindow : Window {
|
||||||
case BUILD_VEHICLE_WIDGET_BUILD: {
|
case BUILD_VEHICLE_WIDGET_BUILD: {
|
||||||
EngineID sel_eng = this->sel_engine;
|
EngineID sel_eng = this->sel_engine;
|
||||||
if (sel_eng != INVALID_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);
|
DoCommandP(this->window_number, sel_eng, 0, GetCmdBuildVeh(this->vehicle_type), callback);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -11,58 +11,12 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "callback_table.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
|
/* If you add a callback for DoCommandP, also add the callback in here
|
||||||
* see below for the full list!
|
* see below for the full list!
|
||||||
* If you don't do it, it won't work across the network!! */
|
* 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[] = {
|
CommandCallback * const _callback_table[] = {
|
||||||
/* 0x00 */ NULL,
|
/* 0x00 */ NULL,
|
||||||
/* 0x01 */ CcBuildPrimaryVehicle,
|
/* 0x01 */ CcBuildPrimaryVehicle,
|
||||||
|
|
|
@ -635,7 +635,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
|
||||||
|
|
||||||
_docommand_recursive = 0;
|
_docommand_recursive = 0;
|
||||||
|
|
||||||
if (callback) callback(true, tile, p1, p2);
|
if (callback) callback(res2, tile, p1, p2);
|
||||||
ClearStorageChanges(true);
|
ClearStorageChanges(true);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ show_error:
|
||||||
callb_err:
|
callb_err:
|
||||||
_docommand_recursive = 0;
|
_docommand_recursive = 0;
|
||||||
|
|
||||||
if (callback) callback(false, tile, p1, p2);
|
if (callback) callback(CMD_ERROR, tile, p1, p2);
|
||||||
ClearStorageChanges(false);
|
ClearStorageChanges(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,52 @@ static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
|
||||||
return 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;
|
CommandCallback CcBuildPrimaryVehicle;
|
||||||
|
|
||||||
#endif /* COMMAND_FUNC_H */
|
#endif /* COMMAND_FUNC_H */
|
||||||
|
|
|
@ -392,13 +392,13 @@ struct Command {
|
||||||
* are from the #CommandProc callback type. The boolean parameter indicates if the
|
* are from the #CommandProc callback type. The boolean parameter indicates if the
|
||||||
* command succeeded or failed.
|
* 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 tile The tile of the command action
|
||||||
* @param p1 Additional data of the command
|
* @param p1 Additional data of the command
|
||||||
* @param p1 Additional data of the command
|
* @param p1 Additional data of the command
|
||||||
* @see CommandProc
|
* @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.
|
* Structure for buffering the build command when selecting a station to join.
|
||||||
|
|
|
@ -121,14 +121,14 @@ extern void DepotSortList(VehicleList *list);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the Callback method after the cloning attempt of a vehicle
|
* 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 tile unused
|
||||||
* @param p1 unused
|
* @param p1 unused
|
||||||
* @param p2 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);
|
const Vehicle *v = Vehicle::Get(_new_vehicle_id);
|
||||||
|
|
||||||
|
|
|
@ -35,17 +35,17 @@ static void ShowBuildDocksDepotPicker(Window *parent);
|
||||||
|
|
||||||
static Axis _ship_depot_direction;
|
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) {
|
if (result.Failed()) return;
|
||||||
|
|
||||||
SndPlayTileFx(SND_02_SPLAT, tile);
|
SndPlayTileFx(SND_02_SPLAT, tile);
|
||||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
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) {
|
switch (select_proc) {
|
||||||
case DDSP_BUILD_BRIDGE:
|
case DDSP_BUILD_BRIDGE:
|
||||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
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);
|
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:
|
case DDSP_DEMOLISH_AREA:
|
||||||
|
|
|
@ -485,7 +485,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
case GRP_WIDGET_CREATE_GROUP: { // Create a new group
|
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);
|
DoCommandP(0, this->vehicle_type, 0, CMD_CREATE_GROUP | CMD_MSG(STR_ERROR_GROUP_CAN_T_CREATE), CcCreateGroup);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -725,9 +724,9 @@ static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner o
|
||||||
* @param p2 unused
|
* @param p2 unused
|
||||||
* @see CmdCreateGroup
|
* @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);
|
assert(p1 <= VEH_AIRCRAFT);
|
||||||
|
|
||||||
VehicleGroupWindow *w = FindVehicleGroupWindow((VehicleType)p1, _current_company);
|
VehicleGroupWindow *w = FindVehicleGroupWindow((VehicleType)p1, _current_company);
|
||||||
|
|
|
@ -21,8 +21,6 @@
|
||||||
#include "transport_type.h"
|
#include "transport_type.h"
|
||||||
|
|
||||||
/* main_gui.cpp */
|
/* 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 HandleOnEditText(const char *str);
|
||||||
void InitializeGUI();
|
void InitializeGUI();
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@
|
||||||
static int _rename_id = 1;
|
static int _rename_id = 1;
|
||||||
static int _rename_what = -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
|
#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). */
|
/* Inform the company of the action of one of it's clients (controllers). */
|
||||||
char msg[64];
|
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
|
#ifdef ENABLE_NETWORK
|
||||||
|
|
|
@ -66,9 +66,9 @@ static void ShowBuildWaypointPicker(Window *parent);
|
||||||
static void ShowStationBuilder(Window *parent);
|
static void ShowStationBuilder(Window *parent);
|
||||||
static void ShowSignalBuilder(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)
|
static void GenericPlaceRail(TileIndex tile, int cmd)
|
||||||
|
@ -128,9 +128,10 @@ 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) {
|
if (result.Failed()) return;
|
||||||
|
|
||||||
DiagDirection dir = (DiagDirection)p2;
|
DiagDirection dir = (DiagDirection)p2;
|
||||||
|
|
||||||
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||||
|
@ -143,7 +144,6 @@ void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
|
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 4]);
|
||||||
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
|
PlaceExtraDepotRail(tile, _place_depot_extra[dir + 8]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRail_Depot(TileIndex tile)
|
static void PlaceRail_Depot(TileIndex tile)
|
||||||
|
@ -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) {
|
if (result.Failed()) return;
|
||||||
|
|
||||||
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||||
/* Only close the station builder window if the default station and non persistent building is chosen. */
|
/* 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 (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRail_Station(TileIndex tile)
|
static void PlaceRail_Station(TileIndex tile)
|
||||||
|
@ -258,9 +258,9 @@ static void PlaceRail_Bridge(TileIndex tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Command callback for building a tunnel */
|
/** 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);
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -62,9 +62,9 @@ static RoadType _cur_roadtype;
|
||||||
static DiagDirection _road_depot_orientation;
|
static DiagDirection _road_depot_orientation;
|
||||||
static DiagDirection _road_station_picker_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);
|
SndPlayTileFx(SND_20_SPLAT_2, tile);
|
||||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||||
} else {
|
} 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) {
|
if (result.Failed()) return;
|
||||||
|
|
||||||
DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
|
DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
|
||||||
SndPlayTileFx(SND_1F_SPLAT, tile);
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
||||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
||||||
BuildRoadOutsideStation(tile, dir);
|
BuildRoadOutsideStation(tile, dir);
|
||||||
/* For a drive-through road stop build connecting road for other entrance */
|
/* For a drive-through road stop build connecting road for other entrance */
|
||||||
if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
|
if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PlaceRoad_Depot(TileIndex tile)
|
static void PlaceRoad_Depot(TileIndex tile)
|
||||||
|
|
|
@ -105,17 +105,17 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback function that is called after a sign is placed
|
* Callback function that is called after a sign is placed
|
||||||
* @param success of the operation
|
* @param result of the operation
|
||||||
* @param tile unused
|
* @param tile unused
|
||||||
* @param p1 unused
|
* @param p1 unused
|
||||||
* @param p2 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) {
|
if (result.Failed()) return;
|
||||||
|
|
||||||
ShowRenameSignWindow(Sign::Get(_new_sign_id));
|
ShowRenameSignWindow(Sign::Get(_new_sign_id));
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.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);
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
||||||
} else {
|
} else {
|
||||||
extern TileIndex _terraform_err_tile;
|
extern TileIndex _terraform_err_tile;
|
||||||
|
@ -145,8 +145,6 @@ static const uint16 _terraform_keycodes[] = {
|
||||||
'O',
|
'O',
|
||||||
};
|
};
|
||||||
|
|
||||||
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, CMD_PURCHASE_LAND_AREA | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E);
|
DoCommandP(tile, 0, 0, CMD_PURCHASE_LAND_AREA | CMD_MSG(STR_ERROR_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E);
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include "window_type.h"
|
#include "window_type.h"
|
||||||
|
|
||||||
void CcTerraform(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
|
||||||
|
|
||||||
Window *ShowTerraformToolbar(Window *link = NULL);
|
Window *ShowTerraformToolbar(Window *link = NULL);
|
||||||
void ShowTerraformToolbarWithTool(uint16 key, uint16 keycode);
|
void ShowTerraformToolbarWithTool(uint16 key, uint16 keycode);
|
||||||
Window *ShowEditorTerraformToolbar();
|
Window *ShowEditorTerraformToolbar();
|
||||||
|
|
|
@ -885,17 +885,17 @@ void ShowTownDirectory()
|
||||||
new TownDirectoryWindow(&_town_directory_desc);
|
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) {
|
if (result.Failed()) return;
|
||||||
|
|
||||||
SndPlayTileFx(SND_1F_SPLAT, tile);
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
||||||
if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
|
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. */
|
/** Widget numbers of town scenario editor window. */
|
||||||
|
|
|
@ -44,8 +44,6 @@ enum VehicleRailFlags {
|
||||||
VRF_TRAIN_STUCK = 8,
|
VRF_TRAIN_STUCK = 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
|
||||||
|
|
||||||
byte FreightWagonMult(CargoID cargo);
|
byte FreightWagonMult(CargoID cargo);
|
||||||
|
|
||||||
void UpdateTrainAcceleration(Train *v);
|
void UpdateTrainAcceleration(Train *v);
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.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. */
|
/* find a locomotive in the depot. */
|
||||||
const Vehicle *found = NULL;
|
const Vehicle *found = NULL;
|
||||||
|
|
|
@ -65,8 +65,6 @@ void VehicleEnterDepot(Vehicle *v);
|
||||||
|
|
||||||
bool CanBuildVehicleInfrastructure(VehicleType type);
|
bool CanBuildVehicleInfrastructure(VehicleType type);
|
||||||
|
|
||||||
void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
|
||||||
|
|
||||||
/** Position information of a vehicle after it moved */
|
/** Position information of a vehicle after it moved */
|
||||||
struct GetNewVehiclePosResult {
|
struct GetNewVehiclePosResult {
|
||||||
int x, y; ///< x and y position of the vehicle after moving
|
int x, y; ///< x and y position of the vehicle after moving
|
||||||
|
|
|
@ -2145,14 +2145,14 @@ void StopGlobalFollowVehicle(const Vehicle *v)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the Callback method after the construction attempt of a primary vehicle
|
* 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 tile unused
|
||||||
* @param p1 unused
|
* @param p1 unused
|
||||||
* @param p2 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);
|
const Vehicle *v = Vehicle::Get(_new_vehicle_id);
|
||||||
if (v->tile == _backup_orders_tile) {
|
if (v->tile == _backup_orders_tile) {
|
||||||
|
|
Loading…
Reference in New Issue