• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Uninitialised Variable Arrays

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
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).
 
Level 12
Joined
May 22, 2015
Messages
1,051
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.).
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
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.
Top