Skip to content

Fix water staying invisible across dimensions - #5141

Merged
FileEX merged 1 commit into
multitheftauto:masterfrom
TheCrazy17:fix/water-dimension-visibility
Aug 5, 2026
Merged

FileEX merged 1 commit into
multitheftauto:masterfrom
TheCrazy17:fix/water-dimension-visibility

Conversation

@TheCrazy17

Copy link
Copy Markdown
Contributor

Summary

Fixes water elements created in a dimension different from the local player's current dimension being deleted instead of just hidden.

Motivation

Resolves #849. CClientWater's constructor calls RelateDimension() right away, comparing its own dimension (still the default 0, since the real value hasn't been read from the network packet yet) against the local player's current dimension. On a mismatch it calls Destroy() instead of Create(), leaving m_pPoly null.

Packet_EntityAdd treated that as a creation failure: if (!pWater->Exists()) { delete pWater; pWater = NULL; }, deleting the element right after construction, before the packet handler even reaches the line further down that applies the water's real dimension (pEntity->SetDimension(usDimension)). That check dates back to when water had no dimension concept and m_pPoly == nullptr could only mean the native call genuinely failed (invalid vertices, water pool full); it was never updated when dimension support was added, so it can no longer tell a real failure apart from water that's just correctly waiting for its dimension to be applied.

Test plan

Created water server-side in dimension 0 while standing in dimension 1, then switched to dimension 0. Before the fix, the water never appeared; after the fix, it shows up correctly once dimensions match.

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 4, 2026
Comment thread Client/mods/deathmatch/logic/CPacketHandler.cpp
@FileEX FileEX added this to the 1.7 (Current) milestone Aug 5, 2026
@FileEX
FileEX merged commit ba3a895 into multitheftauto:master Aug 5, 2026
10 checks passed
@TheCrazy17
TheCrazy17 deleted the fix/water-dimension-visibility branch August 5, 2026 10:49
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.

[Server-side] createWater dimension problems

2 participants