mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-25 06:15:37 +03:00
Added request at29487
1) New hookable Engine func: GetInfoKeyBuffer 2) New GameDLL func that can be called via engfunc: GetInfoKeyBuffer 3) New native: copy_infokey_buffer that copies data out of the specified info key buffer 4) EngFunc_InfoKeyValue, EngFunc_SetKeyValue, and EngFunc_SetClientKeyValue have been reworked so that they expect pointers to an info key buffer in order to work properly o_O 5) Added some error messages to get_tr
This commit is contained in:
parent
25d4b6aea3
commit
de1f1eef8d
@ -15,7 +15,7 @@ BIN_SUFFIX_32 = amxx_i386.so
|
||||
BIN_SUFFIX_64 = amxx_amd64.so
|
||||
|
||||
OBJECTS = sdk/amxxmodule.cpp dllfunc.cpp engfunc.cpp fakemeta_amxx.cpp pdata.cpp forward.cpp \
|
||||
fm_tr.cpp pev.cpp glb.cpp fm_tr2.cpp
|
||||
fm_tr.cpp pev.cpp glb.cpp fm_tr2.cpp misc.cpp
|
||||
|
||||
LINK =
|
||||
|
||||
|
@ -997,20 +997,21 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
|
||||
(*g_engfuncs.pfnWriteAngle)(fparam1);
|
||||
return 1;
|
||||
case EngFunc_InfoKeyValue: // char* ) (char *infobuffer, char *key);
|
||||
// Modify the syntax a bit.
|
||||
// index, key
|
||||
cRet = MF_GetAmxAddr(amx,params[2]);
|
||||
index = cRet[0];
|
||||
temp = reinterpret_cast<char *>(cRet[0]);
|
||||
temp2 = MF_GetAmxString(amx,params[3],0,&len);
|
||||
|
||||
temp = (*g_engfuncs.pfnInfoKeyValue)(temp, temp2);
|
||||
|
||||
cRet = MF_GetAmxAddr(amx,params[5]);
|
||||
iparam1 = cRet[0];
|
||||
CHECK_ENTITY(index);
|
||||
temp2 = MF_GetAmxString(amx,params[3],0,&len);
|
||||
temp = (*g_engfuncs.pfnInfoKeyValue)((*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)),temp2);
|
||||
MF_SetAmxString(amx,params[4],temp,iparam1);
|
||||
|
||||
return 1;
|
||||
|
||||
case EngFunc_SetKeyValue: // void ) (char *infobuffer, char *key, char *value);
|
||||
temp3 = MF_GetAmxString(amx, params[2], 0, &len);
|
||||
cRet = MF_GetAmxAddr(amx, params[2]);
|
||||
temp3 = reinterpret_cast<char *>(cRet[0]);
|
||||
temp = MF_GetAmxString(amx, params[3], 1, &len);
|
||||
temp2 = MF_GetAmxString(amx, params[4], 2, &len);
|
||||
(*g_engfuncs.pfnSetKeyValue)(temp3, temp, temp2);
|
||||
@ -1020,9 +1021,13 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
|
||||
cRet = MF_GetAmxAddr(amx, params[2]);
|
||||
index = cRet[0];
|
||||
CHECK_ENTITY(index);
|
||||
temp = MF_GetAmxString(amx, params[3], 0, &len);
|
||||
temp2 = MF_GetAmxString(amx, params[4], 1, &len);
|
||||
(*g_engfuncs.pfnSetClientKeyValue)(index,(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)),temp,temp2);
|
||||
|
||||
cRet = MF_GetAmxAddr(amx, params[3]);
|
||||
temp = reinterpret_cast<char *>(cRet[0]);
|
||||
|
||||
temp2 = MF_GetAmxString(amx, params[3], 0, &len);
|
||||
temp3 = MF_GetAmxString(amx, params[4], 1, &len);
|
||||
(*g_engfuncs.pfnSetClientKeyValue)(index, temp, temp2, temp3);
|
||||
return 1;
|
||||
case EngFunc_CreateInstancedBaseline: // int ) (int classname, struct entity_state_s *baseline);
|
||||
cRet = MF_GetAmxAddr(amx, params[2]);
|
||||
@ -1038,6 +1043,17 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params)
|
||||
es = reinterpret_cast<entity_state_t *>(*cRet);
|
||||
|
||||
return (*g_engfuncs.pfnCreateInstancedBaseline)(iparam1, es);
|
||||
case EngFunc_GetInfoKeyBuffer: // char *) (edict_t *e);
|
||||
cRet = MF_GetAmxAddr(amx, params[2]);
|
||||
index = cRet[0];
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
CHECK_ENTITY(index);
|
||||
}
|
||||
|
||||
temp = (*g_engfuncs.pfnGetInfoKeyBuffer)((index == -1) ? NULL : INDEXENT2(index));
|
||||
return reinterpret_cast<cell>(temp);
|
||||
default:
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown engfunc type %d", type);
|
||||
return 0;
|
||||
|
@ -78,7 +78,8 @@ enum {
|
||||
EngFunc_InfoKeyValue, // char*) (char *infobuffer, char *key);
|
||||
EngFunc_SetKeyValue, // void ) (char *infobuffer, char *key, char *value);
|
||||
EngFunc_SetClientKeyValue, // void ) (int clientIndex, char *infobuffer, char *key, char *value);
|
||||
EngFunc_CreateInstancedBaseline // int ) (int classname, struct entity_state_s *baseline);
|
||||
EngFunc_CreateInstancedBaseline, // int ) (int classname, struct entity_state_s *baseline);
|
||||
EngFunc_GetInfoKeyBuffer // char*) (edict_t *e);
|
||||
};
|
||||
|
||||
#endif //_ENGFUNC_INCLUDE_H
|
||||
|
@ -133,6 +133,9 @@
|
||||
<File
|
||||
RelativePath=".\fm_tr2.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\misc.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\pdata.cpp">
|
||||
</File>
|
||||
|
@ -14,6 +14,7 @@ void OnAmxxAttach()
|
||||
MF_AddNatives(tr_Natives);
|
||||
MF_AddNatives(glb_natives);
|
||||
MF_AddNatives(ext2_natives);
|
||||
MF_AddNatives(misc_natives);
|
||||
g_kvd_2.szClassName = "";
|
||||
g_kvd_2.szKeyName = "";
|
||||
g_kvd_2.szValue = "";
|
||||
@ -140,6 +141,7 @@ void FMH_ServerDeactivate()
|
||||
RESETE(CVarSetString);
|
||||
RESETE(AlertMessage);
|
||||
RESETE(CreateInstancedBaseline);
|
||||
RESETE(GetInfoKeyBuffer);
|
||||
|
||||
RESETD(Spawn);
|
||||
RESETD(Think);
|
||||
|
@ -49,6 +49,7 @@ extern AMX_NATIVE_INFO pdata_natives[];
|
||||
extern AMX_NATIVE_INFO tr_Natives[];
|
||||
extern AMX_NATIVE_INFO pev_natives[];
|
||||
extern AMX_NATIVE_INFO glb_natives[];
|
||||
extern AMX_NATIVE_INFO misc_natives[];
|
||||
extern TraceResult g_tr;
|
||||
|
||||
/* Wouldnt modifying the table AFTER it's memcpy'd be ... pointless?
|
||||
|
@ -6,10 +6,12 @@ KeyValueData *g_fm_keyValueData;
|
||||
static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
|
||||
{
|
||||
int type = params[1];
|
||||
//TraceResult *tr = (TraceResult*)((void *)cPtr);
|
||||
|
||||
if (*params / sizeof(cell) < 2)
|
||||
return 0; //TODO: Error
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "No data passed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
cell *ptr = MF_GetAmxAddr(amx, params[2]);
|
||||
edict_t *e = 0;
|
||||
@ -79,7 +81,7 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
|
||||
}
|
||||
default:
|
||||
{
|
||||
//TODO: error
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown TraceResult member %d", params[2]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -153,7 +155,7 @@ static cell AMX_NATIVE_CALL get_tr(AMX *amx, cell *params)
|
||||
}
|
||||
default:
|
||||
{
|
||||
//TODO: error
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown TraceResult member %d", params[2]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ static cell AMX_NATIVE_CALL set_tr2(AMX *amx, cell *params)
|
||||
}
|
||||
default:
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown traceresult member %d", params[2]);
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown TraceResult member %d", params[2]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ static cell AMX_NATIVE_CALL get_tr2(AMX *amx, cell *params)
|
||||
}
|
||||
default:
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown traceresult member %d", params[2]);
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "Unknown TraceResult member %d", params[2]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -88,13 +88,13 @@ SIMPLE_INT_HOOK_STRING(PrecacheSound);
|
||||
|
||||
void ClientUserInfoChanged(edict_t *e, char *infobuffer)
|
||||
{
|
||||
FM_ENG_HANDLE(FM_ClientUserInfoChanged, (Engine[FM_ClientUserInfoChanged].at(i), (cell)ENTINDEX(e)));
|
||||
FM_ENG_HANDLE(FM_ClientUserInfoChanged, (Engine[FM_ClientUserInfoChanged].at(i), (cell)ENTINDEX(e), (cell)infobuffer));
|
||||
RETURN_META(mswi(lastFmRes));
|
||||
}
|
||||
|
||||
void ClientUserInfoChanged_post(edict_t *e, char *infobuffer)
|
||||
{
|
||||
FM_ENG_HANDLE_POST(FM_ClientUserInfoChanged, (EnginePost[FM_ClientUserInfoChanged].at(i), (cell)ENTINDEX(e)));
|
||||
FM_ENG_HANDLE_POST(FM_ClientUserInfoChanged, (EnginePost[FM_ClientUserInfoChanged].at(i), (cell)ENTINDEX(e), (cell)infobuffer));
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
||||
@ -625,6 +625,19 @@ int CreateInstancedBaseline_post(int classname, struct entity_state_s *baseline)
|
||||
RETURN_META_VALUE(MRES_IGNORED, (int)mlCellResult);
|
||||
}
|
||||
|
||||
char *GetInfoKeyBuffer(edict_t *e)
|
||||
{
|
||||
FM_ENG_HANDLE(FM_GetInfoKeyBuffer, (Engine[FM_GetInfoKeyBuffer].at(i), (cell)ENTINDEX(e)));
|
||||
RETURN_META_VALUE(mswi(lastFmRes), reinterpret_cast<char *>(mlCellResult));
|
||||
}
|
||||
|
||||
char *GetInfoKeyBuffer_post(edict_t *e)
|
||||
{
|
||||
origCellRet = reinterpret_cast<cell>(META_RESULT_ORIG_RET(char *));
|
||||
FM_ENG_HANDLE(FM_GetInfoKeyBuffer, (Engine[FM_GetInfoKeyBuffer].at(i), (cell)ENTINDEX(e)));
|
||||
RETURN_META_VALUE(MRES_IGNORED, reinterpret_cast<char *>(mlCellResult));
|
||||
}
|
||||
|
||||
/*
|
||||
* Beginning of Engine->Game DLL hooks
|
||||
*/
|
||||
@ -1165,7 +1178,6 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_ARRAY, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
|
||||
ENGHOOK(StaticDecal);
|
||||
break;
|
||||
|
||||
case FM_PrecacheGeneric:
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_STRING, FP_DONE);
|
||||
ENGHOOK(PrecacheGeneric);
|
||||
@ -1199,7 +1211,6 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_DONE);
|
||||
ENGHOOK(CheckVisibility);
|
||||
break;
|
||||
|
||||
case FM_GetCurrentPlayer:
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_DONE);
|
||||
ENGHOOK(GetCurrentPlayer);
|
||||
@ -1413,7 +1424,7 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
||||
NEWDLLHOOK(ShouldCollide);
|
||||
break;
|
||||
case FM_ClientUserInfoChanged:
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE);
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_DONE);
|
||||
DLLHOOK(ClientUserInfoChanged);
|
||||
break;
|
||||
case FM_UpdateClientData:
|
||||
@ -1440,6 +1451,10 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_ARRAY, FP_ARRAY, FP_DONE);
|
||||
DLLHOOK(CreateBaseline);
|
||||
break;
|
||||
case FM_GetInfoKeyBuffer:
|
||||
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE);
|
||||
ENGHOOK(GetInfoKeyBuffer);
|
||||
break;
|
||||
#if 0
|
||||
|
||||
// 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
|
||||
#define _INCLUDE_FORWARD_H
|
||||
|
||||
#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 129
|
||||
#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 130
|
||||
|
||||
#define FMV_STRING 1
|
||||
#define FMV_FLOAT 2
|
||||
@ -162,6 +162,7 @@ enum {
|
||||
FM_CmdEnd,
|
||||
FM_CreateInstancedBaseline,
|
||||
FM_CreateBaseline,
|
||||
FM_GetInfoKeyBuffer,
|
||||
FM_LAST_DONT_USE_ME
|
||||
};
|
||||
|
||||
|
13
dlls/fakemeta/misc.cpp
Normal file
13
dlls/fakemeta/misc.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "fakemeta_amxx.h"
|
||||
|
||||
static cell AMX_NATIVE_CALL copy_infokey_buffer(AMX *amx, cell *params)
|
||||
{
|
||||
char *infobuffer = reinterpret_cast<char *>(params[1]);
|
||||
|
||||
return MF_SetAmxString(amx, params[2], infobuffer, params[3]);
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO misc_natives[] = {
|
||||
{ "copy_infokey_buffer", copy_infokey_buffer },
|
||||
{NULL, NULL},
|
||||
};
|
@ -206,6 +206,10 @@
|
||||
RelativePath="..\fm_tr2.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\misc.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\pdata.cpp"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user