[Scummvm-cvs-logs] SF.net SVN: scummvm:[35876] scummvm/trunk/engines/tucker

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sat Jan 17 00:18:19 CET 2009


Revision: 35876
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35876&view=rev
Author:   fingolfin
Date:     2009-01-16 23:18:18 +0000 (Fri, 16 Jan 2009)

Log Message:
-----------
Some cleanup (one could replace some of those switch/case by jump tables...)

Modified Paths:
--------------
    scummvm/trunk/engines/tucker/graphics.h
    scummvm/trunk/engines/tucker/locations.cpp
    scummvm/trunk/engines/tucker/tucker.cpp
    scummvm/trunk/engines/tucker/tucker.h

Modified: scummvm/trunk/engines/tucker/graphics.h
===================================================================
--- scummvm/trunk/engines/tucker/graphics.h	2009-01-16 21:19:30 UTC (rev 35875)
+++ scummvm/trunk/engines/tucker/graphics.h	2009-01-16 23:18:18 UTC (rev 35876)
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef TUCKER_GRAPHICS_H__
-#define TUCKER_GRAPHICS_H__
+#ifndef TUCKER_GRAPHICS_H
+#define TUCKER_GRAPHICS_H
 
 #include "common/util.h"
 

Modified: scummvm/trunk/engines/tucker/locations.cpp
===================================================================
--- scummvm/trunk/engines/tucker/locations.cpp	2009-01-16 21:19:30 UTC (rev 35875)
+++ scummvm/trunk/engines/tucker/locations.cpp	2009-01-16 23:18:18 UTC (rev 35876)
@@ -578,6 +578,12 @@
 	addDirtyRect(dstOffset % 640, dstOffset / 640, 4, 51);
 }
 
+void TuckerEngine::execData3PostUpdate_locationNum6() {
+	if (_flagsTable[26] < 4) {
+		execData3PreUpdate_locationNum6Helper1();
+	}
+}
+
 void TuckerEngine::updateSprite_locationNum7_0(int i) {
 	int state;
 	++_spritesTable[i].counter;
@@ -973,6 +979,9 @@
 }
 
 void TuckerEngine::execData3PreUpdate_locationNum14() {
+	if (_yPosCurrent >= 126)
+		return;
+
 	if (!isSoundPlaying(0)) {
 		int num = -1;
 		const int i = getRandomNumber();
@@ -1016,7 +1025,7 @@
 }
 
 void TuckerEngine::execData3PreUpdate_locationNum14Helper1(int i) {
-	const int y = 1872; // XXX bug, 187/182 ?
+	const int y = 1872; // FIXME: bug, 187/182 ?
 	if (_updateLocation14ObjNum[i] == 0) {
 		if (getRandomNumber() <= 30000) {
 			return;
@@ -1026,7 +1035,7 @@
 		_updateLocation14Step[i] = -55 - getRandomNumber() / 512;
 		_updateLocation14ObjNum[i] = 231;
 		_updateLocation14Delay[i] = 16 + getRandomNumber() / 2048;
-		// XXX bug, missing return ?
+		// FIXME: bug, missing return ?
 	}
 	_updateLocation14Step[i] = 4;
 	_updateLocationYPosTable2[i] += _updateLocation14Step[i];
@@ -1054,6 +1063,12 @@
 	}
 }
 
+void TuckerEngine::execData3PostUpdate_locationNum14() {
+	if (_yPosCurrent < 127) {
+		execData3PreUpdate_locationNum14();
+	}
+}
+
 void TuckerEngine::updateSprite_locationNum15_0(int i) {
 	_spritesTable[i].state = -1;
 }
@@ -1809,19 +1824,17 @@
 }
 
 void TuckerEngine::execData3PreUpdate_locationNum31() {
-	execData3PreUpdate_locationNum31Helper(32000, 110);
-	execData3PreUpdate_locationNum31Helper(31000, 111);
+	if (getRandomNumber() > 32000 && _flagsTable[110] == 0) {
+		_flagsTable[110] = 1;
+	}
+	if (getRandomNumber() > 31000 && _flagsTable[111] == 0) {
+		_flagsTable[111] = 1;
+	}
 	if (_xPosCurrent < 112 && _flagsTable[104] == 0) {
 		_flagsTable[104] = 1;
 	}
 }
 
-void TuckerEngine::execData3PreUpdate_locationNum31Helper(int r, int flag) {
-	if (getRandomNumber() > r && _flagsTable[flag] == 0) {
-		_flagsTable[flag] = 1;
-	}
-}
-
 void TuckerEngine::execData3PreUpdate_locationNum32() {
 	if (_spritesTable[0].state == 12 && _spritesTable[0].animationFrame < 22) {
 		_flagsTable[113] = 1;
@@ -1969,7 +1982,9 @@
 	}
 }
 
-void TuckerEngine::updateSprite_locationNum37(int i, int j, int offset) {
+void TuckerEngine::updateSprite_locationNum37(int i) {
+	int j = i + 1;
+	int offset = 200 - i * 45;
 	++_spritesTable[i].counter;
 	if (_spritesTable[i].counter > offset) {
 		_spritesTable[i].state = j;
@@ -2069,7 +2084,7 @@
 	} else if (_flagsTable[223] == 3) {
 		state = 5;
 		_spritesTable[i].updateDelay = 5;
-		_spritesTable[i].state = _spritesTable[i].firstFrame - 1; // XXX bug, fxNum ?
+		_spritesTable[i].state = _spritesTable[i].firstFrame - 1; // FIXME: bug, fxNum ?
 		_updateSpriteFlag1 = 1;
 	} else {
 		state = 2;
@@ -2273,32 +2288,29 @@
 		_updateSpriteFlag1 = 1;
 		state = i + 1;
 	}
-	state = i + 1; // XXX bug ?
+	state = i + 1; // FIXME: bug ?
 	_spritesTable[i].state = state;
 }
 
-void TuckerEngine::updateSprite_locationNum51_0(int i) {
-	static const int stateTable[] = { 3, 3, 4, 5, 3, 3, 5, 4, 3, 3, 4, 5, 4, 4 };
-	++_spritesTable[i].counter;
-	if (_spritesTable[i].counter > 13) {
-		_spritesTable[i].counter = 0;
+void TuckerEngine::updateSprite_locationNum51(int i) {
+	if (i == 2) {
+		_spritesTable[i].state = 1;
+	} else if (i == 0) {
+		static const int stateTable[] = { 3, 3, 4, 5, 3, 3, 5, 4, 3, 3, 4, 5, 4, 4 };
+		++_spritesTable[i].counter;
+		if (_spritesTable[i].counter > 13) {
+			_spritesTable[i].counter = 0;
+		}
+		_spritesTable[i].state = stateTable[_spritesTable[i].counter];
+	} else {
+		i = 1;
+		_spritesTable[i].state = 6;
 	}
-	_spritesTable[i].state = stateTable[_spritesTable[i].counter];
-	_spritesTable[i].colorType = 1;
-	_spritesTable[i].yMaxBackground = 0;
-}
 
-void TuckerEngine::updateSprite_locationNum51_1(int i) {
-	_spritesTable[i].state = 6;
 	_spritesTable[i].colorType = 1;
 	_spritesTable[i].yMaxBackground = 0;
 }
 
-void TuckerEngine::updateSprite_locationNum51_2(int i) {
-	_spritesTable[i].state = 1;
-	_spritesTable[i].colorType = 1;
-	_spritesTable[i].yMaxBackground = 0;
-}
 
 void TuckerEngine::execData3PreUpdate_locationNum52() {
 	if (_selectedObject.xPos > 108 && _panelLockedFlag > 0 && _nextAction == 0 && _locationMaskType == 0) {
@@ -2813,7 +2825,7 @@
 			_flagsTable[189] = 0;
 		}
 	} else {
-		if (_xPosCurrent >= 150 && _yPosCurrent < 240) { // XXX bug
+		if (_xPosCurrent >= 150 && _yPosCurrent < 240) { // FIXME: bug
 			if (getRandomNumber() > 32000) {
 				state = 2;
 				_flagsTable[189] = 1;

Modified: scummvm/trunk/engines/tucker/tucker.cpp
===================================================================
--- scummvm/trunk/engines/tucker/tucker.cpp	2009-01-16 21:19:30 UTC (rev 35875)
+++ scummvm/trunk/engines/tucker/tucker.cpp	2009-01-16 23:18:18 UTC (rev 35876)
@@ -1550,9 +1550,7 @@
 		execData3PreUpdate_locationNum13();
 		break;
 	case 14:
-		if (_yPosCurrent > 126) {
-			execData3PreUpdate_locationNum14();
-		}
+		execData3PreUpdate_locationNum14();
 		break;
 	case 15:
 		execData3PreUpdate_locationNum15();
@@ -1659,6 +1657,47 @@
 	}
 }
 
+void TuckerEngine::execData3PostUpdate() {
+	switch (_locationNum) {
+	case 1:
+		execData3PostUpdate_locationNum1();
+		break;
+	case 6:
+		execData3PostUpdate_locationNum6();
+		break;
+	case 8:
+		execData3PostUpdate_locationNum8();
+		break;
+	case 9:
+		execData3PostUpdate_locationNum9();
+		break;
+	case 14:
+		execData3PostUpdate_locationNum14();
+		break;
+	case 21:
+		execData3PostUpdate_locationNum21();
+		break;
+	case 24:
+		execData3PostUpdate_locationNum24();
+		break;
+	case 27:
+		execData3PostUpdate_locationNum27();
+		break;
+	case 28:
+		execData3PostUpdate_locationNum28();
+		break;
+	case 32:
+		execData3PostUpdate_locationNum32();
+		break;
+	case 60:
+		execData3PostUpdate_locationNum60();
+		break;
+	case 66:
+		execData3PostUpdate_locationNum66();
+		break;
+	}
+}
+
 void TuckerEngine::drawBackgroundSprites() {
 	if (_backgroundSpriteDataPtr && _backgroundSpriteCurrentFrame != 0 && _backgroundSpriteCurrentFrame <= _backgroundSpriteLastFrame) {
 		int frameOffset = READ_LE_UINT24(_backgroundSpriteDataPtr + _backgroundSpriteCurrentFrame * 4);
@@ -2181,51 +2220,6 @@
 	_characterPrevFacingDirection = _characterFacingDirection;
 }
 
-void TuckerEngine::execData3PostUpdate() {
-	switch (_locationNum) {
-	case 1:
-		execData3PostUpdate_locationNum1();
-		break;
-	case 6:
-		if (_flagsTable[26] < 4) {
-			execData3PreUpdate_locationNum6Helper1();
-		}
-		break;
-	case 8:
-		execData3PostUpdate_locationNum8();
-		break;
-	case 9:
-		execData3PostUpdate_locationNum9();
-		break;
-	case 14:
-		if (_yPosCurrent < 127) {
-			execData3PreUpdate_locationNum14();
-		}
-		break;
-	case 21:
-		execData3PostUpdate_locationNum21();
-		break;
-	case 24:
-		execData3PostUpdate_locationNum24();
-		break;
-	case 27:
-		execData3PostUpdate_locationNum27();
-		break;
-	case 28:
-		execData3PostUpdate_locationNum28();
-		break;
-	case 32:
-		execData3PostUpdate_locationNum32();
-		break;
-	case 60:
-		execData3PostUpdate_locationNum60();
-		break;
-	case 66:
-		execData3PostUpdate_locationNum66();
-		break;
-	}
-}
-
 void TuckerEngine::addObjectToInventory(int num) {
 	_inventoryObjectsList[_inventoryObjectsCount] = num;
 	_lastInventoryObjectIndex = _inventoryObjectsCount;
@@ -2618,7 +2612,7 @@
 		if (i == 0) {
 			_spritesTable[0].state = -1;
 		} else {
-			updateSprite_locationNum37(i, i + 1, 200 - i * 45);
+			updateSprite_locationNum37(i);
 		}
 		break;
 	case 41:
@@ -2666,13 +2660,7 @@
 		}
 		break;
 	case 51:
-		if (i == 2) {
-			updateSprite_locationNum51_2(2);
-		} else if (i == 0) {
-			updateSprite_locationNum51_0(0);
-		} else {
-			updateSprite_locationNum51_1(1);
-		}
+		updateSprite_locationNum51(i);
 		break;
 	case 53:
 		if (i == 0) {

Modified: scummvm/trunk/engines/tucker/tucker.h
===================================================================
--- scummvm/trunk/engines/tucker/tucker.h	2009-01-16 21:19:30 UTC (rev 35875)
+++ scummvm/trunk/engines/tucker/tucker.h	2009-01-16 23:18:18 UTC (rev 35876)
@@ -23,8 +23,8 @@
  *
  */
 
-#ifndef TUCKER_ENGINE_H__
-#define TUCKER_ENGINE_H__
+#ifndef TUCKER_ENGINE_H
+#define TUCKER_ENGINE_H
 
 #include "common/file.h"
 #include "common/util.h"
@@ -366,6 +366,7 @@
 	void execData3PreUpdate_locationNum6Helper1();
 	void execData3PreUpdate_locationNum6Helper2(int dstOffset, const uint8 *src);
 	void execData3PreUpdate_locationNum6Helper3(int dstOffset, const uint8 *src);
+	void execData3PostUpdate_locationNum6();
 	void updateSprite_locationNum7_0(int i);
 	void updateSprite_locationNum7_1(int i);
 	void updateSprite_locationNum8_0(int i);
@@ -392,6 +393,7 @@
 	void execData3PreUpdate_locationNum14();
 	void execData3PreUpdate_locationNum14Helper1(int i);
 	void execData3PreUpdate_locationNum14Helper2(int i);
+	void execData3PostUpdate_locationNum14();
 	void updateSprite_locationNum15_0(int i);
 	void updateSprite_locationNum15_1(int i);
 	void updateSprite_locationNum15_2(int i);
@@ -443,7 +445,6 @@
 	void updateSprite_locationNum31_0(int i);
 	void updateSprite_locationNum31_1(int i);
 	void execData3PreUpdate_locationNum31();
-	void execData3PreUpdate_locationNum31Helper(int r, int flag);
 	void updateSprite_locationNum32_0(int i);
 	void execData3PreUpdate_locationNum32();
 	void execData3PostUpdate_locationNum32();
@@ -455,7 +456,7 @@
 	void execData3PreUpdate_locationNum35();
 	void updateSprite_locationNum36(int i);
 	void execData3PreUpdate_locationNum36();
-	void updateSprite_locationNum37(int i, int j, int offset);
+	void updateSprite_locationNum37(int i);
 	void execData3PreUpdate_locationNum38();
 	void updateSprite_locationNum41(int i);
 	void execData3PreUpdate_locationNum41();
@@ -472,9 +473,7 @@
 	void updateSprite_locationNum49(int i);
 	void execData3PreUpdate_locationNum49();
 	void updateSprite_locationNum50(int i);
-	void updateSprite_locationNum51_0(int i);
-	void updateSprite_locationNum51_1(int i);
-	void updateSprite_locationNum51_2(int i);
+	void updateSprite_locationNum51(int i);
 	void execData3PreUpdate_locationNum52();
 	void updateSprite_locationNum53_0(int i);
 	void updateSprite_locationNum53_1(int i);


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