From 39f97b76a02c413b4502f0e2fc5db0a7c55ffccb Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Tue, 14 Oct 2025 19:15:06 -0400 Subject: [PATCH 01/15] this does a thing apparently --- OpenDreamRuntime/Objects/Types/DreamList.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 7dc0e2e830..bce598ab56 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -178,9 +178,10 @@ public virtual void SetValue(DreamValue key, DreamValue value, bool allowGrowth _values[keyInteger - 1] = value; } } else { - if (!ContainsValue(key)) _values.Add(key); - _associativeValues ??= new Dictionary(1); + if (!_associativeValues.ContainsKey(key)) { + _values.Add(key); + } _associativeValues[key] = value; } From 3023737a8981ae8ac7b04f811193161071de571c Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 15 Oct 2025 04:55:53 -0400 Subject: [PATCH 02/15] Add a funky unit test --- Content.Tests/DMProject/Tests/List/ListIndexToKey.dm | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 Content.Tests/DMProject/Tests/List/ListIndexToKey.dm diff --git a/Content.Tests/DMProject/Tests/List/ListIndexToKey.dm b/Content.Tests/DMProject/Tests/List/ListIndexToKey.dm new file mode 100644 index 0000000000..9e5c82b350 --- /dev/null +++ b/Content.Tests/DMProject/Tests/List/ListIndexToKey.dm @@ -0,0 +1,6 @@ +/proc/RunTest() + var/list/A = list("thing") + ASSERT(A[1] == "thing") + + A["thing"] = 6 + ASSERT(A["thing"] == 6) \ No newline at end of file From fc4b631cb31645385fb3b0f65c238b6b98960c5d Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 15 Oct 2025 18:36:36 -0400 Subject: [PATCH 03/15] Update DreamList.cs --- OpenDreamRuntime/Objects/Types/DreamList.cs | 69 +++++++++++++++++++-- 1 file changed, 63 insertions(+), 6 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index bce598ab56..2c519d7bdb 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -18,6 +18,10 @@ public class DreamList : DreamObject, IDreamList { public virtual bool IsAssociative => _associativeValues is { Count: > 0 }; + /// + /// Looks up the key to find the index + /// + private readonly Dictionary reverseLookup = []; private readonly List _values; private Dictionary? _associativeValues; @@ -29,6 +33,12 @@ public DreamList(DreamObjectDefinition listDef, int size) : base(listDef) { if (size >= DreamManager.ListPoolThreshold && ListPool.TryPop(out var poppedValues)) { _values = poppedValues; _values.EnsureCapacity(size); + foreach (var value in poppedValues) { + if (!reverseLookup.TryAdd(value, 1)) { + reverseLookup[value] += 1; + } + } + } else { _values = new List(size); } @@ -39,6 +49,11 @@ public DreamList(DreamObjectDefinition listDef, int size) : base(listDef) { /// public DreamList(DreamObjectDefinition listDef, List values, Dictionary? associativeValues) : base(listDef) { _values = values; + foreach (var value in values) { + if (!reverseLookup.TryAdd(value, 1)) { + reverseLookup[value] += 1; + } + } _associativeValues = associativeValues; #if TOOLS @@ -172,16 +187,29 @@ public virtual DreamValue GetValue(DreamValue key) { public virtual void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { if (key.TryGetValueAsInteger(out int keyInteger)) { - if (allowGrowth && keyInteger == _values.Count + 1) { + var index = _values.Count + 1; + if (allowGrowth && keyInteger == index) { _values.Add(value); + + if (!reverseLookup.TryAdd(value, 1)) { + reverseLookup[value] += 1; + } } else { _values[keyInteger - 1] = value; + + if (!reverseLookup.TryAdd(value, 1)) { + reverseLookup[value] += 1; + } + } } else { - _associativeValues ??= new Dictionary(1); - if (!_associativeValues.ContainsKey(key)) { + if (!reverseLookup.TryAdd(key, 1)) { + reverseLookup[key] += 1; + } else { _values.Add(key); } + + _associativeValues ??= new Dictionary(1); _associativeValues[key] = value; } @@ -192,6 +220,12 @@ public virtual void RemoveValue(DreamValue value) { int valueIndex = _values.LastIndexOf(value); if (valueIndex != -1) { + if(reverseLookup.TryGetValue(value, out int element)) { + if (element - 1 <= 0) { + reverseLookup.Remove(value); + } + } + _associativeValues?.Remove(value); _values.RemoveAt(valueIndex); } @@ -200,12 +234,19 @@ public virtual void RemoveValue(DreamValue value) { } public virtual void AddValue(DreamValue value) { - _values.Add(value); + _values.Add(value); + if (!reverseLookup.TryAdd(value, 1)) { + reverseLookup[value] += 1; + } + UpdateTracyContentsMemory(); } //Does not include associations public virtual bool ContainsValue(DreamValue value) { + if(reverseLookup.ContainsKey(value)) { + return true; + } for (int i = 0; i < _values.Count; i++) { if (_values[i].Equals(value)) return true; @@ -236,14 +277,30 @@ public virtual void Cut(int start = 1, int end = 0) { _associativeValues.Remove(_values[i - 1]); } - if (end > start) - _values.RemoveRange(start - 1, end - start); + if (end > start) { + var index = start - 1; + var len = end - start; + var elements = _values.GetRange(index, len); + + foreach (var element in elements) { + var rlCache = reverseLookup[element] -= 1; + + if (rlCache <= 0) { + reverseLookup.Remove(element); + } + } + + _values.RemoveRange(index, len); + } UpdateTracyContentsMemory(); } public void Insert(int index, DreamValue value) { _values.Insert(index - 1, value); + if (!reverseLookup.TryAdd(value, 1)) { + reverseLookup[value] += 1; + } UpdateTracyContentsMemory(); } From b3d1d174affbddd2421efb7430d2093f31e03428 Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 15 Oct 2025 18:46:01 -0400 Subject: [PATCH 04/15] Update DreamList.cs --- OpenDreamRuntime/Objects/Types/DreamList.cs | 40 ++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 2c519d7bdb..94afebe4d1 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -21,7 +21,7 @@ public class DreamList : DreamObject, IDreamList { /// /// Looks up the key to find the index /// - private readonly Dictionary reverseLookup = []; + private readonly Dictionary _reverseLookup = []; private readonly List _values; private Dictionary? _associativeValues; @@ -34,8 +34,8 @@ public DreamList(DreamObjectDefinition listDef, int size) : base(listDef) { _values = poppedValues; _values.EnsureCapacity(size); foreach (var value in poppedValues) { - if (!reverseLookup.TryAdd(value, 1)) { - reverseLookup[value] += 1; + if (!_reverseLookup.TryAdd(value, 1)) { + _reverseLookup[value] += 1; } } @@ -50,8 +50,8 @@ public DreamList(DreamObjectDefinition listDef, int size) : base(listDef) { public DreamList(DreamObjectDefinition listDef, List values, Dictionary? associativeValues) : base(listDef) { _values = values; foreach (var value in values) { - if (!reverseLookup.TryAdd(value, 1)) { - reverseLookup[value] += 1; + if (!_reverseLookup.TryAdd(value, 1)) { + _reverseLookup[value] += 1; } } _associativeValues = associativeValues; @@ -191,20 +191,20 @@ public virtual void SetValue(DreamValue key, DreamValue value, bool allowGrowth if (allowGrowth && keyInteger == index) { _values.Add(value); - if (!reverseLookup.TryAdd(value, 1)) { - reverseLookup[value] += 1; + if (!_reverseLookup.TryAdd(value, 1)) { + _reverseLookup[value] += 1; } } else { _values[keyInteger - 1] = value; - if (!reverseLookup.TryAdd(value, 1)) { - reverseLookup[value] += 1; + if (!_reverseLookup.TryAdd(value, 1)) { + _reverseLookup[value] += 1; } } } else { - if (!reverseLookup.TryAdd(key, 1)) { - reverseLookup[key] += 1; + if (!_reverseLookup.TryAdd(key, 1)) { + _reverseLookup[key] += 1; } else { _values.Add(key); } @@ -220,9 +220,9 @@ public virtual void RemoveValue(DreamValue value) { int valueIndex = _values.LastIndexOf(value); if (valueIndex != -1) { - if(reverseLookup.TryGetValue(value, out int element)) { + if(_reverseLookup.TryGetValue(value, out int element)) { if (element - 1 <= 0) { - reverseLookup.Remove(value); + _reverseLookup.Remove(value); } } @@ -235,8 +235,8 @@ public virtual void RemoveValue(DreamValue value) { public virtual void AddValue(DreamValue value) { _values.Add(value); - if (!reverseLookup.TryAdd(value, 1)) { - reverseLookup[value] += 1; + if (!_reverseLookup.TryAdd(value, 1)) { + _reverseLookup[value] += 1; } UpdateTracyContentsMemory(); @@ -244,7 +244,7 @@ public virtual void AddValue(DreamValue value) { //Does not include associations public virtual bool ContainsValue(DreamValue value) { - if(reverseLookup.ContainsKey(value)) { + if(_reverseLookup.ContainsKey(value)) { return true; } for (int i = 0; i < _values.Count; i++) { @@ -283,10 +283,10 @@ public virtual void Cut(int start = 1, int end = 0) { var elements = _values.GetRange(index, len); foreach (var element in elements) { - var rlCache = reverseLookup[element] -= 1; + var rlCache = _reverseLookup[element] -= 1; if (rlCache <= 0) { - reverseLookup.Remove(element); + _reverseLookup.Remove(element); } } @@ -298,8 +298,8 @@ public virtual void Cut(int start = 1, int end = 0) { public void Insert(int index, DreamValue value) { _values.Insert(index - 1, value); - if (!reverseLookup.TryAdd(value, 1)) { - reverseLookup[value] += 1; + if (!_reverseLookup.TryAdd(value, 1)) { + _reverseLookup[value] += 1; } UpdateTracyContentsMemory(); } From 8fd84d51d8810808e7f2dc3f4c6cd716b094a021 Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 15 Oct 2025 19:50:23 -0400 Subject: [PATCH 05/15] bruh --- OpenDreamRuntime/Objects/Types/DreamList.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 94afebe4d1..446cb01b86 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -220,8 +220,9 @@ public virtual void RemoveValue(DreamValue value) { int valueIndex = _values.LastIndexOf(value); if (valueIndex != -1) { - if(_reverseLookup.TryGetValue(value, out int element)) { - if (element - 1 <= 0) { + if(_reverseLookup.ContainsKey(value)) { + var rLCount = _reverseLookup[value] -= 1; + if (rLCount <= 0) { _reverseLookup.Remove(value); } } From a3ea531af16de1ecf07acd1f97fa10031efa111f Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 15 Oct 2025 18:59:20 -0400 Subject: [PATCH 06/15] Enhance ListIndexToKey tests with additional assertions Added assertions to validate list behavior and contents. --- Content.Tests/DMProject/Tests/List/ListIndexToKey.dm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Content.Tests/DMProject/Tests/List/ListIndexToKey.dm b/Content.Tests/DMProject/Tests/List/ListIndexToKey.dm index 9e5c82b350..37ddbc713d 100644 --- a/Content.Tests/DMProject/Tests/List/ListIndexToKey.dm +++ b/Content.Tests/DMProject/Tests/List/ListIndexToKey.dm @@ -3,4 +3,11 @@ ASSERT(A[1] == "thing") A["thing"] = 6 - ASSERT(A["thing"] == 6) \ No newline at end of file + ASSERT(A["thing"] == 6) + + var/list/L = list() + for(var/i in 1 to 5) + L.Add("[i]") + L["[i]"] = "item [i]" + ASSERT(length(L) == 5) + ASSERT(L["3"] == "item 3") From 4a8674ec4c84eba0ff2aec5029d00c730b500077 Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Wed, 15 Oct 2025 20:25:47 -0400 Subject: [PATCH 07/15] Removes the very slow code --- OpenDreamRuntime/Objects/Types/DreamList.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 446cb01b86..0bc4709025 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -245,15 +245,7 @@ public virtual void AddValue(DreamValue value) { //Does not include associations public virtual bool ContainsValue(DreamValue value) { - if(_reverseLookup.ContainsKey(value)) { - return true; - } - for (int i = 0; i < _values.Count; i++) { - if (_values[i].Equals(value)) - return true; - } - - return false; + return _reverseLookup.ContainsKey(value); } public virtual bool ContainsKey(DreamValue value) { From 21adea3056aa3c536ddc473013527670e92c5268 Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Thu, 16 Oct 2025 17:25:34 -0400 Subject: [PATCH 08/15] Update DreamList.cs --- OpenDreamRuntime/Objects/Types/DreamList.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 0bc4709025..40a6fc98ad 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -195,6 +195,12 @@ public virtual void SetValue(DreamValue key, DreamValue value, bool allowGrowth _reverseLookup[value] += 1; } } else { + var oldValue = _values[keyInteger - 1]; + var rLCount = _reverseLookup[oldValue] -= 1; + if(rLCount <= 0) { + _reverseLookup.Remove(oldValue); + } + _values[keyInteger - 1] = value; if (!_reverseLookup.TryAdd(value, 1)) { From 859398e6e0f9182c2e26ec6f88390833150c479f Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Thu, 16 Oct 2025 17:54:50 -0400 Subject: [PATCH 09/15] Optimize FIndValue for values that don't exist --- OpenDreamRuntime/Objects/Types/DreamList.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 40a6fc98ad..b4c40d953d 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -261,6 +261,8 @@ public virtual bool ContainsKey(DreamValue value) { public virtual int FindValue(DreamValue value, int start = 1, int end = 0) { if (end == 0 || end > _values.Count) end = _values.Count + 1; + if(!ContainsValue(value)) return 0; + for (int i = start; i < end; i++) { if (_values[i - 1].Equals(value)) return i; } From cb4369211fd57ae3821f570b4378456fbc5de909 Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Sun, 19 Oct 2025 19:03:29 -0400 Subject: [PATCH 10/15] Small optimization --- OpenDreamRuntime/Objects/Types/DreamList.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index b4c40d953d..4ae5916107 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -223,17 +223,15 @@ public virtual void SetValue(DreamValue key, DreamValue value, bool allowGrowth } public virtual void RemoveValue(DreamValue value) { - int valueIndex = _values.LastIndexOf(value); - - if (valueIndex != -1) { - if(_reverseLookup.ContainsKey(value)) { - var rLCount = _reverseLookup[value] -= 1; - if (rLCount <= 0) { - _reverseLookup.Remove(value); - } + _associativeValues?.Remove(value); + if (_reverseLookup.ContainsKey(value)) { + var rLCount = _reverseLookup[value] -= 1; + if (rLCount <= 0) { + _reverseLookup.Remove(value); } + _reverseLookup[value] = rLCount; - _associativeValues?.Remove(value); + int valueIndex = _values.LastIndexOf(value); _values.RemoveAt(valueIndex); } From 43ea87b25ca511b7368ccdb308286ed36d993c6b Mon Sep 17 00:00:00 2001 From: Redmoogle Date: Mon, 20 Oct 2025 05:36:12 -0400 Subject: [PATCH 11/15] rev --- OpenDreamRuntime/Objects/Types/DreamList.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 4ae5916107..7a14f6c55b 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -223,15 +223,17 @@ public virtual void SetValue(DreamValue key, DreamValue value, bool allowGrowth } public virtual void RemoveValue(DreamValue value) { - _associativeValues?.Remove(value); - if (_reverseLookup.ContainsKey(value)) { - var rLCount = _reverseLookup[value] -= 1; - if (rLCount <= 0) { - _reverseLookup.Remove(value); + int valueIndex = _values.LastIndexOf(value); + + if (valueIndex != -1) { + if (_reverseLookup.ContainsKey(value)) { + var rLCount = _reverseLookup[value] -= 1; + if (rLCount <= 0) { + _reverseLookup.Remove(value); + } } - _reverseLookup[value] = rLCount; - int valueIndex = _values.LastIndexOf(value); + _associativeValues?.Remove(value); _values.RemoveAt(valueIndex); } From fee67087d2b887d2c446e340c22833794540c451 Mon Sep 17 00:00:00 2001 From: Ruzihm Date: Sat, 13 Dec 2025 13:25:07 -0500 Subject: [PATCH 12/15] small logic fix to dreamlist setvalue, and in dreamvalue just compare refvalue memory locationi f dealing with dreamobjects --- OpenDreamRuntime/DreamValue.cs | 2 +- OpenDreamRuntime/Objects/Types/DreamList.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/OpenDreamRuntime/DreamValue.cs b/OpenDreamRuntime/DreamValue.cs index 2c4deecd50..fcf1050aa0 100644 --- a/OpenDreamRuntime/DreamValue.cs +++ b/OpenDreamRuntime/DreamValue.cs @@ -459,7 +459,7 @@ public bool Equals(DreamValue other) { _refValue = null; if (other._refValue != null && Unsafe.As(other._refValue).Deleted) other._refValue = null; - break; + return _refValue == other._refValue; } } diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 7a14f6c55b..031080b2f4 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -209,9 +209,7 @@ public virtual void SetValue(DreamValue key, DreamValue value, bool allowGrowth } } else { - if (!_reverseLookup.TryAdd(key, 1)) { - _reverseLookup[key] += 1; - } else { + if (_reverseLookup.TryAdd(key, 1)) { _values.Add(key); } From 469a7b19e8218465a50bb04c8206f933c43f966f Mon Sep 17 00:00:00 2001 From: Ruzihm Date: Sun, 14 Dec 2025 15:37:43 -0500 Subject: [PATCH 13/15] Define append for alist, prevent dreamlist overrides from using backreference cache in classes where it isn't synchronized --- .../Objects/Types/DreamAssocList.cs | 12 +++ OpenDreamRuntime/Objects/Types/DreamList.cs | 100 ++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/OpenDreamRuntime/Objects/Types/DreamAssocList.cs b/OpenDreamRuntime/Objects/Types/DreamAssocList.cs index 8b84d4aa53..d59806c6b4 100644 --- a/OpenDreamRuntime/Objects/Types/DreamAssocList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamAssocList.cs @@ -119,4 +119,16 @@ public bool ContainsValue(DreamValue value) { return _values.ContainsKey(value); } + public override DreamValue OperatorAppend(DreamValue b) { + if (b.TryGetValueAsDreamList(out var bList)) { + foreach (var value in bList.EnumerateValues()) { + AddValue(value); // Always add the value + } + } else { + AddValue(b); + } + + return new(this); + } + } diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 031080b2f4..bf15b0906b 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -709,6 +709,16 @@ public override IEnumerable EnumerateValues() { yield return new(verb); } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { throw new Exception("Cannot set the values of a verbs list"); } @@ -773,6 +783,16 @@ public override IEnumerable EnumerateValues() { } } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { throw new Exception("Cannot set the values of a verbs list"); } @@ -847,6 +867,16 @@ public override IEnumerable EnumerateValues() { } } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void Cut(int start = 1, int end = 0) { _atomManager.UpdateAppearance(_owner, appearance => { var overlaysList = GetOverlaysList(appearance); @@ -964,6 +994,16 @@ public override IEnumerable EnumerateValues() { yield return new(visContent); } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void Cut(int start = 1, int end = 0) { int count = _visContents.Count + 1; if (end == 0 || end > count) end = count; @@ -1121,6 +1161,16 @@ public override IEnumerable EnumerateValues() { } } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { if (!value.TryGetValueAsDreamObject(out var filterObject) && !value.IsNull) throw new Exception($"Cannot set value of filter list to {value}"); @@ -1269,6 +1319,16 @@ public override IEnumerable EnumerateValues() { return _imageObjects; } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { throw new Exception("Cannot write to an index of a client images list"); } @@ -1332,6 +1392,16 @@ public override IEnumerable EnumerateValues() { return AtomManager.EnumerateAtoms().Select(atom => new DreamValue(atom)); } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { throw new Exception("Cannot set the value of world contents list"); } @@ -1375,6 +1445,16 @@ public override IEnumerable EnumerateValues() { yield return new(movable); } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { throw new Exception("Cannot set an index of turf contents list"); } @@ -1443,6 +1523,16 @@ public override IEnumerable EnumerateValues() { } } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { throw new Exception("Cannot set an index of area contents list"); } @@ -1594,6 +1684,16 @@ public override IEnumerable EnumerateValues() { yield return state.GetArguments()[i]; } + public override bool ContainsValue(DreamValue value) { + foreach (var containedVal in EnumerateValues()) { + if (value.Equals(containedVal)) { + return true; + } + } + + return false; + } + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { if (!key.TryGetValueAsInteger(out var index)) throw new Exception($"Invalid index into args list: {key}"); From 13bde8f68e2c183b26602a7becd1e19d02f8df4c Mon Sep 17 00:00:00 2001 From: Ruzihm Date: Sun, 14 Dec 2025 16:23:36 -0500 Subject: [PATCH 14/15] remove remnants of other test --- OpenDreamRuntime/DreamValue.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenDreamRuntime/DreamValue.cs b/OpenDreamRuntime/DreamValue.cs index fcf1050aa0..2c4deecd50 100644 --- a/OpenDreamRuntime/DreamValue.cs +++ b/OpenDreamRuntime/DreamValue.cs @@ -459,7 +459,7 @@ public bool Equals(DreamValue other) { _refValue = null; if (other._refValue != null && Unsafe.As(other._refValue).Deleted) other._refValue = null; - return _refValue == other._refValue; + break; } } From 1c77ed1d5de9e0a19ef363780ac5216b998a61ac Mon Sep 17 00:00:00 2001 From: Ruzihm Date: Sun, 14 Dec 2025 16:28:13 -0500 Subject: [PATCH 15/15] remove misleading comment --- OpenDreamRuntime/Objects/Types/DreamAssocList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamAssocList.cs b/OpenDreamRuntime/Objects/Types/DreamAssocList.cs index d59806c6b4..bfed4e2a65 100644 --- a/OpenDreamRuntime/Objects/Types/DreamAssocList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamAssocList.cs @@ -122,7 +122,7 @@ public bool ContainsValue(DreamValue value) { public override DreamValue OperatorAppend(DreamValue b) { if (b.TryGetValueAsDreamList(out var bList)) { foreach (var value in bList.EnumerateValues()) { - AddValue(value); // Always add the value + AddValue(value); } } else { AddValue(b);