mirror of https://github.com/OpenTTD/OpenTTD
Fix: [Script] Access to enum/consts defined outside of main.nut (#14176)
parent
1f212e6f2a
commit
41b113840a
|
@ -17,6 +17,10 @@ function Regression::TestInit()
|
||||||
print(" IsValid(vehicle.plane_speed): " + AIGameSettings.IsValid("vehicle.plane_speed"));
|
print(" IsValid(vehicle.plane_speed): " + AIGameSettings.IsValid("vehicle.plane_speed"));
|
||||||
print(" vehicle.plane_speed: " + AIGameSettings.GetValue("vehicle.plane_speed"));
|
print(" vehicle.plane_speed: " + AIGameSettings.GetValue("vehicle.plane_speed"));
|
||||||
require("require.nut");
|
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(6, 3): " + min(6, 3));
|
||||||
print(" min(3, 6): " + min(3, 6));
|
print(" min(3, 6): " + min(3, 6));
|
||||||
print(" max(6, 3): " + max(6, 3));
|
print(" max(6, 3): " + max(6, 3));
|
||||||
|
|
|
@ -1,2 +1,9 @@
|
||||||
print(" Required this file");
|
print(" Required this file");
|
||||||
|
|
||||||
|
const test_constant = 1;
|
||||||
|
|
||||||
|
enum TestEnum {
|
||||||
|
value0,
|
||||||
|
value1,
|
||||||
|
value2
|
||||||
|
};
|
||||||
|
|
|
@ -8,6 +8,10 @@
|
||||||
IsValid(vehicle.plane_speed): true
|
IsValid(vehicle.plane_speed): true
|
||||||
vehicle.plane_speed: 2
|
vehicle.plane_speed: 2
|
||||||
Required this file
|
Required this file
|
||||||
|
TestEnum.value1: 1
|
||||||
|
test_constant: 1
|
||||||
|
TestEnum.value2: 2
|
||||||
|
test_constant: 1
|
||||||
min(6, 3): 3
|
min(6, 3): 3
|
||||||
min(3, 6): 3
|
min(3, 6): 3
|
||||||
max(6, 3): 6
|
max(6, 3): 6
|
||||||
|
@ -81,7 +85,7 @@
|
||||||
20
|
20
|
||||||
30
|
30
|
||||||
40
|
40
|
||||||
Ops: 8673
|
Ops: 8649
|
||||||
|
|
||||||
--Std--
|
--Std--
|
||||||
abs(-21): 21
|
abs(-21): 21
|
||||||
|
@ -9763,9 +9767,9 @@ ERROR: IsEnd() is invalid as Begin() is never called
|
||||||
--Valuate() with excessive CPU usage--
|
--Valuate() with excessive CPU usage--
|
||||||
Your script made an error: excessive CPU usage in valuator function
|
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 [Valuate()] NATIVE line [-1]
|
||||||
*FUNCTION [Start()] regression/main.nut line [2066]
|
*FUNCTION [Start()] regression/main.nut line [2070]
|
||||||
|
|
||||||
[id] 0
|
[id] 0
|
||||||
[this] TABLE
|
[this] TABLE
|
||||||
|
@ -9774,7 +9778,7 @@ Your script made an error: excessive CPU usage in valuator function
|
||||||
[this] INSTANCE
|
[this] INSTANCE
|
||||||
Your script made an error: excessive CPU usage in valuator function
|
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
|
[Infinite] CLOSURE
|
||||||
[list] INSTANCE
|
[list] INSTANCE
|
||||||
|
|
|
@ -1253,7 +1253,8 @@ bool SQVM::Get(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest,
|
||||||
if(fetchroot) {
|
if(fetchroot) {
|
||||||
if(_rawval(STK(0)) == _rawval(self) &&
|
if(_rawval(STK(0)) == _rawval(self) &&
|
||||||
type(STK(0)) == type(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;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue