예제 #1
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);
        }
예제 #2
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);
        }