Repository navigation
Keep Z as short in memory - #81
Merged
Merged
Conversation
Tile Z, StaticInfo, landscape events, tools and UI now use short instead of sbyte. Map/statics files and network packets are unchanged: Z is still read and written as a single signed byte through the new ZRange helpers (ReadZ/WriteZ), so the on-disk and on-wire format stays byte-identical. ZRange.Min/Max replace the hard-coded -128/127 limits, and ZRange.Clamp replaces sbyte casts that silently wrapped around on overflow. This prepares optional 16-bit Z support without changing behavior. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of the optional 16-bit Z plan: tile Z becomes
shortin memory, while map/statics files and network packets stay exactly as they are.What changes
BaseTile.Z,LandTile,StaticTile,StaticInfo, landscape events, client/server packets, large scale operations, tools and UI useshortinstead ofsbyte.ZRangehelper inShared/ZRange.cs:Min/Max(currently -128/127) replace hard-coded limits in tools, filter window and LSO windows.Clampreplaces(sbyte)casts that silently wrapped on overflow (e.g. scrolling Z from 125 by +10 used to give -121).ReadZ/WriteZread and write Z as a single signed byte, so disk and wire format are byte-identical to today.ImportHeightmap:(sbyte)(value + 128)relied on wrap-around; rewritten asvalue - 128(same result).Not changed
Testing
ZRangeTest(map block and static tile round-trip byte-identical,WriteZclamping).🤖 Generated with Claude Code