diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-10-29 18:03:57 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-10-29 18:03:57 +0000 |
commit | d8c5a6029a325a1c21431b5836e44e4510898973 (patch) | |
tree | 83ad8cfa826fd0a19f730be9745670de41531ee9 /src/player.cpp | |
parent | 738e404b64c76d6c242bef32a37c5904915fcea3 (diff) | |
download | mana-d8c5a6029a325a1c21431b5836e44e4510898973.tar.gz mana-d8c5a6029a325a1c21431b5836e44e4510898973.tar.bz2 mana-d8c5a6029a325a1c21431b5836e44e4510898973.tar.xz mana-d8c5a6029a325a1c21431b5836e44e4510898973.zip |
Fixed excessive unnecessary reloading of sprites. Also updated NEWS file.
Diffstat (limited to 'src/player.cpp')
-rw-r--r-- | src/player.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/player.cpp b/src/player.cpp index 1658840a..0ba99fe7 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -108,12 +108,12 @@ Player::setHairColor(Uint16 color) { if (color != mHairColor && mHairStyle > 0) { - delete mSprites[HAIR_SPRITE]; AnimatedSprite *newHairSprite = new AnimatedSprite( "graphics/sprites/hairstyle" + toString(mHairStyle) + ".xml", color - 1); newHairSprite->setDirection(getSpriteDirection()); + delete mSprites[HAIR_SPRITE]; mSprites[HAIR_SPRITE] = newHairSprite; resetAnimations(); @@ -128,12 +128,12 @@ Player::setHairStyle(Uint16 style) { if (style != mHairStyle && mHairColor > 0) { - delete mSprites[HAIR_SPRITE]; AnimatedSprite *newHairSprite = new AnimatedSprite( "graphics/sprites/hairstyle" + toString(style) + ".xml", mHairColor - 1); newHairSprite->setDirection(getSpriteDirection()); + delete mSprites[HAIR_SPRITE]; mSprites[HAIR_SPRITE] = newHairSprite; resetAnimations(); @@ -160,11 +160,14 @@ Player::setVisibleEquipment(Uint8 slot, Uint8 id) break; } - delete mSprites[position]; - mSprites[position] = NULL; - // id = 0 means unequip - if (id) { + if (id == 0) + { + delete mSprites[position]; + mSprites[position] = NULL; + } + else + { char stringId[4]; sprintf(stringId, "%03i", id); @@ -172,6 +175,7 @@ Player::setVisibleEquipment(Uint8 slot, Uint8 id) "graphics/sprites/item" + toString(stringId) + ".xml", 0); equipmentSprite->setDirection(getSpriteDirection()); + delete mSprites[position]; mSprites[position] = equipmentSprite; resetAnimations(); |