more on savegame migrator and virtualdisk bugfix

This commit is contained in:
minjaesong
2024-10-08 20:22:40 +09:00
parent e0fcd00d82
commit b428273fa2
6 changed files with 20 additions and 7 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -159,7 +159,7 @@ open class IngameInstance(val batch: FlippingSpriteBatch, val isMultiplayer: Boo
val wallChangeQueue = ArrayList<BlockChangeQueueItem?>()
val wireChangeQueue = ArrayList<BlockChangeQueueItem?>() // if 'old' is set and 'new' is blank, it's a wire cutter
val modifiedChunks = Array(16) { TreeSet<Int>() }
val modifiedChunks = Array(16) { TreeSet<Long>() }
var loadedTime_t = App.getTIME_T()
protected set

View File

@@ -49,11 +49,17 @@ object SavegameConverter {
val DOM = ClusteredFormatDOM(newDisk)
val root = DOM.getRootFile()
var cnt = 0
// do filecopy
type254DOM.entries.filter { it.key != 0L }.forEach { entryID, diskEntry ->
val filename = Common.type254EntryIDtoType17Filename(entryID)
println("Converting file $filename; old cluster size: ${DOM.usedClusterCount}; old ROOT cluster num: ${DOM.getRootDir().entryID}; fileCount: $cnt")
if (diskEntry.contents !is EntryFile) throw IllegalStateException("Entry in the savegame is not a file (${diskEntry.contents.javaClass.simpleName})")
cnt += 1
val entry = diskEntry.contents as EntryFile
val oldBytes = entry.bytes.toByteArray()
@@ -72,4 +78,11 @@ object SavegameConverter {
DOM.dispose()
}
}
fun main() {
val infile = File("/home/torvald/.Terrarum/Worlds/2d3e3aa5-bf5b-45c8-acf6-66ef9f1c2217")
val outfile = File("/home/torvald/.Terrarum/Worlds/2d3e3aa5-bf5b-45c8-acf6-66ef9f1c2217.terrarumworld")
SavegameConverter.type254toType11(infile, outfile)
}

View File

@@ -550,7 +550,7 @@ abstract class Gen(val world: GameWorld, val isFinal: Boolean, val seed: Long, v
protected abstract fun getGenerator(seed: Long, params: Any?): List<Joise>
protected abstract fun draw(xStart: Int, yStart: Int, noises: List<Joise>, soff: Double)
private fun getChunksRange(): List<Int> {
private fun getChunksRange(): List<Long> {
val (yStart, yEnd) = Worldgen.getChunkGenStrip(world)
return (0 until world.width / CHUNK_W step 2).flatMap { cx -> // skip every other column because we can :smiling_face_with_horns:
(LandUtil.chunkXYtoChunkNum(world, cx, yStart)..LandUtil.chunkXYtoChunkNum(world, cx, yEnd)).toList()

View File

@@ -761,7 +761,7 @@ object Common {
fun type254EntryIDtoType17Filename(entryID: Long): String {
return entryID.toString(16).uppercase().padStart(16,'0')
return entryID.toULong().toString(16).uppercase().padStart(16,'0')
}
}