Skip to content

Commit

Permalink
Prospector detects regionoffsets overflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterix committed Mar 31, 2010
1 parent c631270 commit 3313175
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
9 changes: 4 additions & 5 deletions output/stones.py
Original file line number Diff line number Diff line change
@@ -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()
21 changes: 20 additions & 1 deletion tools/prospector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <string>
#include <vector>
#include <map>
#include <stdio.h>
using namespace std;

#include <DFTypes.h>
Expand Down Expand Up @@ -103,6 +104,8 @@ int main (int argc, const char* argv[])
int16_t tempvein [16][16];
vector <DFHack::t_vein> veins;
vector <DFHack::t_frozenliquidvein> iceveins;
uint32_t maximum_regionoffset = 0;
uint32_t num_overflows = 0;
// walk the map!
for(uint32_t x = 0; x< x_max;x++)
{
Expand All @@ -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];
}
}
Expand Down Expand Up @@ -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<int16_t, uint32_t>::iterator p;
for(p = materials.begin(); p != materials.end(); p++)
{
Expand Down

0 comments on commit 3313175

Please sign in to comment.