From 797e86813686aa0d6cd197cbab79f8ca889c261c Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Mon, 23 Jan 2012 00:27:29 +0100 Subject: 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 --- src/resources/itemdb.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/resources/itemdb.cpp') diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index b9dd8e83..1cdbdff2 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -163,9 +163,9 @@ void ItemDB::loadFloorSprite(SpriteDisplay *display, xmlNodePtr floorNode) { if (xmlStrEqual(spriteNode->name, BAD_CAST "sprite")) { - SpriteReference *currentSprite = new SpriteReference; - currentSprite->sprite = (const char*)spriteNode->xmlChildrenNode->content; - currentSprite->variant = XML::getProperty(spriteNode, "variant", 0); + SpriteReference currentSprite; + currentSprite.sprite = (const char*)spriteNode->xmlChildrenNode->content; + currentSprite.variant = XML::getProperty(spriteNode, "variant", 0); display->sprites.push_back(currentSprite); } else if (xmlStrEqual(spriteNode->name, BAD_CAST "particlefx")) -- cgit v1.2.3-70-g09d2