(svn r5857) - Backport from trunk (r5800): 0.4
authorDarkvater
Sat, 12 Aug 2006 12:11:54 +0000
branch0.4
changeset 10072 e9bd7b46e732
parent 10071 43992016c7c8
child 10073 a1d404ac9820
(svn r5857) - Backport from trunk (r5800):
When directories were changed in 'Play Scenario', pressing 'New Game' showed
scenarios from that directory, not the default one.
os2.c
unix.c
win32.c
--- a/os2.c	Sat Aug 12 12:01:20 2006 +0000
+++ b/os2.c	Sat Aug 12 12:11:54 2006 +0000
@@ -210,9 +210,10 @@
 	int sort_start;
 	char filename[MAX_PATH];
 
-	if (_fios_scn_path == NULL) {
-		_fios_scn_path = malloc(MAX_PATH);
-		strcpy(_fios_scn_path, _path.scenario_dir);
+	/* Copy the default path on first run or on 'New Game' */
+	if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) {
+		if (_fios_scn_path == NULL) _fios_scn_path = malloc(MAX_PATH);
+		ttd_strlcpy(_fios_scn_path, _path.scenario_dir, MAX_PATH);
 	}
 
 	_fios_path = _fios_scn_path;
--- a/unix.c	Sat Aug 12 12:01:20 2006 +0000
+++ b/unix.c	Sat Aug 12 12:11:54 2006 +0000
@@ -208,9 +208,10 @@
 	int sort_start;
 	char filename[MAX_PATH];
 
-	if (_fios_scn_path == NULL) {
-		_fios_scn_path = malloc(MAX_PATH);
-		strcpy(_fios_scn_path, _path.scenario_dir);
+	/* Copy the default path on first run or on 'New Game' */
+	if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) {
+		if (_fios_scn_path == NULL) _fios_scn_path = malloc(MAX_PATH);
+		ttd_strlcpy(_fios_scn_path, _path.scenario_dir, MAX_PATH);
 	}
 
 	_fios_path = _fios_scn_path;
--- a/win32.c	Sat Aug 12 12:01:20 2006 +0000
+++ b/win32.c	Sat Aug 12 12:11:54 2006 +0000
@@ -779,9 +779,10 @@
 	HANDLE h;
 	int sort_start;
 
-	if (_fios_scn_path == NULL) {
-		_fios_scn_path = malloc(MAX_PATH);
-		strcpy(_fios_scn_path, _path.scenario_dir);
+	/* Copy the default path on first run or on 'New Game' */
+	if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) {
+		if (_fios_scn_path == NULL) _fios_scn_path = malloc(MAX_PATH);
+		ttd_strlcpy(_fios_scn_path, _path.scenario_dir, MAX_PATH);
 	}
 
 	_fios_path = _fios_scn_path;