From e69edf05ebe2b2e6dab9c61d0574c19d83c16879 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 7 May 2007 00:02:33 +0000 Subject: [PATCH] added amb260 --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40756 --- core/smn_keyvalues.cpp | 20 ++++++++++++++++++++ plugins/include/keyvalues.inc | 11 +++++++++++ 2 files changed, 31 insertions(+) diff --git a/core/smn_keyvalues.cpp b/core/smn_keyvalues.cpp index 622c4506..71e9d505 100644 --- a/core/smn_keyvalues.cpp +++ b/core/smn_keyvalues.cpp @@ -637,6 +637,25 @@ static cell_t smn_KvSetEscapeSequences(IPluginContext *pCtx, const cell_t *param return 1; } +static cell_t smn_KvNodesInStack(IPluginContext *pCtx, const cell_t *params) +{ + Handle_t hndl = static_cast(params[1]); + HandleError herr; + HandleSecurity sec; + KeyValueStack *pStk; + + sec.pOwner = NULL; + sec.pIdentity = g_pCoreIdent; + + if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk)) + != HandleError_None) + { + return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr); + } + + return pStk->pCurRoot.size(); +} + static cell_t smn_KvDeleteThis(IPluginContext *pContext, const cell_t *params) { Handle_t hndl = static_cast(params[1]); @@ -731,5 +750,6 @@ REGISTER_NATIVES(keyvaluenatives) {"KvSetEscapeSequences", smn_KvSetEscapeSequences}, {"KvDeleteThis", smn_KvDeleteThis}, {"KvDeleteKey", smn_KvDeleteKey}, + {"KvNodesInStack", smn_KvNodesInStack}, {NULL, NULL} }; diff --git a/plugins/include/keyvalues.inc b/plugins/include/keyvalues.inc index 9082bfec..bb373d67 100644 --- a/plugins/include/keyvalues.inc +++ b/plugins/include/keyvalues.inc @@ -298,3 +298,14 @@ native bool:FileToKeyValues(Handle:kv, const String:file[]); * @error Invalid Handle. */ native KvSetEscapeSequences(Handle:kv, bool:useEscapes); + +/** + * Returns the position in the jump stack; I.e. the number of calls + * required for KvGoBack to return to the root node. If at the root node, + * 0 is returned. + * + * @param kv KeyValues Handle. + * @return Number of non-root nodes in the jump stack. + * @error Invalid Handle. + */ +native KvNodesInStack(Handle:kv); \ No newline at end of file