Maps::Maps(DFContextShared* _d) { d = new Private; d->d = _d; Process *p = d->owner = _d->p; d->Inited = d->FeaturesStarted = d->Started = false; d->block = NULL; d->usesWorldDataPtr = false; DFHack::VersionInfo * mem = p->getDescriptor(); Private::t_offsets &off = d->offsets; d->hasFeatures = d->hasGeology = d->hasVeggies = true; // get the offsets once here OffsetGroup *OG_Maps = mem->getGroup("Maps"); try { off.world_data = OG_Maps->getAddress("world_data"); d->usesWorldDataPtr = true; //cout << "uses world ptr" << endl; }catch(Error::AllMemdef &){} { 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"); if(d->usesWorldDataPtr) { off.world_size_x = OG_Maps->getOffset ("world_size_x_from_wdata"); off.world_size_y = OG_Maps->getOffset ("world_size_y_from_wdata"); } else { 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"); } try { off.mystery = OG_MapBlock->getOffset ("mystery_offset"); } catch(Error::AllMemdef &) { off.mystery = 0; } try { OffsetGroup *OG_Geology = OG_Maps->getGroup("geology"); if(d->usesWorldDataPtr) { off.world_regions = OG_Geology->getOffset ("ptr2_region_array_from_wdata"); off.world_geoblocks_vector = OG_Geology->getOffset ("geoblock_vector_from_wdata"); } else { off.world_regions = OG_Geology->getAddress ("ptr2_region_array"); off.world_geoblocks_vector = OG_Geology->getAddress ("geoblock_vector"); } 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.type_inside_geolayer = OG_Geology->getOffset ("type_inside_geolayer"); } catch(Error::AllMemdef &) { d->hasGeology = false; } OffsetGroup *OG_global_features = OG_Maps->getGroup("features")->getGroup("global"); OffsetGroup *OG_local_features = OG_Maps->getGroup("features")->getGroup("local"); try { if(d->usesWorldDataPtr) { off.local_f_start = OG_local_features->getOffset("start_ptr_from_wdata"); off.global_vector = OG_global_features->getOffset("vector_from_wdata"); } else { off.local_f_start = OG_local_features->getAddress("start_ptr"); off.global_vector = OG_global_features->getAddress("vector"); } off.local_material = OG_local_features->getOffset("material"); off.local_submaterial = OG_local_features->getOffset("submaterial"); off.global_funcptr = OG_global_features->getOffset("funcptr"); off.global_material = OG_global_features->getOffset("material"); off.global_submaterial = OG_global_features->getOffset("submaterial"); } catch(Error::AllMemdef &) { d->hasFeatures = false; } try { OffsetGroup * OG_Veg = d->d->offset_descriptor->getGroup("Vegetation"); off.vegvector = OG_MapBlock->getOffset ("vegetation_vector"); off.tree_desc_offset = OG_Veg->getOffset ("tree_desc_offset"); } catch(Error::AllMemdef &) { d->hasVeggies = false; } } 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); off.vein_mineral_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_mineral",off.vein_mineral_vptr); off.vein_spatter_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_material_spatterst",off.vein_spatter_vptr); off.vein_grass_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_grassst",off.vein_grass_vptr); off.vein_worldconstruction_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_world_constructionst",off.vein_worldconstruction_vptr); d->Inited = true; }
Maps::Maps(DFContextShared* _d) { d = new Private; d->d = _d; Process *p = d->owner = _d->p; d->Inited = d->Started = false; d->block = NULL; DFHack::VersionInfo * mem = p->getDescriptor(); Server::Maps::maps_offsets &off = d->offsets; // get the offsets once here 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); off.vein_mineral_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_mineral",off.vein_mineral_vptr); // upload offsets to SHM server if possible d->maps_module = 0; if(p->getModuleIndex("Maps2010",1,d->maps_module)) { // supply the module with offsets so it can work with them Server::Maps::maps_offsets *off2 = SHMDATA(Server::Maps::maps_offsets); memcpy(off2, &(d->offsets), sizeof(Server::Maps::maps_offsets)); full_barrier const uint32_t cmd = Server::Maps::MAP_INIT + (d->maps_module << 16); p->SetAndWait(cmd); } d->Inited = true; }
Maps::Maps() { Core & c = Core::getInstance(); d = new Private; Process *p = d->owner = c.p; d->Inited = d->FeaturesStarted = d->Started = false; DFHack::VersionInfo * mem = c.vinfo; Private::t_offsets &off = d->offsets; d->hasFeatures = d->hasGeology = d->hasVeggies = true; // get the offsets once here OffsetGroup *OG_Maps = mem->getGroup("Maps"); off.world_data = OG_Maps->getAddress("world_data"); { mdata = (map_data *) OG_Maps->getAddress ("map_data"); off.world_size_x = OG_Maps->getOffset ("world_size_x_from_wdata"); off.world_size_y = OG_Maps->getOffset ("world_size_y_from_wdata"); try { OffsetGroup *OG_Geology = OG_Maps->getGroup("geology"); off.world_regions = OG_Geology->getOffset ("ptr2_region_array_from_wdata"); off.world_geoblocks_vector = OG_Geology->getOffset ("geoblock_vector_from_wdata"); 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.type_inside_geolayer = OG_Geology->getOffset ("type_inside_geolayer"); } catch(Error::AllMemdef &) { d->hasGeology = false; } OffsetGroup *OG_global_features = OG_Maps->getGroup("features")->getGroup("global"); OffsetGroup *OG_local_features = OG_Maps->getGroup("features")->getGroup("local"); try { off.local_f_start = OG_local_features->getOffset("start_ptr_from_wdata"); off.global_vector = OG_global_features->getOffset("vector_from_wdata"); off.local_material = OG_local_features->getOffset("material"); off.local_submaterial = OG_local_features->getOffset("submaterial"); off.global_funcptr = OG_global_features->getOffset("funcptr"); off.global_material = OG_global_features->getOffset("material"); off.global_submaterial = OG_global_features->getOffset("submaterial"); } catch(Error::AllMemdef &) { d->hasFeatures = false; } } 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); off.vein_mineral_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_mineral",off.vein_mineral_vptr); off.vein_spatter_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_material_spatterst",off.vein_spatter_vptr); off.vein_grass_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_grassst",off.vein_grass_vptr); off.vein_worldconstruction_vptr = 0; mem->resolveClassnameToVPtr("block_square_event_world_constructionst",off.vein_worldconstruction_vptr); d->Inited = true; }