From 3bf49ee7d4458c51bafdb5581c288fbd0f71d532 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 9 Sep 2023 23:10:03 -0400 Subject: Support the new dump format with locked attribute. --- mapman/src/mapdump.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'mapman/src/mapdump.cpp') diff --git a/mapman/src/mapdump.cpp b/mapman/src/mapdump.cpp index 6d8fbcc..af32a0f 100644 --- a/mapman/src/mapdump.cpp +++ b/mapman/src/mapdump.cpp @@ -1,13 +1,16 @@ #include "mapdump.hpp" +#include + #include bool load_dump(gzFile f, map_t &d) { - map_t ret; if (gzread(f, &d.id, 4) < 4) return false; int name_len; if (gzread(f, &name_len, 4) < 4) return false; + d.locked = ((name_len & 0xf0000000) != 0); + name_len &= 0x7fffffff; if (name_len) { char *name = new char[name_len]; @@ -16,7 +19,7 @@ bool load_dump(gzFile f, map_t &d) delete[] name; return false; } - d.custom_name = std::string(name); + d.custom_name = std::string(name, name_len); delete[] name; } else d.custom_name = std::string(); if (gzread(f, d.map_data.data(), 128 * 128) < 128 * 128) @@ -48,5 +51,8 @@ std::vector load_tally(const char *fn) gzread(f, &t, 4); ret.push_back(t); } + std::sort(ret.begin(), ret.end()); + auto uend = std::unique(ret.begin(), ret.end()); + ret.erase(uend, ret.end()); return ret; } -- cgit v1.2.3