added Sys_IsDebuggerAttached and Q_assert

This commit is contained in:
myT 2022-11-04 04:46:04 +01:00
parent 6dbf731973
commit 9f90a6ee8b
4 changed files with 22 additions and 2 deletions

View file

@ -751,3 +751,9 @@ sysEvent_t Sys_GetEvent()
void Sys_DebugPrintf( const char*, ... )
{
}
qbool Sys_IsDebuggerAttached()
{
return qfalse;
}

View file

@ -274,9 +274,9 @@ void QDECL Com_ErrorExt( int code, int module, qbool realError, const char *fmt,
vsprintf( com_errorMessage, fmt, argptr );
va_end( argptr );
#if defined(_WIN32) && defined(_DEBUG)
#if defined(_MSC_VER) && defined(_DEBUG)
if ( code != ERR_DISCONNECT && code != ERR_NEED_CD ) {
if ( realError && (!com_noErrorInterrupt || !com_noErrorInterrupt->integer) && IsDebuggerPresent() )
if ( realError && (!com_noErrorInterrupt || !com_noErrorInterrupt->integer) && Sys_IsDebuggerAttached() )
__debugbreak();
}
#endif

View file

@ -1154,6 +1154,7 @@ int64_t Sys_Microseconds();
// prints text in the debugger's output window
void Sys_DebugPrintf( const char* fmt, ... );
qbool Sys_IsDebuggerAttached();
#ifndef DEDICATED
qbool Sys_IsMinimized();
@ -1198,4 +1199,11 @@ typedef enum {
printHelpResult_t Com_PrintHelp( const char* name, printf_t print, qbool printNotFound, qbool printModules, qbool printFlags );
#if defined(_MSC_VER) && defined(_DEBUG)
#define Q_assert(Cond) do { if(!(Cond)) { if(Sys_IsDebuggerAttached()) __debugbreak(); else assert((Cond)); } } while(0)
#else
#define Q_assert(Cond)
#endif
#endif // _QCOMMON_H_

View file

@ -143,3 +143,9 @@ void Sys_DebugPrintf( const char* fmt, ... )
OutputDebugStringA(buffer);
}
qbool Sys_IsDebuggerAttached()
{
return IsDebuggerPresent();
}