[Fixed]Terrain generation glitch
- CommanderABab
- AB
- Posts: 11246
- Joined: 07 Jun 2016, 21:12
- Plugins: Showcase Store
- Version: Beta
-
Plugin Creator
Platform
- Sometheotown mayor
- Has uncountable inhabitants
- Posts: 1548
- Joined: 28 Jan 2017, 21:37
- Location: Somewhere in the middle of russia
- Plugins: Showcase Store
-
Platform
- Sometheotown mayor
- Has uncountable inhabitants
- Posts: 1548
- Joined: 28 Jan 2017, 21:37
- Location: Somewhere in the middle of russia
- Plugins: Showcase Store
-
Platform
- Lobby
- Developer
- Posts: 3719
- Joined: 26 Oct 2008, 12:34
- Plugins: Showcase Store
- Version: Beta
-
Platform
It's a bug in a recent saving optimization of ground tiles.
For the optimization I packed the height (16 bit value) and surface slope heightDX, heightDY (each 8 bit values) into a single variable hxy:
This code is absolutely fine, as long as heightDX and heightDY are not negative. If they are, they will be proceeded by 1s so the OR opteration will always yield 1s for the first 16 bits. This results in a height value of -1 after the next loading.
The solution is to apply masks so that proceeding bits will be cropped:
Unfortunately it's a saving problem and therefore cities which already have this issue will continue to have it.
For the optimization I packed the height (16 bit value) and surface slope heightDX, heightDY (each 8 bit values) into a single variable hxy:
Code: Select all
int hxy = (height << 16) | (heightDX << 8) | heightDY;
The solution is to apply masks so that proceeding bits will be cropped:
Code: Select all
int hxy = (height << 16) | ((heightDX << 8) & 0xF0) | (heightDY & 0xF);
- Sometheotown mayor
- Has uncountable inhabitants
- Posts: 1548
- Joined: 28 Jan 2017, 21:37
- Location: Somewhere in the middle of russia
- Plugins: Showcase Store
-
Platform
- Sometheotown mayor
- Has uncountable inhabitants
- Posts: 1548
- Joined: 28 Jan 2017, 21:37
- Location: Somewhere in the middle of russia
- Plugins: Showcase Store
-
Platform
- AndrewIsCool1111
- Villager
- Posts: 16
- Joined: 05 Mar 2017, 22:56
- Location: Guatemala
- Plugins: Showcase Store
-
Platform
- Ahmad Nur Aizat
- TheoTown Veteran
- Posts: 8260
- Joined: 25 Oct 2016, 15:20
- Location: Johor Bahru
- Plugins: Showcase Store
- Version: Beta
- Contact:
-
Plugin Creator
Platform
- Mayor Jeffrey IX
- TheoTown Cartographer
- Posts: 988
- Joined: 05 Apr 2017, 16:48
- Location: Right here
- Plugins: Showcase Store
-
Platform