mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-23 19:34:15 +08:00
(RepiPack): only ASCII characters supposed to be low-cased.
This commit is contained in:
parent
9d2eb27383
commit
0bb857876b
@ -47,13 +47,12 @@ namespace GameRes.Formats.Littlewitch
|
|||||||
|
|
||||||
public byte[] CreateKey ()
|
public byte[] CreateKey ()
|
||||||
{
|
{
|
||||||
var name_bytes = Encodings.cp932.GetBytes (Name.ToLowerInvariant());
|
var name_bytes = DatOpener.ToLowerAscii (Name);
|
||||||
int name_length = name_bytes.Length;
|
int name_length = name_bytes.Length;
|
||||||
var md5 = new MD5();
|
var md5 = new MD5();
|
||||||
Array.Reverse (name_bytes);
|
Array.Reverse (name_bytes);
|
||||||
var key = new byte[1024];
|
var key = new byte[1024];
|
||||||
int key_pos = 0;
|
int key_pos = 0;
|
||||||
md5.Initialize();
|
|
||||||
for (int i = 0; i < 64; ++i)
|
for (int i = 0; i < 64; ++i)
|
||||||
{
|
{
|
||||||
int name_pos = i % name_length;
|
int name_pos = i % name_length;
|
||||||
@ -209,7 +208,7 @@ namespace GameRes.Formats.Littlewitch
|
|||||||
{
|
{
|
||||||
var md5 = new MD5();
|
var md5 = new MD5();
|
||||||
FormatCatalog.Instance.ReadFileList (ListFileName, name => {
|
FormatCatalog.Instance.ReadFileList (ListFileName, name => {
|
||||||
var name_bytes = Encodings.cp932.GetBytes (name.ToLowerInvariant());
|
var name_bytes = ToLowerAscii (name);
|
||||||
var hash = md5.ComputeHash (name_bytes);
|
var hash = md5.ComputeHash (name_bytes);
|
||||||
dict[hash] = name;
|
dict[hash] = name;
|
||||||
});
|
});
|
||||||
@ -220,6 +219,20 @@ namespace GameRes.Formats.Littlewitch
|
|||||||
}
|
}
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static byte[] ToLowerAscii (string text)
|
||||||
|
{
|
||||||
|
var text_bytes = Encodings.cp932.GetBytes (text);
|
||||||
|
for (int i = 0; i < text_bytes.Length; ++i)
|
||||||
|
{
|
||||||
|
byte c = text_bytes[i];
|
||||||
|
if (c >= 'A' && c <= 'Z')
|
||||||
|
text_bytes[i] += 0x20;
|
||||||
|
else if (c > 0x7F && c < 0xA1 || c > 0xDF)
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
return text_bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class Md5Comparer : IEqualityComparer<byte[]>
|
internal class Md5Comparer : IEqualityComparer<byte[]>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user