From 3f29a2a6d79b4d958d18e730564104f6dd794815 Mon Sep 17 00:00:00 2001 From: Wikot235 <149392035+Wikot235@users.noreply.github.com> Date: Fri, 3 Apr 2026 19:36:33 +0200 Subject: [PATCH 1/2] Added the game_crash entity --- sp/src/game/server/game_crash.cpp | 56 +++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 sp/src/game/server/game_crash.cpp diff --git a/sp/src/game/server/game_crash.cpp b/sp/src/game/server/game_crash.cpp new file mode 100644 index 00000000000..8f1ba86ed82 --- /dev/null +++ b/sp/src/game/server/game_crash.cpp @@ -0,0 +1,56 @@ +#include "cbase.h" +#ifdef _WIN32 +#include +#endif + +class CGameCrash : public CBaseEntity +{ + DECLARE_CLASS( CGameCrash, CBaseEntity ); + DECLARE_DATADESC(); + +private: + void InputCrash( inputdata_t &inputdata ); + +#ifdef _WIN32 + char* m_szTitle; +#endif + char* m_szMessage; + int m_nType; + //0 - crash without a window + //1 - engine error crash + //2 - message box crash +}; + + +LINK_ENTITY_TO_CLASS( game_crash, CGameCrash ); + +BEGIN_DATADESC( CGameCrash ) + + DEFINE_INPUTFUNC( FIELD_VOID, "Crash", InputCrash ), + + DEFINE_KEYFIELD( m_szTitle, FIELD_STRING, "title" ), + DEFINE_KEYFIELD( m_szMessage, FIELD_STRING, "message" ), + DEFINE_KEYFIELD( m_nType, FIELD_INTEGER, "type" ), + +END_DATADESC() + + +void CGameCrash::InputCrash( inputdata_t& inputdata ) +{ + switch ( m_nType ) + { + case 0: + engine->ClientCommand( UTIL_GetLocalPlayer()->edict(), "exit" ); + + case 1: + Error( "%s", m_szMessage ); + + case 2: +#ifdef _WIN32 + engine->ClientCommand( UTIL_GetLocalPlayer()->edict(), "exit" ); + MessageBoxA( NULL, m_szMessage, m_szTitle, MB_OK ); +#else + Error( "%s", m_szMessage ); +#endif + } +} From 7632aae09db5bfc62e8defd608864ea4164eea25 Mon Sep 17 00:00:00 2001 From: Wikot235 <149392035+Wikot235@users.noreply.github.com> Date: Fri, 3 Apr 2026 19:41:31 +0200 Subject: [PATCH 2/2] Added a header --- sp/src/game/server/game_crash.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sp/src/game/server/game_crash.cpp b/sp/src/game/server/game_crash.cpp index 8f1ba86ed82..76bf8cfc84c 100644 --- a/sp/src/game/server/game_crash.cpp +++ b/sp/src/game/server/game_crash.cpp @@ -1,3 +1,9 @@ +//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============// +// +// Purpose: Allows mappers to crash the game and display a message +// +//=============================================================================// + #include "cbase.h" #ifdef _WIN32 #include