Fix cleanmap. Now it treats mud and snow properly.

develop
Petr Mrázek 2011-05-26 05:48:56 +02:00
parent 9c1afa2285
commit b3fd50e2a8
1 changed files with 15 additions and 33 deletions

@ -10,6 +10,10 @@ using namespace std;
#include <DFHack.h>
#include <dfhack/extra/termutil.h>
// magic globals.
const uint32_t water_idx = 6;
const uint32_t mud_idx = 12;
int main (int argc, char** argv)
{
bool temporary_terminal = TemporaryTerminal();
@ -40,31 +44,6 @@ 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())
@ -97,17 +76,20 @@ 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 *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);
DF->WriteRaw(addr + offset,sizeof(zeroes),(uint8_t *) zeroes);
}
// filter snow
if(vein.mat1 == water_idx && vein.matter_state == DFHack::state_powder)
continue;
// filter mud
if(vein.mat1 == mud_idx && vein.matter_state == DFHack::state_solid)
continue;
uint32_t addr = vein.address_of;
uint32_t offset = offsetof(DFHack::t_spattervein, intensity);
// TODO: make this actually destroy the objects/remove them from the vector?
// still, this is safe.
DF->WriteRaw(addr + offset,sizeof(zeroes),(uint8_t *) zeroes);
}
}
}