1600 if (_fios_save_path == NULL) { |
1597 if (_fios_save_path == NULL) { |
1601 _fios_save_path = malloc(MAX_PATH); |
1598 _fios_save_path = malloc(MAX_PATH); |
1602 strcpy(_fios_save_path, _path.save_dir); |
1599 strcpy(_fios_save_path, _path.save_dir); |
1603 } |
1600 } |
1604 |
1601 |
1605 if (_game_mode == GM_EDITOR) |
1602 _fios_path = _fios_save_path; |
1606 _fios_path = _fios_scn_path; |
|
1607 else |
|
1608 _fios_path = _fios_save_path; |
|
1609 |
1603 |
1610 // Parent directory, only if not of the type C:\. |
1604 // Parent directory, only if not of the type C:\. |
1611 if (_fios_path[3] != '\0') { |
1605 if (_fios_path[3] != '\0') { |
1612 fios = FiosAlloc(); |
1606 fios = FiosAlloc(); |
1613 fios->type = FIOS_TYPE_PARENT; |
1607 fios->type = FIOS_TYPE_PARENT; |
1625 strcmp(fd.cFileName, "..") != 0) { |
1619 strcmp(fd.cFileName, "..") != 0) { |
1626 fios = FiosAlloc(); |
1620 fios = FiosAlloc(); |
1627 fios->type = FIOS_TYPE_DIR; |
1621 fios->type = FIOS_TYPE_DIR; |
1628 fios->mtime = 0; |
1622 fios->mtime = 0; |
1629 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
1623 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
1630 snprintf(fios->title, lengthof(fios->title), |
1624 snprintf(fios->title, lengthof(fios->title), "%s\\ (Directory)", fd.cFileName); |
1631 "%s\\ (Directory)", fd.cFileName); |
|
1632 } |
1625 } |
1633 } while (FindNextFile(h, &fd)); |
1626 } while (FindNextFile(h, &fd)); |
1634 FindClose(h); |
1627 FindClose(h); |
1635 } |
1628 } |
1636 |
1629 |
1653 t = strrchr(fd.cFileName, '.'); |
1646 t = strrchr(fd.cFileName, '.'); |
1654 if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD |
1647 if (t != NULL && strcasecmp(t, ".sav") == 0) { // OpenTTD |
1655 fios = FiosAlloc(); |
1648 fios = FiosAlloc(); |
1656 fios->type = FIOS_TYPE_FILE; |
1649 fios->type = FIOS_TYPE_FILE; |
1657 fios->mtime = *(uint64*)&fd.ftLastWriteTime; |
1650 fios->mtime = *(uint64*)&fd.ftLastWriteTime; |
1658 fios->title[0] = '\0'; |
|
1659 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
1651 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
|
1652 |
|
1653 *t = '\0'; // strip extension |
|
1654 ttd_strlcpy(fios->title, fd.cFileName, lengthof(fios->title)); |
|
1655 |
1660 } else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) { |
1656 } else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) { |
1661 if (t != NULL && ( |
1657 if (t != NULL && ( |
1662 strcasecmp(t, ".ss1") == 0 || |
1658 strcasecmp(t, ".ss1") == 0 || |
1663 strcasecmp(t, ".sv1") == 0 || |
1659 strcasecmp(t, ".sv1") == 0 || |
1664 strcasecmp(t, ".sv2") == 0 |
1660 strcasecmp(t, ".sv2") == 0 |
1731 strcmp(fd.cFileName, "..") != 0) { |
1726 strcmp(fd.cFileName, "..") != 0) { |
1732 fios = FiosAlloc(); |
1727 fios = FiosAlloc(); |
1733 fios->type = FIOS_TYPE_DIR; |
1728 fios->type = FIOS_TYPE_DIR; |
1734 fios->mtime = 0; |
1729 fios->mtime = 0; |
1735 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
1730 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
1736 snprintf(fios->title, lengthof(fios->title), |
1731 snprintf(fios->title, lengthof(fios->title), "%s\\ (Directory)", fd.cFileName); |
1737 "%s\\ (Directory)", fd.cFileName); |
|
1738 } |
1732 } |
1739 } while (FindNextFile(h, &fd)); |
1733 } while (FindNextFile(h, &fd)); |
1740 FindClose(h); |
1734 FindClose(h); |
1741 } |
1735 } |
1742 |
1736 |
1758 t = strrchr(fd.cFileName, '.'); |
1752 t = strrchr(fd.cFileName, '.'); |
1759 if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD |
1753 if (t != NULL && strcasecmp(t, ".scn") == 0) { // OpenTTD |
1760 fios = FiosAlloc(); |
1754 fios = FiosAlloc(); |
1761 fios->type = FIOS_TYPE_SCENARIO; |
1755 fios->type = FIOS_TYPE_SCENARIO; |
1762 fios->mtime = *(uint64*)&fd.ftLastWriteTime; |
1756 fios->mtime = *(uint64*)&fd.ftLastWriteTime; |
1763 fios->title[0] = '\0'; |
|
1764 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
1757 ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); |
|
1758 |
|
1759 *t = '\0'; // strip extension |
|
1760 ttd_strlcpy(fios->title, fd.cFileName, lengthof(fios->title)); |
|
1761 |
1765 } else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO || |
1762 } else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO || |
1766 mode == SLD_NEW_GAME) { |
1763 mode == SLD_NEW_GAME) { |
1767 if (t != NULL && ( |
1764 if (t != NULL && ( |
1768 strcasecmp(t, ".sv0") == 0 || |
1765 strcasecmp(t, ".sv0") == 0 || |
1769 strcasecmp(t, ".ss0") == 0 |
1766 strcasecmp(t, ".ss0") == 0 |