Mutagen-Modding / Mutagen.Bethesda.Analyzers

A project to diagnose and analyze the health of a mod or a load order
GNU General Public License v3.0
18 stars 5 forks source link

Issue with Biped Object Names in Race Records Causing System.ArgumentException #163

Open Darkaxt opened 3 weeks ago

Darkaxt commented 3 weeks ago

When editing or creating mods for Fallout 4 using xEdit, the Biped Object Names property within the Race record can exhibit characteristics that Mutagen does not handle well. This results in an error message similar to:

Unexpected header type: NAME System.ArgumentException

Two main issues have been identified:

  1. Number of Entries: The Biped Object Names property is not always constrained to 32 entries (0 to 31). Having more than 32 entries can cause errors.
  2. Null Values: Some slots in the Biped Object Names property can contain null values instead of properly defined empty slots.

Manual Fix:

  1. Ensure that null slots are replaced with empty, unnamed slots.
  2. Verify that the number of entries does not exceed 31, keeping the indexes within the allowed range (0 to 31).

xEdit Script for Reference: To help identify problematic records, here is an xEdit script that checks Race records for the issues outlined:

unit UserScript;

function Process(e: IInterface): integer;
var
  bipedObjNames: IInterface;
  count: integer;
begin
  Result := 0;

  // Check if the record is a race
  if Signature(e) <> 'RACE' then
    Exit;

  // Check if the current record has the "Biped Object Names" path
  bipedObjNames := ElementByPath(e, 'Biped Object Names');
  if Assigned(bipedObjNames) then begin
    // Count the number of sub-elements under "Biped Object Names"
    count := ElementCount(bipedObjNames);

    // Report if there are more than 32 entries
    if count > 32 then
      AddMessage('Record ' + Name(e) + ' has ' + IntToStr(count) + ' Biped Object Names entries.');
  end;
end;

function Finalize: integer;
begin
  AddMessage('Script completed.');
  Result := 0;
end;

end.

This script will identify Race records that have more than 32 Biped Object Names entries, allowing for easy review and correction.