From 5d99b86dca757564b3e6c17c81e813df989329f4 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Sat, 16 Jul 2022 23:17:02 +0200 Subject: [PATCH] rm unused code --- .../topology/colourResourceChunks.kt | 172 ------------------ 1 file changed, 172 deletions(-) diff --git a/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourResourceChunks.kt b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourResourceChunks.kt index d4c5521..96d1835 100644 --- a/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourResourceChunks.kt +++ b/modules/events-server/src/main/kotlin/dev/adamko/kafkatorio/server/processor/topology/colourResourceChunks.kt @@ -113,28 +113,6 @@ fun KStream.convertEntityUpdateToServerM return flatMap("$pid.map") { serverId: FactorioServerId, update: MapChunkEntityUpdate -> -// val entities = update.entitiesXY.convert { entity, position -> -// FactorioEntityData.Standard( -// protoId = update.key.protoId, -// position = position, -// element = entity, -// ) -// } - -// val (validEntityPositions, unboundedEntityPositions) = entities.map { entity -> -// entity.position.toMapTilePosition() to entity -// }.partition { (position, _) -> -// position in update.key.chunkPosition -// } -// -// if (unboundedEntityPositions.isNotEmpty()) { -// val unboundedEntities = unboundedEntityPositions.map { (_, entity) -> entity } -// println( -// "WARNING [convertToServerMapChunkTiles] MapChunkEntityUpdate ${update.key} " + "contained ${unboundedEntities.size} out-of-bounds entities " + unboundedEntities.joinToString( -// limit = 10 -// ) -// ) -// } // // // TODO There might be multiple resources per tile position, therefore this will arbitrarily // // exclude resources. Maybe change it from a Map to a List? Or have multiple resources per @@ -194,38 +172,6 @@ fun KStream.convertResourceUpdateToSer } -//private fun KStream>.reduceServerMapResourceTilesToTable() -// : KTable> { -// -// val pid = "$pid.reduceServerMapResourceTilesToTable" -// -// return repartition( -// repartitionedAs( -// "$pid.pre-table-repartition", -// kxsBinary.serde(), -// kxsBinary.serde>(), -// // force, otherwise KTable-KTable FK join doesn't work -// numberOfPartitions = 1, -// ) -// ).groupByKey( -// groupedAs( -// "$pid.group-by-key", -// kxsBinary.serde(), -// kxsBinary.serde>(), -// ) -// ).reduce( -// "$pid.reduce", -// materializedAs( -// "$pid.reduce.store", -// kxsBinary.serde(), -// kxsBinary.serde>(), -// ) -// ) { chunkTiles, otherChunkTiles -> -// chunkTiles + otherChunkTiles -// } -//} - - private fun KTable>.enrichWithColourData( callerPid: String, protosTable: KTable, @@ -304,18 +250,6 @@ private fun MapBoundingBox.iterator(origin: MapTilePosition): Iterator 0 -> ceil(this).toInt() - this < 0 -> floor(this).toInt() - else -> 0 -} -// ceil(abs(this)).toInt() * this.sign.toInt() - - private fun FactorioPrototype.Entity.mapColour(): ColourHex = (colour ?: mapColour ?: mapColourFriend)?.toHex() ?: ColourHex.WHITE @@ -334,109 +268,3 @@ private operator fun ColourHex.plus(other: ColourHex): ColourHex = copy( blue = (blue + other.blue).toUByte(), alpha = (alpha + other.alpha).toUByte(), ) - - -//// https://stackoverflow.com/a/9355778/4161471 -//private operator fun ColourHex.plus(other: ColourHex): ColourHex { -// -// @Suppress("LocalVariableName") -// val `255` = UByte.MAX_VALUE -// -// val compositeAlpha: UByte = ( -// `255` - ((`255` - other.alpha) * (`255` - this.alpha)) / `255` -// ).toUByte() -// -// if (compositeAlpha == UByte.MIN_VALUE) { -// return ColourHex.TRANSPARENT -// } else { -// -// fun compositeColour( -// colour: (ColourHex) -> UByte, -// ): UByte { -// val colour1 = colour(this) -// val colour2 = colour(other) -// return (( -// ( -// ( colour2 * other.alpha) + (colour1 * this.alpha * ( other.alpha)) -// ) / compositeAlpha -// ) / `255` -// ).toUByte() -// } -// -// return ColourHex( -// compositeColour(ColourHex::red), -// compositeColour(ColourHex::green), -// compositeColour(ColourHex::blue), -// compositeAlpha, -// ) -// } -//} - -//private fun KTable>.streamMapChunkColouredTo( -// chunkSize: ChunkSize, -// outputTopic: String, -//) { -// val pid = "$pid.output-chunk.${chunkSize.name}" -// -// toStream("$pid.stream") -// .filter("$pid.filter-tiles-not-empty") { _, chunkTiles -> -// !chunkTiles?.map.isNullOrEmpty() -// } -// .mapValues("$pid.map-not-null") { _, chunkTiles -> -// requireNotNull(chunkTiles) -// } -// .peek("$pid.print-group-result") { _, chunkTiles -> -// println("Grouping map tiles result: ${chunkTiles.chunkId} / size:${chunkTiles.map.size}") -// }.to( -// outputTopic, -// producedAs( -// "$pid.grouped-map-chunks", -// kxsBinary.serde(), -// kxsBinary.serde>(), -// ) -// ) -//} - - -///** -// * Group [MapChunkTileUpdate]s by the Chunk position. -// * -// * They should already be grouped, but do it again to make sure, and to filter out empty updates. -// */ -//private fun KStream>.groupByChunkPosition( -// chunkSize: ChunkSize = ChunkSize.CHUNK_032 -//): KTable> { -// -// val pid = "$pid.groupByChunkPosition.${chunkSize.name}" -// -// return map("$pid.change-chunk-size") { chunkId: ServerMapChunkId, chunkTiles: ServerMapChunkTiles? -> -// -// val newChunkPosition = chunkId.chunkPosition -// .leftTopTile(chunkId.chunkSize) -// .toMapChunkPosition(chunkSize) -// -// val newId = chunkId.copy( -// chunkSize = chunkSize, -// chunkPosition = newChunkPosition, -// ) -// -// val newChunkTiles = chunkTiles?.map ?: emptyMap() -// -// newId to ServerMapChunkTiles(chunkId = newId, map = newChunkTiles) -// }.groupByKey( -// groupedAs( -// "$pid.group-by-key", -// kxsBinary.serde(), -// kxsBinary.serde>(), -// ) -// ).reduce( -// "$pid.reduce", -// materializedAs( -// "$pid.reduce.store", -// kxsBinary.serde(), -// kxsBinary.serde>(), -// ) -// ) { chunkTiles, otherChunkTiles -> -// chunkTiles + otherChunkTiles -// } -//}