Maps stuff, geology seems broken

develop
Petr Mrázek 2010-08-28 15:43:53 +02:00
parent 51d545402d
commit d46dcb8342
6 changed files with 85 additions and 54 deletions

@ -822,17 +822,17 @@
<Group name="string" description="An STL string.">
<HexValue name="sizeof" description="The total size in bytes." />
</Group>
<Group name="name">
<Offset name="first"/>
<Offset name="nick"/>
<Offset name="second_words"/>
<Group name="name" description="A structure used for names all over the place.">
<Offset name="first" description="Lowercase stl string with the first name. For ex. 'urist'" />
<Offset name="nick" description="Stl string with the nickname. Set by the player." />
<Offset name="second_words" description="Array of 7 indexes into the language vectors."/>
</Group>
<Group name="Position" description="Offsets used by the Position module.">
<Address name="window_x" description="X coordinate of the current view (DWORD)" />
<Address name="window_y" description="Y coordinate of the current view (DWORD)" />
<Address name="window_z" description="Z coordinate of the current view (DWORD)" />
<Address name="cursor_xyz" description="Coordinates of the cursor (3xDWORD)." />
<!--<Address name="mouse_pos" description="Position of the mouse." />-->
<Address name="mouse_pos" description="Position of the mouse (3xDWORD?)" />
<Address name="window_dims" description="Size of the view in tiles (2xWORD)" />
<Address name="screen_tiles_pointer" description="Pointer to the screen tile array." />
</Group>
@ -864,8 +864,8 @@
<Offset name="temperature2" />
<Offset name="biome_stuffs" />
<Offset name="pathfinding" />
<Offset name="feature_local" />
<Offset name="feature_global" />
<Offset name="feature_local" description="Index into a local feature vector (adamantine, etc. Complicated, see source)" />
<Offset name="feature_global" description="Index into the global feature vector (hell, etc.)." />
</Group>
<Group name="features">
<Group name="global">

@ -43,7 +43,7 @@ namespace DFHack
{
uint32_t triplet[3];
VersionInfo * mem = p->getDescriptor();
uint32_t offs = mem->getOffset("vector_triplet");
uint32_t offs = mem->getGroup("vector")->getOffset("start");
p->read(address + offs, sizeof(triplet), (uint8_t *) &triplet);
_start = triplet[0];

@ -52,6 +52,9 @@ struct Maps::Private
DFContextShared *d;
Process * owner;
OffsetGroup *OG_local_features;
OffsetGroup *OG_global_features;
OffsetGroup *OG_vector;
bool Inited;
bool Started;
@ -72,35 +75,41 @@ Maps::Maps(DFContextShared* _d)
Server::Maps::maps_offsets &off = d->offsets;
// get the offsets once here
off.map_offset = mem->getAddress ("map_data");
off.x_count_offset = mem->getAddress ("x_count_block");
off.y_count_offset = mem->getAddress ("y_count_block");
off.z_count_offset = mem->getAddress ("z_count_block");
off.tile_type_offset = mem->getOffset ("map_data_type");
off.designation_offset = mem->getOffset ("map_data_designation");
off.occupancy_offset = mem->getOffset("map_data_occupancy");
off.biome_stuffs = mem->getOffset ("map_data_biome_stuffs");
off.veinvector = mem->getOffset ("map_data_vein_vector");
off.local_feature_offset = mem->getOffset ("map_data_feature_local");
off.global_feature_offset = mem->getOffset ("map_data_feature_global");
off.temperature1_offset = mem->getOffset ("map_data_temperature1_offset");
off.temperature2_offset = mem->getOffset ("map_data_temperature2_offset");
off.region_x_offset = mem->getAddress ("region_x");
off.region_y_offset = mem->getAddress ("region_y");
off.region_z_offset = mem->getAddress ("region_z");
off.world_regions = mem->getAddress ("ptr2_region_array");
off.region_size = mem->getHexValue ("region_size");
off.region_geo_index_offset = mem->getOffset ("region_geo_index_off");
off.geolayer_geoblock_offset = mem->getOffset ("geolayer_geoblock_offset");
off.world_geoblocks_vector = mem->getAddress ("geoblock_vector");
off.type_inside_geolayer = mem->getOffset ("type_inside_geolayer");
off.world_size_x = mem->getAddress ("world_size_x");
off.world_size_y = mem->getAddress ("world_size_y");
// these can fail and will be found when looking at the actual veins later
OffsetGroup *OG_Maps = mem->getGroup("Maps");
off.map_offset = OG_Maps->getAddress ("map_data");
off.x_count_offset = OG_Maps->getAddress ("x_count_block");
off.y_count_offset = OG_Maps->getAddress ("y_count_block");
off.z_count_offset = OG_Maps->getAddress ("z_count_block");
off.region_x_offset = OG_Maps->getAddress ("region_x");
off.region_y_offset = OG_Maps->getAddress ("region_y");
off.region_z_offset = OG_Maps->getAddress ("region_z");
off.world_size_x = OG_Maps->getAddress ("world_size_x");
off.world_size_y = OG_Maps->getAddress ("world_size_y");
OffsetGroup *OG_MapBlock = OG_Maps->getGroup("block");
off.tile_type_offset = OG_MapBlock->getOffset ("type");
off.designation_offset = OG_MapBlock->getOffset ("designation");
off.occupancy_offset = OG_MapBlock->getOffset("occupancy");
off.biome_stuffs = OG_MapBlock->getOffset ("biome_stuffs");
off.veinvector = OG_MapBlock->getOffset ("vein_vector");
off.local_feature_offset = OG_MapBlock->getOffset ("feature_local");
off.global_feature_offset = OG_MapBlock->getOffset ("feature_global");
off.temperature1_offset = OG_MapBlock->getOffset ("temperature1");
off.temperature2_offset = OG_MapBlock->getOffset ("temperature2");
OffsetGroup *OG_Geology = OG_Maps->getGroup("geology");
off.world_regions = OG_Geology->getAddress ("ptr2_region_array");
off.region_size = OG_Geology->getHexValue ("region_size");
off.region_geo_index_offset = OG_Geology->getOffset ("region_geo_index_off");
off.geolayer_geoblock_offset = OG_Geology->getOffset ("geolayer_geoblock_offset");
off.world_geoblocks_vector = OG_Geology->getAddress ("geoblock_vector");
off.type_inside_geolayer = OG_Geology->getOffset ("type_inside_geolayer");
d->OG_global_features = OG_Maps->getGroup("features")->getGroup("global");
d->OG_local_features = OG_Maps->getGroup("features")->getGroup("local");
d->OG_vector = mem->getGroup("vector");
// these can (will) fail and will be found when looking at the actual veins later
// basically a cache
off.vein_ice_vptr = 0;
mem->resolveClassnameToVPtr("block_square_event_frozen_liquid", off.vein_ice_vptr);
@ -723,14 +732,14 @@ bool Maps::ReadLocalFeatures( std::map <planecoord, std::vector<t_feature *> > &
Process * p = d->owner;
VersionInfo * mem = p->getDescriptor();
// deref pointer to the humongo-structure
uint32_t base = p->readDWord(mem->getAddress("local_feature_start_ptr"));
uint32_t base = p->readDWord(d->OG_local_features->getAddress("start_ptr"));
if(!base)
return false;
uint32_t sizeof_vec = mem->getHexValue("sizeof_vector");
const uint32_t sizeof_vec = d->OG_vector->getHexValue("sizeof");
const uint32_t sizeof_elem = 16;
const uint32_t offset_elem = 4;
const uint32_t main_mat_offset = mem->getOffset("local_feature_mat"); // 0x30
const uint32_t sub_mat_offset = mem->getOffset("local_feature_submat"); // 0x34
const uint32_t main_mat_offset = d->OG_local_features->getOffset("material"); // 0x30
const uint32_t sub_mat_offset = d->OG_local_features->getOffset("submaterial"); // 0x34
local_features.clear();
@ -814,12 +823,11 @@ bool Maps::ReadGlobalFeatures( std::vector <t_feature> & features)
return false;
Process * p = d->owner;
VersionInfo * mem = p->getDescriptor();
uint32_t global_feature_vector = mem->getAddress("global_feature_vector");
uint32_t global_feature_funcptr = mem->getOffset("global_feature_funcptr_");
const uint32_t main_mat_offset = mem->getOffset("global_feature_mat"); // 0x34
const uint32_t sub_mat_offset = mem->getOffset("global_feature_submat"); // 0x38
const uint32_t global_feature_vector = d->OG_global_features->getAddress("vector");
const uint32_t global_feature_funcptr = d->OG_global_features->getOffset("funcptr");
const uint32_t main_mat_offset = d->OG_global_features->getOffset("material"); // 0x34
const uint32_t sub_mat_offset = d->OG_global_features->getOffset("submaterial"); // 0x38
DfVector<uint32_t> p_features (p,global_feature_vector);
features.clear();

@ -37,6 +37,7 @@ class Materials::Private
public:
DFContextShared *d;
Process * owner;
OffsetGroup * OG_Materials;
/*
bool Inited;
bool Started;
@ -48,6 +49,7 @@ Materials::Materials(DFContextShared * d_)
d = new Private;
d->d = d_;
d->owner = d_->p;
d->OG_Materials = d->owner->getDescriptor()->getGroup("Materials");
}
Materials::~Materials()
{
@ -216,7 +218,7 @@ inline bool ReadNamesOnly(Process* p, uint32_t address, vector<t_matgloss> & nam
bool Materials::ReadInorganicMaterials (void)
{
Process * p = d->owner;
DfVector <uint32_t> p_matgloss (p, d->owner->getDescriptor()->getAddress ("mat_inorganics"));
DfVector <uint32_t> p_matgloss (p, d->OG_Materials->getAddress("inorganics"));
uint32_t size = p_matgloss.size();
inorganic.clear();
inorganic.reserve (size);
@ -237,29 +239,29 @@ bool Materials::ReadInorganicMaterials (void)
bool Materials::ReadOrganicMaterials (void)
{
return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("mat_organics_all"), organic );
return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("organics_all"), organic );
}
bool Materials::ReadWoodMaterials (void)
{
return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("mat_organics_trees"), tree );
return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("organics_trees"), tree );
}
bool Materials::ReadPlantMaterials (void)
{
return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("mat_organics_plants"), plant );
return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("organics_plants"), plant );
}
bool Materials::ReadCreatureTypes (void)
{
return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("creature_type_vector"), race );
return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("creature_type_vector"), race );
return true;
}
bool Materials::ReadOthers(void)
{
Process * p = d->owner;
uint32_t matBase = p->getDescriptor()->getAddress ("mat_other");
uint32_t matBase = d->OG_Materials->getAddress ("other");
uint32_t i = 0;
uint32_t ptr;

@ -13,16 +13,32 @@ using namespace DFHack;
int main (int numargs, const char ** args)
{
/*
DFHack::VersionInfoFactory * VIF = new DFHack::VersionInfoFactory("Memory.xml");
for(int i = 0; i < VIF->versions.size(); i++)
{
cout << VIF->versions[i]->PrintOffsets();
}
*/
DFHack::ContextManager DFMgr("Memory.xml");
DFHack::Context *DF = DFMgr.getSingleContext();
try
{
DF->Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
cout << DF->getMemoryInfo()->PrintOffsets();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
delete VIF;
//delete VIF;
return 0;
}

@ -313,6 +313,11 @@ int main (int argc, const char* argv[])
std::sort(matss.begin(), matss.end(), compare_pair_second<>());
for(int i = 0; i < matss.size();i++)
{
if(matss[i].first >= Mats->inorganic.size())
{
cerr << "Error, material out of bounds: " << matss[i].first << endl;
continue;
}
cout << Mats->inorganic[matss[i].first].id << " : " << matss[i].second << endl;
}
DF->Detach();