Fixed vdig, improved magma create :)

develop
Petr Mrázek 2010-04-15 22:14:55 +02:00
parent 59cdbeefe7
commit 78e1a58867
2 changed files with 111 additions and 41 deletions

@ -33,36 +33,91 @@ int main (void)
#endif
return 1;
}
Maps->Start();
if(Position->getCursorCoords(x,y,z))
bool end = false;
cout << "Welcome to the liquid spawner. type 'help' for a list of available commands." << endl;
string mode="magma";
int amount = 7;
while(!end)
{
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
if(Maps->isValidBlock(x/16,y/16,z))
DF.Resume();
string command = "";
cout << mode << ":" << amount << " >";
getline(cin, command);
if(command=="help")
{
cout << "m - switch to magma" << endl
<< "w - switch to water" << endl
<< "return - put liquid" << endl
<< "0-7 - set liquid amount" << endl
<< "q - quit" << endl
<< "help - print this list of commands" << endl;
}
else if(command == "m")
{
mode = "magma";
}
else if(command == "w")
{
mode = "water";
}
else if(command == "q")
{
end = true;
}
// blah blah, bad code, bite me.
else if(command == "0")
amount = 0;
else if(command == "1")
amount = 1;
else if(command == "2")
amount = 2;
else if(command == "3")
amount = 3;
else if(command == "4")
amount = 4;
else if(command == "5")
amount = 5;
else if(command == "6")
amount = 6;
else if(command == "7")
amount = 7;
else// if(command.empty())
{
// place the magma
Maps->ReadDesignations((x/16),(y/16),z, &designations);
designations[x%16][y%16].bits.flow_size = 7;
designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma;
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
bflags.bits.liquid_1 = true;
bflags.bits.liquid_2 = true;
Maps->WriteBlockFlags((x/16),(y/16),z,bflags);
DF.Suspend();
Maps->Start();
if(Position->getCursorCoords(x,y,z))
{
cout << "cursor coords: " << x << "/" << y << "/" << z << endl;
if(Maps->isValidBlock(x/16,y/16,z))
{
// place the magma
Maps->ReadDesignations((x/16),(y/16),z, &designations);
designations[x%16][y%16].bits.flow_size = amount;
if(mode == "magma")
designations[x%16][y%16].bits.liquid_type = DFHack::liquid_magma;
if(mode == "water")
designations[x%16][y%16].bits.liquid_type = DFHack::liquid_water;
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
bflags.bits.liquid_1 = true;
bflags.bits.liquid_2 = true;
Maps->WriteBlockFlags((x/16),(y/16),z,bflags);
Maps->Finish();
cout << "OK" << endl;
}
else
cout << "Not a valid block." << endl;
}
else
cout << "NO" << endl;
Maps->Finish();
cout << "Success" << endl;
}
else
cout << "Failure 1" << endl;
}
else
cout << "Failure 2" << endl;
DF.Detach();
#ifndef LINUX_BUILD
cout << "Done. Press any key to continue" << endl;

@ -124,8 +124,8 @@ class Block
}
return true;
}
bool valid;
bool dirty;
volatile bool valid;
volatile bool dirty;
DFHack::Maps * m;
DFHack::mapblock40d raw;
uint32_t x;
@ -173,9 +173,13 @@ class Layer
}
else
{
Block * nblo = new Block(Maps,blockcoord.x,blockcoord.y,z);
blocks[blockcoord] = nblo;
return nblo;
if(blockcoord.x < x_bmax && blockcoord.y < y_bmax)
{
Block * nblo = new Block(Maps,blockcoord.x,blockcoord.y,z);
blocks[blockcoord] = nblo;
return nblo;
}
return 0;
}
}
@ -242,7 +246,7 @@ class Layer
return true;
}
private:
bool valid;
volatile bool valid;
uint32_t z;
uint32_t x_bmax;
uint32_t y_bmax;
@ -287,6 +291,9 @@ int main (int argc, const char* argv[])
int32_t cx, cy, cz;
Maps->getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
Pos->getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
@ -296,10 +303,19 @@ int main (int argc, const char* argv[])
DF.Suspend();
Pos->getCursorCoords(cx,cy,cz);
}
Point xy ((uint32_t)cx,(uint32_t)cy);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
{
cerr << "I won't dig the borders. That would be cheating!" << endl;
DF.Detach();
#ifndef LINUX_BUILD
cin.ignore();
#endif
return 1;
}
Layer * L = new Layer(Maps,cz);
Point xy ((uint32_t)cx,(uint32_t)cy);
DFHack::t_designation des = L->designationAt(xy);
int16_t tt = L->tiletypeAt(xy);
int16_t veinmat = L->materialAt(xy);
@ -317,8 +333,7 @@ int main (int argc, const char* argv[])
printf("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <Point> flood;
flood.push(xy);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
while( !flood.empty() )
{
@ -335,29 +350,29 @@ int main (int argc, const char* argv[])
if(L->setDesignationAt(current,des))
{
L->clearMaterialAt(current);
if(current.x < tx_max)
if(current.x < tx_max - 2)
{
flood.push(Point(current.x + 1, current.y));
if(current.y < ty_max)
if(current.y < ty_max - 2)
{
flood.push(Point(current.x + 1, current.y + 1));
flood.push(Point(current.x, current.y + 1));
}
if(current.y != 0)
if(current.y > 1)
{
flood.push(Point(current.x + 1, current.y - 1));
flood.push(Point(current.x, current.y - 1));
}
}
if(current.x != 0)
if(current.x > 1)
{
flood.push(Point(current.x - 1, current.y));
if(current.y < ty_max)
if(current.y < ty_max - 2)
{
flood.push(Point(current.x - 1, current.y + 1));
flood.push(Point(current.x, current.y + 1));
}
if(current.y != 0)
if(current.y > 1)
{
flood.push(Point(current.x - 1, current.y - 1));
flood.push(Point(current.x, current.y - 1));