diff --git a/dlls/fakemeta/dllfunc.cpp b/dlls/fakemeta/dllfunc.cpp index 59f42f8b..77e6d3a6 100755 --- a/dlls/fakemeta/dllfunc.cpp +++ b/dlls/fakemeta/dllfunc.cpp @@ -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))); diff --git a/dlls/fakemeta/fakemeta.vcproj b/dlls/fakemeta/fakemeta.vcproj index e37963c1..ec51d2cc 100755 --- a/dlls/fakemeta/fakemeta.vcproj +++ b/dlls/fakemeta/fakemeta.vcproj @@ -167,9 +167,21 @@ Filter=""> + + + + + + + + diff --git a/dlls/fakemeta/fakemeta_amxx.cpp b/dlls/fakemeta/fakemeta_amxx.cpp index 5da36ea1..a22e23cc 100755 --- a/dlls/fakemeta/fakemeta_amxx.cpp +++ b/dlls/fakemeta/fakemeta_amxx.cpp @@ -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); diff --git a/dlls/fakemeta/fakemeta_amxx.h b/dlls/fakemeta/fakemeta_amxx.h index 7a245038..36404a33 100755 --- a/dlls/fakemeta/fakemeta_amxx.h +++ b/dlls/fakemeta/fakemeta_amxx.h @@ -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[]; diff --git a/dlls/fakemeta/fm_tr.cpp b/dlls/fakemeta/fm_tr.cpp index f8fdae6d..5ca1fb3e 100755 --- a/dlls/fakemeta/fm_tr.cpp +++ b/dlls/fakemeta/fm_tr.cpp @@ -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}, }; \ No newline at end of file diff --git a/dlls/fakemeta/fm_tr.h b/dlls/fakemeta/fm_tr.h index ca504c73..7e049744 100755 --- a/dlls/fakemeta/fm_tr.h +++ b/dlls/fakemeta/fm_tr.h @@ -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 \ No newline at end of file diff --git a/dlls/fakemeta/forward.cpp b/dlls/fakemeta/forward.cpp index 350dba0b..e7bccccb 100755 --- a/dlls/fakemeta/forward.cpp +++ b/dlls/fakemeta/forward.cpp @@ -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);