Merge pull request #297 from Arkshine/fix/invalid-edict-on-last-player

Fix some natives relying on a known engine bug related to last player's edict being invalid
This commit is contained in:
Vincent Herbet 2015-10-08 19:52:27 +02:00
commit cae7281def
59 changed files with 567 additions and 989 deletions

View File

@ -83,7 +83,7 @@ static cell AMX_NATIVE_CALL emit_sound(AMX *amx, cell *params) /* 7 param */
EMIT_SOUND_DYN2(pPlayer->pEdict, channel, szSample, vol, att, flags, pitch); EMIT_SOUND_DYN2(pPlayer->pEdict, channel, szSample, vol, att, flags, pitch);
} }
} else { } else {
edict_t* pEdict = INDEXENT(params[1]); edict_t* pEdict = TypeConversion.id_to_edict(params[1]);
if (!FNullEnt(pEdict)) if (!FNullEnt(pEdict))
EMIT_SOUND_DYN2(pEdict, channel, szSample, vol, att, flags, pitch); EMIT_SOUND_DYN2(pEdict, channel, szSample, vol, att, flags, pitch);

View File

@ -52,6 +52,7 @@
#include "CvarManager.h" #include "CvarManager.h"
#include "CoreConfig.h" #include "CoreConfig.h"
#include <amxmodx_version.h> #include <amxmodx_version.h>
#include <HLTypeConversion.h>
#define AMXXLOG_Log g_log.Log #define AMXXLOG_Log g_log.Log
#define AMXXLOG_Error g_log.LogError #define AMXXLOG_Error g_log.LogError
@ -368,5 +369,6 @@ enum PrintColor
}; };
extern enginefuncs_t *g_pEngTable; extern enginefuncs_t *g_pEngTable;
extern HLTypeConversion TypeConversion;
#endif // AMXMODX_H #endif // AMXMODX_H

View File

@ -423,7 +423,7 @@ static cell _message_begin(AMX *amx, cell *params, bool useFloat) /* 4 param */
return 0; return 0;
} }
MESSAGE_BEGIN(params[1], params[2], NULL, INDEXENT(params[4])); MESSAGE_BEGIN(params[1], params[2], NULL, TypeConversion.id_to_edict(params[4]));
break; break;
} }
@ -771,7 +771,7 @@ static cell _emessage_begin(AMX *amx, cell *params, bool useFloat)
return 0; return 0;
} }
g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, INDEXENT(params[4])); g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, TypeConversion.id_to_edict(params[4]));
break; break;
} }

View File

@ -147,6 +147,7 @@ int FF_ClientAuthorized = -1;
int FF_ChangeLevel = -1; int FF_ChangeLevel = -1;
IFileSystem* g_FileSystem; IFileSystem* g_FileSystem;
HLTypeConversion TypeConversion;
bool ColoredMenus(const char *ModName) bool ColoredMenus(const char *ModName)
{ {
@ -518,6 +519,8 @@ int C_Spawn(edict_t *pent)
modules_callPluginsLoaded(); modules_callPluginsLoaded();
TypeConversion.init();
// ###### Call precache forward function // ###### Call precache forward function
g_dontprecache = false; g_dontprecache = false;
executeForwards(FF_PluginPrecache); executeForwards(FF_PluginPrecache);

View File

@ -63,7 +63,7 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params)
} }
pEnt = GET_PLAYER_POINTER_I(iEnt)->pEdict; pEnt = GET_PLAYER_POINTER_I(iEnt)->pEdict;
} else { } else {
pEnt = INDEXENT(iEnt); pEnt = TypeConversion.id_to_edict(iEnt);
} }
} }

View File

@ -15,7 +15,6 @@ binary.sources = [
'CstrikeHacks.cpp', 'CstrikeHacks.cpp',
'CstrikeUtils.cpp', 'CstrikeUtils.cpp',
'CstrikeUserMessages.cpp', 'CstrikeUserMessages.cpp',
'CstrikeHLTypeConversion.cpp',
'../../../public/memtools/MemoryUtils.cpp', '../../../public/memtools/MemoryUtils.cpp',
'../../../public/memtools/CDetour/detours.cpp', '../../../public/memtools/CDetour/detours.cpp',
'../../../public/memtools/CDetour/asm/asm.c', '../../../public/memtools/CDetour/asm/asm.c',

View File

@ -14,8 +14,6 @@
#ifndef CSTRIKE_DATA_H #ifndef CSTRIKE_DATA_H
#define CSTRIKE_DATA_H #define CSTRIKE_DATA_H
#include "amxxmodule.h"
/** /**
* Weapon Ids for use with CS_OnBuyAttempt(), CS_OnBuy(). * Weapon Ids for use with CS_OnBuyAttempt(), CS_OnBuy().
*/ */

View File

@ -1,119 +0,0 @@
//
// 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
//
// Counter-Strike Module
//
#include "CstrikeHLTypeConversion.h"
OffsetHandler* G_OffsetHandler;
HL_TypeConversion G_HL_TypeConversion;
void OffsetHandler::search_pev()
{
edict_t *pEdict = INDEXENT(0);
entvars_t *pev = VARS(pEdict);
byte *privateData = reinterpret_cast<byte*>(pEdict->pvPrivateData);
for (int i = 0; i < 0xFFF; i++)
{
entvars_t *val = *(reinterpret_cast<entvars_t**>(privateData + i));
if (val == pev)
{
this->pev = i;
return;
}
}
// This should not happen.
this->pev = 0;
}
inline edict_t* HL_TypeConversion::INDEXENT2(int iEdictNum)
{
if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients)
{
return MF_GetPlayerEdict(iEdictNum);
}
else
{
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
}
edict_t* HL_TypeConversion::entvar_to_edict(entvars_t *pev)
{
if (!pev)
{
return nullptr;
}
return pev->pContainingEntity;
}
int HL_TypeConversion::entvar_to_id(entvars_t *pev)
{
if (!pev)
{
return -1;
}
if (!pev->pContainingEntity)
{
return -1;
}
return ENTINDEX(pev->pContainingEntity);
}
void* HL_TypeConversion::id_to_cbase(int index)
{
edict_t* edict = INDEXENT2(index);
return edict ? edict->pvPrivateData : nullptr;
}
entvars_t* HL_TypeConversion::id_to_entvar(int index)
{
edict_t *pEdict = INDEXENT2(index);
return pEdict ? VARS(pEdict) : nullptr;
}
entvars_t* HL_TypeConversion::cbase_to_entvar(void* cbase)
{
if (!cbase)
{
return nullptr;
}
return *reinterpret_cast<entvars_t**>(reinterpret_cast<int8*>(cbase) + G_OffsetHandler->pev);
}
int HL_TypeConversion::cbase_to_id(void *cbase)
{
if (!cbase)
{
return -1;
}
entvars_t *pev = this->cbase_to_entvar(cbase);
if (!pev)
{
return -1;
}
if (!pev->pContainingEntity || FNullEnt(pev->pContainingEntity))
{
return -1;
}
return ENTINDEX(pev->pContainingEntity);
}

View File

@ -1,49 +0,0 @@
//
// 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
//
// Counter-Strike Module
//
#ifndef HL_TYPE_CONVERSION_H
#define HL_TYPE_CONVERSION_H
#include "amxxmodule.h"
struct OffsetHandler
{
int pev;
void search_pev();
OffsetHandler()
{
search_pev();
}
};
class HL_TypeConversion
{
public:
inline edict_t* INDEXENT2(int iEdictNum);
edict_t* entvar_to_edict(entvars_t *pev);
int entvar_to_id(entvars_t *pev);
void* id_to_cbase(int index);
int cbase_to_id(void *cbase);
entvars_t* id_to_entvar(int index);
entvars_t* cbase_to_entvar(void* cbase);
};
extern OffsetHandler* G_OffsetHandler;
extern HL_TypeConversion G_HL_TypeConversion;
#endif // HL_TYPE_CONVERSION_H

View File

@ -14,7 +14,6 @@
#include "CstrikeDatas.h" #include "CstrikeDatas.h"
#include "CstrikeUtils.h" #include "CstrikeUtils.h"
#include "CstrikeHacks.h" #include "CstrikeHacks.h"
#include "CstrikeHLTypeConversion.h"
#include <sm_stringhashmap.h> #include <sm_stringhashmap.h>
void CtrlDetours_ClientCommand(bool set); void CtrlDetours_ClientCommand(bool set);
@ -213,7 +212,7 @@ DETOUR_DECL_MEMBER1(GiveNamedItem, void, const char*, pszName) // void CBasePlay
// If the current item id is not null, this means player has triggers a buy command. // If the current item id is not null, this means player has triggers a buy command.
if (CurrentItemId) if (CurrentItemId)
{ {
int client = G_HL_TypeConversion.cbase_to_id(this); int client = TypeConversion.cbase_to_id(this);
if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0) if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), static_cast<cell>(CurrentItemId)) > 0)
{ {
@ -234,7 +233,7 @@ DETOUR_DECL_MEMBER1(GiveShield, void, bool, bRetire) // void CBasePlayer::GiveSh
// Special case for shield. Game doesn't use GiveNamedItem() to give a shield. // Special case for shield. Game doesn't use GiveNamedItem() to give a shield.
if (CurrentItemId == CSI_SHIELDGUN) if (CurrentItemId == CSI_SHIELDGUN)
{ {
int client = G_HL_TypeConversion.cbase_to_id(this); int client = TypeConversion.cbase_to_id(this);
if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), CSI_SHIELDGUN) > 0) if (MF_IsPlayerAlive(client) && MF_ExecuteForward(ForwardOnBuy, static_cast<cell>(client), CSI_SHIELDGUN) > 0)
{ {

View File

@ -13,16 +13,15 @@
#include "amxxmodule.h" #include "amxxmodule.h"
#include "CstrikeUtils.h" #include "CstrikeUtils.h"
#include "CstrikeDatas.h"
#include "CstrikeHacks.h" #include "CstrikeHacks.h"
#include "CstrikeHLTypeConversion.h"
#include <IGameConfigs.h> #include <IGameConfigs.h>
#include "engine_strucs.h"
IGameConfig *MainConfig; IGameConfig *MainConfig;
IGameConfig *CommonConfig; IGameConfig *CommonConfig;
IGameConfigManager *ConfigManager; IGameConfigManager *ConfigManager;
HLTypeConversion TypeConversion;
int AmxxCheckGame(const char *game) int AmxxCheckGame(const char *game)
{ {
if (strcasecmp(game, "cstrike") == 0 || if (strcasecmp(game, "cstrike") == 0 ||
@ -75,11 +74,8 @@ void OnPluginsLoaded()
ToggleDetour_ClientCommands(ForwardInternalCommand != -1 || ForwardOnBuy != -1 || ForwardOnBuyAttempt != -1); ToggleDetour_ClientCommands(ForwardInternalCommand != -1 || ForwardOnBuy != -1 || ForwardOnBuyAttempt != -1);
ToggleDetour_BuyCommands(ForwardOnBuy != -1); ToggleDetour_BuyCommands(ForwardOnBuy != -1);
// Search pev offset automatically. // Search pev/vtable offset automatically.
if (!G_OffsetHandler) TypeConversion.init();
{
G_OffsetHandler = new OffsetHandler;
}
// Used with model natives, enabled on demand. // Used with model natives, enabled on demand.
g_pengfuncsTable->pfnSetClientKeyValue = nullptr; g_pengfuncsTable->pfnSetClientKeyValue = nullptr;

View File

@ -16,9 +16,7 @@
#include "CstrikeUtils.h" #include "CstrikeUtils.h"
#include "CstrikeHacks.h" #include "CstrikeHacks.h"
#include "CstrikeUserMessages.h" #include "CstrikeUserMessages.h"
#include "CstrikeHLTypeConversion.h"
#include <CDetour/detours.h> #include <CDetour/detours.h>
#include <amtl/am-vector.h>
#include <amtl/am-string.h> #include <amtl/am-string.h>
bool NoKifesMode = false; bool NoKifesMode = false;
@ -1006,7 +1004,7 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params)
set_pdata<void*>(pImprov, m_behavior + 4 + m_state, reinterpret_cast<int8*>(pImprov) + m_followState); set_pdata<void*>(pImprov, m_behavior + 4 + m_state, reinterpret_cast<int8*>(pImprov) + m_followState);
set_pdata<float>(pImprov, m_behavior + 4 + m_stateTimer, gpGlobals->time); set_pdata<float>(pImprov, m_behavior + 4 + m_stateTimer, gpGlobals->time);
get_pdata<EHANDLE>(pImprov, m_followState + m_leader).Set(GETEDICT(target)); get_pdata<EHANDLE>(pImprov, m_followState + m_leader).Set(TypeConversion.id_to_edict(target));
} }
else else
{ {
@ -1018,7 +1016,7 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params)
} }
else else
{ {
get_pdata<EHANDLE>(pHostage, m_hTargetEnt).Set(target ? GETEDICT(target) : nullptr); get_pdata<EHANDLE>(pHostage, m_hTargetEnt).Set(target ? TypeConversion.id_to_edict(target) : nullptr);
} }
return 1; return 1;
@ -1728,10 +1726,10 @@ static cell AMX_NATIVE_CALL cs_find_ent_by_class(AMX* amx, cell* params)
} }
int len; int len;
void* pEntity = G_HL_TypeConversion.id_to_cbase(params[1]); void* pEntity = TypeConversion.id_to_cbase(params[1]);
const char* value = MF_GetAmxString(amx, params[2], 0, &len); const char* value = MF_GetAmxString(amx, params[2], 0, &len);
int index = G_HL_TypeConversion.cbase_to_id(CS_UTIL_FindEntityByString(pEntity, "classname", value)); int index = TypeConversion.cbase_to_id(CS_UTIL_FindEntityByString(pEntity, "classname", value));
if (index != -1) if (index != -1)
{ {

View File

@ -14,6 +14,10 @@
#ifndef CSTRIKE_UTILS_H #ifndef CSTRIKE_UTILS_H
#define CSTRIKE_UTILS_H #define CSTRIKE_UTILS_H
#include <HLTypeConversion.h>
extern HLTypeConversion TypeConversion;
bool UTIL_IsPlayer(edict_t *pPlayer); bool UTIL_IsPlayer(edict_t *pPlayer);
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message); void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message);
bool UTIL_CheckForPublic(const char *publicname); bool UTIL_CheckForPublic(const char *publicname);
@ -70,10 +74,6 @@ bool UTIL_CheckForPublic(const char *publicname);
return 0; \ return 0; \
} }
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))
#define GET_OFFSET(classname, member) \ #define GET_OFFSET(classname, member) \
static int member = -1; \ static int member = -1; \
if (member == -1) \ if (member == -1) \
@ -99,71 +99,6 @@ bool UTIL_CheckForPublic(const char *publicname);
member = type.fieldOffset; \ member = type.fieldOffset; \
} }
template <typename T>
inline T& get_pdata(edict_t *pEntity, int offset, int element = 0)
{
return *reinterpret_cast<T*>(reinterpret_cast<int8*>(pEntity->pvPrivateData) + offset + element * sizeof(T));
}
template <typename T>
inline T& get_pdata(void *pEntity, int offset, int element = 0)
{
return *reinterpret_cast<T*>(reinterpret_cast<int8*>(pEntity) + offset + element * sizeof(T));
}
template <typename T>
inline void set_pdata(edict_t *pEntity, int offset, T value, int element = 0)
{
*reinterpret_cast<T*>(reinterpret_cast<int8*>(pEntity->pvPrivateData) + offset + element * sizeof(T)) = value;
}
template <typename T>
inline void set_pdata(void *pEntity, int offset, T value, int element = 0)
{
*reinterpret_cast<T*>(reinterpret_cast<int8*>(pEntity) + offset + element * sizeof(T)) = value;
}
class EHANDLE
{
private:
edict_t* m_pent;
int m_serialnumber;
public:
edict_t* Get(void)
{
if (!FNullEnt(m_pent))
{
if (m_pent->serialnumber == m_serialnumber)
{
return m_pent;
}
return nullptr;
}
return nullptr;
};
edict_t* Set(edict_t *pent)
{
if (!FNullEnt(pent))
{
m_pent = pent;
m_serialnumber = m_pent->serialnumber;
}
else
{
m_pent = nullptr;
m_serialnumber = 0;
}
return pent;
};
};
class CUnifiedSignals class CUnifiedSignals
{ {
public: public:

View File

@ -146,7 +146,6 @@
<ClCompile Include="..\..\..\..\public\memtools\MemoryUtils.cpp" /> <ClCompile Include="..\..\..\..\public\memtools\MemoryUtils.cpp" />
<ClCompile Include="..\CstrikeMain.cpp" /> <ClCompile Include="..\CstrikeMain.cpp" />
<ClCompile Include="..\CstrikeHacks.cpp" /> <ClCompile Include="..\CstrikeHacks.cpp" />
<ClCompile Include="..\CstrikeHLTypeConversion.cpp" />
<ClCompile Include="..\CstrikeNatives.cpp" /> <ClCompile Include="..\CstrikeNatives.cpp" />
<ClCompile Include="..\CstrikePlayer.cpp" /> <ClCompile Include="..\CstrikePlayer.cpp" />
<ClCompile Include="..\CstrikeUserMessages.cpp" /> <ClCompile Include="..\CstrikeUserMessages.cpp" />

View File

@ -53,9 +53,6 @@
<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="..\CstrikeHLTypeConversion.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\CstrikeUserMessages.cpp"> <ClCompile Include="..\CstrikeUserMessages.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View File

@ -662,7 +662,7 @@ static cell AMX_NATIVE_CALL objectives_reinit(AMX *amx, cell *params){ // index
MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", player); MF_LogError(amx, AMX_ERR_NATIVE, "Index out of range (%d)", player);
return 0; return 0;
} }
mObjects.InitObj( player == 0 ? MSG_ALL:MSG_ONE, player == 0 ? NULL:INDEXENT(player) ); mObjects.InitObj( player == 0 ? MSG_ALL:MSG_ONE, player == 0 ? NULL: GETEDICT(player) );
return 1; return 1;
} }

View File

@ -44,7 +44,7 @@ void Client_InitObj(void* mValue){
mObjects.Clear(); mObjects.Clear();
break; break;
case 1: case 1:
mObjects.obj[num].pEdict = INDEXENT(*(int*)mValue); mObjects.obj[num].pEdict = GETEDICT(*(int*)mValue);
break; break;
case 2: case 2:
mObjects.obj[num].index = *(int*)mValue; mObjects.obj[num].index = *(int*)mValue;

View File

@ -577,7 +577,7 @@ static cell AMX_NATIVE_CALL dod_weaponlist(AMX *amx, cell *params) // player
return 0; return 0;
} }
MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "WeaponList", NULL), NULL, INDEXENT(id)); MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "WeaponList", NULL), NULL, pPlayer->pEdict);
WRITE_BYTE(weaponlist[wpnID].grp); WRITE_BYTE(weaponlist[wpnID].grp);
WRITE_BYTE(totalrds); WRITE_BYTE(totalrds);
WRITE_BYTE(-1); WRITE_BYTE(-1);

View File

@ -18,8 +18,7 @@ void CreateDetours();
void DestroyDetours(); void DestroyDetours();
CDetour *LightStyleDetour = NULL; CDetour *LightStyleDetour = NULL;
HLTypeConversion TypeConversion;
edict_t *g_player_edicts[33];
int AmxStringToEngine(AMX *amx, cell param, int &len) int AmxStringToEngine(AMX *amx, cell param, int &len)
{ {
@ -73,6 +72,8 @@ void OnAmxxDetach()
void OnPluginsLoaded() void OnPluginsLoaded()
{ {
TypeConversion.init();
g_CameraCount=0; g_CameraCount=0;
pfnThinkForward = MF_RegisterForward("pfn_think", ET_STOP, FP_CELL, FP_DONE); // done pfnThinkForward = MF_RegisterForward("pfn_think", ET_STOP, FP_CELL, FP_DONE); // done
PlayerPreThinkForward = MF_RegisterForward("client_PreThink", ET_STOP, FP_CELL, FP_DONE); // done PlayerPreThinkForward = MF_RegisterForward("client_PreThink", ET_STOP, FP_CELL, FP_DONE); // done
@ -176,7 +177,7 @@ void ClientDisconnect(edict_t *pEntity)
{ {
int id = ENTINDEX(pEntity); int id = ENTINDEX(pEntity);
if (plinfo[ENTINDEX(pEntity)].iViewType != CAMERA_NONE) // Verify that they were originally in a modified view if (plinfo[id].iViewType != CAMERA_NONE) // Verify that they were originally in a modified view
{ {
g_CameraCount--; g_CameraCount--;
if (g_CameraCount < 0) if (g_CameraCount < 0)
@ -226,14 +227,6 @@ void ServerDeactivate()
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
for(int f = 1; f <= gpGlobals->maxClients;f++)
g_player_edicts[f]=pEdictList + f;
RETURN_META(MRES_IGNORED);
}
DETOUR_DECL_STATIC2(LightStyle, void, int, style, const char *, val) // void (*pfnLightStyle) (int style, const char* val); DETOUR_DECL_STATIC2(LightStyle, void, int, style, const char *, val) // void (*pfnLightStyle) (int style, const char* val);
{ {
DETOUR_STATIC_CALL(LightStyle)(style, val); DETOUR_STATIC_CALL(LightStyle)(style, val);

View File

@ -287,7 +287,7 @@ static cell AMX_NATIVE_CALL trace_normal(AMX *amx, cell *params)
Vector vStart = Vector(fStartX, fStartY, fStartZ); Vector vStart = Vector(fStartX, fStartY, fStartZ);
Vector vEnd = Vector(fEndX, fEndY, fEndZ); Vector vEnd = Vector(fEndX, fEndY, fEndZ);
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, iEnt > 0 ? INDEXENT2(iEnt) : NULL, &g_tr); TRACE_LINE(vStart, vEnd, dont_ignore_monsters, iEnt > 0 ? TypeConversion.id_to_edict(iEnt) : NULL, &g_tr);
vRet[0] = amx_ftoc(g_tr.vecPlaneNormal.x); vRet[0] = amx_ftoc(g_tr.vecPlaneNormal.x);
vRet[1] = amx_ftoc(g_tr.vecPlaneNormal.y); vRet[1] = amx_ftoc(g_tr.vecPlaneNormal.y);
@ -321,7 +321,7 @@ static cell AMX_NATIVE_CALL trace_line(AMX *amx, cell *params)
Vector vEnd = Vector(fEndX, fEndY, fEndZ); Vector vEnd = Vector(fEndX, fEndY, fEndZ);
if (iEnt > 0) if (iEnt > 0)
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iEnt), &g_tr); TRACE_LINE(vStart, vEnd, dont_ignore_monsters, TypeConversion.id_to_edict(iEnt), &g_tr);
else else
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &g_tr); TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &g_tr);
@ -376,7 +376,7 @@ static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params)
CHECK_ENTITY(iEnt); CHECK_ENTITY(iEnt);
} }
char *info = GETINFOKEYBUFFER((iEnt == -1) ? NULL : INDEXENT2(iEnt)); char *info = GETINFOKEYBUFFER((iEnt == -1) ? NULL : TypeConversion.id_to_edict(iEnt));
return MF_SetAmxStringUTF8Char(amx, params[2], info, strlen(info), params[3]); return MF_SetAmxStringUTF8Char(amx, params[2], info, strlen(info), params[3]);
} }
@ -389,7 +389,7 @@ static cell AMX_NATIVE_CALL drop_to_floor(AMX *amx, cell *params)
CHECK_ENTITY(iEnt); CHECK_ENTITY(iEnt);
edict_t *e = INDEXENT2(iEnt); edict_t *e = TypeConversion.id_to_edict(iEnt);
return DROP_TO_FLOOR(e); return DROP_TO_FLOOR(e);
} }
@ -405,7 +405,7 @@ static cell AMX_NATIVE_CALL attach_view(AMX *amx, cell *params)
CHECK_ENTITY(iIndex); CHECK_ENTITY(iIndex);
CHECK_ENTITY(iTargetIndex); CHECK_ENTITY(iTargetIndex);
SET_VIEW(INDEXENT2(iIndex), INDEXENT2(iTargetIndex)); SET_VIEW(TypeConversion.id_to_edict(iIndex), TypeConversion.id_to_edict(iTargetIndex));
return 1; return 1;
} }
@ -422,7 +422,7 @@ static cell AMX_NATIVE_CALL set_view(AMX *amx, cell *params) {
return 0; return 0;
} }
edict_t *pPlayer = INDEXENT2(iIndex); edict_t *pPlayer = TypeConversion.id_to_edict(iIndex);
edict_t *pNewCamera; edict_t *pNewCamera;
switch(iCameraType) switch(iCameraType)
@ -603,7 +603,7 @@ static cell AMX_NATIVE_CALL trace_hull(AMX *amx,cell *params)
vEnd = vStart; vEnd = vStart;
TRACE_HULL(vStart, vEnd, params[4], params[2], iEnt > 0 ? INDEXENT2(iEnt) : NULL, &g_tr); TRACE_HULL(vStart, vEnd, params[4], params[2], iEnt > 0 ? TypeConversion.id_to_edict(iEnt) : NULL, &g_tr);
if (g_tr.fStartSolid) { if (g_tr.fStartSolid) {
iResult += 1; iResult += 1;
@ -640,7 +640,7 @@ static cell AMX_NATIVE_CALL playback_event(AMX *amx, cell *params)
if (params[2] > 0) { if (params[2] > 0) {
CHECK_ENTITY(params[2]); CHECK_ENTITY(params[2]);
} }
pInvoker=INDEXENT2(params[2]); pInvoker=TypeConversion.id_to_edict(params[2]);
eventindex=params[3]; eventindex=params[3];
delay=amx_ctof(params[4]); delay=amx_ctof(params[4]);
cell *cOrigin=MF_GetAmxAddr(amx, params[5]); cell *cOrigin=MF_GetAmxAddr(amx, params[5]);
@ -818,8 +818,8 @@ static cell AMX_NATIVE_CALL is_visible(AMX *amx, cell *params)
CHECK_ENTITY(src); CHECK_ENTITY(src);
CHECK_ENTITY(dest); CHECK_ENTITY(dest);
edict_t *pEntity = INDEXENT2(src); edict_t *pEntity = TypeConversion.id_to_edict(src);
edict_t *pTarget = INDEXENT2(dest); edict_t *pTarget = TypeConversion.id_to_edict(dest);
if (pTarget->v.flags & FL_NOTARGET) if (pTarget->v.flags & FL_NOTARGET)
return 0; return 0;
@ -846,7 +846,7 @@ static cell AMX_NATIVE_CALL in_view_cone(AMX *amx, cell *params)
CHECK_ENTITY(src); CHECK_ENTITY(src);
edict_t *pEdictSrc = INDEXENT(src); edict_t *pEdictSrc = TypeConversion.id_to_edict(src);
Vector vecLOS, vecForward; Vector vecLOS, vecForward;
float flDot; float flDot;
@ -1000,7 +1000,7 @@ static cell AMX_NATIVE_CALL trace_forward(AMX *amx, cell *params)
Vector vStart = Vector(fStartX, fStartY, fUseZ); Vector vStart = Vector(fStartX, fStartY, fUseZ);
Vector vEnd = Vector(fEndX, fEndY, fUseZ); Vector vEnd = Vector(fEndX, fEndY, fUseZ);
if(iIgnoreEnt > 0) if(iIgnoreEnt > 0)
TRACE_LINE(vStart, vEnd, dont_ignore_monsters, INDEXENT2(iIgnoreEnt), &tr); TRACE_LINE(vStart, vEnd, dont_ignore_monsters, TypeConversion.id_to_edict(iIgnoreEnt), &tr);
else else
TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr); TRACE_LINE(vStart, vEnd, ignore_monsters, NULL, &tr);
fRetX = tr.vecEndPos.x; fRetX = tr.vecEndPos.x;

View File

@ -26,6 +26,7 @@
#include <amtl/am-vector.h> #include <amtl/am-vector.h>
#include <amtl/am-string.h> #include <amtl/am-string.h>
#include <CDetour/detours.h> #include <CDetour/detours.h>
#include <HLTypeConversion.h>
extern DLL_FUNCTIONS *g_pFunctionTable; extern DLL_FUNCTIONS *g_pFunctionTable;
extern DLL_FUNCTIONS *g_pFunctionTable_Post; extern DLL_FUNCTIONS *g_pFunctionTable_Post;
@ -49,6 +50,7 @@ extern int VexdTouchForward;
extern int VexdServerForward; extern int VexdServerForward;
extern CDetour *LightStyleDetour; extern CDetour *LightStyleDetour;
extern HLTypeConversion TypeConversion;
#define AMS_OFFSET 0.01 #define AMS_OFFSET 0.01
@ -168,16 +170,6 @@ int AmxStringToEngine(AMX *amx, cell param, int &len);
edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius); edict_t *UTIL_FindEntityInSphere(edict_t *pStart, const Vector &vecCenter, float flRadius);
extern int g_CameraCount; extern int g_CameraCount;
extern edict_t *g_player_edicts[33];
inline edict_t* INDEXENT2( int iEdictNum )
{
if (iEdictNum >= 1 && iEdictNum <= gpGlobals->maxClients)
return MF_GetPlayerEdict(iEdictNum);
else
return (*g_engfuncs.pfnPEntityOfEntIndex)(iEdictNum);
}
int Spawn(edict_t *pEntity); int Spawn(edict_t *pEntity);
void PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); void PlaybackEvent(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2);
@ -196,7 +188,7 @@ void StartFrame_Post();
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 (x != 0 && FNullEnt(INDEXENT(x))) { \ 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; \
} \ } \
@ -213,7 +205,7 @@ void StartFrame_Post();
return 0; \ return 0; \
} \ } \
} else { \ } else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \ 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; \
} \ } \

View File

@ -25,7 +25,7 @@ int is_ent_valid(int iEnt)
return 0; return 0;
} }
} else { } else {
if (FNullEnt(INDEXENT(iEnt))) if (FNullEnt(TypeConversion.id_to_edict(iEnt)))
{ {
return 0; return 0;
} }
@ -46,8 +46,8 @@ static cell AMX_NATIVE_CALL entity_range(AMX *amx, cell *params)
CHECK_ENTITY(idxa); CHECK_ENTITY(idxa);
CHECK_ENTITY(idxb); CHECK_ENTITY(idxb);
edict_t *pEntA = INDEXENT2(idxa); edict_t *pEntA = TypeConversion.id_to_edict(idxa);
edict_t *pEntB = INDEXENT2(idxb); edict_t *pEntB = TypeConversion.id_to_edict(idxb);
REAL fRet = (pEntA->v.origin - pEntB->v.origin).Length(); REAL fRet = (pEntA->v.origin - pEntB->v.origin).Length();
@ -64,7 +64,7 @@ static cell AMX_NATIVE_CALL call_think(AMX *amx, cell *params)
CHECK_ENTITY(iEnt); CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
MDLL_Think(pEnt); MDLL_Think(pEnt);
@ -80,8 +80,8 @@ static cell AMX_NATIVE_CALL fake_touch(AMX *amx, cell *params)
CHECK_ENTITY(iPtr); CHECK_ENTITY(iPtr);
CHECK_ENTITY(iPtd); CHECK_ENTITY(iPtd);
edict_t *pToucher = INDEXENT2(iPtr); edict_t *pToucher = TypeConversion.id_to_edict(iPtr);
edict_t *pTouched = INDEXENT2(iPtd); edict_t *pTouched = TypeConversion.id_to_edict(iPtd);
MDLL_Touch(pToucher, pTouched); MDLL_Touch(pToucher, pTouched);
@ -96,8 +96,8 @@ static cell AMX_NATIVE_CALL force_use(AMX *amx, cell *params)
CHECK_ENTITY(iPtr); CHECK_ENTITY(iPtr);
CHECK_ENTITY(iPtd); CHECK_ENTITY(iPtd);
edict_t *pUser = INDEXENT2(iPtr); edict_t *pUser = TypeConversion.id_to_edict(iPtr);
edict_t *pUsed = INDEXENT2(iPtd); edict_t *pUsed = TypeConversion.id_to_edict(iPtd);
MDLL_Use(pUsed, pUser); MDLL_Use(pUsed, pUser);
@ -126,7 +126,7 @@ static cell AMX_NATIVE_CALL remove_entity(AMX *amx, cell *params)
return 0; return 0;
} }
edict_t *pEnt = INDEXENT2(id); edict_t *pEnt = TypeConversion.id_to_edict(id);
if (FNullEnt(pEnt)) if (FNullEnt(pEnt))
return 0; return 0;
@ -158,7 +158,7 @@ static cell AMX_NATIVE_CALL DispatchKeyValue(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iValue); CHECK_ENTITY_SIMPLE(iValue);
edict_t *pEntity = INDEXENT2(iValue); edict_t *pEntity = TypeConversion.id_to_edict(iValue);
KeyValueData kvd; KeyValueData kvd;
int iLength=0; int iLength=0;
char *char1 = MF_GetAmxString(amx, params[2], 0, &iLength); char *char1 = MF_GetAmxString(amx, params[2], 0, &iLength);
@ -193,7 +193,7 @@ static cell AMX_NATIVE_CALL get_keyvalue(AMX *amx, cell *params)
{ {
int idx = params[1]; int idx = params[1];
CHECK_ENTITY(idx); CHECK_ENTITY(idx);
edict_t *pEntity = INDEXENT2(idx); edict_t *pEntity = TypeConversion.id_to_edict(idx);
int iLength=0; int iLength=0;
char *char1 = MF_GetAmxString(amx, params[2], 1, &iLength); char *char1 = MF_GetAmxString(amx, params[2], 1, &iLength);
char *val = INFO_KEY_VALUE(INFO_KEY_BUFFER(pEntity), char1); char *val = INFO_KEY_VALUE(INFO_KEY_BUFFER(pEntity), char1);
@ -221,7 +221,7 @@ static cell AMX_NATIVE_CALL DispatchSpawn(AMX *amx, cell *params)
CHECK_ENTITY(iEnt); CHECK_ENTITY(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
MDLL_Spawn(pEnt); MDLL_Spawn(pEnt);
@ -240,7 +240,7 @@ static cell AMX_NATIVE_CALL entity_get_float(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -371,7 +371,7 @@ static cell AMX_NATIVE_CALL entity_set_float(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -502,7 +502,7 @@ static cell AMX_NATIVE_CALL entity_get_int(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -633,7 +633,7 @@ static cell AMX_NATIVE_CALL entity_set_int(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -765,7 +765,7 @@ static cell AMX_NATIVE_CALL entity_get_vector(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -862,7 +862,7 @@ static cell AMX_NATIVE_CALL entity_set_vector(AMX *amx, cell *params)
REAL fY = amx_ctof(vAmx[1]); REAL fY = amx_ctof(vAmx[1]);
REAL fZ = amx_ctof(vAmx[2]); REAL fZ = amx_ctof(vAmx[2]);
Vector vSet = Vector(fX, fY, fZ); Vector vSet = Vector(fX, fY, fZ);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -952,7 +952,7 @@ static cell AMX_NATIVE_CALL entity_get_string(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -1014,7 +1014,7 @@ static cell AMX_NATIVE_CALL entity_set_string(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -1073,7 +1073,7 @@ static cell AMX_NATIVE_CALL entity_get_edict2(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -1139,8 +1139,8 @@ static cell AMX_NATIVE_CALL entity_set_edict(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
edict_t *pSetEnt = INDEXENT2(iSetEnt); edict_t *pSetEnt = TypeConversion.id_to_edict(iSetEnt);
switch (idx) switch (idx)
{ {
@ -1193,7 +1193,7 @@ static cell AMX_NATIVE_CALL entity_get_byte(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -1236,7 +1236,7 @@ static cell AMX_NATIVE_CALL entity_set_byte(AMX *amx, cell *params)
if(iNewValue < 0) if(iNewValue < 0)
iNewValue = 0; iNewValue = 0;
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
switch (idx) switch (idx)
{ {
@ -1272,7 +1272,7 @@ static cell AMX_NATIVE_CALL entity_set_origin(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
cell *vVector = MF_GetAmxAddr(amx, params[2]); cell *vVector = MF_GetAmxAddr(amx, params[2]);
REAL fX = amx_ctof(vVector[0]); REAL fX = amx_ctof(vVector[0]);
REAL fY = amx_ctof(vVector[1]); REAL fY = amx_ctof(vVector[1]);
@ -1291,7 +1291,7 @@ static cell AMX_NATIVE_CALL entity_set_model(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
int iLen; int iLen;
char *szModel = MF_GetAmxString(amx, params[2], 0, &iLen); char *szModel = MF_GetAmxString(amx, params[2], 0, &iLen);
const char *szStatic = STRING(ALLOC_STRING(szModel)); const char *szStatic = STRING(ALLOC_STRING(szModel));
@ -1307,7 +1307,7 @@ static cell AMX_NATIVE_CALL entity_set_size(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(iEnt); CHECK_ENTITY_SIMPLE(iEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
cell *cMin = MF_GetAmxAddr(amx, params[2]); cell *cMin = MF_GetAmxAddr(amx, params[2]);
REAL x1 = amx_ctof(cMin[0]); REAL x1 = amx_ctof(cMin[0]);
@ -1342,7 +1342,7 @@ static cell AMX_NATIVE_CALL find_ent_in_sphere(AMX *amx, cell *params)
CHECK_ENTITY_SIMPLE(idx); CHECK_ENTITY_SIMPLE(idx);
} }
edict_t *pEnt = INDEXENT2(idx); edict_t *pEnt = TypeConversion.id_to_edict(idx);
cell *cAddr = MF_GetAmxAddr(amx, params[2]); cell *cAddr = MF_GetAmxAddr(amx, params[2]);
float origin[3] = { float origin[3] = {
amx_ctof(cAddr[0]), amx_ctof(cAddr[0]),
@ -1366,7 +1366,7 @@ static cell AMX_NATIVE_CALL find_ent_by_class(AMX *amx, cell *params) /* 3 param
CHECK_ENTITY_SIMPLE(idx); CHECK_ENTITY_SIMPLE(idx);
} }
edict_t *pEnt = INDEXENT2(idx); edict_t *pEnt = TypeConversion.id_to_edict(idx);
int len; int len;
char* sValue = MF_GetAmxString(amx, params[2], 0, &len); char* sValue = MF_GetAmxString(amx, params[2], 0, &len);
@ -1396,7 +1396,7 @@ static cell AMX_NATIVE_CALL find_sphere_class(AMX *amx, cell *params) // find_sp
if (params[1] > 0) { if (params[1] > 0) {
CHECK_ENTITY(params[1]); CHECK_ENTITY(params[1]);
edict_t* pEntity = INDEXENT2(params[1]); edict_t* pEntity = TypeConversion.id_to_edict(params[1]);
vecOrigin = pEntity->v.origin; vecOrigin = pEntity->v.origin;
} else { } else {
cell *cAddr = MF_GetAmxAddr(amx, params[6]); cell *cAddr = MF_GetAmxAddr(amx, params[6]);
@ -1404,7 +1404,7 @@ static cell AMX_NATIVE_CALL find_sphere_class(AMX *amx, cell *params) // find_sp
} }
int entsFound = 0; int entsFound = 0;
edict_t* pSearchEnt = INDEXENT2(0); edict_t* pSearchEnt = TypeConversion.id_to_edict(0);
while (entsFound < params[5]) { while (entsFound < params[5]) {
pSearchEnt = FIND_ENTITY_IN_SPHERE(pSearchEnt, vecOrigin, radius); // takes const float origin pSearchEnt = FIND_ENTITY_IN_SPHERE(pSearchEnt, vecOrigin, radius); // takes const float origin
@ -1435,7 +1435,7 @@ static cell AMX_NATIVE_CALL find_ent_by_target(AMX *amx, cell *params)
if (!is_ent_valid(iStart)) if (!is_ent_valid(iStart))
pStart = NULL; pStart = NULL;
else else
pStart = INDEXENT2(iStart); pStart = TypeConversion.id_to_edict(iStart);
} }
int iReturnEnt = ENTINDEX(FIND_ENTITY_BY_TARGET(pStart, szValue)); int iReturnEnt = ENTINDEX(FIND_ENTITY_BY_TARGET(pStart, szValue));
@ -1458,7 +1458,7 @@ static cell AMX_NATIVE_CALL find_ent_by_model(AMX *amx, cell *params) {
if (!is_ent_valid(iStart)) if (!is_ent_valid(iStart))
pStart = NULL; pStart = NULL;
else else
pStart = INDEXENT2(iStart); pStart = TypeConversion.id_to_edict(iStart);
} }
edict_t *pEdict = FIND_ENTITY_BY_STRING(pStart, "classname", szClass); edict_t *pEdict = FIND_ENTITY_BY_STRING(pStart, "classname", szClass);
@ -1490,7 +1490,7 @@ static cell AMX_NATIVE_CALL find_ent_by_tname(AMX *amx, cell *params) {
if (!is_ent_valid(iStart)) if (!is_ent_valid(iStart))
pStart = NULL; pStart = NULL;
else else
pStart = INDEXENT2(iStart); pStart = TypeConversion.id_to_edict(iStart);
} }
int iReturnEnt = ENTINDEX(FIND_ENTITY_BY_TARGETNAME(pStart, szValue)); int iReturnEnt = ENTINDEX(FIND_ENTITY_BY_TARGETNAME(pStart, szValue));
@ -1507,8 +1507,8 @@ static cell AMX_NATIVE_CALL find_ent_by_owner(AMX *amx, cell *params) // native
} }
CHECK_ENTITY_SIMPLE(oEnt); CHECK_ENTITY_SIMPLE(oEnt);
edict_t *pEnt = INDEXENT2(iEnt); edict_t *pEnt = TypeConversion.id_to_edict(iEnt);
edict_t *entOwner = INDEXENT2(oEnt); edict_t *entOwner = TypeConversion.id_to_edict(oEnt);
//optional fourth parameter is for jghg2 compatibility //optional fourth parameter is for jghg2 compatibility
const char* sCategory = NULL; const char* sCategory = NULL;
@ -1546,8 +1546,8 @@ static cell AMX_NATIVE_CALL get_grenade_id(AMX *amx, cell *params) /* 4 param *
CHECK_ENTITY(index); CHECK_ENTITY(index);
edict_t* pentFind = INDEXENT2(params[4]); edict_t* pentFind = TypeConversion.id_to_edict(params[4]);
edict_t* pentOwner = INDEXENT2(index); edict_t* pentOwner = TypeConversion.id_to_edict(index);
pentFind = FIND_ENTITY_BY_CLASSNAME( pentFind, "grenade" ); pentFind = FIND_ENTITY_BY_CLASSNAME( pentFind, "grenade" );
while (!FNullEnt(pentFind)) { while (!FNullEnt(pentFind)) {
@ -1575,7 +1575,7 @@ static cell AMX_NATIVE_CALL set_ent_rendering(AMX *amx, cell *params) // set_ent
CHECK_ENTITY_SIMPLE(params[1]); CHECK_ENTITY_SIMPLE(params[1]);
edict_t *pEntity = INDEXENT2(params[1]); edict_t *pEntity = TypeConversion.id_to_edict(params[1]);
pEntity->v.renderfx = params[2]; pEntity->v.renderfx = params[2];
pEntity->v.rendercolor = Vector(float(params[3]), float(params[4]), float(params[5])); pEntity->v.rendercolor = Vector(float(params[3]), float(params[4]), float(params[5]));
@ -1593,8 +1593,8 @@ static cell AMX_NATIVE_CALL entity_intersects(AMX *amx, cell *params) // bool:en
CHECK_ENTITY_SIMPLE(params[1]); CHECK_ENTITY_SIMPLE(params[1]);
CHECK_ENTITY_SIMPLE(params[2]); CHECK_ENTITY_SIMPLE(params[2]);
entvars_s *pevEntity = VARS(INDEXENT2(params[1])); entvars_s *pevEntity = VARS(TypeConversion.id_to_edict(params[1]));
entvars_s *pevOther = VARS(INDEXENT2(params[2])); entvars_s *pevOther = VARS(TypeConversion.id_to_edict(params[2]));
if (pevOther->absmin.x > pevEntity->absmax.x || if (pevOther->absmin.x > pevEntity->absmax.x ||
pevOther->absmin.y > pevEntity->absmax.y || pevOther->absmin.y > pevEntity->absmax.y ||

View File

@ -117,7 +117,7 @@
// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */ // #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */ // #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */ // #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
#define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */ // #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */ #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */ // #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */ // #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */

View File

@ -109,6 +109,7 @@
<ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp" /> <ClCompile Include="..\..\..\public\sdk\amxxmodule.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\public\HLTypeConversion.h" />
<ClInclude Include="..\..\..\public\memtools\CDetour\asm\asm.h" /> <ClInclude Include="..\..\..\public\memtools\CDetour\asm\asm.h" />
<ClInclude Include="..\..\..\public\memtools\CDetour\detourhelpers.h" /> <ClInclude Include="..\..\..\public\memtools\CDetour\detourhelpers.h" />
<ClInclude Include="..\..\..\public\memtools\CDetour\detours.h" /> <ClInclude Include="..\..\..\public\memtools\CDetour\detours.h" />

View File

@ -85,6 +85,9 @@
<ClInclude Include="..\..\..\public\memtools\CDetour\asm\asm.h"> <ClInclude Include="..\..\..\public\memtools\CDetour\asm\asm.h">
<Filter>Memtools\CDetour\asm</Filter> <Filter>Memtools\CDetour\asm</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\..\public\HLTypeConversion.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\..\plugins\include\engine.inc"> <None Include="..\..\..\plugins\include\engine.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',
'dllfunc.cpp', 'dllfunc.cpp',
'engfunc.cpp', 'engfunc.cpp',
'fakemeta_amxx.cpp', 'fakemeta_amxx.cpp',

View File

@ -45,14 +45,14 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
return gpGamedllFuncs->dllapi_table->pfnSpawn(INDEXENT2(index)); return gpGamedllFuncs->dllapi_table->pfnSpawn(TypeConversion.id_to_edict(index));
// pfnThink // pfnThink
case DLLFunc_Think: // void ) ( edict_t *pent ); case DLLFunc_Think: // void ) ( edict_t *pent );
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnThink(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnThink(TypeConversion.id_to_edict(index));
return 1; return 1;
// pfnUse // pfnUse
@ -63,7 +63,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
indexb=cRet[0]; indexb=cRet[0];
CHECK_ENTITY(indexb); CHECK_ENTITY(indexb);
gpGamedllFuncs->dllapi_table->pfnUse(INDEXENT2(index),INDEXENT2(indexb)); gpGamedllFuncs->dllapi_table->pfnUse(TypeConversion.id_to_edict(index), TypeConversion.id_to_edict(indexb));
return 1; return 1;
case DLLFunc_KeyValue: case DLLFunc_KeyValue:
@ -79,7 +79,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
else else
kvd = reinterpret_cast<KeyValueData *>(*cRet); kvd = reinterpret_cast<KeyValueData *>(*cRet);
gpGamedllFuncs->dllapi_table->pfnKeyValue(INDEXENT2(index), kvd); gpGamedllFuncs->dllapi_table->pfnKeyValue(TypeConversion.id_to_edict(index), kvd);
return 1; return 1;
} }
@ -91,7 +91,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
indexb=cRet[0]; indexb=cRet[0];
CHECK_ENTITY(indexb); CHECK_ENTITY(indexb);
gpGamedllFuncs->dllapi_table->pfnTouch(INDEXENT2(index),INDEXENT2(indexb)); gpGamedllFuncs->dllapi_table->pfnTouch(TypeConversion.id_to_edict(index), TypeConversion.id_to_edict(indexb));
return 1; return 1;
case DLLFunc_Blocked: // void ) ( edict_t *pentBlocked, edict_t *pentOther ); case DLLFunc_Blocked: // void ) ( edict_t *pentBlocked, edict_t *pentOther );
@ -101,7 +101,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
indexb=cRet[0]; indexb=cRet[0];
CHECK_ENTITY(indexb); CHECK_ENTITY(indexb);
gpGamedllFuncs->dllapi_table->pfnBlocked(INDEXENT2(index),INDEXENT2(indexb)); gpGamedllFuncs->dllapi_table->pfnBlocked(TypeConversion.id_to_edict(index), TypeConversion.id_to_edict(indexb));
return 1; return 1;
@ -109,7 +109,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnSetAbsBox(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnSetAbsBox(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_ClientConnect: // bool) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ); case DLLFunc_ClientConnect: // bool) ( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] );
@ -120,7 +120,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
temp = MF_GetAmxString(amx,params[3],0,&len); temp = MF_GetAmxString(amx,params[3],0,&len);
temp2 = MF_GetAmxString(amx,params[4],1,&len); temp2 = MF_GetAmxString(amx,params[4],1,&len);
//temp3 = GET_AMXSTRING(amx,params[5],2,len); //temp3 = GET_AMXSTRING(amx,params[5],2,len);
iparam1 = MDLL_ClientConnect(INDEXENT2(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2)),(char *)temp3); iparam1 = MDLL_ClientConnect(TypeConversion.id_to_edict(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2)),(char *)temp3);
cRet = MF_GetAmxAddr(amx,params[6]); cRet = MF_GetAmxAddr(amx,params[6]);
MF_SetAmxString(amx,params[5],temp3,cRet[0]); MF_SetAmxString(amx,params[5],temp3,cRet[0]);
return iparam1; return iparam1;
@ -129,21 +129,21 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnClientDisconnect(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnClientDisconnect(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_ClientKill: // void ) ( edict_t *pEntity ); case DLLFunc_ClientKill: // void ) ( edict_t *pEntity );
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnClientKill(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnClientKill(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_ClientPutInServer: // void ) ( edict_t *pEntity ); case DLLFunc_ClientPutInServer: // void ) ( edict_t *pEntity );
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnClientPutInServer(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnClientPutInServer(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_ServerDeactivate: // void) ( void ); case DLLFunc_ServerDeactivate: // void) ( void );
@ -154,14 +154,14 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnPlayerPreThink(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnPlayerPreThink(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_PlayerPostThink: // void ) ( edict_t *pEntity ); case DLLFunc_PlayerPostThink: // void ) ( edict_t *pEntity );
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnPlayerPostThink(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnPlayerPostThink(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_StartFrame: // void ) ( void ); case DLLFunc_StartFrame: // void ) ( void );
@ -188,19 +188,19 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnSpectatorConnect(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnSpectatorConnect(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_SpectatorDisconnect: // void ) ( edict_t *pEntity ); case DLLFunc_SpectatorDisconnect: // void ) ( edict_t *pEntity );
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnSpectatorDisconnect(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnSpectatorDisconnect(TypeConversion.id_to_edict(index));
return 1; return 1;
case DLLFunc_SpectatorThink: // void ) ( edict_t *pEntity ); case DLLFunc_SpectatorThink: // void ) ( edict_t *pEntity );
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnSpectatorThink(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnSpectatorThink(TypeConversion.id_to_edict(index));
return 1; return 1;
// Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. // Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint.
@ -244,13 +244,13 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
iparam1 = gpMetaUtilFuncs->pfnCallGameEntity(PLID,STRING(ALLOC_STRING(temp)),VARS(INDEXENT2(index))); iparam1 = gpMetaUtilFuncs->pfnCallGameEntity(PLID,STRING(ALLOC_STRING(temp)),VARS(TypeConversion.id_to_edict(index)));
return iparam1; return iparam1;
case DLLFunc_ClientUserInfoChanged: // void ) (edict_t *pEntity, char *infobuffer) case DLLFunc_ClientUserInfoChanged: // void ) (edict_t *pEntity, char *infobuffer)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnClientUserInfoChanged(INDEXENT2(index),(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index))); gpGamedllFuncs->dllapi_table->pfnClientUserInfoChanged(TypeConversion.id_to_edict(index),(*g_engfuncs.pfnGetInfoKeyBuffer)(TypeConversion.id_to_edict(index)));
return 1; return 1;
case DLLFunc_UpdateClientData: // void ) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd) case DLLFunc_UpdateClientData: // void ) (const struct edict_s *ent, int sendweapons, struct clientdata_s *cd)
cRet = MF_GetAmxAddr(amx, params[2]); cRet = MF_GetAmxAddr(amx, params[2]);
@ -273,7 +273,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cd = &g_cd_glb; cd = &g_cd_glb;
gpGamedllFuncs->dllapi_table->pfnUpdateClientData(INDEXENT2(index), iparam1, cd); gpGamedllFuncs->dllapi_table->pfnUpdateClientData(TypeConversion.id_to_edict(index), iparam1, cd);
return 1; return 1;
case DLLFunc_AddToFullPack: // int ) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet) case DLLFunc_AddToFullPack: // int ) (struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet)
@ -310,7 +310,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx, params[8]); cRet = MF_GetAmxAddr(amx, params[8]);
pset = reinterpret_cast<unsigned char *>(*cRet); pset = reinterpret_cast<unsigned char *>(*cRet);
return gpGamedllFuncs->dllapi_table->pfnAddToFullPack(es, iparam1, INDEXENT2(index), INDEXENT2(indexb), iparam2, iparam3, pset); return gpGamedllFuncs->dllapi_table->pfnAddToFullPack(es, iparam1, TypeConversion.id_to_edict(index), TypeConversion.id_to_edict(indexb), iparam2, iparam3, pset);
case DLLFunc_CmdStart: // void ) (const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed) case DLLFunc_CmdStart: // void ) (const edict_t *player, const struct usercmd_s *cmd, unsigned int random_seed)
cRet = MF_GetAmxAddr(amx, params[2]); cRet = MF_GetAmxAddr(amx, params[2]);
index = cRet[0]; index = cRet[0];
@ -328,7 +328,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
cRet = MF_GetAmxAddr(amx, params[4]); cRet = MF_GetAmxAddr(amx, params[4]);
iparam1 = cRet[0]; iparam1 = cRet[0];
gpGamedllFuncs->dllapi_table->pfnCmdStart(INDEXENT2(index), uc, iparam1); gpGamedllFuncs->dllapi_table->pfnCmdStart(TypeConversion.id_to_edict(index), uc, iparam1);
return 1; return 1;
case DLLFunc_CmdEnd: // void ) (const edict_t *player) case DLLFunc_CmdEnd: // void ) (const edict_t *player)
@ -336,7 +336,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnCmdEnd(INDEXENT2(index)); gpGamedllFuncs->dllapi_table->pfnCmdEnd(TypeConversion.id_to_edict(index));
return 1; return 1;
@ -371,7 +371,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
Vec2.y = amx_ctof(cRet[1]); Vec2.y = amx_ctof(cRet[1]);
Vec2.z = amx_ctof(cRet[2]); Vec2.z = amx_ctof(cRet[2]);
gpGamedllFuncs->dllapi_table->pfnCreateBaseline(iparam1, iparam2, es, INDEXENT2(index), iparam3, Vec1, Vec2); gpGamedllFuncs->dllapi_table->pfnCreateBaseline(iparam1, iparam2, es, TypeConversion.id_to_edict(index), iparam3, Vec1, Vec2);
return 1; return 1;
default: default:

View File

@ -68,7 +68,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
(*g_engfuncs.pfnSetModel)(INDEXENT2(index),(char*)STRING(ALLOC_STRING(temp))); (*g_engfuncs.pfnSetModel)(TypeConversion.id_to_edict(index),(char*)STRING(ALLOC_STRING(temp)));
return 1; return 1;
@ -98,7 +98,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
Vec2[0]=amx_ctof(cRet[0]); Vec2[0]=amx_ctof(cRet[0]);
Vec2[1]=amx_ctof(cRet[1]); Vec2[1]=amx_ctof(cRet[1]);
Vec2[2]=amx_ctof(cRet[2]); Vec2[2]=amx_ctof(cRet[2]);
(*g_engfuncs.pfnSetSize)(INDEXENT2(index),Vec1,Vec2); (*g_engfuncs.pfnSetSize)(TypeConversion.id_to_edict(index),Vec1,Vec2);
return 1; return 1;
@ -150,7 +150,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[5]); cRet = MF_GetAmxAddr(amx,params[5]);
iparam1=cRet[0]; iparam1=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
(*g_engfuncs.pfnMoveToOrigin)(INDEXENT2(index),Vec1,fparam1,iparam1); (*g_engfuncs.pfnMoveToOrigin)(TypeConversion.id_to_edict(index),Vec1,fparam1,iparam1);
return 1; return 1;
@ -159,7 +159,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
(*g_engfuncs.pfnChangeYaw)(INDEXENT2(index)); (*g_engfuncs.pfnChangeYaw)(TypeConversion.id_to_edict(index));
return 1; return 1;
@ -168,7 +168,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
(*g_engfuncs.pfnChangePitch)(INDEXENT2(index)); (*g_engfuncs.pfnChangePitch)(TypeConversion.id_to_edict(index));
return 1; return 1;
@ -178,7 +178,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
index=cRet[0]; index=cRet[0];
temp = MF_GetAmxString(amx,params[3],0,&len); temp = MF_GetAmxString(amx,params[3],0,&len);
temp2 = MF_GetAmxString(amx,params[4],1,&len); temp2 = MF_GetAmxString(amx,params[4],1,&len);
pRet = (*g_engfuncs.pfnFindEntityByString)(index == -1 ? NULL : INDEXENT2(index),temp,temp2); pRet = (*g_engfuncs.pfnFindEntityByString)(index == -1 ? NULL : TypeConversion.id_to_edict(index),temp,temp2);
if (pRet) if (pRet)
return ENTINDEX(pRet); return ENTINDEX(pRet);
return -1; return -1;
@ -189,7 +189,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
return (*g_engfuncs.pfnGetEntityIllum)(INDEXENT2(index)); return (*g_engfuncs.pfnGetEntityIllum)(TypeConversion.id_to_edict(index));
// pfnFindEntityInSphere // pfnFindEntityInSphere
@ -202,7 +202,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
Vec1[2]=amx_ctof(cRet[2]); Vec1[2]=amx_ctof(cRet[2]);
cRet = MF_GetAmxAddr(amx,params[4]); cRet = MF_GetAmxAddr(amx,params[4]);
fparam1 = amx_ctof(cRet[0]); fparam1 = amx_ctof(cRet[0]);
pRet = (*g_engfuncs.pfnFindEntityInSphere)(index == -1 ? NULL : INDEXENT2(index),Vec1,fparam1); pRet = (*g_engfuncs.pfnFindEntityInSphere)(index == -1 ? NULL : TypeConversion.id_to_edict(index),Vec1,fparam1);
if (pRet) if (pRet)
return ENTINDEX(pRet); return ENTINDEX(pRet);
return -1; return -1;
@ -213,7 +213,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
pRet=(*g_engfuncs.pfnFindClientInPVS)(INDEXENT2(index)); pRet=(*g_engfuncs.pfnFindClientInPVS)(TypeConversion.id_to_edict(index));
return ENTINDEX(pRet); return ENTINDEX(pRet);
@ -222,7 +222,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index=cRet[0]; index=cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
pRet=(*g_engfuncs.pfnEntitiesInPVS)(INDEXENT2(index)); pRet=(*g_engfuncs.pfnEntitiesInPVS)(TypeConversion.id_to_edict(index));
return ENTINDEX(pRet); return ENTINDEX(pRet);
@ -273,7 +273,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
if (index == 0) if (index == 0)
return 0; return 0;
(*g_engfuncs.pfnRemoveEntity)(INDEXENT2(index)); (*g_engfuncs.pfnRemoveEntity)(TypeConversion.id_to_edict(index));
return 1; return 1;
@ -292,7 +292,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
(*g_engfuncs.pfnMakeStatic)(INDEXENT2(index)); (*g_engfuncs.pfnMakeStatic)(TypeConversion.id_to_edict(index));
return 1; return 1;
@ -301,7 +301,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
return (*g_engfuncs.pfnEntIsOnFloor)(INDEXENT2(index)); return (*g_engfuncs.pfnEntIsOnFloor)(TypeConversion.id_to_edict(index));
// pfnDropToFloor // pfnDropToFloor
@ -309,7 +309,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
return (*g_engfuncs.pfnDropToFloor)(INDEXENT2(index)); return (*g_engfuncs.pfnDropToFloor)(TypeConversion.id_to_edict(index));
// pfnWalkMove // pfnWalkMove
@ -323,7 +323,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
fparam2 = amx_ctof(cRet[0]); fparam2 = amx_ctof(cRet[0]);
cRet = MF_GetAmxAddr(amx,params[5]); cRet = MF_GetAmxAddr(amx,params[5]);
iparam1 = cRet[0]; iparam1 = cRet[0];
return (*g_engfuncs.pfnWalkMove)(INDEXENT2(index),fparam1,fparam2,iparam1); return (*g_engfuncs.pfnWalkMove)(TypeConversion.id_to_edict(index),fparam1,fparam2,iparam1);
// pfnSetOrigin // pfnSetOrigin
@ -335,7 +335,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
Vec1[0]=amx_ctof(cRet[0]); Vec1[0]=amx_ctof(cRet[0]);
Vec1[1]=amx_ctof(cRet[1]); Vec1[1]=amx_ctof(cRet[1]);
Vec1[2]=amx_ctof(cRet[2]); Vec1[2]=amx_ctof(cRet[2]);
(*g_engfuncs.pfnSetOrigin)(INDEXENT2(index),Vec1); (*g_engfuncs.pfnSetOrigin)(TypeConversion.id_to_edict(index),Vec1);
return 1; return 1;
@ -355,7 +355,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
iparam2=cRet[0]; iparam2=cRet[0];
cRet = MF_GetAmxAddr(amx,params[8]); cRet = MF_GetAmxAddr(amx,params[8]);
iparam3=cRet[0]; iparam3=cRet[0];
(*g_engfuncs.pfnEmitSound)(INDEXENT2(index),iparam1,temp,fparam1,fparam2,iparam2,iparam3); (*g_engfuncs.pfnEmitSound)(TypeConversion.id_to_edict(index),iparam1,temp,fparam1,fparam2,iparam2,iparam3);
return 1; return 1;
@ -377,7 +377,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
iparam1=cRet[0]; iparam1=cRet[0];
cRet = MF_GetAmxAddr(amx,params[8]); cRet = MF_GetAmxAddr(amx,params[8]);
iparam2=cRet[0]; iparam2=cRet[0];
(*g_engfuncs.pfnEmitAmbientSound)(INDEXENT2(index),Vec1,temp,fparam1,fparam2,iparam1,iparam2); (*g_engfuncs.pfnEmitAmbientSound)(TypeConversion.id_to_edict(index),Vec1,temp,fparam1,fparam2,iparam1,iparam2);
return 1; return 1;
// pfnTraceLine // pfnTraceLine
@ -405,7 +405,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
} else { } else {
tr = &g_tr; tr = &g_tr;
} }
(*g_engfuncs.pfnTraceLine)(Vec1,Vec2,iparam1,index != -1 ? INDEXENT2(index) : NULL, tr); (*g_engfuncs.pfnTraceLine)(Vec1,Vec2,iparam1,index != -1 ? TypeConversion.id_to_edict(index) : NULL, tr);
return 1; return 1;
@ -426,7 +426,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
} else { } else {
tr = &g_tr; tr = &g_tr;
} }
(*g_engfuncs.pfnTraceToss)(INDEXENT2(index),iparam1 == -1 ? NULL : INDEXENT2(iparam1),tr); (*g_engfuncs.pfnTraceToss)(TypeConversion.id_to_edict(index),iparam1 == -1 ? NULL : TypeConversion.id_to_edict(iparam1),tr);
return 1; return 1;
@ -457,7 +457,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
} else { } else {
tr = &g_tr; tr = &g_tr;
} }
(*g_engfuncs.pfnTraceMonsterHull)(INDEXENT2(index),Vec1,Vec2,iparam1,iparam2 == 0 ? NULL : INDEXENT2(iparam2),tr); (*g_engfuncs.pfnTraceMonsterHull)(TypeConversion.id_to_edict(index),Vec1,Vec2,iparam1,iparam2 == 0 ? NULL : TypeConversion.id_to_edict(iparam2),tr);
return 1; return 1;
@ -487,7 +487,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
} else { } else {
tr = &g_tr; tr = &g_tr;
} }
(*g_engfuncs.pfnTraceHull)(Vec1,Vec2,iparam1,iparam2,iparam3 == 0 ? 0 : INDEXENT2(iparam3),tr); (*g_engfuncs.pfnTraceHull)(Vec1,Vec2,iparam1,iparam2,iparam3 == 0 ? 0 : TypeConversion.id_to_edict(iparam3),tr);
return 1; return 1;
@ -515,7 +515,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
} else { } else {
tr = &g_tr; tr = &g_tr;
} }
(*g_engfuncs.pfnTraceModel)(Vec1,Vec2,iparam1,iparam2 == 0 ? NULL : INDEXENT2(iparam2),tr); (*g_engfuncs.pfnTraceModel)(Vec1,Vec2,iparam1,iparam2 == 0 ? NULL : TypeConversion.id_to_edict(iparam2),tr);
return 1; return 1;
@ -532,7 +532,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
Vec2[0]=amx_ctof(cRet[0]); Vec2[0]=amx_ctof(cRet[0]);
Vec2[1]=amx_ctof(cRet[1]); Vec2[1]=amx_ctof(cRet[1]);
Vec2[2]=amx_ctof(cRet[2]); Vec2[2]=amx_ctof(cRet[2]);
temp = (char*)(*g_engfuncs.pfnTraceTexture)(INDEXENT2(index),Vec1,Vec2); temp = (char*)(*g_engfuncs.pfnTraceTexture)(TypeConversion.id_to_edict(index),Vec1,Vec2);
cRet = MF_GetAmxAddr(amx,params[6]); cRet = MF_GetAmxAddr(amx,params[6]);
MF_SetAmxString(amx, params[5], (temp == NULL) ? "NoTexture" : temp, cRet[0]); MF_SetAmxString(amx, params[5], (temp == NULL) ? "NoTexture" : temp, cRet[0]);
return (temp != NULL); return (temp != NULL);
@ -554,7 +554,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
fparam1 = amx_ctof(cRet[0]); fparam1 = amx_ctof(cRet[0]);
cRet = MF_GetAmxAddr(amx,params[6]); cRet = MF_GetAmxAddr(amx,params[6]);
index = cRet[0]; index = cRet[0];
(*g_engfuncs.pfnTraceSphere)(Vec1,Vec2,iparam1,fparam1,index == 0 ? NULL : INDEXENT2(index),&g_tr); (*g_engfuncs.pfnTraceSphere)(Vec1,Vec2,iparam1,fparam1,index == 0 ? NULL : TypeConversion.id_to_edict(index),&g_tr);
return 1; return 1;
@ -565,7 +565,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
fparam1 = amx_ctof(cRet[0]); fparam1 = amx_ctof(cRet[0]);
(*g_engfuncs.pfnGetAimVector)(INDEXENT2(index),fparam1,Vec1); (*g_engfuncs.pfnGetAimVector)(TypeConversion.id_to_edict(index),fparam1,Vec1);
cRet = MF_GetAmxAddr(amx,params[4]); cRet = MF_GetAmxAddr(amx,params[4]);
cRet[0] = amx_ftoc(Vec1[0]); cRet[0] = amx_ftoc(Vec1[0]);
cRet[1] = amx_ftoc(Vec1[1]); cRet[1] = amx_ftoc(Vec1[1]);
@ -620,7 +620,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
(*g_engfuncs.pfnFreeEntPrivateData)(INDEXENT2(index)); (*g_engfuncs.pfnFreeEntPrivateData)(TypeConversion.id_to_edict(index));
return 1; return 1;
@ -655,7 +655,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
fparam1 = amx_ctof(cRet[0]); fparam1 = amx_ctof(cRet[0]);
(*g_engfuncs.pfnAnimationAutomove)(INDEXENT2(index),fparam1); (*g_engfuncs.pfnAnimationAutomove)(TypeConversion.id_to_edict(index),fparam1);
return 1; return 1;
@ -666,7 +666,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
iparam1=cRet[0]; iparam1=cRet[0];
(*g_engfuncs.pfnGetBonePosition)(INDEXENT2(index),iparam1,Vec1,Vec2); (*g_engfuncs.pfnGetBonePosition)(TypeConversion.id_to_edict(index),iparam1,Vec1,Vec2);
cRet = MF_GetAmxAddr(amx,params[4]); cRet = MF_GetAmxAddr(amx,params[4]);
cRet[0]=amx_ftoc(Vec1[0]); cRet[0]=amx_ftoc(Vec1[0]);
cRet[1]=amx_ftoc(Vec1[1]); cRet[1]=amx_ftoc(Vec1[1]);
@ -685,7 +685,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
iparam1=cRet[0]; iparam1=cRet[0];
(*g_engfuncs.pfnGetAttachment)(INDEXENT2(index),iparam1,Vec1,Vec2); (*g_engfuncs.pfnGetAttachment)(TypeConversion.id_to_edict(index),iparam1,Vec1,Vec2);
cRet = MF_GetAmxAddr(amx,params[4]); cRet = MF_GetAmxAddr(amx,params[4]);
cRet[0]=amx_ftoc(Vec1[0]); cRet[0]=amx_ftoc(Vec1[0]);
cRet[1]=amx_ftoc(Vec1[1]); cRet[1]=amx_ftoc(Vec1[1]);
@ -705,7 +705,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
iparam2 = cRet[0]; iparam2 = cRet[0];
CHECK_ENTITY(iparam1); CHECK_ENTITY(iparam1);
CHECK_ENTITY(iparam2); CHECK_ENTITY(iparam2);
(*g_engfuncs.pfnSetView)(INDEXENT2(iparam1),INDEXENT2(iparam2)); (*g_engfuncs.pfnSetView)(TypeConversion.id_to_edict(iparam1),TypeConversion.id_to_edict(iparam2));
return 1; return 1;
@ -724,7 +724,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
fparam1 = amx_ctof(cRet[0]); fparam1 = amx_ctof(cRet[0]);
cRet = MF_GetAmxAddr(amx,params[4]); cRet = MF_GetAmxAddr(amx,params[4]);
fparam2 = amx_ctof(cRet[0]); fparam2 = amx_ctof(cRet[0]);
(*g_engfuncs.pfnCrosshairAngle)(INDEXENT2(index),fparam1,fparam2); (*g_engfuncs.pfnCrosshairAngle)(TypeConversion.id_to_edict(index),fparam1,fparam2);
return 1; return 1;
@ -741,7 +741,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
iparam3 = cRet[0]; iparam3 = cRet[0];
cRet = MF_GetAmxAddr(amx,params[6]); cRet = MF_GetAmxAddr(amx,params[6]);
iparam4 = cRet[0]; iparam4 = cRet[0];
(*g_engfuncs.pfnFadeClientVolume)(INDEXENT2(index),iparam1,iparam2,iparam3,iparam4); (*g_engfuncs.pfnFadeClientVolume)(TypeConversion.id_to_edict(index),iparam1,iparam2,iparam3,iparam4);
return 1; return 1;
@ -752,7 +752,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx,params[3]); cRet = MF_GetAmxAddr(amx,params[3]);
fparam1 = amx_ctof(cRet[0]); fparam1 = amx_ctof(cRet[0]);
(*g_engfuncs.pfnSetClientMaxspeed)(INDEXENT2(index),fparam1); (*g_engfuncs.pfnSetClientMaxspeed)(TypeConversion.id_to_edict(index),fparam1);
return 1; return 1;
@ -786,7 +786,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
iparam2 = cRet[0]; iparam2 = cRet[0];
cRet = MF_GetAmxAddr(amx,params[9]); cRet = MF_GetAmxAddr(amx,params[9]);
iparam3 = cRet[0]; iparam3 = cRet[0];
(*g_engfuncs.pfnRunPlayerMove)(INDEXENT2(index),Vec1,fparam1,fparam2,fparam3,iparam1,iparam2,iparam3); (*g_engfuncs.pfnRunPlayerMove)(TypeConversion.id_to_edict(index),Vec1,fparam1,fparam2,fparam3,iparam1,iparam2,iparam3);
return 1; return 1;
@ -846,7 +846,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
/* don't check, it might not be included /* don't check, it might not be included
CHECK_ENTITY(iparam5); CHECK_ENTITY(iparam5);
*/ */
(*g_engfuncs.pfnBuildSoundMsg)(INDEXENT2(index),iparam1,temp,fparam1,fparam2,iparam2,iparam3,iparam4,iparam5,Vec1,iparam6 == 0 ? NULL : INDEXENT2(iparam6)); (*g_engfuncs.pfnBuildSoundMsg)(TypeConversion.id_to_edict(index),iparam1,temp,fparam1,fparam2,iparam2,iparam3,iparam4,iparam5,Vec1,iparam6 == 0 ? NULL : TypeConversion.id_to_edict(iparam6));
return 1; return 1;
@ -856,7 +856,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
temp = MF_GetAmxString(amx,params[3],0,&len); temp = MF_GetAmxString(amx,params[3],0,&len);
temp2 = (char*)(*g_engfuncs.pfnGetPhysicsKeyValue)(INDEXENT2(index),(const char *)temp); temp2 = (char*)(*g_engfuncs.pfnGetPhysicsKeyValue)(TypeConversion.id_to_edict(index),(const char *)temp);
cRet = MF_GetAmxAddr(amx,params[5]); cRet = MF_GetAmxAddr(amx,params[5]);
MF_SetAmxString(amx,params[4],temp2,cRet[0]); MF_SetAmxString(amx,params[4],temp2,cRet[0]);
return 1; return 1;
@ -869,7 +869,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
temp = MF_GetAmxString(amx,params[3],0,&len); temp = MF_GetAmxString(amx,params[3],0,&len);
temp2 = MF_GetAmxString(amx,params[4],1,&len); temp2 = MF_GetAmxString(amx,params[4],1,&len);
(*g_engfuncs.pfnSetPhysicsKeyValue)(INDEXENT2(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2))); (*g_engfuncs.pfnSetPhysicsKeyValue)(TypeConversion.id_to_edict(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2)));
return 1; return 1;
@ -878,7 +878,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
temp = (char*)(*g_engfuncs.pfnGetPhysicsInfoString)(INDEXENT2(index)); temp = (char*)(*g_engfuncs.pfnGetPhysicsInfoString)(TypeConversion.id_to_edict(index));
cRet = MF_GetAmxAddr(amx,params[4]); cRet = MF_GetAmxAddr(amx,params[4]);
MF_SetAmxString(amx,params[3],temp,cRet[0]); MF_SetAmxString(amx,params[3],temp,cRet[0]);
@ -924,7 +924,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
iparam5 = cRet[0]; iparam5 = cRet[0];
cRet = MF_GetAmxAddr(amx,params[13]); cRet = MF_GetAmxAddr(amx,params[13]);
iparam6 = cRet[0]; iparam6 = cRet[0];
(*g_engfuncs.pfnPlaybackEvent)(iparam1,INDEXENT2(index),iparam2,fparam1,Vec1,Vec2,fparam2,fparam3,iparam3,iparam4,iparam5,iparam6); (*g_engfuncs.pfnPlaybackEvent)(iparam1,TypeConversion.id_to_edict(index),iparam2,fparam1,Vec1,Vec2,fparam2,fparam3,iparam3,iparam4,iparam5,iparam6);
return 1; return 1;
//pfnCheckVisibility //pfnCheckVisibility
@ -934,7 +934,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
cRet = MF_GetAmxAddr(amx, params[3]); cRet = MF_GetAmxAddr(amx, params[3]);
pset = (unsigned char *)cRet[0]; pset = (unsigned char *)cRet[0];
return (*g_engfuncs.pfnCheckVisibility)(INDEXENT2(index), pset); return (*g_engfuncs.pfnCheckVisibility)(TypeConversion.id_to_edict(index), pset);
// pfnGetCurrentPlayer // pfnGetCurrentPlayer
case EngFunc_GetCurrentPlayer: // int ) ( void ); case EngFunc_GetCurrentPlayer: // int ) ( void );
@ -946,7 +946,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
cRet = MF_GetAmxAddr(amx,params[2]); cRet = MF_GetAmxAddr(amx,params[2]);
index = cRet[0]; index = cRet[0];
CHECK_ENTITY(index); CHECK_ENTITY(index);
return (*g_engfuncs.pfnCanSkipPlayer)(INDEXENT2(index)); return (*g_engfuncs.pfnCanSkipPlayer)(TypeConversion.id_to_edict(index));
// pfnSetGroupMask // pfnSetGroupMask
@ -991,7 +991,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
Vec1[2]=amx_ctof(cRet[2]); Vec1[2]=amx_ctof(cRet[2]);
cRet = MF_GetAmxAddr(amx,params[5]); cRet = MF_GetAmxAddr(amx,params[5]);
index = cRet[0]; index = cRet[0];
(*g_engfuncs.pfnMessageBegin)(iparam1,iparam2,Vec1,index == 0 ? NULL : INDEXENT2(index)); (*g_engfuncs.pfnMessageBegin)(iparam1,iparam2,Vec1,index == 0 ? NULL : TypeConversion.id_to_edict(index));
return 1; return 1;
@ -1065,7 +1065,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
} }
temp = (*g_engfuncs.pfnGetInfoKeyBuffer)((index == -1) ? NULL : INDEXENT2(index)); temp = (*g_engfuncs.pfnGetInfoKeyBuffer)((index == -1) ? NULL : TypeConversion.id_to_edict(index));
return reinterpret_cast<cell>(temp); return reinterpret_cast<cell>(temp);
case EngFunc_AlertMessage: // void ) (ALERT_TYPE atype, char *szFmt, ...); case EngFunc_AlertMessage: // void ) (ALERT_TYPE atype, char *szFmt, ...);
cRet = MF_GetAmxAddr(amx, params[2]); cRet = MF_GetAmxAddr(amx, params[2]);
@ -1083,7 +1083,7 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
iparam1 = cRet[0]; iparam1 = cRet[0];
temp = MF_GetAmxString(amx,params[4], 0, &len); temp = MF_GetAmxString(amx,params[4], 0, &len);
(*g_engfuncs.pfnClientPrintf)(INDEXENT2(index), static_cast<PRINT_TYPE>(iparam1), temp); (*g_engfuncs.pfnClientPrintf)(TypeConversion.id_to_edict(index), static_cast<PRINT_TYPE>(iparam1), temp);
return 1; return 1;
case EngFunc_ServerPrint: // void ) (const char *szMsg); case EngFunc_ServerPrint: // void ) (const char *szMsg);
temp = MF_GetAmxString(amx, params[2], 0, &len); temp = MF_GetAmxString(amx, params[2], 0, &len);

View File

@ -14,8 +14,6 @@
#include "fakemeta_amxx.h" #include "fakemeta_amxx.h"
#include "sh_stack.h" #include "sh_stack.h"
edict_t *g_player_edicts[33]; // Used for INDEXENT() forward.
IGameConfig *CommonConfig; IGameConfig *CommonConfig;
IGameConfigManager *ConfigManager; IGameConfigManager *ConfigManager;
@ -78,15 +76,12 @@ void OnAmxxDetach()
delete g_FreeKVDWs.popCopy(); delete g_FreeKVDWs.popCopy();
} }
int GetHullBounds(int hullnumber, float *mins, float *maxs);
// sawce: Do not null out the forward for ServerActivate. It's required for the INDEXENT() fix. (I don't think ServerActivate is planned on being forwarded anyway)
void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{ {
for(int i = 1; i <= gpGlobals->maxClients;i++)
g_player_edicts[i]=pEdictList + i;
g_pFunctionTable_Post->pfnServerDeactivate = FMH_ServerDeactivate_Post; g_pFunctionTable_Post->pfnServerDeactivate = FMH_ServerDeactivate_Post;
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
#define RESETD(tcall) \ #define RESETD(tcall) \
g_pFunctionTable->pfn##tcall =0; \ g_pFunctionTable->pfn##tcall =0; \
g_pFunctionTable_Post->pfn##tcall =NULL; \ g_pFunctionTable_Post->pfn##tcall =NULL; \

View File

@ -28,15 +28,6 @@
#include <IGameConfigs.h> #include <IGameConfigs.h>
#include <HLTypeConversion.h> #include <HLTypeConversion.h>
extern edict_t *g_player_edicts[33];
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 CHECK_ENTITY(x) \ #define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \ if (x < 0 || x > gpGlobals->maxEntities) { \
@ -49,7 +40,7 @@ inline edict_t* INDEXENT2( int iEdictNum )
return 0; \ return 0; \
} \ } \
} else { \ } else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \ 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; \
} \ } \

View File

@ -27,7 +27,7 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
} }
cell *ptr = MF_GetAmxAddr(amx, params[2]); cell *ptr = MF_GetAmxAddr(amx, params[2]);
edict_t *e = 0; edict_t *e;
switch (type) switch (type)
{ {
@ -85,7 +85,7 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
} }
case TR_pHit: case TR_pHit:
{ {
e = INDEXENT(*ptr); e = TypeConversion.id_to_edict(*ptr);
if (!e || FNullEnt(e)) if (!e || FNullEnt(e))
return 0; //TODO: return error return 0; //TODO: return error
gfm_tr->pHit = e; gfm_tr->pHit = e;

View File

@ -98,7 +98,7 @@ static cell AMX_NATIVE_CALL set_tr2(AMX *amx, cell *params)
} }
case TR_pHit: case TR_pHit:
{ {
edict_t *e = INDEXENT(*ptr); edict_t *e = TypeConversion.id_to_edict(*ptr);
if (!e || FNullEnt(e)) if (!e || FNullEnt(e))
return 0; //TODO: return error return 0; //TODO: return error
tr->pHit = e; tr->pHit = e;

View File

@ -341,14 +341,14 @@ void MoveToOrigin_post(edict_t *ent, const float *pflGoal, float dist, int iMove
edict_t *FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue) edict_t *FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue)
{ {
FM_ENG_HANDLE(FM_FindEntityByString, (Engine[FM_FindEntityByString].at(i), (cell)ENTINDEX(pEdictStartSearchAfter), pszField, pszValue)); FM_ENG_HANDLE(FM_FindEntityByString, (Engine[FM_FindEntityByString].at(i), (cell)ENTINDEX(pEdictStartSearchAfter), pszField, pszValue));
RETURN_META_VALUE(mswi(lastFmRes), INDEXENT2((int)mlCellResult)); RETURN_META_VALUE(mswi(lastFmRes), TypeConversion.id_to_edict((int)mlCellResult));
} }
edict_t *FindEntityByString_post(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue) edict_t *FindEntityByString_post(edict_t *pEdictStartSearchAfter, const char *pszField, const char *pszValue)
{ {
origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *));
FM_ENG_HANDLE_POST(FM_FindEntityByString, (EnginePost[FM_FindEntityByString].at(i), (cell)ENTINDEX(pEdictStartSearchAfter), pszField, pszValue)); FM_ENG_HANDLE_POST(FM_FindEntityByString, (EnginePost[FM_FindEntityByString].at(i), (cell)ENTINDEX(pEdictStartSearchAfter), pszField, pszValue));
RETURN_META_VALUE(MRES_IGNORED, INDEXENT2((int)mlCellResult)); RETURN_META_VALUE(MRES_IGNORED, TypeConversion.id_to_edict((int)mlCellResult));
} }
// pfnGetEntityIllum // pfnGetEntityIllum
SIMPLE_INT_HOOK_EDICT(GetEntityIllum); SIMPLE_INT_HOOK_EDICT(GetEntityIllum);

View File

@ -205,13 +205,13 @@
edict_t* call (const char *s) \ edict_t* call (const char *s) \
{ \ { \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), s)); \ FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), s)); \
RETURN_META_VALUE(mswi(lastFmRes), INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(mswi(lastFmRes), TypeConversion.id_to_edict((int)mlCellResult)); \
} \ } \
edict_t* call##_post (const char *s) \ edict_t* call##_post (const char *s) \
{ \ { \
origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \ origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), s)); \ FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), s)); \
RETURN_META_VALUE(MRES_IGNORED, INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(MRES_IGNORED, TypeConversion.id_to_edict((int)mlCellResult)); \
} }
#define SIMPLE_CHAR_HOOK_STRING(call) \ #define SIMPLE_CHAR_HOOK_STRING(call) \
char call (char *s) \ char call (char *s) \
@ -413,38 +413,38 @@
edict_t* call () \ edict_t* call () \
{ \ { \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i))); \ FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i))); \
RETURN_META_VALUE(mswi(lastFmRes),INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(mswi(lastFmRes),TypeConversion.id_to_edict((int)mlCellResult)); \
} \ } \
edict_t* call##_post () \ edict_t* call##_post () \
{ \ { \
origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \ origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i))); \ FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i))); \
RETURN_META_VALUE(MRES_IGNORED,INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(MRES_IGNORED,TypeConversion.id_to_edict((int)mlCellResult)); \
} }
#define SIMPLE_EDICT_HOOK_INT(call) \ #define SIMPLE_EDICT_HOOK_INT(call) \
edict_t* call (int v) \ edict_t* call (int v) \
{ \ { \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i),(cell)v)); \ FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i),(cell)v)); \
RETURN_META_VALUE(mswi(lastFmRes),INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(mswi(lastFmRes),TypeConversion.id_to_edict((int)mlCellResult)); \
} \ } \
edict_t* call##_post (int v) \ edict_t* call##_post (int v) \
{ \ { \
origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \ origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i),(cell)v)); \ FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i),(cell)v)); \
RETURN_META_VALUE(MRES_IGNORED,INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(MRES_IGNORED,TypeConversion.id_to_edict((int)mlCellResult)); \
} }
#define SIMPLE_EDICT_HOOK_EDICT(call) \ #define SIMPLE_EDICT_HOOK_EDICT(call) \
edict_t* call (edict_t *e) \ edict_t* call (edict_t *e) \
{ \ { \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i),(cell)ENTINDEX(e))); \ FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i),(cell)ENTINDEX(e))); \
RETURN_META_VALUE(mswi(lastFmRes),INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(mswi(lastFmRes),TypeConversion.id_to_edict((int)mlCellResult)); \
} \ } \
edict_t* call##_post (edict_t *e) \ edict_t* call##_post (edict_t *e) \
{ \ { \
origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \ origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i),(cell)ENTINDEX(e))); \ FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i),(cell)ENTINDEX(e))); \
RETURN_META_VALUE(MRES_IGNORED,INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(MRES_IGNORED,TypeConversion.id_to_edict((int)mlCellResult)); \
} }
#define SIMPLE_EDICT_HOOK_EDICT_CONSTVECT_FLOAT(call) \ #define SIMPLE_EDICT_HOOK_EDICT_CONSTVECT_FLOAT(call) \
@ -452,14 +452,14 @@
{ \ { \
PREPARE_VECTOR(vec); \ PREPARE_VECTOR(vec); \
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), (cell)ENTINDEX(ed), p_vec, fla)); \ FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), (cell)ENTINDEX(ed), p_vec, fla)); \
RETURN_META_VALUE(mswi(lastFmRes), INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(mswi(lastFmRes), TypeConversion.id_to_edict((int)mlCellResult)); \
} \ } \
edict_t* call##_post (edict_t *ed, const float *vec, float fla) \ edict_t* call##_post (edict_t *ed, const float *vec, float fla) \
{ \ { \
PREPARE_VECTOR(vec); \ PREPARE_VECTOR(vec); \
origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \ origCellRet = ENTINDEX(META_RESULT_ORIG_RET(edict_t *)); \
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), (cell)ENTINDEX(ed), p_vec, fla)); \ FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), (cell)ENTINDEX(ed), p_vec, fla)); \
RETURN_META_VALUE(MRES_IGNORED, INDEXENT2((int)mlCellResult)); \ RETURN_META_VALUE(MRES_IGNORED, TypeConversion.id_to_edict((int)mlCellResult)); \
} }

View File

@ -21,26 +21,6 @@ static cell AMX_NATIVE_CALL copy_infokey_buffer(AMX *amx, cell *params)
return MF_SetAmxString(amx, params[2], infobuffer, params[3]); return MF_SetAmxString(amx, params[2], infobuffer, params[3]);
} }
int UTIL_stricmp(const char *s1, const char *s2)
{
unsigned char c1, c2;
for (;;) {
c1 = *s1++;
c2 = *s2++;
if (!c1 || !c2)
break;
if (c1 == c2)
continue;
if ((c1 = tolower(c1)) != (c2 = tolower(c2)))
break;
}
return (int)c1 - (int)c2;
}
// lookup_sequence(entid, "sequence name", &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0); // lookup_sequence(entid, "sequence name", &Float:framerate = 0.0, &bool:loops = false, &Float:groundspeed = 0.0);
static cell AMX_NATIVE_CALL lookup_sequence(AMX* amx, cell* params) static cell AMX_NATIVE_CALL lookup_sequence(AMX* amx, cell* params)
{ {
@ -48,7 +28,7 @@ static cell AMX_NATIVE_CALL lookup_sequence(AMX* amx, cell* params)
CHECK_ENTITY(index); CHECK_ENTITY(index);
edict_t* ent = INDEXENT(index); edict_t* ent = TypeConversion.id_to_edict(index);
studiohdr_t* pstudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(ent)); studiohdr_t* pstudiohdr = static_cast<studiohdr_t*>(GET_MODEL_PTR(ent));
@ -67,7 +47,7 @@ static cell AMX_NATIVE_CALL lookup_sequence(AMX* amx, cell* params)
for (int i = 0; i < pstudiohdr->numseq; i++) for (int i = 0; i < pstudiohdr->numseq; i++)
{ {
if (UTIL_stricmp( pseqdesc[i].label, label ) == 0) if (strcasecmp( pseqdesc[i].label, label ) == 0)
{ {
REAL* FrameRate = reinterpret_cast<REAL*>(MF_GetAmxAddr(amx, params[3])); REAL* FrameRate = reinterpret_cast<REAL*>(MF_GetAmxAddr(amx, params[3]));
cell* Loops = MF_GetAmxAddr(amx, params[4]); cell* Loops = MF_GetAmxAddr(amx, params[4]);
@ -95,7 +75,7 @@ static cell AMX_NATIVE_CALL set_controller(AMX* amx, cell* params)
// SetController( void *pmodel, entvars_t *pev, int iController, float flValue ) // SetController( void *pmodel, entvars_t *pev, int iController, float flValue )
int entindex = params[1]; int entindex = params[1];
CHECK_ENTITY(entindex); CHECK_ENTITY(entindex);
edict_t* entity = INDEXENT(entindex); edict_t* entity = TypeConversion.id_to_edict(entindex);
int iController = params[2]; int iController = params[2];
@ -176,7 +156,7 @@ static cell AMX_NATIVE_CALL GetModelCollisionBox(AMX *amx, cell *params)
CHECK_ENTITY(entityIndex); CHECK_ENTITY(entityIndex);
edict_t *pEdict = INDEXENT2(entityIndex); edict_t *pEdict = TypeConversion.id_to_edict(entityIndex);
if (!FNullEnt(pEdict)) if (!FNullEnt(pEdict))
{ {
@ -212,7 +192,7 @@ static cell AMX_NATIVE_CALL GetModelBoundingBox(AMX *amx, cell *params)
CHECK_ENTITY(entityIndex); CHECK_ENTITY(entityIndex);
edict_t *pentModel = INDEXENT2(entityIndex); edict_t *pentModel = TypeConversion.id_to_edict(entityIndex);
if (!FNullEnt(pentModel)) if (!FNullEnt(pentModel))
{ {
@ -269,7 +249,7 @@ static cell AMX_NATIVE_CALL SetModelCollisionBox(AMX *amx, cell *params)
CHECK_ENTITY(entityIndex); CHECK_ENTITY(entityIndex);
edict_t *pentModel = INDEXENT2(entityIndex); edict_t *pentModel = TypeConversion.id_to_edict(entityIndex);
if (!FNullEnt(pentModel)) if (!FNullEnt(pentModel))
{ {
@ -296,7 +276,7 @@ static cell AMX_NATIVE_CALL SetModelBoundingBox(AMX *amx, cell *params)
CHECK_ENTITY(entityIndex); CHECK_ENTITY(entityIndex);
edict_t *pentModel = INDEXENT2(entityIndex); edict_t *pentModel = TypeConversion.id_to_edict(entityIndex);
if (!FNullEnt(pentModel)) if (!FNullEnt(pentModel))
{ {

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

@ -58,9 +58,10 @@ static cell AMX_NATIVE_CALL set_pdata_int(AMX *amx, cell *params)
iOffset += params[5]; iOffset += params[5];
#endif #endif
int iValue=params[3]; int iValue=params[3];
*((int *)INDEXENT2(index)->pvPrivateData + iOffset) = iValue; set_pdata<int>(TypeConversion.id_to_edict(index), iOffset, iValue);
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_pdata_int(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_int(AMX *amx, cell *params)
{ {
int index=params[1]; int index=params[1];
@ -79,8 +80,9 @@ static cell AMX_NATIVE_CALL get_pdata_int(AMX *amx, cell *params)
iOffset += params[4]; iOffset += params[4];
#endif #endif
return *((int *)INDEXENT2(index)->pvPrivateData + iOffset); return get_pdata<int>(TypeConversion.id_to_edict(index), iOffset);
} }
// Float // Float
static cell AMX_NATIVE_CALL set_pdata_float(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_float(AMX *amx, cell *params)
{ {
@ -101,7 +103,7 @@ static cell AMX_NATIVE_CALL set_pdata_float(AMX *amx, cell *params)
#endif #endif
float fValue=amx_ctof(params[3]); float fValue=amx_ctof(params[3]);
*((float *)INDEXENT2(index)->pvPrivateData + iOffset) = fValue; set_pdata<float>(TypeConversion.id_to_edict(index), iOffset, fValue);
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_pdata_float(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_float(AMX *amx, cell *params)
@ -122,7 +124,7 @@ static cell AMX_NATIVE_CALL get_pdata_float(AMX *amx, cell *params)
iOffset += params[4]; iOffset += params[4];
#endif #endif
return amx_ftoc(*((float *)INDEXENT2(index)->pvPrivateData + iOffset)); return amx_ftoc(get_pdata<float>(TypeConversion.id_to_edict(index), iOffset));
} }
static cell AMX_NATIVE_CALL get_pdata_string(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_pdata_string(AMX *amx, cell *params)
@ -142,15 +144,14 @@ static cell AMX_NATIVE_CALL get_pdata_string(AMX *amx, cell *params)
else else
iOffset += params[7]; iOffset += params[7];
#endif #endif
edict_t *pEdict = TypeConversion.id_to_edict(index);
edict_t *pEdict = INDEXENT2(index);
char *szData; char *szData;
if (params[5]) if (params[5])
{ {
szData = *((char **)pEdict->pvPrivateData + iOffset); szData = get_pdata<char*>(pEdict, iOffset);
} else { } else {
szData = (char *)pEdict->pvPrivateData + iOffset; szData = get_pdata_direct<char*>(pEdict, iOffset);
} }
if (IsBadReadPtr(szData, 1)) if (IsBadReadPtr(szData, 1))
@ -181,19 +182,19 @@ static cell AMX_NATIVE_CALL set_pdata_string(AMX *amx, cell *params)
iOffset += params[6]; iOffset += params[6];
#endif #endif
edict_t *pEdict = INDEXENT2(index); edict_t *pEdict = TypeConversion.id_to_edict(index);
char *szData; char *szData;
int len; int len;
char *data = MF_GetAmxString(amx, params[3], 0, &len); char *data = MF_GetAmxString(amx, params[3], 0, &len);
if (params[4] == -1) if (params[4] == -1)
{ {
szData = (char *)pEdict->pvPrivateData + iOffset; szData = get_pdata_direct<char*>(pEdict, iOffset);
if (IsBadWritePtr(szData, 1)) if (IsBadWritePtr(szData, 1))
return 0; return 0;
strcpy(szData, data); strcpy(szData, data);
} else { } else {
szData = *((char **)pEdict->pvPrivateData + iOffset); szData = get_pdata<char*>(pEdict, iOffset);
if (IsBadWritePtr(szData, 1)) if (IsBadWritePtr(szData, 1))
return 0; return 0;
if (params[4] == 1) if (params[4] == 1)
@ -205,7 +206,7 @@ static cell AMX_NATIVE_CALL set_pdata_string(AMX *amx, cell *params)
szData = new char[len + 1]; szData = new char[len + 1];
} }
strcpy(szData, data); strcpy(szData, data);
*((char **)pEdict->pvPrivateData + iOffset) = szData; set_pdata<char*>(pEdict, iOffset, szData);
} }
return 1; return 1;
@ -229,7 +230,7 @@ static cell AMX_NATIVE_CALL get_pdata_ent(AMX *amx, cell *params)
iOffset += params[4]; iOffset += params[4];
#endif #endif
edict_t *pEdict = *(edict_t **)((char *)(INDEXENT2(index)->pvPrivateData) + iOffset); edict_t *pEdict = get_pdata<edict_t*>(TypeConversion.id_to_edict(index), iOffset);
if (pEdict == NULL) if (pEdict == NULL)
{ {
@ -273,7 +274,7 @@ static cell AMX_NATIVE_CALL set_pdata_ent(AMX *amx, cell *params)
offset += params[5]; offset += params[5];
#endif #endif
*(edict_t **)((char *)(INDEXENT2(index)->pvPrivateData) + offset) = INDEXENT2(entity); set_pdata<edict_t*>(TypeConversion.id_to_edict(index), offset, TypeConversion.id_to_edict(entity));
return 1; return 1;
} }
@ -296,7 +297,7 @@ static cell AMX_NATIVE_CALL get_pdata_bool(AMX *amx, cell *params)
offset += params[4]; offset += params[4];
#endif #endif
return *(bool *)((char *)INDEXENT2(index)->pvPrivateData + offset) ? TRUE : FALSE; return get_pdata<bool>(TypeConversion.id_to_edict(index), offset) ? TRUE : FALSE;
} }
static cell AMX_NATIVE_CALL set_pdata_bool(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_bool(AMX *amx, cell *params)
@ -319,7 +320,7 @@ static cell AMX_NATIVE_CALL set_pdata_bool(AMX *amx, cell *params)
offset += params[5]; offset += params[5];
#endif #endif
*(bool *)((char *)INDEXENT2(index)->pvPrivateData + offset) = value; set_pdata<bool>(TypeConversion.id_to_edict(index), offset, value);
return 1; return 1;
} }
@ -342,7 +343,7 @@ static cell AMX_NATIVE_CALL get_pdata_byte(AMX *amx, cell *params)
offset += params[4]; offset += params[4];
#endif #endif
return static_cast<cell>(*((byte *)INDEXENT2(index)->pvPrivateData + offset)); return static_cast<cell>(get_pdata<byte>(TypeConversion.id_to_edict(index), offset));
} }
static cell AMX_NATIVE_CALL set_pdata_byte(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_byte(AMX *amx, cell *params)
@ -365,7 +366,7 @@ static cell AMX_NATIVE_CALL set_pdata_byte(AMX *amx, cell *params)
offset += params[5]; offset += params[5];
#endif #endif
*((byte *)INDEXENT2(index)->pvPrivateData + offset) = value; set_pdata<byte>(TypeConversion.id_to_edict(index), offset, value);
return 1; return 1;
} }
@ -388,7 +389,7 @@ static cell AMX_NATIVE_CALL get_pdata_short(AMX *amx, cell *params)
offset += params[4]; offset += params[4];
#endif #endif
return static_cast<cell>(*(short *)((char *)INDEXENT2(index)->pvPrivateData + offset)); return static_cast<cell>(get_pdata<short>(TypeConversion.id_to_edict(index), offset));
} }
static cell AMX_NATIVE_CALL set_pdata_short(AMX *amx, cell *params) static cell AMX_NATIVE_CALL set_pdata_short(AMX *amx, cell *params)
@ -411,7 +412,7 @@ static cell AMX_NATIVE_CALL set_pdata_short(AMX *amx, cell *params)
offset += params[5]; offset += params[5];
#endif #endif
*(short *)((char *)INDEXENT2(index)->pvPrivateData + offset) = value; set_pdata<short>(TypeConversion.id_to_edict(index), offset, value);
return 1; return 1;
} }
@ -436,7 +437,7 @@ static cell AMX_NATIVE_CALL get_pdata_vector(AMX *amx, cell *params)
cell *cpvec = MF_GetAmxAddr(amx, params[3]); cell *cpvec = MF_GetAmxAddr(amx, params[3]);
Vector vec = *(Vector *)((char *)INDEXENT2(index)->pvPrivateData + offset); Vector vec = get_pdata<Vector>(TypeConversion.id_to_edict(index), offset);
cpvec[0] = amx_ftoc(vec.x); cpvec[0] = amx_ftoc(vec.x);
cpvec[1] = amx_ftoc(vec.y); cpvec[1] = amx_ftoc(vec.y);
@ -467,7 +468,7 @@ static cell AMX_NATIVE_CALL set_pdata_vector(AMX *amx, cell *params)
Vector vec(amx_ctof(pcvec[0]), amx_ctof(pcvec[1]), amx_ctof(pcvec[2])); Vector vec(amx_ctof(pcvec[0]), amx_ctof(pcvec[1]), amx_ctof(pcvec[2]));
*(Vector *)((char *)INDEXENT2(index)->pvPrivateData + offset) = vec; set_pdata<Vector>(TypeConversion.id_to_edict(index), offset, vec);
return 1; return 1;
} }
@ -490,7 +491,7 @@ static cell AMX_NATIVE_CALL get_pdata_ehandle(AMX *amx, cell *params)
offset += params[4]; offset += params[4];
#endif #endif
edict_t *pEdict = *(edict_t **)((char * )(INDEXENT2(index)->pvPrivateData) + offset); edict_t *pEdict = get_pdata<edict_t*>(TypeConversion.id_to_edict(index), offset);
if (pEdict == NULL) if (pEdict == NULL)
{ {
@ -510,7 +511,7 @@ static cell AMX_NATIVE_CALL get_pdata_ehandle(AMX *amx, cell *params)
return -1; return -1;
} }
int serialnumber = *(int *)((char *)INDEXENT2(index)->pvPrivateData + offset + 4); int serialnumber = get_pdata<int>(TypeConversion.id_to_edict(index), offset + 4);
if (pEdict->serialnumber != serialnumber) if (pEdict->serialnumber != serialnumber)
{ {
@ -541,13 +542,13 @@ static cell AMX_NATIVE_CALL set_pdata_ehandle(AMX *amx, cell *params)
offset += params[5]; offset += params[5];
#endif #endif
edict_t *pEntity = INDEXENT2(entity); edict_t *pEntity = TypeConversion.id_to_edict(entity);
*(edict_t **)((char* )(INDEXENT2(index)->pvPrivateData) + offset) = pEntity; set_pdata<edict_t*>(TypeConversion.id_to_edict(index), offset, pEntity);
if (pEntity) if (pEntity)
{ {
*(int *)((char *)INDEXENT2(index)->pvPrivateData + offset + 4) = pEntity->serialnumber; set_pdata<int>(TypeConversion.id_to_edict(index), offset + 4, pEntity->serialnumber);
} }
return 1; return 1;

View File

@ -162,7 +162,7 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params)
{ {
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY(index);
edict_t *pEdict = INDEXENT2(index); edict_t *pEdict = TypeConversion.id_to_edict(index);
int iSwitch = params[2]; int iSwitch = params[2];
//onto normal cases - sanity check //onto normal cases - sanity check
@ -347,7 +347,7 @@ static cell AMX_NATIVE_CALL amx_set_pev(AMX *amx, cell *params)
// index, pevdata // index, pevdata
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY(index);
edict_t *pEdict = INDEXENT2(index); edict_t *pEdict = TypeConversion.id_to_edict(index);
int iSwitch = params[2]; int iSwitch = params[2];
//onto normal cases - sanity check //onto normal cases - sanity check
@ -382,7 +382,7 @@ static cell AMX_NATIVE_CALL amx_set_pev(AMX *amx, cell *params)
*(string_t *)EDICT_OFFS(v, offs) = value; *(string_t *)EDICT_OFFS(v, offs) = value;
} else if ( (iSwitch > pev_edict_start && iSwitch < pev_edict_end) } else if ( (iSwitch > pev_edict_start && iSwitch < pev_edict_end)
|| (iSwitch > pev_edict2_start && iSwitch < pev_absolute_end) ) { || (iSwitch > pev_edict2_start && iSwitch < pev_absolute_end) ) {
edict_t *e = INDEXENT((int)*blah); edict_t *e = TypeConversion.id_to_edict((int)*blah);
*(edict_t **)EDICT_OFFS(v, offs) = e; *(edict_t **)EDICT_OFFS(v, offs) = e;
} else if (iSwitch > pev_vecarray_start && iSwitch < pev_vecarray_end) { } else if (iSwitch > pev_vecarray_start && iSwitch < pev_vecarray_end) {
vec3_t vec; vec3_t vec;
@ -416,7 +416,7 @@ static cell AMX_NATIVE_CALL amx_set_pev_string(AMX *amx, cell *params)
// index, pevdata // index, pevdata
int index = params[1]; int index = params[1];
CHECK_ENTITY(index); CHECK_ENTITY(index);
edict_t *pEdict = INDEXENT2(index); edict_t *pEdict = TypeConversion.id_to_edict(index);
int iSwitch = params[2]; int iSwitch = params[2];
//onto normal cases - sanity check //onto normal cases - sanity check
@ -455,7 +455,7 @@ static cell AMX_NATIVE_CALL amx_pev_valid(AMX *amx, cell *params)
{ {
int idx = static_cast<int>(params[1]); int idx = static_cast<int>(params[1]);
edict_t *e = INDEXENT(idx); edict_t *e = TypeConversion.id_to_edict(idx);
if (FNullEnt(e)) if (FNullEnt(e))
return 0; return 0;
@ -470,7 +470,7 @@ static cell AMX_NATIVE_CALL amx_pev_serial(AMX* amx, cell* params)
int id = static_cast<int>(params[1]); int id = static_cast<int>(params[1]);
CHECK_ENTITY(id); CHECK_ENTITY(id);
edict_t* ent = INDEXENT(id); edict_t* ent = TypeConversion.id_to_edict(id);
return ent->serialnumber; return ent->serialnumber;
} }

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

@ -13,6 +13,7 @@
#include <string.h> #include <string.h>
#include "fun.h" #include "fun.h"
#include <HLTypeConversion.h>
/* /*
JGHG says: JGHG says:
@ -39,6 +40,11 @@
} }
*/ */
char g_bodyhits[33][33]; // where can the guy in the first dimension hit the people in the 2nd dimension? :-)
bool g_silent[33]; // used for set_user_footsteps()
HLTypeConversion TypeConversion;
// ######## Utils: // ######## Utils:
void FUNUTIL_ResetPlayer(int index) void FUNUTIL_ResetPlayer(int index)
{ {
@ -100,7 +106,7 @@ static cell AMX_NATIVE_CALL set_user_godmode(AMX *amx, cell *params) // set_user
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Get player pointer. // Get player pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
if (params[2] == 1) { if (params[2] == 1) {
// Enable godmode // Enable godmode
@ -123,7 +129,7 @@ static cell AMX_NATIVE_CALL get_user_godmode(AMX *amx, cell *params) // get_user
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Get player pointer. // Get player pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
int godmode = 0; int godmode = 0;
@ -147,7 +153,7 @@ static cell AMX_NATIVE_CALL give_item(AMX *amx, cell *params) // native give_ite
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Get player pointer. // Get player pointer.
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
// Create item entity pointer // Create item entity pointer
edict_t *pItemEntity; edict_t *pItemEntity;
@ -211,7 +217,7 @@ static cell AMX_NATIVE_CALL spawn(AMX *amx, cell *params) // spawn(id) = 1 param
CHECK_ENTITY(params[1]); CHECK_ENTITY(params[1]);
edict_t *pEnt = GETEDICT(params[1]); edict_t *pEnt = TypeConversion.id_to_edict(params[1]);
MDLL_Spawn(pEnt); MDLL_Spawn(pEnt);
@ -228,7 +234,7 @@ static cell AMX_NATIVE_CALL set_user_health(AMX *amx, cell *params) // set_user_
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
// Kill if health too low. // Kill if health too low.
if (params[2] > 0) if (params[2] > 0)
@ -249,7 +255,7 @@ static cell AMX_NATIVE_CALL set_user_frags(AMX *amx, cell *params) // set_user_f
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.frags = params[2]; pPlayer->v.frags = params[2];
@ -266,7 +272,7 @@ static cell AMX_NATIVE_CALL set_user_armor(AMX *amx, cell *params) // set_user_a
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.armorvalue = params[2]; pPlayer->v.armorvalue = params[2];
@ -283,7 +289,7 @@ static cell AMX_NATIVE_CALL set_user_origin(AMX *amx, cell *params) // set_user_
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
cell *newVectorCell = MF_GetAmxAddr(amx, params[2]); cell *newVectorCell = MF_GetAmxAddr(amx, params[2]);
@ -308,7 +314,7 @@ static cell AMX_NATIVE_CALL set_user_rendering(AMX *amx, cell *params) // set_us
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.renderfx = params[2]; pPlayer->v.renderfx = params[2];
Vector newVector = Vector(float(params[3]), float(params[4]), float(params[5])); Vector newVector = Vector(float(params[3]), float(params[4]), float(params[5]));
@ -332,7 +338,7 @@ static cell AMX_NATIVE_CALL set_user_maxspeed(AMX *amx, cell *params) // set_use
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
SETCLIENTMAXSPEED(pPlayer, fNewSpeed); SETCLIENTMAXSPEED(pPlayer, fNewSpeed);
pPlayer->v.maxspeed = fNewSpeed; pPlayer->v.maxspeed = fNewSpeed;
@ -349,7 +355,7 @@ static cell AMX_NATIVE_CALL get_user_maxspeed(AMX *amx, cell *params) // Float:g
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
return amx_ftoc(pPlayer->v.maxspeed); return amx_ftoc(pPlayer->v.maxspeed);
} }
@ -363,7 +369,7 @@ static cell AMX_NATIVE_CALL set_user_gravity(AMX *amx, cell *params) // set_user
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
pPlayer->v.gravity = amx_ctof(params[2]); pPlayer->v.gravity = amx_ctof(params[2]);
@ -379,7 +385,7 @@ static cell AMX_NATIVE_CALL get_user_gravity(AMX *amx, cell *params) // Float:ge
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
return amx_ftoc(pPlayer->v.gravity); return amx_ftoc(pPlayer->v.gravity);
} }
@ -449,7 +455,7 @@ static cell AMX_NATIVE_CALL set_user_noclip(AMX *amx, cell *params) // set_user_
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
if (params[2] == 1) if (params[2] == 1)
pPlayer->v.movetype = MOVETYPE_NOCLIP; pPlayer->v.movetype = MOVETYPE_NOCLIP;
@ -468,7 +474,7 @@ static cell AMX_NATIVE_CALL get_user_noclip(AMX *amx, cell *params) // get_user_
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
return pPlayer->v.movetype == MOVETYPE_NOCLIP; return pPlayer->v.movetype == MOVETYPE_NOCLIP;
} }
@ -485,7 +491,7 @@ static cell AMX_NATIVE_CALL set_user_footsteps(AMX *amx, cell *params) // set_us
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Fetch player pointer // Fetch player pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = TypeConversion.id_to_edict(params[1]);
if (params[2]) { if (params[2]) {
pPlayer->v.flTimeStepSound = 999; pPlayer->v.flTimeStepSound = 999;
@ -511,7 +517,7 @@ static cell AMX_NATIVE_CALL strip_user_weapons(AMX *amx, cell *params) // index
{ {
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
edict_t* pPlayer = MF_GetPlayerEdict(params[1]); edict_t* pPlayer = TypeConversion.id_to_edict(params[1]);
string_t item = MAKE_STRING("player_weaponstrip"); string_t item = MAKE_STRING("player_weaponstrip");
edict_t *pent = CREATE_NAMED_ENTITY(item); edict_t *pent = CREATE_NAMED_ENTITY(item);
@ -632,6 +638,8 @@ void OnPluginsLoaded() {
// Reset all hitzones // Reset all hitzones
FUNUTIL_ResetPlayer(i); FUNUTIL_ResetPlayer(i);
} }
TypeConversion.init();
} }
/* /*
void ClientConnectFakeBot(int index) void ClientConnectFakeBot(int index)

View File

@ -29,16 +29,6 @@
#define HITGROUP_RIGHTARM 5 // 32 #define HITGROUP_RIGHTARM 5 // 32
#define HITGROUP_LEFTLEG 6 // 64 #define HITGROUP_LEFTLEG 6 // 64
#define HITGROUP_RIGHTLEG 7 // 128 #define HITGROUP_RIGHTLEG 7 // 128
// Fun-specific defines above
// The stuff below might end up in a class soon
char g_bodyhits[33][33]; // where can the guy in the first dimension hit the people in the 2nd dimension? :-)
bool g_silent[33]; // used for set_user_footsteps()
//int g_ResetHUD;
bool g_ResetHUDbool;
edict_t* g_edict;
//bool g_bot[33]; // is user bot? <--- removed, only needed with akimbot
// Globals above
#define CHECK_ENTITY(x) \ #define CHECK_ENTITY(x) \
if (x < 0 || x > gpGlobals->maxEntities) { \ if (x < 0 || x > gpGlobals->maxEntities) { \
@ -51,7 +41,7 @@ edict_t* g_edict;
return 0; \ return 0; \
} \ } \
} else { \ } else { \
if (x != 0 && FNullEnt(INDEXENT(x))) { \ 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; \
} \ } \
@ -63,11 +53,8 @@ edict_t* g_edict;
MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Player out of range (%d)", x); \
return 0; \ return 0; \
} else { \ } else { \
if (!MF_IsPlayerIngame(x) || FNullEnt(MF_GetPlayerEdict(x))) { \ if (!MF_IsPlayerIngame(x) || FNullEnt(TypeConversion.id_to_edict(x))) { \
MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid player %d", x); \
return 0; \ return 0; \
} \ } \
} }
#define GETEDICT(n) \
((n >= 1 && n <= gpGlobals->maxClients) ? MF_GetPlayerEdict(n) : INDEXENT(n))

View File

@ -141,10 +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\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">
@ -37,6 +43,12 @@
<ClInclude Include="..\..\..\public\sdk\amxxmodule.h"> <ClInclude Include="..\..\..\public\sdk\amxxmodule.h">
<Filter>Module SDK\SDK Base</Filter> <Filter>Module SDK\SDK Base</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\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;
}; };
@ -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)
@ -518,7 +518,7 @@ cell Call_Float_Int(AMX *amx, cell *params)
#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;
} }
@ -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,14 +1458,14 @@ 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;
} }
@ -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,8 +1711,7 @@ 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)

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,107 +39,15 @@
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;
@ -157,5 +66,4 @@ inline void *GetVTableEntry(void *pthis, int ventry, int 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

@ -644,10 +644,9 @@ static cell AMX_NATIVE_CALL RegisterHamFromEntity(AMX *amx, cell *params)
// 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

@ -31,7 +31,7 @@ static cell AMX_NATIVE_CALL TFC_SetModel(AMX *amx, cell *params) {
char *szModel = MF_GetAmxString(amx, params[2],0, &iLen); char *szModel = MF_GetAmxString(amx, params[2],0, &iLen);
// Get Player's edict pointer // Get Player's edict pointer
edict_t* pPlayer = INDEXENT(iIndex); edict_t* pPlayer = MF_GetPlayerEdict(iIndex);
// Set key on client, replacement_model is for the model we want. // Set key on client, replacement_model is for the model we want.
KeyValueData pkvd; KeyValueData pkvd;
@ -62,7 +62,7 @@ static cell AMX_NATIVE_CALL TFC_ClearModel(AMX *amx, cell *params) {
CHECK_PLAYER(iIndex) CHECK_PLAYER(iIndex)
edict_t* pPlayer = INDEXENT(iIndex); edict_t* pPlayer = MF_GetPlayerEdict(iIndex);
if (pPlayer->pvPrivateData == NULL) if (pPlayer->pvPrivateData == NULL)
{ {

View File

@ -9,7 +9,9 @@
#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.
#include <sdk_util.h> // FNullEnt, INDEXENT, 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)
{ {
@ -44,6 +46,8 @@ template <typename T>inline void set_pdata(edict_t *pEntity, int offset, T value
} }
extern globalvars_t *gpGlobals;
class HLTypeConversion class HLTypeConversion
{ {
public: public:
@ -96,18 +100,35 @@ 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;
} }
edict_t* id_to_edict(int index) edict_t* id_to_edict(int index)
{ {
return static_cast<edict_t*>(m_FirstEdict + index); if (index < 0 || index >= gpGlobals->maxEntities)
{
return nullptr;
}
if (!index)
{
return m_FirstEdict;
}
auto pEdict = static_cast<edict_t*>(m_FirstEdict + index);
if (pEdict && (pEdict->free || (index > gpGlobals->maxClients && !pEdict->pvPrivateData)))
{
return nullptr;
}
return pEdict;
} }
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;
} }
@ -128,19 +149,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;