summaryrefslogtreecommitdiff
path: root/src/ent.c
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2024-09-25 18:25:08 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2024-09-28 18:28:13 +0100
commitbc9198ba9b654117118a06399d4dbf273262501d (patch)
tree73572d7807797ff22333aeefffae19a708bdd9af /src/ent.c
parenta62d7366a6061c1873b87ead944e2521f589b0c7 (diff)
downloadsst-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.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ent.c b/src/ent.c
index 1845b1f..2eb8e51 100644
--- a/src/ent.c
+++ b/src/ent.c
@@ -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");