Skip to content

Commit

Permalink
fix: autosave is not loading
Browse files Browse the repository at this point in the history
  • Loading branch information
curioustorvald committed Dec 14, 2023
1 parent d0eb542 commit 6025d8b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/net/torvald/terrarum/SavegameCollection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import kotlin.math.roundToInt
/**
* Created by minjaesong on 2023-06-24.
*/
class SavegameCollection(files0: List<DiskSkimmer>, prefiltered: Boolean) {
class SavegameCollection(files0: List<DiskSkimmer>) {

/** Sorted in reverse by the last modified time of the files, index zero being the most recent */
val files = if (prefiltered) files0 else files0.sortedBy { it.diskFile.name }.sortedByDescending {
val files = files0.sortedBy { it.diskFile.name }.sortedByDescending {
it.getLastModifiedTime().shl(2) or
it.diskFile.extension.matches(Regex("^[abc]${'$'}")).toLong(1) or
it.diskFile.extension.isBlank().toLong(0)
Expand All @@ -54,14 +54,14 @@ class SavegameCollection(files0: List<DiskSkimmer>, prefiltered: Boolean) {

companion object {
fun collectFromBaseFilename(skimmers: List<DiskSkimmer>, name: String): SavegameCollection {
return SavegameCollection(skimmers, true)
return SavegameCollection(skimmers)
}


fun collectFromBaseFilename(dir: File, name: String): SavegameCollection {
val files = dir.listFiles().filter { it.name.startsWith(name) }
.mapNotNull { try { DiskSkimmer(it, true) } catch (e: Throwable) { null } }
return SavegameCollection(files, false)
return SavegameCollection(files)
}
}

Expand Down

0 comments on commit 6025d8b

Please sign in to comment.