From c803fd1f425e7ea8e78f83afd481e58326fb1610 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 16:18:21 +0100 Subject: Netvars: handle RecvPropArray3 array props m_iAmmo and m_hMyWeapons were not resolving (both -1). Array props keep their element descriptor in m_pArrayProp and its offset can hold the array base; the walker was also treating a non-null m_pDataTable on an array as a nested table and skipping the name match. Process array props by name, use the element offset when present, and log the first 16 array props under HL2H_DEBUG. --- src/netvars.cpp | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/netvars.cpp b/src/netvars.cpp index 2747c29..9b7e3c9 100644 --- a/src/netvars.cpp +++ b/src/netvars.cpp @@ -67,10 +67,18 @@ static void collect_netvars(uintptr_t table, uintptr_t base_off, int depth) { if (dump) logd(" [%s] %s type=%d off=%d(0x%x) table=%s array=%s", tname, pname2, ptype, poff, poff, ptable ? "yes" : "no", parray ? "yes" : "no"); - if (ptable) { + if (ptable && !parray) { collect_netvars(ptable, base_off + (uint32_t)poff, depth + 1); continue; } + if (parray) { + static int alogs = 0; + if (alogs < 16) { + alogs++; + logd("netvar array %s poff=%d eoff=%d base=%d", pname2, poff, + *(int32_t *)(parray + 0x2C), (int)base_off); + } + } if (strcmp(pname2, "m_lifeState") == 0 && g_net.lifestate < 0) { g_net.lifestate = (int)(base_off + (uint32_t)poff); @@ -115,12 +123,28 @@ static void collect_netvars(uintptr_t table, uintptr_t base_off, int depth) { } else if (strcmp(pname2, "m_hMyWeapons") == 0 && g_net.my_weapons < 0) { int off = (int)(base_off + (uint32_t)poff); - if (off >= 0x20 && off <= 0x2000) + if (parray) { + int32_t eoff = *(int32_t *)(parray + 0x2C); + if (eoff) + off = (int)(base_off + (uint32_t)eoff); + } + if (off >= 0x20 && off <= 0x2000) { g_net.my_weapons = off; + logd("netvar: m_hMyWeapons base_off=%d poff=%d parray=%p -> %d", + (int)base_off, poff, (void *)parray, off); + } } else if (strcmp(pname2, "m_iAmmo") == 0 && g_net.ammo < 0) { int off = (int)(base_off + (uint32_t)poff); - if (off >= 0x20 && off <= 0x2000) + if (parray) { + int32_t eoff = *(int32_t *)(parray + 0x2C); + if (eoff) + off = (int)(base_off + (uint32_t)eoff); + } + if (off >= 0x20 && off <= 0x2000) { g_net.ammo = off; + logd("netvar: m_iAmmo base_off=%d poff=%d parray=%p -> %d", + (int)base_off, poff, (void *)parray, off); + } } else if (strcmp(pname2, "m_iTeamNum") == 0 && g_net.teamnum < 0) { g_net.teamnum = (int)(base_off + (uint32_t)poff); } else if (strcmp(pname2, "m_vecOrigin") == 0 && g_net.origin < 0) { -- cgit v1.2.3