mirror of https://github.com/OpenTTD/OpenTTD
(svn r23215) -Codechange: stricter type safety for CommandFlags
parent
15f671279d
commit
f600429424
|
@ -173,7 +173,7 @@ CommandProc CmdSetVehicleOnTime;
|
||||||
CommandProc CmdAutofillTimetable;
|
CommandProc CmdAutofillTimetable;
|
||||||
CommandProc CmdSetTimetableStart;
|
CommandProc CmdSetTimetableStart;
|
||||||
|
|
||||||
#define DEF_CMD(proc, flags, type) {proc, #proc, flags, type}
|
#define DEF_CMD(proc, flags, type) {proc, #proc, (CommandFlags)flags, type}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The master command table
|
* The master command table
|
||||||
|
@ -327,7 +327,7 @@ bool IsValidCommand(uint32 cmd)
|
||||||
* @param cmd The integer value of the command
|
* @param cmd The integer value of the command
|
||||||
* @return The flags for this command
|
* @return The flags for this command
|
||||||
*/
|
*/
|
||||||
byte GetCommandFlags(uint32 cmd)
|
CommandFlags GetCommandFlags(uint32 cmd)
|
||||||
{
|
{
|
||||||
assert(IsValidCommand(cmd));
|
assert(IsValidCommand(cmd));
|
||||||
|
|
||||||
|
@ -590,7 +590,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
|
||||||
assert(proc != NULL);
|
assert(proc != NULL);
|
||||||
|
|
||||||
/* Command flags are used internally */
|
/* Command flags are used internally */
|
||||||
uint cmd_flags = GetCommandFlags(cmd);
|
CommandFlags cmd_flags = GetCommandFlags(cmd);
|
||||||
/* Flags get send to the DoCommand */
|
/* Flags get send to the DoCommand */
|
||||||
DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
|
DoCommandFlag flags = CommandFlagsToDCFlags(cmd_flags);
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, Comman
|
||||||
extern Money _additional_cash_required;
|
extern Money _additional_cash_required;
|
||||||
|
|
||||||
bool IsValidCommand(uint32 cmd);
|
bool IsValidCommand(uint32 cmd);
|
||||||
byte GetCommandFlags(uint32 cmd);
|
CommandFlags GetCommandFlags(uint32 cmd);
|
||||||
const char *GetCommandName(uint32 cmd);
|
const char *GetCommandName(uint32 cmd);
|
||||||
Money GetAvailableMoneyForCommand();
|
Money GetAvailableMoneyForCommand();
|
||||||
bool IsCommandAllowedWhilePaused(uint32 cmd);
|
bool IsCommandAllowedWhilePaused(uint32 cmd);
|
||||||
|
@ -59,7 +59,7 @@ bool IsCommandAllowedWhilePaused(uint32 cmd);
|
||||||
* @param cmd_flags Flags from GetCommandFlags
|
* @param cmd_flags Flags from GetCommandFlags
|
||||||
* @return flags for DoCommand
|
* @return flags for DoCommand
|
||||||
*/
|
*/
|
||||||
static inline DoCommandFlag CommandFlagsToDCFlags(uint cmd_flags)
|
static inline DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
|
||||||
{
|
{
|
||||||
DoCommandFlag flags = DC_NONE;
|
DoCommandFlag flags = DC_NONE;
|
||||||
if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
|
if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
|
||||||
|
|
|
@ -355,6 +355,7 @@ enum CommandFlags {
|
||||||
CMD_NO_WATER = 0x40, ///< set the DC_NO_WATER flag on this command
|
CMD_NO_WATER = 0x40, ///< set the DC_NO_WATER flag on this command
|
||||||
CMD_CLIENT_ID = 0x80, ///< set p2 with the ClientID of the sending client.
|
CMD_CLIENT_ID = 0x80, ///< set p2 with the ClientID of the sending client.
|
||||||
};
|
};
|
||||||
|
DECLARE_ENUM_AS_BIT_SET(CommandFlags)
|
||||||
|
|
||||||
/** Types of commands we have. */
|
/** Types of commands we have. */
|
||||||
enum CommandType {
|
enum CommandType {
|
||||||
|
@ -406,10 +407,10 @@ typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
* the #CMD_AUTO, #CMD_OFFLINE and #CMD_SERVER values.
|
* the #CMD_AUTO, #CMD_OFFLINE and #CMD_SERVER values.
|
||||||
*/
|
*/
|
||||||
struct Command {
|
struct Command {
|
||||||
CommandProc *proc; ///< The procedure to actually executing
|
CommandProc *proc; ///< The procedure to actually executing
|
||||||
const char *name; ///< A human readable name for the procedure
|
const char *name; ///< A human readable name for the procedure
|
||||||
byte flags; ///< The (command) flags to that apply to this command
|
CommandFlags flags; ///< The (command) flags to that apply to this command
|
||||||
CommandType type; ///< The type of command.
|
CommandType type; ///< The type of command.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue