From 76dfe1aab13610c1cb3fa86cafc02b24f069171b Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 10 Apr 2018 14:47:42 +1000 Subject: [PATCH] Don't use fixed char, fixes runtime issues on some versions of mono (https://bugzilla.xamarin.com/show_bug.cgi?id=60625) --- MCGalaxy/Blocks/Extended/MessageBlock.cs | 2 +- MCGalaxy/Blocks/Extended/Portal.cs | 2 +- MCGalaxy/Database/PlayerData.cs | 2 +- MCGalaxy/util/Extensions/StringExts.cs | 19 ------------------- 4 files changed, 3 insertions(+), 22 deletions(-) diff --git a/MCGalaxy/Blocks/Extended/MessageBlock.cs b/MCGalaxy/Blocks/Extended/MessageBlock.cs index ee770eda7..85e0ad6ee 100644 --- a/MCGalaxy/Blocks/Extended/MessageBlock.cs +++ b/MCGalaxy/Blocks/Extended/MessageBlock.cs @@ -34,7 +34,7 @@ namespace MCGalaxy.Blocks.Extended { string message = Messages.Rows[last]["Message"].ToString().Trim(); message = message.Replace("\\'", "\'"); - message.Cp437ToUnicodeInPlace(); + message = message.Cp437ToUnicode(); message = message.Replace("@p", p.name); if (message != p.prevMsg || (alwaysRepeat || ServerConfig.RepeatMBs)) { diff --git a/MCGalaxy/Blocks/Extended/Portal.cs b/MCGalaxy/Blocks/Extended/Portal.cs index d610c6900..9831bc297 100644 --- a/MCGalaxy/Blocks/Extended/Portal.cs +++ b/MCGalaxy/Blocks/Extended/Portal.cs @@ -34,7 +34,7 @@ namespace MCGalaxy.Blocks.Extended { DataRow row = Portals.Rows[last]; string map = row["ExitMap"].ToString(); - map.Cp437ToUnicodeInPlace(); + map = map.Cp437ToUnicode(); if (p.level.name != map) { Level curLevel = p.level; diff --git a/MCGalaxy/Database/PlayerData.cs b/MCGalaxy/Database/PlayerData.cs index 883a18feb..001f0e9db 100644 --- a/MCGalaxy/Database/PlayerData.cs +++ b/MCGalaxy/Database/PlayerData.cs @@ -110,7 +110,7 @@ namespace MCGalaxy.DB { data.LastLogin = ParseDate(row[ColumnLastLogin]); data.Title = row[ColumnTitle].ToString().Trim(); - data.Title.Cp437ToUnicodeInPlace(); + data.Title = data.Title.Cp437ToUnicode(); data.TitleColor = ParseColor(row[ColumnTColor]); data.Color = ParseColor(row[ColumnColor]); diff --git a/MCGalaxy/util/Extensions/StringExts.cs b/MCGalaxy/util/Extensions/StringExts.cs index 3f1120d90..8858f7ae3 100644 --- a/MCGalaxy/util/Extensions/StringExts.cs +++ b/MCGalaxy/util/Extensions/StringExts.cs @@ -59,25 +59,6 @@ namespace MCGalaxy { c[i] = UnicodeToCp437(str[i]); return new String(c); } - - /// Modifies the characters of a string consisting of code page 437 indices into unicode. - public unsafe static void Cp437ToUnicodeInPlace(this string str) { - fixed (char* ptr = str) { - for (int i = 0; i < str.Length; i++) { - ptr[i] = Cp437ToUnicode(ptr[i]); - } - } - } - - /// Modifies the characters of a unicode string into code page 437 indices. - /// Unicode characters not in code page 437 are replaced with '?'. - public static unsafe void UnicodeToCp437InPlace(this string str) { - fixed (char* ptr = str) { - for (int i = 0; i < str.Length; i++) { - ptr[i] = UnicodeToCp437(ptr[i]); - } - } - } /// Converts a code page 437 indice into unicode.