Use globals defined by the latest codegen.

develop
Alexander Gavrilov 2012-02-11 16:27:12 +04:00
parent 952f621ee2
commit f469fab1e6
5 changed files with 12 additions and 53 deletions

@ -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();

@ -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
}

@ -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"

@ -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"

@ -1 +1 @@
Subproject commit 032d4fea9c6b821d258c8a413e56efe274d9572c
Subproject commit 3b20ecfbfcb7b801dbe83b1c22f183ca6085af9e