--- deliantra/server/common/loader.C 2007/01/19 17:54:15 1.49 +++ deliantra/server/common/loader.C 2007/01/19 18:06:51 1.50 @@ -34,6 +34,9 @@ // future resource loader base class struct loader_base { + const char *filename; + virtual const char *type () const = 0; + virtual archetype *get_arch (const char *name); virtual void put_arch (archetype *arch); @@ -43,7 +46,7 @@ virtual player *get_player (); virtual void put_player (player *pl); - virtual region *get_region (); + virtual region *get_region (const char *name); virtual void put_region (region *region); virtual facetile *get_face (const char *name); @@ -61,19 +64,127 @@ // animations, treasures, faces and so on struct loader_generic : loader_base { - virtual region *get_region (); - virtual void put_region (region *region); + const char *type () const = 0; - virtual facetile *get_face (const char *name); - virtual void put_face (facetile *face); + region *get_region (); + void put_region (region *region); - virtual treasurelist *get_treasure (const char *name, bool one = false); - virtual void put_treasure (treasurelist *treasure); + facetile *get_face (const char *name); + void put_face (facetile *face); - virtual animation *get_animation (const char *name); - virtual void put_animation (animation *anim); + treasurelist *get_treasure (const char *name, bool one = false); + void put_treasure (treasurelist *treasure); + + animation *get_animation (const char *name); + void put_animation (animation *anim); }; +// the base class warns about and skips everything +archetype * +loader_base::get_arch (const char *name) +{ + LOG (llevError, "%s: found archetype definition '%s', which is not allowed in files of type %s.\n", + filename, name, type ()); + + return new archetype; +} + +object * +loader_base::get_object (const char *name) +{ + LOG (llevError, "%s: found object definition '%s', which is not allowed in files of type %s.\n", + filename, name, type ()); + + return object::create (); +} + +player * +loader_base::get_player () +{ + LOG (llevError, "%s: found player definition, which is not allowed in files of type %s.\n", + filename, type ()); + + return player::create (); +} + +region * +loader_base::get_region (const char *name) +{ + LOG (llevError, "%s: found region definition '%s', which is not allowed in files of type %s.\n", + filename, name, type ()); + + return new region; +} + +facetile * +loader_base::get_face (const char *name) +{ + LOG (llevError, "%s: found face definition '%s', which is not allowed in files of type %s.\n", + filename, name, type ()); + + return new facetile; +} + +treasurelist * +loader_base::get_treasure (const char *name, bool one) +{ + LOG (llevError, "%s: found treasure definition '%s', which is not allowed in files of type %s.\n", + filename, name, type ()); + + return new treasurelist;//D +} + +animation * +loader_base::get_animation (const char *name) +{ + LOG (llevError, "%s: found animation definition '%s', which is not allowed in files of type %s.\n", + filename, name, type ()); + + return new animation; +} + +void +loader_base::put_arch (archetype *arch) +{ + delete arch; +} + +void +loader_base::put_object (object *op) +{ + op->destroy (); +} + +void +loader_base::put_player (player *pl) +{ + delete pl; +} + +void +loader_base::put_region (region *region) +{ + delete region; +} + +void +loader_base::put_face (facetile *face) +{ + delete face; +} + +void +loader_base::put_treasure (treasurelist *treasure) +{ + delete treasure; +} + +void +loader_base::put_animation (animation *anim) +{ + delete anim; +} + /* Maps the MOVE_* values to names */ static const char *const move_name[] = { "walk", "fly_low", "fly_high", "swim", "boat", NULL };