2009-09-13 18:02:46 -06:00
|
|
|
// This is a reveal program. It reveals the map.
|
|
|
|
|
|
|
|
#include <iostream>
|
2009-10-21 20:14:16 -06:00
|
|
|
#include <integers.h>
|
2009-09-13 18:02:46 -06:00
|
|
|
#include <vector>
|
2010-05-23 15:06:10 -06:00
|
|
|
#include <map>
|
2009-09-13 18:02:46 -06:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include <DFTypes.h>
|
2010-05-23 15:06:10 -06:00
|
|
|
#include <DFContextManager.h>
|
|
|
|
#include <DFContext.h>
|
2010-04-04 16:48:19 -06:00
|
|
|
#include <modules/Maps.h>
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2010-04-17 14:08:16 -06:00
|
|
|
|
|
|
|
struct hideblock
|
|
|
|
{
|
|
|
|
uint32_t x;
|
|
|
|
uint32_t y;
|
|
|
|
uint32_t z;
|
|
|
|
uint8_t hiddens [16][16];
|
|
|
|
};
|
|
|
|
|
2009-09-13 18:02:46 -06:00
|
|
|
int main (void)
|
|
|
|
{
|
|
|
|
uint32_t x_max,y_max,z_max;
|
2010-03-25 14:37:09 -06:00
|
|
|
DFHack::designations40d designations;
|
2009-09-13 18:02:46 -06:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::ContextManager DFMgr("Memory.xml");
|
|
|
|
DFHack::Context *DF;
|
2010-03-26 06:01:46 -06:00
|
|
|
try
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2010-05-23 15:06:10 -06:00
|
|
|
DF = DFMgr.getSingleContext();
|
|
|
|
DF->Attach();
|
2010-03-26 06:01:46 -06:00
|
|
|
}
|
|
|
|
catch (exception& e)
|
|
|
|
{
|
|
|
|
cerr << e.what() << endl;
|
|
|
|
#ifndef LINUX_BUILD
|
|
|
|
cin.ignore();
|
|
|
|
#endif
|
2009-09-13 18:02:46 -06:00
|
|
|
return 1;
|
|
|
|
}
|
2010-03-26 06:01:46 -06:00
|
|
|
|
2010-05-23 15:06:10 -06:00
|
|
|
DFHack::Maps *Maps =DF->getMaps();
|
2010-03-26 06:01:46 -06:00
|
|
|
// init the map
|
2010-04-04 16:48:19 -06:00
|
|
|
if(!Maps->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-04 16:48:19 -06:00
|
|
|
Maps->getSize(x_max,y_max,z_max);
|
2010-04-17 14:08:16 -06:00
|
|
|
vector <hideblock> hidesaved;
|
|
|
|
// walk the map, save the hide bits, reveal.
|
|
|
|
cout << "Revealing... please wait." << endl;
|
2009-09-13 18:02:46 -06:00
|
|
|
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-04 16:48:19 -06:00
|
|
|
if(Maps->isValidBlock(x,y,z))
|
2009-09-13 18:02:46 -06:00
|
|
|
{
|
2010-04-17 14:08:16 -06:00
|
|
|
hideblock hb;
|
|
|
|
hb.x = x;
|
|
|
|
hb.y = y;
|
|
|
|
hb.z = z;
|
2009-09-13 18:02:46 -06:00
|
|
|
// read block designations
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->ReadDesignations(x,y,z, &designations);
|
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-04-17 14:08:16 -06:00
|
|
|
hb.hiddens[i][j] = designations[i][j].bits.hidden;
|
2010-03-25 14:37:09 -06:00
|
|
|
designations[i][j].bits.hidden = 0;
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
2010-04-17 14:08:16 -06:00
|
|
|
hidesaved.push_back(hb);
|
2009-09-13 18:02:46 -06:00
|
|
|
// write the designations back
|
2010-04-04 16:48:19 -06:00
|
|
|
Maps->WriteDesignations(x,y,z, &designations);
|
2009-09-13 18:02:46 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-04-17 14:08:16 -06:00
|
|
|
// FIXME: force game pause here!
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Detach();
|
2010-04-17 14:08:16 -06:00
|
|
|
cout << "Map revealed. Close window/force exit to keep it that way." << endl;
|
|
|
|
cout << "Press any key to unreveal. Don't close DF or unpause in that case!" << endl;
|
|
|
|
cin.ignore();
|
|
|
|
cout << "Unrevealing... please wait." << endl;
|
|
|
|
// FIXME: do some consistency checks here!
|
2010-05-23 15:06:10 -06:00
|
|
|
DF->Attach();
|
|
|
|
Maps = DF->getMaps();
|
2010-04-19 06:14:37 -06:00
|
|
|
Maps->Start();
|
2010-04-17 14:08:16 -06:00
|
|
|
for(int i = 0; i < hidesaved.size();i++)
|
|
|
|
{
|
|
|
|
hideblock & hb = hidesaved[i];
|
|
|
|
Maps->ReadDesignations(hb.x,hb.y,hb.z, &designations);
|
|
|
|
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
|
|
|
|
{
|
|
|
|
designations[i][j].bits.hidden = hb.hiddens[i][j];
|
|
|
|
}
|
|
|
|
Maps->WriteDesignations(hb.x,hb.y,hb.z, &designations);
|
|
|
|
}
|
2009-11-05 18:04:17 -07:00
|
|
|
#ifndef LINUX_BUILD
|
2009-10-30 03:01:14 -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
|
|
|
}
|