dftry pseudo-tool, dfhack can recognize 40d again, but the old API class isn't there at all. bees and wax.

develop
Petr Mrázek 2011-04-07 11:21:38 +02:00
parent de9400d5e8
commit 4a83f07bdd
5 changed files with 209 additions and 1 deletions

@ -1,5 +1,68 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<DFHack> <DFHack>
<Base name="DF40d.xx">
<Offsets>
<Group name="vector" description="An STL vector.">
<HexValue name="sizeof" description="The total size in bytes." />
<Offset name="start" description="The offset where the actual start/end/alloc_end triplet is." />
</Group>
<Group name="string" description="An STL string.">
<HexValue name="sizeof" description="The total size in bytes." />
<Group name="MSVC">
<!--
MSVC++ 9 string
void * allocator
union
{
char[16] start;
char * start_ptr
}
Uint32 length
Uint32 capacity
-->
<Offset name="buffer" description="Where the buffer/pointer starts." />
<Offset name="size" description="Where the number of leters is stored (string length without 0-terminator)." />
<Offset name="capacity" description="Capacity of the buffer in letters (default=15)." />
</Group>
</Group>
<Group name="name" description="A structure used for names all over the place.">
<Offset name="first" description="Lowercase stl string with the first name. For ex. 'urist'" />
<Offset name="nick" description="Stl string with the nickname. Set by the player." />
<Offset name="second_words" description="Array of 7 indexes into the language vectors."/>
</Group>
</Offsets>
</Base>
<Version name="40d" base="DF40d.xx" os="windows">
<MD5 value="2c686c26307dcccd7c36cc79737ebe4f" />
<PETimeStamp value="0x48C330DF" />
<Offsets>
<Group name="vector">
<HexValue name="sizeof" value="0x10" />
<Offset name="start" value="0x4" />
<!--
Maybe (fits offsets):
Vector layout in MSVC 8:
DWORD Allocator?
DWORD Start
DWORD End
DWORD AllocationEnd
-->
</Group>
<Group name="string">
<HexValue name="sizeof" value="0x1C" />
<Group name="MSVC">
<Offset name="buffer" value="0x4" />
<Offset name="size" value="0x14" />
<Offset name="capacity" value="0x18" />
</Group>
</Group>
<Group name="name">
<Offset name="first" value="0x0" />
<Offset name="nick" value="0x1C" />
<Offset name="second_words" value="0x38" />
</Group>
</Offsets>
</Version>
<Base name="DF2010"> <Base name="DF2010">
<Traits> <Traits>
<Trait name="Nervousness" id="0" level_5="Is a nervous wreck" level_4="Is always tense and jittery" level_3="Is often nervous" level_2="Has a calm demeanor" level_1="Has a very calm demeanor" level_0="Has an incredibly calm demeanor" /> <Trait name="Nervousness" id="0" level_5="Is a nervous wreck" level_4="Is always tense and jittery" level_3="Is often nervous" level_2="Has a calm demeanor" level_1="Has a very calm demeanor" level_0="Has an incredibly calm demeanor" />
@ -146,6 +209,8 @@
<Profession name="Potter" id="101" military="false" can_assign_labors="true" /> <Profession name="Potter" id="101" military="false" can_assign_labors="true" />
<Profession name="Glazer" id="102" military="false" can_assign_labors="true" /> <Profession name="Glazer" id="102" military="false" can_assign_labors="true" />
<Profession name="Presser" id="103" military="false" can_assign_labors="true" /> <Profession name="Presser" id="103" military="false" can_assign_labors="true" />
<Profession name="BEE_KEEPER" id="104" military="false" can_assign_labors="true" />
<Profession name="WAX_WORKER" id="105" military="false" can_assign_labors="true" />
</Professions> </Professions>
<Jobs> <Jobs>
<Job id="0" name = "Carve Fortification" /> <Job id="0" name = "Carve Fortification" />
@ -487,6 +552,7 @@
<Skill name="Glazing" id="112" /> <Skill name="Glazing" id="112" />
<Skill name="Press Operation" id="113" /> <Skill name="Press Operation" id="113" />
<Skill name="Bee Keeping" id="114" /> <Skill name="Bee Keeping" id="114" />
<Skill name="Wax Working" id="115" />
</Skills> </Skills>
<Levels> <Levels>
<Level id="0" name="Dabbling" xpNxtLvl="500"/> <Level id="0" name="Dabbling" xpNxtLvl="500"/>

@ -132,6 +132,9 @@ Can be used to determine tile properties like temperature.
dfprospector dfprospector
============ ============
Lists all available minerals on the map and how much of them there is. Lists all available minerals on the map and how much of them there is.
It has two parameters:
-a processes all tiles, even hidden ones.
-b includes layer rocks into the count.
dfreveal dfreveal
======== ========

@ -471,7 +471,10 @@ You just lost a fortress and gained an adventurer.</p>
</div> </div>
<div class="section" id="dfprospector"> <div class="section" id="dfprospector">
<h2><a class="toc-backref" href="#id22">dfprospector</a></h2> <h2><a class="toc-backref" href="#id22">dfprospector</a></h2>
<p>Lists all available minerals on the map and how much of them there is.</p> <p>Lists all available minerals on the map and how much of them there is.
It has two parameters:
-a processes all tiles, even hidden ones.
-b includes layer rocks into the count.</p>
</div> </div>
<div class="section" id="dfreveal"> <div class="section" id="dfreveal">
<h2><a class="toc-backref" href="#id23">dfreveal</a></h2> <h2><a class="toc-backref" href="#id23">dfreveal</a></h2>

@ -47,6 +47,9 @@ DFHACK_TOOL(dfdigger2 digger2.cpp)
# Author: belal # Author: belal
DFHACK_TOOL(dffindnameindexes findnameindexes.cpp) DFHACK_TOOL(dffindnameindexes findnameindexes.cpp)
# try things
DFHACK_TOOL(dftry dftry.cpp)
# renamer - change the custom names and professions of creatures, sends keys to # renamer - change the custom names and professions of creatures, sends keys to
# df directly # df directly
# Author: belal # Author: belal

@ -0,0 +1,133 @@
#include <iostream>
#include <fstream>
#include <strstream>
#include <DFHack.h>
using namespace std;
bool getNumber (string prompt, int & output, int def, bool pdef = true)
{
cout << prompt;
if(pdef)
cout << ", default=" << def << endl;
while (1)
{
string select;
cout << ">>";
std::getline(cin, select);
if(select.empty())
{
output = def;
break;
}
else if( sscanf(select.c_str(), "%d", &output) == 1 )
{
break;
}
else
{
continue;
}
}
return true;
}
bool splitvector(const vector<uint64_t> & in, vector<uint64_t> & out1, vector<uint64_t> & out2)
{
size_t length = in.size();
if(length > 1)
{
size_t split = length / 2;
out1.clear();
out2.clear();
out1.insert(out1.begin(),in.begin(),in.begin() + split);
out2.insert(out2.begin(),in.begin() + split,in.end());
return true;
}
return false;
}
void printvector (const vector<uint64_t> &in)
{
cout << "[" << endl;
for(int i = 0; i < in.size(); i++)
{
cout << hex << in[i] << endl;
}
cout << "]" << endl;
}
bool tryvals (DFHack::Context * DF, const vector<uint64_t> &in, uint8_t current, uint8_t testing)
{
DF->Suspend();
DFHack::Process * p = DF->getProcess();
for(int i = 0; i < in.size(); i++)
{
p->writeByte(in[i],testing);
}
DF->Resume();
int result;
while (!getNumber("Is the change good? 0 for no, positive for yes.",result,0));
DF->Suspend();
for(int i = 0; i < in.size(); i++)
{
p->writeByte(in[i],current);
}
DF->Resume();
if(result)
return true;
return false;
}
bool dotry (DFHack::Context * DF, const vector<uint64_t> &in, uint8_t current, uint8_t testing)
{
vector <uint64_t> a, b;
bool found = false;
if(!tryvals(DF,in,current,testing))
return false;
if(splitvector(in, a,b))
{
if(dotry(DF, a, current, testing))
return true;
if(dotry(DF, b, current, testing))
return true;
return false;
}
return false;
}
int main()
{
vector <uint64_t> addresses;
vector <uint64_t> a1;
vector <uint64_t> a2;
vector <uint8_t> values;
string line;
DFHack::ContextManager CM("Memory.xml");
DFHack::Context * DF = CM.getSingleContext();
if(!DF)
return 1;
DF->Resume();
ifstream fin("siege.txt");
if(!fin.is_open())
return 1;
do
{
getline(fin,line);
stringstream input (line);
input << hex;
uint64_t value;
input >> value;
if(value)
{
cout << hex << value << endl;
addresses.push_back(value);
}
} while (!fin.eof());
int val_current,val_testing;
while (!getNumber("Insert current value",val_current,1));
while (!getNumber("Insert testing value",val_testing,0));
dotry(DF, addresses,val_current,val_testing);
return 0;
}