2009-09-13 18:02:46 -06:00
|
|
|
// Map cleaner. Removes all the snow, mud spills, blood and vomit from map tiles.
|
|
|
|
|
|
|
|
#include <iostream>
|
2009-10-21 20:14:16 -06:00
|
|
|
#include <integers.h>
|
2009-09-13 18:02:46 -06:00
|
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <DFHackAPI.h>
|
2010-04-09 18:12:45 -06:00
|
|
|
#include <DFTypes.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <modules/Maps.h>
|
2009-09-13 18:02:46 -06:00
|
|
|
|
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
uint32_t x_max,y_max,z_max;
|
|
|
|
uint32_t num_blocks = 0;
|
|
|
|
uint32_t bytes_read = 0;
|
2010-04-09 18:12:45 -06:00
|
|
|
vector<DFHack::t_vein> veinVector;
|
|
|
|
vector<DFHack::t_frozenliquidvein> IceVeinVector;
|
|
|
|
vector<DFHack::t_spattervein> splatter;
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2010-03-26 06:01:46 -06:00
|
|
|
DFHack::API DF("Memory.xml");
|
|
|
|
try
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2010-03-26 06:01:46 -06:00
|
|
|
DF.Attach();
|
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
2009-09-13 18:02:46 -06:00
|
|
|
return 1;
|
|
|
|
}
|
2010-04-09 18:12:45 -06:00
|
|
|
DFHack::Maps *Mapz = DF.getMaps();
|
2010-03-26 06:01:46 -06:00
|
|
|
|
|
|
|
// init the map
|
2010-04-09 18:12:45 -06:00
|
|
|
if(!Mapz->Start())
|
2010-03-26 06:01:46 -06:00
|
|
|
{
|
|
|
|
cerr << "Can't init map." << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-04-09 18:12:45 -06:00
|
|
|
Mapz->getSize(x_max,y_max,z_max);
|
|
|
|
|
|
|
|
uint8_t zeroes [16][16] = {0};
|
2009-09-13 18:02:46 -06:00
|
|
|
|
|
|
|
// 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++)
|
|
|
|
{
|
2010-04-09 18:12:45 -06:00
|
|
|
if(Mapz->isValidBlock(x,y,z))
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2010-04-09 18:12:45 -06:00
|
|
|
Mapz->ReadVeins(x,y,z,veinVector,IceVeinVector,splatter);
|
|
|
|
for(uint32_t i = 0; i < splatter.size(); i++)
|
|
|
|
{
|
|
|
|
DFHack::t_spattervein & vein = splatter[i];
|
|
|
|
if(vein.mat1 > 19)
|
|
|
|
{
|
|
|
|
uint32_t addr = vein.address_of;
|
|
|
|
uint32_t offset = offsetof(DFHack::t_spattervein, intensity);
|
|
|
|
DF.WriteRaw(addr + offset,sizeof(zeroes),(uint8_t *) zeroes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
2009-09-13 18:02:46 -06:00
|
|
|
// read block designations
|
2010-03-25 14:37:09 -06:00
|
|
|
DF.ReadOccupancy(x,y,z, &occupancies);
|
2009-09-13 18:02:46 -06:00
|
|
|
// change the hidden flag to 0
|
2010-03-25 14:37:09 -06:00
|
|
|
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2010-03-25 14:37:09 -06:00
|
|
|
occupancies[i][j].unibits.splatter = 0;
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
|
|
|
// write the designations back
|
2010-03-25 14:37:09 -06:00
|
|
|
DF.WriteOccupancy(x,y,z, &occupancies);
|
2010-04-09 18:12:45 -06:00
|
|
|
*/
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-31 12:18:59 -06:00
|
|
|
DF.Detach();
|
2009-11-05 18:04:17 -07:00
|
|
|
#ifndef LINUX_BUILD
|
2009-10-31 12:09:13 -06:00
|
|
|
cout << "Done. Press any key to continue" << endl;
|
|
|
|
cin.ignore();
|
2009-11-05 18:04:17 -07:00
|
|
|
#endif
|
2009-09-13 18:02:46 -06:00
|
|
|
return 0;
|
2009-12-13 14:03:19 -07:00
|
|
|
}
|