summaryrefslogtreecommitdiffhomepage
path: root/src/build/mkentprops.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-05-16 21:07:41 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-05-16 22:15:46 +0100
commit278b61bc3f2018515e26fd6b45410aded8b6417e (patch)
tree39a860b66c3d88e91359f48dbf937c0c71d61833 /src/build/mkentprops.c
parente8843dba3eb1c7a67f6ff7b920046ae36a12acd0 (diff)
Clean up some random bits and bobs
Diffstat (limited to 'src/build/mkentprops.c')
-rw-r--r--src/build/mkentprops.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/build/mkentprops.c b/src/build/mkentprops.c
index e99873b..321b954 100644
--- a/src/build/mkentprops.c
+++ b/src/build/mkentprops.c
@@ -148,23 +148,23 @@ F( " for (int needclasses = %d; class; class = class->next) {", nclasses)
// ever have more than a few classes/properties?
F( " %sif (!strcmp(class->name, \"%s\")) {", else1, c->name)
_( " struct SendTable *st = class->table;")
- // XXX: christ this is all awful :(
F( " int needprops = %d;", c->props.sz)
-_( " for (struct SendProp *p = st->props; (char *)p -")
-_( " (char *)st->props < st->nprops * sz_SendProp;")
+_( " for (struct SendProp *p = st->props;")
+_( " mem_diff(p, st->props) < st->nprops * sz_SendProp;")
_( " p = mem_offset(p, sz_SendProp)) {")
+_( " const char *varname = mem_loadptr(mem_offset(p, off_SP_varname));")
char *else2 = "";
for (struct prop **pp = c->props.data;
pp - c->props.data < c->props.sz; ++pp) {
-F( " %sif (!strcmp(*(const char **)mem_offset(p, off_SP_varname), \"%s\")) {",
- else2, (*pp)->propname) // ugh
+F( " %sif (!strcmp(varname, \"%s\")) {", else2, (*pp)->propname)
F( " has_%s = true;", (*pp)->varname)
// from AM L4D2 SDK headers:
// > SENDPROP_VECTORELEM makes [offset] negative to start with so we
// > can detect that and set the SPROP_IS_VECTOR_ELEM flag.
// apparently if we're loaded via VDF, it hasn't been flipped back
- // yet. just calling abs() on it as an easy solution.
-F( " %s = abs(*(int *)mem_offset(p, off_SP_offset));", (*pp)->varname)
+ // yet. just calling abs() on everything as an easy solution.
+F( " %s = abs(*(int *)mem_offset(p, off_SP_offset));",
+ (*pp)->varname)
_( " if (!--needprops) break;")
_( " }")
else2 = "else ";