• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Array Size

Status
Not open for further replies.
Level 5
Joined
Aug 6, 2009
Messages
136
So I was wondering before I got into triggering again.

I heard that array size 1 is from 0 - 10
Is this true?

If that's the case, what about the other array sizes?
Array size 2 = 20 then?

Thanks in advance
 
No?..

You declare your array like Tempunit[20];

Then you have 20 + 1 unit variables named Tempunit

Like:
Tempunit[0] = Grunt;
Tempunit[1] = Bob;
Tempunit[2] = LordDz;
Tempunit[3] = AwesomeSauceDude;
Tempunit[4] = Grunt the Extreme Destroyer;
Tempunit[5] = Grunt;
etc
 
I think he means GUI, and no, if you say array size is 1, it is really 1, but never set it to anything but 0, because it is fully useless.

What it does in the background is it tries to initialize every index from 0 to (the number - 1), so if I have Trigger array variable which says "Initial size: 10" it will create 10 triggers at indexes 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.

However this is not really good, because if you make few arrays that need to be constructed of size 8191(maximum), your map will fail to run initialization triggers properly, because you will hit "OP limit"(thats how we call it) before finishing initializing the variables.

Arrays in Jass are always of size 8191(indexes from 0 to 8190) and can not be made bigger or smaller. vJass does the same thing, but forces you to not use higher indexes(not true inside structs, which basically cuts the array into 8190/array_size pieces)
 
JASS has no idea of "array size". Each variable you declare as an array has indices from 0 to 8191. In GUI the size field purely defines what indexes get an initial value.

It should be noted that the implementation of the arrays are dynamic growing arrays with the growth rate being in powers of 2. This means that using index 8191 will resize the array to full size (32 kb) where as using only the first 16 indices will use much less memory (<1 kb).

It should also be noted that due a bug with the save/load code, the contents of index 8191 are lost after a game is loaded.
 
every GUI action related to unit groups, as well as player groups does create group/force automatically.

Yes you need to create them, but I mean you dont need to initialize them at init, hence size can stay 0/1

This is not entirely true. When using add unit to unit group it does not create that unit group first. So the unit group and player group may be null.
 
What it does in the background is it tries to initialize every index from 0 to (the number - 1), so if I have Trigger array variable which says "Initial size: 10" it will create 10 triggers at indexes 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.

GUI array variables are initialized upto the value. Meaning if initial size if 2, then indexes 0, 1, and 2 are initialized with the initial value.

It also creates groups for example upto the initial size. With the default size of 1, groups for indexes 0 and 1 are created automatically.
 
Status
Not open for further replies.
Back
Top