summaryrefslogtreecommitdiff
path: root/src/localplayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/localplayer.cpp')
-rw-r--r--src/localplayer.cpp40
1 files changed, 24 insertions, 16 deletions
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index c83082a44..3df4a3214 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -2,7 +2,7 @@
* The ManaPlus Client
* Copyright (C) 2004-2009 The Mana World Development Team
* Copyright (C) 2009-2010 The Mana Developers
- * Copyright (C) 2011 The ManaPlus Developers
+ * Copyright (C) 2011-2012 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
@@ -98,7 +98,7 @@ extern MiniStatusWindow *miniStatusWindow;
extern SkillDialog *skillDialog;
LocalPlayer::LocalPlayer(int id, int subtype):
- Being(id, PLAYER, subtype, 0),
+ Being(id, PLAYER, subtype, nullptr),
mTargetTime(-1),
mLastTarget(-1),
mTarget(nullptr),
@@ -112,7 +112,7 @@ LocalPlayer::LocalPlayer(int id, int subtype):
mPathSetByMouse(false),
mLocalWalkTime(-1),
mMessageTime(0),
- mAwayDialog(0),
+ mAwayDialog(nullptr),
mAfkTime(0),
mAwayMode(false),
mPseudoAwayMode(false),
@@ -151,12 +151,12 @@ LocalPlayer::LocalPlayer(int id, int subtype):
if (userPalette)
mNameColor = &userPalette->getColor(UserPalette::SELF);
else
- mNameColor = 0;
+ mNameColor = nullptr;
mLastTargetX = 0;
mLastTargetY = 0;
- mInvertDirection = config.getIntValue("invertMoveDirection");
+ mInvertDirection = 0;
mCrazyMoveType = config.getIntValue("crazyMoveType");
mCrazyMoveState = 0;
mAttackWeaponType = config.getIntValue("attackWeaponType");
@@ -381,7 +381,8 @@ void LocalPlayer::setAction(Action action, int attackType)
mLastTarget = -1;
if (!mLastHitFrom.empty())
{
- debugMsg(_("You were killed by ") + mLastHitFrom);
+ debugMsg(strprintf(_("You were killed by %s"),
+ mLastHitFrom.c_str()));
mLastHitFrom = "";
}
setTarget(nullptr);
@@ -1437,13 +1438,17 @@ void LocalPlayer::pickedUp(const ItemInfo &itemInfo, int amount,
case PICKUP_BAD_ITEM:
msg = N_("Tried to pick up nonexistent item.");
break;
- case PICKUP_TOO_HEAVY: msg = N_("Item is too heavy.");
+ case PICKUP_TOO_HEAVY:
+ msg = N_("Item is too heavy.");
break;
- case PICKUP_TOO_FAR: msg = N_("Item is too far away.");
+ case PICKUP_TOO_FAR:
+ msg = N_("Item is too far away.");
break;
- case PICKUP_INV_FULL: msg = N_("Inventory is full.");
+ case PICKUP_INV_FULL:
+ msg = N_("Inventory is full.");
break;
- case PICKUP_STACK_FULL: msg = N_("Stack is too big.");
+ case PICKUP_STACK_FULL:
+ msg = N_("Stack is too big.");
break;
case PICKUP_DROP_STEAL:
msg = N_("Item belongs to someone else.");
@@ -1777,7 +1782,7 @@ void LocalPlayer::moveToTarget(unsigned int dist)
case 6:
case 7:
dist = mAttackRange;
- if (dist == 1)
+ if (dist == 1 && serverVersion < 1)
dist = 2;
default:
break;
@@ -1866,12 +1871,14 @@ void LocalPlayer::moveToHome()
static const unsigned invertDirectionSize = 5;
void LocalPlayer::changeMode(unsigned *var, unsigned limit, const char *conf,
- std::string (LocalPlayer::*func)(), unsigned def)
+ std::string (LocalPlayer::*func)(), unsigned def,
+ bool save)
{
(*var) ++;
if (*var >= limit)
*var = def;
- config.setValue(conf, *var);
+ if (save)
+ config.setValue(conf, *var);
if (miniStatusWindow)
miniStatusWindow->updateStatus();
const std::string str = (this->*func)();
@@ -1883,7 +1890,7 @@ void LocalPlayer::invertDirection()
{
mMoveState = 0;
changeMode(&mInvertDirection, invertDirectionSize, "invertMoveDirection",
- &LocalPlayer::getInvertDirectionString);
+ &LocalPlayer::getInvertDirectionString, 0, false);
}
static const char *invertDirectionStrings[] =
@@ -3709,7 +3716,8 @@ void LocalPlayer::attack2(Being *target, bool keep, bool dontChangeEquipment)
changeEquipmentBeforeAttack(target);
if ((!target || getAttackType() == 0 || getAttackType() == 3)
- || (withinAttackRange(target, true, 1)
+ || (withinAttackRange(target, serverVersion < 1,
+ serverVersion < 1 ? 1 : 0)
&& getPathLength(target) <= getAttackRange2()))
{
attack(target, keep);
@@ -4122,7 +4130,7 @@ void LocalPlayer::checkNewName(Being *being)
void LocalPlayer::resetYellowBar()
{
- mInvertDirection = config.resetIntValue("invertMoveDirection");
+ mInvertDirection = 0;
mCrazyMoveType = config.resetIntValue("crazyMoveType");
mMoveToTargetType = config.resetIntValue("moveToTargetType");
mFollowMode = config.resetIntValue("followMode");