5165 Exception Error! HELP!~

03/01/2010 00:57 killersub#1
okay so I am going to post here my code since not much people are willing to help me without it...here is my LoadCharacter void in database.cs I get like 3 errors in there saying "unable to read beyond end of stream", something like dat...and another error on character.cs but I mainly think it's in Load Character...

so plz HELP ME as I cannot login to the game cuz of dis damm error >.>...

LoadCharacter(MINE-ORIGINAL):

Code:
public static Game.Character LoadCharacter(string Name, ref string Account)
        {
            try
            {
                Game.Character C = new NewestCOServer.Game.Character();
                if (File.Exists(@"C:\OldCODB\Users\Characters\" + Name + ".chr"))
                {
                    FileStream FS = new FileStream(@"C:\OldCODB\Users\Characters\" + Name + ".chr", FileMode.Open);
                    BinaryReader BR = new BinaryReader(FS);
                    C.Name = Name;
                    Account = BR.ReadString();
                    C.EntityID = BR.ReadUInt32();
                    C.Avatar = BR.ReadUInt16();
                    C.Body = BR.ReadUInt16();
                    C.Hair = BR.ReadUInt16();

                    C.Loc = new NewestCOServer.Game.Location();
                    C.Loc.Map = BR.ReadUInt16();
                    C.Loc.X = BR.ReadUInt16();
                    C.Loc.Y = BR.ReadUInt16();
                    C.Loc.PreviousMap = BR.ReadUInt16();

                    C.Job = BR.ReadByte();
                    C.PreviousJob1 = BR.ReadByte();
                    C.Level = BR.ReadByte();
                    C.Experience = BR.ReadUInt64();

                    C.Str = BR.ReadUInt16();
                    C.Agi = BR.ReadUInt16();
                    C.Vit = BR.ReadUInt16();
                    C.Spi = BR.ReadUInt16();
                    C.StatPoints = BR.ReadUInt16();
                    C.CurHP = BR.ReadUInt16();
                    C.CurMP = BR.ReadUInt16();
                    C.Nobility.Donation = BR.ReadUInt64();

                    C.Nobility.ListPlace = -1;
                    if (C.Nobility.Donation >= 3000000)
                    {
                        C.Nobility.ListPlace = 50;
                        for (int i = 49; i >= 0; i--)
                        {
                            if (C.Nobility.Donation >= Game.World.EmpireBoard[i].Donation)
                                C.Nobility.ListPlace--;
                        }
                        if (C.Nobility.ListPlace < 50)
                        {
                            if (C.Nobility.Donation >= 30000000 && C.Nobility.Donation <= 100000000)
                                C.Nobility.Rank = Game.Ranks.Knight;
                            else if (C.Nobility.Donation >= 100000000 && C.Nobility.Donation <= 200000000)
                                C.Nobility.Rank = Game.Ranks.Baron;
                            else if (C.Nobility.Donation >= 200000000 && C.Nobility.Donation <= 300000000)
                                C.Nobility.Rank = Game.Ranks.Earl;
                            else if (C.Nobility.ListPlace >= 15 && C.Nobility.ListPlace <= 50)
                                C.Nobility.Rank = Game.Ranks.Duke;
                            else if (C.Nobility.ListPlace >= 3 && C.Nobility.ListPlace <= 15)
                                C.Nobility.Rank = Game.Ranks.Prince;
                            else if (C.Nobility.ListPlace <= 3)
                                C.Nobility.Rank = Game.Ranks.King;
                        }
                    }

                    C.Silvers = BR.ReadUInt32();
                    C.CPs = BR.ReadUInt32();
                    C.WHSilvers = BR.ReadUInt32();
                    C.VP = BR.ReadUInt64();
                    C.PKPoints = BR.ReadUInt16();
                    ushort GID = BR.ReadUInt16();

                    if (Features.Guilds.AllTheGuilds.Contains(GID))
                    {
                        C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];

                        uint Don = BR.ReadUInt32(); ;
                        byte GR = BR.ReadByte();
                        if (((Hashtable)C.MyGuild.Members[GR]).Contains(C.EntityID))
                        {
                            C.GuildDonation = Don;
                            C.GuildRank = (Features.GuildRank)GR;

                            C.MembInfo = (Features.MemberInfo)((Hashtable)C.MyGuild.Members[GR])[C.EntityID];
                            C.MembInfo.Level = C.Level;
                            C.GuildDonation = C.MembInfo.Donation;
                            C.GuildRank = C.MembInfo.Rank;
                        }
                        else
                            C.MyGuild = null;
                    }
                    else BR.ReadBytes(5);

                    C.Equips = new NewestCOServer.Game.Equipment();
                    C.Equips.ReadThis(BR);
                    C.Inventory = new ArrayList(40);
                    byte InventoryCount = BR.ReadByte();
                    for (byte i = 0; i < InventoryCount; i++)
                    {
                        Game.Item I = new NewestCOServer.Game.Item();
                        I.ReadThis(BR);
                        C.Inventory.Add(I);
                    }
                    C.Warehouses = new NewestCOServer.Game.Banks();
                    C.Warehouses.ReadThis(BR);

                    C.Skills = new Hashtable();
                    byte SkillCount = BR.ReadByte();
                    for (byte i = 0; i < SkillCount; i++)
                    {
                        Game.Skill S = new NewestCOServer.Game.Skill();
                        S.ReadThis(BR);
                        C.Skills.Add(S.ID, S);
                        if (S.ID == 3060)
                            C.CanReflect = true;
                    }

                    C.Profs = new Hashtable();
                    byte ProfCount = BR.ReadByte();
                    for (byte i = 0; i < ProfCount; i++)
                    {
                        Game.Prof P = new NewestCOServer.Game.Prof();
                        P.ReadThis(BR);
                        if (!C.Profs.Contains(P.ID))
                            C.Profs.Add(P.ID, P);
                    }

                    C.Friends = new Hashtable();
                    byte FriendCount = BR.ReadByte();
                    for (byte i = 0; i < FriendCount; i++)
                    {
                        Game.Friend F = new NewestCOServer.Game.Friend();
                        F.ReadThis(BR);
                        if (!C.Friends.Contains(F.UID))
                            C.Friends.Add(F.UID, F);
                    }

                    C.Enemies = new Hashtable();
                    byte EnemyCount = BR.ReadByte();
                    for (byte i = 0; i < EnemyCount; i++)
                    {
                        Game.Enemy E = new NewestCOServer.Game.Enemy();
                        E.ReadThis(BR);
                        if (!C.Enemies.Contains(E.UID))
                            C.Enemies.Add(E.UID, E);
                    }
                    try
                    {
                        C.DoubleExp = BR.ReadBoolean();
                        C.DoubleExpLeft = BR.ReadInt32();
                        C.BlessingLasts = BR.ReadInt32();
                        C.BlessingStarted = DateTime.FromBinary(BR.ReadInt64());

                        C.LuckyTime = BR.ReadUInt32();
                        C.ExpBallsUsedToday = BR.ReadByte();
                        C.Reborns = BR.ReadByte();
                        C.Merchant = (NewestCOServer.Game.MerchantTypes)BR.ReadByte();
                        C.VipLevel = BR.ReadByte();
                        try
                        {
                            C.LastLogin = DateTime.FromBinary(BR.ReadInt64());
                        }
                        catch { C.LastLogin = DateTime.Now; }
                        C.TrainTimeLeft = BR.ReadUInt16();
                        C.InOTG = BR.ReadBoolean();
                        C.LotteryUsed = BR.ReadByte();

                        try
                        {
                            C.WHPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));

                            if (!C.MyClient.ValidWHPass(C.WHPassword))
                                C.WHPassword = "0";
                        }
                        catch { C.WHPassword = "0"; C.UniversityPoints = 0; }

                        try
                        {
                            C.Spouse = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
                            C.UniversityPoints = BR.ReadUInt32();
                        }
                        catch
                        {
                            C.VipLevel = 0;
                            C.ExpBallsUsedToday = 0;
                            C.LotteryUsed = 0;
                            C.TrainTimeLeft = 0;
                            C.InOTG = false;
                            C.LotteryUsed = 0;
                            C.WHPassword = "0";
                            C.Spouse = "None";
                            C.UniversityPoints = 0;
                        }
                        LoadFlowerRank(Name);
                    }
                    catch (Exception ex) { Console.WriteLine(ex.ToString()); }
                    FS.Flush();
                    BR.Close();
                    FS.Close();
                    C.Loaded = true;
                }
                return C;
            }
            catch (Exception Exc) { Console.WriteLine(Exc); return null; }
        }
2nd error:

Code:
public void ReadThis(System.IO.BinaryReader BR)
        {
            TCWarehouse = new ArrayList(20);
            byte Count = BR.ReadByte();
            for (byte i = 0; i < Count; i++)
            {
                Item I = new Item();
                I.ReadThis(BR);
                if (I.ID != 0)
                    TCWarehouse.Add(I);
            }

            PCWarehouse = new ArrayList(20);
            Count = BR.ReadByte();
            for (byte i = 0; i < Count; i++)
            {
                Item I = new Item();
                I.ReadThis(BR);
                if (I.ID != 0)
                    PCWarehouse.Add(I);
            }

            ACWarehouse = new ArrayList(20);
            Count = BR.ReadByte();
            for (byte i = 0; i < Count; i++)
            {
                Item I = new Item();
                I.ReadThis(BR);
                if (I.ID != 0)
                    ACWarehouse.Add(I);
            }

            DCWarehouse = new ArrayList(20);
            Count = BR.ReadByte();
            for (byte i = 0; i < Count; i++)
            {
                Item I = new Item();
                I.ReadThis(BR);
                if (I.ID != 0)
                    DCWarehouse.Add(I);
            }

            BIWarehouse = new ArrayList(20);
            Count = BR.ReadByte();
            for (byte i = 0; i < Count; i++)
            {
                Item I = new Item();
                I.ReadThis(BR);
                if (I.ID != 0)
                    BIWarehouse.Add(I);
            }

            MAWarehouse = new ArrayList(20);
            Count = BR.ReadByte();
            for (byte i = 0; i < Count; i++)
            {
                Item I = new Item();
                I.ReadThis(BR);
                if (I.ID != 0)
                    MAWarehouse.Add(I);
            }
        }
    }
(in there it's line 768...)

3rd and last error:

Code:
public void ReadThis(System.IO.BinaryReader I)
        {
            byte Length = I.ReadByte();
            if (Length == 25)
            {
                UID = I.ReadUInt32();

                if (UID == 0) UID = (uint)Program.Rnd.Next(10000000);
                if (UID == 0) UID = (uint)World.Rnd.Next(10000000);

                ID = I.ReadUInt32();
                if (Database.DatabaseItems.Contains(ID))
                {
                    Plus = I.ReadByte();
                    Bless = I.ReadByte();
                    Enchant = I.ReadByte();
                    Soc1 = (Gem)I.ReadByte();
                    Soc2 = (Gem)I.ReadByte();
                    MaxDur = I.ReadUInt16();
                    CurDur = I.ReadUInt16();
                    FreeItem = I.ReadBoolean();
                    TalismanProgress = I.ReadUInt32();
                    Progress = I.ReadUInt16();
                    Color = (ArmorColor)I.ReadByte();
                }
                else
                {
                    UID = 0;
                    ID = 0;
                    I.ReadBytes(17);
                }
            }
            else I.ReadBytes(Length);
        }
    }
    public enum Ranks : byte { Serf = 0, Knight = 1, Baron = 3, Earl = 5, Duke = 7, Prince = 9, King = 12 }
(it's line 1224 I believe(in my source...)


PLZ HELP =D!!!btw they all have to do with " unable to read beyond end of stream" something like dat...
03/01/2010 09:29 Korvacs#2
Your reading to the end of the file, theres no more data to read. Thats what that exception means.
03/01/2010 15:27 killersub#3
Quote:
Originally Posted by Korvacs View Post
Your reading to the end of the file, theres no more data to read. Thats what that exception means.
so do u have ANY idea to fix cuz idk wtf is an exception knowing I'm a newbie here >.>...I would LOVE sum help from any1 cuz wit this error I can't even log in da client...
03/01/2010 19:31 killersub#4
I really need help...If anyone is WILLING to help me in anyway please comment or pm me cuz I really need this fixed even tv will help! come on :( help a poor noobley out :'(