summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-08-28 20:29:06 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-08-28 20:29:06 +0000
commitbdb09d26fc6c489228cb2c28be75024f9a49eb75 (patch)
tree28ea782fa98c6fe8b060da71a0bb626781ab1b5d /src/localplayer.cpp
parent9a8456c6c95f5d95c568664ba5adaeb466cfbb0d (diff)
downloadmana-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.cpp28
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);
}