I feel like I'm taking crazy pills here, this makes no sense.
I don't really use multidimensional arrays much but ran into some really strange behavior
type node
posX as integer
posY as integer
posZ as integer
endtype
dim nodeMap(3,0,3) as node
nodeX = 0
nodeZ = 0
i = 0
while nodeZ < 3
inc i
nodeMap(nodeX, 0, nodeZ).posX = i
nodeMap(nodeX, 0, nodeZ).posZ = i * -1
for z = 0 to nodeZ
print "check " + str$(x) + "," + str$(y) + "," + str$(z) + " " + str$(nodeMap(x, y, z).posX) + "," + str$(nodeMap(x, y, z).posY) + "," + str$(nodeMap(x, y, z).posZ)
next z
print "---"
inc nodeZ
endwhile
do
loop
this code gives the following output:
check 0,0,0 1,0,-1
---
check 0,0,0 2,0,-2
check 0,0,1 2,0,-2
---
check 0,0,0 3,0,-3
check 0,0,1 3,0,-3
check 0,0,2 3,0,-3
---
I would expect it to instead produce this output:
check 0,0,0 1,0,-1
---
check 0,0,0 1,0,-1
check 0,0,1 2,0,-2
---
check 0,0,0 1,0,-1
check 0,0,1 2,0,-2
check 0,0,2 3,0,-3
---
basically, when setting a UDT value to the 3rd dimension in an index, it applies that value to ALL of the indices within the 1st dimension,
so what am I missing here?
---
edit: after further testing, it happens with basic data types also on a 3 dimensional array. it all works as expected just fine on a 2 dimensional array. just wacky.
---
well, it looks like it is specifically an issue with jagged arrays... dim array(3,0,3) has issues, dim array(3,3,3) works as expected. whatever, the more you know!
http://games.joshkirklin.com/sulium
A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.