Mercurial > hg > openttd
diff src/command.cpp @ 10604:ec12a7f3eef8 draft
(svn r14889) -Codechange: replace some magic numbers with constants.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Wed, 07 Jan 2009 13:26:48 +0000 (2009-01-07) |
parents | 7156262cf0c9 |
children | 32ba3eb6d7c9 |
line wrap: on
line diff
--- a/src/command.cpp +++ b/src/command.cpp @@ -350,7 +350,7 @@ */ bool IsValidCommand(uint32 cmd) { - cmd &= 0xFF; + cmd &= CMD_ID_MASK; return cmd < lengthof(_command_proc_table) && @@ -358,7 +358,7 @@ } /*! - * This function mask the parameter with 0xFF and returns + * This function mask the parameter with CMD_ID_MASK and returns * the flags which belongs to the given command. * * @param cmd The integer value of the command @@ -368,7 +368,7 @@ { assert(IsValidCommand(cmd)); - return _command_proc_table[cmd & 0xFF].flags; + return _command_proc_table[cmd & CMD_ID_MASK].flags; } static int _docommand_recursive = 0; @@ -503,8 +503,9 @@ if (cmd & CMD_NO_WATER) flags |= DC_NO_WATER; /* get pointer to command handler */ - assert((cmd & 0xFF) < lengthof(_command_proc_table)); - proc = _command_proc_table[cmd & 0xFF].proc; + byte cmd_id = cmd & CMD_ID_MASK; + assert(cmd_id < lengthof(_command_proc_table)); + proc = _command_proc_table[cmd_id].proc; if (proc == NULL) return false; if (GetCommandFlags(cmd) & CMD_AUTO) flags |= DC_AUTO; @@ -521,11 +522,12 @@ * CMD_CLONE_VEHICLE: Both building new vehicles and refitting them can be * influenced by newgrf callbacks, which makes it impossible to accurately * estimate the cost of cloning a vehicle. */ + notest = - (cmd & 0xFF) == CMD_CLEAR_AREA || - (cmd & 0xFF) == CMD_LEVEL_LAND || - (cmd & 0xFF) == CMD_REMOVE_LONG_ROAD || - (cmd & 0xFF) == CMD_CLONE_VEHICLE; + cmd_id == CMD_CLEAR_AREA || + cmd_id == CMD_LEVEL_LAND || + cmd_id == CMD_REMOVE_LONG_ROAD || + cmd_id == CMD_CLONE_VEHICLE; _docommand_recursive = 1; @@ -534,7 +536,7 @@ _shift_pressed && IsLocalCompany() && !(cmd & (CMD_NETWORK_COMMAND | CMD_SHOW_NO_ERROR)) && - (cmd & 0xFF) != CMD_PAUSE) { + cmd_id != CMD_PAUSE) { /* estimate the cost. */ SetTownRatingTestMode(true); res = proc(tile, flags, p1, p2, text);