From cd13913b954c3a2a207ef0313526d0c761399ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Henrique=20A=2E=20Louteiro?= <78059994+henriquelouteiro@users.noreply.github.com> Date: Sat, 17 May 2025 20:36:03 -0400 Subject: [PATCH] fix: ensure weapon index is within valid 16-bit range Added a bitwise AND operation (`index = index & 0xFFFF`) at the beginning of the `get_weapon_name_by_index` function to ensure that the input index is always within the valid 16-bit range. This prevents issues caused by negative or out-of-range values that could result from unsigned-to-signed integer conversions or memory reading anomalies. This change helps improve reliability when integrating with game memory structures where weapon indices may contain additional flags or unintended bits. Also noticed a key duplication for index 43 ("Galil" and "Flashbang"). Only the last entry will be used due to dictionary behavior. Galil New Index -> 13 --- PyItV1.0.6.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/PyItV1.0.6.py b/PyItV1.0.6.py index ecf331d..ef798a3 100644 --- a/PyItV1.0.6.py +++ b/PyItV1.0.6.py @@ -604,6 +604,8 @@ def getDefuseTime(): return def get_weapon_name_by_index(index): + index = index & 0xFFFF + weapon_names = { 32: "P2000", 61: "USP-S", @@ -632,7 +634,7 @@ def get_weapon_name_by_index(index): 16: "M4A4", 60: "M4A1-S", 8: "AUG", - 43: "Galil", + 13: "Galil", 7: "AK-47", 39: "SG 553", 40: "SSG 08", @@ -1016,4 +1018,4 @@ def main_program(): process1.join() process2.join() process3.join() - process4.join() \ No newline at end of file + process4.join()