• 🏆 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!

[Question] Group Leaks

Status
Not open for further replies.
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

this only a question for understanding:

I now there are 2 ways of removing group leaks:
  • Custom script: set bj_wantDestroyGroup = true
  • Custom script: call DestroyGroup(udg_GroupVar)
Know I want ask what is better?

Because everyone say: bj functions are bad? But as I remember isn't blizzard using bj's? So this will mean Blizzard's trigger are bad?

Or you can say"no with set bj_wantDestroyGroup = true it's different? But why it would be different at this point?

Or you think the 2nd way is better - but for this you need a variable - and if use this maybe 100 times - is this bad aswell or no problem?
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Yes, bj_wantDestroyGroup removes the group immediately after you run the "pick every ..."
The "Pick every.." function is called ForGroupBJ in JASS and here is the definition of it:
JASS:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

Ok you say it's faster but I think I don't understand this "faster". If I use "bj_wantDestroyGroup = true" it destroy the group immediately after I run "pick every..."

But if I use "call DestroyGroup(udg_GroupVar)" - I know there are some actions before but there is no wait - or all those actions happen at the same time - so this isn't "faster" (?)
 
Hey isn't destroy group faster? as the first calls it? wouldnt it be faster doing the destroy?

I'd assume so since they both lead to calling the DestroyGroup() func. Not that it really matters though, they are pretty even in terms of optimization and it won't really have an impact on your code.

But I'd suggest using DestroyGroup() for the most part since bj_wantDestroy is situational in the fact that it'll immediately be destroyed after ForGroup(). But all-in-all, it isn't something to really worry about.
 
Status
Not open for further replies.
Top