Skip to content

Fix setElementDimension not working on buildings - #5139

Merged
FileEX merged 2 commits into
multitheftauto:masterfrom
TheCrazy17:fix/building-set-dimension
Aug 16, 2026
Merged

Fix setElementDimension not working on buildings#5139
FileEX merged 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.
@FileEX

FileEX commented Aug 14, 2026

Copy link
Copy Markdown
Member

Slightly off-topic, but do you think we could add buildings to MTA's streaming?

@FileEX FileEX added the bugfix Solution to a bug of any kind label Aug 14, 2026
@TheCrazy17

Copy link
Copy Markdown
Contributor Author

Slightly off-topic, but do you think we could add buildings to MTA's streaming?

It should be possible, and it shouldn't be too difficult. I'd have to look into it.

@PlatinMTA

Copy link
Copy Markdown
Contributor

Considering the change, is the default dimension for buildings just going to be 0 or -1? Making it backwards compatible would mean it should be -1 (stream to all dimensions) but idk if that would be confusing

@FileEX

FileEX commented Aug 15, 2026

Copy link
Copy Markdown
Member

The fact that buildings are visible in all dimensions isn't really the expected behavior. That's why imo they should default to dimension 0, just like any other element in MTA.

@TheCrazy17

Copy link
Copy Markdown
Contributor Author

The fact that buildings are visible in all dimensions isn't really the expected behavior. That's why imo they should default to dimension 0, just like any other element in MTA.

In that case, it already works that way. The PR could be merged as it is right now.

@FileEX FileEX added this to the 1.7 (Current) milestone Aug 16, 2026
@FileEX
FileEX merged commit 29f5500 into multitheftauto:master Aug 16, 2026
10 checks passed
@Fernando-A-Rocha

Copy link
Copy Markdown
Contributor

So the dimension of a building is 0 or -1 by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Solution to a bug of any kind

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants