Skip to content

Fix setElementDimension not working on buildings - #5139

Open
TheCrazy17 wants to merge 2 commits into
multitheftauto:masterfrom
TheCrazy17:fix/building-set-dimension
Open

Fix setElementDimension not working on buildings#5139
TheCrazy17 wants to merge 2 commits into
multitheftauto:masterfrom
TheCrazy17:fix/building-set-dimension

Conversation

@TheCrazy17

Copy link
Copy Markdown
Contributor

Summary

CClientBuilding extends CClientEntity directly, not CClientStreamElement, so unlike objects, peds and vehicles it never got automatic dimension-based streaming; SetDimension only stored the value, nothing ever compared it to the local player's dimension to actually show or hide the building.

Added the same RelateDimension pattern already used by CClientPointLights, CClientRadarArea, CClientRadarMarker and CClientWater, the other element types that also aren't stream elements: 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.

Motivation

setElementDimension silently did nothing on buildings; scripts had no way to hide a createBuilding building in a different dimension.

Test plan

Created a building, moved the local player between dimensions and called setElementDimension on the building both ways: it now shows only when its dimension matches the player's, and correctly disappears/reappears when either side changes.

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

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.
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.

1 participant