From 33131754d475845a4a8a5d2767b5ec9c9150d5ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Wed, 31 Mar 2010 17:31:49 +0200 Subject: [PATCH] Prospector detects regionoffsets overflows. --- output/stones.py | 9 ++++----- tools/prospector.cpp | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/output/stones.py b/output/stones.py index 5feb53210..de90f8e7e 100644 --- a/output/stones.py +++ b/output/stones.py @@ -1,12 +1,11 @@ # -*- coding: utf-8 -*- import pydfhack -x = pydfhack.API("Memory.xml") -y = pydfhack.MatglossVector() +DF = pydfhack.API("Memory.xml") -if x.Attach(): - success,stones = x.ReadStoneMatgloss() +if DF.Attach(): + success,stones = DF.ReadStoneMatgloss() if success: print "Dumping all stone" for matgloss in stones: print "ID %s, name %s" % (matgloss.id, matgloss.name) - x.Detach() + DF.Detach() diff --git a/tools/prospector.cpp b/tools/prospector.cpp index d07a7ae23..5cd8acfbf 100644 --- a/tools/prospector.cpp +++ b/tools/prospector.cpp @@ -13,6 +13,7 @@ #include #include #include +#include using namespace std; #include @@ -103,6 +104,8 @@ int main (int argc, const char* argv[]) int16_t tempvein [16][16]; vector veins; vector iceveins; + uint32_t maximum_regionoffset = 0; + uint32_t num_overflows = 0; // walk the map! for(uint32_t x = 0; x< x_max;x++) { @@ -129,9 +132,17 @@ int main (int argc, const char* argv[]) { for (uint32_t yy = 0; yy< 16;yy++) { + uint8_t test = designations[xx][yy].bits.biome; + if(test > maximum_regionoffset) + maximum_regionoffset = test; + if( test >= sizeof(regionoffsets)) + { + num_overflows++; + continue; + } tempvein[xx][yy] = layerassign - [regionoffsets[designations[xx][yy].bits.biome]] + [regionoffsets[test]] [designations[xx][yy].bits.geolayer_index]; } } @@ -182,6 +193,14 @@ int main (int argc, const char* argv[]) } } // print report + cout << "Maximal regionoffset seen: " << maximum_regionoffset << "."; + if(maximum_regionoffset >= sizeof(regionoffsets) ) + { + cout << " This is above the regionoffsets array size!" << endl; + cout << "Number of overflows: " << num_overflows; + } + cout << endl; + map::iterator p; for(p = materials.begin(); p != materials.end(); p++) {