1
0
Fork 0

Fix: [Script] Access to enum/consts defined outside of main.nut (#14176)

pull/13655/merge
Loïc Guilloux 2025-05-01 18:16:32 +02:00 committed by GitHub
parent 1f212e6f2a
commit 41b113840a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 5 deletions

View File

@ -17,6 +17,10 @@ function Regression::TestInit()
print(" IsValid(vehicle.plane_speed): " + AIGameSettings.IsValid("vehicle.plane_speed"));
print(" vehicle.plane_speed: " + AIGameSettings.GetValue("vehicle.plane_speed"));
require("require.nut");
print(" TestEnum.value1: " + ::TestEnum.value1);
print(" test_constant: " + ::test_constant);
print(" TestEnum.value2: " + TestEnum.value2);
print(" test_constant: " + test_constant);
print(" min(6, 3): " + min(6, 3));
print(" min(3, 6): " + min(3, 6));
print(" max(6, 3): " + max(6, 3));

View File

@ -1,2 +1,9 @@
print(" Required this file");
const test_constant = 1;
enum TestEnum {
value0,
value1,
value2
};

View File

@ -8,6 +8,10 @@
IsValid(vehicle.plane_speed): true
vehicle.plane_speed: 2
Required this file
TestEnum.value1: 1
test_constant: 1
TestEnum.value2: 2
test_constant: 1
min(6, 3): 3
min(3, 6): 3
max(6, 3): 6
@ -81,7 +85,7 @@
20
30
40
Ops: 8673
Ops: 8649
--Std--
abs(-21): 21
@ -9763,9 +9767,9 @@ ERROR: IsEnd() is invalid as Begin() is never called
--Valuate() with excessive CPU usage--
Your script made an error: excessive CPU usage in valuator function
*FUNCTION [unknown()] regression/main.nut line [2065]
*FUNCTION [unknown()] regression/main.nut line [2069]
*FUNCTION [Valuate()] NATIVE line [-1]
*FUNCTION [Start()] regression/main.nut line [2066]
*FUNCTION [Start()] regression/main.nut line [2070]
[id] 0
[this] TABLE
@ -9774,7 +9778,7 @@ Your script made an error: excessive CPU usage in valuator function
[this] INSTANCE
Your script made an error: excessive CPU usage in valuator function
*FUNCTION [Start()] regression/main.nut line [2066]
*FUNCTION [Start()] regression/main.nut line [2070]
[Infinite] CLOSURE
[list] INSTANCE

View File

@ -1253,7 +1253,8 @@ bool SQVM::Get(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest,
if(fetchroot) {
if(_rawval(STK(0)) == _rawval(self) &&
type(STK(0)) == type(self)) {
return _table(_roottable)->Get(key,dest);
if (_table(_roottable)->Get(key,dest)) return true;
return _table(_ss(this)->_consts)->Get(key,dest);
}
}
return false;