--- deliantra/server/common/readable.C 2007/05/17 21:32:08 1.23 +++ deliantra/server/common/readable.C 2007/06/04 12:19:08 1.26 @@ -1,28 +1,27 @@ /* - * CrossFire, A Multiplayer game + * This file is part of Crossfire TRT, the Multiplayer Online Role Playing Game. * - * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team - * Copyright (C) 2002 Mark Wedel & Crossfire Development Team - * Copyright (C) 1992 Frank Tore Johansen + * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team + * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992,2007 Frank Tore Johansen * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Crossfire TRT is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * The authors can be reached via e-mail at + * You should have received a copy of the GNU General Public License along + * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51 + * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * The authors can be reached via e-mail to */ - /* This file contains code relevant to the BOOKS hack -- designed * to allow randomly occuring messages in non-magical texts. */ @@ -643,79 +642,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 +767,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 +784,9 @@ did_this = 1; LOG (llevDebug, "Initialising reading data...\n"); - init_msgfile (); init_book_archive (); init_mon_info (); LOG (llevDebug, " Done\n"); - } /***************************************************************************** @@ -870,11 +796,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) { @@ -1047,7 +971,7 @@ t->authour = book->title; t->size = strlen (book->msg); t->msg_index = strtoint (book->msg); - t->archname = book->arch->name; + t->archname = book->arch->archname; t->level = book->level; t->next = tl->first_book; @@ -1557,12 +1481,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 +1595,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 +1818,6 @@ * message type - otherwise a random value is used. * */ - void tailor_readable_ob (object *book, int msg_type) { @@ -1965,27 +1850,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 */