diff --git a/pub-linux-x64/ProspectServerSwitcher b/pub-linux-x64/ProspectServerSwitcher new file mode 100755 index 0000000..0c48318 Binary files /dev/null and b/pub-linux-x64/ProspectServerSwitcher differ diff --git a/pub-linux-x64/ProspectServerSwitcher.pdb b/pub-linux-x64/ProspectServerSwitcher.pdb new file mode 100644 index 0000000..cf4e10b Binary files /dev/null and b/pub-linux-x64/ProspectServerSwitcher.pdb differ diff --git a/pub-win-x64/ProspectServerSwitcher.exe b/pub-win-x64/ProspectServerSwitcher.exe new file mode 100755 index 0000000..c771906 Binary files /dev/null and b/pub-win-x64/ProspectServerSwitcher.exe differ diff --git a/pub-win-x64/ProspectServerSwitcher.pdb b/pub-win-x64/ProspectServerSwitcher.pdb new file mode 100644 index 0000000..860f239 Binary files /dev/null and b/pub-win-x64/ProspectServerSwitcher.pdb differ diff --git a/src/Prospect.Server.Api/Controllers/ClientController.cs b/src/Prospect.Server.Api/Controllers/ClientController.cs index 3c9ca10..ff653a4 100644 --- a/src/Prospect.Server.Api/Controllers/ClientController.cs +++ b/src/Prospect.Server.Api/Controllers/ClientController.cs @@ -274,8 +274,12 @@ public class ClientController : Controller [HttpPost("UpdateUserTitleDisplayName")] [Produces(MediaTypeNames.Application.Json)] [Authorize(AuthenticationSchemes = UserAuthenticationOptions.DefaultScheme)] - public IActionResult UpdateUserTitleDisplayName(FUpdateUserTitleDisplayNameRequest request) + public async Task UpdateUserTitleDisplayName(FUpdateUserTitleDisplayNameRequest request) { + // Persist the rename, otherwise it is echoed back but lost on next login. + var userId = User.FindAuthUserId(); + await _userService.UpdateDisplayNameAsync(userId, request.DisplayName); + return Ok(new ClientResponse { Code = 200, diff --git a/src/Prospect.Server.Api/Services/CloudScript/Functions/ClaimActiveContract.cs b/src/Prospect.Server.Api/Services/CloudScript/Functions/ClaimActiveContract.cs index 5aa031e..5d6955c 100644 --- a/src/Prospect.Server.Api/Services/CloudScript/Functions/ClaimActiveContract.cs +++ b/src/Prospect.Server.Api/Services/CloudScript/Functions/ClaimActiveContract.cs @@ -81,9 +81,16 @@ public class ClaimActiveContract : ICloudScriptFunction{"ContractsActive", "ContractsOneTimeCompleted", "Balance", "Inventory", factionKey, "JobBoardsData" } + new List{"ContractsActive", "ContractsOneTimeCompleted", "Balance", "Inventory", factionKey, "JobBoardsData", seasonXpKey } ); var factionProgression = JsonSerializer.Deserialize(userData[factionKey].Value); @@ -270,6 +277,12 @@ public class ClaimActiveContract : ICloudScriptFunction{ @@ -279,6 +292,7 @@ public class ClaimActiveContract : ICloudScriptFunction { private readonly IHttpContextAccessor _httpContextAccessor; + private readonly UserDataService _userDataService; - public GetCraftingInProgressData(IHttpContextAccessor httpContextAccessor) + public GetCraftingInProgressData(IHttpContextAccessor httpContextAccessor, UserDataService userDataService) { _httpContextAccessor = httpContextAccessor; + _userDataService = userDataService; } - public Task ExecuteAsync(FYGetCraftingInProgressDataRequest request) + public async Task ExecuteAsync(FYGetCraftingInProgressDataRequest request) { var context = _httpContextAccessor.HttpContext; if (context == null) @@ -22,11 +26,20 @@ public class GetCraftingInProgressData : ICloudScriptFunction { "CraftingTimer__2022_05_12" }); + // Fully qualified: a different FYItemCurrentlyBeingCrafted also exists in this namespace. + var craft = JsonSerializer.Deserialize(userData["CraftingTimer__2022_05_12"].Value) + ?? new Models.Data.FYItemCurrentlyBeingCrafted(); + + return new FYGetCraftingInProgressDataResult { - UserId = context.User.FindAuthUserId(), + UserId = userId, Error = string.Empty, - ItemCurrentlyBeingCrafted = {}, - }); + ItemCurrentlyBeingCrafted = craft, + }; } -} \ No newline at end of file +} diff --git a/src/Prospect.Server.Api/Services/CloudScript/Functions/GetPlayerSets.cs b/src/Prospect.Server.Api/Services/CloudScript/Functions/GetPlayerSets.cs index 6b662b7..7e577ca 100644 --- a/src/Prospect.Server.Api/Services/CloudScript/Functions/GetPlayerSets.cs +++ b/src/Prospect.Server.Api/Services/CloudScript/Functions/GetPlayerSets.cs @@ -1,5 +1,7 @@ -using Prospect.Server.Api.Services.Auth.Extensions; +using System.Text.Json; +using Prospect.Server.Api.Services.Auth.Extensions; using Prospect.Server.Api.Services.CloudScript.Models; +using Prospect.Server.Api.Services.UserData; namespace Prospect.Server.Api.Services.CloudScript.Functions; @@ -7,43 +9,53 @@ namespace Prospect.Server.Api.Services.CloudScript.Functions; public class GetPlayerSets : ICloudScriptFunction { private readonly IHttpContextAccessor _httpContextAccessor; + private readonly UserDataService _userDataService; - public GetPlayerSets(IHttpContextAccessor httpContextAccessor) + public GetPlayerSets(IHttpContextAccessor httpContextAccessor, UserDataService userDataService) { _httpContextAccessor = httpContextAccessor; + _userDataService = userDataService; } - - public Task ExecuteAsync(FYGetPlayersSets request) + + public async Task ExecuteAsync(FYGetPlayersSets request) { var context = _httpContextAccessor.HttpContext; if (context == null) { - return Task.FromResult(null); + return null; } - - return Task.FromResult(new + + var userId = context.User.FindAuthUserId(); + + // Return the player's persisted loadout (written by CompleteInventoryUpdate / + // RequestUpdateStationInventory) instead of a blank set, so saved gear survives + // a menu reopen / relog. Same response shape as before, just populated. + var userData = await _userDataService.FindAsync(userId, userId, new List { "LOADOUT" }); + var loadout = JsonSerializer.Deserialize(userData["LOADOUT"].Value) ?? new LoadoutData(); + + return new { success = true, - entries = new [] + entries = new[] { new { setData = new { id = "", - userId = context.User.FindAuthUserId(), + userId, kit = "", - shield = "", - helmet = "", - weaponOne = "", - weaponTwo = "", - bag = "", - bagItemsAsJsonStr = "", - safeItemsAsJsonStr = "" + shield = loadout.Shield ?? "", + helmet = loadout.Helmet ?? "", + weaponOne = loadout.WeaponOne ?? "", + weaponTwo = loadout.WeaponTwo ?? "", + bag = loadout.Bag ?? "", + bagItemsAsJsonStr = loadout.BagItemsAsJsonStr ?? "", + safeItemsAsJsonStr = loadout.SafeItemsAsJsonStr ?? "" }, items = Array.Empty() } } - }); + }; } -} \ No newline at end of file +} diff --git a/src/Prospect.Server.Api/Services/Database/DbUserService.cs b/src/Prospect.Server.Api/Services/Database/DbUserService.cs index 206e58f..d951d80 100644 --- a/src/Prospect.Server.Api/Services/Database/DbUserService.cs +++ b/src/Prospect.Server.Api/Services/Database/DbUserService.cs @@ -24,6 +24,14 @@ public class DbUserService : BaseDbService return await Collection.Find(user => user.Id == id).FirstOrDefaultAsync(); } + // Persist a display-name change (UpdateUserTitleDisplayName). Without this the rename + // is echoed back to the client but lost on next login. + public async Task UpdateDisplayNameAsync(string id, string displayName) + { + var update = Builders.Update.Set(user => user.DisplayName, displayName); + await Collection.UpdateOneAsync(user => user.Id == id, update); + } + private async Task CreateAsync(PlayFabUserAuthType type, string key) { var user = new PlayFabUser