Trim too long descriptions.

This commit is contained in:
Admiral H. Curtiss
2018-12-30 06:37:29 +01:00
parent ba2029e25a
commit f2b10bd0fd

View File

@@ -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 );
}