summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/being/being.cpp32
-rw-r--r--src/being/being.h3
-rw-r--r--src/resources/db/horsedb.cpp6
-rw-r--r--src/resources/db/horsedb.h4
4 files changed, 39 insertions, 6 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index ed9f03179..9e9316417 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -68,6 +68,7 @@
#include "resources/chatobject.h"
#include "resources/emoteinfo.h"
#include "resources/emotesprite.h"
+#include "resources/horseinfo.h"
#include "resources/iteminfo.h"
#include "resources/spriteaction.h"
@@ -182,6 +183,8 @@ Being::Being(const int id,
mOwner(nullptr),
mSpecialParticle(nullptr),
mChat(nullptr),
+ mHorseInfo(nullptr),
+ mHorseSprite(nullptr),
mX(0),
mY(0),
mSortOffsetY(0),
@@ -1312,6 +1315,8 @@ void Being::setAction(const BeingAction::Action &action, const int attackId)
mEmotionSprite->play(currentAction);
if (mAnimationEffect)
mAnimationEffect->play(currentAction);
+ if (mHorseSprite)
+ mHorseSprite->play(currentAction);
mAction = action;
}
@@ -1371,6 +1376,8 @@ void Being::setDirection(const uint8_t direction)
mEmotionSprite->setSpriteDirection(dir);
if (mAnimationEffect)
mAnimationEffect->setSpriteDirection(dir);
+ if (mHorseSprite)
+ mHorseSprite->setSpriteDirection(dir);
recalcSpritesOrder();
}
@@ -1459,6 +1466,8 @@ void Being::logic()
const int time = tick_time * MILLISECONDS_IN_A_TICK;
if (mEmotionSprite)
mEmotionSprite->update(time);
+ if (mHorseSprite)
+ mHorseSprite->update(time);
if (mAnimationEffect)
{
@@ -2408,12 +2417,23 @@ void Being::talkTo() const
}
void Being::draw(Graphics *const graphics,
- const int offsetX, const int offsetY) const
+ const int offsetX,
+ const int offsetY) const
{
if (!mErased)
{
const int px = getActorX() + offsetX;
const int py = getActorY() + offsetY;
+ if (mHorseInfo)
+ {
+ AnimatedSprite *const sprite = mHorseInfo->sprite;
+ if (sprite)
+ {
+ sprite->draw(graphics,
+ px + mHorseInfo->offsetX,
+ py + mHorseInfo->offsetY);
+ }
+ }
ActorSprite::draw1(graphics, px, py);
drawSpriteAt(graphics, px, py);
}
@@ -3578,4 +3598,14 @@ void Being::setRiding(const bool b)
return;
mRiding = b;
setAction(mAction, 0);
+ if (b)
+ {
+ mHorseInfo = HorseDB::get(1);
+ mHorseSprite = mHorseInfo->sprite;
+ }
+ else
+ {
+ mHorseInfo = nullptr;
+ mHorseSprite = nullptr;
+ }
}
diff --git a/src/being/being.h b/src/being/being.h
index 994733727..8d4ec6069 100644
--- a/src/being/being.h
+++ b/src/being/being.h
@@ -63,6 +63,7 @@ class SpeechBubble;
class Text;
struct ChatObject;
+struct HorseInfo;
struct ParticleInfo;
extern volatile int cur_time;
@@ -1050,6 +1051,8 @@ class Being notfinal : public ActorSprite,
Being *mOwner;
Particle *mSpecialParticle;
ChatObject *mChat;
+ HorseInfo *mHorseInfo;
+ AnimatedSprite *mHorseSprite;
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 315cd09d0..6da742d3a 100644
--- a/src/resources/db/horsedb.cpp
+++ b/src/resources/db/horsedb.cpp
@@ -98,8 +98,8 @@ void HorseDB::loadXmlFile(const std::string &fileName)
else
currentInfo = new HorseInfo;
- currentInfo->offsetX = XML::getProperty(horseNode, "x", 0);
- currentInfo->offsetY = XML::getProperty(horseNode, "y", 0);
+ currentInfo->offsetX = XML::getProperty(horseNode, "offsetX", 0);
+ currentInfo->offsetY = XML::getProperty(horseNode, "offsetY", 0);
for_each_xml_child_node(spriteNode, horseNode)
{
@@ -134,7 +134,7 @@ void HorseDB::unload()
mLoaded = false;
}
-const HorseInfo *HorseDB::get(const int id, const bool allowNull)
+HorseInfo *HorseDB::get(const int id, const bool allowNull)
{
const HorseInfos::const_iterator i = mHorseInfos.find(id);
diff --git a/src/resources/db/horsedb.h b/src/resources/db/horsedb.h
index 94809c337..93134a9b1 100644
--- a/src/resources/db/horsedb.h
+++ b/src/resources/db/horsedb.h
@@ -46,8 +46,8 @@ namespace HorseDB
void unload();
- const HorseInfo *get(const int id,
- const bool allowNull = false) A_WARN_UNUSED;
+ HorseInfo *get(const int id,
+ const bool allowNull = false) A_WARN_UNUSED;
int size();