本文整理汇总了C++中Block_Buffer::make_server_message方法的典型用法代码示例。如果您正苦于以下问题:C++ Block_Buffer::make_server_message方法的具体用法?C++ Block_Buffer::make_server_message怎么用?C++ Block_Buffer::make_server_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block_Buffer
的用法示例。
在下文中一共展示了Block_Buffer::make_server_message方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: process_create_guild
int DB_Worker::process_create_guild(int cid, Create_Guild_Info &guild_info) {
Block_Buffer buf;
buf.make_server_message(SYNC_DB_MASTER_CREATE_GUILD, 0);
guild_info.guild_id = DB_MANAGER->create_guild(guild_info);
guild_info.serialize(buf);
buf.finish_message();
DB_MANAGER->send_data_block(cid, buf);
return 0;
}
示例3: process_load_master
int DB_Worker::process_load_master(int cid) {
Base_Struct *master_struct = DB_MANAGER->get_master_data_struct();
for(std::vector<Field_Info>::const_iterator iter = master_struct->field_vec().begin();
iter != master_struct->field_vec().end(); iter++){
Struct_Name_Map::iterator it = DB_MANAGER->db_struct_name_map().find(iter->field_type);
if(it == DB_MANAGER->db_struct_name_map().end()){
LOG_ERROR("Can not find the struct_name:%s", iter->field_type.c_str());
return -1;
}
Block_Buffer buf;
buf.make_server_message(it->second->msg_id() + 400000, 0);
it->second->load_data(0, buf);
buf.finish_message();
DB_MANAGER->send_data_block(cid, buf);
}
return 0;
}
示例4: 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;
}
示例5: 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;
}