From a103b2af2d5c51d05e4d1f2e9ec90dac5c646f67 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 5 Dec 2021 00:02:32 -0800 Subject: [PATCH 01/14] fix: Updates README (#876) --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b37e7ef2e..8825dd323 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ ModernUO [![Discord](https://img.shields.io/discord/751317910504603701?logo=disc ## Requirements #### Supported Operating Systems -[![Windows 8.1/10/2016/2019](https://img.shields.io/badge/-server%202019-0078D6?logo=windows)](https://www.microsoft.com/en-US/evalcenter/evaluate-windows-server-2019) -![MacOS 10/11](https://img.shields.io/badge/-big%20sur-222222?logo=apple&logoColor=white) -[![Debian 9/10](https://img.shields.io/badge/-buster-A81D33?logo=debian)](https://www.debian.org/distrib/) +[![Windows 8.1/10/2016/2019/2022](https://img.shields.io/badge/-server%202022-0078D6?logo=windows)](https://www.microsoft.com/en-US/evalcenter/evaluate-windows-server-2019) +![MacOS 10/11/12](https://img.shields.io/badge/-monterey-222222?logo=apple&logoColor=white) +[![Debian 9/10/11](https://img.shields.io/badge/-bullseye-A81D33?logo=debian)](https://www.debian.org/distrib/) [![Ubuntu 16/18/20 LTS](https://img.shields.io/badge/-20LTS-E95420?logo=ubuntu&logoColor=white)](https://ubuntu.com/download/server) -[![CentOS 7/8](https://img.shields.io/badge/-8.3-262577?logo=centos&logoColor=white)](https://www.centos.org/download/) -[![Fedora 32/33/34](https://img.shields.io/badge/-33-0B57A4?logo=fedora&logoColor=white)](https://getfedora.org/en/server/download/) +[![CentOS 7/8](https://img.shields.io/badge/-8.5-262577?logo=centos&logoColor=white)](https://www.centos.org/download/) +[![Fedora 32/33/34](https://img.shields.io/badge/-34-0B57A4?logo=fedora&logoColor=white)](https://getfedora.org/en/server/download/) [![RedHat 7/8](https://img.shields.io/badge/-8-BE0000?logo=red%20hat&logoColor=white)](https://access.redhat.com/downloads) #### Running the server @@ -31,9 +31,9 @@ ModernUO [![Discord](https://img.shields.io/discord/751317910504603701?logo=disc [![.NET](https://img.shields.io/badge/.NET-%206.0%20SDK-5C2D91)](https://dotnet.microsoft.com/download/dotnet/6.0) #### Supported IDEs -  +    [Jetbrains Rider 2021.3](https://www.jetbrains.com/rider/download) -                     +                          [Visual Studio 2022](https://visualstudio.microsoft.com/downloads)
Rider 2021.3+             Visual Studio 2022+ @@ -49,9 +49,9 @@ Rider 2021.3+           & - Run `./publish.cmd [release|debug (default: release)] [os]` - `os` - [Supported operating systems](https://github.com/dotnet/core/blob/master/release-notes/5.0/5.0-supported-os.md) - `win` - Windows 8.1/10/2016/2019 - - `osx` - MacOS 10.13+/11.0 (High Sierra, Mojave, Catalina, & Big Sur) + - `osx` - MacOS 10.15/11.0+/12.0+ (Catalina, Big Sur, Monterey) - `ubuntu.16.04`, `ubuntu.18.04` `ubuntu.20.04` - Ubuntu LTS - - `debian.9`, `debian.10` - Debian + - `debian.9`, `debian.10`, `debian.11` - Debian - `centos.7`, `centos.8` - CentOS - `fedora.32`, `fedora.33`, `fedora.34` - Fedora - `rhel.7`, `rhel.8` - Redhat From b3c153eae36d7b178bcbffc9d52038a49c3e1961 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 5 Dec 2021 00:13:47 -0800 Subject: [PATCH 02/14] fix: Removes Debian 9 support, Adds Windows 11 (#877) --- Directory.Build.props | 2 +- README.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index aa4172a54..be723978b 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -11,7 +11,7 @@ true true NU1603 - win-x64;debian.9-x64;debian.10-x64;debian.11-x64;ubuntu.16.04-x64;ubuntu.18.04-x64;ubuntu.20.04-x64;centos.7-x64;centos.8-x64;fedora.32-x64;fedora.33-x64;fedora.34-x64;rhel.7-x64;rhel.8-x64;osx-x64 + win-x64;debian.10-x64;debian.11-x64;ubuntu.16.04-x64;ubuntu.18.04-x64;ubuntu.20.04-x64;centos.7-x64;centos.8-x64;fedora.32-x64;fedora.33-x64;fedora.34-x64;rhel.7-x64;rhel.8-x64;osx-x64 Debug;Release;Analyze false true diff --git a/README.md b/README.md index 8825dd323..1ee0cb293 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,9 @@ ModernUO [![Discord](https://img.shields.io/discord/751317910504603701?logo=disc ## Requirements #### Supported Operating Systems -[![Windows 8.1/10/2016/2019/2022](https://img.shields.io/badge/-server%202022-0078D6?logo=windows)](https://www.microsoft.com/en-US/evalcenter/evaluate-windows-server-2019) -![MacOS 10/11/12](https://img.shields.io/badge/-monterey-222222?logo=apple&logoColor=white) -[![Debian 9/10/11](https://img.shields.io/badge/-bullseye-A81D33?logo=debian)](https://www.debian.org/distrib/) +[![Windows 10/11/2016/2019/2022](https://img.shields.io/badge/-server%202022-0078D6?logo=windows)](https://www.microsoft.com/en-US/evalcenter/evaluate-windows-server-2022) +![MacOS 10.15/11/12](https://img.shields.io/badge/-monterey-222222?logo=apple&logoColor=white) +[![Debian 10/11](https://img.shields.io/badge/-bullseye-A81D33?logo=debian)](https://www.debian.org/distrib/) [![Ubuntu 16/18/20 LTS](https://img.shields.io/badge/-20LTS-E95420?logo=ubuntu&logoColor=white)](https://ubuntu.com/download/server) [![CentOS 7/8](https://img.shields.io/badge/-8.5-262577?logo=centos&logoColor=white)](https://www.centos.org/download/) [![Fedora 32/33/34](https://img.shields.io/badge/-34-0B57A4?logo=fedora&logoColor=white)](https://getfedora.org/en/server/download/) @@ -47,11 +47,11 @@ Rider 2021.3+           & ## Building/Publishing - Run `./publish.cmd [release|debug (default: release)] [os]` - - `os` - [Supported operating systems](https://github.com/dotnet/core/blob/master/release-notes/5.0/5.0-supported-os.md) - - `win` - Windows 8.1/10/2016/2019 + - `os` - [Supported operating systems](https://github.com/dotnet/core/blob/main/release-notes/6.0/supported-os.md) + - `win` - Windows 10/11/2016/2019/2022 - `osx` - MacOS 10.15/11.0+/12.0+ (Catalina, Big Sur, Monterey) - `ubuntu.16.04`, `ubuntu.18.04` `ubuntu.20.04` - Ubuntu LTS - - `debian.9`, `debian.10`, `debian.11` - Debian + - `debian.10`, `debian.11` - Debian - `centos.7`, `centos.8` - CentOS - `fedora.32`, `fedora.33`, `fedora.34` - Fedora - `rhel.7`, `rhel.8` - Redhat From 1cf7b6c056ae8fb458cf176a30e82352ac6fb72a Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 5 Dec 2021 08:56:09 -0800 Subject: [PATCH 03/14] fix: Fixes badly formatted files (#878) --- Projects/UOContent/Engines/Help/HelpGump.cs | 10 +- .../ML Quests/Definitions/AGhostOfCovetous.cs | 16 +- .../ML Quests/Definitions/Heartwood.cs | 217 +++++++++--------- .../Engines/ML Quests/Definitions/Heritage.cs | 4 +- .../ML Quests/Definitions/HonestBeggar.cs | 8 +- .../Engines/ML Quests/Definitions/Ilshenar.cs | 10 +- .../ML Quests/Definitions/MistakenIdentity.cs | 6 +- .../Definitions/NewHavenSkillTraining.cs | 4 +- .../ML Quests/Definitions/NewHavenTraining.cs | 46 ++-- .../ML Quests/Definitions/Sanctuary.cs | 41 ++-- .../ML Quests/Definitions/Spellweaving.cs | 29 +-- .../ML Quests/Definitions/TheAncientWorld.cs | 2 +- .../ML Quests/Definitions/UnfadingMemories.cs | 49 ++-- .../Dark Tides/Items/ScrollOfAbraxus.cs | 2 +- .../Mobiles/HiddenFigure.cs | 2 +- .../Quests/Haochi's Trials/Conversations.cs | 51 ++-- Projects/UOContent/Gumps/RunebookGump.cs | 12 +- .../Items/Shields/Artifacts/Aegis.cs | 2 +- .../UOContent/Items/Shields/BaseShield.cs | 34 +-- .../Items/Skill Items/Fishing/Misc/SOS.cs | 2 +- .../Items/Skill Items/Fishing/Misc/Sextant.cs | 2 +- .../Dawn's Music Box/DawnsMusicBox.cs | 2 +- .../8th Anniversary Items/DupresShield.cs | 2 +- .../Items/Special/Gifts/ShaminoCrossbow.cs | 2 +- .../Items/Special/Holiday/HolidayFoods.cs | 4 +- Projects/UOContent/Items/Wands/BaseWand.cs | 9 +- .../Weapons/Abilities/InfectiousStrike.cs | 2 +- .../Items/Weapons/Abilities/ShadowStrike.cs | 2 +- Projects/UOContent/Spells/Base/Spell.cs | 2 +- .../UOContent/Spells/Fifth/MagicReflect.cs | 3 +- .../UOContent/Spells/First/ReactiveArmor.cs | 3 +- .../UOContent/Spells/Necromancy/Wither.cs | 2 +- .../UOContent/Spells/Second/Protection.cs | 4 +- 33 files changed, 274 insertions(+), 312 deletions(-) diff --git a/Projects/UOContent/Engines/Help/HelpGump.cs b/Projects/UOContent/Engines/Help/HelpGump.cs index de622407e..4d46a047b 100644 --- a/Projects/UOContent/Engines/Help/HelpGump.cs +++ b/Projects/UOContent/Engines/Help/HelpGump.cs @@ -225,21 +225,21 @@ namespace Server.Engines.Help * Use this option when another player is verbally harassing your character. * Verbal harassment behaviors include but are not limited to, using bad language, threats etc.. * Before you submit a complaint be sure you understand what constitutes harassment - * � what is verbal harassment? - + * - what is verbal harassment? - * and that you have followed these steps:
* 1. You have asked the player to stop and they have continued.
* 2. You have tried to remove yourself from the situation.
* 3. You have done nothing to instigate or further encourage the harassment.
* 4. You have added the player to your ignore list. * - How do I ignore a player?
- * 5. You have read and understand Origin�s definition of harassment.
+ * 5. You have read and understand Origin's definition of harassment.
* 6. Your account information is up to date. (Including a current email address)
* *If these steps have not been taken, GMs may be unable to take action against the offending player.
* **A chat log will be review by a GM to assess the validity of this complaint. * Abuse of this system is a violation of the Rules of Conduct.
* EXPLOITING
* Use this option to report someone who may be exploiting or cheating. - * � What constitutes an exploit? + * - What constitutes an exploit? */ AddHtmlLocalized( 110, @@ -259,14 +259,14 @@ namespace Server.Engines.Help * Use this option when another player is harassing your character using game mechanics. * Physical harassment includes but is not limited to luring, Kill Stealing, and any act that causes a players death in Trammel. * Before you submit a complaint be sure you understand what constitutes harassment - * � what is physical harassment? + * - what is physical harassment? * and that you have followed these steps:
* 1. You have asked the player to stop and they have continued.
* 2. You have tried to remove yourself from the situation.
* 3. You have done nothing to instigate or further encourage the harassment.
* 4. You have added the player to your ignore list. * - how do I ignore a player?
- * 5. You have read and understand Origin�s definition of harassment.
+ * 5. You have read and understand Origin's definition of harassment.
* 6. Your account information is up to date. (Including a current email address)
* *If these steps have not been taken, GMs may be unable to take action against the offending player.
* **This issue will be reviewed by a GM to assess the validity of this complaint. diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/AGhostOfCovetous.cs b/Projects/UOContent/Engines/ML Quests/Definitions/AGhostOfCovetous.cs index 71afef63e..754d1d8f0 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/AGhostOfCovetous.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/AGhostOfCovetous.cs @@ -42,8 +42,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; Title = 1075337; // Save His Dad Description = - 1075338; // My father, Andros, is a smith in Minoc. Last week his forge overturned and he was splashed by molten steel. He was horribly burned, and we feared he would die. An alchemist in Vesper promised to make a bandage that could heal him, but he needed the silk of a dread spider. I came here to get some, but I was careless, and succumbed to their poison. Please, won�t you help my father? - RefusalMessage = 1075340; // Oh . . . that�s your decision . . . OooOoooOOoo . . . + 1075338; // My father, Andros, is a smith in Minoc. Last week his forge overturned and he was splashed by molten steel. He was horribly burned, and we feared he would die. An alchemist in Vesper promised to make a bandage that could heal him, but he needed the silk of a dread spider. I came here to get some, but I was careless, and succumbed to their poison. Please, won't you help my father? + RefusalMessage = 1075340; // Oh . . . that's your decision . . . OooOoooOOoo . . . InProgressMessage = 1075341; // Thank you! Deliver it to Leon the Alchemist in Vesper. The silk crumbles easily, and much time has already passed since I died. Please! Hurry! CompletionMessage = @@ -74,20 +74,20 @@ namespace Server.Engines.MLQuests.Definitions { Activated = true; OneTimeOnly = true; - Title = 1075343; // A Father�s Gratitude + Title = 1075343; // A Father's Gratitude Description = - 1075344; // That is simply terrible. First Andros, and now his son. Well, let�s make sure Frederic�s sacrifice wasn�t in vain. Will you take the bandages to his father? You can probably deliver them faster than I can, can�t you? + 1075344; // That is simply terrible. First Andros, and now his son. Well, let's make sure Frederic's sacrifice wasn't in vain. Will you take the bandages to his father? You can probably deliver them faster than I can, can't you? RefusalMessage = - 1075346; // Well I�m sorry to hear you say that. Without your help, I don�t know if I can get these to Andros quickly enough to help him. + 1075346; // Well I'm sorry to hear you say that. Without your help, I don't know if I can get these to Andros quickly enough to help him. InProgressMessage = - 1075347; // I don�t know how much longer Andros will survive. You�d better get this to him as quick as you can. Every second counts! + 1075347; // I don't know how much longer Andros will survive. You'd better get this to him as quick as you can. Every second counts! CompletionMessage = - 1075348; // Sorry, I�m not accepting commissions at the moment. What? You have the bandage I need from Leon? Thank you so much! But why didn�t my son bring this to me himself? . . . Oh, no! You can't be serious! *sag* My Freddie, my son! Thank you for carrying out his last wish. Here -- I made this for my son, to give to him when he became a journeyman. I want you to have it. + 1075348; // Sorry, I'm not accepting commissions at the moment. What? You have the bandage I need from Leon? Thank you so much! But why didn't my son bring this to me himself? . . . Oh, no! You can't be serious! *sag* My Freddie, my son! Thank you for carrying out his last wish. Here -- I made this for my son, to give to him when he became a journeyman. I want you to have it. CompletionNotice = CompletionNoticeShort; Objectives.Add(new DeliverObjective(typeof(AlchemistsBandage), 1, "Alchemist's Bandage", typeof(Andros))); - Rewards.Add(new ItemReward(1075345, typeof(AndrosGratitude))); // Andros� Gratitude + Rewards.Add(new ItemReward(1075345, typeof(AndrosGratitude))); // Andros' Gratitude } public override bool IsChainTriggered => true; diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/Heartwood.cs b/Projects/UOContent/Engines/ML Quests/Definitions/Heartwood.cs index fe29cbcf7..20e0216f3 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/Heartwood.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/Heartwood.cs @@ -230,7 +230,7 @@ namespace Server.Engines.MLQuests.Definitions // Restless spirits are known to inhabit these parts, taking the lives of unwary travelers. // It is about time a hero put the dead back in their graves. I'm sure such a hero would be justly rewarded. Description = 1073566; - RefusalMessage = 1073580; // I hope you'll reconsider. Until then, farewell. + RefusalMessage = 1073580; // I hope you'll reconsider. Until then, farwell. InProgressMessage = 1073586; // The restless spirts still walk -- you must kill 15 of them. Objectives.Add( @@ -313,7 +313,7 @@ namespace Server.Engines.MLQuests.Definitions // Please, put them out of their misery. // I will offer you what payment I can if you will end the torment of these undead wretches. Description = 1073565; - RefusalMessage = 1073580; // I hope you'll reconsider. Until then, farewell. + RefusalMessage = 1073580; // I hope you'll reconsider. Until then, farwell. InProgressMessage = 1073585; // Your task is not done. Continue putting the Skeleton and Bone Knights to rest. Objectives.Add( @@ -1314,12 +1314,12 @@ namespace Server.Engines.MLQuests.Definitions { Activated = true; Title = 1074280; // Reptilian Dentist - Description = - 1074710; // I'm working on a striking necklace -- something really unique -- and I know just what I need to finish it up. A huge fang! Won't that catch the eye? I would like to employ you to find me such an item, perhaps a snake would make the ideal donor. I'll make it worth your while, of course. + // I'm working on a striking necklace -- something really unique -- and I know just what I need to finish it up. A huge fang! Won't that catch the eye? I would like to employ you to find me such an item, perhaps a snake would make the ideal donor. I'll make it worth your while, of course. + Description = 1074710; RefusalMessage = 1074723; // I understand. I don't like snakes much either. They're so creepy. - InProgressMessage = - 1074722; // Those really big snakes like swamps, I've heard. You might try the blighted grove. - CompletionMessage = 1074721; // Do you have it? *gasp* What a tooth! Here � I must get right to work. + // Those really big snakes like swamps, I've heard. You might try the blighted grove. + InProgressMessage = 1074722; + CompletionMessage = 1074721; // Do you have it? *gasp* What a tooth! Here … I must get right to work. Objectives.Add(new CollectObjective(1, typeof(CoilsFang), "coil's fang")); @@ -1334,8 +1334,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073881; // Stop Harping on Me - Description = - 1074071; // Humans artistry can be a remarkable thing. For instance, I have heard of a wonderful instrument which creates the most melodious of music. A lap harp. I would be ever so grateful if I could examine one in person. + // Humans artistry can be a remarkable thing. For instance, I have heard of a wonderful instrument which creates the most melodious of music. A lap harp. I would be ever so grateful if I could examine one in person. + Description = 1074071; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073927; // I will be in your debt if you bring me lap harp. CompletionMessage = 1073969; // My thanks for your service. Now, I will show you something of elven carpentry. @@ -1353,8 +1353,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073908; // The Far Eye - Description = - 1074098; // The wonders of human invention! Turning sand and metal into a far-seeing eye! This is something I must experience for myself. Bring me some of these spyglasses friend human. + // The wonders of human invention! Turning sand and metal into a far-seeing eye! This is something I must experience for myself. Bring me some of these spyglasses friend human. + Description = 1074098; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073954; // I will be in your debt if you bring me spyglasses. CompletionMessage = 1073978; // Enjoy my thanks for your service. @@ -1372,8 +1372,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073876; // Lethal Darts - Description = - 1074066; // We elves are no strangers to archery but I would be interested in learning whether there is anything to learn from the human approach. I would gladly trade you something I have if you could teach me of the deadly crossbow bolt. + // We elves are no strangers to archery but I would be interested in learning whether there is anything to learn from the human approach. I would gladly trade you something I have if you could teach me of the deadly crossbow bolt. + Description = 1074066; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073922; // I will be in your debt if you bring me crossbow bolts. CompletionMessage = 1073968; // My thanks for your service. Now, I shall teach you of elven archery. @@ -1392,8 +1392,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073877; // A Simple Bow - Description = - 1074067; // I wish to try a bow crafted in the human style. Is it possible for you to bring me such a weapon? I would be happy to return this favor. + // I wish to try a bow crafted in the human style. Is it possible for you to bring me such a weapon? I would be happy to return this favor. + Description = 1074067; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073923; // I will be in your debt if you bring me bows. CompletionMessage = 1073968; // My thanks for your service. Now, I shall teach you of elven archery. @@ -1412,8 +1412,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073878; // Ingenious Archery, Part I - Description = - 1074068; // I have heard of a curious type of bow, you call it a "crossbow". It sounds fascinating and I would very much like to examine one closely. Would you be able to obtain such an instrument for me? + // I have heard of a curious type of bow, you call it a "crossbow". It sounds fascinating and I would very much like to examine one closely. Would you be able to obtain such an instrument for me? + Description = 1074068; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073924; // I will be in your debt if you bring me crossbows. CompletionMessage = 1073968; // My thanks for your service. Now, I shall teach you of elven archery. @@ -1432,8 +1432,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073879; // Ingenious Archery, Part II - Description = - 1074069; // These human "crossbows" are complex and clever. The "heavy crossbow" is a remarkable instrument of war. I am interested in seeing one up close, if you could arrange for one to make its way to my hands. + // These human "crossbows" are complex and clever. The "heavy crossbow" is a remarkable instrument of war. I am interested in seeing one up close, if you could arrange for one to make its way to my hands. + Description = 1074069; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073925; // I will be in your debt if you bring me heavy crossbows. CompletionMessage = 1073968; // My thanks for your service. Now, I shall teach you of elven archery. @@ -1452,8 +1452,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073880; // Ingenious Archery, Part III - Description = - 1074070; // My friend, I am in search of a device, a instrument of remarkable human ingenuity. It is a repeating crossbow. If you were to obtain such a device, I would gladly reveal to you some of the secrets of elven craftsmanship. + // My friend, I am in search of a device, a instrument of remarkable human ingenuity. It is a repeating crossbow. If you were to obtain such a device, I would gladly reveal to you some of the secrets of elven craftsmanship. + Description = 1074070; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073926; // I will be in your debt if you bring me repeating crossbows. CompletionMessage = 1073968; // My thanks for your service. Now, I shall teach you of elven archery. @@ -1471,11 +1471,11 @@ namespace Server.Engines.MLQuests.Definitions { Activated = true; Title = 1074711; // Scale Armor - Description = - 1074712; // Here's what I need ... there are some creatures called hydra, fearsome beasts, whose scales are especially suitable for a new sort of armor that I'm developing. I need a few such pieces and then some supple alligator skin for the backing. I'm going to need a really large piece that's shaped just right ... the tail I think would do nicely. I appreciate your help. + // Here's what I need ... there are some creatures called hydra, fearsome beasts, whose scales are especially suitable for a new sort of armor that I'm developing. I need a few such pieces and then some supple alligator skin for the backing. I'm going to need a really large piece that's shaped just right ... the tail I think would do nicely. I appreciate your help. + Description = 1074712; RefusalMessage = 1073580; // I hope you'll reconsider. Until then, farwell. - InProgressMessage = - 1074724; // Hydras have been spotted in the Blighted Grove. You won't get those scales without getting your feet wet, I'm afraid. + // Hydras have been spotted in the Blighted Grove. You won't get those scales without getting your feet wet, I'm afraid. + InProgressMessage = 1074724; CompletionMessage = 1074725; // I can't wait to get to work now that you've returned with my scales. Objectives.Add(new CollectObjective(1, typeof(ThrashersTail), "Thrasher's Tail")); @@ -1492,8 +1492,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073913; // Cuts Both Ways - Description = - 1074103; // What would you say is a typical human instrument of war? Is a broadsword a typical example? I wish to see more of such human weapons, so I would gladly trade elven knowledge for human steel. + // What would you say is a typical human instrument of war? Is a broadsword a typical example? I wish to see more of such human weapons, so I would gladly trade elven knowledge for human steel. + Description = 1074103; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073959; // I will be in your debt if you bring me broadswords. CompletionMessage = 1073978; // Enjoy my thanks for your service. @@ -1511,8 +1511,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073915; // Dragon Protection - Description = - 1074105; // Mankind, I am told, knows how to take the scales of a terrible dragon and forge them into powerful armor. Such a feat of craftsmanship! I would give anything to view such a creation - I would even teach some of the prize secrets of the elven people. + // Mankind, I am told, knows how to take the scales of a terrible dragon and forge them into powerful armor. Such a feat of craftsmanship! I would give anything to view such a creation - I would even teach some of the prize secrets of the elven people. + Description = 1074105; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073961; // I will be in your debt if you bring me dragon armor. CompletionMessage = 1073978; // Enjoy my thanks for your service. @@ -1530,8 +1530,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073911; // Nothing Fancy - Description = - 1074101; // I am curious to see the results of human blacksmithing. To examine the care and quality of a simple item. Perhaps, a simple bascinet helmet? Yes, indeed -- if you could bring to me some bascinet helmets, I would demonstrate my gratitude. + // I am curious to see the results of human blacksmithing. To examine the care and quality of a simple item. Perhaps, a simple bascinet helmet? Yes, indeed -- if you could bring to me some bascinet helmets, I would demonstrate my gratitude. + Description = 1074101; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073957; // I will be in your debt if you bring me bascinets. CompletionMessage = 1073978; // Enjoy my thanks for your service. @@ -1549,8 +1549,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073912; // The Bulwark - Description = - 1074102; // The clank of human iron and steel is strange to elven ears. For instance, the metallic heater shield which human warriors carry into battle. It is odd to an elf, but nevertheless intriguing. Tell me friend, could you bring me such an example of human smithing skill? + // The clank of human iron and steel is strange to elven ears. For instance, the metallic heater shield which human warriors carry into battle. It is odd to an elf, but nevertheless intriguing. Tell me friend, could you bring me such an example of human smithing skill? + Description = 1074102; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073958; // I will be in your debt if you bring me heater shields. CompletionMessage = 1073978; // Enjoy my thanks for your service. @@ -1568,8 +1568,8 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; HasRestartDelay = true; Title = 1073882; // Arch Support - Description = - 1074072; // How clever humans are - to understand the need of feet to rest from time to time! Imagine creating a special stool just for weary toes. I would like to examine and learn the secret of their making. Would you bring me some foot stools to examine? + // How clever humans are - to understand the need of feet to rest from time to time! Imagine creating a special stool just for weary toes. I would like to examine and learn the secret of their making. Would you bring me some foot stools to examine? + Description = 1074072; RefusalMessage = 1073921; // I will patiently await your reconsideration. InProgressMessage = 1073928; // I will be in your debt if you bring me foot stools. CompletionMessage = 1073969; // My thanks for your service. Now, I will show you something of elven carpentry. @@ -1597,10 +1597,7 @@ namespace Server.Engines.MLQuests.Definitions 3, new[] { typeof(Succubus) }, "succubi", - new QuestArea( - 1074806, // The Palace of Paroxysmus - "The Palace of Paroxysmus" - ) + new QuestArea(1074806, "The Palace of Paroxysmus") ) ); @@ -1627,7 +1624,7 @@ namespace Server.Engines.MLQuests.Definitions "molochs", new QuestArea(1074806, "The Palace of Paroxysmus") ) - ); // The Palace of Paroxysmus + ); Rewards.Add(ItemReward.LargeBagOfTreasure); } @@ -1652,7 +1649,7 @@ namespace Server.Engines.MLQuests.Definitions "daemons", new QuestArea(1074806, "The Palace of Paroxysmus") ) - ); // The Palace of Paroxysmus + ); Rewards.Add(ItemReward.LargeBagOfTreasure); } @@ -1677,7 +1674,7 @@ namespace Server.Engines.MLQuests.Definitions "arcane daemons", new QuestArea(1074806, "The Palace of Paroxysmus") ) - ); // The Palace of Paroxysmus + ); Rewards.Add(ItemReward.LargeBagOfTreasure); } @@ -1703,7 +1700,7 @@ namespace Server.Engines.MLQuests.Definitions "poison elementals", new QuestArea(1074806, "The Palace of Paroxysmus") ) - ); // The Palace of Paroxysmus + ); Objectives.Add( new KillObjective( 6, @@ -1781,7 +1778,7 @@ namespace Server.Engines.MLQuests.Definitions "crystal lattice seekers", new QuestArea(1074805, "The Prism of Light") ) - ); // The Prism of Light + ); Rewards.Add(ItemReward.LargeBagOfTreasure); } @@ -1809,7 +1806,7 @@ namespace Server.Engines.MLQuests.Definitions "crystal daemons", new QuestArea(1074805, "The Prism of Light") ) - ); // The Prism of Light + ); Rewards.Add(ItemReward.LargeBagOfTreasure); } @@ -1837,7 +1834,7 @@ namespace Server.Engines.MLQuests.Definitions "crystal vortices", new QuestArea(1074805, "The Prism of Light") ) - ); // The Prism of Light + ); Rewards.Add(ItemReward.LargeBagOfTreasure); } @@ -1945,11 +1942,11 @@ namespace Server.Engines.MLQuests.Definitions { Activated = true; Title = 1072913; // Death to the Ninja! - Description = - 1072966; // I wish to make a statement of censure against the elite ninjas of the Black Order. Deliver, in the strongest manner, my disdain. But do not make war on women, even those that take arms against you. It is not ... fitting. + // I wish to make a statement of censure against the elite ninjas of the Black Order. Deliver, in the strongest manner, my disdain. But do not make war on women, even those that take arms against you. It is not ... fitting. + Description = 1072966; RefusalMessage = 1072979; // As you wish. - InProgressMessage = - 1072980; // The Black Order's fortress home is well hidden. Legend has it that a humble fishing village disguises the magical portal. + // The Black Order's fortress home is well hidden. Legend has it that a humble fishing village disguises the magical portal. + InProgressMessage = 1072980; // TODO: Verify that this has to be males only (as per the description) Objectives.Add( @@ -1959,7 +1956,7 @@ namespace Server.Engines.MLQuests.Definitions "elite ninjas", new QuestArea(1074804, "The Citadel") ) - ); // The Citadel + ); Rewards.Add(ItemReward.BagOfTreasure); } @@ -2049,9 +2046,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074186, // Come here, I have a task. - 1074183 + 1074183 // You there! I have a job for you. ) - ); // You there! I have a job for you. + ); } public override void Serialize(IGenericWriter writer) @@ -2116,9 +2113,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074187, // Want a job? - 1074210 + 1074210 // Hi. Looking for something to do? ) - ); // Hi.� Looking for something to do? + ); } public override void Serialize(IGenericWriter writer) @@ -2180,10 +2177,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074213, // Hey buddy.� Looking for work? - 1074187 + 1074213, // Hey buddy. Looking for work? + 1074187 // Want a job? ) - ); // Want a job? + ); } public override void Serialize(IGenericWriter writer) @@ -2247,9 +2244,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074211, // I could use some help. - 1074218 + 1074218 // Hey! I want to talk to you, now. ) - ); // Hey!� I want to talk to you, now. + ); } public override void Serialize(IGenericWriter writer) @@ -2314,7 +2311,7 @@ namespace Server.Engines.MLQuests.Definitions public override void Shout(PlayerMobile pm) { - MLQuestSystem.Tell(this, pm, 1074223); // Have you done it yet?� Oh, I haven�t told you, have I? + MLQuestSystem.Tell(this, pm, 1074223); // Have you done it yet? Oh, I haven't told you, have I? } public override void Serialize(IGenericWriter writer) @@ -2375,9 +2372,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074219, // Hello there, can I have a moment of your time? - 1074223 + 1074223 // Have you done it yet? Oh, I haven't told you, have I? ) - ); // Have you done it yet?� Oh, I haven�t told you, have I? + ); } public override void Serialize(IGenericWriter writer) @@ -2446,9 +2443,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074206, // Excuse me please traveler, might I have a little of your time? - 1074186 + 1074186 // Come here, I have a task. ) - ); // Come here, I have a task. + ); } public override void Serialize(IGenericWriter writer) @@ -2508,10 +2505,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074220, // May I call you friend?� I have a favor to beg of you. - 1074222 + 1074220, // May I call you friend? I have a favor to beg of you. + 1074222 // Could I trouble you for some assistance? ) - ); // Could I trouble you for some assistance? + ); } public override void Serialize(IGenericWriter writer) @@ -2585,10 +2582,10 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074188, // Weakling! You are not up to the task I have. - 1074191, // Just keep walking away!� I thought so. Coward!� I�ll bite your legs off! - 1074195 + 1074191, // Just keep walking away! I thought so. Coward! I'll bite your legs off! + 1074195 // You there, in the stupid hat! Come here. ) - ); // You there, in the stupid hat! Come here. + ); } public override void Serialize(IGenericWriter writer) @@ -2645,9 +2642,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074212, // *yawn* You busy? - 1074210 + 1074210 // Hi. Looking for something to do? ) - ); // Hi.� Looking for something to do? + ); } public override void Serialize(IGenericWriter writer) @@ -2707,10 +2704,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074204, // Greetings seeker.� I have an urgent matter for you, if you are willing. - 1074201 + 1074204, // Greetings seeker. I have an urgent matter for you, if you are willing. + 1074201 // Waste not a minute! There's work to be done. ) - ); // Waste not a minute! There�s work to be done. + ); } public override void Serialize(IGenericWriter writer) @@ -2770,9 +2767,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074211, // I could use some help. - 1074186 + 1074186 // Come here, I have a task. ) - ); // Come here, I have a task. + ); } public override void Serialize(IGenericWriter writer) @@ -2845,9 +2842,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074185, // Hey you! Want to help me out? - 1074186 + 1074186 // Come here, I have a task. ) - ); // Come here, I have a task. + ); } public override void Serialize(IGenericWriter writer) @@ -2927,10 +2924,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074207, // Good day to you friend! Allow me to offer you a fabulous opportunity!� Thrills and adventure await! - 1074209 + 1074207, // Good day to you friend! Allow me to offer you a fabulous opportunity! Thrills and adventure await! + 1074209 // Hey, could you help me out with something? ) - ); // Hey, could you help me out with something? + ); } public override void Serialize(IGenericWriter writer) @@ -2994,10 +2991,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074210, // Hi.� Looking for something to do? - 1074220 + 1074210, // Hi. Looking for something to do? + 1074220 // May I call you friend? I have a favor to beg of you. ) - ); // May I call you friend?� I have a favor to beg of you. + ); } public override void Serialize(IGenericWriter writer) @@ -3126,9 +3123,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074187, // Want a job? - 1074222 + 1074222 // Could I trouble you for some assistance? ) - ); // Could I trouble you for some assistance? + ); } public override void Serialize(IGenericWriter writer) @@ -3194,10 +3191,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074221, // Greetings!� I have a small task for you good traveler. - 1074201 + 1074221, // Greetings! I have a small task for you good traveler. + 1074201 // Waste not a minute! There's work to be done. ) - ); // Waste not a minute! There�s work to be done. + ); } public override void Serialize(IGenericWriter writer) @@ -3257,10 +3254,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074200, // Thank goodness you are here, there�s no time to lose. - 1074206 + 1074200, // Thank goodness you are here, there's no time to lose. + 1074206 // Excuse me please traveler, might I have a little of your time? ) - ); // Excuse me please traveler, might I have a little of your time? + ); } public override void Serialize(IGenericWriter writer) @@ -3440,10 +3437,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074210, // Hi.� Looking for something to do? - 1074213 + 1074210, // Hi. Looking for something to do? + 1074213 // Hey buddy. Looking for work? ) - ); // Hey buddy.� Looking for work? + ); } public override void Serialize(IGenericWriter writer) @@ -3502,10 +3499,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074223, // Have you done it yet?� Oh, I haven�t told you, have I? - 1074213 + 1074223, // Have you done it yet?' Oh, I haven't told you, have I? + 1074213 // Hey buddy. Looking for work? ) - ); // Hey buddy.� Looking for work? + ); } public override void Serialize(IGenericWriter writer) @@ -3698,10 +3695,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074221, // Greetings!� I have a small task for you good traveler. - 1074212 + 1074221, // Greetings! I have a small task for you good traveler. + 1074212 // *yawn* You busy? ) - ); // *yawn* You busy? + ); } public override void Serialize(IGenericWriter writer) @@ -3762,9 +3759,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074206, // Excuse me please traveler, might I have a little of your time? - 1074203 + 1074203 // Hello friend. I realize you are busy but if you would be willing to render me a service I can assure you that you will be judiciously renumerated. ) - ); // Hello friend. I realize you are busy but if you would be willing to render me a service I can assure you that you will be judiciously renumerated. + ); } public override void Serialize(IGenericWriter writer) @@ -4612,10 +4609,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074204, // Greetings seeker.� I have an urgent matter for you, if you are willing. - 1074200 + 1074204, // Greetings seeker. I have an urgent matter for you, if you are willing. + 1074200 // Thank goodness you are here, there's no time to lose. ) - ); // Thank goodness you are here, there�s no time to lose. + ); } public override void Serialize(IGenericWriter writer) @@ -4725,7 +4722,7 @@ namespace Server.Engines.MLQuests.Definitions public override void Shout(PlayerMobile pm) { - MLQuestSystem.Tell(this, pm, 1074197); // Pardon me, but if you could spare some time I�d greatly appreciate it. + MLQuestSystem.Tell(this, pm, 1074197); // Pardon me, but if you could spare some time I'd greatly appreciate it. } public override void Serialize(IGenericWriter writer) @@ -4780,7 +4777,7 @@ namespace Server.Engines.MLQuests.Definitions public override void Shout(PlayerMobile pm) { - MLQuestSystem.Tell(this, pm, 1074204); // Greetings seeker.� I have an urgent matter for you, if you are willing. + MLQuestSystem.Tell(this, pm, 1074204); // Greetings seeker. I have an urgent matter for you, if you are willing. } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/Heritage.cs b/Projects/UOContent/Engines/ML Quests/Definitions/Heritage.cs index 016d7be50..4284e0906 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/Heritage.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/Heritage.cs @@ -647,9 +647,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074188, // Weakling! You are not up to the task I have. - 1074195 + 1074195 // You there, in the stupid hat! Come here. ) - ); // You there, in the stupid hat! Come here. + ); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/HonestBeggar.cs b/Projects/UOContent/Engines/ML Quests/Definitions/HonestBeggar.cs index 249f6d0f5..3173d8179 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/HonestBeggar.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/HonestBeggar.cs @@ -16,14 +16,14 @@ namespace Server.Engines.MLQuests.Definitions 1075393; // Beg pardon, sir. I mean, madam. Uh, can I ask a favor of you? I found this jeweled ring. Most people would sell it and keep the money, but not me. I ain't never stole nothing, and I ain't about to start. I tried to take it over to Brit castle, figgerin' it must belong to some highborn lady, but the guards threw me out. You look like they might let you pass. Will you take the ring over there and see if you can find the owner? RefusalMessage = 1075395; // I see. Too good to help an honest beggar like me, eh? InProgressMessage = - 1075396; // A jewel like this must be worth a lot, so it must belong to some noble or another. I would show it around the castle. Someone�s bound to recognize it. + 1075396; // A jewel like this must be worth a lot, so it must belong to some noble or another. I would show it around the castle. Someone's bound to recognize it. CompletionMessage = 1075397; // Didst thou find my ring? I thank thee very much! It is an old ring, and a gift from my husband. I was most distraught when I realized it was missing. CompletionNotice = CompletionNoticeShort; Objectives.Add(new DeliverObjective(typeof(ReginasRing), 1, "Regina's Ring", typeof(Regina))); - Rewards.Add(new DummyReward(1075394)); // Find the ring�s owner. + Rewards.Add(new DummyReward(1075394)); // Find the ring's owner. } public override Type NextQuest => typeof(ReginasThanks); @@ -35,9 +35,9 @@ namespace Server.Engines.MLQuests.Definitions { Activated = true; OneTimeOnly = true; - Title = 1075398; // Regina�s Thanks + Title = 1075398; // Regina's Thanks Description = - 1075399; // What�s that you say? It was a humble beggar that found my ring? Such honesty must be rewarded. Here, take this packet and return it to him, and I will be in your debt. + 1075399; // What's that you say? It was a humble beggar that found my ring? Such honesty must be rewarded. Here, take this packet and return it to him, and I will be in your debt. RefusalMessage = 1075401; // Hmph. Very well. What did you say his name was? InProgressMessage = 1075402; // Take the packet and return it to the beggar who found my ring. CompletionMessage = diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/Ilshenar.cs b/Projects/UOContent/Engines/ML Quests/Definitions/Ilshenar.cs index 3740ed710..394010258 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/Ilshenar.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/Ilshenar.cs @@ -127,10 +127,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074204, // Greetings seeker.  I have an urgent matter for you, if you are willing. - 1074222 + 1074204, // Greetings seeker. I have an urgent matter for you, if you are willing. + 1074222 // Could I trouble you for some assistance? ) - ); // Could I trouble you for some assistance? + ); } public override void InitBody() @@ -254,7 +254,7 @@ namespace Server.Engines.MLQuests.Definitions public override void Shout(PlayerMobile pm) { - MLQuestSystem.Tell(this, pm, 1074221); // Greetings!  I have a small task for you good traveler. + MLQuestSystem.Tell(this, pm, 1074221); // Greetings! I have a small task for you good traveler. } public override void Serialize(IGenericWriter writer) @@ -305,7 +305,7 @@ namespace Server.Engines.MLQuests.Definitions public override void Shout(PlayerMobile pm) { - MLQuestSystem.Tell(this, pm, 1074218); // Hey!  I want to talk to you, now. + MLQuestSystem.Tell(this, pm, 1074218); // Hey! I want to talk to you, now. } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/MistakenIdentity.cs b/Projects/UOContent/Engines/ML Quests/Definitions/MistakenIdentity.cs index 386948938..057188b8d 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/MistakenIdentity.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/MistakenIdentity.cs @@ -273,10 +273,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074200, // Thank goodness you are here, there�s no time to lose. - 1074203 + 1074200, // Thank goodness you are here, there's no time to lose. + 1074203 // Hello friend. I realize you are busy but if you would be willing to render me a service I can assure you that you will be judiciously renumerated. ) - ); // Hello friend. I realize you are busy but if you would be willing to render me a service I can assure you that you will be judiciously renumerated. + ); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenSkillTraining.cs b/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenSkillTraining.cs index 0e1bcdd58..d0d38411c 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenSkillTraining.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenSkillTraining.cs @@ -1995,9 +1995,9 @@ namespace Server.Engines.MLQuests.Definitions Utility.RandomList( 1078213, // I don't sleep. I wait. 1078212, // There is no theory of evolution. Just a list of creatures I allow to live. - 1078214 + 1078214 // I can lead a horse to water and make it drink. ) - ); // I can lead a horse to water and make it drink. + ); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenTraining.cs b/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenTraining.cs index 42d2e9227..3eeccc7b0 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenTraining.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/NewHavenTraining.cs @@ -114,7 +114,7 @@ namespace Server.Engines.MLQuests.Definitions 1075529; // Have a pickaxe? My supplier is late and I need some iron ore so I can complete a bulk order for another merchant. If you can get me some soon I'll pay you double what it's worth on the market. Just find a cave or mountainside and try to use your pickaxe there, maybe you'll strike a good vein! 5 large pieces should do it. RefusalMessage = 1075531; // Not feeling strong enough today? Its alright, I didn't need a bucket of rocks anyway. - InProgressMessage = 1075532; // Hmmm� we need some more Ore. Try finding a mountain or cave, and give it a whack. + InProgressMessage = 1075532; // Hmmm' we need some more Ore. Try finding a mountain or cave, and give it a whack. CompletionMessage = 1075533; // I see you found a good vien! Great! This will help get this order out on time. Good work! @@ -317,9 +317,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 + 1074213 // Hey buddy. Looking for work? ) - ); // Hey buddy.� Looking for work? + ); } public override void Serialize(IGenericWriter writer) @@ -438,9 +438,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 + 1074213 // Hey buddy. Looking for work? ) - ); // Hey buddy.� Looking for work? + ); } public override void Serialize(IGenericWriter writer) @@ -495,9 +495,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 + 1074213 // Hey buddy. Looking for work? ) - ); // Hey buddy.� Looking for work? + ); } public override void Serialize(IGenericWriter writer) @@ -562,10 +562,10 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213, // Hey buddy.� Looking for work? - 1074211 + 1074213, // Hey buddy. Looking for work? + 1074211 // I could use some help. ) - ); // I could use some help. + ); } public override void Serialize(IGenericWriter writer) @@ -674,9 +674,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 + 1074213 // Hey buddy. Looking for work? ) - ); // Hey buddy.� Looking for work? + ); } public override void Serialize(IGenericWriter writer) @@ -730,9 +730,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 + 1074213 // Hey buddy. Looking for work? ) - ); // Hey buddy.� Looking for work? + ); } public override void Serialize(IGenericWriter writer) @@ -832,10 +832,10 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213, // Hey buddy.� Looking for work? - 1074211 + 1074213, // Hey buddy. Looking for work? + 1074211 // I could use some help. ) - ); // I could use some help. + ); } public override void Serialize(IGenericWriter writer) @@ -892,10 +892,10 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213, // Hey buddy.� Looking for work? - 1074211 + 1074213, // Hey buddy. Looking for work? + 1074211 // I could use some help. ) - ); // I could use some help. + ); } public override void Serialize(IGenericWriter writer) @@ -957,10 +957,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074213, // Hey buddy.� Looking for work? - 1074211 + 1074213, // Hey buddy. Looking for work? + 1074211 // I could use some help. ) - ); // I could use some help. + ); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/Sanctuary.cs b/Projects/UOContent/Engines/ML Quests/Definitions/Sanctuary.cs index 555574a9f..97a363595 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/Sanctuary.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/Sanctuary.cs @@ -389,7 +389,7 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; Title = 1073085; // Arch Enemies Description = - 1073575; // Vermin! They get into everything! I told the boy to leave out some poisoned cheese -- and they shot him. What else can I do? Unless�these ratmen are skilled with a bow, but I'd lay a wager you're better, eh? Could you skin a few of the wretches for me? + 1073575; // Vermin! They get into everything! I told the boy to leave out some poisoned cheese -- and they shot him. What else can I do? Unless these ratmen are skilled with a bow, but I'd lay a wager you're better, eh? Could you skin a few of the wretches for me? RefusalMessage = 1073580; // I hope you'll reconsider. Until then, farwell. InProgressMessage = 1073595; // I don't see 10 tails from Ratman Archers on your belt -- and until I do, no reward for you. @@ -804,9 +804,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074187, // Want a job? - 1074184 + 1074184 // Come here, I have work for you. ) - ); // Come here, I have work for you. + ); } public override void Serialize(IGenericWriter writer) @@ -864,7 +864,7 @@ namespace Server.Engines.MLQuests.Definitions public override void Shout(PlayerMobile pm) { - MLQuestSystem.Tell(this, pm, 1074197); // Pardon me, but if you could spare some time I�d greatly appreciate it. + MLQuestSystem.Tell(this, pm, 1074197); // Pardon me, but if you could spare some time I'd greatly appreciate it. } public override void Serialize(IGenericWriter writer) @@ -923,9 +923,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074188, // Weakling! You are not up to the task I have. - 1074211 + 1074211 // I could use some help. ) - ); // I could use some help. + ); } public override void Serialize(IGenericWriter writer) @@ -993,11 +993,10 @@ namespace Server.Engines.MLQuests.Definitions MLQuestSystem.Tell( this, pm, - Utility.RandomList( - 1074214, // Knave! Come here right now! - 1074218 - ) - ); // Hey!� I want to talk to you, now. + // Knave! Come here right now! + // Hey! I want to talk to you, now. + 1074214 + Utility.Random(2) + ); } public override void Serialize(IGenericWriter writer) @@ -1119,10 +1118,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074196, // Excuse me! I�m sorry to interrupt but I urgently need some assistance. - 1074197 + 1074196, // Excuse me! I'm sorry to interrupt but I urgently need some assistance. + 1074197 // Pardon me, but if you could spare some time I'd greatly appreciate it. ) - ); // Pardon me, but if you could spare some time I�d greatly appreciate it. + ); } public override void Serialize(IGenericWriter writer) @@ -1183,9 +1182,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074185, // Hey you! Want to help me out? - 1074195 + 1074195 // You there, in the stupid hat! Come here. ) - ); // You there, in the stupid hat! Come here. + ); } public override void Serialize(IGenericWriter writer) @@ -1245,9 +1244,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074193, // You there! Yes you. Stop looking about like a toadie and come here. - 1074186 + 1074186 // Come here, I have a task. ) - ); // Come here, I have a task. + ); } public override void Serialize(IGenericWriter writer) @@ -1350,10 +1349,10 @@ namespace Server.Engines.MLQuests.Definitions this, pm, Utility.RandomList( - 1074217, // I want to make you an offer you�d be a fool to �refuse. - 1074218 + 1074217, // I want to make you an offer you'd be a fool to 'refuse. + 1074218 // Hey! I want to talk to you, now. ) - ); // Hey!� I want to talk to you, now. + ); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/Spellweaving.cs b/Projects/UOContent/Engines/ML Quests/Definitions/Spellweaving.cs index c583a9cd2..38104cf18 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/Spellweaving.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/Spellweaving.cs @@ -347,11 +347,8 @@ namespace Server.Engines.MLQuests.Definitions Objectives.Add(new CollectObjective(1, typeof(Beads), 1024235)); // beads Objectives.Add(new CollectObjective(1, typeof(JarHoney), 1022540)); // jar of honey - Rewards.Add( - new DummyReward( - 1074874 - ) - ); // The opportunity to prove yourself worthy of learning to Summon Fey. (Sufficient spellweaving skill is required to cast the spell) + // The opportunity to prove yourself worthy of learning to Summon Fey. (Sufficient spellweaving skill is required to cast the spell) + Rewards.Add(new DummyReward(1074874)); } public override Type NextQuest => typeof(TokenOfFriendship); @@ -372,11 +369,8 @@ namespace Server.Engines.MLQuests.Definitions Objectives.Add(new DeliverObjective(typeof(GiftForArielle), 1, "gift for Arielle", typeof(Arielle))); - Rewards.Add( - new DummyReward( - 1074874 - ) - ); // The opportunity to prove yourself worthy of learning to Summon Fey. (Sufficient spellweaving skill is required to cast the spell) + // The opportunity to prove yourself worthy of learning to Summon Fey. (Sufficient spellweaving skill is required to cast the spell) + Rewards.Add(new DummyReward(1074874)); } public override Type NextQuest => typeof(Alliance); @@ -455,11 +449,8 @@ namespace Server.Engines.MLQuests.Definitions Objectives.Add(new CollectObjective(1, typeof(StoutWhip), "Stout Whip")); - Rewards.Add( - new DummyReward( - 1074873 - ) - ); // The opportunity to prove yourself worthy of learning to Summon Fiends. (Sufficient spellweaving skill is required to cast the spell) + // The opportunity to prove yourself worthy of learning to Summon Fiends. (Sufficient spellweaving skill is required to cast the spell) + Rewards.Add(new DummyReward(1074873)); } public override Type NextQuest => typeof(CrackingTheWhipII); @@ -607,9 +598,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074186, // Come here, I have a task. - 1074218 + 1074218 // Hey! I want to talk to you, now. ) - ); // Hey! I want to talk to you, now. + ); } public override void Serialize(IGenericWriter writer) @@ -728,9 +719,9 @@ namespace Server.Engines.MLQuests.Definitions pm, Utility.RandomList( 1074215, // Don’t test my patience you sniveling worm! - 1074218 + 1074218 // Hey! I want to talk to you, now. ) - ); // Hey!  I want to talk to you, now. + ); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/TheAncientWorld.cs b/Projects/UOContent/Engines/ML Quests/Definitions/TheAncientWorld.cs index f7752d8b7..61a66f811 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/TheAncientWorld.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/TheAncientWorld.cs @@ -130,7 +130,7 @@ namespace Server.Engines.MLQuests.Definitions public override void Shout(PlayerMobile pm) { - MLQuestSystem.Tell(this, pm, 1074200); // Thank goodness you are here, there�s no time to lose. + MLQuestSystem.Tell(this, pm, 1074200); // Thank goodness you are here, there's no time to lose. } public override void Serialize(IGenericWriter writer) diff --git a/Projects/UOContent/Engines/ML Quests/Definitions/UnfadingMemories.cs b/Projects/UOContent/Engines/ML Quests/Definitions/UnfadingMemories.cs index b7a9b6b12..cfa189062 100644 --- a/Projects/UOContent/Engines/ML Quests/Definitions/UnfadingMemories.cs +++ b/Projects/UOContent/Engines/ML Quests/Definitions/UnfadingMemories.cs @@ -12,22 +12,19 @@ namespace Server.Engines.MLQuests.Definitions { Activated = true; Title = 1075355; // Unfading Memories - Description = - 1075356; // Aargh! It�s just not right! It doesn�t capture the unique color of her hair at all! If only I had some Prismatic Amber. That would be perfect. They used to mine it in Malas, but alas, those veins ran dry some time ago. I hear it may have been found in the Prism of Light. Oh, if only there were a bold adventurer within earshot who would go to the Prism of Light and retrieve some for me! + // Aargh! It's just not right! It doesn't capture the unique color of her hair at all! If only I had some Prismatic Amber. That would be perfect. They used to mine it in Malas, but alas, those veins ran dry some time ago. I hear it may have been found in the Prism of Light. Oh, if only there were a bold adventurer within earshot who would go to the Prism of Light and retrieve some for me! + Description = 1075356; RefusalMessage = 1075358; // Is there no one who can help a humble artist pursue his Muse? - InProgressMessage = - 1075359; // You can find Prismatic Amber in the Prism of Light, located just north of the city of Nujel'm. - CompletionMessage = - 1075360; // I knew it! See, it�s just the color I needed! Look how it brings out the highlights of her wheaten tresses! + // You can find Prismatic Amber in the Prism of Light, located just north of the city of Nujel'm. + InProgressMessage = 1075359; + // I knew it! See, it's just the color I needed! Look how it brings out the highlights of her wheaten tresses! + CompletionMessage = 1075360; CompletionNotice = CompletionNoticeShort; Objectives.Add(new CollectObjective(1, typeof(PrismaticAmber), "Prismatic Amber")); - Rewards.Add( - new DummyReward( - 1075357 - ) - ); // The joy of contributing to a noble artistic effort, however paltry the end product. + // The joy of contributing to a noble artistic effort, however paltry the end product. + Rewards.Add(new DummyReward(1075357)); } public override Type NextQuest => typeof(UnfadingMemoriesPartTwo); @@ -39,19 +36,19 @@ namespace Server.Engines.MLQuests.Definitions { Activated = true; Title = 1075367; // Unfading Memories - Description = - 1075368; // Finished! With the pigment I was able to create from the Prismatic Amber you brought me, I was able to complete my humble work. I should explain. Once, I loved a noble lady of gentleness and refinement, who possessed such beauty that I have found myself unable to love another to this day. But it was from afar that I admired her, for it is not for one so lowly as I to pay court to the likes of her. You have heard of the fair Thalia, Lady of Nujel'm? No? Well, she was my Muse, my inspiration, and when I heard she was to be married, I lost whatever pitiful talent I possessed. I felt I must compose a portrait of her, my masterpiece, or I would never be able to paint again. You, my friend, have helped me complete my work. Now I ask another favor of you. Will you take it to her as a wedding gift? She will probably reject it, but I must make the offer. - RefusalMessage = - 1075370; // Alright then, you have already helped me more than I deserved. I shall find someone else to undertake this task. - InProgressMessage = - 1075371; // The wedding is taking place in the palace in Nujel'm. You will likely find her there. - CompletionMessage = - 1075372; // I�m sorry, I�m getting ready to be married. I don�t have time to . . . what�s that you say? + // Finished! With the pigment I was able to create from the Prismatic Amber you brought me, I was able to complete my humble work. I should explain. Once, I loved a noble lady of gentleness and refinement, who possessed such beauty that I have found myself unable to love another to this day. But it was from afar that I admired her, for it is not for one so lowly as I to pay court to the likes of her. You have heard of the fair Thalia, Lady of Nujel'm? No? Well, she was my Muse, my inspiration, and when I heard she was to be married, I lost whatever pitiful talent I possessed. I felt I must compose a portrait of her, my masterpiece, or I would never be able to paint again. You, my friend, have helped me complete my work. Now I ask another favor of you. Will you take it to her as a wedding gift? She will probably reject it, but I must make the offer. + Description = 1075368; + // Alright then, you have already helped me more than I deserved. I shall find someone else to undertake this task. + RefusalMessage = 1075370; + // The wedding is taking place in the palace in Nujel'm. You will likely find her there. + InProgressMessage = 1075371; + // I'm sorry, I'm getting ready to be married. I don't have time to . . . what's that you say? + CompletionMessage = 1075372; CompletionNotice = CompletionNoticeShort; Objectives.Add(new DeliverObjective(typeof(PortraitOfTheBride), 1, "Portrait of the Bride", typeof(Thalia))); - Rewards.Add(new DummyReward(1075369)); // The Artist�s gratitude. + Rewards.Add(new DummyReward(1075369)); // The Artist's gratitude. } public override Type NextQuest => typeof(UnfadingMemoriesPartThree); @@ -65,13 +62,13 @@ namespace Server.Engines.MLQuests.Definitions Activated = true; OneTimeOnly = true; Title = 1075373; // Unfading Memories - Description = - 1075374; // Emilio painted this? It is absolutely wonderful! I used to love looking at his paintings, but I don�t remember him creating anything like this before. Would you be so kind as to carry a letter to him? Fate may have it that I am to marry another, yet I am compelled to reveal to him that his love was not entirely unrequited. + // Emilio painted this? It is absolutely wonderful! I used to love looking at his paintings, but I don't remember him creating anything like this before. Would you be so kind as to carry a letter to him? Fate may have it that I am to marry another, yet I am compelled to reveal to him that his love was not entirely unrequited. + Description = 1075374; RefusalMessage = 1075376; // Very well, then. If you will excuse me, I need to get ready. - InProgressMessage = - 1075377; // Take the letter back to the Artist�s Guild in Britain, if you would do me this kindness. - CompletionMessage = - 1075378; // She said what? She thinks what of me? I . . . I can�t believe it! All this time, I never knew how she truly felt. Thank you, my friend. I believe now I will be able to paint once again. Here, take this bleach. I was going to use it to destroy all of my works. Perhaps you can find a better use for it now. + // Take the letter back to the Artist's Guild in Britain, if you would do me this kindness. + InProgressMessage = 1075377; + // She said what? She thinks what of me? I . . . I can't believe it! All this time, I never knew how she truly felt. Thank you, my friend. I believe now I will be able to paint once again. Here, take this bleach. I was going to use it to destroy all of my works. Perhaps you can find a better use for it now. + CompletionMessage = 1075378; CompletionNotice = CompletionNoticeShort; Objectives.Add(new DeliverObjective(typeof(BridesLetter), 1, "Bride's Letter", typeof(Emilio))); diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs index c86e0915f..e372f9c17 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs @@ -119,7 +119,7 @@ namespace Server.Engines.Quests.Necro * * Do not speak this password anywhere except when seeking passage * into the Crystal Cave, as our adversaries are lurking in the - * shadows � they are everywhere.

Go with the light, friend.

+ * shadows ' they are everywhere.

Go with the light, friend.

* * - Frater Melkeer */ diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs index 06b511eb3..ae582b41d 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs @@ -8,7 +8,7 @@ namespace Server.Engines.Quests.Ninja { public static int[] Messages = { - 1063191, // They won�t find me here. + 1063191, // They won't find me here. 1063192 // Ah, a quiet hideout. }; diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs index 861b3620e..1ff8e26b0 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Conversations.cs @@ -242,24 +242,23 @@ namespace Server.Engines.Quests.Samurai { if (m_KilledCat) { + /* + * Respect comes from allowing another to make their own decisions. + * By denying the gypsy her animals, you negate the respect she is due. + * Perhaps you will have learned something to use next time a similar situation arises. + *

And now you must prove yourself again. Please retrieve my katana from the treasure room and return it to me. + */ return 1063071; } - /* You showed respect by helping another out while allowing the gypsy - * what little dignity she has left.

- * - * Now she will be able to feed herself and gain enough energy to walk - * to her camp.

- * - * The cats are her family members� cursed by an evil mage.

- * - * Once she has enough strength to walk back to the camp, she will be - * able to undo the spell.

- * - * You have been rewarded for completing your trial. And now you must - * prove yourself again.

Please retrieve my katana from the - * treasure room and return it to me. - */ + /* + * You showed respect by helping another out while allowing the gypsy what little dignity she has left. + *

Now she will be able to feed herself and gain enough energy to walk to her camp. + *

The cats are her family members– cursed by an evil mage. + *

Once she has enough strength to walk back to the camp, she will be able to undo the spell. + *

You have been rewarded for completing your trial. And now you must prove yourself again. + *

Please retrieve my katana from the treasure room and return it to me. + */ return 1063070; } } @@ -317,17 +316,23 @@ namespace Server.Engines.Quests.Samurai { if (m_StolenTreasure) { + /* + * I thank you for returning this sword. + * However, you should admonished for also taking treasure that was not asked for nor given back. + *

Think about your actions youngling. + *

Your training is nearly complete. + * Before you have your final trial, you should pay homage to Samurai who came before you. + *

Go into the Altar Room and light a candle for them. Afterwards, return to me. + */ return 1063077; } - /* Thank you for returning this sword to me and leaving the remaining - * treasure alone.

- * - * Your training is nearly complete. Before you have your final trial, - * you should pay homage to Samurai who came before you.

- * - * Go into the Altar Room and light a candle for them. Afterwards, return to me. - */ + /* + * Thank you for returning this sword to me and leaving the remaining treasure alone. + *

Your training is nearly complete. + * Before you have your final trial, you should pay homage to Samurai who came before you. + *

Go into the Altar Room and light a candle for them. Afterwards, return to me. + */ return 1063076; } } diff --git a/Projects/UOContent/Gumps/RunebookGump.cs b/Projects/UOContent/Gumps/RunebookGump.cs index b7bb8d81c..8e95372d8 100644 --- a/Projects/UOContent/Gumps/RunebookGump.cs +++ b/Projects/UOContent/Gumps/RunebookGump.cs @@ -182,8 +182,8 @@ namespace Server.Gumps if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth)) { - AddLabel(135 + half * 160, 80, 0, $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}"); - AddLabel(135 + half * 160, 95, 0, $"{xLong}� {xMins}'{(xEast ? "E" : "W")}"); + AddLabel(135 + half * 160, 80, 0, $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}"); + AddLabel(135 + half * 160, 95, 0, $"{xLong}° {xMins}'{(xEast ? "E" : "W")}"); } // Drop rune button @@ -294,7 +294,7 @@ namespace Server.Gumps )) { var location = - $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}' {xMins}'{(xEast ? "E" : "W")}"; from.SendMessage(location); } @@ -365,7 +365,7 @@ namespace Server.Gumps )) { var location = - $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}' {xMins}'{(xEast ? "E" : "W")}"; from.SendMessage(location); } @@ -401,7 +401,7 @@ namespace Server.Gumps )) { var location = - $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}' {xMins}'{(xEast ? "E" : "W")}"; from.SendMessage(location); } @@ -439,7 +439,7 @@ namespace Server.Gumps )) { var location = - $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}' {xMins}'{(xEast ? "E" : "W")}"; from.SendMessage(location); } diff --git a/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs b/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs index 9696cb3b4..52ecdc322 100644 --- a/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs +++ b/Projects/UOContent/Items/Shields/Artifacts/Aegis.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1061602; // �gis + public override int LabelNumber => 1061602; // Ægis public override int ArtifactRarity => 11; public override int BasePhysicalResistance => 15; diff --git a/Projects/UOContent/Items/Shields/BaseShield.cs b/Projects/UOContent/Items/Shields/BaseShield.cs index 93f4bcd35..1b2ca14cd 100644 --- a/Projects/UOContent/Items/Shields/BaseShield.cs +++ b/Projects/UOContent/Items/Shields/BaseShield.cs @@ -78,16 +78,7 @@ namespace Server.Items absorbed = 2; } - int wear; - - if (weapon.Type == WeaponType.Bashing) - { - wear = absorbed / 2; - } - else - { - wear = Utility.Random(2); - } + var wear = weapon.Type == WeaponType.Bashing ? absorbed / 2 : Utility.Random(2); if (wear > 0 && MaxHitPoints > 0) { @@ -110,11 +101,8 @@ namespace Server.Items if (Parent is Mobile mobile) { - mobile.LocalOverheadMessage( - MessageType.Regular, - 0x3B2, - 1061121 - ); // Your equipment is severely damaged. + // Your equipment is severely damaged. + mobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121); } } else @@ -128,7 +116,7 @@ namespace Server.Items return 0; } - if (!(Parent is Mobile owner)) + if (Parent is not Mobile owner) { return damage; } @@ -141,13 +129,6 @@ namespace Server.Items chance = 0.01; } - /* - FORMULA: Displayed AR = ((Parrying Skill * Base AR of Shield) � 200) + 1 - - FORMULA: % Chance of Blocking = parry skill - (shieldAR * 2) - - FORMULA: Melee Damage Absorbed = (AR of Shield) / 2 | Archery Damage Absorbed = AR of Shield - */ if (owner.CheckSkill(SkillName.Parry, chance)) { damage -= Math.Min(damage, weapon.Skill == SkillName.Archery ? (int)ar : (int)(ar / 2.0)); @@ -177,11 +158,8 @@ namespace Server.Items { MaxHitPoints -= wear; - ((Mobile)Parent).LocalOverheadMessage( - MessageType.Regular, - 0x3B2, - 1061121 - ); // Your equipment is severely damaged. + // Your equipment is severely damaged. + ((Mobile)Parent).LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061121); } else { diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs index 416550283..26a0f6b7a 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SOS.cs @@ -281,7 +281,7 @@ namespace Server.Items if (Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth)) { - fmt = $"{yLat}°{yMins}'{(ySouth ? "S" : "N")},{xLong}°{xMins}'{(xEast ? "E" : "W")}"; + fmt = $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}°{xMins}'{(xEast ? "E" : "W")}"; } else { diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs index 4302ea80c..a36fd7644 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/Sextant.cs @@ -33,7 +33,7 @@ namespace Server.Items if (Format(from.Location, from.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth)) { - var location = $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + var location = $"{yLat}° {yMins}'{(ySouth ? "S" : "N")}, {xLong}' {xMins}'{(xEast ? "E" : "W")}"; from.LocalOverheadMessage(MessageType.Regular, from.SpeechHue, false, location); } } diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs index 794d5f582..3e89229a0 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs @@ -123,7 +123,7 @@ namespace Server.Items { } - public override int LabelNumber => 1075198; // Dawn�s Music Box + public override int LabelNumber => 1075198; // Dawn's Music Box public List Tracks { get; private set; } diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/DupresShield.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/DupresShield.cs index 8cc2ebff7..1471b0bb8 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/DupresShield.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/DupresShield.cs @@ -18,7 +18,7 @@ namespace Server.Items { } - public override int LabelNumber => 1075196; // Dupre�s Shield + public override int LabelNumber => 1075196; // Dupre's Shield public override int BasePhysicalResistance => 1; public override int BaseFireResistance => 0; diff --git a/Projects/UOContent/Items/Special/Gifts/ShaminoCrossbow.cs b/Projects/UOContent/Items/Special/Gifts/ShaminoCrossbow.cs index 3589cad06..e6bf55857 100644 --- a/Projects/UOContent/Items/Special/Gifts/ShaminoCrossbow.cs +++ b/Projects/UOContent/Items/Special/Gifts/ShaminoCrossbow.cs @@ -18,7 +18,7 @@ namespace Server.Items { } - public override int LabelNumber => 1062915; // Shamino�s Best Crossbow + public override int LabelNumber => 1062915; // Shamino's Best Crossbow public override int InitMinHits => 255; public override int InitMaxHits => 255; diff --git a/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs b/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs index 499240523..47d7fa94e 100644 --- a/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs +++ b/Projects/UOContent/Items/Special/Holiday/HolidayFoods.cs @@ -118,9 +118,9 @@ namespace Server.Items 1077396, // Noooo! 1077397, // Please don't eat me... *whimper* 1077405, // Not the face! - 1077406, // Ahhhhhh! My foot�s gone! + 1077406, // Ahhhhhh! My foot's gone! 1077407, // Please. No! I have gingerkids! - 1077408, // No, no! I�m really made of poison. Really. + 1077408, // No, no! I'm really made of poison. Really. 1077409 // Run, run as fast as you can! You can't catch me! I'm the gingerbread man! }; diff --git a/Projects/UOContent/Items/Wands/BaseWand.cs b/Projects/UOContent/Items/Wands/BaseWand.cs index 8bab32252..448985af1 100644 --- a/Projects/UOContent/Items/Wands/BaseWand.cs +++ b/Projects/UOContent/Items/Wands/BaseWand.cs @@ -34,14 +34,7 @@ namespace Server.Items [SerializableField(1)] private int _charges; - public BaseWand(WandEffect effect, int minCharges, int maxCharges) : base( - Utility.RandomList( - 0xDF2, - 0xDF3, - 0xDF4, - 0xDF5 - ) - ) + public BaseWand(WandEffect effect, int minCharges, int maxCharges) : base(0xDF2 + Utility.Random(4)) { Weight = 1.0; _wandEffect = effect; diff --git a/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs b/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs index 05b0e9969..9939e2a14 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/InfectiousStrike.cs @@ -4,7 +4,7 @@ namespace Server.Items { /// /// This special move represents a significant change to the use of poisons in Age of Shadows. - /// Now, only certain weapon types � those that have Infectious Strike as an available special move � will be able to be + /// Now, only certain weapon types, those that have Infectious Strike as an available special move will be able to be /// poisoned. /// Targets will no longer be poisoned at random when hit by poisoned weapons. /// Instead, the wielder must use this ability to deliver the venom. diff --git a/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs b/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs index 29d6e5eaa..18b174893 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/ShadowStrike.cs @@ -2,7 +2,7 @@ namespace Server.Items { /// /// This powerful ability requires secondary skills to activate. - /// Successful use of Shadowstrike deals extra damage to the target � and renders the attacker invisible! + /// Successful use of Shadowstrike deals extra damage to the target and renders the attacker invisible! /// Only those who are adept at the art of stealth will be able to use this ability. /// public class ShadowStrike : WeaponAbility diff --git a/Projects/UOContent/Spells/Base/Spell.cs b/Projects/UOContent/Spells/Base/Spell.cs index 73afcba5b..120d85be1 100644 --- a/Projects/UOContent/Spells/Base/Spell.cs +++ b/Projects/UOContent/Spells/Base/Spell.cs @@ -206,7 +206,7 @@ namespace Server.Spells damageBonus += intBonus; var sdiBonus = AosAttributes.GetValue(Caster, AosAttribute.SpellDamage); - // PvP spell damage increase cap of 15% from an item�s magic property + // PvP spell damage increase cap of 15% from an item's magic property if (playerVsPlayer && sdiBonus > 15) { sdiBonus = 15; diff --git a/Projects/UOContent/Spells/Fifth/MagicReflect.cs b/Projects/UOContent/Spells/Fifth/MagicReflect.cs index d83582374..ca1e0256e 100644 --- a/Projects/UOContent/Spells/Fifth/MagicReflect.cs +++ b/Projects/UOContent/Spells/Fifth/MagicReflect.cs @@ -52,7 +52,8 @@ namespace Server.Spells.Fifth * Physical decrease = 25 - (Inscription/20). * Elemental resistance = +10 (-20 physical, +10 elemental at GM Inscription) * The magic reflection spell has an indefinite duration, becoming active when cast, and deactivated when re-cast. - * Reactive Armor, Protection, and Magic Reflection will stay on�even after logging out, even after dying�until you �turn them off� by casting them again. + * Reactive Armor, Protection, and Magic Reflection will stay on even after logging out, + * even after dying, until you turn them off by casting them again. */ if (CheckSequence()) diff --git a/Projects/UOContent/Spells/First/ReactiveArmor.cs b/Projects/UOContent/Spells/First/ReactiveArmor.cs index 8659c1253..168ba4b81 100644 --- a/Projects/UOContent/Spells/First/ReactiveArmor.cs +++ b/Projects/UOContent/Spells/First/ReactiveArmor.cs @@ -53,7 +53,8 @@ namespace Server.Spells.First * 15 + (Inscription/20) Physcial bonus * -5 Elemental * The reactive armor spell has an indefinite duration, becoming active when cast, and deactivated when re-cast. - * Reactive Armor, Protection, and Magic Reflection will stay on�even after logging out, even after dying�until you �turn them off� by casting them again. + * Reactive Armor, Protection, and Magic Reflection will stay on even after logging out, + * even after dying, until you turn them off by casting them again. * (+20 physical -5 elemental at 100 Inscription) */ diff --git a/Projects/UOContent/Spells/Necromancy/Wither.cs b/Projects/UOContent/Spells/Necromancy/Wither.cs index 64329bf17..9ecf7fdfe 100644 --- a/Projects/UOContent/Spells/Necromancy/Wither.cs +++ b/Projects/UOContent/Spells/Necromancy/Wither.cs @@ -98,7 +98,7 @@ namespace Server.Spells.Necromancy var sdiBonus = AosAttributes.GetValue(Caster, AosAttribute.SpellDamage); - // PvP spell damage increase cap of 15% from an item�s magic property in Publish 33(SE) + // PvP spell damage increase cap of 15% from an item's magic property in Publish 33(SE) if (Core.SE && m.Player && Caster.Player && sdiBonus > 15) { sdiBonus = 15; diff --git a/Projects/UOContent/Spells/Second/Protection.cs b/Projects/UOContent/Spells/Second/Protection.cs index 7944e3015..8271276b5 100644 --- a/Projects/UOContent/Spells/Second/Protection.cs +++ b/Projects/UOContent/Spells/Second/Protection.cs @@ -56,8 +56,8 @@ namespace Server.Spells.Second * a decreased "resisting spells" skill value by -35 + (Inscription/20), * and a slower casting speed modifier (technically, a negative "faster cast speed") of 2 points. * The protection spell has an indefinite duration, becoming active when cast, and deactivated when re-cast. - * Reactive Armor, Protection, and Magic Reflection will stay on�even after logging out, - * even after dying�until you �turn them off� by casting them again. + * Reactive Armor, Protection, and Magic Reflection will stay on even after logging out, + * even after dying, until you turn them off by casting them again. */ if (_table.Remove(target, out var mods)) From 4f9714818d222def73eddde41b7a29154b51c363 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 5 Dec 2021 09:40:57 -0800 Subject: [PATCH 04/14] fix: Fixes skill requirements and cleans up magery spells (#870) * Preps damage stacking for mysticism, necromancy fixes, and spellweaving * Removes extra LINQ allocations * Fixes skill requirements for magery spells. --- Projects/UOContent/Spells/Base/MagerySpell.cs | 31 +++-- Projects/UOContent/Spells/Base/SpecialMove.cs | 58 +++----- Projects/UOContent/Spells/Base/Spell.cs | 90 ++++++------ Projects/UOContent/Spells/Base/SpellHelper.cs | 124 ++++++----------- .../UOContent/Spells/Eighth/Resurrection.cs | 5 +- Projects/UOContent/Spells/First/Feeblemind.cs | 2 + Projects/UOContent/Spells/First/MagicArrow.cs | 9 +- Projects/UOContent/Spells/Fourth/ArchCure.cs | 31 +++-- .../UOContent/Spells/Fourth/ArchProtection.cs | 6 +- Projects/UOContent/Spells/Fourth/Curse.cs | 12 +- .../UOContent/Spells/Second/RemoveTrap.cs | 2 +- .../Spells/Seventh/ChainLightning.cs | 129 ++++++++---------- .../UOContent/Spells/Seventh/EnergyField.cs | 6 +- .../UOContent/Spells/Seventh/MeteorSwarm.cs | 115 +++++++--------- Projects/UOContent/Spells/Sixth/Explosion.cs | 50 +++---- Projects/UOContent/Spells/Third/Poison.cs | 23 +--- 16 files changed, 311 insertions(+), 382 deletions(-) diff --git a/Projects/UOContent/Spells/Base/MagerySpell.cs b/Projects/UOContent/Spells/Base/MagerySpell.cs index c42d60954..68c261e8e 100644 --- a/Projects/UOContent/Spells/Base/MagerySpell.cs +++ b/Projects/UOContent/Spells/Base/MagerySpell.cs @@ -5,9 +5,10 @@ namespace Server.Spells { public abstract class MagerySpell : Spell { - private const double ChanceOffset = 20.0, ChanceLength = 100.0 / 7.0; - - private static readonly int[] m_ManaTable = { 4, 6, 9, 11, 14, 20, 40, 50 }; + private static readonly int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 }; + private static readonly double[] _requiredSkill = Core.ML ? + new[] { 0.0, -4.0, 10.0, 24.0, 38.0, 52.0, 66.0, 80.0 } : + new[] { 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0 }; public MagerySpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info) { @@ -29,13 +30,20 @@ namespace Server.Spells circle -= 2; } - var avg = ChanceLength * circle; + // Original RunUO algorithm for required skill + // const double chanceOffset = 20.0 + // const double chanceLength = 100.0 / 7.0 + // var avg = chanceLength * circle; + // min = avg - chanceOffset; + // max = avg + chanceOffset; - min = avg - ChanceOffset; - max = avg + ChanceOffset; + // Correct algorithm according to OSI. + // TODO: Verify this algorithm on OSI for latest expansion. + min = _requiredSkill[circle]; + max = min + 40; } - public override int GetMana() => Scroll is BaseWand ? 0 : m_ManaTable[(int)Circle]; + public override int GetMana() => Scroll is BaseWand ? 0 : _manaTable[(int)Circle]; public override double GetResistSkill(Mobile m) { @@ -79,12 +87,13 @@ namespace Server.Spells public virtual double GetResistPercentForCircle(Mobile target, SpellCircle circle) { - var firstPercent = target.Skills.MagicResist.Value / 5.0; - var secondPercent = target.Skills.MagicResist.Value - + var magicResist = target.Skills.MagicResist.Value; + var firstPercent = magicResist / 5.0; + var secondPercent = magicResist - ((Caster.Skills[CastSkill].Value - 20.0) / 5.0 + (1 + (int)circle) * 5.0); - return (firstPercent > secondPercent ? firstPercent : secondPercent) / - 2.0; // Seems should be about half of what stratics says. + // Seems should be about half of what stratics says. + return (firstPercent > secondPercent ? firstPercent : secondPercent) / 2.0; } public virtual double GetResistPercent(Mobile target) => GetResistPercentForCircle(target, Circle); diff --git a/Projects/UOContent/Spells/Base/SpecialMove.cs b/Projects/UOContent/Spells/Base/SpecialMove.cs index f42ea076b..d0b98ac79 100644 --- a/Projects/UOContent/Spells/Base/SpecialMove.cs +++ b/Projects/UOContent/Spells/Base/SpecialMove.cs @@ -10,8 +10,7 @@ namespace Server.Spells { public abstract class SpecialMove { - private static readonly Dictionary m_PlayersTable = - new(); + private static readonly Dictionary _playersTable = new(); public virtual int BaseMana => 0; @@ -159,40 +158,18 @@ namespace Server.Spells return false; } - string option = null; - - if (this is Backstab) + string option = this switch { - option = "Backstab"; - } - else if (this is DeathStrike) - { - option = "Death Strike"; - } - else if (this is FocusAttack) - { - option = "Focus Attack"; - } - else if (this is KiAttack) - { - option = "Ki Attack"; - } - else if (this is SurpriseAttack) - { - option = "Surprise Attack"; - } - else if (this is HonorableExecution) - { - option = "Honorable Execution"; - } - else if (this is LightningStrike) - { - option = "Lightning Strike"; - } - else if (this is MomentumStrike) - { - option = "Momentum Strike"; - } + Backstab => "Backstab", + DeathStrike => "Death Strike", + FocusAttack => "Focus Attack", + KiAttack => "Ki Attack", + SurpriseAttack => "Surprise Attack", + HonorableExecution => "Honorable Execution", + LightningStrike => "Lightning Strike", + MomentumStrike => "Momentum Strike", + _ => null + }; if (option != null && !DuelContext.AllowSpecialMove(from, option, this)) { @@ -303,7 +280,7 @@ namespace Server.Spells private static void AddContext(Mobile m, SpecialMoveContext context) { - m_PlayersTable[m] = context; + _playersTable[m] = context; } private static void RemoveContext(Mobile m) @@ -312,23 +289,20 @@ namespace Server.Spells if (context != null) { - m_PlayersTable.Remove(m); + _playersTable.Remove(m); context.Timer.Stop(); } } private static SpecialMoveContext GetContext(Mobile m) => - m_PlayersTable.TryGetValue(m, out var context) ? context : null; + _playersTable.TryGetValue(m, out var context) ? context : null; private class SpecialMoveTimer : Timer { private readonly Mobile m_Mobile; - public SpecialMoveTimer(Mobile from) : base(TimeSpan.FromSeconds(3.0)) - { - m_Mobile = from; - } + public SpecialMoveTimer(Mobile from) : base(TimeSpan.FromSeconds(3.0)) => m_Mobile = from; protected override void OnTick() { diff --git a/Projects/UOContent/Spells/Base/Spell.cs b/Projects/UOContent/Spells/Base/Spell.cs index 120d85be1..78eea7bdc 100644 --- a/Projects/UOContent/Spells/Base/Spell.cs +++ b/Projects/UOContent/Spells/Base/Spell.cs @@ -17,19 +17,16 @@ namespace Server.Spells public abstract class Spell : ISpell { private static readonly TimeSpan NextSpellDelay = TimeSpan.FromSeconds(0.75); - private static readonly TimeSpan AnimateDelay = TimeSpan.FromSeconds(1.5); // In reality, it's ANY delayed Damage spell Post-AoS that can't stack, but, only // Expo & Magic Arrow have enough delay and a short enough cast time to bring up // the possibility of stacking 'em. Note that a MA & an Explosion will stack, but // of course, two MA's won't. - private static readonly Dictionary m_ContextTable = - new(); + private static readonly Dictionary _contextTable = new(); - private AnimTimer m_AnimTimer; - - private CastTimer m_CastTimer; + private AnimTimer _animTimer; + private CastTimer _castTimer; public Spell(Mobile caster, Item scroll, SpellInfo info) { @@ -60,13 +57,17 @@ namespace Server.Spells public virtual bool DelayedDamage => false; - public virtual bool DelayedDamageStacking => true; + public static readonly Type[] AOSNoDelayedDamageStackingSelf = Core.AOS ? Array.Empty() : null; + + // Null means stacking is allowed while empty indicates no stacking with self + // More than zero means no stacking with self and other spells + public virtual Type[] DelayedDamageSpellFamilyStacking => null; public virtual bool BlockedByHorrificBeast => true; public virtual bool BlockedByAnimalForm => true; public virtual bool BlocksMovement => true; - public virtual bool CheckNextSpellTime => !(Scroll is BaseWand); + public virtual bool CheckNextSpellTime => Scroll is not BaseWand; public virtual int CastRecoveryBase => 6; public virtual int CastRecoveryFastScalar => 1; @@ -149,22 +150,39 @@ namespace Server.Spells public void StartDelayedDamageContext(Mobile m, Timer t) { - if (DelayedDamageStacking) + var damageStacking = DelayedDamageSpellFamilyStacking; + if (damageStacking == null) { return; // Sanity } - if (!m_ContextTable.TryGetValue(GetType(), out var contexts)) + var type = GetType(); + + if (!_contextTable.TryGetValue(type, out var context)) { - m_ContextTable[GetType()] = contexts = new DelayedDamageContextWrapper(); + _contextTable[type] = context = new DelayedDamageContextWrapper(); + + for (int i = 0; i < damageStacking.Length; i++) + { + _contextTable.Add(damageStacking[i], context); + } } - contexts.Add(m, t); + context.Add(m, t); } + public bool HasDelayedDamageContext(Mobile m) => + DelayedDamageSpellFamilyStacking != null && + _contextTable.TryGetValue(GetType(), out var context) && context.Contains(m); + public void RemoveDelayedDamageContext(Mobile m) { - if (m_ContextTable.TryGetValue(GetType(), out var contexts)) + if (m == null || DelayedDamageSpellFamilyStacking == null) + { + return; // Sanity + } + + if (_contextTable.TryGetValue(GetType(), out var contexts)) { contexts.Remove(m); } @@ -389,8 +407,8 @@ namespace Server.Spells { OnDisturb(type, true); - m_CastTimer?.Stop(); - m_AnimTimer?.Stop(); + _castTimer?.Stop(); + _animTimer?.Stop(); if (Core.AOS && Caster.Player && type == DisturbType.Hurt) { @@ -469,7 +487,7 @@ namespace Server.Spells { Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form. } - else if (!(Scroll is BaseWand) && (Caster.Paralyzed || Caster.Frozen)) + else if (Scroll is not BaseWand && (Caster.Paralyzed || Caster.Frozen)) { Caster.SendLocalizedMessage(502643); // You can not cast a spell while frozen. } @@ -492,7 +510,7 @@ namespace Server.Spells State = SpellState.Casting; Caster.Spell = this; - if (!(Scroll is BaseWand) && RevealOnCast) + if (Scroll is not BaseWand && RevealOnCast) { Caster.RevealingAction(); } @@ -507,8 +525,8 @@ namespace Server.Spells if (count != 0) { - m_AnimTimer = new AnimTimer(this, count); - m_AnimTimer.Start(); + _animTimer = new AnimTimer(this, count); + _animTimer.Start(); } if (Info.LeftHandEffect > 0) @@ -532,18 +550,18 @@ namespace Server.Spells WeaponAbility.ClearCurrentAbility(Caster); } - m_CastTimer = new CastTimer(this, castDelay); + _castTimer = new CastTimer(this, castDelay); // m_CastTimer.Start(); OnBeginCast(); if (castDelay > TimeSpan.Zero) { - m_CastTimer.Start(); + _castTimer.Start(); } else { - m_CastTimer.Tick(); + _castTimer.Tick(); } return true; @@ -647,11 +665,6 @@ namespace Server.Spells return TimeSpan.FromSeconds((double)delay / CastRecoveryPerSecond); } - // public virtual int CastDelayBase{ get{ return 3; } } - // public virtual int CastDelayFastScalar{ get{ return 1; } } - // public virtual int CastDelayPerSecond{ get{ return 4; } } - // public virtual int CastDelayMinimum{ get{ return 1; } } - public virtual TimeSpan GetCastDelay() { if (Scroll is BaseWand) @@ -665,7 +678,7 @@ namespace Server.Spells // Paladins with magery of 70.0 or above are subject to a faster casting cap of 2 var fcMax = 4; - if (CastSkill == SkillName.Magery || CastSkill == SkillName.Necromancy || + if (CastSkill is SkillName.Magery or SkillName.Necromancy || CastSkill == SkillName.Chivalry && Caster.Skills.Magery.Value >= 70.0) { fcMax = 2; @@ -749,12 +762,9 @@ namespace Server.Spells Scroll.Movable = m; } - else + else if (ClearHandsOnCast) { - if (ClearHandsOnCast) - { - Caster.ClearHands(); - } + Caster.ClearHands(); } var karma = ComputeKarmaAward(); @@ -838,10 +848,14 @@ namespace Server.Spells m_Contexts.Add(m, t); } + public bool Contains(Mobile m) => m_Contexts.ContainsKey(m); + public void Remove(Mobile m) { - m_Contexts.Remove(m); - // TODO: Should we stop the timer? + if (m_Contexts.Remove(m, out var t)) + { + t.Stop(); + } } } @@ -876,7 +890,7 @@ namespace Server.Spells if (!Running) { - m_Spell.m_AnimTimer = null; + m_Spell._animTimer = null; } } } @@ -900,7 +914,7 @@ namespace Server.Spells if (m_Spell.State == SpellState.Casting && m_Spell.Caster.Spell == m_Spell) { m_Spell.State = SpellState.Sequencing; - m_Spell.m_CastTimer = null; + m_Spell._castTimer = null; m_Spell.Caster.OnSpellCast(m_Spell); m_Spell.Caster.Region?.OnSpellCast(m_Spell.Caster, m_Spell); m_Spell.Caster.NextSpellTime = @@ -915,7 +929,7 @@ namespace Server.Spells m_Spell.Caster.Target?.BeginTimeout(m_Spell.Caster, 30000); // 30 seconds } - m_Spell.m_CastTimer = null; + m_Spell._castTimer = null; } } diff --git a/Projects/UOContent/Spells/Base/SpellHelper.cs b/Projects/UOContent/Spells/Base/SpellHelper.cs index f855ad5ac..383228b49 100644 --- a/Projects/UOContent/Spells/Base/SpellHelper.cs +++ b/Projects/UOContent/Spells/Base/SpellHelper.cs @@ -184,7 +184,7 @@ namespace Server.Spells public static void Turn(Mobile from, object to) { - if (!(to is IPoint3D target)) + if (to is not IPoint3D target) { return; } @@ -333,7 +333,7 @@ namespace Server.Spells public static bool AddStatCurse(Mobile caster, Mobile target, StatType type, int curse, TimeSpan duration) { var offset = -curse; - var name = $"[Magic] {type} Offset"; + var name = $"[Magic] {type} Curse"; var mod = target.GetStatMod(name); @@ -447,26 +447,8 @@ namespace Server.Spells var bcFrom = from as BaseCreature; var bcTarg = to as BaseCreature; - PlayerMobile pmFrom; - PlayerMobile pmTarg; - - if (bcFrom?.Summoned == true) - { - pmFrom = bcFrom.SummonMaster as PlayerMobile; - } - else - { - pmFrom = from as PlayerMobile; - } - - if (bcTarg?.Summoned == true) - { - pmTarg = bcTarg.SummonMaster as PlayerMobile; - } - else - { - pmTarg = to as PlayerMobile; - } + var pmFrom = (bcFrom?.Summoned == true ? bcFrom.SummonMaster : from) as PlayerMobile; + var pmTarg = (bcTarg?.Summoned == true ? bcTarg.SummonMaster : to) as PlayerMobile; if (pmFrom?.DuelContext != null && pmFrom.DuelContext == pmTarg?.DuelContext && pmFrom.DuelContext.Started && pmFrom.DuelPlayer != null && pmTarg?.DuelPlayer != null) @@ -864,17 +846,6 @@ namespace Server.Spells return x < 0 || y < 0 || x >= map.Width || y >= map.Height; } - // towns - public static bool IsTown(IPoint3D ip, Mobile caster) - { - if (ip is Item item) - { - ip = item.GetWorldLocation(); - } - - return IsTown(new Point3D(ip), caster); - } - public static bool IsTown(Point3D loc, Mobile caster) { var map = caster.Map; @@ -897,15 +868,8 @@ namespace Server.Spells return reg?.IsDisabled() == false; } - public static bool CheckTown(IPoint3D ip, Mobile caster) - { - if (ip is Item item) - { - ip = item.GetWorldLocation(); - } - - return CheckTown(new Point3D(ip), caster); - } + public static bool CheckTown(IPoint3D ip, Mobile caster) => + CheckTown((ip as Item)?.GetWorldLocation() ?? new Point3D(ip), caster); public static bool CheckTown(Point3D loc, Mobile caster) { @@ -919,13 +883,13 @@ namespace Server.Spells } // magic reflection - public static void CheckReflect(int circle, Mobile caster, ref Mobile target) - { + public static bool CheckReflect(int circle, Mobile caster, ref Mobile target) => CheckReflect(circle, ref caster, ref target); - } - public static void CheckReflect(int circle, ref Mobile caster, ref Mobile target) + public static bool CheckReflect(int circle, ref Mobile caster, ref Mobile target) { + var reflect = false; + if (target.MagicDamageAbsorb > 0) { ++circle; @@ -933,41 +897,26 @@ namespace Server.Spells target.MagicDamageAbsorb -= circle; // This order isn't very intuitive, but you have to nullify reflect before target gets switched - - var reflect = target.MagicDamageAbsorb >= 0; - - (target as BaseCreature)?.CheckReflect(caster, ref reflect); - + reflect = target.MagicDamageAbsorb >= 0; if (target.MagicDamageAbsorb <= 0) { target.MagicDamageAbsorb = 0; DefensiveSpell.Nullify(target); } - - if (reflect) - { - target.FixedEffect(0x37B9, 10, 5); - - var temp = caster; - caster = target; - target = temp; - } } - else if (target is BaseCreature creature) + + if (target is BaseCreature creature) { - var reflect = false; - creature.CheckReflect(caster, ref reflect); - - if (reflect) - { - creature.FixedEffect(0x37B9, 10, 5); - - var temp = caster; - caster = creature; - target = temp; - } } + + if (reflect) + { + target.FixedEffect(0x37B9, 10, 5); + (caster, target) = (target, caster); + } + + return reflect; } public static void Damage(Spell spell, Mobile target, double damage) @@ -995,20 +944,21 @@ namespace Server.Spells { (from as BaseCreature)?.AlterSpellDamageTo(target, ref iDamage); - (target as BaseCreature)?.AlterSpellDamageFrom(from, ref iDamage); + var bcTarget = target as BaseCreature; + bcTarget?.AlterSpellDamageFrom(from, ref iDamage); target.Damage(iDamage, from); + + if (from != null) + { + bcTarget?.OnHarmfulSpell(from); + bcTarget?.OnDamagedBySpell(from); + } } else { new SpellDamageTimer(spell, target, from, iDamage, delay).Start(); } - - if (target is BaseCreature c && from != null && delay == TimeSpan.Zero) - { - c.OnHarmfulSpell(from); - c.OnDamagedBySpell(from); - } } public static void Damage( @@ -1086,6 +1036,11 @@ namespace Server.Spells public static void DoLeech(int damageGiven, Mobile from, Mobile target) { + if (target == null) + { + return; + } + var context = TransformationSpellHelper.GetContext(from); if (context == null) /* cleanup */ @@ -1134,7 +1089,7 @@ namespace Server.Spells m_Damage = damage; m_Spell = s; - if (m_Spell?.DelayedDamage == true && !m_Spell.DelayedDamageStacking) + if (m_Spell?.DelayedDamage == true) { m_Spell.StartDelayedDamageContext(target, this); } @@ -1143,7 +1098,6 @@ namespace Server.Spells protected override void OnTick() { (m_From as BaseCreature)?.AlterSpellDamageTo(m_Target, ref m_Damage); - (m_Target as BaseCreature)?.AlterSpellDamageFrom(m_From, ref m_Damage); m_Target.Damage(m_Damage); @@ -1181,7 +1135,8 @@ namespace Server.Spells m_Chaos = chaos; m_DFA = dfa; m_Spell = s; - if (m_Spell?.DelayedDamage == true && !m_Spell.DelayedDamageStacking) + + if (m_Spell?.DelayedDamage == true) { m_Spell.StartDelayedDamageContext(target, this); } @@ -1189,10 +1144,9 @@ namespace Server.Spells protected override void OnTick() { - var bcFrom = m_From as BaseCreature; var bcTarg = m_Target as BaseCreature; - if (bcFrom != null && m_Target != null) + if (m_From is BaseCreature bcFrom && m_Target != null) { bcFrom.AlterSpellDamageTo(m_Target, ref m_Damage); } @@ -1253,7 +1207,7 @@ namespace Server.Spells public static bool OnCast(Mobile caster, Spell spell) { - if (!(spell is ITransformationSpell transformSpell)) + if (spell is not ITransformationSpell transformSpell) { return false; } diff --git a/Projects/UOContent/Spells/Eighth/Resurrection.cs b/Projects/UOContent/Spells/Eighth/Resurrection.cs index c485850fa..2bda277a0 100644 --- a/Projects/UOContent/Spells/Eighth/Resurrection.cs +++ b/Projects/UOContent/Spells/Eighth/Resurrection.cs @@ -51,9 +51,8 @@ namespace Server.Spells.Eighth } else if (m.Region?.IsPartOf("Khaldun") == true) { - Caster.SendLocalizedMessage( - 1010395 - ); // The veil of death in this area is too strong and resists thy efforts to restore life. + // The veil of death in this area is too strong and resists thy efforts to restore life. + Caster.SendLocalizedMessage(1010395); } else if (CheckBSequence(m, true)) { diff --git a/Projects/UOContent/Spells/First/Feeblemind.cs b/Projects/UOContent/Spells/First/Feeblemind.cs index ac339bca6..674c71b3e 100644 --- a/Projects/UOContent/Spells/First/Feeblemind.cs +++ b/Projects/UOContent/Spells/First/Feeblemind.cs @@ -27,6 +27,8 @@ namespace Server.Spells.First SpellHelper.CheckReflect((int)Circle, Caster, ref m); + // TODO: StoneForm immunity + SpellHelper.AddStatCurse(Caster, m, StatType.Int); m.Spell?.OnCasterHurt(); diff --git a/Projects/UOContent/Spells/First/MagicArrow.cs b/Projects/UOContent/Spells/First/MagicArrow.cs index 02f4de6e7..1461e3548 100644 --- a/Projects/UOContent/Spells/First/MagicArrow.cs +++ b/Projects/UOContent/Spells/First/MagicArrow.cs @@ -1,3 +1,4 @@ +using System; using Server.Targeting; namespace Server.Spells.First @@ -18,7 +19,7 @@ namespace Server.Spells.First public override SpellCircle Circle => SpellCircle.First; - public override bool DelayedDamageStacking => !Core.AOS; + public override Type[] DelayedDamageSpellFamilyStacking => AOSNoDelayedDamageStackingSelf; public override bool DelayedDamage => true; @@ -30,6 +31,12 @@ namespace Server.Spells.First SpellHelper.Turn(source, m); + if (Core.SA && HasDelayedDamageContext(m)) + { + DoHurtFizzle(); + return; + } + SpellHelper.CheckReflect((int)Circle, ref source, ref m); double damage; diff --git a/Projects/UOContent/Spells/Fourth/ArchCure.cs b/Projects/UOContent/Spells/Fourth/ArchCure.cs index 3d7158499..9cacd8790 100644 --- a/Projects/UOContent/Spells/Fourth/ArchCure.cs +++ b/Projects/UOContent/Spells/Fourth/ArchCure.cs @@ -1,6 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; +using Server.Collections; using Server.Mobiles; namespace Server.Spells.Fourth @@ -34,37 +33,39 @@ namespace Server.Spells.Fourth SpellHelper.GetSurfaceTop(ref p); - var targets = new List(); - var map = Caster.Map; - var directTarget = p as Mobile; - var loc = new Point3D(p); - if (map != null) { + using var pool = PooledRefQueue.Create(); + var directTarget = p as Mobile; + var loc = new Point3D(p); + var feluccaRules = map.Rules == MapRules.FeluccaRules; // You can target any living mobile directly, beneficial checks apply if (directTarget != null && Caster.CanBeBeneficial(directTarget, false)) { - targets.Add(directTarget); + pool.Enqueue(directTarget); } var eable = map.GetMobilesInRange(loc, 2); - targets.AddRange(eable.Where(m => m != directTarget).Where(m => AreaCanTarget(m, feluccaRules))); + foreach (var m in eable) + { + if (m != directTarget && AreaCanTarget(m, feluccaRules)) + { + pool.Enqueue(m); + } + } eable.Free(); - } - Effects.PlaySound(loc, Caster.Map, 0x299); + Effects.PlaySound(loc, Caster.Map, 0x299); - if (targets.Count > 0) - { var cured = 0; - for (var i = 0; i < targets.Count; ++i) + while (pool.Count > 0) { - var m = targets[i]; + var m = pool.Dequeue(); Caster.DoBeneficial(m); diff --git a/Projects/UOContent/Spells/Fourth/ArchProtection.cs b/Projects/UOContent/Spells/Fourth/ArchProtection.cs index d924d4c82..dfb258ec9 100644 --- a/Projects/UOContent/Spells/Fourth/ArchProtection.cs +++ b/Projects/UOContent/Spells/Fourth/ArchProtection.cs @@ -19,7 +19,7 @@ namespace Server.Spells.Fourth Reagent.SulfurousAsh ); - private static readonly Dictionary _Table = new(); + private static readonly Dictionary _table = new(); public ArchProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info) { @@ -107,12 +107,12 @@ namespace Server.Spells.Fourth private static void AddEntry(Mobile m, int v) { - _Table[m] = v; + _table[m] = v; } public static void RemoveEntry(Mobile m) { - if (_Table.Remove(m, out var v)) + if (_table.Remove(m, out var v)) { m.EndAction(); m.VirtualArmorMod -= Math.Min(v, m.VirtualArmorMod); diff --git a/Projects/UOContent/Spells/Fourth/Curse.cs b/Projects/UOContent/Spells/Fourth/Curse.cs index 84a076e3d..2eb06c82d 100644 --- a/Projects/UOContent/Spells/Fourth/Curse.cs +++ b/Projects/UOContent/Spells/Fourth/Curse.cs @@ -15,7 +15,7 @@ namespace Server.Spells.Fourth Reagent.SulfurousAsh ); - private static readonly HashSet m_UnderEffect = new(); + private static readonly HashSet _underEffect = new(); public CurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, _info) { @@ -41,7 +41,7 @@ namespace Server.Spells.Fourth if (Caster.Player && m.Player /*&& Caster != m */ && !UnderEffect(m)) { var duration = SpellHelper.GetDuration(Caster, m); - m_UnderEffect.Add(m); + _underEffect.Add(m); Timer.StartTimer(duration, () => RemoveEffect(m)); m.UpdateResistances(); } @@ -71,13 +71,13 @@ namespace Server.Spells.Fourth Caster.Target = new SpellTargetMobile(this, TargetFlags.Harmful, Core.ML ? 10 : 12); } - public static void RemoveEffect(Mobile m) + public static bool RemoveEffect(Mobile m) { - m_UnderEffect.Remove(m); - + var effectRemoved = _underEffect.Remove(m); m.UpdateResistances(); + return effectRemoved; } - public static bool UnderEffect(Mobile m) => m_UnderEffect.Contains(m); + public static bool UnderEffect(Mobile m) => _underEffect.Contains(m); } } diff --git a/Projects/UOContent/Spells/Second/RemoveTrap.cs b/Projects/UOContent/Spells/Second/RemoveTrap.cs index cb800ddf2..085aa319f 100644 --- a/Projects/UOContent/Spells/Second/RemoveTrap.cs +++ b/Projects/UOContent/Spells/Second/RemoveTrap.cs @@ -55,7 +55,7 @@ namespace Server.Spells.Second public override void OnCast() { Caster.Target = new SpellTargetItem(this, range: Core.ML ? 10 : 12); - Caster.SendMessage("What do you wish to untrap?"); // TODO: Localization? + Caster.SendLocalizedMessage(502368); } } } diff --git a/Projects/UOContent/Spells/Seventh/ChainLightning.cs b/Projects/UOContent/Spells/Seventh/ChainLightning.cs index 6f3ec9923..d9edf0567 100644 --- a/Projects/UOContent/Spells/Seventh/ChainLightning.cs +++ b/Projects/UOContent/Spells/Seventh/ChainLightning.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Linq; +using Server.Collections; namespace Server.Spells.Seventh { @@ -27,89 +26,77 @@ namespace Server.Spells.Seventh public void Target(IPoint3D p) { - if (SpellHelper.CheckTown(p, Caster) && CheckSequence()) + var loc = (p as Item)?.GetWorldLocation() ?? new Point3D(p); + if (SpellHelper.CheckTown(loc, Caster) && CheckSequence()) { SpellHelper.Turn(Caster, p); - if (p is Item item) - { - p = item.GetWorldLocation(); - } - - var targets = new List(); - var map = Caster.Map; - var playerVsPlayer = false; - if (map != null) { - var eable = map.GetMobilesInRange(new Point3D(p), 2); + using var pool = PooledRefQueue.Create(); + var pvp = false; - targets.AddRange( - eable.Where( - m => - { - if (Core.AOS && (m == Caster || !Caster.InLOS(m)) || - !SpellHelper.ValidIndirectTarget(Caster, m) || - !Caster.CanBeHarmful(m, false)) - { - return false; - } - - if (m.Player) - { - playerVsPlayer = true; - } - - return true; - } - ) - .ToList() - ); - - eable.Free(); - } - - double damage; - - damage = Core.AOS - ? GetNewAosDamage(51, 1, 5, playerVsPlayer) - : Utility.Random(27, 22); - - if (targets.Count > 0) - { - if (Core.AOS && targets.Count > 2) + var eable = map.GetMobilesInRange(loc, 2); + foreach (var m in eable) { - damage = damage * 2 / targets.Count; - } - else if (!Core.AOS) - { - damage /= targets.Count; - } - - for (var i = 0; i < targets.Count; ++i) - { - var toDeal = damage; - var m = targets[i]; - - if (!Core.AOS && CheckResisted(m)) + if (Core.AOS && (m == Caster || !Caster.InLOS(m)) || + !SpellHelper.ValidIndirectTarget(Caster, m) || + !Caster.CanBeHarmful(m, false)) { - toDeal *= 0.5; - - m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. + continue; } - toDeal *= GetDamageScalar(m); - Caster.DoHarmful(m); - SpellHelper.Damage(this, m, toDeal, 0, 0, 0, 0, 100); + if (m.Player) + { + pvp = true; + } - m.BoltEffect(0); + pool.Enqueue(m); + } + + eable.Free(); + + if (pool.Count > 0) + { + double damage = Core.AOS + ? GetNewAosDamage(51, 1, 5, pvp) + : Utility.Random(27, 22); + + if (pool.Count > 2) + { + if (Core.AOS) + { + damage *= 2; + } + + damage /= pool.Count; + } + + while (pool.Count > 0) + { + var toDeal = damage; + var m = pool.Dequeue(); + + if (!Core.AOS && CheckResisted(m)) + { + toDeal *= 0.5; + + m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. + } + + toDeal *= GetDamageScalar(m); + Caster.DoHarmful(m); + SpellHelper.Damage(this, m, toDeal, 0, 0, 0, 0, 100); + + m.BoltEffect(0); + } + } + else + { + Caster.PlaySound(0x29); } - } - else - { - Caster.PlaySound(0x29); } } diff --git a/Projects/UOContent/Spells/Seventh/EnergyField.cs b/Projects/UOContent/Spells/Seventh/EnergyField.cs index d802cd5e8..abb0895ef 100644 --- a/Projects/UOContent/Spells/Seventh/EnergyField.cs +++ b/Projects/UOContent/Spells/Seventh/EnergyField.cs @@ -45,10 +45,8 @@ namespace Server.Spells.Seventh } else { - duration = TimeSpan.FromSeconds( - Caster.Skills.Magery.Value * 0.28 + - 2.0 - ); // (28% of magery) + 2.0 seconds + // (28% of magery) + 2.0 seconds + duration = TimeSpan.FromSeconds(Caster.Skills.Magery.Value * 0.28 + 2.0); } var itemID = eastToWest ? 0x3946 : 0x3956; diff --git a/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs b/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs index 19899f7b0..f8f934a18 100644 --- a/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs +++ b/Projects/UOContent/Spells/Seventh/MeteorSwarm.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using System.Linq; +using Server.Collections; namespace Server.Spells.Seventh { @@ -36,8 +35,6 @@ namespace Server.Spells.Seventh p = item.GetWorldLocation(); } - List targets; - var map = Caster.Map; var playerVsPlayer = false; @@ -46,69 +43,63 @@ namespace Server.Spells.Seventh if (map != null) { var eable = map.GetMobilesInRange(loc, 2); - - targets = eable.Where( - m => - { - if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || - !Caster.CanBeHarmful(m, false) || - Core.AOS && !Caster.InLOS(m)) - { - return false; - } - - if (m.Player) - { - playerVsPlayer = true; - } - - return true; - } - ) - .ToList(); - - eable.Free(); - } - else - { - targets = new List(); - } - - double damage = Core.AOS - ? GetNewAosDamage(51, 1, 5, playerVsPlayer) - : Utility.Random(27, 22); - - if (targets.Count > 0) - { - Effects.PlaySound(loc, Caster.Map, 0x160); - - if (Core.AOS && targets.Count > 2) + using var queue = PooledRefQueue.Create(); + foreach (var m in eable) { - damage = damage * 2 / targets.Count; - } - else if (!Core.AOS) - { - damage /= targets.Count; - } - - for (var i = 0; i < targets.Count; ++i) - { - var m = targets[i]; - - var toDeal = damage; - - if (!Core.AOS && CheckResisted(m)) + if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || + !Caster.CanBeHarmful(m, false) || Core.AOS && !Caster.InLOS(m)) { - damage *= 0.5; - - m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. + continue; } - toDeal *= GetDamageScalar(m); - Caster.DoHarmful(m); - SpellHelper.Damage(this, m, toDeal, 0, 100, 0, 0, 0); + if (m.Player) + { + playerVsPlayer = true; + } - Caster.MovingParticles(m, 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100); + queue.Enqueue(m); + } + + eable.Free(); + + double damage = Core.AOS + ? GetNewAosDamage(51, 1, 5, playerVsPlayer) + : Utility.Random(27, 22); + + int count = queue.Count; + + if (count > 0) + { + Effects.PlaySound(loc, Caster.Map, 0x160); + + if (Core.AOS && count > 2) + { + damage = damage * 2 / count; + } + else if (!Core.AOS) + { + damage /= count; + } + + while (queue.Count > 0) + { + var m = queue.Dequeue(); + + var toDeal = damage; + + if (!Core.AOS && CheckResisted(m)) + { + damage *= 0.5; + + m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. + } + + toDeal *= GetDamageScalar(m); + Caster.DoHarmful(m); + SpellHelper.Damage(this, m, toDeal, 0, 100, 0, 0, 0); + + Caster.MovingParticles(m, 0x36D4, 7, 0, false, true, 9501, 1, 0, 0x100); + } } } } diff --git a/Projects/UOContent/Spells/Sixth/Explosion.cs b/Projects/UOContent/Spells/Sixth/Explosion.cs index 16b0f69b3..7b21fd54e 100644 --- a/Projects/UOContent/Spells/Sixth/Explosion.cs +++ b/Projects/UOContent/Spells/Sixth/Explosion.cs @@ -20,22 +20,26 @@ namespace Server.Spells.Sixth public override SpellCircle Circle => SpellCircle.Sixth; - public override bool DelayedDamageStacking => !Core.AOS; + public override Type[] DelayedDamageSpellFamilyStacking => AOSNoDelayedDamageStackingSelf; public override bool DelayedDamage => false; public void Target(Mobile m) { + if (Core.SA && HasDelayedDamageContext(m)) + { + DoHurtFizzle(); + return; + } + if (Caster.CanBeHarmful(m) && CheckSequence()) { - Mobile attacker = Caster, defender = m; + Mobile defender = m; SpellHelper.Turn(Caster, m); - SpellHelper.CheckReflect((int)Circle, Caster, ref m); - var t = new InternalTimer(this, attacker, defender, m); - t.Start(); + var t = new InternalTimer(this, Caster, defender, m).Start(); } FinishSequence(); @@ -48,52 +52,52 @@ namespace Server.Spells.Sixth private class InternalTimer : Timer { - private readonly Mobile m_Attacker; - private readonly Mobile m_Defender; - private readonly MagerySpell m_Spell; - private readonly Mobile m_Target; + private readonly Mobile _attacker; + private readonly Mobile _defender; + private readonly MagerySpell _spell; + private readonly Mobile _target; public InternalTimer(MagerySpell spell, Mobile attacker, Mobile defender, Mobile target) : base(TimeSpan.FromSeconds(Core.AOS ? 3.0 : 2.5)) { - m_Spell = spell; - m_Attacker = attacker; - m_Defender = defender; - m_Target = target; + _spell = spell; + _attacker = attacker; + _defender = defender; + _target = target; - m_Spell?.StartDelayedDamageContext(attacker, this); + _spell?.StartDelayedDamageContext(_attacker, this); } protected override void OnTick() { - if (m_Attacker.HarmfulCheck(m_Defender)) + if (_attacker.HarmfulCheck(_defender)) { double damage; if (Core.AOS) { - damage = m_Spell.GetNewAosDamage(40, 1, 5, m_Defender); + damage = _spell.GetNewAosDamage(40, 1, 5, _defender); } else { damage = Utility.Random(23, 22); - if (m_Spell.CheckResisted(m_Target)) + if (_spell.CheckResisted(_target)) { damage *= 0.75; - m_Target.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. + _target.SendLocalizedMessage(501783); // You feel yourself resisting magical energy. } - damage *= m_Spell.GetDamageScalar(m_Target); + damage *= _spell.GetDamageScalar(_target); } - m_Target.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Head); - m_Target.PlaySound(0x307); + _target.FixedParticles(0x36BD, 20, 10, 5044, EffectLayer.Head); + _target.PlaySound(0x307); - SpellHelper.Damage(m_Spell, m_Target, damage, 0, 100, 0, 0, 0); + SpellHelper.Damage(_spell, _target, damage, 0, 100, 0, 0, 0); - m_Spell?.RemoveDelayedDamageContext(m_Attacker); + _spell?.RemoveDelayedDamageContext(_attacker); } } } diff --git a/Projects/UOContent/Spells/Third/Poison.cs b/Projects/UOContent/Spells/Third/Poison.cs index 584d3a20e..67d0e3b01 100644 --- a/Projects/UOContent/Spells/Third/Poison.cs +++ b/Projects/UOContent/Spells/Third/Poison.cs @@ -43,24 +43,13 @@ namespace Server.Spells.Third { if (Caster.InRange(m, 2)) { - var total = (Caster.Skills.Magery.Fixed + Caster.Skills.Poisoning.Fixed) / 2; - - if (total >= 1000) + level = (Caster.Skills.Magery.Fixed + Caster.Skills.Poisoning.Fixed) / 2 switch { - level = 3; - } - else if (total > 850) - { - level = 2; - } - else if (total > 650) - { - level = 1; - } - else - { - level = 0; - } + >= 1000 => 3, + > 850 => 2, + > 650 => 1, + _ => 0 + }; } else { From 32589478979d51f5dd49643c24ffd4c473e08052 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 5 Dec 2021 21:23:08 -0800 Subject: [PATCH 05/14] fix: Fixes codege of hashsets (#879) --- .../SerializableMigration/Rules/HashSetMigrationRule.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Projects/SerializationGenerator/SerializableMigration/Rules/HashSetMigrationRule.cs b/Projects/SerializationGenerator/SerializableMigration/Rules/HashSetMigrationRule.cs index 46e425a3d..d670ae01f 100644 --- a/Projects/SerializationGenerator/SerializableMigration/Rules/HashSetMigrationRule.cs +++ b/Projects/SerializationGenerator/SerializableMigration/Rules/HashSetMigrationRule.cs @@ -67,7 +67,11 @@ namespace SerializableMigration ruleArguments[0] = extraOptions; ruleArguments[1] = setTypeSymbol.ToDisplayString(); ruleArguments[2] = serializableSetType.Rule; - Array.Copy(serializableSetType.RuleArguments, 0, ruleArguments, 3, length); + + if (length > 0) + { + Array.Copy(serializableSetType.RuleArguments, 0, ruleArguments, 3, length); + } return true; } @@ -98,7 +102,7 @@ namespace SerializableMigration source.AppendLine($"{indent}{ruleArguments[argumentsOffset]} {propertyEntry};"); source.AppendLine($"{indent}var {propertyCount} = reader.ReadEncodedInt();"); source.AppendLine($"{indent}{property.Name} = new System.Collections.Generic.HashSet<{ruleArguments[argumentsOffset]}>({propertyCount});"); - source.AppendLine($"{indent}for (var {propertyIndex} = 0; i < {propertyCount}; {propertyIndex}++)"); + source.AppendLine($"{indent}for (var {propertyIndex} = 0; {propertyIndex} < {propertyCount}; {propertyIndex}++)"); source.AppendLine($"{indent}{{"); var serializableSetElement = new SerializableProperty From ef5aee87f38d11f56f335df8ff28da66f66a621a Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 5 Dec 2021 22:55:24 -0800 Subject: [PATCH 06/14] fix: Adds back generic timer delay call (#880) --- Projects/Server/Timer/Timer.DelayStateCall.cs | 242 ++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 Projects/Server/Timer/Timer.DelayStateCall.cs diff --git a/Projects/Server/Timer/Timer.DelayStateCall.cs b/Projects/Server/Timer/Timer.DelayStateCall.cs new file mode 100644 index 000000000..5c7712e55 --- /dev/null +++ b/Projects/Server/Timer/Timer.DelayStateCall.cs @@ -0,0 +1,242 @@ +/************************************************************************* + * ModernUO * + * Copyright 2019-2021 - ModernUO Development Team * + * Email: hi@modernuo.com * + * File: Timer.DelayStateCall.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; +using System.Runtime.CompilerServices; + +namespace Server +{ + public partial class Timer + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(Action callback, T state) => + DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(TimeSpan delay, Action callback, T state) => + DelayCall(delay, TimeSpan.Zero, 1, callback, state); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(TimeSpan delay, TimeSpan interval, Action callback, T state) => + DelayCall(delay, interval, 0, callback, state); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, Action callback, T state) => + new DelayStateCallTimer(delay, interval, count, callback, state).Start(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(Action callback, T1 t1, T2 t2) => + DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(TimeSpan delay, Action callback, T1 t1, T2 t2) => + DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(TimeSpan delay, TimeSpan interval, Action callback, T1 t1, T2 t2) => + DelayCall(delay, interval, 0, callback, t1, t2); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, TimeSpan interval, int count, Action callback, + T1 t1, T2 t2 + ) => new DelayStateCallTimer(delay, interval, count, callback, t1, t2).Start(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall(Action callback, T1 t1, T2 t2, T3 t3) => + DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, Action callback, T1 t1, T2 t2, T3 t3 + ) => DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, TimeSpan interval, Action callback, + T1 t1, T2 t2, T3 t3 + ) => DelayCall(delay, interval, 0, callback, t1, t2, t3); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, TimeSpan interval, int count, + Action callback, T1 t1, T2 t2, T3 t3 + ) => new DelayStateCallTimer(delay, interval, count, callback, t1, t2, t3).Start(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + Action callback, T1 t1, T2 t2, T3 t3, T4 t4 + ) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3, t4); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, Action callback, + T1 t1, T2 t2, T3 t3, T4 t4 + ) => DelayCall(delay, TimeSpan.Zero, 1, callback, t1, t2, t3, t4); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, TimeSpan interval, + Action callback, T1 t1, T2 t2, T3 t3, T4 t4 + ) => DelayCall(delay, interval, 0, callback, t1, t2, t3, t4); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, TimeSpan interval, int count, + Action callback, T1 t1, T2 t2, T3 t3, T4 t4 + ) => new DelayStateCallTimer(delay, interval, count, callback, t1, t2, t3, t4).Start(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + Action callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 + ) => new DelayStateCallTimer(TimeSpan.Zero, TimeSpan.Zero, 1, callback, t1, t2, t3, t4, t5).Start(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, + Action callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 + ) => new DelayStateCallTimer(delay, TimeSpan.Zero, 1, callback, t1, t2, t3, t4, t5).Start(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, TimeSpan interval, + Action callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 + ) => new DelayStateCallTimer(delay, interval, 0, callback, t1, t2, t3, t4, t5).Start(); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Timer DelayCall( + TimeSpan delay, TimeSpan interval, int count, + Action callback, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 + ) => new DelayStateCallTimer(delay, interval, count, callback, t1, t2, t3, t4, t5).Start(); + + private class DelayStateCallTimer : Timer + { + private readonly T _t1; + + public DelayStateCallTimer(TimeSpan delay, TimeSpan interval, int count, Action callback, T state) + : base(delay, interval, count) + { + Callback = callback; + _t1 = state; + } + + public Action Callback { get; } + + protected override void OnTick() => Callback?.Invoke(_t1); + + public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]"; + } + + private class DelayStateCallTimer : Timer + { + private readonly T1 _t1; + private readonly T2 _t2; + + public DelayStateCallTimer( + TimeSpan delay, TimeSpan interval, int count, Action callback, + T1 t1, T2 t2 + ) : base(delay, interval, count) + { + Callback = callback; + _t1 = t1; + _t2 = t2; + } + + public Action Callback { get; } + + protected override void OnTick() => Callback?.Invoke(_t1, _t2); + + public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]"; + } + + private class DelayStateCallTimer : Timer + { + private readonly T1 _t1; + private readonly T2 _t2; + private readonly T3 _t3; + + public DelayStateCallTimer( + TimeSpan delay, TimeSpan interval, int count, Action callback, + T1 t1, T2 t2, T3 t3 + ) : base(delay, interval, count) + { + Callback = callback; + _t1 = t1; + _t2 = t2; + _t3 = t3; + } + + public Action Callback { get; } + + protected override void OnTick() => Callback?.Invoke(_t1, _t2, _t3); + + public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]"; + } + + private class DelayStateCallTimer : Timer + { + private readonly T1 _t1; + private readonly T2 _t2; + private readonly T3 _t3; + private readonly T4 _t4; + + public DelayStateCallTimer( + TimeSpan delay, TimeSpan interval, int count, Action callback, + T1 t1, T2 t2, T3 t3, T4 t4 + ) : base(delay, interval, count) + { + Callback = callback; + _t1 = t1; + _t2 = t2; + _t3 = t3; + _t4 = t4; + } + + public Action Callback { get; } + + protected override void OnTick() => Callback?.Invoke(_t1, _t2, _t3, _t4); + + public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]"; + } + + private class DelayStateCallTimer : Timer + { + private readonly T1 _t1; + private readonly T2 _t2; + private readonly T3 _t3; + private readonly T4 _t4; + private readonly T5 _t5; + + public DelayStateCallTimer( + TimeSpan delay, TimeSpan interval, int count, Action callback, + T1 t1, T2 t2, T3 t3, T4 t4, T5 t5 + ) : base(delay, interval, count) + { + Callback = callback; + _t1 = t1; + _t2 = t2; + _t3 = t3; + _t4 = t4; + _t5 = t5; + } + + public Action Callback { get; } + + protected override void OnTick() => Callback?.Invoke(_t1, _t2, _t3, _t4, _t5); + + public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]"; + } + } +} From 16f65e59c6efb2cf5f7f8f2ddbf72f93a54650e8 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Tue, 7 Dec 2021 10:20:30 -0800 Subject: [PATCH 07/14] fix: Fixes VS builds by reverting back to nstd20 (#882) --- .../SerializationGenerator.csproj | 10 ++++++---- Projects/Server/Server.csproj | 2 +- Projects/UOContent/UOContent.csproj | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Projects/SerializationGenerator/SerializationGenerator.csproj b/Projects/SerializationGenerator/SerializationGenerator.csproj index 1daae2ff1..10448f42f 100755 --- a/Projects/SerializationGenerator/SerializationGenerator.csproj +++ b/Projects/SerializationGenerator/SerializationGenerator.csproj @@ -1,6 +1,6 @@ - netstandard2.1 + netstandard2.0 preview analyzers @@ -12,6 +12,7 @@ + @@ -21,9 +22,10 @@ - - - + + + + diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj index 4efc9e1a9..392fccc6f 100755 --- a/Projects/Server/Server.csproj +++ b/Projects/Server/Server.csproj @@ -40,7 +40,7 @@ - TargetFramework=netstandard2.1 + TargetFramework=netstandard2.0 Analyzer false all diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj index c5561de3d..06e297a52 100755 --- a/Projects/UOContent/UOContent.csproj +++ b/Projects/UOContent/UOContent.csproj @@ -47,7 +47,7 @@ - TargetFramework=netstandard2.1 + TargetFramework=netstandard2.0 Analyzer false all From aba34730308a0eb957601ddd300e96f0aaf115a5 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Thu, 9 Dec 2021 11:57:55 -0800 Subject: [PATCH 08/14] fix: Fixes divide by zero in poison spell (#883) --- Projects/UOContent/Spells/Third/Poison.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/UOContent/Spells/Third/Poison.cs b/Projects/UOContent/Spells/Third/Poison.cs index 67d0e3b01..168413f25 100644 --- a/Projects/UOContent/Spells/Third/Poison.cs +++ b/Projects/UOContent/Spells/Third/Poison.cs @@ -43,7 +43,7 @@ namespace Server.Spells.Third { if (Caster.InRange(m, 2)) { - level = (Caster.Skills.Magery.Fixed + Caster.Skills.Poisoning.Fixed) / 2 switch + level = ((Caster.Skills.Magery.Fixed + Caster.Skills.Poisoning.Fixed) / 2) switch { >= 1000 => 3, > 850 => 2, From 61e217701161a5c541fb563da5b30304fe606cd7 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 11 Dec 2021 09:58:24 -0800 Subject: [PATCH 09/14] fix: Fixes damage bonus and makes it easier to read (#885) --- Projects/UOContent/Items/Weapons/BaseWeapon.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Projects/UOContent/Items/Weapons/BaseWeapon.cs b/Projects/UOContent/Items/Weapons/BaseWeapon.cs index 8e183a7b9..055c23e8d 100644 --- a/Projects/UOContent/Items/Weapons/BaseWeapon.cs +++ b/Projects/UOContent/Items/Weapons/BaseWeapon.cs @@ -2395,24 +2395,24 @@ namespace Server.Items public virtual int GetDamageBonus() { - var bonus = VirtualDamageBonus; - - bonus += m_Quality switch + var quality = m_Quality switch { WeaponQuality.Low => -20, WeaponQuality.Exceptional => 20, _ => 0 }; - return bonus + m_DamageLevel switch + var damageLevel = m_DamageLevel switch { WeaponDamageLevel.Ruin => 15, WeaponDamageLevel.Might => 20, WeaponDamageLevel.Force => 25, WeaponDamageLevel.Power => 30, WeaponDamageLevel.Vanq => 35, - _ => bonus + _ => 0 }; + + return VirtualDamageBonus + quality + damageLevel; } public virtual double ScaleDamageAOS(Mobile attacker, double damage, bool checkSkills) From b125146b27b6a2a1beb7a6e6af9b758b6742fbb0 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 13 Dec 2021 09:31:02 -0800 Subject: [PATCH 10/14] fix: Adds BitArray support with codegen (#888) * Adds a custom BitArray class with the following added features: * ctor for creating BitArray against read only span * ctor for creating BitArray against BinaryReader * CopyTo to copy a BitArray to a Span * Adds BitArray to UO Primitive serialization so it can be codegenned. --- .../Rules/PrimitiveUOTypeMigrationRule.cs | 1 + .../SymbolMetadata/SymbolMetadata.UO.cs | 8 + Projects/Server/Collections/BitArray.cs | 1410 +++++++++++++++++ .../Collections/CollectionThrowStrings.cs | 48 +- .../Server/Serialization/BinaryFileReader.cs | 10 + Projects/Server/Serialization/BufferReader.cs | 14 + Projects/Server/Serialization/BufferWriter.cs | 11 + .../Server/Serialization/IGenericReader.cs | 3 + .../Server/Serialization/IGenericWriter.cs | 3 + 9 files changed, 1489 insertions(+), 19 deletions(-) create mode 100644 Projects/Server/Collections/BitArray.cs diff --git a/Projects/SerializationGenerator/SerializableMigration/Rules/PrimitiveUOTypeMigrationRule.cs b/Projects/SerializationGenerator/SerializableMigration/Rules/PrimitiveUOTypeMigrationRule.cs index ec3562317..9d60ca27e 100644 --- a/Projects/SerializationGenerator/SerializableMigration/Rules/PrimitiveUOTypeMigrationRule.cs +++ b/Projects/SerializationGenerator/SerializableMigration/Rules/PrimitiveUOTypeMigrationRule.cs @@ -43,6 +43,7 @@ namespace SerializableMigration _ when symbol.IsRectangle3D(compilation) => new[] { "Rect3D" }, _ when symbol.IsRace(compilation) => new[] { "Race" }, _ when symbol.IsMap(compilation) => new[] { "Map" }, + _ when symbol.IsBitArray(compilation) => new[] { "BitArray" }, _ => null }; diff --git a/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs b/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs index 9b88b7493..2fdf8793c 100644 --- a/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs +++ b/Projects/SerializationGenerator/SourceGeneration/SymbolMetadata/SymbolMetadata.UO.cs @@ -47,6 +47,8 @@ namespace SerializationGenerator public const string SERIALIZABLE_FIELD_SAVE_FLAG_ATTRIBUTE = "Server.SerializableFieldSaveFlagAttribute"; public const string SERIALIZABLE_FIELD_DEFAULT_ATTRIBUTE = "Server.SerializableFieldDefaultAttribute"; public const string RAW_SERIALIZABLE_INTERFACE = "Server.IRawSerializable"; + // ModernUO modified BitArray + public const string SERVER_BITARRAY_CLASS = "Server.Collections.BitArray"; public static bool IsTimerDrift(this AttributeData attr, Compilation compilation) => attr?.IsAttribute(compilation.GetTypeByMetadataName(TIMER_DRIFT_ATTRIBUTE)) == true; @@ -184,6 +186,12 @@ namespace SerializationGenerator SymbolEqualityComparer.Default ); + public static bool IsBitArray(this ISymbol symbol, Compilation compilation) => + symbol.Equals( + compilation.GetTypeByMetadataName(SERVER_BITARRAY_CLASS), + SymbolEqualityComparer.Default + ); + public static AttributeData? GetAttribute(this ISymbol symbol, ISymbol attrSymbol) => symbol .GetAttributes() diff --git a/Projects/Server/Collections/BitArray.cs b/Projects/Server/Collections/BitArray.cs new file mode 100644 index 000000000..9df8f5441 --- /dev/null +++ b/Projects/Server/Collections/BitArray.cs @@ -0,0 +1,1410 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Buffers.Binary; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics.Arm; +using System.Collections; +using System.IO; + +namespace Server.Collections; + +// A vector of bits. Use this to store bits efficiently, without having to do bit +// shifting yourself. +[System.Serializable] +public sealed class BitArray : ICollection, ICloneable +{ + private int[] m_array; // Do not rename (binary serialization) + private int m_length; // Do not rename (binary serialization) + private int _version; // Do not rename (binary serialization) + + private const int _ShrinkThreshold = 256; + + /*========================================================================= + ** Allocates space to hold length bit values. All of the values in the bit + ** array are set to defaultValue. + ** + ** Exceptions: ArgumentOutOfRangeException if length < 0. + =========================================================================*/ + public BitArray(int length, bool defaultValue = false) + { + if (length < 0) + { + throw new ArgumentOutOfRangeException(nameof(length), length, CollectionThrowStrings.ArgumentOutOfRange_NeedNonNegNum); + } + + m_array = new int[GetInt32ArrayLengthFromBitLength(length)]; + m_length = length; + + if (defaultValue) + { + Array.Fill(m_array, -1); + + // clear high bit values in the last int + Div32Rem(length, out int extraBits); + if (extraBits > 0) + { + m_array[^1] = (1 << extraBits) - 1; + } + } + + _version = 0; + } + + /*========================================================================= + ** Allocates space to hold the bit values in bytes. bytes[0] represents + ** bits 0 - 7, bytes[1] represents bits 8 - 15, etc. The LSB of each byte + ** represents the lowest index value; bytes[0] & 1 represents bit 0, + ** bytes[0] & 2 represents bit 1, bytes[0] & 4 represents bit 2, etc. + ** + ** Exceptions: ArgumentException if bytes == null. + =========================================================================*/ + public BitArray(byte[] bytes) + { + if (bytes == null) + { + throw new ArgumentNullException(nameof(bytes)); + } + + // this value is chosen to prevent overflow when computing m_length. + // m_length is of type int32 and is exposed as a property, so + // type of m_length can't be changed to accommodate. + if (bytes.Length > int.MaxValue / BitsPerByte) + { + throw new ArgumentException(string.Format(CollectionThrowStrings.Argument_ArrayTooLarge, BitsPerByte), nameof(bytes)); + } + + m_array = new int[GetInt32ArrayLengthFromByteLength(bytes.Length)]; + m_length = bytes.Length * BitsPerByte; + + uint totalCount = (uint)bytes.Length / 4; + + ReadOnlySpan byteSpan = bytes; + for (int i = 0; i < totalCount; i++) + { + m_array[i] = BinaryPrimitives.ReadInt32LittleEndian(byteSpan); + byteSpan = byteSpan[4..]; + } + + Debug.Assert(byteSpan.Length >= 0 && byteSpan.Length < 4); + + int last = 0; + switch (byteSpan.Length) + { + case 3: + last = byteSpan[2] << 16; + goto case 2; + // fall through + case 2: + last |= byteSpan[1] << 8; + goto case 1; + // fall through + case 1: + m_array[totalCount] = last | byteSpan[0]; + break; + } + + _version = 0; + } + + /*========================================================================= + ** Allocates space to hold the bit values in bytes. bytes[0] represents + ** bits 0 - 7, bytes[1] represents bits 8 - 15, etc. The LSB of each byte + ** represents the lowest index value; bytes[0] & 1 represents bit 0, + ** bytes[0] & 2 represents bit 1, bytes[0] & 4 represents bit 2, etc. + ** + ** Exceptions: ArgumentException if bytes == null. + =========================================================================*/ + public BitArray(ReadOnlySpan bytes) + { + if (bytes == null) + { + throw new ArgumentNullException(nameof(bytes)); + } + + // this value is chosen to prevent overflow when computing m_length. + // m_length is of type int32 and is exposed as a property, so + // type of m_length can't be changed to accommodate. + if (bytes.Length > int.MaxValue / BitsPerByte) + { + throw new ArgumentException(string.Format(CollectionThrowStrings.Argument_ArrayTooLarge, BitsPerByte), nameof(bytes)); + } + + m_array = new int[GetInt32ArrayLengthFromByteLength(bytes.Length)]; + m_length = bytes.Length * BitsPerByte; + + uint totalCount = (uint)bytes.Length / 4; + + ReadOnlySpan byteSpan = bytes; + for (int i = 0; i < totalCount; i++) + { + m_array[i] = BinaryPrimitives.ReadInt32LittleEndian(byteSpan); + byteSpan = byteSpan[4..]; + } + + Debug.Assert(byteSpan.Length >= 0 && byteSpan.Length < 4); + + int last = 0; + switch (byteSpan.Length) + { + case 3: + last = byteSpan[2] << 16; + goto case 2; + // fall through + case 2: + last |= byteSpan[1] << 8; + goto case 1; + // fall through + case 1: + m_array[totalCount] = last | byteSpan[0]; + break; + } + + _version = 0; + } + + /*========================================================================= + ** Allocates space to hold the bit values in bytes. bytes[0] represents + ** bits 0 - 7, bytes[1] represents bits 8 - 15, etc. The LSB of each byte + ** represents the lowest index value; bytes[0] & 1 represents bit 0, + ** bytes[0] & 2 represents bit 1, bytes[0] & 4 represents bit 2, etc. + ** + ** Exceptions: ArgumentException if bytes == null. + =========================================================================*/ + public BitArray(BinaryReader reader, int length) + { + if (reader == null) + { + throw new ArgumentNullException(nameof(reader)); + } + + // this value is chosen to prevent overflow when computing m_length. + // m_length is of type int32 and is exposed as a property, so + // type of m_length can't be changed to accommodate. + if (length > int.MaxValue / BitsPerByte) + { + throw new ArgumentException(string.Format(CollectionThrowStrings.Argument_ArrayTooLarge, BitsPerByte), nameof(reader)); + } + + m_array = new int[GetInt32ArrayLengthFromByteLength(length)]; + m_length = length * BitsPerByte; + + uint totalCount = (uint)length / 4; + + for (int i = 0; i < totalCount; i++) + { + m_array[i] = reader.ReadInt32(); + length -= 4; + } + + Debug.Assert(length >= 0 && length < 4); + + int last = 0; + switch (length) + { + case 3: + last = reader.ReadInt16(); + goto case 2; + // fall through + case 2: + last |= reader.ReadByte(); + goto case 1; + // fall through + case 1: + m_array[totalCount] = last | reader.ReadByte(); + break; + } + + _version = 0; + } + + private const uint Vector128ByteCount = 16; + private const uint Vector128IntCount = 4; + private const uint Vector256ByteCount = 32; + private const uint Vector256IntCount = 8; + public unsafe BitArray(bool[] values) + { + if (values == null) + { + throw new ArgumentNullException(nameof(values)); + } + + m_array = new int[GetInt32ArrayLengthFromBitLength(values.Length)]; + m_length = values.Length; + + uint i = 0; + + if (values.Length < Vector256.Count) + { + goto LessThan32; + } + + // Comparing with 1s would get rid of the final negation, however this would not work for some CLR bools + // (true for any non-zero values, false for 0) - any values between 2-255 will be interpreted as false. + // Instead, We compare with zeroes (== false) then negate the result to ensure compatibility. + + if (Avx2.IsSupported) + { + // JIT does not support code hoisting for SIMD yet + Vector256 zero = Vector256.Zero; + fixed (bool* ptr = values) + { + for (; i + Vector256ByteCount <= (uint)values.Length; i += Vector256ByteCount) + { + Vector256 vector = Avx.LoadVector256((byte*)ptr + i); + Vector256 isFalse = Avx2.CompareEqual(vector, zero); + int result = Avx2.MoveMask(isFalse); + m_array[i / 32u] = ~result; + } + } + } + else if (Sse2.IsSupported) + { + // JIT does not support code hoisting for SIMD yet + Vector128 zero = Vector128.Zero; + fixed (bool* ptr = values) + { + for (; i + Vector128ByteCount * 2u <= (uint)values.Length; i += Vector128ByteCount * 2u) + { + Vector128 lowerVector = Sse2.LoadVector128((byte*)ptr + i); + Vector128 lowerIsFalse = Sse2.CompareEqual(lowerVector, zero); + int lowerPackedIsFalse = Sse2.MoveMask(lowerIsFalse); + + Vector128 upperVector = Sse2.LoadVector128((byte*)ptr + i + Vector128.Count); + Vector128 upperIsFalse = Sse2.CompareEqual(upperVector, zero); + int upperPackedIsFalse = Sse2.MoveMask(upperIsFalse); + + m_array[i / 32u] = ~((upperPackedIsFalse << 16) | lowerPackedIsFalse); + } + } + } + else if (AdvSimd.Arm64.IsSupported) + { + // JIT does not support code hoisting for SIMD yet + // However comparison against zero can be replaced to cmeq against zero (vceqzq_s8) + // See dotnet/runtime#33972 for details + Vector128 zero = Vector128.Zero; + Vector128 bitMask128 = BitConverter.IsLittleEndian ? + Vector128.Create(0x80402010_08040201).AsByte() : + Vector128.Create(0x01020408_10204080).AsByte(); + + fixed (bool* ptr = values) + { + for (; i + Vector128ByteCount * 2u <= (uint)values.Length; i += Vector128ByteCount * 2u) + { + // Same logic as SSE2 path, however we lack MoveMask (equivalent) instruction + // As a workaround, mask out the relevant bit after comparison + // and combine by ORing all of them together (In this case, adding all of them does the same thing) + Vector128 lowerVector = AdvSimd.LoadVector128((byte*)ptr + i); + Vector128 lowerIsFalse = AdvSimd.CompareEqual(lowerVector, zero); + Vector128 bitsExtracted1 = AdvSimd.And(lowerIsFalse, bitMask128); + bitsExtracted1 = AdvSimd.Arm64.AddPairwise(bitsExtracted1, bitsExtracted1); + bitsExtracted1 = AdvSimd.Arm64.AddPairwise(bitsExtracted1, bitsExtracted1); + bitsExtracted1 = AdvSimd.Arm64.AddPairwise(bitsExtracted1, bitsExtracted1); + Vector128 lowerPackedIsFalse = bitsExtracted1.AsInt16(); + + Vector128 upperVector = AdvSimd.LoadVector128((byte*)ptr + i + Vector128.Count); + Vector128 upperIsFalse = AdvSimd.CompareEqual(upperVector, zero); + Vector128 bitsExtracted2 = AdvSimd.And(upperIsFalse, bitMask128); + bitsExtracted2 = AdvSimd.Arm64.AddPairwise(bitsExtracted2, bitsExtracted2); + bitsExtracted2 = AdvSimd.Arm64.AddPairwise(bitsExtracted2, bitsExtracted2); + bitsExtracted2 = AdvSimd.Arm64.AddPairwise(bitsExtracted2, bitsExtracted2); + Vector128 upperPackedIsFalse = bitsExtracted2.AsInt16(); + + int result = AdvSimd.Arm64.ZipLow(lowerPackedIsFalse, upperPackedIsFalse).AsInt32().ToScalar(); + if (!BitConverter.IsLittleEndian) + { + result = BinaryPrimitives.ReverseEndianness(result); + } + m_array[i / 32u] = ~result; + } + } + } + + LessThan32: + for (; i < (uint)values.Length; i++) + { + if (values[i]) + { + int elementIndex = Div32Rem((int)i, out int extraBits); + m_array[elementIndex] |= 1 << extraBits; + } + } + + _version = 0; + } + + /*========================================================================= + ** Allocates space to hold the bit values in values. values[0] represents + ** bits 0 - 31, values[1] represents bits 32 - 63, etc. The LSB of each + ** integer represents the lowest index value; values[0] & 1 represents bit + ** 0, values[0] & 2 represents bit 1, values[0] & 4 represents bit 2, etc. + ** + ** Exceptions: ArgumentException if values == null. + =========================================================================*/ + public BitArray(int[] values) + { + if (values == null) + { + throw new ArgumentNullException(nameof(values)); + } + + // this value is chosen to prevent overflow when computing m_length + if (values.Length > int.MaxValue / BitsPerInt32) + { + throw new ArgumentException(string.Format(CollectionThrowStrings.Argument_ArrayTooLarge, BitsPerInt32), nameof(values)); + } + + m_array = new int[values.Length]; + Array.Copy(values, m_array, values.Length); + m_length = values.Length * BitsPerInt32; + + _version = 0; + } + + /*========================================================================= + ** Allocates a new BitArray with the same length and bit values as bits. + ** + ** Exceptions: ArgumentException if bits == null. + =========================================================================*/ + public BitArray(BitArray bits) + { + if (bits == null) + { + throw new ArgumentNullException(nameof(bits)); + } + + int arrayLength = GetInt32ArrayLengthFromBitLength(bits.m_length); + + m_array = new int[arrayLength]; + + Debug.Assert(bits.m_array.Length <= arrayLength); + + Array.Copy(bits.m_array, m_array, arrayLength); + m_length = bits.m_length; + + _version = bits._version; + } + + public bool this[int index] + { + get => Get(index); + set => Set(index, value); + } + + /*========================================================================= + ** Returns the bit value at position index. + ** + ** Exceptions: ArgumentOutOfRangeException if index < 0 or + ** index >= GetLength(). + =========================================================================*/ + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public bool Get(int index) + { + if ((uint)index >= (uint)m_length) + { + ThrowArgumentOutOfRangeException(index); + } + + return (m_array[index >> 5] & (1 << index)) != 0; + } + + /*========================================================================= + ** Sets the bit value at position index to value. + ** + ** Exceptions: ArgumentOutOfRangeException if index < 0 or + ** index >= GetLength(). + =========================================================================*/ + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Set(int index, bool value) + { + if ((uint)index >= (uint)m_length) + { + ThrowArgumentOutOfRangeException(index); + } + + int bitMask = 1 << index; + ref int segment = ref m_array[index >> 5]; + + if (value) + { + segment |= bitMask; + } + else + { + segment &= ~bitMask; + } + + _version++; + } + + /*========================================================================= + ** Sets all the bit values to value. + =========================================================================*/ + public void SetAll(bool value) + { + int arrayLength = GetInt32ArrayLengthFromBitLength(Length); + Span span = m_array.AsSpan(0, arrayLength); + if (value) + { + span.Fill(-1); + + // clear high bit values in the last int + Div32Rem(m_length, out int extraBits); + if (extraBits > 0) + { + span[^1] &= (1 << extraBits) - 1; + } + } + else + { + span.Clear(); + } + + _version++; + } + + /*========================================================================= + ** Returns a reference to the current instance ANDed with value. + ** + ** Exceptions: ArgumentException if value == null or + ** value.Length != this.Length. + =========================================================================*/ + public unsafe BitArray And(BitArray value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + // This method uses unsafe code to manipulate data in the BitArrays. To avoid issues with + // buggy code concurrently mutating these instances in a way that could cause memory corruption, + // we snapshot the arrays from both and then operate only on those snapshots, while also validating + // that the count we iterate to is within the bounds of both arrays. We don't care about such code + // corrupting the BitArray data in a way that produces incorrect answers, since BitArray is not meant + // to be thread-safe; we only care about avoiding buffer overruns. + int[] thisArray = m_array; + int[] valueArray = value.m_array; + + int count = GetInt32ArrayLengthFromBitLength(Length); + if (Length != value.Length || (uint)count > (uint)thisArray.Length || (uint)count > (uint)valueArray.Length) + { + throw new ArgumentException(CollectionThrowStrings.Arg_ArrayLengthsDiffer); + } + + // Unroll loop for count less than Vector256 size. + switch (count) + { + case 7: thisArray[6] &= valueArray[6]; goto case 6; + case 6: thisArray[5] &= valueArray[5]; goto case 5; + case 5: thisArray[4] &= valueArray[4]; goto case 4; + case 4: thisArray[3] &= valueArray[3]; goto case 3; + case 3: thisArray[2] &= valueArray[2]; goto case 2; + case 2: thisArray[1] &= valueArray[1]; goto case 1; + case 1: thisArray[0] &= valueArray[0]; goto Done; + case 0: goto Done; + } + + uint i = 0; + if (Avx2.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector256IntCount - 1u); i += Vector256IntCount) + { + Vector256 leftVec = Avx.LoadVector256(leftPtr + i); + Vector256 rightVec = Avx.LoadVector256(rightPtr + i); + Avx.Store(leftPtr + i, Avx2.And(leftVec, rightVec)); + } + } + } + } + else if (Sse2.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 leftVec = Sse2.LoadVector128(leftPtr + i); + Vector128 rightVec = Sse2.LoadVector128(rightPtr + i); + Sse2.Store(leftPtr + i, Sse2.And(leftVec, rightVec)); + } + } + } + } + else if (AdvSimd.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 leftVec = AdvSimd.LoadVector128(leftPtr + i); + Vector128 rightVec = AdvSimd.LoadVector128(rightPtr + i); + AdvSimd.Store(leftPtr + i, AdvSimd.And(leftVec, rightVec)); + } + } + } + } + + for (; i < (uint)count; i++) + { + thisArray[i] &= valueArray[i]; + } + + Done: + _version++; + return this; + } + + /*========================================================================= + ** Returns a reference to the current instance ORed with value. + ** + ** Exceptions: ArgumentException if value == null or + ** value.Length != this.Length. + =========================================================================*/ + public unsafe BitArray Or(BitArray value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + // This method uses unsafe code to manipulate data in the BitArrays. To avoid issues with + // buggy code concurrently mutating these instances in a way that could cause memory corruption, + // we snapshot the arrays from both and then operate only on those snapshots, while also validating + // that the count we iterate to is within the bounds of both arrays. We don't care about such code + // corrupting the BitArray data in a way that produces incorrect answers, since BitArray is not meant + // to be thread-safe; we only care about avoiding buffer overruns. + int[] thisArray = m_array; + int[] valueArray = value.m_array; + + int count = GetInt32ArrayLengthFromBitLength(Length); + if (Length != value.Length || (uint)count > (uint)thisArray.Length || (uint)count > (uint)valueArray.Length) + { + throw new ArgumentException(CollectionThrowStrings.Arg_ArrayLengthsDiffer); + } + + // Unroll loop for count less than Vector256 size. + switch (count) + { + case 7: thisArray[6] |= valueArray[6]; goto case 6; + case 6: thisArray[5] |= valueArray[5]; goto case 5; + case 5: thisArray[4] |= valueArray[4]; goto case 4; + case 4: thisArray[3] |= valueArray[3]; goto case 3; + case 3: thisArray[2] |= valueArray[2]; goto case 2; + case 2: thisArray[1] |= valueArray[1]; goto case 1; + case 1: thisArray[0] |= valueArray[0]; goto Done; + case 0: goto Done; + } + + uint i = 0; + if (Avx2.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector256IntCount - 1u); i += Vector256IntCount) + { + Vector256 leftVec = Avx.LoadVector256(leftPtr + i); + Vector256 rightVec = Avx.LoadVector256(rightPtr + i); + Avx.Store(leftPtr + i, Avx2.Or(leftVec, rightVec)); + } + } + } + } + else if (Sse2.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 leftVec = Sse2.LoadVector128(leftPtr + i); + Vector128 rightVec = Sse2.LoadVector128(rightPtr + i); + Sse2.Store(leftPtr + i, Sse2.Or(leftVec, rightVec)); + } + } + } + } + else if (AdvSimd.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 leftVec = AdvSimd.LoadVector128(leftPtr + i); + Vector128 rightVec = AdvSimd.LoadVector128(rightPtr + i); + AdvSimd.Store(leftPtr + i, AdvSimd.Or(leftVec, rightVec)); + } + } + } + } + + for (; i < (uint)count; i++) + { + thisArray[i] |= valueArray[i]; + } + + Done: + _version++; + return this; + } + + /*========================================================================= + ** Returns a reference to the current instance XORed with value. + ** + ** Exceptions: ArgumentException if value == null or + ** value.Length != this.Length. + =========================================================================*/ + public unsafe BitArray Xor(BitArray value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + + // This method uses unsafe code to manipulate data in the BitArrays. To avoid issues with + // buggy code concurrently mutating these instances in a way that could cause memory corruption, + // we snapshot the arrays from both and then operate only on those snapshots, while also validating + // that the count we iterate to is within the bounds of both arrays. We don't care about such code + // corrupting the BitArray data in a way that produces incorrect answers, since BitArray is not meant + // to be thread-safe; we only care about avoiding buffer overruns. + int[] thisArray = m_array; + int[] valueArray = value.m_array; + + int count = GetInt32ArrayLengthFromBitLength(Length); + if (Length != value.Length || (uint)count > (uint)thisArray.Length || (uint)count > (uint)valueArray.Length) + { + throw new ArgumentException(CollectionThrowStrings.Arg_ArrayLengthsDiffer); + } + + // Unroll loop for count less than Vector256 size. + switch (count) + { + case 7: thisArray[6] ^= valueArray[6]; goto case 6; + case 6: thisArray[5] ^= valueArray[5]; goto case 5; + case 5: thisArray[4] ^= valueArray[4]; goto case 4; + case 4: thisArray[3] ^= valueArray[3]; goto case 3; + case 3: thisArray[2] ^= valueArray[2]; goto case 2; + case 2: thisArray[1] ^= valueArray[1]; goto case 1; + case 1: thisArray[0] ^= valueArray[0]; goto Done; + case 0: goto Done; + } + + uint i = 0; + if (Avx2.IsSupported) + { + fixed (int* leftPtr = m_array) + { + fixed (int* rightPtr = value.m_array) + { + for (; i < (uint)count - (Vector256IntCount - 1u); i += Vector256IntCount) + { + Vector256 leftVec = Avx.LoadVector256(leftPtr + i); + Vector256 rightVec = Avx.LoadVector256(rightPtr + i); + Avx.Store(leftPtr + i, Avx2.Xor(leftVec, rightVec)); + } + } + } + } + else if (Sse2.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 leftVec = Sse2.LoadVector128(leftPtr + i); + Vector128 rightVec = Sse2.LoadVector128(rightPtr + i); + Sse2.Store(leftPtr + i, Sse2.Xor(leftVec, rightVec)); + } + } + } + } + else if (AdvSimd.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + fixed (int* rightPtr = valueArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 leftVec = AdvSimd.LoadVector128(leftPtr + i); + Vector128 rightVec = AdvSimd.LoadVector128(rightPtr + i); + AdvSimd.Store(leftPtr + i, AdvSimd.Xor(leftVec, rightVec)); + } + } + } + } + + for (; i < (uint)count; i++) + { + thisArray[i] ^= valueArray[i]; + } + + Done: + _version++; + return this; + } + + /*========================================================================= + ** Inverts all the bit values. On/true bit values are converted to + ** off/false. Off/false bit values are turned on/true. The current instance + ** is updated and returned. + =========================================================================*/ + public unsafe BitArray Not() + { + // This method uses unsafe code to manipulate data in the BitArray. To avoid issues with + // buggy code concurrently mutating this instance in a way that could cause memory corruption, + // we snapshot the array then operate only on this snapshot. We don't care about such code + // corrupting the BitArray data in a way that produces incorrect answers, since BitArray is not meant + // to be thread-safe; we only care about avoiding buffer overruns. + int[] thisArray = m_array; + + int count = GetInt32ArrayLengthFromBitLength(Length); + + // Unroll loop for count less than Vector256 size. + switch (count) + { + case 7: thisArray[6] = ~thisArray[6]; goto case 6; + case 6: thisArray[5] = ~thisArray[5]; goto case 5; + case 5: thisArray[4] = ~thisArray[4]; goto case 4; + case 4: thisArray[3] = ~thisArray[3]; goto case 3; + case 3: thisArray[2] = ~thisArray[2]; goto case 2; + case 2: thisArray[1] = ~thisArray[1]; goto case 1; + case 1: thisArray[0] = ~thisArray[0]; goto Done; + case 0: goto Done; + } + + uint i = 0; + if (Avx2.IsSupported) + { + Vector256 ones = Vector256.Create(-1); + fixed (int* ptr = thisArray) + { + for (; i < (uint)count - (Vector256IntCount - 1u); i += Vector256IntCount) + { + Vector256 vec = Avx.LoadVector256(ptr + i); + Avx.Store(ptr + i, Avx2.Xor(vec, ones)); + } + } + } + else if (Sse2.IsSupported) + { + Vector128 ones = Vector128.Create(-1); + fixed (int* ptr = thisArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 vec = Sse2.LoadVector128(ptr + i); + Sse2.Store(ptr + i, Sse2.Xor(vec, ones)); + } + } + } + else if (AdvSimd.IsSupported) + { + fixed (int* leftPtr = thisArray) + { + for (; i < (uint)count - (Vector128IntCount - 1u); i += Vector128IntCount) + { + Vector128 leftVec = AdvSimd.LoadVector128(leftPtr + i); + AdvSimd.Store(leftPtr + i, AdvSimd.Not(leftVec)); + } + } + } + + for (; i < (uint)count; i++) + { + thisArray[i] = ~thisArray[i]; + } + + Done: + _version++; + return this; + } + + /*========================================================================= + ** Shift all the bit values to right on count bits. The current instance is + ** updated and returned. + * + ** Exceptions: ArgumentOutOfRangeException if count < 0 + =========================================================================*/ + public BitArray RightShift(int count) + { + if (count <= 0) + { + if (count < 0) + { + throw new ArgumentOutOfRangeException(nameof(count), count, CollectionThrowStrings.ArgumentOutOfRange_NeedNonNegNum); + } + + _version++; + return this; + } + + int toIndex = 0; + int ints = GetInt32ArrayLengthFromBitLength(m_length); + if (count < m_length) + { + // We can not use Math.DivRem without taking a dependency on System.Runtime.Extensions + int fromIndex = Div32Rem(count, out int shiftCount); + Div32Rem(m_length, out int extraBits); + if (shiftCount == 0) + { + unchecked + { + // Cannot use `(1u << extraBits) - 1u` as the mask + // because for extraBits == 0, we need the mask to be 111...111, not 0. + // In that case, we are shifting a uint by 32, which could be considered undefined. + // The result of a shift operation is undefined ... if the right operand + // is greater than or equal to the width in bits of the promoted left operand, + // https://docs.microsoft.com/en-us/cpp/c-language/bitwise-shift-operators?view=vs-2017 + // However, the compiler protects us from undefined behaviour by constraining the + // right operand to between 0 and width - 1 (inclusive), i.e. right_operand = (right_operand % width). + uint mask = uint.MaxValue >> (BitsPerInt32 - extraBits); + m_array[ints - 1] &= (int)mask; + } + Array.Copy(m_array, fromIndex, m_array, 0, ints - fromIndex); + toIndex = ints - fromIndex; + } + else + { + int lastIndex = ints - 1; + unchecked + { + while (fromIndex < lastIndex) + { + uint right = (uint)m_array[fromIndex] >> shiftCount; + int left = m_array[++fromIndex] << (BitsPerInt32 - shiftCount); + m_array[toIndex++] = left | (int)right; + } + uint mask = uint.MaxValue >> (BitsPerInt32 - extraBits); + mask &= (uint)m_array[fromIndex]; + m_array[toIndex++] = (int)(mask >> shiftCount); + } + } + } + + m_array.AsSpan(toIndex, ints - toIndex).Clear(); + _version++; + return this; + } + + /*========================================================================= + ** Shift all the bit values to left on count bits. The current instance is + ** updated and returned. + * + ** Exceptions: ArgumentOutOfRangeException if count < 0 + =========================================================================*/ + public BitArray LeftShift(int count) + { + if (count <= 0) + { + if (count < 0) + { + throw new ArgumentOutOfRangeException(nameof(count), count, CollectionThrowStrings.ArgumentOutOfRange_NeedNonNegNum); + } + + _version++; + return this; + } + + int lengthToClear; + if (count < m_length) + { + int lastIndex = (m_length - 1) >> BitShiftPerInt32; // Divide by 32. + + // We can not use Math.DivRem without taking a dependency on System.Runtime.Extensions + lengthToClear = Div32Rem(count, out int shiftCount); + + if (shiftCount == 0) + { + Array.Copy(m_array, 0, m_array, lengthToClear, lastIndex + 1 - lengthToClear); + } + else + { + int fromindex = lastIndex - lengthToClear; + unchecked + { + while (fromindex > 0) + { + int left = m_array[fromindex] << shiftCount; + uint right = (uint)m_array[--fromindex] >> (BitsPerInt32 - shiftCount); + m_array[lastIndex] = left | (int)right; + lastIndex--; + } + m_array[lastIndex] = m_array[fromindex] << shiftCount; + } + } + } + else + { + lengthToClear = GetInt32ArrayLengthFromBitLength(m_length); // Clear all + } + + m_array.AsSpan(0, lengthToClear).Clear(); + _version++; + return this; + } + + public int Length + { + get + { + return m_length; + } + set + { + if (value < 0) + { + throw new ArgumentOutOfRangeException(nameof(value), value, CollectionThrowStrings.ArgumentOutOfRange_NeedNonNegNum); + } + + int newints = GetInt32ArrayLengthFromBitLength(value); + if (newints > m_array.Length || newints + _ShrinkThreshold < m_array.Length) + { + // grow or shrink (if wasting more than _ShrinkThreshold ints) + Array.Resize(ref m_array, newints); + } + + if (value > m_length) + { + // clear high bit values in the last int + int last = (m_length - 1) >> BitShiftPerInt32; + Div32Rem(m_length, out int bits); + if (bits > 0) + { + m_array[last] &= (1 << bits) - 1; + } + + // clear remaining int values + m_array.AsSpan(last + 1, newints - last - 1).Clear(); + } + + m_length = value; + _version++; + } + } + + public void CopyTo(Span span) + { + int arrayLength = GetByteArrayLengthFromBitLength(m_length); + if (span.Length < arrayLength) + { + throw new ArgumentException(CollectionThrowStrings.Argument_InvalidOffLen); + } + + // equivalent to m_length % BitsPerByte, since BitsPerByte is a power of 2 + uint extraBits = (uint)m_length & (BitsPerByte - 1); + if (extraBits > 0) + { + // last byte is not aligned, we will directly copy one less byte + arrayLength -= 1; + } + + int quotient = Div4Rem(arrayLength, out int remainder); + for (int i = 0; i < quotient; i++) + { + BinaryPrimitives.WriteInt32LittleEndian(span, m_array[i]); + span = span[4..]; + } + + if (extraBits > 0) + { + Debug.Assert(span.Length > 0); + Debug.Assert(m_array.Length > quotient); + // mask the final byte + span[remainder] = (byte)((m_array[quotient] >> (remainder * 8)) & ((1 << (int)extraBits) - 1)); + } + + switch (remainder) + { + case 3: + span[2] = (byte)(m_array[quotient] >> 16); + goto case 2; + // fall through + case 2: + span[1] = (byte)(m_array[quotient] >> 8); + goto case 1; + // fall through + case 1: + span[0] = (byte)m_array[quotient]; + break; + } + } + + public unsafe void CopyTo(Array array, int index) + { + if (array == null) + { + throw new ArgumentNullException(nameof(array)); + } + + if (index < 0) + { + throw new ArgumentOutOfRangeException(nameof(index), index, CollectionThrowStrings.ArgumentOutOfRange_NeedNonNegNum); + } + + if (array.Rank != 1) + { + throw new ArgumentException(CollectionThrowStrings.Arg_RankMultiDimNotSupported, nameof(array)); + } + + if (array is int[] intArray) + { + Div32Rem(m_length, out int extraBits); + + if (extraBits == 0) + { + // we have perfect bit alignment, no need to sanitize, just copy + Array.Copy(m_array, 0, intArray, index, m_array.Length); + } + else + { + int last = (m_length - 1) >> BitShiftPerInt32; + // do not copy the last int, as it is not completely used + Array.Copy(m_array, 0, intArray, index, last); + + // the last int needs to be masked + intArray[index + last] = m_array[last] & unchecked((1 << extraBits) - 1); + } + } + else if (array is byte[] byteArray) + { + int arrayLength = GetByteArrayLengthFromBitLength(m_length); + if (array.Length - index < arrayLength) + { + throw new ArgumentException(CollectionThrowStrings.Argument_InvalidOffLen); + } + + // equivalent to m_length % BitsPerByte, since BitsPerByte is a power of 2 + uint extraBits = (uint)m_length & (BitsPerByte - 1); + if (extraBits > 0) + { + // last byte is not aligned, we will directly copy one less byte + arrayLength -= 1; + } + + Span span = byteArray.AsSpan(index); + + int quotient = Div4Rem(arrayLength, out int remainder); + for (int i = 0; i < quotient; i++) + { + BinaryPrimitives.WriteInt32LittleEndian(span, m_array[i]); + span = span[4..]; + } + + if (extraBits > 0) + { + Debug.Assert(span.Length > 0); + Debug.Assert(m_array.Length > quotient); + // mask the final byte + span[remainder] = (byte)((m_array[quotient] >> (remainder * 8)) & ((1 << (int)extraBits) - 1)); + } + + switch (remainder) + { + case 3: + span[2] = (byte)(m_array[quotient] >> 16); + goto case 2; + // fall through + case 2: + span[1] = (byte)(m_array[quotient] >> 8); + goto case 1; + // fall through + case 1: + span[0] = (byte)m_array[quotient]; + break; + } + } + else if (array is bool[] boolArray) + { + if (array.Length - index < m_length) + { + throw new ArgumentException(CollectionThrowStrings.Argument_InvalidOffLen); + } + + uint i = 0; + + if (m_length < BitsPerInt32) + { + goto LessThan32; + } + + // The mask used when shuffling a single int into Vector128/256. + // On little endian machines, the lower 8 bits of int belong in the first byte, next lower 8 in the second and so on. + // We place the bytes that contain the bits to its respective byte so that we can mask out only the relevant bits later. + Vector128 lowerShuffleMask_CopyToBoolArray = Vector128.Create(0, 0x01010101_01010101).AsByte(); + Vector128 upperShuffleMask_CopyToBoolArray = Vector128.Create(0x02020202_02020202, 0x03030303_03030303).AsByte(); + + if (Avx2.IsSupported) + { + Vector256 shuffleMask = Vector256.Create(lowerShuffleMask_CopyToBoolArray, upperShuffleMask_CopyToBoolArray); + Vector256 bitMask = Vector256.Create(0x80402010_08040201).AsByte(); + Vector256 ones = Vector256.Create((byte)1); + + fixed (bool* destination = &boolArray[index]) + { + for (; i + Vector256ByteCount <= (uint)m_length; i += Vector256ByteCount) + { + int bits = m_array[i / BitsPerInt32]; + Vector256 scalar = Vector256.Create(bits); + Vector256 shuffled = Avx2.Shuffle(scalar.AsByte(), shuffleMask); + Vector256 extracted = Avx2.And(shuffled, bitMask); + + // The extracted bits can be anywhere between 0 and 255, so we normalise the value to either 0 or 1 + // to ensure compatibility with "C# bool" (0 for false, 1 for true, rest undefined) + Vector256 normalized = Avx2.Min(extracted, ones); + Avx.Store((byte*)destination + i, normalized); + } + } + } + else if (Ssse3.IsSupported) + { + Vector128 lowerShuffleMask = lowerShuffleMask_CopyToBoolArray; + Vector128 upperShuffleMask = upperShuffleMask_CopyToBoolArray; + Vector128 ones = Vector128.Create((byte)1); + Vector128 bitMask128 = BitConverter.IsLittleEndian ? + Vector128.Create(0x80402010_08040201).AsByte() : + Vector128.Create(0x01020408_10204080).AsByte(); + + fixed (bool* destination = &boolArray[index]) + { + for (; i + Vector128ByteCount * 2u <= (uint)m_length; i += Vector128ByteCount * 2u) + { + int bits = m_array[i / BitsPerInt32]; + Vector128 scalar = Vector128.CreateScalarUnsafe(bits); + + Vector128 shuffledLower = Ssse3.Shuffle(scalar.AsByte(), lowerShuffleMask); + Vector128 extractedLower = Sse2.And(shuffledLower, bitMask128); + Vector128 normalizedLower = Sse2.Min(extractedLower, ones); + Sse2.Store((byte*)destination + i, normalizedLower); + + Vector128 shuffledHigher = Ssse3.Shuffle(scalar.AsByte(), upperShuffleMask); + Vector128 extractedHigher = Sse2.And(shuffledHigher, bitMask128); + Vector128 normalizedHigher = Sse2.Min(extractedHigher, ones); + Sse2.Store((byte*)destination + i + Vector128.Count, normalizedHigher); + } + } + } + else if (AdvSimd.IsSupported) + { + Vector128 ones = Vector128.Create((byte)1); + Vector128 bitMask128 = BitConverter.IsLittleEndian ? + Vector128.Create(0x80402010_08040201).AsByte() : + Vector128.Create(0x01020408_10204080).AsByte(); + + fixed (bool* destination = &boolArray[index]) + { + for (; i + Vector128ByteCount * 2u <= (uint)m_length; i += Vector128ByteCount * 2u) + { + int bits = m_array[i / BitsPerInt32]; + // Same logic as SSSE3 path, except we do not have Shuffle instruction. + // (TableVectorLookup could be an alternative - dotnet/runtime#1277) + // Instead we use chained ZIP1/2 instructions: + // (A0 is the byte containing LSB, A3 is the byte containing MSB) + // bits (on Big endian) - A3 A2 A1 A0 + // bits (Little endian) / Byte reversal - A0 A1 A2 A3 + // v1 = Vector128.Create - A0 A1 A2 A3 A0 A1 A2 A3 A0 A1 A2 A3 A0 A1 A2 A3 + // v2 = ZipLow(v1, v1) - A0 A0 A1 A1 A2 A2 A3 A3 A0 A0 A1 A1 A2 A2 A3 A3 + // v3 = ZipLow(v2, v2) - A0 A0 A0 A0 A1 A1 A1 A1 A2 A2 A2 A2 A3 A3 A3 A3 + // shuffledLower = ZipLow(v3, v3) - A0 A0 A0 A0 A0 A0 A0 A0 A1 A1 A1 A1 A1 A1 A1 A1 + // shuffledHigher = ZipHigh(v3, v3) - A2 A2 A2 A2 A2 A2 A2 A2 A3 A3 A3 A3 A3 A3 A3 A3 + if (!BitConverter.IsLittleEndian) + { + bits = BinaryPrimitives.ReverseEndianness(bits); + } + Vector128 vector = Vector128.Create(bits).AsByte(); + vector = AdvSimd.Arm64.ZipLow(vector, vector); + vector = AdvSimd.Arm64.ZipLow(vector, vector); + + Vector128 shuffledLower = AdvSimd.Arm64.ZipLow(vector, vector); + Vector128 extractedLower = AdvSimd.And(shuffledLower, bitMask128); + Vector128 normalizedLower = AdvSimd.Min(extractedLower, ones); + AdvSimd.Store((byte*)destination + i, normalizedLower); + + Vector128 shuffledHigher = AdvSimd.Arm64.ZipHigh(vector, vector); + Vector128 extractedHigher = AdvSimd.And(shuffledHigher, bitMask128); + Vector128 normalizedHigher = AdvSimd.Min(extractedHigher, ones); + AdvSimd.Store((byte*)destination + i + Vector128.Count, normalizedHigher); + } + } + } + + LessThan32: + for (; i < (uint)m_length; i++) + { + int elementIndex = Div32Rem((int)i, out int extraBits); + boolArray[(uint)index + i] = ((m_array[elementIndex] >> extraBits) & 0x00000001) != 0; + } + } + else + { + throw new ArgumentException(CollectionThrowStrings.Arg_BitArrayTypeUnsupported, nameof(array)); + } + } + + public int Count => m_length; + + public object SyncRoot => this; + + public bool IsSynchronized => false; + + public bool IsReadOnly => false; + + public object Clone() => new BitArray(this); + + public IEnumerator GetEnumerator() => new BitArrayEnumeratorSimple(this); + + // XPerY=n means that n Xs can be stored in 1 Y. + private const int BitsPerInt32 = 32; + private const int BitsPerByte = 8; + + private const int BitShiftPerInt32 = 5; + private const int BitShiftPerByte = 3; + private const int BitShiftForBytesPerInt32 = 2; + + /// + /// Used for conversion between different representations of bit array. + /// Returns (n + (32 - 1)) / 32, rearranged to avoid arithmetic overflow. + /// For example, in the bit to int case, the straightforward calc would + /// be (n + 31) / 32, but that would cause overflow. So instead it's + /// rearranged to ((n - 1) / 32) + 1. + /// Due to sign extension, we don't need to special case for n == 0, if we use + /// bitwise operations (since ((n - 1) >> 5) + 1 = 0). + /// This doesn't hold true for ((n - 1) / 32) + 1, which equals 1. + /// + /// Usage: + /// GetArrayLength(77): returns how many ints must be + /// allocated to store 77 bits. + /// + /// + /// how many ints are required to store n bytes + private static int GetInt32ArrayLengthFromBitLength(int n) + { + Debug.Assert(n >= 0); + return (int)((uint)(n - 1 + (1 << BitShiftPerInt32)) >> BitShiftPerInt32); + } + + private static int GetInt32ArrayLengthFromByteLength(int n) + { + Debug.Assert(n >= 0); + // Due to sign extension, we don't need to special case for n == 0, since ((n - 1) >> 2) + 1 = 0 + // This doesn't hold true for ((n - 1) / 4) + 1, which equals 1. + return (int)((uint)(n - 1 + (1 << BitShiftForBytesPerInt32)) >> BitShiftForBytesPerInt32); + } + + public static int GetByteArrayLengthFromBitLength(int n) + { + Debug.Assert(n >= 0); + // Due to sign extension, we don't need to special case for n == 0, since ((n - 1) >> 3) + 1 = 0 + // This doesn't hold true for ((n - 1) / 8) + 1, which equals 1. + return (int)((uint)(n - 1 + (1 << BitShiftPerByte)) >> BitShiftPerByte); + } + + private static int Div32Rem(int number, out int remainder) + { + uint quotient = (uint)number / 32; + remainder = number & (32 - 1); // equivalent to number % 32, since 32 is a power of 2 + return (int)quotient; + } + + private static int Div4Rem(int number, out int remainder) + { + uint quotient = (uint)number / 4; + remainder = number & (4 - 1); // equivalent to number % 4, since 4 is a power of 2 + return (int)quotient; + } + + private static void ThrowArgumentOutOfRangeException(int index) + { + throw new ArgumentOutOfRangeException(nameof(index), index, CollectionThrowStrings.ArgumentOutOfRange_Index); + } + + private sealed class BitArrayEnumeratorSimple : IEnumerator, ICloneable + { + private readonly BitArray _bitArray; + private int _index; + private readonly int _version; + private bool _currentElement; + + internal BitArrayEnumeratorSimple(BitArray bitArray) + { + _bitArray = bitArray; + _index = -1; + _version = bitArray._version; + } + + public object Clone() => MemberwiseClone(); + + public bool MoveNext() + { + if (_version != _bitArray._version) + { + throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion); + } + + if (_index < _bitArray.m_length - 1) + { + _index++; + _currentElement = _bitArray.Get(_index); + return true; + } + else + { + _index = _bitArray.m_length; + } + + return false; + } + + public object Current + { + get + { + if ((uint)_index >= (uint)_bitArray.m_length) + { + throw GetInvalidOperationException(_index); + } + + return _currentElement; + } + } + + public void Reset() + { + if (_version != _bitArray._version) + { + throw new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumFailedVersion); + } + + _index = -1; + } + + private InvalidOperationException GetInvalidOperationException(int index) + { + if (index == -1) + { + return new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumNotStarted); + } + + Debug.Assert(index >= _bitArray.m_length); + return new InvalidOperationException(CollectionThrowStrings.InvalidOperation_EnumEnded); + } + } +} diff --git a/Projects/Server/Collections/CollectionThrowStrings.cs b/Projects/Server/Collections/CollectionThrowStrings.cs index 41feda828..1730c6334 100644 --- a/Projects/Server/Collections/CollectionThrowStrings.cs +++ b/Projects/Server/Collections/CollectionThrowStrings.cs @@ -13,33 +13,43 @@ * along with this program. If not, see . * *************************************************************************/ -namespace Server.Collections +namespace Server.Collections; + +public static class CollectionThrowStrings { - public static class CollectionThrowStrings - { - public const string ArgumentOutOfRange_Index = - "Index was out of range. Must be non-negative and less than the size of the collection."; + public const string ArgumentOutOfRange_Index = + "Index was out of range. Must be non-negative and less than the size of the collection."; - public const string ArgumentOutOfRange_NeedNonNegNum = "Non-negative number required."; + public const string ArgumentOutOfRange_NeedNonNegNum = "Non-negative number required."; - public const string Argument_InvalidOffLen = - "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."; + public const string Argument_InvalidOffLen = + "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."; - public const string Argument_AddingDuplicate = "An item with the same value has already been added. Value: {0}"; + public const string Argument_AddingDuplicate = "An item with the same value has already been added. Value: {0}"; - public const string Arg_ArrayPlusOffTooSmall = - "Destination array is not long enough to copy all the items in the collection. Check array index and length."; + public const string Arg_ArrayPlusOffTooSmall = + "Destination array is not long enough to copy all the items in the collection. Check array index and length."; - public const string InvalidOperation_ConcurrentOperationsNotSupported = - "Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct."; + public const string InvalidOperation_ConcurrentOperationsNotSupported = + "Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct."; - public const string InvalidOperation_EnumFailedVersion = - "Collection was modified after the enumerator was instantiated."; + public const string InvalidOperation_EnumFailedVersion = + "Collection was modified after the enumerator was instantiated."; - public const string InvalidOperation_EmptyQueue = "Queue empty."; + public const string InvalidOperation_EmptyQueue = "Queue empty."; - public const string InvalidOperation_EnumNotStarted = "Enumeration has not started. Call MoveNext."; + public const string InvalidOperation_EnumNotStarted = "Enumeration has not started. Call MoveNext."; - public const string InvalidOperation_EnumEnded = "Enumeration already finished."; - } + public const string InvalidOperation_EnumEnded = "Enumeration already finished."; + + public const string Argument_ArrayTooLarge = + "The input array length must not exceed Int32.MaxValue / {0}. Otherwise BitArray.Length would exceed Int32.MaxValue."; + + public const string Arg_ArrayLengthsDiffer = "Array lengths must be the same."; + + public const string Arg_RankMultiDimNotSupported = + "Only single dimensional arrays are supported for the requested action."; + + public const string Arg_BitArrayTypeUnsupported = + "Only supported array types for CopyTo on BitArrays are Boolean[], Int32[] and Byte[]."; } diff --git a/Projects/Server/Serialization/BinaryFileReader.cs b/Projects/Server/Serialization/BinaryFileReader.cs index 81064faa3..e7ba33642 100644 --- a/Projects/Server/Serialization/BinaryFileReader.cs +++ b/Projects/Server/Serialization/BinaryFileReader.cs @@ -16,6 +16,7 @@ using System; using System.IO; using System.Runtime.CompilerServices; +using Server.Collections; namespace Server { @@ -78,6 +79,15 @@ namespace Server [MethodImpl(MethodImplOptions.AggressiveInlining)] public int Read(Span buffer) => _reader.Read(buffer); + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public BitArray ReadBitArray() + { + var length = ((IGenericReader)this).ReadEncodedInt(); + + // BinaryReader doesn't expose a Span slice of the buffer, so we use a custom ctor + return new BitArray(_reader, length); + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public long Seek(long offset, SeekOrigin origin) => _reader.BaseStream.Seek(offset, origin); diff --git a/Projects/Server/Serialization/BufferReader.cs b/Projects/Server/Serialization/BufferReader.cs index 309ac26f4..91641c343 100644 --- a/Projects/Server/Serialization/BufferReader.cs +++ b/Projects/Server/Serialization/BufferReader.cs @@ -19,6 +19,7 @@ using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using System.Text; +using Server.Collections; using Server.Text; namespace Server @@ -156,6 +157,19 @@ namespace Server return length; } + public BitArray ReadBitArray() + { + var length = ((IGenericReader)this).ReadEncodedInt(); + if (length > _buffer.Length - _position) + { + throw new OutOfMemoryException(); + } + + var bitArray = new BitArray(_buffer.AsSpan(_position, length)); + _position += length; + return bitArray; + } + public virtual long Seek(long offset, SeekOrigin origin) { Debug.Assert( diff --git a/Projects/Server/Serialization/BufferWriter.cs b/Projects/Server/Serialization/BufferWriter.cs index 208039916..167d24edb 100644 --- a/Projects/Server/Serialization/BufferWriter.cs +++ b/Projects/Server/Serialization/BufferWriter.cs @@ -18,6 +18,7 @@ using System.Diagnostics; using System.IO; using System.Runtime.CompilerServices; using System.Text; +using Server.Collections; using Server.Text; namespace Server @@ -134,6 +135,16 @@ namespace Server } } + public void Write(BitArray bitArray) + { + var byteLength = BitArray.GetByteArrayLengthFromBitLength(bitArray.Length); + FlushIfNeeded(byteLength + 4); + + ((IGenericWriter)this).WriteEncodedInt(byteLength); + bitArray.CopyTo(_buffer.AsSpan((int)Index, byteLength)); + Index += byteLength; + } + public virtual long Seek(long offset, SeekOrigin origin) { Debug.Assert( diff --git a/Projects/Server/Serialization/IGenericReader.cs b/Projects/Server/Serialization/IGenericReader.cs index 67e27764e..5abf069aa 100644 --- a/Projects/Server/Serialization/IGenericReader.cs +++ b/Projects/Server/Serialization/IGenericReader.cs @@ -16,6 +16,7 @@ using System; using System.IO; using System.Net; +using Server.Collections; namespace Server { @@ -116,6 +117,8 @@ namespace Server return new Guid(bytes); } + BitArray ReadBitArray(); + long Seek(long offset, SeekOrigin origin); } } diff --git a/Projects/Server/Serialization/IGenericWriter.cs b/Projects/Server/Serialization/IGenericWriter.cs index 95aa9d92f..8eeec249f 100644 --- a/Projects/Server/Serialization/IGenericWriter.cs +++ b/Projects/Server/Serialization/IGenericWriter.cs @@ -16,6 +16,7 @@ using System; using System.IO; using System.Net; +using Server.Collections; namespace Server { @@ -160,6 +161,8 @@ namespace Server Write(stack); } + void Write(BitArray bitArray); + long Seek(long offset, SeekOrigin origin); } } From f634ee27483ac52e2c864848f21ba96f759128ca Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 19 Dec 2021 19:58:59 -0800 Subject: [PATCH 11/14] fix: Changes spells so they register during configuration (#889) --- Projects/UOContent/Spells/Initializer.cs | 28 ++++++++++++------------ 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Projects/UOContent/Spells/Initializer.cs b/Projects/UOContent/Spells/Initializer.cs index 7fa5657d8..418e81da7 100644 --- a/Projects/UOContent/Spells/Initializer.cs +++ b/Projects/UOContent/Spells/Initializer.cs @@ -18,7 +18,7 @@ namespace Server.Spells { public static class Initializer { - public static void Initialize() + public static void Configure() { // First circle Register(00, typeof(ClumsySpell)); @@ -169,34 +169,34 @@ namespace Server.Spells Register(606, typeof(SummonFeySpell)); Register(607, typeof(SummonFiendSpell)); Register(608, typeof(ReaperFormSpell)); - // Register( 609, typeof( Spellweaving.WildfireSpell ) ); + // Register(609, typeof(WildfireSpell)); Register(610, typeof(EssenceOfWindSpell)); - // Register( 611, typeof( Spellweaving.DryadAllureSpell ) ); + // Register(611, typeof(DryadAllureSpell)); Register(612, typeof(EtherealVoyageSpell)); Register(613, typeof(WordOfDeathSpell)); Register(614, typeof(GiftOfLifeSpell)); - // Register( 615, typeof( Spellweaving.ArcaneEmpowermentSpell ) ); + // Register(615, typeof(ArcaneEmpowermentSpell)); } if (Core.SA) { // Mysticism spells - // Register( 677, typeof( Mysticism.NetherBoltSpell ) ); - // Register( 678, typeof( Mysticism.HealingStoneSpell ) ); - // Register( 679, typeof( Mysticism.PurgeMagicSpell ) ); - // Register( 680, typeof( Mysticism.EnchantSpell ) ); - // Register( 681, typeof( Mysticism.SleepSpell ) ); + // Register(677, typeof(NetherBoltSpell)); + // Register(678, typeof(HealingStoneSpell)); + // Register(679, typeof(PurgeMagicSpell)); + // Register(680, typeof(EnchantSpell)); + // Register(681, typeof(SleepSpell)); Register(682, typeof(EagleStrikeSpell)); Register(683, typeof(AnimatedWeaponSpell)); Register(684, typeof(StoneFormSpell)); - // Register( 685, typeof( Mysticism.SpellTriggerSpell ) ); - // Register( 686, typeof( Mysticism.MassSleepSpell ) ); - // Register( 687, typeof( Mysticism.CleansingWindsSpell ) ); - // Register( 688, typeof( Mysticism.BombardSpell ) ); + // Register(685, typeof(SpellTriggerSpell)); + // Register(686, typeof(MassSleepSpell)); + // Register(687, typeof(CleansingWindsSpell)); + // Register(688, typeof(BombardSpell)); Register(689, typeof(SpellPlagueSpell)); Register(690, typeof(HailStormSpell)); Register(691, typeof(NetherCycloneSpell)); - // Register( 692, typeof( Mysticism.RisingColossusSpell ) ); + // Register(692, typeof(RisingColossusSpell)); } } } From 171df322576329dc24788c314f8ec81dcd25436d Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 24 Dec 2021 15:26:12 -0800 Subject: [PATCH 12/14] fix: Fixes first/second scrolls crashing (#891) * Fixes first/second circle scrolls crashing * Consolidates some resistance logic * Removes unnecessary multiple lookups for items on layer --- Projects/UOContent/Spells/Base/MagerySpell.cs | 32 ++++++++----------- .../UOContent/Spells/Bushido/CounterAttack.cs | 7 +--- Projects/UOContent/Spells/Bushido/Evasion.cs | 21 ++++++------ .../Spells/Chivalry/ConsecrateWeapon.cs | 2 +- .../Spells/Chivalry/NobleSacrifice.cs | 2 +- .../UOContent/Spells/Fifth/DispelField.cs | 2 +- Projects/UOContent/Spells/Fourth/ArchCure.cs | 2 +- .../Spells/Necromancy/AnimateDeadSpell.cs | 2 +- .../Spells/Necromancy/BloodOathSpell.cs | 2 +- .../Spells/Necromancy/CurseWeapon.cs | 2 +- .../UOContent/Spells/Necromancy/EvilOmen.cs | 2 +- .../UOContent/Spells/Seventh/EnergyField.cs | 2 +- Projects/UOContent/Spells/Third/MagicLock.cs | 2 +- Projects/UOContent/Spells/Third/Teleport.cs | 4 +-- Projects/UOContent/Spells/Third/Unlock.cs | 2 +- .../UOContent/Spells/Third/WallOfStone.cs | 2 +- 16 files changed, 39 insertions(+), 49 deletions(-) diff --git a/Projects/UOContent/Spells/Base/MagerySpell.cs b/Projects/UOContent/Spells/Base/MagerySpell.cs index 68c261e8e..7905a7d65 100644 --- a/Projects/UOContent/Spells/Base/MagerySpell.cs +++ b/Projects/UOContent/Spells/Base/MagerySpell.cs @@ -6,9 +6,11 @@ namespace Server.Spells public abstract class MagerySpell : Spell { private static readonly int[] _manaTable = { 4, 6, 9, 11, 14, 20, 40, 50 }; + + // Starts at Circle -2 to account for scrolls private static readonly double[] _requiredSkill = Core.ML ? - new[] { 0.0, -4.0, 10.0, 24.0, 38.0, 52.0, 66.0, 80.0 } : - new[] { 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0 }; + new[] { -46.0, -32.0, 0.0, -4.0, 10.0, 24.0, 38.0, 52.0, 66.0, 80.0 } : + new[] { -50.0, -30.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0 }; public MagerySpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info) { @@ -23,13 +25,6 @@ namespace Server.Spells public override void GetCastSkills(out double min, out double max) { - var circle = (int)Circle; - - if (Scroll != null) - { - circle -= 2; - } - // Original RunUO algorithm for required skill // const double chanceOffset = 20.0 // const double chanceLength = 100.0 / 7.0 @@ -37,9 +32,9 @@ namespace Server.Spells // min = avg - chanceOffset; // max = avg + chanceOffset; - // Correct algorithm according to OSI. + // Correct algorithm according to OSI for UOR/UOML // TODO: Verify this algorithm on OSI for latest expansion. - min = _requiredSkill[circle]; + min = _requiredSkill[(int)(Scroll == null ? Circle + 2 : Circle)]; max = min + 40; } @@ -47,8 +42,9 @@ namespace Server.Spells public override double GetResistSkill(Mobile m) { - var maxSkill = (1 + (int)Circle) * 10; - maxSkill += (1 + (int)Circle / 6) * 25; + var circle = (int)Circle; + + var maxSkill = 1 + circle * 10 + (1 + circle / 6) * 25; if (m.Skills.MagicResist.Value < maxSkill) { @@ -60,9 +56,7 @@ namespace Server.Spells public virtual bool CheckResisted(Mobile target) { - var n = GetResistPercent(target); - - n /= 100.0; + var n = GetResistPercent(target) / 100.0; if (n <= 0.0) { @@ -74,8 +68,10 @@ namespace Server.Spells return true; } - var maxSkill = (1 + (int)Circle) * 10; - maxSkill += (1 + (int)Circle / 6) * 25; + // Even though this calculation matches AOS+, we don't combine with GetResistSkills because of an assumption + // about how it is used. + var circle = (int)Circle; + var maxSkill = (1 + circle) * 10 + (1 + circle / 6) * 25; if (target.Skills.MagicResist.Value < maxSkill) { diff --git a/Projects/UOContent/Spells/Bushido/CounterAttack.cs b/Projects/UOContent/Spells/Bushido/CounterAttack.cs index ea3c07e22..6dacc8e27 100644 --- a/Projects/UOContent/Spells/Bushido/CounterAttack.cs +++ b/Projects/UOContent/Spells/Bushido/CounterAttack.cs @@ -31,17 +31,12 @@ namespace Server.Spells.Bushido return false; } - if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield) - { - return true; - } - if (Caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon) { return true; } - if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseWeapon) + if (Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield or BaseWeapon) { return true; } diff --git a/Projects/UOContent/Spells/Bushido/Evasion.cs b/Projects/UOContent/Spells/Bushido/Evasion.cs index a5eab88e2..ec9a77b52 100644 --- a/Projects/UOContent/Spells/Bushido/Evasion.cs +++ b/Projects/UOContent/Spells/Bushido/Evasion.cs @@ -33,7 +33,7 @@ namespace Server.Spells.Bushido return false; } - if (!(caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) + if (caster.FindItemOnLayer(Layer.OneHanded) is not BaseWeapon weap) { weap = caster.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; } @@ -44,15 +44,14 @@ namespace Server.Spells.Bushido { if (messages) { - caster.SendLocalizedMessage( - 1076206 - ); // Your skill with your equipped weapon must be 50 or higher to use Evasion. + // Your skill with your equipped weapon must be 50 or higher to use Evasion. + caster.SendLocalizedMessage(1076206); } return false; } } - else if (!(caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) + else if (caster.FindItemOnLayer(Layer.TwoHanded) is not BaseShield) { if (messages) { @@ -77,7 +76,7 @@ namespace Server.Spells.Bushido public static bool CheckSpellEvasion(Mobile defender) { - if (!(defender.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) + if (defender.FindItemOnLayer(Layer.OneHanded) is not BaseWeapon weap) { weap = defender.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; } @@ -96,7 +95,7 @@ namespace Server.Spells.Bushido return false; } } - else if (!(defender.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) + else if (defender.FindItemOnLayer(Layer.TwoHanded) is not BaseShield) { return false; } @@ -162,8 +161,8 @@ namespace Server.Spells.Bushido seconds += (m.Skills.Bushido.Value - 60) / 20; } - if (m.Skills.Anatomy.Value >= 100.0 && m.Skills.Tactics.Value >= 100.0 && m.Skills.Bushido.Value > 100.0 - ) // Bushido being HIGHER than 100 for bonus is intended + // Bushido being HIGHER than 100 for bonus is intended + if (m.Skills.Anatomy.Value >= 100.0 && m.Skills.Tactics.Value >= 100.0 && m.Skills.Bushido.Value > 100.0) { seconds++; } @@ -194,8 +193,8 @@ namespace Server.Spells.Bushido bonus += (m.Skills.Bushido.Value - 60) * .004 + 0.16; } - if (m.Skills.Anatomy.Value >= 100 && m.Skills.Tactics.Value >= 100 && m.Skills.Bushido.Value > 100 - ) // Bushido being HIGHER than 100 for bonus is intended + // Bushido being HIGHER than 100 for bonus is intended + if (m.Skills.Anatomy.Value >= 100 && m.Skills.Tactics.Value >= 100 && m.Skills.Bushido.Value > 100) { bonus += 0.10; } diff --git a/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs b/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs index 01eea62a2..a204fe57c 100644 --- a/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs +++ b/Projects/UOContent/Spells/Chivalry/ConsecrateWeapon.cs @@ -29,7 +29,7 @@ namespace Server.Spells.Chivalry public override void OnCast() { - if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists) + if (Caster.Weapon is not (BaseWeapon weapon and not Fists)) { Caster.SendLocalizedMessage(501078); // You must be holding a weapon. } diff --git a/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs b/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs index 8009e46de..9e8e4e4c7 100644 --- a/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs +++ b/Projects/UOContent/Spells/Chivalry/NobleSacrifice.cs @@ -40,7 +40,7 @@ namespace Server.Spells.Chivalry continue; } - if (Caster != m && m.InLOS(Caster) && Caster.CanBeBeneficial(m, false, true) && !(m is Golem)) + if (Caster != m && m.InLOS(Caster) && Caster.CanBeBeneficial(m, false, true) && m is not Golem) { targets.Add(m); } diff --git a/Projects/UOContent/Spells/Fifth/DispelField.cs b/Projects/UOContent/Spells/Fifth/DispelField.cs index ac0bfe41e..2db3e4f5b 100644 --- a/Projects/UOContent/Spells/Fifth/DispelField.cs +++ b/Projects/UOContent/Spells/Fifth/DispelField.cs @@ -28,7 +28,7 @@ namespace Server.Spells.Fifth { Caster.SendLocalizedMessage(1005049); // That cannot be dispelled. } - else if (item is Moongate moongate && !moongate.Dispellable) + else if (item is Moongate { Dispellable: false }) { Caster.SendLocalizedMessage(1005047); // That magic is too chaotic } diff --git a/Projects/UOContent/Spells/Fourth/ArchCure.cs b/Projects/UOContent/Spells/Fourth/ArchCure.cs index 9cacd8790..841c03d6d 100644 --- a/Projects/UOContent/Spells/Fourth/ArchCure.cs +++ b/Projects/UOContent/Spells/Fourth/ArchCure.cs @@ -127,7 +127,7 @@ namespace Server.Spells.Fourth return false; } - if (feluccaRules && !(target is PlayerMobile)) + if (feluccaRules && target is not PlayerMobile) { return false; } diff --git a/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs b/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs index f67cdeb78..13172b7ce 100644 --- a/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/AnimateDeadSpell.cs @@ -142,7 +142,7 @@ namespace Server.Spells.Necromancy return; } - if (!(item is Corpse c)) + if (item is not Corpse c) { Caster.SendLocalizedMessage(1061084); // You cannot animate that. } diff --git a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs index 0d7969f7d..0b6b1aadf 100644 --- a/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs +++ b/Projects/UOContent/Spells/Necromancy/BloodOathSpell.cs @@ -34,7 +34,7 @@ namespace Server.Spells.Necromancy Caster.SendLocalizedMessage(1060508); // You can't curse that. } // only PlayerMobile and BaseCreature implement blood oath checking - else if (Caster == m || !(m is PlayerMobile || m is BaseCreature)) + else if (Caster == m || m is not (PlayerMobile or BaseCreature)) { Caster.SendLocalizedMessage(1060508); // You can't curse that. } diff --git a/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs b/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs index 96b5fd3ea..737645f75 100644 --- a/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs +++ b/Projects/UOContent/Spells/Necromancy/CurseWeapon.cs @@ -27,7 +27,7 @@ namespace Server.Spells.Necromancy public override void OnCast() { - if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists) + if (Caster.Weapon is not BaseWeapon weapon || weapon is Fists) { Caster.SendLocalizedMessage(501078); // You must be holding a weapon. } diff --git a/Projects/UOContent/Spells/Necromancy/EvilOmen.cs b/Projects/UOContent/Spells/Necromancy/EvilOmen.cs index ea3cd5335..c9fd172a7 100644 --- a/Projects/UOContent/Spells/Necromancy/EvilOmen.cs +++ b/Projects/UOContent/Spells/Necromancy/EvilOmen.cs @@ -30,7 +30,7 @@ namespace Server.Spells.Necromancy public void Target(Mobile m) { - if (!(m is BaseCreature || m is PlayerMobile)) + if (m is not (BaseCreature or PlayerMobile)) { Caster.SendLocalizedMessage(1060508); // You can't curse that. } diff --git a/Projects/UOContent/Spells/Seventh/EnergyField.cs b/Projects/UOContent/Spells/Seventh/EnergyField.cs index abb0895ef..bf5c5c019 100644 --- a/Projects/UOContent/Spells/Seventh/EnergyField.cs +++ b/Projects/UOContent/Spells/Seventh/EnergyField.cs @@ -140,7 +140,7 @@ namespace Server.Spells.Seventh public override bool OnMoveOver(Mobile m) { - if (!(m is PlayerMobile)) + if (m is not PlayerMobile) { return base.OnMoveOver(m); } diff --git a/Projects/UOContent/Spells/Third/MagicLock.cs b/Projects/UOContent/Spells/Third/MagicLock.cs index 76b0ef7a6..c9cfef434 100644 --- a/Projects/UOContent/Spells/Third/MagicLock.cs +++ b/Projects/UOContent/Spells/Third/MagicLock.cs @@ -24,7 +24,7 @@ namespace Server.Spells.Third public void Target(Item item) { - if (!(item is LockableContainer cont)) + if (item is not LockableContainer cont) { Caster.SendLocalizedMessage(501762); // Target must be an unlocked chest. } diff --git a/Projects/UOContent/Spells/Third/Teleport.cs b/Projects/UOContent/Spells/Third/Teleport.cs index 9e2b2236a..eda47e8fc 100644 --- a/Projects/UOContent/Spells/Third/Teleport.cs +++ b/Projects/UOContent/Spells/Third/Teleport.cs @@ -98,8 +98,8 @@ namespace Server.Spells.Third foreach (var item in eable) { - if (item is ParalyzeFieldSpell.InternalItem || item is PoisonFieldSpell.InternalItem || - item is FireFieldSpell.FireFieldItem) + if (item is ParalyzeFieldSpell.InternalItem or + PoisonFieldSpell.InternalItem or FireFieldSpell.FireFieldItem) { item.OnMoveOver(m); } diff --git a/Projects/UOContent/Spells/Third/Unlock.cs b/Projects/UOContent/Spells/Third/Unlock.cs index 715cf1e82..a29040d06 100644 --- a/Projects/UOContent/Spells/Third/Unlock.cs +++ b/Projects/UOContent/Spells/Third/Unlock.cs @@ -42,7 +42,7 @@ namespace Server.Spells.Third { Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 503101); // That did not need to be unlocked. } - else if (!(p is LockableContainer cont)) + else if (p is not LockableContainer cont) { Caster.SendLocalizedMessage(501666); // You can't unlock that! } diff --git a/Projects/UOContent/Spells/Third/WallOfStone.cs b/Projects/UOContent/Spells/Third/WallOfStone.cs index 0be6b4b9c..98d239a07 100644 --- a/Projects/UOContent/Spells/Third/WallOfStone.cs +++ b/Projects/UOContent/Spells/Third/WallOfStone.cs @@ -149,7 +149,7 @@ namespace Server.Spells.Third if (m is PlayerMobile) { var noto = Notoriety.Compute(m_Caster, m); - if (noto == Notoriety.Enemy || noto == Notoriety.Ally) + if (noto is Notoriety.Enemy or Notoriety.Ally) { return false; } From 63e1b02d93e7262f6b4274334c7765aef86896e3 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 24 Dec 2021 15:53:59 -0800 Subject: [PATCH 13/14] chore: Cleans up pattern checks. (#892) --- .../Packets/Outgoing/VendorBuyPackets.cs | 2 +- Projects/Server/Attributes.cs | 2 +- Projects/Server/Collections/PooledRefQueue.cs | 2 +- Projects/Server/ContextMenus/ContextMenu.cs | 2 +- Projects/Server/Items/Container.cs | 6 +- Projects/Server/Items/Item.cs | 2 +- .../Json/Converters/Rectangle3DConverter.cs | 4 +- Projects/Server/Maps/Map.cs | 6 +- Projects/Server/Mobiles/Mobile.cs | 4 +- Projects/Server/Network/NetState/NetState.cs | 8 +- .../Network/Packets/IncomingMessagePackets.cs | 6 +- Projects/Server/Skills.cs | 4 +- Projects/Server/Utilities/Utility.cs | 2 +- Projects/UOContent/Accounting/Account.cs | 2 +- .../UOContent/Accounting/AccountHandler.cs | 6 +- .../UOContent/Commands/BoundingBoxPicker.cs | 2 +- Projects/UOContent/Commands/ExportWSC.cs | 2 +- .../Commands/Generic/Commands/Commands.cs | 13 +-- .../Commands/Generic/Commands/DesignInsert.cs | 2 +- .../Compilers/ConditionalCompiler.cs | 2 +- .../ContainedCommandImplementor.cs | 2 +- .../Implementors/MultiCommandImplementor.cs | 6 +- .../Implementors/SerialCommandImplementor.cs | 4 +- .../Implementors/SingleCommandImplementor.cs | 6 +- Projects/UOContent/Commands/Handlers.cs | 6 +- Projects/UOContent/Commands/HelpInfo.cs | 2 +- .../UOContent/Commands/LocationCommand.cs | 4 +- Projects/UOContent/Commands/Logging.cs | 2 +- .../Commands/Object Creation/Decorate.cs | 2 +- .../Commands/Object Creation/DecorateMag.cs | 2 +- .../Commands/Object Creation/GenTeleporter.cs | 2 +- Projects/UOContent/Commands/Properties.cs | 2 +- Projects/UOContent/Commands/Statics.cs | 6 +- Projects/UOContent/Commands/Wipe.cs | 2 +- .../Engines/Bulk Orders/Books/BOBGump.cs | 2 +- .../Engines/Bulk Orders/Books/BODBuyGump.cs | 2 +- .../UOContent/Engines/Bulk Orders/Rewards.cs | 6 +- .../UOContent/Engines/Bulk Orders/SmallBOD.cs | 2 +- .../Engines/ConPVP/AcceptDuelGump.cs | 2 +- .../UOContent/Engines/ConPVP/DuelContext.cs | 22 ++-- .../Engines/ConPVP/Games/BombingRun.cs | 4 +- .../UOContent/Engines/ConPVP/Games/CTF.cs | 2 +- .../Engines/ConPVP/Games/DoubleDom.cs | 2 +- .../Engines/ConPVP/Games/KingOfTheHill.cs | 2 +- .../Engines/ConPVP/Gumps/AcceptTeamGump.cs | 2 +- .../Engines/ConPVP/Gumps/ConfirmSignupGump.cs | 4 +- .../Engines/ConPVP/Gumps/ParticipantGump.cs | 4 +- .../Engines/ConPVP/Gumps/ReadyUpGump.cs | 2 +- .../ConPVP/Gumps/TournamentBracketGump.cs | 20 ++-- Projects/UOContent/Engines/ConPVP/Ladder.cs | 2 +- .../Engines/ConPVP/TournamentPyramid.cs | 2 +- .../UOContent/Engines/Craft/Core/CraftItem.cs | 6 +- .../UOContent/Engines/Craft/Core/Enhance.cs | 2 +- .../UOContent/Engines/Craft/Core/Repair.cs | 62 ++-------- .../UOContent/Engines/Craft/DefCarpentry.cs | 2 +- .../UOContent/Engines/Doom/GauntletSpawner.cs | 2 +- .../Doom/LeverPuzzle/LeverPuzzleRegions.cs | 2 +- .../UOContent/Engines/Ethics/Core/Ethic.cs | 2 +- .../UOContent/Engines/Ethics/Evil/Ethic.cs | 2 +- .../Engines/Ethics/Evil/Powers/Blight.cs | 2 +- .../Engines/Ethics/Evil/Powers/UnholyItem.cs | 4 +- .../UOContent/Engines/Ethics/Hero/Ethic.cs | 2 +- .../Engines/Ethics/Hero/Powers/Bless.cs | 2 +- .../Engines/Ethics/Hero/Powers/HolyItem.cs | 4 +- .../Engines/Factions/Core/Faction.cs | 8 +- .../Engines/Factions/Core/FactionItem.cs | 2 +- .../Factions/Gumps/LeaveFactionGump.cs | 2 +- .../Items/Power Faction Items/StormsEye.cs | 2 +- .../Factions/Mobiles/Guards/GuardAI.cs | 2 +- .../Engines/Harvest/Core/HarvestTarget.cs | 5 +- Projects/UOContent/Engines/Harvest/Fishing.cs | 6 +- .../Engines/Harvest/Lumberjacking.cs | 2 +- Projects/UOContent/Engines/Help/PageQueue.cs | 2 +- Projects/UOContent/Engines/Help/SpeechLog.cs | 2 +- .../Engines/ML Quests/Gumps/QuestOfferGump.cs | 2 +- .../Engines/ML Quests/Gumps/RaceChangeGump.cs | 4 +- .../ML Quests/Items/PrismaticCrystal.cs | 2 +- .../Engines/ML Quests/Items/Teleporters.cs | 2 +- .../Engines/ML Quests/MLQuestSystem.cs | 8 +- .../ML Quests/Objectives/CollectObjective.cs | 2 +- .../ML Quests/Objectives/DeliverObjective.cs | 2 +- .../Engines/Pathing/PathAlgorithm.cs | 2 +- .../UOContent/Engines/Plants/MainPlantGump.cs | 4 +- .../Engines/Plants/MiscItems/GreenThorns.cs | 2 +- .../Engines/Plants/MiscItems/RedLeaves.cs | 4 +- Projects/UOContent/Engines/Plants/PlantHue.cs | 2 +- .../UOContent/Engines/Plants/PlantItem.cs | 10 +- .../UOContent/Engines/Plants/PlantSystem.cs | 2 +- .../Engines/Plants/PollinateTarget.cs | 3 +- .../Engines/Plants/ReproductionGump.cs | 3 +- Projects/UOContent/Engines/Plants/Seed.cs | 2 +- .../Quests/Collector/Items/EnchantedPaints.cs | 4 +- .../Quests/Collector/Items/Obsidian.cs | 2 +- .../Quests/Collector/Mobiles/Impresario.cs | 4 +- .../Engines/Quests/Core/QuestSystem.cs | 2 +- .../Quests/Dark Tides/DarkTidesQuest.cs | 2 +- .../Dark Tides/Items/CrystalCaveBarrier.cs | 2 +- .../Quests/Dark Tides/Items/KronusScroll.cs | 4 +- .../Dark Tides/Items/ScrollOfAbraxus.cs | 2 +- .../Quests/Dark Tides/Mobiles/Mardoth.cs | 2 +- .../Engines/Quests/Dark Tides/Objectives.cs | 2 +- .../EminosUndertakingQuest.cs | 6 +- .../Emino's Undertaking/Items/EminosKatana.cs | 2 +- .../Emino's Undertaking/Items/NoteForZoel.cs | 2 +- .../Haochi's Trials/HaochisTrialsQuest.cs | 4 +- .../Haochi's Trials/Items/HaochisKatana.cs | 2 +- .../Haochi's Trials/Items/HonorCandle.cs | 2 +- .../Quests/Solen Matriarch/Objectives.cs | 8 +- .../Uzeraan Turmoil/Items/QuestDaemonBlood.cs | 2 +- .../Uzeraan Turmoil/Items/QuestDaemonBone.cs | 2 +- .../Uzeraan Turmoil/Items/QuestFertileDirt.cs | 2 +- .../Quests/Uzeraan Turmoil/Objectives.cs | 4 +- .../Uzeraan Turmoil/UzeraanTurmoilQuest.cs | 10 +- .../BasePigmentsOfTokuno.cs | 2 +- .../Treasures of Tokuno/GreaterArtifacts.cs | 2 +- .../Treasures of Tokuno/TreasuresOfTokuno.cs | 8 +- .../Character Statue Maker/CharacterStatue.cs | 2 +- .../Veteran Rewards/RewardDemolitionGump.cs | 2 +- .../Engines/Veteran Rewards/RewardSystem.cs | 13 +-- .../UOContent/Engines/Virtues/Sacrifice.cs | 3 +- Projects/UOContent/Gumps/AdminGump.cs | 62 +++++----- Projects/UOContent/Gumps/CommentsGump.cs | 2 +- .../Guilds/New Guild System/BaseGuildGump.cs | 8 +- .../New Guild System/BaseGuildListGump.cs | 2 +- .../New Guild System/Create Guild Gump.cs | 2 +- .../Guilds/New Guild System/DiplomacyGump.cs | 13 +-- .../New Guild System/GuildMemberInfoGump.cs | 6 +- .../New Guild System/GuildRosterGump.cs | 2 +- .../Guilds/New Guild System/OtherGuildInfo.cs | 2 +- Projects/UOContent/Gumps/PlayerVendorGumps.cs | 2 +- Projects/UOContent/Gumps/Props/PropsGump.cs | 2 +- Projects/UOContent/Gumps/ReportMurderer.cs | 2 +- Projects/UOContent/Gumps/VendorRentalGumps.cs | 12 +- Projects/UOContent/Gumps/ViewHousesGump.cs | 2 +- .../Halloween/2006/Engines/TrickOrTreat.cs | 2 +- .../Halloween/2006/Items/HalloweenPumpkin.cs | 2 +- Projects/UOContent/Items/Addons/DartBoard.cs | 6 +- Projects/UOContent/Items/Armor/BaseArmor.cs | 4 +- Projects/UOContent/Items/Books/BookPackets.cs | 6 +- .../Items/Construction/Doors/BaseDoor.cs | 10 +- .../Items/Construction/Misc/Vines.cs | 2 +- .../UOContent/Items/Containers/Container.cs | 2 +- .../Items/Containers/FillableContainers.cs | 4 +- .../Items/Containers/FurnitureContainer.cs | 4 +- .../UOContent/Items/Containers/SalvageBag.cs | 7 +- .../Items/Deeds/DragonBardingDeed.cs | 2 +- .../Items/Deeds/HairRestylingDeed.cs | 2 +- .../UOContent/Items/Deeds/HolidayTreeDeed.cs | 2 +- .../Items/Deeds/VendorRentalContract.cs | 2 +- Projects/UOContent/Items/Food/Beverage.cs | 12 +- Projects/UOContent/Items/Food/Cooking.cs | 6 +- Projects/UOContent/Items/Games/BaseBoard.cs | 2 +- .../Games/Mahjong/MahjongDealerIndicator.cs | 2 +- .../Items/Games/Mahjong/MahjongTile.cs | 2 +- Projects/UOContent/Items/Guilds/Guildstone.cs | 2 +- Projects/UOContent/Items/Jewels/BaseJewel.cs | 2 +- .../Items/Lights/BaseEquippableLight.cs | 2 +- .../UOContent/Items/Lights/CandleSkull.cs | 4 +- Projects/UOContent/Items/Lights/Lantern.cs | 2 +- .../UOContent/Items/Maps/MapItemPackets.cs | 2 +- Projects/UOContent/Items/Misc/Bola.cs | 4 +- .../Items/Misc/CommunicationCrystals.cs | 2 +- .../UOContent/Items/Misc/Corpses/Corpse.cs | 7 +- Projects/UOContent/Items/Misc/Guillotine.cs | 10 +- Projects/UOContent/Items/Misc/KeyRing.cs | 4 +- Projects/UOContent/Items/Misc/PoolOfAcid.cs | 2 +- .../UOContent/Items/Quivers/BaseQuiver.cs | 2 +- .../UOContent/Items/Shields/ChaosShield.cs | 2 +- .../UOContent/Items/Shields/OrderShield.cs | 2 +- .../Items/Skill Items/Camping/Bedroll.cs | 2 +- .../Fishing/Misc/SpecialFishingNet.cs | 6 +- .../Harvest Tools/BaseHarvestTool.cs | 2 +- .../Skill Items/Magical/Misc/PotionKeg.cs | 2 +- .../Skill Items/Magical/Potions/BasePotion.cs | 2 +- .../BaseConfusionBlastPotion.cs | 2 +- .../Items/Skill Items/Magical/Runebook.cs | 2 +- .../Items/Skill Items/Magical/Spellbook.cs | 2 +- .../Items/Skill Items/Misc/Bandage.cs | 2 +- .../Musical Instruments/BaseInstrument.cs | 4 +- .../Tailor Items/Dyetubs/DyeTub.cs | 6 +- .../Skill Items/Tailor Items/Misc/Scissors.cs | 4 +- .../Items/Skill Items/Thief/LockPick.cs | 2 +- .../Items/Skill Items/Tinkering/Spyglass.cs | 4 +- .../Items/Skill Items/Tools/BaseTool.cs | 4 +- .../Items/Skill Items/Tools/RunicSewingKit.cs | 2 +- .../Dawn's Music Box/DawnsMusicBox.cs | 2 +- .../AwesomeDisturbingPortrait.cs | 2 +- .../CreepyPortrait.cs | 4 +- .../HauntedMirror.cs | 4 +- .../Special/Heritage Items/Guillotine.cs | 2 +- .../Special/Heritage Items/HouseLadder.cs | 2 +- .../UOContent/Items/Special/Holiday/Wreath.cs | 2 +- .../Special/House Raffle/HouseRaffleStone.cs | 4 +- .../Mutation Core/PlagueBeastBackpack.cs | 4 +- .../Items/Special/Solen Items/BagOfSending.cs | 2 +- .../Special/Solen Items/BraceletOfBinding.cs | 2 +- Projects/UOContent/Items/Special/SoulStone.cs | 4 +- .../Special/Special Scrolls/PowerScroll.cs | 6 +- .../Special/Special Scrolls/SpecialScroll.cs | 2 +- .../Veteran Rewards/AnkhOfSacrifice.cs | 2 +- .../Items/Special/Veteran Rewards/Banner.cs | 2 +- .../Items/Special/Veteran Rewards/Cannon.cs | 2 +- .../Veteran Rewards/CommodityDeedBox.cs | 2 +- .../Veteran Rewards/DecorativeShield.cs | 5 +- .../Veteran Rewards/HangingSkeleton.cs | 3 +- .../Special/Veteran Rewards/PottedCactus.cs | 2 +- .../Special/Veteran Rewards/WallBanner.cs | 2 +- Projects/UOContent/Items/Suits/BaseSuit.cs | 2 +- .../UOContent/Items/Talismans/BaseTalisman.cs | 4 +- Projects/UOContent/Items/Wands/BaseWand.cs | 2 +- .../Items/Weapons/Abilities/Dismount.cs | 2 +- .../UOContent/Items/Weapons/Axes/BaseAxe.cs | 2 +- Projects/UOContent/Items/Weapons/Fists.cs | 2 +- .../Items/Weapons/Ranged/BaseRanged.cs | 2 +- .../UOContent/Items/Weapons/Ranged/JukaBow.cs | 2 +- Projects/UOContent/Misc/AccountPrompt.cs | 2 +- Projects/UOContent/Misc/Geometry.cs | 4 +- .../Misc/Gifts/Winter2004/Mistletoe.cs | 2 +- Projects/UOContent/Misc/Guild.cs | 2 +- Projects/UOContent/Misc/LootPack.cs | 2 +- Projects/UOContent/Misc/Notoriety.cs | 14 +-- Projects/UOContent/Misc/PacketThrottles.cs | 4 +- Projects/UOContent/Misc/Profile.cs | 2 +- Projects/UOContent/Misc/ResourceInfo.cs | 6 +- Projects/UOContent/Mobiles/AI/BaseAI.cs | 29 ++--- Projects/UOContent/Mobiles/AI/MageAI.cs | 4 +- .../Mobiles/Animals/Mounts/Ethereals.cs | 2 +- Projects/UOContent/Mobiles/BaseCreature.cs | 5 +- .../UOContent/Mobiles/Healers/EvilHealer.cs | 5 +- .../Mobiles/Healers/EvilWanderingHealer.cs | 6 +- .../Mobiles/Healers/FortuneTeller.cs | 5 +- Projects/UOContent/Mobiles/Healers/Healer.cs | 5 +- .../Mobiles/Healers/WanderingHealer.cs | 6 +- .../Monsters/Humanoid/Magic/SavageShaman.cs | 9 +- .../Mobiles/Monsters/Humanoid/Melee/Savage.cs | 3 +- .../Monsters/Humanoid/Melee/SavageRider.cs | 3 +- .../Monsters/LBR/Jukas/ChaosDragoon.cs | 3 +- .../Monsters/LBR/Jukas/ChaosDragoonElite.cs | 3 +- .../Mobiles/Monsters/LBR/Meers/MeerCaptain.cs | 2 +- .../Monsters/Misc/Melee/BladeSpirits.cs | 2 +- .../Monsters/Misc/Melee/EnergyVortex.cs | 2 +- .../Monsters/Misc/Melee/PlagueBeastLord.cs | 2 +- .../UOContent/Mobiles/Monsters/SE/Yamandon.cs | 2 +- Projects/UOContent/Mobiles/PlayerMobile.cs | 23 ++-- .../UOContent/Mobiles/Special/Barracoon.cs | 2 +- .../UOContent/Mobiles/Special/BaseChampion.cs | 4 +- .../Mobiles/Special/BaseShieldGuard.cs | 2 +- .../Mobiles/Special/HarrowerTentacles.cs | 2 +- Projects/UOContent/Mobiles/Special/Paragon.cs | 3 +- Projects/UOContent/Mobiles/Special/Rikktor.cs | 2 +- Projects/UOContent/Mobiles/Special/Semidar.cs | 2 +- Projects/UOContent/Mobiles/Special/Serado.cs | 2 +- .../Mobiles/Townfolk/BaseEscortable.cs | 2 +- .../UOContent/Mobiles/Vendors/BaseVendor.cs | 2 +- .../Mobiles/Vendors/NPC/AnimalTrainer.cs | 2 +- .../Mobiles/Vendors/NPC/Blacksmith.cs | 2 +- .../UOContent/Mobiles/Vendors/NPC/Tailor.cs | 2 +- .../Mobiles/Vendors/NPC/Weaponsmith.cs | 2 +- .../UOContent/Mobiles/Vendors/NPC/Weaver.cs | 2 +- .../Mobiles/Vendors/PlayerBarkeeper.cs | 5 +- .../UOContent/Mobiles/Vendors/PlayerVendor.cs | 8 +- Projects/UOContent/Multis/Boats/BaseBoat.cs | 2 +- Projects/UOContent/Multis/Boats/Plank.cs | 2 +- Projects/UOContent/Multis/Houses/BaseHouse.cs | 36 +++--- .../Multis/Houses/HouseFoundation.cs | 12 +- .../UOContent/Multis/Houses/HousePlacement.cs | 2 +- .../UOContent/Multis/Houses/MovingCrate.cs | 2 +- Projects/UOContent/Regions/GuardedRegion.cs | 6 +- Projects/UOContent/Skills/Inscribe.cs | 4 +- Projects/UOContent/Skills/Peacemaking.cs | 2 +- Projects/UOContent/Skills/Poisoning.cs | 4 +- Projects/UOContent/Skills/Provocation.cs | 2 +- Projects/UOContent/Skills/Snooping.cs | 109 +++++++++--------- Projects/UOContent/Skills/SpiritSpeak.cs | 2 +- .../Special Systems/Engines/GiftGiving.cs | 2 +- Projects/UOContent/Spells/Base/SpellHelper.cs | 4 +- .../UOContent/Spells/Ninjitsu/FocusAttack.cs | 4 +- .../UOContent/Spells/Seventh/GateTravel.cs | 2 +- .../Spells/Spellweaving/ArcaneCircle.cs | 4 +- .../Spells/Spellweaving/ArcanistSpell.cs | 2 +- .../Spells/Spellweaving/ImmolatingWeapon.cs | 4 +- .../UOContent/Targets/BladedItemTarget.cs | 2 +- Projects/UOContent/Targets/PickMoveTarget.cs | 2 +- 283 files changed, 587 insertions(+), 702 deletions(-) diff --git a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/VendorBuyPackets.cs b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/VendorBuyPackets.cs index 0573d3263..d7414ea4c 100644 --- a/Projects/Server.Tests/Tests/Network/Packets/Outgoing/VendorBuyPackets.cs +++ b/Projects/Server.Tests/Tests/Network/Packets/Outgoing/VendorBuyPackets.cs @@ -50,7 +50,7 @@ namespace Server.Network { EnsureCapacity(256); - Stream.Write(!(vendor.FindItemOnLayer(Layer.ShopBuy) is Container buyPack) ? Serial.MinusOne : buyPack.Serial); + Stream.Write(vendor.FindItemOnLayer(Layer.ShopBuy) is not Container buyPack ? Serial.MinusOne : buyPack.Serial); Stream.Write((byte)list.Count); diff --git a/Projects/Server/Attributes.cs b/Projects/Server/Attributes.cs index e81a91bed..000e50bd7 100644 --- a/Projects/Server/Attributes.cs +++ b/Projects/Server/Attributes.cs @@ -71,7 +71,7 @@ namespace Server return 50; } - if (!(objs[0] is CallPriorityAttribute attr)) + if (objs[0] is not CallPriorityAttribute attr) { return 50; } diff --git a/Projects/Server/Collections/PooledRefQueue.cs b/Projects/Server/Collections/PooledRefQueue.cs index b3a1b3937..577e7f6f4 100644 --- a/Projects/Server/Collections/PooledRefQueue.cs +++ b/Projects/Server/Collections/PooledRefQueue.cs @@ -451,7 +451,7 @@ namespace Server.Collections private void ThrowEnumerationNotStartedOrEnded() { - Debug.Assert(_index == -1 || _index == -2); + Debug.Assert(_index is -1 or -2); throw new InvalidOperationException(_index == -1 ? CollectionThrowStrings.InvalidOperation_EnumNotStarted : CollectionThrowStrings.InvalidOperation_EnumEnded); } diff --git a/Projects/Server/ContextMenus/ContextMenu.cs b/Projects/Server/ContextMenus/ContextMenu.cs index a58a4d0a5..c6493334d 100644 --- a/Projects/Server/ContextMenus/ContextMenu.cs +++ b/Projects/Server/ContextMenus/ContextMenu.cs @@ -70,7 +70,7 @@ namespace Server.ContextMenus for (var i = 0; i < Entries.Length; ++i) { var number = Entries[i].Number; - if (number < 3000000 || number > 3032767) + if (number is < 3000000 or > 3032767) { return true; } diff --git a/Projects/Server/Items/Container.cs b/Projects/Server/Items/Container.cs index 43a2ba939..1b8375553 100644 --- a/Projects/Server/Items/Container.cs +++ b/Projects/Server/Items/Container.cs @@ -231,7 +231,7 @@ namespace Server.Items return container.CheckHold(m, item, message, checkItems, plusItems, plusWeight); } - if (!(parent is Item parentItem)) + if (parent is not Item parentItem) { break; } @@ -504,7 +504,7 @@ namespace Server.Items { var item = list[i]; - if (!(item is Container) && CheckHold(from, dropped, false, false) && + if (item is not Container && CheckHold(from, dropped, false, false) && item.StackWith(from, dropped, playSound)) { return true; @@ -540,7 +540,7 @@ namespace Server.Items { var item = list[j]; - if (!(item is Container) && CheckHold(from, dropped, false, false, 0, extraWeight) && + if (item is not Container && CheckHold(from, dropped, false, false, 0, extraWeight) && item.CanStackWith(dropped)) { stackItems.Add(new ItemStackEntry(item, dropped)); diff --git a/Projects/Server/Items/Item.cs b/Projects/Server/Items/Item.cs index 0e49d5568..8531c5a86 100644 --- a/Projects/Server/Items/Item.cs +++ b/Projects/Server/Items/Item.cs @@ -443,7 +443,7 @@ namespace Server var weight = TileData.ItemTable[m_ItemID].Weight; - if (weight == 255 || weight == 0) + if (weight is 255 or 0) { weight = 1; } diff --git a/Projects/Server/Json/Converters/Rectangle3DConverter.cs b/Projects/Server/Json/Converters/Rectangle3DConverter.cs index 1401ad874..f957337e5 100644 --- a/Projects/Server/Json/Converters/Rectangle3DConverter.cs +++ b/Projects/Server/Json/Converters/Rectangle3DConverter.cs @@ -78,7 +78,7 @@ namespace Server.Json reader.Read(); - if (key == "start" || key == "end") + if (key is "start" or "end") { if (objType > -1 && objType != 2) { @@ -140,7 +140,7 @@ namespace Server.Json objType = 1; data[i - 10] = reader.GetInt32(); - if (i == 12 || i == 15) + if (i is 12 or 15) { hasZ = true; } diff --git a/Projects/Server/Maps/Map.cs b/Projects/Server/Maps/Map.cs index 8dfe26e66..5593ee918 100644 --- a/Projects/Server/Maps/Map.cs +++ b/Projects/Server/Maps/Map.cs @@ -520,7 +520,7 @@ namespace Server var eable = map.GetItemsInRange(new Point3D(x, y, 0), 0); pool.AddRange( - eable.Where(item => item.ItemID <= TileData.MaxItemValue && !(item is BaseMulti)) + eable.Where(item => item.ItemID <= TileData.MaxItemValue && item is not BaseMulti) .OrderBy(item => item.Z) .Take(pool.Capacity) ); @@ -715,7 +715,7 @@ namespace Server { var item = sector.Items[i]; - if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(p.X, p.Y) && + if (item is not BaseMulti && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(p.X, p.Y) && !item.Movable) { var id = item.ItemData; @@ -1145,7 +1145,7 @@ namespace Server { var item = items[i]; - if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y)) + if (item is not BaseMulti && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y)) { var id = item.ItemData; surface = id.Surface; diff --git a/Projects/Server/Mobiles/Mobile.cs b/Projects/Server/Mobiles/Mobile.cs index 5e259a849..0e1f21fd4 100644 --- a/Projects/Server/Mobiles/Mobile.cs +++ b/Projects/Server/Mobiles/Mobile.cs @@ -1888,7 +1888,7 @@ namespace Server item ??= FindItemOnLayer(Layer.Mount); - if (!(item is IMountItem mountItem)) + if (item is not IMountItem mountItem) { return null; } @@ -8397,7 +8397,7 @@ namespace Server var n = Notoriety.Compute(this, target); - return n == Notoriety.Criminal || n == Notoriety.Murderer; + return n is Notoriety.Criminal or Notoriety.Murderer; } /// diff --git a/Projects/Server/Network/NetState/NetState.cs b/Projects/Server/Network/NetState/NetState.cs index 46a9622aa..b1916bf7b 100755 --- a/Projects/Server/Network/NetState/NetState.cs +++ b/Projects/Server/Network/NetState/NetState.cs @@ -223,7 +223,7 @@ namespace Server.Network private void SetPacketTime(int packetID) { - if (packetID < 0 || packetID >= 0x100) + if (packetID is < 0 or >= 0x100) { return; } @@ -233,7 +233,7 @@ namespace Server.Network public long GetPacketDelay(int packetID) { - if (packetID < 0 || packetID >= 0x100) + if (packetID is < 0 or >= 0x100) { return 0; } @@ -243,7 +243,7 @@ namespace Server.Network private void UpdatePacketCount(int packetID) { - if (packetID < 0 || packetID >= 0x100) + if (packetID is < 0 or >= 0x100) { return; } @@ -728,7 +728,7 @@ namespace Server.Network { reader.Advance((uint)packetLength); } - else if (_parserState == ParserState.AwaitingPartialPacket || _parserState == ParserState.Throttled) + else if (_parserState is ParserState.AwaitingPartialPacket or ParserState.Throttled) { break; } diff --git a/Projects/Server/Network/Packets/IncomingMessagePackets.cs b/Projects/Server/Network/Packets/IncomingMessagePackets.cs index 249bf4ea5..a40355498 100644 --- a/Projects/Server/Network/Packets/IncomingMessagePackets.cs +++ b/Projects/Server/Network/Packets/IncomingMessagePackets.cs @@ -60,7 +60,7 @@ namespace Server.Network reader.ReadInt16(); // font var text = reader.ReadAsciiSafe().Trim(); - if (text.Length <= 0 || text.Length > 128) + if (text.Length is <= 0 or > 128) { return; } @@ -97,7 +97,7 @@ namespace Server.Network var count = (value & 0xFFF0) >> 4; var hold = value & 0xF; - if (count < 0 || count > 50) + if (count is < 0 or > 50) { return; } @@ -141,7 +141,7 @@ namespace Server.Network text = text.Trim(); - if (text.Length <= 0 || text.Length > 128) + if (text.Length is <= 0 or > 128) { return; } diff --git a/Projects/Server/Skills.cs b/Projects/Server/Skills.cs index 077205507..75bfaf0c9 100644 --- a/Projects/Server/Skills.cs +++ b/Projects/Server/Skills.cs @@ -135,7 +135,7 @@ namespace Server } } - if (Lock < SkillLock.Up || Lock > SkillLock.Locked) + if (Lock is < SkillLock.Up or > SkillLock.Locked) { Console.WriteLine("Bad skill lock -> {0}.{1}", owner.Owner, Lock); Lock = SkillLock.Up; @@ -323,7 +323,7 @@ namespace Server public void SetLockNoRelay(SkillLock skillLock) { - if (skillLock < SkillLock.Up || skillLock > SkillLock.Locked) + if (skillLock is < SkillLock.Up or > SkillLock.Locked) { return; } diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index d3a780a4f..faba17ece 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -343,7 +343,7 @@ namespace Server if (endOfSection || i + 1 == end) { - if (number < 0 || number > 255) + if (number is < 0 or > 255) { valid = false; return false; diff --git a/Projects/UOContent/Accounting/Account.cs b/Projects/UOContent/Accounting/Account.cs index 43a1f8fb8..81538bf8b 100644 --- a/Projects/UOContent/Accounting/Account.cs +++ b/Projects/UOContent/Accounting/Account.cs @@ -758,7 +758,7 @@ namespace Server.Accounting private static void EventSink_Connected(Mobile m) { - if (!(m.Account is Account acc)) + if (m.Account is not Account acc) { return; } diff --git a/Projects/UOContent/Accounting/AccountHandler.cs b/Projects/UOContent/Accounting/AccountHandler.cs index a115d993a..55c6a7598 100644 --- a/Projects/UOContent/Accounting/AccountHandler.cs +++ b/Projects/UOContent/Accounting/AccountHandler.cs @@ -110,7 +110,7 @@ namespace Server.Misc { var from = e.Mobile; - if (!(from.Account is Account acct)) + if (@from.Account is not Account acct) { return; } @@ -217,7 +217,7 @@ namespace Server.Misc private static void EventSink_DeleteRequest(NetState state, int index) { - if (!(state.Account is Account acct)) + if (state.Account is not Account acct) { state.Disconnect("Attempted to delete a character but the account could not be found."); return; @@ -349,7 +349,7 @@ namespace Server.Misc e.Accepted = false; - if (!(Accounts.GetAccount(un) is Account acct)) + if (Accounts.GetAccount(un) is not Account acct) { // To prevent someone from making an account of just '' or a bunch of meaningless spaces if (AutoAccountCreation && un.Trim().Length > 0) diff --git a/Projects/UOContent/Commands/BoundingBoxPicker.cs b/Projects/UOContent/Commands/BoundingBoxPicker.cs index 40566bb6e..fa6c1028b 100644 --- a/Projects/UOContent/Commands/BoundingBoxPicker.cs +++ b/Projects/UOContent/Commands/BoundingBoxPicker.cs @@ -37,7 +37,7 @@ namespace Server protected override void OnTarget(Mobile from, object targeted) { - if (!(targeted is IPoint3D p)) + if (targeted is not IPoint3D p) { return; } diff --git a/Projects/UOContent/Commands/ExportWSC.cs b/Projects/UOContent/Commands/ExportWSC.cs index 2ab02bbe8..f032e80fd 100644 --- a/Projects/UOContent/Commands/ExportWSC.cs +++ b/Projects/UOContent/Commands/ExportWSC.cs @@ -24,7 +24,7 @@ namespace Server.Commands foreach (var item in World.Items.Values) { - if ((item is Static || item is BaseFloor || item is BaseWall) + if (item is Static or BaseFloor or BaseWall && item.RootParent == null) { w.WriteLine("SECTION WORLDITEM {0}", count); diff --git a/Projects/UOContent/Commands/Generic/Commands/Commands.cs b/Projects/UOContent/Commands/Generic/Commands/Commands.cs index 752c2e116..944b267b1 100644 --- a/Projects/UOContent/Commands/Generic/Commands/Commands.cs +++ b/Projects/UOContent/Commands/Generic/Commands/Commands.cs @@ -347,9 +347,7 @@ namespace Server.Commands.Generic { var result = Properties.IncreaseValue(e.Mobile, obj, e.Arguments); - if (result == "The property has been increased." || result == "The properties have been increased." || - result == "The property has been decreased." || result == "The properties have been decreased." || - result == "The properties have been changed.") + if (result is "The property has been increased." or "The properties have been increased." or "The property has been decreased." or "The properties have been decreased." or "The properties have been changed.") { AddResponse(result); } @@ -556,7 +554,7 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { - if (!(obj is IPoint3D p)) + if (obj is not IPoint3D p) { return; } @@ -588,7 +586,7 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { - if (!(obj is IPoint3D p)) + if (obj is not IPoint3D p) { return; } @@ -787,8 +785,7 @@ namespace Server.Commands.Generic { var result = Properties.GetValue(e.Mobile, obj, e.GetString(i)); - if (result == "Property not found." || result == "Property is write only." || - result.StartsWithOrdinal("Getting this property")) + if (result is "Property not found." or "Property is write only." || result.StartsWithOrdinal("Getting this property")) { LogFailure(result); } @@ -1285,7 +1282,7 @@ namespace Server.Commands.Generic public override void Execute(CommandEventArgs e, object obj) { - if (!(obj is Item item)) + if (obj is not Item item) { return; } diff --git a/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs b/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs index 7b31e855f..0a048ef51 100644 --- a/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs +++ b/Projects/UOContent/Commands/Generic/Commands/DesignInsert.cs @@ -35,7 +35,7 @@ namespace Server.Commands.Generic { house = null; - if (item == null || item is BaseMulti || item is HouseSign || staticsOnly && !(item is Static)) + if (item is null or BaseMulti or HouseSign || staticsOnly && item is not Static) { return DesignInsertResult.InvalidItem; } diff --git a/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs b/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs index 4343d359b..58ea93f35 100644 --- a/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs +++ b/Projects/UOContent/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs @@ -325,7 +325,7 @@ namespace Server.Commands.Generic throw new InvalidOperationException("Invalid string comparison operator."); } - if (m_Operator == StringOperator.Equal || m_Operator == StringOperator.NotEqual) + if (m_Operator is StringOperator.Equal or StringOperator.NotEqual) { emitter.BeginCall( type.GetMethod( diff --git a/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs index f7598fb5a..bf0fcdb8b 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/ContainedCommandImplementor.cs @@ -44,7 +44,7 @@ namespace Server.Commands.Generic return; // sanity check } - if (!(targeted is Container cont)) + if (targeted is not Container cont) { from.SendMessage("That is not a container."); return; diff --git a/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs index 87a030a61..45558d8f7 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/MultiCommandImplementor.cs @@ -46,7 +46,7 @@ namespace Server.Commands.Generic { case ObjectTypes.Both: { - if (!(targeted is Item || targeted is Mobile)) + if (!(targeted is Item or Mobile)) { from.SendMessage("This command does not work on that."); return; @@ -56,7 +56,7 @@ namespace Server.Commands.Generic } case ObjectTypes.Items: { - if (!(targeted is Item)) + if (targeted is not Item) { from.SendMessage("This command only works on items."); return; @@ -66,7 +66,7 @@ namespace Server.Commands.Generic } case ObjectTypes.Mobiles: { - if (!(targeted is Mobile)) + if (targeted is not Mobile) { from.SendMessage("This command only works on mobiles."); return; diff --git a/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs index 6ee458ea4..fca4324dd 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/SerialCommandImplementor.cs @@ -52,7 +52,7 @@ namespace Server.Commands.Generic { case ObjectTypes.Items: { - if (!(obj is Item)) + if (obj is not Item) { e.Mobile.SendMessage("This command only works on items."); return; @@ -62,7 +62,7 @@ namespace Server.Commands.Generic } case ObjectTypes.Mobiles: { - if (!(obj is Mobile)) + if (obj is not Mobile) { e.Mobile.SendMessage("This command only works on mobiles."); return; diff --git a/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs b/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs index 11aeb43bb..3220cd28b 100644 --- a/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs +++ b/Projects/UOContent/Commands/Generic/Implementors/SingleCommandImplementor.cs @@ -68,7 +68,7 @@ namespace Server.Commands.Generic { case ObjectTypes.Both: { - if (!(targeted is Item) && !(targeted is Mobile)) + if (targeted is not Item && targeted is not Mobile) { from.SendMessage("This command does not work on that."); return; @@ -78,7 +78,7 @@ namespace Server.Commands.Generic } case ObjectTypes.Items: { - if (!(targeted is Item)) + if (targeted is not Item) { from.SendMessage("This command only works on items."); return; @@ -88,7 +88,7 @@ namespace Server.Commands.Generic } case ObjectTypes.Mobiles: { - if (!(targeted is Mobile)) + if (targeted is not Mobile) { from.SendMessage("This command only works on mobiles."); return; diff --git a/Projects/UOContent/Commands/Handlers.cs b/Projects/UOContent/Commands/Handlers.cs index b289f9acd..94a7f9395 100644 --- a/Projects/UOContent/Commands/Handlers.cs +++ b/Projects/UOContent/Commands/Handlers.cs @@ -566,7 +566,7 @@ namespace Server.Commands { map = Map.AllMaps[i]; - if (map.MapIndex == 0x7F || map.MapIndex == 0xFF) + if (map.MapIndex is 0x7F or 0xFF) { continue; } @@ -595,7 +595,7 @@ namespace Server.Commands { map = Map.AllMaps[i]; - if (map.MapIndex == 0x7F || map.MapIndex == 0xFF || from.Map == map) + if (map.MapIndex is 0x7F or 0xFF || @from.Map == map) { continue; } @@ -629,7 +629,7 @@ namespace Server.Commands from.SendMessage("Region name not found"); } - else if (e.Length == 2 || e.Length == 3) + else if (e.Length is 2 or 3) { var map = from.Map; diff --git a/Projects/UOContent/Commands/HelpInfo.cs b/Projects/UOContent/Commands/HelpInfo.cs index 80ee82720..b85ca8b05 100644 --- a/Projects/UOContent/Commands/HelpInfo.cs +++ b/Projects/UOContent/Commands/HelpInfo.cs @@ -76,7 +76,7 @@ namespace Server.Commands continue; } - if (usage == null || !(attrs[0] is DescriptionAttribute desc)) + if (usage == null || attrs[0] is not DescriptionAttribute desc) { continue; } diff --git a/Projects/UOContent/Commands/LocationCommand.cs b/Projects/UOContent/Commands/LocationCommand.cs index 271dbd233..d74108741 100644 --- a/Projects/UOContent/Commands/LocationCommand.cs +++ b/Projects/UOContent/Commands/LocationCommand.cs @@ -23,14 +23,14 @@ namespace Server.Commands public override void Execute(CommandEventArgs e, object obj) { - if (!(obj is IPoint3D point)) + if (obj is not IPoint3D point) { LogFailure("That cannot be located."); return; } var label = $"(x:{point.X}, y:{point.Y}, z:{point.Z})"; - if (obj is LandTarget || obj is StaticTarget) + if (obj is LandTarget or StaticTarget) { List graphics; if (e.Arguments.Length == 0) diff --git a/Projects/UOContent/Commands/Logging.cs b/Projects/UOContent/Commands/Logging.cs index a1a5ab3d2..94f40d597 100644 --- a/Projects/UOContent/Commands/Logging.cs +++ b/Projects/UOContent/Commands/Logging.cs @@ -73,7 +73,7 @@ namespace Server.Commands var path = Core.BaseDirectory; - var name = !(from.Account is Account acct) ? from.Name : acct.Username; + var name = @from.Account is not Account acct ? from.Name : acct.Username; AppendPath(ref path, "Logs"); AppendPath(ref path, "Commands"); diff --git a/Projects/UOContent/Commands/Object Creation/Decorate.cs b/Projects/UOContent/Commands/Object Creation/Decorate.cs index 314bc011b..f8a14b4f2 100644 --- a/Projects/UOContent/Commands/Object Creation/Decorate.cs +++ b/Projects/UOContent/Commands/Object Creation/Decorate.cs @@ -1107,7 +1107,7 @@ namespace Server.Commands } } } - else if (srcItem is Teleporter || srcItem is FillableContainer || srcItem is BaseBook) + else if (srcItem is Teleporter or FillableContainer or BaseBook) { eable = map.GetItemsInRange(new Point3D(x, y, z), 0); diff --git a/Projects/UOContent/Commands/Object Creation/DecorateMag.cs b/Projects/UOContent/Commands/Object Creation/DecorateMag.cs index a1300cef3..fdea8e992 100644 --- a/Projects/UOContent/Commands/Object Creation/DecorateMag.cs +++ b/Projects/UOContent/Commands/Object Creation/DecorateMag.cs @@ -1103,7 +1103,7 @@ namespace Server.Commands } } } - else if (srcItem is Teleporter || srcItem is FillableContainer || srcItem is BaseBook) + else if (srcItem is Teleporter or FillableContainer or BaseBook) { eable = map.GetItemsInRange(new Point3D(x, y, z), 0); diff --git a/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs b/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs index f2542a731..daa84d9b0 100644 --- a/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs +++ b/Projects/UOContent/Commands/Object Creation/GenTeleporter.cs @@ -124,7 +124,7 @@ namespace Server.Commands var count = 0; foreach (var item in eable) { - if (!(item is KeywordTeleporter || item is SkillTeleporter) && IsWithinZ(item.Z - worldLocation.Z)) + if (!(item is KeywordTeleporter or SkillTeleporter) && IsWithinZ(item.Z - worldLocation.Z)) { count++; item.Delete(); diff --git a/Projects/UOContent/Commands/Properties.cs b/Projects/UOContent/Commands/Properties.cs index 29d92e594..21a3e25b0 100644 --- a/Projects/UOContent/Commands/Properties.cs +++ b/Projects/UOContent/Commands/Properties.cs @@ -263,7 +263,7 @@ namespace Server.Commands { var obj = realProps[i].GetValue(realObjs[i], null); - if (!(obj is IConvertible)) + if (obj is not IConvertible) { return "Property is not IConvertable."; } diff --git a/Projects/UOContent/Commands/Statics.cs b/Projects/UOContent/Commands/Statics.cs index 015136f82..839bd0ec3 100644 --- a/Projects/UOContent/Commands/Statics.cs +++ b/Projects/UOContent/Commands/Statics.cs @@ -168,7 +168,7 @@ namespace Server continue; } - if (item is Static || item is BaseFloor || item is BaseWall) + if (item is Static or BaseFloor or BaseWall) { var itemMap = item.Map; @@ -212,7 +212,7 @@ namespace Server foreach (var item in eable) { - if (item is Static || item is BaseFloor || item is BaseWall) + if (item is Static or BaseFloor or BaseWall) { var itemMap = item.Map; @@ -306,7 +306,7 @@ namespace Server var xOffset = item.X - state.m_X * 8; var yOffset = item.Y - state.m_Y * 8; - if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8) + if (xOffset is < 0 or >= 8 || yOffset is < 0 or >= 8) { continue; } diff --git a/Projects/UOContent/Commands/Wipe.cs b/Projects/UOContent/Commands/Wipe.cs index 693f4f3f5..bc066fbde 100644 --- a/Projects/UOContent/Commands/Wipe.cs +++ b/Projects/UOContent/Commands/Wipe.cs @@ -85,7 +85,7 @@ namespace Server.Commands foreach (var obj in eable) { - if (items && obj is Item && !(obj is BaseMulti || obj is HouseSign)) + if (items && obj is Item && !(obj is BaseMulti or HouseSign)) { toDelete.Add(obj); } diff --git a/Projects/UOContent/Engines/Bulk Orders/Books/BOBGump.cs b/Projects/UOContent/Engines/Bulk Orders/Books/BOBGump.cs index 71b5d4c54..442c1a2f3 100644 --- a/Projects/UOContent/Engines/Bulk Orders/Books/BOBGump.cs +++ b/Projects/UOContent/Engines/Bulk Orders/Books/BOBGump.cs @@ -709,7 +709,7 @@ namespace Server.Engines.BulkOrders var price = Utility.ToInt32(text); - if (price < 0 || price > 250000000) + if (price is < 0 or > 250000000) { from.SendLocalizedMessage(1062390); // The price you requested is outrageous! } diff --git a/Projects/UOContent/Engines/Bulk Orders/Books/BODBuyGump.cs b/Projects/UOContent/Engines/Bulk Orders/Books/BODBuyGump.cs index a9c3dc3ce..4b8a13b5c 100644 --- a/Projects/UOContent/Engines/Bulk Orders/Books/BODBuyGump.cs +++ b/Projects/UOContent/Engines/Bulk Orders/Books/BODBuyGump.cs @@ -46,7 +46,7 @@ namespace Server.Engines.BulkOrders return; } - if (!(m_Book.RootParent is PlayerVendor pv)) + if (m_Book.RootParent is not PlayerVendor pv) { m_From.SendLocalizedMessage(1062382); // The deed selected is not available. return; diff --git a/Projects/UOContent/Engines/Bulk Orders/Rewards.cs b/Projects/UOContent/Engines/Bulk Orders/Rewards.cs index 4aaae3152..627682830 100644 --- a/Projects/UOContent/Engines/Bulk Orders/Rewards.cs +++ b/Projects/UOContent/Engines/Bulk Orders/Rewards.cs @@ -533,7 +533,7 @@ namespace Server.Engines.BulkOrders private static Item CreatePowerScroll(int type) { - if (type == 5 || type == 10 || type == 15 || type == 20) + if (type is 5 or 10 or 15 or 20) { return new PowerScroll(SkillName.Blacksmith, 100 + type); } @@ -545,7 +545,7 @@ namespace Server.Engines.BulkOrders private static Item CreateAncientHammer(int type) { - if (type == 10 || type == 15 || type == 30 || type == 60) + if (type is 10 or 15 or 30 or 60) { return new AncientSmithyHammer(type); } @@ -848,7 +848,7 @@ namespace Server.Engines.BulkOrders private static Item CreatePowerScroll(int type) { - if (type == 5 || type == 10 || type == 15 || type == 20) + if (type is 5 or 10 or 15 or 20) { return new PowerScroll(SkillName.Tailoring, 100 + type); } diff --git a/Projects/UOContent/Engines/Bulk Orders/SmallBOD.cs b/Projects/UOContent/Engines/Bulk Orders/SmallBOD.cs index 15cb5d622..8f0489aa1 100644 --- a/Projects/UOContent/Engines/Bulk Orders/SmallBOD.cs +++ b/Projects/UOContent/Engines/Bulk Orders/SmallBOD.cs @@ -132,7 +132,7 @@ namespace Server.Engines.BulkOrders from.SendLocalizedMessage(1045166); } else if (Type == null || objectType != Type && !objectType.IsSubclassOf(Type) || - !(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)) + item is not BaseWeapon && item is not BaseArmor && item is not BaseClothing) { from.SendLocalizedMessage(1045169); // The item is not in the request. } diff --git a/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs b/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs index 50e6d845f..0203b4959 100644 --- a/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs +++ b/Projects/UOContent/Engines/ConPVP/AcceptDuelGump.cs @@ -186,7 +186,7 @@ namespace Server.Engines.ConPVP if (info.IsSwitched(1)) { - if (!(m_Challenged is PlayerMobile pm)) + if (m_Challenged is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/ConPVP/DuelContext.cs b/Projects/UOContent/Engines/ConPVP/DuelContext.cs index 162d8fa4f..b745ad9af 100644 --- a/Projects/UOContent/Engines/ConPVP/DuelContext.cs +++ b/Projects/UOContent/Engines/ConPVP/DuelContext.cs @@ -99,7 +99,7 @@ namespace Server.Engines.ConPVP public static bool IsFreeConsume(Mobile mob) { - if (!(mob is PlayerMobile pm) || pm.DuelContext?.m_EventGame == null) + if (mob is not PlayerMobile pm || pm.DuelContext?.m_EventGame == null) { return false; } @@ -257,7 +257,7 @@ namespace Server.Engines.ConPVP public static bool AllowSpecialAbility(Mobile from, string name, bool message) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return true; } @@ -345,7 +345,7 @@ namespace Server.Engines.ConPVP return false; } - if (!(weapon is BaseRanged) && !Ruleset.GetOption("Weapons", "Melee")) + if (weapon is not BaseRanged && !Ruleset.GetOption("Weapons", "Melee")) { return false; } @@ -411,7 +411,7 @@ namespace Server.Engines.ConPVP return true; } - if (!(item is BaseRefreshPotion)) + if (item is not BaseRefreshPotion) { if (CantDoAnything(from)) { @@ -513,7 +513,7 @@ namespace Server.Engines.ConPVP return false; } - if (item is BasePotion && !(item is BaseExplosionPotion) && !(item is BaseRefreshPotion) && IsSuddenDeath) + if (item is BasePotion && item is not BaseExplosionPotion && item is not BaseRefreshPotion && IsSuddenDeath) { from.SendMessage(0x22, "You may not drink potions in sudden death."); return false; @@ -655,7 +655,7 @@ namespace Server.Engines.ConPVP public void Requip(Mobile from, Container cont) { - if (!(cont is Corpse corpse)) + if (cont is not Corpse corpse) { return; } @@ -670,7 +670,7 @@ namespace Server.Engines.ConPVP { var item = items[i]; - if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || !item.Movable) + if (item.Layer is Layer.Hair or Layer.FacialHair || !item.Movable) { continue; } @@ -1295,7 +1295,7 @@ namespace Server.Engines.ConPVP private static void EventSink_Login(Mobile m) { - if (!(m is PlayerMobile pm)) + if (m is not PlayerMobile pm) { return; } @@ -1385,7 +1385,7 @@ namespace Server.Engines.ConPVP return; } - if (!(e.Mobile is PlayerMobile pm)) + if (e.Mobile is not PlayerMobile pm) { return; } @@ -2048,7 +2048,7 @@ namespace Server.Engines.ConPVP int number = item switch { BaseWeapon _ => 1062001, // You can no longer wield your ~1_WEAPON~ - _ when !(item is BaseShield) && (item is BaseArmor || item is BaseClothing) => 1062002, // You can no longer wear your ~1_ARMOR~ + not BaseShield when item is BaseArmor or BaseClothing => 1062002, // You can no longer wear your ~1_ARMOR~ _ => 1062003 // You can no longer equip your ~1_SHIELD~ }; @@ -2403,7 +2403,7 @@ namespace Server.Engines.ConPVP m_GateFacet = Initiator.Map; } - if (!(arena.Teleporter is ExitTeleporter tp)) + if (arena.Teleporter is not ExitTeleporter tp) { arena.Teleporter = tp = new ExitTeleporter(); tp.MoveToWorld(arena.GateOut == Point3D.Zero ? arena.Outside : arena.GateOut, arena.Facet); diff --git a/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs b/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs index 04921fc64..6d764eb62 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/BombingRun.cs @@ -210,7 +210,7 @@ namespace Server.Engines.ConPVP return false; } - if (!(obj is IPoint3D)) + if (obj is not IPoint3D) { return false; } @@ -1680,7 +1680,7 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return mob is BaseCreature creature ? creature.Team - 1 : -1; } diff --git a/Projects/UOContent/Engines/ConPVP/Games/CTF.cs b/Projects/UOContent/Engines/ConPVP/Games/CTF.cs index ac45f1a4c..cd1a1fec8 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/CTF.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/CTF.cs @@ -953,7 +953,7 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return -1; } diff --git a/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs b/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs index e248a8487..e40af18e0 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/DoubleDom.cs @@ -553,7 +553,7 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return -1; } diff --git a/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs b/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs index 6d95d1630..3202e5b98 100644 --- a/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs +++ b/Projects/UOContent/Engines/ConPVP/Games/KingOfTheHill.cs @@ -924,7 +924,7 @@ namespace Server.Engines.ConPVP public int GetTeamID(Mobile mob) { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return mob is BaseCreature creature ? creature.Team - 1 : -1; } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs index d05be1836..28a6c2794 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/AcceptTeamGump.cs @@ -318,7 +318,7 @@ namespace Server.Engines.ConPVP if (info.IsSwitched(1)) { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs index 40554a6b4..04e235ac6 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ConfirmSignupGump.cs @@ -565,7 +565,7 @@ namespace Server.Engines.ConPVP private void AddPlayer_OnTarget(Mobile from, object obj) { - if (!(obj is Mobile mob) || mob == from) + if (obj is not Mobile mob || mob == from) { m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); @@ -604,7 +604,7 @@ namespace Server.Engines.ConPVP } else { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs index 390a3a7f3..3c89caa3b 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ParticipantGump.cs @@ -217,7 +217,7 @@ namespace Server.Engines.ConPVP return; } - if (!(targeted is Mobile mob)) + if (targeted is not Mobile mob) { from.SendMessage("That is not a player."); } @@ -238,7 +238,7 @@ namespace Server.Engines.ConPVP } else { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs index afc9acd46..735379d2e 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/ReadyUpGump.cs @@ -211,7 +211,7 @@ namespace Server.Engines.ConPVP { case 1: // okay { - if (!(m_From is PlayerMobile pm)) + if (m_From is not PlayerMobile pm) { break; } diff --git a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs index 8da52acff..9dc149ce8 100644 --- a/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs +++ b/Projects/UOContent/Engines/ConPVP/Gumps/TournamentBracketGump.cs @@ -306,7 +306,7 @@ namespace Server.Engines.ConPVP } case TourneyBracketGumpType.Participant_Info: { - if (!(obj is TourneyParticipant part)) + if (obj is not TourneyParticipant part) { break; } @@ -380,7 +380,7 @@ namespace Server.Engines.ConPVP AddLeftArrow(25, 11, ToButtonID(0, 3)); AddHtml(25, 35, 250, 20, Center("Participants")); - if (!(obj is Mobile mob)) + if (obj is not Mobile mob) { break; } @@ -428,7 +428,7 @@ namespace Server.Engines.ConPVP AddLeftArrow(25, 11, ToButtonID(0, 2)); AddHtml(25, 35, 250, 20, Center("Rounds")); - if (!(m_Object is PyramidLevel level)) + if (m_Object is not PyramidLevel level) { break; } @@ -490,9 +490,7 @@ namespace Server.Engines.ConPVP } } else if (m_Tournament.EventController != null || - m_Tournament.TourneyType == TourneyType.RandomTeam || - m_Tournament.TourneyType == TourneyType.RedVsBlue || - m_Tournament.TourneyType == TourneyType.Faction) + m_Tournament.TourneyType is TourneyType.RandomTeam or TourneyType.RedVsBlue or TourneyType.Faction) { for (var j = 0; j < match.Participants.Count; ++j) { @@ -572,7 +570,7 @@ namespace Server.Engines.ConPVP } case TourneyBracketGumpType.Match_Info: { - if (!(obj is TourneyMatch match)) + if (obj is not TourneyMatch match) { break; } @@ -605,9 +603,7 @@ namespace Server.Engines.ConPVP } } else if (m_Tournament.EventController != null || - m_Tournament.TourneyType == TourneyType.RandomTeam || - m_Tournament.TourneyType == TourneyType.RedVsBlue || - m_Tournament.TourneyType == TourneyType.Faction) + m_Tournament.TourneyType is TourneyType.RandomTeam or TourneyType.RedVsBlue or TourneyType.Faction) { for (var i = 0; i < match.Participants.Count; ++i) { @@ -840,7 +836,7 @@ namespace Server.Engines.ConPVP } case 5: { - if (!(m_Object is TourneyMatch match)) + if (m_Object is not TourneyMatch match) { break; } @@ -990,7 +986,7 @@ namespace Server.Engines.ConPVP break; } - if (!(m_Object is PyramidLevel level)) + if (m_Object is not PyramidLevel level) { break; } diff --git a/Projects/UOContent/Engines/ConPVP/Ladder.cs b/Projects/UOContent/Engines/ConPVP/Ladder.cs index ca42ee278..5e76003e7 100644 --- a/Projects/UOContent/Engines/ConPVP/Ladder.cs +++ b/Projects/UOContent/Engines/ConPVP/Ladder.cs @@ -211,7 +211,7 @@ namespace Server.Engines.ConPVP { var x = ourLevel - theirLevel; - if (x < -6 || x > +6) + if (x is < -6 or > +6) { return 0; } diff --git a/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs b/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs index 8c73047d4..0f1e9d646 100644 --- a/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs +++ b/Projects/UOContent/Engines/ConPVP/TournamentPyramid.cs @@ -16,7 +16,7 @@ namespace Server.Engines.ConPVP { var copy = new List(participants); - if (groupType == GroupingType.Nearest || groupType == GroupingType.HighVsLow) + if (groupType is GroupingType.Nearest or GroupingType.HighVsLow) { copy.Sort(); } diff --git a/Projects/UOContent/Engines/Craft/Core/CraftItem.cs b/Projects/UOContent/Engines/Craft/Core/CraftItem.cs index f108acaa8..cece9b8dd 100644 --- a/Projects/UOContent/Engines/Craft/Core/CraftItem.cs +++ b/Projects/UOContent/Engines/Craft/Core/CraftItem.cs @@ -483,7 +483,7 @@ namespace Server.Engines.Craft for (var j = 0; j < items[i].Length; ++j) { - if (!(items[i][j] is IHasQuantity hq)) + if (items[i][j] is not IHasQuantity hq) { totals[i] += items[i][j].Amount; } @@ -512,7 +512,7 @@ namespace Server.Engines.Craft { var item = items[i][j]; - if (!(item is IHasQuantity hq)) + if (item is not IHasQuantity hq) { var theirAmount = item.Amount; @@ -561,7 +561,7 @@ namespace Server.Engines.Craft for (var i = 0; i < items.Length; ++i) { - if (!(items[i] is IHasQuantity hq)) + if (items[i] is not IHasQuantity hq) { amount += items[i].Amount; } diff --git a/Projects/UOContent/Engines/Craft/Core/Enhance.cs b/Projects/UOContent/Engines/Craft/Core/Enhance.cs index a9a160098..c5a6c0377 100644 --- a/Projects/UOContent/Engines/Craft/Core/Enhance.cs +++ b/Projects/UOContent/Engines/Craft/Core/Enhance.cs @@ -35,7 +35,7 @@ namespace Server.Engines.Craft return EnhanceResult.NotInBackpack; } - if (!(item is BaseArmor) && !(item is BaseWeapon)) + if (item is not BaseArmor && item is not BaseWeapon) { return EnhanceResult.BadItem; } diff --git a/Projects/UOContent/Engines/Craft/Core/Repair.cs b/Projects/UOContent/Engines/Craft/Core/Repair.cs index a967556f2..391b76382 100644 --- a/Projects/UOContent/Engines/Craft/Core/Repair.cs +++ b/Projects/UOContent/Engines/Craft/Core/Repair.cs @@ -90,11 +90,7 @@ namespace Server.Engines.Craft if (m_CraftSystem is DefTailoring) { - return clothing is BearMask - || clothing is DeerMask - || clothing is TheMostKnowledgePerson - || clothing is TheRobeOfBritanniaAri - || clothing is EmbroideredOakLeafCloak; + return clothing is BearMask or DeerMask or TheMostKnowledgePerson or TheRobeOfBritanniaAri or EmbroideredOakLeafCloak; } return false; @@ -106,44 +102,23 @@ namespace Server.Engines.Craft if (m_CraftSystem is DefTinkering) { - return weapon is Cleaver - || weapon is Hatchet - || weapon is Pickaxe - || weapon is ButcherKnife - || weapon is SkinningKnife; + return weapon is Cleaver or Hatchet or Pickaxe or ButcherKnife or SkinningKnife; } if (m_CraftSystem is DefCarpentry) { - return weapon is Club - || weapon is BlackStaff - || weapon is MagicWand - - // TODO: Make these items craftable - || weapon is WildStaff; + return weapon is Club or BlackStaff or MagicWand or WildStaff; } if (m_CraftSystem is DefBlacksmithy) { - return weapon is Pitchfork - - // TODO: Make these items craftable - || weapon is RadiantScimitar - || weapon is WarCleaver - || weapon is ElvenSpellblade - || weapon is AssassinSpike - || weapon is Leafblade - || weapon is RuneBlade - || weapon is ElvenMachete - || weapon is OrnateAxe - || weapon is DiamondMace; + return weapon is Pitchfork or RadiantScimitar or WarCleaver or ElvenSpellblade or AssassinSpike or Leafblade or RuneBlade or ElvenMachete or OrnateAxe or DiamondMace; } // TODO: Make these items craftable if (m_CraftSystem is DefBowFletching) { - return weapon is ElvenCompositeLongbow - || weapon is MagicalShortbow; + return weapon is ElvenCompositeLongbow or MagicalShortbow; } return false; @@ -156,36 +131,17 @@ namespace Server.Engines.Craft // TODO: Make these items craftable if (m_CraftSystem is DefTailoring) { - return armor is LeafTonlet - || armor is LeafArms - || armor is LeafChest - || armor is LeafGloves - || armor is LeafGorget - || armor is LeafLegs - || armor is HideChest - || armor is HideGloves - || armor is HideGorget - || armor is HidePants - || armor is HidePauldrons; + return armor is LeafTonlet or LeafArms or LeafChest or LeafGloves or LeafGorget or LeafLegs or HideChest or HideGloves or HideGorget or HidePants or HidePauldrons; } if (m_CraftSystem is DefCarpentry) { - return armor is WingedHelm - || armor is RavenHelm - || armor is VultureHelm - || armor is WoodlandArms - || armor is WoodlandChest - || armor is WoodlandGloves - || armor is WoodlandGorget - || armor is WoodlandLegs; + return armor is WingedHelm or RavenHelm or VultureHelm or WoodlandArms or WoodlandChest or WoodlandGloves or WoodlandGorget or WoodlandLegs; } if (m_CraftSystem is DefBlacksmithy) { - return armor is Circlet - || armor is RoyalCirclet - || armor is GemmedCirclet; + return armor is Circlet or RoyalCirclet or GemmedCirclet; } return false; @@ -448,7 +404,7 @@ namespace Server.Engines.Craft } if (m_CraftSystem.CraftItems.SearchForSubclass(clothing.GetType()) == null && - !IsSpecialClothing(clothing) && !(clothing is TribalMask || clothing is HornedTribalMask)) + !IsSpecialClothing(clothing) && !(clothing is TribalMask or HornedTribalMask)) { number = usingDeed ? 1061136 diff --git a/Projects/UOContent/Engines/Craft/DefCarpentry.cs b/Projects/UOContent/Engines/Craft/DefCarpentry.cs index 23d303a68..95e1a76f6 100644 --- a/Projects/UOContent/Engines/Craft/DefCarpentry.cs +++ b/Projects/UOContent/Engines/Craft/DefCarpentry.cs @@ -87,7 +87,7 @@ namespace Server.Engines.Craft int index; // Other Items - if (Core.Expansion == Expansion.AOS || Core.Expansion == Expansion.SE) + if (Core.Expansion is Expansion.AOS or Expansion.SE) { index = AddCraft(typeof(Board), 1044294, 1027127, 0.0, 0.0, typeof(Log), 1044466, 1, 1044465); SetUseAllRes(index, true); diff --git a/Projects/UOContent/Engines/Doom/GauntletSpawner.cs b/Projects/UOContent/Engines/Doom/GauntletSpawner.cs index 705a9ca67..76d27f205 100644 --- a/Projects/UOContent/Engines/Doom/GauntletSpawner.cs +++ b/Projects/UOContent/Engines/Doom/GauntletSpawner.cs @@ -235,7 +235,7 @@ namespace Server.Engines.Doom _ => new MushroomTrap() }; - if (trap is FireColumnTrap || trap is MushroomTrap) + if (trap is FireColumnTrap or MushroomTrap) { trap.Hue = 0x451; } diff --git a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs index 781cf752d..37745ce61 100644 --- a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs +++ b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs @@ -31,7 +31,7 @@ namespace Server.Engines.Doom public override void OnEnter(Mobile m) { - if (m == null || m is WandererOfTheVoid) + if (m is null or WandererOfTheVoid) { return; } diff --git a/Projects/UOContent/Engines/Ethics/Core/Ethic.cs b/Projects/UOContent/Engines/Ethics/Core/Ethic.cs index e14ea51bf..59e2da0f5 100644 --- a/Projects/UOContent/Engines/Ethics/Core/Ethic.cs +++ b/Projects/UOContent/Engines/Ethics/Core/Ethic.cs @@ -160,7 +160,7 @@ namespace Server.Ethics foreach (var item in eable) { - if (item is AnkhNorth || item is AnkhWest) + if (item is AnkhNorth or AnkhWest) { found = true; break; diff --git a/Projects/UOContent/Engines/Ethics/Evil/Ethic.cs b/Projects/UOContent/Engines/Ethics/Evil/Ethic.cs index e895cad31..211cfa42a 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Ethic.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Ethic.cs @@ -29,7 +29,7 @@ namespace Server.Ethics.Evil { var fac = Faction.Find(mob); - return fac is Minax || fac is Shadowlords; + return fac is Minax or Shadowlords; } } } diff --git a/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs b/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs index 0d3cfc296..0dddf0575 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Powers/Blight.cs @@ -23,7 +23,7 @@ namespace Server.Ethics.Evil private void Power_OnTarget(Mobile fromMobile, object obj, Player from) { - if (!(obj is IPoint3D p)) + if (obj is not IPoint3D p) { return; } diff --git a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs index 59259b19e..a46e3cbb0 100644 --- a/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs +++ b/Projects/UOContent/Engines/Ethics/Evil/Powers/UnholyItem.cs @@ -22,7 +22,7 @@ namespace Server.Ethics.Evil private void Power_OnTarget(Mobile fromMobile, object obj, Player from) { - if (!(obj is Item item)) + if (obj is not Item item) { from.Mobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may not imbue that."); return; @@ -45,7 +45,7 @@ namespace Server.Ethics.Evil return; } - var canImbue = (item is Spellbook || item is BaseClothing || item is BaseArmor || item is BaseWeapon) && + var canImbue = item is Spellbook or BaseClothing or BaseArmor or BaseWeapon && item.Name == null; if (canImbue) diff --git a/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs b/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs index 0a8275be5..e473b00d9 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Ethic.cs @@ -34,7 +34,7 @@ namespace Server.Ethics.Hero var fac = Faction.Find(mob); - return fac is TrueBritannians || fac is CouncilOfMages; + return fac is TrueBritannians or CouncilOfMages; } } } diff --git a/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs b/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs index 2c341a2da..f0c23cb73 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Powers/Bless.cs @@ -23,7 +23,7 @@ namespace Server.Ethics.Hero private void Power_OnTarget(Mobile fromMobile, object obj, Player from) { - if (!(obj is IPoint3D p)) + if (obj is not IPoint3D p) { return; } diff --git a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs index 9e85c4444..e927651ef 100644 --- a/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs +++ b/Projects/UOContent/Engines/Ethics/Hero/Powers/HolyItem.cs @@ -22,7 +22,7 @@ namespace Server.Ethics.Hero private void Power_OnTarget(Mobile fromMobile, object obj, Player from) { - if (!(obj is Item item)) + if (obj is not Item item) { from.Mobile.LocalOverheadMessage(MessageType.Regular, 0x3B2, false, "You may not imbue that."); return; @@ -45,7 +45,7 @@ namespace Server.Ethics.Hero return; } - var canImbue = (item is Spellbook || item is BaseClothing || item is BaseArmor || item is BaseWeapon) && + var canImbue = item is Spellbook or BaseClothing or BaseArmor or BaseWeapon && item.Name == null; if (canImbue) diff --git a/Projects/UOContent/Engines/Factions/Core/Faction.cs b/Projects/UOContent/Engines/Factions/Core/Faction.cs index 967951e57..43d67c6ca 100644 --- a/Projects/UOContent/Engines/Factions/Core/Faction.cs +++ b/Projects/UOContent/Engines/Factions/Core/Faction.cs @@ -502,7 +502,7 @@ namespace Server.Factions public static bool IsFactionBanned(Mobile mob) { - if (!(mob.Account is Account acct)) + if (mob.Account is not Account acct) { return false; } @@ -512,7 +512,7 @@ namespace Server.Factions public void OnJoinAccepted(Mobile mob) { - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return; // sanity } @@ -571,7 +571,7 @@ namespace Server.Factions for (var i = 0; i < members.Count; ++i) { - if (!(members[i] is PlayerMobile member)) + if (members[i] is not PlayerMobile member) { continue; } @@ -767,7 +767,7 @@ namespace Server.Factions foreach (var item in World.Items.Values) { - if (item is IFactionItem && !(item is HoodedShroudOfShadows)) + if (item is IFactionItem && item is not HoodedShroudOfShadows) { items.Add(item); } diff --git a/Projects/UOContent/Engines/Factions/Core/FactionItem.cs b/Projects/UOContent/Engines/Factions/Core/FactionItem.cs index f84925ed2..6d02f0948 100644 --- a/Projects/UOContent/Engines/Factions/Core/FactionItem.cs +++ b/Projects/UOContent/Engines/Factions/Core/FactionItem.cs @@ -129,7 +129,7 @@ namespace Server.Factions public static Item Imbue(Item item, Faction faction, bool expire, int hue) { - if (!(item is IFactionItem)) + if (item is not IFactionItem) { return item; } diff --git a/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs b/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs index f13ffa4b8..9e3a5b667 100644 --- a/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs +++ b/Projects/UOContent/Engines/Factions/Gumps/LeaveFactionGump.cs @@ -50,7 +50,7 @@ namespace Server.Factions { case 1: // continue { - if (!(m_From.Guild is Guild guild)) + if (m_From.Guild is not Guild guild) { var pl = PlayerState.Find(m_From); diff --git a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs index fef72f966..5d6d2729b 100644 --- a/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs +++ b/Projects/UOContent/Engines/Factions/Items/Power Faction Items/StormsEye.cs @@ -32,7 +32,7 @@ namespace Server TargetFlags.None, (from, obj, stormsEye) => { - if (!stormsEye.Movable || stormsEye.Deleted || !(obj is IPoint3D pt)) + if (!stormsEye.Movable || stormsEye.Deleted || obj is not IPoint3D pt) { return; } diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs index 1b437d591..83ff2454b 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -156,7 +156,7 @@ namespace Server.Factions return false; } - if (m_Guard.Weapon is Item weapon && weapon.Parent == m_Guard && !(weapon is Fists)) + if (m_Guard.Weapon is Item weapon && weapon.Parent == m_Guard && weapon is not Fists) { pack.DropItem(weapon); return true; diff --git a/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs b/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs index c5790a8ac..a5a8a4a80 100644 --- a/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs +++ b/Projects/UOContent/Engines/Harvest/Core/HarvestTarget.cs @@ -25,13 +25,12 @@ namespace Server.Engines.Harvest var itemID = target.ItemID; // grave - if (itemID == 0xED3 || itemID == 0xEDF || itemID == 0xEE0 || itemID == 0xEE1 || itemID == 0xEE2 || - itemID == 0xEE8) + if (itemID is 0xED3 or 0xEDF or 0xEE0 or 0xEE1 or 0xEE2 or 0xEE8) { if (from is PlayerMobile player) { var qs = player.Quest; - if (!(qs is WitchApprenticeQuest)) + if (qs is not WitchApprenticeQuest) { return; } diff --git a/Projects/UOContent/Engines/Harvest/Fishing.cs b/Projects/UOContent/Engines/Harvest/Fishing.cs index a4847df90..035f21e4d 100644 --- a/Projects/UOContent/Engines/Harvest/Fishing.cs +++ b/Projects/UOContent/Engines/Harvest/Fishing.cs @@ -350,7 +350,7 @@ namespace Server.Engines.Harvest public override bool Give(Mobile m, Item item, bool placeAtFeet) { - if (item is TreasureMap || item is MessageInABottle || item is SpecialFishingNet) + if (item is TreasureMap or MessageInABottle or SpecialFishingNet) { BaseCreature serp; @@ -395,7 +395,7 @@ namespace Server.Engines.Harvest return true; // we don't want to give the item to the player, it's on the serpent } - return base.Give(m, item, placeAtFeet || item is BigFish || item is WoodenChest || item is MetalGoldenChest); + return base.Give(m, item, placeAtFeet || item is BigFish or WoodenChest or MetalGoldenChest); } public override void SendSuccessTo(Mobile from, Item item, HarvestResource resource) @@ -405,7 +405,7 @@ namespace Server.Engines.Harvest from.SendLocalizedMessage(1042635); // Your fishing pole bends as you pull a big fish from the depths! fish.Fisher = from; } - else if (item is WoodenChest || item is MetalGoldenChest) + else if (item is WoodenChest or MetalGoldenChest) { from.SendLocalizedMessage(503175); // You pull up a heavy chest from the depths of the ocean! } diff --git a/Projects/UOContent/Engines/Harvest/Lumberjacking.cs b/Projects/UOContent/Engines/Harvest/Lumberjacking.cs index dd4c3c2a7..3e046f494 100644 --- a/Projects/UOContent/Engines/Harvest/Lumberjacking.cs +++ b/Projects/UOContent/Engines/Harvest/Lumberjacking.cs @@ -169,7 +169,7 @@ namespace Server.Engines.Harvest { item.LabelTo(from, 500464); // Use this on corpses to carve away meat and hide } - else if (toHarvest is StaticTarget || toHarvest is LandTarget) + else if (toHarvest is StaticTarget or LandTarget) { from.SendLocalizedMessage(500489); // You can't use an axe on that. } diff --git a/Projects/UOContent/Engines/Help/PageQueue.cs b/Projects/UOContent/Engines/Help/PageQueue.cs index 176337323..dee5f13ad 100644 --- a/Projects/UOContent/Engines/Help/PageQueue.cs +++ b/Projects/UOContent/Engines/Help/PageQueue.cs @@ -128,7 +128,7 @@ namespace Server.Engines.Help public static bool CheckAllowedToPage(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return true; } diff --git a/Projects/UOContent/Engines/Help/SpeechLog.cs b/Projects/UOContent/Engines/Help/SpeechLog.cs index 15b3f7848..a83940620 100644 --- a/Projects/UOContent/Engines/Help/SpeechLog.cs +++ b/Projects/UOContent/Engines/Help/SpeechLog.cs @@ -90,7 +90,7 @@ namespace Server.Engines.Help protected override void OnTarget(Mobile from, object targeted) { - if (!(targeted is PlayerMobile pm)) + if (targeted is not PlayerMobile pm) { from.SendMessage("Speech logs aren't supported on that target."); } diff --git a/Projects/UOContent/Engines/ML Quests/Gumps/QuestOfferGump.cs b/Projects/UOContent/Engines/ML Quests/Gumps/QuestOfferGump.cs index 45ade8384..69e9e2376 100644 --- a/Projects/UOContent/Engines/ML Quests/Gumps/QuestOfferGump.cs +++ b/Projects/UOContent/Engines/ML Quests/Gumps/QuestOfferGump.cs @@ -36,7 +36,7 @@ namespace Server.Engines.MLQuests.Gumps public override void OnResponse(NetState sender, RelayInfo info) { - if (!(sender.Mobile is PlayerMobile pm)) + if (sender.Mobile is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs b/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs index 4bd855321..b6759c71c 100644 --- a/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs +++ b/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs @@ -202,7 +202,7 @@ namespace Server.Engines.MLQuests.Gumps CloseCurrent(state); - if (!(state.Mobile is PlayerMobile pm)) + if (state.Mobile is not PlayerMobile pm) { return; } @@ -325,7 +325,7 @@ namespace Server.Engines.MLQuests.Gumps public override void OnDoubleClick(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs b/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs index 791eb6dcf..64978b443 100644 --- a/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs +++ b/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs @@ -22,7 +22,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (!(from is PlayerMobile pm) || pm.Backpack == null) + if (@from is not PlayerMobile pm || pm.Backpack == null) { return; } diff --git a/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs b/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs index a1dd82869..dc7262333 100644 --- a/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs +++ b/Projects/UOContent/Engines/ML Quests/Items/Teleporters.cs @@ -55,7 +55,7 @@ namespace Server.Engines.MLQuests.Items return true; } - if (!(m is PlayerMobile pm)) + if (m is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/ML Quests/MLQuestSystem.cs b/Projects/UOContent/Engines/ML Quests/MLQuestSystem.cs index 658ac3a58..41b71a98a 100644 --- a/Projects/UOContent/Engines/ML Quests/MLQuestSystem.cs +++ b/Projects/UOContent/Engines/ML Quests/MLQuestSystem.cs @@ -210,7 +210,7 @@ namespace Server.Engines.MLQuests { var m = e.Mobile; - if (e.Length == 0 || e.Length > 2) + if (e.Length is 0 or > 2) { m.SendMessage("Syntax: SaveQuest [saveEnabled=true]"); return; @@ -638,7 +638,7 @@ namespace Server.Engines.MLQuests public static void EventSink_QuestGumpRequest(Mobile m) { - if (!Enabled || !(m is PlayerMobile pm)) + if (!Enabled || m is not PlayerMobile pm) { return; } @@ -809,7 +809,7 @@ namespace Server.Engines.MLQuests { var from = e.Mobile; - if (!(obj is PlayerMobile pm)) + if (obj is not PlayerMobile pm) { LogFailure("That is not a player."); return; @@ -840,7 +840,7 @@ namespace Server.Engines.MLQuests public override void Execute(CommandEventArgs e, object obj) { - if (!(obj is PlayerMobile pm)) + if (obj is not PlayerMobile pm) { LogFailure("They have no ML quest context."); } diff --git a/Projects/UOContent/Engines/ML Quests/Objectives/CollectObjective.cs b/Projects/UOContent/Engines/ML Quests/Objectives/CollectObjective.cs index f6891a3c6..0ea76721b 100644 --- a/Projects/UOContent/Engines/ML Quests/Objectives/CollectObjective.cs +++ b/Projects/UOContent/Engines/ML Quests/Objectives/CollectObjective.cs @@ -16,7 +16,7 @@ namespace Server.Engines.MLQuests.Objectives { var itemid = LabelToItemID(name.Number); - if (itemid <= 0 || itemid > 0x4000) + if (itemid is <= 0 or > 0x4000) { Console.WriteLine("Warning: cliloc {0} is likely giving the wrong item ID", name.Number); } diff --git a/Projects/UOContent/Engines/ML Quests/Objectives/DeliverObjective.cs b/Projects/UOContent/Engines/ML Quests/Objectives/DeliverObjective.cs index 5aa9d7e43..25e9ef729 100644 --- a/Projects/UOContent/Engines/ML Quests/Objectives/DeliverObjective.cs +++ b/Projects/UOContent/Engines/ML Quests/Objectives/DeliverObjective.cs @@ -24,7 +24,7 @@ namespace Server.Engines.MLQuests.Objectives { var itemid = CollectObjective.LabelToItemID(name.Number); - if (itemid <= 0 || itemid > 0x4000) + if (itemid is <= 0 or > 0x4000) { logger.Warning("Cliloc {0} is likely giving the wrong item ID", name.Number); } diff --git a/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs b/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs index b655dcff3..40ec83fcd 100644 --- a/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs +++ b/Projects/UOContent/Engines/Pathing/PathAlgorithm.cs @@ -24,7 +24,7 @@ namespace Server.PathAlgorithms var y = yDest + 1 - ySource; var v = y * 3 + x; - if (v < 0 || v >= 9) + if (v is < 0 or >= 9) { return Direction.North; } diff --git a/Projects/UOContent/Engines/Plants/MainPlantGump.cs b/Projects/UOContent/Engines/Plants/MainPlantGump.cs index 5593d3787..a1b730ee7 100644 --- a/Projects/UOContent/Engines/Plants/MainPlantGump.cs +++ b/Projects/UOContent/Engines/Plants/MainPlantGump.cs @@ -101,7 +101,7 @@ namespace Server.Engines.Plants AddItem(127, 112, 0xC62); } - if (status == PlantStatus.Stage3 || status == PlantStatus.Stage4) + if (status is PlantStatus.Stage3 or PlantStatus.Stage4) { AddItem(129, 85, 0xC7E); } @@ -134,7 +134,7 @@ namespace Server.Engines.Plants var hueInfo = PlantHueInfo.GetInfo(m_Plant.PlantHue); // The large images for these trees trigger a client crash, so use a smaller, generic tree. - if (m_Plant.PlantType == PlantType.CypressTwisted || m_Plant.PlantType == PlantType.CypressStraight) + if (m_Plant.PlantType is PlantType.CypressTwisted or PlantType.CypressStraight) { AddItem(130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, 0x0CCA, hueInfo.Hue); } diff --git a/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs b/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs index 4e75a1f2a..882545bb2 100644 --- a/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs +++ b/Projects/UOContent/Engines/Plants/MiscItems/GreenThorns.cs @@ -99,7 +99,7 @@ namespace Server.Items return; } - if (!(targeted is LandTarget land)) + if (targeted is not LandTarget land) { from.LocalOverheadMessage( MessageType.Regular, diff --git a/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs b/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs index 38a6666b4..75d161148 100644 --- a/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs +++ b/Projects/UOContent/Engines/Plants/MiscItems/RedLeaves.cs @@ -65,11 +65,11 @@ namespace Server.Items return; } - if (!(targeted is Item item) || !item.IsChildOf(from.Backpack)) + if (targeted is not Item item || !item.IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it. } - else if (!(item is BaseBook)) + else if (item is not BaseBook) { item.LabelTo(from, 1061911); // You can only use red leaves to seal the ink into book pages! } diff --git a/Projects/UOContent/Engines/Plants/PlantHue.cs b/Projects/UOContent/Engines/Plants/PlantHue.cs index b3c3fb03d..0f5d899af 100644 --- a/Projects/UOContent/Engines/Plants/PlantHue.cs +++ b/Projects/UOContent/Engines/Plants/PlantHue.cs @@ -108,7 +108,7 @@ namespace Server.Engines.Plants public static PlantHue GetNotBright(PlantHue plantHue) => plantHue & ~PlantHue.Bright; public static bool IsPrimary(PlantHue plantHue) => - plantHue == PlantHue.Red || plantHue == PlantHue.Blue || plantHue == PlantHue.Yellow; + plantHue is PlantHue.Red or PlantHue.Blue or PlantHue.Yellow; public static PlantHue Cross(PlantHue first, PlantHue second) { diff --git a/Projects/UOContent/Engines/Plants/PlantItem.cs b/Projects/UOContent/Engines/Plants/PlantItem.cs index edf59eab2..b99a0f7c7 100644 --- a/Projects/UOContent/Engines/Plants/PlantItem.cs +++ b/Projects/UOContent/Engines/Plants/PlantItem.cs @@ -67,7 +67,7 @@ namespace Server.Engines.Plants get => m_PlantStatus; set { - if (m_PlantStatus == value || value < PlantStatus.BowlOfDirt || value > PlantStatus.DeadTwigs) + if (m_PlantStatus == value || value is < PlantStatus.BowlOfDirt or > PlantStatus.DeadTwigs) { return; } @@ -151,7 +151,7 @@ namespace Server.Engines.Plants return true; } - if (!(RootParent is Mobile owner)) + if (RootParent is not Mobile owner) { return false; } @@ -491,7 +491,7 @@ namespace Server.Engines.Plants var full = false; - if (effect == PotionEffect.PoisonGreater || effect == PotionEffect.PoisonDeadly) + if (effect is PotionEffect.PoisonGreater or PotionEffect.PoisonDeadly) { if (PlantSystem.IsFullPoisonPotion) { @@ -535,9 +535,7 @@ namespace Server.Engines.Plants PlantSystem.StrengthPotion++; } } - else if (effect == PotionEffect.PoisonLesser || effect == PotionEffect.Poison || - effect == PotionEffect.CureLesser || effect == PotionEffect.Cure || - effect == PotionEffect.HealLesser || effect == PotionEffect.Heal || effect == PotionEffect.Strength) + else if (effect is PotionEffect.PoisonLesser or PotionEffect.Poison or PotionEffect.CureLesser or PotionEffect.Cure or PotionEffect.HealLesser or PotionEffect.Heal or PotionEffect.Strength) { message = 1053068; // This potion is not powerful enough to use on a plant! return false; diff --git a/Projects/UOContent/Engines/Plants/PlantSystem.cs b/Projects/UOContent/Engines/Plants/PlantSystem.cs index abecd633c..a99b425d9 100644 --- a/Projects/UOContent/Engines/Plants/PlantSystem.cs +++ b/Projects/UOContent/Engines/Plants/PlantSystem.cs @@ -393,7 +393,7 @@ namespace Server.Engines.Plants { var plant = plants[i]; - if (plant.IsGrowable && !(plant.RootParent is Mobile) && now >= plant.PlantSystem.NextGrowth) + if (plant.IsGrowable && plant.RootParent is not Mobile && now >= plant.PlantSystem.NextGrowth) { plant.PlantSystem.DoGrowthCheck(); } diff --git a/Projects/UOContent/Engines/Plants/PollinateTarget.cs b/Projects/UOContent/Engines/Plants/PollinateTarget.cs index a63727f5a..2c383557a 100644 --- a/Projects/UOContent/Engines/Plants/PollinateTarget.cs +++ b/Projects/UOContent/Engines/Plants/PollinateTarget.cs @@ -34,8 +34,7 @@ namespace Server.Engines.Plants } else { - if (!(targeted is PlantItem targ) || targ.PlantStatus >= PlantStatus.DecorativePlant || - targ.PlantStatus <= PlantStatus.BowlOfDirt) + if (targeted is not PlantItem targ || targ.PlantStatus is >= PlantStatus.DecorativePlant or <= PlantStatus.BowlOfDirt) { m_Plant.LabelTo(from, 1053070); // You can only pollinate other specially grown plants! } diff --git a/Projects/UOContent/Engines/Plants/ReproductionGump.cs b/Projects/UOContent/Engines/Plants/ReproductionGump.cs index 63439407f..f5699bc4b 100644 --- a/Projects/UOContent/Engines/Plants/ReproductionGump.cs +++ b/Projects/UOContent/Engines/Plants/ReproductionGump.cs @@ -129,8 +129,7 @@ namespace Server.Engines.Plants { var from = sender.Mobile; - if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant || - m_Plant.PlantStatus == PlantStatus.BowlOfDirt) + if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus is >= PlantStatus.DecorativePlant or PlantStatus.BowlOfDirt) { return; } diff --git a/Projects/UOContent/Engines/Plants/Seed.cs b/Projects/UOContent/Engines/Plants/Seed.cs index 98727af42..bb67f9e4b 100644 --- a/Projects/UOContent/Engines/Plants/Seed.cs +++ b/Projects/UOContent/Engines/Plants/Seed.cs @@ -152,7 +152,7 @@ namespace Server.Engines.Plants public override void OnAfterDuped(Item newItem) { - if (!(newItem is Seed newSeed)) + if (newItem is not Seed newSeed) { return; } diff --git a/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs b/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs index 1a46f0360..aa5eeedb8 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Items/EnchantedPaints.cs @@ -17,7 +17,7 @@ namespace Server.Engines.Quests.Collector { } - public override bool CanDrop(PlayerMobile player) => !(player.Quest is CollectorQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not CollectorQuest; public override void OnDoubleClick(Mobile from) { @@ -75,7 +75,7 @@ namespace Server.Engines.Quests.Collector { var qs = player.Quest; - if (!(qs is CollectorQuest)) + if (qs is not CollectorQuest) { return; } diff --git a/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs b/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs index c59401bf6..7806d403d 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Items/Obsidian.cs @@ -255,7 +255,7 @@ namespace Server.Engines.Quests.Collector protected override void OnTarget(Mobile from, object targeted) { - if (m_Obsidian.Deleted || m_Obsidian.Quantity >= m_Completed || !(targeted is Item targ)) + if (m_Obsidian.Deleted || m_Obsidian.Quantity >= m_Completed || targeted is not Item targ) { return; } diff --git a/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs b/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs index 561bfadfc..b72ba2f39 100644 --- a/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs +++ b/Projects/UOContent/Engines/Quests/Collector/Mobiles/Impresario.cs @@ -53,7 +53,7 @@ namespace Server.Engines.Quests.Collector { var qs = player.Quest; - if (!(qs is CollectorQuest)) + if (qs is not CollectorQuest) { return; } @@ -149,7 +149,7 @@ namespace Server.Engines.Quests.Collector { var qs = player.Quest; - if (!(qs is CollectorQuest)) + if (qs is not CollectorQuest) { return; } diff --git a/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs b/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs index 3ea47a4c3..02d648734 100644 --- a/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs +++ b/Projects/UOContent/Engines/Quests/Core/QuestSystem.cs @@ -431,7 +431,7 @@ namespace Server.Engines.Quests { inRestartPeriod = false; - if (!(check is PlayerMobile pm)) + if (check is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs b/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs index b6a490e08..5ce3407d6 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs @@ -83,7 +83,7 @@ namespace Server.Engines.Quests.Necro public static bool HasLostCallingScroll(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs index c02bdb619..0097997fa 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/CrystalCaveBarrier.cs @@ -25,7 +25,7 @@ namespace Server.Engines.Quests.Necro mob = creature.ControlMaster; } - if (!(mob is PlayerMobile pm)) + if (mob is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs index e893f2ff7..8c91b6a3f 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs @@ -22,7 +22,7 @@ namespace Server.Engines.Quests.Necro public override int LabelNumber => 1060149; // Calling of Kronus - public override bool CanDrop(PlayerMobile player) => !(player.Quest is DarkTidesQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not DarkTidesQuest; public override void OnDoubleClick(Mobile from) { @@ -31,7 +31,7 @@ namespace Server.Engines.Quests.Necro return; } - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs index e372f9c17..01e24fbd7 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/ScrollOfAbraxus.cs @@ -14,7 +14,7 @@ namespace Server.Engines.Quests.Necro public override int LabelNumber => 1028827; // Scroll of Abraxus - public override bool CanDrop(PlayerMobile player) => !(player.Quest is DarkTidesQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not DarkTidesQuest; public override void OnAdded(IEntity parent) { diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs index 7cadf48bd..2af0da317 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs @@ -86,7 +86,7 @@ namespace Server.Engines.Quests.Necro public override bool CanTalkTo(PlayerMobile to) { - if (!(to.Quest is DarkTidesQuest qs)) + if (to.Quest is not DarkTidesQuest qs) { return to.Quest == null && QuestSystem.CanOfferQuest(to, typeof(DarkTidesQuest)); } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs index 7719b2d7f..68a2241e9 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Objectives.cs @@ -127,7 +127,7 @@ namespace Server.Engines.Quests.Necro public override void CheckProgress() { if (System.From.Map != Map.Malas || !System.From.InRange(new Point3D(1076, 450, -84), 5) || - !SummonFamiliarSpell.Table.TryGetValue(System.From, out var bc) || !(bc is HordeMinionFamiliar hmf) || + !SummonFamiliarSpell.Table.TryGetValue(System.From, out var bc) || bc is not HordeMinionFamiliar hmf || !hmf.InRange(System.From, 5) || hmf.TargetLocation != null) { return; diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs index 19e7930ed..bf03061c2 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs @@ -74,7 +74,7 @@ namespace Server.Engines.Quests.Ninja public override void Slice() { if (!m_SentRadarConversion && - (From.Map != Map.Malas || From.X < 407 || From.X > 431 || From.Y < 801 || From.Y > 830)) + (From.Map != Map.Malas || From.X is < 407 or > 431 || From.Y is < 801 or > 830)) { m_SentRadarConversion = true; AddConversation(new RadarConversation()); @@ -99,7 +99,7 @@ namespace Server.Engines.Quests.Ninja public static bool HasLostNoteForZoel(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } @@ -119,7 +119,7 @@ namespace Server.Engines.Quests.Ninja public static bool HasLostEminosKatana(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs index b3ae1d647..a1e5a6e17 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/EminosKatana.cs @@ -13,7 +13,7 @@ namespace Server.Engines.Quests.Ninja public override int LabelNumber => 1063214; // Daimyo Emino's Katana - public override bool CanDrop(PlayerMobile player) => !(player.Quest is EminosUndertakingQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not EminosUndertakingQuest; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/NoteForZoel.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/NoteForZoel.cs index cd1d0dc6e..5aab1c067 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/NoteForZoel.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/Items/NoteForZoel.cs @@ -17,7 +17,7 @@ namespace Server.Engines.Quests.Ninja public override int LabelNumber => 1063186; // A Note for Zoel - public override bool CanDrop(PlayerMobile player) => !(player.Quest is EminosUndertakingQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not EminosUndertakingQuest; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs index 38946c006..bc66e7b7c 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs @@ -77,7 +77,7 @@ namespace Server.Engines.Quests.Samurai public override void Slice() { if (!m_SentRadarConversion && - (From.Map != Map.Malas || From.X < 360 || From.X > 400 || From.Y < 760 || From.Y > 780)) + (From.Map != Map.Malas || From.X is < 360 or > 400 || From.Y is < 760 or > 780)) { m_SentRadarConversion = true; AddConversation(new RadarConversation()); @@ -102,7 +102,7 @@ namespace Server.Engines.Quests.Samurai public static bool HasLostHaochisKatana(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisKatana.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisKatana.cs index b9992bcde..810ad0182 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisKatana.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HaochisKatana.cs @@ -13,7 +13,7 @@ namespace Server.Engines.Quests.Samurai public override int LabelNumber => 1063165; // Daimyo Haochi's Katana - public override bool CanDrop(PlayerMobile player) => !(player.Quest is HaochisTrialsQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not HaochisTrialsQuest; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs index 07e015e56..ce08640bb 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs @@ -30,7 +30,7 @@ namespace Server.Engines.Quests.Samurai if (!wasBurning && Burning) { - if (!(from is PlayerMobile player)) + if (@from is not PlayerMobile player) { return; } diff --git a/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs b/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs index e2140a2ca..dc889d0f4 100644 --- a/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs @@ -43,10 +43,10 @@ namespace Server.Engines.Quests.Matriarch if (redSolen) { - return from is BlackSolenInfiltratorWarrior || from is BlackSolenInfiltratorQueen; + return @from is BlackSolenInfiltratorWarrior or BlackSolenInfiltratorQueen; } - return from is RedSolenInfiltratorWarrior || from is RedSolenInfiltratorQueen; + return @from is RedSolenInfiltratorWarrior or RedSolenInfiltratorQueen; } public override void OnKill(BaseCreature creature, Container corpse) @@ -55,14 +55,14 @@ namespace Server.Engines.Quests.Matriarch if (redSolen) { - if (creature is BlackSolenInfiltratorWarrior || creature is BlackSolenInfiltratorQueen) + if (creature is BlackSolenInfiltratorWarrior or BlackSolenInfiltratorQueen) { CurProgress++; } } else { - if (creature is RedSolenInfiltratorWarrior || creature is RedSolenInfiltratorQueen) + if (creature is RedSolenInfiltratorWarrior or RedSolenInfiltratorQueen) { CurProgress++; } diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBlood.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBlood.cs index a1e7faaa7..f6bdda528 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBlood.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBlood.cs @@ -11,7 +11,7 @@ namespace Server.Engines.Quests.Haven { } - public override bool CanDrop(PlayerMobile player) => !(player.Quest is UzeraanTurmoilQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not UzeraanTurmoilQuest; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBone.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBone.cs index d1da95128..a4dfbf561 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBone.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestDaemonBone.cs @@ -11,7 +11,7 @@ namespace Server.Engines.Quests.Haven { } - public override bool CanDrop(PlayerMobile player) => !(player.Quest is UzeraanTurmoilQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not UzeraanTurmoilQuest; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestFertileDirt.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestFertileDirt.cs index c596f15cb..1f459e7c6 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestFertileDirt.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Items/QuestFertileDirt.cs @@ -11,7 +11,7 @@ namespace Server.Engines.Quests.Haven { } - public override bool CanDrop(PlayerMobile player) => !(player.Quest is UzeraanTurmoilQuest); + public override bool CanDrop(PlayerMobile player) => player.Quest is not UzeraanTurmoilQuest; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs index f59e7b3cd..91d2997b4 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs @@ -395,7 +395,7 @@ namespace Server.Engines.Quests.Haven public override bool IgnoreYoungProtection(Mobile from) { // This restriction continues until the end of the quest - if ((from is Zombie || from is Skeleton) && from.Map == Map.Trammel && from.X >= 3391 && from.X <= 3424 && + if (@from is Zombie or Skeleton && from.Map == Map.Trammel && from.X >= 3391 && from.X <= 3424 && from.Y >= 2639 && from.Y <= 2664) // Haven graveyard { return true; @@ -416,7 +416,7 @@ namespace Server.Engines.Quests.Haven public override void OnKill(BaseCreature creature, Container corpse) { - if ((creature is Zombie || creature is Skeleton) && corpse.Map == Map.Trammel && corpse.X >= 3391 && + if (creature is Zombie or Skeleton && corpse.Map == Map.Trammel && corpse.X >= 3391 && corpse.X <= 3424 && corpse.Y >= 2639 && corpse.Y <= 2664) // Haven graveyard { if (Utility.RandomDouble() < 0.25) diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs index a0cd9ba56..28b56908f 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs @@ -78,7 +78,7 @@ namespace Server.Engines.Quests.Haven public override void Slice() { if (!m_HasLeftTheMansion && - (From.Map != Map.Trammel || From.X < 3573 || From.X > 3611 || From.Y < 2568 || From.Y > 2606)) + (From.Map != Map.Trammel || From.X is < 3573 or > 3611 || From.Y is < 2568 or > 2606)) { m_HasLeftTheMansion = true; AddConversation(new RadarConversation()); @@ -110,7 +110,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostScrollOfPower(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } @@ -130,7 +130,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostFertileDirt(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } @@ -150,7 +150,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostDaemonBlood(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } @@ -170,7 +170,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostDaemonBone(Mobile from) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs b/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs index 916bab5f1..2051ab96c 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs @@ -145,7 +145,7 @@ namespace Server.Items return; } - if (!(targeted is Item i)) + if (targeted is not Item i) { from.SendLocalizedMessage(1070931); // You can only dye artifacts and enhanced magic items with this tub. } diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs b/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs index 57f412128..7603968e8 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs @@ -487,7 +487,7 @@ namespace Server.Items [Constructible] public PigmentsOfTokuno(PigmentType type = PigmentType.None) : this( type, - type == PigmentType.None || type >= PigmentType.FadedCoal ? 10 : 50 + type is PigmentType.None or >= PigmentType.FadedCoal ? 10 : 50 ) { } diff --git a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs index 676d4dd06..a4d2ede01 100644 --- a/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs +++ b/Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs @@ -135,7 +135,7 @@ namespace Server.Misc public static void HandleKill(Mobile victim, Mobile killer) { - if (DropEra == TreasuresOfTokunoEra.None || !(killer is PlayerMobile pm) || !(victim is BaseCreature bc) || + if (DropEra == TreasuresOfTokunoEra.None || killer is not PlayerMobile pm || victim is not BaseCreature bc || !CheckLocation(bc) || !CheckLocation(pm) || !killer.InRange(victim, 18)) { return; @@ -433,7 +433,7 @@ namespace Server.Gumps public override void HandleCancel(NetState sender) { - if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7)) + if (sender.Mobile is not PlayerMobile pm || !pm.InRange(m_Collector.Location, 7)) { return; } @@ -565,7 +565,7 @@ namespace Server.Gumps public override void HandleButtonResponse(NetState sender, int adjustedButton, ImageTileButtonInfo buttonInfo) { - if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7) || + if (sender.Mobile is not PlayerMobile pm || !pm.InRange(m_Collector.Location, 7) || !(pm.ToTItemsTurnedIn >= TreasuresOfTokuno.ItemsPerReward)) { return; @@ -627,7 +627,7 @@ namespace Server.Gumps public override void HandleCancel(NetState sender) { - if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7)) + if (sender.Mobile is not PlayerMobile pm || !pm.InRange(m_Collector.Location, 7)) { return; } diff --git a/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs b/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs index eeb92baa8..1ce3132cb 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/Character Statue Maker/CharacterStatue.cs @@ -613,7 +613,7 @@ namespace Server.Mobiles BaseHouse house = null; var loc = new Point3D(p); - if (targeted is Item item && !item.IsLockedDown && !item.IsSecure && !(item is AddonComponent)) + if (targeted is Item item && !item.IsLockedDown && !item.IsSecure && item is not AddonComponent) { from.SendLocalizedMessage(1076191); // Statues can only be placed in houses. return; diff --git a/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs b/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs index 39de782c7..d88dbf38f 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/RewardDemolitionGump.cs @@ -31,7 +31,7 @@ namespace Server.Gumps public override void OnResponse(NetState sender, RelayInfo info) { - if (!(m_Addon is Item item) || item.Deleted) + if (m_Addon is not Item item || item.Deleted) { return; } diff --git a/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs b/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs index 504de1247..3b6045386 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs @@ -83,7 +83,7 @@ namespace Server.Engines.VeteranRewards public static int GetRewardLevel(Mobile mob) { - if (!(mob.Account is Account acct)) + if (mob.Account is not Account acct) { return 0; } @@ -96,7 +96,7 @@ namespace Server.Engines.VeteranRewards public static bool HasHalfLevel(Mobile mob) { - if (!(mob.Account is Account acct)) + if (mob.Account is not Account acct) { return false; } @@ -115,7 +115,7 @@ namespace Server.Engines.VeteranRewards return false; } - if (!(mob.Account is Account acct)) + if (mob.Account is not Account acct) { return false; } @@ -133,7 +133,7 @@ namespace Server.Engines.VeteranRewards public static void ComputeRewardInfo(Mobile mob, out int cur, out int max, out int level) { - if (!(mob.Account is Account acct)) + if (mob.Account is not Account acct) { cur = max = level = 0; return; @@ -170,7 +170,7 @@ namespace Server.Engines.VeteranRewards public static bool CheckIsUsableBy(Mobile from, Item item, object[] args = null) { - var isRelaxedRules = item is DyeTub || item is MonsterStatuette; + var isRelaxedRules = item is DyeTub or MonsterStatuette; var type = item.GetType(); @@ -578,8 +578,7 @@ namespace Server.Engines.VeteranRewards ComputeRewardInfo(m, out var cur, out var max, out var level); - if (m.SkillsCap == 7000 || m.SkillsCap == 7050 || m.SkillsCap == 7100 || - m.SkillsCap == 7150 || m.SkillsCap == 7200) + if (m.SkillsCap is 7000 or 7050 or 7100 or 7150 or 7200) { level = Math.Clamp(level, 0, 4); diff --git a/Projects/UOContent/Engines/Virtues/Sacrifice.cs b/Projects/UOContent/Engines/Virtues/Sacrifice.cs index 9ce3c9be8..8679a0b06 100644 --- a/Projects/UOContent/Engines/Virtues/Sacrifice.cs +++ b/Projects/UOContent/Engines/Virtues/Sacrifice.cs @@ -190,8 +190,7 @@ namespace Server return false; } - return m is Lich || m is Succubus || m is Daemon || m is EvilMage || m is EnslavedGargoyle || - m is GargoyleEnforcer; + return m is Lich or Succubus or Daemon or EvilMage or EnslavedGargoyle or GargoyleEnforcer; } private class InternalTarget : Target diff --git a/Projects/UOContent/Gumps/AdminGump.cs b/Projects/UOContent/Gumps/AdminGump.cs index 25777e491..7f1b1deb6 100644 --- a/Projects/UOContent/Gumps/AdminGump.cs +++ b/Projects/UOContent/Gumps/AdminGump.cs @@ -476,7 +476,7 @@ namespace Server.Gumps for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index) { - if (!(m_List[index] is NetState ns)) + if (m_List[index] is not NetState ns) { continue; } @@ -517,7 +517,7 @@ namespace Server.Gumps } case AdminGumpPage.ClientInfo: { - if (!(state is Mobile m)) + if (state is not Mobile m) { break; } @@ -738,7 +738,7 @@ namespace Server.Gumps for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index) { - if (!(m_List[index] is Account a)) + if (m_List[index] is not Account a) { continue; } @@ -804,7 +804,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_ChangePassword: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -826,7 +826,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_ChangeAccess: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -863,7 +863,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_Information: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -948,7 +948,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_Access: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -974,7 +974,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_Access_ClientIPs: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -1046,7 +1046,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_Access_Restrictions: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -1120,7 +1120,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_Characters: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -1170,7 +1170,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_Comments: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -1209,7 +1209,7 @@ namespace Server.Gumps } case AdminGumpPage.AccountDetails_Tags: { - if (!(state is Account a)) + if (state is not Account a) { break; } @@ -1308,7 +1308,7 @@ namespace Server.Gumps { AddFirewallHeader(); - if (!(state is Firewall.IFirewallEntry firewallEntry)) + if (state is not Firewall.IFirewallEntry firewallEntry) { break; } @@ -2657,7 +2657,7 @@ namespace Server.Gumps if (m_List != null && index >= 0 && index < m_List.Count) { - if (!(m_List[index] is NetState ns)) + if (m_List[index] is not NetState ns) { break; } @@ -2926,7 +2926,7 @@ namespace Server.Gumps case 10: case 11: { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -2961,7 +2961,7 @@ namespace Server.Gumps } case 12: { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3004,7 +3004,7 @@ namespace Server.Gumps } case 16: // view shared { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3055,7 +3055,7 @@ namespace Server.Gumps } case 17: // ban shared { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3119,7 +3119,7 @@ namespace Server.Gumps } case 18: // firewall all { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3156,7 +3156,7 @@ namespace Server.Gumps } case 19: // add { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3220,7 +3220,7 @@ namespace Server.Gumps case 23: case 24: { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3264,7 +3264,7 @@ namespace Server.Gumps } case 25: { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3291,7 +3291,7 @@ namespace Server.Gumps { var list = m_List; - if (list == null || !(m_State is List rads)) + if (list == null || m_State is not List rads) { break; } @@ -3331,7 +3331,7 @@ namespace Server.Gumps { var list = m_List; - if (list == null || !(m_State is List rads)) + if (list == null || m_State is not List rads) { break; } @@ -3373,7 +3373,7 @@ namespace Server.Gumps } case 29: // Mark all { - if (m_List == null || !(m_State is List)) + if (m_List == null || m_State is not List) { break; } @@ -3564,7 +3564,7 @@ namespace Server.Gumps } case 36: // Clear login addresses { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -3844,7 +3844,7 @@ namespace Server.Gumps } case 7: { - if (!(m_State is Mobile m)) + if (m_State is not Mobile m) { break; } @@ -4039,7 +4039,7 @@ namespace Server.Gumps { if (index < m_List?.Count) { - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -4087,12 +4087,12 @@ namespace Server.Gumps { var obj = m_List[index]; - if (!(obj is IPAddress ip)) + if (obj is not IPAddress ip) { break; } - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } @@ -4143,7 +4143,7 @@ namespace Server.Gumps break; } - if (!(m_State is Account a)) + if (m_State is not Account a) { break; } diff --git a/Projects/UOContent/Gumps/CommentsGump.cs b/Projects/UOContent/Gumps/CommentsGump.cs index 1a31e3ecc..24504383c 100644 --- a/Projects/UOContent/Gumps/CommentsGump.cs +++ b/Projects/UOContent/Gumps/CommentsGump.cs @@ -71,7 +71,7 @@ namespace Server.Gumps private static void OnTarget(Mobile from, object target) { - if (!(target is Mobile m) || !m.Player) + if (target is not Mobile m || !m.Player) { from.SendMessage("You must target a player."); return; diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs index e3ef78fac..7c8052025 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildGump.cs @@ -40,7 +40,7 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { - if (!(sender.Mobile is PlayerMobile pm)) + if (sender.Mobile is not PlayerMobile pm) { return; } @@ -71,11 +71,11 @@ namespace Server.Guilds } public static bool IsLeader(Mobile m, Guild g) => - !(m.Deleted || g.Disbanded || !(m is PlayerMobile) || + !(m.Deleted || g.Disbanded || m is not PlayerMobile || m.AccessLevel < AccessLevel.GameMaster && g.Leader != m); public static bool IsMember(Mobile m, Guild g) => - !(m.Deleted || g.Disbanded || !(m is PlayerMobile) || + !(m.Deleted || g.Disbanded || m is not PlayerMobile || m.AccessLevel < AccessLevel.GameMaster && !g.IsMember(m)); public static bool CheckProfanity(string s, int maxLength = 50) @@ -96,7 +96,7 @@ namespace Server.Guilds { var c = s[i]; - if ((c < 'a' || c > 'z') && (c < '0' || c > '9')) + if (c is < 'a' or > 'z' && c is < '0' or > '9') { var except = false; diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs index 7271b31ab..8b09c06b2 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/BaseGuildListGump.cs @@ -164,7 +164,7 @@ namespace Server.Guilds { base.OnResponse(sender, info); - if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + if (sender.Mobile is not PlayerMobile pm || !IsMember(pm, guild)) { return; } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs index 55368bca9..022ba2651 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/Create Guild Gump.cs @@ -48,7 +48,7 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { - if (!(sender.Mobile is PlayerMobile pm) || pm.Guild != null) + if (sender.Mobile is not PlayerMobile pm || pm.Guild != null) { return; // Sanity } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs index 18f16b1d7..79e11341d 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/DiplomacyGump.cs @@ -208,15 +208,8 @@ namespace Server.Guilds { case GuildDisplayType.Relations: { - // if (!( guild.IsWar( g ) || guild.IsAlly( g ) )) - - if (!(guild.FindActiveWar(g) != null || guild.IsAlly(g)) - ) // As per OSI, only the guild leader wars show up under the sorting by relation - { - return true; - } - - return false; + // As per OSI, only the guild leader wars show up under the sorting by relation + return !(guild.FindActiveWar(g) != null || guild.IsAlly(g)); } case GuildDisplayType.AwaitingAction: { @@ -247,7 +240,7 @@ namespace Server.Guilds { base.OnResponse(sender, info); - if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + if (sender.Mobile is not PlayerMobile pm || !IsMember(pm, guild)) { return; } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs index a23357827..c5bf35787 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs @@ -68,7 +68,7 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { - if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild) || !IsMember(m_Member, guild)) + if (sender.Mobile is not PlayerMobile pm || !IsMember(pm, guild) || !IsMember(m_Member, guild)) { return; } @@ -244,12 +244,12 @@ namespace Server.Guilds public void SetTitle_Callback(Mobile from, string text) { - if (!(from is PlayerMobile pm) || m_Member == null) + if (@from is not PlayerMobile pm || m_Member == null) { return; } - if (!(m_Member.Guild is Guild g) || !IsMember(pm, g) || + if (m_Member.Guild is not Guild g || !IsMember(pm, g) || !(pm.GuildRank.GetFlag(RankFlags.CanSetGuildTitle) && (pm.GuildRank.Rank > m_Member.GuildRank.Rank || pm == m_Member))) { diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs index c31e443db..eedea7a6b 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildRosterGump.cs @@ -101,7 +101,7 @@ namespace Server.Guilds { base.OnResponse(sender, info); - if (!(sender.Mobile is PlayerMobile pm) || !IsMember(pm, guild)) + if (sender.Mobile is not PlayerMobile pm || !IsMember(pm, guild)) { return; } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs index 9e5dca714..b92cd52aa 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs @@ -715,7 +715,7 @@ namespace Server.Guilds public void CreateAlliance_Callback(Mobile from, string text) { - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Gumps/PlayerVendorGumps.cs b/Projects/UOContent/Gumps/PlayerVendorGumps.cs index c12a8589d..b525b59d6 100644 --- a/Projects/UOContent/Gumps/PlayerVendorGumps.cs +++ b/Projects/UOContent/Gumps/PlayerVendorGumps.cs @@ -258,7 +258,7 @@ namespace Server.Gumps { var from = sender.Mobile; - if (info.ButtonID == 1 || info.ButtonID == 2) // See goods or Customize + if (info.ButtonID is 1 or 2) // See goods or Customize { m_Vendor.CheckTeleport(from); } diff --git a/Projects/UOContent/Gumps/Props/PropsGump.cs b/Projects/UOContent/Gumps/Props/PropsGump.cs index b0be1bdfb..e7b43f0fc 100644 --- a/Projects/UOContent/Gumps/Props/PropsGump.cs +++ b/Projects/UOContent/Gumps/Props/PropsGump.cs @@ -458,7 +458,7 @@ namespace Server.Gumps return Array.Empty(); } - if (!(attrs[0] is CustomEnumAttribute ce)) + if (attrs[0] is not CustomEnumAttribute ce) { return Array.Empty(); } diff --git a/Projects/UOContent/Gumps/ReportMurderer.cs b/Projects/UOContent/Gumps/ReportMurderer.cs index 1a96ca70f..6394a76bd 100644 --- a/Projects/UOContent/Gumps/ReportMurderer.cs +++ b/Projects/UOContent/Gumps/ReportMurderer.cs @@ -63,7 +63,7 @@ namespace Server.Gumps var ourKarma = g.Karma; var innocent = n == Notoriety.Innocent; - var criminal = n == Notoriety.Criminal || n == Notoriety.Murderer; + var criminal = n is Notoriety.Criminal or Notoriety.Murderer; var fameAward = m.Fame / 200; var karmaAward = 0; diff --git a/Projects/UOContent/Gumps/VendorRentalGumps.cs b/Projects/UOContent/Gumps/VendorRentalGumps.cs index 84872e6a0..255bb1ce9 100644 --- a/Projects/UOContent/Gumps/VendorRentalGumps.cs +++ b/Projects/UOContent/Gumps/VendorRentalGumps.cs @@ -45,7 +45,7 @@ namespace Server.Gumps AddImageTiled(70, 80, 230, 2, 0x23C5); } - if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) + if (type is GumpType.UnlockedContract or GumpType.LockedContract) { AddButton(30, 96, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 2); } @@ -53,7 +53,7 @@ namespace Server.Gumps AddHtmlLocalized(50, 95, 150, 20, 1062354, 0x1); // Contract Length AddHtmlLocalized(230, 95, 270, 20, duration.Name, 0x1); - if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) + if (type is GumpType.UnlockedContract or GumpType.LockedContract) { AddButton(30, 116, 0x15E1, 0x15E5, 1); } @@ -76,7 +76,7 @@ namespace Server.Gumps AddImage(49, 170, 0x61); AddHtmlLocalized(60, 170, 250, 20, 1062355, 0x1); // Renew On Expiration? - if (type == GumpType.LockedContract || type == GumpType.UnlockedContract || type == GumpType.VendorLandlord) + if (type is GumpType.LockedContract or GumpType.UnlockedContract or GumpType.VendorLandlord) { AddButton(30, 192, 0x15E1, 0x15E5, 3); } @@ -113,7 +113,7 @@ namespace Server.Gumps AddButton(67, 295, 0x15E1, 0x15E5, 5); AddHtmlLocalized(85, 294, 270, 20, 1062358, 0x28); // Offer Contract To Someone } - else if (type == GumpType.VendorLandlord || type == GumpType.VendorRenter) + else if (type is GumpType.VendorLandlord or GumpType.VendorRenter) { if (type == GumpType.VendorLandlord) { @@ -127,7 +127,7 @@ namespace Server.Gumps AddLabel(120, 293, 0x64, renter != null ? renter.Name : ""); } - if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) + if (type is GumpType.UnlockedContract or GumpType.LockedContract) { AddPage(2); @@ -348,7 +348,7 @@ namespace Server.Gumps return; } - if (!(targeted is Mobile mob) || !mob.Player || !mob.Alive || mob == from) + if (targeted is not Mobile mob || !mob.Player || !mob.Alive || mob == from) { from.SendLocalizedMessage(1071984); // That is not a valid target for a rental contract! } diff --git a/Projects/UOContent/Gumps/ViewHousesGump.cs b/Projects/UOContent/Gumps/ViewHousesGump.cs index b140102de..09078026a 100644 --- a/Projects/UOContent/Gumps/ViewHousesGump.cs +++ b/Projects/UOContent/Gumps/ViewHousesGump.cs @@ -180,7 +180,7 @@ namespace Server.Gumps { var list = new List(); - if (!(owner.Account is Account acct)) + if (owner.Account is not Account acct) { list.AddRange(BaseHouse.GetHouses(owner)); } diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index 8841ab65e..3384eec0f 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -153,7 +153,7 @@ namespace Server.Engines.Events return; } - if (!(targ is Mobile)) + if (targ is not Mobile) { from.SendLocalizedMessage(1076781); /* There is little chance of getting candy from that! */ return; diff --git a/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs b/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs index 8acec3394..7197c531e 100644 --- a/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs +++ b/Projects/UOContent/Holiday Stuff/Halloween/2006/Items/HalloweenPumpkin.cs @@ -62,7 +62,7 @@ namespace Server.Items public override bool OnDragLift(Mobile from) { - if (Name == null && (ItemID == 0x4694 || ItemID == 0x4691 || ItemID == 0x4698 || ItemID == 0x4695)) + if (Name == null && ItemID is 0x4694 or 0x4691 or 0x4698 or 0x4695) { if (Utility.RandomBool()) { diff --git a/Projects/UOContent/Items/Addons/DartBoard.cs b/Projects/UOContent/Items/Addons/DartBoard.cs index 52c4cbd55..967b27fd8 100644 --- a/Projects/UOContent/Items/Addons/DartBoard.cs +++ b/Projects/UOContent/Items/Addons/DartBoard.cs @@ -41,11 +41,11 @@ namespace Server.Items } else if (East) { - canThrow = dir == Direction.Left || dir == Direction.West || dir == Direction.Up; + canThrow = dir is Direction.Left or Direction.West or Direction.Up; } else { - canThrow = dir == Direction.Up || dir == Direction.North || dir == Direction.Right; + canThrow = dir is Direction.Up or Direction.North or Direction.Right; } if (canThrow) @@ -60,7 +60,7 @@ namespace Server.Items public void Throw(Mobile from) { - if (!(from.Weapon is BaseKnife knife)) + if (@from.Weapon is not BaseKnife knife) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500751); // Try holding a knife... return; diff --git a/Projects/UOContent/Items/Armor/BaseArmor.cs b/Projects/UOContent/Items/Armor/BaseArmor.cs index 55bbe8a65..dd79ac923 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.cs @@ -598,7 +598,7 @@ namespace Server.Items ); // Not sure since when, but right now 15 points are added, not 14. } - if (Core.ML && !(this is BaseShield)) + if (Core.ML && this is not BaseShield) { var bonus = (int)(from.Skills.ArmsLore.Value / 20); @@ -820,7 +820,7 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { - if (!(newItem is BaseArmor armor)) + if (newItem is not BaseArmor armor) { return; } diff --git a/Projects/UOContent/Items/Books/BookPackets.cs b/Projects/UOContent/Items/Books/BookPackets.cs index 303bb34e0..6eee9c451 100644 --- a/Projects/UOContent/Items/Books/BookPackets.cs +++ b/Projects/UOContent/Items/Books/BookPackets.cs @@ -33,7 +33,7 @@ namespace Server.Items { var from = state.Mobile; - if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable || + if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBook book || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) { return; @@ -52,7 +52,7 @@ namespace Server.Items { var from = state.Mobile; - if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable || + if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBook book || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) { return; @@ -88,7 +88,7 @@ namespace Server.Items { var from = state.Mobile; - if (!(World.FindItem((Serial)reader.ReadUInt32()) is BaseBook book) || !book.Writable || + if (World.FindItem((Serial)reader.ReadUInt32()) is not BaseBook book || !book.Writable || !from.InRange(book.GetWorldLocation(), 1) || !book.IsAccessibleTo(from)) { return; diff --git a/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs b/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs index 1992b7c68..bd44f0a7f 100644 --- a/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs +++ b/Projects/UOContent/Items/Construction/Doors/BaseDoor.cs @@ -144,7 +144,7 @@ namespace Server.Items private static void Link_OnFirstTarget(Mobile from, object targeted) { - if (!(targeted is BaseDoor door)) + if (targeted is not BaseDoor door) { from.BeginTarget(-1, false, TargetFlags.None, Link_OnFirstTarget); from.SendMessage("That is not a door. Try again."); @@ -158,7 +158,7 @@ namespace Server.Items private static void Link_OnSecondTarget(Mobile from, object targeted, BaseDoor first) { - if (!(targeted is BaseDoor second)) + if (targeted is not BaseDoor second) { from.BeginTarget(-1, false, TargetFlags.None, Link_OnSecondTarget, first); from.SendMessage("That is not a door. Try again."); @@ -180,7 +180,7 @@ namespace Server.Items private static void ChainLink_OnTarget(Mobile from, object targeted, List list) { - if (!(targeted is BaseDoor door)) + if (targeted is not BaseDoor door) { from.BeginTarget(-1, false, TargetFlags.None, ChainLink_OnTarget, list); from.SendMessage("That is not a door. Try again."); @@ -328,8 +328,8 @@ namespace Server.Items { var item = items[i]; - if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y) && - !(item is BaseDoor)) + if (item is not BaseMulti && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y) && + item is not BaseDoor) { var id = item.ItemData; var surface = id.Surface; diff --git a/Projects/UOContent/Items/Construction/Misc/Vines.cs b/Projects/UOContent/Items/Construction/Misc/Vines.cs index e45923ebd..f561050c2 100644 --- a/Projects/UOContent/Items/Construction/Misc/Vines.cs +++ b/Projects/UOContent/Items/Construction/Misc/Vines.cs @@ -10,7 +10,7 @@ namespace Server.Items [Constructible] public Vines(int v) : base(0xCEB) { - if (v < 0 || v > 7) + if (v is < 0 or > 7) { v = 0; } diff --git a/Projects/UOContent/Items/Containers/Container.cs b/Projects/UOContent/Items/Containers/Container.cs index f9c92bbcc..1fce1751a 100644 --- a/Projects/UOContent/Items/Containers/Container.cs +++ b/Projects/UOContent/Items/Containers/Container.cs @@ -76,7 +76,7 @@ namespace Server.Items { var item = list[i]; - if (!(item is Container) && item.StackWith(from, dropped, false)) + if (item is not Container && item.StackWith(from, dropped, false)) { return true; } diff --git a/Projects/UOContent/Items/Containers/FillableContainers.cs b/Projects/UOContent/Items/Containers/FillableContainers.cs index 72d371803..54ccdd410 100644 --- a/Projects/UOContent/Items/Containers/FillableContainers.cs +++ b/Projects/UOContent/Items/Containers/FillableContainers.cs @@ -646,11 +646,11 @@ namespace Server.Items (int)KeyType.Rusty ); } - else if (item is Arrow || item is Bolt) + else if (item is Arrow or Bolt) { item.Amount = Utility.RandomMinMax(2, 6); } - else if (item is Bandage || item is Lockpick) + else if (item is Bandage or Lockpick) { item.Amount = Utility.RandomMinMax(1, 3); } diff --git a/Projects/UOContent/Items/Containers/FurnitureContainer.cs b/Projects/UOContent/Items/Containers/FurnitureContainer.cs index ea41f73d3..07dbe1597 100644 --- a/Projects/UOContent/Items/Containers/FurnitureContainer.cs +++ b/Projects/UOContent/Items/Containers/FurnitureContainer.cs @@ -356,7 +356,7 @@ namespace Server.Items return false; } - if (c is Armoire || c is FancyArmoire) + if (c is Armoire or FancyArmoire) { Timer t = new FurnitureTimer(c, m); t.Start(); @@ -382,7 +382,7 @@ namespace Server.Items t.Stop(); } - if (c is Armoire || c is FancyArmoire) + if (c is Armoire or FancyArmoire) { c.ItemID = c.ItemID switch { diff --git a/Projects/UOContent/Items/Containers/SalvageBag.cs b/Projects/UOContent/Items/Containers/SalvageBag.cs index da47e9740..3d8be35dc 100644 --- a/Projects/UOContent/Items/Containers/SalvageBag.cs +++ b/Projects/UOContent/Items/Containers/SalvageBag.cs @@ -157,13 +157,12 @@ namespace Server.Items { foreach (var i in Items) { - if (!(i is IScissorable) || i.Deleted) + if (i is not IScissorable || i.Deleted) { continue; } - if (i is BaseClothing || i is Cloth || i is BoltOfCloth || i is Hides || i is BonePile || - i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Leather) + if (i is BaseClothing or Cloth or BoltOfCloth or Hides or BonePile || i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Leather) { return true; } @@ -249,7 +248,7 @@ namespace Server.Items { var item = scissorables[i]; - if (!(item is IScissorable scissorable)) + if (item is not IScissorable scissorable) { continue; } diff --git a/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs b/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs index acd638366..cf3e814a4 100644 --- a/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs +++ b/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs @@ -110,7 +110,7 @@ namespace Server.Items return; } - if (!(obj is SwampDragon pet) || pet.HasBarding) + if (obj is not SwampDragon pet || pet.HasBarding) { from.SendLocalizedMessage(1053025); // That is not an unarmored swamp dragon. } diff --git a/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs b/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs index a6b999b71..847536294 100644 --- a/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs +++ b/Projects/UOContent/Items/Deeds/HairRestylingDeed.cs @@ -146,7 +146,7 @@ namespace Server.Items return; } - if (info.ButtonID < 1 || info.ButtonID > 10) + if (info.ButtonID is < 1 or > 10) { return; } diff --git a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs index ea3fec3b1..9f3eb7962 100644 --- a/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs +++ b/Projects/UOContent/Items/Deeds/HolidayTreeDeed.cs @@ -89,7 +89,7 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted, HolidayTreeType type) { - if (!(targeted is IPoint3D p)) + if (targeted is not IPoint3D p) { return; } diff --git a/Projects/UOContent/Items/Deeds/VendorRentalContract.cs b/Projects/UOContent/Items/Deeds/VendorRentalContract.cs index 437d4d0f4..6c37f9f55 100644 --- a/Projects/UOContent/Items/Deeds/VendorRentalContract.cs +++ b/Projects/UOContent/Items/Deeds/VendorRentalContract.cs @@ -274,7 +274,7 @@ namespace Server.Items return; } - if (!(targeted is IPoint3D location)) + if (targeted is not IPoint3D location) { return; } diff --git a/Projects/UOContent/Items/Food/Beverage.cs b/Projects/UOContent/Items/Food/Beverage.cs index b3c02eb83..91edd8426 100644 --- a/Projects/UOContent/Items/Food/Beverage.cs +++ b/Projects/UOContent/Items/Food/Beverage.cs @@ -262,7 +262,7 @@ namespace Server.Items public override int ComputeItemID() { - if (ItemID == 0x99A || ItemID == 0x9B3 || ItemID == 0x9BF || ItemID == 0x9CB) + if (ItemID is 0x99A or 0x9B3 or 0x9BF or 0x9CB) { return ItemID; } @@ -420,7 +420,7 @@ namespace Server.Items { if (IsEmpty) { - if (ItemID == 0x9A7 || ItemID == 0xFF7) + if (ItemID is 0x9A7 or 0xFF7) { return ItemID; } @@ -477,7 +477,7 @@ namespace Server.Items } case BeverageType.Water: { - if (ItemID == 0xFF8 || ItemID == 0xFF9 || ItemID == 0x1F9E) + if (ItemID is 0xFF8 or 0xFF9 or 0x1F9E) { return ItemID; } @@ -854,7 +854,7 @@ namespace Server.Items { var qs = player.Quest; - if (!(qs is WitchApprenticeQuest)) + if (qs is not WitchApprenticeQuest) { return; } @@ -986,7 +986,7 @@ namespace Server.Items item.Pour(from, this); } else if (targ is AddonComponent component && - (component.Addon is WaterVatEast || component.Addon is WaterVatSouth) && + component.Addon is WaterVatEast or WaterVatSouth && Content == BeverageType.Water) { if (from is PlayerMobile player) @@ -1070,7 +1070,7 @@ namespace Server.Items for (var i = 0; i < items.Length; ++i) { - if (!(items[i] is BaseBeverage bev) || bev.Content != content || bev.IsEmpty) + if (items[i] is not BaseBeverage bev || bev.Content != content || bev.IsEmpty) { continue; } diff --git a/Projects/UOContent/Items/Food/Cooking.cs b/Projects/UOContent/Items/Food/Cooking.cs index 8b17e5a8f..1d74d028c 100644 --- a/Projects/UOContent/Items/Food/Cooking.cs +++ b/Projects/UOContent/Items/Food/Cooking.cs @@ -44,7 +44,7 @@ namespace Server.Items return; } - if (!(targeted is Item targetItem) || targetItem.Deleted) + if (targeted is not Item targetItem || targetItem.Deleted) { return; } @@ -390,7 +390,7 @@ namespace Server.Items { Delete(); } - else if (m_Quantity < 20 && (ItemID == 0x1039 || ItemID == 0x1045)) + else if (m_Quantity < 20 && ItemID is 0x1039 or 0x1045) { ++ItemID; } @@ -440,7 +440,7 @@ namespace Server.Items return; } - if (ItemID == 0x1039 || ItemID == 0x1045) + if (ItemID is 0x1039 or 0x1045) { ++ItemID; } diff --git a/Projects/UOContent/Items/Games/BaseBoard.cs b/Projects/UOContent/Items/Games/BaseBoard.cs index f9f75c2a5..8426bcb84 100644 --- a/Projects/UOContent/Items/Games/BaseBoard.cs +++ b/Projects/UOContent/Items/Games/BaseBoard.cs @@ -116,7 +116,7 @@ namespace Server.Items public static bool ValidateDefault(Mobile from, BaseBoard board) => !board.Deleted && (from.AccessLevel >= AccessLevel.GameMaster || from.Alive && - (board.IsChildOf(from.Backpack) || !(board.RootParent is Mobile) && + (board.IsChildOf(from.Backpack) || board.RootParent is not Mobile && board.Map == from.Map && from.InRange(board.GetWorldLocation(), 1) && BaseHouse.FindHouseAt(board)?.IsOwner(from) == true)); diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs index 9f022e998..2d9d694be 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs @@ -33,7 +33,7 @@ namespace Server.Engines.Mahjong public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) { - if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down) + if (direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down) { return new MahjongPieceDim(position, 40, 20); } diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs index ddc373d55..e9d3bf628 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongTile.cs @@ -51,7 +51,7 @@ namespace Server.Engines.Mahjong public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) { - if (direction == MahjongPieceDirection.Up || direction == MahjongPieceDirection.Down) + if (direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down) { return new MahjongPieceDim(position, 20, 30); } diff --git a/Projects/UOContent/Items/Guilds/Guildstone.cs b/Projects/UOContent/Items/Guilds/Guildstone.cs index 8191d8505..f002a89b2 100644 --- a/Projects/UOContent/Items/Guilds/Guildstone.cs +++ b/Projects/UOContent/Items/Guilds/Guildstone.cs @@ -431,7 +431,7 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted) { - if (!(targeted is IPoint3D p) || Deleted) + if (targeted is not IPoint3D p || Deleted) { return; } diff --git a/Projects/UOContent/Items/Jewels/BaseJewel.cs b/Projects/UOContent/Items/Jewels/BaseJewel.cs index b049b8876..ac7503be4 100644 --- a/Projects/UOContent/Items/Jewels/BaseJewel.cs +++ b/Projects/UOContent/Items/Jewels/BaseJewel.cs @@ -195,7 +195,7 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { - if (!(newItem is BaseJewel jewel)) + if (newItem is not BaseJewel jewel) { return; } diff --git a/Projects/UOContent/Items/Lights/BaseEquippableLight.cs b/Projects/UOContent/Items/Lights/BaseEquippableLight.cs index 3894733cd..5310b457c 100644 --- a/Projects/UOContent/Items/Lights/BaseEquippableLight.cs +++ b/Projects/UOContent/Items/Lights/BaseEquippableLight.cs @@ -11,7 +11,7 @@ namespace Server.Items public override void Ignite() { - if (!(Parent is Mobile) && RootParent is Mobile holder) + if (Parent is not Mobile && RootParent is Mobile holder) { if (holder.EquipItem(this)) { diff --git a/Projects/UOContent/Items/Lights/CandleSkull.cs b/Projects/UOContent/Items/Lights/CandleSkull.cs index f82c6fb0f..049a426a3 100644 --- a/Projects/UOContent/Items/Lights/CandleSkull.cs +++ b/Projects/UOContent/Items/Lights/CandleSkull.cs @@ -29,7 +29,7 @@ namespace Server.Items { get { - if (ItemID == 0x1583 || ItemID == 0x1854) + if (ItemID is 0x1583 or 0x1854) { return 0x1854; } @@ -42,7 +42,7 @@ namespace Server.Items { get { - if (ItemID == 0x1853 || ItemID == 0x1584) + if (ItemID is 0x1853 or 0x1584) { return 0x1853; } diff --git a/Projects/UOContent/Items/Lights/Lantern.cs b/Projects/UOContent/Items/Lights/Lantern.cs index a925cf884..50635bda3 100644 --- a/Projects/UOContent/Items/Lights/Lantern.cs +++ b/Projects/UOContent/Items/Lights/Lantern.cs @@ -29,7 +29,7 @@ namespace Server.Items { get { - if (ItemID == 0xA15 || ItemID == 0xA17) + if (ItemID is 0xA15 or 0xA17) { return ItemID; } diff --git a/Projects/UOContent/Items/Maps/MapItemPackets.cs b/Projects/UOContent/Items/Maps/MapItemPackets.cs index a413e6213..08229830c 100644 --- a/Projects/UOContent/Items/Maps/MapItemPackets.cs +++ b/Projects/UOContent/Items/Maps/MapItemPackets.cs @@ -29,7 +29,7 @@ namespace Server.Network { var from = state.Mobile; - if (!(World.FindItem((Serial)reader.ReadUInt32()) is MapItem map)) + if (World.FindItem((Serial)reader.ReadUInt32()) is not MapItem map) { return; } diff --git a/Projects/UOContent/Items/Misc/Bola.cs b/Projects/UOContent/Items/Misc/Bola.cs index 67bac32f3..69ab24beb 100644 --- a/Projects/UOContent/Items/Misc/Bola.cs +++ b/Projects/UOContent/Items/Misc/Bola.cs @@ -68,13 +68,13 @@ namespace Server.Items new Bola().MoveToWorld(to.Location, to.Map); } - if (to is ChaosDragoon || to is ChaosDragoonElite) + if (to is ChaosDragoon or ChaosDragoonElite) { from.SendLocalizedMessage(1042047); // You fail to knock the rider from its mount. } var mt = to.Mount; - if (mt != null && !(to is ChaosDragoon || to is ChaosDragoonElite)) + if (mt != null && !(to is ChaosDragoon or ChaosDragoonElite)) { mt.Rider = null; } diff --git a/Projects/UOContent/Items/Misc/CommunicationCrystals.cs b/Projects/UOContent/Items/Misc/CommunicationCrystals.cs index a8605de49..357720994 100644 --- a/Projects/UOContent/Items/Misc/CommunicationCrystals.cs +++ b/Projects/UOContent/Items/Misc/CommunicationCrystals.cs @@ -121,7 +121,7 @@ namespace Server.Items public override void OnSpeech(SpeechEventArgs e) { - if (!Active || Receivers.Count == 0 || RootParent != null && !(RootParent is Mobile)) + if (!Active || Receivers.Count == 0 || RootParent != null && RootParent is not Mobile) { return; } diff --git a/Projects/UOContent/Items/Misc/Corpses/Corpse.cs b/Projects/UOContent/Items/Misc/Corpses/Corpse.cs index 3960d6383..766b5989e 100644 --- a/Projects/UOContent/Items/Misc/Corpses/Corpse.cs +++ b/Projects/UOContent/Items/Misc/Corpses/Corpse.cs @@ -789,7 +789,7 @@ namespace Server.Items public bool DevourCorpse() { - if (Devoured || Deleted || Killer?.Deleted != false || !Killer.Alive || !(Killer is IDevourer devourer) || + if (Devoured || Deleted || Killer?.Deleted != false || !Killer.Alive || Killer is not IDevourer devourer || Owner?.Deleted != false) { return false; @@ -1003,8 +1003,7 @@ namespace Server.Items var item = items[i]; var loc = item.Location; - if (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair || !item.Movable || - !GetRestoreInfo(item, ref loc)) + if (item.Layer is Layer.Hair or Layer.FacialHair || !item.Movable || !GetRestoreInfo(item, ref loc)) { continue; } @@ -1055,7 +1054,7 @@ namespace Server.Items return; } - if (!(from is PlayerMobile player)) + if (@from is not PlayerMobile player) { return; } diff --git a/Projects/UOContent/Items/Misc/Guillotine.cs b/Projects/UOContent/Items/Misc/Guillotine.cs index b1195cb88..3b65f5a63 100644 --- a/Projects/UOContent/Items/Misc/Guillotine.cs +++ b/Projects/UOContent/Items/Misc/Guillotine.cs @@ -24,7 +24,7 @@ namespace Server.Items { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that } - else if (Visible && (ItemID == 4656 || ItemID == 4702) && Core.Now >= m_NextUse) + else if (Visible && ItemID is 4656 or 4702 && Core.Now >= m_NextUse) { var p = GetWorldLocation(); @@ -89,11 +89,11 @@ namespace Server.Items private void BackUp() { - if (ItemID == 4678 || ItemID == 4679) + if (ItemID is 4678 or 4679) { ItemID = 4656; } - else if (ItemID == 4712 || ItemID == 4713) + else if (ItemID is 4712 or 4713) { ItemID = 4702; } @@ -112,11 +112,11 @@ namespace Server.Items int version = reader.ReadByte(); - if (ItemID == 4678 || ItemID == 4679) + if (ItemID is 4678 or 4679) { ItemID = 4656; } - else if (ItemID == 4712 || ItemID == 4713) + else if (ItemID is 4712 or 4713) { ItemID = 4702; } diff --git a/Projects/UOContent/Items/Misc/KeyRing.cs b/Projects/UOContent/Items/Misc/KeyRing.cs index 3ea0e1502..9260e7f26 100644 --- a/Projects/UOContent/Items/Misc/KeyRing.cs +++ b/Projects/UOContent/Items/Misc/KeyRing.cs @@ -29,7 +29,7 @@ namespace Server.Items return false; } - if (!(dropped is Key key) || key.KeyValue == 0) + if (dropped is not Key key || key.KeyValue == 0) { from.SendLocalizedMessage(501689); // Only non-blank keys can be put on a keyring. return false; @@ -80,7 +80,7 @@ namespace Server.Items public void Open(Mobile from) { - if (!(Parent is Container cont)) + if (Parent is not Container cont) { return; } diff --git a/Projects/UOContent/Items/Misc/PoolOfAcid.cs b/Projects/UOContent/Items/Misc/PoolOfAcid.cs index c5ceb1d96..db2511df9 100644 --- a/Projects/UOContent/Items/Misc/PoolOfAcid.cs +++ b/Projects/UOContent/Items/Misc/PoolOfAcid.cs @@ -66,7 +66,7 @@ namespace Server.Items foreach (var m in GetMobilesInRange(0)) { - if (m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned)) + if (m.Alive && !m.IsDeadBondedPet && (m is not BaseCreature bc || bc.Controlled || bc.Summoned)) { toDamage.Add(m); } diff --git a/Projects/UOContent/Items/Quivers/BaseQuiver.cs b/Projects/UOContent/Items/Quivers/BaseQuiver.cs index 02a832003..6234087bd 100644 --- a/Projects/UOContent/Items/Quivers/BaseQuiver.cs +++ b/Projects/UOContent/Items/Quivers/BaseQuiver.cs @@ -126,7 +126,7 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { - if (!(newItem is BaseQuiver quiver)) + if (newItem is not BaseQuiver quiver) { return; } diff --git a/Projects/UOContent/Items/Shields/ChaosShield.cs b/Projects/UOContent/Items/Shields/ChaosShield.cs index 055b1a245..bbc80947c 100644 --- a/Projects/UOContent/Items/Shields/ChaosShield.cs +++ b/Projects/UOContent/Items/Shields/ChaosShield.cs @@ -63,7 +63,7 @@ namespace Server.Items return true; } - if (!(m.Guild is Guild g) || g.Type != GuildType.Chaos) + if (m.Guild is not Guild g || g.Type != GuildType.Chaos) { m.FixedEffect(0x3728, 10, 13); Delete(); diff --git a/Projects/UOContent/Items/Shields/OrderShield.cs b/Projects/UOContent/Items/Shields/OrderShield.cs index 7d5307737..1547c85aa 100644 --- a/Projects/UOContent/Items/Shields/OrderShield.cs +++ b/Projects/UOContent/Items/Shields/OrderShield.cs @@ -68,7 +68,7 @@ namespace Server.Items return true; } - if (!(m.Guild is Guild g) || g.Type != GuildType.Order) + if (m.Guild is not Guild g || g.Type != GuildType.Order) { m.FixedEffect(0x3728, 10, 13); Delete(); diff --git a/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs b/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs index 53bc96d55..78fcbe3eb 100644 --- a/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs +++ b/Projects/UOContent/Items/Skill Items/Camping/Bedroll.cs @@ -32,7 +32,7 @@ namespace Server.Items { var dir = PlayerMobile.GetDirection4(from.Location, Location); - if (dir == Direction.North || dir == Direction.South) + if (dir is Direction.North or Direction.South) { ItemID = 0xA55; } diff --git a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs index 741864073..8d3f3e515 100644 --- a/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs +++ b/Projects/UOContent/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs @@ -133,7 +133,7 @@ namespace Server.Items return; } - if (!(obj is IPoint3D p3D)) + if (obj is not IPoint3D p3D) { return; } @@ -216,7 +216,7 @@ namespace Server.Items Effects.SendLocationEffect(p, Map, 0x352D, 16, 4); Effects.PlaySound(p, Map, 0x364); } - else if (index <= 7 || index == 14) + else if (index is <= 7 or 14) { if (RequireDeepWater) { @@ -397,7 +397,7 @@ namespace Server.Items private static bool ValidateUndeepWater(Map map, object obj, ref int z) { - if (!(obj is StaticTarget)) + if (obj is not StaticTarget) { return false; } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs index 264147b2c..8fffda490 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs @@ -168,7 +168,7 @@ namespace Server.Items return; } - if (!(from is PlayerMobile pm)) + if (@from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs b/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs index 3f352c762..e8a633fab 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Misc/PotionKeg.cs @@ -258,7 +258,7 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item item) { - if (!(item is BasePotion pot)) + if (item is not BasePotion pot) { from.SendLocalizedMessage(502232); // The keg is not designed to hold that type of object. return false; diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs index 030a86745..e6f2bb93a 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/BasePotion.cs @@ -103,7 +103,7 @@ namespace Server.Items // if (keg == null) // continue; - if (keg.Held <= 0 || keg.Held >= 100) + if (keg.Held is <= 0 or >= 100) { continue; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs index 63909ee5c..f65db4499 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs @@ -162,7 +162,7 @@ namespace Server.Items return; } - if (!(targeted is IPoint3D p) || from.Map == null) + if (targeted is not IPoint3D p || from.Map == null) { return; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs index 97e16e150..2088180cb 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs @@ -365,7 +365,7 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { - if (!(newItem is Runebook book)) + if (newItem is not Runebook book) { return; } diff --git a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs index f4d3f636d..18d0dc042 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs @@ -600,7 +600,7 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { - if (!(newItem is Spellbook book)) + if (newItem is not Spellbook book) { return; } diff --git a/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs b/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs index 058cfa1b1..aaab0407f 100644 --- a/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs +++ b/Projects/UOContent/Items/Skill Items/Misc/Bandage.cs @@ -74,7 +74,7 @@ namespace Server.Items private static void EventSink_BandageTargetRequest(Mobile from, Item item, Mobile target) { - if (!(item is Bandage b) || b.Deleted) + if (item is not Bandage b || b.Deleted) { return; } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs index 52fc69dd1..d0faa631e 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -234,7 +234,7 @@ namespace Server.Items public static void OnPickedInstrument(Mobile from, object targeted, InstrumentPickedCallback callback) { - if (!(targeted is BaseInstrument instrument)) + if (targeted is not BaseInstrument instrument) { from.SendLocalizedMessage(500619); // That is not a musical instrument. } @@ -286,7 +286,7 @@ namespace Server.Items val += 100; } - if (targ is VampireBat || targ is VampireBatFamiliar) + if (targ is VampireBat or VampireBatFamiliar) { val += 100; } diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs index 1f422cd94..be13e0150 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs @@ -178,7 +178,7 @@ namespace Server.Items } } } - else if ((item is Runebook || item is RecallRune) && m_Tub.AllowRunebooks) + else if (item is Runebook or RecallRune && m_Tub.AllowRunebooks) { if (!from.InRange(m_Tub.GetWorldLocation(), 1) || !from.InRange(item.GetWorldLocation(), 1)) { @@ -211,9 +211,7 @@ namespace Server.Items } } else if ((item is BaseArmor armor && - (armor.MaterialType == ArmorMaterialType.Leather || - armor.MaterialType == ArmorMaterialType.Studded) || item is ElvenBoots || - item is WoodlandBelt) && m_Tub.AllowLeather) + armor.MaterialType is ArmorMaterialType.Leather or ArmorMaterialType.Studded || item is ElvenBoots or WoodlandBelt) && m_Tub.AllowLeather) { if (!from.InRange(m_Tub.GetWorldLocation(), 1) || !from.InRange(item.GetWorldLocation(), 1)) { diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs index 4a8c962e4..756505c08 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Misc/Scissors.cs @@ -84,7 +84,7 @@ namespace Server.Items } else if (targeted is Item item && !item.Movable) { - if (item is IScissorable obj && (obj is PlagueBeastInnard || obj is PlagueBeastMutationCore)) + if (item is IScissorable obj && obj is PlagueBeastInnard or PlagueBeastMutationCore) { if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) { @@ -107,7 +107,7 @@ namespace Server.Items protected override void OnNonlocalTarget(Mobile from, object targeted) { - if (targeted is IScissorable obj && (obj is PlagueBeastInnard || obj is PlagueBeastMutationCore)) + if (targeted is IScissorable obj && obj is PlagueBeastInnard or PlagueBeastMutationCore) { if (CanScissor(from, obj) && obj.Scissor(from, m_Item)) { diff --git a/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs b/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs index e72c7f7cb..e94194e44 100644 --- a/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs +++ b/Projects/UOContent/Items/Skill Items/Thief/LockPick.cs @@ -126,7 +126,7 @@ namespace Server.Items return; } - if (m_Item.LockLevel == 0 || m_Item.LockLevel == -255) + if (m_Item.LockLevel is 0 or -255) { // LockLevel of 0 means that the door can't be picklocked // LockLevel of -255 means it's magic locked diff --git a/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs b/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs index 46b5004a5..45881715f 100644 --- a/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs +++ b/Projects/UOContent/Items/Skill Items/Tinkering/Spyglass.cs @@ -50,7 +50,7 @@ namespace Server.Items { var qs = player.Quest; - if (!(qs is WitchApprenticeQuest)) + if (qs is not WitchApprenticeQuest) { return; } @@ -61,7 +61,7 @@ namespace Server.Items { Clock.GetTime(from.Map, from.X, from.Y, out var hours, out int _); - if (hours < 5 || hours > 17) + if (hours is < 5 or > 17) { player.SendLocalizedMessage( 1055040 diff --git a/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs b/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs index 271899878..e484fc193 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs @@ -141,14 +141,14 @@ namespace Server.Items { var check = m.FindItemOnLayer(Layer.OneHanded); - if (check is BaseTool && check != tool && !(check is AncientSmithyHammer)) + if (check is BaseTool && check != tool && check is not AncientSmithyHammer) { return false; } check = m.FindItemOnLayer(Layer.TwoHanded); - return !(check is BaseTool) || check == tool || check is AncientSmithyHammer; + return check is not BaseTool || check == tool || check is AncientSmithyHammer; } public override void OnSingleClick(Mobile from) diff --git a/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs b/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs index ae5d9449b..f980d2391 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/RunicSewingKit.cs @@ -79,7 +79,7 @@ namespace Server.Items var version = reader.ReadInt(); - if (ItemID == 0x13E4 || ItemID == 0x13E3) + if (ItemID is 0x13E4 or 0x13E3) { ItemID = 0xF9D; } diff --git a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs index 3e89229a0..bff115f2b 100644 --- a/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs +++ b/Projects/UOContent/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs @@ -132,7 +132,7 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { - if (!(newItem is DawnsMusicBox box)) + if (newItem is not DawnsMusicBox box) { return; } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs index ad870ab43..4d311bd72 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs @@ -27,7 +27,7 @@ namespace Server.Items { Clock.GetTime(Map, X, Y, out var hours, out int _); - if (hours < 4 || hours > 20) + if (hours is < 4 or > 20) { Effects.PlaySound(Location, Map, 0x569); } diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs index a8f1a198e..294e8dd00 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/CreepyPortrait.cs @@ -35,7 +35,7 @@ namespace Server.Items { if (!Utility.InRange(old, Location, 2) && Utility.InRange(m.Location, Location, 2)) { - if (ItemID == 0x2A69 || ItemID == 0x2A6D) + if (ItemID is 0x2A69 or 0x2A6D) { Up(); Timer.StartTimer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), 2, Up); @@ -43,7 +43,7 @@ namespace Server.Items } else if (Utility.InRange(old, Location, 2) && !Utility.InRange(m.Location, Location, 2)) { - if (ItemID == 0x2A6C || ItemID == 0x2A70) + if (ItemID is 0x2A6C or 0x2A70) { Down(); Timer.StartTimer(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5), 2, Down); diff --git a/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs b/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs index f43857563..f77ca1d8f 100644 --- a/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs +++ b/Projects/UOContent/Items/Special/Evil Home Decor Collection/HauntedMirror.cs @@ -22,7 +22,7 @@ namespace Server.Items { if (!Utility.InRange(old, Location, 2) && Utility.InRange(m.Location, Location, 2)) { - if (ItemID == 0x2A7B || ItemID == 0x2A7D) + if (ItemID is 0x2A7B or 0x2A7D) { Effects.PlaySound(Location, Map, Utility.RandomMinMax(0x551, 0x553)); ItemID += 1; @@ -30,7 +30,7 @@ namespace Server.Items } else if (Utility.InRange(old, Location, 2) && !Utility.InRange(m.Location, Location, 2)) { - if (ItemID == 0x2A7C || ItemID == 0x2A7E) + if (ItemID is 0x2A7C or 0x2A7E) { ItemID -= 1; } diff --git a/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs b/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs index 9612bb558..914ecba4a 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/Guillotine.cs @@ -87,7 +87,7 @@ namespace Server.Items public virtual void Activate(AddonComponent c, Mobile from) { - if (c.ItemID == 0x125E || c.ItemID == 0x1269 || c.ItemID == 0x1260) + if (c.ItemID is 0x125E or 0x1269 or 0x1260) { c.ItemID = 0x1269; } diff --git a/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs b/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs index bb610e8d8..da1364a98 100644 --- a/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs +++ b/Projects/UOContent/Items/Special/Heritage Items/HouseLadder.cs @@ -160,7 +160,7 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Deed?.Deleted != false || info.ButtonID == 0 || info.ButtonID < 1 || info.ButtonID > 8) + if (m_Deed?.Deleted != false || info.ButtonID is 0 or < 1 or > 8) { return; } diff --git a/Projects/UOContent/Items/Special/Holiday/Wreath.cs b/Projects/UOContent/Items/Special/Holiday/Wreath.cs index ebc3cad6c..14e5a9e7b 100644 --- a/Projects/UOContent/Items/Special/Holiday/Wreath.cs +++ b/Projects/UOContent/Items/Special/Holiday/Wreath.cs @@ -227,7 +227,7 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted) { - if (!(targeted is IPoint3D p)) + if (targeted is not IPoint3D p) { return; } diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs index 8e6f99915..deb7f74a5 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs @@ -299,7 +299,7 @@ namespace Server.Items private bool HasEntered(Mobile from) { - if (!(from.Account is Account acc)) + if (@from.Account is not Account acc) { return false; } @@ -509,7 +509,7 @@ namespace Server.Items return; } - if (!(from.Account is Account)) + if (@from.Account is not Account) { return; } diff --git a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs index 672285179..a52de68c3 100644 --- a/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs +++ b/Projects/UOContent/Items/Special/Mutation Core/PlagueBeastBackpack.cs @@ -113,7 +113,7 @@ namespace Server.Items public override bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage) { - if (dropped is PlagueBeastInnard || dropped is PlagueBeastGland) + if (dropped is PlagueBeastInnard or PlagueBeastGland) { return base.TryDropItem(from, dropped, sendFullMessage); } @@ -123,7 +123,7 @@ namespace Server.Items public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { - if (IsAccessibleTo(from) && (item is PlagueBeastInnard || item is PlagueBeastGland)) + if (IsAccessibleTo(from) && item is PlagueBeastInnard or PlagueBeastGland) { var ir = ItemBounds.Table[item.ItemID]; int x, y; diff --git a/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs b/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs index e4af5f581..6deb51f52 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BagOfSending.cs @@ -258,7 +258,7 @@ namespace Server.Items 0x59 ); // You may only send items from your backpack to your bank box. } - else if (item is BagOfSending || item is Container) + else if (item is BagOfSending or Container) { from.NetState.SendMessage( m_Bag.Serial, diff --git a/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs b/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs index 3fdf40e66..8cd5832cf 100644 --- a/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs +++ b/Projects/UOContent/Items/Special/Solen Items/BraceletOfBinding.cs @@ -412,7 +412,7 @@ namespace Server.Items if (m_Bracelet.Deleted || m_From.Deleted || !m_Bracelet.CheckUse(m_From, false) || - !(m_Bracelet.Bound.RootParent is Mobile boundRoot)) + m_Bracelet.Bound.RootParent is not Mobile boundRoot) { return; } diff --git a/Projects/UOContent/Items/Special/SoulStone.cs b/Projects/UOContent/Items/Special/SoulStone.cs index 7bba3a90a..e170157f7 100644 --- a/Projects/UOContent/Items/Special/SoulStone.cs +++ b/Projects/UOContent/Items/Special/SoulStone.cs @@ -167,7 +167,7 @@ namespace Server.Items return false; } - if (Account != null && (!(from.Account is Account) || from.Account.Username != Account)) + if (Account != null && (@from.Account is not Accounting.Account || from.Account.Username != Account)) { from.SendLocalizedMessage( 1070714 @@ -993,7 +993,7 @@ namespace Server.Items if (version <= 1) { - if (ItemID == 0x2A93 || ItemID == 0x2A94) + if (ItemID is 0x2A93 or 0x2A94) { ActiveItemID = Utility.Random(0x2AA1, 9); } diff --git a/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs b/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs index 50273d2ff..1dd35b8f3 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/PowerScroll.cs @@ -72,7 +72,7 @@ namespace Server.Items { Hue = 0x481; - if (Value == 105.0 || skill == SkillName.Blacksmith || skill == SkillName.Tailoring) + if (Value == 105.0 || skill is SkillName.Blacksmith or SkillName.Tailoring) { LootType = LootType.Regular; } @@ -155,7 +155,7 @@ namespace Server.Items do { skillName = Skills.RandomElement(); - } while (skillName == SkillName.Blacksmith || skillName == SkillName.Tailoring); + } while (skillName is SkillName.Blacksmith or SkillName.Tailoring); return new PowerScroll(skillName, 100 + Utility.RandomMinMax(min, max) * 5); } @@ -312,7 +312,7 @@ namespace Server.Items var version = InheritsItem ? 0 : reader.ReadInt(); // Required for SpecialScroll insertion - if (Value == 105.0 || Skill == SkillName.Blacksmith || Skill == SkillName.Tailoring) + if (Value == 105.0 || Skill is SkillName.Blacksmith or SkillName.Tailoring) { LootType = LootType.Regular; } diff --git a/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs b/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs index 52416304c..77073a835 100644 --- a/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs +++ b/Projects/UOContent/Items/Special/Special Scrolls/SpecialScroll.cs @@ -106,7 +106,7 @@ namespace Server.Items { InheritsItem = true; - if (!(this is StatCapScroll)) + if (this is not StatCapScroll) { Skill = (SkillName)reader.ReadInt(); } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs b/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs index 6d451fa81..1bd7ce1bc 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs @@ -157,7 +157,7 @@ namespace Server.Items { var from = state.Mobile; - if (info.ButtonID == 1 || info.ButtonID == 2) + if (info.ButtonID is 1 or 2) { if (from.Map?.CanFit(from.Location, 16, false, false) != true) { diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs b/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs index e20d52477..f102d7441 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/Banner.cs @@ -264,7 +264,7 @@ namespace Server.Items var m = sender.Mobile; - if (info.ButtonID < Start || info.ButtonID > End || (info.ButtonID & 0x1) != 0) + if (info.ButtonID is < Start or > End || (info.ButtonID & 0x1) != 0) { return; } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs b/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs index 37246e4f6..4f55b12a1 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/Cannon.cs @@ -273,7 +273,7 @@ namespace Server.Items return; } - if (!(targeted is IPoint3D p)) + if (targeted is not IPoint3D p) { return; } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs b/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs index 9c8224e06..a9d99e5a0 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/CommodityDeedBox.cs @@ -64,7 +64,7 @@ namespace Server.Items { var parent = deed; - while (parent != null && !(parent is CommodityDeedBox)) + while (parent != null && parent is not CommodityDeedBox) { parent = parent.Parent as Item; } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs b/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs index 08670eb85..71f5da8f8 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/DecorativeShield.cs @@ -255,9 +255,8 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Shield?.Deleted != false || info.ButtonID < Start || info.ButtonID > End || - ((info.ButtonID & 0x1) != 0 || info.ButtonID >= 0x1582) && - (info.ButtonID < 0x1582 || info.ButtonID > 0x1585)) + if (m_Shield?.Deleted != false || info.ButtonID is < Start or > End || ((info.ButtonID & 0x1) != 0 || info.ButtonID >= 0x1582) && + info.ButtonID is < 0x1582 or > 0x1585) { return; } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs b/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs index 4ac2c0228..b46114ff2 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/HangingSkeleton.cs @@ -27,8 +27,7 @@ namespace Server.Items { get { - if (ItemID == 0x1A03 || ItemID == 0x1A05 || ItemID == 0x1A09 || - ItemID == 0x1B1E || ItemID == 0x1B7F) + if (ItemID is 0x1A03 or 0x1A05 or 0x1A09 or 0x1B1E or 0x1B7F) { return true; } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs b/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs index c933063b5..80647576c 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/PottedCactus.cs @@ -170,7 +170,7 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Cactus?.Deleted != false || info.ButtonID < 0x1E0F || info.ButtonID > 0x1E14) + if (m_Cactus?.Deleted != false || info.ButtonID is < 0x1E0F or > 0x1E14) { return; } diff --git a/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs b/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs index 17503ade3..cced8f9cb 100644 --- a/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs +++ b/Projects/UOContent/Items/Special/Veteran Rewards/WallBanner.cs @@ -503,7 +503,7 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { - if (m_WallBanner?.Deleted != false || info.ButtonID <= 0 || info.ButtonID >= 31) + if (m_WallBanner?.Deleted != false || info.ButtonID is <= 0 or >= 31) { return; } diff --git a/Projects/UOContent/Items/Suits/BaseSuit.cs b/Projects/UOContent/Items/Suits/BaseSuit.cs index 8e0475f59..19976269c 100644 --- a/Projects/UOContent/Items/Suits/BaseSuit.cs +++ b/Projects/UOContent/Items/Suits/BaseSuit.cs @@ -47,7 +47,7 @@ namespace Server.Items public bool Validate() { - if (!(RootParent is Mobile mobile) || mobile.AccessLevel >= AccessLevel) + if (RootParent is not Mobile mobile || mobile.AccessLevel >= AccessLevel) { return true; } diff --git a/Projects/UOContent/Items/Talismans/BaseTalisman.cs b/Projects/UOContent/Items/Talismans/BaseTalisman.cs index 84f159dc1..fe338037f 100644 --- a/Projects/UOContent/Items/Talismans/BaseTalisman.cs +++ b/Projects/UOContent/Items/Talismans/BaseTalisman.cs @@ -345,7 +345,7 @@ namespace Server.Items public override void OnAfterDuped(Item newItem) { - if (!(newItem is BaseTalisman talisman)) + if (newItem is not BaseTalisman talisman) { return; } @@ -1190,7 +1190,7 @@ namespace Server.Items return; } - if (!(o is Mobile target)) + if (o is not Mobile target) { from.SendLocalizedMessage(1046439); // That is not a valid target. return; diff --git a/Projects/UOContent/Items/Wands/BaseWand.cs b/Projects/UOContent/Items/Wands/BaseWand.cs index 448985af1..3e030dcd8 100644 --- a/Projects/UOContent/Items/Wands/BaseWand.cs +++ b/Projects/UOContent/Items/Wands/BaseWand.cs @@ -244,7 +244,7 @@ namespace Server.Items public virtual void DoWandTarget(Mobile from, object o) { - if (Deleted || _charges <= 0 || Parent != from || o is StaticTarget || o is LandTarget) + if (Deleted || _charges <= 0 || Parent != @from || o is StaticTarget or LandTarget) { return; } diff --git a/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs b/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs index 903803d19..069b5b3a0 100644 --- a/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs +++ b/Projects/UOContent/Items/Weapons/Abilities/Dismount.cs @@ -39,7 +39,7 @@ namespace Server.Items return; } - if (defender is ChaosDragoon || defender is ChaosDragoonElite) + if (defender is ChaosDragoon or ChaosDragoonElite) { return; } diff --git a/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs b/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs index 595ec181c..05087567e 100644 --- a/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs +++ b/Projects/UOContent/Items/Weapons/Axes/BaseAxe.cs @@ -87,7 +87,7 @@ namespace Server.Items return; } - if (!(HarvestSystem is Mining)) + if (HarvestSystem is not Mining) { from.SendLocalizedMessage(1010018); // What do you want to use this item on? } diff --git a/Projects/UOContent/Items/Weapons/Fists.cs b/Projects/UOContent/Items/Weapons/Fists.cs index b2fe3fc93..e20c66c77 100644 --- a/Projects/UOContent/Items/Weapons/Fists.cs +++ b/Projects/UOContent/Items/Weapons/Fists.cs @@ -199,7 +199,7 @@ namespace Server.Items { var item = m.FindItemOnLayer(Layer.OneHanded); - return (item == null || item is Spellbook) && m.FindItemOnLayer(Layer.TwoHanded) == null; + return item is null or Spellbook && m.FindItemOnLayer(Layer.TwoHanded) == null; } private static void EventSink_DisarmRequest(Mobile m) diff --git a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs index a3a393a33..05f3bf3da 100644 --- a/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs +++ b/Projects/UOContent/Items/Weapons/Ranged/BaseRanged.cs @@ -53,7 +53,7 @@ namespace Server.Items if (canSwing) { - canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement; + canSwing = attacker.Spell is not Spell sp || !sp.IsCasting || !sp.BlocksMovement; } } diff --git a/Projects/UOContent/Items/Weapons/Ranged/JukaBow.cs b/Projects/UOContent/Items/Weapons/Ranged/JukaBow.cs index 09c372c7e..658c9d39c 100644 --- a/Projects/UOContent/Items/Weapons/Ranged/JukaBow.cs +++ b/Projects/UOContent/Items/Weapons/Ranged/JukaBow.cs @@ -43,7 +43,7 @@ namespace Server.Items public void OnTargetGears(Mobile from, object targ) { - if (!(targ is Gears g) || !g.IsChildOf(from.Backpack)) + if (targ is not Gears g || !g.IsChildOf(from.Backpack)) { from.SendMessage( "Those are not gears." diff --git a/Projects/UOContent/Misc/AccountPrompt.cs b/Projects/UOContent/Misc/AccountPrompt.cs index 12c6f39de..0e537c0d5 100644 --- a/Projects/UOContent/Misc/AccountPrompt.cs +++ b/Projects/UOContent/Misc/AccountPrompt.cs @@ -13,7 +13,7 @@ namespace Server.Misc Console.Write("Do you want to create the owner account now? (y/n): "); var answer = Console.ReadLine(); - if (answer == "y" || answer == "Y") + if (answer is "y" or "Y") { Console.WriteLine(); diff --git a/Projects/UOContent/Misc/Geometry.cs b/Projects/UOContent/Misc/Geometry.cs index 5af881d2b..d6a20b883 100644 --- a/Projects/UOContent/Misc/Geometry.cs +++ b/Projects/UOContent/Misc/Geometry.cs @@ -36,12 +36,12 @@ namespace Server.Misc public static void Circle2D(Point3D loc, Map map, int radius, DoEffect_Callback effect, int angleStart, int angleEnd) { - if (angleStart < 0 || angleStart > 360) + if (angleStart is < 0 or > 360) { angleStart = 0; } - if (angleEnd > 360 || angleEnd < 0) + if (angleEnd is > 360 or < 0) { angleEnd = 360; } diff --git a/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs b/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs index 6edd5a673..004f2fb43 100644 --- a/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs +++ b/Projects/UOContent/Misc/Gifts/Winter2004/Mistletoe.cs @@ -233,7 +233,7 @@ namespace Server.Items public void Placement_OnTarget(Mobile from, object targeted) { - if (!(targeted is IPoint3D p)) + if (targeted is not IPoint3D p) { return; } diff --git a/Projects/UOContent/Misc/Guild.cs b/Projects/UOContent/Misc/Guild.cs index bccad8bb9..89e1ce4c5 100644 --- a/Projects/UOContent/Misc/Guild.cs +++ b/Projects/UOContent/Misc/Guild.cs @@ -937,7 +937,7 @@ namespace Server.Guilds public static void EventSink_GuildGumpRequest(Mobile m) { - if (!NewGuildSystem || !(m is PlayerMobile pm)) + if (!NewGuildSystem || m is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Misc/LootPack.cs b/Projects/UOContent/Misc/LootPack.cs index 027e1ffb7..4e71aa7d9 100644 --- a/Projects/UOContent/Misc/LootPack.cs +++ b/Projects/UOContent/Misc/LootPack.cs @@ -750,7 +750,7 @@ namespace Server return item; } - if (item is BaseWeapon || item is BaseArmor || item is BaseJewel || item is BaseHat) + if (item is BaseWeapon or BaseArmor or BaseJewel or BaseHat) { if (Core.AOS) { diff --git a/Projects/UOContent/Misc/Notoriety.cs b/Projects/UOContent/Misc/Notoriety.cs index 33e2a8169..3579e988b 100644 --- a/Projects/UOContent/Misc/Notoriety.cs +++ b/Projects/UOContent/Misc/Notoriety.cs @@ -278,8 +278,7 @@ namespace Server.Misc { c.DisplayGuildTitle = false; - if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder == OrderType.Attack || - c.ControlOrder == OrderType.Guard)) + if (c.Map != Map.Internal && (Core.AOS || Guild.NewGuildSystem || c.ControlOrder is OrderType.Attack or OrderType.Guard)) { g = (Guild)(c.Guild = c.ControlMaster.Guild); } @@ -385,7 +384,7 @@ namespace Server.Misc return Notoriety.CanBeAttacked; } - if (!(target.Owner is PlayerMobile)) + if (target.Owner is not PlayerMobile) { return Notoriety.CanBeAttacked; } @@ -406,8 +405,7 @@ namespace Server.Misc { var bcTarg = target as BaseCreature; - if (Core.AOS && (target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor || - target is TownCrier)) + if (Core.AOS && (target.Blessed || bcTarg?.IsInvulnerable == true || target is PlayerVendor or TownCrier)) { return Notoriety.Invulnerable; } @@ -458,8 +456,8 @@ namespace Server.Misc } if (target.Kills >= 5 || - target.Body.IsMonster && IsSummoned(bcTarg) && !(target is BaseFamiliar) && !(target is ArcaneFey) && - !(target is Golem) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true) + target.Body.IsMonster && IsSummoned(bcTarg) && target is not BaseFamiliar && target is not ArcaneFey && + target is not Golem || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true) { return Notoriety.Murderer; } @@ -561,7 +559,7 @@ namespace Server.Misc return false; } - return !(m is BaseCreature c) || c.Deleted || !c.Controlled || c.ControlMaster == null || + return m is not BaseCreature c || c.Deleted || !c.Controlled || c.ControlMaster == null || !house.IsFriend(c.ControlMaster); } diff --git a/Projects/UOContent/Misc/PacketThrottles.cs b/Projects/UOContent/Misc/PacketThrottles.cs index b0459647b..d2b666ed9 100644 --- a/Projects/UOContent/Misc/PacketThrottles.cs +++ b/Projects/UOContent/Misc/PacketThrottles.cs @@ -66,7 +66,7 @@ namespace Server.Network int packetID = e.GetInt32(0); - if (packetID < 0 || packetID > 0x100) + if (packetID is < 0 or > 0x100) { e.Mobile.SendMessage("Invalid Command Format. PacketID must be between 0 and 0x100."); return; @@ -88,7 +88,7 @@ namespace Server.Network int packetID = e.GetInt32(0); int delay = e.GetInt32(1); - if (packetID < 0 || packetID > 0x100) + if (packetID is < 0 or > 0x100) { e.Mobile.SendMessage("Invalid Command Format. PacketID must be between 0 and 0x100."); return; diff --git a/Projects/UOContent/Misc/Profile.cs b/Projects/UOContent/Misc/Profile.cs index 04ceddea5..674ae7b81 100644 --- a/Projects/UOContent/Misc/Profile.cs +++ b/Projects/UOContent/Misc/Profile.cs @@ -64,7 +64,7 @@ namespace Server.Misc private static string GetAccountDuration(Mobile m) { - if (!(m.Account is Account a)) + if (m.Account is not Account a) { return ""; } diff --git a/Projects/UOContent/Misc/ResourceInfo.cs b/Projects/UOContent/Misc/ResourceInfo.cs index 778de771e..601436d56 100644 --- a/Projects/UOContent/Misc/ResourceInfo.cs +++ b/Projects/UOContent/Misc/ResourceInfo.cs @@ -713,10 +713,8 @@ namespace Server.Items /// /// Returns true if '' is None, Iron, RegularLeather or RegularWood. False if otherwise. /// - public static bool IsStandard(CraftResource resource) => resource == CraftResource.None || - resource == CraftResource.Iron || - resource == CraftResource.RegularLeather || - resource == CraftResource.RegularWood; + public static bool IsStandard(CraftResource resource) => + resource is CraftResource.None or CraftResource.Iron or CraftResource.RegularLeather or CraftResource.RegularWood; /// /// Registers that '' uses '' so that it can later be queried by diff --git a/Projects/UOContent/Mobiles/AI/BaseAI.cs b/Projects/UOContent/Mobiles/AI/BaseAI.cs index 42f74c24f..af010e7c4 100644 --- a/Projects/UOContent/Mobiles/AI/BaseAI.cs +++ b/Projects/UOContent/Mobiles/AI/BaseAI.cs @@ -178,7 +178,7 @@ namespace Server.Mobiles list.Add(new InternalEntry(from, 6112, 14, m_Mobile, this, OrderType.Stop)); // Command: Stop list.Add(new InternalEntry(from, 6114, 14, m_Mobile, this, OrderType.Stay)); // Command: Stay - if (!m_Mobile.Summoned && !(m_Mobile is GrizzledMare)) + if (!m_Mobile.Summoned && m_Mobile is not GrizzledMare) { list.Add(new InternalEntry(from, 6110, 14, m_Mobile, this, OrderType.Friend)); // Add Friend list.Add(new InternalEntry(from, 6099, 14, m_Mobile, this, OrderType.Unfriend)); // Remove Friend @@ -283,17 +283,9 @@ namespace Server.Mobiles } if (SolenHelper.CheckRedFriendship(from) && - (target is RedSolenInfiltratorQueen - || target is RedSolenInfiltratorWarrior - || target is RedSolenQueen - || target is RedSolenWarrior - || target is RedSolenWorker) + target is RedSolenInfiltratorQueen or RedSolenInfiltratorWarrior or RedSolenQueen or RedSolenWarrior or RedSolenWorker || SolenHelper.CheckBlackFriendship(from) && - (target is BlackSolenInfiltratorQueen - || target is BlackSolenInfiltratorWarrior - || target is BlackSolenQueen - || target is BlackSolenWarrior - || target is BlackSolenWorker)) + target is BlackSolenInfiltratorQueen or BlackSolenInfiltratorWarrior or BlackSolenQueen or BlackSolenWarrior or BlackSolenWorker) { from.SendAsciiMessage("You can not force your pet to attack a creature you are protected from."); return; @@ -1256,7 +1248,7 @@ namespace Server.Mobiles var distance = m_Mobile.GetDistanceToSqrt(target); - if (!(distance < 1 || distance > 15)) + if (!(distance is < 1 or > 15)) { DoMove(m_Mobile.GetDirectionTo(target)); return true; @@ -1550,7 +1542,7 @@ namespace Server.Mobiles m_Mobile.ControlOrder = OrderType.None; } - if (m_Mobile.FightMode == FightMode.Closest || m_Mobile.FightMode == FightMode.Aggressor) + if (m_Mobile.FightMode is FightMode.Closest or FightMode.Aggressor) { Mobile newCombatant = null; var newScore = 0.0; @@ -1962,8 +1954,7 @@ namespace Server.Mobiles { var res = DoMoveImpl(d); - return res == MoveResult.Success || res == MoveResult.SuccessAutoTurn || - badStateOk && res == MoveResult.BadState; + return res is MoveResult.Success or MoveResult.SuccessAutoTurn || badStateOk && res == MoveResult.BadState; } public virtual MoveResult DoMoveImpl(Direction d) @@ -2540,7 +2531,7 @@ namespace Server.Mobiles continue; } - if (acqType == FightMode.Aggressor || acqType == FightMode.Evil) + if (acqType is FightMode.Aggressor or FightMode.Evil) { var bValid = IsHostile(m); @@ -2741,8 +2732,7 @@ namespace Server.Mobiles m_AI = ai; m_Order = order; - if (mobile.IsDeadPet && (order == OrderType.Guard || order == OrderType.Attack || - order == OrderType.Transfer || order == OrderType.Drop)) + if (mobile.IsDeadPet && order is OrderType.Guard or OrderType.Attack or OrderType.Transfer or OrderType.Drop) { Enabled = false; } @@ -2752,8 +2742,7 @@ namespace Server.Mobiles { if (!m_Mobile.Deleted && m_Mobile.Controlled && m_From.CheckAlive()) { - if (m_Mobile.IsDeadPet && (m_Order == OrderType.Guard || m_Order == OrderType.Attack || - m_Order == OrderType.Transfer || m_Order == OrderType.Drop)) + if (m_Mobile.IsDeadPet && m_Order is OrderType.Guard or OrderType.Attack or OrderType.Transfer or OrderType.Drop) { return; } diff --git a/Projects/UOContent/Mobiles/AI/MageAI.cs b/Projects/UOContent/Mobiles/AI/MageAI.cs index 8fe1f2c7a..9088e27f3 100644 --- a/Projects/UOContent/Mobiles/AI/MageAI.cs +++ b/Projects/UOContent/Mobiles/AI/MageAI.cs @@ -61,7 +61,7 @@ namespace Server.Mobiles { } - public virtual bool SmartAI => m_Mobile is BaseVendor || m_Mobile is BaseEscortable || m_Mobile is Changeling; + public virtual bool SmartAI => m_Mobile is BaseVendor or BaseEscortable or Changeling; public virtual bool IsNecromancer => Core.AOS && m_Mobile.Skills.Necromancy.Value > 50; @@ -792,7 +792,7 @@ namespace Server.Mobiles { spell = DoCombo(c); } - else if (SmartAI && (c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned + else if (SmartAI && c.Spell is HealSpell or GreaterHealSpell && !c.Poisoned ) // They have a heal spell out { spell = new PoisonSpell(m_Mobile); diff --git a/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs b/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs index 98f8be9b1..d97216fce 100644 --- a/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs +++ b/Projects/UOContent/Mobiles/Animals/Mounts/Ethereals.cs @@ -389,7 +389,7 @@ namespace Server.Mobiles public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) { - if (type == DisturbType.EquipRequest || type == DisturbType.UseRequest /* || type == DisturbType.Hurt*/) + if (type is DisturbType.EquipRequest or DisturbType.UseRequest /* || type == DisturbType.Hurt*/) { return false; } diff --git a/Projects/UOContent/Mobiles/BaseCreature.cs b/Projects/UOContent/Mobiles/BaseCreature.cs index 1debdd3cd..1c0b91b4e 100644 --- a/Projects/UOContent/Mobiles/BaseCreature.cs +++ b/Projects/UOContent/Mobiles/BaseCreature.cs @@ -2436,8 +2436,7 @@ namespace Server.Mobiles } if (aggressor.ChangingCombatant && (m_Controlled || _summoned) && - (ct == OrderType.Come || !Core.ML && ct == OrderType.Stay || ct == OrderType.Stop || ct == OrderType.None || - ct == OrderType.Follow)) + (ct == OrderType.Come || !Core.ML && ct == OrderType.Stay || ct is OrderType.Stop or OrderType.None or OrderType.Follow)) { ControlTarget = aggressor; ControlOrder = OrderType.Attack; @@ -3384,7 +3383,7 @@ namespace Server.Mobiles return false; } - if (target is BaseCreature creature && creature.IsInvulnerable || target is PlayerVendor || target is TownCrier) + if (target is BaseCreature creature && creature.IsInvulnerable || target is PlayerVendor or TownCrier) { if (message) { diff --git a/Projects/UOContent/Mobiles/Healers/EvilHealer.cs b/Projects/UOContent/Mobiles/Healers/EvilHealer.cs index 0fd51e5e8..02fcbeb7d 100644 --- a/Projects/UOContent/Mobiles/Healers/EvilHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/EvilHealer.cs @@ -30,10 +30,7 @@ namespace Server.Mobiles return false; } - return skill == SkillName.Forensics - || skill == SkillName.Healing - || skill == SkillName.SpiritSpeak - || skill == SkillName.Swords; + return skill is SkillName.Forensics or SkillName.Healing or SkillName.SpiritSpeak or SkillName.Swords; } public override void InitSBInfo() diff --git a/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs b/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs index 20be43369..ff5a4454b 100644 --- a/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/EvilWanderingHealer.cs @@ -33,11 +33,7 @@ namespace Server.Mobiles return false; } - return skill == SkillName.Anatomy - || skill == SkillName.Camping - || skill == SkillName.Forensics - || skill == SkillName.Healing - || skill == SkillName.SpiritSpeak; + return skill is SkillName.Anatomy or SkillName.Camping or SkillName.Forensics or SkillName.Healing or SkillName.SpiritSpeak; } public override bool CheckResurrect(Mobile m) diff --git a/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs b/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs index fcc41d01f..fbd3a3fed 100644 --- a/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs +++ b/Projects/UOContent/Mobiles/Healers/FortuneTeller.cs @@ -31,10 +31,7 @@ namespace Server.Mobiles return false; } - return skill == SkillName.Anatomy - || skill == SkillName.Healing - || skill == SkillName.Forensics - || skill == SkillName.SpiritSpeak; + return skill is SkillName.Anatomy or SkillName.Healing or SkillName.Forensics or SkillName.SpiritSpeak; } public override void InitSBInfo() diff --git a/Projects/UOContent/Mobiles/Healers/Healer.cs b/Projects/UOContent/Mobiles/Healers/Healer.cs index 88b135812..47eecff5c 100644 --- a/Projects/UOContent/Mobiles/Healers/Healer.cs +++ b/Projects/UOContent/Mobiles/Healers/Healer.cs @@ -33,10 +33,7 @@ namespace Server.Mobiles return false; } - return skill == SkillName.Forensics - || skill == SkillName.Healing - || skill == SkillName.SpiritSpeak - || skill == SkillName.Swords; + return skill is SkillName.Forensics or SkillName.Healing or SkillName.SpiritSpeak or SkillName.Swords; } public override void InitSBInfo() diff --git a/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs b/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs index cad541e0e..036b8741c 100644 --- a/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs +++ b/Projects/UOContent/Mobiles/Healers/WanderingHealer.cs @@ -31,11 +31,7 @@ namespace Server.Mobiles return false; } - return skill == SkillName.Anatomy - || skill == SkillName.Camping - || skill == SkillName.Forensics - || skill == SkillName.Healing - || skill == SkillName.SpiritSpeak; + return skill is SkillName.Anatomy or SkillName.Camping or SkillName.Forensics or SkillName.Healing or SkillName.SpiritSpeak; } public override bool CheckResurrect(Mobile m) diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs index d7ad5c249..29904bf35 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs @@ -110,8 +110,7 @@ namespace Server.Mobiles public override void AlterMeleeDamageTo(Mobile to, ref int damage) { - if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || - to is LesserHiryu || to is Daemon) + if (to is Dragon or WhiteWyrm or SwampDragon or Drake or Nightmare or Hiryu or LesserHiryu or Daemon) { damage *= 3; } @@ -184,7 +183,7 @@ namespace Server.Mobiles { foreach (var m in eable) { - var isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; + var isFriendly = m is Savage or SavageRider or SavageShaman or SavageRidgeback; if (!isFriendly) { @@ -215,7 +214,7 @@ namespace Server.Mobiles { foreach (var m in eable) { - var isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; + var isFriendly = m is Savage or SavageRider or SavageShaman or SavageRidgeback; if (isFriendly) { @@ -253,7 +252,7 @@ namespace Server.Mobiles { foreach (var m in eable) { - var isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; + var isFriendly = m is Savage or SavageRider or SavageShaman or SavageRidgeback; if (isFriendly) { diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs index 100dc84e7..54e899533 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/Savage.cs @@ -111,8 +111,7 @@ namespace Server.Mobiles public override void AlterMeleeDamageTo(Mobile to, ref int damage) { - if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || - to is LesserHiryu || to is Daemon) + if (to is Dragon or WhiteWyrm or SwampDragon or Drake or Nightmare or Hiryu or LesserHiryu or Daemon) { damage *= 3; } diff --git a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs index bfa2b98b1..ad74f08ae 100644 --- a/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs +++ b/Projects/UOContent/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs @@ -119,8 +119,7 @@ namespace Server.Mobiles public override void AlterMeleeDamageTo(Mobile to, ref int damage) { - if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || - to is LesserHiryu || to is Daemon) + if (to is Dragon or WhiteWyrm or SwampDragon or Drake or Nightmare or Hiryu or LesserHiryu or Daemon) { damage *= 3; } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs index d64dc7a4f..c139720cb 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs @@ -129,8 +129,7 @@ namespace Server.Mobiles public override void AlterMeleeDamageTo(Mobile to, ref int damage) { - if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || - to is LesserHiryu || to is Daemon) + if (to is Dragon or WhiteWyrm or SwampDragon or Drake or Nightmare or Hiryu or LesserHiryu or Daemon) { damage *= 3; } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs index 9e1aab189..839f9b117 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs @@ -151,8 +151,7 @@ namespace Server.Mobiles public override void AlterMeleeDamageTo(Mobile to, ref int damage) { - if (to is Dragon || to is WhiteWyrm || to is SwampDragon || to is Drake || to is Nightmare || to is Hiryu || - to is LesserHiryu || to is Daemon) + if (to is Dragon or WhiteWyrm or SwampDragon or Drake or Nightmare or Hiryu or LesserHiryu or Daemon) { damage *= 3; } diff --git a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs index 24cbc389d..0cbe3214b 100644 --- a/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs +++ b/Projects/UOContent/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs @@ -124,7 +124,7 @@ namespace Server.Mobiles foreach (var m in eable) { - if (!(m is MeerWarrior) || !IsFriend(m) || !CanBeBeneficial(m) || m.Hits >= m.HitsMax || m.Poisoned || + if (m is not MeerWarrior || !IsFriend(m) || !CanBeBeneficial(m) || m.Hits >= m.HitsMax || m.Poisoned || MortalStrike.IsWounded(m)) { continue; diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs index d0c70f67f..bcd9ed8ba 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/BladeSpirits.cs @@ -73,7 +73,7 @@ namespace Server.Mobiles { var eable = GetMobilesInRange(5); var spiritsOrVortexes = eable - .Where(m => (m is EnergyVortex || m is BladeSpirits) && ((BaseCreature)m).Summoned) + .Where(m => m is EnergyVortex or BladeSpirits && ((BaseCreature)m).Summoned) .ToList(); eable.Free(); diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs index a1505e2a0..a69586bc3 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs @@ -80,7 +80,7 @@ namespace Server.Mobiles { var eable = GetMobilesInRange(5); var spiritsOrVortexes = eable - .Where(m => (m is EnergyVortex || m is BladeSpirits) && ((BaseCreature)m).Summoned) + .Where(m => m is EnergyVortex or BladeSpirits && ((BaseCreature)m).Summoned) .ToList(); eable.Free(); diff --git a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs index a96c23de2..0e69a4bb1 100644 --- a/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs +++ b/Projects/UOContent/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs @@ -156,7 +156,7 @@ namespace Server.Mobiles public override bool OnDragDrop(Mobile from, Item dropped) { - if (IsAccessibleTo(from) && (dropped is PlagueBeastInnard || dropped is PlagueBeastGland)) + if (IsAccessibleTo(from) && dropped is PlagueBeastInnard or PlagueBeastGland) { return base.OnDragDrop(from, dropped); } diff --git a/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs b/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs index af50366b0..7e7856efb 100644 --- a/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs +++ b/Projects/UOContent/Mobiles/Monsters/SE/Yamandon.cs @@ -131,7 +131,7 @@ namespace Server.Mobiles continue; } - if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + if (m is not BaseCreature bc || !(bc.Controlled || bc.Summoned || bc.Team != Team)) { continue; } diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index 17e7da183..59a605d5b 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -1252,7 +1252,7 @@ namespace Server.Mobiles { string notice; - if (!(from.Account is Account acct) || !acct.HasAccess(from.NetState)) + if (@from.Account is not Account acct || !acct.HasAccess(from.NetState)) { if (from.AccessLevel == AccessLevel.Player) { @@ -1665,7 +1665,7 @@ namespace Server.Mobiles return false; } - if (target is BaseCreature creature && creature.IsInvulnerable || target is PlayerVendor || target is TownCrier) + if (target is BaseCreature creature && creature.IsInvulnerable || target is PlayerVendor or TownCrier) { if (message) { @@ -1701,7 +1701,7 @@ namespace Server.Mobiles { base.OnItemAdded(item); - if (item is BaseArmor || item is BaseWeapon) + if (item is BaseArmor or BaseWeapon) { CheckStatTimers(); } @@ -1716,7 +1716,7 @@ namespace Server.Mobiles { base.OnItemRemoved(item); - if (item is BaseArmor || item is BaseWeapon) + if (item is BaseArmor or BaseWeapon) { CheckStatTimers(); } @@ -2763,9 +2763,9 @@ namespace Server.Mobiles public override void DoSpeech(string text, int[] keywords, MessageType type, int hue) { - if (Guilds.Guild.NewGuildSystem && (type == MessageType.Guild || type == MessageType.Alliance)) + if (Guilds.Guild.NewGuildSystem && type is MessageType.Guild or MessageType.Alliance) { - if (!(Guild is Guild g)) + if (Guild is not Guild g) { SendLocalizedMessage(1063142); // You are not in a guild! } @@ -3662,7 +3662,7 @@ namespace Server.Mobiles { for (var i = m_AllFollowers.Count - 1; i >= 0; --i) { - if (!(AllFollowers[i] is BaseCreature pet) || pet.ControlMaster == null) + if (AllFollowers[i] is not BaseCreature pet || pet.ControlMaster == null) { continue; } @@ -3683,7 +3683,7 @@ namespace Server.Mobiles continue; } - if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack?.Items.Count > 0) + if (pet is PackLlama or PackHorse or Beetle && pet.Backpack?.Items.Count > 0) { continue; } @@ -3728,7 +3728,7 @@ namespace Server.Mobiles for (var i = AutoStabled.Count - 1; i >= 0; --i) { - if (!(AutoStabled[i] is BaseCreature pet)) + if (AutoStabled[i] is not BaseCreature pet) { continue; } @@ -3841,8 +3841,7 @@ namespace Server.Mobiles private bool CanInsure(Item item) { - if (item is Container && !(item is BaseQuiver) || item is BagOfSending || item is KeyRing || item is PotionKeg || - item is Sigil) + if (item is Container && item is not BaseQuiver || item is BagOfSending or KeyRing or PotionKeg or Sigil) { return false; } @@ -4068,7 +4067,7 @@ namespace Server.Mobiles return; } - if (!(obj is Item item)) + if (obj is not Item item) { return; } diff --git a/Projects/UOContent/Mobiles/Special/Barracoon.cs b/Projects/UOContent/Mobiles/Special/Barracoon.cs index 71cba9da7..53e88897c 100644 --- a/Projects/UOContent/Mobiles/Special/Barracoon.cs +++ b/Projects/UOContent/Mobiles/Special/Barracoon.cs @@ -145,7 +145,7 @@ namespace Server.Mobiles foreach (var m in eable) { - if (m is Ratman || m is RatmanArcher || m is RatmanMage) + if (m is Ratman or RatmanArcher or RatmanMage) { rats++; if (rats >= 16) diff --git a/Projects/UOContent/Mobiles/Special/BaseChampion.cs b/Projects/UOContent/Mobiles/Special/BaseChampion.cs index b387c7eff..732016313 100644 --- a/Projects/UOContent/Mobiles/Special/BaseChampion.cs +++ b/Projects/UOContent/Mobiles/Special/BaseChampion.cs @@ -132,7 +132,7 @@ namespace Server.Mobiles { var m = toGive[i]; - if (!(m is PlayerMobile)) + if (m is not PlayerMobile) { continue; } @@ -194,7 +194,7 @@ namespace Server.Mobiles } } - if (!(m is PlayerMobile pm)) + if (m is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs b/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs index 908d47c1a..7c1cb745c 100644 --- a/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs +++ b/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs @@ -116,7 +116,7 @@ namespace Server.Mobiles var from = e.Mobile; - if (!(from.Guild is Guild g) || g.Type != Type) + if (@from.Guild is not Guild g || g.Type != Type) { Say(SignupNumber); } diff --git a/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs b/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs index c86bf35e2..d0521bb08 100644 --- a/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs +++ b/Projects/UOContent/Mobiles/Special/HarrowerTentacles.cs @@ -151,7 +151,7 @@ namespace Server.Mobiles continue; } - if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != m_Owner.Team)) + if (m is not BaseCreature bc || !(bc.Controlled || bc.Summoned || bc.Team != m_Owner.Team)) { continue; } diff --git a/Projects/UOContent/Mobiles/Special/Paragon.cs b/Projects/UOContent/Mobiles/Special/Paragon.cs index 784c32d61..feb1c4b84 100644 --- a/Projects/UOContent/Mobiles/Special/Paragon.cs +++ b/Projects/UOContent/Mobiles/Special/Paragon.cs @@ -174,8 +174,7 @@ namespace Server.Mobiles return false; } - if (bc is BaseChampion || bc is Harrower || bc is BaseVendor || bc is BaseEscortable || bc is Clone || - bc.IsParagon) + if (bc is BaseChampion or Harrower or BaseVendor or BaseEscortable or Clone || bc.IsParagon) { return false; } diff --git a/Projects/UOContent/Mobiles/Special/Rikktor.cs b/Projects/UOContent/Mobiles/Special/Rikktor.cs index dc00a7381..47a8327fe 100644 --- a/Projects/UOContent/Mobiles/Special/Rikktor.cs +++ b/Projects/UOContent/Mobiles/Special/Rikktor.cs @@ -109,7 +109,7 @@ namespace Server.Mobiles continue; } - if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + if (m is not BaseCreature bc || !(bc.Controlled || bc.Summoned || bc.Team != Team)) { continue; } diff --git a/Projects/UOContent/Mobiles/Special/Semidar.cs b/Projects/UOContent/Mobiles/Special/Semidar.cs index b14259708..e6092bd43 100644 --- a/Projects/UOContent/Mobiles/Special/Semidar.cs +++ b/Projects/UOContent/Mobiles/Special/Semidar.cs @@ -101,7 +101,7 @@ namespace Server.Mobiles continue; } - if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + if (m is not BaseCreature bc || !(bc.Controlled || bc.Summoned || bc.Team != Team)) { continue; } diff --git a/Projects/UOContent/Mobiles/Special/Serado.cs b/Projects/UOContent/Mobiles/Special/Serado.cs index 20c680008..39d204493 100644 --- a/Projects/UOContent/Mobiles/Special/Serado.cs +++ b/Projects/UOContent/Mobiles/Special/Serado.cs @@ -163,7 +163,7 @@ namespace Server.Mobiles continue; } - if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) + if (m is not BaseCreature bc || !(bc.Controlled || bc.Summoned || bc.Team != Team)) { continue; } diff --git a/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs b/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs index b6e60df77..21dbb152b 100644 --- a/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs +++ b/Projects/UOContent/Mobiles/Townfolk/BaseEscortable.cs @@ -746,7 +746,7 @@ namespace Server.Mobiles foreach (Region r in list) { - if (r.Name != null && (r is DungeonRegion || r is TownRegion)) + if (r.Name != null && r is DungeonRegion or TownRegion) { m_Table[r.Name] = new EscortDestinationInfo(r.Name, r); } diff --git a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs index aaeb542aa..8cb8eb5c2 100644 --- a/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/BaseVendor.cs @@ -757,7 +757,7 @@ namespace Server.Mobiles for (var i = 0; i < Items.Count; ++i) { var item = Items[i]; - if (item is BaseClothing || item is BaseWeapon || item is BaseArmor || item is BaseTool) + if (item is BaseClothing or BaseWeapon or BaseArmor or BaseTool) { item.Hue = GetRandomNecromancerHue(); } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs index 844645099..a1f8af86a 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/AnimalTrainer.cs @@ -230,7 +230,7 @@ namespace Server.Mobiles SayTo( from, 1048053 ); // You can't stable that! } */ - else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack?.Items.Count > 0) + else if (pet is PackLlama or PackHorse or Beetle && pet.Backpack?.Items.Count > 0) { SayTo(from, 1042563); // You need to unload your pet. } diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs index fc643c672..74641de39 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Blacksmith.cs @@ -126,7 +126,7 @@ namespace Server.Mobiles return null; } - public override bool IsValidBulkOrder(Item item) => item is SmallSmithBOD || item is LargeSmithBOD; + public override bool IsValidBulkOrder(Item item) => item is SmallSmithBOD or LargeSmithBOD; public override bool SupportsBulkOrders(Mobile from) => from is PlayerMobile && from.Skills.Blacksmith.Base > 0; diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs index 6b9e90375..5cb0c9214 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Tailor.cs @@ -68,7 +68,7 @@ namespace Server.Mobiles return null; } - public override bool IsValidBulkOrder(Item item) => item is SmallTailorBOD || item is LargeTailorBOD; + public override bool IsValidBulkOrder(Item item) => item is SmallTailorBOD or LargeTailorBOD; public override bool SupportsBulkOrders(Mobile from) => from is PlayerMobile && from.Skills.Tailoring.Base > 0; diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs index 3f3bed4ca..635877993 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Weaponsmith.cs @@ -92,7 +92,7 @@ namespace Server.Mobiles return null; } - public override bool IsValidBulkOrder(Item item) => item is SmallSmithBOD || item is LargeSmithBOD; + public override bool IsValidBulkOrder(Item item) => item is SmallSmithBOD or LargeSmithBOD; public override bool SupportsBulkOrders(Mobile from) => from is PlayerMobile && Core.AOS && from.Skills.Blacksmith.Base > 0; diff --git a/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs b/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs index 6a6a82c9e..bda5cf958 100644 --- a/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs +++ b/Projects/UOContent/Mobiles/Vendors/NPC/Weaver.cs @@ -74,7 +74,7 @@ namespace Server.Mobiles return null; } - public override bool IsValidBulkOrder(Item item) => item is SmallTailorBOD || item is LargeTailorBOD; + public override bool IsValidBulkOrder(Item item) => item is SmallTailorBOD or LargeTailorBOD; public override bool SupportsBulkOrders(Mobile from) => from is PlayerMobile && from.Skills.Tailoring.Base > 0; diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs b/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs index 8f31ed70f..c2f12b988 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerBarkeeper.cs @@ -315,7 +315,7 @@ namespace Server.Mobiles public override bool CheckGold(Mobile from, Item dropped) { - if (!(dropped is Gold g)) + if (dropped is not Gold g) { return false; } @@ -541,8 +541,7 @@ namespace Server.Mobiles public override void InitSBInfo() { - if (Title == "the waiter" || Title == "the barkeeper" || Title == "the baker" || Title == "the innkeeper" || - Title == "the chef") + if (Title is "the waiter" or "the barkeeper" or "the baker" or "the innkeeper" or "the chef") { if (m_SBInfos.Count == 0) { diff --git a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs index 8bb6fdcb7..11c3e340d 100644 --- a/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs +++ b/Projects/UOContent/Mobiles/Vendors/PlayerVendor.cs @@ -124,7 +124,7 @@ namespace Server.Mobiles return false; } - if (item is Container || item is BulkOrderBook) + if (item is Container or BulkOrderBook) { return true; } @@ -142,7 +142,7 @@ namespace Server.Mobiles { base.GetChildContextMenuEntries(from, list, item); - if (!(RootParent is PlayerVendor pv) || pv.IsOwner(from)) + if (RootParent is not PlayerVendor pv || pv.IsOwner(from)) { return; } @@ -1043,7 +1043,7 @@ namespace Server.Mobiles public static void TryToBuy(Item item, Mobile from) { - if (!(item.RootParent is PlayerVendor vendor) || !vendor.CanInteractWith(from, false)) + if (item.RootParent is not PlayerVendor vendor || !vendor.CanInteractWith(from, false)) { return; } @@ -1493,7 +1493,7 @@ namespace Server.Mobiles setPrice = true; } } - else if (item is BaseBook || item is BulkOrderBook) + else if (item is BaseBook or BulkOrderBook) { setPrice = true; } diff --git a/Projects/UOContent/Multis/Boats/BaseBoat.cs b/Projects/UOContent/Multis/Boats/BaseBoat.cs index ff86aa515..409d7e31f 100644 --- a/Projects/UOContent/Multis/Boats/BaseBoat.cs +++ b/Projects/UOContent/Multis/Boats/BaseBoat.cs @@ -1749,7 +1749,7 @@ namespace Server.Multis { item.NoMoveHS = true; - if (!(item is TillerMan || item is Hold || item is Plank)) + if (!(item is Server.Items.TillerMan or Server.Items.Hold or Plank)) { item.Location = new Point3D(item.X + xOffset, item.Y + yOffset, item.Z); } diff --git a/Projects/UOContent/Multis/Boats/Plank.cs b/Projects/UOContent/Multis/Boats/Plank.cs index e6c0811e4..7c838fab4 100644 --- a/Projects/UOContent/Multis/Boats/Plank.cs +++ b/Projects/UOContent/Multis/Boats/Plank.cs @@ -37,7 +37,7 @@ namespace Server.Items public PlankSide Side { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool IsOpen => ItemID == 0x3ED5 || ItemID == 0x3ED4 || ItemID == 0x3E84 || ItemID == 0x3E89; + public bool IsOpen => ItemID is 0x3ED5 or 0x3ED4 or 0x3E84 or 0x3E89; [CommandProperty(AccessLevel.GameMaster)] public bool Starboard => Side == PlankSide.Starboard; diff --git a/Projects/UOContent/Multis/Houses/BaseHouse.cs b/Projects/UOContent/Multis/Houses/BaseHouse.cs index eef3a3b15..66cef968e 100644 --- a/Projects/UOContent/Multis/Houses/BaseHouse.cs +++ b/Projects/UOContent/Multis/Houses/BaseHouse.cs @@ -116,7 +116,7 @@ namespace Server.Multis return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh; } - if (!(m_Owner.Account is Account acct)) + if (m_Owner.Account is not Account acct) { return Core.AOS ? DecayType.Condemned : DecayType.ManualRefresh; } @@ -185,7 +185,7 @@ namespace Server.Multis { var type = DecayType; - return type == DecayType.Condemned || type == DecayType.ManualRefresh; + return type is DecayType.Condemned or DecayType.ManualRefresh; } } @@ -258,7 +258,7 @@ namespace Server.Multis { foreach (var vendor in PlayerVendors) { - if (!(vendor is RentedVendor)) + if (vendor is not RentedVendor) { return true; } @@ -463,7 +463,7 @@ namespace Server.Multis continue; } - if (!(info.Item is StrongBox)) + if (info.Item is not StrongBox) { count += 1; } @@ -756,7 +756,7 @@ namespace Server.Multis { if ((location.Z - entity.Z).Abs() <= 16) { - if (entity is PlayerVendor || entity is PlayerBarkeeper || entity is PlayerVendorPlaceholder) + if (entity is PlayerVendor or PlayerBarkeeper or PlayerVendorPlaceholder) { vendor = true; break; @@ -1495,7 +1495,7 @@ namespace Server.Multis public SecureAccessResult CheckSecureAccess(Mobile m, Item item) { - if (Secures == null || !(item is Container)) + if (Secures == null || item is not Container) { return SecureAccessResult.Insecure; } @@ -1770,7 +1770,7 @@ namespace Server.Multis { door = new GenericHouseDoor(DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false); } - else if (itemID == 0x2D48 || itemID == 0x2FE2) + else if (itemID is 0x2D48 or 0x2FE2) { door = new GenericHouseDoor(DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false); } @@ -1783,7 +1783,7 @@ namespace Server.Multis door = new GenericHouseDoor(facing, 0x2D63 + 4 * type + mod * 2, 0xEA, 0xF1, false); } - else if (itemID == 0x2FE4 || itemID == 0x31AE) + else if (itemID is 0x2FE4 or 0x31AE) { door = new GenericHouseDoor(DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false); } @@ -2057,7 +2057,7 @@ namespace Server.Multis i.SetLastMoved(); } - if (i is Container && (!locked || !(i is BaseBoard || i is Aquarium || i is FishBowl))) + if (i is Container && (!locked || !(i is BaseBoard or Aquarium or FishBowl))) { foreach (var c in i.Items) { @@ -2102,7 +2102,7 @@ namespace Server.Multis { m.SendLocalizedMessage(501736); // You must lockdown the container first! } - else if (!(item is VendorRentalContract) && (IsAosRules + else if (item is not VendorRentalContract && (IsAosRules ? !CheckAosLockdowns(amt) || !CheckAosStorage(amt) : LockDownCount + amt > MaxLockDowns)) { @@ -2119,7 +2119,7 @@ namespace Server.Multis m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1005526); // That is already locked down return true; } - else if (item is HouseSign || item is Static) + else if (item is HouseSign or Static) { m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1005526); // This is already locked down. } @@ -2363,7 +2363,7 @@ namespace Server.Multis { m.SendLocalizedMessage(1010550); // This is already locked down and cannot be secured. } - else if (!(item is Container)) + else if (item is not Container) { LockDown(m, item); } @@ -2389,7 +2389,7 @@ namespace Server.Multis m.SendLocalizedMessage(1010423); // You cannot secure this, place it on the ground first. } // Mondain's Legacy mod - else if (!(item is BaseAddonContainer) && !item.Movable) + else if (item is not BaseAddonContainer && !item.Movable) { m.SendLocalizedMessage(1010424); // You cannot secure this. } @@ -2437,7 +2437,7 @@ namespace Server.Multis if (info.Defender.Player && info.Defender.Alive && Core.Now - info.LastCombatTime < HouseRegion.CombatHeatDelay && - (!(m.Guild is Guild attackerGuild) || !(info.Defender.Guild is Guild defenderGuild) || + (m.Guild is not Guild attackerGuild || info.Defender.Guild is not Guild defenderGuild || defenderGuild != attackerGuild && !defenderGuild.IsEnemy(attackerGuild))) { return true; @@ -2946,7 +2946,7 @@ namespace Server.Multis { var item = LockDowns[i]; - if (item is Container cont && !(cont is BaseBoard || cont is Aquarium || cont is FishBowl)) + if (item is Container cont && !(cont is BaseBoard or Aquarium or FishBowl)) { var children = cont.Items; @@ -3290,7 +3290,7 @@ namespace Server.Multis { var item = LockDowns[i]; - if (!(item is Container)) + if (item is not Container) { count += item.TotalItems; } @@ -3486,7 +3486,7 @@ namespace Server.Multis public static bool HasAccountHouse(Mobile m) { - if (!(m.Account is Account a)) + if (m.Account is not Account a) { return false; } @@ -3596,7 +3596,7 @@ namespace Server.Multis return true; } - if (!(m is BaseCreature bc)) + if (m is not BaseCreature bc) { return false; } diff --git a/Projects/UOContent/Multis/Houses/HouseFoundation.cs b/Projects/UOContent/Multis/Houses/HouseFoundation.cs index 45a1a5925..bd63938ec 100644 --- a/Projects/UOContent/Multis/Houses/HouseFoundation.cs +++ b/Projects/UOContent/Multis/Houses/HouseFoundation.cs @@ -430,7 +430,7 @@ namespace Server.Multis { door = new GenericHouseDoor(DoorFacing.NorthCW, 0x2D46, 0xEA, 0xF1, false); } - else if (itemID == 0x2D48 || itemID == 0x2FE2) + else if (itemID is 0x2D48 or 0x2FE2) { door = new GenericHouseDoor(DoorFacing.SouthCCW, itemID, 0xEA, 0xF1, false); } @@ -443,7 +443,7 @@ namespace Server.Multis door = new GenericHouseDoor(facing, 0x2D63 + 4 * type + mod * 2, 0xEA, 0xF1, false); } - else if (itemID == 0x2FE4 || itemID == 0x31AE) + else if (itemID is 0x2FE4 or 0x31AE) { door = new GenericHouseDoor(DoorFacing.WestCCW, itemID, 0xEA, 0xF1, false); } @@ -453,11 +453,11 @@ namespace Server.Multis var mod = (itemID - 0x319C) / 2 % 2; - var specialCase = itemID == 0x31AA || itemID == 0x31A8; + var specialCase = itemID is 0x31AA or 0x31A8; DoorFacing facing; - if (itemID == 0x31AA || itemID == 0x31A8) + if (itemID is 0x31AA or 0x31A8) { facing = mod == 0 ? DoorFacing.NorthCW : DoorFacing.EastCW; } @@ -1809,7 +1809,7 @@ namespace Server.Multis var mcl = design.Components; - if (z < -3 || z > 12 || z % 3 != 0) + if (z is < -3 or > 12 || z % 3 != 0) { z = -3; } @@ -2082,7 +2082,7 @@ namespace Server.Multis } // ML doors - if (itemID == 0x2D46 || itemID == 0x2D48 || itemID == 0x2FE2 || itemID == 0x2FE4) + if (itemID is 0x2D46 or 0x2D48 or 0x2FE2 or 0x2FE4) { return true; } diff --git a/Projects/UOContent/Multis/Houses/HousePlacement.cs b/Projects/UOContent/Multis/Houses/HousePlacement.cs index 3f452ad67..5a5640bb9 100644 --- a/Projects/UOContent/Multis/Houses/HousePlacement.cs +++ b/Projects/UOContent/Multis/Houses/HousePlacement.cs @@ -58,7 +58,7 @@ namespace Server.Multis return HousePlacementResult.BadRegion; // No houses in Ilshenar/T2A } - if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E)) + if (map == Map.Malas && multiID is 0x007C or 0x007E) { return HousePlacementResult.InvalidCastleKeep; } diff --git a/Projects/UOContent/Multis/Houses/MovingCrate.cs b/Projects/UOContent/Multis/Houses/MovingCrate.cs index 6ef37c309..7388323fd 100644 --- a/Projects/UOContent/Multis/Houses/MovingCrate.cs +++ b/Projects/UOContent/Multis/Houses/MovingCrate.cs @@ -59,7 +59,7 @@ namespace Server.Multis { var subItem = subItems[i]; - if (!(subItem is Container) && subItem.StackWith(null, dropped, false)) + if (subItem is not Container && subItem.StackWith(null, dropped, false)) { return; } diff --git a/Projects/UOContent/Regions/GuardedRegion.cs b/Projects/UOContent/Regions/GuardedRegion.cs index 09af983db..d714c1719 100644 --- a/Projects/UOContent/Regions/GuardedRegion.cs +++ b/Projects/UOContent/Regions/GuardedRegion.cs @@ -245,7 +245,7 @@ namespace Server.Regions var noto = Notoriety.Compute(helper, helped); - if (helper != helped && (noto == Notoriety.Criminal || noto == Notoriety.Murderer)) + if (helper != helped && noto is Notoriety.Criminal or Notoriety.Murderer) { CheckGuardCandidate(helper); } @@ -358,8 +358,8 @@ namespace Server.Regions } public bool IsGuardCandidate(Mobile m) => - !(m is BaseGuard) && m.Alive && m.AccessLevel <= AccessLevel.Player && !m.Blessed && - (!(m is BaseCreature creature) || !creature.IsInvulnerable) && !IsDisabled() && + m is not BaseGuard && m.Alive && m.AccessLevel <= AccessLevel.Player && !m.Blessed && + (m is not BaseCreature creature || !creature.IsInvulnerable) && !IsDisabled() && (!AllowReds && m.Kills >= 5 || m.Criminal); private class GuardTimer : Timer diff --git a/Projects/UOContent/Skills/Inscribe.cs b/Projects/UOContent/Skills/Inscribe.cs index dbcca17e8..84c47de5f 100644 --- a/Projects/UOContent/Skills/Inscribe.cs +++ b/Projects/UOContent/Skills/Inscribe.cs @@ -86,7 +86,7 @@ namespace Server.SkillHandlers protected override void OnTarget(Mobile from, object targeted) { - if (!(targeted is BaseBook book)) + if (targeted is not BaseBook book) { from.SendLocalizedMessage(1046296); // That is not a book } @@ -131,7 +131,7 @@ namespace Server.SkillHandlers return; } - if (!(targeted is BaseBook bookDst)) + if (targeted is not BaseBook bookDst) { from.SendLocalizedMessage(1046296); // That is not a book } diff --git a/Projects/UOContent/Skills/Peacemaking.cs b/Projects/UOContent/Skills/Peacemaking.cs index 1101c7b21..d6f479a1e 100644 --- a/Projects/UOContent/Skills/Peacemaking.cs +++ b/Projects/UOContent/Skills/Peacemaking.cs @@ -54,7 +54,7 @@ namespace Server.SkillHandlers { from.RevealingAction(); - if (!(targeted is Mobile targ)) + if (targeted is not Mobile targ) { from.SendLocalizedMessage(1049528); // You cannot calm that! } diff --git a/Projects/UOContent/Skills/Poisoning.cs b/Projects/UOContent/Skills/Poisoning.cs index 1c8d0ead2..6e920360b 100644 --- a/Projects/UOContent/Skills/Poisoning.cs +++ b/Projects/UOContent/Skills/Poisoning.cs @@ -56,7 +56,7 @@ namespace Server.SkillHandlers var startTimer = false; - if (targeted is Food || targeted is FukiyaDarts || targeted is Shuriken) + if (targeted is Food or FukiyaDarts or Shuriken) { startTimer = true; } @@ -69,7 +69,7 @@ namespace Server.SkillHandlers } else if (weapon.Layer == Layer.OneHanded) { - startTimer = weapon.Type == WeaponType.Slashing || weapon.Type == WeaponType.Piercing; + startTimer = weapon.Type is WeaponType.Slashing or WeaponType.Piercing; } } diff --git a/Projects/UOContent/Skills/Provocation.cs b/Projects/UOContent/Skills/Provocation.cs index 7078aef11..ad5571005 100644 --- a/Projects/UOContent/Skills/Provocation.cs +++ b/Projects/UOContent/Skills/Provocation.cs @@ -107,7 +107,7 @@ namespace Server.SkillHandlers { from.SendLocalizedMessage(1049446); // You have no chance of provoking those creatures. } - else if (creature.Unprovokable && !(creature is DemonKnight)) + else if (creature.Unprovokable && creature is not DemonKnight) { from.SendLocalizedMessage(1049446); // You have no chance of provoking those creatures. } diff --git a/Projects/UOContent/Skills/Snooping.cs b/Projects/UOContent/Skills/Snooping.cs index 43f894fe3..73b03bffc 100644 --- a/Projects/UOContent/Skills/Snooping.cs +++ b/Projects/UOContent/Skills/Snooping.cs @@ -38,77 +38,76 @@ namespace Server.SkillHandlers public static void Container_Snoop(Container cont, Mobile from) { - if (from.AccessLevel > AccessLevel.Player || from.InRange(cont.GetWorldLocation(), 1)) + if (from.AccessLevel <= AccessLevel.Player && !from.InRange(cont.GetWorldLocation(), 1)) { - var root = cont.RootParent as Mobile; + from.SendLocalizedMessage(500446); // That is too far away. + return; + } - if (root?.Alive == false) + var root = cont.RootParent as Mobile; + + if (root?.Alive == false) + { + return; + } + + if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player) + { + from.SendLocalizedMessage(500209); // You can not peek into the container. + return; + } + + if (root?.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root)) + { + from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target. + return; + } + + if (root?.AccessLevel == AccessLevel.Player && + from.Skills.Snooping.Value < Utility.Random(100)) + { + var map = from.Map; + + if (map != null) { - return; - } + var message = $"You notice {from.Name} attempting to peek into {root.Name}'s belongings."; - if (root?.AccessLevel > AccessLevel.Player && from.AccessLevel == AccessLevel.Player) - { - from.SendLocalizedMessage(500209); // You can not peek into the container. - return; - } + var eable = map.GetClientsInRange(from.Location, 8); - if (root?.AccessLevel == AccessLevel.Player && !CheckSnoopAllowed(from, root)) - { - from.SendLocalizedMessage(1001018); // You cannot perform negative acts on your target. - return; - } - - if (root?.AccessLevel == AccessLevel.Player && - from.Skills.Snooping.Value < Utility.Random(100)) - { - var map = from.Map; - - if (map != null) + foreach (var ns in eable) { - var message = $"You notice {from.Name} attempting to peek into {root.Name}'s belongings."; - - var eable = map.GetClientsInRange(from.Location, 8); - - foreach (var ns in eable) + if (ns.Mobile != from) { - if (ns.Mobile != from) - { - ns.Mobile.SendMessage(message); - } + ns.Mobile.SendMessage(message); } - - eable.Free(); - } - } - - if (from.AccessLevel == AccessLevel.Player) - { - Titles.AwardKarma(from, -4, true); - } - - if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0)) - { - if (cont is TrappableContainer container && container.ExecuteTrap(from)) - { - return; } - cont.DisplayTo(from); + eable.Free(); } - else - { - from.SendLocalizedMessage(500210); // You failed to peek into the container. + } - if (from.Skills.Hiding.Value / 2 < Utility.Random(100)) - { - from.RevealingAction(); - } + if (from.AccessLevel == AccessLevel.Player) + { + Titles.AwardKarma(from, -4, true); + } + + if (from.AccessLevel > AccessLevel.Player || from.CheckTargetSkill(SkillName.Snooping, cont, 0.0, 100.0)) + { + if (cont is TrappableContainer container && container.ExecuteTrap(from)) + { + return; } + + cont.DisplayTo(from); } else { - from.SendLocalizedMessage(500446); // That is too far away. + from.SendLocalizedMessage(500210); // You failed to peek into the container. + + if (from.Skills.Hiding.Value / 2 < Utility.Random(100)) + { + from.RevealingAction(); + } } } } diff --git a/Projects/UOContent/Skills/SpiritSpeak.cs b/Projects/UOContent/Skills/SpiritSpeak.cs index 7bc04ddab..69b40fcf8 100644 --- a/Projects/UOContent/Skills/SpiritSpeak.cs +++ b/Projects/UOContent/Skills/SpiritSpeak.cs @@ -116,7 +116,7 @@ namespace Server.SkillHandlers public override bool CheckDisturb(DisturbType type, bool checkFirst, bool resistable) { - if (type == DisturbType.EquipRequest || type == DisturbType.UseRequest) + if (type is DisturbType.EquipRequest or DisturbType.UseRequest) { return false; } diff --git a/Projects/UOContent/Special Systems/Engines/GiftGiving.cs b/Projects/UOContent/Special Systems/Engines/GiftGiving.cs index 14634063b..5cfc1a06a 100644 --- a/Projects/UOContent/Special Systems/Engines/GiftGiving.cs +++ b/Projects/UOContent/Special Systems/Engines/GiftGiving.cs @@ -26,7 +26,7 @@ namespace Server.Misc private static void EventSink_Login(Mobile m) { - if (!(m.Account is Account acct)) + if (m.Account is not Account acct) { return; } diff --git a/Projects/UOContent/Spells/Base/SpellHelper.cs b/Projects/UOContent/Spells/Base/SpellHelper.cs index 383228b49..ea9ec4131 100644 --- a/Projects/UOContent/Spells/Base/SpellHelper.cs +++ b/Projects/UOContent/Spells/Base/SpellHelper.cs @@ -623,7 +623,7 @@ namespace Server.Spells public static void SendInvalidMessage(Mobile caster, TravelCheckType type) { - if (type == TravelCheckType.RecallTo || type == TravelCheckType.GateTo) + if (type is TravelCheckType.RecallTo or TravelCheckType.GateTo) { caster.SendLocalizedMessage(1019004); // You are not allowed to travel there. } @@ -754,7 +754,7 @@ namespace Server.Spells public static bool IsSafeZone(Map map, Point3D loc) => Region.Find(loc, map).IsPartOf() && - (m_TravelType == TravelCheckType.TeleportTo || m_TravelType == TravelCheckType.TeleportFrom) + m_TravelType is TravelCheckType.TeleportTo or TravelCheckType.TeleportFrom && (m_TravelCaster as PlayerMobile)?.DuelPlayer?.Eliminated == false; public static bool IsFactionStronghold(Map map, Point3D loc) => Region.Find(loc, map).IsPartOf(); diff --git a/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs b/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs index ec88fd711..658eee2e6 100644 --- a/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs +++ b/Projects/UOContent/Spells/Ninjitsu/FocusAttack.cs @@ -20,14 +20,14 @@ namespace Server.Spells.Ninjitsu Item handOne = from.FindItemOnLayer(Layer.OneHanded) as BaseWeapon; - if (handOne != null && !(handOne is BaseRanged)) + if (handOne != null && handOne is not BaseRanged) { return base.Validate(from); } Item handTwo = from.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; - if (handTwo != null && !(handTwo is BaseRanged)) + if (handTwo != null && handTwo is not BaseRanged) { return base.Validate(from); } diff --git a/Projects/UOContent/Spells/Seventh/GateTravel.cs b/Projects/UOContent/Spells/Seventh/GateTravel.cs index 258dce8a3..13a171c04 100644 --- a/Projects/UOContent/Spells/Seventh/GateTravel.cs +++ b/Projects/UOContent/Spells/Seventh/GateTravel.cs @@ -129,7 +129,7 @@ namespace Server.Spells.Seventh foreach (var item in eable) { - if (item is Moongate || item is PublicMoongate) + if (item is Moongate or PublicMoongate) { return true; } diff --git a/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs b/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs index 5399efdec..de4e854ee 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcaneCircle.cs @@ -118,9 +118,7 @@ namespace Server.Spells.Spellweaving } public static bool IsValidTile(int itemID) => - itemID == 0xFEA || itemID == 0x1216 || itemID == 0x307F || itemID == 0x1D10 || itemID == 0x1D0F || - itemID == 0x1D1F || - itemID == 0x1D12; + itemID is 0xFEA or 0x1216 or 0x307F or 0x1D10 or 0x1D0F or 0x1D1F or 0x1D12; private List GetArcanists() { diff --git a/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs b/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs index 919abb461..4ebe0f2aa 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs @@ -34,7 +34,7 @@ namespace Server.Spells.Spellweaving from.Holding as ArcaneFocus ?? from.Backpack?.FindItemByType(); public static bool CheckExpansion(Mobile from) => - !(from is PlayerMobile) || from.NetState?.SupportsExpansion(Expansion.ML) == true; + @from is not PlayerMobile || from.NetState?.SupportsExpansion(Expansion.ML) == true; public override bool CheckCast() { diff --git a/Projects/UOContent/Spells/Spellweaving/ImmolatingWeapon.cs b/Projects/UOContent/Spells/Spellweaving/ImmolatingWeapon.cs index 33b1a58cc..f1b6059d8 100644 --- a/Projects/UOContent/Spells/Spellweaving/ImmolatingWeapon.cs +++ b/Projects/UOContent/Spells/Spellweaving/ImmolatingWeapon.cs @@ -26,7 +26,7 @@ namespace Server.Spells.Spellweaving public override bool CheckCast() { - if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists || weapon is BaseRanged) + if (Caster.Weapon is not BaseWeapon weapon || weapon is Fists or BaseRanged) { Caster.SendLocalizedMessage(1060179); // You must be wielding a weapon to use this ability! return false; @@ -37,7 +37,7 @@ namespace Server.Spells.Spellweaving public override void OnCast() { - if (!(Caster.Weapon is BaseWeapon weapon) || weapon is Fists || weapon is BaseRanged) + if (Caster.Weapon is not BaseWeapon weapon || weapon is Fists or BaseRanged) { Caster.SendLocalizedMessage(1060179); // You must be wielding a weapon to use this ability! } diff --git a/Projects/UOContent/Targets/BladedItemTarget.cs b/Projects/UOContent/Targets/BladedItemTarget.cs index fd2dba71c..8cef72166 100644 --- a/Projects/UOContent/Targets/BladedItemTarget.cs +++ b/Projects/UOContent/Targets/BladedItemTarget.cs @@ -52,7 +52,7 @@ namespace Server.Targets { var itemID = target.ItemID; - if (itemID == 0xD15 || itemID == 0xD16) // red mushroom + if (itemID is 0xD15 or 0xD16) // red mushroom { var player = from as PlayerMobile; diff --git a/Projects/UOContent/Targets/PickMoveTarget.cs b/Projects/UOContent/Targets/PickMoveTarget.cs index 433eb5652..595f1ffd1 100644 --- a/Projects/UOContent/Targets/PickMoveTarget.cs +++ b/Projects/UOContent/Targets/PickMoveTarget.cs @@ -17,7 +17,7 @@ namespace Server.Targets return; } - if (o is Item || o is Mobile) + if (o is Item or Mobile) { from.Target = new MoveTarget(o); } From 3cba8c43f8bea35e30eeb5b294508edabc43c16d Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 24 Dec 2021 15:56:07 -0800 Subject: [PATCH 14/14] fix: Removes from literals (#893) --- Projects/UOContent/Accounting/AccountHandler.cs | 2 +- Projects/UOContent/Commands/Handlers.cs | 2 +- Projects/UOContent/Commands/Logging.cs | 2 +- Projects/UOContent/Engines/ConPVP/DuelContext.cs | 2 +- Projects/UOContent/Engines/Help/PageQueue.cs | 2 +- .../UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs | 2 +- .../UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs | 2 +- .../UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs | 2 +- .../Engines/Quests/Dark Tides/Items/KronusScroll.cs | 2 +- .../Quests/Emino's Undertaking/EminosUndertakingQuest.cs | 4 ++-- .../Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs | 2 +- .../Engines/Quests/Haochi's Trials/Items/HonorCandle.cs | 2 +- .../Engines/Quests/Solen Matriarch/Objectives.cs | 4 ++-- .../Engines/Quests/Uzeraan Turmoil/Objectives.cs | 2 +- .../Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs | 8 ++++---- .../Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs | 2 +- .../Gumps/Guilds/New Guild System/OtherGuildInfo.cs | 2 +- Projects/UOContent/Items/Addons/DartBoard.cs | 2 +- Projects/UOContent/Items/Misc/Corpses/Corpse.cs | 2 +- .../Items/Skill Items/Harvest Tools/BaseHarvestTool.cs | 2 +- .../Items/Special/House Raffle/HouseRaffleStone.cs | 4 ++-- Projects/UOContent/Items/Special/SoulStone.cs | 2 +- Projects/UOContent/Items/Wands/BaseWand.cs | 2 +- Projects/UOContent/Mobiles/PlayerMobile.cs | 2 +- Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs | 2 +- Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs | 2 +- 26 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Projects/UOContent/Accounting/AccountHandler.cs b/Projects/UOContent/Accounting/AccountHandler.cs index 55c6a7598..642660d05 100644 --- a/Projects/UOContent/Accounting/AccountHandler.cs +++ b/Projects/UOContent/Accounting/AccountHandler.cs @@ -110,7 +110,7 @@ namespace Server.Misc { var from = e.Mobile; - if (@from.Account is not Account acct) + if (from.Account is not Account acct) { return; } diff --git a/Projects/UOContent/Commands/Handlers.cs b/Projects/UOContent/Commands/Handlers.cs index 94a7f9395..98279f8ed 100644 --- a/Projects/UOContent/Commands/Handlers.cs +++ b/Projects/UOContent/Commands/Handlers.cs @@ -595,7 +595,7 @@ namespace Server.Commands { map = Map.AllMaps[i]; - if (map.MapIndex is 0x7F or 0xFF || @from.Map == map) + if (map.MapIndex is 0x7F or 0xFF || from.Map == map) { continue; } diff --git a/Projects/UOContent/Commands/Logging.cs b/Projects/UOContent/Commands/Logging.cs index 94f40d597..1ba8401d8 100644 --- a/Projects/UOContent/Commands/Logging.cs +++ b/Projects/UOContent/Commands/Logging.cs @@ -73,7 +73,7 @@ namespace Server.Commands var path = Core.BaseDirectory; - var name = @from.Account is not Account acct ? from.Name : acct.Username; + var name = from.Account is not Account acct ? from.Name : acct.Username; AppendPath(ref path, "Logs"); AppendPath(ref path, "Commands"); diff --git a/Projects/UOContent/Engines/ConPVP/DuelContext.cs b/Projects/UOContent/Engines/ConPVP/DuelContext.cs index b745ad9af..9e763c767 100644 --- a/Projects/UOContent/Engines/ConPVP/DuelContext.cs +++ b/Projects/UOContent/Engines/ConPVP/DuelContext.cs @@ -257,7 +257,7 @@ namespace Server.Engines.ConPVP public static bool AllowSpecialAbility(Mobile from, string name, bool message) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return true; } diff --git a/Projects/UOContent/Engines/Help/PageQueue.cs b/Projects/UOContent/Engines/Help/PageQueue.cs index dee5f13ad..07c4b9509 100644 --- a/Projects/UOContent/Engines/Help/PageQueue.cs +++ b/Projects/UOContent/Engines/Help/PageQueue.cs @@ -128,7 +128,7 @@ namespace Server.Engines.Help public static bool CheckAllowedToPage(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return true; } diff --git a/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs b/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs index b6759c71c..d5b6a0555 100644 --- a/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs +++ b/Projects/UOContent/Engines/ML Quests/Gumps/RaceChangeGump.cs @@ -325,7 +325,7 @@ namespace Server.Engines.MLQuests.Gumps public override void OnDoubleClick(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs b/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs index 64978b443..430506447 100644 --- a/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs +++ b/Projects/UOContent/Engines/ML Quests/Items/PrismaticCrystal.cs @@ -22,7 +22,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (@from is not PlayerMobile pm || pm.Backpack == null) + if (from is not PlayerMobile pm || pm.Backpack == null) { return; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs b/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs index 5ce3407d6..6cbf52433 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/DarkTidesQuest.cs @@ -83,7 +83,7 @@ namespace Server.Engines.Quests.Necro public static bool HasLostCallingScroll(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs index 8c91b6a3f..9fa4a5b48 100644 --- a/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs +++ b/Projects/UOContent/Engines/Quests/Dark Tides/Items/KronusScroll.cs @@ -31,7 +31,7 @@ namespace Server.Engines.Quests.Necro return; } - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs b/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs index bf03061c2..6ca8c0a1a 100644 --- a/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs +++ b/Projects/UOContent/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs @@ -99,7 +99,7 @@ namespace Server.Engines.Quests.Ninja public static bool HasLostNoteForZoel(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } @@ -119,7 +119,7 @@ namespace Server.Engines.Quests.Ninja public static bool HasLostEminosKatana(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs index bc66e7b7c..778c24a1f 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs @@ -102,7 +102,7 @@ namespace Server.Engines.Quests.Samurai public static bool HasLostHaochisKatana(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs index ce08640bb..af6cef5fa 100644 --- a/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs +++ b/Projects/UOContent/Engines/Quests/Haochi's Trials/Items/HonorCandle.cs @@ -30,7 +30,7 @@ namespace Server.Engines.Quests.Samurai if (!wasBurning && Burning) { - if (@from is not PlayerMobile player) + if (from is not PlayerMobile player) { return; } diff --git a/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs b/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs index dc889d0f4..6a4bf5b37 100644 --- a/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Solen Matriarch/Objectives.cs @@ -43,10 +43,10 @@ namespace Server.Engines.Quests.Matriarch if (redSolen) { - return @from is BlackSolenInfiltratorWarrior or BlackSolenInfiltratorQueen; + return from is BlackSolenInfiltratorWarrior or BlackSolenInfiltratorQueen; } - return @from is RedSolenInfiltratorWarrior or RedSolenInfiltratorQueen; + return from is RedSolenInfiltratorWarrior or RedSolenInfiltratorQueen; } public override void OnKill(BaseCreature creature, Container corpse) diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs index 91d2997b4..1de4f00ab 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/Objectives.cs @@ -395,7 +395,7 @@ namespace Server.Engines.Quests.Haven public override bool IgnoreYoungProtection(Mobile from) { // This restriction continues until the end of the quest - if (@from is Zombie or Skeleton && from.Map == Map.Trammel && from.X >= 3391 && from.X <= 3424 && + if (from is Zombie or Skeleton && from.Map == Map.Trammel && from.X >= 3391 && from.X <= 3424 && from.Y >= 2639 && from.Y <= 2664) // Haven graveyard { return true; diff --git a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs index 28b56908f..42236d5de 100644 --- a/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs +++ b/Projects/UOContent/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs @@ -110,7 +110,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostScrollOfPower(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } @@ -130,7 +130,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostFertileDirt(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } @@ -150,7 +150,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostDaemonBlood(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } @@ -170,7 +170,7 @@ namespace Server.Engines.Quests.Haven public static bool HasLostDaemonBone(Mobile from) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return false; } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs index c5bf35787..706035ed1 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs @@ -244,7 +244,7 @@ namespace Server.Guilds public void SetTitle_Callback(Mobile from, string text) { - if (@from is not PlayerMobile pm || m_Member == null) + if (from is not PlayerMobile pm || m_Member == null) { return; } diff --git a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs index b92cd52aa..761bff0d4 100644 --- a/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs +++ b/Projects/UOContent/Gumps/Guilds/New Guild System/OtherGuildInfo.cs @@ -715,7 +715,7 @@ namespace Server.Guilds public void CreateAlliance_Callback(Mobile from, string text) { - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Items/Addons/DartBoard.cs b/Projects/UOContent/Items/Addons/DartBoard.cs index 967b27fd8..18333c337 100644 --- a/Projects/UOContent/Items/Addons/DartBoard.cs +++ b/Projects/UOContent/Items/Addons/DartBoard.cs @@ -60,7 +60,7 @@ namespace Server.Items public void Throw(Mobile from) { - if (@from.Weapon is not BaseKnife knife) + if (from.Weapon is not BaseKnife knife) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500751); // Try holding a knife... return; diff --git a/Projects/UOContent/Items/Misc/Corpses/Corpse.cs b/Projects/UOContent/Items/Misc/Corpses/Corpse.cs index 766b5989e..f3ea9e7b6 100644 --- a/Projects/UOContent/Items/Misc/Corpses/Corpse.cs +++ b/Projects/UOContent/Items/Misc/Corpses/Corpse.cs @@ -1054,7 +1054,7 @@ namespace Server.Items return; } - if (@from is not PlayerMobile player) + if (from is not PlayerMobile player) { return; } diff --git a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs index 8fffda490..66a98318f 100644 --- a/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs +++ b/Projects/UOContent/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs @@ -168,7 +168,7 @@ namespace Server.Items return; } - if (@from is not PlayerMobile pm) + if (from is not PlayerMobile pm) { return; } diff --git a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs index deb7f74a5..248b24751 100644 --- a/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Projects/UOContent/Items/Special/House Raffle/HouseRaffleStone.cs @@ -299,7 +299,7 @@ namespace Server.Items private bool HasEntered(Mobile from) { - if (@from.Account is not Account acc) + if (from.Account is not Account acc) { return false; } @@ -509,7 +509,7 @@ namespace Server.Items return; } - if (@from.Account is not Account) + if (from.Account is not Account) { return; } diff --git a/Projects/UOContent/Items/Special/SoulStone.cs b/Projects/UOContent/Items/Special/SoulStone.cs index e170157f7..a951f169f 100644 --- a/Projects/UOContent/Items/Special/SoulStone.cs +++ b/Projects/UOContent/Items/Special/SoulStone.cs @@ -167,7 +167,7 @@ namespace Server.Items return false; } - if (Account != null && (@from.Account is not Accounting.Account || from.Account.Username != Account)) + if (Account != null && (from.Account is not Accounting.Account || from.Account.Username != Account)) { from.SendLocalizedMessage( 1070714 diff --git a/Projects/UOContent/Items/Wands/BaseWand.cs b/Projects/UOContent/Items/Wands/BaseWand.cs index 3e030dcd8..310ffe526 100644 --- a/Projects/UOContent/Items/Wands/BaseWand.cs +++ b/Projects/UOContent/Items/Wands/BaseWand.cs @@ -244,7 +244,7 @@ namespace Server.Items public virtual void DoWandTarget(Mobile from, object o) { - if (Deleted || _charges <= 0 || Parent != @from || o is StaticTarget or LandTarget) + if (Deleted || _charges <= 0 || Parent != from || o is StaticTarget or LandTarget) { return; } diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index 59a605d5b..3e9895002 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -1252,7 +1252,7 @@ namespace Server.Mobiles { string notice; - if (@from.Account is not Account acct || !acct.HasAccess(from.NetState)) + if (from.Account is not Account acct || !acct.HasAccess(from.NetState)) { if (from.AccessLevel == AccessLevel.Player) { diff --git a/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs b/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs index 7c1cb745c..85eaaaba4 100644 --- a/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs +++ b/Projects/UOContent/Mobiles/Special/BaseShieldGuard.cs @@ -116,7 +116,7 @@ namespace Server.Mobiles var from = e.Mobile; - if (@from.Guild is not Guild g || g.Type != Type) + if (from.Guild is not Guild g || g.Type != Type) { Say(SignupNumber); } diff --git a/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs b/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs index 4ebe0f2aa..bd4e75b5d 100644 --- a/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs +++ b/Projects/UOContent/Spells/Spellweaving/ArcanistSpell.cs @@ -34,7 +34,7 @@ namespace Server.Spells.Spellweaving from.Holding as ArcaneFocus ?? from.Backpack?.FindItemByType(); public static bool CheckExpansion(Mobile from) => - @from is not PlayerMobile || from.NetState?.SupportsExpansion(Expansion.ML) == true; + from is not PlayerMobile || from.NetState?.SupportsExpansion(Expansion.ML) == true; public override bool CheckCast() {