• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[JASS] Array Struct Member

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Hello people,,

I got a question about variables in structs,, especially array'd members,,
JASS:
struct TEST
    unit array UNIT
endstruct
This is actually in short what i mean,,
How would this act? I know struct member become array'd globals,, but how can i array an array'd global? Cause that is actually what we would do here,,
Would it decrease array size, to something like this:
JASS:
UNIT[StructNumber  *  ??]
or is it not even possible? Would i have to make like 5 unit-structmembers?

Thanks!

-Yixx,,-
 
Level 11
Joined
Feb 22, 2006
Messages
752
You have to declare the size of the array for struct array members. For example:

JASS:
struct A
    unit array u[5]
endstruct

This would declare a unit array of size 5. The size is fixed and cannot be changed. Using array members also decreases the maximum instances of a struct type you can have. The max instance limit is 8190 / [next largest power of 2 greater than or equal to array size]. For example struct A above could only have 1023 instances existing at once (8190/8).

EDIT: The limit on how many instances of a struct you have depends on the array member with the largest size, not the total number of indices for all arrays, so for example:

JASS:
struct B
    unit array u[5]
    integer array i[10]
endstruct

Struct B can have 511 instances (8190/16).
 
Status
Not open for further replies.
Top