ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/readable.C
(Generate patch)

Comparing deliantra/server/common/readable.C (file contents):
Revision 1.51 by root, Fri Nov 6 13:03:34 2009 UTC vs.
Revision 1.54 by root, Sun Nov 29 10:55:18 2009 UTC

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
111static int nrofmon = 0, need_to_write_bookarchive = 0; 111static 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 */
116static int nrofmsg = 0;
117
118/* first_msg is the started of the linked list of messages as read from
119 * the messages file
120 */
121static linked_char *first_msg = NULL;
122
123/* 113/*
124 * Spellpath information 114 * Spellpath information
125 */ 115 */
126
127static uint32 spellpathdef[NRSPELLPATHS] = { 116static uint32 spellpathdef[NRSPELLPATHS] = {
128 PATH_PROT, 117 PATH_PROT,
129 PATH_FIRE, 118 PATH_FIRE,
130 PATH_FROST, 119 PATH_FROST,
131 PATH_ELEC, 120 PATH_ELEC,
515 * Start of misc. readable functions used by others functions in this file 504 * Start of misc. readable functions used by others functions in this file
516 * 505 *
517 *****************************************************************************/ 506 *****************************************************************************/
518 507
519static titlelist * 508static titlelist *
520get_empty_booklist (void) 509get_empty_booklist ()
521{ 510{
522 titlelist *bl = new titlelist; 511 titlelist *bl = new titlelist;
523 512
524 bl->number = 0; 513 bl->number = 0;
525 bl->first_book = NULL; 514 bl->first_book = NULL;
526 bl->next = NULL; 515 bl->next = NULL;
527 return bl; 516 return bl;
528} 517}
529 518
530static title * 519static title *
531get_empty_book (void) 520get_empty_book ()
532{ 521{
533 title *t = new title; 522 title *t = new title;
534 523
535 t->name = NULL; 524 t->name = NULL;
536 t->archname = NULL; 525 t->archname = NULL;
619 tbuf = strtok (NULL, sbuf); 608 tbuf = strtok (NULL, sbuf);
620 } 609 }
621 return (char *) rbuf; 610 return (char *) rbuf;
622} 611}
623 612
624static int
625book_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}
633
634/***************************************************************************** 613/*****************************************************************************
635 * 614 *
636 * Start of initialisation related functions. 615 * Start of initialisation related functions.
637 * 616 *
638 ****************************************************************************/ 617 ****************************************************************************/
640/* init_book_archive() - if not called before, initialise the info list 619/* init_book_archive() - if not called before, initialise the info list
641 * This reads in the bookarch file into memory. bookarch is the file 620 * This reads in the bookarch file into memory. bookarch is the file
642 * created and updated across multiple runs of the program. 621 * created and updated across multiple runs of the program.
643 */ 622 */
644static void 623static void
645init_book_archive (void) 624init_book_archive ()
646{ 625{
647 FILE *fp; 626 FILE *fp;
648 int comp, nroftitle = 0; 627 int comp, nroftitle = 0;
649 char buf[MAX_BUF], fname[MAX_BUF], *cp; 628 char buf[MAX_BUF], fname[MAX_BUF], *cp;
650 title *book = NULL; 629 title *book = NULL;
765 * 744 *
766 * This is the function called by the main routine to initialise 745 * This is the function called by the main routine to initialise
767 * all the readable information. 746 * all the readable information.
768 */ 747 */
769void 748void
770init_readable (void) 749init_readable ()
771{ 750{
772 static int did_this; 751 static int did_this;
773 752
774 if (did_this) 753 if (did_this)
775 return; 754 return;
1817 } 1796 }
1818} 1797}
1819 1798
1820/***************************************************************************** 1799/*****************************************************************************
1821 * 1800 *
1822 * Cleanup routine for readble stuff.
1823 *
1824 *****************************************************************************/
1825static void
1826free_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. 1801 * Writeback routine for updating the bookarchive.
1864 * 1802 *
1865 ****************************************************************************/ 1803 ****************************************************************************/
1866/* write_book_archive() - write out the updated book archive */ 1804/* write_book_archive() - write out the updated book archive */
1867void 1805void
1868write_book_archive (void) 1806write_book_archive ()
1869{ 1807{
1870 FILE *fp; 1808 FILE *fp;
1871 int index = 0; 1809 int index = 0;
1872 char fname[MAX_BUF]; 1810 char fname[MAX_BUF];
1873 title *book = NULL; 1811 title *book = NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines