Warcraft III resources & community, 2003–2006 · archived

dimensional arrays

12 posts
#1

dimensional arrays

I need to make a 2 and 3 dimensional array

How would I go about doing this in the world editor ?
#2
whith sizes sx and sy, to access element [x,y] use (your_array[x*sy + y])
#3
Hello! Every array in the physics memory (1d, 2d, 3d etc) are placed linear. And why you create 3 dimensional array in c++ for example, elements for this array will placed as
0,0,0 ; 1,0,0 ; .... mx-1,0,0; 0,1,0; 1,1,0; ... mx-1,1,0; etc...

the basic formula for poly dimensially arrays to transfer this to 1-dimensially array (or physics memory) for 2 and 3 dimensions:

El[0] ... El[ma] - linear array (for example, this is your map array of any type)

mx - x dimension of array you need to make
my - y dimension of array you need to make
mz - z dimension of array you need to make

for 2 dimensions ma = (mx * my - 1)
for 3 dimensions ma = (mx * my * mz - 1)

register your El array with "ma" elements and use for access this formulas:

for element x,y of 2d array you need to get El[a] element where a = x + y*mx

for element x,y,z of 3d array you need to get El[a] element where a = x + y*mx + z*my*mx




for example, u need array with mx=2, my=3, mz=4. ma = mx*my*mz-1 = 23. 23 is the max index, but not dimension of linear array; really dimension is 24. and for access to element 0,0,0 you need to access El[0]; for access to 1,2,3 you need to access El[23]; for access to 1,0,2 you need to access El[13]


Note that all coordinates in this formulas are started with 0, not with 1! if you want to first index 1, you must replace all x,y and z with (x-1), (y-1),(z-1) and add +1 to all formulas

sorry for my bad english
#4
WRONG BITСH

multidimensional arrays in c++ are represented by buffers of data scattered randomly and pointers to them. char m[10] will take 10 bytes. char n[10][20] will take 20x10 bytes for data, not necessarily continuous, AND 10x4 bytes for pointers. n[4] will be a pointer to array of 20 chars.
#5
lol.
i only were want to help human with his problem in warcraft map. by for c++ you right, i was error, because i wasnt program c++ too long...
but my formulas are right and question is fully closed :P
#6
Use a game cache and store your data under a heading comprized of 9 digets.
Every 3 diget could refert to a deminsion and once data is set in the cache all you must do is retrieve it by giving the say reference.
This is the easiest way of making a 3D array.
#7
Gamecaches can hold much less elements than arrays, however.
#8
Did you ever hear about such thing as 'performance' dr? You do realise that game cache is slow as hell, right?
#9
use my method and be happy :P about performance: this method not bad
#10

dimensional arrays

I would rather not jimmy-rig 3 or 2 1 dimension arrays into a simulation of a 2 dimensional array, that just doesn’t sound efficient

what is the point of my spell working, if the game lags ?

There should be a text box in the variable options that changes the dimension of your array.
#11
Low-Life's method works perfectly well.
#12
Low-Life's method will also take a long time to set up properly, I'm always clumsy with my logic

@ Low-Life

ty for the equations, I will try them out