# command_func.h

Go to the documentation of this file.

    00001 /* $Id: command_func.h 19603 2010-04-11 10:57:21Z 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 NetworkSend_Command(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 extern StringID _error_message;
    00061
    00065 bool IsValidCommand(uint32 cmd);
    00069 byte GetCommandFlags(uint32 cmd);
    00073 const char *GetCommandName(uint32 cmd);
    00077 Money GetAvailableMoneyForCommand();
    00078
    00084 static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
    00085 {
    00086   DoCommandFlag flags = DC_NONE;
    00087   if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
    00088   if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
    00089   if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
    00090   return flags;
    00091 }
    00092
    00093 /*** All command callbacks that exist ***/
    00094
    00095 /* ai/ai_core.cpp */
    00096 CommandCallback CcAI;
    00097
    00098 /* airport_gui.cpp */
    00099 CommandCallback CcBuildAirport;
    00100
    00101 /* bridge_gui.cpp */
    00102 CommandCallback CcBuildBridge;
    00103
    00104 /* dock_gui.cpp */
    00105 CommandCallback CcBuildDocks;
    00106 CommandCallback CcBuildCanal;
    00107
    00108 /* depot_gui.cpp */
    00109 CommandCallback CcCloneVehicle;
    00110
    00111 /* group_gui.cpp */
    00112 CommandCallback CcCreateGroup;
    00113
    00114 /* main_gui.cpp */
    00115 CommandCallback CcPlaySound10;
    00116 CommandCallback CcPlaceSign;
    00117 CommandCallback CcTerraform;
    00118 CommandCallback CcGiveMoney;
    00119
    00120 /* rail_gui.cpp */
    00121 CommandCallback CcPlaySound1E;
    00122 CommandCallback CcRailDepot;
    00123 CommandCallback CcStation;
    00124 CommandCallback CcBuildRailTunnel;
    00125
    00126 /* road_gui.cpp */
    00127 CommandCallback CcPlaySound1D;
    00128 CommandCallback CcBuildRoadTunnel;
    00129 CommandCallback CcRoadDepot;
    00130
    00131 /* train_gui.cpp */
    00132 CommandCallback CcBuildWagon;
    00133
    00134 /* town_gui.cpp */
    00135 CommandCallback CcFoundTown;
    00136 CommandCallback CcFoundRandomTown;
    00137
    00138 /* vehicle_gui.cpp */
    00139 CommandCallback CcBuildPrimaryVehicle;
    00140
    00141 #endif /* COMMAND_FUNC_H */