diff options
author | rubidium <rubidium@openttd.org> | 2008-04-07 20:18:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-04-07 20:18:51 +0000 |
commit | 16cb87139885765456c4e0d261ff4b96e5e3b0e9 (patch) | |
tree | d69807c33c01f0721eac13942b3dcf9ca2ff535b | |
parent | 973997e896aeaaf36780abc3c51b1c115cec0535 (diff) | |
download | openttd-16cb87139885765456c4e0d261ff4b96e5e3b0e9.tar.xz |
(svn r12618) -Codechange: as load and unload type are now split, some case statements got ugly.
-rw-r--r-- | src/order_cmd.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index ea4a9e102..8951841df 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -315,22 +315,15 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) default: return CMD_ERROR; } + /* Non stop not allowed for non-trains. */ if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR; - /* Order flags can be any of the following for stations: - * [full-load | unload] [+ transfer] [+ non-stop] - * non-stop orders (if any) are only valid for trains */ - switch (new_order.GetLoadType() | new_order.GetUnloadType()) { - case 0: - case OLFB_FULL_LOAD: - case OLFB_FULL_LOAD | OUFB_TRANSFER: - case OUFB_UNLOAD: - case OUFB_UNLOAD | OUFB_TRANSFER: - case OUFB_TRANSFER: - break; + /* Full load and unload are mutual exclusive. */ + if ((new_order.GetLoadType() & OLFB_FULL_LOAD) && (new_order.GetUnloadType() & OUFB_UNLOAD)) return CMD_ERROR; - default: return CMD_ERROR; - } + /* Filter invalid load/unload types. */ + if (new_order.GetLoadType() & ~OLFB_FULL_LOAD) return CMD_ERROR; + if (new_order.GetUnloadType() & ~(OUFB_UNLOAD | OUFB_TRANSFER)) return CMD_ERROR; break; } @@ -371,17 +364,8 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) } if (new_order.GetNonStopType() != ONSF_STOP_EVERYWHERE && v->type != VEH_TRAIN) return CMD_ERROR; - - /* Order flags can be any of the following for depots: - * order [+ halt] [+ non-stop] - * non-stop orders (if any) are only valid for trains */ - switch (new_order.GetDepotOrderType() | new_order.GetDepotActionType()) { - case ODTFB_PART_OF_ORDERS: - case ODTFB_PART_OF_ORDERS | ODATFB_HALT: - break; - - default: return CMD_ERROR; - } + if (new_order.GetDepotOrderType() & ~ODTFB_PART_OF_ORDERS) return CMD_ERROR; + if (new_order.GetDepotActionType() & ~ODATFB_HALT) return CMD_ERROR; break; } |