Cleanmap filters on matter state. Anything non-solid is removed (including mud and water). Solid mud and snow stay.

develop
Petr Mrázek 2011-05-26 02:14:42 +02:00
parent 6d32802dd4
commit 0661248d1f
2 changed files with 31 additions and 3 deletions

@ -134,7 +134,7 @@ namespace DFHack
int16_t assignment[16];
uint32_t flags;
/// this is NOT part of the DF vein, but an address of the vein as seen by DFhack.
uint32_t address_of;
uint32_t address_of;
};
/**
@ -172,6 +172,7 @@ namespace DFHack
uint32_t vtable;
/// generic material.
uint16_t mat1;
/// possibly alignment artifact
uint16_t unk1;
/// material vector index
uint32_t mat2;

@ -4,6 +4,7 @@
#include <vector>
#include <map>
#include <stddef.h>
#include <cstring>
using namespace std;
#include <DFHack.h>
@ -39,6 +40,31 @@ int main (int argc, char** argv)
return 1;
}
DFHack::Maps *Mapz = DF->getMaps();
DFHack::Materials *Mats = DF->getMaterials();
uint32_t water_idx = (uint32_t) int32_t(-1);
uint32_t mud_idx = (uint32_t) int32_t(-1);
if(Mats->ReadOthers())
{
vector <DFHack::t_matglossOther > & main_mats = Mats->other;
for(size_t i = 0; i < main_mats.size();i++)
{
if(strcmp(main_mats[i].rawname, "MUD"))
{
mud_idx = i;
}
else if(strcmp(main_mats[i].rawname, "WATER"))
{
water_idx = i;
}
}
}
else
{
cerr << "Can't init materials." << endl;
if(temporary_terminal)
cin.ignore();
return 1;
}
// init the map
if(!Mapz->Start())
@ -71,11 +97,12 @@ int main (int argc, char** argv)
occ[i][j].bits.broken_arrows_variant = 0;
}
Mapz->WriteOccupancy(x,y,z,&occ);
// TODO: make this actually destroy the objects/remove them from the vector?
for(uint32_t i = 0; i < splatter.size(); i++)
{
DFHack::t_spattervein & vein = splatter[i];
// filter away snow and mud
if(vein.mat1 != 0xC && vein.mat1 != 0x6)
// filter *solid* away water and mud
if(vein.mat1 != mud_idx && vein.mat2 != water_idx || vein.matter_state != DFHack::state_solid)
{
uint32_t addr = vein.address_of;
uint32_t offset = offsetof(DFHack::t_spattervein, intensity);