- added game statistics gathering and saving on masterserver.

see Table glestserver now has the field: gameUUID
Table glestgamestats has game header stats
Table glestgameplayerstats has game player stats
This commit is contained in:
Mark Vejvoda
2013-10-31 00:57:36 +00:00
parent c0150e752f
commit 7ad30f92bf
48 changed files with 9641 additions and 9188 deletions

View File

@@ -234,12 +234,12 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d] AFTER glewInit call err = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,err);
if (GLEW_OK != err) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
//return 1;
throw std::runtime_error((char *)glewGetErrorString(err));
if (GLEW_OK != err) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
fprintf(stderr, "Error [main]: glewInit failed: %s\n", glewGetErrorString(err));
//return 1;
throw std::runtime_error((char *)glewGetErrorString(err));
}
//fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
@@ -262,7 +262,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
}
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_WM_GrabInput(SDL_GRAB_OFF);
}
}

View File

@@ -34,94 +34,94 @@ string PlatformExceptionHandler::application_binary="";
bool PlatformExceptionHandler::disableBacktrace = false;
PlatformExceptionHandler *PlatformExceptionHandler::thisPointer= NULL;
// Constructs object and convert lpaszString to Unicode
LPWSTR Ansi2WideString(LPCSTR lpaszString) {
LPWSTR lpwszString(NULL);
if(lpaszString != NULL) {
int nLen = ::lstrlenA(lpaszString) + 1;
lpwszString = new WCHAR[nLen];
if (lpwszString == NULL) {
return lpwszString;
}
memset(lpwszString, 0, nLen * sizeof(WCHAR));
if (::MultiByteToWideChar(CP_ACP, 0, lpaszString, nLen, lpwszString, nLen) == 0) {
// Conversation failed
return lpwszString;
}
}
else {
int nLen = 1;
lpwszString = new WCHAR[nLen];
if (lpwszString == NULL) {
return lpwszString;
}
memset(lpwszString, 0, nLen * sizeof(WCHAR));
}
return lpwszString;
// Constructs object and convert lpaszString to Unicode
LPWSTR Ansi2WideString(LPCSTR lpaszString) {
LPWSTR lpwszString(NULL);
if(lpaszString != NULL) {
int nLen = ::lstrlenA(lpaszString) + 1;
lpwszString = new WCHAR[nLen];
if (lpwszString == NULL) {
return lpwszString;
}
memset(lpwszString, 0, nLen * sizeof(WCHAR));
if (::MultiByteToWideChar(CP_ACP, 0, lpaszString, nLen, lpwszString, nLen) == 0) {
// Conversation failed
return lpwszString;
}
}
else {
int nLen = 1;
lpwszString = new WCHAR[nLen];
if (lpwszString == NULL) {
return lpwszString;
}
memset(lpwszString, 0, nLen * sizeof(WCHAR));
}
return lpwszString;
}
// Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring &wstr) {
if(wstr.length() == 0) {
std::string wstrTo;
return wstrTo;
}
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo( size_needed, 0 );
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
replaceAll(strTo, "/", "\\");
replaceAll(strTo, "\\\\", "\\");
updatePathClimbingParts(strTo);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
std::wstring utf8_decode(const std::string &str) {
if(str.length() == 0) {
std::wstring wstrTo;
return wstrTo;
}
string friendly_path = str;
replaceAll(friendly_path, "/", "\\");
replaceAll(friendly_path, "\\\\", "\\");
updatePathClimbingParts(friendly_path);
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &friendly_path[0], (int)friendly_path.size(), NULL, 0);
std::wstring wstrTo( size_needed, 0 );
MultiByteToWideChar(CP_UTF8, 0, &friendly_path[0], (int)friendly_path.size(), &wstrTo[0], size_needed);
return wstrTo;
}
// Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring &wstr) {
if(wstr.length() == 0) {
std::string wstrTo;
return wstrTo;
}
/**
* @param location The location of the registry key. For example "Software\\Bethesda Softworks\\Morrowind"
* @param name the name of the registry key, for example "Installed Path"
* @return the value of the key or an empty string if an error occured.
*/
std::string getRegKey(const std::string& location, const std::string& name){
HKEY key;
CHAR value[1024];
DWORD bufLen = 1024*sizeof(CHAR);
long ret;
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, location.c_str(), 0, KEY_QUERY_VALUE, &key);
if( ret != ERROR_SUCCESS ){
return std::string();
}
ret = RegQueryValueExA(key, name.c_str(), 0, 0, (LPBYTE) value, &bufLen);
RegCloseKey(key);
if ( (ret != ERROR_SUCCESS) || (bufLen > 1024*sizeof(TCHAR)) ){
return std::string();
}
string stringValue = value;
size_t i = stringValue.length();
while( i > 0 && stringValue[i-1] == '\0' ){
--i;
}
return stringValue.substr(0,i);
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo( size_needed, 0 );
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
replaceAll(strTo, "/", "\\");
replaceAll(strTo, "\\\\", "\\");
updatePathClimbingParts(strTo);
return strTo;
}
// Convert an UTF8 string to a wide Unicode String
std::wstring utf8_decode(const std::string &str) {
if(str.length() == 0) {
std::wstring wstrTo;
return wstrTo;
}
string friendly_path = str;
replaceAll(friendly_path, "/", "\\");
replaceAll(friendly_path, "\\\\", "\\");
updatePathClimbingParts(friendly_path);
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &friendly_path[0], (int)friendly_path.size(), NULL, 0);
std::wstring wstrTo( size_needed, 0 );
MultiByteToWideChar(CP_UTF8, 0, &friendly_path[0], (int)friendly_path.size(), &wstrTo[0], size_needed);
return wstrTo;
}
/**
* @param location The location of the registry key. For example "Software\\Bethesda Softworks\\Morrowind"
* @param name the name of the registry key, for example "Installed Path"
* @return the value of the key or an empty string if an error occured.
*/
std::string getRegKey(const std::string& location, const std::string& name){
HKEY key;
CHAR value[1024];
DWORD bufLen = 1024*sizeof(CHAR);
long ret;
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, location.c_str(), 0, KEY_QUERY_VALUE, &key);
if( ret != ERROR_SUCCESS ){
return std::string();
}
ret = RegQueryValueExA(key, name.c_str(), 0, 0, (LPBYTE) value, &bufLen);
RegCloseKey(key);
if ( (ret != ERROR_SUCCESS) || (bufLen > 1024*sizeof(TCHAR)) ){
return std::string();
}
string stringValue = value;
size_t i = stringValue.length();
while( i > 0 && stringValue[i-1] == '\0' ){
--i;
}
return stringValue.substr(0,i);
}
LONG WINAPI PlatformExceptionHandler::handler(LPEXCEPTION_POINTERS pointers){
@@ -175,76 +175,76 @@ void PlatformExceptionHandler::install(string dumpFileName){
}
string PlatformExceptionHandler::getStackTrace() {
string result = "\nStack Trace:\n";
string result = "\nStack Trace:\n";
if(PlatformExceptionHandler::disableBacktrace == true) {
result += "disabled...";
return result;
}
#ifndef __MINGW32__
CONTEXT context = { 0 };
context.ContextFlags = CONTEXT_FULL;
IMAGEHLP_SYMBOL *pSym = (IMAGEHLP_SYMBOL*)new BYTE[sizeof(IMAGEHLP_SYMBOL) + 256];
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
pSym->MaxNameLength = 256;
IMAGEHLP_LINE line = { 0 };
line.SizeOfStruct = sizeof(IMAGEHLP_LINE);
IMAGEHLP_MODULE module = { 0 };
module.SizeOfStruct = sizeof(IMAGEHLP_MODULE);
HANDLE hProcess = GetCurrentProcess();
HANDLE hThread = GetCurrentThread();
if (GetThreadContext(hThread, &context)) {
STACKFRAME stackframe = { 0 };
stackframe.AddrPC.Offset = context.Eip;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.Ebp;
stackframe.AddrFrame.Mode = AddrModeFlat;
SymInitialize(hProcess, NULL, TRUE);
BOOL fSuccess = TRUE;
do
{
fSuccess = StackWalk(IMAGE_FILE_MACHINE_I386,
GetCurrentProcess(),
GetCurrentThread(),
&stackframe,
&context,
NULL,
NULL,
NULL,
NULL);
DWORD dwDisplacement = 0;
SymGetSymFromAddr(hProcess, stackframe.AddrPC.Offset, &dwDisplacement, pSym);
SymGetLineFromAddr(hProcess, stackframe.AddrPC.Offset, &dwDisplacement, &line);
SymGetModuleInfo(hProcess, stackframe.AddrPC.Offset, &module);
// RetAddr Arg1 Arg2 Arg3 module!funtion FileName(line)+offset
char szBuf[8096]="";
snprintf(szBuf,8096,"%08lx %08lx %08lx %08lx %s!%s %s(%lu) %+ld\n",
stackframe.AddrReturn.Offset,
stackframe.Params[0],
stackframe.Params[1],
stackframe.Params[2],
pSym->Name,
module.ModuleName,
line.FileName,
line.LineNumber,
dwDisplacement);
result += szBuf;
} while (fSuccess);
SymCleanup(hProcess);
}
#ifndef __MINGW32__
CONTEXT context = { 0 };
context.ContextFlags = CONTEXT_FULL;
IMAGEHLP_SYMBOL *pSym = (IMAGEHLP_SYMBOL*)new BYTE[sizeof(IMAGEHLP_SYMBOL) + 256];
pSym->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL);
pSym->MaxNameLength = 256;
IMAGEHLP_LINE line = { 0 };
line.SizeOfStruct = sizeof(IMAGEHLP_LINE);
IMAGEHLP_MODULE module = { 0 };
module.SizeOfStruct = sizeof(IMAGEHLP_MODULE);
HANDLE hProcess = GetCurrentProcess();
HANDLE hThread = GetCurrentThread();
if (GetThreadContext(hThread, &context)) {
STACKFRAME stackframe = { 0 };
stackframe.AddrPC.Offset = context.Eip;
stackframe.AddrPC.Mode = AddrModeFlat;
stackframe.AddrFrame.Offset = context.Ebp;
stackframe.AddrFrame.Mode = AddrModeFlat;
SymInitialize(hProcess, NULL, TRUE);
BOOL fSuccess = TRUE;
do
{
fSuccess = StackWalk(IMAGE_FILE_MACHINE_I386,
GetCurrentProcess(),
GetCurrentThread(),
&stackframe,
&context,
NULL,
NULL,
NULL,
NULL);
DWORD dwDisplacement = 0;
SymGetSymFromAddr(hProcess, stackframe.AddrPC.Offset, &dwDisplacement, pSym);
SymGetLineFromAddr(hProcess, stackframe.AddrPC.Offset, &dwDisplacement, &line);
SymGetModuleInfo(hProcess, stackframe.AddrPC.Offset, &module);
// RetAddr Arg1 Arg2 Arg3 module!funtion FileName(line)+offset
char szBuf[8096]="";
snprintf(szBuf,8096,"%08lx %08lx %08lx %08lx %s!%s %s(%lu) %+ld\n",
stackframe.AddrReturn.Offset,
stackframe.Params[0],
stackframe.Params[1],
stackframe.Params[2],
pSym->Name,
module.ModuleName,
line.FileName,
line.LineNumber,
dwDisplacement);
result += szBuf;
} while (fSuccess);
SymCleanup(hProcess);
}
#endif
return result;
#endif
return result;
}
megaglest_runtime_error::megaglest_runtime_error(const string& __arg,bool noStackTrace)