Now players are properly kicked to their ships if world experiences fatal error
This commit is contained in:
parent
4212390bf3
commit
e04cc92ffd
@ -774,7 +774,7 @@ class ServerChunk(world: ServerWorld, pos: ChunkPos) : Chunk<ServerWorld, Server
|
|||||||
|
|
||||||
// some breathing room for other code, since placement checking is performance intense operation
|
// some breathing room for other code, since placement checking is performance intense operation
|
||||||
if (!world.isInPreparation && world.clients.isNotEmpty())
|
if (!world.isInPreparation && world.clients.isNotEmpty())
|
||||||
delay(min(60L, anchor.reader.size.x * anchor.reader.size.y / 40L))
|
delay(min(60L, anchor.reader.size.x * anchor.reader.size.y / 240L))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import ru.dbotthepony.kommons.util.IStruct2i
|
|||||||
import ru.dbotthepony.kstarbound.math.vector.Vector2d
|
import ru.dbotthepony.kstarbound.math.vector.Vector2d
|
||||||
import ru.dbotthepony.kstarbound.math.vector.Vector2i
|
import ru.dbotthepony.kstarbound.math.vector.Vector2i
|
||||||
import ru.dbotthepony.kstarbound.Globals
|
import ru.dbotthepony.kstarbound.Globals
|
||||||
|
import ru.dbotthepony.kstarbound.Registries
|
||||||
import ru.dbotthepony.kstarbound.Starbound
|
import ru.dbotthepony.kstarbound.Starbound
|
||||||
import ru.dbotthepony.kstarbound.defs.WarpAction
|
import ru.dbotthepony.kstarbound.defs.WarpAction
|
||||||
import ru.dbotthepony.kstarbound.defs.WarpAlias
|
import ru.dbotthepony.kstarbound.defs.WarpAlias
|
||||||
@ -97,7 +98,7 @@ class ServerWorld private constructor(
|
|||||||
clients.add(ServerWorldTracker(this, client, start))
|
clients.add(ServerWorldTracker(this, client, start))
|
||||||
|
|
||||||
//if (worldID is WorldID.Celestial)
|
//if (worldID is WorldID.Celestial)
|
||||||
//Registries.dungeons["terrainfeatures"]?.value?.generate(this@ServerWorld, random(), start.x.toInt(), start.y.toInt(), markSurfaceAndTerrain = false, forcePlacement = true)
|
//Registries.dungeons["naturalcave"]?.value?.generate(this@ServerWorld, random(), start.x.toInt(), start.y.toInt(), markSurfaceAndTerrain = false, forcePlacement = true)
|
||||||
} finally {
|
} finally {
|
||||||
isBusy--
|
isBusy--
|
||||||
}
|
}
|
||||||
@ -138,7 +139,7 @@ class ServerWorld private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
clients.forEach {
|
clients.forEach {
|
||||||
it.remove()
|
it.remove("World shutting down", setReturnWarp = false)
|
||||||
it.client.enqueueWarp(WarpAlias.Return)
|
it.client.enqueueWarp(WarpAlias.Return)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,6 +352,10 @@ class ServerWorld private constructor(
|
|||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
LOGGER.fatal("Exception in world tick loop", err)
|
LOGGER.fatal("Exception in world tick loop", err)
|
||||||
eventLoop.shutdown()
|
eventLoop.shutdown()
|
||||||
|
|
||||||
|
if (worldID is WorldID.ShipWorld) {
|
||||||
|
server.channels.connectionByUUID(worldID.uuid)?.disconnect("Exception in shipworld tick loop: $err")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,14 +336,14 @@ class ServerWorldTracker(val world: ServerWorld, val client: ServerConnection, p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun remove(reason: String = "ServerWorldTracker got removed", nullifyVariables: Boolean = true) {
|
fun remove(reason: String = "ServerWorldTracker got removed", nullifyVariables: Boolean = true, setReturnWarp: Boolean = true) {
|
||||||
if (isRemoved.compareAndSet(false, true)) {
|
if (isRemoved.compareAndSet(false, true)) {
|
||||||
// erase all tasks just to be sure
|
// erase all tasks just to be sure
|
||||||
tasks.clear()
|
tasks.clear()
|
||||||
|
|
||||||
val playerEntity = client.playerEntity
|
val playerEntity = client.playerEntity
|
||||||
|
|
||||||
if (playerEntity != null && world.worldID is WorldID.Celestial) {
|
if (playerEntity != null && world.worldID is WorldID.Celestial && setReturnWarp) {
|
||||||
client.returnWarp = WarpAction.World(world.worldID, SpawnTarget.Position(playerEntity.position))
|
client.returnWarp = WarpAction.World(world.worldID, SpawnTarget.Position(playerEntity.position))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user