[Scummvm-git-logs] scummvm master -> 9dbd9c567e298f076be0b1ce0a87b3db5566e3c9

dreammaster dreammaster at scummvm.org
Sat Jun 17 19:39:24 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
9dbd9c567e TITANIC: Fix maintaining total playtime for savegames


Commit: 9dbd9c567e298f076be0b1ce0a87b3db5566e3c9
    https://github.com/scummvm/scummvm/commit/9dbd9c567e298f076be0b1ce0a87b3db5566e3c9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-06-17T13:39:13-04:00

Commit Message:
TITANIC: Fix maintaining total playtime for savegames

Changed paths:
    engines/titanic/core/project_item.cpp
    engines/titanic/events.cpp
    engines/titanic/events.h


diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp
index 1093a5c..205eecf 100644
--- a/engines/titanic/core/project_item.cpp
+++ b/engines/titanic/core/project_item.cpp
@@ -177,6 +177,7 @@ void CProjectItem::loadGame(int slotId) {
 	TitanicSavegameHeader header;
 	readSavegameHeader(&file, header);
 	delete header._thumbnail;
+	g_vm->_events->setTotalPlayTicks(header._totalFrames);
 
 	// Load the contents in
 	CProjectItem *newProject = loadData(&file);
@@ -545,7 +546,7 @@ void CProjectItem::writeSavegameHeader(SimpleFile *file, TitanicSavegameHeader &
 	file->writeUint16LE(td.tm_mday);
 	file->writeUint16LE(td.tm_hour);
 	file->writeUint16LE(td.tm_min);
-	file->writeUint32LE(g_vm->_events->getFrameCounter());
+	file->writeUint32LE(g_vm->_events->getTotalPlayTicks());
 }
 
 Graphics::Surface *CProjectItem::createThumbnail() {
diff --git a/engines/titanic/events.cpp b/engines/titanic/events.cpp
index d29a19d..0d0fcaf 100644
--- a/engines/titanic/events.cpp
+++ b/engines/titanic/events.cpp
@@ -31,7 +31,7 @@
 namespace Titanic {
 
 Events::Events(TitanicEngine *vm): _vm(vm), _frameCounter(1),
-		_priorFrameTime(0), _specialButtons(0) {
+		_totalFrames(0), _priorFrameTime(0), _specialButtons(0) {
 }
 
 void Events::pollEvents() {
@@ -109,6 +109,7 @@ bool Events::checkForNextFrameCounter() {
 	uint32 milli = g_system->getMillis();
 	if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
 		++_frameCounter;
+		++_totalFrames;
 		_priorFrameTime = milli;
 
 		// Handle any idle updates
@@ -130,6 +131,14 @@ uint32 Events::getTicksCount() const {
 	return _frameCounter * GAME_FRAME_TIME;
 }
 
+uint32 Events::getTotalPlayTicks() const {
+	return _totalFrames;
+}
+
+void Events::setTotalPlayTicks(uint frames) {
+	_totalFrames = frames;
+}
+
 void Events::sleep(uint time) {
 	uint32 delayEnd = g_system->getMillis() + time;
 
diff --git a/engines/titanic/events.h b/engines/titanic/events.h
index 52e900c..e14fbd8 100644
--- a/engines/titanic/events.h
+++ b/engines/titanic/events.h
@@ -91,6 +91,7 @@ private:
 	Common::Stack<CEventTarget *> _eventTargets;
 	uint32 _frameCounter;
 	uint32 _priorFrameTime;
+	uint _totalFrames;
 	Common::Point _mousePos;
 	uint _specialButtons;
 
@@ -147,11 +148,21 @@ public:
 	uint32 getFrameCounter() const { return _frameCounter; }
 
 	/**
-	 * Get the elapsed playtime
+	 * Return the current game ticks
 	 */
 	uint32 getTicksCount() const;
 
 	/**
+	 * Get the total number of playtime frames/ticks
+	 */
+	uint32 getTotalPlayTicks() const;
+
+	/**
+	 * Set the total number of frames/ticks played
+	 */
+	void setTotalPlayTicks(uint frames);
+
+	/**
 	 * Sleep for a specified period of time
 	 */
 	void sleep(uint time);





More information about the Scummvm-git-logs mailing list