diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml
index 5de27b5e0..70fba86f8 100644
--- a/data/Memory-ng.xml
+++ b/data/Memory-ng.xml
@@ -822,17 +822,17 @@
-
-
-
-
+
+
+
+
-
+
@@ -864,8 +864,8 @@
-
-
+
+
diff --git a/library/include/dfhack/DFVector.h b/library/include/dfhack/DFVector.h
index de305c015..2eca3f2d8 100644
--- a/library/include/dfhack/DFVector.h
+++ b/library/include/dfhack/DFVector.h
@@ -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];
diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp
index de357dba4..d44cdeee6 100644
--- a/library/modules/Maps.cpp
+++ b/library/modules/Maps.cpp
@@ -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 > &
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 & 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 p_features (p,global_feature_vector);
features.clear();
diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp
index 92ed52858..9a8d2b60a 100644
--- a/library/modules/Materials.cpp
+++ b/library/modules/Materials.cpp
@@ -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 & nam
bool Materials::ReadInorganicMaterials (void)
{
Process * p = d->owner;
- DfVector p_matgloss (p, d->owner->getDescriptor()->getAddress ("mat_inorganics"));
+ DfVector 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;
diff --git a/tools/supported/dumpoffsets.cpp b/tools/supported/dumpoffsets.cpp
index d9240f760..be5861bf1 100644
--- a/tools/supported/dumpoffsets.cpp
+++ b/tools/supported/dumpoffsets.cpp
@@ -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;
}
diff --git a/tools/supported/prospector.cpp b/tools/supported/prospector.cpp
index e7e0e9237..77ba6afcb 100644
--- a/tools/supported/prospector.cpp
+++ b/tools/supported/prospector.cpp
@@ -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();