diff --git a/library/DFMemInfo.cpp b/library/DFMemInfo.cpp index 5c329ff8d..582a225db 100644 --- a/library/DFMemInfo.cpp +++ b/library/DFMemInfo.cpp @@ -29,6 +29,7 @@ distribution. //Inital amount of space in levels vector (since we usually know the number, efficent!) #define NUM_RESERVE_LVLS 20 +#define NUM_RESERVE_MOODS 6 using namespace DFHack; /* @@ -96,6 +97,7 @@ class memory_info::Private vector skills; vector levels; vector< vector > traits; + vector moods; map labors; // storage for class and multiclass @@ -124,6 +126,7 @@ memory_info::memory_info() d->p = 0; d->classindex = 0; d->levels.reserve(NUM_RESERVE_LVLS); + d->moods.reserve(NUM_RESERVE_MOODS); } // copy constructor @@ -151,6 +154,7 @@ memory_info::memory_info(const memory_info &old) d->traits = old.d->traits; d->labors = old.d->labors; d->levels = old.d->levels; + d->moods = old.d->moods; } void memory_info::setParentProcess(Process * _p) { @@ -319,6 +323,16 @@ void memory_info::setLevel(const std::string &nLevel, d->levels[keyInt].xpNxtLvl = strtol(nXp.c_str(), NULL, 10); } +void memory_info::setMood(const std::string &id, const std::string &mood) +{ + uint32_t keyInt = strtol(id.c_str(), NULL, 10); + + if(d->moods.size() <= keyInt) + d->moods.resize(keyInt+1); + + d->moods[keyInt] = mood; +} + void memory_info::setTrait(const string & key, const string & value, const string & zero, @@ -712,3 +726,11 @@ string memory_info::getLabor (const uint32_t laborIdx) throw Error::MissingMemoryDefinition("labor", laborIdx); } +std::string memory_info::getMood(const uint32_t moodID) +{ + if(d->moods.size() > moodID) + { + return d->moods[moodID]; + } + throw Error::MissingMemoryDefinition("Mood", moodID); +} diff --git a/library/DFMemInfoManager.cpp b/library/DFMemInfoManager.cpp index bc34e877a..48ea3f8a2 100644 --- a/library/DFMemInfoManager.cpp +++ b/library/DFMemInfoManager.cpp @@ -212,6 +212,10 @@ void MemInfoManager::ParseEntry (TiXmlElement* entry, memory_info* mem, map setLevel(value, name, pMemEntry->Attribute("xpNxtLvl")); } + else if (type == "Mood") + { + mem->setMood(value, name); + } else { throw Error::MemoryXmlUnknownType(type.c_str()); diff --git a/library/include/dfhack/DFMemInfo.h b/library/include/dfhack/DFMemInfo.h index 84b76da69..400dc5765 100644 --- a/library/include/dfhack/DFMemInfo.h +++ b/library/include/dfhack/DFMemInfo.h @@ -66,6 +66,7 @@ namespace DFHack uint32_t getAddress (const char *); uint32_t getHexValue (const char *); + std::string getMood(const uint32_t moodID); std::string getString (const std::string&); std::string getProfession(const uint32_t) const; std::string getJob(const uint32_t) const; @@ -109,6 +110,7 @@ namespace DFHack void setLabor(const std::string &, const std::string &); void setLevel(const std::string &nLevel, const std::string &nName, const std::string &nXp); + void setMood(const std::string &id, const std::string &mood); void RebaseVTable(const int32_t offset); void setParentProcess(Process * _p); diff --git a/output/Memory.xml b/output/Memory.xml index ff63b1861..fe0a539f3 100755 --- a/output/Memory.xml +++ b/output/Memory.xml @@ -218,7 +218,17 @@ 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 - + + ==================================================================== + M O O D S + ==================================================================== + + + + + + + ==================================================================== P R O F E S S I O N S ====================================================================