• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Unit Groups

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
I was just wondering if there is any advantage over the two methods for fixing memory leaks in unit groups:

I typed the code up so excuse the errors. I hope it makes sense

1.)

  • Events
    • Time - Elapsed Time 5 seconds
  • Conditions
  • Actions
    • Set Variable - TempUnitGroup all players in (playable map area)
    • Unit Group - Pick every unit in TempUnitGroup and do actions
      • loop actions
      • Unit - Kill Picked Unit
    • Custom Script - call DestroyGroup (udg_TempUnitGroup)
2.)

  • Events
    • Time - Elapsed Time 5 seconds
  • Conditions
  • Actions
    • custom script - set bj = true (or whatever its called, i usually copy paste)
    • Unit Group - Pick every unit (playable map area) and do actions
      • loop actions
      • Unit - Kill Picked Unit
Is there any advantage/disadvantage over one or the other?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Use the second one as it uses less function call, no other extra variable needed.
Both serve as same function - to destroy Unit Group leak.

But when 2 Unit Group is involved in the same function, you would need the variables as if you do the second one, it will destroy the Unit Group, making it destroyed before the group is referenced.
 
Status
Not open for further replies.
Top