Snippet TimedHandles

DrEvil

FCRI Associate!
Reaction score
111
Why don't you loop through every instance in a struct loop ,
and then increase the time passed by 'period' and when it get's to max time , destroy / remove it ?

Then you don't need to worry about timer attachment e.t.c..
 

Jesus4Lyf

Good Idea™
Reaction score
397
So you tell me to remove H2I, I remove it and now it's even worse?

...

I don't see how it's less efficient, but what your saying is I should update it with a timer attachment system that doesn't use H2I?
Either that or write your own non-H2I attachment. For this I'd probably attach a linked list to the period. But that's trixxy. Up for a challenge?

>I don't see how it's less efficient
Hashtables are slow as crap until further notice. Subtracting the constant handle thing TimerUtils does is much better (IF DONE STABLY). And GetHandleId == H2I, for all intents and purposes, just ported to 1.24 (some patch which isn't even released). :thup:

My point was make this work on both 1.23 and 1.24 without an update if you want it to be special - different from all the other crappy things people submit to do the same thing.

As said, a linked list attached to period would be MAGIC for this. Or you could use miniscule period modification attachment (would work fine also, probably more efficient). :thup:

At the moment, anyone can write this. Hell, I could do it with KT2 in a flash and it wouldn't even break on patch. ;)
 
Reaction score
341
Dude, I don't get why I should make it non-H2I.

Seriously people with patch 1.23 will have TU for that version. People with patch 1.24 will have the updated TU.

In about a month everyone will have patch 1.24. I'm reverting it back to TU.
 

RaiJin

New Member
Reaction score
40
Either that or write your own non-H2I attachment. For this I'd probably attach a linked list to the period. But that's trixxy. Up for a challenge?

>I don't see how it's less efficient
Hashtables are slow as crap until further notice. Subtracting the constant handle thing TimerUtils does is much better (IF DONE STABLY). And GetHandleId == H2I, for all intents and purposes, just ported to 1.24 (some patch which isn't even released). :thup:

My point was make this work on both 1.23 and 1.24 without an update if you want it to be special - different from all the other crappy things people submit to do the same thing.

As said, a linked list attached to period would be MAGIC for this. Or you could use miniscule period modification attachment (would work fine also, probably more efficient). :thup:

At the moment, anyone can write this. Hell, I could do it with KT2 in a flash and it wouldn't even break on patch. ;)

:p maybe you should do a tutorial on linked lists, and 1.24 is coming out in a month?, i'd say change it to KT2 or TU but i still rather see KT2
 

Jesus4Lyf

Good Idea™
Reaction score
397
> do you have any idea when its coming out
No one does.

>I don't get why I should make it non-H2I.
And that's why.

People are writing for patch 1.24 and it's silly.

>i'd say change it to KT2 or TU but i still rather see KT2
I'd agree (naturally).

>Seriously people with patch 1.23 will have TU for that version. People with patch 1.24 will have the updated TU.
That's a really arrogant assertion that anyone has TU.

If you've failed to follow my point after my last explanation, maybe kingking can write something better.
 
Reaction score
341
People are writing for patch 1.24 and it's silly.

Once again, this is written for either version..

I mean I get your point that people will have to upgrade their TU once patch 1.24 comes out but it's not really a big deal. Takes three minutes to do.

>i'd say change it to KT2 or TU but i still rather see KT2
I'd agree (naturally).

I can't switch it to TU because KT2 isn't approved at wc3c. I'd rather have my script be approved on all sites using the same requirements.
 

Kenny

Back for now.
Reaction score
202
I can't switch it to TU because KT2 isn't approved at wc3c. I'd rather have my script be approved on all sites using the same requirements.

That is their fault for being stubborn about things. I think for this to be approved here, you sure use the best resource available, and currently that is KT2.

Something like this (looks nicer to me):

JASS:
.
    //! textmacro TIMEDHANDLES takes HANDLE,DESTROY
        
        struct $DESTROY$Timed

            $HANDLE$ var

            static method create takes $HANDLE$ h, real time returns thistype
                local thistype this = thistype.allocate()

                set this.var = h

                call KT_Add(function thistype.update,this,time)

                return this
            endmethod

            private static method update takes nothing returns nothing
                call thistype(KT_GetData()).destroy()
                return true
            endmethod

            private method onDestroy takes nothing returns nothing
                call $DESTROY$(this.var)
                set this.var = null
            endmethod

        endstruct
        
        function $DESTROY$TimedFunc takes $HANDLE$ h, real time returns nothing
            call $DESTROY$Timed.create(h,time)
        endfunction

    //! endtextmacro


Something like that, just wrote it in like 2 minutes, probably wrong. This also allows people to use struct syntax if they want, therefore you are pleasing everyone, which is a good thing. :) Even though I think struct syntax is useless for something like this, but there are bound to be people who would want it.

Also you don't null your local timers.
 
Reaction score
341
This also allows people to use struct syntax if they want, therefore you are pleasing everyone, which is a good thing

I had it as a struct before, I just switched it to a plain'ol array. though there weren't any public struct methods.

Also you don't null your local timers.

Why would I?
 

Kenny

Back for now.
Reaction score
202
Why would I?

Good coding practice? I just find it odd that you don't.

Also I think using a struct gives more options to the end user. Which is always good for a system/snippet.
 
Reaction score
341
Good coding practice? I just find it odd that you don't.

I had it before, too and was just too lazy to remove it, but since I updated it I re-wrote the functions and didn't add them back.

Also I think using a struct gives more options to the end user. Which is always good for a system/snippet.

Will do :thup:

EDIT: Updated to allow struct syntax, let me know if I did anything wrong. this textmacro syntax can make everything look confusing.
 

quraji

zap
Reaction score
144
Looks good, but you don't destroy the timer in the callback?

Woops, forgot that the native was CreateTimer, not NewTimer :p
I thought it looked different..

Anyways, good snippet, although some could argue the use of any timed handle besides effect...it never hurts to have a textmacro handy for them =]
 
Reaction score
341
Item/Effect are probably going to be the most common ones, but there are cases where other people would want to use another handle type.

Anyways, thanks for the comments/suggestions, guys.
 

Gtam

Lerning how to write and read!! Yeah.
Reaction score
164
could i maby get the 1.23 patch version coz i dont think ill be geting 1.24 soon
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top