Ship flight now properly accounts for desired target location in new system when switching systems

This commit is contained in:
DBotThePony 2024-04-24 11:57:22 +07:00
parent 2a23c579bc
commit c0c63b9240
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 39 additions and 29 deletions

View File

@ -309,11 +309,7 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
var currentFlightJob: Job? = null
while (true) {
val (system, location) = flyShipQueue.receive()
if (system == world.location) {
// fly ship in current system
suspend fun flyShipInSystem(location: SystemWorldLocation) {
currentFlightJob?.cancel()
val flight = world.flyShip(this, location)
@ -343,6 +339,14 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
for (client in shipWorld.clients) {
client.client.orbitalWarpAction = KOptional()
}
}
while (true) {
val (system, location) = flyShipQueue.receive()
if (system == world.location) {
// fly ship in current system
flyShipInSystem(location)
} else {
// we need to travel to other system
val exists = server.universe.parameters(UniversePos(system)) != null
@ -378,6 +382,11 @@ class ServerConnection(val server: StarboundServer, type: ConnectionType) : Conn
// this seems to be way too big isn't it?
delay((Globals.universeServer.queuedFlightWaitTime * 1000.0).toLong())
if (location != SystemWorldLocation.Transit) {
// player clicked on specific planet in remote system view
flyShipInSystem(location)
}
}
}
}

View File

@ -182,6 +182,7 @@ class ServerSystemWorld : SystemWorld {
var diff = Globals.systemWorld.objectSpawnCycle.coerceAtMost(clock.time - lastSpawn)
lastSpawn = clock.time - diff
// persistent spawning (e.g. we simulate time passing as if we were always loaded)
while (diff > objectSpawnTime) {
lastSpawn += objectSpawnTime
objectSpawnTime = random.nextRange(Globals.systemWorld.objectSpawnInterval)