Merge 273cb928bf6a5a6d37c45c9dcc461076680949a8 into 9ea71dd94f7fb2f6f36214abb5ece55626459b35

This commit is contained in:
Arthur Ice 2013-05-11 00:20:19 -07:00
commit 9e8d39fe2c
20 changed files with 87 additions and 141 deletions

View File

@ -38,9 +38,6 @@ using namespace std;
#include <windows.h> #include <windows.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else

View File

@ -24,9 +24,6 @@
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp

View File

@ -1,16 +1,14 @@
#include "debug.h" #include "debug.h"
#include <iostream> #include <iostream>
using namespace std; #include <string>
#include <time.h> #include <time.h>
#include <string.h>
#ifdef _WINDOWS #ifdef _WINDOWS
#include <process.h> #include <process.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else
@ -73,6 +71,7 @@ EQEMuLog::~EQEMuLog() {
} }
bool EQEMuLog::open(LogIDs id) { bool EQEMuLog::open(LogIDs id) {
if (!logFileValid) { if (!logFileValid) {
return false; return false;
} }
@ -88,36 +87,39 @@ bool EQEMuLog::open(LogIDs id) {
return true; return true;
} }
char exename[200] = ""; std::string filename = FileNames[id];
const EQEmuExePlatform &platform = GetExecutablePlatform(); const EQEmuExePlatform &platform = GetExecutablePlatform();
if(platform == ExePlatformWorld) { if(platform == ExePlatformWorld) {
snprintf(exename, sizeof(exename), "_world"); filename.append("_world");
} else if(platform == ExePlatformZone) { } else if(platform == ExePlatformZone) {
snprintf(exename, sizeof(exename), "_zone"); filename.append("_zone");
} else if(platform == ExePlatformLaunch) { } else if(platform == ExePlatformLaunch) {
snprintf(exename, sizeof(exename), "_launch"); filename.append("_launch");
} else if(platform == ExePlatformUCS) { } else if(platform == ExePlatformUCS) {
snprintf(exename, sizeof(exename), "_ucs"); filename.append("_ucs");
} else if(platform == ExePlatformQueryServ) { } else if(platform == ExePlatformQueryServ) {
snprintf(exename, sizeof(exename), "_queryserv"); filename.append("_queryserv");
} else if(platform == ExePlatformSharedMemory) { } else if(platform == ExePlatformSharedMemory) {
snprintf(exename, sizeof(exename), "_shared_memory"); filename.append("_shared_memory");
} }
char filename[200];
#ifndef NO_PIDLOG #ifndef NO_PIDLOG
snprintf(filename, sizeof(filename), "%s%s_%04i.log", FileNames[id], exename, getpid()); // According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx
#else // Visual Studio 2010 doesn't have std::to_string(int) but it does have one for
snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename); // long long. Oh well, it works fine and formats perfectly acceptably.
filename.append(std::to_string((long long)getpid()));
#endif #endif
fp[id] = fopen(filename, "a"); filename.append(".log");
fp[id] = fopen(filename.c_str(), "a");
if (!fp[id]) { if (!fp[id]) {
cerr << "Failed to open log file: " << filename << endl; std::cerr << "Failed to open log file: " << filename << std::endl;
pLogStatus[id] |= 4; // set file state to error pLogStatus[id] |= 4; // set file state to error
return false; return false;
} }
fputs("---------------------------------------------\n",fp[id]); fputs("---------------------------------------------\n",fp[id]);
write(id, "Starting Log: %s", filename); write(id, "Starting Log: %s", filename.c_str());
return true; return true;
} }
@ -326,6 +328,7 @@ bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
}; };
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) { bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
if (!logFileValid) { if (!logFileValid) {
#if EQDEBUG >= 10 #if EQDEBUG >= 10
cerr << "Error: Dump() from null pointer"<<endl; cerr << "Error: Dump() from null pointer"<<endl;
@ -350,36 +353,45 @@ bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 ski
write(id, "Dumping Packet: %i", size); write(id, "Dumping Packet: %i", size);
// Output as HEX // Output as HEX
int j = 0; char* ascii = new char[cols+1]; memset(ascii, 0, cols+1);
uint32 i; int beginningOfLineOffset = 0;
for(i=skip; i<size; i++) { uint32 indexInData;
if ((i-skip)%cols==0) { std::string asciiOutput;
if (i != skip)
writeNTS(id, dofile, " | %s\n", ascii); for(indexInData=skip; indexInData<size; indexInData++) {
writeNTS(id, dofile, "%4i: ", i-skip); if ((indexInData-skip)%cols==0) {
memset(ascii, 0, cols+1); if (indexInData != skip)
j = 0; writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
writeNTS(id, dofile, "%4i: ", indexInData-skip);
asciiOutput.clear();
beginningOfLineOffset = 0;
} }
else if ((i-skip)%(cols/2) == 0) { else if ((indexInData-skip)%(cols/2) == 0) {
writeNTS(id, dofile, "- "); writeNTS(id, dofile, "- ");
} }
writeNTS(id, dofile, "%02X ", (unsigned char)data[i]); writeNTS(id, dofile, "%02X ", (unsigned char)data[indexInData]);
if (data[i] >= 32 && data[i] < 127) if (data[indexInData] >= 32 && data[indexInData] < 127)
ascii[j++] = data[i]; {
// According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx
// Visual Studio 2010 doesn't have std::to_string(int) but it does have the long long
// version.
asciiOutput.append(std::to_string((long long)data[indexInData]));
}
else else
ascii[j++] = '.'; {
asciiOutput.append(".");
}
} }
uint32 k = ((i-skip)-1)%cols; uint32 k = ((indexInData-skip)-1)%cols;
if (k < 8) if (k < 8)
writeNTS(id, dofile, " "); writeNTS(id, dofile, " ");
for (uint32 h = k+1; h < cols; h++) { for (uint32 h = k+1; h < cols; h++) {
writeNTS(id, dofile, " "); writeNTS(id, dofile, " ");
} }
writeNTS(id, dofile, " | %s\n", ascii); writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
if (dofile) if (dofile)
fflush(fp[id]); fflush(fp[id]);
safe_delete_array(ascii);
return true; return true;
} }
@ -436,6 +448,3 @@ void EQEMuLog::SetAllCallbacks(msgCallbackPva proc) {
SetCallback((LogIDs)r, proc); SetCallback((LogIDs)r, proc);
} }
} }

View File

@ -1,5 +1,5 @@
/* EQEMu: Everquest Server Emulator /* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org) Copyright (C) 2001-2013 EQEMu Development Team (http://eqemu.org)
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -45,22 +45,9 @@
#ifndef _CRTDBG_MAP_ALLOC #ifndef _CRTDBG_MAP_ALLOC
#include <stdlib.h> #include <stdlib.h>
#include <crtdbg.h> #include <crtdbg.h>
#if (_MSC_VER < 1300)
#include <new>
#include <memory>
#define _CRTDBG_MAP_ALLOC
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#endif #endif
#endif #endif
#ifdef _WINDOWS
// VS6 doesn't like the length of STL generated names: disabling
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#endif
#ifndef EQDEBUG_H #ifndef EQDEBUG_H
#define EQDEBUG_H #define EQDEBUG_H
@ -82,6 +69,7 @@
#include "logsys.h" #include "logsys.h"
#include "common_profile.h" #include "common_profile.h"
#ifdef ZONE #ifdef ZONE
#include "../zone/zone_profile.h" #include "../zone/zone_profile.h"
#endif #endif
@ -160,5 +148,7 @@ public:
LARGE_INTEGER tmp; LARGE_INTEGER tmp;
int64* p; int64* p;
}; };
#endif #endif
#endif
#endif

View File

@ -29,9 +29,6 @@
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else

View File

@ -68,9 +68,6 @@ typedef const char Const_char; //for perl XS
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
typedef void ThreadReturnType; typedef void ThreadReturnType;
@ -80,8 +77,8 @@ typedef const char Const_char; //for perl XS
#define THREAD_RETURN(x) return(x); #define THREAD_RETURN(x) return(x);
#endif #endif
#define safe_delete(d) if(d) { delete d; d=0; } #define safe_delete(d) if(d) { delete d; d=nullptr; }
#define safe_delete_array(d) if(d) { delete[] d; d=0; } #define safe_delete_array(d) if(d) { delete[] d; d=nullptr; }
#define L32(i) ((uint32) i) #define L32(i) ((uint32) i)
#define H32(i) ((uint32) (i >> 32)) #define H32(i) ((uint32) (i >> 32))
#define L16(i) ((uint16) i) #define L16(i) ((uint16) i)

View File

@ -31,9 +31,6 @@ using namespace std;
#include <winsock.h> #include <winsock.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else // Pyro: fix for linux #else // Pyro: fix for linux

View File

@ -20,9 +20,6 @@ using namespace std;
#include <windows.h> #include <windows.h>
#include <winsock.h> #include <winsock.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else

View File

@ -49,9 +49,6 @@ using namespace std;
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#endif #endif

View File

@ -47,9 +47,6 @@ using namespace std;
#ifdef _WINDOWS #ifdef _WINDOWS
#include <process.h> #include <process.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#include <conio.h> #include <conio.h>

View File

@ -28,12 +28,9 @@ Child of the Mob class.
#include <sstream> #include <sstream>
using namespace std; using namespace std;
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500) #define strncasecmp _strnicmp
#define vsnprintf _vsnprintf #define strcasecmp _stricmp
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif #endif
#include "masterentity.h" #include "masterentity.h"

View File

@ -25,12 +25,9 @@ target to center around.
#include "../common/debug.h" #include "../common/debug.h"
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500) #define strncasecmp _strnicmp
#define vsnprintf _vsnprintf #define strcasecmp _stricmp
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif #endif
#include "masterentity.h" #include "masterentity.h"

View File

@ -28,19 +28,16 @@ using namespace std;
// for windows compile // for windows compile
#ifdef _WINDOWS #ifdef _WINDOWS
#define abs64 _abs64 #define abs64 _abs64
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500) #define strncasecmp _strnicmp
#define vsnprintf _vsnprintf #define strcasecmp _stricmp
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else #else
#include <stdarg.h> #include <stdarg.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
#include "../common/unix.h" #include "../common/unix.h"
#define abs64 abs #define abs64 abs
#endif #endif
extern volatile bool RunLoops; extern volatile bool RunLoops;

View File

@ -29,9 +29,6 @@
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else

View File

@ -32,9 +32,6 @@
#include <windows.h> #include <windows.h>
#include <winsock.h> #include <winsock.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#else #else

View File

@ -49,12 +49,9 @@ using namespace std;
#include "QuestParserCollection.h" #include "QuestParserCollection.h"
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500) #define strncasecmp _strnicmp
#define vsnprintf _vsnprintf #define strcasecmp _stricmp
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif #endif
extern Zone* zone; extern Zone* zone;

View File

@ -33,14 +33,12 @@ using namespace std;
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__) #define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif #endif
using namespace std; using namespace std;
#ifdef _WINDOWS #ifdef _WINDOWS
#include <conio.h> #include <conio.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500) #define strncasecmp _strnicmp
#define vsnprintf _vsnprintf #define strcasecmp _stricmp
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif #endif
volatile bool RunLoops = true; volatile bool RunLoops = true;

View File

@ -28,12 +28,9 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
#endif #endif
#ifdef _WINDOWS #ifdef _WINDOWS
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500) #define strncasecmp _strnicmp
#define vsnprintf _vsnprintf #define strcasecmp _stricmp
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#endif #endif
#include "../common/packet_functions.h" #include "../common/packet_functions.h"
#include "../common/packet_dump.h" #include "../common/packet_dump.h"

View File

@ -27,16 +27,13 @@
using namespace std; using namespace std;
#ifdef _WINDOWS #ifdef _WINDOWS
#include <windows.h> #include <windows.h>
#include <winsock.h> #include <winsock.h>
#include <process.h> #include <process.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500) #define strncasecmp _strnicmp
#define vsnprintf _vsnprintf #define strcasecmp _stricmp
#endif
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#else #else
#include <stdarg.h> #include <stdarg.h>
#include <sys/socket.h> #include <sys/socket.h>

View File

@ -29,9 +29,6 @@ using namespace std;
#include <process.h> #include <process.h>
#define snprintf _snprintf #define snprintf _snprintf
#if (_MSC_VER < 1500)
#define vsnprintf _vsnprintf
#endif
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#define strcasecmp _stricmp #define strcasecmp _stricmp
#endif #endif