本文整理汇总了C++中mapextras::MapCache::tiletypeAt方法的典型用法代码示例。如果您正苦于以下问题:C++ MapCache::tiletypeAt方法的具体用法?C++ MapCache::tiletypeAt怎么用?C++ MapCache::tiletypeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapextras::MapCache
的用法示例。
在下文中一共展示了MapCache::tiletypeAt方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: df_grow
command_result df_grow (color_ostream &out, vector <string> & parameters)
{
for(size_t i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
{
out << "Usage:\n"
"This command turns all living saplings on the map into full-grown trees.\n"
"With active cursor, work on the targetted one only.\n";
return CR_OK;
}
}
CoreSuspender suspend;
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
MapExtras::MapCache map;
int32_t x,y,z;
if(Gui::getCursorCoords(x,y,z))
{
auto block = Maps::getTileBlock(x,y,z);
stl::vector<df::plant *> *alltrees = &world->plants.all;
if(alltrees)
{
for(size_t i = 0 ; i < alltrees->size(); i++)
{
df::plant * tree = alltrees->at(i);
if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z)
{
if(tileShape(map.tiletypeAt(DFCoord(x,y,z))) == tiletype_shape::SAPLING &&
tileSpecial(map.tiletypeAt(DFCoord(x,y,z))) != tiletype_special::DEAD)
{
tree->grow_counter = sapling_to_tree_threshold;
}
break;
}
}
}
}
else
{
int grown = 0;
for(size_t i = 0 ; i < world->plants.all.size(); i++)
{
df::plant *p = world->plants.all[i];
df::tiletype ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z));
bool is_shrub = p->flags >= plant_flags::shrub_forest;
if(!is_shrub && tileShape(ttype) == tiletype_shape::SAPLING && tileSpecial(ttype) != tiletype_special::DEAD)
{
p->grow_counter = sapling_to_tree_threshold;
}
}
}
return CR_OK;
}
示例2: df_grow
command_result df_grow (color_ostream &out, vector <string> & parameters)
{
for(size_t i = 0; i < parameters.size();i++)
{
if(parameters[i] == "help" || parameters[i] == "?")
{
out.print("This command turns all living saplings into full-grown trees.\n");
return CR_OK;
}
}
CoreSuspender suspend;
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
MapExtras::MapCache map;
int32_t x,y,z;
if(Gui::getCursorCoords(x,y,z))
{
vector<df::plant *> * alltrees;
if(Maps::ReadVegetation(x/16,y/16,z,alltrees))
{
for(size_t i = 0 ; i < alltrees->size(); i++)
{
df::plant * tree = alltrees->at(i);
if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z)
{
if(tileShape(map.tiletypeAt(DFCoord(x,y,z))) == tiletype_shape::SAPLING &&
tileSpecial(map.tiletypeAt(DFCoord(x,y,z))) != tiletype_special::DEAD)
{
tree->grow_counter = Vegetation::sapling_to_tree_threshold;
}
break;
}
}
}
}
else
{
int grown = 0;
for(size_t i = 0 ; i < world->plants.all.size(); i++)
{
df::plant *p = world->plants.all[i];
df::tiletype ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z));
if(!p->flags.bits.is_shrub && tileShape(ttype) == tiletype_shape::SAPLING && tileSpecial(ttype) != tiletype_special::DEAD)
{
p->grow_counter = Vegetation::sapling_to_tree_threshold;
}
}
}
return CR_OK;
}
示例3: 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);
}
}
示例4: vdig
DFhackCExport command_result vdig (Core * c, vector <string> & parameters)
{
uint32_t x_max,y_max,z_max;
bool updown = false;
for(int i = 0; i < parameters.size();i++)
{
if(parameters.size() && parameters[0]=="x")
updown = true;
else if(parameters[i] == "help" || parameters[i] == "?")
{
c->con.print("Designates a whole vein under the cursor for digging.\n"
"Options:\n"
"x - follow veins through z-levels with stairs.\n"
);
return CR_OK;
}
}
Console & con = c->con;
c->Suspend();
DFHack::Maps * Maps = c->getMaps();
DFHack::Gui * Gui = c->getGui();
// init the map
if(!Maps->Start())
{
con.printerr("Can't init map. Make sure you have a map loaded in DF.\n");
c->Resume();
return CR_FAILURE;
}
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;
Gui->getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
con.printerr("Cursor is not active. Point the cursor at a vein.\n");
c->Resume();
return CR_FAILURE;
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
{
con.printerr("I won't dig the borders. That would be cheating!\n");
c->Resume();
return CR_FAILURE;
}
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
DFHack::t_designation des = MCache->designationAt(xy);
int16_t tt = MCache->tiletypeAt(xy);
int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 )
{
con.printerr("This tile is not a vein.\n");
delete MCache;
c->Resume();
return CR_FAILURE;
}
con.print("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <DFHack::DFCoord> flood;
flood.push(xy);
while( !flood.empty() )
{
DFHack::DFCoord current = flood.top();
flood.pop();
int16_t vmat2 = MCache->veinMaterialAt(current);
tt = MCache->tiletypeAt(current);
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);
}
}
//.........这里部分代码省略.........
示例5: digcircle
//.........这里部分代码省略.........
if(!maps->Start())
{
c->Resume();
c->con.printerr("Can't init the map...\n");
return CR_FAILURE;
}
uint32_t x_max, y_max, z_max;
maps->getSize(x_max,y_max,z_max);
MapExtras::MapCache MCache (maps);
if(!gui->getCursorCoords(cx,cy,cz) || cx == -30000)
{
c->Resume();
c->con.printerr("Can't get the cursor coords...\n");
return CR_FAILURE;
}
auto dig = [&](int32_t x, int32_t y, int32_t z) -> bool
{
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;
}
uint16_t tt = MCache.tiletypeAt(at);
t_designation des = MCache.designationAt(at);
// could be potentially used to locate hidden constructions?
if(tileMaterial(tt) == CONSTRUCTED && !des.bits.hidden)
return false;
TileShape ts = tileShape(tt);
if(ts == EMPTY)
return false;
if(!des.bits.hidden)
{
do
{
if(isWallTerrain(tt))
{
std::cerr << "allowing tt" << tt << ", is wall\n";
break;
}
if(isFloorTerrain(tt)
&& (type == designation_d_stair || type == designation_channel)
&& ts != TREE_OK
&& ts != TREE_DEAD
)
{
std::cerr << "allowing tt" << tt << ", is floor\n";
break;
}
if(isStairTerrain(tt) && type == designation_channel )
break;
return false;
}
while(0);
}
switch(what)
示例6: 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;
}
示例7: filltraffic
DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector<std::string> & params)
{
//Maximum map size.
uint32_t x_max,y_max,z_max;
//Source and target traffic types.
e_traffic source = traffic_normal;
e_traffic target = traffic_normal;
//Option flags
bool updown = false;
bool checkpit = true;
bool checkbuilding = true;
//Loop through parameters
for(int i = 0; i < params.size();i++)
{
if(params[i] == "help" || params[i] == "?")
{
c->con.print("Flood-fill selected traffic type from the cursor.\n"
"Traffic Type Codes:\n"
"\tH: High Traffic\n"
"\tN: Normal Traffic\n"
"\tL: Low Traffic\n"
"\tR: Restricted Traffic\n"
"Other Options:\n"
"\tX: Fill accross z-levels.\n"
"\tB: Include buildings and stockpiles.\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;
}
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;
case 'X':
updown = true; break;
case 'B':
checkbuilding = false; break;
case 'P':
checkpit = false; 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;
}
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;
Gui->getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
c->con.printerr("Cursor is not active.\n");
c->Resume();
return CR_FAILURE;
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
MapExtras::MapCache * MCache = new MapExtras::MapCache(Maps);
DFHack::t_designation des = MCache->designationAt(xy);
int16_t tt = MCache->tiletypeAt(xy);
DFHack::t_occupancy oc;
if (checkbuilding)
oc = MCache->occupancyAt(xy);
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");
//.........这里部分代码省略.........
示例8: vdig
command_result vdig (Core * c, vector <string> & parameters)
{
// HOTKEY COMMAND: CORE ALREADY SUSPENDED
uint32_t x_max,y_max,z_max;
bool updown = false;
for(size_t i = 0; i < parameters.size();i++)
{
if(parameters.size() && parameters[0]=="x")
updown = true;
else
return CR_WRONG_USAGE;
}
Console & con = c->con;
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
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;
Gui::getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
con.printerr("Cursor is not active. Point the cursor at a vein.\n");
return CR_FAILURE;
}
DFHack::DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
if(xy.x == 0 || xy.x == tx_max - 1 || xy.y == 0 || xy.y == ty_max - 1)
{
con.printerr("I won't dig the borders. That would be cheating!\n");
return CR_FAILURE;
}
MapExtras::MapCache * MCache = new MapExtras::MapCache;
df::tile_designation des = MCache->designationAt(xy);
df::tiletype tt = MCache->tiletypeAt(xy);
int16_t veinmat = MCache->veinMaterialAt(xy);
if( veinmat == -1 )
{
con.printerr("This tile is not a vein.\n");
delete MCache;
return CR_FAILURE;
}
con.print("%d/%d/%d tiletype: %d, veinmat: %d, designation: 0x%x ... DIGGING!\n", cx,cy,cz, tt, veinmat, des.whole);
stack <DFHack::DFCoord> flood;
flood.push(xy);
while( !flood.empty() )
{
DFHack::DFCoord current = flood.top();
flood.pop();
int16_t vmat2 = MCache->veinMaterialAt(current);
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)
{
//.........这里部分代码省略.........
示例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: df_probe
command_result df_probe (color_ostream &out, vector <string> & parameters)
{
//bool showBlock, showDesig, showOccup, showTile, showMisc;
/*
if (!parseOptions(parameters, showBlock, showDesig, showOccup,
showTile, showMisc))
{
out.printerr("Unknown parameters!\n");
return CR_FAILURE;
}
*/
CoreSuspender suspend;
DFHack::Materials *Materials = Core::getInstance().getMaterials();
std::vector<t_matglossInorganic> inorganic;
bool hasmats = Materials->CopyInorganicMaterials(inorganic);
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
MapExtras::MapCache mc;
int32_t regionX, regionY, regionZ;
Maps::getPosition(regionX,regionY,regionZ);
int32_t cursorX, cursorY, cursorZ;
Gui::getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX == -30000)
{
out.printerr("No cursor; place cursor over tile to probe.\n");
return CR_FAILURE;
}
DFCoord cursor (cursorX,cursorY,cursorZ);
uint32_t blockX = cursorX / 16;
uint32_t tileX = cursorX % 16;
uint32_t blockY = cursorY / 16;
uint32_t tileY = cursorY % 16;
MapExtras::Block * b = mc.BlockAt(cursor/16);
if(!b || !b->is_valid())
{
out.printerr("No data.\n");
return CR_OK;
}
auto &block = *b->getRaw();
out.print("block addr: 0x%x\n\n", &block);
/*
if (showBlock)
{
out.print("block flags:\n");
print_bits<uint32_t>(block.blockflags.whole,out);
out.print("\n\n");
}
*/
df::tiletype tiletype = mc.tiletypeAt(cursor);
df::tile_designation &des = block.designation[tileX][tileY];
df::tile_occupancy &occ = block.occupancy[tileX][tileY];
/*
if(showDesig)
{
out.print("designation\n");
print_bits<uint32_t>(block.designation[tileX][tileY].whole,
out);
out.print("\n\n");
}
if(showOccup)
{
out.print("occupancy\n");
print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,
out);
out.print("\n\n");
}
*/
// tiletype
out.print("tiletype: ");
describeTile(out, tiletype);
out.print("static: ");
describeTile(out, mc.staticTiletypeAt(cursor));
out.print("base: ");
describeTile(out, mc.baseTiletypeAt(cursor));
out.print("temperature1: %d U\n",mc.temperature1At(cursor));
out.print("temperature2: %d U\n",mc.temperature2At(cursor));
int offset = block.region_offset[des.bits.biome];
int bx = clip_range(block.region_pos.x + (offset % 3) - 1, 0, world->world_data->world_width-1);
int by = clip_range(block.region_pos.y + (offset / 3) - 1, 0, world->world_data->world_height-1);
auto biome = &world->world_data->region_map[bx][by];
int sav = biome->savagery;
//.........这里部分代码省略.........
示例12: drawBuffer
void Offscreen::drawBuffer( rect2d window,int z,std::vector<screenTile>& buffer )
{
if(!df::global::world)
return;
//TODO static array of images for each tiletype
MapExtras::MapCache cache;
int w=window.second.x-window.first.x;
int h=window.second.y-window.first.y;
rect2d localWindow=mkrect_wh(0,0,w+1,h+1);
if(buffer.size()!=w*h)
buffer.resize(w*h);
//basic tiletype stuff here
for(int x=window.first.x;x<window.second.x;x++) //todo, make it by block, minimal improvement over cache prob though
for(int y=window.first.y;y<window.second.y;y++)
{
DFCoord coord(x,y,z);
df::tiletype tt=cache.tiletypeAt(coord);
df::tiletype_shape shape = ENUM_ATTR(tiletype,shape,tt);
df::tiletype_shape_basic basic_shape = ENUM_ATTR(tiletype_shape, basic_shape, shape);
t_matpair mat=cache.staticMaterialAt(coord);
df::tiletype_material tileMat= ENUM_ATTR(tiletype,material,tt);
df::tile_designation d=cache.designationAt(coord);
df::tile_occupancy o=cache.occupancyAt(coord);
df::tiletype_special sp=ENUM_ATTR(tiletype,special,tt);
int wx=x-window.first.x;
int wy=y-window.first.y;
screenTile& curTile=buffer[wx*h+wy];
if(d.bits.hidden)
{
curTile.tile=0;
continue;
}
if(shape==df::tiletype_shape::EMPTY || shape==df::tiletype_shape::RAMP_TOP)
{
//empty,liquids and '.' for other stuff...
DFCoord coord2(x,y,z-1);
df::tiletype tt2=cache.tiletypeAt(coord2);
df::tiletype_shape shape2 = ENUM_ATTR(tiletype,shape,tt);
df::tiletype_material tileMat2= ENUM_ATTR(tiletype,material,tt2);
df::tile_designation d2=cache.designationAt(coord2);
df::tiletype_special sp2=ENUM_ATTR(tiletype,special,tt2);
bool unDug2= (sp2!=df::tiletype_special::SMOOTH && shape2==df::tiletype_shape::WALL);
if (d2.bits.flow_size>0)
{
if(shape!=df::tiletype_shape::RAMP_TOP) //don't show liquid amount on ramp tops
curTile.tile='0'+d2.bits.flow_size; //TODO lookup setting for this
else
curTile.tile=tilePics[tt];
curTile.fg=(d2.bits.liquid_type)?(COLOR_RED):(COLOR_BLUE);
continue;
}
else if(shape2==df::tiletype_shape::EMPTY)
{
curTile.tile=178; //look up settings
curTile.fg=COLOR_CYAN;
continue;
}
else
{
if(shape==df::tiletype_shape::RAMP_TOP)
curTile.tile=tilePics[tt];
else
curTile.tile='.';
colorTile(tileMat2,cache,coord2,curTile,unDug2);
continue;
}
}
bool inliquid=false;
bool unDug= (sp!=df::tiletype_special::SMOOTH && shape==df::tiletype_shape::WALL);
if (d.bits.flow_size>0)
{
curTile.tile='0'+d.bits.flow_size;
curTile.fg=(d.bits.liquid_type)?(COLOR_RED):(COLOR_BLUE);
curTile.bold=true;
inliquid=true;
}
if(!inliquid && shape!=df::tiletype_shape::RAMP_TOP)
{
curTile.tile=tilePics[tt];
colorTile(tileMat,cache,coord,curTile,unDug);
if(!unDug)
{
curTile.bg=0;
}
}
else
{
if(shape==df::tiletype_shape::RAMP || shape==df::tiletype_shape::BROOK_BED || shape==df::tiletype_shape::RAMP_TOP)
curTile.tile=tilePics[tt];
if(!inliquid)
colorTile(tileMat,cache,coord,curTile,true);
}
}
//plants
for(int bx=window.first.x/16;bx<=window.second.x/16;bx++) //blocks have items by id. So yeah each item a search would be slow
for(int by=window.first.y/16;by<=window.second.y/16;by++)
//.........这里部分代码省略.........
示例13: df_probe
command_result df_probe (Core * c, vector <string> & parameters)
{
//bool showBlock, showDesig, showOccup, showTile, showMisc;
Console & con = c->con;
/*
if (!parseOptions(parameters, showBlock, showDesig, showOccup,
showTile, showMisc))
{
con.printerr("Unknown parameters!\n");
return CR_FAILURE;
}
*/
CoreSuspender suspend(c);
DFHack::Gui *Gui = c->getGui();
DFHack::Materials *Materials = c->getMaterials();
DFHack::VersionInfo* mem = c->vinfo;
std::vector<t_matglossInorganic> inorganic;
bool hasmats = Materials->CopyInorganicMaterials(inorganic);
if (!Maps::IsValid())
{
c->con.printerr("Map is not available!\n");
return CR_FAILURE;
}
MapExtras::MapCache mc;
int32_t regionX, regionY, regionZ;
Maps::getPosition(regionX,regionY,regionZ);
int32_t cursorX, cursorY, cursorZ;
Gui->getCursorCoords(cursorX,cursorY,cursorZ);
if(cursorX == -30000)
{
con.printerr("No cursor; place cursor over tile to probe.\n");
return CR_FAILURE;
}
DFCoord cursor (cursorX,cursorY,cursorZ);
uint32_t blockX = cursorX / 16;
uint32_t tileX = cursorX % 16;
uint32_t blockY = cursorY / 16;
uint32_t tileY = cursorY % 16;
MapExtras::Block * b = mc.BlockAt(cursor/16);
if(!b && !b->valid)
{
con.printerr("No data.\n");
return CR_OK;
}
mapblock40d & block = b->raw;
con.print("block addr: 0x%x\n\n", block.origin);
/*
if (showBlock)
{
con.print("block flags:\n");
print_bits<uint32_t>(block.blockflags.whole,con);
con.print("\n\n");
}
*/
df::tiletype tiletype = mc.tiletypeAt(cursor);
df::tile_designation &des = block.designation[tileX][tileY];
/*
if(showDesig)
{
con.print("designation\n");
print_bits<uint32_t>(block.designation[tileX][tileY].whole,
con);
con.print("\n\n");
}
if(showOccup)
{
con.print("occupancy\n");
print_bits<uint32_t>(block.occupancy[tileX][tileY].whole,
con);
con.print("\n\n");
}
*/
// tiletype
con.print("tiletype: %d", tiletype);
if(tileName(tiletype))
con.print(" = %s",tileName(tiletype));
con.print("\n");
df::tiletype_shape shape = tileShape(tiletype);
df::tiletype_material material = tileMaterial(tiletype);
df::tiletype_special special = tileSpecial(tiletype);
df::tiletype_variant variant = tileVariant(tiletype);
con.print("%-10s: %4d %s\n","Class" ,shape,
ENUM_KEY_STR(tiletype_shape, shape));
con.print("%-10s: %4d %s\n","Material" ,
material, ENUM_KEY_STR(tiletype_material, material));
con.print("%-10s: %4d %s\n","Special" ,
special, ENUM_KEY_STR(tiletype_special, special));
con.print("%-10s: %4d %s\n" ,"Variant" ,
variant, ENUM_KEY_STR(tiletype_variant, variant));
con.print("%-10s: %s\n" ,"Direction",
//.........这里部分代码省略.........
示例14: filltraffic
command_result filltraffic(color_ostream &out, std::vector<std::string> & params)
{
// HOTKEY COMMAND; CORE ALREADY SUSPENDED
//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
for(size_t i = 0; i < params.size();i++)
{
if (params[i] == "help" || params[i] == "?" || params[i].size() != 1)
return CR_WRONG_USAGE;
switch (toupper(params[i][0]))
{
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;
default:
return CR_WRONG_USAGE;
}
}
if (!Maps::IsValid())
{
out.printerr("Map is not available!\n");
return CR_FAILURE;
}
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;
Gui::getCursorCoords(cx,cy,cz);
while(cx == -30000)
{
out.printerr("Cursor is not active.\n");
return CR_FAILURE;
}
DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz);
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())
//.........这里部分代码省略.........