Fix setElementDimension not working on buildings - #5139
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.
|
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. |
|
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 |
|
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. |
|
So the dimension of a building is 0 or -1 by default? |
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