Spatter veins, spatterdump tool

develop
Petr Mrázek 2010-04-07 22:28:05 +02:00
parent 9589617d98
commit 62fc5bd677
8 changed files with 282 additions and 17 deletions

@ -25,6 +25,18 @@ namespace DFHack
{
uint32_t vtable;
int16_t tiles[16][16];
uint32_t address_of; // this is NOT part of the DF vein, but an address of the vein as seen by DFhack.
};
struct t_spattervein
{
uint32_t vtable;
uint16_t mat1;
uint16_t unk1;
uint32_t mat2;
uint16_t mat3;
uint8_t intensity[16][16];
uint32_t address_of; // this is NOT part of the DF vein, but an address of the vein as seen by DFhack.
};
enum e_traffic
@ -171,15 +183,14 @@ namespace DFHack
typedef int16_t tiletypes40d [16][16];
typedef DFHack::t_designation designations40d [16][16];
typedef DFHack::t_occupancy occupancies40d [16][16];
// typedef DFHack::t_occupancy occupancies40d [16][16];
typedef uint8_t biome_indices40d [16];
typedef struct
{
tiletypes40d tiletypes;
designations40d designation;
occupancies40d occupancy;
// really a '7', but I use 8 to make it neater :)
// occupancies40d occupancy;
biome_indices40d biome_indices;
uint32_t origin; // the address where it came from
t_blockflags blockflags;
@ -265,10 +276,11 @@ namespace DFHack
bool ReadDesignations(uint32_t blockx, uint32_t blocky, uint32_t blockz, designations40d *buffer);
bool WriteDesignations (uint32_t blockx, uint32_t blocky, uint32_t blockz, designations40d *buffer);
/*
/// read/write block occupancies
bool ReadOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, occupancies40d *buffer);
bool WriteOccupancy(uint32_t blockx, uint32_t blocky, uint32_t blockz, occupancies40d *buffer);
*/
/// read/write the block dirty bit - this is used to mark a map block so that DF scans it for designated jobs like digging
bool ReadDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool &dirtybit);
bool WriteDirtyBit(uint32_t blockx, uint32_t blocky, uint32_t blockz, bool dirtybit);
@ -281,7 +293,7 @@ namespace DFHack
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, biome_indices40d *buffer);
/// read aggregated veins of a block
bool ReadVeins(uint32_t blockx, uint32_t blocky, uint32_t blockz, std::vector <t_vein> & veins, std::vector <t_frozenliquidvein>& ices);
bool ReadVeins(uint32_t blockx, uint32_t blocky, uint32_t blockz, std::vector <t_vein> & veins, std::vector <t_frozenliquidvein>& ices, std::vector <t_spattervein>& splatter);
private:
struct Private;

@ -325,7 +325,7 @@ bool Maps::ReadRegionOffsets (uint32_t x, uint32_t y, uint32_t z, biome_indices4
// veins of a block, expects empty vein vectors
bool Maps::ReadVeins(uint32_t x, uint32_t y, uint32_t z, vector <t_vein> & veins, vector <t_frozenliquidvein>& ices)
bool Maps::ReadVeins(uint32_t x, uint32_t y, uint32_t z, vector <t_vein> & veins, vector <t_frozenliquidvein>& ices, vector <t_spattervein> &splatter)
{
uint32_t addr = d->block[x*d->y_block_count*d->z_block_count + y*d->z_block_count + z];
veins.clear();
@ -344,6 +344,7 @@ bool Maps::ReadVeins(uint32_t x, uint32_t y, uint32_t z, vector <t_vein> & veins
{
t_vein v;
t_frozenliquidvein fv;
t_spattervein sv;
// read the vein pointer from the vector
uint32_t temp = * (uint32_t *) p_veins[i];
@ -361,9 +362,18 @@ try_again:
{
// read the ice vein data (dereference pointer)
g_pProcess->read (temp, sizeof(t_frozenliquidvein), (uint8_t *) &fv);
fv.address_of = temp;
// store it in the vector
ices.push_back (fv);
}
else if(type == off.vein_spatter_vptr)
{
// read the splatter vein data (dereference pointer)
g_pProcess->read (temp, sizeof(t_spattervein), (uint8_t *) &sv);
sv.address_of = temp;
// store it in the vector
splatter.push_back (sv);
}
else if(g_pProcess->readClassName(type) == "block_square_event_frozen_liquid")
{
off.vein_ice_vptr = type;
@ -374,6 +384,11 @@ try_again:
off.vein_mineral_vptr = type;
goto try_again;
}
else if(g_pProcess->readClassName(type) == "block_square_event_material_spatter")
{
off.vein_spatter_vptr = type;
goto try_again;
}
}
return true;
}

@ -61,6 +61,10 @@ TARGET_LINK_LIBRARIES(dfvecc dfhack)
ADD_EXECUTABLE(dftreedump treedump.cpp)
TARGET_LINK_LIBRARIES(dftreedump dfhack)
# spatterdump - dump spatter 'veins'
ADD_EXECUTABLE(dfspatterdump spatterdump.cpp)
TARGET_LINK_LIBRARIES(dfspatterdump dfhack)
# catsplosion - Makes every cat pregnant, and almost due...
# Author: Zhentar
# ADD_EXECUTABLE(dfcatsplosion catsplosion.cpp)

@ -0,0 +1,141 @@
// Just show some position data
#include <iostream>
#include <iomanip>
#include <climits>
#include <integers.h>
#include <vector>
#include <sstream>
#include <ctime>
#include <cstdio>
using namespace std;
#include <DFTypes.h>
#include <DFHackAPI.h>
#include <DFProcess.h>
#include <DFMemInfo.h>
#include <DFVector.h>
#include <DFTypes.h>
#include <modules/Vegetation.h>
#include <modules/Materials.h>
#include <modules/Position.h>
#include <modules/Maps.h>
#include "miscutils.h"
using namespace DFHack;
char shades[10] = {'#','$','O','=','+','|','-','^','.',' '};
int main (int numargs, const char ** args)
{
uint32_t addr;
uint32_t x_max,y_max,z_max;
vector<t_vein> veinVector;
vector<t_frozenliquidvein> IceVeinVector;
vector<t_spattervein> splatter;
DFHack::API DF("Memory.xml");
try
{
DF.Attach();
}
catch (exception& e)
{
cerr << e.what() << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
DFHack::Maps *Maps =DF.getMaps();
DFHack::Position *Pos =DF.getPosition();
// init the map
if(!Maps->Start())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
Pos->getCursorCoords(cx,cy,cz);
if(cx == -30000)
{
// walk the map
for(uint32_t x = 0; x< x_max;x++) for(uint32_t y = 0; y< y_max;y++) for(uint32_t z = 0; z< z_max;z++)
{
if(Maps->isValidBlock(x,y,z))
{
// look for splater veins
Maps->ReadVeins(x,y,z,veinVector,IceVeinVector,splatter);
if(splatter.size())
{
printf("Block %d/%d/%d\n",x,y,z);
for(int i = 0; i < splatter.size(); i++)
{
printf("Splatter %d\nmat1: %d\nunknown: %d\nmat2: %d\nmat3: %d\n",i,splatter[i].mat1,splatter[i].unk1,splatter[i].mat2,splatter[i].mat3);
for(uint32_t yyy = 0; yyy < 16; yyy++)
{
cout << "|";
for(uint32_t xxx = 0; xxx < 16; xxx++)
{
uint8_t intensity = splatter[i].intensity[xxx][yyy];
cout << shades[9 - (intensity / 28)];
}
cout << "|" << endl;
}
hexdump(DF, splatter[i].address_of,20);
cout << endl;
}
}
}
}
}
else
{
uint32_t bx,by,bz;
bx = cx / 16;
by = cy / 16;
bz = cz;
// look for splater veins
Maps->ReadVeins(bx,by,bz,veinVector,IceVeinVector,splatter);
if(splatter.size())
{
printf("Block %d/%d/%d\n",bx,by,bz);
for(int i = 0; i < splatter.size(); i++)
{
printf("Splatter %d\nmat1: %d\nunknown: %d\nmat2: %d\nmat3: %d\n",i,splatter[i].mat1,splatter[i].unk1,splatter[i].mat2,splatter[i].mat3);
for(uint32_t y = 0; y < 16; y++)
{
cout << "|";
for(uint32_t x = 0; x < 16; x++)
{
uint8_t intensity = splatter[i].intensity[x][y];
if(intensity)
{
cout << "#";
}
else
{
cout << " ";
}
}
cout << "|" << endl;
}
hexdump(DF, splatter[i].address_of,20);
cout << endl;
}
}
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();
#endif
return 0;
}

@ -19,16 +19,20 @@ using namespace std;
#include <modules/Vegetation.h>
#include <modules/Materials.h>
#include <modules/Position.h>
#include <modules/Maps.h>
#include "miscutils.h"
using namespace DFHack;
char shades[10] = {'#','$','O','=','+','|','-','^','.',' '};
int main (int numargs, const char ** args)
{
uint32_t addr;
if (numargs == 2)
{
istringstream input (args[1],istringstream::in);
input >> std::hex >> addr;
}
uint32_t x_max,y_max,z_max;
vector<t_vein> veinVector;
vector<t_frozenliquidvein> IceVeinVector;
vector<t_spattervein> splatter;
DFHack::API DF("Memory.xml");
try
{
@ -42,7 +46,93 @@ int main (int numargs, const char ** args)
#endif
return 1;
}
DFHack::Maps *Maps =DF.getMaps();
DFHack::Position *Pos =DF.getPosition();
// init the map
if(!Maps->Start())
{
cerr << "Can't init map." << endl;
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
Pos->getCursorCoords(cx,cy,cz);
if(cx == -30000)
{
// walk the map
for(uint32_t x = 0; x< x_max;x++) for(uint32_t y = 0; y< y_max;y++) for(uint32_t z = 0; z< z_max;z++)
{
if(Maps->isValidBlock(x,y,z))
{
// look for splater veins
Maps->ReadVeins(x,y,z,veinVector,IceVeinVector,splatter);
if(splatter.size())
{
printf("Block %d/%d/%d\n",x,y,z);
for(int i = 0; i < splatter.size(); i++)
{
printf("Splatter %d\nmat1: %d\nunknown: %d\nmat2: %d\nmat3: %d\n",i,splatter[i].mat1,splatter[i].unk1,splatter[i].mat2,splatter[i].mat3);
for(uint32_t yyy = 0; yyy < 16; yyy++)
{
cout << "|";
for(uint32_t xxx = 0; xxx < 16; xxx++)
{
uint8_t intensity = splatter[i].intensity[xxx][yyy];
cout << shades[9 - (intensity / 28)];
}
cout << "|" << endl;
}
hexdump(DF, splatter[i].address_of,20);
cout << endl;
}
}
}
}
}
else
{
uint32_t bx,by,bz;
bx = cx / 16;
by = cy / 16;
bz = cz;
// look for splater veins
Maps->ReadVeins(bx,by,bz,veinVector,IceVeinVector,splatter);
if(splatter.size())
{
printf("Block %d/%d/%d\n",bx,by,bz);
for(int i = 0; i < splatter.size(); i++)
{
printf("Splatter %d\nmat1: %d\nunknown: %d\nmat2: %d\nmat3: %d\n",i,splatter[i].mat1,splatter[i].unk1,splatter[i].mat2,splatter[i].mat3);
for(uint32_t y = 0; y < 16; y++)
{
cout << "|";
for(uint32_t x = 0; x < 16; x++)
{
uint8_t intensity = splatter[i].intensity[x][y];
if(intensity)
{
cout << "#";
}
else
{
cout << " ";
}
}
cout << "|" << endl;
}
hexdump(DF, splatter[i].address_of,20);
cout << endl;
}
}
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();

@ -311,6 +311,7 @@ main(int argc, char *argv[])
vector< vector <uint16_t> > layerassign;
vector<t_vein> veinVector;
vector<t_frozenliquidvein> IceVeinVector;
vector<t_spattervein> splatter;
DFHack::Materials * Mats = 0;
DFHack::Maps * Maps = 0;
@ -444,6 +445,7 @@ main(int argc, char *argv[])
veinVector.clear();
IceVeinVector.clear();
effects.clear();
splatter.clear();
dirtybit = 0;
// Supend, read/write data
@ -473,7 +475,7 @@ main(int argc, char *argv[])
if(i == 0 && j == 0)
{
// read veins
Maps->ReadVeins(cursorX+i,cursorY+j,cursorZ,veinVector,IceVeinVector);
Maps->ReadVeins(cursorX+i,cursorY+j,cursorZ,veinVector,IceVeinVector,splatter);
// get pointer to block
blockaddr = Maps->getBlockPtr(cursorX+i,cursorY+j,cursorZ);

@ -1358,15 +1358,15 @@
<Profession can_assign_labors="true" is_military="false" name="SIEGE_OPERATOR">55</Profession>
<Profession can_assign_labors="true" is_military="false" name="PUMP_OPERATOR">56</Profession>
<Profession can_assign_labors="true" is_military="false" name="CLERK">57</Profession>
<Profession can_assign_labors="true" is_military="false" name="ADMINISTRATOR">58</Profession>
<Profession can_assign_labors="true" is_military="false" name="TRADER">59</Profession>
<Profession can_assign_labors="true" is_military="false" name="ARCHITECT">60</Profession>
<Profession can_assign_labors="true" is_military="false" name="ALCHEMIST">61</Profession>
<Profession can_assign_labors="true" is_military="false" name="DOCTOR">62</Profession>
<Profession can_assign_labors="true" is_military="false" name="DIAGNOSER">63</Profession>
<Profession can_assign_labors="true" is_military="false" name="BONE_SETTER">64</Profession>
<Profession can_assign_labors="true" is_military="false" name="SUTURER">65</Profession>
<Profession can_assign_labors="true" is_military="false" name="SURGEON">66</Profession>
<Profession can_assign_labors="true" is_military="false" name="ADMINISTRATOR">58</Profession>
<Profession can_assign_labors="true" is_military="false" name="TRADER">59</Profession>
<Profession can_assign_labors="true" is_military="false" name="ALCHEMIST">61</Profession>
<Profession can_assign_labors="true" is_military="false" name="MERCHANT">67</Profession>
<Profession can_assign_labors="true" is_military="true" name="HAMMERMAN">68</Profession>
<Profession can_assign_labors="true" is_military="true" name="MASTER_HAMMERMAN">69</Profession>

@ -110,6 +110,7 @@ int main (int argc, const char* argv[])
int16_t tempvein [16][16];
vector <DFHack::t_vein> veins;
vector <DFHack::t_frozenliquidvein> iceveins;
vector <DFHack::t_spattervein> splatter;
uint32_t maximum_regionoffset = 0;
uint32_t num_overflows = 0;
// walk the map!
@ -128,7 +129,7 @@ int main (int argc, const char* argv[])
memset(tempvein, -1, sizeof(tempvein));
veins.clear();
Maps->ReadVeins(x,y,z,veins,iceveins);
Maps->ReadVeins(x,y,z,veins,iceveins,splatter);
if(showbaselayers)
{