2011-10-13 18:15:19 -06:00
|
|
|
// Wide-area traffic designation utility.
|
|
|
|
// Flood-fill from cursor or fill entire map.
|
|
|
|
|
2011-11-03 02:04:05 -06:00
|
|
|
#include <ctype.h> //For toupper().
|
|
|
|
#include <algorithm> //for min().
|
2011-10-13 18:15:19 -06:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2011-12-31 04:48:42 -07:00
|
|
|
#include "Core.h"
|
2012-01-15 13:54:14 -07:00
|
|
|
#include "Console.h"
|
|
|
|
#include "Export.h"
|
|
|
|
#include "PluginManager.h"
|
|
|
|
#include "modules/Maps.h"
|
|
|
|
#include "modules/MapCache.h"
|
|
|
|
#include "modules/Gui.h"
|
2011-10-13 18:15:19 -06:00
|
|
|
using std::stack;
|
|
|
|
using MapExtras::MapCache;
|
|
|
|
using namespace DFHack;
|
2012-01-21 17:31:15 -07:00
|
|
|
using namespace df::enums;
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2011-11-03 02:04:05 -06:00
|
|
|
//Function pointer type for whole-map tile checks.
|
2012-02-13 21:54:08 -07:00
|
|
|
typedef void (*checkTile)(DFCoord, MapExtras::MapCache &);
|
2011-11-03 02:04:05 -06:00
|
|
|
|
|
|
|
//Forward Declarations for Commands
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result filltraffic(color_ostream &out, std::vector<std::string> & params);
|
|
|
|
command_result alltraffic(color_ostream &out, std::vector<std::string> & params);
|
2012-12-23 02:09:21 -07:00
|
|
|
command_result restrictLiquid(color_ostream &out, std::vector<std::string> & params);
|
|
|
|
command_result restrictIce(color_ostream &out, std::vector<std::string> & params);
|
2011-11-03 02:04:05 -06:00
|
|
|
|
|
|
|
//Forward Declarations for Utility Functions
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result setAllMatching(color_ostream &out, checkTile checkProc,
|
|
|
|
DFCoord minCoord = DFCoord(0, 0, 0),
|
|
|
|
DFCoord maxCoord = DFCoord(0xFFFF, 0xFFFF, 0xFFFF));
|
2011-11-03 02:04:05 -06:00
|
|
|
|
2012-02-13 21:54:08 -07:00
|
|
|
void allHigh(DFCoord coord, MapExtras::MapCache & map);
|
|
|
|
void allNormal(DFCoord coord, MapExtras::MapCache & map);
|
|
|
|
void allLow(DFCoord coord, MapExtras::MapCache & map);
|
|
|
|
void allRestricted(DFCoord coord, MapExtras::MapCache & map);
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2012-12-23 02:09:21 -07:00
|
|
|
void restrictLiquidProc(DFCoord coord, MapExtras::MapCache &map);
|
|
|
|
void restrictIceProc(DFCoord coord, MapExtras::MapCache &map);
|
|
|
|
|
2012-02-21 10:19:17 -07:00
|
|
|
DFHACK_PLUGIN("filltraffic");
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_init ( color_ostream &out, std::vector <PluginCommand> &commands)
|
2011-10-13 18:15:19 -06:00
|
|
|
{
|
2012-01-28 05:03:56 -07:00
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"filltraffic","Flood-fill with selected traffic designation from cursor",
|
2012-03-03 06:38:24 -07:00
|
|
|
filltraffic, Gui::cursor_hotkey,
|
2012-01-28 05:03:56 -07:00
|
|
|
" Flood-fill selected traffic type from the cursor.\n"
|
|
|
|
"Traffic Type Codes:\n"
|
|
|
|
" H: High Traffic\n"
|
|
|
|
" N: Normal Traffic\n"
|
|
|
|
" L: Low Traffic\n"
|
|
|
|
" R: Restricted Traffic\n"
|
|
|
|
"Other Options:\n"
|
|
|
|
" X: Fill across z-levels.\n"
|
|
|
|
" B: Include buildings and stockpiles.\n"
|
|
|
|
" P: Include empty space.\n"
|
|
|
|
"Example:\n"
|
|
|
|
" filltraffic H\n"
|
|
|
|
" When used in a room with doors,\n"
|
|
|
|
" it will set traffic to HIGH in just that room.\n"
|
|
|
|
));
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"alltraffic","Set traffic for the entire map",
|
|
|
|
alltraffic, false,
|
|
|
|
" Set traffic types for all tiles on the map.\n"
|
|
|
|
"Traffic Type Codes:\n"
|
|
|
|
" H: High Traffic\n"
|
|
|
|
" N: Normal Traffic\n"
|
|
|
|
" L: Low Traffic\n"
|
|
|
|
" R: Restricted Traffic\n"
|
|
|
|
));
|
2012-12-23 02:09:21 -07:00
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"restrictliquids","Restrict on every visible square with liquid",
|
|
|
|
restrictLiquid, false, ""
|
|
|
|
));
|
|
|
|
commands.push_back(PluginCommand(
|
|
|
|
"restrictice","Restrict traffic on squares above visible ice",
|
|
|
|
restrictIce, false, ""
|
|
|
|
));
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
DFhackCExport command_result plugin_shutdown ( color_ostream &out )
|
2011-10-13 18:15:19 -06:00
|
|
|
{
|
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result filltraffic(color_ostream &out, std::vector<std::string> & params)
|
2011-10-13 18:15:19 -06:00
|
|
|
{
|
2012-01-28 05:03:56 -07:00
|
|
|
// HOTKEY COMMAND; CORE ALREADY SUSPENDED
|
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
//Maximum map size.
|
|
|
|
uint32_t x_max,y_max,z_max;
|
|
|
|
//Source and target traffic types.
|
|
|
|
df::tile_traffic source = tile_traffic::Normal;
|
|
|
|
df::tile_traffic target = tile_traffic::Normal;
|
|
|
|
//Option flags
|
|
|
|
bool updown = false;
|
|
|
|
bool checkpit = true;
|
|
|
|
bool checkbuilding = true;
|
|
|
|
|
|
|
|
//Loop through parameters
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t i = 0; i < params.size();i++)
|
2011-10-13 18:15:19 -06:00
|
|
|
{
|
2012-01-28 05:03:56 -07:00
|
|
|
if (params[i] == "help" || params[i] == "?" || params[i].size() != 1)
|
|
|
|
return CR_WRONG_USAGE;
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2011-10-23 14:23:54 -06:00
|
|
|
switch (toupper(params[i][0]))
|
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
case 'H':
|
|
|
|
target = tile_traffic::High; break;
|
|
|
|
case 'N':
|
|
|
|
target = tile_traffic::Normal; break;
|
|
|
|
case 'L':
|
|
|
|
target = tile_traffic::Low; break;
|
|
|
|
case 'R':
|
|
|
|
target = tile_traffic::Restricted; break;
|
|
|
|
case 'X':
|
|
|
|
updown = true; break;
|
|
|
|
case 'B':
|
|
|
|
checkbuilding = false; break;
|
|
|
|
case 'P':
|
|
|
|
checkpit = false; break;
|
2012-01-28 05:03:56 -07:00
|
|
|
default:
|
|
|
|
return CR_WRONG_USAGE;
|
2011-10-23 14:23:54 -06:00
|
|
|
}
|
2011-10-13 18:15:19 -06:00
|
|
|
}
|
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
if (!Maps::IsValid())
|
2011-10-13 18:15:19 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
int32_t cx, cy, cz;
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::getSize(x_max,y_max,z_max);
|
2011-10-13 18:15:19 -06:00
|
|
|
uint32_t tx_max = x_max * 16;
|
|
|
|
uint32_t ty_max = y_max * 16;
|
2012-03-03 06:38:24 -07:00
|
|
|
Gui::getCursorCoords(cx,cy,cz);
|
2011-10-13 18:15:19 -06:00
|
|
|
while(cx == -30000)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Cursor is not active.\n");
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:54:08 -07:00
|
|
|
DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
|
2012-01-19 20:44:17 -07:00
|
|
|
MapExtras::MapCache MCache;
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
df::tile_designation des = MCache.designationAt(xy);
|
2012-02-13 15:56:33 -07:00
|
|
|
df::tiletype tt = MCache.tiletypeAt(xy);
|
2012-01-19 13:11:52 -07:00
|
|
|
df::tile_occupancy oc;
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2011-10-23 14:23:54 -06:00
|
|
|
if (checkbuilding)
|
2012-01-19 20:44:17 -07:00
|
|
|
oc = MCache.occupancyAt(xy);
|
2011-10-23 14:23:54 -06:00
|
|
|
|
2012-01-19 13:11:52 -07:00
|
|
|
source = (df::tile_traffic)des.bits.traffic;
|
2011-10-13 18:15:19 -06:00
|
|
|
if(source == target)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("This tile is already set to the target traffic type.\n");
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-02-13 21:54:08 -07:00
|
|
|
if(isWallTerrain(tt))
|
2011-10-23 14:23:54 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("This tile is a wall. Please select a passable tile.\n");
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_FAILURE;
|
2011-10-23 14:23:54 -06:00
|
|
|
}
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2012-02-13 21:54:08 -07:00
|
|
|
if(checkpit && isOpenTerrain(tt))
|
2012-01-21 17:31:15 -07:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("This tile is a hole. Please select a passable tile.\n");
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_FAILURE;
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
if(checkbuilding && oc.bits.building)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("This tile contains a building. Please select an empty tile.\n");
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_FAILURE;
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("%d/%d/%d ... FILLING!\n", cx,cy,cz);
|
2012-01-21 17:31:15 -07:00
|
|
|
|
|
|
|
//Naive four-way or six-way flood fill with possible tiles on a stack.
|
2012-02-13 21:54:08 -07:00
|
|
|
stack <DFCoord> flood;
|
2012-01-21 17:31:15 -07:00
|
|
|
flood.push(xy);
|
|
|
|
|
|
|
|
while(!flood.empty())
|
|
|
|
{
|
|
|
|
xy = flood.top();
|
|
|
|
flood.pop();
|
|
|
|
|
|
|
|
des = MCache.designationAt(xy);
|
|
|
|
if (des.bits.traffic != source) continue;
|
|
|
|
|
|
|
|
tt = MCache.tiletypeAt(xy);
|
|
|
|
|
2012-02-13 21:54:08 -07:00
|
|
|
if(isWallTerrain(tt)) continue;
|
|
|
|
if(checkpit && isOpenTerrain(tt)) continue;
|
2012-01-21 17:31:15 -07:00
|
|
|
|
|
|
|
if (checkbuilding)
|
|
|
|
{
|
|
|
|
oc = MCache.occupancyAt(xy);
|
|
|
|
if(oc.bits.building) continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//This tile is ready. Set its traffic level and add surrounding tiles.
|
|
|
|
if (MCache.testCoord(xy))
|
|
|
|
{
|
|
|
|
des.bits.traffic = target;
|
|
|
|
MCache.setDesignationAt(xy,des);
|
|
|
|
|
|
|
|
if (xy.x > 0)
|
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
flood.push(DFCoord(xy.x - 1, xy.y, xy.z));
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
if (xy.x < tx_max - 1)
|
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
flood.push(DFCoord(xy.x + 1, xy.y, xy.z));
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
if (xy.y > 0)
|
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
flood.push(DFCoord(xy.x, xy.y - 1, xy.z));
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
if (xy.y < ty_max - 1)
|
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
flood.push(DFCoord(xy.x, xy.y + 1, xy.z));
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (updown)
|
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
if (xy.z > 0 && LowPassable(tt))
|
2012-01-21 17:31:15 -07:00
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
flood.push(DFCoord(xy.x, xy.y, xy.z - 1));
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
2012-02-13 21:54:08 -07:00
|
|
|
if (xy.z < z_max && HighPassable(tt))
|
2012-01-21 17:31:15 -07:00
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
flood.push(DFCoord(xy.x, xy.y, xy.z + 1));
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MCache.WriteAll();
|
2011-10-13 18:15:19 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum e_checktype {no_check, check_equal, check_nequal};
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result alltraffic(color_ostream &out, std::vector<std::string> & params)
|
2011-10-13 18:15:19 -06:00
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
void (*proc)(DFCoord, MapExtras::MapCache &) = allNormal;
|
2012-01-21 17:31:15 -07:00
|
|
|
|
|
|
|
//Loop through parameters
|
2012-01-31 09:55:38 -07:00
|
|
|
for(size_t i = 0; i < params.size();i++)
|
2011-10-13 18:15:19 -06:00
|
|
|
{
|
2012-01-28 05:03:56 -07:00
|
|
|
if (params[i] == "help" || params[i] == "?" || params[i].size() != 1)
|
|
|
|
return CR_WRONG_USAGE;
|
2011-10-13 18:15:19 -06:00
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
//Pick traffic type. Possibly set bounding rectangle later.
|
|
|
|
switch (toupper(params[i][0]))
|
|
|
|
{
|
|
|
|
case 'H':
|
|
|
|
proc = allHigh; break;
|
|
|
|
case 'N':
|
|
|
|
proc = allNormal; break;
|
|
|
|
case 'L':
|
|
|
|
proc = allLow; break;
|
|
|
|
case 'R':
|
|
|
|
proc = allRestricted; break;
|
2012-01-28 05:03:56 -07:00
|
|
|
default:
|
|
|
|
return CR_WRONG_USAGE;
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
2011-10-13 18:15:19 -06:00
|
|
|
}
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
return setAllMatching(out, proc);
|
2011-11-03 02:04:05 -06:00
|
|
|
}
|
|
|
|
|
2012-12-23 02:09:21 -07:00
|
|
|
command_result restrictLiquid(color_ostream &out, std::vector<std::string> & params)
|
|
|
|
{
|
|
|
|
return setAllMatching(out, restrictLiquidProc);
|
|
|
|
}
|
|
|
|
|
|
|
|
command_result restrictIce(color_ostream &out, std::vector<std::string> & params)
|
|
|
|
{
|
|
|
|
return setAllMatching(out, restrictIceProc);
|
|
|
|
}
|
|
|
|
|
2011-11-03 02:04:05 -06:00
|
|
|
//Helper function for writing new functions that check every tile on the map.
|
|
|
|
//newTraffic is the traffic designation to set.
|
|
|
|
//check takes a coordinate and the map cache as arguments, and returns true if the criteria is met.
|
|
|
|
//minCoord and maxCoord can be used to specify a bounding cube.
|
2012-03-10 04:55:42 -07:00
|
|
|
command_result setAllMatching(color_ostream &out, checkTile checkProc,
|
|
|
|
DFCoord minCoord, DFCoord maxCoord)
|
2011-11-03 02:04:05 -06:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
//Initialization.
|
2012-03-10 04:55:42 -07:00
|
|
|
CoreSuspender suspend;
|
2011-11-03 02:04:05 -06:00
|
|
|
|
2012-01-19 20:44:17 -07:00
|
|
|
if (!Maps::IsValid())
|
2011-11-03 02:04:05 -06:00
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Map is not available!\n");
|
2011-11-03 02:04:05 -06:00
|
|
|
return CR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
//Maximum map size.
|
|
|
|
uint32_t x_max,y_max,z_max;
|
2012-01-19 20:44:17 -07:00
|
|
|
Maps::getSize(x_max,y_max,z_max);
|
2011-11-03 02:04:05 -06:00
|
|
|
uint32_t tx_max = x_max * 16;
|
|
|
|
uint32_t ty_max = y_max * 16;
|
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
//Ensure maximum coordinate is within map. Truncate to map edge.
|
|
|
|
maxCoord.x = std::min((uint32_t) maxCoord.x, tx_max);
|
|
|
|
maxCoord.y = std::min((uint32_t) maxCoord.y, ty_max);
|
|
|
|
maxCoord.z = std::min((uint32_t) maxCoord.z, z_max);
|
2011-11-03 02:04:05 -06:00
|
|
|
|
2012-01-21 17:31:15 -07:00
|
|
|
//Check minimum co-ordinates against maximum map size
|
|
|
|
if (minCoord.x > maxCoord.x)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Minimum x coordinate is greater than maximum x coordinate.\n");
|
2011-11-03 02:04:05 -06:00
|
|
|
return CR_FAILURE;
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
if (minCoord.y > maxCoord.y)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Minimum y coordinate is greater than maximum y coordinate.\n");
|
2011-11-03 02:04:05 -06:00
|
|
|
return CR_FAILURE;
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
if (minCoord.z > maxCoord.y)
|
|
|
|
{
|
2012-03-10 04:55:42 -07:00
|
|
|
out.printerr("Minimum z coordinate is greater than maximum z coordinate.\n");
|
2011-11-03 02:04:05 -06:00
|
|
|
return CR_FAILURE;
|
2012-01-21 17:31:15 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
MapExtras::MapCache MCache;
|
|
|
|
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("Setting traffic...\n");
|
2012-01-21 17:31:15 -07:00
|
|
|
|
|
|
|
//Loop through every single tile
|
|
|
|
for(uint32_t x = minCoord.x; x <= maxCoord.x; x++)
|
|
|
|
{
|
|
|
|
for(uint32_t y = minCoord.y; y <= maxCoord.y; y++)
|
|
|
|
{
|
|
|
|
for(uint32_t z = minCoord.z; z <= maxCoord.z; z++)
|
|
|
|
{
|
2012-02-13 21:54:08 -07:00
|
|
|
DFCoord tile = DFCoord(x, y, z);
|
2012-01-21 17:31:15 -07:00
|
|
|
checkProc(tile, MCache);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MCache.WriteAll();
|
2012-03-10 04:55:42 -07:00
|
|
|
out.print("Complete!\n");
|
2011-11-03 02:04:05 -06:00
|
|
|
return CR_OK;
|
|
|
|
}
|
|
|
|
|
2011-11-17 20:31:56 -07:00
|
|
|
//Unconditionally set map to target traffic type
|
2012-02-13 21:54:08 -07:00
|
|
|
void allHigh(DFCoord coord, MapExtras::MapCache &map)
|
2011-11-03 02:04:05 -06:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
df::tile_designation des = map.designationAt(coord);
|
|
|
|
des.bits.traffic = tile_traffic::High;
|
|
|
|
map.setDesignationAt(coord, des);
|
2011-11-03 02:04:05 -06:00
|
|
|
}
|
2012-02-13 21:54:08 -07:00
|
|
|
void allNormal(DFCoord coord, MapExtras::MapCache &map)
|
2011-11-17 20:31:56 -07:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
df::tile_designation des = map.designationAt(coord);
|
|
|
|
des.bits.traffic = tile_traffic::Normal;
|
|
|
|
map.setDesignationAt(coord, des);
|
2011-11-17 20:31:56 -07:00
|
|
|
}
|
2012-02-13 21:54:08 -07:00
|
|
|
void allLow(DFCoord coord, MapExtras::MapCache &map)
|
2011-11-17 20:31:56 -07:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
df::tile_designation des = map.designationAt(coord);
|
|
|
|
des.bits.traffic = tile_traffic::Low;
|
|
|
|
map.setDesignationAt(coord, des);
|
2011-11-17 20:31:56 -07:00
|
|
|
}
|
2012-02-13 21:54:08 -07:00
|
|
|
void allRestricted(DFCoord coord, MapExtras::MapCache &map)
|
2011-11-03 02:04:05 -06:00
|
|
|
{
|
2012-01-21 17:31:15 -07:00
|
|
|
df::tile_designation des = map.designationAt(coord);
|
|
|
|
des.bits.traffic = tile_traffic::Restricted;
|
|
|
|
map.setDesignationAt(coord, des);
|
2012-02-13 21:54:08 -07:00
|
|
|
}
|
2012-12-23 02:09:21 -07:00
|
|
|
|
|
|
|
//Restrict traffic if tile is visible and liquid is present.
|
|
|
|
void restrictLiquidProc(DFCoord coord, MapExtras::MapCache &map)
|
|
|
|
{
|
|
|
|
df::tile_designation des = map.designationAt(coord);
|
|
|
|
if ((des.bits.hidden == 0) && (des.bits.flow_size != 0))
|
|
|
|
{
|
|
|
|
des.bits.traffic = tile_traffic::Restricted;
|
|
|
|
map.setDesignationAt(coord, des);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Restrict traffice if tile is above visible ice wall.
|
|
|
|
void restrictIceProc(DFCoord coord, MapExtras::MapCache &map)
|
|
|
|
{
|
|
|
|
//There is no ice below the bottom of the map.
|
|
|
|
if (coord.z == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
DFCoord tile_below = DFCoord(coord.x, coord.y, coord.z - 1);
|
|
|
|
df::tiletype tt = map.tiletypeAt(tile_below);
|
|
|
|
df::tile_designation des = map.designationAt(tile_below);
|
|
|
|
|
|
|
|
if ((des.bits.hidden == 0) && (tileMaterial(tt) == tiletype_material::FROZEN_LIQUID))
|
|
|
|
{
|
|
|
|
des = map.designationAt(coord);
|
|
|
|
des.bits.traffic = tile_traffic::Restricted;
|
|
|
|
map.setDesignationAt(coord, des);
|
|
|
|
}
|
|
|
|
}
|