static void SaveInfos(BinaryWriter writer) { var section = new SaveInfoSection(); section.Type = ScummHelper.MakeTag('I', 'N', 'F', 'O'); section.Version = InfoSectionVersion; section.Size = SaveInfoSectionSize; // TODO: still save old format for older versions section.TimeTValue = 0; section.PlayTime = 0; //TimeDate curTime; //_system->getTimeAndDate(curTime); //section.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF); //section.time = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF); writer.WriteUInt32BigEndian(section.Type); writer.WriteUInt32BigEndian(section.Version); writer.WriteUInt32BigEndian(section.Size); writer.WriteUInt32BigEndian(section.TimeTValue); writer.WriteUInt32BigEndian(section.PlayTime); writer.WriteUInt32BigEndian(section.Date); writer.WriteUInt16(section.Time); }
static SaveStateMetaInfos LoadInfos(BinaryReader reader) { var stuff = new SaveStateMetaInfos(); var section = new SaveInfoSection(); section.Type = ScummHelper.SwapBytes(reader.ReadUInt32()); if (section.Type != ScummHelper.MakeTag('I', 'N', 'F', 'O')) { return null; } section.Version = ScummHelper.SwapBytes(reader.ReadUInt32()); section.Size = ScummHelper.SwapBytes(reader.ReadUInt32()); // If we ever extend this we should add a table containing the sizes corresponding to each // version, so that we are able to properly verify their correctness. if (section.Version == InfoSectionVersion && section.Size != SaveInfoSectionSize) { //warning("Info section is corrupt"); reader.BaseStream.Seek(section.Size, SeekOrigin.Current); return null; } section.TimeTValue = ScummHelper.SwapBytes(reader.ReadUInt32()); section.PlayTime = ScummHelper.SwapBytes(reader.ReadUInt32()); // For header version 1, we load the data in with our old method if (section.Version == 1) { //time_t tmp = section.timeTValue; //tm *curTime = localtime(&tmp); //stuff->date = (curTime->tm_mday & 0xFF) << 24 | ((curTime->tm_mon + 1) & 0xFF) << 16 | (curTime->tm_year + 1900) & 0xFFFF; //stuff->time = (curTime->tm_hour & 0xFF) << 8 | (curTime->tm_min) & 0xFF; stuff.Date = 0; stuff.Time = 0; } if (section.Version >= 2) { section.Date = ScummHelper.SwapBytes(reader.ReadUInt32()); section.Time = ScummHelper.SwapBytes(reader.ReadUInt16()); stuff.Date = section.Date; stuff.Time = section.Time; } stuff.PlayTime = section.PlayTime; // Skip over the remaining (unsupported) data if (section.Size > SaveInfoSectionSize) reader.BaseStream.Seek(section.Size - SaveInfoSectionSize, SeekOrigin.Current); return stuff; }