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

Comparing deliantra/server/common/loader.C (file contents):
Revision 1.49 by root, Fri Jan 19 17:54:15 2007 UTC vs.
Revision 1.50 by root, Fri Jan 19 18:06:51 2007 UTC

32#include <sproto.h> 32#include <sproto.h>
33 33
34// future resource loader base class 34// future resource loader base class
35struct loader_base 35struct loader_base
36{ 36{
37 const char *filename;
38 virtual const char *type () const = 0;
39
37 virtual archetype *get_arch (const char *name); 40 virtual archetype *get_arch (const char *name);
38 virtual void put_arch (archetype *arch); 41 virtual void put_arch (archetype *arch);
39 42
40 virtual object *get_object (const char *name); 43 virtual object *get_object (const char *name);
41 virtual void put_object (object *op); 44 virtual void put_object (object *op);
42 45
43 virtual player *get_player (); 46 virtual player *get_player ();
44 virtual void put_player (player *pl); 47 virtual void put_player (player *pl);
45 48
46 virtual region *get_region (); 49 virtual region *get_region (const char *name);
47 virtual void put_region (region *region); 50 virtual void put_region (region *region);
48 51
49 virtual facetile *get_face (const char *name); 52 virtual facetile *get_face (const char *name);
50 virtual void put_face (facetile *face); 53 virtual void put_face (facetile *face);
51 54
59// future generic resource loader 62// future generic resource loader
60// handles generic stuff valid in most files, such as 63// handles generic stuff valid in most files, such as
61// animations, treasures, faces and so on 64// animations, treasures, faces and so on
62struct loader_generic : loader_base 65struct loader_generic : loader_base
63{ 66{
67 const char *type () const = 0;
68
64 virtual region *get_region (); 69 region *get_region ();
65 virtual void put_region (region *region); 70 void put_region (region *region);
66 71
67 virtual facetile *get_face (const char *name); 72 facetile *get_face (const char *name);
68 virtual void put_face (facetile *face); 73 void put_face (facetile *face);
69 74
70 virtual treasurelist *get_treasure (const char *name, bool one = false); 75 treasurelist *get_treasure (const char *name, bool one = false);
71 virtual void put_treasure (treasurelist *treasure); 76 void put_treasure (treasurelist *treasure);
72 77
73 virtual animation *get_animation (const char *name); 78 animation *get_animation (const char *name);
74 virtual void put_animation (animation *anim); 79 void put_animation (animation *anim);
75}; 80};
81
82// the base class warns about and skips everything
83archetype *
84loader_base::get_arch (const char *name)
85{
86 LOG (llevError, "%s: found archetype definition '%s', which is not allowed in files of type %s.\n",
87 filename, name, type ());
88
89 return new archetype;
90}
91
92object *
93loader_base::get_object (const char *name)
94{
95 LOG (llevError, "%s: found object definition '%s', which is not allowed in files of type %s.\n",
96 filename, name, type ());
97
98 return object::create ();
99}
100
101player *
102loader_base::get_player ()
103{
104 LOG (llevError, "%s: found player definition, which is not allowed in files of type %s.\n",
105 filename, type ());
106
107 return player::create ();
108}
109
110region *
111loader_base::get_region (const char *name)
112{
113 LOG (llevError, "%s: found region definition '%s', which is not allowed in files of type %s.\n",
114 filename, name, type ());
115
116 return new region;
117}
118
119facetile *
120loader_base::get_face (const char *name)
121{
122 LOG (llevError, "%s: found face definition '%s', which is not allowed in files of type %s.\n",
123 filename, name, type ());
124
125 return new facetile;
126}
127
128treasurelist *
129loader_base::get_treasure (const char *name, bool one)
130{
131 LOG (llevError, "%s: found treasure definition '%s', which is not allowed in files of type %s.\n",
132 filename, name, type ());
133
134 return new treasurelist;//D
135}
136
137animation *
138loader_base::get_animation (const char *name)
139{
140 LOG (llevError, "%s: found animation definition '%s', which is not allowed in files of type %s.\n",
141 filename, name, type ());
142
143 return new animation;
144}
145
146void
147loader_base::put_arch (archetype *arch)
148{
149 delete arch;
150}
151
152void
153loader_base::put_object (object *op)
154{
155 op->destroy ();
156}
157
158void
159loader_base::put_player (player *pl)
160{
161 delete pl;
162}
163
164void
165loader_base::put_region (region *region)
166{
167 delete region;
168}
169
170void
171loader_base::put_face (facetile *face)
172{
173 delete face;
174}
175
176void
177loader_base::put_treasure (treasurelist *treasure)
178{
179 delete treasure;
180}
181
182void
183loader_base::put_animation (animation *anim)
184{
185 delete anim;
186}
76 187
77/* Maps the MOVE_* values to names */ 188/* Maps the MOVE_* values to names */
78static const char *const move_name[] = { "walk", "fly_low", "fly_high", "swim", "boat", NULL }; 189static const char *const move_name[] = { "walk", "fly_low", "fly_high", "swim", "boat", NULL };
79 190
80/* This table is only necessary to convert objects that existed before the 191/* This table is only necessary to convert objects that existed before the

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines