Changeset - r14220:2b66d13ca715
[Not reviewed]
master
0 25 0
rubidium - 15 years ago 2010-01-11 18:46:09
rubidium@openttd.org
(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.
25 files changed with 112 insertions and 125 deletions:
0 comments (0 inline, 0 general)
src/ai/ai.hpp
Show inline comments
 
@@ -17,14 +17,12 @@
 
#include "../core/string_compare_type.hpp"
 
#include <map>
 

	
 
typedef std::map<const char *, class AIInfo *, StringCompare> AIInfoList;
 

	
 

	
 
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
 
class AI {
 
public:
 
	/**
 
	 * The default months AIs start after eachother.
 
	 */
 
	enum StartNext {
src/ai/ai_core.cpp
Show inline comments
 
@@ -215,20 +215,21 @@
 
		if (c != skip_company) AI::NewEvent(c, event);
 
	}
 

	
 
	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();
 
}
 

	
 
/* static */ void AI::Save(CompanyID company)
src/ai/api/ai_object.hpp
Show inline comments
 
@@ -33,13 +33,13 @@ typedef bool (AIModeProc)();
 
 * Uper-parent object of all API classes. You should never use this class in
 
 *   your AI, as it doesn't publish any public functions. It is used
 
 *   internally to have a common place to handle general things, like internal
 
 *   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:
 
	/**
 
	 * Executes a raw DoCommand for the AI.
 
	 */
 
	static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text = NULL, AISuspendCallbackProc *callback = NULL);
src/airport_gui.cpp
Show inline comments
 
@@ -28,19 +28,19 @@
 

	
 
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) {
 
	if (result.Failed()) return;
 

	
 
		SndPlayTileFx(SND_1F_SPLAT, tile);
 
		if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
 
	}
 
}
 

	
 
static void PlaceAirport(TileIndex tile)
 
{
 
	uint32 p2 = _ctrl_pressed;
 
	SB(p2, 16, 16, INVALID_STATION); // no station to join
 

	
src/bridge_gui.cpp
Show inline comments
 
@@ -41,20 +41,20 @@ struct BuildBridgeData {
 

	
 
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 */
 
enum BuildBridgeSelectionWidgets {
 
	BBSW_CAPTION,
 
	BBSW_DROPDOWN_ORDER,
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -1031,13 +1031,13 @@ struct BuildVehicleWindow : Window {
 
				ShowDropDownMenu(this, this->cargo_filter_texts, this->cargo_filter_criteria, BUILD_VEHICLE_WIDGET_CARGO_FILTER_DROPDOWN, 0, 0);
 
				break;
 

	
 
			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;
 
			}
 

	
 
			case BUILD_VEHICLE_WIDGET_RENAME: {
src/callback_table.cpp
Show inline comments
 
@@ -8,64 +8,18 @@
 
 */
 

	
 
/** @file callback_table.cpp All command callbacks. */
 

	
 
#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,
 
	/* 0x02 */ CcBuildAirport,
 
	/* 0x03 */ CcBuildBridge,
 
	/* 0x04 */ CcBuildCanal,
src/command.cpp
Show inline comments
 
@@ -632,26 +632,26 @@ bool DoCommandP(TileIndex tile, uint32 p
 
			if (res2.GetCost() == 0) goto callb_err;
 
		}
 
	}
 

	
 
	_docommand_recursive = 0;
 

	
 
	if (callback) callback(true, tile, p1, p2);
 
	if (callback) callback(res2, tile, p1, p2);
 
	ClearStorageChanges(true);
 
	return true;
 

	
 
show_error:
 
	/* show error message if the command fails? */
 
	if (IsLocalCompany() && error_part1 != 0 && my_cmd) {
 
		ShowErrorMessage(error_part1, _error_message, x, y);
 
	}
 

	
 
callb_err:
 
	_docommand_recursive = 0;
 

	
 
	if (callback) callback(false, tile, p1, p2);
 
	if (callback) callback(CMD_ERROR, tile, p1, p2);
 
	ClearStorageChanges(false);
 
	return false;
 
}
 

	
 

	
 
CommandCost CommandCost::AddCost(CommandCost ret)
src/command_func.h
Show inline comments
 
@@ -104,9 +104,55 @@ static inline DoCommandFlag CommandFlags
 
	if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
 
	if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
 
	if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
 
	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 */
src/command_type.h
Show inline comments
 
@@ -389,19 +389,19 @@ struct Command {
 
 * Define a callback function for the client, after the command is finished.
 
 *
 
 * Functions of this type are called after the command is finished. The parameters
 
 * 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.
 
 */
 
struct CommandContainer {
 
	TileIndex tile;            ///< tile command being executed on
src/depot_gui.cpp
Show inline comments
 
@@ -118,20 +118,20 @@ static const WindowDesc _aircraft_depot_
 
);
 

	
 
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);
 

	
 
	ShowVehicleViewWindow(v);
 
}
 

	
src/dock_gui.cpp
Show inline comments
 
@@ -32,23 +32,23 @@
 

	
 
static void ShowBuildDockStationPicker(Window *parent);
 
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) {
 
	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);
 
}
 

	
 

	
 
static void PlaceDocks_Dock(TileIndex tile)
 
{
 
	uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join
 
@@ -215,13 +215,12 @@ struct BuildDocksToolbarWindow : Window 
 
	virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
 
	{
 
		if (pt.x != -1) {
 
			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:
 
					GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
 
					break;
 
				case DDSP_CREATE_WATER:
src/group_gui.cpp
Show inline comments
 
@@ -482,13 +482,12 @@ public:
 

	
 
				this->SetDirty();
 
				break;
 
			}
 

	
 
			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;
 
			}
 

	
 
			case GRP_WIDGET_DELETE_GROUP: { // Delete the selected group
 
				GroupID group = this->group_sel;
 
@@ -722,15 +721,15 @@ static inline VehicleGroupWindow *FindVe
 
 * @param success did command succeed?
 
 * @param tile unused
 
 * @param p1 vehicle type
 
 * @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);
 
	if (w != NULL) w->ShowRenameGroupWindow(_new_group_id);
 
}
 

	
src/gui.h
Show inline comments
 
@@ -18,14 +18,12 @@
 
#include "economy_type.h"
 
#include "tile_type.h"
 
#include "strings_type.h"
 
#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();
 

	
 
/* settings_gui.cpp */
 
void ShowGameOptions();
 
void ShowGameDifficulty();
src/main_gui.cpp
Show inline comments
 
@@ -40,16 +40,16 @@
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
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];
 
	SetDParam(0, p2);
 
	GetString(msg, STR_COMPANY_NAME, lastof(msg));
 

	
 
@@ -109,15 +109,15 @@ bool HandlePlacePushButton(Window *w, in
 
	w->LowerWidget(widget);
 
	_place_proc = placeproc;
 
	return true;
 
}
 

	
 

	
 
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
 
void ShowNetworkGiveMoneyWindow(CompanyID company)
 
{
 
	_rename_id = company;
src/rail_gui.cpp
Show inline comments
 
@@ -63,15 +63,15 @@ static RailStationGUISettings _railstati
 
static void HandleStationPlacement(TileIndex start, TileIndex end);
 
static void ShowBuildTrainDepotPicker(Window *parent);
 
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)
 
{
 
	DoCommandP(tile, _cur_railtype, cmd,
 
		_remove_button_clicked ?
 
@@ -125,15 +125,16 @@ static const uint16 _place_depot_extra[1
 
	0x0604, 0x2102, 0x1202, 0x0505,  // First additional track for directions 0..3
 
	0x2400, 0x2801, 0x1800, 0x1401,  // Second additional track
 
	0x2203, 0x0904, 0x0A05, 0x1103,  // Third additional track
 
};
 

	
 

	
 
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;
 

	
 
		SndPlayTileFx(SND_20_SPLAT_2, tile);
 
		if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
 

	
 
		tile += TileOffsByDiagDir(dir);
 
@@ -141,13 +142,12 @@ void CcRailDepot(bool success, TileIndex
 
		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]);
 
		}
 
	}
 
}
 

	
 
static void PlaceRail_Depot(TileIndex tile)
 
{
 
	DoCommandP(tile, _cur_railtype, _build_depot_direction,
 
		CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT),
 
		CcRailDepot);
 
@@ -168,20 +168,20 @@ static void PlaceRail_Waypoint(TileIndex
 
		/* Tile where we can't build rail waypoints. This is always going to fail,
 
		 * but provides the user with a proper error message. */
 
		DoCommandP(tile, 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT));
 
	}
 
}
 

	
 
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);
 
		/* 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)
 
{
 
	if (_remove_button_clicked) {
 
		VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
 
		VpSetPlaceSizingLimit(-1);
 
@@ -255,15 +255,15 @@ static void GenericPlaceSignals(TileInde
 
static void PlaceRail_Bridge(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
 
}
 

	
 
/** 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 {
 
		SetRedErrorSquare(_build_tunnel_endtile);
 
	}
 
}
src/road_gui.cpp
Show inline comments
 
@@ -59,15 +59,15 @@ static RoadFlags _place_road_flag;
 

	
 
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);
 
}
 

	
 
/**
 
 * Set the initial flags for the road constuction.
 
 * The flags are:
 
 * @li The direction is the X-dir
 
@@ -116,15 +116,15 @@ static void PlaceRoad_AutoRoad(TileIndex
 
static void PlaceRoad_Bridge(TileIndex tile)
 
{
 
	VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
 
}
 

	
 

	
 
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 {
 
		SetRedErrorSquare(_build_tunnel_endtile);
 
	}
 
}
 
@@ -188,23 +188,23 @@ static void BuildRoadOutsideStation(Tile
 
		if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
 
			DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, CMD_BUILD_ROAD);
 
		}
 
	}
 
}
 

	
 
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);
 
		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)
 
{
 
	DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CMD_BUILD_ROAD_DEPOT | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot), CcRoadDepot);
 
}
 

	
src/signs_cmd.cpp
Show inline comments
 
@@ -102,24 +102,24 @@ CommandCost CmdRenameSign(TileIndex tile
 

	
 
	return CommandCost();
 
}
 

	
 
/**
 
 * 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) {
 
	if (result.Failed()) return;
 

	
 
		ShowRenameSignWindow(Sign::Get(_new_sign_id));
 
		ResetObjectToPlace();
 
	}
 
}
 

	
 
/**
 
 *
 
 * PlaceProc function, called when someone pressed the button if the
 
 *  sign-tool is selected
 
 * @param tile on which to place the sign
src/terraform_gui.cpp
Show inline comments
 
@@ -33,15 +33,15 @@
 
#include "tilehighlight_func.h"
 
#include "strings_func.h"
 

	
 
#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;
 
		SetRedErrorSquare(_terraform_err_tile);
 
	}
 
}
 
@@ -142,14 +142,12 @@ static const uint16 _terraform_keycodes[
 
	'D',
 
	'U',
 
	'I',
 
	'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);
 
}
 

	
 
void PlaceProc_DemolishArea(TileIndex tile)
src/terraform_gui.h
Show inline comments
 
@@ -11,14 +11,12 @@
 

	
 
#ifndef TERRAFORM_GUI_H
 
#define TERRAFORM_GUI_H
 

	
 
#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();
 
void ShowEditorTerraformToolbarWithTool(uint16 key, uint16 keycode);
 

	
 
#endif /* GUI_H */
src/town_gui.cpp
Show inline comments
 
@@ -882,23 +882,23 @@ static const WindowDesc _town_directory_
 
void ShowTownDirectory()
 
{
 
	if (BringWindowToFrontById(WC_TOWN_DIRECTORY, 0)) return;
 
	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);
 
		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. */
 
enum TownScenarioEditorWidgets {
 
	TSEW_BACKGROUND,
 
	TSEW_NEWTOWN,
src/train.h
Show inline comments
 
@@ -41,14 +41,12 @@ enum VehicleRailFlags {
 
	VRF_TOGGLE_REVERSE = 7,
 

	
 
	/* used to mark a train that can't get a path reservation */
 
	VRF_TRAIN_STUCK    = 8,
 
};
 

	
 
void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2);
 

	
 
byte FreightWagonMult(CargoID cargo);
 

	
 
void UpdateTrainAcceleration(Train *v);
 
void CheckTrainsLengths();
 

	
 
void FreeTrainTrackReservation(const Train *v, TileIndex origin = INVALID_TILE, Trackdir orig_td = INVALID_TRACKDIR);
src/train_gui.cpp
Show inline comments
 
@@ -20,15 +20,15 @@
 
#include "engine_base.h"
 
#include "window_func.h"
 

	
 
#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;
 
	const Train *t;
 
	FOR_ALL_TRAINS(t) {
 
		if (t->IsFrontEngine() && t->tile == tile &&
src/vehicle_func.h
Show inline comments
 
@@ -62,14 +62,12 @@ UnitID GetFreeUnitNumber(VehicleType typ
 

	
 
CommandCost SendAllVehiclesToDepot(VehicleType type, DoCommandFlag flags, bool service, Owner owner, uint16 vlw_flag, uint32 id);
 
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
 
	TileIndex old_tile; ///< Current tile of the vehicle
 
	TileIndex new_tile; ///< Tile of the vehicle after moving
 
};
src/vehicle_gui.cpp
Show inline comments
 
@@ -2142,20 +2142,20 @@ void StopGlobalFollowVehicle(const Vehic
 
	}
 
}
 

	
 

	
 
/**
 
 * 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) {
 
		_backup_orders_tile = 0;
 
		RestoreVehicleOrders(v);
 
	}
0 comments (0 inline, 0 general)