From 355df510334a162ae22ca1d0a856dd4c29ac52d4 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Mon, 5 Sep 2022 21:42:33 +0400 Subject: [PATCH] Speedup generating empty map --- mapeditor/windownewmap.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/mapeditor/windownewmap.cpp b/mapeditor/windownewmap.cpp index 57fbefa83..6ba9a8efe 100644 --- a/mapeditor/windownewmap.cpp +++ b/mapeditor/windownewmap.cpp @@ -54,13 +54,10 @@ std::unique_ptr generateEmptyMap(CMapGenOptions & options) map->width = options.getWidth(); map->height = options.getHeight(); map->twoLevel = options.getHasTwoLevels(); - + map->initTerrain(); map->getEditManager()->clearTerrain(&CRandomGenerator::getDefault()); - map->getEditManager()->getTerrainSelection().selectRange(MapRect(int3(0, 0, 0), options.getWidth(), options.getHeight())); - map->getEditManager()->drawTerrain(Terrain("grass"), &CRandomGenerator::getDefault()); - //window->controller.setMap(std::move(map)); return std::move(map); } @@ -98,22 +95,15 @@ void WindowNewMap::on_okButtong_clicked() auto progressBarWnd = new GeneratorProgress(generator, this); progressBarWnd->show(); - - - //std::thread generate(&::generateRandomMap, std::ref(generator), static_cast(parent())); - //progressBarWnd->update(); - //generate.join(); - - //generateRandomMap(generator, static_cast(parent())); + auto f = std::async(std::launch::async, &CMapGenerator::generate, &generator); progressBarWnd->update(); nmap = f.get(); } else - { + { auto f = std::async(std::launch::async, &::generateEmptyMap, std::ref(mapGenOptions)); nmap = f.get(); - //nmap = generateEmptyMap(mapGenOptions, static_cast(parent())); }