Skip to content

Commit

Permalink
now resolving references to hardcoded forms
Browse files Browse the repository at this point in the history
  • Loading branch information
matortheeternal committed Jul 23, 2018
1 parent 9d94e72 commit 3fa0866
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lib/xedit/wbImplementation.pas
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ interface
procedure wbMastersForFile(const aFileName: string; aMasters: TStrings);
function wbFile(const aFileName: string; aLoadOrder: Integer = -1; aCompareTo: string = '';
IsTemporary: Boolean = False; aOnlyHeader: Boolean = False): IwbFile;
function GetHardcodedFile: IwbFile;
function wbNewFile(const aFileName: string; aLoadOrder: Integer): IwbFile;
procedure wbFileForceClosed; overload;
procedure wbFileForceClosed(_File: IwbFile); overload;
Expand Down Expand Up @@ -2832,11 +2833,15 @@ function TwbFile.GetMasterRecordByFormID(aFormID: Cardinal; aAllowInjected: Bool
FileID : Byte;
Master : IwbFile;
begin
Result := nil;
FileID := aFormID shr 24;

if FileID >= Cardinal(GetMasterCount) then begin
Result := nil;
end else begin
if (aFormID < $800) and not (fsIsHardcoded in flStates) then begin
Master := GetHardcodedFile;
if Assigned(Master) then
Result := Master.RecordByFormID[aFormID, aAllowInjected];
end
else if FileID < Cardinal(GetMasterCount) then begin
Master := flMasters[FileID];
Result := Master.RecordByFormID[(aFormID and $00FFFFFF) or (Cardinal(Master.MasterCount) shl 24), aAllowInjected];
end;
Expand Down Expand Up @@ -7487,7 +7492,9 @@ function TwbMainRecord.GetIsInitiallyDisabled: Boolean;
function TwbMainRecord.GetIsInjected: Boolean;
begin
if not (mrsIsInjectedChecked in mrStates) then begin
if not Assigned(mrMaster) and (mrStruct.mrsFormID <> 0) and( (mrStruct.mrsFormID shr 24) < Cardinal(GetFile.MasterCount) ) and not (fsIsHardcoded in GetFile.FileStates) then
if not Assigned(mrMaster) and (mrStruct.mrsFormID <> 0)
and( (mrStruct.mrsFormID shr 24) < Cardinal(GetFile.MasterCount) )
and not (fsIsHardcoded in GetFile.FileStates) then
Include(mrStates, mrsIsInjected)
else
Exclude(mrStates, mrsIsInjected);
Expand Down Expand Up @@ -15410,6 +15417,18 @@ procedure wbMastersForFile(const aFileName: string; aMasters: TStrings);
end;
end;

function GetHardcodedFile: IwbFile;
var
i: Integer;
begin
for i := Low(Files) to High(Files) do begin
Result := Files[i];
if fsIsHardcoded in Files[i].FileStates then
exit;
end;
Result := nil;
end;

function wbNewFile(const aFileName: string; aLoadOrder: Integer): IwbFile;
var
FileName: string;
Expand Down

0 comments on commit 3fa0866

Please sign in to comment.