Esempio n. 1
0
        public override void Process(Level level)
        {
            try
            {
                if (m_vMaintance)
                {
                    Console.WriteLine("Hi");
                }
                if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceProMode"]))
                {
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["adminSpecialMode"]))
                    {
                        level = ResourcesManager.GetPlayer(m_vAccountId);
                        if (level != null && level.GetAccountPrivileges() > 3)
                        {
                        }
                        else
                        {
                            var p = new LoginFailedMessage(Client);
                            p.SetErrorCode(10);
                            p.RemainingTime(0);
                            p.SetReason(ConfigurationManager.AppSettings["maintenanceProMessage"]);
                            PacketManager.ProcessOutgoingPacket(p);
                            return;
                        }
                    }
                    else
                    {
                        var p = new LoginFailedMessage(Client);
                        p.SetErrorCode(10);
                        p.RemainingTime(0);
                        p.SetReason(ConfigurationManager.AppSettings["maintenanceProMessage"]);
                        PacketManager.ProcessOutgoingPacket(p);
                        return;
                    }
                }
                if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
                {
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["adminSpecialMode"]))
                    {
                        level = ResourcesManager.GetPlayer(m_vAccountId);
                        if (level != null && level.GetAccountPrivileges() > 3)
                        {
                        }
                        else
                        {
                            var p = new LoginFailedMessage(Client);
                            p.SetErrorCode(10);
                            p.RemainingTime(Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeLeft"]));
                            PacketManager.ProcessOutgoingPacket(p);
                            return;
                        }
                    }
                    else
                    {
                        var p = new LoginFailedMessage(Client);
                        p.SetErrorCode(10);
                        p.RemainingTime(Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeLeft"]));
                        PacketManager.ProcessOutgoingPacket(p);
                        return;
                    }
                }

                var versionData = ConfigurationManager.AppSettings["clientVersion"].Split('.');
                if (versionData.Length >= 2)
                {
                    if (m_vClientMajorVersion != Convert.ToInt32(versionData[0]) ||
                        m_vClientBuild != Convert.ToInt32(versionData[1]))
                    {
                        var p = new LoginFailedMessage(Client);
                        p.SetErrorCode(8);
                        p.SetUpdateURL(ConfigurationManager.AppSettings["oldClientVersion"]);
                        PacketManager.ProcessOutgoingPacket(p);
                        return;
                    }
                }
                else
                {
                    Debugger.WriteLine("Connection failed. UCS config key clientVersion is not properly set.");
                }

                level = ResourcesManager.GetPlayer(m_vAccountId);
                if (level != null)
                {
                    if (level.GetAccountStatus() == 99)
                    {
                        var p = new LoginFailedMessage(Client);
                        p.SetErrorCode(11);
                        PacketManager.ProcessOutgoingPacket(p);
                        return;
                    }
                }

                if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
                {
                    if (m_vResourceSha != 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["oldClientVersion"]);
                        PacketManager.ProcessOutgoingPacket(p);
                        return;
                    }
                }

                Client.ClientSeed = m_vClientSeed;
                PacketManager.ProcessOutgoingPacket(new SessionKeyMessage(Client));
                Debugger.WriteLine("[M] Retrieve Player Data for player " + m_vAccountId, null, 5);

                //New player
                if (level == null)
                {
                    level = ObjectManager.CreateAvatar(m_vAccountId);
                    var tokenSeed = new byte[20];
                    new Random().NextBytes(tokenSeed);
                    SHA1 sha = new SHA1CryptoServiceProvider();
                    m_vPassToken = BitConverter.ToString(sha.ComputeHash(tokenSeed)).Replace("-", "");
                }
                if (level.GetAccountPrivileges() == 1)
                {
                    level.GetPlayerAvatar().SetLeagueId(12);
                }
                if (level.GetAccountPrivileges() == 2)
                {
                    level.GetPlayerAvatar().SetLeagueId(15);
                }
                if (level.GetAccountPrivileges() == 3)
                {
                    level.GetPlayerAvatar().SetLeagueId(18);
                }
                if (level.GetAccountPrivileges() == 4)
                {
                    level.GetPlayerAvatar().SetLeagueId(21);
                }
                if (level.GetAccountPrivileges() == 5)
                {
                    level.GetPlayerAvatar().SetLeagueId(22);
                }

                ResourcesManager.LogPlayerIn(level, Client);
                level.Tick();

                var loginOk = new LoginOkMessage(Client);
                var avatar  = level.GetPlayerAvatar();
                loginOk.SetAccountId(avatar.GetId());
                loginOk.SetPassToken(m_vPassToken);
                loginOk.SetServerMajorVersion(m_vClientMajorVersion);
                loginOk.SetServerBuild(m_vClientBuild);
                loginOk.SetContentVersion(m_vClientContentVersion);
                loginOk.SetServerEnvironment("dev");
                loginOk.SetDaysSinceStartedPlaying(21222);
                loginOk.SetPlayTimeSeconds(62072000);

                //loginOk.SetFacebookId("100001230452744");
                //loginOk.SetGamecenterId("");
                loginOk.SetServerTime(
                    Math.Round(level.GetTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds *1000)
                    .ToString());
                loginOk.SetAccountCreatedDate("1414003838000");
                loginOk.SetStartupCooldownSeconds(0);
                loginOk.SetCountryCode("US");
                PacketManager.ProcessOutgoingPacket(loginOk);

                var alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
                if (alliance == null)
                {
                    level.GetPlayerAvatar().SetAllianceId(0);
                }
                PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(Client, level));
                if (alliance != null)
                {
                    PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(Client, alliance));
                }

                if (ResourcesManager.IsPlayerOnline(level))
                {
                    var mail = new AllianceMailStreamEntry();
                    mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                    mail.SetSenderId(0);
                    mail.SetSenderAvatarId(0);
                    mail.SetSenderName("System Manager");
                    mail.SetIsNew(0);
                    mail.SetAllianceId(0);
                    mail.SetSenderLeagueId(22);
                    mail.SetAllianceBadgeData(1728059989);
                    mail.SetAllianceName("System Bot");
                    mail.SetMessage(ConfigurationManager.AppSettings["welcomeMessage"]);
                    mail.SetSenderLevel(500);
                    var p = new AvatarStreamEntryMessage(level.GetClient());
                    p.SetAvatarStreamEntry(mail);
                    PacketManager.ProcessOutgoingPacket(p);
                }
            }
            catch
            {
                var p = new LoginFailedMessage(Client);
                p.SetErrorCode(9);
                p.SetRedirectDomain(ConfigurationManager.AppSettings["failSafe"]);
                PacketManager.ProcessOutgoingPacket(p);
            }
        }
Esempio n. 2
0
        public override void Process(Level level)
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
            {
                var p = new LoginFailedMessage(this.Client);
                p.SetErrorCode(10);
                PacketManager.ProcessOutgoingPacket(p);
                return;
            }

            string[] versionData = ConfigurationManager.AppSettings["clientVersion"].Split('.');
            if(versionData.Length >= 2)
            {
                if(m_vClientMajorVersion != Convert.ToInt32(versionData[0]) || m_vClientBuild != Convert.ToInt32(versionData[1]))
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(8);
                    p.SetUpdateURL("http://www.ultrapowa.com/");
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }
            else
            {
                Debugger.WriteLine("Connection failed. UCS config key clientVersion is not properly set.");
            }

            level = ResourcesManager.GetPlayer(m_vAccountId);
            if(level != null)
            {
                if(level.GetAccountStatus() == 99)
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(11);
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }

            if(Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
            {
                if (m_vResourceSha != ObjectManager.FingerPrint.sha)
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(7);
                    p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson());
                    p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]);
                    p.SetUpdateURL("http://www.ultrapowa.com/");
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }

            this.Client.ClientSeed = m_vClientSeed;
            PacketManager.ProcessOutgoingPacket(new SessionKeyMessage(this.Client));
            Debugger.WriteLine("[D] Retrieve Player Data for player " + m_vAccountId);
            Console.ResetColor();
            //New player
            if (level == null)
            {
                level = ObjectManager.CreateAvatar(m_vAccountId);
                byte[] tokenSeed = new byte[20];
                new Random().NextBytes(tokenSeed);
                SHA1 sha = new SHA1CryptoServiceProvider();
                m_vPassToken = BitConverter.ToString(sha.ComputeHash(tokenSeed)).Replace("-","");
            }
            if (level.GetAccountPrivileges() > 0)
                level.GetPlayerAvatar().SetLeagueId(21);
            if (level.GetAccountPrivileges() > 4)
                level.GetPlayerAvatar().SetLeagueId(22);
            ResourcesManager.LogPlayerIn(level, this.Client);
            level.Tick();

            var loginOk = new LoginOkMessage(this.Client);
            var avatar = level.GetPlayerAvatar();
            loginOk.SetAccountId(avatar.GetId());
            loginOk.SetPassToken(m_vPassToken);
            loginOk.SetServerMajorVersion(m_vClientMajorVersion);
            loginOk.SetServerBuild(m_vClientBuild);
            loginOk.SetContentVersion(m_vClientContentVersion);

            loginOk.SetDaysSinceStartedPlaying(10);
            loginOk.SetServerTime(Math.Round((level.GetTime().Subtract(new DateTime(1970, 1, 1))).TotalSeconds * 1000).ToString());
            loginOk.SetAccountCreatedDate("1414003838000");
            loginOk.SetStartupCooldownSeconds(0);
            loginOk.SetCountryCode("US");
            PacketManager.ProcessOutgoingPacket(loginOk);

            Alliance alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
            if (alliance == null)
                level.GetPlayerAvatar().SetAllianceId(0);
            PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(this.Client, level));
            if (alliance != null)
                PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(this.Client, alliance));
        }
Esempio n. 3
0
        public override void Process(Level level)
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]) || banned || Client.CState == 0)
            {
                var p = new LoginFailedMessage(Client);
                p.SetErrorCode(10);
                PacketManager.ProcessOutgoingPacket(p);
                return;
            }

            var versionData = ConfigurationManager.AppSettings["clientVersion"].Split('.');

            if (versionData.Length >= 2)
            {
                var cv = ClientVersion.Split('.');
                if (cv[0] != versionData[0] || cv[1] != versionData[1])
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(8);
                    p.SetUpdateURL(Convert.ToString(ConfigurationManager.AppSettings["UpdateUrl"]));
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }
            else
            {
                Debugger.WriteLine("[UCS][10101] Connection failed. UCS config key clientVersion is not properly set.");
            }

            if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
            {
                if (MasterHash != ObjectManager.FingerPrint.sha)
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(7);
                    p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson());
                    p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]);
                    p.SetUpdateURL("http://www.ultrapowa.com/client");
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }

            level = ResourcesManager.GetPlayer(UserID);
            if (level != null)
            {
                if (level.GetAccountStatus() == 99)
                {
                    var p = new LoginFailedMessage(Client);
                    p.SetErrorCode(11);
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }
            else
            {
                level = ObjectManager.CreateAvatar(UserID, UserToken);
                var tokenSeed = new byte[20];
                new Random().NextBytes(tokenSeed);
                using (SHA1 sha = new SHA1CryptoServiceProvider())
                {
                    UserToken = BitConverter.ToString(sha.ComputeHash(tokenSeed)).Replace("-", string.Empty);
                    level.GetPlayerAvatar().SetToken(UserToken);
                    DatabaseManager.Singelton.Save(level);
                }
            }

            Client.ClientSeed = Seed;
            ResourcesManager.LogPlayerIn(level, Client);
            level.Tick();
            var savedtoken = level.GetPlayerAvatar().GetUserToken();

            if (savedtoken != null || savedtoken != string.Empty)
            {
                level.GetPlayerAvatar().SetToken(UserToken);
            }
            if (level.GetPlayerAvatar().GetUserToken() == UserToken)
            {
                var loginOk = new LoginOkMessage(Client);
                var avatar  = level.GetPlayerAvatar();
                loginOk.SetAccountId(avatar.GetId());
                loginOk.SetPassToken(UserToken);
                loginOk.SetServerMajorVersion(MajorVersion);
                loginOk.SetServerBuild(MinorVersion);
                loginOk.SetContentVersion(ContentVersion);
                loginOk.SetServerEnvironment("prod");
                loginOk.SetDaysSinceStartedPlaying(10);
                loginOk.SetServerTime(
                    Math.Round(level.GetTime().Subtract(new DateTime(1970, 1, 1)).TotalSeconds * 1000).ToString());
                loginOk.SetAccountCreatedDate("1414003838000");
                loginOk.SetStartupCooldownSeconds(0);
                loginOk.SetCountryCode("EN");
                PacketManager.ProcessOutgoingPacket(loginOk);

                if (level.GetAccountPrivileges() >= 3)
                {
                    level.GetPlayerAvatar().SetLeagueId(22);
                }

                var alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
                if (alliance == null)
                {
                    level.GetPlayerAvatar().SetAllianceId(0);
                }

                PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(Client, level));
                if (alliance != null)
                {
                    PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(Client, alliance));
                }
                PacketManager.ProcessOutgoingPacket(new BookmarkMessage(Client));
            }
            else
            {
                var p = new LoginFailedMessage(Client);
                p.SetErrorCode(0);
                PacketManager.ProcessOutgoingPacket(p);
                ResourcesManager.LogPlayerOut(level);
            }
        }
Esempio n. 4
0
        public override void Process(Level level)
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
            {
                var p = new LoginFailedMessage(this.Client);
                p.SetErrorCode(10);
                PacketManager.ProcessOutgoingPacket(p);
                return;
            }

            string[] versionData = ConfigurationManager.AppSettings["clientVersion"].Split('.');
            if(versionData.Length >= 2)
            {
                if(m_vClientMajorVersion != Convert.ToInt32(versionData[0]) || m_vClientBuild != Convert.ToInt32(versionData[1]))
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(8);
                    p.SetUpdateURL("market://details?id=com.supercell.clashofclans");
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }
            else
            {
                Debugger.WriteLine("Connection failed. UCS config key clientVersion is not properly set.");
            }

            level = ResourcesManager.GetPlayer(m_vAccountId);
            if(level != null)
            {
                if(level.GetAccountStatus() == 99)
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(11);
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }

            if(Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
            {
                if (m_vResourceSha != ObjectManager.FingerPrint.sha)
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(7);
                    p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson());
                    p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]);
                    p.SetUpdateURL("market://details?id=com.supercell.clashofclans");
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }

            this.Client.ClientSeed = m_vClientSeed;
            PacketManager.ProcessOutgoingPacket(new SessionKeyMessage(this.Client));
            //Console.WriteLine("Debug: Retrieve Player Data for player " + auth.PlayerId.ToString());
            //New player
            if (level == null)
            {
                level = ObjectManager.CreateAvatar(m_vAccountId);
                byte[] tokenSeed = new byte[20];
                new Random().NextBytes(tokenSeed);
                SHA1 sha = new SHA1CryptoServiceProvider();
                m_vPassToken = BitConverter.ToString(sha.ComputeHash(tokenSeed)).Replace("-","");
            }
            //if (level.GetAccountPrivileges() > 0)
            //    level.GetPlayerAvatar().SetLeagueId(21);
            //if (level.GetAccountPrivileges() > 4)
            //    level.GetPlayerAvatar().SetLeagueId(22);
            if (level.GetPlayerAvatar().GetScore() >= 400 && level.GetPlayerAvatar().GetScore() <= 800)
            {
                level.GetPlayerAvatar().SetLeagueId(3);
            }
            else if (level.GetPlayerAvatar().GetScore() >= 801 && level.GetPlayerAvatar().GetScore() <= 1400)
            {
                level.GetPlayerAvatar().SetLeagueId(6);
            }
            else if (level.GetPlayerAvatar().GetScore() >= 1401 && level.GetPlayerAvatar().GetScore() <= 2000)
            {
                level.GetPlayerAvatar().SetLeagueId(9);
            }
            else if (level.GetPlayerAvatar().GetScore() >= 2001 && level.GetPlayerAvatar().GetScore() <= 2600)
            {
                level.GetPlayerAvatar().SetLeagueId(12);
            }
            else if (level.GetPlayerAvatar().GetScore() >= 2601 && level.GetPlayerAvatar().GetScore() <= 3200)
            {
                level.GetPlayerAvatar().SetLeagueId(15);
            }
            else if (level.GetPlayerAvatar().GetScore() >= 3201 && level.GetPlayerAvatar().GetScore() <= 4099)
            {
                level.GetPlayerAvatar().SetLeagueId(18);
            }
            else if (level.GetPlayerAvatar().GetScore() >= 4100)
            {
                level.GetPlayerAvatar().SetLeagueId(21);
            }

            ResourcesManager.LogPlayerIn(level, this.Client);
            level.Tick();

            var loginOk = new LoginOkMessage(this.Client);
            var avatar = level.GetPlayerAvatar();
            loginOk.SetAccountId(avatar.GetId());
            loginOk.SetPassToken(m_vPassToken);
            loginOk.SetServerMajorVersion(m_vClientMajorVersion);
            loginOk.SetServerBuild(m_vClientBuild);
            loginOk.SetContentVersion(m_vClientContentVersion);
            loginOk.SetServerEnvironment("prod");
            loginOk.SetDaysSinceStartedPlaying(10);
            loginOk.SetServerTime(Math.Round((level.GetTime().Subtract(new DateTime(1970, 1, 1))).TotalSeconds * 1000).ToString());
            loginOk.SetAccountCreatedDate("1414003838000");
            loginOk.SetStartupCooldownSeconds(0);
            loginOk.SetCountryCode("FR");
            PacketManager.ProcessOutgoingPacket(loginOk);

            if (ResourcesManager.IsPlayerOnline(level))
            {
                AllianceMailStreamEntry mail = new AllianceMailStreamEntry();
                mail.SetId((int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds);
                mail.SetSenderId(0);
                mail.SetSenderAvatarId(0);
                mail.SetSenderName("EuroClash.Net");
                mail.SetIsNew(0);
                mail.SetAllianceId(0);
                mail.SetAllianceBadgeData(0);
                mail.SetAllianceName("Automatic Information");
                mail.SetMessage("Welcome to EuroClash ! \nTo see available commands type /help \n\nSaveGame is fully automatic, you don't have to type anything, commands like /savegame or ./savegame doesn't exist, all commands are available on /help\n\nTrophies are randomly given on first login, this will be fixed soon.\n\nNow Clans calculate trophies of players, 50% of their trophies will be added to clan trophies, still kinda bugged, we're testing with simple math. Clan Owner's trophies are not added (bug).\n\nServer is currently in Alpha, to see bugfixes please visit http://euroclash.net ChangeLog Section!");
                mail.SetSenderLeagueId(22);
                var abe = new AvatarStreamEntryMessage(level.GetClient());
                abe.SetAvatarStreamEntry(mail);
                PacketManager.ProcessOutgoingPacket(abe);
            }
            //level.GetPlayerAvatar().SetResourceCount(ObjectManager.DataTables.GetResourceByName("Diamonds"), Convert.ToInt32(1000000));

            Alliance alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());
            if (alliance == null)
                level.GetPlayerAvatar().SetAllianceId(0);
            PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(this.Client, level));
            if (alliance != null)
                PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(this.Client, alliance));
        }
Esempio n. 5
0
        public override void Process(Level level)
        {
            if (Convert.ToBoolean(ConfigurationManager.AppSettings["maintenanceMode"]))
            {
                var p = new LoginFailedMessage(this.Client);
                p.SetErrorCode(10);
                p.RemainingTime(Convert.ToInt32(ConfigurationManager.AppSettings["maintenanceTimeLeft"]));
                PacketManager.ProcessOutgoingPacket(p);
                return;
            }

            string[] versionData = ConfigurationManager.AppSettings["clientVersion"].Split('.');
            if (versionData.Length >= 2)
            {
                if (m_vClientMajorVersion != Convert.ToInt32(versionData[0]) || m_vClientBuild != Convert.ToInt32(versionData[1]))
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(8);
                    p.SetUpdateURL(ConfigurationManager.AppSettings["oldClientVersion"]);
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }
            else
            {
                Debugger.WriteLine("Connection failed. UCS config key clientVersion is not properly set.");
            }

            level = ResourcesManager.GetPlayer(m_vAccountId);
            if (level != null)
            {
                if (level.GetAccountStatus() == 99)
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(11);
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }

            if (Convert.ToBoolean(ConfigurationManager.AppSettings["useCustomPatch"]))
            {
                if (m_vResourceSha != ObjectManager.FingerPrint.sha)
                {
                    var p = new LoginFailedMessage(this.Client);
                    p.SetErrorCode(7);
                    p.SetResourceFingerprintData(ObjectManager.FingerPrint.SaveToJson());
                    p.SetContentURL(ConfigurationManager.AppSettings["patchingServer"]);
                    p.SetUpdateURL(ConfigurationManager.AppSettings["oldClientVersion"]);
                    PacketManager.ProcessOutgoingPacket(p);
                    return;
                }
            }

            this.Client.ClientSeed = m_vClientSeed;
            PacketManager.ProcessOutgoingPacket(new SessionKeyMessage(this.Client));
            Console.WriteLine("[D] Retrieve Player Data for player " + m_vAccountId);
            //New player
            if (level == null)
            {
                level = ObjectManager.CreateAvatar(m_vAccountId);
                byte[] tokenSeed = new byte[20];
                new Random().NextBytes(tokenSeed);
                SHA1 sha = new SHA1CryptoServiceProvider();
                m_vPassToken = BitConverter.ToString(sha.ComputeHash(tokenSeed)).Replace("-", "");
            }
            if (level.GetAccountPrivileges() > 0)
            {
                level.GetPlayerAvatar().SetLeagueId(21);
            }
            if (level.GetAccountPrivileges() > 4)
            {
                level.GetPlayerAvatar().SetLeagueId(22);
            }
            ResourcesManager.LogPlayerIn(level, this.Client);
            level.Tick();

            var loginOk = new LoginOkMessage(this.Client);
            var avatar  = level.GetPlayerAvatar();

            loginOk.SetAccountId(avatar.GetId());
            loginOk.SetPassToken(m_vPassToken);
            loginOk.SetServerMajorVersion(m_vClientMajorVersion);
            loginOk.SetServerBuild(m_vClientBuild);
            loginOk.SetContentVersion(m_vClientContentVersion);
            loginOk.SetServerEnvironment("state");
            loginOk.SetDaysSinceStartedPlaying(10);
            loginOk.SetServerTime(Math.Round((level.GetTime().Subtract(new DateTime(1970, 1, 1))).TotalSeconds * 1000).ToString());
            loginOk.SetAccountCreatedDate("1414003838000");
            loginOk.SetStartupCooldownSeconds(0);
            loginOk.SetCountryCode("US");
            PacketManager.ProcessOutgoingPacket(loginOk);

            Alliance alliance = ObjectManager.GetAlliance(level.GetPlayerAvatar().GetAllianceId());

            if (alliance == null)
            {
                level.GetPlayerAvatar().SetAllianceId(0);
            }
            PacketManager.ProcessOutgoingPacket(new OwnHomeDataMessage(this.Client, level));
            if (alliance != null)
            {
                PacketManager.ProcessOutgoingPacket(new AllianceStreamMessage(this.Client, alliance));
            }
        }