[TF2] Fix engineer building damage effects and placement previews not updating correctly #1280
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.
This fixes two really old, annoying visual bugs with Engineer buildings:
And possibly more minor bugs caused by the same oversight that I'm not aware of.
The problem was an incorrect use of
PreDataUpdate
to keep track of old netprop values, that would then be compared to the current values inOnDataChanged
to detect changes.PreDataUpdate
is called once per packet, which means it can be called multiple times per render frame depending on network conditions (more likely with higher ping/jitter), whileOnDataChanged
is only called once per render frame. IfPreDataUpdate
was called twice or more beforeOnDataChanged
, the old values would be updated to the new ones before being checked, and thus the changes would not be detected.The solution is to simply use
OnPreDataChanged
instead ofPreDataUpdate
, which is the correct function to pair withOnDataChanged
since it's also only called once per render frame.