# command_func.h

Go to the documentation of this file.

    00001 /* $Id: command_func.h 18866 2010-01-18 22: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 Money GetAvailableMoneyForCommand();
    00074
    00080 static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
    00081 {
    00082   DoCommandFlag flags = DC_NONE;
    00083   if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
    00084   if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
    00085   if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
    00086   return flags;
    00087 }
    00088
    00089 /*** All command callbacks that exist ***/
    00090
    00091 /* ai/ai_core.cpp */
    00092 CommandCallback CcAI;
    00093
    00094 /* airport_gui.cpp */
    00095 CommandCallback CcBuildAirport;
    00096
    00097 /* bridge_gui.cpp */
    00098 CommandCallback CcBuildBridge;
    00099
    00100 /* dock_gui.cpp */
    00101 CommandCallback CcBuildDocks;
    00102 CommandCallback CcBuildCanal;
    00103
    00104 /* depot_gui.cpp */
    00105 CommandCallback CcCloneVehicle;
    00106
    00107 /* group_gui.cpp */
    00108 CommandCallback CcCreateGroup;
    00109
    00110 /* main_gui.cpp */
    00111 CommandCallback CcPlaySound10;
    00112 CommandCallback CcPlaceSign;
    00113 CommandCallback CcTerraform;
    00114 CommandCallback CcGiveMoney;
    00115
    00116 /* rail_gui.cpp */
    00117 CommandCallback CcPlaySound1E;
    00118 CommandCallback CcRailDepot;
    00119 CommandCallback CcStation;
    00120 CommandCallback CcBuildRailTunnel;
    00121
    00122 /* road_gui.cpp */
    00123 CommandCallback CcPlaySound1D;
    00124 CommandCallback CcBuildRoadTunnel;
    00125 CommandCallback CcRoadDepot;
    00126
    00127 /* train_gui.cpp */
    00128 CommandCallback CcBuildWagon;
    00129
    00130 /* town_gui.cpp */
    00131 CommandCallback CcFoundTown;
    00132 CommandCallback CcFoundRandomTown;
    00133
    00134 /* vehicle_gui.cpp */
    00135 CommandCallback CcBuildPrimaryVehicle;
    00136
    00137 #endif /* COMMAND_FUNC_H */