mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
new RNG for everything; Joise update
This commit is contained in:
@@ -22,6 +22,11 @@ object ReadWorldInfo {
|
||||
throw IllegalArgumentException("File not a Save Meta")
|
||||
}
|
||||
|
||||
|
||||
val descVersion = fis.read(1) // 0-127
|
||||
val numberOfHashes = fis.read() // 0-127
|
||||
|
||||
|
||||
var byteRead = fis.read()
|
||||
while (byteRead != 0) {
|
||||
if (byteRead == -1)
|
||||
@@ -38,14 +43,14 @@ object ReadWorldInfo {
|
||||
fis.read(8).toLittleLong(), // rng s1
|
||||
fis.read(8).toLittleLong(), // weather s0
|
||||
fis.read(8).toLittleLong(), // weather s1
|
||||
fis.read(32),
|
||||
fis.read(32),
|
||||
fis.read(32),
|
||||
fis.read(4).toLittleInt(), // player id
|
||||
fis.read(8).toLittleLong(), // world TIME_T
|
||||
fis.read(6).toLittleLong(), // creation time
|
||||
fis.read(6).toLittleLong(), // last play time
|
||||
fis.read(4).toLittleInt() // total time wasted
|
||||
fis.read(4).toLittleInt(), // total time wasted
|
||||
fis.read(32), // sha256sum worldinfo1
|
||||
fis.read(32), // sha256sum worldinfo2
|
||||
fis.read(32) // sha256sum worldinfo3
|
||||
)
|
||||
}
|
||||
|
||||
@@ -57,13 +62,13 @@ object ReadWorldInfo {
|
||||
val rngS1: Long,
|
||||
val weatherS0: Long,
|
||||
val weatherS1: Long,
|
||||
val worldinfo1Hash: ByteArray,
|
||||
val worldInfo2Hash: ByteArray,
|
||||
val worldInfo3Hash: ByteArray,
|
||||
val playerID: Int,
|
||||
val timeNow: Long,
|
||||
val creationTime: Long,
|
||||
val lastPlayTime: Long,
|
||||
val totalPlayTime: Int
|
||||
val totalPlayTime: Int,
|
||||
val worldinfo1Hash: ByteArray,
|
||||
val worldInfo2Hash: ByteArray,
|
||||
val worldInfo3Hash: ByteArray
|
||||
)
|
||||
}
|
||||
@@ -18,6 +18,9 @@ object WriteWorldInfo {
|
||||
val META_MAGIC = "TESV".toByteArray(Charsets.UTF_8)
|
||||
val NULL = 0.toByte()
|
||||
|
||||
val VERSION = 1
|
||||
val HASHED_FILES_COUNT = 3
|
||||
|
||||
/**
|
||||
* TODO currently it'll dump the temporary file (tmp_worldinfo1) onto the disk and will return the temp file.
|
||||
*
|
||||
@@ -38,10 +41,11 @@ object WriteWorldInfo {
|
||||
|
||||
val outFiles = ArrayList<File>()
|
||||
outFiles.add(metaFile)
|
||||
|
||||
val worldInfoHash = ArrayList<ByteArray>() // hash of worldinfo1-3
|
||||
// try to write worldinfo1-3
|
||||
|
||||
for (filenum in 1..3) {
|
||||
for (filenum in 1..HASHED_FILES_COUNT) {
|
||||
val outFile = File(path + filenum.toString())
|
||||
if (outFile.exists()) outFile.delete()
|
||||
outFile.createNewFile()
|
||||
@@ -65,11 +69,13 @@ object WriteWorldInfo {
|
||||
}
|
||||
|
||||
|
||||
// compose save meta
|
||||
// compose save meta (actual writing part)
|
||||
val metaOut = BufferedOutputStream(FileOutputStream(metaFile), 256)
|
||||
|
||||
|
||||
metaOut.write(META_MAGIC)
|
||||
metaOut.write(VERSION)
|
||||
metaOut.write(HASHED_FILES_COUNT)
|
||||
|
||||
// world name
|
||||
val worldNameBytes = world.worldName.toByteArray(Charsets.UTF_8)
|
||||
@@ -80,28 +86,23 @@ object WriteWorldInfo {
|
||||
metaOut.write(world.generatorSeed.toLittle())
|
||||
|
||||
// randomiser seed
|
||||
metaOut.write(RoguelikeRandomiser.RNG.s0.toLittle())
|
||||
metaOut.write(RoguelikeRandomiser.RNG.s1.toLittle())
|
||||
metaOut.write(RoguelikeRandomiser.RNG.state0.toLittle())
|
||||
metaOut.write(RoguelikeRandomiser.RNG.state1.toLittle())
|
||||
|
||||
// weather seed
|
||||
metaOut.write(WeatherMixer.RNG.s0.toLittle())
|
||||
metaOut.write(WeatherMixer.RNG.s1.toLittle())
|
||||
|
||||
// SHA256SUM of worldinfo1-3
|
||||
worldInfoHash.forEach {
|
||||
metaOut.write(it)
|
||||
}
|
||||
metaOut.write(WeatherMixer.RNG.state0.toLittle())
|
||||
metaOut.write(WeatherMixer.RNG.state1.toLittle())
|
||||
|
||||
// reference ID of the player
|
||||
metaOut.write(Terrarum.PLAYER_REF_ID.toLittle())
|
||||
|
||||
// time_t
|
||||
// ingame time_t
|
||||
metaOut.write((world as GameWorldExtension).time.TIME_T.toLittle())
|
||||
|
||||
// creation time (real world time)
|
||||
metaOut.write(world.creationTime.toLittle48())
|
||||
|
||||
// time at save
|
||||
// time at save (real world time)
|
||||
val timeNow = System.currentTimeMillis() / 1000L
|
||||
metaOut.write(timeNow.toLittle48())
|
||||
|
||||
@@ -111,8 +112,14 @@ object WriteWorldInfo {
|
||||
world.lastPlayTime = timeNow
|
||||
world.totalPlayTime += timeToAdd
|
||||
|
||||
// SHA256SUM of worldinfo1-3
|
||||
worldInfoHash.forEach {
|
||||
metaOut.write(it)
|
||||
}
|
||||
|
||||
|
||||
// more data goes here //
|
||||
|
||||
|
||||
metaOut.flush()
|
||||
metaOut.close()
|
||||
|
||||
Reference in New Issue
Block a user