stwe / MDCII

An unofficial project making from scratch to create an editable Anno 1602 world.
GNU General Public License v2.0
7 stars 2 forks source link

Your map format #6

Open siredmar opened 2 years ago

siredmar commented 2 years ago

Hi!

Would you mind explaining a little bit about your map format? Did you fully specify it yet? If so, it might be easily possible to write a converter that reads the original ISLAND5 chunks and creates your format.

Thanks for your efforts so far! Looks pretty amazing!

stwe commented 2 years ago

The map format so far represents only a single island with a width and a height. Two layers with the tiles follow. I will explain the details here later. Of course it is not finished yet. I think there will be some changes in the next few weeks. The ticket remains open. Questions about the map format will be discussed here then.

For the beginning, I think it would be a good idea if we could convert the SCP files. Then we could very easily choose from different islands to build on.

siredmar commented 2 years ago

Sounds like a plan. Just for the record, i'd covert everything leaving only standard and custom types, e. g. map files to your custom Format, textures to PNG,...

stwe commented 2 years ago

....can you please explain this in more detail

siredmar commented 2 years ago

Sure. I don't see the requirement of a real drop in replacement. I'd make a hard cut with the original files. I propose converting everything to something we can handle better. Looking at the horrifying COD format, the first big step was taken towards that goal by converting it to JSON. The SCP format with that silly chunks is the next example of how to not do things right. Same with .ZEI and .BSH formats. Let's simply put them into PNGs or whatever is more easily handled instead of a custom bitmap format they invented.

There could be a converter tool, that puts everything in the right place before running the actual MDCII. This way it would be possible to just convert old savegames into the new game and live happily ever after. :)

stwe commented 2 years ago

I packed everything in Benno4j into a few TileAtlas files (a PNG has many images). The TileAtlas can then be loaded directly into the GPU. What doesn't work is that everything is packed into PNGs and distributed with this repo. The TileAtlas files can be created/cached once at the beginning. That's how I did it with the haeuser.cod too. There is a haeuser.json created at startup, if not already there. Unfortunately the initial chaching of the resources takes some time. The copyright must be respected and pointed out here at every place - that is important to me.

siredmar commented 1 year ago

I'd not ship the PNGs with this repo. Our understanding is quite the same. Generate everything out of the freaky original file formats to something more usable on first startup and cache it somewhere.

stwe commented 1 year ago

The current map format version 0.2-dev:

{
    "version": "0.1-DEV",
    "world": {
        "width":
        "height":
    },
    "islands": [
        {
            "width":
            "height":
            "x":                               // x position in the world
            "y":                               // y position in the world
            "climate": "SOUTH",   // NORTH or SOUTH
            "layers": [
                {
                    "coast": [              // only (water) tiles with height of 0
                        {
                            "id":              // building ID
                            "rotation":     // building rotation
                            "x":               // building x
                            "y":               // building y
                        },
                        {
                            // next tile
                        }
                    ]
                } ,
                {
                    "terrain": []            // terrain tiles only with height of 20, including embankment
                },
                {
                    "buildings": []       // additional buildings with a height of 20
                },
                {
                    "figures": [
                        {
                            "id":              // figure ID
                            "rotation":     // figure rotation
                            "animation" : // nr of animation
                        },
                        {
                            // next figure tile
                        }
                     ]
                }
            ]
        },
        {
            // next island
        }
    ]
}
siredmar commented 1 year ago

Great! But, i'd introduce an additional version field on top level of the JSON.

example

{
    "version": "v1alpha1",
    "world": {
        "width":  50
        "height": 50
    }
}
stwe commented 1 year ago

New: The file extension .sav is used for savegames and .map for worlds without additional buildings. The reason is that things like the number of resources (wood, stones ...) have to be saved later in a savegame. The map files should only be used to start a new game.