Skip to content

Commit 8a40df6

Browse files
committed
Add IW4 pointer-walk reader & editor bridge
Introduce support for the IW4 (MW2 PS3) pointer-following zone reader and bridge it into the editor. Adds a new FastFileLib.Iw4 reader set (Iw4ZoneReader, ZonePointer, Memory, readers, models, etc.) and unit tests for the reader/pointer model. Implements Iw4AssetBridge to map IW4-parsed assets (rawfiles, localize, stringtables, weapons, techsets, menus) into the editor models and prefer the IW4 walk for MW2 PS3 zones when complete. UI changes: new AssetSelectionDialog toggles (stringtables, weapons, images, techsets), integrate loading flags in MainWindow, and add WeaponDetailForm to show read-only structured IW4 weapons (WeaponAsset updated with IsStructuredView/DetailFields). Minor fixes: MW2 game definition techset recognition and a clarification comment in Cod5MenuDeserializer about pointer heuristics.
1 parent a05b32c commit 8a40df6

32 files changed

Lines changed: 6284 additions & 14 deletions

Call of Duty FastFile Editor/Call of Duty FastFile Editor.csproj.user

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
<Compile Update="UI\SupportedFormatsForm.cs">
4141
<SubType>Form</SubType>
4242
</Compile>
43+
<Compile Update="UI\WeaponDetailForm.cs">
44+
<SubType>Form</SubType>
45+
</Compile>
4346
<Compile Update="UI\WeaponEditorForm.cs">
4447
<SubType>Form</SubType>
4548
</Compile>

Call of Duty FastFile Editor/GameDefinitions/MW2GameDefinition.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ public MW2GameDefinition(bool isXbox360, bool isPC = false)
7272
? (byte)MW2AssetTypePC.image
7373
: (IsXbox360 ? (byte)MW2AssetTypeXbox360.image : (byte)MW2AssetTypePS3.image);
7474

75+
/// <summary>
76+
/// MW2 MaterialTechniqueSet (techset) asset type ID. PS3 = 0x08, Xbox 360 = 0x07
77+
/// (no vertexshader slot), PC = 0x09 (extra vertexdecl slot).
78+
/// </summary>
79+
public byte TechSetAssetType => IsPC
80+
? (byte)MW2AssetTypePC.techset
81+
: (IsXbox360 ? (byte)MW2AssetTypeXbox360.techset : (byte)MW2AssetTypePS3.techset);
82+
83+
/// <summary>
84+
/// Recognise techset records so the Asset Pool view and per-type counts name them.
85+
/// For MW2 PS3 the techset bodies come from the IW4 pointer-walk; other platforms use
86+
/// the pattern-scan fallback (same as the other view-only types).
87+
/// </summary>
88+
public override bool IsTechSetType(int assetType) => assetType == TechSetAssetType;
89+
7590
public override string GetAssetTypeName(int assetType)
7691
{
7792
if (IsPC)

Call of Duty FastFile Editor/Models/WeaponAsset.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,30 @@ public class WeaponAsset
140140
/// </summary>
141141
public string AdditionalData { get; set; } = string.Empty;
142142

143+
/// <summary>
144+
/// True when this weapon was read by the IW4 pointer-walk (MW2 PS3) rather than the
145+
/// WaW-tuned pattern parser. In that case the classic weapType/weapClass enums aren't
146+
/// recovered (they live in opaque field blocks), the rich structure is exposed via
147+
/// <see cref="DetailFields"/> instead, and the byte-offset editor must NOT be used (it
148+
/// would write WaW offsets into an IW4 layout and corrupt the zone).
149+
/// </summary>
150+
public bool IsStructuredView { get; set; }
151+
152+
/// <summary>
153+
/// Ordered (label, value) pairs of the parsed weapon structure, for the read-only detail
154+
/// view. Populated for <see cref="IsStructuredView"/> weapons from the IW4 WeaponVariantDef
155+
/// + WeaponDef (clip/fire/ADS, arcs, ranges, accuracy, turn speeds, hint/script strings,
156+
/// boolean flags). A blank label denotes a section header.
157+
/// </summary>
158+
public List<(string Label, string Value)> DetailFields { get; set; } = new();
159+
143160
/// <summary>
144161
/// Gets a summary of the weapon properties.
145162
/// </summary>
146163
public string GetSummary()
147164
{
165+
if (IsStructuredView)
166+
return $"clip {ClipSize}, fire {FireTime}ms, adsFov {AdsZoomFov:0.#}";
148167
return $"{WeapClass} ({WeapType}), DMG: {Damage}-{MinDamage}, Clip: {ClipSize}, Fire: {FireType}";
149168
}
150169
}

Call of Duty FastFile Editor/Services/Iw4AssetBridge.cs

Lines changed: 448 additions & 0 deletions
Large diffs are not rendered by default.

Call of Duty FastFile Editor/UI/AssetSelectionDialog.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ public partial class AssetSelectionDialog : Form
3939
/// </summary>
4040
public bool LoadMenuFiles { get; private set; } = true;
4141

42+
/// <summary>
43+
/// Gets whether to load string tables.
44+
/// </summary>
45+
public bool LoadStringTables { get; private set; } = true;
46+
47+
/// <summary>
48+
/// Gets whether to load weapons.
49+
/// </summary>
50+
public bool LoadWeapons { get; private set; } = true;
51+
52+
/// <summary>
53+
/// Gets whether to load images.
54+
/// </summary>
55+
public bool LoadImages { get; private set; } = true;
56+
57+
/// <summary>
58+
/// Gets whether to load techsets.
59+
/// </summary>
60+
public bool LoadTechSets { get; private set; } = true;
61+
4262
/// <summary>
4363
/// Creates a new AssetSelectionDialog.
4464
/// </summary>
@@ -235,6 +255,18 @@ private void okButton_Click(object sender, EventArgs e)
235255
case "menufile":
236256
LoadMenuFiles = item.Checked;
237257
break;
258+
case "stringtable":
259+
LoadStringTables = item.Checked;
260+
break;
261+
case "weapon":
262+
LoadWeapons = item.Checked;
263+
break;
264+
case "image":
265+
LoadImages = item.Checked;
266+
break;
267+
case "techset":
268+
LoadTechSets = item.Checked;
269+
break;
238270
}
239271
}
240272
}

0 commit comments

Comments
 (0)