summaryrefslogtreecommitdiffstats
path: root/src/server.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 23:46:58 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 23:46:58 +0100
commita224cc451233a487a3d931954b125f6e1736e710 (patch)
tree5cd1ed10848b6510ff92dccbe6f7b3cd5f7348f4 /src/server.cpp
parentCharger juice: resolve per-class offsets (diff)
downloadhl2h-a224cc451233a487a3d931954b125f6e1736e710.tar.gz
hl2h-a224cc451233a487a3d931954b125f6e1736e710.zip
Grenade trajectory: actual grenade state, full-length path, rounder rings
- Prefer the local player's thrown frag over the pre-throw estimate: resolve CBaseGrenade::m_hThrower from the server datamap (client owner handles as fallback), then seed the prediction from the live origin/velocity. The real frag is a spinning VPhysics box with a random Y angular impulse, so bounce points remain approximate; the doc now says so. - Keep 512 path points sampled every other 20 ms step (up to 24 s) instead of 127 points / ~2.5 s, so the line reaches the landing instead of stopping in mid-air. - Radius rings use 36 segments; a segment whose near-plane-clipped endpoint the engine overlay refuses falls back to the local projection, and that projection now uses the configured camera FOV instead of a hardcoded 75 degrees (the wide-FOV ring no longer kinks/drops pieces).
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp
index f69ab30..cffc24f 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -58,6 +58,7 @@ static int g_srv_mapname = -1;
58static int g_srv_armor = -1; 58static int g_srv_armor = -1;
59static int g_srv_detonate = -1; 59static int g_srv_detonate = -1;
60static int g_srv_grenade_radius = -1; 60static int g_srv_grenade_radius = -1;
61static int g_srv_thrower = -1;
61static int g_srv_juice_suit = -1; 62static int g_srv_juice_suit = -1;
62static int g_srv_juice_health = -1; 63static int g_srv_juice_health = -1;
63static int g_srv_ammo = -1; 64static int g_srv_ammo = -1;
@@ -181,6 +182,7 @@ bool resolve_server_netvars() {
181 // CBaseGrenade fuse / blast radius (m_flDetonateTime is not networked). 182 // CBaseGrenade fuse / blast radius (m_flDetonateTime is not networked).
182 g_srv_detonate = datamap_offset("m_flDetonateTime", FIELD_TIME); 183 g_srv_detonate = datamap_offset("m_flDetonateTime", FIELD_TIME);
183 g_srv_grenade_radius = datamap_offset("m_DmgRadius", FIELD_FLOAT); 184 g_srv_grenade_radius = datamap_offset("m_DmgRadius", FIELD_FLOAT);
185 g_srv_thrower = datamap_offset("m_hThrower", FIELD_EHANDLE);
184 int juice_offs[8]; 186 int juice_offs[8];
185 int njuice = datamap_offsets("m_iJuice", FIELD_INTEGER, 0x40, 0x4000, 187 int njuice = datamap_offsets("m_iJuice", FIELD_INTEGER, 0x40, 0x4000,
186 juice_offs, 8); 188 juice_offs, 8);
@@ -510,8 +512,24 @@ float server_grenade_radius(int idx) {
510 return *(float *)((uintptr_t)base + g_srv_grenade_radius); 512 return *(float *)((uintptr_t)base + g_srv_grenade_radius);
511} 513}
512 514
513// CWallHealth / CNewRecharge share the same m_iJuice layout (the fields before 515// CBaseGrenade::m_hThrower, used to recognise the local player's own frag even
514// it match), so one datamap offset works for both health and suit chargers. 516// when the client owner handles are unresolved.
517int server_grenade_thrower(int idx) {
518 if (!g_srv_ready || g_srv_thrower < 0)
519 return -1;
520 void *base = nullptr;
521 server_entity_health(idx, nullptr, nullptr, &base);
522 if (!base)
523 return -1;
524 uint32_t h = *(uint32_t *)((uintptr_t)base + g_srv_thrower);
525 if (h == 0 || h == 0xFFFFFFFFu)
526 return -1;
527 return (int)(h & 0x7FF);
528}
529
530// Health chargers (CWallHealth, CBaseToggle) and suit chargers
531// (CNewRecharge, CBaseAnimating) have m_iJuice at different offsets; pick by
532// the server class name.
515int server_item_juice(int idx) { 533int server_item_juice(int idx) {
516 if (!g_srv_ready) 534 if (!g_srv_ready)
517 return -1; 535 return -1;