void Team_Arena_Controler::tick(Time_Value &now) {
	open_tick();
	if (TEAM_SPORTS_ACTIVITY_OPEN != this->sports_activity_switch_) {
		return ;
	}

	if (now - last_match_time_ > Time_Value(MATCH_GAP)) {
		match_arena_team();
		last_match_time_ = now;
	}

	if (now - last_rank_refresh_time_ > Time_Value(30)) {
		refresh_rank_list();
		last_rank_refresh_time_ = now;
	}


	while (team_deque_.size() > 0) {
		Matched_Teams &matched_teams = team_deque_.front();
		if (now - matched_teams.match_time > Time_Value(ENTER_WAIT)) {
			Map_Team *team1 = SCENE_TEAM_MANAGER->get_team(matched_teams.matched_pair.first);
			Map_Team *team2 = SCENE_TEAM_MANAGER->get_team(matched_teams.matched_pair.second);
			if (team1 && team2) {
				transfer_handle(*team1, *team2);
			} else if (team1) {
			} else if (team2) {
			}
			team_deque_.pop_front();
			team_matched_.erase(matched_teams.matched_pair.first);
			team_matched_.erase(matched_teams.matched_pair.second);
		} else {
			break;
		}
	}
}
示例#2
0
int Login_Player::tick(Time_Value &now) {
	if (now - session_info_.session_tick > Time_Value(10)) {
		//session到期,断开客户端与login的连接
		LOG_INFO("player session timeout, drop from login, cid:%d, account:%s", player_cid(), account().c_str());
		session_info_.session_tick += Time_Value(10);
		LOGIN_MANAGER->close_client(0, player_cid(), ERROR_SESSION_TIMEOUT);
	}
	return 0;
}
示例#3
0
int Chat_Monitor::start_monitor_timer(void) {
	Block_Buffer buf;
	buf.make_message(TIMER_GLOBAL_MONITOR_SELF);
	buf.finish_message();
	GLOBAL_TIMER->register_loop_handler(buf, Time_Value(30, 0), unit_);

	{
	Block_Buffer buf;
	buf.make_message(TIMER_TRIGGER_DAILY_ZERO);
	buf.finish_message();
	Time_Value timeout = next_relative_time(24, 00, 00);
	GLOBAL_TIMER->register_loop_handler(buf, Time_Value(timeout), unit_);
	}
	return 0;
}
示例#4
0
int Record_Monitor::start_monitor_timer(void) {
	Block_Buffer buf;
	buf.make_message(TIMER_GLOBAL_MONITOR_SELF);
	buf.finish_message();
	GLOBAL_TIMER->register_loop_handler(buf, Time_Value(Time_Value::ONE_MINUTE_IN_SECS, 0), unit_);
	return 0;
}
示例#5
0
void DB_Worker::process_list(void) {
	Block_Buffer *buffer = 0;

	while (1) {
		buffer = 0;
		bool all_empty = true;

		if ((buffer = load_player_list_.pop_front()) != 0) {
			all_empty = false;
			process_data_block(buffer);
		}
		if ((buffer = create_player_list_.pop_front()) != 0) {
			all_empty = false;
			process_data_block(buffer);
		}
		if ((buffer = save_player_list_.pop_front()) != 0) {
			all_empty = false;
			process_data_block(buffer);
		}
		if ((buffer = data_list_.pop_front()) != 0) {
			all_empty = false;
			process_data_block(buffer);
		}

		if (all_empty)
			Time_Value::sleep(Time_Value(0,100));
	}
}
示例#6
0
bool Wing::is_wing_normal(void){

	if (0 == wing_detail_) {
		MSG_USER("wing data maybe not load properly, role_id=%ld", role_id());
		return false;
	}
	// 未激活状态
	if (Wing_Detail::WING_NOT_ACTIVE == wing_detail_->state) return false;
	// 体验状态,做过期检查
	if (Wing_Detail::WING_EXP == wing_detail_->state) {
		// 体验过期检查
		const int secs = CONFIG_CACHE_PUBLIC->get_wing_experience_mins() * 60;
		Time_Value expired_time = wing_detail_->active_time + Time_Value(secs);
		// 未过期
		if (expired_time > Time_Value::gettimeofday())  return true;
		// 过期,重置等级为0
		if (0 != wing_detail_->lv) {
			wing_detail_->lv = 0;
			wing_detail_->is_show = Wing_Detail::SHOW_OFF;
			player_self()->player_try_time_out(TRY_MAGIC_WING_TIMEOUT);
		}
		return false;
	}

	return true;
}
示例#7
0
int Message_Unit::process_client_buffer(Block_Buffer &buf) {
	msg_tick_ = Time_Value::gettimeofday();

	int cid = 0;
	uint32_t len = 0;
	uint32_t msg_id = 0;
	uint32_t serial_cipher = 0;
	uint32_t msg_time_cipher = 0;

	if (buf.read_int32(cid) ||
		buf.read_uint32(len) ||
		buf.read_uint32(msg_id) ||
		buf.read_uint32(serial_cipher) ||
		buf.read_uint32(msg_time_cipher)) {

		LOG_USER("deserialize error, cid:%d len:%d msg_id:%d", cid, len, msg_id);
		monitor()->close_client_by_cid(cid, Time_Value(2), 10000101);
		return -1;
	}

	process_client_msg(msg_id, cid, buf, serial_cipher, msg_time_cipher);

	count_process_time(msg_id);

	return 0;
}
示例#8
0
void Master_Timer::register_v8_handler(int timer_id, int internal, int first_tick_internal) {
	V8_Timer_Handler *handler = v8_timer_pool_.pop();
	handler->timer_id = timer_id;
	handler->interval = internal;
	handler->next_tick = Time_Value::gettimeofday() + Time_Value(first_tick_internal);
	v8_timer_queue_.push(handler);
}
void Scene_Gang_Manager::tick(Time_Value &now) {
	if (ACTIVITY_CLOSE == this->switch_) {
		return ;
	}

	if (GANG_WAR_CREATE_16 == this->switch_) {
		if (stage() == 2) {
			index_ = 0;
		}
		match_arena_team();
		last_match_time_ = now;
		this->switch_ = GANG_WAR_CREATE_16_END;
	}

	if (ACTIVITY_READY == this->switch_) {
		match_arena_team();
		last_match_time_ = now;
		this->switch_ = ACTIVITY_MATCHED;
	}

	if (ACTIVITY_OPEN == this->switch_
			&& now - last_match_time_ > Time_Value(0)) {
		last_match_time_ = now;
		set_start_time(now);
		this->switch_ = ACTIVITY_FIGHT;
	}

}
示例#10
0
int Single_Scene::exit_scene(Mover *mover, bool offline) {
	int target_scene_id = 0;
	if(mover && mover->player_self()){
		target_scene_id = mover->player_self()->base_detail().rela_scene_id;
	}
	Move_Scene::exit_scene(mover, offline);

	if (mover->player_self() == NULL){
		return 0;
	}
	mover->player_self()->reset_revive_info();
	//
	if(target_scene_id/1000 == Tbay_Scene_Type){
		this->set_scene_status(Move_Scene::SCENE_RECOVER_STATUS);
		recover_time_ = Time_Value::gettimeofday() + Time_Value(60*60);
	}else{
		this->set_scene_status(Move_Scene::SCENE_RECOVER_STATUS);
		if (offline) {
			MSG_DEBUG("single scene recover offline, scene id:%ld", this->scene_id());
			recover_time_ = Time_Value::gettimeofday() + scene_config()->scene_keep_time;
		}else{
			MSG_DEBUG("single scene recover normal, scene id:%ld", this->scene_id());
			recover_time_ = Time_Value::zero;
			// 上古副本通关没有领取宝箱的,自动领取飘字提示
			// 3:通关未领宝箱
			if(scene_type() == Elite_Scene_Type &&
					get_pass_status() == 3){
				if(has_scene_pass_box_){
					Scene_Layer *layer = scene_layer(0);
					if (layer) {
						Mover_Map::iterator it;
						for(it = layer->mover_map_.begin(); it != layer->mover_map_.end(); ++it){
							if(it->second && it->second->drops_self()){
								if(it->second->drops_self()->is_scene_pass_box()){
									it->second->drops_self()->drops_detail().set_getting_status();
									//send to logic
									MSG_20300000 logic_msg;
									logic_msg.drops_role_id = mover->role_id();
									logic_msg.item_index = -1;
									it->second->drops_self()->get_drops_goods_by_index(mover->player_self(), -1, logic_msg.item_vec);
									logic_msg.scene_type = scene_type();
									logic_msg.scene_id = scene_id();

									Block_Buffer logic_buf;
									MAKE_MSG_BUF(logic_msg, logic_buf);
									mover->send_to_logic(logic_buf);
									break;
								}
							}
						}
					}
				}
			}
		}
		offline_ = offline;
	}
	return 0;
}
int Honor_Arena_Manager::inner_act_end(const role_id_t gang_id, Block_Buffer& buf){
	if(act_state_ != ACT_STATE_START){//
		return 0;
	}
	int remain_time = 0;
	buf.read_int32(remain_time);
	act_end_time_ = Time_Value::gettimeofday() + Time_Value(remain_time);
	return 0;
}
int Scene_Gang_Manager::gang_war_load_source_gangs_from_logic(Block_Buffer &buf) {
	int8_t type = 0;
	buf.read_int8(type);
	if (type == 1) {
		int64_t server_id = 0;
		std::string zone;
		uint16_t len = 0;
		int8_t stage = 0;

		buf.read_int64(server_id);
		buf.read_string(zone);
		buf.read_int8(stage);
		if (stage != stage_
				|| load_source_ < Time_Value::gettimeofday()) {
			gang_map_.clear();
			gangid_serverid_map_.clear();
			gangid_zone_map_.clear();
			server_ids_.clear();
			stage_ = stage;
			load_source_ = Time_Value::gettimeofday() + Time_Value(Time_Value::ONE_MINUTE_IN_SECS * 5);
			MSG_USER("GANG_WAR: source_gangs server_id(%d) clear data",server_id);
		}
		server_ids_.insert(server_id);
		buf.read_uint16(len);
		Gang_War_Spot spot;
		std::map<int8_t, Gang_War_Spot> gang_war_result_map;
		for (uint16_t i = 0; i < len; ++i) {
			spot.reset();
			spot.deserialize(buf);
			gang_war_result_map.insert(std::make_pair(spot.index, spot));
		}
		if (!gang_war_result_map.empty()) {
			gang_war_result_map_.clear();
			gang_war_result_map_ = gang_war_result_map;
		}
		buf.read_uint16(len);
		Gang_DB_View info;
		for (uint16_t i = 0; i < len; ++i) {
			info.reset();
			info.gang_war_deserialize(buf);
			gang_map_.insert(std::make_pair(info.gang_id, info));
			gangid_serverid_map_.insert(std::make_pair(info.gang_id, server_id));
			gangid_zone_map_.insert(std::make_pair(info.gang_id, zone));
			SCENE_GANG_GLOBAL_MANAGER->add_gang(info.gang_id, this);
		}
		MSG_USER("GANG_WAR: source_gangs server_id(%d)",server_id);
	} else {
		role_id_t gang_id = 0;
		buf.read_int64(gang_id);
		gang_map_.erase(gang_id);
		gangid_serverid_map_.erase(gang_id);
		gangid_zone_map_.erase(gang_id);
		SCENE_GANG_GLOBAL_MANAGER->erase_gang(gang_id);
	}
	return 0;
}
示例#13
0
int Master_Timer::v8_tick(const Time_Value &now){
	while(!v8_timer_queue_.empty() && (now > v8_timer_queue_.top()->next_tick)) {
		V8_Timer_Handler *handler = v8_timer_queue_.top();
		v8_timer_queue_.pop();
		v8_timer_list_.push_back(handler->timer_id);
		handler->next_tick += Time_Value(handler->interval / 1000, handler->interval % 1000 * 1000);
		v8_timer_queue_.push(handler);
	}
	return 0;
}
示例#14
0
void Logic_Arenaer::set_arena_cd(const int cd){
	if(arenaer_detail_){
		if(cd <= 0){
			arenaer_detail_->cd = Time_Value::zero;
		}else{
			arenaer_detail_->cd = Time_Value::gettimeofday() + Time_Value(cd);
		}
		arenaer_detail_->detail_change();
	}
}
示例#15
0
int Wing::handle_get_ret_reward(int stage) {

	if (0 == wing_detail_) return ERROR_INNER_SERVER;
	if (Wing_Detail::WING_ACTIVE != wing_detail_->state) return ERROR_WING_NOT_ACTIVE;
	if (stage < wing_detail_->got_reward_stage) return ERROR_HAS_GOT_REWARD;

	int secs = CONFIG_CACHE_PUBLIC->get_wing_experience_ret_reward_time() * 60;
	const Time_Value &now = Time_Value::gettimeofday();
	Time_Value expired_time = wing_detail_->active_time + Time_Value(secs);
	if (now >= expired_time) return ERROR_WING_ACTIVITY_EXPIRED;		// 活动过期

	if (0 == wing_detail_->lv) return ERROR_INNER_SERVER;
	const Wing_Config* cfg = CONFIG_CACHE_WING->get_wing_config(wing_detail_->lv);
	if (0 == cfg) return ERROR_CONFIG_NOT_EXIST;
	if (cfg->show_stage < stage) return ERROR_WING_STAGE_LIMIT;

	for (int i=wing_detail_->got_reward_stage+1; i <stage; ++i) {
		if (0 != CONFIG_CACHE_WING->get_wing_ret_reward(i))
			return ERROR_INNER_SERVER;
	}

	const Int_Int_Vec *reward_vec = CONFIG_CACHE_WING->get_wing_ret_reward(stage);
	if (0 == reward_vec) return ERROR_CONFIG_NOT_EXIST;

	MSG_81000102 item_msg;
	Item_Vec item_vec;
	Item_Detail detail;
	Item_Basic_Info item_basic;
	for (Int_Int_Vec::const_iterator it = reward_vec->begin(); it != reward_vec->end(); ++it) {
		detail.reset();
		item_basic.reset();
		detail.id_ = it->val_1;
		detail.amount_ = it->val_2;
		detail.bind_ = Item_Detail::BIND;
		item_vec.push_back(detail);
		detail.set_item_basic_info(item_basic);
		item_msg.item_info.push_back(item_basic);
	}

	int ret = player_self()->pack_insert_item(PACK_T_PACKAGE_INDEX, item_vec,
			Gain_Item_DM_Info(Pack::ITEM_GAIN_WING_RET_REWARD));
	if (0 != ret) return ret;

	wing_detail_->got_reward_stage = stage;

	MSG_50105017 msg;
	msg.result = 0;
	msg.stage = stage;

	THIS_SEND_TO_CLIENT(msg);
	THIS_SEND_TO_CLIENT(item_msg);

	return 0;
}
示例#16
0
int Killing_Scene::tick(const Time_Value &now) {
    Move_Scene::tick(now);

    if (end_time_ != Time_Value::zero && end_time_ <= now) {
        end_time_ = Time_Value::zero;
        kick_all_player();
        recover_time_ = Time_Value::gettimeofday() + Time_Value(4);
        this->set_scene_status(SCENE_RECOVER_STATUS);
    }
    return 0;
}
示例#17
0
Message_Unit::Message_Unit(void) :
is_running_(false),
message_unit_max_limit_(INT_MAX),
monitor_(0),
block_group_pool_(10) {
	pause_ts_.tv_sec = 0;
	pause_ts_.tv_nsec = 30 * 1000 * 1000;
	Date_Time date_time(Time_Value::gettimeofday());
	date_time.minute(0);
	date_time.second(0);
	data_pro_tick_ = Time_Value(date_time.time_sec() + 3600);
}
示例#18
0
void Gate_Master_Connector::process_list(void) {
	Block_Buffer *buf = 0;
	while (1) {
		if (!block_list_.empty()) {
			buf = block_list_.pop_front();
			GATE_MANAGER->push_gate_master_data(buf);
		} else {
			//没有数据时候延迟
			Time_Value::sleep(Time_Value(0,100));
		}
	}
}
示例#19
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;
}
示例#20
0
int Gate_Manager::close_list_tick(Time_Value &now) {
	Close_Info info;
	while (! close_list_.empty()) {
		info = close_list_.front();
		if (now - info.timestamp > Time_Value(2, 0)) {
			close_list_.pop_front();
			GATE_CLIENT_SERVER->receive().push_drop(info.cid);
		} else {
			break;
		}
	}
	return 0;
}
示例#21
0
void Message_Unit::server_status(void) {
	// 当做和日志服心跳
	RECORD_CLIENT->sync_pid(monitor_->type(), monitor_->monitor_idx());

	int uptime = (Time_Value::gettimeofday().sec() - monitor_->start_time().sec()) / 3600;
	LOG_TEXT("↓↓↓ server status start: uptime:%d(hour), type:%d, index:%d ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓", uptime, monitor_->type(), monitor_->monitor_idx());
	show_server_status();

	Date_Time date_time(Time_Value::gettimeofday());
	date_time.minute(0);
	date_time.second(0);
	data_pro_tick_ += Time_Value(3600);
	LOG_TEXT("↑↑↑ server status end: type:%d ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑", monitor_->type());
	LOG_TEXT_FLUSH;
}
int Honor_Arena_Manager::inner_act_start(const role_id_t gang_id, Block_Buffer& buf){
	if(act_state_ != ACT_STATE_START){//
		act_state_ = ACT_STATE_START;
		int icon_id = icon_id_;
		reset();
		icon_id_ = icon_id;
	}
	int remain_time = 0;
	int fight_time = 0;
	buf.read_int32(fight_time);
	buf.read_int32(remain_time);
	act_fight_time_ = fight_time;
	act_end_time_ = Time_Value::gettimeofday() + Time_Value(remain_time);
	return 0;
}
示例#23
0
void Wing::listen_wing_experience_expired(const Time_Value& now) {
	if (0 == wing_detail_) return;
	if (Wing_Detail::WING_EXP != wing_detail_->state) return;
	const int secs = CONFIG_CACHE_PUBLIC->get_wing_experience_mins() * 60;
	Time_Value expired_time = wing_detail_->active_time + Time_Value(secs);

	// 未过期
	if (expired_time > now) return;

	//已处理过期
	if (0 == wing_detail_->lv) return;

	// 过期处理
	int old_lv = wing_detail_->lv;
	wing_detail_->lv = 0;
	wing_detail_->is_show = Wing_Detail::SHOW_OFF;

	refresh_wing_attr(old_lv, wing_detail_->lv);
	player_self()->refresh_avatar();
	player_self()->player_try_time_out(TRY_MAGIC_WING_TIMEOUT);
}
示例#24
0
int Game_Manager::process_list(void) {
	while (1) {
		bool all_empty = true;

		//掉线gate列表
		if (! drop_gate_cid_list_.empty()) {
			all_empty = false;
			int gate_cid = drop_gate_cid_list_.pop_front();
			process_drop_gate_cid(gate_cid);
		}
		//定时器列表
		if (! tick_list_.empty()) {
			all_empty = false;
			tick_list_.pop_front();
			tick();
		}

		if (all_empty)
			Time_Value::sleep(Time_Value(0,100));
	}
	return 0;
}
示例#25
0
int Single_Scene::scene_pass_to_logic(void){
	if(is_scene_pass_ == false){
		if(is_scene_complete_){
			this->is_delay_show_ts_point_= true;
			this->reset_delay_show_ts_point_time();
		}
		return -1;
	}
	if(has_gain_rewards){
		return 0;
	}
	has_gain_rewards = true;
	MSG_20200080 msg;
	if(scene_config() && scene_config()->dungeon.first_layer_id != 0){
		msg.scene_id = scene_config()->dungeon.first_layer_id;
	}else{
		msg.scene_id = scene_id();
	}
	Mover *mover = this->find_mover_with_layer(0, role_id_);
	if (mover) {
		if(is_no_profit(mover->role_id())){// 没收益
			msg.result = 0;
			this->is_delay_show_ts_point_= true;
			this->reset_delay_show_ts_point_time();
		}else{// 有收益
			msg.result = 1;
			this->is_delay_show_ts_point_= true;
			if(has_scene_pass_box_ || scene_config()->type == FuBen_Scene_Type){
				this->ts_point_delay_time_ = Time_Value::gettimeofday() + Time_Value(12);
			}else{
				this->reset_delay_show_ts_point_time();
			}

		}
		OBJ_SEND_TO_LOGIC(msg, (*mover));
	}
	return 0;
}
示例#26
0
int Player_Base<PLAYER>::create_event(int type, event_fun fun, Time_Value interval, int loop_times) {
	Player_Event *event = event_pool_.pop();
	if (!event) {
		return 0;
	}

	event->type = type;
	event->fun = fun;
	event->interval = interval;
	event->loop_times = loop_times;
	event->next_opt = Time_Value::gettimeofday() + Time_Value(interval);

	if (event_set_.count(type)) {
		event_pool_.push(event);
		LOG_USER_TRACE("event has in set, type:%d event size:%d", type, event_set_.size());
		return -1;
	}

	event_set_.insert(type);
	event_queue_.push(event);

	return 0;
}
示例#27
0
int Wing::handle_get_wing_info(void) {

	MSG_50105013 msg;
	if (0 == wing_detail_) {
		msg.lv = 0;
	} else {
		msg.lv = wing_detail_->lv;
		msg.progress = wing_detail_->progress;
		msg.use_times = wing_detail_->times;
		msg.is_show = wing_detail_->is_show;
		msg.state = wing_detail_->state;
		msg.ret_reward_stage = wing_detail_->got_reward_stage;

		if (Wing_Detail::WING_ACTIVE == wing_detail_->state) {
			int secs = CONFIG_CACHE_PUBLIC->get_wing_experience_ret_reward_time() * 60;
			Time_Value expired_time = wing_detail_->active_time + Time_Value(secs);
			const Time_Value &now = Time_Value::gettimeofday();
			if (expired_time > now) {
				msg.secs = (expired_time - now).sec();
			}
		}
	}
	int cur_lv = msg.lv;
	int next_lv = msg.lv + 1;
	if (0 == msg.lv) {
		cur_lv = 1;
		next_lv = 2;
	}

	msg.cur_score = get_wing_stage_score(cur_lv);
	msg.next_score = get_wing_stage_score(next_lv);

	THIS_SEND_TO_CLIENT(msg);

	return 0;
}
示例#28
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);
	}
}
示例#29
0
void Message_Unit::set_monitor(Server_Monitor *monitor) {
	monitor_ = monitor;
	data_pro_tick_ += Time_Value(monitor->monitor_idx());
}
bool Battle_AI_Object::ai_is_valid(Monster_AI_Info* ai_info, bool type_spe/* = false*/){
	if(ai_info->can_trigger() == false){
		return false;
	}
	bool spe = false;
	switch(ai_info->config->a_type){
		case MONSTER_AI_A_TALK:
		case MONSTER_AI_A_PLOT:
		case MONSTER_AI_A_CLEAN_MP:
		case MONSTER_AI_A_CLEAN_BUF:
		case MONSTER_AI_A_REFRESH_HERO:
		case MONSTER_AI_A_ADD_BUF:
		case MONSTER_AI_A_KILL_MONSTER:
		case MONSTER_AI_A_TRANSFORM:{
			spe = true;
			break;
		}
		default:{
			break;
		}
	}
	if(type_spe != spe){
		return false;
	}
	if(ai_info->is_valid){
		if(ai_info->config->a_type == MONSTER_AI_A_ONE_SKILL_BB){
			return true;
		}else if(ai_info->config->a_type == MONSTER_AI_A_ONE_SKILL_DL){
			if(Time_Value::gettimeofday() >
			ai_info->valid_time + Time_Value(ai_info->config->a_val3)){
				return true;
			}else{
				return false;
			}
		}else{
			ai_info->is_valid = false;
			return true;
		}
		if(ai_info->config->a_type != MONSTER_AI_A_ONE_SKILL_BB){
			ai_info->is_valid = false;
		}
	}
	bool is_valid = false;
	switch(ai_info->config->c_type){
		case MONSTER_AI_C_NULL:{
			is_valid = true;
			break;
		}
		case MONSTER_AI_C_HP:{
//			double cur_val = owner_->blood_current();
//			double max_val = owner_->blood_max();
//			int cmp_val;
//			if(ai_info->config->c_val2 == 0){
//				cmp_val = cur_val;
//			}else{
//				cmp_val = 1000*(cur_val/max_val);
//			}
//			if(ai_info->config->c_val1 == 0){
//				if(cmp_val >= ai_info->config->c_val3){
//					is_valid = true;
//				}
//			}else{
//				if(cmp_val <= ai_info->config->c_val3){
//					is_valid = true;
//				}
//			}
			break;
		}
		case MONSTER_AI_C_MP:{
//			double cur_val = owner_->mp_current();
//			double max_val = owner_->mp_max();
//			int cmp_val;
//			if(ai_info->config->c_val2 == 0){
//				cmp_val = cur_val;
//			}else{
//				cmp_val = 1000*(cur_val/max_val);
//			}
//			if(ai_info->config->c_val1 == 0){
//				if(cmp_val >= ai_info->config->c_val3){
//					is_valid = true;
//				}
//			}else{
//				if(cmp_val <= ai_info->config->c_val3){
//					is_valid = true;
//				}
//			}
			break;
		}
		case MONSTER_AI_C_DIE:{
			break;
		}
		case MONSTER_AI_C_SKILL:{
			break;
		}
		case MONSTER_AI_C_TIMES:{
			break;
		}
		case MONSTER_AI_C_TIME:{
			int cur_val;
			int cmp_val;
			Time_Value last_time;
			cmp_val = ai_info->config->c_val2;
			if(ai_info->last_time == Time_Value::zero){// 第一次触发
				last_time = Time_Value::gettimeofday() - begin_time_;
			}else{//
				if(ai_info->has_trigger){
					ai_info->has_trigger = false;
					ai_info->last_time = Time_Value::gettimeofday();
					last_time = Time_Value::zero;
				}else{
					last_time = Time_Value::gettimeofday() - ai_info->last_time;
				}
				if(ai_info->config->c_val1 != 0){
					cmp_val = ai_info->config->c_val1;
				}
			}
			cur_val = last_time.sec();
			if(cur_val >= cmp_val){
				is_valid = true;
			}
			break;
		}
		default:{
			break;
		}
	}
	return is_valid;
}