1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_readable_c = |
|
|
4 | * "$Id: readable.C,v 1.5 2006/09/10 16:00:23 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
80 | /* Moved these structures from struct.h to this file in 0.94.3 - they |
74 | /* Moved these structures from struct.h to this file in 0.94.3 - they |
81 | * are not needed anyplace else, so why have them globally declared? |
75 | * are not needed anyplace else, so why have them globally declared? |
82 | */ |
76 | */ |
83 | |
77 | |
84 | /* 'title' and 'titlelist' are used by the readable code */ |
78 | /* 'title' and 'titlelist' are used by the readable code */ |
85 | typedef struct titlestruct:zero_initialised |
79 | struct title : zero_initialised |
86 | { |
80 | { |
87 | shstr name; /* the name of the book */ |
81 | shstr name; /* the name of the book */ |
88 | shstr authour; /* the name of the book authour */ |
82 | shstr authour; /* the name of the book authour */ |
89 | shstr archname; /* the archetype name of the book */ |
83 | shstr archname; /* the archetype name of the book */ |
90 | int level; /* level of difficulty of this message */ |
84 | int level; /* level of difficulty of this message */ |
91 | int size; /* size of the book message */ |
85 | int size; /* size of the book message */ |
92 | int msg_index; /* an index value derived from book message */ |
86 | int msg_index; /* an index value derived from book message */ |
93 | struct titlestruct *next; |
87 | title *next; |
94 | } title; |
88 | }; |
95 | |
89 | |
96 | typedef struct titleliststruct:zero_initialised |
90 | struct titlelist : zero_initialised |
97 | { |
91 | { |
98 | int number; /* number of items in the list */ |
92 | int number; /* number of items in the list */ |
99 | struct titlestruct *first_book; /* pointer to first book in this list */ |
93 | title *first_book; /* pointer to first book in this list */ |
100 | struct titleliststruct *next; /* pointer to next book list */ |
94 | titlelist *next; /* pointer to next book list */ |
101 | } titlelist; |
95 | }; |
102 | |
96 | |
103 | /* special structure, used only by art_name_array[] */ |
97 | /* special structure, used only by art_name_array[] */ |
104 | |
98 | struct arttypename |
105 | typedef struct namebytype |
|
|
106 | { |
99 | { |
107 | const char *name; /* generic name to call artifacts of this type */ |
100 | const char *name; /* generic name to call artifacts of this type */ |
108 | int type; /* matching type */ |
101 | int type; /* matching type */ |
109 | } |
102 | }; |
110 | arttypename; |
|
|
111 | |
|
|
112 | |
103 | |
113 | /* booklist is the buffer of books read in from the bookarch file */ |
104 | /* booklist is the buffer of books read in from the bookarch file */ |
114 | static titlelist *booklist = NULL; |
105 | static titlelist *booklist = NULL; |
115 | |
106 | |
116 | static objectlink *first_mon_info = NULL; |
107 | static objectlink *first_mon_info = NULL; |
… | |
… | |
565 | |
556 | |
566 | while (tl && number) |
557 | while (tl && number) |
567 | { |
558 | { |
568 | if (!tl->next) |
559 | if (!tl->next) |
569 | tl->next = get_empty_booklist (); |
560 | tl->next = get_empty_booklist (); |
|
|
561 | |
570 | tl = tl->next; |
562 | tl = tl->next; |
571 | number--; |
563 | number--; |
572 | } |
564 | } |
573 | |
565 | |
574 | return tl; |
566 | return tl; |
… | |
… | |
733 | titlelist *bl = get_empty_booklist (); |
725 | titlelist *bl = get_empty_booklist (); |
734 | static int did_init_barch; |
726 | static int did_init_barch; |
735 | |
727 | |
736 | if (did_init_barch) |
728 | if (did_init_barch) |
737 | return; |
729 | return; |
|
|
730 | |
738 | did_init_barch = 1; |
731 | did_init_barch = 1; |
739 | |
732 | |
740 | if (!booklist) |
733 | if (!booklist) |
741 | booklist = bl; |
734 | booklist = bl; |
742 | |
735 | |
… | |
… | |
891 | if (msgtype < 0) |
884 | if (msgtype < 0) |
892 | return (title *) NULL; |
885 | return (title *) NULL; |
893 | |
886 | |
894 | if (tl) |
887 | if (tl) |
895 | t = tl->first_book; |
888 | t = tl->first_book; |
|
|
889 | |
896 | while (t) |
890 | while (t) |
897 | if (t->size == length && t->msg_index == index) |
891 | if (t->size == length && t->msg_index == index) |
898 | break; |
892 | break; |
899 | else |
893 | else |
900 | t = t->next; |
894 | t = t->next; |
… | |
… | |
1617 | archetype *at; |
1611 | archetype *at; |
1618 | |
1612 | |
1619 | /* preamble */ |
1613 | /* preamble */ |
1620 | sprintf (retbuf, "Herein is described a project using %s: \n", formula->skill ? &formula->skill : "an unknown skill"); |
1614 | sprintf (retbuf, "Herein is described a project using %s: \n", formula->skill ? &formula->skill : "an unknown skill"); |
1621 | |
1615 | |
1622 | if ((at = find_archetype (op_name)) != (archetype *) NULL) |
1616 | if ((at = archetype::find (op_name)) != (archetype *) NULL) |
1623 | op_name = at->clone.name; |
1617 | op_name = at->clone.name; |
1624 | else |
1618 | else |
1625 | LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name); |
1619 | LOG (llevError, "formula_msg() can't find arch %s for formula.\n", op_name); |
1626 | |
1620 | |
1627 | /* item name */ |
1621 | /* item name */ |
… | |
… | |
1656 | if (formula->ingred != NULL) |
1650 | if (formula->ingred != NULL) |
1657 | { |
1651 | { |
1658 | linked_char *next; |
1652 | linked_char *next; |
1659 | archetype *at; |
1653 | archetype *at; |
1660 | |
1654 | |
1661 | at = find_archetype (formula->cauldron); |
1655 | at = archetype::find (formula->cauldron); |
1662 | |
1656 | |
1663 | sprintf (retbuf + strlen (retbuf), |
1657 | sprintf (retbuf + strlen (retbuf), |
1664 | " may be made at %s using the following ingredients:\n", at ? query_name (&at->clone) : "an unknown place"); |
1658 | " may be made at %s using the following ingredients:\n", at ? query_name (&at->clone) : "an unknown place"); |
1665 | |
1659 | |
1666 | for (next = formula->ingred; next != NULL; next = next->next) |
1660 | for (next = formula->ingred; next != NULL; next = next->next) |