From b609c4eb86355df8118b27b13b1a9267feaf060b Mon Sep 17 00:00:00 2001 From: Borja Ferrer Date: Sat, 29 Sep 2007 22:26:36 +0000 Subject: [PATCH] added amb964, DispatchKeyValue natives --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401510 --- extensions/sdktools/vnatives.cpp | 84 +++++++++++++++++ gamedata/sdktools.games.txt | 120 +++++++++++++++++++++++++ plugins/include/sdktools_functions.inc | 33 +++++++ 3 files changed, 237 insertions(+) diff --git a/extensions/sdktools/vnatives.cpp b/extensions/sdktools/vnatives.cpp index ef27fb56..09d56161 100644 --- a/extensions/sdktools/vnatives.cpp +++ b/extensions/sdktools/vnatives.cpp @@ -699,6 +699,87 @@ static cell_t DispatchSpawn(IPluginContext *pContext, const cell_t *params) return (ret == -1) ? 0 : 1; } +static cell_t DispatchKeyValue(IPluginContext *pContext, const cell_t *params) +{ + static ValveCall *pCall = NULL; + if (!pCall) + { + ValvePassInfo pass[3]; + InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[1], Valve_String, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); + if (!CreateBaseCall("DispatchKeyValue", ValveCall_Entity, &pass[2], pass, 2, &pCall)) + { + return pContext->ThrowNativeError("\"DispatchKeyValue\" not supported by this mod"); + } else if (!pCall) { + return pContext->ThrowNativeError("\"DispatchKeyValue\" wrapper failed to initialized"); + } + } + + bool ret; + START_CALL(); + DECODE_VALVE_PARAM(1, thisinfo, 0); + DECODE_VALVE_PARAM(2, vparams, 0); + DECODE_VALVE_PARAM(3, vparams, 1); + FINISH_CALL_SIMPLE(&ret); + + return (ret) ? 1 : 0; +} + +static cell_t DispatchKeyValueFloat(IPluginContext *pContext, const cell_t *params) +{ + static ValveCall *pCall = NULL; + if (!pCall) + { + ValvePassInfo pass[3]; + InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[1], Valve_Float, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); + if (!CreateBaseCall("DispatchKeyValueFloat", ValveCall_Entity, &pass[2], pass, 2, &pCall)) + { + return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" not supported by this mod"); + } else if (!pCall) { + return pContext->ThrowNativeError("\"DispatchKeyValueFloat\" wrapper failed to initialized"); + } + } + + bool ret; + START_CALL(); + DECODE_VALVE_PARAM(1, thisinfo, 0); + DECODE_VALVE_PARAM(2, vparams, 0); + DECODE_VALVE_PARAM(3, vparams, 1); + FINISH_CALL_SIMPLE(&ret); + + return (ret) ? 1 : 0; +} + +static cell_t DispatchKeyValueVector(IPluginContext *pContext, const cell_t *params) +{ + static ValveCall *pCall = NULL; + if (!pCall) + { + ValvePassInfo pass[3]; + InitPass(pass[0], Valve_String, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[1], Valve_Vector, PassType_Basic, PASSFLAG_BYVAL); + InitPass(pass[2], Valve_Bool, PassType_Basic, PASSFLAG_BYVAL); + if (!CreateBaseCall("DispatchKeyValueVector", ValveCall_Entity, &pass[2], pass, 2, &pCall)) + { + return pContext->ThrowNativeError("\"DispatchKeyValueVector\" not supported by this mod"); + } else if (!pCall) { + return pContext->ThrowNativeError("\"DispatchKeyValueVector\" wrapper failed to initialized"); + } + } + + bool ret; + START_CALL(); + DECODE_VALVE_PARAM(1, thisinfo, 0); + DECODE_VALVE_PARAM(2, vparams, 0); + DECODE_VALVE_PARAM(3, vparams, 1); + FINISH_CALL_SIMPLE(&ret); + + return (ret) ? 1 : 0; +} + sp_nativeinfo_t g_Natives[] = { {"ExtinguishPlayer", ExtinguishEntity}, @@ -720,5 +801,8 @@ sp_nativeinfo_t g_Natives[] = {"IsPlayerAlive", IsPlayerAlive}, {"CreateEntityByName", CreateEntityByName}, {"DispatchSpawn", DispatchSpawn}, + {"DispatchKeyValue", DispatchKeyValue}, + {"DispatchKeyValueFloat", DispatchKeyValueFloat}, + {"DispatchKeyValueVector", DispatchKeyValueVector}, {NULL, NULL}, }; diff --git a/gamedata/sdktools.games.txt b/gamedata/sdktools.games.txt index 3f5ee9d1..c7ac8cc3 100644 --- a/gamedata/sdktools.games.txt +++ b/gamedata/sdktools.games.txt @@ -304,6 +304,21 @@ "windows" "35" "linux" "36" } + "DispatchKeyValue" + { + "windows" "29" + "linux" "30" + } + "DispatchKeyValueFloat" + { + "windows" "30" + "linux" "31" + } + "DispatchKeyValueVector" + { + "windows" "31" + "linux" "32" + } } } @@ -362,6 +377,21 @@ "windows" "35" "linux" "36" } + "DispatchKeyValue" + { + "windows" "29" + "linux" "30" + } + "DispatchKeyValueFloat" + { + "windows" "30" + "linux" "31" + } + "DispatchKeyValueVector" + { + "windows" "31" + "linux" "32" + } } } @@ -420,6 +450,21 @@ "windows" "35" "linux" "36" } + "DispatchKeyValue" + { + "windows" "29" + "linux" "30" + } + "DispatchKeyValueFloat" + { + "windows" "30" + "linux" "31" + } + "DispatchKeyValueVector" + { + "windows" "31" + "linux" "32" + } } } @@ -474,6 +519,21 @@ "windows" "116" "linux" "117" } + "DispatchKeyValue" + { + "windows" "33" + "linux" "34" + } + "DispatchKeyValueFloat" + { + "windows" "34" + "linux" "35" + } + "DispatchKeyValueVector" + { + "windows" "35" + "linux" "36" + } /* Temp Entities */ "TE_GetServerClass" @@ -541,6 +601,21 @@ "windows" "35" "linux" "36" } + "DispatchKeyValue" + { + "windows" "29" + "linux" "30" + } + "DispatchKeyValueFloat" + { + "windows" "30" + "linux" "31" + } + "DispatchKeyValueVector" + { + "windows" "31" + "linux" "32" + } /* Offset into CBaseTempEntity constructor. * On Windows Dsytopia is heavily inlined; we use the function @@ -618,6 +693,21 @@ { "linux" "28" } + "DispatchKeyValue" + { + "windows" "28" + "linux" "29" + } + "DispatchKeyValueFloat" + { + "windows" "29" + "linux" "30" + } + "DispatchKeyValueVector" + { + "windows" "30" + "linux" "31" + } } } @@ -697,6 +787,21 @@ "windows" "35" "linux" "36" } + "DispatchKeyValue" + { + "windows" "29" + "linux" "30" + } + "DispatchKeyValueFloat" + { + "windows" "30" + "linux" "31" + } + "DispatchKeyValueVector" + { + "windows" "31" + "linux" "32" + } /* Temp Entities */ "s_pTempEntities" @@ -752,6 +857,21 @@ "windows" "106" "linux" "107" } + "DispatchKeyValue" + { + "windows" "28" + "linux" "29" + } + "DispatchKeyValueFloat" + { + "windows" "29" + "linux" "30" + } + "DispatchKeyValueVector" + { + "windows" "30" + "linux" "31" + } /* Temp Entities */ "s_pTempEntities" diff --git a/plugins/include/sdktools_functions.inc b/plugins/include/sdktools_functions.inc index dc2a3a66..03d637e5 100644 --- a/plugins/include/sdktools_functions.inc +++ b/plugins/include/sdktools_functions.inc @@ -172,6 +172,39 @@ native CreateEntityByName(const String:classname[], ForceEdictIndex=-1); */ native bool:DispatchSpawn(entity); +/** + * Dispatches a KeyValue into given entity using a string value. + * + * @param entity Destination entity index. + * @param keyName Name of the key. + * @param value String value. + * @return True on success, false otherwise. + * @error Invalid entity index, or no mod support. + */ +native bool:DispatchKeyValue(entity, const String:keyName[], const String:value[]); + +/** + * Dispatches a KeyValue into given entity using a floating point value. + * + * @param entity Destination entity index. + * @param keyName Name of the key. + * @param value Floating point value. + * @return True on success, false otherwise. + * @error Invalid entity index, or no mod support. + */ +native bool:DispatchKeyValueFloat(entity, const String:keyName[], Float:value); + +/** + * Dispatches a KeyValue into given entity using a vector value. + * + * @param entity Destination entity index. + * @param keyName Name of the key. + * @param vec Vector value. + * @return True on success, false otherwise. + * @error Invalid entity index, or no mod support. + */ +native bool:DispatchKeyValueVector(entity, const String:keyName[], const Float:vector[3]); + /** * @deprecated */