command_func.h
Go to the documentation of this file.00001
00002
00005 #ifndef COMMAND_FUNC_H
00006 #define COMMAND_FUNC_H
00007
00008 #include "command_type.h"
00009
00021 static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
00022
00032 static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
00033
00041 static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID);
00042
00051 #define return_cmd_error(errcode) return CommandCost(errcode);
00052
00056 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = NULL);
00057 CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags);
00058
00062 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = NULL, const char *text = NULL, bool my_cmd = true);
00063 bool DoCommandP(const CommandContainer *container, bool my_cmd = true);
00064
00065 #ifdef ENABLE_NETWORK
00066
00070 void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback, const char *text);
00071 #endif
00072
00073 extern Money _additional_cash_required;
00074 extern StringID _error_message;
00075
00079 bool IsValidCommand(uint32 cmd);
00083 byte GetCommandFlags(uint32 cmd);
00087 Money GetAvailableMoneyForCommand();
00088
00094 static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
00095 {
00096 DoCommandFlag flags = DC_NONE;
00097 if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
00098 if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
00099 if (cmd_flags & CMD_ALL_TILES) flags |= DC_ALL_TILES;
00100 return flags;
00101 }
00102
00103 #endif