--- deliantra/server/common/readable.C 2007/07/01 05:00:17 1.30
+++ deliantra/server/common/readable.C 2008/09/29 09:04:50 1.36
@@ -1,11 +1,11 @@
/*
- * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
+ * This file is part of Deliantra, the Roguelike Realtime MMORPG.
*
- * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
+ * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
* Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
* Copyright (©) 1992,2007 Frank Tore Johansen
*
- * Crossfire TRT is free software: you can redistribute it and/or modify
+ * Deliantra 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 3 of the License, or
* (at your option) any later version.
@@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
- * The authors can be reached via e-mail to
+ * The authors can be reached via e-mail to
*/
/* This file contains code relevant to the BOOKS hack -- designed
@@ -1003,116 +1003,114 @@
switch (book->type)
{
- case BOOK:
- {
- titlelist *tl = get_titlelist (msgtype);
- title *t = NULL;
- int tries = 0;
-
- /* look to see if our msg already been archived. If so, alter
- * the book to match the archival text. If we fail to match,
- * then we archive the new title/name/msg combo if there is
- * room on the titlelist.
- */
-
- if ((strlen (book->msg) > 5) && (t = find_title (book, msgtype)))
- {
- object *tmpbook;
+ case BOOK:
+ {
+ titlelist *tl = get_titlelist (msgtype);
+ title *t = NULL;
+ int tries = 0;
+
+ /* look to see if our msg already been archived. If so, alter
+ * the book to match the archival text. If we fail to match,
+ * then we archive the new title/name/msg combo if there is
+ * room on the titlelist.
+ */
- /* alter book properties */
- if ((tmpbook = get_archetype (t->archname)) != NULL)
- {
- tmpbook->msg = book->msg;
- tmpbook->copy_to (book);
- tmpbook->destroy ();
- }
+ if ((strlen (book->msg) > 5) && (t = find_title (book, msgtype)))
+ {
+ /* alter book properties */
+ if (object *tmpbook = get_archetype (t->archname))
+ {
+ tmpbook->msg = book->msg;
+ tmpbook->copy_to (book);
+ tmpbook->destroy (true);
+ }
- book->title = t->authour;
- book->name = t->name;
- book->level = t->level;
- }
- /* Don't have any default title, so lets make up a new one */
- else
- {
- int numb, maxnames = max_titles[msgtype];
- const char *old_title;
- const char *old_name;
-
- old_title = book->title;
- old_name = book->name;
-
- /* some pre-generated books have title already set (from
- * maps), also don't bother looking for unique title if
- * we already used up all the available names! */
+ book->title = t->authour;
+ book->name = t->name;
+ book->level = t->level;
+ }
+ /* Don't have any default title, so lets make up a new one */
+ else
+ {
+ int numb, maxnames = max_titles[msgtype];
+ const char *old_title;
+ const char *old_name;
+
+ old_title = book->title;
+ old_name = book->name;
+
+ /* some pre-generated books have title already set (from
+ * maps), also don't bother looking for unique title if
+ * we already used up all the available names! */
- if (!tl)
- {
- LOG (llevError, "change_book_name(): can't find title list\n");
- numb = 0;
- }
- else
- numb = tl->number;
+ if (!tl)
+ {
+ LOG (llevError, "change_book_name(): can't find title list\n");
+ numb = 0;
+ }
+ else
+ numb = tl->number;
- if (numb == maxnames)
- {
+ if (numb == maxnames)
+ {
#ifdef ARCHIVE_DEBUG
- LOG (llevDebug, "titles for list %d full (%d possible).\n", msgtype, maxnames);
+ LOG (llevDebug, "titles for list %d full (%d possible).\n", msgtype, maxnames);
#endif
- break;
+ break;
+ }
+ /* shouldnt change map-maker books */
+ else if (!book->title)
+ do
+ {
+ /* random book name */
+ new_text_name (book, msgtype);
+ add_author (book, msgtype); /* random author */
+ tries++;
}
- /* shouldnt change map-maker books */
- else if (!book->title)
- do
- {
- /* random book name */
- new_text_name (book, msgtype);
- add_author (book, msgtype); /* random author */
- tries++;
- }
- while (!unique_book (book, msgtype) && tries < MAX_TITLE_CHECK);
+ while (!unique_book (book, msgtype) && tries < MAX_TITLE_CHECK);
- /* Now deal with 2 cases.
- * 1)If no space for a new title exists lets just restore
- * the old book properties. Remember, if the book had
- * matchd an older entry on the titlelist, we shouldnt
- * have called this routine in the first place!
- * 2) If we got a unique title, we need to add it to
- * the list.
- */
+ /* Now deal with 2 cases.
+ * 1)If no space for a new title exists lets just restore
+ * the old book properties. Remember, if the book had
+ * matchd an older entry on the titlelist, we shouldnt
+ * have called this routine in the first place!
+ * 2) If we got a unique title, we need to add it to
+ * the list.
+ */
- if (tries == MAX_TITLE_CHECK || numb == maxnames)
- { /* got to check maxnames again */
+ if (tries == MAX_TITLE_CHECK || numb == maxnames)
+ { /* got to check maxnames again */
#ifdef ARCHIVE_DEBUG
- LOG (llevDebug, "Failed to obtain unique title for %s %s (names:%d/%d)\n", book->name, book->title, numb, maxnames);
+ LOG (llevDebug, "Failed to obtain unique title for %s %s (names:%d/%d)\n", book->name, book->title, numb, maxnames);
#endif
- /* restore old book properties here */
- book->title = old_title;
+ /* restore old book properties here */
+ book->title = old_title;
- if (RANDOM () % 4)
- {
- /* Lets give the book a description to individualize it some */
- char new_name[MAX_BUF];
-
- snprintf (new_name, MAX_BUF, "%s %s", book_descrpt[rndm (nbr)], old_name);
-
- book->name = new_name;
- }
- else
- {
- book->name = old_name;
- }
- }
- else if (book->title && strlen (book->msg) > 5)
- { /* archive if long msg texts */
- add_book_to_list (book, msgtype);
- }
- }
- break;
- }
+ if (RANDOM () % 4)
+ {
+ /* Lets give the book a description to individualize it some */
+ char new_name[MAX_BUF];
+
+ snprintf (new_name, MAX_BUF, "%s %s", book_descrpt[rndm (nbr)], old_name);
+
+ book->name = new_name;
+ }
+ else
+ {
+ book->name = old_name;
+ }
+ }
+ else if (book->title && strlen (book->msg) > 5)
+ { /* archive if long msg texts */
+ add_book_to_list (book, msgtype);
+ }
+ }
+ break;
+ }
- default:
- LOG (llevError, "change_book_name() called w/ illegal obj type.\n");
- return;
+ default:
+ LOG (llevError, "change_book_name() called w/ illegal obj type.\n");
+ return;
}
}
@@ -1397,7 +1395,7 @@
SET_FLAG (tmp, FLAG_IDENTIFIED);
if ((ch = describe_item (tmp, NULL)) != NULL && strlen (ch) > 1)
sprintf (buf, "%s Properties of this artifact include: \n %s \n", buf, ch);
- tmp->destroy ();
+ tmp->destroy (true);
/* add the buf if it will fit */
if (!book_overflow (retbuf, buf, booksize))
strcat (retbuf, buf);
@@ -1593,6 +1591,21 @@
}
}
+#define DESCRIBE_PATH(retbuf, variable, name) \
+ if(variable) { \
+ int i,j=0; \
+ strcat(retbuf,"(" name ": "); \
+ for(i=0; i 0)
{
sprintf (buf, " ");
@@ -1844,8 +1856,7 @@
* and add_authour().
* 4) you may want separate authour/book name arrays in read.h
*/
-
- msg_type = msg_type > 0 ? msg_type : (RANDOM () % 6);
+ msg_type = msg_type > 0 ? msg_type : (RANDOM () % 8);
switch (msg_type)
{
case 1: /* monster attrib */
@@ -1879,7 +1890,6 @@
/* lets give the "book" a new name, which may be a compound word */
change_book (book, msg_type);
}
-
}