aboutsummaryrefslogtreecommitdiff
path: root/simon
diff options
context:
space:
mode:
authorJames Brown2002-05-29 13:04:56 +0000
committerJames Brown2002-05-29 13:04:56 +0000
commite192a6ca87ae2bf7e43f948a1d08f80b1e93ebd9 (patch)
tree0377170e01e9b4f3a97a228a8fa78d6fdaea1958 /simon
parentba6c570e20f824c3d17479e4fbcd7b2eb61f3dd7 (diff)
downloadscummvm-rg350-e192a6ca87ae2bf7e43f948a1d08f80b1e93ebd9.tar.gz
scummvm-rg350-e192a6ca87ae2bf7e43f948a1d08f80b1e93ebd9.tar.bz2
scummvm-rg350-e192a6ca87ae2bf7e43f948a1d08f80b1e93ebd9.zip
Rewrite Simon filename parser.
svn-id: r4388
Diffstat (limited to 'simon')
-rw-r--r--simon/simon.cpp41
1 files changed, 24 insertions, 17 deletions
diff --git a/simon/simon.cpp b/simon/simon.cpp
index 1e012df780..0a3c95572f 100644
--- a/simon/simon.cpp
+++ b/simon/simon.cpp
@@ -121,28 +121,35 @@ void SimonState::show_it(void *buf) {
}
FILE *SimonState::fopen_maybe_lowercase(const char *filename) {
- char buf[256], *e;
-
+ FILE *in;
+ char buf[256], dotbuf[256], *e;
const char *s = _game_path;
- strcpy(buf, s);
- e = strchr(buf, 0);
- strcpy(e, filename);
-
-#if defined(WIN32) || defined(__MORPHOS__)
- /* win32 is not case sensitive */
- return fopen(buf, "rb");
-#else
- /* first try with the original filename */
- FILE *in = fopen(buf, "rb");
+ strcpy(buf, s); strcat(buf, filename);
+ strcpy(dotbuf, buf); strcat(dotbuf, "."); // '.' appended version
+ // for dumb vfat drivers
+
+ /* original filename */
+ in = fopen(buf, "rb");
+ if (in) return in;
+ /* lowercase original filename */
+ e = buf; do *e = tolower(*e); while(*e++);
+ in = fopen(buf, "rb");
if (in) return in;
- /* if that fails, convert the filename into lowercase and retry */
- do *e = tolower(*e); while(*e++);
+ if (strchr(buf, '.'))
+ return NULL;
- return fopen(buf, "rb");
-#endif
+ /* dot appended original filename */
+ in = fopen(dotbuf, "rb");
+ if (in) return in;
+
+ /* lowercase dot appended */
+ e = dotbuf; do *e = tolower(*e); while(*e++);
+ in = fopen(dotbuf, "rb");
+ warning("loading %s\n", dotbuf);
+ return in;
}
@@ -2098,7 +2105,7 @@ void SimonState::loadTextIntoMem(uint string_id) {
while (*p) {
for(i=0;*p;p++,i++)
filename[i] = *p;
- filename[i] = 0;
+ filename[i] = 0;
p++;
base_max = (p[0]<<8) | p[1];