diff options
Diffstat (limited to 'src/esp.cpp')
| -rw-r--r-- | src/esp.cpp | 56 |
1 files changed, 51 insertions, 5 deletions
diff --git a/src/esp.cpp b/src/esp.cpp index 1fd4904..64c1525 100644 --- a/src/esp.cpp +++ b/src/esp.cpp | |||
| @@ -1405,12 +1405,58 @@ bool triggerbot_apply(CUserCmd *cmd) { | |||
| 1405 | return false; | 1405 | return false; |
| 1406 | } | 1406 | } |
| 1407 | 1407 | ||
| 1408 | // Props are tinted through IStudioRender (studio.cpp), which covers both | 1408 | // Dynamic props are tinted through their client render colour. StudioRender |
| 1409 | // dynamic prop_physics entities and map-static props. There is no per-entity | 1409 | // feeds m_clrRender into the per-model colour modulation each draw, which is |
| 1410 | // netvar write here: m_clrRender resolved to offset 0 in this build. | 1410 | // why tinting the prop material alone had no effect. (The IStudioRender hook |
| 1411 | // experiment corrupted materials and crashed; see studio.cpp.) | ||
| 1411 | void prop_tint_update() { | 1412 | void prop_tint_update() { |
| 1412 | if (feature_active(FEAT_WORLD_TINT) && g_tint_prop_on) | 1413 | static bool applied = false; |
| 1413 | studio_props_init(); | 1414 | static bool logged_missing = false; |
| 1415 | static bool logged_touched = false; | ||
| 1416 | bool on = feature_active(FEAT_WORLD_TINT) && g_tint_prop_on; | ||
| 1417 | if (!on && !applied) | ||
| 1418 | return; | ||
| 1419 | if (!g_iface.entitylist || g_net.clr_render < 0) { | ||
| 1420 | if (on && !logged_missing) { | ||
| 1421 | logged_missing = true; | ||
| 1422 | logf("prop tint: m_clrRender unavailable"); | ||
| 1423 | } | ||
| 1424 | return; | ||
| 1425 | } | ||
| 1426 | static double last = 0.0; | ||
| 1427 | double now = esp_now(); | ||
| 1428 | if (on && now - last < 0.01) | ||
| 1429 | return; | ||
| 1430 | last = now; | ||
| 1431 | |||
| 1432 | using Fn = int (*)(void *); | ||
| 1433 | int hi = vfunc<Fn>(g_iface.entitylist, 6)(g_iface.entitylist); | ||
| 1434 | if (hi < 0 || hi > 4096) | ||
| 1435 | hi = 4096; | ||
| 1436 | uint32_t col = | ||
| 1437 | on ? ((uint32_t)g_tint_prop_rgb[0] | ((uint32_t)g_tint_prop_rgb[1] << 8) | | ||
| 1438 | ((uint32_t)g_tint_prop_rgb[2] << 16) | (255u << 24)) | ||
| 1439 | : 0xFFFFFFFFu; | ||
| 1440 | int touched = 0; | ||
| 1441 | for (int idx = 1; idx <= hi; idx++) { | ||
| 1442 | void *ent = entitylist_get(idx); | ||
| 1443 | if (!ent) | ||
| 1444 | continue; | ||
| 1445 | const char *model = entity_model_name(ent); | ||
| 1446 | if (!model) | ||
| 1447 | continue; | ||
| 1448 | bool prop = strncmp(model, "models/props", 12) == 0 || | ||
| 1449 | strncmp(model, "props_", 6) == 0; | ||
| 1450 | if (!prop) | ||
| 1451 | continue; | ||
| 1452 | *(uint32_t *)((uintptr_t)ent + (uintptr_t)g_net.clr_render) = col; | ||
| 1453 | touched++; | ||
| 1454 | } | ||
| 1455 | applied = on; | ||
| 1456 | if (on && touched > 0 && !logged_touched) { | ||
| 1457 | logged_touched = true; | ||
| 1458 | logf("prop tint: %d prop entities", touched); | ||
| 1459 | } | ||
| 1414 | } | 1460 | } |
| 1415 | 1461 | ||
| 1416 | void esp_draw() { | 1462 | void esp_draw() { |
