--- a/src/command.h Sun Jun 17 21:31:00 2007 +0000
+++ b/src/command.h Tue Jun 26 23:40:58 2007 +0000
@@ -153,6 +153,9 @@
CMD_SET_GROUP_REPLACE_PROTECTION = 126,
CMD_MOVE_ORDER = 127,
+ CMD_CHANGE_TIMETABLE = 128,
+ CMD_SET_VEHICLE_ON_TIME = 129,
+ CMD_AUTOFILL_TIMETABLE = 130,
};
enum {
@@ -163,8 +166,6 @@
DC_NO_RAIL_OVERLAP = 0x10, ///< don't allow overlap of rails (used in buildrail)
DC_NO_TOWN_RATING = 0x40, ///< town rating does not disallow you from building
DC_FORCETEST = 0x80, ///< force test too.
-
- CMD_ERROR = ((int32)0x80000000),
};
#define CMD_MSG(x) ((x) << 16)
@@ -183,30 +184,23 @@
CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
};
-typedef int32 CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
+typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
struct Command {
CommandProc *proc;
byte flags;
};
-//#define return_cmd_error(errcode) do { _error_message=(errcode); return CMD_ERROR; } while(0)
-#define return_cmd_error(errcode) do { return CMD_ERROR | (errcode); } while (0)
+static inline bool CmdFailed(CommandCost cost) { return cost.Failed(); }
+static inline bool CmdSucceeded(CommandCost cost) { return cost.Succeeded(); }
-/**
- * Check the return value of a DoCommand*() function
- * @param res the resulting value from the command to be checked
- * @return Return true if the command failed, false otherwise
- */
-static inline bool CmdFailed(int32 res)
-{
- /* lower 16bits are the StringID of the possible error */
- return res <= (CMD_ERROR | INVALID_STRING_ID);
-}
+static const CommandCost CMD_ERROR = CommandCost((StringID)INVALID_STRING_ID);
+
+#define return_cmd_error(errcode) do { return CommandCost((StringID)(errcode)); } while (0)
/* command.cpp */
typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
-int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
+CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
#ifdef ENABLE_NETWORK
@@ -218,6 +212,6 @@
bool IsValidCommand(uint cmd);
byte GetCommandFlags(uint cmd);
-int32 GetAvailableMoneyForCommand();
+Money GetAvailableMoneyForCommand();
#endif /* COMMAND_H */