--- deliantra/server/include/face.h 2007/01/19 17:50:11 1.8 +++ deliantra/server/include/face.h 2007/03/14 04:12:28 1.11 @@ -21,23 +21,66 @@ * * The author can be reached via e-mail to mark@pyramid.com */ +#ifndef FACE_H__ +#define FACE_H__ + +#include +#include + +#define CHKSUM_SIZE (128 / 8) +#define MAX_FACES 10000 // stupid gcfclient artificially limits + +typedef uint16 faceidx; + +extern faceidx blank_face, empty_face; + +struct facedata +{ + std::string data; + uint8 chksum[CHKSUM_SIZE]; +}; /* 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. */ -struct facetile +struct faceinfo { - uint16 number; /* This is the image id. It should be the */ - /* same value as its position in the array */ shstr name; + facedata data32, data64; + faceidx number; /* This is the image id. It should be the */ + /* same value as its position in the array */ + faceidx smooth; /* the smooth face for this face, or 0 */ uint8 visibility; uint8 magicmap; /* Color to show this in magic map */ + + faceinfo () + : number (0), smooth (0), visibility (0), magicmap (0) + { } }; +typedef std::tr1::unordered_map >, true> facehash_t; + +extern facehash_t facehash; +extern std::vector faces; + +/* 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. + */ +faceidx face_find (const char *name, faceidx defidx = 0); +faceinfo *face_info (faceidx idx); +facedata *face_data (faceidx idx, int faceset); + struct MapLook { - facetile *face; + faceinfo *face; uint8 flags; }; @@ -46,7 +89,9 @@ 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) */ - uint16 *faces; /* The different animations */ + faceidx *faces; /* The different animations */ uint16 num; /* Where we are in the array */ }; +#endif +