diff options
author | Ira Rice <irarice@gmail.com> | 2008-10-30 03:11:07 +0000 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2008-10-30 03:11:07 +0000 |
commit | 4d96a14a3922a21be3f93773c26a42a82c49b589 (patch) | |
tree | b29eb67ae8d12edfa4a8519c234ce3a632d7fe72 /src | |
parent | f50e0ea375bf9053b04a9b0349ca73caf7a08ba4 (diff) | |
download | mana-4d96a14a3922a21be3f93773c26a42a82c49b589.tar.gz mana-4d96a14a3922a21be3f93773c26a42a82c49b589.tar.bz2 mana-4d96a14a3922a21be3f93773c26a42a82c49b589.tar.xz mana-4d96a14a3922a21be3f93773c26a42a82c49b589.zip |
Fixed a small targeting issue that arose from having uninitialized data
at the start.
Diffstat (limited to 'src')
-rw-r--r-- | src/localplayer.cpp | 19 |
1 files 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) { |