command_func.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
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
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