本文整理汇总了C++中Block_Buffer::set_write_idx方法的典型用法代码示例。如果您正苦于以下问题:C++ Block_Buffer::set_write_idx方法的具体用法?C++ Block_Buffer::set_write_idx怎么用?C++ Block_Buffer::set_write_idx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block_Buffer
的用法示例。
在下文中一共展示了Block_Buffer::set_write_idx方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: battle_appear_info
int Player_Monster::battle_appear_info(Block_Buffer &buf) {
// size_t rd_idx = buf.get_read_idx();
size_t wr_begin_idx = buf.get_write_idx();
size_t wr_end_idx = 0;
uint32_t len = 0;
// fill head
buf.make_message(ACTIVE_FIGHTER_APPEAR);
MSG_81000008 msg;
msg.fighter_info.role_id = role_id();
msg.fighter_info.role_name = role_name();
msg.fighter_info.career = career_;
msg.fighter_info.gender = gender_;
msg.fighter_info.position.val_1 = mover_detail().battle_position.pos;
msg.fighter_info.position.val_2 = mover_detail().battle_position.idx;
msg.fighter_info.hp_curr = blood_current();
msg.fighter_info.hp_max = blood_max();
msg.fighter_info.avatar = avatar_vec;
boost::unordered_set<Property_Type> property_set;
property_set.insert(PT_MORALE_CAPS);
property_set.insert(PT_MORALE_CURRENT);
for (boost::unordered_set<Property_Type>::iterator it = property_set.begin(); it != property_set.end(); ++it) {
msg.fighter_info.init_props.push_back(Prop_Change(*it));
}
for (std::vector<Prop_Change>::iterator pc_it = msg.fighter_info.init_props.begin();
pc_it != msg.fighter_info.init_props.end(); ++pc_it) {
(*pc_it).current_val = fighter_detail().fetch_fight_property(Property_Type((*pc_it).prop_type));
}
msg.serialize(buf);
// refill len in head
wr_end_idx = buf.get_write_idx();
len = wr_end_idx - wr_begin_idx - sizeof(uint32_t);
buf.set_write_idx(wr_begin_idx);
buf.write_uint32(len);
buf.set_write_idx(wr_end_idx);
return 0;
}