Esempio n. 1
0
        private static void OnLoad()
        {
            try{
                if (!File.Exists(Path.Combine("Saves/Chat/", "Chat.bin")))
                {
                    return;
                }

                using (FileStream bin = new FileStream(Path.Combine("Saves/Chat/", "Chat.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                    int version = reader.ReadInt();

                    if (version >= 12)
                    {
                        s_PublicPlusIRC = reader.ReadBool();
                    }

                    if (version >= 11)
                    {
                        s_FilterPenalty = (FilterPenalty)reader.ReadInt();
                    }

                    if (version >= 10)
                    {
                        s_AllianceChat = reader.ReadBool();
                    }

                    if (version >= 9)
                    {
                        s_AllowFaction = reader.ReadBool();
                    }

                    if (version >= 8)
                    {
                        s_GuildMenuAccess = reader.ReadBool();
                    }

                    if (version >= 7)
                    {
                        s_MaxPmHistory = reader.ReadInt();
                    }

                    if (version >= 6)
                    {
                        s_IrcAutoReconnect = reader.ReadBool();
                    }

                    if (version >= 5)
                    {
                        s_IrcMaxAttempts = reader.ReadInt();
                    }

                    if (version >= 4)
                    {
                        s_IrcAutoConnect = reader.ReadBool();
                    }

                    if (version >= 3)
                    {
                        s_IrcStaffColor = (IrcColor)reader.ReadInt();
                    }

                    if (version >= 2)
                    {
                        s_IrcNick = reader.ReadString();
                    }

                    if (version >= 1)
                    {
                        s_IrcEnabled = reader.ReadBool();
                        s_IrcServer  = reader.ReadString();
                        s_IrcRoom    = reader.ReadString();
                        s_IrcPort    = reader.ReadInt();
                    }

                    if (version >= 0)
                    {
                        int count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            s_Filters.Add(reader.ReadString());
                        }

                        s_SpamLimiter     = reader.ReadDouble();
                        s_FilterBanLength = reader.ReadDouble();

                        if (version < 11)
                        {
                            reader.ReadBool();                     // FilterBan removed
                        }
                        s_ShowLocation = reader.ReadBool();
                        s_ShowStaff    = reader.ReadBool();
                        s_PublicStyle  = (PublicStyle)reader.ReadInt();

                        count = reader.ReadInt();
                        ChatInfo info;

                        for (int i = 0; i < count; ++i)
                        {
                            info = new ChatInfo(reader.ReadMobile());
                            if (!info.Load(reader))
                            {
                                return;
                            }
                        }
                    }

                    reader.End();
                }

                if (s_IrcAutoConnect)
                {
                    IrcConnection.Connection.Connect();
                }
            }catch { Errors.Report("ChatInfo-> OnLoad"); }
        }
Esempio n. 2
0
        private static void OnLoad()
        {
            try{

            if ( !File.Exists( Path.Combine( "Saves/Chat/", "Chat.bin" ) ) )
                return;

            using ( FileStream bin = new FileStream( Path.Combine( "Saves/Chat/", "Chat.bin" ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
            {
                GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );

                int version = reader.ReadInt();

                if ( version >= 12 )
                    s_PublicPlusIRC = reader.ReadBool();

                if ( version >= 11 )
                    s_FilterPenalty = (FilterPenalty)reader.ReadInt();

                if ( version >= 10 )
                    s_AllianceChat = reader.ReadBool();

                if ( version >= 9 )
                    s_AllowFaction = reader.ReadBool();

                if ( version >= 8 )
                    s_GuildMenuAccess = reader.ReadBool();

                if ( version >= 7 )
                    s_MaxPmHistory = reader.ReadInt();

                if ( version >= 6 )
                    s_IrcAutoReconnect = reader.ReadBool();

                if ( version >= 5 )
                    s_IrcMaxAttempts = reader.ReadInt();

                if ( version >= 4 )
                    s_IrcAutoConnect = reader.ReadBool();

                if ( version >= 3 )
                    s_IrcStaffColor = (IrcColor)reader.ReadInt();

                if ( version >= 2 )
                    s_IrcNick = reader.ReadString();

                if ( version >= 1 )
                {
                    s_IrcEnabled = reader.ReadBool();
                    s_IrcServer = reader.ReadString();
                    s_IrcRoom = reader.ReadString();
                    s_IrcPort = reader.ReadInt();
                }

                if ( version >= 0 )
                {
                    int count = reader.ReadInt();

                    for( int i = 0; i < count; ++i )
                        s_Filters.Add( reader.ReadString() );

                    s_SpamLimiter = reader.ReadDouble();
                    s_FilterBanLength = reader.ReadDouble();

                    if ( version < 11 )
                        reader.ReadBool(); // FilterBan removed

                    s_ShowLocation = reader.ReadBool();
                    s_ShowStaff = reader.ReadBool();
                    s_PublicStyle = (PublicStyle)reader.ReadInt();

                    count = reader.ReadInt();
                    ChatInfo info;

                    for( int i = 0; i < count; ++i )
                    {
                        info = new ChatInfo( reader.ReadMobile() );
                        if ( !info.Load( reader ) )
                            return;
                    }
                }

                reader.End();
            }

            if ( s_IrcAutoConnect )
                IrcConnection.Connection.Connect();

            }catch{ Errors.Report( "ChatInfo-> OnLoad" ); }
        }