From bc8d02c99863f7dc315e6b04d204aafc84ebe103 Mon Sep 17 00:00:00 2001 From: F1F88 <0xf1f88@gmail.com> Date: Sun, 9 Nov 2025 01:09:57 +0800 Subject: [PATCH] Add format specifier "%E" (#2099) (#2330) * Add format specifier "%E" (#2099) * style: Remove extra blank lines --- core/logic/sprintf.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index de0dd87f..d68df7df 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -1226,6 +1227,22 @@ reswitch: arg++; break; } + case 'E': + { + CHECK_ARGS(0); + cell_t *value; + pCtx->LocalToPhysAddr(params[arg], &value); + + CBaseEntity *entity = gamehelpers->ReferenceToEntity(*value); + if (!entity) + return pCtx->ThrowNativeError("Entity index %d is invalid (arg %d)", *value, arg); + + const char *classname = gamehelpers->GetEntityClassname(entity); + if (!AddString(&buf_p, llen, classname, width, prec, flags)) + return pCtx->ThrowNativeError("Escaped string would be truncated (arg %d)", arg); + arg++; + break; + } case 's': { CHECK_ARGS(0);