From 9f939687ec7c0b1945f155bc4fbc335bc8a7fcf0 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 30 Apr 2010 17:42:31 +0200 Subject: [PATCH] Some generic material is decoded, although not well --- dfhack/include/modules/Materials.h | 7 +++++++ dfhack/modules/Materials.cpp | 23 +++++++++++++++++++++++ examples/dfitemdump.cpp | 7 ++++++- output/Memory.xml | 5 ++++- 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/dfhack/include/modules/Materials.h b/dfhack/include/modules/Materials.h index 46931d4d5..8198b2991 100644 --- a/dfhack/include/modules/Materials.h +++ b/dfhack/include/modules/Materials.h @@ -46,6 +46,11 @@ namespace DFHack char adjective[128]; }; + struct t_matglossOther + { + char rawname[128]; + }; + struct t_creatureextract { char rawname[128]; @@ -89,6 +94,7 @@ namespace DFHack std::vector race; std::vector raceEx; std::vector color; + std::vector other; bool ReadInorganicMaterials (void); bool ReadOrganicMaterials (void); @@ -97,6 +103,7 @@ namespace DFHack bool ReadCreatureTypes (void); bool ReadCreatureTypesEx (void); bool ReadDescriptorColors(void); + bool ReadOthers (void); void ReadAllMaterials(void); diff --git a/dfhack/modules/Materials.cpp b/dfhack/modules/Materials.cpp index db00297d5..99150a041 100644 --- a/dfhack/modules/Materials.cpp +++ b/dfhack/modules/Materials.cpp @@ -240,6 +240,28 @@ bool Materials::ReadCreatureTypes (void) return true; } +bool Materials::ReadOthers(void) +{ + Process * p = d->owner; + uint32_t matBase = p->getDescriptor()->getAddress ("mat_other"); + uint32_t i = 0; + uint32_t ptr; + + other.clear(); + + while(1) + { + t_matglossOther mat; + ptr = p->readDWord(matBase + i*4); + if(ptr==0) + break; + p->readSTLString(ptr, mat.rawname, sizeof(mat.rawname)); + other.push_back(mat); + i++; + } + return true; +} + bool Materials::ReadDescriptorColors (void) { Process * p = d->owner; @@ -319,6 +341,7 @@ void Materials::ReadAllMaterials(void) this->ReadCreatureTypes(); this->ReadCreatureTypesEx(); this->ReadDescriptorColors(); + this->ReadOthers(); } std::string Materials::getDescription(t_material & mat) diff --git a/examples/dfitemdump.cpp b/examples/dfitemdump.cpp index 0816bba68..da4656a47 100644 --- a/examples/dfitemdump.cpp +++ b/examples/dfitemdump.cpp @@ -32,7 +32,12 @@ std::string getMatDesc(int32_t typeB, int32_t typeC, int32_t typeD) if(typeC>0x292) return "?"; else - return "stuff"; + { + if(typeC>=Materials->other.size()) + return "stuff"; + else + return Materials->other[typeC].rawname; + } else return Materials->inorganic[typeD].id; } diff --git a/output/Memory.xml b/output/Memory.xml index 732af6339..a54ef24b5 100755 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -1443,7 +1443,10 @@ map_data_1b60_offset 0x1B9c ========= soil, stone, metal inorganics vector = WORLD + 0x54B7C = 0x16B0D4C -
0x16B0D4C
+
0x16B0D4C
+ + stuff like glass, coke, ... +
0x16BA114
wood and plant matter, WORLD + 0x54B94
0x16B0D64