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:
Steve Dudenhoeffer 2007-05-07 13:51:40 +00:00
parent 1f1ecfa590
commit 4e2493759e
6 changed files with 201 additions and 67 deletions

View File

@ -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); 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) inline void *_GetFunction(void *pthis, int id)
{ {
@ -54,7 +73,13 @@ inline void *_GetFunction(void *pthis, int id)
int id=params[2]; \ int id=params[2]; \
CHECK_FUNCTION(func); \ CHECK_FUNCTION(func); \
CHECK_ENTITY(id); \ 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) cell Call_Void_Void(AMX *amx, cell *params)
@ -62,9 +87,9 @@ cell Call_Void_Void(AMX *amx, cell *params)
SETUP(0); SETUP(0);
#ifdef _WIN32 #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__ #elif defined __linux__
reinterpret_cast<void (*)(void *)>(GetFunction(pv, func))(pv); reinterpret_cast<void (*)(void *)>(__func)(pv);
#endif #endif
return 1; return 1;
} }
@ -74,9 +99,9 @@ cell Call_Int_Void(AMX *amx, cell *params)
SETUP(0); SETUP(0);
#ifdef _WIN32 #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__ #elif defined __linux__
return reinterpret_cast<int (*)(void *)>(GetFunction(pv, func))(pv); return reinterpret_cast<int (*)(void *)>(__func)(pv);
#endif #endif
} }
@ -91,9 +116,9 @@ cell Call_Void_Entvar(AMX *amx, cell *params)
entvars_t *ev1=&(INDEXENT_NEW(id3)->v); entvars_t *ev1=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32 #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__ #elif defined __linux__
reinterpret_cast<void (*)(void *, entvars_t *)>(GetFunction(pv, func))(pv, ev1); reinterpret_cast<void (*)(void *, entvars_t *)>(__func)(pv, ev1);
#endif #endif
return 1; return 1;
} }
@ -110,9 +135,9 @@ cell Call_Void_Cbase(AMX *amx, cell *params)
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); void *pv1=(INDEXENT_NEW(id3)->pvPrivateData);
#ifdef _WIN32 #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__ #elif defined __linux__
reinterpret_cast<void (*)(void *, void *)>(GetFunction(pv, func))(pv, pv1); reinterpret_cast<void (*)(void *, void *)>(__func)(pv, pv1);
#endif #endif
return 1; return 1;
} }
@ -125,9 +150,9 @@ cell Call_Int_Float_Int(AMX *amx, cell *params)
int i4=*MF_GetAmxAddr(amx, params[4]); int i4=*MF_GetAmxAddr(amx, params[4]);
#ifdef _WIN32 #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__ #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 #endif
} }
@ -144,9 +169,9 @@ cell Call_Void_Entvar_Int(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32 #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__ #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 #endif
return 1; return 1;
} }
@ -163,9 +188,9 @@ cell Call_Int_Cbase(AMX *amx, cell *params)
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); void *pv1=(INDEXENT_NEW(id3)->pvPrivateData);
#ifdef _WIN32 #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__ #elif defined __linux__
return reinterpret_cast<int (*)(void *, void *)>(GetFunction(pv, func))(pv, pv1); return reinterpret_cast<int (*)(void *, void *)>(__func)(pv, pv1);
#endif #endif
} }
@ -177,9 +202,9 @@ cell Call_Void_Int_Int(AMX *amx, cell *params)
int i4=*MF_GetAmxAddr(amx, params[4]); int i4=*MF_GetAmxAddr(amx, params[4]);
#ifdef _WIN32 #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__ #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 #endif
return 1; return 1;
} }
@ -194,9 +219,9 @@ cell Call_Int_Int_Str_Int(AMX *amx, cell *params)
int i5=*MF_GetAmxAddr(amx, params[5]); int i5=*MF_GetAmxAddr(amx, params[5]);
#ifdef _WIN32 #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__ #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 #endif
} }
@ -207,9 +232,9 @@ cell Call_Int_Int(AMX *amx, cell *params)
int i3=*MF_GetAmxAddr(amx, params[3]); int i3=*MF_GetAmxAddr(amx, params[3]);
#ifdef _WIN32 #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__ #elif defined __linux__
return reinterpret_cast<int (*)(void *, int)>(GetFunction(pv, func))(pv, i3); return reinterpret_cast<int (*)(void *, int)>(__func)(pv, i3);
#endif #endif
} }
@ -224,9 +249,9 @@ cell Call_Int_Entvar(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32 #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__ #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 #endif
} }
@ -246,9 +271,9 @@ cell Call_Int_Entvar_Entvar_Float_Int(AMX *amx, cell *params)
entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev4=&(INDEXENT_NEW(id4)->v);
#ifdef _WIN32 #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__ #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 #endif
} }
@ -259,9 +284,9 @@ cell Call_Void_Int(AMX *amx, cell *params)
int i3=*MF_GetAmxAddr(amx, params[3]); int i3=*MF_GetAmxAddr(amx, params[3]);
#ifdef _WIN32 #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__ #elif defined __linux__
reinterpret_cast<void (*)(void *, int)>(GetFunction(pv, func))(pv, i3); reinterpret_cast<void (*)(void *, int)>(__func)(pv, i3);
#endif #endif
return 1; return 1;
@ -283,9 +308,9 @@ cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params)
void *p4=IndexToPrivate(id4); void *p4=IndexToPrivate(id4);
#ifdef _WIN32 #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__ #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 #endif
return 1; 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); entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32 #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__ #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 #endif
return 1; return 1;
@ -347,9 +372,9 @@ cell Call_Void_Float_Vector_TraceResult_Int(AMX *amx, cell *params)
} }
#ifdef _WIN32 #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__ #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 #endif
return 1; return 1;
@ -360,9 +385,9 @@ cell Call_Str_Void(AMX *amx, cell *params)
SETUP(2); SETUP(2);
#ifdef _WIN32 #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__ #elif defined __linux__
char *v=reinterpret_cast<char *(*)(void *)>(GetFunction(pv, func))(pv); char *v=reinterpret_cast<char *(*)(void *)>(__func)(pv);
#endif #endif
return MF_SetAmxString(amx, params[3], v == NULL ? "" : v, *MF_GetAmxAddr(amx, params[4])); 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); SETUP(0);
#ifdef _WIN32 #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__ #elif defined __linux__
void *ret=reinterpret_cast<void *(*)(void *)>(GetFunction(pv, func))(pv); void *ret=reinterpret_cast<void *(*)(void *)>(__func)(pv);
#endif #endif
return PrivateToIndex(ret); return PrivateToIndex(ret);
} }
@ -383,9 +408,9 @@ cell Call_Vector_Void(AMX *amx, cell *params)
{ {
SETUP(1); SETUP(1);
#ifdef _WIN32 #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__ #elif defined __linux__
Vector ret=reinterpret_cast<Vector (*)(void *)>(GetFunction(pv, func))(pv); Vector ret=reinterpret_cast<Vector (*)(void *)>(__func)(pv);
#endif #endif
float *out=(float *)MF_GetAmxAddr(amx, params[3]); float *out=(float *)MF_GetAmxAddr(amx, params[3]);
out[0]=ret.x; out[0]=ret.x;
@ -406,9 +431,9 @@ cell Call_Vector_pVector(AMX *amx, cell *params)
v3.z=fl3[2]; v3.z=fl3[2];
#ifdef _WIN32 #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__ #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 #endif
float *out=(float *)MF_GetAmxAddr(amx, params[4]); float *out=(float *)MF_GetAmxAddr(amx, params[4]);
out[0]=ret.x; out[0]=ret.x;
@ -433,9 +458,9 @@ cell Call_Int_pVector(AMX *amx, cell *params)
v3.z=fl3[2]; v3.z=fl3[2];
#ifdef _WIN32 #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__ #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 #endif
fl3[0]=v3.x; 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); entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32 #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__ #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 #endif
return 1; return 1;
@ -474,9 +499,9 @@ cell Call_Int_pFloat_pFloat(AMX *amx, cell *params)
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4]));
#ifdef _WIN32 #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__ #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 #endif
} }
@ -493,9 +518,9 @@ cell Call_Void_Entvar_Float(AMX *amx, cell *params)
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3=&(INDEXENT_NEW(id3)->v);
#ifdef _WIN32 #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__ #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 #endif
} }

View File

@ -255,6 +255,10 @@ void process_key(char *data)
size++; size++;
} }
if (size==0)
{
return;
}
int set=0; int set=0;
for (int i=0; i< HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++) for (int i=0; i< HAM_LAST_ENTRY_DONT_USE_ME_LOL; i++)
{ {

View File

@ -61,8 +61,11 @@ public:
#endif #endif
ivtable[entry]=(int *)func; ivtable[entry]=(int *)func;
#if defined _WIN32
VirtualFree(tramp, 0, MEM_RELEASE);
#elif __linux__
free(tramp); free(tramp);
#endif
delete[] ent; delete[] ent;
@ -74,6 +77,15 @@ public:
{ {
delete (*i); delete (*i);
} }
end=post.end();
for (CVector<Forward *>::iterator i=post.begin();
i!=end;
++i)
{
delete (*i);
}
pre.clear();
post.clear();
} }
}; };

View File

@ -20,7 +20,7 @@
OffsetManager Offsets; OffsetManager Offsets;
bool gDoForwards=false; bool gDoForwards=true;
CVector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL]; CVector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];

View File

@ -62,6 +62,10 @@
* *
* - All functions take (and pass) a "this" index as the first param. * - All functions take (and pass) a "this" index as the first param.
* This is the entity from which the function is being executed on. * This is the entity from which the function is being executed on.
*
* - All functions and forwards (eg: {Register,Execute}Ham[B]) require
* the mod to have the pev and base keys in addition to the function
* keys for the corresponding mod/operating system in hamdata.ini
*/ */
enum Ham enum Ham
@ -69,7 +73,9 @@ enum Ham
/** /**
* Description: This is typically called whenever an entity is created. * Description: This is typically called whenever an entity is created.
* It is the virtual equivilent of spawn from the engine. * It is the virtual equivilent of spawn from the engine.
* Some mods call this on player spawns too.
* Forward params: function(this) * Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Spawn, this); * Execute params: ExecuteHam(Ham_Spawn, this);
*/ */
Ham_Spawn = 0, Ham_Spawn = 0,
@ -78,6 +84,7 @@ enum Ham
* Description: This is typically called on map change. * Description: This is typically called on map change.
* This will typically precache all assets required by the entity. * This will typically precache all assets required by the entity.
* Forward params: function(this) * Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Precache, this); * Execute params: ExecuteHam(Ham_Precache, this);
*/ */
Ham_Precache, Ham_Precache,
@ -87,12 +94,15 @@ enum Ham
* Use the kvd natives from fakemeta to handle the kvd_handle passed. * Use the kvd natives from fakemeta to handle the kvd_handle passed.
* NOTE: Do not pass handle 0 to this! Use get_kvd_handle(0) from fakemeta instead! * NOTE: Do not pass handle 0 to this! Use get_kvd_handle(0) from fakemeta instead!
* Forward params: function(this, kvd_handle); * Forward params: function(this, kvd_handle);
* Return type: None.
* Execute params: ExecuteHam(Ham_Keyvalue, this, kvd_handle);
*/ */
Ham_Keyvalue, Ham_Keyvalue,
/** /**
* Description: Returns flags for how an entity can be used (FCAP_* constants in hlsdk_const.inc) * Description: Returns flags for how an entity can be used (FCAP_* constants in hlsdk_const.inc)
* Forward params: function(this) * Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_ObjectCaps, this); * Execute params: ExecuteHam(Ham_ObjectCaps, this);
*/ */
Ham_ObjectCaps, Ham_ObjectCaps,
@ -100,6 +110,7 @@ enum Ham
/** /**
* Description: Usually called to activate some objects. * Description: Usually called to activate some objects.
* Forward params: function(this) * Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Activate, this); * Execute params: ExecuteHam(Ham_Activate, this);
*/ */
Ham_Activate, Ham_Activate,
@ -107,6 +118,7 @@ enum Ham
/** /**
* Description: Usually called after the engine call with the same name. * Description: Usually called after the engine call with the same name.
* Forward params: function(this) * Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_SetObjectCollisionBox, this); * Execute params: ExecuteHam(Ham_SetObjectCollisionBox, this);
*/ */
Ham_SetObjectCollisionBox, Ham_SetObjectCollisionBox,
@ -114,6 +126,7 @@ enum Ham
/** /**
* Description: Returns an integer number that corresponds with what type of entity this is. * Description: Returns an integer number that corresponds with what type of entity this is.
* Forward params: function(this) * Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_Classify, this); * Execute params: ExecuteHam(Ham_Classify, this);
*/ */
Ham_Classify, Ham_Classify,
@ -121,6 +134,7 @@ enum Ham
/** /**
* Description: Typically called when an entity dies to notify any children entities about the death. * Description: Typically called when an entity dies to notify any children entities about the death.
* Forward params: function(this, idchild) * Forward params: function(this, idchild)
* Return type: None.
* Execute params: ExecuteHam(Ham_DeathNotice, this, idchild) * Execute params: ExecuteHam(Ham_DeathNotice, this, idchild)
*/ */
Ham_DeathNotice, Ham_DeathNotice,
@ -130,6 +144,7 @@ enum Ham
* Use the get/set tr2 natives in fakemeta to handle the traceresult data. * Use the get/set tr2 natives in fakemeta to handle the traceresult data.
* Do not use a handle of 0 as a traceresult in execution, use get_tr_handle(0) instead. * Do not use a handle of 0 as a traceresult in execution, use get_tr_handle(0) instead.
* Forward params: function(this, idattacker, Float:damage, Float:direction[3], traceresult, damagebits) * Forward params: function(this, idattacker, Float:damage, Float:direction[3], traceresult, damagebits)
* Return type: None.
* Execute params: ExecuteHam(Ham_TraceAttack, this, idattacker, Float:damage, Float:direction[3], tracehandle, damagebits); * Execute params: ExecuteHam(Ham_TraceAttack, this, idattacker, Float:damage, Float:direction[3], tracehandle, damagebits);
*/ */
Ham_TraceAttack, Ham_TraceAttack,
@ -139,6 +154,7 @@ enum Ham
* Inflictor is the entity that caused the damage (such as a gun). * Inflictor is the entity that caused the damage (such as a gun).
* Attacker is the entity that tirggered the damage (such as the gun's owner). * Attacker is the entity that tirggered the damage (such as the gun's owner).
* Forward params: function(this, idinflictor, idattacker, Float:damage, damagebits); * Forward params: function(this, idinflictor, idattacker, Float:damage, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits); * Execute params: ExecuteHam(Ham_TakeDamage, this, idinflictor, idattacker, Float:damage, damagebits);
*/ */
Ham_TakeDamage, Ham_TakeDamage,
@ -146,6 +162,7 @@ enum Ham
/** /**
* Description: Usually called whenever an entity gets a form of a heal. * Description: Usually called whenever an entity gets a form of a heal.
* Forward params: function(this, Float:health, damagebits); * Forward params: function(this, Float:health, damagebits);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_TakeHealth, this, Float:health, damagebits); * Execute params: ExecuteHam(Ham_TakeHealth, this, Float:health, damagebits);
*/ */
Ham_TakeHealth, Ham_TakeHealth,
@ -153,6 +170,7 @@ enum Ham
/** /**
* Description: Normally called whenever an entity dies. * Description: Normally called whenever an entity dies.
* Forward params: function(this, idattacker, shouldgib) * Forward params: function(this, idattacker, shouldgib)
* Return type: None.
* Execute params: ExecuteHam(Ham_Killed, this, idattacker, shouldgib); * Execute params: ExecuteHam(Ham_Killed, this, idattacker, shouldgib);
*/ */
Ham_Killed, Ham_Killed,
@ -160,6 +178,7 @@ enum Ham
/** /**
* Description: Normally returns the blood color of the entity. * Description: Normally returns the blood color of the entity.
* Forward params: function(this) * Forward params: function(this)
* Return type: Integer.
* Execute params: ExecuteHam(Ham_BloodColor, this) * Execute params: ExecuteHam(Ham_BloodColor, this)
*/ */
Ham_BloodColor, Ham_BloodColor,
@ -168,9 +187,37 @@ enum Ham
Ham_TraceBleed, Ham_TraceBleed,
Ham_IsTriggered, Ham_IsTriggered,
Ham_GetToggleState, Ham_GetToggleState,
/**
* Description: Typically adds points to the entity.
* Forward params: function(this, points, bool:cangonegative);
* Return type: None.
* Execute params: ExecuteHam(Ham_BloodColor, this, points, bool:cangonegative);
*/
Ham_AddPoints, Ham_AddPoints,
/**
* Description: Typically adds points to the entity's team.
* Forward params: function(this, points, bool:cangonegative);
* Return type: None.
* Execute params: ExecuteHam(Ham_BloodColor, this, points, bool:cangonegative);
*/
Ham_AddPointsToTeam, Ham_AddPointsToTeam,
/**
* Description: Adds an item to the player's inventory.
* Forward params: function(this, idother);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_AddPlayerItem, this, idother);
*/
Ham_AddPlayerItem, Ham_AddPlayerItem,
/**
* Description: Removes an item to the player's inventory.
* Forward params: function(this, idother);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_RemovePlayerItem, this, idother);
*/
Ham_RemovePlayerItem, Ham_RemovePlayerItem,
Ham_GiveAmmo, Ham_GiveAmmo,
Ham_GetDelay, Ham_GetDelay,
@ -178,6 +225,7 @@ enum Ham
/** /**
* Description: Whether or not the entity is moving. * Description: Whether or not the entity is moving.
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsMoving, this); * Execute params: ExecuteHam(Ham_IsMoving, this);
*/ */
Ham_IsMoving, Ham_IsMoving,
@ -188,6 +236,7 @@ enum Ham
/** /**
* Description: Not entirely sure what this does. * Description: Not entirely sure what this does.
* Forward params: function(this) * Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_StartSneaking, this); * Execute params: ExecuteHam(Ham_StartSneaking, this);
*/ */
Ham_StartSneaking, Ham_StartSneaking,
@ -195,6 +244,7 @@ enum Ham
/** /**
* Description: Not entirely sure what this does. * Description: Not entirely sure what this does.
* Forward params: function(this) * Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_StopSneaking, this); * Execute params: ExecuteHam(Ham_StopSneaking, this);
*/ */
Ham_StopSneaking, Ham_StopSneaking,
@ -203,6 +253,7 @@ enum Ham
/** /**
* Description: Whether or not the entity is sneaking. * Description: Whether or not the entity is sneaking.
* Forward params: function(this); * Forward params: function(this);
* Return type: None.
* Execute params: ExecuteHam(Ham_IsSneaking, this); * Execute params: ExecuteHam(Ham_IsSneaking, this);
*/ */
Ham_IsSneaking, Ham_IsSneaking,
@ -210,6 +261,7 @@ enum Ham
/** /**
* Description: Whether or not the entity is alive. * Description: Whether or not the entity is alive.
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsAlive, this); * Execute params: ExecuteHam(Ham_IsAlive, this);
*/ */
Ham_IsAlive, Ham_IsAlive,
@ -217,6 +269,7 @@ enum Ham
/** /**
* Description: Whether or not the entity uses a BSP model. * Description: Whether or not the entity uses a BSP model.
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsBSPModel, this); * Execute params: ExecuteHam(Ham_IsBSPModel, this);
*/ */
Ham_IsBSPModel, Ham_IsBSPModel,
@ -224,6 +277,7 @@ enum Ham
/** /**
* Description: Whether or not the entity can reflect gauss shots.. * Description: Whether or not the entity can reflect gauss shots..
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_ReflectGauss, this); * Execute params: ExecuteHam(Ham_ReflectGauss, this);
*/ */
Ham_ReflectGauss, Ham_ReflectGauss,
@ -232,6 +286,7 @@ enum Ham
/** /**
* Description: Whether or not the entity is in the world. * Description: Whether or not the entity is in the world.
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsInWorld, this); * Execute params: ExecuteHam(Ham_IsInWorld, this);
*/ */
Ham_IsInWorld, Ham_IsInWorld,
@ -239,6 +294,7 @@ enum Ham
/** /**
* Description: Whether or not the entity is a player. * Description: Whether or not the entity is a player.
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsPlayer, this); * Execute params: ExecuteHam(Ham_IsPlayer, this);
*/ */
Ham_IsPlayer, Ham_IsPlayer,
@ -246,6 +302,7 @@ enum Ham
/** /**
* Description: Whether or not the entity is a net client. * Description: Whether or not the entity is a net client.
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_IsNetClient, this); * Execute params: ExecuteHam(Ham_IsNetClient, this);
*/ */
Ham_IsNetClient, Ham_IsNetClient,
@ -253,6 +310,7 @@ enum Ham
/** /**
* Description: Get the entity's team id. * Description: Get the entity's team id.
* Forward params: function(this); * Forward params: function(this);
* Return type: String (string length returned and string byref'd in ExecuteHam).
* Execute params: ExecuteHam(Ham_IsPlayer, this, buffer[], size); * Execute params: ExecuteHam(Ham_IsPlayer, this, buffer[], size);
*/ */
Ham_TeamId, Ham_TeamId,
@ -267,6 +325,7 @@ enum Ham
/** /**
* Description: Called whenever an entity thinks. * Description: Called whenever an entity thinks.
* Forward params: function(this) * Forward params: function(this)
* Return type: None.
* Execute params: ExecuteHam(Ham_Think, this); * Execute params: ExecuteHam(Ham_Think, this);
*/ */
Ham_Think, Ham_Think,
@ -274,6 +333,7 @@ enum Ham
/** /**
* Description: Called whenever two entities touch. * Description: Called whenever two entities touch.
* Forward params: function(this, idother); * Forward params: function(this, idother);
* Return type: None.
* Execute params: ExecuteHam(Ham_Touch, this, idother); * Execute params: ExecuteHam(Ham_Touch, this, idother);
*/ */
Ham_Touch, Ham_Touch,
@ -281,6 +341,7 @@ enum Ham
/** /**
* Description: Called whenver one entity uses another. * Description: Called whenver one entity uses another.
* Forward params: function(this, idcaller, idactivator, use_type, Float:value) * Forward params: function(this, idcaller, idactivator, use_type, Float:value)
* Return type: None.
* Execute params: ExecuteHam(Ham_Use, this, idcaller, idactivator, use_type, Float:value); * Execute params: ExecuteHam(Ham_Use, this, idcaller, idactivator, use_type, Float:value);
*/ */
Ham_Use, Ham_Use,
@ -288,6 +349,7 @@ enum Ham
/** /**
* Description: Normally called whenever one entity blocks another from moving. * Description: Normally called whenever one entity blocks another from moving.
* Forward params: function(this, idother); * Forward params: function(this, idother);
* Return type: None.
* Execute params: ExecuteHam(Ham_Blocked, this, idother); * Execute params: ExecuteHam(Ham_Blocked, this, idother);
*/ */
Ham_Blocked, Ham_Blocked,
@ -295,6 +357,7 @@ enum Ham
/** /**
* Description: Normally called when a map-based item respawns, such as a health kit or something. * Description: Normally called when a map-based item respawns, such as a health kit or something.
* Forward params: function(this); * Forward params: function(this);
* Return type: CBaseEntity.
* Execute params: ExecuteHam(Ham_Respawn, this); * Execute params: ExecuteHam(Ham_Respawn, this);
*/ */
Ham_Respawn, Ham_Respawn,
@ -302,6 +365,7 @@ enum Ham
/** /**
* Description: Used in Half-Life to update a monster's owner. * Description: Used in Half-Life to update a monster's owner.
* Forward params: function(this); * Forward params: function(this);
* Return type: None.
* Execute params: ExecuteHam(Ham_UpdateOwner, this); * Execute params: ExecuteHam(Ham_UpdateOwner, this);
*/ */
Ham_UpdateOwner, Ham_UpdateOwner,
@ -309,6 +373,7 @@ enum Ham
/** /**
* Description: Normally called whenever a barnacle grabs the entity. * Description: Normally called whenever a barnacle grabs the entity.
* Forward params: function(this); * Forward params: function(this);
* Return type: Integer.
* Execute params: ExecuteHam(Ham_FBecomeProne, this); * Execute params: ExecuteHam(Ham_FBecomeProne, this);
*/ */
Ham_FBecomeProne, Ham_FBecomeProne,
@ -316,6 +381,7 @@ enum Ham
/** /**
* Description: Returns the center of the entity. * Description: Returns the center of the entity.
* Forward params: function(this); * Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_Center, this, Float:output[3]); * Execute params: ExecuteHam(Ham_Center, this, Float:output[3]);
*/ */
Ham_Center, Ham_Center,
@ -323,6 +389,7 @@ enum Ham
/** /**
* Description: Returns the eye position of the entity. * Description: Returns the eye position of the entity.
* Forward params: function(this); * Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_EyePosition, this, Float:output[3]); * Execute params: ExecuteHam(Ham_EyePosition, this, Float:output[3]);
*/ */
Ham_EyePosition, Ham_EyePosition,
@ -330,9 +397,17 @@ enum Ham
/** /**
* Description: Returns the ear position of the entity. * Description: Returns the ear position of the entity.
* Forward params: function(this); * Forward params: function(this);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_EarPosition, this, Float:output[3]); * Execute params: ExecuteHam(Ham_EarPosition, this, Float:output[3]);
*/ */
Ham_EarPosition, Ham_EarPosition,
/**
* Description: Position to shoot at.
* Forward params: function(this, Float:srcvector[3]);
* Return type: Vector (byref'd in Execute).
* Execute params: ExecuteHam(Ham_BodyTarget, Float:srcvector[3], Float:returnvector[3])
*/
Ham_BodyTarget, Ham_BodyTarget,
Ham_Illumination, Ham_Illumination,
Ham_FVisible, Ham_FVisible,
@ -390,8 +465,6 @@ enum Ham
* @param entity The entity classname to hook. * @param entity The entity classname to hook.
* @param post Whether or not to forward this in post. * @param post Whether or not to forward this in post.
*/ */
native RegisterHam(Ham:function, const callback[], const entity[], post=0); native RegisterHam(Ham:function, const callback[], const entity[], post=0);
/** /**
@ -425,6 +498,37 @@ native ExecuteHamB(Ham:function, this, any:...);
*/ */
native bool:IsHamValid(Ham:function); native bool:IsHamValid(Ham:function);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev field set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
* This will return an index of the corresponding cbase field in private data.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param linuxdiff The linux difference of the data.
* @return The index of the corresponding pdata field. -1 for none set.
*/
native get_pdata_cbase(id, offset, linuxdiff=5);
/**
* This is used to compliment fakemeta's {get,set}_pdata_{int,float,string}.
* This requires the mod to have the pev field set in hamdata.ini.
* Note this dereferences memory! Improper use of this will crash the server.
* This will set the corresponding cbase field in private data with the index.
*
* @param id The entity to examine the private data.
* @param offset The windows offset of the data.
* @param value The index to store.
* @param linuxdiff The linux difference of the data.
* @return The index of the corresponding pdata field. -1 for none set.
*/
native set_pdata_cbase(id, offset, value, linuxdiff=5);
enum HamError enum HamError
{ {

View File

@ -94,6 +94,7 @@
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
CommandLine="copy $(OutDir)\hamsandwich_amxx.dll c:\hlds\cstrike\addons\amxmodx\modules"
/> />
</Configuration> </Configuration>
<Configuration <Configuration
@ -190,14 +191,6 @@
RelativePath="..\call_funcs.h" RelativePath="..\call_funcs.h"
> >
</File> </File>
<File
RelativePath="..\ecall_funcs.cpp"
>
</File>
<File
RelativePath="..\ecall_funcs.h"
>
</File>
<File <File
RelativePath="..\forward.h" RelativePath="..\forward.h"
> >
@ -259,10 +252,6 @@
> >
</File> </File>
</Filter> </Filter>
<Filter
Name="Calls"
>
</Filter>
<Filter <Filter
Name="Config File" Name="Config File"
> >