Skip to content
This repository was archived by the owner on Feb 16, 2024. It is now read-only.

Commit 77bc8d8

Browse files
committed
make plugin properly error out
1 parent 74a22fb commit 77bc8d8

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

authsessionfix.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,18 @@ bool AuthSessionFix::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen
7777
#endif
7878
g_pNotifyClientDisconnect = (NotifyClientDisconnect_t)serverModule->FindSignature((byte*)sig, sizeof(sig)-1, err);
7979

80-
auto g_hook = funchook_create();
81-
funchook_prepare(g_hook, (void**)&g_pNotifyClientDisconnect, (void*)Hook_NotifyClientDisconnect);
82-
funchook_install(g_hook, 0);
83-
8480
if (err)
8581
{
86-
META_CONPRINTF("Failed to find signature: %d\n", err);
82+
META_CONPRINTF("[AuthSessionFix] Failed to find signature: %i\n", err);
83+
V_snprintf(error, maxlen, "[AuthSessionFix] Failed to find signature: %i\n", err);
84+
return false;
8785
}
8886

89-
META_CONPRINTF( "All hooks started!\n" );
87+
auto g_hook = funchook_create();
88+
funchook_prepare(g_hook, (void**)&g_pNotifyClientDisconnect, (void*)Hook_NotifyClientDisconnect);
89+
funchook_install(g_hook, 0);
90+
91+
META_CONPRINTF( "AuthSessionFix started!\n" );
9092

9193
g_pCVar = icvar;
9294
ConVar_Register( FCVAR_RELEASE | FCVAR_CLIENT_CAN_EXECUTE | FCVAR_GAMEDLL );
@@ -99,8 +101,11 @@ bool AuthSessionFix::Unload(char *error, size_t maxlen)
99101
SH_REMOVE_HOOK(IServerGameDLL, GameServerSteamAPIActivated, g_pSource2Server, SH_MEMBER(this, &AuthSessionFix::Hook_GameServerSteamAPIActivated), false);
100102
SH_REMOVE_HOOK(IServerGameDLL, GameServerSteamAPIDeactivated, g_pSource2Server, SH_MEMBER(this, &AuthSessionFix::Hook_GameServerSteamAPIDeactivated), false);
101103

102-
funchook_uninstall(g_hook, 0);
103-
funchook_destroy(g_hook);
104+
if (g_hook)
105+
{
106+
funchook_uninstall(g_hook, 0);
107+
funchook_destroy(g_hook);
108+
}
104109

105110
return true;
106111
}

0 commit comments

Comments
 (0)