Skip to content

Commit

Permalink
fixed: Assert() now prints file and line number + generate_project work
Browse files Browse the repository at this point in the history
  • Loading branch information
phrounz committed Aug 24, 2016
1 parent ab3ccdf commit c0ca469
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
4 changes: 2 additions & 2 deletions common/Windows/App_VS2013_DX_Desktop.vcxproj.src
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;$(SolutionDir)\..\lua\lua-5.2.3_Win64_vc12_lib\lua52.lib;pthreadVC2.lib;libxml2.lib;zlib.lib;libiconv.lib;WSock32.Lib;XInput.lib;D3DCompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\VisualStudioOtherLibs\lib;c:\progs\GnuWin32\lib;D:\progs\OpenAL 1.1 SDK\libs\Win32;d:\Desktop\Steam SDK - Asteroids Minesweeper\Steam SDK - Asteroids Minesweeper\sdk\redistributable_bin\win64;d:\Desktop\Steam SDK - Asteroids Minesweeper\Steam SDK - Asteroids Minesweeper\sdk\public\steam\lib\win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\common\dependancy_libraries\lib;c:\progs\GnuWin32\lib;D:\progs\OpenAL 1.1 SDK\libs\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<FxCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\..</AdditionalIncludeDirectories>
Expand Down Expand Up @@ -184,7 +184,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>d2d1.lib;d3d11.lib;dxgi.lib;ole32.lib;windowscodecs.lib;dwrite.lib;xaudio2.lib;mfcore.lib;mfplat.lib;mfreadwrite.lib;$(SolutionDir)\..\lua\lua-5.2.3_Win64_vc12_lib\lua52.lib;pthreadVC2.lib;libxml2.lib;zlib.lib;libiconv.lib;WSock32.Lib;XInput.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\VisualStudioOtherLibs\lib;c:\progs\GnuWin32\lib;D:\progs\OpenAL 1.1 SDK\libs\Win32;d:\Desktop\Steam SDK - Asteroids Minesweeper\Steam SDK - Asteroids Minesweeper\sdk\redistributable_bin\win64;d:\Desktop\Steam SDK - Asteroids Minesweeper\Steam SDK - Asteroids Minesweeper\sdk\public\steam\lib\win64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)\..\..\common\dependancy_libraries\lib;c:\progs\GnuWin32\lib;D:\progs\OpenAL 1.1 SDK\libs\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<FxCompile>
<AdditionalIncludeDirectories>$(SolutionDir)\..</AdditionalIncludeDirectories>
Expand Down
2 changes: 1 addition & 1 deletion generate_project.pm
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ sub processVisualStudioProjectFile_($$$$$$$)
push @l_additional_include_dirs_32, "$steam_sdk_path_or_empty\\sdk\\public";
push @l_additional_include_dirs_64, "$steam_sdk_path_or_empty\\sdk\\public\\steam\\lib\\win64";
push @l_additional_lib_dirs_32, "$steam_sdk_path_or_empty\\sdk\\redistributable_bin";
push @l_additional_lib_dirs_64, "$steam_sdk_path_or_empty\\sdk\\redistributable_bin";
push @l_additional_lib_dirs_64, "$steam_sdk_path_or_empty\\sdk\\redistributable_bin\\win64";
push @l_additional_lib_dirs_32, "$steam_sdk_path_or_empty\\sdk\\public\\steam\\lib\\win32";
push @l_additional_lib_dirs_64, "$steam_sdk_path_or_empty\\sdk\\public\\steam\\lib\\win64";
#push @l_additional_libs_32, "sdkencryptedappticket.lib";# already in Steam.cpp
Expand Down
3 changes: 2 additions & 1 deletion include/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ namespace Utils
#ifdef USES_WINDOWS8_METRO
#define Assert( a ) Utils::assertion(__LINE__, __FILE__, ( a ) )
#else
#define Assert Utils::assertion
//#define Assert Utils::assertion
#define Assert( a ) Utils::assertion(__LINE__, __FILE__, ( a ) )
#endif
#define AssertMessage( a , b ) {if ( ! (a) ) {Utils::dieErrorMessageToUser( b );}}
#endif
Expand Down
37 changes: 35 additions & 2 deletions source/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ void dieErrorMessageToUser(const std::string& message)
{
Utils::print("ERROR: ");
Utils::print(message.c_str());
Utils::print(s_errorMessageEndUser.c_str());
Utils::print("\n");
if (THROW_ERROR) throw EngineError(message);
#if !defined(USES_LINUX) && !defined(USES_JS_EMSCRIPTEN) && !defined(USES_WINDOWS8_METRO)
Expand All @@ -143,7 +144,39 @@ void dieErrorMessageToUser(const std::string& message)
std::string str = "ERROR (call stack infos missing)";
#endif
outputln(str.c_str());
MessageBox(NULL, Utils::convertStringToWString(message).c_str(), L"Fatal error", MB_OK|MB_ICONEXCLAMATION);
MessageBox(NULL, Utils::convertStringToWString(message).c_str(), L"Fatal error - please provide this information to the developers", MB_OK|MB_ICONEXCLAMATION);
#endif

/*#ifndef USES_WINDOWS8_METRO
system("PAUSE");
#endif*/
#ifdef USES_JS_EMSCRIPTEN
emscripten_force_exit(1);
#endif

exit(1);
}

//-------------------------------------------------------------------------

void dieBothErrorMessagesToUser(const std::string& message)
{
Utils::print("ERROR: ");
Utils::print(message.c_str());
Utils::print(s_errorMessageEndUser.c_str());
Utils::print("\n");
if (THROW_ERROR) throw EngineError(message);
#if !defined(USES_LINUX) && !defined(USES_JS_EMSCRIPTEN) && !defined(USES_WINDOWS8_METRO)
#ifdef ENABLE_CALLSTACK
MyStackWalker sw;
sw.ShowCallstack();
std::string str = sw.getStr();
#else
std::string str = "ERROR (call stack infos missing)";
#endif
outputln(str.c_str());
std::wstring mess = Utils::convertStringToWString(message) + L"\n\n" + s_errorMessageEndUser;
MessageBox(NULL, mess.c_str(), L"Fatal error - please provide this information to the developers", MB_OK|MB_ICONEXCLAMATION);
#endif

/*#ifndef USES_WINDOWS8_METRO
Expand Down Expand Up @@ -523,7 +556,7 @@ void assertion(int line, const char* filename, bool condition)
{
std::stringstream sstr;
sstr << "Assertion failed at line " << line << " of file " << filename;
Utils::dieErrorMessageToUser(sstr.str());
Utils::dieBothErrorMessagesToUser(sstr.str());
}
}

Expand Down

0 comments on commit c0ca469

Please sign in to comment.