[Scummvm-cvs-logs] SF.net SVN: scummvm:[54334] scummvm/trunk/backends

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Nov 18 18:42:28 CET 2010


Revision: 54334
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54334&view=rev
Author:   fingolfin
Date:     2010-11-18 17:42:28 +0000 (Thu, 18 Nov 2010)

Log Message:
-----------
DS: cleanup

Modified Paths:
--------------
    scummvm/trunk/backends/fs/ds/ds-fs.cpp
    scummvm/trunk/backends/platform/ds/arm9/source/cdaudio.cpp

Modified: scummvm/trunk/backends/fs/ds/ds-fs.cpp
===================================================================
--- scummvm/trunk/backends/fs/ds/ds-fs.cpp	2010-11-18 17:38:56 UTC (rev 54333)
+++ scummvm/trunk/backends/fs/ds/ds-fs.cpp	2010-11-18 17:42:28 UTC (rev 54334)
@@ -460,8 +460,8 @@
 	MAX_FILE_HANDLES = 32
 };
 
-static bool inited = false;
-static DS::fileHandle s_handle[MAX_FILE_HANDLES];
+static bool inited = false;	// FIXME: Avoid non-const global vars
+static DS::fileHandle s_handle[MAX_FILE_HANDLES];	// FIXME: Avoid non-const global vars
 
 FILE *std_fopen(const char *name, const char *mode) {
 	if (!inited) {
@@ -671,18 +671,18 @@
 	}
 
 	switch (whence) {
-		case SEEK_CUR:
-			handle->pos += offset;
-			break;
-		case SEEK_SET:
-			handle->pos = offset;
-			break;
-		case SEEK_END:
-			handle->pos = handle->size + offset;
-			break;
-		default:
-			handle->pos = offset;
-			break;
+	case SEEK_CUR:
+		handle->pos += offset;
+		break;
+	case SEEK_SET:
+		handle->pos = offset;
+		break;
+	case SEEK_END:
+		handle->pos = handle->size + offset;
+		break;
+	default:
+		handle->pos = offset;
+		break;
 	}
 
 	return 0;

Modified: scummvm/trunk/backends/platform/ds/arm9/source/cdaudio.cpp
===================================================================
--- scummvm/trunk/backends/platform/ds/arm9/source/cdaudio.cpp	2010-11-18 17:38:56 UTC (rev 54333)
+++ scummvm/trunk/backends/platform/ds/arm9/source/cdaudio.cpp	2010-11-18 17:42:28 UTC (rev 54334)
@@ -77,6 +77,7 @@
 	unsigned char	sample[1024];
 } __attribute__ ((packed));
 
+static bool s_started = false;
 static bool s_active = false;
 static WaveHeader waveHeader;
 static Header blockHeader;
@@ -143,9 +144,8 @@
 
 	char str[100];
 
-	if (path[strlen(path.c_str()) - 1] != '/') {
-		path = path + "/";
-	}
+	if (path.lastChar() != '/')
+		path += '/';
 
 	Common::String fname;
 
@@ -199,7 +199,6 @@
 	dataChunkStart = DS::std_ftell(s_file);
 
 
-	static bool started = false;
 	sampleNum = 0;
 	blockCount = 0;
 
@@ -207,11 +206,11 @@
 	IPC->streamFillNeeded[1] = true;
 	IPC->streamFillNeeded[2] = true;
 	IPC->streamFillNeeded[3] = true;
-	if (!started) {
+	if (!s_started) {
 		fillPos = 0;
 		audioBuffer = (s16 *) malloc(BUFFER_SIZE * 2);
 		decompressionBuffer = (s16 *) malloc(waveHeader.fmtExtra * 2);
-		started = true;
+		s_started = true;
 //		consolePrintf("****Starting buffer*****\n");
 		memset(audioBuffer, 0, BUFFER_SIZE * 2);
 		memset(decompressionBuffer, 0, waveHeader.fmtExtra * 2);
@@ -472,20 +471,20 @@
 }
 
 bool trackExists(int num) {
-	Common::String path = ConfMan.get("path");
-
+	Common::String path;
 	char fname[128];
+	FILE *file;
 
 	sprintf(fname, "track%d.wav", num);
 
-	if (path[strlen(path.c_str()) - 1] == '/') {
-		path = path + fname;
-	} else {
-		path = path + "/" + fname;
-	}
+	path = ConfMan.get("path");
+	if (path.lastChar() != '/')
+		path += '/';
+	path += fname;
+
 	consolePrintf("Looking for %s...", path.c_str());
 
-	FILE *file = DS::std_fopen(path.c_str(), "r");
+	file = DS::std_fopen(path.c_str(), "r");
 	if (file) {
 		consolePrintf("Success!\n");
 		setActive(true);
@@ -495,27 +494,24 @@
 
 	sprintf(fname, "track%02d.wav", num);
 
-	 path = ConfMan.get("path");
+	path = ConfMan.get("path");
+	if (path.lastChar() != '/')
+		path += '/';
+	path += fname;
 
-	if (path[strlen(path.c_str()) - 1] == '/') {
-		path = path + fname;
-	} else {
-		path = path + "/" + fname;
-	}
-
 	consolePrintf("Looking for %s...", path.c_str());
 
-
-	if ((file = DS::std_fopen(path.c_str(), "r"))) {
+	file = DS::std_fopen(path.c_str(), "r");
+	if (file) {
 		consolePrintf("Success!\n");
 		setActive(true);
 		DS::std_fclose(file);
 		return true;
-	} else {
-		setActive(false);
-		consolePrintf("Failed!\n");
-		return false;
 	}
+
+	setActive(false);
+	consolePrintf("Failed!\n");
+	return false;
 }
 
 bool checkCD() {


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