Merge branch 'master' of github.com:peterix/dfhack

develop
Petr Mrázek 2010-06-10 19:02:17 +02:00
commit 60a085be98
5 changed files with 85 additions and 3 deletions

@ -27,6 +27,8 @@ distribution.
#include "dfhack/DFError.h"
#include "dfhack/DFProcess.h"
//Inital amount of space in levels vector (since we usually know the number, efficent!)
#define NUM_RESERVE_LVLS 20
using namespace DFHack;
/*
@ -92,6 +94,7 @@ class memory_info::Private
vector<string> professions;
vector<string> jobs;
vector<string> skills;
vector<DFHack::t_level> levels;
vector< vector<string> > traits;
map <uint32_t, string> labors;
@ -120,6 +123,7 @@ memory_info::memory_info()
d->base = 0;
d->p = 0;
d->classindex = 0;
d->levels.reserve(NUM_RESERVE_LVLS);
}
// copy constructor
@ -146,6 +150,7 @@ memory_info::memory_info(const memory_info &old)
d->skills = old.d->skills;
d->traits = old.d->traits;
d->labors = old.d->labors;
d->levels = old.d->levels;
}
void memory_info::setParentProcess(Process * _p)
{
@ -300,6 +305,22 @@ void memory_info::setSkill (const string & key, const string & value)
d->skills[keyInt] = value;
}
void memory_info::setLevel(const std::string &nLevel,
const std::string &nName,
const std::string &nMin_xp,
const std::string &nMax_xp)
{
uint32_t keyInt = strtol(nLevel.c_str(), NULL, 10);
if(d->levels.size() <= keyInt)
d->levels.resize(keyInt+1);
d->levels[keyInt].level = keyInt;
d->levels[keyInt].name = nName;
d->levels[keyInt].min_xp = strtol(nMin_xp.c_str(), NULL, 10);
d->levels[keyInt].max_xp = strtol(nMax_xp.c_str(), NULL, 10);
}
void memory_info::setTrait(const string & key,
const string & value,
const string & zero,
@ -628,6 +649,15 @@ string memory_info::getSkill (const uint32_t key) const
throw Error::MissingMemoryDefinition("skill", key);
}
DFHack::t_level memory_info::getLevelInfo(const uint32_t level) const
{
if(d->levels.size() > level)
{
return d->levels[level];
}
throw Error::MissingMemoryDefinition("Level", level);
}
// FIXME: ugly hack that needs to die
int absolute (int number)
{

@ -152,8 +152,12 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map <str
{
// only elements get processed
const char *cstr_type = pMemEntry->Value();
const char *cstr_name = pMemEntry->Attribute("name");
const char *cstr_name = pMemEntry->Attribute("name");
const char *cstr_value = pMemEntry->GetText();
if(!cstr_value)
cstr_value = pMemEntry->Attribute("id");
// check for missing parts
string type, name, value;
type = cstr_type;
@ -203,6 +207,10 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map <str
else if (type == "Labor")
{
mem->setLabor(value,name);
}
else if (type == "Level")
{
mem->setLevel(value, name, pMemEntry->Attribute("min_xp"), pMemEntry->Attribute("max_xp"));
}
else
{

@ -27,6 +27,8 @@ distribution.
#include "DFPragma.h"
#include "DFExport.h"
#include "dfhack/DFTypes.h"
namespace DFHack
{
/*
@ -72,6 +74,8 @@ namespace DFHack
std::string getTraitName(const uint32_t) const;
std::string getLabor (const uint32_t);
DFHack::t_level getLevelInfo(const uint32_t level) const;
void setVersion(const char *);
void setVersion(const std::string&);
std::string getVersion();
@ -98,8 +102,12 @@ namespace DFHack
void setProfession(const std::string &, const std::string &);
void setJob(const std::string &, const std::string &);
void setSkill(const std::string &, const std::string &);
void setTrait(const std::string &,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &);
void setTrait(const std::string &, const std::string &, const std::string &,
const std::string &, const std::string &,
const std::string &, const std::string &, const std::string &);
void setLabor(const std::string &, const std::string &);
void setLevel(const std::string &nLevel, const std::string &nName,
const std::string &nMin_xp, const std::string &nMax_xp);
void RebaseVTable(const int32_t offset);
void setParentProcess(Process * _p);

@ -211,5 +211,13 @@ struct t_attrib
uint32_t field_18;
};
struct t_level
{
uint32_t level;
std::string name;
uint32_t min_xp;
uint32_t max_xp;
};
}// namespace DFHack
#endif // TYPES_H_INCLUDED

@ -4,6 +4,7 @@
<MemoryDescriptors>
<Entry version="meta-2010" os="all" id="meta-2010">
<Offset name="keep_me_happy">0x0</Offset>
====================================================================
T R A I T S
====================================================================
@ -217,6 +218,7 @@
level_2="Often does the first thing that comes to mind"
level_1="Acts impulsively"
level_0="Always acts without considering alternatives or thinking through possibilities">29</Trait>
====================================================================
P R O F E S S I O N S
====================================================================
@ -322,6 +324,7 @@
<Profession can_assign_labors="true" is_military="true" name="LASHER">88</Profession>
<Profession can_assign_labors="true" is_military="true" name="MASTER_LASHER">89</Profession>
<Profession can_assign_labors="true" is_military="false" name="None">90</Profession>
====================================================================
J O B S
====================================================================
@ -792,7 +795,32 @@ size=212
<Skill name="Bone Setting">62</Skill>
<Skill name="Suturing">63</Skill>
<Skill name="Crutch-walking">64</Skill>
====================================================================
L E V E L S
====================================================================
<Level id="0" name="Dabbling" min_xp="1" max_xp="499"/>
<Level id="1" name="Novice" min_xp="500" max_xp="1099"/>
<Level id="2" name="Adequate" min_xp="1100" max_xp="1799"/>
<Level id="3" name="Competent" min_xp="1800" max_xp="2599"/>
<Level id="4" name="Skilled" min_xp="2600" max_xp="3499"/>
<Level id="5" name="Proficient" min_xp="3500" max_xp="4499"/>
<Level id="6" name="Talented" min_xp="4500" max_xp="5599"/>
<Level id="7" name="Adept" min_xp="5600" max_xp="6799"/>
<Level id="8" name="Expert" min_xp="6800" max_xp="8099"/>
<Level id="9" name="Professional" min_xp="8100" max_xp="9499"/>
<Level id="10" name="Accomplished" min_xp="9500" max_xp="10999"/>
<Level id="11" name="Great" min_xp="11000" max_xp="12599"/>
<Level id="12" name="Master" min_xp="12600" max_xp="14299"/>
<Level id="13" name="High Master" min_xp="14300" max_xp="16099"/>
<Level id="14" name="Grand Master" min_xp="16100" max_xp="17999"/>
<Level id="15" name="Legendary" min_xp="18000" max_xp="19999"/>
<Level id="16" name="Legendary+1" min_xp="20000" max_xp="22099"/> TODO verify level 16 and up's existence in DF2010
<Level id="17" name="Legendary+2" min_xp="22100" max_xp="24299"/>
<Level id="18" name="Legendary+3" min_xp="24300" max_xp="26599"/>
<Level id="19" name="Legendary+4" min_xp="26600" max_xp="28999"/>
<Level id="20" name="Legendary+5" min_xp="29000" max_xp="30000"/> No max xp on last level but 30000 is nice and round
====================================================================
L A B O R S
====================================================================