Fix: [OSX] Don't show a crash/assertion message box for a GUI-less video driver.
[openttd-github.git] / src / command_func.h
blob7a0a77e8d8aa77ca14d1185bce3982edd5de8ddc
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file command_func.h Functions related to commands. */
10 #ifndef COMMAND_FUNC_H
11 #define COMMAND_FUNC_H
13 #include "command_type.h"
14 #include "company_type.h"
16 /**
17 * Define a default return value for a failed command.
19 * This variable contains a CommandCost object with is declared as "failed".
20 * Other functions just need to return this error if there is an error,
21 * which doesn't need to specific by a StringID.
23 static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
25 /**
26 * Returns from a function with a specific StringID as error.
28 * This macro is used to return from a function. The parameter contains the
29 * StringID which will be returned.
31 * @param errcode The StringID to return
33 #define return_cmd_error(errcode) return CommandCost(errcode);
35 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = nullptr);
36 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
38 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const char *text = nullptr, bool my_cmd = true);
39 bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
41 CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
43 void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
45 extern Money _additional_cash_required;
47 bool IsValidCommand(uint32 cmd);
48 CommandFlags GetCommandFlags(uint32 cmd);
49 const char *GetCommandName(uint32 cmd);
50 Money GetAvailableMoneyForCommand();
51 bool IsCommandAllowedWhilePaused(uint32 cmd);
53 /**
54 * Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags
55 * @param cmd_flags Flags from GetCommandFlags
56 * @return flags for DoCommand
58 static inline DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
60 DoCommandFlag flags = DC_NONE;
61 if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
62 if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
63 if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
64 return flags;
67 /*** All command callbacks that exist ***/
69 /* ai/ai_instance.cpp */
70 CommandCallback CcAI;
72 /* airport_gui.cpp */
73 CommandCallback CcBuildAirport;
75 /* bridge_gui.cpp */
76 CommandCallback CcBuildBridge;
78 /* dock_gui.cpp */
79 CommandCallback CcBuildDocks;
80 CommandCallback CcPlaySound_SPLAT_WATER;
82 /* depot_gui.cpp */
83 CommandCallback CcCloneVehicle;
85 /* game/game_instance.cpp */
86 CommandCallback CcGame;
88 /* group_gui.cpp */
89 CommandCallback CcCreateGroup;
90 CommandCallback CcAddVehicleNewGroup;
92 /* industry_gui.cpp */
93 CommandCallback CcBuildIndustry;
95 /* main_gui.cpp */
96 CommandCallback CcPlaySound_EXPLOSION;
97 CommandCallback CcPlaceSign;
98 CommandCallback CcTerraform;
99 CommandCallback CcGiveMoney;
101 /* rail_gui.cpp */
102 CommandCallback CcPlaySound_SPLAT_RAIL;
103 CommandCallback CcRailDepot;
104 CommandCallback CcStation;
105 CommandCallback CcBuildRailTunnel;
107 /* road_gui.cpp */
108 CommandCallback CcPlaySound_SPLAT_OTHER;
109 CommandCallback CcBuildRoadTunnel;
110 CommandCallback CcRoadDepot;
111 CommandCallback CcRoadStop;
113 /* train_gui.cpp */
114 CommandCallback CcBuildWagon;
116 /* town_gui.cpp */
117 CommandCallback CcFoundTown;
118 CommandCallback CcFoundRandomTown;
120 /* vehicle_gui.cpp */
121 CommandCallback CcBuildPrimaryVehicle;
122 CommandCallback CcStartStopVehicle;
124 #endif /* COMMAND_FUNC_H */