add empty thing type

This commit is contained in:
Henrique 2011-12-02 01:01:56 -02:00
parent 3e27d5a79f
commit 19eb56997d
3 changed files with 6 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#include "thing.h" #include "thing.h"
#include "spritemanager.h" #include "spritemanager.h"
#include "thingstype.h"
#include <framework/graphics/graphics.h> #include <framework/graphics/graphics.h>
Thing::Thing() : m_id(0) Thing::Thing() : m_id(0)
@ -30,6 +31,7 @@ Thing::Thing() : m_id(0)
m_yPattern = 0; m_yPattern = 0;
m_zPattern = 0; m_zPattern = 0;
m_animation = 0; m_animation = 0;
m_type = g_thingsType.getEmptyThingType();
} }
void Thing::internalDraw(const Point& p, int layers, Otc::SpriteMask mask) void Thing::internalDraw(const Point& p, int layers, Otc::SpriteMask mask)

View File

@ -26,6 +26,7 @@
#include <framework/core/resourcemanager.h> #include <framework/core/resourcemanager.h>
ThingsType g_thingsType; ThingsType g_thingsType;
ThingType ThingsType::m_emptyThingType;
bool ThingsType::load(const std::string& file) bool ThingsType::load(const std::string& file)
{ {
@ -121,8 +122,7 @@ ThingType *ThingsType::getThingType(uint16 id, Categories category)
// assert wrokground // assert wrokground
if(id >= m_things[category].size()) { if(id >= m_things[category].size()) {
//logTraceErrorOnce("got an invalid type"); //logTraceErrorOnce("got an invalid type");
static ThingType emptyType; return &m_emptyThingType;
return &emptyType;
} }
return &m_things[category][id]; return &m_things[category][id];

View File

@ -43,6 +43,7 @@ public:
void parseThingType(std::stringstream& fin, ThingType& thingType); void parseThingType(std::stringstream& fin, ThingType& thingType);
ThingType *getEmptyThingType() { return &m_emptyThingType; }
ThingType *getThingType(uint16 id, Categories category); ThingType *getThingType(uint16 id, Categories category);
uint32 getSignature() { return m_signature; } uint32 getSignature() { return m_signature; }
@ -51,6 +52,7 @@ private:
uint32 m_signature; uint32 m_signature;
ThingTypeList m_things[LastCategory]; ThingTypeList m_things[LastCategory];
static ThingType m_emptyThingType;
}; };
extern ThingsType g_thingsType; extern ThingsType g_thingsType;