Пример #1
0
        /// <summary>
        /// 初始化GameServer代理
        /// 同一个GameServer的Service与ClientAgent是一个N:1的关系
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="clientInfo"></param>
        /// <param name="bFistInit">是否是首次初始化该client</param>
        /// <returns></returns>
        public int InitializeClient(IKuaFuClient callback, KuaFuClientContext clientInfo, out bool bFistInit)
        {
            bFistInit = false;
            lock (Mutex)
            {
                ClientAgent agent = null;
                if (!ServerId2ClientAgent.TryGetValue(clientInfo.ServerId, out agent) ||
                    !agent.IsAlive)
                {
                    // clientInfo.ServerId 上的任意service都未连接过来,或者已连接,但是agent已超时死亡,需要重设agent
                    LogManager.WriteLog(LogTypes.Info,
                                        string.Format("InitializeClient服务器连接1.ServerId:{0},ClientId:{1},info:{2},GameType:{3} [Service首次连接过来]",
                                                      clientInfo.ServerId, clientInfo.ClientId, clientInfo.Token, (GameTypes)clientInfo.GameType));
                    bFistInit           = true;
                    clientInfo.ClientId = KuaFuServerManager.GetUniqueClientId();
                    agent = new ClientAgent(clientInfo, callback);
                    ServerId2ClientAgent[clientInfo.ServerId] = agent;
                }
                else
                {
                    // clientInfo.ServerId 上的至少有一个service已经连接过来了

                    // token 不一致,重复 ServerId重复!!!
                    if (clientInfo.Token != agent.ClientInfo.Token)
                    {
                        LogManager.WriteLog(LogTypes.Info,
                                            string.Format("InitializeClient服务器ID重复,禁止连接.ServerId:{0},ClientId:{1},info:{2},GameType:{3}",
                                                          clientInfo.ServerId, clientInfo.ClientId, clientInfo.Token, (GameTypes)clientInfo.GameType));
                        return(StdErrorCode.Error_Duplicate_Key_ServerId);
                    }

                    // clientInfo.ServerId 这个GameType的Service首次连接过来
                    if (clientInfo.ClientId <= 0)
                    {
                        bFistInit = true;
                        LogManager.WriteLog(LogTypes.Info,
                                            string.Format("InitializeClient服务器连接2.ServerId:{0},ClientId:{1},info:{2},GameType:{3} [Service非首次连接过来]",
                                                          clientInfo.ServerId, clientInfo.ClientId, clientInfo.Token, (GameTypes)clientInfo.GameType));
                    }
                    else if (clientInfo.ClientId != agent.ClientInfo.ClientId)
                    {
                        // GameServer不重启,中心重启后,从第二个连过来的service开始会走到这里
                        // tcp的虚拟连接能够使Gameserver感知不到中心的重启,这里需要修改clientInfo.ClientId
                        bFistInit = true;
                        LogManager.WriteLog(LogTypes.Info,
                                            string.Format("InitializeClient服务器连接3.ServerId:{0},ClientId:{1},info:{2},GameType:{3} [中心重启]",
                                                          clientInfo.ServerId, clientInfo.ClientId, clientInfo.Token, (GameTypes)clientInfo.GameType));
                    }
                }

                if (agent != null)
                {
                    clientInfo.ClientId = agent.ClientInfo.ClientId;
                    agent.ClientHeartTick();
                    agent.TryInitGameType(clientInfo.GameType);
                }

                return(clientInfo.ClientId);
            }
        }
Пример #2
0
        public int InitializeClient(KuaFuClientContext clientInfo)
        {
            int result;

            try
            {
                if (clientInfo.ServerId != 0)
                {
                    bool bFirstInit = false;
                    int  ret        = ClientAgentManager.Instance().InitializeClient(clientInfo, out bFirstInit);
                    if (ret > 0)
                    {
                        if (clientInfo.MapClientCountDict != null && clientInfo.MapClientCountDict.Count > 0)
                        {
                            KuaFuServerManager.UpdateKuaFuLineData(clientInfo.ServerId, clientInfo.MapClientCountDict);
                            ClientAgentManager.Instance().SetMainlinePayload(clientInfo.ServerId, clientInfo.MapClientCountDict.Values.ToList <int>().Sum());
                        }
                    }
                    result = ret;
                }
                else
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("InitializeClient时GameType错误,禁止连接.ServerId:{0},GameType:{1}", clientInfo.ServerId, clientInfo.GameType), null, true);
                    result = -4003;
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(string.Format("InitializeClient服务器ID重复,禁止连接.ServerId:{0},ClientId:{1},info:{2}", clientInfo.ServerId, clientInfo.ClientId, clientInfo.Token));
                result = -11003;
            }
            return(result);
        }
Пример #3
0
 public void InitConfig()
 {
     if (!this._Config.Load(KuaFuServerManager.GetResourcePath("Config\\Match.xml", KuaFuServerManager.ResourcePathTypes.GameRes), KuaFuServerManager.GetResourcePath("Config\\Sustain.xml", KuaFuServerManager.ResourcePathTypes.GameRes), KuaFuServerManager.GetResourcePath("Config\\MatchBirthPoint.xml", KuaFuServerManager.ResourcePathTypes.GameRes)))
     {
         LogManager.WriteLog(LogTypes.Error, "ZhengBaManagerK.InitConfig failed!", null, true);
     }
 }
Пример #4
0
 public AsyncDataItem GetKuaFuLineDataList(int mapCode)
 {
     return(new AsyncDataItem(KuaFuEventTypes.Other, new object[]
     {
         KuaFuServerManager.GetKuaFuLineDataList(mapCode)
     }));
 }
Пример #5
0
        private void InitLangHunLingYuConfig()
        {
            string fileName = "";

            lock (this.Mutex)
            {
                try
                {
                    Dictionary <int, CityLevelInfo> cityLevelInfoDict = new Dictionary <int, CityLevelInfo>();
                    fileName = "Config/MU_City.xml";
                    string   fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
                    XElement xml = ConfigHelper.Load(fullPathFileName);
                    IEnumerable <XElement> nodes = xml.Elements();
                    foreach (XElement t in nodes)
                    {
                        string type = ConfigHelper.GetElementAttributeValue(t, "TypeID", "");
                        if (string.Compare(type, KuaFuServerManager.platformType.ToString(), true) == 0)
                        {
                            foreach (XElement node in t.Elements())
                            {
                                CityLevelInfo item = new CityLevelInfo();
                                item.ID        = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID", 0L);
                                item.CityLevel = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityLevel", 0L);
                                item.CityNum   = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityNum", 0L);
                                item.MaxNum    = (int)ConfigHelper.GetElementAttributeValueLong(node, "MaxNum", 0L);
                                string strAttackWeekDay = ConfigHelper.GetElementAttributeValue(node, "AttackWeekDay", "");
                                item.AttackWeekDay = ConfigHelper.String2IntArray(strAttackWeekDay, ',');
                                if (!ConfigHelper.ParserTimeRangeListWithDay(item.BaoMingTime, ConfigHelper.GetElementAttributeValue(node, "BaoMingTime", "").Replace(';', '|'), true, '|', '-', ','))
                                {
                                    LogManager.WriteLog(LogTypes.Fatal, string.Format("解析文件{0}的BaoMingTime出错", fileName), null, true);
                                    KuaFuServerManager.LoadConfigSuccess = false;
                                }
                                if (!ConfigHelper.ParserTimeRangeList(item.AttackTime, ConfigHelper.GetElementAttributeValue(node, "AttackTime", ""), true, '|', '-'))
                                {
                                    LogManager.WriteLog(LogTypes.Fatal, string.Format("解析文件{0}的BaoMingTime出错", fileName), null, true);
                                    KuaFuServerManager.LoadConfigSuccess = false;
                                }
                                cityLevelInfoDict[item.CityLevel] = item;
                            }
                            break;
                        }
                    }
                    this.CityLevelInfoDict = cityLevelInfoDict;
                    if (this.CityLevelInfoDict.Count == 0)
                    {
                        LogManager.WriteLog(LogTypes.Fatal, string.Format("读取配置{0}失败,读取到的城池配置数为0", new object[0]), null, true);
                        KuaFuServerManager.LoadConfigSuccess = false;
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。{1}", fileName, ex.ToString()), null, true);
                    KuaFuServerManager.LoadConfigSuccess = false;
                }
            }
        }
Пример #6
0
        private void InitLangHunLingYuConfig()
        {
            string fileName         = "";
            string fullPathFileName = "";
            IEnumerable <XElement> nodes;

            lock (Mutex)
            {
                try
                {
                    Dictionary <int, CityLevelInfo> cityLevelInfoDict = new Dictionary <int, CityLevelInfo>();

                    fileName         = "Config/MU_City.xml";
                    fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
                    XElement xml = ConfigHelper.Load(fullPathFileName);

                    nodes = xml.Elements();
                    int cityId = 0;
                    foreach (var t in nodes)
                    {
                        string type = ConfigHelper.GetElementAttributeValue(t, "TypeID");
                        if (string.Compare(type, KuaFuServerManager.platformType.ToString(), true) == 0)
                        {
                            foreach (var node in t.Elements())
                            {
                                CityLevelInfo item = new CityLevelInfo();
                                item.ID        = (int)ConfigHelper.GetElementAttributeValueLong(node, "ID");
                                item.CityLevel = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityLevel");
                                item.CityNum   = (int)ConfigHelper.GetElementAttributeValueLong(node, "CityNum");
                                item.MaxNum    = (int)ConfigHelper.GetElementAttributeValueLong(node, "MaxNum");

                                string strAttackWeekDay = ConfigHelper.GetElementAttributeValue(node, "AttackWeekDay");
                                item.AttackWeekDay = ConfigHelper.String2IntArray(strAttackWeekDay);

                                cityLevelInfoDict[item.CityLevel] = item;
                            }

                            break;
                        }
                    }

                    CityLevelInfoDict = cityLevelInfoDict;
                    if (CityLevelInfoDict.Count == 0)
                    {
                        LogManager.WriteLog(LogTypes.Fatal, string.Format("读取配置{0}失败,读取到的城池配置数为0"));
                        KuaFuServerManager.LoadConfigSuccess = false;
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogTypes.Fatal, string.Format("加载xml配置文件:{0}, 失败。{1}", fileName, ex.ToString()));
                    KuaFuServerManager.LoadConfigSuccess = false;
                }
            }
        }
Пример #7
0
 private bool LoadKuaFuLueDuoBHData(Dictionary <int, KuaFuData <KuaFuLueDuoBHData> > KuaFuLueDuoBHDataDict, int minSeason)
 {
     try
     {
         long   sAge   = TimeUtil.AgeByNow();
         string strSql = string.Format("SELECT * FROM t_kfld_banghui where `season`>={0}", minSeason);
         using (MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false))
         {
             while (sdr != null && sdr.Read())
             {
                 KuaFuData <KuaFuLueDuoBHData> bhData = new KuaFuData <KuaFuLueDuoBHData>();
                 bhData.V.season      = Convert.ToInt32(sdr["season"]);
                 bhData.V.bhid        = Convert.ToInt32(sdr["bhid"]);
                 bhData.V.bhname      = (sdr["bhname"] as string);
                 bhData.V.zoneid      = Convert.ToInt32(sdr["zoneid"]);
                 bhData.V.sum_ziyuan  = Convert.ToInt32(sdr["sum_ziyuan"]);
                 bhData.V.last_ziyuan = Convert.ToInt32(sdr["last"]);
                 bhData.Age           = sAge;
                 KuaFuLueDuoBHDataDict[bhData.V.bhid] = bhData;
                 int zoneid = bhData.V.zoneid;
                 if (bhData.V.sum_ziyuan > 0 && zoneid > 0 && zoneid < this.ZoneID2ServerIDs.Length)
                 {
                     KuaFuLueDuoServerInfo data;
                     if (this.ServerInfoDict.TryGetValue(this.ZoneID2ServerIDs[zoneid], out data))
                     {
                         string name = KuaFuServerManager.FormatName(bhData.V.bhname, bhData.V.zoneid);
                         data.MingXingList.Add(new KuaFuLueDuoRankInfo
                         {
                             Key    = bhData.V.bhid,
                             Param1 = name,
                             Value  = bhData.V.sum_ziyuan
                         });
                     }
                 }
             }
         }
         foreach (KuaFuLueDuoServerInfo data in this.ServerInfoDict.Values)
         {
             string mingxing = KuaFuLueDuoUtils.RankList2MingXingStr(data.MingXingList, 2);
             if (mingxing != data.MingXingZhanMengList)
             {
                 data.MingXingZhanMengList = mingxing;
                 string sql = string.Format("update t_kfld_server set `mingxing`='{1}' where `serverid`={0}", data.ServerId, mingxing);
                 this.ExecuteSqlNoQuery(sql);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
         return(false);
     }
     return(true);
 }
Пример #8
0
		public void InitConfig()
		{
			if (!this._config.Load(KuaFuServerManager.GetResourcePath("Config\\PlunderLands.xml", KuaFuServerManager.ResourcePathTypes.GameRes), KuaFuServerManager.GetResourcePath("Config\\PlunderLandsMonster.xml", KuaFuServerManager.ResourcePathTypes.GameRes), KuaFuServerManager.GetResourcePath("Config\\PlunderLandsRebirth.xml", KuaFuServerManager.ResourcePathTypes.GameRes)))
			{
				LogManager.WriteLog(LogTypes.Error, string.Format("加载[{0}]时出错!!!", "争夺之地"), null, true);
			}
			else
			{
				this.LoadDBConfig();
			}
		}
Пример #9
0
 public void UpdateKuaFuMapClientCount(int serverId, Dictionary <int, int> mapClientCountDict)
 {
     if (mapClientCountDict != null && mapClientCountDict.Count > 0)
     {
         ClientAgent agent = ClientAgentManager.Instance().GetCurrentClientAgent(serverId);
         if (null != agent)
         {
             KuaFuServerManager.UpdateKuaFuLineData(agent.ClientInfo.ServerId, mapClientCountDict);
             ClientAgentManager.Instance().SetMainlinePayload(agent.ClientInfo.ServerId, mapClientCountDict.Values.ToList <int>().Sum());
         }
     }
 }
Пример #10
0
 public void InitConfig()
 {
     try
     {
         lock (this.Mutex)
         {
             string fileName         = "Config/RebornBoss.xml";
             string fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
             this.RebornBossConfigDict.Clear();
             XElement xml = ConfigHelper.Load(fullPathFileName);
             IEnumerable <XElement> xmlItems = xml.Elements();
             foreach (XElement xmlItem in xmlItems)
             {
                 int MapCodeID = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "MapID", 0L);
                 List <RebornBossConfig> bossList;
                 if (!this.RebornBossConfigDict.TryGetValue(MapCodeID, out bossList))
                 {
                     bossList = new List <RebornBossConfig>();
                     this.RebornBossConfigDict[MapCodeID] = bossList;
                 }
                 RebornBossConfig myData = new RebornBossConfig();
                 myData.ID         = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L);
                 myData.MapID      = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "MapID", 0L);
                 myData.MonstersID = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "MonstersID", 0L);
                 bossList.Add(myData);
             }
             foreach (List <RebornBossConfig> value in this.RebornBossConfigDict.Values)
             {
                 value.Sort(delegate(RebornBossConfig left, RebornBossConfig right)
                 {
                     int result;
                     if (left.ID < right.ID)
                     {
                         result = -1;
                     }
                     else if (left.ID > right.ID)
                     {
                         result = 1;
                     }
                     else
                     {
                         result = 0;
                     }
                     return(result);
                 });
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
     }
 }
Пример #11
0
        private bool LoadBHMatchPKInfoList(BangHuiMatchType type, KuaFuData <List <BangHuiMatchPKInfo> > BHMatchPKInfoList_Gold)
        {
            bool result;

            if (null == BHMatchPKInfoList_Gold)
            {
                result = false;
            }
            else
            {
                BHMatchPKInfoList_Gold.V.Clear();
                try
                {
                    KuaFuData <BHMatchBHData> bhData = null;
                    string          strSql           = string.Format("SELECT * FROM t_banghui_match_pk_log WHERE `type`={0} ORDER BY `season` DESC, `round` DESC LIMIT {1}", (int)type, 80);
                    MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false);
                    while (sdr != null && sdr.Read())
                    {
                        BangHuiMatchPKInfo pkInfo = new BangHuiMatchPKInfo();
                        pkInfo.type    = Convert.ToByte(sdr["type"]);
                        pkInfo.season  = Convert.ToInt32(sdr["season"]);
                        pkInfo.round   = Convert.ToByte(sdr["round"]);
                        pkInfo.bhid1   = Convert.ToInt32(sdr["bhid1"]);
                        pkInfo.bhid2   = Convert.ToInt32(sdr["bhid2"]);
                        pkInfo.result  = Convert.ToByte(sdr["result"]);
                        pkInfo.zoneid1 = Convert.ToInt32(sdr["zoneid1"]);
                        pkInfo.zoneid2 = Convert.ToInt32(sdr["zoneid2"]);
                        if (this.BHMatchBHDataDict_Gold.TryGetValue(pkInfo.bhid1, out bhData))
                        {
                            pkInfo.bhname1 = KuaFuServerManager.FormatName(bhData.V.zoneid_bh, bhData.V.bhname);
                        }
                        if (this.BHMatchBHDataDict_Gold.TryGetValue(pkInfo.bhid2, out bhData))
                        {
                            pkInfo.bhname2 = KuaFuServerManager.FormatName(bhData.V.zoneid_bh, bhData.V.bhname);
                        }
                        BHMatchPKInfoList_Gold.V.Add(pkInfo);
                    }
                    TimeUtil.AgeByNow(ref BHMatchPKInfoList_Gold.Age);
                    if (sdr != null)
                    {
                        sdr.Close();
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                    return(false);
                }
                result = true;
            }
            return(result);
        }
Пример #12
0
        public void InitConfig()
        {
            bool bOk = _Config.Load(
                KuaFuServerManager.GetResourcePath(ZhengBaConsts.MatchConfigFile, KuaFuServerManager.ResourcePathTypes.GameRes),
                KuaFuServerManager.GetResourcePath(ZhengBaConsts.SupportConfigFile, KuaFuServerManager.ResourcePathTypes.GameRes),
                KuaFuServerManager.GetResourcePath(ZhengBaConsts.BirthPointConfigFile, KuaFuServerManager.ResourcePathTypes.GameRes)
                );

            if (!bOk)
            {
                LogManager.WriteLog(LogTypes.Error, "ZhengBaManagerK.InitConfig failed!");
            }
        }
Пример #13
0
 public void StartUp()
 {
     try
     {
         this._Config.Load(KuaFuServerManager.GetResourcePath(CoupleWishConsts.RankAwardCfgFile, KuaFuServerManager.ResourcePathTypes.GameRes), KuaFuServerManager.GetResourcePath(CoupleWishConsts.WishTypeCfgFile, KuaFuServerManager.ResourcePathTypes.GameRes), KuaFuServerManager.GetResourcePath(CoupleWishConsts.YanHuiCfgFile, KuaFuServerManager.ResourcePathTypes.GameRes));
         this.ReloadSyncData();
         this.WishRecordMgr = new CoupleWishRecordManager(this.SyncData.ThisWeek.Week);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Error, "CoupleWishService.StartUp failed!", ex, true);
     }
 }
Пример #14
0
 public void InitConfig()
 {
     try
     {
         lock (this.Mutex)
         {
             string fileName         = "Config/TeQuanTiaoJian.xml";
             string fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
             this.SpecPConditionList.Clear();
             XElement xml = ConfigHelper.Load(fullPathFileName);
             IEnumerable <XElement> xmlItems = xml.Elements();
             foreach (XElement xmlItem in xmlItems)
             {
                 SpecPConditionConfig myData = new SpecPConditionConfig();
                 myData.GroupID = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L);
                 string FromDate = ConfigHelper.GetElementAttributeValue(xmlItem, "KaiQiShiJian", "");
                 if (!string.IsNullOrEmpty(FromDate))
                 {
                     myData.FromDate = DateTime.Parse(FromDate);
                 }
                 else
                 {
                     myData.FromDate = DateTime.Parse("2008-08-08 08:08:08");
                 }
                 string ToDate = ConfigHelper.GetElementAttributeValue(xmlItem, "JieShuShiJian", "");
                 if (!string.IsNullOrEmpty(ToDate))
                 {
                     myData.ToDate = DateTime.Parse(ToDate);
                 }
                 else
                 {
                     myData.ToDate = DateTime.Parse("2028-08-08 08:08:08");
                 }
                 myData.ConditionType = (SpecPConditionType)ConfigHelper.GetElementAttributeValueLong(xmlItem, "TiaoJianLeiXing", 0L);
                 this.SpecPConditionList.Add(myData);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
     }
 }
Пример #15
0
        public void ChangeName(int ptId, int roleId, string roleName)
        {
            try
            {
                lock (this.Mutex)
                {
                    KeyValuePair <int, int>      key = new KeyValuePair <int, int>(ptId, roleId);
                    KuaFuData <KFRebornRoleData> kfRebornRoleData = null;
                    if (this.RebornRoleDataDict.TryGetValue(key, out kfRebornRoleData))
                    {
                        kfRebornRoleData.V.RoleName = roleName;
                        TimeUtil.AgeByNow(ref kfRebornRoleData.Age);
                        this.Persistence.UpdateRebornRoleDataRoleName(kfRebornRoleData.V);
                        bool refreshRank = false;
                        foreach (KeyValuePair <int, List <KFRebornRankInfo> > kvp in this.RebornRankDict.V)
                        {
                            KFRebornRankInfo item = kvp.Value.Find((KFRebornRankInfo x) => x.PtID == ptId && x.Key == roleId);
                            if (null != item)
                            {
                                string             worldRoleID   = ConstData.FormatWorldRoleID(roleId, ptId);
                                KuaFuWorldRoleData worldRoleData = TSingleton <KuaFuWorldManager> .getInstance().LoadKuaFuWorldRoleData(roleId, ptId, worldRoleID);

                                if (null != worldRoleData)
                                {
                                    item.Param1 = KuaFuServerManager.FormatName(item.tagInfo.V.RoleName, worldRoleData.ZoneID);
                                    refreshRank = true;
                                }
                            }
                        }
                        if (refreshRank)
                        {
                            TimeUtil.AgeByNow(ref this.RebornRankDict.Age);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteException(ex.ToString());
            }
        }
Пример #16
0
 public bool LoadZorkBattleRankInfo(int rankType, List <KFZorkRankInfo> rankList)
 {
     try
     {
         string strSql = this.FormatLoadZorkBattleRankSql(rankType);
         if (string.IsNullOrEmpty(strSql))
         {
             return(false);
         }
         MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false);
         while (sdr != null && sdr.Read())
         {
             KFZorkRankInfo rankInfo = new KFZorkRankInfo();
             rankInfo.Key   = Convert.ToInt32(sdr["a"]);
             rankInfo.Value = Convert.ToInt32(sdr["b"]);
             if (rankType == 1)
             {
                 string   strParam = string.Format("SELECT zoneid,rname,rebornlev FROM `t_kf_5v5_zhandui_roles` WHERE rid={0};", rankInfo.Key);
                 object[] arr;
                 if (DbHelperMySQL.GetSingleValues(strParam, out arr) >= 0)
                 {
                     rankInfo.StrParam1 = KuaFuServerManager.FormatName(Convert.ToInt32(arr[0]), arr[1].ToString());
                     rankInfo.Param1    = Convert.ToInt32(arr[2]);
                 }
                 rankList.Add(rankInfo);
             }
         }
         if (sdr != null)
         {
             sdr.Close();
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
         return(false);
     }
     return(true);
 }
Пример #17
0
        public int CheckEnterWorldKuaFuSign(string worldRoleID, string token, out string signKey, out string[] ips, out int[] ports)
        {
            int result = -100;

            signKey = null;
            ips     = null;
            ports   = null;
            long utcTicks = TimeUtil.UTCTicks();

            lock (this.Mutex)
            {
                KuaFuServerLoginData data;
                if (this.WorldRoleIDDict.TryGetValue(worldRoleID, out data) && token == data.SignToken)
                {
                    if (utcTicks > data.EndTicks)
                    {
                        return(result);
                    }
                    result  = 0;
                    signKey = data.SignKey;
                }
                KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(data.ServerId);
                if (null != serverInfo)
                {
                    ips = new string[]
                    {
                        serverInfo.DbIp,
                        serverInfo.DbIp
                    };
                    ports = new int[]
                    {
                        serverInfo.DbPort,
                        serverInfo.LogDbPort
                    };
                }
            }
            return(result);
        }
Пример #18
0
        public bool SpecialKfFuben(GameTypes gameType, long gameId, int roleNum, out int kfSrvId)
        {
            kfSrvId = 0;
            ClientAgent assignAgent = null;
            int         serverId    = KuaFuServerManager.GetSpecialLineId(gameType);
            bool        result;

            if (serverId <= 0)
            {
                kfSrvId = -3;
                result  = false;
            }
            else
            {
                lock (this.Mutex)
                {
                    ClientAgent agent = null;
                    if (this.ServerId2ClientAgent.TryGetValue(serverId, out agent) && agent.IsAlive)
                    {
                        assignAgent = agent;
                    }
                    else
                    {
                        kfSrvId = -100;
                    }
                    if (assignAgent != null)
                    {
                        assignAgent.AssginKfFuben(gameType, gameId, roleNum);
                        kfSrvId = assignAgent.ClientInfo.ServerId;
                        return(true);
                    }
                }
                result = false;
            }
            return(result);
        }
Пример #19
0
 public void PlatFormChat(int serverId, byte[] bytes)
 {
     try
     {
         AsyncDataItem evItem = new AsyncDataItem(KuaFuEventTypes.PlatFormChat, new object[]
         {
             bytes
         });
         HashSet <int> SpecialLineSet = new HashSet <int>();
         lock (this.Mutex)
         {
             foreach (KeyValuePair <int, List <RebornBossConfig> > item in this.RebornBossConfigDict)
             {
                 List <KuaFuLineData> lineList = KuaFuServerManager.GetKuaFuLineDataList(item.Key);
                 if (null != lineList)
                 {
                     foreach (KuaFuLineData line in lineList)
                     {
                         SpecialLineSet.Add(line.ServerId);
                     }
                 }
             }
         }
         foreach (int lineServerId in SpecialLineSet)
         {
             if (serverId != lineServerId)
             {
                 ClientAgentManager.Instance().PostAsyncEvent(lineServerId, this.EvItemGameType, evItem);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteException(ex.ToString());
     }
 }
Пример #20
0
 public List <KuaFuServerInfo> GetKuaFuServerInfoData(int age)
 {
     return(KuaFuServerManager.GetKuaFuServerInfoData(age));
 }
Пример #21
0
        public bool LoadRebornRankInfo(int rankType, KuaFuData <Dictionary <int, List <KFRebornRankInfo> > > RebornRankDict)
        {
            bool result;

            if (null == RebornRankDict)
            {
                result = false;
            }
            else
            {
                List <KFRebornRankInfo> rankList = null;
                if (!RebornRankDict.V.TryGetValue(rankType, out rankList))
                {
                    rankList = (RebornRankDict.V[rankType] = new List <KFRebornRankInfo>());
                }
                else
                {
                    rankList.Clear();
                }
                try
                {
                    string strSql = this.FormatLoadRebornRankSql(rankType);
                    if (string.IsNullOrEmpty(strSql))
                    {
                        return(false);
                    }
                    MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false);
                    while (sdr != null && sdr.Read())
                    {
                        KFRebornRankInfo rankInfo = new KFRebornRankInfo();
                        rankInfo.Key   = Convert.ToInt32(sdr["a"]);
                        rankInfo.Value = Convert.ToInt32(sdr["b"]);
                        rankInfo.PtID  = Convert.ToInt32(sdr["c"]);
                        KuaFuData <KFRebornRoleData> kfRoleData = null;
                        if (this.RebornRoleDataDict.TryGetValue(new KeyValuePair <int, int>(rankInfo.PtID, rankInfo.Key), out kfRoleData))
                        {
                            string             worldRoleID   = ConstData.FormatWorldRoleID(rankInfo.Key, rankInfo.PtID);
                            KuaFuWorldRoleData worldRoleData = TSingleton <KuaFuWorldManager> .getInstance().LoadKuaFuWorldRoleData(rankInfo.Key, rankInfo.PtID, worldRoleID);

                            if (null != worldRoleData)
                            {
                                int KFZoneID = ConstData.ConvertToKuaFuServerID(worldRoleData.ZoneID, worldRoleData.PTID);
                                rankInfo.Param1  = KuaFuServerManager.FormatName(kfRoleData.V.RoleName, KFZoneID);
                                rankInfo.Param2  = worldRoleData.Channel;
                                rankInfo.UserID  = worldRoleData.UserID;
                                rankInfo.tagInfo = kfRoleData;
                            }
                        }
                        rankList.Add(rankInfo);
                    }
                    if (null != RebornRankDict)
                    {
                        TimeUtil.AgeByNow(ref RebornRankDict.Age);
                    }
                    if (sdr != null)
                    {
                        sdr.Close();
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                    return(false);
                }
                result = true;
            }
            return(result);
        }
Пример #22
0
        public void StartUp()
        {
            try
            {
                XElement xml  = null;
                string   file = "";

                file = @"Config\CoupleWar.xml";
                xml  = XElement.Load(KuaFuServerManager.GetResourcePath(file, KuaFuServerManager.ResourcePathTypes.GameRes));
                foreach (var xmlItem in xml.Elements())
                {
                    string[] fields = xmlItem.Attribute("TimePoints").Value.Split(new char[] { ',', '-', '|' });
                    for (int i = 0; i < fields.Length; i += 3)
                    {
                        var tp = new _CoupleArenaWarTimePoint();
                        tp.Weekday = Convert.ToInt32(fields[i]);
                        if (tp.Weekday < 1 || tp.Weekday > 7)
                        {
                            throw new Exception("weekday error!");
                        }
                        tp.DayStartTicks = DateTime.Parse(fields[i + 1]).TimeOfDay.Ticks;
                        tp.DayEndTicks   = DateTime.Parse(fields[i + 2]).TimeOfDay.Ticks;

                        _WarTimePointList.Add(tp);
                    }

                    _WarTimePointList.Sort((_l, _r) => { return(_l.Weekday - _r.Weekday); });

                    break;
                }

                file = @"Config\CoupleDuanWei.xml";
                xml  = XElement.Load(KuaFuServerManager.GetResourcePath(file, KuaFuServerManager.ResourcePathTypes.GameRes));
                foreach (var xmlItem in xml.Elements())
                {
                    var cfg = new _CoupleArenaDuanWeiCfg();
                    cfg.NeedJiFen    = Convert.ToInt32(xmlItem.Attribute("NeedCoupleDuanWeiJiFen").Value.ToString());
                    cfg.DuanWeiType  = Convert.ToInt32(xmlItem.Attribute("Type").Value.ToString());
                    cfg.DuanWeiLevel = Convert.ToInt32(xmlItem.Attribute("Level").Value.ToString());
                    cfg.WinJiFen     = Convert.ToInt32(xmlItem.Attribute("WinJiFen").Value.ToString());
                    cfg.LoseJiFen    = Convert.ToInt32(xmlItem.Attribute("LoseJiFen").Value.ToString());

                    _DuanWeiCfgList.Add(cfg);
                }
                _DuanWeiCfgList.Sort((_l, _r) => { return(_l.NeedJiFen - _r.NeedJiFen); });

                DateTime now = TimeUtil.NowDateTime();
                Persistence.CheckClearRank(CurrRankWeek(now));
                SyncData.RankList = Persistence.LoadRankFromDb();
                SyncData.BuildRoleDict();
                SyncData.ModifyTime = now;

                this.IsNeedSort = false;
                for (int i = 1; i < SyncData.RankList.Count && !this.IsNeedSort; i++)
                {
                    this.IsNeedSort |= SyncData.RankList[i].CompareTo(SyncData.RankList[i - 1]) < 0;
                    this.IsNeedSort |= this.SyncData.RankList[i].Rank != this.SyncData.RankList[i - 1].Rank + 1;
                }

                CheckRebuildRank(now);
                CheckFlushRank2Db();
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, "CoupleArenaService.InitConfig failed!", ex);
            }
        }
Пример #23
0
        public int InitializeClient(KuaFuClientContext clientInfo, out bool bFistInit)
        {
            bFistInit = false;
            if (KuaFuServerManager.LimitIP)
            {
                bool            denied     = true;
                KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(clientInfo.ServerId);
                if (null == serverInfo)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("非法连接,无效的服务器编号#serverid={0},ip={1},gametype={2}", clientInfo.ServerId, clientInfo.Token, (GameTypes)clientInfo.GameType), null, true);
                    return(-1);
                }
                if (serverInfo != null && !string.IsNullOrEmpty(clientInfo.Token))
                {
                    if (!string.IsNullOrEmpty(serverInfo.LanIp) && clientInfo.Token.Contains(serverInfo.LanIp))
                    {
                        denied = false;
                    }
                    else if (clientInfo.Token.Contains(serverInfo.Ip))
                    {
                        denied = false;
                    }
                }
                if (denied)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("非法连接#serverid={0},ip={1},ip={2},lanip={3},gametype={4}", new object[]
                    {
                        clientInfo.ServerId,
                        clientInfo.Token,
                        serverInfo.Ip,
                        serverInfo.LanIp,
                        (GameTypes)clientInfo.GameType
                    }), null, true);
                    return(-1);
                }
            }
            int clientId;

            lock (this.Mutex)
            {
                ClientAgent agent = null;
                if (!this.ServerId2ClientAgent.TryGetValue(clientInfo.ServerId, out agent))
                {
                    LogManager.WriteLog(LogTypes.Info, string.Format("InitializeClient服务器连接1.ServerId:{0},ClientId:{1},info:{2},GameType:{3} [Service首次连接过来]", new object[]
                    {
                        clientInfo.ServerId,
                        clientInfo.ClientId,
                        clientInfo.Token,
                        (GameTypes)clientInfo.GameType
                    }), null, true);
                    bFistInit           = true;
                    clientInfo.ClientId = KuaFuServerManager.GetUniqueClientId();
                    agent = new ClientAgent(clientInfo);
                    this.ServerId2ClientAgent[clientInfo.ServerId] = agent;
                }
                else if (clientInfo.Token != agent.ClientInfo.Token)
                {
                    if (clientInfo.ClientId == agent.ClientInfo.ClientId)
                    {
                        LogManager.WriteLog(LogTypes.Info, string.Format("InitializeClient服务器IP变化.ServerId:{0},ClientId:{1},info:{2},GameType:{3}", new object[]
                        {
                            clientInfo.ServerId,
                            clientInfo.ClientId,
                            clientInfo.Token,
                            (GameTypes)clientInfo.GameType
                        }), null, true);
                    }
                    else
                    {
                        if (agent.IsAlive)
                        {
                            LogManager.WriteLog(LogTypes.Info, string.Format("InitializeClient服务器ID重复,禁止连接.ServerId:{0},ClientId:{1},info:{2},GameType:{3}", new object[]
                            {
                                clientInfo.ServerId,
                                clientInfo.ClientId,
                                clientInfo.Token,
                                (GameTypes)clientInfo.GameType
                            }), null, true);
                            return(-11002);
                        }
                        bFistInit           = true;
                        clientInfo.ClientId = KuaFuServerManager.GetUniqueClientId();
                        agent.Reset(clientInfo);
                        LogManager.WriteLog(LogTypes.Info, string.Format("InitializeClient服务器IP变化.ServerId:{0},ClientId:{1},info:{2},GameType:{3}", new object[]
                        {
                            clientInfo.ServerId,
                            clientInfo.ClientId,
                            clientInfo.Token,
                            (GameTypes)clientInfo.GameType
                        }), null, true);
                    }
                }
                else if (clientInfo.ClientId != agent.ClientInfo.ClientId)
                {
                    if (clientInfo.ClientId <= 0)
                    {
                        clientInfo.ClientId = agent.ClientInfo.ClientId;
                        agent.Reset(clientInfo);
                        LogManager.WriteLog(LogTypes.Info, string.Format("InitializeClient服务器重连.ServerId:{0},ClientId:{1},info:{2},GameType:{3} [首次连接过来]", new object[]
                        {
                            clientInfo.ServerId,
                            clientInfo.ClientId,
                            clientInfo.Token,
                            (GameTypes)clientInfo.GameType
                        }), null, true);
                    }
                    else
                    {
                        LogManager.WriteLog(LogTypes.Info, string.Format("InitializeClient服务器重连.ServerId:{0},ClientId:{1},info:{2},GameType:{3} [非首次连接过来]", new object[]
                        {
                            clientInfo.ServerId,
                            clientInfo.ClientId,
                            clientInfo.Token,
                            (GameTypes)clientInfo.GameType
                        }), null, true);
                    }
                }
                else if (!Global.TestMode && !agent.IsAlive)
                {
                    LogManager.WriteLog(LogTypes.Info, string.Format("InitializeClient服务器连接和上次心跳时间间隔过长.ServerId:{0},ClientId:{1},info:{2},GameType:{3},time={4}", new object[]
                    {
                        clientInfo.ServerId,
                        clientInfo.ClientId,
                        clientInfo.Token,
                        (GameTypes)clientInfo.GameType,
                        agent.DeltaTime
                    }), null, true);
                }
                if (agent != null)
                {
                    clientInfo.ClientId = agent.ClientInfo.ClientId;
                    agent.ClientHeartTick();
                    agent.TryInitGameType(clientInfo.GameType);
                }
                clientId = clientInfo.ClientId;
            }
            return(clientId);
        }
Пример #24
0
 public void StartUp()
 {
     try
     {
         int  num;
         bool flag;
         IEnumerator <XElement> objA = XElement.Load(KuaFuServerManager.GetResourcePath(@"Config\CoupleWar.xml", KuaFuServerManager.ResourcePathTypes.GameRes)).Elements().GetEnumerator();
         try
         {
             flag = objA.MoveNext();
             if (flag)
             {
                 string[] strArray = objA.Current.Attribute("TimePoints").Value.Split(new char[] { ',', '-', '|' });
                 num = 0;
                 while (true)
                 {
                     flag = num < strArray.Length;
                     if (!flag)
                     {
                         this._WarTimePointList.Sort((_l, _r) => _l.Weekday - _r.Weekday);
                         break;
                     }
                     _CoupleArenaWarTimePoint item = new _CoupleArenaWarTimePoint
                     {
                         Weekday = Convert.ToInt32(strArray[num])
                     };
                     if ((item.Weekday < 1) || (item.Weekday > 7))
                     {
                         throw new Exception("weekday error!");
                     }
                     item.DayStartTicks = DateTime.Parse(strArray[num + 1]).TimeOfDay.Ticks;
                     item.DayEndTicks   = DateTime.Parse(strArray[num + 2]).TimeOfDay.Ticks;
                     this._WarTimePointList.Add(item);
                     num += 3;
                 }
             }
         }
         finally
         {
             if (!ReferenceEquals(objA, null))
             {
                 objA.Dispose();
             }
         }
         objA = XElement.Load(KuaFuServerManager.GetResourcePath(@"Config\CoupleDuanWei.xml", KuaFuServerManager.ResourcePathTypes.GameRes)).Elements().GetEnumerator();
         try
         {
             while (true)
             {
                 flag = objA.MoveNext();
                 if (!flag)
                 {
                     break;
                 }
                 XElement current            = objA.Current;
                 _CoupleArenaDuanWeiCfg item = new _CoupleArenaDuanWeiCfg
                 {
                     NeedJiFen    = Convert.ToInt32(current.Attribute("NeedCoupleDuanWeiJiFen").Value.ToString()),
                     DuanWeiType  = Convert.ToInt32(current.Attribute("Type").Value.ToString()),
                     DuanWeiLevel = Convert.ToInt32(current.Attribute("Level").Value.ToString()),
                     WinJiFen     = Convert.ToInt32(current.Attribute("WinJiFen").Value.ToString()),
                     LoseJiFen    = Convert.ToInt32(current.Attribute("LoseJiFen").Value.ToString())
                 };
                 this._DuanWeiCfgList.Add(item);
             }
         }
         finally
         {
             if (!ReferenceEquals(objA, null))
             {
                 objA.Dispose();
             }
         }
         this._DuanWeiCfgList.Sort((_l, _r) => _l.NeedJiFen - _r.NeedJiFen);
         DateTime time = TimeUtil.NowDateTime();
         this.Persistence.CheckClearRank(this.CurrRankWeek(time));
         this.SyncData.RankList = this.Persistence.LoadRankFromDb();
         this.SyncData.BuildRoleDict();
         this.SyncData.ModifyTime = time;
         this.IsNeedSort          = false;
         num = 1;
         while (true)
         {
             flag = (num < this.SyncData.RankList.Count) && !this.IsNeedSort;
             if (!flag)
             {
                 this.CheckRebuildRank(time);
                 this.CheckFlushRank2Db();
                 break;
             }
             this.IsNeedSort |= this.SyncData.RankList[num].CompareTo(this.SyncData.RankList[num - 1]) < 0;
             this.IsNeedSort |= this.SyncData.RankList[num].Rank != (this.SyncData.RankList[num - 1].Rank + 1);
             num++;
         }
     }
     catch (Exception exception)
     {
         LogManager.WriteLog(LogTypes.Error, "CoupleArenaService.InitConfig failed!", exception, true);
     }
 }
Пример #25
0
        private bool LoadKuaFuLueDuoRankInfo(int rankType, int minSeasonID, int seasonLast, Dictionary <int, KuaFuLueDuoRankListData> KuaFuLueDuoRankInfoDict)
        {
            try
            {
                long sAge   = TimeUtil.AgeByNow();
                int  length = this.ZoneID2GroupIDs.Length;
                KuaFuLueDuoRankListData[]    rankArr = new KuaFuLueDuoRankListData[length];
                List <KuaFuLueDuoRankInfo>[] listArr = new List <KuaFuLueDuoRankInfo> [length];
                for (int i = 0; i < this.ZoneID2GroupIDs.Length; i++)
                {
                    int groupID = this.ZoneID2GroupIDs[i];
                    KuaFuLueDuoRankListData rankData;
                    if (!KuaFuLueDuoRankInfoDict.TryGetValue(groupID, out rankData))
                    {
                        rankData = new KuaFuLueDuoRankListData
                        {
                            Age = sAge
                        };
                        rankData.LastInfoDict            = new Dictionary <int, KuaFuLueDuoRankInfo>();
                        rankData.SelfInfoDict            = new Dictionary <int, KuaFuLueDuoRankInfo>();
                        KuaFuLueDuoRankInfoDict[groupID] = rankData;
                    }
                    List <KuaFuLueDuoRankInfo> rankList;
                    if (!rankData.ListDict.TryGetValue(rankType, out rankList))
                    {
                        rankList = new List <KuaFuLueDuoRankInfo>();
                        rankData.ListDict[rankType] = rankList;
                    }
                    rankArr[i] = rankData;
                    listArr[i] = rankList;
                }
                string strSql = this.FormatLoadKuaFuLueDuoRankSql(rankType, minSeasonID, seasonLast);
                if (!string.IsNullOrEmpty(strSql))
                {
                    int rank = 0;
                    using (MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false))
                    {
                        while (sdr != null && sdr.Read())
                        {
                            int zoneID = Convert.ToInt32(sdr[3]);
                            if (zoneID < length)
                            {
                                rank++;
                                KuaFuLueDuoRankListData rankData = rankArr[zoneID];
                                KuaFuLueDuoRankInfo     rankInfo = new KuaFuLueDuoRankInfo();
                                int zoneId = Convert.ToInt32(sdr[3]);
                                rankInfo.Key    = Convert.ToInt32(sdr[0]);
                                rankInfo.Value  = Convert.ToInt32(sdr[1]);
                                rankInfo.Param1 = sdr[2].ToString();
                                switch (rankType)
                                {
                                case 0:
                                    listArr[zoneID].Add(rankInfo);
                                    if (rank == 1)
                                    {
                                        rankData.LastInfoDict[0] = rankInfo;
                                    }
                                    break;

                                case 2:
                                case 4:
                                    rankInfo.Param1 = KuaFuServerManager.FormatName(rankInfo.Param1, zoneId);
                                    listArr[zoneID].Add(rankInfo);
                                    break;

                                case 3:
                                case 5:
                                    rankInfo.Param1 = KuaFuServerManager.FormatName(rankInfo.Param1, zoneId);
                                    rankData.LastInfoDict[rankType - 1] = rankInfo;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteExceptionUseCache(ex.ToString());
                return(false);
            }
            return(true);
        }
Пример #26
0
        private bool LoadBHMatchRankInfo(int rankType, int seasonCur, int seasonLast, KuaFuData <Dictionary <int, List <BangHuiMatchRankInfo> > > BHMatchRankInfoDict)
        {
            bool result;

            if (null == BHMatchRankInfoDict)
            {
                result = false;
            }
            else
            {
                List <BangHuiMatchRankInfo> rankList = null;
                if (!BHMatchRankInfoDict.V.TryGetValue(rankType, out rankList))
                {
                    rankList = (BHMatchRankInfoDict.V[rankType] = new List <BangHuiMatchRankInfo>());
                }
                else
                {
                    rankList.Clear();
                }
                try
                {
                    string strSql = this.FormatLoadBHMatchRankSql(rankType, seasonCur, seasonLast);
                    if (string.IsNullOrEmpty(strSql))
                    {
                        return(false);
                    }
                    MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false);
                    while (sdr != null && sdr.Read())
                    {
                        BangHuiMatchRankInfo rankInfo = new BangHuiMatchRankInfo();
                        rankInfo.Key   = Convert.ToInt32(sdr["a"]);
                        rankInfo.Value = Convert.ToInt32(sdr["b"]);
                        switch (rankType)
                        {
                        case 4:
                        case 6:
                        case 10:
                        case 12:
                        {
                            string   strParam = string.Format("SELECT zoneid,rname FROM t_banghui_match_roles WHERE `type`={0} AND rid={1};", 1, rankInfo.Key);
                            object[] arr;
                            if (DbHelperMySQL.GetSingleValues(strParam, out arr) >= 0)
                            {
                                rankInfo.Param1 = KuaFuServerManager.FormatName(Convert.ToInt32(arr[0]), arr[1].ToString());
                            }
                            string strParam2 = string.Format("SELECT zoneid_bh,bhname FROM t_banghui_match_bh, \r\n                                                (SELECT bhid FROM t_banghui_match_roles WHERE `type`={0} AND rid={1}) a1 WHERE t_banghui_match_bh.bhid = a1.bhid;", 1, rankInfo.Key);
                            if (DbHelperMySQL.GetSingleValues(strParam2, out arr) >= 0)
                            {
                                rankInfo.Param2 = KuaFuServerManager.FormatName(Convert.ToInt32(arr[0]), arr[1].ToString());
                            }
                            rankList.Add(rankInfo);
                            break;
                        }

                        case 5:
                        case 7:
                        case 11:
                        case 13:
                        {
                            string strParam = string.Format("SELECT zoneid,rname FROM t_banghui_match_roles WHERE `type`={0} AND rid={1};", 2, rankInfo.Key);
                            rankInfo.Param1 = Convert.ToString(DbHelperMySQL.GetSingle(strParam));
                            object[] arr;
                            if (DbHelperMySQL.GetSingleValues(strParam, out arr) >= 0)
                            {
                                rankInfo.Param1 = KuaFuServerManager.FormatName(Convert.ToInt32(arr[0]), arr[1].ToString());
                            }
                            string strParam2 = string.Format("SELECT zoneid_bh,bhname FROM t_banghui_match_bh, \r\n                                                (SELECT bhid FROM t_banghui_match_roles WHERE `type`={0} AND rid={1}) a1 WHERE t_banghui_match_bh.bhid = a1.bhid;", 2, rankInfo.Key);
                            if (DbHelperMySQL.GetSingleValues(strParam2, out arr) >= 0)
                            {
                                rankInfo.Param2 = KuaFuServerManager.FormatName(Convert.ToInt32(arr[0]), arr[1].ToString());
                            }
                            rankList.Add(rankInfo);
                            break;
                        }

                        case 8:
                        case 9:
                            goto IL_24B;

                        default:
                            goto IL_24B;
                        }
                        continue;
IL_24B:
                        KuaFuData <BHMatchBHData> bhData = null;
                        if (this.BHMatchBHDataDict_Gold.TryGetValue(rankInfo.Key, out bhData))
                        {
                            rankInfo.Param1 = KuaFuServerManager.FormatName(bhData.V.zoneid_bh, bhData.V.bhname);
                            rankInfo.Param2 = KuaFuServerManager.FormatName(bhData.V.zoneid_r, bhData.V.rname);
                            rankList.Add(rankInfo);
                        }
                        else if (this.BHMatchBHDataDict_Rookie.TryGetValue(rankInfo.Key, out bhData))
                        {
                            rankInfo.Param1 = KuaFuServerManager.FormatName(bhData.V.zoneid_bh, bhData.V.bhname);
                            rankInfo.Param2 = KuaFuServerManager.FormatName(bhData.V.zoneid_r, bhData.V.rname);
                            rankList.Add(rankInfo);
                        }
                    }
                    TimeUtil.AgeByNow(ref BHMatchRankInfoDict.Age);
                    if (sdr != null)
                    {
                        sdr.Close();
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                    return(false);
                }
                result = true;
            }
            return(result);
        }
Пример #27
0
 public bool LoadConfig()
 {
     try
     {
         this.Initialiazed = false;
         XElement xml = ConfigHelper.Load(KuaFuServerManager.GetResourcePath("Config/JieRiGifts/JieRiChongZhiHongBao.xml", KuaFuServerManager.ResourcePathTypes.GameRes));
         if (null == xml)
         {
             return(false);
         }
         lock (this.Mutex)
         {
             this.ConfigDict.Clear();
             XElement args = xml.Element("Activities");
             if (null != args)
             {
                 this.FromDate       = ConfigHelper.GetElementAttributeValue(args, "FromDate", "");
                 this.ToDate         = ConfigHelper.GetElementAttributeValue(args, "ToDate", "");
                 this.ActivityType   = (int)ConfigHelper.GetElementAttributeValueLong(args, "ActivityType", 0L);
                 this.AwardStartDate = ConfigHelper.GetElementAttributeValue(args, "AwardStartDate", "");
                 this.AwardEndDate   = ConfigHelper.GetElementAttributeValue(args, "AwardEndDate", "");
                 this.StartTime      = DateTime.Parse(this.FromDate);
                 this.EndTime        = DateTime.Parse(this.ToDate);
                 this.ActivityKeyStr = string.Format("{0}_{1}", this.FromDate, this.ToDate).Replace(':', '$');
             }
             else
             {
                 this.ActivityKeyStr = "";
                 this.StartTime      = (this.EndTime = DateTime.MinValue);
             }
             this.HuoDongStartTicks = this.StartTime.Ticks / 10000000L * 1000L;
             args = xml.Element("GiftList");
             if (null != args)
             {
                 IEnumerable <XElement> xmlItems = args.Elements();
                 foreach (XElement xmlItem in xmlItems)
                 {
                     if (null != xmlItem)
                     {
                         JieRiChongZhiHongBaoInfo item = new JieRiChongZhiHongBaoInfo();
                         item.ID = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L);
                         item.RechargeDifference = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "RechargeDifference", 0L);
                         item.PlatformID         = ConfigHelper.GetElementAttributeValue(xmlItem, "PlatformID", "");
                         item.RedPacketSize      = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "RedPacketSize", 0L);
                         item.Interval           = ConfigHelper.String2IntArray(ConfigHelper.GetElementAttributeValue(xmlItem, "Interval", ""), ',');
                         item.DurationTime       = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "DurationTime", 0L);
                         if (string.Compare(item.PlatformID, KuaFuServerManager.platformType.ToString(), true) == 0)
                         {
                             this.ConfigDict.Add(item.ID, item);
                         }
                     }
                 }
             }
         }
         this.Initialiazed = this.InitData();
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Fatal, string.Format("{0}解析出现异常, {1}", "Config/JieRiGifts/JieRiChongZhiHongBao.xml", ex.Message), null, true);
         return(false);
     }
     return(true);
 }
Пример #28
0
        public int EnterPTKuaFuMap(int serverID, int roleId, int ptid, int mapCode, int kuaFuLine, out string signToken, out string signKey, out int kuaFuServerID, out string[] ips, out int[] ports)
        {
            ips           = null;
            ports         = null;
            signToken     = null;
            signKey       = null;
            kuaFuServerID = 0;
            string             worldRoleID = ConstData.FormatWorldRoleID(roleId, ptid);
            KuaFuWorldRoleData roleData    = this.LoadKuaFuWorldRoleData(roleId, ptid, worldRoleID);
            int result;

            if (null == roleData)
            {
                result = -4010;
            }
            else
            {
                kuaFuServerID = KuaFuServerManager.EnterKuaFuMapLine(kuaFuLine, mapCode);
                if (kuaFuServerID <= 0)
                {
                    result = -100;
                }
                else
                {
                    KuaFuServerInfo serverInfo = KuaFuServerManager.GetKuaFuServerInfo(kuaFuServerID);
                    if (null != serverInfo)
                    {
                        ips = new string[]
                        {
                            serverInfo.Ip
                        };
                        ports = new int[]
                        {
                            serverInfo.Port
                        };
                    }
                    signToken = Guid.NewGuid().ToString("N");
                    signKey   = Guid.NewGuid().ToString("N");
                    long utcTicks = TimeUtil.UTCTicks();
                    lock (this.Mutex)
                    {
                        KuaFuServerLoginData loginData;
                        if (!this.WorldRoleIDDict.TryGetValue(worldRoleID, out loginData))
                        {
                            loginData            = new KuaFuServerLoginData();
                            loginData.TempRoleID = roleData.TempRoleID;
                            this.WorldRoleIDDict[worldRoleID] = loginData;
                        }
                        loginData.SignKey        = signKey;
                        loginData.SignToken      = signToken;
                        loginData.EndTicks       = utcTicks + 86400000L;
                        loginData.TargetServerID = kuaFuServerID;
                        loginData.ServerId       = ConstData.ConvertToKuaFuServerID(serverID, ptid);
                        loginData.RoleId         = roleId;
                        loginData.PTID           = ptid;
                        loginData.GameId         = (long)mapCode;
                        result = loginData.TempRoleID;
                    }
                }
            }
            return(result);
        }
Пример #29
0
        public bool LoadCompRankInfo(int rankType, int compType, KuaFuData <Dictionary <int, List <KFCompRankInfo> > > CompRankDict, KuaFuData <List <KFCompRankInfo> > CompRankList)
        {
            bool result;

            if (CompRankDict == null && null == CompRankList)
            {
                result = false;
            }
            else
            {
                List <KFCompRankInfo> rankList = null;
                if (null != CompRankDict)
                {
                    if (!CompRankDict.V.TryGetValue(compType, out rankList))
                    {
                        rankList = (CompRankDict.V[compType] = new List <KFCompRankInfo>());
                    }
                    else
                    {
                        rankList.Clear();
                    }
                }
                else
                {
                    rankList = CompRankList.V;
                    rankList.Clear();
                }
                try
                {
                    string strSql = this.FormatLoadCompRankSql(rankType, compType);
                    if (string.IsNullOrEmpty(strSql))
                    {
                        return(false);
                    }
                    if (rankType == 3)
                    {
                        for (int i = 1; i <= 3; i++)
                        {
                            rankList.Add(new KFCompRankInfo());
                        }
                    }
                    MySqlDataReader sdr = DbHelperMySQL.ExecuteReader(strSql, false);
                    while (sdr != null && sdr.Read())
                    {
                        KFCompRankInfo rankInfo = new KFCompRankInfo();
                        rankInfo.Key   = Convert.ToInt32(sdr["a"]);
                        rankInfo.Value = Convert.ToInt32(sdr["b"]);
                        if (rankType == 3)
                        {
                            rankList[rankInfo.Key - 1] = rankInfo;
                        }
                        else
                        {
                            KuaFuData <KFCompRoleData> kfRoleData = null;
                            if (this.CompRoleDataDict.TryGetValue(rankInfo.Key, out kfRoleData))
                            {
                                rankInfo.Param1  = KuaFuServerManager.FormatName(kfRoleData.V.RoleName, kfRoleData.V.ZoneID);
                                rankInfo.tagInfo = kfRoleData;
                            }
                            rankList.Add(rankInfo);
                        }
                    }
                    if (null != CompRankDict)
                    {
                        TimeUtil.AgeByNow(ref CompRankDict.Age);
                    }
                    if (null != CompRankList)
                    {
                        TimeUtil.AgeByNow(ref CompRankList.Age);
                    }
                    if (sdr != null)
                    {
                        sdr.Close();
                    }
                }
                catch (Exception ex)
                {
                    LogManager.WriteExceptionUseCache(ex.ToString());
                    return(false);
                }
                result = true;
            }
            return(result);
        }
Пример #30
0
 public void InitConfig()
 {
     try
     {
         lock (this.RuntimeData.Mutex)
         {
             string fileName         = "Config/EraUI.xml";
             string fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
             this.RuntimeData.EraUIConfigDict.Load(fullPathFileName, null);
             fileName         = "Config/EraTask.xml";
             fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
             this.RuntimeData.EraTaskConfigDict.Clear();
             XElement xml = ConfigHelper.Load(fullPathFileName);
             IEnumerable <XElement> xmlItems = xml.Elements();
             foreach (XElement xmlItem in xmlItems)
             {
                 EraTaskConfig data = new EraTaskConfig();
                 data.ID       = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L);
                 data.EraID    = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "EraID", 0L);
                 data.EraStage = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "EraStage", 0L);
                 data.Reward   = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "Reward", 0L);
                 string   tempValue  = ConfigHelper.GetElementAttributeValue(xmlItem, "CompletionCondition", "");
                 string[] tempFields = tempValue.Split(new char[]
                 {
                     '|'
                 });
                 foreach (string item in tempFields)
                 {
                     string[] strkvp = item.Split(new char[]
                     {
                         ','
                     });
                     if (strkvp.Length == 2)
                     {
                         int goodsid = Convert.ToInt32(strkvp[0]);
                         int num     = Convert.ToInt32(strkvp[1]);
                         data.CompletionCondition.Add(new KeyValuePair <int, int>(goodsid, num));
                     }
                 }
                 this.RuntimeData.EraTaskConfigDict[data.ID] = data;
             }
             fileName         = "Config/EraReward.xml";
             fullPathFileName = KuaFuServerManager.GetResourcePath(fileName, KuaFuServerManager.ResourcePathTypes.GameRes);
             this.RuntimeData.EraAwardConfigDict.Clear();
             xml      = ConfigHelper.Load(fullPathFileName);
             xmlItems = xml.Elements();
             foreach (XElement xmlItem in xmlItems)
             {
                 EraAwardConfigBase data2 = new EraAwardConfigBase();
                 data2.ID        = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "ID", 0L);
                 data2.EraID     = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "EraID", 0L);
                 data2.AwardType = (int)ConfigHelper.GetElementAttributeValueLong(xmlItem, "Type", 0L);
                 string StartTime = ConfigHelper.GetElementAttributeValue(xmlItem, "StartTime", "");
                 if (!string.IsNullOrEmpty(StartTime))
                 {
                     DateTime.TryParse(StartTime, out data2.StartTime);
                 }
                 string EndTime = ConfigHelper.GetElementAttributeValue(xmlItem, "EndTime", "");
                 if (!string.IsNullOrEmpty(EndTime))
                 {
                     DateTime.TryParse(EndTime, out data2.EndTime);
                 }
                 this.RuntimeData.EraAwardConfigDict[data2.ID] = data2;
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteExceptionUseCache(ex.ToString());
     }
 }