Jerenaux / phaserquest

Reproduction of Mozilla's BrowserQuest using Phaser, socket.io and Node.js
http://www.dynetisgames.com/2017/03/18/phaser-quest/
MIT License
374 stars 126 forks source link

Format script does not work with Tiled versions higher than 1.1.6 #19

Closed frycz closed 4 years ago

frycz commented 4 years ago

Context

Map JSON format has changed in Tiled in versions higher than 1.1.6. Cause of that provided tmx map in phaserquest won't be exported to JSON format supported by format script.

Issue

format script throws an error when formatting JSON map exported from Tiled in versions higher than 1.1.6:

➜  server git:(master) node -e 'require("./format").format()'
Formatting ...
/Users/adamsawicki/Kodowanie/phaserquest/js/server/format.js:62
                    var tileProperties = map.tilesets[0].tileproperties[layer.data[j]-1];
                                                                       ^

TypeError: Cannot read property '-1' of undefined
    at /Users/adamsawicki/Kodowanie/phaserquest/js/server/format.js:62:72
    at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)

This, in turn, makes running edited map impossible.

Possible solution

Provide information to developers that using Tiled version 1.1.6 or lower is a workaround for the issue.

Alternative solution

Modify format script to the new JSON format.

Additional information

More details can be found in this thread: https://discourse.mapeditor.org/t/are-old-versions-of-tiled-available/3721/4

Jerenaux commented 4 years ago

Many thanks for spotting and documenting the issue!