mirror of https://github.com/OpenTTD/OpenTTD
(svn r22884) [1.1] -Backport from trunk:
- Fix: Perform stricter checks on some commands [FS#4745] (r22845) - Fix: Harden savegame load against too many AI config settings [FS#4748] (r22843)release/1.1
parent
a95c366f58
commit
7d984241f3
|
@ -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) {
|
||||
|
|
|
@ -307,7 +307,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;
|
||||
|
|
|
@ -66,6 +66,8 @@ static void Load_AIPL()
|
|||
|
||||
CompanyID index;
|
||||
while ((index = (CompanyID)SlIterateArray()) != (CompanyID)-1) {
|
||||
if (index >= MAX_COMPANIES) SlErrorCorrupt("Too many AI configs");
|
||||
|
||||
_ai_saveload_version = -1;
|
||||
SlObject(NULL, _ai_company);
|
||||
|
||||
|
|
|
@ -517,10 +517,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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue