2010-04-07 08:45:38 -06:00
|
|
|
// Just show some position data
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <climits>
|
|
|
|
#include <vector>
|
|
|
|
#include <sstream>
|
|
|
|
#include <ctime>
|
|
|
|
#include <cstdio>
|
|
|
|
using namespace std;
|
|
|
|
|
2010-06-04 16:02:02 -06:00
|
|
|
#define DFHACK_WANT_MISCUTILS
|
2010-05-25 22:48:23 -06:00
|
|
|
#include <DFHack.h>
|
2011-05-14 07:51:11 -06:00
|
|
|
/*
|
|
|
|
uint16_t material; // +0x3E
|
|
|
|
uint16_t x; // +0x40
|
|
|
|
uint16_t y; // +0x42
|
|
|
|
uint16_t z; // +0x44
|
|
|
|
uint16_t padding; // +0x46
|
|
|
|
uint32_t unknown_1; // +0x48
|
|
|
|
uint16_t temperature_1; // +0x4C
|
|
|
|
uint16_t temperature_2; // +0x4E - maybe fraction?
|
|
|
|
uint32_t mystery_flag; // 0x50: yes, just one
|
|
|
|
uint32_t unknown_2; // 0x54
|
|
|
|
uint32_t unknown_3; // 0x58
|
|
|
|
// a vector is here
|
|
|
|
uint32_t address;
|
|
|
|
*/
|
2011-05-14 16:26:44 -06:00
|
|
|
void print_tree( DFHack::Context * DF , DFHack::dfh_plant & tree)
|
2011-02-27 05:59:45 -07:00
|
|
|
{
|
|
|
|
DFHack::Materials * mat = DF->getMaterials();
|
2011-05-14 16:26:44 -06:00
|
|
|
DFHack::t_plant & tdata = tree.sdata;
|
|
|
|
printf("%d:%d = ",tdata.type,tdata.material);
|
|
|
|
if(tdata.watery)
|
2011-02-27 05:59:45 -07:00
|
|
|
{
|
|
|
|
cout << "near-water ";
|
|
|
|
}
|
2011-05-14 16:26:44 -06:00
|
|
|
cout << mat->organic[tdata.material].id << " ";
|
|
|
|
if(!tdata.is_shrub)
|
2011-02-27 05:59:45 -07:00
|
|
|
{
|
|
|
|
cout << "tree";
|
|
|
|
}
|
2011-05-14 16:26:44 -06:00
|
|
|
else
|
2011-02-27 05:59:45 -07:00
|
|
|
{
|
|
|
|
cout << "shrub";
|
|
|
|
}
|
|
|
|
cout << endl;
|
2011-05-14 17:53:43 -06:00
|
|
|
printf("Grow counter: 0x%08x\n", tdata.grow_counter);
|
|
|
|
printf("temperature 1: %d\n", tdata.temperature_1);
|
|
|
|
printf("temperature 2: %d\n", tdata.temperature_2);
|
2011-05-14 16:26:44 -06:00
|
|
|
printf("On fire: %d\n", tdata.is_burning);
|
|
|
|
printf("hitpoints: 0x%08x\n", tdata.hitpoints);
|
2011-05-14 18:21:24 -06:00
|
|
|
printf("update order: %d\n", tdata.update_order);
|
2011-02-27 05:59:45 -07:00
|
|
|
printf("Address: 0x%x\n", tree.address);
|
2011-04-02 18:49:03 -06:00
|
|
|
hexdump(DF,tree.address,13*16);
|
2011-02-27 05:59:45 -07:00
|
|
|
}
|
|
|
|
|
2010-04-07 08:45:38 -06:00
|
|
|
int main (int numargs, const char ** args)
|
|
|
|
{
|
|
|
|
uint32_t addr;
|
|
|
|
if (numargs == 2)
|
|
|
|
{
|
|
|
|
istringstream input (args[1],istringstream::in);
|
|
|
|
input >> std::hex >> addr;
|
|
|
|
}
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context * DF;
|
2010-04-07 08:45:38 -06:00
|
|
|
try
|
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
2010-04-07 08:45:38 -06:00
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
2010-06-04 16:02:02 -06:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::Process* p = DF->getProcess();
|
2010-08-20 06:10:05 -06:00
|
|
|
DFHack::VersionInfo* mem = DF->getMemoryInfo();
|
2011-03-18 04:38:37 -06:00
|
|
|
DFHack::Gui * Gui = DF->getGui();
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::Vegetation * v = DF->getVegetation();
|
2011-02-27 05:59:45 -07:00
|
|
|
DFHack::Maps * mps = DF->getMaps();
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::Materials * mat = DF->getMaterials();
|
2010-04-28 10:09:32 -06:00
|
|
|
mat->ReadOrganicMaterials();
|
2010-06-04 16:02:02 -06:00
|
|
|
|
2010-04-07 08:45:38 -06:00
|
|
|
int32_t x,y,z;
|
2011-03-18 04:38:37 -06:00
|
|
|
Gui->getCursorCoords(x,y,z);
|
2010-06-04 16:02:02 -06:00
|
|
|
|
2010-04-07 08:45:38 -06:00
|
|
|
uint32_t numVegs = 0;
|
|
|
|
v->Start(numVegs);
|
|
|
|
if(x == -30000)
|
|
|
|
{
|
|
|
|
cout << "----==== Trees ====----" << endl;
|
|
|
|
for(uint32_t i =0; i < numVegs; i++)
|
|
|
|
{
|
2011-05-14 16:26:44 -06:00
|
|
|
DFHack::dfh_plant tree;
|
2010-04-07 08:45:38 -06:00
|
|
|
v->Read(i,tree);
|
2011-05-14 16:26:44 -06:00
|
|
|
printf("%d/%d/%d, %d:%d\n",tree.sdata.x,tree.sdata.y,tree.sdata.z,tree.sdata.type,tree.sdata.material);
|
2010-04-07 08:45:38 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-02-27 05:59:45 -07:00
|
|
|
// new method, gets the vector of trees in a block. can show farm plants
|
|
|
|
if(mps->Start())
|
|
|
|
{
|
2011-05-14 16:26:44 -06:00
|
|
|
vector<DFHack::dfh_plant> alltrees;
|
2011-02-27 05:59:45 -07:00
|
|
|
if(mps->ReadVegetation(x/16,y/16,z,&alltrees))
|
|
|
|
{
|
|
|
|
for(int i = 0 ; i < alltrees.size(); i++)
|
|
|
|
{
|
2011-05-14 16:26:44 -06:00
|
|
|
DFHack::dfh_plant & tree = alltrees[i];
|
2011-02-27 05:59:45 -07:00
|
|
|
// you could take the tree coords from the struct and % them with 16 for use in loops over the whole block
|
2011-05-14 16:26:44 -06:00
|
|
|
if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z)
|
2011-02-27 05:59:45 -07:00
|
|
|
{
|
|
|
|
cout << "----==== Tree at "<< x << "/" << y << "/" << z << " ====----" << endl;
|
|
|
|
print_tree(DF, tree);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// old method, gets the tree from the global vegetation vector. can't show farm plants
|
2010-04-07 08:45:38 -06:00
|
|
|
for(uint32_t i =0; i < numVegs; i++)
|
|
|
|
{
|
2011-05-14 16:26:44 -06:00
|
|
|
DFHack::dfh_plant tree;
|
2010-04-07 08:45:38 -06:00
|
|
|
v->Read(i,tree);
|
2011-05-14 16:26:44 -06:00
|
|
|
if(tree.sdata.x == x && tree.sdata.y == y && tree.sdata.z == z)
|
2010-04-07 08:45:38 -06:00
|
|
|
{
|
2011-05-14 07:51:11 -06:00
|
|
|
cout << "----==== Tree at "<< dec << x << "/" << y << "/" << z << " ====----" << endl;
|
2011-02-27 05:59:45 -07:00
|
|
|
print_tree(DF, tree);
|
2010-04-07 08:45:38 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
v->Finish();
|
2010-06-04 16:02:02 -06:00
|
|
|
|
2010-04-07 08:45:38 -06:00
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|