[Scummvm-cvs-logs] CVS: scummvm/simon simon.cpp,1.4,1.5

Ludvig Strigeus strigeus at users.sourceforge.net
Sat Apr 13 04:45:05 CEST 2002


Update of /cvsroot/scummvm/scummvm/simon
In directory usw-pr-cvs1:/tmp/cvs-serv32336

Modified Files:
	simon.cpp 
Log Message:
try both uppercase and lowercase filename when opening files

Index: simon.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/simon/simon.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** simon.cpp	13 Apr 2002 11:31:54 -0000	1.4
--- simon.cpp	13 Apr 2002 11:44:56 -0000	1.5
***************
*** 52,58 ****
  	1316/4, /* MUSIC_INDEX_BASE */
  	0,		/* SOUND_INDEX_BASE */
! 	"simon.gme",	/* gme_filename */
! 	"simon.wav",	/* wav_filename */
! 	"gamepc",			/* gamepc_filename */
  };
  
--- 52,58 ----
  	1316/4, /* MUSIC_INDEX_BASE */
  	0,		/* SOUND_INDEX_BASE */
! 	"SIMON.GME",	/* gme_filename */
! 	"SIMON.WAV",	/* wav_filename */
! 	"GAMEPC",			/* gamepc_filename */
  };
  
***************
*** 68,74 ****
  	1128/4, /* MUSIC_INDEX_BASE */
  	1660/4,			/* SOUND_INDEX_BASE */
! 	"simon2.gme", /* gme_filename */
! 	"simon2.wav",	/* wav_filename */
! 	"gsptr30",		/* gamepc_filename */
  };
  
--- 68,74 ----
  	1128/4, /* MUSIC_INDEX_BASE */
  	1660/4,			/* SOUND_INDEX_BASE */
! 	"SIMON2.GME", /* gme_filename */
! 	"SIMON2.WAV",	/* wav_filename */
! 	"GSPTR30",		/* gamepc_filename */
  };
  
***************
*** 109,112 ****
--- 109,131 ----
  }
  
+ FILE *fopen_maybe_lowercase(const char *filename) {
+ #ifdef WIN32
+ 	/* win32 is not case sensitive */
+ 	return fopen(filename, "rb");
+ #else
+ 	/* first try with the original filename */
+ 	FILE *in = fopen(filename, "rb");
+ 	char buf[50], *s;
+ 
+ 	if (in) return in;
+ 	/* if that fails, convert the filename into lowercase and retry */
+ 	
+ 	s=buf;
+ 	do *s++ = tolower(*filename++); while (filename[-1]);
+ 
+ 	return fopen(buf, "rb");
+ #endif
+ }
+ 
  
  byte *SimonState::allocateItem(uint size) {
***************
*** 528,532 ****
  
  	/* read main gamepc file */
! 	in = fopen(filename, "rb");
  	if (in==NULL) return false;
  
--- 547,551 ----
  
  	/* read main gamepc file */
! 	in = fopen_maybe_lowercase(filename);
  	if (in==NULL) return false;
  
***************
*** 546,550 ****
  
  	/* Read list of TABLE resources */
! 	in = fopen("tbllist", "rb");
  	if (in==NULL) return false;
  
--- 565,569 ----
  
  	/* Read list of TABLE resources */
! 	in = fopen_maybe_lowercase("TBLLIST");
  	if (in==NULL) return false;
  
***************
*** 565,569 ****
  	
  	/* Read list of TEXT resources */
! 	in = fopen("stripped.txt", "rb");
  	if (in==NULL) return false;
  
--- 584,588 ----
  	
  	/* Read list of TEXT resources */
! 	in = fopen_maybe_lowercase("STRIPPED.TXT");
  	if (in==NULL) return false;
  
***************
*** 2186,2190 ****
  /* Simon1DOS load tables file */
  uint SimonState::loadTextFile_simon1(const char *filename, byte *dst) {
! 	FILE *fo = fopen(filename, "rb");
  	uint32 size;
  	
--- 2205,2209 ----
  /* Simon1DOS load tables file */
  uint SimonState::loadTextFile_simon1(const char *filename, byte *dst) {
! 	FILE *fo = fopen_maybe_lowercase(filename);
  	uint32 size;
  	
***************
*** 2205,2209 ****
  
  FILE *SimonState::openTablesFile_simon1(const char *filename) {
! 	FILE *fo = fopen(filename, "rb");
  	if (fo==NULL)
  		error("openTablesFile: Cannot open '%s'", filename);
--- 2224,2228 ----
  
  FILE *SimonState::openTablesFile_simon1(const char *filename) {
! 	FILE *fo = fopen_maybe_lowercase(filename);
  	if (fo==NULL)
  		error("openTablesFile: Cannot open '%s'", filename);
***************
*** 3124,3128 ****
  
  void SimonState::loadIconFile() {
! 	FILE *in = fopen("icon.dat", "rb");
  	uint size;
  
--- 3143,3147 ----
  
  void SimonState::loadIconFile() {
! 	FILE *in = fopen_maybe_lowercase("ICON.DAT");
  	uint size;
  
***************
*** 6523,6527 ****
  		uint32 size;
  
! 		in = fopen(filename, "rb");
  
  		if(in==NULL) {
--- 6542,6546 ----
  		uint32 size;
  
! 		in = fopen_maybe_lowercase(filename);
  
  		if(in==NULL) {
***************
*** 7260,7264 ****
  		sprintf(buf, "%.3d%d.VGA", vga_id>>1, (vga_id&1)+1);
  
! 		in = fopen(buf, "rb");
  		if (in==NULL)
  			error("read_vga_from_datfile_1: cannot open %s", buf);
--- 7279,7283 ----
  		sprintf(buf, "%.3d%d.VGA", vga_id>>1, (vga_id&1)+1);
  
! 		in = fopen_maybe_lowercase(buf);
  		if (in==NULL)
  			error("read_vga_from_datfile_1: cannot open %s", buf);
***************
*** 7289,7293 ****
  		sprintf(buf, "%.3d%d.VGA", id>>1, (id&1)+1);
  
! 		in = fopen(buf, "rb");
  		if (in==NULL)
  			error("read_vga_from_datfile_2: cannot open %s", buf);
--- 7308,7312 ----
  		sprintf(buf, "%.3d%d.VGA", id>>1, (id&1)+1);
  
! 		in = fopen_maybe_lowercase(buf);
  		if (in==NULL)
  			error("read_vga_from_datfile_2: cannot open %s", buf);
***************
*** 7327,7331 ****
  void SimonState::openGameFile() {
  	if (_game != GAME_SIMON1DOS) {
! 		_game_file = fopen(gss->gme_filename, "rb");
  
  		if (_game_file==NULL)
--- 7346,7350 ----
  void SimonState::openGameFile() {
  	if (_game != GAME_SIMON1DOS) {
! 		_game_file = fopen_maybe_lowercase(gss->gme_filename);
  
  		if (_game_file==NULL)
***************
*** 7720,7724 ****
  	errno = 0;
  
! 	f = fopen(filename, "rb");
  	if (f==NULL)
  		return false;
--- 7739,7743 ----
  	errno = 0;
  
! 	f = fopen_maybe_lowercase(filename);
  	if (f==NULL)
  		return false;
***************
*** 7827,7846 ****
  
  void SimonState::initSound() {
! 	const char *s = gss->wav_filename;
  
! 	_voice_offsets = NULL;
  
! 	_voice_file = fopen(s, "rb");
! 	if (_voice_file == NULL) {
! 		warning("Cannot open %s",s);
! 		return;
! 	}
  
! 	_voice_offsets = (uint32*)malloc(gss->NUM_VOICE_RESOURCES * sizeof(uint32));
! 	if (_voice_offsets == NULL)
! 		error("Out of memory for voice offsets");
  
! 	if (fread(_voice_offsets, gss->NUM_VOICE_RESOURCES * sizeof(uint32), 1, _voice_file) != 1)
! 		error("Cannot read voice offsets");
  }
  
--- 7846,7868 ----
  
  void SimonState::initSound() {
! 	/* only read voice file in windows game */
! 	if (_game & GAME_WIN) {
! 		const char *s = gss->wav_filename;
  
! 		_voice_offsets = NULL;
  
! 		_voice_file = fopen_maybe_lowercase(s);
! 		if (_voice_file == NULL) {
! 			warning("Cannot open %s",s);
! 			return;
! 		}
  
! 		_voice_offsets = (uint32*)malloc(gss->NUM_VOICE_RESOURCES * sizeof(uint32));
! 		if (_voice_offsets == NULL)
! 			error("Out of memory for voice offsets");
  
! 		if (fread(_voice_offsets, gss->NUM_VOICE_RESOURCES * sizeof(uint32), 1, _voice_file) != 1)
! 			error("Cannot read voice offsets");
! 	}
  }
  
***************
*** 7941,7946 ****
  	} else {
  		char buf[50];
! 		sprintf(buf, "mod%d.mus", music);
! 		f = fopen(buf, "rb");
  		if (f==NULL) {
  			warning("Cannot load music from '%s'", buf);
--- 7963,7968 ----
  	} else {
  		char buf[50];
! 		sprintf(buf, "MOD%d.MUS", music);
! 		f = fopen_maybe_lowercase(buf);
  		if (f==NULL) {
  			warning("Cannot load music from '%s'", buf);





More information about the Scummvm-git-logs mailing list