|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
#include <DFHack.h>
|
|
|
|
@ -45,6 +46,8 @@ int main (void)
|
|
|
|
|
string flowmode="f+";
|
|
|
|
|
string setmode ="s.";
|
|
|
|
|
int amount = 7;
|
|
|
|
|
int width = 1;
|
|
|
|
|
int height = 1;
|
|
|
|
|
while(!end)
|
|
|
|
|
{
|
|
|
|
|
DF->Resume();
|
|
|
|
@ -69,6 +72,7 @@ int main (void)
|
|
|
|
|
<< "0-7 - set liquid amount" << endl
|
|
|
|
|
<< "Brush:" << endl
|
|
|
|
|
<< "point - single tile" << endl
|
|
|
|
|
<< "range - rectangle with cursor at top left" << endl
|
|
|
|
|
<< "block - block with cursor in it" << endl
|
|
|
|
|
<< "Other:" << endl
|
|
|
|
|
<< "q - quit" << endl
|
|
|
|
@ -110,6 +114,18 @@ int main (void)
|
|
|
|
|
{
|
|
|
|
|
brush = "point";
|
|
|
|
|
}
|
|
|
|
|
else if(command == "range")
|
|
|
|
|
{
|
|
|
|
|
cout << " :set range width<" << width << "># ";
|
|
|
|
|
getline(cin, command);
|
|
|
|
|
width = atoi (command.c_str());
|
|
|
|
|
if(width < 1) width = 1;
|
|
|
|
|
cout << " :set range height<" << height << "># ";
|
|
|
|
|
getline(cin, command);
|
|
|
|
|
height = atoi (command.c_str());
|
|
|
|
|
if(height < 1) height = 1;
|
|
|
|
|
brush = "range";
|
|
|
|
|
}
|
|
|
|
|
else if(command == "block")
|
|
|
|
|
{
|
|
|
|
|
brush = "block";
|
|
|
|
@ -257,6 +273,8 @@ int main (void)
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// place the magma
|
|
|
|
|
if(brush != "range")
|
|
|
|
|
{
|
|
|
|
|
Maps->ReadDesignations((x/16),(y/16),z, &designations);
|
|
|
|
|
Maps->ReadTemperatures((x/16),(y/16),z, &temp1, &temp2);
|
|
|
|
|
if(brush == "point")
|
|
|
|
@ -320,7 +338,6 @@ int main (void)
|
|
|
|
|
}
|
|
|
|
|
Maps->WriteTemperatures((x/16),(y/16),z, &temp1, &temp2);
|
|
|
|
|
Maps->WriteDesignations(x/16,y/16,z, &designations);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// make the magma flow :)
|
|
|
|
|
DFHack::t_blockflags bflags;
|
|
|
|
@ -343,6 +360,103 @@ int main (void)
|
|
|
|
|
cout << "flow bit 2 = " << bflags.bits.liquid_2 << endl;
|
|
|
|
|
}
|
|
|
|
|
Maps->WriteBlockFlags((x/16),(y/16),z,bflags);
|
|
|
|
|
}
|
|
|
|
|
else // (brush == "range")
|
|
|
|
|
{
|
|
|
|
|
// Crop the range into each block if necessary
|
|
|
|
|
int beginxblock = x/16;
|
|
|
|
|
int endxblock = (x+width)/16;
|
|
|
|
|
int beginyblock = y/16;
|
|
|
|
|
int endyblock = (y+height)/16;
|
|
|
|
|
for(uint32_t bx = beginxblock; bx < endxblock+1; bx++) for(uint32_t by = beginyblock; by < endyblock+1; by++)
|
|
|
|
|
{
|
|
|
|
|
if(Maps->isValidBlock(bx,by,z))
|
|
|
|
|
{
|
|
|
|
|
Maps->ReadDesignations(bx,by,z, &designations);
|
|
|
|
|
Maps->ReadTemperatures(bx,by,z, &temp1, &temp2);
|
|
|
|
|
// Take original range and crop it into current block
|
|
|
|
|
int nx = x;
|
|
|
|
|
int ny = y;
|
|
|
|
|
int nwidth = width;
|
|
|
|
|
int nheight = height;
|
|
|
|
|
if(x/16 < bx) //Start point is left of block
|
|
|
|
|
{
|
|
|
|
|
nx = bx*16;
|
|
|
|
|
nwidth -= nx - x;
|
|
|
|
|
}
|
|
|
|
|
if (nx/16 < (nx+nwidth-1)/16)// End point is right of block
|
|
|
|
|
{
|
|
|
|
|
nwidth = (bx*16)+16-nx;
|
|
|
|
|
}
|
|
|
|
|
if(y/16 < by) //Start point is above block
|
|
|
|
|
{
|
|
|
|
|
ny = by*16;
|
|
|
|
|
nheight -= ny - y;
|
|
|
|
|
}
|
|
|
|
|
if (ny/16 < (ny+nheight-1)/16) // End point is below block
|
|
|
|
|
{
|
|
|
|
|
nheight = (by*16)+16-ny;
|
|
|
|
|
}
|
|
|
|
|
cout << " Block:" << bx << "," << by << ":" << endl;
|
|
|
|
|
cout << " Start:" << nx << "," << ny << ":" << endl;
|
|
|
|
|
cout << " Area: " << nwidth << "," << nheight << ":" << endl;
|
|
|
|
|
for(uint32_t xx = nx; xx < nx+nwidth; xx++) for(uint32_t yy = ny; yy < ny+nheight; yy++)
|
|
|
|
|
{
|
|
|
|
|
if(mode != "flowbits")
|
|
|
|
|
{
|
|
|
|
|
// fix temperatures so we don't produce lethal heat traps
|
|
|
|
|
if(amount == 0 || designations[xx%16][yy%16].bits.liquid_type == DFHack::liquid_magma && mode == "water")
|
|
|
|
|
temp1[xx%16][yy%16] = temp2[xx%16][yy%16] = 10015;
|
|
|
|
|
DFHack::naked_designation & flow= designations[xx%16][yy%16].bits;
|
|
|
|
|
if(setmode == "s.")
|
|
|
|
|
{
|
|
|
|
|
flow.flow_size = amount;
|
|
|
|
|
}
|
|
|
|
|
else if(setmode == "s+")
|
|
|
|
|
{
|
|
|
|
|
if(flow.flow_size < amount)
|
|
|
|
|
flow.flow_size = amount;
|
|
|
|
|
}
|
|
|
|
|
else if(setmode == "s-")
|
|
|
|
|
{
|
|
|
|
|
if (flow.flow_size > amount)
|
|
|
|
|
flow.flow_size = amount;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(mode == "magma")
|
|
|
|
|
designations[xx%16][yy%16].bits.liquid_type = DFHack::liquid_magma;
|
|
|
|
|
else if(mode == "water")
|
|
|
|
|
designations[xx%16][yy%16].bits.liquid_type = DFHack::liquid_water;
|
|
|
|
|
}
|
|
|
|
|
Maps->WriteTemperatures(bx,by,z, &temp1, &temp2);
|
|
|
|
|
Maps->WriteDesignations(bx,by,z, &designations);
|
|
|
|
|
|
|
|
|
|
// make the magma flow :)
|
|
|
|
|
DFHack::t_blockflags bflags;
|
|
|
|
|
Maps->ReadBlockFlags(bx,by,z,bflags);
|
|
|
|
|
// 0x00000001 = job-designated
|
|
|
|
|
// 0x0000000C = run flows? - both bit 3 and 4 required for making magma placed on a glacier flow
|
|
|
|
|
if(flowmode == "f+")
|
|
|
|
|
{
|
|
|
|
|
bflags.bits.liquid_1 = true;
|
|
|
|
|
bflags.bits.liquid_2 = true;
|
|
|
|
|
}
|
|
|
|
|
else if(flowmode == "f-")
|
|
|
|
|
{
|
|
|
|
|
bflags.bits.liquid_1 = false;
|
|
|
|
|
bflags.bits.liquid_2 = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cout << "flow bit 1 = " << bflags.bits.liquid_1 << endl;
|
|
|
|
|
cout << "flow bit 2 = " << bflags.bits.liquid_2 << endl;
|
|
|
|
|
}
|
|
|
|
|
Maps->WriteBlockFlags(bx,by,z,bflags);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
cout << "OK" << endl;
|
|
|
|
|
Maps->Finish();
|
|
|
|
|
} while (0);
|
|
|
|
|