summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-26 16:07:54 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-01-26 16:07:54 +0100
commit5afe88df2538274859a162ffd63ed52118e80c19 (patch)
treeb610dfd58dc748fd63f49565b2a43eea2316714f /src/net
parent73ba2a95f5bd4a0dd09af52d5864800be2b0a4c6 (diff)
downloadmana-5afe88df2538274859a162ffd63ed52118e80c19.tar.gz
mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.bz2
mana-5afe88df2538274859a162ffd63ed52118e80c19.tar.xz
mana-5afe88df2538274859a162ffd63ed52118e80c19.zip
Apply C++11 fixits
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
Diffstat (limited to 'src/net')
-rw-r--r--src/net/charhandler.h10
-rw-r--r--src/net/download.cpp24
-rw-r--r--src/net/download.h8
-rw-r--r--src/net/manaserv/adminhandler.h22
-rw-r--r--src/net/manaserv/beinghandler.cpp12
-rw-r--r--src/net/manaserv/beinghandler.h2
-rw-r--r--src/net/manaserv/buysellhandler.cpp4
-rw-r--r--src/net/manaserv/buysellhandler.h2
-rw-r--r--src/net/manaserv/charhandler.cpp14
-rw-r--r--src/net/manaserv/charhandler.h30
-rw-r--r--src/net/manaserv/chathandler.cpp2
-rw-r--r--src/net/manaserv/chathandler.h26
-rw-r--r--src/net/manaserv/connection.cpp4
-rw-r--r--src/net/manaserv/effecthandler.h2
-rw-r--r--src/net/manaserv/gamehandler.h20
-rw-r--r--src/net/manaserv/generalhandler.cpp8
-rw-r--r--src/net/manaserv/generalhandler.h12
-rw-r--r--src/net/manaserv/guildhandler.cpp2
-rw-r--r--src/net/manaserv/guildhandler.h28
-rw-r--r--src/net/manaserv/inventoryhandler.cpp26
-rw-r--r--src/net/manaserv/inventoryhandler.h38
-rw-r--r--src/net/manaserv/itemhandler.h2
-rw-r--r--src/net/manaserv/loginhandler.h34
-rw-r--r--src/net/manaserv/messagehandler.h4
-rw-r--r--src/net/manaserv/messageout.cpp2
-rw-r--r--src/net/manaserv/network.cpp12
-rw-r--r--src/net/manaserv/npchandler.cpp2
-rw-r--r--src/net/manaserv/npchandler.h28
-rw-r--r--src/net/manaserv/partyhandler.cpp2
-rw-r--r--src/net/manaserv/partyhandler.h30
-rw-r--r--src/net/manaserv/playerhandler.cpp2
-rw-r--r--src/net/manaserv/playerhandler.h40
-rw-r--r--src/net/manaserv/specialhandler.h10
-rw-r--r--src/net/manaserv/tradehandler.cpp4
-rw-r--r--src/net/manaserv/tradehandler.h18
-rw-r--r--src/net/net.cpp30
-rw-r--r--src/net/playerhandler.h2
-rw-r--r--src/net/serverinfo.h4
-rw-r--r--src/net/tmwa/adminhandler.h22
-rw-r--r--src/net/tmwa/beinghandler.cpp2
-rw-r--r--src/net/tmwa/beinghandler.h2
-rw-r--r--src/net/tmwa/buysellhandler.cpp2
-rw-r--r--src/net/tmwa/buysellhandler.h2
-rw-r--r--src/net/tmwa/charserverhandler.cpp20
-rw-r--r--src/net/tmwa/charserverhandler.h26
-rw-r--r--src/net/tmwa/chathandler.h28
-rw-r--r--src/net/tmwa/gamehandler.cpp2
-rw-r--r--src/net/tmwa/gamehandler.h22
-rw-r--r--src/net/tmwa/generalhandler.cpp8
-rw-r--r--src/net/tmwa/generalhandler.h16
-rw-r--r--src/net/tmwa/gui/guildtab.h12
-rw-r--r--src/net/tmwa/gui/partytab.h12
-rw-r--r--src/net/tmwa/guildhandler.cpp4
-rw-r--r--src/net/tmwa/guildhandler.h28
-rw-r--r--src/net/tmwa/inventoryhandler.cpp14
-rw-r--r--src/net/tmwa/inventoryhandler.h26
-rw-r--r--src/net/tmwa/itemhandler.h2
-rw-r--r--src/net/tmwa/loginhandler.cpp2
-rw-r--r--src/net/tmwa/loginhandler.h34
-rw-r--r--src/net/tmwa/messagehandler.cpp2
-rw-r--r--src/net/tmwa/messagehandler.h4
-rw-r--r--src/net/tmwa/network.cpp22
-rw-r--r--src/net/tmwa/network.h4
-rw-r--r--src/net/tmwa/npchandler.cpp2
-rw-r--r--src/net/tmwa/npchandler.h28
-rw-r--r--src/net/tmwa/partyhandler.cpp8
-rw-r--r--src/net/tmwa/partyhandler.h32
-rw-r--r--src/net/tmwa/playerhandler.cpp8
-rw-r--r--src/net/tmwa/playerhandler.h38
-rw-r--r--src/net/tmwa/specialhandler.h10
-rw-r--r--src/net/tmwa/tradehandler.cpp6
-rw-r--r--src/net/tmwa/tradehandler.h18
-rw-r--r--src/net/worldinfo.h2
73 files changed, 495 insertions, 497 deletions
diff --git a/src/net/charhandler.h b/src/net/charhandler.h
index 1835ceb9..4b108cac 100644
--- a/src/net/charhandler.h
+++ b/src/net/charhandler.h
@@ -40,7 +40,7 @@ struct Character
{
Character() :
slot(0),
- dummy(0)
+ dummy(nullptr)
{
}
@@ -54,7 +54,7 @@ struct Character
PlayerInfoBackend data;
};
-typedef std::list<Character*> Characters;
+using Characters = std::list<Character *>;
class CharHandler
{
@@ -97,9 +97,9 @@ class CharHandler
protected:
CharHandler():
- mSelectedCharacter(0),
- mCharSelectDialog(0),
- mCharCreateDialog(0)
+ mSelectedCharacter(nullptr),
+ mCharSelectDialog(nullptr),
+ mCharCreateDialog(nullptr)
{}
void updateCharSelectDialog();
diff --git a/src/net/download.cpp b/src/net/download.cpp
index 61cdf114..d15eb18d 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -66,11 +66,11 @@ Download::Download(void *ptr, const std::string &url,
mPtr(ptr),
mUrl(url),
mFileName(""),
- mWriteFunction(NULL),
+ mWriteFunction(nullptr),
mUpdateFunction(updateFunction),
- mThread(NULL),
- mCurl(NULL),
- mHeaders(NULL)
+ mThread(nullptr),
+ mCurl(nullptr),
+ mHeaders(nullptr)
{
mError = (char*) malloc(CURL_ERROR_SIZE);
@@ -145,8 +145,8 @@ void Download::cancel()
mOptions.cancel = true;
if (mThread && SDL_GetThreadID(mThread) != 0)
{
- SDL_WaitThread(mThread, NULL);
- mThread = NULL;
+ SDL_WaitThread(mThread, nullptr);
+ mThread = nullptr;
}
}
@@ -158,7 +158,7 @@ char *Download::getError()
int Download::downloadProgress(void *clientp, double dltotal, double dlnow,
double ultotal, double ulnow)
{
- Download *d = reinterpret_cast<Download*>(clientp);
+ auto *d = reinterpret_cast<Download*>(clientp);
if (d->mOptions.cancel)
{
@@ -174,7 +174,7 @@ int Download::downloadThread(void *ptr)
{
int attempts = 0;
bool complete = false;
- Download *d = reinterpret_cast<Download*>(ptr);
+ auto *d = reinterpret_cast<Download*>(ptr);
CURLcode res;
std::string outFilename;
@@ -189,13 +189,13 @@ int Download::downloadThread(void *ptr)
while (attempts < 3 && !complete && !d->mOptions.cancel)
{
- FILE *file = NULL;
+ FILE *file = nullptr;
d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_STARTING, 0, 0);
if (d->mOptions.cancel)
{
- d->mThread = NULL;
+ d->mThread = nullptr;
return 0;
}
@@ -309,7 +309,7 @@ int Download::downloadThread(void *ptr)
}
if (d->mOptions.cancel)
{
- d->mThread = NULL;
+ d->mThread = nullptr;
return 0;
}
attempts++;
@@ -328,7 +328,7 @@ int Download::downloadThread(void *ptr)
d->mUpdateFunction(d->mPtr, DOWNLOAD_STATUS_COMPLETE, 0, 0);
}
- d->mThread = NULL;
+ d->mThread = nullptr;
return 0;
}
diff --git a/src/net/download.h b/src/net/download.h
index 26810f3f..b3501363 100644
--- a/src/net/download.h
+++ b/src/net/download.h
@@ -35,15 +35,13 @@ enum DownloadStatus
DOWNLOAD_STATUS_COMPLETE
};
-typedef int (*DownloadUpdate)(void *ptr, DownloadStatus status,
- size_t total, size_t remaining);
+using DownloadUpdate = int (*)(void *, DownloadStatus, size_t, size_t);
// Matches what CURL expects
-typedef size_t (*WriteFunction)( void *ptr, size_t size, size_t nmemb,
- void *stream);
+using WriteFunction = size_t (*)(void *, size_t, size_t, void *);
struct SDL_Thread;
-typedef void CURL;
+using CURL = void;
struct curl_slist;
namespace Net {
diff --git a/src/net/manaserv/adminhandler.h b/src/net/manaserv/adminhandler.h
index 83fbb854..1edcf6b6 100644
--- a/src/net/manaserv/adminhandler.h
+++ b/src/net/manaserv/adminhandler.h
@@ -33,27 +33,27 @@ class AdminHandler : public Net::AdminHandler, public MessageHandler
public:
AdminHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void announce(const std::string &text);
+ void announce(const std::string &text) override;
- void localAnnounce(const std::string &text);
+ void localAnnounce(const std::string &text) override;
- void hide(bool hide);
+ void hide(bool hide) override;
- void kick(int playerId);
+ void kick(int playerId) override;
- void kick(const std::string &name);
+ void kick(const std::string &name) override;
- void ban(int playerId);
+ void ban(int playerId) override;
- void ban(const std::string &name);
+ void ban(const std::string &name) override;
- void unban(int playerId);
+ void unban(int playerId) override;
- void unban(const std::string &name);
+ void unban(const std::string &name) override;
- void mute(int playerId, int type, int limit);
+ void mute(int playerId, int type, int limit) override;
};
} // namespace ManaServ
diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp
index 61b4ef81..6be90d51 100644
--- a/src/net/manaserv/beinghandler.cpp
+++ b/src/net/manaserv/beinghandler.cpp
@@ -113,10 +113,10 @@ void BeingHandler::handleBeingEnterMessage(MessageIn &msg)
{
int type = msg.readInt8();
int id = msg.readInt16();
- Being::Action action = (Being::Action)msg.readInt8();
+ auto action = (Being::Action)msg.readInt8();
int px = msg.readInt16();
int py = msg.readInt16();
- BeingDirection direction = (BeingDirection)msg.readInt8();
+ auto direction = (BeingDirection)msg.readInt8();
Gender gender;
int genderAsInt = msg.readInt8();
if (genderAsInt == ::GENDER_FEMALE)
@@ -241,7 +241,7 @@ void BeingHandler::handleBeingsMoveMessage(MessageIn &msg)
void BeingHandler::handleBeingAttackMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
- const BeingDirection direction = (BeingDirection) msg.readInt8();
+ const auto direction = (BeingDirection) msg.readInt8();
const int attackId = msg.readInt8();
if (!being)
@@ -260,7 +260,7 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
int damage = msg.readInt16();
if (being)
{
- being->takeDamage(0, damage, Being::HIT);
+ being->takeDamage(nullptr, damage, Being::HIT);
}
}
}
@@ -268,7 +268,7 @@ void BeingHandler::handleBeingsDamageMessage(MessageIn &msg)
void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
- Being::Action action = (Being::Action) msg.readInt8();
+ auto action = (Being::Action) msg.readInt8();
if (!being)
return;
@@ -299,7 +299,7 @@ void BeingHandler::handleBeingActionChangeMessage(MessageIn &msg)
};
std::string message(deadMsg[rand()%13]);
message.append(std::string(" ") + _("Press OK to respawn."));
- OkDialog *dlg = new OkDialog(_("You Died"), message, false);
+ auto *dlg = new OkDialog(_("You Died"), message, false);
dlg->addActionListener(&(ManaServ::respawnListener));
}
}
diff --git a/src/net/manaserv/beinghandler.h b/src/net/manaserv/beinghandler.h
index 94cf20c4..3d80f45f 100644
--- a/src/net/manaserv/beinghandler.h
+++ b/src/net/manaserv/beinghandler.h
@@ -43,7 +43,7 @@ class BeingHandler : public MessageHandler
public:
BeingHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
private:
void handleBeingAttackMessage(MessageIn &msg);
diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp
index 2e7cf26d..5395adb8 100644
--- a/src/net/manaserv/buysellhandler.cpp
+++ b/src/net/manaserv/buysellhandler.cpp
@@ -57,7 +57,7 @@ void BuySellHandler::handleMessage(MessageIn &msg)
{
case GPMSG_NPC_BUY:
{
- BuyDialog* dialog = new BuyDialog(npcId);
+ auto* dialog = new BuyDialog(npcId);
dialog->reset();
dialog->setMoney(PlayerInfo::getAttribute(MONEY));
@@ -74,7 +74,7 @@ void BuySellHandler::handleMessage(MessageIn &msg)
case GPMSG_NPC_SELL:
{
- SellDialog* dialog = new SellDialog(npcId);
+ auto* dialog = new SellDialog(npcId);
dialog->reset();
dialog->setMoney(PlayerInfo::getAttribute(MONEY));
diff --git a/src/net/manaserv/buysellhandler.h b/src/net/manaserv/buysellhandler.h
index 88432842..f0ae9ab3 100644
--- a/src/net/manaserv/buysellhandler.h
+++ b/src/net/manaserv/buysellhandler.h
@@ -31,7 +31,7 @@ class BuySellHandler : public MessageHandler
public:
BuySellHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
};
} // namespace ManaServ
diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp
index ece8e108..d5a5497e 100644
--- a/src/net/manaserv/charhandler.cpp
+++ b/src/net/manaserv/charhandler.cpp
@@ -187,7 +187,7 @@ void CharHandler::handleCharacterCreateResponse(MessageIn &msg)
if (mCharCreateDialog)
{
mCharCreateDialog->scheduleDelete();
- mCharCreateDialog = 0;
+ mCharCreateDialog = nullptr;
}
}
}
@@ -228,7 +228,7 @@ void CharHandler::handleCharacterDeleteResponse(MessageIn &msg)
}
new OkDialog(_("Error"), errorMessage);
}
- mSelectedCharacter = 0;
+ mSelectedCharacter = nullptr;
unlockCharSelectDialog();
}
@@ -254,7 +254,7 @@ void CharHandler::handleCharacterSelectResponse(MessageIn &msg)
// Prevent the selected local player from being deleted
local_player = mSelectedCharacter->dummy;
PlayerInfo::setBackend(mSelectedCharacter->data);
- mSelectedCharacter->dummy = 0;
+ mSelectedCharacter->dummy = nullptr;
Client::setState(STATE_CONNECT_GAME);
}
@@ -386,7 +386,7 @@ void CharHandler::updateCharacters()
{
const CachedCharacterInfo &info = mCachedCharacterInfos.at(i);
- Net::Character *character = new Net::Character;
+ auto *character = new Net::Character;
character->slot = info.slot;
LocalPlayer *player = character->dummy = new LocalPlayer;
player->setName(info.name);
@@ -397,7 +397,7 @@ void CharHandler::updateCharacters()
character->data.mAttributes[CHAR_POINTS] = info.characterPoints;
character->data.mAttributes[CORR_POINTS] = info.correctionPoints;
- for (CachedAttributes::const_iterator it = info.attribute.begin(),
+ for (auto it = info.attribute.begin(),
it_end = info.attribute.end(); it != it_end; it++)
{
character->data.mStats[i].base = it->second.base;
@@ -412,8 +412,8 @@ void CharHandler::updateCharacters()
void CharHandler::clear()
{
- setCharCreateDialog(0);
- setCharSelectDialog(0);
+ setCharCreateDialog(nullptr);
+ setCharSelectDialog(nullptr);
mCachedCharacterInfos.clear();
updateCharacters();
diff --git a/src/net/manaserv/charhandler.h b/src/net/manaserv/charhandler.h
index d2159204..262d8a01 100644
--- a/src/net/manaserv/charhandler.h
+++ b/src/net/manaserv/charhandler.h
@@ -42,43 +42,43 @@ class CharHandler : public MessageHandler, public Net::CharHandler
public:
CharHandler();
- ~CharHandler();
+ ~CharHandler() override;
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void setCharSelectDialog(CharSelectDialog *window);
+ void setCharSelectDialog(CharSelectDialog *window) override;
/**
* Sets the character create dialog. The handler will clean up this
* dialog when a new character is succesfully created, and will unlock
* the dialog when a new character failed to be created.
*/
- void setCharCreateDialog(CharCreateDialog *window);
+ void setCharCreateDialog(CharCreateDialog *window) override;
- void requestCharacters();
+ void requestCharacters() override;
- void chooseCharacter(Net::Character *character);
+ void chooseCharacter(Net::Character *character) override;
void newCharacter(const std::string &name, int slot,
bool gender, int hairstyle, int hairColor,
- const std::vector<int> &stats);
+ const std::vector<int> &stats) override;
- void deleteCharacter(Net::Character *character);
+ void deleteCharacter(Net::Character *character) override;
- void switchCharacter();
+ void switchCharacter() override;
- unsigned int baseSprite() const;
+ unsigned int baseSprite() const override;
- unsigned int hairSprite() const;
+ unsigned int hairSprite() const override;
- unsigned int maxSprite() const;
+ unsigned int maxSprite() const override;
// No limitation on Manaserv
- int getCharCreateMaxHairColorId() const
+ int getCharCreateMaxHairColorId() const override
{ return 0; }
// No limitation on Manaserv
- int getCharCreateMaxHairStyleId() const
+ int getCharCreateMaxHairStyleId() const override
{ return 0; }
void clear();
@@ -94,7 +94,7 @@ class CharHandler : public MessageHandler, public Net::CharHandler
double mod;
};
- typedef std::map<int, CachedAttrbiute> CachedAttributes;
+ using CachedAttributes = std::map<int, CachedAttrbiute>;
struct CachedCharacterInfo {
int slot;
diff --git a/src/net/manaserv/chathandler.cpp b/src/net/manaserv/chathandler.cpp
index d777fa35..6d0b6b4e 100644
--- a/src/net/manaserv/chathandler.cpp
+++ b/src/net/manaserv/chathandler.cpp
@@ -184,7 +184,7 @@ void ChatHandler::handleEnterChannelResponse(MessageIn &msg)
short channelId = msg.readInt16();
std::string channelName = msg.readString();
std::string announcement = msg.readString();
- Channel *channel = new Channel(channelId, channelName, announcement);
+ auto *channel = new Channel(channelId, channelName, announcement);
channelManager->addChannel(channel);
ChatTab *tab = channel->getTab();
tab->chatLog(strprintf(_("Topic: %s"), announcement.c_str()), BY_CHANNEL);
diff --git a/src/net/manaserv/chathandler.h b/src/net/manaserv/chathandler.h
index 7ae4227b..f9602407 100644
--- a/src/net/manaserv/chathandler.h
+++ b/src/net/manaserv/chathandler.h
@@ -37,7 +37,7 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
/**
* Handle the given message appropriately.
*/
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
void connect();
@@ -45,31 +45,31 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
void disconnect();
- void talk(const std::string &text);
+ void talk(const std::string &text) override;
- void me(const std::string &text);
+ void me(const std::string &text) override;
void privateMessage(const std::string &recipient,
- const std::string &text);
+ const std::string &text) override;
- void channelList();
+ void channelList() override;
void enterChannel(const std::string &channel,
- const std::string &password);
+ const std::string &password) override;
- void quitChannel(int channelId);
+ void quitChannel(int channelId) override;
- void sendToChannel(int channelId, const std::string &text);
+ void sendToChannel(int channelId, const std::string &text) override;
- void userList(const std::string &channel);
+ void userList(const std::string &channel) override;
- void setChannelTopic(int channelId, const std::string &text);
+ void setChannelTopic(int channelId, const std::string &text) override;
- void setUserMode(int channelId, const std::string &name, int mode);
+ void setUserMode(int channelId, const std::string &name, int mode) override;
- void kickUser(int channelId, const std::string &name);
+ void kickUser(int channelId, const std::string &name) override;
- void who();
+ void who() override;
private:
/**
diff --git a/src/net/manaserv/connection.cpp b/src/net/manaserv/connection.cpp
index 5d869b9d..4bc57695 100644
--- a/src/net/manaserv/connection.cpp
+++ b/src/net/manaserv/connection.cpp
@@ -32,7 +32,7 @@ namespace ManaServ
{
Connection::Connection(ENetHost *client):
- mConnection(0), mClient(client)
+ mConnection(nullptr), mClient(client)
{
mPort = 0;
connections++;
@@ -83,7 +83,7 @@ void Connection::disconnect()
enet_host_flush(mClient);
enet_peer_reset(mConnection);
- mConnection = 0;
+ mConnection = nullptr;
}
bool Connection::isConnected()
diff --git a/src/net/manaserv/effecthandler.h b/src/net/manaserv/effecthandler.h
index f5f31b11..268e2725 100644
--- a/src/net/manaserv/effecthandler.h
+++ b/src/net/manaserv/effecthandler.h
@@ -31,7 +31,7 @@ class EffectHandler : public MessageHandler
public:
EffectHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
private:
void handleCreateEffectPos(MessageIn &msg);
diff --git a/src/net/manaserv/gamehandler.h b/src/net/manaserv/gamehandler.h
index 454cae43..2bc56ef0 100644
--- a/src/net/manaserv/gamehandler.h
+++ b/src/net/manaserv/gamehandler.h
@@ -36,32 +36,32 @@ class GameHandler : public MessageHandler, public Net::GameHandler
public:
GameHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void connect();
+ void connect() override;
- bool isConnected();
+ bool isConnected() override;
- void disconnect();
+ void disconnect() override;
- void who();
+ void who() override;
void quit(bool reconnectAccount);
- void quit() { quit(false); }
+ void quit() override { quit(false); }
- bool removeDeadBeings() const { return false; }
+ bool removeDeadBeings() const override { return false; }
void clear();
void gameLoading();
/** The ManaServ protocol doesn't use the MP status bar. */
- bool canUseMagicBar() const { return false; }
+ bool canUseMagicBar() const override { return false; }
- int getPickupRange() const { return PICKUP_RANGE; }
+ int getPickupRange() const override { return PICKUP_RANGE; }
- int getNpcTalkRange() const { return NPC_TALK_RANGE; }
+ int getNpcTalkRange() const override { return NPC_TALK_RANGE; }
};
} // namespace ManaServ
diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp
index 1e39410c..aa62dff1 100644
--- a/src/net/manaserv/generalhandler.cpp
+++ b/src/net/manaserv/generalhandler.cpp
@@ -61,9 +61,9 @@ extern ManaServ::LoginHandler *loginHandler;
namespace ManaServ {
-Connection *accountServerConnection = 0;
-Connection *chatServerConnection = 0;
-Connection *gameServerConnection = 0;
+Connection *accountServerConnection = nullptr;
+Connection *chatServerConnection = nullptr;
+Connection *gameServerConnection = nullptr;
std::string netToken = "";
ServerInfo gameServer;
ServerInfo chatServer;
@@ -181,7 +181,7 @@ void GeneralHandler::event(Event::Channel channel,
if (newState == STATE_GAME)
{
- GameHandler *game = static_cast<GameHandler*>(Net::getGameHandler());
+ auto *game = static_cast<GameHandler*>(Net::getGameHandler());
game->gameLoading();
}
}
diff --git a/src/net/manaserv/generalhandler.h b/src/net/manaserv/generalhandler.h
index ce511587..582c1796 100644
--- a/src/net/manaserv/generalhandler.h
+++ b/src/net/manaserv/generalhandler.h
@@ -36,17 +36,17 @@ class GeneralHandler : public Net::GeneralHandler, public EventListener
public:
GeneralHandler();
- void load();
+ void load() override;
- void reload();
+ void reload() override;
- void unload();
+ void unload() override;
- void flushNetwork();
+ void flushNetwork() override;
- void clearHandlers();
+ void clearHandlers() override;
- void event(Event::Channel channel, const Event &event);
+ void event(Event::Channel channel, const Event &event) override;
protected:
MessageHandlerPtr mAdminHandler;
diff --git a/src/net/manaserv/guildhandler.cpp b/src/net/manaserv/guildhandler.cpp
index 19fa03ca..be2a5ec8 100644
--- a/src/net/manaserv/guildhandler.cpp
+++ b/src/net/manaserv/guildhandler.cpp
@@ -285,7 +285,7 @@ void GuildHandler::joinedGuild(MessageIn &msg)
// Automatically create the guild channel
// COMMENT: Should this go here??
- Channel *channel = new Channel(channelId, guildName, announcement);
+ auto *channel = new Channel(channelId, guildName, announcement);
channelManager->addChannel(channel);
channel->getTab()->chatLog(strprintf(_("Topic: %s"), announcement.c_str()),
BY_CHANNEL);
diff --git a/src/net/manaserv/guildhandler.h b/src/net/manaserv/guildhandler.h
index d1232a6f..b14bb203 100644
--- a/src/net/manaserv/guildhandler.h
+++ b/src/net/manaserv/guildhandler.h
@@ -33,34 +33,34 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
public:
GuildHandler();
- bool isSupported() { return true; }
+ bool isSupported() override { return true; }
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void create(const std::string &name);
+ void create(const std::string &name) override;
- void invite(int guildId, const std::string &name);
+ void invite(int guildId, const std::string &name) override;
- void invite(int guidId, Being *being);
+ void invite(int guidId, Being *being) override;
- void inviteResponse(int guidId, bool response);
+ void inviteResponse(int guidId, bool response) override;
- void leave(int guildId);
+ void leave(int guildId) override;
- void kick(GuildMember *member, std::string reason = "");
+ void kick(GuildMember *member, std::string reason = "") override;
- void chat(int guildId, const std::string &text);
+ void chat(int guildId, const std::string &text) override;
- void memberList(int guildId);
+ void memberList(int guildId) override;
- void changeMemberPostion(GuildMember *member, int level);
+ void changeMemberPostion(GuildMember *member, int level) override;
- void requestAlliance(int guildId, int otherGuildId);
+ void requestAlliance(int guildId, int otherGuildId) override;
void requestAllianceResponse(int guildId, int otherGuildId,
- bool response);
+ bool response) override;
- void endAlliance(int guildId, int otherGuildId);
+ void endAlliance(int guildId, int otherGuildId) override;
protected:
void joinedGuild(MessageIn &msg);
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index b306869e..af482400 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -72,20 +72,20 @@ EquipBackend::~EquipBackend()
Item *EquipBackend::getEquipment(int slotIndex) const
{
- Slots::const_iterator it = mSlots.find(slotIndex);
- return it == mSlots.end() ? 0 : it->second.item;
+ auto it = mSlots.find(slotIndex);
+ return it == mSlots.end() ? nullptr : it->second.item;
}
std::string EquipBackend::getSlotName(int slotIndex) const
{
- Slots::const_iterator it = mSlots.find(slotIndex);
+ auto it = mSlots.find(slotIndex);
return it == mSlots.end() ? std::string() : it->second.name;
}
void EquipBackend::triggerUnequip(int slotIndex) const
{
// First get the itemInstance
- Slots::const_iterator it = mSlots.find(slotIndex);
+ auto it = mSlots.find(slotIndex);
if (it == mSlots.end() || it->second.itemInstance == 0 || !it->second.item)
return;
@@ -99,13 +99,13 @@ void EquipBackend::triggerUnequip(int slotIndex) const
void EquipBackend::clear()
{
- for (Slots::iterator i = mSlots.begin(), i_end = mSlots.end();
+ for (auto i = mSlots.begin(), i_end = mSlots.end();
i != i_end; ++i)
{
if (i->second.item)
{
delete i->second.item;
- i->second.item = 0;
+ i->second.item = nullptr;
}
}
mSlots.clear();
@@ -121,8 +121,8 @@ void EquipBackend::equip(int itemId, int slotTypeId, int amountUsed,
return;
}
- Slots::iterator it = mSlots.begin();
- Slots::iterator it_end = mSlots.end();
+ auto it = mSlots.begin();
+ auto it_end = mSlots.end();
bool slotTypeFound = false;
for (; it != it_end; ++it)
if (it->second.slotTypeId == (unsigned)slotTypeId)
@@ -161,8 +161,8 @@ void EquipBackend::equip(int itemId, int slotTypeId, int amountUsed,
void EquipBackend::unequip(int itemInstance)
{
- Slots::iterator it = mSlots.begin();
- Slots::iterator it_end = mSlots.end();
+ auto it = mSlots.begin();
+ auto it_end = mSlots.end();
bool itemInstanceFound = false;
for (; it != it_end; ++it)
if (it->second.itemInstance == (unsigned)itemInstance)
@@ -187,7 +187,7 @@ void EquipBackend::unequip(int itemInstance)
if (it->second.item)
{
delete it->second.item;
- it->second.item = 0;
+ it->second.item = nullptr;
}
}
}
@@ -280,7 +280,7 @@ void EquipBackend::readBoxNode(xmlNodePtr slotNode)
bool EquipBackend::isWeaponSlot(int slotTypeId) const
{
- for (Slots::const_iterator it = mSlots.begin(), it_end = mSlots.end();
+ for (auto it = mSlots.begin(), it_end = mSlots.end();
it != it_end; ++it)
{
if (it->second.slotTypeId == (unsigned)slotTypeId)
@@ -291,7 +291,7 @@ bool EquipBackend::isWeaponSlot(int slotTypeId) const
bool EquipBackend::isAmmoSlot(int slotTypeId) const
{
- for (Slots::const_iterator it = mSlots.begin(), it_end = mSlots.end();
+ for (auto it = mSlots.begin(), it_end = mSlots.end();
it != it_end; ++it)
{
if (it->second.slotTypeId == (unsigned)slotTypeId)
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index 808acb96..3659286b 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -38,25 +38,25 @@ class EquipBackend : public Equipment::Backend, public EventListener
public:
EquipBackend();
- ~EquipBackend();
+ ~EquipBackend() override;
- Item *getEquipment(int slotIndex) const;
- std::string getSlotName(int slotIndex) const;
- void clear();
+ Item *getEquipment(int slotIndex) const override;
+ std::string getSlotName(int slotIndex) const override;
+ void clear() override;
void equip(int itemId, int slotTypeId, int amountUsed = 1,
int itemInstance = 0);
void unequip(int slotTypeId);
- void event(Event::Channel channel, const Event &event);
+ void event(Event::Channel channel, const Event &event) override;
- int getSlotNumber() const
+ int getSlotNumber() const override
{ return mSlots.size(); }
unsigned int getVisibleSlotsNumber() const
{ return mVisibleSlots; }
- void triggerUnequip(int slotIndex) const;
+ void triggerUnequip(int slotIndex) const override;
bool isWeaponSlot(int slotTypeId) const;
bool isAmmoSlot(int slotTypeId) const;
@@ -66,13 +66,13 @@ class EquipBackend : public Equipment::Backend, public EventListener
const std::string& getBoxBackground(unsigned int slotIndex) const;
private:
- void readEquipFile();
+ void readEquipFile() override;
void readBoxNode(xmlNodePtr slotNode);
struct Slot {
Slot():
- item(0),
+ item(nullptr),
slotTypeId(0),
subId(0),
itemInstance(0),
@@ -113,7 +113,7 @@ class EquipBackend : public Equipment::Backend, public EventListener
unsigned int mVisibleSlots;
// slot client index, slot info
- typedef std::map<unsigned int, Slot> Slots;
+ using Slots = std::map<unsigned int, Slot>;
Slots mSlots;
std::vector<Position> mBoxesPositions;
std::vector<std::string> mBoxesBackgroundFile;
@@ -125,27 +125,27 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler,
public:
InventoryHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void event(Event::Channel channel, const Event &event);
+ void event(Event::Channel channel, const Event &event) override;
- bool canSplit(const Item *item);
+ bool canSplit(const Item *item) override;
- size_t getSize(int type) const;
+ size_t getSize(int type) const override;
- bool isWeaponSlot(unsigned int slotTypeId) const
+ bool isWeaponSlot(unsigned int slotTypeId) const override
{ return mEquipBackend.isWeaponSlot(slotTypeId); }
- bool isAmmoSlot(unsigned int slotTypeId) const
+ bool isAmmoSlot(unsigned int slotTypeId) const override
{ return mEquipBackend.isAmmoSlot(slotTypeId); }
- unsigned int getVisibleSlotsNumber() const
+ unsigned int getVisibleSlotsNumber() const override
{ return mEquipBackend.getVisibleSlotsNumber(); }
- Position getBoxPosition(unsigned int slotIndex) const
+ Position getBoxPosition(unsigned int slotIndex) const override
{ return mEquipBackend.getBoxPosition(slotIndex); }
- const std::string& getBoxBackground(unsigned int slotIndex) const
+ const std::string& getBoxBackground(unsigned int slotIndex) const override
{ return mEquipBackend.getBoxBackground(slotIndex); }
private:
diff --git a/src/net/manaserv/itemhandler.h b/src/net/manaserv/itemhandler.h
index e45db269..4396886f 100644
--- a/src/net/manaserv/itemhandler.h
+++ b/src/net/manaserv/itemhandler.h
@@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler
public:
ItemHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
};
} // namespace ManaServ
diff --git a/src/net/manaserv/loginhandler.h b/src/net/manaserv/loginhandler.h
index 33cc83ad..cdfbe222 100644
--- a/src/net/manaserv/loginhandler.h
+++ b/src/net/manaserv/loginhandler.h
@@ -36,43 +36,43 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
public:
LoginHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void connect();
+ void connect() override;
- bool isConnected();
+ bool isConnected() override;
- void disconnect();
+ void disconnect() override;
- int supportedOptionalActions() const
+ int supportedOptionalActions() const override
{ return Unregister | ChangeEmail | SetEmailOnRegister; }
- bool isRegistrationEnabled();
+ bool isRegistrationEnabled() override;
- void getRegistrationDetails();
+ void getRegistrationDetails() override;
- unsigned int getMinUserNameLength() const;
+ unsigned int getMinUserNameLength() const override;
- unsigned int getMaxUserNameLength() const;
+ unsigned int getMaxUserNameLength() const override;
- void loginAccount(LoginData *loginData);
+ void loginAccount(LoginData *loginData) override;
- void logout();
+ void logout() override;
- void changeEmail(const std::string &email);
+ void changeEmail(const std::string &email) override;
void changePassword(const std::string &username,
const std::string &oldPassword,
- const std::string &newPassword);
+ const std::string &newPassword) override;
- void chooseServer(unsigned int server);
+ void chooseServer(unsigned int server) override;
- void registerAccount(LoginData *loginData);
+ void registerAccount(LoginData *loginData) override;
void unregisterAccount(const std::string &username,
- const std::string &password);
+ const std::string &password) override;
- Worlds getWorlds() const;
+ Worlds getWorlds() const override;
void reconnect();
diff --git a/src/net/manaserv/messagehandler.h b/src/net/manaserv/messagehandler.h
index 8949d34e..f9ee09ab 100644
--- a/src/net/manaserv/messagehandler.h
+++ b/src/net/manaserv/messagehandler.h
@@ -36,12 +36,12 @@ class MessageIn;
class MessageHandler : public Net::MessageHandler
{
public:
- ~MessageHandler();
+ ~MessageHandler() override;
virtual void handleMessage(MessageIn &msg) = 0;
};
-typedef const std::unique_ptr<MessageHandler> MessageHandlerPtr;
+using MessageHandlerPtr = const std::unique_ptr<MessageHandler>;
} // namespace ManaServ
diff --git a/src/net/manaserv/messageout.cpp b/src/net/manaserv/messageout.cpp
index 1197176f..3dc2c1b2 100644
--- a/src/net/manaserv/messageout.cpp
+++ b/src/net/manaserv/messageout.cpp
@@ -28,7 +28,7 @@
namespace ManaServ {
MessageOut::MessageOut(uint16_t id):
- mData(0),
+ mData(nullptr),
mPos(0),
mDataSize(0),
mDebugMode(false)
diff --git a/src/net/manaserv/network.cpp b/src/net/manaserv/network.cpp
index 30dfb243..7f354fa1 100644
--- a/src/net/manaserv/network.cpp
+++ b/src/net/manaserv/network.cpp
@@ -42,8 +42,8 @@ namespace {
namespace ManaServ
{
-typedef std::map<unsigned short, MessageHandler*> MessageHandlers;
-typedef MessageHandlers::iterator MessageHandlerIterator;
+using MessageHandlers = std::map<unsigned short, MessageHandler *>;
+using MessageHandlerIterator = MessageHandlers::iterator;
static MessageHandlers mMessageHandlers;
void initialize()
@@ -53,7 +53,7 @@ void initialize()
logger->error("Failed to initialize ENet.");
}
- client = enet_host_create(NULL, 3, 0, 0, 0);
+ client = enet_host_create(nullptr, 3, 0, 0, 0);
if (!client)
{
@@ -119,7 +119,7 @@ namespace
{
MessageIn msg((const char *)packet->data, packet->dataLength);
- MessageHandlerIterator iter = mMessageHandlers.find(msg.getId());
+ auto iter = mMessageHandlers.find(msg.getId());
if (iter != mMessageHandlers.end())
{
@@ -150,7 +150,7 @@ void flush()
case ENET_EVENT_TYPE_CONNECT:
logger->log("Connected to port %d.", event.peer->address.port);
// Store any relevant server information here.
- event.peer->data = 0;
+ event.peer->data = nullptr;
break;
case ENET_EVENT_TYPE_RECEIVE:
@@ -160,7 +160,7 @@ void flush()
case ENET_EVENT_TYPE_DISCONNECT:
logger->log("Disconnected.");
// Reset the server information.
- event.peer->data = 0;
+ event.peer->data = nullptr;
break;
case ENET_EVENT_TYPE_NONE:
diff --git a/src/net/manaserv/npchandler.cpp b/src/net/manaserv/npchandler.cpp
index 502df13d..bd131d55 100644
--- a/src/net/manaserv/npchandler.cpp
+++ b/src/net/manaserv/npchandler.cpp
@@ -62,7 +62,7 @@ void NpcHandler::handleMessage(MessageIn &msg)
}
int npcId = being->getId(), count = 0;
- Event *event = 0;
+ Event *event = nullptr;
switch (msg.getId())
{
diff --git a/src/net/manaserv/npchandler.h b/src/net/manaserv/npchandler.h
index 0f42385d..8d397253 100644
--- a/src/net/manaserv/npchandler.h
+++ b/src/net/manaserv/npchandler.h
@@ -37,34 +37,34 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler
public:
NpcHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void startShopping(int beingId);
+ void startShopping(int beingId) override;
- void buy(int beingId);
+ void buy(int beingId) override;
- void sell(int beingId);
+ void sell(int beingId) override;
- void buyItem(int beingId, int itemId, int amount);
+ void buyItem(int beingId, int itemId, int amount) override;
- void sellItem(int beingId, int itemId, int amount);
+ void sellItem(int beingId, int itemId, int amount) override;
- void endShopping(int beingId);
+ void endShopping(int beingId) override;
- void talk(int npcId);
+ void talk(int npcId) override;
- void nextDialog(int npcId);
+ void nextDialog(int npcId) override;
- void closeDialog(int npcId);
+ void closeDialog(int npcId) override;
- void menuSelect(int npcId, int choice);
+ void menuSelect(int npcId, int choice) override;
- void integerInput(int npcId, int value);
+ void integerInput(int npcId, int value) override;
- void stringInput(int npcId, const std::string &value);
+ void stringInput(int npcId, const std::string &value) override;
void sendLetter(int npcId, const std::string &recipient,
- const std::string &text);
+ const std::string &text) override;
};
diff --git a/src/net/manaserv/partyhandler.cpp b/src/net/manaserv/partyhandler.cpp
index a0d4b6d9..e0ee91a7 100644
--- a/src/net/manaserv/partyhandler.cpp
+++ b/src/net/manaserv/partyhandler.cpp
@@ -113,7 +113,7 @@ void PartyHandler::handleMessage(MessageIn &msg)
if (msg.readInt8() == ERRMSG_OK)
{
mParty->clearMembers();
- local_player->setParty(NULL);
+ local_player->setParty(nullptr);
}
} break;
diff --git a/src/net/manaserv/partyhandler.h b/src/net/manaserv/partyhandler.h
index 6c526f73..ed8a1f25 100644
--- a/src/net/manaserv/partyhandler.h
+++ b/src/net/manaserv/partyhandler.h
@@ -37,35 +37,35 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
public:
PartyHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void create(const std::string &name = "");
+ void create(const std::string &name = "") override;
- void join(int partyId);
+ void join(int partyId) override;
- void invite(Being *being);
+ void invite(Being *being) override;
- void invite(const std::string &name);
+ void invite(const std::string &name) override;
- void inviteResponse(const std::string &inviter, bool accept);
+ void inviteResponse(const std::string &inviter, bool accept) override;
- void leave();
+ void leave() override;
- void kick(Being *being);
+ void kick(Being *being) override;
- void kick(const std::string &name);
+ void kick(const std::string &name) override;
- void chat(const std::string &text);
+ void chat(const std::string &text) override;
- void requestPartyMembers();
+ void requestPartyMembers() override;
- PartyShare getShareExperience() { return PARTY_SHARE_NO; }
+ PartyShare getShareExperience() override { return PARTY_SHARE_NO; }
- void setShareExperience(PartyShare share) {}
+ void setShareExperience(PartyShare share) override {}
- PartyShare getShareItems() { return PARTY_SHARE_NO; }
+ PartyShare getShareItems() override { return PARTY_SHARE_NO; }
- void setShareItems(PartyShare share) {}
+ void setShareItems(PartyShare share) override {}
private:
Party *mParty;
};
diff --git a/src/net/manaserv/playerhandler.cpp b/src/net/manaserv/playerhandler.cpp
index c1f78f67..15b0eb5c 100644
--- a/src/net/manaserv/playerhandler.cpp
+++ b/src/net/manaserv/playerhandler.cpp
@@ -105,7 +105,7 @@ void PlayerHandler::handleMessage(MessageIn &msg)
gameServerConnection->disconnect();
Client::setState(STATE_CHANGE_MAP);
- local_player->setMap(0);
+ local_player->setMap(nullptr);
} break;
case GPMSG_PLAYER_ATTRIBUTE_CHANGE:
diff --git a/src/net/manaserv/playerhandler.h b/src/net/manaserv/playerhandler.h
index abb29e9b..e2a52d4d 100644
--- a/src/net/manaserv/playerhandler.h
+++ b/src/net/manaserv/playerhandler.h
@@ -32,7 +32,7 @@ namespace ManaServ {
struct RespawnRequestListener : public gcn::ActionListener
{
- void action(const gcn::ActionEvent &event);
+ void action(const gcn::ActionEvent &event) override;
};
static RespawnRequestListener respawnListener;
@@ -41,35 +41,35 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
public:
PlayerHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void attack(int id);
- void emote(int emoteId);
+ void attack(int id) override;
+ void emote(int emoteId) override;
- void increaseAttribute(int attr);
- void decreaseAttribute(int attr);
- void increaseSkill(int skillId);
+ void increaseAttribute(int attr) override;
+ void decreaseAttribute(int attr) override;
+ void increaseSkill(int skillId) override;
- void pickUp(FloorItem *floorItem);
- void setDirection(char direction);
- void setDestination(int x, int y, int direction = -1);
- void changeAction(Being::Action action);
+ void pickUp(FloorItem *floorItem) override;
+ void setDirection(char direction) override;
+ void setDestination(int x, int y, int direction = -1) override;
+ void changeAction(Being::Action action) override;
- void respawn();
+ void respawn() override;
- void ignorePlayer(const std::string &player, bool ignore);
- void ignoreAll(bool ignore);
+ void ignorePlayer(const std::string &player, bool ignore) override;
+ void ignoreAll(bool ignore) override;
- bool canUseMagic();
- bool canCorrectAttributes();
+ bool canUseMagic() override;
+ bool canCorrectAttributes() override;
- int getJobLocation();
+ int getJobLocation() override;
- Vector getDefaultMoveSpeed() const;
+ Vector getDefaultMoveSpeed() const override;
- Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0);
+ Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = nullptr) override;
- bool usePixelPrecision()
+ bool usePixelPrecision() override
{ return true; }
private:
diff --git a/src/net/manaserv/specialhandler.h b/src/net/manaserv/specialhandler.h
index ee26b3b7..55b5225b 100644
--- a/src/net/manaserv/specialhandler.h
+++ b/src/net/manaserv/specialhandler.h
@@ -33,15 +33,15 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
public:
SpecialHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void use(int id);
+ void use(int id) override;
- void use(int id, int level, int beingId);
+ void use(int id, int level, int beingId) override;
- void use(int id, int level, int x, int y);
+ void use(int id, int level, int x, int y) override;
- void use(int id, const std::string &map);
+ void use(int id, const std::string &map) override;
};
} // namespace ManaServ
diff --git a/src/net/manaserv/tradehandler.cpp b/src/net/manaserv/tradehandler.cpp
index ff7849ff..9537909c 100644
--- a/src/net/manaserv/tradehandler.cpp
+++ b/src/net/manaserv/tradehandler.cpp
@@ -55,7 +55,7 @@ extern Connection *gameServerConnection;
namespace {
struct RequestTradeListener : public gcn::ActionListener
{
- void action(const gcn::ActionEvent &event)
+ void action(const gcn::ActionEvent &event) override
{
if (event.getId() == "yes")
{
@@ -112,7 +112,7 @@ void TradeHandler::handleMessage(MessageIn &msg)
mTrading = true;
tradePartnerName = being->getName();
tradePartnerID = being->getId();
- ConfirmDialog *dlg = new ConfirmDialog(_("Request for Trade"),
+ auto *dlg = new ConfirmDialog(_("Request for Trade"),
strprintf(_("%s wants to trade with you, do you accept?"),
tradePartnerName.c_str()));
dlg->addActionListener(&listener);
diff --git a/src/net/manaserv/tradehandler.h b/src/net/manaserv/tradehandler.h
index 5d20c14e..094b3c17 100644
--- a/src/net/manaserv/tradehandler.h
+++ b/src/net/manaserv/tradehandler.h
@@ -33,7 +33,7 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
public:
TradeHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
/**
* Returns whether trade requests are accepted.
@@ -50,21 +50,21 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
*/
void setAcceptTradeRequests(bool acceptTradeRequests);
- void request(Being *being);
+ void request(Being *being) override;
- void respond(bool accept);
+ void respond(bool accept) override;
- void addItem(Item *item, int amount);
+ void addItem(Item *item, int amount) override;
- void removeItem(int slotNum, int amount);
+ void removeItem(int slotNum, int amount) override;
- void setMoney(int amount);
+ void setMoney(int amount) override;
- void confirm();
+ void confirm() override;
- void finish();
+ void finish() override;
- void cancel();
+ void cancel() override;
private:
bool mAcceptTradeRequests;
diff --git a/src/net/net.cpp b/src/net/net.cpp
index 8946945b..c060d2e8 100644
--- a/src/net/net.cpp
+++ b/src/net/net.cpp
@@ -44,19 +44,19 @@
#include "utils/gettext.h"
-Net::AdminHandler *adminHandler = NULL;
-Net::CharHandler *charHandler = NULL;
-Net::ChatHandler *chatHandler = NULL;
-Net::GeneralHandler *generalHandler = NULL;
-Net::InventoryHandler *inventoryHandler = NULL;
-Net::LoginHandler *loginHandler = NULL;
-Net::GameHandler *gameHandler = NULL;
-Net::GuildHandler *guildHandler = NULL;
-Net::NpcHandler *npcHandler = NULL;
-Net::PartyHandler *partyHandler = NULL;
-Net::PlayerHandler *playerHandler = NULL;
-Net::SpecialHandler *specialHandler = NULL;
-Net::TradeHandler *tradeHandler = NULL;
+Net::AdminHandler *adminHandler = nullptr;
+Net::CharHandler *charHandler = nullptr;
+Net::ChatHandler *chatHandler = nullptr;
+Net::GeneralHandler *generalHandler = nullptr;
+Net::InventoryHandler *inventoryHandler = nullptr;
+Net::LoginHandler *loginHandler = nullptr;
+Net::GameHandler *gameHandler = nullptr;
+Net::GuildHandler *guildHandler = nullptr;
+Net::NpcHandler *npcHandler = nullptr;
+Net::PartyHandler *partyHandler = nullptr;
+Net::PlayerHandler *playerHandler = nullptr;
+Net::SpecialHandler *specialHandler = nullptr;
+Net::TradeHandler *tradeHandler = nullptr;
Net::AdminHandler *Net::getAdminHandler()
{
@@ -141,13 +141,13 @@ void connectToServer(ServerInfo &server)
logger->error(_("Unknown Server Type! Exiting."));
}
- if (networkType == server.type && getGeneralHandler() != NULL)
+ if (networkType == server.type && getGeneralHandler() != nullptr)
{
getGeneralHandler()->reload();
}
else
{
- if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != NULL)
+ if (networkType != ServerInfo::UNKNOWN && getGeneralHandler() != nullptr)
{
getGeneralHandler()->unload();
}
diff --git a/src/net/playerhandler.h b/src/net/playerhandler.h
index 8d697e46..0d638ac1 100644
--- a/src/net/playerhandler.h
+++ b/src/net/playerhandler.h
@@ -74,7 +74,7 @@ class PlayerHandler
* Convert the original server-dependant speed for internal use.
*/
virtual Vector getPixelsPerTickMoveSpeed(const Vector &speed,
- Map *map = 0) = 0;
+ Map *map = nullptr) = 0;
/**
* Tells whether the client has to use pixel paths.
diff --git a/src/net/serverinfo.h b/src/net/serverinfo.h
index 98881931..f9119d19 100644
--- a/src/net/serverinfo.h
+++ b/src/net/serverinfo.h
@@ -36,7 +36,7 @@ public:
TMWATHENA
};
- typedef std::pair<int, std::string> VersionString;
+ using VersionString = std::pair<int, std::string>;
Type type = UNKNOWN;
std::string name;
@@ -96,6 +96,6 @@ public:
}
};
-typedef std::deque<ServerInfo> ServerInfos;
+using ServerInfos = std::deque<ServerInfo>;
#endif // SERVERINFO_H
diff --git a/src/net/tmwa/adminhandler.h b/src/net/tmwa/adminhandler.h
index 71c37a09..f91a093d 100644
--- a/src/net/tmwa/adminhandler.h
+++ b/src/net/tmwa/adminhandler.h
@@ -34,27 +34,27 @@ class AdminHandler : public MessageHandler, public Net::AdminHandler
public:
AdminHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void announce(const std::string &text);
+ void announce(const std::string &text) override;
- void localAnnounce(const std::string &text);
+ void localAnnounce(const std::string &text) override;
- void hide(bool hide);
+ void hide(bool hide) override;
- void kick(int playerId);
+ void kick(int playerId) override;
- void kick(const std::string &name);
+ void kick(const std::string &name) override;
- void ban(int playerId);
+ void ban(int playerId) override;
- void ban(const std::string &name);
+ void ban(const std::string &name) override;
- void unban(int playerId);
+ void unban(int playerId) override;
- void unban(const std::string &name);
+ void unban(const std::string &name) override;
- void mute(int playerId, int type, int limit);
+ void mute(int playerId, int type, int limit) override;
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/beinghandler.cpp b/src/net/tmwa/beinghandler.cpp
index 12c97feb..3027efc8 100644
--- a/src/net/tmwa/beinghandler.cpp
+++ b/src/net/tmwa/beinghandler.cpp
@@ -90,7 +90,7 @@ static Being *createBeing(int id, short job)
else if (job > 1000 && job <= 2000)
type = ActorSprite::MONSTER;
else if (job == 45)
- return NULL; // Skip portals
+ return nullptr; // Skip portals
Being *being = actorSpriteManager->createBeing(id, type, job);
diff --git a/src/net/tmwa/beinghandler.h b/src/net/tmwa/beinghandler.h
index 81bbad74..1ec1583c 100644
--- a/src/net/tmwa/beinghandler.h
+++ b/src/net/tmwa/beinghandler.h
@@ -31,7 +31,7 @@ class BeingHandler : public MessageHandler
public:
BeingHandler(bool enableSync);
- virtual void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
private:
// Should we honor server "Stop Walking" packets
diff --git a/src/net/tmwa/buysellhandler.cpp b/src/net/tmwa/buysellhandler.cpp
index 908e1d6d..00a36f15 100644
--- a/src/net/tmwa/buysellhandler.cpp
+++ b/src/net/tmwa/buysellhandler.cpp
@@ -88,7 +88,7 @@ void BuySellHandler::handleMessage(MessageIn &msg)
n_items = (msg.getLength() - 4) / 10;
if (n_items > 0)
{
- SellDialog *dialog = new SellDialog(mNpcId);
+ auto *dialog = new SellDialog(mNpcId);
dialog->setMoney(PlayerInfo::getAttribute(MONEY));
for (int k = 0; k < n_items; k++)
diff --git a/src/net/tmwa/buysellhandler.h b/src/net/tmwa/buysellhandler.h
index b5229e0f..6e22b4af 100644
--- a/src/net/tmwa/buysellhandler.h
+++ b/src/net/tmwa/buysellhandler.h
@@ -33,7 +33,7 @@ class BuySellHandler : public MessageHandler
public:
BuySellHandler();
- virtual void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
private:
int mNpcId;
diff --git a/src/net/tmwa/charserverhandler.cpp b/src/net/tmwa/charserverhandler.cpp
index a8e87622..45c07bec 100644
--- a/src/net/tmwa/charserverhandler.cpp
+++ b/src/net/tmwa/charserverhandler.cpp
@@ -87,7 +87,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
for (int i = 0; i < count; ++i)
{
- Net::Character *character = new Net::Character;
+ auto *character = new Net::Character;
readPlayerData(msg, character);
mCharacters.push_back(character);
logger->log("CharServer: Player: %s (%d)",
@@ -117,7 +117,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
case SMSG_CHAR_CREATE_SUCCEEDED:
{
- Net::Character *character = new Net::Character;
+ auto *character = new Net::Character;
readPlayerData(msg, character);
mCharacters.push_back(character);
@@ -127,7 +127,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
if (mCharCreateDialog)
{
mCharCreateDialog->scheduleDelete();
- mCharCreateDialog = 0;
+ mCharCreateDialog = nullptr;
}
}
break;
@@ -142,7 +142,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
case SMSG_CHAR_DELETE_SUCCEEDED:
delete mSelectedCharacter;
mCharacters.remove(mSelectedCharacter);
- mSelectedCharacter = 0;
+ mSelectedCharacter = nullptr;
updateCharSelectDialog();
unlockCharSelectDialog();
new OkDialog(_("Info"), _("Character deleted."));
@@ -156,7 +156,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
case SMSG_CHAR_MAP_INFO:
{
msg.skip(4); // CharID, must be the same as local_player->charID
- GameHandler *gh = static_cast<GameHandler*>(Net::getGameHandler());
+ auto *gh = static_cast<GameHandler*>(Net::getGameHandler());
gh->setMap(msg.readString(16));
const auto ip = msg.readInt32();
@@ -172,7 +172,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
PlayerInfo::setBackend(mSelectedCharacter->data);
// Prevent the selected local player from being deleted
- mSelectedCharacter->dummy = 0;
+ mSelectedCharacter->dummy = nullptr;
delete_all(mCharacters);
mCharacters.clear();
@@ -185,7 +185,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
case SMSG_CHANGE_MAP_SERVER:
{
- GameHandler *gh = static_cast<GameHandler*>(Net::getGameHandler());
+ auto *gh = static_cast<GameHandler*>(Net::getGameHandler());
gh->setMap(msg.readString(16));
int x = msg.readInt16();
int y = msg.readInt16();
@@ -199,7 +199,7 @@ void CharServerHandler::handleMessage(MessageIn &msg)
const int tileHeight = map->getTileHeight();
local_player->setPosition(Vector(x * tileWidth + tileWidth / 2,
y * tileHeight + tileHeight / 2));
- local_player->setMap(0);
+ local_player->setMap(nullptr);
}
break;
}
@@ -210,7 +210,7 @@ void CharServerHandler::readPlayerData(MessageIn &msg, Net::Character *character
const Token &token =
static_cast<LoginHandler*>(Net::getLoginHandler())->getToken();
- LocalPlayer *tempPlayer = new LocalPlayer(msg.readInt32(), 0);
+ auto *tempPlayer = new LocalPlayer(msg.readInt32(), 0);
tempPlayer->setGender(token.sex);
character->data.mAttributes[EXP] = msg.readInt32();
@@ -309,7 +309,7 @@ void CharServerHandler::requestCharacters()
void CharServerHandler::chooseCharacter(Net::Character *character)
{
mSelectedCharacter = character;
- mCharSelectDialog = 0;
+ mCharSelectDialog = nullptr;
MessageOut outMsg(CMSG_CHAR_SELECT);
outMsg.writeInt8(mSelectedCharacter->slot);
diff --git a/src/net/tmwa/charserverhandler.h b/src/net/tmwa/charserverhandler.h
index 7e4fc2d9..cf673a4d 100644
--- a/src/net/tmwa/charserverhandler.h
+++ b/src/net/tmwa/charserverhandler.h
@@ -40,37 +40,37 @@ class CharServerHandler : public MessageHandler, public Net::CharHandler
public:
CharServerHandler();
- virtual void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void setCharSelectDialog(CharSelectDialog *window);
+ void setCharSelectDialog(CharSelectDialog *window) override;
/**
* Sets the character create dialog. The handler will clean up this
* dialog when a new character is succesfully created, and will unlock
* the dialog when a new character failed to be created.
*/
- void setCharCreateDialog(CharCreateDialog *window);
+ void setCharCreateDialog(CharCreateDialog *window) override;
- void requestCharacters();
+ void requestCharacters() override;
- void chooseCharacter(Net::Character *character);
+ void chooseCharacter(Net::Character *character) override;
void newCharacter(const std::string &name, int slot, bool gender,
int hairstyle, int hairColor,
- const std::vector<int> &stats);
+ const std::vector<int> &stats) override;
- void deleteCharacter(Net::Character *character);
+ void deleteCharacter(Net::Character *character) override;
- void switchCharacter();
+ void switchCharacter() override;
- unsigned int baseSprite() const;
+ unsigned int baseSprite() const override;
- unsigned int hairSprite() const;
+ unsigned int hairSprite() const override;
- unsigned int maxSprite() const;
+ unsigned int maxSprite() const override;
- int getCharCreateMaxHairColorId() const;
- int getCharCreateMaxHairStyleId() const;
+ int getCharCreateMaxHairColorId() const override;
+ int getCharCreateMaxHairStyleId() const override;
void connect();
diff --git a/src/net/tmwa/chathandler.h b/src/net/tmwa/chathandler.h
index fa3a8ec3..682a3743 100644
--- a/src/net/tmwa/chathandler.h
+++ b/src/net/tmwa/chathandler.h
@@ -36,36 +36,36 @@ class ChatHandler : public MessageHandler, public Net::ChatHandler
public:
ChatHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void talk(const std::string &text);
+ void talk(const std::string &text) override;
- void me(const std::string &text);
+ void me(const std::string &text) override;
void privateMessage(const std::string &recipient,
- const std::string &text);
+ const std::string &text) override;
- void channelList();
+ void channelList() override;
void enterChannel(const std::string &channel,
- const std::string &password);
+ const std::string &password) override;
- void quitChannel(int channelId);
+ void quitChannel(int channelId) override;
- void sendToChannel(int channelId, const std::string &text);
+ void sendToChannel(int channelId, const std::string &text) override;
- void userList(const std::string &channel);
+ void userList(const std::string &channel) override;
- void setChannelTopic(int channelId, const std::string &text);
+ void setChannelTopic(int channelId, const std::string &text) override;
- void setUserMode(int channelId, const std::string &name, int mode);
+ void setUserMode(int channelId, const std::string &name, int mode) override;
- void kickUser(int channelId, const std::string &name);
+ void kickUser(int channelId, const std::string &name) override;
- void who();
+ void who() override;
private:
- typedef std::queue<std::string> WhisperQueue;
+ using WhisperQueue = std::queue<std::string>;
WhisperQueue mSentWhispers;
};
diff --git a/src/net/tmwa/gamehandler.cpp b/src/net/tmwa/gamehandler.cpp
index 68ed62b0..44ce6bc0 100644
--- a/src/net/tmwa/gamehandler.cpp
+++ b/src/net/tmwa/gamehandler.cpp
@@ -93,7 +93,7 @@ void GameHandler::handleMessage(MessageIn &msg)
if (msg.readInt8())
{
new OkDialog(_("Game"), _("Request to quit denied!"), false,
- NULL);
+ nullptr);
}
break;
}
diff --git a/src/net/tmwa/gamehandler.h b/src/net/tmwa/gamehandler.h
index a6bcde0a..8859c9c6 100644
--- a/src/net/tmwa/gamehandler.h
+++ b/src/net/tmwa/gamehandler.h
@@ -39,32 +39,32 @@ class GameHandler : public MessageHandler, public Net::GameHandler,
public:
GameHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void event(Event::Channel channel, const Event &event);
+ void event(Event::Channel channel, const Event &event) override;
- void connect();
+ void connect() override;
- bool isConnected();
+ bool isConnected() override;
- void disconnect();
+ void disconnect() override;
- void who();
+ void who() override;
- void quit();
+ void quit() override;
- bool removeDeadBeings() const { return true; }
+ bool removeDeadBeings() const override { return true; }
void clear();
void setMap(const std::string map);
/** The tmwAthena protocol is making use of the MP status bar. */
- bool canUseMagicBar() const { return true; }
+ bool canUseMagicBar() const override { return true; }
- int getPickupRange() const;
+ int getPickupRange() const override;
- int getNpcTalkRange() const { return DEFAULT_TILE_LENGTH * 30; }
+ int getNpcTalkRange() const override { return DEFAULT_TILE_LENGTH * 30; }
private:
std::string mMap; ///< Keeps the map filename.
diff --git a/src/net/tmwa/generalhandler.cpp b/src/net/tmwa/generalhandler.cpp
index 5e445eaf..4053e17c 100644
--- a/src/net/tmwa/generalhandler.cpp
+++ b/src/net/tmwa/generalhandler.cpp
@@ -184,8 +184,8 @@ void GeneralHandler::reload()
mNetwork->disconnect();
static_cast<LoginHandler*>(mLoginHandler.get())->clearWorlds();
- static_cast<CharServerHandler*>(mCharHandler.get())->setCharCreateDialog(0);
- static_cast<CharServerHandler*>(mCharHandler.get())->setCharSelectDialog(0);
+ static_cast<CharServerHandler*>(mCharHandler.get())->setCharCreateDialog(nullptr);
+ static_cast<CharServerHandler*>(mCharHandler.get())->setCharSelectDialog(nullptr);
}
void GeneralHandler::unload()
@@ -255,10 +255,10 @@ void GeneralHandler::event(Event::Channel channel,
socialWindow->removeTab(taParty);
delete guildTab;
- guildTab = 0;
+ guildTab = nullptr;
delete partyTab;
- partyTab = 0;
+ partyTab = nullptr;
}
}
}
diff --git a/src/net/tmwa/generalhandler.h b/src/net/tmwa/generalhandler.h
index a34852fd..22c6b650 100644
--- a/src/net/tmwa/generalhandler.h
+++ b/src/net/tmwa/generalhandler.h
@@ -37,21 +37,21 @@ class GeneralHandler : public MessageHandler, public Net::GeneralHandler,
public:
GeneralHandler();
- ~GeneralHandler();
+ ~GeneralHandler() override;
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void load();
+ void load() override;
- void reload();
+ void reload() override;
- void unload();
+ void unload() override;
- void flushNetwork();
+ void flushNetwork() override;
- void clearHandlers();
+ void clearHandlers() override;
- void event(Event::Channel channel, const Event &event);
+ void event(Event::Channel channel, const Event &event) override;
protected:
MessageHandlerPtr mAdminHandler;
diff --git a/src/net/tmwa/gui/guildtab.h b/src/net/tmwa/gui/guildtab.h
index 0e208e93..e7d7b7cc 100644
--- a/src/net/tmwa/gui/guildtab.h
+++ b/src/net/tmwa/gui/guildtab.h
@@ -33,18 +33,18 @@ class GuildTab : public ChatTab
{
public:
GuildTab();
- ~GuildTab();
+ ~GuildTab() override;
- void showHelp();
+ void showHelp() override;
- bool handleCommand(const std::string &type, const std::string &args);
+ bool handleCommand(const std::string &type, const std::string &args) override;
- void saveToLogFile(std::string &msg);
+ void saveToLogFile(std::string &msg) override;
protected:
- void handleInput(const std::string &msg);
+ void handleInput(const std::string &msg) override;
- void getAutoCompleteList(std::vector<std::string> &names) const;
+ void getAutoCompleteList(std::vector<std::string> &names) const override;
};
extern GuildTab *guildTab;
diff --git a/src/net/tmwa/gui/partytab.h b/src/net/tmwa/gui/partytab.h
index 1049b770..61ccf37a 100644
--- a/src/net/tmwa/gui/partytab.h
+++ b/src/net/tmwa/gui/partytab.h
@@ -33,18 +33,18 @@ class PartyTab : public ChatTab
{
public:
PartyTab();
- ~PartyTab();
+ ~PartyTab() override;
- void showHelp();
+ void showHelp() override;
- bool handleCommand(const std::string &type, const std::string &args);
+ bool handleCommand(const std::string &type, const std::string &args) override;
- void saveToLogFile(std::string &msg);
+ void saveToLogFile(std::string &msg) override;
protected:
- void handleInput(const std::string &msg);
+ void handleInput(const std::string &msg) override;
- virtual void getAutoCompleteList(std::vector<std::string>&) const;
+ void getAutoCompleteList(std::vector<std::string>&) const override;
};
extern PartyTab *partyTab;
diff --git a/src/net/tmwa/guildhandler.cpp b/src/net/tmwa/guildhandler.cpp
index a3194991..180d1dfb 100644
--- a/src/net/tmwa/guildhandler.cpp
+++ b/src/net/tmwa/guildhandler.cpp
@@ -39,7 +39,7 @@ extern Net::GuildHandler *guildHandler;
namespace TmwAthena {
-GuildTab *guildTab = 0;
+GuildTab *guildTab = nullptr;
Guild *taGuild;
GuildHandler::GuildHandler()
@@ -83,7 +83,7 @@ GuildHandler::GuildHandler()
GuildHandler::~GuildHandler()
{
delete guildTab;
- guildTab = 0;
+ guildTab = nullptr;
}
void GuildHandler::handleMessage(MessageIn &msg)
diff --git a/src/net/tmwa/guildhandler.h b/src/net/tmwa/guildhandler.h
index 4a74a26b..5f8c987c 100644
--- a/src/net/tmwa/guildhandler.h
+++ b/src/net/tmwa/guildhandler.h
@@ -32,34 +32,34 @@ class GuildHandler : public Net::GuildHandler, public MessageHandler
public:
GuildHandler();
- ~GuildHandler();
+ ~GuildHandler() override;
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void create(const std::string &name);
+ void create(const std::string &name) override;
- void invite(int guildId, const std::string &name);
+ void invite(int guildId, const std::string &name) override;
- void invite(int guildId, Being *being);
+ void invite(int guildId, Being *being) override;
- void inviteResponse(int guildId, bool response);
+ void inviteResponse(int guildId, bool response) override;
- void leave(int guildId);
+ void leave(int guildId) override;
- void kick(GuildMember *member, std::string reason = "");
+ void kick(GuildMember *member, std::string reason = "") override;
- void chat(int guildId, const std::string &text);
+ void chat(int guildId, const std::string &text) override;
- void memberList(int guildId);
+ void memberList(int guildId) override;
- void changeMemberPostion(GuildMember *member, int level);
+ void changeMemberPostion(GuildMember *member, int level) override;
- void requestAlliance(int guildId, int otherGuildId);
+ void requestAlliance(int guildId, int otherGuildId) override;
void requestAllianceResponse(int guildId, int otherGuildId,
- bool response);
+ bool response) override;
- void endAlliance(int guildId, int otherGuildId);
+ void endAlliance(int guildId, int otherGuildId) override;
private:
// TmwAthena (and eAthena) only supports one guild per player
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 256e7159..6f32fb3d 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -107,8 +107,8 @@ InventoryHandler::InventoryHandler()
handledMessages = _messages;
inventoryHandler = this;
- mStorage = 0;
- mStorageWindow = 0;
+ mStorage = nullptr;
+ mStorageWindow = nullptr;
listen(Event::ItemChannel);
}
@@ -118,7 +118,7 @@ InventoryHandler::~InventoryHandler()
if (mStorageWindow)
{
mStorageWindow->close();
- mStorageWindow = 0;
+ mStorageWindow = nullptr;
}
delete mStorage;
@@ -312,8 +312,8 @@ void InventoryHandler::handleMessage(MessageIn &msg)
if (!mStorage)
mStorage = new Inventory(Inventory::STORAGE, size);
- InventoryItems::iterator it = mInventoryItems.begin();
- InventoryItems::iterator it_end = mInventoryItems.end();
+ auto it = mInventoryItems.begin();
+ auto it_end = mInventoryItems.end();
for (; it != it_end; it++)
mStorage->setItem((*it).slot, (*it).id, (*it).quantity);
mInventoryItems.clear();
@@ -359,11 +359,11 @@ void InventoryHandler::handleMessage(MessageIn &msg)
// Storage access has been closed
// Storage window deletes itself
- mStorageWindow = 0;
+ mStorageWindow = nullptr;
mStorage->clear();
delete mStorage;
- mStorage = 0;
+ mStorage = nullptr;
break;
case SMSG_PLAYER_EQUIPMENT:
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index 3eefdd9b..6224b572 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -51,13 +51,13 @@ class EquipBackend : public Equipment::Backend
memset(mEquipment, -1, sizeof(mEquipment));
}
- Item *getEquipment(int index) const
+ Item *getEquipment(int index) const override
{
int invyIndex = mEquipment[index];
return PlayerInfo::getInventory()->getItem(invyIndex);
}
- std::string getSlotName(int slotIndex) const
+ std::string getSlotName(int slotIndex) const override
{
switch (slotIndex)
{
@@ -88,7 +88,7 @@ class EquipBackend : public Equipment::Backend
}
}
- void clear()
+ void clear() override
{
for (int i = 0; i < EQUIP_VECTOR_END; i++)
{
@@ -126,14 +126,14 @@ class EquipBackend : public Equipment::Backend
inventoryWindow->updateButtons();
}
- void triggerUnequip(int slotIndex) const
+ void triggerUnequip(int slotIndex) const override
{
Item *item = getEquipment(slotIndex);
if (item)
item->doEvent(Event::DoUnequip);
}
- int getSlotNumber() const
+ int getSlotNumber() const override
{ return EQUIP_VECTOR_END; }
// Note the slot type id is equal to the slot Index for tA.
@@ -172,7 +172,7 @@ class InventoryItem
}
};
-typedef std::list<InventoryItem> InventoryItems;
+using InventoryItems = std::list<InventoryItem>;
class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
public EventListener
@@ -185,20 +185,20 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler,
InventoryHandler();
- ~InventoryHandler();
+ ~InventoryHandler() override;
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void event(Event::Channel channel, const Event &event);
+ void event(Event::Channel channel, const Event &event) override;
- bool canSplit(const Item *item);
+ bool canSplit(const Item *item) override;
- size_t getSize(int type) const;
+ size_t getSize(int type) const override;
- bool isWeaponSlot(unsigned int slotTypeId) const
+ bool isWeaponSlot(unsigned int slotTypeId) const override
{ return mEquips.isWeaponSlot(slotTypeId); }
- bool isAmmoSlot(unsigned int slotTypeId) const
+ bool isAmmoSlot(unsigned int slotTypeId) const override
{ return mEquips.isAmmoSlot(slotTypeId); }
private:
diff --git a/src/net/tmwa/itemhandler.h b/src/net/tmwa/itemhandler.h
index 3f58a172..29ed8246 100644
--- a/src/net/tmwa/itemhandler.h
+++ b/src/net/tmwa/itemhandler.h
@@ -31,7 +31,7 @@ class ItemHandler : public MessageHandler
public:
ItemHandler();
- virtual void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/loginhandler.cpp b/src/net/tmwa/loginhandler.cpp
index 2fbc02d4..3e742f88 100644
--- a/src/net/tmwa/loginhandler.cpp
+++ b/src/net/tmwa/loginhandler.cpp
@@ -127,7 +127,7 @@ void LoginHandler::handleMessage(MessageIn &msg)
for (int i = 0; i < worldCount; i++)
{
- WorldInfo *world = new WorldInfo;
+ auto *world = new WorldInfo;
world->address = msg.readInt32();
world->port = msg.readInt16();
diff --git a/src/net/tmwa/loginhandler.h b/src/net/tmwa/loginhandler.h
index fcc7c5cc..92a268f1 100644
--- a/src/net/tmwa/loginhandler.h
+++ b/src/net/tmwa/loginhandler.h
@@ -38,43 +38,43 @@ class LoginHandler : public MessageHandler, public Net::LoginHandler
public:
LoginHandler();
- ~LoginHandler();
+ ~LoginHandler() override;
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void connect();
+ void connect() override;
- bool isConnected();
+ bool isConnected() override;
- void disconnect();
+ void disconnect() override;
- int supportedOptionalActions() const
+ int supportedOptionalActions() const override
{ return SetGenderOnRegister; }
- bool isRegistrationEnabled();
+ bool isRegistrationEnabled() override;
- void getRegistrationDetails();
+ void getRegistrationDetails() override;
- unsigned int getMaxPasswordLength() const { return 25; }
+ unsigned int getMaxPasswordLength() const override { return 25; }
- void loginAccount(LoginData *loginData);
+ void loginAccount(LoginData *loginData) override;
- void logout();
+ void logout() override;
- void changeEmail(const std::string &email);
+ void changeEmail(const std::string &email) override;
void changePassword(const std::string &username,
const std::string &oldPassword,
- const std::string &newPassword);
+ const std::string &newPassword) override;
- void chooseServer(unsigned int server);
+ void chooseServer(unsigned int server) override;
- void registerAccount(LoginData *loginData);
+ void registerAccount(LoginData *loginData) override;
void unregisterAccount(const std::string &username,
- const std::string &password);
+ const std::string &password) override;
- Worlds getWorlds() const;
+ Worlds getWorlds() const override;
void clearWorlds();
const Token &getToken() const { return mToken; }
diff --git a/src/net/tmwa/messagehandler.cpp b/src/net/tmwa/messagehandler.cpp
index b22b623e..e9ce33b1 100644
--- a/src/net/tmwa/messagehandler.cpp
+++ b/src/net/tmwa/messagehandler.cpp
@@ -28,7 +28,7 @@
namespace TmwAthena {
MessageHandler::MessageHandler()
- : mNetwork(NULL)
+ : mNetwork(nullptr)
{
}
diff --git a/src/net/tmwa/messagehandler.h b/src/net/tmwa/messagehandler.h
index b598f896..0d278c15 100644
--- a/src/net/tmwa/messagehandler.h
+++ b/src/net/tmwa/messagehandler.h
@@ -39,7 +39,7 @@ class MessageHandler : public Net::MessageHandler
public:
MessageHandler();
- ~MessageHandler();
+ ~MessageHandler() override;
virtual void handleMessage(MessageIn &msg) = 0;
@@ -49,7 +49,7 @@ class MessageHandler : public Net::MessageHandler
Network *mNetwork;
};
-typedef const std::unique_ptr<MessageHandler> MessageHandlerPtr;
+using MessageHandlerPtr = const std::unique_ptr<MessageHandler>;
}
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 5ff4f7e5..c1ba615f 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -91,7 +91,7 @@ namespace TmwAthena {
int networkThread(void *data)
{
- Network *network = static_cast<Network*>(data);
+ auto *network = static_cast<Network*>(data);
if (!network->realConnect())
return -1;
@@ -101,16 +101,16 @@ int networkThread(void *data)
return 0;
}
-Network *Network::mInstance = 0;
+Network *Network::mInstance = nullptr;
Network::Network():
- mSocket(0),
+ mSocket(nullptr),
mInBuffer(new char[BUFFER_SIZE]),
mOutBuffer(new char[BUFFER_SIZE]),
mInSize(0), mOutSize(0),
mToSkip(0),
mState(IDLE),
- mWorkerThread(0)
+ mWorkerThread(nullptr)
{
SDLNet_Init();
@@ -124,7 +124,7 @@ Network::~Network()
if (mState != IDLE && mState != NET_ERROR)
disconnect();
- mInstance = 0;
+ mInstance = nullptr;
delete[] mInBuffer;
delete[] mOutBuffer;
@@ -175,14 +175,14 @@ void Network::disconnect()
if (mWorkerThread)
{
- SDL_WaitThread(mWorkerThread, NULL);
- mWorkerThread = NULL;
+ SDL_WaitThread(mWorkerThread, nullptr);
+ mWorkerThread = nullptr;
}
if (mSocket)
{
SDLNet_TCP_Close(mSocket);
- mSocket = 0;
+ mSocket = nullptr;
}
}
@@ -203,7 +203,7 @@ void Network::unregisterHandler(MessageHandler *handler)
mMessageHandlers.erase(*i);
}
- handler->setNetwork(0);
+ handler->setNetwork(nullptr);
}
void Network::clearHandlers()
@@ -211,7 +211,7 @@ void Network::clearHandlers()
MessageHandlerIterator i;
for (i = mMessageHandlers.begin(); i != mMessageHandlers.end(); ++i)
{
- i->second->setNetwork(0);
+ i->second->setNetwork(nullptr);
}
mMessageHandlers.clear();
}
@@ -222,7 +222,7 @@ void Network::dispatchMessages()
{
MessageIn msg = getNextMessage();
- MessageHandlerIterator iter = mMessageHandlers.find(msg.getId());
+ auto iter = mMessageHandlers.find(msg.getId());
if (msg.getLength() == 0)
logger->error("Zero length packet received. Exiting.");
diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h
index 079e71ca..97c7970f 100644
--- a/src/net/tmwa/network.h
+++ b/src/net/tmwa/network.h
@@ -120,8 +120,8 @@ class Network
SDL_Thread *mWorkerThread;
Mutex mMutex;
- typedef std::map<Uint16, MessageHandler*> MessageHandlers;
- typedef MessageHandlers::iterator MessageHandlerIterator;
+ using MessageHandlers = std::map<Uint16, MessageHandler *>;
+ using MessageHandlerIterator = MessageHandlers::iterator;
MessageHandlers mMessageHandlers;
static Network *mInstance;
diff --git a/src/net/tmwa/npchandler.cpp b/src/net/tmwa/npchandler.cpp
index 2b0a5b0a..9bd15572 100644
--- a/src/net/tmwa/npchandler.cpp
+++ b/src/net/tmwa/npchandler.cpp
@@ -76,7 +76,7 @@ void NpcHandler::handleMessage(MessageIn &msg)
}
int npcId = msg.readInt32();
- Event *event = 0;
+ Event *event = nullptr;
switch (msg.getId())
{
diff --git a/src/net/tmwa/npchandler.h b/src/net/tmwa/npchandler.h
index 71486a40..0a0cd130 100644
--- a/src/net/tmwa/npchandler.h
+++ b/src/net/tmwa/npchandler.h
@@ -37,34 +37,34 @@ class NpcHandler : public MessageHandler, public Net::NpcHandler
public:
NpcHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void startShopping(int beingId);
+ void startShopping(int beingId) override;
- void buy(int beingId);
+ void buy(int beingId) override;
- void sell(int beingId);
+ void sell(int beingId) override;
- void buyItem(int beingId, int itemId, int amount);
+ void buyItem(int beingId, int itemId, int amount) override;
- void sellItem(int beingId, int itemId, int amount);
+ void sellItem(int beingId, int itemId, int amount) override;
- void endShopping(int beingId);
+ void endShopping(int beingId) override;
- void talk(int npcId);
+ void talk(int npcId) override;
- void nextDialog(int npcId);
+ void nextDialog(int npcId) override;
- void closeDialog(int npcId);
+ void closeDialog(int npcId) override;
- void menuSelect(int npcId, int choice);
+ void menuSelect(int npcId, int choice) override;
- void integerInput(int npcId, int value);
+ void integerInput(int npcId, int value) override;
- void stringInput(int npcId, const std::string &value);
+ void stringInput(int npcId, const std::string &value) override;
void sendLetter(int npcId, const std::string &recipient,
- const std::string &text);
+ const std::string &text) override;
};
diff --git a/src/net/tmwa/partyhandler.cpp b/src/net/tmwa/partyhandler.cpp
index 4753dac1..b8d9c3c7 100644
--- a/src/net/tmwa/partyhandler.cpp
+++ b/src/net/tmwa/partyhandler.cpp
@@ -43,7 +43,7 @@ extern Net::PartyHandler *partyHandler;
namespace TmwAthena {
-PartyTab *partyTab = 0;
+PartyTab *partyTab = nullptr;
Party *taParty;
PartyHandler::PartyHandler():
@@ -70,7 +70,7 @@ PartyHandler::PartyHandler():
PartyHandler::~PartyHandler()
{
delete partyTab;
- partyTab = 0;
+ partyTab = nullptr;
}
void PartyHandler::handleMessage(MessageIn &msg)
@@ -237,7 +237,7 @@ void PartyHandler::handleMessage(MessageIn &msg)
if (partyTab)
{
delete partyTab;
- partyTab = 0;
+ partyTab = nullptr;
}
socialWindow->removeTab(taParty);
}
@@ -248,7 +248,7 @@ void PartyHandler::handleMessage(MessageIn &msg)
if (Being *b = actorSpriteManager->findBeing(id))
{
- b->setParty(NULL);
+ b->setParty(nullptr);
}
taParty->removeMember(id);
diff --git a/src/net/tmwa/partyhandler.h b/src/net/tmwa/partyhandler.h
index 9a3570a8..5268f395 100644
--- a/src/net/tmwa/partyhandler.h
+++ b/src/net/tmwa/partyhandler.h
@@ -36,37 +36,37 @@ class PartyHandler : public MessageHandler, public Net::PartyHandler
public:
PartyHandler();
- ~PartyHandler();
+ ~PartyHandler() override;
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void create(const std::string &name = "");
+ void create(const std::string &name = "") override;
- void join(int partyId);
+ void join(int partyId) override;
- void invite(Being *being);
+ void invite(Being *being) override;
- void invite(const std::string &name);
+ void invite(const std::string &name) override;
- void inviteResponse(const std::string &inviter, bool accept);
+ void inviteResponse(const std::string &inviter, bool accept) override;
- void leave();
+ void leave() override;
- void kick(Being *being);
+ void kick(Being *being) override;
- void kick(const std::string &name);
+ void kick(const std::string &name) override;
- void chat(const std::string &text);
+ void chat(const std::string &text) override;
- void requestPartyMembers();
+ void requestPartyMembers() override;
- PartyShare getShareExperience() { return mShareExp; }
+ PartyShare getShareExperience() override { return mShareExp; }
- void setShareExperience(PartyShare share);
+ void setShareExperience(PartyShare share) override;
- PartyShare getShareItems() { return mShareItems; }
+ PartyShare getShareItems() override { return mShareItems; }
- void setShareItems(PartyShare share);
+ void setShareItems(PartyShare share) override;
private:
PartyShare mShareExp, mShareItems;
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp
index c598c5f9..6ef669e4 100644
--- a/src/net/tmwa/playerhandler.cpp
+++ b/src/net/tmwa/playerhandler.cpp
@@ -60,9 +60,9 @@ namespace {
*/
struct WeightListener : public gcn::ActionListener
{
- void action(const gcn::ActionEvent &event)
+ void action(const gcn::ActionEvent &event) override
{
- weightNotice = NULL;
+ weightNotice = nullptr;
}
} weightListener;
@@ -71,10 +71,10 @@ namespace {
*/
struct DeathListener : public gcn::ActionListener
{
- void action(const gcn::ActionEvent &event)
+ void action(const gcn::ActionEvent &event) override
{
Net::getPlayerHandler()->respawn();
- deathNotice = NULL;
+ deathNotice = nullptr;
BuyDialog::closeAll();
BuySellDialog::closeAll();
diff --git a/src/net/tmwa/playerhandler.h b/src/net/tmwa/playerhandler.h
index 2c4b6194..24284ee4 100644
--- a/src/net/tmwa/playerhandler.h
+++ b/src/net/tmwa/playerhandler.h
@@ -34,35 +34,35 @@ class PlayerHandler : public MessageHandler, public Net::PlayerHandler
public:
PlayerHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void attack(int id);
- void emote(int emoteId);
+ void attack(int id) override;
+ void emote(int emoteId) override;
- void increaseAttribute(int attr);
- void decreaseAttribute(int attr);
- void increaseSkill(int skillId);
+ void increaseAttribute(int attr) override;
+ void decreaseAttribute(int attr) override;
+ void increaseSkill(int skillId) override;
- void pickUp(FloorItem *floorItem);
- void setDirection(char direction);
- void setDestination(int x, int y, int direction = -1);
- void changeAction(Being::Action action);
+ void pickUp(FloorItem *floorItem) override;
+ void setDirection(char direction) override;
+ void setDestination(int x, int y, int direction = -1) override;
+ void changeAction(Being::Action action) override;
- void respawn();
+ void respawn() override;
- void ignorePlayer(const std::string &player, bool ignore);
- void ignoreAll(bool ignore);
+ void ignorePlayer(const std::string &player, bool ignore) override;
+ void ignoreAll(bool ignore) override;
- bool canUseMagic();
- bool canCorrectAttributes();
+ bool canUseMagic() override;
+ bool canCorrectAttributes() override;
- int getJobLocation();
+ int getJobLocation() override;
- Vector getDefaultMoveSpeed() const;
+ Vector getDefaultMoveSpeed() const override;
- Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = 0);
+ Vector getPixelsPerTickMoveSpeed(const Vector &speed, Map *map = nullptr) override;
- bool usePixelPrecision()
+ bool usePixelPrecision() override
{ return false; }
};
diff --git a/src/net/tmwa/specialhandler.h b/src/net/tmwa/specialhandler.h
index bb772ff1..f43c900e 100644
--- a/src/net/tmwa/specialhandler.h
+++ b/src/net/tmwa/specialhandler.h
@@ -34,15 +34,15 @@ class SpecialHandler : public MessageHandler, public Net::SpecialHandler
public:
SpecialHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void use(int id);
+ void use(int id) override;
- void use(int id, int level, int beingId);
+ void use(int id, int level, int beingId) override;
- void use(int id, int level, int x, int y);
+ void use(int id, int level, int x, int y) override;
- void use(int id, const std::string &map);
+ void use(int id, const std::string &map) override;
};
} // namespace TmwAthena
diff --git a/src/net/tmwa/tradehandler.cpp b/src/net/tmwa/tradehandler.cpp
index a02056a4..2441d83a 100644
--- a/src/net/tmwa/tradehandler.cpp
+++ b/src/net/tmwa/tradehandler.cpp
@@ -51,9 +51,9 @@ ConfirmDialog *confirmDlg;
namespace {
struct RequestTradeListener : public gcn::ActionListener
{
- void action(const gcn::ActionEvent &event)
+ void action(const gcn::ActionEvent &event) override
{
- confirmDlg = 0;
+ confirmDlg = nullptr;
Net::getTradeHandler()->respond(event.getId() == "yes");
}
} listener;
@@ -77,7 +77,7 @@ TradeHandler::TradeHandler()
};
handledMessages = _messages;
tradeHandler = this;
- confirmDlg = 0;
+ confirmDlg = nullptr;
}
diff --git a/src/net/tmwa/tradehandler.h b/src/net/tmwa/tradehandler.h
index 60ee4444..d4f2494f 100644
--- a/src/net/tmwa/tradehandler.h
+++ b/src/net/tmwa/tradehandler.h
@@ -34,23 +34,23 @@ class TradeHandler : public MessageHandler, public Net::TradeHandler
public:
TradeHandler();
- void handleMessage(MessageIn &msg);
+ void handleMessage(MessageIn &msg) override;
- void request(Being *being);
+ void request(Being *being) override;
- void respond(bool accept);
+ void respond(bool accept) override;
- void addItem(Item *item, int amount);
+ void addItem(Item *item, int amount) override;
- void removeItem(int slotNum, int amount);
+ void removeItem(int slotNum, int amount) override;
- void setMoney(int amount);
+ void setMoney(int amount) override;
- void confirm();
+ void confirm() override;
- void finish();
+ void finish() override;
- void cancel();
+ void cancel() override;
private:
bool mTrading;
diff --git a/src/net/worldinfo.h b/src/net/worldinfo.h
index 2bc3b316..d9596239 100644
--- a/src/net/worldinfo.h
+++ b/src/net/worldinfo.h
@@ -33,6 +33,6 @@ struct WorldInfo {
std::string updateHost;
};
-typedef std::vector<WorldInfo*> Worlds;
+using Worlds = std::vector<WorldInfo *>;
#endif // WORLD_INFO_H