public void loadFromDat(cDatFile datFile) { Console.WriteLine("Reading map from dat file..."); Stopwatch timer = new Stopwatch(); timer.Start(); int landBlockCounter = 0; int landBlockInfoCounter = 0; foreach (KeyValuePair <uint, cDatFileEntry> entry in datFile.fileCache) { if ((entry.Value.fileId & 0x0000FFFF) == 0x0000FFFF) { uint x = (uint)entry.Value.fileId >> 24; uint y = (uint)(entry.Value.fileId & 0x00FF0000) >> 16; cCellLandblock newLandblock = new cCellLandblock(entry.Value); surfaceLandblocks[(int)x].Add((int)y, newLandblock); landBlockCounter++; } else if ((entry.Value.fileId & 0x0000FFFE) == 0x0000FFFE) { uint x = (uint)entry.Value.fileId >> 24; uint y = (uint)(entry.Value.fileId & 0x00FF0000) >> 16; cLandblockInfo newLandblockInfo = new cLandblockInfo(entry.Value); landblockInfo[(int)x].Add((int)y, newLandblockInfo); landBlockInfoCounter++; } } timer.Stop(); Console.WriteLine("{0} landblocks and {1} landblockInfos read in {2} seconds.", landBlockCounter, landBlockInfoCounter, timer.ElapsedMilliseconds / 1000f); }
public void loadFromDat(cDatFile datFile) { Console.WriteLine("Reading map from dat file..."); Stopwatch timer = new Stopwatch(); timer.Start(); int landBlockCounter = 0; foreach (KeyValuePair <uint, cDatFileEntry> entry in datFile.fileCache) { byte[] buffer = new byte[1024]; StreamReader reader = new StreamReader(entry.Value.fileContent); if ((entry.Value.fileId & 0x0000FFFF) == 0x0000FFFF) { uint x = (uint)entry.Value.fileId >> 24; uint y = (uint)(entry.Value.fileId & 0x00FF0000) >> 16; cCellLandblock newLandblock = new cCellLandblock(buffer, reader); surfaceLandblocks[(int)x].Add((int)y, newLandblock); landBlockCounter++; } } timer.Stop(); Console.WriteLine("{0} landblocks read in {1} seconds.", landBlockCounter, timer.ElapsedMilliseconds / 1000f); }