summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-11-18 18:28:32 +0000
committerrubidium <rubidium@openttd.org>2007-11-18 18:28:32 +0000
commit92e0bf68e3b4825e4093d5d67a2da3d609d84d91 (patch)
tree75fd97c8a7f10ea2cd73cdf46c98d32cc23e7dac
parentdc81ea6454c3a5465b611c9a698229598d2ec401 (diff)
downloadopenttd-92e0bf68e3b4825e4093d5d67a2da3d609d84d91.tar.xz
(svn r11464) -Fix: some issue that made OpenTTD on MorphOS seriously unplayable.
-rw-r--r--src/fileio.cpp13
-rw-r--r--src/fios.cpp23
2 files changed, 27 insertions, 9 deletions
diff --git a/src/fileio.cpp b/src/fileio.cpp
index f33c8e0c1..f92a7f6ab 100644
--- a/src/fileio.cpp
+++ b/src/fileio.cpp
@@ -363,6 +363,16 @@ void FioCreateDirectory(const char *name)
CreateDirectory(OTTD2FS(name), NULL);
#elif defined(OS2) && !defined(__INNOTEK_LIBC__)
mkdir(OTTD2FS(name));
+#elif defined(__MORPHOS__) || defined(__AMIGAOS__)
+ char buf[MAX_PATH];
+ ttd_strlcpy(buf, name, MAX_PATH);
+
+ size_t len = strlen(name) - 1;
+ if (buf[len] == '/') {
+ buf[len] = '\0'; // Kill pathsep, so mkdir() will not fail
+ }
+
+ mkdir(OTTD2FS(buf), 0755);
#else
mkdir(OTTD2FS(name), 0755);
#endif
@@ -720,7 +730,10 @@ void DeterminePaths(const char *exe)
char *autosave_dir = str_fmt("%s%s", _personal_dir, FioGetSubdirectory(AUTOSAVE_DIR));
/* Make the necessary folders */
+#if !defined(__MORPHOS__) && !defined(__AMIGA__) && defined(WITH_PERSONAL_DIR)
FioCreateDirectory(_personal_dir);
+#endif
+
FioCreateDirectory(save_dir);
FioCreateDirectory(autosave_dir);
diff --git a/src/fios.cpp b/src/fios.cpp
index 31c3d8390..2dc10002c 100644
--- a/src/fios.cpp
+++ b/src/fios.cpp
@@ -145,15 +145,7 @@ char *FiosBrowseTo(const FiosItem *item)
case FIOS_TYPE_BMP:
{
static char str_buffr[512];
-
-#if defined(__MORPHOS__) || defined(__AMIGAOS__)
- /* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
- if (FiosIsRoot(path)) {
- snprintf(str_buffr, lengthof(str_buffr), "%s:%s", path, item->name);
- } else // XXX - only next line!
-#endif
snprintf(str_buffr, lengthof(str_buffr), "%s%s", path, item->name);
-
return str_buffr;
}
}
@@ -170,8 +162,21 @@ void FiosMakeSavegameName(char *buf, const char *name, size_t size)
/* Don't append the extension if it is already there */
period = strrchr(name, '.');
if (period != NULL && strcasecmp(period, extension) == 0) extension = "";
-
+#if defined(__MORPHOS__) || defined(__AMIGAOS__)
+ if (_fios_path != NULL) {
+ unsigned char sepchar = _fios_path[(strlen(_fios_path) - 1)];
+
+ if (sepchar != ':' && sepchar != '/') {
+ snprintf(buf, size, "%s" PATHSEP "%s%s", _fios_path, name, extension);
+ } else {
+ snprintf(buf, size, "%s%s%s", _fios_path, name, extension);
+ }
+ } else {
+ snprintf(buf, size, "%s%s", name, extension);
+ }
+#else
snprintf(buf, size, "%s" PATHSEP "%s%s", _fios_path, name, extension);
+#endif
}
#if defined(WIN32)