Fixed CDetour crash in TF2 extension when last plugin using forward is unloaded (bug 4713, r=fyren).
This commit is contained in:
parent
57cf6db4e0
commit
9ec7feb9ab
@ -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;
|
||||
|
@ -309,21 +309,19 @@ 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();
|
||||
}
|
||||
if (!m_RulesDetoursEnabled)
|
||||
|
||||
if (!m_RulesDetoursEnabled
|
||||
&& ( g_waitingPlayersStartForward->GetFunctionCount() || g_waitingPlayersEndForward->GetFunctionCount() )
|
||||
)
|
||||
{
|
||||
if(g_waitingPlayersStartForward->GetFunctionCount() || g_waitingPlayersEndForward->GetFunctionCount())
|
||||
{
|
||||
InitialiseRulesDetours();
|
||||
m_RulesDetoursEnabled = true;
|
||||
}
|
||||
m_RulesDetoursEnabled = InitialiseRulesDetours();
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,7 +339,7 @@ void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
|
||||
}
|
||||
if (m_RulesDetoursEnabled)
|
||||
{
|
||||
if(!g_waitingPlayersStartForward->GetFunctionCount() || !g_waitingPlayersEndForward->GetFunctionCount())
|
||||
if (!g_waitingPlayersStartForward->GetFunctionCount() && !g_waitingPlayersEndForward->GetFunctionCount())
|
||||
{
|
||||
RemoveRulesDetours();
|
||||
m_RulesDetoursEnabled = false;
|
||||
|
@ -64,17 +64,18 @@ DETOUR_DECL_MEMBER1(SetInWaitingForPlayers, void, bool, bWaitingForPlayers)
|
||||
}
|
||||
}
|
||||
|
||||
void InitialiseRulesDetours()
|
||||
bool InitialiseRulesDetours()
|
||||
{
|
||||
setInWaitingForPlayersDetour = DETOUR_CREATE_MEMBER(SetInWaitingForPlayers, "SetInWaitingForPlayers");
|
||||
|
||||
if (setInWaitingForPlayersDetour != NULL)
|
||||
{
|
||||
setInWaitingForPlayersDetour->EnableDetour();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
g_pSM->LogError(myself, "No Gameplay Rules detours could be initialized - Disabled Gameplay Rules functions");
|
||||
return false;
|
||||
}
|
||||
|
||||
void RemoveRulesDetours()
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <jit/x86/x86_macros.h>
|
||||
#include "CDetour/detours.h"
|
||||
|
||||
void InitialiseRulesDetours();
|
||||
bool InitialiseRulesDetours();
|
||||
void RemoveRulesDetours();
|
||||
|
||||
extern IForward *g_waitingPlayersStartForward;
|
||||
|
@ -58,17 +58,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