diff -r -N -c socketmud/src/action_safe.c socketmud-1.4/src/action_safe.c *** socketmud/src/action_safe.c Sat Mar 22 14:49:38 2003 --- socketmud-1.4/src/action_safe.c Thu May 1 23:38:05 2003 *************** *** 25,31 **** /* log the attempt */ sprintf(buf, "%s has left the game.", dMob->name); ! log(buf); save_player(dMob); --- 25,31 ---- /* log the attempt */ sprintf(buf, "%s has left the game.", dMob->name); ! log_string(buf); save_player(dMob); diff -r -N -c socketmud/src/help.c socketmud-1.4/src/help.c *** socketmud/src/help.c Sat Mar 9 19:49:04 2002 --- socketmud-1.4/src/help.c Thu May 1 23:38:05 2003 *************** *** 15,21 **** /* include main header file */ #include "mud.h" ! HELP_DATA * help_list; /* the linked list of help files */ char * greeting; /* the welcome greeting */ char * motd; /* the MOTD help file */ --- 15,21 ---- /* include main header file */ #include "mud.h" ! HELP_DATA * help_list = NULL; /* the linked list of help files */ char * greeting; /* the welcome greeting */ char * motd; /* the MOTD help file */ *************** *** 72,80 **** } pHelp->keyword = strdup(hFile); pHelp->text = strdup(entry); - pHelp->next = help_list; pHelp->load_time = time(NULL); ! help_list = pHelp; } } --- 72,79 ---- } pHelp->keyword = strdup(hFile); pHelp->text = strdup(entry); pHelp->load_time = time(NULL); ! add_help(pHelp); } } *************** *** 96,115 **** if ((fp = fopen("../help/help.lst", "r")) == NULL) return; ! log("Load_helps: getting all help files."); while ((hFile = fread_line(fp)) != NULL) { if ((new_help = malloc(sizeof(*new_help))) == NULL) { bug("Load_helps: Cannot allocate memory."); abort(); } new_help->keyword = strdup(hFile); new_help->text = strdup(read_help_entry(hFile)); new_help->load_time = time(NULL); ! new_help->next = help_list; ! help_list = new_help; if (compares("GREETING", new_help->keyword)) greeting = new_help->text; --- 95,122 ---- if ((fp = fopen("../help/help.lst", "r")) == NULL) return; ! log_string("Load_helps: getting all help files."); while ((hFile = fread_line(fp)) != NULL) { + char *s = read_help_entry(hFile); + + if (s == NULL) + { + bug("load_helps: Helpfile %s does not exist.", hFile); + continue; + } + if ((new_help = malloc(sizeof(*new_help))) == NULL) { bug("Load_helps: Cannot allocate memory."); abort(); } + new_help->keyword = strdup(hFile); new_help->text = strdup(read_help_entry(hFile)); new_help->load_time = time(NULL); ! add_help(new_help); if (compares("GREETING", new_help->keyword)) greeting = new_help->text; *************** *** 117,119 **** --- 124,198 ---- motd = new_help->text; } } + + void add_help(HELP_DATA *help) + { + HELP_DATA *pHelp = NULL; + HELP_DATA *prev = NULL; + bool done = FALSE; + int i; + + if (help_list == NULL) + { + help_list = help; + help->next = NULL; + } + else + { + for (pHelp = help_list; pHelp; pHelp = pHelp->next) + { + if (toupper(help->keyword[0]) > toupper(pHelp->keyword[0])) + { + prev = pHelp; + continue; + } + else if (toupper(help->keyword[0]) == toupper(pHelp->keyword[0])) + { + for (i = 0; help->keyword[i] != '\0' && pHelp->keyword[i] != '\0'; i++) + { + if (toupper(help->keyword[i]) > toupper(pHelp->keyword[i])) + { + prev = pHelp; + break; + } + + if (help->keyword[i+1] == '\0') + { + done = TRUE; + break; + } + + /* Helpfile should previous to this helpfile entry */ + if (toupper(help->keyword[i]) == toupper(pHelp->keyword[i])) + { + prev = pHelp; + break; + } + + /* less than or at the end of the word */ + if (toupper(help->keyword[i]) < toupper(pHelp->keyword[i])) + { + done = TRUE; + break; + } + } + + if (!done) + continue; + } + + break; + } + + if (prev == NULL) + { + help->next = help_list; + help_list = help; + } + else + { + help->next = prev->next; + prev->next = help; + } + } + } diff -r -N -c socketmud/src/io.c socketmud-1.4/src/io.c *** socketmud/src/io.c Wed Feb 26 11:56:10 2003 --- socketmud-1.4/src/io.c Thu May 1 23:38:05 2003 *************** *** 22,28 **** * I would never have known about the * va_ functions. */ ! void log(const char *txt, ...) { FILE *fp; char logfile[MAX_BUFFER]; --- 22,28 ---- * I would never have known about the * va_ functions. */ ! void log_string(const char *txt, ...) { FILE *fp; char logfile[MAX_BUFFER]; diff -r -N -c socketmud/src/mud.h socketmud-1.4/src/mud.h *** socketmud/src/mud.h Sat Mar 22 14:59:16 2003 --- socketmud-1.4/src/mud.h Thu May 1 23:38:24 2003 *************** *** 241,247 **** /* * io.c */ ! void log ( const char *txt, ... ); void bug ( const char *txt, ... ); time_t last_modified ( char *helpfile ); char *read_help_entry ( const char *helpfile ); /* pointer */ --- 241,247 ---- /* * io.c */ ! void log_string ( const char *txt, ... ); void bug ( const char *txt, ... ); time_t last_modified ( char *helpfile ); char *read_help_entry ( const char *helpfile ); /* pointer */ *************** *** 273,278 **** --- 273,279 ---- */ bool check_help ( D_M *dMob, char *helpfile ); void load_helps ( void ); + void add_help ( HELP_DATA *help ); /* * utils.c diff -r -N -c socketmud/src/socket.c socketmud-1.4/src/socket.c *** socketmud/src/socket.c Wed Apr 2 10:11:59 2003 --- socketmud-1.4/src/socket.c Thu May 1 23:38:05 2003 *************** *** 52,58 **** current_time = time(NULL); /* note that we are booting up */ ! log("Program starting."); if (argv[1] && argv[1][0]) { --- 52,58 ---- current_time = time(NULL); /* note that we are booting up */ ! log_string("Program starting."); if (argv[1] && argv[1][0]) { *************** *** 75,81 **** close(control); /* terminated without errors */ ! log("Program terminated without errors."); return 0; } --- 75,81 ---- close(control); /* terminated without errors */ ! log_string("Program terminated without errors."); return 0; } *************** *** 380,386 **** else if (dsock->player) { dsock->player->socket = NULL; ! log("Closing link to %s", dsock->player->name); } } else if (dsock->player) --- 380,386 ---- else if (dsock->player) { dsock->player->socket = NULL; ! log_string("Closing link to %s", dsock->player->name); } } else if (dsock->player) *************** *** 427,433 **** } else if (sInput == 0) { ! log("Read_from_socket: EOF"); return FALSE; } else if (errno == EAGAIN || sInput == wanted) --- 427,433 ---- } else if (sInput == 0) { ! log_string("Read_from_socket: EOF"); return FALSE; } else if (errno == EAGAIN || sInput == wanted) *************** *** 560,566 **** if (length >= MAX_BUFFER) { ! log("text_to_buffer: buffer overflow."); return; } --- 560,566 ---- if (length >= MAX_BUFFER) { ! log_string("text_to_buffer: buffer overflow."); return; } *************** *** 872,878 **** break; } arg[0] = toupper(arg[0]); ! log("%s is trying to connect.", arg); /* Check for a new Player */ if ((p_new = load_profile(arg)) == NULL) --- 872,878 ---- break; } arg[0] = toupper(arg[0]); ! log_string("%s is trying to connect.", arg); /* Check for a new Player */ if ((p_new = load_profile(arg)) == NULL) *************** *** 940,946 **** dsock->player->next = dmobile_list; dmobile_list = dsock->player; ! log("New player: %s has entered the game.", dsock->player->name); /* and into the game */ dsock->state = STATE_PLAYING; --- 940,946 ---- dsock->player->next = dmobile_list; dmobile_list = dsock->player; ! log_string("New player: %s has entered the game.", dsock->player->name); /* and into the game */ dsock->state = STATE_PLAYING; *************** *** 964,970 **** dsock->player = p_new; p_new->socket = dsock; ! log("%s has reconnected.", dsock->player->name); /* and let him enter the game */ dsock->state = STATE_PLAYING; --- 964,970 ---- dsock->player = p_new; p_new->socket = dsock; ! log_string("%s has reconnected.", dsock->player->name); /* and let him enter the game */ dsock->state = STATE_PLAYING; *************** *** 989,995 **** p_new->next = dmobile_list; dmobile_list = p_new; ! log("%s has entered the game.", dsock->player->name); /* and let him enter the game */ dsock->state = STATE_PLAYING; --- 989,995 ---- p_new->next = dmobile_list; dmobile_list = p_new; ! log_string("%s has entered the game.", dsock->player->name); /* and let him enter the game */ dsock->state = STATE_PLAYING; diff -r -N -c socketmud/src/utils.c socketmud-1.4/src/utils.c *** socketmud/src/utils.c Mon Mar 24 21:58:42 2003 --- socketmud-1.4/src/utils.c Thu May 1 23:38:05 2003 *************** *** 151,161 **** char host[MAX_BUFFER]; int desc; ! log("Copyover recovery initiated"); if ((fp = fopen(COPYOVER_FILE, "r")) == NULL) { ! log("Copyover file not found. Exitting."); exit (1); } --- 151,161 ---- char host[MAX_BUFFER]; int desc; ! log_string("Copyover recovery initiated"); if ((fp = fopen(COPYOVER_FILE, "r")) == NULL) { ! log_string("Copyover file not found. Exitting."); exit (1); }