diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | src/game.cpp | 4 | ||||
-rw-r--r-- | src/net/network.cpp | 22 |
3 files changed, 14 insertions, 14 deletions
@@ -1,5 +1,7 @@ 2006-01-22 Björn Steinbrink <B.Steinbrink@gmx.de> + * src/game.cpp, src/net/network.cpp: Make dispatchMessages actually + handle more than one message per call. * src/main.cpp: Remove obsoleted action listeners. * src/main.cpp: Use generic error method for sound failure. * src/main.cpp, src/net/charserverhandler.cpp, diff --git a/src/game.cpp b/src/game.cpp index dcd7b9d9..edc1789f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -369,10 +369,8 @@ void game(Network *network) } // Handle network stuff - while(network->messageReady()) - network->dispatchMessages(); - network->flush(); + network->dispatchMessages(); } do_exit(network); diff --git a/src/net/network.cpp b/src/net/network.cpp index 3b0652e2..f519a467 100644 --- a/src/net/network.cpp +++ b/src/net/network.cpp @@ -214,20 +214,20 @@ void Network::clearHandlers() void Network::dispatchMessages() { - if (!messageReady()) - return; - - MessageIn msg = getNextMessage(); + while (messageReady()) + { + MessageIn msg = getNextMessage(); - std::map<Uint16, MessageHandler*>::iterator iter; - iter = mMessageHandlers.find(msg.getId()); + std::map<Uint16, MessageHandler*>::iterator iter; + iter = mMessageHandlers.find(msg.getId()); - if (iter != mMessageHandlers.end()) - iter->second->handleMessage(&msg); - else - logger->log("Unhandled packet: %x", msg.getId()); + if (iter != mMessageHandlers.end()) + iter->second->handleMessage(&msg); + else + logger->log("Unhandled packet: %x", msg.getId()); - skip(msg.getLength()); + skip(msg.getLength()); + } } void Network::flush() |