diff --git a/library/Core.cpp b/library/Core.cpp index 4a3dacd25..4531370b8 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -1097,7 +1097,6 @@ MODULE_GETTER(Materials); MODULE_GETTER(Items); MODULE_GETTER(Translation); MODULE_GETTER(Vegetation); -MODULE_GETTER(Buildings); MODULE_GETTER(Constructions); MODULE_GETTER(Vermin); MODULE_GETTER(Notes); diff --git a/library/include/Core.h b/library/include/Core.h index a368e360d..c6cf73b0d 100644 --- a/library/include/Core.h +++ b/library/include/Core.h @@ -61,7 +61,6 @@ namespace DFHack class Items; class Translation; class Vegetation; - class Buildings; class Constructions; class Vermin; class Notes; @@ -119,8 +118,6 @@ namespace DFHack Translation * getTranslation(); /// get the vegetation module Vegetation * getVegetation(); - /// get the buildings module - Buildings * getBuildings(); /// get the constructions module Constructions * getConstructions(); /// get the vermin module @@ -182,7 +179,6 @@ namespace DFHack Items * pItems; Translation * pTranslation; Vegetation * pVegetation; - Buildings * pBuildings; Constructions * pConstructions; Vermin * pVermin; Notes * pNotes; diff --git a/library/include/modules/Buildings.h b/library/include/modules/Buildings.h index 8089fd4b1..7da2ad9dc 100644 --- a/library/include/modules/Buildings.h +++ b/library/include/modules/Buildings.h @@ -23,61 +23,49 @@ distribution. */ #pragma once -#ifndef CL_MOD_BUILDINGS -#define CL_MOD_BUILDINGS -/** - * \defgroup grp_buildings Building module parts - also includes zones and stockpiles - * @ingroup grp_modules - */ #include "Export.h" -#include "Module.h" -#ifdef __cplusplus namespace DFHack { -#endif - /** - * Structure for holding a read DF building object - * \ingroup grp_buildings - */ - struct t_building - { - uint32_t x1; - uint32_t y1; - uint32_t x2; - uint32_t y2; - uint32_t z; - t_matglossPair material; - uint32_t type; - int32_t custom_type; - void * origin; - }; +namespace Simple +{ +namespace Buildings +{ +/** + * Structure for holding a read DF building object + * \ingroup grp_buildings + */ +struct t_building +{ + uint32_t x1; + uint32_t y1; + uint32_t x2; + uint32_t y2; + uint32_t z; + t_matglossPair material; + uint32_t type; + int32_t custom_type; + void * origin; +}; -#ifdef __cplusplus - /** - * The Buildings module - allows reading DF buildings - * \ingroup grp_modules - * \ingroup grp_buildings - */ - class DFHACK_EXPORT Buildings : public Module - { - public: - Buildings(); - ~Buildings(); - bool Start(uint32_t & numBuildings); - // read one building at offset - bool Read (const uint32_t index, t_building & building); - bool Finish(); +/** + * The Buildings module - allows reading DF buildings + * \ingroup grp_modules + * \ingroup grp_buildings + */ +DFHACK_EXPORT uint32_t getNumBuildings (); - // read mapping from custom_type value to building RAW name - // custom_type of -1 implies ordinary building - bool ReadCustomWorkshopTypes(std::map & btypes); +/** + * read building by index + */ +DFHACK_EXPORT bool Read (const uint32_t index, t_building & building); - private: - struct Private; - Private *d; - }; -} -#endif // __cplusplus +/** + * read mapping from custom_type value to building RAW name + * custom_type of -1 implies ordinary building + */ +DFHACK_EXPORT bool ReadCustomWorkshopTypes(std::map & btypes); -#endif +} +} +} diff --git a/library/modules/Buildings.cpp b/library/modules/Buildings.cpp index 6f2b4a3f3..2213abd35 100644 --- a/library/modules/Buildings.cpp +++ b/library/modules/Buildings.cpp @@ -38,10 +38,10 @@ using namespace std; #include "ModuleFactory.h" #include "Core.h" using namespace DFHack; +using namespace DFHack::Simple; #include "DataDefs.h" #include "df/world.h" -#include "df/world_raws.h" #include "df/building_def.h" #include "df/building.h" #include "df/building_workshopst.h" @@ -50,70 +50,19 @@ using namespace df::enums; using df::global::world; using df::building_def; -//raw -struct t_building_df40d +uint32_t Buildings::getNumBuildings() { - uint32_t vtable; - uint32_t x1; - uint32_t y1; - uint32_t centerx; - uint32_t x2; - uint32_t y2; - uint32_t centery; - uint32_t z; - uint32_t height; - t_matglossPair material; - // not complete -}; - -struct Buildings::Private -{ - Process * owner; - bool Inited; - bool Started; - int32_t custom_workshop_id; -}; - -Module* DFHack::createBuildings() -{ - return new Buildings(); -} - -Buildings::Buildings() -{ - Core & c = Core::getInstance(); - d = new Private; - d->Started = false; - d->owner = c.p; - d->Inited = true; - c.vinfo->resolveClassnameToClassID("building_custom_workshop", d->custom_workshop_id); -} - -Buildings::~Buildings() -{ - if(d->Started) - Finish(); - delete d; -} - -bool Buildings::Start(uint32_t & numbuildings) -{ - if(!d->Inited) - return false; - numbuildings = world->buildings.all.size(); - d->Started = true; - return true; + return world->buildings.all.size(); } bool Buildings::Read (const uint32_t index, t_building & building) { - if(!d->Started) - return false; + Core & c = Core::getInstance(); df::building *bld_40d = world->buildings.all[index]; // transform int32_t type = -1; - d->owner->getDescriptor()->resolveObjectToClassID ( (char *)bld_40d, type); + c.vinfo->resolveObjectToClassID ( (char *)bld_40d, type); building.x1 = bld_40d->x1; building.x2 = bld_40d->x2; building.y1 = bld_40d->y1; @@ -127,19 +76,10 @@ bool Buildings::Read (const uint32_t index, t_building & building) return true; } -bool Buildings::Finish() -{ - d->Started = false; - return true; -} - bool Buildings::ReadCustomWorkshopTypes(map & btypes) { - if(!d->Inited) - return false; Core & c = Core::getInstance(); - Process * p = d->owner; vector & bld_def = world->raws.buildings.all; uint32_t size = bld_def.size(); btypes.clear(); diff --git a/plugins/df2mc b/plugins/df2mc index 3277c6b29..c114ec5f9 160000 --- a/plugins/df2mc +++ b/plugins/df2mc @@ -1 +1 @@ -Subproject commit 3277c6b29ddbb5d800ccb65eba27fed200236f3d +Subproject commit c114ec5f995aec69631187212254309464f82775 diff --git a/plugins/probe.cpp b/plugins/probe.cpp index a000d9e31..d70a6dbaf 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -135,7 +135,7 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) MapExtras::Block * b = mc.BlockAt(cursor/16); mapblock40d & block = b->raw; - if(b) + if(b && b->valid) { con.print("block addr: 0x%x\n\n", block.origin); /* @@ -285,6 +285,10 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) con << "mystery: " << block.mystery << endl; con << std::endl; } + else + { + con.printerr("No data.\n"); + } } } c->Resume(); diff --git a/plugins/stonesense b/plugins/stonesense index 545b2730e..92627e39c 160000 --- a/plugins/stonesense +++ b/plugins/stonesense @@ -1 +1 @@ -Subproject commit 545b2730ed137935643778f1b8ba115ae11c50a2 +Subproject commit 92627e39cb3502812cd5a131716d3d1da8ef625a