mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-17 05:54:05 +09:00
vt: new filesystem using tevd
This commit is contained in:
@@ -121,29 +121,17 @@ class ActorInventory() {
|
||||
return capacityMode
|
||||
}
|
||||
|
||||
fun getTotalWeight(): Double {
|
||||
var weight = 0.0
|
||||
itemList.forEach { weight += it.item.mass * it.amount }
|
||||
|
||||
return weight
|
||||
}
|
||||
fun getTotalWeight(): Double = itemList.map { it.item.mass * it.amount }.sum()
|
||||
|
||||
/**
|
||||
* Real amount
|
||||
*/
|
||||
fun getTotalCount(): Int {
|
||||
var count = 0
|
||||
itemList.forEach { count += it.amount }
|
||||
|
||||
return count
|
||||
}
|
||||
fun getTotalCount(): Int = itemList.map { it.amount }.sum()
|
||||
|
||||
/**
|
||||
* Unique amount, multiple items are calculated as one
|
||||
*/
|
||||
fun getTotalUniqueCount(): Int {
|
||||
return itemList.size
|
||||
}
|
||||
fun getTotalUniqueCount(): Int = itemList.size
|
||||
|
||||
/**
|
||||
* Check whether the itemList contains too many items
|
||||
|
||||
@@ -111,19 +111,15 @@ object DecodeTapestry {
|
||||
val FORMAT_64 = 2
|
||||
|
||||
operator fun invoke(fileObj: File): TapestryObject {
|
||||
fun magicMismatch(magic: ByteArray): Boolean {
|
||||
MAGIC.forEachIndexed { i, byte ->
|
||||
if (byte != magic[i])
|
||||
return true
|
||||
}
|
||||
return false
|
||||
fun magicMismatch(magic: ByteArray, array: ByteArray): Boolean {
|
||||
return !Arrays.equals(array.sliceArray(0..magic.lastIndex), magic)
|
||||
}
|
||||
|
||||
val file = fileObj.readBytes()
|
||||
|
||||
val magic = file.copyOfRange(0, 4)
|
||||
|
||||
if (magicMismatch(magic))
|
||||
if (magicMismatch(MAGIC, magic))
|
||||
throw RuntimeException("Invalid file -- type mismatch: expected header " +
|
||||
"${MAGIC[0]} ${MAGIC[1]} ${MAGIC[2]} ${MAGIC[3]}; got " +
|
||||
"${magic[0]} ${magic[1]} ${magic[2]} ${magic[3]}")
|
||||
@@ -156,8 +152,8 @@ object DecodeTapestry {
|
||||
|
||||
|
||||
|
||||
val artName = kotlin.text.String(artNameBytes.toByteArray(), charset = Charset.forName("UTF-8"))
|
||||
val authorName = kotlin.text.String(authorNameBytes.toByteArray(), charset = Charset.forName("UTF-8"))
|
||||
val artName = String(artNameBytes.toByteArray(), charset = Charset.forName("UTF-8"))
|
||||
val authorName = String(authorNameBytes.toByteArray(), charset = Charset.forName("UTF-8"))
|
||||
|
||||
val imageDataSize = file.size - readCounter
|
||||
val height = imageDataSize / width
|
||||
|
||||
Reference in New Issue
Block a user