Ensure the chunk & system that the player's ship is always in their local chunk cache

#74
This commit is contained in:
Kae 2024-06-24 14:08:04 +10:00
parent 4c90472977
commit e1b1b2fd59
2 changed files with 5 additions and 3 deletions

View File

@ -75,7 +75,8 @@ void SystemWorldClient::update(float dt) {
m_clientShips.clear();
m_ship = {};
m_location = Vec3I();
}
} else if (auto celestialSlave = as<CelestialSlaveDatabase>(m_celestialDatabase))
celestialSlave->signalSystem(currentSystem()); // keeps the celestial chunk for our current system alive
}
List<SystemObjectPtr> SystemWorldClient::objects() const {

View File

@ -735,7 +735,7 @@ void UniverseServer::kickErroredPlayers() {
for (auto const& worldId : m_worlds.keys()) {
if (auto world = getWorld(worldId)) {
for (auto clientId : world->erroredClients())
m_pendingDisconnections.add(clientId, "Incoming client packet has caused exception");
m_pendingDisconnections[clientId] = "Incoming client packet has caused exception";
}
}
}
@ -1714,8 +1714,9 @@ void UniverseServer::acceptConnection(UniverseConnection connection, Maybe<HostA
Vec3I location = clientContext->shipCoordinate().location();
if (location != Vec3I()) {
auto clientSystem = createSystemWorld(clientContext->shipCoordinate().location());
auto clientSystem = createSystemWorld(location);
clientSystem->addClient(clientId, clientContext->playerUuid(), clientContext->shipUpgrades().shipSpeed, clientContext->shipLocation());
addCelestialRequests(clientId, {makeLeft(location.vec2()), makeRight(location)});
clientContext->setSystemWorld(clientSystem);
}