Merge branch 'master' of git://github.com/Zhentar/dfhack into mergeb

Conflicts:
	library/DFHackAPI.cpp
develop
Petr Mrázek 2010-03-08 13:56:32 +01:00
commit d2c84df4c8
8 changed files with 179 additions and 75 deletions

@ -169,8 +169,9 @@ int main (void)
return 1; return 1;
} }
map<string, vector<string> > names; vector< vector<string> > englishWords;
if(!DF.InitReadNameTables(names)) vector< vector<string> > foreignWords;
if(!DF.InitReadNameTables(englishWords,foreignWords))
{ {
cerr << "Can't get name tables" << endl; cerr << "Can't get name tables" << endl;
return 1; return 1;
@ -189,17 +190,17 @@ int main (void)
{ {
cout << "address: " << temp.origin << " creature type: " << creaturestypes[temp.type].id << ", position: " << temp.x << "x " << temp.y << "y "<< temp.z << "z" << endl; cout << "address: " << temp.origin << " creature type: " << creaturestypes[temp.type].id << ", position: " << temp.x << "x " << temp.y << "y "<< temp.z << "z" << endl;
bool addendl = false; bool addendl = false;
if(temp.first_name[0]) if(temp.name.first_name[0])
{ {
cout << "first name: " << temp.first_name; cout << "first name: " << temp.name.first_name;
addendl = true; addendl = true;
} }
if(temp.nick_name[0]) if(temp.name.nickname[0])
{ {
cout << ", nick name: " << temp.nick_name; cout << ", nick name: " << temp.name.nickname;
addendl = true; addendl = true;
} }
string transName = DF.TranslateName(temp.last_name,names,creaturestypes[temp.type].id); string transName = DF.TranslateName(temp.name,englishWords,foreignWords,false);
if(!transName.empty()) if(!transName.empty())
{ {
cout << ", trans name: " << transName; cout << ", trans name: " << transName;

@ -50,8 +50,9 @@ int main (void)
cerr << "DF not found" << endl; cerr << "DF not found" << endl;
return 1; return 1;
} }
map< string, vector<string> > names; vector< vector<string> > englishWords;
if(!DF.InitReadNameTables(names)) vector< vector<string> > foreignWords;
if(!DF.InitReadNameTables(englishWords,foreignWords))
{ {
cerr << "Could not get Names" << endl; cerr << "Could not get Names" << endl;
return 1; return 1;
@ -61,7 +62,7 @@ int main (void)
cout << "\nSelect Name to search or q to Quit" << endl; cout << "\nSelect Name to search or q to Quit" << endl;
getline (cin, input); getline (cin, input);
while(input != "q"){ while(input != "q"){
for( map< string, vector<string> >::iterator it = names.begin();it != names.end(); it++){ /*for( map< string, vector<string> >::iterator it = names.begin();it != names.end(); it++){
for(uint32_t i = 0; i < it->second.size(); i++){ for(uint32_t i = 0; i < it->second.size(); i++){
uint32_t found = tolower(input).find(tolower(it->second[i])); uint32_t found = tolower(input).find(tolower(it->second[i]));
if(found != string::npos){ if(found != string::npos){
@ -70,7 +71,7 @@ int main (void)
cout << it->first << " " << it->second[i] << " " << groupBy2(value.str()) << endl; cout << it->first << " " << it->second[i] << " " << groupBy2(value.str()) << endl;
} }
} }
} }*/
DF.Resume(); DF.Resume();
getline(cin,input); getline(cin,input);
} }

@ -23,7 +23,8 @@ void print_bits ( T val, std::ostream& out )
val >>= 1; val >>= 1;
} }
} }
map<string, vector<string> > names; vector< vector<string> > englishWords;
vector< vector<string> > foreignWords;
uint32_t numCreatures; uint32_t numCreatures;
vector<DFHack::t_matgloss> creaturestypes; vector<DFHack::t_matgloss> creaturestypes;
void printDwarves(DFHack::API & DF) void printDwarves(DFHack::API & DF)
@ -37,15 +38,15 @@ void printDwarves(DFHack::API & DF)
if (type == "DWARF" && !temp.flags1.bits.dead && !temp.flags2.bits.killed) if (type == "DWARF" && !temp.flags1.bits.dead && !temp.flags2.bits.killed)
{ {
cout << i << ":"; cout << i << ":";
if (temp.nick_name[0]) if (temp.name.nickname[0])
{ {
cout << temp.nick_name; cout << temp.name.nickname;
} }
else else
{ {
cout << temp.first_name; cout << temp.name.first_name;
} }
string transName = DF.TranslateName(temp.last_name,names,creaturestypes[temp.type].id); string transName = DF.TranslateName(temp.name,englishWords,foreignWords, false);
cout << " " << temp.custom_profession; //transName; cout << " " << temp.custom_profession; //transName;
if (dwarfCounter%3 != 2) if (dwarfCounter%3 != 2)
{ {
@ -109,7 +110,7 @@ bool getDwarfSelection(DFHack::API & DF, DFHack::t_creature & toChange,string &
if (input == "n") if (input == "n")
{ {
commandString = "pzyn"; commandString = "pzyn";
eraseAmount = string(toChange.nick_name).length(); eraseAmount = string(toChange.name.nickname).length();
changeType = true; changeType = true;
isName = true; isName = true;
} }
@ -153,7 +154,7 @@ bool waitTillChanged(DFHack::API &DF, int creatureToCheck, string changeValue, b
int tryCount = 0; int tryCount = 0;
if (isName) if (isName)
{ {
while (testCre.nick_name != changeValue && tryCount <50) while (testCre.name.nickname != changeValue && tryCount <50)
{ {
DF.Resume(); DF.Resume();
w->TypeSpecial(DFHack::WAIT,1,100); w->TypeSpecial(DFHack::WAIT,1,100);
@ -324,7 +325,7 @@ int main (void)
return 1; return 1;
} }
DF.InitReadNameTables(names); DF.InitReadNameTables(englishWords,foreignWords);
DF.InitReadCreatures(numCreatures); DF.InitReadCreatures(numCreatures);
DF.InitViewAndCursor(); DF.InitViewAndCursor();
DFHack::Process * p = DF.getProcess(); DFHack::Process * p = DF.getProcess();

@ -9,10 +9,11 @@ using namespace std;
#include <DFTypes.h> #include <DFTypes.h>
#include <DFHackAPI.h> #include <DFHackAPI.h>
void printSettlement(DFHack::API & DF, const DFHack::t_settlement & settlement, const map<string, vector<string> > &names)
void printSettlement(DFHack::API & DF, const DFHack::t_settlement & settlement, const vector< vector<string> > &englishWords, const vector< vector<string> > &foreignWords)
{ {
string genericName = DF.TranslateName(settlement.name,2,names,"GENERIC"); string genericName = DF.TranslateName(settlement.name,englishWords,foreignWords,true);
string dwarfName = DF.TranslateName(settlement.name,2,names,"DWARF"); string dwarfName = DF.TranslateName(settlement.name,englishWords,foreignWords,false);
cout << dwarfName << " " << genericName << " " << "world x: " << settlement.world_x << " world y: " << settlement.world_y cout << dwarfName << " " << genericName << " " << "world x: " << settlement.world_x << " world y: " << settlement.world_y
<< " local_x: " << settlement.local_x1 << " local_y: " << settlement.local_y1 << " size: " << settlement.local_x2 - settlement.local_x1 << " by " << settlement.local_y2 - settlement.local_y1 << "\n"; << " local_x: " << settlement.local_x1 << " local_y: " << settlement.local_y1 << " size: " << settlement.local_x2 - settlement.local_x1 << " by " << settlement.local_y2 - settlement.local_y1 << "\n";
} }
@ -32,22 +33,23 @@ int main (int argc,const char* argv[])
cerr << "Could not read Settlements" << endl; cerr << "Could not read Settlements" << endl;
return 1; return 1;
} }
map<string, vector<string> > names; vector< vector<string> > englishWords;
if(!DF.InitReadNameTables(names)) vector< vector<string> > foreignWords;
if(!DF.InitReadNameTables(englishWords,foreignWords))
{ {
cerr << "Can't get name tables" << endl; cerr << "Can't get name tables" << endl;
return 1; return 1;
} }
cout << "Settlements\n"; cout << "Settlements\n";
for(uint32_t i =0;i<numSettlements;i++){ /*for(uint32_t i =0;i<numSettlements;i++){
DFHack::t_settlement temp; DFHack::t_settlement temp;
DF.ReadSettlement(i,temp); DF.ReadSettlement(i,temp);
printSettlement(DF,temp,names); printSettlement(DF,temp,englishWords,foreignWords);
} }*/
// MSVC claims this is causing the heap to be corrupted, I think it is because the currentSettlement vector only has 1 item in it // MSVC claims this is causing the heap to be corrupted, I think it is because the currentSettlement vector only has 1 item in it
cout << "Current Settlement\n"; cout << "Current Settlement\n";
DF.ReadCurrentSettlement(current); if(DF.ReadCurrentSettlement(current))
printSettlement(DF,current,names); printSettlement(DF,current,englishWords,foreignWords);
DF.FinishReadNameTables(); DF.FinishReadNameTables();
DF.FinishReadSettlements(); DF.FinishReadSettlements();

@ -36,6 +36,9 @@ public:
, pm (NULL), p (NULL), offset_descriptor (NULL) , pm (NULL), p (NULL), offset_descriptor (NULL)
, p_cons (NULL), p_bld (NULL), p_veg (NULL) , p_cons (NULL), p_bld (NULL), p_veg (NULL)
{} {}
void readName(t_name & name, uint32_t address);
uint32_t * block; uint32_t * block;
uint32_t x_block_count, y_block_count, z_block_count; uint32_t x_block_count, y_block_count, z_block_count;
uint32_t regionX, regionY, regionZ; uint32_t regionX, regionY, regionZ;
@ -61,14 +64,15 @@ public:
uint32_t view_screen_offset; uint32_t view_screen_offset;
uint32_t current_menu_state_offset; uint32_t current_menu_state_offset;
uint32_t name_firstname_offset;
uint32_t name_nickname_offset;
uint32_t name_words_offset;
uint32_t creature_pos_offset; uint32_t creature_pos_offset;
uint32_t creature_type_offset; uint32_t creature_type_offset;
uint32_t creature_flags1_offset; uint32_t creature_flags1_offset;
uint32_t creature_flags2_offset; uint32_t creature_flags2_offset;
uint32_t creature_first_name_offset; uint32_t creature_name_offset;
uint32_t creature_nick_name_offset;
uint32_t creature_last_name_offset;
uint32_t creature_custom_profession_offset; uint32_t creature_custom_profession_offset;
uint32_t creature_profession_offset; uint32_t creature_profession_offset;
uint32_t creature_sex_offset; uint32_t creature_sex_offset;
@ -86,6 +90,8 @@ public:
uint32_t creature_happiness_offset; uint32_t creature_happiness_offset;
uint32_t creature_traits_offset; uint32_t creature_traits_offset;
uint32_t creature_likes_offset; uint32_t creature_likes_offset;
uint32_t creature_artifact_name_offset;
uint32_t creature_mood_offset;
uint32_t item_material_offset; uint32_t item_material_offset;
@ -865,14 +871,15 @@ bool API::InitReadCreatures( uint32_t &numcreatures )
try try
{ {
memory_info * minfo = d->offset_descriptor; memory_info * minfo = d->offset_descriptor;
d->name_firstname_offset = minfo->getOffset("name_firstname");
d->name_nickname_offset = minfo->getOffset("name_nickname");
d->name_words_offset = minfo->getOffset("name_words");
int creatures = d->offset_descriptor->getAddress ("creatures"); int creatures = d->offset_descriptor->getAddress ("creatures");
d->creature_pos_offset = minfo->getOffset ("creature_position"); d->creature_pos_offset = minfo->getOffset ("creature_position");
d->creature_type_offset = minfo->getOffset ("creature_race"); d->creature_type_offset = minfo->getOffset ("creature_race");
d->creature_flags1_offset = minfo->getOffset ("creature_flags1"); d->creature_flags1_offset = minfo->getOffset ("creature_flags1");
d->creature_flags2_offset = minfo->getOffset ("creature_flags2"); d->creature_flags2_offset = minfo->getOffset ("creature_flags2");
d->creature_first_name_offset = minfo->getOffset ("creature_first_name"); d->creature_name_offset = minfo->getOffset ("creature_name");
d->creature_nick_name_offset = minfo->getOffset ("creature_nick_name");
d->creature_last_name_offset = minfo->getOffset ("creature_last_name");
d->creature_custom_profession_offset = minfo->getOffset ("creature_custom_profession"); d->creature_custom_profession_offset = minfo->getOffset ("creature_custom_profession");
d->creature_profession_offset = minfo->getOffset ("creature_profession"); d->creature_profession_offset = minfo->getOffset ("creature_profession");
d->creature_sex_offset = minfo->getOffset ("creature_sex"); d->creature_sex_offset = minfo->getOffset ("creature_sex");
@ -890,6 +897,8 @@ bool API::InitReadCreatures( uint32_t &numcreatures )
d->creature_happiness_offset = minfo->getOffset ("creature_happiness"); d->creature_happiness_offset = minfo->getOffset ("creature_happiness");
d->creature_traits_offset = minfo->getOffset ("creature_traits"); d->creature_traits_offset = minfo->getOffset ("creature_traits");
d->creature_likes_offset = minfo->getOffset("creature_likes"); d->creature_likes_offset = minfo->getOffset("creature_likes");
d->creature_artifact_name_offset = minfo->getOffset("creature_artifact_name");
d->creature_mood_offset = minfo->getOffset("creature_mood");
d->p_cre = new DfVector (d->p->readVector (creatures, 4)); d->p_cre = new DfVector (d->p->readVector (creatures, 4));
//InitReadNameTables(); //InitReadNameTables();
@ -971,7 +980,7 @@ bool API::ReadSettlement(const int32_t index, t_settlement & settlement)
// read pointer from vector at position // read pointer from vector at position
uint32_t temp = * (uint32_t *) d->p_settlements->at (index); uint32_t temp = * (uint32_t *) d->p_settlements->at (index);
settlement.origin = temp; settlement.origin = temp;
g_pProcess->read(temp + d->settlement_name_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.name); d->readName(settlement.name, temp + d->settlement_name_offset);
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x); g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x);
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1); g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1);
return true; return true;
@ -984,7 +993,7 @@ bool API::ReadCurrentSettlement(t_settlement & settlement)
uint32_t temp = * (uint32_t *) d->p_current_settlement->at(0); uint32_t temp = * (uint32_t *) d->p_current_settlement->at(0);
settlement.origin = temp; settlement.origin = temp;
g_pProcess->read(temp + d->settlement_name_offset, 2 * sizeof(int32_t), (uint8_t *) &settlement.name); d->readName(settlement.name, temp + d->settlement_name_offset);
g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x); g_pProcess->read(temp + d->settlement_world_xy_offset, 2 * sizeof(int16_t), (uint8_t *) &settlement.world_x);
g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1); g_pProcess->read(temp + d->settlement_local_xy_offset, 4 * sizeof(int16_t), (uint8_t *) &settlement.local_x1);
return true; return true;
@ -1098,6 +1107,13 @@ bool API::getItemIndexesInBox(vector<uint32_t> &indexes,
return true; return true;
} }
void API::Private::readName(t_name & name, uint32_t address)
{
g_pProcess->readSTLString(address + name_firstname_offset , name.first_name, 128);
g_pProcess->readSTLString(address + name_nickname_offset , name.nickname, 128);
g_pProcess->read(address + name_words_offset ,48, (uint8_t *) name.words);
}
bool API::ReadCreature (const int32_t index, t_creature & furball) bool API::ReadCreature (const int32_t index, t_creature & furball)
{ {
if(!d->creaturesInited) return false; if(!d->creaturesInited) return false;
@ -1109,17 +1125,12 @@ bool API::ReadCreature (const int32_t index, t_creature & furball)
g_pProcess->readDWord (temp + d->creature_type_offset, furball.type); g_pProcess->readDWord (temp + d->creature_type_offset, furball.type);
g_pProcess->readDWord (temp + d->creature_flags1_offset, furball.flags1.whole); g_pProcess->readDWord (temp + d->creature_flags1_offset, furball.flags1.whole);
g_pProcess->readDWord (temp + d->creature_flags2_offset, furball.flags2.whole); g_pProcess->readDWord (temp + d->creature_flags2_offset, furball.flags2.whole);
// normal names // names
d->p->readSTLString (temp + d->creature_first_name_offset, furball.first_name, 128); d->readName(furball.name,temp + d->creature_name_offset);
d->p->readSTLString (temp + d->creature_nick_name_offset, furball.nick_name, 128); d->readName(furball.squad_name, temp + d->creature_squad_name_offset);
d->readName(furball.artifact_name, temp + d->creature_artifact_name_offset);
// custom profession // custom profession
d->p->readSTLString (temp + d->creature_nick_name_offset, furball.nick_name, 128);
fill_char_buf (furball.custom_profession, d->p->readSTLString (temp + d->creature_custom_profession_offset)); fill_char_buf (furball.custom_profession, d->p->readSTLString (temp + d->creature_custom_profession_offset));
// crazy composited names
g_pProcess->read (temp + d->creature_last_name_offset, sizeof (t_lastname), (uint8_t *) &furball.last_name);
g_pProcess->read (temp + d->creature_squad_name_offset, sizeof (t_squadname), (uint8_t *) &furball.squad_name);
// labors // labors
g_pProcess->read (temp + d->creature_labors_offset, NUM_CREATURE_LABORS, furball.labors); g_pProcess->read (temp + d->creature_labors_offset, NUM_CREATURE_LABORS, furball.labors);
@ -1161,6 +1172,9 @@ bool API::ReadCreature (const int32_t index, t_creature & furball)
g_pProcess->read(temp2,sizeof(t_like),(uint8_t *) &furball.likes[i]); g_pProcess->read(temp2,sizeof(t_like),(uint8_t *) &furball.likes[i]);
} }
g_pProcess->readWord (temp + d->creature_mood_offset, furball.mood);
g_pProcess->readDWord (temp + d->creature_happiness_offset, furball.happiness); g_pProcess->readDWord (temp + d->creature_happiness_offset, furball.happiness);
g_pProcess->readDWord (temp + d->creature_id_offset, furball.id); g_pProcess->readDWord (temp + d->creature_id_offset, furball.id);
g_pProcess->readDWord (temp + d->creature_agility_offset, furball.agility); g_pProcess->readDWord (temp + d->creature_agility_offset, furball.agility);
@ -1178,7 +1192,7 @@ void API::WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS])
WriteRaw(temp + d->creature_labors_offset, NUM_CREATURE_LABORS, labors); WriteRaw(temp + d->creature_labors_offset, NUM_CREATURE_LABORS, labors);
} }
bool API::InitReadNameTables (map< string, vector<string> > & nameTable) bool API::InitReadNameTables(vector<vector<string>> & translations , vector<vector<string> > & foreign_languages) //(map< string, vector<string> > & nameTable)
{ {
try try
{ {
@ -1189,23 +1203,28 @@ bool API::InitReadNameTables (map< string, vector<string> > & nameTable)
DfVector genericVec (d->p->readVector (genericAddress, 4)); DfVector genericVec (d->p->readVector (genericAddress, 4));
DfVector transVec (d->p->readVector (transAddress, 4)); DfVector transVec (d->p->readVector (transAddress, 4));
translations.resize(10);
for (uint32_t i = 0;i < genericVec.getSize();i++) for (uint32_t i = 0;i < genericVec.getSize();i++)
{ {
uint32_t genericNamePtr = * (uint32_t *) genericVec.at (i); uint32_t genericNamePtr = * (uint32_t *) genericVec.at (i);
string genericName = d->p->readSTLString (genericNamePtr); for(int i=0; i<10;i++)
nameTable["GENERIC"].push_back (genericName); {
string word = d->p->readSTLString (genericNamePtr + i * sizeof(string));
translations[i].push_back (word);
}
} }
foreign_languages.resize(transVec.getSize());
for (uint32_t i = 0; i < transVec.getSize();i++) for (uint32_t i = 0; i < transVec.getSize();i++)
{ {
uint32_t transPtr = * (uint32_t *) transVec.at (i); uint32_t transPtr = * (uint32_t *) transVec.at (i);
string transName = d->p->readSTLString (transPtr); //string transName = d->p->readSTLString (transPtr);
DfVector trans_names_vec (d->p->readVector (transPtr + word_table_offset, 4)); DfVector trans_names_vec (d->p->readVector (transPtr + word_table_offset, 4));
for (uint32_t j = 0;j < trans_names_vec.getSize();j++) for (uint32_t j = 0;j < trans_names_vec.getSize();j++)
{ {
uint32_t transNamePtr = * (uint32_t *) trans_names_vec.at (j); uint32_t transNamePtr = * (uint32_t *) trans_names_vec.at (j);
string name = d->p->readSTLString (transNamePtr); string name = d->p->readSTLString (transNamePtr);
nameTable[transName].push_back (name); foreign_languages[i].push_back (name);
} }
} }
d->nameTablesInited = true; d->nameTablesInited = true;
@ -1218,6 +1237,80 @@ bool API::InitReadNameTables (map< string, vector<string> > & nameTable)
} }
} }
string API::TranslateName(const DFHack::t_name &name,const std::vector< std::vector<std::string> > & translations ,const std::vector< std::vector<std::string> > & foreign_languages, bool inEnglish)
{
string out;
assert (d->nameTablesInited);
map<string, vector<string> >::const_iterator it;
if(!inEnglish)
{
if(name.words[0] >=0 || name.words[1] >=0)
{
if(name.words[0]>=0) out.append(foreign_languages[name.language][name.words[0]]);
if(name.words[1]>=0) out.append(foreign_languages[name.language][name.words[1]]);
out[0] = toupper(out[0]);
}
if(name.words[5] >=0)
{
string word;
for(int i=2;i<=5;i++)
if(name.words[i]>=0) word.append(foreign_languages[name.language][name.words[i]]);
word[0] = toupper(word[0]);
if(out.length() > 0) out.append(" ");
out.append(word);
}
if(name.words[6] >=0)
{
string word;
word.append(foreign_languages[name.language][name.words[6]]);
word[0] = toupper(word[0]);
if(out.length() > 0) out.append(" ");
out.append(word);
}
}
else
{
if(name.words[0] >=0 || name.words[1] >=0)
{
if(name.words[0]>=0) out.append(translations[name.parts_of_speech[0]+1][name.words[0]]);
if(name.words[1]>=0) out.append(translations[name.parts_of_speech[1]+1][name.words[1]]);
out[0] = toupper(out[0]);
}
if(name.words[5] >=0)
{
if(out.length() > 0)
out.append(" the");
else
out.append("The");
string word;
for(int i=2;i<=5;i++)
{
if(name.words[i]>=0)
{
word = translations[name.parts_of_speech[i]+1][name.words[i]];
word[0] = toupper(word[0]);
out.append(" " + word);
}
}
}
if(name.words[6] >=0)
{
if(out.length() > 0)
out.append(" of");
else
out.append("Of");
string word;
word.append(translations[name.parts_of_speech[6]+1][name.words[6]]);
word[0] = toupper(word[0]);
out.append(" " + word);
}
}
return out;
}
/*
string API::TranslateName (const int names[], int size, const map<string, vector<string> > & nameTable, const string & language) string API::TranslateName (const int names[], int size, const map<string, vector<string> > & nameTable, const string & language)
{ {
string trans; string trans;
@ -1283,7 +1376,7 @@ string API::TranslateName (const t_squadname & squad, const map<string, vector<s
} }
} }
return (trans_squad); return (trans_squad);
} }*/
void API::FinishReadNameTables() void API::FinishReadNameTables()
{ {

@ -221,12 +221,10 @@ namespace DFHack
vector<t_trait> getTraits(const uint32_t &index); vector<t_trait> getTraits(const uint32_t &index);
vector<t_labor> getLabors(const uint32_t &index); vector<t_labor> getLabors(const uint32_t &index);
*/ */
bool InitReadNameTables (std::map< std::string, std::vector<std::string> > & nameTable); bool InitReadNameTables (std::vector< std::vector<std::string> > & translations , std::vector< std::vector<std::string> > & foreign_languages);
void FinishReadNameTables(); void FinishReadNameTables();
std::string TranslateName(const t_lastname & last, const std::map< std::string, std::vector< std::string > > &nameTable,const std::string & language="GENERIC"); std::string TranslateName(const t_name & name,const std::vector< std::vector<std::string> > & translations ,const std::vector< std::vector<std::string> > & foreign_languages, bool inEnglish=true);
std::string TranslateName(const t_squadname & squad, const std::map< std::string, std::vector< std::string > > &nameTable,const std::string & language="GENERIC");
std::string TranslateName (const int names[], int size, const std::map<std::string, std::vector<std::string> > &nameTable, const std::string & language="GENERIC");
void WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]); void WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);

@ -484,14 +484,17 @@ struct t_trait
CREATURE CREATURE
*/ */
struct t_lastname
{ struct t_name
int names[7];
};
struct t_squadname
{ {
int names[6]; char first_name[128];
char nickname[128];
int words[7];
short parts_of_speech[7];
int language;
bool has_name;
}; };
struct t_skill struct t_skill
{ {
uint16_t id; uint16_t id;
@ -522,10 +525,9 @@ struct t_creature
uint32_t type; uint32_t type;
t_creaturflags1 flags1; t_creaturflags1 flags1;
t_creaturflags2 flags2; t_creaturflags2 flags2;
char first_name [128]; t_name name;
char nick_name [128]; t_name squad_name;
t_lastname last_name; t_name artifact_name;
t_squadname squad_name;
uint8_t profession; uint8_t profession;
char custom_profession[128]; char custom_profession[128];
// enabled labors // enabled labors
@ -541,6 +543,7 @@ struct t_creature
uint8_t numLikes; uint8_t numLikes;
t_like likes[32]; t_like likes[32];
t_job current_job; t_job current_job;
uint16_t mood;
uint32_t happiness; uint32_t happiness;
uint32_t id; uint32_t id;
uint32_t agility; uint32_t agility;
@ -795,7 +798,7 @@ struct t_hotkey
struct t_settlement struct t_settlement
{ {
uint32_t origin; uint32_t origin;
int32_t name[2]; t_name name;
int16_t world_x; int16_t world_x;
int16_t world_y; int16_t world_y;
int16_t local_x1; int16_t local_x1;

@ -734,9 +734,7 @@
<Offset name="biome_stuffs">0x1D64</Offset> <Offset name="biome_stuffs">0x1D64</Offset>
<!-- creature offsets --> <!-- creature offsets -->
<Offset name="creature_first_name">0x00</Offset> <Offset name="creature_name">0x00</Offset>
<Offset name="creature_nick_name">0x1C</Offset>
<Offset name="creature_last_name">0x38</Offset>
<Offset name="creature_custom_profession">0x6c</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>
@ -902,15 +900,22 @@
<Address name="language_vector">0x01534240</Address> <Address name="language_vector">0x01534240</Address>
<Offset name="word_table">0x54</Offset> <Offset name="word_table">0x54</Offset>
<!-- name struct -->
<Offset name="name_firstname">0x0</Offset>
<Offset name="name_nickname">0x1C</Offset>
<Offset name="name_words">0x38</Offset>
<!-- creature offsets --> <!-- creature offsets -->
<Offset name="creature_flags1">0xFC</Offset> <Offset name="creature_flags1">0xFC</Offset>
<Offset name="creature_flags2">0x100</Offset> <Offset name="creature_flags2">0x100</Offset>
<Offset name="creature_sex">0x10A</Offset> <Offset name="creature_sex">0x10A</Offset>
<Offset name="creature_id">0x10C</Offset> <Offset name="creature_id">0x10C</Offset>
<Offset name="creature_squad_name">0x1D8</Offset> <Offset name="creature_squad_name">0x198</Offset>
<Offset name="creature_mood">0x238</Offset>
<Offset name="creature_squad_leader_id">0x268</Offset> <Offset name="creature_squad_leader_id">0x268</Offset>
<Offset name="creature_money">0x2F8</Offset> <Offset name="creature_money">0x2F8</Offset>
<Offset name="creature_current_job">0x314</Offset> <Offset name="creature_current_job">0x314</Offset>
<Offset name="creature_artifact_name">0x484</Offset>
<Offset name="creature_strength">0x4F0</Offset> <Offset name="creature_strength">0x4F0</Offset>
<Offset name="creature_agility">0x4F4</Offset> <Offset name="creature_agility">0x4F4</Offset>
<Offset name="creature_toughness">0x4F8</Offset> <Offset name="creature_toughness">0x4F8</Offset>
@ -994,7 +999,7 @@
<Address name="settlement_current">0x01533CC0</Address> <Address name="settlement_current">0x01533CC0</Address>
<Address name="settlements">0x01533BF4</Address> <Address name="settlements">0x01533BF4</Address>
<Offset name="settlement_name">0x38</Offset> <Offset name="settlement_name">0x0</Offset>
<Offset name="settlement_world_xy">0x7a</Offset> <Offset name="settlement_world_xy">0x7a</Offset>
<Offset name="settlement_local_xy">0x100</Offset> <Offset name="settlement_local_xy">0x100</Offset>