Fix Interval Map GetAlignedRecursiveRange lookup bug

Any lookups done using `GetAlignedRecursiveRange` incorrectly added intervals in the exclusive interval entry lookups as the condition for adding them was the reverse of what it should've been due to a last minute refactor, it led to graphical glitches and crashes. This has been fixed and the lookups should return the correct results.
This commit is contained in:
PixelyIon 2022-03-07 02:05:14 +05:30
parent f2faa74707
commit da8cb48933

View File

@ -187,15 +187,19 @@ namespace skyline {
for (const auto &entryInterval2 : recursedEntry->group->intervals) { for (const auto &entryInterval2 : recursedEntry->group->intervals) {
// Similar to case (2) below but for the recursed entry // Similar to case (2) below but for the recursed entry
bool exclusiveIntervalEntry{true};
auto alignedEntryInterval2{entryInterval2.Align(Alignment)}; auto alignedEntryInterval2{entryInterval2.Align(Alignment)};
auto recursedEntry2{std::lower_bound(entries.begin(), entries.end(), alignedEntryInterval2.end)}; auto recursedEntry2{std::lower_bound(entries.begin(), entries.end(), alignedEntryInterval2.end)};
for (; recursedEntry2 != entries.begin() && (--recursedEntry2)->start < alignedEntryInterval2.end;) { for (; recursedEntry2 != entries.begin() && (--recursedEntry2)->start < alignedEntryInterval2.end;) {
if (recursedEntry2->end > alignedEntryInterval2.start && recursedEntry2->group != recursedEntry->group && recursedEntry2->group != entry->group) { if (recursedEntry2->end > alignedEntryInterval2.start && recursedEntry2->group != recursedEntry->group && recursedEntry2->group != entry->group) {
intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval2.end), alignedEntryInterval2); exclusiveIntervalEntry = false;
break; break;
} }
} }
if (exclusiveIntervalEntry)
intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval2.end), alignedEntryInterval2);
} }
} }
} }
@ -203,12 +207,17 @@ namespace skyline {
intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval.start), alignedEntryInterval); intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval.start), alignedEntryInterval);
} else { } else {
// Case (2) - We only want to add this interval if it only contains the entry // Case (2) - We only want to add this interval if it only contains the entry
bool exclusiveIntervalEntry{true};
for (auto recursedEntry{std::lower_bound(entries.begin(), entries.end(), alignedEntryInterval.end)}; recursedEntry != entries.begin() && (--recursedEntry)->start < alignedEntryInterval.end;) { for (auto recursedEntry{std::lower_bound(entries.begin(), entries.end(), alignedEntryInterval.end)}; recursedEntry != entries.begin() && (--recursedEntry)->start < alignedEntryInterval.end;) {
if (recursedEntry->end > alignedEntryInterval.start && recursedEntry->group != entry->group) { if (recursedEntry->end > alignedEntryInterval.start && recursedEntry->group != entry->group) {
intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval.start), alignedEntryInterval); exclusiveIntervalEntry = false;
break; break;
} }
} }
if (exclusiveIntervalEntry)
intervals.emplace(std::lower_bound(intervals.begin(), intervals.end(), alignedEntryInterval.start), alignedEntryInterval);
} }
} }
} }