From 4d96a14a3922a21be3f93773c26a42a82c49b589 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Thu, 30 Oct 2008 03:11:07 +0000 Subject: Fixed a small targeting issue that arose from having uninitialized data at the start. --- src/localplayer.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index ee73b673..dccd3914 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -53,8 +53,9 @@ LocalPlayer::LocalPlayer(Uint32 id, Uint16 job, Map *map): mXp(0), mNetwork(0), mTarget(NULL), mPickUpTarget(NULL), mTrading(false), mGoingToTarget(false), - mLastAction(-1), - mWalkingDir(0), mDestX(0), mDestY(0), + mTargetTime(-1), mLastAction(-1), + mLastTarget(-1), mWalkingDir(0), + mDestX(0), mDestY(0), mInventory(new Inventory(INVENTORY_SIZE)), mStorage(new Inventory(STORAGE_SIZE)) { @@ -115,17 +116,15 @@ void LocalPlayer::logic() if (get_elapsed_time(mLastAction) >= 1000) { mLastAction = -1; } - // Targeting allowed 4 times a second if (get_elapsed_time(mLastTarget) >= 250) { mLastTarget = -1; } - // Remove target if its been on a being for more than a minute if (get_elapsed_time(mTargetTime) >= 60000) { mTargetTime = -1; - setTarget(mTarget); + setTarget(NULL); mLastTarget = -1; } @@ -290,15 +289,15 @@ void LocalPlayer::setTarget(Being *target) return; mLastTarget = tick_time; - if (target) - { - mTargetTime = tick_time; - } - if ((target == NULL) || target == mTarget) { target = NULL; mKeepAttacking = false; + mTargetTime = -1; + } + if (target) + { + mTargetTime = tick_time; } if (mTarget && mTarget->getType() == Being::MONSTER) { -- cgit v1.2.3-70-g09d2