Unverified Commit 658dc07c authored by s1lent's avatar s1lent

Fix another crash due AMXX_Assert function.

parent a68cde02
......@@ -250,6 +250,7 @@
</ClCompile>
<ClCompile Include="..\include\cssdk\public\interface.cpp" />
<ClCompile Include="..\src\amxxmodule.cpp" />
<ClCompile Include="..\src\amx_hook.cpp" />
<ClCompile Include="..\src\api_config.cpp" />
<ClCompile Include="..\src\dllapi.cpp" />
<ClCompile Include="..\src\engine_api.cpp" />
......
......@@ -824,6 +824,9 @@
<ClCompile Include="..\src\entity_callback.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\src\amx_hook.cpp">
<Filter>src</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="..\extra\amxmodx\scripting\include\reapi.inc">
......
#include "precompiled.h"
CAmxxHookBase::CAmxxHookBase(AMX *amx, const char *funcname, int index) :
m_index(index),
m_state(FSTATE_ENABLED),
m_amx(amx)
{
Q_strlcpy(m_CallbackName, funcname);
}
CAmxxHookBase::~CAmxxHookBase()
{
if (m_index != -1)
{
g_amxxapi.UnregisterSPForward(m_index);
m_index = -1;
}
}
void CAmxxHookBase::Error(int error, const char *fmt, ...)
{
va_list argptr;
static char string[1024];
va_start(argptr, fmt);
vsprintf(string, fmt, argptr);
va_end(argptr);
auto scriptName = g_amxxapi.GetAmxScriptName(g_amxxapi.FindAmxScriptByAmx(m_amx));
if (scriptName)
{
if ((scriptName = strrchr(scriptName, CORRECT_PATH_SEPARATOR)))
scriptName++;
}
g_amxxapi.Log("Run time error %d (plugin \"%s\") (forward \"%s\")", error, scriptName, m_CallbackName);
g_amxxapi.Log("%s", string);
}
......@@ -11,21 +11,8 @@ enum fwdstate
class CAmxxHookBase
{
public:
~CAmxxHookBase()
{
if (m_index != -1) {
g_amxxapi.UnregisterSPForward(m_index);
m_index = -1;
}
}
CAmxxHookBase(AMX *amx, const char *funcname, int index) :
m_index(index),
m_state(FSTATE_ENABLED),
m_amx(amx)
{
Q_strlcpy(m_CallbackName, funcname);
}
~CAmxxHookBase();
CAmxxHookBase(AMX *amx, const char *funcname, int index);
int GetIndex() const { return m_index; }
fwdstate GetState() const { return m_state; }
......@@ -33,6 +20,7 @@ public:
const char *GetCallbackName() const { return m_CallbackName; }
void SetState(fwdstate st) { m_state = st; }
void Error(int error, const char *fmt, ...);
private:
int m_index;
......
......@@ -221,24 +221,6 @@ NOINLINE void AMXX_LogError(AMX *amx, int err, const char *fmt, ...)
g_amxxapi.LogError(amx, err, "[%s] %s", g_ModuleInfo.logtag, msg);
}
NOINLINE void AMXX_Assert(AMX *amx, const char *fmt, ...)
{
char msg[2048];
va_list arglst;
va_start(arglst, fmt);
vsnprintf(msg, sizeof msg, fmt, arglst);
va_end(arglst);
auto scriptName = g_amxxapi.GetAmxScriptName(g_amxxapi.FindAmxScriptByAmx(amx));
if (scriptName)
{
if ((scriptName = strrchr(scriptName, CORRECT_PATH_SEPARATOR)))
scriptName++;
}
g_amxxapi.LogError(amx, AMX_ERR_ASSERT, "[%s] %s", scriptName, msg);
}
char* getAmxString(cell* src, char* dest, size_t max, size_t* len)
{
char* start = dest;
......
......@@ -493,7 +493,6 @@ extern amxxapi_t g_amxxapi;
void AMXX_Log(const char *fmt, ...);
void AMXX_LogError(AMX *amx, int err, const char *fmt, ...);
void AMXX_Assert(AMX *amx, const char *fmt, ...);
char* getAmxString(cell* src, char* dest, size_t max, size_t* len = nullptr);
void setAmxString(cell* dest, const char* string, size_t max);
......
......@@ -215,7 +215,7 @@ NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, f_arg
}
if (unlikely(!hookCtx->retVal.set)) {
AMXX_Assert(fwd->GetAmx(), "%s : Can't suppress original function call without new return value set", fwd->GetCallbackName());
fwd->Error(AMX_ERR_ASSERT, "Can't suppress original function call without new return value set");
continue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment