summaryrefslogtreecommitdiffstats
path: root/src/esp.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/esp.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/esp.cpp b/src/esp.cpp
index 06bafaf..a0d84dd 100644
--- a/src/esp.cpp
+++ b/src/esp.cpp
@@ -873,6 +873,8 @@ bool melee_weapon_active(void *local_ent) {
873 if (!local_ent) 873 if (!local_ent)
874 return false; 874 return false;
875 int local = engine_get_local_player(); 875 int local = engine_get_local_player();
876 if (g_iface.engineserver)
877 resolve_server_netvars();
876 878
877 auto check = [&](int idx, const char **cls_out, 879 auto check = [&](int idx, const char **cls_out,
878 const char **model_out) -> bool { 880 const char **model_out) -> bool {
@@ -882,6 +884,14 @@ bool melee_weapon_active(void *local_ent) {
882 void *net = entity_networkable(idx); 884 void *net = entity_networkable(idx);
883 const char *cls = net ? entity_class_name(net, nullptr) : nullptr; 885 const char *cls = net ? entity_class_name(net, nullptr) : nullptr;
884 const char *model = wep ? entity_model_name(wep) : nullptr; 886 const char *model = wep ? entity_model_name(wep) : nullptr;
887 // Client weapon models can be missing/0 after a map change; recover the
888 // server model index so the crowbar is still recognized.
889 if ((!model || !*model) && g_iface.engineserver) {
890 void *sbase = nullptr;
891 server_entity_health(idx, nullptr, nullptr, &sbase);
892 if (sbase)
893 model = model_name_from_index(server_model_index(sbase));
894 }
885 *cls_out = cls; 895 *cls_out = cls;
886 *model_out = model; 896 *model_out = model;
887 return (cls && strstr(cls, "Crowbar")) || 897 return (cls && strstr(cls, "Crowbar")) ||
@@ -916,8 +926,15 @@ bool melee_weapon_active(void *local_ent) {
916 if (idx != last_idx || crowbar != last_crowbar) { 926 if (idx != last_idx || crowbar != last_crowbar) {
917 last_idx = idx; 927 last_idx = idx;
918 last_crowbar = crowbar; 928 last_crowbar = crowbar;
919 logd("melee: active idx=%d cls=%s model=%s crowbar=%d", idx, 929 logf("melee: active idx=%d cls=%s model=%s crowbar=%d", idx,
920 cls ? cls : "?", model ? model : "?", (int)crowbar); 930 cls ? cls : "?", model ? model : "?", (int)crowbar);
931 if (!crowbar) {
932 static bool warned = false;
933 if (!warned) {
934 warned = true;
935 toastf(TOAST_WARN, "Melee killbot: equip the crowbar");
936 }
937 }
921 } 938 }
922 return crowbar; 939 return crowbar;
923} 940}