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

[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