diff --git a/build/Incursion.sln b/build/Incursion.sln
index cdf0d70..3246d56 100644
--- a/build/Incursion.sln
+++ b/build/Incursion.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.25420.1
+# Visual Studio Version 17
+VisualStudioVersion = 17.10.35122.118
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lib_incursion", "Incursion.vcxproj", "{9040FAAA-3DBF-41E9-BF70-4FACC525DC84}"
EndProject
diff --git a/build/Incursion.vcxproj b/build/Incursion.vcxproj
index 4dc224d..2f04714 100644
--- a/build/Incursion.vcxproj
+++ b/build/Incursion.vcxproj
@@ -28,23 +28,23 @@
Unicode
false
- v142
+ v143
StaticLibrary
Unicode
false
- v142
+ v143
StaticLibrary
Unicode
- v142
+ v143
StaticLibrary
Unicode
- v142
+ v143
StaticLibrary
diff --git a/build/exe_curses.vcxproj b/build/exe_curses.vcxproj
index 94e6cc3..8d96449 100644
--- a/build/exe_curses.vcxproj
+++ b/build/exe_curses.vcxproj
@@ -27,25 +27,25 @@
Application
true
- v142
+ v143
MultiByte
Application
true
- v142
+ v143
MultiByte
Application
false
- v142
+ v143
Unicode
Application
false
- v142
+ v143
Unicode
diff --git a/build/exe_libtcod.vcxproj b/build/exe_libtcod.vcxproj
index f06b8eb..e4529d6 100644
--- a/build/exe_libtcod.vcxproj
+++ b/build/exe_libtcod.vcxproj
@@ -27,26 +27,26 @@
Application
true
- v142
+ v143
Unicode
Application
true
- v142
+ v143
Unicode
Application
false
- v142
+ v143
true
Unicode
Application
false
- v142
+ v143
true
Unicode
@@ -192,15 +192,15 @@ $(LocalDebuggerEnvironment)
true
$(IntDir)$(SolutionName).pch
$(IntDir)$(SolutionName).pdb
- _UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)
- ..\inc;..\dependencies\libtcod-1.7.0-x86-msvc\include;%(AdditionalIncludeDirectories)
+ USE_BREAKPAD_OFF;_UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)
+ ..\inc;..\dependencies\breakpad;..\dependencies\libtcod-1.7.0-x86-msvc\include;%(AdditionalIncludeDirectories)
true
$(OutDir)$(TargetName)$(TargetExt)
libtcod.lib
true
- ..\dependencies\libtcod-1.7.0-x86-msvc;%(AdditionalLibraryDirectories)
+ ..\dependencies\breakpad\$(Platform)\$(Configuration);..\dependencies\libtcod-1.7.0-x86-msvc;%(AdditionalLibraryDirectories)
@@ -219,8 +219,8 @@ $(LocalDebuggerEnvironment)
true
$(IntDir)$(SolutionName).pch
$(IntDir)$(SolutionName).pdb
- _UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)
- ..\inc;..\dependencies\libtcod-1.7.0-x86_64-msvc\include;%(AdditionalIncludeDirectories)
+ USE_BREAKPAD_OFF;_UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)
+ ..\inc;..\dependencies\breakpad;..\dependencies\libtcod-1.7.0-x86_64-msvc\include;%(AdditionalIncludeDirectories)
true
@@ -228,7 +228,7 @@ $(LocalDebuggerEnvironment)
libtcod.lib
true
MachineX64
- ..\dependencies\libtcod-1.7.0-x86_64-msvc;%(AdditionalLibraryDirectories)
+ ..\dependencies\breakpad\$(Platform)\$(Configuration);..\dependencies\libtcod-1.7.0-x86_64-msvc;%(AdditionalLibraryDirectories)
diff --git a/build/modaccent.vcxproj b/build/modaccent.vcxproj
index 44a59c7..c02b5a9 100644
--- a/build/modaccent.vcxproj
+++ b/build/modaccent.vcxproj
@@ -53,27 +53,27 @@
Application
true
Unicode
- v142
+ v143
Application
true
Unicode
- v142
+ v143
Application
false
true
Unicode
- v142
+ v143
Application
false
true
Unicode
- v142
+ v143
diff --git a/src/Wlibtcod.cpp b/src/Wlibtcod.cpp
index 63e701f..35dd599 100644
--- a/src/Wlibtcod.cpp
+++ b/src/Wlibtcod.cpp
@@ -74,6 +74,17 @@
#undef EV_BREAK
#undef MOUSE_MOVED
+#ifdef USE_BREAKPAD
+#pragma comment(lib, "common")
+#pragma comment(lib, "exception_handler")
+#pragma comment(lib, "crash_generation_client")
+#include "client/windows/handler/exception_handler.h"
+#undef ERROR
+#undef MIN
+#undef MAX
+#undef EV_BREAK
+#endif
+
#include "Incursion.h"
#undef ERROR
#undef MIN
@@ -89,6 +100,9 @@
#define CURSOR_BLINK_MS 300
#define INPUT_IDLE_MS 50
+#ifdef USE_BREAKPAD
+using google_breakpad::ExceptionHandler;
+#endif
TCOD_color_t RGBValues[MAX_COLOURS] = {
{ 0, 0, 0 }, // BLACK
@@ -326,6 +340,10 @@ static int16 kbPolish[][3] = {
Term *T1;
libtcodTerm *AT1;
+#ifdef USE_BREAKPAD
+ExceptionHandler* crashdumpHandler;
+#endif
+
/*****************************************************************************\
* libtcodTerm *
* main() Function *
@@ -364,6 +382,18 @@ int main(int argc, char *argv[]) {
Error("Failed to locate Incursion directory under debugger (error 23)");
}
+#ifndef DEBUG
+#ifdef USE_BREAKPAD
+ std::wstring wsExecutablePath(strlen(executablePath), 0);
+ mbstowcs(&wsExecutablePath[0], executablePath, strlen(executablePath));
+ crashdumpHandler = new ExceptionHandler(wsExecutablePath,
+ NULL, /* &filter */
+ NULL /* &callback */,
+ NULL,
+ ExceptionHandler::HANDLER_ALL);
+#endif
+#endif
+
theGame = new Game();
AT1 = new libtcodTerm;
AT1->SetIncursionDirectory(executablePath);
@@ -765,12 +795,22 @@ void Error(const char*fmt,...) {
return;
}
+#ifdef USE_BREAKPAD
+retry:
+#endif
attempts += 1;
#ifdef DEBUG
sprintf(__buff2, "Error: %s\n[B]reak, [E]xit or [C]ontinue?",__buffer);
+#else
+#ifdef USE_BREAKPAD
+ if (attempts > 1)
+ sprintf(__buff2, "Error: %s\n[E]xit or [C]ontinue?", __buffer);
+ else
+ sprintf(__buff2, "Error: %s\n[M]inidump, [E]xit or [C]ontinue?", __buffer);
#else
sprintf(__buff2, "Error: %s\n[E]xit or [C]ontinue?", __buffer);
+#endif
#endif
((libtcodTerm*)T1)->Save();
((libtcodTerm*)T1)->Box(WIN_SCREEN,BOX_NOPAUSE|BOX_NOSAVE,RED,PINK,__buff2);
@@ -781,8 +821,21 @@ void Error(const char*fmt,...) {
} while (ch != 'C' && ch != 'E'
#ifdef DEBUG
&& ch != 'B'
+#else
+#ifdef USE_BREAKPAD
+ && ch != 'M'
+#endif
#endif
);
+#ifdef USE_BREAKPAD
+ if (ch == 'M') {
+ /* This causes problems for some people apparently. See Issue #215. */
+ crashdumpHandler->WriteMinidump();
+ ((libtcodTerm*)T1)->Restore();
+
+ goto retry;
+ }
+#endif
if (ch == 'E') {
T1->ShutDown();
exit(1);