Misc fixes
This commit is contained in:
parent
26c579f568
commit
d1e5557f27
@ -42,6 +42,6 @@ class DamageTileGroupPacket(val tiles: Collection<Vector2i>, val isBackground: B
|
||||
}
|
||||
|
||||
override fun play(connection: ServerConnection) {
|
||||
connection.tracker?.damageTiles(tiles, isBackground, sourcePosition, damage)
|
||||
connection.tracker?.damageTiles(tiles, isBackground, sourcePosition, damage, source)
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class ServerWorldTracker(val world: ServerWorld, val client: ServerConnection, p
|
||||
client.worldID = world.worldID
|
||||
}
|
||||
|
||||
private data class DamageTileEntry(val positions: Collection<Vector2i>, val isBackground: Boolean, val sourcePosition: Vector2d, val damage: TileDamage, val source: AbstractEntity? = null)
|
||||
private data class DamageTileEntry(val positions: Collection<Vector2i>, val isBackground: Boolean, val sourcePosition: Vector2d, val damage: TileDamage, val source: Int? = null)
|
||||
private val damageTilesQueue = Channel<DamageTileEntry>(64) // 64 pending tile group damage requests should be more than enough
|
||||
private val tileModificationBudget = ActionPacer(actions = 512, handicap = 2048) // TODO: make this configurable
|
||||
private val modifyTilesQueue = Channel<Pair<Collection<Pair<Vector2i, TileModification>>, Boolean>>(64)
|
||||
@ -91,7 +91,7 @@ class ServerWorldTracker(val world: ServerWorld, val client: ServerConnection, p
|
||||
val (positions, isBackground, sourcePosition, damage, source) = damageTilesQueue.receive()
|
||||
|
||||
try {
|
||||
world.damageTiles(positions, isBackground, sourcePosition, damage, source, tileModificationBudget)
|
||||
world.damageTiles(positions, isBackground, sourcePosition, damage, world.entities[source], tileModificationBudget)
|
||||
} catch (err: Throwable) {
|
||||
LOGGER.error("Exception in player damage tiles loop", err)
|
||||
client.disconnect("Exception in player damage tiles loop: $err")
|
||||
@ -99,7 +99,7 @@ class ServerWorldTracker(val world: ServerWorld, val client: ServerConnection, p
|
||||
}
|
||||
}
|
||||
|
||||
fun damageTiles(positions: Collection<Vector2i>, isBackground: Boolean, sourcePosition: Vector2d, damage: TileDamage, source: AbstractEntity? = null) {
|
||||
fun damageTiles(positions: Collection<Vector2i>, isBackground: Boolean, sourcePosition: Vector2d, damage: TileDamage, source: Int? = null) {
|
||||
damageTilesQueue.trySend(DamageTileEntry(positions, isBackground, sourcePosition, damage, source))
|
||||
}
|
||||
|
||||
|
@ -585,11 +585,11 @@ abstract class World<This : World<This, ChunkType>, ChunkType : Chunk<This, Chun
|
||||
// this *could* have been divided into per-entity map and beheaded world's map
|
||||
// but we can't, because response packets contain only message UUID, and don't contain entity ID
|
||||
val pendingEntityMessages: Cache<UUID, CompletableFuture<JsonElement>> = Caffeine.newBuilder()
|
||||
.maximumSize(32000L) // some unreachable value unless there is a malicious actor
|
||||
.maximumSize(200_000L) // some unreachable value unless there is a malicious actor
|
||||
.expireAfterWrite(1L, TimeUnit.MINUTES)
|
||||
.executor(Starbound.EXECUTOR)
|
||||
.scheduler(Starbound)
|
||||
.removalListener<UUID, CompletableFuture<JsonElement>> { key, value, cause -> if (!cause.wasEvicted()) value?.completeExceptionally(TimeoutException("Did not receive response from remote in time")) }
|
||||
.removalListener<UUID, CompletableFuture<JsonElement>> { key, value, cause -> if (cause.wasEvicted()) value?.completeExceptionally(TimeoutException("Did not receive response from remote in time")) }
|
||||
.build()
|
||||
|
||||
companion object {
|
||||
|
Loading…
Reference in New Issue
Block a user