creature dump test, valid offsets for linux d9 and d11

develop
Petr Mrázek 2009-10-23 10:54:24 +00:00
parent 876dcbf7cc
commit dab8d37c03
4 changed files with 56 additions and 5 deletions

@ -383,7 +383,7 @@ bool DFHackAPIImpl::ReadCreatureMatgloss(vector<t_matgloss> & creatures)
{
int matgloss_address = offset_descriptor->getAddress("matgloss");
int matgloss_offset = offset_descriptor->getHexValue("matgloss_skip");
DfVector p_matgloss = dm->readVector(matgloss_address + matgloss_offset*4, 4);
DfVector p_matgloss = dm->readVector(matgloss_address + matgloss_offset*6, 4);
creatures.clear();
@ -595,7 +595,7 @@ uint32_t DFHackAPIImpl::InitReadVegetation()
vegetationInited = true;
int vegetation = offset_descriptor->getAddress("vegetation");
tree_offset = offset_descriptor->getOffset("tree_desc_offset");
assert(vegetation && treeoffset);
assert(vegetation && tree_offset);
p_veg = new DfVector(dm->readVector(vegetation,4));
return p_veg->getSize();
}
@ -627,7 +627,7 @@ uint32_t DFHackAPIImpl::InitReadCreatures()
int creatures = offset_descriptor->getAddress("creatures");
creature_pos_offset = offset_descriptor->getOffset("creature_position");
creature_type_offset = offset_descriptor->getOffset("creature_type");
assert(creatures && creatureposoffset && creaturetypeoffset);
assert(creatures && creature_pos_offset && creature_type_offset);
p_cre = new DfVector(dm->readVector(creatures, 4));
return p_cre->getSize();
}
@ -635,7 +635,7 @@ uint32_t DFHackAPIImpl::InitReadCreatures()
bool DFHackAPIImpl::ReadCreature(const uint32_t &index, t_creature & furball)
{
assert(vegetationInited);
assert(creaturesInited);
uint32_t temp;
// read pointer from vector at position
p_cre->read(index,(uint8_t *)&temp);

@ -368,6 +368,12 @@
<!--<Address name="buildings">0x09332C80</Address>-->
<!--<Address name="buildings">0x09332EF0</Address>-->
<Address name="vegetation">0x09335CB0</Address>
<Address name="creatures">0x093326AC</Address>
<!-- creature offsets -->
<Offset name="creature_position">0x4C</Offset>
<Offset name="creature_type">0x44</Offset>
<!-- tree and shrub offsets -->
<Offset name="tree_desc_offset">0x40</Offset>
@ -512,6 +518,7 @@
<Address name="constructions">0x08F41918</Address>
<Address name="buildings">0x08F55740</Address>
<Address name="vegetation">0x08F58890</Address>
<Address name="creatures">0x08F55250</Address>
<!-- size of the map -->
<Address name="x_count">0x08F95BD0</Address>

@ -19,4 +19,8 @@ TARGET_LINK_LIBRARIES(prospector dfhack)
# cleanmap - removes mud, snow, blood and similar stuff from a map. farmers beware
ADD_EXECUTABLE(cleanmap cleanmap.cpp)
TARGET_LINK_LIBRARIES(cleanmap dfhack)
TARGET_LINK_LIBRARIES(cleanmap dfhack)
# creaturedump - basic creature dump - a test of the creature related exports
ADD_EXECUTABLE(creaturedump creaturedump.cpp)
TARGET_LINK_LIBRARIES(creaturedump dfhack)

@ -0,0 +1,40 @@
// Creature dump
#include <iostream>
#include <integers.h>
#include <vector>
using namespace std;
#include <DFTypes.h>
#include <DFHackAPI.h>
int main (void)
{
vector<t_matgloss> creaturestypes;
DFHackAPI *pDF = CreateDFHackAPI("Memory.xml");
DFHackAPI &DF = *pDF;
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++)
{
t_creature temp;
DF.ReadCreature(i, temp);
cout << "creature type " << creaturestypes[temp.type].id << ", position:" << temp.x << " " << temp.y << " "<< temp.z << endl;
}
DF.FinishReadCreatures();
delete pDF;
return 0;
}