Skip to content

Commit 674f637

Browse files
committed
Fix LE default header. Lean on GameConstants more
closes #650
1 parent 600aaca commit 674f637

File tree

15 files changed

+71
-30
lines changed

15 files changed

+71
-30
lines changed

Mutagen.Bethesda.Core/Plugins/Meta/GameConstants.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ public GameConstants(
190190
DataFolderRelativePath = Path.Combine("OblivionRemastered", "Content", "Dev", "ObvData", "Data")
191191
};
192192

193-
/// <summary>
194-
/// Readonly singleton of Skyrim LE game constants
195-
/// </summary>
193+
/// <summary>
194+
/// Readonly singleton of Skyrim LE game constants
195+
/// </summary>
196196
public static readonly GameConstants SkyrimLE = new GameConstants(
197197
release: GameRelease.SkyrimLE,
198198
modHeaderLength: 24,
@@ -255,7 +255,7 @@ public GameConstants(
255255
languageFormat: Strings.StringsLanguageFormat.FullName,
256256
hasEnabledMarkers: false,
257257
defaultFormVersion: 43,
258-
defaultModHeaderVersion: 1.71f,
258+
defaultModHeaderVersion: 1.70f,
259259
defaultHighRangeFormId: 0x800,
260260
useLowerRangeFormIdVersion: 1.71f,
261261
myDocumentsString: "Skyrim",
@@ -273,14 +273,15 @@ public GameConstants(
273273
IniName = "Enderal",
274274
};
275275

276-
/// <summary>
277-
/// Readonly singleton of Skyrim SE game constants
278-
/// </summary>
276+
/// <summary>
277+
/// Readonly singleton of Skyrim SE game constants
278+
/// </summary>
279279
public static readonly GameConstants SkyrimSE = SkyrimLE with
280280
{
281281
Release = GameRelease.SkyrimSE,
282282
HasEnabledMarkers = true,
283283
DefaultFormVersion = 44,
284+
DefaultModHeaderVersion = 1.71f,
284285
MyDocumentsString = "Skyrim Special Edition",
285286
};
286287

Mutagen.Bethesda.Fallout4/Records/Fallout4ModHeader.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</Object>
2525
<Object name="ModStats" recordType="HEDR" objType="Subrecord">
2626
<Fields>
27-
<Float name="Version" default="1f" />
27+
<Float name="Version" />
2828
<UInt32 name="NumRecords" />
2929
<UInt32 name="NextFormID" default="0x0" />
3030
</Fields>

Mutagen.Bethesda.Fallout4/Records/Fallout4Mod_Generated.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5833,11 +5833,15 @@ public Fallout4Mod(
58335833
bool? forceUseLowerFormIDRanges = false)
58345834
: base(modKey)
58355835
{
5836+
this.Fallout4Release = release;
58365837
if (headerVersion != null)
58375838
{
58385839
this.ModHeader.Stats.Version = headerVersion.Value;
58395840
}
5840-
this.Fallout4Release = release;
5841+
else
5842+
{
5843+
this.ModHeader.Stats.Version = GameConstants.Get(release.ToGameRelease()).DefaultModHeaderVersion ?? 0f;
5844+
}
58415845
this.ModHeader.Stats.NextFormID = GetDefaultInitialNextFormID(forceUseLowerFormIDRanges: forceUseLowerFormIDRanges);
58425846
_GameSettings_Object = new Fallout4Group<GameSetting>(this);
58435847
_Keywords_Object = new Fallout4Group<Keyword>(this);

Mutagen.Bethesda.Fallout4/Records/ModStats_Generated.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public ModStats()
5151
#endregion
5252

5353
#region Version
54-
public static readonly Single VersionDefault = 1f;
55-
public Single Version { get; set; } = VersionDefault;
54+
public Single Version { get; set; } = default(Single);
5655
#endregion
5756
#region NumRecords
5857
public UInt32 NumRecords { get; set; } = default(UInt32);
@@ -758,7 +757,7 @@ internal partial class ModStatsSetterCommon
758757
public void Clear(IModStats item)
759758
{
760759
ClearPartial();
761-
item.Version = ModStats.VersionDefault;
760+
item.Version = default(Single);
762761
item.NumRecords = default(UInt32);
763762
item.NextFormID = ModStats.NextFormIDDefault;
764763
}

Mutagen.Bethesda.Generation/Modules/Plugin/ModModule.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,27 @@ public override async Task GenerateInClass(ObjectGeneration obj, StructuredStrin
136136
}
137137
using (sb.CurlyBrace())
138138
{
139+
if (objData.GameReleaseOptions != null)
140+
{
141+
sb.AppendLine($"this.{ReleaseEnumName(obj)} = release;");
142+
}
143+
139144
sb.AppendLine("if (headerVersion != null)");
140145
using (sb.CurlyBrace())
141146
{
142147
sb.AppendLine($"this.ModHeader.Stats.Version = headerVersion.Value;");
143148
}
144-
if (objData.GameReleaseOptions != null)
149+
sb.AppendLine("else");
150+
using (sb.CurlyBrace())
145151
{
146-
sb.AppendLine($"this.{ReleaseEnumName(obj)} = release;");
152+
if (objData.GameReleaseOptions != null)
153+
{
154+
sb.AppendLine($"this.ModHeader.Stats.Version = {nameof(GameConstants)}.Get(release.ToGameRelease()).DefaultModHeaderVersion ?? 0f;");
155+
}
156+
else
157+
{
158+
sb.AppendLine($"this.ModHeader.Stats.Version = {nameof(GameConstants)}.Get({nameof(GameRelease)}.{objData.GameCategory}).DefaultModHeaderVersion ?? 0f;");
159+
}
147160
}
148161

149162
using (var a = sb.Call("this.ModHeader.Stats.NextFormID = GetDefaultInitialNextFormID"))

Mutagen.Bethesda.Oblivion/Records/ModStats_Generated.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public ModStats()
5151
#endregion
5252

5353
#region Version
54-
public static readonly Single VersionDefault = 1.0f;
55-
public Single Version { get; set; } = VersionDefault;
54+
public Single Version { get; set; } = default(Single);
5655
#endregion
5756
#region NumRecords
5857
public UInt32 NumRecords { get; set; } = default(UInt32);
@@ -758,7 +757,7 @@ internal partial class ModStatsSetterCommon
758757
public void Clear(IModStats item)
759758
{
760759
ClearPartial();
761-
item.Version = ModStats.VersionDefault;
760+
item.Version = default(Single);
762761
item.NumRecords = default(UInt32);
763762
item.NextFormID = ModStats.NextFormIDDefault;
764763
}

Mutagen.Bethesda.Oblivion/Records/OblivionModHeader.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</Object>
1616
<Object name="ModStats" recordType="HEDR" objType="Subrecord">
1717
<Fields>
18-
<Float name="Version" default="1.0f" />
18+
<Float name="Version" />
1919
<UInt32 name="NumRecords" />
2020
<UInt32 name="NextFormID" default="0x800" />
2121
</Fields>

Mutagen.Bethesda.Oblivion/Records/OblivionMod_Generated.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2823,11 +2823,15 @@ public OblivionMod(
28232823
bool? forceUseLowerFormIDRanges = false)
28242824
: base(modKey)
28252825
{
2826+
this.OblivionRelease = release;
28262827
if (headerVersion != null)
28272828
{
28282829
this.ModHeader.Stats.Version = headerVersion.Value;
28292830
}
2830-
this.OblivionRelease = release;
2831+
else
2832+
{
2833+
this.ModHeader.Stats.Version = GameConstants.Get(release.ToGameRelease()).DefaultModHeaderVersion ?? 0f;
2834+
}
28312835
this.ModHeader.Stats.NextFormID = GetDefaultInitialNextFormID(forceUseLowerFormIDRanges: forceUseLowerFormIDRanges);
28322836
_GameSettings_Object = new OblivionGroup<GameSetting>(this);
28332837
_Globals_Object = new OblivionGroup<Global>(this);

Mutagen.Bethesda.Skyrim/Records/ModStats_Generated.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public ModStats()
5151
#endregion
5252

5353
#region Version
54-
public static readonly Single VersionDefault = 1.71f;
55-
public Single Version { get; set; } = VersionDefault;
54+
public Single Version { get; set; } = default(Single);
5655
#endregion
5756
#region NumRecords
5857
public UInt32 NumRecords { get; set; } = default(UInt32);
@@ -758,7 +757,7 @@ internal partial class ModStatsSetterCommon
758757
public void Clear(IModStats item)
759758
{
760759
ClearPartial();
761-
item.Version = ModStats.VersionDefault;
760+
item.Version = default(Single);
762761
item.NumRecords = default(UInt32);
763762
item.NextFormID = ModStats.NextFormIDDefault;
764763
}

Mutagen.Bethesda.Skyrim/Records/SkyrimModHeader.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</Object>
2323
<Object name="ModStats" recordType="HEDR" objType="Subrecord">
2424
<Fields>
25-
<Float name="Version" default="1.71f" />
25+
<Float name="Version" />
2626
<UInt32 name="NumRecords" />
2727
<UInt32 name="NextFormID" default="0x0" />
2828
</Fields>

0 commit comments

Comments
 (0)