Skip to content

Fix improper hash collision handling in WindingFactory #108

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

Merged
merged 1 commit into from
Aug 2, 2021

Conversation

rihi
Copy link
Collaborator

@rihi rihi commented Aug 4, 2020

The WindingFactory class uses maps to cache already calculated windings.

While all methods use their respective DStruct as keys in the cache, fromSide() uses a hash based on the DBrush and the DBrushSide. This approach however doesn't account for hash collisions. If a DBrush + DBrushSide combination produces the same hash as a different DBrush + DBrushSide combination, the method incorrectly assumes their equal and returns the already calculated winding.

The pull request fixes this by simply using a Key-Value pair class as keys in the cache.

This probably resolves #56 as it seems to have been caused by this.

@ata4 ata4 merged commit 2868d6c into ata4:master Aug 2, 2021
@rihi rihi deleted the fix/hash-collision branch August 3, 2021 00:11
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.

BSPSource 1.3.24 seems to fail to produce correct .vmf compared to 1.3.23
2 participants