--- deliantra/server/include/face.h 2006/08/29 08:01:36 1.2 +++ deliantra/server/include/face.h 2007/03/11 02:12:44 1.9 @@ -1,56 +1,91 @@ /* - * static char *rcsid_face_h = - * "$Id$"; + * CrossFire, A Multiplayer game for X-windows + * + * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team + * Copyright (C) 1994 Mark Wedel + * 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 author can be reached via e-mail to mark@pyramid.com */ +#ifndef FACE_H__ +#define FACE_H__ -/* - CrossFire, A Multiplayer game for X-windows - - Copyright (C) 1994 Mark Wedel - Copyright (C) 1992 Frank Tore Johansen +#include +#include - 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. +#define CHKSUM_SIZE (128 / 8) +#define MAX_FACES 10000 // stupid gcfclient artificially limits - The author can be reached via e-mail to mark@pyramid.com -*/ +typedef uint16 faceidx; +extern faceidx blank_face, empty_face; /* New face structure - this enforces the notion that data is face by * face only - you can not change the color of an item - you need to instead * create a new face with that color. */ -typedef struct new_face_struct { - uint16 number; /* This is the image id. It should be the */ +struct faceinfo +{ + shstr name; + faceidx number; /* This is the image id. It should be the */ /* same value as its position in the array */ - const char *name; - uint8 visibility; - uint8 magicmap; /* Color to show this in magic map */ -} New_Face; - -typedef struct map_look_struct { - New_Face *face; - uint8 flags; -} MapLook; - - -typedef struct { - const char *name; /* Name of the animation sequence */ - uint8 num_animations; /* How many different faces to animate */ - uint8 facings; /* How many facings (1,2,4,8) */ - Fontindex *faces; /* The different animations */ - uint16 num; /* Where we are in the array */ -} Animations; + uint8 visibility; + uint8 magicmap; /* Color to show this in magic map */ +}; + +struct facedata +{ + std::string data; + uint8 chksum[CHKSUM_SIZE]; +}; + +typedef std::tr1::unordered_map >, true> facehash_t; + +extern facehash_t facehash; +extern std::vector faces; +extern std::vector face32, face64; + +/* This returns an the face number of face 'name'. Number is constant + * during an invocation, but not necessarily between versions (this + * is because the faces are arranged in alphabetical order, so + * if a face is removed or added, all faces after that will now + * have a different number. + * + * If a face is not found, then defidx is returned. This can be useful + * if you want some default face used, or can be set to negative so that + * it will be known that the face could not be found. + */ +int face_find (const char *name, int defidx = 0); +facedata *face_data (int idx, int faceset); + +struct MapLook +{ + faceinfo *face; + uint8 flags; +}; + +struct animation +{ + shstr name; /* Name of the animation sequence */ + uint8 num_animations; /* How many different faces to animate */ + uint8 facings; /* How many facings (1,2,4,8) */ + faceidx *faces; /* The different animations */ + uint16 num; /* Where we are in the array */ +}; +#endif