-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comparison of bools in structs fails under certain circumstances #12
Comments
Some extra weirdness. Commenting out some of the previous calls to Function testBoolStruct() Global
testStruct structA = new testStruct
testStruct structB = new testStruct
structA.b = false
structA.i = 0
structA.f = 0
structA.O = Game.GetForm(0x14) as ObjectReference ; PlayerRef
structB.b = true
structB.i = 1
structB.f = 1
structB.O = Game.GetForm(0x22B94) as ObjectReference ; some arbitrary rock somewhere
bool bFalse = false
bool bTrue = true
int i0 = 0
int i1 = 1
float f0 = 0
float f1 = 1
ObjectReference PlayerRef = Game.GetForm(0x14) as ObjectReference
ObjectReference Rock = Game.GetForm(0x22B94) as ObjectReference
Debug.Trace("##############################")
; these work properly
Debug.Trace("structA: " + structA.b)
Debug.Trace("structB: " + structB.b)
; Debug.Trace("structA.b || structB.b: " + (structA.b || structB.b))
; Debug.Trace("structB.b || structA.b: " + (structB.b || structA.b))
; Debug.Trace("false || (bTrue != bFalse): " + (false || (bTrue != bFalse)))
; Debug.Trace("false || (i0 != i1): " + (false || (i0 != i1)))
; Debug.Trace("false || (f0 != f1): " + (false || (f0 != f1)))
; Debug.Trace("false || (PlayerRef != Rock): " + (false || (PlayerRef != Rock)))
; Debug.Trace("false || (structA.i != structB.i): " + (false || (structA.i != structB.i)))
; Debug.Trace("false || (structA.f != structB.f): " + (false || (structA.f != structB.f)))
; Debug.Trace("false || (structA.O != structB.O): " + (false || (structA.O != structB.O)))
; this one doesn't, with Caprica
Debug.Trace("false || (structA.b != structB.b): " + (false || (structA.b != structB.b)))
Debug.Trace("##############################")
EndFunction The assembly:
The two |
Hmm, it appears to be related to reuse of earlier temp variables created for the same function.
compiles down to
I haven't tried running this variation either, but presumably the first line would correctly return true, and the second one, incorrectly, false. |
So, I ran into a confusing thing earlier, where one line of code in one of my scripts wasn't working as expected. I investigated, and here's some test code that demonstrates the bug:
I compiled two separate scripts, identical except that one was compiled with the Bethesda compiler, and the other with Caprica (boolTestB and boolTestC respectively), and here's the log output, again in the same order:
Also, here's the assembly after running each through Bethesda's disassembler:
It appears that Caprica gets really confused and starts assigning everything to ::temp3 for some reason. This also makes Champollion fail miserably on the Caprica script, it just gives up when it gets to that section. This was compiled with the now 2-year-old v0.2.0 release binary from the Nexus, without the -O flag since I know it's borked in that version.
Also, here's a link to an archive with the sources, compiled scripts, Caprica .pas output (for boolTestC), and disassembled .pas outputs for both, in case it helps any.
This is easy enough to work around, but really confusing if you run into it like I did. Any ideas?
The text was updated successfully, but these errors were encountered: