GRIM: Remove tag from the pool template

This commit is contained in:
Joel Teichroeb 2012-04-05 15:20:30 -07:00
parent 21000e432c
commit 94aeca9663
17 changed files with 94 additions and 95 deletions

View File

@ -63,7 +63,7 @@ void Actor::restoreStaticState(SaveGame *state) {
}
Actor::Actor(const Common::String &actorName) :
PoolObject<Actor, MKTAG('A', 'C', 'T', 'R')>(), _name(actorName), _setName(""),
_name(actorName), _setName(""),
_talkColor(255, 255, 255), _pos(0, 0, 0),
// Some actors don't set walk and turn rates, so we default the
// _turnRate so Doug at the cat races can turn and we set the
@ -98,8 +98,7 @@ Actor::Actor(const Common::String &actorName) :
}
}
Actor::Actor() :
PoolObject<Actor, MKTAG('A', 'C', 'T', 'R')>() {
Actor::Actor() {
_shadowArray = new Shadow[5];
_running = false;

View File

@ -63,7 +63,7 @@ struct Shadow {
*
* @short Actor represents a 3D character on screen.
*/
class Actor : public PoolObject<Actor, MKTAG('A', 'C', 'T', 'R')> {
class Actor : public PoolObject<Actor> {
public:
enum CollisionMode {
CollisionOff = 0,
@ -87,6 +87,8 @@ public:
*/
~Actor();
static int32 getStaticTag() { return MKTAG('A', 'C', 'T', 'R'); }
/**
* Saves the actor state.
*

View File

@ -389,20 +389,17 @@ const Graphics::PixelBuffer &BitmapData::getImageData(int num) const {
// Bitmap
Bitmap::Bitmap(const Common::String &fname) :
PoolObject<Bitmap, MKTAG('V', 'B', 'U', 'F')>() {
Bitmap::Bitmap(const Common::String &fname) {
_data = BitmapData::getBitmapData(fname);
_currImage = 1;
}
Bitmap::Bitmap(const Graphics::PixelBuffer &buf, int w, int h, const char *fname) :
PoolObject<Bitmap, MKTAG('V', 'B', 'U', 'F')>() {
Bitmap::Bitmap(const Graphics::PixelBuffer &buf, int w, int h, const char *fname) {
_data = new BitmapData(buf, w, h, fname);
_currImage = 1;
}
Bitmap::Bitmap() :
PoolObject<Bitmap, MKTAG('V', 'B', 'U', 'F')>() {
Bitmap::Bitmap() {
_data = new BitmapData();
}

View File

@ -106,7 +106,7 @@ public:
Graphics::PixelBuffer *_data;
};
class Bitmap : public PoolObject<Bitmap, MKTAG('V', 'B', 'U', 'F')> {
class Bitmap : public PoolObject<Bitmap> {
public:
/**
* Construct a bitmap from the given data.
@ -119,6 +119,8 @@ public:
Bitmap(const Graphics::PixelBuffer &buf, int width, int height, const char *filename);
Bitmap();
static int32 getStaticTag() { return MKTAG('V', 'B', 'U', 'F'); }
static Bitmap *create(const Common::String &filename);
const Common::String &getFilename() const { return _data->_fname; }

View File

@ -87,9 +87,10 @@ private:
friend class EMICostume;
};
class PoolChore : public PoolObject<PoolChore, MKTAG('C', 'H', 'O', 'R')>, public Chore {
class PoolChore : public PoolObject<PoolChore>, public Chore {
public:
virtual int getId() { return PoolObject<PoolChore, MKTAG('C', 'H', 'O', 'R')>::getId(); }
virtual int getId() { return PoolObject<PoolChore>::getId(); }
static int32 getStaticTag() { return MKTAG('C', 'H', 'O', 'R'); }
};
} // end of namespace Grim

View File

@ -179,9 +179,10 @@ void Lua_V2::ImFlushStack() {
warning("Lua_V2::ImFlushStack: implement opcode");
}
class PoolSound : public PoolObject<PoolSound, MKTAG('A', 'I', 'F', 'F')>{
class PoolSound : public PoolObject<PoolSound>{
public:
PoolSound(const Common::String &filename);
static int32 getStaticTag() { return MKTAG('A', 'I', 'F', 'F'); }
AIFFTrack *track;
};

View File

@ -32,13 +32,13 @@
namespace Grim {
Font::Font(const Common::String &filename, Common::SeekableReadStream *data) :
PoolObject<Font, MKTAG('F', 'O', 'N', 'T')>(), _userData(NULL),
_userData(NULL),
_fontData(NULL), _charHeaders(NULL), _charIndex(NULL) {
load(filename, data);
}
Font::Font() :
PoolObject<Font, MKTAG('F', 'O', 'N', 'T')>(), _userData(NULL),
_userData(NULL),
_fontData(NULL), _charHeaders(NULL), _charIndex(NULL)
{

View File

@ -33,11 +33,14 @@ namespace Grim {
class SaveGame;
class Font : public PoolObject<Font, MKTAG('F', 'O', 'N', 'T')> {
class Font : public PoolObject<Font> {
public:
Font(const Common::String &filename, Common::SeekableReadStream *data);
Font();
~Font();
static int32 getStaticTag() { return MKTAG('F', 'O', 'N', 'T'); }
void load(const Common::String &filename, Common::SeekableReadStream *data);
const Common::String &getFilename() const { return _filename; }

View File

@ -28,7 +28,7 @@
namespace Grim {
ObjectState::ObjectState(int setup, ObjectState::Position position, const char *bitmap, const char *zbitmap, bool transparency) :
PoolObject<ObjectState, MKTAG('S', 'T', 'A', 'T')>(), _setupID(setup), _pos(position), _visibility(false) {
_setupID(setup), _pos(position), _visibility(false) {
_bitmap = Bitmap::create(bitmap);
if (zbitmap) {
@ -38,7 +38,7 @@ ObjectState::ObjectState(int setup, ObjectState::Position position, const char *
}
ObjectState::ObjectState() :
PoolObject<ObjectState, MKTAG('S', 'T', 'A', 'T')>(), _bitmap(NULL), _zbitmap(NULL) {
_bitmap(NULL), _zbitmap(NULL) {
}

View File

@ -32,7 +32,7 @@ namespace Grim {
class SaveGame;
class ObjectState : public PoolObject<ObjectState, MKTAG('S', 'T', 'A', 'T')> {
class ObjectState : public PoolObject<ObjectState> {
public:
enum Position {
OBJSTATE_BACKGROUND = 0,
@ -45,6 +45,8 @@ public:
ObjectState();
~ObjectState();
static int32 getStaticTag() { return MKTAG('S', 'T', 'A', 'T'); }
void saveState(SaveGame *savedState) const;
bool restoreState(SaveGame *savedState);

View File

@ -18,7 +18,7 @@ public:
virtual int32 getTag() const = 0;
};
template<class T, int32 tag>
template<class T>
class PoolObject : public PoolObjectBase {
public:
class Pool {
@ -118,8 +118,7 @@ public:
virtual ~PoolObject();
int getId() const;
int32 getTag() const;
static int32 getTagStatic();
virtual int32 getTag() const { return T::getStaticTag(); }
static Pool &getPool();
@ -144,24 +143,24 @@ private:
friend class Ptr;
};
template <class T, int32 tag>
bool operator==(T *obj, const typename PoolObject<T, tag>::Ptr &ptr) {
template <class T>
bool operator==(T *obj, const typename PoolObject<T>::Ptr &ptr) {
return obj == ptr._obj;
}
template <class T, int32 tag>
bool operator!=(T *obj, const typename PoolObject<T, tag>::Ptr &ptr) {
template <class T>
bool operator!=(T *obj, const typename PoolObject<T>::Ptr &ptr) {
return obj != ptr._obj;
}
template <class T, int32 tag>
int PoolObject<T, tag>::s_id = 0;
template <class T>
int PoolObject<T>::s_id = 0;
template <class T, int32 tag>
typename PoolObject<T, tag>::Pool *PoolObject<T, tag>::s_pool = NULL;
template <class T>
typename PoolObject<T>::Pool *PoolObject<T>::s_pool = NULL;
template <class T, int32 tag>
PoolObject<T, tag>::PoolObject() {
template <class T>
PoolObject<T>::PoolObject() {
++s_id;
_id = s_id;
@ -171,8 +170,8 @@ PoolObject<T, tag>::PoolObject() {
s_pool->addObject(static_cast<T *>(this));
}
template <class T, int32 tag>
PoolObject<T, tag>::~PoolObject() {
template <class T>
PoolObject<T>::~PoolObject() {
s_pool->removeObject(_id);
for (typename Common::List<Ptr *>::iterator i = _pointers.begin(); i != _pointers.end(); ++i) {
@ -180,105 +179,94 @@ PoolObject<T, tag>::~PoolObject() {
}
}
template <class T, int32 tag>
void PoolObject<T, tag>::setId(int id) {
template <class T>
void PoolObject<T>::setId(int id) {
_id = id;
if (id > s_id) {
s_id = id;
}
}
template <class T, int32 tag>
int PoolObject<T, tag>::getId() const {
template <class T>
int PoolObject<T>::getId() const {
return _id;
}
template <class T, int32 tag>
typename PoolObject<T, tag>::Pool &PoolObject<T, tag>::getPool() {
template <class T>
typename PoolObject<T>::Pool &PoolObject<T>::getPool() {
if (!s_pool) {
s_pool = new Pool();
}
return *s_pool;
}
template <class T, int32 tag>
int32 PoolObject<T, tag>::getTag() const {
return tag;
}
template <class T, int32 tag>
int32 PoolObject<T, tag>::getTagStatic() {
return tag;
}
/**
* @class Pool
*/
template <class T, int32 tag>
PoolObject<T, tag>::Pool::Pool() :
template <class T>
PoolObject<T>::Pool::Pool() :
_restoring(false) {
}
template <class T, int32 tag>
PoolObject<T, tag>::Pool::~Pool() {
PoolObject<T, tag>::s_pool = NULL;
template <class T>
PoolObject<T>::Pool::~Pool() {
PoolObject<T>::s_pool = NULL;
}
template <class T, int32 tag>
void PoolObject<T, tag>::Pool::addObject(T *obj) {
template <class T>
void PoolObject<T>::Pool::addObject(T *obj) {
if (!_restoring) {
_map.setVal(obj->_id, obj);
}
}
template <class T, int32 tag>
void PoolObject<T, tag>::Pool::removeObject(int32 id) {
template <class T>
void PoolObject<T>::Pool::removeObject(int32 id) {
_map.erase(id);
}
template <class T, int32 tag>
T *PoolObject<T, tag>::Pool::getObject(int32 id) {
template <class T>
T *PoolObject<T>::Pool::getObject(int32 id) {
return _map.getVal(id, NULL);
}
template <class T, int32 tag>
typename PoolObject<T, tag>::Pool::iterator PoolObject<T, tag>::Pool::begin() {
template <class T>
typename PoolObject<T>::Pool::iterator PoolObject<T>::Pool::begin() {
return iterator(_map.begin());
}
template <class T, int32 tag>
typename PoolObject<T, tag>::Pool::const_iterator PoolObject<T, tag>::Pool::begin() const {
template <class T>
typename PoolObject<T>::Pool::const_iterator PoolObject<T>::Pool::begin() const {
return const_iterator(_map.begin());
}
template <class T, int32 tag>
typename PoolObject<T, tag>::Pool::iterator PoolObject<T, tag>::Pool::end() {
template <class T>
typename PoolObject<T>::Pool::iterator PoolObject<T>::Pool::end() {
return iterator(_map.end());
}
template <class T, int32 tag>
typename PoolObject<T, tag>::Pool::const_iterator PoolObject<T, tag>::Pool::end() const {
template <class T>
typename PoolObject<T>::Pool::const_iterator PoolObject<T>::Pool::end() const {
return const_iterator(_map.end());
}
template <class T, int32 tag>
int PoolObject<T, tag>::Pool::getSize() const {
template <class T>
int PoolObject<T>::Pool::getSize() const {
return _map.size();
}
template <class T, int32 tag>
void PoolObject<T, tag>::Pool::deleteObjects() {
template <class T>
void PoolObject<T>::Pool::deleteObjects() {
while (!_map.empty()) {
delete *begin();
}
delete this;
}
template <class T, int32 tag>
void PoolObject<T, tag>::Pool::saveObjects(SaveGame *state) {
state->beginSection(tag);
template <class T>
void PoolObject<T>::Pool::saveObjects(SaveGame *state) {
state->beginSection(T::getStaticTag());
T::saveStaticState(state);
@ -293,9 +281,9 @@ void PoolObject<T, tag>::Pool::saveObjects(SaveGame *state) {
state->endSection();
}
template <class T, int32 tag>
void PoolObject<T, tag>::Pool::restoreObjects(SaveGame *state) {
state->beginSection(tag);
template <class T>
void PoolObject<T>::Pool::restoreObjects(SaveGame *state) {
state->beginSection(T::getStaticTag());
T::restoreStaticState(state);
@ -322,8 +310,8 @@ void PoolObject<T, tag>::Pool::restoreObjects(SaveGame *state) {
state->endSection();
}
template<class T, int32 tag>
typename PoolObject<T, tag>::Ptr &PoolObject<T, tag>::Ptr::operator=(T *obj) {
template<class T>
typename PoolObject<T>::Ptr &PoolObject<T>::Ptr::operator=(T *obj) {
if (_obj) {
_obj->removePointer(this);
}
@ -335,8 +323,8 @@ typename PoolObject<T, tag>::Ptr &PoolObject<T, tag>::Ptr::operator=(T *obj) {
return *this;
}
template<class T, int32 tag>
typename PoolObject<T, tag>::Ptr &PoolObject<T, tag>::Ptr::operator=(const Ptr &ptr) {
template<class T>
typename PoolObject<T>::Ptr &PoolObject<T>::Ptr::operator=(const Ptr &ptr) {
if (_obj) {
_obj->removePointer(this);
}

View File

@ -28,8 +28,7 @@
namespace Grim {
PrimitiveObject::PrimitiveObject() :
PoolObject<PrimitiveObject, MKTAG('P', 'R', 'I', 'M')>() {
PrimitiveObject::PrimitiveObject() {
_filled = false;
_type = 0;
}

View File

@ -32,11 +32,13 @@ namespace Grim {
class SaveGame;
class PrimitiveObject : public PoolObject<PrimitiveObject, MKTAG('P', 'R', 'I', 'M')> {
class PrimitiveObject : public PoolObject<PrimitiveObject> {
public:
PrimitiveObject();
~PrimitiveObject();
static int32 getStaticTag() { return MKTAG('P', 'R', 'I', 'M'); }
typedef enum {
RECTANGLE = 1,
LINE,

View File

@ -39,7 +39,7 @@
namespace Grim {
Set::Set(const Common::String &sceneName, Common::SeekableReadStream *data) :
PoolObject<Set, MKTAG('S', 'E', 'T', ' ')>(), _locked(false), _name(sceneName), _enableLights(false) {
_locked(false), _name(sceneName), _enableLights(false) {
char header[7];
data->read(header, 7);
@ -52,8 +52,7 @@ Set::Set(const Common::String &sceneName, Common::SeekableReadStream *data) :
}
}
Set::Set() :
PoolObject<Set, MKTAG('S', 'E', 'T', ' ')>(), _cmaps(NULL) {
Set::Set() : _cmaps(NULL) {
}

View File

@ -38,12 +38,14 @@ class SaveGame;
class CMap;
class Light;
class Set : public PoolObject<Set, MKTAG('S', 'E', 'T', ' ')> {
class Set : public PoolObject<Set> {
public:
Set(const Common::String &name, Common::SeekableReadStream *data);
Set();
~Set();
static int32 getStaticTag() { return MKTAG('S', 'E', 'T', ' '); }
void loadText(TextSplitter &ts);
void loadBinary(Common::SeekableReadStream *data);

View File

@ -37,14 +37,14 @@ TextObjectCommon::TextObjectCommon() :
}
TextObject::TextObject(bool blastDraw, bool isSpeech) :
PoolObject<TextObject, MKTAG('T', 'E', 'X', 'T')>(), TextObjectCommon(), _numberLines(1),
TextObjectCommon(), _numberLines(1),
_maxLineWidth(0), _lines(0), _userData(0), _created(false) {
_blastDraw = blastDraw;
_isSpeech = isSpeech;
}
TextObject::TextObject() :
PoolObject<TextObject, MKTAG('T', 'E', 'X', 'T')>(), TextObjectCommon(), _maxLineWidth(0), _lines(NULL) {
TextObjectCommon(), _maxLineWidth(0), _lines(NULL) {
}

View File

@ -76,13 +76,15 @@ class TextObjectDefaults : public TextObjectCommon {
};
class TextObject : public PoolObject<TextObject, MKTAG('T', 'E', 'X', 'T')>,
class TextObject : public PoolObject<TextObject>,
public TextObjectCommon {
public:
TextObject(bool blastDraw, bool isSpeech = false);
TextObject();
~TextObject();
static int32 getStaticTag() { return MKTAG('T', 'E', 'X', 'T'); }
void setDefaults(TextObjectDefaults *defaults);
void setText(const Common::String &text);
void reset();