summaryrefslogtreecommitdiffstats
path: root/src/network/Network.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-28 16:16:05 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-28 16:16:05 +0200
commitd93c2073896e63aca5a859fe7182ba24dbe84cd3 (patch)
tree6144aaf7e01854fe245011ca4f4735974366febb /src/network/Network.cpp
parent2017-05-26 (diff)
downloadAltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.gz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.bz2
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.lz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.xz
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.tar.zst
AltCraft-d93c2073896e63aca5a859fe7182ba24dbe84cd3.zip
Diffstat (limited to '')
-rw-r--r--src/network/Network.cpp39
1 files changed, 6 insertions, 33 deletions
diff --git a/src/network/Network.cpp b/src/network/Network.cpp
index ac84494..b3b1e4b 100644
--- a/src/network/Network.cpp
+++ b/src/network/Network.cpp
@@ -57,8 +57,8 @@ Packet Network::ReceivePacket() {
}
Field fLen = FieldParser::Parse(VarInt, bufLen);
size_t packetLen = fLen.GetVarInt() + fLen.GetLength();
- if (packetLen > 1024 * 1024 * 30)
- std::cout << "OMG! SIZEOF PACKET IS " << packetLen << std::endl;
+ if (packetLen > 1024 * 1024 * 15)
+ LOG(WARNING)<<"OMG SIZEOF PACKAGE IS "<<packetLen;
if (packetLen < rec) {
return Packet(bufLen);
}
@@ -68,39 +68,12 @@ Packet Network::ReceivePacket() {
while (m_socket.receive(bufPack + dataLen, packetLen - dataLen, rec) == sf::Socket::Done && dataLen < packetLen) {
dataLen += rec;
}
- if (dataLen < packetLen)
- throw 93;
- else {
+ if (dataLen < packetLen) {
+ LOG(ERROR) << "Received data is "<<dataLen<<" but "<<packetLen<<" is promoted";
+ throw std::runtime_error("");
+ } else {
Packet p(bufPack);
delete[] bufPack;
return p;
}
-
- /*if (m_socket.receive(bufPack + rec, packetLen - rec, rec) != sf::Socket::Done) {
- delete[] bufPack;
- throw 93;
- }
- rec++;
- //Check for losted data
- int losted = 0;
- for (int i = packetLen - 2; i > 0; i--)
- if (bufPack[i] == 'N')
- losted++;
- if (losted > 100) {
- if (m_socket.receive(bufPack + rec, packetLen - rec, rec) != sf::Socket::Done) {
- throw 93;
- }
- std::cout << "Keep receiving!" << std::endl;
- }
- //One more time
- losted = 0;
- for (int i = packetLen - 2; i > 0; i--)
- if (bufPack[i] == 'N')
- losted++;
- if (losted > 100) {
- std::cout << "\x1b[31m" << "Losted " << losted << " bytes of " << packetLen << "\x1b[0m" << std::endl;
- delete[] bufPack;
- throw 93;
- }*/
- throw 94;
}