diff --git a/data/Memory-ng.xml b/data/Memory-ng.xml
index 100a2657b..20a7e3f37 100644
--- a/data/Memory-ng.xml
+++ b/data/Memory-ng.xml
@@ -823,6 +823,11 @@
+
+
+
+
+
@@ -831,6 +836,200 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ vector
+ vector
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ List of offsets in the VTable :
+
+
+
+
+
+
+
+
+
+ (in the vtable)
+
+
+
+
+
@@ -1060,7 +1259,7 @@
-
+
@@ -1160,11 +1359,11 @@
-
-
-
-
-
+
+
+
+
+
@@ -1222,16 +1421,16 @@
-
-
-
-
-
+
+
+
+
+
-
-
-
+
+
+
@@ -1260,7 +1459,7 @@
-
+
@@ -1269,10 +1468,10 @@
-
+
-
+
@@ -1465,8 +1664,8 @@
-
-
+
+
@@ -1597,7 +1796,7 @@
-
+
diff --git a/library/VersionInfo.cpp b/library/VersionInfo.cpp
index a7d427056..fe18ec4f4 100644
--- a/library/VersionInfo.cpp
+++ b/library/VersionInfo.cpp
@@ -26,6 +26,7 @@ distribution.
#include "dfhack/VersionInfo.h"
#include "dfhack/DFError.h"
#include "dfhack/DFProcess.h"
+#include
//Inital amount of space in levels vector (since we usually know the number, efficient!)
#define NUM_RESERVE_LVLS 20
@@ -102,6 +103,8 @@ namespace DFHack
map offsets;
map strings;
map groups;
+ std::string name;
+ OffsetGroup * parent;
};
}
@@ -134,7 +137,7 @@ void OffsetGroup::setOffset (const string & key, const string & value)
(*it).second.second = offset;
(*it).second.first = true;
}
- else throw Error::MissingMemoryDefinition("offset", key);
+ else throw Error::MissingMemoryDefinition("offset", getFullName() + key);
}
@@ -147,7 +150,7 @@ void OffsetGroup::setAddress (const string & key, const string & value)
(*it).second.second = address;
(*it).second.first = true;
}
- else throw Error::MissingMemoryDefinition("address", key);
+ else throw Error::MissingMemoryDefinition("address", getFullName() + key);
}
@@ -159,7 +162,7 @@ void OffsetGroup::setHexValue (const string & key, const string & value)
(*it).second.second = strtol(value.c_str(), NULL, 16);
(*it).second.first = true;
}
- else throw Error::MissingMemoryDefinition("hexvalue", key);
+ else throw Error::MissingMemoryDefinition("hexvalue", getFullName() + key);
}
@@ -171,7 +174,7 @@ void OffsetGroup::setString (const string & key, const string & value)
(*it).second.second = value;
(*it).second.first = true;
}
- else throw Error::MissingMemoryDefinition("string", key);
+ else throw Error::MissingMemoryDefinition("string", getFullName() + key);
}
@@ -184,9 +187,9 @@ uint32_t OffsetGroup::getAddress (const string & key)
{
if((*iter).second.first)
return (*iter).second.second;
- throw Error::UnsetMemoryDefinition("address", key);
+ throw Error::UnsetMemoryDefinition("address", getFullName() + key);
}
- throw Error::MissingMemoryDefinition("address", key);
+ throw Error::MissingMemoryDefinition("address", getFullName() + key);
}
@@ -198,9 +201,9 @@ int32_t OffsetGroup::getOffset (const string & key)
{
if((*iter).second.first)
return (*iter).second.second;
- throw Error::UnsetMemoryDefinition("offset", key);
+ throw Error::UnsetMemoryDefinition("offset", getFullName() + key);
}
- throw Error::MissingMemoryDefinition("offset", key);
+ throw Error::MissingMemoryDefinition("offset", getFullName() + key);
}
@@ -212,9 +215,9 @@ uint32_t OffsetGroup::getHexValue (const string & key)
{
if((*iter).second.first)
return (*iter).second.second;
- throw Error::UnsetMemoryDefinition("hexvalue", key);
+ throw Error::UnsetMemoryDefinition("hexvalue", getFullName() + key);
}
- throw Error::MissingMemoryDefinition("hexvalue", key);
+ throw Error::MissingMemoryDefinition("hexvalue", getFullName() + key);
}
// Get named string
@@ -225,9 +228,9 @@ std::string OffsetGroup::getString (const string &key)
{
if((*iter).second.first)
return (*iter).second.second;
- throw Error::UnsetMemoryDefinition("string", key);
+ throw Error::UnsetMemoryDefinition("string", getFullName() + key);
}
- throw Error::MissingMemoryDefinition("string", key);
+ throw Error::MissingMemoryDefinition("string", getFullName() + key);
}
OffsetGroup * OffsetGroup::getGroup(const std::string &name)
@@ -243,7 +246,7 @@ OffsetGroup * OffsetGroup::createGroup(const std::string &name)
OffsetGroup * ret = getGroup(name);
if(ret)
return ret;
- ret = new OffsetGroup();
+ ret = new OffsetGroup(name, this);
OGd->groups[name] = ret;
return ret;
}
@@ -264,6 +267,15 @@ void OffsetGroup::RebaseAddresses(int32_t offset)
OffsetGroup::OffsetGroup()
{
OGd = new OffsetGroupPrivate();
+ OGd->name = "Version";
+ OGd->parent = 0;
+}
+
+OffsetGroup::OffsetGroup(const std::string & name, OffsetGroup * parent)
+{
+ OGd = new OffsetGroupPrivate();
+ OGd->name = name;
+ OGd->parent = parent;
}
OffsetGroup::~OffsetGroup()
@@ -276,6 +288,65 @@ OffsetGroup::~OffsetGroup()
delete OGd;
}
+std::string OffsetGroup::getName()
+{
+ return OGd->name;
+}
+
+OffsetGroup * OffsetGroup::getParent()
+{
+ return OGd->parent;
+}
+
+std::string OffsetGroup::getFullName()
+{
+ string temp, accum;
+ OffsetGroup * curr = this;
+ while(curr)
+ {
+ temp = curr->getName() + string("/") + accum;
+ accum = temp;
+ curr = curr->getParent();
+ }
+ return accum;
+}
+
+std::string OffsetGroup::PrintOffsets()
+{
+ uint32_Iter iter;
+ ostringstream ss;
+ for(iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
+ {
+ if((*iter).second.first)
+ ss << "" << endl;
+ }
+ int32_Iter iter2;
+ for(iter2 = OGd->offsets.begin(); iter2 != OGd->offsets.end(); iter2++)
+ {
+ if((*iter).second.first)
+ ss << "" << endl;
+ }
+ for(iter = OGd->hexvals.begin(); iter != OGd->hexvals.end(); iter++)
+ {
+ if((*iter).second.first)
+ ss << "" << endl;
+ }
+ strings_Iter iter3;
+ for(iter3 = OGd->strings.begin(); iter3 != OGd->strings.end(); iter3++)
+ {
+ if((*iter3).second.first)
+ ss << "" << endl;
+ }
+ groups_Iter iter4;
+ for(iter4 = OGd->groups.begin(); iter4 != OGd->groups.end(); iter4++)
+ {
+ ss << "" << endl;
+ ss <<(*iter4).second->PrintOffsets();
+ ss << "" << endl;
+ }
+ return ss.str();
+}
+
/*
* Private data
*/
@@ -325,6 +396,7 @@ VersionInfo::VersionInfo()
d->moods.reserve(NUM_RESERVE_MOODS);
d->md5 = "invalid";
d->PE_timestamp = 0;
+ OffsetGroup();
}
@@ -343,7 +415,7 @@ void OffsetGroup::copy(const OffsetGroup * old)
OGd->strings = old->OGd->strings;
for(groups_Iter it = old->OGd->groups.begin(); it != old->OGd->groups.end(); it++)
{
- OffsetGroup * ogn = new OffsetGroup();
+ OffsetGroup * ogn = new OffsetGroup((*it).first, this);
ogn->copy((*it).second);
OGd->groups[(*it).first] = ogn;
}
@@ -905,27 +977,7 @@ std::string VersionInfo::PrintOffsets()
ss << " UNKNOWN" << endl;
}
ss << "" << endl;
- /*
- map::const_iterator iter;
- for(iter = OGd->addresses.begin(); iter != OGd->addresses.end(); iter++)
- {
- ss << " " << endl;
- }
- map::const_iterator iter2;
- for(iter2 = OGd->offsets.begin(); iter2 != OGd->offsets.end(); iter2++)
- {
- ss << " " << endl;
- }
- for(iter = OGd->hexvals.begin(); iter != OGd->hexvals.end(); iter++)
- {
- ss << " " << endl;
- }
- map::const_iterator iter3;
- for(iter3 = OGd->strings.begin(); iter3 != OGd->strings.end(); iter3++)
- {
- ss << " " << endl;
- }
- */
+ ss << OffsetGroup::PrintOffsets();
ss << "" << endl;
ss << "" << endl;
return ss.str();
diff --git a/library/VersionInfoFactory.cpp b/library/VersionInfoFactory.cpp
index 6a1bd517b..11007f00c 100644
--- a/library/VersionInfoFactory.cpp
+++ b/library/VersionInfoFactory.cpp
@@ -183,6 +183,12 @@ void VersionInfoFactory::ParseOffsets(TiXmlElement * parent, VersionInfo* target
groupPair & gp = breadcrumbs.back();
gp.first = currentElem->NextSiblingElement();
+ if(!og)
+ {
+ string fullname = currentGroup->getFullName() + cstr_name;
+ throw Error::MissingMemoryDefinition("group", fullname);
+ }
+
// add a new level that will be processed next
breadcrumbs.push_back(groupPair(currentElem->FirstChildElement(), og));
continue;
diff --git a/library/include/dfhack/DFError.h b/library/include/dfhack/DFError.h
index 6e967218f..e4def9883 100644
--- a/library/include/dfhack/DFError.h
+++ b/library/include/dfhack/DFError.h
@@ -81,7 +81,7 @@ namespace DFHack
MissingMemoryDefinition(const char* _type, const std::string _key) : type(_type), key(_key)
{
std::stringstream s;
- s << "memory object not declared: type " << type << " key " << key;
+ s << "memory object not declared: type=" << type << " key=" << key;
full = s.str();
}
// Used by functios using integer keys, such as getTrait
@@ -92,7 +92,7 @@ namespace DFHack
key = s1.str();
std::stringstream s;
- s << "memory object not declared: type " << type << " key " << key;
+ s << "memory object not declared: type=" << type << " key=" << key;
full = s.str();
}
virtual ~MissingMemoryDefinition() throw(){};
diff --git a/library/include/dfhack/VersionInfo.h b/library/include/dfhack/VersionInfo.h
index e76fe65d1..571ac646a 100644
--- a/library/include/dfhack/VersionInfo.h
+++ b/library/include/dfhack/VersionInfo.h
@@ -49,6 +49,7 @@ namespace DFHack
OffsetGroupPrivate * OGd;
public:
OffsetGroup();
+ OffsetGroup(const std::string & _name, OffsetGroup * parent = 0);
~OffsetGroup();
void copy(const OffsetGroup * old); // recursive
@@ -70,6 +71,10 @@ namespace DFHack
void setAddress (const std::string & key, const std::string & value);
void setHexValue (const std::string & key, const std::string & value);
void setString (const std::string & key, const std::string & value);
+ std::string PrintOffsets();
+ std::string getName();
+ std::string getFullName();
+ OffsetGroup * getParent();
};
/*