Skip to content

Commit

Permalink
added new property mrSubrecordErrors to TwbMainRecord, helper functio…
Browse files Browse the repository at this point in the history
…n to add a new subrecord error, and populating of these errors in the TwbMainRecord.Init function

Exposed through property GetSubrecordErrors
  • Loading branch information
matortheeternal committed May 24, 2016
1 parent a0593c7 commit caac0e6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/xedit/wbImplementation.pas
Expand Up @@ -864,6 +864,7 @@ TwbMainRecord = class(TwbRecord, IwbMainRecord, IwbMainRecordInternal, IwbMain
mrOverridesSorted : Boolean;
mrEditorID : string;
mrFullName : string;
mrSubrecordErrors : string;
mrStates : TwbMainRecordStates;
mrBaseRecordID : Cardinal;
mrConflictAll : TConflictAll;
Expand All @@ -885,6 +886,7 @@ TwbMainRecord = class(TwbRecord, IwbMainRecord, IwbMainRecordInternal, IwbMain
procedure ElementChanged(const aElement: IwbElement; aContainer: Pointer); override;
function RemoveElement(aPos: Integer; aMarkModified: Boolean = False): IwbElement; overload; override;
function ResolveElementName(aName: string; out aRemainingName: string; aCanCreate: Boolean = False): IwbElement; override;
procedure SubrecordError(sig: string);

function GetIsInjected: Boolean; override;
function GetReferencesInjected: Boolean; override;
Expand Down Expand Up @@ -974,6 +976,7 @@ TwbMainRecord = class(TwbRecord, IwbMainRecord, IwbMainRecordInternal, IwbMain
function GetReferencedBy(aIndex: Integer): IwbMainRecord;
function GetReferencedByCount: Integer;
function GetCheck: string; override;
function GetSubrecordErrors: string;
function GetIsWinningOverride: Boolean;
function GetWinningOverride: IwbMainRecord;
function GetHighestOverrideOrSelf(aMaxLoadOrder: Integer): IwbMainRecord;
Expand Down Expand Up @@ -6030,7 +6033,8 @@ procedure TwbMainRecord.Init;
Exit;

DecompressIfNeeded;


mrSubrecordErrors := '';
FoundError := False;

if not (mrsQuickInit in mrStates) then begin
Expand Down Expand Up @@ -6088,6 +6092,7 @@ procedure TwbMainRecord.Init;
if mrDef.AllowUnordered then begin
CurrentDefPos := mrDef.GetMemberIndexFor(CurrentRec.Signature, CurrentRec);
if CurrentDefPos < 0 then begin
SubrecordError(String(CurrentRec.Signature));
if Assigned(wbProgressCallback) then
wbProgressCallback('Error: record '+ String(GetSignature) + ' contains unexpected (or out of order) subrecord ' + String(CurrentRec.Signature) + ' ' + IntToHex(Int64(Cardinal(CurrentRec.Signature)), 8) );
FoundError := True;
Expand All @@ -6097,6 +6102,7 @@ procedure TwbMainRecord.Init;
CurrentDef := mrDef.Members[CurrentDefPos];
end else begin
if not mrDef.ContainsMemberFor(CurrentRec.Signature, CurrentRec) then begin
SubrecordError(String(CurrentRec.Signature));
if Assigned(wbProgressCallback) then
wbProgressCallback('Error: record '+ String(GetSignature) + ' contains unexpected (or out of order) subrecord ' + String(CurrentRec.Signature) + ' ' + IntToHex(Int64(Cardinal(CurrentRec.Signature)), 8) );
FoundError := True;
Expand All @@ -6111,6 +6117,7 @@ procedure TwbMainRecord.Init;
Continue;
end;
end else begin
SubrecordError(String(CurrentRec.Signature));
if Assigned(wbProgressCallback) then
wbProgressCallback('Error: record '+ String(GetSignature) + ' contains unexpected (or out of order) subrecord ' + String(CurrentRec.Signature) );
FoundError := True;
Expand Down Expand Up @@ -6189,6 +6196,7 @@ procedure TwbMainRecord.Init;
Continue;
end;

SubrecordError(String(CurrentRec.Signature));
if Assigned(wbProgressCallback) then
wbProgressCallback('Error: record '+ String(GetSignature) + ' contains unexpected (or out of order) subrecord ' + String(CurrentRec.Signature) );
FoundError := True;
Expand Down Expand Up @@ -6475,6 +6483,19 @@ function TwbMainRecord.GetCheck: string;
end;
end;

function TwbMainRecord.GetSubrecordErrors: String;
begin
Result := mrSubrecordErrors;
end;

procedure TwbMainRecord.SubrecordError(sig: String);
begin
if mrSubrecordErrors = '' then
mrSubrecordErrors := sig
else
mrSubrecordErrors := mrSubrecordErrors + ',' + sig;
end;

function TwbMainRecord.GetChildGroup: IwbGroupRecord;
var
SearchForGroup: Integer;
Expand Down
3 changes: 3 additions & 0 deletions lib/xedit/wbInterface.pas
Expand Up @@ -945,6 +945,7 @@ TwbGridCell = record
procedure SetEditorID(const aValue: string);
function GetFullName: string;
function GetDisplayNameKey: string;
function GetSubrecordErrors: string;
function GetMaster: IwbMainRecord;
function GetIsMaster: Boolean;
function GetMasterOrSelf: IwbMainRecord;
Expand Down Expand Up @@ -1029,6 +1030,8 @@ TwbGridCell = record
read GetFullName;
property DisplayNameKey: string
read GetDisplayNameKey;
property SubrecordErrors: string
read GetSubrecordErrors;

property Flags: TwbMainRecordStructFlags
read GetFlags;
Expand Down

0 comments on commit caac0e6

Please sign in to comment.