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 
00028 static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
00029 
00039 static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
00040 
00048 static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
00049 
00058 #define return_cmd_error(errcode) return CommandCost(errcode);
00059 
00063 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = NULL);
00064 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
00065 
00069 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true);
00070 bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
00071 
00072 #ifdef ENABLE_NETWORK
00073 
00077 void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text);
00078 #endif /* ENABLE_NETWORK */
00079 
00080 extern Money _additional_cash_required;
00081 extern StringID _error_message;
00082 
00086 bool IsValidCommand(uint32 cmd);
00090 byte GetCommandFlags(uint32 cmd);
00094 Money GetAvailableMoneyForCommand();
00095 
00101 static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
00102 {
00103   DoCommandFlag flags = DC_NONE;
00104   if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
00105   if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
00106   if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
00107   return flags;
00108 }
00109 
00110 #endif /* COMMAND_FUNC_H */

Generated on Wed Dec 30 20:40:01 2009 for OpenTTD by  doxygen 1.5.6