Skip to content

Commit

Permalink
Improve dbg code to work Assertion properly
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Dec 13, 2023
1 parent 806f565 commit f97c9d9
Show file tree
Hide file tree
Showing 17 changed files with 1,077 additions and 517 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.bat
*.log
*.lnk
*.aps
**/msvc/Debug*
**/msvc/Release*
**/msvc/Tests
Expand Down
3 changes: 3 additions & 0 deletions regamedll/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ set(SHARED_SRCS
"public/FileSystem.cpp"
"public/interface.cpp"
"public/MemPool.cpp"
"public/MemPool.cpp"
"public/tier0/dbg.cpp"
"public/tier0/platform_posix.cpp"
)

set(GAMEDLL_SRCS
Expand Down
6 changes: 3 additions & 3 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
CBaseEntity *pTarget = nullptr;
pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(nullptr, "trigger_camera");

#ifndef REGAMEDLL_FIXES
#ifndef REGAMEDLL_FIXES
if (g_pGameRules && g_pGameRules->IsMultiplayer())
{
CSGameRules()->m_bMapHasCameras = (pPlayer->m_pIntroCamera != nullptr);
Expand All @@ -696,8 +696,8 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
pPlayer->pev->angles = CamAngles;
pPlayer->pev->v_angle = pPlayer->pev->angles;

pPlayer->m_fIntroCamTime =
#ifdef REGAMEDLL_FIXES
pPlayer->m_fIntroCamTime =
#ifdef REGAMEDLL_FIXES
(CSGameRules()->m_bMapHasCameras <= 1) ? 0.0 : // no need to refresh cameras if map has only one
#endif
gpGlobals->time + 6;
Expand Down
30 changes: 30 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,13 @@ void GameDLL_SwapTeams_f()

#endif // REGAMEDLL_ADD

SpewRetval_t GameDLL_SpewHandler(SpewType_t spewType, int level, const char *pMsg);

void EXT_FUNC GameDLLInit()
{
// By default, direct dbg reporting...
SpewOutputFunc(GameDLL_SpewHandler);

g_pskill = CVAR_GET_POINTER("skill");
g_psv_gravity = CVAR_GET_POINTER("sv_gravity");
g_psv_aim = CVAR_GET_POINTER("sv_aim");
Expand Down Expand Up @@ -455,3 +460,28 @@ void EXT_FUNC GameDLLInit()
#endif

}

SpewRetval_t GameDLL_SpewHandler(SpewType_t spewType, int level, const char *pMsg)
{
bool bSpewPrint = (CVAR_GET_FLOAT("developer") >= level);
switch (spewType)
{
case SPEW_LOG:
case SPEW_MESSAGE:
if (bSpewPrint) UTIL_ServerPrint("%s", pMsg);
break;
case SPEW_WARNING:
if (bSpewPrint) UTIL_ServerPrint("Warning: %s", pMsg);
break;
case SPEW_ERROR:
Sys_Error("%s", pMsg);
return SPEW_ABORT; // fatal error, terminate it!
case SPEW_ASSERT:
UTIL_ServerPrint("Assert: %s", pMsg);
return SPEW_DEBUGGER; // assert always tries to debugger break
default:
break;
}

return SPEW_CONTINUE; // spew handled, continue on
}
19 changes: 2 additions & 17 deletions regamedll/dlls/h_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,7 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global
Regamedll_Game_Init();
}

#ifdef _WIN32

// DLL entry point
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
}

return TRUE;
}

#else // _WIN32
#if defined(_LINUX)

void __attribute__((constructor)) DllMainLoad()
{
Expand All @@ -41,4 +26,4 @@ void __attribute__((destructor)) DllMainUnload()
{
}

#endif // _WIN32
#endif // _LINUX
13 changes: 7 additions & 6 deletions regamedll/dlls/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ void UTIL_RestartOther(const char *szClassname)
while ((pEntity = UTIL_FindEntityByClassname(pEntity, szClassname)))
{
pEntity->Restart();

#ifdef REGAMEDLL_ADD
FireTargets("game_entity_restart", pEntity, nullptr, USE_TOGGLE, 0.0);
#endif
Expand Down Expand Up @@ -1731,7 +1731,7 @@ bool UTIL_AreHostagesImprov()
#ifdef REGAMEDLL_ADD
if (g_engfuncs.pfnEngCheckParm == nullptr)
return false;

// someday in CS 1.6
int improv = ENG_CHECK_PARM("-host-improv", nullptr);
if (improv)
Expand Down Expand Up @@ -1819,10 +1819,11 @@ void NORETURN Sys_Error(const char *error, ...)

CONSOLE_ECHO("FATAL ERROR (shutting down): %s\n", text);

//TerminateProcess(GetCurrentProcess(), 1);
int *null = 0;
*null = 0;
exit(-1);
#if defined(_WIN32)
MessageBoxA(NULL, text, "Fatal error", MB_ICONERROR | MB_OK);
#endif

exit(EXIT_FAILURE);
}

int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter)
Expand Down
10 changes: 4 additions & 6 deletions regamedll/engine/unicode_strtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,9 +756,8 @@ int Q_UnicodeConvertT(const SrcType *pIn, int nInChars, DstType *pOut, int nOutB

if (bErr)
{
#ifdef _DEBUG
AssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");
#endif
DbgAssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");

if (ePolicy & _STRINGCONVERTFLAG_SKIP)
{
nOut -= EncodeDstLen(uVal);
Expand Down Expand Up @@ -793,9 +792,8 @@ int Q_UnicodeConvertT(const SrcType *pIn, int nInChars, DstType *pOut, int nOutB
nOut += EncodeDst(uVal, pOut + nOut);
if (bErr)
{
#ifdef _DEBUG
AssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");
#endif
DbgAssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");

if (ePolicy & _STRINGCONVERTFLAG_SKIP)
{
nOut -= EncodeDstLen(uVal);
Expand Down
6 changes: 6 additions & 0 deletions regamedll/msvc/ReGameDLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@
<ClCompile Include="..\public\FileSystem.cpp" />
<ClCompile Include="..\public\interface.cpp" />
<ClCompile Include="..\public\MemPool.cpp" />
<ClCompile Include="..\public\tier0\assert_dialog.cpp" />
<ClCompile Include="..\public\tier0\dbg.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</ExcludedFromBuild>
Expand All @@ -548,6 +549,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\public\tier0\platform_win32.cpp" />
<ClCompile Include="..\public\utlsymbol.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">true</ExcludedFromBuild>
Expand Down Expand Up @@ -787,6 +789,7 @@
<ClInclude Include="..\public\regamedll\regamedll_api.h" />
<ClInclude Include="..\public\tier0\dbg.h" />
<ClInclude Include="..\public\tier0\platform.h" />
<ClInclude Include="..\public\tier0\resource.h" />
<ClInclude Include="..\public\utlarray.h" />
<ClInclude Include="..\public\utlmemory.h" />
<ClInclude Include="..\public\utlrbtree.h" />
Expand All @@ -810,6 +813,9 @@
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\public\tier0\assert_dialog.rc" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{70A2B904-B7DB-4C48-8DE0-AF567360D572}</ProjectGuid>
<RootNamespace>ReGameDLL</RootNamespace>
Expand Down
14 changes: 14 additions & 0 deletions regamedll/msvc/ReGameDLL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,12 @@
<ClCompile Include="..\public\FileSystem.cpp">
<Filter>public</Filter>
</ClCompile>
<ClCompile Include="..\public\tier0\platform_win32.cpp">
<Filter>public\tier0</Filter>
</ClCompile>
<ClCompile Include="..\public\tier0\assert_dialog.cpp">
<Filter>public\tier0</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\version\version.h">
Expand Down Expand Up @@ -1055,5 +1061,13 @@
<ClInclude Include="..\public\utlarray.h">
<Filter>public</Filter>
</ClInclude>
<ClInclude Include="..\public\tier0\resource.h">
<Filter>public\tier0</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\public\tier0\assert_dialog.rc">
<Filter>public\tier0</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
Loading

0 comments on commit f97c9d9

Please sign in to comment.