diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-01-23 00:27:29 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-01-24 19:25:38 +0100 |
commit | 797e86813686aa0d6cd197cbab79f8ca889c261c (patch) | |
tree | 13cffc47dbb2eb90fc7c7c9c0e8964e2b5b2a2fc /src/actorsprite.cpp | |
parent | b856e8b47ab2dfd393e3c2720c5647eb66393931 (diff) | |
download | mana-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/actorsprite.cpp')
-rw-r--r-- | src/actorsprite.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/actorsprite.cpp b/src/actorsprite.cpp index a74a3a00..a1a3d18c 100644 --- a/src/actorsprite.cpp +++ b/src/actorsprite.cpp @@ -324,8 +324,8 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display, for (it = display.sprites.begin(), it_end = display.sprites.end(); it != it_end; it++) { - std::string file = paths.getStringValue("sprites") + (*it)->sprite; - int variant = (*it)->variant; + std::string file = paths.getStringValue("sprites") + it->sprite; + int variant = it->variant; addSprite(AnimatedSprite::load(file, variant)); } |