Beispiel #1
0
        private void MyThreadCalc(object Param)
        {
            ThreadParam tp = (ThreadParam)Param;

            String[] files = tp.files;

            foreach (String s in files)
            {
                Parser    p = new Parser(s, errwr, outwr, writeOnlyCheck.Checked, DelimiterCheck.Checked, StaticCheck.Checked, TileCheck.Checked);
                BlockFile b = p.Parse();
                lock (f.blockfileslist)
                {
                    if (numBlocks.Value > 0 && f.blockfileslist.Count >= numBlocks.Value)
                    {
                        stopcollect = true;
                        if (parseOnly.Checked)
                        {
                            break;
                        }
                    }
                    if (!stopcollect)
                    {
                        f.blockfileslist.Add(b);
                    }
                }
                if (closed)
                {
                    break;
                }
                progressBar1.BeginInvoke(new IncDelegate(Inc));
            }
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            handle_select        = false;
            this.blockbox.Text   = "";
            blocklist.DataSource = null;
            bool genera = extendedCheck.Checked;

            stopcollect       = false;
            groupBox1.Enabled = false;
            groupBox2.Enabled = false;
            f = new Facet();
            blocklist.DataSource = null;
            GC.Collect();
            String[]  files = Directory.GetFiles(textBox2.Text, "*.dat");
            IComparer icomp = new FileComparer();

            Array.Sort(files, icomp);
            progressBar1.Minimum = 0;
            progressBar1.Maximum = (parseOnly.Checked && numBlocks.Value > 0) ? (int)numBlocks.Value : files.Length;
            progressBar1.Value   = 0;
            errwr = new StreamWriter("error.log");
            outwr = null;
            if (genera)
            {
                outwr = new StreamWriter("outuput.log");
            }
            int div = (parseOnly.Checked && numBlocks.Value > 0) ? (int)numBlocks.Value : files.Length / 3;

            if (div > 50)
            {
                bw1.RunWorkerAsync(files);
            }
            else
            {
                foreach (String s in files)
                {
                    Parser    p = new Parser(s, errwr, outwr, writeOnlyCheck.Checked, DelimiterCheck.Checked, StaticCheck.Checked, TileCheck.Checked);
                    BlockFile b = p.Parse();
                    if (numBlocks.Value > 0 && f.blockfileslist.Count >= numBlocks.Value)
                    {
                        stopcollect = true;
                        if (parseOnly.Checked)
                        {
                            break;
                        }
                    }
                    if (!stopcollect)
                    {
                        f.blockfiles.AddLast(b);
                        f.blockfileslist.Add(b);
                    }
                    Inc();
                    if (closed)
                    {
                        break;
                    }
                }
                bw1_RunWorkerCompleted(null, null);
            }
        }
Beispiel #3
0
        private void blocklist_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!handle_select)
            {
                return;
            }

            BlockFile bf = blocklist.SelectedItem as BlockFile;

            blockbox.Text = bf.Dump();
        }
        private void button4_Click(object sender, EventArgs e)
        {
            this.Text = "Searching...";
            bool trovato = false;

            for (; enumerator != null; enumerator = enumerator.Next)
            {
                BlockFile bfile  = enumerator.Value;
                int       angoli = 0;
                foreach (MapPoint m in bfile.blocks)
                {
                    if (m.offsetx == 0 && m.offsety == 0)
                    {
                        angoli++;
                    }
                    if (m.offsetx == 0 && m.offsety == 63)
                    {
                        angoli++;
                    }
                    if (m.offsetx == 63 && m.offsety == 0)
                    {
                        angoli++;
                    }
                    if (m.offsetx == 63 && m.offsety == 63)
                    {
                        angoli++;
                    }
                }
                if (angoli <= 2)
                {
                    trovato = true;
                    break;
                }
            }
            if (!trovato)
            {
                enumerator = facet.blockfiles.First;
            }
            DisplayGrid();
        }
Beispiel #5
0
        public BlockFile Parse()
        {
            BlockFile result = new BlockFile();

            result.header.facet  = br.ReadByte();
            result.header.FileID = br.ReadUInt16();

            fileid = result.header.FileID;

            if (output != null)
            {
                WriteFileOut(result.header.Dump());
            }

            mp         = new MapPoint();
            mp.offsetx = 0;
            mp.x       = AdjustX(0);
            mp.offsety = 0;
            mp.y       = AdjustY(0);
            mp.lt      = ReadLandtile();


            ushort currentx = 0;
            ushort currenty = 0;

            byte type1, type2;

            while (br.BaseStream.Position < br.BaseStream.Length - 3)
            {
                type1 = br.ReadByte();
                type2 = br.ReadByte();
                if (type1 == 0 && type2 == 0) //Landtile
                {
                    currenty++;
                    if (currenty == BLOCK_HEIGHT)
                    {
                        currentx++;
                        currenty = 0;
                        if (currentx >= BLOCK_WIDTH)
                        {
                            WriteFileErr("FileID=" + fileid + ", ERROR X is too huge: " + currentx);
                        }
                    }
                    if ((mp.delimiter_list.Count > 0 && delimitercheck) || (mp.static_list.Count > 0 && staticcheck) || (mp.delimiter_list.Count == 0 && mp.static_list.Count == 0 && tilecheck))
                    {
                        if (!writeonlyfiles)
                        {
                            result.blocks.Add(mp);
                        }
                        if (output != null)
                        {
                            WriteFileOut(mp.Dump());
                        }
                    }
                    mp         = new MapPoint();
                    mp.offsetx = currentx;
                    mp.x       = AdjustX(currentx);
                    mp.offsety = currenty;
                    mp.y       = AdjustY(currenty);
                    mp.lt      = ReadLandtile();
                }
                else if (type1 == 0 && type2 != 0) //Static
                {
                    for (int i = 0; i < type2; i++)
                    {
                        if (i > 0)
                        {
                            ushort zero = br.ReadUInt16();
                            if (zero != 0)
                            {
                                WriteFileErr("FileID=" + fileid + ", X=" + AdjustX(currentx) + " (offset " + currentx + "), Y=" + AdjustY(currenty) + " (offset " + currenty + "), error static header placeholder zero byte is not zero: " + zero);
                            }
                        }
                        mp.static_list.Add(ReadStatic());
                    }
                }
                else if (type1 > 0)
                {
                    br.BaseStream.Position--;
                    for (int i = 0; i < type1; i++)
                    {
                        if (i > 0)
                        {
                            byte zero = br.ReadByte();
                            if (zero != 0)
                            {
                                WriteFileErr("FileID=" + fileid + ", X=" + AdjustX(currentx) + " (offset " + currentx + "), Y=" + AdjustY(currenty) + " (offset " + currenty + "), error delimiter type1 placeholder zero byte is not zero: " + zero);
                            }
                        }
                        mp.delimiter_list.Add(ReadDelimiter());
                    }
                }
                else
                {
                    WriteFileErr("FileID=" + fileid + ", ERROR Type undefined, type1:" + type1 + ", type2:" + type2);
                }
            }
            if ((mp.delimiter_list.Count > 0 && delimitercheck) || (mp.static_list.Count > 0 && staticcheck) || (mp.delimiter_list.Count == 0 && mp.static_list.Count == 0 && tilecheck))
            {
                if (!writeonlyfiles)
                {
                    result.blocks.Add(mp);
                }
                if (output != null)
                {
                    WriteFileOut(mp.Dump());
                }
            }
            br.Close();
            return(result);
        }