inline Vector2 operator/(const Vector2& v, const float scalar) { if (scalar == 0.f) { SystemDialogue_Okay("Divide by Zero", "Attempted to divide a Vector2 by zero", SEVERITY_FATAL); return Vector2(0.f, 0.f); } else return Vector2(v.x / scalar, v.y / scalar); }
//----------------------------------------------------------------------------------------------- __declspec( noreturn ) void FatalError( const char* filePath, const char* functionName, int lineNum, const std::string& reasonForError, const char* conditionText ) { std::string errorMessage = reasonForError; if( reasonForError.empty() ) { if( conditionText ) errorMessage = Stringf( "ERROR: \"%s\" is false!", conditionText ); else errorMessage = "Unspecified fatal error"; } const char* fileName = FindStartOfFileNameWithinFilePath( filePath ); // std::string appName = theApplication ? theApplication->GetApplicationName() : "Unnamed Application"; std::string appName = "Unnamed Application"; std::string fullMessageTitle = appName + " :: Error"; std::string fullMessageText = errorMessage; fullMessageText += "\n\nThe application will now close.\n"; bool isDebuggerPresent = (IsDebuggerPresent() == TRUE); if( isDebuggerPresent ) { fullMessageText += "\nDEBUGGER DETECTED!\nWould you like to break and debug?\n (Yes=debug, No=quit)\n"; } fullMessageText += "\n---------- Debugging Details Follow ----------\n"; if( conditionText ) { fullMessageText += Stringf( "\nThis error was triggered by a run-time condition check:\n %s\n from %s(), line %i in %s\n", conditionText, functionName, lineNum, fileName ); } else { fullMessageText += Stringf( "\nThis was an unconditional error triggered by reaching\n line %i of %s, in %s()\n", lineNum, fileName, functionName ); } DebuggerPrintf( "\n==============================================================================\n" ); DebuggerPrintf( "RUN-TIME FATAL ERROR on line %i of %s, in %s()\n", lineNum, fileName, functionName ); DebuggerPrintf( "%s(%d): %s\n", filePath, lineNum, errorMessage.c_str() ); // Use this specific format so Visual Studio users can double-click to jump to file-and-line of error DebuggerPrintf( "==============================================================================\n\n" ); if( isDebuggerPresent ) { bool isAnswerYes = SystemDialogue_YesNo( fullMessageTitle, fullMessageText, SEVERITY_FATAL ); ShowCursor( TRUE ); if( isAnswerYes ) { __debugbreak(); } } else { SystemDialogue_Okay( fullMessageTitle, fullMessageText, SEVERITY_FATAL ); ShowCursor( TRUE ); } exit( 0 ); }