OpenTTD
command_func.h
Go to the documentation of this file.
1 /* $Id$ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #ifndef COMMAND_FUNC_H
13 #define COMMAND_FUNC_H
14 
15 #include "command_type.h"
16 #include "company_type.h"
17 
26 
35 #define return_cmd_error(errcode) return CommandCost(errcode);
36 
37 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = nullptr);
38 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
39 
40 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const char *text = nullptr, bool my_cmd = true);
41 bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
42 
43 CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
44 
45 void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
46 
47 extern Money _additional_cash_required;
48 
49 bool IsValidCommand(uint32 cmd);
50 CommandFlags GetCommandFlags(uint32 cmd);
51 const char *GetCommandName(uint32 cmd);
53 bool IsCommandAllowedWhilePaused(uint32 cmd);
54 
61 {
62  DoCommandFlag flags = DC_NONE;
63  if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
64  if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
65  if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
66  return flags;
67 }
68 
69 /*** All command callbacks that exist ***/
70 
71 /* ai/ai_instance.cpp */
73 
74 /* airport_gui.cpp */
75 CommandCallback CcBuildAirport;
76 
77 /* bridge_gui.cpp */
79 
80 /* dock_gui.cpp */
81 CommandCallback CcBuildDocks;
82 CommandCallback CcPlaySound_SPLAT_WATER;
83 
84 /* depot_gui.cpp */
86 
87 /* game/game_instance.cpp */
89 
90 /* group_gui.cpp */
93 
94 /* industry_gui.cpp */
96 
97 /* main_gui.cpp */
98 CommandCallback CcPlaySound_EXPLOSION;
100 CommandCallback CcTerraform;
101 CommandCallback CcGiveMoney;
102 
103 /* rail_gui.cpp */
104 CommandCallback CcPlaySound_SPLAT_RAIL;
105 CommandCallback CcRailDepot;
106 CommandCallback CcStation;
108 
109 /* road_gui.cpp */
110 CommandCallback CcPlaySound_SPLAT_OTHER;
112 CommandCallback CcRoadDepot;
114 
115 /* train_gui.cpp */
117 
118 /* town_gui.cpp */
119 CommandCallback CcFoundTown;
120 CommandCallback CcFoundRandomTown;
121 
122 /* vehicle_gui.cpp */
125 
126 #endif /* COMMAND_FUNC_H */
Owner
Enum for all companies/owners.
Definition: company_type.h:20
don&#39;t allow building on structures
Definition: command_type.h:347
set the DC_NO_WATER flag on this command
Definition: command_type.h:395
void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company)
Prepare a DoCommand to be send over the network.
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback=nullptr, const char *text=nullptr, bool my_cmd=true)
Definition: command.cpp:554
static const CommandCost CMD_ERROR
Define a default return value for a failed command.
Definition: command_func.h:25
set the DC_AUTO flag on this command
Definition: command_type.h:392
no flag is set
Definition: command_type.h:345
CommandFlags
Command flags for the command table _command_proc_table.
Definition: command_type.h:388
bool IsCommandAllowedWhilePaused(uint32 cmd)
Returns whether the command is allowed while the game is paused.
Definition: command.cpp:412
void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback.
void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after attempting to start/stop a vehicle.
Common return value for all commands.
Definition: command_type.h:25
void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after the construction attempt of a primary vehicle.
void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, uint32 cmd)
Callback executed after a build Bridge CMD has been called.
Definition: bridge_gui.cpp:63
void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Opens a &#39;Rename group&#39; window for newly created group.
Definition: group_gui.cpp:1052
void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
DoCommand callback function for all commands executed by AIs.
Types related to commands.
void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Define a callback function for the client, after the command is finished.
Definition: command_type.h:472
bool IsValidCommand(uint32 cmd)
Definition: command.cpp:372
void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
DoCommand callback function for all commands executed by Game Scripts.
Structure for buffering the build command when selecting a station to join.
Definition: command_type.h:477
DoCommandFlag
List of flags for a command.
Definition: command_type.h:344
void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Open rename window after adding a vehicle to a new group via drag and drop.
Definition: group_gui.cpp:1069
void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, uint32 cmd)
Callback executed after a build road tunnel command has been called.
Definition: road_gui.cpp:101
don&#39;t allow building on water
Definition: command_type.h:349
static DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition: command_func.h:60
void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Callback function that is called after a sign is placed.
Definition: signs_cmd.cpp:122
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback for building a tunnel.
Definition: rail_gui.cpp:275
void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Callback for building wagons.
Definition: train_gui.cpp:32
allow this command also on MP_VOID tiles
Definition: command_type.h:355
CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text=nullptr)
Definition: command.cpp:461
Money GetAvailableMoneyForCommand()
Definition: command.cpp:521
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
Types related to companies.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:19
CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only)
Definition: command.cpp:627
void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
This is the Callback method after the cloning attempt of a vehicle.
Definition: depot_gui.cpp:122
void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback for building road stops.
Definition: road_gui.cpp:160
const char * GetCommandName(uint32 cmd)
Definition: command.cpp:400
allow this command also on MP_VOID tiles
Definition: command_type.h:393
CommandFlags GetCommandFlags(uint32 cmd)
Definition: command.cpp:386