Reveal that unrevals, solids

develop
Petr Mrázek 2010-04-17 22:08:16 +02:00
parent caa482fbd1
commit 13d07e5d70
2 changed files with 88 additions and 17 deletions

@ -10,11 +10,14 @@ using namespace std;
#include <DFHackAPI.h>
#include <modules/Maps.h>
#include <modules/Position.h>
#include <DFTileTypes.h>
int main (void)
{
int32_t x,y,z;
DFHack::designations40d designations;
DFHack::tiletypes40d tiles;
uint32_t x_max,y_max,z_max;
DFHack::API DF("Memory.xml");
DFHack::Maps * Maps;
@ -41,6 +44,7 @@ int main (void)
int amount = 7;
while(!end)
{
Maps->getSize(x_max,y_max,z_max);
DF.Resume();
string command = "";
cout <<"[" << mode << ":" << amount << ":" << flowmode << "]# ";
@ -50,6 +54,7 @@ int main (void)
cout << "Modes:" << endl
<< "m - switch to magma" << endl
<< "w - switch to water" << endl
<< "o - make obsidian wall instead" << endl
<< "f - flow bits only" << endl
<< "Properties:" << endl
<< "f+ - make the spawned liquid flow" << endl
@ -72,6 +77,14 @@ int main (void)
{
mode = "magma";
}
else if(command == "o")
{
mode = "obsidian";
}
else if(command == "clmn")
{
mode = "column";
}
else if(command == "w")
{
mode = "water";
@ -142,30 +155,55 @@ int main (void)
cout << "Not a valid block." << endl;
break;
}
// place the magma
Maps->ReadDesignations((x/16),(y/16),z, &designations);
if(brush == "point")
if(mode == "obsidian")
{
if(mode != "flowbits")
designations[x%16][y%16].bits.flow_size = amount;
if(mode == "magma")
designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma;
else if(mode == "water")
designations[x%16][y%16].bits.liquid_type = DFHack::liquid_water;
Maps->ReadTileTypes((x/16),(y/16),z, &tiles);
tiles[x%16][y%16] = 331;
Maps->WriteTileTypes((x/16),(y/16),z, &tiles);
}
else if(mode == "column")
{
int zzz = z;
int16_t tile;
while ( zzz < z_max )
{
Maps->ReadTileTypes((x/16),(y/16),zzz, &tiles);
tile = tiles[x%16][y%16];
if (DFHack::tileTypeTable[tile].c == DFHack::WALL)
break;
tiles[x%16][y%16] = 331;
Maps->WriteTileTypes((x/16),(y/16),zzz, &tiles);
zzz++;
}
}
else
{
for(uint32_t xx = 0; xx < 16; xx++) for(uint32_t yy = 0; yy < 16; yy++)
// place the magma
Maps->ReadDesignations((x/16),(y/16),z, &designations);
if(brush == "point")
{
if(mode != "flowbits")
designations[xx][yy].bits.flow_size = amount;
designations[x%16][y%16].bits.flow_size = amount;
if(mode == "magma")
designations[xx][yy].bits.liquid_type = DFHack::liquid_magma;
designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma;
else if(mode == "water")
designations[xx][yy].bits.liquid_type = DFHack::liquid_water;
designations[x%16][y%16].bits.liquid_type = DFHack::liquid_water;
}
else
{
for(uint32_t xx = 0; xx < 16; xx++) for(uint32_t yy = 0; yy < 16; yy++)
{
if(mode != "flowbits")
designations[xx][yy].bits.flow_size = amount;
if(mode == "magma")
designations[xx][yy].bits.liquid_type = DFHack::liquid_magma;
else if(mode == "water")
designations[xx][yy].bits.liquid_type = DFHack::liquid_water;
}
}
Maps->WriteDesignations(x/16,y/16,z, &designations);
}
Maps->WriteDesignations(x/16,y/16,z, &designations);
// make the magma flow :)
DFHack::t_blockflags bflags;

@ -9,6 +9,15 @@ using namespace std;
#include <DFHackAPI.h>
#include <modules/Maps.h>
struct hideblock
{
uint32_t x;
uint32_t y;
uint32_t z;
uint8_t hiddens [16][16];
};
int main (void)
{
uint32_t x_max,y_max,z_max;
@ -40,8 +49,9 @@ int main (void)
}
Maps->getSize(x_max,y_max,z_max);
// walk the map
vector <hideblock> hidesaved;
// walk the map, save the hide bits, reveal.
cout << "Revealing... please wait." << endl;
for(uint32_t x = 0; x< x_max;x++)
{
for(uint32_t y = 0; y< y_max;y++)
@ -50,20 +60,43 @@ int main (void)
{
if(Maps->isValidBlock(x,y,z))
{
hideblock hb;
hb.x = x;
hb.y = y;
hb.z = z;
// read block designations
Maps->ReadDesignations(x,y,z, &designations);
// change the hidden flag to 0
for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++)
{
hb.hiddens[i][j] = designations[i][j].bits.hidden;
designations[i][j].bits.hidden = 0;
}
hidesaved.push_back(hb);
// write the designations back
Maps->WriteDesignations(x,y,z, &designations);
}
}
}
}
// FIXME: force game pause here!
DF.Detach();
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;
DF.Attach();
// FIXME: do some consistency checks here!
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);
}
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;
cin.ignore();