2010-04-09 16:24:41 -06:00
|
|
|
// Just show some position data
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <climits>
|
|
|
|
#include <integers.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <sstream>
|
|
|
|
#include <ctime>
|
|
|
|
#include <cstdio>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-04-18 06:56:09 -06:00
|
|
|
#include <DFGlobal.h>
|
2010-04-09 16:24:41 -06:00
|
|
|
#include <DFTypes.h>
|
2010-05-23 15:06:10 -06:00
|
|
|
#include <DFContextManager.h>
|
|
|
|
#include <DFContext.h>
|
2010-04-09 16:24:41 -06:00
|
|
|
#include <DFProcess.h>
|
|
|
|
#include <DFMemInfo.h>
|
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <modules/Materials.h>
|
|
|
|
#include <modules/Position.h>
|
|
|
|
#include <modules/Constructions.h>
|
2010-04-30 13:52:37 -06:00
|
|
|
#include <DFMiscUtils.h>
|
2010-04-09 16:24:41 -06:00
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
|
|
|
|
int main (int numargs, const char ** args)
|
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context* DF;
|
2010-04-09 16:24:41 -06:00
|
|
|
try
|
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
2010-04-09 16:24:41 -06:00
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::Position *Pos = DF->getPosition();
|
2010-04-09 16:24:41 -06:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::Constructions *Cons = DF->getConstructions();
|
|
|
|
DFHack::Materials *Mats = DF->getMaterials();
|
2010-04-28 10:09:32 -06:00
|
|
|
Mats->ReadInorganicMaterials();
|
2010-04-09 16:24:41 -06:00
|
|
|
uint32_t numConstr;
|
|
|
|
Cons->Start(numConstr);
|
|
|
|
|
|
|
|
int32_t cx, cy, cz;
|
|
|
|
Pos->getCursorCoords(cx,cy,cz);
|
|
|
|
if(cx != -30000)
|
|
|
|
{
|
|
|
|
t_construction con;
|
|
|
|
for(uint32_t i = 0; i < numConstr; i++)
|
|
|
|
{
|
|
|
|
Cons->Read(i,con);
|
|
|
|
if(cx == con.x && cy == con.y && cz == con.z)
|
|
|
|
{
|
|
|
|
printf("Construction %d/%d/%d @ 0x%x\n", con.x, con.y, con.z,con.origin);
|
|
|
|
// inorganic stuff - we can recognize that
|
2010-04-09 21:48:50 -06:00
|
|
|
printf("Material: form %d, type %d, index %d\n",con.form, con.mat_type, con.mat_idx);
|
2010-04-09 16:24:41 -06:00
|
|
|
string matstr = "unknown";
|
|
|
|
if(con.mat_type == 0)
|
|
|
|
{
|
2010-04-09 18:12:45 -06:00
|
|
|
if(con.mat_idx != 0xffffffff)
|
2010-04-28 10:09:32 -06:00
|
|
|
matstr = Mats->inorganic[con.mat_idx].id;
|
2010-04-09 18:12:45 -06:00
|
|
|
else matstr = "inorganic";
|
2010-04-09 16:24:41 -06:00
|
|
|
}
|
2010-04-09 21:48:50 -06:00
|
|
|
switch(con.form)
|
2010-04-09 16:24:41 -06:00
|
|
|
{
|
|
|
|
case constr_bar:
|
|
|
|
printf("It is made of %s bars!\n",matstr.c_str());
|
|
|
|
break;
|
|
|
|
case constr_block:
|
|
|
|
printf("It is made of %s blocks!\n",matstr.c_str());
|
|
|
|
break;
|
|
|
|
case constr_boulder:
|
|
|
|
printf("It is made of %s stones!\n",matstr.c_str());
|
|
|
|
break;
|
|
|
|
case constr_logs:
|
|
|
|
printf("It is made of %s logs!\n",matstr.c_str());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("It is made of something we don't know yet! The material is %s.\n",matstr.c_str());
|
|
|
|
}
|
|
|
|
hexdump(DF,con.origin,2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|