diff --git a/sp/src/game/server/game_crash.cpp b/sp/src/game/server/game_crash.cpp new file mode 100644 index 00000000000..76bf8cfc84c --- /dev/null +++ b/sp/src/game/server/game_crash.cpp @@ -0,0 +1,62 @@ +//========= 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 +#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 + } +}