internal void HandleQueryArenaMatchGroup(ulong guid) { LogSys.Log(LOG_TYPE.DEBUG, "---got query match group msg! id=" + guid); UserInfo user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(guid); if (user == null) { return; } JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaMatchGroupResult); resultMsg.m_Guid = guid; int cur_user_rank = ArenaSystem.UNKNOWN_RANK; ArenaInfo arena_info = m_ArenaSystem.GetArenaInfoById(guid); if (arena_info != null) { cur_user_rank = arena_info.GetRank(); }; List<MatchGroup> match_groups = m_ArenaSystem.QueryMatchArena(cur_user_rank, 3); ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult(); foreach (MatchGroup group in match_groups) { ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData group_msg = new ArkCrossEngineMessage.Msg_LC_ArenaMatchGroupResult.MatchGroupData(); group_msg.One = ArenaUtil.CreateArenaInfoMsg(group.One); group_msg.Two = ArenaUtil.CreateArenaInfoMsg(group.Two); group_msg.Three = ArenaUtil.CreateArenaInfoMsg(group.Three); if (group_msg.One == null || group_msg.Two == null || group_msg.Three == null) { continue; } protoData.m_MatchGroups.Add(group_msg); } resultMsg.m_ProtoData = protoData; JsonMessageDispatcher.SendDcoreMessage(user.NodeName, resultMsg); LogSys.Log(LOG_TYPE.DEBUG, "---send match group msg! id=" + guid); }
private void RecordChallengeAction(ArenaInfo challenger, ArenaInfo target, bool IsSuccess) { DataProcessScheduler dataProcess = LobbyServer.Instance.DataProcessScheduler; if (null == challenger && null == target) { return; } UserInfo user1 = dataProcess.GetUserInfo(challenger.GetId()); UserInfo user2 = dataProcess.GetUserInfo(target.GetId()); if (null == user1 || null == user2) { return; } AccountInfo challenger_acc = dataProcess.FindAccountInfoById(user1.AccountId); if (null != challenger_acc) { int c_ct = challenger.FightPartners.Count; int c_partner_frt = 0 < c_ct ? challenger.FightPartners[0].Id : 0; int c_partner_scd = 1 < c_ct ? challenger.FightPartners[1].Id : 0; int c_partner_thd = 2 < c_ct ? challenger.FightPartners[2].Id : 0; int t_ct = target.FightPartners.Count; int t_partner_frt = 0 < t_ct ? target.FightPartners[0].Id : 0; int t_partner_scd = 1 < t_ct ? target.FightPartners[1].Id : 0; int t_partner_thd = 2 < t_ct ? target.FightPartners[2].Id : 0; /// norm log LogSys.NormLog("arena", LobbyConfig.AppKeyStr, challenger_acc.ClientGameVersion, Module.arena, LobbyConfig.LogNormVersionStr, "C0500", challenger_acc.LogicServerId, user1.AccountId, user1.Guid, user1.Level, user1.HeroId, user1.FightingScore, c_partner_frt, c_partner_scd, c_partner_thd, user2.AccountId, user2.Guid, user2.Level, user2.HeroId, user2.FightingScore, t_partner_frt, t_partner_scd, t_partner_thd, challenger.GetRank(), IsSuccess ? 1 : 0); } }
internal void AddArenaInfo(ArenaInfo arenaInfo) { if (arenaInfo != null) { arenaInfo.BattleCD = m_BaseConfig.BattleCd; arenaInfo.MaxFightCount = m_BaseConfig.MaxBattleCount; m_ArenaRank.SetRankEntity(arenaInfo.GetRank(), arenaInfo); } }
private void PrintRank(int rank) { ArenaInfo rank_info = m_ArenaRank.GetRankEntity(rank); if (rank_info != null) { LogSys.Log(LOG_TYPE.DEBUG, "RankInfo: rank={0} guid={1} nickname={2}", rank_info.GetRank(), rank_info.GetId(), rank_info.NickName); } else { LogSys.Log(LOG_TYPE.DEBUG, "RankInfo: rank {0} is not set to anybody!", rank); } }
internal void SaveUserArena(ulong userGuid) { ArenaInfo arenaInfo = m_ArenaSystem.GetArenaInfoById(userGuid); if (arenaInfo != null && arenaInfo.GetRank() == ArenaSystem.UNKNOWN_RANK) { var dsThread = LobbyServer.Instance.DataStoreThread; if (dsThread.DataStoreAvailable) { List<ChallengeInfo> arenaRecordList = m_ArenaSystem.QueryHistory(userGuid); dsThread.DSPSaveUserArena(arenaInfo, arenaRecordList); m_ArenaSystem.RemoveUnRankEntity(userGuid); } } }
internal void HandleArenaQueryRank(ulong guid, int handle) { JsonMessageWithGuid resultMsg = new JsonMessageWithGuid(JsonMessageID.ArenaQueryRankResult); resultMsg.m_Guid = guid; ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult protoData = new ArkCrossEngineMessage.Msg_LC_ArenaQueryRankResult(); ArenaInfo cur_info = m_ArenaSystem.GetArenaInfoById(guid); if (cur_info != null) { List<ArenaInfo> result = m_ArenaSystem.QueryRankList(cur_info.GetRank()); for (int i = 0; i < result.Count; i++) { protoData.RankMsg.Add(ArenaUtil.CreateArenaInfoMsg(result[i])); } } resultMsg.m_ProtoData = protoData; JsonMessageDispatcher.SendDcoreMessage(handle, resultMsg); LogSys.Log(LOG_TYPE.DEBUG, "send query rank list!"); }
internal void ChallengeResult(ChallengeInfo info, bool IsSuccess) { if (info.IsDone) { return; } ArenaInfo challenger = m_Rank.GetRankEntityById(info.Challenger.Guid); ArenaInfo target = m_Rank.GetRankEntityById(info.Target.Guid); info.Challenger.Rank = challenger.GetRank(); info.Target.Rank = target.GetRank(); if (IsSuccess && IsRankShouldChange(info.Challenger.Rank, info.Target.Rank)) { m_Rank.ExchangeRank(challenger, target); } info.IsDone = true; info.IsChallengerSuccess = IsSuccess; if (IsChallengeOverTime(info)) { info.ChallengeEndTime = info.ChallengeDeadLine; challenger.LastBattleTime = info.ChallengeDeadLine; } else { info.ChallengeEndTime = DateTime.Now; challenger.LastBattleTime = DateTime.Now; } m_DoingChallenges.Remove(challenger.GetId()); AddChallengeHistory(info.Challenger.Guid, info); AddChallengeHistory(info.Target.Guid, info); UserInfo challenge_user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(info.Challenger.Guid); SendResultMsg(info, challenge_user); UserInfo target_user = LobbyServer.Instance.DataProcessScheduler.GetUserInfo(info.Target.Guid); SendResultMsg(info, target_user); LogSys.Log(LOG_TYPE.DEBUG, "-----send challenge result msg"); /// RecordChallengeAction(challenger, target, IsSuccess); }
private ChallengeEntityInfo CreateChallengeEntityInfo(ArenaInfo arena) { ChallengeEntityInfo info = new ChallengeEntityInfo(); info.Guid = arena.GetId(); info.HeroId = arena.HeroId; info.Level = arena.Level; info.FightScore = arena.FightScore; info.NickName = arena.NickName; info.Rank = arena.GetRank(); info.UserDamage = 0; info.PartnerDamage.Clear(); for (int i = 0; i < arena.FightPartners.Count; i++) { PartnerInfo partner = arena.FightPartners[i]; DamageInfo damange_info = new DamageInfo(); damange_info.OwnerId = partner.Id; damange_info.Damage = 0; info.PartnerDamage.Add(damange_info); } return(info); }
internal void DoLastSaveGlobalData() { m_LastSaveFinished = false; m_NextGuidSaveCount = 0; m_NextMailSaveCount = 0; m_NextGowstarSaveCount = 0; m_NextArenaRankSaveCount = 0; m_NextArenaRecordSaveCount = 0; var dsThread = LobbyServer.Instance.DataStoreThread; if (dsThread.DataStoreAvailable) { dsThread.DSGSaveGuid(m_GuidSystem.GuidList, m_NextGuidSaveCount); dsThread.DSGSaveGowStar(m_GowSystem.GowStarList, m_NextGowstarSaveCount); dsThread.DSGSaveMail(m_MailSystem.TotalMailList, m_NextMailSaveCount); m_CurrentArenaRankSaveCountList.Clear(); int rankPieceCount = dsThread.DSGSaveArenaRank(m_ArenaSystem.ArenaRankList, m_NextArenaRankSaveCount); m_CurrentArenaRankSaveCountList = new List<long>(rankPieceCount); for (int i = 0; i < rankPieceCount; ++i) { m_CurrentArenaRankSaveCountList.Add(-1); } m_CurrentArenaRecordSaveCountList.Clear(); var challengeHistory = m_ArenaSystem.ArenaChallengeHistory; Dictionary<ulong, int> userRankDict = new Dictionary<ulong, int>(); foreach (var userGuid in challengeHistory.Keys) { ArenaInfo ai = m_ArenaSystem.GetArenaInfoById(userGuid); userRankDict.Add(userGuid, ai.GetRank()); } int recordPieceCount = dsThread.DSGSaveArenaRecord(challengeHistory, userRankDict, m_NextArenaRecordSaveCount); m_CurrentArenaRecordSaveCountList = new List<long>(recordPieceCount); for (int i = 0; i < recordPieceCount; ++i) { m_CurrentArenaRecordSaveCountList.Add(-1); } } }
internal static ArkCrossEngineMessage.ArenaInfoMsg CreateArenaInfoMsg(ArenaInfo entity, bool is_detail = true) { if (null == entity) { return(null); } ArkCrossEngineMessage.ArenaInfoMsg info_msg = new ArkCrossEngineMessage.ArenaInfoMsg(); info_msg.Guid = entity.GetId(); info_msg.HeroId = entity.HeroId; info_msg.Level = entity.Level; info_msg.NickName = entity.NickName; info_msg.Rank = entity.GetRank(); info_msg.FightScore = entity.FightScore; foreach (PartnerInfo partner in entity.FightPartners) { ArkCrossEngineMessage.PartnerDataMsg partner_msg = new ArkCrossEngineMessage.PartnerDataMsg(); partner_msg.Id = partner.Id; partner_msg.AdditionLevel = partner.CurAdditionLevel; partner_msg.SkillStage = partner.CurSkillStage; info_msg.FightParters.Add(partner_msg); } if (!is_detail) { return(info_msg); } if (entity.ActivePartner != null) { ArkCrossEngineMessage.PartnerDataMsg active_partner_msg = new ArkCrossEngineMessage.PartnerDataMsg(); active_partner_msg.Id = entity.ActivePartner.Id; active_partner_msg.AdditionLevel = entity.ActivePartner.CurAdditionLevel; active_partner_msg.SkillStage = entity.ActivePartner.CurSkillStage; info_msg.ActivePartner = active_partner_msg; } foreach (ItemInfo item in entity.EquipInfo) { ArkCrossEngineMessage.ItemDataMsg equip = new ArkCrossEngineMessage.ItemDataMsg(); equip.ItemId = item.ItemId; equip.Level = item.Level; equip.Num = item.ItemNum; info_msg.EquipInfo.Add(equip); } foreach (SkillDataInfo skill in entity.SkillDataInfo) { ArkCrossEngineMessage.SkillDataInfo skill_msg = new ArkCrossEngineMessage.SkillDataInfo(); skill_msg.ID = skill.ID; skill_msg.Level = skill.Level; skill_msg.Postions = (int)skill.Postions.Presets[0]; info_msg.ActiveSkills.Add(skill_msg); } foreach (ArenaItemInfo legacy in entity.LegacyInfo) { ArkCrossEngineMessage.LegacyDataMsg legacy_msg = new ArkCrossEngineMessage.LegacyDataMsg(); legacy_msg.ItemId = legacy.ItemId; legacy_msg.Level = legacy.Level; legacy_msg.AppendProperty = legacy.AppendProperty; legacy_msg.IsUnlock = legacy.IsUnlocked; info_msg.LegacyAttr.Add(legacy_msg); } foreach (ArenaXSoulInfo xsoul in entity.XSoulInfo) { ArkCrossEngineMessage.XSoulDataMsg msg = new ArkCrossEngineMessage.XSoulDataMsg(); msg.ItemId = xsoul.ItemId; msg.Level = xsoul.Level; msg.Experience = xsoul.Experience; msg.ModelLevel = xsoul.ModelLevel; info_msg.XSouls.Add(msg); } return(info_msg); }
protected override void OnTick() { long curTime = TimeUtility.GetServerMilliseconds(); if (m_LastLogTime + 60000 < curTime) { m_LastLogTime = curTime; DebugPoolCount((string msg) => { LogSys.Log(LOG_TYPE.INFO, "GlobalDataProcessThread.ActionQueue {0}", msg); }); } m_ActivitySystem.Tick(); m_MailSystem.Tick(); m_GowSystem.Tick(); m_ArenaSystem.Tick(); //全局数据存储 var dsThread = LobbyServer.Instance.DataStoreThread; if (dsThread.DataStoreAvailable) { if (curTime - m_LastGuidSaveTime > s_GuidSaveInterval && m_NextGuidSaveCount != 0) { dsThread.DSGSaveGuid(m_GuidSystem.GuidList, m_NextGuidSaveCount); m_LastGuidSaveTime = curTime; m_NextGuidSaveCount++; } if (curTime - m_LastMailSaveTime > s_MailSaveInterval && m_NextMailSaveCount != 0) { dsThread.DSGSaveMail(m_MailSystem.TotalMailList, m_NextMailSaveCount); m_LastMailSaveTime = curTime; m_NextMailSaveCount++; } if (curTime - m_LastGowstarSaveTime > s_GowstarSaveInterval && m_NextGowstarSaveCount != 0) { dsThread.DSGSaveGowStar(m_GowSystem.GowStarList, m_NextGowstarSaveCount); m_LastGowstarSaveTime = curTime; m_NextGowstarSaveCount++; } if (curTime - m_LastArenaRankSaveTime > s_ArenaRankSaveInterval && m_NextArenaRankSaveCount != 0) { m_CurrentArenaRankSaveCountList.Clear(); int pieceCount = dsThread.DSGSaveArenaRank(m_ArenaSystem.ArenaRankList, m_NextArenaRankSaveCount); m_CurrentArenaRankSaveCountList = new List<long>(pieceCount); for (int i = 0; i < pieceCount; ++i) { m_CurrentArenaRankSaveCountList.Add(-1); } m_LastArenaRankSaveTime = curTime; m_NextArenaRankSaveCount++; } if (curTime - m_LastArenaRecordSaveTime > s_ArenaRecordSaveInterval && m_NextArenaRecordSaveCount != 0) { m_CurrentArenaRecordSaveCountList.Clear(); var challengeHistory = m_ArenaSystem.ArenaChallengeHistory; Dictionary<ulong, int> userRankDict = new Dictionary<ulong, int>(); foreach (var userGuid in challengeHistory.Keys) { ArenaInfo ai = m_ArenaSystem.GetArenaInfoById(userGuid); userRankDict.Add(userGuid, ai.GetRank()); } int pieceCount = dsThread.DSGSaveArenaRecord(challengeHistory, userRankDict, m_NextArenaRecordSaveCount); m_CurrentArenaRecordSaveCountList = new List<long>(pieceCount); for (int i = 0; i < pieceCount; ++i) { m_CurrentArenaRecordSaveCountList.Add(-1); } m_LastArenaRecordSaveTime = curTime; m_NextArenaRecordSaveCount++; } if (m_CurrentGuidSaveCount == 0 && m_CurrentMailSaveCount == 0 && m_CurrentGowstarSaveCount == 0 && CheckLastSaveArenaRankDone() && CheckLastSaveArenaRecordDone()) { if (m_LastSaveFinished == false) { //全局数据(Guid、战神赛排行榜,邮件,竞技场排行榜,竞技场战斗记录)存储完成 LogSys.Log(LOG_TYPE.MONITOR, "GlobalDataProcessThread DoLastSaveGlobalData Done!"); m_LastSaveFinished = true; } } } }