Fix setElementDimension not working on buildings - #5139
Open
TheCrazy17 wants to merge 2 commits into
Open
Conversation
CClientBuilding extends CClientEntity directly, not CClientStreamElement, so it never got the automatic dimension based streaming that objects, peds and vehicles have; SetDimension only updated the stored value, nothing ever compared it to the local player's dimension. Added the same RelateDimension pattern already used by PointLights, RadarArea, RadarMarker and Water: CClientBuildingManager tracks the local player's dimension and calls RelateDimension on every building when it changes; CClientBuilding overrides SetDimension to re-evaluate itself the same way. Also fixed RestoreDestroyed, which recreated every building unconditionally on pool resize, ignoring dimension entirely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
CClientBuildingextendsCClientEntitydirectly, notCClientStreamElement, so unlike objects, peds and vehicles it never got automatic dimension-based streaming;SetDimensiononly stored the value, nothing ever compared it to the local player's dimension to actually show or hide the building.Added the same
RelateDimensionpattern already used byCClientPointLights,CClientRadarArea,CClientRadarMarkerandCClientWater, the other element types that also aren't stream elements:CClientBuildingManagertracks the local player's dimension and callsRelateDimensionon every building when it changes;CClientBuildingoverridesSetDimensionto re-evaluate itself the same way. Also fixedRestoreDestroyed(), which recreated every building unconditionally on pool resize, ignoring dimension entirely.Motivation
setElementDimensionsilently did nothing on buildings; scripts had no way to hide acreateBuildingbuilding in a different dimension.Test plan
Created a building, moved the local player between dimensions and called
setElementDimensionon the building both ways: it now shows only when its dimension matches the player's, and correctly disappears/reappears when either side changes.Checklist