mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 14:25:38 +03:00
Added NEW_DLL_FUNCTIONS to FM_* and a newdllfunc() native to call these... Although I'm not sure there is a reason to call those?
Anyway it will be needed later when client cvar query function is implemented.
This commit is contained in:
parent
e9993cce25
commit
1cdb12c4e4
@ -11,7 +11,7 @@ DEBUG_FLAGS = -g -ggdb3
|
|||||||
CPP = gcc
|
CPP = gcc
|
||||||
NAME = fakemeta_amxx
|
NAME = fakemeta_amxx
|
||||||
|
|
||||||
OBJECTS = sdk/amxxmodule.cpp dllfunc.cpp engfunc.cpp fakemeta_amxx.cpp pdata.cpp forward.cpp \
|
OBJECTS = sdk/amxxmodule.cpp dllfunc.cpp newdllfunc.cpp engfunc.cpp fakemeta_amxx.cpp pdata.cpp forward.cpp \
|
||||||
fm_tr.cpp pev.cpp
|
fm_tr.cpp pev.cpp
|
||||||
|
|
||||||
LINK =
|
LINK =
|
||||||
|
@ -89,7 +89,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
|
|||||||
iparam1 = MDLL_ClientConnect(INDEXENT2(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2)),temp3);
|
iparam1 = MDLL_ClientConnect(INDEXENT2(index),STRING(ALLOC_STRING(temp)),STRING(ALLOC_STRING(temp2)),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 1;
|
return iparam1;
|
||||||
|
|
||||||
case DLLFunc_ClientDisconnect: // void ) ( edict_t *pEntity );
|
case DLLFunc_ClientDisconnect: // void ) ( edict_t *pEntity );
|
||||||
cRet = MF_GetAmxAddr(amx,params[2]);
|
cRet = MF_GetAmxAddr(amx,params[2]);
|
||||||
|
@ -161,6 +161,12 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\engfunc.h">
|
RelativePath=".\engfunc.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\newdllfunc.cpp">
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\newdllfunc.h">
|
||||||
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter
|
<Filter
|
||||||
Name="pev"
|
Name="pev"
|
||||||
@ -168,8 +174,7 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\pev.cpp">
|
RelativePath=".\pev.cpp">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32">
|
||||||
ExcludedFromBuild="TRUE">
|
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCLCompilerTool"/>
|
Name="VCCLCompilerTool"/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
@ -177,8 +182,7 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath=".\pev.h">
|
RelativePath=".\pev.h">
|
||||||
<FileConfiguration
|
<FileConfiguration
|
||||||
Name="Debug|Win32"
|
Name="Debug|Win32">
|
||||||
ExcludedFromBuild="TRUE">
|
|
||||||
<Tool
|
<Tool
|
||||||
Name="VCCustomBuildTool"/>
|
Name="VCCustomBuildTool"/>
|
||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
|
@ -10,6 +10,7 @@ void OnAmxxAttach()
|
|||||||
MF_AddNatives(forward_natives);
|
MF_AddNatives(forward_natives);
|
||||||
MF_AddNatives(pdata_natives);
|
MF_AddNatives(pdata_natives);
|
||||||
MF_AddNatives(tr_Natives);
|
MF_AddNatives(tr_Natives);
|
||||||
|
MF_AddNatives(newdllfunc_natives);
|
||||||
}
|
}
|
||||||
int GetHullBounds(int hullnumber, float *mins, float *maxs);
|
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)
|
// 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)
|
||||||
|
@ -42,7 +42,7 @@ inline edict_t* INDEXENT2( int iEdictNum )
|
|||||||
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
|
#define CHECK_ENTITY(x) if (x != 0 && (FNullEnt(INDEXENT2(x)) || x < 0 || x > gpGlobals->maxEntities)) { MF_RaiseAmxError(amx,AMX_ERR_NATIVE); return 0; }
|
||||||
extern AMX_NATIVE_INFO engfunc_natives[];
|
extern AMX_NATIVE_INFO engfunc_natives[];
|
||||||
extern AMX_NATIVE_INFO dllfunc_natives[];
|
extern AMX_NATIVE_INFO dllfunc_natives[];
|
||||||
//extern AMX_NATIVE_INFO pev_natives[];
|
extern AMX_NATIVE_INFO newdllfunc_natives[];
|
||||||
extern AMX_NATIVE_INFO forward_natives[];
|
extern AMX_NATIVE_INFO forward_natives[];
|
||||||
extern AMX_NATIVE_INFO pdata_natives[];
|
extern AMX_NATIVE_INFO pdata_natives[];
|
||||||
extern AMX_NATIVE_INFO tr_Natives[];
|
extern AMX_NATIVE_INFO tr_Natives[];
|
||||||
@ -58,7 +58,8 @@ extern DLL_FUNCTIONS *g_pFunctionTable;
|
|||||||
extern DLL_FUNCTIONS *g_pFunctionTable_Post;
|
extern DLL_FUNCTIONS *g_pFunctionTable_Post;
|
||||||
extern enginefuncs_t *g_pengfuncsTable;
|
extern enginefuncs_t *g_pengfuncsTable;
|
||||||
extern enginefuncs_t *g_pengfuncsTable_Post;
|
extern enginefuncs_t *g_pengfuncsTable_Post;
|
||||||
|
extern NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
|
||||||
|
extern NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
|
||||||
|
|
||||||
#endif //_FAKEMETA_INCLUDE_H
|
#endif //_FAKEMETA_INCLUDE_H
|
||||||
|
|
||||||
|
@ -479,7 +479,15 @@ SIMPLE_VOID_HOOK_VOID(CreateInstancedBaselines);
|
|||||||
SIMPLE_INT_HOOK_VOID(AllowLagCompensation);
|
SIMPLE_INT_HOOK_VOID(AllowLagCompensation);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NEW_DLL_FUNCTIONS
|
||||||
|
*/
|
||||||
|
// pfnOnFreeEntPrivateData
|
||||||
|
SIMPLE_VOID_HOOK_EDICT(OnFreeEntPrivateData);
|
||||||
|
// pfnGameShutdown
|
||||||
|
SIMPLE_VOID_HOOK_VOID(GameShutdown);
|
||||||
|
// pfnShouldCollide
|
||||||
|
SIMPLE_INT_HOOK_EDICT_EDICT(ShouldCollide);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -503,15 +511,19 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
|||||||
|
|
||||||
DLL_FUNCTIONS *dlltable;
|
DLL_FUNCTIONS *dlltable;
|
||||||
|
|
||||||
|
NEW_DLL_FUNCTIONS *newdlltable;
|
||||||
|
|
||||||
if (post)
|
if (post)
|
||||||
{
|
{
|
||||||
engtable = g_pengfuncsTable_Post;
|
engtable = g_pengfuncsTable_Post;
|
||||||
dlltable = g_pFunctionTable_Post;
|
dlltable = g_pFunctionTable_Post;
|
||||||
|
newdlltable = g_pNewFunctionsTable_Post;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
engtable = g_pengfuncsTable;
|
engtable = g_pengfuncsTable;
|
||||||
dlltable = g_pFunctionTable;
|
dlltable = g_pFunctionTable;
|
||||||
|
newdlltable = g_pNewFunctionsTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (func)
|
switch (func)
|
||||||
@ -1061,6 +1073,20 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
|||||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_DONE);
|
fId = MF_RegisterSPForwardByName(amx, funcname, FP_DONE);
|
||||||
DLLHOOK(AllowLagCompensation);
|
DLLHOOK(AllowLagCompensation);
|
||||||
break;
|
break;
|
||||||
|
// NEW_DLL_FUNCTIONS:
|
||||||
|
case FM_OnFreeEntPrivateData:
|
||||||
|
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE);
|
||||||
|
NEWDLLHOOK(OnFreeEntPrivateData);
|
||||||
|
break;
|
||||||
|
// Maybe it's not possible to hook this forward? O_o
|
||||||
|
case FM_GameShutdown:
|
||||||
|
fId = MF_RegisterSPForwardByName(amx, funcname, FP_DONE);
|
||||||
|
NEWDLLHOOK(GameShutdown);
|
||||||
|
break;
|
||||||
|
case FM_ShouldCollide:
|
||||||
|
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_DONE);
|
||||||
|
NEWDLLHOOK(ShouldCollide);
|
||||||
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
// I know this does not fit with DLLFUNC(), but I dont want another native just for it.
|
// I know this does not fit with DLLFUNC(), but I dont want another native just for it.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef _INCLUDE_FORWARD_H
|
#ifndef _INCLUDE_FORWARD_H
|
||||||
#define _INCLUDE_FORWARD_H
|
#define _INCLUDE_FORWARD_H
|
||||||
|
|
||||||
#define ENGFUNC_NUM 118
|
#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 118
|
||||||
|
|
||||||
#define FMV_STRING 1
|
#define FMV_STRING 1
|
||||||
#define FMV_FLOAT 2
|
#define FMV_FLOAT 2
|
||||||
@ -150,6 +150,12 @@ enum {
|
|||||||
FM_CreateInstancedBaselines, // done
|
FM_CreateInstancedBaselines, // done
|
||||||
FM_AllowLagCompensation, // done
|
FM_AllowLagCompensation, // done
|
||||||
FM_AlertMessage,
|
FM_AlertMessage,
|
||||||
|
|
||||||
|
// NEW_DLL_FUNCTIONS
|
||||||
|
FM_OnFreeEntPrivateData,
|
||||||
|
FM_GameShutdown,
|
||||||
|
FM_ShouldCollide,
|
||||||
|
// FM_CvarValue
|
||||||
FM_LAST_DONT_USE_ME,
|
FM_LAST_DONT_USE_ME,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -742,12 +742,31 @@
|
|||||||
RETURN_META(MRES_IGNORED); \
|
RETURN_META(MRES_IGNORED); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define SIMPLE_INT_HOOK_EDICT(call) \
|
||||||
|
int call (edict_t *pent) \
|
||||||
|
{ \
|
||||||
|
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), ENTINDEX(pent))); \
|
||||||
|
RETURN_META_VALUE(mswi(lastFmRes), (int)mlCellResult); \
|
||||||
|
} \
|
||||||
|
int call##_post (edict_t *pent) \
|
||||||
|
{ \
|
||||||
|
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), ENTINDEX(pent))); \
|
||||||
|
RETURN_META_VALUE(MRES_IGNORED, (int)mlCellResult); \
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SIMPLE_INT_HOOK_EDICT_EDICT(call) \
|
||||||
|
int call (edict_t *pent,edict_t *pentb) \
|
||||||
|
{ \
|
||||||
|
FM_ENG_HANDLE(FM_##call, (Engine[FM_##call].at(i), ENTINDEX(pent), ENTINDEX(pentb))); \
|
||||||
|
RETURN_META_VALUE(mswi(lastFmRes), (int)mlCellResult); \
|
||||||
|
} \
|
||||||
|
int call##_post (edict_t *pent,edict_t *pentb) \
|
||||||
|
{ \
|
||||||
|
FM_ENG_HANDLE_POST(FM_##call, (EnginePost[FM_##call].at(i), ENTINDEX(pent), ENTINDEX(pentb))); \
|
||||||
|
RETURN_META_VALUE(MRES_IGNORED, (int)mlCellResult); \
|
||||||
|
}
|
||||||
|
|
||||||
#define ENGHOOK(pfnCall) \
|
#define ENGHOOK(pfnCall) \
|
||||||
if (post) \
|
if (post) \
|
||||||
@ -772,6 +791,17 @@
|
|||||||
if (dlltable->pfn##pfnCall == NULL) \
|
if (dlltable->pfn##pfnCall == NULL) \
|
||||||
dlltable->pfn##pfnCall = pfnCall; \
|
dlltable->pfn##pfnCall = pfnCall; \
|
||||||
}
|
}
|
||||||
|
#define NEWDLLHOOK(pfnCall) \
|
||||||
|
if (post) \
|
||||||
|
{ \
|
||||||
|
if (newdlltable->pfn##pfnCall == NULL) \
|
||||||
|
newdlltable->pfn##pfnCall = pfnCall##_post; \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
{ \
|
||||||
|
if (newdlltable->pfn##pfnCall == NULL) \
|
||||||
|
newdlltable->pfn##pfnCall = pfnCall; \
|
||||||
|
}
|
||||||
|
|
||||||
#define PREPARE_VECTOR(vector_name) \
|
#define PREPARE_VECTOR(vector_name) \
|
||||||
cell vector_name##_cell[3] = {amx_ftoc(vector_name[0]), amx_ftoc(vector_name[1]), amx_ftoc(vector_name[2])}; \
|
cell vector_name##_cell[3] = {amx_ftoc(vector_name[0]), amx_ftoc(vector_name[1]), amx_ftoc(vector_name[2])}; \
|
||||||
|
52
dlls/fakemeta/newdllfunc.cpp
Executable file
52
dlls/fakemeta/newdllfunc.cpp
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#include "newdllfunc.h"
|
||||||
|
|
||||||
|
static cell AMX_NATIVE_CALL newdllfunc(AMX *amx,cell *params)
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
int index;
|
||||||
|
int indexb;
|
||||||
|
//char *temp = "";
|
||||||
|
//char *temp2 = "";
|
||||||
|
//char *temp3 = "";
|
||||||
|
//vec3_t Vec1;
|
||||||
|
//vec3_t Vec2;
|
||||||
|
int iparam1;
|
||||||
|
//int len;
|
||||||
|
cell *cRet;
|
||||||
|
type = params[1];
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
|
||||||
|
/*// pfnGameInit
|
||||||
|
case DLLFunc_GameInit: // void) ( void );
|
||||||
|
gpGamedllFuncs->dllapi_table->pfnGameInit();
|
||||||
|
return 1;
|
||||||
|
*/
|
||||||
|
case NEWDLLFunc_OnFreeEntPrivateData: // void ) ( edict_t *pent );
|
||||||
|
cRet = MF_GetAmxAddr(amx, params[2]);
|
||||||
|
index=cRet[0];
|
||||||
|
CHECK_ENTITY(index);
|
||||||
|
gpGamedllFuncs->newapi_table->pfnOnFreeEntPrivateData(INDEXENT2(index));
|
||||||
|
return 1;
|
||||||
|
case NEWDLLFunc_GameShutdown: // void ) ( void );
|
||||||
|
gpGamedllFuncs->newapi_table->pfnGameShutdown();
|
||||||
|
return 1;
|
||||||
|
case NEWDLLFunc_ShouldCollide: // int ) ( ent1, ent2 );
|
||||||
|
cRet = MF_GetAmxAddr(amx,params[2]);
|
||||||
|
index=cRet[0];
|
||||||
|
CHECK_ENTITY(index);
|
||||||
|
cRet = MF_GetAmxAddr(amx,params[3]);
|
||||||
|
indexb=cRet[0];
|
||||||
|
CHECK_ENTITY(indexb);
|
||||||
|
iparam1 = gpGamedllFuncs->newapi_table->pfnShouldCollide(INDEXENT2(index),INDEXENT2(indexb));
|
||||||
|
return iparam1;
|
||||||
|
default:
|
||||||
|
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown newdllfunc entry %d", type);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AMX_NATIVE_INFO newdllfunc_natives[] = {
|
||||||
|
{"newdllfunc", newdllfunc},
|
||||||
|
{NULL, NULL},
|
||||||
|
};
|
13
dlls/fakemeta/newdllfunc.h
Executable file
13
dlls/fakemeta/newdllfunc.h
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef _NEWDLLFUNC_INCLUDE_H
|
||||||
|
#define _NEWDLLFUNC_INCLUDE_H
|
||||||
|
|
||||||
|
#include "fakemeta_amxx.h"
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NEWDLLFunc_OnFreeEntPrivateData, // void ) (edict_t *pEnt);
|
||||||
|
NEWDLLFunc_GameShutdown, // void ) (void);
|
||||||
|
NEWDLLFunc_ShouldCollide // int ) (edict_t *pentTouched, edict_t *pentOther);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_NEWDLLFUNC_INCLUDE_H
|
||||||
|
|
@ -38,6 +38,7 @@ native forward_return(type,{Float,Sql,Result,_}:...);
|
|||||||
|
|
||||||
native engfunc(type,{Float,Sql,Result,_}:...);
|
native engfunc(type,{Float,Sql,Result,_}:...);
|
||||||
native dllfunc(type,{Float,Sql,Result,_}:...);
|
native dllfunc(type,{Float,Sql,Result,_}:...);
|
||||||
|
native newdllfunc(type,{Float,Sql,Result,_}:...);
|
||||||
|
|
||||||
//only use this with functions that pass a Trace
|
//only use this with functions that pass a Trace
|
||||||
// get: zero extra params - return int, one extra param = byref float or vector
|
// get: zero extra params - return int, one extra param = byref float or vector
|
||||||
|
@ -154,6 +154,15 @@ enum
|
|||||||
MetaFunc_CallGameEntity, // bool (plid_t plid, const char *entStr,entvars_t *pev);
|
MetaFunc_CallGameEntity, // bool (plid_t plid, const char *entStr,entvars_t *pev);
|
||||||
DLLFunc_ClientUserInfoChanged // void (idplayer)
|
DLLFunc_ClientUserInfoChanged // void (idplayer)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Used with newdllfunc()
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
NEWDLLFunc_OnFreeEntPrivateData, // void ) (edict_t *pEnt);
|
||||||
|
NEWDLLFunc_GameShutdown, // void ) (void);
|
||||||
|
NEWDLLFunc_ShouldCollide // int ) (edict_t *pentTouched, edict_t *pentOther);
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
pev_string_start = 0,
|
pev_string_start = 0,
|
||||||
pev_classname,
|
pev_classname,
|
||||||
@ -437,6 +446,11 @@ enum {
|
|||||||
FM_CreateInstancedBaseline, // done
|
FM_CreateInstancedBaseline, // done
|
||||||
FM_AllowLagCompensation, // done
|
FM_AllowLagCompensation, // done
|
||||||
FM_AlertMessage, //done (at_type, message[])
|
FM_AlertMessage, //done (at_type, message[])
|
||||||
|
|
||||||
|
// NEW_DLL_FUNCTIONS:
|
||||||
|
FM_OnFreeEntPrivateData,
|
||||||
|
FM_GameShutdown,
|
||||||
|
FM_ShouldCollide
|
||||||
};
|
};
|
||||||
|
|
||||||
enum TraceResult
|
enum TraceResult
|
||||||
|
Loading…
Reference in New Issue
Block a user