Added missing file, small changes

develop
Petr Mrázek 2010-04-08 02:20:54 +02:00
parent 13571a9bde
commit 659e57e3c4
3 changed files with 147 additions and 35 deletions

@ -31,48 +31,20 @@ distribution.
namespace DFHack namespace DFHack
{ {
template <int SIZE> struct t_matglossPair
struct junk_fill
{
uint8_t data[SIZE];
/*
void Dump()
{
cout<<hex;
for (int i=0;i<SIZE;i++)
cout<<setw(2)<<i<<" ";
cout<<endl;
for (int i=0;i<SIZE;i++)
{
cout<<setw(2)<<(int)data[i]<<" ";
if ((i%32)==32-1)
cout<<endl;
}
cout<<endl;
}
*/
};
/*
struct t_vein
{ {
uint32_t vtable;
int16_t type; int16_t type;
int16_t assignment[16]; int16_t index;
int16_t unknown;
uint32_t flags;
uint32_t address_of; // this is NOT part of the DF vein, but an address of the vein as seen by DFhack.
}; };
*/
// DF effects, by darius from the bay12 forum
struct t_matglossPair template <int SIZE>
struct junk_fill
{ {
int16_t type; uint8_t data[SIZE];
int16_t index;
}; };
// DF effects, by darius from the bay12 forum
enum EFFECT_TYPE enum EFFECT_TYPE
{ {
EFF_MIASMA=0, EFF_MIASMA=0,
@ -88,6 +60,7 @@ enum EFFECT_TYPE
EFF_BOILING, // uses matgloss EFF_BOILING, // uses matgloss
EFF_OCEANWAVE EFF_OCEANWAVE
}; };
struct t_effect_df40d //size 40 struct t_effect_df40d //size 40
{ {
uint16_t type; uint16_t type;

@ -0,0 +1,137 @@
#ifndef DF_MISCUTILS
#define DF_MISCUTILS
#include <iostream>
#include <iomanip>
#include <climits>
#include <integers.h>
#include <vector>
#include <sstream>
#include <ctime>
#include <cstdio>
using namespace std;
void DumpObjStr0Vector (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector vect(p,addr,4);
for(int i = 0; i < vect.getSize();i++)
{
uint32_t addr = *(uint32_t *) vect[i];
cout << p->readSTLString(addr) << endl;
}
cout << endl;
}
void DumpObjVtables (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector vect(p,addr,4);
for(int i = 0; i < vect.getSize();i++)
{
uint32_t addr = *(uint32_t *) vect[i];
uint32_t vptr = p->readDWord(addr);
cout << p->readClassName(vptr) << endl;
}
cout << endl;
}
void DumpDWordVector (const char * name, DFHack::Process *p, uint32_t addr)
{
cout << "----==== " << name << " ====----" << endl;
DFHack::DfVector vect(p,addr,4);
for(int i = 0; i < vect.getSize();i++)
{
uint32_t number = *(uint32_t *) vect[i];
cout << number << endl;
}
cout << endl;
}
/*
address = absolute address of dump start
length = length in lines. 1 line = 16 bytes
*/
void hexdump (DFHack::API& DF, uint32_t address, uint32_t length)
{
char *buf = new char[length * 16];
DF.ReadRaw(address, length * 16, (uint8_t *) buf);
for (int i = 0; i < length; i++)
{
// leading offset
cout << "0x" << hex << setw(8) << address + i*16 << "| ";
// groups
for(int j = 0; j < 4; j++)
{
// bytes
for(int k = 0; k < 4; k++)
{
int idx = i * 16 + j * 4 + k;
cout << hex << setw(2) << int(static_cast<unsigned char>(buf[idx])) << " ";
}
cout << " ";
}
cout << endl;
}
delete buf;
}
void interleave_hex (DFHack::API& DF, vector < uint32_t > & addresses, uint32_t length)
{
vector <char * > bufs;
for(int counter = 0; counter < addresses.size(); counter ++)
{
char * buf = new char[length * 16];
DF.ReadRaw(addresses[counter], length * 16, (uint8_t *) buf);
bufs.push_back(buf);
}
cout << setfill('0');
// output a header
cout << "line offset ";
for (int obj = 0; obj < addresses.size(); obj++)
{
cout << "0x" << hex << setw(9) << addresses[obj] << " ";
}
cout << endl;
for(int offs = 0 ; offs < length * 16; offs += 4)
{
if((!(offs % 16)) && offs != 0)
{
cout << endl;
}
cout << setfill(' ');
cout << dec << setw(4) << offs/4 << " ";
cout << setfill('0');
cout << "0x" << hex << setw(4) << offs << " ";
for (int object = 0; object < bufs.size(); object++)
{
// bytes
for(int k = 0; k < 4; k++)
{
uint8_t data = bufs[object][offs + k];
cout << hex << setw(2) << int(static_cast<unsigned char>(data)) << " ";
}
cout << " ";
}
cout << endl;
}
for(int counter = 0; counter < addresses.size(); counter ++)
{
delete bufs[counter];
}
}
template <typename T>
void print_bits ( T val, std::ostream& out )
{
T n_bits = sizeof ( val ) * CHAR_BIT;
for ( unsigned i = 0; i < n_bits; ++i ) {
out<< !!( val & 1 ) << " ";
val >>= 1;
}
}
#endif

@ -3026,6 +3026,8 @@ map_data_1b60_offset 0x1B9c
<Address name="creature_type_vector">0x016AFE58</Address> <Address name="creature_type_vector">0x016AFE58</Address>
<!--<Address name="mat_creature_types2">0x16AEE08</Address>--> <!--<Address name="mat_creature_types2">0x16AEE08</Address>-->
<!-- this is an array of length 0x
<Address name="array_for_spatters?">0x016b90cc</Address>
Constructions Constructions
============= =============