fix: a seamless instance move keeps the player in scope, in place and without the white fade

The source no longer destroys the player's own ghost: losing it hid the character, and the target's construction
brought it back with the login effect (LWOGhostComponent::OnGhostReceiveDestruction, 0x00c99410,
LWOBaseRenderComponent::OnEnterScope, 0x00be2150). The target constructs the player to its own client without a
position and with world transition state 3. The client sends PlayerLoaded itself after that construction, so the
server only runs it when none came within 5 s, and PlayerReady (camera pitch reset) is not sent. A seamless arrival is
only expected for 30 s, so a later login gets LOAD_STATIC_ZONE.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-11-10 15:15:16 -06:00
parent f081dafb94
commit 1113775741
4 changed files with 39 additions and 11 deletions

View File

@@ -62,7 +62,11 @@ namespace GameMessages {
void PlayerLoaded::Handle(Entity& entityRef, const SystemAddress& sysAddr) {
auto* entity = &entityRef;
const auto* const zoneControlEntity = Game::entityManager->GetZoneControlEntity();
SendPlayerReady(entity->GetObjectID(), zoneControlEntity ? zoneControlEntity->GetObjectID() : LWOOBJID_EMPTY, sysAddr);
// A client that kept its player across a seamless instance move is ready already; PlayerReady would only put
// its camera's pitch back to the default (LWOCharacterComponent::iSendMessage, 0x00d34330)
if (!WorldMigration::ArrivesSeamlessly(entity->GetObjectID())) {
SendPlayerReady(entity->GetObjectID(), zoneControlEntity ? zoneControlEntity->GetObjectID() : LWOOBJID_EMPTY, sysAddr);
}
entity->SetPlayerReadyForUpdates();
// Venture vision from equipped items was sent before the client's UI existed on a fresh login

View File

@@ -40,6 +40,10 @@ namespace {
// Give up on a migration after this long moving; whoever is left stays (or is saved when the world shuts down)
constexpr float MAX_MOVE_SECONDS = 150.0f;
constexpr float STATUS_INTERVAL = 1.0f;
// How long after it was sent a seamless arrival is expected (the reconnect takes a second or two)
constexpr float SEAMLESS_ARRIVAL_SECONDS = 30.0f;
// A client that arrived without reloading and hasn't sent PlayerLoaded after this gets it run for them
constexpr float SEAMLESS_LOADED_FALLBACK_SECONDS = 5.0f;
// Carried state for a player who never arrives
constexpr float CARRIED_EXPIRY_SECONDS = 300.0f;
@@ -185,10 +189,13 @@ namespace {
MasterPackets::SendToMaster(carried);
}
// Seamless: take every object we sent away first. The client deletes them but keeps its own player object when
// that ghost goes (LWOGhostComponent::OnGhostReceiveDestruction), and the target's construction of the
// player is adopted by it. Same ordered channel as the transfer, so these arrive before it.
if (order.seamless) Game::entityManager->DestructAllEntities(sysAddr);
// Seamless: take every object we sent away first, except their own player. The client keeps its player object
// either way (LWOGhostComponent::OnGhostReceiveDestruction, 0x00c99410), but losing its last ghost puts it out
// of scope: it fades out, and fades back in with the login effect when the target constructs it
// (LWOBaseRenderComponent::OnEnterScope, 0x00be2150). With its old ghost left alone, the target's
// construction just takes over (LwoClientGhostManager::OnReceiveConstruction, 0x00b31c30). Same ordered
// channel as the transfer, so these arrive before it.
if (order.seamless) Game::entityManager->DestructAllEntities(sysAddr, playerId);
ClientPackets::TransferToWorld transfer;
transfer.serverIP = LUString(order.targetIp);
@@ -391,7 +398,14 @@ void WorldMigration::OnDisconnected(const SystemAddress& sysAddr) {
bool WorldMigration::ArrivesSeamlessly(LWOOBJID characterId) {
const auto it = g_Carried.find(characterId);
return it != g_Carried.end() && it->second.first.seamless;
// Only for a while: a client that logs in again later has no scene and needs LOAD_STATIC_ZONE
return it != g_Carried.end() && it->second.first.seamless && it->second.second <= SEAMLESS_ARRIVAL_SECONDS;
}
void WorldMigration::KeepClientPlayer(Entity* player, const bool keep) {
if (!player || (keep && !ArrivesSeamlessly(player->GetObjectID()))) return;
if (auto* physics = player->GetComponent<ControllablePhysicsComponent>()) physics->SetKeepClientPosition(keep);
if (auto* characterComponent = player->GetComponent<CharacterComponent>()) characterComponent->SetKeepClientScene(keep);
}
void WorldMigration::OnSeamlessArrival(Entity* player) {
@@ -399,10 +413,11 @@ void WorldMigration::OnSeamlessArrival(Entity* player) {
const auto playerId = player->GetObjectID();
const auto sysAddr = player->GetSystemAddress();
LOG("Player %llu arrived without reloading the zone", playerId);
// The client already finished loading on the old instance and won't send PlayerLoaded again: do what it would
// trigger, once the constructions have had a moment to arrive
player->AddCallbackTimer(1.0f, [playerId, sysAddr]() {
if (!Game::entityManager->GetEntity(playerId)) return;
// The client sends PlayerLoaded itself once its character got the construction
// (LWOCharacterComponent::PostCharacterLoaded, 0x00c71660). Should that not come, do what it would trigger.
player->AddCallbackTimer(SEAMLESS_LOADED_FALLBACK_SECONDS, [playerId, sysAddr]() {
if (!g_Carried.contains(playerId) || !Game::entityManager->GetEntity(playerId)) return;
LOG("Player %llu sent no PlayerLoaded after arriving without a reload, running it for them", playerId);
RakNet::BitStream empty;
GameMessageHandler::HandleMessage(empty, sysAddr, playerId, MessageType::Game::PLAYER_LOADED);
});

View File

@@ -51,7 +51,12 @@ namespace WorldMigration {
// not be sent LOAD_STATIC_ZONE (that tears the scene down); load it at once instead
bool ArrivesSeamlessly(LWOOBJID characterId);
// Its player entity was created and constructed: run what the client's PlayerLoaded would have
// While `keep` is set, constructions of a seamlessly arriving player leave out what would reset its client's own
// player: the position (the client stands where it is) and the world transition (no fade from white). Set only
// around the construction that goes to the player's own client; does nothing for other players.
void KeepClientPlayer(Entity* player, bool keep);
// Its player entity was created and constructed: the client sends PlayerLoaded itself; a fallback runs it if not
void OnSeamlessArrival(Entity* player);
// MIGRATE_STATUS from master: tell the GM who asked, if they are here

View File

@@ -1213,7 +1213,11 @@ void LoadPlayer(const SystemAddress& sysAddr) {
}
}
// Their own client's construction of the player: one that kept its player (seamless instance move) is not
// to be put back where it was saved or shown a world transition
WorldMigration::KeepClientPlayer(player, true);
Game::entityManager->ConstructAllEntities(sysAddr);
WorldMigration::KeepClientPlayer(player, false);
characterComponent->RocketUnEquip(player);