Let's not crash the client and server on dbg_assert

This commit is contained in:
def 2017-06-02 20:12:20 +02:00
parent 27074e926a
commit a6e144ea72
4 changed files with 16 additions and 11 deletions

View file

@ -97,11 +97,11 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg)
if(!test)
{
dbg_msg("assert", "%s(%d): %s", filename, line, msg);
dbg_break();
dbg_break_imp();
}
}
void dbg_break()
void dbg_break_imp()
{
*((volatile unsigned*)0) = 0x0;
}

View file

@ -26,13 +26,16 @@ extern "C" {
msg - Message that should be printed if the test fails.
Remarks:
Does nothing in release version of the library.
Does nothing in release version
See Also:
<dbg_break>
*/
void dbg_assert(int test, const char *msg);
#ifdef CONF_DEBUG
#define dbg_assert(test,msg) dbg_assert_imp(__FILE__, __LINE__, test, msg)
#else
#define dbg_assert(test,msg)
#endif
void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
@ -47,12 +50,17 @@ void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
Breaks into the debugger.
Remarks:
Does nothing in release version of the library.
Does nothing in release version
See Also:
<dbg_assert>
*/
void dbg_break();
#ifdef CONF_DEBUG
#define dbg_break() dbg_break_imp()
#else
#define dbg_break()
#endif
void dbg_break_imp();
/*
Function: dbg_msg
@ -64,7 +72,7 @@ void dbg_break();
fmt - A printf styled format string.
Remarks:
Does nothing in release version of the library.
Also works in release version
See Also:
<dbg_assert>

View file

@ -66,8 +66,7 @@ static int GetID(int Index)
void CUuidManager::RegisterName(int ID, const char *pName)
{
int Index = GetIndex(ID);
dbg_assert(Index == m_aNames.size(), "names must be registered with increasing ID");
dbg_assert(GetIndex(ID) == m_aNames.size(), "names must be registered with increasing ID");
CName Name;
Name.m_pName = pName;
Name.m_Uuid = CalculateUuid(pName);

View file

@ -3032,8 +3032,6 @@ void CGameContext::ResetTuning()
bool CheckClientID2(int ClientID)
{
dbg_assert(ClientID >= 0 || ClientID < MAX_CLIENTS,
"The Client ID is wrong");
if (ClientID < 0 || ClientID >= MAX_CLIENTS)
return false;
return true;