diff options
Diffstat (limited to 'mapman/src/mapdump.cpp')
-rw-r--r-- | mapman/src/mapdump.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
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 <algorithm> + #include <zlib.h> 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<int> 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; } |