summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-10-18 15:37:01 +0300
committerAndrei Karas <akaras@inbox.ru>2015-10-18 15:37:01 +0300
commitae7d05fce2107e762e84a287f33f2dbad60abd7d (patch)
treea9d8ce99e98eda697c2b4e8e19d8473b8fedc14a
parent3e1eec6460461242ff6548f8c542e0c020d18c4a (diff)
downloadmanaplus-ae7d05fce2107e762e84a287f33f2dbad60abd7d.tar.gz
manaplus-ae7d05fce2107e762e84a287f33f2dbad60abd7d.tar.bz2
manaplus-ae7d05fce2107e762e84a287f33f2dbad60abd7d.tar.xz
manaplus-ae7d05fce2107e762e84a287f33f2dbad60abd7d.zip
Split horse into two sprites before player and after player.
-rw-r--r--src/being/being.cpp54
-rw-r--r--src/being/being.h3
-rw-r--r--src/resources/db/horsedb.cpp37
-rw-r--r--src/resources/horseinfo.h18
4 files changed, 77 insertions, 35 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index b8f4ce414..711fcf233 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -194,7 +194,8 @@ Being::Being(const BeingId id,
#ifdef EATHENA_SUPPORT
mChat(nullptr),
mHorseInfo(nullptr),
- mHorseSprite(nullptr),
+ mDownHorseSprite(nullptr),
+ mUpHorseSprite(nullptr),
#endif
mX(0),
mY(0),
@@ -1439,8 +1440,10 @@ void Being::setAction(const BeingActionT &action, const int attackId)
sprite->play(currentAction);
}
#ifdef EATHENA_SUPPORT
- if (mHorseSprite)
- mHorseSprite->play(currentAction);
+ if (mDownHorseSprite)
+ mDownHorseSprite->play(currentAction);
+ if (mUpHorseSprite)
+ mUpHorseSprite->play(currentAction);
#endif
mAction = action;
}
@@ -1510,8 +1513,10 @@ void Being::setDirection(const uint8_t direction)
}
#ifdef EATHENA_SUPPORT
- if (mHorseSprite)
- mHorseSprite->setSpriteDirection(dir);
+ if (mDownHorseSprite)
+ mDownHorseSprite->setSpriteDirection(dir);
+ if (mUpHorseSprite)
+ mUpHorseSprite->setSpriteDirection(dir);
#endif
recalcSpritesOrder();
}
@@ -1603,8 +1608,10 @@ void Being::logic()
if (mEmotionSprite)
mEmotionSprite->update(time);
#ifdef EATHENA_SUPPORT
- if (mHorseSprite)
- mHorseSprite->update(time);
+ if (mDownHorseSprite)
+ mDownHorseSprite->update(time);
+ if (mUpHorseSprite)
+ mUpHorseSprite->update(time);
#endif
if (mAnimationEffect)
@@ -2669,19 +2676,23 @@ void Being::draw(Graphics *const graphics,
const int px = getActorX() + offsetX;
const int py = getActorY() + offsetY;
#ifdef EATHENA_SUPPORT
- if (mHorseInfo)
+ if (mDownHorseSprite)
{
- AnimatedSprite *const sprite = mHorseInfo->sprite;
- if (sprite)
- {
- sprite->draw(graphics,
- px + mHorseInfo->offsetX,
- py + mHorseInfo->offsetY);
- }
+ mDownHorseSprite->draw(graphics,
+ px + mHorseInfo->downOffsetX,
+ py + mHorseInfo->downOffsetY);
}
#endif
ActorSprite::draw1(graphics, px, py);
drawSpriteAt(graphics, px, py);
+#ifdef EATHENA_SUPPORT
+ if (mUpHorseSprite)
+ {
+ mUpHorseSprite->draw(graphics,
+ px + mHorseInfo->upOffsetX,
+ py + mHorseInfo->upOffsetY);
+ }
+#endif
}
}
@@ -4031,14 +4042,21 @@ void Being::setRiding(const bool b)
{
mHorseInfo = HorseDB::get(1);
if (mHorseInfo)
- mHorseSprite = mHorseInfo->sprite;
+ {
+ mDownHorseSprite = mHorseInfo->downSprite;
+ mUpHorseSprite = mHorseInfo->upSprite;
+ }
else
- mHorseSprite = nullptr;
+ {
+ mDownHorseSprite = nullptr;
+ mUpHorseSprite = nullptr;
+ }
}
else
{
mHorseInfo = nullptr;
- mHorseSprite = nullptr;
+ mDownHorseSprite = nullptr;
+ mUpHorseSprite = nullptr;
}
}
#endif
diff --git a/src/being/being.h b/src/being/being.h
index 8253cca55..09da505c5 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -1087,7 +1087,8 @@ class Being notfinal : public ActorSprite,
ChatObject *mChat;
HorseInfo *mHorseInfo;
#endif
- AnimatedSprite *mHorseSprite;
+ AnimatedSprite *mDownHorseSprite;
+ AnimatedSprite *mUpHorseSprite;
int mX; // position in tiles
int mY; // position in tiles
diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp
index a3daf76cc..e01ebe27c 100644
--- a/src/resources/db/horsedb.cpp
+++ b/src/resources/db/horsedb.cpp
@@ -42,10 +42,14 @@ void HorseDB::load()
if (mLoaded)
unload();
- mUnknown.sprite = AnimatedSprite::load(
+ mUnknown.downSprite = AnimatedSprite::load(
paths.getStringValue("spriteErrorFile"));
- mUnknown.offsetX = 0;
- mUnknown.offsetY = 0;
+ mUnknown.upSprite = AnimatedSprite::load(
+ paths.getStringValue("spriteErrorFile"));
+ mUnknown.upOffsetX = 0;
+ mUnknown.upOffsetY = 0;
+ mUnknown.downOffsetX = 0;
+ mUnknown.downOffsetY = 0;
logger->log1("Initializing horse database...");
@@ -99,22 +103,33 @@ void HorseDB::loadXmlFile(const std::string &fileName)
if (!currentInfo)
continue;
- currentInfo->offsetX = XML::getProperty(horseNode, "offsetX", 0);
- currentInfo->offsetY = XML::getProperty(horseNode, "offsetY", 0);
+ const int offsetX = XML::getProperty(horseNode, "offsetX", 0);
+ const int offsetY = XML::getProperty(horseNode, "offsetY", 0);
+ currentInfo->upOffsetX = XML::getProperty(horseNode, "upOffsetX", offsetX);
+ currentInfo->upOffsetY = XML::getProperty(horseNode, "upOffsetY", offsetY);
+ currentInfo->downOffsetX = XML::getProperty(horseNode, "downOffsetX", offsetX);
+ currentInfo->downOffsetY = XML::getProperty(horseNode, "downOffsetY", offsetY);
for_each_xml_child_node(spriteNode, horseNode)
{
if (!spriteNode->xmlChildrenNode)
continue;
- if (xmlNameEqual(spriteNode, "sprite"))
+ if (xmlNameEqual(spriteNode, "downSprite"))
+ {
+ currentInfo->downSprite = AnimatedSprite::load(
+ paths.getStringValue("sprites").append(std::string(
+ reinterpret_cast<const char*>(
+ spriteNode->xmlChildrenNode->content))),
+ XML::getProperty(spriteNode, "variant", 0));
+ }
+ else if (xmlNameEqual(spriteNode, "upSprite"))
{
- currentInfo->sprite = AnimatedSprite::load(
+ currentInfo->upSprite = AnimatedSprite::load(
paths.getStringValue("sprites").append(std::string(
reinterpret_cast<const char*>(
spriteNode->xmlChildrenNode->content))),
XML::getProperty(spriteNode, "variant", 0));
- break;
}
}
mHorseInfos[id] = currentInfo;
@@ -125,12 +140,14 @@ void HorseDB::unload()
{
FOR_EACH (HorseInfos::const_iterator, i, mHorseInfos)
{
- delete i->second->sprite;
+ delete i->second->upSprite;
+ delete i->second->downSprite;
delete i->second;
}
mHorseInfos.clear();
- delete mUnknown.sprite;
+ delete mUnknown.upSprite;
+ delete mUnknown.downSprite;
mLoaded = false;
}
diff --git a/src/resources/horseinfo.h b/src/resources/horseinfo.h
index 262ecb7e7..860700124 100644
--- a/src/resources/horseinfo.h
+++ b/src/resources/horseinfo.h
@@ -29,16 +29,22 @@ class AnimatedSprite;
struct HorseInfo final
{
HorseInfo() :
- sprite(nullptr),
- offsetX(0),
- offsetY(0)
+ downSprite(nullptr),
+ upSprite(nullptr),
+ downOffsetX(0),
+ downOffsetY(0),
+ upOffsetX(0),
+ upOffsetY(0)
{ }
A_DELETE_COPY(HorseInfo)
- AnimatedSprite *sprite;
- int offsetX;
- int offsetY;
+ AnimatedSprite *downSprite;
+ AnimatedSprite *upSprite;
+ int downOffsetX;
+ int downOffsetY;
+ int upOffsetX;
+ int upOffsetY;
};
#endif // RESOURCES_HORSEINFO_H