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);