mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
gamemode on savegame format
This commit is contained in:
@@ -392,7 +392,7 @@ removefile:
|
|||||||
|
|
||||||
fun setSaveSnapshotVersion(snapshot: Snapshot?) {
|
fun setSaveSnapshotVersion(snapshot: Snapshot?) {
|
||||||
val fa = RandomAccessFile(diskFile, "rwd")
|
val fa = RandomAccessFile(diskFile, "rwd")
|
||||||
fa.seek(51L)
|
fa.seek(52L)
|
||||||
if (snapshot == null)
|
if (snapshot == null)
|
||||||
fa.write(byteArrayOf(0, 0))
|
fa.write(byteArrayOf(0, 0))
|
||||||
else
|
else
|
||||||
@@ -400,6 +400,13 @@ removefile:
|
|||||||
fa.close()
|
fa.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setGameMode(bits: Int) {
|
||||||
|
val fa = RandomAccessFile(diskFile, "rwd")
|
||||||
|
fa.seek(54L)
|
||||||
|
fa.writeByte(bits)
|
||||||
|
fa.close()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Save type (0b 0000 00ab)
|
* @return Save type (0b 0000 00ab)
|
||||||
* b: unset - full save; set - quicksave (only applicable to worlds -- quicksave just means the disk is in dirty state)
|
* b: unset - full save; set - quicksave (only applicable to worlds -- quicksave just means the disk is in dirty state)
|
||||||
@@ -440,6 +447,12 @@ removefile:
|
|||||||
else Snapshot(byteArrayOf(b1, b2))
|
else Snapshot(byteArrayOf(b1, b2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getGameMode(): Int {
|
||||||
|
val fa = RandomAccessFile(diskFile, "rwd")
|
||||||
|
fa.seek(54L)
|
||||||
|
return fa.read().also { fa.close() }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
override fun getDiskName(charset: Charset): String {
|
override fun getDiskName(charset: Charset): String {
|
||||||
|
|||||||
@@ -87,7 +87,12 @@ Version 254 is a customised version of TEVD tailored to be used as a savegame fo
|
|||||||
w: ISO Week Number (1-53)
|
w: ISO Week Number (1-53)
|
||||||
Aaa: Alphabet (a->000, b->001, ... e->100, f->101, ..., h->111)
|
Aaa: Alphabet (a->000, b->001, ... e->100, f->101, ..., h->111)
|
||||||
e.g. 23w40f is encoded as 1_0010111 101000_01
|
e.g. 23w40f is encoded as 1_0010111 101000_01
|
||||||
Int8[10] Extra info bytes reserved for future usage
|
Int8 Game Mode (0b ww tttttt)
|
||||||
|
t: 0 - Undecided
|
||||||
|
1 - Survival (0.4.0+)
|
||||||
|
w: 0 - Singleplayer
|
||||||
|
2 - Multiplayer
|
||||||
|
Int8[9] Extra info bytes reserved for future usage
|
||||||
|
|
||||||
-- END extraInfoBytes --
|
-- END extraInfoBytes --
|
||||||
UInt8[236] Rest of the long disk name (268 bytes total)
|
UInt8[236] Rest of the long disk name (268 bytes total)
|
||||||
@@ -183,6 +188,9 @@ class VirtualDisk(
|
|||||||
Snapshot(extraInfoBytes.sliceArray(4..5))
|
Snapshot(extraInfoBytes.sliceArray(4..5))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var gamemode: Int
|
||||||
|
set(value) { extraInfoBytes[6] = value.toByte() }
|
||||||
|
get() = extraInfoBytes[6].toUint()
|
||||||
|
|
||||||
override fun getDiskName(charset: Charset) = diskName.toCanonicalString(charset)
|
override fun getDiskName(charset: Charset) = diskName.toCanonicalString(charset)
|
||||||
val root: DiskEntry
|
val root: DiskEntry
|
||||||
|
|||||||
Reference in New Issue
Block a user