From 4090a378c1045127cab8aac2c67a0777c33a86b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 24 Mar 2011 04:20:34 +0100 Subject: [PATCH] Remove message spam, make sure the old methods act the same. --- library/include/dfhack/modules/Maps.h | 5 +++++ library/modules/Maps.cpp | 27 +++++++++++++++++++-------- tools/supported/dftubefill.cpp | 3 +-- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/library/include/dfhack/modules/Maps.h b/library/include/dfhack/modules/Maps.h index cfbec42e4..db426ef9b 100644 --- a/library/include/dfhack/modules/Maps.h +++ b/library/include/dfhack/modules/Maps.h @@ -527,10 +527,15 @@ namespace DFHack @endcode */ bool ReadGeology( std::vector < std::vector >& assign ); + /** * Initialize the map feature caches, if possible */ bool StartFeatures(); + /** + * Free the feature cache + */ + bool StopFeatures(); /** * Get a global feature with the given index. */ diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp index 79280bdf8..959060133 100644 --- a/library/modules/Maps.cpp +++ b/library/modules/Maps.cpp @@ -278,6 +278,8 @@ Maps::Maps(DFContextShared* _d) Maps::~Maps() { + if(d->FeaturesStarted) + StopFeatures(); if(d->Started) Finish(); delete d; @@ -357,10 +359,7 @@ bool Maps::Finish() { if(d->FeaturesStarted) { - d->local_feature_store.clear(); - d->v_global_feature.clear(); - d->m_local_feature.clear(); - d->FeaturesStarted = false; + StopFeatures(); } if (d->block != NULL) { @@ -604,6 +603,18 @@ bool Maps::ReadRegionOffsets (uint32_t x, uint32_t y, uint32_t z, biome_indices4 } return false; } +bool Maps::StopFeatures() +{ + if(d->FeaturesStarted) + { + d->local_feature_store.clear(); + d->v_global_feature.clear(); + d->m_local_feature.clear(); + d->FeaturesStarted = false; + return true; + } + return false; +} bool Maps::StartFeatures() { @@ -1092,8 +1103,8 @@ bool Maps::ReadGeology (vector < vector >& assign) bool Maps::ReadLocalFeatures( std::map > & local_features ) { - if(!d->FeaturesStarted) - StartFeatures(); + StopFeatures(); + StartFeatures(); if(d->FeaturesStarted) { local_features = d->m_local_feature; @@ -1104,8 +1115,8 @@ bool Maps::ReadLocalFeatures( std::map > & lo bool Maps::ReadGlobalFeatures( std::vector & features) { - if(!d->FeaturesStarted) - StartFeatures(); + StopFeatures(); + StartFeatures(); if(d->FeaturesStarted) { features = d->v_global_feature; diff --git a/tools/supported/dftubefill.cpp b/tools/supported/dftubefill.cpp index d4a28618a..bc9f2c8ba 100644 --- a/tools/supported/dftubefill.cpp +++ b/tools/supported/dftubefill.cpp @@ -73,12 +73,11 @@ int main (void) DFHack::t_feature * glof = 0; if (Mapz->ReadFeatures(x,y,z,&locf,&glof)) { - cout << "bleep" << endl; // we're looking for addy tubes if(!locf) continue; if(locf->type != DFHack::feature_Adamantine_Tube) continue; + dirty=0; - cout << "bloop" << endl; Mapz->ReadDesignations(x,y,z, &designations); Mapz->ReadTileTypes(x,y,z, &tiles);