1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | |
7 | * |
8 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. |
11 | * (at your option) any later version. |
12 | |
12 | * |
13 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | |
17 | * |
18 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
21 | * |
22 | The authors can be reached via e-mail to crossfire@schmorp.de |
22 | * The authors can be reached via e-mail to crossfire@schmorp.de |
23 | */ |
23 | */ |
24 | |
24 | |
25 | |
25 | |
26 | #define LL_IGNORED -1 |
26 | #define LL_IGNORED -1 |
27 | #define LL_EOF 0 |
27 | #define LL_EOF 0 |
28 | #define LL_MORE 1 |
28 | #define LL_MORE 1 |
29 | #define LL_NORMAL 2 |
29 | #define LL_NORMAL 2 |
30 | |
30 | |
31 | extern int nrofpixmaps; |
31 | extern int nrofpixmaps; |
|
|
32 | |
|
|
33 | // resource loader pure base class |
|
|
34 | struct loader_base |
|
|
35 | { |
|
|
36 | const char *filename; |
|
|
37 | |
|
|
38 | virtual archetype *get_arch (const char *name); |
|
|
39 | virtual void put_arch (archetype *arch); |
|
|
40 | |
|
|
41 | virtual object *get_object (const char *name); |
|
|
42 | virtual void put_object (object *op); |
|
|
43 | |
|
|
44 | virtual player *get_player (); |
|
|
45 | virtual void put_player (player *pl); |
|
|
46 | |
|
|
47 | virtual region *get_region (const char *name); |
|
|
48 | virtual void put_region (region *rgn); |
|
|
49 | |
|
|
50 | virtual facetile *get_face (const char *name); |
|
|
51 | virtual void put_face (facetile *face); |
|
|
52 | |
|
|
53 | virtual treasurelist *get_treasure (const char *name, bool one = false); |
|
|
54 | virtual void put_treasure (treasurelist *treasure); |
|
|
55 | |
|
|
56 | virtual animation *get_animation (const char *name); |
|
|
57 | virtual void put_animation (animation *anim); |
|
|
58 | |
|
|
59 | bool parse_arch (object_thawer &thawer, archetype *arch); |
|
|
60 | bool parse_object (object_thawer &thawer, object *op); |
|
|
61 | bool parse_player (object_thawer &thawer, player *pl); |
|
|
62 | bool parse_region (object_thawer &thawer, region *rgn); |
|
|
63 | bool parse_face (object_thawer &thawer, facetile *face); |
|
|
64 | bool parse_treasure (object_thawer &thawer, treasurelist *treasure); |
|
|
65 | bool parse_animation (object_thawer &thawer, animation *anim); |
|
|
66 | |
|
|
67 | bool parse (object_thawer &thawer); |
|
|
68 | |
|
|
69 | bool load (const char *filename); |
|
|
70 | }; |
|
|
71 | |
|
|
72 | // pure base class for default archetype loader |
|
|
73 | struct loader_arch : virtual loader_base { |
|
|
74 | archetype *get_arch (const char *name); |
|
|
75 | void put_arch (archetype *arch); |
|
|
76 | }; |
|
|
77 | |
|
|
78 | // pure base class for default object loader |
|
|
79 | struct loader_object : virtual loader_base { |
|
|
80 | object *get_object (const char *name); |
|
|
81 | void put_object (object *op); |
|
|
82 | }; |
|
|
83 | |
|
|
84 | // pure base class for default player loader |
|
|
85 | struct loader_player : virtual loader_base { |
|
|
86 | virtual player *get_player (); |
|
|
87 | virtual void put_player (player *pl); |
|
|
88 | }; |
|
|
89 | |
|
|
90 | // pure base class for default region loader |
|
|
91 | struct loader_region : virtual loader_base { |
|
|
92 | region *get_region (const char *name); |
|
|
93 | void put_region (region *rgn); |
|
|
94 | }; |
|
|
95 | |
|
|
96 | // pure base class for default face loader |
|
|
97 | struct loader_face : virtual loader_base { |
|
|
98 | facetile *get_face (const char *name); |
|
|
99 | void put_face (facetile *face); |
|
|
100 | }; |
|
|
101 | |
|
|
102 | // pure base class for default treasure loader |
|
|
103 | struct loader_treasure : virtual loader_base { |
|
|
104 | treasurelist *get_treasure (const char *name, bool one = false); |
|
|
105 | void put_treasure (treasurelist *treasure); |
|
|
106 | }; |
|
|
107 | |
|
|
108 | // pure base class for default animation loader |
|
|
109 | struct loader_animation : virtual loader_base { |
|
|
110 | animation *get_animation (const char *name); |
|
|
111 | void put_animation (animation *anim); |
|
|
112 | }; |
|
|
113 | |
|
|
114 | // future generic resource loader |
|
|
115 | // handles generic stuff valid in most files, such as |
|
|
116 | // animations, treasures, faces and so on |
|
|
117 | struct loader_generic |
|
|
118 | : virtual loader_base, |
|
|
119 | loader_object, loader_player, |
|
|
120 | loader_region, loader_face, |
|
|
121 | loader_treasure, loader_animation |
|
|
122 | { |
|
|
123 | }; |
|
|
124 | |