not reading material csv issue fixed

This commit is contained in:
minjaesong
2019-03-12 00:47:06 +09:00
parent 7f53be48d1
commit 1ac735805d
12 changed files with 124 additions and 60 deletions

View File

@@ -1,35 +0,0 @@
"idst";"tens";"impf";"dsty";"fmod";"endurance";"tcond";"comments"
"ROCK"; "15"; "210";"3000"; "1"; "0.42"; "1.0";
"CUPR"; "210"; "770";"8960"; "2"; "1.00";"401.0";"copper"
"EGLS"; "33";"1000";"2325"; "4"; "0.82"; "1.0";"elven glass/moldavite"
"IRON"; "350";"1085";"7874"; "5"; "1.42"; "1.0";
"ARGN"; "170"; "595";"10490"; "9"; "0.91"; "1.0";"argentum/silver"
"STAL"; "531";"2520";"7874"; "14"; "1.73"; "1.0";"steel"
"EAUR"; "768"; "0";"8192"; "21"; "1.36"; "1.0";"elven aurichalcum"
"TIAL"; "900"; "0";"4420"; "33"; "2.16"; "1.0";"titanium alloy (Ti6Al4V)"
"ADMT";"2000";"4090";"2700"; "71"; "3.42"; "1.0";"adamant"
"OOZE"; "20"; "0";"1000"; "1"; "N/A"; "0.5";"genetic ooze; data is about human skin"
"BONE"; "130"; "0";"2000"; "1"; "0.23"; "0.55";"data was bovine bone"
# idst: ID_STRING, ALL CAPS
# tens: tensile strength (= ultimate stringth)
# not all 'impact' is not tensile stress, but I'm using it anyway because it's easiest to get the value from.
# that, or DF's tensile fracture divided by 1000 (I think Toady and I are both using values posted on Wikipedia, e.g. Silver)
# impf: Dwarf Fortress impact fracture divided by 1000 (likely not being used)
# dsty: density (grams per litre)
# fmod: forcemod -- related to attack points
# Attack points = `4 * forcemod.sqrt()` for each strike
# endurance: multiplier, using copper as reference; determines durability of tools/weapons/armours/etc.
the base value for endurance differes to tool to tool. When integer is used, resulting value must be ROUNDED.
# tcond: thermal conductivity
# Comments: do nothing; do not parse
## These values are being used by the phys simulator (blocks) and for attack power calculation (items)
1 idst tens impf dsty fmod endurance tcond comments
2 ROCK 15 210 3000 1 0.42 1.0
3 CUPR 210 770 8960 2 1.00 401.0 copper
4 EGLS 33 1000 2325 4 0.82 1.0 elven glass/moldavite
5 IRON 350 1085 7874 5 1.42 1.0
6 ARGN 170 595 10490 9 0.91 1.0 argentum/silver
7 STAL 531 2520 7874 14 1.73 1.0 steel
8 EAUR 768 0 8192 21 1.36 1.0 elven aurichalcum
9 TIAL 900 0 4420 33 2.16 1.0 titanium alloy (Ti6Al4V)
10 ADMT 2000 4090 2700 71 3.42 1.0 adamant
11 OOZE 20 0 1000 1 N/A 0.5 genetic ooze; data is about human skin
12 BONE 130 0 2000 1 0.23 0.55 data was bovine bone
13 # idst: ID_STRING, ALL CAPS
14 # tens: tensile strength (= ultimate stringth)
15 # not all 'impact' is not tensile stress, but I'm using it anyway because it's easiest to get the value from.
16 # that, or DF's tensile fracture divided by 1000 (I think Toady and I are both using values posted on Wikipedia, e.g. Silver)
17 # impf: Dwarf Fortress impact fracture divided by 1000 (likely not being used)
18 # dsty: density (grams per litre)
19 # fmod: forcemod -- related to attack points
20 # Attack points = `4 * forcemod.sqrt()` for each strike
21 # endurance: multiplier, using copper as reference determines durability of tools/weapons/armours/etc.
22 the base value for endurance differes to tool to tool. When integer is used, resulting value must be ROUNDED.
23 # tcond: thermal conductivity
24 # Comments: do nothing do not parse
25 ## These values are being used by the phys simulator (blocks) and for attack power calculation (items)

View File

@@ -0,0 +1,35 @@
"idst";"tens";"impf";"dsty";"fmod";"endurance";"tcond";"comments"
"ROCK"; "15"; "210";"3000"; "1"; "0.42"; "1.0";"data is that of marble"
"CUPR"; "210"; "770";"8960"; "2"; "1.00";"401.0";"copper"
"EGLS"; "33";"1000";"2325"; "4"; "0.82"; "1.0";"elven glass/moldavite"
"IRON"; "350";"1085";"7874"; "5"; "1.42"; "1.0";"not wrought iron; just natural iron"
"ARGN"; "170"; "595";"10490"; "9"; "0.91"; "1.0";"argentum/silver"
"STAL"; "531";"2520";"7874"; "14"; "1.73"; "1.0";"steel"
"EAUR"; "768"; "0";"8192"; "21"; "1.36"; "1.0";"elven aurichalcum"
"TIAL"; "900"; "0";"4420"; "33"; "2.16"; "1.0";"titanium alloy (Ti6Al4V)"
"ADMT";"2000";"4090";"2700"; "71"; "3.42"; "1.0";"adamant"
"OOZE"; "20"; "0";"1000"; "1"; "N/A"; "0.5";"genetic ooze; data is about human skin"
"BONE"; "130"; "0";"2000"; "1"; "0.23"; "0.55";"data is that of bovine bone"
# idst: ID_STRING, ALL CAPS
#
# tens: tensile strength (= ultimate stringth)
# not all 'impact' is not tensile stress, but I'm using it anyway because it's easiest to get the value from.
# that, or DF's tensile fracture divided by 1000 (I think Toady and I are both using values posted on Wikipedia, e.g. Silver)
#
# impf: Dwarf Fortress impact fracture divided by 1000 (likely not being used)
#
# dsty: density (grams per litre)
#
# fmod: forcemod -- related to attack points
# Attack points = `4 * forcemod.sqrt()` for each strike
#
# endurance: multiplier, using copper as reference; determines durability of tools/weapons/armours/etc.
# the base value for endurance differes to tool to tool. When integer is used, resulting value must be ROUNDED.
#
# tcond: thermal conductivity
#
# Comments: do nothing; do not parse
#
## These values are being used by the phys simulator (blocks) and for attack power calculation (items)
1 idst tens impf dsty fmod endurance tcond comments
1 idst tens impf dsty fmod endurance tcond comments
2 ROCK 15 210 3000 1 0.42 1.0 data is that of marble
3 CUPR 210 770 8960 2 1.00 401.0 copper
4 EGLS 33 1000 2325 4 0.82 1.0 elven glass/moldavite
5 IRON 350 1085 7874 5 1.42 1.0 not wrought iron; just natural iron
6 ARGN 170 595 10490 9 0.91 1.0 argentum/silver
7 STAL 531 2520 7874 14 1.73 1.0 steel
8 EAUR 768 0 8192 21 1.36 1.0 elven aurichalcum
9 TIAL 900 0 4420 33 2.16 1.0 titanium alloy (Ti6Al4V)
10 ADMT 2000 4090 2700 71 3.42 1.0 adamant
11 OOZE 20 0 1000 1 N/A 0.5 genetic ooze; data is about human skin
12 BONE 130 0 2000 1 0.23 0.55 data is that of bovine bone
13 # idst: ID_STRING, ALL CAPS
14 #
15 # tens: tensile strength (= ultimate stringth)
16 # not all 'impact' is not tensile stress, but I'm using it anyway because it's easiest to get the value from.
17 # that, or DF's tensile fracture divided by 1000 (I think Toady and I are both using values posted on Wikipedia, e.g. Silver)
18 #
19 # impf: Dwarf Fortress impact fracture divided by 1000 (likely not being used)
20 #
21 # dsty: density (grams per litre)
22 #
23 # fmod: forcemod -- related to attack points
24 # Attack points = `4 * forcemod.sqrt()` for each strike
25 #
26 # endurance: multiplier, using copper as reference determines durability of tools/weapons/armours/etc.
27 # the base value for endurance differes to tool to tool. When integer is used, resulting value must be ROUNDED.
28 #
29 # tcond: thermal conductivity
30 #
31 # Comments: do nothing do not parse
32 #
33 ## These values are being used by the phys simulator (blocks) and for attack power calculation (items)
34
35

View File

@@ -881,6 +881,10 @@ public class AppLoader implements ApplicationListener {
}
}
public static void printmsg(Object obj, Object message) {
System.out.println("[" + obj.getClass().getSimpleName() + "] " + message.toString());
}
public static ShaderProgram loadShader(String vert, String frag) {
ShaderProgram s = new ShaderProgram(Gdx.files.internal(vert), Gdx.files.internal(frag));

View File

@@ -2,8 +2,7 @@ package net.torvald.terrarum
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.files.FileHandle
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.AppLoader.printdbgerr
import net.torvald.terrarum.AppLoader.*
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.itemproperties.GameItem
import net.torvald.terrarum.itemproperties.ItemCodex
@@ -75,7 +74,7 @@ object ModMgr {
loadOrder.forEachIndexed { index, it ->
val moduleName = it[0]
printdbg(this, "Loading module $moduleName")
printmsg(this, "Loading module $moduleName")
try {
val modMetadata = Properties()

View File

@@ -102,15 +102,25 @@ class UIItemInventoryElem(
// this one-liner sets color
batch.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol
// draw name of the item
Terrarum.fontGame.draw(batch,
// print name and amount in parens
item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
// TEMPORARY print eqipped slot info as well
(if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""),
if (AppLoader.IS_DEVELOPMENT_BUILD) {
Terrarum.fontGame.draw(batch,
// print static id, dynamic id, and count
"${item!!.originalID}/${item!!.dynamicID}" + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else ""),
posX + textOffsetX,
posY + textOffsetY
)
}
else {
Terrarum.fontGame.draw(batch,
// print name and amount in parens
item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
// TEMPORARY print eqipped slot info as well
(if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""),
posX + textOffsetX,
posY + textOffsetY
)
posX + textOffsetX,
posY + textOffsetY
)
}
// durability metre

View File

@@ -2,6 +2,7 @@ package net.torvald.terrarum.blockproperties
import com.badlogic.gdx.graphics.Color
import net.torvald.terrarum.AppLoader
import net.torvald.terrarum.AppLoader.printmsg
import net.torvald.terrarum.gameworld.FluidType
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.gameworld.MapLayer
@@ -33,7 +34,7 @@ object BlockCodex {
try {
val records = CSVFetcher.readFromModule(module, path)
AppLoader.printdbg(this, "Building block properties table")
AppLoader.printmsg(this, "Building block properties table")
records.forEach {
/*if (intVal(it, "id") == -1) {
@@ -136,8 +137,7 @@ object BlockCodex {
blockProps[key] = prop
print("${intVal(record, "id")}")
println("\t" + prop.nameKey)
printmsg(this, "${intVal(record, "id")}\t" + prop.nameKey)
}
}

View File

@@ -44,11 +44,15 @@ open class GameWorld {
val loadTime: Long = System.currentTimeMillis() / 1000L
//layers
@TEMzPayload("WALL", TEMzPayload.EIGHT_MSB)
val layerWall: MapLayer
@TEMzPayload("TERR", TEMzPayload.EIGHT_MSB)
val layerTerrain: MapLayer
//val layerWire: MapLayer
@TEMzPayload("WALL", TEMzPayload.FOUR_LSB)
val layerWallLowBits: PairedMapLayer
@TEMzPayload("TERR", TEMzPayload.FOUR_LSB)
val layerTerrainLowBits: PairedMapLayer
//val layerThermal: MapLayerHalfFloat // in Kelvins
@@ -59,11 +63,17 @@ open class GameWorld {
/** Tilewise spawn point */
var spawnY: Int
@TEMzPayload("WdMG", TEMzPayload.INT48_FLOAT_PAIR)
val wallDamages: HashMap<BlockAddress, Float>
@TEMzPayload("TdMG", TEMzPayload.INT48_FLOAT_PAIR)
val terrainDamages: HashMap<BlockAddress, Float>
@TEMzPayload("FlTP", TEMzPayload.INT48_SHORT_PAIR)
val fluidTypes: HashMap<BlockAddress, FluidType>
@TEMzPayload("FlFL", TEMzPayload.INT48_FLOAT_PAIR)
val fluidFills: HashMap<BlockAddress, Float>
@TEMzPayload("CtYP", TEMzPayload.INT48_INT_PAIR)
val conduitTypes: HashMap<BlockAddress, Int> // 1 bit = 1 conduit (pipe/wire) type
@TEMzPayload("CfL", TEMzPayload.INT48_FLOAT_PAIR)
val conduitFills: Array<HashMap<BlockAddress, Float>>
val conduitFills0: HashMap<BlockAddress, Float> // size of liquid packet on the block
get() = conduitFills[0]
@@ -483,4 +493,21 @@ infix fun Float.fmod(other: Float) = if (this >= 0f) this % other else (this % o
inline class FluidType(val value: Int) {
infix fun sameAs(other: FluidType) = this.value.absoluteValue == other.value.absoluteValue
fun abs() = this.value.absoluteValue
}
}
/**
* @param payloadName Payload name defined in Map Data Format.txt
* * 4 Letters: regular payload
* * 3 Letters: only valid for arrays with 16 elements, names are auto-generated by appending '0'..'9'+'a'..'f'. E.g.: 'CfL' turns into 'CfL0', 'CfL1' ... 'CfLe', 'CfLf'
*
* @param arg 0 for 8 MSBs of Terrain/Wall layer, 1 for 4 LSBs of Terrain/Wall layer, 2 for Int48-Float pair, 3 for Int48-Short pair, 4 for Int48-Int pair
*/
annotation class TEMzPayload(val payloadName: String, val arg: Int) {
companion object {
const val EIGHT_MSB = 0
const val FOUR_LSB = 1
const val INT48_FLOAT_PAIR = 2
const val INT48_SHORT_PAIR = 3
const val INT48_INT_PAIR = 4
}
}

View File

@@ -1,6 +1,6 @@
package net.torvald.terrarum.itemproperties
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.AppLoader.printmsg
import net.torvald.terrarum.blockproperties.floatVal
import net.torvald.terrarum.blockproperties.intVal
import net.torvald.terrarum.utils.CSVFetcher
@@ -22,6 +22,8 @@ class Material {
//var armourMod: Float // multiplier. Copper as 1.0
var durability: Int = 0 // tools only
var identifier: String = "Name not set"
}
object MaterialCodex {
@@ -33,17 +35,20 @@ object MaterialCodex {
try {
val records = CSVFetcher.readFromModule(module, path)
printdbg(this, "Building materials table")
printmsg(this, "Building materials table")
records.forEach {
val prop = Material()
prop.strength = intVal(it, "tens")
prop.density = intVal(it, "dsty")
prop.forceMod = intVal(it, "forcemod")
prop.forceMod = intVal(it, "fmod")
prop.enduranceMod = floatVal(it, "endurance")
prop.thermalConductivity = floatVal(it, "tcond")
prop.identifier = it.get("idst").toUpperCase()
materialProps[it.get("idst").toUpperCase()] = prop
materialProps[prop.identifier] = prop
printmsg(this, "${prop.identifier}\t${prop.strength}\t${prop.density}\t${prop.forceMod}\t${prop.enduranceMod}")
}
}
catch (e: IOException) {
@@ -51,6 +56,13 @@ object MaterialCodex {
}
}
operator fun get(identifier: String) = materialProps[identifier.toUpperCase()] ?: nullMaterial
operator fun get(identifier: String) = try {
materialProps[identifier.toUpperCase()]!!
}
catch (e: NullPointerException) {
throw NullPointerException("Material with id $identifier does not exist.")
}
fun getOrDefault(identifier: String) = materialProps[identifier.toUpperCase()] ?: nullMaterial
}

View File

@@ -64,7 +64,7 @@ class EntryPoint : ModuleEntryPoint() {
override var stackable = true
override var inventoryCategory = if (i in ItemCodex.ITEM_TILES) Category.BLOCK else Category.WALL
override var isDynamic = false
override val material = MaterialCodex[blockProp.material]
override val material = MaterialCodex.getOrDefault(blockProp.material)
init {
equipPosition = EquipPosition.HAND_GRIP

View File

@@ -81,7 +81,7 @@ class PickaxeCopper(override val originalID: ItemID) : GameItem() {
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override var material = MaterialCodex["CUPR"]
override val material = MaterialCodex["CUPR"]
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
override val itemImage: TextureRegion?
get() = (AppLoader.resourcePool["basegame.items24"] as TextureRegionPack).get(0,0)
@@ -109,7 +109,7 @@ class PickaxeIron(override val originalID: ItemID) : GameItem() {
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override var material = MaterialCodex["IRON"]
override val material = MaterialCodex["IRON"]
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
override val itemImage: TextureRegion?
get() = (AppLoader.resourcePool["basegame.items24"] as TextureRegionPack).get(1,0)
@@ -137,7 +137,7 @@ class PickaxeSteel(override val originalID: ItemID) : GameItem() {
override var inventoryCategory = Category.TOOL
override val isUnique = false
override val isDynamic = true
override var material = MaterialCodex["STAL"]
override val material = MaterialCodex["STAL"]
override var baseMass = material.density.toDouble() / MaterialCodex["IRON"].density * BASE_MASS_AND_SIZE
override val itemImage: TextureRegion?
get() = (AppLoader.resourcePool["basegame.items24"] as TextureRegionPack).get(2,0)

View File

@@ -287,7 +287,14 @@ class UIItemInventoryDynamicList(
// set tooltip accordingly
if (isCompactMode && it.mouseUp && !tooltipSet) {
(Terrarum.ingame as? Ingame)?.setTooltipMessage(it.item?.name)
(Terrarum.ingame as? Ingame)?.setTooltipMessage(
if (AppLoader.IS_DEVELOPMENT_BUILD) {
it.item?.name + "/Mat: ${it.item?.material?.identifier}"
}
else {
it.item?.name
}
)
tooltipSet = true
}
}

View File

@@ -1,5 +1,6 @@
package net.torvald.terrarum.serialise
import net.torvald.terrarum.AppLoader.printdbg
import net.torvald.terrarum.gameworld.GameWorld
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64GrowableOutputStream
@@ -105,6 +106,10 @@ internal object WriteLayerDataZip {
// TODO serialised payloads have bit too much zeros, should I be worried?
val savePayloads = world.javaClass.superclass.declaredFields//.filter { it.isAnnotationPresent(TEMzPayload::class.java) }
printdbg(this, "")
savePayloads.forEach { printdbg(this, "${it.name}: ${it.type} @${it.declaredAnnotations.size}") }
wb(PAYLOAD_HEADER); wb("TERR".toByteArray())
wi48(world.width * world.height * 3L / 2)
deflater = DeflaterOutputStream(outputStream, Deflater(Deflater.BEST_COMPRESSION, true), false)