public bool CheckPTKuaFuLoginSign(KuaFuServerLoginData data)
        {
            string signKey     = null;
            string worldRoleID = ConstData.FormatWorldRoleID(data.RoleId, data.PTID);

            string[] ips;
            int[]    ports;
            int      result = KuaFuWorldClient.getInstance().CheckEnterWorldKuaFuSign(worldRoleID, data.SignToken, out signKey, out ips, out ports);
            bool     result2;

            if (result < 0)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("CheckEnterWorldKuaFuSign faild,roleid={0},ptid={1},result={2}", data.RoleId, data.PTID, result), null, true);
                result2 = false;
            }
            else
            {
                string kfsign = MD5Helper.get_md5_string(data.SignDataString() + signKey).ToLower();
                if (kfsign != data.SignCode)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("CheckEnterWorldKuaFuSign SignCode Error,roleid={0},ptid={1},SignCode={2}", data.RoleId, data.PTID, data.SignCode), null, true);
                    result2 = false;
                }
                else
                {
                    data.ips   = ips;
                    data.ports = ports;
                    result2    = true;
                }
            }
            return(result2);
        }
Beispiel #2
0
        public void TimerProc(object sender, EventArgs e)
        {
            Dictionary <int, int> dict = new Dictionary <int, int>();

            if (KuaFuManager.getInstance().CanKuaFuLogin())
            {
                lock (this.RuntimeData.Mutex)
                {
                    foreach (int mapCode in this.RuntimeData.MapCode2KuaFuLineDataDict.Keys)
                    {
                        dict[mapCode] = 0;
                    }
                }
            }
            List <int> list = dict.Keys.ToList <int>();

            foreach (int mapCode in list)
            {
                dict[mapCode] = GameManager.ClientMgr.GetMapClientsCount(mapCode);
            }
            if (KuaFuManager.KuaFuWorldKuaFuGameServer)
            {
                KuaFuWorldClient.getInstance().UpdateKuaFuMapClientCount(dict);
            }
            else
            {
                YongZheZhanChangClient.getInstance().UpdateKuaFuMapClientCount(dict);
            }
        }
Beispiel #3
0
 public bool initialize(ICoreInterface coreInterface)
 {
     try
     {
         this.CoreInterface = coreInterface;
         if (!this.InitConfig())
         {
             return(false);
         }
         RemotingConfiguration.Configure(Process.GetCurrentProcess().MainModule.FileName + ".config", false);
         if (!HuanYingSiYuanClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!TianTiClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!YongZheZhanChangClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!KFCopyRpcClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!SpreadClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!AllyClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!IPStatisticsClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!JunTuanClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         if (!KuaFuWorldClient.getInstance().initialize(coreInterface))
         {
             return(false);
         }
         GlobalEventSource.getInstance().registerListener(12, KuaFuManager.getInstance());
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
 public bool ProcessGetKuaFuLineDataListCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
 {
     try
     {
         int mapCode = Global.SafeConvertToInt32(cmdParams[0]);
         if (Global.GetMapSceneType(mapCode) == SceneUIClasses.ChongShengMap)
         {
             List <KuaFuLineData> list = KuaFuWorldClient.getInstance().GetKuaFuLineDataList(mapCode) as List <KuaFuLineData>;
             client.sendCmd <List <KuaFuLineData> >(nID, list, false);
         }
         else
         {
             List <KuaFuLineData> list = YongZheZhanChangClient.getInstance().GetKuaFuLineDataList(mapCode) as List <KuaFuLineData>;
             client.sendCmd <List <KuaFuLineData> >(nID, list, false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
     }
     return(false);
 }
Beispiel #5
0
 public bool startup()
 {
     try
     {
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("HuanYingSiYuanClient.TimerProc", new EventHandler(HuanYingSiYuanClient.getInstance().TimerProc)), 2000, 2857);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("TianTiClient.TimerProc", new EventHandler(TianTiClient.getInstance().TimerProc)), 2000, 2857);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("YongZheZhanChangClient.TimerProc", new EventHandler(YongZheZhanChangClient.getInstance().TimerProc)), 2000, 3389);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("KFCopyRpcClient.TimerProc", new EventHandler(KFCopyRpcClient.getInstance().TimerProc)), 2000, 2732);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("SpreadClient.TimerProc", new EventHandler(SpreadClient.getInstance().TimerProc)), 2000, 4285);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("AllyClient.TimerProc", new EventHandler(AllyClient.getInstance().TimerProc)), 2000, 5714);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("IPStatisticsClient.TimerProc", new EventHandler(IPStatisticsClient.getInstance().TimerProc)), 2000, 5000);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("JunTuanClient.TimerProc", new EventHandler(JunTuanClient.getInstance().TimerProc)), 2000, 2500);
         ScheduleExecutor2.Instance.scheduleExecute(new NormalScheduleTask("KuaFuWorldClient.TimerProc", new EventHandler(KuaFuWorldClient.getInstance().TimerProc)), 2000, 3389);
         lock (this.RuntimeData.Mutex)
         {
             if (null == this.RuntimeData.BackGroundThread)
             {
                 this.RuntimeData.BackGroundThread = new Thread(new ThreadStart(this.BackGroudThreadProc));
                 this.RuntimeData.BackGroundThread.IsBackground = true;
                 this.RuntimeData.BackGroundThread.Start();
             }
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Beispiel #6
0
        public bool ProcessKuaFuMapEnterCmd(GameClient client, int nID, byte[] bytes, string[] cmdParams)
        {
            try
            {
                int result     = 0;
                int toMapCode  = Global.SafeConvertToInt32(cmdParams[0]);
                int line       = Global.SafeConvertToInt32(cmdParams[1]);
                int toBoss     = 0;
                int teleportId = 0;
                if (cmdParams.Length >= 3)
                {
                    toBoss = Global.SafeConvertToInt32(cmdParams[2]);
                }
                if (cmdParams.Length >= 4)
                {
                    teleportId = Global.SafeConvertToInt32(cmdParams[3]);
                }
                KuaFuLineData kuaFuLineData;
                if (!KuaFuMapManager.getInstance().IsKuaFuMap(toMapCode))
                {
                    result = -12;
                }
                else if (!this.RuntimeData.LineMap2KuaFuLineDataDict.TryGetValue(new IntPairKey(line, toMapCode), out kuaFuLineData))
                {
                    result = -12;
                }
                else if (!Global.CanEnterMap(client, toMapCode) || (toMapCode == client.ClientData.MapCode && kuaFuLineData.MapType != 1))
                {
                    result = -12;
                }
                else
                {
                    if (toMapCode == client.ClientData.MapCode && kuaFuLineData.MapType == 1)
                    {
                        List <KuaFuLineData> list = KuaFuWorldClient.getInstance().GetKuaFuLineDataList(toMapCode) as List <KuaFuLineData>;
                        if (null == list)
                        {
                            result = -12;
                            goto IL_67F;
                        }
                        KuaFuLineData currentLineData = list.Find((KuaFuLineData x) => x.ServerId == GameManager.KuaFuServerId);
                        if (currentLineData != null && currentLineData.Line == kuaFuLineData.Line)
                        {
                            result = -4011;
                            goto IL_67F;
                        }
                    }
                    if (!KuaFuMapManager.getInstance().IsKuaFuMap(client.ClientData.MapCode) && !this.CheckMap(client))
                    {
                        result = -21;
                    }
                    else if (!this.IsGongNengOpened(client, false))
                    {
                        result = -12;
                    }
                    else if (kuaFuLineData.OnlineCount >= kuaFuLineData.MaxOnlineCount)
                    {
                        result = -100;
                    }
                    else
                    {
                        int fromMapCode = client.ClientData.MapCode;
                        if (teleportId > 0)
                        {
                            GameMap fromGameMap = null;
                            if (!GameManager.MapMgr.DictMaps.TryGetValue(fromMapCode, out fromGameMap))
                            {
                                result = -3;
                                goto IL_67F;
                            }
                            MapTeleport mapTeleport = null;
                            if (!fromGameMap.MapTeleportDict.TryGetValue(teleportId, out mapTeleport) || mapTeleport.ToMapID != toMapCode)
                            {
                                result = -12;
                                goto IL_67F;
                            }
                            if (Global.GetTwoPointDistance(client.CurrentPos, new Point((double)mapTeleport.X, (double)mapTeleport.Y)) > 800.0)
                            {
                                result = -301;
                                goto IL_67F;
                            }
                        }
                        KuaFuServerLoginData kuaFuServerLoginData = Global.GetClientKuaFuServerLoginData(client);
                        int kuaFuServerId;
                        if (kuaFuLineData.MapType == 1)
                        {
                            if (!GlobalNew.IsGongNengOpened(client, GongNengIDs.Reborn, true))
                            {
                                result = -400;
                                goto IL_67F;
                            }
                            string signToken;
                            string signKey;
                            int    rt = KuaFuWorldClient.getInstance().EnterPTKuaFuMap(client.ServerId, client.ClientData.LocalRoleID, client.ClientData.ServerPTID, kuaFuLineData.MapCode, kuaFuLineData.Line, kuaFuServerLoginData, out signToken, out signKey);
                            if (rt == -4010)
                            {
                                KuaFuWorldRoleData kuaFuWorldRoleData = new KuaFuWorldRoleData
                                {
                                    LocalRoleID = client.ClientData.LocalRoleID,
                                    UserID      = client.strUserID,
                                    WorldRoleID = client.ClientData.WorldRoleID,
                                    Channel     = client.ClientData.Channel,
                                    PTID        = client.ClientData.ServerPTID,
                                    ServerID    = client.ServerId,
                                    ZoneID      = client.ClientData.ZoneID
                                };
                                rt = KuaFuWorldClient.getInstance().RegPTKuaFuRoleData(ref kuaFuWorldRoleData);
                                rt = KuaFuWorldClient.getInstance().EnterPTKuaFuMap(client.ServerId, client.ClientData.LocalRoleID, client.ClientData.ServerPTID, kuaFuLineData.MapCode, kuaFuLineData.Line, kuaFuServerLoginData, out signToken, out signKey);
                            }
                            if (rt < 0)
                            {
                                result = rt;
                                goto IL_67F;
                            }
                            KFRebornRoleData rebornRoleData = KuaFuWorldClient.getInstance().Reborn_GetRebornRoleData(client.ClientData.ServerPTID, client.ClientData.LocalRoleID);
                            if (null == rebornRoleData)
                            {
                                result = KuaFuWorldClient.getInstance().Reborn_RoleReborn(client.ClientData.ServerPTID, client.ClientData.LocalRoleID, client.ClientData.RoleName, client.ClientData.RebornLevel);
                                if (result < 0)
                                {
                                    goto IL_67F;
                                }
                                LogManager.WriteLog(LogTypes.Analysis, string.Format("Reborn_RoleReborn ptId={0} roleId={1} roleName={2} rebornLevel={3}", new object[]
                                {
                                    client.ClientData.ServerPTID,
                                    client.ClientData.LocalRoleID,
                                    client.ClientData.RoleName,
                                    client.ClientData.RebornLevel
                                }), null, true);
                            }
                            kuaFuServerLoginData.PTID       = client.ClientData.ServerPTID;
                            kuaFuServerLoginData.RoleId     = client.ClientData.LocalRoleID;
                            kuaFuServerLoginData.SignToken  = signToken;
                            kuaFuServerLoginData.TempRoleID = rt;
                            kuaFuServerLoginData.SignCode   = MD5Helper.get_md5_string(kuaFuServerLoginData.SignDataString() + signKey).ToLower();
                            kuaFuServerId = kuaFuServerLoginData.TargetServerID;
                        }
                        else
                        {
                            kuaFuServerLoginData.SignCode = null;
                            kuaFuServerId = YongZheZhanChangClient.getInstance().EnterKuaFuMap(client.ClientData.LocalRoleID, kuaFuLineData.MapCode, kuaFuLineData.Line, client.ServerId, Global.GetClientKuaFuServerLoginData(client));
                        }
                        kuaFuServerLoginData.Line = line;
                        if (kuaFuServerId > 0)
                        {
                            bool flag      = 0 == 0;
                            int  needMoney = (teleportId > 0) ? 0 : Global.GetMapTransNeedMoney(toMapCode);
                            if (Global.GetTotalBindTongQianAndTongQianVal(client) < needMoney)
                            {
                                GameManager.ClientMgr.NotifyImportantMsg(client, StringUtil.substitute(GLang.GetLang(171, new object[0]), new object[]
                                {
                                    needMoney,
                                    Global.GetMapName(toMapCode)
                                }), GameInfoTypeIndexes.Error, ShowGameInfoTypes.ErrAndBox, 27);
                                result = -9;
                                Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                            }
                            else
                            {
                                int[] enterFlags = new int[5];
                                enterFlags[0] = fromMapCode;
                                enterFlags[1] = teleportId;
                                enterFlags[2] = toBoss;
                                Global.SaveRoleParamsIntListToDB(client, new List <int>(enterFlags), "EnterKuaFuMapFlag", true);
                                GlobalNew.RecordSwitchKuaFuServerLog(client);
                                client.sendCmd <KuaFuServerLoginData>(14000, Global.GetClientKuaFuServerLoginData(client), false);
                            }
                        }
                        else
                        {
                            Global.GetClientKuaFuServerLoginData(client).RoleId = 0;
                            result = kuaFuServerId;
                        }
                    }
                }
IL_67F:
                client.sendCmd <int>(nID, result, false);
                return(true);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, Global.GetDebugHelperInfo(client.ClientSocket), false, false);
            }
            return(false);
        }