OpenTTD
command_func.h
Go to the documentation of this file.
1 /* $Id: command_func.h 27571 2016-05-22 10:07:48Z frosch $ */
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 = NULL);
38 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
39 
40 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, 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 #ifdef ENABLE_NETWORK
46 void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
47 #endif /* ENABLE_NETWORK */
48 
49 extern Money _additional_cash_required;
50 
51 bool IsValidCommand(uint32 cmd);
52 CommandFlags GetCommandFlags(uint32 cmd);
53 const char *GetCommandName(uint32 cmd);
55 bool IsCommandAllowedWhilePaused(uint32 cmd);
56 
63 {
64  DoCommandFlag flags = DC_NONE;
65  if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
66  if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
67  if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
68  return flags;
69 }
70 
71 /*** All command callbacks that exist ***/
72 
73 /* ai/ai_instance.cpp */
75 
76 /* airport_gui.cpp */
77 CommandCallback CcBuildAirport;
78 
79 /* bridge_gui.cpp */
81 
82 /* dock_gui.cpp */
83 CommandCallback CcBuildDocks;
84 CommandCallback CcPlaySound_SPLAT_WATER;
85 
86 /* depot_gui.cpp */
88 
89 /* game/game_instance.cpp */
91 
92 /* group_gui.cpp */
95 
96 /* industry_gui.cpp */
98 
99 /* main_gui.cpp */
100 CommandCallback CcPlaySound_EXPLOSION;
102 CommandCallback CcTerraform;
103 CommandCallback CcGiveMoney;
104 
105 /* rail_gui.cpp */
106 CommandCallback CcPlaySound_SPLAT_RAIL;
107 CommandCallback CcRailDepot;
108 CommandCallback CcStation;
110 
111 /* road_gui.cpp */
112 CommandCallback CcPlaySound_SPLAT_OTHER;
114 CommandCallback CcRoadDepot;
116 
117 /* train_gui.cpp */
119 
120 /* town_gui.cpp */
121 CommandCallback CcFoundTown;
122 CommandCallback CcFoundRandomTown;
123 
124 /* vehicle_gui.cpp */
127 
128 #endif /* COMMAND_FUNC_H */