mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Merge pull request #202 from Arkshine/fix/crash-null-detour
Fix crash when cvar hook detour is not created
This commit is contained in:
commit
c556bf9f68
@ -230,7 +230,7 @@ CvarInfo* CvarManager::CreateCvar(const char* name, const char* value, const cha
|
|||||||
|
|
||||||
// Detour is disabled on map change.
|
// Detour is disabled on map change.
|
||||||
// Don't enable it unless there are things to do.
|
// Don't enable it unless there are things to do.
|
||||||
if (info->bound.hasMin || info->bound.hasMax)
|
if ((info->bound.hasMin || info->bound.hasMax) && m_HookDetour)
|
||||||
{
|
{
|
||||||
m_HookDetour->EnableDetour();
|
m_HookDetour->EnableDetour();
|
||||||
}
|
}
|
||||||
@ -321,7 +321,10 @@ AutoForward* CvarManager::HookCvarChange(cvar_t* var, AMX* amx, cell param, cons
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detour is disabled on map change.
|
// Detour is disabled on map change.
|
||||||
m_HookDetour->EnableDetour();
|
if (m_HookDetour)
|
||||||
|
{
|
||||||
|
m_HookDetour->EnableDetour();
|
||||||
|
}
|
||||||
|
|
||||||
AutoForward* forward = new AutoForward(forwardId, *callback);
|
AutoForward* forward = new AutoForward(forwardId, *callback);
|
||||||
info->hooks.append(new CvarHook(g_plugins.findPlugin(amx)->getId(), forward));
|
info->hooks.append(new CvarHook(g_plugins.findPlugin(amx)->getId(), forward));
|
||||||
@ -374,7 +377,10 @@ bool CvarManager::BindCvar(CvarInfo* info, CvarBind::CvarType type, AMX* amx, ce
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Detour is disabled on map change.
|
// Detour is disabled on map change.
|
||||||
m_HookDetour->EnableDetour();
|
if (m_HookDetour)
|
||||||
|
{
|
||||||
|
m_HookDetour->EnableDetour();
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -394,7 +400,10 @@ bool CvarManager::SetCvarMin(CvarInfo* info, bool set, float value, int pluginId
|
|||||||
info->bound.minVal = value;
|
info->bound.minVal = value;
|
||||||
|
|
||||||
// Detour is disabled on map change.
|
// Detour is disabled on map change.
|
||||||
m_HookDetour->EnableDetour();
|
if (m_HookDetour)
|
||||||
|
{
|
||||||
|
m_HookDetour->EnableDetour();
|
||||||
|
}
|
||||||
|
|
||||||
// Update if needed.
|
// Update if needed.
|
||||||
CVAR_SET_FLOAT(info->var->name, value);
|
CVAR_SET_FLOAT(info->var->name, value);
|
||||||
@ -418,7 +427,10 @@ bool CvarManager::SetCvarMax(CvarInfo* info, bool set, float value, int pluginId
|
|||||||
info->bound.maxVal = value;
|
info->bound.maxVal = value;
|
||||||
|
|
||||||
// Detour is disabled on map change.
|
// Detour is disabled on map change.
|
||||||
m_HookDetour->EnableDetour();
|
if (m_HookDetour)
|
||||||
|
{
|
||||||
|
m_HookDetour->EnableDetour();
|
||||||
|
}
|
||||||
|
|
||||||
// Update if needed.
|
// Update if needed.
|
||||||
CVAR_SET_FLOAT(info->var->name, value);
|
CVAR_SET_FLOAT(info->var->name, value);
|
||||||
@ -596,7 +608,10 @@ void CvarManager::OnPluginUnloaded()
|
|||||||
|
|
||||||
// There is no point to enable detour if at next map change
|
// There is no point to enable detour if at next map change
|
||||||
// no plugins hook cvars.
|
// no plugins hook cvars.
|
||||||
m_HookDetour->DisableDetour();
|
if (m_HookDetour)
|
||||||
|
{
|
||||||
|
m_HookDetour->DisableDetour();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvarManager::OnAmxxShutdown()
|
void CvarManager::OnAmxxShutdown()
|
||||||
@ -619,5 +634,9 @@ void CvarManager::OnAmxxShutdown()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_Cache.clear();
|
m_Cache.clear();
|
||||||
m_HookDetour->Destroy();
|
|
||||||
|
if (m_HookDetour)
|
||||||
|
{
|
||||||
|
m_HookDetour->Destroy();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user