diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-08-28 20:29:06 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2008-08-28 20:29:06 +0000 |
commit | bdb09d26fc6c489228cb2c28be75024f9a49eb75 (patch) | |
tree | 28ea782fa98c6fe8b060da71a0bb626781ab1b5d /src/localplayer.cpp | |
parent | 9a8456c6c95f5d95c568664ba5adaeb466cfbb0d (diff) | |
download | mana-bdb09d26fc6c489228cb2c28be75024f9a49eb75.tar.gz mana-bdb09d26fc6c489228cb2c28be75024f9a49eb75.tar.bz2 mana-bdb09d26fc6c489228cb2c28be75024f9a49eb75.tar.xz mana-bdb09d26fc6c489228cb2c28be75024f9a49eb75.zip |
Accepted Patch by Scraggy that moves text in such a way that no text overlaps
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r-- | src/localplayer.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 3929da8b..3caa5ead 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -31,6 +31,7 @@ #include "main.h" #include "particle.h" #include "sound.h" +#include "monster.h" #include "gui/gui.h" @@ -226,6 +227,23 @@ void LocalPlayer::walk(unsigned char dir) } } +void LocalPlayer::setTarget(Being *target) +{ + if (target == mTarget) + { + return; + } + if (mTarget && mTarget->getType() == Being::MONSTER) + { + static_cast<Monster *>(mTarget)->showName(false); + } + mTarget = target; + if (target && target->getType() == Being::MONSTER) + { + static_cast<Monster *>(target)->showName(true); + } +} + void LocalPlayer::setDestination(Uint16 x, Uint16 y) { // Only send a new message to the server when destination changes @@ -363,9 +381,13 @@ void LocalPlayer::attack(Being *target, bool keep) return; if (keep && target) - mTarget = target; + { + setTarget(target); + } else if (mTarget) + { target = mTarget; + } if (!target) return; @@ -411,7 +433,7 @@ void LocalPlayer::attack(Being *target, bool keep) void LocalPlayer::stopAttack() { - mTarget = NULL; + setTarget(NULL); } Being* LocalPlayer::getTarget() const @@ -454,7 +476,7 @@ bool LocalPlayer::withinAttackRange(Being *target) void LocalPlayer::setGotoTarget(Being *target) { - mTarget = target; + setTarget(target); mGoingToTarget = true; setDestination(target->mX, target->mY); } |