From ac1e3a90015a57dfe8050a0bb91b13a30ed5ab20 Mon Sep 17 00:00:00 2001 From: Scott Ehlert Date: Tue, 23 May 2006 03:26:26 +0000 Subject: [PATCH] Added ClientPrintf engine function (request at30137) --- dlls/fakemeta/engfunc.cpp | 10 ++++++++++ dlls/fakemeta/engfunc.h | 3 ++- dlls/fakemeta/fakemeta_amxx.cpp | 1 + dlls/fakemeta/forward.cpp | 16 ++++++++++++++++ dlls/fakemeta/forward.h | 3 ++- plugins/include/fakemeta_const.inc | 6 ++++-- plugins/include/fakemeta_stocks.inc | 2 ++ 7 files changed, 37 insertions(+), 4 deletions(-) diff --git a/dlls/fakemeta/engfunc.cpp b/dlls/fakemeta/engfunc.cpp index 835c1ddb..5e47ebd8 100755 --- a/dlls/fakemeta/engfunc.cpp +++ b/dlls/fakemeta/engfunc.cpp @@ -1061,6 +1061,16 @@ static cell AMX_NATIVE_CALL engfunc(AMX *amx, cell *params) (*g_engfuncs.pfnAlertMessage)(static_cast(iparam1), temp); return 1; + case EngFunc_ClientPrintf: // void ) (edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg); + cRet = MF_GetAmxAddr(amx, params[2]); + index = cRet[0]; + CHECK_ENTITY(index); + + cRet = MF_GetAmxAddr(amx, params[3]); + iparam1 = cRet[0]; + temp = MF_GetAmxString(amx,params[4], 0, &len); + + (*g_engfuncs.pfnClientPrintf)(INDEXENT2(index), static_cast(iparam1), temp); default: MF_LogError(amx, AMX_ERR_NATIVE, "Unknown engfunc type %d", type); return 0; diff --git a/dlls/fakemeta/engfunc.h b/dlls/fakemeta/engfunc.h index 96393142..4038d222 100755 --- a/dlls/fakemeta/engfunc.h +++ b/dlls/fakemeta/engfunc.h @@ -80,7 +80,8 @@ enum { EngFunc_SetClientKeyValue, // void ) (int clientIndex, char *infobuffer, char *key, char *value); EngFunc_CreateInstancedBaseline, // int ) (int classname, struct entity_state_s *baseline); EngFunc_GetInfoKeyBuffer, // char*) (edict_t *e); - EngFunc_AlertMessage // void ) (ALERT_TYPE atype, char *szFmt, ...); + EngFunc_AlertMessage, // void ) (ALERT_TYPE atype, char *szFmt, ...); + EngFunc_ClientPrintf // void ) (edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg); }; #endif //_ENGFUNC_INCLUDE_H diff --git a/dlls/fakemeta/fakemeta_amxx.cpp b/dlls/fakemeta/fakemeta_amxx.cpp index 8fc3d210..ddebec73 100755 --- a/dlls/fakemeta/fakemeta_amxx.cpp +++ b/dlls/fakemeta/fakemeta_amxx.cpp @@ -142,6 +142,7 @@ void FMH_ServerDeactivate() RESETE(AlertMessage); RESETE(CreateInstancedBaseline); RESETE(GetInfoKeyBuffer); + RESETE(ClientPrintf); RESETD(Spawn); RESETD(Think); diff --git a/dlls/fakemeta/forward.cpp b/dlls/fakemeta/forward.cpp index 070df9f2..6c6f2b52 100755 --- a/dlls/fakemeta/forward.cpp +++ b/dlls/fakemeta/forward.cpp @@ -638,6 +638,18 @@ char *GetInfoKeyBuffer_post(edict_t *e) RETURN_META_VALUE(MRES_IGNORED, reinterpret_cast(mlCellResult)); } +void ClientPrintf(edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg) +{ + FM_ENG_HANDLE(FM_ClientPrintf, (Engine[FM_ClientPrintf].at(i), (cell)ENTINDEX(pEdict), (cell)ptype, szMsg)); + RETURN_META(mswi(lastFmRes)); +} + +void ClientPrintf_post(edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg) +{ + FM_ENG_HANDLE(FM_ClientPrintf, (Engine[FM_ClientPrintf].at(i), (cell)ENTINDEX(pEdict), (cell)ptype, szMsg)); + RETURN_META(MRES_IGNORED); +} + /* * Beginning of Engine->Game DLL hooks */ @@ -1455,6 +1467,10 @@ static cell AMX_NATIVE_CALL register_forward(AMX *amx, cell *params) fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_DONE); ENGHOOK(GetInfoKeyBuffer); break; + case FM_ClientPrintf: + fId = MF_RegisterSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_STRING, FP_DONE); + ENGHOOK(ClientPrintf); + break; #if 0 // I know this does not fit with DLLFUNC(), but I dont want another native just for it. diff --git a/dlls/fakemeta/forward.h b/dlls/fakemeta/forward.h index b50a3425..bb722a4b 100755 --- a/dlls/fakemeta/forward.h +++ b/dlls/fakemeta/forward.h @@ -1,7 +1,7 @@ #ifndef _INCLUDE_FORWARD_H #define _INCLUDE_FORWARD_H -#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 130 +#define ENGFUNC_NUM FM_LAST_DONT_USE_ME // 131 #define FMV_STRING 1 #define FMV_FLOAT 2 @@ -163,6 +163,7 @@ enum { FM_CreateInstancedBaseline, FM_CreateBaseline, FM_GetInfoKeyBuffer, + FM_ClientPrintf, FM_LAST_DONT_USE_ME }; diff --git a/plugins/include/fakemeta_const.inc b/plugins/include/fakemeta_const.inc index 81ad3d9c..f1705f06 100755 --- a/plugins/include/fakemeta_const.inc +++ b/plugins/include/fakemeta_const.inc @@ -117,7 +117,8 @@ enum { // Returns pointer to info buffer that can be used with the infobuffer param of InfoKeyValue, SetKeyValue, and SetClientKeyValue EngFunc_GetInfoKeyBuffer, // char*) (edict_t *e); - EngFunc_AlertMessage // void ) (ALERT_TYPE atype, char *szFmt, ...); + EngFunc_AlertMessage, // void ) (ALERT_TYPE atype, char *szFmt, ...); + EngFunc_ClientPrintf // void ) (edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg); }; /* Used with dllfunc() @@ -534,7 +535,8 @@ enum { FM_CmdEnd, FM_CreateInstBaseline, FM_CreateBaseline, - FM_GetInfoKeyBuffer + FM_GetInfoKeyBuffer, + FM_ClientPrintf }; enum TraceResult diff --git a/plugins/include/fakemeta_stocks.inc b/plugins/include/fakemeta_stocks.inc index 48e96910..84c81916 100755 --- a/plugins/include/fakemeta_stocks.inc +++ b/plugins/include/fakemeta_stocks.inc @@ -190,6 +190,8 @@ stock EF_CreateInstBaseline(CLASSNAME, baseline) // of EF_InfoKeyValue, EF_SetKeyValue, and EF_SetClientKeyValue stock EF_GetInfoKeyBuffer(const ENTITY) return engfunc(EngFunc_GetInfoKeyBuffer, ENTITY) +stock EF_ClientPrintf(const ENTITY, const printType, const MESSAGE[]) + return engfunc(EngFunc_ClientPrintf, ENTITY, printType, MESSAGE) // DLLFuncs stock DF_GameInit()