From 94d65b487d458341e3626bcfa41fa09c1c240d89 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 19 Aug 2012 15:44:41 +0300 Subject: Flush send buffer if it too big. --- src/net/tmwa/messageout.cpp | 1 + src/net/tmwa/network.cpp | 11 +++++++++++ src/net/tmwa/network.h | 2 ++ 3 files changed, 14 insertions(+) (limited to 'src/net/tmwa') diff --git a/src/net/tmwa/messageout.cpp b/src/net/tmwa/messageout.cpp index 57cbceca3..1ceb806be 100644 --- a/src/net/tmwa/messageout.cpp +++ b/src/net/tmwa/messageout.cpp @@ -45,6 +45,7 @@ MessageOut::MessageOut(short id): Net::MessageOut(id) { mNetwork = TmwAthena::Network::instance(); + mNetwork->fixSendBuffer(); mData = mNetwork->mOutBuffer + mNetwork->mOutSize; writeInt16(id); diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp index 32b1174c1..4f2f85a51 100644 --- a/src/net/tmwa/network.cpp +++ b/src/net/tmwa/network.cpp @@ -503,4 +503,15 @@ uint16_t Network::readWord(int pos) #endif } +void Network::fixSendBuffer() +{ + if (mOutSize > BUFFER_LIMIT) + { + if (mState != CONNECTED) + mOutSize = 0; + else + flush(); + } +} + } // namespace TmwAthena diff --git a/src/net/tmwa/network.h b/src/net/tmwa/network.h index 2c9e0de0d..cc7ae129b 100644 --- a/src/net/tmwa/network.h +++ b/src/net/tmwa/network.h @@ -87,6 +87,8 @@ class Network void flush(); + void fixSendBuffer(); + // ERROR replaced by NET_ERROR because already defined in Windows enum { -- cgit v1.2.3-70-g09d2