Skip to content

Commit

Permalink
Made debugger utility functions available also in non-debug builds
Browse files Browse the repository at this point in the history
  • Loading branch information
cbnolok committed Jul 30, 2024
1 parent 1b9e7cd commit 7c815bf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
22 changes: 13 additions & 9 deletions src/common/CException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "../game/CServer.h"
#include "../game/CWorld.h"

#ifdef _DEBUG
#include <fcntl.h>
int IsDebuggerPresent(void)
{
Expand All @@ -35,12 +34,10 @@ int IsDebuggerPresent(void)

return debugger_present;
}
#endif // _DEBUG

#endif // !_WIN32


#ifdef _DEBUG
void NotifyDebugger()
{
if (IsDebuggerPresent())
Expand All @@ -58,7 +55,6 @@ void NotifyDebugger()

}
}
#endif // _DEBUG


#ifdef _WIN32
Expand Down Expand Up @@ -342,12 +338,20 @@ void _cdecl Signal_Children(int sig = 0)
#ifndef _WIN32
void SetUnixSignals( bool fSet ) // Signal handlers are installed only in secure mode
{
#if defined(_SANITIZERS)
# define __SANS true

#ifdef _SANITIZERS
const bool fSan = true;
#else
# define __SANS false
const bool fSan = false;
#endif
if (!IsDebuggerPresent() || !__SANS)

#ifdef _DEBUG
const bool fDebugger = IsDebuggerPresent();
#else
const bool fDebugger = false;
#endif

if (!fDebugger && !fSan)
{
signal( SIGHUP, fSet ? &Signal_Hangup : SIG_DFL );
signal( SIGTERM, fSet ? &Signal_Terminate : SIG_DFL );
Expand All @@ -361,6 +365,6 @@ void SetUnixSignals( bool fSet ) // Signal handlers are installed only in sec

signal( SIGPIPE, fSet ? SIG_IGN : SIG_DFL );
signal( SIGCHLD, fSet ? &Signal_Children : SIG_DFL );
#undef __SANS

}
#endif
8 changes: 2 additions & 6 deletions src/common/CException.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@ void SetExceptionTranslator();

#ifndef _WIN32
void SetUnixSignals( bool );
#ifdef _DEBUG
int IsDebuggerPresent(); // Windows already has this function
#endif
int IsDebuggerPresent(); // Windows already has this function
#endif

#ifdef _DEBUG
void NotifyDebugger();
#endif
void NotifyDebugger();

// -------------------------------------------------------------------
// -------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/game/CObjBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void CObjBase::DeletePrepare()

const SERVMODE_TYPE servMode = g_Serv.GetServerMode();
const bool fDestroyingWorld = (servMode != SERVMODE_Exiting && servMode != SERVMODE_Loading);
if (fDestroyingWorld)
if (!fDestroyingWorld)
{
RemoveFromView();
}
Expand Down

0 comments on commit 7c815bf

Please sign in to comment.