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 Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied

@ -19,9 +19,9 @@ int main (int argc, char** argv)
{ {
quiet = true; 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 num_blocks = 0;
uint32_t bytes_read = 0; uint32_t bytes_read = 0;
vector<DFHack::t_spattervein> splatter; vector<DFHack::t_spattervein> splatter;

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

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

@ -18,7 +18,7 @@ int main (int argc, char** argv)
{ {
quiet = true; quiet = true;
} }
} }
DFHack::Position * Position = 0; DFHack::Position * Position = 0;
DFHack::ContextManager DFMgr("Memory.xml"); DFHack::ContextManager DFMgr("Memory.xml");
@ -60,11 +60,11 @@ int main (int argc, char** argv)
} }
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
if(!quiet) if(!quiet)
{ {
cout << "Done. Press any key to continue" << endl; cout << "Done. Press any key to continue" << endl;
cin.ignore(); cin.ignore();
} }
#endif #endif
return 0; return 0;
} }

@ -41,7 +41,6 @@ struct compare_pair_second
int main (int argc, const char* argv[]) int main (int argc, const char* argv[])
{ {
bool showhidden = false; bool showhidden = false;
bool showbaselayers = false; bool showbaselayers = false;
for(int i = 1; i < argc; i++) for(int i = 1; i < argc; i++)
@ -95,7 +94,6 @@ int main (int argc, const char* argv[])
return 1; return 1;
} }
DFHack::Maps * Maps = DF->getMaps(); DFHack::Maps * Maps = DF->getMaps();
DFHack::Materials * Mats = DF->getMaterials(); DFHack::Materials * Mats = DF->getMaterials();

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

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