From 4d54d36ed8e4bcc34e5b9f90e2126fadb490c34f Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 16 Sep 2014 16:44:21 +0300 Subject: Add server feature haveBrokenPlayerAttackDistance. --- src/being/localplayer.cpp | 12 ++++++++---- src/net/eathena/serverfeatures.cpp | 5 +++++ src/net/eathena/serverfeatures.h | 2 ++ src/net/serverfeatures.h | 2 ++ src/net/tmwa/serverfeatures.cpp | 5 +++++ src/net/tmwa/serverfeatures.h | 2 ++ 6 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index fd3acd4f9..d5e32316c 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -1117,18 +1117,20 @@ void LocalPlayer::moveToTarget(int dist) dist = settings.moveToTargetType; if (dist != 0) { + const bool broken = Net::getServerFeatures() + ->haveBrokenPlayerAttackDistance(); switch (dist) { case 10: dist = mAttackRange; - if (dist == 1 && serverVersion < 1) + if (dist == 1 && broken) dist = 2; break; case 11: dist = mAttackRange - 1; if (dist < 1) dist = 1; - if (dist == 1 && serverVersion < 1) + if (dist == 1 && broken) dist = 2; break; default: @@ -2746,10 +2748,12 @@ void LocalPlayer::attack2(Being *const target, const bool keep, if (!dontChangeEquipment && target) changeEquipmentBeforeAttack(target); + const bool broken = Net::getServerFeatures() + ->haveBrokenPlayerAttackDistance(); + // probably need cache getPathLength(target) if ((!target || settings.attackType == 0 || settings.attackType == 3) - || (withinAttackRange(target, serverVersion < 1, - serverVersion < 1 ? 1 : 0) + || (withinAttackRange(target, broken, broken ? 1 : 0) && getPathLength(target) <= getAttackRange2())) { attack(target, keep); diff --git a/src/net/eathena/serverfeatures.cpp b/src/net/eathena/serverfeatures.cpp index 94af844b8..f724d663a 100644 --- a/src/net/eathena/serverfeatures.cpp +++ b/src/net/eathena/serverfeatures.cpp @@ -62,4 +62,9 @@ bool ServerFeatures::havePlayerStatusUpdate() const return false; } +bool ServerFeatures::haveBrokenPlayerAttackDistance() const +{ + return false; +} + } // namespace EAthena diff --git a/src/net/eathena/serverfeatures.h b/src/net/eathena/serverfeatures.h index a11e73a40..fcd4cc97a 100644 --- a/src/net/eathena/serverfeatures.h +++ b/src/net/eathena/serverfeatures.h @@ -45,6 +45,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveLangTab() const override final; bool havePlayerStatusUpdate() const override final; + + bool haveBrokenPlayerAttackDistance() const override final; }; } // namespace EAthena diff --git a/src/net/serverfeatures.h b/src/net/serverfeatures.h index f84464b5d..b3407d2b0 100644 --- a/src/net/serverfeatures.h +++ b/src/net/serverfeatures.h @@ -42,6 +42,8 @@ class ServerFeatures notfinal virtual bool haveLangTab() const = 0; virtual bool havePlayerStatusUpdate() const = 0; + + virtual bool haveBrokenPlayerAttackDistance() const = 0; }; } // namespace Net diff --git a/src/net/tmwa/serverfeatures.cpp b/src/net/tmwa/serverfeatures.cpp index 28f0a3cee..86f679ae9 100644 --- a/src/net/tmwa/serverfeatures.cpp +++ b/src/net/tmwa/serverfeatures.cpp @@ -64,4 +64,9 @@ bool ServerFeatures::havePlayerStatusUpdate() const return serverVersion >= 4; } +bool ServerFeatures::haveBrokenPlayerAttackDistance() const +{ + return serverVersion < 1; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/serverfeatures.h b/src/net/tmwa/serverfeatures.h index 87a1b61b0..8bf7288b3 100644 --- a/src/net/tmwa/serverfeatures.h +++ b/src/net/tmwa/serverfeatures.h @@ -45,6 +45,8 @@ class ServerFeatures final : public Net::ServerFeatures bool haveLangTab() const override final; bool havePlayerStatusUpdate() const override final; + + bool haveBrokenPlayerAttackDistance() const override final; }; } // namespace TmwAthena -- cgit v1.2.3-70-g09d2