[Scummvm-cvs-logs] SF.net SVN: scummvm:[55083] scummvm/trunk/engines/hugo/hugo.cpp

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Sat Jan 1 11:13:42 CET 2011


Revision: 55083
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55083&view=rev
Author:   strangerke
Date:     2011-01-01 10:13:42 +0000 (Sat, 01 Jan 2011)

Log Message:
-----------
HUGO: Reduce CPU usage by adding a delay in the main loop

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/hugo.cpp

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2010-12-31 23:04:49 UTC (rev 55082)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2011-01-01 10:13:42 UTC (rev 55083)
@@ -330,6 +330,7 @@
 */
 void HugoEngine::runMachine() {
 	static uint32 lastTime;
+	uint32 curTime;
 
 	status_t &gameStatus = getGameStatus();
 	// Don't process if we're in a textbox
@@ -340,10 +341,13 @@
 	if (gameStatus.gameOverFl)
 		return;
 
+	curTime = g_system->getMillis();
 	// Process machine once every tick
-	if (g_system->getMillis() - lastTime < (uint32)(1000 / getTPS()))
-		return;
-	lastTime = g_system->getMillis();
+	while (curTime - lastTime < (uint32)(1000 / getTPS())) {
+		g_system->delayMillis(5);
+		curTime = g_system->getMillis();
+	}
+	lastTime = curTime;
 
 	switch (gameStatus.viewState) {
 	case V_IDLE:                                    // Not processing state machine


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list