Dangerb0y
New Member
- Reaction score
- 0
Maybe someone can help me understand why this is happening. It makes no freaking sense to me! :nuts:
Don't ask me how I got to this point, but say for example that you have the following script...
Let's call the trigger unit "Bob". If I looked at that script I would be willing to bet my mother that when the testactions function is called, it would print:
Bob
Bob
(null)
(null)
Bob
(null)
Right? My mom sure wouldn't think so. For some reason it displays this:
Bob
Bob
(null)
(null)
Bob
Bob <- notice the "Bob" that should be a "(null)"
Is this a bug? or is it working as it should be and I'm just not understanding exactly how structs function behind the scenes?
Don't ask me how I got to this point, but say for example that you have the following script...
JASS:
scope test initializer init
private struct data
unit u
endstruct
globals
private data array d
endglobals
private function testactions takes nothing returns nothing
local unit u = GetTriggerUnit()
local data d1
local data d2
set d1 = data.create()
set d1.u = u
set d[0] = d1
set d2 = data.create()
set d2.u = u
set d[1] = d2
set d1 = d[0]
set d2 = d[1]
call BJDebugMsg( GetUnitName(d1.u) )
call BJDebugMsg( GetUnitName(d2.u) )
set d1.u = null
call d1.destroy()
set d2.u = null
call d2.destroy()
call BJDebugMsg( GetUnitName(d1.u) )
call BJDebugMsg( GetUnitName(d2.u) )
set d1 = data.create()
set d1.u = u
call BJDebugMsg( GetUnitName(d1.u) )
call BJDebugMsg( GetUnitName(d2.u) )
endfunction
private function init takes nothing returns nothing
// etc...
endfunction
endscope
Let's call the trigger unit "Bob". If I looked at that script I would be willing to bet my mother that when the testactions function is called, it would print:
Bob
Bob
(null)
(null)
Bob
(null)
Right? My mom sure wouldn't think so. For some reason it displays this:
Bob
Bob
(null)
(null)
Bob
Bob <- notice the "Bob" that should be a "(null)"
Is this a bug? or is it working as it should be and I'm just not understanding exactly how structs function behind the scenes?