mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
Add playtime feature support to sword1
svn-id: r39083
This commit is contained in:
parent
f31990f897
commit
0077889eeb
@ -1117,7 +1117,9 @@ void Control::saveGameToFile(uint8 slot) {
|
||||
|
||||
outf->writeUint32BE(saveDate);
|
||||
outf->writeUint16BE(saveTime);
|
||||
// TODO: played time
|
||||
|
||||
uint32 currentTime = _system->getMillis() / 1000;
|
||||
outf->writeUint32BE(currentTime - SwordEngine::_systemVars.engineStartTime);
|
||||
|
||||
_objMan->saveLiveList(liveBuf);
|
||||
for (cnt = 0; cnt < TOTAL_SECTIONS; cnt++)
|
||||
@ -1165,7 +1167,7 @@ bool Control::restoreGameFromFile(uint8 slot) {
|
||||
inf->skip(40); // skip description
|
||||
uint8 saveVersion = inf->readByte();
|
||||
|
||||
if (saveVersion != SAVEGAME_VERSION) {
|
||||
if (saveVersion > SAVEGAME_VERSION) {
|
||||
warning("Different save game version");
|
||||
return false;
|
||||
}
|
||||
@ -1183,7 +1185,13 @@ bool Control::restoreGameFromFile(uint8 slot) {
|
||||
|
||||
inf->readUint32BE(); // save date
|
||||
inf->readUint16BE(); // save time
|
||||
// TODO: played time
|
||||
|
||||
if (saveVersion < 2) { // Before version 2 we didn't had play time feature
|
||||
SwordEngine::_systemVars.engineStartTime = _system->getMillis() / 1000; // Start counting
|
||||
} else {
|
||||
uint32 currentTime = _system->getMillis() / 1000;
|
||||
SwordEngine::_systemVars.engineStartTime = currentTime - inf->readUint32BE(); // Engine start time
|
||||
}
|
||||
|
||||
_restoreBuf = (uint8*)malloc(
|
||||
TOTAL_SECTIONS * 2 +
|
||||
@ -1281,7 +1289,7 @@ bool Control::convertSaveGame(uint8 slot, char* desc) {
|
||||
|
||||
newSave->writeUint32BE(saveDate);
|
||||
newSave->writeUint16BE(saveTime);
|
||||
// TODO: played time
|
||||
newSave->writeUint32BE(0); // We don't have playtime info when converting, so we start from 0.
|
||||
|
||||
newSave->write(saveData, dataSize);
|
||||
|
||||
|
@ -44,7 +44,7 @@ class Music;
|
||||
class Sound;
|
||||
|
||||
#define SAVEGAME_HEADER MKID_BE('BS_1')
|
||||
#define SAVEGAME_VERSION 1
|
||||
#define SAVEGAME_VERSION 2
|
||||
#define HAS_THUMBNAIL 1
|
||||
#define NO_THUMBNAIL 0
|
||||
|
||||
|
@ -102,7 +102,8 @@ bool SwordMetaEngine::hasFeature(MetaEngineFeature f) const {
|
||||
(f == kSupportsDeleteSave) ||
|
||||
(f == kSavesSupportMetaInfo) ||
|
||||
(f == kSavesSupportThumbnail) ||
|
||||
(f == kSavesSupportCreationDate);
|
||||
(f == kSavesSupportCreationDate) ||
|
||||
(f == kSavesSupportPlayTime);
|
||||
}
|
||||
|
||||
bool Sword1::SwordEngine::hasFeature(EngineFeature f) const {
|
||||
@ -244,13 +245,15 @@ SaveStateDescriptor SwordMetaEngine::querySaveMetaInfos(const char *target, int
|
||||
char fileName[12];
|
||||
snprintf(fileName, 12, "sword1.%03d", slot);
|
||||
char name[40];
|
||||
uint32 playTime;
|
||||
byte versionSave;
|
||||
|
||||
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName);
|
||||
|
||||
if (in) {
|
||||
in->skip(4); // header
|
||||
in->read(name, sizeof(name));
|
||||
in->skip(1); // version
|
||||
in->read(&versionSave, 1); // version
|
||||
|
||||
SaveStateDescriptor desc(slot, name);
|
||||
|
||||
@ -271,6 +274,8 @@ SaveStateDescriptor SwordMetaEngine::querySaveMetaInfos(const char *target, int
|
||||
|
||||
uint32 saveDate = in->readUint32BE();
|
||||
uint16 saveTime = in->readUint16BE();
|
||||
if (versionSave > 1) // Previous versions did not have playtime data
|
||||
playTime = in->readUint32BE();
|
||||
|
||||
int day = (saveDate >> 24) & 0xFF;
|
||||
int month = (saveDate >> 16) & 0xFF;
|
||||
@ -283,7 +288,14 @@ SaveStateDescriptor SwordMetaEngine::querySaveMetaInfos(const char *target, int
|
||||
|
||||
desc.setSaveTime(hour, minutes);
|
||||
|
||||
// TODO: played time
|
||||
if (versionSave > 1) {
|
||||
minutes = playTime / 60;
|
||||
hour = minutes / 60;
|
||||
minutes %= 60;
|
||||
desc.setPlayTime(hour, minutes);
|
||||
} else { //We have no playtime data
|
||||
desc.setPlayTime(0, 0);
|
||||
}
|
||||
|
||||
delete in;
|
||||
|
||||
|
@ -546,6 +546,7 @@ void SwordEngine::checkCdFiles(void) { // check if we're running from cd, hdd or
|
||||
|
||||
Common::Error SwordEngine::go() {
|
||||
_control->checkForOldSaveGames();
|
||||
SwordEngine::_systemVars.engineStartTime = _system->getMillis() / 1000;
|
||||
|
||||
uint16 startPos = ConfMan.getInt("boot_param");
|
||||
_control->readSavegameDescriptions();
|
||||
|
@ -66,6 +66,7 @@ struct SystemVars {
|
||||
uint8 showText;
|
||||
uint8 language;
|
||||
bool isDemo;
|
||||
uint32 engineStartTime; // Used for playtime
|
||||
Common::Platform platform;
|
||||
};
|
||||
|
||||
@ -75,7 +76,7 @@ public:
|
||||
virtual ~SwordEngine();
|
||||
static SystemVars _systemVars;
|
||||
void reinitialize(void);
|
||||
|
||||
|
||||
uint32 _features;
|
||||
|
||||
bool mouseIsActive();
|
||||
@ -96,6 +97,7 @@ protected:
|
||||
}
|
||||
virtual bool hasFeature(EngineFeature f) const;
|
||||
virtual void syncSoundSettings();
|
||||
|
||||
// FIXME: Loading a game through the GMM crashes the game
|
||||
#if 0
|
||||
Common::Error loadGameState(int slot);
|
||||
|
Loading…
Reference in New Issue
Block a user