GroupPointOrder Help

svenski

New Member
Reaction score
1
Is there a better way of doing this, and does this leak at all? I'm new to Jass editing, but the trigger seems to be working fine.

JASS:
function Trig_Pathing1_Actions takes nothing returns nothing
    local group pathers = GetUnitsInRectOfPlayer(gg_rct_Somewhere, Player(11))
    call GroupPointOrder( pathers, "attack", 500, 500 )
    set pathers = null
endfunction



Would it be more appropriate to call DestroyGroup(pathers) rather than setting the variable to null, or is that essentially doing the same thing?


Thanks for any help:)
 

Azlier

Old World Ghost
Reaction score
461
In order for a handle to be recycled, it must be destroyed and nulled. Even if you destroy and null groups, however, if you actually use the group and run it through a filter, it leaks some. If you don't supply a filter, it leaks a boolexpr. The only answers are a global group or a group stack like GroupUtils.
 

RaiJin

New Member
Reaction score
40
it must be destroyed and nulled

and btw im pretty sure you need to create a group

local group VARNAME = CreateGroup()
 

Azlier

Old World Ghost
Reaction score
461
No, he's using a BJ that automagically creates and fills the group.
 

RaiJin

New Member
Reaction score
40
if it is a LOCAL variable then why are u using udg_ ?? it looks so ugly.. if its a global then yes thats how u clear the leak
 

Azlier

Old World Ghost
Reaction score
461
I see no local in what svenski provided. It still leaks minorly, though. Dynamically created groups and timers are to be feared.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
In order for a handle to be recycled, it must be destroyed and nulled. Even if you destroy and null groups, however, if you actually use the group and run it through a filter, it leaks some. If you don't supply a filter, it leaks a boolexpr. The only answers are a global group or a group stack like GroupUtils.

This is the correct answer. Destroy and then null your group.

It is also worth noting that GetUnitsInRectOfPlayer leaks as well, as it does not null the group it returns:

JASS:
function GetUnitsInRectOfPlayer takes rect r, player whichPlayer returns group
    local group g = CreateGroup()
    set bj_groupEnumOwningPlayer = whichPlayer
    call GroupEnumUnitsInRect(g, r, filterGetUnitsInRectOfPlayer)
    return g
endfunction


Therefore, you are best off doing these actions on your own:

JASS:
function Trig_Pathing1_Actions takes nothing returns nothing
    local group pathers = CreateGroup()
    set bj_groupEnumOwningPlayer = Player(11)
    call GroupEnumUnitsInRect(pathers,gg_rct_Somewhere, filterGetUnitsInRectOfPlayer)
    call GroupPointOrder( pathers, "attack", 500, 500 )
    call DestroyGroup(pathers)
    set pathers = null
endfunction


It's always good to look at a bj function to see what it's doing. If it's not useful or it leaks, in-line the actions into your function instead of wasting the function call.
 

emjlr3

Change can be a good thing
Reaction score
395
if you are doing this often just use a global group so there is not need to keep creating/destroying one
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top