AdamGriffith
You can change this now in User CP.
- Reaction score
- 69
Is their a way to check wether a struct array is in use? So I can reuse the empty ones.
struct Data
endstruct
globals
Data array Data_ar
endglobals
function DiiDii...
set Data_ar[x] = Data.create()
endfunction
JassHelper manual said:structs use arrays which have a 8191 values limit, and we cannot use index 0 which is null for structs, so there is an 8190 instances limit
library test
struct teststruct
real distance = 0.00
endstruct
globals
private integer counter = 0
private teststruct array data
endglobals
private function Test takes nothing returns nothing
// ...
// ...
// ...
call data[1].destroy()
endfunction
private function Actions takes nothing returns nothing
local teststruct a
set counter = counter + 1
set data[counter] = teststruct.create()
set a.distance = 2000.00
// ...
// ...
// ...
endfunction
//===========================================================================
function InitTrig_Test takes nothing returns nothing
set gg_trg_Test = CreateTrigger( )
call TriggerAddAction( gg_trg_Test, function Actions )
endfunction
endlibrary
Usually when I want to check if struct exists and is in use, I compare it to 0. And after I've destroyed a struct I set it's value to 0.
library Initialization
struct InitializationData
unit footy = null
endstruct
globals
integer counter = 0
InitializationData array data
endglobals
function Sorting takes nothing returns integer
local integer i = 1
local integer value = 0
loop
exitwhen i > 1200 or data<i> == null
set i = i + 1
endloop
set value = i
return value
endfunction
function Trig_Initialization_Actions takes nothing returns nothing
local InitializationData a
set counter = Sorting()
call DisplayTextToForce(GetPlayersAll(), I2S(counter))
set data[counter] = InitializationData.create()
set a = data[counter]
call CreateNUnitsAtLoc( 1, 039;hfoo039;, GetTriggerPlayer(), GetRectCenter(GetPlayableMapRect()), bj_UNIT_FACING )
set a.footy = GetLastCreatedUnit()
call PolledWait(10.00)
call RemoveUnit(a.footy)
call a.destroy()
set a = 0
endfunction
//===========================================================================
function InitTrig_Initialization takes nothing returns nothing
set gg_trg_Initialization = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_Initialization, Player(0) )
call TriggerAddAction( gg_trg_Initialization, function Trig_Initialization_Actions )
endfunction
endlibrary</i>
call DisplayTextToForce(GetPlayersAll(), I2S(a))