From 0df0d953630b0ffa3deb6f16bd50e64f6eb7aaf5 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 23 Aug 2025 21:02:24 +0100 Subject: [PATCH] First pass at rest area hideout changes --- .../Callbacks/InventoryCallbacks.cs | 10 +++++++++ .../Eft/Inventory/SaveDialogueStateRequest.cs | 21 +++++++++++++++++++ .../Models/Enums/ItemEventActions.cs | 3 +-- .../ItemEvents/InventoryItemEventRouter.cs | 4 ++++ .../Services/ProfileFixerService.cs | 17 ++++++++++++++- .../BaseInteractionRequestDataConverter.cs | 2 ++ 6 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 Libraries/SPTarkov.Server.Core/Models/Eft/Inventory/SaveDialogueStateRequest.cs diff --git a/Libraries/SPTarkov.Server.Core/Callbacks/InventoryCallbacks.cs b/Libraries/SPTarkov.Server.Core/Callbacks/InventoryCallbacks.cs index 215f5a30..18f1975c 100644 --- a/Libraries/SPTarkov.Server.Core/Callbacks/InventoryCallbacks.cs +++ b/Libraries/SPTarkov.Server.Core/Callbacks/InventoryCallbacks.cs @@ -371,4 +371,14 @@ public class InventoryCallbacks(InventoryController inventoryController, QuestCo inventoryController.PinOrLock(pmcData, info, sessionID, output); return output; } + + public ItemEventRouterResponse SaveDialogueState( + PmcData pmcData, + SaveDialogueStateRequest request, + MongoId sessionId, + ItemEventRouterResponse output + ) + { + throw new NotImplementedException(); + } } diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Inventory/SaveDialogueStateRequest.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Inventory/SaveDialogueStateRequest.cs new file mode 100644 index 00000000..f1fe7034 --- /dev/null +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Inventory/SaveDialogueStateRequest.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace SPTarkov.Server.Core.Models.Eft.Inventory; + +public record SaveDialogueStateRequest : InventoryBaseActionRequestData +{ + [JsonPropertyName("nodePathTraveled")] + public List NodePathTraveled { get; set; } +} + +public class NodePathTraveled +{ + [JsonPropertyName("traderId")] + public string TraderId { get; set; } + + [JsonPropertyName("dialogueId")] + public string DialogueId { get; set; } + + [JsonPropertyName("nodeId")] + public string NodeId { get; set; } +} diff --git a/Libraries/SPTarkov.Server.Core/Models/Enums/ItemEventActions.cs b/Libraries/SPTarkov.Server.Core/Models/Enums/ItemEventActions.cs index 80161d2f..9ba14dd9 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Enums/ItemEventActions.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Enums/ItemEventActions.cs @@ -1,5 +1,3 @@ -using System.Text.Json.Serialization; - namespace SPTarkov.Server.Core.Models.Enums; public record ItemEventActions @@ -58,4 +56,5 @@ public record ItemEventActions public const string EAT = "Eat"; public const string CUSTOMIZATION_SET = "CustomizationSet"; public const string CUSTOMIZATION_BUY = "CustomizationBuy"; + public const string SAVE_DIALOGUE_STATE = "SaveDialogueState"; } diff --git a/Libraries/SPTarkov.Server.Core/Routers/ItemEvents/InventoryItemEventRouter.cs b/Libraries/SPTarkov.Server.Core/Routers/ItemEvents/InventoryItemEventRouter.cs index c9277462..2d3a3d39 100644 --- a/Libraries/SPTarkov.Server.Core/Routers/ItemEvents/InventoryItemEventRouter.cs +++ b/Libraries/SPTarkov.Server.Core/Routers/ItemEvents/InventoryItemEventRouter.cs @@ -147,6 +147,10 @@ public class InventoryItemEventRouter(InventoryCallbacks inventoryCallbacks, Hid return new ValueTask( inventoryCallbacks.PinOrLock(pmcData, body as PinOrLockItemRequest, sessionID, output) ); + case ItemEventActions.SAVE_DIALOGUE_STATE: + return new ValueTask( + inventoryCallbacks.SaveDialogueState(pmcData, body as SaveDialogueStateRequest, sessionID, output) + ); default: throw new Exception($"InventoryItemEventRouter being used when it cant handle route {url}"); } diff --git a/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs b/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs index 2dc90d29..fe519297 100644 --- a/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs @@ -1,6 +1,5 @@ using System.Text.RegularExpressions; using SPTarkov.DI.Annotations; -using SPTarkov.Server.Core.Exceptions; using SPTarkov.Server.Core.Extensions; using SPTarkov.Server.Core.Helpers; using SPTarkov.Server.Core.Models.Common; @@ -421,6 +420,22 @@ public class ProfileFixerService( } } + var restArea = pmcProfile.Hideout.Areas.FirstOrDefault(area => area.Type == HideoutAreas.RestSpace); + if (restArea is not null) + { + var slots = restArea.Slots.Count; + + if (slots < 1) + { + if (logger.IsLogEnabled(LogLevel.Debug)) + { + logger.Debug("Updating restArea slots to a size of 1"); + } + + AddEmptyObjectsToHideoutAreaSlots(HideoutAreas.RestSpace, 1, pmcProfile); + } + } + var waterCollSlots = pmcProfile.Hideout.Areas.FirstOrDefault(x => x.Type == HideoutAreas.WaterCollector)?.Slots?.Count; var extraWaterCollSlots = globals.Configuration.SkillsSettings.HideoutManagement.EliteSlots.WaterCollector.Slots; diff --git a/Libraries/SPTarkov.Server.Core/Utils/Json/Converters/BaseInteractionRequestDataConverter.cs b/Libraries/SPTarkov.Server.Core/Utils/Json/Converters/BaseInteractionRequestDataConverter.cs index f96f6e59..292962c2 100644 --- a/Libraries/SPTarkov.Server.Core/Utils/Json/Converters/BaseInteractionRequestDataConverter.cs +++ b/Libraries/SPTarkov.Server.Core/Utils/Json/Converters/BaseInteractionRequestDataConverter.cs @@ -185,6 +185,8 @@ public class BaseInteractionRequestDataConverter : JsonConverter(jsonText, options); case ItemEventActions.PIN_LOCK: return JsonSerializer.Deserialize(jsonText, options); + case ItemEventActions.SAVE_DIALOGUE_STATE: + return JsonSerializer.Deserialize(jsonText, options); default: if (_modHandlers.TryGetValue(action, out var handler)) {