1414#include " globals.hpp"
1515#include " patch-hook.hpp"
1616
17- // ---------------------------------------------------------------------------------
18- // The plugin is a static singleton that is exported as an interface
19- // ---------------------------------------------------------------------------------
20- EXPOSE_SINGLE_INTERFACE_GLOBALVAR (CP2SMPlusPlusPlugin, IServerPluginCallbacks, INTERFACEVERSION_ISERVERPLUGINCALLBACKS , g_P2SMPlusPlusPlugin);
21-
22- // ---------------------------------------------------------------------------------
23- // Purpose: constructor
24- // ---------------------------------------------------------------------------------
17+ /* *
18+ * @brief The plugin is a static singleton that is exported as an interface. Max plugin interface version Portal 2 uses is 3.
19+ */
20+ EXPOSE_SINGLE_INTERFACE_GLOBALVAR (CP2SMPlusPlusPlugin, IServerPluginCallbacks, " ISERVERPLUGINCALLBACKS003 " , g_P2SMPlusPlusPlugin);
21+
22+ /* *
23+ * @brief Constructor
24+ */
2525CP2SMPlusPlusPlugin::CP2SMPlusPlusPlugin ()
2626{
27- this ->m_bPluginLoaded = false ;
28- this ->m_bNoUnload = false ; // If we fail to load, we don't want to run anything on Unload() to get what the error was.
27+ this ->pluginLoaded = false ;
28+ this ->noUnload = false ; // If we fail to load, we don't want to run anything on Unload() to get what the error was.
29+
30+ this ->clientCommandIndex = 0 ;
31+ this ->debugID = EVENT_DEBUG_ID_INIT;
32+ }
33+
34+ /* *
35+ * @brief Destructor
36+ */
37+ CP2SMPlusPlusPlugin::~CP2SMPlusPlusPlugin ()
38+ {
39+ this ->debugID = EVENT_DEBUG_ID_SHUTDOWN;
2940}
3041
3142// ---------------------------------------------------------------------------------
3243// Purpose: Description of plugin outputted when the "plugin_print" console command is executed.
3344// ---------------------------------------------------------------------------------
34- const char * CP2SMPlusPlusPlugin::GetPluginDescription (void )
45+ const char * CP2SMPlusPlusPlugin::GetPluginDescription ()
3546{
3647 return " P2SourceModPlusPlus Plugin | Plugin Version: " P2SMPLUSPLUS_PLUGIN_VERSION;
3748}
@@ -40,12 +51,12 @@ const char* CP2SMPlusPlusPlugin::GetPluginDescription(void)
4051// Purpose: Called when the plugin is loaded, initialization process.
4152// Loads the interfaces we need from the engine and applies our patches.
4253// ---------------------------------------------------------------------------------
43- bool CP2SMPlusPlusPlugin::Load (CreateInterfaceFn interfaceFactory, const CreateInterfaceFn gameServerFactory)
54+ bool CP2SMPlusPlusPlugin::Load (CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory)
4455{
45- if (m_bPluginLoaded )
56+ if (pluginLoaded )
4657 {
4758 Log (WARNING, false , " Already loaded!" );
48- m_bNoUnload = true ;
59+ noUnload = true ;
4960 return false ;
5061 }
5162
@@ -85,7 +96,7 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateI
8596 {
8697 assert (false && " Unable to load engineServer!" );
8798 Log (WARNING, false , " Unable to load engineServer!" );
88- this ->m_bNoUnload = true ;
99+ this ->noUnload = true ;
89100 return false ;
90101 }
91102
@@ -95,7 +106,7 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateI
95106 {
96107 assert (false && " Unable to load engineClient!" );
97108 Log (WARNING, false , " Unable to load engineClient!" );
98- this ->m_bNoUnload = true ;
109+ this ->noUnload = true ;
99110 return false ;
100111 }
101112
@@ -105,7 +116,7 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateI
105116 {
106117 assert (false && " Unable to load g_pPlayerInfoManager!" );
107118 Log (WARNING, false , " Unable to load g_pPlayerInfoManager!" );
108- this ->m_bNoUnload = true ;
119+ this ->noUnload = true ;
109120 return false ;
110121 }
111122
@@ -115,7 +126,7 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateI
115126 {
116127 assert (false && " Unable to load g_pGlobals!" );
117128 Log (WARNING, false , " Unable to load g_pGlobals!" );
118- this ->m_bNoUnload = true ;
129+ this ->noUnload = true ;
119130 return false ;
120131 }
121132
@@ -127,7 +138,7 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateI
127138
128139 if (!Patches::EnablePatches ())
129140 {
130- this ->m_bNoUnload = true ;
141+ this ->noUnload = true ;
131142 throw std::runtime_error (" Failed to enable patches!" );
132143 }
133144
@@ -142,7 +153,7 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateI
142153 } catch (const std::exception& ex) {
143154 Log (INFO, false , " Failed to perform patch and hook operations! :( Exception: \" %s\" " , ex.what ());
144155 assert (false && " Patch and hook failure!" );
145- this ->m_bNoUnload = true ;
156+ this ->noUnload = true ;
146157 return false ;
147158 }
148159
@@ -169,20 +180,20 @@ bool CP2SMPlusPlusPlugin::Load(CreateInterfaceFn interfaceFactory, const CreateI
169180 ifuCVar->RemoveFlags (FCVAR_CHEAT);
170181
171182 Log (INFO, false , " Loaded plugin! Yay! :D" );
172- m_bPluginLoaded = true ;
183+ pluginLoaded = true ;
173184
174185 return true ;
175186}
176187
177188// ---------------------------------------------------------------------------------
178189// Purpose: Called when the plugin is turning off/unloading.
179190// ---------------------------------------------------------------------------------
180- void CP2SMPlusPlusPlugin::Unload (void )
191+ void CP2SMPlusPlusPlugin::Unload ()
181192{
182193 // If the plugin errors for some reason, prevent it from unloading.
183- if (m_bNoUnload )
194+ if (noUnload )
184195 {
185- m_bNoUnload = false ;
196+ noUnload = false ;
186197 Log (WARNING, true , " Failed to load plugin!" );
187198 MessageBox (GeneralGUI::GetWindowHandle (), " P2SM++ ran into a error when starting!\n Please check the console for more info!" , " P2SM++ Startup Error" , MB_OK | MB_ICONERROR);
188199 return ;
@@ -241,14 +252,14 @@ void CP2SMPlusPlusPlugin::Unload(void)
241252 DisconnectTier2Libraries ();
242253 DisconnectTier1Libraries ();
243254
244- m_bPluginLoaded = false ;
255+ pluginLoaded = false ;
245256 Log (INFO, false , " Plugin unloaded! Goodbye!" );
246257}
247258
248- void CP2SMPlusPlusPlugin::ClientFullyConnect (Edict* pEntity )
259+ void CP2SMPlusPlusPlugin::ClientFullyConnect (Edict* edict )
249260{
250261 // Make sure the r_drawscreenoverlay ConVar is enabled for connecting clients.
251- engineServer->ClientCommand (pEntity , " r_drawscreenoverlay 1" );
262+ engineServer->ClientCommand (edict , " r_drawscreenoverlay 1" );
252263 Log (WARNING, true , " r_drawscreenoverlay enabled for client." );
253264}
254265
0 commit comments