Skip to content

Commit f97c9d9

Browse files
committed
Improve dbg code to work Assertion properly
1 parent 806f565 commit f97c9d9

File tree

17 files changed

+1077
-517
lines changed

17 files changed

+1077
-517
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.bat
33
*.log
44
*.lnk
5+
*.aps
56
**/msvc/Debug*
67
**/msvc/Release*
78
**/msvc/Tests

regamedll/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ set(SHARED_SRCS
161161
"public/FileSystem.cpp"
162162
"public/interface.cpp"
163163
"public/MemPool.cpp"
164+
"public/MemPool.cpp"
165+
"public/tier0/dbg.cpp"
166+
"public/tier0/platform_posix.cpp"
164167
)
165168

166169
set(GAMEDLL_SRCS

regamedll/dlls/client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
673673
CBaseEntity *pTarget = nullptr;
674674
pPlayer->m_pIntroCamera = UTIL_FindEntityByClassname(nullptr, "trigger_camera");
675675

676-
#ifndef REGAMEDLL_FIXES
676+
#ifndef REGAMEDLL_FIXES
677677
if (g_pGameRules && g_pGameRules->IsMultiplayer())
678678
{
679679
CSGameRules()->m_bMapHasCameras = (pPlayer->m_pIntroCamera != nullptr);
@@ -696,8 +696,8 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
696696
pPlayer->pev->angles = CamAngles;
697697
pPlayer->pev->v_angle = pPlayer->pev->angles;
698698

699-
pPlayer->m_fIntroCamTime =
700-
#ifdef REGAMEDLL_FIXES
699+
pPlayer->m_fIntroCamTime =
700+
#ifdef REGAMEDLL_FIXES
701701
(CSGameRules()->m_bMapHasCameras <= 1) ? 0.0 : // no need to refresh cameras if map has only one
702702
#endif
703703
gpGlobals->time + 6;

regamedll/dlls/game.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,13 @@ void GameDLL_SwapTeams_f()
228228

229229
#endif // REGAMEDLL_ADD
230230

231+
SpewRetval_t GameDLL_SpewHandler(SpewType_t spewType, int level, const char *pMsg);
232+
231233
void EXT_FUNC GameDLLInit()
232234
{
235+
// By default, direct dbg reporting...
236+
SpewOutputFunc(GameDLL_SpewHandler);
237+
233238
g_pskill = CVAR_GET_POINTER("skill");
234239
g_psv_gravity = CVAR_GET_POINTER("sv_gravity");
235240
g_psv_aim = CVAR_GET_POINTER("sv_aim");
@@ -455,3 +460,28 @@ void EXT_FUNC GameDLLInit()
455460
#endif
456461

457462
}
463+
464+
SpewRetval_t GameDLL_SpewHandler(SpewType_t spewType, int level, const char *pMsg)
465+
{
466+
bool bSpewPrint = (CVAR_GET_FLOAT("developer") >= level);
467+
switch (spewType)
468+
{
469+
case SPEW_LOG:
470+
case SPEW_MESSAGE:
471+
if (bSpewPrint) UTIL_ServerPrint("%s", pMsg);
472+
break;
473+
case SPEW_WARNING:
474+
if (bSpewPrint) UTIL_ServerPrint("Warning: %s", pMsg);
475+
break;
476+
case SPEW_ERROR:
477+
Sys_Error("%s", pMsg);
478+
return SPEW_ABORT; // fatal error, terminate it!
479+
case SPEW_ASSERT:
480+
UTIL_ServerPrint("Assert: %s", pMsg);
481+
return SPEW_DEBUGGER; // assert always tries to debugger break
482+
default:
483+
break;
484+
}
485+
486+
return SPEW_CONTINUE; // spew handled, continue on
487+
}

regamedll/dlls/h_export.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,7 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global
1616
Regamedll_Game_Init();
1717
}
1818

19-
#ifdef _WIN32
20-
21-
// DLL entry point
22-
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
23-
{
24-
if (fdwReason == DLL_PROCESS_ATTACH)
25-
{
26-
}
27-
else if (fdwReason == DLL_PROCESS_DETACH)
28-
{
29-
}
30-
31-
return TRUE;
32-
}
33-
34-
#else // _WIN32
19+
#if defined(_LINUX)
3520

3621
void __attribute__((constructor)) DllMainLoad()
3722
{
@@ -41,4 +26,4 @@ void __attribute__((destructor)) DllMainUnload()
4126
{
4227
}
4328

44-
#endif // _WIN32
29+
#endif // _LINUX

regamedll/dlls/util.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ void UTIL_RestartOther(const char *szClassname)
14971497
while ((pEntity = UTIL_FindEntityByClassname(pEntity, szClassname)))
14981498
{
14991499
pEntity->Restart();
1500-
1500+
15011501
#ifdef REGAMEDLL_ADD
15021502
FireTargets("game_entity_restart", pEntity, nullptr, USE_TOGGLE, 0.0);
15031503
#endif
@@ -1731,7 +1731,7 @@ bool UTIL_AreHostagesImprov()
17311731
#ifdef REGAMEDLL_ADD
17321732
if (g_engfuncs.pfnEngCheckParm == nullptr)
17331733
return false;
1734-
1734+
17351735
// someday in CS 1.6
17361736
int improv = ENG_CHECK_PARM("-host-improv", nullptr);
17371737
if (improv)
@@ -1819,10 +1819,11 @@ void NORETURN Sys_Error(const char *error, ...)
18191819

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

1822-
//TerminateProcess(GetCurrentProcess(), 1);
1823-
int *null = 0;
1824-
*null = 0;
1825-
exit(-1);
1822+
#if defined(_WIN32)
1823+
MessageBoxA(NULL, text, "Fatal error", MB_ICONERROR | MB_OK);
1824+
#endif
1825+
1826+
exit(EXIT_FAILURE);
18261827
}
18271828

18281829
int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter)

regamedll/engine/unicode_strtools.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,8 @@ int Q_UnicodeConvertT(const SrcType *pIn, int nInChars, DstType *pOut, int nOutB
756756

757757
if (bErr)
758758
{
759-
#ifdef _DEBUG
760-
AssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");
761-
#endif
759+
DbgAssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");
760+
762761
if (ePolicy & _STRINGCONVERTFLAG_SKIP)
763762
{
764763
nOut -= EncodeDstLen(uVal);
@@ -793,9 +792,8 @@ int Q_UnicodeConvertT(const SrcType *pIn, int nInChars, DstType *pOut, int nOutB
793792
nOut += EncodeDst(uVal, pOut + nOut);
794793
if (bErr)
795794
{
796-
#ifdef _DEBUG
797-
AssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");
798-
#endif
795+
DbgAssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence");
796+
799797
if (ePolicy & _STRINGCONVERTFLAG_SKIP)
800798
{
801799
nOut -= EncodeDstLen(uVal);

regamedll/msvc/ReGameDLL.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@
540540
<ClCompile Include="..\public\FileSystem.cpp" />
541541
<ClCompile Include="..\public\interface.cpp" />
542542
<ClCompile Include="..\public\MemPool.cpp" />
543+
<ClCompile Include="..\public\tier0\assert_dialog.cpp" />
543544
<ClCompile Include="..\public\tier0\dbg.cpp">
544545
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
545546
</ExcludedFromBuild>
@@ -548,6 +549,7 @@
548549
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
549550
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">true</ExcludedFromBuild>
550551
</ClCompile>
552+
<ClCompile Include="..\public\tier0\platform_win32.cpp" />
551553
<ClCompile Include="..\public\utlsymbol.cpp">
552554
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
553555
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">true</ExcludedFromBuild>
@@ -787,6 +789,7 @@
787789
<ClInclude Include="..\public\regamedll\regamedll_api.h" />
788790
<ClInclude Include="..\public\tier0\dbg.h" />
789791
<ClInclude Include="..\public\tier0\platform.h" />
792+
<ClInclude Include="..\public\tier0\resource.h" />
790793
<ClInclude Include="..\public\utlarray.h" />
791794
<ClInclude Include="..\public\utlmemory.h" />
792795
<ClInclude Include="..\public\utlrbtree.h" />
@@ -810,6 +813,9 @@
810813
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
811814
</ProjectReference>
812815
</ItemGroup>
816+
<ItemGroup>
817+
<ResourceCompile Include="..\public\tier0\assert_dialog.rc" />
818+
</ItemGroup>
813819
<PropertyGroup Label="Globals">
814820
<ProjectGuid>{70A2B904-B7DB-4C48-8DE0-AF567360D572}</ProjectGuid>
815821
<RootNamespace>ReGameDLL</RootNamespace>

regamedll/msvc/ReGameDLL.vcxproj.filters

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,12 @@
555555
<ClCompile Include="..\public\FileSystem.cpp">
556556
<Filter>public</Filter>
557557
</ClCompile>
558+
<ClCompile Include="..\public\tier0\platform_win32.cpp">
559+
<Filter>public\tier0</Filter>
560+
</ClCompile>
561+
<ClCompile Include="..\public\tier0\assert_dialog.cpp">
562+
<Filter>public\tier0</Filter>
563+
</ClCompile>
558564
</ItemGroup>
559565
<ItemGroup>
560566
<ClInclude Include="..\version\version.h">
@@ -1055,5 +1061,13 @@
10551061
<ClInclude Include="..\public\utlarray.h">
10561062
<Filter>public</Filter>
10571063
</ClInclude>
1064+
<ClInclude Include="..\public\tier0\resource.h">
1065+
<Filter>public\tier0</Filter>
1066+
</ClInclude>
1067+
</ItemGroup>
1068+
<ItemGroup>
1069+
<ResourceCompile Include="..\public\tier0\assert_dialog.rc">
1070+
<Filter>public\tier0</Filter>
1071+
</ResourceCompile>
10581072
</ItemGroup>
10591073
</Project>

0 commit comments

Comments
 (0)