public JsonUnpacker(D2OReader reader, Dictionary <int, int> objectPointerTable, Dictionary <int, GameDataClassDefinition> classDefinitions) { this.reader = reader; this.objectPointerTable = objectPointerTable; this.classDefinitions = classDefinitions; jsonBuilder = new StringBuilder(); }
int contentOffset = 0; //or uint? public App(string d2oFilePath) { objectPointerTable = new Dictionary <int, int>(); classDefinitions = new Dictionary <int, GameDataClassDefinition>(); using (FileStream d2oFile = File.Open(d2oFilePath, FileMode.Open)) using (reader = new D2OReader(d2oFile)) { string headerString = reader.ReadAscii(3); if (!headerString.Equals("D2O")) { reader.Pointer = 0; string headers = reader.ReadUtf8(); short formatVersion = reader.ReadShort(); int len = reader.ReadInt(); reader.Pointer = reader.Pointer + len; contentOffset = reader.Pointer; int streamStartIndex = (contentOffset + 7); //or uint? headers = reader.ReadAscii(3); if (!headers.Equals("D2O")) { throw new InvalidDataException("Header doesn't equal the string 'D2O' : Corrupted file"); } } readObjectPointerTable(); //printObjectPointerTable(); readClassTable(); printClassTable(); readGameDataProcessor(); //TODO: implement unpackObjectsAsJson(); writeJsonFile(true); //printAllObjects(); //call after unpackObjectsAsJson(); searchObjectById(); //call after unpackObjectsAsJson(); } }
internal void AddField(D2OReader reader) { GameDataField field = new GameDataField(reader); Fields.Add(field); }