diff options
author | frosch <frosch@openttd.org> | 2009-01-12 15:27:39 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-01-12 15:27:39 +0000 |
commit | 5dcb9e63e361d3212f1b4dbeb7f4253b23d45473 (patch) | |
tree | 1531a0dd531eb511b9d2669071bcd3747f09a65c | |
parent | 5477af10b546a0523ba4b2522182329d985746df (diff) | |
download | openttd-5dcb9e63e361d3212f1b4dbeb7f4253b23d45473.tar.xz |
(svn r15014) -Codechange: Add a helper function to get the needed DC_xxx flags from the result of GetCommandFlags().
-rw-r--r-- | src/command.cpp | 6 | ||||
-rw-r--r-- | src/command_func.h | 13 |
2 files changed, 15 insertions, 4 deletions
diff --git a/src/command.cpp b/src/command.cpp index 2cc944676..6c1bc6cde 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -527,12 +527,10 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac CommandProc *proc = _command_proc_table[cmd_id].proc; if (proc == NULL) return false; - /* Flags get send to the DoCommand */ - uint32 flags = 0; /* Command flags are used internally */ uint cmd_flags = GetCommandFlags(cmd); - if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER; - if (cmd_flags & CMD_AUTO) flags |= DC_AUTO; + /* Flags get send to the DoCommand */ + uint32 flags = CommandFlagsToDCFlags(cmd_flags); bool notest = (cmd_flags & CMD_NO_TEST) != 0; diff --git a/src/command_func.h b/src/command_func.h index 1b8af25b9..a6b77c6a0 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -86,4 +86,17 @@ byte GetCommandFlags(uint32 cmd); */ Money GetAvailableMoneyForCommand(); +/** + * Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags + * @param cmd_flags Flags from GetCommandFlags + * @return flags for DoCommand + */ +static inline uint32 CommandFlagsToDCFlags(uint cmd_flags) +{ + uint32 flags = 0; + if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER; + if (cmd_flags & CMD_AUTO) flags |= DC_AUTO; + return flags; +} + #endif /* COMMAND_FUNC_H */ |