mirror of https://github.com/OpenTTD/OpenTTD.git
Fix: [Script] Access to enum/consts defined outside of main.nut (#10573)
This commit is contained in:
parent
0bf6f82305
commit
9642e87bc8
|
@ -566,6 +566,10 @@ void Squirrel::Initialize()
|
||||||
|
|
||||||
sq_pushroottable(this->vm);
|
sq_pushroottable(this->vm);
|
||||||
squirrel_register_global_std(this);
|
squirrel_register_global_std(this);
|
||||||
|
|
||||||
|
/* Set consts table as delegate of root table, so consts/enums defined via require() are accessible */
|
||||||
|
sq_pushconsttable(this->vm);
|
||||||
|
sq_setdelegate(this->vm, -2);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SQFile {
|
class SQFile {
|
||||||
|
@ -764,6 +768,12 @@ void Squirrel::Uninitialize()
|
||||||
{
|
{
|
||||||
ScriptAllocatorScope alloc_scope(this);
|
ScriptAllocatorScope alloc_scope(this);
|
||||||
|
|
||||||
|
/* Remove the delegation */
|
||||||
|
sq_pushroottable(this->vm);
|
||||||
|
sq_pushnull(this->vm);
|
||||||
|
sq_setdelegate(this->vm, -2);
|
||||||
|
sq_pop(this->vm, 1);
|
||||||
|
|
||||||
/* Clean up the stuff */
|
/* Clean up the stuff */
|
||||||
sq_pop(this->vm, 1);
|
sq_pop(this->vm, 1);
|
||||||
sq_close(this->vm);
|
sq_close(this->vm);
|
||||||
|
|
Loading…
Reference in New Issue