Esempio n. 1
0
        ///<summary>
        /// Two modes of operation: if passed true, save all Chunks in one go.  If passed false, save up to two chunks.
        /// Return true if all chunks have been saved.
        ///</summary>
        public bool SaveChunks(bool par1, IProgressUpdate par2IProgressUpdate)
        {
            int i = 0;

            for (int j = 0; j < chunkList.Count; j++)
            {
                Chunk chunk = chunkList[j];

                if (par1)
                {
                    SaveChunkExtraData(chunk);
                }

                if (!chunk.NeedsSaving(par1))
                {
                    continue;
                }

                SaveChunkData(chunk);
                chunk.IsModified = false;

                if (++i == 24 && !par1)
                {
                    return(false);
                }
            }

            if (par1)
            {
                if (chunkLoader == null)
                {
                    return(true);
                }

                chunkLoader.SaveExtraData();
            }

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Two modes of operation: if passed true, save all Chunks in one go.  If passed false, save up to two chunks.
        /// Return true if all chunks have been saved.
        /// </summary>
        public virtual bool SaveChunks(bool par1, IProgressUpdate par2IProgressUpdate)
        {
            int i = 0;
            int j = 0;

            if (par2IProgressUpdate != null)
            {
                for (int k = 0; k < Chunks.Length; k++)
                {
                    if (Chunks[k] != null && Chunks[k].NeedsSaving(par1))
                    {
                        j++;
                    }
                }
            }

            int l = 0;

            for (int i1 = 0; i1 < Chunks.Length; i1++)
            {
                if (Chunks[i1] == null)
                {
                    continue;
                }

                if (par1)
                {
                    SaveExtraChunkData(Chunks[i1]);
                }

                if (!Chunks[i1].NeedsSaving(par1))
                {
                    continue;
                }

                SaveChunk(Chunks[i1]);
                Chunks[i1].IsModified = false;

                if (++i == 2 && !par1)
                {
                    return(false);
                }

                if (par2IProgressUpdate != null && ++l % 10 == 0)
                {
                    par2IProgressUpdate.SetLoadingProgress((l * 100) / j);
                }
            }

            if (par1)
            {
                if (ChunkLoader == null)
                {
                    return(true);
                }

                ChunkLoader.SaveExtraData();
            }

            return(true);
        }