• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

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