From 4b3f24c1b08025c855bc68509e9e42fef87402eb Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 25 Oct 2026 02:07:46 +0000 Subject: Add a quick edict info dumper to dbg.c --- src/dbg.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/dbg.c b/src/dbg.c index b5de6ba..3ea32f7 100644 --- a/src/dbg.c +++ b/src/dbg.c @@ -14,6 +14,8 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include + #ifdef _WIN32 #include #endif @@ -21,6 +23,7 @@ #include "accessor.h" #include "con_.h" #include "engineapi.h" +#include "ent.h" #include "errmsg.h" #include "gamedata.h" #include "intdefs.h" @@ -144,4 +147,36 @@ DEF_CCMD_HERE(sst_dbg_gamedata, "Dump current gamedata values", 0) { dumpentprops(); } +DEF_CCMD_HERE(sst_dbg_edict, "Dump edict state", 0) { + if (argc != 2) { + con_warn("usage: sst_dbg_edict index\n"); + return; + } + int n = atoi(argv[1]); // meh + // XXX: assumes ent feature is working, because this file can't be hooked + // into the feature system (well... it would be annoying). since this is + // debug code anyway this is deemed sorta borderline acceptable for now but + // it would still be good to smooth over the sharp edge + struct edict *e = ent_getedict(n); + if (!e) { + con_warn("edict %d does not exist or could not be accessed\n", n); + return; + } + con_msg("edict %d (%p)\n", n, (void *)e); + con_msg(" stateflags: %d\n", e->stateflags); + if (e->stateflags & 1) con_msg(" - FL_EDICT_CHANGED (1)\n"); + if (e->stateflags & 2) con_msg(" - FL_EDICT_FREE (2)\n"); + if (e->stateflags & 4) con_msg(" - FL_EDICT_FULL (4)\n"); + if (e->stateflags & 8) con_msg(" - FL_EDICT_ALWAYS (8)\n"); + if (e->stateflags & 16) con_msg(" - FL_EDICT_DONTSEND (16)\n"); + if (e->stateflags & 32) con_msg(" - FL_EDICT_PVSCHECK (32)\n"); + if (e->stateflags & 64) con_msg(" - FL_EDICT_PENDING_DORMANT_CHECK (64)\n"); + if (e->stateflags & 128) con_msg(" - FL_EDICT_DIRTY_PVS_INFORMATION (128)\n"); + if (e->stateflags & 256) con_msg(" - FL_EDICT_FULL_EDICT_CHANGED (256)\n"); + con_msg(" netserial: %d\n", e->netserial); + con_msg(" ent_networkable: %p\n", e->ent_networkable); + con_msg(" ent_unknown: %p\n", e->ent_unknown); + if (!GAMETYPE_MATCHES(L4Dbased)) con_msg(" freetime: %f\n", e->freetime); +} + // vi: sw=4 ts=4 noet tw=80 cc=80 -- cgit v1.2.3-54-g00ecf