Vegetation vector for 31.19

develop
Petr Mrázek 2011-02-21 03:39:29 +01:00
parent 9f5ee8a790
commit 710b50eb1f
4 changed files with 152 additions and 77 deletions

@ -1944,6 +1944,9 @@
<Group name="GUI" valid="false">
<Address name="pause_state" value="0x14c9be1" valid="true" />
</Group>
<Group name="Vegetation" valid="true">
<Address name="vector" value="0x16db478" />
</Group>
<!--
<Address name="WORLD" valid="false" />
<Group name="Buildings">
@ -1977,10 +1980,6 @@
<Address name="language_vector" value="0x016e553c"/>
<Address name="translation_vector" value="0x016e551c"/>
</Group>
<Group name="Vegetation" valid="false">
<Address name="vector"/>
<Offset name="tree_desc_offset" valid="true"/>
</Group>
<Group name="Items" valid="false">
<Address name="items_vector" />
List of offsets in the VTable :

@ -386,14 +386,15 @@ public:
return false;
}
}
bool insert( char what )
template < class T >
bool insert( T what )
{
if(constant)
return false;
if(d->length+1 == d->allocated)
Allocate(d->allocated * 2);
((char *) d->object)[d->length] = what;
d->length ++;
if(d->length+sizeof(T) >= d->allocated)
Allocate((d->length+sizeof(T)) * 2);
(*(T *)(d->object + d->length)) = what;
d->length += sizeof(T);
}
Bytestreamdata * d;
bool constant;

@ -179,10 +179,14 @@ bool Incremental ( vector <uint64_t> &found, const char * what, T& output,
}
goto incremental_more;
}
else if(select.empty())
else if(select == "q")
{
return false;
}
else if(select.empty())
{
goto incremental_more;
}
else
{
if(numberz)
@ -399,29 +403,91 @@ void FindData(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& range
DF->Detach();
}
}
/*
while(Incremental(found, "integer",test1))
bool TriggerIncremental ( vector <uint64_t> &found )
{
string select;
if(found.empty())
{
cout << "search ready - position the DF cursor and hit enter when ready" << endl;
}
else if( found.size() == 1 )
{
cout << "Found single coord!" << endl;
cout << hex << "0x" << found[0] << endl;
}
else
{
cout << "Found " << dec << found.size() << " coords." << endl;
}
incremental_more:
cout << ">>";
std::getline(cin, select);
size_t num = 0;
if( sscanf(select.c_str(),"p %d", &num) && num > 0)
{
cout << "Found coords:" << endl;
for(int i = 0; i < min(found.size(), num);i++)
{
cout << hex << "0x" << found[i] << endl;
}
goto incremental_more;
}
else if(select == "p")
{
cout << "Found coords:" << endl;
for(int i = 0; i < found.size();i++)
{
cout << hex << "0x" << found[i] << endl;
}
goto incremental_more;
}
else if(select == "q")
{
return false;
}
else return true;
}
void FindCoords(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
vector <uint64_t> found;
int size = 4;
do
{
getNumber("Select coord size (2,4 bytes)",size, 4);
} while (size != 2 && size != 4);
while (TriggerIncremental(found))
{
DFMgr.Refresh();
DFHack::Context * DF = DFMgr.getSingleContext();
DF->Attach();
SegmentedFinder sf(ranges,DF);
switch(size)
DFHack::Position * pos = DF->getPosition();
pos->Start();
int32_t x, y, z;
pos->getCursorCoords(x,y,z);
cout << "Searching for: " << dec << x << ":" << y << ":" << z << endl;
Bytestream select;
if(size == 2)
{
case 1:
sf.Incremental<uint8_t,uint8_t>(test1,alignment,found, equalityP<uint8_t>);
break;
case 2:
sf.Incremental<uint16_t,uint16_t>(test1,alignment,found, equalityP<uint16_t>);
break;
case 4:
sf.Incremental<uint32_t,uint32_t>(test1,alignment,found, equalityP<uint32_t>);
break;
select.insert<uint16_t>(x);
select.insert<uint16_t>(y);
select.insert<uint16_t>(z);
}
else
{
select.insert<uint32_t>(x);
select.insert<uint32_t>(y);
select.insert<uint32_t>(z);
}
cout << select << endl;
SegmentedFinder sf(ranges,DF);
sf.Incremental< Bytestream ,uint32_t>(select,1,found, findBytestream);
DF->Detach();
}
}
*/
void PtrTrace(DFHack::ContextManager & DFMgr, vector <DFHack::t_memrange>& ranges)
{
int element_size;
@ -841,12 +907,12 @@ int main (void)
"Select search type: 1=number(default), 2=vector by length, 3=vector>object>string,\n"
" 4=string, 5=automated offset search, 6=vector by address in its array,\n"
" 7=pointer vector by address of an object, 8=vector>first object>string\n"
" 9=string buffers, 10=known data, 11=backpointers, 12=data+backpointers\n";
" 9=string buffers, 10=known data, 11=backpointers, 12=data+backpointers\n"
" 13=coord lookup\n";
int mode;
do
{
getNumber(prompt,mode, 1, false);
} while (mode < 1 || mode > 12 );
switch (mode)
{
case 1:
@ -896,9 +962,14 @@ int main (void)
DF->Detach();
DataPtrTrace(DFMgr, selected_ranges);
break;
case 13:
DF->Detach();
FindCoords(DFMgr, selected_ranges);
break;
default:
cout << "not implemented :(" << endl;
}
} while (mode < 1 || mode > 12 );
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -13,6 +13,8 @@ using namespace std;
#include <argstream.h>
#define MAX_DIM 0x300
//TODO: turn into the official coord class for DFHack/DF
class Vertex
{
public:
@ -25,8 +27,10 @@ class Vertex
{
return (other.x == x && other.y == y && other.z == z);
}
// FIXME: <tomprince> peterix_: you could probably get away with not defining operator< if you defined a std::less specialization for Vertex.
bool operator<(const Vertex &other) const
{
// FIXME: could be changed to eliminate MAX_DIM and make std::map lookups faster?
return ( (z*MAX_DIM*MAX_DIM + y*MAX_DIM + x) < (other.z*MAX_DIM*MAX_DIM + other.y*MAX_DIM + other.x));
}
Vertex operator/(int number) const