From 717e2beaed84b8aff28fb65d34635351d92dbcb9 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Thu, 12 Apr 2018 20:25:51 +1000 Subject: [PATCH] fix /xmodel with per-axis model scale --- MCGalaxy/Commands/CPE/CmdModel.cs | 2 +- MCGalaxy/util/Extensions/Extensions.cs | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/MCGalaxy/Commands/CPE/CmdModel.cs b/MCGalaxy/Commands/CPE/CmdModel.cs index 9154bb415..104def43a 100644 --- a/MCGalaxy/Commands/CPE/CmdModel.cs +++ b/MCGalaxy/Commands/CPE/CmdModel.cs @@ -29,7 +29,7 @@ namespace MCGalaxy.Commands.CPE { new CommandPerm(LevelPermission.Operator, "+ can change the model of bots") }; } } public override CommandAlias[] Aliases { - get { return new[] { new CommandAlias("XModel") }; } + get { return new[] { new CommandAlias("XModel", "-own") }; } } public override void Use(Player p, string message) { diff --git a/MCGalaxy/util/Extensions/Extensions.cs b/MCGalaxy/util/Extensions/Extensions.cs index 79045eed2..ed65eb048 100644 --- a/MCGalaxy/util/Extensions/Extensions.cs +++ b/MCGalaxy/util/Extensions/Extensions.cs @@ -71,30 +71,26 @@ namespace MCGalaxy { public static byte[] GZip(this byte[] bytes) { using (MemoryStream ms = new MemoryStream()) { - using (GZipStream gs = new GZipStream(ms, CompressionMode.Compress, true)) + using (GZipStream gs = new GZipStream(ms, CompressionMode.Compress, true)) { gs.Write(bytes, 0, bytes.Length); + } ms.Position = 0; return ms.ToArray(); } } - public static byte[] Decompress(this byte[] gzip, int capacity = 16) - { - // Create a GZIP stream with decompression mode. - // ... Then create a buffer and write into while reading from the GZIP stream. - using (GZipStream stream = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress)) - { + public static byte[] Decompress(this byte[] gzip, int capacity = 16) { + using (GZipStream src = new GZipStream(new MemoryStream(gzip), CompressionMode.Decompress)) { const int size = 4096; byte[] buffer = new byte[size]; - using (MemoryStream memory = new MemoryStream(capacity)) - { + + using (MemoryStream dst = new MemoryStream(capacity)) { int count = 0; - do { - count = stream.Read(buffer, 0, size); - if (count > 0) memory.Write(buffer, 0, count); - } while (count > 0); - return memory.ToArray(); + while ((count = src.Read(buffer, 0, size)) > 0) { + dst.Write(buffer, 0, count); + } + return dst.ToArray(); } } }