• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Unit Group

Status
Not open for further replies.
Level 18
Joined
May 11, 2012
Messages
2,103
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))
 
Level 7
Joined
Jan 22, 2013
Messages
293
I'm thinking the whole bj_wantDestroyGroup is not good since the group isn't nulled when using that.

You should edit the Things that leak (Thread) and put in big bold

YOU SHOULD ALWAYS NULL AFTER LEAK REMOVALS
 
Level 4
Joined
Jan 27, 2010
Messages
133
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.
Top