本文整理汇总了C++中Block_Buffer::write_string方法的典型用法代码示例。如果您正苦于以下问题:C++ Block_Buffer::write_string方法的具体用法?C++ Block_Buffer::write_string怎么用?C++ Block_Buffer::write_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block_Buffer
的用法示例。
在下文中一共展示了Block_Buffer::write_string方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serialize
int Public_Detail::serialize(Block_Buffer &buffer) const {
buffer.write_string(plot_id);
buffer.write_int32(plot_step);
buffer.write_bool(plot_switch);
buffer.write_uint16(plot_info.size());
for (String_Int_Map::const_iterator it = plot_info.begin(); it != plot_info.end(); ++it) {
buffer.write_string(it->first);
buffer.write_int32(it->second);
}
buffer.write_int32(awake_lvl);
buffer.write_uint16(artifacts.size());
for (Artifact_Map::const_iterator it = artifacts.begin(); it != artifacts.end(); ++it) {
it->second.serialize(buffer);
}
buffer.write_uint16(fornotice_gifts_status.size());
for (Fornotice_Gifts_Status_Map::const_iterator it = fornotice_gifts_status.begin();
it != fornotice_gifts_status.end(); ++it) {
buffer.write_int32(it->first);
buffer.write_int8(it->second);
}
buffer.write_int32(exploit_val);
buffer.write_int32(exploit_lvl);
return 0;
}
示例2: serialize
int Expedition_Force::serialize(Block_Buffer &w) const {
w.write_int64(server_uuid);
w.write_string(server_name);
w.write_int64(gang_id);
w.write_string(gang_name);
return 0;
}
示例3: process_create_player
int DB_Worker::process_create_player(int cid, Create_Role_Info &role_info) {
int64_t role_id = 0;
Block_Buffer buf;
if ((role_id = DB_MANAGER->create_player(role_info)) > 0) {
buf.make_server_message(SYNC_DB_GAME_CREATE_PLAYER, ROLE_SUCCESS_CREATE);
buf.write_string(role_info.account);
//创建所有玩家表,构建登录消息buf
create_player_data(role_id, buf);
} else {
buf.make_server_message(SYNC_DB_GAME_CREATE_PLAYER, ROLE_HAS_EXIST);
buf.write_string(role_info.account);
}
buf.finish_message();
DB_MANAGER->send_data_block(cid, buf);
return 0;
}
示例4: serialize
void Map_Team::serialize(Block_Buffer &buf) {
buf.write_int8(type_);
buf.write_string(words_);
buf.write_int32(scene_id_);
buf.write_int8(degree_);
buf.write_uint32(team_index_);
buf.write_int64(team_id_);
buf.write_int64(team_id_for_scene_);
buf.write_int64(leader_role_id_);
uint16_t len = 0;
len = team_member_set_.size();
buf.write_uint16(len);
for (Role_Hash_Set::iterator it = team_member_set_.begin(); it != team_member_set_.end(); ++it) {
buf.write_int64(*it);
}
len = offline_teamer_map_.size();
buf.write_uint16(len);
for (RoleID_OnlineMap_TeamerInfo_Map::iterator it = offline_teamer_map_.begin(); it != offline_teamer_map_.end(); ++it) {
buf.write_int64(it->first);
}
buf.write_int8(in_battle_);
len = lineup_.size();
buf.write_uint16(len);
for (Int_Role_Id_Vec::iterator it = lineup_.begin(); it != lineup_.end(); ++it) {
it->serialize(buf);
}
buf.write_int32(enter_level_);
buf.write_int16(fail_times_);
buf.write_int16(match_fail_);
buf.write_bool(is_not_first_team_fb_);
}
示例5: offline_receive_flowers
int Operating::offline_receive_flowers(role_id_t role_id, std::string &role_name, uint32_t item_id, uint32_t charm, uint32_t friend_num, std::string &msg, role_id_t receive_role_id) {
if ( role_id == 0 ) return 0;
Block_Buffer buf;
buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
int type = OPERATING_OFFLINE_RECEIVE_FLOWERS;
buf.write_int32(type);
buf.write_int64(role_id);
buf.write_string(role_name);
buf.write_uint32(item_id);
buf.write_uint32(charm);
buf.write_uint32(friend_num);
buf.write_string(msg);
buf.write_int64(receive_role_id);
buf.finish_message();
DB_MANAGER->push_data_block(buf, 0);
return 0;
}
示例6: send_err_to_client
int Chat_Player::send_err_to_client(int error_id, int source) {
Block_Buffer buf;
buf.make_message(80000001);
buf.write_int32(error_id);
buf.write_int32(source);
buf.write_string("");
buf.finish_message();
return send_to_client(buf);
}
示例7: build_buffer_arg
void Msg_Struct::build_buffer_arg(const Field_Info &field_info, Block_Buffer &buffer, Isolate* isolate, v8::Local<v8::Value> value) {
if(field_info.field_type == "int8") {
int8_t val = 0;
if (value->IsInt32()) {
val = value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
buffer.write_int8(val);
}
else if(field_info.field_type == "int16") {
int16_t val = 0;
if (value->IsInt32()) {
val = value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
buffer.write_int16(val);
}
else if(field_info.field_type == "int32") {
int32_t val = 0;
if (value->IsInt32()) {
val = value->Int32Value(isolate->GetCurrentContext()).FromJust();
}
buffer.write_int32(val);
}
else if(field_info.field_type == "int64") {
int64_t val = 0;
if (value->IsNumber()) {
val = value->NumberValue(isolate->GetCurrentContext()).FromJust();
}
buffer.write_int64(val);
}
else if(field_info.field_type == "double") {
double val = 0;
if (value->IsNumber()) {
val = value->NumberValue(isolate->GetCurrentContext()).FromJust();
}
buffer.write_double(val);
}
else if(field_info.field_type == "bool") {
bool val = 0;
if (value->IsBoolean()) {
val = value->BooleanValue(isolate->GetCurrentContext()).FromJust();
}
buffer.write_bool(val);
}
else if(field_info.field_type == "string") {
std::string val = "";
if (value->IsString()) {
String::Utf8Value str(value->ToString(isolate->GetCurrentContext()).ToLocalChecked());
std::stringstream stream;
stream << ToCString(str);
val = stream.str();
}
buffer.write_string(val);
}
else {
LOG_ERROR("Can not find the field_type:%s, struct_name:%s", field_info.field_type.c_str(), struct_name().c_str());
}
}
示例8: vagrant_store_trigger
int Scene_Outpost_Manager::vagrant_store_trigger(Move_Scene* scene, const int point, bool is_boss, Coord point_coord){
int scene_id = scene->scene_id();
int monster_id = CONFIG_CACHE_NPC->vagrant_item_trigger(scene_id, point);
if(monster_id == 0){
return 0;
}
// create monster
NPC_Addition_Info npc_add;
npc_add.birth_coord = point_coord;
Monster* monster = NPC_MANAGER->create_monster(monster_id, 5, scene, NULL, npc_add);
if(!monster){
return 0;
}
int64_t monster_role_id = monster->role_id();
// 生存流浪商店物品
Vagrant_Item_Config_Map* vic_map = CONFIG_CACHE_NPC->get_vagrant_item_config_map();
if(!vic_map){
return 0;
}
Vagrant_Item_Info_Vec vi_vec;
Vagrant_Item_Info vi;
for(Vagrant_Item_Config_Map::iterator it = vic_map->begin(); it != vic_map->end();
++ it){
if(it->second.is_valid(monster_id)){
vi.reset();
vi.cfg_key = it->second.key;
vi.cfg_item_id = it->second.item_id;
vi.cfg_cost_type = it->second.sys_sell_type;
vi.cfg_cost = it->second.cost;
vi.cfg_num = it->second.num;
vi.cfg_limit_num = it->second.limit_num;
vi_vec.push_back(vi);
}
}
Vagrant_Store_Scene_Map::iterator it = vagrant_item_map_.find(scene_id);
if(it != vagrant_item_map_.end()){
it->second[monster_role_id] = vi_vec;
}else{
Vagrant_Store_Map vagrant_stroe_map;
vagrant_stroe_map[monster_role_id] = vi_vec;
vagrant_item_map_[scene_id] = vagrant_stroe_map;
}
// 飘字
{
int err_id = ERROR_VAGRANT_STORE_OPEN;
Block_Buffer buf;
buf.make_message(80000001);
buf.write_int32(err_id);
buf.write_int32(0);
buf.write_string("");
buf.finish_message();
scene->broadcast_all(0, buf);
}
return 0;
}
示例9: process_load_player
int DB_Worker::process_load_player(int cid, std::string &account) {
Block_Buffer buf;
buf.make_inner_message(SYNC_DB_GAME_LOAD_PLAYER);
buf.write_string(account);
DB_Manager::DB_Cache_Account_Map::iterator iter = DB_MANAGER->db_cache_account_map().find(account);
if (iter != DB_MANAGER->db_cache_account_map().end()) {
//角色存在,开始加载数据
buf.write_int32(SUCCESS_LOADED);
int64_t role_id = iter->second.role_id;
load_player_data(role_id, buf);
} else {
//角色不存在,直接返回
buf.write_int32(ROLE_NOT_EXIST);
}
buf.finish_message();
DB_MANAGER->send_data_block(cid, buf);
return 0;
}
示例10: process_create_player
int DB_Worker::process_create_player(int cid, Game_Player_Info &player_info) {
Block_Buffer buf;
buf.make_inner_message(SYNC_DB_GAME_CREATE_PLAYER);
int32_t status = 0;
if (DB_MANAGER->create_player(player_info) < 0) {
status = ROLE_HAS_EXIST;
} else {
status = SUCCESS_CREATED;
//创建所有玩家表
create_player_data(player_info.role_id);
}
buf.write_string(player_info.account);
buf.write_int32(status);
load_player_data(player_info.role_id, buf);
buf.finish_message();
DB_MANAGER->send_data_block(cid, buf);
return 0;
}
示例11: offline_dragon_vale_rob_fight_result_notice
int Operating::offline_dragon_vale_rob_fight_result_notice(role_id_t role_id, uint8_t notice_type, std::string server_name,
std::string player_name, uint8_t result) {
if (!role_id) {
MSG_USER("error role id");
return -1;
}
Block_Buffer buf;
buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
uint32_t op_type = OPERATING_OFFLINE_DRAGON_VALE_ROB_FIGHT_RESULT;
buf.write_uint32(op_type);
buf.write_int64(role_id);
buf.write_uint8(notice_type);
buf.write_string(server_name);
buf.write_string(player_name);
buf.write_uint8(result);
buf.finish_message();
DB_MANAGER->push_data_block(buf, 0);
return 0;
}
示例12: offline_dargon_vale_gain_rob_production_notice
int Operating::offline_dargon_vale_gain_rob_production_notice(role_id_t role_id, std::string server_name, std::string player_name,
uint32_t gold_mine, uint32_t moon_well, uint32_t totem) {
if (!role_id) {
MSG_USER("error role id");
return -1;
}
Block_Buffer buf;
buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
uint32_t op_type = OPERATING_OFFLINE_DRAGON_VALE_GAIN_ROB_PRODUCTION;
buf.write_uint32(op_type);
buf.write_int64(role_id);
buf.write_string(server_name);
buf.write_string(player_name);
buf.write_uint32(gold_mine);
buf.write_uint32(moon_well);
buf.write_uint32(totem);
buf.finish_message();
DB_MANAGER->push_data_block(buf, 0);
return 0;
}
示例13: process_save_player
int DB_Worker::process_save_player(int cid, int status, Block_Buffer &buffer) {
//先把两个额外字段读出来,再保存玩家数据,防止buffer错乱
bool logout = false;
std::string account = "";
buffer.read_bool(logout);
buffer.read_string(account);
if (logout) {
//离线保存
save_player_data(buffer);
Block_Buffer buf;
buf.make_server_message(SYNC_DB_GAME_SAVE_PLAYER, 0);
buf.write_string(account);
buf.finish_message();
DB_MANAGER->send_data_block(cid, buf);
} else {
//在线定时保存
save_player_data(buffer);
}
return 0;
}
示例14: process_load_player
int DB_Worker::process_load_player(int cid, std::string &account) {
int32_t status = 0;
int64_t role_id = 0;
DB_Manager::DB_Cache_Account_Map::iterator iter = DB_MANAGER->db_cache_account_map().find(account);
if (iter != DB_MANAGER->db_cache_account_map().end()) {
//角色存在,加载数据
status = ROLE_SUCCESS_LOAD;
role_id = iter->second.role_id;
} else {
//角色不存在,直接返回
status = ROLE_NOT_EXIST;
}
Block_Buffer buf;
buf.make_server_message(SYNC_DB_GAME_LOAD_PLAYER, status);
buf.write_string(account);
if (role_id > 0) {
load_player_data(role_id, buf);
}
buf.finish_message();
DB_MANAGER->send_data_block(cid, buf);
return 0;
}
示例15: serialize
void Hero_Info_Detail::serialize(Block_Buffer &w) const {
w.write_int32(hero_id);
w.write_int32(hero_index);
w.write_int32(hero_facade_id);
w.write_string(hero_name);
w.write_int8(is_outer);
w.write_int8(is_fighter);
w.write_int32(level);
w.write_int32(formation);
w.write_int32(awake_lvl);
w.write_double(exp);
uint16_t __prop_value_vec_size = prop_value.size();
w.write_uint16(__prop_value_vec_size);
for(uint16_t i = 0; i < __prop_value_vec_size; ++i) {
prop_value[i].serialize(w);
}
w.write_uint16(artifacts.size());
for (Artifact_Map::const_iterator it = artifacts.begin(); it != artifacts.end(); ++it) {
it->second.serialize(w);
}
hero_fighter_detail.serialize(w);
}