Added FM_KeyValue and get_kv/set_kv natives.

Removed pev natives.

Probably fixed something in DLLFunc_ClientUserInfoChanged.
This commit is contained in:
Johnny Bergström 2005-03-25 09:30:45 +00:00
parent 560f50eda7
commit 81f4a505c1
7 changed files with 141 additions and 23 deletions

View File

@ -212,6 +212,7 @@ static cell AMX_NATIVE_CALL dllfunc(AMX *amx,cell *params)
iparam1 = gpMetaUtilFuncs->pfnCallGameEntity(PLID,STRING(ALLOC_STRING(temp)),VARS(INDEXENT2(index)));
return iparam1;
case DLLFunc_ClientUserInfoChanged: // void ) (edict_t *pEntity, char *infobuffer)
cRet = MF_GetAmxAddr(amx,params[1]);
index = cRet[0];
CHECK_ENTITY(index);
gpGamedllFuncs->dllapi_table->pfnClientUserInfoChanged(INDEXENT2(index),(*g_engfuncs.pfnGetInfoKeyBuffer)(INDEXENT2(index)));

View File

@ -167,9 +167,21 @@
Filter="">
<File
RelativePath=".\pev.cpp">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCLCompilerTool"/>
</FileConfiguration>
</File>
<File
RelativePath=".\pev.h">
<FileConfiguration
Name="Debug|Win32"
ExcludedFromBuild="TRUE">
<Tool
Name="VCCustomBuildTool"/>
</FileConfiguration>
</File>
</Filter>
<Filter
@ -185,6 +197,10 @@
RelativePath=".\forwardmacros.h">
</File>
</Filter>
<Filter
Name="hlsdk"
Filter="">
</Filter>
</Files>
<Globals>
</Globals>

View File

@ -6,7 +6,7 @@ void OnAmxxAttach()
{
MF_AddNatives(engfunc_natives);
MF_AddNatives(dllfunc_natives);
MF_AddNatives(pev_natives);
//MF_AddNatives(pev_natives);
MF_AddNatives(forward_natives);
MF_AddNatives(pdata_natives);
MF_AddNatives(tr_Natives);

View File

@ -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; }
extern AMX_NATIVE_INFO engfunc_natives[];
extern AMX_NATIVE_INFO dllfunc_natives[];
extern AMX_NATIVE_INFO pev_natives[];
//extern AMX_NATIVE_INFO pev_natives[];
extern AMX_NATIVE_INFO forward_natives[];
extern AMX_NATIVE_INFO pdata_natives[];
extern AMX_NATIVE_INFO tr_Natives[];

View File

@ -1,20 +1,7 @@
#include "fakemeta_amxx.h"
TraceResult *gfm_tr;
/*enum
{
TR_AllSolid,
TR_StartSolid,
TR_InOpen,
TR_InWater,
TR_flFraction,
TR_vecEndPos,
TR_flPlaneDist,
TR_vecPlaneNormal,
TR_pHit,
TR_iHitgroup,
};*/
KeyValueData *g_fm_keyValueData;
static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
{
@ -37,7 +24,8 @@ static cell AMX_NATIVE_CALL set_tr(AMX *amx, cell *params)
}
case TR_StartSolid:
{
return gfm_tr->fStartSolid;
gfm_tr->fStartSolid = *ptr;
return 1;
break;
}
case TR_InWater:
@ -171,8 +159,93 @@ static cell AMX_NATIVE_CALL get_tr(AMX *amx, cell *params)
}
}
// native set_kv(TraceResult:tr_member, {Float,_}:...);
static cell AMX_NATIVE_CALL set_kv(AMX *amx, cell *params)
{
//if (*params / sizeof(cell) < 2)
//return 0; //TODO: Error
//cell *ptr = MF_GetAmxAddr(amx, params[2]);
//edict_t *e = 0;
switch (params[1])
{
case KV_ClassName:
{
int len;
g_fm_keyValueData->szClassName = MF_GetAmxString(amx, params[2], 0, &len);
return 1;
}
case KV_KeyName:
{
int len;
g_fm_keyValueData->szKeyName = MF_GetAmxString(amx, params[2], 0, &len);
return 1;
}
case KV_Value:
{
int len;
g_fm_keyValueData->szValue = MF_GetAmxString(amx, params[2], 0, &len);
return 1;
}
case KV_fHandled:
{
g_fm_keyValueData->fHandled = params[2];
return 1;
}
default:
{
//TODO: error
return 0;
}
}
}
static cell AMX_NATIVE_CALL get_kv(AMX *amx, cell *params)
{
int type = params[1];
cell *ptr = 0;
const char *szRet = "";
switch (type)
{
case KV_ClassName:
{
if (g_fm_keyValueData->szClassName)
szRet = g_fm_keyValueData->szClassName;
break;
}
case KV_KeyName:
{
if (g_fm_keyValueData->szKeyName)
szRet = g_fm_keyValueData->szKeyName;
break;
}
case KV_Value:
{
if (g_fm_keyValueData->szValue)
szRet = g_fm_keyValueData->szValue;
break;
}
case KV_fHandled: {
return g_fm_keyValueData->fHandled;
}
default:
{
//TODO: error
return 0;
}
}
return MF_SetAmxString(amx, params[2], szRet, params[3]);
}
AMX_NATIVE_INFO tr_Natives[] = {
{"get_tr", get_tr},
{"set_tr", set_tr},
{"get_kv", get_kv},
{"set_kv", set_kv},
{NULL, NULL},
};

View File

@ -2,7 +2,7 @@
#define _INCLUDE_TR_H
extern TraceResult *gfm_tr;
extern KeyValueData *g_fm_keyValueData; // JGHG: Yeah yeah I know this doesn't fit in here. Then again, neither does gaben.
enum
{
TR_AllSolid,
@ -17,6 +17,14 @@ enum
TR_iHitgroup,
};
enum KeyValue
{
KV_ClassName,
KV_KeyName,
KV_Value,
KV_fHandled
};
extern AMX_NATIVE_INFO tr_Natives[];
#endif //_INCLUDE_TR_H

View File

@ -111,6 +111,27 @@ void TraceLine_post(const float *v1, const float *v2, int fNoMonsters, edict_t *
RETURN_META(MRES_IGNORED);
}
/*
// Passed to pfnKeyValue
typedef struct KeyValueData_s
{
char *szClassName; // in: entity classname
char *szKeyName; // in: name of key
char *szValue; // in: value of key
int32 fHandled; // out: DLL sets to true if key-value pair was understood
} KeyValueData;
*/
void KeyValue(edict_t* entity, KeyValueData* data) {
g_fm_keyValueData = data;
FM_ENG_HANDLE(FM_KeyValue, (Engine[FM_KeyValue].at(i), ENTINDEX(entity)));
RETURN_META(mswi(lastFmRes));
}
void KeyValue_post(edict_t* entity, KeyValueData* data) {
FM_ENG_HANDLE_POST(FM_KeyValue, (Engine[FM_KeyValue].at(i), ENTINDEX(entity)));
RETURN_META(MRES_IGNORED);
}
void AlertMessage(ALERT_TYPE atype, char *szFmt, ...)
{
static char buf[2048];
@ -927,15 +948,14 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params)
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_DONE);
DLLHOOK(Blocked);
break;
/*
TODO: Expand the structure (simple: just a bunch of strings and a float.)
//TODO: Expand the structure (simple: just a bunch of strings and a float.)
//DLLFunc_KeyValue, // void ) ( edict_t *pentKeyvalue, KeyValueData *pkvd );
case FM_KeyValue:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_????, FP_DONE);
//fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_STRING, FP_STRING, FP_STRING, FP_CELL, FP_DONE);
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE);
DLLHOOK(KeyValue);
break;
*/
//DLLFunc_SetAbsBox, // void ) ( edict_t *pent );
case FM_SetAbsBox:
fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE);