2017-03-15 08:12:21 -04:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace ACE.DatLoader
|
|
|
|
|
{
|
|
|
|
|
public class CellDatDatabase : DatDatabase
|
|
|
|
|
{
|
2018-11-20 07:45:09 -06:00
|
|
|
public CellDatDatabase(string filename, bool keepOpen = false) : base(filename, keepOpen)
|
2017-03-15 08:12:21 -04:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ExtractLandblockContents(string path)
|
|
|
|
|
{
|
2018-01-23 04:02:39 -06:00
|
|
|
foreach (KeyValuePair<uint, DatFile> entry in AllFiles)
|
2017-03-15 08:12:21 -04:00
|
|
|
{
|
2017-05-06 18:20:41 -07:00
|
|
|
string thisFolder = Path.Combine(path, (entry.Value.ObjectId >> 16).ToString("X4"));
|
2017-03-15 08:12:21 -04:00
|
|
|
|
2017-05-06 18:20:41 -07:00
|
|
|
if (!Directory.Exists(thisFolder))
|
|
|
|
|
Directory.CreateDirectory(thisFolder);
|
2017-03-15 08:12:21 -04:00
|
|
|
|
2017-05-06 18:20:41 -07:00
|
|
|
// Use the DatReader to get the file data - file blocks can extend over block size.
|
2018-01-23 04:02:39 -06:00
|
|
|
DatReader dr = GetReaderForFile(entry.Value.ObjectId);
|
2017-03-15 08:12:21 -04:00
|
|
|
|
2017-05-06 18:20:41 -07:00
|
|
|
string hex = entry.Value.ObjectId.ToString("X8");
|
|
|
|
|
string thisFile = Path.Combine(thisFolder, hex + ".bin");
|
|
|
|
|
File.WriteAllBytes(thisFile, dr.Buffer);
|
2017-03-15 08:12:21 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|