Fix formatting.

develop
Petr Mrázek 2010-10-08 04:28:26 +02:00
parent aaf3155e43
commit 1460066a69
1 changed files with 202 additions and 203 deletions

@ -1,6 +1,8 @@
// This will create 7 deep magama on the square the cursor is on. It does not
// enable magma buildings at this time.
// TO BE DEPRECATED SOON.
#include <iostream>
#include <vector>
#include <map>
@ -46,8 +48,8 @@ int main (void)
string flowmode="f+";
string setmode ="s.";
int amount = 7;
int width = 1;
int height = 1;
int width = 1;
int height = 1;
while(!end)
{
DF->Resume();
@ -72,7 +74,7 @@ int main (void)
<< "0-7 - set liquid amount" << endl
<< "Brush:" << endl
<< "point - single tile" << endl
<< "range - rectangle with cursor at top left" << endl
<< "range - rectangle with cursor at top left" << endl
<< "block - block with cursor in it" << endl
<< "Other:" << endl
<< "q - quit" << endl
@ -114,18 +116,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 == "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";
@ -230,7 +232,6 @@ int main (void)
cout << "sizeof(tiletypes) = " << sizeof(tiles) << endl;
for(uint32_t xx = 0; xx < 16; xx++) for(uint32_t yy = 0; yy < 16; yy++)
{
cout<< xx << " " << yy <<": " << tiles[xx][yy] << endl;
tiles[xx][yy] = 335;// 45
DFHack::naked_designation & des = designations[xx][yy].bits;
@ -240,10 +241,8 @@ int main (void)
des.skyview = 0;
des.light = 0;
des.subterranean = 1;
temp1[xx][yy] = 10015;
temp2[xx][yy] = 10015;
}
Maps->WriteTemperatures((x/16),(y/16),z, &temp1, &temp2);
Maps->WriteDesignations((x/16),(y/16),z, &designations);
@ -273,192 +272,192 @@ 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")
{
if(mode != "flowbits")
{
// fix temperatures so we don't produce lethal heat traps
if(amount == 0 || designations[x%16][y%16].bits.liquid_type == DFHack::liquid_magma && mode == "water")
temp1[x%16][y%16] = temp2[x%16][y%16] = 10015;
DFHack::naked_designation & flow = designations[x%16][y%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[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;
}
else
{
for(uint32_t xx = 0; xx < 16; xx++) for(uint32_t yy = 0; yy < 16; yy++)
{
if(mode != "flowbits")
{
// fix temperatures so we don't produce lethal heat traps
if(amount == 0 || designations[xx][yy].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][yy].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][yy].bits.liquid_type = DFHack::liquid_magma;
else if(mode == "water")
designations[xx][yy].bits.liquid_type = DFHack::liquid_water;
}
}
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;
Maps->ReadBlockFlags((x/16),(y/16),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((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);
}
}
}
if(brush != "range")
{
Maps->ReadDesignations((x/16),(y/16),z, &designations);
Maps->ReadTemperatures((x/16),(y/16),z, &temp1, &temp2);
if(brush == "point")
{
if(mode != "flowbits")
{
// fix temperatures so we don't produce lethal heat traps
if(amount == 0 || designations[x%16][y%16].bits.liquid_type == DFHack::liquid_magma && mode == "water")
temp1[x%16][y%16] = temp2[x%16][y%16] = 10015;
DFHack::naked_designation & flow = designations[x%16][y%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[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;
}
else
{
for(uint32_t xx = 0; xx < 16; xx++) for(uint32_t yy = 0; yy < 16; yy++)
{
if(mode != "flowbits")
{
// fix temperatures so we don't produce lethal heat traps
if(amount == 0 || designations[xx][yy].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][yy].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][yy].bits.liquid_type = DFHack::liquid_magma;
else if(mode == "water")
designations[xx][yy].bits.liquid_type = DFHack::liquid_water;
}
}
Maps->WriteTemperatures((x/16),(y/16),z, &temp1, &temp2);
Maps->WriteDesignations(x/16,y/16,z, &designations);
}
cout << "OK" << endl;
Maps->Finish();
// make the magma flow :)
DFHack::t_blockflags bflags;
Maps->ReadBlockFlags((x/16),(y/16),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((x/16),(y/16),z,bflags);
}
else if (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);
}
}