Many fixes to DFHack tools and examples

develop
Petr Mrázek 2010-03-26 13:01:46 +01:00
parent 02b7d92135
commit 4d939363b5
24 changed files with 431 additions and 241 deletions

@ -1,5 +1,5 @@
// Attach test
// attachtest - 100x attach/detach, 100x reads, 100x writes
// attachtest - 1000x suspend/resume
#include <iostream>
#include <climits>
@ -21,9 +21,12 @@ int main (void)
DF.Attach();
DF.Detach();
}
catch (DFHack::Error::NoProcess& e)
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
/*
@ -79,8 +82,8 @@ int main (void)
cout << "suspend tests done in " << time_diff << " seconds." << endl;
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -8,18 +8,10 @@
#include <vector>
using namespace std;
#include <DFError.h>
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFMemInfo.h>
/*
oh. fsck it. I'll do the hexdump now and add the things I found in a research/ folder
groups of four bytes, 4 per line
1 space between bytes
2 between groups
offset from the object start on the left
and length set from command line
default 256
*/
/*
address = absolute address of dump start
@ -131,9 +123,16 @@ int main (int argc,const char* argv[])
vector<DFHack::t_matgloss> creaturestypes;
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << "DF not found" << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::memory_info * mem = DF.getMemoryInfo();
@ -173,9 +172,9 @@ int main (int argc,const char* argv[])
}
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -1,6 +1,7 @@
// Catsplosion
// By Zhentar
// This work of evil makes every cat, male or female, grown or kitten, pregnant and due within 2 in-game hours...
// This work of evil makes every cat, male or female, grown or kitten, pregnant
// and due within 2 in-game hours...
#include <iostream>
#include <climits>
@ -9,6 +10,7 @@
#include <stdlib.h> // for rand()
using namespace std;
#include <DFError.h>
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFMemInfo.h>
@ -22,42 +24,54 @@ uint32_t creature_pregnancy_offset;
int fertilizeCat(DFHack::API & DF, const DFHack::t_creature & creature)
{
if(string(creaturestypes[creature.type].id) == "CAT")
{
proc->writeDWord(creature.origin + creature_pregnancy_offset, rand() % 100 + 1);
return 1;
if(string(creaturestypes[creature.type].id) == "CAT")
{
proc->writeDWord(creature.origin + creature_pregnancy_offset, rand() % 100 + 1);
return 1;
}
return 0;
return 0;
}
int main (void)
{
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << "DF not found" << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
}
proc = DF.getProcess();
mem = DF.getMemoryInfo();
creature_pregnancy_offset = mem->getOffset("creature_pregnancy");
creature_pregnancy_offset = mem->getOffset("creature_pregnancy");
if(!DF.ReadCreatureMatgloss(creaturestypes))
{
cerr << "Can't get the creature types." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
uint32_t numCreatures;
if(!DF.InitReadCreatures(numCreatures))
{
cerr << "Can't get creatures" << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
int cats=0;
int cats=0;
for(uint32_t i = 0; i < numCreatures; i++)
{
@ -66,13 +80,13 @@ int main (void)
cats+=fertilizeCat(DF,temp);
}
cout << cats << " cats impregnated." << endl;
cout << cats << " cats impregnated." << endl;
DF.FinishReadCreatures();
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -6,6 +6,7 @@
#include <vector>
using namespace std;
#include <DFError.h>
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFMemInfo.h>
@ -152,7 +153,7 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
{
if(string(creaturestypes[creature.type].id) == "DWARF")
{
cout << "address: " << hex << creature.origin << dec << " creature type: " << creaturestypes[creature.type].id << ", position: " << creature.x << "x " << creature.y << "y "<< creature.z << "z" << endl;
cout << "address: " << hex << creature.origin << dec << " creature type: " << creaturestypes[creature.type].id << ", position: " << creature.x << "x " << creature.y << "y "<< creature.z << "z" << endl;
bool addendl = false;
if(creature.name.first_name[0])
{
@ -213,11 +214,11 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
cout <<"Male";
}
cout << endl;
if(creature.pregnancy_timer > 0)
cout << "gives birth in " << creature.pregnancy_timer/1200 << " days. ";
cout << "Blood: " << creature.blood_current << "/" << creature.blood_max << " bleeding: " << creature.bleed_rate;
cout << endl;
if(creature.pregnancy_timer > 0)
cout << "gives birth in " << creature.pregnancy_timer/1200 << " days. ";
cout << "Blood: " << creature.blood_current << "/" << creature.blood_max << " bleeding: " << creature.bleed_rate;
cout << endl;
/*
//skills
@ -301,9 +302,16 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
int main (void)
{
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << "DF not found" << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}

@ -8,6 +8,7 @@
#include <vector>
using namespace std;
#include <DFError.h>
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFMemInfo.h>
@ -190,14 +191,20 @@ void printItem(DFHack::t_item item, const string & typeString,const matGlosses &
int main ()
{
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
DFHack::API DF("Memory.xml");
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::memory_info * mem = DF.getMemoryInfo();
DF.InitViewAndCursor();
matGlosses mat;
@ -280,11 +287,10 @@ int main ()
}
DF.FinishReadItems();
}
DF.FinishReadBuildings();
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -50,9 +50,16 @@ int main (int numargs, char** args)
DFHack::mapblock40d Block;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}

@ -15,22 +15,22 @@ using namespace std;
// returns a lower case version of the string
string tolower (const string & s)
{
string d (s);
string d (s);
transform (d.begin (), d.end (), d.begin (), (int(*)(int)) tolower);
return d;
transform (d.begin (), d.end (), d.begin (), (int(*)(int)) tolower);
return d;
}
string groupBy2(const string & s)
{
string d;
for(int i =2;i<s.length();i++){
if(i%2==0)
{
d+= s.substr(i-2,2) + " ";
}
}
d+=s.substr(s.length()-2,2);
return(d);
string d;
for(int i =2;i<s.length();i++){
if(i%2==0)
{
d+= s.substr(i-2,2) + " ";
}
}
d+=s.substr(s.length()-2,2);
return(d);
}
uint32_t endian_swap(uint32_t x)
@ -39,57 +39,65 @@ uint32_t endian_swap(uint32_t x)
((x<<8) & 0x00FF0000) |
((x>>8) & 0x0000FF00) |
(x<<24);
return x;
return x;
}
int main (void)
{
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
DFHack::API DF("Memory.xml");
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << "DF not found" << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;
vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;
if(!DF.InitReadNameTables(englishWords,foreignWords))
{
cerr << "Could not get Names" << endl;
return 1;
}
string input;
DF.ForceResume();
{
cerr << "Could not get Names" << endl;
return 1;
}
string input;
DF.ForceResume();
cout << "\nSelect Name to search or q to Quit" << endl;
getline (cin, input);
while(input != "q"){
while(input != "q"){
for( uint32_t i = 0; i < englishWords.size();i++){
for( uint32_t j = 0;j < englishWords[i].size();j++){
if(englishWords[i][j] != ""){
uint32_t found = tolower(input).find(tolower(englishWords[i][j]));
if(found != string::npos){
stringstream value;
value << setfill('0') << setw(8) << hex << endian_swap(j);
cout << englishWords[i][j] << " " << groupBy2(value.str()) << endl;
uint32_t found = tolower(input).find(tolower(englishWords[i][j]));
if(found != string::npos){
stringstream value;
value << setfill('0') << setw(8) << hex << endian_swap(j);
cout << englishWords[i][j] << " " << groupBy2(value.str()) << endl;
}
}
}
}
}
}
}
for( uint32_t i = 0; i < foreignWords.size();i++){
for( uint32_t j = 0;j < foreignWords[i].size();j++){
uint32_t found = tolower(input).find(tolower(foreignWords[i][j]));
if(found != string::npos){
stringstream value;
value << setfill('0') << setw(8) << hex << endian_swap(j);
cout << foreignWords[i][j] << " " << groupBy2(value.str()) << endl;
}
}
}
DF.Resume();
getline(cin,input);
}
uint32_t found = tolower(input).find(tolower(foreignWords[i][j]));
if(found != string::npos){
stringstream value;
value << setfill('0') << setw(8) << hex << endian_swap(j);
cout << foreignWords[i][j] << " " << groupBy2(value.str()) << endl;
}
}
}
DF.Resume();
getline(cin,input);
}
DF.Detach();
DF.FinishReadNameTables();
DF.FinishReadNameTables();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -15,9 +15,16 @@ int main (void)
{
vector<DFHack::t_matgloss> creaturestypes;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}

@ -11,11 +11,19 @@ using namespace std;
int main (void)
{
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
vector <DFHack::t_matgloss> Woods;
DF.ReadWoodMatgloss(Woods);

@ -13,44 +13,51 @@ using namespace std;
int main (void)
{
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
if (DF.InitViewAndCursor())
{
int32_t x,y,z;
if(DF.getViewCoords(x,y,z))
cout << "view coords: " << x << "/" << y << "/" << z << endl;
if(DF.getCursorCoords(x,y,z))
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
}
else
{
if (DF.InitViewAndCursor())
{
int32_t x,y,z;
if(DF.getViewCoords(x,y,z))
cout << "view coords: " << x << "/" << y << "/" << z << endl;
if(DF.getCursorCoords(x,y,z))
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
}
else
{
cerr << "cursor and window parameters are unsupported on your version of DF" << endl;
}
if(DF.InitViewSize())
{
int32_t width,height;
if(DF.getWindowSize(width,height))
cout << "window size : " << width << " " << height << endl;
}
else
{
cerr << "view size is unsupported on your version of DF" << endl;
}
if(!DF.Detach())
{
cerr << "Can't detach from DF" << endl;
}
cerr << "cursor and window parameters are unsupported on your version of DF" << endl;
}
if(DF.InitViewSize())
{
int32_t width,height;
if(DF.getWindowSize(width,height))
cout << "window size : " << width << " " << height << endl;
}
else
{
cerr << "view size is unsupported on your version of DF" << endl;
}
if(!DF.Detach())
{
cerr << "Can't detach from DF" << endl;
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -24,10 +24,12 @@ void print_bits ( T val, std::ostream& out )
val >>= 1;
}
}
vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;
uint32_t numCreatures;
vector<DFHack::t_matgloss> creaturestypes;
void printDwarves(DFHack::API & DF)
{
int dwarfCounter = 0;
@ -311,13 +313,19 @@ bool setCursorToCreature(DFHack::API &DF)
int main (void)
{
DFHack::API DF("Memory.xml");
if (!DF.Attach())
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << "DF not found" << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.Suspend();
DFHack::memory_info * mem = DF.getMemoryInfo();
if (!DF.ReadCreatureMatgloss(creaturestypes))

@ -31,43 +31,55 @@ void printSettlement(DFHack::API & DF, const DFHack::t_settlement & settlement,
int main (int argc,const char* argv[])
{
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
DFHack::API DF("Memory.xml");
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::t_settlement current;
uint32_t numSettlements;
if(!DF.InitReadSettlements(numSettlements))
{
cerr << "Could not read Settlements" << endl;
return 1;
}
vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;
cerr << "Could not read Settlements" << endl;
return 1;
}
vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;
if(!DF.InitReadNameTables(englishWords,foreignWords))
{
cerr << "Can't get name tables" << endl;
return 1;
}
cout << "Settlements\n";
/*for(uint32_t i =0;i<numSettlements;i++){
DFHack::t_settlement temp;
DF.ReadSettlement(i,temp);
printSettlement(DF,temp,englishWords,foreignWords);
}*/
// MSVC claims this is causing the heap to be corrupted, I think it is because the currentSettlement vector only has 1 item in it
cout << "Current Settlement\n";
if(DF.ReadCurrentSettlement(current))
printSettlement(DF,current,englishWords,foreignWords);
cout << "Settlements\n";
/*for(uint32_t i =0;i<numSettlements;i++){
DFHack::t_settlement temp;
DF.ReadSettlement(i,temp);
printSettlement(DF,temp,englishWords,foreignWords);
}*/
// MSVC claims this is causing the heap to be corrupted, I think it is because the currentSettlement vector only has 1 item in it
cout << "Current Settlement\n";
if(DF.ReadCurrentSettlement(current))
printSettlement(DF,current,englishWords,foreignWords);
DF.FinishReadNameTables();
DF.FinishReadSettlements();
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
DF.FinishReadNameTables();
DF.FinishReadSettlements();
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
return 0;
}

@ -15,11 +15,19 @@ int main (void)
{
string blah;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
cout << "Attached, DF should be suspended now" << endl;
getline(cin, blah);

@ -22,31 +22,38 @@ int main (int numargs, const char ** args)
input >> std::hex >> addr;
}
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
else
catch (exception& e)
{
DFHack::Process* p = DF.getProcess();
DFHack::memory_info* mem = DF.getMemoryInfo();
const vector<string> * names = mem->getClassIDMapping();
for(int i = 0; i < names->size();i++)
{
cout << i << " " << names->at(i) << endl;
}
/*
#ifdef LINUX_BUILD
cout << "start 0x" << hex << p->readDWord(addr+0x0) << endl;
cout << "end 0x" << hex << p->readDWord(addr+0x4) << endl;
cout << "cap 0x" << hex << p->readDWord(addr+0x8) << endl;
#else
cout << "start 0x" << hex << p->readDWord(addr+0x4) << endl;
cout << "end 0x" << hex << p->readDWord(addr+0x8) << endl;
cout << "cap 0x" << hex << p->readDWord(addr+0xC) << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
*/
return 1;
}
DFHack::Process* p = DF.getProcess();
DFHack::memory_info* mem = DF.getMemoryInfo();
const vector<string> * names = mem->getClassIDMapping();
for(int i = 0; i < names->size();i++)
{
cout << i << " " << names->at(i) << endl;
}
/*
#ifdef LINUX_BUILD
cout << "start 0x" << hex << p->readDWord(addr+0x0) << endl;
cout << "end 0x" << hex << p->readDWord(addr+0x4) << endl;
cout << "cap 0x" << hex << p->readDWord(addr+0x8) << endl;
#else
cout << "start 0x" << hex << p->readDWord(addr+0x4) << endl;
cout << "end 0x" << hex << p->readDWord(addr+0x8) << endl;
cout << "cap 0x" << hex << p->readDWord(addr+0xC) << endl;
#endif
*/
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -307,15 +307,19 @@ main(int argc, char *argv[])
vector< vector <uint16_t> > layerassign;
vector<t_vein> veinVector;
vector<t_frozenliquidvein> IceVeinVector;
// init the API
DFHack::API DF("Memory.xml");
pDF = &DF;
// attach
if(!DF.Attach())
try
{
error = "Can't find DF.";
pDF = 0;
DF.Attach();
pDF = &DF;
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
finish(0);
}

@ -268,7 +268,9 @@ bool API::InitMap()
uint32_t x_array_loc = g_pProcess->readDWord (map_offset);
if (!x_array_loc)
{
throw Error::NoMapLoaded();
return false;
// FIXME: only throw this due to programmer error, in the other map functions
//throw Error::NoMapLoaded();
}
// get the size

@ -15,13 +15,30 @@ int main (void)
uint32_t bytes_read = 0;
DFHack::occupancies40d occupancies;
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
DFHack::API DF("Memory.xml");
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.InitMap();
// init the map
if(!DF.InitMap())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.getSize(x_max,y_max,z_max);
// walk the map

@ -41,14 +41,19 @@ int main ()
int items;
int found = 0, converted = 0;
DFHack::API DF ("Memory.xml");
if(!DF.Attach())
DFHack::API DF("Memory.xml");
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.Suspend();
// Find out which material is bauxite
if(!DF.ReadStoneMatgloss(stoneMat))

@ -299,7 +299,7 @@ int main (int argc, char** argv)
string s_targets;
string s_origin;
bool verbose;
int max;
int max = 10;
argstream as(argc,argv);
as >>option('v',"verbose",verbose,"Active verbose mode")
@ -327,31 +327,36 @@ int main (int argc, char** argv)
else
{
DFHack::API DF("Memory.xml");
if(DF.Attach())
try
{
if (DF.InitMap())
{
int count = dig(DF, targets, 10, origin[0],origin[1],origin[2], verbose);
cout << count << " targets designated" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
if (DF.InitMap())
{
int count = dig(DF, targets, max, origin[0],origin[1],origin[2], verbose);
cout << count << " targets designated" << endl;
if (!DF.Detach())
{
cerr << "Unable to detach DF process" << endl;
}
}
else
if (!DF.Detach())
{
cerr << "Unable to init map" << endl;
cerr << "Unable to detach DF process" << endl;
}
}
else
{
cerr << "Unable to attach to DF process" << endl;
{
cerr << "Unable to init map" << endl;
}
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -100,9 +100,16 @@ int main (void)
{
string select;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Process * p = DF.getProcess();

@ -194,9 +194,16 @@ int main ()
<< "Like set on fire all MICROCLINE item_stone..." << endl
<< "Some unusual combinations might be untested and cause the program to crash..."<< endl
<< "so, watch your step and backup your fort" << endl;
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::memory_info *mem = DF.getMemoryInfo();

@ -15,12 +15,19 @@ int main (void)
DFHack::designations40d designations;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << "DF not found" << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.InitMap();
if (DF.InitViewAndCursor())

@ -54,18 +54,29 @@ int main (int argc, const char* argv[])
vector<DFHack::t_matgloss> stonetypes;
vector< vector <uint16_t> > layerassign;
// init the API
DFHack::API DF("Memory.xml");
// attach
if(!DF.Attach())
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << "DF not found" << endl;
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
// init the map
DF.InitMap();
if(!DF.InitMap())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.getSize(x_max,y_max,z_max);
// get stone matgloss mapping
@ -73,6 +84,9 @@ int main (int argc, const char* argv[])
{
//DF.DestroyMap();
cerr << "Can't get the materials." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
@ -80,6 +94,9 @@ int main (int argc, const char* argv[])
if(!DF.ReadGeology( layerassign ))
{
cerr << "Can't get region geology." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
@ -172,8 +189,8 @@ int main (int argc, const char* argv[])
}
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -14,12 +14,29 @@ int main (void)
DFHack::designations40d designations;
DFHack::API DF("Memory.xml");
if(!DF.Attach())
try
{
cerr << "DF not found" << endl;
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.InitMap();
// init the map
if(!DF.InitMap())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DF.getSize(x_max,y_max,z_max);
// walk the map