Help with locating C time function, and ch struct

Posted by Sylaer on Sun 30 Apr 2006 09:52 PM — 5 posts, 20,309 views.

#0
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.
USA #1
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.
Canada #2
...not allowing cancellation of "queued" commands?

Didn't you fix that? :D
#3
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!
USA #4
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!