From 8858ccc17f5e4b7ba716ca22e4c0870ff59132f7 Mon Sep 17 00:00:00 2001 From: Chomp Date: Thu, 3 Jul 2025 10:06:15 +0100 Subject: [PATCH] Improved handling of edge-case MongoId values --- .../SPTarkov.Server.Core/Models/Common/MongoId.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs b/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs index b547fedb..5ce6ba3b 100644 --- a/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs +++ b/Libraries/SPTarkov.Server.Core/Models/Common/MongoId.cs @@ -1,15 +1,14 @@ using System.Runtime.CompilerServices; -using System.Text.RegularExpressions; using SPTarkov.Server.Core.Extensions; namespace SPTarkov.Server.Core.Models.Common; -public readonly partial struct MongoId : IEquatable +public readonly struct MongoId : IEquatable { private readonly string _stringId; public MongoId( - string id, + string? id, // TODO: TEMPORARY REMOVE ME WHEN DONE!!!! [CallerFilePath] string callerFilePath = "", [CallerMemberName] string methodName = "", @@ -17,9 +16,11 @@ public readonly partial struct MongoId : IEquatable ) { // This is temporary, otherwise item buying is broken as when LINQ searches for string id's it's possible null is passed - if (id == null) + if (string.IsNullOrEmpty(id)) { - id = string.Empty; + _stringId = string.Intern("000000000000000000000000"); + + return; } if (id.Length != 24) @@ -92,7 +93,7 @@ public readonly partial struct MongoId : IEquatable { if (other is null) { - return other == this; + return this == null; } return other.Equals(ToString(), StringComparison.InvariantCultureIgnoreCase);