Fixed CDetour crash in TF2 extension when last plugin using forward is unloaded (bug 4713, r=fyren).
This commit is contained in:
parent
dd83c23cda
commit
1bb9adc767
@ -188,7 +188,7 @@ DETOUR_DECL_MEMBER0(CalcIsAttackCriticalHelperBow, bool)
|
||||
}
|
||||
}
|
||||
|
||||
void InitialiseCritDetours()
|
||||
bool InitialiseCritDetours()
|
||||
{
|
||||
calcIsAttackCriticalDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCritical");
|
||||
calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperMelee, "CalcCriticalMelee");
|
||||
@ -214,17 +214,33 @@ void InitialiseCritDetours()
|
||||
HookCreated = true;
|
||||
}
|
||||
|
||||
if (!HookCreated)
|
||||
if (HookCreated)
|
||||
{
|
||||
g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void RemoveCritDetours()
|
||||
{
|
||||
calcIsAttackCriticalDetour->Destroy();
|
||||
calcIsAttackCriticalMeleeDetour->Destroy();
|
||||
calcIsAttackCriticalBowDetour->Destroy();
|
||||
if (calcIsAttackCriticalDetour != NULL)
|
||||
{
|
||||
calcIsAttackCriticalDetour->Destroy();
|
||||
calcIsAttackCriticalDetour = NULL;
|
||||
}
|
||||
|
||||
if (calcIsAttackCriticalMeleeDetour != NULL)
|
||||
{
|
||||
calcIsAttackCriticalMeleeDetour->Destroy();
|
||||
calcIsAttackCriticalMeleeDetour = NULL;
|
||||
}
|
||||
|
||||
if (calcIsAttackCriticalBowDetour != NULL)
|
||||
{
|
||||
calcIsAttackCriticalBowDetour->Destroy();
|
||||
calcIsAttackCriticalBowDetour = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <jit/x86/x86_macros.h>
|
||||
#include "CDetour/detours.h"
|
||||
|
||||
void InitialiseCritDetours();
|
||||
bool InitialiseCritDetours();
|
||||
void RemoveCritDetours();
|
||||
|
||||
extern IForward *g_critForward;
|
||||
|
@ -303,13 +303,11 @@ void TF2Tools::OnPluginLoaded(IPlugin *plugin)
|
||||
{
|
||||
if (!m_CritDetoursEnabled && g_critForward->GetFunctionCount())
|
||||
{
|
||||
InitialiseCritDetours();
|
||||
m_CritDetoursEnabled = true;
|
||||
m_CritDetoursEnabled = InitialiseCritDetours();
|
||||
}
|
||||
if (!m_GetHolidayDetourEnabled && g_getHolidayForward->GetFunctionCount())
|
||||
{
|
||||
InitialiseGetHolidayDetour();
|
||||
m_GetHolidayDetourEnabled = true;
|
||||
m_GetHolidayDetourEnabled = InitialiseGetHolidayDetour();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,17 +27,18 @@ DETOUR_DECL_STATIC0(GetHoliday, int)
|
||||
return actualres;
|
||||
}
|
||||
|
||||
void InitialiseGetHolidayDetour()
|
||||
bool InitialiseGetHolidayDetour()
|
||||
{
|
||||
getHolidayDetour = DETOUR_CREATE_STATIC(GetHoliday, "GetHoliday");
|
||||
|
||||
if (!getHolidayDetour)
|
||||
if (getHolidayDetour != NULL)
|
||||
{
|
||||
g_pSM->LogError(myself, "GetHoliday detour failed");
|
||||
return;
|
||||
getHolidayDetour->EnableDetour();
|
||||
return true;
|
||||
}
|
||||
|
||||
getHolidayDetour->EnableDetour();
|
||||
g_pSM->LogError(myself, "GetHoliday detour failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
void RemoveGetHolidayDetour()
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <jit/x86/x86_macros.h>
|
||||
#include "CDetour/detours.h"
|
||||
|
||||
void InitialiseGetHolidayDetour();
|
||||
bool InitialiseGetHolidayDetour();
|
||||
void RemoveGetHolidayDetour();
|
||||
|
||||
extern IForward *g_getHolidayForward;
|
||||
|
Loading…
Reference in New Issue
Block a user