diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-04-18 19:29:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-04-18 19:29:26 +0300 |
commit | ac9d9925b52789abc07795d5ed52dd0de620c757 (patch) | |
tree | d4ab04c3285edb0e2748d39b35d9966235dcaac5 /src | |
parent | 129f749d057e3b96161630934da7b2d89dec3c71 (diff) | |
download | manaverse-ac9d9925b52789abc07795d5ed52dd0de620c757.tar.gz manaverse-ac9d9925b52789abc07795d5ed52dd0de620c757.tar.bz2 manaverse-ac9d9925b52789abc07795d5ed52dd0de620c757.tar.xz manaverse-ac9d9925b52789abc07795d5ed52dd0de620c757.zip |
Improve gamemodifiers class for using from other places.
Diffstat (limited to 'src')
-rw-r--r-- | src/gamemodifiers.cpp | 12 | ||||
-rw-r--r-- | src/gamemodifiers.h | 84 |
2 files changed, 39 insertions, 57 deletions
diff --git a/src/gamemodifiers.cpp b/src/gamemodifiers.cpp index b5d5d91bb..a77861370 100644 --- a/src/gamemodifiers.cpp +++ b/src/gamemodifiers.cpp @@ -47,8 +47,8 @@ #include "debug.h" #define addModifier(name1, name2, sz, ...) \ - static const unsigned m##name1##Size = sz; \ - static const char *const m##name1##Strings[] = \ + const unsigned GameModifiers::m##name1##Size = sz; \ + const char *const GameModifiers::m##name1##Strings[] = \ __VA_ARGS__; \ std::string GameModifiers::get##name1##String() \ { \ @@ -57,8 +57,8 @@ } #define addModifier2(name1, name2, str, sz, ...) \ - static const unsigned m##name1##Size = sz; \ - static const char *const m##name1##Strings[] = \ + const unsigned GameModifiers::m##name1##Size = sz; \ + const char *const GameModifiers::m##name1##Strings[] = \ __VA_ARGS__; \ void GameModifiers::change##name1(const bool forward) \ { \ @@ -162,7 +162,7 @@ void GameModifiers::changeMoveType(const bool forward) &GameModifiers::getMoveTypeString, 0, false, forward); } -static const unsigned mCrazyMoveTypeSize = 11; +const unsigned GameModifiers::mCrazyMoveTypeSize = 11; void GameModifiers::changeCrazyMoveType(const bool forward) { @@ -266,7 +266,7 @@ addModifier2(AttackType, attackType, "attackType", 4, N_("(?) attack") }) -const unsigned mQuickDropCounterSize = 31; +const unsigned GameModifiers::mQuickDropCounterSize = 31; changeMethod(QuickDropCounter, quickDropCounter, "quickDropCounter") diff --git a/src/gamemodifiers.h b/src/gamemodifiers.h index bdb94bd1a..d3ef572e0 100644 --- a/src/gamemodifiers.h +++ b/src/gamemodifiers.h @@ -25,6 +25,17 @@ #include "localconsts.h" +#define declModifier(name1) \ + static std::string get##name1##String(); \ + static const unsigned m##name1##Size; \ + static const char *const m##name1##Strings[]; + +#define declModifier2(name1) \ + static void change##name1(const bool forward); \ + static std::string get##name1##String(); \ + static const unsigned m##name1##Size; \ + static const char *const m##name1##Strings[]; + class GameModifiers final { public: @@ -40,63 +51,31 @@ class GameModifiers final const bool save, const bool forward); - static void changeMoveType(const bool forward); - - static void changeCrazyMoveType(const bool forward); - - static void changeMoveToTargetType(const bool forward); - - static void changeFollowMode(const bool forward); - - static void changeAttackWeaponType(const bool forward); - - static void changeAttackType(const bool forward); - - static void changeQuickDropCounter(const bool forward); - - static void changePickUpType(const bool forward); - - static void changeMagicAttackType(const bool forward); - - static void changePvpAttackType(const bool forward); - - static void changeImitationMode(const bool forward); - - static void changeGameModifiers(); + declModifier(MoveType) + declModifier2(CrazyMoveType) + declModifier2(MoveToTargetType) + declModifier2(FollowMode) + declModifier2(AttackWeaponType) + declModifier2(AttackType) + declModifier2(QuickDropCounter) + declModifier2(PickUpType) + declModifier2(MagicAttackType) + declModifier2(PvpAttackType) + declModifier2(ImitationMode) + declModifier(MapDrawType) + declModifier(CameraMode) + declModifier(AwayMode); static void changeAwayMode(); - static void setQuickDropCounter(const int n); - - static std::string getMoveTypeString(); - - static std::string getCrazyMoveTypeString(); - - static std::string getMoveToTargetTypeString(); - - static std::string getFollowModeString(); - - static std::string getAttackWeaponTypeString(); - - static std::string getAttackTypeString(); - - static std::string getQuickDropCounterString(); - - static std::string getPickUpTypeString(); - - static std::string getMagicAttackTypeString(); - - static std::string getPvpAttackTypeString(); - - static std::string getImitationModeString(); + static void changeMoveType(const bool forward); static std::string getGameModifiersString(); + static void changeGameModifiers(); + static const unsigned mGameModifiersSize; + static const char *const mGameModifiersStrings[]; - static std::string getMapDrawTypeString(); - - static std::string getAwayModeString(); - - static std::string getCameraModeString(); + static void setQuickDropCounter(const int n); static void resetModifiers(); @@ -106,4 +85,7 @@ class GameModifiers final const unsigned sz) A_WARN_UNUSED; }; +#undef declModifier +#undef declModifier2 + #endif // GAMEMODIFIERS_H |