dfhack/examples/materialtest.cpp

103 lines
3.0 KiB
C++

// Just show some position data
2009-11-02 05:53:39 -07:00
#include <iostream>
#include <climits>
#include <integers.h>
#include <vector>
#include <sstream>
2009-11-02 05:53:39 -07:00
#include <ctime>
using namespace std;
#include <DFGlobal.h>
2009-11-02 05:53:39 -07:00
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFProcess.h>
#include <DFMemInfo.h>
#include <DFVector.h>
2010-04-04 16:48:19 -06:00
#include <modules/Materials.h>
2009-11-02 05:53:39 -07:00
int main (int numargs, const char ** args)
{
uint32_t addr;
if (numargs == 2)
{
istringstream input (args[1],istringstream::in);
input >> std::hex >> addr;
}
2009-11-10 20:37:28 -07:00
DFHack::API DF("Memory.xml");
try
2009-11-02 05:53:39 -07:00
{
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
2009-11-02 05:53:39 -07:00
return 1;
}
DFHack::Process* p = DF.getProcess();
DFHack::memory_info* mem = DF.getMemoryInfo();
2010-04-04 16:48:19 -06:00
DFHack::Materials *Materials = DF.getMaterials();
2010-04-04 02:10:00 -06:00
cout << "----==== Inorganic ====----" << endl;
2010-04-28 10:09:32 -06:00
Materials->ReadInorganicMaterials ();
for(uint32_t i = 0; i < Materials->inorganic.size();i++)
2010-04-04 02:10:00 -06:00
{
2010-04-28 10:09:32 -06:00
cout << i << ": " << Materials->inorganic[i].id << endl;
2010-04-04 02:10:00 -06:00
}
2009-11-02 05:53:39 -07:00
2010-04-04 02:10:00 -06:00
cout << endl << "----==== Organic ====----" << endl;
2010-04-28 10:09:32 -06:00
Materials->ReadOrganicMaterials ();
for(uint32_t i = 0; i < Materials->organic.size();i++)
2010-04-04 02:10:00 -06:00
{
2010-04-28 10:09:32 -06:00
cout << i << ": " << Materials->organic[i].id << endl;
2010-04-04 02:10:00 -06:00
}
2010-04-14 04:16:56 -06:00
cout << endl << "----==== Organic - trees ====----" << endl;
2010-04-28 10:09:32 -06:00
Materials->ReadWoodMaterials ();
for(uint32_t i = 0; i < Materials->tree.size();i++)
2010-04-14 04:16:56 -06:00
{
2010-04-28 10:09:32 -06:00
cout << i << ": " << Materials->tree[i].id << endl;
2010-04-14 04:16:56 -06:00
}
cout << endl << "----==== Organic - plants ====----" << endl;
2010-04-28 10:09:32 -06:00
Materials->ReadPlantMaterials ();
for(uint32_t i = 0; i < Materials->plant.size();i++)
2010-04-14 04:16:56 -06:00
{
2010-04-28 10:09:32 -06:00
cout << i << ": " << Materials->plant[i].id << endl;
2010-04-14 04:16:56 -06:00
}
2010-04-04 02:10:00 -06:00
cout << endl << "----==== Creature types ====----" << endl;
2010-04-28 10:09:32 -06:00
Materials->ReadCreatureTypesEx ();
for(uint32_t i = 0; i < Materials->raceEx.size();i++)
2010-04-04 02:10:00 -06:00
{
2010-04-28 10:09:32 -06:00
cout << i << ": " << Materials->raceEx[i].rawname << endl;
vector<DFHack::t_creaturecaste> & castes = Materials->raceEx[i].castes;
2010-04-14 14:12:02 -06:00
for(uint32_t j = 0; j < castes.size();j++)
{
cout << " ["
<< castes[j].rawname << ":"
<< castes[j].singular << ":"
<< castes[j].plural << ":"
<< castes[j].adjective << "] ";
cout << endl;
}
cout << endl;
2010-04-04 02:10:00 -06:00
}
2010-04-20 10:25:39 -06:00
cout << endl << "----==== Color descriptors ====----" << endl;
2010-04-28 10:09:32 -06:00
Materials->ReadDescriptorColors();
for(uint32_t i = 0; i < Materials->color.size();i++)
2010-04-20 10:25:39 -06:00
{
2010-04-28 10:09:32 -06:00
cout << i << ": " << Materials->color[i].id << " - " << Materials->color[i].name << "["
<< (unsigned int) (Materials->color[i].r*255) << ":"
<< (unsigned int) (Materials->color[i].v*255) << ":"
<< (unsigned int) (Materials->color[i].b*255) << ":"
2010-04-20 10:25:39 -06:00
<< "]" << endl;
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
2009-11-02 05:53:39 -07:00
cin.ignore();
#endif
2009-11-02 05:53:39 -07:00
return 0;
}