This looks like a really neat idea; it would be great to be able to create a "scenario" and let the user choose the NewGRFs to use and the map size they want to play on.
I've taken the code from
http://devs.openttd.org/~terkhen/patches/scenario/ and made the few small tweaks needed to apply the patches to master. I've then gone ahead and extended it to support loading extended heightmaps from .ehm files (really just tar files, as described on the wiki at
http://wiki.openttd.org/Terkhen/Scenario_format); so far only the height layer and the town layer are supported.
The code can be seen at
https://github.com/ZornsLemma/OpenTTD/t ... -heightmap. There are some (not very exciting) sample/test extended heightmaps in the eh-test directory in that repository. If anyone would like to give this a try please do, although the code is beta quality at best and while it works for me it may fall over horribly with inputs prepared by anyone else.
You can open an extended heightmap by choosing "Play heightmap" from the main menu and then choosing a .ehm file, or by starting the scenario editor, choosing "Load heightmap" and then choosing a .ehm file from there. There's currently no support for saving as an extended heightmap.
The text files mostly follow the spec on the wiki but have a few small discrepancies; the main ones I can think of are:
- There's currently no default for the 'file' property; you have to specify this explicitly.
- The town layer in metadata.txt is introduced by '[town_layer]' not '[town_file]' as per the spec (an oversight, easy to fix but I won't do it just now)
- The town 'name' property is not optional
- Towns have a 'size' property which takes values small/medium/large/random instead of a 'buildings' property; I couldn't see how to implement the 'buildings' property.
- You can specify a numeric 'radius' property in the [town_layer] section of metadata.txt, and you can override it for a specific town with a 'radius' property in the town file. This determines how far from the specified posx/posy position the code will allow the town to be created if the specified position isn't suitable. It defaults to 5; you can specify 'radius=0' to disable this and only allow the town to be created at the exact specified position.
You might find it helpful to look at the examples/tests in the eh-test directory; the component files are also present in the repository in subdirectories of the eh-test directory, or you can just unpack the .ehm files with something like "tar xvf vg1.ehm". If you hit problems please post your .ehm file here and I'll take a look.
I'd appreciate it if someone familiar with the OpenTTD code could give this a bit of a review, particularly the comments containing the string "EHTODO:" which indicate what I think are the main potential problems. It would be good to know if the basic approach I've taken to extending the earlier work is sound before putting any more effort into this. The individual commits on the branch are just me talking to myself as I worked on the code; anyone interested in reviewing this should just look at the diff between the last commit on my branch and master.
I should say that the earlier work was really helpful in getting this started; I have very little prior experience with the OpenTTD code and I'd have been struggling to find how to plumb my changes in properly without it.
Cheers.
Steve