[Scummvm-cvs-logs] SF.net SVN: scummvm:[38497] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Feb 18 20:14:40 CET 2009


Revision: 38497
          http://scummvm.svn.sourceforge.net/scummvm/?rev=38497&view=rev
Author:   fingolfin
Date:     2009-02-18 19:14:40 +0000 (Wed, 18 Feb 2009)

Log Message:
-----------
SCI: Some random cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/include/resource.h
    scummvm/trunk/engines/sci/scicore/tools.cpp
    scummvm/trunk/engines/sci/sfx/player/polled.cpp

Modified: scummvm/trunk/engines/sci/include/resource.h
===================================================================
--- scummvm/trunk/engines/sci/include/resource.h	2009-02-18 19:12:13 UTC (rev 38496)
+++ scummvm/trunk/engines/sci/include/resource.h	2009-02-18 19:14:40 UTC (rev 38497)
@@ -72,16 +72,6 @@
 #  include <fcntl.h>
 #endif
 
-// FIXME: Get rid of G_DIR_SEPARATOR  / G_DIR_SEPARATOR_S
-#if _MSC_VER
-#  define G_DIR_SEPARATOR_S "\\"
-#  define G_DIR_SEPARATOR '\\'
-#else
-#  define G_DIR_SEPARATOR_S "/"
-#  define G_DIR_SEPARATOR '/'
-#endif
-
-
 #define GUINT16_SWAP_LE_BE_CONSTANT(val) ((((val) & 0x00ff) << 8) | (((val) & 0xff00) >> 8))
 
 #define GUINT32_SWAP_LE_BE_CONSTANT(val)  ( \
@@ -121,16 +111,13 @@
 #    define scimkdir(arg1,arg2) mkdir(arg1,arg2)
 #endif
 
-#ifndef _GET_INT_16
-#define _GET_INT_16
-
 static inline gint16
 getInt16(byte *d) {
 	return (gint16)(*d | (d[1] << 8));
 }
 
 #define getUInt16(d) (guint16)(getInt16(d))
-#endif
+
 /* Turns a little endian 16 bit value into a machine-dependant 16 bit value
 ** Parameters: d: Pointer to the memory position from which to read
 ** Returns   : (gint16) The (possibly converted) 16 bit value
@@ -265,15 +252,6 @@
 ** Returns   : (int) filesize of the file, -1 on error
 */
 
-char *
-_fcaseseek(const char *fname, sci_dir_t *dir);
-/* Returns the case-sensitive filename of a file.
-** Expects *dir to be uninitialized and the caller to free it afterwards.
-** Parameters: (const char *) fname: Name of file to get case-sensitive.
-**             (sci_dir_t *) dir: Directory to find file within.
-** Returns   : (char *) Case-sensitive filename of the file.
-*/
-
 /* Simple heuristic to work around array handling peculiarity in SQ4:
 It uses StrAt() to read the individual elements, so we must determine
 whether a string is really a string or an array. */

Modified: scummvm/trunk/engines/sci/scicore/tools.cpp
===================================================================
--- scummvm/trunk/engines/sci/scicore/tools.cpp	2009-02-18 19:12:13 UTC (rev 38496)
+++ scummvm/trunk/engines/sci/scicore/tools.cpp	2009-02-18 19:14:40 UTC (rev 38497)
@@ -64,6 +64,17 @@
 
 #include "sci/include/engine.h"
 
+
+// FIXME: Get rid of G_DIR_SEPARATOR  / G_DIR_SEPARATOR_S
+#if _MSC_VER
+#  define G_DIR_SEPARATOR_S "\\"
+#  define G_DIR_SEPARATOR '\\'
+#else
+#  define G_DIR_SEPARATOR_S "/"
+#  define G_DIR_SEPARATOR '/'
+#endif
+
+
 #ifdef HAVE_SYS_TIME_H
 #  include <sys/time.h>
 #endif
@@ -389,7 +400,6 @@
 	return 0;
 }
 
-
 /*-- Yielding to the scheduler --*/
 
 #ifdef HAVE_SCHED_YIELD
@@ -423,13 +433,17 @@
 #endif /* !HAVE_SCHED_YIELD */
 
 
-char *
-_fcaseseek(const char *fname, sci_dir_t *dir)
+/* Returns the case-sensitive filename of a file.
+** Expects *dir to be uninitialized and the caller to free it afterwards.
+** Parameters: (const char *) fname: Name of file to get case-sensitive.
+**             (sci_dir_t *) dir: Directory to find file within.
+** Returns   : (char *) Case-sensitive filename of the file.
+*/
+char *_fcaseseek(const char *fname, sci_dir_t *dir) {
 /* Expects *dir to be uninitialized and the caller to
  ** free it afterwards  */
-{
-	char *buf, *iterator;
-	char _buf[14];
+
+	Common::String buf;
 	char *retval = NULL, *name;
 
 #ifdef _MSC_VER
@@ -441,23 +455,17 @@
 		BREAKPOINT();
 	}
 
-	if (strlen(fname) > 12) /* not a DOS file? */
-		buf = (char*)sci_malloc(strlen(fname) + 1);
-	else
-		buf = _buf;
-
 	sci_init_dir(dir);
 
 	/* Replace all letters with '?' chars */
-	strcpy(buf, fname);
-	iterator = buf;
-	while (*iterator) {
+	buf = fname;
+	
+	for (Common::String::iterator iterator = buf.begin(); iterator != buf.end(); ++iterator) {
 		if (isalpha(*iterator))
 			*iterator = '?';
-		iterator++;
 	}
 
-	name = sci_find_first(dir, buf);
+	name = sci_find_first(dir, buf.c_str());
 
 	while (name && !retval) {
 		if (!scumm_stricmp(fname, name))
@@ -466,9 +474,6 @@
 			name = sci_find_next(dir);
 	}
 
-	if (strlen(fname) > 12)
-		free(buf);
-
 	return retval;
 }
 

Modified: scummvm/trunk/engines/sci/sfx/player/polled.cpp
===================================================================
--- scummvm/trunk/engines/sci/sfx/player/polled.cpp	2009-02-18 19:12:13 UTC (rev 38496)
+++ scummvm/trunk/engines/sci/sfx/player/polled.cpp	2009-02-18 19:14:40 UTC (rev 38497)
@@ -29,9 +29,7 @@
 #include "sci/sfx/softseq.h"
 #include "sci/sfx/mixer.h"
 
-#ifndef _MSC_VER
-#include <unistd.h> // for close()
-#endif
+#include "common/file.h"
 
 static song_iterator_t *play_it;
 static int play_paused = 0;
@@ -167,20 +165,15 @@
 static int
 pp_init(resource_mgr_t *resmgr, int expected_latency) {
 	resource_t *res = NULL, *res2 = NULL;
-	int fd;
 
 	if (!mixer)
 		return SFX_ERROR;
 
 	/* FIXME Temporary hack to detect Amiga games. */
-	fd = sci_open("bank.001", O_RDONLY);
-
-	if (fd == SCI_INVALID_FD)
+	if (!Common::File::exists("bank.001"))
 		seq = sfx_find_softseq(NULL);
-	else {
-		close(fd);
+	else
 		seq = sfx_find_softseq("amiga");
-	}
 
 	if (!seq) {
 		sciprintf("[sfx:seq:polled] Initialisation failed: Could not find software sequencer\n");


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