SYNOPSIS
help server
DESCRIPTION
The server for help keywords is designed to be a simple extension
to the help command for players. The help command is functional but
limited in the way it searches for help topics. When a player types
'help <topic>', the builtin help command searches the text files
located in /doc/helpdir/* to see if it finds a file name which
matches <topic>. If it finds one, the content of the file is
output to the player; otherwise the player gets a message that we
don't have a help file matching that topic.
The problem arises when players attempt to access help on a topic
which we actually do have a file for, but the player uses the wrong
keyword. Examples of this are 'help HP' (file is named 'hitpoints'),
'help mail' (file is named 'email') or 'help emote' (the file is
named 'emotes'). You see the problem.
The help server attempts to bridge this gap with a simple mechanism.
It consists of two pieces: the server itself (keyword_server.c) and
the keywords file (help_keywords). The keywords file stores a hard
copy of the various aliases plus pointers to the files. The server
keeps a mapping of keywords and file paths in memory and allows
public queries. This way, any one help file can have an unlimited
number of aliases to it.
THE KEYWORD FILE
The format for entering new keywords is:
keyword:absolute file name
Comments beginning with // are ignored, as are blank lines.
Only one entry per line is allowed. There must be no spaces
between the keyword, colon and file path.
That's it - easy, eh?
When the server loads, it automatically checks the keywords
file and updates itself if necessary.
THE KEYWORD SERVER
The server maintains a mapping of keywords and file paths. This
mapping is stored via save_object() and restore_object() into a
local save ("keyword_server.o") file.
When the server loads, it checks the age of the keywords file and
compares it against the age of its save file. Depending
on which is newer, it either keeps the local mapping or
reloads the keyword data from the save file. This way it only
uses up resources parsing the text file when the text file has
changed.
If it reloads from the keywords file, the data mapping is always
cleaned out, not simply appended to, in case a help file
has been deleted.
The keyword server performs a number of checks to ascertain that
the data it's reading in is valid.
It is not possible to clone the server. It could be possible to make
it inheritable for other projects though.
FUNCTIONS
There are only 2 public functions in the server.
mixed QueryKeyword(string keyword)
The server returns either the absolute path for the given keyword,
or 0 if not found.
void update_server()
This forces the server to reload the keyword file.
SEE ALSO