Skip to content

Fix #5196: setLowLODElement crash when LOD element is a building - #5201

Open
x6c85 wants to merge 5 commits into
multitheftauto:masterfrom
x6c85:master
Open

Fix #5196: setLowLODElement crash when LOD element is a building#5201
x6c85 wants to merge 5 commits into
multitheftauto:masterfrom
x6c85:master

Conversation

@x6c85

@x6c85 x6c85 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

setLowLODElement could crash the client when both the high-detail element and the LOD were buildings. After #5139 a building in another dimension (or one that failed to allocate) has no native GTA entity (m_pBuilding == nullptr), but CClientBuilding::SetLowLodBuilding still called SetLod on that pointer.

The MTA-side high/low link is now stored even if the native entities are missing, SetLod is only called when both exist, and Create() restores the GTA LOD link once the building is actually created.

Motivation

Fixes #5196. Building-to-building LOD is supported (wiki: createBuilding + createBuilding + setLowLODElement); it just shouldn't crash. This matches the report that it reproduced in a gamemode but not always via runcode.

Test plan

local b = createBuilding(5427, 2170.9765625, -1461.125, 25.0859375, 0, 0, 0, 0)
local bLOD = createBuilding(5581, 2170.9765625, -1461.125, 25.0859375, 0, 0, 0, 0)
setLowLODElement(b, bLOD)

Client should not crash. Also check:

  • same snippet while the local player is in a non-zero dimension
  • createBuilding + createObject(..., true) + setLowLODElement still works
  • changing the player's dimension and coming back still shows the LOD pair

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.

@FileEX FileEX added the bugfix Solution to a bug of any kind label Aug 21, 2026
@FileEX FileEX added this to the 1.7 (Current) milestone Aug 21, 2026
@FileEX
FileEX enabled auto-merge (squash) August 21, 2026 16:15
@FileEX

FileEX commented Aug 25, 2026

Copy link
Copy Markdown
Member

Please resolve conflicts

auto-merge was automatically disabled August 25, 2026 10:44

Head branch was pushed to by a user without write access

@FileEX
FileEX enabled auto-merge (squash) September 10, 2026 21:50
auto-merge was automatically disabled September 11, 2026 15:48

Head branch was pushed to by a user without write access

@FileEX

FileEX commented Sep 12, 2026

Copy link
Copy Markdown
Member

Please fix the clang-format issues

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.

setLowLODElement might crash if LLOD Element is Building

2 participants