private void AddToList()
        {
            Range range = new Range(RangeStart, RangeEnd);

            if (Ranges.Contains(range))
            {
                ShowDialog("Information!", "Range has already been entered into the list");
            }
            else
            {
                Ranges.Add(range);
            }

            RangeStart = String.Empty;
            RangeEnd   = String.Empty;

            IsRangeStartFocussed = true;
            IsRangeEndFocussed   = false;
        }
        public bool IsValid(long sequenceNumber, bool isLast)
        {
            if (_reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
            {
                if (isLast)
                {
                    if (Last == 0)
                    {
                        if (Ranges.Count > 0)
                        {
                            return(sequenceNumber > Ranges[Ranges.Count - 1].Upper);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        return(sequenceNumber == Last);
                    }
                }
                else if (Last > 0)
                {
                    return(sequenceNumber < Last);
                }
            }
            else
            {
                if (_isLastKnown)
                {
                    return(Ranges.Contains(sequenceNumber));
                }
            }

            return(true);
        }
示例#3
0
        /// <summary>
        /// Load the String.srl Data
        /// </summary>
        static void LoadData()
        {
            Log("Initializing String Reloads...", true);
            StartPipe();
            var Data = new SRLData3();

            try {
                using (StructReader Reader = new StructReader(TLMap)) {
                    if (Reader.PeekInt() == 0x43424C54)
                    {
                        TLBCParser(Reader);
                        return;
                    }
                    if (Reader.PeekInt() == 0x4C5253)
                    {
                        SRL1Parser(Reader);
                        return;
                    }
                    if (Reader.PeekInt() == 0x324C5253)
                    {
                        SRL2Parser(Reader);
                        return;
                    }
                    if (Reader.PeekInt() != 0x334C5253)
                    {
                        Error("Failed to Initialize - Corrupted Data");
                        Thread.Sleep(5000);
                        Environment.Exit(2);
                    }

                    Reader.Seek(4, 0);
                    if (Reader.ReadUInt16() > 1)
                    {
                        Error("Unexpected SRL Database Format");
                        Thread.Sleep(5000);
                        Environment.Exit(2);
                    }
                    Reader.Seek(0, 0);

                    Reader.ReadStruct(ref Data);

                    Log("Initializing Replaces...", true);
                    for (uint i = 0; i < Data.RepOri.LongLength; i++)
                    {
                        AppendArray(ref Replaces, Data.RepOri[i]);
                        AppendArray(ref Replaces, Data.RepTrg[i]);
                    }

                    Log("Processing Char Reloads... 1/3", true);
                    CharRld = new Dictionary <ushort, char>();
                    for (uint i = 0; i < Data.OriLetters.LongLength; i++)
                    {
                        char cOri = Data.OriLetters[i];
                        char cPrx = Data.MemoryLetters[i];
                        if (!CharRld.ContainsKey(cPrx))
                        {
                            CharRld.Add(cPrx, cOri);
                            AppendArray(ref Replaces, cOri.ToString());
                            AppendArray(ref Replaces, cPrx.ToString());

                            Range Range = new Range()
                            {
                                Min = cPrx,
                                Max = cPrx
                            };

                            if (!Ranges.Contains(Range))
                            {
                                Ranges.Add(Range);
                            }
                        }
                    }

                    Log("Processing Char Reloads... 2/3", true);
                    UnkRld = new Dictionary <ushort, char>();
                    for (uint i = 0; i < Data.UnkChars.LongLength; i++)
                    {
                        ushort c = Data.UnkChars[i];
                        if (!UnkRld.ContainsKey(c))
                        {
                            UnkRld.Add(c, Data.UnkReps[i]);
                        }
                    }

                    if (AutoUnks)
                    {
                        Log("Processing Char Reloads... 3/3", true);
                        for (uint i = 0; i < Data.OriLetters.LongLength; i++)
                        {
                            char   Char   = Data.MemoryLetters[i];
                            char   OChar  = Data.OriLetters[i];
                            byte[] Buffer = WriteEncoding.GetBytes(Char.ToString());
                            if (BitConverter.IsLittleEndian)
                            {
                                Buffer = Buffer.Reverse().ToArray();
                            }

                            if (Buffer.Length > 2)
                            {
                                Warning("Failed to generate Auto Unk Char to the char {0}", Char);
                                continue;
                            }

                            byte[] DW = new byte[2];
                            Buffer.CopyTo(DW, 0);
                            ushort Unk = BitConverter.ToUInt16(DW, 0);
#if DEBUG
                            Log("Unk Added: 0x{0:X4} from {1}", true, Unk, OChar);
#endif
                            if (UnkRld.ContainsKey(Unk))
                            {
                                continue;
                            }

                            UnkRld.Add(Unk, OChar);

                            DW[1] = 0xFF;
                            Unk   = BitConverter.ToUInt16(DW, 0);
#if DEBUG
                            Log("Unk Added: 0x{0:X4} from {1}", true, Unk, OChar);
#endif
                            if (UnkRld.ContainsKey(Unk))
                            {
                                continue;
                            }

                            UnkRld.Add(Unk, OChar);
                        }
                    }


                    Log("Chars Reloads Initialized, Total entries: {0} + {1}", true, UnkRld.Count, CharRld.Count);
                    Log("Processing String Reloads...", true);
                    List <string> Temp = new List <string>();
                    StrRld = CreateDictionary();
                    long ReloadEntries = 0, MaskEntries = 0;
                    foreach (SRLDatabase2 Database in Data.Databases)
                    {
                        for (uint i = 0; i < Database.Original.LongLength; i++)
                        {
                            Application.DoEvents();
                            string str = SimplfyMatch(Database.Original[i]);
                            if (AllowDuplicates || !ContainsKey(str, true))
                            {
                                if (IsMask(Database.Original[i]))
                                {
                                    if (LiteralMaskMatch)
                                    {
                                        AddEntry(str, ReplaceChars(Database.Replace[i]));
                                        ReloadEntries++;
                                    }

                                    if (Database.Replace[i].StartsWith(AntiMaskParser))
                                    {
                                        Database.Replace[i] = Database.Replace[i].Substring(AntiMaskParser.Length, Database.Replace[i].Length - AntiMaskParser.Length);
                                    }
                                    else
                                    {
                                        //Prevent Duplicates
                                        if (!Temp.Contains(Database.Original[i]))
                                        {
                                            Temp.Add(Database.Original[i]);
                                        }
                                        else
                                        {
                                            continue;
                                        }

                                        AddMask(Database.Original[i], ReplaceChars(Database.Replace[i]));
                                        MaskEntries++;
                                        continue;
                                    }
                                }
                                else
                                {
                                    AddEntry(str, ReplaceChars(Database.Replace[i]));
                                    ReloadEntries++;
                                }
                            }
                        }

                        if (MultipleDatabases)
                        {
                            FinishDatabase();
                        }
                    }
                    Log("String Reloads Initialized, {0} Databases Created, {1} Reload Entries, {2} Mask Entries", true, Databases.Count, ReloadEntries, MaskEntries);


                    Log("Registring Databases Name...", true);
                    DBNames = new Dictionary <long, string>();
                    for (long i = 0; i < Data.Databases.Length; i++)
                    {
                        DBNames[i] = Data.Databases[i].Name;

                        Log("Database ID: {0} Named As: {1}", true, i, DBNames[i]);
                    }

                    if (Data.Version > 0)
                    {
                        Log("Loading Intros...", true);
                        SRLIntro Intros = new SRLIntro();
                        Reader.ReadStruct(ref Intros);
                        Introduction = Intros.Intros;
                    }
                    else
                    {
                        Warning("The SRL Data is outdated, try rebuild it.");
                    }

                    Reader.Close();
                }

                Log("Loading Complete.", true);
            } catch (Exception ex) {
                Error("Failed to Execute: {0}\n=========\n{1}", false, ex.Message, ex.StackTrace);
                Thread.Sleep(5000);
                Environment.Exit(2);
            }
        }