Skip to content

Commit

Permalink
Changes necessitated by excessively long path name of the Mirage_F1_R…
Browse files Browse the repository at this point in the history
…ADAR patch. Added support for patch extensions ".gpat" and ".grev"
  • Loading branch information
BlueFinBima committed May 17, 2024
1 parent be7b244 commit ffe8c64
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Patching/PatchFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal void Load(string patchPath)
_patches = _googleDiff.patch_fromText(patchText);
}

string revertPath = Path.ChangeExtension(patchPath, ".grevert");
string revertPath = Path.ChangeExtension(patchPath, Path.GetExtension(patchPath) == ".gpat" ? ".grev" : ".grevert");
if (!File.Exists(revertPath))
{
return;
Expand Down
4 changes: 2 additions & 2 deletions Patching/PatchList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ public static PatchList Load( string fromFolder)
{
return patches;
}
foreach (string patchPath in Directory.EnumerateFiles(fromFolder, "*.gpatch",
foreach (string patchPath in Directory.EnumerateFiles(fromFolder, "*.gpat??",
SearchOption.AllDirectories))
{
PatchFile patch = new PatchFile
{
TargetPath = patchPath.Substring(fromFolder.Length + 1,
patchPath.Length - (fromFolder.Length + 8))
patchPath.Length - (fromFolder.Length + Path.GetExtension(patchPath).Length))
};
patch.Load(patchPath);
patches.Add(patch);
Expand Down
16 changes: 10 additions & 6 deletions Patching/Patching.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9514,8 +9514,12 @@
<Content Include="Patches\DCS\002_009_00004_53627_00000\Viewports\mods\Aircraft\SA342\Cockpit\WP1\init.lua.grevert">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Common\ALR_300\Indicator\Baked\ALR_300_bake_init.lua.gpatch" />
<Content Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Common\ALR_300\Indicator\Baked\ALR_300_bake_init.lua.grevert" />
<Content Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Common\ALR_300\Indicator\Baked\ALR_300_bake_init.lua.gpatch">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Common\ALR_300\Indicator\Baked\ALR_300_bake_init.lua.grevert">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Templates\Patching\readme.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down Expand Up @@ -10392,12 +10396,12 @@
<Content Include="Templates\Patching\Additional Simulator Viewports\MIRAGE_F1_RWR.htpl">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Mirage-F1\Mirage-F1_Common\Radar_Cyrano_IV_legacy\Indicator\BakedGeneral\CyranoLegacy_bake_general_init.lua.gpatch">
<Content Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Mirage-F1\Mirage-F1_Common\Radar_Cyrano_IV_legacy\Indicator\BakedGeneral\CyranoLegacy_bake_general_init.lua.gpat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Mirage-F1\Mirage-F1_Common\Radar_Cyrano_IV_legacy\Indicator\BakedGeneral\CyranoLegacy_bake_general_init.lua.grevert">
</Content>
<Content Include="Patches\DCS\002_009_00004_53990_00000\Viewports\mods\Aircraft\Mirage-F1\Cockpit\Mirage-F1\Mirage-F1_Common\Radar_Cyrano_IV_legacy\Indicator\BakedGeneral\CyranoLegacy_bake_general_init.lua.grev">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</Content>
</ItemGroup>
<ItemGroup />
<Import Project="..\HeliosPlugin.targets" />
Expand Down
6 changes: 3 additions & 3 deletions Tools/TestApplyPatches/TestApplyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ private static void TestDcsPatches()
const string testsRoot = "..\\..\\..\\..\\Patches\\DCS\\002_005_005_41371\\";

diff_match_patch googleDiff = new diff_match_patch();
foreach (string testFilePath in Directory.EnumerateFiles(testsRoot, "*.gpatch", SearchOption.AllDirectories)
foreach (string testFilePath in Directory.EnumerateFiles(testsRoot, "*.gpat??", SearchOption.AllDirectories)
)
{
Debug.Assert(testFilePath.Contains(testsRoot));
string testFileRelative = testFilePath.Replace(testsRoot, "").Replace(".gpatch", "");
string testFileRelative = testFilePath.Replace(testsRoot, "").Replace(".gpatch", "").Replace(".gpat", "");

string source = ReadFile(Path.Combine(dcsRoot, testFileRelative));

Expand All @@ -87,7 +87,7 @@ private static void TestDcsPatches()

CheckApplied(googleDiff, testFilePath, patches, patched);

List<Patch> reverts = googleDiff.patch_fromText(ReadFile(testFilePath.Replace(".gpatch", ".grevert")));
List<Patch> reverts = googleDiff.patch_fromText(ReadFile(testFilePath.Replace(".gpatch", ".grevert").Replace(".gpat", ".grev")));
string reverted = ApplyPatches(googleDiff, patched, reverts);

CompareEquals(googleDiff, testFilePath, source, reverted);
Expand Down

0 comments on commit ffe8c64

Please sign in to comment.