|
|
@ -54,42 +54,45 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
|
|
|
|
if(params[i] == "help" || params[i] == "?")
|
|
|
|
if(params[i] == "help" || params[i] == "?")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
c->con.print("Flood-fill selected traffic type from the cursor.\n"
|
|
|
|
c->con.print("Flood-fill selected traffic type from the cursor.\n"
|
|
|
|
"Traffic Type Codes:\n"
|
|
|
|
"Traffic Type Codes:\n"
|
|
|
|
" H: High Traffic\n"
|
|
|
|
"\tH: High Traffic\n"
|
|
|
|
" N: Normal Traffic\n"
|
|
|
|
"\tN: Normal Traffic\n"
|
|
|
|
" L: Low Traffic\n"
|
|
|
|
"\tL: Low Traffic\n"
|
|
|
|
" R: Restricted Traffic\n"
|
|
|
|
"\tR: Restricted Traffic\n"
|
|
|
|
"Other Options:\n"
|
|
|
|
"Other Options:\n"
|
|
|
|
" X: Fill accross z-levels.\n"
|
|
|
|
"\tX: Fill accross z-levels.\n"
|
|
|
|
" B: Include buildings and stockpiles.\n"
|
|
|
|
"\tB: Include buildings and stockpiles.\n"
|
|
|
|
" P: Include empty space.\n"
|
|
|
|
"\tP: Include empty space.\n"
|
|
|
|
|
|
|
|
"Example:\n"
|
|
|
|
|
|
|
|
"'filltraffic H' - When used in a room with doors,\n"
|
|
|
|
|
|
|
|
" it will set traffic to HIGH in just that room."
|
|
|
|
);
|
|
|
|
);
|
|
|
|
return CR_OK;
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (toupper(params[i][0]))
|
|
|
|
switch (toupper(params[i][0]))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case 'H':
|
|
|
|
case 'H':
|
|
|
|
target = traffic_high; break;
|
|
|
|
target = traffic_high; break;
|
|
|
|
case 'N':
|
|
|
|
case 'N':
|
|
|
|
target = traffic_normal; break;
|
|
|
|
target = traffic_normal; break;
|
|
|
|
case 'L':
|
|
|
|
case 'L':
|
|
|
|
target = traffic_low; break;
|
|
|
|
target = traffic_low; break;
|
|
|
|
case 'R':
|
|
|
|
case 'R':
|
|
|
|
target = traffic_restricted; break;
|
|
|
|
target = traffic_restricted; break;
|
|
|
|
case 'X':
|
|
|
|
case 'X':
|
|
|
|
updown = true; break;
|
|
|
|
updown = true; break;
|
|
|
|
case 'B':
|
|
|
|
case 'B':
|
|
|
|
checkbuilding = false; break;
|
|
|
|
checkbuilding = false; break;
|
|
|
|
case 'P':
|
|
|
|
case 'P':
|
|
|
|
checkpit = false; break;
|
|
|
|
checkpit = false; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Initialization.
|
|
|
|
//Initialization.
|
|
|
|
c->Suspend();
|
|
|
|
c->Suspend();
|
|
|
|
|
|
|
|
|
|
|
|
DFHack::Maps * Maps = c->getMaps();
|
|
|
|
DFHack::Maps * Maps = c->getMaps();
|
|
|
|
DFHack::Gui * Gui = c->getGui();
|
|
|
|
DFHack::Gui * Gui = c->getGui();
|
|
|
|
// init the map
|
|
|
|
// init the map
|
|
|
|
if(!Maps->Start())
|
|
|
|
if(!Maps->Start())
|
|
|
@ -111,17 +114,17 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
|
|
|
|
return CR_FAILURE;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
|
|
|
|
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
|
|
|
|
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
|
|
|
|
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
|
|
|
|
|
|
|
|
|
|
|
|
DFHack::t_designation des = MCache->designationAt(xy);
|
|
|
|
DFHack::t_designation des = MCache->designationAt(xy);
|
|
|
|
int16_t tt = MCache->tiletypeAt(xy);
|
|
|
|
int16_t tt = MCache->tiletypeAt(xy);
|
|
|
|
DFHack::t_occupancy oc;
|
|
|
|
DFHack::t_occupancy oc;
|
|
|
|
|
|
|
|
|
|
|
|
if (checkbuilding)
|
|
|
|
if (checkbuilding)
|
|
|
|
oc = MCache->occupancyAt(xy);
|
|
|
|
oc = MCache->occupancyAt(xy);
|
|
|
|
|
|
|
|
|
|
|
|
source = des.bits.traffic;
|
|
|
|
source = des.bits.traffic;
|
|
|
|
if(source == target)
|
|
|
|
if(source == target)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
c->con.printerr("This tile is already set to the target traffic type.\n");
|
|
|
|
c->con.printerr("This tile is already set to the target traffic type.\n");
|
|
|
@ -130,13 +133,13 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::stri
|
|
|
|
return CR_FAILURE;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(DFHack::isWallTerrain(tt))
|
|
|
|
if(DFHack::isWallTerrain(tt))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
c->con.printerr("This tile is a wall. Please select a passable tile.\n");
|
|
|
|
c->con.printerr("This tile is a wall. Please select a passable tile.\n");
|
|
|
|
delete MCache;
|
|
|
|
delete MCache;
|
|
|
|
c->Resume();
|
|
|
|
c->Resume();
|
|
|
|
return CR_FAILURE;
|
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(checkpit && DFHack::isOpenTerrain(tt))
|
|
|
|
if(checkpit && DFHack::isOpenTerrain(tt))
|
|
|
|
{
|
|
|
|
{
|
|
|
|