diff --git a/dfhack/APIPrivate.cpp b/dfhack/APIPrivate.cpp index 37b2ce8da..2f132b8cc 100644 --- a/dfhack/APIPrivate.cpp +++ b/dfhack/APIPrivate.cpp @@ -11,6 +11,7 @@ #include "modules/Maps.h" #include "modules/Materials.h" #include "modules/Position.h" +#include "modules/Translation.h" #include "modules/Gui.h" using namespace DFHack; @@ -23,6 +24,7 @@ APIPrivate::APIPrivate() position = 0; gui = 0; materials = 0; + translation = 0; } APIPrivate::~APIPrivate() @@ -32,6 +34,7 @@ APIPrivate::~APIPrivate() if(position) delete position; if(gui) delete gui; if(materials) delete materials; + if(translation) delete translation; } bool APIPrivate::InitReadNames() diff --git a/dfhack/DFHackAPI.cpp b/dfhack/DFHackAPI.cpp index b0affcd1c..d47189f6b 100644 --- a/dfhack/DFHackAPI.cpp +++ b/dfhack/DFHackAPI.cpp @@ -40,6 +40,7 @@ distribution. #include "modules/Position.h" #include "modules/Gui.h" #include "modules/Creatures.h" +#include "modules/Translation.h" using namespace DFHack; @@ -201,6 +202,13 @@ Materials * API::getMaterials() return d->materials; } +Translation * API::getTranslation() +{ + if(!d->translation) + d->translation = new Translation(d); + return d->translation; +} + /* // returns number of buildings, expects v_buildingtypes that will later map t_building.type to its name bool API::InitReadBuildings ( uint32_t& numbuildings ) diff --git a/dfhack/include/DFHackAPI.h b/dfhack/include/DFHackAPI.h index 42caca606..352caeb1b 100644 --- a/dfhack/include/DFHackAPI.h +++ b/dfhack/include/DFHackAPI.h @@ -37,6 +37,7 @@ distribution. namespace DFHack { + class APIPrivate; class memory_info; class Process; @@ -47,6 +48,7 @@ namespace DFHack class Position; class Gui; class Materials; + class Translation; class DFHACK_EXPORT API { @@ -89,6 +91,7 @@ namespace DFHack Gui * getGui(); Position * getPosition(); Materials * getMaterials(); + Translation * getTranslation(); /* * Constructions (costructed walls, floors, ramps, etc...) diff --git a/dfhack/include/modules/Translation.h b/dfhack/include/modules/Translation.h index 7efb70d0c..e6b4d2237 100644 --- a/dfhack/include/modules/Translation.h +++ b/dfhack/include/modules/Translation.h @@ -1,5 +1,5 @@ -#ifndef CL_MOD_POSITION -#define CL_MOD_POSITION +#ifndef CL_MOD_TRANSLATION +#define CL_MOD_TRANSLATION /* * DF translation tables and name translation */ diff --git a/dfhack/modules/Creatures.cpp b/dfhack/modules/Creatures.cpp index 903de54c6..f925daddd 100644 --- a/dfhack/modules/Creatures.cpp +++ b/dfhack/modules/Creatures.cpp @@ -67,6 +67,7 @@ Creatures::Creatures(APIPrivate* _d) creatures.creature_vector = minfo->getAddress ("creature_vector"); creatures.creature_pos_offset = minfo->getOffset ("creature_position"); creatures.creature_profession_offset = minfo->getOffset ("creature_profession"); + creatures.creature_custom_profession_offset = minfo->getOffset ("creature_custom_profession"); creatures.creature_race_offset = minfo->getOffset ("creature_race"); creatures.creature_flags1_offset = minfo->getOffset ("creature_flags1"); creatures.creature_flags2_offset = minfo->getOffset ("creature_flags2"); @@ -153,7 +154,7 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball) //d->readName(furball.squad_name, temp + offs.creature_squad_name_offset); d->d->readName(furball.artifact_name, temp + offs.creature_artifact_name_offset); // custom profession - //fill_char_buf (furball.custom_profession, d->p->readSTLString (temp + offs.creature_custom_profession_offset)); + fill_char_buf (furball.custom_profession, g_pProcess->readSTLString (temp + offs.creature_custom_profession_offset)); // labors g_pProcess->read (temp + offs.creature_labors_offset, NUM_CREATURE_LABORS, furball.labors); diff --git a/dfhack/modules/Translation.cpp b/dfhack/modules/Translation.cpp index f2eac532a..ddec1c72e 100644 --- a/dfhack/modules/Translation.cpp +++ b/dfhack/modules/Translation.cpp @@ -54,10 +54,10 @@ Translation::Translation(APIPrivate * d_) d->d = d_; d->Inited = d->Started = false; memory_info * mem = d->d->offset_descriptor; - int genericAddress = mem->getAddress ("language_vector"); - int transAddress = mem->getAddress ("translation_vector"); - int word_table_offset = mem->getOffset ("word_table"); - int sizeof_string = mem->getHexValue ("sizeof_string"); + 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"); d->Inited = true; } @@ -75,8 +75,8 @@ bool Translation::Start() Process * p = d->d->p; DfVector genericVec (p, d->genericAddress, 4); DfVector transVec (p, d->transAddress, 4); - DFDict translations = d->dicts.translations; - DFDict foreign_languages = d->dicts.foreign_languages; + DFDict & translations = d->dicts.translations; + DFDict & foreign_languages = d->dicts.foreign_languages; translations.resize(10); for (uint32_t i = 0;i < genericVec.getSize();i++) diff --git a/dfhack/private/APIPrivate.h b/dfhack/private/APIPrivate.h index 07bd63adc..85fce5f26 100644 --- a/dfhack/private/APIPrivate.h +++ b/dfhack/private/APIPrivate.h @@ -36,6 +36,7 @@ namespace DFHack class Position; class Maps; class Creatures; + class Translation; class ProcessEnumerator; class Process; class memory_info; @@ -67,6 +68,7 @@ namespace DFHack Position * position; Gui * gui; Materials * materials; + Translation * translation; /* uint32_t item_material_offset; diff --git a/dfhack/shm/mod-creature2010.h b/dfhack/shm/mod-creature2010.h index 24795f889..facd42de1 100644 --- a/dfhack/shm/mod-creature2010.h +++ b/dfhack/shm/mod-creature2010.h @@ -37,6 +37,7 @@ typedef struct uint32_t creature_vector; uint32_t creature_pos_offset; uint32_t creature_profession_offset; + uint32_t creature_custom_profession_offset; uint32_t creature_race_offset; uint32_t creature_flags1_offset; uint32_t creature_flags2_offset; diff --git a/examples/creaturedump.cpp b/examples/creaturedump.cpp index 60cb343be..f09268442 100644 --- a/examples/creaturedump.cpp +++ b/examples/creaturedump.cpp @@ -12,6 +12,7 @@ using namespace std; #include #include #include +#include template void print_bits ( T val, std::ostream& out ) @@ -165,14 +166,16 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature) cout << ", nick name: " << creature.name.nickname; addendl = true; } - /* - string transName = DF.TranslateName(creature.name,englishWords,foreignWords,false); + + DFHack::Translation *Tran = DF.getTranslation(); + + string transName = Tran->TranslateName(creature.name,false); if(!transName.empty()) { cout << ", trans name: " << transName; addendl=true; } -*/ + /* cout << ", likes: "; for(uint32_t i = 0;igetProfession(creature.profession) << "(" << (int) creature.profession << ")"; - /* + if(creature.custom_profession[0]) { cout << ", custom profession: " << creature.custom_profession; } + /* if(creature.current_job.active) { cout << ", current job: " << mem->getJob(creature.current_job.jobId); @@ -297,6 +301,7 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature) cout << "from the underworld, "; } cout << endl; +#include /* if(creature.flags1.bits.had_mood && (creature.mood == -1 || creature.mood == 8 ) ) { @@ -325,6 +330,7 @@ int main (void) DFHack::Creatures * Creatures = DF.getCreatures(); DFHack::Materials * Materials = DF.getMaterials(); + DFHack::Translation * Tran = DF.getTranslation(); uint32_t numCreatures; if(!Creatures->Start(numCreatures)) @@ -358,19 +364,19 @@ int main (void) cerr << "Can't get the creature types." << endl; return 1; } - /* - if(!DF.InitReadNameTables(englishWords,foreignWords)) + + if(!Tran->Start()) { cerr << "Can't get name tables" << endl; return 1; } - */ + //DF.InitViewAndCursor(); for(uint32_t i = 0; i < numCreatures; i++) { DFHack::t_creature temp; Creatures->ReadCreature(i,temp); - //if(string(creaturestypes[temp.type].id) == "DWARF") + if(string(creaturestypes[temp.type].id) == "DWARF") { cout << "index " << i << " "; printCreature(DF,temp); diff --git a/output/Memory.xml b/output/Memory.xml index 329b29ad7..3dd1e7c43 100644 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -2962,6 +2962,7 @@ map_data_1b60_offset 0x1B9c =========
0x0166ecc4
0x0 + 0x6c 0x88 0x8C 0x90 @@ -2972,6 +2973,7 @@ map_data_1b60_offset 0x1B9c 0x6D0 0x770 0x830 + 0x1FC
0x01470fbc
DWORD, OK @@ -3018,15 +3020,32 @@ map_data_1b60_offset 0x1B9c - + Constructions + =============
0x165b290
0x14 Translations ============ -
0x016B0008
-
0x016AFFD8
- 0x58 +
0x016AFFD8
+
0x016B0008
+ 0x4C + + Vegetation + ========== + + :( + + Buildings + ========= + + :( + + Effects + ======= + + :( +