Skip to content

Commit 4bc9325

Browse files
committed
Moved constants into 'Patcher().'
1 parent b28a67a commit 4bc9325

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

LibIPS.NET/Creator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void Create(Stream source, Stream target, ref Stream patch)
121121
}
122122

123123
// Avoid premature EOF.
124-
if (offset == Studier.EndOfFile)
124+
if (offset == Patcher.EndOfFile)
125125
{
126126
offset--;
127127
thislen++;

LibIPS.NET/Patcher.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ namespace CodeIsle
88
{
99
class Patcher
1010
{
11+
public const string PatchText = "PATCH";
12+
public const int EndOfFile = 0x454F46;
13+
1114
public void PatchStudy(Stream patch, Studier.IpsStudy study, Stream source, Stream target)
1215
{
1316
source.CopyTo(target);
@@ -19,7 +22,7 @@ public void PatchStudy(Stream patch, Studier.IpsStudy study, Stream source, Stre
1922
// Skip PATCH text.
2023
patch.Seek(5, SeekOrigin.Begin);
2124
int offset = Reader.Read24(patch);
22-
while (offset != Studier.EndOfFile)
25+
while (offset != EndOfFile)
2326
{
2427
int size = Reader.Read16(patch);
2528

LibIPS.NET/Studier.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ namespace CodeIsle
88
{
99
class Studier
1010
{
11-
public const string PatchText = "PATCH";
12-
public const int EndOfFile = 0x454F46;
1311
public enum IpsError
1412
{
1513
// Patch applied or created successfully.
@@ -41,9 +39,9 @@ public IpsStudy Study(Stream patch)
4139
if (patch.Length < 8) return study;
4240

4341
// If 'PATCH' text was not found, return IPS was invalid error.
44-
byte[] header = new byte[PatchText.Length];
45-
patch.Read(header, 0, PatchText.Length);
46-
if (!Enumerable.SequenceEqual(header, System.Text.Encoding.ASCII.GetBytes(PatchText))) return study;
42+
byte[] header = new byte[Patcher.PatchText.Length];
43+
patch.Read(header, 0, Patcher.PatchText.Length);
44+
if (!Enumerable.SequenceEqual(header, System.Text.Encoding.ASCII.GetBytes(Patcher.PatchText))) return study;
4745

4846
int offset = Reader.Read24(patch);
4947
int outlen = 0;
@@ -52,7 +50,7 @@ public IpsStudy Study(Stream patch)
5250
bool w_scrambled = false;
5351
bool w_notthis = false;
5452

55-
while (offset != EndOfFile)
53+
while (offset != Patcher.EndOfFile)
5654
{
5755
int size = Reader.Read16(patch);
5856

0 commit comments

Comments
 (0)