[Scummvm-cvs-logs] SF.net SVN: scummvm: [32469] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Jun 1 17:18:58 CEST 2008


Revision: 32469
          http://scummvm.svn.sourceforge.net/scummvm/?rev=32469&view=rev
Author:   lordhoto
Date:     2008-06-01 08:18:58 -0700 (Sun, 01 Jun 2008)

Log Message:
-----------
Cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/script_tim.cpp
    scummvm/trunk/engines/kyra/script_tim.h

Modified: scummvm/trunk/engines/kyra/script_tim.cpp
===================================================================
--- scummvm/trunk/engines/kyra/script_tim.cpp	2008-06-01 15:15:12 UTC (rev 32468)
+++ scummvm/trunk/engines/kyra/script_tim.cpp	2008-06-01 15:18:58 UTC (rev 32469)
@@ -118,7 +118,8 @@
 	for (uint i = 0; i < avtlChunkSize; ++i)
 		tim->avtl[i] = READ_LE_UINT16(tim->avtl + i);
 	
-	for (int i = 0; i < 10; ++i)
+	int num = (avtlChunkSize < TIM::kCountFuncs) ? avtlChunkSize : TIM::kCountFuncs;
+	for (int i = 0; i < num; ++i)
 		tim->func[i].avtl = tim->avtl + tim->avtl[i];	
 
 	return tim;
@@ -145,7 +146,7 @@
 	}
 
 	do {
-		for (_currentFunc = 0; _currentFunc < 10; ++_currentFunc) {
+		for (_currentFunc = 0; _currentFunc < TIM::kCountFuncs; ++_currentFunc) {
 			TIM::Function &cur = _currentTim->func[_currentFunc];
 
 			if (_currentTim->procFunc != -1)
@@ -185,7 +186,10 @@
 }
 
 void TIMInterpreter::refreshTimersAfterPause(uint32 elapsedTime) {
-	for (int i = 0; i < 10; i++) {
+	if (!_currentTim)
+		return;
+
+	for (int i = 0; i < TIM::kCountFuncs; i++) {
 		if (_currentTim->func[i].lastTime)
 			_currentTim->func[i].lastTime += elapsedTime;
 		if (_currentTim->func[i].nextTime)
@@ -215,7 +219,7 @@
 }
 
 int TIMInterpreter::cmd_stopCurFunc(const uint16 *param) {
-	if (_currentFunc < 10)
+	if (_currentFunc < TIM::kCountFuncs)
 		_currentTim->func[_currentFunc].ip = 0;
 	if (!_currentFunc)
 		_finished = true;
@@ -224,7 +228,7 @@
 
 int TIMInterpreter::cmd_initFunc(const uint16 *param) {
 	uint16 func = *param;
-	assert(func < 10);
+	assert(func < TIM::kCountFuncs);
 	if (_currentTim->func[func].avtl)
 		_currentTim->func[func].ip = _currentTim->func[func].avtl;
 	else
@@ -234,13 +238,13 @@
 
 int TIMInterpreter::cmd_stopFunc(const uint16 *param) {
 	uint16 func = *param;
-	assert(func < 10);
+	assert(func < TIM::kCountFuncs);
 	_currentTim->func[func].ip = 0;
 	return 1;
 }
 
 int TIMInterpreter::cmd_resetAllRuntimes(const uint16 *param) {
-	for (int i = 0; i < 10; ++i) {
+	for (int i = 0; i < TIM::kCountFuncs; ++i) {
 		if (_currentTim->func[i].ip)
 			_currentTim->func[i].nextTime = _system->getMillis();
 	}
@@ -264,7 +268,7 @@
 
 int TIMInterpreter::cmd_initFuncNow(const uint16 *param) {
 	uint16 func = *param;
-	assert(func < 10);
+	assert(func < TIM::kCountFuncs);
 	_currentTim->func[func].ip = _currentTim->func[func].avtl;
 	_currentTim->func[func].lastTime = _currentTim->func[func].nextTime = _system->getMillis();
 	return 1;
@@ -272,7 +276,7 @@
 
 int TIMInterpreter::cmd_stopFuncNow(const uint16 *param) {
 	uint16 func = *param;
-	assert(func < 10);
+	assert(func < TIM::kCountFuncs);
 	_currentTim->func[func].ip = 0;
 	_currentTim->func[func].lastTime = _currentTim->func[func].nextTime = _system->getMillis();
 	return 1;

Modified: scummvm/trunk/engines/kyra/script_tim.h
===================================================================
--- scummvm/trunk/engines/kyra/script_tim.h	2008-06-01 15:15:12 UTC (rev 32468)
+++ scummvm/trunk/engines/kyra/script_tim.h	2008-06-01 15:18:58 UTC (rev 32469)
@@ -40,6 +40,10 @@
 	int16 procFunc;
 	uint16 procParam;
 
+	enum {
+		kCountFuncs = 10
+	};
+
 	struct Function {
 		const uint16 *ip;
 
@@ -47,7 +51,7 @@
 		uint32 nextTime;
 
 		const uint16 *avtl;
-	} func[10];
+	} func[kCountFuncs];
 
 	uint16 *avtl;
 	uint8 *text;


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