Ejemplo n.º 1
0
        private void Func_48430_a(string par1File, string par2File, WorldChunkManager par3WorldChunkManager, int par4, int par5, IProgressUpdate par6IProgressUpdate)
        {
            try
            {
                FileInfo   file        = new FileInfo(par2File);
                string     s           = file.Name;
                RegionFile regionfile  = new RegionFile(par2File);
                RegionFile regionfile1 = new RegionFile(IOPath.Combine(par1File, (new StringBuilder()).Append(s.Substring(0, s.Length - ".mcr".Length)).Append(".mca").ToString()));

                for (int i = 0; i < 32; i++)
                {
                    for (int j = 0; j < 32; j++)
                    {
                        if (!regionfile.IsChunkSaved(i, j) || regionfile1.IsChunkSaved(i, j))
                        {
                            continue;
                        }

                        Stream datainputstream = regionfile.GetChunkFileStream(i, j);

                        if (datainputstream == null)
                        {
                            Console.WriteLine("Failed to fetch input stream");
                        }
                        else
                        {
                            NBTTagCompound nbttagcompound = CompressedStreamTools.Read(new BinaryReader(datainputstream));
                            datainputstream.Close();

                            NBTTagCompound nbttagcompound1 = nbttagcompound.GetCompoundTag("Level");

                            AnvilConverterData anvilconverterdata = ChunkLoader.Load(nbttagcompound1);
                            NBTTagCompound     nbttagcompound2    = new NBTTagCompound();
                            NBTTagCompound     nbttagcompound3    = new NBTTagCompound();
                            nbttagcompound2.SetTag("Level", nbttagcompound3);

                            ChunkLoader.ConvertToAnvilFormat(anvilconverterdata, nbttagcompound3, par3WorldChunkManager);

                            Stream dataoutputstream = regionfile1.GetChunkDataOutputStream(i, j);
                            CompressedStreamTools.Write(nbttagcompound2, new BinaryWriter(dataoutputstream));
                            dataoutputstream.Close();
                        }
                    }

                    int k = (int)Math.Round((100D * (double)(par4 * 1024)) / (double)(par5 * 1024));
                    int l = (int)Math.Round((100D * (double)((i + 1) * 32 + par4 * 1024)) / (double)(par5 * 1024));

                    if (l > k)
                    {
                        par6IProgressUpdate.SetLoadingProgress(l);
                    }
                }

                regionfile.Close();
                regionfile1.Close();
            }
            catch (IOException ioexception)
            {
                Utilities.LogException(ioexception);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns an input stream for the specified chunk. Args: worldDir, chunkX, chunkZ
        /// </summary>
        public static Stream GetChunkFileStream(string par0File, int par1, int par2)
        {
            RegionFile regionfile = CreateOrLoadRegionFile(par0File, par1, par2);

            return(regionfile.GetChunkFileStream(par1 & 0x1f, par2 & 0x1f));
        }