From 0d11d1b79c254b1c131b4d98838842eb7537b557 Mon Sep 17 00:00:00 2001 From: Quietust Date: Tue, 7 Feb 2012 15:37:21 -0600 Subject: [PATCH 1/3] Synch with structures changes --- library/include/modules/Constructions.h | 2 +- library/include/modules/kitchen.h | 2 +- library/modules/Constructions.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/include/modules/Constructions.h b/library/include/modules/Constructions.h index 9e2150dd6..cc9fef2b1 100644 --- a/library/include/modules/Constructions.h +++ b/library/include/modules/Constructions.h @@ -46,7 +46,7 @@ namespace Constructions struct t_construction { df::coord pos; df::item_type item_type; - int16_t unk; + int16_t item_subtype; int16_t mat_type; int32_t mat_index; df::construction_flags flags; diff --git a/library/include/modules/kitchen.h b/library/include/modules/kitchen.h index a18011390..fab387288 100644 --- a/library/include/modules/kitchen.h +++ b/library/include/modules/kitchen.h @@ -49,7 +49,7 @@ typedef uint8_t t_exclusionType; const unsigned int seedLimit = 400; // a limit on the limits which can be placed on seeds const t_itemSubtype organicSubtype = -1; // seems to fixed const t_exclusionType cookingExclusion = 1; // seems to be fixed -const t_itemType limitType = 0; // used to store limit as an entry in the exclusion list. 0 = BAR +const df::enums::item_type::item_type limitType = df::enums::item_type::BAR; // used to store limit as an entry in the exclusion list. 0 = BAR const t_itemSubtype limitSubtype = 0; // used to store limit as an entry in the exclusion list const t_exclusionType limitExclusion = 4; // used to store limit as an entry in the exclusion list diff --git a/library/modules/Constructions.cpp b/library/modules/Constructions.cpp index 0f371b56a..ac9057075 100644 --- a/library/modules/Constructions.cpp +++ b/library/modules/Constructions.cpp @@ -67,7 +67,7 @@ bool Constructions::copyConstruction(const int32_t index, t_construction &out) out.pos = out.origin->pos; out.item_type = out.origin->item_type; - out.unk = out.origin->anon_1; + out.item_subtype = out.origin->item_subtype; out.mat_type = out.origin->mat_type; out.mat_index = out.origin->mat_index; out.flags = out.origin->flags; From 952f621ee272f321939ac8161b9f566496593e2a Mon Sep 17 00:00:00 2001 From: Quietust Date: Wed, 8 Feb 2012 22:35:22 -0600 Subject: [PATCH 2/3] Synchronize with df-structures --- library/include/modules/Engravings.h | 4 ++-- library/modules/Engravings.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/library/include/modules/Engravings.h b/library/include/modules/Engravings.h index 6c80eac7b..d52303f32 100644 --- a/library/include/modules/Engravings.h +++ b/library/include/modules/Engravings.h @@ -49,8 +49,8 @@ struct t_engraving { df::coord pos; df::engraving_flags flags; int8_t tile; - int32_t type; - int16_t subtype; + int32_t art_id; + int16_t art_subid; df::item_quality quality; // Pointer to original object, in case you want to modify it df::engraving *origin; diff --git a/library/modules/Engravings.cpp b/library/modules/Engravings.cpp index c7cbd9452..9fc2c3adf 100644 --- a/library/modules/Engravings.cpp +++ b/library/modules/Engravings.cpp @@ -72,8 +72,8 @@ bool Engravings::copyEngraving(const int32_t index, t_engraving &out) out.pos = out.origin->pos; out.flags = out.origin->flags; out.tile = out.origin->tile; - out.type = out.origin->type; - out.subtype = out.origin->subtype; + out.art_id = out.origin->art_id; + out.art_subid = out.origin->art_subid; out.quality = out.origin->quality; return true; } From f469fab1e6e419ff26655bc3fe9868653dc0f0f0 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Sat, 11 Feb 2012 16:27:12 +0400 Subject: [PATCH 3/3] Use globals defined by the latest codegen. --- library/Core.cpp | 2 +- library/DataDefs.cpp | 19 ------------------- library/DataStatics.cpp | 8 ++++++++ library/include/DataDefs.h | 34 ++-------------------------------- library/xml | 2 +- 5 files changed, 12 insertions(+), 53 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index e06dd3f3c..4550fe25e 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -651,7 +651,7 @@ bool Core::Init() // initialize data defs virtual_identity::Init(this); - InitDataDefGlobals(this); + df::global::InitGlobals(); // create mutex for syncing with interactive tasks StackMutex = new mutex(); diff --git a/library/DataDefs.cpp b/library/DataDefs.cpp index cd8a8ed7c..d328d7a17 100644 --- a/library/DataDefs.cpp +++ b/library/DataDefs.cpp @@ -206,22 +206,3 @@ int DFHack::findBitfieldField(const std::string &name, int size, const bitfield_ return -1; } - -#define SIMPLE_GLOBAL(name,tname) \ - tname *df::global::name = NULL; -#define GLOBAL(name,tname) SIMPLE_GLOBAL(name,df::tname) -DF_KNOWN_GLOBALS -#undef GLOBAL -#undef SIMPLE_GLOBAL - -void DFHack::InitDataDefGlobals(Core *core) { - OffsetGroup *global_table = core->vinfo->getGroup("global"); - void * tmp; - -#define SIMPLE_GLOBAL(name,tname) \ - if (global_table->getSafeAddress(#name,tmp)) df::global::name = (tname*)tmp; -#define GLOBAL(name,tname) SIMPLE_GLOBAL(name,df::tname) -DF_KNOWN_GLOBALS -#undef GLOBAL -#undef SIMPLE_GLOBAL -} diff --git a/library/DataStatics.cpp b/library/DataStatics.cpp index f47c0fe05..63eb596e1 100644 --- a/library/DataStatics.cpp +++ b/library/DataStatics.cpp @@ -1,6 +1,7 @@ #include "Internal.h" #include "DataDefs.h" #include "MiscUtils.h" +#include "VersionInfo.h" #include "df/world.h" #include "df/world_data.h" @@ -13,6 +14,13 @@ namespace { inline T &_toref(T *&p) { return *p; } } +#define INIT_GLOBAL_FUNCTION_PREFIX \ + DFHack::OffsetGroup *global_table_ = DFHack::Core::getInstance().vinfo->getGroup("global"); \ + void * tmp_; + +#define INIT_GLOBAL_FUNCTION_ITEM(type,name) \ + if (global_table_->getSafeAddress(#name,tmp_)) name = (type*)tmp_; + // Instantiate all the static objects #include "df/static.inc" #include "df/static.enums.inc" diff --git a/library/include/DataDefs.h b/library/include/DataDefs.h index 1e72e9a1f..7ef64ef5e 100644 --- a/library/include/DataDefs.h +++ b/library/include/DataDefs.h @@ -237,38 +237,8 @@ namespace df #define FOR_ENUM_ITEMS(enum,iter) \ for(df::enum iter = ENUM_FIRST_ITEM(enum); iter <= ENUM_LAST_ITEM(enum); iter = df::enum(1+int(iter))) -namespace df { -#define DF_KNOWN_GLOBALS \ - GLOBAL(cursor,cursor) \ - GLOBAL(selection_rect,selection_rect) \ - GLOBAL(world,world) \ - GLOBAL(ui,ui) \ - GLOBAL(gview,interface) \ - GLOBAL(init,init) \ - GLOBAL(d_init,d_init) \ - SIMPLE_GLOBAL(job_next_id,int) \ - SIMPLE_GLOBAL(ui_look_cursor,int) \ - SIMPLE_GLOBAL(ui_workshop_job_cursor,int) \ - SIMPLE_GLOBAL(ui_building_item_cursor,int) \ - SIMPLE_GLOBAL(ui_workshop_in_add,bool) \ - SIMPLE_GLOBAL(ui_selected_unit,int) \ - SIMPLE_GLOBAL(cur_year,int) \ - SIMPLE_GLOBAL(cur_year_tick,int) \ - GLOBAL(ui_sidebar_menus,ui_sidebar_menus) \ - GLOBAL(ui_build_selector,ui_build_selector) \ - GLOBAL(ui_look_list,ui_look_list) \ - GLOBAL(ui_unit_view_mode, ui_unit_view_mode) \ - GLOBAL(gps, graphic) \ - - -#define SIMPLE_GLOBAL(name,tname) \ - namespace global { extern DFHACK_EXPORT tname *name; } -#define GLOBAL(name,tname) \ - struct tname; SIMPLE_GLOBAL(name,tname) -DF_KNOWN_GLOBALS -#undef GLOBAL -#undef SIMPLE_GLOBAL -} +// Global object pointers +#include "df/global_objects.h" // A couple of headers that have to be included at once #include "df/coord2d.h" diff --git a/library/xml b/library/xml index 032d4fea9..3b20ecfbf 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 032d4fea9c6b821d258c8a413e56efe274d9572c +Subproject commit 3b20ecfbfcb7b801dbe83b1c22f183ca6085af9e