From 22d3c69de3e81d6d1e30fc2b8858a297ea94e9ae Mon Sep 17 00:00:00 2001 From: F1F88 <0xF1F88@gmail.com> Date: Mon, 2 Jun 2025 11:14:34 +0800 Subject: [PATCH 1/2] Add format specifier "%E" (#2099) --- core/logic/sprintf.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index 6263ddfb70..e409377c5f 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -1199,6 +1200,23 @@ size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext 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); From 8159c9abbaf4c561d6f0384f0ad2b235cf77b17c Mon Sep 17 00:00:00 2001 From: F1F88 <0xF1F88@gmail.com> Date: Mon, 2 Jun 2025 14:53:17 +0800 Subject: [PATCH 2/2] style: Remove extra blank lines --- core/logic/sprintf.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index e409377c5f..ddd1715cc2 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -1215,7 +1215,6 @@ size_t atcprintf(char *buffer, size_t maxlen, const char *format, IPluginContext return pCtx->ThrowNativeError("Escaped string would be truncated (arg %d)", arg); arg++; break; - } case 's': {