• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Snippet] TimedHandles

Hmm right, so you could do the same stuff with other agent types ?
http://www.hiveworkshop.com/forums/triggers-scripts-269/fun-stuff-images-210359/
Don't take me wrong, i'm not saying that would be useful, just trying to know.

At least it makes sense for me now why people said you don't need to null agents, even if i still highly doubt you don't need it, for let's say timer, just as an agent example.
I have a doubt for item/unit/pool as an handle example, but for the others it makes sense.

I'm not sure what you are asking. You don't need to null pointers to agents that are never destroyed. You should null pointers to agents that may be destroyed.

You don't need to null pointers to regular handles though, because they are not reference counted (e.g. texttags), even if you destroy them. They don't suffer the handle ID bug.
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
JASS:
call DestroyEffectTimed(null, 5)

This is going to create a new instance, a one-shot timer with a timeout of 5 seconds, and once it expires, it's going to recycle the timer and the instance. And all of this for what? A null value? It's not going to anything useful, just waste your CPU time.

It gets even worse with single timer enabled, it's going to add quite a lot to the loop's execution time for utterly no reason.

All I was trying to say is that if I wanted to handle null values properly ("I took the trouble to implement null safety"), I would sort them out before instanciation ("I'd do it in the constructor").

(Was it really that hard to interpret?)
 
Level 16
Joined
Aug 7, 2009
Messages
1,403
JASS:
//! zinc

library NullTest
{
    struct Foo
    {
        effect e;
        
        private static method onInit()
        {
            thistype this=thistype.allocate();
            
            this.e=AddSpecialEffect("",0.,0.);
            
            if (this.e==null)
            {
                BJDebugMsg("e is null");
            }
            else
            {
                BJDebugMsg("e is not null");
            }
            
            DestroyEffect(this.e);
            
            if (this.e==null)
            {
                BJDebugMsg("e is null");
            }
            else
            {
                BJDebugMsg("e is not null");
            }
            
        }
    }
}

//! endzinc

Output:
e is not null
e is not null

But W/E. If you want null to be a valid argument, then so shall it be.

P.s: and I was not complaining about performance, I was complaining about a lot of BS being done for no reason (when a null is passed, that is)
 
Top