diff options
Diffstat (limited to 'src/net/tmwa/network.cpp')
-rw-r--r-- | src/net/tmwa/network.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 15200fa50..278f8e2fd 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -137,24 +137,26 @@ void Network::dispatchMessages() { while (messageReady()) { - MessageIn msg = getNextMessage(); + MessageIn *const msg = getNextMessage(); - const MessageHandlerIterator iter = mMessageHandlers.find(msg.getId()); + const MessageHandlerIterator iter = mMessageHandlers.find( + msg->getId()); - if (msg.getLength() == 0) + if (msg->getLength() == 0) logger->safeError("Zero length packet received. Exiting."); if (iter != mMessageHandlers.end()) { if (iter->second) - iter->second->handleMessage(msg); + iter->second->handleMessage(*msg); } else { - logger->log("Unhandled packet: %x", msg.getId()); + logger->log("Unhandled packet: %x", msg->getId()); } - skip(msg.getLength()); + skip(msg->getLength()); + delete msg; } } @@ -193,7 +195,7 @@ bool Network::messageReady() return ret; } -MessageIn Network::getNextMessage() +MessageIn *Network::getNextMessage() { while (!messageReady()) { @@ -219,7 +221,7 @@ MessageIn Network::getNextMessage() // msgId, len)); #endif - MessageIn msg(mInBuffer, len); + MessageIn *msg = new MessageIn(mInBuffer, len); SDL_mutexV(mMutex); return msg; |