Skip to content

Commit 869f758

Browse files
Minor improvements
1 parent 3e4f0ae commit 869f758

File tree

9 files changed

+25
-13
lines changed

9 files changed

+25
-13
lines changed

CpkTools/CpkTools.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
11+
<PackageReference Include="System.Text.Encoding.CodePages" Version="10.0.1" />
1112
</ItemGroup>
1213

1314
</Project>

CpkTools/Model/Cpk.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Buffers.Binary;
2+
using System.Numerics;
23
using System.Text;
34
using CpkTools.Comparers;
45
using CpkTools.Endian;
@@ -603,7 +604,7 @@ private static ColumnData<T> GetColumnData<T>(Utf utf, int rowIndex, string colu
603604
return new ColumnData<T>(default!, -1, null);
604605
}
605606

606-
private static DataInfo<T> GetFileSizeInfo<T>(ColumnData<byte[]> inputData) {
607+
private static DataInfo<T> GetFileSizeInfo<T>(ColumnData<byte[]> inputData) where T : INumber<T> {
607608
var result = new DataInfo<T>();
608609

609610
if (inputData.Value == null)
@@ -623,7 +624,7 @@ private static DataInfo<T> GetFileSizeInfo<T>(ColumnData<byte[]> inputData) {
623624

624625
var extractSize = GetColumnData<T>(utfData, i, "ExtractSize");
625626

626-
if (extractSize.Value != null) {
627+
if (extractSize.Value != default) {
627628
extractSize.Position += inputData.Position;
628629

629630
result.CSizeTable.Add(id, extractSize);

CpkTools/Tools.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
namespace CpkTools;
55

66
public static class Tools {
7+
static Tools() {
8+
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
9+
}
10+
711
public static string ReadCString(EndianReader reader, int maxLength = -1, long lOffset = -1, Encoding? enc = null) {
812
enc ??= Encoding.GetEncoding(932);
913

ParLibrary/Converter/ParArchiveReader.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ public class ParArchiveReader : IConverter<BinaryFormat, NodeContainerFormat> {
2121
/// <summary>
2222
/// Initializes a new instance of the <see cref="ParArchiveReader"/> class.
2323
/// </summary>
24-
public ParArchiveReader() { }
24+
public ParArchiveReader() {
25+
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
26+
}
2527

2628
/// <summary>
2729
/// Initializes a new instance of the <see cref="ParArchiveReader"/> class.
2830
/// </summary>
2931
/// <param name="parameters">The parameters.</param>
30-
public ParArchiveReader(ParArchiveReaderParameters parameters) {
32+
public ParArchiveReader(ParArchiveReaderParameters parameters) : this() {
3133
_parameters = parameters;
3234
}
3335

ParLibrary/Converter/ParArchiveWriter.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,19 @@ public class ParArchiveWriter : IConverter<NodeContainerFormat, ParFile> {
4444
/// Occurs after the file is compressed.
4545
/// </summary>
4646
public static event NodeEventHandler FileCompressed;
47-
47+
4848
/// <summary>
4949
/// Initializes a new instance of the <see cref="ParArchiveWriter"/> class.
5050
/// </summary>
51-
public ParArchiveWriter() { }
51+
public ParArchiveWriter() {
52+
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
53+
}
5254

5355
/// <summary>
5456
/// Initializes a new instance of the <see cref="ParArchiveWriter"/> class.
5557
/// </summary>
5658
/// <param name="parameters">The parameters.</param>
57-
public ParArchiveWriter(ParArchiveWriterParameters parameters) {
59+
public ParArchiveWriter(ParArchiveWriterParameters parameters) : this() {
5860
_parameters = parameters;
5961
}
6062

ParLibrary/ParLibrary.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12+
<PackageReference Include="System.Text.Encoding.CodePages" Version="10.0.1" />
1213
<PackageReference Include="Yarhl" Version="4.0.0" />
1314
</ItemGroup>
1415

Scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ declare -A TARGET_ARGS_PREVIEW=(
4444
["windows-slim"]="win-x64;--no-self-contained -p:BuildSuffix=windows-slim-preview"
4545
)
4646

47-
if [ "$IS_PREVIEW" = true ]; then
47+
if [[ "$IS_PREVIEW" = true ]]; then
4848
declare -n TARGET_ARGS=TARGET_ARGS_PREVIEW;
4949
else
5050
declare -n TARGET_ARGS=TARGET_ARGS_PROD;
@@ -67,7 +67,7 @@ ASSET_URL=$(curl -s "${API_URL}" | jq -r \
6767
')
6868

6969
if [[ -z "${ASSET_URL}" ]]; then
70-
echo "ERROR: No assets matching pattern '${PATTERN}' found."
70+
echo "ERROR: No assets matching pattern '${PATTERN}' found." >&2
7171
exit 1
7272
fi
7373

Scripts/package.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ for TARGET in "${SRMM_BUILD_DIRS[@]}"; do
8181
fi
8282

8383
# Create only for .zip, as that's universally available
84-
if [ "$IS_PREVIEW" = false ]; then
84+
if [[ "$IS_PREVIEW" = false ]]; then
8585
netsparkle-generate-appcast \
8686
-a "${APPCAST_OUTPUT_DIR}" \
8787
--single-file "${SRMM_OUTPUT_DIR}/${OUTPUT_FILE_BASE}.zip" \
@@ -96,7 +96,7 @@ for TARGET in "${SRMM_BUILD_DIRS[@]}"; do
9696

9797
done
9898

99-
if [ "$IS_PREVIEW" = false ]; then
99+
if [[ "$IS_PREVIEW" = false ]]; then
100100
for TARGET in "${UPDATER_BUILD_DIRS[@]}"; do
101101
DIR="${UPDATER_SELECTOR}/${TARGET}"
102102
OUTPUT_TARGET_STR=$(echo "${TARGET}" | sed -e "s/\b\(.\)/\u\1/g") # Capitalizes each target word: linux-slim -> Linux-Slim

ShinRyuModManager-CE/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.IO.Compression;
33
using Avalonia;
44
using Avalonia.Svg.Skia;
5+
using CpkTools.Model;
56
using IniParser;
67
using IniParser.Model;
78
using Serilog;
@@ -83,7 +84,7 @@ private static void Main(string[] args) {
8384
} else {
8485
Log.Information("Shin Ryu Mod Manager CLI Mode Start");
8586

86-
MainCLI(args).GetAwaiter().GetResult();
87+
MainCli(args).GetAwaiter().GetResult();
8788
}
8889
}
8990

@@ -97,7 +98,7 @@ private static AppBuilder BuildAvaloniaApp() {
9798
.LogToTrace();
9899
}
99100

100-
private static async Task MainCLI(string[] args) {
101+
private static async Task MainCli(string[] args) {
101102
Log.Information("Shin Ryu Mod Manager-CE v{Version}", AssemblyVersion.GetVersion());
102103
Log.Information("By TheTrueColonel (a port of SRMM Studio's work)");
103104

0 commit comments

Comments
 (0)