From e078b2b54264c4aeac9ebde11427d0acb7ca9248 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Thu, 3 Sep 2026 10:42:59 +0200 Subject: [PATCH] Add `VFormat` macro for backwards compatibility SourcePawn 2 supports passing the variable arguments through to another function natively. Instead of using `VFormat` you can just call `Format(buf, sizeof(buf), fmt, ...)` directly with the ellipsis `...`. This broke plugins using VFormat. Add a macro to transparently replace `VFormat` with `Format` calls when compiling with the SourcePawn 2 compiler to keep the plugins from complaining about a missing `VFormat`. Preprocessor macros are not affected by `#pragma deprecated` so we cannot warn about this yet. --- plugins/include/string.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/include/string.inc b/plugins/include/string.inc index 4670ac31..4945f80b 100644 --- a/plugins/include/string.inc +++ b/plugins/include/string.inc @@ -165,7 +165,12 @@ native int Format(char[] buffer, int maxlength, const char[] format, any ...); */ native int FormatEx(char[] buffer, int maxlength, const char[] format, any ...); -#if !defined __sourcepawn2 +#if defined __sourcepawn2 + +// #pragma deprecated VFormat got replaced by spreading the variable arguments in SourcePawn 2: Format(buffer, sizeof(buffer), format, ...) +#define VFormat(%1,%2,%3,%4) Format(%1, %2, %3, ...) + +#else /** * Formats a string according to the SourceMod format rules (see documentation). * @note This is the same as Format(), except it grabs parameters from a @@ -182,7 +187,7 @@ native int FormatEx(char[] buffer, int maxlength, const char[] format, any ...); * @error Invalid argument index. */ native int VFormat(char[] buffer, int maxlength, const char[] format, int varpos); -#endif +#endif /** * Converts a string to an integer.