summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-25 22:03:28 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-25 22:03:28 +0300
commitd670395fff93f805b666e0cc4cc56cdb880e0bba (patch)
treee7949649a7c0568b3b238c91092f60606a495f9f /src
parent7d6d3d997614e8e76ca9044ca8ed5a81d3b14a95 (diff)
downloadplus-d670395fff93f805b666e0cc4cc56cdb880e0bba.tar.gz
plus-d670395fff93f805b666e0cc4cc56cdb880e0bba.tar.bz2
plus-d670395fff93f805b666e0cc4cc56cdb880e0bba.tar.xz
plus-d670395fff93f805b666e0cc4cc56cdb880e0bba.zip
Use all methods in gamemodifiers as static.
Diffstat (limited to 'src')
-rw-r--r--src/actionmanager.cpp19
-rw-r--r--src/being/localplayer.cpp2
-rw-r--r--src/commands.cpp3
-rw-r--r--src/game.cpp2
-rw-r--r--src/gamemodifiers.cpp6
-rw-r--r--src/gamemodifiers.h76
-rw-r--r--src/gui/popups/popupmenu.cpp3
-rw-r--r--src/gui/popups/statuspopup.cpp33
-rw-r--r--src/gui/windows/statuswindow.cpp31
-rw-r--r--src/listeners/awaylistener.cpp4
10 files changed, 80 insertions, 99 deletions
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 567bb0647..94ff787a2 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -91,18 +91,14 @@
#define impHandler0(name) bool name(const InputEvent &event A_UNUSED)
#define callYellowBar(name) \
- if (modifiers) \
- { \
- modifiers->name(!inputManager.isActionActive( \
- InputAction::STOP_ATTACK)); \
- return true; \
- } \
- return false;
+ GameModifiers::name(!inputManager.isActionActive( \
+ InputAction::STOP_ATTACK)); \
+ return true;
#define callYellowBarCond(name) \
- if (modifiers && !settings.disableGameModifiers) \
+ if (!settings.disableGameModifiers) \
{ \
- modifiers->name(!inputManager.isActionActive( \
+ GameModifiers::name(!inputManager.isActionActive( \
InputAction::STOP_ATTACK)); \
return true; \
} \
@@ -563,7 +559,7 @@ impHandler0(changeGameModifier)
{
if (player_node)
{
- modifiers->changeGameModifiers();
+ GameModifiers::changeGameModifiers();
return true;
}
return false;
@@ -579,8 +575,7 @@ impHandler0(changeAudio)
impHandler0(away)
{
- if (modifiers)
- modifiers->changeAwayMode();
+ GameModifiers::changeAwayMode();
if (player_node)
{
player_node->updateStatus();
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index a980ec73b..ec4c51a19 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -2469,7 +2469,7 @@ void LocalPlayer::tryPingRequest()
void LocalPlayer::setAway(const std::string &message)
{
setAfkMessage(message);
- modifiers->changeAwayMode();
+ GameModifiers::changeAwayMode();
updateStatus();
}
diff --git a/src/commands.cpp b/src/commands.cpp
index f64e570c1..62cb58049 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -1162,8 +1162,7 @@ impHandler2(dumpTests)
impHandler1(setDrop)
{
- if (modifiers)
- modifiers->setQuickDropCounter(atoi(args.c_str()));
+ GameModifiers::setQuickDropCounter(atoi(args.c_str()));
}
impHandler0(error)
diff --git a/src/game.cpp b/src/game.cpp
index 2262e34e5..c96771e46 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -141,7 +141,6 @@ static void initEngines()
actorManager = new ActorManager;
commandHandler = new CommandHandler;
effectManager = new EffectManager;
- modifiers = new GameModifiers;
AuctionManager::init();
GuildManager::init();
@@ -423,7 +422,6 @@ Game::~Game()
AnimatedSprite::setEnableCache(false);
- delete2(modifiers);
delete2(actorManager)
if (client->getState() != STATE_CHANGE_MAP)
delete2(player_node)
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp
index 57a51b0e8..94dea8ecf 100644
--- a/src/gamemodifiers.cpp
+++ b/src/gamemodifiers.cpp
@@ -76,8 +76,6 @@
&GameModifiers::get##name1##String, 0, true, forward); \
}
-GameModifiers *modifiers = nullptr;
-
GameModifiers::GameModifiers()
{
settings.crazyMoveType = config.getIntValue("crazyMoveType");
@@ -101,7 +99,7 @@ GameModifiers::~GameModifiers()
void GameModifiers::changeMode(unsigned *restrict const var,
const unsigned limit,
const char *restrict const conf,
- std::string (GameModifiers::*const func)(),
+ std::string (*const func)(),
const unsigned def,
const bool save,
const bool forward)
@@ -126,7 +124,7 @@ void GameModifiers::changeMode(unsigned *restrict const var,
if (save)
config.setValue(conf, *var);
UpdateStatusListener::distributeEvent();
- const std::string str = (this->*func)();
+ const std::string str = (*func)();
if (str.size() > 4)
debugMsg(str.substr(4));
}
diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h
index 8ca57ef3f..497622236 100644
--- a/src/gamemodifiers.h
+++ b/src/gamemodifiers.h
@@ -34,73 +34,73 @@ class GameModifiers final
~GameModifiers();
- void changeMode(unsigned *restrict const var,
- const unsigned limit,
- const char *restrict const conf,
- std::string (GameModifiers::*const func)(),
- const unsigned def,
- const bool save,
- const bool forward);
+ static void changeMode(unsigned *restrict const var,
+ const unsigned limit,
+ const char *restrict const conf,
+ std::string (*const func)(),
+ const unsigned def,
+ const bool save,
+ const bool forward);
- void changeMoveType(const bool forward);
+ static void changeMoveType(const bool forward);
- void changeCrazyMoveType(const bool forward);
+ static void changeCrazyMoveType(const bool forward);
- void changeMoveToTargetType(const bool forward);
+ static void changeMoveToTargetType(const bool forward);
- void changeFollowMode(const bool forward);
+ static void changeFollowMode(const bool forward);
- void changeAttackWeaponType(const bool forward);
+ static void changeAttackWeaponType(const bool forward);
- void changeAttackType(const bool forward);
+ static void changeAttackType(const bool forward);
- void changeQuickDropCounter(const bool forward);
+ static void changeQuickDropCounter(const bool forward);
- void changePickUpType(const bool forward);
+ static void changePickUpType(const bool forward);
- void changeMagicAttackType(const bool forward);
+ static void changeMagicAttackType(const bool forward);
- void changePvpAttackType(const bool forward);
+ static void changePvpAttackType(const bool forward);
- void changeImitationMode(const bool forward);
+ static void changeImitationMode(const bool forward);
- void changeGameModifiers();
+ static void changeGameModifiers();
- void changeAwayMode();
+ static void changeAwayMode();
- void setQuickDropCounter(const int n);
+ static void setQuickDropCounter(const int n);
- std::string getMoveTypeString();
+ static std::string getMoveTypeString();
- std::string getCrazyMoveTypeString();
+ static std::string getCrazyMoveTypeString();
- std::string getMoveToTargetTypeString();
+ static std::string getMoveToTargetTypeString();
- std::string getFollowModeString();
+ static std::string getFollowModeString();
- std::string getAttackWeaponTypeString();
+ static std::string getAttackWeaponTypeString();
- std::string getAttackTypeString();
+ static std::string getAttackTypeString();
- std::string getQuickDropCounterString();
+ static std::string getQuickDropCounterString();
- std::string getPickUpTypeString();
+ static std::string getPickUpTypeString();
- std::string getMagicAttackTypeString();
+ static std::string getMagicAttackTypeString();
- std::string getPvpAttackTypeString();
+ static std::string getPvpAttackTypeString();
- std::string getImitationModeString();
+ static std::string getImitationModeString();
- std::string getGameModifiersString();
+ static std::string getGameModifiersString();
- std::string getMapDrawTypeString();
+ static std::string getMapDrawTypeString();
- std::string getAwayModeString();
+ static std::string getAwayModeString();
- std::string getCameraModeString();
+ static std::string getCameraModeString();
- void resetModifiers();
+ static void resetModifiers();
protected:
static const char *getVarItem(const char *const *const arr,
@@ -108,6 +108,4 @@ class GameModifiers final
const unsigned sz) A_WARN_UNUSED;
};
-extern GameModifiers *modifiers;
-
#endif // GAMEMODIFIERS_H
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 1712ce34b..50b725a5d 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1722,8 +1722,7 @@ void PopupMenu::handleLink(const std::string &link,
}
else if (link == "reset yellow")
{
- if (modifiers)
- modifiers->resetModifiers();
+ GameModifiers::resetModifiers();
}
else if (link == "bar to chat" && !mNick.empty())
{
diff --git a/src/gui/popups/statuspopup.cpp b/src/gui/popups/statuspopup.cpp
index 235d2aee6..fd696c568 100644
--- a/src/gui/popups/statuspopup.cpp
+++ b/src/gui/popups/statuspopup.cpp
@@ -137,37 +137,34 @@ void StatusPopup::setLabelText(const int num,
void StatusPopup::updateLabels() const
{
- if (!modifiers)
- return;
-
- setLabelText(0, modifiers->getMoveTypeString(),
+ setLabelText(0, GameModifiers::getMoveTypeString(),
InputAction::INVERT_DIRECTION);
- setLabelText(1, modifiers->getCrazyMoveTypeString(),
+ setLabelText(1, GameModifiers::getCrazyMoveTypeString(),
InputAction::CHANGE_CRAZY_MOVES_TYPE);
- setLabelText(2, modifiers->getMoveToTargetTypeString(),
+ setLabelText(2, GameModifiers::getMoveToTargetTypeString(),
InputAction::CHANGE_MOVE_TO_TARGET);
- setLabelText(3, modifiers->getFollowModeString(),
+ setLabelText(3, GameModifiers::getFollowModeString(),
InputAction::CHANGE_FOLLOW_MODE);
- setLabelText(4, modifiers->getAttackWeaponTypeString(),
+ setLabelText(4, GameModifiers::getAttackWeaponTypeString(),
InputAction::CHANGE_ATTACK_WEAPON_TYPE);
- setLabelText(5, modifiers->getAttackTypeString(),
+ setLabelText(5, GameModifiers::getAttackTypeString(),
InputAction::CHANGE_ATTACK_TYPE);
- setLabelText(6, modifiers->getQuickDropCounterString(),
+ setLabelText(6, GameModifiers::getQuickDropCounterString(),
InputAction::SWITCH_QUICK_DROP);
- setLabelText(7, modifiers->getPickUpTypeString(),
+ setLabelText(7, GameModifiers::getPickUpTypeString(),
InputAction::CHANGE_PICKUP_TYPE);
- setLabelText(8, modifiers->getMapDrawTypeString(),
+ setLabelText(8, GameModifiers::getMapDrawTypeString(),
InputAction::PATHFIND);
- setLabelText(9, modifiers->getMagicAttackTypeString(),
+ setLabelText(9, GameModifiers::getMagicAttackTypeString(),
InputAction::SWITCH_MAGIC_ATTACK);
- setLabelText(10, modifiers->getPvpAttackTypeString(),
+ setLabelText(10, GameModifiers::getPvpAttackTypeString(),
InputAction::SWITCH_PVP_ATTACK);
- setLabelText(11, modifiers->getGameModifiersString(),
+ setLabelText(11, GameModifiers::getGameModifiersString(),
InputAction::DISABLE_GAME_MODIFIERS);
- setLabelText(12, modifiers->getImitationModeString(),
+ setLabelText(12, GameModifiers::getImitationModeString(),
InputAction::CHANGE_IMITATION_MODE);
- setLabelText(13, modifiers->getAwayModeString(),
+ setLabelText(13, GameModifiers::getAwayModeString(),
InputAction::AWAY);
- setLabelText(14, modifiers->getCameraModeString(),
+ setLabelText(14, GameModifiers::getCameraModeString(),
InputAction::CAMERA);
}
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index adde623bb..c5f2b29d3 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -640,27 +640,24 @@ std::string StatusWindow::translateLetter2(const std::string &letters)
void StatusWindow::updateStatusBar(ProgressBar *const bar,
const bool percent A_UNUSED) const
{
- if (!modifiers)
- return;
-
- bar->setText(translateLetter2(modifiers->getMoveTypeString())
- .append(translateLetter2(modifiers->getCrazyMoveTypeString()))
- .append(translateLetter2(modifiers->getMoveToTargetTypeString()))
- .append(translateLetter2(modifiers->getFollowModeString()))
+ bar->setText(translateLetter2(GameModifiers::getMoveTypeString())
+ .append(translateLetter2(GameModifiers::getCrazyMoveTypeString()))
+ .append(translateLetter2(GameModifiers::getMoveToTargetTypeString()))
+ .append(translateLetter2(GameModifiers::getFollowModeString()))
.append(" ").append(translateLetter2(
- modifiers->getAttackWeaponTypeString()))
- .append(translateLetter2(modifiers->getAttackTypeString()))
- .append(translateLetter2(modifiers->getMagicAttackTypeString()))
- .append(translateLetter2(modifiers->getPvpAttackTypeString()))
+ GameModifiers::getAttackWeaponTypeString()))
+ .append(translateLetter2(GameModifiers::getAttackTypeString()))
+ .append(translateLetter2(GameModifiers::getMagicAttackTypeString()))
+ .append(translateLetter2(GameModifiers::getPvpAttackTypeString()))
.append(" ").append(translateLetter2(
- modifiers->getQuickDropCounterString()))
- .append(translateLetter2(modifiers->getPickUpTypeString()))
+ GameModifiers::getQuickDropCounterString()))
+ .append(translateLetter2(GameModifiers::getPickUpTypeString()))
.append(" ").append(translateLetter2(
- modifiers->getMapDrawTypeString()))
+ GameModifiers::getMapDrawTypeString()))
.append(" ").append(translateLetter2(
- modifiers->getImitationModeString()))
- .append(translateLetter2(modifiers->getCameraModeString()))
- .append(translateLetter2(modifiers->getAwayModeString())));
+ GameModifiers::getImitationModeString()))
+ .append(translateLetter2(GameModifiers::getCameraModeString()))
+ .append(translateLetter2(GameModifiers::getAwayModeString())));
bar->setProgress(50);
if (settings.disableGameModifiers)
diff --git a/src/listeners/awaylistener.cpp b/src/listeners/awaylistener.cpp
index 17e48c1a8..9966abd99 100644
--- a/src/listeners/awaylistener.cpp
+++ b/src/listeners/awaylistener.cpp
@@ -35,9 +35,9 @@
void AwayListener::action(const ActionEvent &event)
{
- if (event.getId() == "ok" && modifiers && player_node && settings.awayMode)
+ if (event.getId() == "ok" && player_node && settings.awayMode)
{
- modifiers->changeAwayMode();
+ GameModifiers::changeAwayMode();
player_node->updateStatus();
if (outfitWindow)
outfitWindow->unwearAwayOutfit();