From 1a6f4e08b24adb5cc784a2f8ef058006ff273c4c Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Wed, 19 Jul 2006 04:23:00 +0000 Subject: [PATCH] Added request am41585 (Orangutanz) --- dlls/fakemeta/glb.cpp | 10 ++++++++++ dlls/fakemeta/pev.cpp | 16 ++++++++++++++++ plugins/include/fakemeta.inc | 21 +++++++++++++++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/dlls/fakemeta/glb.cpp b/dlls/fakemeta/glb.cpp index f5fa9044..9527b63f 100644 --- a/dlls/fakemeta/glb.cpp +++ b/dlls/fakemeta/glb.cpp @@ -152,6 +152,16 @@ static cell AMX_NATIVE_CALL amx_glb(AMX *amx, cell *params) } MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return type"); } + else if (paramnum == 3) + { + cell size = *(MF_GetAmxAddr(amx, params[4])); + if (Valtype == Ret_PChar) + { + cell *str = MF_GetAmxAddr(amx, params[2]); + return MF_SetAmxString(amx, params[3], STRING((int)*str), size); + } + MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return type"); + } //if we got here, something happened MF_LogError(amx, AMX_ERR_NATIVE, "Unknown global index or return combination %d", iSwitch); diff --git a/dlls/fakemeta/pev.cpp b/dlls/fakemeta/pev.cpp index 1197dd0a..44ad4807 100755 --- a/dlls/fakemeta/pev.cpp +++ b/dlls/fakemeta/pev.cpp @@ -243,6 +243,8 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params) return rets.i; } else if (ValType == Ret_Float) { return (cell)rets.f; + } else if (ValType == Ret_String) { + return (cell)rets.s; } else { MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return type"); return 0; @@ -304,6 +306,20 @@ static cell AMX_NATIVE_CALL amx_pev(AMX *amx,cell *params) return MF_SetAmxString(amx, params[3], temp, size); } + MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return type"); + } else if (count == 3) { + cell size = *(MF_GetAmxAddr(amx, params[5])); + if (ValType == Ret_String) + { + const char *str = STRING(rets.s); + cell *addr = MF_GetAmxAddr(amx, params[3]); + *addr = (cell)rets.s; + if (!str) + str = ""; + int num = MF_SetAmxString(amx, params[4], str, size); + return num; + } + MF_LogError(amx, AMX_ERR_NATIVE, "Invalid return type"); } diff --git a/plugins/include/fakemeta.inc b/plugins/include/fakemeta.inc index 1b0dcf69..fa4788b8 100755 --- a/plugins/include/fakemeta.inc +++ b/plugins/include/fakemeta.inc @@ -21,7 +21,16 @@ #pragma library fakemeta #endif -/* Returns entvar data from an entity Use the pev_* enum to specify which form of data you want returned. */ +/* Returns entvar data from an entity Use the pev_* enum to specify which form of data you want returned. + * + * If retrieving strings, you may optionally get a pointer into the global string table. Depending on + * your situation, there are two ways to do this. + * 1: This simply gets the pointer. + * new ptr = pev(entid, pev_classname) + * 2: The pointer will be stored in ptr AND the actual string is retrieved. + * new ptr, classname[32] + * pev(entid, pev_classname, ptr, classname, 31) + */ native pev(_index,_value,{Float,Sql,Result,_}:...); /* Sets entvar data for an entity. Use the pev_* enum */ @@ -32,7 +41,15 @@ native set_pev(_index,_value,{Float,Sql,Result,_}:...); */ native pev_valid(entindex); -/* Returns any global variable inside globalvars_t structure. Use the glb_* enum. */ +/* Returns any global variable inside globalvars_t structure. Use the glb_* enum. + * + * When returning data from glb_pStringBase (the global string table), you may give a pointer into that table + * in order to get different strings. + * Example: + * new model[128] + * new ptr = pev(id, pev_viewmodel) + * global_get(glb_pStringBase, ptr, model, 127) + */ native global_get(_value, {Float,Sql,Result,_}:...); /* Returns an integer from private data. _linuxdiff is added into the _Offset if it's used on a linux server. */