diff options
author | 2024-09-25 18:25:08 +0100 | |
---|---|---|
committer | 2024-09-28 18:28:13 +0100 | |
commit | bc9198ba9b654117118a06399d4dbf273262501d (patch) | |
tree | 73572d7807797ff22333aeefffae19a708bdd9af /src/ent.c | |
parent | a62d7366a6061c1873b87ead944e2521f589b0c7 (diff) | |
download | sst-bc9198ba9b654117118a06399d4dbf273262501d.tar.gz sst-bc9198ba9b654117118a06399d4dbf273262501d.zip |
Create and use macros to define accessor functions
Avoids the need to manually mess around with mem_offset() and gamedata
off_ and sz_ values as often, because that's kind of annoying.
Should also make the codebase a little less confusing for new players.
Diffstat (limited to 'src/ent.c')
-rw-r--r-- | src/ent.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -14,6 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ +#include "accessor.h" #include "con_.h" #include "dictmaptree.h" #include "engineapi.h" @@ -31,12 +32,16 @@ FEATURE() DECL_VFUNC_DYN(void *, PEntityOfEntIndex, int) + +DEF_PTR_ACCESSOR(struct edict *, edicts) +DEF_ARRAYIDX_ACCESSOR(edict) + static struct edict **edicts = 0; struct edict *ent_getedict(int idx) { if (edicts) { // globalvars->edicts seems to be null when disconnected - if_hot (*edicts) return mem_offset(*edicts, sz_edict * idx); + if_hot (*edicts) return arrayidx_edict(*edicts, idx); return 0; } else { @@ -177,7 +182,7 @@ INIT { // can just call the function later. if (has_vtidx_PEntityOfEntIndex) return true; if (globalvars && has_off_edicts) { - edicts = mem_offset(globalvars, off_edicts); + edicts = getptr_edicts(globalvars); return true; } errmsg_warnx("not implemented for this engine"); |