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;
}
int Team_Arena_Controler::refresh_rank_list(role_id_t role_id) {
	Scene_Player *player = 0;

	if (role_id) {
		Team_Role_Score_Map::iterator find_it = team_role_score_map.find(role_id);
		if (find_it != team_role_score_map.end()) {
			player = SCENE_MONITOR->find_scene_player_by_role_id(role_id);
			if (player) {
				Block_Buffer buf;
				buf.make_message(20100312);
				buf.write_int32(find_it->second.rank);
				buf.finish_message();
				player->send_to_logic(buf);
			}
		}
	} else {
		level_team_role_score_map.clear();
		for (Team_Role_Score_Map::iterator it = team_role_score_map.begin(); it != team_role_score_map.end(); ++it) {
			if (it->second.score > 0) {
				int level = CONFIG_CACHE_TEAM->arena_multi_level(it->second.score);
				level_team_role_score_map[level].push_back(&it->second);
				it->second.change = false;
			}
		}


		for (Level_Team_Role_Score_Map::iterator it = level_team_role_score_map.begin(); it != level_team_role_score_map.end(); ++it) {
			std::sort(it->second.begin(), it->second.end(), Team_Role_Score_Greater());

			int i = 1;
			for (Team_Role_Score_Vec::iterator r_it = it->second.begin(); r_it != it->second.end(); ++r_it, ++i) {
				if ((**r_it).rank != i) {
					player = SCENE_MONITOR->find_scene_player_by_role_id((*r_it)->role_id);
					if (player) {
						Block_Buffer buf;
						buf.make_message(20100312);
						buf.write_int32(i);
						buf.finish_message();
						player->send_to_logic(buf);
					}
				}
				(**r_it).rank = i;
			}
		}
	}

	return 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;
}
Beispiel #4
0
void Chat::say(Time_Value &now, Location &location) {
	if(now >= (last_say_time + say_interval)) {
		last_say_time = now;
		Robot_Player *player = (Robot_Player*)this;
		MSG_10300000 msg;
		msg.chat_type = 1;
		Chat_Content cc;
		//人物信息
		cc.reset();
		cc.type = 2;
		cc.role_Info.role_name = player->base_detail().role_name;
		cc.role_Info.career = player->base_detail().career;
		cc.role_Info.gender = player->base_detail().gender;
		cc.role_Info.role_id = player->base_detail().role_id;
		msg.content.push_back(cc);
		//聊天内容
		cc.reset();
		cc.type = 0;
		std::ostringstream text;
		text << "各位你好!我目前的场景是:" << location.scene_id << ",坐标(x=" << location.coord.x << ",y=" << location.coord.y << "), 过来找我吧~{a" << ((rand()%39)+1) << "}";
		cc.text = text.str();
		msg.content.push_back(cc);
		//send
		Block_Buffer buf;
		buf.make_client_message(10300000, player->msg_detail().msg_serial++, Time_Value::gettimeofday().sec());
		msg.serialize(buf);
		buf.finish_message();
		player->send_to_server(buf);
	}
}
Beispiel #5
0
int Gate_Manager::self_close_process(void) {
	server_status_ = STATUS_CLOSING;

	Block_Buffer buf;
	buf.make_inner_message(ACTIVE_DISCONNECT, ERROR_DISCONNECT_SELF);
	buf.finish_message();
	for (Gate_Player_Cid_Map::iterator iter = player_cid_map_.begin(); iter != player_cid_map_.end(); ++iter) {
		GATE_MANAGER->send_to_client(iter->first, buf);
	}
	//等待服务器通知客户端完毕
	sleep(2);

	//关闭客户端连接
	for (Gate_Player_Cid_Map::iterator iter = player_cid_map_.begin(); iter != player_cid_map_.end(); ++iter) {
		iter->second->link_close();
	}

	int i = 0;
	while (++i < 60) {
		sleep(1);
		LOG_DEBUG("gate server has user:%d", player_cid_map_.size());
		if (player_cid_map_.size() == 0)
			break;
	}

	return 0;
}
void Answer_Manager::save_data(Block_Buffer& buf_) {
	Block_Buffer buf;
	buf.make_message(MONGO_SAVE_ANSWER_INFO);
	buf.copy(&buf_);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
}
void Daemon_Record::stop(void) {
	if (is_server_running()) {
		Block_Buffer buf;
		buf.make_message(SERVER_INNER_SELF_CLOSE);
		buf.finish_message();
		RECORD_MONITOR->push_async_buff(buf);
	}
}
Beispiel #8
0
int DB_Worker::process_create_guild(int cid, Create_Guild_Info &guild_info) {
	Block_Buffer buf;
	buf.make_server_message(SYNC_DB_MASTER_CREATE_GUILD, 0);
	guild_info.guild_id = DB_MANAGER->create_guild(guild_info);
	guild_info.serialize(buf);
	buf.finish_message();
	DB_MANAGER->send_data_block(cid, buf);
	return 0;
}
Beispiel #9
0
int Chat_Player::send_err_to_client(int error_id, int source) {
	Block_Buffer buf;
	buf.make_message(80000001);
	buf.write_int32(error_id);
	buf.write_int32(source);
	buf.write_string("");
	buf.finish_message();
	return send_to_client(buf);
}
Beispiel #10
0
void Vip::sync_vip_info_to_chat(void) {
	MSG_20200024 inner_msg;
	inner_msg.vip_level = player_self()->base_detail().vip;
	inner_msg.over_time = player_self()->base_detail().vip_over_time.sec();
	Block_Buffer buf;
	buf.make_message(inner_msg.msg_id);
	inner_msg.serialize(buf);
	buf.finish_message();
	this->send_to_local_chat(buf);
}
int Scene_Outpost_Manager::vagrant_store_trigger(Move_Scene* scene, const int point, bool is_boss, Coord point_coord){
	int scene_id = scene->scene_id();
	int monster_id = CONFIG_CACHE_NPC->vagrant_item_trigger(scene_id, point);
	if(monster_id == 0){
		return 0;
	}
	// create monster
	NPC_Addition_Info npc_add;
	npc_add.birth_coord = point_coord;
	Monster* monster = NPC_MANAGER->create_monster(monster_id, 5, scene, NULL, npc_add);
	if(!monster){
		return 0;
	}
	int64_t monster_role_id = monster->role_id();
	// 生存流浪商店物品
	Vagrant_Item_Config_Map* vic_map = CONFIG_CACHE_NPC->get_vagrant_item_config_map();
	if(!vic_map){
		return 0;
	}
	Vagrant_Item_Info_Vec vi_vec;
	Vagrant_Item_Info vi;
	for(Vagrant_Item_Config_Map::iterator it = vic_map->begin(); it != vic_map->end();
			++ it){
		if(it->second.is_valid(monster_id)){
			vi.reset();
			vi.cfg_key = it->second.key;
			vi.cfg_item_id = it->second.item_id;
			vi.cfg_cost_type = it->second.sys_sell_type;
			vi.cfg_cost = it->second.cost;
			vi.cfg_num = it->second.num;
			vi.cfg_limit_num = it->second.limit_num;
			vi_vec.push_back(vi);
		}
	}
	Vagrant_Store_Scene_Map::iterator it = vagrant_item_map_.find(scene_id);
	if(it != vagrant_item_map_.end()){
		it->second[monster_role_id] = vi_vec;
	}else{
		Vagrant_Store_Map vagrant_stroe_map;
		vagrant_stroe_map[monster_role_id] = vi_vec;
		vagrant_item_map_[scene_id] = vagrant_stroe_map;
	}
	// 飘字
	{
		int err_id = ERROR_VAGRANT_STORE_OPEN;
		Block_Buffer buf;
		buf.make_message(80000001);
		buf.write_int32(err_id);
		buf.write_int32(0);
		buf.write_string("");
		buf.finish_message();
		scene->broadcast_all(0, buf);
	}
	return 0;
}
Beispiel #12
0
void Answer_Scene::send_logic_get_integral_reward(Mover *mover, const uint32_t sorce) {
	if(!mover) return;
	Block_Buffer buf;
	buf.make_message(INNER_ANSWER_DATA_CHANNEL);
	buf.write_uint8(ANSWER_DATA_CHANNLE_TYPE_SL_GET_INTEGRAL_REWARD);
	//DATA START
	buf.write_uint32(sorce);
	//DATA END
	buf.finish_message();
	mover->send_to_logic(buf);
}
Beispiel #13
0
int Operating::offline_team_award(role_id_t role_id, int level_id) {

	Block_Buffer buf;
	buf.make_message(OPERATING_OFFLINE_TEAM_AWARD);
	buf.write_int64(role_id);
	buf.write_int32(level_id);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);

	return 0;
}
Beispiel #14
0
int Operating::offline_arena_seven_day_reward(role_id_t role_id, Arena_Reward_Info &info){
	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	int type = OPERATING_OFFLINE_ARENA_SEVEN_DAY_REWARD;
	buf.write_int32(type);
	buf.write_int64(role_id);
	info.serialize(buf);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}
Beispiel #15
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 Answer_Manager::send_scene_open_action(void) {
	Block_Buffer buf;
	buf.make_message(INNER_ANSWER_DATA_CHANNEL);
	buf.write_uint8(ANSWER_DATA_CHANNLE_TYPE_LS_OPEN_ACTIVE);
	buf.write_int64(start_time.sec());
	//DATA START
	answer_info.serialize(buf);
	//DATA END

	buf.finish_message();
	LOGIC_MONITOR->send_to_scene(ANSWER_INNER_SCENE_ID, 0, buf);
}
Beispiel #17
0
void RandMsg::rand_send(void) {
	Robot_Player *player = (Robot_Player*)this;
	int num = rand()%msg_vec->size();
	Robot_Base_Msg *msg = (*msg_vec)[num];
	msg->set_rand();
	Block_Buffer buf;
	buf.make_client_message(msg->msg_id, player->msg_detail().msg_serial++, Time_Value::gettimeofday().sec());
	msg->serialize(buf);
	buf.finish_message();
	player->send_to_server(buf);
	//MSG_USER("%s >< 发送随机消息号:%d", player->base_detail().account.c_str(), msg->msg_id);
}
Beispiel #18
0
int Operating::offline_ganger_info_update(role_id_t role_id, Ganger_Detail& detail) {
	if ( role_id == 0 ) return 0;
	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	int type = OPERATING_OFFLINE_GANGER_INFO;
	buf.write_int32(type);
	buf.write_int64(role_id);
	detail.serialize( buf );
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}
Beispiel #19
0
void Answer_Scene::send_to_logic_save_data(void) {
	//以下代码;策划要求改跨服需要特殊处理
	Block_Buffer buf;
	buf.make_message(INNER_ANSWER_DATA_CHANNEL);
	buf.write_uint8(ANSWER_DATA_CHANNLE_TYPE_SL_SAVE_DATA);

	//DATA START
	answer_info.serialize(buf);
	//DATA END

	buf.finish_message();
	SCENE_MONITOR->send_to_logic(CONFIG_CACHE->server_flag(), buf);
}
void Answer_Manager::send_scene_close_action(void) {
	is_close = true;
	Block_Buffer buf;
	buf.make_message(INNER_ANSWER_DATA_CHANNEL);
	buf.write_uint8(ANSWER_DATA_CHANNLE_TYPE_LS_CLOSE_ACTIVE);

	//DATA START
	buf.write_int64(end_time.sec());
	//DATA END

	buf.finish_message();
	LOGIC_MONITOR->send_to_scene(ANSWER_INNER_SCENE_ID, 0, buf);
}
Beispiel #21
0
int Map_Team::sync_info_logic(void) {
	MSG_20100304 inner_msg;
	Block_Buffer buf;
	Time_Value now;
	now = Time_Value::gettimeofday();
	buf.make_message(inner_msg.msg_id);
	buf.write_int64(team_id_);
	buf.write_int16(fail_times_);
	buf.write_int16(match_fail_);
	now.serialize(buf);
	buf.finish_message();
	this->info_all_online_player(inner_msg.msg_id, &buf);
	return 0;
}
Beispiel #22
0
int Chat_Player::system_chat(std::vector<Chat_Content *> &contents){
	MSG_83000000 scMsg;
	scMsg.chat_type = chat_system;
	scMsg.system_type = 4;
	scMsg.role_type = player_self()->base_detail().role_type;

	for (std::vector<Chat_Content *>::iterator it = contents.begin(); it != contents.end(); ++it) {
		scMsg.content.push_back(**it);
	}
	Block_Buffer buf;
	buf.make_message(ACTIVE_CHAT_BOARD);
	scMsg.serialize(buf);
	buf.finish_message();
	return monitor()->send_to_all_players(buf);
}
Beispiel #23
0
int Operating::offline_like_success(role_id_t role_id) {
	if (!role_id) {
		MSG_USER("error role id");
		return -1;
	}

	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	uint32_t op_type = OPERATING_OFFLINE_LIKE_SUCCESS;
	buf.write_uint32(op_type);
	buf.write_int64(role_id);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}
Beispiel #24
0
int Scene_Common::req_scene_chat(std::vector<Chat_Content> &content, int32_t sys_type) {
    if(player_self() && player_self()->move_scene()) {
        MSG_83000000 msg;
        msg.chat_type = chat_scene;
        msg.system_type = sys_type;
        msg.role_type = player_self()->base_detail().role_type;
        msg.content = content;
        Block_Buffer buf;
        buf.make_message(msg.msg_id);
        msg.serialize(buf);
        buf.finish_message();
        player_self()->move_scene()->broadcast_chat_all(player_self()->mover_detail().layer_id, buf);
    }
    return 0;
}
Beispiel #25
0
int Game_Manager::close_client(int gate_cid, int player_cid, int error_code) {
	if (Server_Manager::close_client(gate_cid, player_cid, error_code) < 0) return -1;

	//将玩家cid投放到js层
	push_drop_player_cid(GET_CID(gate_cid, player_cid));

	if (error_code != 0) {
		//gate与game断开连接不通知客户端,其他情况通知
		Block_Buffer buf;
		buf.make_player_message(ACTIVE_DISCONNECT, error_code, player_cid);
		buf.finish_message();
		send_to_gate(gate_cid, buf);
	}
	return 0;
}
Beispiel #26
0
int DB_Worker::process_create_player(int cid, Create_Role_Info &role_info) {
	int64_t role_id = 0;
	Block_Buffer buf;
	if ((role_id = DB_MANAGER->create_player(role_info)) > 0) {
		buf.make_server_message(SYNC_DB_GAME_CREATE_PLAYER, ROLE_SUCCESS_CREATE);
		buf.write_string(role_info.account);
		//创建所有玩家表,构建登录消息buf
		create_player_data(role_id, buf);
	} else {
		buf.make_server_message(SYNC_DB_GAME_CREATE_PLAYER, ROLE_HAS_EXIST);
		buf.write_string(role_info.account);
	}
	buf.finish_message();
	DB_MANAGER->send_data_block(cid, buf);
	return 0;
}
Beispiel #27
0
int Operating::offline_invite_player(role_id_t role_id, const Time_Value &time) {
	if (!role_id) {
		MSG_USER("error role id");
		return -1;
	}

	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	uint32_t op_type = OPERATING_OFFLINE_INVITE_PLAYER;
	buf.write_uint32(op_type);
	buf.write_int64(role_id);
	buf.write_int64(time.sec());
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}
Beispiel #28
0
int Operating::offline_dragon_vale_special_notice(role_id_t role_id, bool is_special) {
	if (!role_id) {
		MSG_USER("error role id");
		return -1;
	}

	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	uint32_t op_type = OPERATING_OFFLINE_DRAGON_VALE_SPECIAL;
	buf.write_uint32(op_type);
	buf.write_int64(role_id);
	buf.write_bool(is_special);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}
Beispiel #29
0
int Operating::offline_mail(Mail_Send_Info &send_info) {
	if (!send_info.receiver_id) {
		MSG_USER("error receiver id");
		return -1;
	}
	MSG_DEBUG("offline_mail, role_id:%ld, mail_title:%s, mail_contents:%s", send_info.receiver_id, send_info.title.c_str(), send_info.content.c_str() );
	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	int type = OPERATING_OFFLINE_MAIL;
	buf.write_int32(type);
	send_info.serialize(buf);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);

	return 0;
}
Beispiel #30
0
int Operating::offline_receive_flowers(role_id_t role_id, std::string &role_name, uint32_t item_id,  uint32_t charm, uint32_t friend_num, std::string &msg, role_id_t receive_role_id) {
	if ( role_id == 0 ) return 0;
	Block_Buffer buf;
	buf.make_message(MONGO_OPERATING_OFFLINE_DATA);
	int type = OPERATING_OFFLINE_RECEIVE_FLOWERS;
	buf.write_int32(type);
	buf.write_int64(role_id);
	buf.write_string(role_name);
	buf.write_uint32(item_id);
	buf.write_uint32(charm);
	buf.write_uint32(friend_num);
	buf.write_string(msg);
	buf.write_int64(receive_role_id);
	buf.finish_message();
	DB_MANAGER->push_data_block(buf, 0);
	return 0;
}