Hopefully fixed up HamExecuteB for the last time.
Fixed a small memory leak because I wasn't deleting post forwards at map change. Hopefully fixed an erroneous display of 'stray' keys.
This commit is contained in:
@@ -12,9 +12,28 @@ extern CVector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
|
||||
|
||||
void FailPlugin(AMX *amx, int id, int err, const char *reason);
|
||||
|
||||
inline void *GetFunction(void *pthis, int id)
|
||||
extern bool gDoForwards;
|
||||
|
||||
inline void *GetFunction(void *pthis, int id, bool &istramp)
|
||||
{
|
||||
return GetVTableEntry(pthis, hooklist[id].vtid, Offsets.GetBase());
|
||||
istramp=false;
|
||||
void *func=GetVTableEntry(pthis, hooklist[id].vtid, Offsets.GetBase());
|
||||
|
||||
// Check to see if it's a trampoline
|
||||
CVector<Hook *>::iterator end=hooks[id].end();
|
||||
|
||||
for (CVector<Hook *>::iterator i=hooks[id].begin();
|
||||
i!=end;
|
||||
++i)
|
||||
{
|
||||
if (func==(*i)->tramp)
|
||||
{
|
||||
istramp=true;
|
||||
return func;
|
||||
}
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
||||
inline void *_GetFunction(void *pthis, int id)
|
||||
{
|
||||
@@ -54,7 +73,13 @@ inline void *_GetFunction(void *pthis, int id)
|
||||
int id=params[2]; \
|
||||
CHECK_FUNCTION(func); \
|
||||
CHECK_ENTITY(id); \
|
||||
void *pv=IndexToPrivate(id);
|
||||
void *pv=IndexToPrivate(id); \
|
||||
bool istramp; \
|
||||
void *__func=GetFunction(pv, func, istramp); \
|
||||
if (!istramp && !gDoForwards) \
|
||||
{ \
|
||||
gDoForwards=true; \
|
||||
}
|
||||
|
||||
|
||||
cell Call_Void_Void(AMX *amx, cell *params)
|
||||
@@ -62,9 +87,9 @@ cell Call_Void_Void(AMX *amx, cell *params)
|
||||
SETUP(0);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void*, int)>(GetFunction(pv, func))(pv, 0);
|
||||
reinterpret_cast<void (__fastcall *)(void*, int)>(__func)(pv, 0);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *)>(GetFunction(pv, func))(pv);
|
||||
reinterpret_cast<void (*)(void *)>(__func)(pv);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -74,9 +99,9 @@ cell Call_Int_Void(AMX *amx, cell *params)
|
||||
SETUP(0);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int)>(GetFunction(pv, func))(pv, 0);
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int)>(__func)(pv, 0);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *)>(GetFunction(pv, func))(pv);
|
||||
return reinterpret_cast<int (*)(void *)>(__func)(pv);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -91,9 +116,9 @@ cell Call_Void_Entvar(AMX *amx, cell *params)
|
||||
entvars_t *ev1=&(INDEXENT_NEW(id3)->v);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *)>(GetFunction(pv, func))(pv, 0, ev1);
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *)>(__func)(pv, 0, ev1);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, entvars_t *)>(GetFunction(pv, func))(pv, ev1);
|
||||
reinterpret_cast<void (*)(void *, entvars_t *)>(__func)(pv, ev1);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -110,9 +135,9 @@ cell Call_Void_Cbase(AMX *amx, cell *params)
|
||||
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, void *)>(GetFunction(pv, func))(pv, 0, pv1);
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, void *)>(GetFunction(pv, func))(pv, pv1);
|
||||
reinterpret_cast<void (*)(void *, void *)>(__func)(pv, pv1);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -125,9 +150,9 @@ cell Call_Int_Float_Int(AMX *amx, cell *params)
|
||||
int i4=*MF_GetAmxAddr(amx, params[4]);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, float, int)>(GetFunction(pv, func))(pv, 0, f3, i4);
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, float, int)>(__func)(pv, 0, f3, i4);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, float, int)>(GetFunction(pv, func))(pv, f3, i4);
|
||||
return reinterpret_cast<int (*)(void *, float, int)>(__func)(pv, f3, i4);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -144,9 +169,9 @@ cell Call_Void_Entvar_Int(AMX *amx, cell *params)
|
||||
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, int)>(GetFunction(pv, func))(pv, 0, ev3, i4);
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, int)>(__func)(pv, 0, ev3, i4);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, entvars_t *, int)>(GetFunction(pv, func))(pv, ev3, i4);
|
||||
reinterpret_cast<void (*)(void *, entvars_t *, int)>(__func)(pv, ev3, i4);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -163,9 +188,9 @@ cell Call_Int_Cbase(AMX *amx, cell *params)
|
||||
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, void *)>(GetFunction(pv, func))(pv, 0, pv1);
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, void *)>(GetFunction(pv, func))(pv, pv1);
|
||||
return reinterpret_cast<int (*)(void *, void *)>(__func)(pv, pv1);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -177,9 +202,9 @@ cell Call_Void_Int_Int(AMX *amx, cell *params)
|
||||
int i4=*MF_GetAmxAddr(amx, params[4]);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, int, int)>(GetFunction(pv, func))(pv, 0, i3, i4);
|
||||
reinterpret_cast<void (__fastcall *)(void*, int, int, int)>(__func)(pv, 0, i3, i4);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, int, int)>(GetFunction(pv, func))(pv, i3, i4);
|
||||
reinterpret_cast<void (*)(void *, int, int)>(__func)(pv, i3, i4);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
@@ -194,9 +219,9 @@ cell Call_Int_Int_Str_Int(AMX *amx, cell *params)
|
||||
int i5=*MF_GetAmxAddr(amx, params[5]);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, int, const char *, int)>(GetFunction(pv, func))(pv, 0, i3, sz4, i5);
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, int, const char *, int)>(__func)(pv, 0, i3, sz4, i5);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, int, const char *, int)>(GetFunction(pv, func))(pv, i3, sz4, i5);
|
||||
return reinterpret_cast<int (*)(void *, int, const char *, int)>(__func)(pv, i3, sz4, i5);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -207,9 +232,9 @@ cell Call_Int_Int(AMX *amx, cell *params)
|
||||
int i3=*MF_GetAmxAddr(amx, params[3]);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, int)>(GetFunction(pv, func))(pv, 0, i3);
|
||||
return reinterpret_cast<int (__fastcall *)(void*, int, int)>(__func)(pv, 0, i3);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, int)>(GetFunction(pv, func))(pv, i3);
|
||||
return reinterpret_cast<int (*)(void *, int)>(__func)(pv, i3);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -224,9 +249,9 @@ cell Call_Int_Entvar(AMX *amx, cell *params)
|
||||
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *)>(GetFunction(pv, func))(pv, 0, ev3);
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *)>(__func)(pv, 0, ev3);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, entvars_t *)>(GetFunction(pv, func))(pv, ev3);
|
||||
return reinterpret_cast<int (*)(void *, entvars_t *)>(__func)(pv, ev3);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -246,9 +271,9 @@ cell Call_Int_Entvar_Entvar_Float_Int(AMX *amx, cell *params)
|
||||
entvars_t *ev4=&(INDEXENT_NEW(id4)->v);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, int)>(GetFunction(pv, func))(pv, 0, ev3, ev4, f5, i6);
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, int)>(__func)(pv, 0, ev3, ev4, f5, i6);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, entvars_t *, entvars_t *, float, int)>(GetFunction(pv, func))(pv, ev3, ev4, f5, i6);
|
||||
return reinterpret_cast<int (*)(void *, entvars_t *, entvars_t *, float, int)>(__func)(pv, ev3, ev4, f5, i6);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -259,9 +284,9 @@ cell Call_Void_Int(AMX *amx, cell *params)
|
||||
int i3=*MF_GetAmxAddr(amx, params[3]);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, int)>(GetFunction(pv, func))(pv, 0, i3);
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, int)>(__func)(pv, 0, i3);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, int)>(GetFunction(pv, func))(pv, i3);
|
||||
reinterpret_cast<void (*)(void *, int)>(__func)(pv, i3);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -283,9 +308,9 @@ cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params)
|
||||
void *p4=IndexToPrivate(id4);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, void *, void *, int, float)>(GetFunction(pv, func))(pv, 0, p3, p4, i5, f6);
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, void *, void *, int, float)>(__func)(pv, 0, p3, p4, i5, f6);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, void *, void *, int, float)>(GetFunction(pv, func))(pv, p3, p4, i5, f6);
|
||||
reinterpret_cast<void (*)(void *, void *, void *, int, float)>(__func)(pv, p3, p4, i5, f6);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -317,9 +342,9 @@ cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params)
|
||||
|
||||
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, Vector, TraceResult *, int)>(GetFunction(pv, func))(pv, 0, ev3, f4, v5, tr6, i7);
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, Vector, TraceResult *, int)>(__func)(pv, 0, ev3, f4, v5, tr6, i7);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, entvars_t *, float, Vector, TraceResult *, int)>(GetFunction(pv, func))(pv, ev3, f4, v5, tr6, i7);
|
||||
reinterpret_cast<void (*)(void *, entvars_t *, float, Vector, TraceResult *, int)>(__func)(pv, ev3, f4, v5, tr6, i7);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -347,9 +372,9 @@ cell Call_Void_Float_Vector_TraceResult_Int(AMX *amx, cell *params)
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, float, Vector, TraceResult *, int)>(GetFunction(pv, func))(pv, 0, f3, v4, tr5, i6);
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, float, Vector, TraceResult *, int)>(__func)(pv, 0, f3, v4, tr5, i6);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, float, Vector, TraceResult *, int)>(GetFunction(pv, func))(pv, f3, v4, tr5, i6);
|
||||
reinterpret_cast<void (*)(void *, float, Vector, TraceResult *, int)>(__func)(pv, f3, v4, tr5, i6);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -360,9 +385,9 @@ cell Call_Str_Void(AMX *amx, cell *params)
|
||||
SETUP(2);
|
||||
|
||||
#ifdef _WIN32
|
||||
char *v=reinterpret_cast<char *(__fastcall *)(void *, int)>(GetFunction(pv, func))(pv, 0);
|
||||
char *v=reinterpret_cast<char *(__fastcall *)(void *, int)>(__func)(pv, 0);
|
||||
#elif defined __linux__
|
||||
char *v=reinterpret_cast<char *(*)(void *)>(GetFunction(pv, func))(pv);
|
||||
char *v=reinterpret_cast<char *(*)(void *)>(__func)(pv);
|
||||
#endif
|
||||
return MF_SetAmxString(amx, params[3], v == NULL ? "" : v, *MF_GetAmxAddr(amx, params[4]));
|
||||
|
||||
@@ -372,9 +397,9 @@ cell Call_Cbase_Void(AMX *amx, cell *params)
|
||||
{
|
||||
SETUP(0);
|
||||
#ifdef _WIN32
|
||||
void *ret=reinterpret_cast<void *(__fastcall *)(void *, int)>(GetFunction(pv, func))(pv, 0);
|
||||
void *ret=reinterpret_cast<void *(__fastcall *)(void *, int)>(__func)(pv, 0);
|
||||
#elif defined __linux__
|
||||
void *ret=reinterpret_cast<void *(*)(void *)>(GetFunction(pv, func))(pv);
|
||||
void *ret=reinterpret_cast<void *(*)(void *)>(__func)(pv);
|
||||
#endif
|
||||
return PrivateToIndex(ret);
|
||||
}
|
||||
@@ -383,9 +408,9 @@ cell Call_Vector_Void(AMX *amx, cell *params)
|
||||
{
|
||||
SETUP(1);
|
||||
#ifdef _WIN32
|
||||
Vector ret=reinterpret_cast<Vector (__fastcall *)(void *, int)>(GetFunction(pv, func))(pv, 0);
|
||||
Vector ret=reinterpret_cast<Vector (__fastcall *)(void *, int)>(__func)(pv, 0);
|
||||
#elif defined __linux__
|
||||
Vector ret=reinterpret_cast<Vector (*)(void *)>(GetFunction(pv, func))(pv);
|
||||
Vector ret=reinterpret_cast<Vector (*)(void *)>(__func)(pv);
|
||||
#endif
|
||||
float *out=(float *)MF_GetAmxAddr(amx, params[3]);
|
||||
out[0]=ret.x;
|
||||
@@ -406,9 +431,9 @@ cell Call_Vector_pVector(AMX *amx, cell *params)
|
||||
v3.z=fl3[2];
|
||||
|
||||
#ifdef _WIN32
|
||||
Vector ret=reinterpret_cast<Vector (__fastcall *)(void *, int, Vector*)>(GetFunction(pv, func))(pv, 0, &v3);
|
||||
Vector ret=reinterpret_cast<Vector (__fastcall *)(void *, int, Vector*)>(__func)(pv, 0, &v3);
|
||||
#elif defined __linux__
|
||||
Vector ret=reinterpret_cast<Vector (*)(void *, Vector*)>(GetFunction(pv, func))(pv, &v3);
|
||||
Vector ret=reinterpret_cast<Vector (*)(void *, Vector*)>(__func)(pv, &v3);
|
||||
#endif
|
||||
float *out=(float *)MF_GetAmxAddr(amx, params[4]);
|
||||
out[0]=ret.x;
|
||||
@@ -433,9 +458,9 @@ cell Call_Int_pVector(AMX *amx, cell *params)
|
||||
v3.z=fl3[2];
|
||||
|
||||
#ifdef _WIN32
|
||||
int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector*)>(GetFunction(pv, func))(pv, 0, &v3);
|
||||
int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector*)>(__func)(pv, 0, &v3);
|
||||
#elif defined __linux__
|
||||
int ret=reinterpret_cast<int (*)(void *, Vector*)>(GetFunction(pv, func))(pv, &v3);
|
||||
int ret=reinterpret_cast<int (*)(void *, Vector*)>(__func)(pv, &v3);
|
||||
#endif
|
||||
|
||||
fl3[0]=v3.x;
|
||||
@@ -458,9 +483,9 @@ cell Call_Void_Entvar_Float_Float(AMX *amx, cell *params)
|
||||
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
|
||||
|
||||
#ifdef _WIN32
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, float)>(GetFunction(pv, func))(pv, 0, ev3, f4, f5);
|
||||
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, float)>(__func)(pv, 0, ev3, f4, f5);
|
||||
#elif defined __linux__
|
||||
reinterpret_cast<void (*)(void *, entvars_t *, float, float)>(GetFunction(pv, func))(pv, ev3, f4, f5);
|
||||
reinterpret_cast<void (*)(void *, entvars_t *, float, float)>(__func)(pv, ev3, f4, f5);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@@ -474,9 +499,9 @@ cell Call_Int_pFloat_pFloat(AMX *amx, cell *params)
|
||||
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4]));
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, float*, float*)>(GetFunction(pv, func))(pv, 0, &f3, &f4);
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, float*, float*)>(__func)(pv, 0, &f3, &f4);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, float*, float*)>(GetFunction(pv, func))(pv, &f3, &f4);
|
||||
return reinterpret_cast<int (*)(void *, float*, float*)>(__func)(pv, &f3, &f4);
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -493,9 +518,9 @@ cell Call_Void_Entvar_Float(AMX *amx, cell *params)
|
||||
entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
|
||||
|
||||
#ifdef _WIN32
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t*, float)>(GetFunction(pv, func))(pv, 0, ev3, f4);
|
||||
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t*, float)>(__func)(pv, 0, ev3, f4);
|
||||
#elif defined __linux__
|
||||
return reinterpret_cast<int (*)(void *, entvars_t*, float)>(GetFunction(pv, func))(pv, ev3, f4);
|
||||
return reinterpret_cast<int (*)(void *, entvars_t*, float)>(__func)(pv, ev3, f4);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user