… | |
… | |
24 | |
24 | |
25 | /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. |
25 | /* Eneq(@csd.uu.se): Added weight-modifiers in environment of objects. |
26 | sub/add_weight will transcend the environment updating the carrying |
26 | sub/add_weight will transcend the environment updating the carrying |
27 | variable. */ |
27 | variable. */ |
28 | |
28 | |
29 | |
|
|
30 | #include <global.h> |
29 | #include <global.h> |
31 | #include <loader.h> |
30 | #include <loader.h> |
32 | #include <sproto.h> |
31 | #include <sproto.h> |
33 | |
32 | |
34 | // future resource loader base class |
33 | // resource loader pure base class |
35 | struct loader_base |
34 | struct loader_base |
36 | { |
35 | { |
37 | const char *filename; |
36 | const char *filename; |
38 | virtual const char *type () const = 0; |
37 | virtual const char *type () const = 0; |
39 | |
38 | |
… | |
… | |
57 | |
56 | |
58 | virtual animation *get_animation (const char *name); |
57 | virtual animation *get_animation (const char *name); |
59 | virtual void put_animation (animation *anim); |
58 | virtual void put_animation (animation *anim); |
60 | }; |
59 | }; |
61 | |
60 | |
|
|
61 | // pure base class for default archetype loader |
|
|
62 | struct loader_arch : virtual loader_base { |
|
|
63 | archetype *get_arch (const char *name); |
|
|
64 | void put_arch (archetype *arch); |
|
|
65 | }; |
|
|
66 | |
|
|
67 | // pure base class for default object loader |
|
|
68 | struct loader_object : virtual loader_base { |
|
|
69 | object *get_object (const char *name); |
|
|
70 | void put_object (object *op); |
|
|
71 | }; |
|
|
72 | |
|
|
73 | // pure base class for default player loader |
|
|
74 | struct loader_player : virtual loader_base { |
|
|
75 | virtual player *get_player (); |
|
|
76 | virtual void put_player (player *pl); |
|
|
77 | }; |
|
|
78 | |
|
|
79 | // pure base class for default region loader |
|
|
80 | struct loader_region : virtual loader_base { |
|
|
81 | region *get_region (); |
|
|
82 | void put_region (region *region); |
|
|
83 | }; |
|
|
84 | |
|
|
85 | // pure base class for default face loader |
|
|
86 | struct loader_face : virtual loader_base { |
|
|
87 | facetile *get_face (const char *name); |
|
|
88 | void put_face (facetile *face); |
|
|
89 | }; |
|
|
90 | |
|
|
91 | // pure base class for default treasure loader |
|
|
92 | struct loader_treasure : virtual loader_base { |
|
|
93 | treasurelist *get_treasure (const char *name, bool one = false); |
|
|
94 | void put_treasure (treasurelist *treasure); |
|
|
95 | }; |
|
|
96 | |
|
|
97 | // pure base class for default animation loader |
|
|
98 | struct loader_animation : virtual loader_base { |
|
|
99 | animation *get_animation (const char *name); |
|
|
100 | void put_animation (animation *anim); |
|
|
101 | }; |
|
|
102 | |
62 | // future generic resource loader |
103 | // future generic resource loader |
63 | // handles generic stuff valid in most files, such as |
104 | // handles generic stuff valid in most files, such as |
64 | // animations, treasures, faces and so on |
105 | // animations, treasures, faces and so on |
65 | struct loader_generic : loader_base |
106 | struct loader_generic |
|
|
107 | : virtual loader_base, |
|
|
108 | loader_object, loader_player, |
|
|
109 | loader_region, loader_face, |
|
|
110 | loader_treasure, loader_animation |
66 | { |
111 | { |
67 | const char *type () const = 0; |
112 | const char *type () const = 0; |
68 | |
|
|
69 | region *get_region (); |
|
|
70 | void put_region (region *region); |
|
|
71 | |
|
|
72 | facetile *get_face (const char *name); |
|
|
73 | void put_face (facetile *face); |
|
|
74 | |
|
|
75 | treasurelist *get_treasure (const char *name, bool one = false); |
|
|
76 | void put_treasure (treasurelist *treasure); |
|
|
77 | |
|
|
78 | animation *get_animation (const char *name); |
|
|
79 | void put_animation (animation *anim); |
|
|
80 | }; |
113 | }; |
81 | |
114 | |
82 | // the base class warns about and skips everything |
115 | // the base class warns about and skips everything |
83 | archetype * |
116 | archetype * |
84 | loader_base::get_arch (const char *name) |
117 | loader_base::get_arch (const char *name) |