… | |
… | |
108 | /* these are needed for creation of a linked list of |
108 | /* these are needed for creation of a linked list of |
109 | * pointers to all (hostile) monster objects */ |
109 | * pointers to all (hostile) monster objects */ |
110 | |
110 | |
111 | static int nrofmon = 0, need_to_write_bookarchive = 0; |
111 | static int nrofmon = 0, need_to_write_bookarchive = 0; |
112 | |
112 | |
113 | |
|
|
114 | /* this is needed to keep track of status of initialisation |
|
|
115 | * of the message file */ |
|
|
116 | static int nrofmsg = 0; |
|
|
117 | |
|
|
118 | /* first_msg is the started of the linked list of messages as read from |
113 | /* first_msg is the started of the linked list of messages as read from |
119 | * the messages file |
114 | * the messages file |
120 | */ |
115 | */ |
121 | static linked_char *first_msg = NULL; |
116 | static linked_char *first_msg = NULL; |
122 | |
117 | |
123 | /* |
118 | /* |
124 | * Spellpath information |
119 | * Spellpath information |
125 | */ |
120 | */ |
126 | |
|
|
127 | static uint32 spellpathdef[NRSPELLPATHS] = { |
121 | static uint32 spellpathdef[NRSPELLPATHS] = { |
128 | PATH_PROT, |
122 | PATH_PROT, |
129 | PATH_FIRE, |
123 | PATH_FIRE, |
130 | PATH_FROST, |
124 | PATH_FROST, |
131 | PATH_ELEC, |
125 | PATH_ELEC, |
… | |
… | |
617 | else |
611 | else |
618 | strcat (rbuf, "."); |
612 | strcat (rbuf, "."); |
619 | tbuf = strtok (NULL, sbuf); |
613 | tbuf = strtok (NULL, sbuf); |
620 | } |
614 | } |
621 | return (char *) rbuf; |
615 | return (char *) rbuf; |
622 | } |
|
|
623 | |
|
|
624 | static int |
|
|
625 | book_overflow (const char *buf1, const char *buf2, int booksize) |
|
|
626 | { |
|
|
627 | if (buf_overflow (buf1, buf2, BOOK_BUF - 2) /* 2 less so always room for trailing \n */ |
|
|
628 | || buf_overflow (buf1, buf2, booksize)) |
|
|
629 | return 1; |
|
|
630 | |
|
|
631 | return 0; |
|
|
632 | } |
616 | } |
633 | |
617 | |
634 | /***************************************************************************** |
618 | /***************************************************************************** |
635 | * |
619 | * |
636 | * Start of initialisation related functions. |
620 | * Start of initialisation related functions. |
… | |
… | |
1817 | } |
1801 | } |
1818 | } |
1802 | } |
1819 | |
1803 | |
1820 | /***************************************************************************** |
1804 | /***************************************************************************** |
1821 | * |
1805 | * |
1822 | * Cleanup routine for readble stuff. |
|
|
1823 | * |
|
|
1824 | *****************************************************************************/ |
|
|
1825 | static void |
|
|
1826 | free_all_readable (void) |
|
|
1827 | { |
|
|
1828 | titlelist *tlist, *tnext; |
|
|
1829 | title *title1, *titlenext; |
|
|
1830 | linked_char *lmsg, *nextmsg; |
|
|
1831 | objectlink *monlink, *nextmon; |
|
|
1832 | |
|
|
1833 | LOG (llevDebug, "freeing all book information\n"); |
|
|
1834 | |
|
|
1835 | for (tlist = booklist; tlist; tlist = tnext) |
|
|
1836 | { |
|
|
1837 | tnext = tlist->next; |
|
|
1838 | |
|
|
1839 | for (title1 = tlist->first_book; title1; title1 = titlenext) |
|
|
1840 | { |
|
|
1841 | titlenext = title1->next; |
|
|
1842 | delete title1; |
|
|
1843 | } |
|
|
1844 | |
|
|
1845 | delete tlist; |
|
|
1846 | } |
|
|
1847 | |
|
|
1848 | for (lmsg = first_msg; lmsg; lmsg = nextmsg) |
|
|
1849 | { |
|
|
1850 | nextmsg = lmsg->next; |
|
|
1851 | delete lmsg; |
|
|
1852 | } |
|
|
1853 | |
|
|
1854 | for (monlink = first_mon_info; monlink; monlink = nextmon) |
|
|
1855 | { |
|
|
1856 | nextmon = monlink->next; |
|
|
1857 | delete monlink; |
|
|
1858 | } |
|
|
1859 | } |
|
|
1860 | |
|
|
1861 | /***************************************************************************** |
|
|
1862 | * |
|
|
1863 | * Writeback routine for updating the bookarchive. |
1806 | * Writeback routine for updating the bookarchive. |
1864 | * |
1807 | * |
1865 | ****************************************************************************/ |
1808 | ****************************************************************************/ |
1866 | /* write_book_archive() - write out the updated book archive */ |
1809 | /* write_book_archive() - write out the updated book archive */ |
1867 | void |
1810 | void |