Fixed URL in LICENSE, whitespace in tools.

develop
Petr Mrázek 2010-11-11 02:32:33 +01:00
parent 415051ecf3
commit e41a5c6300
8 changed files with 106 additions and 108 deletions

@ -1,4 +1,4 @@
www.sourceforge.net/projects/dfhack
github.com/peterix/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf
This software is provided 'as-is', without any express or implied

@ -19,13 +19,13 @@ int main (int argc, char** argv)
{
quiet = true;
}
}
uint32_t x_max,y_max,z_max;
}
uint32_t x_max,y_max,z_max;
uint32_t num_blocks = 0;
uint32_t bytes_read = 0;
vector<DFHack::t_spattervein> splatter;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
try
@ -41,7 +41,7 @@ int main (int argc, char** argv)
return 1;
}
DFHack::Maps *Mapz = DF->getMaps();
// init the map
if(!Mapz->Start())
{
@ -51,11 +51,11 @@ int main (int argc, char** argv)
#endif
return 1;
}
Mapz->getSize(x_max,y_max,z_max);
uint8_t zeroes [16][16] = {0};
// walk the map
for(uint32_t x = 0; x< x_max;x++)
{

@ -18,8 +18,8 @@ int main (int argc, char** argv)
{
quiet = true;
}
}
}
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
try
@ -42,8 +42,8 @@ int main (int argc, char** argv)
Gui->SetPauseState(true);
DF->Resume();
#ifndef LINUX_BUILD
cout << "Done. The current game frame will have to finish first. This can take some time on bugged maps." << endl;
if (!quiet) cin.ignore();
cout << "Done. The current game frame will have to finish first. This can take some time on bugged maps." << endl;
if (!quiet) cin.ignore();
#endif
return 0;
}

@ -19,13 +19,13 @@ int main (int argc, char** argv)
{
quiet = true;
}
}
int32_t x,y,z;
}
int32_t x,y,z;
DFHack::designations40d designations;
DFHack::tiletypes40d tiles;
DFHack::t_temperatures temp1,temp2;
uint32_t x_max,y_max,z_max;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
DFHack::Maps * Maps;
@ -469,11 +469,11 @@ int main (int argc, char** argv)
}
DF->Detach();
#ifndef LINUX_BUILD
if(!quiet)
{
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
if(!quiet)
{
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
#endif
return 0;
}

@ -18,8 +18,8 @@ int main (int argc, char** argv)
{
quiet = true;
}
}
}
DFHack::Position * Position = 0;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context * DF;
@ -41,7 +41,7 @@ int main (int argc, char** argv)
{
int32_t x,y,z;
int32_t width,height;
if(Position->getViewCoords(x,y,z))
cout << "view coords: " << x << "/" << y << "/" << z << endl;
if(Position->getCursorCoords(x,y,z))
@ -53,18 +53,18 @@ int main (int argc, char** argv)
{
cerr << "cursor and window parameters are unsupported on your version of DF" << endl;
}
if(!DF->Detach())
{
cerr << "Can't detach from DF" << endl;
}
#ifndef LINUX_BUILD
if(!quiet)
{
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
if(!quiet)
{
cout << "Done. Press any key to continue" << endl;
cin.ignore();
}
#endif
return 0;
}

@ -41,7 +41,6 @@ struct compare_pair_second
int main (int argc, const char* argv[])
{
bool showhidden = false;
bool showbaselayers = false;
for(int i = 1; i < argc; i++)
@ -76,9 +75,9 @@ int main (int argc, const char* argv[])
materials.clear();
vector<DFHack::t_feature> global_features;
std::map <DFHack::planecoord, std::vector<DFHack::t_feature *> > local_features;
vector< vector <uint16_t> > layerassign;
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF;
try
@ -94,11 +93,10 @@ int main (int argc, const char* argv[])
#endif
return 1;
}
DFHack::Maps * Maps = DF->getMaps();
DFHack::Materials * Mats = DF->getMaterials();
// init the map
if(!Maps->Start())
{
@ -109,7 +107,7 @@ int main (int argc, const char* argv[])
return 1;
}
Maps->getSize(x_max,y_max,z_max);
if(!Maps->ReadGlobalFeatures(global_features))
{
cerr << "Can't get global features." << endl;
@ -137,7 +135,7 @@ int main (int argc, const char* argv[])
#endif
return 1;
}
// get region geology
if(!Maps->ReadGeology( layerassign ))
{
@ -147,7 +145,7 @@ int main (int argc, const char* argv[])
#endif
return 1;
}
int16_t tempvein [16][16];
vector <DFHack::t_vein> veins;
uint32_t maximum_regionoffset = 0;
@ -161,16 +159,16 @@ int main (int argc, const char* argv[])
{
if(!Maps->isValidBlock(x,y,z))
continue;
// read data
Maps->ReadBlock40d(x,y,z, &Block);
//Maps->ReadTileTypes(x,y,z, &tiletypes);
//Maps->ReadDesignations(x,y,z, &designations);
memset(tempvein, -1, sizeof(tempvein));
veins.clear();
Maps->ReadVeins(x,y,z,&veins);
if(showbaselayers)
{
//Maps->ReadRegionOffsets(x,y,z, &regionoffsets);
@ -194,7 +192,7 @@ int main (int argc, const char* argv[])
}
}
}
// for each vein
for(int i = 0; i < (int)veins.size();i++)
{
@ -214,7 +212,7 @@ int main (int argc, const char* argv[])
}
}
}
// global feature overrides
int16_t idx = Block.global_feature;
if( idx != -1 && uint16_t(idx) < global_features.size() && global_features[idx].type == DFHack::feature_Underworld)
@ -234,7 +232,7 @@ int main (int argc, const char* argv[])
}
}
}
idx = Block.local_feature;
if( idx != -1 )
{
@ -263,7 +261,7 @@ int main (int argc, const char* argv[])
}
}
}
// count the material types
for(uint32_t xi = 0 ; xi< 16 ; xi++)
{
@ -275,7 +273,7 @@ int main (int argc, const char* argv[])
continue;
if(tempvein[xi][yi] < 0)
continue;
if(materials.count(tempvein[xi][yi]))
{
materials[tempvein[xi][yi]] += 1;

@ -13,37 +13,37 @@ using namespace std;
#include <argstream.h>
#define MAX_DIM 0x300
class Point
class Vertex
{
public:
Point(uint32_t _x, uint32_t _y, uint32_t _z):x(_x),y(_y),z(_z) {}
Point()
Vertex(uint32_t _x, uint32_t _y, uint32_t _z):x(_x),y(_y),z(_z) {}
Vertex()
{
x = y = z = 0;
}
bool operator==(const Point &other) const
bool operator==(const Vertex &other) const
{
return (other.x == x && other.y == y && other.z == z);
}
bool operator<(const Point &other) const
bool operator<(const Vertex &other) const
{
return ( (z*MAX_DIM*MAX_DIM + y*MAX_DIM + x) < (other.z*MAX_DIM*MAX_DIM + other.y*MAX_DIM + other.x));
}
Point operator/(int number) const
Vertex operator/(int number) const
{
return Point(x/number, y/number, z);
return Vertex(x/number, y/number, z);
}
Point operator%(int number) const
Vertex operator%(int number) const
{
return Point(x%number, y%number, z);
return Vertex(x%number, y%number, z);
}
Point operator-(int number) const
Vertex operator-(int number) const
{
return Point(x,y,z-number);
return Vertex(x,y,z-number);
}
Point operator+(int number) const
Vertex operator+(int number) const
{
return Point(x,y,z+number);
return Vertex(x,y,z+number);
}
uint32_t x;
uint32_t y;
@ -53,7 +53,7 @@ class Point
class Block
{
public:
Block(DFHack::Maps *_m, Point _bcoord)
Block(DFHack::Maps *_m, Vertex _bcoord)
{
vector <DFHack::t_vein> veins;
m = _m;
@ -92,23 +92,23 @@ class Block
valid = true;
}
}
int16_t MaterialAt(Point p)
int16_t MaterialAt(Vertex p)
{
return materials[p.x][p.y];
}
void ClearMaterialAt(Point p)
void ClearMaterialAt(Vertex p)
{
materials[p.x][p.y] = -1;
}
int16_t TileTypeAt(Point p)
int16_t TileTypeAt(Vertex p)
{
return raw.tiletypes[p.x][p.y];
}
DFHack::t_designation DesignationAt(Point p)
DFHack::t_designation DesignationAt(Vertex p)
{
return raw.designation[p.x][p.y];
}
bool setDesignationAt(Point p, DFHack::t_designation des)
bool setDesignationAt(Vertex p, DFHack::t_designation des)
{
if(!valid) return false;
dirty = true;
@ -131,7 +131,7 @@ class Block
volatile bool dirty;
DFHack::Maps * m;
DFHack::mapblock40d raw;
Point bcoord;
Vertex bcoord;
int16_t materials[16][16];
int8_t bitmap[16][16];
};
@ -148,7 +148,7 @@ class MapCache
};
~MapCache()
{
map<Point, Block *>::iterator p;
map<Vertex, Block *>::iterator p;
for(p = blocks.begin(); p != blocks.end(); p++)
{
delete p->second;
@ -160,11 +160,11 @@ class MapCache
return valid;
}
Block * BlockAt (Point blockcoord)
Block * BlockAt (Vertex blockcoord)
{
if(!valid) return 0;
map <Point, Block*>::iterator iter = blocks.find(blockcoord);
map <Vertex, Block*>::iterator iter = blocks.find(blockcoord);
if(iter != blocks.end())
{
return (*iter).second;
@ -181,7 +181,7 @@ class MapCache
}
}
uint16_t tiletypeAt (Point tilecoord)
uint16_t tiletypeAt (Vertex tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -191,7 +191,7 @@ class MapCache
return 0;
}
int16_t materialAt (Point tilecoord)
int16_t materialAt (Vertex tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -200,7 +200,7 @@ class MapCache
}
return 0;
}
bool clearMaterialAt (Point tilecoord)
bool clearMaterialAt (Vertex tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -211,7 +211,7 @@ class MapCache
}
DFHack::t_designation designationAt (Point tilecoord)
DFHack::t_designation designationAt (Vertex tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -222,7 +222,7 @@ class MapCache
temp.whole = 0;
return temp;
}
bool setDesignationAt (Point tilecoord, DFHack::t_designation des)
bool setDesignationAt (Vertex tilecoord, DFHack::t_designation des)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -232,7 +232,7 @@ class MapCache
}
return false;
}
bool testCoord (Point tilecoord)
bool testCoord (Vertex tilecoord)
{
Block * b= BlockAt(tilecoord / 16);
if(b && b->valid)
@ -244,7 +244,7 @@ class MapCache
bool WriteAll()
{
map<Point, Block *>::iterator p;
map<Vertex, Block *>::iterator p;
for(p = blocks.begin(); p != blocks.end(); p++)
{
p->second->WriteDesignations();
@ -260,7 +260,7 @@ class MapCache
uint32_t y_tmax;
uint32_t z_max;
DFHack::Maps * Maps;
map<Point, Block *> blocks;
map<Vertex, Block *> blocks;
};
int main (int argc, char* argv[])
@ -325,7 +325,7 @@ int main (int argc, char* argv[])
DF->Suspend();
Pos->getCursorCoords(cx,cy,cz);
}
Point xy ((uint32_t)cx,(uint32_t)cy,cz);
Vertex xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
{
cerr << "I won't dig the borders. That would be cheating!" << endl;
@ -353,13 +353,13 @@ int main (int argc, char* argv[])
return 1;
}
printf("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <Point> flood;
stack <Vertex> flood;
flood.push(xy);
while( !flood.empty() )
{
Point current = flood.top();
Vertex current = flood.top();
flood.pop();
int16_t vmat2 = MCache->materialAt(current);
@ -397,30 +397,30 @@ int main (int argc, char* argv[])
MCache->clearMaterialAt(current);
if(current.x < tx_max - 2)
{
flood.push(Point(current.x + 1, current.y, current.z));
flood.push(Vertex(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2)
{
flood.push(Point(current.x + 1, current.y + 1,current.z));
flood.push(Point(current.x, current.y + 1,current.z));
flood.push(Vertex(current.x + 1, current.y + 1,current.z));
flood.push(Vertex(current.x, current.y + 1,current.z));
}
if(current.y > 1)
{
flood.push(Point(current.x + 1, current.y - 1,current.z));
flood.push(Point(current.x, current.y - 1,current.z));
flood.push(Vertex(current.x + 1, current.y - 1,current.z));
flood.push(Vertex(current.x, current.y - 1,current.z));
}
}
if(current.x > 1)
{
flood.push(Point(current.x - 1, current.y,current.z));
flood.push(Vertex(current.x - 1, current.y,current.z));
if(current.y < ty_max - 2)
{
flood.push(Point(current.x - 1, current.y + 1,current.z));
flood.push(Point(current.x, current.y + 1,current.z));
flood.push(Vertex(current.x - 1, current.y + 1,current.z));
flood.push(Vertex(current.x, current.y + 1,current.z));
}
if(current.y > 1)
{
flood.push(Point(current.x - 1, current.y - 1,current.z));
flood.push(Point(current.x, current.y - 1,current.z));
flood.push(Vertex(current.x - 1, current.y - 1,current.z));
flood.push(Vertex(current.x, current.y - 1,current.z));
}
}
if(updown)

@ -45,9 +45,9 @@ void printWeather(DFHack::WeatherType current)
using namespace DFHack;
int main (int argc, char** argv)
{
string command = "";
string command = "";
bool quiet = false;
bool cmdarg = false;
bool cmdarg = false;
for(int i = 1; i < argc; i++)
{
string test = argv[i];
@ -55,14 +55,14 @@ int main (int argc, char** argv)
{
quiet = true;
}
else
{
command = test;
cmdarg = true;
}
}
DFHack::ContextManager DFMgr("Memory.xml");
else
{
command = test;
cmdarg = true;
}
}
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
try
@ -104,15 +104,15 @@ int main (int argc, char** argv)
{
end = true;
}
command = "";
if(cmdarg) end = true; // exit the loop when a cmd line arg has been passed.
command = "";
if(cmdarg) end = true; // exit the loop when a cmd line arg has been passed.
}
#ifndef LINUX_BUILD
if (!quiet)
{
std::cout << "Done. Press any key to continue" << std::endl;
cin.ignore();
}
if (!quiet)
{
std::cout << "Done. Press any key to continue" << std::endl;
cin.ignore();
}
#endif
DF->Detach();
return 0;