(svn r15014) -Codechange: Add a helper function to get the needed DC_xxx flags from the result of GetCommandFlags().

This commit is contained in:
frosch 2009-01-12 15:27:39 +00:00
parent 809bf8fb43
commit 508fc29221
2 changed files with 15 additions and 4 deletions

View File

@ -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;

View File

@ -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 */