Fix logout flow, reentry instead half logout because sdk only except that

This commit is contained in:
HungDK
2026-05-07 15:51:33 +07:00
parent 27b453b251
commit 925f2cf562
3 changed files with 46 additions and 14 deletions
@@ -830,11 +830,8 @@ namespace CSNetwork
// a_LogOutput(1, "CECGameSession::OnPrtcPlayerLogout, LogoutFlag=1 replaced by 2.");
// g_pGame->GetGameRun()->SetLogoutFlag(2);
// }
if (!IsConnected && EC_Game.GetGameRun().GetLogoutFlag() == 1)
{
// _logger.Log(LogType.Log, "CECGameSession::OnPrtcPlayerLogout, LogoutFlag=1 replaced by 2.");
EC_Game.GetGameRun().SetLogoutFlag(2);
}
// Keep half logout as role-select even if the server closes the socket.
// LoginScene will reconnect with saved credentials if needed.
}
/// <summary>Format parsed PLAYER_EQUIP_DETAIL with real game data: slot names and item names from element data.</summary>
@@ -264,8 +264,11 @@ namespace BrewMonster.Network
// Force the login UI to refresh to the correct entry state immediately.
ApplyLoginEntryToUI(entryTarget);
// now we have to logout from Tech3C SDK
Tech3CSDKWrapper.Instance.Logout();
if (entryTarget == LogoutFlowState.LoginEntryTarget.LoginUI)
{
// Account logout only; half logout keeps SDK credentials so LoginScene can reopen role select.
Tech3CSDKWrapper.Instance.Logout();
}
}
private static void ApplyLoginEntryToUI(LogoutFlowState.LoginEntryTarget entryTarget)
@@ -84,11 +84,8 @@ namespace BrewMonster.UI
_passwordInputField.text = PlayerPrefs.GetString("password", "");
#endif
// Default: login UI first, select-role hidden until login succeeds.
if (_selectCharacterScreen != null)
_selectCharacterScreen.gameObject.SetActive(false);
// ApplyLoginEntry(LogoutFlowState.ConsumeNextLoginEntry());
// Default is login UI, unless a logout flow asked us to return directly to role select.
ApplyLoginEntry(LogoutFlowState.ConsumeNextLoginEntry());
}
private AudioClip PickLoginBGM()
@@ -181,8 +178,43 @@ namespace BrewMonster.UI
await UnityGameSession.Login(username, password, OnLoginComplete);
}
// NOTE: Previously had an ApplyLoginEntry helper that referenced LogoutFlowState.
// It was unused and caused build/lint issues on some platforms, so it's been removed.
public async void ApplyLoginEntry(LogoutFlowState.LoginEntryTarget entryTarget)
{
if (entryTarget != LogoutFlowState.LoginEntryTarget.SelectRole)
{
if (_selectCharacterScreen != null)
_selectCharacterScreen.gameObject.SetActive(false);
_loginInProgress = false;
if (_loginButton != null)
_loginButton.interactable = true;
return;
}
if (_selectCharacterScreen != null)
_selectCharacterScreen.gameObject.SetActive(true);
_loginInProgress = true;
if (_loginButton != null)
_loginButton.interactable = false;
var session = UnityGameSession.Instance?.GameSession;
if (session != null && session.IsConnected)
{
UnityGameSession.GetRoleListAsync(OnGetRoleListComplete);
return;
}
string username = PlayerPrefs.GetString("username", "");
string password = PlayerPrefs.GetString("password", "");
if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
{
await BeginGameLoginAsync(username, password);
return;
}
OnExitCharacterSelect();
}
/// <summary>
/// Callback when the login is complete.