Prospector detects regionoffsets overflows.

develop
Petr Mrázek 2010-03-31 17:31:49 +02:00
parent c631270425
commit 33131754d4
2 changed files with 24 additions and 6 deletions

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import pydfhack import pydfhack
x = pydfhack.API("Memory.xml") DF = pydfhack.API("Memory.xml")
y = pydfhack.MatglossVector()
if x.Attach(): if DF.Attach():
success,stones = x.ReadStoneMatgloss() success,stones = DF.ReadStoneMatgloss()
if success: if success:
print "Dumping all stone" print "Dumping all stone"
for matgloss in stones: for matgloss in stones:
print "ID %s, name %s" % (matgloss.id, matgloss.name) print "ID %s, name %s" % (matgloss.id, matgloss.name)
x.Detach() DF.Detach()

@ -13,6 +13,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
#include <stdio.h>
using namespace std; using namespace std;
#include <DFTypes.h> #include <DFTypes.h>
@ -103,6 +104,8 @@ int main (int argc, const char* argv[])
int16_t tempvein [16][16]; int16_t tempvein [16][16];
vector <DFHack::t_vein> veins; vector <DFHack::t_vein> veins;
vector <DFHack::t_frozenliquidvein> iceveins; vector <DFHack::t_frozenliquidvein> iceveins;
uint32_t maximum_regionoffset = 0;
uint32_t num_overflows = 0;
// walk the map! // walk the map!
for(uint32_t x = 0; x< x_max;x++) 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++) 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] = tempvein[xx][yy] =
layerassign layerassign
[regionoffsets[designations[xx][yy].bits.biome]] [regionoffsets[test]]
[designations[xx][yy].bits.geolayer_index]; [designations[xx][yy].bits.geolayer_index];
} }
} }
@ -182,6 +193,14 @@ int main (int argc, const char* argv[])
} }
} }
// print report // 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<int16_t, uint32_t>::iterator p; map<int16_t, uint32_t>::iterator p;
for(p = materials.begin(); p != materials.end(); p++) for(p = materials.begin(); p != materials.end(); p++)
{ {