command_func.h

Go to the documentation of this file.
00001 /* $Id: command_func.h 21427 2010-12-07 21:08:35Z rubidium $ */
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 
00040 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = NULL);
00041 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
00042 
00046 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true);
00047 bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
00048 
00050 CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only);
00051 
00052 #ifdef ENABLE_NETWORK
00053 
00056 void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company);
00057 #endif /* ENABLE_NETWORK */
00058 
00059 extern Money _additional_cash_required;
00060 
00064 bool IsValidCommand(uint32 cmd);
00068 byte GetCommandFlags(uint32 cmd);
00072 const char *GetCommandName(uint32 cmd);
00076 Money GetAvailableMoneyForCommand();
00077 
00078 bool IsCommandAllowedWhilePaused(uint32 cmd);
00079 
00085 static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
00086 {
00087   DoCommandFlag flags = DC_NONE;
00088   if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
00089   if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
00090   if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
00091   return flags;
00092 }
00093 
00094 /*** All command callbacks that exist ***/
00095 
00096 /* ai/ai_core.cpp */
00097 CommandCallback CcAI;
00098 
00099 /* airport_gui.cpp */
00100 CommandCallback CcBuildAirport;
00101 
00102 /* bridge_gui.cpp */
00103 CommandCallback CcBuildBridge;
00104 
00105 /* dock_gui.cpp */
00106 CommandCallback CcBuildDocks;
00107 CommandCallback CcBuildCanal;
00108 
00109 /* depot_gui.cpp */
00110 CommandCallback CcCloneVehicle;
00111 
00112 /* group_gui.cpp */
00113 CommandCallback CcCreateGroup;
00114 
00115 /* industry_gui.cpp */
00116 CommandCallback CcBuildIndustry;
00117 
00118 /* main_gui.cpp */
00119 CommandCallback CcPlaySound10;
00120 CommandCallback CcPlaceSign;
00121 CommandCallback CcTerraform;
00122 CommandCallback CcGiveMoney;
00123 
00124 /* rail_gui.cpp */
00125 CommandCallback CcPlaySound1E;
00126 CommandCallback CcRailDepot;
00127 CommandCallback CcStation;
00128 CommandCallback CcBuildRailTunnel;
00129 
00130 /* road_gui.cpp */
00131 CommandCallback CcPlaySound1D;
00132 CommandCallback CcBuildRoadTunnel;
00133 CommandCallback CcRoadDepot;
00134 CommandCallback CcRoadStop;
00135 
00136 /* train_gui.cpp */
00137 CommandCallback CcBuildWagon;
00138 
00139 /* town_gui.cpp */
00140 CommandCallback CcFoundTown;
00141 CommandCallback CcFoundRandomTown;
00142 
00143 /* vehicle_gui.cpp */
00144 CommandCallback CcBuildPrimaryVehicle;
00145 CommandCallback CcStartStopVehicle;
00146 
00147 #endif /* COMMAND_FUNC_H */

Generated on Sun Jan 9 16:01:53 2011 for OpenTTD by  doxygen 1.6.1