summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2024-09-16 20:36:16 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2024-09-16 20:36:16 +0100
commit6d77b9751089f531375deb8ca7fb7b759cedbbb9 (patch)
treea2f6eb80bd761d9f0ef5447825a1126fe3b4ce0c /src
parent05cb6abe4ffaa6928190073f86423b3c0b03b4fd (diff)
Address some minor L4D warp testing oversights
- Check the player's team before attempting any form of warp prediction (as per the code bill wrote before) - Avoid overlapping boxes and an unnecessary line draw in the case where the player is never actually stuck.
Diffstat (limited to 'src')
-rw-r--r--src/l4dwarp.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/l4dwarp.c b/src/l4dwarp.c
index 50a5d46..f508460 100644
--- a/src/l4dwarp.c
+++ b/src/l4dwarp.c
@@ -112,6 +112,10 @@ DEF_CCMD_HERE_UNREG(sst_l4d_testwarp, "Simulate a bot warping to you "
return;
}
void *e = ed->ent_unknown;
+ if_cold (mem_loadu32(mem_offset(e, off_teamnum)) != 2) {
+ clientcon_msg(ed, "error: must be in the Survivor team");
+ return;
+ }
filter.pass_ent = e;
struct vec3f stuckpos = warptarget(e);
struct vec3f finalpos;
@@ -171,6 +175,10 @@ DEF_CCMD_HERE_UNREG(sst_l4d_previewwarp, "Visualise bot warp unstuck logic "
return;
}
void *e = ed->ent_unknown;
+ if_cold (mem_loadu32(mem_offset(e, off_teamnum)) != 2) {
+ clientcon_msg(ed, "error: must be in the Survivor team");
+ return;
+ }
filter.pass_ent = e;
struct vec3f stuckpos = warptarget(e);
struct vec3f finalpos;
@@ -182,13 +190,9 @@ DEF_CCMD_HERE_UNREG(sst_l4d_previewwarp, "Visualise bot warp unstuck logic "
struct vec3f maxs = *OBBMaxs(mem_offset(ed->ent_unknown, off_collision));
struct vec3f step = {maxs.x - mins.x, maxs.y - mins.y, maxs.z - mins.z};
struct failranges { struct { int neg, pos; } x, y, z; } ranges;
- AddBoxOverlay2(dbgoverlay, &stuckpos, &mins, &maxs, &zerovec,
- &red_face, &red_edge, 1000.0);
if (success) {
AddBoxOverlay2(dbgoverlay, &finalpos, &mins, &maxs, &zerovec,
&green_face, &green_edge, 1000.0);
- AddLineOverlay(dbgoverlay, &stuckpos, &finalpos,
- cyan_line.r, cyan_line.g, cyan_line.b, true, 1000.0);
if (finalpos.x != stuckpos.x) {
float iters = roundf((finalpos.x - stuckpos.x) / step.x);
int isneg = iters < 0;
@@ -223,12 +227,16 @@ DEF_CCMD_HERE_UNREG(sst_l4d_previewwarp, "Visualise bot warp unstuck logic "
// we were never actually stuck - no need to draw all the boxes
return;
}
+ AddLineOverlay(dbgoverlay, &stuckpos, &finalpos,
+ cyan_line.r, cyan_line.g, cyan_line.b, true, 1000.0);
}
else {
finalpos = stuckpos;
// searched the entire 15 iteration range, found nowhere to go
ranges = (struct failranges){{-15, 15}, {-15, 15}, {-15, 15}};
}
+ AddBoxOverlay2(dbgoverlay, &stuckpos, &mins, &maxs, &zerovec,
+ &red_face, &red_edge, 1000.0);
bool needline = true;
for (int i = ranges.x.neg; i <= ranges.x.pos; ++i) {
if (i == 0) { needline = true; continue; }