diff --git a/src/Parsec/Common/Episode.cs b/src/Parsec/Common/Episode.cs
index 38741b3c..e9e1c0fb 100644
--- a/src/Parsec/Common/Episode.cs
+++ b/src/Parsec/Common/Episode.cs
@@ -2,10 +2,17 @@
public enum Episode
{
- Unknown,
- EP4,
- EP5,
- EP6,
- EP7,
- EP8
+ Unknown = 0,
+
+ EP4 = 40,
+
+ EP5 = 50,
+
+ EP6 = 60,
+
+ EP6_4 = 64,
+
+ EP7 = 70,
+
+ EP8 = 80
}
diff --git a/src/Parsec/Shaiya/Item/Item.cs b/src/Parsec/Shaiya/Item/Item.cs
index cf922b23..a4fe7eef 100644
--- a/src/Parsec/Shaiya/Item/Item.cs
+++ b/src/Parsec/Shaiya/Item/Item.cs
@@ -30,6 +30,11 @@ protected override void Write(SBinaryWriter binaryWriter)
/// instance
public static Item FromCsv(string csvPath, Episode episode, Encoding? encoding = null)
{
+ if (episode >= Episode.EP8)
+ {
+ throw new Exception("Item format is not supported for EP8 and above, use ItemData instead.");
+ }
+
encoding ??= Encoding.ASCII;
// Read item definitions from csv
diff --git a/src/Parsec/Shaiya/Item/ItemDefinition.cs b/src/Parsec/Shaiya/Item/ItemDefinition.cs
index 9858d8e3..ce591f26 100644
--- a/src/Parsec/Shaiya/Item/ItemDefinition.cs
+++ b/src/Parsec/Shaiya/Item/ItemDefinition.cs
@@ -55,12 +55,10 @@ public sealed class ItemDefinition : ISerializable
public ushort ReqWis { get; set; }
- public ushort ReqLuc { get; set; }
+ public uint ReqLuc { get; set; }
public ushort ReqVg { get; set; }
- public ushort Unknown { get; set; }
-
public byte ReqOg { get; set; }
public byte ReqIg { get; set; }
@@ -185,18 +183,20 @@ public void Read(SBinaryReader binaryReader)
ReqRec = binaryReader.ReadUInt16();
ReqInt = binaryReader.ReadUInt16();
ReqWis = binaryReader.ReadUInt16();
- ReqLuc = binaryReader.ReadUInt16();
- ReqVg = binaryReader.ReadUInt16();
- if (episode >= Episode.EP6)
+ if (episode >= Episode.EP6_4)
+ {
+ ReqLuc = binaryReader.ReadUInt32();
+ }
+ else
{
- Unknown = binaryReader.ReadUInt16();
+ ReqLuc = binaryReader.ReadUInt16();
}
+ ReqVg = binaryReader.ReadUInt16();
ReqOg = binaryReader.ReadByte();
ReqIg = binaryReader.ReadByte();
-
if (episode <= Episode.EP5)
{
Range = binaryReader.ReadByte();
@@ -286,20 +286,23 @@ public void Write(SBinaryWriter binaryWriter)
binaryWriter.Write(ReqRec);
binaryWriter.Write(ReqInt);
binaryWriter.Write(ReqWis);
- binaryWriter.Write(ReqLuc);
- binaryWriter.Write(ReqVg);
- if (episode >= Episode.EP6)
+ if (episode >= Episode.EP6_4)
{
- binaryWriter.Write(Unknown);
+ binaryWriter.Write(ReqLuc);
+ }
+ else
+ {
+ binaryWriter.Write((ushort)ReqLuc);
}
+ binaryWriter.Write(ReqVg);
binaryWriter.Write(ReqOg);
binaryWriter.Write(ReqIg);
if (episode <= Episode.EP5)
{
- binaryWriter.Write(Range);
+ binaryWriter.Write((byte)Range);
}
else
{
diff --git a/tests/Parsec.Tests/Parsec.Tests.csproj b/tests/Parsec.Tests/Parsec.Tests.csproj
index 2ca09b84..08218c25 100644
--- a/tests/Parsec.Tests/Parsec.Tests.csproj
+++ b/tests/Parsec.Tests/Parsec.Tests.csproj
@@ -4,18 +4,18 @@
false
- net7.0
+ net8.0
-
-
-
-
+
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
@@ -710,7 +710,7 @@
PreserveNewest
-
+
PreserveNewest
@@ -815,5 +815,11 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
diff --git a/tests/Parsec.Tests/Shaiya/Item/ItemEp6_1251.SData b/tests/Parsec.Tests/Shaiya/Item/ItemEp64_1251.SData
similarity index 100%
rename from tests/Parsec.Tests/Shaiya/Item/ItemEp6_1251.SData
rename to tests/Parsec.Tests/Shaiya/Item/ItemEp64_1251.SData
diff --git a/tests/Parsec.Tests/Shaiya/Item/ItemTests.cs b/tests/Parsec.Tests/Shaiya/Item/ItemTests.cs
index 38337efb..a9179199 100644
--- a/tests/Parsec.Tests/Shaiya/Item/ItemTests.cs
+++ b/tests/Parsec.Tests/Shaiya/Item/ItemTests.cs
@@ -20,28 +20,40 @@ public void ItemEp5CsvTest()
}
[Fact]
- public void ItemEp6CsvTest()
+ public void ItemEp5ReadWriteTest()
{
- const string filePath = "Shaiya/Item/ItemEp6.SData";
- const string csvPath = "Shaiya/Item/ItemEp6.SData.csv";
+ const string filePath = "Shaiya/Item/ItemEp5.SData";
+ const string outputPath = "Shaiya/Item/ItemEp5.written.SData";
+
+ var item = ParsecReader.FromFile(filePath, Episode.EP5, TestEncodings.Encoding1252);
+ item.WriteEncrypted(outputPath);
+
+ Assert.Equal(FileHash.Checksum(filePath), FileHash.Checksum(outputPath));
+ }
+
+ [Fact]
+ public void ItemEp64CsvTest()
+ {
+ const string filePath = "Shaiya/Item/Item_ES_ps0224.SData";
+ const string csvPath = "Shaiya/Item/Item_ES_ps0224.SData.csv";
- var item = ParsecReader.FromFile(filePath, Episode.EP6);
+ var item = ParsecReader.FromFile(filePath, Episode.EP6_4, TestEncodings.Encoding1252);
item.WriteCsv(csvPath);
- var itemFromCsv = Parsec.Shaiya.Item.Item.FromCsv(csvPath, Episode.EP6);
- Assert.Equal(item.GetBytes(Episode.EP6), itemFromCsv.GetBytes(Episode.EP6));
+ var itemFromCsv = Parsec.Shaiya.Item.Item.FromCsv(csvPath, Episode.EP6_4, TestEncodings.Encoding1252);
+ Assert.Equal(item.GetBytes(Episode.EP6_4, TestEncodings.Encoding1252), itemFromCsv.GetBytes(Episode.EP6_4, TestEncodings.Encoding1252));
}
[Fact]
- public void ItemEp6Csv_EncodingTest()
+ public void ItemEp64Csv_EncodingTest()
{
- const string filePath = "Shaiya/Item/ItemEp6_1251.SData";
- const string csvPath = "Shaiya/Item/ItemEp6_1252.SData.csv";
+ const string filePath = "Shaiya/Item/ItemEp64_1251.SData";
+ const string csvPath = "Shaiya/Item/ItemEp64_1251.SData.csv";
var encoding = TestEncodings.Encoding1251;
- var item = ParsecReader.FromFile(filePath, Episode.EP6, encoding);
+ var item = ParsecReader.FromFile(filePath, Episode.EP6_4, encoding);
item.WriteCsv(csvPath, encoding);
- var itemFromCsv = Parsec.Shaiya.Item.Item.FromCsv(csvPath, Episode.EP6, encoding);
- Assert.Equal(item.GetBytes(Episode.EP6), itemFromCsv.GetBytes(Episode.EP6));
+ var itemFromCsv = Parsec.Shaiya.Item.Item.FromCsv(csvPath, Episode.EP6_4, encoding);
+ Assert.Equal(item.GetBytes(Episode.EP6_4), itemFromCsv.GetBytes(Episode.EP6_4));
}
[Fact]
diff --git a/tests/Parsec.Tests/Shaiya/Item/Item_ES_ps0224.SData b/tests/Parsec.Tests/Shaiya/Item/Item_ES_ps0224.SData
new file mode 100644
index 00000000..80e7d25c
Binary files /dev/null and b/tests/Parsec.Tests/Shaiya/Item/Item_ES_ps0224.SData differ
diff --git a/tests/Parsec.Tests/Shaiya/Item/Item_US_ps0216.SData b/tests/Parsec.Tests/Shaiya/Item/Item_US_ps0216.SData
new file mode 100644
index 00000000..66cfe7f2
Binary files /dev/null and b/tests/Parsec.Tests/Shaiya/Item/Item_US_ps0216.SData differ
diff --git a/tests/Parsec.Tests/Shaiya/SData/SDataTests.cs b/tests/Parsec.Tests/Shaiya/SData/SDataTests.cs
index e2cdf544..f6257eec 100644
--- a/tests/Parsec.Tests/Shaiya/SData/SDataTests.cs
+++ b/tests/Parsec.Tests/Shaiya/SData/SDataTests.cs
@@ -60,7 +60,7 @@ public void SDataDecryptionTest()
const string encryptedOutputPath = "Shaiya/SData/ItemEp6.encrypted.SData";
const string decryptedOutputPath = "Shaiya/SData/ItemEp6.decrypted.SData";
- var item = ParsecReader.FromFile(EncryptedSDataFilePath, Episode.EP6);
+ var item = ParsecReader.FromFile(EncryptedSDataFilePath, Episode.EP6_4);
item.WriteEncrypted(encryptedOutputPath);
item.WriteDecrypted(decryptedOutputPath);