Add NPC interaction normalization
This commit is contained in:
@@ -149,9 +149,12 @@ func issuesFor(doc *source.SourceDocument, value dnd.NPCInteractionList, npcRegi
|
||||
}
|
||||
|
||||
func interactionLess(doc *source.SourceDocument, left, right dnd.NPCInteraction) bool {
|
||||
leftPosition, _ := earliestSourcePosition(doc, left)
|
||||
rightPosition, _ := earliestSourcePosition(doc, right)
|
||||
if leftPosition != rightPosition {
|
||||
leftPosition, leftHasEvidence := earliestSourcePosition(doc, left)
|
||||
rightPosition, rightHasEvidence := earliestSourcePosition(doc, right)
|
||||
if leftHasEvidence != rightHasEvidence {
|
||||
return leftHasEvidence
|
||||
}
|
||||
if leftHasEvidence && leftPosition != rightPosition {
|
||||
return leftPosition < rightPosition
|
||||
}
|
||||
leftKey := identity.ComparisonKey(left.Name)
|
||||
@@ -182,14 +185,26 @@ func sourceRefLess(doc *source.SourceDocument, left, right source.SourceRef) boo
|
||||
if left.SourceID != right.SourceID {
|
||||
return left.SourceID < right.SourceID
|
||||
}
|
||||
leftStart, _ := source.UnitIndex(doc, left.StartUnitID)
|
||||
rightStart, _ := source.UnitIndex(doc, right.StartUnitID)
|
||||
if leftStart != rightStart {
|
||||
leftStart, leftStartOK := source.UnitIndex(doc, left.StartUnitID)
|
||||
rightStart, rightStartOK := source.UnitIndex(doc, right.StartUnitID)
|
||||
if leftStartOK != rightStartOK {
|
||||
return leftStartOK
|
||||
}
|
||||
if leftStartOK && leftStart != rightStart {
|
||||
return leftStart < rightStart
|
||||
}
|
||||
leftEnd, _ := source.UnitIndex(doc, left.EndUnitID)
|
||||
rightEnd, _ := source.UnitIndex(doc, right.EndUnitID)
|
||||
return leftEnd < rightEnd
|
||||
if left.StartUnitID != right.StartUnitID {
|
||||
return left.StartUnitID < right.StartUnitID
|
||||
}
|
||||
leftEnd, leftEndOK := source.UnitIndex(doc, left.EndUnitID)
|
||||
rightEnd, rightEndOK := source.UnitIndex(doc, right.EndUnitID)
|
||||
if leftEndOK != rightEndOK {
|
||||
return leftEndOK
|
||||
}
|
||||
if leftEndOK && leftEnd != rightEnd {
|
||||
return leftEnd < rightEnd
|
||||
}
|
||||
return left.EndUnitID < right.EndUnitID
|
||||
}
|
||||
|
||||
func earliestSourcePosition(doc *source.SourceDocument, interaction dnd.NPCInteraction) (int, bool) {
|
||||
|
||||
Reference in New Issue
Block a user