summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-10-28 12:42:46 +0100
committersalmonik <salmonik@tuta.io>2026-10-28 12:42:46 +0100
commit2eda18951fde7ebd803aeb48595f203c0bb2f82a (patch)
tree01b93c7ceb45c29652ccf261aa63faaa9a85fec4
parentLogging: per-session file and debug-gated verbose logs (diff)
downloadhl2h-2eda18951fde7ebd803aeb48595f203c0bb2f82a.tar.gz
hl2h-2eda18951fde7ebd803aeb48595f203c0bb2f82a.zip
Item ESP: make 0 = unlimited explicit and persistent
- config_load now accepts max_dist=0 instead of clamping it to 250, so the "unlimited" setting survives a restart. - The Max distance slider shows "All" at 0 and its tooltip documents 0 = unlimited; the categories log prints max=All. - Skip unclassified entities before projecting them / computing distance. - Keep the removed prop/crate debug logging and the user's rule that the distance slider applies to every tag.
Diffstat (limited to '')
-rw-r--r--CONTEXT.md5
-rw-r--r--src/esp.cpp41
-rw-r--r--src/gui.cpp12
-rw-r--r--src/menu.cpp2
4 files changed, 22 insertions, 38 deletions
diff --git a/CONTEXT.md b/CONTEXT.md
index 7a1ee33..0ecf80c 100644
--- a/CONTEXT.md
+++ b/CONTEXT.md
@@ -284,8 +284,9 @@ vocabulary / decisions.
284- Scans the client entity list every 100 ms and tags health, ammo, armor/suit, 284- Scans the client entity list every 100 ms and tags health, ammo, armor/suit,
285 world weapon pickups, the two supply-crate models and generic items. 285 world weapon pickups, the two supply-crate models and generic items.
286- Each tag is a colored marker with a name and optional distance, filtered by 286- Each tag is a colored marker with a name and optional distance, filtered by
287 category toggles and a max-distance slider (default 5000 units). Drawn 287 category toggles and a max-distance slider (default 5000 units; 0 means
288 through walls and independently of the hostile NPC ESP. 288 unlimited and displays as "All"). Drawn through walls and independently of
289 the hostile NPC ESP.
289- Ammo labels are specific where the model is known: pistol, SMG, AR2, .357, 290- Ammo labels are specific where the model is known: pistol, SMG, AR2, .357,
290 crossbow, shotgun, sniper, flares, AR2 grenade, RPG rocket, plus ammo-crate 291 crossbow, shotgun, sniper, flares, AR2 grenade, RPG rocket, plus ammo-crate
291 variants. Unknown ammo falls back to "Ammo". 292 variants. Unknown ammo falls back to "Ammo".
diff --git a/src/esp.cpp b/src/esp.cpp
index 50549a1..4d2345d 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -1644,15 +1644,18 @@ static void items_collect(int local_idx) {
1644 static bool cats_logged = false; 1644 static bool cats_logged = false;
1645 if (!cats_logged) { 1645 if (!cats_logged) {
1646 cats_logged = true; 1646 cats_logged = true;
1647 char maxbuf[16];
1648 if (g_item_max_dist == 0)
1649 snprintf(maxbuf, sizeof(maxbuf), "All");
1650 else
1651 snprintf(maxbuf, sizeof(maxbuf), "%d", g_item_max_dist);
1647 logf("items: categories health=%d ammo=%d armor=%d weapons=%d " 1652 logf("items: categories health=%d ammo=%d armor=%d weapons=%d "
1648 "crates=%d distance=%d max=%d", 1653 "crates=%d distance=%d max=%s",
1649 (int)g_item_health, (int)g_item_ammo, (int)g_item_armor, 1654 (int)g_item_health, (int)g_item_ammo, (int)g_item_armor,
1650 (int)g_item_weapons, (int)g_item_crates, (int)g_item_distance, 1655 (int)g_item_weapons, (int)g_item_crates, (int)g_item_distance,
1651 g_item_max_dist); 1656 maxbuf);
1652 } 1657 }
1653 static int dbg_lines = 0; 1658 static int dbg_lines = 0;
1654 static int prop_logs = 0;
1655 static int crate_logs = 0;
1656 static bool owner_warned = false; 1659 static bool owner_warned = false;
1657 if (!owner_warned && g_net.owner < 0 && g_net.weapon_owner < 0) { 1660 if (!owner_warned && g_net.owner < 0 && g_net.weapon_owner < 0) {
1658 owner_warned = true; 1661 owner_warned = true;
@@ -1680,14 +1683,7 @@ static void items_collect(int local_idx) {
1680 } 1683 }
1681 char label[128]; 1684 char label[128];
1682 int kind = classify_item(model, cls, label, sizeof(label)); 1685 int kind = classify_item(model, cls, label, sizeof(label));
1683 1686 if (kind < 0)
1684 bool propish = item_icontains(cls, "crate") ||
1685 item_icontains(model, "crate") ||
1686 item_icontains(cls, "physicsprop") ||
1687 item_icontains(cls, "breakableprop") ||
1688 item_icontains(cls, "func_breakable") ||
1689 item_icontains(cls, "physbox");
1690 if (kind < 0 && !propish)
1691 continue; 1687 continue;
1692 1688
1693 Vector origin{*(float *)((uintptr_t)ent + g_net.origin), 1689 Vector origin{*(float *)((uintptr_t)ent + g_net.origin),
@@ -1698,30 +1694,11 @@ static void items_collect(int local_idx) {
1698 float dz = origin.z - g_cam_eye.z; 1694 float dz = origin.z - g_cam_eye.z;
1699 float dist = sqrtf(dx * dx + dy * dy + dz * dz); 1695 float dist = sqrtf(dx * dx + dy * dy + dz * dz);
1700 1696
1701 if (propish && dist < 1500.0f && prop_logs < 40) {
1702 prop_logs++;
1703 logd("item prop: idx=%d cls=%s model=%s kind=%d dist=%.0f "
1704 "origin=(%.0f %.0f %.0f)",
1705 idx, cls ? cls : "?", model ? model : "?", kind, dist, origin.x,
1706 origin.y, origin.z);
1707 }
1708 bool crateish = item_icontains(cls, "crate") ||
1709 item_icontains(model, "crate");
1710 if (crateish && dist < 1500.0f && crate_logs < 40) {
1711 crate_logs++;
1712 logf("item crate seen: idx=%d cls=%s model=%s kind=%d dist=%.0f "
1713 "origin=(%.0f %.0f %.0f)",
1714 idx, cls ? cls : "?", model ? model : "?", kind, dist, origin.x,
1715 origin.y, origin.z);
1716 }
1717 if (kind < 0)
1718 continue;
1719
1720 if (kind == IK_WEAPON) { 1697 if (kind == IK_WEAPON) {
1721 if (idx == active_idx || item_weapon_is_owned(ent)) 1698 if (idx == active_idx || item_weapon_is_owned(ent))
1722 continue; 1699 continue;
1723 } 1700 }
1724 // Distance applies to every tag, including supply crates. 1701 // Distance applies to every tag; 0 means unlimited.
1725 if (g_item_max_dist > 0 && dist > (float)g_item_max_dist) 1702 if (g_item_max_dist > 0 && dist > (float)g_item_max_dist)
1726 continue; 1703 continue;
1727 1704
diff --git a/src/gui.cpp b/src/gui.cpp
index e826ba9..b512ef3 100644
--- a/src/gui.cpp
+++ b/src/gui.cpp
@@ -193,6 +193,7 @@ struct Ctrl {
193 int *ival; // CK_SLIDER 193 int *ival; // CK_SLIDER
194 int min, max; 194 int min, max;
195 int action; // CK_BUTTON 195 int action; // CK_BUTTON
196 bool zero_unlimited; // slider: value 0 displays as "All"
196}; 197};
197 198
198struct Card { 199struct Card {
@@ -243,6 +244,7 @@ static void add_ctrl(int card, int kind, const char *label, const char *desc,
243 c.min = min; 244 c.min = min;
244 c.max = max; 245 c.max = max;
245 c.action = action; 246 c.action = action;
247 c.zero_unlimited = false;
246 g_cards[card].n++; 248 g_cards[card].n++;
247} 249}
248static void add_toggle(int card, const char *label, const char *desc, 250static void add_toggle(int card, const char *label, const char *desc,
@@ -364,8 +366,9 @@ static void build_cards() {
364 add_toggle(items, "Show distance", "Append the distance in units.", 366 add_toggle(items, "Show distance", "Append the distance in units.",
365 &g_item_distance); 367 &g_item_distance);
366 add_slider(items, "Max distance", 368 add_slider(items, "Max distance",
367 "Items farther away than this are not tagged.", 250, 10000, 369 "0 = unlimited; otherwise items farther away are hidden.", 0,
368 &g_item_max_dist); 370 10000, &g_item_max_dist);
371 g_ctrls[g_nctrl - 1].zero_unlimited = true;
369 372
370 int spread = add_card(3, &g_spread, "Spread control", 373 int spread = add_card(3, &g_spread, "Spread control",
371 "Choose a server shot seed that tightens the cone.", 374 "Choose a server shot seed that tightens the cone.",
@@ -1290,7 +1293,10 @@ static void draw_slider(const Rect &clip, const Rect &cr, int y, int rh,
1290 int kx = track.x + fw - S(4.0f); 1293 int kx = track.x + fw - S(4.0f);
1291 fill(Rect{kx, track.y - S(4.0f), S(8.0f), S(16.0f)}, C_ACCENT, &clip); 1294 fill(Rect{kx, track.y - S(4.0f), S(8.0f), S(16.0f)}, C_ACCENT, &clip);
1292 char val[32]; 1295 char val[32];
1293 snprintf(val, sizeof(val), "%d", value); 1296 if (ct.zero_unlimited && value == 0)
1297 snprintf(val, sizeof(val), "All");
1298 else
1299 snprintf(val, sizeof(val), "%d", value);
1294 text_in(clip, cr.x + cr.w - S(52.0f), y + (rh - g_body_h) / 2, val, 1300 text_in(clip, cr.x + cr.w - S(52.0f), y + (rh - g_body_h) / 2, val,
1295 g_font_body, g_body_h, 0, C_TEXT); 1301 g_font_body, g_body_h, 0, C_TEXT);
1296} 1302}
diff --git a/src/menu.cpp b/src/menu.cpp
index 6d7143d..2d4c660 100644
--- a/src/menu.cpp
+++ b/src/menu.cpp
@@ -280,7 +280,7 @@ static bool config_load() {
280 g_item_distance = atoi(val) != 0; 280 g_item_distance = atoi(val) != 0;
281 else if (strcmp(key, "max_dist") == 0) { 281 else if (strcmp(key, "max_dist") == 0) {
282 int v = atoi(val); 282 int v = atoi(val);
283 if (v < 250) v = 250; 283 if (v < 0) v = 0; // 0 = unlimited
284 if (v > 10000) v = 10000; 284 if (v > 10000) v = 10000;
285 g_item_max_dist = v; 285 g_item_max_dist = v;
286 } 286 }