summaryrefslogtreecommitdiffstats
path: root/src/hl2h.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-27 21:11:32 +0100
committersalmonik <salmonik@tuta.io>2026-10-27 21:11:32 +0100
commitc91c7248fcb3911a8a2b6442d8657167364a911c (patch)
treeca0b0304463c17bc93a67091522fef711f49b526 /src/hl2h.cpp
parentBind labels: name unlisted scancodes instead of showing None (diff)
downloadhl2h-c91c7248fcb3911a8a2b6442d8657167364a911c.tar.gz
hl2h-c91c7248fcb3911a8a2b6442d8657167364a911c.zip
Stucklaunch: fix prop detection and add diagnostics
- Client physics props are CPhysicsProp/CPhysBox, not the server class prop_physics; the old case-sensitive class check never matched. Detect MOVETYPE_VPHYSICS first (the reliable signal), then case-insensitive class/model patterns. - Log the first few prop checks with index, movetype, class and model so a failed ground lookup is diagnosable. - Log once when Stucklaunch is active (with run state, bind and ground offset), when it engages, and when the ground is not a prop. - Toast a warning when binding a feature that is not Active yet.
Diffstat (limited to '')
-rw-r--r--src/hl2h.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/hl2h.cpp b/src/hl2h.cpp
index 84de815..defdd27 100644
--- a/src/hl2h.cpp
+++ b/src/hl2h.cpp
@@ -172,8 +172,14 @@ static void apply_autostrafe(CUserCmd *cmd, const float *vel) {
172// True while the player stands on (or just left) a physics prop. m_hGroundEntity 172// True while the player stands on (or just left) a physics prop. m_hGroundEntity
173// is latched briefly because it clears during each hop. 173// is latched briefly because it clears during each hop.
174static bool stucklaunch_prop_ok(void *ent, int tick) { 174static bool stucklaunch_prop_ok(void *ent, int tick) {
175 if (g_net.groundentity < 0) 175 if (g_net.groundentity < 0) {
176 static bool logged = false;
177 if (!logged) {
178 logged = true;
179 logf("stucklaunch: m_hGroundEntity unavailable; prop detection off");
180 }
176 return true; // no netvar: the bind is the only safeguard 181 return true; // no netvar: the bind is the only safeguard
182 }
177 static int last_prop_tick = -100000; 183 static int last_prop_tick = -100000;
178 uint32_t h = *(uint32_t *)((uintptr_t)ent + g_net.groundentity); 184 uint32_t h = *(uint32_t *)((uintptr_t)ent + g_net.groundentity);
179 int gi = (h == 0xFFFFFFFFu) ? 0 : (int)(h & 0xFFFF); 185 int gi = (h == 0xFFFFFFFFu) ? 0 : (int)(h & 0xFFFF);
@@ -182,9 +188,15 @@ static bool stucklaunch_prop_ok(void *ent, int tick) {
182 static int prop_logs = 0; 188 static int prop_logs = 0;
183 if (prop_logs < 4) { 189 if (prop_logs < 4) {
184 prop_logs++; 190 prop_logs++;
185 logf("stucklaunch: prop idx=%d", gi); 191 logf("stucklaunch: prop idx=%d engaged", gi);
186 } 192 }
187 last_prop_tick = tick; 193 last_prop_tick = tick;
194 } else {
195 static int miss_logs = 0;
196 if (miss_logs < 4) {
197 miss_logs++;
198 logf("stucklaunch: ground h=%#x idx=%d is not a physics prop", h, gi);
199 }
188 } 200 }
189 return tick - last_prop_tick < 32; // ~0.5 s at 66 tick 201 return tick - last_prop_tick < 32; // ~0.5 s at 66 tick
190} 202}
@@ -194,6 +206,11 @@ static bool stucklaunch_prop_ok(void *ent, int tick) {
194// gun's +attack) to keep regrabbing the prop, and air-strafes the hops. 206// gun's +attack) to keep regrabbing the prop, and air-strafes the hops.
195static void stucklaunch_apply(CUserCmd *cmd, void *local_ent, bool onground, 207static void stucklaunch_apply(CUserCmd *cmd, void *local_ent, bool onground,
196 const float *vel) { 208 const float *vel) {
209 static bool engaged_logged = false;
210 if (!engaged_logged) {
211 engaged_logged = true;
212 logf("stucklaunch: applying jump/spam (onground=%d)", (int)onground);
213 }
197 cmd->buttons |= IN_JUMP; 214 cmd->buttons |= IN_JUMP;
198 int period = stucklaunch_spam_ticks(); 215 int period = stucklaunch_spam_ticks();
199 if (period < 1) 216 if (period < 1)
@@ -629,6 +646,14 @@ static void do_move(int seq, float frametime) {
629 } 646 }
630 647
631 bool stuck_on = feature_active(FEAT_STUCKLAUNCH); 648 bool stuck_on = feature_active(FEAT_STUCKLAUNCH);
649 if (g_stucklaunch.active) {
650 static bool state_logged = false;
651 if (!state_logged) {
652 state_logged = true;
653 logf("stucklaunch: active=1 run=%d bind=%d groundoff=%d",
654 (int)stuck_on, g_stucklaunch.bind, g_net.groundentity);
655 }
656 }
632 bool stuck_engaged = stuck_on && stucklaunch_prop_ok(ent, cmd->tick_count); 657 bool stuck_engaged = stuck_on && stucklaunch_prop_ok(ent, cmd->tick_count);
633 if (stuck_engaged) { 658 if (stuck_engaged) {
634 stucklaunch_apply(cmd, ent, onground, vel); 659 stucklaunch_apply(cmd, ent, onground, vel);