… | |
… | |
657 | if (did_init_msgfile) |
657 | if (did_init_msgfile) |
658 | return; |
658 | return; |
659 | did_init_msgfile = 1; |
659 | did_init_msgfile = 1; |
660 | |
660 | |
661 | sprintf (fname, "%s/messages", settings.datadir); |
661 | sprintf (fname, "%s/messages", settings.datadir); |
662 | LOG (llevDebug, "Reading messages from %s...", fname); |
662 | LOG (llevDebug, "Reading messages from %s...\n", fname); |
663 | |
663 | |
664 | if ((fp = open_and_uncompress (fname, 0, &comp)) != NULL) |
664 | if ((fp = open_and_uncompress (fname, 0, &comp)) != NULL) |
665 | { |
665 | { |
666 | linked_char *tmp = NULL; |
666 | linked_char *tmp = NULL; |
667 | |
667 | |
… | |
… | |
677 | if (!strncmp (cp, "ENDMSG", 6)) |
677 | if (!strncmp (cp, "ENDMSG", 6)) |
678 | { |
678 | { |
679 | if (strlen (msgbuf) > BOOK_BUF) |
679 | if (strlen (msgbuf) > BOOK_BUF) |
680 | { |
680 | { |
681 | LOG (llevDebug, "Warning: this string exceeded max book buf size:"); |
681 | LOG (llevDebug, "Warning: this string exceeded max book buf size:"); |
682 | LOG (llevDebug, " %s", msgbuf); |
682 | LOG (llevDebug, " %s\n", msgbuf); |
683 | } |
683 | } |
684 | tmp->name = msgbuf; |
684 | tmp->name = msgbuf; |
685 | tmp->next = first_msg; |
685 | tmp->next = first_msg; |
686 | first_msg = tmp; |
686 | first_msg = tmp; |
687 | nrofmsg++; |
687 | nrofmsg++; |
… | |
… | |
702 | } |
702 | } |
703 | close_and_delete (fp, comp); |
703 | close_and_delete (fp, comp); |
704 | } |
704 | } |
705 | |
705 | |
706 | #ifdef BOOK_MSG_DEBUG |
706 | #ifdef BOOK_MSG_DEBUG |
707 | LOG (llevDebug, "\ninit_info_listfile() got %d messages.\n", nrofmsg); |
707 | LOG (llevDebug, "init_info_listfile() got %d messages.\n", nrofmsg); |
708 | #endif |
708 | #endif |
709 | LOG (llevDebug, "done.\n"); |
709 | LOG (llevDebug, "done.\n"); |
710 | } |
710 | } |
711 | |
711 | |
712 | |
712 | |
… | |
… | |
788 | book->next = bl->first_book; |
788 | book->next = bl->first_book; |
789 | bl->first_book = book; |
789 | bl->first_book = book; |
790 | bl->number++; |
790 | bl->number++; |
791 | } |
791 | } |
792 | } |
792 | } |
793 | LOG (llevDebug, " book archives(used/avail): "); |
793 | LOG (llevDebug, "book archives(used/avail): \n"); |
794 | for (bl = booklist, i = 0; bl != NULL && i < sizeof (max_titles) / sizeof (*max_titles); bl = bl->next, i++) |
794 | for (bl = booklist, i = 0; bl != NULL && i < sizeof (max_titles) / sizeof (*max_titles); bl = bl->next, i++) |
795 | { |
795 | { |
796 | LOG (llevDebug, "(%d/%d)", bl->number, max_titles[i]); |
796 | LOG (llevDebug, "(%d/%d)", bl->number, max_titles[i]); |
797 | } |
797 | } |
798 | LOG (llevDebug, "\n"); |
798 | LOG (llevDebug, "\n"); |
… | |
… | |
853 | if (did_this) |
853 | if (did_this) |
854 | return; |
854 | return; |
855 | |
855 | |
856 | did_this = 1; |
856 | did_this = 1; |
857 | |
857 | |
858 | LOG (llevDebug, "Initializing reading data..."); |
858 | LOG (llevDebug, "Initialising reading data...\n"); |
859 | init_msgfile (); |
859 | init_msgfile (); |
860 | init_book_archive (); |
860 | init_book_archive (); |
861 | init_mon_info (); |
861 | init_mon_info (); |
862 | LOG (llevDebug, " Done\n"); |
862 | LOG (llevDebug, " Done\n"); |
863 | |
863 | |
… | |
… | |
1099 | |
1099 | |
1100 | /* alter book properties */ |
1100 | /* alter book properties */ |
1101 | if ((tmpbook = get_archetype (t->archname)) != NULL) |
1101 | if ((tmpbook = get_archetype (t->archname)) != NULL) |
1102 | { |
1102 | { |
1103 | tmpbook->msg = book->msg; |
1103 | tmpbook->msg = book->msg; |
1104 | copy_object (tmpbook, book); |
1104 | tmpbook->copy_to (book); |
1105 | tmpbook->destroy (0); |
1105 | tmpbook->destroy (); |
1106 | } |
1106 | } |
1107 | |
1107 | |
1108 | book->title = t->authour; |
1108 | book->title = t->authour; |
1109 | book->name = t->name; |
1109 | book->name = t->name; |
1110 | book->level = t->level; |
1110 | book->level = t->level; |
… | |
… | |
1467 | * level is kinda high */ |
1467 | * level is kinda high */ |
1468 | if (art->item->msg && (RANDOM () % 4 + 1) < level && !((strlen (art->item->msg) + strlen (buf)) > BOOK_BUF)) |
1468 | if (art->item->msg && (RANDOM () % 4 + 1) < level && !((strlen (art->item->msg) + strlen (buf)) > BOOK_BUF)) |
1469 | strcat (buf, art->item->msg); |
1469 | strcat (buf, art->item->msg); |
1470 | |
1470 | |
1471 | /* properties of the artifact */ |
1471 | /* properties of the artifact */ |
1472 | tmp = get_object (); |
1472 | tmp = object::create (); |
1473 | add_abilities (tmp, art->item); |
1473 | add_abilities (tmp, art->item); |
1474 | tmp->type = type; |
1474 | tmp->type = type; |
1475 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1475 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
1476 | if ((ch = describe_item (tmp, NULL)) != NULL && strlen (ch) > 1) |
1476 | if ((ch = describe_item (tmp, NULL)) != NULL && strlen (ch) > 1) |
1477 | sprintf (buf, "%s Properties of this artifact include: \n %s \n", buf, ch); |
1477 | sprintf (buf, "%s Properties of this artifact include: \n %s \n", buf, ch); |
1478 | tmp->destroy (0); |
1478 | tmp->destroy (); |
1479 | /* add the buf if it will fit */ |
1479 | /* add the buf if it will fit */ |
1480 | if (!book_overflow (retbuf, buf, booksize)) |
1480 | if (!book_overflow (retbuf, buf, booksize)) |
1481 | strcat (retbuf, buf); |
1481 | strcat (retbuf, buf); |
1482 | else |
1482 | else |
1483 | break; |
1483 | break; |