summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/actionmanager.cpp2
-rw-r--r--src/being/localplayer.cpp41
-rw-r--r--src/being/localplayer.h8
-rw-r--r--src/game.cpp4
-rw-r--r--src/gamemodifiers.cpp29
-rw-r--r--src/gamemodifiers.h4
-rw-r--r--src/gui/popups/statuspopup.cpp2
-rw-r--r--src/gui/windows/statuswindow.cpp2
-rw-r--r--src/settings.h2
9 files changed, 46 insertions, 48 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 07e452117..65edb562a 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -519,7 +519,7 @@ impHandler0(changeAttackWeaponType)
impHandler0(changeAttackType)
{
- callYellowBar(changeAttackType);
+ callYellowBar2(changeAttackType);
}
impHandler0(changeFollowMode)
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index aed4a17e2..aaaf2e411 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -119,7 +119,6 @@ LocalPlayer::LocalPlayer(const int id, const uint16_t subtype) :
mPickUpType(config.getIntValue("pickUpType")),
mMagicAttackType(config.getIntValue("magicAttackType")),
mPvpAttackType(config.getIntValue("pvpAttackType")),
- mAttackType(config.getIntValue("attackType")),
mImitationMode(config.getIntValue("imitationMode")),
mLastTargetX(0),
mLastTargetY(0),
@@ -558,7 +557,7 @@ void LocalPlayer::setDestination(const int x, const int y)
{
mActivityTime = cur_time;
- if (getAttackType() == 0 || !mAttackMoving)
+ if (settings.attackType == 0 || !mAttackMoving)
mKeepAttacking = false;
// Only send a new message to the server when destination changes
@@ -1261,34 +1260,6 @@ void LocalPlayer::changeMode(unsigned *restrict const var,
debugMsg(str.substr(4));
}
-const unsigned attackTypeSize = 4;
-
-void LocalPlayer::changeAttackType(const bool forward)
-{
- changeMode(&mAttackType, attackTypeSize, "attackType",
- &LocalPlayer::getAttackTypeString, 0, true, forward);
-}
-
-static const char *const attackTypeStrings[] =
-{
- // TRANSLATORS: attack type in status bar
- N_("(D) default attack"),
- // TRANSLATORS: attack type in status bar
- N_("(G) go and attack"),
- // TRANSLATORS: attack type in status bar
- N_("(A) go, attack, pickup"),
- // TRANSLATORS: attack type in status bar
- N_("(d) without auto attack"),
- // TRANSLATORS: attack type in status bar
- N_("(?) attack")
-};
-
-std::string LocalPlayer::getAttackTypeString()
-{
- return gettext(getVarItem(&attackTypeStrings[0],
- mAttackType, attackTypeSize));
-}
-
const unsigned quickDropCounterSize = 31;
void LocalPlayer::changeQuickDropCounter(const bool forward)
@@ -3121,13 +3092,13 @@ void LocalPlayer::attack2(Being *const target, const bool keep,
changeEquipmentBeforeAttack(target);
// probably need cache getPathLength(target)
- if ((!target || mAttackType == 0 || mAttackType == 3)
+ if ((!target || settings.attackType == 0 || settings.attackType == 3)
|| (withinAttackRange(target, serverVersion < 1,
serverVersion < 1 ? 1 : 0)
&& getPathLength(target) <= getAttackRange2()))
{
attack(target, keep);
- if (mAttackType == 2)
+ if (settings.attackType == 2)
{
if (!target)
{
@@ -3142,7 +3113,7 @@ void LocalPlayer::attack2(Being *const target, const bool keep,
}
else if (!mPickUpTarget)
{
- if (mAttackType == 2)
+ if (settings.attackType == 2)
{
if (pickUpItems())
return;
@@ -3457,7 +3428,7 @@ void LocalPlayer::fixAttackTarget()
if (!mMap || !mTarget)
return;
- if (settings.moveToTargetType == 7 || !mAttackType
+ if (settings.moveToTargetType == 7 || !settings.attackType
|| !config.getBoolValue("autofixPos"))
{
return;
@@ -3557,7 +3528,7 @@ void LocalPlayer::resetYellowBar()
settings.moveToTargetType = config.resetIntValue("moveToTargetType");
settings.followMode = config.resetIntValue("followMode");
settings.attackWeaponType = config.resetIntValue("attackWeaponType");
- mAttackType = config.resetIntValue("attackType");
+ settings.attackType = config.resetIntValue("attackType");
mMagicAttackType = config.resetIntValue("magicAttackType");
mPvpAttackType = config.resetIntValue("pvpAttackType");
mQuickDropCounter = config.resetIntValue("quickDropCounter");
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 711582125..4225be4a0 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -186,14 +186,9 @@ class LocalPlayer final : public Being,
bool isPathSetByMouse() const A_WARN_UNUSED
{ return mPathSetByMouse; }
- int getAttackType() const A_WARN_UNUSED
- { return mAttackType; }
-
int getImitationMode() const A_WARN_UNUSED
{ return mImitationMode; }
- void changeAttackType(const bool forward);
-
void changeImitationMode(const bool forward);
void changePickUpType(const bool forward);
@@ -429,8 +424,6 @@ class LocalPlayer final : public Being,
void setTestParticle(const std::string &fileName,
const bool updateHash = true);
- std::string getAttackTypeString();
-
std::string getQuickDropCounterString();
std::string getPickUpTypeString();
@@ -517,7 +510,6 @@ class LocalPlayer final : public Being,
unsigned int mMagicAttackType;
// pvp attack type
unsigned int mPvpAttackType;
- unsigned int mAttackType;
unsigned int mImitationMode;
int mLastTargetX;
diff --git a/src/game.cpp b/src/game.cpp
index 877204a4d..f282cbeae 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -1059,7 +1059,7 @@ void Game::changeMap(const std::string &mapPath)
void Game::updateHistory(const SDL_Event &event)
{
- if (!player_node || !player_node->getAttackType())
+ if (!player_node || !settings.attackType)
return;
if (static_cast<int>(event.key.keysym.sym) != -1)
@@ -1116,7 +1116,7 @@ void Game::checkKeys()
const int timeRange = 120;
const int cntInTime = 130;
- if (!player_node || !player_node->getAttackType())
+ if (!player_node || !settings.attackType)
return;
const int time = cur_time;
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp
index e04629301..6fa606408 100644
--- a/src/gamemodifiers.cpp
+++ b/src/gamemodifiers.cpp
@@ -41,6 +41,7 @@ GameModifiers::GameModifiers()
settings.moveToTargetType = config.getIntValue("moveToTargetType");
settings.followMode = config.getIntValue("followMode");
settings.attackWeaponType = config.getIntValue("attackWeaponType");
+ settings.attackType = config.getIntValue("attackType");
}
GameModifiers::~GameModifiers()
@@ -253,3 +254,31 @@ std::string GameModifiers::getAttackWeaponTypeString()
return gettext(getVarItem(&attackWeaponTypeStrings[0],
settings.attackWeaponType, attackWeaponTypeSize));
}
+
+const unsigned attackTypeSize = 4;
+
+void GameModifiers::changeAttackType(const bool forward)
+{
+ changeMode(&settings.attackType, attackTypeSize, "attackType",
+ &GameModifiers::getAttackTypeString, 0, true, forward);
+}
+
+static const char *const attackTypeStrings[] =
+{
+ // TRANSLATORS: attack type in status bar
+ N_("(D) default attack"),
+ // TRANSLATORS: attack type in status bar
+ N_("(G) go and attack"),
+ // TRANSLATORS: attack type in status bar
+ N_("(A) go, attack, pickup"),
+ // TRANSLATORS: attack type in status bar
+ N_("(d) without auto attack"),
+ // TRANSLATORS: attack type in status bar
+ N_("(?) attack")
+};
+
+std::string GameModifiers::getAttackTypeString()
+{
+ return gettext(getVarItem(&attackTypeStrings[0],
+ settings.attackType, attackTypeSize));
+}
diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h
index 9c1e21953..1ede2d49a 100644
--- a/src/gamemodifiers.h
+++ b/src/gamemodifiers.h
@@ -52,6 +52,8 @@ class GameModifiers final
void changeAttackWeaponType(const bool forward);
+ void changeAttackType(const bool forward);
+
std::string getMoveTypeString();
std::string getCrazyMoveTypeString();
@@ -62,6 +64,8 @@ class GameModifiers final
std::string getAttackWeaponTypeString();
+ std::string getAttackTypeString();
+
protected:
static const char *getVarItem(const char *const *const arr,
const unsigned index,
diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp
index 5a5c27e12..8275e1748 100644
--- a/src/gui/popups/statuspopup.cpp
+++ b/src/gui/popups/statuspopup.cpp
@@ -150,7 +150,7 @@ void StatusPopup::updateLabels() const
InputAction::CHANGE_FOLLOW_MODE);
setLabelText(4, modifiers->getAttackWeaponTypeString(),
InputAction::CHANGE_ATTACK_WEAPON_TYPE);
- setLabelText(5, player_node->getAttackTypeString(),
+ setLabelText(5, modifiers->getAttackTypeString(),
InputAction::CHANGE_ATTACK_TYPE);
setLabelText(6, player_node->getQuickDropCounterString(),
InputAction::SWITCH_QUICK_DROP);
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 718234814..5be44f76b 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -648,7 +648,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
.append(translateLetter2(modifiers->getFollowModeString()))
.append(" ").append(translateLetter2(
modifiers->getAttackWeaponTypeString()))
- .append(translateLetter2(player_node->getAttackTypeString()))
+ .append(translateLetter2(modifiers->getAttackTypeString()))
.append(translateLetter2(player_node->getMagicAttackString()))
.append(translateLetter2(player_node->getPvpAttackString()))
.append(" ").append(translateLetter2(
diff --git a/src/settings.h b/src/settings.h
index 668079707..05c24a9b4 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -57,6 +57,7 @@ class Settings final
moveToTargetType(0U),
followMode(0U),
attackWeaponType(0U),
+ attackType(0U),
persistentIp(true),
limitFps(false),
inputFocused(true),
@@ -88,6 +89,7 @@ class Settings final
unsigned int moveToTargetType;
unsigned int followMode;
unsigned int attackWeaponType;
+ unsigned int attackType;
bool persistentIp;
bool limitFps;
bool inputFocused;