예제 #1
0
void Config_Cache_Scene::update_single_dungeon_relation(void){
	int scene_index = 0;
	int scene_id = 0;

	// 单人副本
	single_id_index_map_.clear();
	single_dungeon_ids_.clear();
	scene_index = 0;
	scene_id = CONFIG_CACHE_ROLE->player_init_cache().first_single_id;
	while (scene_id != 0) {
		scene_index += 1;
		std::pair<Relation_Map::iterator,bool> ret = single_id_index_map_.insert(std::make_pair(scene_id, scene_index));
		if(ret.second == false){//
			LOG_ABORT("scene config single dungeon next_id error :%d", scene_id);
		}
		single_dungeon_ids_.push_back(scene_id);
		const Scene_Config* cfg = CONFIG_CACHE_SCENE->scene_config_cache(scene_id);
		if (!cfg) {
			break;
		}
		scene_id = cfg->dungeon.next_id;
	}
	// 上古副本
	elite_id_index_map_.clear();
	elite_dungeon_ids_.clear();
	scene_index = 0;
	scene_id = CONFIG_CACHE_ROLE->player_init_cache().first_nor_elite_id;
	while (scene_id != 0) {
		scene_index += 1;
		std::pair<Relation_Map::iterator,bool> ret = elite_id_index_map_.insert(std::make_pair(scene_id, scene_index));
		if(ret.second == false){//
			LOG_ABORT("scene config elite dungeon next_id error :%d", scene_id);
		}
		elite_dungeon_ids_.push_back(scene_id);
		const Scene_Config* cfg = CONFIG_CACHE_SCENE->scene_config_cache(scene_id);
		if (!cfg) {
			break;
		}
		scene_id = cfg->dungeon.next_id;
	}

	// 魔神殿副本
	lord_id_index_map_.clear();
	lord_dungeon_ids_.clear();
	scene_index = 0;
	scene_id = CONFIG_CACHE_ROLE->player_init_cache().first_hor_elite_id;
	while (scene_id != 0) {
		scene_index += 1;
		std::pair<Relation_Map::iterator,bool> ret = lord_id_index_map_.insert(std::make_pair(scene_id, scene_index));
		if(ret.second == false){//
			LOG_ABORT("scene config lord temple dungeon next_id error :%d", scene_id);
		}
		lord_dungeon_ids_.push_back(scene_id);
		const Scene_Config* cfg = CONFIG_CACHE_SCENE->scene_config_cache(scene_id);
		if (!cfg) {
			break;
		}
		scene_id = cfg->dungeon.next_id;
	}
}
예제 #2
0
int main(int argc, char **argv)
{
	int ret;
	odp_shm_t shm;

	if (odp_init_global(NULL, NULL) != 0)
		LOG_ABORT("Failed global init.\n");

	if (odp_init_local() != 0)
		LOG_ABORT("Failed local init.\n");

	shm = odp_shm_reserve("test_globals",
			      sizeof(test_globals_t), ODP_CACHE_LINE_SIZE, 0);
	gbl_args = odp_shm_addr(shm);
	if (gbl_args == NULL)
		LOG_ABORT("Shared memory reserve failed.\n");
	memset(gbl_args, 0, sizeof(test_globals_t));

	parse_args(argc, argv, &gbl_args->args);

	ret = test_init();

	if (ret == 0) {
		ret = run_test();
		test_term();
	}

	return ret;
}
예제 #3
0
int main(int argc, char **argv)
{
	int ret;
	odp_shm_t shm;
	int max_thrs;

	if (odp_init_global(NULL, NULL) != 0)
		LOG_ABORT("Failed global init.\n");

	if (odp_init_local(ODP_THREAD_CONTROL) != 0)
		LOG_ABORT("Failed local init.\n");

	shm = odp_shm_reserve("test_globals",
			      sizeof(test_globals_t), ODP_CACHE_LINE_SIZE, 0);
	gbl_args = odp_shm_addr(shm);
	if (gbl_args == NULL)
		LOG_ABORT("Shared memory reserve failed.\n");
	memset(gbl_args, 0, sizeof(test_globals_t));

	max_thrs = odp_thread_count_max();

	gbl_args->rx_stats_size = max_thrs * sizeof(pkt_rx_stats_t);
	gbl_args->tx_stats_size = max_thrs * sizeof(pkt_tx_stats_t);

	shm = odp_shm_reserve("test_globals.rx_stats",
			      gbl_args->rx_stats_size,
			      ODP_CACHE_LINE_SIZE, 0);

	gbl_args->rx_stats = odp_shm_addr(shm);

	if (gbl_args->rx_stats == NULL)
		LOG_ABORT("Shared memory reserve failed.\n");

	memset(gbl_args->rx_stats, 0, gbl_args->rx_stats_size);

	shm = odp_shm_reserve("test_globals.tx_stats",
			      gbl_args->tx_stats_size,
			      ODP_CACHE_LINE_SIZE, 0);

	gbl_args->tx_stats = odp_shm_addr(shm);

	if (gbl_args->tx_stats == NULL)
		LOG_ABORT("Shared memory reserve failed.\n");

	memset(gbl_args->tx_stats, 0, gbl_args->tx_stats_size);

	parse_args(argc, argv, &gbl_args->args);

	ret = test_init();

	if (ret == 0) {
		ret = run_test();
		test_term();
	}

	return ret;
}
예제 #4
0
void Receiver::init(void) {
	if (heartbeat_timeout_ == Time_Value::zero) {
		if ((reactor_ = new Receiver_Watcher(this)) == 0) {
			LOG_ABORT("new Receiver_Watcher errno:%d", errno);
		}
	} else {
		if ((reactor_ = new Receiver_Watcher(this, Epoll_Watcher::WITH_IO_HEARTBEAT, heartbeat_timeout_.sec())) == 0) {
			LOG_ABORT("Receiver new Reactor errno:%d", errno);
		}
	}
}
예제 #5
0
void Config_Cache::refresh_monitor_link_cache(void) {
	const Json::Value &server_solution = CONFIG_INSTANCE->open_solution();

	int port_prefix = server_maintainer_cache_.game_port_prefix * 1000;

	for (Json::Value::const_iterator monitor_it = server_solution["monitor_list"].begin(); monitor_it != server_solution["monitor_list"].end(); ++monitor_it) {
		for (Json::Value::iterator acceptor_it = (*monitor_it)["acceptor"].begin(); acceptor_it != (*monitor_it)["acceptor"].end(); ++acceptor_it) {
			Monitor_Link_Info monitor_link;

			int run_on = (*monitor_it)["run_on"].asInt();
			Server_Id_IP_Map::iterator ip_find_it = server_ip_ip_cache_.find(run_on);
			if (ip_find_it != server_ip_ip_cache_.end()) {
				monitor_link.telecom_ip = ip_find_it->second.telecom_ip;
				monitor_link.unicom_ip = ip_find_it->second.unicom_ip;
			} else {
				LOG_ABORT("开服run_on:%d不存在", run_on);
			}

			Server_Enum::MONITOR_TYPE monitor_type = (Server_Enum::MONITOR_TYPE)(*acceptor_it)["monitor_type"].asInt();
			int client_port_suffix = (*acceptor_it)["client_port_suffix"].asInt();
			monitor_link.client_port = (*acceptor_it)["ingore_prefix"].asBool() ? client_port_suffix : port_prefix + client_port_suffix;

			int inner_port_suffix = (*acceptor_it)["inner_port_suffix"].asInt();
			monitor_link.inner_port = (*acceptor_it)["ingore_prefix"].asBool() ? inner_port_suffix : port_prefix + inner_port_suffix;

			if ((*acceptor_it)["list"] != Json::Value::null) {
				for (Json::Value::iterator list_it = (*acceptor_it)["list"].begin(); list_it != (*acceptor_it)["list"].end(); ++list_it) {
					Monitor_Unique_ID monitor_index;
					monitor_index.uuid = CONFIG_CACHE->server_flag();
					monitor_index.type = monitor_type;

					if ((*list_it).isArray()) {
						monitor_index.id = (*list_it)[0u].asInt();
						if ((*list_it).size() == 2)
							monitor_index.order = (*list_it)[1u].asInt();
						if ((*list_it).size() > 2)
							LOG_ABORT("open solution error, id:%d", monitor_index.id);
					} else {
						monitor_index.id = (*list_it)["id"].asInt();
						monitor_index.order = (*list_it)["order"].asInt();
					}

					set_map_second_value_by_key(monitor_index, monitor_link_cache_, monitor_link);
				}
			} else {
				Monitor_Unique_ID monitor_index(CONFIG_CACHE->server_flag(), monitor_type, 0, 0);
				set_map_second_value_by_key(monitor_index, monitor_link_cache_, monitor_link);
			}
		}
	}
}
void Config_Cache_Fashion::refresh_reinforced_map(void) {

	const Json::Value& json = CONFIG_INSTANCE->config_json()["fashion"]["fashion_reinforced"];
	Fashion_Reinforced_Cfg cfg;
	for (Json::Value::const_iterator it = json.begin(); it != json.end(); ++it) {
		cfg.reset();
		cfg.lv = (*it)["reinforced_lvl"].asInt();
		cfg.part = (*it)["fashion_part"].asInt();
		cfg.percent = (*it)["reinforced_perce"].asInt();
		cfg.coin_cost = (*it)["reinforced_cost"].asInt();
		cfg.suc_rate = (*it)["reinforcedl_rate"].asInt();
		cfg.exp_add = (*it)["power_add"].asInt();
		cfg.exp_max = (*it)["power_max"].asInt();

		if (!(*it)["reinforced_prop"].isArray()) continue;
		for (Json::Value::const_iterator prop_it = (*it)["reinforced_prop"].begin();
				prop_it != (*it)["reinforced_prop"].end(); ++prop_it) {
			if (!(*prop_it).isArray() || 2 != (*prop_it).size()) {
				LOG_ABORT("fashion_reinforced prop error, lv=%d, part=%d", cfg.lv, cfg.part);
			}
			cfg.wore_props_map[(*prop_it)[0u].asInt()] = (*prop_it)[1].asDouble();
		}

		if (!(*it)["reinforced_cost_item"].isArray()) continue;
		cfg.item_cost.val_1 = (*it)["reinforced_cost_item"][0u].asInt();
		cfg.item_cost.val_2 = (*it)["reinforced_cost_item"][1].asInt();

		fashion_reinforced_map_[cfg.part][cfg.lv] = cfg;
	}
}
예제 #7
0
void AI_Machine::init(void) {

	const Json::Value &all_ai_json = CONFIG_INSTANCE->config_json()["ai"]["ai_behavior"];
	if (all_ai_json == Json::Value::null) {
		LOG_ABORT("configure file error.");
	}

	for (Json::Value::iterator iter = all_ai_json.begin(); iter != all_ai_json.end(); ++iter) {
		int ai_id = atoi(iter.key().asCString());
		AI_Data *ai_data = new AI_Data;
		Composite_Node *ai_behavior = new CompositeNode_Selector();
		ai_data->ai_behavior = ai_behavior;
		behavior_init(*iter, ai_behavior);
		ai_data_map_.insert(std::make_pair(ai_id, ai_data));
	}

	{
		Composite_Node* pselect_idle = new CompositeNode_Selector();
		pselect_idle->add_child(CREATE_TERMINATE_NODE(Be_Idle));
		blockhead_ai_ = pselect_idle;
	}

	{
		Composite_Node* psequence_ai_behavior = new CompositeNode_Sequence();
		psequence_ai_behavior->add_child(CREATE_TERMINATE_NODE(Co_Idle_Status));
		psequence_ai_behavior->add_child(CREATE_TERMINATE_NODE(Be_Idle));
		//psequence_ai_behavior->add_child(CREATE_TERMINATE_NODE(Co_Die_Status));
		//psequence_ai_behavior->add_child(CREATE_TERMINATE_NODE(Be_NPC_Recover));
		normal_ai_ = psequence_ai_behavior;
	}

}
예제 #8
0
int Message_Unit::register_inner_process(const uint32_t msg_id, Inner_Func callback) {
	Inner_Func_Map::iterator find_it = inner_message_func_.find(msg_id);
	if (find_it != inner_message_func_.end())
		LOG_ABORT("rebind msg_id:%d", msg_id);
	inner_message_func_[msg_id] = callback;
	return 0;
}
void Config_Cache_Honor_Arena::refresh_rank(void){
	const Json::Value &config = CONFIG_INSTANCE->config_json()["arena_multi"]["pk_rank"];
	Honor_Arena_Rank_Config cache;

	for (Json::Value::iterator it = config.begin();it != config.end(); ++it){
		const Json::Value &config_json = (*it);

		cache.reset();

		if (config_json.isMember("rank")){
			if(config_json["rank"].size() == 2){
				cache.rank.val_1 = config_json["rank"][0u].asInt();
				cache.rank.val_2 = config_json["rank"][1u].asInt();
			}else{
				LOG_ABORT("honor arena pk_rank config error(rank)");
			}

		}

		if (config_json.isMember("award")){
			Json_Utility::assign_int_int_vec(config_json["award"], cache.award);
		}

		set_map_second_value_by_key(cache.rank.val_1, cfg_rank_map_, cache);
	}
}
예제 #10
0
void Config_Cache::check_cache_solution(void) {
	{
		// 跨服不需要检查(调试版也不能检查了)
		const Json::Value &server_solution = CONFIG_INSTANCE->open_solution();
		int inter_solution_id = server_solution["inter_solution_id"].asInt();
		if (inter_solution_id) {
			// 场景不在开服方案
			const Server_Solution_Cache &server_solution_cache = CONFIG_CACHE->server_solution_cache();
			Monitor_Mark_Vec muid;
			Scene_Unique_ID scene_uid;
			Hash_Map<Scene_Unique_ID, Monitor_Unique_ID, NULL_MUTEX> scene_muid_map_;
			server_solution_cache.fetch_muid_by_type(muid, Server_Enum::MONITOR_SCENE);
			for (Monitor_Mark_Vec::iterator it = muid.begin(); it != muid.end(); ++it) {
				scene_uid.scene_id = (*it).id;
				scene_uid.scene_order = (*it).order;
				if (scene_muid_map_.bind(scene_uid, (*it))) {
					LOG_ABORT("scene repeat, scene_id:%d, scene_order:%d", (*it).id, (*it).order);
				}
			}

			const Json::Value json_scene = CONFIG_INSTANCE->config_json()["scene"]["scene_config"];
			for (Json::Value::const_iterator it = json_scene.begin(); it != json_scene.end(); it++) {
				int scene_id = (*it)["sceneId"].asInt();
				Monitor_Unique_ID muid;
				Scene_Unique_ID suid(scene_id, 0);
				if (scene_muid_map_.find(suid, muid)) {
					LOG_ABORT("场景:%d不在开服方案", scene_id);
				}
			}

			Hash_Map<Scene_Unique_ID, Monitor_Unique_ID, NULL_MUTEX>::iterator begin = scene_muid_map_.begin();
			Hash_Map<Scene_Unique_ID, Monitor_Unique_ID, NULL_MUTEX>::iterator end = scene_muid_map_.end();
			for (Hash_Map<Scene_Unique_ID, Monitor_Unique_ID, NULL_MUTEX>::iterator it = begin; it != end; ++it) {
				const Scene_Config *scene_config = CONFIG_CACHE_SCENE->scene_config_cache(it->first.scene_id);
				if (!scene_config) {
					LOG_ABORT("方案场景:%d找不到配制", it->first.scene_id);
				}

				int map_id = scene_config->map_id ? scene_config->map_id : scene_config->scene_id;
				if (!CONFIG_CACHE_SCENE->scene_map_data_cache(map_id)) {
					LOG_ABORT("场景:%d地图%d不存在", scene_config->scene_id, map_id);
				}
			}
		}
	}

}
예제 #11
0
static int test_init(void)
{
	odp_pool_param_t params;
	odp_queue_param_t qparam;
	odp_queue_t inq_def;
	char inq_name[ODP_QUEUE_NAME_LEN];

	memset(&params, 0, sizeof(params));
	params.pkt.len     = PKT_HDR_LEN + gbl_args->args.pkt_len;
	params.pkt.seg_len = params.pkt.len;
	params.pkt.num     = PKT_BUF_NUM;
	params.type        = ODP_POOL_PACKET;

	transmit_pkt_pool = odp_pool_create("pkt_pool_transmit",
						  ODP_SHM_NULL, &params);
	if (transmit_pkt_pool == ODP_POOL_INVALID)
		LOG_ABORT("Failed to create transmit pool\n");

	odp_atomic_init_u32(&ip_seq, 0);
	odp_atomic_init_u32(&shutdown, 0);

	/* create pktios and associate input/output queues */
	gbl_args->pktio_tx = create_pktio(gbl_args->args.ifaces[0]);
	if (gbl_args->args.num_ifaces > 1)
		gbl_args->pktio_rx = create_pktio(gbl_args->args.ifaces[1]);
	else
		gbl_args->pktio_rx = gbl_args->pktio_tx;

	if (gbl_args->pktio_rx == ODP_PKTIO_INVALID ||
	    gbl_args->pktio_tx == ODP_PKTIO_INVALID) {
		LOG_ERR("failed to open pktio\n");
		return -1;
	}

	/* create and associate an input queue for the RX side */
	qparam.sched.prio  = ODP_SCHED_PRIO_DEFAULT;
	qparam.sched.sync  = ODP_SCHED_SYNC_NONE;
	qparam.sched.group = ODP_SCHED_GROUP_DEFAULT;

	snprintf(inq_name, sizeof(inq_name), "inq-pktio-%" PRIu64,
		 odp_pktio_to_u64(gbl_args->pktio_rx));
	inq_def = odp_queue_lookup(inq_name);
	if (inq_def == ODP_QUEUE_INVALID)
		inq_def = odp_queue_create(inq_name,
				ODP_QUEUE_TYPE_PKTIN, &qparam);

	if (inq_def == ODP_QUEUE_INVALID)
		return -1;

	if (odp_pktio_inq_setdef(gbl_args->pktio_rx, inq_def) != 0)
		return -1;

	return 0;
}
예제 #12
0
int Message_Unit::process_ptr_list(void) {
	// 连接日志服
	int loop = 0;
	while (true) {
		if (loop++ >= 10)
			LOG_ABORT("sync record error, type:%d, idx:%d", monitor_->type(), monitor_->monitor_idx());
		if (RECORD_CLIENT->sync_pid(monitor_->type(), monitor_->monitor_idx())) {
			Time_Value::sleep(Time_Value(3, 0));
			LOG_DEBUG("sync record error, type:%d, idx:%d", monitor_->type(), monitor_->monitor_idx());
		} else {
			break;
		}
	}

	this->is_running_ = true;

	Unit_Message *ptr_data = 0;

	Time_Value last_t = Time_Value::gettimeofday();
	while (1) {
    	if (!data_ptr_list_.pop(ptr_data)) {
        	switch (ptr_data->unit_type) {
        		case Unit_Message::TYPE_UNIT_CLIENT: {
        			process_client_buffer(*(Block_Buffer *)ptr_data->ptr_data);
        			break;
        		}
        		case Unit_Message::TYPE_UNIT_CONNECT_SERVER:
          		case Unit_Message::TYPE_UNIT_ACCEPT_SERVER: {
        			process_server_buffer(*(Block_Buffer *)ptr_data->ptr_data);
            		break;
            	}
          		case Unit_Message::TYPE_UNIT_TIMER: {
        			process_timer_buffer(*(Block_Buffer *)ptr_data->ptr_data);
            		break;
            	}
          		case Unit_Message::TYPE_UNIT_LOOP: {
        			process_async_data(ptr_data->data_type, ptr_data->ptr_data);
            		break;
            	}
          		default: {
          			break;
          		}
        	}

        	recover_ptr_body(ptr_data);

        	recover_ptr_shell(ptr_data);
    	}
	}

	return 0;
}
예제 #13
0
파일: aggr.cpp 프로젝트: songhtdo/vespa
Aggregator &
Aggregator::create(Aggr aggr, Stash &stash)
{
    switch (aggr) {
    case Aggr::AVG:   return stash.create<Avg>();
    case Aggr::COUNT: return stash.create<Count>();
    case Aggr::PROD:  return stash.create<Prod>();
    case Aggr::SUM:   return stash.create<Sum>();
    case Aggr::MAX:   return stash.create<Max>();
    case Aggr::MIN:   return stash.create<Min>();
    }
    LOG_ABORT("should not be reached");
}
void Config_Cache_Fashion::refresh_base_map(void) {

	const Json::Value& json = CONFIG_INSTANCE->config_json()["fashion"]["fashion_lvl_base_new"];
	Fashion_Base_Cfg cfg;
	for (Json::Value::const_iterator it = json.begin(); it != json.end(); ++it) {
		cfg.reset();
		cfg.id = (*it)["fashion_id"].asInt();
		cfg.part = (*it)["fashion_part"].asInt();
		cfg.exp = (*it)["exp"].asInt();
		cfg.suit_id = (*it)["suit_id"].asInt();

		if (!(*it)["prop_hide"].isArray()) continue;
		for (Json::Value::const_iterator prop_it = (*it)["prop_hide"].begin();
				prop_it != (*it)["prop_hide"].end(); ++prop_it) {
			if (!(*prop_it).isArray() || 2 != (*prop_it).size()) {
				LOG_ABORT("prop_hide error, fashion_id=%d", cfg.id);
			}
			cfg.hidden_props_map[(*prop_it)[0u].asInt()] = (*prop_it)[1].asDouble();
		}
		if (!(*it)["prop_wire"].isArray()) continue;
		for (Json::Value::const_iterator prop_it = (*it)["prop_wire"].begin();
				prop_it != (*it)["prop_wire"].end(); ++prop_it) {
			if (!(*prop_it).isArray() || 2 != (*prop_it).size()) {
				LOG_ABORT("prop_wire error, fashion_id=%d", cfg.id);
			}
			cfg.wore_props_map[(*prop_it)[0u].asInt()] = (*prop_it)[1].asDouble();
		}
		if (!(*it)["avatars"].isArray())
			LOG_ABORT("fashion no avatar config, id=%d", cfg.id);
		for (Json::Value::const_iterator avatar_it = (*it)["avatars"].begin();
				avatar_it != (*it)["avatars"].end(); ++avatar_it) {
			if (!(*avatar_it).isArray() || 3 != (*avatar_it).size()) {
				LOG_ABORT("avatars error, fashion_id=%d", cfg.id);
			}
			cfg.fashion_avatar_map[(*avatar_it)[0u].asInt()][(*avatar_it)[1].asInt()] = (*avatar_it)[2].asInt();
		}
		fashion_base_map_[cfg.id] = cfg;
	}
}
예제 #15
0
void Config_Cache::refresh_server_list_cache(void) {
	server_list_map_.clear();
	const Json::Value &servers_config = CONFIG_INSTANCE->config_json()["server_global_conf"]["server_list"];
	if (servers_config == Json::Value::null || servers_config["server_list"].size() == 0) {
		LOG_ABORT("");
	}

	int agent = 0;
	int server = 0;
	for (uint i = 0; i < servers_config["server_list"].size(); ++i) {
		agent = servers_config["server_list"][i]["agent_num"].asInt();
		server = servers_config["server_list"][i]["server_num"].asInt();
		if (agent < 100 || agent > 999 || server < 1000 || server > 9999) {
			LOG_ABORT("");
		}

		set_map_second_value_by_key(Server_Key(agent, server), server_list_map_, i);
	}

	if (server_list_map_.empty()) LOG_ABORT("");

	server_flag_ = (*server_list_map_.begin()).first.agent_num * 10000;
	server_flag_ += (*server_list_map_.begin()).first.server_num;
}
예제 #16
0
static void *run_thread_rx(void *arg)
{
	test_globals_t *globals;
	int thr_id, batch_len;
	odp_queue_t pollq = ODP_QUEUE_INVALID;

	thread_args_t *targs = arg;

	batch_len = targs->batch_len;

	if (batch_len > BATCH_LEN_MAX)
		batch_len = BATCH_LEN_MAX;

	thr_id = odp_thread_id();

	globals = odp_shm_addr(odp_shm_lookup("test_globals"));

	pkt_rx_stats_t *stats = &globals->rx_stats[thr_id];

	if (gbl_args->args.schedule == 0) {
		pollq = odp_pktio_inq_getdef(globals->pktio_rx);
		if (pollq == ODP_QUEUE_INVALID)
			LOG_ABORT("Invalid input queue.\n");
	}

	odp_barrier_wait(&globals->rx_barrier);
	while (1) {
		odp_event_t ev[BATCH_LEN_MAX];
		int i, n_ev;

		n_ev = receive_packets(pollq, ev, batch_len);

		for (i = 0; i < n_ev; ++i) {
			if (odp_event_type(ev[i]) == ODP_EVENT_PACKET) {
				odp_packet_t pkt = odp_packet_from_event(ev[i]);
				if (pktio_pkt_has_magic(pkt))
					stats->s.rx_cnt++;
				else
					stats->s.rx_ignore++;
			}
			odp_buffer_free(odp_buffer_from_event(ev[i]));
		}
		if (n_ev == 0 && odp_atomic_load_u32(&shutdown))
			break;
	}

	return NULL;
}
예제 #17
0
int DB_Manager::create_db_view(DB_View *&db_view) {
	LOG_DEBUG("db_view is created");
	PERF_MON("create_db_view");
	if ((db_view = new DB_View) == 0) {
		LOG_ABORT("new DB_View return 0.");
	}

	const Server_List_Map &list = CONFIG_CACHE->server_list_map();
	for (Server_List_Map::const_iterator it = list.begin(); it != list.end(); ++it) {
		int64_t agent_l = it->first.agent_num * 10000000000000L;
		int64_t server_l = it->first.server_num * 1000000000L;
		db_view->server_amount_map.insert(std::make_pair(it->first, agent_l + server_l + 0));
	}

	return MONGO_OPERATOR->load_db_view(db_view);
}
예제 #18
0
파일: odp_l2fwd.c 프로젝트: mitra/odp-mppa
/**
 * Lookup the destination port for a given packet
 *
 * @param pkt  ODP packet handle
 */
static inline int lookup_dest_port(odp_packet_t pkt)
{
	int i, src_idx;
	odp_pktio_t pktio_src;

	pktio_src = odp_packet_input(pkt);

	for (src_idx = -1, i = 0; gbl_args->pktios[i] != ODP_PKTIO_INVALID; ++i)
		if (gbl_args->pktios[i] == pktio_src)
			src_idx = i;

	if (src_idx == -1)
		LOG_ABORT("Failed to determine pktio input\n");

	return gbl_args->dst_port[src_idx];
}
void Config_Cache_Ranking::refresh_config_cache(void) {
	Ranking_Config base_set;
	const Json::Value& hero_critical_json = CONFIG_INSTANCE->config_json()["rank"]["conf"];
	if (hero_critical_json == Json::Value::null || hero_critical_json.size() == 0) {
		LOG_ABORT("");
	}
	for (uint i = 0; i < hero_critical_json.size(); ++i) {
		base_set.reset();
		const Json::Value& critical_json = hero_critical_json[i];
		base_set.type = critical_json["type"].asInt();
		base_set.num = critical_json["num"].asInt();
		base_set.time = critical_json["time"].asInt() * 60;
		base_set.day = critical_json["day"].asInt();
		base_set.week = critical_json["week"].asInt();
		set_map_second_value_by_key(base_set.type, ranking_config_, base_set);
	}
}
예제 #20
0
void Config_Cache::refresh_mysql_init_config(void) {
	mysql_init_sql_map_.clear();
	const Json::Value &mysql_init_config = CONFIG_INSTANCE->config_json()["mysql"]["init"];
	if (mysql_init_config == Json::Value::null || mysql_init_config.size() == 0) {
		LOG_ABORT("");
	}

	std::string table_name = "";
	std::string create_sql = "";
	for (uint i = 0; i < mysql_init_config.size(); ++i) {
		table_name = mysql_init_config[i]["table_name"].asString();
		create_sql = mysql_init_config[i]["create_sql"].asString();
		String_String_Map::iterator it = mysql_init_sql_map_.find("table_name");
		if(table_name != "" && create_sql != "" && it == mysql_init_sql_map_.end()){
			mysql_init_sql_map_.insert(std::make_pair(table_name, create_sql));
		}
	}
}
예제 #21
0
/**
 * Lookup the destination pktio for a given packet
 */
static inline odp_queue_t lookup_dest_q(odp_packet_t pkt)
{
	int i, src_idx, dst_idx;
	odp_pktio_t pktio_src, pktio_dst;

	pktio_src = odp_packet_input(pkt);

	for (src_idx = -1, i = 0; gbl_args->pktios[i] != ODP_PKTIO_INVALID; ++i)
		if (gbl_args->pktios[i] == pktio_src)
			src_idx = i;

	if (src_idx == -1)
		LOG_ABORT("Failed to determine pktio input\n");

	dst_idx = (src_idx % 2 == 0) ? src_idx+1 : src_idx-1;
	pktio_dst = gbl_args->pktios[dst_idx];

	return odp_pktio_outq_getdef(pktio_dst);
}
void Config_Cache_Fashion::refresh_soul_map(void) {

	const Json::Value& json = CONFIG_INSTANCE->config_json()["fashion"]["fashion_soul"];
	Fashion_Soul_Cfg cfg;
	for (Json::Value::const_iterator it = json.begin(); it != json.end(); ++it) {
		cfg.reset();
		cfg.lv = (*it)["soul_lvl"].asInt();
		cfg.exp = (*it)["soul_exp"].asInt();

		if (!(*it)["soul_prop"].isArray()) continue;
		for (Json::Value::const_iterator prop_it = (*it)["soul_prop"].begin();
				prop_it != (*it)["soul_prop"].end(); ++prop_it) {
			if (!(*prop_it).isArray() || 3 != (*prop_it).size()) {
				LOG_ABORT("fashion_soul error, lv=%d", cfg.lv);
			}
			cfg.props_map[(*prop_it)[0u].asInt()] = (*prop_it)[1].asDouble();
		}

		fashion_soul_map_[cfg.lv] = cfg;
	}
}
예제 #23
0
const ConfigValue
FRTConfigResponseV3::readConfigValue() const
{
    vespalib::string md5(_data->get()[RESPONSE_CONFIG_MD5].asString().make_string());
    CompressionInfo info;
    info.deserialize(_data->get()[RESPONSE_COMPRESSION_INFO]);
    Slime * rawData = new Slime();
    SlimePtr payloadData(rawData);
    DecompressedData data(decompress(((*_returnValues)[1]._data._buf), ((*_returnValues)[1]._data._len), info.compressionType, info.uncompressedSize));
    if (data.memRef.size > 0) {
        size_t consumedSize = JsonFormat::decode(data.memRef, *rawData);
        if (consumedSize == 0) {
            std::string json(make_json(*payloadData, true));
            LOG(error, "Error decoding JSON. Consumed size: %lu, uncompressed size: %u, compression type: %s, assumed uncompressed size(%u), compressed size: %u, slime(%s)", consumedSize, data.size, compressionTypeToString(info.compressionType).c_str(), info.uncompressedSize, ((*_returnValues)[1]._data._len), json.c_str());
            LOG_ABORT("Error decoding JSON");
        }
    }
    if (LOG_WOULD_LOG(spam)) {
        LOG(spam, "read config value md5(%s), payload size: %lu", md5.c_str(), data.memRef.size);
    }
    return ConfigValue(PayloadPtr(new V3Payload(payloadData)), md5);
}
예제 #24
0
void Config_Cache::refresh_server_solution_cache(void) {
	if (!server_maintainer_cache_.game_port_prefix) {
		LOG_ABORT("error port prefix");
	}
	server_solution_cache_.reset();

	const Json::Value &server_solution = CONFIG_INSTANCE->open_solution();
	server_solution_cache_.solution_id = server_solution["solution_id"].asInt();

	int port_prefix = server_maintainer_cache_.game_port_prefix * 1000;

	int index = 0;
	Hash_Map<Monitor_Unique_ID, int, NULL_MUTEX> repeat_muid_check;
	for (Json::Value::const_iterator monitor_it = server_solution["monitor_list"].begin(); monitor_it != server_solution["monitor_list"].end(); ++monitor_it) {
		Monitor_Info server_monitor;

		server_monitor.name = (*monitor_it)["name"].asString();
		server_monitor.command = (*monitor_it)["command"].asString();
		server_monitor.run_on = (*monitor_it)["run_on"].asInt();
		server_monitor.index = index++;
		server_monitor.check = (*monitor_it)["check"].asString();

		Int_Set m_set;
		for (Json::Value::iterator acceptor_it = (*monitor_it)["acceptor"].begin(); acceptor_it != (*monitor_it)["acceptor"].end(); ++acceptor_it) {
			Monitor_Acceptor acceptor;

			acceptor.monitor_type = (Server_Enum::MONITOR_TYPE)(*acceptor_it)["monitor_type"].asInt();
			if (m_set.count(acceptor.monitor_type)) {
				LOG_ABORT("error repeat config monitor type:%d", acceptor.monitor_type);
			}
			m_set.insert(acceptor.monitor_type);

			acceptor.client_port_suffix = (*acceptor_it)["client_port_suffix"].asInt();
			acceptor.client_port = (*acceptor_it)["ingore_prefix"].asBool() ? acceptor.client_port_suffix : port_prefix + acceptor.client_port_suffix;

			acceptor.inner_port_suffix = (*acceptor_it)["inner_port_suffix"].asInt();
			acceptor.inner_port = (*acceptor_it)["ingore_prefix"].asBool() ? acceptor.inner_port_suffix : port_prefix + acceptor.inner_port_suffix;

			if ((*acceptor_it)["client_recv_timeout"] != Json::Value::null) {
				// 内网客户端要调试,特殊处理
				if (CONFIG_CACHE->server_maintainer_cache().md5_key.empty())
					acceptor.client_recv_timeout = Time_Value(900);
				else
					Json_Utility::assign_time_value((*acceptor_it)["client_recv_timeout"], acceptor.client_recv_timeout);
			}

			if ((*acceptor_it)["inner_recv_timeout"] != Json::Value::null)
				Json_Utility::assign_time_value((*acceptor_it)["inner_recv_timeout"], acceptor.inner_recv_timeout);

			Monitor_Unique_ID monitor_index;
			monitor_index.type = acceptor.monitor_type;
			monitor_index.uuid = CONFIG_CACHE->server_flag();
			monitor_index.port = acceptor.inner_port;
			Server_Id_IP_Map::iterator ip_find_it = server_ip_ip_cache_.find(server_monitor.run_on);
			if (ip_find_it != server_ip_ip_cache_.end())
				monitor_index.ip = ip_find_it->second.telecom_ip;
			else
				LOG_ABORT("开服run_on不存在:%d", server_monitor.run_on);
			if ((*acceptor_it)["list"] != Json::Value::null) {
				for (Json::Value::iterator list_it = (*acceptor_it)["list"].begin(); list_it != (*acceptor_it)["list"].end(); ++list_it) {
					if ((*list_it).isArray()) {
						monitor_index.id = (*list_it)[0u].asInt();
						if ((*list_it).size() == 2)
							monitor_index.order = (*list_it)[1u].asInt();
						if ((*list_it).size() > 2)
							LOG_ABORT("open solution error, id:%d", monitor_index.id);
					} else {
						monitor_index.id = (*list_it)["id"].asInt();
						monitor_index.order = (*list_it)["order"].asInt();
					}
					if (repeat_muid_check.exist(monitor_index))
						LOG_ABORT("repeat monitor, id:%d", monitor_index.id);
					repeat_muid_check.bind(monitor_index, 1);
					acceptor.monitor_id_order_vec_.push_back(monitor_index);
					if (server_monitor.run_on > 8000) {
						server_solution_cache_.inter_server.insert(monitor_index.id);
					}
				}
			} else {
				acceptor.monitor_id_order_vec_.push_back(monitor_index);
			}

			server_monitor.acceptor_list.push_back(acceptor);
		}
		server_solution_cache_.monitor_list.push_back(server_monitor);
	}
}
예제 #25
0
void Config_Cache::refresh_maintainer_cache(void) {
	const Json::Value &server_identity = CONFIG_INSTANCE->config_json()["server_global_conf"]["server_identity"];
	server_maintainer_cache_.server_identity = server_identity["server_identity"].asInt();
	ABORT_INT_ZERO(server_maintainer_cache_.server_identity);

	const Json::Value &server_maintainer = CONFIG_INSTANCE->config_json()["server_global_conf"]["server_maintainer"];
	if (server_maintainer.isMember("record_log_level")) {
		std::string skill_extra_bit = server_maintainer["record_log_level"].asCString();
		Json_Utility::assign_int_by_string(skill_extra_bit, server_maintainer_cache_.record_log_level);
	}

	if (server_maintainer.isMember("package_frequency")) {
		server_maintainer_cache_.package_frequency = server_maintainer["package_frequency"].asUInt();
	}

	if (server_maintainer.isMember("local_log_level")) {
		std::string skill_extra_bit = server_maintainer["local_log_level"].asCString();
		Json_Utility::assign_int_by_string(skill_extra_bit, server_maintainer_cache_.local_log_level);
	}

	if (server_maintainer.isMember("game_ver_type")) {
		server_maintainer_cache_.game_ver_type = server_maintainer["game_ver_type"].asInt();
	}

	if (server_maintainer_cache_.game_open_time == Time_Value::zero) {
		server_maintainer_cache_.game_open_time.sec(server_maintainer["game_open_time"].asInt());
	}

	if (server_maintainer_cache_.game_merge_time == Time_Value::zero) {
		server_maintainer_cache_.game_merge_time.sec(server_maintainer["game_merge_time"].asInt());
	}

	server_maintainer_cache_.game_server_flag = server_maintainer["game_server_flag"].asString();
	server_maintainer_cache_.platform_des = server_maintainer["platform_des"].asString();

	server_maintainer_cache_.game_port_prefix = server_maintainer["game_port_prefix"].asInt();
	server_maintainer_cache_.game_solution_id = server_maintainer["game_solution_id"].asInt();
	server_maintainer_cache_.server_close_delay = server_maintainer["server_close_delay"].asInt();

	server_maintainer_cache_.game_inter_flag = CONFIG_INSTANCE->config_json()["server_global_conf"]["server_inter"]["inter_area"].asInt();

	server_maintainer_cache_.db_work_num = server_maintainer["db_work_num"].asInt();
	server_maintainer_cache_.record_output_type = server_maintainer["record_output_type"].asInt();
	server_maintainer_cache_.record_id = server_maintainer["record_id"].asInt();
	server_maintainer_cache_.md5_key = server_maintainer["md5_key"].asString();
	server_maintainer_cache_.verify_msg_time = server_maintainer["verify_msg_time"].asBool();
	server_maintainer_cache_.config_not_update = server_maintainer["config_not_update"].asBool();
	server_maintainer_cache_.valgrind_allow = server_maintainer["valgrind_allow"].asBool();

	if (server_maintainer.isMember("inner_tick_time"))
		Json_Utility::assign_time_value(server_maintainer["inner_tick_time"], server_maintainer_cache_.inner_tick_time_);
	if (server_maintainer.isMember("inner_time_out"))
		Json_Utility::assign_time_value(server_maintainer["inner_time_out"], server_maintainer_cache_.inner_time_out_);
	if (server_maintainer_cache_.inner_tick_time_ == Time_Value::zero)
		LOG_ABORT("error inner_tick_time_");
	if (server_maintainer_cache_.inner_time_out_ == Time_Value::zero)
		LOG_ABORT("error inner_time_out");

	const Json::Value &server_miscellaneous = CONFIG_INSTANCE->config_json()["server_global_conf"]["server_miscellaneous"];
	if (server_miscellaneous.isMember("command")) {
		server_maintainer_cache_.command_mode = server_miscellaneous["command"]["mode"].asInt();
	}

	server_maintainer_cache_.chat_monitor_url = server_miscellaneous["chat_monitor_url"].asString();
	server_maintainer_cache_.chat_monitor_key = server_miscellaneous["chat_monitor_key"].asString();
	server_maintainer_cache_.pt_server_id = server_miscellaneous["pt_server_id"].asString();

	server_maintainer_cache_.mongo_ip = server_maintainer["mongodb_server"]["ip"].asString();
	server_maintainer_cache_.mongo_port = server_maintainer["mongodb_server"]["port"].asInt();

	server_maintainer_cache_.mysql_ip = server_maintainer["mysql_server"]["ip"].asString();
	server_maintainer_cache_.mysql_port = server_maintainer["mysql_server"]["port"].asInt();
	server_maintainer_cache_.mysql_user = server_maintainer["mysql_server"]["user"].asString();
	server_maintainer_cache_.mysql_pw = server_maintainer["mysql_server"]["passwd"].asString();
	server_maintainer_cache_.mysql_dbname = server_maintainer["mysql_server"]["dbname"].asString();

	ABORT_STRING_NULL(server_maintainer_cache_.game_server_flag);
	ABORT_INT_ZERO(server_maintainer_cache_.game_port_prefix);
	ABORT_INT_ZERO(server_maintainer_cache_.game_solution_id);

}
예제 #26
0
Tensor::UP
WrappedSimpleTensor::join(join_fun_t, const Tensor &) const
{
    LOG_ABORT("should not be reached");
}
예제 #27
0
Tensor::UP
WrappedSimpleTensor::reduce(join_fun_t, const std::vector<vespalib::string> &) const
{
    LOG_ABORT("should not be reached");
}
예제 #28
0
void Config_Cache_Team::refresh_config_cache(void) {
	PERF_MON("Config_Cache_Team");

	// task_setting ======================================
	{
		const Json::Value& team_setting_json = CONFIG_INSTANCE->config_json()["team"]["team_setting"];
		if (!team_setting_json.isNull() && team_setting_json.isArray() && team_setting_json.size() > 0) {
			// task_type
			if (team_setting_json[0u]["max_player"] != Json::Value::null)
				team_config_.max_player = team_setting_json[0u]["max_player"].asInt();
			team_config_.profile_num_fb = team_setting_json[0u]["profile_num"].asInt();
			team_config_.profile_num_sports = team_setting_json[0u]["profile_num_sports"].asInt();
			team_config_.profile_num_hero_dream = team_setting_json[0u]["profile_num_hero_dream"].asInt();
			team_config_.profile_num_defend = team_setting_json[0u]["profile_num_defend"].asInt();
	//		team_config_.words = team_setting_json["words"].asString();
			team_config_.offline_limit = Time_Value::zero;
			team_config_.offline_limit.sec(team_setting_json[0u]["offline_limit"].asInt());
			team_config_.robot_task = team_setting_json[0u]["robot_task"].asInt();
			if (team_config_.robot_task == 0) {
				MSG_USER("robot_task empty!");
			}
			team_config_.friendship_timelimit = team_setting_json[0u]["friendship"].asInt();
			if (!team_setting_json[0u]["world_invite_cost"].isNull() && team_setting_json[0u]["world_invite_cost"].isArray()) {
				Json_Utility::assign_item_vec(team_setting_json[0u]["world_invite_cost"], team_config_.world_invite_cost);
			}
		}

		const Json::Value& team_json = CONFIG_INSTANCE->config_json()["team"]["team"];
		for (Json::Value::iterator it = team_json.begin();
					it != team_json.end(); ++it) {
			Team_Scene_Config::Scene_Type key = (Team_Scene_Config::Scene_Type)((*it)["type"].asInt());//程序从0开始
			int value = (*it)["scene_id"].asInt();
			set_map_second_value_by_key(key, team_config_.scene.data, value);
		}
	}
	// task_setting ======================================

	{
		arena_multi_cfg_win_.clear();
		arena_multi_cfg_fail_.clear();
		const Json::Value& json = CONFIG_INSTANCE->config_json()["arena_multi"]["arena"];
		Arena_Multi_Detail detail;
		for (Json::Value::iterator it = json.begin(); it != json.end(); ++it) {
			detail.reset();
			detail.level_ = (*it)["tier"].asInt();
			detail.victory_ = (*it)["victory"].asInt();
			detail.friendship_ = (*it)["friendly"].asInt();
			detail.integrate_ = (*it)["credit"].asInt();
			detail.exp_ = (*it)["exp"].asInt();
			detail.gold_ = (*it)["gold"].asInt();
			const Json::Value &item_json = (*it)["item"];
			if (!item_json.isNull() && item_json.isArray()) {
				Json_Utility::assign_item_vec(item_json, detail.item_vec_);
			}
			detail.merit_ = (*it)["merit"].asInt();
			if (detail.victory_) {
				set_map_second_value_by_key(detail.level_, arena_multi_cfg_win_, detail);
			} else {
				set_map_second_value_by_key(detail.level_, arena_multi_cfg_fail_, detail);
			}
		}
	}

	{
		arena_multi_cfg_checkout_.clear();
		const Json::Value& json = CONFIG_INSTANCE->config_json()["arena_multi"]["tier"];
		Arena_Multi_Checkout_Detail detail;
		for (Json::Value::iterator it = json.begin(); it != json.end(); ++it) {
			detail.reset();
			detail.index = (*it)["tier"].asInt();
			const Json::Value &item_json = (*it)["item"];
			Json_Utility::assign_item_vec(item_json, detail.item_vec);
			if ((*it)["tier_credit"] != Json::Value::null && (*it)["tier_credit"].isArray()
					&& (*it)["tier_credit"].size() > 0) {
				if ((*it)["tier_credit"].size() == 2) {
					detail.rank.low = (*it)["tier_credit"][0u].asInt();
					detail.rank.high = (*it)["tier_credit"][1u].asInt() == -1 ? INT_MAX : (*it)["tier_credit"][1u].asInt();
				} else {
					LOG_ABORT("error Arena_Multi:%d, integral_num", detail.index);
				}
				set_map_second_value_by_key(detail.index, arena_multi_cfg_checkout_, detail);
			}
		}
	}

	{
		team_arena_correct_cfg_.clear();
		const Json::Value& json = CONFIG_INSTANCE->config_json()["arena_multi"]["correct"];
		Team_Arena_Correct detail;
		for (Json::Value::iterator it = json.begin(); it != json.end(); ++it) {
			detail.reset();
			if ((*it)["gap"] != Json::Value::null && (*it)["gap"].isArray()
					&& (*it)["gap"].size() > 0) {
				if ((*it)["gap"].size() == 2) {
					detail.gap.low = (*it)["gap"][0u].asInt() == -999999 ? INT_MIN : (*it)["gap"][0u].asInt();
					detail.gap.high = (*it)["gap"][1u].asInt() == 999999 ? INT_MAX : (*it)["gap"][1u].asInt();
				} else {
					LOG_ABORT("error Arena_Multi Correct: gap not 2!");
				}
				if (((*it)["correct"] != Json::Value::null && (*it)["correct"].isArray()
					&& (*it)["correct"].size() == 2)) {
					detail.correct.low = (*it)["correct"][0u].asInt();
					detail.correct.high = (*it)["correct"][1u].asInt();
				} else {
					LOG_ABORT("error Arena_Multi Correct: correct not 2!");
				}
				team_arena_correct_cfg_.push_back(detail);
			}
		}
	}

	{
		team_robot_cfg_.clear();
		const Json::Value& json = CONFIG_INSTANCE->config_json()["team"]["robot"];
		// task_type
		Team_Robot_Config detail;
		for (Json::Value::const_iterator it = json.begin(); it != json.end(); ++it) {
			detail.reset();
			detail.id = (*it)["id"].asInt();
			detail.name = (*it)["name"].asString();
			detail.career = (*it)["career"].asInt();
			detail.lvl = (*it)["lvl"].asInt();

			Json_Utility::assign_set_list((*it)["equip"], detail.equip);
			Json_Utility::assign_set_list((*it)["skill"], detail.skill);

			detail.hero_id = (*it)["hero_id"].asInt();
			detail.hero_name = (*it)["hero_name"].asString();
			detail.hero_fight = (*it)["hero_fight"].asInt();
			detail.hero_lvl = (*it)["hero_lvl"].asInt();
			detail.hero_awake_lvl = (*it)["hero_awake_lvl"].asInt();

			Json_Utility::assign_set_list((*it)["hero_equip"], detail.hero_equip);
			Json_Utility::assign_set_list((*it)["hero_skill"], detail.hero_skill);

			set_map_second_value_by_key(detail.id, team_robot_cfg_, detail);
		}
	}

	{
		team_defend_cfg_.clear();
		const Json::Value& json = CONFIG_INSTANCE->config_json()["team"]["defend"];
		// task_type
		Team_Defend_Cfg_Detail detail;
		for (Json::Value::const_iterator it = json.begin(); it != json.end(); ++it) {
			detail.reset();
			detail.scene_id = (*it)["sceneId"].asInt();
			Json_Utility::assign_coord_list((*it)["birth_coord"], detail.birth_coord);
			Json_Utility::assign_set_list((*it)["name_list"], detail.monster_ids);

			detail.boss_id = (*it)["boss_name"].asInt();
			detail.wave = (*it)["wave"].asInt();
			detail.init_time = (*it)["init_time"].asInt();
			detail.award_time = (*it)["award_time"].asInt();
			detail.wave_time = (*it)["wave_time"].asInt();
			detail.first_wave_time = (*it)["first_wave_time"].asInt();

			set_map_second_value_by_key(detail.scene_id, team_defend_cfg_, detail);
		}
	}
}
예제 #29
0
void Config_Cache_Scene::refresh_scene_config_cache(void)  {
	PERF_MON("refresh_scene_config_cache");

	Relation_Map relation_map;
	Int_Set scene_set;
	Scene_Config scene_config;
	Scene_Config::Transmit_Point_Vec client_find_path_point;
	const Json::Value json_scene = CONFIG_INSTANCE->config_json()["scene"]["scene_config"];
	for (Json::Value::const_iterator it = json_scene.begin(); it != json_scene.end(); it++) {
		scene_config.reset();

		const Json::Value &config = (*it);

		scene_config.scene_id = config["sceneId"].asInt();

		if (config["scene_block"] != Json::Value::null) {
			if (config["scene_block"].size() != 2) {
				LOG_ABORT("scene:%d, error scene block", scene_config.scene_id);
			}
			scene_config.scene_block_x = config["scene_block"][0u].asInt();
			scene_config.scene_block_y = config["scene_block"][1u].asInt();
		}

		const Server_Solution_Cache &server_solution_cache = CONFIG_CACHE->server_solution_cache();
		scene_config.order_total = server_solution_cache.fetch_order_total(Server_Enum::MONITOR_TYPE::MONITOR_SCENE, scene_config.scene_id);
		if (server_solution_cache.inter_server.count(scene_config.scene_id))
			scene_config.inter_order = CONFIG_CACHE->server_maintainer_cache().game_inter_flag % scene_config.order_total;

		scene_config.role_limit = config["role_limit"].asInt();
		scene_config.type = Scene_Type(config["type"].asInt());
		scene_config.manager = config["manager"].asInt();
		if (scene_config.manager == 0 || scene_config.manager >= Scene_Manager_Enum::Scene_Unknow) {
			LOG_ABORT("scene:%ld 未知manager:%d", scene_config.scene_id, scene_config.manager);
		}

		scene_config.map_id = config["mapId"].asInt();

		ABORT_INT_ZERO(scene_config.scene_id);
		ABORT_INT_ZERO(scene_config.map_id);

		if (scene_set.count(scene_config.scene_id))
			LOG_ABORT("场景id重复id:%d", scene_config.scene_id);

		scene_config.scene_name = config["defaultName"].asString();
		scene_config.login_create = config["login_create"].asBool();
		scene_config.timeLimit = config["timeLimit"].asInt();

		if (config["transmit_point"] != Json::Value::null) {
			Transmit_Point point;
			for (Json::Value::const_iterator it = config["transmit_point"].begin(); it != config["transmit_point"].end(); ++it) {
				Json_Utility::assign_coord((*it)["coord"], point.coord);
				point.scene_id = scene_config.scene_id;
				point.visible = (*it)["visible"].asInt();
				point.role_name = (*it)["name"].asString();
				point.des_scene_id = (*it)["des_scene_id"].asInt();
				point.role_id++;
				int map_value = get_map_value(scene_config.map_id, point.coord);
				if (map_value <= 0) {
					LOG_ABORT("传送点坐标非法map id:%d, x:%d, y:%d", scene_config.map_id, point.coord.x, point.coord.y);
				}

				scene_config.transmit_point.push_back(point);
				if ((*it)["client_find_path"].asInt())
					client_find_path_point.push_back(point);
			}
		}

		if (config["enter_point"] != Json::Value::null) {
			for (Json::Value::const_iterator it = config["enter_point"].begin(); it != config["enter_point"].end(); ++it) {
				Scene_Config::Transmit_Coord coord;
				Json_Utility::assign_coord((*it)["coord"], coord.coord);
				coord.src_scene_id = (*it)["src_scene_id"].asInt();
				int map_value = get_map_value(scene_config.map_id, coord.coord);
				if (map_value <= 0) {
					LOG_ABORT("进入点坐标非法map id:%d, x:%d, y:%d", scene_config.map_id, coord.coord.x, coord.coord.y);
				}

				scene_config.transmit_coord.insert(std::make_pair(coord.src_scene_id, coord));
			}
		}

		if (config["revive_point"] != Json::Value::null) {
			Coord coord;
			if (config["revive_point"].size() && config["revive_point"][0u].size() >= 2) {
				for (uint i = 0; i < config["revive_point"].size(); ++i) {
					Json_Utility::assign_coord(config["revive_point"][i], coord);
					int map_value = get_map_value(scene_config.map_id, coord);
					if (map_value <= 0) {
						LOG_ABORT("map id:%d, x:%d, y:%d", scene_config.map_id, coord.x, coord.y);
					}
					scene_config.revive_point.push_back(coord);
				}
			} else {
				Json_Utility::assign_coord(config["revive_point"], coord);
				int map_value = get_map_value(scene_config.map_id, coord);
				if (map_value <= 0) {
					LOG_ABORT("map id:%d, x:%d, y:%d", scene_config.map_id, coord.x, coord.y);
				}
				scene_config.revive_point.push_back(coord);
			}
		}

		if (config["des_scene_limit"] != Json::Value::null) {
			Json_Utility::assign_set_list(config["des_scene_limit"], scene_config.des_scene_limit);
		}

		if (config["scene_keep_time"] != Json::Value::null) {
			Json_Utility::assign_time_value(config["scene_keep_time"], scene_config.scene_keep_time);
		}

		scene_config.hero_disable = config["hero_disable"].asBool();

		//dungeon
		if(config["dungeon"] != Json::Value::null){
			const Json::Value &config_json = config["dungeon"];
			scene_config.dungeon.reset();
			if (config_json.isMember("id")) {
				scene_config.dungeon.id = config_json["id"].asInt();
			}
			if (config_json.isMember("name")) {
				scene_config.dungeon.name = config_json["name"].asString();
			}
			if (config_json.isMember("lv")) {
				scene_config.dungeon.lv = config_json["lv"].asInt();
			}
			if (config_json.isMember("difficulty")) {
				scene_config.dungeon.difficulty = config_json["difficulty"].asInt();
			}
			if(config_json.isMember("open_con")){
				for (Json::Value::iterator s_it = config_json["open_con"].begin();
					s_it != config_json["open_con"].end(); ++s_it) {
					scene_config.dungeon.open_con_map.insert(Scene_Config::Dungeon_Config_Detail::OpenConMap::value_type(
						(*s_it)[0u].asInt(), (*s_it)[1].asInt()));
				}
			}
			if (config_json.isMember("pass_con")) {
				scene_config.dungeon.pass_con = config_json["pass_con"].asInt();
			}
			if(config_json.isMember("cost")){
				for (Json::Value::iterator s_it = config_json["cost"].begin();
						s_it != config_json["cost"].end(); ++s_it) {
					scene_config.dungeon.cost_map.insert(Scene_Config::Dungeon_Config_Detail::CostMap::value_type(
							(*s_it)[0u].asInt(), (*s_it)[1].asInt()));
				}
			}
			if (config_json.isMember("entrance")) {
				scene_config.dungeon.be_enter = config_json["entrance"].asInt();
			}
			if (config_json.isMember("be_mop")) {
				scene_config.dungeon.be_mop = config_json["be_mop"].asInt();
			}
			if (config_json.isMember("can_team")) {
				scene_config.dungeon.can_team = config_json["can_team"].asInt();
			}
			if(config_json.isMember("task")){
				scene_config.dungeon.require_task = config_json["task"].asInt();
			}
			if (config_json.isMember("team_lim")) {
				scene_config.dungeon.team_lim = config_json["team_lim"].asInt();
			}
			if (config_json.isMember("relation")) {
				scene_config.dungeon.relation = config_json["relation"].asInt();
			}
			if (config_json.isMember("next_id")) {
				scene_config.dungeon.next_id = config_json["next_id"].asInt();
			}
			if (config_json.isMember("elite")) {
				scene_config.dungeon.elite = config_json["elite"].asInt();

			}
			if (config_json.isMember("vip_exp")) {
				int vip = 1;
				Scene_Config::Dungeon_Config_Detail::VipExtMap vipmap;
				for (Json::Value::iterator s_it = config_json["vip_exp"].begin();
						s_it != config_json["vip_exp"].end(); ++s_it) {
					vipmap.insert(Scene_Config::Dungeon_Config_Detail::VipExtMap::value_type(vip, (*s_it).asInt()));
					++vip;
				}
				scene_config.dungeon.vip_ext_map = vipmap;
			}

			insert_dungeon_relation(relation_map, scene_config.dungeon.relation, scene_config.dungeon.id);
			scene_config.dungeon.first_layer_id = get_dungeon_first_layer_id(relation_map,
					scene_config.dungeon.id);


			// 单人副本和精英副本对应关系
			if(scene_config.dungeon.elite != 0){
				if(scene_config.dungeon.difficulty ==
						Scene_Config::Dungeon_Config_Detail::DUNGEON_DIFF_NOR){
					single_elite_nor_map_.insert(std::make_pair(scene_config.dungeon.elite, scene_config.dungeon.id));
					elite_single_map_.insert(std::make_pair(scene_config.dungeon.id,scene_config.dungeon.elite));
				}else if(scene_config.dungeon.difficulty ==
						Scene_Config::Dungeon_Config_Detail::DUNGEON_DIFF_HOR){
					single_elite_hor_map_.insert(std::make_pair(scene_config.dungeon.elite, scene_config.dungeon.id));
					elite_single_map_.insert(std::make_pair(scene_config.dungeon.id,scene_config.dungeon.elite));
				}
			}

		}
		scene_set.insert(scene_config.scene_id);
		set_map_second_value_by_key(scene_config.scene_id, scene_config_cache_map_, scene_config);
	}

	client_find_path_point_.reset();
	client_find_path_point_.make_message(81000041);
	uint16_t __transmit_point_vec_size = client_find_path_point.size();
	client_find_path_point_.write_uint16(__transmit_point_vec_size);
	for(uint16_t i = 0; i < __transmit_point_vec_size; ++i) {
		client_find_path_point[i].serialize(client_find_path_point_);
	}
	client_find_path_point_.finish_message();
}
예제 #30
0
void Config_Cache_Scene::refresh_scene_map_cache(std::string &module)  {
	PERF_MON("refresh_scene_map_cache");

	Int_Set scene_set;
	Scene_Map_Data map_config;
	const Json::Value json_scene = CONFIG_INSTANCE->config_json()["map_data"];\
	Int_String_Map int_string_map;
	for (Json::Value::const_iterator it = json_scene.begin(); it != json_scene.end(); it++) {
		map_config.reset();

		const Json::Value mapInfo = (*it)["mapInfo"];
		if (mapInfo == Json::Value::null) LOG_ABORT("找不到:mapInfo");

		map_config.id = mapInfo["mapId"].asInt();

		if (!map_config.id || scene_set.count(map_config.id))
			LOG_ABORT("mapInfo场景id不存在或重复:%d", map_config.id);

		uint baseMapIndex = mapInfo["baseMapIndex"].asInt();
		if (baseMapIndex >= mapInfo["mapLayers"].size()) {
			LOG_ABORT("id:%d, baseMapIndex:%d  mapLayers size:%d", map_config.id, baseMapIndex, mapInfo["mapLayers"].size());
		}

		map_config.head.map_width =  mapInfo["mapLayers"][baseMapIndex]["width"].asInt();
		map_config.head.map_height = mapInfo["mapLayers"][baseMapIndex]["height"].asInt();;

		map_config.head.cell_width = MAP_X_PIEX;
		map_config.head.cell_height = MAP_Y_PIEX;

		map_config.head.x_len = map_config.head.map_width/MAP_X_PIEX;
		map_config.head.x_len = map_config.head.x_len * MAP_X_PIEX < map_config.head.map_width ? map_config.head.x_len + 1 : map_config.head.x_len;
		map_config.head.y_len = map_config.head.map_height/MAP_Y_PIEX;
		map_config.head.y_len = map_config.head.y_len * MAP_Y_PIEX < map_config.head.map_height ? map_config.head.y_len + 1 : map_config.head.y_len;

		JUDGE_ERROR_ABORT(!map_config.head.map_width || !map_config.head.map_height || !map_config.head.x_len || !map_config.head.y_len);

		const Json::Value mapData = (*it)["mapData"];
		if (mapData == Json::Value::null) LOG_ABORT("");

		uint max_len = map_config.head.y_len > map_config.head.x_len ? map_config.head.y_len : map_config.head.x_len;
		if (int_string_map.size() < max_len) {
			for (uint i = int_string_map.size(); i <= max_len; ++i) {
				char temp[64] = {0};
				sprintf(temp, "%d", i);
				int_string_map[i] = std::string(temp);
			}
		}
		for (int y = 0; y < map_config.head.y_len; ++y) {
			std::string &y_s = int_string_map[y];
			const Json::Value &y_json = mapData[y_s];
			for (int x = 0; x < map_config.head.x_len; ++x) {
				if (y_json != Json::Value::null) {
					std::string &x_s = int_string_map[x];
					if (y_json[x_s] != Json::Value::null) {
						int16_t value = y_json[x_s].asInt();
						value = (0 < value && value <= 1000) ? 1 : value;
						map_config.content.push_back(value);

					} else {
						map_config.content.push_back(0);
					}
				} else {
					map_config.content.push_back(0);
				}
			}
		}

		scene_set.insert(map_config.id);
		set_map_second_value_by_key(map_config.id, scene_map_data_cache_map_, map_config);
	}

}