public string getObjectJsonString(int objectId) { int objectPointer = objectPointerTable[objectId]; reader.Pointer = objectPointer; int objectClassId = reader.ReadInt(); StringBuilder objectBuilder = new StringBuilder(); objectBuilder.Append(getObjectBuilder(objectClassId)); return(objectBuilder.ToString()); }
private int getClassId(int objectId) { int objectPointer = objectPointerTable[objectId]; reader.Pointer = objectPointer; return(reader.ReadInt()); }
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(); } }