Consistency: Replace GETEDICT, INDEXENT2 and others things with HLTypeConversion in hamsandwich module

This commit is contained in:
Arkshine 2015-10-07 17:31:28 +02:00
parent bf5fdc2b5c
commit 6f301b5cea
20 changed files with 252 additions and 407 deletions

View File

@ -9,6 +9,7 @@ binary.compiler.defines += [
binary.sources = [ binary.sources = [
'../../public/sdk/amxxmodule.cpp', '../../public/sdk/amxxmodule.cpp',
'../../public/memtools/MemoryUtils.cpp',
'dllfunc.cpp', 'dllfunc.cpp',
'engfunc.cpp', 'engfunc.cpp',
'fakemeta_amxx.cpp', 'fakemeta_amxx.cpp',

View File

@ -96,6 +96,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\public\memtools\MemoryUtils.cpp" />
<ClCompile Include="..\fakemeta_amxx.cpp" /> <ClCompile Include="..\fakemeta_amxx.cpp" />
<ClCompile Include="..\fm_tr.cpp" /> <ClCompile Include="..\fm_tr.cpp" />
<ClCompile Include="..\fm_tr2.cpp" /> <ClCompile Include="..\fm_tr2.cpp" />
@ -111,6 +112,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\public\HLTypeConversion.h" /> <ClInclude Include="..\..\..\public\HLTypeConversion.h" />
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\fakemeta_amxx.h" /> <ClInclude Include="..\fakemeta_amxx.h" />
<ClInclude Include="..\fm_tr.h" /> <ClInclude Include="..\fm_tr.h" />
<ClInclude Include="..\dllfunc.h" /> <ClInclude Include="..\dllfunc.h" />

View File

@ -33,6 +33,9 @@
<Filter Include="Pawn Includes"> <Filter Include="Pawn Includes">
<UniqueIdentifier>{65d8835f-89cd-44ab-b2ac-83617ab4d7b3}</UniqueIdentifier> <UniqueIdentifier>{65d8835f-89cd-44ab-b2ac-83617ab4d7b3}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Memtools">
<UniqueIdentifier>{e1b28b22-6fde-4e1f-a982-f37dec584571}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\fakemeta_amxx.cpp"> <ClCompile Include="..\fakemeta_amxx.cpp">
@ -71,6 +74,9 @@
<ClCompile Include="..\pdata_gc.cpp"> <ClCompile Include="..\pdata_gc.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\public\memtools\MemoryUtils.cpp">
<Filter>Memtools</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\fakemeta_amxx.h"> <ClInclude Include="..\fakemeta_amxx.h">
@ -109,6 +115,9 @@
<ClInclude Include="..\..\..\public\HLTypeConversion.h"> <ClInclude Include="..\..\..\public\HLTypeConversion.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h">
<Filter>Memtools</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\..\plugins\include\fakemeta.inc"> <None Include="..\..\..\plugins\include\fakemeta.inc">

View File

@ -5,6 +5,7 @@ binary = AMXX.MetaModule(builder, 'fun')
binary.sources = [ binary.sources = [
'../../public/sdk/amxxmodule.cpp', '../../public/sdk/amxxmodule.cpp',
'../../public/memtools/MemoryUtils.cpp',
'fun.cpp', 'fun.cpp',
] ]

View File

@ -141,11 +141,13 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\public\memtools\MemoryUtils.cpp" />
<ClCompile Include="..\fun.cpp" /> <ClCompile Include="..\fun.cpp" />
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp" /> <ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\public\HLTypeConversion.h" /> <ClInclude Include="..\..\..\public\HLTypeConversion.h" />
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\fun.h" /> <ClInclude Include="..\fun.h" />
<ClInclude Include="..\moduleconfig.h" /> <ClInclude Include="..\moduleconfig.h" />
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h" /> <ClInclude Include="..\..\..\public\sdk\amxxmodule.h" />

View File

@ -18,6 +18,9 @@
<Filter Include="Pawn Includes"> <Filter Include="Pawn Includes">
<UniqueIdentifier>{2256d296-4d3f-4321-8afb-8ff5dff8053f}</UniqueIdentifier> <UniqueIdentifier>{2256d296-4d3f-4321-8afb-8ff5dff8053f}</UniqueIdentifier>
</Filter> </Filter>
<Filter Include="Memtools">
<UniqueIdentifier>{d2522a66-df9f-49c8-9f74-ee3738ae3d98}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\fun.cpp"> <ClCompile Include="..\fun.cpp">
@ -26,6 +29,9 @@
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp"> <ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp">
<Filter>Module SDK\SDK Base</Filter> <Filter>Module SDK\SDK Base</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\public\memtools\MemoryUtils.cpp">
<Filter>Memtools</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\fun.h"> <ClInclude Include="..\fun.h">
@ -40,6 +46,9 @@
<ClInclude Include="..\..\..\public\HLTypeConversion.h"> <ClInclude Include="..\..\..\public\HLTypeConversion.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h">
<Filter>Memtools</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\..\plugins\include\fun.inc"> <None Include="..\..\..\plugins\include\fun.inc">

View File

@ -9,6 +9,7 @@ binary.compiler.defines += [
binary.sources = [ binary.sources = [
'../../public/sdk/amxxmodule.cpp', '../../public/sdk/amxxmodule.cpp',
'../../public/memtools/MemoryUtils.cpp',
'amxx_api.cpp', 'amxx_api.cpp',
'config_parser.cpp', 'config_parser.cpp',
'hook_callbacks.cpp', 'hook_callbacks.cpp',

View File

@ -20,7 +20,6 @@
#include "ham_const.h" #include "ham_const.h"
#include "ham_utils.h" #include "ham_utils.h"
#include "NEW_Util.h"
CStack< Data * > ReturnStack; CStack< Data * > ReturnStack;
CStack< Data * > OrigReturnStack; CStack< Data * > OrigReturnStack;

View File

@ -151,7 +151,7 @@ public:
{ {
return -1; return -1;
} }
*(reinterpret_cast<REAL *>(m_data))=amx_ctof2(*data); *(reinterpret_cast<REAL *>(m_data))=amx_ctof(*data);
return 0; return 0;
}; };
@ -167,9 +167,9 @@ public:
} }
Vector *vec=reinterpret_cast<Vector *>(m_data); Vector *vec=reinterpret_cast<Vector *>(m_data);
vec->x=amx_ctof2(data[0]); vec->x=amx_ctof(data[0]);
vec->y=amx_ctof2(data[1]); vec->y=amx_ctof(data[1]);
vec->z=amx_ctof2(data[2]); vec->z=amx_ctof(data[2]);
return 0; return 0;
}; };
@ -218,7 +218,7 @@ public:
} }
if (IsType(RET_CBASE)) if (IsType(RET_CBASE))
{ {
*(reinterpret_cast<void **>(m_data))=IndexToPrivate(*data); *(reinterpret_cast<void **>(m_data))= TypeConversion.id_to_cbase(*data);
if (m_index != 0) if (m_index != 0)
{ {
*m_index=*data; *m_index=*data;
@ -228,7 +228,7 @@ public:
} }
else if (IsType(RET_ENTVAR)) else if (IsType(RET_ENTVAR))
{ {
*(reinterpret_cast<entvars_t **>(m_data))=IndexToEntvar(*data); *(reinterpret_cast<entvars_t **>(m_data))= TypeConversion.id_to_entvars(*data);
if (m_index != 0) if (m_index != 0)
{ {
*m_index=*data; *m_index=*data;
@ -238,7 +238,7 @@ public:
} }
else if (IsType(RET_EDICT)) else if (IsType(RET_EDICT))
{ {
*(reinterpret_cast<edict_t **>(m_data)) = IndexToEdict(*data); *(reinterpret_cast<edict_t **>(m_data)) = TypeConversion.id_to_edict(*data);
if (m_index != 0) if (m_index != 0)
{ {
*m_index = *data; *m_index = *data;
@ -299,7 +299,7 @@ public:
{ {
return -1; return -1;
} }
*data=amx_ftoc2(*(reinterpret_cast<REAL *>(m_data))); *data=amx_ftoc(*(reinterpret_cast<REAL *>(m_data)));
return 0; return 0;
}; };
@ -314,9 +314,9 @@ public:
return -1; return -1;
} }
Vector *vec=reinterpret_cast<Vector *>(m_data); Vector *vec=reinterpret_cast<Vector *>(m_data);
data[0]=amx_ftoc2(vec->x); data[0]=amx_ftoc(vec->x);
data[1]=amx_ftoc2(vec->y); data[1]=amx_ftoc(vec->y);
data[2]=amx_ftoc2(vec->z); data[2]=amx_ftoc(vec->z);
return 0; return 0;
}; };
@ -332,7 +332,7 @@ public:
} }
const char *i=(reinterpret_cast<ke::AString *>(m_data)->chars()); const char *i=(reinterpret_cast<ke::AString *>(m_data)->chars());
while (len-- && while (len-- &&
(*data++=*i++)!='\0') (*data++=*i++)!='\0')
{ {
/* nothing */ /* nothing */
@ -347,19 +347,19 @@ public:
} }
if (IsType(RET_CBASE)) if (IsType(RET_CBASE))
{ {
*data=PrivateToIndex(m_data); *data= TypeConversion.cbase_to_id(m_data);
return 0; return 0;
} }
else if (IsType(RET_ENTVAR)) else if (IsType(RET_ENTVAR))
{ {
*data=EntvarToIndex(reinterpret_cast<entvars_t *>(m_data)); *data= TypeConversion.entvars_to_id(reinterpret_cast<entvars_t *>(m_data));
return 0; return 0;
} }
else if (IsType(RET_EDICT)) else if (IsType(RET_EDICT))
{ {
*data = EdictToIndex(reinterpret_cast<edict_t *>(m_data)); *data = TypeConversion.edict_to_id(reinterpret_cast<edict_t *>(m_data));
return 0; return 0;
} }

View File

@ -1,71 +0,0 @@
// vim: set ts=4 sw=4 tw=99 noet:
//
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
// Copyright (C) The AMX Mod X Development Team.
//
// This software is licensed under the GNU General Public License, version 3 or higher.
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
// https://alliedmods.net/amxmodx-license
//
// Ham Sandwich Module
//
/* Inlined replacements for INDEXENT/ENTINDEX
* It only really removes the overhead of the push/jump
* but since INDEXENT/ENTINDEX are used a lot with amxx
* it might be beneficial to include.
* NOTE: Bad stuff will happen if you call these before
* NEW_Initialize()
* NOTE: No bounds checking is done because natives
* should use their own bounds checking!
*/
#ifndef NEW_UTIL_H
#define NEW_UTIL_H
extern edict_t *NEW_FirstEdict;
extern bool NEW_Initialized;
/**
* This is called on the first Spawn() ever hooked. This would be worldspawn (index 0)
*/
inline void NEW_Initialize(edict_t *Entity)
{
NEW_FirstEdict=Entity;
NEW_Initialized=true;
}
/**
* Converts an integer index into an edict pointer
*/
inline edict_t *INDEXENT_NEW(const int Index)
{
return (edict_t *)(NEW_FirstEdict + Index);
};
/**
* Converts an edict pointer into an integer index
*/
inline int ENTINDEX_NEW(const edict_t *Ent)
{
return (int)(Ent - NEW_FirstEdict);
};
// Inlined replacement of MF_GetAmxAddr
inline REAL amx_ctof2(cell x)
{
return *(REAL*)&x;
}
inline cell amx_ftoc2(REAL x)
{
return *(cell*)&x;
}
#endif // NEW_UTIL_H

View File

@ -14,7 +14,6 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include <extdll.h> #include <extdll.h>
#include "NEW_Util.h"
#include <amtl/am-vector.h> #include <amtl/am-vector.h>
#include "forward.h" #include "forward.h"
#include "hook.h" #include "hook.h"
@ -24,9 +23,9 @@
#include <assert.h> #include <assert.h>
#include "DataHandler.h" #include "DataHandler.h"
#include "hook_specialbot.h" #include "hook_specialbot.h"
#include <HLTypeConversion.h>
edict_t *NEW_FirstEdict; HLTypeConversion TypeConversion;
bool NEW_Initialized;
extern ke::Vector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL]; extern ke::Vector<Hook*> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
extern CHamSpecialBotHandler SpecialbotHandler; extern CHamSpecialBotHandler SpecialbotHandler;
@ -36,7 +35,6 @@ extern AMX_NATIVE_INFO ReturnNatives[];
extern AMX_NATIVE_INFO pdata_natives[]; extern AMX_NATIVE_INFO pdata_natives[];
extern AMX_NATIVE_INFO pdata_natives_safe[]; extern AMX_NATIVE_INFO pdata_natives_safe[];
extern hook_t hooklist[]; extern hook_t hooklist[];
int ReadConfig(void); int ReadConfig(void);
@ -66,6 +64,7 @@ void OnAmxxAttach(void)
assert(strcmp(hooklist[Ham_Item_GetItemInfo].name, "item_getiteminfo") == 0); assert(strcmp(hooklist[Ham_Item_GetItemInfo].name, "item_getiteminfo") == 0);
MF_AddNatives(pdata_natives_safe); MF_AddNatives(pdata_natives_safe);
if (ReadConfig() > 0) if (ReadConfig() > 0)
{ {
if (Offsets.IsValid()) if (Offsets.IsValid())
@ -118,8 +117,9 @@ void OnPluginsUnloaded(void)
void OnPluginsLoaded(void) void OnPluginsLoaded(void)
{ {
NEW_Initialize(INDEXENT(0)); TypeConversion.init();
} }
void OnMetaAttach(void) void OnMetaAttach(void)
{ {
REG_SVR_COMMAND("ham", HamCommand); REG_SVR_COMMAND("ham", HamCommand);

View File

@ -76,7 +76,7 @@ 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=TypeConversion.id_to_cbase(id); \
bool istramp; \ bool istramp; \
void *__func=GetFunction(pv, func, istramp); \ void *__func=GetFunction(pv, func, istramp); \
if (!istramp && !gDoForwards) \ if (!istramp && !gDoForwards) \
@ -116,7 +116,7 @@ cell Call_Void_Entvar(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
entvars_t *ev1=&(INDEXENT_NEW(id3)->v); entvars_t *ev1 = TypeConversion.id_to_entvars(id3);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *)>(__func)(pv, 0, ev1); reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *)>(__func)(pv, 0, ev1);
@ -135,7 +135,7 @@ cell Call_Void_Cbase(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); void *pv1 = TypeConversion.id_to_cbase(id3);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1); reinterpret_cast<void (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1);
@ -149,7 +149,7 @@ cell Call_Int_Float_Int(AMX *amx, cell *params)
{ {
SETUP(2); SETUP(2);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
int i4=*MF_GetAmxAddr(amx, params[4]); int i4=*MF_GetAmxAddr(amx, params[4]);
#if defined(_WIN32) #if defined(_WIN32)
@ -163,7 +163,7 @@ cell Call_Int_Float_Int_Int(AMX *amx, cell *params)
{ {
SETUP(3); SETUP(3);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
int i4=*MF_GetAmxAddr(amx, params[4]); int i4=*MF_GetAmxAddr(amx, params[4]);
int i5=*MF_GetAmxAddr(amx, params[5]); int i5=*MF_GetAmxAddr(amx, params[5]);
@ -183,7 +183,7 @@ cell Call_Void_Entvar_Int(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, int)>(__func)(pv, 0, ev3, i4); reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, int)>(__func)(pv, 0, ev3, i4);
@ -204,8 +204,8 @@ cell Call_Void_Entvar_Entvar_Int(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev4 = TypeConversion.id_to_entvars(id4);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, entvars_t *, int)>(__func)(pv, 0, ev3, ev4, i5); reinterpret_cast<void (__fastcall *)(void*, int, entvars_t *, entvars_t *, int)>(__func)(pv, 0, ev3, ev4, i5);
@ -224,7 +224,7 @@ cell Call_Int_Cbase(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); void *pv1 = TypeConversion.id_to_cbase(id3);
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1); return reinterpret_cast<int (__fastcall *)(void*, int, void *)>(__func)(pv, 0, pv1);
@ -300,7 +300,7 @@ cell Call_Int_Entvar(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *)>(__func)(pv, 0, ev3); return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *)>(__func)(pv, 0, ev3);
@ -315,14 +315,14 @@ cell Call_Int_Entvar_Entvar_Float_Int(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
int i6=*MF_GetAmxAddr(amx, params[6]); int i6=*MF_GetAmxAddr(amx, params[6]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev4 = TypeConversion.id_to_entvars(id4);
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, int)>(__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);
@ -337,15 +337,15 @@ cell Call_Int_Entvar_Entvar_Float_Float_Int(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); float f6=amx_ctof(*MF_GetAmxAddr(amx, params[6]));
int i7=*MF_GetAmxAddr(amx, params[7]); int i7=*MF_GetAmxAddr(amx, params[7]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev4 = TypeConversion.id_to_entvars(id4);
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, float, int)>(__func)(pv, 0, ev3, ev4, f5, f6, i7); return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, float, int)>(__func)(pv, 0, ev3, ev4, f5, f6, i7);
@ -373,13 +373,13 @@ cell Call_Vector_Float_Cbase_Int(AMX *amx, cell *params)
{ {
SETUP(4); SETUP(4);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
int i5=*MF_GetAmxAddr(amx, params[5]); int i5=*MF_GetAmxAddr(amx, params[5]);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
void *p4=IndexToPrivate(id4); void *p4 = TypeConversion.id_to_cbase(id4);
#if defined(_WIN32) #if defined(_WIN32)
Vector ret; Vector ret;
@ -403,13 +403,13 @@ cell Call_Void_Cbase_Cbase_Int_Float(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
int i5=*MF_GetAmxAddr(amx, params[5]); int i5=*MF_GetAmxAddr(amx, params[5]);
float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); float f6=amx_ctof(*MF_GetAmxAddr(amx, params[6]));
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
void *p3=IndexToPrivate(id3); void *p3 = TypeConversion.id_to_cbase(id3);
void *p4=IndexToPrivate(id4); void *p4 = TypeConversion.id_to_cbase(id4);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, void *, void *, int, float)>(__func)(pv, 0, p3, p4, i5, f6); reinterpret_cast<void (__fastcall *)(void *, int, void *, void *, int, float)>(__func)(pv, 0, p3, p4, i5, f6);
@ -425,7 +425,7 @@ cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params)
SETUP(5); SETUP(5);
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
Vector v5; Vector v5;
TraceResult *tr6=reinterpret_cast<TraceResult *>(*MF_GetAmxAddr(amx, params[6])); TraceResult *tr6=reinterpret_cast<TraceResult *>(*MF_GetAmxAddr(amx, params[6]));
int i7=*MF_GetAmxAddr(amx, params[7]); int i7=*MF_GetAmxAddr(amx, params[7]);
@ -444,7 +444,7 @@ cell Call_Void_Entvar_Float_Vector_Trace_Int(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, Vector, TraceResult *, int)>(__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__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
@ -458,7 +458,7 @@ cell Call_Void_Float_Vector_Trace_Int(AMX *amx, cell *params)
{ {
SETUP(4); SETUP(4);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
Vector v4; Vector v4;
TraceResult *tr5=reinterpret_cast<TraceResult *>(*MF_GetAmxAddr(amx, params[5])); TraceResult *tr5=reinterpret_cast<TraceResult *>(*MF_GetAmxAddr(amx, params[5]));
int i6=*MF_GetAmxAddr(amx, params[6]); int i6=*MF_GetAmxAddr(amx, params[6]);
@ -504,7 +504,7 @@ cell Call_Cbase_Void(AMX *amx, cell *params)
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
void *ret=reinterpret_cast<void *(*)(void *)>(__func)(pv); void *ret=reinterpret_cast<void *(*)(void *)>(__func)(pv);
#endif #endif
return PrivateToIndex(ret); return TypeConversion.cbase_to_id(ret);
} }
cell Call_Float_Int(AMX *amx, cell *params) cell Call_Float_Int(AMX *amx, cell *params)
@ -512,15 +512,15 @@ cell Call_Float_Int(AMX *amx, cell *params)
SETUP(2); SETUP(2);
int i3=*MF_GetAmxAddr(amx, params[3]); int i3=*MF_GetAmxAddr(amx, params[3]);
#if defined(_WIN32) #if defined(_WIN32)
float ret=reinterpret_cast<float (__fastcall *)(void *, int, int)>(__func)(pv, 0, i3); float ret=reinterpret_cast<float (__fastcall *)(void *, int, int)>(__func)(pv, 0, i3);
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
float ret=reinterpret_cast<float (*)(void *, int)>(__func)(pv, i3); float ret=reinterpret_cast<float (*)(void *, int)>(__func)(pv, i3);
#endif #endif
*MF_GetAmxAddr(amx, params[4])=amx_ftoc2(ret); *MF_GetAmxAddr(amx, params[4])=amx_ftoc(ret);
return 1; return 1;
} }
cell Call_Vector_Void(AMX *amx, cell *params) cell Call_Vector_Void(AMX *amx, cell *params)
@ -596,12 +596,12 @@ cell Call_Void_Entvar_Float_Float(AMX *amx, cell *params)
SETUP(3); SETUP(3);
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, float)>(__func)(pv, 0, ev3, f4, f5); reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, float, float)>(__func)(pv, 0, ev3, f4, f5);
@ -625,8 +625,8 @@ cell Call_Void_pFloat_pFloat(AMX *amx, cell *params)
reinterpret_cast<void (*)(void *, float*, float*)>(__func)(pv, &f3, &f4); reinterpret_cast<void (*)(void *, float*, float*)>(__func)(pv, &f3, &f4);
#endif #endif
*MF_GetAmxAddr(amx, params[3]) = amx_ftoc2(f3); *MF_GetAmxAddr(amx, params[3]) = amx_ftoc(f3);
*MF_GetAmxAddr(amx, params[4]) = amx_ftoc2(f4); *MF_GetAmxAddr(amx, params[4]) = amx_ftoc(f4);
return 1; return 1;
} }
@ -636,11 +636,11 @@ cell Call_Void_Entvar_Float(AMX *amx, cell *params)
SETUP(2); SETUP(2);
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t*, float)>(__func)(pv, 0, ev3, f4); return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t*, float)>(__func)(pv, 0, ev3, f4);
@ -693,16 +693,16 @@ cell Call_Float_Void(AMX *amx, cell *params)
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
float ret=reinterpret_cast<float (*)(void *)>(__func)(pv); float ret=reinterpret_cast<float (*)(void *)>(__func)(pv);
#endif #endif
*MF_GetAmxAddr(amx, params[3])=amx_ftoc2(ret); *MF_GetAmxAddr(amx, params[3])=amx_ftoc(ret);
return 1; return 1;
} }
cell Call_Void_Float_Int(AMX* amx, cell* params) cell Call_Void_Float_Int(AMX* amx, cell* params)
{ {
SETUP(2); SETUP(2);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
int i4 = *MF_GetAmxAddr(amx, params[4]); int i4 = *MF_GetAmxAddr(amx, params[4]);
#if defined(_WIN32) #if defined(_WIN32)
@ -718,17 +718,17 @@ cell Call_Float_Float_Cbase(AMX* amx, cell* params)
{ {
SETUP(3); SETUP(3);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
void *p4 = IndexToPrivate(id4); void *p4 = TypeConversion.id_to_cbase(id4);
#if defined(_WIN32) #if defined(_WIN32)
float ret = reinterpret_cast<float(__fastcall *)(void*, int, float, void*)>(__func)(pv, 0, f3, p4); float ret = reinterpret_cast<float(__fastcall *)(void*, int, float, void*)>(__func)(pv, 0, f3, p4);
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
float ret = reinterpret_cast<float (*)(void*, float, void*)>(__func)(pv, f3, p4); float ret = reinterpret_cast<float (*)(void*, float, void*)>(__func)(pv, f3, p4);
#endif #endif
*MF_GetAmxAddr(amx, params[5]) = amx_ftoc2(ret); *MF_GetAmxAddr(amx, params[5]) = amx_ftoc(ret);
return 1; return 1;
} }
@ -737,7 +737,7 @@ cell Call_Void_Float(AMX* amx, cell* params)
{ {
SETUP(1); SETUP(1);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, float)>(__func)(pv, 0, f3); reinterpret_cast<void (__fastcall *)(void*, int, float)>(__func)(pv, 0, f3);
@ -751,9 +751,9 @@ cell Call_Void_Float_Float_Float_Int(AMX* amx, cell* params)
{ {
SETUP(4); SETUP(4);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
int i6=*MF_GetAmxAddr(amx, params[6]); int i6=*MF_GetAmxAddr(amx, params[6]);
#if defined(_WIN32) #if defined(_WIN32)
@ -768,7 +768,7 @@ cell Call_Vector_Float(AMX *amx, cell *params)
{ {
SETUP(2); SETUP(2);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
#if defined(_WIN32) #if defined(_WIN32)
Vector ret; Vector ret;
@ -788,12 +788,12 @@ cell Call_Void_Float_Cbase(AMX *amx, cell *params)
{ {
SETUP(2); SETUP(2);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
void *p4=IndexToPrivate(id4); void *p4 = TypeConversion.id_to_cbase(id4);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, float, void *)>(__func)(pv, 0, f3, p4); reinterpret_cast<void (__fastcall *)(void *, int, float, void *)>(__func)(pv, 0, f3, p4);
@ -808,8 +808,8 @@ cell Call_Int_Float_Float(AMX *amx, cell *params)
{ {
SETUP(2); SETUP(2);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, float, float)>(__func)(pv, 0, f3, f4); return reinterpret_cast<int (__fastcall *)(void*, int, float, float)>(__func)(pv, 0, f3, f4);
@ -822,7 +822,7 @@ cell Call_Int_Float(AMX *amx, cell *params)
{ {
SETUP(1); SETUP(1);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void*, int, float)>(__func)(pv, 0, f3); return reinterpret_cast<int (__fastcall *)(void*, int, float)>(__func)(pv, 0, f3);
@ -850,9 +850,9 @@ cell Call_Void_Str_Float_Float_Float(AMX *amx, cell *params)
SETUP(4); SETUP(4);
char *sz3=MF_GetAmxString(amx, params[3], 0, NULL); char *sz3=MF_GetAmxString(amx, params[3], 0, NULL);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); float f6=amx_ctof(*MF_GetAmxAddr(amx, params[6]));
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, const char *, float, float, float)>(__func)(pv, 0, sz3, f4, f5, f6); reinterpret_cast<void (__fastcall *)(void*, int, const char *, float, float, float)>(__func)(pv, 0, sz3, f4, f5, f6);
@ -868,16 +868,15 @@ cell Call_Void_Str_Float_Float_Float_Int_Cbase(AMX *amx, cell *params)
SETUP(6); SETUP(6);
char *sz3=MF_GetAmxString(amx, params[3], 0, NULL); char *sz3=MF_GetAmxString(amx, params[3], 0, NULL);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); float f6=amx_ctof(*MF_GetAmxAddr(amx, params[6]));
int i7=*MF_GetAmxAddr(amx, params[7]); int i7=*MF_GetAmxAddr(amx, params[7]);
int id8=*MF_GetAmxAddr(amx, params[8]); int id8=*MF_GetAmxAddr(amx, params[8]);
CHECK_ENTITY(id8); CHECK_ENTITY(id8);
void *p8=IndexToPrivate(id8); void *p8 = TypeConversion.id_to_cbase(id8);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, const char *, float, float, float, int, void *)>(__func)(pv, 0, sz3, f4, f5, f6, i7, p8); reinterpret_cast<void (__fastcall *)(void*, int, const char *, float, float, float, int, void *)>(__func)(pv, 0, sz3, f4, f5, f6, i7, p8);
@ -905,8 +904,8 @@ cell Call_Int_Vector_Vector_Float_Float(AMX *amx, cell *params)
v4.y=fl4[1]; v4.y=fl4[1];
v4.z=fl4[2]; v4.z=fl4[2];
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); float f6=amx_ctof(*MF_GetAmxAddr(amx, params[6]));
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, Vector, Vector, float, float)>(__func)(pv, 0, v3, v4, f5, f6); return reinterpret_cast<int (__fastcall *)(void *, int, Vector, Vector, float, float)>(__func)(pv, 0, v3, v4, f5, f6);
@ -934,15 +933,15 @@ cell Call_Void_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
int i6=*MF_GetAmxAddr(amx, params[6]); int i6=*MF_GetAmxAddr(amx, params[6]);
int i7=*MF_GetAmxAddr(amx, params[7]); int i7=*MF_GetAmxAddr(amx, params[7]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev4 = TypeConversion.id_to_entvars(id4);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, int, int)>(__func)(pv, 0, ev3, ev4, f5, i6, i7); reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, entvars_t *, float, int, int)>(__func)(pv, 0, ev3, ev4, f5, i6, i7);
@ -966,15 +965,15 @@ cell Call_Void_Vector_Entvar_Entvar_Float_Int_Int(AMX *amx, cell *params)
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
int id5=*MF_GetAmxAddr(amx, params[5]); int id5=*MF_GetAmxAddr(amx, params[5]);
float f6=amx_ctof2(*MF_GetAmxAddr(amx, params[6])); float f6=amx_ctof(*MF_GetAmxAddr(amx, params[6]));
int i7=*MF_GetAmxAddr(amx, params[7]); int i7=*MF_GetAmxAddr(amx, params[7]);
int i8=*MF_GetAmxAddr(amx, params[8]); int i8=*MF_GetAmxAddr(amx, params[8]);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
CHECK_ENTITY(id5); CHECK_ENTITY(id5);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev4 = TypeConversion.id_to_entvars(id4);
entvars_t *ev5=&(INDEXENT_NEW(id5)->v); entvars_t *ev5 = TypeConversion.id_to_entvars(id5);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, Vector, entvars_t *, entvars_t *, float, int, int)>(__func)(pv, 0, v3, ev4, ev5, f6, i7, i8); reinterpret_cast<void (__fastcall *)(void *, int, Vector, entvars_t *, entvars_t *, float, int, int)>(__func)(pv, 0, v3, ev4, ev5, f6, i7, i8);
@ -990,14 +989,14 @@ cell Call_Float_Int_Float(AMX *amx, cell *params)
SETUP(3); SETUP(3);
int i3=*MF_GetAmxAddr(amx, params[3]); int i3=*MF_GetAmxAddr(amx, params[3]);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
#if defined(_WIN32) #if defined(_WIN32)
float ret=reinterpret_cast<float (__fastcall *)(void *, int, int, float)>(__func)(pv, 0, i3, f4); float ret=reinterpret_cast<float (__fastcall *)(void *, int, int, float)>(__func)(pv, 0, i3, f4);
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
float ret=reinterpret_cast<float (*)(void *, int, float)>(__func)(pv, i3, f4); float ret=reinterpret_cast<float (*)(void *, int, float)>(__func)(pv, i3, f4);
#endif #endif
*MF_GetAmxAddr(amx, params[5])=amx_ftoc2(ret); *MF_GetAmxAddr(amx, params[5])=amx_ftoc(ret);
return 1; return 1;
} }
@ -1022,7 +1021,7 @@ cell Call_Void_Edict(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
edict_t *ed3=INDEXENT_NEW(id3); edict_t *ed3 = TypeConversion.id_to_edict(id3);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<int (__fastcall *)(void*, int, edict_t *)>(__func)(pv, 0, ed3); reinterpret_cast<int (__fastcall *)(void*, int, edict_t *)>(__func)(pv, 0, ed3);
@ -1119,7 +1118,7 @@ cell Call_Int_Int_Int_Float_Int(AMX* amx, cell* params)
int i3=*MF_GetAmxAddr(amx, params[3]); int i3=*MF_GetAmxAddr(amx, params[3]);
int i4=*MF_GetAmxAddr(amx, params[4]); int i4=*MF_GetAmxAddr(amx, params[4]);
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
int i6=*MF_GetAmxAddr(amx, params[6]); int i6=*MF_GetAmxAddr(amx, params[6]);
#if defined(_WIN32) #if defined(_WIN32)
@ -1152,7 +1151,7 @@ cell Call_Void_Cbase_Int(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *p8=IndexToPrivate(id3); void *p8 = TypeConversion.id_to_cbase(id3);
int i4=*MF_GetAmxAddr(amx, params[4]); int i4=*MF_GetAmxAddr(amx, params[4]);
@ -1239,8 +1238,8 @@ cell Call_Void_Float_Float(AMX *amx, cell *params)
{ {
SETUP(2); SETUP(2);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, float, float)>(__func)(pv, 0, f3, f4); reinterpret_cast<void (__fastcall *)(void *, int, float, float)>(__func)(pv, 0, f3, f4);
@ -1288,7 +1287,7 @@ cell Call_Int_pVector_pVector_Cbase_pFloat(AMX *amx, cell *params)
int id5=*MF_GetAmxAddr(amx, params[5]); int id5=*MF_GetAmxAddr(amx, params[5]);
CHECK_ENTITY(id5); CHECK_ENTITY(id5);
void *p5=IndexToPrivate(id5); void *p5 = TypeConversion.id_to_cbase(id5);
float f6; float f6;
@ -1306,7 +1305,7 @@ cell Call_Int_pVector_pVector_Cbase_pFloat(AMX *amx, cell *params)
fl4[1]=v4.y; fl4[1]=v4.y;
fl4[2]=v4.z; fl4[2]=v4.z;
*MF_GetAmxAddr(amx, params[6]) = amx_ftoc2(f6); *MF_GetAmxAddr(amx, params[6]) = amx_ftoc(f6);
return ret; return ret;
} }
@ -1318,7 +1317,7 @@ cell Call_Void_Cbase_pVector_Float(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *i3=IndexToPrivate(id3); void *i3 = TypeConversion.id_to_cbase(id3);
Vector v4; Vector v4;
float *fl4=(float *)MF_GetAmxAddr(amx, params[4]); float *fl4=(float *)MF_GetAmxAddr(amx, params[4]);
@ -1326,7 +1325,7 @@ cell Call_Void_Cbase_pVector_Float(AMX *amx, cell *params)
v4.y=fl4[1]; v4.y=fl4[1];
v4.z=fl4[2]; v4.z=fl4[2];
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, void *, Vector *, float)>(__func)(pv, 0, i3, &v4, f5); reinterpret_cast<void (__fastcall *)(void*, int, void *, Vector *, float)>(__func)(pv, 0, i3, &v4, f5);
@ -1359,11 +1358,11 @@ cell Call_Int_pVector_pVector_Float_Cbase_pVector(AMX *amx, cell *params)
v4.y=fl4[1]; v4.y=fl4[1];
v4.z=fl4[2]; v4.z=fl4[2];
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
int id6=*MF_GetAmxAddr(amx, params[6]); int id6=*MF_GetAmxAddr(amx, params[6]);
CHECK_ENTITY(id6); CHECK_ENTITY(id6);
void *p6=IndexToPrivate(id6); void *p6 = TypeConversion.id_to_cbase(id6);
Vector v7; Vector v7;
float *fl7=(float *)MF_GetAmxAddr(amx, params[7]); float *fl7=(float *)MF_GetAmxAddr(amx, params[7]);
@ -1401,7 +1400,7 @@ cell Call_Int_Cbase_Bool(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); void *pv1 = TypeConversion.id_to_cbase(id3);
bool b4=*MF_GetAmxAddr(amx, params[4]) ? true : false; bool b4=*MF_GetAmxAddr(amx, params[4]) ? true : false;
@ -1444,9 +1443,9 @@ cell Call_Int_Entvar_Float(AMX *amx, cell *params)
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4=amx_ctof(*MF_GetAmxAddr(amx, params[4]));
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, float)>(__func)(pv, 0, ev3, f4); return reinterpret_cast<int (__fastcall *)(void *, int, entvars_t *, float)>(__func)(pv, 0, ev3, f4);
@ -1459,16 +1458,16 @@ cell Call_Float_Float(AMX *amx, cell *params)
{ {
SETUP(2); SETUP(2);
float f3=amx_ctof2(*MF_GetAmxAddr(amx, params[3])); float f3=amx_ctof(*MF_GetAmxAddr(amx, params[3]));
#if defined(_WIN32) #if defined(_WIN32)
float ret=reinterpret_cast<float (__fastcall *)(void *, int, float)>(__func)(pv, 0, f3); float ret=reinterpret_cast<float (__fastcall *)(void *, int, float)>(__func)(pv, 0, f3);
#elif defined(__linux__) || defined(__APPLE__) #elif defined(__linux__) || defined(__APPLE__)
float ret=reinterpret_cast<float (*)(void *, float)>(__func)(pv, f3); float ret=reinterpret_cast<float (*)(void *, float)>(__func)(pv, f3);
#endif #endif
*MF_GetAmxAddr(amx, params[4])=amx_ftoc2(ret); *MF_GetAmxAddr(amx, params[4])=amx_ftoc(ret);
return 1; return 1;
} }
cell Call_Void_Entvar_Entvar_Float(AMX *amx, cell *params) cell Call_Void_Entvar_Entvar_Float(AMX *amx, cell *params)
@ -1477,13 +1476,13 @@ cell Call_Void_Entvar_Entvar_Float(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
entvars_t *ev3=&(INDEXENT_NEW(id3)->v); entvars_t *ev3 = TypeConversion.id_to_entvars(id3);
entvars_t *ev4=&(INDEXENT_NEW(id4)->v); entvars_t *ev4 = TypeConversion.id_to_entvars(id4);
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, entvars_t *, float)>(__func)(pv, 0, ev3, ev4, f5); reinterpret_cast<void (__fastcall *)(void *, int, entvars_t *, entvars_t *, float)>(__func)(pv, 0, ev3, ev4, f5);
@ -1523,11 +1522,11 @@ cell Call_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(AMX *amx, cell *p
v4.y=fl4[1]; v4.y=fl4[1];
v4.z=fl4[2]; v4.z=fl4[2];
float f5=amx_ctof2(*MF_GetAmxAddr(amx, params[5])); float f5=amx_ctof(*MF_GetAmxAddr(amx, params[5]));
int id6=*MF_GetAmxAddr(amx, params[6]); int id6=*MF_GetAmxAddr(amx, params[6]);
CHECK_ENTITY(id6); CHECK_ENTITY(id6);
void *p6=IndexToPrivate(id6); void *p6 = TypeConversion.id_to_cbase(id6);
Vector v7; Vector v7;
float *fl7=(float *)MF_GetAmxAddr(amx, params[7]); float *fl7=(float *)MF_GetAmxAddr(amx, params[7]);
@ -1582,7 +1581,7 @@ cell Call_Int_Vector_Cbase(AMX *amx, cell *params)
int id4=*MF_GetAmxAddr(amx, params[4]); int id4=*MF_GetAmxAddr(amx, params[4]);
CHECK_ENTITY(id4); CHECK_ENTITY(id4);
void *p4=IndexToPrivate(id4); void *p4 = TypeConversion.id_to_cbase(id4);
#if defined(_WIN32) #if defined(_WIN32)
int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector, void*)>(__func)(pv, 0, v3, p4); int ret=reinterpret_cast<int (__fastcall *)(void *, int, Vector, void*)>(__func)(pv, 0, v3, p4);
@ -1622,7 +1621,7 @@ cell Call_Int_Cbase_pVector(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); void *pv1 = TypeConversion.id_to_cbase(id3);
Vector v4; Vector v4;
float *fl4=(float *)MF_GetAmxAddr(amx, params[4]); float *fl4=(float *)MF_GetAmxAddr(amx, params[4]);
@ -1664,7 +1663,7 @@ cell Call_Bool_Cbase(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *pv1=(INDEXENT_NEW(id3)->pvPrivateData); void *pv1 = TypeConversion.id_to_cbase(id3);
#if defined(_WIN32) #if defined(_WIN32)
return reinterpret_cast<bool (__fastcall *)(void*, int, void*)>(__func)(pv, 0, pv1); return reinterpret_cast<bool (__fastcall *)(void*, int, void*)>(__func)(pv, 0, pv1);
@ -1693,9 +1692,8 @@ cell Call_Void_Cbase_Float(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *p8=IndexToPrivate(id3); void *p8 = TypeConversion.id_to_cbase(id3);
float f4=amx_ctof2(*MF_GetAmxAddr(amx, params[4])); float f4 = amx_ctof(*MF_GetAmxAddr(amx, params[4]));
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, void *, float)>(__func)(pv, 0, p8, f4); reinterpret_cast<void (__fastcall *)(void*, int, void *, float)>(__func)(pv, 0, p8, f4);
@ -1713,9 +1711,8 @@ cell Call_Void_Cbase_Bool(AMX *amx, cell *params)
int id3=*MF_GetAmxAddr(amx, params[3]); int id3=*MF_GetAmxAddr(amx, params[3]);
CHECK_ENTITY(id3); CHECK_ENTITY(id3);
void *p8=IndexToPrivate(id3); void *p8 = TypeConversion.id_to_cbase(id3);
bool b4 = *MF_GetAmxAddr(amx, params[4]) ? true : false;
bool b4=*MF_GetAmxAddr(amx, params[4]) ? true : false;
#if defined(_WIN32) #if defined(_WIN32)
reinterpret_cast<void (__fastcall *)(void*, int, void *, bool)>(__func)(pv, 0, p8, b4); reinterpret_cast<void (__fastcall *)(void*, int, void *, bool)>(__func)(pv, 0, p8, b4);

View File

@ -16,8 +16,9 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include "offsets.h" #include "offsets.h"
#include "NEW_Util.h" #include <HLTypeConversion.h>
#include <amtl/am-string.h>
extern HLTypeConversion TypeConversion;
#define CHECK_FUNCTION(x) \ #define CHECK_FUNCTION(x) \
if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \ if (x < 0 || x >= HAM_LAST_ENTRY_DONT_USE_ME_LOL) { \
@ -38,124 +39,31 @@
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \ return 0; \
} else { \ } else { \
if (INDEXENT_NEW(x)->free) { \ if (TypeConversion.id_to_edict(x)->free) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity (%d)", x); \
return 0; \ return 0; \
} else if (INDEXENT_NEW(x)->pvPrivateData == NULL) { \ } else if (TypeConversion.id_to_edict(x)->pvPrivateData == NULL) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity has null private data (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Entity has null private data (%d)", x); \
return 0; \ return 0; \
} \ } \
} }
inline edict_t *PrivateToEdict(const void *pdata)
{
if (!pdata)
{
return NULL;
}
char *ptr=(char*)pdata + Offsets.GetPev();
entvars_t *pev=(entvars_t *)ptr;
if (!pev)
{
return NULL;
}
return pev->pContainingEntity;
};
inline int PrivateToIndex(const void *pdata)
{
if (pdata==NULL)
{
return -1;
}
char *ptr=(char*)pdata;
ptr+=Offsets.GetPev();
entvars_t *pev=*(entvars_t **)ptr;
if (pev==NULL)
{
return -1;
}
if (pev->pContainingEntity==NULL)
{
return -1;
}
return ENTINDEX_NEW(pev->pContainingEntity);
};
inline void *IndexToPrivate(int index)
{
return INDEXENT_NEW(index)->pvPrivateData;
};
inline entvars_t *IndexToEntvar(int index)
{
return &(INDEXENT_NEW(index)->v);
};
inline int EntvarToIndex(entvars_t *pev)
{
if (pev==NULL)
{
return -1;
}
if (pev->pContainingEntity==NULL)
{
return -1;
}
return ENTINDEX_NEW(pev->pContainingEntity);
};
inline int EdictToIndex(edict_t *v)
{
if (v==NULL)
{
return -1;
}
return ENTINDEX_NEW(v);
}
inline edict_t *IndexToEdict(int index)
{
return INDEXENT_NEW(index);
};
inline edict_t *EntvarToEdict(entvars_t *pev)
{
if (pev==NULL)
{
return NULL;
}
return pev->pContainingEntity;
};
inline void **EdictToVTable(edict_t *ent) inline void **EdictToVTable(edict_t *ent)
{ {
char *btbl=(char *)ent->pvPrivateData; char *btbl = (char *)ent->pvPrivateData;
btbl+=Offsets.GetBase(); btbl += Offsets.GetBase();
return *((void ***)btbl); return *((void ***)btbl);
}; };
inline void **GetVTable(void *pthis, int size) inline void **GetVTable(void *pthis, int size)
{ {
return *((void***)(((char*)pthis)+size)); return *((void***)(((char*)pthis) + size));
} }
inline void *GetVTableEntry(void *pthis, int ventry, int size) inline void *GetVTableEntry(void *pthis, int ventry, int size)
{ {
void **vtbl=GetVTable(pthis, size); void **vtbl = GetVTable(pthis, size);
return vtbl[ventry]; return vtbl[ventry];
} }
void print_srvconsole(const char *fmt, ...);
#endif #endif

View File

@ -47,7 +47,7 @@ extern bool gDoForwards;
// Parameter value pushes // Parameter value pushes
#define MAKE_VECTOR() \ #define MAKE_VECTOR() \
int iThis=PrivateToIndex(pthis); \ int iThis=TypeConversion.cbase_to_id(pthis); \
ke::Vector<Data *> *__vec=new ke::Vector<Data *>; \ ke::Vector<Data *> *__vec=new ke::Vector<Data *>; \
ParamStack.push(__vec); \ ParamStack.push(__vec); \
P_CBASE(pthis, iThis) P_CBASE(pthis, iThis)
@ -194,7 +194,7 @@ void Hook_Void_Entvar(Hook *hook, void *pthis, entvars_t *entvar)
{ {
PUSH_VOID() PUSH_VOID()
int iOther=EntvarToIndex(entvar); int iOther= TypeConversion.entvars_to_id(entvar);
MAKE_VECTOR() MAKE_VECTOR()
@ -222,7 +222,7 @@ void Hook_Void_Entvar(Hook *hook, void *pthis, entvars_t *entvar)
void Hook_Void_Cbase(Hook *hook, void *pthis, void *other) void Hook_Void_Cbase(Hook *hook, void *pthis, void *other)
{ {
PUSH_VOID() PUSH_VOID()
int iOther=PrivateToIndex(other); int iOther=TypeConversion.cbase_to_id(other);
MAKE_VECTOR() MAKE_VECTOR()
@ -312,7 +312,7 @@ int Hook_Int_Float_Int_Int(Hook *hook, void *pthis, float f1, int i1, int i2)
void Hook_Void_Entvar_Int(Hook *hook, void *pthis, entvars_t *ev1, int i1) void Hook_Void_Entvar_Int(Hook *hook, void *pthis, entvars_t *ev1, int i1)
{ {
PUSH_VOID() PUSH_VOID()
int iOther=EntvarToIndex(ev1); int iOther=TypeConversion.entvars_to_id(ev1);
MAKE_VECTOR() MAKE_VECTOR()
@ -340,8 +340,8 @@ void Hook_Void_Entvar_Int(Hook *hook, void *pthis, entvars_t *ev1, int i1)
void Hook_Void_Entvar_Entvar_Int(Hook *hook, void *pthis, entvars_t *ev1, entvars_t *ev2, int i1) void Hook_Void_Entvar_Entvar_Int(Hook *hook, void *pthis, entvars_t *ev1, entvars_t *ev2, int i1)
{ {
PUSH_VOID() PUSH_VOID()
int iInflictor=EntvarToIndex(ev1); int iInflictor=TypeConversion.entvars_to_id(ev1);
int iAttacker=EntvarToIndex(ev2); int iAttacker=TypeConversion.entvars_to_id(ev2);
MAKE_VECTOR() MAKE_VECTOR()
@ -374,7 +374,7 @@ int Hook_Int_Cbase(Hook *hook, void *pthis, void *cb1)
PUSH_INT() PUSH_INT()
int iOther=PrivateToIndex(cb1); int iOther=TypeConversion.cbase_to_id(cb1);
MAKE_VECTOR() MAKE_VECTOR()
@ -533,7 +533,7 @@ int Hook_Int_Entvar(Hook *hook, void *pthis, entvars_t *ev1)
int origret=0; int origret=0;
PUSH_INT() PUSH_INT()
int iOther=EntvarToIndex(ev1); int iOther=TypeConversion.entvars_to_id(ev1);
MAKE_VECTOR() MAKE_VECTOR()
P_ENTVAR(ev1, iOther) P_ENTVAR(ev1, iOther)
@ -563,8 +563,8 @@ int Hook_Int_Entvar_Entvar_Float_Int(Hook *hook, void *pthis, entvars_t *inflict
int ret=0; int ret=0;
int origret=0; int origret=0;
PUSH_INT() PUSH_INT()
int iInflictor=EntvarToIndex(inflictor); int iInflictor=TypeConversion.entvars_to_id(inflictor);
int iAttacker=EntvarToIndex(attacker); int iAttacker=TypeConversion.entvars_to_id(attacker);
MAKE_VECTOR() MAKE_VECTOR()
P_ENTVAR(inflictor, iInflictor) P_ENTVAR(inflictor, iInflictor)
@ -597,8 +597,8 @@ int Hook_Int_Entvar_Entvar_Float_Float_Int(Hook *hook, void *pthis, entvars_t *i
int ret=0; int ret=0;
int origret=0; int origret=0;
PUSH_INT() PUSH_INT()
int iInflictor=EntvarToIndex(inflictor); int iInflictor=TypeConversion.entvars_to_id(inflictor);
int iAttacker=EntvarToIndex(attacker); int iAttacker=TypeConversion.entvars_to_id(attacker);
MAKE_VECTOR() MAKE_VECTOR()
P_ENTVAR(inflictor, iInflictor) P_ENTVAR(inflictor, iInflictor)
@ -698,7 +698,7 @@ void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1,
memset(&ret, 0x0, sizeof(Vector)); memset(&ret, 0x0, sizeof(Vector));
memset(&origret, 0x0, sizeof(Vector)); memset(&origret, 0x0, sizeof(Vector));
int iEnt = PrivateToIndex(cb); int iEnt = TypeConversion.cbase_to_id(cb);
P_FLOAT(f1) P_FLOAT(f1)
P_CBASE(cb, iEnt) P_CBASE(cb, iEnt)
@ -728,8 +728,8 @@ void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1,
void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *cb2, int i1, float f1) void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *cb2, int i1, float f1)
{ {
PUSH_VOID() PUSH_VOID()
int iCaller=PrivateToIndex(cb1); int iCaller=TypeConversion.cbase_to_id(cb1);
int iActivator=PrivateToIndex(cb2); int iActivator=TypeConversion.cbase_to_id(cb2);
MAKE_VECTOR() MAKE_VECTOR()
P_CBASE(cb1, iCaller) P_CBASE(cb1, iCaller)
@ -759,7 +759,7 @@ void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *c
void Hook_Void_Entvar_Float_Vector_Trace_Int(Hook *hook, void *pthis, entvars_t *ev1, float f1, Vector v1, TraceResult *tr1, int i1) void Hook_Void_Entvar_Float_Vector_Trace_Int(Hook *hook, void *pthis, entvars_t *ev1, float f1, Vector v1, TraceResult *tr1, int i1)
{ {
PUSH_VOID() PUSH_VOID()
int iev1=EntvarToIndex(ev1); int iev1=TypeConversion.entvars_to_id(ev1);
MAKE_VECTOR() MAKE_VECTOR()
P_ENTVAR(ev1, iev1) P_ENTVAR(ev1, iev1)
@ -972,7 +972,7 @@ int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1)
void Hook_Void_Entvar_Float_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1, float f2) void Hook_Void_Entvar_Float_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1, float f2)
{ {
PUSH_VOID() PUSH_VOID()
cell cev1=EntvarToIndex(ev1); cell cev1=TypeConversion.entvars_to_id(ev1);
MAKE_VECTOR() MAKE_VECTOR()
P_ENTVAR(ev1, cev1) P_ENTVAR(ev1, cev1)
@ -1026,7 +1026,7 @@ void Hook_Void_pFloat_pFloat(Hook *hook, void *pthis, float *f1, float *f2)
void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1) void Hook_Void_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1)
{ {
PUSH_VOID() PUSH_VOID()
cell cev1=EntvarToIndex(ev1); cell cev1=TypeConversion.entvars_to_id(ev1);
MAKE_VECTOR() MAKE_VECTOR()
P_ENTVAR(ev1, cev1) P_ENTVAR(ev1, cev1)
@ -1160,7 +1160,7 @@ float Hook_Float_Float_Cbase(Hook* hook, void* pthis, float f1, void *cb1)
MAKE_VECTOR() MAKE_VECTOR()
int i1 = PrivateToIndex(cb1); int i1 = TypeConversion.cbase_to_id(cb1);
P_FLOAT(f1) P_FLOAT(f1)
P_CBASE(cb1, i1) P_CBASE(cb1, i1)
@ -1277,7 +1277,7 @@ void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1)
void Hook_Void_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb) void Hook_Void_Float_Cbase(Hook *hook, void *pthis, float f1, void *cb)
{ {
PUSH_VOID() PUSH_VOID()
int iEnt =PrivateToIndex(cb); int iEnt =TypeConversion.cbase_to_id(cb);
MAKE_VECTOR() MAKE_VECTOR()
P_FLOAT(f1) P_FLOAT(f1)
@ -1440,7 +1440,7 @@ void Hook_Void_Str_Float_Float_Float_Int_Cbase(Hook *hook, void *pthis, const ch
PUSH_VOID() PUSH_VOID()
a = sz1; a = sz1;
int iEnt=PrivateToIndex(cb); int iEnt=TypeConversion.cbase_to_id(cb);
MAKE_VECTOR() MAKE_VECTOR()
@ -1544,8 +1544,8 @@ void Hook_Void_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis, entvars_t *i
{ {
PUSH_VOID() PUSH_VOID()
int iInflictor=EntvarToIndex(inflictor); int iInflictor=TypeConversion.entvars_to_id(inflictor);
int iAttacker=EntvarToIndex(attacker); int iAttacker=TypeConversion.entvars_to_id(attacker);
MAKE_VECTOR() MAKE_VECTOR()
@ -1578,8 +1578,8 @@ void Hook_Void_Vector_Entvar_Entvar_Float_Int_Int(Hook *hook, void *pthis, Vecto
{ {
PUSH_VOID() PUSH_VOID()
int iInflictor=EntvarToIndex(inflictor); int iInflictor=TypeConversion.entvars_to_id(inflictor);
int iAttacker=EntvarToIndex(attacker); int iAttacker=TypeConversion.entvars_to_id(attacker);
MAKE_VECTOR() MAKE_VECTOR()
@ -1682,7 +1682,7 @@ void Hook_Void_Edict(Hook *hook, void *pthis, edict_t *ed1)
{ {
PUSH_VOID() PUSH_VOID()
int id1=EdictToIndex(ed1); int id1=TypeConversion.edict_to_id(ed1);
MAKE_VECTOR() MAKE_VECTOR()
P_EDICT(ed1, id1) P_EDICT(ed1, id1)
@ -1900,7 +1900,7 @@ void Hook_Void_Str_Int(Hook *hook, void *pthis, const char *sz1, int i2)
void Hook_Void_Cbase_Int(Hook *hook, void *pthis, void *p1, int i1) void Hook_Void_Cbase_Int(Hook *hook, void *pthis, void *p1, int i1)
{ {
PUSH_VOID() PUSH_VOID()
int iEnt =PrivateToIndex(p1); int iEnt =TypeConversion.cbase_to_id(p1);
MAKE_VECTOR() MAKE_VECTOR()
@ -2124,7 +2124,7 @@ int Hook_Int_pVector_pVector_Cbase_pFloat(Hook *hook, void *pthis, Vector *v1, V
PUSH_INT() PUSH_INT()
int i3=PrivateToIndex(cb); int i3=TypeConversion.cbase_to_id(cb);
MAKE_VECTOR() MAKE_VECTOR()
P_PTRVECTOR(v1) P_PTRVECTOR(v1)
@ -2161,7 +2161,7 @@ int Hook_Int_pVector_pVector_Cbase_pFloat(Hook *hook, void *pthis, Vector *v1, V
void Hook_Void_Cbase_pVector_Float(Hook *hook, void *pthis, void *p1, Vector *v1, float fl) void Hook_Void_Cbase_pVector_Float(Hook *hook, void *pthis, void *p1, Vector *v1, float fl)
{ {
PUSH_VOID() PUSH_VOID()
int iEnt =PrivateToIndex(p1); int iEnt =TypeConversion.cbase_to_id(p1);
MAKE_VECTOR() MAKE_VECTOR()
@ -2194,7 +2194,7 @@ int Hook_Int_pVector_pVector_Float_Cbase_pVector(Hook *hook, void *pthis, Vector
PUSH_INT() PUSH_INT()
int i4=PrivateToIndex(cb); int i4=TypeConversion.cbase_to_id(cb);
MAKE_VECTOR() MAKE_VECTOR()
P_PTRVECTOR(v1) P_PTRVECTOR(v1)
@ -2238,7 +2238,7 @@ int Hook_Int_Cbase_Bool(Hook *hook, void *pthis, void *cb1, bool b1)
PUSH_INT() PUSH_INT()
int i1=PrivateToIndex(cb1); int i1=TypeConversion.cbase_to_id(cb1);
MAKE_VECTOR() MAKE_VECTOR()
@ -2305,7 +2305,7 @@ int Hook_Int_Entvar_Float(Hook *hook, void *pthis, entvars_t *ev1, float f1)
int origret=0; int origret=0;
PUSH_INT() PUSH_INT()
int i1=EntvarToIndex(ev1); int i1=TypeConversion.entvars_to_id(ev1);
MAKE_VECTOR() MAKE_VECTOR()
P_ENTVAR(ev1, i1) P_ENTVAR(ev1, i1)
@ -2365,8 +2365,8 @@ void Hook_Void_Entvar_Entvar_Float(Hook *hook, void *pthis, entvars_t *attacker,
{ {
PUSH_VOID() PUSH_VOID()
int iAttacker=EntvarToIndex(attacker); int iAttacker=TypeConversion.entvars_to_id(attacker);
int iInflictor=EntvarToIndex(inflictor); int iInflictor=TypeConversion.entvars_to_id(inflictor);
MAKE_VECTOR() MAKE_VECTOR()
@ -2428,7 +2428,7 @@ int Hook_Int_pVector_pVector_Float_Cbase_pVector_pVector_Bool(Hook *hook, void *
PUSH_INT() PUSH_INT()
int i4=PrivateToIndex(cb); int i4=TypeConversion.cbase_to_id(cb);
MAKE_VECTOR() MAKE_VECTOR()
@ -2478,7 +2478,7 @@ int Hook_Int_Vector_Cbase(Hook *hook, void *pthis, Vector v1, void* cb)
int origret=0; int origret=0;
PUSH_INT() PUSH_INT()
int i4=PrivateToIndex(cb); int i4=TypeConversion.cbase_to_id(cb);
MAKE_VECTOR() MAKE_VECTOR()
@ -2546,7 +2546,7 @@ int Hook_Int_Cbase_pVector(Hook *hook, void *pthis, void *cb1, Vector *v1)
PUSH_INT() PUSH_INT()
int iOther=PrivateToIndex(cb1); int iOther=TypeConversion.cbase_to_id(cb1);
MAKE_VECTOR() MAKE_VECTOR()
@ -2606,7 +2606,7 @@ bool Hook_Bool_Cbase(Hook *hook, void *pthis, void *cb)
PUSH_BOOL() PUSH_BOOL()
int iOther=PrivateToIndex(cb); int iOther=TypeConversion.cbase_to_id(cb);
MAKE_VECTOR() MAKE_VECTOR()
@ -2669,7 +2669,7 @@ bool Hook_Bool_Int(Hook *hook, void *pthis, int i1)
void Hook_Void_Cbase_Float(Hook *hook, void *pthis, void *p1, float f1) void Hook_Void_Cbase_Float(Hook *hook, void *pthis, void *p1, float f1)
{ {
PUSH_VOID() PUSH_VOID()
int iEnt =PrivateToIndex(p1); int iEnt =TypeConversion.cbase_to_id(p1);
MAKE_VECTOR() MAKE_VECTOR()
@ -2698,7 +2698,7 @@ void Hook_Void_Cbase_Float(Hook *hook, void *pthis, void *p1, float f1)
void Hook_Void_Cbase_Bool(Hook *hook, void *pthis, void *p1, bool b1) void Hook_Void_Cbase_Bool(Hook *hook, void *pthis, void *p1, bool b1)
{ {
PUSH_VOID() PUSH_VOID()
int iEnt =PrivateToIndex(p1); int iEnt =TypeConversion.cbase_to_id(p1);
MAKE_VECTOR() MAKE_VECTOR()

View File

@ -641,13 +641,12 @@ static cell AMX_NATIVE_CALL RegisterHamFromEntity(AMX *amx, cell *params)
char *function=MF_GetAmxString(amx, params[3], 0, NULL); char *function=MF_GetAmxString(amx, params[3], 0, NULL);
int entid=params[2]; int entid=params[2];
char classname[64]; char classname[64];
// Check the entity // Check the entity
edict_t *Entity=INDEXENT_NEW(entid); edict_t *Entity = TypeConversion.id_to_edict(entid);
if (!Entity || Entity->pvPrivateData == NULL)
if (Entity->pvPrivateData == NULL)
{ {
MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id \"%d\", hook for \"%s\" not active.",entid,function); MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve classtype for entity id \"%d\", hook for \"%s\" not active.",entid,function);
@ -656,7 +655,6 @@ static cell AMX_NATIVE_CALL RegisterHamFromEntity(AMX *amx, cell *params)
} }
void **vtable=GetVTable(Entity->pvPrivateData, Offsets.GetBase()); void **vtable=GetVTable(Entity->pvPrivateData, Offsets.GetBase());
if (vtable == NULL) if (vtable == NULL)
{ {
MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve vtable for entity id \"%d\", hook for \"%s\" not active.",entid,function); MF_LogError(amx, AMX_ERR_NATIVE,"Failed to retrieve vtable for entity id \"%d\", hook for \"%s\" not active.",entid,function);

View File

@ -100,6 +100,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\public\memtools\MemoryUtils.cpp" />
<ClCompile Include="..\call_funcs.cpp" /> <ClCompile Include="..\call_funcs.cpp" />
<ClCompile Include="..\hook_callbacks.cpp" /> <ClCompile Include="..\hook_callbacks.cpp" />
<ClCompile Include="..\hook_create.cpp" /> <ClCompile Include="..\hook_create.cpp" />
@ -113,6 +114,8 @@
<ClCompile Include="..\srvcmd.cpp" /> <ClCompile Include="..\srvcmd.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\public\HLTypeConversion.h" />
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h" />
<ClInclude Include="..\call_funcs.h" /> <ClInclude Include="..\call_funcs.h" />
<ClInclude Include="..\forward.h" /> <ClInclude Include="..\forward.h" />
<ClInclude Include="..\hook.h" /> <ClInclude Include="..\hook.h" />
@ -127,8 +130,6 @@
<ClInclude Include="..\DataHandler.h" /> <ClInclude Include="..\DataHandler.h" />
<ClInclude Include="..\ham_const.h" /> <ClInclude Include="..\ham_const.h" />
<ClInclude Include="..\ham_utils.h" /> <ClInclude Include="..\ham_utils.h" />
<ClInclude Include="..\NEW_Util.h" />
<ClInclude Include="..\offsets.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\..\plugins\include\ham_const.inc" /> <None Include="..\..\..\plugins\include\ham_const.inc" />

View File

@ -30,6 +30,9 @@
<UniqueIdentifier>{1f536280-a798-4422-847e-ed6e8df80258}</UniqueIdentifier> <UniqueIdentifier>{1f536280-a798-4422-847e-ed6e8df80258}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter> </Filter>
<Filter Include="Memtools">
<UniqueIdentifier>{c26eb07d-14b7-49e9-9122-6b7f5a711ecf}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\call_funcs.cpp"> <ClCompile Include="..\call_funcs.cpp">
@ -65,6 +68,9 @@
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp"> <ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp">
<Filter>Module SDK\SDK Base</Filter> <Filter>Module SDK\SDK Base</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\public\memtools\MemoryUtils.cpp">
<Filter>Memtools</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\call_funcs.h"> <ClInclude Include="..\call_funcs.h">
@ -100,12 +106,6 @@
<ClInclude Include="..\ham_utils.h"> <ClInclude Include="..\ham_utils.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\NEW_Util.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\offsets.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\hook_specialbot.h"> <ClInclude Include="..\hook_specialbot.h">
<Filter>Hooks</Filter> <Filter>Hooks</Filter>
</ClInclude> </ClInclude>
@ -115,6 +115,12 @@
<ClInclude Include="..\moduleconfig.h"> <ClInclude Include="..\moduleconfig.h">
<Filter>Module SDK</Filter> <Filter>Module SDK</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\public\HLTypeConversion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\public\memtools\MemoryUtils.h">
<Filter>Memtools</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\..\plugins\include\ham_const.inc"> <None Include="..\..\..\plugins\include\ham_const.inc">

View File

@ -13,17 +13,8 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include "offsets.h" #include "offsets.h"
#include "NEW_Util.h"
#include "ham_utils.h" #include "ham_utils.h"
inline edict_t* INDEXENT2( int iEdictNum )
{
if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients)
return MF_GetPlayerEdict(iEdictNum);
else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
#ifdef DONT_TOUCH_THIS_AGAIN_BAIL #ifdef DONT_TOUCH_THIS_AGAIN_BAIL
#define FM_CHECK_ENTITY(x) \ #define FM_CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \ if (x < 0 || x > gpGlobals->maxEntities) { \
@ -48,7 +39,7 @@ inline edict_t* INDEXENT2( int iEdictNum )
if (x < 0 || x > gpGlobals->maxEntities) { \ if (x < 0 || x > gpGlobals->maxEntities) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \
return 0; \ return 0; \
} else if (x != 0 && FNullEnt(INDEXENT2(x))) { \ } else if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \
return 0; \ return 0; \
} }
@ -73,16 +64,16 @@ static cell AMX_NATIVE_CALL get_pdata_cbase_safe(AMX *amx, cell *params)
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset); MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
return 0; return 0;
} }
void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)); void *ptr = get_pdata<void*>(TypeConversion.id_to_edict(index), iOffset * 4); // *4 because macro is char-based and native is int-based.
if (ptr == 0) if (!ptr)
{ {
return -1; return -1;
} }
for (int i=0; i<gpGlobals->maxEntities; ++i) for (int i=0; i<gpGlobals->maxEntities; ++i)
{ {
if (ptr == INDEXENT_NEW(i)->pvPrivateData) if (ptr == TypeConversion.id_to_cbase(i))
{ {
return i; return i;
} }
@ -90,6 +81,7 @@ static cell AMX_NATIVE_CALL get_pdata_cbase_safe(AMX *amx, cell *params)
return -2; return -2;
} }
static cell AMX_NATIVE_CALL get_pdata_cbase(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_cbase(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
@ -110,10 +102,11 @@ static cell AMX_NATIVE_CALL get_pdata_cbase(AMX *amx, cell *params)
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset); MF_LogError(amx, AMX_ERR_NATIVE, "Invalid offset provided. (got: %d)", iOffset);
return 0; return 0;
} }
void *ptr=*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)); void *ptr = get_pdata<void*>(TypeConversion.id_to_edict(index), iOffset * 4);
return PrivateToIndex(ptr); return TypeConversion.cbase_to_id(ptr);
} }
static cell AMX_NATIVE_CALL set_pdata_cbase(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_cbase(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
@ -142,11 +135,11 @@ static cell AMX_NATIVE_CALL set_pdata_cbase(AMX *amx, cell *params)
if (target == -1) if (target == -1)
{ {
*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)) = NULL; set_pdata<void*>(TypeConversion.id_to_edict(index), iOffset * 4, nullptr);
} }
else else
{ {
*((void **)((int *)INDEXENT_NEW(index)->pvPrivateData + iOffset)) = INDEXENT_NEW(target)->pvPrivateData; set_pdata<void*>(TypeConversion.id_to_edict(index), iOffset * 4, TypeConversion.id_to_cbase(target));
} }
return 1; return 1;

View File

@ -12,32 +12,15 @@
// //
#include "amxxmodule.h" #include "amxxmodule.h"
#include <stdarg.h>
#include <amtl/am-vector.h> #include <amtl/am-vector.h>
#include "ham_const.h" #include "ham_const.h"
#include "hooklist.h" #include "hooklist.h"
#include "offsets.h" #include "offsets.h"
#include "forward.h"
#include "hook.h" #include "hook.h"
extern hook_t hooklist[]; extern hook_t hooklist[];
extern ke::Vector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL]; extern ke::Vector<Hook *> hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL];
void print_srvconsole(const char *fmt, ...)
{
va_list argptr;
static char string[384];
va_start(argptr, fmt);
vsnprintf(string, sizeof(string) - 1, fmt, argptr);
string[sizeof(string) - 1] = '\0';
va_end(argptr);
SERVER_PRINT(string);
}
void HamCommand(void) void HamCommand(void)
{ {
const char *cmd=CMD_ARGV(1); const char *cmd=CMD_ARGV(1);
@ -45,10 +28,11 @@ void HamCommand(void)
if (strcmp(cmd, "list")==0) if (strcmp(cmd, "list")==0)
{ {
unsigned int Total=0; unsigned int Total=0;
print_srvconsole("%-24s | %10s\n","Name","Set","Value");
print_srvconsole("------------------------------------\n"); MF_PrintSrvConsole("%-24s | %10s\n","Name","Set","Value");
print_srvconsole("%-24s | %10d\n", "pev", Offsets.GetPev()); MF_PrintSrvConsole("------------------------------------\n");
print_srvconsole("%-24s | %10d\n", "base", Offsets.GetBase()); MF_PrintSrvConsole("%-24s | %10d\n", "pev", Offsets.GetPev());
MF_PrintSrvConsole("%-24s | %10d\n", "base", Offsets.GetBase());
if (Offsets.IsPevSet()) if (Offsets.IsPevSet())
{ {
@ -66,7 +50,7 @@ void HamCommand(void)
if (hooklist[i].isset != 0) if (hooklist[i].isset != 0)
{ {
print_srvconsole("%-24s | %10d\n", hooklist[i].name, hooklist[i].vtid); MF_PrintSrvConsole("%-24s | %10d\n", hooklist[i].name, hooklist[i].vtid);
Total++; Total++;
count++; count++;
} }
@ -74,19 +58,19 @@ void HamCommand(void)
if (count >= 5) if (count >= 5)
{ {
count = 0; count = 0;
print_srvconsole("------------------------------------\n"); MF_PrintSrvConsole("------------------------------------\n");
} }
} }
print_srvconsole("\n%u keys, %u set.\n\n", HAM_LAST_ENTRY_DONT_USE_ME_LOL, Total); MF_PrintSrvConsole("\n%u keys, %u set.\n\n", HAM_LAST_ENTRY_DONT_USE_ME_LOL, Total);
return; return;
} }
else if (strcmp(cmd, "hooks")==0) else if (strcmp(cmd, "hooks")==0)
{ {
print_srvconsole("%-24s | %-27s | %10s | %10s\n", "Key", "Classname", "Pre", "Post"); MF_PrintSrvConsole("%-24s | %-27s | %10s | %10s\n", "Key", "Classname", "Pre", "Post");
print_srvconsole("--------------------------------------------------------------------------------\n"); MF_PrintSrvConsole("--------------------------------------------------------------------------------\n");
unsigned int ForwardCount=0; unsigned int ForwardCount=0;
unsigned int HookCount=0; unsigned int HookCount=0;
int count = 0; int count = 0;
@ -97,20 +81,20 @@ void HamCommand(void)
HookCount++; HookCount++;
ForwardCount += hooks[i].at(j)->pre.length() + hooks[i].at(j)->post.length(); ForwardCount += hooks[i].at(j)->pre.length() + hooks[i].at(j)->post.length();
print_srvconsole("%-24s | %-27s | %10d | %10d\n", hooklist[i].name, hooks[i].at(j)->ent, hooks[i].at(j)->pre.length(), hooks[i].at(j)->post.length()); MF_PrintSrvConsole("%-24s | %-27s | %10d | %10d\n", hooklist[i].name, hooks[i].at(j)->ent, hooks[i].at(j)->pre.length(), hooks[i].at(j)->post.length());
if (count >= 5) if (count >= 5)
{ {
print_srvconsole("--------------------------------------------------------------------------------\n"); MF_PrintSrvConsole("--------------------------------------------------------------------------------\n");
} }
} }
} }
print_srvconsole("\n%u hooks, %u forwards.\n\n", HookCount, ForwardCount); MF_PrintSrvConsole("\n%u hooks, %u forwards.\n\n", HookCount, ForwardCount);
return; return;
} }
// Unknown command // Unknown command
print_srvconsole("Usage: ham < command > [ argument ]\n"); MF_PrintSrvConsole("Usage: ham < command > [ argument ]\n");
print_srvconsole("Commands:\n"); MF_PrintSrvConsole("Commands:\n");
print_srvconsole(" %-22s - %s\n", "list", "list all keys and their values from the config file."); MF_PrintSrvConsole(" %-22s - %s\n", "list", "list all keys and their values from the config file.");
print_srvconsole(" %-22s - %s\n", "hooks", "list all active hooks"); MF_PrintSrvConsole(" %-22s - %s\n", "hooks", "list all active hooks");
} }

View File

@ -9,7 +9,8 @@
#ifndef _HL_CONVERSION_TYPE_H_ #ifndef _HL_CONVERSION_TYPE_H_
#define _HL_CONVERSION_TYPE_H_ #define _HL_CONVERSION_TYPE_H_
#include "amxxmodule.h" #include <stddef.h> // size_t
#include <extdll.h> // edict_t, etc.
template <typename T> static inline T& ref_pdata(void *pPrivateData, int offset, int element = 0) template <typename T> static inline T& ref_pdata(void *pPrivateData, int offset, int element = 0)
{ {
@ -98,7 +99,7 @@ class HLTypeConversion
void* id_to_cbase(int index) void* id_to_cbase(int index)
{ {
edict_t *pEdict = id_to_edict(index); auto pEdict = id_to_edict(index);
return pEdict ? pEdict->pvPrivateData : nullptr; return pEdict ? pEdict->pvPrivateData : nullptr;
} }
@ -126,7 +127,7 @@ class HLTypeConversion
entvars_t* id_to_entvars(int index) entvars_t* id_to_entvars(int index)
{ {
edict_t *pEdict = id_to_edict(index); auto pEdict = id_to_edict(index);
return pEdict ? VARS(pEdict) : nullptr; return pEdict ? VARS(pEdict) : nullptr;
} }
@ -147,19 +148,23 @@ class HLTypeConversion
return entvars_to_id(cbase_to_entvar(cbase)); return entvars_to_id(cbase_to_entvar(cbase));
} }
public:
size_t get_pev()
{
return m_PevOffset;
}
private: private:
void search_pev() void search_pev()
{ {
entvars_t *pev = VARS(m_FirstEdict); auto pev = VARS(m_FirstEdict);
auto privateData = reinterpret_cast<byte*>(m_FirstEdict->pvPrivateData);
byte *privateData = reinterpret_cast<byte*>(m_FirstEdict->pvPrivateData);
for (size_t i = 0; i < 0xFFF; ++i) for (size_t i = 0; i < 0xFFF; ++i)
{ {
entvars_t *val = *(reinterpret_cast<entvars_t**>(privateData + i)); if (*reinterpret_cast<entvars_t**>(privateData + i) == pev)
if (val == pev)
{ {
m_PevOffset = i; m_PevOffset = i;
return; return;