Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Commit

Permalink
Fix some little mistakes
Browse files Browse the repository at this point in the history
  • Loading branch information
CurTInq authored Jan 18, 2019
1 parent 9d6292d commit 5d63c63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions extension/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void HookExtensionUnload(IExtension * pExt)

bool bHookedAlready = false;
for (int i = 0; i < g_Hooks.Count(); i++)
{
if (g_Hooks[i].pExtensionAPI == pExt->GetAPI())
{
bHookedAlready = true;
Expand All @@ -90,8 +91,10 @@ void HookExtensionUnload(IExtension * pExt)
break;
}
}
}
if (!bHookedAlready)
for (int i = 0; i < g_HooksGamerules.Count(); i++)
{
if (g_HooksGamerules[i].pExtensionAPI == pExt->GetAPI())
{
bHookedAlready = true;
Expand All @@ -107,6 +110,7 @@ void HookExtensionUnload(IExtension * pExt)
break;
}
}
}
if (!bHookedAlready) //Hook only if needed!
SH_ADD_HOOK(IExtensionInterface, OnExtensionUnload, pExt->GetAPI(), SH_STATIC(Hook_OnExtensionUnload), false);
}
Expand All @@ -118,6 +122,7 @@ void UnhookExtensionUnload(IExtension * pExt)

bool bHaveHooks = false;
for (int i = 0; i < g_Hooks.Count(); i++)
{
if (g_Hooks[i].pExtensionAPI == pExt->GetAPI())
{
bHaveHooks = true;
Expand All @@ -133,8 +138,10 @@ void UnhookExtensionUnload(IExtension * pExt)
break;
}
}
}
if (!bHaveHooks)
for (int i = 0; i < g_HooksGamerules.Count(); i++)
{
if (g_HooksGamerules[i].pExtensionAPI == pExt->GetAPI())
{
bHaveHooks = true;
Expand All @@ -150,6 +157,7 @@ void UnhookExtensionUnload(IExtension * pExt)
break;
}
}
}

if (!bHaveHooks) //so, if there are active hooks, we shouldn't remove hook!
SH_REMOVE_HOOK(IExtensionInterface, OnExtensionUnload, pExt->GetAPI(), SH_STATIC(Hook_OnExtensionUnload), false);
Expand Down
2 changes: 1 addition & 1 deletion extension/natives.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
#include "extension.h"
extern const sp_nativeinfo_t g_MyNatives[];

#endif;
#endif

0 comments on commit 5d63c63

Please sign in to comment.