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


C++ Lines::find方法代码示例

本文整理汇总了C++中Lines::find方法的典型用法代码示例。如果您正苦于以下问题:C++ Lines::find方法的具体用法?C++ Lines::find怎么用?C++ Lines::find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lines的用法示例。


在下文中一共展示了Lines::find方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load_from_lemmini

void Level::load_from_lemmini(const Filename& filename)
{
    typedef std::map <std::string, LemminiLine> Lines;
    Lines lines;

    std::ifstream file(filename.get_rootful().c_str());
    if (! file.good()) {
        status = BAD_FILE_NOT_FOUND;
        return;
    }

    // safely parse into lines, see other/file/io.cpp for comments.
    // ignore lines starting with #.
    std::string s;
    char        c;
    while (file.get(c)) {
        if (c != '\n' && c != '\r') s += c;
        else if (! s.empty()) {
            if (s[0] != '#') {
                LemminiLine ll(s);
                lines[ll.name] = ll;
            }
            s.clear();
        }
    }
    // No newline at end of file shall not matter
    if (! s.empty() && s[0] != '#') {
        LemminiLine ll(s);
        lines[ll.name] = ll;
    }

    file.close();

    // parse the contents of the LemminiLines

    name_english = lines["name"].str;
    size_x       = 2 * 1600;
    size_y       = 2 * 160;
    start_x      = lines["xPos"].nr;

    seconds       = std::max(lines["timeLimit"].nr * 60,
                             lines["timeLimitSeconds"].nr);
    initial       = lines["numLemmings"].nr;
    required      = lines["numToRescue"].nr;
    spawnint_slow = 4 + Help::even(99 - lines["releaseRate"].nr) / 2;
    spawnint_fast = 4;

    skills[LixEn::CLIMBER]  = lines["numClimbers"].nr;
    skills[LixEn::FLOATER]  = lines["numFloaters"].nr;
    skills[LixEn::EXPLODER] = lines["numBombers"].nr;
    skills[LixEn::BLOCKER]  = lines["numBlockers"].nr;
    skills[LixEn::BUILDER]  = lines["numBuilders"].nr;
    skills[LixEn::BASHER]   = lines["numBashers"].nr;
    skills[LixEn::MINER]    = lines["numMiners"].nr;
    skills[LixEn::DIGGER]   = lines["numDiggers"].nr;
    // skill slots with 0 skills will be culled in the finalize function

    legacy_ac_vec.push_back(LixEn::CLIMBER);
    legacy_ac_vec.push_back(LixEn::FLOATER);
    legacy_ac_vec.push_back(LixEn::EXPLODER);
    legacy_ac_vec.push_back(LixEn::BLOCKER);
    legacy_ac_vec.push_back(LixEn::BUILDER);
    legacy_ac_vec.push_back(LixEn::BASHER);
    legacy_ac_vec.push_back(LixEn::MINER);
    legacy_ac_vec.push_back(LixEn::DIGGER);

    int graphics_set = 0;
    std::string sty = lines["style"].str;
    Help::string_to_nice_case(sty);
    if      (sty == "Dirt")    graphics_set = 0;
    else if (sty == "Fire")    graphics_set = 1;
    else if (sty == "Marble")  graphics_set = 2;
    else if (sty == "Pillar")  graphics_set = 3;
    else if (sty == "Crystal") graphics_set = 4;
    else if (sty == "Brick")   graphics_set = 5;
    else if (sty == "Rock")    graphics_set = 6;
    else if (sty == "Snow")    graphics_set = 7;
    else if (sty == "Bubble")  graphics_set = 8;
    else if (sty == "Special") graphics_set = 9;

    // Parse the terrain

    int piece_nr = 0;
    while (true) {
        std::ostringstream piece_str;
        piece_str << "terrain_" << piece_nr;
        Lines::const_iterator itr = lines.find(piece_str.str());
        if (itr == lines.end()) break;
        else {
            Pos ter;
            ter.ob   = ObjLib::get_orig_terrain(graphics_set, itr->second.nr);
            ter.x    = itr->second.x;
            ter.y    = itr->second.y;
            ter.noow = itr->second.flags & 8;
            ter.mirr = itr->second.flags & 4;
            ter.dark = itr->second.flags & 2;
            if (ter.ob) pos[Object::TERRAIN].push_back(ter);
            else status = BAD_IMAGE;
        }
        ++piece_nr;
//.........这里部分代码省略.........
开发者ID:Lucki,项目名称:Lix,代码行数:101,代码来源:level_ni.cpp


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