OnlineCop / kq-fork

Fork of KQ r910. Just for fun.
GNU General Public License v2.0
15 stars 9 forks source link

Map* utilities should probably be removed or replaced #53

Closed nkutya closed 8 years ago

nkutya commented 8 years ago

Now that kq-fork uses TMX instead of own map format, the map* utities (mapdiff, mapdraw and mapdump) do not succesfully compile anymore, complaining about the lack of load_s_map and load_s_entity functions. This results in annoying clutter during make (aka make all). Should they be replaced by their TMX equivalents or removed altogether?

OnlineCop commented 8 years ago

You are correct. If we are now able to go 100% with the TMX format, we'll switch over to using Tiled (http://www.mapeditor.org/) exclusively to create the map content. I'm not sure how we're planning to deal with entities (NPCs) that were built into the maps, but if those could all be exported to LUA, and then created dynamically instead of hard-coding them, that would be the best all-around.

You should be able to remove the map editor files from any make build script, since we no longer need those files.

ghost commented 8 years ago

Laziness on my part. mapdump and mapdraw are indeed obsolete as the tiled editor does that. The function of mapdiff isn't - how much is this used? I can attempt to rewrite if needed.

At the moment the data from s_entity is stored as properties in the TMX file - each entity is an object in the entities objectlayer and the values from s_entity are stored in its custom properties. In my mind the best way would be to store only the entity's ID (its name preferably) and a sprite number so it can be shown in the map editor. All other properties would then be in the script file. property example First thing to do is to decide which properties actually need saving for each entity (some things saved now aren't needed)

OnlineCop commented 8 years ago

MapDiff isn't needed anymore either. According to TeamTerradactyl, it was actually a precursor to MapDump, and its goal was to give a textual difference of the binary data so we could see when something changed between two revisions. MapDump, with its --text or --json options, let us output the entire contents of one or more files, which can be diffed manually.

If TMX is working "enough" that the map editor can be totally deprecated, and we've already dumped all the .map information (including all these embedded NPC values) to TMX, I think it's safe to remove all those Map* utilities from maps/.

If I'm not mistaken, all .map (and now, all .tmx) files have a corresponding .lua file, so it should be fairly simple to dump those values into LUA. There was one oddity that I saw in the map data concerning those entities, though. The editor looped from 0..MAX_ENTITIES (or 0..MAX_ENTITIES_PER_MAP) until it read in an entity whose chrx was set to 0. When that was found, it broke from the loop. There may be "more entities" in the map data, but they were to be considered garbage/remnants, and were never read in. So if we have any automated script to parse those files, we may need to be aware of that, and ignore any extra data in the same way.

ghost commented 8 years ago

The converter I wrote (maps/maptiled.py) adds all entities with eid greater than zero. That made sense to me at the time, maybe I got it wrong. It would be good to do a manual check of the TMX files vs. originals to see what's missing/wrong, but I haven't had time to do that yet.