Unit Group

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,108
Does this leak one unit group?

  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Random 1 units from (Units within 500.00 of TempPoints[1])) and do (Actions)
    • Loop - Actions
      • Set TempPoints[2] = (Position of (Picked unit))
 
rulerofiron99 said:
Set TempUnit = Random unit from (units within 500 of TempPoint)
Set TempPoint2 = position of TempUnit

You should use bj_wantDestroyGroup=true, or it will leak a group.

  • Custom script: set bj_wantDestroyGroup = true
  • Set TempUnit = Random unit from (units within 500 of TempPoints[1])
  • Set TempPoints[2] = position of TempUnit
JASS:
set udg_TempUnit = GroupPickRandomUnit(GetUnitsInRangeOfLocAll(500, udg_TempPoint[1]))

  • GetUnitsInRangeOfLocAll - creates a group.
  • GroupPickRandomUnit - destroys a group if bj_wantDestroyGroup=true.

Maker said:
I'm thinking the whole bj_wantDestroyGroup is not good since the group isn't nulled when using that.

I don't think you can avoid a pointer leak when using GUI...

  • Unit Group - Get Units in (Range) of (Point)
JASS:
function GetUnitsInRangeOfLocAll takes real radius, location whichLocation returns group
    return GetUnitsInRangeOfLocMatching(radius, whichLocation, null)
endfunction

function GetUnitsInRangeOfLocMatching takes real radius, location whichLocation, boolexpr filter returns group
    local group g = CreateGroup()
    call GroupEnumUnitsInRangeOfLoc(g, whichLocation, radius, filter)
    call DestroyBoolExpr(filter)
    return g // POINTER-LEAK, local variable isn't nulled
endfunction
 
Last edited:
Status
Not open for further replies.
Back
Top