[Scummvm-cvs-logs] CVS: scummvm/queen cutaway.cpp,1.128,1.129 graphics.cpp,1.101,1.102 logic.cpp,1.198,1.199 queen.cpp,1.87,1.88 resource.cpp,1.47,1.48 resource.h,1.38,1.39 talk.cpp,1.99,1.100

Gregory Montoir cyx at users.sourceforge.net
Fri Aug 6 04:29:09 CEST 2004


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8386/queen

Modified Files:
	cutaway.cpp graphics.cpp logic.cpp queen.cpp resource.cpp 
	resource.h talk.cpp 
Log Message:
minor cleanup

Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- cutaway.cpp	6 Apr 2004 20:15:19 -0000	1.128
+++ cutaway.cpp	6 Aug 2004 11:28:33 -0000	1.129
@@ -114,7 +114,7 @@
 
 	byte *bankNamesPtr  = _fileData + READ_BE_UINT16(ptr);
 	ptr += 2;
-	//debug(6, "Bank name file offset = %08x", 20 + bankNamesPtr - _fileData);
+	debug(6, "Bank name file offset = %08x", 20 + bankNamesPtr - _fileData);
 
 	_objectData = ptr;
 
@@ -159,7 +159,7 @@
 	int bankNameCount = READ_BE_UINT16(ptr);
 	ptr += 2;
 
-	//debug(6, "Bank name count = %i", bankNameCount);
+	debug(6, "Bank name count = %i", bankNameCount);
 
 	/*
 		 The _bankNames zero-based array is the one-based BANK_NAMEstr array in
@@ -170,7 +170,7 @@
 		ptr = Talk::getString(ptr, _bankNames[j], MAX_FILENAME_LENGTH);
 
 		if (_bankNames[j][0]) {
-			//debug(6, "Bank name %i = '%s'", j, _bankNames[j]);
+			debug(6, "Bank name %i = '%s'", j, _bankNames[j]);
 			j++;
 		}
 	}
@@ -272,7 +272,7 @@
 	for (int i = 0; i < object.personCount; i++) {
 		object.person[i] = (int16)READ_BE_INT16(ptr);
 		ptr += 2;
-		//debug(6, "[%i] Turn on person %i", i, object.person[i]);
+		debug(7, "[%i] Turn on person %i", i, object.person[i]);
 	}
 
 	return ptr;
@@ -726,13 +726,10 @@
 }
 
 static void findCdCut(const char *basename, int index, char *result) {
-	// Function find_cd_cut, lines 5-15 in execute.c
-
 	strcpy(result, basename);
 	for (int i = strlen(basename); i < 5; i++)
 		result[i] = '_';
 	snprintf(result + 5, 3, "%02i", index);
-	//debug(6, "findCdCut(\"%s\", %i, \"%s\")", basename, index, result);
 }
 
 void Cutaway::handlePersonRecord(

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- graphics.cpp	6 Apr 2004 20:15:19 -0000	1.101
+++ graphics.cpp	6 Aug 2004 11:28:33 -0000	1.102
@@ -190,6 +190,11 @@
 	box = _defaultBox;
 }
 
+static int compareBobDrawOrder(const void *a, const void *b) {
+	const BobSlot *bob1 = *(const BobSlot * const *)a;
+	const BobSlot *bob2 = *(const BobSlot * const *)b;
+	return bob1->y - bob2->y;
+}
 
 const Box Graphics::_gameScreenBox(0, 0, GAME_SCREEN_WIDTH - 1, ROOM_ZONE_HEIGHT - 1);
 const Box Graphics::_fullScreenBox(0, 0, GAME_SCREEN_WIDTH - 1, GAME_SCREEN_HEIGHT - 1);
@@ -333,7 +338,6 @@
 
 	// animate/move the bobs
 	for (int32 i = 0; i < ARRAYSIZE(_bobs); ++i) {
-
 		BobSlot *pbs = &_bobs[i];
 		if (pbs->active) {
 			_sortedBobs[_sortedBobsCount] = pbs;
@@ -354,19 +358,7 @@
 			}
 		}
 	}
-
-	// bubble sort the bobs
-	for (int32 index = 0; index < _sortedBobsCount - 1; ++index) {
-		int32 smallest = index;
-		for (int32 compare = index + 1; compare <= _sortedBobsCount - 1; ++compare) {
-			if (_sortedBobs[compare]->y < _sortedBobs[smallest]->y) {
-				smallest = compare;
-			}
-		}
-		if (index != smallest) {
-			SWAP(_sortedBobs[index], _sortedBobs[smallest]);
-		}
-	}
+	qsort(_sortedBobs, _sortedBobsCount, sizeof(BobSlot *), compareBobDrawOrder);
 }
 
 void Graphics::drawBobs() {

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- logic.cpp	3 Apr 2004 17:58:58 -0000	1.198
+++ logic.cpp	6 Aug 2004 11:28:33 -0000	1.199
@@ -1247,7 +1247,7 @@
 	struct { 
 		uint16 obj;
 		int16 song;
-	} songs[] = { 
+	} cmds[] = { 
 		{ 0x2A,  3 },
 		{ 0x29, 16 },
 		{ 0x2F,  6 },
@@ -1255,9 +1255,9 @@
 		{ 0x2B,  3 },
 		{ 0x30,  3 }
 	};
-	for (int i = 0; i < ARRAYSIZE(songs); ++i) {
-		if (songs[i].obj == prevObj) {
-			_vm->sound()->playSong(songs[i].song);
+	for (int i = 0; i < ARRAYSIZE(cmds); ++i) {
+		if (cmds[i].obj == prevObj) {
+			_vm->sound()->playSong(cmds[i].song);
 		}
 	}
 
@@ -1852,7 +1852,7 @@
 	_vm->input()->fastMode(true);
 	_vm->update();
 				
-	int i = 4, k = 160;
+	int k = 160;
 
 	// Adjust thug1 gun so it matches rest of body
 	bob_thugA1->x += (k / 2) * 2 - 45; 
@@ -1866,32 +1866,25 @@
 	bob_thugB1->x += (k / 2) * 4 + k; 
 	bob_thugB2->x += (k / 2) * 4 + k; 
 
-	if (i == 3) {
-		bob_thugB1->x += 10;
-		bob_thugB2->x += 10;
-	}
-
-	i *= 2;
-
 	int horizontalScroll = 0;
 	while (horizontalScroll < k && !_vm->input()->cutawayQuit()) {
 
-		horizontalScroll = horizontalScroll + i;
+		horizontalScroll += 8;
 		if (horizontalScroll > k)
 			horizontalScroll = k;
 
 		_vm->display()->horizontalScroll(horizontalScroll);
 
-		bob_thugA1->x -= i * 2; 
-		bob_thugA2->x -= i * 2; 
-		bob_thugA3->x -= i * 2;
+		bob_thugA1->x -= 16; 
+		bob_thugA2->x -= 16; 
+		bob_thugA3->x -= 16;
 
-		bob_hugh1->x -= i * 3;
-		bob_hugh2->x -= i * 3;
-		bob_hugh3->x -= i * 3;
+		bob_hugh1->x -= 24;
+		bob_hugh2->x -= 24;
+		bob_hugh3->x -= 24;
 
-		bob_thugB1->x -= i * 4;
-		bob_thugB2->x -= i * 4;
+		bob_thugB1->x -= 32;
+		bob_thugB2->x -= 32;
 
 		_vm->update();
 	}
@@ -1921,20 +1914,19 @@
 
 	int horizontalScroll = _vm->display()->horizontalScroll();
 
-	int i = 1;
 	while (horizontalScroll < 290 && !_vm->input()->cutawayQuit()) {
 
-		horizontalScroll = horizontalScroll + i;
+		++horizontalScroll;
 		if (horizontalScroll > 290)
 			horizontalScroll = 290;
 
 		_vm->display()->horizontalScroll(horizontalScroll);
 
-		bob_box  ->x -= i * 2;
-		bob_beam ->x -= i;
-		bob_crate->x -= i * 3;
-		bob_clock->x -= i * 2;
-		bob_hands->x -= i * 2;
+		bob_box  ->x -= 2;
+		bob_beam ->x -= 1;
+		bob_crate->x -= 3;
+		bob_clock->x -= 2;
+		bob_hands->x -= 2;
 
 		_vm->update();
 	}
@@ -1950,19 +1942,18 @@
 				
 	int horizontalScroll = _vm->display()->horizontalScroll();
 
-	int i = 5;
 	while ((horizontalScroll > 0 || bob21->x < 136) && !_vm->input()->cutawayQuit()) {
 
-		horizontalScroll -= i;
+		horizontalScroll -= 5;
 		if (horizontalScroll < 0)
 			horizontalScroll = 0;
 
 		_vm->display()->horizontalScroll(horizontalScroll);
 
 		if (horizontalScroll < 272 && bob21->x < 136)
-			bob21->x += (i/2);
+			bob21->x += 2;
 
-		bob22->x += i;
+		bob22->x += 5;
 
 		_vm->update();
 	}

Index: queen.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/queen.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- queen.cpp	5 Aug 2004 18:17:39 -0000	1.87
+++ queen.cpp	6 Aug 2004 11:28:33 -0000	1.88
@@ -227,7 +227,7 @@
 		if (file->write(saveData, dataSize) != dataSize) {
 			warning("Can't write file '%s'. (Disk full?)", name);
 		}
-		delete saveData;
+		delete[] saveData;
 		delete file;
 	} else {
 		warning("Can't create file '%s', game not saved", name);

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- resource.cpp	5 Aug 2004 18:10:34 -0000	1.47
+++ resource.cpp	6 Aug 2004 11:28:33 -0000	1.48
@@ -47,9 +47,9 @@
 };
 
 static int compareResourceEntry(const void *a, const void *b) {
-	const char *key = (const char *)a;
+	const char *filename = (const char *)a;
 	const ResourceEntry *entry = (const ResourceEntry *)b;
-	return strcmp(key, entry->filename);
+	return strcmp(filename, entry->filename);
 }
 
 Resource::Resource(const Common::String &datafilePath)
@@ -84,14 +84,6 @@
 	re = (ResourceEntry *)bsearch(entryName, _resourceTable, _resourceEntries, sizeof(ResourceEntry), compareResourceEntry);
 #else
 	// cyx: is that code still necessary ?
-	uint32 low = 0;
-	uint32 high = _resourceEntries - 1;
-
-	if (!strcmp(entryName, _resourceTable[low].filename))
-		return low;
-	if (!strcmp(entryName, _resourceTable[high].filename))
-		return high;
-
 	// Does work for me (????) use this instead
 	uint32 cur = 0;
 	do {
@@ -99,7 +91,7 @@
 			re = &_resourceTable[cur];
 			break;
 		}
-	} while (cur++ <= high);
+	} while (cur++ < _resourceEntries);
 #endif
 
 	debug(7, "Couldn't find file '%s'", entryName);
@@ -163,7 +155,9 @@
 }
 
 void Resource::checkJASVersion() {
-	int32 offset = resourceEntry("QUEEN.JAS")->offset;
+	ResourceEntry *re = resourceEntry("QUEEN.JAS");
+	assert(re != NULL);
+	uint32 offset = re->offset;
 	if (isDemo())
 		offset += JAS_VERSION_OFFSET_DEMO;
 	else if (isInterview())
@@ -200,7 +194,7 @@
 bool Resource::readTableFile(const GameVersion *gameVersion) {
 	File tableFile;
 	tableFile.open(_tableFilename);
-	if (tableFile.isOpen() && tableFile.readUint32BE() == 'QTBL') {
+	if (tableFile.isOpen() && tableFile.readUint32BE() == MKID_BE('QTBL')) {
 		if (tableFile.readUint32BE() != CURRENT_TBL_VERSION)
 			warning("Incorrect version of queen.tbl, please update it");
 		tableFile.seek(gameVersion->tableOffset);
@@ -211,7 +205,7 @@
 }
 
 void Resource::readTableCompResource() {
-	if (_resourceFile->readUint32BE() != 'QTBL')
+	if (_resourceFile->readUint32BE() != MKID_BE('QTBL'))
 		error("Invalid table header");
 
 	_resourceFile->read(_versionString, 6);
@@ -247,7 +241,9 @@
 
 File *Resource::giveCompressedSound(const char *filename) {
 	assert(strstr(filename, ".SB"));
-	_resourceFile->seek(resourceEntry(filename)->offset);
+	ResourceEntry *re = resourceEntry(filename);
+	assert(re != NULL);
+	_resourceFile->seek(re->offset);
 	return _resourceFile;
 }
 

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- resource.h	5 Aug 2004 18:10:34 -0000	1.38
+++ resource.h	6 Aug 2004 11:28:33 -0000	1.39
@@ -37,9 +37,7 @@
 	VER_GER_TALKIE   = 5,
 	VER_ITA_FLOPPY   = 6,
 	VER_ITA_TALKIE   = 7,
-	// VER_SPA_FLOPPY
 	VER_SPA_TALKIE   = 8,
-	// VER_HEB_FLOPPY
 	VER_HEB_TALKIE	 = 9,
 	VER_DEMO_PCGAMES = 10,
 	VER_DEMO         = 11,

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- talk.cpp	5 Aug 2004 18:10:34 -0000	1.99
+++ talk.cpp	6 Aug 2004 11:28:33 -0000	1.100
@@ -598,8 +598,8 @@
 		person = &joe_person;
 	}
 	
-	//debug(6, "Sentence '%s' is said by person '%s' and voice files with prefix '%s' played",
-	//		sentence, person->name, voiceFilePrefix);
+	debug(6, "Sentence '%s' is said by person '%s' and voice files with prefix '%s' played",
+			sentence, person->name, voiceFilePrefix);
 
 	if (sentence[0] == '\0') {
 		goto exit;
@@ -658,7 +658,6 @@
 	return personWalking;
 }
 
-// cyx : there is a similar function in Cutaway, what about merging them ?
 int Talk::countSpaces(const char *segment) {
 	int tmp = 0;
 
@@ -764,7 +763,6 @@
 		int bankNum) {
 	// lines 1730-1823 in talk.c
 
-#if 0
 	debug(6, "Talk::defaultAnimation(\"%s\", %s, {\"%s\", %i, ...}, %i, %i)",
 			segment, 
 			isJoe ? "true" : "false",
@@ -772,7 +770,6 @@
 			parameters->state,
 			startFrame,
 			bankNum);
-#endif
 
 	if (segment[0] != 0)  {
 
@@ -859,8 +856,6 @@
 		const char *voiceFilePrefix,
 		int index)
 {
-	// Function SPEAK_SUB, lines 1406-1870 in talk.a
-
 	int i;
 	char segment[MAX_STRING_SIZE];
 	memcpy(segment, segmentStart, length);
@@ -869,9 +864,6 @@
 	char voiceFileName[MAX_STRING_SIZE];
 	snprintf(voiceFileName, sizeof(voiceFileName), "%s%1x", voiceFilePrefix, index + 1);
 
-	// debug(6, "Sentence segment '%*s' is said by person '%s' and voice file '%s' is played",
-	//		length, segment, person->name, voiceFileName);
-
 	// FIXME - it seems the french talkie version has a useless voice file ; 
 	// the c30e_102 file is very similar to c30e_101, so there is no need to 
 	// play it. This voice was used in room 30 (N8) when talking to Klunk.





More information about the Scummvm-git-logs mailing list