From d43531363266dd033efba73b077ff219d772a47b Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 5 May 2010 13:48:01 +0200 Subject: [PATCH] Body parts are decoded Color modifiers parts are decoded --- dfhack/include/modules/Materials.h | 17 ++++++++++++++++- dfhack/modules/Materials.cpp | 30 +++++++++++++++++++++++++++--- examples/materialtest.cpp | 16 +++++++++++----- output/Memory.xml | 12 +++++++++++- 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/dfhack/include/modules/Materials.h b/dfhack/include/modules/Materials.h index eef9a5251..f216893b2 100644 --- a/dfhack/include/modules/Materials.h +++ b/dfhack/include/modules/Materials.h @@ -37,6 +37,20 @@ namespace DFHack char food_name[128]; char extract_name[128]; }; + + struct t_bodypart + { + char id[128]; + char category[128]; + char single[128]; + char plural[128]; + }; + + struct t_colormodifier + { + char part[128]; + std::vector colorlist; + }; struct t_creaturecaste { @@ -44,7 +58,8 @@ namespace DFHack char singular[128]; char plural[128]; char adjective[128]; - std::vector > ColorModifier; + std::vector ColorModifier; + std::vector bodypart; }; struct t_matglossOther diff --git a/dfhack/modules/Materials.cpp b/dfhack/modules/Materials.cpp index c06830ce3..2c95c9c4c 100644 --- a/dfhack/modules/Materials.cpp +++ b/dfhack/modules/Materials.cpp @@ -295,10 +295,18 @@ bool Materials::ReadCreatureTypesEx (void) 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 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"); + uint32_t bodypart_plural_offset = mem->getOffset ("bodypart_plural_vector"); + uint32_t color_modifier_part_offset = mem->getOffset ("color_modifier_part"); 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(); @@ -311,24 +319,40 @@ bool Materials::ReadCreatureTypesEx (void) sizecas = p_castes.size(); for (uint32_t j = 0; j < sizecas;j++) { + /* caste name */ t_creaturecaste caste; uint32_t caste_start = p_castes[j]; p->readSTLString (caste_start, caste.rawname, sizeof(caste.rawname)); p->readSTLString (caste_start + sizeof_string, caste.singular, sizeof(caste.singular)); p->readSTLString (caste_start + 2 * sizeof_string, caste.plural, sizeof(caste.plural)); p->readSTLString (caste_start + 3 * sizeof_string, caste.adjective, sizeof(caste.adjective)); + + /* color mod reading */ DfVector p_colormod(p, caste_start + caste_colormod_offset); sizecolormod = p_colormod.size(); caste.ColorModifier.resize(sizecolormod); - for(uint32_t k = 0; k < sizecolormod;k++) { DfVector p_colorlist(p, p_colormod[k]); sizecolorlist = p_colorlist.size(); - caste.ColorModifier[k].resize(sizecolorlist); + caste.ColorModifier[k].colorlist.resize(sizecolorlist); for(uint32_t l = 0; l < sizecolorlist; l++) - caste.ColorModifier[k][l] = p_colorlist[l]; + caste.ColorModifier[k].colorlist[l] = p_colorlist[l]; + p->readSTLString( p_colormod[k] + color_modifier_part_offset, caste.ColorModifier[k].part, sizeof(caste.ColorModifier[k].part)); } + + /* body parts */ + DfVector p_bodypart(p, caste_start + caste_bodypart_offset); + caste.bodypart.empty(); + sizebp = p_bodypart.size(); + for(uint32_t k = 0; k < sizebp; k++) + { + t_bodypart part; + p->readSTLString (p_bodypart[k] + bodypart_id_offset, part.id, sizeof(part.id)); + p->readSTLString (p_bodypart[k] + bodypart_category_offset, part.category, sizeof(part.category)); + caste.bodypart.push_back(part); + } + mat.castes.push_back(caste); } mat.tile_character = p->readByte( p_races[i] + tile_offset ); diff --git a/examples/materialtest.cpp b/examples/materialtest.cpp index f37b22529..4dc1b1088 100644 --- a/examples/materialtest.cpp +++ b/examples/materialtest.cpp @@ -100,16 +100,22 @@ int main (int numargs, const char ** args) cout << endl; for(uint32_t k = 0; k < castes[j].ColorModifier.size(); k++) { - cout << " colormod[" << k << "] "; - for(uint32_t l = 0; l < castes[j].ColorModifier[k].size(); l++) + cout << " colormod[" << castes[j].ColorModifier[k].part << "] "; + for(uint32_t l = 0; l < castes[j].ColorModifier[k].colorlist.size(); l++) { - if( castes[j].ColorModifier[k][l] < Materials->color.size() ) - cout << Materials->color[castes[j].ColorModifier[k][l]].name << " "; + if( castes[j].ColorModifier[k].colorlist[l] < Materials->color.size() ) + cout << Materials->color[castes[j].ColorModifier[k].colorlist[l]].name << " "; else - cout << Materials->alldesc[castes[j].ColorModifier[k][l]].id << " "; + cout << Materials->alldesc[castes[j].ColorModifier[k].colorlist[l]].id << " "; } cout << endl; } + cout << " body: "; + for(uint32_t k = 0; k < castes[j].bodypart.size(); k++) + { + cout << castes[j].bodypart[k].category << " "; + } + cout << endl; } cout << endl; } diff --git a/output/Memory.xml b/output/Memory.xml index 0b883bdcf..2b123d148 100755 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -1435,7 +1435,7 @@ map_data_1b60_offset 0x1B9c --> 0x390 0x394 the skill that will be increased at the end of the mood (or not) - 0x604 seems to be indexes in the list of possible colors defined in the raws for each group + 0x604 0x6D4 0x774 0x0740 @@ -1444,7 +1444,17 @@ map_data_1b60_offset 0x1B9c Castes ====== + 0x51C 0xACC + 0x70 + + Body Parts + ========== + 0x0 + 0x1C + 0x44 + 0x78 + 0x90 Materials =========