Browse Source

Wrap NetLog stuff in !defined(PLASMA_EXTERNAL_RELEASE)

Michael Hansen 13 years ago
parent
commit
7cbcc8a6fc
  1. 44
      Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp

44
Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp

@ -42,6 +42,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//#define NO_ENCRYPTION //#define NO_ENCRYPTION
#ifndef PLASMA_EXTERNAL_RELEASE
struct NetLogMessage_Header struct NetLogMessage_Header
{ {
unsigned m_protocol; unsigned m_protocol;
@ -50,22 +52,24 @@ struct NetLogMessage_Header
unsigned m_size; unsigned m_size;
}; };
#define HURU_PIPE_NAME "\\\\.\\pipe\\H-Uru_NetLog" #define HURU_PIPE_NAME "\\\\.\\pipe\\H-Uru_NetLog"
static CRITICAL_SECTION s_pipeCritical; static CRITICAL_SECTION s_pipeCritical;
static HANDLE s_netlog = 0; static HANDLE s_netlog = 0;
static ULARGE_INTEGER s_timeOffset; static ULARGE_INTEGER s_timeOffset;
static unsigned GetAdjustedTimer() static unsigned GetAdjustedTimer()
{ {
FILETIME time; FILETIME time;
ULARGE_INTEGER maths; ULARGE_INTEGER maths;
GetSystemTimeAsFileTime(&time); GetSystemTimeAsFileTime(&time);
maths.HighPart = time.dwHighDateTime; maths.HighPart = time.dwHighDateTime;
maths.LowPart = time.dwLowDateTime; maths.LowPart = time.dwLowDateTime;
maths.QuadPart -= s_timeOffset.QuadPart; maths.QuadPart -= s_timeOffset.QuadPart;
return maths.LowPart % 864000000; return maths.LowPart % 864000000;
} }
#endif // PLASMA_EXTERNAL_RELEASE
namespace pnNetCli { namespace pnNetCli {
@ -153,6 +157,7 @@ static void PutBufferOnWire (NetCli * cli, void * data, unsigned bytes) {
byte * temp, * heap = NULL; byte * temp, * heap = NULL;
#ifndef PLASMA_EXTERNAL_RELEASE
// Write to the netlog // Write to the netlog
if (s_netlog) { if (s_netlog) {
NetLogMessage_Header header; NetLogMessage_Header header;
@ -167,6 +172,7 @@ static void PutBufferOnWire (NetCli * cli, void * data, unsigned bytes) {
WriteFile(s_netlog, data, bytes, &bytesWritten, NULL); WriteFile(s_netlog, data, bytes, &bytesWritten, NULL);
LeaveCriticalSection(&s_pipeCritical); LeaveCriticalSection(&s_pipeCritical);
} }
#endif // PLASMA_EXTERNAL_RELEASE
if (cli->mode == kNetCliModeEncrypted) { if (cli->mode == kNetCliModeEncrypted) {
// Encrypt data... // Encrypt data...
@ -862,6 +868,7 @@ static NetCli * ConnCreate (
cli->mode = mode; cli->mode = mode;
cli->SetValue(kNilGuid); cli->SetValue(kNilGuid);
#ifndef PLASMA_EXTERNAL_RELEASE
// Network debug pipe // Network debug pipe
if (!s_netlog) { if (!s_netlog) {
InitializeCriticalSection(&s_pipeCritical); InitializeCriticalSection(&s_pipeCritical);
@ -882,6 +889,7 @@ static NetCli * ConnCreate (
s_timeOffset.HighPart = timeBase.dwHighDateTime; s_timeOffset.HighPart = timeBase.dwHighDateTime;
s_timeOffset.LowPart = timeBase.dwLowDateTime; s_timeOffset.LowPart = timeBase.dwLowDateTime;
} }
#endif // PLASMA_EXTERNAL_RELEASE
ResetSendRecv(cli); ResetSendRecv(cli);
@ -1070,6 +1078,7 @@ bool NetCliDispatch (
cli->input.Add(bytes, data); cli->input.Add(bytes, data);
bool result = DispatchData(cli, param); bool result = DispatchData(cli, param);
#ifndef PLASMA_EXTERNAL_RELEASE
// Write to the netlog // Write to the netlog
if (s_netlog) { if (s_netlog) {
NetLogMessage_Header header; NetLogMessage_Header header;
@ -1077,13 +1086,14 @@ bool NetCliDispatch (
header.m_direction = 1; // kSrv2Cli header.m_direction = 1; // kSrv2Cli
header.m_time = GetAdjustedTimer(); header.m_time = GetAdjustedTimer();
header.m_size = bytes; header.m_size = bytes;
EnterCriticalSection(&s_pipeCritical); EnterCriticalSection(&s_pipeCritical);
DWORD bytesWritten; DWORD bytesWritten;
WriteFile(s_netlog, &header, sizeof(header), &bytesWritten, NULL); WriteFile(s_netlog, &header, sizeof(header), &bytesWritten, NULL);
WriteFile(s_netlog, data, bytes, &bytesWritten, NULL); WriteFile(s_netlog, data, bytes, &bytesWritten, NULL);
LeaveCriticalSection(&s_pipeCritical); LeaveCriticalSection(&s_pipeCritical);
} }
#endif // PLASMA_EXTERNAL_RELEASE
#ifdef SERVER #ifdef SERVER
cli->recvDispatch = result; cli->recvDispatch = result;

Loading…
Cancel
Save