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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Jan 16 22:08:56 CET 2009


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

Log Message:
-----------
TUCKER: Changed loadFile and loadImage to take filename as parameter (trying to get rid of _fileToLoad)

Modified Paths:
--------------
    scummvm/trunk/engines/tucker/resource.cpp
    scummvm/trunk/engines/tucker/sequences.cpp
    scummvm/trunk/engines/tucker/tucker.cpp
    scummvm/trunk/engines/tucker/tucker.h

Modified: scummvm/trunk/engines/tucker/resource.cpp
===================================================================
--- scummvm/trunk/engines/tucker/resource.cpp	2009-01-16 20:53:43 UTC (rev 35873)
+++ scummvm/trunk/engines/tucker/resource.cpp	2009-01-16 21:08:55 UTC (rev 35874)
@@ -161,38 +161,40 @@
 	int _pos;
 };
 
-uint8 *TuckerEngine::loadFile(uint8 *p) {
+uint8 *TuckerEngine::loadFile(const char *fname, uint8 *p) {
+	char filename[80];
+	strcpy(filename, fname);
 	if (_gameLang == Common::DE_DEU) {
-		if (strcmp(_fileToLoad, "bgtext.c") == 0) {
-			strcpy(_fileToLoad, "bgtextgr.c");
-		} else if (strcmp(_fileToLoad, "charname.c") == 0) {
-			strcpy(_fileToLoad, "charnmgr.c");
-		} else if (strcmp(_fileToLoad, "data5.c") == 0) {
-			strcpy(_fileToLoad, "data5gr.c");
-		} else if (strcmp(_fileToLoad, "infobar.txt") == 0) {
-			strcpy(_fileToLoad, "infobrgr.txt");
-		} else if (strcmp(_fileToLoad, "charsize.dta") == 0) {
-			strcpy(_fileToLoad, "charszgr.dta");
-		} else if (strncmp(_fileToLoad, "objtxt", 6) == 0) {
-			const char num = _fileToLoad[6];
-			snprintf(_fileToLoad, sizeof(_fileToLoad), "objtx%cgr.c", num);
-		} else if (strncmp(_fileToLoad, "pt", 2) == 0) {
-			const char num = _fileToLoad[2];
-			snprintf(_fileToLoad, sizeof(_fileToLoad), "pt%ctxtgr.c", num);
+		if (strcmp(filename, "bgtext.c") == 0) {
+			strcpy(filename, "bgtextgr.c");
+		} else if (strcmp(filename, "charname.c") == 0) {
+			strcpy(filename, "charnmgr.c");
+		} else if (strcmp(filename, "data5.c") == 0) {
+			strcpy(filename, "data5gr.c");
+		} else if (strcmp(filename, "infobar.txt") == 0) {
+			strcpy(filename, "infobrgr.txt");
+		} else if (strcmp(filename, "charsize.dta") == 0) {
+			strcpy(filename, "charszgr.dta");
+		} else if (strncmp(filename, "objtxt", 6) == 0) {
+			const char num = filename[6];
+			snprintf(filename, sizeof(filename), "objtx%cgr.c", num);
+		} else if (strncmp(filename, "pt", 2) == 0) {
+			const char num = filename[2];
+			snprintf(filename, sizeof(filename), "pt%ctxtgr.c", num);
 		}
 	}
 	_fileLoadSize = 0;
 	bool decode = false;
 	if (_gameFlags & kGameFlagEncodedData) {
-		char *ext = strrchr(_fileToLoad, '.');
+		char *ext = strrchr(filename, '.');
 		if (ext && strcmp(ext + 1, "c") == 0) {
 			strcpy(ext + 1, "enc");
 			decode = true;
 		}
 	}
 	Common::File f;
-	if (!f.open(_fileToLoad)) {
-		warning("Unable to open '%s'", _fileToLoad);
+	if (!f.open(filename)) {
+		warning("Unable to open '%s'", filename);
 		return 0;
 	}
 	const int sz = f.size();
@@ -227,12 +229,15 @@
 	_fCompressedSound.close();
 }
 
-void TuckerEngine::loadImage(uint8 *dst, int type) {
+void TuckerEngine::loadImage(const char *fname, uint8 *dst, int type) {
+	char filename[80];
+	strcpy(filename, fname);
+
 	Common::File f;
-	if (!f.open(_fileToLoad)) {
+	if (!f.open(filename)) {
 		// workaround for "paper-3.pcx" / "paper_3.pcx"
 		bool tryOpen = false;
-		for (char *p = _fileToLoad; *p; ++p) {
+		for (char *p = filename; *p; ++p) {
 			switch (*p) {
 			case '-':
 				*p = '_';
@@ -244,8 +249,8 @@
 				break;
 			}
 		}
-		if (!tryOpen || !f.open(_fileToLoad)) {
-			warning("Unable to open '%s'", _fileToLoad);
+		if (!tryOpen || !f.open(filename)) {
+			warning("Unable to open '%s'", filename);
 			return;
 		}
 	}
@@ -277,16 +282,14 @@
 }
 
 void TuckerEngine::loadCursor() {
-	strcpy(_fileToLoad, "pointer.pcx");
-	loadImage(_loadTempBuf, 0);
+	loadImage("pointer.pcx", _loadTempBuf, 0);
 	for (int cursor = 0; cursor < 7; ++cursor) {
 		Graphics::encodeRAW(_loadTempBuf + cursor * 320 * 16, _cursorGfxBuf + cursor * 256, 16, 16);
 	}
 }
 
 void TuckerEngine::loadCharset() {
-	strcpy(_fileToLoad, "charset.pcx");
-	loadImage(_loadTempBuf, 0);
+	loadImage("charset.pcx", _loadTempBuf, 0);
 	switch (_gameLang) {
 	case Common::EN_ANY:
 		Graphics::setCharset(kCharsetTypeEng);
@@ -302,8 +305,7 @@
 	_charWidthTable[58] = 7;
 	_charWidthTable[32] = 15;
 	memcpy(_charWidthTable + 65, _charWidthCharset2, 58);
-	strcpy(_fileToLoad, "char2.pcx");
-	loadImage(_loadTempBuf, 0);
+	loadImage("char2.pcx", _loadTempBuf, 0);
 	Graphics::setCharset(kCharsetTypeCredits);
 	loadCharsetHelper();
 }
@@ -320,8 +322,7 @@
 }
 
 void TuckerEngine::loadCharSizeDta() {
-	strcpy(_fileToLoad, "charsize.dta");
-	loadFile(_loadTempBuf);
+	loadFile("charsize.dta", _loadTempBuf);
 	if (_fileLoadSize != 0) {
 		DataTokenizer t(_loadTempBuf, _fileLoadSize, true);
 		for (int i = 0; i < 256; ++i) {
@@ -335,7 +336,7 @@
 
 void TuckerEngine::loadPanel() {
 	strcpy(_fileToLoad, (_panelNum == 0) ? "panel1.pcx" : "panel2.pcx");
-	loadImage(_panelGfxBuf, 0);
+	loadImage(_fileToLoad, _panelGfxBuf, 0);
 }
 
 void TuckerEngine::loadBudSpr(int startOffset) {
@@ -357,7 +358,7 @@
 				sprintf(_fileToLoad, "mac_%d.pcx", frame + 1);
 				break;
 			}
-			loadImage(_loadTempBuf, 0);
+			loadImage(_fileToLoad, _loadTempBuf, 0);
 			++frame;
 		}
 		int sz = Graphics::encodeRLE(_loadTempBuf + _spriteFramesTable[i].sourceOffset, _spritesGfxBuf + spriteOffset, _spriteFramesTable[i].xSize, _spriteFramesTable[i].ySize);
@@ -367,8 +368,7 @@
 }
 
 void TuckerEngine::loadCTable01(int locationNum, int firstSpriteNum, int &lastSpriteNum) {
-	strcpy(_fileToLoad, "ctable01.c");
-	loadFile(_loadTempBuf);
+	loadFile("ctable01.c", _loadTempBuf);
 	DataTokenizer t(_loadTempBuf,  _fileLoadSize);
 	lastSpriteNum = firstSpriteNum;
 	int count = 0;
@@ -404,8 +404,7 @@
 	assert(fl == 0);
 	int entry = 0;
 	int i = 0;
-	strcpy(_fileToLoad, "ctable02.c");
-	loadFile(_loadTempBuf);
+	loadFile("ctable02.c", _loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	while (t.findNextToken(kDataTokenDw)) {
 		_spriteAnimationsTable[entry].numParts = t.getNextInteger();
@@ -454,9 +453,8 @@
 		Graphics::copyFrom640(_locationBackgroundGfxBuf, _quadBackgroundGfxBuf + 89600, 320, 140);
 	}
 	if (_locationNum == 1) {
-		strcpy(_fileToLoad, "rochpath.pcx");
 		_loadLocBufPtr = _quadBackgroundGfxBuf + 89600;
-		loadImage(_loadLocBufPtr, 0);
+		loadImage("rochpath.pcx", _loadLocBufPtr, 0);
 	}
 	if (i > 3) {
 		sprintf(_fileToLoad, "loc%02dd.pcx", _locationNum);
@@ -488,10 +486,10 @@
 	_currentPartNum = _partNum;
 	sprintf(_fileToLoad, "objtxt%d.c", _partNum);
 	free(_objTxtBuf);
-	_objTxtBuf = loadFile();
+	_objTxtBuf = loadFile(_fileToLoad, 0);
 	sprintf(_fileToLoad, "pt%dtext.c", _partNum);
 	free(_ptTextBuf);
-	_ptTextBuf = loadFile();
+	_ptTextBuf = loadFile(_fileToLoad, 0);
 	loadData();
 	loadPanObj();
 }
@@ -499,8 +497,7 @@
 void TuckerEngine::loadData() {
 	int flag = 0;
 	int objNum = _partNum * 10;
-	strcpy(_fileToLoad, "data.c");
-	loadFile(_loadTempBuf);
+	loadFile("data.c", _loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	_dataCount = 0;
 	int count = 0;
@@ -542,7 +539,7 @@
 	int offset = 0;
 	for (int i = 0; i < count; ++i) {
 		sprintf(_fileToLoad, "scrobj%d%d.pcx", _partNum, i);
-		loadImage(_loadTempBuf, 0);
+		loadImage(_fileToLoad, _loadTempBuf, 0);
 		offset = loadDataHelper(offset, i);
 	}
 }
@@ -560,7 +557,7 @@
 
 void TuckerEngine::loadPanObj() {
 	sprintf(_fileToLoad, "panobjs%d.pcx", _partNum);
-	loadImage(_loadTempBuf, 0);
+	loadImage(_fileToLoad, _loadTempBuf, 0);
 	int offset = 0;
 	for (int y = 0; y < 5; ++y) {
 		for (int x = 0; x < 10; ++x) {
@@ -572,8 +569,7 @@
 }
 
 void TuckerEngine::loadData3() {
-	strcpy(_fileToLoad, "data3.c");
-	loadFile(_loadTempBuf);
+	loadFile("data3.c", _loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	_locationAnimationsCount = 0;
 	if (t.findIndex(_locationNum)) {
@@ -617,8 +613,7 @@
 }
 
 void TuckerEngine::loadData4() {
-	strcpy(_fileToLoad,"data4.c");
-	loadFile(_loadTempBuf);
+	loadFile("data4.c", _loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	t.findNextToken(kDataTokenDw);
 	_gameDebug = t.getNextInteger() != 0;
@@ -667,7 +662,7 @@
 		strcpy(_fileToLoad, "action3.c");
 		break;
 	}
-	loadFile(_loadTempBuf);
+	loadFile(_fileToLoad, _loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	_actionsCount = 0;
 	if (t.findIndex(_locationNum)) {
@@ -699,8 +694,7 @@
 }
 
 void TuckerEngine::loadCharPos() {
-	strcpy(_fileToLoad, "charpos.c");
-	loadFile(_loadTempBuf);
+	loadFile("charpos.c", _loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	_charPosCount = 0;
 	if (t.findIndex(_locationNum)) {
@@ -766,7 +760,7 @@
 	const int count = _sprA02LookupTable[_locationNum];
 	for (int i = 1; i < count + 1; ++i) {
 		sprintf(_fileToLoad, "sprites/a%02d_%02d.spr", _locationNum, i);
-		_sprA02Table[i] = loadFile();
+		_sprA02Table[i] = loadFile(_fileToLoad, 0);
 	}
 	_sprA02Table[0] = _sprA02Table[1];
 }
@@ -784,7 +778,7 @@
 	const int count = _sprC02LookupTable[_locationNum];
 	for (int i = 1; i < count + 1; ++i) {
 		sprintf(_fileToLoad, "sprites/c%02d_%02d.spr", _locationNum, i);
-		_sprC02Table[i] = loadFile();
+		_sprC02Table[i] = loadFile(_fileToLoad, 0);
 	}
 	_sprC02Table[0] = _sprC02Table[1];
 	_spritesCount = _sprC02LookupTable2[_locationNum];
@@ -804,8 +798,7 @@
 }
 
 void TuckerEngine::loadFx() {
-	strcpy(_fileToLoad, "fx.c");
-	loadFile(_loadTempBuf);
+	loadFile("fx.c", _loadTempBuf);
 	DataTokenizer t(_loadTempBuf, _fileLoadSize);
 	t.findIndex(_locationNum);
 	t.findNextToken(kDataTokenDw);

Modified: scummvm/trunk/engines/tucker/sequences.cpp
===================================================================
--- scummvm/trunk/engines/tucker/sequences.cpp	2009-01-16 20:53:43 UTC (rev 35873)
+++ scummvm/trunk/engines/tucker/sequences.cpp	2009-01-16 21:08:55 UTC (rev 35874)
@@ -63,10 +63,8 @@
 		_spritesTable[i].state = -1;
 		_spritesTable[i].stateIndex = -1;
 	}
-	strcpy(_fileToLoad, "credits.txt");
-	loadFile(_ptTextBuf);
-	strcpy(_fileToLoad, "loc74.pcx");
-	loadImage(_quadBackgroundGfxBuf, 1);
+	loadFile("credits.txt", _ptTextBuf);
+	loadImage("loc74.pcx", _quadBackgroundGfxBuf, 1);
 	startSpeechSound(9001, 120);
 	_timerCounter2 = 0;
 	_fadePaletteCounter = 0;
@@ -128,30 +126,30 @@
 				_spritesTable[i].stateIndex = -1;
 			}
 			++num;
-			switch (num) {
-			case 1:
-				strcpy(_fileToLoad, "loc75.pcx");
-				break;
-			case 2:
-				strcpy(_fileToLoad, "loc76.pcx");
-				break;
-			case 3:
-				strcpy(_fileToLoad, "paper-3.pcx");
-				break;
-			case 4:
-				strcpy(_fileToLoad, "loc77.pcx");
-				break;
-			case 5:
-				strcpy(_fileToLoad, "loc78.pcx");
-				break;
-			}
 			if (num == 6) {
 				for (int i = 0; i < 16; ++i) {
 					sprintf(_fileToLoad, "cogs%04d.pcx", i);
-					loadImage(imgBuf + i * 64000, 2);
+					loadImage(_fileToLoad, imgBuf + i * 64000, 2);
 				}
 			} else {
-				loadImage(_quadBackgroundGfxBuf, 2);
+				switch (num) {
+				case 1:
+					strcpy(_fileToLoad, "loc75.pcx");
+					break;
+				case 2:
+					strcpy(_fileToLoad, "loc76.pcx");
+					break;
+				case 3:
+					strcpy(_fileToLoad, "paper-3.pcx");
+					break;
+				case 4:
+					strcpy(_fileToLoad, "loc77.pcx");
+					break;
+				case 5:
+					strcpy(_fileToLoad, "loc78.pcx");
+					break;
+				}
+				loadImage(_fileToLoad, _quadBackgroundGfxBuf, 2);
 			}
 			_spritesCount = _creditsSequenceData2[num];
 			++_flagsTable[236];
@@ -173,8 +171,7 @@
 	_timerCounter2 = 0;
 	_fadePaletteCounter = 0;
 	stopSounds();
-	strcpy(_fileToLoad, "congrat.pcx");
-	loadImage(_loadTempBuf, 1);
+	loadImage("congrat.pcx", _loadTempBuf, 1);
 	Graphics::copyTo640(_locationBackgroundGfxBuf, _loadTempBuf, 320, 320, 200);
 	_fullRedrawCounter = 2;
 	redrawScreen(0);
@@ -215,7 +212,15 @@
 		strcpy(_fileToLoad, "pt3bak.pcx");
 		break;
 	}
-	loadImage(_quadBackgroundGfxBuf, 1);
+	loadImage(_fileToLoad, _quadBackgroundGfxBuf, 1);
+	_spritesCount = 1;
+	memset(&_spritesTable[0], 0, sizeof(Sprite));
+	_spritesTable[0].state = -1;
+	_spritesTable[0].stateIndex = -1;
+	int currentLocation = _locationNum;
+	_locationNum = 98;
+	unloadSprA02_01();
+	unloadSprC02_01();
 	switch (_partNum) {
 	case 1:
 		strcpy(_fileToLoad, "sprites/partone.spr");
@@ -227,15 +232,7 @@
 		strcpy(_fileToLoad, "sprites/partthr.spr");
 		break;
 	}
-	_spritesCount = 1;
-	memset(&_spritesTable[0], 0, sizeof(Sprite));
-	_spritesTable[0].state = -1;
-	_spritesTable[0].stateIndex = -1;
-	int currentLocation = _locationNum;
-	_locationNum = 98;
-	unloadSprA02_01();
-	unloadSprC02_01();
-	_sprC02Table[1] = loadFile();
+	_sprC02Table[1] = loadFile(_fileToLoad, 0);
 	startSpeechSound(9000, 60);
 	_fadePaletteCounter = 0;
 	do {
@@ -287,7 +284,7 @@
 	if (_flagsTable[215] == 0 && _flagsTable[231] == 1) {
 		strcpy(_fileToLoad, "loc80.pcx");
 	}
-	loadImage(_quadBackgroundGfxBuf + 89600, 1);
+	loadImage(_fileToLoad, _quadBackgroundGfxBuf + 89600, 1);
 	_fadePaletteCounter = 0;
 	for (int i = 0; i < 60; ++i) {
 		if (_fadePaletteCounter < 16) {
@@ -314,10 +311,8 @@
 }
 
 void TuckerEngine::handleMapSequence() {
-	strcpy(_fileToLoad, "map2.pcx");
-	loadImage(_quadBackgroundGfxBuf + 89600, 0);
-	strcpy(_fileToLoad, "map1.pcx");
-	loadImage(_loadTempBuf, 1);
+	loadImage("map2.pcx", _quadBackgroundGfxBuf + 89600, 0);
+	loadImage("map1.pcx", _loadTempBuf, 1);
 	_selectedObject.locationObject_locationNum = 0;
 	if (_flagsTable[7] > 0) {
 		copyMapRect(0, 0, 140, 86);
@@ -455,7 +450,7 @@
 		--_fadePaletteCounter;
 	}
 	_mouseClick = 1;
-	loadImage(_quadBackgroundGfxBuf, 1);
+	loadImage(_fileToLoad, _quadBackgroundGfxBuf, 1);
 	_fadePaletteCounter = 0;
 	while (!_quitGame) {
 		waitForTimer(2);

Modified: scummvm/trunk/engines/tucker/tucker.cpp
===================================================================
--- scummvm/trunk/engines/tucker/tucker.cpp	2009-01-16 20:53:43 UTC (rev 35873)
+++ scummvm/trunk/engines/tucker/tucker.cpp	2009-01-16 21:08:55 UTC (rev 35874)
@@ -331,16 +331,11 @@
 	loadCharSizeDta();
 	loadCharset();
 	loadPanel();
-	strcpy(_fileToLoad, "infobar.txt");
-	loadFile(_infoBarBuf);
-	strcpy(_fileToLoad, "data5.c");
-	_data5Buf = loadFile();
-	strcpy(_fileToLoad, "bgtext.c");
-	_bgTextBuf = loadFile();
-	strcpy(_fileToLoad, "charname.c");
-	_charNameBuf = loadFile();
-	strcpy(_fileToLoad, "csdata.c");
-	_csDataBuf = loadFile();
+	loadFile("infobar.txt", _infoBarBuf);
+	_data5Buf = loadFile("data5.c", 0);
+	_bgTextBuf = loadFile("bgtext.c", 0);
+	_charNameBuf = loadFile("charname.c", 0);
+	_csDataBuf = loadFile("csdata.c", 0);
 	_csDataSize = _fileLoadSize;
 
 	_currentSaveLoadGameState = 1;
@@ -720,12 +715,12 @@
 	}
 }
 
-void TuckerEngine::copyLocBitmap(int offset, bool isMask) {
+void TuckerEngine::copyLocBitmap(const char *filename, int offset, bool isMask) {
 	int type = !isMask ? 1 : 0;
 	if (offset > 0 && _locationNum == 16) {
 		type = 0;
 	}
-	loadImage(_loadTempBuf, type);
+	loadImage(filename, _loadTempBuf, type);
 	uint8 *dst = isMask ? _locationBackgroundMaskBuf : _locationBackgroundGfxBuf;
 	dst += offset;
 	const uint8 *src = _loadTempBuf;

Modified: scummvm/trunk/engines/tucker/tucker.h
===================================================================
--- scummvm/trunk/engines/tucker/tucker.h	2009-01-16 20:53:43 UTC (rev 35873)
+++ scummvm/trunk/engines/tucker/tucker.h	2009-01-16 21:08:55 UTC (rev 35874)
@@ -541,8 +541,8 @@
 
 	void openCompressedSoundFile();
 	void closeCompressedSoundFile();
-	uint8 *loadFile(uint8 *p = 0);
-	void loadImage(uint8 *dst, int a);
+	uint8 *loadFile(const char *filename, uint8 *p);
+	void loadImage(const char *filename, uint8 *dst, int a);
 	void loadCursor();
 	void loadCharset();
 	void loadCharset2();


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