2009-10-23 04:54:24 -06:00
|
|
|
// Creature dump
|
|
|
|
|
|
|
|
#include <iostream>
|
2009-10-23 10:50:36 -06:00
|
|
|
#include <climits>
|
2009-10-23 04:54:24 -06:00
|
|
|
#include <integers.h>
|
|
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <DFHackAPI.h>
|
|
|
|
|
2009-10-23 10:50:36 -06:00
|
|
|
template <typename T>
|
|
|
|
void print_bits ( T val, std::ostream& out )
|
|
|
|
{
|
|
|
|
T n_bits = sizeof ( val ) * CHAR_BIT;
|
|
|
|
|
|
|
|
for ( unsigned i = 0; i < n_bits; ++i ) {
|
|
|
|
out<< !!( val & 1 ) << " ";
|
|
|
|
val >>= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-23 04:54:24 -06:00
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
vector<t_matgloss> creaturestypes;
|
|
|
|
|
2009-11-10 20:37:28 -07:00
|
|
|
DFHack::API DF("Memory.xml");
|
2009-10-23 04:54:24 -06:00
|
|
|
if(!DF.Attach())
|
|
|
|
{
|
|
|
|
cerr << "DF not found" << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// get stone matgloss mapping
|
|
|
|
if(!DF.ReadCreatureMatgloss(creaturestypes))
|
|
|
|
{
|
|
|
|
cerr << "Can't get the creature types." << endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t numCreatures = DF.InitReadCreatures();
|
|
|
|
for(uint32_t i = 0; i < numCreatures; i++)
|
|
|
|
{
|
2009-11-12 10:52:44 -07:00
|
|
|
t_creature temp;
|
2009-10-23 04:54:24 -06:00
|
|
|
DF.ReadCreature(i, temp);
|
|
|
|
cout << "creature type " << creaturestypes[temp.type].id << ", position:" << temp.x << " " << temp.y << " "<< temp.z << endl;
|
2009-11-05 18:04:17 -07:00
|
|
|
bool addendl = false;
|
2009-11-13 06:35:44 -07:00
|
|
|
if(temp.first_name[0])
|
2009-11-05 18:04:17 -07:00
|
|
|
{
|
|
|
|
cout << "first name: " << temp.first_name;
|
|
|
|
addendl = true;
|
|
|
|
}
|
2009-11-13 06:35:44 -07:00
|
|
|
if(temp.nick_name[0])
|
2009-11-05 18:04:17 -07:00
|
|
|
{
|
|
|
|
cout << ", nick name: " << temp.nick_name;
|
|
|
|
addendl = true;
|
|
|
|
}
|
2009-11-13 06:35:44 -07:00
|
|
|
/*
|
2009-11-07 14:05:10 -07:00
|
|
|
if(!temp.trans_name.empty()){
|
|
|
|
cout << ", trans name: " << temp.trans_name;
|
|
|
|
addendl =true;
|
|
|
|
}
|
|
|
|
if(!temp.generic_name.empty()){
|
|
|
|
cout << ", generic name: " << temp.generic_name;
|
|
|
|
addendl=true;
|
|
|
|
}
|
2009-11-13 06:35:44 -07:00
|
|
|
*/
|
2009-11-05 18:04:17 -07:00
|
|
|
if(addendl)
|
|
|
|
{
|
|
|
|
cout << endl;
|
2009-11-07 14:05:10 -07:00
|
|
|
addendl = false;
|
|
|
|
}
|
2009-11-13 06:35:44 -07:00
|
|
|
/*
|
2009-11-07 14:05:10 -07:00
|
|
|
if(!temp.profession.empty()){
|
2009-11-08 09:35:55 -07:00
|
|
|
cout << ", profession: " << temp.profession;
|
2009-11-07 14:05:10 -07:00
|
|
|
addendl = false;
|
|
|
|
}
|
|
|
|
if(!temp.custom_profession.empty()){
|
|
|
|
cout << ", custom profession: " << temp.custom_profession;
|
|
|
|
addendl = false;
|
2009-11-05 18:04:17 -07:00
|
|
|
}
|
2009-11-07 14:05:10 -07:00
|
|
|
if(!temp.current_job.empty()){
|
|
|
|
cout << ", current job: " << temp.current_job;
|
|
|
|
addendl = false;
|
|
|
|
}
|
2009-11-13 06:35:44 -07:00
|
|
|
*/
|
2009-11-07 14:05:10 -07:00
|
|
|
if(addendl)
|
|
|
|
{
|
|
|
|
cout << endl;
|
|
|
|
addendl = false;
|
|
|
|
}
|
2009-11-08 09:35:55 -07:00
|
|
|
cout << ", happiness: " << temp.happiness << ", strength: " << temp.strength << ", agility: "
|
2009-11-09 16:18:20 -07:00
|
|
|
<< temp.agility << ", toughness: " << temp.toughness << ", money: " << temp.money << ", id: " << temp.id;
|
|
|
|
if(temp.squad_leader_id != -1){
|
|
|
|
cout << ", squad_leader_id: " << temp.squad_leader_id;
|
|
|
|
}
|
2009-11-07 14:05:10 -07:00
|
|
|
cout << ", sex";
|
|
|
|
if(temp.sex == 0){
|
|
|
|
cout << ", Female";
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
cout <<", Male";
|
|
|
|
}
|
|
|
|
cout << endl;
|
2009-11-13 06:35:44 -07:00
|
|
|
/*
|
2009-11-09 16:18:20 -07:00
|
|
|
//skills
|
|
|
|
for(unsigned int i = 0; i < temp.skills.size();i++){
|
|
|
|
if(i > 0){
|
|
|
|
cout << ", ";
|
|
|
|
}
|
|
|
|
cout << temp.skills[i].name << ": " << temp.skills[i].rating;
|
|
|
|
}
|
2009-11-13 06:35:44 -07:00
|
|
|
*/
|
2009-10-23 20:32:57 -06:00
|
|
|
/*
|
|
|
|
* FLAGS 1
|
|
|
|
*/
|
2009-10-23 10:50:36 -06:00
|
|
|
cout << "flags1: ";
|
2009-10-23 20:32:57 -06:00
|
|
|
print_bits(temp.flags1.whole, cout);
|
|
|
|
cout << endl;
|
|
|
|
if(temp.flags1.bits.dead)
|
|
|
|
{
|
|
|
|
cout << "dead ";
|
|
|
|
}
|
2009-10-29 08:06:05 -06:00
|
|
|
if(temp.flags1.bits.on_ground)
|
2009-10-23 20:32:57 -06:00
|
|
|
{
|
2009-10-29 08:06:05 -06:00
|
|
|
cout << "on the ground, ";
|
2009-10-23 20:32:57 -06:00
|
|
|
}
|
2009-10-29 08:06:05 -06:00
|
|
|
if(temp.flags1.bits.skeleton)
|
2009-10-23 20:32:57 -06:00
|
|
|
{
|
|
|
|
cout << "skeletal ";
|
|
|
|
}
|
|
|
|
if(temp.flags1.bits.zombie)
|
|
|
|
{
|
|
|
|
cout << "zombie ";
|
|
|
|
}
|
|
|
|
if(temp.flags1.bits.tame)
|
|
|
|
{
|
|
|
|
cout << "tame ";
|
|
|
|
}
|
|
|
|
if(temp.flags1.bits.royal_guard)
|
|
|
|
{
|
|
|
|
cout << "royal_guard ";
|
|
|
|
}
|
|
|
|
if(temp.flags1.bits.fortress_guard)
|
|
|
|
{
|
|
|
|
cout << "fortress_guard ";
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* FLAGS 2
|
|
|
|
*/
|
2009-10-23 10:50:36 -06:00
|
|
|
cout << endl << "flags2: ";
|
2009-10-23 20:32:57 -06:00
|
|
|
print_bits(temp.flags2.whole, cout);
|
|
|
|
cout << endl;
|
2009-10-29 08:06:05 -06:00
|
|
|
if(temp.flags2.bits.killed)
|
2009-10-23 20:32:57 -06:00
|
|
|
{
|
2009-10-29 08:06:05 -06:00
|
|
|
cout << "killed by kill function, ";
|
2009-10-23 20:32:57 -06:00
|
|
|
}
|
2009-10-29 08:06:05 -06:00
|
|
|
if(temp.flags2.bits.resident)
|
2009-10-23 20:32:57 -06:00
|
|
|
{
|
2009-10-29 08:06:05 -06:00
|
|
|
cout << "resident ";
|
2009-10-23 20:32:57 -06:00
|
|
|
}
|
2009-10-29 08:06:05 -06:00
|
|
|
if(temp.flags2.bits.gutted)
|
2009-10-23 20:32:57 -06:00
|
|
|
{
|
2009-10-29 08:06:05 -06:00
|
|
|
cout << "gutted ";
|
2009-10-23 20:32:57 -06:00
|
|
|
}
|
|
|
|
if(temp.flags2.bits.slaughter)
|
|
|
|
{
|
|
|
|
cout << "slaughter ";
|
|
|
|
}
|
|
|
|
if(temp.flags2.bits.underworld)
|
|
|
|
{
|
|
|
|
cout << "from the underworld ";
|
|
|
|
}
|
2009-10-23 10:50:36 -06:00
|
|
|
cout << endl << endl;
|
2009-10-23 04:54:24 -06:00
|
|
|
}
|
|
|
|
DF.FinishReadCreatures();
|
2009-10-31 12:09:13 -06:00
|
|
|
DF.Detach();
|
2009-11-05 18:04:17 -07:00
|
|
|
#ifndef LINUX_BUILD
|
2009-10-30 03:01:14 -06:00
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
2009-11-05 18:04:17 -07:00
|
|
|
#endif
|
2009-10-23 04:54:24 -06:00
|
|
|
return 0;
|
|
|
|
}
|