1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] Does TriggerRegisterAnyUnitEventBJ really leak?

Discussion in 'Triggers & Scripts' started by Deuterium, Jul 20, 2009.

  1. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Well, although as far as I know TriggerRegisterAnyUnitEventBJ does leak, I've been noticing some Jassers lately mentioning that it doesn't really leak.

    So, does TriggerRegisterAnyUnitEventBJ really leak or not?

    Oops I was reading rules, and I guess this should be in the World Editor Help Zone... should it?
     
    Last edited by a moderator: Jul 24, 2009
  2. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Doesn't really matter.

    Oh, and

    Code (vJASS):
    function TriggerRegisterAnyUnitEventBJ takes trigger trig, playerunitevent whichEvent returns nothing
        local integer index

        set index = 0
        loop
            call TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent, null)

            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
    endfunction
     
  3. Viikuna

    Viikuna

    Joined:
    Aug 6, 2008
    Messages:
    430
    Resources:
    0
    Resources:
    0
    yep, it doesnt really matter. It doesnt leak as far as I know, and even if it does I would still use it.
     
  4. Ciebron

    Ciebron

    Joined:
    Apr 6, 2008
    Messages:
    760
    Resources:
    2
    Spells:
    2
    Resources:
    2
    can't boolexprs leak? or they are just minor?
     
  5. Viikuna

    Viikuna

    Joined:
    Aug 6, 2008
    Messages:
    430
    Resources:
    0
    Resources:
    0
    They say that null boolexprs leaks with GroupEnum but not with events.

    I dont know if this is true, but it doesnt really matter, since I never use null boolexprs with GroupEnum and even if every AnyUnitEventBJ actually leaks those 16 boolexprs, that would not matter at all, since that function is only called in map init anyways. ( At least thats how I use it )
     
  6. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Thanks PP I forgot to post the function code of the BJ... =)

    Well now it's not a matter of whether it matters or not, but I'm just curious to know if users are supposed to still use an Anti-Leak filter instead of the null in the TriggerRegisterPlayerUnitEvent or not...

    It's just a matter of knowledge rather than efficiency :p
     
  7. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Who cares?
     
  8. Deuterium

    Deuterium

    Joined:
    Mar 17, 2009
    Messages:
    1,301
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    Heh I do... :p
     
  9. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    602
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    exactly like everyone said and as i told you before. boolexpr leaks are caused when null is inserted at place of that boolexpr however many people ignore it coz its minor leak. i am one of this guys who dont ignore that leak and fix it. however i only told you about that leak so that you know it exists... but if its any problem like readability of your code then dont use it if you dont want...

    Poot said it in right way! who cares? well there are some who do and some who dont! but both ways are acceptable. leak is minor and only 16 leaks on map init so...

    and most important thing is like i told you before! just select your own way of coding and so.. you said that some people said it does not leak... well some of them simply ignore it and say it does not and then this who dont know read it and then they talk like they know...

    it is true that its really not a big leak but i like to fix my leaks so thats why i do it.
    and remember not to trust just anyone who tells you some random stuff... just ignore them if they are persistent. so just select do you want to remove it or not and if you want not to remove it and someone bothers you that it leaks just say its a minor and keep going with your coding style and skills, else if you select to remove leaks and someone tells you it does not leak just say you want to be sure nothing leaks... coz its not a leak to insert a proper boolexpr...

    thats all and i hope you now fully understand boolexpr-s!
    Greets!
    ~Dark Dragon
     
  10. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,952
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Code (vJASS):

    function empty takes nothing returns boolean
        return true
    endfunction

    function TriggerRegisterAnyUnitEvent takes trigger trig, playerunitevent whichEvent returns nothing
        local integer index = 0
        loop
            call TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent,wtf_is_the_syntax(empty))

            set index = index + 1
            exitwhen index == bj_MAX_PLAYER_SLOTS
        endloop
    endfunction
     


    Hurray?...
     
  11. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Passing null as a parameter sometimes leak (so I've heard). Making a boolexpr of a function that returns true is a good thing to do.

    Code (vJASS):
    function True takes nothing returns boolean
        return true
    endfunction

    // ...

    call TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent,Condition(True))


    Pooty has the greatest answers ever.
     
  12. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    For some more personal knowledge:
    Wouldn't that still create 16 boolexp? I mean, the Condition function creates a boolexp from a function.
    Offcourse that is easily avoidable, by using a global boolexp variable.

    Indeed he does.
     
  13. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Feel free to spend half an hour researching whether this leaks and if so in what way and then writing a solution to it if it does, and I'll spend that time doing something productive. I mean really, run-once leaks (and in that low numbers) are a joke even if they exist, and should only be avoided when it isn't an utter hassle to do so.
     
  14. busterkomo

    busterkomo

    Joined:
    Jun 17, 2007
    Messages:
    1,423
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    The whole "anti-leak, return true functions" are awful. The mapper should either use their own event function (like GhostWolf suggested), user BoolexprUtils, or just stick the BJ.
     
  15. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    Boolexprs are tabled like strings.
     
  16. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    RegisterAnyUnitEventBJ is one of the good BJs, if it would leak then just 16 minor leaks, which doesn't affect gameplay.

    For me, I would just stick to the RegisterAnyPlayerEvent (or whatever it was called) and make my own loop, use a dummyfilter-function and clean it.

    I don't really matter whether that leak is much or not, but clean scripting is my aim.

    And why not?


    Anyway, I would like to get a few new events, so I think I am gonna make an Event-System.
     
  17. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    602
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8

    thats correct! so its just up to coder to selcet does he want to use Condition(func...) or store it in variable. well storing it in variable is only a few nanoseconds faster so if u want sure do it!

    Code (vJASS):

    call Filter(function DummyBool)
    call Filter(function DummyBool)
    call Filter(function DummyBool)
    call Filter(function DummyBool)
    call Filter(function DummyBool)
    call Filter(function DummyBool)

    call DestroyFilter(Filter(function DummyBool))
     


    leaks cleared... since its bool table and it is just referenced at function ~via Filter of Condition natives... the read boolean condition from table and thats all. same table is never created twice no matter how much you call Filter or Condition of same function. DestroyBoolExpr simply destroys table so it is cleared until next time you generate it.

    about null filter its like poot already said its a minor leak and it wont cause lag or delays in game if not removed...
     
  18. spiwn

    spiwn

    Joined:
    Apr 27, 2008
    Messages:
    1,228
    Resources:
    0
    Resources:
    0
    There isn't the slightest chance for that to happen. I much more enjoyed spending a day with a friend.
    I was just wondering how good is the coding of a top game(of it's day).
     
  19. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    I should note that And(), Or(), and Not() boolexprs are not tabled.
     
  20. Dark_Dragon

    Dark_Dragon

    Joined:
    Jul 19, 2007
    Messages:
    602
    Resources:
    8
    Tools:
    1
    Spells:
    7
    Resources:
    8
    yeah they must be destroyed! ~via DestroyBoolExpr but if i remember correctly i never saw anyone else other then me using them :D well i used And() in fully leakless groups since it was a must...

    well And, Or, Not are not taking code they take already referenced boolexpr and thats why ofc game cant know what to do other then really loading an object.. which ofc means its a must to destroy it..

    ty for explaing thing to people Poot! +rep
    i am having hard time sometimes explaining things to everyone who asks :S

    Greets!
    ~Dark Dragon