Fix refresh login menu & login menu error messages

This commit is contained in:
2025-06-15 15:44:46 -07:00
parent 3ce13f5b1f
commit c5e51b53dd
2 changed files with 64 additions and 86 deletions

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}