summaryrefslogtreecommitdiff
path: root/src/resources/spritedef.h
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-23 00:27:29 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2012-01-24 19:25:38 +0100
commit797e86813686aa0d6cd197cbab79f8ca889c261c (patch)
tree13cffc47dbb2eb90fc7c7c9c0e8964e2b5b2a2fc /src/resources/spritedef.h
parentb856e8b47ab2dfd393e3c2720c5647eb66393931 (diff)
downloadmana-797e86813686aa0d6cd197cbab79f8ca889c261c.tar.gz
mana-797e86813686aa0d6cd197cbab79f8ca889c261c.tar.bz2
mana-797e86813686aa0d6cd197cbab79f8ca889c261c.tar.xz
mana-797e86813686aa0d6cd197cbab79f8ca889c261c.zip
Fixed the crash in setupSpriteDisplay
This happened when an NPC, monster or item couldn't be found and it had to fall back on Being::Unknown. This instance was bugged since it had a 0 pointer in its sprites list, because when the Being::Unknown was created, the SpriteDef::Empty was not initialized yet (since both were global static variables, the initialization order was not well defined). Fixed it by removing SpriteDef::Empty and instead creating it in the BeingInfo constructor. I've also changed the SpriteReference instances to be inline values rather than instances on the heap, since they're quite small. That also fixed a leak since those instances were never getting deleted. Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src/resources/spritedef.h')
-rw-r--r--src/resources/spritedef.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h
index cef158fa..89d2055f 100644
--- a/src/resources/spritedef.h
+++ b/src/resources/spritedef.h
@@ -35,12 +35,12 @@ class ImageSet;
struct SpriteReference
{
- static SpriteReference *Empty;
-
SpriteReference() {}
- SpriteReference(std::string sprite, int variant)
- { this->sprite = sprite; this->variant = variant; }
+ SpriteReference(std::string sprite, int variant):
+ sprite(sprite),
+ variant(variant)
+ {}
std::string sprite;
int variant;
@@ -49,11 +49,11 @@ struct SpriteReference
struct SpriteDisplay
{
std::string image;
- std::list<SpriteReference*> sprites;
+ std::list<SpriteReference> sprites;
std::list<std::string> particles;
};
-typedef std::list<SpriteReference*>::const_iterator SpriteRefs;
+typedef std::list<SpriteReference>::const_iterator SpriteRefs;
/*
* Remember those are the main action.