From c5e51b53ddb9c7614ac17f42b5aa5ce64eda9e8e Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sun, 15 Jun 2025 15:44:46 -0700 Subject: [PATCH] Fix refresh login menu & login menu error messages --- Assets/Scripts/AccountMenu/AccountLogin.cs | 91 +++++++++---------- .../AccountMenu/AccountRefreshLogin.cs | 59 +++++------- 2 files changed, 64 insertions(+), 86 deletions(-) diff --git a/Assets/Scripts/AccountMenu/AccountLogin.cs b/Assets/Scripts/AccountMenu/AccountLogin.cs index 522a7a8..4e7fe82 100644 --- a/Assets/Scripts/AccountMenu/AccountLogin.cs +++ b/Assets/Scripts/AccountMenu/AccountLogin.cs @@ -43,59 +43,52 @@ public class AccountLogin : MonoBehaviour return; } string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY); - if (response != "-1") + if (response == "-999") { - if (response == "-999") - { - AccountHandler.UpdateStatusText(loginPanelStatusText, "Server error while fetching data", Color.red); - return; - } - else if (response == "-998") - { - AccountHandler.UpdateStatusText(loginPanelStatusText, "Client version too outdated to access servers", Color.red); - return; - } - else if (response == "-997") - { - AccountHandler.UpdateStatusText(loginPanelStatusText, "Encryption/decryption issues", Color.red); - return; - } - else if (response == "-2") - { - AccountHandler.UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red); - } - else if (response.Split(":")[0] == "1") - { - string[] array = response.Split(':'); - string session = array[1]; - string userName = array[2]; - int userId = int.Parse(array[3]); - BigInteger highScore = BigInteger.Parse(array[4]); - int iconId = int.Parse(array[5]); - int overlayId = int.Parse(array[6]); - PlayerPrefs.SetString("gameSession", session); - PlayerPrefs.SetString("userName", userName); - PlayerPrefs.SetInt("userId", userId); - PlayerPrefs.SetString("HighScoreV2", highScore.ToString()); - PlayerPrefs.SetInt("icon", iconId); - PlayerPrefs.SetInt("overlay", overlayId); - PlayerPrefs.SetString("TotalNormalBerries", array[7]); - PlayerPrefs.SetString("TotalPoisonBerries", array[8]); - PlayerPrefs.SetString("TotalSlowBerries", array[9]); - PlayerPrefs.SetString("TotalUltraBerries", array[10]); - PlayerPrefs.SetString("TotalSpeedyBerries", array[11]); - PlayerPrefs.SetString("TotalAttempts", array[12]); - AccountHandler.instance.SwitchPanel(0); - AccountHandler.UpdateStatusText(loginPanelStatusText, "", Color.red); - } - else - { - AccountHandler.UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red); - } + AccountHandler.UpdateStatusText(loginPanelStatusText, "Server error while fetching data", Color.red); + return; + } + else if (response == "-998") + { + AccountHandler.UpdateStatusText(loginPanelStatusText, "Client version too outdated to access servers", Color.red); + return; + } + else if (response == "-997") + { + AccountHandler.UpdateStatusText(loginPanelStatusText, "Encryption/decryption issues", Color.red); + return; + } + else if (response == "-1") + { + AccountHandler.UpdateStatusText(loginPanelStatusText, "Incorrect username or password", Color.red); + } + else if (response.Split(":")[0] == "1") + { + string[] array = response.Split(':'); + string session = array[1]; + string userName = array[2]; + int userId = int.Parse(array[3]); + BigInteger highScore = BigInteger.Parse(array[4]); + int iconId = int.Parse(array[5]); + int overlayId = int.Parse(array[6]); + PlayerPrefs.SetString("gameSession", session); + PlayerPrefs.SetString("userName", userName); + PlayerPrefs.SetInt("userId", userId); + PlayerPrefs.SetString("HighScoreV2", highScore.ToString()); + PlayerPrefs.SetInt("icon", iconId); + PlayerPrefs.SetInt("overlay", overlayId); + PlayerPrefs.SetString("TotalNormalBerries", array[7]); + PlayerPrefs.SetString("TotalPoisonBerries", array[8]); + PlayerPrefs.SetString("TotalSlowBerries", array[9]); + PlayerPrefs.SetString("TotalUltraBerries", array[10]); + PlayerPrefs.SetString("TotalSpeedyBerries", array[11]); + PlayerPrefs.SetString("TotalAttempts", array[12]); + AccountHandler.instance.SwitchPanel(0); + AccountHandler.UpdateStatusText(loginPanelStatusText, "", Color.red); } else { - AccountHandler.UpdateStatusText(loginPanelStatusText, "Internal login server error", Color.red); + AccountHandler.UpdateStatusText(loginPanelStatusText, "Unknown server response", Color.red); } } } diff --git a/Assets/Scripts/AccountMenu/AccountRefreshLogin.cs b/Assets/Scripts/AccountMenu/AccountRefreshLogin.cs index e4e462c..5db754c 100644 --- a/Assets/Scripts/AccountMenu/AccountRefreshLogin.cs +++ b/Assets/Scripts/AccountMenu/AccountRefreshLogin.cs @@ -40,47 +40,32 @@ public class AccountRefreshLogin : MonoBehaviour return; } string response = SensitiveInfo.Decrypt(request.downloadHandler.text, SensitiveInfo.SERVER_RECEIVE_TRANSFER_KEY); - if (response != "-1") + if (response == "-999") { - if (response == "-999") - { - AccountHandler.UpdateStatusText(refreshLoginStatusText, "Server error while fetching data", Color.red); - return; - } - else if (response == "-998") - { - AccountHandler.UpdateStatusText(refreshLoginStatusText, "Client version too outdated to access servers", Color.red); - return; - } - else if (response == "-997") - { - AccountHandler.UpdateStatusText(refreshLoginStatusText, "Encryption/decryption issues", Color.red); - return; - } - else if (response == "-2") - { - AccountHandler.UpdateStatusText(refreshLoginStatusText, "Incorrect username or password", Color.red); - } - else if (response.Split(":")[0] == "1") - { - string[] array = response.Split(':'); - string session = array[1]; - string userName = array[2]; - int userId = int.Parse(array[3]); - PlayerPrefs.SetString("gameSession", session); - PlayerPrefs.SetString("userName", userName); - PlayerPrefs.SetInt("userId", userId); - AccountHandler.instance.SwitchPanel(0); - AccountHandler.UpdateStatusText(refreshLoginStatusText, "", Color.red); - } - else - { - AccountHandler.UpdateStatusText(refreshLoginStatusText, "Unknown server response", Color.red); - } + AccountHandler.UpdateStatusText(refreshLoginStatusText, "Server error while fetching data", Color.red); + return; + } + else if (response == "-998") + { + AccountHandler.UpdateStatusText(refreshLoginStatusText, "Client version too outdated to access servers", Color.red); + return; + } + else if (response == "-997") + { + AccountHandler.UpdateStatusText(refreshLoginStatusText, "Encryption/decryption issues", Color.red); + return; + } + else if (response == "-1") + { + AccountHandler.UpdateStatusText(refreshLoginStatusText, "Incorrect username or password", Color.red); + } + else if (response == "1") + { + AccountHandler.instance.SwitchPanel(0); } else { - AccountHandler.UpdateStatusText(refreshLoginStatusText, "Internal login server error", Color.red); + AccountHandler.UpdateStatusText(refreshLoginStatusText, "Unknown server response", Color.red); } } }