Make it build and run on linux (no stonesense, df2mc, dfusion)

develop
Petr Mrázek 2012-02-09 03:07:26 +01:00
parent f7d8635be1
commit 8f680dcf94
15 changed files with 71 additions and 106 deletions

@ -75,8 +75,11 @@
<!-- .data --> <!-- .data -->
<Address key='cursor' value='0x8c3de60'/> <Address key='cursor' value='0x8c3de60'/>
<Address key='selection_rect' value='0x8c3de70'/> <Address key='selection_rect' value='0x8c3de70'/>
<Address key="control_mode" value="0x8c3de90" />
<Address key="game_mode" value="0x8c3dea0" />
<!-- .bss --> <!-- .bss -->
<Address key='world' value='0x93f77a0'/> <Address key='world' value='0x93f77a0'/>
<Address key="pause_state" value="0x93f06f0" />
<Address key='ui' value='0x93f0780'/> <Address key='ui' value='0x93f0780'/>
<Address key='gview' value='0x8c3e900'/> <Address key='gview' value='0x8c3e900'/>
<Address key='init' value='0x959c2a0'/> <Address key='init' value='0x959c2a0'/>
@ -94,6 +97,7 @@
<Address key='ui_building_item_cursor' value='0x93f0648'/> <Address key='ui_building_item_cursor' value='0x93f0648'/>
<Address key='ui_selected_unit' value='0x93f06d0'/> <Address key='ui_selected_unit' value='0x93f06d0'/>
<Address key='ui_unit_view_mode' value='0x93f06d8'/> <Address key='ui_unit_view_mode' value='0x93f06d8'/>
<Address key="current_weather" value="0x0x93f05e4" />
<Address key='cur_year' value='0x93f0600'/> <Address key='cur_year' value='0x93f0600'/>
<Address key='cur_year_tick' value='0x93f0620'/> <Address key='cur_year_tick' value='0x93f0620'/>

@ -72,7 +72,6 @@ DataStaticsCtor.cpp
MiscUtils.cpp MiscUtils.cpp
PluginManager.cpp PluginManager.cpp
TileTypes.cpp TileTypes.cpp
VersionInfo.cpp
VersionInfoFactory.cpp VersionInfoFactory.cpp
Virtual.cpp Virtual.cpp

@ -640,15 +640,15 @@ bool Core::Init()
cerr << "Console is running.\n"; cerr << "Console is running.\n";
else else
fatal ("Console has failed to initialize!\n", false); fatal ("Console has failed to initialize!\n", false);
/*
// dump offsets to a file // dump offsets to a file
std::ofstream dump("offsets.log"); std::ofstream dump("offsets.log");
if(!dump.fail()) if(!dump.fail())
{ {
dump << vinfo->PrintOffsets(); //dump << vinfo->PrintOffsets();
dump.close(); dump.close();
} }
*/
// initialize data defs // initialize data defs
virtual_identity::Init(this); virtual_identity::Init(this);
InitDataDefGlobals(this); InitDataDefGlobals(this);

@ -152,7 +152,8 @@ void virtual_identity::Init(Core *core)
p->parent->has_children = true; p->parent->has_children = true;
} }
} }
//FIXME: ... nuked. the group was empty...
/*
// Read pre-filled vtable ptrs // Read pre-filled vtable ptrs
OffsetGroup *ptr_table = core->vinfo->getGroup("vtable"); OffsetGroup *ptr_table = core->vinfo->getGroup("vtable");
for (virtual_identity *p = list; p; p = p->next) { 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)) if (ptr_table->getSafeAddress(p->getName(),tmp))
p->vtable_ptr = tmp; p->vtable_ptr = tmp;
} }
*/
} }
std::string DFHack::bitfieldToString(const void *p, int size, const bitfield_item_info *items) std::string DFHack::bitfieldToString(const void *p, int size, const bitfield_item_info *items)
@ -215,11 +217,11 @@ DF_KNOWN_GLOBALS
#undef SIMPLE_GLOBAL #undef SIMPLE_GLOBAL
void DFHack::InitDataDefGlobals(Core *core) { void DFHack::InitDataDefGlobals(Core *core) {
OffsetGroup *global_table = core->vinfo->getGroup("global"); VersionInfo *vinfo = core->vinfo;
void * tmp; void * tmp;
#define SIMPLE_GLOBAL(name,tname) \ #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) #define GLOBAL(name,tname) SIMPLE_GLOBAL(name,df::tname)
DF_KNOWN_GLOBALS DF_KNOWN_GLOBALS
#undef GLOBAL #undef GLOBAL

@ -65,7 +65,6 @@ Process::Process(VersionInfoFactory * known_versions)
if(vinfo) if(vinfo)
{ {
my_descriptor = new VersionInfo(*vinfo); my_descriptor = new VersionInfo(*vinfo);
my_descriptor->setParentProcess(this);
identified = true; identified = true;
} }
else else

@ -120,7 +120,7 @@ void VersionInfoFactory::ParseVersion (TiXmlElement* entry, VersionInfo* mem)
type = cstr_type; type = cstr_type;
if(type == "Address") if(type == "Address")
{ {
const char *cstr_key = currentElem->Attribute("name"); const char *cstr_key = pMemEntry->Attribute("key");
if(!cstr_key) if(!cstr_key)
throw Error::MemoryXmlUnderspecifiedEntry(cstr_key); throw Error::MemoryXmlUnderspecifiedEntry(cstr_key);
const char *cstr_value = pMemEntry->Attribute("value"); const char *cstr_value = pMemEntry->Attribute("value");
@ -188,7 +188,7 @@ bool VersionInfoFactory::loadFile(string path_to_xml)
{ {
clear(); clear();
// For each version // For each version
pMemInfo=hRoot.FirstChild( "Version" ).Element(); TiXmlElement * pMemInfo=hRoot.FirstChild( "Version" ).Element();
for( ; pMemInfo; pMemInfo=pMemInfo->NextSiblingElement("Version")) for( ; pMemInfo; pMemInfo=pMemInfo->NextSiblingElement("Version"))
{ {
const char *name = pMemInfo->Attribute("name"); const char *name = pMemInfo->Attribute("name");

@ -31,6 +31,7 @@ distribution.
#include <map> #include <map>
#include <sys/types.h> #include <sys/types.h>
#include <vector> #include <vector>
#include <algorithm>
namespace DFHack namespace DFHack
{ {
@ -49,7 +50,7 @@ namespace DFHack
private: private:
std::vector <std::string> md5_list; std::vector <std::string> md5_list;
std::vector <uint32_t> PE_list; std::vector <uint32_t> PE_list;
map <std::string, uint32_t> Addresses; std::map <std::string, uint32_t> Addresses;
uint32_t base; uint32_t base;
std::string version; std::string version;
OSType OS; OSType OS;
@ -75,13 +76,13 @@ namespace DFHack
void rebaseTo(const uint32_t new_base) void rebaseTo(const uint32_t new_base)
{ {
int64_t old = base; int64_t old = base;
int64_t new = new_base; int64_t newx = new_base;
int64_t rebase = new - old; int64_t rebase = newx - old;
base = new_base; base = new_base;
auto iter = Addresses.start(); auto iter = Addresses.begin();
while (iter != Addresses.end()) while (iter != Addresses.end())
{ {
uint32_t & ref = *iter.second; uint32_t & ref = (*iter).second;
ref += rebase; ref += rebase;
iter ++; iter ++;
} }
@ -93,7 +94,7 @@ namespace DFHack
}; };
bool hasMD5 (const std::string & _md5) const 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_) void addPE (uint32_t PE_)
@ -102,7 +103,7 @@ namespace DFHack
}; };
bool hasPE (uint32_t PE_) const 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) void setVersion(const std::string& v)
@ -115,12 +116,21 @@ namespace DFHack
{ {
Addresses[key] = value; Addresses[key] = value;
}; };
uint32_t getAddress (const std::string& key) const; template <typename T>
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()) if(i == Addresses.end())
return 0; return 0;
return *i.second; return (*i).second;
} }
void setOS(const OSType os) void setOS(const OSType os)

@ -45,7 +45,8 @@ struct t_building
uint32_t y2; uint32_t y2;
uint32_t z; uint32_t z;
t_matglossPair material; t_matglossPair material;
uint32_t type; int32_t type;
int16_t subtype;
int32_t custom_type; int32_t custom_type;
df::building * origin; df::building * origin;
}; };

@ -360,9 +360,6 @@ namespace DFHack
std::string getType(const t_material & mat); std::string getType(const t_material & mat);
std::string getDescription(const t_material & mat); std::string getDescription(const t_material & mat);
private:
class Private;
Private* d;
}; };
} }
#endif #endif

@ -59,9 +59,6 @@ bool Buildings::Read (const uint32_t index, t_building & building)
Core & c = Core::getInstance(); Core & c = Core::getInstance();
df::building *bld_40d = world->buildings.all[index]; 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.x1 = bld_40d->x1;
building.x2 = bld_40d->x2; building.x2 = bld_40d->x2;
building.y1 = bld_40d->y1; 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.z = bld_40d->z;
building.material.index = bld_40d->mat_index; building.material.index = bld_40d->mat_index;
building.material.type = bld_40d->mat_type; 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.custom_type = bld_40d->getCustomType();
building.origin = bld_40d; building.origin = bld_40d;
return true; return true;

@ -481,34 +481,18 @@ Gui::Gui()
d = new Private; d = new Private;
d->owner = c.p; d->owner = c.p;
VersionInfo * mem = c.vinfo; VersionInfo * mem = c.vinfo;
OffsetGroup * OG_Gui = mem->getGroup("GUI");
// Setting up menu state // Setting up menu state
try df_menu_state = (uint32_t *) & df::global::ui->main.mode;
{
df_menu_state = (uint32_t *) OG_Gui->getAddress("current_menu_state");
}
catch(Error::All &)
{
df_menu_state = 0;
};
OffsetGroup * OG_Position; d->window_x_offset = (int32_t *) mem->getAddress ("window_x");
try d->window_y_offset = (int32_t *) mem->getAddress ("window_y");
{ d->window_z_offset = (int32_t *) mem->getAddress ("window_z");
OG_Position = mem->getGroup("Position"); if(d->window_z_offset && d->window_y_offset && d->window_x_offset)
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->Started = true; d->Started = true;
}
catch(Error::All &){}; d->screen_tiles_ptr_offset = (void *) mem->getAddress ("screen_tiles_pointer");
try if(d->screen_tiles_ptr_offset)
{
d->screen_tiles_ptr_offset = (void *) OG_Position->getAddress ("screen_tiles_pointer");
d->StartedScreen = true; d->StartedScreen = true;
}
catch(Error::All &){};
} }
Gui::~Gui() Gui::~Gui()

@ -539,29 +539,13 @@ Module* DFHack::createMaterials()
return new Materials(); return new Materials();
} }
class Materials::Private
{
public:
Process * owner;
OffsetGroup * OG_Materials;
void * vector_races;
void * vector_other;
};
Materials::Materials() 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() Materials::~Materials()
{ {
delete d;
} }
bool Materials::Finish() bool Materials::Finish()
@ -596,7 +580,6 @@ bool t_matglossInorganic::isGem()
bool Materials::CopyInorganicMaterials (std::vector<t_matglossInorganic> & inorganic) bool Materials::CopyInorganicMaterials (std::vector<t_matglossInorganic> & inorganic)
{ {
Process * p = d->owner;
size_t size = world->raws.inorganics.size(); size_t size = world->raws.inorganics.size();
inorganic.clear(); inorganic.clear();
inorganic.reserve (size); inorganic.reserve (size);

@ -36,6 +36,8 @@ using namespace std;
#include "ModuleFactory.h" #include "ModuleFactory.h"
#include "Core.h" #include "Core.h"
#include "modules/Notes.h" #include "modules/Notes.h"
#include <DataDefs.h>
#include "df/ui.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createNotes() Module* DFHack::createNotes()
@ -43,21 +45,8 @@ Module* DFHack::createNotes()
return new Notes(); return new Notes();
} }
// FIXME: not even a wrapper now
Notes::Notes() Notes::Notes()
{ {
Core & c = Core::getInstance(); notes = (std::vector<t_note*>*) &df::global::ui->waypoints.points;
notes = NULL;
VersionInfo * mem = c.vinfo;
try
{
OffsetGroup * OG_Notes = mem->getGroup("Notes");
notes = (std::vector<t_note*>*) OG_Notes->getAddress("vector");
}
catch(DFHack::Error::AllMemdef &e)
{
notes = NULL;
cerr << "Notes not available... " << e.what() << endl;
}
} }

@ -82,29 +82,19 @@ World::World()
d->owner = c.p; d->owner = c.p;
wmap = 0; wmap = 0;
OffsetGroup * OG_Gui = c.vinfo->getGroup("GUI"); d->pause_state_offset = (void *) c.vinfo->getAddress ("pause_state");
try if(d->pause_state_offset)
{
d->pause_state_offset = OG_Gui->getAddress ("pause_state");
d->PauseInited = true; d->PauseInited = true;
}
catch(exception &){};
OffsetGroup * OG_World = c.vinfo->getGroup("World"); d->weather_offset = (char *) c.vinfo->getAddress( "current_weather" );
try if(d->weather_offset)
{ {
d->weather_offset = OG_World->getAddress( "current_weather" );
wmap = (weather_map *) d->weather_offset; wmap = (weather_map *) d->weather_offset;
d->StartedWeather = true; d->StartedWeather = true;
} }
catch(Error::All &){}; d->gamemode_offset = (void *) c.vinfo->getAddress( "game_mode" );
try d->controlmode_offset = (void *) c.vinfo->getAddress( "control_mode" );
{ d->StartedMode = true;
d->gamemode_offset = OG_World->getAddress( "game_mode" );
d->controlmode_offset = OG_World->getAddress( "control_mode" );
d->StartedMode = true;
}
catch(Error::All &){};
d->Inited = true; d->Inited = true;
} }

@ -28,6 +28,7 @@ using df::global::world;
// our own, empty header. // our own, empty header.
#include "dwarfexport.h" #include "dwarfexport.h"
#include <df/personality_facet_type.h>
// Here go all the command declarations... // Here go all the command declarations...
@ -106,18 +107,26 @@ static void printAttributes(Core* c, df::unit* cre, ostream& out) {
out << " </Attributes>" << endl; out << " </Attributes>" << endl;
} }
static void printTraits(Core* c, df::unit* cre, ostream& out) { static void printTraits(Core* c, df::unit* cre, ostream& out)
{
out << " <Traits>" << endl; out << " <Traits>" << endl;
df::unit_soul * s = cre->status.current_soul; df::unit_soul * s = cre->status.current_soul;
if (s) { if (s)
for (int i = 0; i < NUM_CREATURE_TRAITS; i++) { {
out << " <Trait name='" << c->vinfo->getTraitName(i) << FOR_ENUM_ITEMS(personality_facet_type,index)
"' value='" << s->traits[i] << "'>"; {
out << " <Trait name='" << df::enums::personality_facet_type::get_key(index) <<
"' value='" << s->traits[index] << "'>";
//FIXME: needs reimplementing trait string generation
/*
string trait = c->vinfo->getTrait(i, s->traits[i]); string trait = c->vinfo->getTrait(i, s->traits[i]);
if (!trait.empty()) { if (!trait.empty()) {
out << trait.c_str(); out << trait.c_str();
} }
*/
out << "</Trait>" << endl; out << "</Trait>" << endl;
} }
} }
out << " </Traits>" << endl; out << " </Traits>" << endl;