db.Database.CreateGuestAccount C# (CSharp) Method

CreateGuestAccount() public static method

public static CreateGuestAccount ( string uuid ) : Account
uuid string
return Account
        public static Account CreateGuestAccount(string uuid)
        {
            return new Account
            {
                Name = Names[(uint)uuid.GetHashCode() % Names.Length],
                AccountId = 0,
                Admin = false,
                Banned = false,
                Rank = 0,
                BeginnerPackageTimeLeft = 0,
                Converted = false,
                Credits = 0,
                Guild = new Guild
                {
                    Name = "",
                    Id = 0,
                    Rank = 0
                },
                NameChosen = false,
                NextCharSlotPrice = 5000,
                VerifiedEmail = false,
                Stats = new Stats
                {
                    BestCharFame = 0,
                    ClassStates = new List<ClassStats>(),
                    Fame = 0,
                    TotalFame = 0
                },
                Vault = new VaultData
                {
                    Chests = new List<VaultChest>()
                },
                Bonuses = new List<short>()
            };
        }

Usage Example

        private void ProcessHelloPacket(HelloPacket pkt)
        {
            Database = new Database();
            if ((Account = Database.Verify(pkt.GUID, pkt.Password)) == null)
            {
                Logger.Warn("Account not verified");
                Account = Database.CreateGuestAccount(pkt.GUID);

                if (Account == null)
                {
                    Logger.Warn("Account is null");
                    SendPacket(new FailurePacket
                    {
                        Message = "Invalid account."
                    });
                    Disconnect();
                    Database.Dispose();
                    return;
                }
            }
            if ((IP = Database.CheckIp(Socket.RemoteEndPoint.ToString().Split(':')[0])) == null)
            {
                Logger.Error("Error checking IP");
                SendPacket(new FailurePacket
                {
                    Message = "Error with IP."
                });
                Disconnect();
                Database.Dispose();
                return;
            }
            Logger.Info("Client trying to connect");
            ConnectedBuild = pkt.BuildVersion;
            if (!RealmManager.TryConnect(this))
            {
                if (CheckAccountInUse(Account.AccountId))
                {
                    Logger.Warn($"Account in use: {Account.Name} ({Account.AccountId})");
                    Account = null;
                    SendPacket(new FailurePacket
                    {
                        Message = "Account in use! Retrying..."
                    });
                    Disconnect();
                    Database.Dispose();
                    return;
                }
                Account = null;
                SendPacket(new FailurePacket
                {
                    Message = "Failed to connect."
                });
                Disconnect();
                Logger.Error("Failed to connect");
            }
            else
            {
                Logger.Info("Client loading world");
                var world = RealmManager.GetWorld(pkt.GameId);
                if (world == null)
                {
                    SendPacket(new FailurePacket
                    {
                        Message = "Invalid world."
                    });
                    Disconnect();
                    Logger.Error("Invalid world");
                }
                try
                {
                    Logger.Info($"Client joined world {world.Id}");
                }
                catch
                {
                    Logger.Error("Error, world is null");
                }
                if (world.Id == -6) //Test World
                    (world as Test).LoadJson(pkt.MapInfo);
                else if (world.IsLimbo)
                    world = world.GetInstance(this);
                var seed = (uint)((long)Environment.TickCount * pkt.GUID.GetHashCode()) % uint.MaxValue;
                Random = new wRandom(seed);
                targetWorld = world.Id;
                if (!ConnectedBuildStartsWith(clientVer))
                {
                    SendPacket(new TextPacket
                    {
                        BubbleTime = 1,
                        Stars = -1,
                        Name = "",
                        Text = "Your client is outdated. Visit http://forum.zerorealms.com to get the latest one!"
                    });
                    Disconnect();
                    /*SendPacket(new TextBoxPacket
                    {
                        Button1 = "Okay",
                        Message = "Your client is outdated, Click <font color=\"white\"><b><a href='http://forum.zerorealms.com'>Here</a></b></font> to get the latest one!",
                        Title = "Outdated Client!",
                        Type = "NewClient"
                    });*/
                }
                SendPacket(new MapInfoPacket
                {
                    Width = world.Map.Width,
                    Height = world.Map.Height,
                    Name = world.Name,
                    Seed = seed,
                    Background = world.Background,
                    AllowTeleport = world.AllowTeleport,
                    ShowDisplays = world.ShowDisplays,
                    Music = world.GetMusic(Random),
                    ClientXML = world.ClientXML,
                    ExtraXML = world.ExtraXML,

                    SendMusic = ConnectedBuildStartsWith(clientVer)
                });
                Stage = ProtocalStage.Handshaked;
            }
        }