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