mirror of https://github.com/OpenTTD/OpenTTD
(svn r22845) -Fix [FS#4745]: perform stricter checks on some commands (monoid)
parent
9975f30eb7
commit
4836a6e50e
|
@ -731,7 +731,7 @@ CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||||
GroupID id_g = GB(p1, 16, 16);
|
GroupID id_g = GB(p1, 16, 16);
|
||||||
CommandCost cost;
|
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 (!Engine::IsValidID(old_engine_type)) return CMD_ERROR;
|
||||||
|
|
||||||
if (new_engine_type != INVALID_ENGINE) {
|
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 (!IsValidCommand(cp->cmd)) return "invalid command";
|
||||||
if (GetCommandFlags(cp->cmd) & CMD_OFFLINE) return "offline only command";
|
if (GetCommandFlags(cp->cmd) & CMD_OFFLINE) return "offline only command";
|
||||||
if ((cp->cmd & CMD_FLAGS_MASK) != 0) return "invalid command flag";
|
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];
|
cp->callback = _callback_table[callback];
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -727,10 +727,10 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
case OT_CONDITIONAL: {
|
case OT_CONDITIONAL: {
|
||||||
VehicleOrderID skip_to = new_order.GetConditionSkipToOrder();
|
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 (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();
|
OrderConditionComparator occ = new_order.GetConditionComparator();
|
||||||
if (occ > OCC_END) return CMD_ERROR;
|
if (occ >= OCC_END) return CMD_ERROR;
|
||||||
switch (new_order.GetConditionVariable()) {
|
switch (new_order.GetConditionVariable()) {
|
||||||
case OCV_REQUIRES_SERVICE:
|
case OCV_REQUIRES_SERVICE:
|
||||||
if (occ != OCC_IS_TRUE && occ != OCC_IS_FALSE) return CMD_ERROR;
|
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);
|
CommandCost cost(EXPENSES_NEW_VEHICLES);
|
||||||
VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
|
VehicleType vehicle_type = Extract<VehicleType, 0, 3>(p1);
|
||||||
uint sell_command = GetCmdSellVeh(vehicle_type);
|
|
||||||
|
|
||||||
if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
|
if (!IsCompanyBuildableVehicleType(vehicle_type)) return CMD_ERROR;
|
||||||
|
|
||||||
|
uint sell_command = GetCmdSellVeh(vehicle_type);
|
||||||
|
|
||||||
/* Get the list of vehicles in the depot */
|
/* Get the list of vehicles in the depot */
|
||||||
BuildDepotVehicleList(vehicle_type, tile, &list, &list);
|
BuildDepotVehicleList(vehicle_type, tile, &list, &list);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue