Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Help with locating C time function, and ch struct
Help with locating C time function, and ch struct
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Sylaer
(20 posts) Bio
|
Date
| Sun 30 Apr 2006 09:52 PM (UTC) |
Message
| New to mud coding but experienced player, taking several computer science courses this semester in C(++) and unix.
I'm trying to locate the guts of smaug time- the one that controls pulses, etc. I'd like to be able to write my own waits/lags, but can't find an example of it in the code. I figure, any wait/pause/lag has to call some unix function, and I'm guessing that's why sys/time is included, but I'm not familiar with the command. Could anyone point me to the file(s) that contain(s) the C or unix wait?
Also, on a similar note, I found that many smaug functions dealing with waiting use members of a pointer to a character struct. I think it's CHAR_DATA. What file is this defined in?
Hope you guys can help, I've gleaned much from lurking and will continue to do so. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Sun 30 Apr 2006 10:04 PM (UTC) |
Message
| The time-keeping code is closely tied to the network code. It works like this:
- wait for incoming data, up to a certain time limit (the tick time)
- process that data
- sleep for the tick time minus the time it took to get the data
So, every "network round" lasts "tick time". All that is in comm.c.
Then, at every tick, the update() function is called (in update.c). That takes care of counting ticks, and calling appropriate sub-updates (e.g. violence update, mob update...) after so-many ticks have gone by.
Character waits are implemented somewhat differently, and do not in fact call any unix function (they couldn't, because the system is not multithreaded, and if they paused via system call the entire game would pause). They're also handled in the network code, by simply not taking incoming data off of a connection until the wait time has elapsed. Not the best implementation (for instance it does not allow cancelling of "queued" commands) but it works.
As for CHAR_DATA, that's defined in mud.h. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Dace K
Canada (169 posts) Bio
|
Date
| Reply #2 on Sun 30 Apr 2006 11:15 PM (UTC) |
Message
| ...not allowing cancellation of "queued" commands?
Didn't you fix that? :D |
ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com
Drop by the area archives and find something for your mud. http://areaarchives.servegame.com | Top |
|
Posted by
| Sylaer
(20 posts) Bio
|
Date
| Reply #3 on Sun 30 Apr 2006 11:33 PM (UTC) |
Message
| Hey great! Thanks, that's all the information I needed, in a very timely manner, too! My questions are all wrapped up, thanks for your help! | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #4 on Mon 01 May 2006 05:12 AM (UTC) |
Message
| Dace:
Well, sure, but it requires some amount of modification to the code. :)
Sylaer:
Glad to hear that you're all set; if you have any more questions feel free to ask! |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
15,037 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top