Changeset - r7911:0dfae2052a84
[Not reviewed]
master
0 2 0
rubidium - 17 years ago 2007-11-18 18:28:32
rubidium@openttd.org
(svn r11464) -Fix: some issue that made OpenTTD on MorphOS seriously unplayable.
2 files changed with 26 insertions and 8 deletions:
0 comments (0 inline, 0 general)
src/fileio.cpp
Show inline comments
 
@@ -360,12 +360,22 @@ FILE *FioFOpenFile(const char *filename,
 
void FioCreateDirectory(const char *name)
 
{
 
#if defined(WIN32) || defined(WINCE)
 
	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
 
}
 

	
 
/**
 
@@ -717,13 +727,16 @@ void DeterminePaths(const char *exe)
 
	_log_file = str_fmt("%sopenttd.log",  _personal_dir);
 

	
 
	char *save_dir     = str_fmt("%s%s", _personal_dir, FioGetSubdirectory(SAVE_DIR));
 
	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);
 

	
 
	free(save_dir);
 
	free(autosave_dir);
 
}
src/fios.cpp
Show inline comments
 
@@ -142,21 +142,13 @@ char *FiosBrowseTo(const FiosItem *item)
 
	case FIOS_TYPE_SCENARIO:
 
	case FIOS_TYPE_OLD_SCENARIO:
 
	case FIOS_TYPE_PNG:
 
	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;
 
	}
 
	}
 

	
 
	return NULL;
 
}
 
@@ -167,14 +159,27 @@ void FiosMakeSavegameName(char *buf, con
 

	
 
	extension = (_game_mode == GM_EDITOR) ? ".scn" : ".sav";
 

	
 
	/* 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)
 
# define unlink _tunlink
 
#endif
 

	
0 comments (0 inline, 0 general)