Merge branch 'master' of git://github.com/peterix/dfhack

develop
Simon Jackson 2010-06-23 03:41:48 +01:00
commit f21bd7b04e
6 changed files with 101 additions and 11 deletions

@ -6,6 +6,7 @@ Dependencies
You'll need cmake and 'a' compiler for building the main lib and the various tools.
(Linux only) Veinlook requires the wide-character ncurses library (libncursesw)
(Linux only) You'll need X11 dev libraries.
Building on Linux:
--------------------

@ -33,11 +33,12 @@ OSX is also not supported due to lack of developers with a Mac.
Currently supported Dwarf Fortress versions:
* Windows
0.31.01 - 0.31.03 legacy
0.31.04 - 0.31.06 SDL
0.31.04 - 0.31.08 SDL
* Linux
0.31.04 - 0.31.06 native. There are missing offsets but Map tools should be OK.
All Windows versions through wine.
0.31.04 - 0.31.08 native.
There are missing offsets but Map tools should be OK. Linux support is a bit lacking, I'm working on it.
All supported Windows versions running in wine can be used with DFHack.
Using the library as a developer
--------------------------------

@ -1818,10 +1818,17 @@ map_data_1b60_offset 0x1B9c
Creature type offsets
=====================
<Offset name="creature_type_caste_vector">0x60</Offset> VERIFIED
<Offset name="creature_type_extract_vector">0x1A14</Offset>
<Offset name="creature_tile">0xE0</Offset>
<Offset name="creature_tile_color">0xF6</Offset>
from 0.31.08
Toad: 0xaf75b68
Toad: rawname = 0x0
Toad: character (not reliable) = 0x20
Toad: caste vector = 0x60
Toad: extract? vector = 0x18f4
Toad: colors = 0x36
<Offset name="creature_type_extract_vector">0x18f4</Offset> VERIFIED
<Offset name="creature_tile">0x20</Offset> VERIFIED
<Offset name="creature_tile_color">0x36</Offset> LOOKS OK
<!--
<Offset name="creature_type_caste_vector">0x138</Offset>
<Offset name="creature_type_extract_vector">0x1A14</Offset>
@ -2173,6 +2180,12 @@ map_data_1b60_offset 0x1B9c
0x92d79e0 = real one? seems like it
0x92d7a10
</Entry>
<Entry version="v0.31.07" os="linux" id="30_07lin" base="30_06lin" rebase="0x2000">
<String name="md5">b31979551782e89c049b11db8d2d86d7</String>
</Entry>
<Entry version="v0.31.08" os="linux" id="30_08lin" base="30_07lin">
<String name="md5">e37750890350d7b9d8203879aff8fa5c</String>
</Entry>
</MemoryDescriptors>
</DFExtractor>

@ -292,9 +292,9 @@ struct Bytestream
void * object;
};
bool findBytestream (SegmentedFinder* s, uint32_t *addr, Bytestream * compare )
bool findBytestream (SegmentedFinder* s, void *addr, Bytestream compare )
{
if(memcmp(addr, compare->object, compare->length) == 0)
if(memcmp(addr, compare.object, compare.length) == 0)
return true;
return false;
}

@ -553,6 +553,15 @@ void printFoundStrVec(vector <uint64_t> &found, const char * what, SegmentedFind
}
}
// meh
#pragma pack(1)
struct tilecolors
{
uint16_t fore;
uint16_t back;
uint16_t bright;
};
#pragma pack()
void automatedLangtables(DFHack::Context * DF, vector <DFHack::t_memrange>& ranges)
{
@ -698,6 +707,7 @@ void automatedLangtables(DFHack::Context * DF, vector <DFHack::t_memrange>& rang
vecTriplet *vtCretypes = sf.Translate<vecTriplet>(to_use);
uint32_t elephant = sf.Read<uint32_t>(vtCretypes->start);
uint64_t Eoffset;
cout << "Elephant: 0x" << hex << elephant << endl;
cout << "Elephant: rawname = 0x0" << endl;
Eoffset = sf.FindInRange<uint8_t,uint8_t> ('E',equalityP<uint8_t>, elephant, 0x300 );
if(Eoffset)
@ -709,12 +719,51 @@ void automatedLangtables(DFHack::Context * DF, vector <DFHack::t_memrange>& rang
{
cout << "Elephant: caste vector = 0x" << hex << Eoffset - elephant << endl;
}
Eoffset = sf.FindInRange<const char *,vecTriplet> ("SKIN",vectorStringFirst, elephant, 0x2000 );
if(Eoffset)
{
cout << "Elephant: extract? vector = 0x" << hex << Eoffset - elephant << endl;
}
tilecolors eletc = {7,0,0};
Bytestream bs_eletc = {sizeof(tilecolors), &eletc};
Eoffset = sf.FindInRange<Bytestream,tilecolors> (bs_eletc, findBytestream, elephant, 0x300 );
if(Eoffset)
{
cout << "Elephant: colors = 0x" << hex << Eoffset - elephant << endl;
}
//cout << "Amber color:" << hex << "0x" << colorObj << endl;
// TODO: find string 'amber', the floats
}
if(!toad_first.empty())
{
to_use = toad_first[0];
vecTriplet *vtCretypes = sf.Translate<vecTriplet>(to_use);
uint32_t toad = sf.Read<uint32_t>(vtCretypes->start);
uint64_t Eoffset;
cout << "Toad: 0x" << hex << toad << endl;
cout << "Toad: rawname = 0x0" << endl;
Eoffset = sf.FindInRange<uint8_t,uint8_t> (0xF9,equalityP<uint8_t>, toad, 0x300 );
if(Eoffset)
{
cout << "Toad: character (not reliable) = 0x" << hex << Eoffset - toad << endl;
}
Eoffset = sf.FindInRange<const char *,vecTriplet> ("FEMALE",vectorStringFirst, toad, 0x300 );
if(Eoffset)
{
cout << "Toad: caste vector = 0x" << hex << Eoffset - toad << endl;
}
Eoffset = sf.FindInRange<const char *,vecTriplet> ("SKIN",vectorStringFirst, toad, 0x2000 );
if(Eoffset)
{
cout << "Toad: extract? vector = 0x" << hex << Eoffset - toad << endl;
}
tilecolors toadtc = {2,0,0};
Bytestream bs_toadc = {sizeof(tilecolors), &toadtc};
Eoffset = sf.FindInRange<Bytestream,tilecolors> (bs_toadc, findBytestream, toad, 0x300 );
if(Eoffset)
{
cout << "Toad: colors = 0x" << hex << Eoffset - toad << endl;
}
}
if(to_use)
{

@ -13,11 +13,32 @@
#include <vector>
#include <map>
#include <stdio.h>
#include <algorithm>
using namespace std;
#include <DFHack.h>
#include <dfhack/DFTileTypes.h>
template<template <typename> class P = std::less >
struct compare_pair_first
{
template<class T1, class T2>
bool operator()(const std::pair<T1, T2>& left, const std::pair<T1, T2>& right)
{
return P<T1>()(left.first, right.first);
}
};
template<template <typename> class P = std::less >
struct compare_pair_second
{
template<class T1, class T2>
bool operator()(const std::pair<T1, T2>& left, const std::pair<T1, T2>& right)
{
return P<T2>()(left.second, right.second);
}
};
int main (int argc, const char* argv[])
{
@ -276,7 +297,7 @@ int main (int argc, const char* argv[])
cout << "Number of overflows: " << num_overflows;
}
cout << endl;
vector <pair <int16_t, uint32_t> > matss;
map<int16_t, uint32_t>::iterator p;
for(p = materials.begin(); p != materials.end(); p++)
{
@ -286,9 +307,14 @@ int main (int argc, const char* argv[])
}
else
{
cout << Mats->inorganic[p->first].id << " : " << p->second << endl;
matss.push_back( pair<int16_t,uint32_t>(p->first, p->second) );
}
}
std::sort(matss.begin(), matss.end(), compare_pair_second<>());
for(int i = 0; i < matss.size();i++)
{
cout << Mats->inorganic[matss[i].first].id << " : " << matss[i].second << endl;
}
DF->Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;