summaryrefslogtreecommitdiff
path: root/src/net/eathena/network.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-09-02 02:59:54 +0300
committerAndrei Karas <akaras@inbox.ru>2015-09-02 02:59:54 +0300
commitab8c8cdae07d96cb18276a95b41ddb856c864958 (patch)
treecd971a8f686942e33715dcb781dcaa9fd9d13fee /src/net/eathena/network.cpp
parent7ccc1b5fe8988b2a51d3fb2f4422f95c98a8d6aa (diff)
downloadplus-ab8c8cdae07d96cb18276a95b41ddb856c864958.tar.gz
plus-ab8c8cdae07d96cb18276a95b41ddb856c864958.tar.bz2
plus-ab8c8cdae07d96cb18276a95b41ddb856c864958.tar.xz
plus-ab8c8cdae07d96cb18276a95b41ddb856c864958.zip
Remove variable mMessageHandlers from network code.
Diffstat (limited to 'src/net/eathena/network.cpp')
-rw-r--r--src/net/eathena/network.cpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index fdafd6baf..33c530989 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -93,30 +93,28 @@ static const unsigned int messagesSize = 0xFFFFU;
Network *Network::mInstance = nullptr;
Network::Network() :
- Ea::Network(),
- mMessageHandlers(new MessageHandler*[messagesSize])
+ Ea::Network()
{
mInstance = this;
- memset(&mMessageHandlers[0], 0, sizeof(MessageHandler*) * 0xffff);
mPackets = new PacketInfo[messagesSize];
-#include "net/eathena/recvpackets.inc"
}
Network::~Network()
{
clearHandlers();
- delete2Arr(mMessageHandlers);
mInstance = nullptr;
}
+void Network::registerHandlers()
+{
+#include "net/eathena/recvpackets.inc"
+}
+
void Network::registerHandler(MessageHandler *const handler)
{
if (!handler)
return;
- for (const uint16_t *i = handler->handledMessages; *i; ++i)
- mMessageHandlers[*i] = handler;
-
handler->setNetwork(this);
}
@@ -125,22 +123,11 @@ void Network::unregisterHandler(MessageHandler *const handler)
if (!handler)
return;
- for (const uint16_t *i = handler->handledMessages; *i; ++i)
- mMessageHandlers[*i] = nullptr;
-
handler->setNetwork(nullptr);
}
void Network::clearHandlers()
{
- for (size_t f = 0; f < messagesSize; f ++)
- {
- if (mMessageHandlers[f])
- {
- mMessageHandlers[f]->setNetwork(nullptr);
- mMessageHandlers[f] = nullptr;
- }
- }
}
void Network::dispatchMessages()