Skip to content
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

fix: NetworkIdentity component bitmask shifting overflows #3941

Merged
merged 2 commits into from
Nov 9, 2024

Conversation

imerr
Copy link
Contributor

@imerr imerr commented Nov 7, 2024

Thanks to EnragedOxygen on Discord for tracking this one down!

Turns out you need to be very explicit with typing otherwise c# will default to int.
This will cause the component dirty mask to overflow for any components > 32, which causes weird issues since it will cancel each other out (both the bitmask creation and the following IsDirty(componentIndex) overflow)
This will lead to serialization on the component index < 32 and > 32 (so index 33 would deserialize for both 1 and 33), but only sometimes
Generally in real games this would show up as a size mismatch which is how EnragedOxygen discovered it

I've done a quick project wide search for any other occurences, but it seems like everywhere else is typed correctly

imerr added 2 commits November 7, 2024 15:57
Otherwise it uses ints and overflows when shifting more than 32
@imerr imerr force-pushed the fix/netid_bitmasks branch from cc00697 to 7e4943d Compare November 7, 2024 15:57
@imerr imerr requested a review from miwarnec November 7, 2024 15:59
@miwarnec miwarnec merged commit 1187a59 into master Nov 9, 2024
@miwarnec miwarnec deleted the fix/netid_bitmasks branch November 9, 2024 16:45
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.

2 participants