From 7756f8d8e8e39abd37bc4bfb4a73d34cd2f2ad71 Mon Sep 17 00:00:00 2001 From: morkt Date: Thu, 4 Feb 2016 05:59:55 +0400 Subject: [PATCH] use ArView.ReadBytes and Binary.RotR shortcut methods. --- ArcFormats/NitroPlus/ArcNitro.cs | 10 ++++------ ArcFormats/Xuse/ArcWAG.cs | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ArcFormats/NitroPlus/ArcNitro.cs b/ArcFormats/NitroPlus/ArcNitro.cs index 2d60e2c5..8c0fadaa 100644 --- a/ArcFormats/NitroPlus/ArcNitro.cs +++ b/ArcFormats/NitroPlus/ArcNitro.cs @@ -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); diff --git a/ArcFormats/Xuse/ArcWAG.cs b/ArcFormats/Xuse/ArcWAG.cs index d7c9ddff..a5231574 100644 --- a/ArcFormats/Xuse/ArcWAG.cs +++ b/ArcFormats/Xuse/ArcWAG.cs @@ -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 (title, 0); if (-1 == title_length)