Skip to content
Permalink
Browse files
(svn r22845) -Fix [FS#4745]: perform stricter checks on some commands…
… (monoid)
  • Loading branch information
rubidium42 committed Aug 26, 2011
1 parent 9975f30 commit 4836a6e50e94978e2f363d586838cea2bdb9c26e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
@@ -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) {
@@ -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;
@@ -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;
@@ -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);

0 comments on commit 4836a6e

Please sign in to comment.