Skip to content

fix: ensure weapon index is within valid 16-bit range #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

henriquelouteiro
Copy link

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.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant