os2.c
changeset 2338 8b953706648a
parent 2334 b4e5c353bf38
child 2526 cae4842086a9
equal deleted inserted replaced
2337:a4587769d43a 2338:8b953706648a
   137 
   137 
   138 			append_path(filename, _fios_path, dirent->d_name);
   138 			append_path(filename, _fios_path, dirent->d_name);
   139 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
   139 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
   140 
   140 
   141 			t = strrchr(dirent->d_name, '.');
   141 			t = strrchr(dirent->d_name, '.');
   142 			if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD
   142 			if (t == NULL) continue;
       
   143 
       
   144 			if (strcasecmp(t, ".sav") == 0) { // OpenTTD
   143 				fios = FiosAlloc();
   145 				fios = FiosAlloc();
   144 				fios->type = FIOS_TYPE_FILE;
   146 				fios->type = FIOS_TYPE_FILE;
   145 				fios->mtime = sb.st_mtime;
   147 				fios->mtime = sb.st_mtime;
   146 				ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
   148 				ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
   147 
   149 
   148 				*t = '\0'; // strip extension
   150 				*t = '\0'; // strip extension
   149 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
   151 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
   150 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
   152 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
   151 				if (t != NULL && (
   153 				if (strcasecmp(t, ".ss1") == 0 ||
   152 							strcasecmp(t, ".ss1") == 0 ||
   154 						strcasecmp(t, ".sv1") == 0 ||
   153 							strcasecmp(t, ".sv1") == 0 ||
   155 						strcasecmp(t, ".sv2") == 0) { // TTDLX(Patch)
   154 							strcasecmp(t, ".sv2") == 0
       
   155 						)) { // TTDLX(Patch)
       
   156 					fios = FiosAlloc();
   156 					fios = FiosAlloc();
   157 					fios->type = FIOS_TYPE_OLDFILE;
   157 					fios->type = FIOS_TYPE_OLDFILE;
   158 					fios->mtime = sb.st_mtime;
   158 					fios->mtime = sb.st_mtime;
   159 					ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
   159 					ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
   160 					GetOldSaveGameName(fios->title, filename);
   160 					GetOldSaveGameName(fios->title, filename);
   263 
   263 
   264 			append_path(filename, _fios_path, dirent->d_name);
   264 			append_path(filename, _fios_path, dirent->d_name);
   265 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
   265 			if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
   266 
   266 
   267 			t = strrchr(dirent->d_name, '.');
   267 			t = strrchr(dirent->d_name, '.');
   268 			if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD
   268 			if (t == NULL) continue;
       
   269 
       
   270 			if (strcasecmp(t, ".scn") == 0) { // OpenTTD
   269 				fios = FiosAlloc();
   271 				fios = FiosAlloc();
   270 				fios->type = FIOS_TYPE_SCENARIO;
   272 				fios->type = FIOS_TYPE_SCENARIO;
   271 				fios->mtime = sb.st_mtime;
   273 				fios->mtime = sb.st_mtime;
   272 				ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
   274 				ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
   273 
   275 
   274 				*t = '\0'; // strip extension
   276 				*t = '\0'; // strip extension
   275 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
   277 				ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
   276 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
   278 			} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
   277 					mode == SLD_NEW_GAME) {
   279 					mode == SLD_NEW_GAME) {
   278 				if (t != NULL && (
   280 				if (strcasecmp(t, ".sv0") == 0 ||
   279 							strcasecmp(t, ".sv0") == 0 ||
   281 						strcasecmp(t, ".ss0") == 0) { // TTDLX(Patch)
   280 							strcasecmp(t, ".ss0") == 0
       
   281 						)) { // TTDLX(Patch)
       
   282 					fios = FiosAlloc();
   282 					fios = FiosAlloc();
   283 					fios->type = FIOS_TYPE_OLD_SCENARIO;
   283 					fios->type = FIOS_TYPE_OLD_SCENARIO;
   284 					fios->mtime = sb.st_mtime;
   284 					fios->mtime = sb.st_mtime;
   285 					GetOldScenarioGameName(fios->title, filename);
   285 					GetOldScenarioGameName(fios->title, filename);
   286 					ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
   286 					ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));