diff options
author | rubidium <rubidium@openttd.org> | 2011-08-26 16:39:02 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2011-08-26 16:39:02 +0000 |
commit | 4836a6e50e94978e2f363d586838cea2bdb9c26e (patch) | |
tree | 14c32b2f0aa2dde2384308d54a3c0c65a4c2735f | |
parent | 9975f30eb76025ba911323f75e06b5f7d6e2e4a5 (diff) | |
download | openttd-4836a6e50e94978e2f363d586838cea2bdb9c26e.tar.xz |
(svn r22845) -Fix [FS#4745]: perform stricter checks on some commands (monoid)
-rw-r--r-- | src/autoreplace_cmd.cpp | 2 | ||||
-rw-r--r-- | src/network/network_command.cpp | 2 | ||||
-rw-r--r-- | src/order_cmd.cpp | 4 | ||||
-rw-r--r-- | src/vehicle_cmd.cpp | 3 |
4 files changed, 6 insertions, 5 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 19a740de1..4cb3c9bf3 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -731,7 +731,7 @@ CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, ui GroupID id_g = GB(p1, 16, 16); CommandCost cost; - if (!Group::IsValidID(id_g) && !IsAllGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR; + if (Group::IsValidID(id_g) ? Group::Get(id_g)->owner != _current_company : !IsAllGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR; if (!Engine::IsValidID(old_engine_type)) return CMD_ERROR; if (new_engine_type != INVALID_ENGINE) { diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 27e8338fb..0e37eeff4 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -308,7 +308,7 @@ const char *NetworkGameSocketHandler::ReceiveCommand(Packet *p, CommandPacket *c if (!IsValidCommand(cp->cmd)) return "invalid command"; if (GetCommandFlags(cp->cmd) & CMD_OFFLINE) return "offline only command"; if ((cp->cmd & CMD_FLAGS_MASK) != 0) return "invalid command flag"; - if (callback > lengthof(_callback_table)) return "invalid callback"; + if (callback >= lengthof(_callback_table)) return "invalid callback"; cp->callback = _callback_table[callback]; return NULL; diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index e8d1899fc..9a9046005 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -727,10 +727,10 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 case OT_CONDITIONAL: { VehicleOrderID skip_to = new_order.GetConditionSkipToOrder(); if (skip_to != 0 && skip_to >= v->GetNumOrders()) return CMD_ERROR; // Always allow jumping to the first (even when there is no order). - if (new_order.GetConditionVariable() > OCV_END) return CMD_ERROR; + if (new_order.GetConditionVariable() >= OCV_END) return CMD_ERROR; OrderConditionComparator occ = new_order.GetConditionComparator(); - if (occ > OCC_END) return CMD_ERROR; + if (occ >= OCC_END) return CMD_ERROR; switch (new_order.GetConditionVariable()) { case OCV_REQUIRES_SERVICE: if (occ != OCC_IS_TRUE && occ != OCC_IS_FALSE) return CMD_ERROR; diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index fdb9fd66c..46d8ba8e0 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -524,10 +524,11 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 CommandCost cost(EXPENSES_NEW_VEHICLES); VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1); - uint sell_command = GetCmdSellVeh(vehicle_type); if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR; + uint sell_command = GetCmdSellVeh(vehicle_type); + /* Get the list of vehicles in the depot */ BuildDepotVehicleList(vehicle_type, tile, &list, &list); |