当前位置: 首页>>代码示例>>C++>>正文


C++ MapCache::trash方法代码示例

本文整理汇总了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;
}
开发者ID:Alloyed,项目名称:dfhack,代码行数:7,代码来源:isoworldremote.cpp

示例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();
}
开发者ID:Dimble,项目名称:dfhack,代码行数:39,代码来源:digFlood.cpp

示例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;
}
开发者ID:mstram,项目名称:dfhack-40d,代码行数:101,代码来源:prospector.cpp

示例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)
开发者ID:Pheosics,项目名称:dfhack,代码行数:67,代码来源:prospector.cpp

示例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;
}
开发者ID:AnnanFay,项目名称:dfhack,代码行数:101,代码来源:mapexport.cpp


注:本文中的mapextras::MapCache::trash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。