From 0661248d1f2ce2f9aa07ad715478caaa929e42fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 26 May 2011 02:14:42 +0200 Subject: [PATCH] Cleanmap filters on matter state. Anything non-solid is removed (including mud and water). Solid mud and snow stay. --- library/include/dfhack/modules/Maps.h | 3 ++- tools/supported/cleanmap.cpp | 31 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/library/include/dfhack/modules/Maps.h b/library/include/dfhack/modules/Maps.h index 351a9616d..9001f6334 100644 --- a/library/include/dfhack/modules/Maps.h +++ b/library/include/dfhack/modules/Maps.h @@ -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; diff --git a/tools/supported/cleanmap.cpp b/tools/supported/cleanmap.cpp index 35490bf8b..4557eaea1 100644 --- a/tools/supported/cleanmap.cpp +++ b/tools/supported/cleanmap.cpp @@ -4,6 +4,7 @@ #include #include #include +#include using namespace std; #include @@ -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 & 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);