From 95abf6e6053ee41309a19491e52a86e65e6a7941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 30 Aug 2010 00:08:17 +0200 Subject: [PATCH] All the modules *should* now use the new offset storage properly. Maybe, needs testing :) --- data/Memory-ng.xml | 4 ++ library/include/dfhack/modules/Items.h | 5 ++ library/modules/Buildings.cpp | 11 +-- library/modules/Constructions.cpp | 2 +- library/modules/Creatures.cpp | 92 ++++++++++++++------------ library/modules/Gui.cpp | 8 +-- library/modules/Items.cpp | 11 +-- library/modules/Maps.cpp | 67 ++++++++++--------- library/modules/Materials.cpp | 85 +++++++++++++++--------- library/modules/Position.cpp | 1 + library/modules/Translation.cpp | 11 +-- library/modules/Vegetation.cpp | 8 ++- library/modules/World.cpp | 6 +- 13 files changed, 182 insertions(+), 129 deletions(-) diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml index 6d85acfe5..9ba868c52 100644 --- a/data/Memory-ng.xml +++ b/data/Memory-ng.xml @@ -918,6 +918,7 @@ + @@ -952,6 +953,7 @@
+
@@ -1013,6 +1015,7 @@ +
List of offsets in the VTable : @@ -1554,6 +1557,7 @@
+ diff --git a/library/include/dfhack/modules/Items.h b/library/include/dfhack/modules/Items.h index 9b2dba8fe..3810e6037 100644 --- a/library/include/dfhack/modules/Items.h +++ b/library/include/dfhack/modules/Items.h @@ -1,5 +1,10 @@ #ifndef CL_MOD_ITEMS #define CL_MOD_ITEMS + +/* + * DEPRECATED, DO NOT USE UNTIL FURTHER NOTICE! + **/ + /* * Creatures */ diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index a927277a7..92fca41d3 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -72,11 +72,12 @@ Buildings::Buildings(DFContextShared * d_) d->owner = d_->p; d->Inited = d->Started = false; VersionInfo * mem = d->d->offset_descriptor; - d->custom_workshop_vector = mem->getAddress("custom_workshop_vector"); - d->building_custom_workshop_type = mem->getOffset("building_custom_workshop_type"); - d->custom_workshop_type = mem->getOffset("custom_workshop_type"); - d->custom_workshop_name = mem->getOffset("custom_workshop_name"); - d->buildings_vector = mem->getAddress ("buildings_vector"); + OffsetGroup * OG_build = mem->getGroup("Buildings"); + d->custom_workshop_vector = OG_build->getAddress("custom_workshop_vector"); + d->building_custom_workshop_type = OG_build->getOffset("building_custom_workshop_type"); + d->custom_workshop_type = OG_build->getOffset("custom_workshop_type"); + d->custom_workshop_name = OG_build->getOffset("custom_workshop_name"); + d->buildings_vector = OG_build->getAddress ("buildings_vector"); mem->resolveClassnameToClassID("building_custom_workshop", d->custom_workshop_id); d->Inited = true; } diff --git a/library/modules/Constructions.cpp b/library/modules/Constructions.cpp index de8bc5985..ba6370ffd 100644 --- a/library/modules/Constructions.cpp +++ b/library/modules/Constructions.cpp @@ -53,7 +53,7 @@ Constructions::Constructions(DFContextShared * d_) d->p_cons = 0; d->Inited = d->Started = false; VersionInfo * mem = d->d->offset_descriptor; - d->construction_vector = mem->getAddress ("construction_vector"); + d->construction_vector = mem->getGroup("Constructions")->getAddress ("vector"); d->Inited = true; } diff --git a/library/modules/Creatures.cpp b/library/modules/Creatures.cpp index 73f2691c7..141828243 100644 --- a/library/modules/Creatures.cpp +++ b/library/modules/Creatures.cpp @@ -71,49 +71,59 @@ Creatures::Creatures(DFContextShared* _d) { VersionInfo * minfo = d->d->offset_descriptor; Creatures2010::creature_offsets &creatures = d->creatures; - creatures.vector = minfo->getAddress ("creature_vector"); - creatures.pos_offset = minfo->getOffset ("creature_position"); - creatures.profession_offset = minfo->getOffset ("creature_profession"); - creatures.custom_profession_offset = minfo->getOffset ("creature_custom_profession"); - creatures.race_offset = minfo->getOffset ("creature_race"); - creatures.civ_offset = minfo->getOffset ("creature_civ"); - creatures.flags1_offset = minfo->getOffset ("creature_flags1"); - creatures.flags2_offset = minfo->getOffset ("creature_flags2"); - creatures.name_offset = minfo->getOffset ("creature_name"); - creatures.sex_offset = minfo->getOffset ("creature_sex"); - creatures.caste_offset = minfo->getOffset ("creature_caste"); - creatures.id_offset = minfo->getOffset ("creature_id"); - creatures.labors_offset = minfo->getOffset ("creature_labors"); - creatures.happiness_offset = minfo->getOffset ("creature_happiness"); - creatures.artifact_name_offset = minfo->getOffset("creature_artifact_name"); - creatures.soul_vector_offset = minfo->getOffset("creature_soul_vector"); - creatures.default_soul_offset = minfo->getOffset("creature_default_soul"); - creatures.physical_offset = minfo->getOffset("creature_physical"); - creatures.mood_offset = minfo->getOffset("creature_mood"); - creatures.mood_skill_offset = minfo->getOffset("creature_mood_skill"); - creatures.pickup_equipment_bit = minfo->getOffset("creature_pickup_equipment_bit"); - creatures.current_job_offset = minfo->getOffset("creature_current_job"); - // soul offsets - creatures.soul_skills_vector_offset = minfo->getOffset("soul_skills_vector"); - creatures.soul_mental_offset = minfo->getOffset("soul_mental"); - creatures.soul_traits_offset = minfo->getOffset("soul_traits"); - - // appearance - creatures.appearance_vector_offset = minfo->getOffset("creature_appearance_vector"); - - //birth - creatures.birth_year_offset = minfo->getOffset("creature_birth_year"); - creatures.birth_time_offset = minfo->getOffset("creature_birth_time"); - + OffsetGroup *OG_Creatures = minfo->getGroup("Creatures"); + { + creatures.vector = OG_Creatures->getAddress ("vector"); + d->dwarf_race_index_addr = OG_Creatures->getAddress("current_race"); + d->dwarf_civ_id_addr = OG_Creatures->getAddress("current_civ"); + OffsetGroup *OG_creature = OG_Creatures->getGroup("creature"); + { + creatures.name_offset = OG_creature->getOffset ("name"); + creatures.custom_profession_offset = OG_creature->getOffset ("custom_profession"); + creatures.profession_offset = OG_creature->getOffset ("profession"); + creatures.race_offset = OG_creature->getOffset ("race"); + creatures.pos_offset = OG_creature->getOffset ("position"); + creatures.flags1_offset = OG_creature->getOffset ("creature_flags1"); + creatures.flags2_offset = OG_creature->getOffset ("creature_flags2"); + creatures.sex_offset = OG_creature->getOffset ("sex"); + creatures.caste_offset = OG_creature->getOffset ("caste"); + creatures.id_offset = OG_creature->getOffset ("id"); + creatures.civ_offset = OG_creature->getOffset ("civ"); + OffsetGroup *OG_creature_ex = OG_creature->getGroup("advanced"); + { + creatures.inventory_offset = OG_creature_ex->getOffset("inventory_vector"); + creatures.pickup_equipment_bit = OG_creature_ex->getOffset("pickup_equipment_bit"); + creatures.mood_offset = OG_creature_ex->getOffset("mood"); + // pregnancy + // pregnancy_ptr + creatures.birth_year_offset = OG_creature_ex->getOffset("birth_year"); + creatures.birth_time_offset = OG_creature_ex->getOffset("birth_time"); + creatures.current_job_offset = OG_creature_ex->getOffset("current_job"); + creatures.mood_skill_offset = OG_creature_ex->getOffset("current_job_skill"); + creatures.physical_offset = OG_creature_ex->getOffset("physical"); + creatures.appearance_vector_offset = OG_creature_ex->getOffset("appearance_vector"); + creatures.artifact_name_offset = OG_creature_ex->getOffset("artifact_name"); + creatures.soul_vector_offset = OG_creature_ex->getOffset("soul_vector"); + creatures.default_soul_offset = OG_creature_ex->getOffset("current_soul"); + creatures.labors_offset = OG_creature_ex->getOffset ("labors"); + creatures.happiness_offset = OG_creature_ex->getOffset ("happiness"); + } + } + OffsetGroup *OG_soul = OG_Creatures->getGroup("soul"); + { + creatures.soul_mental_offset = OG_soul->getOffset("mental"); + creatures.soul_skills_vector_offset = OG_soul->getOffset("skills_vector"); + creatures.soul_traits_offset = OG_soul->getOffset("traits"); + } + } // name offsets for the creature module - creatures.name_firstname_offset = minfo->getOffset("name_firstname"); - creatures.name_nickname_offset = minfo->getOffset("name_nickname"); - creatures.name_words_offset = minfo->getOffset("name_words"); - - creatures.inventory_offset = minfo->getOffset("creature_inventory_vector"); + OffsetGroup * OG_name = minfo->getGroup("name"); + { + creatures.name_firstname_offset = OG_name->getOffset("first"); + creatures.name_nickname_offset = OG_name->getOffset("nick"); + creatures.name_words_offset = OG_name->getOffset("second_words"); + } - d->dwarf_race_index_addr = minfo->getAddress("dwarf_race_index"); - d->dwarf_civ_id_addr = minfo->getAddress("dwarf_civ_id"); /* // upload offsets to the SHM if(p->getModuleIndex("Creatures2010",1,d->creature_module)) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index 26835aab5..4bb29f1f0 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -51,10 +51,10 @@ Gui::Gui(DFContextShared * _d) d->owner = _d->p; d->Inited = d->Started = true; - VersionInfo * mem = d->d->offset_descriptor; - d->current_menu_state_offset = mem->getAddress("current_menu_state"); - d->pause_state_offset = mem->getAddress ("pause_state"); - d->view_screen_offset = mem->getAddress ("view_screen"); + OffsetGroup * OG_Gui = d->d->offset_descriptor->getGroup("Gui"); + d->current_menu_state_offset = OG_Gui->getAddress("current_menu_state"); + d->pause_state_offset = OG_Gui->getAddress ("pause_state"); + d->view_screen_offset = OG_Gui->getAddress ("view_screen"); d->Inited = d->Started = true; } diff --git a/library/modules/Items.cpp b/library/modules/Items.cpp index 47ba55fb2..6ae558dcd 100644 --- a/library/modules/Items.cpp +++ b/library/modules/Items.cpp @@ -189,11 +189,12 @@ int32_t Accessor::getValue(uint32_t objectPtr) ItemDesc::ItemDesc(uint32_t VTable, Process *p) { - uint32_t funcOffsetA = p->getDescriptor()->getOffset("item_type_accessor"); - uint32_t funcOffsetB = p->getDescriptor()->getOffset("item_subtype_accessor"); - uint32_t funcOffsetC = p->getDescriptor()->getOffset("item_subindex_accessor"); - uint32_t funcOffsetD = p->getDescriptor()->getOffset("item_index_accessor"); - uint32_t funcOffsetQuality = p->getDescriptor()->getOffset("item_quality_accessor"); + OffsetGroup * Items = p->getDescriptor()->getGroup("Items"); + uint32_t funcOffsetA = Items->getOffset("item_type_accessor"); + uint32_t funcOffsetB = Items->getOffset("item_subtype_accessor"); + uint32_t funcOffsetC = Items->getOffset("item_subindex_accessor"); + uint32_t funcOffsetD = Items->getOffset("item_index_accessor"); + uint32_t funcOffsetQuality = Items->getOffset("item_quality_accessor"); this->vtable = VTable; this->p = p; this->className = p->readClassName(VTable).substr(5); diff --git a/library/modules/Maps.cpp b/library/modules/Maps.cpp index d44cdeee6..eab61faf9 100644 --- a/library/modules/Maps.cpp +++ b/library/modules/Maps.cpp @@ -76,37 +76,42 @@ Maps::Maps(DFContextShared* _d) // 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"); + { + 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 diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index 9a8d2b60a..b5ce66306 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -38,6 +38,12 @@ class Materials::Private DFContextShared *d; Process * owner; OffsetGroup * OG_Materials; + uint32_t vector_inorganic; + uint32_t vector_organic_all; + uint32_t vector_organic_plants; + uint32_t vector_organic_trees; + uint32_t vector_races; + uint32_t vector_other; /* bool Inited; bool Started; @@ -49,7 +55,14 @@ Materials::Materials(DFContextShared * d_) d = new Private; d->d = d_; d->owner = d_->p; - d->OG_Materials = d->owner->getDescriptor()->getGroup("Materials"); + OffsetGroup *OG_Materials = d->OG_Materials = d->owner->getDescriptor()->getGroup("Materials"); + { + d->vector_inorganic = OG_Materials->getAddress("inorganics"); + d->vector_organic_all = OG_Materials->getAddress ("organics_all"); + d->vector_organic_plants = OG_Materials->getAddress ("organics_plants"); + d->vector_organic_trees = OG_Materials->getAddress ("organics_trees"); + d->vector_races = OG_Materials->getAddress("creature_type_vector"); + } } Materials::~Materials() { @@ -218,7 +231,7 @@ inline bool ReadNamesOnly(Process* p, uint32_t address, vector & nam bool Materials::ReadInorganicMaterials (void) { Process * p = d->owner; - DfVector p_matgloss (p, d->OG_Materials->getAddress("inorganics")); + DfVector p_matgloss (p, d->vector_inorganic); uint32_t size = p_matgloss.size(); inorganic.clear(); inorganic.reserve (size); @@ -239,22 +252,22 @@ bool Materials::ReadInorganicMaterials (void) bool Materials::ReadOrganicMaterials (void) { - return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("organics_all"), organic ); + return ReadNamesOnly(d->owner, d->vector_organic_all, organic ); } bool Materials::ReadWoodMaterials (void) { - return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("organics_trees"), tree ); + return ReadNamesOnly(d->owner, d->vector_organic_trees, tree ); } bool Materials::ReadPlantMaterials (void) { - return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("organics_plants"), plant ); + return ReadNamesOnly(d->owner, d->vector_organic_plants, plant ); } bool Materials::ReadCreatureTypes (void) { - return ReadNamesOnly(d->owner, d->OG_Materials->getAddress ("creature_type_vector"), race ); + return ReadNamesOnly(d->owner, d->vector_races, race ); return true; } @@ -283,7 +296,8 @@ bool Materials::ReadOthers(void) bool Materials::ReadDescriptorColors (void) { Process * p = d->owner; - DfVector p_colors (p, p->getDescriptor()->getAddress ("descriptor_colors_vector")); + OffsetGroup * OG_Descriptors = p->getDescriptor()->getGroup("Materials")->getGroup("descriptors"); + DfVector p_colors (p, OG_Descriptors->getAddress ("colors_vector")); uint32_t size = p_colors.size(); color.clear(); @@ -293,43 +307,52 @@ bool Materials::ReadDescriptorColors (void) for (uint32_t i = 0; i < size;i++) { t_descriptor_color col; - p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_rawname"), col.id, 128); - p->readSTLString (p_colors[i] + p->getDescriptor()->getOffset ("descriptor_name"), col.name, 128); - col.r = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_r") ); - col.v = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_v") ); - col.b = p->readFloat( p_colors[i] + p->getDescriptor()->getOffset ("descriptor_color_b") ); + p->readSTLString (p_colors[i] + OG_Descriptors->getOffset ("rawname"), col.id, 128); + p->readSTLString (p_colors[i] + OG_Descriptors->getOffset ("name"), col.name, 128); + col.r = p->readFloat( p_colors[i] + OG_Descriptors->getOffset ("color_r") ); + col.v = p->readFloat( p_colors[i] + OG_Descriptors->getOffset ("color_v") ); + col.b = p->readFloat( p_colors[i] + OG_Descriptors->getOffset ("color_b") ); color.push_back(col); } - return ReadNamesOnly(d->owner, d->owner->getDescriptor()->getAddress ("descriptor_all_colors"), alldesc ); + return ReadNamesOnly(d->owner, OG_Descriptors->getAddress ("all_colors_vector"), alldesc ); return true; } bool Materials::ReadCreatureTypesEx (void) { Process *p = d->owner; - VersionInfo *mem = d->owner->getDescriptor(); - DfVector p_races (p, mem->getAddress ("creature_type_vector")); - uint32_t castes_vector_offset = mem->getOffset ("creature_type_caste_vector"); - uint32_t extract_vector_offset = mem->getOffset ("creature_type_extract_vector"); - uint32_t sizeof_string = mem->getHexValue ("sizeof_string"); - uint32_t caste_colormod_offset = mem->getOffset ("caste_color_modifiers"); - uint32_t caste_bodypart_offset = mem->getOffset ("caste_bodypart_vector"); - uint32_t caste_attributes_offset = mem->getOffset ("caste_attributes"); - uint32_t bodypart_id_offset = mem->getOffset ("bodypart_id"); - uint32_t bodypart_category_offset = mem->getOffset ("bodypart_category"); - uint32_t bodypart_layers_offset = mem->getOffset ("bodypart_layers_vector"); - uint32_t bodypart_singular_offset = mem->getOffset ("bodypart_singular_vector"); // unused - uint32_t bodypart_plural_offset = mem->getOffset ("bodypart_plural_vector"); // unused - uint32_t color_modifier_part_offset = mem->getOffset ("color_modifier_part"); - uint32_t color_modifier_startdate_offset = mem->getOffset ("color_modifier_startdate"); - uint32_t color_modifier_enddate_offset = mem->getOffset ("color_modifier_enddate"); + VersionInfo *mem = p->getDescriptor(); + OffsetGroup * OG_string = mem->getGroup("string"); + uint32_t sizeof_string = OG_string->getHexValue ("sizeof"); + + OffsetGroup * OG_Mats = mem->getGroup("Materials"); + DfVector p_races (p, OG_Mats->getAddress ("creature_type_vector")); + + OffsetGroup * OG_Creature = OG_Mats->getGroup("creature"); + uint32_t castes_vector_offset = OG_Creature->getOffset ("caste_vector"); + uint32_t extract_vector_offset = OG_Creature->getOffset ("extract_vector"); + uint32_t tile_offset = OG_Creature->getOffset ("creature_tile"); + uint32_t tile_color_offset = OG_Creature->getOffset ("creature_tile_color"); + OffsetGroup * OG_Caste = OG_Creature->getGroup("caste"); + uint32_t caste_colormod_offset = OG_Caste->getOffset ("color_modifiers"); + uint32_t caste_attributes_offset = OG_Caste->getOffset ("attributes"); + uint32_t caste_bodypart_offset = OG_Caste->getOffset ("bodypart_vector"); + OffsetGroup * OG_CasteBodyparts = OG_Creature->getGroup("caste_bodyparts"); + uint32_t bodypart_id_offset = OG_CasteBodyparts->getOffset ("id"); + uint32_t bodypart_category_offset = OG_CasteBodyparts->getOffset ("category"); + uint32_t bodypart_layers_offset = OG_CasteBodyparts->getOffset ("layers_vector"); // unused + uint32_t bodypart_singular_offset = OG_CasteBodyparts->getOffset ("singular_vector"); // unused + uint32_t bodypart_plural_offset = OG_CasteBodyparts->getOffset ("plural_vector"); // unused + OffsetGroup * OG_CasteColorMods = OG_Creature->getGroup("caste_color_mods"); + uint32_t color_modifier_part_offset = OG_CasteColorMods->getOffset ("part"); + uint32_t color_modifier_startdate_offset = OG_CasteColorMods->getOffset ("startdate"); + uint32_t color_modifier_enddate_offset = OG_CasteColorMods->getOffset ("enddate"); + uint32_t size = p_races.size(); uint32_t sizecas = 0; uint32_t sizecolormod; uint32_t sizecolorlist; uint32_t sizebp; - uint32_t tile_offset = mem->getOffset ("creature_tile"); - uint32_t tile_color_offset = mem->getOffset ("creature_tile_color"); raceEx.clear(); raceEx.reserve (size); for (uint32_t i = 0; i < size;i++) diff --git a/library/modules/Position.cpp b/library/modules/Position.cpp index 1395e59e3..8dda58fae 100644 --- a/library/modules/Position.cpp +++ b/library/modules/Position.cpp @@ -61,6 +61,7 @@ Position::Position(DFContextShared * d_) d->StartedHotkeys = d->Started = d->StartedScreen = false; OffsetGroup * OG_Position; VersionInfo * mem = d->d->offset_descriptor; + // this is how to do feature detection properly try { OG_Position = mem->getGroup("Position"); diff --git a/library/modules/Translation.cpp b/library/modules/Translation.cpp index 28ea49d38..ba6018d55 100644 --- a/library/modules/Translation.cpp +++ b/library/modules/Translation.cpp @@ -52,11 +52,12 @@ Translation::Translation(DFContextShared * d_) d = new Private; d->d = d_; d->Inited = d->Started = false; - VersionInfo * mem = d->d->offset_descriptor; - d->genericAddress = mem->getAddress ("language_vector"); - d->transAddress = mem->getAddress ("translation_vector"); - d->word_table_offset = mem->getOffset ("word_table"); - d->sizeof_string = mem->getHexValue ("sizeof_string"); + OffsetGroup * OG_Translation = d->d->offset_descriptor->getGroup("Translations"); + OffsetGroup * OG_String = d->d->offset_descriptor->getGroup("string"); + d->genericAddress = OG_Translation->getAddress ("language_vector"); + d->transAddress = OG_Translation->getAddress ("translation_vector"); + d->word_table_offset = OG_Translation->getOffset ("word_table"); + d->sizeof_string = OG_String->getHexValue ("sizeof"); d->Inited = true; } diff --git a/library/modules/Vegetation.cpp b/library/modules/Vegetation.cpp index 2f0503c58..cceff66ef 100644 --- a/library/modules/Vegetation.cpp +++ b/library/modules/Vegetation.cpp @@ -53,9 +53,9 @@ Vegetation::Vegetation(DFContextShared * d_) d->owner = d_->p; d->d = d_; d->Inited = d->Started = false; - VersionInfo * mem = d->d->offset_descriptor; - d->vegetation_vector = mem->getAddress ("vegetation_vector"); - d->tree_desc_offset = mem->getOffset ("tree_desc_offset"); + OffsetGroup * OG_Veg = d->d->offset_descriptor->getGroup("Vegetation"); + d->vegetation_vector = OG_Veg->getAddress ("vector"); + d->tree_desc_offset = OG_Veg->getOffset ("tree_desc_offset"); d->Inited = true; } @@ -68,6 +68,8 @@ Vegetation::~Vegetation() bool Vegetation::Start(uint32_t & numplants) { + if(!d->Inited) + return false; d->p_veg = new DfVector (d->owner, d->vegetation_vector); numplants = d->p_veg->size(); d->Started = true; diff --git a/library/modules/World.cpp b/library/modules/World.cpp index 8db6d6f7c..7a2cab963 100644 --- a/library/modules/World.cpp +++ b/library/modules/World.cpp @@ -60,9 +60,9 @@ World::World(DFContextShared * _d) d->d = _d; d->owner = _d->p; - VersionInfo * mem = d->d->offset_descriptor; - d->year_offset = mem->getAddress( "current_year" ); - d->tick_offset = mem->getAddress( "current_tick" ); + OffsetGroup * OG_World = d->d->offset_descriptor->getGroup("World"); + d->year_offset = OG_World->getAddress( "current_year" ); + d->tick_offset = OG_World->getAddress( "current_tick" ); d->Inited = d->Started = true; }