Fix #10263, ccefa76: [scripts] restore tile validation for commands (#10269)

pull/441/head
Loïc Guilloux 1 year ago committed by GitHub
parent a857ed8240
commit c179c10048
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1703,6 +1703,7 @@ function Regression::Vehicle()
print(" BuildVehicle(): " + AIVehicle.BuildVehicle(33417, 153));
print(" IsValidVehicle(12): " + AIVehicle.IsValidVehicle(12));
print(" CloneVehicle(): " + AIVehicle.CloneVehicle(33417, 12, true));
print(" BuildVehicle(): " + AIVehicle.BuildVehicle(-1, 153));
local bank_after = AICompany.GetBankBalance(AICompany.COMPANY_SELF);

@ -9295,6 +9295,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
BuildVehicle(): 12
IsValidVehicle(12): true
CloneVehicle(): 13
BuildVehicle(): 1048575
--Accounting--
GetCosts(): 11894
Should be: 11894

@ -333,6 +333,9 @@ bool ScriptObject::ScriptDoCommandHelper<Tcmd, Tret(*)(DoCommandFlag, Targs...)>
tile = std::get<0>(args);
}
/* Do not even think about executing out-of-bounds tile-commands. */
if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (GetCommandFlags<Tcmd>() & CMD_ALL_TILES) == 0))) return false;
/* Only set ClientID parameters when the command does not come from the network. */
if constexpr ((::GetCommandFlags<Tcmd>() & CMD_CLIENT_ID) != 0) ScriptObjectInternal::SetClientIds(args, std::index_sequence_for<Targs...>{});

Loading…
Cancel
Save