Exemple #1
0
        internal override void Process()
        {
            try
            {
                if (this.Device.PlayerState == State.LOGIN)
                {
                    if (Constants.LicensePlanID == 3)
                    {
                        if (ResourcesManager.m_vOnlinePlayers.Count >= Constants.MaxOnlinePlayers)
                        {
                            new LoginFailedMessage(Device)
                            {
                                ErrorCode = 12,
                                Reason    = "Sorry the Server is currently full! \n\nPlease try again in a few Minutes.\n"
                            }.Send();
                            return;
                        }
                    }

                    if (ParserThread.GetMaintenanceMode())
                    {
                        new LoginFailedMessage(Device)
                        {
                            ErrorCode     = 10,
                            RemainingTime = ParserThread.GetMaintenanceTime(),
                            Version       = 8
                        }.Send();
                        return;
                    }

                    if (Constants.LicensePlanID < 1)
                    {
                        if (ResourcesManager.m_vOnlinePlayers.Count >= 350)
                        {
                            new LoginFailedMessage(Device)
                            {
                                ErrorCode = 11,
                                Reason    = "This is a Free Version of UCS. Please Upgrade on https://ultrapowa.com/forum"
                            }.Send();
                            return;
                        }
                    }
                    else if (Constants.LicensePlanID < 2)
                    {
                        if (ResourcesManager.m_vOnlinePlayers.Count >= 700)
                        {
                            new LoginFailedMessage(Device)
                            {
                                ErrorCode = 11,
                                Reason    =
                                    "This is a Pro Version of UCS. Please Upgrade to Ultra on https://ultrapowa.com/forum"
                            }.Send();
                            return;
                        }
                    }

                    int time = Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"]);
                    if (time != 0)
                    {
                        new LoginFailedMessage(Device)
                        {
                            ErrorCode     = 10,
                            RemainingTime = time,
                            Version       = 8
                        }.Send();
                        return;
                    }

                    if (ConfigurationManager.AppSettings["CustomMaintenance"] != string.Empty)
                    {
                        new LoginFailedMessage(Device)
                        {
                            ErrorCode = 10,
                            Reason    = Utils.ParseConfigString("CustomMaintenance")
                        }.Send();
                        return;
                    }

                    string[] cv2 = ConfigurationManager.AppSettings["ClientVersion"].Split('.');
                    string[] cv  = ClientVersion.Split('.');
                    if (cv[0] != cv2[0] || cv[1] != cv2[1] || cv[2] != cv2[2])
                    {
                        new LoginFailedMessage(Device)
                        {
                            ErrorCode = 8,
                            UpdateUrl = Utils.ParseConfigString("UpdateUrl")
                        }.Send();
                        return;
                    }

                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]) &&
                        MasterHash != ObjectManager.FingerPrint.sha)
                    {
                        new LoginFailedMessage(Device)
                        {
                            ErrorCode = 7,
                            ResourceFingerprintData = ObjectManager.FingerPrint.SaveToJson(),
                            ContentUrl = Utils.ParseConfigString("patchingServer"),
                            UpdateUrl  = Utils.ParseConfigString("UpdateUrl")
                        }.Send();
                        return;
                    }
                    CheckClient();
                }
            }
            catch
            {
            }
        }
Exemple #2
0
        public override void Process(Level a)
        {
            if (Client.State == ClientState.Login)
            {
                if (Constants.IsRc4)
                {
                    Client.ClientSeed = Seed;
                    new RC4SessionKey(Client).Send();
                }

                if (ParserThread.GetMaintenanceMode() == true)
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(10);
                    p.RemainingTime(ParserThread.GetMaintenanceTime());
                    p.SetMessageVersion(8);
                    p.Send();
                    return;
                }

                if (Constants.IsPremiumServer == false)
                {
                    if (ResourcesManager.GetOnlinePlayers().Count >= 100)
                    {
                        var p = new LoginFailedMessage(Client);
                        p.SetErrorCode(11);
                        p.SetReason("This is a free Version of UCS. Please Upgrade to Premium on https://ultrapowa.com/forum");
                        p.Send();
                        return;
                    }
                }

                int time = Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"]);
                if (time != 0)
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(10);
                    p.RemainingTime(time);
                    p.SetMessageVersion(8);
                    p.Send();
                    return;
                }

                if (ConfigurationManager.AppSettings["CustomMaintenance"] != string.Empty)
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(10);
                    p.SetReason(ConfigurationManager.AppSettings["CustomMaintenance"]);
                    p.Send();
                    return;
                }

                var cv2 = ConfigurationManager.AppSettings["ClientVersion"].Split('.');
                var cv  = ClientVersion.Split('.');
                if (cv[0] != cv2[0] || cv[1] != cv2[1])
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(8);
                    p.SetUpdateURL(Convert.ToString(ConfigurationManager.AppSettings["UpdateUrl"]));
                    p.Send();
                    return;
                }

                if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]) &&
                    MasterHash != ObjectManager.FingerPrint.sha)
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(7);
                    p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson());
                    p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]);
                    p.SetUpdateURL(ConfigurationManager.AppSettings["UpdateUrl"]);
                    p.Send();
                    return;
                }
                CheckClient();
            }
        }
        public override void Process(Level a)
        {
            try
            {
                if (Client.State == ClientState.Login)
                {
                    if (Constants.IsRc4)
                    {
                        Client.ClientSeed = Seed;
                        PacketProcessor.Send(new RC4SessionKey(Client));
                    }

                    if (Constants.LicensePlanID == 3)
                    {
                        if (ResourcesManager.GetOnlinePlayers().Count >= Constants.MaxOnlinePlayers)
                        {
                            LoginFailedMessage p = new LoginFailedMessage(Client);
                            p.SetErrorCode(12);
                            p.SetReason("Sorry the Server is currently full! \n\nPlease try again in a few Minutes.\n");
                            PacketProcessor.Send(p);
                            return;
                        }
                    }

                    if (ParserThread.GetMaintenanceMode())
                    {
                        LoginFailedMessage p = new LoginFailedMessage(Client);
                        p.SetErrorCode(10);
                        p.RemainingTime(ParserThread.GetMaintenanceTime());
                        p.SetMessageVersion(8);
                        PacketProcessor.Send(p);
                        return;
                    }

                    if (Constants.LicensePlanID < 1)
                    {
                        if (ResourcesManager.GetOnlinePlayers().Count >= 350)
                        {
                            LoginFailedMessage p = new LoginFailedMessage(Client);
                            p.SetErrorCode(11);
                            p.SetReason("This is a Free Version of UCS. Please Upgrade on https://ultrapowa.com/forum");
                            PacketProcessor.Send(p);
                            return;
                        }
                    }
                    else if (Constants.LicensePlanID < 2)
                    {
                        if (ResourcesManager.GetOnlinePlayers().Count >= 700)
                        {
                            LoginFailedMessage p = new LoginFailedMessage(Client);
                            p.SetErrorCode(11);
                            p.SetReason("This is a Pro Version of UCS. Please Upgrade to Ultra on https://ultrapowa.com/forum");
                            PacketProcessor.Send(p);
                            return;
                        }
                    }

                    int time = Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeleft"]);
                    if (time != 0)
                    {
                        LoginFailedMessage p = new LoginFailedMessage(Client);
                        p.SetErrorCode(10);
                        p.RemainingTime(time);
                        p.SetMessageVersion(8);
                        PacketProcessor.Send(p);
                        return;
                    }

                    if (ConfigurationManager.AppSettings["CustomMaintenance"] != string.Empty)
                    {
                        LoginFailedMessage p = new LoginFailedMessage(Client);
                        p.SetErrorCode(10);
                        p.SetReason(ConfigurationManager.AppSettings["CustomMaintenance"]);
                        PacketProcessor.Send(p);
                        return;
                    }

                    string[] cv2 = ConfigurationManager.AppSettings["ClientVersion"].Split('.');
                    string[] cv  = ClientVersion.Split('.');
                    if (cv[0] != cv2[0] || cv[1] != cv2[1])
                    {
                        LoginFailedMessage p = new LoginFailedMessage(Client);
                        p.SetErrorCode(8);
                        /*FOR FHX*/       //p.SetReason("Please re-downoad the APK on the Official FHX Site! \n Official Site: \n\n https://fhx-server.com, or \nhttp://fhxservercoc.com \n\n Or click the Update Button below!");
                        p.SetUpdateURL(Convert.ToString(ConfigurationManager.AppSettings["UpdateUrl"]));
                        PacketProcessor.Send(p);
                        return;
                    }

                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]) && MasterHash != ObjectManager.FingerPrint.sha)
                    {
                        LoginFailedMessage p = new LoginFailedMessage(Client);
                        p.SetErrorCode(7);
                        p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson());
                        p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]);
                        p.SetUpdateURL(ConfigurationManager.AppSettings["UpdateUrl"]);
                        PacketProcessor.Send(p);
                        return;
                    }
                    CheckClient();
                }
            } catch (Exception) { }
        }