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

[Trigger] Maximum value of an array? Quick question :)

Status
Not open for further replies.
Level 3
Joined
Jul 7, 2007
Messages
22
Hey all,

I was thinking today about my ID system -- it's a "stupid" system and doesn't fill gaps when a unit dies. Basically I just add 1 to a counter each time a unit enters the map -yes I know I am a bad boy-, set that unit's custom value to the counter, and set udg_id_unit[#] to that unit. But I have quite a few units who enter and are removed from the map. What is the maximum bit that this can go up to?

Thanks and sorry if this is a dumb question...

Extra credit question: Why is it that some arrays MUST be set a size, but other array vars you can leave at just [1] and it will enumerate seemingly indefinitely?
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
I was thinking today about my ID system -- it's a "stupid" system and doesn't fill gaps when a unit dies. Basically I just add 1 to a counter each time a unit enters the map -yes I know I am a bad boy-, set that unit's custom value to the counter, and set udg_id_unit[#] to that unit. But I have quite a few units who enter and are removed from the map. What is the maximum bit that this can go up to?
Get a unit indexer from the spell section. The system will literally do this all for you. They will assign an "ID" to units that enter the map, and properly recycle them when they are removed from the game.

Extra credit question: Why is it that some arrays MUST be set a size, but other array vars you can leave at just [1] and it will enumerate seemingly indefinitely?
You can easily leave it at their default values and have no issues. Some exceptions however are unit group and timer arrays. For cases like this, you will need to manually initialize them if you do not define a definite size.

I think array size has no max limits!
The max array size is 8192 (0 - 8191). However, if I remember correctly, 8191 is known to bug out, so people stick to 8190 as the max. Regardless, I don't see how its possible to ever reach the max. You would really need to try to even break 1000. Either that, or you just have a bad recycler :p
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
If you define a size, the array will be filled with the default value that you specified for that amount of slots.
The remaining slots are always the null value (0 for integers and reals and false for booleans).

This doesnt really matter except for some types like a unit group which requires custom scripts to create a new empty group.
Same for timers, but also for locations, forces, hashtables, multiboards, quests, and everything else.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Carefull, you can reach the limit op if you use several GUI global array variables with a big defined size and use a custom default value.
In fact 2 array variables with the size 8192 is enough.
And you don't have to define the size of a GUI variable unless you want a custom default value.

In short, the triggers will not be created, because the limit op will be reached on the loop where GUI array variables are setted to the specified value.
vJass stuff won't be broken because it's done before.
But that also means that you shouldn't use GUI variables at map init in vJass code, unless you know what you are doing.
 
Status
Not open for further replies.
Top