Name translation for real

develop
Petr Mrázek 2010-04-07 01:17:03 +02:00
parent 216cfa74e6
commit 5ee584b372
10 changed files with 64 additions and 21 deletions

@ -11,6 +11,7 @@
#include "modules/Maps.h" #include "modules/Maps.h"
#include "modules/Materials.h" #include "modules/Materials.h"
#include "modules/Position.h" #include "modules/Position.h"
#include "modules/Translation.h"
#include "modules/Gui.h" #include "modules/Gui.h"
using namespace DFHack; using namespace DFHack;
@ -23,6 +24,7 @@ APIPrivate::APIPrivate()
position = 0; position = 0;
gui = 0; gui = 0;
materials = 0; materials = 0;
translation = 0;
} }
APIPrivate::~APIPrivate() APIPrivate::~APIPrivate()
@ -32,6 +34,7 @@ APIPrivate::~APIPrivate()
if(position) delete position; if(position) delete position;
if(gui) delete gui; if(gui) delete gui;
if(materials) delete materials; if(materials) delete materials;
if(translation) delete translation;
} }
bool APIPrivate::InitReadNames() bool APIPrivate::InitReadNames()

@ -40,6 +40,7 @@ distribution.
#include "modules/Position.h" #include "modules/Position.h"
#include "modules/Gui.h" #include "modules/Gui.h"
#include "modules/Creatures.h" #include "modules/Creatures.h"
#include "modules/Translation.h"
using namespace DFHack; using namespace DFHack;
@ -201,6 +202,13 @@ Materials * API::getMaterials()
return d->materials; 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 // returns number of buildings, expects v_buildingtypes that will later map t_building.type to its name
bool API::InitReadBuildings ( uint32_t& numbuildings ) bool API::InitReadBuildings ( uint32_t& numbuildings )

@ -37,6 +37,7 @@ distribution.
namespace DFHack namespace DFHack
{ {
class APIPrivate; class APIPrivate;
class memory_info; class memory_info;
class Process; class Process;
@ -47,6 +48,7 @@ namespace DFHack
class Position; class Position;
class Gui; class Gui;
class Materials; class Materials;
class Translation;
class DFHACK_EXPORT API class DFHACK_EXPORT API
{ {
@ -89,6 +91,7 @@ namespace DFHack
Gui * getGui(); Gui * getGui();
Position * getPosition(); Position * getPosition();
Materials * getMaterials(); Materials * getMaterials();
Translation * getTranslation();
/* /*
* Constructions (costructed walls, floors, ramps, etc...) * Constructions (costructed walls, floors, ramps, etc...)

@ -1,5 +1,5 @@
#ifndef CL_MOD_POSITION #ifndef CL_MOD_TRANSLATION
#define CL_MOD_POSITION #define CL_MOD_TRANSLATION
/* /*
* DF translation tables and name translation * DF translation tables and name translation
*/ */

@ -67,6 +67,7 @@ Creatures::Creatures(APIPrivate* _d)
creatures.creature_vector = minfo->getAddress ("creature_vector"); creatures.creature_vector = minfo->getAddress ("creature_vector");
creatures.creature_pos_offset = minfo->getOffset ("creature_position"); creatures.creature_pos_offset = minfo->getOffset ("creature_position");
creatures.creature_profession_offset = minfo->getOffset ("creature_profession"); 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_race_offset = minfo->getOffset ("creature_race");
creatures.creature_flags1_offset = minfo->getOffset ("creature_flags1"); creatures.creature_flags1_offset = minfo->getOffset ("creature_flags1");
creatures.creature_flags2_offset = minfo->getOffset ("creature_flags2"); 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->readName(furball.squad_name, temp + offs.creature_squad_name_offset);
d->d->readName(furball.artifact_name, temp + offs.creature_artifact_name_offset); d->d->readName(furball.artifact_name, temp + offs.creature_artifact_name_offset);
// custom profession // 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 // labors
g_pProcess->read (temp + offs.creature_labors_offset, NUM_CREATURE_LABORS, furball.labors); g_pProcess->read (temp + offs.creature_labors_offset, NUM_CREATURE_LABORS, furball.labors);

@ -54,10 +54,10 @@ Translation::Translation(APIPrivate * d_)
d->d = d_; d->d = d_;
d->Inited = d->Started = false; d->Inited = d->Started = false;
memory_info * mem = d->d->offset_descriptor; memory_info * mem = d->d->offset_descriptor;
int genericAddress = mem->getAddress ("language_vector"); d->genericAddress = mem->getAddress ("language_vector");
int transAddress = mem->getAddress ("translation_vector"); d->transAddress = mem->getAddress ("translation_vector");
int word_table_offset = mem->getOffset ("word_table"); d->word_table_offset = mem->getOffset ("word_table");
int sizeof_string = mem->getHexValue ("sizeof_string"); d->sizeof_string = mem->getHexValue ("sizeof_string");
d->Inited = true; d->Inited = true;
} }
@ -75,8 +75,8 @@ bool Translation::Start()
Process * p = d->d->p; Process * p = d->d->p;
DfVector genericVec (p, d->genericAddress, 4); DfVector genericVec (p, d->genericAddress, 4);
DfVector transVec (p, d->transAddress, 4); DfVector transVec (p, d->transAddress, 4);
DFDict translations = d->dicts.translations; DFDict & translations = d->dicts.translations;
DFDict foreign_languages = d->dicts.foreign_languages; DFDict & foreign_languages = d->dicts.foreign_languages;
translations.resize(10); translations.resize(10);
for (uint32_t i = 0;i < genericVec.getSize();i++) for (uint32_t i = 0;i < genericVec.getSize();i++)

@ -36,6 +36,7 @@ namespace DFHack
class Position; class Position;
class Maps; class Maps;
class Creatures; class Creatures;
class Translation;
class ProcessEnumerator; class ProcessEnumerator;
class Process; class Process;
class memory_info; class memory_info;
@ -67,6 +68,7 @@ namespace DFHack
Position * position; Position * position;
Gui * gui; Gui * gui;
Materials * materials; Materials * materials;
Translation * translation;
/* /*
uint32_t item_material_offset; uint32_t item_material_offset;

@ -37,6 +37,7 @@ typedef struct
uint32_t creature_vector; uint32_t creature_vector;
uint32_t creature_pos_offset; uint32_t creature_pos_offset;
uint32_t creature_profession_offset; uint32_t creature_profession_offset;
uint32_t creature_custom_profession_offset;
uint32_t creature_race_offset; uint32_t creature_race_offset;
uint32_t creature_flags1_offset; uint32_t creature_flags1_offset;
uint32_t creature_flags2_offset; uint32_t creature_flags2_offset;

@ -12,6 +12,7 @@ using namespace std;
#include <DFMemInfo.h> #include <DFMemInfo.h>
#include <modules/Materials.h> #include <modules/Materials.h>
#include <modules/Creatures.h> #include <modules/Creatures.h>
#include <modules/Translation.h>
template <typename T> template <typename T>
void print_bits ( T val, std::ostream& out ) 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; cout << ", nick name: " << creature.name.nickname;
addendl = true; 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()) if(!transName.empty())
{ {
cout << ", trans name: " << transName; cout << ", trans name: " << transName;
addendl=true; addendl=true;
} }
*/
/* /*
cout << ", likes: "; cout << ", likes: ";
for(uint32_t i = 0;i<creature.numLikes; i++) for(uint32_t i = 0;i<creature.numLikes; i++)
@ -189,11 +192,12 @@ void printCreature(DFHack::API & DF, const DFHack::t_creature & creature)
addendl = false; addendl = false;
} }
cout << "profession: " << mem->getProfession(creature.profession) << "(" << (int) creature.profession << ")"; cout << "profession: " << mem->getProfession(creature.profession) << "(" << (int) creature.profession << ")";
/*
if(creature.custom_profession[0]) if(creature.custom_profession[0])
{ {
cout << ", custom profession: " << creature.custom_profession; cout << ", custom profession: " << creature.custom_profession;
} }
/*
if(creature.current_job.active) if(creature.current_job.active)
{ {
cout << ", current job: " << mem->getJob(creature.current_job.jobId); 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 << "from the underworld, ";
} }
cout << endl; cout << endl;
#include <modules/Translation.h>
/* /*
if(creature.flags1.bits.had_mood && (creature.mood == -1 || creature.mood == 8 ) ) 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::Creatures * Creatures = DF.getCreatures();
DFHack::Materials * Materials = DF.getMaterials(); DFHack::Materials * Materials = DF.getMaterials();
DFHack::Translation * Tran = DF.getTranslation();
uint32_t numCreatures; uint32_t numCreatures;
if(!Creatures->Start(numCreatures)) if(!Creatures->Start(numCreatures))
@ -358,19 +364,19 @@ int main (void)
cerr << "Can't get the creature types." << endl; cerr << "Can't get the creature types." << endl;
return 1; return 1;
} }
/*
if(!DF.InitReadNameTables(englishWords,foreignWords)) if(!Tran->Start())
{ {
cerr << "Can't get name tables" << endl; cerr << "Can't get name tables" << endl;
return 1; return 1;
} }
*/
//DF.InitViewAndCursor(); //DF.InitViewAndCursor();
for(uint32_t i = 0; i < numCreatures; i++) for(uint32_t i = 0; i < numCreatures; i++)
{ {
DFHack::t_creature temp; DFHack::t_creature temp;
Creatures->ReadCreature(i,temp); Creatures->ReadCreature(i,temp);
//if(string(creaturestypes[temp.type].id) == "DWARF") if(string(creaturestypes[temp.type].id) == "DWARF")
{ {
cout << "index " << i << " "; cout << "index " << i << " ";
printCreature(DF,temp); printCreature(DF,temp);

@ -2962,6 +2962,7 @@ map_data_1b60_offset 0x1B9c
========= =========
<Address name="creature_vector">0x0166ecc4</Address> <Address name="creature_vector">0x0166ecc4</Address>
<Offset name="creature_name">0x0</Offset> <Offset name="creature_name">0x0</Offset>
<Offset name="creature_custom_profession">0x6c</Offset>
<Offset name="creature_profession">0x88</Offset> <Offset name="creature_profession">0x88</Offset>
<Offset name="creature_race">0x8C</Offset> <Offset name="creature_race">0x8C</Offset>
<Offset name="creature_position">0x90</Offset> <Offset name="creature_position">0x90</Offset>
@ -2972,6 +2973,7 @@ map_data_1b60_offset 0x1B9c
<Offset name="creature_artifact_name">0x6D0</Offset> <Offset name="creature_artifact_name">0x6D0</Offset>
<Offset name="creature_labors">0x770</Offset> <Offset name="creature_labors">0x770</Offset>
<Offset name="creature_happiness">0x830</Offset> <Offset name="creature_happiness">0x830</Offset>
<Offset name="creature_skills">0x1FC</Offset>
<!-- from DT --> <!-- from DT -->
<Address name="dwarf_race_index">0x01470fbc</Address>DWORD, OK <Address name="dwarf_race_index">0x01470fbc</Address>DWORD, OK
@ -3018,15 +3020,32 @@ map_data_1b60_offset 0x1B9c
<!--<Address name="mat_creature_types2">0x16AEE08</Address>--> <!--<Address name="mat_creature_types2">0x16AEE08</Address>-->
<!-- possible constructions --> Constructions
=============
<Address name="construction_vector">0x165b290</Address> <Address name="construction_vector">0x165b290</Address>
<Offset name="sizeof_construction">0x14</Offset> <Offset name="sizeof_construction">0x14</Offset>
Translations Translations
============ ============
<Address name="language_vector">0x016B0008</Address> <Address name="language_vector">0x016AFFD8</Address>
<Address name="translation_vector">0x016AFFD8</Address> <Address name="translation_vector">0x016B0008</Address>
<Offset name="word_table">0x58</Offset> <Offset name="word_table">0x4C</Offset>
Vegetation
==========
:(
Buildings
=========
:(
Effects
=======
:(
<!-- <!--
addresses from belal: vectors might need 8 subtracted from them addresses from belal: vectors might need 8 subtracted from them