Apply suggestions from upstream

This commit is contained in:
Sławomir Śpiewak 2024-07-31 16:32:35 +02:00
parent 3bd697577c
commit 6a90018798
4 changed files with 9 additions and 10 deletions

View File

@ -313,8 +313,8 @@ namespace GameRes.Formats.DxLib
internal static void Decrypt (byte[] data, int index, int count, long offset, byte[] key) internal static void Decrypt (byte[] data, int index, int count, long offset, byte[] key)
{ {
if (key.Length !=0) if (key.Length == 0)
{ return;
int key_pos = (int)(offset % key.Length); int key_pos = (int)(offset % key.Length);
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
@ -322,7 +322,6 @@ namespace GameRes.Formats.DxLib
if (key.Length == key_pos) if (key.Length == key_pos)
key_pos = 0; key_pos = 0;
} }
}
} }
public override ResourceScheme Scheme public override ResourceScheme Scheme

View File

@ -26,6 +26,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
using GameRes.Utility; using GameRes.Utility;
@ -183,8 +184,8 @@ namespace GameRes.Formats.DxLib
oddString = string.Concat(keyword.Where((c, i) => i % 2 == 0)); oddString = string.Concat(keyword.Where((c, i) => i % 2 == 0));
evenString = string.Concat(keyword.Where((c, i) => (i+1) % 2 == 0)); evenString = string.Concat(keyword.Where((c, i) => (i+1) % 2 == 0));
UInt32 crc_0, crc_1; UInt32 crc_0, crc_1;
crc_0 = Crc32.Compute(Encodings.ASCII.GetBytes(oddString), 0, oddString.Length); crc_0 = Crc32.Compute(Encoding.ASCII.GetBytes(oddString), 0, oddString.Length);
crc_1 = Crc32.Compute(Encodings.ASCII.GetBytes(evenString), 0, evenString.Length); crc_1 = Crc32.Compute(Encoding.ASCII.GetBytes(evenString), 0, evenString.Length);
byte[] crc_0_Bytes = BitConverter.GetBytes(crc_0),crc_1_Bytes=BitConverter.GetBytes(crc_1); byte[] crc_0_Bytes = BitConverter.GetBytes(crc_0),crc_1_Bytes=BitConverter.GetBytes(crc_1);
key[0] = crc_0_Bytes[0]; key[0] = crc_0_Bytes[0];
key[1] = crc_0_Bytes[1]; key[1] = crc_0_Bytes[1];

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// Ten kod został wygenerowany przez narzędzie. // This code was generated by a tool.
// Wersja wykonawcza:4.0.30319.42000 // Runtime Version:4.0.30319.42000
// //
// Zmiany w tym pliku mogą spowodować nieprawidłowe zachowanie i zostaną utracone, jeśli // Changes to this file may cause incorrect behavior and will be lost if
// kod zostanie ponownie wygenerowany. // the code is regenerated.
// </auto-generated> // </auto-generated>
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -34,7 +34,6 @@ namespace GameRes
public static class Encodings public static class Encodings
{ {
public static readonly Encoding cp932 = Encoding.GetEncoding(932); public static readonly Encoding cp932 = Encoding.GetEncoding(932);
public static readonly Encoding ASCII = Encoding.ASCII;
public static Encoding WithFatalFallback (this Encoding enc) public static Encoding WithFatalFallback (this Encoding enc)
{ {