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


C++ SerializeBuffer::read_container方法代码示例

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


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

示例1: net_recv_player_actions

void net_recv_player_actions(SerializeBuffer& sb, int sender, PlayerData& pd) {
	int frame, player_number;
	sb.read_int(frame);
	sb.read_int(player_number);

	PlayerDataEntry& pde = pd.all_players().at(player_number);

	ActionQueue actions;
	sb.read_container(actions);
	pde.action_queue.queue_actions_for_frame(actions, frame);

//	printf("Receiving %d actions for player %d from %d \n", actions.size(),
//			player_number, sender);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:14,代码来源:GameNetConnection.cpp

示例2: deserialize

void GameScreenSet::deserialize(GameState *gs, SerializeBuffer &serializer) {
    serializer.read_int(current_screen);
    simulation_map = read_gamemap(gs, serializer);
    serializer.read_container(screens, [&](GameScreen& screen) {
        screen.deserialize(gs, serializer);
    });

    GameSettings& settings = gs->game_settings();
    int n_local_players = 0;
    for (PlayerDataEntry &player: gs->player_data().all_players()) {
        if (player.is_local_player) {
            n_local_players++;
        }
    }
    // Number of split-screens tiled together
    int n_x = 1, n_y = 1;
    if (n_local_players <= 2) {
        n_x = n_local_players;
    } else if (n_local_players <= 4) {
        // More than 2, less than 4? Try 2x2 tiling
        n_x = 2, n_y = 2;
    } else if (n_local_players <= 6) {
        n_x = 3, n_y = 2;
    } else {
        LANARTS_ASSERT(n_local_players <= 9);
        // Last resort, Try 3x3 tiling
        n_x = 3, n_y = 3;
    }

    const int WIDTH = settings.view_width / n_x;
    const int HEIGHT = settings.view_height / n_y; // / N_PLAYERS;
    std::vector<BBox> bounding_boxes;
    for (GameScreen& screen : screens) {
        const int x1 = (screen.index % n_x) * WIDTH, y1 = (screen.index / n_x) * HEIGHT;
        bounding_boxes.push_back(BBox {x1, y1, x1 + WIDTH, y1 + HEIGHT});
    }
    if (bounding_boxes.size() == 3) {
        bounding_boxes[1] = {WIDTH, 0, settings.view_width, settings.view_height};
    }
    for (GameScreen& screen : screens) {
        BBox b = bounding_boxes[screen.index];
        screen.window_region = b;
        screen.hud = GameHud {
                BBox(b.x2 - GAME_SIDEBAR_WIDTH, b.y1, b.x2, b.y2),
                BBox(b.x1, b.y1, b.x2 - GAME_SIDEBAR_WIDTH, b.y2)
        };
        screen.view = GameView {0, 0, b.width() - GAME_SIDEBAR_WIDTH, b.height()};
    }
}
开发者ID:ludamad,项目名称:lanarts,代码行数:49,代码来源:GameScreen.cpp

示例3: deserialize

void MonsterController::deserialize(SerializeBuffer& serializer) {
	serializer.read_container(mids);
	serializer.read(monsters_wandering_flag);
}
开发者ID:yi-juchung,项目名称:lanarts,代码行数:4,代码来源:MonsterController.cpp


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