本文整理汇总了C++中SerializeBuffer::read_int方法的典型用法代码示例。如果您正苦于以下问题:C++ SerializeBuffer::read_int方法的具体用法?C++ SerializeBuffer::read_int怎么用?C++ SerializeBuffer::read_int使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SerializeBuffer
的用法示例。
在下文中一共展示了SerializeBuffer::read_int方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: deserialize
void FeatureInst::deserialize(GameState* gs, SerializeBuffer& serializer) {
GameInst::deserialize(gs, serializer);
serializer.read_int(feature);
serializer.read_int(last_seen_spr);
serializer.read_int(spriteid);
serializer.read_int(sprite_frame);
}
示例2: 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);
}
示例3: deserialize
void GameInstSet::deserialize(GameState* gs, SerializeBuffer& serializer) {
serializer.read_int(grid_w);
serializer.read_int(grid_h);
//Resize and clear
unit_grid.resize(grid_w * grid_h);
clear();
int amnt;
serializer.read_int(amnt);
serializer.read_int(next_id);
for (int i = 0; i < amnt; i++) {
InstType type;
int id;
serializer.read_int(type);
serializer.read_int(id);
printf("Deserializing id=%d\n", id);
GameInst* inst = get_instance(id);
bool has_inst = inst != NULL;
if (!has_inst) {
inst = from_inst_type(type);
inst->deserialize(gs, serializer);
inst->last_x = inst->x;
inst->last_y = inst->y;
inst->id = id;
add_instance(inst, inst->id);
} else {
safe_deserialize(inst, gs, serializer);
}
LANARTS_ASSERT(
serializer_equals_read(serializer, inst->integrity_hash()));
}
}
示例4: 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);
}
示例5: deserialize
void Equipment::deserialize(SerializeBuffer& serializer) {
inventory.deserialize(serializer);
weapon.deserialize(serializer);
projectile.deserialize(serializer);
serializer.read_int(projectile_amnt);
armour.deserialize(serializer);
serializer.read_int(money);
}
示例6: deserialize
void EffectStats::deserialize(GameState* gs, SerializeBuffer& serializer) {
lua_State* L = gs->get_luastate();
for (int i = 0; i < EFFECTS_MAX; i++) {
serializer.read_int(effects[i].effectid);
effects[i].state.deserialize(L, serializer);
if (!effects[i].state.isnil(L)) {
lua_init_metatable(L, effects[i].state, effects[i].effectid);
}
serializer.read_int(effects[i].t_remaining);
}
}
示例7: 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);
}
示例8: _handle_message
bool GameNetConnection::_handle_message(int sender,
SerializeBuffer& serializer) {
// Read type from buffer
message_t type;
serializer.read_int(type);
switch (type) {
case PACKET_CLIENT2SERV_CONNECTION_AFFIRM: {
net_recv_connection_affirm(serializer, sender, pd);
break;
}
case PACKET_SERV2CLIENT_INITIALPLAYERDATA: {
net_recv_game_init_data(serializer, sender, init_data, pd);
break;
}
case PACKET_ACTION: {
net_recv_player_actions(serializer, sender, pd);
break;
}
case PACKET_CHAT_MESSAGE: {
ChatMessage msg;
msg.deserialize(serializer);
chat.add_message(msg);
break;
}
default:
serializer.move_read_position(-(int)sizeof(int));
return false;
}
return true;
}
示例9: deserialize
void GameScreen::deserialize(GameState *gs, SerializeBuffer &serializer) {
serializer.read_int(index);
// hud details not serialized as they are ephermal user interface state
serializer.read(focus_player_id);
current_level = read_gamemap(gs, serializer);
serializer.read(last_player_pos);
}
示例10: net_recv_connection_affirm
// Only the server is concerned with this message
void net_recv_connection_affirm(SerializeBuffer& sb, int sender,
PlayerData& pd) {
std::string name;
class_id classtype;
sb.read(name);
sb.read_int(classtype);
printf("connection affirm read\n");
pd.register_player(name, NULL, classtype, sender);
printf("now there are %d players\n", (int)pd.all_players().size());
pd.set_local_player_idx(0);
}
示例11: 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);
}
}
示例12: has_message
static bool has_message(std::vector<QueuedMessage>& delayed_messages,
int type) {
for (int i = 0; i < delayed_messages.size(); i++) {
SerializeBuffer* msg = delayed_messages[i].message;
int msg_type;
msg->read_int(msg_type);
msg->move_read_position(-(int)sizeof(int));
if (type == msg_type) {
return true;
}
}
return false;
}
示例13: 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);
}
示例14: find_message_type
static int find_message_type(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);
msg->move_read_position(-(int) sizeof(int));
if (type == msg_type) {
return i;
}
}
return -1;
}
示例15: 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;
}