本文整理汇总了C++中mapextras::MapCache::setDesignationAt方法的典型用法代码示例。如果您正苦于以下问题:C++ MapCache::setDesignationAt方法的具体用法?C++ MapCache::setDesignationAt怎么用?C++ MapCache::setDesignationAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapextras::MapCache
的用法示例。
在下文中一共展示了MapCache::setDesignationAt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restrictLiquidProc
//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);
}
}
示例2: restrictIceProc
//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);
}
}
示例3: vdig
//.........这里部分代码省略.........
if(!DFHack::isWallTerrain(tt))
continue;
if(vmat2!=veinmat)
continue;
// found a good tile, dig+unset material
DFHack::t_designation des = MCache->designationAt(current);
DFHack::t_designation des_minus;
DFHack::t_designation des_plus;
des_plus.whole = des_minus.whole = 0;
int16_t vmat_minus = -1;
int16_t vmat_plus = -1;
bool below = 0;
bool above = 0;
if(updown)
{
if(MCache->testCoord(current-1))
{
below = 1;
des_minus = MCache->designationAt(current-1);
vmat_minus = MCache->veinMaterialAt(current-1);
}
if(MCache->testCoord(current+1))
{
above = 1;
des_plus = MCache->designationAt(current+1);
vmat_plus = MCache->veinMaterialAt(current+1);
}
}
if(MCache->testCoord(current))
{
MCache->clearMaterialAt(current);
if(current.x < tx_max - 2)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
}
if(current.y > 1)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y - 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y - 1,current.z));
}
}
if(current.x > 1)
{
flood.push(DFHack::DFCoord(current.x - 1, current.y,current.z));
if(current.y < ty_max - 2)
{
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
}
if(current.y > 1)
{
flood.push(DFHack::DFCoord(current.x - 1, current.y - 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y - 1,current.z));
}
}
if(updown)
{
if(current.z > 0 && below && vmat_minus == vmat2)
{
flood.push(current-1);
if(des_minus.bits.dig == DFHack::designation_d_stair)
des_minus.bits.dig = DFHack::designation_ud_stair;
else
des_minus.bits.dig = DFHack::designation_u_stair;
MCache->setDesignationAt(current-1,des_minus);
des.bits.dig = DFHack::designation_d_stair;
}
if(current.z < z_max - 1 && above && vmat_plus == vmat2)
{
flood.push(current+ 1);
if(des_plus.bits.dig == DFHack::designation_u_stair)
des_plus.bits.dig = DFHack::designation_ud_stair;
else
des_plus.bits.dig = DFHack::designation_d_stair;
MCache->setDesignationAt(current+1,des_plus);
if(des.bits.dig == DFHack::designation_d_stair)
des.bits.dig = DFHack::designation_ud_stair;
else
des.bits.dig = DFHack::designation_u_stair;
}
}
if(des.bits.dig == DFHack::designation_no)
des.bits.dig = DFHack::designation_default;
MCache->setDesignationAt(current,des);
}
}
MCache->WriteAll();
c->Resume();
return CR_OK;
}
示例4: digcircle
//.........这里部分代码省略.........
break;
}
if(isStairTerrain(tt) && type == designation_channel )
break;
return false;
}
while(0);
}
switch(what)
{
case circle_set:
if(des.bits.dig == designation_no)
{
des.bits.dig = type;
}
break;
case circle_unset:
if (des.bits.dig != designation_no)
{
des.bits.dig = designation_no;
}
case circle_invert:
if(des.bits.dig == designation_no)
{
des.bits.dig = type;
}
else
{
des.bits.dig = designation_no;
}
break;
}
std::cerr << "allowing tt" << tt << "\n";
MCache.setDesignationAt(at,des);
return true;
};
auto lineX = [&](int32_t y1, int32_t y2, int32_t x, int32_t z) -> bool
{
for(int32_t y = y1; y <= y2; y++)
{
dig(x,y,z);
}
return true;
};
auto lineY = [&](int32_t x1, int32_t x2, int32_t y, int32_t z) -> bool
{
for(int32_t x = x1; x <= x2; x++)
{
dig(x,y,z);
}
return true;
};
int r = diameter / 2;
int iter;
bool adjust;
if(diameter % 2)
{
// paint center
if(filled)
{
lineY(cx - r, cx + r, cy, cz);
}
else
{
dig(cx - r, cy, cz);
dig(cx + r, cy, cz);
示例5: expdig
//.........这里部分代码省略.........
int x = 0,mx = 16;
if(bx == 0)
x = 1;
if(bx == x_max - 1)
mx = 15;
for(; x < mx; x++)
{
int y = 0,my = 16;
if(by == 0)
y = 1;
if(by == y_max - 1)
my = 15;
for(; y < my; y++)
{
naked_designation & des = bl->designation[x][y].bits;
short unsigned int tt = bl->tiletype[x][y];
// could be potentially used to locate hidden constructions?
if(tileMaterial(tt) == CONSTRUCTED && !des.hidden)
continue;
if(!isWallTerrain(tt) && !des.hidden)
continue;
if(how == EXPLO_CLEAR)
{
des.dig = designation_no;
continue;
}
if(dm[y][x])
{
if(what == EXPLO_ALL
|| des.dig == designation_default && what == EXPLO_DESIGNATED
|| des.hidden && what == EXPLO_HIDDEN)
{
des.dig = designation_default;
}
}
else if(what == EXPLO_DESIGNATED)
{
des.dig = designation_no;
}
}
}
bl->flags.set(BLOCK_DESIGNATED);
return true;
};
if(how == EXPLO_DIAG5)
{
int which;
for(uint32_t x = 0; x < x_max; x++)
{
for(int32_t y = 0 ; y < y_max; y++)
{
which = (4*x + y) % 5;
apply(x,y_max - 1 - y,diag5[which]);
}
}
}
else if(how == EXPLO_LADDER)
{
int which;
for(uint32_t x = 0; x < x_max; x++)
{
which = x % 3;
for(int32_t y = 0 ; y < y_max; y++)
{
apply(x,y,ladder[which]);
}
}
}
else if(how == EXPLO_CROSS)
{
// middle + recentering for the image
int xmid = x_max * 8 - 8;
int ymid = y_max * 8 - 8;
MapExtras::MapCache mx (maps);
for(int x = 0; x < 16; x++)
for(int y = 0; y < 16; y++)
{
DFCoord pos(xmid+x,ymid+y,z_level);
short unsigned int tt = mx.tiletypeAt(pos);
if(tt == 0)
continue;
t_designation des = mx.designationAt(pos);
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
continue;
if(!isWallTerrain(tt) && !des.bits.hidden)
continue;
if(cross[y][x])
{
des.bits.dig = designation_default;
mx.setDesignationAt(pos,des);
}
}
mx.WriteAll();
}
else for(uint32_t x = 0; x < x_max; x++)
for(int32_t y = 0 ; y < y_max; y++)
apply(x,y,all_tiles);
c->Resume();
return CR_OK;
}
示例6: filltraffic
//.........这里部分代码省略.........
source = des.bits.traffic;
if(source == target)
{
c->con.printerr("This tile is already set to the target traffic type.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
if(DFHack::isWallTerrain(tt))
{
c->con.printerr("This tile is a wall. Please select a passable tile.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
if(checkpit && DFHack::isOpenTerrain(tt))
{
c->con.printerr("This tile is a hole. Please select a passable tile.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
if(checkbuilding && oc.bits.building)
{
c->con.printerr("This tile contains a building. Please select an empty tile.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
c->con.print("%d/%d/%d ... FILLING!\n", cx,cy,cz);
//Naive four-way or six-way flood fill with possible tiles on a stack.
stack <DFHack::DFCoord> flood;
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);
if(DFHack::isWallTerrain(tt)) continue;
if(checkpit && DFHack::isOpenTerrain(tt)) continue;
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)
{
flood.push(DFHack::DFCoord(xy.x - 1, xy.y, xy.z));
}
if (xy.x < tx_max - 1)
{
flood.push(DFHack::DFCoord(xy.x + 1, xy.y, xy.z));
}
if (xy.y > 0)
{
flood.push(DFHack::DFCoord(xy.x, xy.y - 1, xy.z));
}
if (xy.y < ty_max - 1)
{
flood.push(DFHack::DFCoord(xy.x, xy.y + 1, xy.z));
}
if (updown)
{
if (xy.z > 0 && DFHack::LowPassable(tt))
{
flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z - 1));
}
if (xy.z < z_max && DFHack::HighPassable(tt))
{
flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z + 1));
}
}
}
}
MCache->WriteAll();
c->Resume();
return CR_OK;
}
示例7: tiletraffic
DFhackCExport command_result tiletraffic(DFHack::Core * c, std::vector<std::string> & params)
{
//Target traffic types.
e_traffic target = traffic_normal;
//!!! Options Later !!!
//Loop through parameters
for(int i = 0; i < params.size();i++)
{
if(params[i] == "help" || params[i] == "?")
{
c->con.print("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"
);
return CR_OK;
}
switch (toupper(params[i][0]))
{
case 'H':
target = traffic_high; break;
case 'N':
target = traffic_normal; break;
case 'L':
target = traffic_low; break;
case 'R':
target = traffic_restricted; break;
}
}
//Initialization.
c->Suspend();
DFHack::Maps * Maps = c->getMaps();
DFHack::Gui * Gui = c->getGui();
// init the map
if(!Maps->Start())
{
c->con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
c->Resume();
return CR_FAILURE;
}
//Maximum map size.
uint32_t x_max,y_max,z_max;
Maps->getSize(x_max,y_max,z_max);
uint32_t tx_max = x_max * 16;
uint32_t ty_max = y_max * 16;
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
c->con.print("Entire map ... FILLING!\n");
//Loop through every single tile
for(uint32_t x = 0; x <= tx_max; x++)
{
for(uint32_t y = 0; y <= ty_max; y++)
{
for(uint32_t z = 0; z <= z_max; z++)
{
DFHack::DFCoord tile = DFHack::DFCoord(x, y, z);
DFHack::t_designation des = MCache->designationAt(tile);
des.bits.traffic = target;
MCache->setDesignationAt(tile, des);
}
}
}
MCache->WriteAll();
c->Resume();
return CR_OK;
}
示例8: vdig
//.........这里部分代码省略.........
tt = MCache->tiletypeAt(current);
if(!DFHack::isWallTerrain(tt))
continue;
if(vmat2!=veinmat)
continue;
// found a good tile, dig+unset material
df::tile_designation des = MCache->designationAt(current);
df::tile_designation des_minus;
df::tile_designation des_plus;
des_plus.whole = des_minus.whole = 0;
int16_t vmat_minus = -1;
int16_t vmat_plus = -1;
bool below = 0;
bool above = 0;
if(updown)
{
if(MCache->testCoord(current-1))
{
below = 1;
des_minus = MCache->designationAt(current-1);
vmat_minus = MCache->veinMaterialAt(current-1);
}
if(MCache->testCoord(current+1))
{
above = 1;
des_plus = MCache->designationAt(current+1);
vmat_plus = MCache->veinMaterialAt(current+1);
}
}
if(MCache->testCoord(current))
{
MCache->clearMaterialAt(current);
if(current.x < tx_max - 2)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y, current.z));
if(current.y < ty_max - 2)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
}
if(current.y > 1)
{
flood.push(DFHack::DFCoord(current.x + 1, current.y - 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y - 1,current.z));
}
}
if(current.x > 1)
{
flood.push(DFHack::DFCoord(current.x - 1, current.y,current.z));
if(current.y < ty_max - 2)
{
flood.push(DFHack::DFCoord(current.x - 1, current.y + 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y + 1,current.z));
}
if(current.y > 1)
{
flood.push(DFHack::DFCoord(current.x - 1, current.y - 1,current.z));
flood.push(DFHack::DFCoord(current.x, current.y - 1,current.z));
}
}
if(updown)
{
if(current.z > 0 && below && vmat_minus == vmat2)
{
flood.push(current-1);
if(des_minus.bits.dig == tile_dig_designation::DownStair)
des_minus.bits.dig = tile_dig_designation::UpDownStair;
else
des_minus.bits.dig = tile_dig_designation::UpStair;
MCache->setDesignationAt(current-1,des_minus);
des.bits.dig = tile_dig_designation::DownStair;
}
if(current.z < z_max - 1 && above && vmat_plus == vmat2)
{
flood.push(current+ 1);
if(des_plus.bits.dig == tile_dig_designation::UpStair)
des_plus.bits.dig = tile_dig_designation::UpDownStair;
else
des_plus.bits.dig = tile_dig_designation::DownStair;
MCache->setDesignationAt(current+1,des_plus);
if(des.bits.dig == tile_dig_designation::DownStair)
des.bits.dig = tile_dig_designation::UpDownStair;
else
des.bits.dig = tile_dig_designation::UpStair;
}
}
if(des.bits.dig == tile_dig_designation::No)
des.bits.dig = tile_dig_designation::Default;
MCache->setDesignationAt(current,des);
}
}
MCache->WriteAll();
return CR_OK;
}
示例9: expdig
//.........这里部分代码省略.........
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
Maps::getSize(x_max,y_max,z_max);
int32_t xzzz,yzzz,z_level;
if(!Gui::getViewCoords(xzzz,yzzz,z_level))
{
c->con.printerr("Can't get view coords...\n");
return CR_FAILURE;
}
if(how == EXPLO_DIAG5)
{
int which;
for(uint32_t x = 0; x < x_max; x++)
{
for(int32_t y = 0 ; y < y_max; y++)
{
which = (4*x + y) % 5;
stamp_pattern(x,y_max - 1 - y, z_level, diag5[which],
how, what, x_max, y_max);
}
}
}
else if(how == EXPLO_DIAG5R)
{
int which;
for(uint32_t x = 0; x < x_max; x++)
{
for(int32_t y = 0 ; y < y_max; y++)
{
which = (4*x + 1000-y) % 5;
stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which],
how, what, x_max, y_max);
}
}
}
else if(how == EXPLO_LADDER)
{
int which;
for(uint32_t x = 0; x < x_max; x++)
{
which = x % 3;
for(int32_t y = 0 ; y < y_max; y++)
{
stamp_pattern(x, y, z_level, ladder[which],
how, what, x_max, y_max);
}
}
}
else if(how == EXPLO_LADDERR)
{
int which;
for(int32_t y = 0 ; y < y_max; y++)
{
which = y % 3;
for(uint32_t x = 0; x < x_max; x++)
{
stamp_pattern(x, y, z_level, ladderr[which],
how, what, x_max, y_max);
}
}
}
else if(how == EXPLO_CROSS)
{
// middle + recentering for the image
int xmid = x_max * 8 - 8;
int ymid = y_max * 8 - 8;
MapExtras::MapCache mx;
for(int x = 0; x < 16; x++)
for(int y = 0; y < 16; y++)
{
DFCoord pos(xmid+x,ymid+y,z_level);
df::tiletype tt = mx.tiletypeAt(pos);
if(tt == tiletype::Void)
continue;
df::tile_designation des = mx.designationAt(pos);
if(tileMaterial(tt) == tiletype_material::CONSTRUCTION && !des.bits.hidden)
continue;
if(!isWallTerrain(tt) && !des.bits.hidden)
continue;
if(cross[y][x])
{
des.bits.dig = tile_dig_designation::Default;
mx.setDesignationAt(pos,des);
}
}
mx.WriteAll();
}
else for(uint32_t x = 0; x < x_max; x++)
{
for(int32_t y = 0 ; y < y_max; y++)
{
stamp_pattern(x, y, z_level, all_tiles,
how, what, x_max, y_max);
}
}
return CR_OK;
}
示例10: dig
bool dig (MapExtras::MapCache & MCache,
circle_what what,
df::tile_dig_designation type,
int32_t x, int32_t y, int32_t z,
int x_max, int y_max
)
{
DFCoord at (x,y,z);
auto b = MCache.BlockAt(at/16);
if(!b || !b->valid)
return false;
if(x == 0 || x == x_max * 16 - 1)
{
//c->con.print("not digging map border\n");
return false;
}
if(y == 0 || y == y_max * 16 - 1)
{
//c->con.print("not digging map border\n");
return false;
}
df::tiletype tt = MCache.tiletypeAt(at);
df::tile_designation des = MCache.designationAt(at);
// could be potentially used to locate hidden constructions?
if(tileMaterial(tt) == df::tiletype_material::CONSTRUCTION && !des.bits.hidden)
return false;
df::tiletype_shape ts = tileShape(tt);
if (ts == tiletype_shape::EMPTY)
return false;
if(!des.bits.hidden)
{
do
{
df::tiletype_shape_basic tsb = ENUM_ATTR(tiletype_shape, basic_shape, ts);
if(tsb == tiletype_shape_basic::Wall)
{
std::cerr << "allowing tt" << (int)tt << ", is wall\n";
break;
}
if (tsb == tiletype_shape_basic::Floor
&& (type == tile_dig_designation::DownStair || type == tile_dig_designation::Channel)
&& ts != tiletype_shape::TREE
)
{
std::cerr << "allowing tt" << (int)tt << ", is floor\n";
break;
}
if (tsb == tiletype_shape_basic::Stair && type == tile_dig_designation::Channel )
break;
return false;
}
while(0);
}
switch(what)
{
case circle_set:
if(des.bits.dig == tile_dig_designation::No)
{
des.bits.dig = type;
}
break;
case circle_unset:
if (des.bits.dig != tile_dig_designation::No)
{
des.bits.dig = tile_dig_designation::No;
}
break;
case circle_invert:
if(des.bits.dig == tile_dig_designation::No)
{
des.bits.dig = type;
}
else
{
des.bits.dig = tile_dig_designation::No;
}
break;
}
std::cerr << "allowing tt" << (int)tt << "\n";
MCache.setDesignationAt(at,des);
return true;
};
示例11: filltraffic
//.........这里部分代码省略.........
MapExtras::MapCache MCache;
df::tile_designation des = MCache.designationAt(xy);
df::tiletype tt = MCache.tiletypeAt(xy);
df::tile_occupancy oc;
if (checkbuilding)
oc = MCache.occupancyAt(xy);
source = (df::tile_traffic)des.bits.traffic;
if(source == target)
{
out.printerr("This tile is already set to the target traffic type.\n");
return CR_FAILURE;
}
if(isWallTerrain(tt))
{
out.printerr("This tile is a wall. Please select a passable tile.\n");
return CR_FAILURE;
}
if(checkpit && isOpenTerrain(tt))
{
out.printerr("This tile is a hole. Please select a passable tile.\n");
return CR_FAILURE;
}
if(checkbuilding && oc.bits.building)
{
out.printerr("This tile contains a building. Please select an empty tile.\n");
return CR_FAILURE;
}
out.print("%d/%d/%d ... FILLING!\n", cx,cy,cz);
//Naive four-way or six-way flood fill with possible tiles on a stack.
stack <DFCoord> flood;
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);
if(isWallTerrain(tt)) continue;
if(checkpit && isOpenTerrain(tt)) continue;
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)
{
flood.push(DFCoord(xy.x - 1, xy.y, xy.z));
}
if (xy.x < int32_t(tx_max) - 1)
{
flood.push(DFCoord(xy.x + 1, xy.y, xy.z));
}
if (xy.y > 0)
{
flood.push(DFCoord(xy.x, xy.y - 1, xy.z));
}
if (xy.y < int32_t(ty_max) - 1)
{
flood.push(DFCoord(xy.x, xy.y + 1, xy.z));
}
if (updown)
{
if (xy.z > 0 && LowPassable(tt))
{
flood.push(DFCoord(xy.x, xy.y, xy.z - 1));
}
if (xy.z < int32_t(z_max) && HighPassable(tt))
{
flood.push(DFCoord(xy.x, xy.y, xy.z + 1));
}
}
}
}
MCache.WriteAll();
return CR_OK;
}
示例12: allRestricted
void allRestricted(DFCoord coord, MapExtras::MapCache &map)
{
df::tile_designation des = map.designationAt(coord);
des.bits.traffic = tile_traffic::Restricted;
map.setDesignationAt(coord, des);
}
示例13: allNormal
void allNormal(DFCoord coord, MapExtras::MapCache &map)
{
df::tile_designation des = map.designationAt(coord);
des.bits.traffic = tile_traffic::Normal;
map.setDesignationAt(coord, des);
}