HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

TimerUtils - Problems.

02-25-2010, 12:49 PM#1
Anachron
Hey guys.

I want to reuse as much of variables that I can now, and I started using TimerUtils.

However, I always get the error that there are no free timers, when I create the first timer. The start amount is 50.

Ignore my system double free, the timer problem is still there.

Thanks for helping.
CM_UP_v.0.0.2.w3x
Attached Files
File type: w3xCM_UP_v.0.0.2.w3x (90.5 KB)
02-25-2010, 01:20 PM#2
moyack
disclaimer: I haven't opened your test map.

Which flavour are you using?? if you use red, try blue (just for testing)
Are you using properly ReleaseTimer()?? post code of your code...
02-25-2010, 01:22 PM#3
Anachron
It doesn't work with any of the flavors.
And its easier to check the map, since I only create one timer once and never again.

I do not release timers, because there is only one timer I need. (yet).
02-25-2010, 02:30 PM#4
moyack
Quote:
Originally Posted by Anachron
It doesn't work with any of the flavors.
And its easier to check the map,
I don't have WC3 here, that's the reason.
Quote:
since I only create one timer once and never again.

I do not release timers, because there is only one timer I need. (yet).
Then right now timerutils in general is useless for you. With just create a timer in a global variable that's enough for your needs.
02-25-2010, 02:31 PM#5
Anachron
Yes, but sooner or later I want to learn how to use that stuff, and I want to give the possibility to create a timer per instance.

So it wouldn't be useless.
02-25-2010, 02:41 PM#6
Ammorth
How to use TimerUtils:

Replace CreateTimer() with NewTimer()
Replace DestroyTimer() with ReleaseTimer()

I personally would use Blue flavour for what you need it for.
02-25-2010, 02:45 PM#7
Anachron
I don't even destroy timers and I only have one function that creates a timer, using NewTimer().

Please check the map.
02-25-2010, 03:29 PM#8
Ammorth
Struct initialization occurs before library Initialization. Move your NewTimer calls into a library intialization instead of the struct.
02-25-2010, 04:55 PM#9
Anitarf
What Ammorth said. Generally, however, for a static timer that you never destroy, you should just use CreateTimer() instead of NewTimer(), problem averted.
02-25-2010, 06:17 PM#10
Anachron
Hmm yeah thanks, that was my mistake.

And why isn't it initialized before? I mean it requires the other library, doesn't that mean its onInit parsed after the requirement? At least it should
02-25-2010, 07:05 PM#11
Earth-Fury
TimerUtil's NewTimer() method requires the TimerUtil's library be initialized before it can be used. If you use it from a struct's initializer, which is run before _any_ library initializers....
02-25-2010, 07:14 PM#12
Anachron
Oh I see. Damn so there is no other way around.
02-25-2010, 10:51 PM#13
Ammorth
Collapse JASS:
library YourLib intitializer onInit requires TimerUtils, Blah blah blah

struct yourStruct
...

private function onInit takes nothing returns nothing
    set yourStruct.t = NewTimer()
endfunction
02-25-2010, 10:52 PM#14
Anachron
Yes I know, but I really like the static onInit method. So they are kinda useless?
02-26-2010, 12:29 AM#15
Anitarf
Quote:
Originally Posted by Anachron
Yes I know, but I really like the static onInit method. So they are kinda useless?
Why? Because you can't do something you weren't supposed to do anyway? Seriously, just use CreateTimer().