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");
|
calcIsAttackCriticalDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelper, "CalcCritical");
|
||||||
calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperMelee, "CalcCriticalMelee");
|
calcIsAttackCriticalMeleeDetour = DETOUR_CREATE_MEMBER(CalcIsAttackCriticalHelperMelee, "CalcCriticalMelee");
|
||||||
@ -214,17 +214,33 @@ void InitialiseCritDetours()
|
|||||||
HookCreated = true;
|
HookCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HookCreated)
|
if (HookCreated)
|
||||||
{
|
{
|
||||||
g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks");
|
return true;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_pSM->LogError(myself, "No critical hit forwards could be initialized - Disabled critical hit hooks");
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveCritDetours()
|
void RemoveCritDetours()
|
||||||
{
|
{
|
||||||
calcIsAttackCriticalDetour->Destroy();
|
if (calcIsAttackCriticalDetour != NULL)
|
||||||
calcIsAttackCriticalMeleeDetour->Destroy();
|
{
|
||||||
calcIsAttackCriticalBowDetour->Destroy();
|
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 <jit/x86/x86_macros.h>
|
||||||
#include "CDetour/detours.h"
|
#include "CDetour/detours.h"
|
||||||
|
|
||||||
void InitialiseCritDetours();
|
bool InitialiseCritDetours();
|
||||||
void RemoveCritDetours();
|
void RemoveCritDetours();
|
||||||
|
|
||||||
extern IForward *g_critForward;
|
extern IForward *g_critForward;
|
||||||
|
@ -303,13 +303,11 @@ void TF2Tools::OnPluginLoaded(IPlugin *plugin)
|
|||||||
{
|
{
|
||||||
if (!m_CritDetoursEnabled && g_critForward->GetFunctionCount())
|
if (!m_CritDetoursEnabled && g_critForward->GetFunctionCount())
|
||||||
{
|
{
|
||||||
InitialiseCritDetours();
|
m_CritDetoursEnabled = InitialiseCritDetours();
|
||||||
m_CritDetoursEnabled = true;
|
|
||||||
}
|
}
|
||||||
if (!m_GetHolidayDetourEnabled && g_getHolidayForward->GetFunctionCount())
|
if (!m_GetHolidayDetourEnabled && g_getHolidayForward->GetFunctionCount())
|
||||||
{
|
{
|
||||||
InitialiseGetHolidayDetour();
|
m_GetHolidayDetourEnabled = InitialiseGetHolidayDetour();
|
||||||
m_GetHolidayDetourEnabled = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,17 +27,18 @@ DETOUR_DECL_STATIC0(GetHoliday, int)
|
|||||||
return actualres;
|
return actualres;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitialiseGetHolidayDetour()
|
bool InitialiseGetHolidayDetour()
|
||||||
{
|
{
|
||||||
getHolidayDetour = DETOUR_CREATE_STATIC(GetHoliday, "GetHoliday");
|
getHolidayDetour = DETOUR_CREATE_STATIC(GetHoliday, "GetHoliday");
|
||||||
|
|
||||||
if (!getHolidayDetour)
|
if (getHolidayDetour != NULL)
|
||||||
{
|
{
|
||||||
g_pSM->LogError(myself, "GetHoliday detour failed");
|
getHolidayDetour->EnableDetour();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
getHolidayDetour->EnableDetour();
|
g_pSM->LogError(myself, "GetHoliday detour failed");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveGetHolidayDetour()
|
void RemoveGetHolidayDetour()
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <jit/x86/x86_macros.h>
|
#include <jit/x86/x86_macros.h>
|
||||||
#include "CDetour/detours.h"
|
#include "CDetour/detours.h"
|
||||||
|
|
||||||
void InitialiseGetHolidayDetour();
|
bool InitialiseGetHolidayDetour();
|
||||||
void RemoveGetHolidayDetour();
|
void RemoveGetHolidayDetour();
|
||||||
|
|
||||||
extern IForward *g_getHolidayForward;
|
extern IForward *g_getHolidayForward;
|
||||||
|
Loading…
Reference in New Issue
Block a user