summaryrefslogtreecommitdiff
path: root/src/net/tmwa/network.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/tmwa/network.cpp')
-rw-r--r--src/net/tmwa/network.cpp25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index cce906703..0e99f9dbd 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -74,30 +74,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/tmwa/recvpackets.inc"
}
Network::~Network()
{
clearHandlers();
- delete2Arr(mMessageHandlers);
mInstance = nullptr;
}
+void Network::registerHandlers()
+{
+#include "net/tmwa/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);
}
@@ -106,22 +104,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()