summaryrefslogtreecommitdiffstats
path: root/src/esp.cpp
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 01:13:09 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 01:13:09 +0100
commitb9d5965c0366fd7777c3627b9fbf89c8526ac0ec (patch)
tree65a1213b902f2a3352ecc19dc76be396e80f63f3 /src/esp.cpp
parentSkybox image: swap red/blue in the uploaded texture (diff)
downloadhl2h-b9d5965c0366fd7777c3627b9fbf89c8526ac0ec.tar.gz
hl2h-b9d5965c0366fd7777c3627b9fbf89c8526ac0ec.zip
World tint: colour dynamic props through m_clrRender
Prop model materials (VertexLitGeneric) ignore IMaterial::ColorModulate: the engine feeds StudioRender the per-entity render colour (m_clrRender) on every draw, so the material-side tint never showed on crates and other props. Resolve m_clrRender from DT_BaseEntity and, every 10 ms while World tint and Props are enabled, write the prop colour into every entity whose model is under models/props. Restore white once when disabled.
Diffstat (limited to '')
-rw-r--r--src/esp.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/esp.cpp b/src/esp.cpp
index 50d7b5d..9d041b0 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -1405,6 +1405,55 @@ bool triggerbot_apply(CUserCmd *cmd) {
1405 return false; 1405 return false;
1406} 1406}
1407 1407
1408// Tints dynamic props by writing their client render colour. StudioRender
1409// uses m_clrRender as the per-model colour modulation, which is why changing
1410// the prop MATERIAL colour had no effect.
1411void prop_tint_update() {
1412 static bool applied = false;
1413 static bool logged_missing = false;
1414 static bool logged_touched = false;
1415 bool on = feature_active(FEAT_WORLD_TINT) && g_tint_prop_on;
1416 if (!on && !applied)
1417 return;
1418 if (!g_iface.entitylist || g_net.clr_render < 0) {
1419 if (on && !logged_missing) {
1420 logged_missing = true;
1421 logf("prop tint: m_clrRender unavailable");
1422 }
1423 return;
1424 }
1425 static double last = 0.0;
1426 double now = esp_now();
1427 if (on && now - last < 0.01)
1428 return;
1429 last = now;
1430
1431 using Fn = int (*)(void *);
1432 int hi = vfunc<Fn>(g_iface.entitylist, 6)(g_iface.entitylist);
1433 if (hi < 0 || hi > 4096)
1434 hi = 4096;
1435 uint32_t col =
1436 on ? ((uint32_t)g_tint_prop_rgb[0] | ((uint32_t)g_tint_prop_rgb[1] << 8) |
1437 ((uint32_t)g_tint_prop_rgb[2] << 16) | (255u << 24))
1438 : 0xFFFFFFFFu;
1439 int touched = 0;
1440 for (int idx = 1; idx <= hi; idx++) {
1441 void *ent = entitylist_get(idx);
1442 if (!ent)
1443 continue;
1444 const char *model = entity_model_name(ent);
1445 if (!model || strncmp(model, "models/props", 12) != 0)
1446 continue;
1447 *(uint32_t *)((uintptr_t)ent + (uintptr_t)g_net.clr_render) = col;
1448 touched++;
1449 }
1450 applied = on;
1451 if (on && touched > 0 && !logged_touched) {
1452 logged_touched = true;
1453 logf("prop tint: %d prop entities", touched);
1454 }
1455}
1456
1408void esp_draw() { 1457void esp_draw() {
1409 if (!g_surface || !g_iface.entitylist || !g_net.esp_ok()) return; 1458 if (!g_surface || !g_iface.entitylist || !g_net.esp_ok()) return;
1410 if (!g_scr_w) { 1459 if (!g_scr_w) {