code tidy
This commit is contained in:
parent
066f68ff4d
commit
93e02e852a
2 changed files with 2 additions and 63 deletions
|
|
@ -3,7 +3,6 @@ export namespace EventDataCache {
|
||||||
|
|
||||||
declare const global: {
|
declare const global: {
|
||||||
cache: LuaTable<string, CacheEntry<FactorioEventUpdateType>>,
|
cache: LuaTable<string, CacheEntry<FactorioEventUpdateType>>,
|
||||||
// cache: Map<string, CacheEntry<FactorioEventUpdateType>>,
|
|
||||||
defaultCacheDurationTicks: Record<FactorioEventUpdateType | "default", uint>,
|
defaultCacheDurationTicks: Record<FactorioEventUpdateType | "default", uint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,7 +93,6 @@ export namespace EventDataCache {
|
||||||
countExpired++
|
countExpired++
|
||||||
expiredData.push(entry.data)
|
expiredData.push(entry.data)
|
||||||
global.cache.delete(key)
|
global.cache.delete(key)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(`cache expired items count: ${countExpired}, total: ${countTotal}`)
|
log(`cache expired items count: ${countExpired}, total: ${countTotal}`)
|
||||||
|
|
@ -106,7 +104,6 @@ export namespace EventDataCache {
|
||||||
key: CacheKey<TYPE>
|
key: CacheKey<TYPE>
|
||||||
): CacheEntry<TYPE> | undefined {
|
): CacheEntry<TYPE> | undefined {
|
||||||
const hash = game.encode_string(game.table_to_json(key))!!
|
const hash = game.encode_string(game.table_to_json(key))!!
|
||||||
// const value: CacheEntry<any> | undefined = global.cache.get(hash)
|
|
||||||
if (!global.cache.has(hash)) {
|
if (!global.cache.has(hash)) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
@ -140,16 +137,12 @@ export namespace EventDataCache {
|
||||||
TYPE extends "ENTITY" ? EntityUpdate :
|
TYPE extends "ENTITY" ? EntityUpdate :
|
||||||
never
|
never
|
||||||
|
|
||||||
|
|
||||||
type ConvertToUpdateKey<TYPE extends FactorioEventUpdateType> =
|
type ConvertToUpdateKey<TYPE extends FactorioEventUpdateType> =
|
||||||
TYPE extends "PLAYER" ? PlayerUpdateKey :
|
TYPE extends "PLAYER" ? PlayerUpdateKey :
|
||||||
TYPE extends "MAP_CHUNK" ? MapChunkUpdateKey :
|
TYPE extends "MAP_CHUNK" ? MapChunkUpdateKey :
|
||||||
TYPE extends "ENTITY" ? EntityUpdateKey :
|
TYPE extends "ENTITY" ? EntityUpdateKey :
|
||||||
never
|
never
|
||||||
// type ConvertToUpdateData<TYPE extends FactorioEventUpdateType> =
|
|
||||||
// TYPE extends "PLAYER" ? PlayerUpdateData :
|
|
||||||
// TYPE extends "MAP_CHUNK" ? MapChunkUpdateData :
|
|
||||||
// TYPE extends "ENTITY" ? EntityUpdateData :
|
|
||||||
// never
|
|
||||||
|
|
||||||
|
|
||||||
/** Make `updateType` specific */
|
/** Make `updateType` specific */
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,13 @@ sealed interface FactorioEventUpdateKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//sealed interface FactorioEventUpdateData {
|
|
||||||
// val updateType: FactorioEventUpdateType
|
|
||||||
// val event: String?
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable(with = FactorioEventUpdate.Companion.JsonSerializer::class)
|
@Serializable(with = FactorioEventUpdate.Companion.JsonSerializer::class)
|
||||||
sealed class FactorioEventUpdate : FactorioEventUpdateKey {
|
sealed class FactorioEventUpdate : FactorioEventUpdateKey {
|
||||||
|
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
abstract override val updateType: FactorioEventUpdateType
|
abstract override val updateType: FactorioEventUpdateType
|
||||||
@Contextual
|
@Contextual
|
||||||
abstract val events: List<String>?
|
abstract val events: List<String>? // TODO change this to Map<String, UInt>
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
enum class FactorioEventUpdateType {
|
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
|
@Serializable
|
||||||
data class PlayerUpdate(
|
data class PlayerUpdate(
|
||||||
override val index: PlayerIndex,
|
override val index: PlayerIndex,
|
||||||
|
|
@ -172,17 +138,6 @@ sealed interface EntityUpdateKey : EntityIdentifiers, FactorioEventUpdateKey {
|
||||||
override val type: String
|
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
|
@Serializable
|
||||||
data class EntityUpdate(
|
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<MapTile>?
|
|
||||||
// val isDeleted: Boolean?
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MapChunkUpdate(
|
data class MapChunkUpdate(
|
||||||
override val chunkPosition: MapChunkPosition,
|
override val chunkPosition: MapChunkPosition,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue