コード例 #1
0
        //将data从内存写入本地,而后清除内存
        public static void WriteLoadedChunks()
        {
            // 对每一个temp中载入的chunk
            foreach (string chunkIndex in TempChunkData.Keys)
            {
                Index  index  = Index.FromString(chunkIndex);
                string region = GetParentRegion(index).ToString();

                // 检查一个区域是否已经载入,没有就在如
                if (LoadRegionData(GetParentRegion(index)) == false)
                {
                    CreateRegionFile(GetParentRegion(index));
                    LoadRegionData(GetParentRegion(index));
                }

                // 将chunk数据写入那啥
                int chunkRegionIndex = GetChunkRegionIndex(index);
                LoadedRegions[region][chunkRegionIndex] = TempChunkData[chunkIndex];
            }
            TempChunkData.Clear();


            // 把每一个区域的都写入
            foreach (string regionIndex in LoadedRegions.Keys)
            {
                WriteRegionFile(regionIndex);
            }
            LoadedRegions.Clear();
        }
コード例 #2
0
        private static void WriteRegionFile(string regionIndex)
        {
            string[] regionData = LoadedRegions[regionIndex];

            StreamWriter writer = new StreamWriter(GetRegionPath(Index.FromString(regionIndex)));
            int          count  = 0;

            foreach (string chunk in regionData)
            {
                writer.Write(chunk);
                if (count != regionData.Length - 1)
                {
                    writer.Write((char)ushort.MaxValue);
                }
                count++;
            }

            writer.Flush();
            writer.Close();
        }