diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-18 12:18:44 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-18 14:52:11 +0300 |
commit | bb9ed14fc1bf7dc20f1e951e67bb359c273033a3 (patch) | |
tree | c46e7e5708d3a2058233a41a08995e6c861703ea /src | |
parent | 10273bc94e90fefcfe3fc215aaaaafe7e0e96bd4 (diff) | |
download | manaverse-bb9ed14fc1bf7dc20f1e951e67bb359c273033a3.tar.gz manaverse-bb9ed14fc1bf7dc20f1e951e67bb359c273033a3.tar.bz2 manaverse-bb9ed14fc1bf7dc20f1e951e67bb359c273033a3.tar.xz manaverse-bb9ed14fc1bf7dc20f1e951e67bb359c273033a3.zip |
fix code style.
Diffstat (limited to 'src')
69 files changed, 312 insertions, 266 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3db1eaeb1..3b956b482 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -262,6 +262,7 @@ SET(SRCS gui/widgets/tabs/shortcuttab.h gui/widgets/tabs/skilltab.h gui/widgets/tabs/socialattacktab.h + gui/widgets/tabs/socialfriendsfunctor.h gui/widgets/tabs/socialfriendstab.h gui/widgets/tabs/socialguildtab.h gui/widgets/tabs/socialguildtab2.h diff --git a/src/Makefile.am b/src/Makefile.am index 8e356dbb7..d55d674f3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -364,6 +364,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/widgets/tabs/shortcuttab.h \ gui/widgets/tabs/skilltab.h \ gui/widgets/tabs/socialattacktab.h \ + gui/widgets/tabs/socialfriendsfunctor.h \ gui/widgets/tabs/socialfriendstab.h \ gui/widgets/tabs/socialguildtab.h \ gui/widgets/tabs/socialguildtab2.h \ @@ -1134,7 +1135,7 @@ if ENABLE_UNITTESTS manaplus_CXXFLAGS += -DUNITTESTS manaplus_SOURCES += \ animatedsprite_unittest.cc \ - gui/sdlfont_unittest.cc \ + gui/fonts/font_unittest.cc \ gui/widgets/browserbox_unittest.cc \ utils/files_unittest.cc \ utils/stringutils_unittest.cc \ diff --git a/src/avatar.cpp b/src/avatar.cpp index 077ded04d..d04c703a3 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -38,7 +38,7 @@ Avatar::Avatar(const std::string &name): mY(-1), mType(AVATAR_PLAYER), mExp(0), - mGender(GENDER_UNSPECIFIED), + mGender(Gender::UNSPECIFIED), mRace(-1), mIp(), mOnline(false), diff --git a/src/avatar.h b/src/avatar.h index f8f8d9941..482e75873 100644 --- a/src/avatar.h +++ b/src/avatar.h @@ -156,10 +156,10 @@ public: void setCharId(const int id) { mCharId = id; } - Gender getGender() const A_WARN_UNUSED + Gender::Type getGender() const A_WARN_UNUSED { return mGender; } - void setGender(const Gender g) + void setGender(const Gender::Type g) { mGender = g; } int getRace() const A_WARN_UNUSED @@ -194,7 +194,7 @@ protected: int mY; int mType; int mExp; - Gender mGender; + Gender::Type mGender; int mRace; std::string mIp; bool mOnline; diff --git a/src/being/being.cpp b/src/being/being.cpp index c0e325afb..55426913c 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -147,7 +147,7 @@ Being::Being(const int id, mAttackRange(1), mLastAttackX(0), mLastAttackY(0), - mGender(GENDER_UNSPECIFIED), + mGender(Gender::UNSPECIFIED), mAction(BeingAction::STAND), mSubType(0xFFFF), mDirection(BeingDirection::DOWN), @@ -1802,9 +1802,9 @@ std::string Being::getGenderSign() const std::string str; if (mShowGender) { - if (getGender() == GENDER_FEMALE) + if (getGender() == Gender::FEMALE) str = "\u2640"; - else if (getGender() == GENDER_MALE) + else if (getGender() == Gender::MALE) str = "\u2642"; } if (mShowPlayersStatus && mAdvanced) @@ -2118,7 +2118,7 @@ void Being::load() // Hairstyles are encoded as negative numbers. Count how far negative // we can go. int hairstyles = 1; - while (ItemDB::get(-hairstyles).getSprite(GENDER_MALE, 0) != + while (ItemDB::get(-hairstyles).getSprite(Gender::MALE, 0) != paths.getStringValue("spriteErrorFile")) { hairstyles ++; @@ -2126,7 +2126,7 @@ void Being::load() mNumberOfHairstyles = hairstyles; int races = 100; - while (ItemDB::get(-races).getSprite(GENDER_MALE, 0) != + while (ItemDB::get(-races).getSprite(Gender::MALE, 0) != paths.getStringValue("spriteErrorFile")) { races ++; @@ -2275,7 +2275,7 @@ BeingCacheEntry* Being::getCacheEntry(const int id) } -void Being::setGender(const Gender gender) +void Being::setGender(const Gender::Type gender) { if (gender != mGender) { @@ -3016,32 +3016,32 @@ void Being::updatePercentHP() } } -uint8_t Being::genderToInt(const Gender sex) +uint8_t Being::genderToInt(const Gender::Type sex) { switch (sex) { - case GENDER_FEMALE: - case GENDER_UNSPECIFIED: + case Gender::FEMALE: + case Gender::UNSPECIFIED: default: return 0; - case GENDER_MALE: + case Gender::MALE: return 1; - case GENDER_OTHER: + case Gender::OTHER: return 3; } } -Gender Being::intToGender(const uint8_t sex) +Gender::Type Being::intToGender(const uint8_t sex) { switch (sex) { case 0: default: - return GENDER_FEMALE; + return Gender::FEMALE; case 1: - return GENDER_MALE; + return Gender::MALE; case 3: - return GENDER_OTHER; + return Gender::OTHER; } } diff --git a/src/being/being.h b/src/being/being.h index 87949479c..020c97e45 100644 --- a/src/being/being.h +++ b/src/being/being.h @@ -599,9 +599,9 @@ class Being : public ActorSprite, public ConfigListener /** * Sets the gender of this being. */ - virtual void setGender(const Gender gender); + virtual void setGender(const Gender::Type gender); - Gender getGender() const A_WARN_UNUSED + Gender::Type getGender() const A_WARN_UNUSED { return mGender; } /** @@ -858,9 +858,9 @@ class Being : public ActorSprite, public ConfigListener void setLook(const uint8_t look); - static uint8_t genderToInt(const Gender sex) A_WARN_UNUSED; + static uint8_t genderToInt(const Gender::Type sex) A_WARN_UNUSED; - static Gender intToGender(const uint8_t sex) A_WARN_UNUSED; + static Gender::Type intToGender(const uint8_t sex) A_WARN_UNUSED; NextSoundInfo mNextSound; @@ -956,7 +956,7 @@ class Being : public ActorSprite, public ConfigListener int mAttackRange; int mLastAttackX; int mLastAttackY; - Gender mGender; + Gender::Type mGender; BeingAction::Action mAction; uint16_t mSubType; /**< Subtype (graphical view, basically) */ uint8_t mDirection; /**< Facing direction */ diff --git a/src/being/gender.h b/src/being/gender.h index c4d0bd7c7..ed8e759b6 100644 --- a/src/being/gender.h +++ b/src/being/gender.h @@ -23,12 +23,15 @@ #ifndef BEING_GENDER_H #define BEING_GENDER_H -enum Gender +namespace Gender { - GENDER_MALE = 0, - GENDER_FEMALE = 1, - GENDER_UNSPECIFIED = 2, - GENDER_OTHER = 3 -}; + enum Type + { + MALE = 0, + FEMALE = 1, + UNSPECIFIED = 2, + OTHER = 3 + }; +} // nemespace Gender #endif // BEING_GENDER_H diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index 29e8eaf03..62eecb9b2 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -964,7 +964,7 @@ void LocalPlayer::handleStatusEffect(const StatusEffect *const effect, { mStatusEffectIcons.erase(mStatusEffectIcons.begin() + i); if (miniStatusWindow) - miniStatusWindow->eraseIcon(i); + miniStatusWindow->eraseIcon(static_cast<int>(i)); } else { diff --git a/src/client.cpp b/src/client.cpp index d2b8fb474..5efbd08a9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1644,7 +1644,8 @@ int Client::gameExec() // TRANSLATORS: password change message header mCurrentDialog = new OkDialog(_("Password Change"), // TRANSLATORS: password change message text - _("Password changed successfully!"), DialogType::ERROR); + _("Password changed successfully!"), + DialogType::ERROR); mCurrentDialog->addActionListener(&accountListener); mCurrentDialog = nullptr; // OkDialog deletes itself loginData.password = loginData.newPassword; diff --git a/src/commands.cpp b/src/commands.cpp index e18d2e484..b434ba9ca 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -558,7 +558,8 @@ impHandler(unignore) if (player_relations.getRelation(args) == PlayerRelation::NEUTRAL) { // TRANSLATORS: unignore command - tab->chatLog(_("Player no longer ignored!"), ChatMsgType::BY_SERVER); + tab->chatLog(_("Player no longer ignored!"), + ChatMsgType::BY_SERVER); } else { diff --git a/src/gui/chatmsgtype.h b/src/gui/chatmsgtype.h index 5c1cf5589..62fac3e0a 100644 --- a/src/gui/chatmsgtype.h +++ b/src/gui/chatmsgtype.h @@ -37,6 +37,6 @@ namespace ChatMsgType BY_LOGGER, BY_UNKNOWN = -1 }; -} +} // namespace ChatMsgType #endif // GUI_CHATMSGTYPE_H diff --git a/src/gui/dialogtype.h b/src/gui/dialogtype.h index 8da9f37fb..afe88794a 100644 --- a/src/gui/dialogtype.h +++ b/src/gui/dialogtype.h @@ -20,8 +20,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef GUI_DIALOG_TYPE_H -#define GUI_DIALOG_TYPE_H +#ifndef GUI_DIALOGTYPE_H +#define GUI_DIALOGTYPE_H + +#undef ERROR namespace DialogType { @@ -33,4 +35,4 @@ namespace DialogType }; } -#endif // GUI_DIALOG_TYPE_H +#endif // GUI_DIALOGTYPE_H diff --git a/src/gui/fonts/font.cpp b/src/gui/fonts/font.cpp index 2edca6b0b..72a047e57 100644 --- a/src/gui/fonts/font.cpp +++ b/src/gui/fonts/font.cpp @@ -67,7 +67,6 @@ #include "gui/fonts/font.h" #include "logger.h" -#include "main.h" #include "gui/fonts/textchunk.h" diff --git a/src/gui/fonts/font.h b/src/gui/fonts/font.h index c8e39fd7c..ebb2d8dcb 100644 --- a/src/gui/fonts/font.h +++ b/src/gui/fonts/font.h @@ -142,7 +142,7 @@ class Font final }; #ifdef UNITTESTS -extern int sdlTextChunkCnt; +extern int textChunkCnt; #endif #endif // GUI_FONTS_FONT_H diff --git a/src/gui/sdlfont_unittest.cc b/src/gui/fonts/font_unittest.cc index e0f536c01..b5b589e72 100644 --- a/src/gui/sdlfont_unittest.cc +++ b/src/gui/fonts/font_unittest.cc @@ -20,9 +20,12 @@ #include "logger.h" -#include "gui/font.h" #include "gui/theme.h" +#include "gui/fonts/font.h" +#include "gui/fonts/textchunk.h" +#include "gui/fonts/textchunksmall.h" + #include "gtest/gtest.h" #include "debug.h" @@ -42,7 +45,7 @@ TEST(TextChunkList, add1) { TextChunkList list; - SDLTextChunk *chunk = new SDLTextChunk("test", + TextChunk *chunk = new TextChunk("test", Color(1, 2, 3), Color(2, 3, 4)); list.insertFirst(chunk); @@ -54,7 +57,7 @@ TEST(TextChunkList, add1) EXPECT_EQ(nullptr, chunk->next); EXPECT_EQ(1, list.search.size()); - EXPECT_EQ(chunk, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk, (*list.search.find(TextChunkSmall( chunk->text, chunk->color, chunk->color2))).second); EXPECT_EQ(1, list.searchWidth.size()); @@ -65,9 +68,9 @@ TEST(TextChunkList, add2) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(3, 4, 5)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(2, 3, 4), Color(4, 5, 6)); list.insertFirst(chunk2); @@ -82,9 +85,9 @@ TEST(TextChunkList, add2) EXPECT_EQ(nullptr, chunk2->next); EXPECT_EQ(2, list.search.size()); - EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk1, (*list.search.find(TextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); - EXPECT_EQ(chunk2, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk2, (*list.search.find(TextChunkSmall( chunk2->text, chunk2->color, chunk2->color2))).second); EXPECT_EQ(1, list.searchWidth.size()); @@ -95,7 +98,7 @@ TEST(TextChunkList, addRemoveBack1) { TextChunkList list; - SDLTextChunk *chunk = new SDLTextChunk("test", + TextChunk *chunk = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); list.insertFirst(chunk); @@ -112,9 +115,9 @@ TEST(TextChunkList, addRemoveBack2) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(1, 2, 4), Color(1, 2, 5)); list.insertFirst(chunk2); @@ -128,7 +131,7 @@ TEST(TextChunkList, addRemoveBack2) EXPECT_EQ(nullptr, chunk1->next); EXPECT_EQ(1, list.search.size()); - EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk1, (*list.search.find(TextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); EXPECT_EQ(1, list.searchWidth.size()); @@ -139,9 +142,9 @@ TEST(TextChunkList, addRemoveBack3) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(2, 3, 4), Color(2, 3, 4)); list.insertFirst(chunk2); @@ -160,11 +163,11 @@ TEST(TextChunkList, addRemoveBack4) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(2, 3, 4), Color(2, 3, 4)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(3, 4, 5), Color(3, 4, 5)); list.insertFirst(chunk3); @@ -180,7 +183,7 @@ TEST(TextChunkList, addRemoveBack4) EXPECT_EQ(nullptr, chunk1->next); EXPECT_EQ(1, list.search.size()); - EXPECT_EQ(chunk1, (*list.search.find(SDLTextChunkSmall( + EXPECT_EQ(chunk1, (*list.search.find(TextChunkSmall( chunk1->text, chunk1->color, chunk1->color2))).second); EXPECT_EQ(0, list.searchWidth.size()); @@ -190,7 +193,7 @@ TEST(TextChunkList, moveToFirst1) { TextChunkList list; - SDLTextChunk *chunk = new SDLTextChunk("test", + TextChunk *chunk = new TextChunk("test", Color(1, 2, 3), Color(2, 3, 4)); list.insertFirst(chunk); @@ -207,9 +210,9 @@ TEST(TextChunkList, moveToFirst2) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(2, 3, 4), Color(1, 2, 3)); list.insertFirst(chunk1); @@ -229,11 +232,11 @@ TEST(TextChunkList, moveToFirst3) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 4), Color(1, 2, 3)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(1, 2, 5), Color(1, 2, 3)); list.insertFirst(chunk3); @@ -256,11 +259,11 @@ TEST(TextChunkList, moveToFirst4) { TextChunkList list; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(), Color()); - SDLTextChunk *chunk2 = new SDLTextChunk("test2", + TextChunk *chunk2 = new TextChunk("test2", Color(), Color()); - SDLTextChunk *chunk3 = new SDLTextChunk("test3", + TextChunk *chunk3 = new TextChunk("test3", Color(), Color()); list.insertFirst(chunk1); @@ -282,9 +285,9 @@ TEST(TextChunkList, moveToFirst4) TEST(TextChunkList, clear1) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk = new SDLTextChunk("test", Color(), Color()); + TextChunk *chunk = new TextChunk("test", Color(), Color()); list.insertFirst(chunk); list.clear(); @@ -292,7 +295,7 @@ TEST(TextChunkList, clear1) EXPECT_EQ(0, list.size); EXPECT_EQ(nullptr, list.start); EXPECT_EQ(nullptr, list.end); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } @@ -300,13 +303,13 @@ TEST(TextChunkList, clear1) TEST(TextChunkList, clear2) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 0)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 1)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); @@ -317,7 +320,7 @@ TEST(TextChunkList, clear2) EXPECT_EQ(0, list.size); EXPECT_EQ(nullptr, list.start); EXPECT_EQ(nullptr, list.end); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } @@ -325,30 +328,30 @@ TEST(TextChunkList, clear2) TEST(TextChunkList, clear3) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 0)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 1)); - SDLTextChunk *chunk3 = new SDLTextChunk("test", + TextChunk *chunk3 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); list.insertFirst(chunk2); list.insertFirst(chunk3); list.moveToFirst(chunk1); - EXPECT_EQ(chunksLeft + 3, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 3, textChunkCnt); EXPECT_EQ(3, list.search.size()); EXPECT_EQ(1, list.searchWidth.size()); list.removeBack(); - EXPECT_EQ(chunksLeft + 2, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 2, textChunkCnt); EXPECT_EQ(2, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); list.clear(); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } @@ -356,41 +359,41 @@ TEST(TextChunkList, clear3) TEST(TextChunkList, clear4) { TextChunkList list; - int chunksLeft = sdlTextChunkCnt; + int chunksLeft = textChunkCnt; - SDLTextChunk *chunk1 = new SDLTextChunk("test", + TextChunk *chunk1 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 0)); - SDLTextChunk *chunk2 = new SDLTextChunk("test", + TextChunk *chunk2 = new TextChunk("test", Color(1, 2, 3), Color(2, 0, 1)); - SDLTextChunk *chunk3 = new SDLTextChunk("test3", + TextChunk *chunk3 = new TextChunk("test3", Color(1, 2, 3), Color(2, 0, 2)); list.insertFirst(chunk1); list.insertFirst(chunk2); list.insertFirst(chunk3); list.moveToFirst(chunk2); - EXPECT_EQ(chunksLeft + 3, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 3, textChunkCnt); EXPECT_EQ(3, list.search.size()); EXPECT_EQ(2, list.searchWidth.size()); list.removeBack(2); - EXPECT_EQ(chunksLeft + 1, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft + 1, textChunkCnt); EXPECT_EQ(1, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); list.clear(); - EXPECT_EQ(chunksLeft, sdlTextChunkCnt); + EXPECT_EQ(chunksLeft, textChunkCnt); EXPECT_EQ(0, list.search.size()); EXPECT_EQ(0, list.searchWidth.size()); } TEST(TextChunkList, sort1) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item3("test line2", + TextChunkSmall item3("test line2", Color(1, 2, 3), Color(1, 2, 3)); EXPECT_EQ(false, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -400,9 +403,9 @@ TEST(TextChunkList, sort1) TEST(TextChunkList, sort2) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(2, 3, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -410,9 +413,9 @@ TEST(TextChunkList, sort2) TEST(TextChunkList, sort3) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 3, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -420,9 +423,9 @@ TEST(TextChunkList, sort3) TEST(TextChunkList, sort4) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 4), Color(1, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -430,9 +433,9 @@ TEST(TextChunkList, sort4) TEST(TextChunkList, sort5) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(2, 2, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -440,9 +443,9 @@ TEST(TextChunkList, sort5) TEST(TextChunkList, sort6) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(1, 3, 3)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); @@ -450,9 +453,9 @@ TEST(TextChunkList, sort6) TEST(TextChunkList, sort7) { - SDLTextChunkSmall item1("test line1", + TextChunkSmall item1("test line1", Color(1, 2, 3), Color(1, 2, 3)); - SDLTextChunkSmall item2("test line1", + TextChunkSmall item2("test line1", Color(1, 2, 3), Color(1, 2, 4)); EXPECT_EQ(true, item1 < item2); EXPECT_EQ(false, item2 < item1); diff --git a/src/gui/fonts/textchunk.cpp b/src/gui/fonts/textchunk.cpp index 632dfaf7b..be0509562 100644 --- a/src/gui/fonts/textchunk.cpp +++ b/src/gui/fonts/textchunk.cpp @@ -41,7 +41,7 @@ namespace char *strBuf = nullptr; #ifdef UNITTESTS -int sdlTextChunkCnt = 0; +int textChunkCnt = 0; #endif TextChunk::TextChunk(const std::string &text0, const Color &color0, @@ -54,7 +54,7 @@ TextChunk::TextChunk(const std::string &text0, const Color &color0, next(nullptr) { #ifdef UNITTESTS - sdlTextChunkCnt ++; + textChunkCnt ++; #endif } @@ -62,7 +62,7 @@ TextChunk::~TextChunk() { delete2(img); #ifdef UNITTESTS - sdlTextChunkCnt --; + textChunkCnt --; #endif } diff --git a/src/gui/fonts/textchunk.h b/src/gui/fonts/textchunk.h index 6f124346d..f9aa41406 100644 --- a/src/gui/fonts/textchunk.h +++ b/src/gui/fonts/textchunk.h @@ -58,7 +58,7 @@ class TextChunk final }; #ifdef UNITTESTS -extern int sdlTextChunkCnt; +extern int textChunkCnt; #endif #endif // GUI_FONTS_TEXTCHUNK_H diff --git a/src/gui/fonts/textchunklist.cpp b/src/gui/fonts/textchunklist.cpp index 98d90e23d..ec6083d7d 100644 --- a/src/gui/fonts/textchunklist.cpp +++ b/src/gui/fonts/textchunklist.cpp @@ -54,10 +54,10 @@ void TextChunkList::moveToFirst(TextChunk *const item) if (item == start) return; - TextChunk *oldPrev = item->prev; + TextChunk *const oldPrev = item->prev; if (oldPrev) oldPrev->next = item->next; - TextChunk *oldNext = item->next; + TextChunk *const oldNext = item->next; if (oldNext) oldNext->prev = item->prev; else @@ -121,7 +121,7 @@ void TextChunkList::clear() TextChunk *item = start; while (item) { - TextChunk *item2 = item->next; + TextChunk *const item2 = item->next; delete item; item = item2; } diff --git a/src/gui/fonts/textchunksmall.cpp b/src/gui/fonts/textchunksmall.cpp index 84c1aa378..aa5661dee 100644 --- a/src/gui/fonts/textchunksmall.cpp +++ b/src/gui/fonts/textchunksmall.cpp @@ -72,4 +72,3 @@ bool TextChunkSmall::operator<(const TextChunkSmall &chunk) const return false; } - diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp index 119a4fba8..41e846f55 100644 --- a/src/gui/models/playertablemodel.cpp +++ b/src/gui/models/playertablemodel.cpp @@ -26,7 +26,6 @@ #include "gui/widgets/label.h" #include "gui/models/playerrelationlistmodel.h" -#include "gui/models/tablemodel.h" #include "utils/delete2.h" #include "utils/dtor.h" diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h index 0b15aefae..a62dabc40 100644 --- a/src/gui/models/serverslistmodel.h +++ b/src/gui/models/serverslistmodel.h @@ -31,8 +31,6 @@ #include "gui/windows/serverdialog.h" -#include "utils/mutex.h" - #include "gui/models/listmodel.h" #include <string> diff --git a/src/gui/popups/createpartypopup.h b/src/gui/popups/createpartypopup.h index 16dc5c9af..c3de37259 100644 --- a/src/gui/popups/createpartypopup.h +++ b/src/gui/popups/createpartypopup.h @@ -19,6 +19,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef GUI_POPUPS_CREATEPARTYPOPUP_H +#define GUI_POPUPS_CREATEPARTYPOPUP_H + #include "gui/widgets/browserbox.h" #include "gui/widgets/linkhandler.h" #include "gui/widgets/popup.h" @@ -91,3 +94,5 @@ class CreatePartyPopup final : public Popup, private: BrowserBox* mBrowserBox; }; + +#endif // GUI_POPUPS_CREATEPARTYPOPUP_H diff --git a/src/gui/setupactiondata.h b/src/gui/setupactiondata.h index 94a16668f..891875d7c 100644 --- a/src/gui/setupactiondata.h +++ b/src/gui/setupactiondata.h @@ -34,9 +34,9 @@ struct SetupActionData final { #ifdef ADVGCC - SetupActionData(const std::string name0, + SetupActionData(const std::string &name0, const int actionId0, - const std::string text0) : + const std::string &text0) : name(name0), actionId(actionId0), text(text0) diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index d96b7c943..a33104084 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -48,8 +48,6 @@ #include "gui/windows/ministatuswindow.h" -#include "listeners/updatestatuslistener.h" - #include "utils/delete2.h" #include "debug.h" diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index b5d3c3593..e098cda34 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -113,7 +113,7 @@ void AvatarListBox::draw(Graphics *graphics) Font *const font = getFont(); const int fontHeight = getFont()->getHeight(); - const std::string name = player_node->getName(); + const std::string &name = player_node->getName(); // Draw the list elements graphics->setColorAll(mForegroundColor, mForegroundColor2); @@ -242,15 +242,15 @@ void AvatarListBox::draw(Graphics *graphics) { switch (a->getGender()) { - case GENDER_FEMALE: + case Gender::FEMALE: text.append(" \u2640 "); break; - case GENDER_MALE: + case Gender::MALE: text.append(" \u2642 "); break; default: - case GENDER_UNSPECIFIED: - case GENDER_OTHER: + case Gender::UNSPECIFIED: + case Gender::OTHER: break; } } @@ -261,17 +261,17 @@ void AvatarListBox::draw(Graphics *graphics) { switch (a->getGender()) { - case GENDER_FEMALE: + case Gender::FEMALE: text.append(strprintf(" \u2640 %s", a->getAdditionString().c_str())); break; - case GENDER_MALE: + case Gender::MALE: text.append(strprintf(" \u2642 %s", a->getAdditionString().c_str())); break; default: - case GENDER_UNSPECIFIED: - case GENDER_OTHER: + case Gender::UNSPECIFIED: + case Gender::OTHER: break; } } diff --git a/src/gui/widgets/browserbox_unittest.cc b/src/gui/widgets/browserbox_unittest.cc index f8b5e149e..0a3e06f27 100644 --- a/src/gui/widgets/browserbox_unittest.cc +++ b/src/gui/widgets/browserbox_unittest.cc @@ -22,9 +22,10 @@ #include "client.h" -#include "gui/font.h" #include "gui/theme.h" +#include "gui/fonts/font.h" + #include "gui/widgets/browserbox.h" #include "resources/sdlimagehelper.h" diff --git a/src/gui/widgets/guitable.cpp b/src/gui/widgets/guitable.cpp index 400365a84..e6d3119fb 100644 --- a/src/gui/widgets/guitable.cpp +++ b/src/gui/widgets/guitable.cpp @@ -32,8 +32,6 @@ #include "listeners/guitableactionlistener.h" -#include "render/graphics.h" - #include "utils/delete2.h" #include "utils/dtor.h" diff --git a/src/gui/widgets/statuswindowattrs.h b/src/gui/widgets/statuswindowattrs.h index d266b2086..1cc755907 100644 --- a/src/gui/widgets/statuswindowattrs.h +++ b/src/gui/widgets/statuswindowattrs.h @@ -20,8 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef GUI_WINDOWS_STATUSWINDOWATTRS_H -#define GUI_WINDOWS_STATUSWINDOWATTRS_H +#ifndef GUI_WIDGETS_STATUSWINDOWATTRS_H +#define GUI_WIDGETS_STATUSWINDOWATTRS_H #include "gui/widgets/container.h" @@ -121,4 +121,4 @@ class ChangeDisplay final : public AttrDisplay, Button *mInc; }; -#endif // GUI_WINDOWS_STATUSWINDOWATTRS_H +#endif // GUI_WIDGETS_STATUSWINDOWATTRS_H diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index 47787d25d..4f81d2aa7 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -212,10 +212,13 @@ void ChatTab::chatLog(std::string line, ChatMsgType::Type own, // if configured, move magic messages log to debug chat tab if (localChatTab && this == localChatTab - && ((config.getBoolValue("showMagicInDebug") && own == ChatMsgType::BY_PLAYER - && tmp.text.length() > 1 && tmp.text.at(0) == '#' + && ((config.getBoolValue("showMagicInDebug") + && own == ChatMsgType::BY_PLAYER + && tmp.text.length() > 1 + && tmp.text.at(0) == '#' && tmp.text.at(1) != '#') - || (config.getBoolValue("serverMsgInDebug") && (own == ChatMsgType::BY_SERVER + || (config.getBoolValue("serverMsgInDebug") + && (own == ChatMsgType::BY_SERVER || tmp.nick.empty())))) { if (debugChatTab) diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp index 723131edc..b14208c3b 100644 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ b/src/gui/widgets/tabs/setup_relations.cpp @@ -39,7 +39,6 @@ #include "gui/widgets/guitable.h" #include "utils/delete2.h" -#include "utils/gettext.h" #include "debug.h" diff --git a/src/gui/widgets/tabs/socialattacktab.h b/src/gui/widgets/tabs/socialattacktab.h index 01921b016..17ee78eb0 100644 --- a/src/gui/widgets/tabs/socialattacktab.h +++ b/src/gui/widgets/tabs/socialattacktab.h @@ -31,8 +31,6 @@ #include "gui/widgets/tabs/socialtabbase.h" -#include "resources/map/mapitem.h" - #include "utils/delete2.h" #include "utils/gettext.h" diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h new file mode 100644 index 000000000..1ad209adb --- /dev/null +++ b/src/gui/widgets/tabs/socialfriendsfunctor.h @@ -0,0 +1,52 @@ +/* + * The ManaPlus Client + * Copyright (C) 2011-2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H +#define GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H + +#include "avatar.h" + +#include "localconsts.h" + +class SortFriendsFunctor final +{ + public: + bool operator() (const Avatar *const m1, + const Avatar *const m2) const + { + if (!m1 || !m2) + return false; + + if (m1->getOnline() != m2->getOnline()) + return m1->getOnline() > m2->getOnline(); + + if (m1->getName() != m2->getName()) + { + std::string s1 = m1->getName(); + std::string s2 = m2->getName(); + toLower(s1); + toLower(s2); + return s1 < s2; + } + return false; + } +}; + +#endif // GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h index 3d65e2678..0a43c6e2f 100644 --- a/src/gui/widgets/tabs/socialfriendstab.h +++ b/src/gui/widgets/tabs/socialfriendstab.h @@ -24,15 +24,15 @@ #include "gui/widgets/tabs/socialtab.h" #include "actormanager.h" -#include "avatar.h" -#include "being/actortype.h" #include "being/playerrelations.h" #include "gui/models/beingslistmodel.h" #include "gui/windows/whoisonline.h" +#include "gui/widgets/tabs/socialfriendsfunctor.h" + #include "utils/delete2.h" #include "utils/gettext.h" #include "utils/stringutils.h" @@ -41,33 +41,6 @@ #include "localconsts.h" -namespace -{ - static class SortFriendsFunctor final - { - public: - bool operator() (const Avatar *const m1, - const Avatar *const m2) const - { - if (!m1 || !m2) - return false; - - if (m1->getOnline() != m2->getOnline()) - return m1->getOnline() > m2->getOnline(); - - if (m1->getName() != m2->getName()) - { - std::string s1 = m1->getName(); - std::string s2 = m2->getName(); - toLower(s1); - toLower(s2); - return s1 < s2; - } - return false; - } - } friendSorter; -} // namespace - class SocialFriendsTab final : public SocialTab { public: @@ -75,7 +48,8 @@ class SocialFriendsTab final : public SocialTab std::string name, const bool showBackground) : SocialTab(widget), - mBeings(new BeingsListModel) + mBeings(new BeingsListModel), + mFriendSorter() { createControls(mBeings, showBackground); @@ -139,7 +113,7 @@ class SocialFriendsTab final : public SocialTab total ++; avatars->push_back(ava); } - std::sort(avatars->begin(), avatars->end(), friendSorter); + std::sort(avatars->begin(), avatars->end(), mFriendSorter); delete players; // TRANSLATORS: social window label @@ -151,6 +125,7 @@ class SocialFriendsTab final : public SocialTab private: BeingsListModel *mBeings; + SortFriendsFunctor mFriendSorter; }; #endif // GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h index ee40e146f..0347087b7 100644 --- a/src/gui/widgets/tabs/socialguildtab.h +++ b/src/gui/widgets/tabs/socialguildtab.h @@ -54,7 +54,8 @@ class SocialGuildTab final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::GUILD_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(guild, showBackground); @@ -81,7 +82,9 @@ class SocialGuildTab final : public SocialTab, localChatTab->chatLog(strprintf( // TRANSLATORS: chat message _("Invited user %s to guild %s."), - name.c_str(), mGuild->getName().c_str()), ChatMsgType::BY_SERVER); + name.c_str(), + mGuild->getName().c_str()), + ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -95,8 +98,10 @@ class SocialGuildTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: chat message - localChatTab->chatLog(strprintf(_("Guild %s quit requested."), - mGuild->getName().c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Guild %s quit requested."), + mGuild->getName().c_str()), + ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h index c5702b17d..ba40d7c4f 100644 --- a/src/gui/widgets/tabs/socialguildtab2.h +++ b/src/gui/widgets/tabs/socialguildtab2.h @@ -52,7 +52,8 @@ class SocialGuildTab2 final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::GUILD_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(guild, showBackground); @@ -70,7 +71,8 @@ class SocialGuildTab2 final : public SocialTab, { } - void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) + void buildCounter(const int online0 A_UNUSED, + const int total0 A_UNUSED) { if (!player_node) return; diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index e8925cbb2..4344e1251 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -204,7 +204,8 @@ class SocialNavigationTab final : public SocialTab if (item) { const std::string name = strprintf("%s [%d %d]", - item->getComment().c_str(), item->getX(), item->getY()); + item->getComment().c_str(), + item->getX(), item->getY()); ava->setName(name); ava->setOriginalName(name); } diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h index 247414851..847a43d42 100644 --- a/src/gui/widgets/tabs/socialpartytab.h +++ b/src/gui/widgets/tabs/socialpartytab.h @@ -55,7 +55,8 @@ class SocialPartyTab final : public SocialTab, setHighlightedTabColor(&getThemeColor( Theme::PARTY_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( Theme::PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED), + setSelectedTabColor(&getThemeColor( + Theme::PARTY_SOCIAL_TAB_SELECTED), &getThemeColor(Theme::PARTY_SOCIAL_TAB_SELECTED_OUTLINE)); createControls(party, showBackground); @@ -80,8 +81,10 @@ class SocialPartyTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: chat message - localChatTab->chatLog(strprintf(_("Invited user %s to party."), - name.c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Invited user %s to party."), + name.c_str()), + ChatMsgType::BY_SERVER); } mInviteDialog = nullptr; } @@ -95,8 +98,10 @@ class SocialPartyTab final : public SocialTab, if (localChatTab) { // TRANSLATORS: tab in social window - localChatTab->chatLog(strprintf(_("Party %s quit requested."), - mParty->getName().c_str()), ChatMsgType::BY_SERVER); + localChatTab->chatLog(strprintf( + _("Party %s quit requested."), + mParty->getName().c_str()), + ChatMsgType::BY_SERVER); } mConfirmDialog = nullptr; } @@ -129,7 +134,8 @@ class SocialPartyTab final : public SocialTab, mConfirmDialog->addActionListener(this); } - void buildCounter(const int online0 A_UNUSED, const int total0 A_UNUSED) + void buildCounter(const int online0 A_UNUSED, + const int total0 A_UNUSED) { if (!player_node) return; diff --git a/src/gui/widgets/tabs/socialpickuptab.h b/src/gui/widgets/tabs/socialpickuptab.h index 15d7c3aeb..3dd4d5959 100644 --- a/src/gui/widgets/tabs/socialpickuptab.h +++ b/src/gui/widgets/tabs/socialpickuptab.h @@ -46,7 +46,8 @@ class SocialPickupTab final : public SocialTab { createControls(mBeings, showBackground); - // TRANSLATORS: Pickup filter tab name in social window. Should be small + // TRANSLATORS: Pickup filter tab name in social window. + // TRANSLATORS: Should be small setCaption(_("Pik")); } diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h index bb2e2250a..78c03feb4 100644 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ b/src/gui/widgets/tabs/socialplayerstab.h @@ -78,7 +78,8 @@ class SocialPlayersTab final : public SocialTab return; if (Party::getParty(1)) { - const PartyMember *const pm = Party::getParty(1)->getMember(name); + const PartyMember *const + pm = Party::getParty(1)->getMember(name); if (pm && pm->getMaxHp() > 0) { avatar->setMaxHp(pm->getMaxHp()); diff --git a/src/gui/windows/botcheckerwindow.cpp b/src/gui/windows/botcheckerwindow.cpp index aa991b36b..8e4bdd047 100644 --- a/src/gui/windows/botcheckerwindow.cpp +++ b/src/gui/windows/botcheckerwindow.cpp @@ -29,12 +29,9 @@ #include "gui/models/userstablemodel.h" -#include "actormanager.h" #include "client.h" #include "configuration.h" -#include "being/localplayer.h" - #include "utils/gettext.h" #include "debug.h" diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp index f0daaeef2..6799bcaf8 100644 --- a/src/gui/windows/buydialog.cpp +++ b/src/gui/windows/buydialog.cpp @@ -159,7 +159,7 @@ namespace return type1 < type2; } } itemTypeBuySorter; -} +} // namespace BuyDialog::DialogList BuyDialog::instances; diff --git a/src/gui/windows/charcreatedialog.cpp b/src/gui/windows/charcreatedialog.cpp index 203ab01d2..cc254bce0 100644 --- a/src/gui/windows/charcreatedialog.cpp +++ b/src/gui/windows/charcreatedialog.cpp @@ -148,7 +148,7 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *const parent, setSticky(true); setWindowName("NewCharacter"); - mPlayer->setGender(GENDER_MALE); + mPlayer->setGender(Gender::MALE); const std::vector<int> &items = CharDB::getDefaultItems(); int i = 1; for (std::vector<int>::const_iterator it = items.begin(), @@ -410,9 +410,9 @@ void CharCreateDialog::action(const ActionEvent &event) else if (id == "gender") { if (mMale->isSelected()) - mPlayer->setGender(GENDER_MALE); + mPlayer->setGender(Gender::MALE); else - mPlayer->setGender(GENDER_FEMALE); + mPlayer->setGender(Gender::FEMALE); } else if (id == "action") { @@ -537,15 +537,16 @@ void CharCreateDialog::setAttributes(const StringVect &labels, setButtonsPosition(w, h); } -void CharCreateDialog::setFixedGender(const bool fixed, const Gender gender) +void CharCreateDialog::setFixedGender(const bool fixed, + const Gender::Type gender) { - if (gender == GENDER_FEMALE) + if (gender == Gender::FEMALE) { mFemale->setSelected(true); mMale->setSelected(false); mOther->setSelected(false); } - else if (gender == GENDER_MALE) + else if (gender == Gender::MALE) { mFemale->setSelected(false); mMale->setSelected(true); diff --git a/src/gui/windows/charcreatedialog.h b/src/gui/windows/charcreatedialog.h index e0a188303..58395e21e 100644 --- a/src/gui/windows/charcreatedialog.h +++ b/src/gui/windows/charcreatedialog.h @@ -73,7 +73,7 @@ class CharCreateDialog final : public Window, const int min, const int max); void setFixedGender(const bool fixed, - const Gender gender = GENDER_FEMALE); + const Gender::Type gender = Gender::FEMALE); void logic() override final; diff --git a/src/gui/windows/chardeleteconfirm.h b/src/gui/windows/chardeleteconfirm.h index 4ab990eae..06840ceda 100644 --- a/src/gui/windows/chardeleteconfirm.h +++ b/src/gui/windows/chardeleteconfirm.h @@ -20,6 +20,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef GUI_WINDOWS_CHARDELETECONFIRM_H +#define GUI_WINDOWS_CHARDELETECONFIRM_H + #include "gui/windows/charselectdialog.h" #include "gui/windows/confirmdialog.h" @@ -58,3 +61,5 @@ class CharDeleteConfirm final : public ConfirmDialog CharSelectDialog *mMaster; int mIndex; }; + +#endif // GUI_WINDOWS_CHARDELETECONFIRM_H diff --git a/src/gui/windows/charselectdialog.cpp b/src/gui/windows/charselectdialog.cpp index 66460f4e7..74a135bab 100644 --- a/src/gui/windows/charselectdialog.cpp +++ b/src/gui/windows/charselectdialog.cpp @@ -48,8 +48,6 @@ #include "net/loginhandler.h" #include "net/net.h" -#include "utils/gettext.h" - #include "debug.h" // Character slots per row in the dialog diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 8dc915604..bcf51d023 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -147,4 +147,3 @@ void DebugWindow::logicChildren() BLOCK_END("DebugWindow::logicChildren") } #endif - diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index c2b00e87e..4d49eedd9 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -49,7 +49,6 @@ #include "gui/widgets/slider.h" #include "utils/delete2.h" -#include "utils/gettext.h" #include <cmath> diff --git a/src/gui/windows/logindialog.cpp b/src/gui/windows/logindialog.cpp index 01d1bcd61..99354f4fb 100644 --- a/src/gui/windows/logindialog.cpp +++ b/src/gui/windows/logindialog.cpp @@ -44,11 +44,9 @@ #include "gui/widgets/layoutcell.h" #include "net/charserverhandler.h" -#include "net/logindata.h" #include "net/loginhandler.h" #include "net/net.h" -#include "utils/gettext.h" #include "utils/paths.h" #include "debug.h" diff --git a/src/gui/windows/registerdialog.cpp b/src/gui/windows/registerdialog.cpp index 2ecf5fc87..61b7e0dac 100644 --- a/src/gui/windows/registerdialog.cpp +++ b/src/gui/windows/registerdialog.cpp @@ -253,11 +253,11 @@ void RegisterDialog::action(const ActionEvent &event) mLoginData->username = mUserField->getText(); mLoginData->password = mPasswordField->getText(); if (mFemaleButton && mFemaleButton->isSelected()) - mLoginData->gender = GENDER_FEMALE; + mLoginData->gender = Gender::FEMALE; else if (mOtherButton && mOtherButton->isSelected()) - mLoginData->gender = GENDER_OTHER; + mLoginData->gender = Gender::OTHER; else - mLoginData->gender = GENDER_MALE; + mLoginData->gender = Gender::MALE; if (mEmailField) mLoginData->email = mEmailField->getText(); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 04e2f1511..903a21a57 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -49,7 +49,6 @@ #include "inventory.h" #include "item.h" #include "shopitem.h" -#include "soundconsts.h" #include "soundmanager.h" #include "being/attributes.h" diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp index 2a858d964..7b0aa849a 100644 --- a/src/gui/windows/socialwindow.cpp +++ b/src/gui/windows/socialwindow.cpp @@ -50,13 +50,6 @@ #include "gui/popups/createpartypopup.h" -#include "net/net.h" -#include "net/guildhandler.h" -#include "net/partyhandler.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - #include "debug.h" extern unsigned int tmwServerVersion; diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 7ae87c470..797ba68fe 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -22,6 +22,9 @@ #include "gui/windows/whoisonline.h" +#include "actormanager.h" +#include "client.h" +#include "configuration.h" #include "guild.h" #include "party.h" @@ -35,11 +38,6 @@ #include "gui/widgets/browserbox.h" #include "gui/widgets/scrollarea.h" -#include "actormanager.h" -#include "client.h" -#include "configuration.h" -#include "main.h" - #include "being/beingflag.h" #include "being/localplayer.h" #include "being/playerrelations.h" @@ -440,7 +438,7 @@ void WhoIsOnline::loadWebList() OnlinePlayer *const player = new OnlinePlayer(nick, static_cast<unsigned char>(255), level, - GENDER_UNSPECIFIED, -1); + Gender::UNSPECIFIED, -1); mOnlinePlayers.insert(player); mOnlineNicks.insert(nick); @@ -829,9 +827,9 @@ void OnlinePlayer::setText(std::string color) if (mLevel > 0) mText.append(strprintf("%d", mLevel)); - if (mGender == GENDER_FEMALE) + if (mGender == Gender::FEMALE) mText.append("\u2640"); - else if (mGender == GENDER_MALE) + else if (mGender == Gender::MALE) mText.append("\u2642"); if (mStatus > 0 && mStatus != 255) diff --git a/src/guildmanager.cpp b/src/guildmanager.cpp index 94d1cc3df..a55f2a96d 100644 --- a/src/guildmanager.cpp +++ b/src/guildmanager.cpp @@ -192,7 +192,7 @@ void GuildManager::updateList() if (m) { m->setOnline(status & 1); - m->setGender(GENDER_UNSPECIFIED); + m->setGender(Gender::UNSPECIFIED); if (status & 2) m->setPos(10); else diff --git a/src/inventory.cpp b/src/inventory.cpp index 4bb3f7892..a2e890306 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -219,7 +219,7 @@ void Inventory::distributeSlotsChangedEvent() } const Item *Inventory::findItemBySprite(std::string spritePath, - const Gender gender, + const Gender::Type gender, const int race) const { spritePath = removeSpriteIndex(spritePath); diff --git a/src/inventory.h b/src/inventory.h index b1d359daf..86bdb080a 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -144,7 +144,7 @@ class Inventory final { return mType == INVENTORY; } const Item *findItemBySprite(std::string spritePath, - const Gender gender, + const Gender::Type gender, const int race) const A_WARN_UNUSED; std::string getName() const A_WARN_UNUSED; diff --git a/src/listeners/openurllistener.h b/src/listeners/openurllistener.h index 2fdd6b945..61780474e 100644 --- a/src/listeners/openurllistener.h +++ b/src/listeners/openurllistener.h @@ -20,6 +20,9 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef LISTENERS_OPENURLLISTENER_H +#define LISTENERS_OPENURLLISTENER_H + #include "listeners/actionlistener.h" #include "utils/process.h" @@ -46,3 +49,5 @@ struct OpenUrlListener final : public ActionListener std::string url; }; + +#endif // LISTENERS_OPENURLLISTENER_H diff --git a/src/listeners/wrongdatanoticelistener.cpp b/src/listeners/wrongdatanoticelistener.cpp index 157ce8a4e..11b209ab2 100644 --- a/src/listeners/wrongdatanoticelistener.cpp +++ b/src/listeners/wrongdatanoticelistener.cpp @@ -42,4 +42,3 @@ void WrongDataNoticeListener::action(const ActionEvent &event) if (event.getId() == "ok" && mTarget) mTarget->requestFocus(); } - diff --git a/src/net/ea/beinghandler.cpp b/src/net/ea/beinghandler.cpp index c983cfd9d..8366d1dc4 100644 --- a/src/net/ea/beinghandler.cpp +++ b/src/net/ea/beinghandler.cpp @@ -280,16 +280,16 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, switch (gender) { case 2: - dstBeing->setGender(GENDER_FEMALE); + dstBeing->setGender(Gender::FEMALE); break; case 3: - dstBeing->setGender(GENDER_MALE); + dstBeing->setGender(Gender::MALE); break; case 4: - dstBeing->setGender(GENDER_OTHER); + dstBeing->setGender(Gender::OTHER); break; default: - dstBeing->setGender(GENDER_UNSPECIFIED); + dstBeing->setGender(Gender::UNSPECIFIED); break; } } diff --git a/src/net/ea/chathandler.cpp b/src/net/ea/chathandler.cpp index c880de0f6..40dc15a15 100644 --- a/src/net/ea/chathandler.cpp +++ b/src/net/ea/chathandler.cpp @@ -106,8 +106,9 @@ void ChatHandler::processWhisperResponse(Net::MessageIn &msg) { chatWindow->addWhisper(nick, // TRANSLATORS: chat message - strprintf(_("Whisper could not be " - "sent, %s is offline."), nick.c_str()), ChatMsgType::BY_SERVER); + strprintf(_("Whisper could not be sent, %s is offline."), + nick.c_str()), + ChatMsgType::BY_SERVER); } break; case 0x02: @@ -328,8 +329,9 @@ void ChatHandler::processBeingChat(Net::MessageIn &msg, if (player_relations.checkPermissionSilently(sender_name, PlayerRelation::SPEECH_LOG) && chatWindow) { - allow = chatWindow->resortChatLog(removeColors(sender_name) - .append(" : ").append(chatMsg), ChatMsgType::BY_OTHER, channel, false, true); + allow = chatWindow->resortChatLog( + removeColors(sender_name).append(" : ").append(chatMsg), + ChatMsgType::BY_OTHER, channel, false, true); } if (allow && player_relations.hasPermission(sender_name, diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index 25ad6d916..c53cdb773 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -102,16 +102,16 @@ void LoginHandler::registerAccount(const LoginData *const loginData1) const std::string username = loginData1->username; switch (loginData1->gender) { - case GENDER_FEMALE: + case Gender::FEMALE: username.append("_F"); break; - case GENDER_MALE: + case Gender::MALE: username.append("_M"); break; - case GENDER_OTHER: + case Gender::OTHER: username.append("_O"); break; - case GENDER_UNSPECIFIED: + case Gender::UNSPECIFIED: default: break; } diff --git a/src/net/ea/token.h b/src/net/ea/token.h index dadc341c7..35aadd02c 100644 --- a/src/net/ea/token.h +++ b/src/net/ea/token.h @@ -30,14 +30,14 @@ struct Token int account_ID; int session_ID1; int session_ID2; - Gender sex; + Gender::Type sex; void clear() { account_ID = 0; session_ID1 = 0; session_ID2 = 0; - sex = GENDER_UNSPECIFIED; + sex = Gender::UNSPECIFIED; } }; diff --git a/src/net/eathena/beinghandler.cpp b/src/net/eathena/beinghandler.cpp index e07062585..136f19b03 100644 --- a/src/net/eathena/beinghandler.cpp +++ b/src/net/eathena/beinghandler.cpp @@ -758,16 +758,16 @@ void BeingHandler::processBeingVisibleOrMove(Net::MessageIn &msg, switch (gender) { case 2: - dstBeing->setGender(GENDER_FEMALE); + dstBeing->setGender(Gender::FEMALE); break; case 3: - dstBeing->setGender(GENDER_MALE); + dstBeing->setGender(Gender::MALE); break; case 4: - dstBeing->setGender(GENDER_OTHER); + dstBeing->setGender(Gender::OTHER); break; default: - dstBeing->setGender(GENDER_UNSPECIFIED); + dstBeing->setGender(Gender::UNSPECIFIED); break; } } diff --git a/src/net/logindata.h b/src/net/logindata.h index a2179a0b9..69dbfbb66 100644 --- a/src/net/logindata.h +++ b/src/net/logindata.h @@ -45,7 +45,7 @@ class LoginData final email(), captchaResponse(), registerUrl(), - gender(GENDER_UNSPECIFIED), + gender(Gender::UNSPECIFIED), remember(false), registerLogin(false), characterSlots(9) @@ -74,7 +74,7 @@ class LoginData final std::string captchaResponse; std::string registerUrl; - Gender gender; + Gender::Type gender; bool remember; // Whether to store the username. bool registerLogin; // Whether an account is being registered. @@ -92,7 +92,7 @@ class LoginData final email.clear(); captchaResponse.clear(); registerUrl.clear(); - gender = GENDER_UNSPECIFIED; + gender = Gender::UNSPECIFIED; lastLogin.clear(); resetCharacterSlots(); } diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index c8cee7979..a0246dbd4 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -285,17 +285,17 @@ void PlayerHandler::processOnlineList(Net::MessageIn &msg) } buf ++; - int gender = GENDER_UNSPECIFIED; + int gender = Gender::UNSPECIFIED; if (serverVersion >= 4) { if (config.getBoolValue("showgender")) { if (status & BeingFlag::GENDER_MALE) - gender = GENDER_MALE; + gender = Gender::MALE; else if (status & BeingFlag::GENDER_OTHER) - gender = GENDER_OTHER; + gender = Gender::OTHER; else - gender = GENDER_FEMALE; + gender = Gender::FEMALE; } } arr.push_back(new OnlinePlayer(static_cast<const char*>(buf), diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp index c2d58fccc..32b724de9 100644 --- a/src/resources/db/itemdb.cpp +++ b/src/resources/db/itemdb.cpp @@ -224,9 +224,9 @@ void ItemDB::load() mUnknown->setName(_("Unknown item")); mUnknown->setDisplay(SpriteDisplay()); std::string errFile = paths.getStringValue("spriteErrorFile"); - mUnknown->setSprite(errFile, GENDER_MALE, 0); - mUnknown->setSprite(errFile, GENDER_FEMALE, 0); - mUnknown->setSprite(errFile, GENDER_OTHER, 0); + mUnknown->setSprite(errFile, Gender::MALE, 0); + mUnknown->setSprite(errFile, Gender::FEMALE, 0); + mUnknown->setSprite(errFile, Gender::OTHER, 0); mUnknown->addTag(mTags["All"]); loadXmlFile(paths.getStringValue("itemsFile"), tagNum); loadXmlFile(paths.getStringValue("itemsPatchFile"), tagNum); @@ -749,11 +749,11 @@ void loadSpriteRef(ItemInfo *const itemInfo, const XmlNodePtr node) const int race = XML::getProperty(node, "race", 0); if (gender == "male" || gender == "unisex") - itemInfo->setSprite(filename, GENDER_MALE, race); + itemInfo->setSprite(filename, Gender::MALE, race); if (gender == "female" || gender == "unisex") - itemInfo->setSprite(filename, GENDER_FEMALE, race); + itemInfo->setSprite(filename, Gender::FEMALE, race); if (gender == "other" || gender == "unisex") - itemInfo->setSprite(filename, GENDER_OTHER, race); + itemInfo->setSprite(filename, Gender::OTHER, race); } void loadSoundRef(ItemInfo *const itemInfo, const XmlNodePtr node) diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index d405e6909..e6b56c43b 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -84,7 +84,7 @@ ItemInfo::~ItemInfo() mSpriteToItemReplaceMap[f] = nullptr; } -const std::string &ItemInfo::getSprite(const Gender gender, +const std::string &ItemInfo::getSprite(const Gender::Type gender, const int race) const { if (mView) @@ -346,7 +346,8 @@ int ItemInfo::getDrawPriority(const int direction) const } void ItemInfo::setSprite(const std::string &animationFile, - const Gender gender, const int race) + const Gender::Type gender, + const int race) { mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile; } diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h index 9b8c1656a..4ea61664d 100644 --- a/src/resources/iteminfo.h +++ b/src/resources/iteminfo.h @@ -165,9 +165,9 @@ class ItemInfo final { mView = view; } void setSprite(const std::string &animationFile, - const Gender gender, const int race); + const Gender::Type gender, const int race); - const std::string &getSprite(const Gender gender, + const std::string &getSprite(const Gender::Type gender, const int race) const A_WARN_UNUSED; void setAttackAction(const std::string &attackAction); diff --git a/src/resources/skillconsts.h b/src/resources/skillconsts.h index fd5181515..bba04eb47 100644 --- a/src/resources/skillconsts.h +++ b/src/resources/skillconsts.h @@ -18,10 +18,10 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef GUI_RESOURCES_SKILLCONSTS_H -#define GUI_RESOURCES_SKILLCONSTS_H +#ifndef RESOURCES_SKILLCONSTS_H +#define RESOURCES_SKILLCONSTS_H const int SKILL_MIN_ID = 200000; const unsigned int SKILL_VAR_MIN_ID = 1000000; -#endif // GUI_RESOURCES_SKILLCONSTS_H +#endif // RESOURCES_SKILLCONSTS_H diff --git a/src/resources/updatefile.h b/src/resources/updatefile.h index 0e07fc112..fb4e522d8 100644 --- a/src/resources/updatefile.h +++ b/src/resources/updatefile.h @@ -20,8 +20,8 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef GUI_RESOURCES_UPDATEFILE_H -#define GUI_RESOURCES_UPDATEFILE_H +#ifndef RESOURCES_UPDATEFILE_H +#define RESOURCES_UPDATEFILE_H #include <string> @@ -45,4 +45,4 @@ struct UpdateFile final bool required; }; -#endif // GUI_RESOURCES_UPDATEFILE_H +#endif // RESOURCES_UPDATEFILE_H |