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


C++ SerializedGameData::PopFOWObject方法代码示例

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


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

示例1: Deserialize

void MapNode::Deserialize(SerializedGameData& sgd, const unsigned numPlayers)
{
    for(unsigned z = 0; z < roads.size(); ++z)
    {
        roads[z] = sgd.PopUnsignedChar();
        RTTR_Assert(roads[z] < 4);
        roads_real[z] = roads[z] != 0;
    }

    altitude = sgd.PopUnsignedChar();
    shadow = sgd.PopUnsignedChar();
    t1 = TerrainType(sgd.PopUnsignedChar());
    RTTR_Assert(t1 < TT_COUNT);
    t2 = TerrainType(sgd.PopUnsignedChar());
    RTTR_Assert(t2 < TT_COUNT);
    resources = sgd.PopUnsignedChar();
    reserved = sgd.PopBool();
    owner = sgd.PopUnsignedChar();
    for(unsigned b = 0; b < boundary_stones.size(); ++b)
        boundary_stones[b] = sgd.PopUnsignedChar();
    bq = BuildingQuality(sgd.PopUnsignedChar());
    bqVisual = BuildingQuality(sgd.PopUnsignedChar());
    RTTR_Assert(numPlayers < fow.size());
    for(unsigned z = 0; z < numPlayers; ++z)
    {
        MapNode::FoWData& curFoW = fow[z];
        curFoW.visibility = Visibility(sgd.PopUnsignedChar());
        // Only in FoW can be FoW objects
        if(curFoW.visibility == VIS_FOW)
        {
            curFoW.last_update_time = sgd.PopUnsignedInt();
            curFoW.object = sgd.PopFOWObject();
            for(unsigned r = 0; r < curFoW.roads.size(); ++r)
                curFoW.roads[r] = sgd.PopUnsignedChar();
            curFoW.owner = sgd.PopUnsignedChar();
            for(unsigned b = 0; b < curFoW.boundary_stones.size(); ++b)
                curFoW.boundary_stones[b] = sgd.PopUnsignedChar();
        }
        else
        {
            curFoW.last_update_time = 0;
            curFoW.object = NULL;
            for(unsigned r = 0; r < curFoW.roads.size(); ++r)
                curFoW.roads[r] = 0;
            curFoW.owner = 0;
            for(unsigned b = 0; b < curFoW.boundary_stones.size(); ++b)
                curFoW.boundary_stones[b] = 0;
        }
    }
    obj = sgd.PopObject<noBase>(GOT_UNKNOWN);
    sgd.PopObjectContainer(figures, GOT_UNKNOWN);
    sea_id = sgd.PopUnsignedShort();
    harbor_id = sgd.PopUnsignedInt();
}
开发者ID:aidevn,项目名称:s25client,代码行数:54,代码来源:MapNode.cpp

示例2: Deserialize

void GameWorld::Deserialize(SerializedGameData& sgd)
{
    // Headinformationen
    width_ = sgd.PopUnsignedShort();
    height_ = sgd.PopUnsignedShort();
    lt = LandscapeType(sgd.PopUnsignedChar());

    // Initialisierungen
    Init();

    // Obj-ID-Counter setzen
    GameObject::SetObjIDCounter(sgd.PopUnsignedInt());

    // Trade graphs
    // Only if trade is enabled
    if(GAMECLIENT.GetGGS().isEnabled(ADDON_TRADE))
    {
        tgs.resize(sgd.PopUnsignedChar());
        for(unsigned i = 0; i < tgs.size(); ++i)
            tgs[i] = new TradeGraph(sgd, this);
    }

    // Alle Weltpunkte serialisieren
    for(unsigned i = 0; i < map_size; ++i)
    {
        for(unsigned z = 0; z < 3; ++z)
        {
            nodes[i].roads[z] = sgd.PopUnsignedChar();
            nodes[i].roads_real[z] = nodes[i].roads[z] ? true : false;
        }


        nodes[i].altitude = sgd.PopUnsignedChar();
        nodes[i].shadow = sgd.PopUnsignedChar();
        nodes[i].t1 = TerrainType(sgd.PopUnsignedChar());
        nodes[i].t2 = TerrainType(sgd.PopUnsignedChar());
        nodes[i].resources = sgd.PopUnsignedChar();
        nodes[i].reserved = sgd.PopBool();
        nodes[i].owner = sgd.PopUnsignedChar();
        for(unsigned b = 0; b < 4; ++b)
            nodes[i].boundary_stones[b] = sgd.PopUnsignedChar();
        nodes[i].bq = BuildingQuality(sgd.PopUnsignedChar());
        for(unsigned z = 0; z < GAMECLIENT.GetPlayerCount(); ++z)
        {
            MapNode::FoWData& fow = nodes[i].fow[z];
            fow.visibility = Visibility(sgd.PopUnsignedChar());
            // Nur im FoW können FOW-Objekte stehen
            if(fow.visibility == VIS_FOW)
            {
                fow.last_update_time = sgd.PopUnsignedInt();
                fow.object = sgd.PopFOWObject();
                for(unsigned r = 0; r < 3; ++r)
                    fow.roads[r] = sgd.PopUnsignedChar();
                fow.owner = sgd.PopUnsignedChar();
                for(unsigned b = 0; b < 4; ++b)
                    fow.boundary_stones[b] = sgd.PopUnsignedChar();
            }
            else
            {
                fow.last_update_time = 0;
                fow.object = NULL;
                for(unsigned r = 0; r < 3; ++r)
                    fow.roads[r] = 0;
                fow.owner = 0;
                for(unsigned b = 0; b < 4; ++b)
                    fow.boundary_stones[b] = 0;
            }
        }
        nodes[i].obj = sgd.PopObject<noBase>(GOT_UNKNOWN);
        sgd.PopObjectContainer(nodes[i].figures, GOT_UNKNOWN);
        nodes[i].sea_id = sgd.PopUnsignedShort();
        nodes[i].harbor_id = sgd.PopUnsignedInt();

        if (nodes[i].harbor_id)
        {
            GameWorldBase::HarborPos p(MapPoint((MapCoord) (i % width_), (MapCoord) (i / width_)));
            harbor_pos.push_back(p);
        }
    }

    // Katapultsteine deserialisieren
    sgd.PopObjectContainer(catapult_stones, GOT_CATAPULTSTONE);

    // Meeresinformationen deserialisieren
    seas.resize(sgd.PopUnsignedInt());
    for(unsigned i = 0; i < seas.size(); ++i)
    {
        seas[i].nodes_count = sgd.PopUnsignedInt();
    }

    // Hafenpositionen serialisieren
    harbor_pos.resize(sgd.PopUnsignedInt());
    for(unsigned i = 0; i < harbor_pos.size(); ++i)
    {
        harbor_pos[i].pos = sgd.PopMapPoint();
        for(unsigned z = 0; z < 6; ++z)
            harbor_pos[i].cps[z].sea_id = sgd.PopUnsignedShort();
        for(unsigned z = 0; z < 6; ++z)
        {
            harbor_pos[i].neighbors[z].resize(sgd.PopUnsignedInt());
//.........这里部分代码省略.........
开发者ID:Ribosom,项目名称:s25client,代码行数:101,代码来源:GameWorld.cpp


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