From 93e02e852afdae612ed3f753e233a34cb40c6689 Mon Sep 17 00:00:00 2001 From: Adam <897017+aSemy@users.noreply.github.com> Date: Thu, 24 Feb 2022 22:17:00 +0100 Subject: [PATCH] code tidy --- .../typescript/main/cache/EventDataCache.ts | 9 +-- .../events/schema/factorioEventUpdates.kt | 56 +------------------ 2 files changed, 2 insertions(+), 63 deletions(-) diff --git a/modules/events-mod/src/main/typescript/main/cache/EventDataCache.ts b/modules/events-mod/src/main/typescript/main/cache/EventDataCache.ts index 08b7e17..2cc0ebe 100644 --- a/modules/events-mod/src/main/typescript/main/cache/EventDataCache.ts +++ b/modules/events-mod/src/main/typescript/main/cache/EventDataCache.ts @@ -3,7 +3,6 @@ export namespace EventDataCache { declare const global: { cache: LuaTable>, - // cache: Map>, defaultCacheDurationTicks: Record, } @@ -94,7 +93,6 @@ export namespace EventDataCache { countExpired++ expiredData.push(entry.data) global.cache.delete(key) - } } log(`cache expired items count: ${countExpired}, total: ${countTotal}`) @@ -106,7 +104,6 @@ export namespace EventDataCache { key: CacheKey ): CacheEntry | undefined { const hash = game.encode_string(game.table_to_json(key))!! - // const value: CacheEntry | undefined = global.cache.get(hash) if (!global.cache.has(hash)) { return undefined } @@ -140,16 +137,12 @@ export namespace EventDataCache { TYPE extends "ENTITY" ? EntityUpdate : never + type ConvertToUpdateKey = TYPE extends "PLAYER" ? PlayerUpdateKey : TYPE extends "MAP_CHUNK" ? MapChunkUpdateKey : TYPE extends "ENTITY" ? EntityUpdateKey : never - // type ConvertToUpdateData = - // TYPE extends "PLAYER" ? PlayerUpdateData : - // TYPE extends "MAP_CHUNK" ? MapChunkUpdateData : - // TYPE extends "ENTITY" ? EntityUpdateData : - // never /** Make `updateType` specific */ diff --git a/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEventUpdates.kt b/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEventUpdates.kt index 54c3fbf..b6c393b 100644 --- a/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEventUpdates.kt +++ b/modules/events-schema/src/commonMain/kotlin/dev/adamko/kafkatorio/events/schema/factorioEventUpdates.kt @@ -32,19 +32,13 @@ sealed interface FactorioEventUpdateKey { } -//sealed interface FactorioEventUpdateData { -// val updateType: FactorioEventUpdateType -// val event: String? -//} - - @Serializable(with = FactorioEventUpdate.Companion.JsonSerializer::class) sealed class FactorioEventUpdate : FactorioEventUpdateKey { @EncodeDefault abstract override val updateType: FactorioEventUpdateType @Contextual - abstract val events: List? + abstract val events: List? // TODO change this to Map @Serializable enum class FactorioEventUpdateType { @@ -97,34 +91,6 @@ sealed interface PlayerUpdateKey : FactorioEventUpdateKey { } -//sealed interface PlayerUpdateData : FactorioEventUpdateData { -// val characterUnitNumber: UnitNumber? -// val chatColour: Colour? -// val colour: Colour? -// val name: String? -// -// val afkTime: Tick? -// val ticksToRespawn: Tick? -// val forceIndex: ForceIndex? -// val isAdmin: Boolean? -// val isConnected: Boolean? -// val isShowOnMap: Boolean? -// val isSpectator: Boolean? -// val lastOnline: Tick? -// val onlineTime: Tick? -// val position: MapEntityPosition? -// val surfaceIndex: SurfaceIndex? -// val tag: String? -// val diedCause: EntityIdentifiers? -// -// val bannedReason: String? -// val kickedReason: String? -// val disconnectReason: String? -// /** `true` when a player is removed (deleted) from the game */ -// val isRemoved: Boolean? -//} - - @Serializable data class PlayerUpdate( override val index: PlayerIndex, @@ -172,17 +138,6 @@ sealed interface EntityUpdateKey : EntityIdentifiers, FactorioEventUpdateKey { override val type: String } -//sealed interface EntityUpdateData : FactorioEventUpdateData { -// val chunkPosition: MapChunkPosition? -// val graphicsVariation: UShort? -// val health: Float? -// val isActive: Boolean? -// val isRotatable: Boolean? -// val lastUser: UInt? -// val localisedDescription: String? -// val localisedName: String? -// val prototype: PrototypeName? -//} @Serializable data class EntityUpdate( @@ -217,15 +172,6 @@ sealed interface MapChunkUpdateKey : FactorioEventUpdateKey { } -//sealed interface MapChunkUpdateData : FactorioEventUpdateData { -// val player: PlayerIndex? -// val robot: EntityIdentifiers? -// val force: ForceIndex? -// val tiles: List? -// val isDeleted: Boolean? -//} - - @Serializable data class MapChunkUpdate( override val chunkPosition: MapChunkPosition,