mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 13:45:34 +08:00
use ArView.ReadBytes and Binary.RotR shortcut methods.
This commit is contained in:
parent
f502e9578c
commit
7756f8d8e8
@ -2,7 +2,7 @@
|
||||
//! \date Wed Feb 25 20:28:14 2015
|
||||
//! \brief Nitro+ PAK archives implementation.
|
||||
//
|
||||
// Copyright (C) 2015 by morkt
|
||||
// Copyright (C) 2015-2016 by morkt
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to
|
||||
@ -125,8 +125,7 @@ namespace GameRes.Formats.NitroPlus
|
||||
uint size_xor = file.View.ReadUInt32 (0x104);
|
||||
if (0x64 != size_xor)
|
||||
return null;
|
||||
byte[] name_buf = new byte[0x100];
|
||||
file.View.Read (4, name_buf, 0, 0x100);
|
||||
byte[] name_buf = file.View.ReadBytes (4, 0x100);
|
||||
int name_len = 0;
|
||||
for (int i = 0; i < name_buf.Length; ++i)
|
||||
{
|
||||
@ -223,13 +222,12 @@ namespace GameRes.Formats.NitroPlus
|
||||
uint enc_size = Math.Min (entry.Size, 0x10u);
|
||||
if (0 == enc_size)
|
||||
return Stream.Null;
|
||||
var buf = new byte[enc_size];
|
||||
arc.File.View.Read (entry.Offset, buf, 0, enc_size);
|
||||
var buf = arc.File.View.ReadBytes (entry.Offset, enc_size);
|
||||
uint key = entry.Key;
|
||||
for (int i = 0; i < buf.Length; ++i)
|
||||
{
|
||||
buf[i] ^= (byte)key;
|
||||
key = key >> 8 | key << 24;
|
||||
key = Binary.RotR (key, 8);
|
||||
}
|
||||
if (enc_size == entry.Size)
|
||||
return new MemoryStream (buf, false);
|
||||
|
@ -67,8 +67,8 @@ namespace GameRes.Formats.Xuse
|
||||
if (!IsSaneCount (count))
|
||||
return null;
|
||||
|
||||
byte[] title = new byte[0x40];
|
||||
if (0x40 != file.View.Read (6, title, 0, 0x40))
|
||||
byte[] title = file.View.ReadBytes (6, 0x40);
|
||||
if (0x40 != title.Length)
|
||||
return null;
|
||||
int title_length = Array.IndexOf<byte> (title, 0);
|
||||
if (-1 == title_length)
|
||||
|
Loading…
Reference in New Issue
Block a user