--- deliantra/server/common/readable.C 2007/05/17 21:32:08 1.23 +++ deliantra/server/common/readable.C 2007/05/24 03:33:28 1.24 @@ -643,79 +643,10 @@ * ****************************************************************************/ -/* init_msgfile() - if not called before, initialise the info list - * reads the messages file into the list pointed to by first_msg -*/ - -static void -init_msgfile (void) -{ - FILE *fp; - char buf[MAX_BUF], msgbuf[HUGE_BUF], fname[MAX_BUF], *cp; - int comp; - static int did_init_msgfile; - - if (did_init_msgfile) - return; - did_init_msgfile = 1; - - sprintf (fname, "%s/messages", settings.datadir); - LOG (llevDebug, "Reading messages from %s...\n", fname); - - if ((fp = open_and_uncompress (fname, 0, &comp)) != NULL) - { - linked_char *tmp = NULL; - - while (fgets (buf, MAX_BUF, fp) != NULL) - { - if (*buf == '#') - continue; - if ((cp = strchr (buf, '\n')) != NULL) - *cp = '\0'; - cp = buf; - while (*cp == ' ') /* Skip blanks */ - cp++; - if (!strncmp (cp, "ENDMSG", 6)) - { - if (strlen (msgbuf) > BOOK_BUF) - { - LOG (llevDebug, "Warning: this string exceeded max book buf size:"); - LOG (llevDebug, " %s\n", msgbuf); - } - tmp->name = msgbuf; - tmp->next = first_msg; - first_msg = tmp; - nrofmsg++; - continue; - } - else if (!strncmp (cp, "MSG", 3)) - { - tmp = new linked_char; - - strcpy (msgbuf, " "); /* reset msgbuf for new message */ - continue; - } - else if (!buf_overflow (msgbuf, cp, HUGE_BUF - 1)) - { - strcat (msgbuf, cp); - strcat (msgbuf, "\n"); - } - } - close_and_delete (fp, comp); - } - -#ifdef BOOK_MSG_DEBUG - LOG (llevDebug, "init_info_listfile() got %d messages.\n", nrofmsg); -#endif - LOG (llevDebug, "done.\n"); -} - - /* init_book_archive() - if not called before, initialise the info list * This reads in the bookarch file into memory. bookarch is the file * created and updated across multiple runs of the program. */ - static void init_book_archive (void) { @@ -837,14 +768,12 @@ LOG (llevDebug, "init_mon_info() got %d monsters\n", nrofmon); } - /* init_readable() - initialise linked lists utilized by * message functions in tailor_readable_ob() * * This is the function called by the main routine to initialise * all the readable information. */ - void init_readable (void) { @@ -856,11 +785,9 @@ did_this = 1; LOG (llevDebug, "Initialising reading data...\n"); - init_msgfile (); init_book_archive (); init_mon_info (); LOG (llevDebug, " Done\n"); - } /***************************************************************************** @@ -870,11 +797,9 @@ * *****************************************************************************/ - /* find_title() - Search the titlelist (based on msgtype) to see if * book matches something already there. IF so, return that title. */ - static title * find_title (const object *book, int msgtype) { @@ -1557,12 +1482,9 @@ return retbuf; } - - /* formula_msg() - generate a message detailing the properties * of a randomly selected alchemical formula. */ - void make_formula_book (object *book, int level) { @@ -1674,41 +1596,6 @@ } } - -/* msgfile_msg() - generate a message drawn randomly from a - * file in lib/. Level currently has no effect on the message - * which is returned. - */ - -char * -msgfile_msg (int level, int booksize) -{ - static char retbuf[BOOK_BUF]; - int i, msgnum; - linked_char *msg = NULL; - - /* get a random message for the 'book' from linked list */ - if (nrofmsg > 1) - { - msg = first_msg; - msgnum = RANDOM () % nrofmsg; - for (i = 0; msg && i < nrofmsg && i != msgnum; i++) - msg = msg->next; - } - - if (msg && !book_overflow (retbuf, msg->name, booksize)) - assign (retbuf, msg->name); - else - sprintf (retbuf, "\n "); - -#ifdef BOOK_MSG_DEBUG - LOG (llevDebug, "\n info_list_msg() created strng: %d\n", strlen (retbuf)); - LOG (llevDebug, " MADE THIS:\n%s\n", retbuf); -#endif - - return retbuf; -} - /* god_info_msg() - generate a message detailing the properties * of a random god. Used by the book hack. b.t. */ @@ -1932,7 +1819,6 @@ * message type - otherwise a random value is used. * */ - void tailor_readable_ob (object *book, int msg_type) { @@ -1965,27 +1851,27 @@ msg_type = msg_type > 0 ? msg_type : (RANDOM () % 6); switch (msg_type) { - case 1: /* monster attrib */ - strcpy (msgbuf, mon_info_msg (level, book_buf_size)); - break; - case 2: /* artifact attrib */ - strcpy (msgbuf, artifact_msg (level, book_buf_size)); - break; - case 3: /* grouping incantations/prayers by path */ - strcpy (msgbuf, spellpath_msg (level, book_buf_size)); - break; - case 4: /* describe an alchemy formula */ - make_formula_book (book, level); - /* make_formula_book already gives title */ - return; - break; - case 5: /* bits of information about a god */ - strcpy (msgbuf, god_info_msg (level, book_buf_size)); - break; - case 0: /* use info list in lib/ */ - default: - strcpy (msgbuf, msgfile_msg (level, book_buf_size)); - break; + case 1: /* monster attrib */ + strcpy (msgbuf, mon_info_msg (level, book_buf_size)); + break; + case 2: /* artifact attrib */ + strcpy (msgbuf, artifact_msg (level, book_buf_size)); + break; + case 3: /* grouping incantations/prayers by path */ + strcpy (msgbuf, spellpath_msg (level, book_buf_size)); + break; + case 4: /* describe an alchemy formula */ + make_formula_book (book, level); + /* make_formula_book already gives title */ + return; + break; + case 5: /* bits of information about a god */ + strcpy (msgbuf, god_info_msg (level, book_buf_size)); + break; + case 0: /* use info list in lib/ */ + default: + cfperl_make_book (book, level); + return; } strcat (msgbuf, "\n"); /* safety -- we get ugly map saves/crashes w/o this */