summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-05 10:13:15 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-03-06 21:49:14 +0000
commit3ce39d2b497ab5356290a22b324181386af51c51 (patch)
tree1b923b8be7e4d2ce8ff70768dc7fff596487935c /src/gui
parenta9df89bda908e3b3d443db7f3ca865b6f12c75e5 (diff)
downloadmana-3ce39d2b497ab5356290a22b324181386af51c51.tar.gz
mana-3ce39d2b497ab5356290a22b324181386af51c51.tar.bz2
mana-3ce39d2b497ab5356290a22b324181386af51c51.tar.xz
mana-3ce39d2b497ab5356290a22b324181386af51c51.zip
General code cleanups
* Use final for all message handlers, Client, LocalPlayer, Being::getType, Being::setPosition and Being::setMap. (avoids some warnings about virtual dispatch in constructors) * Use auto in more places * Use emplace_back instead of push_back in some places * Use default member initializers * Less else after return * Removed superfluous .c_str() * Removed type aliases that are only used once * Removed more unused includes
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/charselectdialog.cpp22
-rw-r--r--src/gui/charselectdialog.h6
-rw-r--r--src/gui/serverdialog.cpp6
-rw-r--r--src/gui/textpopup.cpp9
-rw-r--r--src/gui/textpopup.h2
5 files changed, 9 insertions, 36 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp
index a0a14c65..7792813c 100644
--- a/src/gui/charselectdialog.cpp
+++ b/src/gui/charselectdialog.cpp
@@ -111,10 +111,6 @@ class CharacterDisplay : public Container
CharSelectDialog::CharSelectDialog(LoginData *loginData):
Window(_("Account and Character Management")),
- mLocked(false),
- mUnregisterButton(nullptr),
- mChangeEmailButton(nullptr),
- mCharacterEntries(0),
mLoginData(loginData),
mCharHandler(Net::getCharHandler())
{
@@ -168,9 +164,7 @@ CharSelectDialog::CharSelectDialog(LoginData *loginData):
mCharacterEntries[0]->requestFocus();
}
-CharSelectDialog::~CharSelectDialog()
-{
-}
+CharSelectDialog::~CharSelectDialog() = default;
void CharSelectDialog::action(const gcn::ActionEvent &event)
{
@@ -265,20 +259,14 @@ void CharSelectDialog::attemptCharacterSelect(int index)
void CharSelectDialog::setCharacters(const Net::Characters &characters)
{
// Reset previous characters
- std::vector<CharacterDisplay*>::iterator iter, iter_end;
- for (iter = mCharacterEntries.begin(), iter_end = mCharacterEntries.end();
- iter != iter_end; ++iter)
- (*iter)->setCharacter(nullptr);
+ for (auto *characterEntry : mCharacterEntries)
+ characterEntry->setCharacter(nullptr);
- Net::Characters::const_iterator i, i_end = characters.end();
- for (i = characters.begin(); i != i_end; ++i)
+ for (auto character : characters)
{
- Net::Character *character = *i;
-
// Slots Number start at 1 for Manaserv, so we offset them by one.
int characterSlot = character->slot;
- if (Net::getNetworkType() == ServerType::MANASERV
- && characterSlot > 0)
+ if (Net::getNetworkType() == ServerType::MANASERV && characterSlot > 0)
--characterSlot;
if (characterSlot >= (int)mCharacterEntries.size())
diff --git a/src/gui/charselectdialog.h b/src/gui/charselectdialog.h
index d30e4e68..2deb5a7d 100644
--- a/src/gui/charselectdialog.h
+++ b/src/gui/charselectdialog.h
@@ -84,14 +84,14 @@ class CharSelectDialog : public Window, public gcn::ActionListener,
void unlock();
void setLocked(bool locked);
- bool mLocked;
+ bool mLocked = false;
gcn::Label *mAccountNameLabel;
gcn::Button *mSwitchLoginButton;
gcn::Button *mChangePasswordButton;
- gcn::Button *mUnregisterButton;
- gcn::Button *mChangeEmailButton;
+ gcn::Button *mUnregisterButton = nullptr;
+ gcn::Button *mChangeEmailButton = nullptr;
/** The player boxes */
std::vector<CharacterDisplay*> mCharacterEntries;
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index bad2c2b5..5b8372ee 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -26,7 +26,6 @@
#include "configuration.h"
#include "gui.h"
#include "log.h"
-#include "main.h"
#include "gui/customserverdialog.h"
#include "gui/okdialog.h"
@@ -40,8 +39,6 @@
#include "gui/widgets/scrollarea.h"
#include "gui/widgets/textfield.h"
-#include "net/net.h"
-
#include "resources/theme.h"
#include "utils/gettext.h"
@@ -474,8 +471,7 @@ void ServerDialog::loadServers()
std::string version = XML::getProperty(serverNode, "minimumVersion",
std::string());
- bool meetsMinimumVersion = (compareStrI(version, PACKAGE_VERSION)
- <= 0);
+ bool meetsMinimumVersion = compareStrI(version, PACKAGE_VERSION) <= 0;
// For display in the list
if (meetsMinimumVersion)
diff --git a/src/gui/textpopup.cpp b/src/gui/textpopup.cpp
index 57f80275..4e8272d6 100644
--- a/src/gui/textpopup.cpp
+++ b/src/gui/textpopup.cpp
@@ -24,15 +24,10 @@
#include "gui/textpopup.h"
#include "gui/gui.h"
-#include "gui/palette.h"
#include "gui/widgets/label.h"
#include "graphics.h"
-#include "units.h"
-
-#include "utils/gettext.h"
-#include "utils/stringutils.h"
#include <guichan/font.hpp>
#include <guichan/widgets/label.hpp>
@@ -53,10 +48,6 @@ TextPopup::TextPopup():
addMouseListener(this);
}
-TextPopup::~TextPopup()
-{
-}
-
void TextPopup::show(int x, int y, const std::string &str1, const std::string &str2)
{
mText1->setCaption(str1);
diff --git a/src/gui/textpopup.h b/src/gui/textpopup.h
index cda8d14a..b12d4475 100644
--- a/src/gui/textpopup.h
+++ b/src/gui/textpopup.h
@@ -38,8 +38,6 @@ class TextPopup : public Popup
public:
TextPopup();
- ~TextPopup() override;
-
/**
* Sets the text to be displayed.
*/