Skip to content

Commit

Permalink
Reading: remove params options, use Episode instead
Browse files Browse the repository at this point in the history
  • Loading branch information
matigramirez committed Sep 25, 2023
1 parent fdc780d commit e8fa45d
Show file tree
Hide file tree
Showing 36 changed files with 246 additions and 370 deletions.
54 changes: 0 additions & 54 deletions src/Parsec/Cryptography/SahCrypto.cs

This file was deleted.

69 changes: 35 additions & 34 deletions src/Parsec/Readers/Reader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Text;
using Newtonsoft.Json;
using Parsec.Common;
using Parsec.Extensions;
using Parsec.Helpers;
using Parsec.Shaiya.Core;
Expand All @@ -13,71 +14,71 @@ public static class Reader
/// Reads a shaiya file format from a file
/// </summary>
/// <param name="path">File path</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <typeparam name="T">Shaiya File Format Type</typeparam>
/// <returns>T instance</returns>
public static T ReadFromFile<T>(string path, params object[] options) where T : FileBase, new() =>
FileBase.ReadFromFile<T>(path, options);
public static T ReadFromFile<T>(string path, Episode episode = Episode.EP5) where T : FileBase, new() =>
FileBase.ReadFromFile<T>(path, episode);

/// <summary>
/// Reads a shaiya file format from a file
/// </summary>
/// <param name="path">File path</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <typeparam name="T">Shaiya File Format Type</typeparam>
public static Task<T> ReadFromFileAsync<T>(string path, params object[] options) where T : FileBase, new() =>
Task.FromResult(ReadFromFile<T>(path, options));
public static Task<T> ReadFromFileAsync<T>(string path, Episode episode = Episode.EP5) where T : FileBase, new() =>
Task.FromResult(ReadFromFile<T>(path, episode));

/// <summary>
/// Reads the shaiya file format from a file
/// </summary>
/// <param name="path">File path</param>
/// <param name="type">FileBase child type to be read</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <returns>FileBase instance</returns>
public static FileBase ReadFromFile(string path, Type type, params object[] options) =>
FileBase.ReadFromFile(path, type, options);
public static FileBase ReadFromFile(string path, Type type, Episode episode = Episode.EP5) =>
FileBase.ReadFromFile(path, type, episode);

/// <summary>
/// Reads the shaiya file format from a file
/// </summary>
/// <param name="path">File path</param>
/// <param name="type">FileBase child type to be read</param>
/// <param name="options">Array of reading options</param>
public static Task<FileBase> ReadFromFileAsync(string path, Type type, params object[] options) =>
Task.FromResult(ReadFromFile(path, type, options));
/// <param name="episode">File episode</param>
public static Task<FileBase> ReadFromFileAsync(string path, Type type, Episode episode = Episode.EP5) =>
Task.FromResult(ReadFromFile(path, type, episode));

/// <summary>
/// Reads a shaiya file format from a buffer (byte array)
/// </summary>
/// <param name="name">File name</param>
/// <param name="buffer">File buffer</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <typeparam name="T">Shaiya File Format Type</typeparam>
/// <returns>T instance</returns>
public static T ReadFromBuffer<T>(string name, byte[] buffer, params object[] options) where T : FileBase, new() =>
FileBase.ReadFromBuffer<T>(name, buffer, options);
public static T ReadFromBuffer<T>(string name, byte[] buffer, Episode episode = Episode.EP5) where T : FileBase, new() =>
FileBase.ReadFromBuffer<T>(name, buffer, episode);


/// <summary>
/// Reads a shaiya file format from a buffer (byte array)
/// </summary>
/// <param name="name">File name</param>
/// <param name="buffer">File buffer</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <typeparam name="T">Shaiya File Format Type</typeparam>
public static Task<T> ReadFromBufferAsync<T>(string name, byte[] buffer, params object[] options) where T : FileBase, new() =>
Task.FromResult(ReadFromBuffer<T>(name, buffer, options));
public static Task<T> ReadFromBufferAsync<T>(string name, byte[] buffer, Episode episode = Episode.EP5) where T : FileBase, new() =>
Task.FromResult(ReadFromBuffer<T>(name, buffer, episode));

/// <summary>
/// Reads the shaiya file format from a buffer (byte array)
/// </summary>
/// <param name="name">File name</param>
/// <param name="buffer">File buffer</param>
/// <param name="type">FileBase child type to be read</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <returns>FileBase instance</returns>
public static FileBase ReadFromBuffer(string name, byte[] buffer, Type type, params object[] options) =>
public static FileBase ReadFromBuffer(string name, byte[] buffer, Type type, Episode episode = Episode.EP5) =>
FileBase.ReadFromBuffer(name, buffer, type);

/// <summary>
Expand All @@ -86,8 +87,8 @@ public static FileBase ReadFromBuffer(string name, byte[] buffer, Type type, par
/// <param name="name">File name</param>
/// <param name="buffer">File buffer</param>
/// <param name="type">FileBase child type to be read</param>
/// <param name="options">Array of reading options</param>
public static Task<FileBase> ReadFromBufferAsync(string name, byte[] buffer, Type type, params object[] options) =>
/// <param name="episode">File episode</param>
public static Task<FileBase> ReadFromBufferAsync(string name, byte[] buffer, Type type, Episode episode = Episode.EP5) =>
Task.FromResult(ReadFromBuffer(name, buffer, type));

/// <summary>
Expand Down Expand Up @@ -219,38 +220,38 @@ public static Task<FileBase> ReadFromJsonAsync(string name, string jsonText, Typ
/// </summary>
/// <param name="data"><see cref="Data"/> instance</param>
/// <param name="file"><see cref="SFile"/> instance</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <returns>FileBase instance</returns>
public static T ReadFromData<T>(Data data, SFile file, params object[] options) where T : FileBase, new() =>
FileBase.ReadFromData<T>(data, file, options);
public static T ReadFromData<T>(Data data, SFile file, Episode episode = Episode.EP5) where T : FileBase, new() =>
FileBase.ReadFromData<T>(data, file, episode);

/// <summary>
/// Reads the shaiya file format from a buffer (byte array) within a <see cref="Data"/> instance
/// </summary>
/// <param name="data"><see cref="Data"/> instance</param>
/// <param name="file"><see cref="SFile"/> instance</param>
/// <param name="options">Array of reading options</param>
public static Task<T> ReadFromDataAsync<T>(Data data, SFile file, params object[] options) where T : FileBase, new() =>
Task.FromResult(ReadFromData<T>(data, file, options));
/// <param name="episode">File episode</param>
public static Task<T> ReadFromDataAsync<T>(Data data, SFile file, Episode episode = Episode.EP5) where T : FileBase, new() =>
Task.FromResult(ReadFromData<T>(data, file, episode));

/// <summary>
/// Reads the shaiya file format from a buffer (byte array) within a <see cref="Data"/> instance
/// </summary>
/// <param name="data"><see cref="Data"/> instance</param>
/// <param name="file"><see cref="SFile"/> instance</param>
/// <param name="type">FileBase child type to be read</param>
/// <param name="options">Array of reading options</param>
/// <param name="episode">File episode</param>
/// <returns>FileBase instance</returns>
public static FileBase ReadFromData(Data data, SFile file, Type type, params object[] options) =>
FileBase.ReadFromData(data, file, type, options);
public static FileBase ReadFromData(Data data, SFile file, Type type, Episode episode = Episode.EP5) =>
FileBase.ReadFromData(data, file, type, episode);

/// <summary>
/// Reads the shaiya file format from a buffer (byte array) within a <see cref="Data"/> instance
/// </summary>
/// <param name="data"><see cref="Data"/> instance</param>
/// <param name="file"><see cref="SFile"/> instance</param>
/// <param name="type">FileBase child type to be read</param>
/// <param name="options">Array of reading options</param>
public static Task<FileBase> ReadFromDataAsync(Data data, SFile file, Type type, params object[] options) =>
Task.FromResult(ReadFromData(data, file, type, options));
/// <param name="episode">File episode</param>
public static Task<FileBase> ReadFromDataAsync(Data data, SFile file, Type type, Episode episode = Episode.EP5) =>
Task.FromResult(ReadFromData(data, file, type, episode));
}
2 changes: 1 addition & 1 deletion src/Parsec/Shaiya/3DE/_3DE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public sealed class _3DE : FileBase
/// Reads the .3DE file from the file buffer. This format requires a manually defined Read method because of its "complexity" when
/// dealing with the vertex translation frames.
/// </summary>
public override void Read(params object[] options)
public override void Read()
{
Texture = _binaryReader.ReadString();

Expand Down
2 changes: 1 addition & 1 deletion src/Parsec/Shaiya/ALT/ALT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public sealed class ALT : FileBase

public override string Extension => ".ALT";

public override void Read(params object[] options)
public override void Read()
{
Signature = _binaryReader.ReadString(3);

Expand Down
2 changes: 1 addition & 1 deletion src/Parsec/Shaiya/Cloak/ClothTexture/CTL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public CTL()
[JsonIgnore]
public override string Extension => "CTL";

public override void Read(params object[] options)
public override void Read()
{
int textureCount = _binaryReader.Read<int>();
for (int i = 0; i < textureCount; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/Parsec/Shaiya/Cloak/Emblem/EmblemDat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public EmblemDat()
[JsonIgnore]
public override string Extension => "dat";

public override void Read(params object[] options)
public override void Read()
{
int textureCount = _binaryReader.Read<int>();
for (int i = 0; i < textureCount; i++)
Expand Down
Loading

0 comments on commit e8fa45d

Please sign in to comment.