summaryrefslogtreecommitdiffhomepage
path: root/src/build/mkentprops.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-05-15 23:05:41 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-05-15 23:05:41 +0100
commit9009f75bf5fd33e13abae5762d31968b39f233c3 (patch)
tree99a65caf9b2199ad4a8d7bbc539867bfea254412 /src/build/mkentprops.c
parent831862bec84dde31a0568ec8a2f2b0170e18a973 (diff)
Fix GetEngineBuildNumber and entity property stuff
I still haven't bothered to flesh out all the possible indices for GetEngineBuildNumber but we're back to being able to use it to detect The Last Stand (as a result of some old version testing Aciidz did - thanks again!). This means we can do away with the terrible map file- based hotfix. Also, turns out sst_l4d_testwarp doesn't work if the plugin gets loaded early via VDF because certain SendTable offsets start out negated, so we work around that too now.
Diffstat (limited to 'src/build/mkentprops.c')
-rw-r--r--src/build/mkentprops.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/build/mkentprops.c b/src/build/mkentprops.c
index 5dd2fea..e99873b 100644
--- a/src/build/mkentprops.c
+++ b/src/build/mkentprops.c
@@ -144,11 +144,11 @@ _( "static void initentprops(struct ServerClass *class) {")
F( " for (int needclasses = %d; class; class = class->next) {", nclasses)
char *else1 = "";
for (struct class *c = classes.x[0]; c; c = c->hdr.x[0]) {
- // TODO(opt): some sort of PHF instead of chained strcmp, if we ever
- // have more than a few classes/properties?
+ // TODO(opt): some sort of PHF or trie instead of chained strcmp, if we
+ // ever have more than a few classes/properties?
F( " %sif (!strcmp(class->name, \"%s\")) {", else1, c->name)
_( " struct SendTable *st = class->table;")
- // christ this is awful :(
+ // 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;")
@@ -159,7 +159,12 @@ _( " p = mem_offset(p, sz_SendProp)) {")
F( " %sif (!strcmp(*(const char **)mem_offset(p, off_SP_varname), \"%s\")) {",
else2, (*pp)->propname) // ugh
F( " has_%s = true;", (*pp)->varname)
-F( " %s = *(int *)mem_offset(p, off_SP_offset);", (*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)
_( " if (!--needprops) break;")
_( " }")
else2 = "else ";