• 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!

Uninitialised Variable Arrays

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,347
So I want to save some data into a variable:

  • Set BossSounds[5] = HeroTinkerReady1 <gen>
My question is, what happens to the array count 0, 1, 2, 3 and 4? Is a NULL value being saved into them or nothing? I'm asking this because I'm wondering if skipping array positions is wasting system memory (by saving useless values).
 
If I understand it correctly, you are wasting system memory if you skip them, however, it is going to be a very small amount. It should be noted that the size of the array increases only if it is not large enough to accommodate the index you are trying to use. It will skip to the next largest power of 2. In this case, your array is actually size 8 in the memory. Units are actually just unit handles, so you are essentially just storing one integer. 8 integers is very little memory. However, I imagine it could get bad if you had many hundred arrays and skipped to index 5000 or something. I think that is why unit indexers are typically quite aggressive with recycling.

I can't say I'm an expert on how WC3 works. This is just what I have picked up over time and from what I know about computers (from school etc.).
 
The data stored in the other array indices remains the same as what they were before.
You can see arrays as a list of boxes.
In each box, you can store one thing, for example sounds.
If you change the value of a specific box, it wont affect the others.

A WC3 array has a limit of 8192 (0 ... 8191). The 8191st index is bugged when saving and loading the game though (iirc).
 
Status
Not open for further replies.
Back
Top