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");
|
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()
|
||||||
|
{
|
||||||
|
if (calcIsAttackCriticalDetour != NULL)
|
||||||
{
|
{
|
||||||
calcIsAttackCriticalDetour->Destroy();
|
calcIsAttackCriticalDetour->Destroy();
|
||||||
calcIsAttackCriticalMeleeDetour->Destroy();
|
calcIsAttackCriticalDetour = NULL;
|
||||||
calcIsAttackCriticalBowDetour->Destroy();
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -309,21 +309,19 @@ 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;
|
|
||||||
}
|
}
|
||||||
if (!m_RulesDetoursEnabled)
|
|
||||||
|
if (!m_RulesDetoursEnabled
|
||||||
|
&& ( g_waitingPlayersStartForward->GetFunctionCount() || g_waitingPlayersEndForward->GetFunctionCount() )
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if(g_waitingPlayersStartForward->GetFunctionCount() || g_waitingPlayersEndForward->GetFunctionCount())
|
m_RulesDetoursEnabled = InitialiseRulesDetours();
|
||||||
{
|
|
||||||
InitialiseRulesDetours();
|
|
||||||
m_RulesDetoursEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +339,7 @@ void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
|
|||||||
}
|
}
|
||||||
if (m_RulesDetoursEnabled)
|
if (m_RulesDetoursEnabled)
|
||||||
{
|
{
|
||||||
if(!g_waitingPlayersStartForward->GetFunctionCount() || !g_waitingPlayersEndForward->GetFunctionCount())
|
if (!g_waitingPlayersStartForward->GetFunctionCount() && !g_waitingPlayersEndForward->GetFunctionCount())
|
||||||
{
|
{
|
||||||
RemoveRulesDetours();
|
RemoveRulesDetours();
|
||||||
m_RulesDetoursEnabled = false;
|
m_RulesDetoursEnabled = false;
|
||||||
|
@ -64,17 +64,18 @@ DETOUR_DECL_MEMBER1(SetInWaitingForPlayers, void, bool, bWaitingForPlayers)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitialiseRulesDetours()
|
bool InitialiseRulesDetours()
|
||||||
{
|
{
|
||||||
setInWaitingForPlayersDetour = DETOUR_CREATE_MEMBER(SetInWaitingForPlayers, "SetInWaitingForPlayers");
|
setInWaitingForPlayersDetour = DETOUR_CREATE_MEMBER(SetInWaitingForPlayers, "SetInWaitingForPlayers");
|
||||||
|
|
||||||
if (setInWaitingForPlayersDetour != NULL)
|
if (setInWaitingForPlayersDetour != NULL)
|
||||||
{
|
{
|
||||||
setInWaitingForPlayersDetour->EnableDetour();
|
setInWaitingForPlayersDetour->EnableDetour();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pSM->LogError(myself, "No Gameplay Rules detours could be initialized - Disabled Gameplay Rules functions");
|
g_pSM->LogError(myself, "No Gameplay Rules detours could be initialized - Disabled Gameplay Rules functions");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveRulesDetours()
|
void RemoveRulesDetours()
|
||||||
|
@ -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 InitialiseRulesDetours();
|
bool InitialiseRulesDetours();
|
||||||
void RemoveRulesDetours();
|
void RemoveRulesDetours();
|
||||||
|
|
||||||
extern IForward *g_waitingPlayersStartForward;
|
extern IForward *g_waitingPlayersStartForward;
|
||||||
|
@ -58,17 +58,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