summaryrefslogtreecommitdiff
path: root/src/resources/db/horsedb.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-18 20:00:38 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-18 20:08:15 +0300
commitcf6a135902b647b565e782e9cb9626b7ac8b361b (patch)
treea6cebb27ca4f89ea5e559958dac2a4af9afa87d2 /src/resources/db/horsedb.cpp
parenta3ad4ab670c7fa776375f569e9fe9d7fbe227245 (diff)
downloadmanaverse-cf6a135902b647b565e782e9cb9626b7ac8b361b.tar.gz
manaverse-cf6a135902b647b565e782e9cb9626b7ac8b361b.tar.bz2
manaverse-cf6a135902b647b565e782e9cb9626b7ac8b361b.tar.xz
manaverse-cf6a135902b647b565e782e9cb9626b7ac8b361b.zip
Add support for multiply sprites in each horse part.
Also fix horse sprites actions issue.
Diffstat (limited to 'src/resources/db/horsedb.cpp')
-rw-r--r--src/resources/db/horsedb.cpp49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp
index 41754bd77..df1e6345c 100644
--- a/src/resources/db/horsedb.cpp
+++ b/src/resources/db/horsedb.cpp
@@ -21,13 +21,14 @@
#include "resources/db/horsedb.h"
-#include "animatedsprite.h"
#include "configuration.h"
#include "logger.h"
#include "resources/beingcommon.h"
#include "resources/horseinfo.h"
+#include "utils/dtor.h"
+
#include "debug.h"
namespace
@@ -38,11 +39,15 @@ namespace
}
#define loadSprite(name) \
- currentInfo->name = AnimatedSprite::load( \
- paths.getStringValue("sprites").append(std::string( \
- reinterpret_cast<const char*>( \
- spriteNode->xmlChildrenNode->content))), \
- XML::getProperty(spriteNode, "variant", 0))
+ { \
+ SpriteReference *const currentSprite = new SpriteReference; \
+ currentSprite->sprite = paths.getStringValue("sprites").append( \
+ std::string(reinterpret_cast<const char*>( \
+ spriteNode->xmlChildrenNode->content))); \
+ currentSprite->variant = XML::getProperty( \
+ spriteNode, "variant", 0); \
+ currentInfo->name.push_back(currentSprite); \
+ }
static void loadDownSprites(XmlNodePtrConst parentNode,
HorseInfo *currentInfo);
@@ -55,10 +60,18 @@ void HorseDB::load()
if (mLoaded)
unload();
- mUnknown.downSprite = AnimatedSprite::load(
+ SpriteReference *currentSprite = new SpriteReference;
+ currentSprite->sprite = paths.getStringValue("sprites").append(
paths.getStringValue("spriteErrorFile"));
- mUnknown.upSprite = AnimatedSprite::load(
+ currentSprite->variant = 0;
+ mUnknown.downSprites.push_back(currentSprite);
+
+ currentSprite = new SpriteReference;
+ currentSprite->sprite = paths.getStringValue("sprites").append(
paths.getStringValue("spriteErrorFile"));
+ currentSprite->variant = 0;
+ mUnknown.upSprites.push_back(currentSprite);
+
mUnknown.upOffsetX = 0;
mUnknown.upOffsetY = 0;
mUnknown.downOffsetX = 0;
@@ -129,7 +142,7 @@ void HorseDB::loadXmlFile(const std::string &fileName)
continue;
if (xmlNameEqual(spriteNode, "sprite"))
- loadSprite(downSprite);
+ loadSprite(downSprites)
if (xmlNameEqual(spriteNode, "down"))
loadDownSprites(spriteNode, currentInfo);
@@ -149,10 +162,7 @@ static void loadDownSprites(XmlNodePtrConst parentNode,
continue;
if (xmlNameEqual(spriteNode, "sprite"))
- {
- loadSprite(downSprite);
- return;
- }
+ loadSprite(downSprites)
}
}
@@ -165,10 +175,7 @@ static void loadUpSprites(XmlNodePtrConst parentNode,
continue;
if (xmlNameEqual(spriteNode, "sprite"))
- {
- loadSprite(upSprite);
- return;
- }
+ loadSprite(upSprites)
}
}
@@ -176,14 +183,14 @@ void HorseDB::unload()
{
FOR_EACH (HorseInfos::const_iterator, i, mHorseInfos)
{
- delete i->second->upSprite;
- delete i->second->downSprite;
+ delete_all(i->second->upSprites);
+ delete_all(i->second->downSprites);
delete i->second;
}
mHorseInfos.clear();
- delete mUnknown.upSprite;
- delete mUnknown.downSprite;
+ delete_all(mUnknown.upSprites);
+ delete_all(mUnknown.downSprites);
mLoaded = false;
}