summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-02-02 17:30:50 +0100
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2012-02-02 18:08:32 +0100
commitbe354621d3859164d3563760a9d613e356926686 (patch)
tree18dcb9fe4523c54d76b447887433e6b6daa92c79 /src
parentf5de9ae444f1bca1f6ba6969214e9a8cacb15f68 (diff)
downloadmana-be354621d3859164d3563760a9d613e356926686.tar.gz
mana-be354621d3859164d3563760a9d613e356926686.tar.bz2
mana-be354621d3859164d3563760a9d613e356926686.tar.xz
mana-be354621d3859164d3563760a9d613e356926686.zip
Remove duplicate direction computation by a call to lookAt()
It simply does the same thing, in better. Reviewed-by: Erik Schilling
Diffstat (limited to 'src')
-rw-r--r--src/localplayer.cpp20
1 files changed, 1 insertions, 19 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 212b896d..3759e5a3 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -844,25 +844,7 @@ void LocalPlayer::attack(Being *target, bool keep)
setTarget(target);
}
- Vector plaPos = this->getPosition();
- Vector tarPos = mTarget->getPosition();
- int dist_x = plaPos.x - tarPos.x;
- int dist_y = plaPos.y - tarPos.y;
-
- if (abs(dist_y) >= abs(dist_x))
- {
- if (dist_y < 0)
- setDirection(DOWN);
- else
- setDirection(UP);
- }
- else
- {
- if (dist_x < 0)
- setDirection(RIGHT);
- else
- setDirection(LEFT);
- }
+ lookAt(mTarget->getPosition());
mLastActionTime = tick_time;