Skip to content

Commit c365d5e

Browse files
committed
Put 'Clamp' back into 'Patcher' class.
1 parent a01542d commit c365d5e

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

LibIPS.NET/LibIPS.NET.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
<Compile Include="Patcher.cs" />
5050
<Compile Include="Properties\AssemblyInfo.cs" />
5151
<Compile Include="Studier.cs" />
52-
<Compile Include="Utils\MathHelper.cs" />
5352
<Compile Include="Utils\Reader.cs" />
5453
<Compile Include="Utils\Writer.cs" />
5554
</ItemGroup>

LibIPS.NET/Patcher.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void PatchStudy(Stream patch, Studier.IpsStudy study, Stream source, Stre
1515
{
1616
source.CopyTo(target);
1717
if (study.Error == Studier.IpsError.IpsInvalid) throw new Exceptions.IpsInvalidException();
18-
int outlen = (int)MathHelper.Clamp(study.OutlenMin, target.Length, study.OutlenMax);
18+
int outlen = (int)Clamp(study.OutlenMin, target.Length, study.OutlenMax);
1919
// Set target file length to new size.
2020
target.SetLength(outlen);
2121

@@ -52,5 +52,9 @@ public void Patch(Stream patch, Stream source, Stream target)
5252
Studier.IpsStudy study = studier.Study(patch);
5353
PatchStudy(patch, study, source, target);
5454
}
55+
public static long Clamp(long value, long minimum, long maximum)
56+
{
57+
return (value < minimum) ? minimum : (value > maximum) ? maximum : value;
58+
}
5559
}
5660
}

0 commit comments

Comments
 (0)