flags for creatures. no idea what they mean

develop
Petr Mrázek 2009-10-23 16:50:36 +00:00
parent 1ac83c8a0f
commit f5acba111e
5 changed files with 29 additions and 1 deletions

@ -627,7 +627,9 @@ uint32_t DFHackAPIImpl::InitReadCreatures()
int creatures = offset_descriptor->getAddress("creatures"); int creatures = offset_descriptor->getAddress("creatures");
creature_pos_offset = offset_descriptor->getOffset("creature_position"); creature_pos_offset = offset_descriptor->getOffset("creature_position");
creature_type_offset = offset_descriptor->getOffset("creature_type"); creature_type_offset = offset_descriptor->getOffset("creature_type");
assert(creatures && creature_pos_offset && creature_type_offset); creature_flags1_offset = offset_descriptor->getOffset("creature_flags1");
creature_flags2_offset = offset_descriptor->getOffset("creature_flags2");
assert(creatures && creature_pos_offset && creature_type_offset && creature_flags1_offset && creature_flags2_offset);
p_cre = new DfVector(dm->readVector(creatures, 4)); p_cre = new DfVector(dm->readVector(creatures, 4));
return p_cre->getSize(); return p_cre->getSize();
} }
@ -642,6 +644,8 @@ bool DFHackAPIImpl::ReadCreature(const uint32_t &index, t_creature & furball)
//read creature from memory //read creature from memory
Mread(temp + creature_pos_offset, 3 * sizeof(uint16_t), (uint8_t *) &(furball.x)); // xyz really Mread(temp + creature_pos_offset, 3 * sizeof(uint16_t), (uint8_t *) &(furball.x)); // xyz really
Mread(temp + creature_type_offset, sizeof(uint32_t), (uint8_t *) &furball.type); Mread(temp + creature_type_offset, sizeof(uint32_t), (uint8_t *) &furball.type);
Mread(temp + creature_flags1_offset, sizeof(uint32_t), (uint8_t *) &furball.flags1);
Mread(temp + creature_flags2_offset, sizeof(uint32_t), (uint8_t *) &furball.flags2);
return true; return true;
} }

@ -186,6 +186,8 @@ private:
uint32_t creature_pos_offset; uint32_t creature_pos_offset;
uint32_t creature_type_offset; uint32_t creature_type_offset;
uint32_t creature_flags1_offset;
uint32_t creature_flags2_offset;
ProcessManager* pm; ProcessManager* pm;
Process* p; Process* p;

@ -135,6 +135,8 @@ struct t_creature
uint16_t y; uint16_t y;
uint16_t z; uint16_t z;
uint32_t type; uint32_t type;
uint32_t flags1;
uint32_t flags2;
}; };
/* /*

@ -380,6 +380,8 @@
<!-- creature offsets --> <!-- creature offsets -->
<Offset name="creature_position">0x4C</Offset> <Offset name="creature_position">0x4C</Offset>
<Offset name="creature_type">0x44</Offset> <Offset name="creature_type">0x44</Offset>
<Offset name="creature_flags1">0x90</Offset>
<Offset name="creature_flags2">0x94</Offset>
<!-- tree and shrub offsets --> <!-- tree and shrub offsets -->
<Offset name="tree_desc_offset">0x40</Offset> <Offset name="tree_desc_offset">0x40</Offset>

@ -1,6 +1,7 @@
// Creature dump // Creature dump
#include <iostream> #include <iostream>
#include <climits>
#include <integers.h> #include <integers.h>
#include <vector> #include <vector>
using namespace std; using namespace std;
@ -8,6 +9,18 @@ using namespace std;
#include <DFTypes.h> #include <DFTypes.h>
#include <DFHackAPI.h> #include <DFHackAPI.h>
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;
}
}
int main (void) int main (void)
{ {
vector<t_matgloss> creaturestypes; vector<t_matgloss> creaturestypes;
@ -33,6 +46,11 @@ int main (void)
t_creature temp; t_creature temp;
DF.ReadCreature(i, temp); DF.ReadCreature(i, temp);
cout << "creature type " << creaturestypes[temp.type].id << ", position:" << temp.x << " " << temp.y << " "<< temp.z << endl; cout << "creature type " << creaturestypes[temp.type].id << ", position:" << temp.x << " " << temp.y << " "<< temp.z << endl;
cout << "flags1: ";
print_bits(temp.flags1, cout);
cout << endl << "flags2: ";
print_bits(temp.flags2, cout);
cout << endl << endl;
} }
DF.FinishReadCreatures(); DF.FinishReadCreatures();
delete pDF; delete pDF;