Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions OpenDreamRuntime/Objects/Types/DreamList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,16 +1080,14 @@ public override DreamValue GetValue(DreamValue key) {
int filterIndex;
if (key.TryGetValueAsString(out var filterName)) {
filterIndex = GetIndexOfFilter(filterName) + 1; // We're 1-indexed while GetIndexOfFilter() is not
if (filterIndex < 1) // If a filter by the name doesn't exist, it returns null
return DreamValue.Null;
} else {
key.TryGetValueAsInteger(out filterIndex);
}

if (filterIndex < 1) { // The key failed to resolve to a valid index
throw new Exception($"Invalid index into filter list: {key}");
}

ImmutableAppearance appearance = GetAppearance();
if (filterIndex > appearance.Filters.Length)
if (filterIndex < 1 || filterIndex > appearance.Filters.Length)
throw new Exception($"Atom only has {appearance.Filters.Length} filter(s), cannot index {filterIndex}");

DreamFilter filter = appearance.Filters[filterIndex - 1];
Expand Down
Loading