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

[vJass] RAS

Level 12
Joined
Apr 27, 2008
Messages
1,228
Will it work if I replace this:
JASS:
private struct $ID$str
    integer array $ID$struct[size]
endstruct
with this:
JASS:
private struct $ID$str [size]
    integer array $ID$struct[size]
endstruct
??

NewGen seems to have some flaws, but it is user created and free(and great ;) ). Maybe because of lack of extensive testing :p

Well
JASS:
struct a [size*some_number]
 any_standard_type array  name [size]
endstruct
Can have some_number instances of the struct.


JASS:
private type blah extends integer array [400,10000]
struct a [some_number]
 blah data
endstruct

This will have a 250(or some_number - whichever is the smaller) instances limit.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
This one should work, right?

JASS:
library RAS initializer Init

private function H2I takes handle h returns integer
    return h
    return 0
endfunction

globals
    private constant integer size = 8191
    private constant integer size2 = 50
endglobals

private struct str [size*size2]
    integer array struct
endstruct

globals
    private str array stru [size][size2]
endglobals

function GetAttachedStruct takes handle h, integer slot, integer slot2 returns integer
    return stru[H2I(h) - 0x100000][slot].struct[slot2]
endfunction

function AttachStruct takes handle h, integer dat, integer slot, integer slot2 returns nothing
    set stru[H2I(h) - 0x100000][slot].struct[slot2] = dat
endfunction

private function Init takes nothing returns nothing
    local integer i = 0
    local integer i2 = 0
    local integer i3 = 0
    loop
        exitwhen i > size * size2
        loop
            exitwhen i2 > size2
            set stru[i][i2] = i3
            set i3 = i3 + 1
            set i2 = i2 + 1
        endloop
        set i2 = 0
        set i = i + 1
    endloop
endfunction

endlibrary
 
Last edited:
Level 12
Joined
Apr 27, 2008
Messages
1,228
No :(
Several reasons:

Though ain't sure for the field name - "struct"(not sure about vJass, but in other programming languages identifiers can't have the same name as any keyword).

The struct is still limited to 8191 instances. To change that:
JASS:
private struct str [ Some_size]
    integer array struct
endstruct

And as Captain Griffen said, any array in vJass can have 408000 ( 409550 to be precise, as stated by the syntax checker, equal to 8191 * 50, after all the extended arrays are formed by using lots of arrays) members/slots/indexes.
The one you wanted to create has 1000* 408000.

P.s. I recommend using Game Cache ;)
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
spiwn said:
Though ain't sure for the field name - "struct"(not sure about vJass, but in other programming languages identifiers can't have the same name as any keyword).
NewGen doesn't react when I have a variable with the name "struct", but it does when I use names such as "unit", "destructible" etc.

spiwn said:
The struct is still limited to 8191 instances.
Does this mean I can't have more than 8191 structs? Or can't it be higher than 8191?

spiwn said:
And as Captain Griffen said, any array in vJass can have 408000 ( 409550 to be precise, as stated by the syntax checker, equal to 8191 * 50, after all the extended arrays are formed by using lots of arrays) members/slots/indexes.
The one you wanted to create has 1000* 408000.
I can change that, so it will be 50*8191 instead.

spiwn said:
P.s. I recommend using Game Cache ;)
I don't want to use it ^^
 
Top