From 77ce596056fed58fd589a322c6ab19e8a48cdf56 Mon Sep 17 00:00:00 2001 From: Chomp Date: Wed, 2 Jul 2025 19:50:29 +0100 Subject: [PATCH] Added MongoId type to various places --- .../Controllers/LocationController.cs | 5 +++-- .../Controllers/ProfileController.cs | 16 ---------------- .../Models/Eft/Common/LocationBase.cs | 2 +- .../Tables/LocationsGenerateAllResponse.cs | 3 ++- .../Models/Eft/Prestige/ObtainPrestigeRequest.cs | 3 ++- .../Models/Eft/Profile/SptProfile.cs | 2 +- .../Services/CreateProfileService.cs | 1 - 7 files changed, 9 insertions(+), 23 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/LocationController.cs b/Libraries/SPTarkov.Server.Core/Controllers/LocationController.cs index b8129b91..e9591011 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/LocationController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/LocationController.cs @@ -1,4 +1,5 @@ using SPTarkov.DI.Annotations; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Common; using SPTarkov.Server.Core.Models.Eft.Common.Tables; using SPTarkov.Server.Core.Models.Eft.Location; @@ -29,7 +30,7 @@ public class LocationController( var maps = locationsFromDb.GetDictionary(); // keyed by _id location property - var locationResult = new Dictionary(); + var locationResult = new Dictionary(); foreach (var (locationId, location) in maps) { @@ -47,7 +48,7 @@ public class LocationController( // Clear out loot array mapBase.Loot = []; // Add map base data to dictionary - locationResult.Add(mapBase.IdField!, mapBase); + locationResult.Add(mapBase.IdField, mapBase); } return new LocationsGenerateAllResponse diff --git a/Libraries/SPTarkov.Server.Core/Controllers/ProfileController.cs b/Libraries/SPTarkov.Server.Core/Controllers/ProfileController.cs index 17000d13..9973eeab 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/ProfileController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/ProfileController.cs @@ -9,33 +9,17 @@ using SPTarkov.Server.Core.Models.Eft.Profile; using SPTarkov.Server.Core.Models.Enums; using SPTarkov.Server.Core.Models.Spt.Launcher; using SPTarkov.Server.Core.Models.Utils; -using SPTarkov.Server.Core.Routers; using SPTarkov.Server.Core.Servers; using SPTarkov.Server.Core.Services; -using SPTarkov.Server.Core.Utils; -using SPTarkov.Server.Core.Utils.Cloners; namespace SPTarkov.Server.Core.Controllers; [Injectable] public class ProfileController( ISptLogger _logger, - HashUtil _hashUtil, - ICloner _cloner, - TimeUtil _timeUtil, SaveServer _saveServer, - DatabaseService _databaseService, - ItemHelper _itemHelper, - ProfileFixerService _profileFixerService, - ServerLocalisationService _serverLocalisationService, CreateProfileService _createProfileService, - SeasonalEventService _seasonalEventService, PlayerScavGenerator _playerScavGenerator, - EventOutputHolder _eventOutputHolder, - TraderHelper _traderHelper, - DialogueHelper _dialogueHelper, - QuestHelper _questHelper, - QuestRewardHelper _questRewardHelper, ProfileHelper _profileHelper ) { diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/LocationBase.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/LocationBase.cs index 7eb76b40..83601624 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/LocationBase.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/LocationBase.cs @@ -291,7 +291,7 @@ public record LocationBase public long? UnixDateTime { get; set; } [JsonPropertyName("_Id")] - public string? IdField { get; set; } + public MongoId IdField { get; set; } [JsonPropertyName("doors")] public List? Doors { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/LocationsGenerateAllResponse.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/LocationsGenerateAllResponse.cs index 76d54d06..dfa7a09e 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/LocationsGenerateAllResponse.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Common/Tables/LocationsGenerateAllResponse.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; namespace SPTarkov.Server.Core.Models.Eft.Common.Tables; @@ -8,7 +9,7 @@ public record LocationsGenerateAllResponse public Dictionary? ExtensionData { get; set; } [JsonPropertyName("locations")] - public Dictionary Locations { get; set; } + public Dictionary Locations { get; set; } [JsonPropertyName("paths")] public List? Paths { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs index 1e9becc7..cfca4240 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Prestige/ObtainPrestigeRequest.cs @@ -1,4 +1,5 @@ using System.Text.Json.Serialization; +using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Utils; namespace SPTarkov.Server.Core.Models.Eft.Prestige; @@ -11,7 +12,7 @@ public record ObtainPrestigeRequest : IRequestData public Dictionary? ExtensionData { get; set; } [JsonPropertyName("id")] - public string Id { get; set; } + public MongoId Id { get; set; } [JsonPropertyName("location")] public Location Location { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Models/Eft/Profile/SptProfile.cs b/Libraries/SPTarkov.Server.Core/Models/Eft/Profile/SptProfile.cs index 05959682..dd8f9844 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Eft/Profile/SptProfile.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Eft/Profile/SptProfile.cs @@ -87,7 +87,7 @@ public record Info /// main profile id /// [JsonPropertyName("id")] - public string? ProfileId { get; set; } + public MongoId? ProfileId { get; set; } [JsonPropertyName("scavId")] public string? ScavengerId { get; set; } diff --git a/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs b/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs index 32d5bc53..8a86be45 100644 --- a/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/CreateProfileService.cs @@ -21,7 +21,6 @@ namespace SPTarkov.Server.Core.Services; public class CreateProfileService( ISptLogger _logger, TimeUtil _timeUtil, - HashUtil _hashUtil, DatabaseService _databaseService, ServerLocalisationService _serverLocalisationService, ProfileHelper _profileHelper,