• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ SerializeBuffer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了SerializeBuffer类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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:ludamad,项目名称: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: extract_message

static bool extract_message(QueuedMessage& qm,
		std::vector<QueuedMessage>& delayed_messages, int type) {
	for (int i = 0; i < delayed_messages.size(); i++) {
		qm = delayed_messages[i];
		SerializeBuffer* msg = qm.message;
		int msg_type;
		msg->read_int(msg_type);
		if (type == msg_type) {
			delayed_messages.erase(delayed_messages.begin() + i);
			return true;
		}
		msg->move_read_position(-(int)sizeof(int));
	}
	return false;
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:15,代码来源:GameNetConnection.cpp


示例4: write_or_assert_hash

static void write_or_assert_hash(SerializeBuffer& sb, unsigned int hash,
		bool is_writing) {
	if (is_writing) {
		sb.write_int(hash);
	} else {
		LANARTS_ASSERT(serializer_equals_read(sb, hash));
	}
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:8,代码来源:GameNetConnection.cpp


示例5: net_recv_sync_data

void net_recv_sync_data(SerializeBuffer& sb, GameState* gs) {
    printf("Got sync on frame %d\n", gs->frame());
    int mtwistseed;
    sb.read_int(mtwistseed);
    gs->rng().init_genrand(mtwistseed);
    gs->deserialize(sb);
    std::vector<PlayerDataEntry>& pdes = gs->player_data().all_players();
    for (int i = 0; i < pdes.size(); i++) {
        pdes[i].player()->set_local_player(pdes[i].is_local_player);
    }
}
开发者ID:ludamad,项目名称:lanarts,代码行数:11,代码来源:GameNetConnection.cpp


示例6: net_recv_game_init_data

void net_recv_game_init_data(SerializeBuffer& sb, int sender,
		GameStateInitData& init_data, PlayerData& pd) {
	//Write seed
	sb.read_int(init_data.seed);
	init_data.seed_set_by_network_message = true;

	//Read player data
	int localidx;
	sb.read_int(localidx);
	pd.set_local_player_idx(localidx);
	int playern;
	sb.read_int(playern);
	LANARTS_ASSERT(pd.all_players().empty());
	for (int i = 0; i < playern; i++) {
		std::string name;
		class_id classtype;
		int net_id;
		sb.read(name);
		sb.read_int(classtype);
		sb.read_int(net_id);
		pd.register_player(name, NULL, classtype, net_id);
	}
	printf("Received init packet: seed = 0x%X, localid = %d, nplayers = %d\n",
			init_data.seed, localidx, playern);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:25,代码来源:GameNetConnection.cpp


示例7: net_recv_game_init_data

void net_recv_game_init_data(SerializeBuffer& sb, int sender,
        GameStateInitData& init_data, PlayerData& pd) {
    //Write seed
    sb.read(init_data);
    init_data.received_init_data = true;

    //Read player data
    int localidx;
    sb.read_int(localidx);
    int playern;
    sb.read_int(playern);
    LANARTS_ASSERT(pd.all_players().empty());
    for (int i = 0; i < playern; i++) {
        std::string name;
        std::string classtype;
        int net_id;
        sb.read(name);
        sb.read(classtype);
        sb.read_int(net_id);
        pd.register_player(name, NULL, classtype, LuaValue(), (i == localidx), net_id);
    }

    printf(
            "Received init packet: seed = 0x%X, localid = %d, nplayers = %d, "
                    "frame_action_repeat = %d, regen_level_on_death = %d, network_debug_mode = %d, time_per_step = %f\n",
            init_data.seed, localidx, playern, init_data.frame_action_repeat,
            (int) init_data.regen_on_death,
            (int) init_data.network_debug_mode, init_data.time_per_step);
}
开发者ID:ludamad,项目名称:lanarts,代码行数:29,代码来源:GameNetConnection.cpp


示例8: net_recv_sync_data

void net_recv_sync_data(SerializeBuffer& sb, GameState* gs) {
	int mtwistseed;
	sb.read_int(mtwistseed);
	gs->rng().init_genrand(mtwistseed);
	int nplayer = gs->player_data().get_local_player_idx();
	gs->deserialize(sb);
	std::vector<PlayerDataEntry>& pdes = gs->player_data().all_players();
	for (int i = 0; i < pdes.size(); i++) {
		pdes[i].player()->set_local_player(false);
	}
	gs->player_data().set_local_player_idx(nplayer);
	gs->game_world().set_current_level(gs->local_player()->current_level);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:13,代码来源:GameNetConnection.cpp


示例9: serialize

void GameInstSet::serialize(GameState* gs, SerializeBuffer& serializer) {
	serializer.write_int(grid_w);
	serializer.write_int(grid_h);

	serializer.write_int(size());
	serializer.write_int(next_id);
	DepthMap::const_iterator it = depthlist_map.end();
	for (int ind = 0; it != depthlist_map.begin();) {
		--it;
		InstanceState* state = it->second.start_of_list;
		while (state) {
			GameInst* inst = state->inst;
			serializer.write_int(get_inst_type(inst));
			serializer.write_int(inst->id);
			inst->serialize(gs, serializer);
			serializer.write_int(inst->integrity_hash());
			state = state->next_same_depth;
		}
	}
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:20,代码来源:GameInstSet.cpp


示例10: send_packet

void GameNetConnection::send_packet(SerializeBuffer& serializer, int receiver) {
	_connection->send_message(serializer.data(), serializer.size(), receiver);

}
开发者ID:Zolomon,项目名称:lanarts,代码行数:4,代码来源:GameNetConnection.cpp


示例11: deserialize

void ChatMessage::deserialize(SerializeBuffer& serializer) {
	serializer.read(sender);
	serializer.read(message);
	serializer.read(sender_colour);
	serializer.read(message_colour);
}
开发者ID:gigimoi,项目名称:lanarts,代码行数:6,代码来源:GameChat.cpp


示例12: serialize

void ChatMessage::serialize(SerializeBuffer& serializer) {
	serializer.write(sender);
	serializer.write(message);
	serializer.write(sender_colour);
	serializer.write(message_colour);
}
开发者ID:gigimoi,项目名称:lanarts,代码行数:6,代码来源:GameChat.cpp


示例13: deserialize

void AnimatedInst::deserialize(GameState* gs, SerializeBuffer& serializer) {
	GameInst::deserialize(gs, serializer);
	DESERIALIZE_POD_REGION(serializer, this, textcol, animatetime);
	serializer.read(text);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:5,代码来源:AnimatedInst.cpp


示例14: deserialize

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


示例15: serialize

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


示例16: serialize

void StoreInst::serialize(GameState* gs, SerializeBuffer& serializer) {
	GameInst::serialize(gs, serializer);
	inv.serialize(serializer);
	serializer.write(last_seen_spr);
	serializer.write(spriteid);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:6,代码来源:StoreInst.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ SerializeOutput类代码示例发布时间:2022-05-30
下一篇:
C++ SerializationNode类代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap