1
0
Fork 0
Loïc Guilloux 2025-06-29 04:47:56 +00:00 committed by GitHub
commit dfbd72e03e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 0 deletions

View File

@ -36,3 +36,11 @@ AITown.FoundTown <- function(tile, size, city, layout, name) { return AITown.Fou
AIVehicle.SetNameCompat14 <- AIVehicle.SetName; AIVehicle.SetNameCompat14 <- AIVehicle.SetName;
AIVehicle.SetName <- function(id, name) { return AIVehicle.SetNameCompat14(id, AICompat14.Text(name)); } 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"); }
}

View File

@ -81,3 +81,11 @@ GSTown.FoundTown <- function(tile, size, city, layout, name) { return GSTown.Fou
GSVehicle.SetNameCompat14 <- GSVehicle.SetName; GSVehicle.SetNameCompat14 <- GSVehicle.SetName;
GSVehicle.SetName <- function(id, name) { return GSVehicle.SetNameCompat14(id, GSCompat14.Text(name)); } 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"); }
}

View File

@ -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)); 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 /* 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. */ * 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) { 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; if (*it == this->api_version) break;
} }
sq_pushroottable(vm);
sq_pushstring(vm, "CompatScriptRootTable");
sq_deleteslot(vm, -2, SQFalse);
sq_pop(vm, 1);
return true; return true;
} }