@@ -151,6 +151,7 @@ CUtlVector<IEntityListener *> *EntListeners()
151
151
/* *
152
152
* IServerGameDLL & IVEngineServer Hooks
153
153
*/
154
+ SH_DECL_HOOK0_void (IServerGameDLL, LevelShutdown, SH_NOATTRIB, false );
154
155
SH_DECL_HOOK6 (IServerGameDLL, LevelInit, SH_NOATTRIB, 0 , bool , const char *, const char *, const char *, const char *, bool , bool );
155
156
#ifdef GAMEDESC_CAN_CHANGE
156
157
SH_DECL_HOOK0 (IServerGameDLL, GetGameDescription, SH_NOATTRIB, 0 , const char *);
@@ -247,6 +248,8 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
247
248
sharesys->AddCapabilityProvider (myself, this , " SDKHook_DmgCustomInOTD" );
248
249
sharesys->AddCapabilityProvider (myself, this , " SDKHook_LogicalEntSupport" );
249
250
251
+ SH_ADD_HOOK (IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER (this , &SDKHooks::LevelShutdown), false );
252
+
250
253
playerhelpers->AddClientListener (&g_Interface);
251
254
252
255
plsys->AddPluginsListener (&g_Interface);
@@ -365,7 +368,9 @@ void SDKHooks::SDK_OnUnload()
365
368
forwards->ReleaseForward (g_pOnLevelInit);
366
369
367
370
plsys->RemovePluginsListener (&g_Interface);
368
-
371
+
372
+ SH_REMOVE_HOOK (IServerGameDLL, LevelShutdown, gamedll, SH_MEMBER (this , &SDKHooks::LevelShutdown), true );
373
+
369
374
playerhelpers->RemoveClientListener (&g_Interface);
370
375
371
376
sharesys->DropCapabilityProvider (myself, this , " SDKHook_DmgCustomInOTD" );
@@ -445,6 +450,24 @@ void SDKHooks::OnClientDisconnecting(int client)
445
450
HandleEntityDeleted (pEntity);
446
451
}
447
452
453
+ void SDKHooks::LevelShutdown ()
454
+ {
455
+ #if defined PLATFORM_LINUX
456
+ for (size_t type = 0 ; type < SDKHook_MAXHOOKS; ++type)
457
+ {
458
+ std::vector<CVTableList *> &vtablehooklist = g_HookList[type];
459
+ for (size_t listentry = 0 ; listentry < vtablehooklist.size (); ++listentry)
460
+ {
461
+ std::vector<HookList> &pawnhooks = vtablehooklist[listentry]->hooks ;
462
+ pawnhooks.clear ();
463
+
464
+ delete vtablehooklist[listentry];
465
+ }
466
+ vtablehooklist.clear ();
467
+ }
468
+ #endif
469
+ }
470
+
448
471
void SDKHooks::AddEntityListener (ISMEntityListener *listener)
449
472
{
450
473
m_EntListeners.push_back (listener);
@@ -791,12 +814,14 @@ void SDKHooks::Unhook(CBaseEntity *pEntity)
791
814
entry--;
792
815
}
793
816
817
+ #if !defined PLATFORM_LINUX
794
818
if (pawnhooks.size () == 0 )
795
819
{
796
820
delete vtablehooklist[listentry];
797
821
vtablehooklist.erase (vtablehooklist.begin () + listentry);
798
822
listentry--;
799
823
}
824
+ #endif
800
825
}
801
826
}
802
827
}
@@ -820,12 +845,14 @@ void SDKHooks::Unhook(IPluginContext *pContext)
820
845
entry--;
821
846
}
822
847
848
+ #if !defined PLATFORM_LINUX
823
849
if (pawnhooks.size () == 0 )
824
850
{
825
851
delete vtablehooklist[listentry];
826
852
vtablehooklist.erase (vtablehooklist.begin () + listentry);
827
853
listentry--;
828
854
}
855
+ #endif
829
856
}
830
857
}
831
858
}
@@ -862,12 +889,14 @@ void SDKHooks::Unhook(int entity, SDKHookType type, IPluginFunction *pCallback)
862
889
entry--;
863
890
}
864
891
892
+ #if !defined PLATFORM_LINUX
865
893
if (pawnhooks.size () == 0 )
866
894
{
867
895
delete vtablehooklist[listentry];
868
896
vtablehooklist.erase (vtablehooklist.begin () + listentry);
869
897
listentry--;
870
898
}
899
+ #endif
871
900
872
901
break ;
873
902
}
0 commit comments