# command_func.h

Go to the documentation of this file.

    00001 /* $Id$ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * 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.
    00006  * 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.
    00007  * 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/>.
    00008  */
    00009
    00012 #ifndef COMMAND_FUNC_H
    00013 #define COMMAND_FUNC_H
    00014
    00015 #include "command_type.h"
    00016 #include "company_type.h"
    00017
    00025 static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
    00026
    00035 #define return_cmd_error(errcode) return CommandCost(errcode);
    00036
    00037 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = NULL);
    00038 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
    00039
    00040 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true);
    00041 bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
    00042
    00043 CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
    00044
    00045 #ifdef ENABLE_NETWORK
    00046 void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
    00047 #endif /* ENABLE_NETWORK */
    00048
    00049 extern Money _additional_cash_required;
    00050
    00051 bool IsValidCommand(uint32 cmd);
    00052 CommandFlags GetCommandFlags(uint32 cmd);
    00053 const char *GetCommandName(uint32 cmd);
    00054 Money GetAvailableMoneyForCommand();
    00055 bool IsCommandAllowedWhilePaused(uint32 cmd);
    00056
    00062 static inline DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
    00063 {
    00064   DoCommandFlag flags = DC_NONE;
    00065   if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
    00066   if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
    00067   if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
    00068   return flags;
    00069 }
    00070
    00071 /*** All command callbacks that exist ***/
    00072
    00073 /* ai/ai_instance.cpp */
    00074 CommandCallback CcAI;
    00075
    00076 /* airport_gui.cpp */
    00077 CommandCallback CcBuildAirport;
    00078
    00079 /* bridge_gui.cpp */
    00080 CommandCallback CcBuildBridge;
    00081
    00082 /* dock_gui.cpp */
    00083 CommandCallback CcBuildDocks;
    00084 CommandCallback CcBuildCanal;
    00085
    00086 /* depot_gui.cpp */
    00087 CommandCallback CcCloneVehicle;
    00088
    00089 /* game/game_instance.cpp */
    00090 CommandCallback CcGame;
    00091
    00092 /* group_gui.cpp */
    00093 CommandCallback CcCreateGroup;
    00094
    00095 /* industry_gui.cpp */
    00096 CommandCallback CcBuildIndustry;
    00097
    00098 /* main_gui.cpp */
    00099 CommandCallback CcPlaySound10;
    00100 CommandCallback CcPlaceSign;
    00101 CommandCallback CcTerraform;
    00102 CommandCallback CcGiveMoney;
    00103
    00104 /* rail_gui.cpp */
    00105 CommandCallback CcPlaySound1E;
    00106 CommandCallback CcRailDepot;
    00107 CommandCallback CcStation;
    00108 CommandCallback CcBuildRailTunnel;
    00109
    00110 /* road_gui.cpp */
    00111 CommandCallback CcPlaySound1D;
    00112 CommandCallback CcBuildRoadTunnel;
    00113 CommandCallback CcRoadDepot;
    00114 CommandCallback CcRoadStop;
    00115
    00116 /* train_gui.cpp */
    00117 CommandCallback CcBuildWagon;
    00118
    00119 /* town_gui.cpp */
    00120 CommandCallback CcFoundTown;
    00121 CommandCallback CcFoundRandomTown;
    00122
    00123 /* vehicle_gui.cpp */
    00124 CommandCallback CcBuildPrimaryVehicle;
    00125 CommandCallback CcStartStopVehicle;
    00126
    00127 #endif /* COMMAND_FUNC_H */