From f2b10bd0fdc8180e0cf2fd11aac10460a1919717 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 30 Dec 2018 06:37:29 +0100 Subject: [PATCH] Trim too long descriptions. --- Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index bfb3346..e7464e2 100644 --- a/Program.cs +++ b/Program.cs @@ -99,7 +99,11 @@ namespace MysteryGiftConvert { description = System.IO.File.ReadAllText( descFilename ).Replace( "\r\n", "\xFFFE" ).Replace( "\n", "\xFFFE" ); } byte[] descriptionBytes = Encoding.Unicode.GetBytes( description ); - outStream.Write( descriptionBytes, 0, descriptionBytes.Length ); + int bytecopycount = Math.Min( descriptionBytes.Length, 0x2CA - 0xD0 - 2 ); + if ( bytecopycount != descriptionBytes.Length ) { + Console.WriteLine( "Warning: Description too long." ); + } + outStream.Write( descriptionBytes, 0, bytecopycount ); while ( outStream.Length < 0x2CA ) { outStream.WriteByte( 0xFF ); }