summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/net/eathena/messageout.cpp1
-rw-r--r--src/net/eathena/network.cpp11
-rw-r--r--src/net/eathena/network.h2
-rw-r--r--src/net/tmwa/messageout.cpp1
-rw-r--r--src/net/tmwa/network.cpp11
-rw-r--r--src/net/tmwa/network.h2
6 files changed, 28 insertions, 0 deletions
diff --git a/src/net/eathena/messageout.cpp b/src/net/eathena/messageout.cpp
index 795807a3f..a486a02f5 100644
--- a/src/net/eathena/messageout.cpp
+++ b/src/net/eathena/messageout.cpp
@@ -45,6 +45,7 @@ MessageOut::MessageOut(short id):
Net::MessageOut(id)
{
mNetwork = EAthena::Network::instance();
+ mNetwork->fixSendBuffer();
mData = mNetwork->mOutBuffer + mNetwork->mOutSize;
writeInt16(id);
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index e7e15d8e4..d01613075 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -525,4 +525,15 @@ uint16_t Network::readWord(int pos)
#endif
}
+void Network::fixSendBuffer()
+{
+ if (mOutSize > BUFFER_LIMIT)
+ {
+ if (mState != CONNECTED)
+ mOutSize = 0;
+ else
+ flush();
+ }
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/network.h b/src/net/eathena/network.h
index 4a7f41c09..1fdcf7c6e 100644
--- a/src/net/eathena/network.h
+++ b/src/net/eathena/network.h
@@ -86,6 +86,8 @@ class Network
void flush();
+ void fixSendBuffer();
+
// ERROR replaced by NET_ERROR because already defined in Windows
enum
{
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
{