summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2014-01-25 15:28:16 +0100
committermadmaxoft <github@xoft.cz>2014-01-25 15:28:16 +0100
commitff066453b805748d6e665b3ad219a62c777e4453 (patch)
tree6e8f15418c0dfab39e55c28e96648290be33ca68
parentAdded cFile::Flush(). (diff)
downloadcuberite-ff066453b805748d6e665b3ad219a62c777e4453.tar
cuberite-ff066453b805748d6e665b3ad219a62c777e4453.tar.gz
cuberite-ff066453b805748d6e665b3ad219a62c777e4453.tar.bz2
cuberite-ff066453b805748d6e665b3ad219a62c777e4453.tar.lz
cuberite-ff066453b805748d6e665b3ad219a62c777e4453.tar.xz
cuberite-ff066453b805748d6e665b3ad219a62c777e4453.tar.zst
cuberite-ff066453b805748d6e665b3ad219a62c777e4453.zip
-rw-r--r--src/Protocol/Protocol17x.cpp26
-rw-r--r--src/Protocol/Protocol17x.h2
-rw-r--r--src/main.cpp4
3 files changed, 16 insertions, 16 deletions
diff --git a/src/Protocol/Protocol17x.cpp b/src/Protocol/Protocol17x.cpp
index 8abe4f259..504dd99c3 100644
--- a/src/Protocol/Protocol17x.cpp
+++ b/src/Protocol/Protocol17x.cpp
@@ -53,10 +53,8 @@ Implements the 1.7.x protocol classes:
-#ifdef _DEBUG
// fwd: main.cpp:
extern bool g_ShouldLogComm;
-#endif
@@ -76,14 +74,12 @@ cProtocol172::cProtocol172(cClientHandle * a_Client, const AString & a_ServerAdd
m_IsEncrypted(false)
{
// Create the comm log file, if so requested:
- #ifdef _DEBUG
if (g_ShouldLogComm)
{
cFile::CreateFolder("CommLogs");
AString FileName = Printf("CommLogs/%x__%s.log", (unsigned)time(NULL), a_Client->GetIPString().c_str());
m_CommLogFile.Open(FileName, cFile::fmWrite);
}
- #endif // _DEBUG
}
@@ -1087,7 +1083,6 @@ void cProtocol172::SendWindowProperty(const cWindow & a_Window, short a_Property
void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
{
// Write the incoming data into the comm log file:
- #ifdef _DEBUG
if (g_ShouldLogComm)
{
if (m_ReceivedData.GetReadableSpace() > 0)
@@ -1109,7 +1104,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
a_Size, a_Size, Hex.c_str()
);
}
- #endif
if (!m_ReceivedData.Write(a_Data, a_Size))
{
@@ -1147,7 +1141,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
}
// Log the packet info into the comm log file:
- #ifdef _DEBUG
if (g_ShouldLogComm)
{
AString PacketData;
@@ -1162,7 +1155,6 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
PacketType, PacketType, PacketLen, PacketLen, m_State, PacketDataHex.c_str()
);
}
- #endif // _DEBUG
if (!HandlePacket(bb, PacketType))
{
@@ -1180,6 +1172,12 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
LOGD("Packet contents:\n%s", Out.c_str());
#endif // _DEBUG
+ // Put a message in the comm log:
+ if (g_ShouldLogComm)
+ {
+ m_CommLogFile.Printf("^^^^^^ Unhandled packet ^^^^^^\n\n\n");
+ }
+
return;
}
@@ -1189,6 +1187,16 @@ void cProtocol172::AddReceivedData(const char * a_Data, int a_Size)
LOGWARNING("Protocol 1.7: Wrong number of bytes read for packet 0x%x, state %d. Read %u bytes, packet contained %u bytes",
PacketType, m_State, bb.GetUsedSpace() - bb.GetReadableSpace(), PacketLen
);
+
+ // Put a message in the comm log:
+ if (g_ShouldLogComm)
+ {
+ m_CommLogFile.Printf("^^^^^^ Wrong number of bytes read for this packet (exp %d left, got %d left) ^^^^^^\n\n\n",
+ 1, bb.GetReadableSpace()
+ );
+ m_CommLogFile.Flush();
+ }
+
ASSERT(!"Read wrong number of bytes!");
m_Client->PacketError(PacketType);
}
@@ -1873,7 +1881,6 @@ cProtocol172::cPacketizer::~cPacketizer()
m_Out.CommitRead();
// Log the comm into logfile:
- #ifdef _DEBUG
if (g_ShouldLogComm)
{
AString Hex;
@@ -1883,7 +1890,6 @@ cProtocol172::cPacketizer::~cPacketizer()
DataToSend[0], DataToSend[0], PacketLen, PacketLen, m_Protocol.m_State, Hex.c_str()
);
}
- #endif // _DEBUG
}
diff --git a/src/Protocol/Protocol17x.h b/src/Protocol/Protocol17x.h
index b04a1f019..cac7f0d29 100644
--- a/src/Protocol/Protocol17x.h
+++ b/src/Protocol/Protocol17x.h
@@ -223,10 +223,8 @@ protected:
CryptoPP::CFB_Mode<CryptoPP::AES>::Decryption m_Decryptor;
CryptoPP::CFB_Mode<CryptoPP::AES>::Encryption m_Encryptor;
- #ifdef _DEBUG
/** The logfile where the comm is logged, when g_ShouldLogComm is true */
cFile m_CommLogFile;
- #endif
/// Adds the received (unencrypted) data to m_ReceivedData, parses complete packets
diff --git a/src/main.cpp b/src/main.cpp
index 902e9e43b..06b344c25 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -19,10 +19,8 @@ bool g_SERVER_TERMINATED = false; // Set to true when the server terminates, so
-#ifdef _DEBUG
/** If set to true, the protocols will log each player's communication to a separate logfile */
bool g_ShouldLogComm;
-#endif
@@ -232,7 +230,6 @@ int main( int argc, char **argv )
// *((int *)0) = 0;
// Check if comm logging is to be enabled:
- #ifdef _DEBUG
for (int i = 0; i < argc; i++)
{
if (
@@ -243,7 +240,6 @@ int main( int argc, char **argv )
g_ShouldLogComm = true;
}
}
- #endif // _DEBUG
#if !defined(ANDROID_NDK)
try