From: Loïc Blot Date: Mon, 25 Mar 2019 15:38:35 +0000 (+0100) Subject: EmergeManager::initMapgens use FATAL_ERROR if and drop boolean return X-Git-Tag: 5.1.0~258 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=b3716a03a6d47058b50acfc71c861ecfea5f80ad;p=oweals%2Fminetest.git EmergeManager::initMapgens use FATAL_ERROR if and drop boolean return We never handle the boolean return, also init twice is a coding error, not a runtime error --- diff --git a/src/emerge.cpp b/src/emerge.cpp index 0a1852985..9b3394a23 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -184,33 +184,28 @@ EmergeManager::~EmergeManager() } -bool EmergeManager::initMapgens(MapgenParams *params) +void EmergeManager::initMapgens(MapgenParams *params) { - if (!m_mapgens.empty()) - return false; - - this->mgparams = params; + FATAL_ERROR_IF(!m_mapgens.empty(), "mapgen already inited."); - for (u32 i = 0; i != m_threads.size(); i++) { - Mapgen *mg = Mapgen::createMapgen(params->mgtype, i, params, this); - m_mapgens.push_back(mg); - } + mgparams = params; - return true; + for (u32 i = 0; i != m_threads.size(); i++) + m_mapgens.push_back(Mapgen::createMapgen(params->mgtype, i, params, this)); } Mapgen *EmergeManager::getCurrentMapgen() { if (!m_threads_active) - return NULL; + return nullptr; for (u32 i = 0; i != m_threads.size(); i++) { if (m_threads[i]->isCurrentThread()) return m_threads[i]->m_mapgen; } - return NULL; + return nullptr; } diff --git a/src/emerge.h b/src/emerge.h index d4a34451d..df849e542 100644 --- a/src/emerge.h +++ b/src/emerge.h @@ -117,7 +117,7 @@ public: ~EmergeManager(); DISABLE_CLASS_COPY(EmergeManager); - bool initMapgens(MapgenParams *mgparams); + void initMapgens(MapgenParams *mgparams); void startThreads(); void stopThreads();