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.cpp33
-rw-r--r--src/being/localplayer.h9
-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
8 files changed, 40 insertions, 43 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 1ceca4a1c..cec5fce97 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -549,7 +549,7 @@ impHandler0(changeMagicAttackType)
impHandler0(changePvpMode)
{
- callYellowBar(switchPvpAttack);
+ callYellowBar2(changePvpAttackType);
}
impHandler0(changeMoveToTarget)
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 84768e443..baeb75146 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -115,7 +115,6 @@ LocalPlayer::LocalPlayer(const int id, const uint16_t subtype) :
mGMLevel(0),
mCrazyMoveState(0),
mMoveState(0),
- mPvpAttackType(config.getIntValue("pvpAttackType")),
mImitationMode(config.getIntValue("imitationMode")),
mLastTargetX(0),
mLastTargetY(0),
@@ -1286,34 +1285,6 @@ std::string LocalPlayer::getMapDrawTypeString()
viewport->getMapDrawType(), debugPathSize));
}
-const unsigned pvpAttackSize = 4;
-
-void LocalPlayer::switchPvpAttack(const bool forward)
-{
- changeMode(&mPvpAttackType, pvpAttackSize, "pvpAttackType",
- &LocalPlayer::getPvpAttackString, 0, true, forward);
-}
-
-static const char *const pvpAttackStrings[] =
-{
- // TRANSLATORS: player attack type in status bar
- N_("(a) attack all players"),
- // TRANSLATORS: player attack type in status bar
- N_("(f) attack all except friends"),
- // TRANSLATORS: player attack type in status bar
- N_("(b) attack bad relations"),
- // TRANSLATORS: player attack type in status bar
- N_("(d) don't attack players"),
- // TRANSLATORS: player attack type in status bar
- N_("(?) pvp attack")
-};
-
-std::string LocalPlayer::getPvpAttackString()
-{
- return gettext(getVarItem(&pvpAttackStrings[0],
- mPvpAttackType, pvpAttackSize));
-}
-
const unsigned imitationModeSize = 2;
void LocalPlayer::changeImitationMode(const bool forward)
@@ -3433,7 +3404,7 @@ void LocalPlayer::resetYellowBar()
settings.attackWeaponType = config.resetIntValue("attackWeaponType");
settings.attackType = config.resetIntValue("attackType");
settings.magicAttackType = config.resetIntValue("magicAttackType");
- mPvpAttackType = config.resetIntValue("pvpAttackType");
+ settings.pvpAttackType = config.resetIntValue("pvpAttackType");
settings.quickDropCounter = config.resetIntValue("quickDropCounter");
settings.pickUpType = config.resetIntValue("pickUpType");
if (viewport)
@@ -3478,7 +3449,7 @@ bool LocalPlayer::checAttackPermissions(const Being *const target) const
if (!target)
return false;
- switch (mPvpAttackType)
+ switch (settings.pvpAttackType)
{
case 0:
return true;
diff --git a/src/being/localplayer.h b/src/being/localplayer.h
index 354339016..191ed73fe 100644
--- a/src/being/localplayer.h
+++ b/src/being/localplayer.h
@@ -203,11 +203,6 @@ class LocalPlayer final : public Being,
void setCrazyMoveState(const unsigned int n)
{ mCrazyMoveState = n; }
- void switchPvpAttack(const bool forward);
-
- int getPvpAttackType() const A_WARN_UNUSED
- { return mPvpAttackType; }
-
int getDisableGameModifiers() const A_WARN_UNUSED
{ return mDisableGameModifiers; }
@@ -409,8 +404,6 @@ class LocalPlayer final : public Being,
static std::string getMapDrawTypeString();
- std::string getPvpAttackString();
-
std::string getImitationModeString();
std::string getAwayModeString();
@@ -479,8 +472,6 @@ class LocalPlayer final : public Being,
unsigned int mCrazyMoveState;
// move state. used if mMoveType == 2
unsigned int mMoveState;
- // pvp attack type
- unsigned int mPvpAttackType;
unsigned int mImitationMode;
int mLastTargetX;
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp
index 87dcd5aa7..5ce9dd63b 100644
--- a/src/gamemodifiers.cpp
+++ b/src/gamemodifiers.cpp
@@ -45,6 +45,7 @@ GameModifiers::GameModifiers()
settings.quickDropCounter = config.getIntValue("quickDropCounter");
settings.pickUpType = config.getIntValue("pickUpType");
settings.magicAttackType = config.getIntValue("magicAttackType");
+ settings.pvpAttackType = config.getIntValue("pvpAttackType");
}
GameModifiers::~GameModifiers()
@@ -381,3 +382,31 @@ std::string GameModifiers::getMagicAttackString()
return gettext(getVarItem(&magicAttackStrings[0],
settings.magicAttackType, magicAttackSize));
}
+
+const unsigned pvpAttackTypeSize = 4;
+
+void GameModifiers::changePvpAttackType(const bool forward)
+{
+ changeMode(&settings.pvpAttackType, pvpAttackTypeSize, "pvpAttackType",
+ &GameModifiers::getPvpAttackTypeString, 0, true, forward);
+}
+
+static const char *const pvpAttackTypeStrings[] =
+{
+ // TRANSLATORS: player attack type in status bar
+ N_("(a) attack all players"),
+ // TRANSLATORS: player attack type in status bar
+ N_("(f) attack all except friends"),
+ // TRANSLATORS: player attack type in status bar
+ N_("(b) attack bad relations"),
+ // TRANSLATORS: player attack type in status bar
+ N_("(d) don't attack players"),
+ // TRANSLATORS: player attack type in status bar
+ N_("(?) pvp attack")
+};
+
+std::string GameModifiers::getPvpAttackTypeString()
+{
+ return gettext(getVarItem(&pvpAttackTypeStrings[0],
+ settings.pvpAttackType, pvpAttackTypeSize));
+}
diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h
index cfb8e4210..35615f15a 100644
--- a/src/gamemodifiers.h
+++ b/src/gamemodifiers.h
@@ -60,6 +60,8 @@ class GameModifiers final
void changeMagicAttackType(const bool forward);
+ void changePvpAttackType(const bool forward);
+
void setQuickDropCounter(const int n);
std::string getMoveTypeString();
@@ -80,6 +82,8 @@ class GameModifiers final
std::string getMagicAttackString();
+ std::string getPvpAttackTypeString();
+
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 4612844a8..8536e25d8 100644
--- a/src/gui/popups/statuspopup.cpp
+++ b/src/gui/popups/statuspopup.cpp
@@ -160,7 +160,7 @@ void StatusPopup::updateLabels() const
InputAction::PATHFIND);
setLabelText(9, modifiers->getMagicAttackString(),
InputAction::SWITCH_MAGIC_ATTACK);
- setLabelText(10, player_node->getPvpAttackString(),
+ setLabelText(10, modifiers->getPvpAttackTypeString(),
InputAction::SWITCH_PVP_ATTACK);
setLabelText(11, player_node->getGameModifiersString(),
InputAction::DISABLE_GAME_MODIFIERS);
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 27e47e1ad..aee371f9e 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -650,7 +650,7 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
modifiers->getAttackWeaponTypeString()))
.append(translateLetter2(modifiers->getAttackTypeString()))
.append(translateLetter2(modifiers->getMagicAttackString()))
- .append(translateLetter2(player_node->getPvpAttackString()))
+ .append(translateLetter2(modifiers->getPvpAttackTypeString()))
.append(" ").append(translateLetter2(
modifiers->getQuickDropCounterString()))
.append(translateLetter2(modifiers->getPickUpTypeString()))
diff --git a/src/settings.h b/src/settings.h
index 21b53fb7b..cd6e68a99 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -61,6 +61,7 @@ class Settings final
quickDropCounter(0U),
pickUpType(0U),
magicAttackType(0U),
+ pvpAttackType(0U),
persistentIp(true),
limitFps(false),
inputFocused(true),
@@ -96,6 +97,7 @@ class Settings final
unsigned int quickDropCounter;
unsigned int pickUpType;
unsigned int magicAttackType;
+ unsigned int pvpAttackType;
bool persistentIp;
bool limitFps;
bool inputFocused;