forked from ValveSoftware/source-sdk-2013
-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathgame_crash.cpp
More file actions
62 lines (48 loc) · 1.3 KB
/
game_crash.cpp
File metadata and controls
62 lines (48 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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 <windows.h>
#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
}
}