Skip to content

Commit c6bd0c1

Browse files
authored
Handle DreamObjectSavefile in the in operator (OpenDreamProject#2471)
1 parent 99546a4 commit c6bd0c1

File tree

5 files changed

+257
-235
lines changed

5 files changed

+257
-235
lines changed

OpenDream.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<s:Boolean x:Key="/Default/UserDictionary/Words/=cmptext/@EntryIndexedValue">True</s:Boolean>
4242
<s:Boolean x:Key="/Default/UserDictionary/Words/=compiletimereadonly/@EntryIndexedValue">True</s:Boolean>
4343
<s:Boolean x:Key="/Default/UserDictionary/Words/=copytext/@EntryIndexedValue">True</s:Boolean>
44+
<s:Boolean x:Key="/Default/UserDictionary/Words/=datums/@EntryIndexedValue">True</s:Boolean>
4445
<s:Boolean x:Key="/Default/UserDictionary/Words/=Debuggee/@EntryIndexedValue">True</s:Boolean>
4546
<s:Boolean x:Key="/Default/UserDictionary/Words/=deciseconds/@EntryIndexedValue">True</s:Boolean>
4647
<s:Boolean x:Key="/Default/UserDictionary/Words/=fcopy/@EntryIndexedValue">True</s:Boolean>

OpenDreamRuntime/Objects/Types/DreamList.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ public override void AddValue(DreamValue value) {
827827
var immutableOverlay = _appearanceSystem.AddAppearance(overlayAppearance ?? MutableAppearance.Default);
828828
overlayAppearance?.Dispose();
829829

830-
//after UpdateApparance is done, the atom is set with a new immutable appearance containing a hard ref to the overlay
830+
//after UpdateAppearance is done, the atom is set with a new immutable appearance containing a hard ref to the overlay
831831
//only /mutable_appearance handles it differently, and that's done in DreamObjectImage
832832
_atomManager.UpdateAppearance(_owner, appearance => {
833833
GetOverlaysList(appearance).Add(immutableOverlay);
@@ -1567,8 +1567,8 @@ public override int FindValue(DreamValue value, int start = 1, int end = 0) {
15671567
}
15681568
}
15691569

1570-
// Savefile Dir List - always sync'd with Savefiles currentDir. Only stores keys.
1571-
internal sealed class SavefileDirList(DreamObjectDefinition listDef, DreamObjectSavefile backedSaveFile) : DreamList(listDef, 0) {
1570+
// Savefile Dir List - always synced with Savefiles currentDir. Only stores keys.
1571+
public sealed class SavefileDirList(DreamObjectDefinition listDef, DreamObjectSavefile backedSaveFile) : DreamList(listDef, 0) {
15721572
public override DreamValue GetValue(DreamValue key) {
15731573
if (!key.TryGetValueAsInteger(out var index))
15741574
throw new Exception($"Invalid index on savefile dir list: {key}");
@@ -1577,6 +1577,10 @@ public override DreamValue GetValue(DreamValue key) {
15771577
return new DreamValue(backedSaveFile.CurrentDir.Keys.ElementAt(index - 1));
15781578
}
15791579

1580+
public override bool ContainsValue(DreamValue value) {
1581+
return value.TryGetValueAsString(out var str) && backedSaveFile.CurrentDir.ContainsKey(str);
1582+
}
1583+
15801584
public override List<DreamValue> GetValues() {
15811585
return EnumerateValues().ToList();
15821586
}

0 commit comments

Comments
 (0)