diff --git a/Memory.xml b/Memory.xml index 114ee081a..ca70e10bf 100644 --- a/Memory.xml +++ b/Memory.xml @@ -75,8 +75,11 @@
+
+
+
@@ -94,6 +97,7 @@
+
diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index c8fe57a92..4e1c8fcaf 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -72,7 +72,6 @@ DataStaticsCtor.cpp MiscUtils.cpp PluginManager.cpp TileTypes.cpp -VersionInfo.cpp VersionInfoFactory.cpp Virtual.cpp diff --git a/library/Core.cpp b/library/Core.cpp index e06dd3f3c..96c60ab84 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -640,15 +640,15 @@ bool Core::Init() cerr << "Console is running.\n"; else fatal ("Console has failed to initialize!\n", false); - +/* // dump offsets to a file std::ofstream dump("offsets.log"); if(!dump.fail()) { - dump << vinfo->PrintOffsets(); + //dump << vinfo->PrintOffsets(); dump.close(); } - + */ // initialize data defs virtual_identity::Init(this); InitDataDefGlobals(this); diff --git a/library/DataDefs.cpp b/library/DataDefs.cpp index cd8a8ed7c..86c3ea024 100644 --- a/library/DataDefs.cpp +++ b/library/DataDefs.cpp @@ -152,7 +152,8 @@ void virtual_identity::Init(Core *core) p->parent->has_children = true; } } - + //FIXME: ... nuked. the group was empty... +/* // Read pre-filled vtable ptrs OffsetGroup *ptr_table = core->vinfo->getGroup("vtable"); for (virtual_identity *p = list; p; p = p->next) { @@ -160,6 +161,7 @@ void virtual_identity::Init(Core *core) if (ptr_table->getSafeAddress(p->getName(),tmp)) p->vtable_ptr = tmp; } + */ } std::string DFHack::bitfieldToString(const void *p, int size, const bitfield_item_info *items) @@ -215,11 +217,11 @@ DF_KNOWN_GLOBALS #undef SIMPLE_GLOBAL void DFHack::InitDataDefGlobals(Core *core) { - OffsetGroup *global_table = core->vinfo->getGroup("global"); + VersionInfo *vinfo = core->vinfo; void * tmp; #define SIMPLE_GLOBAL(name,tname) \ - if (global_table->getSafeAddress(#name,tmp)) df::global::name = (tname*)tmp; + if (vinfo->getAddress(#name,tmp)) df::global::name = (tname*)tmp; #define GLOBAL(name,tname) SIMPLE_GLOBAL(name,df::tname) DF_KNOWN_GLOBALS #undef GLOBAL diff --git a/library/Process-linux.cpp b/library/Process-linux.cpp index 1a2669286..f5503fb4f 100644 --- a/library/Process-linux.cpp +++ b/library/Process-linux.cpp @@ -65,7 +65,6 @@ Process::Process(VersionInfoFactory * known_versions) if(vinfo) { my_descriptor = new VersionInfo(*vinfo); - my_descriptor->setParentProcess(this); identified = true; } else diff --git a/library/VersionInfoFactory.cpp b/library/VersionInfoFactory.cpp index c5ed7f14f..c6914583b 100644 --- a/library/VersionInfoFactory.cpp +++ b/library/VersionInfoFactory.cpp @@ -120,7 +120,7 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem) type = cstr_type; if(type == "Address") { - const char *cstr_key = currentElem->Attribute("name"); + const char *cstr_key = pMemEntry->Attribute("key"); if(!cstr_key) throw Error::MemoryXmlUnderspecifiedEntry(cstr_key); const char *cstr_value = pMemEntry->Attribute("value"); @@ -188,7 +188,7 @@ bool VersionInfoFactory::loadFile(string path_to_xml) { clear(); // For each version - pMemInfo=hRoot.FirstChild( "Version" ).Element(); + TiXmlElement * pMemInfo=hRoot.FirstChild( "Version" ).Element(); for( ; pMemInfo; pMemInfo=pMemInfo->NextSiblingElement("Version")) { const char *name = pMemInfo->Attribute("name"); diff --git a/library/include/VersionInfo.h b/library/include/VersionInfo.h index 3bbcd9c06..d996722c0 100644 --- a/library/include/VersionInfo.h +++ b/library/include/VersionInfo.h @@ -31,6 +31,7 @@ distribution. #include #include #include +#include namespace DFHack { @@ -49,7 +50,7 @@ namespace DFHack private: std::vector md5_list; std::vector PE_list; - map Addresses; + std::map Addresses; uint32_t base; std::string version; OSType OS; @@ -75,13 +76,13 @@ namespace DFHack void rebaseTo(const uint32_t new_base) { int64_t old = base; - int64_t new = new_base; - int64_t rebase = new - old; + int64_t newx = new_base; + int64_t rebase = newx - old; base = new_base; - auto iter = Addresses.start(); + auto iter = Addresses.begin(); while (iter != Addresses.end()) { - uint32_t & ref = *iter.second; + uint32_t & ref = (*iter).second; ref += rebase; iter ++; } @@ -93,7 +94,7 @@ namespace DFHack }; bool hasMD5 (const std::string & _md5) const { - return find(md5_list.begin(), md5_list.end(), PE_) != md5_list.end(); + return std::find(md5_list.begin(), md5_list.end(), _md5) != md5_list.end(); }; void addPE (uint32_t PE_) @@ -102,7 +103,7 @@ namespace DFHack }; bool hasPE (uint32_t PE_) const { - return find(PE_list.begin(), PE_list.end(), PE_) != PE_list.end(); + return std::find(PE_list.begin(), PE_list.end(), PE_) != PE_list.end(); }; void setVersion(const std::string& v) @@ -115,12 +116,21 @@ namespace DFHack { Addresses[key] = value; }; - uint32_t getAddress (const std::string& key) const; + template + bool getAddress (const std::string& key, T & value) { - iter i = Addresses.find(key); + auto i = Addresses.find(key); + if(i == Addresses.end()) + return false; + value = (T) (*i).second; + return true; + }; + uint32_t getAddress (const std::string& key) const + { + auto i = Addresses.find(key); if(i == Addresses.end()) return 0; - return *i.second; + return (*i).second; } void setOS(const OSType os) diff --git a/library/include/modules/Buildings.h b/library/include/modules/Buildings.h index 39fbe8de6..78fa064a8 100644 --- a/library/include/modules/Buildings.h +++ b/library/include/modules/Buildings.h @@ -45,7 +45,8 @@ struct t_building uint32_t y2; uint32_t z; t_matglossPair material; - uint32_t type; + int32_t type; + int16_t subtype; int32_t custom_type; df::building * origin; }; diff --git a/library/include/modules/Materials.h b/library/include/modules/Materials.h index 3b4d78203..f3c526d76 100644 --- a/library/include/modules/Materials.h +++ b/library/include/modules/Materials.h @@ -360,9 +360,6 @@ namespace DFHack std::string getType(const t_material & mat); std::string getDescription(const t_material & mat); - private: - class Private; - Private* d; }; } #endif diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 1673cfc5c..96a34153e 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -59,9 +59,6 @@ bool Buildings::Read (const uint32_t index, t_building & building) Core & c = Core::getInstance(); df::building *bld_40d = world->buildings.all[index]; - // transform - int32_t type = -1; - c.vinfo->resolveObjectToClassID ( (char *)bld_40d, type); building.x1 = bld_40d->x1; building.x2 = bld_40d->x2; building.y1 = bld_40d->y1; @@ -69,7 +66,8 @@ bool Buildings::Read (const uint32_t index, t_building & building) building.z = bld_40d->z; building.material.index = bld_40d->mat_index; building.material.type = bld_40d->mat_type; - building.type = type; + building.type = bld_40d->getType(); + building.subtype = bld_40d->getSubtype(); building.custom_type = bld_40d->getCustomType(); building.origin = bld_40d; return true; diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index fbe103798..88eed7f1f 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -481,34 +481,18 @@ Gui::Gui() d = new Private; d->owner = c.p; VersionInfo * mem = c.vinfo; - OffsetGroup * OG_Gui = mem->getGroup("GUI"); - // Setting up menu state - try - { - df_menu_state = (uint32_t *) OG_Gui->getAddress("current_menu_state"); - } - catch(Error::All &) - { - df_menu_state = 0; - }; + df_menu_state = (uint32_t *) & df::global::ui->main.mode; - OffsetGroup * OG_Position; - try - { - OG_Position = mem->getGroup("Position"); - d->window_x_offset = (int32_t *) OG_Position->getAddress ("window_x"); - d->window_y_offset = (int32_t *) OG_Position->getAddress ("window_y"); - d->window_z_offset = (int32_t *) OG_Position->getAddress ("window_z"); + d->window_x_offset = (int32_t *) mem->getAddress ("window_x"); + d->window_y_offset = (int32_t *) mem->getAddress ("window_y"); + d->window_z_offset = (int32_t *) mem->getAddress ("window_z"); + if(d->window_z_offset && d->window_y_offset && d->window_x_offset) d->Started = true; - } - catch(Error::All &){}; - try - { - d->screen_tiles_ptr_offset = (void *) OG_Position->getAddress ("screen_tiles_pointer"); + + d->screen_tiles_ptr_offset = (void *) mem->getAddress ("screen_tiles_pointer"); + if(d->screen_tiles_ptr_offset) d->StartedScreen = true; - } - catch(Error::All &){}; } Gui::~Gui() diff --git a/library/modules/Materials.cpp b/library/modules/Materials.cpp index 922fa7789..e52ebb283 100644 --- a/library/modules/Materials.cpp +++ b/library/modules/Materials.cpp @@ -539,29 +539,13 @@ Module* DFHack::createMaterials() return new Materials(); } -class Materials::Private -{ - public: - Process * owner; - OffsetGroup * OG_Materials; - void * vector_races; - void * vector_other; -}; Materials::Materials() { - Core & c = Core::getInstance(); - d = new Private; - d->owner = c.p; - OffsetGroup *OG_Materials = d->OG_Materials = c.vinfo->getGroup("Materials"); - { - d->vector_races = OG_Materials->getAddress("creature_type_vector"); - } } Materials::~Materials() { - delete d; } bool Materials::Finish() @@ -596,7 +580,6 @@ bool t_matglossInorganic::isGem() bool Materials::CopyInorganicMaterials (std::vector & inorganic) { - Process * p = d->owner; size_t size = world->raws.inorganics.size(); inorganic.clear(); inorganic.reserve (size); diff --git a/library/modules/Notes.cpp b/library/modules/Notes.cpp index bcfe6aa68..b5215102f 100644 --- a/library/modules/Notes.cpp +++ b/library/modules/Notes.cpp @@ -36,6 +36,8 @@ using namespace std; #include "ModuleFactory.h" #include "Core.h" #include "modules/Notes.h" +#include +#include "df/ui.h" using namespace DFHack; Module* DFHack::createNotes() @@ -43,21 +45,8 @@ Module* DFHack::createNotes() return new Notes(); } +// FIXME: not even a wrapper now Notes::Notes() { - Core & c = Core::getInstance(); - - notes = NULL; - VersionInfo * mem = c.vinfo; - try - { - OffsetGroup * OG_Notes = mem->getGroup("Notes"); - - notes = (std::vector*) OG_Notes->getAddress("vector"); - } - catch(DFHack::Error::AllMemdef &e) - { - notes = NULL; - cerr << "Notes not available... " << e.what() << endl; - } + notes = (std::vector*) &df::global::ui->waypoints.points; } diff --git a/library/modules/World.cpp b/library/modules/World.cpp index e5184ee3c..406303ebd 100644 --- a/library/modules/World.cpp +++ b/library/modules/World.cpp @@ -82,29 +82,19 @@ World::World() d->owner = c.p; wmap = 0; - OffsetGroup * OG_Gui = c.vinfo->getGroup("GUI"); - try - { - d->pause_state_offset = OG_Gui->getAddress ("pause_state"); + d->pause_state_offset = (void *) c.vinfo->getAddress ("pause_state"); + if(d->pause_state_offset) d->PauseInited = true; - } - catch(exception &){}; - OffsetGroup * OG_World = c.vinfo->getGroup("World"); - try + d->weather_offset = (char *) c.vinfo->getAddress( "current_weather" ); + if(d->weather_offset) { - d->weather_offset = OG_World->getAddress( "current_weather" ); wmap = (weather_map *) d->weather_offset; d->StartedWeather = true; } - catch(Error::All &){}; - try - { - d->gamemode_offset = OG_World->getAddress( "game_mode" ); - d->controlmode_offset = OG_World->getAddress( "control_mode" ); - d->StartedMode = true; - } - catch(Error::All &){}; + d->gamemode_offset = (void *) c.vinfo->getAddress( "game_mode" ); + d->controlmode_offset = (void *) c.vinfo->getAddress( "control_mode" ); + d->StartedMode = true; d->Inited = true; } diff --git a/plugins/dwarfexport/dwarfexport.cpp b/plugins/dwarfexport/dwarfexport.cpp index 3dfd3f88f..20d48f39a 100644 --- a/plugins/dwarfexport/dwarfexport.cpp +++ b/plugins/dwarfexport/dwarfexport.cpp @@ -28,6 +28,7 @@ using df::global::world; // our own, empty header. #include "dwarfexport.h" +#include // Here go all the command declarations... @@ -106,18 +107,26 @@ static void printAttributes(Core* c, df::unit* cre, ostream& out) { out << " " << endl; } -static void printTraits(Core* c, df::unit* cre, ostream& out) { +static void printTraits(Core* c, df::unit* cre, ostream& out) +{ + out << " " << endl; df::unit_soul * s = cre->status.current_soul; - if (s) { - for (int i = 0; i < NUM_CREATURE_TRAITS; i++) { - out << " "; + if (s) + { + FOR_ENUM_ITEMS(personality_facet_type,index) + { + out << " "; + //FIXME: needs reimplementing trait string generation + /* string trait = c->vinfo->getTrait(i, s->traits[i]); if (!trait.empty()) { out << trait.c_str(); } + */ out << "" << endl; + } } out << " " << endl;