diff --git a/Projects/UOContent/Engines/Plants/Network/DisplayHelpTopic.cs b/Projects/UOContent.Tests/Tests/Engines/Help/HelpTopic.cs similarity index 100% rename from Projects/UOContent/Engines/Plants/Network/DisplayHelpTopic.cs rename to Projects/UOContent.Tests/Tests/Engines/Help/HelpTopic.cs diff --git a/Projects/UOContent.Tests/Tests/Engines/Help/TestHelpTopicPacket.cs b/Projects/UOContent.Tests/Tests/Engines/Help/TestHelpTopicPacket.cs new file mode 100644 index 000000000..481cda5ba --- /dev/null +++ b/Projects/UOContent.Tests/Tests/Engines/Help/TestHelpTopicPacket.cs @@ -0,0 +1,26 @@ +using System; +using Server.Engines.Help; +using Server.Network; +using Server.Tests; +using Server.Tests.Network; +using Xunit; + +namespace UOContent.Tests +{ + public class TestHelpTopicPacket + { + [Theory] + [InlineData(HelpTopic.Healing, false)] + [InlineData(HelpTopic.EmptyingBowl, true)] + public void TestDisplayHelpTopic(int topic, bool display) + { + var expected = new DisplayHelpTopic(topic, display).Compile(); + + using var ns = PacketTestUtilities.CreateTestNetState(); + ns.SendDisplayHelpTopic(topic, display); + + var result = ns.SendPipe.Reader.TryRead(); + AssertThat.Equal(result.Buffer[0].AsSpan(0), expected); + } + } +} diff --git a/Projects/UOContent/Engines/Help/HelpTopic.cs b/Projects/UOContent/Engines/Help/HelpTopic.cs new file mode 100644 index 000000000..0fc242891 --- /dev/null +++ b/Projects/UOContent/Engines/Help/HelpTopic.cs @@ -0,0 +1,55 @@ +/************************************************************************* + * ModernUO * + * Copyright (C) 2019-2021 - ModernUO Development Team * + * Email: hi@modernuo.com * + * File: HelpTopic.cs * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation, either version 3 of the License, or * + * (at your option) any later version. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *************************************************************************/ + +using System.Buffers; +using Server.Network; + +namespace Server.Engines.Help +{ + public static class HelpTopic + { + // Topics + public const int Healing = 29; + public const int PlantGrowing = 48; + public const int InfestationLevel = 54; + public const int FungusLevel = 56; + public const int PoisonLevel = 58; + public const int DiseaseLevel = 60; + public const int PollinationState = 67; + public const int SeedProduction = 68; + public const int ResourceProduction = 69; + public const int DecorativeMode = 70; + public const int EmptyingBowl = 71; + + public static void SendDisplayHelpTopic(this NetState ns, int topicID, bool display = true) + { + if (ns == null) + { + return; + } + + var writer = new SpanWriter(stackalloc byte[11]); + writer.Write((byte)0xBF); // Packet ID + writer.Write((ushort)11); + writer.Write((ushort)0x17); // Sub-packet + writer.Write((byte)1); // Command + + writer.Write(topicID); + writer.Write(display); + + ns.Send(writer.Span); + } + } +} diff --git a/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs b/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs index 2c36fde67..e127cb496 100644 --- a/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs +++ b/Projects/UOContent/Engines/Plants/EmptyTheBowlGump.cs @@ -1,3 +1,4 @@ +using Server.Engines.Help; using Server.Gumps; using Server.Network; @@ -79,7 +80,7 @@ namespace Server.Engines.Plants } case 2: // Help { - from.Send(new DisplayHelpTopic(71, true)); // EMPTYING THE BOWL + from.NetState.SendDisplayHelpTopic(HelpTopic.EmptyingBowl); from.SendGump(new EmptyTheBowlGump(m_Plant)); diff --git a/Projects/UOContent/Engines/Plants/MainPlantGump.cs b/Projects/UOContent/Engines/Plants/MainPlantGump.cs index adf46da5b..5593d3787 100644 --- a/Projects/UOContent/Engines/Plants/MainPlantGump.cs +++ b/Projects/UOContent/Engines/Plants/MainPlantGump.cs @@ -1,4 +1,5 @@ using System; +using Server.Engines.Help; using Server.Gumps; using Server.Items; using Server.Network; @@ -294,7 +295,7 @@ namespace Server.Engines.Plants } case 2: // Infestation { - from.Send(new DisplayHelpTopic(54, true)); // INFESTATION LEVEL + from.NetState.SendDisplayHelpTopic(HelpTopic.InfestationLevel); from.SendGump(new MainPlantGump(m_Plant)); @@ -302,7 +303,7 @@ namespace Server.Engines.Plants } case 3: // Fungus { - from.Send(new DisplayHelpTopic(56, true)); // FUNGUS LEVEL + from.NetState.SendDisplayHelpTopic(HelpTopic.FungusLevel); from.SendGump(new MainPlantGump(m_Plant)); @@ -310,7 +311,7 @@ namespace Server.Engines.Plants } case 4: // Poison { - from.Send(new DisplayHelpTopic(58, true)); // POISON LEVEL + from.NetState.SendDisplayHelpTopic(HelpTopic.PoisonLevel); from.SendGump(new MainPlantGump(m_Plant)); @@ -318,7 +319,7 @@ namespace Server.Engines.Plants } case 5: // Disease { - from.Send(new DisplayHelpTopic(60, true)); // DISEASE LEVEL + from.NetState.SendDisplayHelpTopic(HelpTopic.DiseaseLevel); from.SendGump(new MainPlantGump(m_Plant)); @@ -375,7 +376,7 @@ namespace Server.Engines.Plants } case 11: // Help { - from.Send(new DisplayHelpTopic(48, true)); // PLANT GROWING + from.NetState.SendDisplayHelpTopic(HelpTopic.PlantGrowing); from.SendGump(new MainPlantGump(m_Plant)); diff --git a/Projects/UOContent/Engines/Plants/ReproductionGump.cs b/Projects/UOContent/Engines/Plants/ReproductionGump.cs index 4e983681f..63439407f 100644 --- a/Projects/UOContent/Engines/Plants/ReproductionGump.cs +++ b/Projects/UOContent/Engines/Plants/ReproductionGump.cs @@ -1,3 +1,4 @@ +using Server.Engines.Help; using Server.Gumps; using Server.Network; @@ -165,7 +166,7 @@ namespace Server.Engines.Plants } case 3: // Pollination { - from.Send(new DisplayHelpTopic(67, true)); // POLLINATION STATE + from.NetState.SendDisplayHelpTopic(HelpTopic.PollinationState); from.SendGump(new ReproductionGump(m_Plant)); @@ -173,7 +174,7 @@ namespace Server.Engines.Plants } case 4: // Resources { - from.Send(new DisplayHelpTopic(69, true)); // RESOURCE PRODUCTION + from.NetState.SendDisplayHelpTopic(HelpTopic.ResourceProduction); from.SendGump(new ReproductionGump(m_Plant)); @@ -181,7 +182,7 @@ namespace Server.Engines.Plants } case 5: // Seeds { - from.Send(new DisplayHelpTopic(68, true)); // SEED PRODUCTION + from.NetState.SendDisplayHelpTopic(HelpTopic.SeedProduction); from.SendGump(new ReproductionGump(m_Plant)); diff --git a/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs b/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs index a36f7c1c4..3ff7817cb 100644 --- a/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs +++ b/Projects/UOContent/Engines/Plants/SetToDecorativeGump.cs @@ -1,3 +1,4 @@ +using Server.Engines.Help; using Server.Gumps; using Server.Network; @@ -66,7 +67,7 @@ namespace Server.Engines.Plants } case 2: // Help { - from.Send(new DisplayHelpTopic(70, true)); // DECORATIVE MODE + from.NetState.SendDisplayHelpTopic(HelpTopic.DecorativeMode); from.SendGump(new SetToDecorativeGump(m_Plant)); diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs index d64f067f0..f59e7b3cd 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs @@ -1,3 +1,4 @@ +using Server.Engines.Help; using Server.Items; using Server.Mobiles; using Server.Network; @@ -91,16 +92,16 @@ namespace Server.Engines.Quests.Haven { KillHordeMinionsStep.First => /* Find the mountain pass beyond the house which lies at the - * end of the runic road.

- * - * Assist the city Militia by slaying Horde Minions - */ + * end of the runic road.

+ * + * Assist the city Militia by slaying Horde Minions + */ 1049089, KillHordeMinionsStep.LearnKarma => /* You have just gained some Karma - * for killing the horde minion. Learn - * how this affects your Paladin abilities. - */ + * for killing the horde minion. Learn + * how this affects your Paladin abilities. + */ 1060389, _ => 1060507 }; @@ -175,7 +176,7 @@ namespace Server.Engines.Quests.Haven { if (CurProgress == 0) { - System.From.Send(new DisplayHelpTopic(29, false)); // HEALING + System.From.NetState.SendDisplayHelpTopic(HelpTopic.Healing, false); } CurProgress++;