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

@ -72,7 +72,6 @@ DataStaticsCtor.cpp
MiscUtils.cpp
PluginManager.cpp
TileTypes.cpp
VersionInfo.cpp
VersionInfoFactory.cpp
Virtual.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);

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

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

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

@ -31,6 +31,7 @@ distribution.
#include <map>
#include <sys/types.h>
#include <vector>
#include <algorithm>
namespace DFHack
{
@ -49,7 +50,7 @@ namespace DFHack
private:
std::vector <std::string> md5_list;
std::vector <uint32_t> PE_list;
map <std::string, uint32_t> Addresses;
std::map <std::string, uint32_t> 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 <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())
return 0;
return *i.second;
return (*i).second;
}
void setOS(const OSType os)

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

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

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

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

@ -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<t_matglossInorganic> & inorganic)
{
Process * p = d->owner;
size_t size = world->raws.inorganics.size();
inorganic.clear();
inorganic.reserve (size);

@ -36,6 +36,8 @@ using namespace std;
#include "ModuleFactory.h"
#include "Core.h"
#include "modules/Notes.h"
#include <DataDefs.h>
#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<t_note*>*) OG_Notes->getAddress("vector");
}
catch(DFHack::Error::AllMemdef &e)
{
notes = NULL;
cerr << "Notes not available... " << e.what() << endl;
}
notes = (std::vector<t_note*>*) &df::global::ui->waypoints.points;
}

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

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