Fixed form comparison

This commit is contained in:
Eddoursul 2022-10-10 23:51:58 +02:00
parent 06c6dd1c6b
commit daab017fbd

View File

@ -55,7 +55,7 @@ begin
end;
// Refs referencing themselves do not require the flag
if not Equals(rec, referencingRecord) then begin
if not SameRecord(rec, referencingRecord) then begin
result := True;
break;
end;
@ -64,6 +64,12 @@ begin
end;
end;
function SameRecord(ref: IwbMainRecord; otherRef: IwbMainRecord): boolean;
begin
// 'Equals' does not fit here
result := Assigned(ref) and (GetLoadOrderFormID(ref) = GetLoadOrderFormID(otherRef));
end;
function InSameCell(ref: IwbMainRecord; otherRef: IwbMainRecord): boolean;
var
cell, otherCell, worldspace, otherWorldspace: IwbMainRecord;
@ -76,14 +82,14 @@ begin
// Interior cell
if (GetElementNativeValues(cell, 'DATA') and 1) > 0 then begin
result := Equals(cell, otherCell);
result := SameRecord(cell, otherCell);
exit;
end;
worldspace := LinksTo(ElementByPath(cell, 'Worldspace'));
otherWorldspace := LinksTo(ElementByPath(otherCell, 'Worldspace'));
if not Equals(worldspace, otherWorldspace) then begin
if not SameRecord(worldspace, otherWorldspace) then begin
result := false;
exit;
end;
@ -93,10 +99,12 @@ begin
result := true;
exit;
end;
// Persistent refs are located in 0,0 so we detect their original grid position via their position
coords := wbPositionToGridCell(GetPosition(ref));
otherCoords := wbPositionToGridCell(GetPosition(otherRef));
//AddMessage(IntToStr(coords.x) + ' ' + IntToStr(otherCoords.x));
//AddMessage(IntToStr(coords.y) + ' ' + IntToStr(otherCoords.y));
result := (coords.x = otherCoords.x) and (coords.y = otherCoords.y);
end;
@ -123,7 +131,7 @@ function MarkPersistent(e: IwbMainRecord): boolean;
begin
AddMessage(' + Marking as persistent: ' + GetElementEditValues(e, 'NAME') + ' - (' + Name(e) + ')');
Inc(flaggedCount);
SetIsPersistent(e, True);
//SetIsPersistent(e, True);
CheckNonPersistentOverride(e);
end;
@ -159,7 +167,7 @@ begin
linkedCount := ElementCount(linkedRefs);
for i := 0 to Pred(linkedCount) do begin
currentItem := ElementByIndex(linkedRefs, i);
if Equals(LinksTo(ElementByPath(currentItem, 'Keyword/Ref')), keyword) then begin
if SameRecord(LinksTo(ElementByPath(currentItem, 'Keyword/Ref')), keyword) then begin
result := LinksTo(ElementByPath(currentItem, 'Ref'));
break;
end;
@ -321,7 +329,7 @@ begin
else if (packageLoc = 'In cell') then begin
refCell := LinksTo(ElementByPath(ElementByIndex(ElementByPath(package, 'Package Data\Data Input Values'), 0), 'PLDT\Cell'));
if Assigned(refCell) then begin
if Equals(refCell, LinksTo(ElementByPath(e, 'Cell'))) then continue;
if SameRecord(refCell, LinksTo(ElementByPath(e, 'Cell'))) then continue;
end;
end
else if (packageLoc = 'Near linked reference') then begin