mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
fix: autosave being god damn slow
This commit is contained in:
@@ -135,13 +135,9 @@ class QuickSingleplayerWorldSavingThread(
|
|||||||
actorsList.forEachIndexed { count, it ->
|
actorsList.forEachIndexed { count, it ->
|
||||||
printdbg(this, "Writing actors... ${count+1}/${actorsList.size} (${it.javaClass.canonicalName})")
|
printdbg(this, "Writing actors... ${count+1}/${actorsList.size} (${it.javaClass.canonicalName})")
|
||||||
|
|
||||||
printdbg(this, " Serialising")
|
|
||||||
val actorContent = EntryFile(WriteActor.encodeToByteArray64(it))
|
val actorContent = EntryFile(WriteActor.encodeToByteArray64(it))
|
||||||
printdbg(this, " Preparing disk entry")
|
|
||||||
val actor = DiskEntry(it.referenceID.toLong(), ROOT, creation_t, time_t, actorContent)
|
val actor = DiskEntry(it.referenceID.toLong(), ROOT, creation_t, time_t, actorContent)
|
||||||
printdbg(this, " DOM add entry (${actor.entryID})")
|
|
||||||
addFile(disk, actor)
|
addFile(disk, actor)
|
||||||
printdbg(this, " Skimmer append entry") // FIXME too slow!
|
|
||||||
skimmer.appendEntry(actor)
|
skimmer.appendEntry(actor)
|
||||||
|
|
||||||
WriteSavegame.saveProgress += actorProgressMultiplier
|
WriteSavegame.saveProgress += actorProgressMultiplier
|
||||||
|
|||||||
@@ -568,27 +568,18 @@ removefile:
|
|||||||
fun appendEntry(entry: DiskEntry) {
|
fun appendEntry(entry: DiskEntry) {
|
||||||
val fa = RandomAccessFile(diskFile, "rwd")
|
val fa = RandomAccessFile(diskFile, "rwd")
|
||||||
|
|
||||||
|
|
||||||
// val parentDir = requestFile(entry.parentEntryID)!!
|
|
||||||
val id = entry.entryID
|
val id = entry.entryID
|
||||||
// val parent = entry.parentEntryID
|
|
||||||
|
|
||||||
// add the entry to its parent directory if there was none
|
|
||||||
// val dirContent = (parentDir.contents as EntryDirectory)
|
|
||||||
// if (!dirContent.contains(id)) dirContent.add(id)
|
|
||||||
|
|
||||||
// invalidateEntry(parent)
|
|
||||||
// invalidateEntry(id)
|
|
||||||
|
|
||||||
val appendAt = fa.length()
|
val appendAt = fa.length()
|
||||||
fa.seek(appendAt)
|
fa.seek(appendAt)
|
||||||
|
|
||||||
// append new file
|
// append new file
|
||||||
entryToOffsetTable[id] = appendAt + 8
|
entryToOffsetTable[id] = appendAt + 8
|
||||||
entry.serialize().forEach { fa.writeByte(it.toInt()) }
|
entry.serialize().let { ba ->
|
||||||
// append modified directory
|
ba.forEachUsedBanks { count, bytes ->
|
||||||
// entryToOffsetTable[parent] = fa.filePointer + 8
|
fa.write(bytes, 0, count)
|
||||||
// parentDir.serialize().forEach { fa.writeByte(it.toInt()) }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fa.close()
|
fa.close()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user