mirror of https://github.com/OpenTTD/OpenTTD
Merge 41d497f36a
into 9bcf1cf29b
commit
dfbd72e03e
|
@ -36,3 +36,11 @@ AITown.FoundTown <- function(tile, size, city, layout, name) { return AITown.Fou
|
|||
|
||||
AIVehicle.SetNameCompat14 <- AIVehicle.SetName;
|
||||
AIVehicle.SetName <- function(id, name) { return AIVehicle.SetNameCompat14(id, AICompat14.Text(name)); }
|
||||
|
||||
AIObject.constructorCompat14 <- AIObject.constructor;
|
||||
foreach(name, object in CompatScriptRootTable) {
|
||||
if (type(object) != "class") continue;
|
||||
if (!object.rawin("constructor")) continue;
|
||||
if (object.constructor != AIObject.constructorCompat14) continue;
|
||||
object.constructor <- function() : (name) { AILog.Error("'" + name + "' is not instantiable"); }
|
||||
}
|
||||
|
|
|
@ -81,3 +81,11 @@ GSTown.FoundTown <- function(tile, size, city, layout, name) { return GSTown.Fou
|
|||
|
||||
GSVehicle.SetNameCompat14 <- GSVehicle.SetName;
|
||||
GSVehicle.SetName <- function(id, name) { return GSVehicle.SetNameCompat14(id, GSCompat14.Text(name)); }
|
||||
|
||||
GSObject.constructorCompat14 <- GSObject.constructor;
|
||||
foreach(name, object in CompatScriptRootTable) {
|
||||
if (type(object) != "class") continue;
|
||||
if (!object.rawin("constructor")) continue;
|
||||
if (object.constructor != GSObject.constructorCompat14) continue;
|
||||
object.constructor <- function() : (name) { GSLog.Error("'" + name + "' is not instantiable"); }
|
||||
}
|
||||
|
|
|
@ -128,6 +128,13 @@ bool ScriptInstance::LoadCompatibilityScripts(Subdirectory dir, std::span<const
|
|||
|
||||
ScriptLog::Info(fmt::format("Downgrading API to be compatible with version {}", this->api_version));
|
||||
|
||||
HSQUIRRELVM vm = this->engine->GetVM();
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "CompatScriptRootTable");
|
||||
sq_pushroottable(vm);
|
||||
sq_newslot(vm, -3, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
|
||||
/* Downgrade the API till we are the same version as the script. The last
|
||||
* entry in the list is always the current version, so skip that one. */
|
||||
for (auto it = std::rbegin(api_versions) + 1; it != std::rend(api_versions); ++it) {
|
||||
|
@ -136,6 +143,11 @@ bool ScriptInstance::LoadCompatibilityScripts(Subdirectory dir, std::span<const
|
|||
if (*it == this->api_version) break;
|
||||
}
|
||||
|
||||
sq_pushroottable(vm);
|
||||
sq_pushstring(vm, "CompatScriptRootTable");
|
||||
sq_deleteslot(vm, -2, SQFalse);
|
||||
sq_pop(vm, 1);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue