Skip to content

Commit 33bb8c5

Browse files
committed
Store map names in json, instead of ID
1 parent 10cb27f commit 33bb8c5

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

src/MAP.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,16 @@ void MAPExporter::saveObject(MapObject& obj, TIMPalette& pal, std::filesystem::p
411411
bool MAPExporter::save(std::filesystem::path outputDir)
412412
{
413413
// write JSON
414-
std::ofstream(outputDir / "map.json") << map.to_json().dump(2);
414+
auto json = map.to_json();
415+
for (int i = 0; i < 10; i++)
416+
{
417+
auto& val = json["elements"]["warp"][std::to_string(i)]["map"];
418+
if (val < mapEntries.size())
419+
val = mapEntries[val].data.name;
420+
else
421+
val = "";
422+
}
423+
std::ofstream(outputDir / "map.json") << json.dump(2);
415424

416425
// write background images
417426
auto images = tfs.getImages(map);

src/MAP.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,15 @@ class MAPExporter
237237
TFSFile tfs;
238238
MapEntry mapEntry;
239239
std::map<uint32_t, Model> doors;
240+
std::array<MapEntry, 255> mapEntries;
240241

241242
public:
242-
MAPExporter(MapFile map, TFSFile tfs, MapEntry mapEntry, std::map<uint32_t, Model> doors)
243+
MAPExporter(MapFile map, TFSFile tfs, MapEntry mapEntry, std::map<uint32_t, Model> doors, std::array<MapEntry, 255> mapEntries)
243244
: map(map)
244245
, tfs(tfs)
245246
, mapEntry(mapEntry)
246247
, doors(doors)
248+
, mapEntries(mapEntries)
247249
{
248250
}
249251

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void exportMaps(std::filesystem::path dataPath, std::filesystem::path outputPath
299299
}
300300
}
301301

302-
MAPExporter exporter(map, tfs, entry, doors);
302+
MAPExporter exporter(map, tfs, entry, doors, entries);
303303

304304
bool success = exporter.save(outputDir);
305305
if (success)

0 commit comments

Comments
 (0)