Parsec 1.2.0
dotnet add package Parsec --version 1.2.0
NuGet\Install-Package Parsec -Version 1.2.0
<PackageReference Include="Parsec" Version="1.2.0" />
<PackageVersion Include="Parsec" Version="1.2.0" />
<PackageReference Include="Parsec" />
paket add Parsec --version 1.2.0
#r "nuget: Parsec, 1.2.0"
#:package Parsec@1.2.0
#addin nuget:?package=Parsec&version=1.2.0
#tool nuget:?package=Parsec&version=1.2.0
Parsec
Parsec is a simple .NET parsing library for Shaiya file formats which provides easy to use APIs
for serialization and deserialization of the game's file formats, including JSON and CSV support.
Parsec works on any .NET Standard 2.0 compliant platform, including .NET 5+, .NET Framework 4.6.1+, .NET Core 2.0+, Unity and Godot.
Supported file formats
data.sah/safNpcQuest.SDataKillStatus.SDataCash.SDataSetItem.SDataDualLayerClothes.SDataGuildHouse.SDataMonster.SDataItem.SDataSkill.SDataNpcSkill.SDatasvmapWLDdgANI3DC3DO3DEMLTITMSMODEFTseffzonALTVAniMAniMLXMONCTLdat(Cloth/Emblem)DBItemData.SDataDBItemText.SDataDBMonsterData.SDataDBMonsterText.SDataDBSkillData.SDataDBSkillText.SDataDBItemSellData.SDataDBItemSellText.SDataDBNpcSkillData.SDataDBNpcSkillText.SDataDBDualLayerClothesData.SDataDBSetItemData.SDataDBSetItemText.SDataDBTransformModelData.SDataDBTransformWeaponModelData.SData
NOTE: These file formats have been tested on Episodes 5, 6 & 8. Other episodes might differ slightly and this library might not work with them.
Features
- Shaiya file formats parsing and serialization (including JSON and CSV support)
dataextraction, building and patchingSDataencryption/decryption
Getting Started
Prerequisites
.NET 8 SDK (recommended)or any.NET Standard 2.0compliant platform
Documentation
Reading
From a standalone file
// Read file with default episode (EP5) and encoding (ASCII)
var svmap = ParsecReader.FromFile<Svmap>("0.svmap");
// Read file with a specific episode and default encoding
var svmap = ParsecReader.FromFile<Svmap>("0.svmap", Episode.Ep6);
// Read file with a specific episode and a specific encoding
var windows1252Encoding = CodePagesEncodingProvider.Instance.GetEncoding(1252);
var svmap = ParsecReader.FromFile<Svmap>("0.svmap", Episode.Ep6, windows1252Encoding);
From data.saf
// Load data (sah and saf)
var data = new Data("data.sah", "data.saf");
// Find the file you want to read
var file = data.GetFile("world/0.svmap");
// Read and parse the file's content directly from the saf file
var svmap = ParsecReader.FromBuffer<Svmap>(file.Name, data.GetFileBuffer(file));
From a JSON file
Parsec supports importing a file as JSON, which can be later exported as its original format. The user must make sure
that the JSON file is properly formatted to match the JSON standards and contain all the fields present in the chosen
format.
// Read JSON file
var svmap = ParsecReader.FromJsonFile<Svmap>("0_svmap.json");
It is advised to first read a file from its original format, export it as JSON, edit it, and import it once again as JSON, so that all the original fields are present in the JSON file.
From a CSV file
Only some pre-Ep8 SData formats support reading as CSV.
All of the Episode 8 BinarySData formats have CSV support.
// Read csv file
var item = Item.FromCsv("Item.csv");
Encoding
When reading files, the default encoding is ASCII. If you want to read a file with a different encoding, you can
specify it as a parameter when calling the FromFile/Json/Csv methods.
Writing
Writing a standalone file
After modifying the file, you can save it in its original format by calling the Write method. If you specified
the episode and encoding when reading the file, you don't need to specify them again when writing it.
// Write file with previously defined episode and encoding (defined when reading the file)
svmap.Write("0_modified.svmap");
// Write file with a specific episode and default encoding
svmap.Write("0_modified.svmap", Episode.Ep6);
// Write file with a specific episode and a specific encoding
var windows1252Encoding = CodePagesEncodingProvider.Instance.GetEncoding(1252);
svmap.Write("0_modified.svmap", Episode.Ep6, windows1252Encoding);
Writing as JSON
Call the WriteJson method
svmap.WriteJson("map0.json");
Writing as CSV
Only some pre-Ep8 SData formats support exporting as CSV.
All of the Episode 8 BinarySData formats have CSV support.
// Write as csv
item.WriteCsv("Item.csv")
Encoding
When writing files, the default encoding is ASCII. If you want to write a file with a different encoding, you can
specify it as a parameter when calling the Write, WriteJson and WriteCsv methods.
Samples
sah/saf
Read and extract
// Load data (sah and saf)
var data = new Data("data.sah", "data.saf");
// Find the file you want to extract
var file = data.GetFile("world/2.svmap");
// Extract the selected file
data.Extract(file, "extracted");
Data/Patch building
// Create data from directory
DataBuilder.CreateFromDirectory("input", "output");
Patch
// Load target data and patch data
var data = new Data("data.sah", "data.saf");
var update = new Data("update.sah", "update.saf");
// Patch data
using (var dataPatcher = new DataPatcher())
{
dataPatcher.Patch(data, update);
}
SData
Encryption / Decryption
SData encryption is slightly different for pre-Ep8 and Ep8 SData files. The SDataVersion enum is used to specify
which version of SData is being encrypted (it's not necessary when decrypting);
// Encrypt
SData.EncryptFile("NpcQuest.SData", "NpcQuest.encrypted.SData", SDataVersion.Regular);
// Decrypt
SData.DecryptFile("NpcQuest.SData", "NpcQuest.decrypted.SData");
More examples can be found in the samples directory.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CsvHelper (>= 33.0.1)
- Microsoft.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 13.0.3)
- System.Text.Encoding.CodePages (>= 9.0.3)
-
net8.0
- CsvHelper (>= 33.0.1)
- Microsoft.CSharp (>= 4.7.0)
- Newtonsoft.Json (>= 13.0.3)
- System.Text.Encoding.CodePages (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.