Exemplo n.º 1
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_);
}
int Heroer_Detail::serialize_fighter(Block_Buffer &buffer) const{
	this->hero_base_detail_.serialize(buffer);
	buffer.write_int32(this->fighter_index);

	Hero_Map::const_iterator it = this->hero_map.find(this->fighter_index);
	if(it != this->hero_map.end()){
		int8_t has_hero = 1;
		buffer.write_int8(has_hero);
		it->second.serialize(buffer);
	}else{
		int8_t has_hero = 0;
		buffer.write_int8(has_hero);
	}
	return 0;
}
Exemplo n.º 3
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 Stronghold::serialize(Block_Buffer &w) const {
	w.write_uint32(point_id);
	w.write_int8((int8_t)type);

	info.serialize(w);
	return 0;
}
int Scene_Outpost_Manager::req_vagrant_buy_item(Scene_Player* player, const int64_t monster_role_id, const int item_index){
	if(!player){
		return 0;
	}
	int scene_id = player->move_scene_id();
	Vagrant_Item_Info* item_info = get_vagrant_item_info(scene_id, monster_role_id, item_index);
	if(!item_info){
		return -1;
	}
	// 购买数量检测
	if(item_info->cfg_num != 0 &&
			item_info->buy_num >= item_info->cfg_num){
		//
		MSG_50211301 msg;
		msg.item_index = item_index;
		msg.result = 0;
		OBJ_SEND_TO_CLIENT(msg, (*player));
		//
		req_vagrant_item_info(player, monster_role_id);
		return ERROR_SECRET_SHOP_NUM_LIMIT;
	}
	// 限购检测
	if(item_info->cfg_limit_num != 0 &&
			item_info->player_buy_num(player->role_id()) >= item_info->cfg_limit_num){
		return ERROR_SECRET_SHOP_LIMIT_NUM_LIMIT;
	}
	{
		Block_Buffer buf;
		buf.make_message(INNER_SYNC_SCENE_OUTPOST);

		buf.write_int8(10);
		buf.write_int32(scene_id);
		buf.write_int64(monster_role_id);
		buf.write_int32(item_index);
		buf.write_int32(item_info->cfg_item_id);
		buf.write_int32(1);
		buf.write_int8(item_info->cfg_cost_type);
		buf.write_int32(item_info->cfg_cost);

		buf.finish_message();

		player->send_to_logic(buf);
	}
	return 0;
}
Exemplo n.º 6
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 Anci_Artifact_Detail::serialize(Block_Buffer &buffer) const {
	buffer.write_int64(role_id);
//	buffer.write_int64(perfectPoint);
	buffer.write_uint16(aa_info_map.size());
	for (AA_Info_Map::const_iterator it = aa_info_map.begin(); it != aa_info_map.end(); ++it) {
		buffer.write_int32(it->second.id);
		buffer.write_int8(it->second.state_count);
		buffer.write_int32(it->second.data);
	}
	buffer.write_uint16(complete_ids.size());
	for (Int_Hash_Set::const_iterator it = complete_ids.begin(); it != complete_ids.end(); ++it) {
		buffer.write_int32(*it);
	}
	buffer.write_uint16(aa_unban_info.size());
	for (AA_Unban_Info::const_iterator it = aa_unban_info.begin(); it != aa_unban_info.end(); ++it) {
		buffer.write_int32(it->second.id);
		buffer.write_int8(it->second.state);
		buffer.write_int8(it->second.box_state);
	}
	return 0;
}
Exemplo n.º 8
0
int Scene_Common::req_single_dungeon_revive(int8_t type) {
    if(player_self() && player_self()->move_scene() &&
            player_self()->move_scene()->scene_type() == FuBen_Scene_Type) {
        int param1 = 0;
        int param2 = 0;
        int param3 = 0;
        player_self()->move_scene()->get_scene_param(param1, param2, param3);
        if(param1 != 1) {
            return 0;
        }
        if(type == 0) { // 免费复活
            if(param2 <= 0) { // 免费复活次数
                {
                    MSG_50200215 msg;
                    msg.result = 0;
                    THIS_SEND_TO_CLIENT(msg);
                }
                return ERROR_FB_REVIVE_NO_FREE;
            }
            param2 -= 1;
            param1 = 0;
            player_self()->move_scene()->set_scene_param(param1, param2, param3, true);
            player_self()->reset_revive_info();
            {
                MSG_81000026 msg;
                msg.role_id = player_self()->role_id();
                msg.state = 0;
                THIS_SEND_TO_CLIENT(msg);
            }
            {
                MSG_50200215 msg;
                msg.result = 1;
                THIS_SEND_TO_CLIENT(msg);
            }
        } else { // 付费复活
            if(param2 > 0) { // 免费复活次数
                {
                    MSG_50200215 msg;
                    msg.result = 0;
                    THIS_SEND_TO_CLIENT(msg);
                }
                return ERROR_FB_REVIVE_HAS_FREE;
            }
            Block_Buffer buf;
            buf.make_message(INNER_WAR_SCENE_SYNC_INFO);
            buf.write_int8(3);
            buf.write_int32(param3);
            buf.finish_message();
            this->send_to_logic(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);
}
Exemplo n.º 10
0
int Operating::offline_firend_handel(role_id_t role_id, role_id_t other_role_id, int8_t handel) {
	if (!role_id) {
		MSG_USER("error role id");
		return -1;
	}

	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	int type = OPERATING_OFFLINE_APPLY_HANDEL;
	buf.write_int32(type);
	buf.write_int64(role_id);
	buf.write_int64(other_role_id);
	buf.write_int8(handel);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}
Exemplo n.º 11
0
void Map_Team::create_team_hero_detail(const Team_Robot_Config &tr_cfg, Block_Buffer &buf) {
	const Hero_Config *hero_config = CONFIG_CACHE_HERO->find_hero(tr_cfg.hero_id);
	if (!hero_config) {
		buf.write_int8(0);
		return ;
	}

	Hero_Info_Detail hero_info_detail;
	hero_info_detail.hero_index = 1;
	hero_info_detail.hero_id = tr_cfg.hero_id;
	hero_info_detail.hero_facade_id = tr_cfg.hero_id;
	hero_info_detail.hero_name = hero_config->hero_name;
	hero_info_detail.level = tr_cfg.hero_lvl;
	hero_info_detail.formation = 5;
	hero_info_detail.awake_lvl = tr_cfg.hero_awake_lvl;

	// 一二级转化率
	for (Int_Double_Map::const_iterator it_prop_val = hero_config->hero_prop_conver.begin();
			it_prop_val != hero_config->hero_prop_conver.end(); ++it_prop_val) {
		hero_info_detail.hero_fighter_detail.modify_percent_property(Property_Type(it_prop_val->first),
				AT_CONVERSION, O_SET, it_prop_val->second);
	}

	// heroer_prop_refresh(it_hero->second.hero_index, syn_scene, false);
	{
		for (int addition_type = AT_BASIC; addition_type < AT_END; ++addition_type) {
			if (addition_type == AT_CONVERSION || addition_type == AT_PASSIVE_SKILL) {
				continue;
			}
			for (Int_Set::const_iterator it_prop = FIGHT_PROP_SET.begin(); it_prop != FIGHT_PROP_SET.end(); ++it_prop) {
				hero_info_detail.hero_fighter_detail.modify_fight_property((Property_Type)(*it_prop), (Addition_Type)addition_type, O_SET, 0.0, 0.0, 0.0);
				if (PT_BLOOD_MAX == *it_prop) {
					hero_info_detail.hero_fighter_detail.modify_fight_property(PT_BLOOD_CURRENT, (Addition_Type)addition_type, O_SET, 0.0, 0.0, 0.0);
				}
			}
		}

		// 英雄等级属性 level_prop_refresh(it_hero->second, hero_config);
		{
			std::map<int, double> pro_val_map;
			const Int_Double_Map *hero_lvl_prop = CONFIG_CACHE_HERO->find_hero_lvl_prop(hero_info_detail.level);
			for (Int_Double_Map::const_iterator it_lvl_pro = hero_lvl_prop->begin();
					it_lvl_pro != hero_lvl_prop->end(); ++it_lvl_pro) {
				int prop = it_lvl_pro->first;
				double value = it_lvl_pro->second;
				if (it_lvl_pro->first > 0 && it_lvl_pro->second > 0.0) {
					pro_val_map[prop] += value;
				}
			}

			// 属性修正(改为只修正英雄等级属性)correct_prop_refresh(hero_info_detail, pro_val_map, hero_config);
			if (! pro_val_map.empty()) {
				for (std::map<int, double>::iterator it_pro_val_map = pro_val_map.begin();
						it_pro_val_map != pro_val_map.end(); ++it_pro_val_map) {
					if (it_pro_val_map->first && it_pro_val_map->second > 0.0) {
						Int_Double_Map::const_iterator it_correct_val = hero_config->hero_prop_correct.find(it_pro_val_map->first);
						if (it_correct_val != hero_config->hero_prop_correct.end()) {
							it_pro_val_map->second *= it_correct_val->second;
						} else {
							it_pro_val_map->second = 0;
						}
					}
				}
			}

			// 属性加成 hero_modify_fight_property(hero_info_detail, AT_BASIC, PST_BASIC, pro_val_map);
			bool pst_basic = true, pst_fixed = false, pst_percent = false;
			for (std::map<int, double>::const_iterator iter = pro_val_map.begin(); iter != pro_val_map.end(); ++iter) {
				if (iter->first) {
					double basic = pst_basic ? iter->second : 0.0;
					double fixed = pst_fixed ? iter->second : 0.0;
					double percent = pst_percent ? iter->second : 0.0;
					hero_info_detail.hero_fighter_detail.modify_fight_property((Property_Type)iter->first, AT_BASIC, O_SET, basic, fixed, percent);
				}
			}
		}

		// 装备属性 equip_prop_refresh(it_hero->second);
		{
			std::map<int, double> pro_val_map;
			for (Int_Hash_Set::const_iterator it_equip = tr_cfg.hero_equip.begin();
					it_equip != tr_cfg.hero_equip.end(); ++it_equip) {
				const Item_Detail_Config *item_config = CONFIG_CACHE_ITEM->find_item(*it_equip);
				if (! item_config) {
					continue;
				}

				// 装备基础属性
				const Prop_Value_Vec &cfg_prop_val_vec = item_config->equip_cfg.prop_val_vec;
				if (! cfg_prop_val_vec.empty()) {
					for (size_t i = 0; i < cfg_prop_val_vec.size(); ++i) {
						pro_val_map[cfg_prop_val_vec[i].id] += cfg_prop_val_vec[i].value;
					}
				}
			}
			// 属性加成hero_modify_fight_property(hero_info_detail, AT_EQUIP, PST_BASIC, pro_val_map);
			Prop_Setter setter;
			Prop_Setter_Vec setter_vec;
			bool pst_basic = true, pst_fixed = false, pst_percent = false;
			for (std::map<int, double>::const_iterator iter = pro_val_map.begin(); iter != pro_val_map.end(); ++iter) {
				if (iter->first) {
					double basic = pst_basic ? iter->second : 0.0;
					double fixed = pst_fixed ? iter->second : 0.0;
					double percent = pst_percent ? iter->second : 0.0;
					hero_info_detail.hero_fighter_detail.modify_fight_property((Property_Type)iter->first, AT_EQUIP, O_SET, basic, fixed, percent);
				}
			}
		}

//					// 神器属性
//					artifacts_prop_refresh(it_hero->second);
//
//					// 龙谷属性
//					dragon_vale_prop_refresh(it_hero->second);
//
//					// 符石属性
//					rune_stone_prop_refresh(it_hero->second);
//
//					// 公会技能属性
//					gang_skill_hero_prop_refresh(it_hero->second);
//
//					// 符文属性
//					if (it_hero->first == heroer_detail_->fighter_index) {
//						hero_rune_prop_refresh(it_hero->second);
//					}
//
//					// 战斗精灵属性加成
//					covenant_prop_refresh(it_hero->second);

		// ---------------------- 属性加成 END -------------------------

		// 更新:更新英雄战力
//		hero_info_detail.hero_fighter_detail.update_force();

		// 刷新当前血量
		double blood_max = hero_info_detail.hero_fighter_detail.fetch_fight_property(PT_BLOOD_MAX);
		hero_info_detail.hero_fighter_detail.modify_fight_property(PT_BLOOD_CURRENT, AT_BASIC, O_SET, blood_max, 0.0, 0.0);
	}

	// heroer_skill_refresh(hero_info_detail.hero_index, syn_scene, false);
	{

		// -----------Reset hero skills START --------------------------------------------
		hero_info_detail.hero_fighter_detail.talent_map.clear();
		hero_info_detail.hero_fighter_detail.cur_used_talent_ = 0;
		hero_info_detail.hero_fighter_detail.default_skill = 0;

		// reset skill prop
		for (Int_Set::const_iterator it_prop = FIGHT_PROP_SET.begin(); it_prop != FIGHT_PROP_SET.end(); ++it_prop) {
			hero_info_detail.hero_fighter_detail.modify_fight_property((Property_Type)(*it_prop), AT_PASSIVE_SKILL, O_SET, 0.0, 0.0, 0.0);
			if (PT_BLOOD_MAX == *it_prop) {
				hero_info_detail.hero_fighter_detail.modify_fight_property(PT_BLOOD_CURRENT, AT_PASSIVE_SKILL, O_SET, 0.0, 0.0, 0.0);
			}
		}

		// -----------Reset hero skills END ----------------------------------------------

		//int player_level = player_self()->level();
		int skill_loc = 6;
		int default_skill = 0;

		Talent talent;
		talent.talent_id = 1;
		Skill_DB_Info skill_db_info;

		// 英雄等级技能
		for (uint16_t i_skill_id_vec = 0; i_skill_id_vec < hero_config->skill_id_vec.size(); ++i_skill_id_vec) {
			int skill_id = hero_config->skill_id_vec[i_skill_id_vec];
			const Skill_Config *skill_config = CONFIG_CACHE_FIGHTER->skill_config_cache(skill_id);
			if (! skill_config) {
				continue;
			}

			int skill_level = 0;
			for (Skill_Detail_Map::const_iterator it_skill_lvl_map = skill_config->skill_level_map.begin();
					it_skill_lvl_map != skill_config->skill_level_map.end(); ++it_skill_lvl_map) {
				if (it_skill_lvl_map->second.skill_level > skill_level &&
						hero_info_detail.level >= it_skill_lvl_map->second.lv_lim) {
					skill_level = it_skill_lvl_map->second.skill_level;
				}
			}
			if (! skill_level) {
				continue;
			}
			default_skill = !default_skill ? skill_id : default_skill;
			skill_db_info.reset();
			skill_db_info.skill_id = skill_id;
			skill_db_info.skill_level = 1;

			if (skill_config->skill_type == TYPE_ADD_SKILL) {
				skill_db_info.skill_loc = 9;	// 追加技能放最后位置
			} else {
				skill_db_info.skill_loc = (skill_id == default_skill) ? 0 : skill_loc++;
			}

			talent.skill_db_info_map.insert(std::make_pair(skill_db_info.skill_id, skill_db_info));
		}

		// 英雄觉醒技能
		uint16_t awake_start_index = 0;
		if(hero_info_detail.awake_lvl > 4){
			awake_start_index = hero_info_detail.awake_lvl - 4;
		}
		for (uint16_t i_skill_id_vec = 0;
				i_skill_id_vec < hero_info_detail.awake_lvl && i_skill_id_vec < hero_config->awake_skill_id_vec.size();
				++i_skill_id_vec) {
			if(i_skill_id_vec < awake_start_index){
				continue;
			}
			int skill_id = hero_config->awake_skill_id_vec[i_skill_id_vec];
			const Skill_Config *skill_config = CONFIG_CACHE_FIGHTER->skill_config_cache(skill_id);
			if (! skill_config) {
				continue;
			}

			int skill_level = 0;
			for (Skill_Detail_Map::const_iterator it_skill_lvl_map = skill_config->skill_level_map.begin();
					it_skill_lvl_map != skill_config->skill_level_map.end(); ++it_skill_lvl_map) {
				if (it_skill_lvl_map->second.skill_level > skill_level &&
						hero_info_detail.level >= it_skill_lvl_map->second.lv_lim) {
					skill_level = it_skill_lvl_map->second.skill_level;
				}
			}
			if (! skill_level) {
				continue;
			}
			default_skill = !default_skill ? skill_id : default_skill;

			skill_db_info.reset();
			skill_db_info.skill_id = skill_id;
			skill_db_info.skill_level = skill_level;
			skill_db_info.skill_loc = 0;

			talent.skill_db_info_map.insert(std::make_pair(skill_db_info.skill_id, skill_db_info));
		}
		hero_info_detail.hero_fighter_detail.talent_map[talent.talent_id] = talent;
		hero_info_detail.hero_fighter_detail.cur_used_talent_ = talent.talent_id;
		hero_info_detail.hero_fighter_detail.default_skill = default_skill;

		hero_info_detail.hero_fighter_detail.set_be_skill_attr();
	}
	buf.write_int8(1);

	Hero_Base_Detail base_detail;
	base_detail.master_role_id = 0;		// 主人id
	base_detail.master_role_name = tr_cfg.name;	// 主人名称
	base_detail.hero_index = hero_info_detail.hero_index;					// 英雄index
	base_detail.hero_id = hero_info_detail.hero_id;					// 英雄ID
	base_detail.hero_name = hero_info_detail.hero_name;			// 英雄name
	base_detail.hero_facade_id = hero_info_detail.hero_id;				// 英雄facade_id
	base_detail.hero_formation = hero_info_detail.formation;				// 英雄阵型
	base_detail.hero_level = hero_info_detail.level;					// 英雄等级
	base_detail.awake_lvl = hero_info_detail.awake_lvl;					// 觉醒等级
	base_detail.serialize(buf);

	hero_info_detail.hero_fighter_detail.serialize(buf);
}
Exemplo n.º 12
0
void Smelter_Detail::serialize(Block_Buffer & w) const {
	w.write_int8(smelter_idx);
	w.write_int8(is_open);
}
Exemplo n.º 13
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;
}
int Logic_Outpost_Manager::inner_sync_info(Logic_Player* player, Block_Buffer& buf){
	int8_t sync_type = 0;
	buf.read_int8(sync_type);
	switch(sync_type){
		case 10:{//购买流浪商人物品
			if(!player){
				return 0;
			}
			int scene_id = 0;
			int64_t monster_role_id = 0;
			int item_index = 0;
			int item_id = 0;
			int item_amount = 0;
			int8_t cost_type = 0;
			int cost_num  = 0;

			buf.read_int32(scene_id);
			buf.read_int64(monster_role_id);
			buf.read_int32(item_index);
			buf.read_int32(item_id);
			buf.read_int32(item_amount);
			buf.read_int8(cost_type);
			buf.read_int32(cost_num);

			int buy_result = 0;
			Money_Sub_Info m_s_info((Pack::Money_Sub_Type)cost_type, cost_num, MONEY_SUB_VAGRANT_STORE);
			if(cost_num > 0){
				buy_result = player->pack_try_sub_money(m_s_info);
			}
			if(buy_result != 0){
				player->send_err_to_client(buy_result, REQ_VAGRANT_BUY_ITEM);
				{
					Block_Buffer buf;
					buf.make_message(INNER_SYNC_SCENE_OUTPOST);
					buf.write_int8(sync_type);
					buf.write_int32(scene_id);
					buf.write_int64(monster_role_id);
					buf.write_int32(item_index);
					buf.write_int8(0);
					buf.finish_message();
					player->send_to_scene(buf);
				}
				return 0;
			}
			// 背包检测
			Item_Detail item = Item_Detail(item_id, item_amount, (Item_Detail::Bind_Type)0);
			buy_result = player->pack_try_insert_item(Pack::PACK_T_PACKAGE_INDEX, item);
			if( buy_result != 0){
				player->send_err_to_client(buy_result, REQ_VAGRANT_BUY_ITEM);
				{
					Block_Buffer buf;
					buf.make_message(INNER_SYNC_SCENE_OUTPOST);
					buf.write_int8(sync_type);
					buf.write_int32(scene_id);
					buf.write_int64(monster_role_id);
					buf.write_int32(item_index);
					buf.write_int8(0);
					buf.finish_message();
					player->send_to_scene(buf);
				}
				return 0;
			}
			// 添加到背包
			player->pack_insert_item(Pack::PACK_T_PACKAGE_INDEX, item,Gain_Item_DM_Info(Pack::ITEM_GAIN_VAGRANT_STORE));
			// 扣钱
			if(cost_num > 0){
				player->pack_sub_money(m_s_info);
			}
			{
				MSG_81000102 acv_msg;
				acv_msg.type = 0;
				Item_Basic_Info ibi;
				item.set_item_basic_info(ibi);
				acv_msg.item_info.push_back(ibi);
				OBJ_SEND_TO_CLIENT(acv_msg, (*player));
			}
			Block_Buffer buf;
			buf.make_message(INNER_SYNC_SCENE_OUTPOST);
			buf.write_int8(sync_type);
			buf.write_int32(scene_id);
			buf.write_int64(monster_role_id);
			buf.write_int32(item_index);
			buf.write_int8(1);
			buf.finish_message();
			player->send_to_scene(buf);
			return 0;
			break;
		}
		case 20:{// 宝藏海湾神秘祝福
			int8_t bless_index;
			int cost_type = 0;
			int cost_num = 0;
			buf.read_int8(bless_index);
			buf.read_int32(cost_type);
			buf.read_int32(cost_num);
			int buy_result = 0;
			Money_Sub_Info m_s_info((Pack::Money_Sub_Type)cost_type, cost_num, MONEY_SUB_TBAY_BLESS);
			if(cost_num > 0){
				buy_result = player->pack_try_sub_money(m_s_info);
			}
			if(buy_result != 0){
				player->send_err_to_client(buy_result, REQ_TBAY_BLESS);
				{
					Block_Buffer buf;
					buf.make_message(INNER_SYNC_SCENE_OUTPOST);
					buf.write_int8(sync_type);
					buf.write_int8(bless_index);
					buf.write_int8(0);
					buf.finish_message();
					player->send_to_scene(buf);
				}
				return 0;
			}
			// 扣钱
			if(cost_num > 0){
				player->pack_sub_money(m_s_info);
			}
			Block_Buffer buf;
			buf.make_message(INNER_SYNC_SCENE_OUTPOST);
			buf.write_int8(sync_type);
			buf.write_int8(bless_index);
			buf.write_int8(1);
			buf.finish_message();
			player->send_to_scene(buf);
			return 0;
			break;
		}
		default:{
			break;
		}
	}
	return 0;
}
Exemplo n.º 15
0
int Single_Scene::add_new_monster_point(const int point, bool is_boss, Coord point_coord) {
	Move_Scene::add_new_monster_point(point, is_boss, point_coord);
	//刷流浪商人
	SCENE_OUTPOST_MANAGER->add_new_monster_point(this, point, is_boss, point_coord);

	if(scene_config()){
		// 国内任务特殊处理
		if(CONFIG_CACHE->server_maintainer_cache().game_ver_type == 0){
			if(scene_config()->scene_id == CONFIG_CACHE_ROLE->get_single_first_id() &&
					this->create_scene_args_.type == 0){// 特定副本首通加
				Mover* mover = this->find_mover_with_layer(0, role_id_);
				if(mover && mover->player_self()){
					if(point == 1){// 临时英雄出战
						Block_Buffer buf;
						buf.make_message(INNER_HERO_TMP_OUT_FIGHT);
						buf.write_int8(0);
						buf.write_int32(60210021);
						buf.finish_message();
						mover->player_self()->send_to_logic(buf);
					}else if(point == 2){// 删除临时英雄
						Block_Buffer buf;
						buf.make_message(INNER_HERO_TMP_OUT_FIGHT);
						buf.write_int8(1);
						buf.write_int32(60210021);
						buf.finish_message();
						mover->player_self()->send_to_logic(buf);
					}
				}
			}
		}else{
//			if(scene_config()->scene_id == 80201002
//					&& this->create_scene_args_.type == 0){// 特定副本首通加
//				Mover* mover = this->find_mover_with_layer(0, role_id_);
//				if(mover && mover->player_self()){
//					if(point == 2){// 临时英雄出战
//						Block_Buffer buf;
//						buf.make_message(INNER_HERO_TMP_OUT_FIGHT);
//						buf.write_int8(0);
//						buf.write_int32(60210021);
//						buf.finish_message();
//						mover->player_self()->send_to_logic(buf);
//					}else if(point == 3){// 删除临时英雄
//						Block_Buffer buf;
//						buf.make_message(INNER_HERO_TMP_OUT_FIGHT);
//						buf.write_int8(1);
//						buf.write_int32(60210021);
//						buf.finish_message();
//						mover->player_self()->send_to_logic(buf);
//					}
//				}
//			}
		}

		if(scene_config()->dungeon.pass_con == SCENE_PASS_CON_KILL_ALL){
			if (is_monster_point_all_clear()) {
				is_scene_complete_ = true;
				if(scene_config()->dungeon.relation == 0 ||
						scene_config()->dungeon.relation == -1){
					is_scene_pass_ = true;
					// 副本通关状态
					if(has_scene_pass_box_){// 精英的为没有领取宝箱的状态
						set_pass_status(Move_Scene::SCENE_PASS_STATUS_COMPELTE_NO_RECEIVE);
					}else{
						set_pass_status(Move_Scene::SCENE_PASS_STATUS_COMPELTE_RECEIVE);
					}
					hook_scene_pass();
				}
			}
		}else if(scene_config()->dungeon.pass_con == SCENE_PASS_CON_KILL_BOSS){
			if(is_boss){
				is_scene_complete_ = true;
				if(scene_config()->dungeon.relation == 0 ||
						scene_config()->dungeon.relation == -1){
					is_scene_pass_ = true;
					// 副本通关状态
					if(has_scene_pass_box_){// 精英的为没有领取宝箱的状态
						set_pass_status(Move_Scene::SCENE_PASS_STATUS_COMPELTE_NO_RECEIVE);
					}else{
						set_pass_status(Move_Scene::SCENE_PASS_STATUS_COMPELTE_RECEIVE);
					}
					hook_scene_pass();
				}
			}
		}
	}
	return 0;
}