Possibly figured out building type offsets.

buildingsdump improvements (interacts with cursor, dump all with no parameters)
develop
Petr Mrázek 2010-04-09 15:16:14 +02:00
parent fb01ecf6c9
commit ce279302d5
2 changed files with 86 additions and 45 deletions

@ -16,12 +16,16 @@ using namespace std;
#include <DFTypes.h> #include <DFTypes.h>
#include <modules/Buildings.h> #include <modules/Buildings.h>
#include <modules/Materials.h> #include <modules/Materials.h>
#include <modules/Position.h>
#include "miscutils.h" #include "miscutils.h"
int main (int argc,const char* argv[]) int main (int argc,const char* argv[])
{ {
int lines = 16;
int mode = 0;
if (argc < 2 || argc > 3) if (argc < 2 || argc > 3)
{ {
/*
cout << "usage:" << endl; cout << "usage:" << endl;
cout << argv[0] << " object_name [number of lines]" << endl; cout << argv[0] << " object_name [number of lines]" << endl;
#ifndef LINUX_BUILD #ifndef LINUX_BUILD
@ -29,14 +33,15 @@ int main (int argc,const char* argv[])
cin.ignore(); cin.ignore();
#endif #endif
return 0; return 0;
*/
} }
int lines = 16; else if(argc == 3)
if(argc == 3)
{ {
string s = argv[2]; //blah. I don't care string s = argv[2]; //blah. I don't care
istringstream ins; // Declare an input string stream. istringstream ins; // Declare an input string stream.
ins.str(s); // Specify string to read. ins.str(s); // Specify string to read.
ins >> lines; // Reads the integers from the string. ins >> lines; // Reads the integers from the string.
mode = 1;
} }
vector<DFHack::t_matgloss> creaturestypes; vector<DFHack::t_matgloss> creaturestypes;
@ -56,35 +61,71 @@ int main (int argc,const char* argv[])
} }
DFHack::memory_info * mem = DF.getMemoryInfo(); DFHack::memory_info * mem = DF.getMemoryInfo();
DFHack::Buildings * Bld = DF.getBuildings(); DFHack::Buildings * Bld = DF.getBuildings();
DFHack::Position * Pos = DF.getPosition();
uint32_t numBuildings; uint32_t numBuildings;
if(Bld->Start(numBuildings)) if(Bld->Start(numBuildings))
{ {
cout << numBuildings << endl; if(mode)
vector < uint32_t > addresses; {
for(uint32_t i = 0; i < numBuildings; i++) cout << numBuildings << endl;
vector < uint32_t > addresses;
for(uint32_t i = 0; i < numBuildings; i++)
{
DFHack::t_building temp;
Bld->Read(i, temp);
if(temp.type != 0xFFFFFFFF) // check if type isn't invalid
{
string typestr;
mem->resolveClassIDToClassname(temp.type, typestr);
cout << typestr << endl;
if(typestr == argv[1])
{
//cout << buildingtypes[temp.type] << " 0x" << hex << temp.origin << endl;
//hexdump(DF, temp.origin, 16);
addresses.push_back(temp.origin);
}
}
else
{
// couldn't translate type, print out the vtable
cout << "unknown vtable: " << temp.vtable << endl;
}
}
interleave_hex(DF,addresses,lines / 4);
}
else // mode
{ {
DFHack::t_building temp; int32_t x,y,z;
Bld->Read(i, temp); Pos->getCursorCoords(x,y,z);
if(temp.type != 0xFFFFFFFF) // check if type isn't invalid if(x != -30000)
{ {
string typestr; for(uint32_t i = 0; i < numBuildings; i++)
mem->resolveClassIDToClassname(temp.type, typestr);
cout << typestr << endl;
if(typestr == argv[1])
{ {
//cout << buildingtypes[temp.type] << " 0x" << hex << temp.origin << endl; DFHack::t_building temp;
//hexdump(DF, temp.origin, 16); Bld->Read(i, temp);
addresses.push_back(temp.origin); if(x >= temp.x1 && x <= temp.x2 && y >= temp.y1 && y <= temp.y2 && z == temp.z)
{
string typestr;
mem->resolveClassIDToClassname(temp.type, typestr);
printf("Address 0x%x, type %d (%s), %d/%d/%d\n",temp.origin, temp.type, typestr.c_str(), temp.x1,temp.y1,temp.z);
hexdump(DF,temp.origin,120);
}
} }
} }
else else
{ {
// couldn't translate type, print out the vtable cout << numBuildings << endl;
cout << "unknown vtable: " << temp.vtable << endl; for(uint32_t i = 0; i < numBuildings; i++)
{
DFHack::t_building temp;
Bld->Read(i, temp);
string typestr;
mem->resolveClassIDToClassname(temp.type, typestr);
printf("Address 0x%x, type %d (%s), %d/%d/%d\n",temp.origin, temp.type, typestr.c_str(), temp.x1,temp.y1,temp.z);
}
} }
} }
interleave_hex(DF,addresses,lines / 4);
Bld->Finish(); Bld->Finish();
} }
else else

@ -2821,32 +2821,32 @@
==================================================================== ====================================================================
<VTable name="building_vtable"> <VTable name="building_vtable">
<multiclass name="building_workshopst" typeoffset="0x138"> <multiclass name="building_workshopst" typeoffset="0x138">
<class name="building_alchemists_laboratoryst" type="0x0"/> <!--<class name="building_alchemists_laboratoryst" type="0x0"/>-->
<class name="building_carpenters_workshopst" type="0x1"/> <class name="building_carpenters_workshopst" type="0x0"/>
<class name="building_farmers_workshopst" type="0x2"/> <class name="building_farmers_workshopst" type="0x1"/>
<class name="building_masons_workshopst" type="0x3"/> <class name="building_masons_workshopst" type="0x2"/>
<class name="building_craftdwarfs_workshopst" type="0x4"/> <class name="building_craftdwarfs_workshopst" type="0x3"/>
<class name="building_jewelers_workshopst" type="0x5"/> <class name="building_jewelers_workshopst" type="0x4"/>
<class name="building_metalsmiths_workshopst" type="0x6"/> <class name="building_metalsmiths_workshopst" type="0x5"/>
<class name="building_magma_forgest" type="0x7"/> <class name="building_magma_forgest" type="0x6"/>
<class name="building_bowyers_workshopst" type="0x8"/> <class name="building_bowyers_workshopst" type="0x7"/>
<class name="building_mechanics_workshopst" type="0x9"/> <class name="building_mechanics_workshopst" type="0x8"/>
<class name="building_siege_workshopst" type="0xA"/> <class name="building_siege_workshopst" type="0x9"/>
<class name="building_butchers_shopst" type="0xB"/> <class name="building_butchers_shopst" type="0xA"/>
<class name="building_leather_worksst" type="0xC"/> <class name="building_leather_worksst" type="0xB"/>
<class name="building_tanners_shopst" type="0xD"/> <class name="building_tanners_shopst" type="0xC"/>
<class name="building_clothiers_shopst" type="0xE"/> <class name="building_clothiers_shopst" type="0xD"/>
<class name="building_fisheryst" type="0xF"/> <class name="building_fisheryst" type="0xE"/>
<class name="building_stillst" type="0x10"/> <class name="building_stillst" type="0xF"/>
<class name="building_loomst" type="0x11"/> <class name="building_loomst" type="0x10"/>
<class name="building_quernst" type="0x12"/> <class name="building_quernst" type="0x11"/>
<class name="building_kennelsst" type="0x13"/> <class name="building_kennelsst" type="0x12"/>
<class name="building_kitchenst" type="0x14"/> <class name="building_kitchenst" type="0x13"/>
<class name="building_asheryst" type="0x15"/> <class name="building_asheryst" type="0x14"/>
<class name="building_dyers_shopst" type="0x16"/> <class name="building_dyers_shopst" type="0x15"/>
<class name="building_millstonest" type="0x17"/> <class name="building_millstonest" type="0x16"/>
</multiclass> </multiclass>
<multiclass name="building_furnacest" typeoffset="0xDA"> <multiclass name="building_furnacest" typeoffset="0x152">
<class name="building_wood_furnacest" type="0x0"/> <class name="building_wood_furnacest" type="0x0"/>
<class name="building_smelterst" type="0x1"/> <class name="building_smelterst" type="0x1"/>
<class name="building_glass_furnacest" type="0x2"/> <class name="building_glass_furnacest" type="0x2"/>
@ -2855,11 +2855,11 @@
<class name="building_magma_glass_furnacest" type="0x5"/> <class name="building_magma_glass_furnacest" type="0x5"/>
<class name="building_magma_kilnst" type="0x6"/> <class name="building_magma_kilnst" type="0x6"/>
</multiclass> </multiclass>
<multiclass name="building_siegeenginest" typeoffset="0xC8"> <multiclass name="building_siegeenginest" typeoffset="0x138">
<class name="building_catapultst" type="0x0"/> <class name="building_catapultst" type="0x0"/>
<class name="building_ballistast" type="0x1"/> <class name="building_ballistast" type="0x1"/>
</multiclass> </multiclass>
<multiclass name="building_trapst" typeoffset="0xC8"> <multiclass name="building_trapst" typeoffset="0x138">
<class name="building_leverst" type="0x0"/> <class name="building_leverst" type="0x0"/>
<class name="building_pressure_platest" type="0x1"/> <class name="building_pressure_platest" type="0x1"/>
<class name="building_cage_trapst" type="0x2"/> <class name="building_cage_trapst" type="0x2"/>