From 09ae7e52e2cbc21eb11b57b5df8b4d511c2b828b Mon Sep 17 00:00:00 2001 From: T1ti <40864460+T1ti@users.noreply.github.com> Date: Tue, 29 Oct 2024 03:11:16 +0100 Subject: [PATCH] only load md5minimaptrnaslate data once in clientData instead of on every map load --- src/external/blizzard-archive-library | 2 +- src/external/blizzard-database-library | 2 +- src/noggit/map_index.cpp | 21 +++++++++++++++++---- src/noggit/map_index.hpp | 2 +- src/noggit/rendering/WorldRender.cpp | 5 +++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/external/blizzard-archive-library b/src/external/blizzard-archive-library index 07d3d1d6..2a150d76 160000 --- a/src/external/blizzard-archive-library +++ b/src/external/blizzard-archive-library @@ -1 +1 @@ -Subproject commit 07d3d1d68485be2ed8398773cb517147e644996c +Subproject commit 2a150d766abc11885cf71111ffee852558b6a86f diff --git a/src/external/blizzard-database-library b/src/external/blizzard-database-library index 8e277380..d0b399cb 160000 --- a/src/external/blizzard-database-library +++ b/src/external/blizzard-database-library @@ -1 +1 @@ -Subproject commit 8e27738046e944065796764cb92361422901e505 +Subproject commit d0b399cb52da1d98d174a93c4ba939caeffe55e6 diff --git a/src/noggit/map_index.cpp b/src/noggit/map_index.cpp index 6b6619b4..6137f269 100755 --- a/src/noggit/map_index.cpp +++ b/src/noggit/map_index.cpp @@ -114,6 +114,7 @@ MapIndex::MapIndex (const std::string &pBasename, int map_id, World* world, /// this is the theory. Sadly, we are also compiling on 64 bit machines with size_t being 8 byte, not 4. Therefore, we can't do the same thing, Blizzard does in its 32bit executable. //theFile.read( &(mTiles[0][0]), sizeof( 8 * 64 * 64 ) ); + // We could skip for WMO only maps for (int j = 0; j < 64; ++j) { for (int i = 0; i < 64; ++i) @@ -121,13 +122,17 @@ MapIndex::MapIndex (const std::string &pBasename, int map_id, World* world, theFile.read(&mTiles[j][i].flags, 4); theFile.seekRelative(4); + mTiles[j][i].tile = nullptr; + + if (!(mTiles[j][i].flags & 1)) + continue; + std::stringstream adt_filename; adt_filename << "World\\Maps\\" << basename << "\\" << basename << "_" << i << "_" << j << ".adt"; - mTiles[j][i].tile = nullptr; mTiles[j][i].onDisc = Noggit::Application::NoggitApplication::instance()->clientData()->existsOnDisk(adt_filename.str()); - if (mTiles[j][i].onDisc && !(mTiles[j][i].flags & 1)) + if (mTiles[j][i].onDisc) { mTiles[j][i].flags |= 1; changed = true; @@ -1080,6 +1085,12 @@ void MapIndex::loadMaxUID() void MapIndex::loadMinimapMD5translate() { + auto& minimap_md5translate = Noggit::Application::NoggitApplication::instance()->clientData()->_minimap_md5translate; + + // already loaded. + if (minimap_md5translate.empty()) + return; + if (!Noggit::Application::NoggitApplication::instance()->clientData()->exists("textures/minimap/md5translate.trs")) { LogError << "md5translate.trs was not found. " @@ -1125,7 +1136,7 @@ void MapIndex::loadMinimapMD5translate() if (cur_dir.length()) { - _minimap_md5translate[cur_dir.toStdString()][line_split[0].toStdString()] = line_split[1].toStdString(); + minimap_md5translate[cur_dir.toStdString()][line_split[0].toStdString()] = line_split[1].toStdString(); } } @@ -1147,7 +1158,9 @@ void MapIndex::saveMinimapMD5translate() { QTextStream out(&file); - for (auto it = _minimap_md5translate.begin(); it != _minimap_md5translate.end(); ++it) + auto const& minimap_md5translate = Noggit::Application::NoggitApplication::instance()->clientData()->_minimap_md5translate; + + for (auto it = minimap_md5translate.begin(); it != minimap_md5translate.end(); ++it) { out << "dir: " << it->first.c_str() << "\n"; // save dir diff --git a/src/noggit/map_index.hpp b/src/noggit/map_index.hpp index 8ff7e76f..216c091c 100755 --- a/src/noggit/map_index.hpp +++ b/src/noggit/map_index.hpp @@ -272,7 +272,7 @@ private: public: int const _map_id; - std::unordered_map> _minimap_md5translate; + // std::unordered_map> _minimap_md5translate; std::string globalWMOName; ENTRY_MODF wmoEntry; public: diff --git a/src/noggit/rendering/WorldRender.cpp b/src/noggit/rendering/WorldRender.cpp index 7ab0d55a..6f9491db 100755 --- a/src/noggit/rendering/WorldRender.cpp +++ b/src/noggit/rendering/WorldRender.cpp @@ -970,7 +970,7 @@ void WorldRender::draw (glm::mat4x4 const& model_view continue; glm::mat4x4 identity_mtx = glm::mat4x4{ 1 }; - auto const extents = selection_group.getExtents(); + auto const& extents = selection_group.getExtents(); Noggit::Rendering::Primitives::WireBox::getInstance(_world->_context).draw(model_view , projection , identity_mtx @@ -2067,7 +2067,8 @@ bool WorldRender::saveMinimap(TileIndex const& tile_idx, MinimapRenderSettings* auto sstream = std::stringstream(); sstream << map_name << "\\map" << tile_idx.x << "_" << std::setfill('0') << std::setw(2) << tile_idx.z << ".blp"; std::string tilename_left = sstream.str(); - _world->mapIndex._minimap_md5translate[map_name][tilename_left] = tex_name; + auto& minimap_md5translate = Noggit::Application::NoggitApplication::instance()->clientData()->_minimap_md5translate; + minimap_md5translate[map_name][tilename_left] = tex_name; } catch(MapDB::NotFound) {