Advertisement
Guest User

Untitled

a guest
Feb 18th, 2015
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.14 KB | None | 0 0
  1. {
  2.   Compare record to the previous override and remove if the same.
  3.   This process depends on the plugins and their load order in xEdit!
  4.   Can be used to remove unneeded records from dynamic patch files.
  5. }
  6. unit RemoveITPO;
  7.  
  8. var
  9.   CountITPO: Integer;
  10.  
  11. function Process(e: IInterface): integer;
  12. var
  13.   m, prevovr, ovr: IInterface;
  14.   i: integer;
  15. begin
  16.   // skip master records
  17.   if IsMaster(e) then
  18.     Exit;
  19.    
  20.   // skip records that have elements in child group (WRLD, CELL, DIAL)
  21.   if ElementCount(ChildGroup(e)) <> 0 then
  22.     Exit;
  23.  
  24.   m := MasterOrSelf(e);
  25.  
  26.   // find previous override record in a list of overrides for master record
  27.   prevovr := m;
  28.   for i := 0 to Pred(OverrideCount(m)) do begin
  29.     ovr := OverrideByIndex(m, i);
  30.     if Equals(ovr, e) then
  31.       Break;
  32.     prevovr := ovr;
  33.   end;
  34.  
  35.   // remove record if no conflicts
  36.   if ConflictAllForElements(prevovr, e, False, False) <= caConflictBenign then begin
  37.     AddMessage('Removing: ' + Name(e));
  38.     RemoveNode(e);
  39.     Inc(CountITPO);
  40.   end;
  41. end;
  42.  
  43. function Finalize: integer;
  44. begin
  45.   AddMessage('ITPO records removed: ' + IntToStr(CountITPO));
  46. end;
  47.  
  48. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement