Update readme and changelog for v1.27.0
[openttd-joker.git] / src / command_func.h
blobcb32eb5a432f5a876200810bcceb51b269771924
1 /* $Id$ */
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 */
10 /** @file command_func.h Functions related to commands. */
12 #ifndef COMMAND_FUNC_H
13 #define COMMAND_FUNC_H
15 #include "command_type.h"
16 #include "company_type.h"
18 /**
19 * Returns a specific StringID as error.
21 * @param error_msg The StringID to return
23 inline CommandCost CommandError(StringID error_msg = INVALID_STRING_ID) { return CommandCost(error_msg); }
25 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = nullptr);
26 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
28 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const char *text = nullptr, bool my_cmd = true, uint32 binary_length = 0);
29 bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
31 CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only, uint32 binary_length);
33 #ifdef ENABLE_NETWORK
34 void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company, uint32 binary_length);
35 #endif /* ENABLE_NETWORK */
37 extern Money _additional_cash_required;
39 bool IsValidCommand(uint32 cmd);
40 CommandFlags GetCommandFlags(uint32 cmd);
41 const char *GetCommandName(uint32 cmd);
42 Money GetAvailableMoneyForCommand();
43 bool IsCommandAllowedWhilePaused(uint32 cmd);
45 /**
46 * Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags
47 * @param cmd_flags Flags from GetCommandFlags
48 * @return flags for DoCommand
50 static inline DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
52 DoCommandFlag flags = DC_NONE;
53 if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
54 if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
55 if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
56 return flags;
59 void ClearCommandLog();
60 char *DumpCommandLog(char *buffer, const char *last);
62 /*** All command callbacks that exist ***/
64 /* ai/ai_instance.cpp */
65 CommandCallback CcAI;
67 /* airport_gui.cpp */
68 CommandCallback CcBuildAirport;
70 /* bridge_gui.cpp */
71 CommandCallback CcBuildBridge;
73 /* dock_gui.cpp */
74 CommandCallback CcBuildDocks;
75 CommandCallback CcPlaySound_SPLAT_WATER;
77 /* depot_gui.cpp */
78 CommandCallback CcCloneVehicle;
80 /* game/game_instance.cpp */
81 CommandCallback CcGame;
83 /* group_gui.cpp */
84 CommandCallback CcCreateGroup;
85 CommandCallback CcAddVehicleNewGroup;
87 /* industry_gui.cpp */
88 CommandCallback CcBuildIndustry;
90 /* main_gui.cpp */
91 CommandCallback CcPlaySound_EXPLOSION;
92 CommandCallback CcPlaceSign;
93 CommandCallback CcTerraform;
94 CommandCallback CcGiveMoney;
96 /* plans_gui.cpp */
97 CommandCallback CcAddPlan;
99 /* rail_gui.cpp */
100 CommandCallback CcPlaySound_SPLAT_RAIL;
101 CommandCallback CcRailDepot;
102 CommandCallback CcStation;
103 CommandCallback CcBuildRailTunnel;
105 /* road_gui.cpp */
106 CommandCallback CcPlaySound_SPLAT_OTHER;
107 CommandCallback CcBuildRoadTunnel;
108 CommandCallback CcRoadDepot;
109 CommandCallback CcRoadStop;
111 /* train_gui.cpp */
112 CommandCallback CcBuildWagon;
114 /* town_gui.cpp */
115 CommandCallback CcFoundTown;
116 CommandCallback CcFoundRandomTown;
118 /* vehicle_gui.cpp */
119 CommandCallback CcBuildPrimaryVehicle;
120 CommandCallback CcStartStopVehicle;
122 /* tbtr_template_gui_create.cpp */
123 CommandCallback CcSetVirtualTrain;
124 CommandCallback CcVirtualTrainWagonsMoved;
125 CommandCallback CcDeleteVirtualTrain;
127 /* build_vehicle_gui.cpp */
128 CommandCallback CcAddVirtualEngine;
131 #endif /* COMMAND_FUNC_H */