- Joined
- Feb 2, 2006
- Messages
- 1,633
Hi,
for my new spell I simply wanted to add all units of type Footman as casters:
I am setting the cleanup flag bj_wantDestroyGroup for ForGroupBJ to avoid a leak of the group from GetUnitsOfTypeIdAll. However this does not work with GetUnitsOfTypeIdAll.
If you look at the function, it uses GroupAddGroup which then will destroy the source group:
The source group g being destroyed, everything after the first player will be bugged right which explains that only player 1 units have been added.
This is pretty annoying.
Is there any other way to avoid the leak without using a temporary group? Is this a known issue?
for my new spell I simply wanted to add all units of type Footman as casters:
-
Actions
-
-------- Casters --------
-
Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units of type Footman) and do (Actions)
-
Loop - Actions
-
Custom script: call RewindTime_AddCaster(GetEnumUnit())
-
-
-
JASS:
set bj_wantDestroyGroup = true
call ForGroupBJ( GetUnitsOfTypeIdAll('hfoo'), function Trig_Game_Start_Func014A )
I am setting the cleanup flag bj_wantDestroyGroup for ForGroupBJ to avoid a leak of the group from GetUnitsOfTypeIdAll. However this does not work with GetUnitsOfTypeIdAll.
If you look at the function, it uses GroupAddGroup which then will destroy the source group:
JASS:
function GetUnitsOfTypeIdAll takes integer unitid returns group
local group result = CreateGroup()
local group g = CreateGroup()
local integer index
set index = 0
loop
set bj_groupEnumTypeId = unitid
call GroupClear(g)
call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
call GroupAddGroup(g, result)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call DestroyGroup(g)
return result
endfunction
The source group g being destroyed, everything after the first player will be bugged right which explains that only player 1 units have been added.
This is pretty annoying.
Is there any other way to avoid the leak without using a temporary group? Is this a known issue?