summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/network.cpp25
-rw-r--r--src/net/network.h3
2 files changed, 28 insertions, 0 deletions
diff --git a/src/net/network.cpp b/src/net/network.cpp
index e94acee7..4504a944 100644
--- a/src/net/network.cpp
+++ b/src/net/network.cpp
@@ -332,6 +332,31 @@ unsigned short readWord(int pos)
#endif
}
+bool packetReady()
+{
+ bool ret = false;
+ if (in_size >= 2)
+ {
+ int length = packet_lengths[readWord(0)];
+ if (length == -1)
+ {
+ if (in_size >= 4)
+ {
+ length = readWord(2);
+ if (in_size >= length)
+ {
+ ret = true;
+ }
+ }
+ }
+ else if (in_size >= length)
+ {
+ ret = true;
+ }
+ }
+ return ret;
+}
+
MessageIn
get_next_message()
{
diff --git a/src/net/network.h b/src/net/network.h
index 50638683..db95d7c3 100644
--- a/src/net/network.h
+++ b/src/net/network.h
@@ -47,6 +47,9 @@ void closeConnection();
/** Send and receive data waiting in the buffers */
void flush();
+/** Check if a packet is complete */
+bool packetReady();
+
/**
* Returns the next arriving message, waiting for it if necessary.
*/