Fix orbital warp actions
This commit is contained in:
parent
aea534add4
commit
31ea958304
@ -49,6 +49,10 @@ class ServerChannels(val server: StarboundServer) : Closeable {
|
|||||||
return connections.firstOrNull { it.connectionID == id }
|
return connections.firstOrNull { it.connectionID == id }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun connectionByUUID(id: UUID): ServerConnection? {
|
||||||
|
return connections.firstOrNull { it.uuid == id }
|
||||||
|
}
|
||||||
|
|
||||||
private fun cycleConnectionID(): Int {
|
private fun cycleConnectionID(): Int {
|
||||||
val v = ++nextConnectionID and MAX_PLAYERS
|
val v = ++nextConnectionID and MAX_PLAYERS
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import ru.dbotthepony.kommons.vector.Vector3i
|
|||||||
import ru.dbotthepony.kstarbound.Globals
|
import ru.dbotthepony.kstarbound.Globals
|
||||||
import ru.dbotthepony.kstarbound.defs.WarpAction
|
import ru.dbotthepony.kstarbound.defs.WarpAction
|
||||||
import ru.dbotthepony.kstarbound.defs.WarpAlias
|
import ru.dbotthepony.kstarbound.defs.WarpAlias
|
||||||
|
import ru.dbotthepony.kstarbound.defs.WarpMode
|
||||||
import ru.dbotthepony.kstarbound.defs.WorldID
|
import ru.dbotthepony.kstarbound.defs.WorldID
|
||||||
import ru.dbotthepony.kstarbound.defs.world.CelestialParameters
|
import ru.dbotthepony.kstarbound.defs.world.CelestialParameters
|
||||||
import ru.dbotthepony.kstarbound.defs.world.VisitableWorldParameters
|
import ru.dbotthepony.kstarbound.defs.world.VisitableWorldParameters
|
||||||
@ -167,6 +168,16 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
world.acceptClient(this, request).await()
|
world.acceptClient(this, request).await()
|
||||||
|
|
||||||
|
if (resolve is WorldID.ShipWorld) {
|
||||||
|
val connection = server.channels.connectionByUUID(resolve.uuid)
|
||||||
|
|
||||||
|
if (connection != null) {
|
||||||
|
orbitalWarpAction = connection.currentOrbitalWarpAction
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
orbitalWarpAction = KOptional()
|
||||||
|
}
|
||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
send(PlayerWarpResultPacket(false, request, false))
|
send(PlayerWarpResultPacket(false, request, false))
|
||||||
|
|
||||||
@ -186,6 +197,8 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
flyShipQueue.trySend(system to location)
|
flyShipQueue.trySend(system to location)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var currentOrbitalWarpAction = KOptional<Pair<WarpAction, WarpMode>>()
|
||||||
|
|
||||||
// coordinates ship flight
|
// coordinates ship flight
|
||||||
private suspend fun shipFlightEventLoop() {
|
private suspend fun shipFlightEventLoop() {
|
||||||
shipWorld.sky.startFlying(true, true)
|
shipWorld.sky.startFlying(true, true)
|
||||||
@ -194,7 +207,7 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
LOGGER.info("Finding starter world for ${alias()}...")
|
LOGGER.info("Finding starter world for ${alias()}...")
|
||||||
val params = Globals.universeServer.findStarterWorldParameters
|
val params = Globals.universeServer.findStarterWorldParameters
|
||||||
|
|
||||||
// visit all since sparsingly trying to find specific world is not healthy performance wise
|
// visit all since randomly trying to find specific world is not healthy performance wise
|
||||||
val found = server.universe.findRandomWorld(params.tries, params.range, visitAll = true, predicate = {
|
val found = server.universe.findRandomWorld(params.tries, params.range, visitAll = true, predicate = {
|
||||||
if (++visited % 600 == 0) {
|
if (++visited % 600 == 0) {
|
||||||
LOGGER.info("Still finding starter world for ${alias()}...")
|
LOGGER.info("Still finding starter world for ${alias()}...")
|
||||||
@ -264,7 +277,7 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
currentFlightJob = scope.launch {
|
currentFlightJob = scope.launch {
|
||||||
val coords = flight.await()
|
val coords = flight.await()
|
||||||
val action = coords.orbitalAction(world)
|
val action = coords.orbitalAction(world)
|
||||||
orbitalWarpAction = action
|
currentOrbitalWarpAction = action
|
||||||
|
|
||||||
for (client in shipWorld.clients) {
|
for (client in shipWorld.clients) {
|
||||||
client.client.orbitalWarpAction = action
|
client.client.orbitalWarpAction = action
|
||||||
@ -277,7 +290,7 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
orbitalWarpAction = KOptional()
|
currentOrbitalWarpAction = KOptional()
|
||||||
|
|
||||||
for (client in shipWorld.clients) {
|
for (client in shipWorld.clients) {
|
||||||
client.client.orbitalWarpAction = KOptional()
|
client.client.orbitalWarpAction = KOptional()
|
||||||
@ -300,7 +313,7 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
|
|||||||
val newSystem = server.loadSystemWorld(system)
|
val newSystem = server.loadSystemWorld(system)
|
||||||
|
|
||||||
shipCoordinate = UniversePos(system)
|
shipCoordinate = UniversePos(system)
|
||||||
orbitalWarpAction = KOptional()
|
currentOrbitalWarpAction = KOptional()
|
||||||
|
|
||||||
for (client in shipWorld.clients) {
|
for (client in shipWorld.clients) {
|
||||||
client.client.orbitalWarpAction = KOptional()
|
client.client.orbitalWarpAction = KOptional()
|
||||||
|
Loading…
Reference in New Issue
Block a user