Page 1 of 2
Patch: Advanced Terrain Schemes (r13191)
Posted: 27 May 2008 19:26
by CommanderZ
DEVELOPMENT PAUSED
until I finish the BMB patch
I saw many players requesting increased map variability like seen in Civilization IV or Age of Empires during the short period I'm present on TT-F. So here it is.
Technology
Very soon I realized it is extremely simple to make a clean cut into the map, but for pretty long time I found it almost impossible to make it look naturally with various map settings. I restarted the project two times until I found a working and well-looking solution: I create a second height map, create the inverted shape on it, apply some noise on it (which is in fact third full featured height map) and then substract it from the original game height map. I had to adapt HeightMapGenerate, HeightMapNormalize and their subfunctions to be able to create the noise map for me, so the changes to the tgp.cpp are quite wide. The pros of this are clear - I only adapted several functions and the map shaping is then matter of several lines of code. The cons is slightly longer generation time, but it is still incomparable with ECS industries.
Current map schemes
Please note that current schemes work in cooperation with other map settings - everything is dynamic. See attached pictures.
Two continents
Variation on continents or shore-to-shore maps. Creates two large landmasses separated by a canal.
Crater lake
Usually known as "mediterranean", this scheme creates a map with large circular lake in the middle.
This is all for now. I have several more ideas, but you can of course post some ideas/proposals. The code as it is allows me to add more schemes very quickly (as long as the can be simply mathematically described).
Known issues
- Small height map glitch in Two continents
Now I have to tame the GUI and SVN to share it with you.
Re: Advanced Terrain Schemes
Posted: 27 May 2008 19:28
by CommanderZ
Some Crater lake shots
Re: Advanced Terrain Schemes
Posted: 27 May 2008 20:05
by Zuu
Nice work you've done!
I've never really get into into the OpenTTD GUI, but I wish you good luck, and as others have managed it I guess you will have good chances to make it.
Also nice to see someone else using headlines in their longer posts to give them clear structure.

Re: Advanced Terrain Schemes
Posted: 27 May 2008 20:15
by el koeno
Looks awesome! Good job.
I don't know much about coding and such, but perhaps it might be useful if I make some suggestions for map scripts (or whatever you want to call them):
-It would be cool if you could set the number of continents, in you current two continent thing.
-Archipelago would be a challenge: lots of small islands. You would need ships trucks, and perhaps trains.
-Mountain pass: A huge mountain range with one low corridor. Not sure what this would look like actually.
Re: Advanced Terrain Schemes
Posted: 27 May 2008 20:23
by CommanderZ
Thanks for replies.
I don't know much about coding and such, but perhaps it might be useful if I make some suggestions for map scripts (or whatever you want to call them):
No. I have no idea how to do that.
EDIT: Sorry, I understood this as if you suggested to implement external map scripts - these are for me simply impossible to do. But map scheme suggestions? Of course!
-It would be cool if you could set the number of continents, in you current two continent thing.
You can generate multiple continent thing with original high water level setting. Maybe I will make 4 continents (4 corners), but some random continents...no. I'm substracting mathematically definable shapes from perlin noise map, Civ IV or AoE use a blob-based thing (I have no idea how to call it). The just say...put a randomly shaped blob of land here, put a blob of land there, I can't do that.
-Archipelago would be a challenge: lots of small islands. You would need ships trucks, and perhaps trains.
I thought about it. I think the easiest way will be to add fifth water level setting, with cca twice the water percentage value.
Mountain pass: A huge mountain range with one low corridor. Not sure what this would look like actually.
This is a job for later stage. Now I'm toying with shape of the landmasses, not their heights at all. But I can say this is planned. There are two limiting factors though: max. height is 16 and map border tiles must be water.
Re: Advanced Terrain Schemes
Posted: 27 May 2008 22:32
by el koeno
CommanderZ wrote:
EDIT: Sorry, I understood this as if you suggested to implement external map scripts - these are for me simply impossible to do. But map scheme suggestions? Of course!
Well, I
was thinking about suggesting external map scripts. But then again, I figured that would be waaay more complex than what you're doing here (which is already too complex for me

), so it'll probably have to wait. It would be awesome though.
Re: Advanced Terrain Schemes
Posted: 28 May 2008 11:54
by CommanderZ
Uuuf, I must say the GUI system in OTTD is pretty confusing to work with. Took me several hours to add one stupid drop-down box.
I would post the diff as the code is now basically ready to use, but I'm still
having no luck with the SVN.
Also, the bug with Crater lake is fixed and the one with Continents is not severe (I'm even starting to think it looks cool).
Re: Advanced Terrain Schemes
Posted: 28 May 2008 14:05
by Roujin
As a workaround until you figure out a way to do it yourself, you could give me the files you altered, plus tell me what revision it is based on and I can make a .diff out of it for you..
Re: Advanced Terrain Schemes
Posted: 29 May 2008 10:29
by el koeno
What's the atoll map scheme?
Re: Advanced Terrain Schemes
Posted: 29 May 2008 10:50
by doktorhonig
I'd love something like "mountain ridge", with lines of mountains. I've only managed to create them with heightmaps up to now.
Re: Advanced Terrain Schemes
Posted: 30 May 2008 10:52
by CommanderZ
Thanks to Roujin, I now have first releasable patch file. Please ignore Atoll in the game/ATS_ATOLL in the code, it is WIP.
I'm also attaching emodded executable and english lang file. Copy it over r13191 with game data.
I'd love something like "mountain ridge", with lines of mountains. I've only managed to create them with heightmaps up to now.
Could you please post example of such height map? I will have a look at it and see if it could be procedurally generated. I'm open to more scheme ideas!
I also got one more idea, how to use my code in order to improve TGen maps. The crappiest thing on current maps are the areas along map borders. They are created with not-smoothed 2d perlin noise. I could apply my noise map on them instead exactly in the same way I'm doing it with my templates. This would make the edges look smooth/rough depending on map settings and would fit perfectly with my templates. Do you like this idea? I heard devs want patches to do only one thing at time...
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 30 May 2008 11:14
by richk67
If you could create a totally separate patch that did a nice / better job of handling the map edges (at all scales from 64x64 up to 2048+), then Im sure it would be well received by the devs. Its a known area of weakness, where the current code does an adequate job - if your patch could visibly improve it, Im sure it would be appreciated.
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 30 May 2008 11:35
by CommanderZ
I could seperate it, but i would have to copy the most invasive changes I did to the TGen code - deglobalizing nearly all the functions TGen uses (all are inside tgp.cpp).
I got one idea now though. I could make a Better Edges patch and then ATS would be only its extension using its functions.
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 30 May 2008 11:57
by Roujin
CommanderZ wrote:I could seperate it, but i would have to copy the most invasive changes I did to the TGen code - deglobalizing nearly all the functions TGen uses (all are inside tgp.cpp).
I got one idea now though. I could make a Better Edges patch and then ATS would be only its extension using its functions.
Advice: Do the code changing even seperately. Or, even better, get in contact with the devs first, and tell them that you're planning to clean up the functions of TGen. Then start making the changes in logical and small steps.
If your changes are reasonable and acceptable, i think that's the best way to have them accepted. First do the codechanges, without introducing any new feature yet. If you're done with that, you can make the "better edges" fix on top of that, then the new feature (advanced schemes) on top of that.
edit: you didn't change the revision number in your .patch file...
edit: argh, seems i can't read. you wrote the revision number in your post...
one more thing: patches should be based on /trunk, not /src.
more edit: don't know what you're compiling with, but my gcc gives some warnings. Some double to int conversion, comparing unsigned with signed, and one that reads "warning: taking address of temporary" which can't be good
oh and I didn't ignore that "Atoll" option like you said, but tried it out. Gives nice results already if you set mountains and sea level to high
My suggestion for a setting would be "multiple continents" (like 4 or 5), for bigger maps, but I guess that will already be covered by Atoll?
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 30 May 2008 15:03
by CommanderZ
Advice: Do the code changing even seperately. Or, even better, get in contact with the devs first, and tell them that you're planning to clean up the functions of TGen. Then start making the changes in logical and small steps.
If your changes are reasonable and acceptable, i think that's the best way to have them accepted. First do the codechanges, without introducing any new feature yet. If you're done with that, you can make the "better edges" fix on top of that, then the new feature (advanced schemes) on top of that.
I will try to make the code as clean as possible. I will consider contacting devs once I have at least something to show. I don't have time this weekend anyways.
edit: you didn't change the revision number in your .patch file...
Revision numbers are quite weird, I'm creating the patches offline...is it problem? Is it possible to set rev number on my SVN? If it matters, I can always grab text exitor and replace all occurences of "Revison 7" with "Revision 13191". It is not that much work.
one more thing: patches should be based on /trunk, not /src.
Src is my local dir with code...I will change it to trunk to prevent errors. I thought it will take the files inside the dir, not the dir itself. I renamed the trunk to src in order to fit with the MSVS project file which is packed with the source.
more edit: don't know what you're compiling with, but my gcc gives some warnings. Some double to int conversion, comparing unsigned with signed, and one that reads "warning: taking address of temporary" which can't be good
I'm using MSVC++ 2008 Express and I'm getting no warnings.
oh and I didn't ignore that "Atoll" option like you said, but tried it out. Gives nice results already if you set mountains and sea level to high
Atoll should be a narrow circle of small flat circular/slightly elliptic islets. I'm still nowhere near result I imagine as ideal.
My suggestion for a setting would be "multiple continents" (like 4 or 5), for bigger maps, but I guess that will already be covered by Atoll?
I see this gonna be popular request...it seems I will have to look into it.
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 31 May 2008 09:03
by Roujin
CommanderZ wrote:edit: you didn't change the revision number in your .patch file...
Revision numbers are quite weird, I'm creating the patches offline...is it problem? Is it possible to set rev number on my SVN? If it matters, I can always grab text exitor and replace all occurences of "Revison 7" with "Revision 13191". It is not that much work.
Of course the numbers are resembling your local repository (rev7~ish) instead of the openttd repository. It's not a problem, but it would help people know what revision to apply it to if the numbers match

It should be fine if you do that with editor->replace like you said.
Also the automatic building tool BuildOTTD relies on those numbers, so people who can't compile on their own, only with that tool will only be able to test your patch if the correct revision stands in the file.
one more thing: patches should be based on /trunk, not /src.
Src is my local dir with code...I will change it to trunk to prevent errors. I thought it will take the files inside the dir, not the dir itself. I renamed the trunk to src in order to fit with the MSVS project file which is packed with the source.
Uhm, normally there is a directory structure like this:
[base dir] (often called trunk)
[base dir]/src
[base dir]/docs
[base dir]/{some other directories...}
the makefile should be located in the base dir for example, and the source files .c(pp)/.h(pp) are in /src or subdirectories of it
Now it is, lets say a standard, to base the patch on the base dir, to allow changes not only in the /src/* files, but also for example on the /docs/* files. So if you're using TurtoiseSVN just right click on your base dir (the one the src dir is in) and then on "create patch", instead of doing this in the src dir.
that should result in your patch file showing
Code: Select all
--- src/genworld_gui.cpp (revision 7)
+++ src/genworld_gui.cpp (working copy)
instead of
Code: Select all
--- genworld_gui.cpp (revision 7)
+++ genworld_gui.cpp (working copy)
more edit: don't know what you're compiling with, but my gcc gives some warnings. Some double to int conversion, comparing unsigned with signed, and one that reads "warning: taking address of temporary" which can't be good
I'm using MSVC++ 2008 Express and I'm getting no warnings.
yes, c++ compilers are quite different on what they give warnings.. as long as they're not errors it's not that critical though
My suggestion for a setting would be "multiple continents" (like 4 or 5), for bigger maps, but I guess that will already be covered by Atoll?
I see this gonna be popular request...it seems I will have to look into it.
I guess it is popular because the real world is like this with multiple continents, and maybe because maps in (O)TTD have always been one big land mass and it may be interesting and a new challenge if we can have multiple continents. Then you can't just connect everything with rail anymore, but also have to use planes/ships.

Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 26 Jun 2008 18:49
by Youri219
Just downloaded this to generate a map which I then wanted to load in a recent nightly. Why does this patch break savegame compatibility when (by the looks of it) it doesn't have to change anything in a game at all?
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 26 Jun 2008 19:30
by CommanderZ
There was a slight bump affecting how game settings are stored somewhere in 133** (which could possibly also affect savegames), I was fixing this in BMB today. I will jump back on ATS once BMB is finished. ATS will be slightly rewritten to be an extension of BMB, so I need it finished first.
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 27 Jun 2008 11:03
by Sarin
Some map suggestions from me:
Satelites: one large islands with several smaller around. Primary industries are on satelite islands, secondary are on the central one.
High and low: half map highland, half lowland. Quite similar to TTDX scenario of same name (does anyone remember that?)
None Shall Pass: two highlands separated by pass going through whole map.
Spiral: spiral of land with all secondary industries in the middle.
River Delta: I don't think it needs describing.
Streams: a map with a lot of small lakes and dozens of thin rivers going from one edge to another.
Also, is it possible to make some map affect towns/industries layout? Like having primary industries near one edge, secondary on the other side etc...
Re: Patch: Advanced Terrain Schemes (r13191)
Posted: 27 Jun 2008 12:33
by CommanderZ
Satelites: one large islands with several smaller around. Primary industries are on satelite islands, secondary are on the central one.
I'm planning this.
High and low: half map highland, half lowland. Quite similar to TTDX scenario of same name (does anyone remember that?)
Nice and simple, be sure this will be implemented once I get back to ATS.
None Shall Pass: two highlands separated by pass going through whole map.
This was already suggested and I must say I dream about it myself, but I'm very limited by the count of height levels (16) which prevents me from more detailed layouts like this.
Spiral: spiral of land with all secondary industries in the middle.
You mean the milky-way spiral shape? It would be really nice. But it would be very hard to make unless I found a nice formula how to calculate the beams.
River Delta: I don't think it needs describing.
I like this, but it has very complicated layout and also - it would look weird unless we had possibility to create land on map edges. All maps must be in fact islands now.
Streams: a map with a lot of small lakes and dozens of thin rivers going from one edge to another.
I'm planning something like this.
Also, is it possible to make some map affect towns/industries layout? Like having primary industries near one edge, secondary on the other side etc...
It surely is. I have an idea - it would be nice, if there were several different items (layouts) to define - I mean height/landmass distribution (that's what I'm doing now), population distribution, industry distribution and humidity distribution for tropical climate. I'm afraid of overcomplicating the patch though.
Thanks for feedback