Net: reconnect to the new core on GC_WARP

RecvWarpPacket now matches Windows: DirectEnter for the selected slot
(warp flavour, SetNewLoadingPhase) and Connect(lAddr, wPort) through
LoginClient::warp, discarding what is left on the old socket.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-13 13:20:47 +09:00
co-authored by Claude Opus 5.5
parent ce6d457808
commit 189da4c269
8 changed files with 63 additions and 11 deletions
+15 -1
View File
@@ -1412,7 +1412,12 @@ void pump_python_net() {
} else if(event.type == LoginClient::EventType::DirectEnterReady) callback(handler, "SetLoadingPhase");
else if(event.type == LoginClient::EventType::Loading) {
PythonNetworkStream::Instance().SetPhase(PHASE_LOADING);
callback(handler,"SetLoadingPhase");
// SetSelectPhase under DirectEnter: ENABLE_NEW_LOADING picks SetNewLoadingPhase for a warp.
callback(handler,client.is_warp()?"SetNewLoadingPhase":"SetLoadingPhase");
}
else if(client.is_direct_enter() && event.connection_failure) {
// OnConnectFailure under DirectEnter: ClosePhase -> handler.SetLoginPhase.
client.cancel();PythonNetworkStream::Instance().ResetConnection();callback(handler,"SetLoginPhase");
}
else {
auto* target = account_handler ? account_handler : phases[1];
@@ -1422,6 +1427,15 @@ void pump_python_net() {
auto& stream=PythonNetworkStream::Instance();
stream.PushRecvData(client.take_game_input(stream.RecvBufferSpace()));
stream.ProcessRecvData();
uint32_t warpAddress=0;uint16_t warpPort=0;
if(stream.TakeWarpRequest(warpAddress,warpPort) && client.status()==LoginClient::Status::Loading) {
// RecvWarpPacket: __DirectEnterMode_Set(selected slot, true) + Connect. Leaving the game phase
// (__LeaveGamePhase) and SetLoadingPhase clear actors, items and the player before the new map.
try { client.warp(warpAddress,warpPort); }
catch(const std::exception& e) { SDL_Log("Warp failed: %s",e.what());client.cancel();stream.ResetConnection();callback(handler,"SetLoginPhase");return; }
stream.ResetConnection();
return;
}
if(client.status()==LoginClient::Status::Loading) {
for(auto& [packet,sequence]:stream.PopSendPacketsWithSequence()) client.send_game_packet(std::move(packet),sequence);
}