(svn r2864) Code simplification and diff reduction
authortron
Sat, 13 Aug 2005 21:35:31 +0000
changeset 2338 8b953706648a
parent 2337 a4587769d43a
child 2339 1c64119d5a3b
(svn r2864) Code simplification and diff reduction
os2.c
unix.c
win32.c
--- a/os2.c	Sat Aug 13 21:34:05 2005 +0000
+++ b/os2.c	Sat Aug 13 21:35:31 2005 +0000
@@ -139,7 +139,9 @@
 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
 
 			t = strrchr(dirent->d_name, '.');
-			if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD
+			if (t == NULL) continue;
+
+			if (strcasecmp(t, ".sav") == 0) { // OpenTTD
 				fios = FiosAlloc();
 				fios->type = FIOS_TYPE_FILE;
 				fios->mtime = sb.st_mtime;
@@ -148,11 +150,9 @@
 				*t = '\0'; // strip extension
 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
-				if (t != NULL && (
-							strcasecmp(t, ".ss1") == 0 ||
-							strcasecmp(t, ".sv1") == 0 ||
-							strcasecmp(t, ".sv2") == 0
-						)) { // TTDLX(Patch)
+				if (strcasecmp(t, ".ss1") == 0 ||
+						strcasecmp(t, ".sv1") == 0 ||
+						strcasecmp(t, ".sv2") == 0) { // TTDLX(Patch)
 					fios = FiosAlloc();
 					fios->type = FIOS_TYPE_OLDFILE;
 					fios->mtime = sb.st_mtime;
@@ -265,7 +265,9 @@
 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
 
 			t = strrchr(dirent->d_name, '.');
-			if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD
+			if (t == NULL) continue;
+
+			if (strcasecmp(t, ".scn") == 0) { // OpenTTD
 				fios = FiosAlloc();
 				fios->type = FIOS_TYPE_SCENARIO;
 				fios->mtime = sb.st_mtime;
@@ -275,10 +277,8 @@
 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
 					mode == SLD_NEW_GAME) {
-				if (t != NULL && (
-							strcasecmp(t, ".sv0") == 0 ||
-							strcasecmp(t, ".ss0") == 0
-						)) { // TTDLX(Patch)
+				if (strcasecmp(t, ".sv0") == 0 ||
+						strcasecmp(t, ".ss0") == 0) { // TTDLX(Patch)
 					fios = FiosAlloc();
 					fios->type = FIOS_TYPE_OLD_SCENARIO;
 					fios->mtime = sb.st_mtime;
--- a/unix.c	Sat Aug 13 21:34:05 2005 +0000
+++ b/unix.c	Sat Aug 13 21:35:31 2005 +0000
@@ -148,7 +148,9 @@
 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
 
 			t = strrchr(dirent->d_name, '.');
-			if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD
+			if (t == NULL) continue;
+
+			if (strcasecmp(t, ".sav") == 0) { // OpenTTD
 				fios = FiosAlloc();
 				fios->type = FIOS_TYPE_FILE;
 				fios->mtime = sb.st_mtime;
@@ -157,11 +159,9 @@
 				*t = '\0'; // strip extension
 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
-				if (t != NULL && (
-							strcasecmp(t, ".ss1") == 0 ||
-							strcasecmp(t, ".sv1") == 0 ||
-							strcasecmp(t, ".sv2") == 0
-						)) { // TTDLX(Patch)
+				if (strcasecmp(t, ".ss1") == 0 ||
+						strcasecmp(t, ".sv1") == 0 ||
+						strcasecmp(t, ".sv2") == 0) { // TTDLX(Patch)
 					fios = FiosAlloc();
 					fios->type = FIOS_TYPE_OLDFILE;
 					fios->mtime = sb.st_mtime;
@@ -247,7 +247,9 @@
 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
 
 			t = strrchr(dirent->d_name, '.');
-			if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD
+			if (t == NULL) continue;
+
+			if (strcasecmp(t, ".scn") == 0) { // OpenTTD
 				fios = FiosAlloc();
 				fios->type = FIOS_TYPE_SCENARIO;
 				fios->mtime = sb.st_mtime;
@@ -257,10 +259,8 @@
 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
 					mode == SLD_NEW_GAME) {
-				if (t != NULL && (
-							strcasecmp(t, ".sv0") == 0 ||
-							strcasecmp(t, ".ss0") == 0
-						)) { // TTDLX(Patch)
+				if (strcasecmp(t, ".sv0") == 0 ||
+						strcasecmp(t, ".ss0") == 0) { // TTDLX(Patch)
 					fios = FiosAlloc();
 					fios->type = FIOS_TYPE_OLD_SCENARIO;
 					fios->mtime = sb.st_mtime;
@@ -330,7 +330,7 @@
 StringID FiosGetDescText(const char **path, uint32 *tot)
 {
 	uint32 free = 0;
-	*path = _fios_path[0] != '\0' ? _fios_path : "/";
+	*path = _fios_path;
 
 #ifdef HAS_STATVFS
 	{
--- a/win32.c	Sat Aug 13 21:34:05 2005 +0000
+++ b/win32.c	Sat Aug 13 21:35:31 2005 +0000
@@ -672,7 +672,9 @@
 			if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue;
 
 			t = strrchr(fd.cFileName, '.');
-			if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD
+			if (t == NULL) continue;
+
+			if (strcasecmp(t, ".sav") == 0) { // OpenTTD
 				fios = FiosAlloc();
 				fios->type = FIOS_TYPE_FILE;
 				fios->mtime = *(uint64*)&fd.ftLastWriteTime;
@@ -681,11 +683,9 @@
 				*t = '\0'; // strip extension
 				ttd_strlcpy(fios->title, fd.cFileName, lengthof(fios->title));
 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
-				if (t != NULL && (
-							strcasecmp(t, ".ss1") == 0 ||
-							strcasecmp(t, ".sv1") == 0 ||
-							strcasecmp(t, ".sv2") == 0
-						)) { // TTDLX(Patch)
+				if (strcasecmp(t, ".ss1") == 0 ||
+						strcasecmp(t, ".sv1") == 0 ||
+						strcasecmp(t, ".sv2") == 0) { // TTDLX(Patch)
 					char buf[MAX_PATH];
 
 					fios = FiosAlloc();
@@ -785,7 +785,9 @@
 			if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) continue;
 
 			t = strrchr(fd.cFileName, '.');
-			if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD
+			if (t == NULL) continue;
+
+			if (strcasecmp(t, ".scn") == 0) { // OpenTTD
 				fios = FiosAlloc();
 				fios->type = FIOS_TYPE_SCENARIO;
 				fios->mtime = *(uint64*)&fd.ftLastWriteTime;
@@ -795,10 +797,8 @@
 				ttd_strlcpy(fios->title, fd.cFileName, lengthof(fios->title));
 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
 					mode == SLD_NEW_GAME) {
-				if (t != NULL && (
-							strcasecmp(t, ".sv0") == 0 ||
-							strcasecmp(t, ".ss0") == 0
-						)) { // TTDLX(Patch)
+				if (strcasecmp(t, ".sv0") == 0 ||
+						strcasecmp(t, ".ss0") == 0) { // TTDLX(Patch)
 					char buf[MAX_PATH];
 
 					fios = FiosAlloc();