diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-10-19 15:44:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-10-19 15:44:14 +0300 |
commit | 3420babbbc6d10f1fc5be7ff7b895e618acd5f0e (patch) | |
tree | 92dc07613db98c4bd56f28aa8faffb99e0bde88f | |
parent | cf6a135902b647b565e782e9cb9626b7ac8b361b (diff) | |
download | plus-3420babbbc6d10f1fc5be7ff7b895e618acd5f0e.tar.gz plus-3420babbbc6d10f1fc5be7ff7b895e618acd5f0e.tar.bz2 plus-3420babbbc6d10f1fc5be7ff7b895e618acd5f0e.tar.xz plus-3420babbbc6d10f1fc5be7ff7b895e618acd5f0e.zip |
Allow support for different horses riding.
-rw-r--r-- | src/being/actorsprite.cpp | 4 | ||||
-rw-r--r-- | src/being/actorsprite.h | 4 | ||||
-rw-r--r-- | src/being/being.cpp | 29 | ||||
-rw-r--r-- | src/being/being.h | 2 | ||||
-rw-r--r-- | src/net/eathena/serverfeatures.cpp | 5 | ||||
-rw-r--r-- | src/net/eathena/serverfeatures.h | 2 | ||||
-rw-r--r-- | src/net/serverfeatures.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/serverfeatures.cpp | 5 | ||||
-rw-r--r-- | src/net/tmwa/serverfeatures.h | 2 |
9 files changed, 43 insertions, 12 deletions
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp index 0518c82fa..9b76ac328 100644 --- a/src/being/actorsprite.cpp +++ b/src/being/actorsprite.cpp @@ -66,6 +66,7 @@ ActorSprite::ActorSprite(const BeingId id) : mStunParticleEffects(), mStatusParticleEffects(&mStunParticleEffects, false), mChildParticleEffects(&mStatusParticleEffects, false), + mHorseId(0), mId(id), mStunMode(0), mUsedTargetCursor(nullptr), @@ -74,8 +75,7 @@ ActorSprite::ActorSprite(const BeingId id) : mCursorPaddingY(0), mMustResetParticles(false), mPoison(false), - mHaveCart(false), - mRiding(false) + mHaveCart(false) { } diff --git a/src/being/actorsprite.h b/src/being/actorsprite.h index 93fddedce..d5cb16613 100644 --- a/src/being/actorsprite.h +++ b/src/being/actorsprite.h @@ -177,7 +177,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor { return mHaveCart; } virtual void setRiding(const bool b) - { mRiding = b; } + { mHorseId = b ? 1 : 0; } protected: /** @@ -226,6 +226,7 @@ class ActorSprite notfinal : public CompoundSprite, public Actor ParticleList mStunParticleEffects; ParticleVector mStatusParticleEffects; ParticleList mChildParticleEffects; + int mHorseId; BeingId mId; uint16_t mStunMode; /**< Stun mode; zero if not stunned */ @@ -243,7 +244,6 @@ class ActorSprite notfinal : public CompoundSprite, public Actor bool mMustResetParticles; bool mPoison; bool mHaveCart; - bool mRiding; }; #endif // BEING_ACTORSPRITE_H diff --git a/src/being/being.cpp b/src/being/being.cpp index 03e67f327..96c94cc92 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -1249,7 +1249,7 @@ void Being::fireMissile(Being *const victim, const std::string &particle) const std::string Being::getSitAction() const { - if (mRiding) + if (mHorseId != 0) return SpriteAction::SITRIDE; if (mMap) { @@ -1267,7 +1267,7 @@ std::string Being::getSitAction() const std::string Being::getMoveAction() const { - if (mRiding) + if (mHorseId != 0) return SpriteAction::RIDE; if (mMap) { @@ -1285,7 +1285,7 @@ std::string Being::getWeaponAttackAction(const ItemInfo *const weapon) const if (!weapon) return SpriteAction::ATTACK; - if (mRiding) + if (mHorseId != 0) return weapon->getRideAttackAction(); if (mMap) { @@ -1317,7 +1317,7 @@ std::string Being::getAttackAction(const Attack *const attack1) const #define getSpriteAction(func, action) \ std::string Being::get##func##Action() const \ { \ - if (mRiding) \ + if (mHorseId != 0) \ return SpriteAction::action##RIDE; \ if (mMap) \ { \ @@ -4055,14 +4055,27 @@ void Being::removeHorse() void Being::setRiding(const bool b) { - if (b == mRiding) + if (serverFeatures->haveExtendedRiding()) return; - mRiding = b; + + if (b == (mHorseId != 0)) + return; + if (b) + setHorse(1); + else + setHorse(0); +} + +void Being::setHorse(const int horseId) +{ + if (mHorseId == horseId) + return; + mHorseId = horseId; setAction(mAction, 0); removeHorse(); - if (b) + if (mHorseId != 0) { - mHorseInfo = HorseDB::get(1); + mHorseInfo = HorseDB::get(horseId); if (mHorseInfo) { FOR_EACH (SpriteRefs, it, mHorseInfo->downSprites) diff --git a/src/being/being.h b/src/being/being.h index 8aad79698..9b6f3f6f7 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -895,6 +895,8 @@ class Being notfinal : public ActorSprite, void setRiding(const bool b) override final; + void setHorse(const int horseId); + void removeHorse(); void setSellBoard(const std::string &text); diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp index b9d349446..b3f4b7814 100644 --- a/src/net/eathena/serverfeatures.cpp +++ b/src/net/eathena/serverfeatures.cpp @@ -240,4 +240,9 @@ bool ServerFeatures::haveAdvancedSprites() const return serverVersion >= 7; } +bool ServerFeatures::haveExtendedRiding() const +{ + return serverVersion >= 9; +} + } // namespace EAthena diff --git a/src/net/eathena/serverfeatures.h b/src/net/eathena/serverfeatures.h index 04a8fb96c..b1fc7c74e 100644 --- a/src/net/eathena/serverfeatures.h +++ b/src/net/eathena/serverfeatures.h @@ -115,6 +115,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveNewGuild() const override final; bool haveAdvancedSprites() const override final; + + bool haveExtendedRiding() const override final; }; } // namespace EAthena diff --git a/src/net/serverfeatures.h b/src/net/serverfeatures.h index 53c37602a..c03d409af 100644 --- a/src/net/serverfeatures.h +++ b/src/net/serverfeatures.h @@ -112,6 +112,8 @@ class ServerFeatures notfinal virtual bool haveNewGuild() const = 0; virtual bool haveAdvancedSprites() const = 0; + + virtual bool haveExtendedRiding() const = 0; }; } // namespace Net diff --git a/src/net/tmwa/serverfeatures.cpp b/src/net/tmwa/serverfeatures.cpp index 17418268b..566bcc983 100644 --- a/src/net/tmwa/serverfeatures.cpp +++ b/src/net/tmwa/serverfeatures.cpp @@ -239,4 +239,9 @@ bool ServerFeatures::haveAdvancedSprites() const return false; } +bool ServerFeatures::haveExtendedRiding() const +{ + return false; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/serverfeatures.h b/src/net/tmwa/serverfeatures.h index 24dd88a99..33eb1457d 100644 --- a/src/net/tmwa/serverfeatures.h +++ b/src/net/tmwa/serverfeatures.h @@ -115,6 +115,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveNewGuild() const override final; bool haveAdvancedSprites() const override final; + + bool haveExtendedRiding() const override final; }; } // namespace TmwAthena |