Updated info savegame chunk:
- now we save the date and time(although in localtime) in the same format as we pass it to the dialog (See "ATTN: Porters. Notes about time() implementation and thumbnails" on -devel) - old format is kept for compatibility for older ScummVM versions svn-id: r19036
This commit is contained in:
parent
961cd63ae9
commit
56c9058706
1 changed files with 30 additions and 17 deletions
|
@ -60,15 +60,18 @@ struct SaveInfoSection {
|
||||||
uint32 version;
|
uint32 version;
|
||||||
uint32 size;
|
uint32 size;
|
||||||
|
|
||||||
uint32 timeTValue;
|
uint32 timeTValue; // Obsolete since version 2, but kept for compatibility
|
||||||
uint32 playtime;
|
uint32 playtime;
|
||||||
|
|
||||||
|
uint32 date;
|
||||||
|
uint16 time;
|
||||||
} GCC_PACK;
|
} GCC_PACK;
|
||||||
|
|
||||||
#if !defined(__GNUC__)
|
#if !defined(__GNUC__)
|
||||||
#pragma END_PACK_STRUCTS
|
#pragma END_PACK_STRUCTS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define INFOSECTION_VERSION 1
|
#define INFOSECTION_VERSION 2
|
||||||
|
|
||||||
void ScummEngine::requestSave(int slot, const char *name, bool temporary) {
|
void ScummEngine::requestSave(int slot, const char *name, bool temporary) {
|
||||||
_saveLoadSlot = slot;
|
_saveLoadSlot = slot;
|
||||||
|
@ -546,22 +549,24 @@ bool ScummEngine::loadInfos(Common::InSaveFile *file, InfoStuff *stuff) {
|
||||||
section.timeTValue = file->readUint32BE();
|
section.timeTValue = file->readUint32BE();
|
||||||
section.playtime = file->readUint32BE();
|
section.playtime = file->readUint32BE();
|
||||||
|
|
||||||
|
// for compatibility for older version we
|
||||||
|
// to load in with our old method
|
||||||
|
if (section.version == 1) {
|
||||||
time_t curTime_ = section.timeTValue;
|
time_t curTime_ = section.timeTValue;
|
||||||
tm *curTime = localtime(&curTime_);
|
tm *curTime = localtime(&curTime_);
|
||||||
stuff->date = (curTime->tm_mday & 0xFF) << 24 | ((curTime->tm_mon + 1) & 0xFF) << 16 | (curTime->tm_year + 1900) & 0xFFFF;
|
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->time = (curTime->tm_hour & 0xFF) << 8 | (curTime->tm_min) & 0xFF;
|
||||||
stuff->playtime = section.playtime;
|
}
|
||||||
|
|
||||||
// if we extend the header we should check here for the version
|
if (section.version >= 2) {
|
||||||
// e.g.:
|
section.date = file->readUint32BE();
|
||||||
// if (header.version == 2) {
|
section.time = file->readUint16BE();
|
||||||
// // load some things here
|
|
||||||
// }
|
stuff->date = section.date;
|
||||||
//
|
stuff->time = section.time;
|
||||||
// if (header.version == 3) {
|
}
|
||||||
// // ...
|
|
||||||
// }
|
stuff->playtime = section.playtime;
|
||||||
// and so on...
|
|
||||||
|
|
||||||
// skip all newer features, this could make problems if some older version uses more space for
|
// skip all newer features, this could make problems if some older version uses more space for
|
||||||
// saving informations, but this should NOT happen
|
// saving informations, but this should NOT happen
|
||||||
|
@ -578,14 +583,22 @@ void ScummEngine::saveInfos(Common::OutSaveFile* file) {
|
||||||
section.version = INFOSECTION_VERSION;
|
section.version = INFOSECTION_VERSION;
|
||||||
section.size = sizeof(SaveInfoSection);
|
section.size = sizeof(SaveInfoSection);
|
||||||
|
|
||||||
|
// still save old format for older versions
|
||||||
section.timeTValue = time(0);
|
section.timeTValue = time(0);
|
||||||
section.playtime = _system->getMillis() / 1000 - _engineStartTime;
|
section.playtime = _system->getMillis() / 1000 - _engineStartTime;
|
||||||
|
|
||||||
|
time_t curTime_ = time(0);
|
||||||
|
tm *curTime = localtime(&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;
|
||||||
|
|
||||||
file->write(§ion.type, 4);
|
file->write(§ion.type, 4);
|
||||||
file->writeUint32BE(section.version);
|
file->writeUint32BE(section.version);
|
||||||
file->writeUint32BE(section.size);
|
file->writeUint32BE(section.size);
|
||||||
file->writeUint32BE(section.timeTValue);
|
file->writeUint32BE(section.timeTValue);
|
||||||
file->writeUint32BE(section.playtime);
|
file->writeUint32BE(section.playtime);
|
||||||
|
file->writeUint32BE(section.date);
|
||||||
|
file->writeUint16BE(section.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
|
void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue