Net: handle in-game GC_PHASE like the Windows client

PHASE_SELECT returns the connection to LoginSession (cached roster,
SelectReady, later LOGIN_SUCCESS refreshes), PHASE_CLOSE goes to the
login phase, LOADING clears the player, GAME refreshes the status and
DEAD no longer leaves the game phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-13 13:24:12 +09:00
co-authored by Claude Opus 5.5
parent 189da4c269
commit 40cac5cf52
9 changed files with 113 additions and 24 deletions
+30 -2
View File
@@ -88,7 +88,7 @@ void PythonNetworkStream::StartGame() {
}
void PythonNetworkStream::ResetConnection() {
m_recvBuffer.clear();m_unportedPackets.clear();m_unknownPacketQuit=false;m_isObserverMode=m_bMobileFlag=false;std::memset(m_lastPacket,0,sizeof(m_lastPacket));ClearSendQueue();m_startGameRequested=m_refreshInventory=m_refreshStatus=m_refreshSkill=m_refreshCharacter=m_refreshShopSearch=m_stopGamePhase=m_warpRequested=false;
m_recvBuffer.clear();m_unportedPackets.clear();m_unknownPacketQuit=false;m_isObserverMode=m_bMobileFlag=false;std::memset(m_lastPacket,0,sizeof(m_lastPacket));ClearSendQueue();m_startGameRequested=m_refreshInventory=m_refreshStatus=m_refreshSkill=m_refreshCharacter=m_refreshShopSearch=m_stopGamePhase=m_warpRequested=m_selectRequested=false;m_selectLeftover.clear();
m_refreshGuildInfo=m_refreshGuildBoard=m_refreshGuildMember=m_refreshGuildCombo=m_refreshGuildSkill=m_refreshGuildGrade=m_refreshMessenger=false;
m_guildID=0;
m_changeServerTime=m_changeClientTime=0;m_dungeonDestination={};
@@ -445,7 +445,35 @@ bool PythonNetworkStream::DispatchPortedGamePhasePacket(uint8_t header) {
bool PythonNetworkStream::RecvPhasePacket() {
TPacketGCPhase p;
if (!Read(sizeof(p), &p)) return false;
SetPhase(static_cast<EPhase>(p.phase));
switch(p.phase) {
case PHASE_CLOSE: // ClosePhase
inventory_callback(m_poHandler,"SetLoginPhase",nullptr);
break;
case PHASE_HANDSHAKE:
case PHASE_LOGIN:
// SetHandShakePhase/SetLoginPhase leave the game phase; the login transport owns these phases.
NetworkActorManager::Instance().Clear();
SetPhase(static_cast<EPhase>(p.phase));
break;
case PHASE_SELECT:
// SetSelectPhase leaves the game phase (__LeaveGamePhase). The select-phase packets that follow
// (LOGIN_SUCCESS, EMPIRE, PLAYER_CREATE/DELETE, CHANGE_NAME) belong to LoginSession, so the
// unprocessed bytes go back to the transport. __DownloadMark: guild marks are not ported.
m_selectRequested=true;
m_selectLeftover.assign(m_recvBuffer.begin(),m_recvBuffer.end());
m_recvBuffer.clear();m_stopGamePhase=true;
break;
case PHASE_LOADING: // SetLoadingPhase: CPythonPlayer::Clear
ResetPlayerState();
SetPhase(PHASE_LOADING);
break;
case PHASE_GAME: // SetGamePhase: __RefreshStatus
SetPhase(PHASE_GAME);
m_refreshStatus=true;
break;
case PHASE_DEAD: // no-op on Windows; m_strPhase stays "Game"
break;
}
return true;
}