--- deliantra/server/include/loader.h 2006/02/03 07:12:49 1.1 +++ deliantra/server/include/loader.h 2007/02/01 19:15:39 1.8 @@ -1,41 +1,124 @@ /* - * static char *rcsid_object_h = - * "$Id$"; + * CrossFire, A Multiplayer game for X-windows + * + * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team + * Copyright (C) 2002 Mark Wedel & Crossfire Development Team + * Copyright (C) 1992 Frank Tore Johansen + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * The authors can be reached via e-mail to crossfire@schmorp.de */ -/* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 2002 Mark Wedel & Crossfire Development Team - Copyright (C) 1992 Frank Tore Johansen - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - The authors can be reached via e-mail to crossfire-devel@real-time.com -*/ - #define LL_IGNORED -1 #define LL_EOF 0 #define LL_MORE 1 #define LL_NORMAL 2 -/* see loader.l for more details on this */ -#define LO_REPEAT 0 -#define LO_LINEMODE 1 -#define LO_NEWFILE 2 -#define LO_NOREAD 3 - extern int nrofpixmaps; + +// resource loader pure base class +struct loader_base +{ + const char *filename; + + virtual archetype *get_arch (const char *name); + virtual void put_arch (archetype *arch); + + virtual object *get_object (const char *name); + virtual void put_object (object *op); + + virtual player *get_player (); + virtual void put_player (player *pl); + + virtual region *get_region (const char *name); + virtual void put_region (region *rgn); + + virtual facetile *get_face (const char *name); + virtual void put_face (facetile *face); + + virtual treasurelist *get_treasure (const char *name, bool one = false); + virtual void put_treasure (treasurelist *treasure); + + virtual animation *get_animation (const char *name); + virtual void put_animation (animation *anim); + + bool parse_arch (object_thawer &thawer, archetype *arch); + bool parse_object (object_thawer &thawer, object *op); + bool parse_player (object_thawer &thawer, player *pl); + bool parse_region (object_thawer &thawer, region *rgn); + bool parse_face (object_thawer &thawer, facetile *face); + bool parse_treasure (object_thawer &thawer, treasurelist *treasure); + bool parse_animation (object_thawer &thawer, animation *anim); + + bool parse (object_thawer &thawer); + + bool load (const char *filename); +}; + +// pure base class for default archetype loader +struct loader_arch : virtual loader_base { + archetype *get_arch (const char *name); + void put_arch (archetype *arch); +}; + +// pure base class for default object loader +struct loader_object : virtual loader_base { + object *get_object (const char *name); + void put_object (object *op); +}; + +// pure base class for default player loader +struct loader_player : virtual loader_base { + virtual player *get_player (); + virtual void put_player (player *pl); +}; + +// pure base class for default region loader +struct loader_region : virtual loader_base { + region *get_region (const char *name); + void put_region (region *rgn); +}; + +// pure base class for default face loader +struct loader_face : virtual loader_base { + facetile *get_face (const char *name); + void put_face (facetile *face); +}; + +// pure base class for default treasure loader +struct loader_treasure : virtual loader_base { + treasurelist *get_treasure (const char *name, bool one = false); + void put_treasure (treasurelist *treasure); +}; + +// pure base class for default animation loader +struct loader_animation : virtual loader_base { + animation *get_animation (const char *name); + void put_animation (animation *anim); +}; + +// future generic resource loader +// handles generic stuff valid in most files, such as +// animations, treasures, faces and so on +struct loader_generic +: virtual loader_base, + loader_object, loader_player, + loader_region, loader_face, + loader_treasure, loader_animation +{ +}; +