Crashcourse - Part 12

[previous part] [Table of contents] [next part]

What are daemons good for? Good question...

There is one important thing to note about daemons, they don't get turned off. This may not seem important to you right now, but believe me, it can be very useful. Objects that no longer are in touch with players are "turned off" (no heartbeat -> no reset, etc.) and eventually get swapped out to save space and cpu load. This does not happen to daemons.

Let me illustrate this with an example, some of you may or may not recognize the settings from a certain area of mine: There's a fort with some bowmen on top of the walls. These bowmen watch the surroundings of the fort for potential enemies. They also look around inside the fort to see if an intruder is attacking the fort. So, what's easier than adding this "looking around" in a load_chat() and have that load_chat run every 10 secs or so? Great idea. It's easy and it'll work just fine. NOT! Since there are no players in the same room as the bowmen, their heartbeats have been turned off! And when there's no heartbeat, there's no load_chat() either... And whoopsie, the attackers can go about their business without the fear of being hit by an arrow...

Now, you may think, what is a daemon, codewise? Actually, a daemon is basically just a functionfile (if you code them like you have learned in this course), so there's not much new to learn.

What's important to note with daemons, is that you must make sure the daemon gets loaded. There are several ways of making this happen. If the daemon is only supposed to be operational when someone enters a specified area, then all you have to do, is hook the first exit into the area, and have that exit load the daemon if it's not already loaded. This may work on some areas, but what if the area has got several ways in or what if the daemon is for several smaller areas or perhaps for the whole mud? If so, you take the easy way out:

  1. You make damn sure your daemon works 100% and does what it's supposed to.
  2. You take a note of it's full pathname (not just the filename).
  3. You beg an arch, preferably a QC Arch, to include that pathname in the mud's initfile(/secure/etc/init_file).

All files in this initfile are loaded automatically upon reboot, so once your file is included into that file, you're home free... ;-)

If you ever move/rename/delete that file, remember to notify an arch about it so that he/she can fix up the initfile.

You can take a look at greeting_d.c for an example. And since you're such a coding wizkid, I won't bother telling you what it does and how it does it. ;-)


WRITTEN: 23 - Dec - 1996 - Gunner
LAST UPDATE: 28 - May - 1998 - Gunner
HTML Version: 07 - Feb - 2000 - Ghorwin

[previous part] [to the top] [Table of contents] [next part]