Fix save/load
This commit is contained in:
@@ -50,10 +50,9 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
loggedInLogoutButton.interactable = false;
|
||||
loggedInBackButton.interactable = false;
|
||||
WWWForm dataForm = new();
|
||||
dataForm.AddField("username", BazookaManager.Instance.GetAccountName());
|
||||
dataForm.AddField("token", BazookaManager.Instance.GetAccountSession());
|
||||
dataForm.AddField("saveData", Convert.ToBase64String(Encoding.UTF8.GetBytes(BazookaManager.Instance.saveFile.ToString(Formatting.None))));
|
||||
using UnityWebRequest request = UnityWebRequest.Post(SensitiveInfo.SERVER_DATABASE_PREFIX + "berrydash/saveAccount.php", dataForm);
|
||||
using UnityWebRequest request = UnityWebRequest.Post(Endpoints.ACCOUNT_SAVE_ENDPOINT, dataForm);
|
||||
request.SetRequestHeader("Authorization", BazookaManager.Instance.GetAccountSession());
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
@@ -117,10 +116,8 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
loggedInRefreshLoginButton.interactable = false;
|
||||
loggedInLogoutButton.interactable = false;
|
||||
loggedInBackButton.interactable = false;
|
||||
WWWForm dataForm = new();
|
||||
dataForm.AddField("token", BazookaManager.Instance.GetAccountSession());
|
||||
dataForm.AddField("username", BazookaManager.Instance.GetAccountName());
|
||||
using UnityWebRequest request = UnityWebRequest.Post(SensitiveInfo.SERVER_DATABASE_PREFIX + "berrydash/loadAccount.php", dataForm);
|
||||
using UnityWebRequest request = UnityWebRequest.Get(Endpoints.ACCOUNT_SAVE_ENDPOINT);
|
||||
request.SetRequestHeader("Authorization", BazookaManager.Instance.GetAccountSession());
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
@@ -137,26 +134,7 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
Tools.UpdateStatusText(loggedInText, "Failed to make HTTP request", Color.red);
|
||||
return;
|
||||
}
|
||||
string response = request.downloadHandler.text;
|
||||
if (response == "-999")
|
||||
{
|
||||
Tools.UpdateStatusText(loggedInText, "Server error while fetching data", Color.red);
|
||||
}
|
||||
else if (response == "-998")
|
||||
{
|
||||
Tools.UpdateStatusText(loggedInText, "Client version too outdated to access servers", Color.red);
|
||||
}
|
||||
else if (response == "-997")
|
||||
{
|
||||
Tools.UpdateStatusText(loggedInText, "Encryption/decryption issues", Color.red);
|
||||
}
|
||||
else if (response == "-996")
|
||||
{
|
||||
Tools.UpdateStatusText(loggedInText, "Can't send requests on self-built instance", Color.red);
|
||||
}
|
||||
else
|
||||
{
|
||||
var jsonResponse = JObject.Parse(response);
|
||||
var jsonResponse = JObject.Parse(request.downloadHandler.text);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
BazookaManager.Instance.saveFile = JObject.FromObject(jsonResponse["data"]);
|
||||
@@ -180,7 +158,6 @@ public class AccountLoggedIn : MonoBehaviour
|
||||
{
|
||||
Tools.UpdateStatusText(loggedInText, (string)jsonResponse["message"], Color.red);
|
||||
}
|
||||
}
|
||||
loggedInChangeUsernameButton.interactable = true;
|
||||
loggedInChangePasswordButton.interactable = true;
|
||||
loggedInSaveButton.interactable = true;
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
public class Endpoints
|
||||
{
|
||||
public static readonly string BASE_URL = "https://games.lncvrt.xyz/api";
|
||||
public static readonly string LEADERBOARDS_SCORE_ENDPOINT = BASE_URL + "/berrydash/leaderboards/score";
|
||||
public static readonly string LEADERBOARDS_BERRY_ENDPOINT = BASE_URL + "/berrydash/leaderboards/berry";
|
||||
public static readonly string LEADERBOARDS_COIN_ENDPOINT = BASE_URL + "/berrydash/leaderboards/coin";
|
||||
public static readonly string LEADERBOARDS_LEGACY_ENDPOINT = BASE_URL + "/berrydash/leaderboards/legacy";
|
||||
public static readonly string LEADERBOARDS_TOTAL_ENDPOINT = BASE_URL + "/berrydash/leaderboards/total";
|
||||
public static readonly string BASE_URL = "http://localhost:3342/api";
|
||||
public static readonly string LEADERBOARDS_ENDPOINT = BASE_URL + "/berrydash/leaderboards";
|
||||
public static readonly string LEADERBOARDS_SCORE_ENDPOINT = LEADERBOARDS_ENDPOINT + "/score";
|
||||
public static readonly string LEADERBOARDS_BERRY_ENDPOINT = LEADERBOARDS_ENDPOINT + "/berry";
|
||||
public static readonly string LEADERBOARDS_COIN_ENDPOINT = LEADERBOARDS_ENDPOINT + "/coin";
|
||||
public static readonly string LEADERBOARDS_LEGACY_ENDPOINT = LEADERBOARDS_ENDPOINT + "/legacy";
|
||||
public static readonly string LEADERBOARDS_TOTAL_ENDPOINT = LEADERBOARDS_ENDPOINT + "/total";
|
||||
public static readonly string PROFILE_ENDPOINT = BASE_URL + "/berrydash/profile";
|
||||
public static readonly string PROFILE_POSTS_ENDPOINT = BASE_URL + "/berrydash/profile/posts";
|
||||
public static readonly string PROFILE_POSTS_ENDPOINT = PROFILE_ENDPOINT + "/posts";
|
||||
public static readonly string ACCOUNT_ENDPOINT = BASE_URL + "/berrydash/account";
|
||||
public static readonly string ACCOUNT_SAVE_ENDPOINT = ACCOUNT_ENDPOINT + "/save";
|
||||
}
|
||||
Reference in New Issue
Block a user