Skip to content

Commit

Permalink
#25 readd breakpad support and verify it builds if enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtew committed Aug 22, 2024
1 parent c77baf5 commit 4c8eb19
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 24 deletions.
4 changes: 2 additions & 2 deletions build/Incursion.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions build/Incursion.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand Down
8 changes: 4 additions & 4 deletions build/exe_curses.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand Down
20 changes: 10 additions & 10 deletions build/exe_libtcod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
Expand Down Expand Up @@ -192,15 +192,15 @@ $(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
<SDLCheck>true</SDLCheck>
<PrecompiledHeaderOutputFile>$(IntDir)$(SolutionName).pch</PrecompiledHeaderOutputFile>
<ProgramDataBaseFileName>$(IntDir)$(SolutionName).pdb</ProgramDataBaseFileName>
<PreprocessorDefinitions>_UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\inc;..\dependencies\libtcod-1.7.0-x86-msvc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>USE_BREAKPAD_OFF;_UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\inc;..\dependencies\breakpad;..\dependencies\libtcod-1.7.0-x86-msvc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalDependencies>libtcod.lib</AdditionalDependencies>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>..\dependencies\libtcod-1.7.0-x86-msvc;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\dependencies\breakpad\$(Platform)\$(Configuration);..\dependencies\libtcod-1.7.0-x86-msvc;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>
Expand All @@ -219,16 +219,16 @@ $(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
<SDLCheck>true</SDLCheck>
<PrecompiledHeaderOutputFile>$(IntDir)$(SolutionName).pch</PrecompiledHeaderOutputFile>
<ProgramDataBaseFileName>$(IntDir)$(SolutionName).pdb</ProgramDataBaseFileName>
<PreprocessorDefinitions>_UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\inc;..\dependencies\libtcod-1.7.0-x86_64-msvc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>USE_BREAKPAD_OFF;_UNICODE;LIBTCOD_TERM;TCOD_SDL2;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\inc;..\dependencies\breakpad;..\dependencies\libtcod-1.7.0-x86_64-msvc\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<AdditionalDependencies>libtcod.lib</AdditionalDependencies>
<OptimizeReferences>true</OptimizeReferences>
<TargetMachine>MachineX64</TargetMachine>
<AdditionalLibraryDirectories>..\dependencies\libtcod-1.7.0-x86_64-msvc;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>..\dependencies\breakpad\$(Platform)\$(Configuration);..\dependencies\libtcod-1.7.0-x86_64-msvc;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<CustomBuildStep>
<Command>
Expand Down
8 changes: 4 additions & 4 deletions build/modaccent.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,27 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
53 changes: 53 additions & 0 deletions src/Wlibtcod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -326,6 +340,10 @@ static int16 kbPolish[][3] = {
Term *T1;
libtcodTerm *AT1;

#ifdef USE_BREAKPAD
ExceptionHandler* crashdumpHandler;
#endif

/*****************************************************************************\
* libtcodTerm *
* main() Function *
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 4c8eb19

Please sign in to comment.