minor update

This commit is contained in:
T1ti
2024-06-17 23:17:07 +02:00
parent 063297b5b6
commit aac2960759
4 changed files with 15 additions and 3 deletions

View File

@@ -99,6 +99,7 @@ void AsyncLoader::process()
std::lock_guard<std::mutex> const lock(_guard); std::lock_guard<std::mutex> const lock(_guard);
object->error_on_loading(); object->error_on_loading();
LogError << "Caught unknown error." << std::endl;
if (object->is_required_when_saving()) if (object->is_required_when_saving())
{ {
@@ -144,6 +145,10 @@ void AsyncLoader::ensure_deletable (AsyncObject* object)
AsyncLoader::AsyncLoader(int numThreads) AsyncLoader::AsyncLoader(int numThreads)
: _stop (false) : _stop (false)
{ {
// use half of the available threads
unsigned int maxThreads = std::thread::hardware_concurrency() / 2;
numThreads = maxThreads > numThreads ? maxThreads : numThreads;
for (int i = 0; i < numThreads; ++i) for (int i = 0; i < numThreads; ++i)
{ {
_threads.emplace_back (&AsyncLoader::process, this); _threads.emplace_back (&AsyncLoader::process, this);
@@ -152,7 +157,10 @@ AsyncLoader::AsyncLoader(int numThreads)
AsyncLoader::~AsyncLoader() AsyncLoader::~AsyncLoader()
{ {
_stop = true; {
std::unique_lock<std::mutex> lock(_guard);
_stop = true;
}
_state_changed.notify_all(); _state_changed.notify_all();
for (auto& thread : _threads) for (auto& thread : _threads)

View File

@@ -423,10 +423,12 @@ void MapIndex::unloadTiles(const TileIndex& tile)
void MapIndex::unloadTile(const TileIndex& tile) void MapIndex::unloadTile(const TileIndex& tile)
{ {
// unloads a tile with givn cords // unloads a tile with given cords
if (tileLoaded(tile)) if (tileLoaded(tile))
{ {
Log << "Unload Tile " << tile.x << "-" << tile.z << std::endl; Log << "Unload Tile " << tile.x << "-" << tile.z << std::endl;
AsyncLoader::instance().ensure_deletable(mTiles[tile.z][tile.x].tile.get());
mTiles[tile.z][tile.x].tile = nullptr; mTiles[tile.z][tile.x].tile = nullptr;
_n_loaded_tiles--; _n_loaded_tiles--;
} }

View File

@@ -9,7 +9,6 @@
#include <QString> #include <QString>
#include <chrono> #include <chrono>
#include <QJsonArray> #include <QJsonArray>
#include <noggit/Log.h>
namespace Noggit::Project namespace Noggit::Project
{ {

View File

@@ -2,6 +2,7 @@
#include "WMOGroupRender.hpp" #include "WMOGroupRender.hpp"
#include <noggit/WMO.h> #include <noggit/WMO.h>
#include <noggit/Log.h> // LogDebug
using namespace Noggit::Rendering; using namespace Noggit::Rendering;
@@ -346,6 +347,8 @@ void WMOGroupRender::initRenderBatches()
_render_batch_mapping[batch.vertex_start + i] = static_cast<unsigned>(batch_counter + 1); _render_batch_mapping[batch.vertex_start + i] = static_cast<unsigned>(batch_counter + 1);
} }
} }
else
LogError << "WMO has incorrect render batch data. batch.vertex_end < batch.vertex_start" << std::endl;
std::uint32_t flags = 0; std::uint32_t flags = 0;