1
1
// ===========================================================================//
2
2
//
3
3
// Authors: Orsell & Nanoman2525 & NULLderef
4
- // Purpose: WorkshopStopper9000 plugin
4
+ // Purpose: P2SourceModPlusPlus plugin
5
5
//
6
6
// ===========================================================================//
7
7
#include " main.hpp"
10
10
#include " tier0/memdbgon.h"
11
11
12
12
void Log (int level, bool dev, const char * pMsgFormat, ...);
13
- ConVar wss9000_developer ( " wss9000_developer " , " 0" , FCVAR_HIDDEN, " Enable for developer messages." );
13
+ ConVar p2sm_developer ( " p2sm_developer " , " 0" , FCVAR_HIDDEN, " Enable for developer messages." );
14
14
15
15
// ---------------------------------------------------------------------------------
16
16
// The plugin is a static singleton that is exported as an interface
17
17
// ---------------------------------------------------------------------------------
18
- CWSS9000Plugin g_WSS9000Plugin ;
19
- EXPOSE_SINGLE_INTERFACE_GLOBALVAR (CWSS9000Plugin , IServerPluginCallbacks, INTERFACEVERSION_ISERVERPLUGINCALLBACKS, g_WSS9000Plugin );
18
+ CP2SMPlusPlusPlugin g_P2SMPlusPlusPlugin ;
19
+ EXPOSE_SINGLE_INTERFACE_GLOBALVAR (CP2SMPlusPlusPlugin , IServerPluginCallbacks, INTERFACEVERSION_ISERVERPLUGINCALLBACKS, g_P2SMPlusPlusPlugin );
20
20
21
21
// ---------------------------------------------------------------------------------
22
22
// Purpose: Logging for the plugin by adding a prefix and line break.
23
23
// Max character limit of 1024 characters.
24
- // level: 0 = Msg/DevMsg, 1 = Warning/DevWarning
24
+ // level: 0 = Msg/DevMsg, 1 = Warning/DevWarning, 2 = Error WILL STOP ENGINE!
25
25
// ---------------------------------------------------------------------------------
26
26
void Log (int level, bool dev, const char * pMsgFormat, ...)
27
27
{
28
+ if (dev && !p2sm_developer.GetBool () && level != 2 ) return ; // Stop developer messages when p2mm_developer isn't enabled.
29
+
30
+ // Take our log message and format any arguments it has into the message.
28
31
va_list argptr;
29
- char szFormattedText[1024 ];
32
+ char szFormattedText[1024 ] = { 0 } ;
30
33
va_start (argptr, pMsgFormat);
31
34
V_vsnprintf (szFormattedText, sizeof (szFormattedText), pMsgFormat, argptr);
32
35
va_end (argptr);
33
36
34
- char completeMsg[1024 ];
35
- V_snprintf (completeMsg, sizeof (completeMsg), " (WorkshopStopper9000 PLUGIN): %s\n " , szFormattedText);
36
-
37
- if (dev && !wss9000_developer.GetBool ()) { return ; }
37
+ // Add a header to the log message.
38
+ char completeMsg[1024 ] = { 0 };
39
+ V_snprintf (completeMsg, sizeof (completeMsg), " (P2SourceModPlusPlus PLUGIN): %s\n " , szFormattedText);
38
40
39
41
switch (level)
40
42
{
41
43
case 0 :
42
- ConColorMsg (WSS9000_PLUGIN_CONSOLE_COLOR , completeMsg);
44
+ ConColorMsg (P2SMPLUSPLUS_PLUGIN_CONSOLE_COLOR , completeMsg);
43
45
return ;
44
46
case 1 :
45
47
Warning (completeMsg);
46
48
return ;
49
+ case 2 :
50
+ Warning (" (P2SourceModPlusPlus PLUGIN):\n !!!ERROR ERROR ERROR!!!:\n A FATAL ERROR OCCURED WITH THE ENGINE:\n %s" , completeMsg);
51
+ Error (completeMsg);
52
+ return ;
47
53
default :
48
- Warning (" (WorkshopStopper9000 PLUGIN): Log level set outside of 0-1, \" %i\" , defaulting to ConColorMsg() .\n " , level);
49
- ConColorMsg (WSS9000_PLUGIN_CONSOLE_COLOR , completeMsg);
54
+ Warning (" (P2SourceModPlusPlus PLUGIN): Log level set outside of 0-1, \" %i\" . Defaulting to level 0 .\n " , level);
55
+ ConColorMsg (P2SMPLUSPLUS_PLUGIN_CONSOLE_COLOR , completeMsg);
50
56
return ;
51
57
}
52
58
}
53
59
54
60
// ---------------------------------------------------------------------------------
55
61
// Purpose: constructor
56
62
// ---------------------------------------------------------------------------------
57
- CWSS9000Plugin::CWSS9000Plugin ()
63
+ CP2SMPlusPlusPlugin::CP2SMPlusPlusPlugin ()
58
64
{
59
65
this ->m_bPluginLoaded = false ;
60
66
this ->m_bNoUnload = false ; // If we fail to load, we don't want to run anything on Unload() to get what the error was.
@@ -63,17 +69,19 @@ CWSS9000Plugin::CWSS9000Plugin()
63
69
// ---------------------------------------------------------------------------------
64
70
// Purpose: destructor
65
71
// ---------------------------------------------------------------------------------
66
- CWSS9000Plugin ::~CWSS9000Plugin () {}
72
+ CP2SMPlusPlusPlugin ::~CP2SMPlusPlusPlugin () {}
67
73
68
74
// ---------------------------------------------------------------------------------
69
75
// Purpose: Description of plugin outputted when the "plugin_print" console command is executed.
70
76
// ---------------------------------------------------------------------------------
71
- const char * CWSS9000Plugin ::GetPluginDescription (void )
77
+ const char * CP2SMPlusPlusPlugin ::GetPluginDescription (void )
72
78
{
73
- return " WorkshopStopper9000 Plugin | Plugin Version: " WSS9000_PLUGIN_VERSION ;
79
+ return " P2SourceModPlusPlus Plugin | Plugin Version: " P2SMPLUSPLUS_PLUGIN_VERSION ;
74
80
}
75
81
76
- // STOP THEM WORKSHOP DOWNLOADS!
82
+ // ---------------------------------------------------------------------------------
83
+ // Purpose: Stop the UGC manager from automatically download workshop maps.
84
+ // ---------------------------------------------------------------------------------
77
85
class CUGCFileRequestManager ;
78
86
void (__fastcall* CUGCFileRequestManager__Update_orig)(CUGCFileRequestManager* thisptr);
79
87
void __fastcall CUGCFileRequestManager__Update_hook (CUGCFileRequestManager* thisptr) { return ; }
@@ -82,7 +90,7 @@ void __fastcall CUGCFileRequestManager__Update_hook(CUGCFileRequestManager* thi
82
90
// Purpose: Called when the plugin is loaded, initialization process.
83
91
// Loads the interfaces we need from the engine and applies our patches.
84
92
// ---------------------------------------------------------------------------------
85
- bool CWSS9000Plugin ::Load (CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
93
+ bool CP2SMPlusPlusPlugin ::Load (CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
86
94
{
87
95
if (m_bPluginLoaded)
88
96
{
@@ -130,7 +138,7 @@ bool CWSS9000Plugin::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn
130
138
// ---------------------------------------------------------------------------------
131
139
// Purpose: Called when the plugin is turning off/unloading.
132
140
// ---------------------------------------------------------------------------------
133
- void CWSS9000Plugin ::Unload (void )
141
+ void CP2SMPlusPlusPlugin ::Unload (void )
134
142
{
135
143
// If the plugin errors for some reason, prevent it from unloading.
136
144
if (m_bNoUnload)
@@ -153,24 +161,24 @@ void CWSS9000Plugin::Unload(void)
153
161
// Purpose: Unused callbacks
154
162
// ---------------------------------------------------------------------------------
155
163
#pragma region UNUSED_CALLBACKS
156
- void CWSS9000Plugin ::SetCommandClient (int index) {}
157
- void CWSS9000Plugin ::ServerActivate (edict_t * pEdictList, int edictCount, int clientMax) {}
158
- void CWSS9000Plugin ::LevelInit (char const * pMapName) {}
159
- PLUGIN_RESULT CWSS9000Plugin ::ClientCommand (edict_t * pEntity, const CCommand& args) { return PLUGIN_CONTINUE; }
160
- void CWSS9000Plugin ::ClientActive (edict_t * pEntity) {}
161
- void CWSS9000Plugin ::GameFrame (bool simulating) {}
162
- void CWSS9000Plugin ::LevelShutdown (void ) {}
163
- void CWSS9000Plugin ::Pause (void ) {}
164
- void CWSS9000Plugin ::UnPause (void ) {}
165
- void CWSS9000Plugin ::ClientDisconnect (edict_t * pEntity) {}
166
- void CWSS9000Plugin ::ClientFullyConnect (edict_t * pEntity) {}
167
- void CWSS9000Plugin ::ClientPutInServer (edict_t * pEntity, char const * playername) {}
168
- void CWSS9000Plugin ::ClientSettingsChanged (edict_t * pEdict) {}
169
- PLUGIN_RESULT CWSS9000Plugin ::ClientConnect (bool * bAllowConnect, edict_t * pEntity, const char * pszName, const char * pszAddress, char * reject, int maxrejectlen) { return PLUGIN_CONTINUE; }
170
- PLUGIN_RESULT CWSS9000Plugin ::NetworkIDValidated (const char * pszUserName, const char * pszNetworkID) { return PLUGIN_CONTINUE; }
171
- void CWSS9000Plugin ::OnQueryCvarValueFinished (QueryCvarCookie_t iCookie, edict_t * pPlayerEntity, EQueryCvarValueStatus eStatus, const char * pCvarName, const char * pCvarValue) {}
172
- void CWSS9000Plugin ::OnEdictAllocated (edict_t * edict) {}
173
- void CWSS9000Plugin ::OnEdictFreed (const edict_t * edict) {}
174
- bool CWSS9000Plugin ::BNetworkCryptKeyCheckRequired (uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, bool bClientWantsToUseCryptKey) { return false ; }
175
- bool CWSS9000Plugin ::BNetworkCryptKeyValidate (uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, int nEncryptionKeyIndexFromClient, int numEncryptedBytesFromClient, byte* pbEncryptedBufferFromClient, byte* pbPlainTextKeyForNetchan) { return true ; }
164
+ void CP2SMPlusPlusPlugin ::SetCommandClient (int index) {}
165
+ void CP2SMPlusPlusPlugin ::ServerActivate (edict_t * pEdictList, int edictCount, int clientMax) {}
166
+ void CP2SMPlusPlusPlugin ::LevelInit (char const * pMapName) {}
167
+ PLUGIN_RESULT CP2SMPlusPlusPlugin ::ClientCommand (edict_t * pEntity, const CCommand& args) { return PLUGIN_CONTINUE; }
168
+ void CP2SMPlusPlusPlugin ::ClientActive (edict_t * pEntity) {}
169
+ void CP2SMPlusPlusPlugin ::GameFrame (bool simulating) {}
170
+ void CP2SMPlusPlusPlugin ::LevelShutdown (void ) {}
171
+ void CP2SMPlusPlusPlugin ::Pause (void ) {}
172
+ void CP2SMPlusPlusPlugin ::UnPause (void ) {}
173
+ void CP2SMPlusPlusPlugin ::ClientDisconnect (edict_t * pEntity) {}
174
+ void CP2SMPlusPlusPlugin ::ClientFullyConnect (edict_t * pEntity) {}
175
+ void CP2SMPlusPlusPlugin ::ClientPutInServer (edict_t * pEntity, char const * playername) {}
176
+ void CP2SMPlusPlusPlugin ::ClientSettingsChanged (edict_t * pEdict) {}
177
+ PLUGIN_RESULT CP2SMPlusPlusPlugin ::ClientConnect (bool * bAllowConnect, edict_t * pEntity, const char * pszName, const char * pszAddress, char * reject, int maxrejectlen) { return PLUGIN_CONTINUE; }
178
+ PLUGIN_RESULT CP2SMPlusPlusPlugin ::NetworkIDValidated (const char * pszUserName, const char * pszNetworkID) { return PLUGIN_CONTINUE; }
179
+ void CP2SMPlusPlusPlugin ::OnQueryCvarValueFinished (QueryCvarCookie_t iCookie, edict_t * pPlayerEntity, EQueryCvarValueStatus eStatus, const char * pCvarName, const char * pCvarValue) {}
180
+ void CP2SMPlusPlusPlugin ::OnEdictAllocated (edict_t * edict) {}
181
+ void CP2SMPlusPlusPlugin ::OnEdictFreed (const edict_t * edict) {}
182
+ bool CP2SMPlusPlusPlugin ::BNetworkCryptKeyCheckRequired (uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, bool bClientWantsToUseCryptKey) { return false ; }
183
+ bool CP2SMPlusPlusPlugin ::BNetworkCryptKeyValidate (uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, int nEncryptionKeyIndexFromClient, int numEncryptedBytesFromClient, byte* pbEncryptedBufferFromClient, byte* pbPlainTextKeyForNetchan) { return true ; }
176
184
#pragma endregion
0 commit comments