Tiny bit more saftey.
This commit is contained in:
parent
e727f3baf3
commit
c8acdedf50
@ -31,6 +31,8 @@
|
|||||||
#elif defined _WINDOWS
|
#elif defined _WINDOWS
|
||||||
#define _STDINT // ~.~
|
#define _STDINT // ~.~
|
||||||
#include "client/windows/handler/exception_handler.h"
|
#include "client/windows/handler/exception_handler.h"
|
||||||
|
#else
|
||||||
|
#error Bad platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Accelerator g_accelerator;
|
Accelerator g_accelerator;
|
||||||
@ -134,6 +136,8 @@ static bool dumpCallback(const wchar_t* dump_path,
|
|||||||
printf("Wrote minidump to: %ls\\%ls.dmp\n", dump_path, minidump_id);
|
printf("Wrote minidump to: %ls\\%ls.dmp\n", dump_path, minidump_id);
|
||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#error Bad platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void UploadCrashDump(const char *path)
|
void UploadCrashDump(const char *path)
|
||||||
@ -141,6 +145,7 @@ void UploadCrashDump(const char *path)
|
|||||||
IWebForm *form = webternet->CreateForm();
|
IWebForm *form = webternet->CreateForm();
|
||||||
|
|
||||||
form->AddString("UserID", g_pSM->GetCoreConfigValue("MinidumpAccount"));
|
form->AddString("UserID", g_pSM->GetCoreConfigValue("MinidumpAccount"));
|
||||||
|
form->AddString("GameDir", g_pSM->GetGameFolderName());
|
||||||
|
|
||||||
form->AddFile("upload_file_minidump", path);
|
form->AddFile("upload_file_minidump", path);
|
||||||
|
|
||||||
@ -164,6 +169,7 @@ void Accelerator::OnCoreMapStart(edict_t *pEdictList, int edictCount, int client
|
|||||||
IDirectory *dumps = libsys->OpenDirectory(buffer);
|
IDirectory *dumps = libsys->OpenDirectory(buffer);
|
||||||
|
|
||||||
char path[512];
|
char path[512];
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
while (dumps->MoreFiles())
|
while (dumps->MoreFiles())
|
||||||
{
|
{
|
||||||
@ -176,16 +182,27 @@ void Accelerator::OnCoreMapStart(edict_t *pEdictList, int edictCount, int client
|
|||||||
g_pSM->Format(path, sizeof(path), "%s/%s", buffer, dumps->GetEntryName());
|
g_pSM->Format(path, sizeof(path), "%s/%s", buffer, dumps->GetEntryName());
|
||||||
UploadCrashDump(path);
|
UploadCrashDump(path);
|
||||||
|
|
||||||
|
int err = 0;
|
||||||
#if defined _LINUX
|
#if defined _LINUX
|
||||||
unlink(path);
|
err = unlink(path);
|
||||||
#elif defined _WINDOWS
|
#elif defined _WINDOWS
|
||||||
_unlink(path);
|
err = _unlink(path);
|
||||||
|
#else
|
||||||
|
#error Bad platform.
|
||||||
#endif
|
#endif
|
||||||
|
if (err != 0) {
|
||||||
|
printf(">>> FAILED TO DELETE CRASH DUMP!!!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
dumps->NextEntry();
|
dumps->NextEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
libsys->CloseDirectory(dumps);
|
libsys->CloseDirectory(dumps);
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
printf(">>> UPLOADED %d CRASH DUMPS\n", count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Accelerator::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
bool Accelerator::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||||
@ -223,10 +240,10 @@ bool Accelerator::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
|||||||
AddVectoredExceptionHandler(0, BreakpadVectoredHandler);
|
AddVectoredExceptionHandler(0, BreakpadVectoredHandler);
|
||||||
|
|
||||||
delete buf;
|
delete buf;
|
||||||
|
#else
|
||||||
|
#error Bad platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,6 +253,8 @@ void Accelerator::SDK_OnUnload()
|
|||||||
g_pSM->RemoveGameFrameHook(OnGameFrame);
|
g_pSM->RemoveGameFrameHook(OnGameFrame);
|
||||||
#elif defined _WINDOWS
|
#elif defined _WINDOWS
|
||||||
RemoveVectoredExceptionHandler(BreakpadVectoredHandler);
|
RemoveVectoredExceptionHandler(BreakpadVectoredHandler);
|
||||||
|
#else
|
||||||
|
#error Bad platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete handler;
|
delete handler;
|
||||||
|
Loading…
Reference in New Issue
Block a user