Fix multiple damage instances in certain areas during explosions #4187
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #997 and #4125
The world in SA is divided into sectors for optimization purposes. Sectors are determined based on position, and it's possible for a single point to be located in multiple sectors simultaneously — for example, at the corner where four sectors meet. To prevent logic from being processed multiple times for the same entities, a mechanism called 'scan codes' was introduced. When scanning sectors, a new scan code is set, and each entity is assigned the current scan code during processing. Entities that already have the current scan code are skipped, as they've already been handled.
For some reason, R* likely forgot to include the scan code logic in the explosion-related functions, which caused the same entities to be processed (and receive damage) multiple times. This explains why the bug only occurred in specific areas — those happened to be at sector boundaries where a point was part of multiple sectors simultaneously