Skip to content

Fix testSphereAgainstWorld returning nil hitElement for buildings - #5140

Merged
FileEX merged 1 commit into
multitheftauto:masterfrom
TheCrazy17:fix/building-processlineofsight-hitelement
Aug 2, 2026
Merged

Fix testSphereAgainstWorld returning nil hitElement for buildings#5140
FileEX merged 1 commit into
multitheftauto:masterfrom
TheCrazy17:fix/building-processlineofsight-hitelement

Conversation

@TheCrazy17

Copy link
Copy Markdown
Contributor

Summary

Fixes hitElement returning nil when testSphereAgainstWorld (and processLineOfSight) hits a building created with createBuilding.

Motivation

Resolves #5136. CPoolsSA::GetEntity never checked the buildings pool, so CEntity* resolution for a building always fell through to null. Even after that, testSphereAgainstWorld still returned nil because it resolves its element through GetStoredPointer, which CClientBuilding::Create never set on the native entity, unlike objects, peds and vehicles.

Test plan

Created a building with createBuilding, called testSphereAgainstWorld and processLineOfSight against it. Before the fix, both returned a hit with a nil hitElement; after the fix, hitElement correctly resolves to the building.

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.

…gainstWorld

Add buildings pool lookup to CPoolsSA::GetEntity; set stored pointer on building creation so entity resolves back to its client element.
@FileEX

FileEX commented Aug 2, 2026

Copy link
Copy Markdown
Member

What about CPoolsSA::GetClientEntity method?

@FileEX FileEX added the bugfix Solution to a bug of any kind label Aug 2, 2026
@FileEX FileEX added this to the 1.7 (Current) milestone Aug 2, 2026
@FileEX
FileEX merged commit b069947 into multitheftauto:master Aug 2, 2026
10 checks passed
@TheCrazy17
TheCrazy17 deleted the fix/building-processlineofsight-hitelement branch August 2, 2026 23:22
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.

processLineOfSight and testSphereAgainstWorld don't return hitElement for buildings created by createBuilding

2 participants