From 0718c14b781e7e125ffa3721407fee10cbaff92c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 13 Jan 2018 09:55:02 +1100 Subject: [PATCH] Prefer checking for InstantMOTD cpe extension support, instead of hardcoding app name check --- MCGalaxy/Levels/LevelOptions.cs | 8 ++++---- MCGalaxy/Player/Player.CPE.cs | 24 +++++++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/MCGalaxy/Levels/LevelOptions.cs b/MCGalaxy/Levels/LevelOptions.cs index e726301d1..e59f61126 100644 --- a/MCGalaxy/Levels/LevelOptions.cs +++ b/MCGalaxy/Levels/LevelOptions.cs @@ -77,10 +77,10 @@ namespace MCGalaxy { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { - // Unfortunately, some clients will freeze or crash if we send a MOTD packet, - // but don't follow it up by a new map. Thus, we have to use the ugly approach - // of only sending to whitelisted clients. - if (pl.appName != null && pl.appName.CaselessStarts("classicalsharp")) { + // Some clients will freeze or crash if we send a MOTD packet, but don't follow it up by a new map. + // Although checking for CPE extension support is preferred, also send to whitelisted clients for maximum compatibility + bool motdOnly = pl.Supports(CpeExt.InstantMOTD) || (pl.appName != null && pl.appName.CaselessStarts("classicalsharp")); + if (motdOnly) { pl.SendMapMotd(); } else { LevelActions.ReloadMap(p, pl, false); diff --git a/MCGalaxy/Player/Player.CPE.cs b/MCGalaxy/Player/Player.CPE.cs index f7222c791..fe1baf791 100644 --- a/MCGalaxy/Player/Player.CPE.cs +++ b/MCGalaxy/Player/Player.CPE.cs @@ -34,19 +34,20 @@ namespace MCGalaxy { } ExtEntry[] extensions = new ExtEntry[] { - new ExtEntry(CpeExt.ClickDistance), new ExtEntry(CpeExt.CustomBlocks), - new ExtEntry(CpeExt.HeldBlock), new ExtEntry(CpeExt.TextHotkey), + new ExtEntry(CpeExt.ClickDistance), new ExtEntry(CpeExt.CustomBlocks), + new ExtEntry(CpeExt.HeldBlock), new ExtEntry(CpeExt.TextHotkey), new ExtEntry(CpeExt.ExtPlayerList, 2), new ExtEntry(CpeExt.EnvColors), - new ExtEntry(CpeExt.SelectionCuboid), new ExtEntry(CpeExt.BlockPermissions), - new ExtEntry(CpeExt.ChangeModel), new ExtEntry(CpeExt.EnvMapAppearance, 2), - new ExtEntry(CpeExt.EnvWeatherType), new ExtEntry(CpeExt.HackControl), - new ExtEntry(CpeExt.EmoteFix), new ExtEntry(CpeExt.MessageTypes), - new ExtEntry(CpeExt.LongerMessages), new ExtEntry(CpeExt.FullCP437), + new ExtEntry(CpeExt.SelectionCuboid), new ExtEntry(CpeExt.BlockPermissions), + new ExtEntry(CpeExt.ChangeModel), new ExtEntry(CpeExt.EnvMapAppearance, 2), + new ExtEntry(CpeExt.EnvWeatherType), new ExtEntry(CpeExt.HackControl), + new ExtEntry(CpeExt.EmoteFix), new ExtEntry(CpeExt.MessageTypes), + new ExtEntry(CpeExt.LongerMessages), new ExtEntry(CpeExt.FullCP437), new ExtEntry(CpeExt.BlockDefinitions), new ExtEntry(CpeExt.BlockDefinitionsExt, 2), - new ExtEntry(CpeExt.TextColors), new ExtEntry(CpeExt.BulkBlockUpdate), - new ExtEntry(CpeExt.EnvMapAspect), new ExtEntry(CpeExt.PlayerClick), - new ExtEntry(CpeExt.EntityProperty), new ExtEntry(CpeExt.ExtEntityPositions), - new ExtEntry(CpeExt.TwoWayPing), new ExtEntry(CpeExt.InventoryOrder), + new ExtEntry(CpeExt.TextColors), new ExtEntry(CpeExt.BulkBlockUpdate), + new ExtEntry(CpeExt.EnvMapAspect), new ExtEntry(CpeExt.PlayerClick), + new ExtEntry(CpeExt.EntityProperty), new ExtEntry(CpeExt.ExtEntityPositions), + new ExtEntry(CpeExt.TwoWayPing), new ExtEntry(CpeExt.InventoryOrder), + new ExtEntry(CpeExt.InstantMOTD), }; ExtEntry FindExtension(string extName) { @@ -229,6 +230,7 @@ namespace MCGalaxy { public const string ExtEntityPositions = "ExtEntityPositions"; public const string TwoWayPing = "TwoWayPing"; public const string InventoryOrder = "InventoryOrder"; + public const string InstantMOTD = "InstantMOTD"; } public enum CpeMessageType : byte {