--- deliantra/server/include/face.h 2011/04/23 04:56:48 1.36 +++ deliantra/server/include/face.h 2018/11/17 23:40:01 1.47 @@ -1,41 +1,40 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. - * - * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team - * + * + * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team + * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the * Free Software Foundation, either version 3 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 Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . - * + * * The authors can be reached via e-mail to */ #ifndef FACE_H__ #define FACE_H__ -#include -#include +#include -#define CHKSUM_MAXLEN 15 -#define MAX_FACES 10000 // stupid gcfclient artificially limits +#include "flat_hash_map.hpp" -typedef uint16 faceidx; +#define CHKSUM_MAXLEN 15 +#define MAX_FACES 65535 // we reserve face #65535 extern faceidx blank_face, empty_face, magicmouth_face; struct facedata { - std::string data; uint8 chksum[CHKSUM_MAXLEN]; uint8 chksum_len; @@ -51,12 +50,11 @@ struct faceinfo { faceinfo () - : number (0), smooth (0), type (0), smoothlevel (0), visibility (0), magicmap (0) + : number (0), smooth (0), type (0), smoothlevel (0), visibility (0), magicmap (0), refcnt (1) { } shstr name; - std::string meta; facedata face[3]; // indexed by faceset, 0 == 32 bit or generic, 1 == 64, 2 == text faceidx number; /* This is the image id. It should be the */ /* same value as its position in the array */ @@ -67,6 +65,10 @@ uint8 magicmap; /* Color to show this in magic map */ facedata *data (int faceset) const; + + int refcnt; // reference count - 1 + void ref () { ++refcnt; } + void unref (); }; inline void @@ -78,7 +80,7 @@ put (k); } -typedef std::tr1::unordered_map > > facehash_t; +typedef ska::flat_hash_map>> facehash_t; extern facehash_t facehash; extern std::vector faces; @@ -94,6 +96,7 @@ * it will be known that the face could not be found. */ faceidx face_find (const char *name, faceidx defidx = 0); +faceidx face_alloc (); faceinfo *face_info (faceidx idx); facedata *face_data (faceidx idx, int faceset); @@ -119,7 +122,7 @@ void resize (int new_size); }; -typedef std::tr1::unordered_map > > animhash_t; +typedef ska::flat_hash_map>> animhash_t; extern std::vector animations;