mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
poi json out test
This commit is contained in:
@@ -1607,7 +1607,7 @@ public class App implements ApplicationListener {
|
|||||||
System.out.println(prompt+"null");
|
System.out.println(prompt+"null");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String indentation = " ".repeat(out.length() + 15);
|
String indentation = " ".repeat(out.length() + 16);
|
||||||
String[] msgLines = message.toString().split("\\n");
|
String[] msgLines = message.toString().split("\\n");
|
||||||
for (int i = 0; i < msgLines.length; i++) {
|
for (int i = 0; i < msgLines.length; i++) {
|
||||||
System.out.println((i == 0 ? prompt : indentation) + msgLines[i]);
|
System.out.println((i == 0 ? prompt : indentation) + msgLines[i]);
|
||||||
@@ -1629,10 +1629,10 @@ public class App implements ApplicationListener {
|
|||||||
System.out.println(prompt+"null"+csi0);
|
System.out.println(prompt+"null"+csi0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String indentation = " ".repeat(out.length() + 11);
|
String indentation = " ".repeat(out.length() + 16);
|
||||||
String[] msgLines = message.toString().split("\\n");
|
String[] msgLines = message.toString().split("\\n");
|
||||||
for (int i = 0; i < msgLines.length; i++) {
|
for (int i = 0; i < msgLines.length; i++) {
|
||||||
System.out.println((i == 0 ? prompt : indentation) + msgLines[i] + csi0);
|
System.out.println((i == 0 ? prompt : indentation) + csiR + msgLines[i] + csi0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import net.torvald.terrarum.gameitems.ItemID
|
|||||||
import net.torvald.terrarum.gameparticles.ParticleBase
|
import net.torvald.terrarum.gameparticles.ParticleBase
|
||||||
import net.torvald.terrarum.gameworld.BlockLayerI16
|
import net.torvald.terrarum.gameworld.BlockLayerI16
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.gameworld.GameWorld.Companion.TERRAIN
|
|
||||||
import net.torvald.terrarum.gameworld.GameWorld.Companion.WALL
|
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.gameworld.WorldTime
|
import net.torvald.terrarum.gameworld.WorldTime
|
||||||
import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerBlockChooser
|
import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerBlockChooser
|
||||||
@@ -742,6 +740,8 @@ class YamlCommandToolExportTest : YamlInvokable {
|
|||||||
marked.add(it.toAddr())
|
marked.add(it.toAddr())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printdbg(this, "POI Area: ($minX,$minY)..($maxX,$maxY), WH=(${maxX - minX},${maxY - minY})")
|
||||||
|
|
||||||
var name = "test"
|
var name = "test"
|
||||||
|
|
||||||
// prepare POI
|
// prepare POI
|
||||||
@@ -750,7 +750,7 @@ class YamlCommandToolExportTest : YamlInvokable {
|
|||||||
val terr = BlockLayerI16(poi.w, poi.h)
|
val terr = BlockLayerI16(poi.w, poi.h)
|
||||||
val wall = BlockLayerI16(poi.w, poi.h)
|
val wall = BlockLayerI16(poi.w, poi.h)
|
||||||
layer.blockLayer = arrayListOf(terr, wall)
|
layer.blockLayer = arrayListOf(terr, wall)
|
||||||
poi.layers[0] = layer
|
poi.layers.add(layer)
|
||||||
|
|
||||||
for (x in minX..maxX) {
|
for (x in minX..maxX) {
|
||||||
for (y in minY..maxY) {
|
for (y in minY..maxY) {
|
||||||
|
|||||||
@@ -34,20 +34,16 @@ class PointOfInterest(
|
|||||||
override fun write(json: Json) {
|
override fun write(json: Json) {
|
||||||
val tileSymbolToItemId = HashArray<ItemID>() // exported
|
val tileSymbolToItemId = HashArray<ItemID>() // exported
|
||||||
|
|
||||||
val uniqueTiles = ArrayList(layers.flatMap { it.getUniqueTiles() }.toSet().toList().sorted())
|
val uniqueTiles = ArrayList(layers.flatMap { it.getUniqueTiles() }.toSet().toList().sorted()) // contains TileNumber
|
||||||
// swap if non-air tile is occupying the index 0
|
|
||||||
if (tileNumberToNameMap[uniqueTiles[0].toLong()] != Block.AIR) {
|
|
||||||
val otherTileIndex = uniqueTiles.linearSearchBy { tileNumberToNameMap[it.toLong()] == Block.AIR }!!
|
|
||||||
val t = uniqueTiles[otherTileIndex]
|
|
||||||
uniqueTiles[otherTileIndex] = uniqueTiles[0]
|
|
||||||
uniqueTiles[0] = t
|
|
||||||
}
|
|
||||||
|
|
||||||
// build tileSymbolToItemId
|
// build tileSymbolToItemId
|
||||||
uniqueTiles.forEachIndexed { index, tilenum ->
|
uniqueTiles.forEachIndexed { index, tilenum ->
|
||||||
tileSymbolToItemId[index.toLong()] = tileNumberToNameMap[tilenum.toLong()]!!
|
tileSymbolToItemId[index.toLong()] = if (tilenum == 65535) // largest value on BlockLayerI16
|
||||||
|
Block.NULL
|
||||||
|
else
|
||||||
|
tileNumberToNameMap[tilenum.toLong()] ?: throw NullPointerException("No tileNumber->tileName mapping for $tilenum")
|
||||||
}
|
}
|
||||||
tileSymbolToItemId[-1] = Block.NULL
|
|
||||||
|
|
||||||
val itemIDtoTileSym = tileSymbolToItemId.map { it.value to it.key }.toMap()
|
val itemIDtoTileSym = tileSymbolToItemId.map { it.value to it.key }.toMap()
|
||||||
|
|
||||||
@@ -55,6 +51,7 @@ class PointOfInterest(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
printdbg(this, "unique tiles: ${tileSymbolToItemId.size}")
|
||||||
printdbg(this, "lut=$tileSymbolToItemId")
|
printdbg(this, "lut=$tileSymbolToItemId")
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +120,7 @@ class POILayer(
|
|||||||
ByteArray(layer.width * layer.height * byteLength) { i ->
|
ByteArray(layer.width * layer.height * byteLength) { i ->
|
||||||
if (byteLength == 1) {
|
if (byteLength == 1) {
|
||||||
val tilenum = layer.unsafeGetTile(i % layer.width, i / layer.width).toLong()
|
val tilenum = layer.unsafeGetTile(i % layer.width, i / layer.width).toLong()
|
||||||
val itemID = if (tilenum == 255L) Block.NULL else tilenumToItemID[tilenum]!!
|
val itemID = if (tilenum == 65535L) Block.NULL else tilenumToItemID[tilenum] ?: throw NullPointerException("No tileNumber->tileName mapping for $tilenum")
|
||||||
val tileSym = itemIDtoTileSym[itemID]!!
|
val tileSym = itemIDtoTileSym[itemID]!!
|
||||||
tileSym.toByte()
|
tileSym.toByte()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ POIs are serialised as following:
|
|||||||
"w": 7, "h": 4,
|
"w": 7, "h": 4,
|
||||||
"layers": [ /* order matters! */
|
"layers": [ /* order matters! */
|
||||||
{"name": "base", "dat": [
|
{"name": "base", "dat": [
|
||||||
"...layer_0.gz.b85", /* each byte matches what's on the LUT, except 0xFF (0xFFFF if wlen=16) always refers to the null tile. Endianness: little */
|
"...layer_0.gz.b85", /* each byte matches what's on the LUT, except 0xFF (0xFFFF if wlen=16) always refers to the null tile. Endianness: little; byte of 0 is NOT guaranteed to be an air tile */
|
||||||
"...layer_1.gz.b85"
|
"...layer_1.gz.b85"
|
||||||
]},
|
]},
|
||||||
{"name": "varianceA", "dat": [
|
{"name": "varianceA", "dat": [
|
||||||
|
|||||||
Reference in New Issue
Block a user