From 9705e05d8c67f8e739b20d9bffe9c05119997255 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 19 Apr 2010 11:23:11 +0200 Subject: [PATCH] Creature tile description support Reading of the tile character and colors in the race structure, plus offsets in Memory.xml. Upgrade of creaturedump --- dfhack/include/modules/Materials.h | 7 +++++++ dfhack/modules/Materials.cpp | 6 ++++++ examples/creaturedump.cpp | 14 ++++++++++---- output/Memory.xml | 4 +++- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/dfhack/include/modules/Materials.h b/dfhack/include/modules/Materials.h index eb9f0c6fd..f190e8737 100644 --- a/dfhack/include/modules/Materials.h +++ b/dfhack/include/modules/Materials.h @@ -41,6 +41,13 @@ namespace DFHack { char rawname[128]; vector castes; + uint8_t tile_character; + struct + { + uint16_t fore; + uint16_t back; + uint16_t bright; + } tilecolor; }; class DFHACK_EXPORT Materials diff --git a/dfhack/modules/Materials.cpp b/dfhack/modules/Materials.cpp index 93ca96e93..1505a6796 100644 --- a/dfhack/modules/Materials.cpp +++ b/dfhack/modules/Materials.cpp @@ -232,6 +232,8 @@ bool Materials::ReadCreatureTypesEx (vector & creatures) uint32_t sizeof_string = mem->getHexValue ("sizeof_string"); uint32_t size = p_races.size(); uint32_t sizecas = 0; + uint32_t tile_offset = mem->getOffset ("creature_tile"); + uint32_t tile_color_offset = mem->getOffset ("creature_tile_color"); creatures.clear(); creatures.reserve (size); for (uint32_t i = 0; i < size;i++) @@ -250,6 +252,10 @@ bool Materials::ReadCreatureTypesEx (vector & creatures) p->readSTLString (caste_start + 3 * sizeof_string, caste.adjective, sizeof(caste.adjective)); mat.castes.push_back(caste); } + mat.tile_character = p->readByte( p_races[i] + tile_offset ); + mat.tilecolor.fore = p->readWord( p_races[i] + tile_color_offset ); + mat.tilecolor.back = p->readWord( p_races[i] + tile_color_offset + 2 ); + mat.tilecolor.bright = p->readWord( p_races[i] + tile_color_offset + 4 ); creatures.push_back(mat); } return true; diff --git a/examples/creaturedump.cpp b/examples/creaturedump.cpp index ffcb1b22e..795387769 100644 --- a/examples/creaturedump.cpp +++ b/examples/creaturedump.cpp @@ -33,7 +33,7 @@ enum likeType FOOD = 3 }; -vector creaturestypes; +vector creaturestypes; matGlosses mat; vector< vector > itemTypes; DFHack::memory_info *mem; @@ -147,7 +147,13 @@ likeType printLike40d(DFHack::t_like like, const matGlosses & mat,const vector< void printCreature(DFHack::API & DF, const DFHack::t_creature & creature) { - cout << "address: " << hex << creature.origin << dec << " creature type: " << creaturestypes[creature.race].id << ", position: " << creature.x << "x " << creature.y << "y "<< creature.z << "z" << endl; + cout << "address: " << hex << creature.origin << dec << " creature type: " << creaturestypes[creature.race].rawname + << "[" << creaturestypes[creature.race].tile_character + << "," << creaturestypes[creature.race].tilecolor.fore + << "," << creaturestypes[creature.race].tilecolor.back + << "," << creaturestypes[creature.race].tilecolor.bright + << "]" + << ", position: " << creature.x << "x " << creature.y << "y "<< creature.z << "z" << endl; bool addendl = false; if(creature.name.first_name[0]) { @@ -394,7 +400,7 @@ int main (int numargs, char ** args) mem = DF.getMemoryInfo(); // get stone matgloss mapping - if(!Materials->ReadCreatureTypes(creaturestypes)) + if(!Materials->ReadCreatureTypesEx(creaturestypes)) { cerr << "Can't get the creature types." << endl; return 1; @@ -411,7 +417,7 @@ int main (int numargs, char ** args) { DFHack::t_creature temp; Creatures->ReadCreature(i,temp); - if(check.empty() || string(creaturestypes[temp.race].id) == check) + if(check.empty() || string(creaturestypes[temp.race].rawname) == check) { cout << "index " << i << " "; diff --git a/output/Memory.xml b/output/Memory.xml index 4350fac70..1b94d3000 100644 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -1200,7 +1200,9 @@ map_data_1b60_offset 0x1B9c WORLD + 0x54CD0
0x016AFE58
0x138 - + 0xE0 + 0xF6 +