コード例 #1
0
ファイル: World.cs プロジェクト: Terminologies/MoreTerra
		public void Clear()
		{
			header = new WorldHeader();
			tiles = null;
			chests = null;
			signs = null;
			footer = null;

			posChests = 0;
			posEnd = 0;
			posFooter = 0;
			posNpcs = 0;
			posSigns = 0;
			posTiles = 0;

			MaxX = 0;
			MaxY = 0;
			progress = 0;

			if (reader != null)
			{
				reader.Close();
				reader = null;
			}

			if (stream != null)
				stream = null;

			if (buffReader != null)
				buffReader = null;

			if (bw != null)
				bw = null;
		}
コード例 #2
0
ファイル: World.cs プロジェクト: Terminologies/MoreTerra
		// Ok so this is how this works.
		// It starts out by walking the file backwards to find the ending offset.
		// It then sets up the original path and starts scanning along the tiles.
		// When it finds an unknown tile type the program duplicates the current
		// path and makes one follow the path of it being non-important while
		// the other follows the path of being important.
		// When a path turns out not to fit the data it gets removed from the list.
		// All paths get checked in parallel.
		public TileImportance[] ScanWorld(String world, BackgroundWorker worker = null)
		{
			Timer t = null;
			TileImportance[] retList;

			if (worker != null)
			{
				bw = worker;
				t = new Timer(333);
				t.Elapsed += new ElapsedEventHandler(timer_ScanWorld);
				t.Enabled = true;
				t.Start();
			}

			stream = new FileStream(world, FileMode.Open, FileAccess.Read);
			reader = new BinaryReader(stream);
			buffReader = new BufferedBinaryReader(stream, 5000, 1000);

			posChests = new BackwardsScanner(stream, header).SeekToChestsBackwards();

			stream.Seek(0, SeekOrigin.Begin);
			ReadHeader();
			retList = ScanWorldTiles();

			if (bw != null)
			{
				t.Stop();
				bw = null;
			}

			reader.Close();

			return retList;
		}