tibiamaps / tibia-maps-script

:wrench: A command-line utility to convert between binary Tibia maps and human-readable forms of the map data.
https://tibiamaps.io/
MIT License
17 stars 8 forks source link

Export Tibia 11-compatible minimap files #18

Closed mathiasbynens closed 7 years ago

mathiasbynens commented 7 years ago

https://tibiamaps.io/guides/minimap-file-format

mathiasbynens commented 7 years ago

The images generated by our script are visually identical to the images generated by the Tibia 11 installer’s auto-converter. I’ve confirmed this as follows:

for file in minimap/*.png; do
    result=$(compare -metric AE "${file}" "${file/minimap/minimap-converted-by-installer}" /tmp/diff.png 2>&1);
    if [ "${result}" != '0' ]; then
        echo "${result} incorrect pixels in ${file}";
    fi;
done;

# compare -metric AE minimap{,-converted-by-installer}/Minimap_WaypointCost_33024_30976_7.png diff.png

However, they are still not read properly by the Tibia 11 client. It looks like Tibia 11 relies upon some image metadata.

The Cipsoft version of the images has this in their EXIF data (whereas our images don’t):

Palette                         : (Binary data 768 bytes, use -b option to extract)
Pixels Per Unit X               : 3780
Pixels Per Unit Y               : 3780
Pixel Units                     : meters

The three pixel fields can be added using exiftool:

exiftool -PixelsPerUnitX=3780 -PixelsPerUnitY=3780 minimap-generated-by-our-script/*.png
mathiasbynens commented 7 years ago

Minimap files for this area in Rookgaard: https://tibiamaps.io/map#32015,32144,7:1

The images in all ZIP files are visually, pixel-by-pixel identical.

TODO: figure out how the images in the ZIPs differ. (Must be some metadata.)

mathiasbynens commented 7 years ago

Base64-encoded palette data for Color images:

AAAAAAAzAABmAACZAADMAAD/ADMAADMzADNmADOZADPMADP/AGYAAGYzAGZmAGaZAGbMAGb/AJkAAJkzAJlmAJmZAJnMAJn/AMwAAMwzAMxmAMyZAMzMAMz/AP8AAP8zAP9mAP+ZAP/MAP//MwAAMwAzMwBmMwCZMwDMMwD/MzMAMzMzMzNmMzOZMzPMMzP/M2YAM2YzM2ZmM2aZM2bMM2b/M5kAM5kzM5lmM5mZM5nMM5n/M8wAM8wzM8xmM8yZM8zMM8z/M/8AM/8zM/9mM/+ZM//MM///Z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R0dHSEhISUlJSkpKS0tLTExMTU1NTk5OT09PUFBQUVFRUlJSU1NTVFRUVVVVVlZWV1dXWFhYWVlZWlpaW1tbXFxcXV1dXl5eX19fYGBgYWFhYmJiY2NjZGRkZWVlZmZmZ2dnaGhoaWlpampqa2trbGxsbW1tbm5ub29vcHBwcXFxcnJyc3NzdHR0dXV1dnZ2d3d3eHh4eXl5enp6e3t7fHx8fX19fn5+f39/gICAgYGBgoKCg4ODhISEhYWFhoaGh4eHiIiIiYmJioqKi4uLjIyMjY2Njo6Oj4+PkJCQkZGRkpKSk5OTlJSUlZWVlpaWl5eXmJiYmZmZmpqam5ubnJycnZ2dnp6en5+foKCgoaGhoqKio6OjpKSkpaWlpqamp6enqKioqampqqqqq6urrKysra2trq6ur6+vsLCwsbGxsrKys7OztLS0tbW1tra2t7e3uLi4ubm5urq6u7u7vLy8vb29vr6+v7+/wMDAwcHBwsLCw8PDxMTExcXFxsbGx8fHyMjIycnJysrKy8vLzMzMzc3Nzs7Oz8/P0NDQ0dHR0tLS09PT1NTU1dXV1tbW19fX2NjY2dnZ2tra29vb3Nzc3d3d3t7e39/f4ODg4eHh4uLi4+Pj5OTk5eXl5ubm5+fn6Ojo6enp6urq6+vr7Ozs7e3t7u7u7+/v8PDw8fHx8vLy8/Pz9PT09fX19vb29/f3+Pj4+fn5+vr6/wAA/wAA/wAA/wD///8A
mathiasbynens commented 7 years ago

Confirmed: it’s the palettes. The Tibia 11 client expects a specific palette to be used for the Color images, and another for the WaypointCost images. :(

mathiasbynens commented 7 years ago

https://github.com/tibiamaps/tibia-minimap-png can be used to generate the PNGs.

mathiasbynens commented 7 years ago

The only remaining item is the minimapmarkers.bin file.

I’ve generated a floor-07-markers.json with the contents generated by this script:

const minX = 32256;
const minY = 32000;
const z = 7;
const res = [];
for (let deltaY = 0; deltaY < 256; deltaY++) {
    const y = minY + deltaY;
    for (deltaX = 0; deltaX < 256; deltaX++) {
        const x = minX + deltaX;
        const marker = {
            description: `Marker: ${x},${y},${z}`,
            icon: '!',
            x: x,
            y: y,
            z: z
        };
        res.push(marker);
    }
}
const obj = { 12612507: res };
copy(obj);

Then I converted it into a .map file (marker-test-map.zip) which I then converted to minimapmarkers.bin through the Tibia 11 installer.

mathiasbynens commented 7 years ago

minimapmarker-test.zip