Esempio n. 1
0
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;
}
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;
}
// for db save --
void Expedition_Scene_Demage_Rank_Data::serialize(Block_Buffer &w) const {
	w.write_string(role_name);
	w.write_int64(role_id);
	w.write_int64(gang_id);
	w.write_string(gang_name);
	w.write_int64(uuid);
	w.write_string(server_name);
	w.write_int32(force);
	w.write_int32(level);
	w.write_double(demage);
}
int Expedition_Occupy_Castle_Data::serialize(Block_Buffer &w) const {
	w.write_int64(role_id);
	w.write_int64(gang_id);
	w.write_int64(server_uuid);
	w.write_string(role_name);
	w.write_string(gang_name);
	w.write_string(server_name);
	w.write_int32(level);
	w.write_int32(force);
	w.write_int16(nums);
	w.write_int16(get_nums);
	return 0;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
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_);
}
Esempio n. 7
0
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;
}
Esempio n. 8
0
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);
}
Esempio n. 9
0
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());
    }
}
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;
}
Esempio n. 11
0
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;
}
Esempio n. 12
0
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;
}
Esempio n. 13
0
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;
}
Esempio n. 14
0
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;
}
Esempio n. 15
0
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;
}
Esempio n. 16
0
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;
}
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);
}
int Team_Arena_Controler::get_role_score_list(role_id_t role_id, int level, Block_Buffer &buf) {
	//level = 0;
	//Team_Role_Score_Map::iterator t_find_it = team_role_score_map.begin();
	//if (t_find_it != team_role_score_map.end()) {
	//	level = t_find_it->second.rank;
	//}
	buf.write_int32(level);

	Level_Team_Role_Score_Map::iterator find_it = level_team_role_score_map.find(level);
	if (find_it != level_team_role_score_map.end()) {
		int amount = find_it->second.size() > 50 ? 50 : find_it->second.size();
		buf.write_int32(amount);
		for (Team_Role_Score_Vec::iterator it = find_it->second.begin(); it != find_it->second.end() && amount > 0; ++it, --amount) {
			buf.write_string((*it)->name);
			buf.write_string((*it)->area);
			buf.write_int32((*it)->score);
			buf.write_int32((*it)->force);
		}
	} else {
		buf.write_int32(0);
	}

	return 0;
}
int Dragon_Vale_Detail::serialize(Block_Buffer &buffer) const {
	buffer.write_int64(role_id);
	buffer.write_int64(target_player_id);
	buffer.write_bool(is_rob_enter_dragon_vale);
	buffer.write_int64(uuid);
	buffer.write_bool(is_gold_mine_max_storage);
	buffer.write_bool(is_moon_well_max_storage);
	buffer.write_bool(is_totem_max_storage);
	buffer.write_uint8(build_gold_mine_num);
	buffer.write_uint8(build_moon_well_num);
	buffer.write_uint8(build_totem_num);
	buffer.write_uint8(build_queue_num);
	buffer.write_uint8(all_open_build_queue_num);

	uint8_t size = dragon_building_info_map.size();
	buffer.write_uint8(size);

	for(DragonBuildingInfoMap::const_iterator it = dragon_building_info_map.begin();
			it != dragon_building_info_map.end();
			++it) {
		it->second.serialize(buffer);
	}

	buffer.write_bool(is_dragon_born);
	buffer.write_uint64((uint64_t)begin_born_time.sec());

	dragon_info.serialize(buffer);

	buffer.write_uint64((uint64_t)begin_play_dragon_interval_time.sec());
	buffer.write_uint64((uint64_t)begin_down_feeling_time.sec());

	buffer.write_bool(is_vip_down_to_zero);
	buffer.write_uint32(matched_num);

	size = thief_id_quality_map.size();
	buffer.write_uint8(size);
	for(Thief_Id_Quality_Map::const_iterator it = thief_id_quality_map.begin(); it != thief_id_quality_map.end(); ++it) {
		buffer.write_int64(it->first);
		buffer.write_int64(it->second);
	}

	buffer.write_uint64((uint64_t)begin_refresh_thief_time.sec());

	buffer.write_uint8(star_num);
	buffer.write_uint8(award_foot_num);
	buffer.write_bool(is_special);

	size = foot_info_map.size();
	buffer.write_uint8(size);
	for(Foot_Info_Map::const_iterator it = foot_info_map.begin(); it != foot_info_map.end(); ++it) {
		buffer.write_int64(it->first);
		buffer.write_uint8(it->second.sex);
		buffer.write_string(it->second.name);
	}

	uint32_t size_32 = foot_id_set.size();
	buffer.write_uint32(size_32);
	for(Foot_Id_Set::const_iterator it = foot_id_set.begin(); it != foot_id_set.end(); ++it) {
		buffer.write_int64(*it);
	}

	buffer.write_bool(is_yesterday_login);
	buffer.write_uint8(dragon_heart_num);

	size = notice_board_list.size();
	buffer.write_uint8(size);
	for(Notice_Board_List::const_iterator it = notice_board_list.begin();
			it != notice_board_list.end();
			++it) {
		it->serialize(buffer);
	}

	buffer.write_bool(is_rob_protect);
	buffer.write_uint64((uint64_t)begin_rob_protect_time.sec());

	buffer.write_bool(is_first_enter_after_robbed);

	buffer.write_bool(is_in_robbed_dragon_vale);
	buffer.write_uint64((uint64_t)begin_in_robbed_dragon_vale_time.sec());

	size = cancel_create_building_set.size();
	buffer.write_uint8(size);
	for(Cancel_Create_Building_Set::const_iterator it = cancel_create_building_set.begin();
			it != cancel_create_building_set.end();
			++it) {
		buffer.write_uint8(*it);
	}

	buffer.write_bool(is_dragon_vale_open);

	buffer.write_uint64((uint64_t)begin_no_enter_time.sec());
	buffer.write_uint32(left_time);

	buffer.write_uint32(play_dragon_num);
	buffer.write_uint32(drive_thief_num);

	return 0;
}
int Scene_Gang_Manager::sync_to_logic(void) {
	MSG_USER("GANG_WAR:sync_to_logic, stage(%d), gang_vec_.size(%d)", stage(), gang_vec_.size());
	Block_Buffer buf;
	buf.make_message(INNER_SYNC_GANG_WAR_INFO);
	buf.write_int8(stage());
	buf.write_uint16(gang_vec_.size());
	int64_t index = 0;
	int8_t camp = 0;
	Time_Value match_time = Time_Value::zero;
	int64_t scene_index = 0;
	std::string zone;
	std::string gang_name;
	int8_t rank = 0;
	int64_t force = 0;
	for (GangWarMatchedGangsPair_Vec::const_iterator it = gang_vec_.begin(); it != gang_vec_.end(); ++it) {
		buf.write_int64(it->matched_pair.first);
		{
			index = 0;
			camp = 0;
			match_time = Time_Value::zero;
			scene_index = 0;
			zone.clear();
			gang_name.clear();
			rank = 0;
			force = 0;
			const Gang_War_Matched_Gang_Info *it_index = find_matched_gang_info(it->matched_pair.first);
			if (it_index) {
				index = it_index->matched_index;
				camp = it_index->camp;
				match_time.set(it_index->match_time);
				scene_index = it_index->scene_index;
				zone = it_index->zone;
				gang_name = it_index->gang_name;
				rank = it_index->rank;
				force = it_index->force;
			}
		}
		buf.write_int64(index);
		buf.write_int8(camp);
		match_time.serialize(buf);
		buf.write_int64(scene_index);
		buf.write_string(zone);
		buf.write_string(gang_name);
		buf.write_int8(rank);
		buf.write_int64(force);

		buf.write_int64(it->matched_pair.second);
		{
			index = 0;
			camp = 0;
			match_time = Time_Value::zero;
			scene_index = 0;
			zone.clear();
			gang_name.clear();
			rank = 0;
			force = 0;
			const Gang_War_Matched_Gang_Info *it_index = find_matched_gang_info(it->matched_pair.second);
			if (it_index) {
				index = it_index->matched_index;
				camp = it_index->camp;
				match_time.set(it_index->match_time);
				scene_index = it_index->scene_index;
				zone = it_index->zone;
				gang_name = it_index->gang_name;
				rank = it_index->rank;
				force = it_index->force;
			}
		}
		buf.write_int64(index);
		buf.write_int8(camp);
		match_time.serialize(buf);
		buf.write_int64(scene_index);
		buf.write_string(zone);
		buf.write_string(gang_name);
		buf.write_int8(rank);
		buf.write_int64(force);

		it->match_time.serialize(buf);
		buf.write_int8(it->result);
		buf.write_int8(it->matched_index);
		buf.write_int64(it->scene_index);
	}
	buf.finish_message();
	sync_to_logic(buf);
	return 0;
}