From 2c782ef84273aad8c87d99381866867000d3ca38 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 4 Jun 2026 17:47:02 -0700 Subject: [PATCH] Fix compatibility issue in Call_PushStringEx. When we changed the C++ API, we forgot to add a compatibility workaround for functions.inc which had matching constants. Fix that now in smn_functions.cpp. Bug: issue #2481 --- core/logic/smn_functions.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/logic/smn_functions.cpp b/core/logic/smn_functions.cpp index 5036a918..f74db93b 100644 --- a/core/logic/smn_functions.cpp +++ b/core/logic/smn_functions.cpp @@ -512,6 +512,8 @@ static cell_t sm_CallPushString(IPluginContext *pContext, const cell_t *params) return 1; } +static_assert(SM_PARAM_COPYBACK == (1 << 0), "SM_PARAM_COPYBACK should match functions.inc"); + static cell_t sm_CallPushStringEx(IPluginContext *pContext, const cell_t *params) { char *value; @@ -524,7 +526,17 @@ static cell_t sm_CallPushStringEx(IPluginContext *pContext, const cell_t *params if (int err = pContext->LocalToString(params[1], &value); err != SP_ERROR_NONE) return pContext->ThrowNativeErrorEx(err, nullptr); - sArgs.PushString(value, params[2], params[3] | params[4]); + int sz_flags = params[3]; + int cp_flags = params[4]; + int translated_flags = cp_flags; + if (sz_flags & (1 << 0)) + translated_flags |= SM_PARAM_STRING_UTF8; + if (sz_flags & (1 << 1)) + translated_flags |= SM_PARAM_STRING_COPY; + if (sz_flags & (1 << 2)) + translated_flags |= SM_PARAM_STRING_BINARY; + + sArgs.PushString(value, params[2], translated_flags); if (sArgs.error) return pContext->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, nullptr);