Hello,
I have finished the first version of my more heightlevels patch.
What did I do?
=========
I introduced a new configuration setting construction.allow_more_heightlevels. I furthermore added a new array _map_heightdata, which saves the heightlevel information when the patch is active. If the patch is not active, this array is just null, so it does not waste any space in this case. This especially applies to savegames. If the patch is active, the 4 bits in the old tile_height field of _m are ignored.
What works so far?
============
Terraforming mountains higher than height 16.
Saving and loading games (the patch being turned on or not) works. After loading, the setting saved in the game will be used. If the game was saved before the patch was introduced, it will be loaded with the patch being turned off.
Turning on and off the patch works. This is especially possible in game, so old games can be used with the patch being turned on. The patch even can be turned off again, however this is only possible if no mountain higher than height 15 exists (i.e. if the information can be saved in the old 4 bit datastructure).
What still needs to be done / what I want to implement in further versions?
==============================================
(1) The minimap currently displays just the color for maximal height for any fields higher than height 15.
(2) Terraforming works. However, I suspect that some array overflows will be possible if you try to terraform too big mountains in one click. Furthermore, I suspect that the current code is not that efficient. Maybe, using advanced data structures like HashSets would be appropriate instead of linear searches by coordinate in arrays.
(3) I didn't look at the painting code. As you can see on the screenshot, it works without glitches, but I didn't try it with heights > 20 so far. The argument concerning efficiency may apply here as well. Maybe one has to expect glitches when using bigger heights than height 20, I didn't test this so far.
(4) Looking at CmdLevelland in terraform_cmd.cpp, I don't really understand the code there. You get an unsigned int, the docs say it can have the value -1. Then you add it to another unsigned int, and finally you test for already being at sea level. So maybe here something has to be done. However, I used the levelling tool to generate the sample game I attach to this post.
(5) I did not touch map generation so far. Maybe someone familiar with the algorithms could do something senseful with the existent algorithms?
(6) Furthermore, I would very much like generated maps with really huge valleys, like e.g. the Inntal and its side valleys in the austrian mountains. Unfortunately, the current generators don't support this.
(7) Much easier than (6) will be generating maps with height levels much higher than just 16 from height maps.
(8) I didn't test or touch airplanes.
(9) One might make the sea level be a flexible setting, e.g. having a sea level at height 128. Things like allowing bridges only in flat water or making them really expensive in deep water will be possible.
Finally, a screenshot:
- A screenshot of a test game at height level 17.
- ScreenshotOfGameWithHeight17.png (66.9 KiB) Viewed 4797 times