[+] Introduced crash dump writing for win32
[-] Fixed crash if engine is tried to play unloaded sound
This commit is contained in:
parent
ce26c1da78
commit
46f7162c2f
3 changed files with 40 additions and 4 deletions
|
@ -822,7 +822,7 @@ endif()
|
|||
if(WIN32)
|
||||
add_definitions(-DUSE_WIN32)
|
||||
set(stratagus_SRCS ${stratagus_SRCS} ${win32_SRCS})
|
||||
set(stratagus_LIBS ${stratagus_LIBS} dsound winmm ws2_32)
|
||||
set(stratagus_LIBS ${stratagus_LIBS} dsound winmm ws2_32 dbghelp)
|
||||
endif()
|
||||
|
||||
if (WIN32 AND MSVC)
|
||||
|
|
|
@ -304,6 +304,9 @@ void PlayUnitSound(const CUnit &unit, UnitVoiceGroup voice)
|
|||
*/
|
||||
void PlayUnitSound(const CUnit &unit, CSound *sound)
|
||||
{
|
||||
if (!sound) {
|
||||
return;
|
||||
}
|
||||
Origin source = {&unit, unsigned(UnitNumber(unit))};
|
||||
unsigned char volume = CalculateVolume(false, ViewPointDistanceToUnit(unit), sound->Range);
|
||||
if (volume == 0) {
|
||||
|
@ -326,6 +329,9 @@ void PlayUnitSound(const CUnit &unit, CSound *sound)
|
|||
*/
|
||||
void PlayMissileSound(const Missile &missile, CSound *sound)
|
||||
{
|
||||
if (!sound) {
|
||||
return;
|
||||
}
|
||||
int stereo = ((missile.position.x + (missile.Type->G ? missile.Type->G->Width / 2 : 0) +
|
||||
UI.SelectedViewport->MapPos.x * PixelTileSize.x) * 256 /
|
||||
((UI.SelectedViewport->MapWidth - 1) * PixelTileSize.x)) - 128;
|
||||
|
@ -353,6 +359,9 @@ void PlayMissileSound(const Missile &missile, CSound *sound)
|
|||
*/
|
||||
void PlayGameSound(CSound *sound, unsigned char volume, bool always)
|
||||
{
|
||||
if (!sound) {
|
||||
return;
|
||||
}
|
||||
Origin source = {NULL, 0};
|
||||
|
||||
CSample *sample = ChooseSample(sound, false, source);
|
||||
|
|
|
@ -217,6 +217,10 @@ extern void beos_init(int argc, char **argv);
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef USE_WIN32
|
||||
#include <windows.h>
|
||||
#include <dbghelp.h>
|
||||
#endif
|
||||
|
||||
#if defined(USE_WIN32) && ! defined(NO_STDIO_REDIRECT)
|
||||
#include "windows.h"
|
||||
|
@ -431,6 +435,9 @@ void Exit(int err)
|
|||
*/
|
||||
void ExitFatal(int err)
|
||||
{
|
||||
#ifdef USE_STACKTRACE
|
||||
throw stacktrace::stack_runtime_error((const char*)err);
|
||||
#endif
|
||||
exit(err);
|
||||
}
|
||||
|
||||
|
@ -654,6 +661,24 @@ void ParseCommandLine(int argc, char **argv, Parameters ¶meters)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_WIN32
|
||||
static LONG WINAPI CreateDumpFile(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
{
|
||||
HANDLE hFile = CreateFile("crash.dmp", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
MINIDUMP_EXCEPTION_INFORMATION mei;
|
||||
mei.ThreadId = GetCurrentThreadId();
|
||||
mei.ClientPointers = TRUE;
|
||||
mei.ExceptionPointers = ExceptionInfo;
|
||||
MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &mei, NULL, NULL);
|
||||
fprintf(stderr, "Stratagus crashed!\n");
|
||||
fprintf(stderr, "A mini dump file \"crash.dmp\" has been created in the Stratagus folder.\n");
|
||||
fprintf(stderr, "Please send it to our bug tracker: https://bugs.launchpad.net/stratagus\n");
|
||||
fprintf(stderr, "and tell us what have you done to cause this bug.\n");
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** The main program: initialise, parse options and arguments.
|
||||
**
|
||||
|
@ -669,7 +694,9 @@ int stratagusMain(int argc, char **argv)
|
|||
// Parse arguments for BeOS
|
||||
beos_init(argc, argv);
|
||||
#endif
|
||||
|
||||
#ifdef USE_WIN32
|
||||
SetUnhandledExceptionFilter(CreateDumpFile);
|
||||
#endif
|
||||
// Setup some defaults.
|
||||
#ifndef MAC_BUNDLE
|
||||
StratagusLibPath = ".";
|
||||
|
@ -750,10 +777,10 @@ int stratagusMain(int argc, char **argv)
|
|||
} catch (const std::exception &e) {
|
||||
fprintf(stderr, "Stratagus crashed!\n");
|
||||
fprintf(stderr, "Please send this call stack to our bug tracker: https://bugs.launchpad.net/stratagus\n");
|
||||
fprintf(stderr, "and what have you done to cause this bug.\n");
|
||||
fprintf(stderr, "and tell us what have you done to cause this bug.\n");
|
||||
fprintf(stderr, " === exception state traceback === \n");
|
||||
fprintf(stderr, "%s", e.what());
|
||||
ExitFatal(1);
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue