From 6670b93cc6c1225dcabcb1e6f4038383635c0f1b Mon Sep 17 00:00:00 2001 From: fakuivan Date: Thu, 30 Mar 2023 01:06:36 -0300 Subject: [PATCH] keyvalues: adjust KvSavePosition return value to implementation (#757) The current ``KvSavePosition`` definition does not reflect the behaviour seen in [core/smn_keyvalues.cpp#L973-L981](https://github.com/alliedmodders/sourcemod/blob/404e96ad456531e9029f3b02b243a5284efd9691/core/smn_keyvalues.cpp#L973-L981). This can cause problems if some procedure on sp expects ``KvSavePosition`` to always add one node to the stack, no matter if there is no higher node. Co-authored-by: peace-maker --- plugins/include/keyvalues.inc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/include/keyvalues.inc b/plugins/include/keyvalues.inc index 7e38ad10..3906d45d 100644 --- a/plugins/include/keyvalues.inc +++ b/plugins/include/keyvalues.inc @@ -241,7 +241,8 @@ methodmap KeyValues < Handle // have the previous key saved for backwards traversal. // // @param kv KeyValues Handle. - public native void SavePosition(); + // @return True on success, false if there is no higher node. + public native bool SavePosition(); // Jumps back to the previous position. Returns false if there are no // previous positions (i.e., at the root node). This should be called @@ -523,9 +524,10 @@ native bool KvGotoNextKey(Handle kv, bool keyOnly=true); * have the previous key saved for backwards traversal. * * @param kv KeyValues Handle. + * @return True on success, false if there is no higher node. * @error Invalid Handle. */ -native void KvSavePosition(Handle kv); +native bool KvSavePosition(Handle kv); /** * Removes the given key from the current position.