--- deliantra/server/common/readable.C 2008/05/06 16:55:25 1.34 +++ deliantra/server/common/readable.C 2008/08/31 05:47:14 1.35 @@ -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 (); + } - 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); - default: - LOG (llevError, "change_book_name() called w/ illegal obj type.\n"); - return; + 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; } } @@ -1892,7 +1890,6 @@ /* lets give the "book" a new name, which may be a compound word */ change_book (book, msg_type); } - }