本文整理汇总了C++中mapextras::MapCache::trash方法的典型用法代码示例。如果您正苦于以下问题:C++ MapCache::trash方法的具体用法?C++ MapCache::trash怎么用?C++ MapCache::trash使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapextras::MapCache
的用法示例。
在下文中一共展示了MapCache::trash方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEmbarkTile
static command_result GetEmbarkTile(color_ostream &stream, const TileRequest *in, EmbarkTile *out)
{
MapExtras::MapCache MC;
gather_embark_tile(in->want_x() * 3, in->want_y() * 3, out, &MC);
MC.trash();
return CR_OK;
}
示例2: onDig
void onDig(color_ostream& out, void* ptr) {
CoreSuspender bob;
df::job* job = (df::job*)ptr;
if ( job->completion_timer > 0 )
return;
if ( job->job_type != df::enums::job_type::Dig &&
job->job_type != df::enums::job_type::CarveUpwardStaircase &&
job->job_type != df::enums::job_type::CarveDownwardStaircase &&
job->job_type != df::enums::job_type::CarveUpDownStaircase &&
job->job_type != df::enums::job_type::CarveRamp &&
job->job_type != df::enums::job_type::DigChannel )
return;
set<df::coord> jobLocations;
for ( df::job_list_link* link = &world->job_list; link != NULL; link = link->next ) {
if ( link->item == NULL )
continue;
if ( link->item->job_type != df::enums::job_type::Dig &&
link->item->job_type != df::enums::job_type::CarveUpwardStaircase &&
link->item->job_type != df::enums::job_type::CarveDownwardStaircase &&
link->item->job_type != df::enums::job_type::CarveUpDownStaircase &&
link->item->job_type != df::enums::job_type::CarveRamp &&
link->item->job_type != df::enums::job_type::DigChannel )
continue;
jobLocations.insert(link->item->pos);
}
MapExtras::MapCache cache;
df::coord pos = job->pos;
for ( int16_t a = -1; a <= 1; a++ ) {
for ( int16_t b = -1; b <= 1; b++ ) {
maybeExplore(out, cache, df::coord(pos.x+a,pos.y+b,pos.z), jobLocations);
}
}
cache.trash();
}
示例3: prospector
//.........这里部分代码省略.........
break;
case tiletype_material::LAVA_STONE:
// TODO ?
break;
default:
break;
}
}
}
// Check plants this way, as the other way wasn't getting them all
// and we can check visibility more easily here
if (showPlants)
{
auto block = Maps::getBlock(b_x,b_y,z);
stl::vector<df::plant *> *plants = block ? &block->plants : NULL;
if(plants)
{
for (auto it = plants->begin(); it != plants->end(); it++)
{
const df::plant & plant = *(*it);
df::coord2d loc(plant.pos.x, plant.pos.y);
loc = loc % 16;
if (showHidden || !b->DesignationAt(loc).bits.hidden)
{
if(plant.flags.bits.is_shrub)
plantMats[plant.plant_id].add(global_z);
else
treeMats[plant.wood_id].add(global_z);
}
}
}
}
// Block end
} // block x
// Clean uneeded memory
map.trash();
} // block y
} // z
MatMap::const_iterator it;
con << "Base materials:" << std::endl;
for (it = baseMats.begin(); it != baseMats.end(); ++it)
{
con << std::setw(25) << ENUM_KEY_STR(tiletype_material,(df::tiletype_material)it->first) << " : " << it->second.count << std::endl;
}
if (liquidWater.count || liquidMagma.count)
{
con << std::endl << "Liquids:" << std::endl;
if (liquidWater.count)
{
con << std::setw(25) << "WATER" << " : ";
printMatdata(con, liquidWater);
}
if (liquidWater.count)
{
con << std::setw(25) << "MAGMA" << " : ";
printMatdata(con, liquidMagma);
}
}
con << std::endl << "Layer materials:" << std::endl;
printMats<df::matgloss_stone, shallower>(con, layerMats, world->raws.matgloss.stone, showValue);
printVeins(con, veinMats, mats, showValue);
if (showPlants)
{
con << "Shrubs:" << std::endl;
printMats<df::matgloss_plant, std::greater>(con, plantMats, world->raws.matgloss.plant, showValue);
con << "Wood in trees:" << std::endl;
printMats<df::matgloss_wood, std::greater>(con, treeMats, world->raws.matgloss.wood, showValue);
}
if (hasAquifer)
{
con << "Has aquifer";
if (aquiferTiles.count)
{
con << " : ";
printMatdata(con, aquiferTiles);
}
else
con << std::endl;
}
if (showHFS && hfsTiles.count)
{
con << "Has HFS : ";
printMatdata(con, hfsTiles);
}
// Cleanup
mats->Finish();
con << std::endl;
return CR_OK;
}
示例4: prospector
//.........这里部分代码省略.........
}
}
}
// Check plants this way, as the other way wasn't getting them all
// and we can check visibility more easily here
if (showPlants)
{
auto block = Maps::getBlockColumn(b_x,b_y);
vector<df::plant *> *plants = block ? &block->plants : NULL;
if(plants)
{
for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++)
{
const df::plant & plant = *(*it);
if (plant.pos.z != z)
continue;
df::coord2d loc(plant.pos.x, plant.pos.y);
loc = loc % 16;
if (showHidden || !b->DesignationAt(loc).bits.hidden)
{
if(plant.flags.bits.is_shrub)
plantMats[plant.material].add(global_z);
else
treeMats[plant.material].add(global_z);
}
}
}
}
// Block end
} // block x
// Clean uneeded memory
map.trash();
} // block y
} // z
MatMap::const_iterator it;
con << "Base materials:" << std::endl;
for (it = baseMats.begin(); it != baseMats.end(); ++it)
{
con << std::setw(25) << ENUM_KEY_STR(tiletype_material,(df::tiletype_material)it->first) << " : " << it->second.count << std::endl;
}
if (liquidWater.count || liquidMagma.count)
{
con << std::endl << "Liquids:" << std::endl;
if (liquidWater.count)
{
con << std::setw(25) << "WATER" << " : ";
printMatdata(con, liquidWater);
}
if (liquidWater.count)
{
con << std::setw(25) << "MAGMA" << " : ";
printMatdata(con, liquidMagma);
}
}
con << std::endl << "Layer materials:" << std::endl;
printMats<df::inorganic_raw, shallower>(con, layerMats, world->raws.inorganics, showValue);
printVeins(con, veinMats, mats, showValue);
if (showPlants)
示例5: mapexport
//.........这里部分代码省略.........
// Skip hidden tiles
if (!showHidden && des.bits.hidden)
{
continue;
}
dfproto::Tile *prototile = protoblock.add_tile();
prototile->set_x(x);
prototile->set_y(y);
// Check for liquid
if (des.bits.flow_size)
{
prototile->set_liquid_type((dfproto::Tile::LiquidType)des.bits.liquid_type);
prototile->set_flow_size(des.bits.flow_size);
}
df::tiletype type = b->TileTypeAt(coord);
prototile->set_type((dfproto::Tile::TileType)tileShape(type));
prototile->set_tile_material((dfproto::Tile::TileMaterialType)tileMaterial(type));
df::coord map_pos = df::coord(b_x*16+x,b_y*16+y,z);
switch (tileMaterial(type))
{
case tiletype_material::SOIL:
case tiletype_material::STONE:
prototile->set_material_type(0);
prototile->set_material_index(b->baseMaterialAt(coord));
break;
case tiletype_material::MINERAL:
prototile->set_material_type(0);
prototile->set_material_index(b->veinMaterialAt(coord));
break;
case tiletype_material::FEATURE:
if (blockFeatureLocal.type != -1 && des.bits.feature_local)
{
if (blockFeatureLocal.type == feature_type::deep_special_tube
&& blockFeatureLocal.main_material == 0) // stone
{
prototile->set_material_type(0);
prototile->set_material_index(blockFeatureLocal.sub_material);
}
if (blockFeatureGlobal.type != -1 && des.bits.feature_global
&& blockFeatureGlobal.type == feature_type::feature_underworld_from_layer
&& blockFeatureGlobal.main_material == 0) // stone
{
prototile->set_material_type(0);
prototile->set_material_index(blockFeatureGlobal.sub_material);
}
}
break;
case tiletype_material::CONSTRUCTION:
if (constructionMaterials.find(map_pos) != constructionMaterials.end())
{
prototile->set_material_index(constructionMaterials[map_pos].first);
prototile->set_material_type(constructionMaterials[map_pos].second);
}
break;
default:
break;
}
}
}
PlantList *plants;
if (Maps::ReadVegetation(b_x, b_y, z, plants))
{
for (PlantList::const_iterator it = plants->begin(); it != plants->end(); it++)
{
const df::plant & plant = *(*it);
df::coord2d loc(plant.pos.x, plant.pos.y);
loc = loc % 16;
if (showHidden || !b->DesignationAt(loc).bits.hidden)
{
dfproto::Plant *protoplant = protoblock.add_plant();
protoplant->set_x(loc.x);
protoplant->set_y(loc.y);
protoplant->set_is_shrub(plant.flags.bits.is_shrub);
protoplant->set_material(plant.material);
}
}
}
coded_output->WriteVarint32(protoblock.ByteSize());
protoblock.SerializeToCodedStream(coded_output);
} // block x
// Clean uneeded memory
map.trash();
} // block y
} // z
delete coded_output;
delete zip_output;
delete raw_output;
mats->Finish();
out.print("\nMap succesfully exported!\n");
return CR_OK;
}