Author Topic: Suggestion: Timers  (Read 3946 times)

0 Members and 1 Guest are viewing this topic.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Suggestion: Timers
« on: November 12, 2007, 12:33:16 pm »
Well, frustrated by the buggyness of making threads in scripts, I come here with this suggestion. It consists of 2 functions and one event:

SetTimer(ID, time: integer);
Sets up a timer, time in milliseconds.

KillTimer(ID: integer);
Unsets a timer.

OnTimer(ID: integer);
Event called for each timer.

This would be great, it'd give the possibility of creating scripts that control the game flow with a precision of milliseconds.

AppOnIdle is useless in some cases (example: PerroRACE), that's why I suggest this.

I hope this is taken into consideration.
urraka

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Suggestion: Timers
« Reply #1 on: November 12, 2007, 09:43:24 pm »
You can make those functions yourself.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Suggestion: Timers
« Reply #2 on: November 12, 2007, 09:59:45 pm »
I can't get a function getting called each X milliseconds without using a separate thread. And the point is to avoid using a thread. AppOnIdle is called every 1 second, and that's not enough precision.

Another way this could be done is having a function to set the time interval of AppOnIdle, maybe that's a better and easier approach.
urraka

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: Suggestion: Timers
« Reply #3 on: November 12, 2007, 10:01:27 pm »
AppOnIdle is the closest you will get, 1 second. Milliseconds will rape your server too much

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: Suggestion: Timers
« Reply #4 on: November 13, 2007, 06:46:31 am »
Why will a shorter interval rape your server so much if people would do what they are already doing in threadfunc and it runs fine there (aside from the issues with soldat not being thread safe for whatever reason)?
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Suggestion: Timers
« Reply #5 on: November 13, 2007, 09:06:42 am »
AppOnIdle is the closest you will get, 1 second. Milliseconds will rape your server too much

Raping or not the server would be a responsability of the scripter. Anyway, I'm sure my server would love it by the ass.
urraka

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: Suggestion: Timers
« Reply #6 on: November 13, 2007, 09:22:51 am »
lol
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: Suggestion: Timers
« Reply #7 on: November 13, 2007, 11:32:11 am »
lol

This user was warned for this post.

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: Suggestion: Timers
« Reply #8 on: November 13, 2007, 12:26:02 pm »
IMO, i think we could try it tho. I agree on the fact its the server scripter own responsability.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Suggestion: Timers
« Reply #9 on: November 13, 2007, 05:44:11 pm »
So is there any chance to get this implemented? Or the definitive answer is NO! GTFO!?
It's not a complex thing, just a couple of lines  [pigtail]
urraka

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: Suggestion: Timers
« Reply #10 on: November 13, 2007, 07:56:39 pm »
It's not a complex thing, just a couple of lines  [pigtail]

All the more reason to just do it yourself ;)


one could say that there's a reason it is called a "scripting core" not a "scripting everything-you-will-ever-need-in-one-place"

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: Suggestion: Timers
« Reply #11 on: November 13, 2007, 08:07:54 pm »
It's not a complex thing, just a couple of lines  [pigtail]

All the more reason to just do it yourself ;)
He just stated he needs a time resolution smaller than a second, and currently that is not possible. You can't do that yourself because it needs changes in the server app. Not saying they should or should not be made, that's up to EnEsCe.
« Last Edit: November 13, 2007, 08:13:18 pm by sai`ke »
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Suggestion: Timers
« Reply #12 on: November 13, 2007, 08:38:13 pm »
You could always give me the server code and I'll do it myself :P
urraka

Offline Iq Unlimited

  • Flagrunner
  • ****
  • Posts: 864
  • mr. foobar2000
Re: Suggestion: Timers
« Reply #13 on: November 13, 2007, 08:41:52 pm »
You could always give me the server code and I'll do it myself :P

He's totally going to give you the server code...

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: Suggestion: Timers
« Reply #14 on: November 13, 2007, 08:46:05 pm »
It's not a complex thing, just a couple of lines  [pigtail]

All the more reason to just do it yourself ;)
He just stated he needs a time resolution smaller than a second, and currently that is not possible. You can't do that yourself because it needs changes in the server app. Not saying they should or should not be made, that's up to EnEsCe.

I didn't see him say anywhere that he needed a resolution better than 1s, but your point is made either way

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Suggestion: Timers
« Reply #15 on: November 13, 2007, 08:53:14 pm »
You could always give me the server code and I'll do it myself :P

He's totally going to give you the server code...
I hope so.

I didn't see him say anywhere that he needed a resolution better than 1s, but your point is made either way

I thought I made that clear:

This would be great, it'd give the possibility of creating scripts that control the game flow with a precision of milliseconds.


Anyway, he said 1 second is the closest I'd get.. so I guess that means he will implement it! Yay!

/retarded_mode off
urraka

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: Suggestion: Timers
« Reply #16 on: November 14, 2007, 05:30:53 am »
Do you still want these timer functions now that they don't have any added advantage over regular apponidle anymore?
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Suggestion: Timers
« Reply #17 on: November 14, 2007, 12:39:22 pm »
You missed the "/retardedmode off" part
urraka

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Suggestion: Timers
« Reply #18 on: November 14, 2007, 04:35:31 pm »
This isn't, as some people might think, an easy thing to do; as it is, the server itself only runs about every second (I say about, because sleep(1000)[windows] or usleep(1000000)[linux] only guarantee you will sleep for AT LEAST 1000ms, it's very possible you will exceed that amount of time, particularily under load), so to get AppOnIdle to be called every millisecond would require the server to also run every ms as well. Which is not going to happen, the server spends so much of it's time sleeping for a reason, so it doesn't saturate the CPU.

As for actual timers, they have their own issues; they would also only be accurate to one second, unless they were run as a seperate thread, which also adds a whole lot of complication to deal with locking of resources, race conditions, etc. Anyone that's used the scripting thread functions knows what kind of instability results there. (Mostly due to the script engine not being re-entrant).


Most of this is invalid, server only sleeps for (at least) 1 ms. But still partially valid.
« Last Edit: November 14, 2007, 11:13:26 pm by chrisgbk »

Offline sai`ke

  • Camper
  • ***
  • Posts: 318
  • Can't be arsed to remove christmas avatar
Re: Suggestion: Timers
« Reply #19 on: November 14, 2007, 05:10:07 pm »
Time resolution increase always increases load and one millisecond is absurd. And yes of course. It wouldn't do much good having timers of 100 milliseconds if the variables we have access to with scriptcore aren't updated at that resolution. Haha and yeah, writing good multithread code is a skill in itself. Is there a tech doc anywhere with the global layout of the server code?
#soldat.ttw #ttw.gather --- Quakenet!
http://ttwforums.com