/// <summary> /// /// </summary> /// <param name="binaryReader"></param> public Cartridge(BinaryReader binaryReader) { try { objects = new Dictionary <short, Objects>(); ok = false; ushort count = SeekFile.GetUShort(binaryReader); for (int i = 0; i < count; i++) { short objectId = SeekFile.GetShort(binaryReader); long address = SeekFile.GetLong(binaryReader); Objects obj = new Objects(objectId, address); objects.Add(obj.ObjectId, obj); } long headerLenght = SeekFile.GetLong(binaryReader); latitude = SeekFile.GetDouble(binaryReader); longitude = SeekFile.GetDouble(binaryReader); altitude = SeekFile.GetDouble(binaryReader); unknown0 = SeekFile.GetLong(binaryReader); unknown1 = SeekFile.GetLong(binaryReader); splashScreenId = SeekFile.GetShort(binaryReader); smallIconId = SeekFile.GetShort(binaryReader); typeOfCartridge = SeekFile.GetASCIIZ(binaryReader); playerName = SeekFile.GetASCIIZ(binaryReader); unknown2 = SeekFile.GetLong(binaryReader); unknown3 = SeekFile.GetLong(binaryReader); cartridgeName = SeekFile.GetASCIIZ(binaryReader); cartridgeGuid = SeekFile.GetASCIIZ(binaryReader); cartridgeDesc = SeekFile.GetASCIIZ(binaryReader); startLocationDesc = SeekFile.GetASCIIZ(binaryReader); version = SeekFile.GetASCIIZ(binaryReader); author = SeekFile.GetASCIIZ(binaryReader); company = SeekFile.GetASCIIZ(binaryReader); recommendedDevice = SeekFile.GetASCIIZ(binaryReader); unknown4 = SeekFile.GetLong(binaryReader); completionCode = SeekFile.GetASCIIZ(binaryReader); foreach (Objects obj in objects.Values) { obj.LoadObject(binaryReader); } ok = true; } catch (Exception ex) { Trace.DoTrace(Trace.TraceCategories.Cartridge, ex); } }
/// <summary> /// Read the object directly from the file /// </summary> /// <param name="binaryReader">filehandle</param> /// <returns>True, if no errors occured</returns> public bool LoadObject(BinaryReader binaryReader) { bool retValue = false; binaryReader.BaseStream.Seek(address, SeekOrigin.Begin); try { long length; if (objectId == 0) { length = SeekFile.GetLong(binaryReader); data = new byte[length]; for (int i = 0; i < length; i++) { data[i] = binaryReader.ReadByte(); } } else { byte validObj = SeekFile.GetByte(binaryReader); if (validObj != 0) { objectType = SeekFile.GetLong(binaryReader); length = SeekFile.GetLong(binaryReader); data = new byte[length]; for (int i = 0; i < length; i++) { data[i] = binaryReader.ReadByte(); } } } retValue = true; } catch (Exception ex) { Trace.DoTrace(Trace.TraceCategories.Cartridge, ex); } return(retValue); }