From fe7a0c9ad85481f34371be8cdab54aec14967f27 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 10 May 2020 15:22:58 +0200 Subject: Tools/Extractors: Don't try extracting maps that have no wdt defined in Map.db2 --- src/tools/map_extractor/System.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/tools/map_extractor') diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index 16fb142ff08..ecb4d00358e 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -238,19 +238,21 @@ void ReadMapDBC() exit(1); } - map_ids.resize(db2.GetRecordCount()); - std::unordered_map idToIndex; + map_ids.reserve(db2.GetRecordCount()); + std::unordered_map idToIndex; for (uint32 x = 0; x < db2.GetRecordCount(); ++x) { DB2Record record = db2.GetRecord(x); if (!record) continue; - map_ids[x].Id = record.GetId(); - map_ids[x].WdtFileDataId = record.GetInt32("WdtFileDataID"); - map_ids[x].Name = record.GetString("MapName"); - map_ids[x].Directory = record.GetString("Directory"); - idToIndex[map_ids[x].Id] = x; + MapEntry map; + map.Id = record.GetId(); + map.WdtFileDataId = record.GetInt32("WdtFileDataID"); + map.Name = record.GetString("MapName"); + map.Directory = record.GetString("Directory"); + idToIndex[map.Id] = map_ids.size(); + map_ids.push_back(map); } for (uint32 x = 0; x < db2.GetRecordCopyCount(); ++x) @@ -259,15 +261,17 @@ void ReadMapDBC() auto itr = idToIndex.find(copy.SourceRowId); if (itr != idToIndex.end()) { - MapEntry id; - id.Id = copy.NewRowId; - id.WdtFileDataId = map_ids[itr->second].WdtFileDataId; - id.Name = map_ids[itr->second].Name; - id.Directory = map_ids[itr->second].Directory; - map_ids.push_back(id); + MapEntry map; + map.Id = copy.NewRowId; + map.WdtFileDataId = map_ids[itr->second].WdtFileDataId; + map.Name = map_ids[itr->second].Name; + map.Directory = map_ids[itr->second].Directory; + map_ids.push_back(map); } } + map_ids.erase(std::remove_if(map_ids.begin(), map_ids.end(), [](MapEntry const& map) { return !map.WdtFileDataId; }), map_ids.end()); + printf("Done! (" SZFMTD " maps loaded)\n", map_ids.size()); } -- cgit v1.2.3