From 556a17aba8e76a617d5ab2ff4d03de57e902b757 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sun, 26 Apr 2020 00:16:02 -0700 Subject: [PATCH] Adds style cop (#109) --- ModernUO.sln | 5 + Projects/Scripts/Accounting/Account.cs | 602 +-- .../Accounting/AccountAttackLimiter.cs | 11 +- Projects/Scripts/Accounting/AccountComment.cs | 4 +- Projects/Scripts/Accounting/AccountHandler.cs | 27 +- Projects/Scripts/Accounting/AccountTag.cs | 4 +- Projects/Scripts/Accounting/Accounts.cs | 1 - Projects/Scripts/Accounting/Firewall.cs | 26 +- Projects/Scripts/Accounting/IPLimiter.cs | 2 +- Projects/Scripts/Commands/Add.cs | 69 +- Projects/Scripts/Commands/Attributes.cs | 6 +- Projects/Scripts/Commands/Batch.cs | 72 +- .../Scripts/Commands/BoundingBoxPicker.cs | 8 +- Projects/Scripts/Commands/ConvertPlayers.cs | 2 +- Projects/Scripts/Commands/Decorate.cs | 43 +- Projects/Scripts/Commands/DecorateMag.cs | 33 +- Projects/Scripts/Commands/Docs.cs | 140 +- Projects/Scripts/Commands/Dupe.cs | 12 +- Projects/Scripts/Commands/ExportWSC.cs | 2 +- .../Scripts/Commands/GenCategorization.cs | 28 +- Projects/Scripts/Commands/GenTeleporter.cs | 4 +- .../Commands/Generic/Commands/BaseCommand.cs | 20 +- .../Commands/Generic/Commands/Commands.cs | 16 +- .../Commands/Generic/Commands/DesignInsert.cs | 78 +- .../Commands/Generic/Commands/Interface.cs | 321 +- .../Generic/Extensions/BaseExtension.cs | 12 +- .../Compilers/ConditionalCompiler.cs | 67 +- .../Extensions/Compilers/DistinctCompiler.cs | 51 +- .../Extensions/Compilers/SortCompiler.cs | 31 +- .../Generic/Extensions/DistinctExtension.cs | 2 +- .../Generic/Extensions/LimitExtension.cs | 2 +- .../Generic/Extensions/SortExtension.cs | 2 +- .../Generic/Extensions/WhereExtension.cs | 2 +- .../Implementors/AreaCommandImplementor.cs | 4 +- .../Implementors/BaseCommandImplementor.cs | 88 +- .../ContainedCommandImplementor.cs | 2 +- .../Implementors/MultiCommandImplementor.cs | 42 +- .../Generic/Implementors/ObjectConditional.cs | 4 +- .../Implementors/RangeCommandImplementor.cs | 2 +- .../Implementors/SerialCommandImplementor.cs | 28 +- .../Implementors/SingleCommandImplementor.cs | 42 +- Projects/Scripts/Commands/Handlers.cs | 10 +- Projects/Scripts/Commands/HelpInfo.cs | 98 +- Projects/Scripts/Commands/LocationCommand.cs | 4 +- Projects/Scripts/Commands/Logging.cs | 6 +- Projects/Scripts/Commands/Profiling.cs | 9 +- Projects/Scripts/Commands/Properties.cs | 30 +- Projects/Scripts/Commands/SignParser.cs | 10 +- Projects/Scripts/Commands/Skills.cs | 8 +- Projects/Scripts/Commands/Statics.cs | 133 +- Projects/Scripts/Commands/Wipe.cs | 4 +- Projects/Scripts/Context Menus/AddToParty.cs | 4 +- .../Context Menus/AddToSpellbookEntry.cs | 2 +- Projects/Scripts/Context Menus/EatEntry.cs | 4 +- Projects/Scripts/Context Menus/EjectPlayer.cs | 6 +- .../Scripts/Context Menus/OpenBankEntry.cs | 2 +- Projects/Scripts/Context Menus/TeachEntry.cs | 6 +- .../Scripts/Engines/BulkOrders/BODTarget.cs | 4 +- .../Scripts/Engines/BulkOrders/BaseBOD.cs | 50 +- .../Engines/BulkOrders/Books/BOBFilter.cs | 22 +- .../Engines/BulkOrders/Books/BOBFilterGump.cs | 150 +- .../Engines/BulkOrders/Books/BOBGump.cs | 329 +- .../Engines/BulkOrders/Books/BOBLargeEntry.cs | 39 +- .../BulkOrders/Books/BOBLargeSubEntry.cs | 26 +- .../Engines/BulkOrders/Books/BOBSmallEntry.cs | 46 +- .../Engines/BulkOrders/Books/BODBuyGump.cs | 10 +- .../Engines/BulkOrders/Books/BulkOrderBook.cs | 230 +- .../Engines/BulkOrders/Books/IBOBEntry.cs | 10 +- .../Scripts/Engines/BulkOrders/LargeBOD.cs | 77 +- .../Engines/BulkOrders/LargeBODAcceptGump.cs | 4 +- .../Engines/BulkOrders/LargeBODGump.cs | 4 +- .../Engines/BulkOrders/LargeBulkEntry.cs | 82 +- .../Engines/BulkOrders/LargeSmithBOD.cs | 2 +- .../Engines/BulkOrders/LargeTailorBOD.cs | 2 +- .../Scripts/Engines/BulkOrders/Rewards.cs | 40 +- .../Scripts/Engines/BulkOrders/SmallBOD.cs | 26 +- .../Engines/BulkOrders/SmallBODAcceptGump.cs | 4 +- .../Engines/BulkOrders/SmallBODGump.cs | 4 +- .../Engines/BulkOrders/SmallBulkEntry.cs | 44 +- .../Engines/BulkOrders/SmallSmithBOD.cs | 1 - .../Engines/BulkOrders/SmallTailorBOD.cs | 1 - .../Engines/CannedEvil/ChampionAltar.cs | 12 +- .../Engines/CannedEvil/ChampionPlatform.cs | 20 +- .../Engines/CannedEvil/ChampionSkull.cs | 8 +- .../CannedEvil/ChampionSkullBrazier.cs | 20 +- .../CannedEvil/ChampionSkullPlatform.cs | 18 +- .../Engines/CannedEvil/ChampionSpawn.cs | 206 +- .../Engines/CannedEvil/ChampionSpawnType.cs | 10 +- .../Engines/CannedEvil/HarrowerGate.cs | 12 +- .../Engines/CannedEvil/RestartTimer.cs | 2 +- .../Scripts/Engines/CannedEvil/SliceTimer.cs | 2 +- .../Engines/CannedEvil/StarRoomGate.cs | 22 +- Projects/Scripts/Engines/Chat/Channel.cs | 12 +- Projects/Scripts/Engines/Chat/Chat.cs | 11 +- .../Scripts/Engines/Chat/ChatActionHandler.cs | 6 +- .../Engines/Chat/ChatActionHandlers.cs | 9 +- Projects/Scripts/Engines/Chat/ChatUser.cs | 18 +- Projects/Scripts/Engines/Chat/Packets.cs | 10 +- .../Scripts/Engines/ConPVP/AcceptDuelGump.cs | 21 +- Projects/Scripts/Engines/ConPVP/Arena.cs | 158 +- .../Scripts/Engines/ConPVP/DuelContext.cs | 79 +- .../Engines/ConPVP/Games/BombingRun.cs | 119 +- Projects/Scripts/Engines/ConPVP/Games/CTF.cs | 142 +- .../Scripts/Engines/ConPVP/Games/DoubleDom.cs | 80 +- .../Scripts/Engines/ConPVP/Games/EventGame.cs | 2 +- .../Engines/ConPVP/Games/KingOfTheHill.cs | 92 +- .../Engines/ConPVP/Games/TourneyMatch.cs | 7 +- .../Engines/ConPVP/Gumps/AcceptTeamGump.cs | 25 +- .../Scripts/Engines/ConPVP/Gumps/ArenaGump.cs | 6 +- .../Engines/ConPVP/Gumps/ConfirmSignupGump.cs | 254 +- .../Engines/ConPVP/Gumps/DuelContextGump.cs | 82 +- .../Engines/ConPVP/Gumps/LadderGump.cs | 20 +- .../Engines/ConPVP/Gumps/ParticipantGump.cs | 20 +- .../Engines/ConPVP/Gumps/PickRulesetGump.cs | 68 +- .../Engines/ConPVP/Gumps/ReadyUpGump.cs | 44 +- .../Engines/ConPVP/Gumps/RulesetGump.cs | 10 +- .../ConPVP/Gumps/TournamentBracketGump.cs | 1259 +++-- Projects/Scripts/Engines/ConPVP/Ladder.cs | 100 +- .../Scripts/Engines/ConPVP/Participant.cs | 14 +- .../Scripts/Engines/ConPVP/Preferences.cs | 72 +- Projects/Scripts/Engines/ConPVP/Ruleset.cs | 12 +- .../Scripts/Engines/ConPVP/RulesetLayout.cs | 44 +- Projects/Scripts/Engines/ConPVP/Tournament.cs | 385 +- .../Engines/ConPVP/TournamentBracketItem.cs | 10 +- .../Engines/ConPVP/TournamentController.cs | 16 +- .../Engines/ConPVP/TournamentPyramid.cs | 246 +- .../Engines/ConPVP/TournamentRegistrar.cs | 10 +- .../Engines/ConPVP/TournamentSignupItem.cs | 138 +- .../Engines/ConPVP/TourneyParticipant.cs | 6 +- Projects/Scripts/Engines/ConPVP/Trophy.cs | 6 +- .../Engines/Craft/Core/CraftContext.cs | 12 +- .../Scripts/Engines/Craft/Core/CraftGroup.cs | 6 +- .../Engines/Craft/Core/CraftGroupCol.cs | 4 +- .../Scripts/Engines/Craft/Core/CraftGump.cs | 360 +- .../Engines/Craft/Core/CraftGumpItem.cs | 14 +- .../Scripts/Engines/Craft/Core/CraftItem.cs | 175 +- .../Craft/Core/CraftItemIDAttribute.cs | 2 +- .../Scripts/Engines/Craft/Core/CraftRes.cs | 12 +- .../Scripts/Engines/Craft/Core/CraftSkill.cs | 6 +- .../Scripts/Engines/Craft/Core/CraftSubRes.cs | 12 +- .../Engines/Craft/Core/CraftSubResCol.cs | 8 +- .../Scripts/Engines/Craft/Core/CraftSystem.cs | 35 +- .../Scripts/Engines/Craft/Core/CustomCraft.cs | 12 +- .../Scripts/Engines/Craft/Core/Enhance.cs | 70 +- .../Engines/Craft/Core/QueryMakersMarkGump.cs | 12 +- .../Scripts/Engines/Craft/Core/Recipes.cs | 15 +- Projects/Scripts/Engines/Craft/Core/Repair.cs | 23 +- .../Scripts/Engines/Craft/Core/Resmelt.cs | 12 +- Projects/Scripts/Engines/Craft/DefAlchemy.cs | 2 +- .../Scripts/Engines/Craft/DefBlacksmithy.cs | 110 +- .../Scripts/Engines/Craft/DefBowFletching.cs | 4 +- .../Scripts/Engines/Craft/DefCarpentry.cs | 12 +- .../Scripts/Engines/Craft/DefGlassblowing.cs | 8 +- .../Scripts/Engines/Craft/DefInscription.cs | 10 +- Projects/Scripts/Engines/Craft/DefMasonry.cs | 8 +- .../Scripts/Engines/Craft/DefTailoring.cs | 38 +- .../Scripts/Engines/Craft/DefTinkering.cs | 42 +- .../Scripts/Engines/Doom/GauntletSpawner.cs | 75 +- .../Doom/LeverPuzzle/LeverPuzzleController.cs | 43 +- .../Doom/LeverPuzzle/LeverPuzzleItems.cs | 2 +- .../Doom/LeverPuzzle/LeverPuzzleRegions.cs | 4 +- Projects/Scripts/Engines/Ethics/Core/Ethic.cs | 20 +- .../Engines/Ethics/Core/Persistance.cs | 12 +- .../Scripts/Engines/Ethics/Core/Player.cs | 30 +- .../Ethics/Definitions/EthicDefinition.cs | 10 +- .../Ethics/Definitions/PowerDefinition.cs | 8 +- Projects/Scripts/Engines/Ethics/Evil/Ethic.cs | 3 +- .../Engines/Ethics/Evil/Powers/Blight.cs | 3 +- .../Ethics/Evil/Powers/SummonFamiliar.cs | 3 +- .../Engines/Ethics/Evil/Powers/UnholyItem.cs | 3 +- .../Engines/Ethics/Evil/Powers/UnholySense.cs | 3 +- .../Ethics/Evil/Powers/UnholyShield.cs | 3 +- .../Engines/Ethics/Evil/Powers/UnholySteed.cs | 3 +- .../Engines/Ethics/Evil/Powers/UnholyWord.cs | 3 +- .../Engines/Ethics/Evil/Powers/VileBlade.cs | 3 +- Projects/Scripts/Engines/Ethics/Hero/Ethic.cs | 3 +- .../Engines/Ethics/Hero/Powers/Bless.cs | 3 +- .../Engines/Ethics/Hero/Powers/HolyBlade.cs | 3 +- .../Engines/Ethics/Hero/Powers/HolyItem.cs | 3 +- .../Engines/Ethics/Hero/Powers/HolySense.cs | 3 +- .../Engines/Ethics/Hero/Powers/HolyShield.cs | 3 +- .../Engines/Ethics/Hero/Powers/HolySteed.cs | 3 +- .../Engines/Ethics/Hero/Powers/HolyWord.cs | 3 +- .../Ethics/Hero/Powers/SummonFamiliar.cs | 3 +- .../Scripts/Engines/Events/BroadcastEvent.cs | 68 +- .../Scripts/Engines/Events/EventScheduler.cs | 177 +- .../Scripts/Engines/Factions/Core/Election.cs | 258 +- .../Scripts/Engines/Factions/Core/Faction.cs | 191 +- .../Engines/Factions/Core/FactionItem.cs | 18 +- .../Engines/Factions/Core/FactionState.cs | 186 +- .../Engines/Factions/Core/GuardList.cs | 7 +- .../Scripts/Engines/Factions/Core/Keywords.cs | 220 +- .../Engines/Factions/Core/MerchantTitles.cs | 12 +- .../Engines/Factions/Core/Persistance.cs | 30 +- .../Engines/Factions/Core/PlayerState.cs | 38 +- .../Engines/Factions/Core/Reflector.cs | 2 +- .../Engines/Factions/Core/SilverGivenEntry.cs | 4 +- .../Engines/Factions/Core/StrongholdRegion.cs | 2 +- .../Scripts/Engines/Factions/Core/Town.cs | 6 +- .../Engines/Factions/Core/TownState.cs | 54 +- .../Engines/Factions/Core/VendorList.cs | 7 +- .../Factions/Definitions/FactionDefinition.cs | 50 +- .../Definitions/FactionItemDefinition.cs | 16 +- .../Factions/Definitions/GuardDefinition.cs | 14 +- .../Factions/Definitions/RankDefinition.cs | 8 +- .../Definitions/StrongholdDefintion.cs | 8 +- .../Factions/Definitions/TownDefinition.cs | 26 +- .../Factions/Definitions/VendorDefinition.cs | 31 +- .../Engines/Factions/Gumps/ElectionGump.cs | 138 +- .../Factions/Gumps/ElectionManagementGump.cs | 7 +- .../Factions/Gumps/FactionImbueGump.cs | 19 +- .../Factions/Gumps/FactionStoneGump.cs | 159 +- .../Engines/Factions/Gumps/FinanceGump.cs | 169 +- .../Factions/Gumps/HorseBreederGump.cs | 4 +- .../Engines/Factions/Gumps/JoinStoneGump.cs | 7 +- .../Factions/Gumps/LeaveFactionGump.cs | 76 +- .../Engines/Factions/Gumps/SheriffGump.cs | 23 +- .../Engines/Factions/Gumps/TownStoneGump.cs | 102 +- .../Engines/Factions/Gumps/VoteGump.cs | 4 +- .../Instances/Factions/CouncilOfMages.cs | 5 +- .../Factions/Instances/Factions/Minax.cs | 5 +- .../Instances/Factions/Shadowlords.cs | 5 +- .../Instances/Factions/TrueBritannians.cs | 5 +- .../Engines/Factions/Items/BaseMonolith.cs | 14 +- .../Engines/Factions/Items/FactionStone.cs | 8 +- .../Engines/Factions/Items/JoinStone.cs | 8 +- .../Power Faction Items/ClarityPotion.cs | 4 +- .../Power Faction Items/PowerFactionItem.cs | 22 +- .../Items/Power Faction Items/StormsEye.cs | 17 +- .../Scripts/Engines/Factions/Items/Sigil.cs | 58 +- .../Factions/Items/StrongholdMonolith.cs | 1 - .../Engines/Factions/Items/TownStone.cs | 10 +- .../Factions/Items/Traps/BaseFactionTrap.cs | 42 +- .../Items/Traps/BaseFactionTrapDeed.cs | 8 +- .../Items/Traps/FactionTrapRemovalKit.cs | 18 +- .../Factions/Mobiles/FactionWarHorse.cs | 8 +- .../Mobiles/Guards/BaseFactionGuard.cs | 14 +- .../Factions/Mobiles/Guards/GuardAI.cs | 40 +- .../Engines/Factions/Mobiles/Guards/Orders.cs | 46 +- .../Mobiles/Vendors/BaseFactionVendor.cs | 14 +- .../Mobiles/Vendors/FactionBoardVendor.cs | 7 +- .../Mobiles/Vendors/FactionBottleVendor.cs | 4 +- .../Mobiles/Vendors/FactionOreVendor.cs | 4 +- .../Mobiles/Vendors/FactionReagentVendor.cs | 4 +- .../Harvest/Core/BonusHarvestResource.cs | 8 +- .../Harvest/Core/FurnitureAttribute.cs | 10 + .../Engines/Harvest/Core/HarvestBank.cs | 12 +- .../Engines/Harvest/Core/HarvestDefinition.cs | 95 +- .../Engines/Harvest/Core/HarvestResource.cs | 10 +- .../Engines/Harvest/Core/HarvestSoundTimer.cs | 13 +- .../Engines/Harvest/Core/HarvestSystem.cs | 35 +- .../Engines/Harvest/Core/HarvestTarget.cs | 6 +- .../Engines/Harvest/Core/HarvestTimer.cs | 14 +- .../Engines/Harvest/Core/HarvestVein.cs | 12 +- .../Engines/Harvest/Core/IChoppable..cs | 7 + Projects/Scripts/Engines/Harvest/Fishing.cs | 151 +- .../Scripts/Engines/Harvest/Lumberjacking.cs | 28 +- Projects/Scripts/Engines/Harvest/Mining.cs | 50 +- Projects/Scripts/Engines/Help/HelpGump.cs | 248 +- Projects/Scripts/Engines/Help/PagePrompt.cs | 12 +- .../Scripts/Engines/Help/PagePromptGump.cs | 12 +- Projects/Scripts/Engines/Help/PageQueue.cs | 10 +- .../Scripts/Engines/Help/PageQueueGump.cs | 439 +- .../Scripts/Engines/Help/PageResponseGump.cs | 5 +- Projects/Scripts/Engines/Help/SpeechLog.cs | 16 +- .../Scripts/Engines/Help/SpeechLogGump.cs | 26 +- Projects/Scripts/Engines/Help/StuckMenu.cs | 25 +- .../Engines/Khaldun/Books/GrimmochJournal.cs | 314 +- .../Engines/Khaldun/Books/LysanderNotebook.cs | 222 +- .../Engines/Khaldun/Books/TavarasJournal.cs | 562 +- .../Engines/Khaldun/KhaldunPitTeleporter.cs | 6 +- .../Khaldun/Mobiles/GrimmochDrummel.cs | 6 +- .../Scripts/Engines/Khaldun/PuzzleChest.cs | 72 +- .../Scripts/Engines/Khaldun/RaisableItem.cs | 10 +- .../Scripts/Engines/Khaldun/RaiseSwitch.cs | 4 +- .../MLQuests/Definitions/AGhostOfCovetous.cs | 8 - .../Engines/MLQuests/Definitions/Bedlam.cs | 8 - .../MLQuests/Definitions/BlightedGrove.cs | 11 +- .../Engines/MLQuests/Definitions/Britannia.cs | 8 - .../Engines/MLQuests/Definitions/Heartwood.cs | 86 +- .../Engines/MLQuests/Definitions/Heritage.cs | 19 +- .../MLQuests/Definitions/HonestBeggar.cs | 8 - .../Engines/MLQuests/Definitions/Ilshenar.cs | 11 +- .../Engines/MLQuests/Definitions/LostItems.cs | 10 +- .../Engines/MLQuests/Definitions/Malas.cs | 8 - .../MLQuests/Definitions/MistakenIdentity.cs | 11 +- .../Definitions/NewHavenSkillTraining.cs | 15 +- .../MLQuests/Definitions/NewHavenTraining.cs | 37 +- .../Engines/MLQuests/Definitions/Sanctuary.cs | 29 +- .../MLQuests/Definitions/Spellweaving.cs | 26 +- .../MLQuests/Definitions/TheAncientWorld.cs | 8 - .../MLQuests/Definitions/UnfadingMemories.cs | 8 - .../Engines/MLQuests/Gumps/BaseQuestGump.cs | 16 +- .../MLQuests/Gumps/QuestCancelConfirmGump.cs | 20 +- .../MLQuests/Gumps/QuestLogDetailedGump.cs | 30 +- .../Engines/MLQuests/Gumps/QuestLogGump.cs | 4 +- .../Engines/MLQuests/Gumps/QuestOfferGump.cs | 20 +- .../MLQuests/Gumps/QuestReportBackGump.cs | 2 +- .../Engines/MLQuests/Gumps/QuestRewardGump.cs | 2 +- .../Engines/MLQuests/Gumps/RaceChangeGump.cs | 58 +- .../Scripts/Engines/MLQuests/IQuestGiver.cs | 6 +- .../MLQuests/Items/CraftmansSatchel.cs | 10 +- .../Engines/MLQuests/Items/Teleporters.cs | 4 +- Projects/Scripts/Engines/MLQuests/MLQuest.cs | 34 +- .../Engines/MLQuests/MLQuestContext.cs | 10 +- .../Scripts/Engines/MLQuests/MLQuestEntry.cs | 15 +- .../Scripts/Engines/MLQuests/MLQuestSystem.cs | 14 +- .../Engines/MLQuests/Mobiles/BoonCollector.cs | 16 +- .../Engines/MLQuests/Mobiles/SirHelper.cs | 2 +- .../MLQuests/Objectives/BaseObjective.cs | 42 +- .../MLQuests/Objectives/CollectObjective.cs | 17 +- .../MLQuests/Objectives/DeliverObjective.cs | 20 +- .../MLQuests/Objectives/EscortObjective.cs | 16 +- .../MLQuests/Objectives/GainSkillObjective.cs | 6 +- .../MLQuests/Objectives/KillObjective.cs | 25 +- .../Scripts/Engines/MLQuests/QuestArea.cs | 9 +- .../Engines/MLQuests/QuesterNameAttribute.cs | 2 +- .../Engines/MLQuests/Rewards/BaseReward.cs | 2 +- .../Engines/MLQuests/Rewards/ItemReward.cs | 4 +- .../Scripts/Engines/Party/DeclineTimer.cs | 5 +- Projects/Scripts/Engines/Party/Packets.cs | 40 +- Projects/Scripts/Engines/Party/Party.cs | 16 +- .../Scripts/Engines/Party/PartyMemberInfo.cs | 4 +- .../Scripts/Engines/Party/RemoveFromParty.cs | 4 +- .../Engines/Pathing/FastAStarAlgorithm.cs | 22 +- .../Scripts/Engines/Pathing/FastMovement.cs | 30 +- Projects/Scripts/Engines/Pathing/Movement.cs | 46 +- .../Scripts/Engines/Pathing/MovementPath.cs | 10 +- .../Scripts/Engines/Pathing/PathAlgorithm.cs | 2 +- .../Scripts/Engines/Pathing/PathFollower.cs | 13 +- .../Engines/Pathing/SlowAStarAlgorithm.cs | 8 +- .../Engines/Plants/EmptyTheBowlGump.cs | 64 +- .../Scripts/Engines/Plants/MainPlantGump.cs | 196 +- .../Engines/Plants/MiscItems/GreenThorns.cs | 312 +- .../Engines/Plants/MiscItems/OrangePetals.cs | 6 +- .../Engines/Plants/MiscItems/RedLeaves.cs | 2 +- .../Plants/Network/DisplayHelpTopic.cs | 8 +- Projects/Scripts/Engines/Plants/PlantBowl.cs | 4 +- Projects/Scripts/Engines/Plants/PlantHue.cs | 10 +- Projects/Scripts/Engines/Plants/PlantItem.cs | 45 +- .../Scripts/Engines/Plants/PlantPourTarget.cs | 2 +- .../Scripts/Engines/Plants/PlantResources.cs | 8 +- .../Scripts/Engines/Plants/PlantSystem.cs | 11 +- Projects/Scripts/Engines/Plants/PlantType.cs | 32 +- .../Scripts/Engines/Plants/PollinateTarget.cs | 2 +- .../Engines/Plants/ReproductionGump.cs | 222 +- Projects/Scripts/Engines/Plants/Seed.cs | 2 +- .../Engines/Plants/SetToDecorativeGump.cs | 32 +- .../AmbitiousQueenQuest.cs | 4 +- .../Ambitious Solen Queen/Conversations.cs | 2 +- .../Mobiles/AmbitiousSolenQueen.cs | 4 +- .../Ambitious Solen Queen/Objectives.cs | 6 +- .../Quests/Collector/CollectorQuest.cs | 2 +- .../Engines/Quests/Collector/Conversations.cs | 2 +- .../Quests/Collector/Items/EnchantedPaints.cs | 36 +- .../Quests/Collector/Items/ImageTypeInfo.cs | 10 +- .../Quests/Collector/Items/Obsidian.cs | 4 +- .../Quests/Collector/Mobiles/Impresario.cs | 1 - .../Quests/Collector/Mobiles/TomasONeerlan.cs | 2 +- .../Engines/Quests/Core/BaseQuester.cs | 2 +- .../Quests/Core/Items/EnchantedSextant.cs | 8 +- .../Quests/Core/Items/HornOfRetreat.cs | 18 +- .../Engines/Quests/Core/QuestCallbackEntry.cs | 2 +- .../Engines/Quests/Core/QuestConversation.cs | 18 +- .../Engines/Quests/Core/QuestItemInfo.cs | 4 +- .../Engines/Quests/Core/QuestObjective.cs | 32 +- .../Engines/Quests/Core/QuestRestartInfo.cs | 4 +- .../Engines/Quests/Core/QuestSerializer.cs | 94 +- .../Engines/Quests/Core/QuestSystem.cs | 77 +- .../Quests/Core/Regions/CancelQuestRegion.cs | 2 +- .../Regions/QuestCompleteObjectiveRegion.cs | 4 +- .../Quests/Core/Regions/QuestNoEntryRegion.cs | 8 +- .../Quests/Core/Regions/QuestOfferRegion.cs | 2 +- .../Quests/Dark Tides/Conversations.cs | 6 +- .../Quests/Dark Tides/DarkTidesQuest.cs | 2 +- .../Quests/Dark Tides/Items/KronusScroll.cs | 2 +- .../Quests/Dark Tides/Items/MaabusCoffin.cs | 4 +- .../Quests/Dark Tides/Mobiles/Horus.cs | 4 +- .../Quests/Dark Tides/Mobiles/Mardoth.cs | 2 +- .../Dark Tides/Mobiles/SummonedPaladin.cs | 2 +- .../Engines/Quests/Dark Tides/Objectives.cs | 6 +- .../EminosUndertakingQuest.cs | 2 +- .../Emino's Undertaking/Mobiles/Emino.cs | 2 +- .../Mobiles/HiddenFigure.cs | 2 +- .../Quests/Emino's Undertaking/Objectives.cs | 4 +- .../Haochi's Trials/HaochisTrialsQuest.cs | 2 +- .../Quests/Haochi's Trials/Mobiles/Haochi.cs | 2 +- .../Quests/Haochi's Trials/Mobiles/Relnia.cs | 1 - .../Quests/Haochi's Trials/Objectives.cs | 6 +- .../Quests/Solen Matriarch/Conversations.cs | 2 +- .../Solen Matriarch/Mobiles/SolenMatriarch.cs | 10 +- .../Solen Matriarch/SolenMatriarchQuest.cs | 4 +- .../Mobiles/Naturalist.cs | 3 +- .../Study of the Solen Hive/NestArea.cs | 4 +- .../Study of the Solen Hive/Objectives.cs | 4 +- .../StudyOfSolenQuest.cs | 4 +- .../TerribleHatchlingsQuest.cs | 2 +- .../The Summoning/Items/BellOfTheDead.cs | 6 +- .../Quests/The Summoning/Mobiles/Chyloth.cs | 10 +- .../Quests/The Summoning/Objectives.cs | 2 +- .../Quests/The Summoning/TheSummoningQuest.cs | 6 +- .../Quests/Uzeraan Turmoil/Conversations.cs | 60 +- .../Quests/Uzeraan Turmoil/Items/Cannon.cs | 60 +- .../Quests/Uzeraan Turmoil/Mobiles/Dryad.cs | 4 +- .../Mobiles/MilitiaCanoneer.cs | 2 +- .../Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs | 2 +- .../Quests/Uzeraan Turmoil/Objectives.cs | 36 +- .../Uzeraan Turmoil/UzeraanTurmoilQuest.cs | 2 +- .../Quests/Witch Apprentice/Conversations.cs | 4 +- .../Quests/Witch Apprentice/Ingredient.cs | 8 +- .../Witch Apprentice/Items/HagCauldron.cs | 4 +- .../Quests/Witch Apprentice/Items/HagStew.cs | 6 +- .../Witch Apprentice/Items/HangoverCure.cs | 18 +- .../Witch Apprentice/Items/MagicFlute.cs | 2 +- .../Witch Apprentice/Mobiles/Grizelda.cs | 3 +- .../Quests/Witch Apprentice/Objectives.cs | 28 +- .../Witch Apprentice/WitchApprenticeQuest.cs | 4 +- .../Engines/Spawner/ProximitySpawner.cs | 8 +- Projects/Scripts/Engines/Spawner/Spawner.cs | 274 +- .../Scripts/Engines/Spawner/SpawnerGump.cs | 152 +- .../BasePigmentsOfTokuno.cs | 53 +- .../Treasures of Tokuno/GreaterArtifacts.cs | 3 +- .../Treasures of Tokuno/LesserArtifacts.cs | 9 +- .../Treasures of Tokuno/TreasuresOfTokuno.cs | 74 +- .../TreasuresOfTokunoPersistance.cs | 12 +- .../Character Statue Maker/CharacterStatue.cs | 16 +- .../Gumps/CharacterStatueGump.cs | 6 +- .../Character Statue Maker/Packets.cs | 22 +- .../Engines/VeteranRewards/RewardCategory.cs | 6 +- .../VeteranRewards/RewardChoiceGump.cs | 2 +- .../VeteranRewards/RewardConfirmGump.cs | 4 +- .../VeteranRewards/RewardDemolitionGump.cs | 2 +- .../Engines/VeteranRewards/RewardEntry.cs | 16 +- .../Engines/VeteranRewards/RewardList.cs | 4 +- .../VeteranRewards/RewardNoticeGump.cs | 2 +- .../VeteranRewards/RewardOptionGump.cs | 8 +- .../Engines/VeteranRewards/RewardSystem.cs | 11 +- .../Scripts/Engines/Virtues/Compassion.cs | 4 +- Projects/Scripts/Engines/Virtues/Honor.cs | 38 +- Projects/Scripts/Engines/Virtues/Justice.cs | 6 +- Projects/Scripts/Engines/Virtues/Sacrifice.cs | 4 +- Projects/Scripts/Engines/Virtues/Valor.cs | 40 +- .../Scripts/Engines/Virtues/VirtueGump.cs | 14 +- .../Scripts/Engines/Virtues/VirtueInfoGump.cs | 30 +- .../Engines/Virtues/VirtueStatusGump.cs | 84 +- Projects/Scripts/Gumps/AddDoorGump.cs | 2 +- Projects/Scripts/Gumps/AddGump.cs | 91 +- Projects/Scripts/Gumps/AdminGump.cs | 4553 ++++++++--------- Projects/Scripts/Gumps/BanDurationGump.cs | 200 +- Projects/Scripts/Gumps/BaseGridGump.cs | 6 +- .../Scripts/Gumps/BaseImageTileButtonsGump.cs | 9 +- Projects/Scripts/Gumps/CategorizedAddGump.cs | 90 +- Projects/Scripts/Gumps/ClientGump.cs | 200 +- Projects/Scripts/Gumps/CommentsGump.cs | 6 +- .../Scripts/Gumps/ConfirmBreakCrystalGump.cs | 2 +- Projects/Scripts/Gumps/ConfirmHeritageGump.cs | 4 +- Projects/Scripts/Gumps/ConfirmHouseResize.cs | 6 +- Projects/Scripts/Gumps/ConfirmReleaseGump.cs | 4 +- Projects/Scripts/Gumps/DawnsMusicBoxGump.cs | 2 +- Projects/Scripts/Gumps/Go/ChildNode.cs | 6 +- Projects/Scripts/Gumps/Go/GoGump.cs | 73 +- Projects/Scripts/Gumps/Go/LocationTree.cs | 6 +- Projects/Scripts/Gumps/Go/ParentNode.cs | 19 +- .../Scripts/Gumps/Guilds/GuildAbbrvPrompt.cs | 4 +- .../Gumps/Guilds/GuildAdminCandidatesGump.cs | 138 +- .../Gumps/Guilds/GuildChangeTypeGump.cs | 8 +- .../Scripts/Gumps/Guilds/GuildCharterGump.cs | 18 +- .../Gumps/Guilds/GuildCharterPrompt.cs | 4 +- .../Gumps/Guilds/GuildDeclareWarGump.cs | 2 +- .../Gumps/Guilds/GuildDeclareWarPrompt.cs | 4 +- Projects/Scripts/Gumps/Guilds/GuildGump.cs | 133 +- .../Scripts/Gumps/Guilds/GuildNamePrompt.cs | 4 +- .../Scripts/Gumps/Guilds/GuildTitlePrompt.cs | 5 +- .../Scripts/Gumps/Guilds/GuildWarAdminGump.cs | 64 +- Projects/Scripts/Gumps/Guilds/GuildWarGump.cs | 4 +- .../Gumps/Guilds/GuildWebsitePrompt.cs | 4 +- .../Scripts/Gumps/Guilds/GuildmasterGump.cs | 178 +- .../Guilds/New Guild System/AdvancedSearch.cs | 5 +- .../Guilds/New Guild System/BaseGuildGump.cs | 41 +- .../New Guild System/BaseGuildListGump.cs | 59 +- .../New Guild System/Create Guild Gump.cs | 114 +- .../Guilds/New Guild System/DiplomacyGump.cs | 45 +- .../Guilds/New Guild System/GuildInfoGump.cs | 96 +- .../GuildInvitationRequest.cs | 37 +- .../New Guild System/GuildMemberInfoGump.cs | 224 +- .../New Guild System/GuildRosterGump.cs | 23 +- .../Guilds/New Guild System/OtherGuildInfo.cs | 756 ++- .../New Guild System/War Declaration gump.cs | 162 +- .../Scripts/Gumps/Guilds/RecruitTarget.cs | 10 +- Projects/Scripts/Gumps/HeritageTokenGump.cs | 2 +- Projects/Scripts/Gumps/HonorSelf.cs | 2 +- Projects/Scripts/Gumps/HouseDemolishGump.cs | 22 +- Projects/Scripts/Gumps/HouseGump.cs | 479 +- Projects/Scripts/Gumps/HouseGumpAOS.cs | 1677 +++--- Projects/Scripts/Gumps/HouseTransferGump.cs | 5 +- Projects/Scripts/Gumps/NoticeGump.cs | 2 +- Projects/Scripts/Gumps/PetResurrectGump.cs | 8 +- Projects/Scripts/Gumps/PlayerVendorGumps.cs | 358 +- Projects/Scripts/Gumps/PolymorphGump.cs | 39 +- Projects/Scripts/Gumps/Props/PropsGump.cs | 267 +- Projects/Scripts/Gumps/Props/SetBodyGump.cs | 28 +- .../Scripts/Gumps/Props/SetCustomEnumGump.cs | 2 +- Projects/Scripts/Gumps/Props/SetGump.cs | 108 +- .../Scripts/Gumps/Props/SetListOptionGump.cs | 7 +- Projects/Scripts/Gumps/Props/SetObjectGump.cs | 102 +- .../Scripts/Gumps/Props/SetObjectTarget.cs | 14 +- .../Scripts/Gumps/Props/SetPoint2DGump.cs | 78 +- .../Scripts/Gumps/Props/SetPoint3DGump.cs | 82 +- .../Scripts/Gumps/Props/SetTimeSpanGump.cs | 164 +- Projects/Scripts/Gumps/ReclaimVendorGump.cs | 4 +- Projects/Scripts/Gumps/ReportMurderer.cs | 134 +- Projects/Scripts/Gumps/ResurrectGump.cs | 159 +- Projects/Scripts/Gumps/RewardGump.cs | 22 +- Projects/Scripts/Gumps/RunebookGump.cs | 256 +- Projects/Scripts/Gumps/SetSecureLevelGump.cs | 7 +- Projects/Scripts/Gumps/SkillsGump.cs | 134 +- Projects/Scripts/Gumps/TithingGump.cs | 102 +- Projects/Scripts/Gumps/ToTAdminGump.cs | 12 +- Projects/Scripts/Gumps/VendorInventoryGump.cs | 4 +- Projects/Scripts/Gumps/VendorRentalGumps.cs | 424 +- Projects/Scripts/Gumps/ViewHousesGump.cs | 62 +- Projects/Scripts/Gumps/WarningGump.cs | 50 +- Projects/Scripts/Gumps/WhoGump.cs | 211 +- Projects/Scripts/Gumps/YoungGumps.cs | 58 +- .../Christmas/2010/Addons/FireFliesDeed.cs | 11 +- .../Halloween/2006/Engines/TrickOrTreat.cs | 12 +- .../Halloween/2009/Engines/PumpkinPatch.cs | 2 +- .../Halloween/2011/Items/BasePaintedMask.cs | 4 +- .../Halloween/2012/Engines/PlayerZombies.cs | 173 +- .../Halloween/HolidaySettings.cs | 4 +- .../Valentine/2011/Items/StValentinesBears.cs | 4 +- .../Valentine/2012/Items/CupidsArrow.cs | 76 +- .../Scripts/Items/Addons/AddonComponent.cs | 34 +- .../Items/Addons/AddonContainerComponent.cs | 6 +- .../Scripts/Items/Addons/ArcheryButteAddon.cs | 202 +- Projects/Scripts/Items/Addons/BallotBox.cs | 102 +- Projects/Scripts/Items/Addons/BaseAddon.cs | 20 +- .../Items/Addons/BaseAddonContainer.cs | 8 +- .../Items/Addons/BaseAddonContainerDeed.cs | 8 +- .../Scripts/Items/Addons/BaseAddonDeed.cs | 8 +- .../Addons/ElvenSpinningwheelEastAddon.cs | 8 +- .../Addons/ElvenSpinningwheelSouthAddon.cs | 8 +- .../Items/Addons/FlourMillEastAddon.cs | 15 +- .../Items/Addons/FlourMillSouthAddon.cs | 10 +- Projects/Scripts/Items/Addons/JackOLantern.cs | 10 +- .../Scripts/Items/Addons/LoomEastAddon.cs | 12 +- .../Scripts/Items/Addons/LoomSouthAddon.cs | 10 +- .../Scripts/Items/Addons/PickpocketDips.cs | 26 +- Projects/Scripts/Items/Addons/SHTeleporter.cs | 12 +- Projects/Scripts/Items/Addons/SolenAntHole.cs | 3 +- .../Items/Addons/SpinningwheelEastAddon.cs | 10 +- .../Items/Addons/SpinningwheelSouthAddon.cs | 8 +- .../Scripts/Items/Addons/TrainingDummies.cs | 26 +- Projects/Scripts/Items/Aquarium/Aquarium.cs | 161 +- .../Scripts/Items/Aquarium/AquariumGump.cs | 2 +- .../Scripts/Items/Aquarium/AquariumState.cs | 6 +- Projects/Scripts/Items/Aquarium/FishBowl.cs | 2 +- .../Items/Armor/Artifacts/LeggingsOfBane.cs | 2 +- Projects/Scripts/Items/Armor/BaseArmor.cs | 493 +- .../Armor/Glasses/AnthropomorphistGlasses.cs | 2 +- .../Items/Armor/Glasses/ArtsGlasses.cs | 2 +- .../Items/Armor/Glasses/ElvenGlasses.cs | 2 +- .../Items/Armor/Glasses/FoldedSteelGlasses.cs | 2 +- .../Items/Armor/Glasses/LightOfWayGlasses.cs | 2 +- .../Items/Armor/Glasses/LyricalGlasses.cs | 2 +- .../Items/Armor/Glasses/MaceShieldGlasses.cs | 2 +- .../Items/Armor/Glasses/MaritimeGlasses.cs | 2 +- .../Items/Armor/Glasses/NecromanticGlasses.cs | 2 +- .../Items/Armor/Glasses/PoisonedGlasses.cs | 2 +- .../Items/Armor/Glasses/TradeGlasses.cs | 2 +- .../Armor/Glasses/TreasureTrinketGlasses.cs | 2 +- .../Items/Armor/Glasses/WizardsGlasses.cs | 2 +- .../Scripts/Items/Armor/Leather/LeafGloves.cs | 22 +- .../Items/Armor/Leather/LeatherGloves.cs | 22 +- .../Items/Armor/Leather/LeatherHaidate.cs | 1 - .../Items/Armor/Leather/LeatherNinjaMitts.cs | 20 +- .../Items/Armor/Plate/FemaleWoodlandChest.cs | 2 +- Projects/Scripts/Items/Body Parts/BonePile.cs | 2 +- Projects/Scripts/Items/Body Parts/Head.cs | 4 +- Projects/Scripts/Items/Body Parts/RibCage.cs | 2 +- Projects/Scripts/Items/Books/BaseBook.cs | 177 +- .../Books/Defined/BlackthornWelcomeBook.cs | 148 +- .../Items/Books/Defined/BookContent.cs | 6 +- .../Items/Books/Defined/DrakovsJournal.cs | 58 +- .../Items/Books/Defined/FropozJournal.cs | 80 +- .../Items/Books/Defined/KaburJournal.cs | 124 +- .../Items/Books/Defined/LibraryBooks.cs | 3138 ++++-------- .../Items/Books/Defined/NewAquariumBook.cs | 58 +- .../Defined/TranslatedGargoyleJournal.cs | 78 +- .../Champion Artifacts/Decorative/Pier.cs | 6 +- .../Champion Artifacts/Decorative/Web.cs | 2 +- .../Clothing/Artifacts/DivineCountenance.cs | 14 +- .../Items/Clothing/Artifacts/HatOfTheMagi.cs | 10 +- .../Clothing/Artifacts/HuntersHeaddress.cs | 8 +- .../Clothing/Artifacts/SpiritOfTheTotem.cs | 8 +- .../Scripts/Items/Clothing/BaseClothing.cs | 172 +- Projects/Scripts/Items/Clothing/Cloaks.cs | 34 +- Projects/Scripts/Items/Clothing/Hats.cs | 18 +- Projects/Scripts/Items/Clothing/OuterTorso.cs | 74 +- Projects/Scripts/Items/Clothing/Shoes.cs | 38 +- Projects/Scripts/Items/Construction/Ankhs.cs | 8 +- .../Items/Construction/Doors/BaseDoor.cs | 50 +- .../Scripts/Items/Construction/Doors/Doors.cs | 2 +- .../Items/Construction/Doors/HouseDoors.cs | 26 +- .../Items/Construction/Signs/LocalizedSign.cs | 8 +- .../Items/Containers/BaseTreasureChest.cs | 20 +- .../Scripts/Items/Containers/Container.cs | 14 +- .../Items/Containers/FillableContainers.cs | 70 +- .../Items/Containers/FurnitureContainer.cs | 7 +- .../Items/Containers/LockableContainer.cs | 132 +- .../Scripts/Items/Containers/MarkContainer.cs | 10 +- .../Scripts/Items/Containers/ParagonChest.cs | 4 +- .../Scripts/Items/Containers/SalvageBag.cs | 46 +- .../Scripts/Items/Containers/Strongbox.cs | 16 +- .../Items/Containers/TrappableContainer.cs | 166 +- .../Scripts/Items/Containers/TreasureChest.cs | 6 +- .../Items/Containers/TreasureMapChest.cs | 66 +- .../BaseDecorationArtifact.cs | 4 +- .../DoomDecorationArtifacts.cs | 92 - .../SEDecorationArtifacts.cs | 212 - .../StealableArtifactsSpawner.cs | 26 +- .../Scripts/Items/Deeds/BarkeepContract.cs | 2 +- .../Scripts/Items/Deeds/ClothingBlessDeed.cs | 5 +- Projects/Scripts/Items/Deeds/CommodityDeed.cs | 20 +- .../Scripts/Items/Deeds/DragonBardingDeed.cs | 20 +- .../Scripts/Items/Deeds/HairRestylingDeed.cs | 22 +- .../Scripts/Items/Deeds/HolidayTreeDeed.cs | 29 +- .../Scripts/Items/Deeds/NameChangeDeed.cs | 3 +- .../Scripts/Items/Deeds/NewPlayerTicket.cs | 16 +- .../Items/Deeds/VendorRentalContract.cs | 10 +- Projects/Scripts/Items/Facial/Beard.cs | 2 +- Projects/Scripts/Items/Facial/Hair.cs | 46 +- Projects/Scripts/Items/Food/Beverage.cs | 312 +- Projects/Scripts/Items/Food/CookableFood.cs | 35 +- Projects/Scripts/Items/Food/Cooking.cs | 60 +- Projects/Scripts/Items/Food/Food.cs | 55 +- Projects/Scripts/Items/Games/BaseBoard.cs | 12 +- Projects/Scripts/Items/Games/BasePiece.cs | 14 +- .../Games/Mahjong/MahjongDealerIndicator.cs | 8 +- .../Items/Games/Mahjong/MahjongDices.cs | 6 +- .../Items/Games/Mahjong/MahjongGame.cs | 54 +- .../Games/Mahjong/MahjongPacketHandlers.cs | 2 +- .../Items/Games/Mahjong/MahjongPieceDim.cs | 6 +- .../Items/Games/Mahjong/MahjongPlayers.cs | 14 +- .../Items/Games/Mahjong/MahjongTile.cs | 16 +- .../Games/Mahjong/MahjongTileTypeGenerator.cs | 2 +- .../Mahjong/MahjongWallBreakIndicator.cs | 4 +- .../Scripts/Items/Games/Mahjong/Packets.cs | 146 +- Projects/Scripts/Items/Gems/Amber.cs | 1 - Projects/Scripts/Items/Gems/Amethyst.cs | 1 - Projects/Scripts/Items/Gems/Citrine.cs | 1 - Projects/Scripts/Items/Gems/Diamond.cs | 1 - Projects/Scripts/Items/Gems/Emerald.cs | 1 - Projects/Scripts/Items/Gems/Ruby.cs | 1 - Projects/Scripts/Items/Gems/Sapphire.cs | 1 - Projects/Scripts/Items/Gems/StarSapphire.cs | 1 - Projects/Scripts/Items/Gems/Tourmaline.cs | 1 - Projects/Scripts/Items/Guilds/GuildDeed.cs | 6 +- .../Scripts/Items/Guilds/GuildTeleporter.cs | 10 +- Projects/Scripts/Items/Guilds/Guildstone.cs | 71 +- Projects/Scripts/Items/Jewels/BaseJewel.cs | 108 +- Projects/Scripts/Items/Jewels/Necklace.cs | 1 - Projects/Scripts/Items/Lights/BaseLight.cs | 27 +- Projects/Scripts/Items/Lights/Candelabra.cs | 16 +- Projects/Scripts/Items/Maps/MapItem.cs | 60 +- Projects/Scripts/Items/Maps/PresetMap.cs | 18 +- Projects/Scripts/Items/Maps/TreasureMap.cs | 62 +- .../Items/Minor Artifacts/IolosLute.cs | 2 +- Projects/Scripts/Items/Misc/AcidSlime.cs | 10 +- Projects/Scripts/Items/Misc/BankCheck.cs | 8 +- Projects/Scripts/Items/Misc/Beeswax.cs | 1 - .../Misc/Blighted Grove/MelisandesHairDye.cs | 2 +- Projects/Scripts/Items/Misc/Blocker.cs | 18 +- Projects/Scripts/Items/Misc/Blood.cs | 2 +- Projects/Scripts/Items/Misc/Bola.cs | 2 +- Projects/Scripts/Items/Misc/BulletinBoards.cs | 150 +- .../Scripts/Items/Misc/ClockworkAssembly.cs | 60 +- .../Items/Misc/CommunicationCrystals.cs | 12 +- Projects/Scripts/Items/Misc/Corpses/Corpse.cs | 270 +- .../Items/Misc/Corpses/CorpseNameAttribute.cs | 2 +- .../Items/Misc/Corpses/DecayedCorpse.cs | 22 +- .../Scripts/Items/Misc/Corpses/Packets.cs | 134 +- Projects/Scripts/Items/Misc/DeceitBrazier.cs | 80 +- .../Scripts/Items/Misc/EffectController.cs | 147 +- Projects/Scripts/Items/Misc/EffectItem.cs | 4 +- Projects/Scripts/Items/Misc/Firebomb.cs | 116 +- .../Items/Misc/FlippableAddonAttribute.cs | 6 +- .../Scripts/Items/Misc/FlippableAttribute.cs | 4 +- Projects/Scripts/Items/Misc/GlassItems.cs | 77 +- Projects/Scripts/Items/Misc/Guillotine.cs | 2 +- Projects/Scripts/Items/Misc/HairDye.cs | 12 +- Projects/Scripts/Items/Misc/IDurability.cs | 10 +- .../Scripts/Items/Misc/InteriorDecorator.cs | 6 +- Projects/Scripts/Items/Misc/Key.cs | 44 +- Projects/Scripts/Items/Misc/KeyRing.cs | 4 +- Projects/Scripts/Items/Misc/LOSBlocker.cs | 18 +- Projects/Scripts/Items/Misc/Moonstone.cs | 19 +- Projects/Scripts/Items/Misc/MoonstoneGate.cs | 8 +- Projects/Scripts/Items/Misc/MorphItem.cs | 28 +- Projects/Scripts/Items/Misc/OilCloth.cs | 10 +- .../Items/Misc/PlayerBulletinBoards.cs | 560 +- .../Scripts/Items/Misc/PlayerVendorDeed.cs | 2 +- Projects/Scripts/Items/Misc/PoolOfAcid.cs | 55 +- Projects/Scripts/Items/Misc/PowerGenerator.cs | 30 +- .../Scripts/Items/Misc/PromotionalToken.cs | 90 +- Projects/Scripts/Items/Misc/PublicMoongate.cs | 18 +- Projects/Scripts/Items/Misc/Rares.cs | 9 - Projects/Scripts/Items/Misc/Scales.cs | 4 +- Projects/Scripts/Items/Misc/SerpentPillar.cs | 6 +- .../Scripts/Items/Misc/SpecialBeardDye.cs | 12 +- Projects/Scripts/Items/Misc/SpecialHairDye.cs | 12 +- Projects/Scripts/Items/Misc/Static.cs | 8 +- Projects/Scripts/Items/Misc/Teleporter.cs | 112 +- Projects/Scripts/Items/Misc/TrashBarrel.cs | 4 +- Projects/Scripts/Items/Misc/TribalBerry.cs | 1 - Projects/Scripts/Items/Misc/UnholyBone.cs | 4 +- Projects/Scripts/Items/Misc/WarningItem.cs | 34 +- Projects/Scripts/Items/Misc/Waypoint.cs | 14 +- Projects/Scripts/Items/Misc/WindChimes.cs | 12 +- .../HammerOfHephaestus.cs | 5 +- Projects/Scripts/Items/Quivers/BaseQuiver.cs | 14 +- .../Scripts/Items/Resources/Arrows/Arrow.cs | 1 - .../Scripts/Items/Resources/Arrows/Bolt.cs | 1 - .../Scripts/Items/Resources/Arrows/Shaft.cs | 1 - .../Items/Resources/Blacksmithing/Ingots.cs | 42 +- .../Items/Resources/Blacksmithing/Ore.cs | 58 +- .../Items/Resources/Blacksmithing/Scales.cs | 8 +- .../Items/Resources/Fishing/BigFish.cs | 22 +- .../Scripts/Items/Resources/Fishing/Fish.cs | 3 +- .../Items/Resources/Masonry/Granite.cs | 8 +- .../Items/Resources/MiscMLResources.cs | 18 - .../Items/Resources/Reagents/BatWing.cs | 1 - .../Items/Resources/Reagents/Bloodmoss.cs | 1 - .../Items/Resources/Reagents/DaemonBlood.cs | 1 - .../Items/Resources/Reagents/DaemonBone.cs | 1 - .../Items/Resources/Reagents/Garlic.cs | 1 - .../Items/Resources/Reagents/Ginseng.cs | 1 - .../Items/Resources/Reagents/GraveDust.cs | 1 - .../Items/Resources/Reagents/MandrakeRoot.cs | 1 - .../Items/Resources/Reagents/Nightshade.cs | 1 - .../Items/Resources/Reagents/NoxCrystal.cs | 1 - .../Items/Resources/Reagents/PigIron.cs | 1 - .../Items/Resources/Reagents/SpidersSilk.cs | 1 - .../Items/Resources/Reagents/SulfurousAsh.cs | 1 - .../Items/Resources/Tailor/BoltOfCloth.cs | 2 +- .../Scripts/Items/Resources/Tailor/Bone.cs | 1 - .../Scripts/Items/Resources/Tailor/Cloth.cs | 2 +- .../Scripts/Items/Resources/Tailor/Cotton.cs | 2 +- .../Scripts/Items/Resources/Tailor/Flax.cs | 2 +- .../Scripts/Items/Resources/Tailor/Hides.cs | 26 +- .../Items/Resources/Tailor/Leathers.cs | 18 +- .../Items/Resources/Tailor/UncutCloth.cs | 2 +- .../Scripts/Items/Resources/Tailor/Wool.cs | 2 +- .../Items/Resources/Tailor/YarnsAndThreads.cs | 2 +- Projects/Scripts/Items/Shields/BaseShield.cs | 4 +- .../Scripts/Items/Shields/BronzeShield.cs | 2 +- Projects/Scripts/Items/Shields/Buckler.cs | 2 +- Projects/Scripts/Items/Shields/ChaosShield.cs | 2 +- .../Scripts/Items/Shields/HeaterShield.cs | 2 +- .../Scripts/Items/Shields/MetalKiteShield.cs | 2 +- Projects/Scripts/Items/Shields/MetalShield.cs | 2 +- Projects/Scripts/Items/Shields/OrderShield.cs | 2 +- .../Scripts/Items/Shields/WoodenKiteShield.cs | 2 +- .../Scripts/Items/Shields/WoodenShield.cs | 2 +- .../Items/Skill Items/Camping/Bedroll.cs | 6 +- .../Items/Skill Items/Camping/Campfire.cs | 12 +- .../Items/Skill Items/Camping/Kindling.cs | 1 - .../Skill Items/Carpenter Items/Board.cs | 14 +- .../Carpenter Items/TaxidermyKit.cs | 74 +- .../Fishing/Misc/MessageInABottle.cs | 28 +- .../Items/Skill Items/Fishing/Misc/SOS.cs | 71 +- .../Fishing/Misc/ShipwreckedItem.cs | 6 +- .../Fishing/Misc/SpecialFishingNet.cs | 26 +- .../Harvest Tools/BaseHarvestTool.cs | 38 +- .../Harvest Tools/ProspectorsTool.cs | 18 +- .../Items/Skill Items/Lumberjack/Log.cs | 10 +- .../Items/Skill Items/Magical/Misc/Bottle.cs | 1 - .../Skill Items/Magical/Misc/Moongate.cs | 74 +- .../Skill Items/Magical/Misc/PotionKeg.cs | 14 +- .../Skill Items/Magical/Misc/RecallRune.cs | 28 +- .../Agility Potions/BaseAgilityPotion.cs | 4 +- .../Skill Items/Magical/Potions/BasePotion.cs | 20 +- .../BaseConflagrationPotion.cs | 32 +- .../BaseConfusionBlastPotion.cs | 16 +- .../Potions/Cure Potions/BaseCurePotion.cs | 6 +- .../Potions/Cure Potions/CurePotion.cs | 4 +- .../Potions/Cure Potions/GreaterCurePotion.cs | 4 +- .../Potions/Cure Potions/LesserCurePotion.cs | 4 +- .../Explosion Potions/BaseExplosionPotion.cs | 18 +- .../Potions/Heal Potions/BaseHealPotion.cs | 6 +- .../Magical/Potions/InvisibilityPotion.cs | 4 +- .../Poison Potions/BasePoisonPotion.cs | 6 +- .../Refresh Potions/BaseRefreshPotion.cs | 2 +- .../Strength Potions/BaseStrengthPotion.cs | 4 +- .../Items/Skill Items/Magical/Runebook.cs | 92 +- .../Magical/Scrolls/SpellScroll.cs | 10 +- .../Items/Skill Items/Magical/Spellbook.cs | 85 +- .../Scripts/Items/Skill Items/Misc/Bandage.cs | 21 +- .../Items/Skill Items/Misc/FireHorn.cs | 5 +- .../Items/Skill Items/Misc/RecipeScroll.cs | 8 +- .../Items/Skill Items/Misc/RepairDeed.cs | 28 +- .../Musical Instruments/BaseInstrument.cs | 79 +- .../Items/Skill Items/Ninjitsu/Fukiya.cs | 22 +- .../Items/Skill Items/Ninjitsu/FukiyaDarts.cs | 12 +- .../Skill Items/Ninjitsu/LeatherNinjaBelt.cs | 23 +- .../Skill Items/Ninjitsu/NinjaWeapons.cs | 34 +- .../Items/Skill Items/Ninjitsu/Shuriken.cs | 12 +- .../Tailor Items/Dyetubs/CustomHuePicker.cs | 65 +- .../Tailor Items/Dyetubs/DyeTub.cs | 28 +- .../Tailor Items/Dyetubs/FurnitureDyeTub.cs | 10 +- .../Tailor Items/Dyetubs/LeatherDyeTub.cs | 10 +- .../Tailor Items/Dyetubs/MetallicHuePicker.cs | 22 +- .../Tailor Items/Dyetubs/RewardBlackDyeTub.cs | 10 +- .../Tailor Items/Dyetubs/RunebookDyeTub.cs | 10 +- .../Tailor Items/Dyetubs/SpecialDyeTub.cs | 10 +- .../Tailor Items/Dyetubs/StatuetteDyeTub.cs | 10 +- .../Dyetubs/WhiteLeatherDyeTub.cs | 1 - .../Skill Items/Tailor Items/Misc/Dyes.cs | 2 +- .../Skill Items/Tailor Items/Misc/Scissors.cs | 8 +- .../Items/Skill Items/Thief/DisguiseKit.cs | 24 +- .../Skill Items/Thief/DisguisePersistance.cs | 22 +- .../Items/Skill Items/Thief/LockPick.cs | 19 +- .../Items/Skill Items/Tinkering/Clocks.cs | 4 +- .../Items/Skill Items/Tinkering/Spyglass.cs | 2 +- .../Items/Skill Items/Tools/BaseRunicTool.cs | 148 +- .../Items/Skill Items/Tools/BaseTool.cs | 35 +- .../11th Year promo/EarringsOfProtection.cs | 10 +- .../Dawn's Music Box/DawnsMusicBox.cs | 6 +- .../Dawn's Music Box/DawnsMusicGear.cs | 12 +- .../Dawn's Music Box/DawnsMusicInfo.cs | 4 +- .../8th Anniversary Items/DupresShield.cs | 2 +- .../8th Anniversary Items/FountainOfLife.cs | 6 +- .../8th Anniversary Items/OssianGrimoire.cs | 2 +- .../8th Anniversary Items/Talismans.cs | 10 +- .../Special/AoS Promotional/LuckyNecklace.cs | 2 +- .../Broken Furniture Collection/BrokenBed.cs | 2 +- .../BrokenVanity.cs | 2 +- .../Blacksmithy/AncientSmithyHammer.cs | 8 +- .../Blacksmithy/GlovesOfMining.cs | 8 +- .../Blacksmithy/PowderOfTemperament.cs | 12 +- .../JesterHatofChuckles.cs | 2 +- .../AwesomeDisturbingPortrait.cs | 2 +- .../Evil Home Decor Collection/BedOfNails.cs | 2 +- .../Items/Special/Gifts/HearthOfHomeFire.cs | 2 +- .../Items/Special/Gifts/RoseOfTrinsic.cs | 5 +- .../Items/Special/Gifts/TapestryOfSosaria.cs | 2 +- .../Items/Special/Heritage Items/Curtains.cs | 8 +- .../Special/Heritage Items/FruitTrees.cs | 4 +- .../Special/Heritage Items/HangingAxes.cs | 2 +- .../Special/Heritage Items/HangingSwords.cs | 2 +- .../Special/Heritage Items/HouseLadder.cs | 2 +- .../Special/Heritage Items/IronMaiden.cs | 2 +- .../Items/Special/Heritage Items/Statue.cs | 2 +- .../Items/Special/Heritage Items/UnmadeBed.cs | 2 +- .../Items/Special/Heritage Items/Vanity.cs | 2 +- .../Items/Special/Heritage Items/WallTorch.cs | 1 - .../Special/Heritage Items/WoodenCoffin.cs | 2 +- .../Special/Holiday/Christmas/HolidayTree.cs | 167 +- .../Special/Holiday/GingerBreadHouseDeed.cs | 2 +- .../Items/Special/Holiday/HolidayBell.cs | 4 +- .../Items/Special/Holiday/HolidayFoods.cs | 6 +- .../Special/Holiday/HolidayPottedPlant.cs | 2 +- .../Scripts/Items/Special/Holiday/IcyPatch.cs | 12 +- .../Items/Special/Holiday/SnowGlobes.cs | 24 +- .../Items/Special/Holiday/SnowStatue.cs | 2 +- .../Scripts/Items/Special/Holiday/Snowman.cs | 8 +- .../Scripts/Items/Special/Holiday/Wreath.cs | 10 +- .../Special/House Raffle/HouseRaffleDeed.cs | 22 +- .../House Raffle/HouseRaffleManagementGump.cs | 122 +- .../Special/House Raffle/HouseRaffleRegion.cs | 2 +- .../Special/House Raffle/HouseRaffleStone.cs | 184 +- .../Items/Special/ML/BaseImprisonedMobile.cs | 2 +- Projects/Scripts/Items/Special/MiniHouses.cs | 32 +- .../Scripts/Items/Special/MonsterStatuette.cs | 27 +- .../Mutation Core/PlagueBeastBackpack.cs | 4 +- .../Special/Mutation Core/PlagueBeastBlood.cs | 2 +- .../Special/Mutation Core/PlagueBeastHeart.cs | 2 +- .../Mutation Core/PlagueBeastInnard.cs | 4 +- .../Mutation Core/PlagueBeastMutationCore.cs | 2 +- .../Mutation Core/PlagueBeastOrgans.cs | 8 +- .../Special/Mutation Core/PlagueBeastVein.cs | 2 +- .../Rares/Containers/BaseWaterContainer.cs | 10 +- .../Items/Special/Rares/Containers/Bucket.cs | 4 +- .../Special/Rares/Containers/WaterBarrel.cs | 4 +- .../Special/Rares/Containers/WaterTub.cs | 4 +- .../Items/Special/Solen Items/BagOfSending.cs | 24 +- .../Special/Solen Items/BallOfSummoning.cs | 36 +- .../Special/Solen Items/BraceletOfBinding.cs | 30 +- .../Solen Items/PowderOfTranslocation.cs | 12 +- Projects/Scripts/Items/Special/SoulStone.cs | 85 +- .../Special/Special Scrolls/PowerScroll.cs | 40 +- .../Special Scrolls/ScrollofAlacrity.cs | 34 +- .../Special Scrolls/ScrollofTranscendence.cs | 33 +- .../Special/Special Scrolls/SpecialScroll.cs | 58 +- .../Special/Special Scrolls/StatScroll.cs | 36 +- .../Special/Valentines/2007/ValentinesCard.cs | 12 +- .../Veteran Rewards/AnkhOfSacrifice.cs | 8 +- .../Items/Special/Veteran Rewards/Banner.cs | 15 +- .../Items/Special/Veteran Rewards/Brazier.cs | 4 +- .../Items/Special/Veteran Rewards/Cannon.cs | 61 +- .../Veteran Rewards/DecorativeShield.cs | 24 +- .../Special/Veteran Rewards/FlamingHead.cs | 2 +- .../Veteran Rewards/HangingSkeleton.cs | 20 +- .../Special/Veteran Rewards/MiningCart.cs | 16 +- .../Special/Veteran Rewards/PottedCactus.cs | 3 +- .../Special/Veteran Rewards/StoneAnkh.cs | 2 +- .../Special/Veteran Rewards/WallBanner.cs | 7 +- .../Veteran Rewards/WeaponEngravingTool.cs | 10 +- Projects/Scripts/Items/Suits/BaseSuit.cs | 11 +- .../Scripts/Items/Talismans/BaseTalisman.cs | 134 +- .../Items/Talismans/Items/RunedSwitch.cs | 2 +- .../Items/Talismans/TalismanAttribute.cs | 6 +- .../Scripts/Items/Talismans/TalismanSlayer.cs | 7 +- .../Items/Talismans/TalismanSummons.cs | 19 +- .../Scripts/Items/Traps/FireColumnTrap.cs | 12 +- .../Scripts/Items/Traps/FlameSpurtTrap.cs | 12 +- Projects/Scripts/Items/Traps/GasTrap.cs | 10 +- .../TreasureChests/TreasureChestLevel1.cs | 2 +- .../TreasureChests/TreasureChestLevel2.cs | 2 +- .../TreasureChests/TreasureChestLevel3.cs | 2 +- Projects/Scripts/Items/Wands/BaseWand.cs | 10 +- Projects/Scripts/Items/Wands/WandTarget.cs | 2 +- .../Items/Weapons/Abilities/BleedAttack.cs | 10 +- .../Scripts/Items/Weapons/Abilities/Block.cs | 8 +- .../Items/Weapons/Abilities/CrushingBlow.cs | 1 - .../Items/Weapons/Abilities/DefenseMastery.cs | 8 +- .../Scripts/Items/Weapons/Abilities/Disarm.cs | 8 +- .../Items/Weapons/Abilities/Dismount.cs | 7 +- .../Items/Weapons/Abilities/Disrobe.cs | 4 +- .../Items/Weapons/Abilities/DoubleShot.cs | 2 +- .../Items/Weapons/Abilities/DoubleStrike.cs | 2 +- .../Items/Weapons/Abilities/DualWield.cs | 8 +- .../Scripts/Items/Weapons/Abilities/Feint.cs | 8 +- .../Weapons/Abilities/FrenziedWhirlwind.cs | 10 +- .../Items/Weapons/Abilities/MortalStrike.cs | 4 +- .../Items/Weapons/Abilities/MovingShot.cs | 4 +- .../Items/Weapons/Abilities/NerveStrike.cs | 4 +- .../Items/Weapons/Abilities/ParalyzingBlow.cs | 12 +- .../Items/Weapons/Abilities/RidingSwipe.cs | 8 +- .../Items/Weapons/Abilities/TalonStrike.cs | 12 +- .../Items/Weapons/Abilities/WeaponAbility.cs | 19 +- .../Weapons/Artifacts/BladeOfTheRighteous.cs | 2 +- .../Items/Weapons/Artifacts/TheDryadBow.cs | 2 +- .../Scripts/Items/Weapons/Axes/BaseAxe.cs | 26 +- .../Scripts/Items/Weapons/BaseMeleeWeapon.cs | 4 +- Projects/Scripts/Items/Weapons/BaseWeapon.cs | 823 ++- Projects/Scripts/Items/Weapons/Fists.cs | 10 +- Projects/Scripts/Items/Weapons/HitLower.cs | 8 +- .../Items/Weapons/Knives/ThrowingDagger.cs | 2 +- .../Items/Weapons/Maces/FireworksWand.cs | 8 +- .../Items/Weapons/PoleArms/BasePoleArm.cs | 26 +- .../Items/Weapons/Ranged/BaseRanged.cs | 40 +- Projects/Scripts/Items/Weapons/SlayerEntry.cs | 10 +- Projects/Scripts/Items/Weapons/SlayerGroup.cs | 18 +- .../Items/Weapons/Staves/GlacialStaff.cs | 2 +- .../Items/Weapons/Staves/ShepherdsCrook.cs | 4 +- .../Items/Weapons/Swords/BoneMachete.cs | 4 - Projects/Scripts/Misc/AOS.cs | 39 +- Projects/Scripts/Misc/AttackMessage.cs | 2 +- Projects/Scripts/Misc/AutoRestart.cs | 8 +- Projects/Scripts/Misc/AutoSave.cs | 10 +- Projects/Scripts/Misc/BuffIcons.cs | 148 +- Projects/Scripts/Misc/CharacterCreation.cs | 1304 +++-- Projects/Scripts/Misc/Cleanup.cs | 13 +- Projects/Scripts/Misc/ClientVerification.cs | 48 +- Projects/Scripts/Misc/CrashGuard.cs | 4 +- Projects/Scripts/Misc/CurrentExpansion.cs | 3 +- Projects/Scripts/Misc/DoorGenerator.cs | 102 +- Projects/Scripts/Misc/Email.cs | 7 +- Projects/Scripts/Misc/Emitter.cs | 435 +- Projects/Scripts/Misc/Fastwalk.cs | 10 +- Projects/Scripts/Misc/Geometry.cs | 6 +- .../Winter2004/LightOfTheWinterSolstice.cs | 26 +- .../Misc/Gifts/Winter2004/Mistletoe.cs | 10 +- .../Gifts/Winter2004/PileOfGlacialSnow.cs | 5 +- .../Scripts/Misc/Gifts/Winter2004/SnowPile.cs | 5 +- Projects/Scripts/Misc/Guild.cs | 326 +- Projects/Scripts/Misc/HardwareInfo.cs | 52 +- Projects/Scripts/Misc/InhumanSpeech.cs | 230 +- Projects/Scripts/Misc/Keywords.cs | 42 +- Projects/Scripts/Misc/LanguageStatistics.cs | 26 +- Projects/Scripts/Misc/LightCycle.cs | 2 +- Projects/Scripts/Misc/Loot.cs | 155 +- Projects/Scripts/Misc/LootPack.cs | 92 +- Projects/Scripts/Misc/MapDefinitions.cs | 4 +- Projects/Scripts/Misc/MapUO.cs | 34 +- Projects/Scripts/Misc/MondainsLegacy.cs | 2 +- Projects/Scripts/Misc/NameList.cs | 52 +- Projects/Scripts/Misc/NameVerification.cs | 12 +- Projects/Scripts/Misc/Notoriety.cs | 41 +- Projects/Scripts/Misc/Poison.cs | 31 +- Projects/Scripts/Misc/ProfanityProtection.cs | 25 +- Projects/Scripts/Misc/ProtocolExtensions.cs | 4 +- Projects/Scripts/Misc/RaceDefinitions.cs | 54 +- Projects/Scripts/Misc/RegenRates.cs | 10 +- Projects/Scripts/Misc/ResourceInfo.cs | 216 +- Projects/Scripts/Misc/ShardPoller.cs | 72 +- Projects/Scripts/Misc/ShrinkTable.cs | 4 +- Projects/Scripts/Misc/SkillCheck.cs | 175 +- Projects/Scripts/Misc/SocketOptions.cs | 2 +- Projects/Scripts/Misc/TextDefinition.cs | 4 +- Projects/Scripts/Misc/Titles.cs | 6 +- Projects/Scripts/Misc/ToggleItem.cs | 6 +- Projects/Scripts/Misc/VendorGenerator.cs | 50 +- Projects/Scripts/Misc/Weather.cs | 166 +- Projects/Scripts/Misc/WebStatus.cs | 6 +- Projects/Scripts/Misc/WeightOverloading.cs | 18 +- Projects/Scripts/Misc/WelcomeTimer.cs | 9 +- Projects/Scripts/Misc/uoamVendors.cs | 17 +- .../Mobiles/AI/AIControlMobileTarget.cs | 4 +- Projects/Scripts/Mobiles/AI/AnimalAI.cs | 2 +- Projects/Scripts/Mobiles/AI/ArcherAI.cs | 1 - Projects/Scripts/Mobiles/AI/BaseAI.cs | 471 +- Projects/Scripts/Mobiles/AI/HealerAI.cs | 14 +- Projects/Scripts/Mobiles/AI/MageAI.cs | 199 +- Projects/Scripts/Mobiles/AI/MeleeAI.cs | 9 +- .../Scripts/Mobiles/AI/OppositionGroup.cs | 8 +- Projects/Scripts/Mobiles/AI/PredatorAI.cs | 6 - Projects/Scripts/Mobiles/AI/SpeedInfo.cs | 18 +- Projects/Scripts/Mobiles/AI/ThiefAI.cs | 5 - Projects/Scripts/Mobiles/AI/VendorAI.cs | 5 - .../Scripts/Mobiles/Animals/Birds/Crane.cs | 1 - Projects/Scripts/Mobiles/Animals/Cows/Bull.cs | 2 +- Projects/Scripts/Mobiles/Animals/Cows/Cow.cs | 4 +- .../Scripts/Mobiles/Animals/Misc/PackHorse.cs | 8 +- .../Scripts/Mobiles/Animals/Misc/PackLlama.cs | 4 - .../Scripts/Mobiles/Animals/Misc/Sheep.cs | 8 +- .../Mobiles/Animals/Mounts/BaseMount.cs | 42 +- .../Scripts/Mobiles/Animals/Mounts/Beetle.cs | 7 +- .../Mobiles/Animals/Mounts/DesertOstard.cs | 3 +- .../Mobiles/Animals/Mounts/Ethereals.cs | 46 +- .../Mobiles/Animals/Mounts/FireSteed.cs | 3 +- .../Mobiles/Animals/Mounts/ForestOstard.cs | 3 +- .../Mobiles/Animals/Mounts/FrenziedOstard.cs | 3 +- .../Mobiles/Animals/Mounts/HellSteed.cs | 3 +- .../Scripts/Mobiles/Animals/Mounts/Hiryu.cs | 37 +- .../Scripts/Mobiles/Animals/Mounts/Horse.cs | 5 +- .../Scripts/Mobiles/Animals/Mounts/Kirin.cs | 10 +- .../Mobiles/Animals/Mounts/LesserHiryu.cs | 26 +- .../Mobiles/Animals/Mounts/Nightmare.cs | 33 +- .../Mobiles/Animals/Mounts/RidableLlama.cs | 3 +- .../Mobiles/Animals/Mounts/Ridgeback.cs | 3 +- .../Mobiles/Animals/Mounts/SavageRidgeback.cs | 3 +- .../Animals/Mounts/ScaledSwampDragon.cs | 3 +- .../Mobiles/Animals/Mounts/SeaHorse.cs | 3 +- .../Mobiles/Animals/Mounts/SilverSteed.cs | 3 +- .../Mobiles/Animals/Mounts/SkeletalMount.cs | 15 +- .../Mobiles/Animals/Mounts/SwampDragon.cs | 19 +- .../Scripts/Mobiles/Animals/Mounts/Unicorn.cs | 7 +- .../Mobiles/Animals/Reptiles/GiantSerpent.cs | 2 +- .../Mobiles/Animals/Reptiles/IceSerpent.cs | 2 +- Projects/Scripts/Mobiles/BaseCreature.cs | 446 +- .../Scripts/Mobiles/Familiars/BaseFamiliar.cs | 4 +- .../Scripts/Mobiles/Familiars/DeathAdder.cs | 2 +- .../Scripts/Mobiles/Familiars/HordeMinion.cs | 4 - .../Scripts/Mobiles/Guards/ArcherGuard.cs | 67 +- Projects/Scripts/Mobiles/Guards/BaseGuard.cs | 2 +- .../Scripts/Mobiles/Guards/WarriorGuard.cs | 46 +- .../Scripts/Mobiles/Healers/BaseHealer.cs | 4 +- .../Scripts/Mobiles/Healers/PricedHealer.cs | 10 +- .../Mobiles/Monsters/AOS/DemonKnight.cs | 6 +- .../Scripts/Mobiles/Monsters/AOS/Impaler.cs | 2 +- .../Scripts/Mobiles/Monsters/AOS/Revenant.cs | 4 +- .../Scripts/Mobiles/Monsters/Ants/AntLion.cs | 1 - .../Ants/BlackSolenInfiltratorQueen.cs | 2 +- .../Ants/BlackSolenInfiltratorWarrior.cs | 2 +- .../Mobiles/Monsters/Ants/BlackSolenQueen.cs | 10 +- .../Monsters/Ants/BlackSolenWarrior.cs | 12 +- .../Monsters/Ants/RedSolenInfiltratorQueen.cs | 2 +- .../Ants/RedSolenInfiltratorWarrior.cs | 2 +- .../Mobiles/Monsters/Ants/RedSolenQueen.cs | 11 +- .../Mobiles/Monsters/Ants/RedSolenWarrior.cs | 12 +- .../Mobiles/Monsters/Ants/SolenHelper.cs | 2 +- .../Monsters/Elemental/Magic/Efreet.cs | 2 +- .../Monsters/Humanoid/Magic/Betrayer.cs | 8 +- .../Monsters/Humanoid/Magic/Gargoyle.cs | 2 +- .../Humanoid/Magic/GargoyleDestroyer.cs | 6 +- .../Humanoid/Magic/GargoyleEnforcer.cs | 2 +- .../Humanoid/Magic/GolemController.cs | 2 +- .../Mobiles/Monsters/Humanoid/Magic/Lich.cs | 1 - .../Monsters/Humanoid/Magic/OrcishMage.cs | 3 +- .../Monsters/Humanoid/Magic/RatmanMage.cs | 2 +- .../Monsters/Humanoid/Magic/SavageShaman.cs | 154 +- .../Monsters/Humanoid/Magic/Succubus.cs | 10 +- .../Mobiles/Monsters/Humanoid/Melee/Cursed.cs | 2 +- .../Humanoid/Melee/EnslavedGargoyle.cs | 2 +- .../Monsters/Humanoid/Melee/Guardian.cs | 3 +- .../Monsters/Humanoid/Melee/Juggernaut.cs | 11 +- .../Humanoid/Melee/KhaldunRevenant.cs | 10 +- .../Mobiles/Monsters/Humanoid/Melee/Orc.cs | 2 +- .../Monsters/Humanoid/Melee/OrcBomber.cs | 7 +- .../Monsters/Humanoid/Melee/OrcBrute.cs | 6 +- .../Monsters/Humanoid/Melee/OrcishLord.cs | 4 +- .../Monsters/Humanoid/Melee/RestlessSoul.cs | 3 +- .../Mobiles/Monsters/Humanoid/Melee/Savage.cs | 8 +- .../Monsters/Humanoid/Melee/SavageRider.cs | 2 +- .../Monsters/Humanoid/Melee/ShadowFiend.cs | 2 +- .../Monsters/Humanoid/Melee/StoneGargoyle.cs | 2 +- .../Monsters/LBR/Exodus/ExodusMinion.cs | 6 +- .../Monsters/LBR/Exodus/ExodusOverseer.cs | 6 +- .../Monsters/LBR/Jukas/ChaosDragoon.cs | 12 +- .../Monsters/LBR/Jukas/ChaosDragoonElite.cs | 1 - .../Mobiles/Monsters/LBR/Jukas/JukaLord.cs | 2 +- .../Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs | 32 +- .../Monsters/LBR/Meers/EnragedCreatures.cs | 4 +- .../Mobiles/Monsters/LBR/Meers/MeerCaptain.cs | 4 +- .../Mobiles/Monsters/LBR/Meers/MeerEternal.cs | 2 +- .../Mobiles/Monsters/LBR/Meers/MeerMage.cs | 4 +- .../Mobiles/Monsters/ML/Animal/CuSidhe.cs | 11 +- .../Mobiles/Monsters/ML/Animal/Ferret.cs | 8 +- .../Monsters/ML/Animal/RagingGrizzlyBear.cs | 4 +- .../Monsters/ML/Bedlam/LadyJennifyr.cs | 10 +- .../Mobiles/Monsters/ML/Bedlam/LadyMarai.cs | 6 +- .../Monsters/ML/Bedlam/MasterJonath.cs | 6 +- .../Monsters/ML/Bedlam/MasterMikael.cs | 6 +- .../Mobiles/Monsters/ML/Bedlam/SirPatrick.cs | 8 +- .../Monsters/ML/Blighted Grove/Coil.cs | 4 +- .../ML/Blighted Grove/EnslavedSatyr.cs | 4 +- .../Monsters/ML/Blighted Grove/Hydra.cs | 6 +- .../Monsters/ML/Blighted Grove/InsaneDryad.cs | 4 +- .../Monsters/ML/Blighted Grove/Saliva.cs | 6 +- .../Monsters/ML/Humanoid/Magic/MLDryad.cs | 12 +- .../Monsters/ML/Humanoid/Magic/Satyr.cs | 28 +- .../ML/Humanoid/Melee/FerelTreefellow.cs | 6 +- .../ML/Humanoid/Melee/MinotaurScout.cs | 8 +- .../ML/Humanoid/Melee/Tormented Minotaur.cs | 1 - .../Mobiles/Monsters/ML/Labyrinth/Miasma.cs | 4 +- .../Monsters/ML/Misc/Melee/CorrosiveSlime.cs | 2 +- .../Monsters/ML/Painted Caves/Grobu.cs | 1 - .../ML/Palace of Paroxysmus/Putrefier.cs | 4 +- .../ML/Prism of Light/CrystalDaemon.cs | 4 +- .../ML/Prism of Light/CrystalLatticeSeeker.cs | 56 +- .../ML/Prism of Light/CrystalSeaSerpent.cs | 8 +- .../ML/Prism of Light/CrystalVortex.cs | 8 +- .../Monsters/ML/Prism of Light/Protector.cs | 4 +- .../ML/Prism of Light/UnfrozenMummy.cs | 8 +- .../Mobiles/Monsters/ML/Special/Ilhenir.cs | 10 +- .../Mobiles/Monsters/ML/Special/Meraktus.cs | 18 +- .../Mobiles/Monsters/ML/Special/Twaulo.cs | 4 +- .../Mobiles/Monsters/ML/Twisted Weald/Gnaw.cs | 4 +- .../Mobiles/Monsters/ML/Twisted Weald/Irk.cs | 6 +- .../Monsters/ML/Twisted Weald/LadyLissith.cs | 8 +- .../Monsters/ML/Twisted Weald/LadySabrix.cs | 8 +- .../Monsters/ML/Twisted Weald/Malefic.cs | 4 +- .../Monsters/ML/Twisted Weald/Swoop.cs | 14 +- .../Monsters/ML/Twisted Weald/Virulent.cs | 6 +- .../Monsters/Misc/Magic/EtherealWarrior.cs | 2 +- .../Mobiles/Monsters/Misc/Magic/Pixie.cs | 2 +- .../Monsters/Misc/Melee/EnergyVortex.cs | 3 +- .../Mobiles/Monsters/Misc/Melee/Golem.cs | 17 +- .../Monsters/Misc/Melee/PlagueBeast.cs | 24 +- .../Monsters/Misc/Melee/PlagueBeastLord.cs | 8 +- .../Monsters/Misc/Melee/PlagueSpawn.cs | 7 +- .../Mobiles/Monsters/Misc/Melee/SandVortex.cs | 3 +- .../Ore Elementals/BronzeElemental.cs | 3 +- .../Ore Elementals/DullCopperElemental.cs | 3 +- .../Ore Elementals/GoldenElemental.cs | 3 +- .../Mobiles/Monsters/Plant/Melee/BogThing.cs | 6 +- .../Mobiles/Monsters/Plant/Melee/Corpser.cs | 2 +- .../Monsters/Plant/Melee/WhippingVine.cs | 2 +- .../Monsters/Reptile/Magic/DeepSeaSerpent.cs | 2 +- .../Monsters/Reptile/Magic/Leviathan.cs | 9 +- .../Reptile/Magic/OphidianArchmage.cs | 2 +- .../Monsters/Reptile/Magic/OphidianMage.cs | 2 +- .../Monsters/Reptile/Magic/SeaSerpent.cs | 2 +- .../Reptile/Magic/SerpentineDragon.cs | 2 +- .../Mobiles/Monsters/Reptile/Melee/Kraken.cs | 2 +- .../Monsters/Reptile/Melee/OphidianKnight.cs | 2 +- .../Monsters/Reptile/Melee/OphidianWarrior.cs | 2 +- .../Monsters/Reptile/Melee/Scorpion.cs | 2 +- .../Mobiles/Monsters/SE/BakeKitsune.cs | 13 +- .../Monsters/SE/DeathWatchBeetleHatchling.cs | 1 - .../Scripts/Mobiles/Monsters/SE/EliteNinja.cs | 2 - .../Scripts/Mobiles/Monsters/SE/FanDancer.cs | 17 +- .../Scripts/Mobiles/Monsters/SE/FireBeetle.cs | 1 - Projects/Scripts/Mobiles/Monsters/SE/Kappa.cs | 6 +- .../Scripts/Mobiles/Monsters/SE/KazeKemono.cs | 15 +- .../Mobiles/Monsters/SE/LadyOfTheSnow.cs | 11 +- Projects/Scripts/Mobiles/Monsters/SE/RaiJu.cs | 8 +- Projects/Scripts/Mobiles/Monsters/SE/Ronin.cs | 1 - .../Scripts/Mobiles/Monsters/SE/RuneBeetle.cs | 9 +- .../Scripts/Mobiles/Monsters/SE/TsukiWolf.cs | 8 +- .../Scripts/Mobiles/Monsters/SE/Yamandon.cs | 5 +- .../Mobiles/Monsters/SE/YomotsuElder.cs | 4 +- .../Mobiles/Monsters/SE/YomotsuPriest.cs | 4 +- .../Mobiles/Monsters/SE/YomotsuWarrior.cs | 2 +- Projects/Scripts/Mobiles/PlayerMobile.cs | 869 ++-- Projects/Scripts/Mobiles/Special/Barracoon.cs | 10 +- .../Scripts/Mobiles/Special/BaseChampion.cs | 82 +- .../Mobiles/Special/BaseShieldGuard.cs | 10 +- Projects/Scripts/Mobiles/Special/Dummy.cs | 2 +- Projects/Scripts/Mobiles/Special/Harrower.cs | 101 +- .../Mobiles/Special/HarrowerTentacles.cs | 21 +- Projects/Scripts/Mobiles/Special/LordOaks.cs | 14 +- Projects/Scripts/Mobiles/Special/Neira.cs | 26 +- Projects/Scripts/Mobiles/Special/Paragon.cs | 6 +- Projects/Scripts/Mobiles/Special/Rikktor.cs | 4 +- Projects/Scripts/Mobiles/Special/Semidar.cs | 6 +- Projects/Scripts/Mobiles/Special/Serado.cs | 4 +- Projects/Scripts/Mobiles/Special/Silvani.cs | 4 +- Projects/Scripts/Mobiles/Special/Wanderer.cs | 4 +- Projects/Scripts/Mobiles/Townfolk/Actor.cs | 1 - Projects/Scripts/Mobiles/Townfolk/Artist.cs | 3 - Projects/Scripts/Mobiles/Townfolk/Banker.cs | 214 +- .../Mobiles/Townfolk/BaseEscortable.cs | 30 +- Projects/Scripts/Mobiles/Townfolk/Gypsy.cs | 1 - .../Scripts/Mobiles/Townfolk/HarborMaster.cs | 3 - Projects/Scripts/Mobiles/Townfolk/Merchant.cs | 7 +- Projects/Scripts/Mobiles/Townfolk/Ninja.cs | 1 - Projects/Scripts/Mobiles/Townfolk/Peasant.cs | 12 +- Projects/Scripts/Mobiles/Townfolk/Samurai.cs | 1 - Projects/Scripts/Mobiles/Townfolk/Sculptor.cs | 1 - .../Mobiles/Townfolk/SeekerOfAdventure.cs | 4 +- .../Scripts/Mobiles/Townfolk/TownCrier.cs | 26 +- Projects/Scripts/Mobiles/Vendors/AnimalBuy.cs | 2 +- .../Scripts/Mobiles/Vendors/BaseVendor.cs | 174 +- .../Scripts/Mobiles/Vendors/BeverageBuy.cs | 5 +- .../Scripts/Mobiles/Vendors/GenericBuy.cs | 20 +- .../Scripts/Mobiles/Vendors/GenericSell.cs | 77 +- .../Scripts/Mobiles/Vendors/NPC/Alchemist.cs | 2 +- .../Mobiles/Vendors/NPC/AnimalTrainer.cs | 30 +- .../Scripts/Mobiles/Vendors/NPC/Architect.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Armorer.cs | 62 +- Projects/Scripts/Mobiles/Vendors/NPC/Baker.cs | 2 +- Projects/Scripts/Mobiles/Vendors/NPC/Bard.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Barkeeper.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Beekeeper.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Blacksmith.cs | 8 +- .../Scripts/Mobiles/Vendors/NPC/Bowyer.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Butcher.cs | 4 +- .../Scripts/Mobiles/Vendors/NPC/Carpenter.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Cobbler.cs | 4 +- Projects/Scripts/Mobiles/Vendors/NPC/Cook.cs | 2 +- .../Mobiles/Vendors/NPC/CustomHairstylist.cs | 61 +- .../Scripts/Mobiles/Vendors/NPC/Farmer.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Fisherman.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Furtrader.cs | 4 +- .../Mobiles/Vendors/NPC/Glassblower.cs | 2 +- .../Mobiles/Vendors/NPC/GolemCrafter.cs | 2 +- .../NPC/Guildmasters/BaseGuildmaster.cs | 2 +- .../NPC/Guildmasters/TinkerGuildmaster.cs | 4 +- .../Mobiles/Vendors/NPC/GypsyMaiden.cs | 2 +- .../Mobiles/Vendors/NPC/HairStylist.cs | 4 +- .../Scripts/Mobiles/Vendors/NPC/Herbalist.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/HolyMage.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/InnKeeper.cs | 4 +- .../Scripts/Mobiles/Vendors/NPC/IronWorker.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Jeweler.cs | 2 +- .../Mobiles/Vendors/NPC/KeeperOfChivalry.cs | 2 +- .../Mobiles/Vendors/NPC/LeatherWorker.cs | 4 +- Projects/Scripts/Mobiles/Vendors/NPC/Mage.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Mapmaker.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Miller.cs | 2 +- Projects/Scripts/Mobiles/Vendors/NPC/Miner.cs | 2 +- Projects/Scripts/Mobiles/Vendors/NPC/Monk.cs | 2 +- .../Mobiles/Vendors/NPC/Provisioner.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Rancher.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Ranger.cs | 2 +- .../Mobiles/Vendors/NPC/RealEstateBroker.cs | 6 +- .../Scripts/Mobiles/Vendors/NPC/Scribe.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Shipwright.cs | 6 +- .../Mobiles/Vendors/NPC/StoneCrafter.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Tailor.cs | 8 +- .../Scripts/Mobiles/Vendors/NPC/Tanner.cs | 2 +- .../Mobiles/Vendors/NPC/TavernKeeper.cs | 4 +- Projects/Scripts/Mobiles/Vendors/NPC/Thief.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Tinker.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Vagabond.cs | 3 +- .../Mobiles/Vendors/NPC/VarietyDealer.cs | 2 +- .../Mobiles/Vendors/NPC/Veterinarian.cs | 2 +- .../Scripts/Mobiles/Vendors/NPC/Waiter.cs | 2 +- .../Mobiles/Vendors/NPC/Weaponsmith.cs | 8 +- .../Scripts/Mobiles/Vendors/NPC/Weaver.cs | 8 +- .../Mobiles/Vendors/PlayerBarkeeper.cs | 148 +- .../Scripts/Mobiles/Vendors/PlayerVendor.cs | 117 +- .../Scripts/Mobiles/Vendors/PresetMapBuy.cs | 2 +- .../Scripts/Mobiles/Vendors/RentedVendor.cs | 30 +- .../Vendors/SBInfo/Armors/SBChainmailArmor.cs | 4 +- .../Vendors/SBInfo/Armors/SBHelmetArmor.cs | 4 +- .../Vendors/SBInfo/Armors/SBLeatherArmor.cs | 4 +- .../Vendors/SBInfo/Armors/SBMetalShields.cs | 4 +- .../Vendors/SBInfo/Armors/SBPlateArmor.cs | 4 +- .../Vendors/SBInfo/Armors/SBRingmailArmor.cs | 4 +- .../Vendors/SBInfo/Armors/SBStuddedArmor.cs | 4 +- .../Vendors/SBInfo/Armors/SBWoodenShields.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBAlchemist.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBAnimalTrainer.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBArchitect.cs | 4 +- .../Scripts/Mobiles/Vendors/SBInfo/SBBaker.cs | 6 +- .../Mobiles/Vendors/SBInfo/SBBanker.cs | 4 +- .../Scripts/Mobiles/Vendors/SBInfo/SBBard.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBBarkeeper.cs | 10 +- .../Mobiles/Vendors/SBInfo/SBBeekeeper.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBBlacksmith.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBBowyer.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBButcher.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBCarpenter.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBCobbler.cs | 4 +- .../Scripts/Mobiles/Vendors/SBInfo/SBCook.cs | 6 +- .../Mobiles/Vendors/SBInfo/SBFarmer.cs | 8 +- .../Mobiles/Vendors/SBInfo/SBFisherman.cs | 14 +- .../Mobiles/Vendors/SBInfo/SBFortuneTeller.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBFurtrader.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBGlassblower.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBHairStylist.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBHealer.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBHerbalist.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBHolyMage.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBHouseDeed.cs | 4 +- .../Scripts/Mobiles/Vendors/SBInfo/SBInfo.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBInnKeeper.cs | 6 +- .../Scripts/Mobiles/Vendors/SBInfo/SBJewel.cs | 4 +- .../Vendors/SBInfo/SBKeeperOfChivalry.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBLeatherWorker.cs | 4 +- .../Scripts/Mobiles/Vendors/SBInfo/SBMage.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBMapmaker.cs | 6 +- .../Mobiles/Vendors/SBInfo/SBMiller.cs | 4 +- .../Scripts/Mobiles/Vendors/SBInfo/SBMiner.cs | 8 +- .../Scripts/Mobiles/Vendors/SBInfo/SBMonk.cs | 4 +- .../Scripts/Mobiles/Vendors/SBInfo/SBNinja.cs | 4 +- .../Vendors/SBInfo/SBPlayerBarkeeper.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBProvisioner.cs | 10 +- .../Mobiles/Vendors/SBInfo/SBRancher.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBRanger.cs | 4 +- .../Vendors/SBInfo/SBRealEstateBroker.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBSECook.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBSEHats.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBSamurai.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBScribe.cs | 6 +- .../Mobiles/Vendors/SBInfo/SBShipwright.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBSmithTools.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBStoneCrafter.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBTailor.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBTanner.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBTavernKeeper.cs | 10 +- .../Scripts/Mobiles/Vendors/SBInfo/SBThief.cs | 8 +- .../Mobiles/Vendors/SBInfo/SBTinker.cs | 5 +- .../Mobiles/Vendors/SBInfo/SBVagabond.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBVarietyDealer.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBVeterinarian.cs | 4 +- .../Mobiles/Vendors/SBInfo/SBWaiter.cs | 6 +- .../Mobiles/Vendors/SBInfo/SBWeaponSmith.cs | 108 +- .../Mobiles/Vendors/SBInfo/SBWeaver.cs | 4 +- .../Mobiles/Vendors/SBInfo/SE/SBSEArmor.cs | 4 +- .../Mobiles/Vendors/SBInfo/SE/SBSEBowyer.cs | 4 +- .../Vendors/SBInfo/SE/SBSECarpenter.cs | 4 +- .../Mobiles/Vendors/SBInfo/SE/SBSEFood.cs | 4 +- .../Vendors/SBInfo/SE/SBSELeatherArmor.cs | 4 +- .../Mobiles/Vendors/SBInfo/SE/SBSEWeapons.cs | 4 +- .../Vendors/SBInfo/Weapons/SBAxeWeapon.cs | 4 +- .../Vendors/SBInfo/Weapons/SBKnifeWeapon.cs | 4 +- .../Vendors/SBInfo/Weapons/SBMaceWeapon.cs | 4 +- .../Vendors/SBInfo/Weapons/SBPoleArmWeapon.cs | 4 +- .../Vendors/SBInfo/Weapons/SBRangedWeapon.cs | 4 +- .../SBInfo/Weapons/SBSpearForkWeapon.cs | 4 +- .../Vendors/SBInfo/Weapons/SBStavesWeapon.cs | 4 +- .../Vendors/SBInfo/Weapons/SBSwordWeapon.cs | 4 +- .../Mobiles/Vendors/VendorInventory.cs | 18 +- Projects/Scripts/Multis/BaseHouse.cs | 608 ++- Projects/Scripts/Multis/Boats/BaseBoat.cs | 361 +- Projects/Scripts/Multis/Boats/BaseBoatDeed.cs | 18 +- .../Scripts/Multis/Boats/BaseDockedBoat.cs | 24 +- .../Multis/Boats/ConfirmDryDockGump.cs | 4 +- Projects/Scripts/Multis/Boats/Hold.cs | 14 +- Projects/Scripts/Multis/Boats/Plank.cs | 46 +- .../Scripts/Multis/Boats/RenameBoatPrompt.cs | 2 +- Projects/Scripts/Multis/Boats/Strandedness.cs | 38 +- Projects/Scripts/Multis/Boats/TillerMan.cs | 14 +- Projects/Scripts/Multis/Camps/BaseCamp.cs | 14 +- Projects/Scripts/Multis/Camps/BrigandCamp.cs | 40 +- .../Scripts/Multis/Camps/LizardmenCamp.cs | 40 +- Projects/Scripts/Multis/Camps/OrcCamp.cs | 50 +- Projects/Scripts/Multis/Camps/RatCamp.cs | 50 +- .../Scripts/Multis/ComponentVerification.cs | 34 +- Projects/Scripts/Multis/ContestHouses.cs | 47 +- Projects/Scripts/Multis/Deeds.cs | 107 +- Projects/Scripts/Multis/DynamicDecay.cs | 6 +- Projects/Scripts/Multis/HouseFoundation.cs | 368 +- Projects/Scripts/Multis/HousePlacement.cs | 318 +- Projects/Scripts/Multis/HousePlacementTool.cs | 402 +- Projects/Scripts/Multis/HouseSign.cs | 30 +- Projects/Scripts/Multis/HouseTeleporter.cs | 38 +- Projects/Scripts/Multis/Houses.cs | 30 +- Projects/Scripts/Multis/MovingCrate.cs | 20 +- Projects/Scripts/Multis/PreviewHouse.cs | 16 +- Projects/Scripts/Regions/BaseRegion.cs | 67 +- Projects/Scripts/Regions/DungeonRegion.cs | 2 +- Projects/Scripts/Regions/GuardedRegion.cs | 18 +- Projects/Scripts/Regions/HouseRegion.cs | 2 +- Projects/Scripts/Regions/NoHousingRegion.cs | 2 +- .../Regions/Spawning/SpawnDefinition.cs | 90 +- .../Scripts/Regions/Spawning/SpawnEntry.cs | 26 +- Projects/Scripts/Scripts.csproj | 46 +- Projects/Scripts/Skills/Anatomy.cs | 4 +- Projects/Scripts/Skills/AnimalLore.cs | 35 +- Projects/Scripts/Skills/AnimalTaming.cs | 16 +- Projects/Scripts/Skills/ArmsLore.cs | 29 +- Projects/Scripts/Skills/Begging.cs | 10 +- Projects/Scripts/Skills/DetectHidden.cs | 6 +- Projects/Scripts/Skills/Discordance.cs | 20 +- Projects/Scripts/Skills/EvalInt.cs | 4 +- Projects/Scripts/Skills/ForensicEval.cs | 22 +- Projects/Scripts/Skills/Hiding.cs | 8 +- Projects/Scripts/Skills/Inscribe.cs | 6 +- Projects/Scripts/Skills/ItemIdentification.cs | 4 +- Projects/Scripts/Skills/Meditation.cs | 4 +- Projects/Scripts/Skills/Peacemaking.cs | 8 +- Projects/Scripts/Skills/Poisoning.cs | 13 +- Projects/Scripts/Skills/Provocation.cs | 14 +- Projects/Scripts/Skills/RemoveTrap.cs | 6 +- Projects/Scripts/Skills/Snooping.cs | 4 +- Projects/Scripts/Skills/SpiritSpeak.cs | 14 +- Projects/Scripts/Skills/Stealing.cs | 36 +- Projects/Scripts/Skills/Stealth.cs | 34 +- Projects/Scripts/Skills/TasteID.cs | 4 +- Projects/Scripts/Skills/Tracking.cs | 35 +- .../SpecialSystems/Engines/GiftGiving.cs | 6 +- .../SpecialSystems/Engines/PreventInaccess.cs | 4 +- .../SpecialSystems/Engines/TestCenter.cs | 83 +- .../SpecialSystems/Items/Stones/GMStone.cs | 56 - .../Items/Stones/GamblingStone.cs | 8 +- Projects/Scripts/Spells/Base/MagerySpell.cs | 4 +- Projects/Scripts/Spells/Base/SpecialMove.cs | 14 +- Projects/Scripts/Spells/Base/Spell.cs | 82 +- Projects/Scripts/Spells/Base/SpellHelper.cs | 117 +- Projects/Scripts/Spells/Base/SpellInfo.cs | 16 +- Projects/Scripts/Spells/Base/SpellRegistry.cs | 14 +- Projects/Scripts/Spells/Bushido/Confidence.cs | 15 +- .../Scripts/Spells/Bushido/CounterAttack.cs | 9 +- Projects/Scripts/Spells/Bushido/Evasion.cs | 37 +- .../Spells/Bushido/HonorableExecution.cs | 10 +- .../Scripts/Spells/Bushido/SamuraiMove.cs | 2 +- .../Scripts/Spells/Bushido/SamuraiSpell.cs | 8 +- .../Scripts/Spells/Chivalry/CleanseByFire.cs | 5 +- .../Scripts/Spells/Chivalry/CloseWounds.cs | 5 +- .../Spells/Chivalry/ConsecrateWeapon.cs | 9 +- .../Scripts/Spells/Chivalry/DispelEvil.cs | 7 +- .../Scripts/Spells/Chivalry/DivineFury.cs | 7 +- .../Scripts/Spells/Chivalry/EnemyOfOne.cs | 7 +- Projects/Scripts/Spells/Chivalry/HolyLight.cs | 5 +- .../Scripts/Spells/Chivalry/NobleSacrifice.cs | 5 +- .../Scripts/Spells/Chivalry/PaladinSpell.cs | 10 +- .../Scripts/Spells/Chivalry/RemoveCurse.cs | 5 +- .../Scripts/Spells/Chivalry/SacredJourney.cs | 14 +- .../Scripts/Spells/Eighth/AirElemental.cs | 5 +- .../Scripts/Spells/Eighth/EarthElemental.cs | 5 +- Projects/Scripts/Spells/Eighth/Earthquake.cs | 5 +- .../Scripts/Spells/Eighth/EnergyVortex.cs | 5 +- .../Scripts/Spells/Eighth/FireElemental.cs | 5 +- .../Scripts/Spells/Eighth/Resurrection.cs | 5 +- .../Scripts/Spells/Eighth/SummonDaemon.cs | 5 +- .../Scripts/Spells/Eighth/WaterElemental.cs | 5 +- Projects/Scripts/Spells/Fifth/BladeSpirits.cs | 5 +- Projects/Scripts/Spells/Fifth/DispelField.cs | 5 +- Projects/Scripts/Spells/Fifth/Incognito.cs | 13 +- Projects/Scripts/Spells/Fifth/MagicReflect.cs | 9 +- Projects/Scripts/Spells/Fifth/MindBlast.cs | 5 +- Projects/Scripts/Spells/Fifth/Paralyze.cs | 7 +- Projects/Scripts/Spells/Fifth/PoisonField.cs | 32 +- .../Scripts/Spells/Fifth/SummonCreature.cs | 9 +- Projects/Scripts/Spells/First/Clumsy.cs | 5 +- Projects/Scripts/Spells/First/CreateFood.cs | 11 +- Projects/Scripts/Spells/First/Feeblemind.cs | 5 +- Projects/Scripts/Spells/First/Heal.cs | 7 +- Projects/Scripts/Spells/First/MagicArrow.cs | 5 +- Projects/Scripts/Spells/First/NightSight.cs | 9 +- .../Scripts/Spells/First/ReactiveArmor.cs | 9 +- Projects/Scripts/Spells/First/Weaken.cs | 5 +- Projects/Scripts/Spells/Fourth/ArchCure.cs | 5 +- .../Scripts/Spells/Fourth/ArchProtection.cs | 9 +- Projects/Scripts/Spells/Fourth/Curse.cs | 10 +- Projects/Scripts/Spells/Fourth/FireField.cs | 40 +- Projects/Scripts/Spells/Fourth/GreaterHeal.cs | 7 +- Projects/Scripts/Spells/Fourth/Lightning.cs | 5 +- Projects/Scripts/Spells/Fourth/ManaDrain.cs | 7 +- Projects/Scripts/Spells/Fourth/Recall.cs | 16 +- Projects/Scripts/Spells/Initializer.cs | 26 +- .../Spells/Mysticism/AnimatedWeaponSpell.cs | 7 +- .../Spells/Mysticism/EagleStrikeSpell.cs | 5 +- .../Spells/Mysticism/HailStormSpell.cs | 5 +- .../Scripts/Spells/Mysticism/MysticSpell.cs | 4 +- .../Spells/Mysticism/NetherCycloneSpell.cs | 5 +- .../Spells/Mysticism/SpellPlagueSpell.cs | 13 +- .../Spells/Mysticism/StoneFormSpell.cs | 9 +- .../Spells/Necromancy/AnimateDeadSpell.cs | 25 +- .../Spells/Necromancy/BloodOathSpell.cs | 19 +- .../Scripts/Spells/Necromancy/CorpseSkin.cs | 13 +- .../Scripts/Spells/Necromancy/CurseWeapon.cs | 11 +- .../Scripts/Spells/Necromancy/EvilOmen.cs | 7 +- .../Scripts/Spells/Necromancy/Exorcism.cs | 19 +- .../Spells/Necromancy/HorrificBeast.cs | 5 +- .../Scripts/Spells/Necromancy/LichForm.cs | 5 +- Projects/Scripts/Spells/Necromancy/MindRot.cs | 13 +- .../Spells/Necromancy/NecromancerSpell.cs | 13 +- .../Scripts/Spells/Necromancy/PainSpike.cs | 17 +- .../Scripts/Spells/Necromancy/PoisonStrike.cs | 9 +- .../Scripts/Spells/Necromancy/Strangle.cs | 24 +- .../Spells/Necromancy/SummonFamiliar.cs | 25 +- .../Spells/Necromancy/TransformationSpell.cs | 2 +- .../Spells/Necromancy/VampiricEmbrace.cs | 5 +- .../Spells/Necromancy/VengefulSpirit.cs | 5 +- Projects/Scripts/Spells/Necromancy/Wither.cs | 9 +- .../Scripts/Spells/Necromancy/WraithForm.cs | 5 +- .../Scripts/Spells/Ninjitsu/AnimalForm.cs | 68 +- Projects/Scripts/Spells/Ninjitsu/Backstab.cs | 6 +- .../Scripts/Spells/Ninjitsu/DeathStrike.cs | 12 +- Projects/Scripts/Spells/Ninjitsu/KiAttack.cs | 4 +- .../Scripts/Spells/Ninjitsu/MirrorImage.cs | 8 +- Projects/Scripts/Spells/Ninjitsu/NinjaMove.cs | 2 +- .../Scripts/Spells/Ninjitsu/NinjaSpell.cs | 8 +- .../Scripts/Spells/Ninjitsu/ShadowJump.cs | 5 +- .../Scripts/Spells/Ninjitsu/SurpriseAttack.cs | 10 +- Projects/Scripts/Spells/Reagent.cs | 2 +- Projects/Scripts/Spells/Second/Agility.cs | 5 +- Projects/Scripts/Spells/Second/Cunning.cs | 5 +- Projects/Scripts/Spells/Second/Cure.cs | 5 +- Projects/Scripts/Spells/Second/Harm.cs | 5 +- Projects/Scripts/Spells/Second/MagicTrap.cs | 7 +- Projects/Scripts/Spells/Second/Protection.cs | 15 +- Projects/Scripts/Spells/Second/RemoveTrap.cs | 7 +- Projects/Scripts/Spells/Second/Strength.cs | 5 +- .../Scripts/Spells/Seventh/ChainLightning.cs | 7 +- .../Scripts/Spells/Seventh/EnergyField.cs | 13 +- .../Scripts/Spells/Seventh/FlameStrike.cs | 5 +- Projects/Scripts/Spells/Seventh/GateTravel.cs | 14 +- .../Scripts/Spells/Seventh/ManaVampire.cs | 5 +- Projects/Scripts/Spells/Seventh/MassDispel.cs | 5 +- .../Scripts/Spells/Seventh/MeteorSwarm.cs | 7 +- Projects/Scripts/Spells/Seventh/Polymorph.cs | 15 +- Projects/Scripts/Spells/Sixth/Dispel.cs | 5 +- Projects/Scripts/Spells/Sixth/EnergyBolt.cs | 5 +- Projects/Scripts/Spells/Sixth/Explosion.cs | 12 +- Projects/Scripts/Spells/Sixth/Invisibility.cs | 11 +- Projects/Scripts/Spells/Sixth/Mark.cs | 5 +- Projects/Scripts/Spells/Sixth/MassCurse.cs | 5 +- .../Scripts/Spells/Sixth/ParalyzeField.cs | 21 +- Projects/Scripts/Spells/Sixth/Reveal.cs | 9 +- .../Spells/Spellweaving/ArcaneCircle.cs | 15 +- .../Scripts/Spells/Spellweaving/ArcaneForm.cs | 2 +- .../Spells/Spellweaving/ArcaneSummon.cs | 2 +- .../Spells/Spellweaving/ArcanistSpell.cs | 8 +- .../Spells/Spellweaving/AttuneWeapon.cs | 12 +- .../Spells/Spellweaving/EssenceOfWind.cs | 14 +- .../Spells/Spellweaving/EtherealVoyage.cs | 9 +- .../Scripts/Spells/Spellweaving/GiftOfLife.cs | 14 +- .../Spells/Spellweaving/GiftOfRenewal.cs | 22 +- .../Spells/Spellweaving/ImmolatingWeapon.cs | 17 +- .../Spells/Spellweaving/Items/ArcaneFocus.cs | 2 +- .../Spellweaving/Items/TransientItem.cs | 5 +- .../Spellweaving/Mobiles/ArcaneFiend.cs | 2 +- .../Scripts/Spells/Spellweaving/NatureFury.cs | 7 +- .../Scripts/Spells/Spellweaving/ReaperForm.cs | 2 +- .../Scripts/Spells/Spellweaving/SummonFey.cs | 5 +- .../Spells/Spellweaving/SummonFiend.cs | 5 +- .../Spells/Spellweaving/Thunderstorm.cs | 7 +- .../Spells/Spellweaving/WordOfDeath.cs | 2 +- .../Scripts/Spells/Targeting/IRecallSpell.cs | 2 +- .../Scripts/Spells/Targeting/ISpellTarget.cs | 2 +- .../Spells/Targeting/RecallSpellTarget.cs | 4 +- .../Spells/Targeting/SpellTargetItem.cs | 2 +- .../Spells/Targeting/SpellTargetMobile.cs | 2 +- .../Spells/Targeting/SpellTargetPoint3D.cs | 2 +- Projects/Scripts/Spells/Third/Bless.cs | 5 +- Projects/Scripts/Spells/Third/Fireball.cs | 5 +- Projects/Scripts/Spells/Third/MagicLock.cs | 5 +- Projects/Scripts/Spells/Third/Poison.cs | 13 +- Projects/Scripts/Spells/Third/Telekinesis.cs | 5 +- Projects/Scripts/Spells/Third/Teleport.cs | 5 +- Projects/Scripts/Spells/Third/Unlock.cs | 5 +- Projects/Scripts/Spells/Third/WallOfStone.cs | 39 +- Projects/Scripts/Spells/UnsummonTimer.cs | 2 +- Projects/Scripts/Targets/BladedItemTarget.cs | 6 +- Projects/Scripts/Targets/MoveTarget.cs | 2 +- Projects/Server/AggressorInfo.cs | 6 +- Projects/Server/AssemblyHandler.cs | 43 +- Projects/Server/Attributes.cs | 25 +- Projects/Server/BaseVendor.cs | 30 +- Projects/Server/Body.cs | 18 +- Projects/Server/Buffers/BufferReader.cs | 33 +- .../Server/Buffers/BufferReaderExtensions.cs | 7 +- Projects/Server/Buffers/MemoryPoolSlab.cs | 1 + .../Server/Buffers/MemoryPoolThrowHelper.cs | 19 +- Projects/Server/Buffers/SlabMemoryPool.cs | 22 +- Projects/Server/Buffers/SpanWriter.cs | 8 +- Projects/Server/CityInfo.cs | 2 +- Projects/Server/ClientVersion.cs | 32 +- Projects/Server/Collections/ArraySet.cs | 10 +- Projects/Server/Commands.cs | 40 +- Projects/Server/Configuration.cs | 21 +- Projects/Server/ContextMenus/ContextMenu.cs | 14 +- .../Server/ContextMenus/ContextMenuEntry.cs | 12 +- .../Server/ContextMenus/OpenBackpackEntry.cs | 2 +- .../Server/ContextMenus/PaperdollEntry.cs | 2 +- Projects/Server/Diagnostics/BaseProfile.cs | 18 +- Projects/Server/Diagnostics/GumpProfile.cs | 2 +- Projects/Server/Diagnostics/PacketProfile.cs | 6 +- Projects/Server/Diagnostics/TargetProfile.cs | 2 +- Projects/Server/Diagnostics/TimerProfile.cs | 8 +- Projects/Server/Effects.cs | 55 +- Projects/Server/Events/AccountLoginEvent.cs | 10 +- .../Server/Events/AggressiveActionEvent.cs | 8 +- .../Server/Events/CharacterCreatedEvent.cs | 45 +- Projects/Server/Events/CreateGuildEvent.cs | 4 +- Projects/Server/Events/EventSink.cs | 42 +- Projects/Server/Events/FastwalkEvent.cs | 4 +- Projects/Server/Events/GameLoginEvent.cs | 10 +- Projects/Server/Events/MovementEvent.cs | 8 +- Projects/Server/Events/ServerCrashedEvent.cs | 4 +- Projects/Server/Events/ServerListEvent.cs | 8 +- .../Server/Events/SocketConnectionEvent.cs | 4 +- Projects/Server/Events/SpeechEvent.cs | 16 +- Projects/Server/ExpansionInfo.cs | 66 +- Projects/Server/Geometry.cs | 58 +- Projects/Server/Guild.cs | 45 +- Projects/Server/HuePicker.cs | 6 +- Projects/Server/IAccount.cs | 20 +- Projects/Server/IEntity.cs | 16 +- Projects/Server/Insensitive.cs | 2 +- Projects/Server/Interfaces.cs | 46 +- Projects/Server/Item.cs | 1133 ++-- Projects/Server/ItemBounds.cs | 14 +- Projects/Server/Items/BaseMulti.cs | 12 +- Projects/Server/Items/Container.cs | 612 ++- Projects/Server/Items/Containers.cs | 30 +- Projects/Server/Items/SecureTradeContainer.cs | 9 +- Projects/Server/Items/VirtualCheck.cs | 114 +- Projects/Server/Items/VirtualHair.cs | 50 +- .../Server/JsonConverters/Point3dConverter.cs | 4 +- Projects/Server/KeywordList.cs | 18 +- Projects/Server/Layer.cs | 2 +- Projects/Server/LightType.cs | 2 +- Projects/Server/Main.cs | 137 +- Projects/Server/Map.cs | 521 +- Projects/Server/Menus/IMenu.cs | 6 +- Projects/Server/Menus/ItemListMenu.cs | 23 +- Projects/Server/Menus/QuestionMenu.cs | 17 +- Projects/Server/Mobile.cs | 1916 ++++--- Projects/Server/Mobiles/IMount.cs | 34 + Projects/Server/Mobiles/IVendor.cs | 33 + Projects/Server/Movement.cs | 4 +- Projects/Server/MultiData.cs | 527 +- Projects/Server/NativeReader.cs | 16 +- .../Server/Network/EncodedPacketHandler.cs | 6 +- Projects/Server/Network/EncodedReader.cs | 13 +- Projects/Server/Network/MessagePumpService.cs | 7 +- Projects/Server/Network/NetState.cs | 61 +- .../{Compression.cs => NetworkCompression.cs} | 134 +- Projects/Server/Network/Packet.cs | 52 +- Projects/Server/Network/PacketHandler.cs | 10 +- Projects/Server/Network/PacketHandlers.cs | 877 ++-- Projects/Server/Network/PacketReader.cs | 64 +- Projects/Server/Network/PacketWriter.cs | 22 +- Projects/Server/Network/Packets.cs | 2438 +++++---- .../Server/Network/ServerConnectionHandler.cs | 19 +- Projects/Server/Network/ServerStartup.cs | 2 +- .../Server/Network/StaticPacketHandlers.cs | 40 +- Projects/Server/Network/TcpServer.cs | 22 +- Projects/Server/Notoriety.cs | 4 +- Projects/Server/ObjectPropertyList.cs | 44 +- Projects/Server/Party.cs | 4 +- .../Server/Persistence/BinaryMemoryWriter.cs | 8 +- .../Server/Persistence/DualSaveStrategy.cs | 7 +- .../Server/Persistence/DynamicSaveStrategy.cs | 87 +- Projects/Server/Persistence/FileOperations.cs | 11 +- Projects/Server/Persistence/FileQueue.cs | 53 +- .../Persistence/ParallelSaveStrategy.cs | 102 +- Projects/Server/Persistence/Persistence.cs | 12 +- .../Server/Persistence/QueuedMemoryWriter.cs | 32 +- Projects/Server/Persistence/SaveStrategy.cs | 6 +- ...riter.cs => SequentialFileWriterStream.cs} | 11 +- .../Persistence/StandardSaveStrategy.cs | 60 +- Projects/Server/Point3DList.cs | 18 +- Projects/Server/Poison.cs | 24 +- Projects/Server/Prompt.cs | 4 +- Projects/Server/QuestArrow.cs | 12 +- Projects/Server/Race.cs | 32 +- Projects/Server/Region.cs | 255 +- Projects/Server/Sector.cs | 27 +- Projects/Server/SecureTrade.cs | 83 +- Projects/Server/Serial.cs | 12 +- Projects/Server/Serialization/AsyncWriter.cs | 102 +- .../Server/Serialization/BinaryFileReader.cs | 47 +- .../Server/Serialization/BinaryFileWriter.cs | 72 +- Projects/Server/Serialization/BufferWriter.cs | 72 +- .../Server/Serialization/IGenericReader.cs | 2 +- .../Server/Serialization/IGenericWriter.cs | 2 +- .../Server/Serialization/ISerializable.cs | 6 +- Projects/Server/Server.csproj | 46 +- Projects/Server/Skills.cs | 230 +- Projects/Server/Targeting/LandTarget.cs | 4 +- Projects/Server/Targeting/MultiTarget.cs | 7 +- Projects/Server/Targeting/StaticTarget.cs | 4 +- Projects/Server/Targeting/Target.cs | 22 +- Projects/Server/Targeting/TargetCancelType.cs | 2 +- Projects/Server/Targeting/TargetFlags.cs | 2 +- Projects/Server/TileData.cs | 62 +- Projects/Server/TileList.cs | 20 +- Projects/Server/TileMatrix.cs | 115 +- Projects/Server/TileMatrixPatch.cs | 70 +- Projects/Server/Timer.cs | 88 +- Projects/Server/Utilities/ActivatorUtil.cs | 32 +- Projects/Server/Utilities/DRng64.cs | 36 +- Projects/Server/Utilities/Random.cs | 2 +- Projects/Server/Utilities/RefPool.cs | 30 +- Projects/Server/Utilities/Utility.cs | 315 +- .../Server/Utilities/Xoshiro256PlusPlus.cs | 79 +- Projects/Server/VirtueInfo.cs | 38 +- Projects/Server/World.cs | 319 +- README.md | 13 +- Rules.ruleset | 178 + clean.cmd => Tools/clean.cmd | 2 + clean.sh => Tools/clean.sh | 2 + .../publish-linux-debug.cmd | 0 .../publish-linux-debug.sh | 0 publish-linux.cmd => Tools/publish-linux.cmd | 0 publish-linux.sh => Tools/publish-linux.sh | 0 .../publish-osx-debug.cmd | 0 .../publish-osx-debug.sh | 0 publish-osx.cmd => Tools/publish-osx.cmd | 0 publish-osx.sh => Tools/publish-osx.sh | 0 .../publish-windows-debug.cmd | 0 .../publish-windows-debug.sh | 0 .../publish-windows.cmd | 0 .../publish-windows.sh | 0 stylecop.json | 11 + 1725 files changed, 33831 insertions(+), 38046 deletions(-) create mode 100644 Projects/Scripts/Engines/Harvest/Core/FurnitureAttribute.cs create mode 100644 Projects/Scripts/Engines/Harvest/Core/IChoppable..cs delete mode 100644 Projects/Scripts/SpecialSystems/Items/Stones/GMStone.cs create mode 100644 Projects/Server/Mobiles/IMount.cs create mode 100644 Projects/Server/Mobiles/IVendor.cs rename Projects/Server/Network/{Compression.cs => NetworkCompression.cs} (71%) rename Projects/Server/Persistence/{SequentialFileWriter.cs => SequentialFileWriterStream.cs} (88%) create mode 100644 Rules.ruleset rename clean.cmd => Tools/clean.cmd (96%) rename clean.sh => Tools/clean.sh (98%) rename publish-linux-debug.cmd => Tools/publish-linux-debug.cmd (100%) rename publish-linux-debug.sh => Tools/publish-linux-debug.sh (100%) rename publish-linux.cmd => Tools/publish-linux.cmd (100%) rename publish-linux.sh => Tools/publish-linux.sh (100%) rename publish-osx-debug.cmd => Tools/publish-osx-debug.cmd (100%) rename publish-osx-debug.sh => Tools/publish-osx-debug.sh (100%) rename publish-osx.cmd => Tools/publish-osx.cmd (100%) rename publish-osx.sh => Tools/publish-osx.sh (100%) rename publish-windows-debug.cmd => Tools/publish-windows-debug.cmd (100%) rename publish-windows-debug.sh => Tools/publish-windows-debug.sh (100%) rename publish-windows.cmd => Tools/publish-windows.cmd (100%) rename publish-windows.sh => Tools/publish-windows.sh (100%) create mode 100644 stylecop.json diff --git a/ModernUO.sln b/ModernUO.sln index 056240d46..8c149d643 100644 --- a/ModernUO.sln +++ b/ModernUO.sln @@ -8,14 +8,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scripts", "Projects\Scripts EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Analyze|Any CPU = Analyze|Any CPU Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5E93BB35-3661-4822-9A8A-859726BAD87F}.Analyze|Any CPU.ActiveCfg = Analyze|Any CPU + {5E93BB35-3661-4822-9A8A-859726BAD87F}.Analyze|Any CPU.Build.0 = Analyze|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Release|Any CPU.ActiveCfg = Release|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Release|Any CPU.Build.0 = Release|Any CPU + {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Analyze|Any CPU.ActiveCfg = Analyze|Any CPU + {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Analyze|Any CPU.Build.0 = Analyze|Any CPU {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/Projects/Scripts/Accounting/Account.cs b/Projects/Scripts/Accounting/Account.cs index 635782b9b..622d8d3cc 100644 --- a/Projects/Scripts/Accounting/Account.cs +++ b/Projects/Scripts/Accounting/Account.cs @@ -13,9 +13,9 @@ namespace Server.Accounting { public class Account : IAccount, IComparable { - public static readonly TimeSpan YoungDuration = TimeSpan.FromHours( 40.0 ); + public static readonly TimeSpan YoungDuration = TimeSpan.FromHours(40.0); - public static readonly TimeSpan InactiveDuration = TimeSpan.FromDays( 180.0 ); + public static readonly TimeSpan InactiveDuration = TimeSpan.FromDays(180.0); public static readonly TimeSpan EmptyInactiveDuration = TimeSpan.FromDays(30.0); @@ -23,23 +23,23 @@ namespace Server.Accounting private TimeSpan m_TotalGameTime; private List m_Comments; private List m_Tags; - private Mobile[] m_Mobiles; + private readonly Mobile[] m_Mobiles; /// /// Deletes the account, all characters of the account, and all houses of those characters /// public void Delete() { - for ( int i = 0; i < Length; ++i ) + for (int i = 0; i < Length; ++i) { Mobile m = this[i]; - if ( m == null ) + if (m == null) continue; - List list = BaseHouse.GetHouses( m ); + List list = BaseHouse.GetHouses(m); - for ( int j = 0; j < list.Count; ++j ) + for (int j = 0; j < list.Count; ++j) list[j].Delete(); m.Delete(); @@ -48,10 +48,10 @@ namespace Server.Accounting m_Mobiles[i] = null; } - if ( LoginIPs.Length != 0 && AccountHandler.IPTable.ContainsKey( LoginIPs[0] ) ) + if (LoginIPs.Length != 0 && AccountHandler.IPTable.ContainsKey(LoginIPs[0])) --AccountHandler.IPTable[LoginIPs[0]]; - Accounts.Remove( Username ); + Accounts.Remove(Username); } /// @@ -125,22 +125,22 @@ namespace Server.Accounting { get { - bool isBanned = GetFlag( 0 ); + bool isBanned = GetFlag(0); - if ( !isBanned ) + if (!isBanned) return false; - if ( GetBanTags( out DateTime banTime, out TimeSpan banDuration ) ) - if ( banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= banTime + banDuration ) + if (GetBanTags(out DateTime banTime, out TimeSpan banDuration)) + if (banDuration != TimeSpan.MaxValue && DateTime.UtcNow >= banTime + banDuration) { - SetUnspecifiedBan( null ); // clear + SetUnspecifiedBan(null); // clear Banned = false; return false; } return true; } - set => SetFlag( 0, value ); + set => SetFlag(0, value); } /// @@ -148,10 +148,10 @@ namespace Server.Accounting /// public bool Young { - get => !GetFlag( 1 ); + get => !GetFlag(1); set { - SetFlag( 1, !value ); + SetFlag(1, !value); m_YoungTimer?.Stop(); m_YoungTimer = null; @@ -175,7 +175,7 @@ namespace Server.Accounting { get { - if ( AccessLevel != AccessLevel.Player ) + if (AccessLevel != AccessLevel.Player) return false; TimeSpan inactiveLength = DateTime.UtcNow - LastLogin; @@ -192,9 +192,9 @@ namespace Server.Accounting { get { - for ( int i = 0; i < m_Mobiles.Length; i++ ) - if ( m_Mobiles[i] is PlayerMobile m && m.NetState != null ) - return m_TotalGameTime + ( DateTime.UtcNow - m.SessionStart ); + for (int i = 0; i < m_Mobiles.Length; i++) + if (m_Mobiles[i] is PlayerMobile m && m.NetState != null) + return m_TotalGameTime + (DateTime.UtcNow - m.SessionStart); return m_TotalGameTime; } @@ -204,19 +204,19 @@ namespace Server.Accounting /// Gets the value of a specific flag in the Flags bitfield. /// /// The zero-based flag index. - public bool GetFlag( int index ) => ( Flags & 1 << index ) != 0; + public bool GetFlag(int index) => (Flags & 1 << index) != 0; /// /// Sets the value of a specific flag in the Flags bitfield. /// /// The zero-based flag index. /// The value to set. - public void SetFlag( int index, bool value ) + public void SetFlag(int index, bool value) { - if ( value ) + if (value) Flags |= 1 << index; else - Flags &= ~( 1 << index ); + Flags &= ~(1 << index); } /// @@ -224,26 +224,26 @@ namespace Server.Accounting /// /// New tag name. /// New tag value. - public void AddTag( string name, string value ) + public void AddTag(string name, string value) { - Tags.Add( new AccountTag( name, value ) ); + Tags.Add(new AccountTag(name, value)); } /// /// Removes all tags with the specified name from this account. /// /// Tag name to remove. - public void RemoveTag( string name ) + public void RemoveTag(string name) { - for ( int i = Tags.Count - 1; i >= 0; --i ) + for (int i = Tags.Count - 1; i >= 0; --i) { - if ( i >= Tags.Count ) + if (i >= Tags.Count) continue; AccountTag tag = Tags[i]; - if ( tag.Name == name ) - Tags.RemoveAt( i ); + if (tag.Name == name) + Tags.RemoveAt(i); } } @@ -252,76 +252,76 @@ namespace Server.Accounting /// /// Tag name. /// Tag value. - public void SetTag( string name, string value ) + public void SetTag(string name, string value) { - for ( int i = 0; i < Tags.Count; ++i ) + for (int i = 0; i < Tags.Count; ++i) { AccountTag tag = Tags[i]; - if ( tag.Name == name ) + if (tag.Name == name) { tag.Value = value; return; } } - AddTag( name, value ); + AddTag(name, value); } /// /// Gets the value of a tag -or- null if there are no tags with the specified name. /// /// Name of the desired tag value. - public string GetTag( string name ) + public string GetTag(string name) { - for ( int i = 0; i < Tags.Count; ++i ) + for (int i = 0; i < Tags.Count; ++i) { AccountTag tag = Tags[i]; - if ( tag.Name == name ) + if (tag.Name == name) return tag.Value; } return null; } - public void SetUnspecifiedBan( Mobile from ) + public void SetUnspecifiedBan(Mobile from) { - SetBanTags( from, DateTime.MinValue, TimeSpan.Zero ); + SetBanTags(from, DateTime.MinValue, TimeSpan.Zero); } - public void SetBanTags( Mobile from, DateTime banTime, TimeSpan banDuration ) + public void SetBanTags(Mobile from, DateTime banTime, TimeSpan banDuration) { - if ( from == null ) - RemoveTag( "BanDealer" ); + if (from == null) + RemoveTag("BanDealer"); else - SetTag( "BanDealer", from.ToString() ); + SetTag("BanDealer", from.ToString()); - if ( banTime == DateTime.MinValue ) - RemoveTag( "BanTime" ); + if (banTime == DateTime.MinValue) + RemoveTag("BanTime"); else - SetTag( "BanTime", XmlConvert.ToString( banTime, XmlDateTimeSerializationMode.Utc ) ); + SetTag("BanTime", XmlConvert.ToString(banTime, XmlDateTimeSerializationMode.Utc)); - if ( banDuration == TimeSpan.Zero ) - RemoveTag( "BanDuration" ); + if (banDuration == TimeSpan.Zero) + RemoveTag("BanDuration"); else - SetTag( "BanDuration", banDuration.ToString() ); + SetTag("BanDuration", banDuration.ToString()); } - public bool GetBanTags( out DateTime banTime, out TimeSpan banDuration ) + public bool GetBanTags(out DateTime banTime, out TimeSpan banDuration) { - string tagTime = GetTag( "BanTime" ); - string tagDuration = GetTag( "BanDuration" ); + string tagTime = GetTag("BanTime"); + string tagDuration = GetTag("BanDuration"); - if ( tagTime != null ) - banTime = Utility.GetXMLDateTime( tagTime, DateTime.MinValue ); + if (tagTime != null) + banTime = Utility.GetXMLDateTime(tagTime, DateTime.MinValue); else banTime = DateTime.MinValue; - if ( tagDuration == "Infinite" ) + if (tagDuration == "Infinite") banDuration = TimeSpan.MaxValue; - else if ( tagDuration != null ) - banDuration = Utility.ToTimeSpan( tagDuration ); + else if (tagDuration != null) + banDuration = Utility.ToTimeSpan(tagDuration); else banDuration = TimeSpan.Zero; @@ -332,88 +332,88 @@ namespace Server.Accounting private static SHA1CryptoServiceProvider m_SHA1HashProvider; private static byte[] m_HashBuffer; - public static string HashMD5( string phrase ) + public static string HashMD5(string phrase) { - if ( m_MD5HashProvider == null ) + if (m_MD5HashProvider == null) m_MD5HashProvider = new MD5CryptoServiceProvider(); - if ( m_HashBuffer == null ) + if (m_HashBuffer == null) m_HashBuffer = new byte[256]; - int length = Encoding.ASCII.GetBytes( phrase, 0, phrase.Length > 256 ? 256 : phrase.Length, m_HashBuffer, 0 ); - byte[] hashed = m_MD5HashProvider.ComputeHash( m_HashBuffer, 0, length ); + int length = Encoding.ASCII.GetBytes(phrase, 0, phrase.Length > 256 ? 256 : phrase.Length, m_HashBuffer, 0); + byte[] hashed = m_MD5HashProvider.ComputeHash(m_HashBuffer, 0, length); - return BitConverter.ToString( hashed ); + return BitConverter.ToString(hashed); } - public static string HashSHA1( string phrase ) + public static string HashSHA1(string phrase) { - if ( m_SHA1HashProvider == null ) + if (m_SHA1HashProvider == null) m_SHA1HashProvider = new SHA1CryptoServiceProvider(); - if ( m_HashBuffer == null ) + if (m_HashBuffer == null) m_HashBuffer = new byte[256]; - int length = Encoding.ASCII.GetBytes( phrase, 0, phrase.Length > 256 ? 256 : phrase.Length, m_HashBuffer, 0 ); - byte[] hashed = m_SHA1HashProvider.ComputeHash( m_HashBuffer, 0, length ); + int length = Encoding.ASCII.GetBytes(phrase, 0, phrase.Length > 256 ? 256 : phrase.Length, m_HashBuffer, 0); + byte[] hashed = m_SHA1HashProvider.ComputeHash(m_HashBuffer, 0, length); - return BitConverter.ToString( hashed ); + return BitConverter.ToString(hashed); } - public void SetPassword( string plainPassword ) + public void SetPassword(string plainPassword) { - switch ( AccountHandler.ProtectPasswords ) + switch (AccountHandler.ProtectPasswords) { case PasswordProtection.None: - { - PlainPassword = plainPassword; - CryptPassword = null; - NewCryptPassword = null; + { + PlainPassword = plainPassword; + CryptPassword = null; + NewCryptPassword = null; - break; - } + break; + } case PasswordProtection.Crypt: - { - PlainPassword = null; - CryptPassword = HashMD5( plainPassword ); - NewCryptPassword = null; + { + PlainPassword = null; + CryptPassword = HashMD5(plainPassword); + NewCryptPassword = null; - break; - } + break; + } default: // PasswordProtection.NewCrypt - { - PlainPassword = null; - CryptPassword = null; - NewCryptPassword = HashSHA1( Username + plainPassword ); + { + PlainPassword = null; + CryptPassword = null; + NewCryptPassword = HashSHA1(Username + plainPassword); - break; - } + break; + } } } - public bool CheckPassword( string plainPassword ) + public bool CheckPassword(string plainPassword) { bool ok; PasswordProtection curProt; - if ( PlainPassword != null ) + if (PlainPassword != null) { ok = PlainPassword == plainPassword; curProt = PasswordProtection.None; } - else if ( CryptPassword != null ) + else if (CryptPassword != null) { - ok = CryptPassword == HashMD5( plainPassword ); + ok = CryptPassword == HashMD5(plainPassword); curProt = PasswordProtection.Crypt; } else { - ok = NewCryptPassword == HashSHA1( Username + plainPassword ); + ok = NewCryptPassword == HashSHA1(Username + plainPassword); curProt = PasswordProtection.NewCrypt; } - if ( ok && curProt != AccountHandler.ProtectPasswords ) - SetPassword( plainPassword ); + if (ok && curProt != AccountHandler.ProtectPasswords) + SetPassword(plainPassword); return ok; } @@ -429,28 +429,28 @@ namespace Server.Accounting private static void EventSink_Connected(Mobile m) { - if ( !(m.Account is Account acc) ) + if (!(m.Account is Account acc)) return; - if ( acc.Young && acc.m_YoungTimer == null ) + if (acc.Young && acc.m_YoungTimer == null) { - acc.m_YoungTimer = new YoungTimer( acc ); + acc.m_YoungTimer = new YoungTimer(acc); acc.m_YoungTimer.Start(); } } private static void EventSink_Disconnected(Mobile m) { - if ( !(m.Account is Account acc) ) + if (!(m.Account is Account acc)) return; - if ( acc.m_YoungTimer != null ) + if (acc.m_YoungTimer != null) { acc.m_YoungTimer.Stop(); acc.m_YoungTimer = null; } - if ( !(m is PlayerMobile pm) ) + if (!(m is PlayerMobile pm)) return; acc.m_TotalGameTime += DateTime.UtcNow - pm.SessionStart; @@ -458,52 +458,52 @@ namespace Server.Accounting private static void EventSink_Login(Mobile m) { - if ( !(m is PlayerMobile pm) ) + if (!(m is PlayerMobile pm)) return; - if ( !(m.Account is Account acc) ) + if (!(m.Account is Account acc)) return; - if ( pm.Young && acc.Young ) + if (pm.Young && acc.Young) { TimeSpan ts = YoungDuration - acc.TotalGameTime; - int hours = Math.Max( (int) ts.TotalHours, 0 ); + int hours = Math.Max((int)ts.TotalHours, 0); - m.SendAsciiMessage( "You will enjoy the benefits and relatively safe status of a young player for {0} more hour{1}.", hours, hours != 1 ? "s" : "" ); + m.SendAsciiMessage("You will enjoy the benefits and relatively safe status of a young player for {0} more hour{1}.", hours, hours != 1 ? "s" : ""); } } - public void RemoveYoungStatus( int message ) + public void RemoveYoungStatus(int message) { Young = false; - for ( int i = 0; i < m_Mobiles.Length; i++ ) - if ( m_Mobiles[i] is PlayerMobile m && m.Young ) + for (int i = 0; i < m_Mobiles.Length; i++) + if (m_Mobiles[i] is PlayerMobile m && m.Young) { m.Young = false; - if ( m.NetState != null ) + if (m.NetState != null) { - if ( message > 0 ) - m.SendLocalizedMessage( message ); + if (message > 0) + m.SendLocalizedMessage(message); - m.SendLocalizedMessage( 1019039 ); // You are no longer considered a young player of Ultima Online, and are no longer subject to the limitations and benefits of being in that caste. + m.SendLocalizedMessage(1019039); // You are no longer considered a young player of Ultima Online, and are no longer subject to the limitations and benefits of being in that caste. } } } public void CheckYoung() { - if ( TotalGameTime >= YoungDuration ) - RemoveYoungStatus( 1019038 ); // You are old enough to be considered an adult, and have outgrown your status as a young player! + if (TotalGameTime >= YoungDuration) + RemoveYoungStatus(1019038); // You are old enough to be considered an adult, and have outgrown your status as a young player! } private class YoungTimer : Timer { - private Account m_Account; + private readonly Account m_Account; - public YoungTimer( Account account ) - : base( TimeSpan.FromMinutes( 1.0 ), TimeSpan.FromMinutes( 1.0 ) ) + public YoungTimer(Account account) + : base(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0)) { m_Account = account; @@ -516,11 +516,11 @@ namespace Server.Accounting } } - public Account( string username, string password ) + public Account(string username, string password) { Username = username; - SetPassword( password ); + SetPassword(password); m_AccessLevel = AccessLevel.Player; @@ -529,93 +529,93 @@ namespace Server.Accounting m_Mobiles = new Mobile[7]; - IPRestrictions = new string[0]; - LoginIPs = new IPAddress[0]; + IPRestrictions = Array.Empty(); + LoginIPs = Array.Empty(); - Accounts.Add( this ); + Accounts.Add(this); } - public Account( XmlElement node ) + public Account(XmlElement node) { - Username = Utility.GetText( node["username"], "empty" ); + Username = Utility.GetText(node["username"], "empty"); - string plainPassword = Utility.GetText( node["password"], null ); - string cryptPassword = Utility.GetText( node["cryptPassword"], null ); - string newCryptPassword = Utility.GetText( node["newCryptPassword"], null ); + string plainPassword = Utility.GetText(node["password"], null); + string cryptPassword = Utility.GetText(node["cryptPassword"], null); + string newCryptPassword = Utility.GetText(node["newCryptPassword"], null); - switch ( AccountHandler.ProtectPasswords ) + switch (AccountHandler.ProtectPasswords) { case PasswordProtection.None: - { - if ( plainPassword != null ) - SetPassword( plainPassword ); - else if ( newCryptPassword != null ) - NewCryptPassword = newCryptPassword; - else if ( cryptPassword != null ) - CryptPassword = cryptPassword; - else - SetPassword( "empty" ); + { + if (plainPassword != null) + SetPassword(plainPassword); + else if (newCryptPassword != null) + NewCryptPassword = newCryptPassword; + else if (cryptPassword != null) + CryptPassword = cryptPassword; + else + SetPassword("empty"); - break; - } + break; + } case PasswordProtection.Crypt: - { - if ( cryptPassword != null ) - CryptPassword = cryptPassword; - else if ( plainPassword != null ) - SetPassword( plainPassword ); - else if ( newCryptPassword != null ) - NewCryptPassword = newCryptPassword; - else - SetPassword( "empty" ); + { + if (cryptPassword != null) + CryptPassword = cryptPassword; + else if (plainPassword != null) + SetPassword(plainPassword); + else if (newCryptPassword != null) + NewCryptPassword = newCryptPassword; + else + SetPassword("empty"); - break; - } + break; + } default: // PasswordProtection.NewCrypt - { - if ( newCryptPassword != null ) - NewCryptPassword = newCryptPassword; - else if ( plainPassword != null ) - SetPassword( plainPassword ); - else if ( cryptPassword != null ) - CryptPassword = cryptPassword; - else - SetPassword( "empty" ); + { + if (newCryptPassword != null) + NewCryptPassword = newCryptPassword; + else if (plainPassword != null) + SetPassword(plainPassword); + else if (cryptPassword != null) + CryptPassword = cryptPassword; + else + SetPassword("empty"); - break; - } + break; + } } - Enum.TryParse( Utility.GetText( node["accessLevel"], "Player" ), true, out m_AccessLevel ); - Flags = Utility.GetXMLInt32( Utility.GetText( node["flags"], "0" ), 0 ); - Created = Utility.GetXMLDateTime( Utility.GetText( node["created"], null ), DateTime.UtcNow ); - LastLogin = Utility.GetXMLDateTime( Utility.GetText( node["lastLogin"], null ), DateTime.UtcNow ); + Enum.TryParse(Utility.GetText(node["accessLevel"], "Player"), true, out m_AccessLevel); + Flags = Utility.GetXMLInt32(Utility.GetText(node["flags"], "0"), 0); + Created = Utility.GetXMLDateTime(Utility.GetText(node["created"], null), DateTime.UtcNow); + LastLogin = Utility.GetXMLDateTime(Utility.GetText(node["lastLogin"], null), DateTime.UtcNow); - TotalGold = Utility.GetXMLInt32( Utility.GetText(node["totalGold"], "0" ), 0 ); + TotalGold = Utility.GetXMLInt32(Utility.GetText(node["totalGold"], "0"), 0); TotalPlat = Utility.GetXMLInt32(Utility.GetText(node["totalPlat"], "0"), 0); - m_Mobiles = LoadMobiles( node ); - m_Comments = LoadComments( node ); - m_Tags = LoadTags( node ); - LoginIPs = LoadAddressList( node ); - IPRestrictions = LoadAccessCheck( node ); + m_Mobiles = LoadMobiles(node); + m_Comments = LoadComments(node); + m_Tags = LoadTags(node); + LoginIPs = LoadAddressList(node); + IPRestrictions = LoadAccessCheck(node); - for ( int i = 0; i < m_Mobiles.Length; ++i ) - if ( m_Mobiles[i] != null ) + for (int i = 0; i < m_Mobiles.Length; ++i) + if (m_Mobiles[i] != null) m_Mobiles[i].Account = this; - TimeSpan totalGameTime = Utility.GetXMLTimeSpan( Utility.GetText( node["totalGameTime"], null ), TimeSpan.Zero ); - if ( totalGameTime == TimeSpan.Zero ) - for ( int i = 0; i < m_Mobiles.Length; i++ ) - if ( m_Mobiles[i] is PlayerMobile m ) + TimeSpan totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero); + if (totalGameTime == TimeSpan.Zero) + for (int i = 0; i < m_Mobiles.Length; i++) + if (m_Mobiles[i] is PlayerMobile m) totalGameTime += m.GameTime; m_TotalGameTime = totalGameTime; - if ( Young ) + if (Young) CheckYoung(); - Accounts.Add( this ); + Accounts.Add(this); } /// @@ -623,28 +623,28 @@ namespace Server.Accounting /// /// The XmlElement from which to deserialize. /// String list. Value will never be null. - public static string[] LoadAccessCheck( XmlElement node ) + public static string[] LoadAccessCheck(XmlElement node) { string[] stringList; XmlElement accessCheck = node["accessCheck"]; - if ( accessCheck != null ) + if (accessCheck != null) { List list = new List(); - foreach ( XmlElement ip in accessCheck.GetElementsByTagName( "ip" ) ) + foreach (XmlElement ip in accessCheck.GetElementsByTagName("ip")) { - string text = Utility.GetText( ip, null ); + string text = Utility.GetText(ip, null); - if ( text != null ) - list.Add( text ); + if (text != null) + list.Add(text); } stringList = list.ToArray(); } else { - stringList = new string[0]; + stringList = Array.Empty(); } return stringList; @@ -655,39 +655,39 @@ namespace Server.Accounting /// /// The XmlElement from which to deserialize. /// Address list. Value will never be null. - public static IPAddress[] LoadAddressList( XmlElement node ) + public static IPAddress[] LoadAddressList(XmlElement node) { IPAddress[] list; XmlElement addressList = node["addressList"]; - if ( addressList != null ) + if (addressList != null) { - int count = Utility.GetXMLInt32( Utility.GetAttribute( addressList, "count", "0" ), 0 ); + int count = Utility.GetXMLInt32(Utility.GetAttribute(addressList, "count", "0"), 0); list = new IPAddress[count]; count = 0; - foreach ( XmlElement ip in addressList.GetElementsByTagName( "ip" ) ) - if ( count < list.Length ) - if ( IPAddress.TryParse( Utility.GetText( ip, null ), out IPAddress address ) ) + foreach (XmlElement ip in addressList.GetElementsByTagName("ip")) + if (count < list.Length) + if (IPAddress.TryParse(Utility.GetText(ip, null), out IPAddress address)) { - list[count] = Utility.Intern( address ); + list[count] = Utility.Intern(address); count++; } - if ( count != list.Length ) + if (count != list.Length) { IPAddress[] old = list; list = new IPAddress[count]; - for ( int i = 0; i < count && i < old.Length; ++i ) + for (int i = 0; i < count && i < old.Length; ++i) list[i] = old[i]; } } else { - list = new IPAddress[0]; + list = Array.Empty(); } return list; @@ -698,24 +698,24 @@ namespace Server.Accounting /// /// The XmlElement instance from which to deserialize. /// Mobile list. Value will never be null. - public static Mobile[] LoadMobiles( XmlElement node ) + public static Mobile[] LoadMobiles(XmlElement node) { Mobile[] list = new Mobile[7]; XmlElement chars = node["chars"]; - //int length = Accounts.GetInt32( Accounts.GetAttribute( chars, "length", "6" ), 6 ); - //list = new Mobile[length]; - //Above is legacy, no longer used + // int length = Accounts.GetInt32( Accounts.GetAttribute( chars, "length", "6" ), 6 ); + // list = new Mobile[length]; + // Above is legacy, no longer used - if ( chars != null ) - foreach ( XmlElement ele in chars.GetElementsByTagName( "char" ) ) + if (chars != null) + foreach (XmlElement ele in chars.GetElementsByTagName("char")) try { - int index = Utility.GetXMLInt32( Utility.GetAttribute( ele, "index", "0" ), 0 ); - uint serial = Utility.GetXMLUInt32( Utility.GetText( ele, "0" ), 0 ); + int index = Utility.GetXMLInt32(Utility.GetAttribute(ele, "index", "0"), 0); + uint serial = Utility.GetXMLUInt32(Utility.GetText(ele, "0"), 0); - if ( index >= 0 && index < list.Length ) - list[index] = World.FindMobile( serial ); + if (index >= 0 && index < list.Length) + list[index] = World.FindMobile(serial); } catch { @@ -730,17 +730,17 @@ namespace Server.Accounting /// /// The XmlElement from which to deserialize. /// Comment list. Value will never be null. - public static List LoadComments( XmlElement node ) + public static List LoadComments(XmlElement node) { List list = null; XmlElement comments = node["comments"]; - if ( comments != null ) + if (comments != null) { list = new List(); - foreach ( XmlElement comment in comments.GetElementsByTagName( "comment" ) ) - try { list.Add( new AccountComment( comment ) ); } + foreach (XmlElement comment in comments.GetElementsByTagName("comment")) + try { list.Add(new AccountComment(comment)); } catch { // ignored @@ -755,17 +755,17 @@ namespace Server.Accounting /// /// The XmlElement from which to deserialize. /// Tag list. Value will never be null. - public static List LoadTags( XmlElement node ) + public static List LoadTags(XmlElement node) { List list = null; XmlElement tags = node["tags"]; - if ( tags != null ) + if (tags != null) { list = new List(); - foreach ( XmlElement tag in tags.GetElementsByTagName( "tag" ) ) - try { list.Add( new AccountTag( tag ) ); } + foreach (XmlElement tag in tags.GetElementsByTagName("tag")) + try { list.Add(new AccountTag(tag)); } catch { // ignored @@ -782,35 +782,35 @@ namespace Server.Accounting /// True if allowed, false if not. public bool HasAccess(NetState ns) => ns != null && HasAccess(ns.Address); - public bool HasAccess( IPAddress ipAddress ) + public bool HasAccess(IPAddress ipAddress) { AccessLevel level = AccountHandler.LockdownLevel; - if ( level > AccessLevel.Player ) + if (level > AccessLevel.Player) { bool hasAccess = false; - if ( m_AccessLevel >= level ) + if (m_AccessLevel >= level) hasAccess = true; else - for ( int i = 0; !hasAccess && i < Length; ++i ) + for (int i = 0; !hasAccess && i < Length; ++i) { Mobile m = this[i]; - if ( m?.AccessLevel >= level ) + if (m?.AccessLevel >= level) hasAccess = true; } Console.WriteLine("{0} {1}", hasAccess ? "yes" : "no", m_AccessLevel); - if ( !hasAccess ) + if (!hasAccess) return false; } - bool accessAllowed = IPRestrictions.Length == 0 || IPLimiter.IsExempt( ipAddress ); + bool accessAllowed = IPRestrictions.Length == 0 || IPLimiter.IsExempt(ipAddress); - for ( int i = 0; !accessAllowed && i < IPRestrictions.Length; ++i ) - accessAllowed = Utility.IPMatch( IPRestrictions[i], ipAddress ); + for (int i = 0; !accessAllowed && i < IPRestrictions.Length; ++i) + accessAllowed = Utility.IPMatch(IPRestrictions[i], ipAddress); return accessAllowed; } @@ -819,17 +819,19 @@ namespace Server.Accounting /// Records the IP address of 'ns' in its 'LoginIPs' list. /// /// NetState instance to record. - public void LogAccess( NetState ns ) + public void LogAccess(NetState ns) { - if ( ns != null ) LogAccess( ns.Address ); + if (ns != null) LogAccess(ns.Address); } - public void LogAccess( IPAddress ipAddress ) { - if ( IPLimiter.IsExempt( ipAddress ) ) + public void LogAccess(IPAddress ipAddress) + { + if (IPLimiter.IsExempt(ipAddress)) return; - if ( LoginIPs.Length == 0 ) { - if ( AccountHandler.IPTable.ContainsKey( ipAddress ) ) + if (LoginIPs.Length == 0) + { + if (AccountHandler.IPTable.ContainsKey(ipAddress)) AccountHandler.IPTable[ipAddress]++; else AccountHandler.IPTable[ipAddress] = 1; @@ -837,16 +839,16 @@ namespace Server.Accounting bool contains = false; - for ( int i = 0; !contains && i < LoginIPs.Length; ++i ) - contains = LoginIPs[i].Equals( ipAddress ); + for (int i = 0; !contains && i < LoginIPs.Length; ++i) + contains = LoginIPs[i].Equals(ipAddress); - if ( contains ) + if (contains) return; IPAddress[] old = LoginIPs; LoginIPs = new IPAddress[old.Length + 1]; - for ( int i = 0; i < old.Length; ++i ) + for (int i = 0; i < old.Length; ++i) LoginIPs[i] = old[i]; LoginIPs[old.Length] = ipAddress; @@ -857,13 +859,14 @@ namespace Server.Accounting /// /// NetState instance to check. /// True if allowed, false if not. - public bool CheckAccess( NetState ns ) => ns != null && CheckAccess( ns.Address ); + public bool CheckAccess(NetState ns) => ns != null && CheckAccess(ns.Address); - public bool CheckAccess( IPAddress ipAddress ) { - bool hasAccess = HasAccess( ipAddress ); + public bool CheckAccess(IPAddress ipAddress) + { + bool hasAccess = HasAccess(ipAddress); - if ( hasAccess ) - LogAccess( ipAddress ); + if (hasAccess) + LogAccess(ipAddress); return hasAccess; } @@ -872,74 +875,74 @@ namespace Server.Accounting /// Serializes this Account instance to an XmlTextWriter. /// /// The XmlTextWriter instance from which to serialize. - public void Save( XmlTextWriter xml ) + public void Save(XmlTextWriter xml) { - xml.WriteStartElement( "account" ); + xml.WriteStartElement("account"); - xml.WriteStartElement( "username" ); - xml.WriteString( Username ); + xml.WriteStartElement("username"); + xml.WriteString(Username); xml.WriteEndElement(); - if ( PlainPassword != null ) + if (PlainPassword != null) { - xml.WriteStartElement( "password" ); - xml.WriteString( PlainPassword ); + xml.WriteStartElement("password"); + xml.WriteString(PlainPassword); xml.WriteEndElement(); } - if ( CryptPassword != null ) + if (CryptPassword != null) { - xml.WriteStartElement( "cryptPassword" ); - xml.WriteString( CryptPassword ); + xml.WriteStartElement("cryptPassword"); + xml.WriteString(CryptPassword); xml.WriteEndElement(); } - if ( NewCryptPassword != null ) + if (NewCryptPassword != null) { - xml.WriteStartElement( "newCryptPassword" ); - xml.WriteString( NewCryptPassword ); + xml.WriteStartElement("newCryptPassword"); + xml.WriteString(NewCryptPassword); xml.WriteEndElement(); } - if ( m_AccessLevel != AccessLevel.Player ) + if (m_AccessLevel != AccessLevel.Player) { - xml.WriteStartElement( "accessLevel" ); - xml.WriteString( m_AccessLevel.ToString() ); + xml.WriteStartElement("accessLevel"); + xml.WriteString(m_AccessLevel.ToString()); xml.WriteEndElement(); } - if ( Flags != 0 ) + if (Flags != 0) { - xml.WriteStartElement( "flags" ); - xml.WriteString( XmlConvert.ToString( Flags ) ); + xml.WriteStartElement("flags"); + xml.WriteString(XmlConvert.ToString(Flags)); xml.WriteEndElement(); } - xml.WriteStartElement( "created" ); - xml.WriteString( XmlConvert.ToString( Created, XmlDateTimeSerializationMode.Utc ) ); + xml.WriteStartElement("created"); + xml.WriteString(XmlConvert.ToString(Created, XmlDateTimeSerializationMode.Utc)); xml.WriteEndElement(); - xml.WriteStartElement( "lastLogin" ); - xml.WriteString( XmlConvert.ToString( LastLogin, XmlDateTimeSerializationMode.Utc ) ); + xml.WriteStartElement("lastLogin"); + xml.WriteString(XmlConvert.ToString(LastLogin, XmlDateTimeSerializationMode.Utc)); xml.WriteEndElement(); - xml.WriteStartElement( "totalGameTime" ); - xml.WriteString( XmlConvert.ToString( TotalGameTime ) ); + xml.WriteStartElement("totalGameTime"); + xml.WriteString(XmlConvert.ToString(TotalGameTime)); xml.WriteEndElement(); - xml.WriteStartElement( "chars" ); + xml.WriteStartElement("chars"); - //xml.WriteAttributeString( "length", m_Mobiles.Length.ToString() ); //Legacy, Not used anymore + // xml.WriteAttributeString( "length", m_Mobiles.Length.ToString() ); //Legacy, Not used anymore - for ( int i = 0; i < m_Mobiles.Length; ++i ) + for (int i = 0; i < m_Mobiles.Length; ++i) { Mobile m = m_Mobiles[i]; if (m?.Deleted == false) { - xml.WriteStartElement( "char" ); - xml.WriteAttributeString( "index", i.ToString() ); - xml.WriteString( m.Serial.Value.ToString() ); + xml.WriteStartElement("char"); + xml.WriteAttributeString("index", i.ToString()); + xml.WriteString(m.Serial.Value.ToString()); xml.WriteEndElement(); } } @@ -948,48 +951,48 @@ namespace Server.Accounting if (m_Comments?.Count > 0) { - xml.WriteStartElement( "comments" ); + xml.WriteStartElement("comments"); - for ( int i = 0; i < m_Comments.Count; ++i ) - m_Comments[i].Save( xml ); + for (int i = 0; i < m_Comments.Count; ++i) + m_Comments[i].Save(xml); xml.WriteEndElement(); } if (m_Tags?.Count > 0) { - xml.WriteStartElement( "tags" ); + xml.WriteStartElement("tags"); - for ( int i = 0; i < m_Tags.Count; ++i ) - m_Tags[i].Save( xml ); + for (int i = 0; i < m_Tags.Count; ++i) + m_Tags[i].Save(xml); xml.WriteEndElement(); } - if ( LoginIPs.Length > 0 ) + if (LoginIPs.Length > 0) { - xml.WriteStartElement( "addressList" ); + xml.WriteStartElement("addressList"); - xml.WriteAttributeString( "count", LoginIPs.Length.ToString() ); + xml.WriteAttributeString("count", LoginIPs.Length.ToString()); - for ( int i = 0; i < LoginIPs.Length; ++i ) + for (int i = 0; i < LoginIPs.Length; ++i) { - xml.WriteStartElement( "ip" ); - xml.WriteString( LoginIPs[i].ToString() ); + xml.WriteStartElement("ip"); + xml.WriteString(LoginIPs[i].ToString()); xml.WriteEndElement(); } xml.WriteEndElement(); } - if ( IPRestrictions.Length > 0 ) + if (IPRestrictions.Length > 0) { - xml.WriteStartElement( "accessCheck" ); + xml.WriteStartElement("accessCheck"); - for ( int i = 0; i < IPRestrictions.Length; ++i ) + for (int i = 0; i < IPRestrictions.Length; ++i) { - xml.WriteStartElement( "ip" ); - xml.WriteString( IPRestrictions[i] ); + xml.WriteStartElement("ip"); + xml.WriteString(IPRestrictions[i]); xml.WriteEndElement(); } @@ -1016,8 +1019,8 @@ namespace Server.Accounting { int count = 0; - for ( int i = 0; i < Length; ++i ) - if ( this[i] != null ) + for (int i = 0; i < Length; ++i) + if (this[i] != null) ++count; return count; @@ -1041,7 +1044,7 @@ namespace Server.Accounting { get { - if ( index >= 0 && index < m_Mobiles.Length ) + if (index >= 0 && index < m_Mobiles.Length) { Mobile m = m_Mobiles[index]; @@ -1058,14 +1061,14 @@ namespace Server.Accounting } set { - if ( index >= 0 && index < m_Mobiles.Length ) + if (index >= 0 && index < m_Mobiles.Length) { - if ( m_Mobiles[index] != null ) + if (m_Mobiles[index] != null) m_Mobiles[index].Account = null; m_Mobiles[index] = value; - if ( m_Mobiles[index] != null ) + if (m_Mobiles[index] != null) m_Mobiles[index].Account = this; } } @@ -1073,11 +1076,10 @@ namespace Server.Accounting public override string ToString() => Username; - public int CompareTo( Account other ) => other == null ? 1 : Username.CompareTo( other.Username ); + public int CompareTo(Account other) => other == null ? 1 : Username.CompareTo(other.Username); - public int CompareTo( IAccount other ) => other == null ? 1 : Username.CompareTo( other.Username ); + public int CompareTo(IAccount other) => other == null ? 1 : Username.CompareTo(other.Username); - #region Gold Account /// /// This amount represents the current amount of Gold owned by the player. /// The value does not include the value of Platinum and ranges from @@ -1164,7 +1166,5 @@ namespace Server.Accounting /// /// Total gold, capped at Int32.MaxValue public long GetTotalGold() => TotalGold + TotalPlat * AccountGold.CurrencyThreshold; - - #endregion } } diff --git a/Projects/Scripts/Accounting/AccountAttackLimiter.cs b/Projects/Scripts/Accounting/AccountAttackLimiter.cs index f302c22f3..ac8ecdd57 100644 --- a/Projects/Scripts/Accounting/AccountAttackLimiter.cs +++ b/Projects/Scripts/Accounting/AccountAttackLimiter.cs @@ -10,7 +10,7 @@ namespace Server.Accounting { public static bool Enabled = true; - private static List m_List = new List(); + private static readonly List m_List = new List(); public static void Initialize() { @@ -75,8 +75,7 @@ namespace Server.Accounting "{0}\t{1}\t{2}", DateTime.UtcNow, ns, - accessLog.Counts - ); + accessLog.Counts); } catch { @@ -113,13 +112,13 @@ namespace Server.Accounting RefreshAccessTime(); } - public IPAddress Address{ get; set; } + public IPAddress Address { get; set; } - public DateTime LastAccessTime{ get; set; } + public DateTime LastAccessTime { get; set; } public bool HasExpired => DateTime.UtcNow >= LastAccessTime + TimeSpan.FromHours(1.0); - public int Counts{ get; set; } + public int Counts { get; set; } public void RefreshAccessTime() { diff --git a/Projects/Scripts/Accounting/AccountComment.cs b/Projects/Scripts/Accounting/AccountComment.cs index 2305d3272..1516ff868 100644 --- a/Projects/Scripts/Accounting/AccountComment.cs +++ b/Projects/Scripts/Accounting/AccountComment.cs @@ -33,7 +33,7 @@ namespace Server.Accounting /// /// A string representing who added this comment. /// - public string AddedBy{ get; } + public string AddedBy { get; } /// /// Gets or sets the body of this comment. Setting this value will reset LastModified. @@ -51,7 +51,7 @@ namespace Server.Accounting /// /// The date and time when this account was last modified -or- the comment creation time, if never modified. /// - public DateTime LastModified{ get; private set; } + public DateTime LastModified { get; private set; } /// /// Serializes this AccountComment instance to an XmlTextWriter. diff --git a/Projects/Scripts/Accounting/AccountHandler.cs b/Projects/Scripts/Accounting/AccountHandler.cs index 262ecad3a..24896a617 100644 --- a/Projects/Scripts/Accounting/AccountHandler.cs +++ b/Projects/Scripts/Accounting/AccountHandler.cs @@ -18,14 +18,14 @@ namespace Server.Misc public class AccountHandler { - private static int MaxAccountsPerIP = 1; - private static bool AutoAccountCreation = true; - private static bool RestrictDeletion = !TestCenter.Enabled; - private static TimeSpan DeleteDelay = TimeSpan.FromDays(7.0); + private static readonly int MaxAccountsPerIP = 1; + private static readonly bool AutoAccountCreation = true; + private static readonly bool RestrictDeletion = !TestCenter.Enabled; + private static readonly TimeSpan DeleteDelay = TimeSpan.FromDays(7.0); public static PasswordProtection ProtectPasswords = PasswordProtection.NewCrypt; - private static CityInfo[] StartingCities = + private static readonly CityInfo[] StartingCities = { new CityInfo("New Haven", "New Haven Bank", 1150168, 3667, 2625, 0), new CityInfo("Yew", "The Empath Abbey", 1075072, 633, 858, 0), @@ -47,7 +47,7 @@ namespace Server.Misc // .. new CityInfo( "Haven", "Buckler's Hideaway", 3667, 2625, 0 ) - if ( Core.AOS ) + if (Core.AOS) { //CityInfo haven = new CityInfo( "Haven", "Uzeraan's Mansion", 3618, 2591, 0 ); CityInfo haven = new CityInfo( "Haven", "Uzeraan's Mansion", 3503, 2574, 14 ); @@ -55,7 +55,7 @@ namespace Server.Misc } */ - private static bool PasswordCommandEnabled = false; + private static readonly bool PasswordCommandEnabled = false; private static Dictionary m_IPTable; @@ -64,7 +64,7 @@ namespace Server.Misc '<', '>', ':', '"', '/', '\\', '|', '?', '*' }; - public static AccessLevel LockdownLevel{ get; set; } + public static AccessLevel LockdownLevel { get; set; } public static Dictionary IPTable { @@ -174,10 +174,10 @@ namespace Server.Misc from.SendMessage( "Your IP address does not match that which created this account. A page has been entered into the help system on your behalf."); - from.SendLocalizedMessage(501234, "", - 0x35); /* The next available Counselor/Game Master will respond as soon as possible. - * Please check your Journal for messages every few minutes. - */ + /* The next available Counselor/Game Master will respond as soon as possible. + * Please check your Journal for messages every few minutes. + */ + from.SendLocalizedMessage(501234, "", 0x35); PageQueue.Enqueue(new PageEntry(from, $"[Automated: Change Password]
Desired password: {pass}
Current IP address: {ipAddress}
Account IP address: {accessList[0]}", @@ -222,8 +222,7 @@ namespace Server.Misc state.Send(new CharacterListUpdate(acct)); } else if (m.AccessLevel == AccessLevel.Player && - Region.Find(m.LogoutLocation, m.LogoutMap).IsPartOf() - ) //Don't need to check current location, if netstate is null, they're logged out + Region.Find(m.LogoutLocation, m.LogoutMap).IsPartOf()) // Don't need to check current location, if netstate is null, they're logged out { state.Send(new DeleteResult(DeleteResultType.BadRequest)); state.Send(new CharacterListUpdate(acct)); diff --git a/Projects/Scripts/Accounting/AccountTag.cs b/Projects/Scripts/Accounting/AccountTag.cs index b67a20c1b..6689eb1da 100644 --- a/Projects/Scripts/Accounting/AccountTag.cs +++ b/Projects/Scripts/Accounting/AccountTag.cs @@ -28,12 +28,12 @@ namespace Server.Accounting /// /// Gets or sets the name of this tag. /// - public string Name{ get; set; } + public string Name { get; set; } /// /// Gets or sets the value of this tag. /// - public string Value{ get; set; } + public string Value { get; set; } /// /// Serializes this AccountTag instance to an XmlTextWriter. diff --git a/Projects/Scripts/Accounting/Accounts.cs b/Projects/Scripts/Accounting/Accounts.cs index 5b3a710a0..bae956a27 100644 --- a/Projects/Scripts/Accounting/Accounts.cs +++ b/Projects/Scripts/Accounting/Accounts.cs @@ -75,7 +75,6 @@ namespace Server.Accounting using StreamWriter op = new StreamWriter(filePath); XmlTextWriter xml = new XmlTextWriter(op) { Formatting = Formatting.Indented, IndentChar = '\t', Indentation = 1 }; - xml.WriteStartDocument(true); xml.WriteStartElement("accounts"); diff --git a/Projects/Scripts/Accounting/Firewall.cs b/Projects/Scripts/Accounting/Firewall.cs index 4946ff9c6..b05aebfb9 100644 --- a/Projects/Scripts/Accounting/Firewall.cs +++ b/Projects/Scripts/Accounting/Firewall.cs @@ -30,7 +30,7 @@ namespace Server object toAdd; IPAddress addr; - if ( IPAddress.TryParse( line, out addr ) ) + if (IPAddress.TryParse( line, out addr )) toAdd = addr; else toAdd = line; @@ -41,7 +41,7 @@ namespace Server } } - public static List List{ get; } + public static List List { get; } public static IFirewallEntry ToFirewallEntry(object entry) { @@ -60,7 +60,7 @@ namespace Server if (IPAddress.TryParse(entry, out IPAddress addr)) return new IPFirewallEntry(addr); - //Try CIDR parse + // Try CIDR parse string[] str = entry.Split('/'); if (str.Length == 2) @@ -147,15 +147,15 @@ namespace Server for ( int i = 0; !contains && i < m_Blocked.Count; ++i ) { - if ( m_Blocked[i] is IPAddress ) + if (m_Blocked[i] is IPAddress) contains = ip.Equals( m_Blocked[i] ); - else if ( m_Blocked[i] is String ) + else if (m_Blocked[i] is String) { string s = (string)m_Blocked[i]; contains = Utility.IPMatchCIDR( s, ip ); - if ( !contains ) + if (!contains) contains = Utility.IPMatch( s, ip ); } } @@ -164,8 +164,6 @@ namespace Server * */ } - #region Firewall Entries - public interface IFirewallEntry { bool IsBlocked(IPAddress address); @@ -173,7 +171,7 @@ namespace Server public class IPFirewallEntry : IFirewallEntry { - private IPAddress m_Address; + private readonly IPAddress m_Address; public IPFirewallEntry(IPAddress address) => m_Address = address; @@ -203,8 +201,8 @@ namespace Server public class CIDRFirewallEntry : IFirewallEntry { - private int m_CIDRLength; - private IPAddress m_CIDRPrefix; + private readonly int m_CIDRLength; + private readonly IPAddress m_CIDRPrefix; public CIDRFirewallEntry(IPAddress cidrPrefix, int cidrLength) { @@ -240,7 +238,7 @@ namespace Server public class WildcardIPFirewallEntry : IFirewallEntry { - private string m_Entry; + private readonly string m_Entry; private bool m_Valid; @@ -249,7 +247,7 @@ namespace Server public bool IsBlocked(IPAddress address) { if (!m_Valid) - return false; //Why process if it's invalid? it'll return false anyway after processing it. + return false; // Why process if it's invalid? it'll return false anyway after processing it. bool matched = Utility.IPMatch(m_Entry, address, out bool valid); m_Valid = valid; @@ -268,7 +266,5 @@ namespace Server public override int GetHashCode() => m_Entry.GetHashCode(); } - - #endregion } } diff --git a/Projects/Scripts/Accounting/IPLimiter.cs b/Projects/Scripts/Accounting/IPLimiter.cs index 5e0cbf7c0..8d866b070 100644 --- a/Projects/Scripts/Accounting/IPLimiter.cs +++ b/Projects/Scripts/Accounting/IPLimiter.cs @@ -13,7 +13,7 @@ namespace Server.Misc public static IPAddress[] Exemptions = { - //IPAddress.Parse( "127.0.0.1" ), + // IPAddress.Parse( "127.0.0.1" ), }; public static bool IsExempt(IPAddress ip) diff --git a/Projects/Scripts/Commands/Add.cs b/Projects/Scripts/Commands/Add.cs index f0a354f8e..6634d09a3 100644 --- a/Projects/Scripts/Commands/Add.cs +++ b/Projects/Scripts/Commands/Add.cs @@ -9,20 +9,20 @@ namespace Server.Commands { public class Add { - private static Type m_EntityType = typeof(IEntity); + private static readonly Type m_EntityType = typeof(IEntity); - private static Type m_ConstructibleType = typeof(ConstructibleAttribute); + private static readonly Type m_ConstructibleType = typeof(ConstructibleAttribute); - private static Type m_EnumType = typeof(Enum); + private static readonly Type m_EnumType = typeof(Enum); - private static Type m_TypeType = typeof(Type); + private static readonly Type m_TypeType = typeof(Type); - private static Type m_ParsableType = typeof(ParsableAttribute); + private static readonly Type m_ParsableType = typeof(ParsableAttribute); - private static Type[] m_ParseTypes = { typeof(string) }; - private static object[] m_ParseArgs = new object[1]; + private static readonly Type[] m_ParseTypes = { typeof(string) }; + private static readonly object[] m_ParseArgs = new object[1]; - private static Type[] m_SignedNumerics = + private static readonly Type[] m_SignedNumerics = { typeof(long), typeof(int), @@ -30,7 +30,7 @@ namespace Server.Commands typeof(sbyte) }; - private static Type[] m_UnsignedNumerics = + private static readonly Type[] m_UnsignedNumerics = { typeof(ulong), typeof(uint), @@ -198,7 +198,6 @@ namespace Server.Commands if (!paramList[j].HasDefaultValue) totalParams += 1; - if (args.Length >= totalParams && args.Length <= paramList.Length) { object[] paramValues = ParseValues(paramList, args); @@ -348,23 +347,23 @@ namespace Server.Commands int z = start.Z; for (int x = start.X; x <= end.X; ++x) - for (int y = start.Y; y <= end.Y; ++y) - { - if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y) - continue; + for (int y = start.Y; y <= end.Y; ++y) + { + if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y) + continue; - if (mapAvg) - z = map.GetAverageZ(x, y); + if (mapAvg) + z = map.GetAverageZ(x, y); - IEntity built = Build(from, ctor, values, props, realProps, ref sendError); + IEntity built = Build(from, ctor, values, props, realProps, ref sendError); - sb.AppendFormat("0x{0:X}; ", built.Serial.Value); + sb.AppendFormat("0x{0:X}; ", built.Serial.Value); - if (built is Item item) - item.MoveToWorld(new Point3D(x, y, z), map); - else if (built is Mobile m) - m.MoveToWorld(new Point3D(x, y, z), map); - } + if (built is Item item) + item.MoveToWorld(new Point3D(x, y, z), map); + else if (built is Mobile m) + m.MoveToWorld(new Point3D(x, y, z), map); + } } CommandLogging.WriteLine(from, sb.ToString()); @@ -433,15 +432,15 @@ namespace Server.Commands switch (ts.m_ZType) { case TileZType.Fixed: - { - start.Z = end.Z = ts.m_FixedZ; - break; - } + { + start.Z = end.Z = ts.m_FixedZ; + break; + } case TileZType.MapAverage: - { - mapAvg = true; - break; - } + { + mapAvg = true; + break; + } } Invoke(from, start, end, ts.m_Args, null, ts.m_Outline, mapAvg); @@ -667,10 +666,10 @@ namespace Server.Commands private class TileState { - public string[] m_Args; - public int m_FixedZ; - public bool m_Outline; - public TileZType m_ZType; + public readonly string[] m_Args; + public readonly int m_FixedZ; + public readonly bool m_Outline; + public readonly TileZType m_ZType; public TileState(TileZType zType, int fixedZ, string[] args, bool outline) { diff --git a/Projects/Scripts/Commands/Attributes.cs b/Projects/Scripts/Commands/Attributes.cs index 7a20c6832..fd30526a9 100644 --- a/Projects/Scripts/Commands/Attributes.cs +++ b/Projects/Scripts/Commands/Attributes.cs @@ -6,20 +6,20 @@ namespace Server { public UsageAttribute(string usage) => Usage = usage; - public string Usage{ get; } + public string Usage { get; } } public class DescriptionAttribute : Attribute { public DescriptionAttribute(string description) => Description = description; - public string Description{ get; } + public string Description { get; } } public class AliasesAttribute : Attribute { public AliasesAttribute(params string[] aliases) => Aliases = aliases; - public string[] Aliases{ get; } + public string[] Aliases { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Commands/Batch.cs b/Projects/Scripts/Commands/Batch.cs index 89e703c5e..1037b64e9 100644 --- a/Projects/Scripts/Commands/Batch.cs +++ b/Projects/Scripts/Commands/Batch.cs @@ -15,11 +15,11 @@ namespace Server.Commands ListOptimized = true; } - public BaseCommandImplementor Scope{ get; set; } + public BaseCommandImplementor Scope { get; set; } - public string Condition{ get; set; } = ""; + public string Condition { get; set; } = ""; - public List BatchCommands{ get; } = new List(); + public List BatchCommands { get; } = new List(); public override void ExecuteList(CommandEventArgs e, List list) { @@ -180,9 +180,9 @@ namespace Server.Commands Object = obj; } - public string Command{ get; set; } + public string Command { get; set; } - public string Object{ get; set; } + public string Object { get; set; } public void GetDetails(out string command, out string argString, out string[] args) { @@ -199,15 +199,15 @@ namespace Server.Commands { argString = ""; command = Command.ToLower(); - args = new string[0]; + args = Array.Empty(); } } } public class BatchGump : BaseGridGump { - private Batch m_Batch; - private Mobile m_From; + private readonly Batch m_Batch; + private readonly Mobile m_From; public BatchGump(Mobile from, Batch batch) : base(30, 30) { @@ -326,28 +326,28 @@ namespace Server.Commands switch (type) { case 0: // main - { - switch (index) { - case 0: // run + switch (index) { - m_Batch.Run(m_From); - break; + case 0: // run + { + m_Batch.Run(m_From); + break; + } + case 1: // set scope + { + m_From.SendGump(new BatchScopeGump(m_From, m_Batch)); + return; + } + case 2: // add command + { + m_Batch.BatchCommands.Add(new BatchCommand("", "")); + break; + } } - case 1: // set scope - { - m_From.SendGump(new BatchScopeGump(m_From, m_Batch)); - return; - } - case 2: // add command - { - m_Batch.BatchCommands.Add(new BatchCommand("", "")); - break; - } - } - break; - } + break; + } } m_From.SendGump(new BatchGump(m_From, m_Batch)); @@ -356,8 +356,8 @@ namespace Server.Commands public class BatchScopeGump : BaseGridGump { - private Batch m_Batch; - private Mobile m_From; + private readonly Batch m_Batch; + private readonly Mobile m_From; public BatchScopeGump(Mobile from, Batch batch) : base(30, 30) { @@ -399,17 +399,17 @@ namespace Server.Commands switch (type) { case 0: - { - if (index < BaseCommandImplementor.Implementors.Count) { - BaseCommandImplementor impl = BaseCommandImplementor.Implementors[index]; + if (index < BaseCommandImplementor.Implementors.Count) + { + BaseCommandImplementor impl = BaseCommandImplementor.Implementors[index]; - if (m_From.AccessLevel >= impl.AccessLevel) - m_Batch.Scope = impl; + if (m_From.AccessLevel >= impl.AccessLevel) + m_Batch.Scope = impl; + } + + break; } - - break; - } } m_From.SendGump(new BatchGump(m_From, m_Batch)); diff --git a/Projects/Scripts/Commands/BoundingBoxPicker.cs b/Projects/Scripts/Commands/BoundingBoxPicker.cs index d95156919..72a11f0ac 100644 --- a/Projects/Scripts/Commands/BoundingBoxPicker.cs +++ b/Projects/Scripts/Commands/BoundingBoxPicker.cs @@ -14,10 +14,10 @@ namespace Server private class PickTarget : Target { - private BoundingBoxCallback m_Callback; - private bool m_First; - private Map m_Map; - private Point3D m_Store; + private readonly BoundingBoxCallback m_Callback; + private readonly bool m_First; + private readonly Map m_Map; + private readonly Point3D m_Store; public PickTarget(BoundingBoxCallback callback) : this(Point3D.Zero, true, null, callback) { diff --git a/Projects/Scripts/Commands/ConvertPlayers.cs b/Projects/Scripts/Commands/ConvertPlayers.cs index 5dacd925e..80804f37d 100644 --- a/Projects/Scripts/Commands/ConvertPlayers.cs +++ b/Projects/Scripts/Commands/ConvertPlayers.cs @@ -64,7 +64,7 @@ namespace Server.Commands } } - private static PropertyInfo[] _mobProps = + private static readonly PropertyInfo[] _mobProps = typeof(Mobile).GetProperties(BindingFlags.Public | BindingFlags.Instance) .Where(prop => prop.CanRead && prop.CanWrite).ToArray(); diff --git a/Projects/Scripts/Commands/Decorate.cs b/Projects/Scripts/Commands/Decorate.cs index 9f5bdba79..19b525101 100644 --- a/Projects/Scripts/Commands/Decorate.cs +++ b/Projects/Scripts/Commands/Decorate.cs @@ -1,9 +1,7 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; -using System.Reflection; using Server.Engines.Quests.Haven; using Server.Engines.Quests.Necro; using Server.Items; @@ -12,7 +10,7 @@ using Server.Utilities; namespace Server.Commands { - public class Decorate + public static class Decorate { private static Mobile m_Mobile; private static int m_Count; @@ -60,22 +58,22 @@ namespace Server.Commands public class DecorationList { - private static Type typeofStatic = typeof(Static); - private static Type typeofLocalizedStatic = typeof(LocalizedStatic); - private static Type typeofBaseDoor = typeof(BaseDoor); - private static Type typeofAnkhWest = typeof(AnkhWest); - private static Type typeofAnkhNorth = typeof(AnkhNorth); - private static Type typeofBeverage = typeof(BaseBeverage); - private static Type typeofLocalizedSign = typeof(LocalizedSign); - private static Type typeofMarkContainer = typeof(MarkContainer); - private static Type typeofWarningItem = typeof(WarningItem); - private static Type typeofHintItem = typeof(HintItem); - private static Type typeofCannon = typeof(Cannon); - private static Type typeofSerpentPillar = typeof(SerpentPillar); + private static readonly Type typeofStatic = typeof(Static); + private static readonly Type typeofLocalizedStatic = typeof(LocalizedStatic); + private static readonly Type typeofBaseDoor = typeof(BaseDoor); + private static readonly Type typeofAnkhWest = typeof(AnkhWest); + private static readonly Type typeofAnkhNorth = typeof(AnkhNorth); + private static readonly Type typeofBeverage = typeof(BaseBeverage); + private static readonly Type typeofLocalizedSign = typeof(LocalizedSign); + private static readonly Type typeofMarkContainer = typeof(MarkContainer); + private static readonly Type typeofWarningItem = typeof(WarningItem); + private static readonly Type typeofHintItem = typeof(HintItem); + private static readonly Type typeofCannon = typeof(Cannon); + private static readonly Type typeofSerpentPillar = typeof(SerpentPillar); - private static Queue m_DeleteQueue = new Queue(); + private static readonly Queue m_DeleteQueue = new Queue(); - private static string[] m_EmptyParams = new string[0]; + private static readonly string[] m_EmptyParams = Array.Empty(); private List m_Entries; private int m_ItemID; private string[] m_Params; @@ -934,14 +932,13 @@ namespace Server.Commands for (int j = 0; j < maps.Length; ++j) { - try { item ??= Construct(); } - catch(TypeInitializationException e) + catch (TypeInitializationException e) { - Console.WriteLine($"{nameof(Generate)}() failed to load type: {e.TypeName}: {e.InnerException.Message}"); + Console.WriteLine($"{nameof(Generate)}() failed to load type: {e.TypeName}: {e.InnerException?.Message}"); continue; } @@ -1083,11 +1080,11 @@ namespace Server.Commands Extra = line; } - public Point3D Location{ get; } + public Point3D Location { get; } - public string Extra{ get; } + public string Extra { get; } - public void Pop(out string v, ref string line) + public static void Pop(out string v, ref string line) { int space = line.IndexOf(' '); diff --git a/Projects/Scripts/Commands/DecorateMag.cs b/Projects/Scripts/Commands/DecorateMag.cs index 1f038c371..9d16aacc4 100644 --- a/Projects/Scripts/Commands/DecorateMag.cs +++ b/Projects/Scripts/Commands/DecorateMag.cs @@ -33,7 +33,6 @@ namespace Server.Commands Generate("Data/Decoration/RuinedMaginciaTram", Map.Trammel); Generate("Data/Decoration/RuinedMaginciaFel", Map.Felucca); - m_Mobile.SendMessage("World generating complete. {0} items were generated.", m_Count); } @@ -56,22 +55,22 @@ namespace Server.Commands public class DecorationListMag { - private static Type typeofStatic = typeof(Static); - private static Type typeofLocalizedStatic = typeof(LocalizedStatic); - private static Type typeofBaseDoor = typeof(BaseDoor); - private static Type typeofAnkhWest = typeof(AnkhWest); - private static Type typeofAnkhNorth = typeof(AnkhNorth); - private static Type typeofBeverage = typeof(BaseBeverage); - private static Type typeofLocalizedSign = typeof(LocalizedSign); - private static Type typeofMarkContainer = typeof(MarkContainer); - private static Type typeofWarningItem = typeof(WarningItem); - private static Type typeofHintItem = typeof(HintItem); - private static Type typeofCannon = typeof(Cannon); - private static Type typeofSerpentPillar = typeof(SerpentPillar); + private static readonly Type typeofStatic = typeof(Static); + private static readonly Type typeofLocalizedStatic = typeof(LocalizedStatic); + private static readonly Type typeofBaseDoor = typeof(BaseDoor); + private static readonly Type typeofAnkhWest = typeof(AnkhWest); + private static readonly Type typeofAnkhNorth = typeof(AnkhNorth); + private static readonly Type typeofBeverage = typeof(BaseBeverage); + private static readonly Type typeofLocalizedSign = typeof(LocalizedSign); + private static readonly Type typeofMarkContainer = typeof(MarkContainer); + private static readonly Type typeofWarningItem = typeof(WarningItem); + private static readonly Type typeofHintItem = typeof(HintItem); + private static readonly Type typeofCannon = typeof(Cannon); + private static readonly Type typeofSerpentPillar = typeof(SerpentPillar); - private static Queue m_DeleteQueue = new Queue(); + private static readonly Queue m_DeleteQueue = new Queue(); - private static string[] m_EmptyParams = new string[0]; + private static readonly string[] m_EmptyParams = Array.Empty(); private List m_Entries; private int m_ItemID; private string[] m_Params; @@ -1070,9 +1069,9 @@ namespace Server.Commands Extra = line; } - public Point3D Location{ get; } + public Point3D Location { get; } - public string Extra{ get; } + public string Extra { get; } public void Pop(out string v, ref string line) { diff --git a/Projects/Scripts/Commands/Docs.cs b/Projects/Scripts/Commands/Docs.cs index c5aff2b29..bedffa94f 100644 --- a/Projects/Scripts/Commands/Docs.cs +++ b/Projects/Scripts/Commands/Docs.cs @@ -243,7 +243,7 @@ namespace Server.Commands nameBuilder.Append(sanitizedName); fnamBuilder.Append("T"); - if (DontLink(typeArguments[i])) //if ( DontLink( typeArguments[i].Name ) ) + if (DontLink(typeArguments[i])) linkBuilder.Append($"{aliasedName}"); else linkBuilder.Append( @@ -270,7 +270,7 @@ namespace Server.Commands else linkName = link; - //Console.WriteLine( typeName+":"+fileName+":"+linkName ); + // Console.WriteLine( typeName+":"+fileName+":"+linkName ); } public static string SanitizeType(string name) @@ -312,7 +312,7 @@ namespace Server.Commands public static bool DontLink( string name ) { foreach( string dontLink in m_DontLink ) - if ( dontLink == name ) return true; + if (dontLink == name ) return true; return false; } */ @@ -416,9 +416,13 @@ namespace Server.Commands private class TypeInfo { public List m_Derived, m_Nested; - private string m_FileName, m_TypeName, m_LinkName; - public Type[] m_Interfaces; - public Type m_Type, m_BaseType, m_Declaring; + private readonly string m_FileName; + private readonly string m_TypeName; + private readonly string m_LinkName; + public readonly Type[] m_Interfaces; + public readonly Type m_Type; + public readonly Type m_BaseType; + public readonly Type m_Declaring; public TypeInfo(Type type) { @@ -437,8 +441,6 @@ namespace Server.Commands public string LinkName(string dirRoot) => m_LinkName.Replace("@directory@", dirRoot); } - #region FileSystem - private static readonly char[] ReplaceChars = "<>".ToCharArray(); public static string GetFileName(string root, string name, string ext) @@ -460,7 +462,7 @@ namespace Server.Commands return file; } - private static string m_RootDirectory = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]); + private static readonly string m_RootDirectory = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]); private static void EnsureDirectory(string path) { @@ -482,11 +484,7 @@ namespace Server.Commands private static StreamWriter GetWriter(string path) => new StreamWriter(Path.Combine(m_RootDirectory, path)); - #endregion - - #region GetPair - - private static string[,] m_Aliases = + private static readonly string[,] m_Aliases = { { "System.Object", "object" }, { "System.String", "string" }, @@ -506,7 +504,7 @@ namespace Server.Commands { "System.Void", "void" } }; - private static int m_AliasLength = m_Aliases.GetLength(0); + private static readonly int m_AliasLength = m_Aliases.GetLength(0); public static string GetPair(Type varType, string name, bool ignoreRef) { @@ -600,10 +598,6 @@ namespace Server.Commands return string.Concat(prepend, aliased, append, name); } - #endregion - - #region Root documentation - private static bool Document() { try @@ -634,7 +628,6 @@ namespace Server.Commands List assemblies = new List { Core.Assembly }; - foreach (Assembly asm in AssemblyHandler.Assemblies) assemblies.Add(asm); @@ -713,10 +706,6 @@ namespace Server.Commands html.WriteLine(""); } - #endregion - - #region BODs - private const int Iron = 0xCCCCDD; private const int DullCopper = 0xAAAAAA; private const int ShadowIron = 0x777799; @@ -763,7 +752,6 @@ namespace Server.Commands html.WriteLine("

"); html.WriteLine("

"); - sbod.Type = typeof(PlateArms); WriteSmithBODHeader(html, "(Small) Armor: Normal"); @@ -923,8 +911,6 @@ namespace Server.Commands } } - #region Tailor Bods - private static void WriteTailorLBOD(StreamWriter html, string name, SmallBulkEntry[] entries, bool expandCloth, bool expandPlain) { @@ -1221,20 +1207,20 @@ namespace Server.Commands switch (material) { case BulkMaterialType.None: - { - if (type.IsSubclassOf(typeof(BaseArmor)) || type.IsSubclassOf(typeof(BaseShoes))) { - style = "pl"; - name = "Plain"; - } - else - { - style = "cl"; - name = "Cloth"; - } + if (type.IsSubclassOf(typeof(BaseArmor)) || type.IsSubclassOf(typeof(BaseShoes))) + { + style = "pl"; + name = "Plain"; + } + else + { + style = "cl"; + name = "Cloth"; + } - break; - } + break; + } case BulkMaterialType.Spined: style = "sp"; name = "Spined"; @@ -1281,10 +1267,6 @@ namespace Server.Commands html.WriteLine(" "); } - #endregion - - #region Smith Bods - private static void WriteSmithLBOD(StreamWriter html, string name, SmallBulkEntry[] entries) { LargeBOD lbod = new LargeSmithBOD(); @@ -1564,12 +1546,6 @@ namespace Server.Commands html.WriteLine(" "); } - #endregion - - #endregion - - #region Bodies - public static List LoadBodies() { List list = new List(); @@ -1689,10 +1665,6 @@ namespace Server.Commands html.WriteLine(""); } - #endregion - - #region Speech - private static void DocumentKeywords() { List> tables = LoadSpeechFile(); @@ -1728,7 +1700,7 @@ namespace Server.Commands html.Write(" 0x{0:X4}", entry.Index); - entry.Strings.Sort(); //( new EnglishPrioStringSorter() ); + entry.Strings.Sort(); // ( new EnglishPrioStringSorter() ); for (int j = 0; j < entry.Strings.Count; ++j) { @@ -1776,9 +1748,9 @@ namespace Server.Commands Strings = new List(); } - public int Index{ get; } + public int Index { get; } - public List Strings{ get; } + public List Strings { get; } } private class SpeechEntrySorter : IComparer @@ -1833,10 +1805,6 @@ namespace Server.Commands return tables; } - #endregion - - #region Commands - public class DocCommandEntry { public DocCommandEntry(AccessLevel accessLevel, string name, string[] aliases, string usage, string description) @@ -1848,15 +1816,15 @@ namespace Server.Commands Description = description; } - public AccessLevel AccessLevel{ get; } + public AccessLevel AccessLevel { get; } - public string Name{ get; } + public string Name { get; } - public string[] Aliases{ get; } + public string[] Aliases { get; } - public string Usage{ get; } + public string Usage { get; } - public string Description{ get; } + public string Description { get; } } public class CommandEntrySorter : IComparer @@ -2112,12 +2080,10 @@ namespace Server.Commands html.WriteLine(""); } - #endregion - - #region Constructible Objects - - private static Type typeofItem = typeof(Item), typeofMobile = typeof(Mobile), typeofMap = typeof(Map); - private static Type typeofCustomEnum = typeof(CustomEnumAttribute); + private static readonly Type typeofItem = typeof(Item); + private static readonly Type typeofMobile = typeof(Mobile); + private static readonly Type typeofMap = typeof(Map); + private static readonly Type typeofCustomEnum = typeof(CustomEnumAttribute); private static bool IsConstructible(Type t, out bool isItem) => (isItem = typeofItem.IsAssignableFrom(t)) || typeofMobile.IsAssignableFrom(t); @@ -2226,13 +2192,9 @@ namespace Server.Commands html.WriteLine(""); } - #endregion - - #region Tooltips - private const string HtmlNewLine = " "; - private static object[,] m_Tooltips = + private static readonly object[,] m_Tooltips = { { typeof(byte), "Numeric value in the range from 0 to 255, inclusive." }, { typeof(sbyte), "Numeric value in the range from negative 128 to positive 127, inclusive." }, @@ -2319,10 +2281,6 @@ namespace Server.Commands return ""; } - #endregion - - #region Const Strings - private const string RefString = "ref "; private const string GetString = " get;"; private const string SetString = " set;"; @@ -2334,10 +2292,6 @@ namespace Server.Commands private const string CtorString = "(ctor) "; private const string StaticString = "(static) "; - #endregion - - #region Write[...] - private static void WriteEnum(TypeInfo info, StreamWriter typeHtml) { Type type = info.m_Type; @@ -2381,7 +2335,7 @@ namespace Server.Commands if (decInfo == null) typeHtml.Write(decType.Name); else - //typeHtml.Write( "{1}", decInfo.m_FileName, decInfo.m_TypeName ); + // typeHtml.Write( "{1}", decInfo.m_FileName, decInfo.m_TypeName ); typeHtml.Write(decInfo.LinkName(null)); typeHtml.Write(") - "); @@ -2452,7 +2406,7 @@ namespace Server.Commands if (i != 0) typeHtml.Write(", "); - //typeHtml.Write( "{1}", derivedInfo.m_FileName, derivedInfo.m_TypeName ); + // typeHtml.Write( "{1}", derivedInfo.m_FileName, derivedInfo.m_TypeName ); typeHtml.Write($"{derivedInfo.LinkName(null)}"); } @@ -2474,7 +2428,7 @@ namespace Server.Commands if (i != 0) typeHtml.Write(", "); - //typeHtml.Write( "{1}", nestedInfo.m_FileName, nestedInfo.m_TypeName ); + // typeHtml.Write( "{1}", nestedInfo.m_FileName, nestedInfo.m_TypeName ); typeHtml.Write($"{nestedInfo.LinkName(null)}"); } @@ -2600,12 +2554,8 @@ namespace Server.Commands html.WriteLine(")
"); } - - #endregion } - #region BodyEntry & BodyType - public enum ModelBodyType { Invalid = -1, @@ -2625,11 +2575,11 @@ namespace Server.Commands Name = name; } - public Body Body{ get; } + public Body Body { get; } - public ModelBodyType BodyType{ get; } + public ModelBodyType BodyType { get; } - public string Name{ get; } + public string Name { get; } public override bool Equals(object obj) { @@ -2657,6 +2607,4 @@ namespace Server.Commands return a?.Name.CompareTo(b?.Name) ?? 1; } } - - #endregion } diff --git a/Projects/Scripts/Commands/Dupe.cs b/Projects/Scripts/Commands/Dupe.cs index 3516c87fa..f1bb47b6b 100644 --- a/Projects/Scripts/Commands/Dupe.cs +++ b/Projects/Scripts/Commands/Dupe.cs @@ -1,8 +1,8 @@ +using System; +using System.Reflection; using Server.Items; using Server.Targeting; using Server.Utilities; -using System; -using System.Reflection; namespace Server.Commands { @@ -48,14 +48,14 @@ namespace Server.Commands } catch { - //Console.WriteLine( "Denied" ); + // Console.WriteLine( "Denied" ); } } private class DupeTarget : Target { - private int m_Amount; - private bool m_InBag; + private readonly int m_Amount; + private readonly bool m_InBag; public DupeTarget(bool inbag, int amount) : base(15, false, TargetFlags.None) @@ -103,7 +103,7 @@ namespace Server.Commands for (int i = 0; i < m_Amount; i++) if (c.Invoke(args) is Item newItem) { - CopyProperties(newItem, copy); //copy.Dupe( item, copy.Amount ); + CopyProperties(newItem, copy); // copy.Dupe( item, copy.Amount ); copy.OnAfterDuped(newItem); newItem.Parent = null; diff --git a/Projects/Scripts/Commands/ExportWSC.cs b/Projects/Scripts/Commands/ExportWSC.cs index 3633e02a1..0c76648a1 100644 --- a/Projects/Scripts/Commands/ExportWSC.cs +++ b/Projects/Scripts/Commands/ExportWSC.cs @@ -76,4 +76,4 @@ WEIGHT 25500 OWNER -1 SPAWN -1 VALUE 1 -}*/ \ No newline at end of file +}*/ diff --git a/Projects/Scripts/Commands/GenCategorization.cs b/Projects/Scripts/Commands/GenCategorization.cs index 2855b2e50..7124c2786 100644 --- a/Projects/Scripts/Commands/GenCategorization.cs +++ b/Projects/Scripts/Commands/GenCategorization.cs @@ -13,9 +13,9 @@ namespace Server.Commands { private static CategoryEntry m_RootItems, m_RootMobiles; - private static Type typeofItem = typeof(Item); - private static Type typeofMobile = typeof(Mobile); - private static Type typeofConstructible = typeof(ConstructibleAttribute); + private static readonly Type typeofItem = typeof(Item); + private static readonly Type typeofMobile = typeof(Mobile); + private static readonly Type typeofConstructible = typeof(ConstructibleAttribute); public static CategoryEntry Items { @@ -275,9 +275,9 @@ namespace Server.Commands Object = ActivatorUtil.CreateInstance(type); } - public Type Type{ get; } + public Type Type { get; } - public object Object{ get; } + public object Object { get; } } public class CategoryEntry @@ -286,8 +286,8 @@ namespace Server.Commands { Parent = parent; Title = title; - SubCategories = subCats ?? new CategoryEntry[0]; - Matches = new Type[0]; + SubCategories = subCats ?? Array.Empty(); + Matches = Array.Empty(); Matched = new List(); } @@ -342,15 +342,15 @@ namespace Server.Commands Matched = new List(); } - public string Title{ get; } + public string Title { get; } - public Type[] Matches{ get; } + public Type[] Matches { get; } - public CategoryEntry Parent{ get; } + public CategoryEntry Parent { get; } - public CategoryEntry[] SubCategories{ get; } + public CategoryEntry[] SubCategories { get; } - public List Matched{ get; } + public List Matched { get; } public bool IsMatch(Type type) { @@ -380,9 +380,9 @@ namespace Server.Commands Text = input.Substring(index); } - public int Indentation{ get; } + public int Indentation { get; } - public string Text{ get; } + public string Text { get; } public static CategoryLine[] Load(string path) { diff --git a/Projects/Scripts/Commands/GenTeleporter.cs b/Projects/Scripts/Commands/GenTeleporter.cs index 5902f0b27..b450e5ee6 100644 --- a/Projects/Scripts/Commands/GenTeleporter.cs +++ b/Projects/Scripts/Commands/GenTeleporter.cs @@ -1,10 +1,10 @@ -using Server.Items; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; +using Server.Items; using Server.Json; namespace Server.Commands @@ -122,7 +122,7 @@ namespace Server.Commands public int Count { get; private set; } public int DelCount { get; private set; } - private static bool IsWithinZ(int delta) => -12 <= delta && delta <= 12; + private static bool IsWithinZ(int delta) => delta >= -12 && delta <= 12; public static int DeleteTeleporters(Location location) { diff --git a/Projects/Scripts/Commands/Generic/Commands/BaseCommand.cs b/Projects/Scripts/Commands/Generic/Commands/BaseCommand.cs index 4c360b8ab..f44d9ab57 100644 --- a/Projects/Scripts/Commands/Generic/Commands/BaseCommand.cs +++ b/Projects/Scripts/Commands/Generic/Commands/BaseCommand.cs @@ -12,22 +12,22 @@ namespace Server.Commands.Generic public abstract class BaseCommand { - private List m_Responses = new List(); - private List m_Failures = new List(); + private readonly List m_Responses = new List(); + private readonly List m_Failures = new List(); - public bool ListOptimized{ get; set; } + public bool ListOptimized { get; set; } - public string[] Commands{ get; set; } + public string[] Commands { get; set; } - public string Usage{ get; set; } + public string Usage { get; set; } - public string Description{ get; set; } + public string Description { get; set; } - public AccessLevel AccessLevel{ get; set; } + public AccessLevel AccessLevel { get; set; } - public ObjectTypes ObjectTypes{ get; set; } + public ObjectTypes ObjectTypes { get; set; } - public CommandSupport Supports{ get; set; } + public CommandSupport Supports { get; set; } public static bool IsAccessible(Mobile from, object obj) { @@ -117,7 +117,7 @@ namespace Server.Commands.Generic private class MessageEntry { public int m_Count; - public string m_Message; + public readonly string m_Message; public MessageEntry(string message) { diff --git a/Projects/Scripts/Commands/Generic/Commands/Commands.cs b/Projects/Scripts/Commands/Generic/Commands/Commands.cs index 9f05b2624..c5f1cb897 100644 --- a/Projects/Scripts/Commands/Generic/Commands/Commands.cs +++ b/Projects/Scripts/Commands/Generic/Commands/Commands.cs @@ -14,7 +14,7 @@ namespace Server.Commands.Generic { public class TargetCommands { - public static List AllCommands{ get; } = new List(); + public static List AllCommands { get; } = new List(); public static void Initialize() { @@ -348,7 +348,7 @@ namespace Server.Commands.Generic public class TellCommand : BaseCommand { - private bool m_InGump; + private readonly bool m_InGump; public TellCommand(bool inGump) { @@ -511,7 +511,7 @@ namespace Server.Commands.Generic SpellHelper.GetSurfaceTop(ref p); - //CommandLogging.WriteLine( from, "{0} {1} teleporting to {2}", from.AccessLevel, CommandLogging.Format( from ), new Point3D( p ) ); + // CommandLogging.WriteLine( from, "{0} {1} teleporting to {2}", from.AccessLevel, CommandLogging.Format( from ), new Point3D( p ) ); Point3D fromLoc = from.Location; Point3D toLoc = new Point3D(p); @@ -683,8 +683,8 @@ namespace Server.Commands.Generic public class AliasedSetCommand : BaseCommand { - private string m_Name; - private string m_Value; + private readonly string m_Name; + private readonly string m_Value; public AliasedSetCommand(AccessLevel level, string command, string name, string value, ObjectTypes objects) { @@ -830,7 +830,7 @@ namespace Server.Commands.Generic public class KillCommand : BaseCommand { - private bool m_Value; + private readonly bool m_Value; public KillCommand(bool value) { @@ -916,7 +916,7 @@ namespace Server.Commands.Generic public class HideCommand : BaseCommand { - private bool m_Value; + private readonly bool m_Value; public HideCommand(bool value) { @@ -1011,7 +1011,7 @@ namespace Server.Commands.Generic public class KickCommand : BaseCommand { - private bool m_Ban; + private readonly bool m_Ban; public KickCommand(bool ban) { diff --git a/Projects/Scripts/Commands/Generic/Commands/DesignInsert.cs b/Projects/Scripts/Commands/Generic/Commands/DesignInsert.cs index cae91d825..84b5c4b26 100644 --- a/Projects/Scripts/Commands/Generic/Commands/DesignInsert.cs +++ b/Projects/Scripts/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 == null || item is BaseMulti || item is HouseSign || (staticsOnly && !(item is Static))) return DesignInsertResult.InvalidItem; house = BaseHouse.FindHouseAt(item) as HouseFoundation; @@ -69,8 +69,6 @@ namespace Server.Commands.Generic return true; } - #region Single targeting mode - public override void Execute(CommandEventArgs e, object obj) { Target t = new DesignInsertTarget(new List(), e.Length < 1 || !e.GetBoolean(0)); @@ -79,8 +77,8 @@ namespace Server.Commands.Generic private class DesignInsertTarget : Target { - private List m_Foundations; - private bool m_StaticsOnly; + private readonly List m_Foundations; + private readonly bool m_StaticsOnly; public DesignInsertTarget(List foundations, bool staticsOnly) : base(-1, false, TargetFlags.None) @@ -107,39 +105,35 @@ namespace Server.Commands.Generic switch (result) { case DesignInsertResult.Valid: - { - if (m_Foundations.Count == 0) - from.SendMessage( - "The item has been inserted into the house design. Press ESC when you are finished."); - else - from.SendMessage("The item has been inserted into the house design."); + { + if (m_Foundations.Count == 0) + from.SendMessage( + "The item has been inserted into the house design. Press ESC when you are finished."); + else + from.SendMessage("The item has been inserted into the house design."); - if (!m_Foundations.Contains(house)) - m_Foundations.Add(house); + if (!m_Foundations.Contains(house)) + m_Foundations.Add(house); - break; - } + break; + } case DesignInsertResult.InvalidItem: - { - from.SendMessage("That cannot be inserted. Try again."); - break; - } + { + from.SendMessage("That cannot be inserted. Try again."); + break; + } case DesignInsertResult.NotInHouse: case DesignInsertResult.OutsideHouseBounds: - { - from.SendMessage("That item is not inside a customizable house. Try again."); - break; - } + { + from.SendMessage("That item is not inside a customizable house. Try again."); + break; + } } from.Target = new DesignInsertTarget(m_Foundations, m_StaticsOnly); } } - #endregion - - #region Area targeting mode - public override void ExecuteList(CommandEventArgs e, List list) { Mobile from = e.Mobile; @@ -165,25 +159,25 @@ namespace Server.Commands.Generic switch (result) { case DesignInsertResult.Valid: - { - AddResponse("The item has been inserted into the house design."); + { + AddResponse("The item has been inserted into the house design."); - if (!foundations.Contains(house)) - foundations.Add(house); + if (!foundations.Contains(house)) + foundations.Add(house); - break; - } + break; + } case DesignInsertResult.InvalidItem: - { - LogFailure("That cannot be inserted."); - break; - } + { + LogFailure("That cannot be inserted."); + break; + } case DesignInsertResult.NotInHouse: case DesignInsertResult.OutsideHouseBounds: - { - LogFailure("That item is not inside a customizable house."); - break; - } + { + LogFailure("That item is not inside a customizable house."); + break; + } } } @@ -197,7 +191,5 @@ namespace Server.Commands.Generic Flush(from, flushToLog); } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Commands/Generic/Commands/Interface.cs b/Projects/Scripts/Commands/Generic/Commands/Interface.cs index f87c18b13..6ceab010a 100644 --- a/Projects/Scripts/Commands/Generic/Commands/Interface.cs +++ b/Projects/Scripts/Commands/Generic/Commands/Interface.cs @@ -25,7 +25,6 @@ namespace Server.Commands.Generic { List columns = new List { "Object" }; - if (e.Length > 0) { int offset = 0; @@ -50,13 +49,13 @@ namespace Server.Commands.Generic { private const int EntriesPerPage = 15; - private string[] m_Columns; - private Mobile m_From; + private readonly string[] m_Columns; + private readonly Mobile m_From; - private List m_List; - private int m_Page; + private readonly List m_List; + private readonly int m_Page; - private object m_Select; + private readonly object m_Select; public InterfaceGump(Mobile from, string[] columns, List list, int page, object select) : base(30, 30) { @@ -197,57 +196,57 @@ namespace Server.Commands.Generic switch (info.ButtonID) { case 1: - { - if (m_Page > 0) - m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page - 1, m_Select)); - - break; - } - case 2: - { - if ((m_Page + 1) * EntriesPerPage < m_List.Count) - m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page + 1, m_Select)); - - break; - } - default: - { - int v = info.ButtonID - 3; - - if (v >= 0 && v < m_List.Count) { - object obj = m_List[v]; + if (m_Page > 0) + m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page - 1, m_Select)); - if (!BaseCommand.IsAccessible(m_From, obj)) + break; + } + case 2: + { + if ((m_Page + 1) * EntriesPerPage < m_List.Count) + m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page + 1, m_Select)); + + break; + } + default: + { + int v = info.ButtonID - 3; + + if (v >= 0 && v < m_List.Count) { - m_From.SendLocalizedMessage(500447); // That is not accessible. - m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select)); - break; + object obj = m_List[v]; + + if (!BaseCommand.IsAccessible(m_From, obj)) + { + m_From.SendLocalizedMessage(500447); // That is not accessible. + m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select)); + break; + } + + if (obj is Item item && !item.Deleted) + m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, item)); + else if (obj is Mobile mobile && !mobile.Deleted) + m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, mobile)); + else + m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select)); } - if (obj is Item item && !item.Deleted) - m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, item)); - else if (obj is Mobile mobile && !mobile.Deleted) - m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, mobile)); - else - m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select)); + break; } - - break; - } } } } public class InterfaceItemGump : BaseGridGump { - private string[] m_Columns; - private Mobile m_From; + private readonly string[] m_Columns; + private readonly Mobile m_From; - private Item m_Item; + private readonly Item m_Item; - private List m_List; - private int m_Page; + private readonly List m_List; + private readonly int m_Page; public InterfaceItemGump(Mobile from, string[] columns, List list, int page, Item item) : base(30, 30) { @@ -318,71 +317,71 @@ namespace Server.Commands.Generic { case 0: case 1: - { - m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item)); - break; - } + { + m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item)); + break; + } case 2: // Properties - { - m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); - m_From.SendGump(new PropertiesGump(m_From, m_Item)); - break; - } - case 3: // Delete - { - CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, - CommandLogging.Format(m_From), CommandLogging.Format(m_Item)); - m_Item.Delete(); - m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item)); - break; - } - case 4: // Go there - { - m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); - InvokeCommand($"Go {m_Item.Serial.Value}"); - break; - } - case 5: // Move to target - { - m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); - m_From.Target = new MoveTarget(m_Item); - break; - } - case 6: // Bring to pack - { - Mobile owner = m_Item.RootParent as Mobile; - - if (owner?.Map != null && owner.Map != Map.Internal && - !BaseCommand.IsAccessible(m_From, owner) /* !m_From.CanSee( owner )*/) - { - m_From.SendMessage("You can not get what you can not see."); - } - else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && - owner.AccessLevel >= m_From.AccessLevel) - { - m_From.SendMessage("You can not get what you can not see."); - } - else { m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); - m_From.AddToBackpack(m_Item); + m_From.SendGump(new PropertiesGump(m_From, m_Item)); + break; } + case 3: // Delete + { + CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, + CommandLogging.Format(m_From), CommandLogging.Format(m_Item)); + m_Item.Delete(); + m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item)); + break; + } + case 4: // Go there + { + m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); + InvokeCommand($"Go {m_Item.Serial.Value}"); + break; + } + case 5: // Move to target + { + m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); + m_From.Target = new MoveTarget(m_Item); + break; + } + case 6: // Bring to pack + { + Mobile owner = m_Item.RootParent as Mobile; - break; - } + if (owner?.Map != null && owner.Map != Map.Internal && + !BaseCommand.IsAccessible(m_From, owner) /* !m_From.CanSee( owner )*/) + { + m_From.SendMessage("You can not get what you can not see."); + } + else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && + owner.AccessLevel >= m_From.AccessLevel) + { + m_From.SendMessage("You can not get what you can not see."); + } + else + { + m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); + m_From.AddToBackpack(m_Item); + } + + break; + } } } } public class InterfaceMobileGump : BaseGridGump { - private string[] m_Columns; - private Mobile m_From; + private readonly string[] m_Columns; + private readonly Mobile m_From; - private List m_List; + private readonly List m_List; - private Mobile m_Mobile; - private int m_Page; + private readonly Mobile m_Mobile; + private readonly int m_Page; public InterfaceMobileGump(Mobile from, string[] columns, List list, int page, Mobile mob) : base(30, 30) @@ -482,86 +481,86 @@ namespace Server.Commands.Generic { case 0: case 1: - { - m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); - break; - } - case 2: // Properties - { - m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); - m_From.SendGump(new PropertiesGump(m_From, m_Mobile)); - break; - } - case 3: // Delete - { - if (!m_Mobile.Player) { - CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, - CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile)); - m_Mobile.Delete(); m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + break; } - - break; - } - case 4: // Go there - { - m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); - InvokeCommand($"Go {m_Mobile.Serial.Value}"); - break; - } - case 5: // Bring them here - { - if (m_From.Map == null || m_From.Map == Map.Internal) - { - m_From.SendMessage("You cannot bring that person here."); - } - else + case 2: // Properties { m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); - m_Mobile.MoveToWorld(m_From.Location, m_From.Map); + m_From.SendGump(new PropertiesGump(m_From, m_Mobile)); + break; } - - break; - } - case 6: // Move to target - { - m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); - m_From.Target = new MoveTarget(m_Mobile); - break; - } - case 7: // Kill - { - if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel) - m_Mobile.Kill(); - - m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); - - break; - } - case 8: // Res - { - if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel) + case 3: // Delete { - m_Mobile.PlaySound(0x214); - m_Mobile.FixedEffect(0x376A, 10, 16); + if (!m_Mobile.Player) + { + CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, + CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile)); + m_Mobile.Delete(); + m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + } - m_Mobile.Resurrect(); + break; } + case 4: // Go there + { + m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + InvokeCommand($"Go {m_Mobile.Serial.Value}"); + break; + } + case 5: // Bring them here + { + if (m_From.Map == null || m_From.Map == Map.Internal) + { + m_From.SendMessage("You cannot bring that person here."); + } + else + { + m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + m_Mobile.MoveToWorld(m_From.Location, m_From.Map); + } - m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + break; + } + case 6: // Move to target + { + m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + m_From.Target = new MoveTarget(m_Mobile); + break; + } + case 7: // Kill + { + if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel) + m_Mobile.Kill(); - break; - } + m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + + break; + } + case 8: // Res + { + if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel) + { + m_Mobile.PlaySound(0x214); + m_Mobile.FixedEffect(0x376A, 10, 16); + + m_Mobile.Resurrect(); + } + + m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + + break; + } case 9: // Client - { - m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); + { + m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); - if (m_Mobile.NetState != null) - m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState)); + if (m_Mobile.NetState != null) + m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState)); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Commands/Generic/Extensions/BaseExtension.cs b/Projects/Scripts/Commands/Generic/Extensions/BaseExtension.cs index c8927953e..78594b8b3 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/BaseExtension.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/BaseExtension.cs @@ -17,18 +17,18 @@ namespace Server.Commands.Generic Constructor = constructor; } - public static Dictionary Table{ get; } = + public static Dictionary Table { get; } = new Dictionary(StringComparer.InvariantCultureIgnoreCase); - public int Order{ get; } + public int Order { get; } - public string Name{ get; } + public string Name { get; } - public int Size{ get; } + public int Size { get; } public bool IsFixedSize => Size >= 0; - public ExtensionConstructor Constructor{ get; } + public ExtensionConstructor Constructor { get; } public static void Register(ExtensionInfo ext) { @@ -103,7 +103,7 @@ namespace Server.Commands.Generic public abstract class BaseExtension { - public abstract ExtensionInfo Info{ get; } + public abstract ExtensionInfo Info { get; } public string Name => Info.Name; diff --git a/Projects/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs b/Projects/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs index 2dace3003..673a6c633 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/Compilers/ConditionalCompiler.cs @@ -1,8 +1,8 @@ -using Server.Utilities; using System; using System.Globalization; using System.Reflection; using System.Reflection.Emit; +using Server.Utilities; namespace Server.Commands.Generic { @@ -47,11 +47,11 @@ namespace Server.Commands.Generic Value = value; } - public Type Type{ get; } + public Type Type { get; } - public object Value{ get; private set; } + public object Value { get; private set; } - public FieldInfo Field{ get; private set; } + public FieldInfo Field { get; private set; } public bool HasField => Field != null; @@ -119,8 +119,7 @@ namespace Server.Commands.Generic BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(string), typeof(NumberStyles) }, - null - ); + null); if (parseNumber != null) { @@ -142,8 +141,7 @@ namespace Server.Commands.Generic BindingFlags.Public | BindingFlags.Static, null, new[] { typeof(string) }, - null - ); + null); parseMethod = parseGeneral; parseArgs = new object[] { toParse }; @@ -158,13 +156,11 @@ namespace Server.Commands.Generic Field = typeBuilder.DefineField( fieldName, Type, - FieldAttributes.Private | FieldAttributes.InitOnly - ); + FieldAttributes.Private | FieldAttributes.InitOnly); - // parseMethod.Invoke(null, + // parseMethod.Invoke(null, // parseArgs.Length == 2 ? new object[] {toParse, (int) parseArgs[1]} : new object[] {toParse}); - il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldstr, toParse); @@ -179,8 +175,7 @@ namespace Server.Commands.Generic else { throw new InvalidOperationException( - $"Unable to convert string \"{Value}\" into type '{Type}'." - ); + $"Unable to convert string \"{Value}\" into type '{Type}'."); } } } @@ -215,9 +210,9 @@ namespace Server.Commands.Generic public sealed class StringCondition : PropertyCondition { - private bool m_IgnoreCase; - private StringOperator m_Operator; - private PropertyValue m_Value; + private readonly bool m_IgnoreCase; + private readonly StringOperator m_Operator; + private readonly PropertyValue m_Value; public StringCondition(Property property, bool not, StringOperator op, object value, bool ignoreCase) : base(property, not) @@ -280,9 +275,7 @@ namespace Server.Commands.Generic typeof(string), typeof(string) }, - null - ) - ); + null)); emitter.Chain(m_Property); m_Value.Load(emitter); @@ -319,9 +312,7 @@ namespace Server.Commands.Generic { typeof(string) }, - null - ) - ); + null)); m_Value.Load(emitter); @@ -347,8 +338,8 @@ namespace Server.Commands.Generic public sealed class ComparisonCondition : PropertyCondition { - private ComparisonOperator m_Operator; - private PropertyValue m_Value; + private readonly ComparisonOperator m_Operator; + private readonly PropertyValue m_Value; public ComparisonCondition(Property property, bool not, ComparisonOperator op, object value) : base(property, not) @@ -369,7 +360,7 @@ namespace Server.Commands.Generic bool inverse = false; bool couldCompare = - emitter.CompareTo(1, delegate { m_Value.Load(emitter); }); + emitter.CompareTo(1, () => { m_Value.Load(emitter); }); if (couldCompare) { @@ -449,17 +440,12 @@ namespace Server.Commands.Generic TypeBuilder typeBuilder = assembly.DefineType( $"__conditional{index}", TypeAttributes.Public, - typeof(object) - ); - - #region Constructor - + typeof(object)); { ConstructorBuilder ctor = typeBuilder.DefineConstructor( MethodAttributes.Public, CallingConventions.Standard, - Type.EmptyTypes - ); + Type.EmptyTypes); ILGenerator il = ctor.GetILGenerator(); @@ -474,16 +460,9 @@ namespace Server.Commands.Generic il.Emit(OpCodes.Ret); } - #endregion - - #region IComparer - typeBuilder.AddInterfaceImplementation(typeof(IConditional)); MethodBuilder compareMethod; - - #region Compare - { MethodEmitter emitter = new MethodEmitter(typeBuilder); @@ -531,17 +510,11 @@ namespace Server.Commands.Generic new[] { typeof(object) - } - ) - ); + })); compareMethod = emitter.Method; } - #endregion - - #endregion - Type conditionalType = typeBuilder.CreateType(); return (IConditional)ActivatorUtil.CreateInstance(conditionalType); diff --git a/Projects/Scripts/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs b/Projects/Scripts/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs index a5b8fcb13..79d7f7980 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/Compilers/DistinctCompiler.cs @@ -1,8 +1,8 @@ -using Server.Utilities; using System; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; +using Server.Utilities; namespace Server.Commands.Generic { @@ -13,17 +13,12 @@ namespace Server.Commands.Generic TypeBuilder typeBuilder = assembly.DefineType( "__distinct", TypeAttributes.Public, - typeof(object) - ); - - #region Constructor - + typeof(object)); { ConstructorBuilder ctor = typeBuilder.DefineConstructor( MethodAttributes.Public, CallingConventions.Standard, - Type.EmptyTypes - ); + Type.EmptyTypes); ILGenerator il = ctor.GetILGenerator(); @@ -36,16 +31,9 @@ namespace Server.Commands.Generic il.Emit(OpCodes.Ret); } - #endregion - - #region IComparer - typeBuilder.AddInterfaceImplementation(typeof(IComparer)); MethodBuilder compareMethod; - - #region Compare - { MethodEmitter emitter = new MethodEmitter(typeBuilder); @@ -78,7 +66,7 @@ namespace Server.Commands.Generic if (i > 0) { emitter.LoadLocal(v); - emitter.BranchIfTrue(end); // if ( v != 0 ) return v; + emitter.BranchIfTrue(end); } Property prop = props[i]; @@ -87,7 +75,7 @@ namespace Server.Commands.Generic emitter.Chain(prop); bool couldCompare = - emitter.CompareTo(1, delegate + emitter.CompareTo(1, () => { emitter.LoadLocal(b); emitter.Chain(prop); @@ -112,23 +100,12 @@ namespace Server.Commands.Generic { typeof(T), typeof(T) - } - ) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}") - ); + }) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}")); compareMethod = emitter.Method; } - #endregion - - #endregion - - #region IEqualityComparer - typeBuilder.AddInterfaceImplementation(typeof(IEqualityComparer)); - - #region Equals - { MethodEmitter emitter = new MethodEmitter(typeBuilder); @@ -158,15 +135,9 @@ namespace Server.Commands.Generic { typeof(T), typeof(T) - } - ) ?? throw new Exception($"No Equals method found for type {typeof(T).FullName}") - ); + }) ?? throw new Exception($"No Equals method found for type {typeof(T).FullName}")); } - #endregion - - #region GetHashCode - { MethodEmitter emitter = new MethodEmitter(typeBuilder); @@ -242,15 +213,9 @@ namespace Server.Commands.Generic new[] { typeof(T) - } - ) ?? throw new Exception($"No GetHashCode method found for type {typeof(T).FullName}") - ); + }) ?? throw new Exception($"No GetHashCode method found for type {typeof(T).FullName}")); } - #endregion - - #endregion - Type comparerType = typeBuilder.CreateType(); return (IComparer)ActivatorUtil.CreateInstance(comparerType); diff --git a/Projects/Scripts/Commands/Generic/Extensions/Compilers/SortCompiler.cs b/Projects/Scripts/Commands/Generic/Extensions/Compilers/SortCompiler.cs index 9416e59ef..1d837a6d6 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/Compilers/SortCompiler.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/Compilers/SortCompiler.cs @@ -1,8 +1,8 @@ -using Server.Utilities; using System; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; +using Server.Utilities; namespace Server.Commands.Generic { @@ -17,7 +17,7 @@ namespace Server.Commands.Generic IsAscending = isAscending; } - public Property Property{ get; set; } + public Property Property { get; set; } public bool IsAscending { @@ -51,17 +51,12 @@ namespace Server.Commands.Generic TypeBuilder typeBuilder = assembly.DefineType( "__sort", TypeAttributes.Public, - typeof(T) - ); - - #region Constructor - + typeof(T)); { ConstructorBuilder ctor = typeBuilder.DefineConstructor( MethodAttributes.Public, CallingConventions.Standard, - Type.EmptyTypes - ); + Type.EmptyTypes); ILGenerator il = ctor.GetILGenerator(); @@ -74,13 +69,7 @@ namespace Server.Commands.Generic il.Emit(OpCodes.Ret); } - #endregion - - #region IComparer - typeBuilder.AddInterfaceImplementation(typeof(IComparer)); - - #region Compare { MethodEmitter emitter = new MethodEmitter(typeBuilder); @@ -113,7 +102,7 @@ namespace Server.Commands.Generic if (i > 0) { emitter.LoadLocal(v); - emitter.BranchIfTrue(end); // if ( v != 0 ) return v; + emitter.BranchIfTrue(end); } OrderInfo orderInfo = orders[i]; @@ -125,7 +114,7 @@ namespace Server.Commands.Generic emitter.Chain(prop); bool couldCompare = - emitter.CompareTo(sign, delegate + emitter.CompareTo(sign, () => { emitter.LoadLocal(b); emitter.Chain(prop); @@ -150,15 +139,9 @@ namespace Server.Commands.Generic { typeof(T), typeof(T) - } - ) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}") - ); + }) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}")); } - #endregion - - #endregion - Type comparerType = typeBuilder.CreateType(); return (IComparer)ActivatorUtil.CreateInstance(comparerType); } diff --git a/Projects/Scripts/Commands/Generic/Extensions/DistinctExtension.cs b/Projects/Scripts/Commands/Generic/Extensions/DistinctExtension.cs index cc3fcf846..49f8fc512 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/DistinctExtension.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/DistinctExtension.cs @@ -10,7 +10,7 @@ namespace Server.Commands.Generic private IComparer m_Comparer; - private List m_Properties; + private readonly List m_Properties; public DistinctExtension() => m_Properties = new List(); diff --git a/Projects/Scripts/Commands/Generic/Extensions/LimitExtension.cs b/Projects/Scripts/Commands/Generic/Extensions/LimitExtension.cs index 055c19689..07b589c07 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/LimitExtension.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/LimitExtension.cs @@ -9,7 +9,7 @@ namespace Server.Commands.Generic public override ExtensionInfo Info => ExtInfo; - public int Limit{ get; private set; } + public int Limit { get; private set; } public static void Initialize() { diff --git a/Projects/Scripts/Commands/Generic/Extensions/SortExtension.cs b/Projects/Scripts/Commands/Generic/Extensions/SortExtension.cs index 63a7c1c03..9124f7d61 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/SortExtension.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/SortExtension.cs @@ -9,7 +9,7 @@ namespace Server.Commands.Generic private IComparer m_Comparer; - private List m_Orders; + private readonly List m_Orders; public SortExtension() => m_Orders = new List(); diff --git a/Projects/Scripts/Commands/Generic/Extensions/WhereExtension.cs b/Projects/Scripts/Commands/Generic/Extensions/WhereExtension.cs index 019e78e92..fe9f281c1 100644 --- a/Projects/Scripts/Commands/Generic/Extensions/WhereExtension.cs +++ b/Projects/Scripts/Commands/Generic/Extensions/WhereExtension.cs @@ -8,7 +8,7 @@ namespace Server.Commands.Generic public override ExtensionInfo Info => ExtInfo; - public ObjectConditional Conditional{ get; private set; } + public ObjectConditional Conditional { get; private set; } public static void Initialize() { diff --git a/Projects/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs b/Projects/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs index 109431398..e4ef1cca0 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/AreaCommandImplementor.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; namespace Server.Commands.Generic { @@ -19,7 +18,7 @@ namespace Server.Commands.Generic Instance = this; } - public static AreaCommandImplementor Instance{ get; private set; } + public static AreaCommandImplementor Instance { get; private set; } public override void Process(Mobile from, BaseCommand command, string[] args) { @@ -48,7 +47,6 @@ namespace Server.Commands.Generic if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj)) objs.Add(obj); - eable.Free(); ext.Filter(objs); diff --git a/Projects/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs b/Projects/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs index 23edf03ea..e2515fcb5 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/BaseCommandImplementor.cs @@ -32,19 +32,19 @@ namespace Server.Commands.Generic public BaseCommandImplementor() => Commands = new Dictionary(StringComparer.OrdinalIgnoreCase); - public bool SupportsConditionals{ get; set; } + public bool SupportsConditionals { get; set; } - public string[] Accessors{ get; set; } + public string[] Accessors { get; set; } - public string Usage{ get; set; } + public string Usage { get; set; } - public string Description{ get; set; } + public string Description { get; set; } - public AccessLevel AccessLevel{ get; set; } + public AccessLevel AccessLevel { get; set; } - public CommandSupport SupportRequirement{ get; set; } + public CommandSupport SupportRequirement { get; set; } - public Dictionary Commands{ get; } + public Dictionary Commands { get; } public static List Implementors { @@ -110,43 +110,43 @@ namespace Server.Commands.Generic { case ObjectTypes.All: case ObjectTypes.Both: - { - if (condIsItem) - items = true; + { + if (condIsItem) + items = true; - if (condIsMobile) - mobiles = true; + if (condIsMobile) + mobiles = true; - break; - } + break; + } case ObjectTypes.Items: - { - if (condIsItem) { - items = true; - } - else if (condIsMobile) - { - from.SendMessage("You may not use a mobile type condition for this command."); - return false; - } + if (condIsItem) + { + items = true; + } + else if (condIsMobile) + { + from.SendMessage("You may not use a mobile type condition for this command."); + return false; + } - break; - } + break; + } case ObjectTypes.Mobiles: - { - if (condIsMobile) { - mobiles = true; - } - else if (condIsItem) - { - from.SendMessage("You may not use an item type condition for this command."); - return false; - } + if (condIsMobile) + { + mobiles = true; + } + else if (condIsItem) + { + from.SendMessage("You may not use an item type condition for this command."); + return false; + } - break; - } + break; + } } return true; @@ -199,8 +199,8 @@ namespace Server.Commands.Generic public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args) { - // try - // { + // try + // { CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args); if (!command.ValidateArgs(this, e)) @@ -226,17 +226,17 @@ namespace Server.Commands.Generic else if (obj != null) { if (command.ListOptimized) - command.ExecuteList(e, new List{ obj }); + command.ExecuteList(e, new List { obj }); else command.Execute(e, obj); } command.Flush(from, flushToLog); - // } - // catch ( Exception ex ) - // { - // from.SendMessage( ex.Message ); - // } + // } + // catch ( Exception ex ) + // { + // from.SendMessage( ex.Message ); + // } } public virtual void Process(Mobile from, BaseCommand command, string[] args) diff --git a/Projects/Scripts/Commands/Generic/Implementors/ContainedCommandImplementor.cs b/Projects/Scripts/Commands/Generic/Implementors/ContainedCommandImplementor.cs index 2425840fe..320957e61 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/ContainedCommandImplementor.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/ContainedCommandImplementor.cs @@ -40,7 +40,7 @@ namespace Server.Commands.Generic from.SendMessage("That is not a container."); return; } - + try { Extensions ext = Extensions.Parse(from, ref args); diff --git a/Projects/Scripts/Commands/Generic/Implementors/MultiCommandImplementor.cs b/Projects/Scripts/Commands/Generic/Implementors/MultiCommandImplementor.cs index b3ac04af2..bfe99f577 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/MultiCommandImplementor.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/MultiCommandImplementor.cs @@ -33,35 +33,35 @@ namespace Server.Commands.Generic switch (command.ObjectTypes) { case ObjectTypes.Both: - { - if (!(targeted is Item || targeted is Mobile)) { - from.SendMessage("This command does not work on that."); - return; - } + if (!(targeted is Item || targeted is Mobile)) + { + from.SendMessage("This command does not work on that."); + return; + } - break; - } + break; + } case ObjectTypes.Items: - { - if (!(targeted is Item)) { - from.SendMessage("This command only works on items."); - return; - } + if (!(targeted is Item)) + { + from.SendMessage("This command only works on items."); + return; + } - break; - } + break; + } case ObjectTypes.Mobiles: - { - if (!(targeted is Mobile)) { - from.SendMessage("This command only works on mobiles."); - return; - } + if (!(targeted is Mobile)) + { + from.SendMessage("This command only works on mobiles."); + return; + } - break; - } + break; + } } RunCommand(from, targeted, command, args); diff --git a/Projects/Scripts/Commands/Generic/Implementors/ObjectConditional.cs b/Projects/Scripts/Commands/Generic/Implementors/ObjectConditional.cs index 6a57ad9b3..bcf9df2ba 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/ObjectConditional.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/ObjectConditional.cs @@ -12,7 +12,7 @@ namespace Server.Commands.Generic private IConditional[] m_Conditionals; - private ICondition[][] m_Conditions; + private readonly ICondition[][] m_Conditions; public ObjectConditional(Type objectType, ICondition[][] conditions) { @@ -20,7 +20,7 @@ namespace Server.Commands.Generic m_Conditions = conditions; } - public Type Type{ get; } + public Type Type { get; } public bool IsItem => Type == null || Type == typeofItem || Type.IsSubclassOf(typeofItem); diff --git a/Projects/Scripts/Commands/Generic/Implementors/RangeCommandImplementor.cs b/Projects/Scripts/Commands/Generic/Implementors/RangeCommandImplementor.cs index a87999209..b8d0d44db 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/RangeCommandImplementor.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/RangeCommandImplementor.cs @@ -15,7 +15,7 @@ namespace Server.Commands.Generic Instance = this; } - public static RangeCommandImplementor Instance{ get; private set; } + public static RangeCommandImplementor Instance { get; private set; } public override void Execute(CommandEventArgs e) { diff --git a/Projects/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs b/Projects/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs index 5996b1466..7b0f9133f 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/SerialCommandImplementor.cs @@ -46,25 +46,25 @@ namespace Server.Commands.Generic switch (command.ObjectTypes) { case ObjectTypes.Items: - { - if (!(obj is Item)) { - e.Mobile.SendMessage("This command only works on items."); - return; - } + if (!(obj is Item)) + { + e.Mobile.SendMessage("This command only works on items."); + return; + } - break; - } + break; + } case ObjectTypes.Mobiles: - { - if (!(obj is Mobile)) { - e.Mobile.SendMessage("This command only works on mobiles."); - return; - } + if (!(obj is Mobile)) + { + e.Mobile.SendMessage("This command only works on mobiles."); + return; + } - break; - } + break; + } } string[] oldArgs = e.Arguments; diff --git a/Projects/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs b/Projects/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs index bf8439168..a68146727 100644 --- a/Projects/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs +++ b/Projects/Scripts/Commands/Generic/Implementors/SingleCommandImplementor.cs @@ -52,35 +52,35 @@ namespace Server.Commands.Generic switch (command.ObjectTypes) { case ObjectTypes.Both: - { - if (!(targeted is Item) && !(targeted is Mobile)) { - from.SendMessage("This command does not work on that."); - return; - } + if (!(targeted is Item) && !(targeted is Mobile)) + { + from.SendMessage("This command does not work on that."); + return; + } - break; - } + break; + } case ObjectTypes.Items: - { - if (!(targeted is Item)) { - from.SendMessage("This command only works on items."); - return; - } + if (!(targeted is Item)) + { + from.SendMessage("This command only works on items."); + return; + } - break; - } + break; + } case ObjectTypes.Mobiles: - { - if (!(targeted is Mobile)) { - from.SendMessage("This command only works on mobiles."); - return; - } + if (!(targeted is Mobile)) + { + from.SendMessage("This command only works on mobiles."); + return; + } - break; - } + break; + } } RunCommand(from, targeted, command, args); diff --git a/Projects/Scripts/Commands/Handlers.cs b/Projects/Scripts/Commands/Handlers.cs index f1540b499..48d3cfad1 100644 --- a/Projects/Scripts/Commands/Handlers.cs +++ b/Projects/Scripts/Commands/Handlers.cs @@ -287,7 +287,7 @@ namespace Server.Commands foreach (Mobile m in World.Mobiles.Values) if (m is BaseCreature bc) - if (bc.Controlled && bc.ControlMaster == master || bc.Summoned && bc.SummonMaster == master) + if ((bc.Controlled && bc.ControlMaster == master) || (bc.Summoned && bc.SummonMaster == master)) pets.Add(bc); if (pets.Count > 0) @@ -408,7 +408,7 @@ namespace Server.Commands AutoSave.Save(true); } - private static bool FixMap(ref Map map, ref Point3D loc, Item item) => map != null && map != Map.Internal || item.RootParent is Mobile m && FixMap(ref map, ref loc, m); + private static bool FixMap(ref Map map, ref Point3D loc, Item item) => (map != null && map != Map.Internal) || (item.RootParent is Mobile m && FixMap(ref map, ref loc, m)); private static bool FixMap(ref Map map, ref Point3D loc, Mobile m) { @@ -782,7 +782,7 @@ namespace Server.Commands private class EquipMenu : ItemListMenu { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public EquipMenu(Mobile from, Mobile m, ItemListEntry[] entries) : base("Equipment", entries) { @@ -804,8 +804,8 @@ namespace Server.Commands private class EquipDetailsMenu : QuestionMenu { - private Item m_Item; - private Mobile m_Mobile; + private readonly Item m_Item; + private readonly Mobile m_Mobile; public EquipDetailsMenu(Mobile m, Item item) : base($"{item.Layer}: {item.GetType().Name}", new[] { "Move", "Delete", "Props" }) diff --git a/Projects/Scripts/Commands/HelpInfo.cs b/Projects/Scripts/Commands/HelpInfo.cs index a868edf7e..48dab2c5f 100644 --- a/Projects/Scripts/Commands/HelpInfo.cs +++ b/Projects/Scripts/Commands/HelpInfo.cs @@ -11,9 +11,9 @@ namespace Server.Commands { public class HelpInfo { - public static Dictionary HelpInfos{ get; } = new Dictionary(); + public static Dictionary HelpInfos { get; } = new Dictionary(); - public static List SortedHelpInfo{ get; private set; } = new List(); + public static List SortedHelpInfo { get; private set; } = new List(); [CallPriority(100)] public static void Initialize() @@ -106,7 +106,6 @@ namespace Server.Commands } } - for (int i = 0; i < TargetCommands.AllCommands.Count; ++i) { BaseCommand command = TargetCommands.AllCommands[i]; @@ -221,9 +220,9 @@ namespace Server.Commands public class CommandListGump : BaseGridGump { private const int EntriesPerPage = 15; - private List m_List; + private readonly List m_List; - private int m_Page; + private readonly int m_Page; public CommandListGump(int page, Mobile from, List list) : base(30, 30) @@ -290,51 +289,50 @@ namespace Server.Commands switch (info.ButtonID) { case 0: - { - m.CloseGump(); - break; - } - case 1: - { - if (m_Page > 0) - m.SendGump(new CommandListGump(m_Page - 1, m, m_List)); - - break; - } - case 2: - { - if ((m_Page + 1) * EntriesPerPage < SortedHelpInfo.Count) - m.SendGump(new CommandListGump(m_Page + 1, m, m_List)); - - break; - } - default: - { - int v = info.ButtonID - 3; - - if (v >= 0 && v < m_List.Count) { - CommandInfo c = m_List[v]; - - if (m.AccessLevel >= c.AccessLevel) - { - m.SendGump(new CommandInfoGump(c)); - m.SendGump(new CommandListGump(m_Page, m, m_List)); - } - else - { - m.SendMessage("You no longer have access to that command."); - m.SendGump(new CommandListGump(m_Page, m, null)); - } + m.CloseGump(); + break; } + case 1: + { + if (m_Page > 0) + m.SendGump(new CommandListGump(m_Page - 1, m, m_List)); - break; - } + break; + } + case 2: + { + if ((m_Page + 1) * EntriesPerPage < SortedHelpInfo.Count) + m.SendGump(new CommandListGump(m_Page + 1, m, m_List)); + + break; + } + default: + { + int v = info.ButtonID - 3; + + if (v >= 0 && v < m_List.Count) + { + CommandInfo c = m_List[v]; + + if (m.AccessLevel >= c.AccessLevel) + { + m.SendGump(new CommandInfoGump(c)); + m.SendGump(new CommandListGump(m_Page, m, m_List)); + } + else + { + m.SendMessage("You no longer have access to that command."); + m.SendGump(new CommandListGump(m_Page, m, null)); + } + } + + break; + } } } } - public class CommandInfoGump : Gump { public CommandInfoGump(CommandInfo info, int width = 320, int height = 200) @@ -344,13 +342,13 @@ namespace Server.Commands AddBackground(0, 0, width, height, 5054); - //AddImageTiled( 10, 10, width - 20, 20, 2624 ); - //AddAlphaRegion( 10, 10, width - 20, 20 ); - //AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false ); + // AddImageTiled( 10, 10, width - 20, 20, 2624 ); + // AddAlphaRegion( 10, 10, width - 20, 20 ); + // AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false ); AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000)); - //AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); - //AddAlphaRegion( 10, 40, width - 20, height - 80 ); + // AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); + // AddAlphaRegion( 10, 40, width - 20, height - 80 ); StringBuilder sb = new StringBuilder(); @@ -384,8 +382,8 @@ namespace Server.Commands AddHtml(10, 40, width - 20, height - 80, sb.ToString(), false, true); - //AddImageTiled( 10, height - 30, width - 20, 20, 2624 ); - //AddAlphaRegion( 10, height - 30, width - 20, 20 ); + // AddImageTiled( 10, height - 30, width - 20, 20, 2624 ); + // AddAlphaRegion( 10, height - 30, width - 20, 20 ); } public string Color(string text, int color) => $"{text}"; diff --git a/Projects/Scripts/Commands/LocationCommand.cs b/Projects/Scripts/Commands/LocationCommand.cs index 8cfc78ebe..c34251bea 100644 --- a/Projects/Scripts/Commands/LocationCommand.cs +++ b/Projects/Scripts/Commands/LocationCommand.cs @@ -1,14 +1,14 @@ using System.Collections.Generic; +using System.Globalization; using Server.Commands.Generic; using Server.Items; using Server.Targeting; -using System.Globalization; namespace Server.Commands { public class LocationCommand : BaseCommand { - private static readonly List m_DefaultGraphics = new List{ 0x17AF, 0x17B0, 0x17B1, 0x17B2 }; + private static readonly List m_DefaultGraphics = new List { 0x17AF, 0x17B0, 0x17B1, 0x17B2 }; public LocationCommand() { diff --git a/Projects/Scripts/Commands/Logging.cs b/Projects/Scripts/Commands/Logging.cs index 8c4f09b86..7fc535d9a 100644 --- a/Projects/Scripts/Commands/Logging.cs +++ b/Projects/Scripts/Commands/Logging.cs @@ -7,10 +7,10 @@ namespace Server.Commands { public class CommandLogging { - private static char[] m_NotSafe = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }; - public static bool Enabled{ get; set; } = true; + private static readonly char[] m_NotSafe = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }; + public static bool Enabled { get; set; } = true; - public static StreamWriter Output{ get; private set; } + public static StreamWriter Output { get; private set; } public static void Initialize() { diff --git a/Projects/Scripts/Commands/Profiling.cs b/Projects/Scripts/Commands/Profiling.cs index 470c8b698..3479ff868 100644 --- a/Projects/Scripts/Commands/Profiling.cs +++ b/Projects/Scripts/Commands/Profiling.cs @@ -6,7 +6,7 @@ using Server.Diagnostics; namespace Server.Commands { - public class Profiling + public static class Profiling { public static void Initialize() { @@ -168,10 +168,10 @@ namespace Server.Commands if ((flags & ExpandFlag.Blessed) != 0) ++countTable[4]; - /*if ( ( flags & ExpandFlag.TempFlag ) != 0 ) + /*if (( flags & ExpandFlag.TempFlag ) != 0) ++countTable[5]; - if ( ( flags & ExpandFlag.SaveFlag ) != 0 ) + if (( flags & ExpandFlag.SaveFlag ) != 0) ++countTable[6];*/ if ((flags & ExpandFlag.Weight) != 0) @@ -243,7 +243,8 @@ namespace Server.Commands { parms[0]++; parms[1] += item.Amount; - } else + } + else table[type] = new[] { 1, item.Amount }; } diff --git a/Projects/Scripts/Commands/Properties.cs b/Projects/Scripts/Commands/Properties.cs index a06b3d60a..377428cc8 100644 --- a/Projects/Scripts/Commands/Properties.cs +++ b/Projects/Scripts/Commands/Properties.cs @@ -18,25 +18,25 @@ namespace Server.Commands public static class Properties { - private static Type typeofCPA = typeof(CPA); + private static readonly Type typeofCPA = typeof(CPA); - private static Type typeofSerial = typeof(Serial); + private static readonly Type typeofSerial = typeof(Serial); - private static Type typeofType = typeof(Type); + private static readonly Type typeofType = typeof(Type); - private static Type typeofChar = typeof(char); + private static readonly Type typeofChar = typeof(char); - private static Type typeofString = typeof(string); + private static readonly Type typeofString = typeof(string); - private static Type typeofText = typeof(TextDefinition); + private static readonly Type typeofText = typeof(TextDefinition); - private static Type typeofTimeSpan = typeof(TimeSpan); - private static Type typeofParsable = typeof(ParsableAttribute); + private static readonly Type typeofTimeSpan = typeof(TimeSpan); + private static readonly Type typeofParsable = typeof(ParsableAttribute); - private static Type[] m_ParseTypes = { typeof(string) }; - private static object[] m_ParseParams = new object[1]; + private static readonly Type[] m_ParseTypes = { typeof(string) }; + private static readonly object[] m_ParseParams = new object[1]; - private static Type[] m_NumericTypes = + private static readonly Type[] m_NumericTypes = { typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), @@ -602,8 +602,8 @@ namespace Server { } - public AccessLevel PlayerAccess{ get; set; } - public AccessLevel NeededAccess{ get; set; } + public AccessLevel PlayerAccess { get; set; } + public AccessLevel NeededAccess { get; set; } } public sealed class ReadAccessException : ClearanceException @@ -630,11 +630,11 @@ namespace Server public Property(PropertyInfo[] chain) => m_Chain = chain; - public string Binding{ get; } + public string Binding { get; } public bool IsBound => m_Chain != null; - public PropertyAccess Access{ get; private set; } + public PropertyAccess Access { get; private set; } public PropertyInfo[] Chain { diff --git a/Projects/Scripts/Commands/SignParser.cs b/Projects/Scripts/Commands/SignParser.cs index 0eaf271b3..d4c1fcd00 100644 --- a/Projects/Scripts/Commands/SignParser.cs +++ b/Projects/Scripts/Commands/SignParser.cs @@ -6,7 +6,7 @@ namespace Server.Commands { public class SignParser { - private static Queue m_ToDelete = new Queue(); + private static readonly Queue m_ToDelete = new Queue(); public static void Initialize() { @@ -119,10 +119,10 @@ namespace Server.Commands private class SignEntry { - public int m_ItemID; - public Point3D m_Location; - public int m_Map; - public string m_Text; + public readonly int m_ItemID; + public readonly Point3D m_Location; + public readonly int m_Map; + public readonly string m_Text; public SignEntry(string text, Point3D pt, int itemID, int mapLoc) { diff --git a/Projects/Scripts/Commands/Skills.cs b/Projects/Scripts/Commands/Skills.cs index 7decdfc6f..f427111fc 100644 --- a/Projects/Scripts/Commands/Skills.cs +++ b/Projects/Scripts/Commands/Skills.cs @@ -58,7 +58,7 @@ namespace Server.Commands public class AllSkillsTarget : Target { - private double m_Value; + private readonly double m_Value; public AllSkillsTarget(double value) : base(-1, false, TargetFlags.None) => m_Value = value; @@ -82,9 +82,9 @@ namespace Server.Commands public class SkillTarget : Target { - private bool m_Set; - private SkillName m_Skill; - private double m_Value; + private readonly bool m_Set; + private readonly SkillName m_Skill; + private readonly double m_Value; public SkillTarget(SkillName skill, double value) : base(-1, false, TargetFlags.None) { diff --git a/Projects/Scripts/Commands/Statics.cs b/Projects/Scripts/Commands/Statics.cs index 476f96790..790146bb2 100644 --- a/Projects/Scripts/Commands/Statics.cs +++ b/Projects/Scripts/Commands/Statics.cs @@ -28,7 +28,7 @@ namespace Server "It is strongly recommended that you make backup of the data files mentioned above. " + "Do you wish to proceed?"; - private static Point3D NullP3D = new Point3D(int.MinValue, int.MinValue, int.MinValue); + private static readonly Point3D NullP3D = new Point3D(int.MinValue, int.MinValue, int.MinValue); private static byte[] m_Buffer; @@ -45,7 +45,7 @@ namespace Server CommandSystem.Register("UnfreezeWorld", AccessLevel.Administrator, UnfreezeWorld_OnCommand); } - public delegate void FreezeCallback( Mobile from, bool okay, StateInfo si ); + public delegate void FreezeCallback(Mobile from, bool okay, StateInfo si); [Usage("Freeze")] [Description("Makes a targeted area of dynamic items static.")] @@ -361,79 +361,79 @@ namespace Server BinaryWriter mulWriter = new BinaryWriter(mulStream); for (int x = xStartBlock; x <= xEndBlock; ++x) - for (int y = yStartBlock; y <= yEndBlock; ++y) - { - StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, x, y, matrix.BlockWidth, - matrix.BlockHeight, out int oldTileCount); - - if (oldTileCount < 0) - continue; - - int newTileCount = 0; - StaticTile[] newTiles = new StaticTile[oldTileCount]; - - int baseX = (x << 3) - xTileStart, baseY = (y << 3) - yTileStart; - - for (int i = 0; i < oldTileCount; ++i) + for (int y = yStartBlock; y <= yEndBlock; ++y) { - StaticTile oldTile = oldTiles[i]; + StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, x, y, matrix.BlockWidth, + matrix.BlockHeight, out int oldTileCount); - int px = baseX + oldTile.X; - int py = baseY + oldTile.Y; + if (oldTileCount < 0) + continue; - if (px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight) + int newTileCount = 0; + StaticTile[] newTiles = new StaticTile[oldTileCount]; + + int baseX = (x << 3) - xTileStart, baseY = (y << 3) - yTileStart; + + for (int i = 0; i < oldTileCount; ++i) { - newTiles[newTileCount++] = oldTile; + StaticTile oldTile = oldTiles[i]; + + int px = baseX + oldTile.X; + int py = baseY + oldTile.Y; + + if (px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight) + { + newTiles[newTileCount++] = oldTile; + } + else + { + ++totalUnfrozen; + + Item item = new Static(oldTile.ID); + + item.Hue = oldTile.Hue; + + item.MoveToWorld(new Point3D(px + xTileStart, py + yTileStart, oldTile.Z), map); + } } - else + + int mulPos = -1; + int length = -1; + int extra = 0; + + if (newTileCount > 0) { - ++totalUnfrozen; + mulWriter.Seek(0, SeekOrigin.End); - Item item = new Static(oldTile.ID); + mulPos = (int)mulWriter.BaseStream.Position; + length = newTileCount * 7; + extra = 1; - item.Hue = oldTile.Hue; + for (int i = 0; i < newTileCount; ++i) + { + StaticTile toWrite = newTiles[i]; - item.MoveToWorld(new Point3D(px + xTileStart, py + yTileStart, oldTile.Z), map); + mulWriter.Write((ushort)toWrite.ID); + mulWriter.Write((byte)toWrite.X); + mulWriter.Write((byte)toWrite.Y); + mulWriter.Write((sbyte)toWrite.Z); + mulWriter.Write((short)toWrite.Hue); + } + + mulWriter.Flush(); } + + int idxPos = (x * matrix.BlockHeight + y) * 12; + + idxWriter.Seek(idxPos, SeekOrigin.Begin); + idxWriter.Write(mulPos); + idxWriter.Write(length); + idxWriter.Write(extra); + + idxWriter.Flush(); + + matrix.SetStaticBlock(x, y, null); } - - int mulPos = -1; - int length = -1; - int extra = 0; - - if (newTileCount > 0) - { - mulWriter.Seek(0, SeekOrigin.End); - - mulPos = (int)mulWriter.BaseStream.Position; - length = newTileCount * 7; - extra = 1; - - for (int i = 0; i < newTileCount; ++i) - { - StaticTile toWrite = newTiles[i]; - - mulWriter.Write((ushort)toWrite.ID); - mulWriter.Write((byte)toWrite.X); - mulWriter.Write((byte)toWrite.Y); - mulWriter.Write((sbyte)toWrite.Z); - mulWriter.Write((short)toWrite.Hue); - } - - mulWriter.Flush(); - } - - int idxPos = (x * matrix.BlockHeight + y) * 12; - - idxWriter.Seek(idxPos, SeekOrigin.Begin); - idxWriter.Write(mulPos); - idxWriter.Write(length); - idxWriter.Write(extra); - - idxWriter.Flush(); - - matrix.SetStaticBlock(x, y, null); - } } public static void DoUnfreeze(Map map, ref bool badDataFile, ref int totalUnfrozen) @@ -551,8 +551,9 @@ namespace Server private class DeltaState { - public List m_List; - public int m_X, m_Y; + public readonly List m_List; + public readonly int m_X; + public readonly int m_Y; public DeltaState(Point2D p) { diff --git a/Projects/Scripts/Commands/Wipe.cs b/Projects/Scripts/Commands/Wipe.cs index eec17443b..6eb0179e7 100644 --- a/Projects/Scripts/Commands/Wipe.cs +++ b/Projects/Scripts/Commands/Wipe.cs @@ -72,9 +72,9 @@ namespace Server.Commands IPooledEnumerable eable; - if (!items && !multis || !mobiles) + if ((!items && !multis) || !mobiles) return; - + eable = map.GetObjectsInBounds(rect); foreach (IEntity obj in eable) diff --git a/Projects/Scripts/Context Menus/AddToParty.cs b/Projects/Scripts/Context Menus/AddToParty.cs index c35817acc..c5a1c3535 100644 --- a/Projects/Scripts/Context Menus/AddToParty.cs +++ b/Projects/Scripts/Context Menus/AddToParty.cs @@ -4,8 +4,8 @@ namespace Server.ContextMenus { public class AddToPartyEntry : ContextMenuEntry { - private Mobile m_From; - private Mobile m_Target; + private readonly Mobile m_From; + private readonly Mobile m_Target; public AddToPartyEntry(Mobile from, Mobile target) : base(0197, 12) { diff --git a/Projects/Scripts/Context Menus/AddToSpellbookEntry.cs b/Projects/Scripts/Context Menus/AddToSpellbookEntry.cs index 18d1e0b35..415ebda76 100644 --- a/Projects/Scripts/Context Menus/AddToSpellbookEntry.cs +++ b/Projects/Scripts/Context Menus/AddToSpellbookEntry.cs @@ -18,7 +18,7 @@ namespace Server.ContextMenus private class InternalTarget : Target { - private SpellScroll m_Scroll; + private readonly SpellScroll m_Scroll; public InternalTarget(SpellScroll scroll) : base(3, false, TargetFlags.None) => m_Scroll = scroll; diff --git a/Projects/Scripts/Context Menus/EatEntry.cs b/Projects/Scripts/Context Menus/EatEntry.cs index f7b63a902..ed9fe1165 100644 --- a/Projects/Scripts/Context Menus/EatEntry.cs +++ b/Projects/Scripts/Context Menus/EatEntry.cs @@ -4,8 +4,8 @@ namespace Server.ContextMenus { public class EatEntry : ContextMenuEntry { - private Food m_Food; - private Mobile m_From; + private readonly Food m_Food; + private readonly Mobile m_From; public EatEntry(Mobile from, Food food) : base(6135, 1) { diff --git a/Projects/Scripts/Context Menus/EjectPlayer.cs b/Projects/Scripts/Context Menus/EjectPlayer.cs index 7573aa5a9..343d2ea75 100644 --- a/Projects/Scripts/Context Menus/EjectPlayer.cs +++ b/Projects/Scripts/Context Menus/EjectPlayer.cs @@ -4,9 +4,9 @@ namespace Server.ContextMenus { public class EjectPlayerEntry : ContextMenuEntry { - private Mobile m_From; - private Mobile m_Target; - private BaseHouse m_TargetHouse; + private readonly Mobile m_From; + private readonly Mobile m_Target; + private readonly BaseHouse m_TargetHouse; public EjectPlayerEntry(Mobile from, Mobile target) : base(6206, 12) { diff --git a/Projects/Scripts/Context Menus/OpenBankEntry.cs b/Projects/Scripts/Context Menus/OpenBankEntry.cs index a58153bae..a7b19b7ed 100644 --- a/Projects/Scripts/Context Menus/OpenBankEntry.cs +++ b/Projects/Scripts/Context Menus/OpenBankEntry.cs @@ -2,7 +2,7 @@ namespace Server.ContextMenus { public class OpenBankEntry : ContextMenuEntry { - private Mobile m_Banker; + private readonly Mobile m_Banker; public OpenBankEntry(Mobile from, Mobile banker) : base(6105, 12) => m_Banker = banker; diff --git a/Projects/Scripts/Context Menus/TeachEntry.cs b/Projects/Scripts/Context Menus/TeachEntry.cs index 03f0f5325..e44d8ff84 100644 --- a/Projects/Scripts/Context Menus/TeachEntry.cs +++ b/Projects/Scripts/Context Menus/TeachEntry.cs @@ -5,9 +5,9 @@ namespace Server.ContextMenus { public class TeachEntry : ContextMenuEntry { - private Mobile m_From; - private BaseCreature m_Mobile; - private SkillName m_Skill; + private readonly Mobile m_From; + private readonly BaseCreature m_Mobile; + private readonly SkillName m_Skill; public TeachEntry(SkillName skill, BaseCreature m, Mobile from, bool enabled) : base(6000 + (int)skill) { diff --git a/Projects/Scripts/Engines/BulkOrders/BODTarget.cs b/Projects/Scripts/Engines/BulkOrders/BODTarget.cs index 71b6e9625..997c9e070 100644 --- a/Projects/Scripts/Engines/BulkOrders/BODTarget.cs +++ b/Projects/Scripts/Engines/BulkOrders/BODTarget.cs @@ -4,7 +4,7 @@ namespace Server.Engines.BulkOrders { public class BODTarget : Target { - private BaseBOD m_Deed; + private readonly BaseBOD m_Deed; public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None) => m_Deed = deed; @@ -15,7 +15,7 @@ namespace Server.Engines.BulkOrders if (!(targeted is Item item && item.IsChildOf(from.Backpack))) { - from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it. + from.SendLocalizedMessage(1045158); // You must have the item in your backpack to target it. return; } diff --git a/Projects/Scripts/Engines/BulkOrders/BaseBOD.cs b/Projects/Scripts/Engines/BulkOrders/BaseBOD.cs index 135218b0e..d6c2e61d0 100644 --- a/Projects/Scripts/Engines/BulkOrders/BaseBOD.cs +++ b/Projects/Scripts/Engines/BulkOrders/BaseBOD.cs @@ -12,9 +12,9 @@ namespace Server.Engines.BulkOrders { double random = Utility.RandomDouble(); - for ( int i = 0; i < chances.Length; ++i ) + for (int i = 0; i < chances.Length; ++i) { - if ( random < chances[i] ) + if (random < chances[i]) return i == 0 ? BulkMaterialType.None : start + (i - 1); random -= chances[i]; @@ -41,30 +41,30 @@ namespace Server.Engines.BulkOrders { } - public abstract bool Complete{ get; } + public abstract bool Complete { get; } [CommandProperty(AccessLevel.GameMaster)] - public sealed override int Hue{ get; set; } + public sealed override int Hue { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int AmountMax { get => m_AmountMax; - set{ m_AmountMax = value; InvalidateProperties(); } + set { m_AmountMax = value; InvalidateProperties(); } } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public bool RequireExceptional { get => m_RequireExceptional; - set{ m_RequireExceptional = value; InvalidateProperties(); } + set { m_RequireExceptional = value; InvalidateProperties(); } } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public BulkMaterialType Material { get => m_Material; - set{ m_Material = value; InvalidateProperties(); } + set { m_Material = value; InvalidateProperties(); } } public abstract RewardGroup GetRewardGroup(); @@ -118,35 +118,35 @@ namespace Server.Engines.BulkOrders from.Target = new BODTarget(this); } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.WriteEncodedInt( 0 ); // version + writer.WriteEncodedInt(0); // version - writer.Write( m_AmountMax ); - writer.Write( m_RequireExceptional ); - writer.Write( (int) m_Material ); + writer.Write(m_AmountMax); + writer.Write(m_RequireExceptional); + writer.Write((int)m_Material); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadEncodedInt(); - switch ( version ) + switch (version) { case 0: - { - m_AmountMax = reader.ReadInt(); - m_RequireExceptional = reader.ReadBool(); - m_Material = (BulkMaterialType)reader.ReadInt(); - break; - } + { + m_AmountMax = reader.ReadInt(); + m_RequireExceptional = reader.ReadBool(); + m_Material = (BulkMaterialType)reader.ReadInt(); + break; + } } - if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero ) + if (Parent == null && Map == Map.Internal && Location == Point3D.Zero) Delete(); } } diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BOBFilter.cs b/Projects/Scripts/Engines/BulkOrders/Books/BOBFilter.cs index 92283d5a1..f7aa9da41 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BOBFilter.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BOBFilter.cs @@ -13,26 +13,26 @@ namespace Server.Engines.BulkOrders switch (version) { case 1: - { - Type = reader.ReadEncodedInt(); - Quality = reader.ReadEncodedInt(); - Material = reader.ReadEncodedInt(); - Quantity = reader.ReadEncodedInt(); + { + Type = reader.ReadEncodedInt(); + Quality = reader.ReadEncodedInt(); + Material = reader.ReadEncodedInt(); + Quantity = reader.ReadEncodedInt(); - break; - } + break; + } } } public bool IsDefault => Type == 0 && Quality == 0 && Material == 0 && Quantity == 0; - public int Type{ get; set; } + public int Type { get; set; } - public int Quality{ get; set; } + public int Quality { get; set; } - public int Material{ get; set; } + public int Material { get; set; } - public int Quantity{ get; set; } + public int Quantity { get; set; } public void Clear() { diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs b/Projects/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs index 4a87e82cd..ed5c063b2 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BOBFilterGump.cs @@ -8,7 +8,7 @@ namespace Server.Engines.BulkOrders { private const int LabelColor = 0x7FFF; - private static int[,] m_MaterialFilters = + private static readonly int[,] m_MaterialFilters = { { 1044067, 1 }, // Blacksmithy { 1062226, 3 }, // Iron @@ -16,14 +16,12 @@ namespace Server.Engines.BulkOrders { 1018333, 5 }, // Shadow Iron { 1018334, 6 }, // Copper { 1018335, 7 }, // Bronze - { 0, 0 }, // --Blank-- { 1018336, 8 }, // Golden { 1018337, 9 }, // Agapite { 1018338, 10 }, // Verite { 1018339, 11 }, // Valorite { 0, 0 }, // --Blank-- - { 1044094, 2 }, // Tailoring { 1044286, 12 }, // Cloth { 1062235, 13 }, // Leather @@ -32,21 +30,21 @@ namespace Server.Engines.BulkOrders { 1062238, 16 } // Barbed }; - private static int[,] m_TypeFilters = + private static readonly int[,] m_TypeFilters = { { 1062229, 0 }, // All { 1062224, 1 }, // Small { 1062225, 2 } // Large }; - private static int[,] m_QualityFilters = + private static readonly int[,] m_QualityFilters = { { 1062229, 0 }, // All { 1011542, 1 }, // Normal { 1060636, 2 } // Exceptional }; - private static int[,] m_AmountFilters = + private static readonly int[,] m_AmountFilters = { { 1062229, 0 }, // All { 1049706, 1 }, // 10 @@ -54,7 +52,7 @@ namespace Server.Engines.BulkOrders { 1062239, 3 } // 20 }; - private static int[][,] m_Filters = + private static readonly int[][,] m_Filters = { m_TypeFilters, m_QualityFilters, @@ -62,15 +60,15 @@ namespace Server.Engines.BulkOrders m_AmountFilters }; - private static int[] m_XOffsets_Type = { 0, 75, 170 }; - private static int[] m_XOffsets_Quality = { 0, 75, 170 }; - private static int[] m_XOffsets_Amount = { 0, 75, 180, 275 }; - private static int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 }; + private static readonly int[] m_XOffsets_Type = { 0, 75, 170 }; + private static readonly int[] m_XOffsets_Quality = { 0, 75, 170 }; + private static readonly int[] m_XOffsets_Amount = { 0, 75, 180, 275 }; + private static readonly int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 }; - private static int[] m_XWidths_Small = { 50, 50, 70, 50 }; - private static int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 }; - private BulkOrderBook m_Book; - private PlayerMobile m_From; + private static readonly int[] m_XWidths_Small = { 50, 50, 70, 50 }; + private static readonly int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 }; + private readonly BulkOrderBook m_Book; + private readonly PlayerMobile m_From; public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24) { @@ -132,7 +130,7 @@ namespace Server.Engines.BulkOrders continue; bool isSelected = filters[i, 1] == filterValue || - i % xOffsets.Length == 0 && filterValue == 0; + (i % xOffsets.Length == 0 && filterValue == 0); AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor); @@ -150,70 +148,70 @@ namespace Server.Engines.BulkOrders switch (index) { case 0: // Apply - { - m_From.SendGump(new BOBGump(m_From, m_Book)); - - break; - } - case 1: // Set Book Filter - { - m_From.UseOwnFilter = false; - m_From.SendGump(new BOBFilterGump(m_From, m_Book)); - - break; - } - case 2: // Set Your Filter - { - m_From.UseOwnFilter = true; - m_From.SendGump(new BOBFilterGump(m_From, m_Book)); - - break; - } - case 3: // Clear Filter - { - f.Clear(); - m_From.SendGump(new BOBFilterGump(m_From, m_Book)); - - break; - } - default: - { - index -= 4; - - int type = index % 4; - index /= 4; - - if (type >= 0 && type < m_Filters.Length) { - int[,] filters = m_Filters[type]; + m_From.SendGump(new BOBGump(m_From, m_Book)); - if (index >= 0 && index < filters.GetLength(0)) - { - if (filters[index, 0] == 0) - break; - - switch (type) - { - case 0: - f.Type = filters[index, 1]; - break; - case 1: - f.Quality = filters[index, 1]; - break; - case 2: - f.Material = filters[index, 1]; - break; - case 3: - f.Quantity = filters[index, 1]; - break; - } - - m_From.SendGump(new BOBFilterGump(m_From, m_Book)); - } + break; } + case 1: // Set Book Filter + { + m_From.UseOwnFilter = false; + m_From.SendGump(new BOBFilterGump(m_From, m_Book)); - break; - } + break; + } + case 2: // Set Your Filter + { + m_From.UseOwnFilter = true; + m_From.SendGump(new BOBFilterGump(m_From, m_Book)); + + break; + } + case 3: // Clear Filter + { + f.Clear(); + m_From.SendGump(new BOBFilterGump(m_From, m_Book)); + + break; + } + default: + { + index -= 4; + + int type = index % 4; + index /= 4; + + if (type >= 0 && type < m_Filters.Length) + { + int[,] filters = m_Filters[type]; + + if (index >= 0 && index < filters.GetLength(0)) + { + if (filters[index, 0] == 0) + break; + + switch (type) + { + case 0: + f.Type = filters[index, 1]; + break; + case 1: + f.Quality = filters[index, 1]; + break; + case 2: + f.Material = filters[index, 1]; + break; + case 3: + f.Quantity = filters[index, 1]; + break; + } + + m_From.SendGump(new BOBFilterGump(m_From, m_Book)); + } + } + + break; + } } } } diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BOBGump.cs b/Projects/Scripts/Engines/BulkOrders/Books/BOBGump.cs index 4cbab8357..d7fdbbd9e 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BOBGump.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BOBGump.cs @@ -11,9 +11,9 @@ namespace Server.Engines.BulkOrders public class BOBGump : Gump { private const int LabelColor = 0x7FFF; - private BulkOrderBook m_Book; - private PlayerMobile m_From; - private List m_List; + private readonly BulkOrderBook m_Book; + private readonly PlayerMobile m_From; + private readonly List m_List; private int m_Page; @@ -173,7 +173,7 @@ namespace Server.Engines.BulkOrders if (canDrop) AddButton(35, y + 2, 5602, 5606, 5 + i * 2); - if (canDrop || canBuy && entry.Price > 0) + if (canDrop || (canBuy && entry.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, entry.Price.ToString()); @@ -214,7 +214,7 @@ namespace Server.Engines.BulkOrders if (canDrop) AddButton(35, y + 2, 5602, 5606, 5 + i * 2); - if (canDrop || canBuy && smallEntry.Price > 0) + if (canDrop || (canBuy && smallEntry.Price > 0)) { AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddLabel(495, y, 1152, smallEntry.Price.ToString()); @@ -281,22 +281,22 @@ namespace Server.Engines.BulkOrders return f.Material switch { - 1 => (deedType == BODType.Smith), - 2 => (deedType == BODType.Tailor), - 3 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron), - 4 => (mat == BulkMaterialType.DullCopper), - 5 => (mat == BulkMaterialType.ShadowIron), - 6 => (mat == BulkMaterialType.Copper), - 7 => (mat == BulkMaterialType.Bronze), - 8 => (mat == BulkMaterialType.Gold), - 9 => (mat == BulkMaterialType.Agapite), - 10 => (mat == BulkMaterialType.Verite), - 11 => (mat == BulkMaterialType.Valorite), - 12 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth), - 13 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather), - 14 => (mat == BulkMaterialType.Spined), - 15 => (mat == BulkMaterialType.Horned), - 16 => (mat == BulkMaterialType.Barbed), + 1 => deedType == BODType.Smith, + 2 => deedType == BODType.Tailor, + 3 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron, + 4 => mat == BulkMaterialType.DullCopper, + 5 => mat == BulkMaterialType.ShadowIron, + 6 => mat == BulkMaterialType.Copper, + 7 => mat == BulkMaterialType.Bronze, + 8 => mat == BulkMaterialType.Gold, + 9 => mat == BulkMaterialType.Agapite, + 10 => mat == BulkMaterialType.Verite, + 11 => mat == BulkMaterialType.Valorite, + 12 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth, + 13 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather, + 14 => mat == BulkMaterialType.Spined, + 15 => mat == BulkMaterialType.Horned, + 16 => mat == BulkMaterialType.Barbed, _ => true }; } @@ -391,46 +391,45 @@ namespace Server.Engines.BulkOrders return page; } - public object GetMaterialName(BulkMaterialType mat, BODType type, Type itemType) { switch (type) { case BODType.Smith: - { - switch (mat) { - case BulkMaterialType.None: return 1062226; - case BulkMaterialType.DullCopper: return 1018332; - case BulkMaterialType.ShadowIron: return 1018333; - case BulkMaterialType.Copper: return 1018334; - case BulkMaterialType.Bronze: return 1018335; - case BulkMaterialType.Gold: return 1018336; - case BulkMaterialType.Agapite: return 1018337; - case BulkMaterialType.Verite: return 1018338; - case BulkMaterialType.Valorite: return 1018339; - } - - break; - } - case BODType.Tailor: - { - switch (mat) - { - case BulkMaterialType.None: + switch (mat) { - if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))) - return 1062235; - - return 1044286; + case BulkMaterialType.None: return 1062226; + case BulkMaterialType.DullCopper: return 1018332; + case BulkMaterialType.ShadowIron: return 1018333; + case BulkMaterialType.Copper: return 1018334; + case BulkMaterialType.Bronze: return 1018335; + case BulkMaterialType.Gold: return 1018336; + case BulkMaterialType.Agapite: return 1018337; + case BulkMaterialType.Verite: return 1018338; + case BulkMaterialType.Valorite: return 1018339; } - case BulkMaterialType.Spined: return 1062236; - case BulkMaterialType.Horned: return 1062237; - case BulkMaterialType.Barbed: return 1062238; - } - break; - } + break; + } + case BODType.Tailor: + { + switch (mat) + { + case BulkMaterialType.None: + { + if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))) + return 1062235; + + return 1044286; + } + case BulkMaterialType.Spined: return 1062236; + case BulkMaterialType.Horned: return 1062237; + case BulkMaterialType.Barbed: return 1062238; + } + + break; + } } return "Invalid"; @@ -443,148 +442,148 @@ namespace Server.Engines.BulkOrders switch (index) { case 0: // EXIT - { - break; - } + { + break; + } case 1: // Set Filter - { - m_From.SendGump(new BOBFilterGump(m_From, m_Book)); + { + m_From.SendGump(new BOBFilterGump(m_From, m_Book)); - break; - } + break; + } case 2: // Previous page - { - if (m_Page > 0) - m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List)); + { + if (m_Page > 0) + m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List)); - return; - } + return; + } case 3: // Next page - { - if (GetIndexForPage(m_Page + 1) < m_List.Count) - m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List)); + { + if (GetIndexForPage(m_Page + 1) < m_List.Count) + m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List)); - break; - } + break; + } case 4: // Price all - { - if (m_Book.IsChildOf(m_From.Backpack)) { - m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List); - m_From.SendMessage("Type in a price for all deeds in the book:"); - } + if (m_Book.IsChildOf(m_From.Backpack)) + { + m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List); + m_From.SendMessage("Type in a price for all deeds in the book:"); + } - break; - } + break; + } default: - { - index -= 5; - - int type = index % 2; - index /= 2; - - if (index < 0 || index >= m_List.Count) - break; - - IBOBEntry bobEntry = m_List[index]; - - if (!m_Book.Entries.Contains(bobEntry)) { - m_From.SendLocalizedMessage(1062382); // The deed selected is not available. - break; - } + index -= 5; - if (type == 0) // Drop - { - if (m_Book.IsChildOf(m_From.Backpack)) + int type = index % 2; + index /= 2; + + if (index < 0 || index >= m_List.Count) + break; + + IBOBEntry bobEntry = m_List[index]; + + if (!m_Book.Entries.Contains(bobEntry)) { - Item item = bobEntry.Reconstruct(); - - Container pack = m_From.Backpack; - if (pack?.CheckHold(m_From, item, true, true, 0, - item.PileWeight + item.TotalWeight) != true) - { - m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this - m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); - } - else - { - if (m_Book.IsChildOf(m_From.Backpack)) - { - int sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1; - - m_From.AddToBackpack(item); - m_From.SendLocalizedMessage( - 1045152); // The bulk order deed has been placed in your backpack. - m_Book.Entries.Remove(bobEntry); - m_Book.InvalidateProperties(); - - if (m_Book.Entries.Count / 5 < m_Book.ItemCount) - { - m_Book.ItemCount--; - m_Book.InvalidateItems(); - } - - if (m_Book.Entries.Count > 0) - { - m_Page = GetPageForIndex(index, sizeOfDroppedBod); - m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); - } - else - { - m_From.SendLocalizedMessage(1062381); // The book is empty. - } - } - } + m_From.SendLocalizedMessage(1062382); // The deed selected is not available. + break; } - } - else // Set Price | Buy - { - if (m_Book.IsChildOf(m_From.Backpack)) + + if (type == 0) // Drop { - m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List); - m_From.SendLocalizedMessage(1062383); // Type in a price for the deed: - } - else if (m_Book.RootParent is PlayerVendor pv) - { - VendorItem vi = pv.GetVendorItem(m_Book); - - if (vi?.IsForSale != false) - return; - - int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; - int price = bobEntry.Price; - - if (price == 0) + if (m_Book.IsChildOf(m_From.Backpack)) { - m_From.SendLocalizedMessage(1062382); // The deed selected is not available. - } - else - { - if (m_Book.Entries.Count > 0) + Item item = bobEntry.Reconstruct(); + + Container pack = m_From.Backpack; + if (pack?.CheckHold(m_From, item, true, true, 0, + item.PileWeight + item.TotalWeight) != true) { - m_Page = GetPageForIndex(index, sizeOfDroppedBod); - m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price)); + m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this + m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); } else { - m_From.SendLocalizedMessage(1062381); // The book is emptz + if (m_Book.IsChildOf(m_From.Backpack)) + { + int sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1; + + m_From.AddToBackpack(item); + m_From.SendLocalizedMessage( + 1045152); // The bulk order deed has been placed in your backpack. + m_Book.Entries.Remove(bobEntry); + m_Book.InvalidateProperties(); + + if (m_Book.Entries.Count / 5 < m_Book.ItemCount) + { + m_Book.ItemCount--; + m_Book.InvalidateItems(); + } + + if (m_Book.Entries.Count > 0) + { + m_Page = GetPageForIndex(index, sizeOfDroppedBod); + m_From.SendGump(new BOBGump(m_From, m_Book, m_Page)); + } + else + { + m_From.SendLocalizedMessage(1062381); // The book is empty. + } + } } } } - } + else // Set Price | Buy + { + if (m_Book.IsChildOf(m_From.Backpack)) + { + m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List); + m_From.SendLocalizedMessage(1062383); // Type in a price for the deed: + } + else if (m_Book.RootParent is PlayerVendor pv) + { + VendorItem vi = pv.GetVendorItem(m_Book); - break; - } + if (vi?.IsForSale != false) + return; + + int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1; + int price = bobEntry.Price; + + if (price == 0) + { + m_From.SendLocalizedMessage(1062382); // The deed selected is not available. + } + else + { + if (m_Book.Entries.Count > 0) + { + m_Page = GetPageForIndex(index, sizeOfDroppedBod); + m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price)); + } + else + { + m_From.SendLocalizedMessage(1062381); // The book is emptz + } + } + } + } + + break; + } } } private class SetPricePrompt : Prompt { - private BulkOrderBook m_Book; - private List m_List; - private IBOBEntry m_Entry; - private int m_Page; + private readonly BulkOrderBook m_Book; + private readonly List m_List; + private readonly IBOBEntry m_Entry; + private readonly int m_Page; public SetPricePrompt(BulkOrderBook book, IBOBEntry entry, int page, List list) { diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs b/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs index db0f151dc..247f9dc6c 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeEntry.cs @@ -1,6 +1,6 @@ namespace Server.Engines.BulkOrders { - public class BOBLargeEntry: IBOBEntry + public class BOBLargeEntry : IBOBEntry { public BOBLargeEntry(LargeBOD bod) { @@ -27,36 +27,36 @@ namespace Server.Engines.BulkOrders switch (version) { case 0: - { - RequireExceptional = reader.ReadBool(); + { + RequireExceptional = reader.ReadBool(); - DeedType = (BODType)reader.ReadEncodedInt(); + DeedType = (BODType)reader.ReadEncodedInt(); - Material = (BulkMaterialType)reader.ReadEncodedInt(); - AmountMax = reader.ReadEncodedInt(); - Price = reader.ReadEncodedInt(); + Material = (BulkMaterialType)reader.ReadEncodedInt(); + AmountMax = reader.ReadEncodedInt(); + Price = reader.ReadEncodedInt(); - Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()]; + Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()]; - for (int i = 0; i < Entries.Length; ++i) - Entries[i] = new BOBLargeSubEntry(reader); + for (int i = 0; i < Entries.Length; ++i) + Entries[i] = new BOBLargeSubEntry(reader); - break; - } + break; + } } } - public bool RequireExceptional{ get; } + public bool RequireExceptional { get; } - public BODType DeedType{ get; } + public BODType DeedType { get; } - public BulkMaterialType Material{ get; } + public BulkMaterialType Material { get; } - public int AmountMax{ get; } + public int AmountMax { get; } - public int Price{ get; set; } + public int Price { get; set; } - public BOBLargeSubEntry[] Entries{ get; } + public BOBLargeSubEntry[] Entries { get; } public Item Reconstruct() { @@ -79,7 +79,8 @@ namespace Server.Engines.BulkOrders for (int i = 0; i < Entries.Length; ++i) entries[i] = new LargeBulkEntry(null, - new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic)) { Amount = Entries[i].AmountCur }; + new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic)) + { Amount = Entries[i].AmountCur }; return entries; } diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeSubEntry.cs b/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeSubEntry.cs index 63a6539b5..ea818c4c2 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeSubEntry.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BOBLargeSubEntry.cs @@ -19,28 +19,28 @@ namespace Server.Engines.BulkOrders switch (version) { case 0: - { - string type = reader.ReadString(); + { + string type = reader.ReadString(); - if (type != null) - ItemType = AssemblyHandler.FindFirstTypeForName(type); + if (type != null) + ItemType = AssemblyHandler.FindFirstTypeForName(type); - AmountCur = reader.ReadEncodedInt(); - Number = reader.ReadEncodedInt(); - Graphic = reader.ReadEncodedInt(); + AmountCur = reader.ReadEncodedInt(); + Number = reader.ReadEncodedInt(); + Graphic = reader.ReadEncodedInt(); - break; - } + break; + } } } - public Type ItemType{ get; } + public Type ItemType { get; } - public int AmountCur{ get; } + public int AmountCur { get; } - public int Number{ get; } + public int Number { get; } - public int Graphic{ get; } + public int Graphic { get; } public void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BOBSmallEntry.cs b/Projects/Scripts/Engines/BulkOrders/Books/BOBSmallEntry.cs index f3f22fc61..caef12f81 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BOBSmallEntry.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BOBSmallEntry.cs @@ -28,45 +28,45 @@ namespace Server.Engines.BulkOrders switch (version) { case 0: - { - string type = reader.ReadString(); + { + string type = reader.ReadString(); - if (type != null) - ItemType = AssemblyHandler.FindFirstTypeForName(type); + if (type != null) + ItemType = AssemblyHandler.FindFirstTypeForName(type); - RequireExceptional = reader.ReadBool(); + RequireExceptional = reader.ReadBool(); - DeedType = (BODType)reader.ReadEncodedInt(); + DeedType = (BODType)reader.ReadEncodedInt(); - Material = (BulkMaterialType)reader.ReadEncodedInt(); - AmountCur = reader.ReadEncodedInt(); - AmountMax = reader.ReadEncodedInt(); - Number = reader.ReadEncodedInt(); - Graphic = reader.ReadEncodedInt(); - Price = reader.ReadEncodedInt(); + Material = (BulkMaterialType)reader.ReadEncodedInt(); + AmountCur = reader.ReadEncodedInt(); + AmountMax = reader.ReadEncodedInt(); + Number = reader.ReadEncodedInt(); + Graphic = reader.ReadEncodedInt(); + Price = reader.ReadEncodedInt(); - break; - } + break; + } } } - public Type ItemType{ get; } + public Type ItemType { get; } - public bool RequireExceptional{ get; } + public bool RequireExceptional { get; } - public BODType DeedType{ get; } + public BODType DeedType { get; } - public BulkMaterialType Material{ get; } + public BulkMaterialType Material { get; } - public int AmountCur{ get; } + public int AmountCur { get; } - public int AmountMax{ get; } + public int AmountMax { get; } - public int Number{ get; } + public int Number { get; } - public int Graphic{ get; } + public int Graphic { get; } - public int Price{ get; set; } + public int Price { get; set; } public Item Reconstruct() { diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs b/Projects/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs index 5f9bccc61..af337f7e3 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BODBuyGump.cs @@ -7,11 +7,11 @@ namespace Server.Engines.BulkOrders { public class BODBuyGump : Gump { - private BulkOrderBook m_Book; - private PlayerMobile m_From; - private IBOBEntry m_Entry; - private int m_Page; - private int m_Price; + private readonly BulkOrderBook m_Book; + private readonly PlayerMobile m_From; + private readonly IBOBEntry m_Entry; + private readonly int m_Page; + private readonly int m_Price; public BODBuyGump(PlayerMobile from, BulkOrderBook book, IBOBEntry entry, int page, int price) : base(100, 200) { diff --git a/Projects/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs b/Projects/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs index 3be45331a..734364c57 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/BulkOrderBook.cs @@ -12,14 +12,14 @@ namespace Server.Engines.BulkOrders { private string m_BookName; - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public string BookName { get => m_BookName; - set{ m_BookName = value; InvalidateProperties(); } + set { m_BookName = value; InvalidateProperties(); } } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public SecureLevel Level { get; set; } public List Entries { get; private set; } @@ -29,7 +29,7 @@ namespace Server.Engines.BulkOrders public int ItemCount { get; set; } [Constructible] - public BulkOrderBook() : base( 0x2259 ) + public BulkOrderBook() : base(0x2259) { Weight = 1.0; LootType = LootType.Blessed; @@ -40,89 +40,89 @@ namespace Server.Engines.BulkOrders Level = SecureLevel.CoOwners; } - public override void OnDoubleClick( Mobile from ) + public override void OnDoubleClick(Mobile from) { - if ( !from.InRange( GetWorldLocation(), 2 ) ) - from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. - else if ( Entries.Count == 0 ) - from.SendLocalizedMessage( 1062381 ); // The book is empty. - else if ( from is PlayerMobile mobile ) - mobile.SendGump( new BOBGump( mobile, this ) ); + if (!from.InRange(GetWorldLocation(), 2)) + from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + else if (Entries.Count == 0) + from.SendLocalizedMessage(1062381); // The book is empty. + else if (from is PlayerMobile mobile) + mobile.SendGump(new BOBGump(mobile, this)); } - public override void OnDoubleClickSecureTrade( Mobile from ) + public override void OnDoubleClickSecureTrade(Mobile from) { - if ( !from.InRange( GetWorldLocation(), 2 ) ) + if (!from.InRange(GetWorldLocation(), 2)) { - from.SendLocalizedMessage( 500446 ); // That is too far away. + from.SendLocalizedMessage(500446); // That is too far away. } - else if ( Entries.Count == 0 ) + else if (Entries.Count == 0) { - from.SendLocalizedMessage( 1062381 ); // The book is empty. + from.SendLocalizedMessage(1062381); // The book is empty. } else { - from.SendGump( new BOBGump( (PlayerMobile)from, this ) ); + from.SendGump(new BOBGump((PlayerMobile)from, this)); SecureTrade trade = GetSecureTradeCont()?.Trade; - if (trade?.From.Mobile == from ) - trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) ); - else if (trade?.To.Mobile == from ) - trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) ); + if (trade?.From.Mobile == from) + trade.To.Mobile.SendGump(new BOBGump((PlayerMobile)trade.To.Mobile, this)); + else if (trade?.To.Mobile == from) + trade.From.Mobile.SendGump(new BOBGump((PlayerMobile)trade.From.Mobile, this)); } } - public override bool OnDragDrop( Mobile from, Item dropped ) + public override bool OnDragDrop(Mobile from, Item dropped) { - if ( dropped is BaseBOD ) + if (dropped is BaseBOD) { - if ( !IsChildOf( from.Backpack ) ) + if (!IsChildOf(from.Backpack)) { - from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it. + from.SendLocalizedMessage(1062385); // You must have the book in your backpack to add deeds to it. return false; } - if ( !from.Backpack.CheckHold( from, dropped, true, true ) ) + if (!from.Backpack.CheckHold(from, dropped, true, true)) return false; - if ( Entries.Count < 500 ) + if (Entries.Count < 500) { - if ( dropped is LargeBOD bod ) - Entries.Add( new BOBLargeEntry( bod ) ); + if (dropped is LargeBOD bod) + Entries.Add(new BOBLargeEntry(bod)); else - Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) ); + Entries.Add(new BOBSmallEntry((SmallBOD)dropped)); InvalidateProperties(); - if ( Entries.Count / 5 > ItemCount ) + if (Entries.Count / 5 > ItemCount) { ItemCount++; InvalidateItems(); } from.SendSound(0x42, GetWorldLocation()); - from.SendLocalizedMessage( 1062386 ); // Deed added to book. + from.SendLocalizedMessage(1062386); // Deed added to book. - if ( from is PlayerMobile pm ) - pm.SendGump( new BOBGump( pm, this ) ); + if (from is PlayerMobile pm) + pm.SendGump(new BOBGump(pm, this)); dropped.Delete(); return true; } - from.SendLocalizedMessage( 1062387 ); // The book is full of deeds. + from.SendLocalizedMessage(1062387); // The book is full of deeds. return false; } - from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed. + from.SendLocalizedMessage(1062388); // That is not a bulk order deed. return false; } - public override int GetTotal( TotalType type ) + public override int GetTotal(TotalType type) { - int total = base.GetTotal( type ); + int total = base.GetTotal(type); - if ( type == TotalType.Items ) + if (type == TotalType.Items) total = ItemCount; return total; @@ -130,111 +130,111 @@ namespace Server.Engines.BulkOrders public void InvalidateItems() { - if ( RootParent is Mobile m ) + if (RootParent is Mobile m) { m.UpdateTotals(); - InvalidateContainers( Parent ); + InvalidateContainers(Parent); } } public void InvalidateContainers(IEntity parent) { - if ( parent is Container c ) + if (parent is Container c) { c.InvalidateProperties(); - InvalidateContainers( c.Parent ); + InvalidateContainers(c.Parent); } } - public BulkOrderBook( Serial serial ) : base( serial ) + public BulkOrderBook(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 2 ); // version + writer.Write(2); // version - writer.Write( ItemCount ); + writer.Write(ItemCount); - writer.Write( (int) Level ); + writer.Write((int)Level); - writer.Write( m_BookName ); + writer.Write(m_BookName); - Filter.Serialize( writer ); + Filter.Serialize(writer); - writer.WriteEncodedInt( Entries.Count ); + writer.WriteEncodedInt(Entries.Count); - for ( int i = 0; i < Entries.Count; ++i ) + for (int i = 0; i < Entries.Count; ++i) { object obj = Entries[i]; - if ( obj is BOBLargeEntry entry ) + if (obj is BOBLargeEntry entry) { - writer.WriteEncodedInt( 0 ); - entry.Serialize( writer ); + writer.WriteEncodedInt(0); + entry.Serialize(writer); } else { - writer.WriteEncodedInt( 1 ); - ((BOBSmallEntry)obj).Serialize( writer ); + writer.WriteEncodedInt(1); + ((BOBSmallEntry)obj).Serialize(writer); } } } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); - switch ( version ) + switch (version) { case 2: - { - ItemCount = reader.ReadInt(); - goto case 1; - } - case 1: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } - case 0: - { - m_BookName = reader.ReadString(); - - Filter = new BOBFilter( reader ); - - int count = reader.ReadEncodedInt(); - - Entries = new List( count ); - - for ( int i = 0; i < count; ++i ) { - int v = reader.ReadEncodedInt(); - - switch ( v ) - { - case 0: Entries.Add( new BOBLargeEntry( reader ) ); break; - case 1: Entries.Add( new BOBSmallEntry( reader ) ); break; - } + ItemCount = reader.ReadInt(); + goto case 1; } + case 1: + { + Level = (SecureLevel)reader.ReadInt(); + goto case 0; + } + case 0: + { + m_BookName = reader.ReadString(); - break; - } + Filter = new BOBFilter(reader); + + int count = reader.ReadEncodedInt(); + + Entries = new List(count); + + for (int i = 0; i < count; ++i) + { + int v = reader.ReadEncodedInt(); + + switch (v) + { + case 0: Entries.Add(new BOBLargeEntry(reader)); break; + case 1: Entries.Add(new BOBSmallEntry(reader)); break; + } + } + + break; + } } } - public override void GetProperties( ObjectPropertyList list ) + public override void GetProperties(ObjectPropertyList list) { - base.GetProperties( list ); + base.GetProperties(list); - list.Add( 1062344, Entries.Count.ToString() ); // Deeds in book: ~1_val~ + list.Add(1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~ - if ( !string.IsNullOrEmpty(m_BookName) ) - list.Add( 1062481, m_BookName ); // Book Name: ~1_val~ + if (!string.IsNullOrEmpty(m_BookName)) + list.Add(1062481, m_BookName); // Book Name: ~1_val~ } public override void OnSingleClick(Mobile from) @@ -247,22 +247,22 @@ namespace Server.Engines.BulkOrders LabelTo(from, 1062481, m_BookName); } - public override void GetContextMenuEntries( Mobile from, List list ) + public override void GetContextMenuEntries(Mobile from, List list) { - base.GetContextMenuEntries( from, list ); + base.GetContextMenuEntries(from, list); - if ( from.CheckAlive() && IsChildOf( from.Backpack ) ) - list.Add( new NameBookEntry( from, this ) ); + if (from.CheckAlive() && IsChildOf(from.Backpack)) + list.Add(new NameBookEntry(from, this)); - SetSecureLevelEntry.AddTo( from, this, list ); + SetSecureLevelEntry.AddTo(from, this, list); } private class NameBookEntry : ContextMenuEntry { - private Mobile m_From; - private BulkOrderBook m_Book; + private readonly Mobile m_From; + private readonly BulkOrderBook m_Book; - public NameBookEntry( Mobile from, BulkOrderBook book ) : base( 6216 ) + public NameBookEntry(Mobile from, BulkOrderBook book) : base(6216) { m_From = from; m_Book = book; @@ -270,34 +270,34 @@ namespace Server.Engines.BulkOrders public override void OnClick() { - if ( m_From.CheckAlive() && m_Book.IsChildOf( m_From.Backpack ) ) + if (m_From.CheckAlive() && m_Book.IsChildOf(m_From.Backpack)) { - m_From.Prompt = new NameBookPrompt( m_Book ); - m_From.SendLocalizedMessage( 1062479 ); // Type in the new name of the book: + m_From.Prompt = new NameBookPrompt(m_Book); + m_From.SendLocalizedMessage(1062479); // Type in the new name of the book: } } } private class NameBookPrompt : Prompt { - private BulkOrderBook m_Book; + private readonly BulkOrderBook m_Book; - public NameBookPrompt( BulkOrderBook book ) => m_Book = book; + public NameBookPrompt(BulkOrderBook book) => m_Book = book; - public override void OnResponse( Mobile from, string text ) + public override void OnResponse(Mobile from, string text) { - if ( text.Length > 40 ) - text = text.Substring( 0, 40 ); + if (text.Length > 40) + text = text.Substring(0, 40); - if ( from.CheckAlive() && m_Book.IsChildOf( from.Backpack ) ) + if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack)) { - m_Book.BookName = Utility.FixHtml( text.Trim() ); + m_Book.BookName = Utility.FixHtml(text.Trim()); - from.SendLocalizedMessage( 1062480 ); // The bulk order book's name has been changed. + from.SendLocalizedMessage(1062480); // The bulk order book's name has been changed. } } - public override void OnCancel( Mobile from ) + public override void OnCancel(Mobile from) { } } diff --git a/Projects/Scripts/Engines/BulkOrders/Books/IBOBEntry.cs b/Projects/Scripts/Engines/BulkOrders/Books/IBOBEntry.cs index 71dd7c2f7..61ce92899 100644 --- a/Projects/Scripts/Engines/BulkOrders/Books/IBOBEntry.cs +++ b/Projects/Scripts/Engines/BulkOrders/Books/IBOBEntry.cs @@ -2,11 +2,11 @@ namespace Server.Engines.BulkOrders { public interface IBOBEntry { - bool RequireExceptional{ get; } - BODType DeedType{ get; } - BulkMaterialType Material{ get; } - int AmountMax{ get; } - int Price{ get; set; } + bool RequireExceptional { get; } + BODType DeedType { get; } + BulkMaterialType Material { get; } + int AmountMax { get; } + int Price { get; set; } Item Reconstruct(); } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/BulkOrders/LargeBOD.cs b/Projects/Scripts/Engines/BulkOrders/LargeBOD.cs index 68a6a81ef..ffe8ec0d2 100644 --- a/Projects/Scripts/Engines/BulkOrders/LargeBOD.cs +++ b/Projects/Scripts/Engines/BulkOrders/LargeBOD.cs @@ -9,16 +9,16 @@ namespace Server.Engines.BulkOrders public LargeBulkEntry[] Entries { get => m_Entries; - set{ m_Entries = value; InvalidateProperties(); } + set { m_Entries = value; InvalidateProperties(); } } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public override bool Complete { get { - for ( int i = 0; i < m_Entries.Length; ++i ) - if ( m_Entries[i].Amount < AmountMax ) + for (int i = 0; i < m_Entries.Length; ++i) + if (m_Entries[i].Amount < AmountMax) return false; return true; @@ -27,48 +27,47 @@ namespace Server.Engines.BulkOrders public override int LabelNumber => 1045151; // a bulk order deed - public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : - base(hue, amountMax, requireExeptional, material) => + public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : base(hue, amountMax, requireExeptional, material) => m_Entries = entries; public LargeBOD() { } - public override void GetProperties( ObjectPropertyList list ) + public override void GetProperties(ObjectPropertyList list) { - base.GetProperties( list ); + base.GetProperties(list); - list.Add( 1060655 ); // large bulk order + list.Add(1060655); // large bulk order - if ( RequireExceptional ) - list.Add( 1045141 ); // All items must be exceptional. + if (RequireExceptional) + list.Add(1045141); // All items must be exceptional. - if ( Material != BulkMaterialType.None ) - list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material. + if (Material != BulkMaterialType.None) + list.Add(LargeBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material. - list.Add( 1060656, AmountMax.ToString() ); // amount to make: ~1_val~ + list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~ - for ( int i = 0; i < m_Entries.Length; ++i ) - list.Add( 1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount ); // ~1_val~: ~2_val~ + for (int i = 0; i < m_Entries.Length; ++i) + list.Add(1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount); // ~1_val~: ~2_val~ } - public override void OnDoubleClickNotAccessible( Mobile from ) + public override void OnDoubleClickNotAccessible(Mobile from) { - OnDoubleClick( from ); + OnDoubleClick(from); } - public override void OnDoubleClickSecureTrade( Mobile from ) + public override void OnDoubleClickSecureTrade(Mobile from) { - OnDoubleClick( from ); + OnDoubleClick(from); } - public override void OnDoubleClick( Mobile from ) + public override void OnDoubleClick(Mobile from) { - if ( IsChildOf( from.Backpack ) || InSecureTrade || RootParent is PlayerVendor ) - from.SendGump( new LargeBODGump( from, this ) ); + if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor) + from.SendGump(new LargeBODGump(from, this)); else - from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it. + from.SendLocalizedMessage(1045156); // You must have the deed in your backpack to use it. } public override void EndCombine(Mobile from, Item item) @@ -136,35 +135,35 @@ namespace Server.Engines.BulkOrders { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.WriteEncodedInt( 0 ); // version + writer.WriteEncodedInt(0); // version - writer.Write( m_Entries.Length ); + writer.Write(m_Entries.Length); - for ( int i = 0; i < m_Entries.Length; ++i ) - m_Entries[i].Serialize( writer ); + for (int i = 0; i < m_Entries.Length; ++i) + m_Entries[i].Serialize(writer); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadEncodedInt(); - switch ( version ) + switch (version) { case 0: - { - m_Entries = new LargeBulkEntry[reader.ReadInt()]; + { + m_Entries = new LargeBulkEntry[reader.ReadInt()]; - for ( int i = 0; i < m_Entries.Length; ++i ) - m_Entries[i] = new LargeBulkEntry( this, reader ); + for (int i = 0; i < m_Entries.Length; ++i) + m_Entries[i] = new LargeBulkEntry(this, reader); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs b/Projects/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs index 6d852f7d7..b2d4d658d 100644 --- a/Projects/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs +++ b/Projects/Scripts/Engines/BulkOrders/LargeBODAcceptGump.cs @@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders { public class LargeBODAcceptGump : Gump { - private LargeBOD m_Deed; - private Mobile m_From; + private readonly LargeBOD m_Deed; + private readonly Mobile m_From; public LargeBODAcceptGump(Mobile from, LargeBOD deed) : base(50, 50) { diff --git a/Projects/Scripts/Engines/BulkOrders/LargeBODGump.cs b/Projects/Scripts/Engines/BulkOrders/LargeBODGump.cs index b59065e61..1f38babc6 100644 --- a/Projects/Scripts/Engines/BulkOrders/LargeBODGump.cs +++ b/Projects/Scripts/Engines/BulkOrders/LargeBODGump.cs @@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders { public class LargeBODGump : Gump { - private LargeBOD m_Deed; - private Mobile m_From; + private readonly LargeBOD m_Deed; + private readonly Mobile m_From; public LargeBODGump(Mobile from, LargeBOD deed) : base(25, 25) { diff --git a/Projects/Scripts/Engines/BulkOrders/LargeBulkEntry.cs b/Projects/Scripts/Engines/BulkOrders/LargeBulkEntry.cs index 50c9b93cf..985792ad0 100644 --- a/Projects/Scripts/Engines/BulkOrders/LargeBulkEntry.cs +++ b/Projects/Scripts/Engines/BulkOrders/LargeBulkEntry.cs @@ -12,88 +12,86 @@ namespace Server.Engines.BulkOrders public int Amount { get => m_Amount; - set{ m_Amount = value; Owner?.InvalidateProperties(); } + set { m_Amount = value; Owner?.InvalidateProperties(); } } public SmallBulkEntry Details { get; } - public static SmallBulkEntry[] LargeRing => GetEntries( "Blacksmith", "largering" ); + public static SmallBulkEntry[] LargeRing => GetEntries("Blacksmith", "largering"); - public static SmallBulkEntry[] LargePlate => GetEntries( "Blacksmith", "largeplate" ); + public static SmallBulkEntry[] LargePlate => GetEntries("Blacksmith", "largeplate"); - public static SmallBulkEntry[] LargeChain => GetEntries( "Blacksmith", "largechain" ); + public static SmallBulkEntry[] LargeChain => GetEntries("Blacksmith", "largechain"); - public static SmallBulkEntry[] LargeAxes => GetEntries( "Blacksmith", "largeaxes" ); + public static SmallBulkEntry[] LargeAxes => GetEntries("Blacksmith", "largeaxes"); - public static SmallBulkEntry[] LargeFencing => GetEntries( "Blacksmith", "largefencing" ); + public static SmallBulkEntry[] LargeFencing => GetEntries("Blacksmith", "largefencing"); - public static SmallBulkEntry[] LargeMaces => GetEntries( "Blacksmith", "largemaces" ); + public static SmallBulkEntry[] LargeMaces => GetEntries("Blacksmith", "largemaces"); - public static SmallBulkEntry[] LargePolearms => GetEntries( "Blacksmith", "largepolearms" ); + public static SmallBulkEntry[] LargePolearms => GetEntries("Blacksmith", "largepolearms"); - public static SmallBulkEntry[] LargeSwords => GetEntries( "Blacksmith", "largeswords" ); + public static SmallBulkEntry[] LargeSwords => GetEntries("Blacksmith", "largeswords"); + public static SmallBulkEntry[] BoneSet => GetEntries("Tailoring", "boneset"); - public static SmallBulkEntry[] BoneSet => GetEntries( "Tailoring", "boneset" ); + public static SmallBulkEntry[] Farmer => GetEntries("Tailoring", "farmer"); - public static SmallBulkEntry[] Farmer => GetEntries( "Tailoring", "farmer" ); + public static SmallBulkEntry[] FemaleLeatherSet => GetEntries("Tailoring", "femaleleatherset"); - public static SmallBulkEntry[] FemaleLeatherSet => GetEntries( "Tailoring", "femaleleatherset" ); + public static SmallBulkEntry[] FisherGirl => GetEntries("Tailoring", "fishergirl"); - public static SmallBulkEntry[] FisherGirl => GetEntries( "Tailoring", "fishergirl" ); + public static SmallBulkEntry[] Gypsy => GetEntries("Tailoring", "gypsy"); - public static SmallBulkEntry[] Gypsy => GetEntries( "Tailoring", "gypsy" ); + public static SmallBulkEntry[] HatSet => GetEntries("Tailoring", "hatset"); - public static SmallBulkEntry[] HatSet => GetEntries( "Tailoring", "hatset" ); + public static SmallBulkEntry[] Jester => GetEntries("Tailoring", "jester"); - public static SmallBulkEntry[] Jester => GetEntries( "Tailoring", "jester" ); + public static SmallBulkEntry[] Lady => GetEntries("Tailoring", "lady"); - public static SmallBulkEntry[] Lady => GetEntries( "Tailoring", "lady" ); + public static SmallBulkEntry[] MaleLeatherSet => GetEntries("Tailoring", "maleleatherset"); - public static SmallBulkEntry[] MaleLeatherSet => GetEntries( "Tailoring", "maleleatherset" ); + public static SmallBulkEntry[] Pirate => GetEntries("Tailoring", "pirate"); - public static SmallBulkEntry[] Pirate => GetEntries( "Tailoring", "pirate" ); + public static SmallBulkEntry[] ShoeSet => GetEntries("Tailoring", "shoeset"); - public static SmallBulkEntry[] ShoeSet => GetEntries( "Tailoring", "shoeset" ); + public static SmallBulkEntry[] StuddedSet => GetEntries("Tailoring", "studdedset"); - public static SmallBulkEntry[] StuddedSet => GetEntries( "Tailoring", "studdedset" ); + public static SmallBulkEntry[] TownCrier => GetEntries("Tailoring", "towncrier"); - public static SmallBulkEntry[] TownCrier => GetEntries( "Tailoring", "towncrier" ); + public static SmallBulkEntry[] Wizard => GetEntries("Tailoring", "wizard"); - public static SmallBulkEntry[] Wizard => GetEntries( "Tailoring", "wizard" ); + private static Dictionary> m_Cache; - - private static Dictionary> m_Cache; - - public static SmallBulkEntry[] GetEntries( string type, string name ) + public static SmallBulkEntry[] GetEntries(string type, string name) { m_Cache ??= new Dictionary>(); - if (!m_Cache.TryGetValue( type, out Dictionary table )) + if (!m_Cache.TryGetValue(type, out Dictionary table)) m_Cache[type] = table = new Dictionary(); - if (!table.TryGetValue( name, out SmallBulkEntry[] entries )) + if (!table.TryGetValue(name, out SmallBulkEntry[] entries)) table[name] = entries = SmallBulkEntry.LoadEntries(type, name); return entries; } - public static LargeBulkEntry[] ConvertEntries( LargeBOD owner, SmallBulkEntry[] small ) + public static LargeBulkEntry[] ConvertEntries(LargeBOD owner, SmallBulkEntry[] small) { LargeBulkEntry[] large = new LargeBulkEntry[small.Length]; - for ( int i = 0; i < small.Length; ++i ) - large[i] = new LargeBulkEntry( owner, small[i] ); + for (int i = 0; i < small.Length; ++i) + large[i] = new LargeBulkEntry(owner, small[i]); return large; } - public LargeBulkEntry( LargeBOD owner, SmallBulkEntry details ) + public LargeBulkEntry(LargeBOD owner, SmallBulkEntry details) { Owner = owner; Details = details; } - public LargeBulkEntry( LargeBOD owner, IGenericReader reader ) + public LargeBulkEntry(LargeBOD owner, IGenericReader reader) { Owner = owner; m_Amount = reader.ReadInt(); @@ -102,18 +100,18 @@ namespace Server.Engines.BulkOrders string type = reader.ReadString(); - if ( type != null ) - realType = AssemblyHandler.FindFirstTypeForName( type ); + if (type != null) + realType = AssemblyHandler.FindFirstTypeForName(type); - Details = new SmallBulkEntry( realType, reader.ReadInt(), reader.ReadInt() ); + Details = new SmallBulkEntry(realType, reader.ReadInt(), reader.ReadInt()); } - public void Serialize(IGenericWriter writer ) + public void Serialize(IGenericWriter writer) { - writer.Write( m_Amount ); - writer.Write( Details.Type?.FullName ); - writer.Write( Details.Number ); - writer.Write( Details.Graphic ); + writer.Write(m_Amount); + writer.Write(Details.Type?.FullName); + writer.Write(Details.Number); + writer.Write(Details.Graphic); } } } diff --git a/Projects/Scripts/Engines/BulkOrders/LargeSmithBOD.cs b/Projects/Scripts/Engines/BulkOrders/LargeSmithBOD.cs index c1e8be17d..51af6ebb8 100644 --- a/Projects/Scripts/Engines/BulkOrders/LargeSmithBOD.cs +++ b/Projects/Scripts/Engines/BulkOrders/LargeSmithBOD.cs @@ -41,7 +41,7 @@ namespace Server.Engines.BulkOrders int hue = 0x44E; int amountMax = Utility.RandomList(10, 15, 20, 20); - bool reqExceptional = 0.825 > Utility.RandomDouble(); + bool reqExceptional = Utility.RandomDouble() < 0.825; BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances) : BulkMaterialType.None; diff --git a/Projects/Scripts/Engines/BulkOrders/LargeTailorBOD.cs b/Projects/Scripts/Engines/BulkOrders/LargeTailorBOD.cs index 055b873c8..8a2168fb7 100644 --- a/Projects/Scripts/Engines/BulkOrders/LargeTailorBOD.cs +++ b/Projects/Scripts/Engines/BulkOrders/LargeTailorBOD.cs @@ -69,7 +69,7 @@ namespace Server.Engines.BulkOrders int hue = 0x483; int amountMax = Utility.RandomList(10, 15, 20, 20); - bool reqExceptional = 0.825 > Utility.RandomDouble(); + bool reqExceptional = Utility.RandomDouble() < 0.825; BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances) : BulkMaterialType.None; diff --git a/Projects/Scripts/Engines/BulkOrders/Rewards.cs b/Projects/Scripts/Engines/BulkOrders/Rewards.cs index 9b20f201f..056b776a5 100644 --- a/Projects/Scripts/Engines/BulkOrders/Rewards.cs +++ b/Projects/Scripts/Engines/BulkOrders/Rewards.cs @@ -13,9 +13,9 @@ namespace Server.Engines.BulkOrders Types = types; } - public int Points{ get; } + public int Points { get; } - public Type[] Types{ get; } + public Type[] Types { get; } public bool Contains(Type type) { @@ -36,11 +36,11 @@ namespace Server.Engines.BulkOrders Type = type; } - public int Weight{ get; } + public int Weight { get; } - public ConstructCallback Constructor{ get; } + public ConstructCallback Constructor { get; } - public int Type{ get; } + public int Type { get; } public Item Construct() { @@ -63,9 +63,9 @@ namespace Server.Engines.BulkOrders Items = items; } - public int Points{ get; } + public int Points { get; } - public RewardItem[] Items{ get; } + public RewardItem[] Items { get; } public RewardItem AcquireItem() { @@ -97,7 +97,7 @@ namespace Server.Engines.BulkOrders public abstract class RewardCalculator { - public RewardGroup[] Groups{ get; set; } + public RewardGroup[] Groups { get; set; } public abstract int ComputePoints(int quantity, bool exceptional, BulkMaterialType material, int itemCount, Type type); @@ -165,7 +165,7 @@ namespace Server.Engines.BulkOrders private static readonly ConstructCallback AncientHammer = CreateAncientHammer; public static readonly SmithRewardCalculator Instance = new SmithRewardCalculator(); - private static int[][][] m_GoldTable = + private static readonly int[][][] m_GoldTable = { new[] // 1-part (regular) { @@ -253,7 +253,7 @@ namespace Server.Engines.BulkOrders } }; - private RewardType[] m_Types = + private readonly RewardType[] m_Types = { // Armors new RewardType(200, typeof(RingmailGloves), typeof(RingmailChest), typeof(RingmailArms), typeof(RingmailLegs)), @@ -264,7 +264,7 @@ namespace Server.Engines.BulkOrders // Weapons new RewardType(200, typeof(Bardiche), typeof(Halberd)), new RewardType(300, typeof(Dagger), typeof(ShortSpear), typeof(Spear), typeof(WarFork), - typeof(Kryss)), //OSI put the dagger in there. Odd, ain't it. + typeof(Kryss)), // OSI put the dagger in there. Odd, ain't it. new RewardType(350, typeof(Axe), typeof(BattleAxe), typeof(DoubleAxe), typeof(ExecutionersAxe), typeof(LargeBattleAxe), typeof(TwoHandedAxe)), new RewardType(350, typeof(Broadsword), typeof(Cutlass), typeof(Katana), typeof(Longsword), @@ -379,8 +379,6 @@ namespace Server.Engines.BulkOrders return Utility.RandomMinMax(min, max); } - #region Constructors - private static Item CreateSturdyShovel(int type) => new SturdyShovel(); private static Item CreateSturdyPickaxe(int type) => new SturdyPickaxe(); @@ -427,8 +425,6 @@ namespace Server.Engines.BulkOrders throw new InvalidOperationException(); } - - #endregion } public sealed class TailorRewardCalculator : RewardCalculator @@ -443,7 +439,7 @@ namespace Server.Engines.BulkOrders private static readonly ConstructCallback ClothingBlessDeed = CreateCBD; public static readonly TailorRewardCalculator Instance = new TailorRewardCalculator(); - private static int[][][] m_AosGoldTable = + private static readonly int[][][] m_AosGoldTable = { new[] // 1-part (regular) { @@ -495,7 +491,7 @@ namespace Server.Engines.BulkOrders } }; - private static int[][][] m_OldGoldTable = + private static readonly int[][][] m_OldGoldTable = { new[] // 1-part (regular) { @@ -612,7 +608,7 @@ namespace Server.Engines.BulkOrders 4 => 1, _ => 0 } * 2 + (exceptional ? 1 : 0); - + int quanIndex = quantity switch { 20 => 2, @@ -636,9 +632,7 @@ namespace Server.Engines.BulkOrders return Utility.RandomMinMax(min, max); } - #region Constructors - - private static int[][] m_ClothHues = + private static readonly int[][] m_ClothHues = { new[] { 0x483, 0x48C, 0x488, 0x48A }, new[] { 0x495, 0x48B, 0x486, 0x485 }, @@ -659,7 +653,7 @@ namespace Server.Engines.BulkOrders throw new InvalidOperationException(); } - private static int[] m_SandalHues = + private static readonly int[] m_SandalHues = { 0x489, 0x47F, 0x482, 0x47E, 0x48F, 0x494, @@ -718,7 +712,5 @@ namespace Server.Engines.BulkOrders } private static Item CreateCBD(int type) => new ClothingBlessDeed(); - - #endregion } } diff --git a/Projects/Scripts/Engines/BulkOrders/SmallBOD.cs b/Projects/Scripts/Engines/BulkOrders/SmallBOD.cs index 9fc582986..822f4062f 100644 --- a/Projects/Scripts/Engines/BulkOrders/SmallBOD.cs +++ b/Projects/Scripts/Engines/BulkOrders/SmallBOD.cs @@ -38,7 +38,7 @@ namespace Server.Engines.BulkOrders } [CommandProperty(AccessLevel.GameMaster)] - public Type Type{ get; set; } + public Type Type { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Number @@ -52,7 +52,7 @@ namespace Server.Engines.BulkOrders } [CommandProperty(AccessLevel.GameMaster)] - public int Graphic{ get; set; } + public int Graphic { get; set; } [CommandProperty(AccessLevel.GameMaster)] public override bool Complete => m_AmountCur == AmountMax; @@ -121,8 +121,8 @@ namespace Server.Engines.BulkOrders from.SendLocalizedMessage( 1045166); // The maximum amount of requested items have already been combined to this deed. } - else if (Type == null || objectType != Type && !objectType.IsSubclassOf(Type) || - !(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)) + else if (Type == null || (objectType != Type && !objectType.IsSubclassOf(Type)) || + (!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing))) { from.SendLocalizedMessage(1045169); // The item is not in the request. } @@ -194,18 +194,18 @@ namespace Server.Engines.BulkOrders switch (version) { case 0: - { - m_AmountCur = reader.ReadInt(); + { + m_AmountCur = reader.ReadInt(); - string type = reader.ReadString(); + string type = reader.ReadString(); - if (type != null) - Type = AssemblyHandler.FindFirstTypeForName(type); + if (type != null) + Type = AssemblyHandler.FindFirstTypeForName(type); - m_Number = reader.ReadInt(); - Graphic = reader.ReadInt(); - break; - } + m_Number = reader.ReadInt(); + Graphic = reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs b/Projects/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs index 1234a9c2a..cee36c998 100644 --- a/Projects/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs +++ b/Projects/Scripts/Engines/BulkOrders/SmallBODAcceptGump.cs @@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders { public class SmallBODAcceptGump : Gump { - private SmallBOD m_Deed; - private Mobile m_From; + private readonly SmallBOD m_Deed; + private readonly Mobile m_From; public SmallBODAcceptGump(Mobile from, SmallBOD deed) : base(50, 50) { diff --git a/Projects/Scripts/Engines/BulkOrders/SmallBODGump.cs b/Projects/Scripts/Engines/BulkOrders/SmallBODGump.cs index 342776555..53d8b45b0 100644 --- a/Projects/Scripts/Engines/BulkOrders/SmallBODGump.cs +++ b/Projects/Scripts/Engines/BulkOrders/SmallBODGump.cs @@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders { public class SmallBODGump : Gump { - private SmallBOD m_Deed; - private Mobile m_From; + private readonly SmallBOD m_Deed; + private readonly Mobile m_From; public SmallBODGump(Mobile from, SmallBOD deed) : base(25, 25) { diff --git a/Projects/Scripts/Engines/BulkOrders/SmallBulkEntry.cs b/Projects/Scripts/Engines/BulkOrders/SmallBulkEntry.cs index 02b5cd10c..bf87b7997 100644 --- a/Projects/Scripts/Engines/BulkOrders/SmallBulkEntry.cs +++ b/Projects/Scripts/Engines/BulkOrders/SmallBulkEntry.cs @@ -12,66 +12,66 @@ namespace Server.Engines.BulkOrders public int Graphic { get; } - public SmallBulkEntry( Type type, int number, int graphic ) + public SmallBulkEntry(Type type, int number, int graphic) { Type = type; Number = number; Graphic = graphic; } - public static SmallBulkEntry[] BlacksmithWeapons => GetEntries( "Blacksmith", "weapons" ); + public static SmallBulkEntry[] BlacksmithWeapons => GetEntries("Blacksmith", "weapons"); - public static SmallBulkEntry[] BlacksmithArmor => GetEntries( "Blacksmith", "armor" ); + public static SmallBulkEntry[] BlacksmithArmor => GetEntries("Blacksmith", "armor"); - public static SmallBulkEntry[] TailorCloth => GetEntries( "Tailoring", "cloth" ); + public static SmallBulkEntry[] TailorCloth => GetEntries("Tailoring", "cloth"); - public static SmallBulkEntry[] TailorLeather => GetEntries( "Tailoring", "leather" ); + public static SmallBulkEntry[] TailorLeather => GetEntries("Tailoring", "leather"); private static Dictionary> m_Cache; - public static SmallBulkEntry[] GetEntries( string type, string name ) + public static SmallBulkEntry[] GetEntries(string type, string name) { - if ( m_Cache == null ) + if (m_Cache == null) m_Cache = new Dictionary>(); - if (!m_Cache.TryGetValue( type, out Dictionary table )) + if (!m_Cache.TryGetValue(type, out Dictionary table)) m_Cache[type] = table = new Dictionary(); - if (!table.TryGetValue( name, out SmallBulkEntry[] entries )) + if (!table.TryGetValue(name, out SmallBulkEntry[] entries)) table[name] = entries = LoadEntries(type, name); return entries; } - public static SmallBulkEntry[] LoadEntries( string type, string name ) => LoadEntries($"Data/Bulk Orders/{type}/{name}.cfg"); + public static SmallBulkEntry[] LoadEntries(string type, string name) => LoadEntries($"Data/Bulk Orders/{type}/{name}.cfg"); - public static SmallBulkEntry[] LoadEntries( string path ) + public static SmallBulkEntry[] LoadEntries(string path) { - path = Path.Combine( Core.BaseDirectory, path ); + path = Path.Combine(Core.BaseDirectory, path); List list = new List(); - if ( File.Exists( path ) ) + if (File.Exists(path)) { - using StreamReader ip = new StreamReader( path ); + using StreamReader ip = new StreamReader(path); string line; - while ( (line = ip.ReadLine()) != null ) + while ((line = ip.ReadLine()) != null) { - if ( line.Length == 0 || line.StartsWith( "#" ) ) + if (line.Length == 0 || line.StartsWith("#")) continue; try { - string[] split = line.Split( '\t' ); + string[] split = line.Split('\t'); - if ( split.Length >= 2 ) + if (split.Length >= 2) { - Type type = AssemblyHandler.FindFirstTypeForName( split[0] ); - int graphic = Utility.ToInt32( split[split.Length - 1] ); + Type type = AssemblyHandler.FindFirstTypeForName(split[0]); + int graphic = Utility.ToInt32(split[split.Length - 1]); - if ( type != null && graphic > 0 ) - list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) ); + if (type != null && graphic > 0) + list.Add(new SmallBulkEntry(type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic)); } } catch diff --git a/Projects/Scripts/Engines/BulkOrders/SmallSmithBOD.cs b/Projects/Scripts/Engines/BulkOrders/SmallSmithBOD.cs index 381699c2d..e69132008 100644 --- a/Projects/Scripts/Engines/BulkOrders/SmallSmithBOD.cs +++ b/Projects/Scripts/Engines/BulkOrders/SmallSmithBOD.cs @@ -153,7 +153,6 @@ namespace Server.Engines.BulkOrders SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; return new SmallSmithBOD(entry, material, amountMax, reqExceptional); - } public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Engines/BulkOrders/SmallTailorBOD.cs b/Projects/Scripts/Engines/BulkOrders/SmallTailorBOD.cs index f860413df..ed3b35ab6 100644 --- a/Projects/Scripts/Engines/BulkOrders/SmallTailorBOD.cs +++ b/Projects/Scripts/Engines/BulkOrders/SmallTailorBOD.cs @@ -121,7 +121,6 @@ namespace Server.Engines.BulkOrders bool reqExceptional = excChance > Utility.RandomDouble(); - CraftSystem system = DefTailoring.CraftSystem; List validEntries = new List(); diff --git a/Projects/Scripts/Engines/CannedEvil/ChampionAltar.cs b/Projects/Scripts/Engines/CannedEvil/ChampionAltar.cs index 98e1adc34..b015e62e5 100644 --- a/Projects/Scripts/Engines/CannedEvil/ChampionAltar.cs +++ b/Projects/Scripts/Engines/CannedEvil/ChampionAltar.cs @@ -37,14 +37,14 @@ namespace Server.Engines.CannedEvil switch (version) { case 0: - { - m_Spawn = reader.ReadItem() as ChampionSpawn; + { + m_Spawn = reader.ReadItem() as ChampionSpawn; - if (m_Spawn == null) - Delete(); + if (m_Spawn == null) + Delete(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/CannedEvil/ChampionPlatform.cs b/Projects/Scripts/Engines/CannedEvil/ChampionPlatform.cs index 4361d0d01..9bb47771f 100644 --- a/Projects/Scripts/Engines/CannedEvil/ChampionPlatform.cs +++ b/Projects/Scripts/Engines/CannedEvil/ChampionPlatform.cs @@ -11,12 +11,12 @@ namespace Server.Engines.CannedEvil m_Spawn = spawn; for (int x = -2; x <= 2; ++x) - for (int y = -2; y <= 2; ++y) - AddComponent(0x750, x, y, -5); + for (int y = -2; y <= 2; ++y) + AddComponent(0x750, x, y, -5); for (int x = -1; x <= 1; ++x) - for (int y = -1; y <= 1; ++y) - AddComponent(0x750, x, y, 0); + for (int y = -1; y <= 1; ++y) + AddComponent(0x750, x, y, 0); for (int i = -1; i <= 1; ++i) { @@ -71,14 +71,14 @@ namespace Server.Engines.CannedEvil switch (version) { case 0: - { - m_Spawn = reader.ReadItem() as ChampionSpawn; + { + m_Spawn = reader.ReadItem() as ChampionSpawn; - if (m_Spawn == null) - Delete(); + if (m_Spawn == null) + Delete(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/CannedEvil/ChampionSkull.cs b/Projects/Scripts/Engines/CannedEvil/ChampionSkull.cs index 19083724a..10c12bb8e 100644 --- a/Projects/Scripts/Engines/CannedEvil/ChampionSkull.cs +++ b/Projects/Scripts/Engines/CannedEvil/ChampionSkull.cs @@ -60,11 +60,11 @@ namespace Server.Items { case 1: case 0: - { - m_Type = (ChampionSkullType)reader.ReadInt(); + { + m_Type = (ChampionSkullType)reader.ReadInt(); - break; - } + break; + } } if (version == 0) diff --git a/Projects/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs b/Projects/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs index 186c66b20..fca9514b3 100644 --- a/Projects/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs +++ b/Projects/Scripts/Engines/CannedEvil/ChampionSkullBrazier.cs @@ -23,7 +23,7 @@ namespace Server.Engines.CannedEvil } [CommandProperty(AccessLevel.GameMaster)] - public ChampionSkullPlatform Platform{ get; private set; } + public ChampionSkullPlatform Platform { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public ChampionSkullType Type @@ -147,16 +147,16 @@ namespace Server.Engines.CannedEvil switch (version) { case 0: - { - m_Type = (ChampionSkullType)reader.ReadInt(); - Platform = reader.ReadItem() as ChampionSkullPlatform; - m_Skull = reader.ReadItem(); + { + m_Type = (ChampionSkullType)reader.ReadInt(); + Platform = reader.ReadItem() as ChampionSkullPlatform; + m_Skull = reader.ReadItem(); - if (Platform == null) - Delete(); + if (Platform == null) + Delete(); - break; - } + break; + } } if (Hue == 0x497) @@ -168,7 +168,7 @@ namespace Server.Engines.CannedEvil private class SacrificeTarget : Target { - private ChampionSkullBrazier m_Brazier; + private readonly ChampionSkullBrazier m_Brazier; public SacrificeTarget(ChampionSkullBrazier brazier) : base(12, false, TargetFlags.None) => m_Brazier = brazier; diff --git a/Projects/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs b/Projects/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs index a99853157..4a1d3994f 100644 --- a/Projects/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs +++ b/Projects/Scripts/Engines/CannedEvil/ChampionSkullPlatform.cs @@ -109,16 +109,16 @@ namespace Server.Engines.CannedEvil switch (version) { case 0: - { - m_Power = reader.ReadItem() as ChampionSkullBrazier; - m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier; - m_Venom = reader.ReadItem() as ChampionSkullBrazier; - m_Pain = reader.ReadItem() as ChampionSkullBrazier; - m_Greed = reader.ReadItem() as ChampionSkullBrazier; - m_Death = reader.ReadItem() as ChampionSkullBrazier; + { + m_Power = reader.ReadItem() as ChampionSkullBrazier; + m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier; + m_Venom = reader.ReadItem() as ChampionSkullBrazier; + m_Pain = reader.ReadItem() as ChampionSkullBrazier; + m_Greed = reader.ReadItem() as ChampionSkullBrazier; + m_Death = reader.ReadItem() as ChampionSkullBrazier; - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/CannedEvil/ChampionSpawn.cs b/Projects/Scripts/Engines/CannedEvil/ChampionSpawn.cs index ef56f3b3e..c97411178 100644 --- a/Projects/Scripts/Engines/CannedEvil/ChampionSpawn.cs +++ b/Projects/Scripts/Engines/CannedEvil/ChampionSpawn.cs @@ -26,7 +26,7 @@ namespace Server.Engines.CannedEvil private List m_RedSkulls; private ChampionSpawnRegion m_Region; - //private int m_SpawnRange; + // private int m_SpawnRange; private Rectangle2D m_SpawnArea; private int m_SPawnSzMod; @@ -68,13 +68,13 @@ namespace Server.Engines.CannedEvil } [CommandProperty(AccessLevel.GameMaster)] - public bool ConfinedRoaming{ get; set; } + public bool ConfinedRoaming { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool HasBeenAdvanced{ get; set; } + public bool HasBeenAdvanced { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool RandomizeType{ get; set; } + public bool RandomizeType { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Kills @@ -100,16 +100,16 @@ namespace Server.Engines.CannedEvil } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan RestartDelay{ get; set; } + public TimeSpan RestartDelay { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime RestartTime{ get; private set; } + public DateTime RestartTime { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan ExpireDelay{ get; set; } + public TimeSpan ExpireDelay { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime ExpireTime{ get; set; } + public DateTime ExpireTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] public ChampionSpawnType Type @@ -138,7 +138,7 @@ namespace Server.Engines.CannedEvil } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Champion{ get; set; } + public Mobile Champion { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Level @@ -173,7 +173,7 @@ namespace Server.Engines.CannedEvil public void SetInitialSpawnArea() { - //Previous default used to be 24; + // Previous default used to be 24; SpawnArea = new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); } @@ -188,7 +188,7 @@ namespace Server.Engines.CannedEvil } /* - if ( m_Region == null ) + if (m_Region == null) { m_Region = new ChampionSpawnRegion( this ); } @@ -307,8 +307,6 @@ namespace Server.Engines.CannedEvil Start(); } - #region Scroll of Transcendence - private ScrollofTranscendence CreateRandomSoT(bool felucca) { int level = Utility.RandomMinMax(1, 5); @@ -319,11 +317,9 @@ namespace Server.Engines.CannedEvil return ScrollofTranscendence.CreateRandom(level, level); } - #endregion - public static void GiveScrollTo(Mobile killer, SpecialScroll scroll) { - if (scroll == null || killer == null) //sanity + if (scroll == null || killer == null) // sanity return; if (scroll is ScrollofTranscendence) @@ -437,8 +433,6 @@ namespace Server.Engines.CannedEvil if (killer is PlayerMobile pm) { - #region Scroll of Transcendence - if (Core.ML) { if (Map == Map.Felucca) @@ -467,8 +461,6 @@ namespace Server.Engines.CannedEvil } } - #endregion - int mobSubLevel = GetSubLevelFor(m) + 1; if (mobSubLevel >= 0) @@ -484,7 +476,7 @@ namespace Server.Engines.CannedEvil else m.SendLocalizedMessage(1054030); // You have gained in Valor! - //No delay on Valor gains + // No delay on Valor gains } PlayerMobile.ChampionTitleInfo info = pm.ChampionTitles; @@ -790,7 +782,7 @@ namespace Server.Engines.CannedEvil list.Add(1060659, "Level\t{0}", Level); // ~1_val~: ~2_val~ list.Add(1060660, "Kills\t{0} of {1} ({2:F1}%)", m_Kills, MaxKills, 100.0 * ((double)m_Kills / MaxKills)); // ~1_val~: ~2_val~ - //list.Add( 1060661, "Spawn Range\t{0}", m_SpawnRange ); // ~1_val~: ~2_val~ + // list.Add( 1060661, "Spawn Range\t{0}", m_SpawnRange ); // ~1_val~: ~2_val~ } else { @@ -988,9 +980,9 @@ namespace Server.Engines.CannedEvil 1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. } - public bool IsEligible(Mobile m, Item Artifact) => + public bool IsEligible(Mobile m, Item artifact) => m.Player && m.Alive && m.Region != null && m.Region == m_Region && - m.Backpack?.CheckHold(m, Artifact, false) == true; + m.Backpack?.CheckHold(m, artifact, false) == true; public override void Serialize(IGenericWriter writer) { @@ -1013,7 +1005,7 @@ namespace Server.Engines.CannedEvil writer.Write(RandomizeType); - // writer.Write( m_SpawnRange ); + // writer.Write( m_SpawnRange ); writer.Write(m_Kills); writer.Write(m_Active); @@ -1045,97 +1037,97 @@ namespace Server.Engines.CannedEvil switch (version) { case 6: - { - m_SPawnSzMod = reader.ReadInt(); - goto case 5; - } + { + m_SPawnSzMod = reader.ReadInt(); + goto case 5; + } case 5: - { - int entries = reader.ReadInt(); - for (int i = 0; i < entries; ++i) { - Mobile m = reader.ReadMobile(); - int damage = reader.ReadInt(); + int entries = reader.ReadInt(); + for (int i = 0; i < entries; ++i) + { + Mobile m = reader.ReadMobile(); + int damage = reader.ReadInt(); - if (m == null) - continue; + if (m == null) + continue; - m_DamageEntries.Add(m, damage); + m_DamageEntries.Add(m, damage); + } + + goto case 4; } - - goto case 4; - } case 4: - { - ConfinedRoaming = reader.ReadBool(); - m_Idol = reader.ReadItem(); - HasBeenAdvanced = reader.ReadBool(); + { + ConfinedRoaming = reader.ReadBool(); + m_Idol = reader.ReadItem(); + HasBeenAdvanced = reader.ReadBool(); - goto case 3; - } + goto case 3; + } case 3: - { - m_SpawnArea = reader.ReadRect2D(); + { + m_SpawnArea = reader.ReadRect2D(); - goto case 2; - } + goto case 2; + } case 2: - { - RandomizeType = reader.ReadBool(); + { + RandomizeType = reader.ReadBool(); - goto case 1; - } + goto case 1; + } case 1: - { - if (version < 3) { - int oldRange = reader.ReadInt(); + if (version < 3) + { + int oldRange = reader.ReadInt(); - m_SpawnArea = new Rectangle2D(new Point2D(X - oldRange, Y - oldRange), - new Point2D(X + oldRange, Y + oldRange)); + m_SpawnArea = new Rectangle2D(new Point2D(X - oldRange, Y - oldRange), + new Point2D(X + oldRange, Y + oldRange)); + } + + m_Kills = reader.ReadInt(); + + goto case 0; } - - m_Kills = reader.ReadInt(); - - goto case 0; - } case 0: - { - if (version < 1) - m_SpawnArea = - new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); //Default was 24 - - bool active = reader.ReadBool(); - m_Type = (ChampionSpawnType)reader.ReadInt(); - m_Creatures = reader.ReadStrongMobileList(); - m_RedSkulls = reader.ReadStrongItemList(); - m_WhiteSkulls = reader.ReadStrongItemList(); - m_Platform = reader.ReadItem(); - m_Altar = reader.ReadItem(); - ExpireDelay = reader.ReadTimeSpan(); - ExpireTime = reader.ReadDeltaTime(); - Champion = reader.ReadMobile(); - RestartDelay = reader.ReadTimeSpan(); - - if (reader.ReadBool()) { - RestartTime = reader.ReadDeltaTime(); - BeginRestart(RestartTime - DateTime.UtcNow); + if (version < 1) + m_SpawnArea = + new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); // Default was 24 + + bool active = reader.ReadBool(); + m_Type = (ChampionSpawnType)reader.ReadInt(); + m_Creatures = reader.ReadStrongMobileList(); + m_RedSkulls = reader.ReadStrongItemList(); + m_WhiteSkulls = reader.ReadStrongItemList(); + m_Platform = reader.ReadItem(); + m_Altar = reader.ReadItem(); + ExpireDelay = reader.ReadTimeSpan(); + ExpireTime = reader.ReadDeltaTime(); + Champion = reader.ReadMobile(); + RestartDelay = reader.ReadTimeSpan(); + + if (reader.ReadBool()) + { + RestartTime = reader.ReadDeltaTime(); + BeginRestart(RestartTime - DateTime.UtcNow); + } + + if (version < 4) + { + m_Idol = new IdolOfTheChampion(this); + m_Idol.MoveToWorld(new Point3D(X, Y, Z - 15), Map); + } + + if (m_Platform == null || m_Altar == null || m_Idol == null) + Delete(); + else if (active) + Start(); + + break; } - - if (version < 4) - { - m_Idol = new IdolOfTheChampion(this); - m_Idol.MoveToWorld(new Point3D(X, Y, Z - 15), Map); - } - - if (m_Platform == null || m_Altar == null || m_Idol == null) - Delete(); - else if (active) - Start(); - - break; - } } Timer.DelayCall(TimeSpan.Zero, UpdateRegion); @@ -1150,7 +1142,7 @@ namespace Server.Engines.CannedEvil public override bool YoungProtected => false; - public ChampionSpawn ChampionSpawn{ get; } + public ChampionSpawn ChampionSpawn { get; } public override bool AllowHousing(Mobile from, Point3D p) => false; @@ -1159,7 +1151,7 @@ namespace Server.Engines.CannedEvil base.AlterLightLevel(m, ref global, ref personal); global = Math.Max(global, 1 + ChampionSpawn - .Level); //This is a guesstimate. TODO: Verify & get exact values // OSI testing: at 2 red skulls, light = 0x3 ; 1 red = 0x3.; 3 = 8; 9 = 0xD 8 = 0xD 12 = 0x12 10 = 0xD + .Level); // This is a guesstimate. TODO: Verify & get exact values // OSI testing: at 2 red skulls, light = 0x3 ; 1 red = 0x3.; 3 = 8; 9 = 0xD 8 = 0xD 12 = 0x12 10 = 0xD } } @@ -1175,7 +1167,7 @@ namespace Server.Engines.CannedEvil { } - public ChampionSpawn Spawn{ get; private set; } + public ChampionSpawn Spawn { get; private set; } public override string DefaultName => "Idol of the Champion"; @@ -1204,14 +1196,14 @@ namespace Server.Engines.CannedEvil switch (version) { case 0: - { - Spawn = reader.ReadItem() as ChampionSpawn; + { + Spawn = reader.ReadItem() as ChampionSpawn; - if (Spawn == null) - Delete(); + if (Spawn == null) + Delete(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/CannedEvil/ChampionSpawnType.cs b/Projects/Scripts/Engines/CannedEvil/ChampionSpawnType.cs index 43bd221f7..328de63f0 100644 --- a/Projects/Scripts/Engines/CannedEvil/ChampionSpawnType.cs +++ b/Projects/Scripts/Engines/CannedEvil/ChampionSpawnType.cs @@ -26,15 +26,15 @@ namespace Server.Engines.CannedEvil SpawnTypes = spawnTypes; } - public string Name{ get; } + public string Name { get; } - public Type Champion{ get; } + public Type Champion { get; } - public Type[][] SpawnTypes{ get; } + public Type[][] SpawnTypes { get; } - public string[] LevelNames{ get; } + public string[] LevelNames { get; } - public static ChampionSpawnInfo[] Table{ get; } = + public static ChampionSpawnInfo[] Table { get; } = { new ChampionSpawnInfo("Abyss", typeof(Semidar), new[] { "Foe", "Assassin", "Conqueror" }, new[] // Abyss { diff --git a/Projects/Scripts/Engines/CannedEvil/HarrowerGate.cs b/Projects/Scripts/Engines/CannedEvil/HarrowerGate.cs index 27f803ff3..8709a32cc 100644 --- a/Projects/Scripts/Engines/CannedEvil/HarrowerGate.cs +++ b/Projects/Scripts/Engines/CannedEvil/HarrowerGate.cs @@ -39,14 +39,14 @@ namespace Server.Items switch (version) { case 0: - { - m_Harrower = reader.ReadMobile(); + { + m_Harrower = reader.ReadMobile(); - if (m_Harrower == null) - Delete(); + if (m_Harrower == null) + Delete(); - break; - } + break; + } } if (Light != LightType.Circle300) diff --git a/Projects/Scripts/Engines/CannedEvil/RestartTimer.cs b/Projects/Scripts/Engines/CannedEvil/RestartTimer.cs index 692d89fde..7b30fbfd7 100644 --- a/Projects/Scripts/Engines/CannedEvil/RestartTimer.cs +++ b/Projects/Scripts/Engines/CannedEvil/RestartTimer.cs @@ -4,7 +4,7 @@ namespace Server.Engines.CannedEvil { public class RestartTimer : Timer { - private ChampionSpawn m_Spawn; + private readonly ChampionSpawn m_Spawn; public RestartTimer(ChampionSpawn spawn, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Engines/CannedEvil/SliceTimer.cs b/Projects/Scripts/Engines/CannedEvil/SliceTimer.cs index b28e52af1..99b69495d 100644 --- a/Projects/Scripts/Engines/CannedEvil/SliceTimer.cs +++ b/Projects/Scripts/Engines/CannedEvil/SliceTimer.cs @@ -4,7 +4,7 @@ namespace Server.Engines.CannedEvil { public class SliceTimer : Timer { - private ChampionSpawn m_Spawn; + private readonly ChampionSpawn m_Spawn; public SliceTimer(ChampionSpawn spawn) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) { diff --git a/Projects/Scripts/Engines/CannedEvil/StarRoomGate.cs b/Projects/Scripts/Engines/CannedEvil/StarRoomGate.cs index a0f12727b..b8787d637 100644 --- a/Projects/Scripts/Engines/CannedEvil/StarRoomGate.cs +++ b/Projects/Scripts/Engines/CannedEvil/StarRoomGate.cs @@ -65,25 +65,25 @@ namespace Server.Items switch (version) { case 0: - { - m_Decays = reader.ReadBool(); - - if (m_Decays) { - m_DecayTime = reader.ReadDeltaTime(); + m_Decays = reader.ReadBool(); - m_Timer = new InternalTimer(this, m_DecayTime); - m_Timer.Start(); + if (m_Decays) + { + m_DecayTime = reader.ReadDeltaTime(); + + m_Timer = new InternalTimer(this, m_DecayTime); + m_Timer.Start(); + } + + break; } - - break; - } } } private class InternalTimer : Timer { - private Item m_Item; + private readonly Item m_Item; public InternalTimer(Item item, DateTime end) : base(end - DateTime.UtcNow) => m_Item = item; diff --git a/Projects/Scripts/Engines/Chat/Channel.cs b/Projects/Scripts/Engines/Chat/Channel.cs index bc1a54ba8..6c890a81c 100644 --- a/Projects/Scripts/Engines/Chat/Channel.cs +++ b/Projects/Scripts/Engines/Chat/Channel.cs @@ -6,7 +6,10 @@ namespace Server.Engines.Chat { private string m_Name; private string m_Password; - private List m_Users, m_Banned, m_Moderators, m_Voices; + private readonly List m_Users; + private readonly List m_Banned; + private readonly List m_Moderators; + private readonly List m_Voices; private bool m_VoiceRestricted; public Channel(string name) @@ -66,9 +69,9 @@ namespace Server.Engines.Chat } } - public bool AlwaysAvailable{ get; set; } + public bool AlwaysAvailable { get; set; } - public static List Channels{ get; } = new List(); + public static List Channels { get; } = new List(); public bool Contains(ChatUser user) => m_Users.Contains(user); @@ -100,7 +103,6 @@ namespace Server.Engines.Chat from.Mobile.SendMessage("Your access level is too low to do this."); return false; - } public bool AddUser(ChatUser user, string password = null) @@ -132,7 +134,7 @@ namespace Server.Engines.Chat m_Users.Add(user); user.CurrentChannel = this; - if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || !AlwaysAvailable && m_Users.Count == 1) + if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!AlwaysAvailable && m_Users.Count == 1)) AddModerator(user); SendUsersTo(user); diff --git a/Projects/Scripts/Engines/Chat/Chat.cs b/Projects/Scripts/Engines/Chat/Chat.cs index 705463ec5..2f38299bb 100644 --- a/Projects/Scripts/Engines/Chat/Chat.cs +++ b/Projects/Scripts/Engines/Chat/Chat.cs @@ -8,7 +8,7 @@ namespace Server.Engines.Chat { public class ChatSystem { - public static bool Enabled{ get; set; } = true; + public static bool Enabled { get; set; } = true; public static void Initialize() { @@ -128,9 +128,10 @@ namespace Server.Engines.Chat Channel channel = user.CurrentChannel; if (handler.RequireConference && channel == null) - user.SendMessage(31); /* You must be in a conference to do this. - * To join a conference, select one from the Conference menu. - */ + /* You must be in a conference to do this. + * To join a conference, select one from the Conference menu. + */ + user.SendMessage(31); else if (handler.RequireModerator && !user.IsModerator) user.SendMessage(29); // You must have operator status to do this. else @@ -147,4 +148,4 @@ namespace Server.Engines.Chat } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Chat/ChatActionHandler.cs b/Projects/Scripts/Engines/Chat/ChatActionHandler.cs index 5130d31b4..9f11a6af2 100644 --- a/Projects/Scripts/Engines/Chat/ChatActionHandler.cs +++ b/Projects/Scripts/Engines/Chat/ChatActionHandler.cs @@ -11,10 +11,10 @@ namespace Server.Engines.Chat Callback = callback; } - public bool RequireModerator{ get; } + public bool RequireModerator { get; } - public bool RequireConference{ get; } + public bool RequireConference { get; } - public OnChatAction Callback{ get; } + public OnChatAction Callback { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Chat/ChatActionHandlers.cs b/Projects/Scripts/Engines/Chat/ChatActionHandlers.cs index b6ad6c2df..cf2a4a660 100644 --- a/Projects/Scripts/Engines/Chat/ChatActionHandlers.cs +++ b/Projects/Scripts/Engines/Chat/ChatActionHandlers.cs @@ -2,7 +2,7 @@ namespace Server.Engines.Chat { public class ChatActionHandlers { - private static ChatActionHandler[] m_Handlers; + private static readonly ChatActionHandler[] m_Handlers; static ChatActionHandlers() { @@ -111,9 +111,10 @@ namespace Server.Engines.Chat public static void DisallowPrivateMessages(ChatUser from, Channel channel, string param) { from.IgnorePrivateMessage = true; - from.SendMessage(38); /* You will no longer receive private messages. - * Those who send you a message will be notified that you are blocking incoming messages. - */ + /* You will no longer receive private messages. + * Those who send you a message will be notified that you are blocking incoming messages. + */ + from.SendMessage(38); } public static void TogglePrivateMessages(ChatUser from, Channel channel, string param) diff --git a/Projects/Scripts/Engines/Chat/ChatUser.cs b/Projects/Scripts/Engines/Chat/ChatUser.cs index a24ee7508..1a02c2924 100644 --- a/Projects/Scripts/Engines/Chat/ChatUser.cs +++ b/Projects/Scripts/Engines/Chat/ChatUser.cs @@ -9,8 +9,8 @@ namespace Server.Engines.Chat public const char ModeratorColorCharacter = '1'; public const char VoicedColorCharacter = '2'; - private static List m_Users = new List(); - private static Dictionary m_Table = new Dictionary(); + private static readonly List m_Users = new List(); + private static readonly Dictionary m_Table = new Dictionary(); public ChatUser(Mobile m) { @@ -19,11 +19,11 @@ namespace Server.Engines.Chat Ignoring = new List(); } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public List Ignored{ get; } + public List Ignored { get; } - public List Ignoring{ get; } + public List Ignoring { get; } public string Username { @@ -41,13 +41,13 @@ namespace Server.Engines.Chat } } - public Channel CurrentChannel{ get; set; } + public Channel CurrentChannel { get; set; } public bool IsOnline => Mobile.NetState != null; - public bool Anonymous{ get; set; } + public bool Anonymous { get; set; } - public bool IgnorePrivateMessage{ get; set; } + public bool IgnorePrivateMessage { get; set; } public bool IsModerator => CurrentChannel?.IsModerator(this) == true; @@ -135,7 +135,7 @@ namespace Server.Engines.Chat break; } - //ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username ); + // ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username ); return user; } diff --git a/Projects/Scripts/Engines/Chat/Packets.cs b/Projects/Scripts/Engines/Chat/Packets.cs index 7ffef69c8..04bec8725 100644 --- a/Projects/Scripts/Engines/Chat/Packets.cs +++ b/Projects/Scripts/Engines/Chat/Packets.cs @@ -11,15 +11,15 @@ namespace Server.Engines.Chat EnsureCapacity(13 + (param1.Length + param2.Length) * 2); - m_Stream.Write((ushort)(number - 20)); + Stream.Write((ushort)(number - 20)); if (who != null) - m_Stream.WriteAsciiFixed(who.Language, 4); + Stream.WriteAsciiFixed(who.Language, 4); else - m_Stream.Write(0); + Stream.Write(0); - m_Stream.WriteBigUniNull(param1); - m_Stream.WriteBigUniNull(param2); + Stream.WriteBigUniNull(param1); + Stream.WriteBigUniNull(param2); } } } diff --git a/Projects/Scripts/Engines/ConPVP/AcceptDuelGump.cs b/Projects/Scripts/Engines/ConPVP/AcceptDuelGump.cs index 99b8f3cd8..7e77d37ba 100644 --- a/Projects/Scripts/Engines/ConPVP/AcceptDuelGump.cs +++ b/Projects/Scripts/Engines/ConPVP/AcceptDuelGump.cs @@ -11,13 +11,14 @@ namespace Server.Engines.ConPVP private const int LabelColor32 = 0xFFFFFF; private const int BlackColor32 = 0x000008; - private static Dictionary> m_IgnoreLists = new Dictionary>(); + private static readonly Dictionary> m_IgnoreLists = new Dictionary>(); private bool m_Active = true; - private Mobile m_Challenger, m_Challenged; - private DuelContext m_Context; - private Participant m_Participant; - private int m_Slot; + private readonly Mobile m_Challenger; + private readonly Mobile m_Challenged; + private readonly DuelContext m_Context; + private readonly Participant m_Participant; + private readonly int m_Slot; public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(50, 50) @@ -34,15 +35,15 @@ namespace Server.Engines.ConPVP AddPage(0); - //AddBackground( 0, 0, 400, 220, 9150 ); + // AddBackground( 0, 0, 400, 220, 9150 ); AddBackground(1, 1, 398, 218, 3600); - //AddBackground( 16, 15, 369, 189, 9100 ); + // AddBackground( 16, 15, 369, 189, 9100 ); AddImageTiled(16, 15, 369, 189, 3604); AddAlphaRegion(16, 15, 369, 189); AddImage(215, -43, 0xEE40); - //AddImage( 330, 141, 0x8BA ); + // AddImage( 330, 141, 0x8BA ); AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); @@ -251,9 +252,9 @@ namespace Server.Engines.ConPVP private class IgnoreEntry { - private static TimeSpan ExpireDelay = TimeSpan.FromMinutes(15.0); + private static readonly TimeSpan ExpireDelay = TimeSpan.FromMinutes(15.0); public DateTime m_Expire; - public Mobile m_Ignored; + public readonly Mobile m_Ignored; public IgnoreEntry(Mobile ignored) { diff --git a/Projects/Scripts/Engines/ConPVP/Arena.cs b/Projects/Scripts/Engines/ConPVP/Arena.cs index 435aa1f3d..7d1e510e4 100644 --- a/Projects/Scripts/Engines/ConPVP/Arena.cs +++ b/Projects/Scripts/Engines/ConPVP/Arena.cs @@ -24,14 +24,14 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public Arena Arena{ get; private set; } + public Arena Arena { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public bool IsPrivate{ get; set; } + public bool IsPrivate { get; set; } public override string DefaultName => "arena controller"; - public static List Instances{ get; set; } = new List(); + public static List Instances { get; set; } = new List(); public override void OnDelete() { @@ -67,16 +67,16 @@ namespace Server.Engines.ConPVP switch (version) { case 1: - { - IsPrivate = reader.ReadBool(); + { + IsPrivate = reader.ReadBool(); - goto case 0; - } + goto case 0; + } case 0: - { - Arena = new Arena(reader); - break; - } + { + Arena = new Arena(reader); + break; + } } Instances.Add(this); @@ -96,7 +96,7 @@ namespace Server.Engines.ConPVP Points[i] = reader.ReadPoint3D(); } - public Point3D[] Points{ get; } + public Point3D[] Points { get; } [CommandProperty(AccessLevel.GameMaster)] public Point3D EdgeWest @@ -194,74 +194,74 @@ namespace Server.Engines.ConPVP switch (version) { case 7: - { - m_IsGuarded = reader.ReadBool(); + { + m_IsGuarded = reader.ReadBool(); - goto case 6; - } + goto case 6; + } case 6: - { - Ladder = reader.ReadItem() as LadderController; + { + Ladder = reader.ReadItem() as LadderController; - goto case 5; - } + goto case 5; + } case 5: - { - m_Tournament = reader.ReadItem() as TournamentController; - Announcer = reader.ReadMobile(); + { + m_Tournament = reader.ReadItem() as TournamentController; + Announcer = reader.ReadMobile(); - goto case 4; - } + goto case 4; + } case 4: - { - m_Name = reader.ReadString(); + { + m_Name = reader.ReadString(); - goto case 3; - } + goto case 3; + } case 3: - { - m_Zone = reader.ReadRect2D(); + { + m_Zone = reader.ReadRect2D(); - goto case 2; - } + goto case 2; + } case 2: - { - GateIn = reader.ReadPoint3D(); - m_GateOut = reader.ReadPoint3D(); - Teleporter = reader.ReadItem(); + { + GateIn = reader.ReadPoint3D(); + m_GateOut = reader.ReadPoint3D(); + Teleporter = reader.ReadItem(); - goto case 1; - } + goto case 1; + } case 1: - { - Players = reader.ReadStrongMobileList(); + { + Players = reader.ReadStrongMobileList(); - goto case 0; - } + goto case 0; + } case 0: - { - m_Facet = reader.ReadMap(); - m_Bounds = reader.ReadRect2D(); - Outside = reader.ReadPoint3D(); - Wall = reader.ReadPoint3D(); - - if (version == 0) { - reader.ReadBool(); - Players = new List(); + m_Facet = reader.ReadMap(); + m_Bounds = reader.ReadRect2D(); + Outside = reader.ReadPoint3D(); + Wall = reader.ReadPoint3D(); + + if (version == 0) + { + reader.ReadBool(); + Players = new List(); + } + + m_Active = reader.ReadBool(); + Points = new ArenaStartPoints(reader); + + if (m_Active) + { + Arenas.Add(this); + Arenas.Sort(); + } + + break; } - - m_Active = reader.ReadBool(); - Points = new ArenaStartPoints(reader); - - if (m_Active) - { - Arenas.Add(this); - Arenas.Sort(); - } - - break; - } } if (m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null) @@ -275,7 +275,7 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public LadderController Ladder{ get; set; } + public LadderController Ladder { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsGuarded @@ -305,7 +305,7 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Announcer{ get; set; } + public Mobile Announcer { get; set; } [CommandProperty(AccessLevel.GameMaster)] public string Name @@ -385,10 +385,10 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Outside{ get; set; } + public Point3D Outside { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D GateIn{ get; set; } + public Point3D GateIn { get; set; } [CommandProperty(AccessLevel.GameMaster)] public Point3D GateOut @@ -403,17 +403,17 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Wall{ get; set; } + public Point3D Wall { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsOccupied => Players.Count > 0; [CommandProperty(AccessLevel.GameMaster)] - public ArenaStartPoints Points{ get; private set; } + public ArenaStartPoints Points { get; private set; } - public Item Teleporter{ get; set; } + public Item Teleporter { get; set; } - public List Players{ get; } + public List Players { get; } [CommandProperty(AccessLevel.GameMaster)] public bool Active @@ -448,7 +448,7 @@ namespace Server.Engines.ConPVP } } - public static List Arenas{ get; } = new List(); + public static List Arenas { get; } = new List(); public int CompareTo(Arena c) { @@ -738,7 +738,7 @@ namespace Server.Engines.ConPVP private class ArenaEntry { - public Arena m_Arena; + public readonly Arena m_Arena; public int m_VotesAgainst; public int m_VotesFor; @@ -747,9 +747,7 @@ namespace Server.Engines.ConPVP public int Value => m_VotesFor; } - #region Offsets & Rotation - - private static Point2D[] m_EdgeOffsets = + private static readonly Point2D[] m_EdgeOffsets = { /* * /\ @@ -772,7 +770,7 @@ namespace Server.Engines.ConPVP }; // nw corner - private static Point2D[] m_CornerOffsets = + private static readonly Point2D[] m_CornerOffsets = { /* * /\ @@ -793,7 +791,7 @@ namespace Server.Engines.ConPVP new Point2D(3, 0) }; - private static int[][,] m_Rotate = + private static readonly int[][,] m_Rotate = { new[,] { { +1, 0 }, { 0, +1 } }, // west new[,] { { -1, 0 }, { 0, -1 } }, // east @@ -804,7 +802,5 @@ namespace Server.Engines.ConPVP new[,] { { 0, +1 }, { +1, 0 } }, // sw new[,] { { 0, -1 }, { -1, 0 } } // ne }; - - #endregion } } diff --git a/Projects/Scripts/Engines/ConPVP/DuelContext.cs b/Projects/Scripts/Engines/ConPVP/DuelContext.cs index 6cfe4eefd..88675c2c5 100644 --- a/Projects/Scripts/Engines/ConPVP/DuelContext.cs +++ b/Projects/Scripts/Engines/ConPVP/DuelContext.cs @@ -26,8 +26,8 @@ namespace Server.Engines.ConPVP public class DuelContext { - private static TimeSpan CombatDelay = TimeSpan.FromSeconds(30.0); - private static TimeSpan AutoTieDelay = TimeSpan.FromMinutes(15.0); + private static readonly TimeSpan CombatDelay = TimeSpan.FromSeconds(30.0); + private static readonly TimeSpan AutoTieDelay = TimeSpan.FromMinutes(15.0); private Timer m_AutoTieTimer; @@ -44,7 +44,7 @@ namespace Server.Engines.ConPVP private Timer m_SDWarnTimer, m_SDActivateTimer; public Tournament m_Tournament; - private List m_Walls = new List(); + private readonly List m_Walls = new List(); private bool m_Yielding; @@ -63,36 +63,36 @@ namespace Server.Engines.ConPVP } } - public bool Rematch{ get; private set; } + public bool Rematch { get; private set; } - public bool ReadyWait{ get; private set; } + public bool ReadyWait { get; private set; } - public int ReadyCount{ get; private set; } + public int ReadyCount { get; private set; } - public bool Registered{ get; private set; } = true; + public bool Registered { get; private set; } = true; - public bool Finished{ get; private set; } + public bool Finished { get; private set; } - public bool Started{ get; private set; } + public bool Started { get; private set; } - public Mobile Initiator{ get; } + public Mobile Initiator { get; } - public List Participants{ get; } + public List Participants { get; } - public Ruleset Ruleset{ get; private set; } + public Ruleset Ruleset { get; private set; } - public Arena Arena{ get; private set; } + public Arena Arena { get; private set; } - public bool Tied{ get; private set; } + public bool Tied { get; private set; } - public bool IsSuddenDeath{ get; set; } + public bool IsSuddenDeath { get; set; } public bool IsOneVsOne => Participants.Count == 2 && Participants[0].Players.Length == 1 && Participants[1].Players.Length == 1; - public bool StartedBeginCountdown{ get; private set; } + public bool StartedBeginCountdown { get; private set; } - public bool StartedReadyCountdown{ get; private set; } + public bool StartedReadyCountdown { get; private set; } public Tournament Tournament => m_Tournament; @@ -139,7 +139,6 @@ namespace Server.Engines.ConPVP else if (move is SamuraiMove) title = "Ninjitsu"; - if (title == null || name == null || Ruleset.GetOption(title, name)) return true; @@ -1202,7 +1201,7 @@ namespace Server.Engines.ConPVP if (instance == null) { - //pm.SendMessage( "Ladder not yet initialized." ); + // pm.SendMessage( "Ladder not yet initialized." ); } else { @@ -1218,8 +1217,8 @@ namespace Server.Engines.ConPVP pm.NonlocalOverheadMessage(MessageType.Regular, pm.SpeechHue, true, string.Format(text, pm.Name, "is")); - //pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) ); - //pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) ); + // pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) ); + // pm.PublicOverheadMessage( MessageType.Regular, pm.SpeechHue, true, String.Format( "Level {0} with {1} win{2} and {3} loss{4}.", Ladder.GetLevel( entry.Experience ), entry.Wins, entry.Wins==1?"":"s", entry.Losses, entry.Losses==1?"":"es" ) ); } } } @@ -1236,7 +1235,7 @@ namespace Server.Engines.ConPVP if (instance == null) { - //pm.SendMessage( "Ladder not yet initialized." ); + // pm.SendMessage( "Ladder not yet initialized." ); } else { @@ -1765,7 +1764,7 @@ namespace Server.Engines.ConPVP BounceInfo bi = inHand.GetBounce(); - if (bi.m_Parent == mob) + if (bi.Parent == mob) pack.DropItem(inHand); else inHand.Bounce(mob); @@ -2210,11 +2209,11 @@ namespace Server.Engines.ConPVP m_Expire = DateTime.UtcNow + TimeSpan.FromMinutes(30.0); } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public Point3D Location{ get; private set; } + public Point3D Location { get; private set; } - public Map Facet{ get; private set; } + public Map Facet { get; private set; } public bool Expired => DateTime.UtcNow >= m_Expire; @@ -2351,29 +2350,29 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - int count = reader.ReadEncodedInt(); - - m_Entries = new List(count); - - for (int i = 0; i < count; ++i) { - Mobile mob = reader.ReadMobile(); - Point3D loc = reader.ReadPoint3D(); - Map map = reader.ReadMap(); + int count = reader.ReadEncodedInt(); - m_Entries.Add(new ReturnEntry(mob, loc, map)); + m_Entries = new List(count); + + for (int i = 0; i < count; ++i) + { + Mobile mob = reader.ReadMobile(); + Point3D loc = reader.ReadPoint3D(); + Map map = reader.ReadMap(); + + m_Entries.Add(new ReturnEntry(mob, loc, map)); + } + + break; } - - break; - } } } } private class ArenaMoongate : ConfirmationMoongate { - private ExitTeleporter m_Teleporter; + private readonly ExitTeleporter m_Teleporter; public ArenaMoongate(Point3D target, Map map, ExitTeleporter tp) : base(target, map) { diff --git a/Projects/Scripts/Engines/ConPVP/Games/BombingRun.cs b/Projects/Scripts/Engines/ConPVP/Games/BombingRun.cs index 42ac03d21..2d6834173 100644 --- a/Projects/Scripts/Engines/ConPVP/Games/BombingRun.cs +++ b/Projects/Scripts/Engines/ConPVP/Games/BombingRun.cs @@ -14,16 +14,15 @@ namespace Server.Engines.ConPVP { private bool m_Flying; - private BRGame m_Game; + private readonly BRGame m_Game; - private List m_Helpers; + private readonly List m_Helpers; - private Point3DList m_Path = new Point3DList(); + private readonly Point3DList m_Path = new Point3DList(); private int m_PathIdx; - private EffectTimer m_Timer; + private readonly EffectTimer m_Timer; - public BRBomb(BRGame game) : - base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball + public BRBomb(BRGame game) : base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball { Movable = false; Hue = 0x35; @@ -42,7 +41,7 @@ namespace Server.Engines.ConPVP public override string DefaultName => "da bomb"; - public Mobile Thrower{ get; private set; } + public Mobile Thrower { get; private set; } private Mobile FindOwner(IEntity parent) { @@ -64,9 +63,9 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - break; - } + { + break; + } } Timer.DelayCall(TimeSpan.Zero, Delete).Start(); // delete this after the world loads @@ -262,7 +261,7 @@ namespace Server.Engines.ConPVP org.Z += 10; // always add 10 at the start cause we're coming from a mobile's eye level - /*if ( org.X > dest.X || ( org.X == dest.X && org.Y > dest.Y ) || ( org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z ) ) + /*if (org.X > dest.X || ( org.X == dest.X && org.Y > dest.Y ) || ( org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z )) { Point3D swap = org; org = dest; @@ -311,12 +310,12 @@ namespace Server.Engines.ConPVP if (list.Count > 0 && list[list.Count - 1] != dest) list.Add(dest); - /*if ( dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y ) ) + /*if (dist3d > 4 && ( dest.X != org.X || dest.Y != org.Y )) { int count = list.Count; int i; int climb = count / 2; - if ( climb > 3 ) + if (climb > 3) climb = 3; for ( i = 0; i < climb; i++ ) @@ -470,7 +469,7 @@ namespace Server.Engines.ConPVP point = m_Path[j]; if (loc.X == point.X && loc.Y == point.Y && - (i is Blocker || loc.Z <= point.Z && loc.Z + height >= point.Z)) + (i is Blocker || (loc.Z <= point.Z && loc.Z + height >= point.Z))) { found = true; if (j > m_PathIdx) @@ -663,7 +662,7 @@ namespace Server.Engines.ConPVP private class EffectTimer : Timer { - private BRBomb m_Bomb; + private readonly BRBomb m_Bomb; private int m_Count; public EffectTimer(BRBomb bomb) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) @@ -705,8 +704,8 @@ namespace Server.Engines.ConPVP private class BombTarget : Target { - private BRBomb m_Bomb; - private Mobile m_Mob; + private readonly BRBomb m_Bomb; + private readonly Mobile m_Mob; private bool m_Resend = true; public BombTarget(BRBomb bomb, Mobile from) : base(10, true, TargetFlags.None) @@ -880,14 +879,14 @@ namespace Server.Engines.ConPVP switch (version) { case 1: - { - m_North = reader.ReadBool(); - goto case 0; - } + { + m_North = reader.ReadBool(); + goto case 0; + } case 0: - { - break; - } + { + break; + } } Hue = 0x84C; @@ -959,11 +958,11 @@ namespace Server.Engines.ConPVP private const int LabelColor32 = 0xFFFFFF; private const int BlackColor32 = 0x000000; - // private BRGame m_Game; + // private BRGame m_Game; public BRBoardGump(Mobile mob, BRGame game, BRTeamInfo section = null) : base(60, 60) { - // m_Game = game; + // m_Game = game; BRTeamInfo ourTeam = game.GetTeamInfo(mob); @@ -1010,7 +1009,7 @@ namespace Server.Engines.ConPVP AddAlphaRegion(16, 15, 369, height - 29); AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); + // AddImage( 330, 141, 0x8BA ); AddBorderedText(22, 22, 294, 20, Center("BR Scoreboard"), LabelColor32, BlackColor32); @@ -1117,7 +1116,7 @@ namespace Server.Engines.ConPVP private int m_Kills; private int m_Score; - private BRTeamInfo m_TeamInfo; + private readonly BRTeamInfo m_TeamInfo; public BRPlayerInfo(BRTeamInfo teamInfo, Mobile player) { @@ -1125,7 +1124,7 @@ namespace Server.Engines.ConPVP Player = player; } - public Mobile Player{ get; } + public Mobile Player { get; } public int CompareTo(BRPlayerInfo pi) { @@ -1198,26 +1197,26 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Board = ip.ReadItem() as BRBoard; - TeamName = ip.ReadString(); - Color = ip.ReadEncodedInt(); - m_Goal = ip.ReadItem() as BRGoal; - break; - } + { + Board = ip.ReadItem() as BRBoard; + TeamName = ip.ReadString(); + Color = ip.ReadEncodedInt(); + m_Goal = ip.ReadItem() as BRGoal; + break; + } } } - public BRGame Game{ get; set; } + public BRGame Game { get; set; } - public int TeamID{ get; } + public int TeamID { get; } - public BRPlayerInfo Leader{ get; set; } + public BRPlayerInfo Leader { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public BRBoard Board{ get; set; } + public BRBoard Board { get; set; } - public Dictionary Players{ get; } + public Dictionary Players { get; } public BRPlayerInfo this[Mobile mob] { @@ -1234,10 +1233,10 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } + public int Color { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string TeamName{ get; set; } + public string TeamName { get; set; } [CommandProperty(AccessLevel.GameMaster)] public BRGoal Goal @@ -1267,11 +1266,11 @@ namespace Server.Engines.ConPVP public string Name => $"{TeamName} Team"; - public int Kills{ get; set; } + public int Kills { get; set; } - public int Captures{ get; set; } + public int Captures { get; set; } - public int Score{ get; set; } + public int Score { get; set; } public void Reset() { @@ -1333,7 +1332,7 @@ namespace Server.Engines.ConPVP { } - public BRTeamInfo[] TeamInfo{ get; private set; } + public BRTeamInfo[] TeamInfo { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public BRTeamInfo Team1 => TeamInfo[0]; @@ -1348,10 +1347,10 @@ namespace Server.Engines.ConPVP public BRTeamInfo Team4 => TeamInfo[3]; [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } + public TimeSpan Duration { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D BombHome{ get; set; } + public Point3D BombHome { get; set; } public override string Title => "Bombing Run"; public override string DefaultName => "Bombing Run Controller"; @@ -1385,18 +1384,18 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - BombHome = reader.ReadPoint3D(); + { + BombHome = reader.ReadPoint3D(); - Duration = reader.ReadTimeSpan(); + Duration = reader.ReadTimeSpan(); - TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()]; + TeamInfo = new BRTeamInfo[reader.ReadEncodedInt()]; - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new BRTeamInfo(i, reader); + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new BRTeamInfo(i, reader); - break; - } + break; + } } } } @@ -1411,7 +1410,7 @@ namespace Server.Engines.ConPVP public BRGame(BRController controller, DuelContext context) : base(context) => Controller = controller; - public BRController Controller{ get; } + public BRController Controller { get; } public Map Facet { @@ -1676,8 +1675,8 @@ namespace Server.Engines.ConPVP { sb.Append(": "); - //sb.Append( pl.Score.ToString( "N0" ) ); - //sb.Append( pl.Score == 1 ? " point" : " points" ); + // sb.Append( pl.Score.ToString( "N0" ) ); + // sb.Append( pl.Score == 1 ? " point" : " points" ); sb.Append(pl.Kills.ToString("N0")); sb.Append(pl.Kills == 1 ? " kill" : " kills"); diff --git a/Projects/Scripts/Engines/ConPVP/Games/CTF.cs b/Projects/Scripts/Engines/ConPVP/Games/CTF.cs index 190067c3f..bbc8719a6 100644 --- a/Projects/Scripts/Engines/ConPVP/Games/CTF.cs +++ b/Projects/Scripts/Engines/ConPVP/Games/CTF.cs @@ -81,7 +81,7 @@ namespace Server.Engines.ConPVP if (player.Score > 0) entries.Add(player); - entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); + entries.Sort((a, b) => b.Score - a.Score); int height = 0; @@ -102,7 +102,7 @@ namespace Server.Engines.ConPVP AddAlphaRegion(16, 15, 369, height - 29); AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); + // AddImage( 330, 141, 0x8BA ); AddBorderedText(22, 22, 294, 20, Center("CTF Scoreboard"), LabelColor32, BlackColor32); @@ -345,27 +345,27 @@ namespace Server.Engines.ConPVP case 3: case 2: case 1: - { - owner?.SendMessage(0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount, - m_ReturnCount == 1 ? "second" : "seconds"); - - break; - } - - case 0: - { - if (owner != null) { - owner.SendMessage(0x26, "You have taken too long to capture the cookies!"); - owner.Kill(); + owner?.SendMessage(0x26, "You have {0} {1} to capture the cookies!", m_ReturnCount, + m_ReturnCount == 1 ? "second" : "seconds"); + + break; } - SendHome(); + case 0: + { + if (owner != null) + { + owner.SendMessage(0x26, "You have taken too long to capture the cookies!"); + owner.Kill(); + } - m_TeamInfo?.Game?.Alert("The {0} cookies have been returned.", m_TeamInfo.Name); + SendHome(); - return; - } + m_TeamInfo?.Game?.Alert("The {0} cookies have been returned.", m_TeamInfo.Name); + + return; + } } --m_ReturnCount; @@ -497,10 +497,10 @@ namespace Server.Engines.ConPVP public interface IRankedCTF { - int Kills{ get; } - int Captures{ get; } - int Score{ get; } - string Name{ get; } + int Kills { get; } + int Captures { get; } + int Score { get; } + string Name { get; } } public sealed class CTFPlayerInfo : IRankedCTF @@ -510,7 +510,7 @@ namespace Server.Engines.ConPVP private int m_Kills; private int m_Score; - private CTFTeamInfo m_TeamInfo; + private readonly CTFTeamInfo m_TeamInfo; public CTFPlayerInfo(CTFTeamInfo teamInfo, Mobile player) { @@ -518,7 +518,7 @@ namespace Server.Engines.ConPVP Player = player; } - public Mobile Player{ get; } + public Mobile Player { get; } string IRankedCTF.Name => Player.Name; @@ -575,38 +575,38 @@ namespace Server.Engines.ConPVP switch (version) { case 2: - { - Board = ip.ReadItem() as CTFBoard; + { + Board = ip.ReadItem() as CTFBoard; - goto case 1; - } + goto case 1; + } case 1: - { - Name = ip.ReadString(); + { + Name = ip.ReadString(); - goto case 0; - } + goto case 0; + } case 0: - { - Color = ip.ReadEncodedInt(); + { + Color = ip.ReadEncodedInt(); - Flag = ip.ReadItem() as CTFFlag; - Origin = ip.ReadPoint3D(); - break; - } + Flag = ip.ReadItem() as CTFFlag; + Origin = ip.ReadPoint3D(); + break; + } } } - public CTFGame Game{ get; set; } + public CTFGame Game { get; set; } - public int TeamID{ get; } + public int TeamID { get; } - public CTFPlayerInfo Leader{ get; set; } + public CTFPlayerInfo Leader { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public CTFBoard Board{ get; set; } + public CTFBoard Board { get; set; } - public Dictionary Players{ get; } + public Dictionary Players { get; } public CTFPlayerInfo this[Mobile mob] { @@ -623,24 +623,24 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } + public int Color { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string Name{ get; set; } + public string Name { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public CTFFlag Flag{ get; set; } + public CTFFlag Flag { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Origin{ get; set; } + public Point3D Origin { get; set; } string IRankedCTF.Name => $"{Name} Team"; - public int Kills{ get; set; } + public int Kills { get; set; } - public int Captures{ get; set; } + public int Captures { get; set; } - public int Score{ get; set; } + public int Score { get; set; } public void Reset() { @@ -702,7 +702,7 @@ namespace Server.Engines.ConPVP { } - public CTFTeamInfo[] TeamInfo{ get; private set; } + public CTFTeamInfo[] TeamInfo { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public CTFTeamInfo Team1 => TeamInfo[0]; @@ -729,7 +729,7 @@ namespace Server.Engines.ConPVP public CTFTeamInfo Team8 => TeamInfo[7]; [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } + public TimeSpan Duration { get; set; } public override string Title => "CTF"; @@ -760,29 +760,29 @@ namespace Server.Engines.ConPVP switch (version) { case 2: - { - Duration = reader.ReadTimeSpan(); + { + Duration = reader.ReadTimeSpan(); - goto case 1; - } + goto case 1; + } case 1: - { - TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()]; + { + TeamInfo = new CTFTeamInfo[reader.ReadEncodedInt()]; - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new CTFTeamInfo(i, reader); + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new CTFTeamInfo(i, reader); - break; - } + break; + } case 0: - { - TeamInfo = new CTFTeamInfo[8]; + { + TeamInfo = new CTFTeamInfo[8]; - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new CTFTeamInfo(i); + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new CTFTeamInfo(i); - break; - } + break; + } } if (version < 2) @@ -796,7 +796,7 @@ namespace Server.Engines.ConPVP public CTFGame(CTFController controller, DuelContext context) : base(context) => Controller = controller; - public CTFController Controller{ get; } + public CTFController Controller { get; } public Map Facet { @@ -999,7 +999,7 @@ namespace Server.Engines.ConPVP teams.Add(teamInfo); } - teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b) { return b.Score - a.Score; }); + teams.Sort((a, b) => b.Score - a.Score); Tournament tourney = m_Context.m_Tournament; @@ -1063,7 +1063,7 @@ namespace Server.Engines.ConPVP if (mob == null) continue; - //"Red v Blue CTF Champion" + // "Red v Blue CTF Champion" sb = new StringBuilder(); diff --git a/Projects/Scripts/Engines/ConPVP/Games/DoubleDom.cs b/Projects/Scripts/Engines/ConPVP/Games/DoubleDom.cs index 4025b0516..746d4243a 100644 --- a/Projects/Scripts/Engines/ConPVP/Games/DoubleDom.cs +++ b/Projects/Scripts/Engines/ConPVP/Games/DoubleDom.cs @@ -52,12 +52,12 @@ namespace Server.Engines.ConPVP private const int LabelColor32 = 0xFFFFFF; private const int BlackColor32 = 0x000000; - // private DDGame m_Game; + // private DDGame m_Game; public DDBoardGump(Mobile mob, DDGame game, DDTeamInfo section = null) : base(60, 60) { - // m_Game = game; + // m_Game = game; DDTeamInfo ourTeam = game.GetTeamInfo(mob); @@ -76,7 +76,7 @@ namespace Server.Engines.ConPVP if (player.Score > 0) entries.Add(player); - entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); + entries.Sort((a, b) => b.Score - a.Score); int height = 0; @@ -97,7 +97,7 @@ namespace Server.Engines.ConPVP AddAlphaRegion(16, 15, 369, height - 29); AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); + // AddImage( 330, 141, 0x8BA ); AddBorderedText(22, 22, 294, 20, Center("DD Scoreboard"), LabelColor32, BlackColor32); @@ -204,7 +204,7 @@ namespace Server.Engines.ConPVP private int m_Kills; private int m_Score; - private DDTeamInfo m_TeamInfo; + private readonly DDTeamInfo m_TeamInfo; public DDPlayerInfo(DDTeamInfo teamInfo, Mobile player) { @@ -212,7 +212,7 @@ namespace Server.Engines.ConPVP Player = player; } - public Mobile Player{ get; } + public Mobile Player { get; } public string Name => Player.Name; @@ -269,26 +269,26 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Board = ip.ReadItem() as DDBoard; - TeamName = ip.ReadString(); - Color = ip.ReadEncodedInt(); - Origin = ip.ReadPoint3D(); - break; - } + { + Board = ip.ReadItem() as DDBoard; + TeamName = ip.ReadString(); + Color = ip.ReadEncodedInt(); + Origin = ip.ReadPoint3D(); + break; + } } } - public DDGame Game{ get; set; } + public DDGame Game { get; set; } - public int TeamID{ get; } + public int TeamID { get; } - public DDPlayerInfo Leader{ get; set; } + public DDPlayerInfo Leader { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DDBoard Board{ get; set; } + public DDBoard Board { get; set; } - public Dictionary Players{ get; } + public Dictionary Players { get; } public DDPlayerInfo this[Mobile mob] { @@ -305,21 +305,21 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } + public int Color { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string TeamName{ get; set; } + public string TeamName { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Origin{ get; set; } + public Point3D Origin { get; set; } public string Name => $"{TeamName} Team"; - public int Kills{ get; set; } + public int Kills { get; set; } - public int Captures{ get; set; } + public int Captures { get; set; } - public int Score{ get; set; } + public int Score { get; set; } public void Reset() { @@ -370,7 +370,7 @@ namespace Server.Engines.ConPVP { } - public DDTeamInfo[] TeamInfo{ get; private set; } + public DDTeamInfo[] TeamInfo { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public DDTeamInfo Team1 => TeamInfo[0]; @@ -379,13 +379,13 @@ namespace Server.Engines.ConPVP public DDTeamInfo Team2 => TeamInfo[1]; [CommandProperty(AccessLevel.GameMaster)] - public DDWayPoint PointA{ get; set; } + public DDWayPoint PointA { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DDWayPoint PointB{ get; set; } + public DDWayPoint PointB { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } + public TimeSpan Duration { get; set; } public override string Title => "DoubleDom"; @@ -421,18 +421,18 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Duration = reader.ReadTimeSpan(); - TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()]; + { + Duration = reader.ReadTimeSpan(); + TeamInfo = new DDTeamInfo[reader.ReadEncodedInt()]; - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new DDTeamInfo(i, reader); + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new DDTeamInfo(i, reader); - PointA = reader.ReadItem() as DDWayPoint; - PointB = reader.ReadItem() as DDWayPoint; + PointA = reader.ReadItem() as DDWayPoint; + PointB = reader.ReadItem() as DDWayPoint; - break; - } + break; + } } } } @@ -449,7 +449,7 @@ namespace Server.Engines.ConPVP public DDGame(DDController controller, DuelContext context) : base(context) => Controller = controller; - public DDController Controller{ get; } + public DDController Controller { get; } public Map Facet { @@ -693,7 +693,7 @@ namespace Server.Engines.ConPVP if (mob == null) continue; - //"Red v Blue DD Champion" + // "Red v Blue DD Champion" sb = new StringBuilder(); @@ -1071,7 +1071,7 @@ namespace Server.Engines.ConPVP { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override bool OnMoveOver(Mobile m) => Addon.OnMoveOver(m); diff --git a/Projects/Scripts/Engines/ConPVP/Games/EventGame.cs b/Projects/Scripts/Engines/ConPVP/Games/EventGame.cs index b3ebd2562..1bfcc96dc 100644 --- a/Projects/Scripts/Engines/ConPVP/Games/EventGame.cs +++ b/Projects/Scripts/Engines/ConPVP/Games/EventGame.cs @@ -17,7 +17,7 @@ namespace Server.Engines.ConPVP { } - public abstract string Title{ get; } + public abstract string Title { get; } public abstract EventGame Construct(DuelContext dc); public abstract string GetTeamName(int teamID); diff --git a/Projects/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs b/Projects/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs index d30302da7..cda7aff34 100644 --- a/Projects/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs +++ b/Projects/Scripts/Engines/ConPVP/Games/KingOfTheHill.cs @@ -30,7 +30,7 @@ namespace Server.Engines.ConPVP { } - public Mobile King{ get; private set; } + public Mobile King { get; private set; } public KHGame Game { @@ -47,7 +47,7 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public int ScoreInterval{ get; set; } + public int ScoreInterval { get; set; } public int CapturesSoFar { @@ -68,10 +68,10 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - ScoreInterval = reader.ReadEncodedInt(); - break; - } + { + ScoreInterval = reader.ReadEncodedInt(); + break; + } } } @@ -182,7 +182,7 @@ namespace Server.Engines.ConPVP private class KingTimer : Timer { private int m_Counter; - private HillOfTheKing m_Hill; + private readonly HillOfTheKing m_Hill; public KingTimer(HillOfTheKing hill) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) @@ -194,7 +194,7 @@ namespace Server.Engines.ConPVP Priority = TimerPriority.FiftyMS; } - public int Captures{ get; private set; } + public int Captures { get; private set; } public void StartHillTicker() { @@ -329,10 +329,10 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - m_Controller = reader.ReadItem() as KHController; - break; - } + { + m_Controller = reader.ReadItem() as KHController; + break; + } } } } @@ -384,7 +384,7 @@ namespace Server.Engines.ConPVP AddAlphaRegion(16, 15, 369, height - 29); AddImage(215, -45, 0xEE40); - //AddImage( 330, 141, 0x8BA ); + // AddImage( 330, 141, 0x8BA ); AddBorderedText(22, 22, 294, 20, Center("King of the Hill Scoreboard"), LabelColor32, BlackColor32); @@ -486,7 +486,7 @@ namespace Server.Engines.ConPVP private int m_Kills; private int m_Score; - private KHTeamInfo m_TeamInfo; + private readonly KHTeamInfo m_TeamInfo; public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player) { @@ -494,7 +494,7 @@ namespace Server.Engines.ConPVP Player = player; } - public Mobile Player{ get; } + public Mobile Player { get; } public int CompareTo(KHPlayerInfo pi) { @@ -562,21 +562,21 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - TeamName = ip.ReadString(); - Color = ip.ReadEncodedInt(); - break; - } + { + TeamName = ip.ReadString(); + Color = ip.ReadEncodedInt(); + break; + } } } - public KHGame Game{ get; set; } + public KHGame Game { get; set; } - public int TeamID{ get; } + public int TeamID { get; } - public KHPlayerInfo Leader{ get; set; } + public KHPlayerInfo Leader { get; set; } - public Dictionary Players{ get; } + public Dictionary Players { get; } public KHPlayerInfo this[Mobile mob] { @@ -593,10 +593,10 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public int Color{ get; set; } + public int Color { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string TeamName{ get; set; } + public string TeamName { get; set; } public int CompareTo(KHTeamInfo ti) { @@ -614,11 +614,11 @@ namespace Server.Engines.ConPVP public string Name => $"{TeamName ?? "(none)"} Team"; - public int Kills{ get; set; } + public int Kills { get; set; } - public int Captures{ get; set; } + public int Captures { get; set; } - public int Score{ get; set; } + public int Score { get; set; } public void Reset() { @@ -668,7 +668,7 @@ namespace Server.Engines.ConPVP { } - public KHTeamInfo[] TeamInfo{ get; private set; } + public KHTeamInfo[] TeamInfo { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public KHTeamInfo Team1_W => TeamInfo[0]; @@ -694,7 +694,7 @@ namespace Server.Engines.ConPVP [CommandProperty(AccessLevel.GameMaster)] public KHTeamInfo Team8_NE => TeamInfo[7]; - public HillOfTheKing[] Hills{ get; private set; } + public HillOfTheKing[] Hills { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public HillOfTheKing Hill1 @@ -724,10 +724,10 @@ namespace Server.Engines.ConPVP set => Hills[3] = value; } - public List Boards{ get; private set; } + public List Boards { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan Duration{ get; set; } + public TimeSpan Duration { get; set; } public override string Title => "King of the Hill"; @@ -779,23 +779,23 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - m_ScoreInterval = reader.ReadEncodedInt(); + { + m_ScoreInterval = reader.ReadEncodedInt(); - Duration = reader.ReadTimeSpan(); + Duration = reader.ReadTimeSpan(); - Boards = reader.ReadStrongItemList(); + Boards = reader.ReadStrongItemList(); - Hills = new HillOfTheKing[reader.ReadEncodedInt()]; - for (int i = 0; i < Hills.Length; ++i) - Hills[i] = reader.ReadItem() as HillOfTheKing; + Hills = new HillOfTheKing[reader.ReadEncodedInt()]; + for (int i = 0; i < Hills.Length; ++i) + Hills[i] = reader.ReadItem() as HillOfTheKing; - TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()]; - for (int i = 0; i < TeamInfo.Length; ++i) - TeamInfo[i] = new KHTeamInfo(i, reader); + TeamInfo = new KHTeamInfo[reader.ReadEncodedInt()]; + for (int i = 0; i < TeamInfo.Length; ++i) + TeamInfo[i] = new KHTeamInfo(i, reader); - break; - } + break; + } } } } @@ -806,7 +806,7 @@ namespace Server.Engines.ConPVP public KHGame(KHController controller, DuelContext context) : base(context) => Controller = controller; - public KHController Controller{ get; } + public KHController Controller { get; } public Map Facet { diff --git a/Projects/Scripts/Engines/ConPVP/Games/TourneyMatch.cs b/Projects/Scripts/Engines/ConPVP/Games/TourneyMatch.cs index 1642a504f..525c9cd54 100644 --- a/Projects/Scripts/Engines/ConPVP/Games/TourneyMatch.cs +++ b/Projects/Scripts/Engines/ConPVP/Games/TourneyMatch.cs @@ -43,11 +43,11 @@ namespace Server.Engines.ConPVP } } - public List Participants{ get; set; } + public List Participants { get; set; } - public TourneyParticipant Winner{ get; set; } + public TourneyParticipant Winner { get; set; } - public DuelContext Context{ get; set; } + public DuelContext Context { get; set; } public bool InProgress => Context?.Registered == true; @@ -67,7 +67,6 @@ namespace Server.Engines.ConPVP TourneyPart = tourneyPart }; - for (int j = 0; j < tourneyPart.Players.Count; ++j) duelPart.Add(tourneyPart.Players[j]); diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs index e7d5c695f..37ec2a5ff 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/AcceptTeamGump.cs @@ -14,14 +14,13 @@ namespace Server.Engines.ConPVP private const int LabelColor32 = 0xFFFFFF; private bool m_Active; - private Mobile m_From; - private List m_Players; - private Mobile m_Registrar; - private Mobile m_Requested; - private Tournament m_Tournament; + private readonly Mobile m_From; + private readonly List m_Players; + private readonly Mobile m_Registrar; + private readonly Mobile m_Requested; + private readonly Tournament m_Tournament; - public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List players) : - base(50, 50) + public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List players) : base(50, 50) { m_From = from; m_Requested = requested; @@ -31,8 +30,6 @@ namespace Server.Engines.ConPVP m_Active = true; - #region Rules - Ruleset ruleset = tourney.Ruleset; Ruleset basedef = ruleset.Base; @@ -66,8 +63,6 @@ namespace Server.Engines.ConPVP height += 10 + 22 + 25 + 25; - #endregion - Closable = false; AddPage(0); @@ -124,8 +119,6 @@ namespace Server.Engines.ConPVP AddImageTiled(32, 88, 264, 1, 9107); AddImageTiled(42, 90, 264, 1, 9157); - #region Rules - int y = 100; var groupText = tourney.GroupType switch @@ -144,8 +137,8 @@ namespace Server.Engines.ConPVP TieType.Random => "Random", TieType.Highest => "Highest advances", TieType.Lowest => "Lowest advances", - TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"), - TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"), + TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances", + TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated", _ => null }; @@ -205,8 +198,6 @@ namespace Server.Engines.ConPVP y += 20; } - #endregion - y += 8; AddImageTiled(32, y - 1, 264, 1, 9107); AddImageTiled(42, y + 1, 264, 1, 9157); diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs index c1d2df320..98d2f42ee 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/ArenaGump.cs @@ -72,11 +72,11 @@ namespace Server.Engines.ConPVP public class ArenaGump : Gump { - private List m_Arenas; + private readonly List m_Arenas; private int m_ColumnX = 12; - private Mobile m_From; - private ArenasMoongate m_Gate; + private readonly Mobile m_From; + private readonly ArenasMoongate m_Gate; public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50) { diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs index c62c1725a..62b501c14 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/ConfirmSignupGump.cs @@ -14,10 +14,10 @@ namespace Server.Engines.ConPVP { private const int BlackColor32 = 0x000008; private const int LabelColor32 = 0xFFFFFF; - private Mobile m_From; - private List m_Players; - private Mobile m_Registrar; - private Tournament m_Tournament; + private readonly Mobile m_From; + private readonly List m_Players; + private readonly Mobile m_Registrar; + private readonly Tournament m_Tournament; public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List players) : base(50, 50) { @@ -31,8 +31,6 @@ namespace Server.Engines.ConPVP m_From.CloseGump(); m_From.CloseGump(); - #region Rules - Ruleset ruleset = tourney.Ruleset; Ruleset basedef = ruleset.Base; @@ -69,21 +67,19 @@ namespace Server.Engines.ConPVP if (tourney.PlayersPerParticipant > 1) height += 36 + tourney.PlayersPerParticipant * 20; - #endregion - Closable = false; AddPage(0); - //AddBackground( 0, 0, 400, 220, 9150 ); + // AddBackground( 0, 0, 400, 220, 9150 ); AddBackground(1, 1, 398, height, 3600); - //AddBackground( 16, 15, 369, 189, 9100 ); + // AddBackground( 16, 15, 369, 189, 9100 ); AddImageTiled(16, 15, 369, height - 29, 3604); AddAlphaRegion(16, 15, 369, height - 29); AddImage(215, -43, 0xEE40); - //AddImage( 330, 141, 0x8BA ); + // AddImage( 330, 141, 0x8BA ); StringBuilder sb = new StringBuilder(); @@ -128,8 +124,6 @@ namespace Server.Engines.ConPVP AddImageTiled(32, 88, 264, 1, 9107); AddImageTiled(42, 90, 264, 1, 9157); - #region Rules - int y = 100; var groupText = tourney.GroupType switch @@ -148,8 +142,8 @@ namespace Server.Engines.ConPVP TieType.Random => "Random", TieType.Highest => "Highest advances", TieType.Lowest => "Lowest advances", - TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"), - TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"), + TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances", + TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated", _ => null }; @@ -209,10 +203,6 @@ namespace Server.Engines.ConPVP y += 20; } - #endregion - - #region Team - if (tourney.PlayersPerParticipant > 1) { y += 8; @@ -244,8 +234,6 @@ namespace Server.Engines.ConPVP } } - #endregion - y += 8; AddImageTiled(32, y - 1, 264, 1, 9107); AddImageTiled(42, y + 1, 264, 1, 9157); @@ -300,141 +288,141 @@ namespace Server.Engines.ConPVP switch (tourney.Stage) { case TournamentStage.Fighting: - { - if (m_Registrar != null) { - if (m_Tournament.HasParticipant(from)) - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "Excuse me? You are already signed up.", from.NetState); - else - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "The tournament has already begun. You are too late to signup now.", - from.NetState); - } + if (m_Registrar != null) + { + if (m_Tournament.HasParticipant(from)) + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "Excuse me? You are already signed up.", from.NetState); + else + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "The tournament has already begun. You are too late to signup now.", + from.NetState); + } - break; - } - case TournamentStage.Inactive: - { - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "The tournament is closed.", from.NetState); - - break; - } - case TournamentStage.Signup: - { - if (m_Players.Count != tourney.PlayersPerParticipant) - { - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "You have not yet chosen your team.", from.NetState); - - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); break; } - - Ladder ladder = Ladder.Instance; - - for (int i = 0; i < m_Players.Count; ++i) + case TournamentStage.Inactive: { - Mobile mob = m_Players[i]; + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "The tournament is closed.", from.NetState); - LadderEntry entry = ladder?.Find(mob); - - if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) - { - if (m_Registrar != null) - { - if (mob == from) - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState); - else - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.", - from.NetState); - } - - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; - } - - if (tourney.IsFactionRestricted && Faction.Find(mob) == null) + break; + } + case TournamentStage.Signup: + { + if (m_Players.Count != tourney.PlayersPerParticipant) { m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "Only those who have declared their faction allegiance may participate.", - from.NetState); + 0x35, false, "You have not yet chosen your team.", from.NetState); m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; + break; } - if (tourney.HasParticipant(mob)) + Ladder ladder = Ladder.Instance; + + for (int i = 0; i < m_Players.Count; ++i) { - if (m_Registrar != null) + Mobile mob = m_Players[i]; + + LadderEntry entry = ladder?.Find(mob); + + if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) { - if (mob == from) - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "You have already entered this tournament.", from.NetState); - else - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState); + if (m_Registrar != null) + { + if (mob == from) + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState); + else + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, $"{mob.Name} has not yet proven themselves a worthy dueler.", + from.NetState); + } + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; } - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; + if (tourney.IsFactionRestricted && Faction.Find(mob) == null) + { + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "Only those who have declared their faction allegiance may participate.", + from.NetState); + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; + } + + if (tourney.HasParticipant(mob)) + { + if (m_Registrar != null) + { + if (mob == from) + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "You have already entered this tournament.", from.NetState); + else + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, $"{mob.Name} has already entered this tournament.", from.NetState); + } + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; + } + + if (mob is PlayerMobile mobile && mobile.DuelContext != null) + { + if (mob == from) + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, + "You are already assigned to a duel. You must yield it before joining this tournament.", + from.NetState); + else + m_Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, + $"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.", + from.NetState); + + m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); + return; + } } - if (mob is PlayerMobile mobile && mobile.DuelContext != null) + if (m_Registrar != null) { - if (mob == from) - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, - "You are already assigned to a duel. You must yield it before joining this tournament.", - from.NetState); + string fmt; + + if (tourney.PlayersPerParticipant == 1) + fmt = + "As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}."; + else if (tourney.PlayersPerParticipant == 2) + fmt = + "As you wish m'{0}. The tournament will begin {1}, but first you must name your partner."; else - m_Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, - $"{mobile.Name} is already assigned to a duel. They must yield it before joining this tournament.", - from.NetState); + fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team."; - m_From.SendGump(new ConfirmSignupGump(m_From, m_Registrar, m_Tournament, m_Players)); - return; + string timeUntil; + int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow) + .TotalMinutes); + + if (minutesUntil == 0) + timeUntil = "momentarily"; + else + timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}"; + + m_Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState); } + + TourneyParticipant part = new TourneyParticipant(from); + part.Players.Clear(); + part.Players.AddRange(m_Players); + + tourney.Participants.Add(part); + + break; } - - if (m_Registrar != null) - { - string fmt; - - if (tourney.PlayersPerParticipant == 1) - fmt = - "As you say m'{0}. I've written your name to the bracket. The tournament will begin {1}."; - else if (tourney.PlayersPerParticipant == 2) - fmt = - "As you wish m'{0}. The tournament will begin {1}, but first you must name your partner."; - else - fmt = "As you wish m'{0}. The tournament will begin {1}, but first you must name your team."; - - string timeUntil; - int minutesUntil = (int)Math.Round((tourney.SignupStart + tourney.SignupPeriod - DateTime.UtcNow) - .TotalMinutes); - - if (minutesUntil == 0) - timeUntil = "momentarily"; - else - timeUntil = $"in {minutesUntil} minute{(minutesUntil == 1 ? "" : "s")}"; - - m_Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, string.Format(fmt, from.Female ? "Lady" : "Lord", timeUntil), from.NetState); - } - - TourneyParticipant part = new TourneyParticipant(from); - part.Players.Clear(); - part.Players.AddRange(m_Players); - - tourney.Participants.Add(part); - - break; - } } } else if (info.ButtonID > 1) diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs index b29bea6d5..f68005345 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/DuelContextGump.cs @@ -52,9 +52,9 @@ namespace Server.Engines.ConPVP } } - public Mobile From{ get; } + public Mobile From { get; } - public DuelContext Context{ get; } + public DuelContext Context { get; } public string Center(string text) => $"
{text}
"; @@ -80,56 +80,56 @@ namespace Server.Engines.ConPVP switch (index) { case -1: // CloseGump - { - break; - } + { + break; + } case 0: // closed - { - Context.Unregister(); - break; - } + { + Context.Unregister(); + break; + } case 1: // Rules - { - //m_From.SendGump( new RulesetGump( m_From, m_Context.Ruleset, m_Context.Ruleset.Layout, m_Context ) ); - From.SendGump(new PickRulesetGump(From, Context, Context.Ruleset)); - break; - } + { + // m_From.SendGump( new RulesetGump( m_From, m_Context.Ruleset, m_Context.Ruleset.Layout, m_Context ) ); + From.SendGump(new PickRulesetGump(From, Context, Context.Ruleset)); + break; + } case 2: // Start - { - if (Context.CheckFull()) { - Context.CloseAllGumps(); - Context.SendReadyUpGump(); - //m_Context.SendReadyGump(); - } - else - { - From.SendMessage("You cannot start the duel before all participating players have been assigned."); - From.SendGump(new DuelContextGump(From, Context)); - } + if (Context.CheckFull()) + { + Context.CloseAllGumps(); + Context.SendReadyUpGump(); + // m_Context.SendReadyGump(); + } + else + { + From.SendMessage("You cannot start the duel before all participating players have been assigned."); + From.SendGump(new DuelContextGump(From, Context)); + } - break; - } + break; + } case 3: // New Participant - { - if (Context.Participants.Count < 10) - Context.Participants.Add(new Participant(Context, 1)); - else - From.SendMessage("The number of participating parties may not be increased further."); + { + if (Context.Participants.Count < 10) + Context.Participants.Add(new Participant(Context, 1)); + else + From.SendMessage("The number of participating parties may not be increased further."); - From.SendGump(new DuelContextGump(From, Context)); + From.SendGump(new DuelContextGump(From, Context)); - break; - } + break; + } default: // Participant - { - index -= 4; + { + index -= 4; - if (index >= 0 && index < Context.Participants.Count) - From.SendGump(new ParticipantGump(From, Context, Context.Participants[index])); + if (index >= 0 && index < Context.Participants.Count) + From.SendGump(new ParticipantGump(From, Context, Context.Participants[index])); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/LadderGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/LadderGump.cs index 0ac08f851..c691d272d 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/LadderGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/LadderGump.cs @@ -15,7 +15,7 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public LadderController Ladder{ get; set; } + public LadderController Ladder { get; set; } public override string DefaultName => "1v1 leaderboard"; @@ -37,10 +37,10 @@ namespace Server.Engines.ConPVP switch (version) { case 1: - { - Ladder = reader.ReadItem(); - break; - } + { + Ladder = reader.ReadItem(); + break; + } } } @@ -66,10 +66,10 @@ namespace Server.Engines.ConPVP public class LadderGump : Gump { private int m_ColumnX = 12; - private Ladder m_Ladder; + private readonly Ladder m_Ladder; - private List m_List; - private int m_Page; + private readonly List m_List; + private readonly int m_Page; public LadderGump(Ladder ladder, int page = 0) : base(50, 50) { @@ -153,7 +153,7 @@ namespace Server.Engines.ConPVP else width = (109 * xpOffset + xpAdvance / 2) / (xpAdvance - 1); - //AddImageTiled( 21, y + 6, width, 8, 0x2617 ); + // AddImageTiled( 21, y + 6, width, 8, 0x2617 ); AddImageTiled(x + 3, y + 4, width, 11, 0x806); AddBorderedText(x, y, 115, Center(level.ToString()), 0xFFFFFF, 0); x += 115; @@ -174,7 +174,7 @@ namespace Server.Engines.ConPVP AddBorderedText(x, y, 60, Center(entry.Losses.ToString()), 0xFFFFFF, 0); x += 60; - //AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0}
/
{1}
", entry.Wins, entry.Losses ), 0xFFC000, 0 ); + // AddBorderedText( 292 + 15, y, 115 - 30, String.Format( "{0}
/
{1}
", entry.Wins, entry.Losses ), 0xFFC000, 0 ); } } diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs index fefd3a68e..6f8fc9008 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/ParticipantGump.cs @@ -31,7 +31,7 @@ namespace Server.Engines.ConPVP AddButton(240, 25, 0xFB1, 0xFB3, 3); - //AddButton( 223, 54, 0x265A, 0x265A, 4, ); + // AddButton( 223, 54, 0x265A, 0x265A, 4, ); AddHtml(35, 25, 230, 20, Center("Participant Setup")); @@ -58,11 +58,11 @@ namespace Server.Engines.ConPVP } } - public Mobile From{ get; } + public Mobile From { get; } - public DuelContext Context{ get; } + public DuelContext Context { get; } - public Participant Participant{ get; } + public Participant Participant { get; } public string Center(string text) => $"
{text}
"; @@ -118,7 +118,7 @@ namespace Server.Engines.ConPVP { /*Container cont = m_Participant.Stakes; - if ( cont != null ) + if (cont != null) cont.Delete();*/ Context.Participants.Remove(Participant); @@ -130,13 +130,13 @@ namespace Server.Engines.ConPVP From.SendGump(new ParticipantGump(From, Context, Participant)); } } - /*else if ( bid == 4 ) + /*else if (bid == 4) { m_From.SendGump( new ParticipantGump( m_From, m_Context, m_Participant ) ); Container cont = m_Participant.Stakes; - if ( cont != null && !cont.Deleted ) + if (cont != null && !cont.Deleted) { cont.DisplayTo( m_From ); @@ -178,9 +178,9 @@ namespace Server.Engines.ConPVP private class ParticipantTarget : Target { - private DuelContext m_Context; - private int m_Index; - private Participant m_Participant; + private readonly DuelContext m_Context; + private readonly int m_Index; + private readonly Participant m_Participant; public ParticipantTarget(DuelContext context, Participant p, int index) : base(12, false, TargetFlags.None) { diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs index 95a0302c3..4c9c395c6 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/PickRulesetGump.cs @@ -5,11 +5,11 @@ namespace Server.Engines.ConPVP { public class PickRulesetGump : Gump { - private DuelContext m_Context; - private Ruleset[] m_Defaults; - private Ruleset[] m_Flavors; - private Mobile m_From; - private Ruleset m_Ruleset; + private readonly DuelContext m_Context; + private readonly Ruleset[] m_Defaults; + private readonly Ruleset[] m_Flavors; + private readonly Mobile m_From; + private readonly Ruleset m_Ruleset; public PickRulesetGump(Mobile from, DuelContext context, Ruleset ruleset) : base(50, 50) { @@ -80,43 +80,43 @@ namespace Server.Engines.ConPVP switch (info.ButtonID) { case 0: // closed - { - if (m_Context != null) - m_From.SendGump(new DuelContextGump(m_From, m_Context)); - - break; - } - case 1: // customize - { - m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Ruleset.Layout, m_Context)); - break; - } - default: - { - int idx = info.ButtonID - 2; - - if (idx >= 0 && idx < m_Defaults.Length) { - m_Ruleset.ApplyDefault(m_Defaults[idx]); - m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset)); + if (m_Context != null) + m_From.SendGump(new DuelContextGump(m_From, m_Context)); + + break; } - else + case 1: // customize { - idx -= m_Defaults.Length; + m_From.SendGump(new RulesetGump(m_From, m_Ruleset, m_Ruleset.Layout, m_Context)); + break; + } + default: + { + int idx = info.ButtonID - 2; - if (idx >= 0 && idx < m_Flavors.Length) + if (idx >= 0 && idx < m_Defaults.Length) { - if (m_Ruleset.Flavors.Contains(m_Flavors[idx])) - m_Ruleset.RemoveFlavor(m_Flavors[idx]); - else - m_Ruleset.AddFlavor(m_Flavors[idx]); - + m_Ruleset.ApplyDefault(m_Defaults[idx]); m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset)); } - } + else + { + idx -= m_Defaults.Length; - break; - } + if (idx >= 0 && idx < m_Flavors.Length) + { + if (m_Ruleset.Flavors.Contains(m_Flavors[idx])) + m_Ruleset.RemoveFlavor(m_Flavors[idx]); + else + m_Ruleset.AddFlavor(m_Flavors[idx]); + + m_From.SendGump(new PickRulesetGump(m_From, m_Context, m_Ruleset)); + } + } + + break; + } } } } diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs index fe2438585..04c63cd9b 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/ReadyUpGump.cs @@ -8,8 +8,8 @@ namespace Server.Engines.ConPVP { public class ReadyUpGump : Gump { - private DuelContext m_Context; - private Mobile m_From; + private readonly DuelContext m_Context; + private readonly Mobile m_From; public ReadyUpGump(Mobile from, DuelContext context) : base(50, 50) { @@ -33,8 +33,6 @@ namespace Server.Engines.ConPVP } else { - #region Participants - AddPage(1); List parts = context.Participants; @@ -98,10 +96,6 @@ namespace Server.Engines.ConPVP AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2); AddButton(169, y, 242, 241, 2); - #endregion - - #region Rules - AddPage(2); Ruleset ruleset = context.Ruleset; @@ -184,8 +178,6 @@ namespace Server.Engines.ConPVP AddButton(102, y, 247, 248, 1); AddButton(169, y, 242, 241, 3); - - #endregion } } @@ -205,25 +197,25 @@ namespace Server.Engines.ConPVP switch (info.ButtonID) { case 1: // okay - { - if (!(m_From is PlayerMobile pm)) + { + if (!(m_From is PlayerMobile pm)) + break; + + pm.DuelPlayer.Ready = true; + m_Context.SendReadyGump(); + break; - - pm.DuelPlayer.Ready = true; - m_Context.SendReadyGump(); - - break; - } + } case 2: // reject participants - { - m_Context.RejectReady(m_From, "participants"); - break; - } + { + m_Context.RejectReady(m_From, "participants"); + break; + } case 3: // reject rules - { - m_Context.RejectReady(m_From, "rules"); - break; - } + { + m_Context.RejectReady(m_From, "rules"); + break; + } } } } diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs index 56d0b76fe..712a68eb3 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/RulesetGump.cs @@ -6,11 +6,11 @@ namespace Server.Engines.ConPVP { public class RulesetGump : Gump { - private DuelContext m_DuelContext; - private Mobile m_From; - private RulesetLayout m_Page; - private bool m_ReadOnly; - private Ruleset m_Ruleset; + private readonly DuelContext m_DuelContext; + private readonly Mobile m_From; + private readonly RulesetLayout m_Page; + private readonly bool m_ReadOnly; + private readonly Ruleset m_Ruleset; public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly = false) : base(readOnly ? 310 : 50, 50) diff --git a/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs b/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs index 52dcaeaf5..f1925ad97 100644 --- a/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs +++ b/Projects/Scripts/Engines/ConPVP/Gumps/TournamentBracketGump.cs @@ -24,13 +24,13 @@ namespace Server.Engines.ConPVP { private const int BlackColor32 = 0x000008; private const int LabelColor32 = 0xFFFFFF; - private Mobile m_From; - private List m_List; - private object m_Object; - private int m_Page; + private readonly Mobile m_From; + private readonly List m_List; + private readonly object m_Object; + private readonly int m_Page; private int m_PerPage; - private Tournament m_Tournament; - private TourneyBracketGumpType m_Type; + private readonly Tournament m_Tournament; + private readonly TourneyBracketGumpType m_Type; public TournamentBracketGump(Mobile from, Tournament tourney, TourneyBracketGumpType type, List list = null, int page = 0, object obj = null) : base(50, 50) @@ -46,391 +46,497 @@ namespace Server.Engines.ConPVP switch (type) { case TourneyBracketGumpType.Index: - { - AddPage(0); - AddBackground(0, 0, 300, 300, 9380); - - StringBuilder sb = new StringBuilder(); - - if (tourney.TourneyType == TourneyType.FreeForAll) { - sb.Append("FFA"); - } - else if (tourney.TourneyType == TourneyType.RandomTeam) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-Team"); - } - else if (tourney.TourneyType == TourneyType.RedVsBlue) - { - sb.Append("Red v Blue"); - } - else if (tourney.TourneyType == TourneyType.Faction) - { - sb.Append(tourney.ParticipantsPerMatch); - sb.Append("-Team Faction"); - } - else - { - for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) - { - if (sb.Length > 0) - sb.Append('v'); - - sb.Append(tourney.PlayersPerParticipant); - } - } - - if (tourney.EventController != null) - sb.Append(' ').Append(tourney.EventController.Title); - - sb.Append(" Tournament Bracket"); - - AddHtml(25, 35, 250, 20, Center(sb.ToString())); - - AddRightArrow(25, 53, ToButtonID(0, 4), "Rules"); - AddRightArrow(25, 71, ToButtonID(0, 1), "Participants"); - - if (m_Tournament.Stage == TournamentStage.Signup) - { - TimeSpan until = m_Tournament.SignupStart + m_Tournament.SignupPeriod - DateTime.UtcNow; - string text; - int secs = (int)until.TotalSeconds; - - if (secs > 0) - { - int mins = secs / 60; - secs %= 60; - - if (mins > 0 && secs > 0) - text = - $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")} and {secs} second{(secs == 1 ? "" : "s")}."; - else if (mins > 0) - text = $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")}."; - else if (secs > 0) - text = $"The tournament will begin in {secs} second{(secs == 1 ? "" : "s")}."; - else - text = "The tournament will begin shortly."; - } - else - { - text = "The tournament will begin shortly."; - } - - AddHtml(25, 92, 250, 40, text); - } - else - { - AddRightArrow(25, 89, ToButtonID(0, 2), "Rounds"); - } - - break; - } - case TourneyBracketGumpType.Rules_Info: - { - Ruleset ruleset = tourney.Ruleset; - Ruleset basedef = ruleset.Base; - - BitArray defs; - - if (ruleset.Flavors.Count > 0) - { - defs = new BitArray(basedef.Options); - - for (int i = 0; i < ruleset.Flavors.Count; ++i) - defs.Or(ruleset.Flavors[i].Options); - } - else - { - defs = basedef.Options; - } - - int changes = 0; - - BitArray opts = ruleset.Options; - - for (int i = 0; i < opts.Length; ++i) - if (defs[i] != opts[i]) - ++changes; - - AddPage(0); - AddBackground(0, 0, 300, - 60 + 18 + 20 + 20 + 20 + 8 + 20 + ruleset.Flavors.Count * 18 + 4 + 20 + changes * 22 + 6, 9380); - - AddLeftArrow(25, 11, ToButtonID(0, 0)); - AddHtml(25, 35, 250, 20, Center("Rules")); - - int y = 53; - - var groupText = tourney.GroupType switch - { - GroupingType.HighVsLow => "High vs Low", - GroupingType.Nearest => "Closest opponent", - GroupingType.Random => "Random", - _ => null - }; - - AddHtml(35, y, 190, 20, $"Grouping: {groupText}"); - y += 20; - - var tieText = tourney.TieType switch - { - TieType.Random => "Random", - TieType.Highest => "Highest advances", - TieType.Lowest => "Lowest advances", - TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"), - TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"), - _ => null - }; - - AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}"); - y += 20; - - string sdText = "Off"; - - if (tourney.SuddenDeath > TimeSpan.Zero) - { - sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; - - if (tourney.SuddenDeathRounds > 0) - sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; - else - sdText = $"{sdText} (all rounds)"; - } - - AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}"); - y += 20; - - y += 8; - - AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}"); - y += 20; - - for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) - AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}"); - - y += 4; - - if (changes > 0) - { - AddHtml(35, y, 190, 20, "Modifications:"); - y += 20; - - for (int i = 0; i < opts.Length; ++i) - if (defs[i] != opts[i]) - { - string name = ruleset.Layout.FindByIndex(i); - - if (name != null) // sanity - { - AddImage(35, y, opts[i] ? 0xD3 : 0xD2); - AddHtml(60, y, 165, 22, name); - } - - y += 22; - } - } - else - { - AddHtml(35, y, 190, 20, "Modifications: None"); - } - - break; - } - case TourneyBracketGumpType.Participant_List: - { - AddPage(0); - AddBackground(0, 0, 300, 300, 9380); - - List pList = m_List != null - ? Utility.CastListCovariant(m_List) - : new List(tourney.Participants); - - AddLeftArrow(25, 11, ToButtonID(0, 0)); - AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}")); - - StartPage(out int index, out int count, out int y, 12); - - for (int i = 0; i < count; ++i, y += 18) - { - TourneyParticipant part = pList[index + i]; - string name = part.NameList; - - if (m_Tournament.TourneyType != TourneyType.Standard && part.Players.Count == 1) - if (part.Players[0] is PlayerMobile pm && pm.DuelPlayer != null) - name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666); - - AddRightArrow(25, y, ToButtonID(2, index + i), name); - } - - break; - } - case TourneyBracketGumpType.Participant_Info: - { - if (!(obj is TourneyParticipant part)) - break; - - AddPage(0); - AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380); - - AddLeftArrow(25, 11, ToButtonID(0, 1)); - AddHtml(25, 35, 250, 20, Center("Participants")); - - int y = 53; - - AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team"); - y += 20; - - for (int i = 0; i < part.Players.Count; ++i) - { - Mobile mob = part.Players[i]; - string name = mob.Name; - - if (m_Tournament.TourneyType != TourneyType.Standard) - if (mob is PlayerMobile pm && pm.DuelPlayer != null) - name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666); - - AddRightArrow(35, y, ToButtonID(4, i), name); - y += 18; - } - - AddHtml(25, y, 200, 20, - $"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}"); - y += 20; - - AddHtml(25, y, 200, 20, "Log:"); - y += 20; - - StringBuilder sb = new StringBuilder(); - - for (int i = 0; i < part.Log.Count; ++i) - { - if (sb.Length > 0) - sb.Append("
"); - - sb.Append(part.Log[i]); - } - - if (sb.Length == 0) - sb.Append("Nothing logged yet."); - - AddHtml(25, y, 250, 150, Color(sb.ToString(), BlackColor32), false, true); - - break; - } - case TourneyBracketGumpType.Player_Info: - { - AddPage(0); - AddBackground(0, 0, 300, 300, 9380); - - AddLeftArrow(25, 11, ToButtonID(0, 3)); - AddHtml(25, 35, 250, 20, Center("Participants")); - - if (!(obj is Mobile mob)) - break; - - Ladder ladder = Ladder.Instance; - LadderEntry entry = ladder?.Find(mob); - - AddHtml(25, 53, 250, 20, $"Name: {mob.Name}"); - AddHtml(25, 73, 250, 20, - $"Guild: {(mob.Guild == null ? "None" : $"{mob.Guild.Name} [{mob.Guild.Abbreviation}]")}"); - AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}"); - AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}"); - AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}"); - AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}"); - - break; - } - case TourneyBracketGumpType.Round_List: - { - AddPage(0); - AddBackground(0, 0, 300, 300, 9380); - - AddLeftArrow(25, 11, ToButtonID(0, 0)); - AddHtml(25, 35, 250, 20, Center("Rounds")); - - - // List levelsList = m_List != null - // ? Utility.CastListCovariant(m_List) - // : new List(tourney.Pyramid.Levels); - - StartPage(out int index, out int count, out int y, 12); - - for (int i = 0; i < count; ++i, y += 18) - AddRightArrow(25, y, ToButtonID(3, index + i), $"Round #{index + i + 1}"); - - break; - } - case TourneyBracketGumpType.Round_Info: - { - AddPage(0); - AddBackground(0, 0, 300, 300, 9380); - - AddLeftArrow(25, 11, ToButtonID(0, 2)); - AddHtml(25, 35, 250, 20, Center("Rounds")); - - if (!(m_Object is PyramidLevel level)) - break; - - List matchesList = m_List != null - ? Utility.CastListCovariant(m_List) - : new List(level.Matches); - - AddRightArrow(25, 53, ToButtonID(5, 0), - $"Free Advance: {(level.FreeAdvance == null ? "None" : level.FreeAdvance.NameList)}"); - - AddHtml(25, 73, 200, 20, $"{matchesList.Count} Match{(matchesList.Count == 1 ? "" : "es")}"); - - StartPage(out int index, out int count, out int y, 10); - - for (int i = 0; i < count; ++i, y += 18) - { - TourneyMatch match = matchesList[index + i]; - - int color = -1; - - if (match.InProgress) - color = 0x336666; - else if (match.Context != null && match.Winner == null) - color = 0x666666; + AddPage(0); + AddBackground(0, 0, 300, 300, 9380); StringBuilder sb = new StringBuilder(); - if (m_Tournament.TourneyType == TourneyType.Standard) - for (int j = 0; j < match.Participants.Count; ++j) + if (tourney.TourneyType == TourneyType.FreeForAll) + { + sb.Append("FFA"); + } + else if (tourney.TourneyType == TourneyType.RandomTeam) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-Team"); + } + else if (tourney.TourneyType == TourneyType.RedVsBlue) + { + sb.Append("Red v Blue"); + } + else if (tourney.TourneyType == TourneyType.Faction) + { + sb.Append(tourney.ParticipantsPerMatch); + sb.Append("-Team Faction"); + } + else + { + for (int i = 0; i < tourney.ParticipantsPerMatch; ++i) { if (sb.Length > 0) - sb.Append(" vs "); + sb.Append('v'); - TourneyParticipant part = match.Participants[j]; - string txt = part.NameList; + sb.Append(tourney.PlayersPerParticipant); + } + } - if (color == -1 && match.Context != null && match.Winner == part) - txt = Color(txt, 0x336633); - else if (color == -1 && match.Context != null) - txt = Color(txt, 0x663333); + if (tourney.EventController != null) + sb.Append(' ').Append(tourney.EventController.Title); - sb.Append(txt); + sb.Append(" Tournament Bracket"); + + AddHtml(25, 35, 250, 20, Center(sb.ToString())); + + AddRightArrow(25, 53, ToButtonID(0, 4), "Rules"); + AddRightArrow(25, 71, ToButtonID(0, 1), "Participants"); + + if (m_Tournament.Stage == TournamentStage.Signup) + { + TimeSpan until = m_Tournament.SignupStart + m_Tournament.SignupPeriod - DateTime.UtcNow; + string text; + int secs = (int)until.TotalSeconds; + + if (secs > 0) + { + int mins = secs / 60; + secs %= 60; + + if (mins > 0 && secs > 0) + text = + $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")} and {secs} second{(secs == 1 ? "" : "s")}."; + else if (mins > 0) + text = $"The tournament will begin in {mins} minute{(mins == 1 ? "" : "s")}."; + else if (secs > 0) + text = $"The tournament will begin in {secs} second{(secs == 1 ? "" : "s")}."; + else + text = "The tournament will begin shortly."; + } + else + { + text = "The tournament will begin shortly."; + } + + AddHtml(25, 92, 250, 40, text); + } + else + { + AddRightArrow(25, 89, ToButtonID(0, 2), "Rounds"); + } + + break; + } + case TourneyBracketGumpType.Rules_Info: + { + Ruleset ruleset = tourney.Ruleset; + Ruleset basedef = ruleset.Base; + + BitArray defs; + + if (ruleset.Flavors.Count > 0) + { + defs = new BitArray(basedef.Options); + + for (int i = 0; i < ruleset.Flavors.Count; ++i) + defs.Or(ruleset.Flavors[i].Options); + } + else + { + defs = basedef.Options; + } + + int changes = 0; + + BitArray opts = ruleset.Options; + + for (int i = 0; i < opts.Length; ++i) + if (defs[i] != opts[i]) + ++changes; + + AddPage(0); + AddBackground(0, 0, 300, + 60 + 18 + 20 + 20 + 20 + 8 + 20 + ruleset.Flavors.Count * 18 + 4 + 20 + changes * 22 + 6, 9380); + + AddLeftArrow(25, 11, ToButtonID(0, 0)); + AddHtml(25, 35, 250, 20, Center("Rules")); + + int y = 53; + + var groupText = tourney.GroupType switch + { + GroupingType.HighVsLow => "High vs Low", + GroupingType.Nearest => "Closest opponent", + GroupingType.Random => "Random", + _ => null + }; + + AddHtml(35, y, 190, 20, $"Grouping: {groupText}"); + y += 20; + + var tieText = tourney.TieType switch + { + TieType.Random => "Random", + TieType.Highest => "Highest advances", + TieType.Lowest => "Lowest advances", + TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances", + TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated", + _ => null + }; + + AddHtml(35, y, 190, 20, $"Tiebreaker: {tieText}"); + y += 20; + + string sdText = "Off"; + + if (tourney.SuddenDeath > TimeSpan.Zero) + { + sdText = $"{(int)tourney.SuddenDeath.TotalMinutes}:{tourney.SuddenDeath.Seconds:D2}"; + + if (tourney.SuddenDeathRounds > 0) + sdText = $"{sdText} (first {tourney.SuddenDeathRounds} rounds)"; + else + sdText = $"{sdText} (all rounds)"; + } + + AddHtml(35, y, 240, 20, $"Sudden Death: {sdText}"); + y += 20; + + y += 8; + + AddHtml(35, y, 190, 20, $"Ruleset: {basedef.Title}"); + y += 20; + + for (int i = 0; i < ruleset.Flavors.Count; ++i, y += 18) + AddHtml(35, y, 190, 20, $" + {ruleset.Flavors[i].Title}"); + + y += 4; + + if (changes > 0) + { + AddHtml(35, y, 190, 20, "Modifications:"); + y += 20; + + for (int i = 0; i < opts.Length; ++i) + if (defs[i] != opts[i]) + { + string name = ruleset.Layout.FindByIndex(i); + + if (name != null) // sanity + { + AddImage(35, y, opts[i] ? 0xD3 : 0xD2); + AddHtml(60, y, 165, 22, name); + } + + y += 22; + } + } + else + { + AddHtml(35, y, 190, 20, "Modifications: None"); + } + + break; + } + case TourneyBracketGumpType.Participant_List: + { + AddPage(0); + AddBackground(0, 0, 300, 300, 9380); + + List pList = m_List != null + ? Utility.CastListCovariant(m_List) + : new List(tourney.Participants); + + AddLeftArrow(25, 11, ToButtonID(0, 0)); + AddHtml(25, 35, 250, 20, Center($"{pList.Count} Participant{(pList.Count == 1 ? "" : "s")}")); + + StartPage(out int index, out int count, out int y, 12); + + for (int i = 0; i < count; ++i, y += 18) + { + TourneyParticipant part = pList[index + i]; + string name = part.NameList; + + if (m_Tournament.TourneyType != TourneyType.Standard && part.Players.Count == 1) + if (part.Players[0] is PlayerMobile pm && pm.DuelPlayer != null) + name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666); + + AddRightArrow(25, y, ToButtonID(2, index + i), name); + } + + break; + } + case TourneyBracketGumpType.Participant_Info: + { + if (!(obj is TourneyParticipant part)) + break; + + AddPage(0); + AddBackground(0, 0, 300, 60 + 18 + 20 + part.Players.Count * 18 + 20 + 20 + 160, 9380); + + AddLeftArrow(25, 11, ToButtonID(0, 1)); + AddHtml(25, 35, 250, 20, Center("Participants")); + + int y = 53; + + AddHtml(25, y, 200, 20, part.Players.Count == 1 ? "Players" : "Team"); + y += 20; + + for (int i = 0; i < part.Players.Count; ++i) + { + Mobile mob = part.Players[i]; + string name = mob.Name; + + if (m_Tournament.TourneyType != TourneyType.Standard) + if (mob is PlayerMobile pm && pm.DuelPlayer != null) + name = Color(name, pm.DuelPlayer.Eliminated ? 0x6633333 : 0x336666); + + AddRightArrow(35, y, ToButtonID(4, i), name); + y += 18; + } + + AddHtml(25, y, 200, 20, + $"Free Advances: {(part.FreeAdvances == 0 ? "None" : part.FreeAdvances.ToString())}"); + y += 20; + + AddHtml(25, y, 200, 20, "Log:"); + y += 20; + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < part.Log.Count; ++i) + { + if (sb.Length > 0) + sb.Append("
"); + + sb.Append(part.Log[i]); + } + + if (sb.Length == 0) + sb.Append("Nothing logged yet."); + + AddHtml(25, y, 250, 150, Color(sb.ToString(), BlackColor32), false, true); + + break; + } + case TourneyBracketGumpType.Player_Info: + { + AddPage(0); + AddBackground(0, 0, 300, 300, 9380); + + AddLeftArrow(25, 11, ToButtonID(0, 3)); + AddHtml(25, 35, 250, 20, Center("Participants")); + + if (!(obj is Mobile mob)) + break; + + Ladder ladder = Ladder.Instance; + LadderEntry entry = ladder?.Find(mob); + + AddHtml(25, 53, 250, 20, $"Name: {mob.Name}"); + AddHtml(25, 73, 250, 20, + $"Guild: {(mob.Guild == null ? "None" : $"{mob.Guild.Name} [{mob.Guild.Abbreviation}]")}"); + AddHtml(25, 93, 250, 20, $"Rank: {(entry == null ? "N/A" : LadderGump.Rank(entry.Index + 1))}"); + AddHtml(25, 113, 250, 20, $"Level: {(entry == null ? 0 : Ladder.GetLevel(entry.Experience))}"); + AddHtml(25, 133, 250, 20, $"Wins: {entry?.Wins ?? 0:N0}"); + AddHtml(25, 153, 250, 20, $"Losses: {entry?.Losses ?? 0:N0}"); + + break; + } + case TourneyBracketGumpType.Round_List: + { + AddPage(0); + AddBackground(0, 0, 300, 300, 9380); + + AddLeftArrow(25, 11, ToButtonID(0, 0)); + AddHtml(25, 35, 250, 20, Center("Rounds")); + + // List levelsList = m_List != null + // ? Utility.CastListCovariant(m_List) + // : new List(tourney.Pyramid.Levels); + + StartPage(out int index, out int count, out int y, 12); + + for (int i = 0; i < count; ++i, y += 18) + AddRightArrow(25, y, ToButtonID(3, index + i), $"Round #{index + i + 1}"); + + break; + } + case TourneyBracketGumpType.Round_Info: + { + AddPage(0); + AddBackground(0, 0, 300, 300, 9380); + + AddLeftArrow(25, 11, ToButtonID(0, 2)); + AddHtml(25, 35, 250, 20, Center("Rounds")); + + if (!(m_Object is PyramidLevel level)) + break; + + List matchesList = m_List != null + ? Utility.CastListCovariant(m_List) + : new List(level.Matches); + + AddRightArrow(25, 53, ToButtonID(5, 0), + $"Free Advance: {(level.FreeAdvance == null ? "None" : level.FreeAdvance.NameList)}"); + + AddHtml(25, 73, 200, 20, $"{matchesList.Count} Match{(matchesList.Count == 1 ? "" : "es")}"); + + StartPage(out int index, out int count, out int y, 10); + + for (int i = 0; i < count; ++i, y += 18) + { + TourneyMatch match = matchesList[index + i]; + + int color = -1; + + if (match.InProgress) + color = 0x336666; + else if (match.Context != null && match.Winner == null) + color = 0x666666; + + StringBuilder sb = new StringBuilder(); + + if (m_Tournament.TourneyType == TourneyType.Standard) + for (int j = 0; j < match.Participants.Count; ++j) + { + if (sb.Length > 0) + sb.Append(" vs "); + + TourneyParticipant part = match.Participants[j]; + string txt = part.NameList; + + if (color == -1 && match.Context != null && match.Winner == part) + txt = Color(txt, 0x336633); + else if (color == -1 && match.Context != null) + txt = Color(txt, 0x663333); + + sb.Append(txt); + } + else if (m_Tournament.EventController != null || m_Tournament.TourneyType == TourneyType.RandomTeam || + m_Tournament.TourneyType == TourneyType.RedVsBlue || + m_Tournament.TourneyType == TourneyType.Faction) + for (int j = 0; j < match.Participants.Count; ++j) + { + if (sb.Length > 0) + sb.Append(" vs "); + + TourneyParticipant part = match.Participants[j]; + string txt; + + if (m_Tournament.EventController != null) + { + txt = $"Team {m_Tournament.EventController.GetTeamName(j)} ({part.Players.Count})"; + } + else if (m_Tournament.TourneyType == TourneyType.RandomTeam) + { + txt = $"Team {j + 1} ({part.Players.Count})"; + } + else if (m_Tournament.TourneyType == TourneyType.Faction) + { + if (m_Tournament.ParticipantsPerMatch == 4) + { + string name = "(null)"; + + switch (j) + { + case 0: + { + name = "Minax"; + break; + } + case 1: + { + name = "Council of Mages"; + break; + } + case 2: + { + name = "True Britannians"; + break; + } + case 3: + { + name = "Shadowlords"; + break; + } + } + + txt = $"{name} ({part.Players.Count})"; + } + else if (m_Tournament.ParticipantsPerMatch == 2) + { + txt = $"{(j == 0 ? "Evil" : "Hero")} Team ({part.Players.Count})"; + } + else + { + txt = $"Team {j + 1} ({part.Players.Count})"; + } + } + else + { + txt = $"Team {(j == 0 ? "Red" : "Blue")} ({part.Players.Count})"; + } + + if (color == -1 && match.Context != null && match.Winner == part) + txt = Color(txt, 0x336633); + else if (color == -1 && match.Context != null) + txt = Color(txt, 0x663333); + + sb.Append(txt); + } + else if (m_Tournament.TourneyType == TourneyType.FreeForAll) sb.Append("Free For All"); + + string str = sb.ToString(); + + if (color >= 0) + str = Color(str, color); + + AddRightArrow(25, y, ToButtonID(5, index + i + 1), str); + } + + break; + } + case TourneyBracketGumpType.Match_Info: + { + if (!(obj is TourneyMatch match)) + break; + + int ct = m_Tournament.TourneyType == TourneyType.FreeForAll ? 2 : match.Participants.Count; + + AddPage(0); + AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + ct * 18 + 6, 9380); + + AddLeftArrow(25, 11, ToButtonID(0, 5)); + AddHtml(25, 35, 250, 20, Center("Rounds")); + + AddHtml(25, 53, 250, 20, $"Winner: {(match.Winner == null ? "N/A" : match.Winner.NameList)}"); + AddHtml(25, 73, 250, 20, + $"State: {(match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting")}"); + AddHtml(25, 93, 250, 20, "Participants:"); + + if (m_Tournament.TourneyType == TourneyType.Standard) + for (int i = 0; i < match.Participants.Count; ++i) + { + TourneyParticipant part = match.Participants[i]; + + AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), part.NameList); } else if (m_Tournament.EventController != null || m_Tournament.TourneyType == TourneyType.RandomTeam || m_Tournament.TourneyType == TourneyType.RedVsBlue || m_Tournament.TourneyType == TourneyType.Faction) - for (int j = 0; j < match.Participants.Count; ++j) + for (int i = 0; i < match.Participants.Count; ++i) { - if (sb.Length > 0) - sb.Append(" vs "); - - TourneyParticipant part = match.Participants[j]; - string txt; + TourneyParticipant part = match.Participants[i]; if (m_Tournament.EventController != null) { - txt = $"Team {m_Tournament.EventController.GetTeamName(j)} ({part.Players.Count})"; + AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), + $"Team {m_Tournament.EventController.GetTeamName(i)} ({part.Players.Count})"); } else if (m_Tournament.TourneyType == TourneyType.RandomTeam) { - txt = $"Team {j + 1} ({part.Players.Count})"; + AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), + $"Team {i + 1} ({part.Players.Count})"); } else if (m_Tournament.TourneyType == TourneyType.Faction) { @@ -438,162 +544,55 @@ namespace Server.Engines.ConPVP { string name = "(null)"; - switch (j) + switch (i) { case 0: - { - name = "Minax"; - break; - } + { + name = "Minax"; + break; + } case 1: - { - name = "Council of Mages"; - break; - } + { + name = "Council of Mages"; + break; + } case 2: - { - name = "True Britannians"; - break; - } + { + name = "True Britannians"; + break; + } case 3: - { - name = "Shadowlords"; - break; - } + { + name = "Shadowlords"; + break; + } } - txt = $"{name} ({part.Players.Count})"; + AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), + $"{name} ({part.Players.Count})"); } else if (m_Tournament.ParticipantsPerMatch == 2) { - txt = $"{(j == 0 ? "Evil" : "Hero")} Team ({part.Players.Count})"; + AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), + $"{(i == 0 ? "Evil" : "Hero")} Team ({part.Players.Count})"); } else { - txt = $"Team {j + 1} ({part.Players.Count})"; + AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), + $"Team {i + 1} ({part.Players.Count})"); } } else { - txt = $"Team {(j == 0 ? "Red" : "Blue")} ({part.Players.Count})"; + AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), + $"Team {(i == 0 ? "Red" : "Blue")} ({part.Players.Count})"); } - - if (color == -1 && match.Context != null && match.Winner == part) - txt = Color(txt, 0x336633); - else if (color == -1 && match.Context != null) - txt = Color(txt, 0x663333); - - sb.Append(txt); } - else if (m_Tournament.TourneyType == TourneyType.FreeForAll) sb.Append("Free For All"); + else if (m_Tournament.TourneyType == TourneyType.FreeForAll) + AddHtml(25, 113, 250, 20, "Free For All"); - string str = sb.ToString(); - - if (color >= 0) - str = Color(str, color); - - AddRightArrow(25, y, ToButtonID(5, index + i + 1), str); - } - - break; - } - case TourneyBracketGumpType.Match_Info: - { - if (!(obj is TourneyMatch match)) break; - - int ct = m_Tournament.TourneyType == TourneyType.FreeForAll ? 2 : match.Participants.Count; - - AddPage(0); - AddBackground(0, 0, 300, 60 + 18 + 20 + 20 + 20 + ct * 18 + 6, 9380); - - AddLeftArrow(25, 11, ToButtonID(0, 5)); - AddHtml(25, 35, 250, 20, Center("Rounds")); - - AddHtml(25, 53, 250, 20, $"Winner: {(match.Winner == null ? "N/A" : match.Winner.NameList)}"); - AddHtml(25, 73, 250, 20, - $"State: {(match.InProgress ? "In progress" : match.Context != null ? "Complete" : "Waiting")}"); - AddHtml(25, 93, 250, 20, "Participants:"); - - if (m_Tournament.TourneyType == TourneyType.Standard) - for (int i = 0; i < match.Participants.Count; ++i) - { - TourneyParticipant part = match.Participants[i]; - - AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), part.NameList); - } - else if (m_Tournament.EventController != null || m_Tournament.TourneyType == TourneyType.RandomTeam || - m_Tournament.TourneyType == TourneyType.RedVsBlue || - m_Tournament.TourneyType == TourneyType.Faction) - for (int i = 0; i < match.Participants.Count; ++i) - { - TourneyParticipant part = match.Participants[i]; - - if (m_Tournament.EventController != null) - { - AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), - $"Team {m_Tournament.EventController.GetTeamName(i)} ({part.Players.Count})"); - } - else if (m_Tournament.TourneyType == TourneyType.RandomTeam) - { - AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), - $"Team {i + 1} ({part.Players.Count})"); - } - else if (m_Tournament.TourneyType == TourneyType.Faction) - { - if (m_Tournament.ParticipantsPerMatch == 4) - { - string name = "(null)"; - - switch (i) - { - case 0: - { - name = "Minax"; - break; - } - case 1: - { - name = "Council of Mages"; - break; - } - case 2: - { - name = "True Britannians"; - break; - } - case 3: - { - name = "Shadowlords"; - break; - } - } - - AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), - $"{name} ({part.Players.Count})"); - } - else if (m_Tournament.ParticipantsPerMatch == 2) - { - AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), - $"{(i == 0 ? "Evil" : "Hero")} Team ({part.Players.Count})"); - } - else - { - AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), - $"Team {i + 1} ({part.Players.Count})"); - } - } - else - { - AddRightArrow(25, 113 + i * 18, ToButtonID(6, i), - $"Team {(i == 0 ? "Red" : "Blue")} ({part.Players.Count})"); - } - } - else if (m_Tournament.TourneyType == TourneyType.FreeForAll) - AddHtml(25, 113, 250, 20, "Free For All"); - - break; - } + } } } @@ -677,153 +676,153 @@ namespace Server.Engines.ConPVP switch (type) { case 0: - { - switch (index) { - case 0: - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Index)); - break; - case 1: - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, - TourneyBracketGumpType.Participant_List)); - break; - case 2: - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Round_List)); - break; - case 4: - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Rules_Info)); - break; - case 3: + switch (index) { - Mobile mob = m_Object as Mobile; - - for (int i = 0; i < m_Tournament.Participants.Count; ++i) - { - TourneyParticipant part = m_Tournament.Participants[i]; - - if (part.Players.Contains(mob)) + case 0: + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Index)); + break; + case 1: + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, + TourneyBracketGumpType.Participant_List)); + break; + case 2: + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Round_List)); + break; + case 4: + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Rules_Info)); + break; + case 3: { - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, - TourneyBracketGumpType.Participant_Info, null, 0, part)); + Mobile mob = m_Object as Mobile; + + for (int i = 0; i < m_Tournament.Participants.Count; ++i) + { + TourneyParticipant part = m_Tournament.Participants[i]; + + if (part.Players.Contains(mob)) + { + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, + TourneyBracketGumpType.Participant_Info, null, 0, part)); + break; + } + } + break; } - } + case 5: + { + if (!(m_Object is TourneyMatch match)) + break; - break; + for (int i = 0; i < m_Tournament.Pyramid.Levels.Count; ++i) + { + PyramidLevel level = m_Tournament.Pyramid.Levels[i]; + + if (level.Matches.Contains(match)) + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, + TourneyBracketGumpType.Round_Info, null, 0, level)); + } + + break; + } } - case 5: - { - if (!(m_Object is TourneyMatch match)) - break; - for (int i = 0; i < m_Tournament.Pyramid.Levels.Count; ++i) - { - PyramidLevel level = m_Tournament.Pyramid.Levels[i]; - - if (level.Matches.Contains(match)) - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, - TourneyBracketGumpType.Round_Info, null, 0, level)); - } - - break; - } + break; } - - break; - } case 1: - { - switch (index) { - case 0: + switch (index) { - if (m_List != null && m_Page > 0) - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page - 1, - m_Object)); + case 0: + { + if (m_List != null && m_Page > 0) + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page - 1, + m_Object)); - break; - } - case 1: - { - if (m_List != null && (m_Page + 1) * m_PerPage < m_List.Count) - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page + 1, - m_Object)); + break; + } + case 1: + { + if (m_List != null && (m_Page + 1) * m_PerPage < m_List.Count) + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page + 1, + m_Object)); - break; + break; + } } + + break; } - - break; - } case 2: - { - if (m_Type != TourneyBracketGumpType.Participant_List) - break; - - if (index >= 0 && index < m_List.Count) - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, - TourneyBracketGumpType.Participant_Info, null, 0, m_List[index])); - - break; - } - case 3: - { - if (m_Type != TourneyBracketGumpType.Round_List) - break; - - if (index >= 0 && index < m_List.Count) - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Round_Info, - null, 0, m_List[index])); - - break; - } - case 4: - { - if (m_Type != TourneyBracketGumpType.Participant_Info) - break; - - if (m_Object is TourneyParticipant part && index >= 0 && index < part.Players.Count) - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Player_Info, - null, 0, part.Players[index])); - - break; - } - case 5: - { - if (m_Type != TourneyBracketGumpType.Round_Info) - break; - - if (!(m_Object is PyramidLevel level)) - break; - - if (index == 0) { - if (level.FreeAdvance != null) + if (m_Type != TourneyBracketGumpType.Participant_List) + break; + + if (index >= 0 && index < m_List.Count) m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, - TourneyBracketGumpType.Participant_Info, null, 0, level.FreeAdvance)); - else - m_From.SendGump( - new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page, m_Object)); - } - else if (index >= 1 && index <= level.Matches.Count) - { - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Match_Info, - null, 0, level.Matches[index - 1])); - } + TourneyBracketGumpType.Participant_Info, null, 0, m_List[index])); - break; - } - case 6: - { - if (m_Type != TourneyBracketGumpType.Match_Info) break; + } + case 3: + { + if (m_Type != TourneyBracketGumpType.Round_List) + break; - if (m_Object is TourneyMatch match && index >= 0 && index < match.Participants.Count) - m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, - TourneyBracketGumpType.Participant_Info, null, 0, match.Participants[index])); + if (index >= 0 && index < m_List.Count) + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Round_Info, + null, 0, m_List[index])); - break; - } + break; + } + case 4: + { + if (m_Type != TourneyBracketGumpType.Participant_Info) + break; + + if (m_Object is TourneyParticipant part && index >= 0 && index < part.Players.Count) + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Player_Info, + null, 0, part.Players[index])); + + break; + } + case 5: + { + if (m_Type != TourneyBracketGumpType.Round_Info) + break; + + if (!(m_Object is PyramidLevel level)) + break; + + if (index == 0) + { + if (level.FreeAdvance != null) + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, + TourneyBracketGumpType.Participant_Info, null, 0, level.FreeAdvance)); + else + m_From.SendGump( + new TournamentBracketGump(m_From, m_Tournament, m_Type, m_List, m_Page, m_Object)); + } + else if (index >= 1 && index <= level.Matches.Count) + { + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, TourneyBracketGumpType.Match_Info, + null, 0, level.Matches[index - 1])); + } + + break; + } + case 6: + { + if (m_Type != TourneyBracketGumpType.Match_Info) + break; + + if (m_Object is TourneyMatch match && index >= 0 && index < match.Participants.Count) + m_From.SendGump(new TournamentBracketGump(m_From, m_Tournament, + TourneyBracketGumpType.Participant_Info, null, 0, match.Participants[index])); + + break; + } } } } diff --git a/Projects/Scripts/Engines/ConPVP/Ladder.cs b/Projects/Scripts/Engines/ConPVP/Ladder.cs index d24aeff74..ca4e9a803 100644 --- a/Projects/Scripts/Engines/ConPVP/Ladder.cs +++ b/Projects/Scripts/Engines/ConPVP/Ladder.cs @@ -20,8 +20,8 @@ namespace Server.Engines.ConPVP { } - [CommandProperty( AccessLevel.Administrator )] - public Ladder Ladder{ get; private set; } + [CommandProperty(AccessLevel.Administrator)] + public Ladder Ladder { get; private set; } public override string DefaultName => "ladder controller"; @@ -54,21 +54,21 @@ namespace Server.Engines.ConPVP { case 1: case 0: - { - Ladder = new Ladder(reader); + { + Ladder = new Ladder(reader); - if (version < 1 || reader.ReadBool()) - Ladder.Instance = Ladder; + if (version < 1 || reader.ReadBool()) + Ladder.Instance = Ladder; - break; - } + break; + } } } } public class Ladder { - private static int[] m_ShortLevels = + private static readonly int[] m_ShortLevels = { 1, 2, @@ -81,12 +81,12 @@ namespace Server.Engines.ConPVP 9, 9, 9, 9, 9 }; - private static int[] m_BaseXP = + private static readonly int[] m_BaseXP = { 0, 100, 200, 400, 600, 900, 1200, 1600, 2000, 2500 }; - private static int[] m_LossFactors = + private static readonly int[] m_LossFactors = { 10, 11, 11, @@ -95,7 +95,7 @@ namespace Server.Engines.ConPVP 67, 67 }; - private static int[,] m_OffsetScalar = + private static readonly int[,] m_OffsetScalar = { /* { win, los } */ /* -6 */ { 175, 25 }, @@ -113,9 +113,9 @@ namespace Server.Engines.ConPVP /* +6 */ { 40, 160 } }; - public List Entries{ get; } = new List(); + public List Entries { get; } = new List(); - private Dictionary m_Table; + private readonly Dictionary m_Table; public Ladder() => m_Table = new Dictionary(); @@ -127,42 +127,42 @@ namespace Server.Engines.ConPVP { case 1: case 0: - { - int count = reader.ReadEncodedInt(); - - m_Table = new Dictionary(count); - Entries = new List(count); - - for (int i = 0; i < count; ++i) { - LadderEntry entry = new LadderEntry(reader, this, version); + int count = reader.ReadEncodedInt(); - if (entry.Mobile != null) + m_Table = new Dictionary(count); + Entries = new List(count); + + for (int i = 0; i < count; ++i) { - m_Table[entry.Mobile] = entry; - entry.Index = Entries.Count; - Entries.Add(entry); + LadderEntry entry = new LadderEntry(reader, this, version); + + if (entry.Mobile != null) + { + m_Table[entry.Mobile] = entry; + entry.Index = Entries.Count; + Entries.Add(entry); + } } - } - if (version == 0) - { - Entries.Sort(); - - for (int i = 0; i < Entries.Count; ++i) + if (version == 0) { - LadderEntry entry = Entries[i]; + Entries.Sort(); - entry.Index = i; + for (int i = 0; i < Entries.Count; ++i) + { + LadderEntry entry = Entries[i]; + + entry.Index = i; + } } - } - break; - } + break; + } } } - public static Ladder Instance{ get; set; } + public static Ladder Instance { get; set; } public static int GetLevel(int xp) { @@ -295,7 +295,7 @@ namespace Server.Engines.ConPVP public class LadderEntry : IComparable { private int m_Experience; - private Ladder m_Ladder; + private readonly Ladder m_Ladder; public LadderEntry(Mobile mob, Ladder ladder) { @@ -311,18 +311,18 @@ namespace Server.Engines.ConPVP { case 1: case 0: - { - Mobile = reader.ReadMobile(); - m_Experience = reader.ReadEncodedInt(); - Wins = reader.ReadEncodedInt(); - Losses = reader.ReadEncodedInt(); + { + Mobile = reader.ReadMobile(); + m_Experience = reader.ReadEncodedInt(); + Wins = reader.ReadEncodedInt(); + Losses = reader.ReadEncodedInt(); - break; - } + break; + } } } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public int Experience @@ -336,12 +336,12 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public int Wins{ get; set; } + public int Wins { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public int Losses{ get; set; } + public int Losses { get; set; } - public int Index{ get; set; } + public int Index { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Rank => Index; diff --git a/Projects/Scripts/Engines/ConPVP/Participant.cs b/Projects/Scripts/Engines/ConPVP/Participant.cs index 2f83d7fbe..2f1acc018 100644 --- a/Projects/Scripts/Engines/ConPVP/Participant.cs +++ b/Projects/Scripts/Engines/ConPVP/Participant.cs @@ -10,16 +10,16 @@ namespace Server.Engines.ConPVP public Participant(DuelContext context, int count) { Context = context; - //m_Stakes = new StakesContainer( context, this ); + // m_Stakes = new StakesContainer( context, this ); Resize(count); } public int Count => Players.Length; - public DuelPlayer[] Players{ get; private set; } + public DuelPlayer[] Players { get; private set; } - public DuelContext Context{ get; } + public DuelContext Context { get; } - public TourneyParticipant TourneyPart{ get; set; } + public TourneyParticipant TourneyPart { get; set; } public int FilledSlots { @@ -205,9 +205,9 @@ namespace Server.Engines.ConPVP mobile.DuelPlayer = this; } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public bool Ready{ get; set; } + public bool Ready { get; set; } public bool Eliminated { @@ -223,6 +223,6 @@ namespace Server.Engines.ConPVP } } - public Participant Participant{ get; set; } + public Participant Participant { get; set; } } } diff --git a/Projects/Scripts/Engines/ConPVP/Preferences.cs b/Projects/Scripts/Engines/ConPVP/Preferences.cs index 6a98fbba5..625893e1a 100644 --- a/Projects/Scripts/Engines/ConPVP/Preferences.cs +++ b/Projects/Scripts/Engines/ConPVP/Preferences.cs @@ -24,8 +24,8 @@ namespace Server.Engines.ConPVP { } - [CommandProperty( AccessLevel.Administrator )] - public Preferences Preferences{ get; private set; } + [CommandProperty(AccessLevel.Administrator)] + public Preferences Preferences { get; private set; } public override string DefaultName => "preferences controller"; @@ -53,18 +53,18 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Preferences = new Preferences(reader); - Preferences.Instance = Preferences; - break; - } + { + Preferences = new Preferences(reader); + Preferences.Instance = Preferences; + break; + } } } } public class Preferences { - private Dictionary m_Table; + private readonly Dictionary m_Table; public Preferences() { @@ -79,31 +79,31 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - int count = reader.ReadEncodedInt(); - - m_Table = new Dictionary(count); - Entries = new List(count); - - for (int i = 0; i < count; ++i) { - PreferencesEntry entry = new PreferencesEntry(reader, version); + int count = reader.ReadEncodedInt(); - if (entry.Mobile != null) + m_Table = new Dictionary(count); + Entries = new List(count); + + for (int i = 0; i < count; ++i) { - m_Table[entry.Mobile] = entry; - Entries.Add(entry); - } - } + PreferencesEntry entry = new PreferencesEntry(reader, version); - break; - } + if (entry.Mobile != null) + { + m_Table[entry.Mobile] = entry; + Entries.Add(entry); + } + } + + break; + } } } - public List Entries{ get; } + public List Entries { get; } - public static Preferences Instance{ get; set; } + public static Preferences Instance { get; set; } public PreferencesEntry Find(Mobile mob) { @@ -140,24 +140,24 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Mobile = reader.ReadMobile(); + { + Mobile = reader.ReadMobile(); - int count = reader.ReadEncodedInt(); + int count = reader.ReadEncodedInt(); - Disliked = new List(count); + Disliked = new List(count); - for (int i = 0; i < count; ++i) - Disliked.Add(reader.ReadString()); + for (int i = 0; i < count; ++i) + Disliked.Add(reader.ReadString()); - break; - } + break; + } } } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public List Disliked{ get; } + public List Disliked { get; } public void Serialize(IGenericWriter writer) { @@ -173,7 +173,7 @@ namespace Server.Engines.ConPVP public class PreferencesGump : Gump { private int m_ColumnX = 12; - private PreferencesEntry m_Entry; + private readonly PreferencesEntry m_Entry; public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50) { diff --git a/Projects/Scripts/Engines/ConPVP/Ruleset.cs b/Projects/Scripts/Engines/ConPVP/Ruleset.cs index abf20c95f..e61beb157 100644 --- a/Projects/Scripts/Engines/ConPVP/Ruleset.cs +++ b/Projects/Scripts/Engines/ConPVP/Ruleset.cs @@ -11,17 +11,17 @@ namespace Server.Engines.ConPVP Options = new BitArray(layout.TotalLength); } - public RulesetLayout Layout{ get; } + public RulesetLayout Layout { get; } - public BitArray Options{ get; private set; } + public BitArray Options { get; private set; } - public string Title{ get; set; } + public string Title { get; set; } - public Ruleset Base{ get; private set; } + public Ruleset Base { get; private set; } - public List Flavors{ get; } = new List(); + public List Flavors { get; } = new List(); - public bool Changed{ get; set; } + public bool Changed { get; set; } public void ApplyDefault(Ruleset newDefault) { diff --git a/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs b/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs index b25555877..7a6075172 100644 --- a/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs +++ b/Projects/Scripts/Engines/ConPVP/RulesetLayout.cs @@ -7,21 +7,21 @@ namespace Server.Engines.ConPVP { private static RulesetLayout m_Root; - public RulesetLayout(string title, string[] options) : this(title, title, new RulesetLayout[0], options) + public RulesetLayout(string title, string[] options) : this(title, title, Array.Empty(), options) { } public RulesetLayout(string title, string description, string[] options) : this(title, description, - new RulesetLayout[0], options) + Array.Empty(), options) { } - public RulesetLayout(string title, RulesetLayout[] children) : this(title, title, children, new string[0]) + public RulesetLayout(string title, RulesetLayout[] children) : this(title, title, children, Array.Empty()) { } public RulesetLayout(string title, string description, RulesetLayout[] children) : this(title, description, children, - new string[0]) + Array.Empty()) { } @@ -356,8 +356,6 @@ namespace Server.Engines.ConPVP if (!Core.AOS) { - #region Mage 5x - Ruleset m5x = new Ruleset(m_Root); m5x.Title = "Mage 5x"; @@ -404,10 +402,6 @@ namespace Server.Engines.ConPVP m5x.SetOption("Items", "Trapped Containers", true); - #endregion - - #region Mage 7x - Ruleset m7x = new Ruleset(m_Root); m7x.Title = "Mage 7x"; @@ -459,10 +453,6 @@ namespace Server.Engines.ConPVP m7x.SetOption("Items", "Trapped Containers", true); m7x.SetOption("Items", "Bandages", true); - #endregion - - #region Standard 7x - Ruleset s7x = new Ruleset(m_Root); s7x.Title = "Standard 7x"; @@ -514,19 +504,14 @@ namespace Server.Engines.ConPVP s7x.SetOption("Items", "Bandages", true); s7x.SetOption("Items", "Trapped Containers", true); - #endregion - m_Root.Defaults = new[] { m5x, m7x, s7x }; } else { - #region Standard All Skills - Ruleset all = new Ruleset(m_Root); all.Title = "Standard All Skills"; - all.SetOptionRange("Spells", true); all.SetOption("Spells", "Wall of Stone", false); @@ -606,15 +591,12 @@ namespace Server.Engines.ConPVP all.SetOption("Items", "Trapped Containers", true); m_Root.Defaults = new[] { all }; - - #endregion } // Set up flavors Ruleset pots = new Ruleset(m_Root) { Title = "Potions" }; - pots.SetOptionRange("Potions", true); pots.SetOption("Potions", "Explosion", false); @@ -663,23 +645,23 @@ namespace Server.Engines.ConPVP } } - public string Title{ get; } + public string Title { get; } - public string Description{ get; } + public string Description { get; } - public string[] Options{ get; } + public string[] Options { get; } - public int Offset{ get; private set; } + public int Offset { get; private set; } - public int TotalLength{ get; private set; } + public int TotalLength { get; private set; } - public RulesetLayout Parent{ get; private set; } + public RulesetLayout Parent { get; private set; } - public RulesetLayout[] Children{ get; } + public RulesetLayout[] Children { get; } - public Ruleset[] Defaults{ get; set; } + public Ruleset[] Defaults { get; set; } - public Ruleset[] Flavors{ get; set; } + public Ruleset[] Flavors { get; set; } public RulesetLayout FindByTitle(string title) { diff --git a/Projects/Scripts/Engines/ConPVP/Tournament.cs b/Projects/Scripts/Engines/ConPVP/Tournament.cs index f15b087cd..998015a6c 100644 --- a/Projects/Scripts/Engines/ConPVP/Tournament.cs +++ b/Projects/Scripts/Engines/ConPVP/Tournament.cs @@ -54,55 +54,55 @@ namespace Server.Engines.ConPVP switch (version) { case 5: - { - FactionRestricted = reader.ReadBool(); + { + FactionRestricted = reader.ReadBool(); - goto case 4; - } + goto case 4; + } case 4: - { - EventController = reader.ReadItem() as EventController; + { + EventController = reader.ReadItem() as EventController; - goto case 3; - } + goto case 3; + } case 3: - { - SuddenDeathRounds = reader.ReadEncodedInt(); + { + SuddenDeathRounds = reader.ReadEncodedInt(); - goto case 2; - } + goto case 2; + } case 2: - { - TourneyType = (TourneyType)reader.ReadEncodedInt(); + { + TourneyType = (TourneyType)reader.ReadEncodedInt(); - goto case 1; - } + goto case 1; + } case 1: - { - GroupType = (GroupingType)reader.ReadEncodedInt(); - TieType = (TieType)reader.ReadEncodedInt(); - SignupPeriod = reader.ReadTimeSpan(); + { + GroupType = (GroupingType)reader.ReadEncodedInt(); + TieType = (TieType)reader.ReadEncodedInt(); + SignupPeriod = reader.ReadTimeSpan(); - goto case 0; - } + goto case 0; + } case 0: - { - if (version < 3) - SuddenDeathRounds = 3; + { + if (version < 3) + SuddenDeathRounds = 3; - m_ParticipantsPerMatch = reader.ReadEncodedInt(); - m_PlayersPerParticipant = reader.ReadEncodedInt(); - SignupPeriod = reader.ReadTimeSpan(); - CurrentStage = TournamentStage.Inactive; - Pyramid = new TourneyPyramid(); - Ruleset = new Ruleset(RulesetLayout.Root); - Ruleset.ApplyDefault(Ruleset.Layout.Defaults[0]); - Participants = new List(); - Undefeated = new List(); - Arenas = new List(); + m_ParticipantsPerMatch = reader.ReadEncodedInt(); + m_PlayersPerParticipant = reader.ReadEncodedInt(); + SignupPeriod = reader.ReadTimeSpan(); + CurrentStage = TournamentStage.Inactive; + Pyramid = new TourneyPyramid(); + Ruleset = new Ruleset(RulesetLayout.Root); + Ruleset.ApplyDefault(Ruleset.Layout.Defaults[0]); + Participants = new List(); + Undefeated = new List(); + Arenas = new List(); - break; - } + break; + } } Timer.DelayCall(SliceInterval, SliceInterval, Slice); @@ -126,24 +126,24 @@ namespace Server.Engines.ConPVP public bool IsNotoRestricted => TourneyType != TourneyType.Standard; [CommandProperty(AccessLevel.GameMaster)] - public EventController EventController{ get; set; } + public EventController EventController { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int SuddenDeathRounds{ get; set; } + public int SuddenDeathRounds { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TourneyType TourneyType{ get; set; } + public TourneyType TourneyType { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public GroupingType GroupType{ get; set; } + public GroupingType GroupType { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TieType TieType{ get; set; } + public TieType TieType { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan SuddenDeath{ get; set; } + public TimeSpan SuddenDeath { get; set; } - public Ruleset Ruleset{ get; set; } + public Ruleset Ruleset { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int ParticipantsPerMatch @@ -170,19 +170,19 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public int LevelRequirement{ get; set; } + public int LevelRequirement { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool FactionRestricted{ get; set; } + public bool FactionRestricted { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan SignupPeriod{ get; set; } + public TimeSpan SignupPeriod { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime SignupStart{ get; set; } + public DateTime SignupStart { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TournamentStage CurrentStage{ get; private set; } + public TournamentStage CurrentStage { get; private set; } public TournamentStage Stage { @@ -190,13 +190,13 @@ namespace Server.Engines.ConPVP set => CurrentStage = value; } - public TourneyPyramid Pyramid{ get; set; } + public TourneyPyramid Pyramid { get; set; } - public List Arenas{ get; set; } + public List Arenas { get; set; } - public List Participants{ get; set; } + public List Participants { get; set; } - public List Undefeated{ get; set; } + public List Undefeated { get; set; } public bool IsFactionRestricted => FactionRestricted || TourneyType == TourneyType.Faction; @@ -280,76 +280,76 @@ namespace Server.Engines.ConPVP switch (tieType) { case TieType.FullAdvancement: - { - sb.AppendFormat("In accordance with the rules, {0} parties are advanced.", whole); - break; - } + { + sb.AppendFormat("In accordance with the rules, {0} parties are advanced.", whole); + break; + } case TieType.FullElimination: - { - for (int j = 0; j < remaining.Count; ++j) - Undefeated.Remove(remaining[j]); + { + for (int j = 0; j < remaining.Count; ++j) + Undefeated.Remove(remaining[j]); - sb.AppendFormat("In accordance with the rules, {0} parties are eliminated.", whole); - break; - } + sb.AppendFormat("In accordance with the rules, {0} parties are eliminated.", whole); + break; + } case TieType.Random: - { - TourneyParticipant advanced = remaining[Utility.Random(remaining.Count)]; + { + TourneyParticipant advanced = remaining[Utility.Random(remaining.Count)]; - for (int i = 0; i < remaining.Count; ++i) - if (remaining[i] != advanced) - Undefeated.Remove(remaining[i]); + for (int i = 0; i < remaining.Count; ++i) + if (remaining[i] != advanced) + Undefeated.Remove(remaining[i]); - if (advanced != null) - sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, - advanced.Players.Count == 1 ? "is" : "are"); + if (advanced != null) + sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, + advanced.Players.Count == 1 ? "is" : "are"); - break; - } + break; + } case TieType.Highest: - { - TourneyParticipant advanced = null; - - for (int i = 0; i < remaining.Count; ++i) { - TourneyParticipant part = remaining[i]; + TourneyParticipant advanced = null; - if (advanced == null || part.TotalLadderXP > advanced.TotalLadderXP) - advanced = part; + for (int i = 0; i < remaining.Count; ++i) + { + TourneyParticipant part = remaining[i]; + + if (advanced == null || part.TotalLadderXP > advanced.TotalLadderXP) + advanced = part; + } + + for (int i = 0; i < remaining.Count; ++i) + if (remaining[i] != advanced) + Undefeated.Remove(remaining[i]); + + if (advanced != null) + sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, + advanced.Players.Count == 1 ? "is" : "are"); + + break; } - - for (int i = 0; i < remaining.Count; ++i) - if (remaining[i] != advanced) - Undefeated.Remove(remaining[i]); - - if (advanced != null) - sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, - advanced.Players.Count == 1 ? "is" : "are"); - - break; - } case TieType.Lowest: - { - TourneyParticipant advanced = null; - - for (int i = 0; i < remaining.Count; ++i) { - TourneyParticipant part = remaining[i]; + TourneyParticipant advanced = null; - if (advanced == null || part.TotalLadderXP < advanced.TotalLadderXP) - advanced = part; + for (int i = 0; i < remaining.Count; ++i) + { + TourneyParticipant part = remaining[i]; + + if (advanced == null || part.TotalLadderXP < advanced.TotalLadderXP) + advanced = part; + } + + for (int i = 0; i < remaining.Count; ++i) + if (remaining[i] != advanced) + Undefeated.Remove(remaining[i]); + + if (advanced != null) + sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, + advanced.Players.Count == 1 ? "is" : "are"); + + break; } - - for (int i = 0; i < remaining.Count; ++i) - if (remaining[i] != advanced) - Undefeated.Remove(remaining[i]); - - if (advanced != null) - sb.AppendFormat("In accordance with the rules, {0} {1} advanced.", advanced.NameList, - advanced.Players.Count == 1 ? "is" : "are"); - - break; - } } Alert(arena, sb.ToString()); @@ -429,69 +429,69 @@ namespace Server.Engines.ConPVP switch (TourneyType) { case TourneyType.FreeForAll: - { - if (Pyramid.Levels.Count < 1) + { + if (Pyramid.Levels.Count < 1) + break; + + PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1]; + + if (top.FreeAdvance != null || top.Matches.Count != 1) + break; + + TourneyMatch match = top.Matches[0]; + TourneyParticipant winner = match.Winner; + + if (winner != null) + GiveAwards(winner.Players, TrophyRank.Gold, ComputeCashAward()); + break; - - PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1]; - - if (top.FreeAdvance != null || top.Matches.Count != 1) - break; - - TourneyMatch match = top.Matches[0]; - TourneyParticipant winner = match.Winner; - - if (winner != null) - GiveAwards(winner.Players, TrophyRank.Gold, ComputeCashAward()); - - break; - } + } case TourneyType.Standard: - { - if (Pyramid.Levels.Count < 2) - break; - - PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1]; - - if (top.FreeAdvance != null || top.Matches.Count != 1) - break; - - int cash = ComputeCashAward(); - - TourneyMatch match = top.Matches[0]; - TourneyParticipant winner = match.Winner; - - for (int i = 0; i < match.Participants.Count; ++i) { - TourneyParticipant part = match.Participants[i]; + if (Pyramid.Levels.Count < 2) + break; - if (part == winner) - GiveAwards(part.Players, TrophyRank.Gold, cash); - else - GiveAwards(part.Players, TrophyRank.Silver, cash / 2); - } + PyramidLevel top = Pyramid.Levels[Pyramid.Levels.Count - 1]; - PyramidLevel next = Pyramid.Levels[Pyramid.Levels.Count - 2]; + if (top.FreeAdvance != null || top.Matches.Count != 1) + break; - if (next.Matches.Count > 2) - break; + int cash = ComputeCashAward(); - for (int i = 0; i < next.Matches.Count; ++i) - { - match = next.Matches[i]; - winner = match.Winner; + TourneyMatch match = top.Matches[0]; + TourneyParticipant winner = match.Winner; - for (int j = 0; j < match.Participants.Count; ++j) + for (int i = 0; i < match.Participants.Count; ++i) { - TourneyParticipant part = match.Participants[j]; + TourneyParticipant part = match.Participants[i]; - if (part != winner) - GiveAwards(part.Players, TrophyRank.Bronze, cash / 4); + if (part == winner) + GiveAwards(part.Players, TrophyRank.Gold, cash); + else + GiveAwards(part.Players, TrophyRank.Silver, cash / 2); } - } - break; - } + PyramidLevel next = Pyramid.Levels[Pyramid.Levels.Count - 2]; + + if (next.Matches.Count > 2) + break; + + for (int i = 0; i < next.Matches.Count; ++i) + { + match = next.Matches[i]; + winner = match.Winner; + + for (int j = 0; j < match.Participants.Count; ++j) + { + TourneyParticipant part = match.Participants[j]; + + if (part != winner) + GiveAwards(part.Players, TrophyRank.Bronze, cash / 4); + } + } + + break; + } } } @@ -682,25 +682,25 @@ namespace Server.Engines.ConPVP winner)) { case 0: - { - name = "Minax"; - break; - } + { + name = "Minax"; + break; + } case 1: - { - name = "Council of Mages"; - break; - } + { + name = "Council of Mages"; + break; + } case 2: - { - name = "True Britannians"; - break; - } + { + name = "True Britannians"; + break; + } case 3: - { - name = "Shadowlords"; - break; - } + { + name = "Shadowlords"; + break; + } } Alert("The tournament has completed!", $"The {name} team has won!"); @@ -817,25 +817,25 @@ namespace Server.Engines.ConPVP .Participants.IndexOf(winner)) { case 0: - { - name = "Minax"; - break; - } + { + name = "Minax"; + break; + } case 1: - { - name = "Council of Mages"; - break; - } + { + name = "Council of Mages"; + break; + } case 2: - { - name = "True Britannians"; - break; - } + { + name = "True Britannians"; + break; + } case 3: - { - name = "Shadowlords"; - break; - } + { + name = "Shadowlords"; + break; + } } Alert("The tournament has completed!", $"The {name} team has won!"); @@ -873,7 +873,6 @@ namespace Server.Engines.ConPVP Undefeated.Clear(); break; } - } if (Undefeated.Count > 1) diff --git a/Projects/Scripts/Engines/ConPVP/TournamentBracketItem.cs b/Projects/Scripts/Engines/ConPVP/TournamentBracketItem.cs index e269c7365..e3b9ba3e6 100644 --- a/Projects/Scripts/Engines/ConPVP/TournamentBracketItem.cs +++ b/Projects/Scripts/Engines/ConPVP/TournamentBracketItem.cs @@ -12,7 +12,7 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public TournamentController Tournament{ get; set; } + public TournamentController Tournament { get; set; } public override string DefaultName => "tournament bracket"; @@ -52,10 +52,10 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Tournament = reader.ReadItem() as TournamentController; - break; - } + { + Tournament = reader.ReadItem() as TournamentController; + break; + } } } } diff --git a/Projects/Scripts/Engines/ConPVP/TournamentController.cs b/Projects/Scripts/Engines/ConPVP/TournamentController.cs index 894eefcd2..8944c83c5 100644 --- a/Projects/Scripts/Engines/ConPVP/TournamentController.cs +++ b/Projects/Scripts/Engines/ConPVP/TournamentController.cs @@ -7,7 +7,7 @@ namespace Server.Engines.ConPVP { public class TournamentController : Item { - private static List m_Instances = new List(); + private static readonly List m_Instances = new List(); [Constructible] public TournamentController() : base(0x1B7A) @@ -24,7 +24,7 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public Tournament Tournament{ get; private set; } + public Tournament Tournament { get; private set; } public static bool IsActive { @@ -86,10 +86,10 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Tournament = new Tournament(reader); - break; - } + { + Tournament = new Tournament(reader); + break; + } } m_Instances.Add(this); @@ -104,7 +104,7 @@ namespace Server.Engines.ConPVP private class EditEntry : ContextMenuEntry { - private Tournament m_Tournament; + private readonly Tournament m_Tournament; public EditEntry(Tournament tourney) : base(5101) => m_Tournament = tourney; @@ -116,7 +116,7 @@ namespace Server.Engines.ConPVP private class StartEntry : ContextMenuEntry { - private Tournament m_Tournament; + private readonly Tournament m_Tournament; public StartEntry(Tournament tourney) : base(5113) => m_Tournament = tourney; diff --git a/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs b/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs index a3b4d2da0..104a447f2 100644 --- a/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs +++ b/Projects/Scripts/Engines/ConPVP/TournamentPyramid.cs @@ -8,7 +8,7 @@ namespace Server.Engines.ConPVP { public TourneyPyramid() => Levels = new List(); - public List Levels{ get; set; } + public List Levels { get; set; } public void AddLevel(int partsPerMatch, List participants, GroupingType groupType, TourneyType tourneyType) { @@ -22,150 +22,150 @@ namespace Server.Engines.ConPVP switch (tourneyType) { case TourneyType.RedVsBlue: - { - TourneyParticipant[] parts = new TourneyParticipant[2]; - - for (int i = 0; i < parts.Length; ++i) - parts[i] = new TourneyParticipant(new List()); - - for (int i = 0; i < copy.Count; ++i) { - List players = copy[i].Players; + TourneyParticipant[] parts = new TourneyParticipant[2]; - for (int j = 0; j < players.Count; ++j) + for (int i = 0; i < parts.Length; ++i) + parts[i] = new TourneyParticipant(new List()); + + for (int i = 0; i < copy.Count; ++i) { - Mobile mob = players[j]; + List players = copy[i].Players; - if (mob.Kills >= 5) - parts[0].Players.Add(mob); - else - parts[1].Players.Add(mob); + for (int j = 0; j < players.Count; ++j) + { + Mobile mob = players[j]; + + if (mob.Kills >= 5) + parts[0].Players.Add(mob); + else + parts[1].Players.Add(mob); + } } - } - level.Matches.Add(new TourneyMatch(new List(parts))); - break; - } + level.Matches.Add(new TourneyMatch(new List(parts))); + break; + } case TourneyType.Faction: - { - TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch]; - - for (int i = 0; i < parts.Length; ++i) - parts[i] = new TourneyParticipant(new List()); - - for (int i = 0; i < copy.Count; ++i) { - List players = copy[i].Players; + TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch]; - for (int j = 0; j < players.Count; ++j) + for (int i = 0; i < parts.Length; ++i) + parts[i] = new TourneyParticipant(new List()); + + for (int i = 0; i < copy.Count; ++i) { - Mobile mob = players[j]; + List players = copy[i].Players; - int index = -1; - - if (partsPerMatch == 4) + for (int j = 0; j < players.Count; ++j) { - Faction fac = Faction.Find(mob); + Mobile mob = players[j]; - if (fac != null) - index = fac.Definition.Sort; + int index = -1; + + if (partsPerMatch == 4) + { + Faction fac = Faction.Find(mob); + + if (fac != null) + index = fac.Definition.Sort; + } + else if (partsPerMatch == 2) + { + if (Ethic.Evil.IsEligible(mob)) + index = 0; + else if (Ethic.Hero.IsEligible(mob)) index = 1; + } + + if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch; + + parts[index].Players.Add(mob); } - else if (partsPerMatch == 2) - { - if (Ethic.Evil.IsEligible(mob)) - index = 0; - else if (Ethic.Hero.IsEligible(mob)) index = 1; - } - - if (index < 0 || index >= partsPerMatch) index = i % partsPerMatch; - - parts[index].Players.Add(mob); } - } - level.Matches.Add(new TourneyMatch(new List(parts))); - break; - } + level.Matches.Add(new TourneyMatch(new List(parts))); + break; + } case TourneyType.RandomTeam: - { - TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch]; - - for (int i = 0; i < partsPerMatch; ++i) - parts[i] = new TourneyParticipant(new List()); - - for (int i = 0; i < copy.Count; ++i) - parts[i % parts.Length].Players.AddRange(copy[i].Players); - - level.Matches.Add(new TourneyMatch(new List(parts))); - break; - } - case TourneyType.FreeForAll: - { - level.Matches.Add(new TourneyMatch(copy)); - break; - } - case TourneyType.Standard: - { - if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1) { - int lowAdvances = int.MaxValue; - - for (int i = 0; i < participants.Count; ++i) - { - TourneyParticipant p = participants[i]; - - if (p.FreeAdvances < lowAdvances) - lowAdvances = p.FreeAdvances; - } - - List toAdvance = new List(); - - for (int i = 0; i < participants.Count; ++i) - { - TourneyParticipant p = participants[i]; - - if (p.FreeAdvances == lowAdvances) - toAdvance.Add(p); - } - - if (toAdvance.Count == 0) - toAdvance = copy; // sanity - - int idx = Utility.Random(toAdvance.Count); - - toAdvance[idx].AddLog( - "Advanced automatically due to an odd number of challengers."); - level.FreeAdvance = toAdvance[idx]; - ++level.FreeAdvance.FreeAdvances; - copy.Remove(toAdvance[idx]); - } - - while (copy.Count >= partsPerMatch) - { - List thisMatch = new List(); + TourneyParticipant[] parts = new TourneyParticipant[partsPerMatch]; for (int i = 0; i < partsPerMatch; ++i) - { - var idx = groupType switch - { - GroupingType.HighVsLow => (i * (copy.Count - 1) / (partsPerMatch - 1)), - GroupingType.Nearest => 0, - GroupingType.Random => Utility.Random(copy.Count), - _ => 0 - }; + parts[i] = new TourneyParticipant(new List()); - thisMatch.Add(copy[idx]); - copy.RemoveAt(idx); + for (int i = 0; i < copy.Count; ++i) + parts[i % parts.Length].Players.AddRange(copy[i].Players); + + level.Matches.Add(new TourneyMatch(new List(parts))); + break; + } + case TourneyType.FreeForAll: + { + level.Matches.Add(new TourneyMatch(copy)); + break; + } + case TourneyType.Standard: + { + if (partsPerMatch >= 2 && participants.Count % partsPerMatch == 1) + { + int lowAdvances = int.MaxValue; + + for (int i = 0; i < participants.Count; ++i) + { + TourneyParticipant p = participants[i]; + + if (p.FreeAdvances < lowAdvances) + lowAdvances = p.FreeAdvances; + } + + List toAdvance = new List(); + + for (int i = 0; i < participants.Count; ++i) + { + TourneyParticipant p = participants[i]; + + if (p.FreeAdvances == lowAdvances) + toAdvance.Add(p); + } + + if (toAdvance.Count == 0) + toAdvance = copy; // sanity + + int idx = Utility.Random(toAdvance.Count); + + toAdvance[idx].AddLog( + "Advanced automatically due to an odd number of challengers."); + level.FreeAdvance = toAdvance[idx]; + ++level.FreeAdvance.FreeAdvances; + copy.Remove(toAdvance[idx]); } - level.Matches.Add(new TourneyMatch(thisMatch)); + while (copy.Count >= partsPerMatch) + { + List thisMatch = new List(); + + for (int i = 0; i < partsPerMatch; ++i) + { + var idx = groupType switch + { + GroupingType.HighVsLow => i * (copy.Count - 1) / (partsPerMatch - 1), + GroupingType.Nearest => 0, + GroupingType.Random => Utility.Random(copy.Count), + _ => 0 + }; + + thisMatch.Add(copy[idx]); + copy.RemoveAt(idx); + } + + level.Matches.Add(new TourneyMatch(thisMatch)); + } + + if (copy.Count > 1) + level.Matches.Add(new TourneyMatch(copy)); + + break; } - - if (copy.Count > 1) - level.Matches.Add(new TourneyMatch(copy)); - - break; - } } Levels.Add(level); @@ -174,7 +174,7 @@ namespace Server.Engines.ConPVP public class PyramidLevel { - public List Matches{ get; set; } = new List(); - public TourneyParticipant FreeAdvance{ get; set; } + public List Matches { get; set; } = new List(); + public TourneyParticipant FreeAdvance { get; set; } } } diff --git a/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs b/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs index 7137c5a3c..bb491abea 100644 --- a/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs +++ b/Projects/Scripts/Engines/ConPVP/TournamentRegistrar.cs @@ -18,7 +18,7 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public TournamentController Tournament{ get; set; } + public TournamentController Tournament { get; set; } private void Announce_Callback() { @@ -81,10 +81,10 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Tournament = reader.ReadItem() as TournamentController; - break; - } + { + Tournament = reader.ReadItem() as TournamentController; + break; + } } Timer.DelayCall(TimeSpan.FromSeconds(30.0), TimeSpan.FromSeconds(30.0), Announce_Callback); diff --git a/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs b/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs index 77651568c..1078775ee 100644 --- a/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs +++ b/Projects/Scripts/Engines/ConPVP/TournamentSignupItem.cs @@ -15,10 +15,10 @@ namespace Server.Engines.ConPVP } [CommandProperty(AccessLevel.GameMaster)] - public TournamentController Tournament{ get; set; } + public TournamentController Tournament { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Registrar{ get; set; } + public Mobile Registrar { get; set; } public override string DefaultName => "tournament signup book"; @@ -41,77 +41,77 @@ namespace Server.Engines.ConPVP switch (tourney.Stage) { case TournamentStage.Fighting: - { - if (Registrar != null) { - if (tourney.HasParticipant(from)) - Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "Excuse me? You are already signed up.", from.NetState); - else - Registrar.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "The tournament has already begun. You are too late to signup now.", - from.NetState); - } + if (Registrar != null) + { + if (tourney.HasParticipant(from)) + Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "Excuse me? You are already signed up.", from.NetState); + else + Registrar.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "The tournament has already begun. You are too late to signup now.", + from.NetState); + } - break; - } + break; + } case TournamentStage.Inactive: - { - Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "The tournament is closed.", from.NetState); + { + Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "The tournament is closed.", from.NetState); - break; - } + break; + } case TournamentStage.Signup: - { - Ladder ladder = Ladder.Instance; - LadderEntry entry = ladder?.Find(from); - - if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) { - Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState); + Ladder ladder = Ladder.Instance; + LadderEntry entry = ladder?.Find(from); + + if (entry != null && Ladder.GetLevel(entry.Experience) < tourney.LevelRequirement) + { + Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "You have not yet proven yourself a worthy dueler.", from.NetState); + + break; + } + + if (tourney.IsFactionRestricted && Faction.Find(from) == null) + { + Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "Only those who have declared their faction allegiance may participate.", + from.NetState); + + break; + } + + if (from.HasGump()) + { + Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "You must first respond to the offer I've given you.", from.NetState); + } + else if (from.HasGump()) + { + Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "You must first cancel your duel offer.", from.NetState); + } + else if (from is PlayerMobile mobile && mobile.DuelContext != null) + { + Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x22, false, "You are already participating in a duel.", mobile.NetState); + } + else if (!tourney.HasParticipant(from)) + { + from.CloseGump(); + from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List { from })); + } + else + { + Registrar?.PrivateOverheadMessage(MessageType.Regular, + 0x35, false, "You have already entered this tournament.", from.NetState); + } break; } - - if (tourney.IsFactionRestricted && Faction.Find(from) == null) - { - Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "Only those who have declared their faction allegiance may participate.", - from.NetState); - - break; - } - - if (from.HasGump()) - { - Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "You must first respond to the offer I've given you.", from.NetState); - } - else if (from.HasGump()) - { - Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "You must first cancel your duel offer.", from.NetState); - } - else if (from is PlayerMobile mobile && mobile.DuelContext != null) - { - Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x22, false, "You are already participating in a duel.", mobile.NetState); - } - else if (!tourney.HasParticipant(from)) - { - from.CloseGump(); - from.SendGump(new ConfirmSignupGump(from, Registrar, tourney, new List { from })); - } - else - { - Registrar?.PrivateOverheadMessage(MessageType.Regular, - 0x35, false, "You have already entered this tournament.", from.NetState); - } - - break; - } } } } @@ -135,11 +135,11 @@ namespace Server.Engines.ConPVP switch (version) { case 0: - { - Tournament = reader.ReadItem() as TournamentController; - Registrar = reader.ReadMobile(); - break; - } + { + Tournament = reader.ReadItem() as TournamentController; + Registrar = reader.ReadMobile(); + break; + } } } } diff --git a/Projects/Scripts/Engines/ConPVP/TourneyParticipant.cs b/Projects/Scripts/Engines/ConPVP/TourneyParticipant.cs index 7591a527b..9a5d95d07 100644 --- a/Projects/Scripts/Engines/ConPVP/TourneyParticipant.cs +++ b/Projects/Scripts/Engines/ConPVP/TourneyParticipant.cs @@ -18,11 +18,11 @@ namespace Server.Engines.ConPVP Players = players; } - public List Players{ get; set; } + public List Players { get; set; } - public List Log{ get; set; } + public List Log { get; set; } - public int FreeAdvances{ get; set; } + public int FreeAdvances { get; set; } public int TotalLadderXP { diff --git a/Projects/Scripts/Engines/ConPVP/Trophy.cs b/Projects/Scripts/Engines/ConPVP/Trophy.cs index c8c3f60e0..caf4561da 100644 --- a/Projects/Scripts/Engines/ConPVP/Trophy.cs +++ b/Projects/Scripts/Engines/ConPVP/Trophy.cs @@ -31,7 +31,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string Title{ get; set; } + public string Title { get; set; } [CommandProperty(AccessLevel.GameMaster)] public TrophyRank Rank @@ -45,10 +45,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime Date{ get; private set; } + public DateTime Date { get; private set; } public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Engines/Craft/Core/CraftContext.cs b/Projects/Scripts/Engines/Craft/Core/CraftContext.cs index 38bc10757..151dbcd70 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftContext.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftContext.cs @@ -19,17 +19,17 @@ namespace Server.Engines.Craft LastGroupIndex = -1; } - public List Items{ get; } + public List Items { get; } - public int LastResourceIndex{ get; set; } + public int LastResourceIndex { get; set; } - public int LastResourceIndex2{ get; set; } + public int LastResourceIndex2 { get; set; } - public int LastGroupIndex{ get; set; } + public int LastGroupIndex { get; set; } - public bool DoNotColor{ get; set; } + public bool DoNotColor { get; set; } - public CraftMarkOption MarkOption{ get; set; } + public CraftMarkOption MarkOption { get; set; } public CraftItem LastMade { diff --git a/Projects/Scripts/Engines/Craft/Core/CraftGroup.cs b/Projects/Scripts/Engines/Craft/Core/CraftGroup.cs index c3fe8d237..8072d0af7 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftGroup.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftGroup.cs @@ -9,11 +9,11 @@ namespace Server.Engines.Craft CraftItems = new CraftItemCol(); } - public CraftItemCol CraftItems{ get; } + public CraftItemCol CraftItems { get; } - public string NameString{ get; } + public string NameString { get; } - public int NameNumber{ get; } + public int NameNumber { get; } public void AddCraftItem(CraftItem craftItem) { diff --git a/Projects/Scripts/Engines/Craft/Core/CraftGroupCol.cs b/Projects/Scripts/Engines/Craft/Core/CraftGroupCol.cs index 196924e4a..9aa926c03 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftGroupCol.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftGroupCol.cs @@ -28,8 +28,8 @@ namespace Server.Engines.Craft int nameNumber = craftGroup.NameNumber; string nameString = craftGroup.NameString; - if (nameNumber != 0 && nameNumber == groupName.Number || - nameString != null && nameString == groupName.String) + if ((nameNumber != 0 && nameNumber == groupName.Number) || + (nameString != null && nameString == groupName.String)) return i; } diff --git a/Projects/Scripts/Engines/Craft/Core/CraftGump.cs b/Projects/Scripts/Engines/Craft/Core/CraftGump.cs index e7f5447ce..0abf2595e 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftGump.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftGump.cs @@ -11,11 +11,11 @@ namespace Server.Engines.Craft private const int LabelHue = 0x480; private const int LabelColor = 0x7FFF; private const int FontColor = 0xFFFFFF; - private CraftSystem m_CraftSystem; - private Mobile m_From; + private readonly CraftSystem m_CraftSystem; + private readonly Mobile m_From; - private CraftPage m_Page; - private BaseTool m_Tool; + private readonly CraftPage m_Page; + private readonly BaseTool m_Tool; public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None) : base(40, 40) { @@ -384,209 +384,209 @@ namespace Server.Engines.Craft switch (type) { case 0: // Show group - { - if (context == null) - break; - - if (index >= 0 && index < groups.Count) { - context.LastGroupIndex = index; - m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); - } + if (context == null) + break; - break; - } + if (index >= 0 && index < groups.Count) + { + context.LastGroupIndex = index; + m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); + } + + break; + } case 1: // Create item - { - if (context == null) - break; - - int groupIndex = context.LastGroupIndex; - - if (groupIndex >= 0 && groupIndex < groups.Count) { - CraftGroup group = groups.GetAt(groupIndex); + if (context == null) + break; - if (index >= 0 && index < group.CraftItems.Count) - CraftItem(group.CraftItems.GetAt(index)); + int groupIndex = context.LastGroupIndex; + + if (groupIndex >= 0 && groupIndex < groups.Count) + { + CraftGroup group = groups.GetAt(groupIndex); + + if (index >= 0 && index < group.CraftItems.Count) + CraftItem(group.CraftItems.GetAt(index)); + } + + break; } - - break; - } case 2: // Item details - { - if (context == null) - break; - - int groupIndex = context.LastGroupIndex; - - if (groupIndex >= 0 && groupIndex < groups.Count) { - CraftGroup group = groups.GetAt(groupIndex); + if (context == null) + break; - if (index >= 0 && index < group.CraftItems.Count) - m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool)); + int groupIndex = context.LastGroupIndex; + + if (groupIndex >= 0 && groupIndex < groups.Count) + { + CraftGroup group = groups.GetAt(groupIndex); + + if (index >= 0 && index < group.CraftItems.Count) + m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool)); + } + + break; } - - break; - } case 3: // Create item (last 10) - { - if (context == null) + { + if (context == null) + break; + + List lastTen = context.Items; + + if (index >= 0 && index < lastTen.Count) + CraftItem(lastTen[index]); + break; - - List lastTen = context.Items; - - if (index >= 0 && index < lastTen.Count) - CraftItem(lastTen[index]); - - break; - } + } case 4: // Item details (last 10) - { - if (context == null) + { + if (context == null) + break; + + List lastTen = context.Items; + + if (index >= 0 && index < lastTen.Count) + m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool)); + break; - - List lastTen = context.Items; - - if (index >= 0 && index < lastTen.Count) - m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool)); - - break; - } + } case 5: // Resource selected - { - if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count) { - CraftSubRes res = system.CraftSubRes.GetAt(index); - - if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) + if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count) { - m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); - } - else - { - if (context != null) - context.LastResourceIndex = index; + CraftSubRes res = system.CraftSubRes.GetAt(index); - m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); - } - } - else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count) - { - CraftSubRes res = system.CraftSubRes2.GetAt(index); - - if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) - { - m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); - } - else - { - if (context != null) - context.LastResourceIndex2 = index; - - m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); - } - } - - break; - } - case 6: // Misc. buttons - { - switch (index) - { - case 0: // Resource selection - { - if (system.CraftSubRes.Init) - m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource)); - - break; - } - case 1: // Smelt item - { - if (system.Resmelt) - Resmelt.Do(m_From, system, m_Tool); - - break; - } - case 2: // Make last - { - if (context == null) - break; - - CraftItem item = context.LastMade; - - if (item != null) - CraftItem(item); - else - m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, - m_Page)); // You haven't made anything yet. - - break; - } - case 3: // Last 10 - { - if (context == null) - break; - - context.LastGroupIndex = 501; - m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); - - break; - } - case 4: // Toggle use resource hue - { - if (context == null) - break; - - context.DoNotColor = !context.DoNotColor; - - m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); - - break; - } - case 5: // Repair item - { - if (system.Repair) - Repair.Do(m_From, system, m_Tool); - - break; - } - case 6: // Toggle mark option - { - if (context == null || !system.MarkOption) - break; - - context.MarkOption = context.MarkOption switch + if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) { - CraftMarkOption.MarkItem => CraftMarkOption.DoNotMark, - CraftMarkOption.DoNotMark => CraftMarkOption.PromptForMark, - CraftMarkOption.PromptForMark => CraftMarkOption.MarkItem, - _ => context.MarkOption - }; + m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); + } + else + { + if (context != null) + context.LastResourceIndex = index; - m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); - - break; + m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); + } } - case 7: // Resource selection 2 + else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count) { - if (system.CraftSubRes2.Init) - m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2)); + CraftSubRes res = system.CraftSubRes2.GetAt(index); - break; - } - case 8: // Enhance item - { - if (system.CanEnhance) - Enhance.BeginTarget(m_From, system, m_Tool); + if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill) + { + m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message)); + } + else + { + if (context != null) + context.LastResourceIndex2 = index; - break; + m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); + } } + + break; } + case 6: // Misc. buttons + { + switch (index) + { + case 0: // Resource selection + { + if (system.CraftSubRes.Init) + m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource)); - break; - } + break; + } + case 1: // Smelt item + { + if (system.Resmelt) + Resmelt.Do(m_From, system, m_Tool); + + break; + } + case 2: // Make last + { + if (context == null) + break; + + CraftItem item = context.LastMade; + + if (item != null) + CraftItem(item); + else + m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, + m_Page)); // You haven't made anything yet. + + break; + } + case 3: // Last 10 + { + if (context == null) + break; + + context.LastGroupIndex = 501; + m_From.SendGump(new CraftGump(m_From, system, m_Tool, null)); + + break; + } + case 4: // Toggle use resource hue + { + if (context == null) + break; + + context.DoNotColor = !context.DoNotColor; + + m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); + + break; + } + case 5: // Repair item + { + if (system.Repair) + Repair.Do(m_From, system, m_Tool); + + break; + } + case 6: // Toggle mark option + { + if (context == null || !system.MarkOption) + break; + + context.MarkOption = context.MarkOption switch + { + CraftMarkOption.MarkItem => CraftMarkOption.DoNotMark, + CraftMarkOption.DoNotMark => CraftMarkOption.PromptForMark, + CraftMarkOption.PromptForMark => CraftMarkOption.MarkItem, + _ => context.MarkOption + }; + + m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page)); + + break; + } + case 7: // Resource selection 2 + { + if (system.CraftSubRes2.Init) + m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2)); + + break; + } + case 8: // Enhance item + { + if (system.CanEnhance) + Enhance.BeginTarget(m_From, system, m_Tool); + + break; + } + } + + break; + } } } diff --git a/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs b/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs index 7edce2b0a..eed593b97 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftGumpItem.cs @@ -16,16 +16,16 @@ namespace Server.Engines.Craft private const int GreyLabelColor = 0x3DEF; - private static Type typeofBlankScroll = typeof(BlankScroll); - private static Type typeofSpellScroll = typeof(SpellScroll); - private CraftItem m_CraftItem; - private CraftSystem m_CraftSystem; - private Mobile m_From; + private static readonly Type typeofBlankScroll = typeof(BlankScroll); + private static readonly Type typeofSpellScroll = typeof(SpellScroll); + private readonly CraftItem m_CraftItem; + private readonly CraftSystem m_CraftSystem; + private readonly Mobile m_From; private int m_OtherCount; private bool m_ShowExceptionalChance; - private BaseTool m_Tool; + private readonly BaseTool m_Tool; public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool) : base(40, 40) { @@ -93,7 +93,7 @@ namespace Server.Engines.Craft DrawResource(); /* - if ( craftItem.RequiresSE ) + if (craftItem.RequiresSE) AddHtmlLocalized( 170, 302 + (m_OtherCount++ * 20), 310, 18, 1063363, LabelColor, false, false ); //* Requires the "Samurai Empire" expansion * */ diff --git a/Projects/Scripts/Engines/Craft/Core/CraftItem.cs b/Projects/Scripts/Engines/Craft/Core/CraftItem.cs index 305fa7c49..33f4ac895 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftItem.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftItem.cs @@ -24,7 +24,7 @@ namespace Server.Engines.Craft public class CraftItem { - private static Dictionary _itemIds = new Dictionary(); + private static readonly Dictionary _itemIds = new Dictionary(); private int m_ResAmount; private int m_ResHue; @@ -46,45 +46,45 @@ namespace Server.Engines.Craft RequiredBeverage = BeverageType.Water; } - public bool ForceNonExceptional{ get; set; } + public bool ForceNonExceptional { get; set; } - public Expansion RequiredExpansion{ get; set; } + public Expansion RequiredExpansion { get; set; } - public Recipe Recipe{ get; private set; } + public Recipe Recipe { get; private set; } - public BeverageType RequiredBeverage{ get; set; } + public BeverageType RequiredBeverage { get; set; } - public int Mana{ get; set; } + public int Mana { get; set; } - public int Hits{ get; set; } + public int Hits { get; set; } - public int Stam{ get; set; } + public int Stam { get; set; } - public bool UseSubRes2{ get; set; } + public bool UseSubRes2 { get; set; } - public bool UseAllRes{ get; set; } + public bool UseAllRes { get; set; } - public bool NeedHeat{ get; set; } + public bool NeedHeat { get; set; } - public bool NeedOven{ get; set; } + public bool NeedOven { get; set; } - public bool NeedMill{ get; set; } + public bool NeedMill { get; set; } - public Type ItemType{ get; } + public Type ItemType { get; } - public int ItemHue{ get; set; } + public int ItemHue { get; set; } - public string GroupNameString{ get; } + public string GroupNameString { get; } - public int GroupNameNumber{ get; } + public int GroupNameNumber { get; } - public string NameString{ get; } + public string NameString { get; } - public int NameNumber{ get; } + public int NameNumber { get; } - public CraftResCol Resources{ get; } + public CraftResCol Resources { get; } - public CraftSkillCol Skills{ get; } + public CraftSkillCol Skills { get; } public void AddRecipe(int id, CraftSystem system) { @@ -170,7 +170,6 @@ namespace Server.Engines.Craft Resources.Add(craftRes); } - public void AddSkill(SkillName skillToMake, double minSkill, double maxSkill) { CraftSkill craftSkill = new CraftSkill(skillToMake, minSkill, maxSkill); @@ -221,7 +220,7 @@ namespace Server.Engines.Craft public bool IsMarkable(Type type) { - if (ForceNonExceptional) //Don't even display the stuff for marking if it can't ever be exceptional. + if (ForceNonExceptional) // Don't even display the stuff for marking if it can't ever be exceptional. return false; for (int i = 0; i < m_MarkableTable.Length; ++i) @@ -282,27 +281,27 @@ namespace Server.Engines.Craft return true; for (int x = -2; x <= 2; ++x) - for (int y = -2; y <= 2; ++y) - { - int vx = from.X + x; - int vy = from.Y + y; - - StaticTile[] tiles = map.Tiles.GetStaticTiles(vx, vy, true); - - for (int i = 0; i < tiles.Length; ++i) + for (int y = -2; y <= 2; ++y) { - int z = tiles[i].Z; - int id = tiles[i].ID; + int vx = from.X + x; + int vy = from.Y + y; - if (z + 16 > from.Z && from.Z + 16 > z && Find(id, itemIDs)) - return true; + StaticTile[] tiles = map.Tiles.GetStaticTiles(vx, vy, true); + + for (int i = 0; i < tiles.Length; ++i) + { + int z = tiles[i].Z; + int id = tiles[i].ID; + + if (z + 16 > from.Z && from.Z + 16 > z && Find(id, itemIDs)) + return true; + } } - } return false; } - public bool Find(int itemID, int[] itemIDs) + public static bool Find(int itemID, int[] itemIDs) { bool contains = false; @@ -312,19 +311,8 @@ namespace Server.Engines.Craft return contains; } - public bool IsQuantityType(Type[][] types) - { - for (int i = 0; i < types.Length; ++i) - { - Type[] check = types[i]; - - for (int j = 0; j < check.Length; ++j) - if (typeof(IHasQuantity).IsAssignableFrom(check[j])) - return true; - } - - return false; - } + public bool IsQuantityType(Type[][] types) => + types.Any(check => check.Any(t => typeof(IHasQuantity).IsAssignableFrom(t))); public int ConsumeQuantity(Container cont, Type[][] types, int[] amounts) { @@ -461,6 +449,7 @@ namespace Server.Engines.Craft CraftSubResCol resCol = UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes; + CraftRes res; for (int i = 0; i < types.Length; ++i) { CraftRes craftRes = Resources.GetAt(i); @@ -501,7 +490,7 @@ namespace Server.Engines.Craft if (maxAmount == 0) { - CraftRes res = Resources.GetAt(i); + res = Resources.GetAt(i); if (res.MessageNumber > 0) message = res.MessageNumber; @@ -557,7 +546,6 @@ namespace Server.Engines.Craft resHue = m_ResHue; } - // Consume Half ( for use all resource craft type ) else if (consumeType == ConsumeType.Half) { @@ -580,7 +568,6 @@ namespace Server.Engines.Craft resHue = m_ResHue; } - else // ConstumeType.None ( it's basically used to know if the crafter has enough resource before starting the process ) { index = -1; @@ -612,18 +599,16 @@ namespace Server.Engines.Craft return true; } - { - CraftRes res = Resources.GetAt(index); + res = Resources.GetAt(index); - if (res.MessageNumber > 0) - message = res.MessageNumber; - else if (!string.IsNullOrEmpty(res.MessageString)) - message = res.MessageString; - else - message = 502925; // You don't have the resources required to make that item. + if (res.MessageNumber > 0) + message = res.MessageNumber; + else if (!string.IsNullOrEmpty(res.MessageString)) + message = res.MessageString; + else + message = 502925; // You don't have the resources required to make that item. - return false; - } + return false; } private void OnResourceConsumed(Item item, int amount) @@ -662,17 +647,17 @@ namespace Server.Engines.Craft chance = chance * 0.5 - 0.1; break; case CraftECA.ChanceMinusSixtyToFourtyFive: - { - double offset = 0.60 - (from.Skills[system.MainSkill].Value - 95.0) * 0.03; + { + double offset = 0.60 - (from.Skills[system.MainSkill].Value - 95.0) * 0.03; - if (offset < 0.45) - offset = 0.45; - else if (offset > 0.60) - offset = 0.60; + if (offset < 0.45) + offset = 0.45; + else if (offset > 0.60) + offset = 0.60; - chance -= offset; - break; - } + chance -= offset; + break; + } } if (chance > 0) @@ -731,7 +716,7 @@ namespace Server.Engines.Craft if (allRequiredSkills) chance = craftSystem.GetChanceAtMin(this) + (valMainSkill - minMainSkill) / (maxMainSkill - minMainSkill) * - (1.0 - craftSystem.GetChanceAtMin(this)); + (1.0 - craftSystem.GetChanceAtMin(this)); else chance = 0.0; @@ -819,7 +804,7 @@ namespace Server.Engines.Craft { from.EndAction(); from.SendGump(new CraftGump(from, craftSystem, tool, - RequiredExpansionMessage(RequiredExpansion))); //The {0} expansion is required to attempt this item. + RequiredExpansionMessage(RequiredExpansion))); // The {0} expansion is required to attempt this item. } } else @@ -828,12 +813,12 @@ namespace Server.Engines.Craft } } - //Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea. + // Eventually convert to TextDefinition, but that requires that we convert all the gumps to ues it too. Not that it wouldn't be a bad idea. private object RequiredExpansionMessage(Expansion expansion) { return expansion switch { - Expansion.SE => (object)1063307, // The "Samurai Empire" expansion is required to attempt this item. + Expansion.SE => 1063307, // The "Samurai Empire" expansion is required to attempt this item. Expansion.ML => 1072650, // The "Mondain's Legacy" expansion is required to attempt this item. _ => $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item." }; @@ -955,7 +940,7 @@ namespace Server.Engines.Craft CommandLogging.WriteLine(from, "Crafting {0} with craft system {1}", CommandLogging.Format(item), craftSystem.GetType().Name); - //from.PlaySound( 0x57 ); + // from.PlaySound( 0x57 ); } if (num == 0) @@ -1052,13 +1037,13 @@ namespace Server.Engines.Craft private class InternalTimer : Timer { - private CraftItem m_CraftItem; - private CraftSystem m_CraftSystem; - private Mobile m_From; + private readonly CraftItem m_CraftItem; + private readonly CraftSystem m_CraftSystem; + private readonly Mobile m_From; private int m_iCount; - private int m_iCountMax; - private BaseTool m_Tool; - private Type m_TypeRes; + private readonly int m_iCountMax; + private readonly BaseTool m_Tool; + private readonly Type m_TypeRes; public InternalTimer(Mobile from, CraftSystem craftSystem, CraftItem craftItem, Type typeRes, BaseTool tool, int iCountMax) : base(TimeSpan.Zero, TimeSpan.FromSeconds(craftSystem.Delay), iCountMax) @@ -1148,9 +1133,7 @@ namespace Server.Engines.Craft } } - #region Tables - - private static int[] m_HeatSources = + private static readonly int[] m_HeatSources = { 0x461, 0x48E, // Sandstone oven/fireplace 0x92B, 0x96C, // Stone oven/fireplace @@ -1159,27 +1142,27 @@ namespace Server.Engines.Craft 0x184A, 0x184C, // Heating stand (left) 0x184E, 0x1850, // Heating stand (right) 0x398C, 0x399F, // Fire field - 0x2DDB, 0x2DDC, //Elven stove + 0x2DDB, 0x2DDC, // Elven stove 0x19AA, 0x19BB, // Veteran Reward Brazier 0x197A, 0x19A9, // Large Forge 0x0FB1, 0x0FB1, // Small Forge 0x2DD8, 0x2DD8 // Elven Forge }; - private static int[] m_Ovens = + private static readonly int[] m_Ovens = { 0x461, 0x46F, // Sandstone oven 0x92B, 0x93F, // Stone oven - 0x2DDB, 0x2DDC //Elven stove + 0x2DDB, 0x2DDC // Elven stove }; - private static int[] m_Mills = + private static readonly int[] m_Mills = { 0x1920, 0x1921, 0x1922, 0x1923, 0x1924, 0x1295, 0x1926, 0x1928, 0x192C, 0x192D, 0x192E, 0x129F, 0x1930, 0x1931, 0x1932, 0x1934 }; - private static Type[][] m_TypesTable = + private static readonly Type[][] m_TypesTable = { new[] { typeof(Log), typeof(Board) }, new[] { typeof(HeartwoodLog), typeof(HeartwoodBoard) }, @@ -1199,13 +1182,13 @@ namespace Server.Engines.Craft new[] { typeof(WoodenBowlOfPeas), typeof(PewterBowlOfPeas) } }; - private static Type[] m_ColoredItemTable = + private static readonly Type[] m_ColoredItemTable = { typeof(BaseWeapon), typeof(BaseArmor), typeof(BaseClothing), typeof(BaseJewel), typeof(DragonBardingDeed) }; - private static Type[] m_ColoredResourceTable = + private static readonly Type[] m_ColoredResourceTable = { typeof(BaseIngot), typeof(BaseOre), typeof(BaseLeather), typeof(BaseHides), @@ -1213,7 +1196,7 @@ namespace Server.Engines.Craft typeof(BaseGranite), typeof(BaseScales) }; - private static Type[] m_MarkableTable = + private static readonly Type[] m_MarkableTable = { typeof(BaseArmor), typeof(BaseWeapon), @@ -1227,11 +1210,9 @@ namespace Server.Engines.Craft typeof(BaseQuiver) }; - private static Type[] m_NeverColorTable = + private static readonly Type[] m_NeverColorTable = { typeof(OrcHelm) }; - - #endregion } } diff --git a/Projects/Scripts/Engines/Craft/Core/CraftItemIDAttribute.cs b/Projects/Scripts/Engines/Craft/Core/CraftItemIDAttribute.cs index 74cc0d9f6..ac0a2d76d 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftItemIDAttribute.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftItemIDAttribute.cs @@ -7,6 +7,6 @@ namespace Server.Engines.Craft { public CraftItemIDAttribute(int itemID) => ItemID = itemID; - public int ItemID{ get; } + public int ItemID { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Craft/Core/CraftRes.cs b/Projects/Scripts/Engines/Craft/Core/CraftRes.cs index 42bd7155a..9fc4bfbb8 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftRes.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftRes.cs @@ -16,17 +16,17 @@ namespace Server.Engines.Craft MessageString = message; } - public Type ItemType{ get; } + public Type ItemType { get; } - public string MessageString{ get; } + public string MessageString { get; } - public int MessageNumber{ get; } + public int MessageNumber { get; } - public string NameString{ get; } + public string NameString { get; } - public int NameNumber{ get; } + public int NameNumber { get; } - public int Amount{ get; } + public int Amount { get; } public void SendMessage(Mobile from) { diff --git a/Projects/Scripts/Engines/Craft/Core/CraftSkill.cs b/Projects/Scripts/Engines/Craft/Core/CraftSkill.cs index 5fa2fbb2b..afbfae234 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftSkill.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftSkill.cs @@ -9,10 +9,10 @@ namespace Server.Engines.Craft MaxSkill = maxSkill; } - public SkillName SkillToMake{ get; } + public SkillName SkillToMake { get; } - public double MinSkill{ get; } + public double MinSkill { get; } - public double MaxSkill{ get; } + public double MaxSkill { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Craft/Core/CraftSubRes.cs b/Projects/Scripts/Engines/Craft/Core/CraftSubRes.cs index 61bd68da6..88b63a2ec 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftSubRes.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftSubRes.cs @@ -19,16 +19,16 @@ namespace Server.Engines.Craft Message = message; } - public Type ItemType{ get; } + public Type ItemType { get; } - public string NameString{ get; } + public string NameString { get; } - public int NameNumber{ get; } + public int NameNumber { get; } - public int GenericNameNumber{ get; } + public int GenericNameNumber { get; } - public object Message{ get; } + public object Message { get; } - public double RequiredSkill{ get; } + public double RequiredSkill { get; } } } diff --git a/Projects/Scripts/Engines/Craft/Core/CraftSubResCol.cs b/Projects/Scripts/Engines/Craft/Core/CraftSubResCol.cs index 1bad74936..c499f6a31 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftSubResCol.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftSubResCol.cs @@ -7,13 +7,13 @@ namespace Server.Engines.Craft { public CraftSubResCol() => Init = false; - public bool Init{ get; set; } + public bool Init { get; set; } - public Type ResType{ get; set; } + public Type ResType { get; set; } - public string NameString{ get; set; } + public string NameString { get; set; } - public int NameNumber{ get; set; } + public int NameNumber { get; set; } public void Add(CraftSubRes craftSubRes) { diff --git a/Projects/Scripts/Engines/Craft/Core/CraftSystem.cs b/Projects/Scripts/Engines/Craft/Core/CraftSystem.cs index 422919f62..b4baf111d 100644 --- a/Projects/Scripts/Engines/Craft/Core/CraftSystem.cs +++ b/Projects/Scripts/Engines/Craft/Core/CraftSystem.cs @@ -13,9 +13,9 @@ namespace Server.Engines.Craft public abstract class CraftSystem { - private Dictionary m_ContextTable = new Dictionary(); - private List m_RareRecipes; - private List m_Recipes; + private readonly Dictionary m_ContextTable = new Dictionary(); + private readonly List m_RareRecipes; + private readonly List m_Recipes; public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay) { @@ -34,34 +34,34 @@ namespace Server.Engines.Craft InitCraftList(); } - public int MinCraftEffect{ get; } + public int MinCraftEffect { get; } - public int MaxCraftEffect{ get; } + public int MaxCraftEffect { get; } - public double Delay{ get; } + public double Delay { get; } - public CraftItemCol CraftItems{ get; } + public CraftItemCol CraftItems { get; } - public CraftGroupCol CraftGroups{ get; } + public CraftGroupCol CraftGroups { get; } - public CraftSubResCol CraftSubRes{ get; } + public CraftSubResCol CraftSubRes { get; } - public CraftSubResCol CraftSubRes2{ get; } + public CraftSubResCol CraftSubRes2 { get; } - public abstract SkillName MainSkill{ get; } + public abstract SkillName MainSkill { get; } public virtual int GumpTitleNumber => 0; public virtual string GumpTitleString => ""; public virtual CraftECA ECA => CraftECA.ChanceMinusSixty; - public bool Resmelt{ get; set; } + public bool Resmelt { get; set; } - public bool Repair{ get; set; } + public bool Repair { get; set; } - public bool MarkOption{ get; set; } + public bool MarkOption { get; set; } - public bool CanEnhance{ get; set; } + public bool CanEnhance { get; set; } public abstract double GetChanceAtMin(CraftItem item); @@ -114,7 +114,6 @@ namespace Server.Engines.Craft return m_RareRecipes[Utility.Random(m_RareRecipes.Count)]; } - public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, Type typeRes, TextDefinition nameRes, int amount) => AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, ""); @@ -138,7 +137,6 @@ namespace Server.Engines.Craft return CraftItems.Add(craftItem); } - private void DoGroup(TextDefinition groupName, CraftItem craftItem) { int index = CraftGroups.SearchFor(groupName); @@ -155,7 +153,6 @@ namespace Server.Engines.Craft } } - public void SetItemHue(int index, int hue) { CraftItem craftItem = CraftItems.GetAt(index); @@ -268,7 +265,6 @@ namespace Server.Engines.Craft craftItem.ForceNonExceptional = true; } - public void SetSubRes(Type type, string name) { CraftSubRes.ResType = type; @@ -301,7 +297,6 @@ namespace Server.Engines.Craft CraftSubRes.Add(craftSubRes); } - public void SetSubRes2(Type type, string name) { CraftSubRes2.ResType = type; diff --git a/Projects/Scripts/Engines/Craft/Core/CustomCraft.cs b/Projects/Scripts/Engines/Craft/Core/CustomCraft.cs index 656c6e3d1..133994f4e 100644 --- a/Projects/Scripts/Engines/Craft/Core/CustomCraft.cs +++ b/Projects/Scripts/Engines/Craft/Core/CustomCraft.cs @@ -16,17 +16,17 @@ namespace Server.Engines.Craft Quality = quality; } - public Mobile From{ get; } + public Mobile From { get; } - public CraftItem CraftItem{ get; } + public CraftItem CraftItem { get; } - public CraftSystem CraftSystem{ get; } + public CraftSystem CraftSystem { get; } - public Type TypeRes{ get; } + public Type TypeRes { get; } - public BaseTool Tool{ get; } + public BaseTool Tool { get; } - public int Quality{ get; } + public int Quality { get; } public abstract void EndCraftAction(); public abstract Item CompleteCraft(out int message); diff --git a/Projects/Scripts/Engines/Craft/Core/Enhance.cs b/Projects/Scripts/Engines/Craft/Core/Enhance.cs index d634d1545..b08a91886 100644 --- a/Projects/Scripts/Engines/Craft/Core/Enhance.cs +++ b/Projects/Scripts/Engines/Craft/Core/Enhance.cs @@ -182,43 +182,43 @@ namespace Server.Engines.Craft switch (res) { case EnhanceResult.Broken: - { - if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, - ref resMessage)) - return EnhanceResult.NoResources; + { + if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, + ref resMessage)) + return EnhanceResult.NoResources; - item.Delete(); - break; - } + item.Delete(); + break; + } case EnhanceResult.Success: - { - if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, - ref resMessage)) - return EnhanceResult.NoResources; - - if (item is BaseWeapon w) { - w.Resource = resource; + if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, + ref resMessage)) + return EnhanceResult.NoResources; - int hue = w.GetElementalDamageHue(); - if (hue > 0) - w.Hue = hue; - } - else - { - ((BaseArmor)item).Resource = resource; - } + if (item is BaseWeapon w) + { + w.Resource = resource; - break; - } + int hue = w.GetElementalDamageHue(); + if (hue > 0) + w.Hue = hue; + } + else + { + ((BaseArmor)item).Resource = resource; + } + + break; + } case EnhanceResult.Failure: - { - if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, - ref resMessage)) - return EnhanceResult.NoResources; + { + if (!craftItem.ConsumeRes(from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.Half, + ref resMessage)) + return EnhanceResult.NoResources; - break; - } + break; + } } return res; @@ -231,7 +231,7 @@ namespace Server.Engines.Craft int random = Utility.Random(100); - if (10 > random) + if (random < 10) res = EnhanceResult.Failure; else if (chance > random) res = EnhanceResult.Broken; @@ -281,10 +281,10 @@ namespace Server.Engines.Craft private class InternalTarget : Target { - private CraftSystem m_CraftSystem; - private CraftResource m_Resource; - private Type m_ResourceType; - private BaseTool m_Tool; + private readonly CraftSystem m_CraftSystem; + private readonly CraftResource m_Resource; + private readonly Type m_ResourceType; + private readonly BaseTool m_Tool; public InternalTarget(CraftSystem craftSystem, BaseTool tool, Type resourceType, CraftResource resource) : base( 2, false, TargetFlags.None) diff --git a/Projects/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs b/Projects/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs index fe7c17f1b..a6b99b856 100644 --- a/Projects/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs +++ b/Projects/Scripts/Engines/Craft/Core/QueryMakersMarkGump.cs @@ -7,12 +7,12 @@ namespace Server.Engines.Craft { public class QueryMakersMarkGump : Gump { - private CraftItem m_CraftItem; - private CraftSystem m_CraftSystem; - private Mobile m_From; - private int m_Quality; - private BaseTool m_Tool; - private Type m_TypeRes; + private readonly CraftItem m_CraftItem; + private readonly CraftSystem m_CraftSystem; + private readonly Mobile m_From; + private readonly int m_Quality; + private readonly BaseTool m_Tool; + private readonly Type m_TypeRes; public QueryMakersMarkGump(int quality, Mobile from, CraftItem craftItem, CraftSystem craftSystem, Type typeRes, BaseTool tool) : base(100, 200) diff --git a/Projects/Scripts/Engines/Craft/Core/Recipes.cs b/Projects/Scripts/Engines/Craft/Core/Recipes.cs index a2b3578c3..7b226b28a 100644 --- a/Projects/Scripts/Engines/Craft/Core/Recipes.cs +++ b/Projects/Scripts/Engines/Craft/Core/Recipes.cs @@ -22,16 +22,15 @@ namespace Server.Engines.Craft LargestRecipeID = Math.Max(id, LargestRecipeID); } + public static Dictionary Recipes { get; } = new Dictionary(); - public static Dictionary Recipes{ get; } = new Dictionary(); + public static int LargestRecipeID { get; private set; } - public static int LargestRecipeID{ get; private set; } + public CraftSystem CraftSystem { get; set; } - public CraftSystem CraftSystem{ get; set; } + public CraftItem CraftItem { get; set; } - public CraftItem CraftItem{ get; set; } - - public int ID{ get; } + public int ID { get; } public TextDefinition TextDefinition => m_TD ?? (m_TD = new TextDefinition(CraftItem.NameNumber, CraftItem.NameString)); @@ -48,7 +47,7 @@ namespace Server.Engines.Craft Mobile m = e.Mobile; m.SendMessage("Target a player to teach them all of the recipes."); - m.BeginTarget(-1, false, TargetFlags.None, delegate(Mobile from, object targeted) + m.BeginTarget(-1, false, TargetFlags.None, (from, targeted) => { if (targeted is PlayerMobile mobile) { @@ -86,4 +85,4 @@ namespace Server.Engines.Craft }); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Craft/Core/Repair.cs b/Projects/Scripts/Engines/Craft/Core/Repair.cs index 2d74fc499..31cbf521a 100644 --- a/Projects/Scripts/Engines/Craft/Core/Repair.cs +++ b/Projects/Scripts/Engines/Craft/Core/Repair.cs @@ -21,9 +21,9 @@ namespace Server.Engines.Craft private class InternalTarget : Target { - private CraftSystem m_CraftSystem; - private RepairDeed m_Deed; - private BaseTool m_Tool; + private readonly CraftSystem m_CraftSystem; + private readonly RepairDeed m_Deed; + private readonly BaseTool m_Tool; public InternalTarget(CraftSystem craftSystem, BaseTool tool) : base(2, false, TargetFlags.None) { @@ -47,7 +47,6 @@ namespace Server.Engines.Craft { double difficulty = GetRepairDifficulty(curHits, maxHits) * 0.1; - if (m_Deed != null) { double value = m_Deed.SkillLevel; @@ -105,20 +104,14 @@ namespace Server.Engines.Craft || weapon is BlackStaff || weapon is MagicWand - #region Temporary - // TODO: Make these items craftable || weapon is WildStaff; - - #endregion } if (m_CraftSystem is DefBlacksmithy) { return weapon is Pitchfork - #region Temporary - // TODO: Make these items craftable || weapon is RadiantScimitar || weapon is WarCleaver @@ -129,19 +122,13 @@ namespace Server.Engines.Craft || weapon is ElvenMachete || weapon is OrnateAxe || weapon is DiamondMace; - - #endregion } - #region Temporary - // TODO: Make these items craftable if (m_CraftSystem is DefBowFletching) return weapon is ElvenCompositeLongbow || weapon is MagicalShortbow; - #endregion - return false; } @@ -149,8 +136,6 @@ namespace Server.Engines.Craft { // Armor repairable but not craftable - #region Temporary - // TODO: Make these items craftable if (m_CraftSystem is DefTailoring) return armor is LeafTonlet @@ -179,8 +164,6 @@ namespace Server.Engines.Craft || armor is RoyalCirclet || armor is GemmedCirclet; - #endregion - return false; } diff --git a/Projects/Scripts/Engines/Craft/Core/Resmelt.cs b/Projects/Scripts/Engines/Craft/Core/Resmelt.cs index 11b636a9d..fd9656894 100644 --- a/Projects/Scripts/Engines/Craft/Core/Resmelt.cs +++ b/Projects/Scripts/Engines/Craft/Core/Resmelt.cs @@ -32,8 +32,8 @@ namespace Server.Engines.Craft private class InternalTarget : Target { - private CraftSystem m_CraftSystem; - private BaseTool m_Tool; + private readonly CraftSystem m_CraftSystem; + private readonly BaseTool m_Tool; public InternalTarget(CraftSystem craftSystem, BaseTool tool) : base(2, false, TargetFlags.None) { @@ -85,9 +85,9 @@ namespace Server.Engines.Craft Type resourceType = info.ResourceTypes[0]; Item ingot = (Item)ActivatorUtil.CreateInstance(resourceType); - if (item is DragonBardingDeed || item is BaseArmor armor && armor.PlayerConstructed || - item is BaseWeapon weapon && weapon.PlayerConstructed || - item is BaseClothing clothing && clothing.PlayerConstructed) + if (item is DragonBardingDeed || (item is BaseArmor armor && armor.PlayerConstructed) || + (item is BaseWeapon weapon && weapon.PlayerConstructed) || + (item is BaseClothing clothing && clothing.PlayerConstructed)) ingot.Amount = craftResource.Amount / 2; else ingot.Amount = 1; @@ -151,7 +151,7 @@ namespace Server.Engines.Craft { SmeltResult.Invalid => 1044272, SmeltResult.NoSkill => 1044269, - SmeltResult.Success => (isStoreBought ? 500418 : 1044270), + SmeltResult.Success => isStoreBought ? 500418 : 1044270, _ => 1044272 }; diff --git a/Projects/Scripts/Engines/Craft/DefAlchemy.cs b/Projects/Scripts/Engines/Craft/DefAlchemy.cs index 85746fc1f..fb55f8614 100644 --- a/Projects/Scripts/Engines/Craft/DefAlchemy.cs +++ b/Projects/Scripts/Engines/Craft/DefAlchemy.cs @@ -7,7 +7,7 @@ namespace Server.Engines.Craft { private static CraftSystem m_CraftSystem; - private static Type typeofPotion = typeof(BasePotion); + private static readonly Type typeofPotion = typeof(BasePotion); private DefAlchemy() : base(1, 1, 1.25) // base( 1, 1, 3.1 ) { diff --git a/Projects/Scripts/Engines/Craft/DefBlacksmithy.cs b/Projects/Scripts/Engines/Craft/DefBlacksmithy.cs index 4e708cff3..1b9ac5caf 100644 --- a/Projects/Scripts/Engines/Craft/DefBlacksmithy.cs +++ b/Projects/Scripts/Engines/Craft/DefBlacksmithy.cs @@ -7,8 +7,8 @@ namespace Server.Engines.Craft { private static CraftSystem m_CraftSystem; - private static Type typeofAnvil = typeof(AnvilAttribute); - private static Type typeofForge = typeof(ForgeAttribute); + private static readonly Type typeofAnvil = typeof(AnvilAttribute); + private static readonly Type typeofForge = typeof(ForgeAttribute); private DefBlacksmithy() : base(1, 1, 1.25) // base( 1, 2, 1.7 ) { @@ -16,9 +16,9 @@ namespace Server.Engines.Craft base( MinCraftEffect, MaxCraftEffect, Delay ) - MinCraftEffect : The minimum number of time the mobile will play the craft effect - MaxCraftEffect : The maximum number of time the mobile will play the craft effect - Delay : The delay between each craft effect + MinCraftEffect : The minimum number of time the mobile will play the craft effect + MaxCraftEffect : The maximum number of time the mobile will play the craft effect + Delay : The delay between each craft effect Example: (3, 6, 1.7) would make the mobile do the PlayCraftEffect override function between 3 and 6 time, with a 1.7 second delay each time. @@ -55,7 +55,7 @@ namespace Server.Engines.Craft bool isAnvil = type.IsDefined(typeofAnvil, false) || item.ItemID == 4015 || item.ItemID == 4016 || item.ItemID == 0x2DD5 || item.ItemID == 0x2DD6; bool isForge = type.IsDefined(typeofForge, false) || item.ItemID == 4017 || - item.ItemID >= 6522 && item.ItemID <= 6569 || item.ItemID == 0x2DD8; + (item.ItemID >= 6522 && item.ItemID <= 6569) || item.ItemID == 0x2DD8; if (isAnvil || isForge) { @@ -73,28 +73,28 @@ namespace Server.Engines.Craft eable.Free(); for (int x = -range; (!anvil || !forge) && x <= range; ++x) - for (int y = -range; (!anvil || !forge) && y <= range; ++y) - { - StaticTile[] tiles = map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true); - - for (int i = 0; (!anvil || !forge) && i < tiles.Length; ++i) + for (int y = -range; (!anvil || !forge) && y <= range; ++y) { - int id = tiles[i].ID; + StaticTile[] tiles = map.Tiles.GetStaticTiles(from.X + x, from.Y + y, true); - bool isAnvil = id == 4015 || id == 4016 || id == 0x2DD5 || id == 0x2DD6; - bool isForge = id == 4017 || id >= 6522 && id <= 6569 || id == 0x2DD8; - - if (isAnvil || isForge) + for (int i = 0; (!anvil || !forge) && i < tiles.Length; ++i) { - if (from.Z + 16 < tiles[i].Z || tiles[i].Z + 16 < from.Z || - !from.InLOS(new Point3D(from.X + x, from.Y + y, tiles[i].Z + tiles[i].Height / 2 + 1))) - continue; + int id = tiles[i].ID; - anvil = anvil || isAnvil; - forge = forge || isForge; + bool isAnvil = id == 4015 || id == 4016 || id == 0x2DD5 || id == 0x2DD6; + bool isForge = id == 4017 || (id >= 6522 && id <= 6569) || id == 0x2DD8; + + if (isAnvil || isForge) + { + if (from.Z + 16 < tiles[i].Z || tiles[i].Z + 16 < from.Z || + !from.InLOS(new Point3D(from.X + x, from.Y + y, tiles[i].Z + tiles[i].Height / 2 + 1))) + continue; + + anvil = anvil || isAnvil; + forge = forge || isForge; + } } } - } } public override int CanCraft(Mobile from, BaseTool tool, Type itemType) @@ -117,9 +117,9 @@ namespace Server.Engines.Craft public override void PlayCraftEffect(Mobile from) { // no animation, instant sound - //if ( from.Body.Type == BodyType.Human && !from.Mounted ) - // from.Animate( 9, 5, 1, true, false, 0 ); - //new InternalTimer( from ).Start(); + // if (from.Body.Type == BodyType.Human && !from.Mounted) + // from.Animate( 9, 5, 1, true, false, 0 ); + // new InternalTimer( from ).Start(); from.PlaySound(0x2A); } @@ -152,13 +152,13 @@ namespace Server.Engines.Craft Syntax for a SIMPLE craft item AddCraft( ObjectType, Group, MinSkill, MaxSkill, ResourceType, Amount, Message ) - ObjectType : The type of the object you want to add to the build list. - Group : The group in which the object will be showed in the craft menu. - MinSkill : The minimum of skill value - MaxSkill : The maximum of skill value - ResourceType : The type of the resource the mobile need to create the item - Amount : The amount of the ResourceType it need to create the item - Message : String or Int for Localized. The message that will be sent to the mobile, if the specified resource is missing. + ObjectType : The type of the object you want to add to the build list. + Group : The group in which the object will be showed in the craft menu. + MinSkill : The minimum of skill value + MaxSkill : The maximum of skill value + ResourceType : The type of the resource the mobile need to create the item + Amount : The amount of the ResourceType it need to create the item + Message : String or Int for Localized. The message that will be sent to the mobile, if the specified resource is missing. Syntax for a COMPLEX craft item. A complex item is an item that need either more than only one skill, or more than only one resource. @@ -166,27 +166,17 @@ namespace Server.Engines.Craft Coming soon.... */ - #region Ringmail - AddCraft(typeof(RingmailGloves), 1011076, 1025099, 12.0, 62.0, typeof(IronIngot), 1044036, 10, 1044037); AddCraft(typeof(RingmailLegs), 1011076, 1025104, 19.4, 69.4, typeof(IronIngot), 1044036, 16, 1044037); AddCraft(typeof(RingmailArms), 1011076, 1025103, 16.9, 66.9, typeof(IronIngot), 1044036, 14, 1044037); AddCraft(typeof(RingmailChest), 1011076, 1025100, 21.9, 71.9, typeof(IronIngot), 1044036, 18, 1044037); - #endregion - - #region Chainmail - AddCraft(typeof(ChainCoif), 1011077, 1025051, 14.5, 64.5, typeof(IronIngot), 1044036, 10, 1044037); AddCraft(typeof(ChainLegs), 1011077, 1025054, 36.7, 86.7, typeof(IronIngot), 1044036, 18, 1044037); AddCraft(typeof(ChainChest), 1011077, 1025055, 39.1, 89.1, typeof(IronIngot), 1044036, 20, 1044037); - #endregion - int index; - #region Platemail - AddCraft(typeof(PlateArms), 1011078, 1025136, 66.3, 116.3, typeof(IronIngot), 1044036, 18, 1044037); AddCraft(typeof(PlateGloves), 1011078, 1025140, 58.9, 108.9, typeof(IronIngot), 1044036, 12, 1044037); AddCraft(typeof(PlateGorget), 1011078, 1025139, 56.4, 106.4, typeof(IronIngot), 1044036, 10, 1044037); @@ -203,7 +193,7 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); index = AddCraft(typeof(PlateDo), 1011078, 1030184, 80.0, 130.0, typeof(IronIngot), 1044036, 28, - 1044037); //Double check skill + 1044037); // Double check skill SetNeededExpansion(index, Expansion.SE); index = AddCraft(typeof(PlateHiroSode), 1011078, 1030187, 80.0, 130.0, typeof(IronIngot), 1044036, 16, @@ -219,10 +209,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Helmets - AddCraft(typeof(Bascinet), 1011079, 1025132, 8.3, 58.3, typeof(IronIngot), 1044036, 15, 1044037); AddCraft(typeof(CloseHelm), 1011079, 1025128, 37.9, 87.9, typeof(IronIngot), 1044036, 15, 1044037); AddCraft(typeof(Helmet), 1011079, 1025130, 37.9, 87.9, typeof(IronIngot), 1044036, 15, 1044037); @@ -281,10 +267,6 @@ namespace Server.Engines.Craft } } - #endregion - - #region Shields - AddCraft(typeof(Buckler), 1011080, 1027027, -25.0, 25.0, typeof(IronIngot), 1044036, 10, 1044037); AddCraft(typeof(BronzeShield), 1011080, 1027026, -15.2, 34.8, typeof(IronIngot), 1044036, 12, 1044037); AddCraft(typeof(HeaterShield), 1011080, 1027030, 24.3, 74.3, typeof(IronIngot), 1044036, 18, 1044037); @@ -298,10 +280,6 @@ namespace Server.Engines.Craft AddCraft(typeof(OrderShield), 1011080, 1027108, 85.0, 135.0, typeof(IronIngot), 1044036, 25, 1044037); } - #endregion - - #region Bladed - if (Core.AOS) AddCraft(typeof(BoneHarvester), 1011081, 1029915, 33.0, 83.0, typeof(IronIngot), 1044036, 10, 1044037); @@ -581,10 +559,6 @@ namespace Server.Engines.Craft } } - #endregion - - #region Axes - AddCraft(typeof(Axe), 1011082, 1023913, 34.2, 84.2, typeof(IronIngot), 1044036, 14, 1044037); AddCraft(typeof(BattleAxe), 1011082, 1023911, 30.5, 80.5, typeof(IronIngot), 1044036, 14, 1044037); AddCraft(typeof(DoubleAxe), 1011082, 1023915, 29.3, 79.3, typeof(IronIngot), 1044036, 12, 1044037); @@ -622,10 +596,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.ML); } - #endregion - - #region Pole Arms - AddCraft(typeof(Bardiche), 1011083, 1023917, 31.7, 81.7, typeof(IronIngot), 1044036, 18, 1044037); if (Core.AOS) @@ -651,11 +621,7 @@ namespace Server.Engines.Craft AddCraft(typeof(WarFork), 1011083, 1025125, 42.9, 92.9, typeof(IronIngot), 1044036, 12, 1044037); // Not craftable (is this an AOS change ??) - //AddCraft( typeof( Pitchfork ), 1011083, 1023720, 36.1, 86.1, typeof( IronIngot ), 1044036, 12, 1044037 ); - - #endregion - - #region Bashing + // AddCraft( typeof( Pitchfork ), 1011083, 1023720, 36.1, 86.1, typeof( IronIngot ), 1044036, 12, 1044037 ); AddCraft(typeof(HammerPick), 1011084, 1025181, 34.2, 84.2, typeof(IronIngot), 1044036, 16, 1044037); AddCraft(typeof(Mace), 1011084, 1023932, 14.5, 64.5, typeof(IronIngot), 1044036, 6, 1044037); @@ -714,10 +680,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.ML); } - #endregion - - #region Dragon Scale Armor - index = AddCraft(typeof(DragonGloves), 1053114, 1029795, 68.9, 118.9, typeof(RedScales), 1060883, 16, 1060884); SetUseSubRes2(index, true); @@ -733,8 +695,6 @@ namespace Server.Engines.Craft index = AddCraft(typeof(DragonChest), 1053114, 1029793, 85.0, 135.0, typeof(RedScales), 1060883, 36, 1060884); SetUseSubRes2(index, true); - #endregion - // Set the overridable material SetSubRes(typeof(IronIngot), 1044022); @@ -768,7 +728,7 @@ namespace Server.Engines.Craft // Delay to synchronize the sound with the hit on the anvil private class InternalTimer : Timer { - private Mobile m_From; + private readonly Mobile m_From; public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from; diff --git a/Projects/Scripts/Engines/Craft/DefBowFletching.cs b/Projects/Scripts/Engines/Craft/DefBowFletching.cs index 1af14ebf7..aef47c32c 100644 --- a/Projects/Scripts/Engines/Craft/DefBowFletching.cs +++ b/Projects/Scripts/Engines/Craft/DefBowFletching.cs @@ -34,8 +34,8 @@ namespace Server.Engines.Craft public override void PlayCraftEffect(Mobile from) { // no animation - //if ( from.Body.Type == BodyType.Human && !from.Mounted ) - // from.Animate( 33, 5, 1, true, false, 0 ); + // if (from.Body.Type == BodyType.Human && !from.Mounted) + // from.Animate( 33, 5, 1, true, false, 0 ); from.PlaySound(0x55); } diff --git a/Projects/Scripts/Engines/Craft/DefCarpentry.cs b/Projects/Scripts/Engines/Craft/DefCarpentry.cs index 4e965a2f0..8a898d1ee 100644 --- a/Projects/Scripts/Engines/Craft/DefCarpentry.cs +++ b/Projects/Scripts/Engines/Craft/DefCarpentry.cs @@ -32,8 +32,8 @@ namespace Server.Engines.Craft public override void PlayCraftEffect(Mobile from) { // no animation - //if ( from.Body.Type == BodyType.Human && !from.Mounted ) - // from.Animate( 9, 5, 1, true, false, 0 ); + // if (from.Body.Type == BodyType.Human && !from.Mounted) + // from.Animate( 9, 5, 1, true, false, 0 ); from.PlaySound(0x23D); } @@ -99,10 +99,10 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - if (Core.AOS) //Duplicate Entries to preserve ordering depending on era + if (Core.AOS) // Duplicate Entries to preserve ordering depending on era { index = AddCraft(typeof(FishingPole), 1044294, 1023519, 68.4, 93.4, typeof(Log), 1044041, 5, - 1044351); //This is in the categor of Other during AoS + 1044351); // This is in the categor of Other during AoS AddSkill(index, SkillName.Tailoring, 40.0, 45.0); AddRes(index, typeof(Cloth), 1044286, 5, 1044287); } @@ -288,10 +288,10 @@ namespace Server.Engines.Craft AddCraft(typeof(WoodenShield), Core.ML ? 1062760 : 1044295, 1027034, 52.6, 77.6, typeof(Log), 1044041, 9, 1044351); - if (!Core.AOS) //Duplicate Entries to preserve ordering depending on era + if (!Core.AOS) // Duplicate Entries to preserve ordering depending on era { index = AddCraft(typeof(FishingPole), Core.ML ? 1044294 : 1044295, 1023519, 68.4, 93.4, typeof(Log), 1044041, - 5, 1044351); //This is in the categor of Other during AoS + 5, 1044351); // This is in the categor of Other during AoS AddSkill(index, SkillName.Tailoring, 40.0, 45.0); AddRes(index, typeof(Cloth), 1044286, 5, 1044287); } diff --git a/Projects/Scripts/Engines/Craft/DefGlassblowing.cs b/Projects/Scripts/Engines/Craft/DefGlassblowing.cs index 4daf3d40f..9b901e456 100644 --- a/Projects/Scripts/Engines/Craft/DefGlassblowing.cs +++ b/Projects/Scripts/Engines/Craft/DefGlassblowing.cs @@ -40,10 +40,10 @@ namespace Server.Engines.Craft { from.PlaySound(0x2B); // bellows - //if ( from.Body.Type == BodyType.Human && !from.Mounted ) - // from.Animate( 9, 5, 1, true, false, 0 ); + // if (from.Body.Type == BodyType.Human && !from.Mounted) + // from.Animate( 9, 5, 1, true, false, 0 ); - //new InternalTimer( from ).Start(); + // new InternalTimer( from ).Start(); } public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, @@ -97,7 +97,7 @@ namespace Server.Engines.Craft // Delay to synchronize the sound with the hit on the anvil private class InternalTimer : Timer { - private Mobile m_From; + private readonly Mobile m_From; public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from; diff --git a/Projects/Scripts/Engines/Craft/DefInscription.cs b/Projects/Scripts/Engines/Craft/DefInscription.cs index 5f469d368..73d3039ff 100644 --- a/Projects/Scripts/Engines/Craft/DefInscription.cs +++ b/Projects/Scripts/Engines/Craft/DefInscription.cs @@ -10,13 +10,13 @@ namespace Server.Engines.Craft { private static CraftSystem m_CraftSystem; - private static Type typeofSpellScroll = typeof(SpellScroll); + private static readonly Type typeofSpellScroll = typeof(SpellScroll); private int m_Circle, m_Mana; private int m_Index; - private Type[] m_RegTypes = + private readonly Type[] m_RegTypes = { typeof(BlackPearl), typeof(Bloodmoss), @@ -78,7 +78,7 @@ namespace Server.Engines.Craft if (toolBroken) from.SendLocalizedMessage(1044038); // You have worn out your tool - if (!typeofSpellScroll.IsAssignableFrom(item.ItemType)) // not a scroll + if (!typeofSpellScroll.IsAssignableFrom(item.ItemType)) // not a scroll { if (failed) { @@ -156,7 +156,7 @@ namespace Server.Engines.Craft { int index = AddCraft(type, 1061677, 1060509 + spell, minSkill, minSkill + 1.0, regs[0], CraftItem.LabelNumber(regs[0]), 1, - 501627); //Yes, on OSI it's only 1.0 skill diff'. Don't blame me, blame OSI. + 501627); // Yes, on OSI it's only 1.0 skill diff'. Don't blame me, blame OSI. for (int i = 1; i < regs.Length; ++i) AddRes(index, regs[i], CraftItem.LabelNumber(regs[0]), 1, 501627); @@ -331,7 +331,7 @@ namespace Server.Engines.Craft if (Core.SE) AddCraft(typeof(Spellbook), 1044294, 1023834, 50.0, 126, typeof(BlankScroll), 1044377, 10, 1044378); /* TODO - if ( Core.ML ) + if (Core.ML) { index = AddCraft( typeof( ScrappersCompendium ), 1044294, 1072940, 75.0, 125.0, typeof( BlankScroll ), 1044377, 100, 1044378 ); AddRes( index, typeof( DreadHornMane ), 1032682, 1, 1044253 ); diff --git a/Projects/Scripts/Engines/Craft/DefMasonry.cs b/Projects/Scripts/Engines/Craft/DefMasonry.cs index 66b193e29..3c8ad51ad 100644 --- a/Projects/Scripts/Engines/Craft/DefMasonry.cs +++ b/Projects/Scripts/Engines/Craft/DefMasonry.cs @@ -39,9 +39,9 @@ namespace Server.Engines.Craft public override void PlayCraftEffect(Mobile from) { // no effects - //if ( from.Body.Type == BodyType.Human && !from.Mounted ) - // from.Animate( 9, 5, 1, true, false, 0 ); - //new InternalTimer( from ).Start(); + // if (from.Body.Type == BodyType.Human && !from.Mounted) + // from.Animate( 9, 5, 1, true, false, 0 ); + // new InternalTimer( from ).Start(); } public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, @@ -111,7 +111,7 @@ namespace Server.Engines.Craft // Delay to synchronize the sound with the hit on the anvil private class InternalTimer : Timer { - private Mobile m_From; + private readonly Mobile m_From; public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(0.7)) => m_From = from; diff --git a/Projects/Scripts/Engines/Craft/DefTailoring.cs b/Projects/Scripts/Engines/Craft/DefTailoring.cs index cc4185fb8..96c179143 100644 --- a/Projects/Scripts/Engines/Craft/DefTailoring.cs +++ b/Projects/Scripts/Engines/Craft/DefTailoring.cs @@ -7,7 +7,7 @@ namespace Server.Engines.Craft { private static CraftSystem m_CraftSystem; - private static Type[] m_TailorColorables = + private static readonly Type[] m_TailorColorables = { typeof(GozaMatEastDeed), typeof(GozaMatSouthDeed), typeof(SquareGozaMatEastDeed), typeof(SquareGozaMatSouthDeed), @@ -85,8 +85,6 @@ namespace Server.Engines.Craft { int index; - #region Hats - AddCraft(typeof(SkullCap), 1011375, 1025444, 0.0, 25.0, typeof(Cloth), 1044286, 2, 1044287); AddCraft(typeof(Bandana), 1011375, 1025440, 0.0, 25.0, typeof(Cloth), 1044286, 2, 1044287); AddCraft(typeof(FloppyHat), 1011375, 1025907, 6.2, 31.2, typeof(Cloth), 1044286, 11, 1044287); @@ -112,10 +110,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Shirts - AddCraft(typeof(Doublet), 1015269, 1028059, 0, 25.0, typeof(Cloth), 1044286, 8, 1044287); AddCraft(typeof(Shirt), 1015269, 1025399, 20.7, 45.7, typeof(Cloth), 1044286, 8, 1044287); AddCraft(typeof(FancyShirt), 1015269, 1027933, 24.8, 49.8, typeof(Cloth), 1044286, 8, 1044287); @@ -151,10 +145,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Pants - AddCraft(typeof(ShortPants), 1015279, 1025422, 24.8, 49.8, typeof(Cloth), 1044286, 6, 1044287); AddCraft(typeof(LongPants), 1015279, 1025433, 24.8, 49.8, typeof(Cloth), 1044286, 8, 1044287); AddCraft(typeof(Kilt), 1015279, 1025431, 20.7, 45.7, typeof(Cloth), 1044286, 8, 1044287); @@ -171,10 +161,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Misc - AddCraft(typeof(BodySash), 1015283, 1025441, 4.1, 29.1, typeof(Cloth), 1044286, 4, 1044287); AddCraft(typeof(HalfApron), 1015283, 1025435, 20.7, 45.7, typeof(Cloth), 1044286, 6, 1044287); AddCraft(typeof(FullApron), 1015283, 1025437, 29.0, 54.0, typeof(Cloth), 1044286, 10, 1044287); @@ -243,10 +229,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Footwear - if (Core.AOS) AddCraft(typeof(FurBoots), 1015288, 1028967, 50.0, 75.0, typeof(Cloth), 1044286, 12, 1044287); @@ -263,10 +245,6 @@ namespace Server.Engines.Craft AddCraft(typeof(Boots), 1015288, 1025899, 33.1, 58.1, typeof(Leather), 1044462, 8, 1044463); AddCraft(typeof(ThighBoots), 1015288, 1025906, 41.4, 66.4, typeof(Leather), 1044462, 10, 1044463); - #endregion - - #region Leather Armor - if (Core.ML) { index = AddCraft(typeof(SpellWovenBritches), 1015293, 1072929, 92.5, 117.5, typeof(Leather), 1044462, 15, @@ -338,10 +316,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Studded Armor - AddCraft(typeof(StuddedGorget), 1015300, 1025078, 78.8, 103.8, typeof(Leather), 1044462, 6, 1044463); AddCraft(typeof(StuddedGloves), 1015300, 1025077, 82.9, 107.9, typeof(Leather), 1044462, 8, 1044463); AddCraft(typeof(StuddedArms), 1015300, 1025076, 87.1, 112.1, typeof(Leather), 1044462, 10, 1044463); @@ -365,10 +339,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Female Armor - AddCraft(typeof(LeatherShorts), 1015306, 1027168, 62.2, 87.2, typeof(Leather), 1044462, 8, 1044463); AddCraft(typeof(LeatherSkirt), 1015306, 1027176, 58.0, 83.0, typeof(Leather), 1044462, 6, 1044463); AddCraft(typeof(LeatherBustierArms), 1015306, 1027178, 58.0, 83.0, typeof(Leather), 1044462, 6, 1044463); @@ -376,10 +346,6 @@ namespace Server.Engines.Craft AddCraft(typeof(FemaleLeatherChest), 1015306, 1027174, 62.2, 87.2, typeof(Leather), 1044462, 8, 1044463); AddCraft(typeof(FemaleStuddedChest), 1015306, 1027170, 87.1, 112.1, typeof(Leather), 1044462, 10, 1044463); - #endregion - - #region Bone Armor - index = AddCraft(typeof(BoneHelm), 1049149, 1025206, 85.0, 110.0, typeof(Leather), 1044462, 4, 1044463); AddRes(index, typeof(Bone), 1049064, 2, 1049063); @@ -398,8 +364,6 @@ namespace Server.Engines.Craft index = AddCraft(typeof(OrcHelm), 1049149, 1027947, 90.0, 115.0, typeof(Leather), 1044462, 6, 1044463); AddRes(index, typeof(Bone), 1049064, 4, 1049063); - #endregion - // Set the overridable material SetSubRes(typeof(Leather), 1049150); diff --git a/Projects/Scripts/Engines/Craft/DefTinkering.cs b/Projects/Scripts/Engines/Craft/DefTinkering.cs index e2cd7f346..4d287b744 100644 --- a/Projects/Scripts/Engines/Craft/DefTinkering.cs +++ b/Projects/Scripts/Engines/Craft/DefTinkering.cs @@ -9,7 +9,7 @@ namespace Server.Engines.Craft { private static CraftSystem m_CraftSystem; - private static Type[] m_TinkerColorables = + private static readonly Type[] m_TinkerColorables = { typeof(ForkLeft), typeof(ForkRight), typeof(SpoonLeft), typeof(SpoonRight), @@ -73,7 +73,7 @@ namespace Server.Engines.Craft public override void PlayCraftEffect(Mobile from) { // no sound - //from.PlaySound( 0x241 ); + // from.PlaySound( 0x241 ); } public override int PlayEndingEffect(Mobile from, bool failed, bool lostMaterial, bool toolBroken, int quality, @@ -139,8 +139,6 @@ namespace Server.Engines.Craft { int index; - #region Wooden Items - AddCraft(typeof(JointingPlane), 1044042, 1024144, 0.0, 50.0, typeof(Log), 1044041, 4, 1044351); AddCraft(typeof(MouldingPlane), 1044042, 1024140, 0.0, 50.0, typeof(Log), 1044041, 4, 1044351); AddCraft(typeof(SmoothingPlane), 1044042, 1024146, 0.0, 50.0, typeof(Log), 1044041, 4, 1044351); @@ -155,10 +153,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Tools - AddCraft(typeof(Scissors), 1044046, 1023998, 5.0, 55.0, typeof(IronIngot), 1044036, 2, 1044037); AddCraft(typeof(MortarPestle), 1044046, 1023739, 20.0, 70.0, typeof(IronIngot), 1044036, 3, 1044037); AddCraft(typeof(Scorp), 1044046, 1024327, 30.0, 80.0, typeof(IronIngot), 1044036, 2, 1044037); @@ -183,10 +177,6 @@ namespace Server.Engines.Craft AddCraft(typeof(MapmakersPen), 1044046, 1044167, 25.0, 75.0, typeof(IronIngot), 1044036, 1, 1044037); AddCraft(typeof(ScribesPen), 1044046, 1044168, 25.0, 75.0, typeof(IronIngot), 1044036, 1, 1044037); - #endregion - - #region Parts - AddCraft(typeof(Gears), 1044047, 1024179, 5.0, 55.0, typeof(IronIngot), 1044036, 2, 1044037); AddCraft(typeof(ClockParts), 1044047, 1024175, 25.0, 75.0, typeof(IronIngot), 1044036, 1, 1044037); AddCraft(typeof(BarrelTap), 1044047, 1024100, 35.0, 85.0, typeof(IronIngot), 1044036, 2, 1044037); @@ -205,10 +195,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.ML); } - #endregion - - #region Utensils - AddCraft(typeof(ButcherKnife), 1044048, 1025110, 25.0, 75.0, typeof(IronIngot), 1044036, 2, 1044037); AddCraft(typeof(SpoonLeft), 1044048, 1044158, 0.0, 50.0, typeof(IronIngot), 1044036, 1, 1044037); AddCraft(typeof(SpoonRight), 1044048, 1044159, 0.0, 50.0, typeof(IronIngot), 1044036, 1, 1044037); @@ -222,10 +208,6 @@ namespace Server.Engines.Craft AddCraft(typeof(PewterMug), 1044048, 1024097, 10.0, 60.0, typeof(IronIngot), 1044036, 2, 1044037); AddCraft(typeof(SkinningKnife), 1044048, 1023781, 25.0, 75.0, typeof(IronIngot), 1044036, 2, 1044037); - #endregion - - #region Misc - AddCraft(typeof(KeyRing), 1044050, 1024113, 10.0, 60.0, typeof(IronIngot), 1044036, 2, 1044037); AddCraft(typeof(Candelabra), 1044050, 1022599, 55.0, 105.0, typeof(IronIngot), 1044036, 4, 1044037); AddCraft(typeof(Scales), 1044050, 1026225, 60.0, 110.0, typeof(IronIngot), 1044036, 4, 1044037); @@ -260,10 +242,6 @@ namespace Server.Engines.Craft SetNeededExpansion(index, Expansion.SE); } - #endregion - - #region Jewelry - AddJewelrySet(GemType.StarSapphire, typeof(StarSapphire)); AddJewelrySet(GemType.Emerald, typeof(Emerald)); AddJewelrySet(GemType.Sapphire, typeof(Sapphire)); @@ -274,10 +252,6 @@ namespace Server.Engines.Craft AddJewelrySet(GemType.Amber, typeof(Amber)); AddJewelrySet(GemType.Diamond, typeof(Diamond)); - #endregion - - #region Multi-Component Items - index = AddCraft(typeof(AxleGears), 1044051, 1024177, 0.0, 0.0, typeof(Axle), 1044169, 1, 1044253); AddRes(index, typeof(Gears), 1044254, 1, 1044253); @@ -303,10 +277,6 @@ namespace Server.Engines.Craft AddRes(index, typeof(BarrelLid), 1044251, 1, 1044253); AddRes(index, typeof(BarrelTap), 1044252, 1, 1044253); - #endregion - - #region Traps - // Dart Trap index = AddCraft(typeof(DartTrapCraft), 1044052, 1024396, 30.0, 80.0, typeof(IronIngot), 1044036, 1, 1044037); AddRes(index, typeof(Bolt), 1044570, 1, 1044253); @@ -349,8 +319,6 @@ namespace Server.Engines.Craft 1044253); AddRes(index, typeof(IronIngot), 1044036, 10, 1044037); - #endregion - // Magic Jewelry if (Core.ML) { @@ -410,9 +378,9 @@ namespace Server.Engines.Craft { } - public LockableContainer Container{ get; private set; } + public LockableContainer Container { get; private set; } - public abstract TrapType TrapType{ get; } + public abstract TrapType TrapType { get; } private int Verify(LockableContainer container) { @@ -471,7 +439,7 @@ namespace Server.Engines.Craft private class ContainerTarget : Target { - private TrapCraft m_TrapCraft; + private readonly TrapCraft m_TrapCraft; public ContainerTarget(TrapCraft trapCraft) : base(-1, false, TargetFlags.None) => m_TrapCraft = trapCraft; diff --git a/Projects/Scripts/Engines/Doom/GauntletSpawner.cs b/Projects/Scripts/Engines/Doom/GauntletSpawner.cs index 2067e2df8..57329601e 100644 --- a/Projects/Scripts/Engines/Doom/GauntletSpawner.cs +++ b/Projects/Scripts/Engines/Doom/GauntletSpawner.cs @@ -42,16 +42,16 @@ namespace Server.Engines.Doom } [CommandProperty(AccessLevel.GameMaster)] - public string TypeName{ get; set; } + public string TypeName { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public BaseDoor Door{ get; set; } + public BaseDoor Door { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public BaseAddon Addon{ get; set; } + public BaseAddon Addon { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public GauntletSpawner Sequence{ get; set; } + public GauntletSpawner Sequence { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool HasCompleted @@ -74,7 +74,7 @@ namespace Server.Engines.Doom } [CommandProperty(AccessLevel.GameMaster)] - public Rectangle2D RegionBounds{ get; set; } + public Rectangle2D RegionBounds { get; set; } [CommandProperty(AccessLevel.GameMaster)] public GauntletSpawnerState State @@ -145,11 +145,11 @@ namespace Server.Engines.Doom } } - public List Creatures{ get; set; } + public List Creatures { get; set; } - public List Traps{ get; set; } + public List Traps { get; set; } - public Region Region{ get; set; } + public Region Region { get; set; } public override string DefaultName => "doom spawner"; @@ -199,13 +199,13 @@ namespace Server.Engines.Doom int random = Utility.Random(100); - if (22 > random) + if (random < 22) trap = new SawTrap(Utility.RandomBool() ? SawTrapType.WestFloor : SawTrapType.NorthFloor); - else if (44 > random) + else if (random < 44) trap = new SpikeTrap(Utility.RandomBool() ? SpikeTrapType.WestFloor : SpikeTrapType.NorthFloor); - else if (66 > random) + else if (random < 66) trap = new GasTrap(Utility.RandomBool() ? GasTrapType.NorthWall : GasTrapType.WestWall); - else if (88 > random) + else if (random < 88) trap = new FireColumnTrap(); else trap = new MushroomTrap(); @@ -382,31 +382,31 @@ namespace Server.Engines.Doom switch (version) { case 1: - { - RegionBounds = reader.ReadRect2D(); - Traps = reader.ReadStrongItemList(); - - goto case 0; - } - case 0: - { - if (version < 1) { - Traps = new List(); - RegionBounds = new Rectangle2D(X - 40, Y - 40, 80, 80); + RegionBounds = reader.ReadRect2D(); + Traps = reader.ReadStrongItemList(); + + goto case 0; } + case 0: + { + if (version < 1) + { + Traps = new List(); + RegionBounds = new Rectangle2D(X - 40, Y - 40, 80, 80); + } - Creatures = reader.ReadStrongMobileList(); + Creatures = reader.ReadStrongMobileList(); - TypeName = reader.ReadString(); - Door = reader.ReadItem(); - Addon = reader.ReadItem(); - Sequence = reader.ReadItem(); + TypeName = reader.ReadString(); + Door = reader.ReadItem(); + Addon = reader.ReadItem(); + Sequence = reader.ReadItem(); - State = (GauntletSpawnerState)reader.ReadInt(); + State = (GauntletSpawnerState)reader.ReadInt(); - break; - } + break; + } } } @@ -557,13 +557,13 @@ namespace Server.Engines.Doom CreateVarietyDealer(492, 369); for (int x = 434; x <= 478; ++x) - for (int y = 371; y <= 372; ++y) - { - Static item = new Static(0x524); + for (int y = 371; y <= 372; ++y) + { + Static item = new Static(0x524); - item.Hue = 1; - item.MoveToWorld(new Point3D(x, y, -1), Map.Malas); - } + item.Hue = 1; + item.MoveToWorld(new Point3D(x, y, -1), Map.Malas); + } /* End supply room */ /* Begin gauntlet cycle */ @@ -614,7 +614,6 @@ namespace Server.Engines.Doom } } - public class GauntletRegion : BaseRegion { private GauntletSpawner m_Spawner; diff --git a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs index f2b46c005..0cce376ae 100644 --- a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs +++ b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleController.cs @@ -5,11 +5,6 @@ using Server.Mobiles; using Server.Network; using Server.Spells; -/* - this is From me to you, Under no terms, Conditions... K? to apply you - just simply Unpatch/delete, Stick these in, Same location.. Restart - */ - namespace Server.Engines.Doom { public class LeverPuzzleController : Item @@ -96,12 +91,12 @@ namespace Server.Engines.Doom /* SOUNDS */ - private static int[] fs = { 0x144, 0x154 }; - private static int[] ms = { 0x144, 0x14B }; - private static int[] fs2 = { 0x13F, 0x154 }; - private static int[] ms2 = { 0x13F, 0x14B }; - private static int[] cs1 = { 0x244 }; - private static int[] exp = { 0x307 }; + private static readonly int[] fs = { 0x144, 0x154 }; + private static readonly int[] ms = { 0x144, 0x14B }; + private static readonly int[] fs2 = { 0x13F, 0x154 }; + private static readonly int[] ms2 = { 0x13F, 0x14B }; + private static readonly int[] cs1 = { 0x244 }; + private static readonly int[] exp = { 0x307 }; private Timer l_Timer; private LampRoomBox m_Box; private Region m_LampRoom; @@ -151,15 +146,15 @@ namespace Server.Engines.Doom } [CommandProperty(AccessLevel.GameMaster)] - public ushort MyKey{ get; set; } + public ushort MyKey { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public ushort TheirKey{ get; set; } + public ushort TheirKey { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool Enabled{ get; set; } + public bool Enabled { get; set; } - public Mobile Successful{ get; private set; } + public Mobile Successful { get; private set; } public bool CircleComplete { @@ -196,12 +191,12 @@ namespace Server.Engines.Doom e.Mobile.SendMessage("Lamp room puzzle successfully generated."); } - public static Item AddLeverPuzzlePart(int[] Loc, Item newitem) + public static Item AddLeverPuzzlePart(int[] loc, Item newitem) { if (newitem?.Deleted != false) installed = false; else - newitem.MoveToWorld(new Point3D(Loc[0], Loc[1], Loc[2]), Map.Malas); + newitem.MoveToWorld(new Point3D(loc[0], loc[1], loc[2]), Map.Malas); return newitem; } @@ -369,8 +364,8 @@ namespace Server.Engines.Doom private static bool IsValidDamagable(Mobile m) => m?.Deleted == false && - (m.Player && m.Alive || - m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet); + ((m.Player && m.Alive) || + (m is BaseCreature bc && (bc.Controlled || bc.Summoned) && !bc.IsDeadBondedPet)); public static void MoveMobileOut(Mobile m) { @@ -387,7 +382,7 @@ namespace Server.Engines.Doom public static bool AniSafe(Mobile m) => m?.BodyMod == 0 && m.Alive && !TransformationSpellHelper.UnderTransformation(m); - public static IEntity ZAdjustedIEFromMobile(Mobile m, int ZDelta) => new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + ZDelta), m.Map); + public static IEntity ZAdjustedIEFromMobile(Mobile m, int zDelta) => new Entity(Serial.Zero, new Point3D(m.X, m.Y, m.Z + zDelta), m.Map); public static void DoDamage(Mobile m, int min, int max, bool poison) { @@ -475,14 +470,14 @@ namespace Server.Engines.Doom { private int Count; private LeverPuzzleController m_Controller; - private Mobile m_Player; + private readonly Mobile m_Player; - public RockTimer(Mobile player, LeverPuzzleController Controller) + public RockTimer(Mobile player, LeverPuzzleController controller) : base(TimeSpan.Zero, TimeSpan.FromSeconds(.25)) { Count = 0; m_Player = player; - m_Controller = Controller; + m_Controller = controller; } private int Rock() => 0x1363 + Utility.Random(0, 11); @@ -547,7 +542,7 @@ namespace Server.Engines.Doom public class LampRoomKickTimer : Timer { - private Mobile m; + private readonly Mobile m; public LampRoomKickTimer(Mobile player) : base(TimeSpan.FromSeconds(.25)) => diff --git a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs index 2b7275d81..05417dbae 100644 --- a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs +++ b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleItems.cs @@ -116,7 +116,7 @@ namespace Server.Engines.Doom } [CommandProperty(AccessLevel.GameMaster)] - public ushort Code{ get; private set; } + public ushort Code { get; private set; } public override void OnDoubleClick(Mobile m) { diff --git a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs index 8a2b2d862..2c8594027 100644 --- a/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs +++ b/Projects/Scripts/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Doom { public class LampRoomRegion : BaseRegion { - private LeverPuzzleController m_Controller; + private readonly LeverPuzzleController m_Controller; public LampRoomRegion(LeverPuzzleController controller) : base(null, Map.Malas, Find(LeverPuzzleController.lr_Enter, Map.Malas), LeverPuzzleController.lr_Rect) @@ -43,7 +43,7 @@ namespace Server.Engines.Doom { if (m == m_Controller.Successful) return; } - else if (m is BaseCreature bc && (bc.Controlled && bc.ControlMaster == m_Controller.Successful || + else if (m is BaseCreature bc && ((bc.Controlled && bc.ControlMaster == m_Controller.Successful) || bc.Summoned)) { return; diff --git a/Projects/Scripts/Engines/Ethics/Core/Ethic.cs b/Projects/Scripts/Engines/Ethics/Core/Ethic.cs index 80015335e..b75c9658c 100644 --- a/Projects/Scripts/Engines/Ethics/Core/Ethic.cs +++ b/Projects/Scripts/Engines/Ethics/Core/Ethic.cs @@ -193,19 +193,19 @@ namespace Server.Ethics switch (version) { case 0: - { - int playerCount = reader.ReadEncodedInt(); - - for (int i = 0; i < playerCount; ++i) { - Player pl = new Player(this, reader); + int playerCount = reader.ReadEncodedInt(); - if (pl.Mobile != null) - Timer.DelayCall(TimeSpan.Zero, pl.CheckAttach); + for (int i = 0; i < playerCount; ++i) + { + Player pl = new Player(this, reader); + + if (pl.Mobile != null) + Timer.DelayCall(TimeSpan.Zero, pl.CheckAttach); + } + + break; } - - break; - } } } diff --git a/Projects/Scripts/Engines/Ethics/Core/Persistance.cs b/Projects/Scripts/Engines/Ethics/Core/Persistance.cs index 5f5d5c410..0bfd67ad9 100644 --- a/Projects/Scripts/Engines/Ethics/Core/Persistance.cs +++ b/Projects/Scripts/Engines/Ethics/Core/Persistance.cs @@ -18,7 +18,7 @@ namespace Server.Ethics : base(serial) => Instance = this; - public static EthicsPersistance Instance{ get; private set; } + public static EthicsPersistance Instance { get; private set; } public override string DefaultName => "Ethics Persistance - Internal"; @@ -41,12 +41,12 @@ namespace Server.Ethics switch (version) { case 0: - { - for (int i = 0; i < Ethic.Ethics.Length; ++i) - Ethic.Ethics[i].Deserialize(reader); + { + for (int i = 0; i < Ethic.Ethics.Length; ++i) + Ethic.Ethics[i].Deserialize(reader); - break; - } + break; + } } } diff --git a/Projects/Scripts/Engines/Ethics/Core/Player.cs b/Projects/Scripts/Engines/Ethics/Core/Player.cs index 1cb04b557..cb1a44980 100644 --- a/Projects/Scripts/Engines/Ethics/Core/Player.cs +++ b/Projects/Scripts/Engines/Ethics/Core/Player.cs @@ -31,37 +31,37 @@ namespace Server.Ethics switch (version) { case 0: - { - Mobile = reader.ReadMobile(); + { + Mobile = reader.ReadMobile(); - Power = reader.ReadEncodedInt(); - History = reader.ReadEncodedInt(); + Power = reader.ReadEncodedInt(); + History = reader.ReadEncodedInt(); - Steed = reader.ReadMobile(); - Familiar = reader.ReadMobile(); + Steed = reader.ReadMobile(); + Familiar = reader.ReadMobile(); - m_Shield = reader.ReadDeltaTime(); + m_Shield = reader.ReadDeltaTime(); - break; - } + break; + } } } - public Ethic Ethic{ get; } + public Ethic Ethic { get; } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public int Power{ get; set; } + public int Power { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public int History{ get; set; } + public int History { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public Mobile Steed{ get; set; } + public Mobile Steed { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public Mobile Familiar{ get; set; } + public Mobile Familiar { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsShielded diff --git a/Projects/Scripts/Engines/Ethics/Definitions/EthicDefinition.cs b/Projects/Scripts/Engines/Ethics/Definitions/EthicDefinition.cs index cbcaf9cb3..980c3e5a6 100644 --- a/Projects/Scripts/Engines/Ethics/Definitions/EthicDefinition.cs +++ b/Projects/Scripts/Engines/Ethics/Definitions/EthicDefinition.cs @@ -15,14 +15,14 @@ namespace Server.Ethics Powers = powers; } - public int PrimaryHue{ get; } + public int PrimaryHue { get; } - public TextDefinition Title{ get; } + public TextDefinition Title { get; } - public TextDefinition Adjunct{ get; } + public TextDefinition Adjunct { get; } - public TextDefinition JoinPhrase{ get; } + public TextDefinition JoinPhrase { get; } - public Power[] Powers{ get; } + public Power[] Powers { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Ethics/Definitions/PowerDefinition.cs b/Projects/Scripts/Engines/Ethics/Definitions/PowerDefinition.cs index 2c5d5c972..714966ea1 100644 --- a/Projects/Scripts/Engines/Ethics/Definitions/PowerDefinition.cs +++ b/Projects/Scripts/Engines/Ethics/Definitions/PowerDefinition.cs @@ -11,12 +11,12 @@ namespace Server.Ethics Description = description; } - public int Power{ get; } + public int Power { get; } - public TextDefinition Name{ get; } + public TextDefinition Name { get; } - public TextDefinition Phrase{ get; } + public TextDefinition Phrase { get; } - public TextDefinition Description{ get; } + public TextDefinition Description { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Ethics/Evil/Ethic.cs b/Projects/Scripts/Engines/Ethics/Evil/Ethic.cs index 6aa035c76..d0d53f6e3 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Ethic.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Ethic.cs @@ -20,8 +20,7 @@ namespace Server.Ethics.Evil new UnholyShield(), new UnholySteed(), new UnholyWord() - } - ); + }); } public override bool IsEligible(Mobile mob) diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/Blight.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/Blight.cs index 59a4216e4..6dd061d3d 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/Blight.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/Blight.cs @@ -12,8 +12,7 @@ namespace Server.Ethics.Evil 15, "Blight", "Velgo Ontawl", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs index 5f854207a..32a5c3fd1 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/SummonFamiliar.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Evil 5, "Summon Familiar", "Trubechs Vingir", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyItem.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyItem.cs index 15cf89cb6..28e65068f 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyItem.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyItem.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Evil 5, "Unholy Item", "Vidda K'balc", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySense.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySense.cs index faf336aad..433b0961d 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySense.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySense.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Evil 0, "Unholy Sense", "Drewrok Velgo", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyShield.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyShield.cs index b4e75c93f..8cabacc31 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyShield.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyShield.cs @@ -9,8 +9,7 @@ namespace Server.Ethics.Evil 20, "Unholy Shield", "Velgo K'blac", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs index bfe591b1f..471eda197 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholySteed.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Evil 30, "Unholy Steed", "Trubechs Yeliab", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyWord.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyWord.cs index 3c5a4e54c..1891e33ab 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyWord.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/UnholyWord.cs @@ -7,8 +7,7 @@ namespace Server.Ethics.Evil 100, "Unholy Word", "Velgo Oostrac", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Evil/Powers/VileBlade.cs b/Projects/Scripts/Engines/Ethics/Evil/Powers/VileBlade.cs index f713df11e..bdb4caea1 100644 --- a/Projects/Scripts/Engines/Ethics/Evil/Powers/VileBlade.cs +++ b/Projects/Scripts/Engines/Ethics/Evil/Powers/VileBlade.cs @@ -7,8 +7,7 @@ namespace Server.Ethics.Evil 10, "Vile Blade", "Velgo Reyam", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Ethic.cs b/Projects/Scripts/Engines/Ethics/Hero/Ethic.cs index 3c180cb06..6dd4e530d 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Ethic.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Ethic.cs @@ -20,8 +20,7 @@ namespace Server.Ethics.Hero new HolyShield(), new HolySteed(), new HolyWord() - } - ); + }); } public override bool IsEligible(Mobile mob) diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/Bless.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/Bless.cs index f6ecfc8a6..73a1c0b66 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/Bless.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/Bless.cs @@ -12,8 +12,7 @@ namespace Server.Ethics.Hero 15, "Bless", "Erstok Ontawl", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyBlade.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyBlade.cs index b39f2a039..4035c3e36 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyBlade.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyBlade.cs @@ -7,8 +7,7 @@ namespace Server.Ethics.Hero 10, "Holy Blade", "Erstok Reyam", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyItem.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyItem.cs index 06eeeac62..daa340842 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyItem.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyItem.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Hero 5, "Holy Item", "Vidda K'balc", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySense.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySense.cs index dff3df97c..bb7ef8999 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySense.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySense.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Hero 0, "Holy Sense", "Drewrok Erstok", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyShield.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyShield.cs index 5345f244d..9b5b46a37 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyShield.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyShield.cs @@ -9,8 +9,7 @@ namespace Server.Ethics.Hero 20, "Holy Shield", "Erstok K'blac", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs index 4df96f3bb..05d1bdfab 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolySteed.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Hero 30, "Holy Steed", "Trubechs Yeliab", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyWord.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyWord.cs index 708c47826..03e658cae 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyWord.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/HolyWord.cs @@ -7,8 +7,7 @@ namespace Server.Ethics.Hero 100, "Holy Word", "Erstok Oostrac", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs b/Projects/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs index 3315eb455..c68b421a8 100644 --- a/Projects/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs +++ b/Projects/Scripts/Engines/Ethics/Hero/Powers/SummonFamiliar.cs @@ -11,8 +11,7 @@ namespace Server.Ethics.Hero 5, "Summon Familiar", "Trubechs Vingir", - "" - ); + ""); public override void BeginInvoke(Player from) { diff --git a/Projects/Scripts/Engines/Events/BroadcastEvent.cs b/Projects/Scripts/Engines/Events/BroadcastEvent.cs index e1348c69e..fd703e648 100644 --- a/Projects/Scripts/Engines/Events/BroadcastEvent.cs +++ b/Projects/Scripts/Engines/Events/BroadcastEvent.cs @@ -1,36 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Server.Engines.Events -{ - public class BroadcastEvent : IEvent - { - private int _hue = 0; - private string _text = ""; - public static void Initialize() - { - /* - EventScheduler.Instance.ScheduleEvent(new BroadcastEvent(22, "Test Message Please Ignore 2min"), 0, 0, TimeSpan.FromMinutes(2.0)); - EventScheduler.Instance.ScheduleEvent(new BroadcastEvent(33, "Test Message Please Ignore 3min"), 0, 0, TimeSpan.FromMinutes(3.0)); - EventScheduler.Instance.ScheduleEvent(new BroadcastEvent(44, "Test Message Please Ignore 4min"), 0, 0, TimeSpan.FromMinutes(4.0)); - */ - } - - public BroadcastEvent(int hue, string text) - { - _hue = hue; - _text = text; - } - - public override string ToString() - { - return $"Broadcast: {_text}"; - } - - public void OnEventScheduled() - { - World.Broadcast(_hue, true, _text); - } - } -} +namespace Server.Engines.Events +{ + public class BroadcastEvent : IEvent + { + private readonly int _hue = 0; + private readonly string _text = ""; + public static void Initialize() + { + /* + EventScheduler.Instance.ScheduleEvent(new BroadcastEvent(22, "Test Message Please Ignore 2min"), 0, 0, TimeSpan.FromMinutes(2.0)); + EventScheduler.Instance.ScheduleEvent(new BroadcastEvent(33, "Test Message Please Ignore 3min"), 0, 0, TimeSpan.FromMinutes(3.0)); + EventScheduler.Instance.ScheduleEvent(new BroadcastEvent(44, "Test Message Please Ignore 4min"), 0, 0, TimeSpan.FromMinutes(4.0)); + */ + } + + public BroadcastEvent(int hue, string text) + { + _hue = hue; + _text = text; + } + + public override string ToString() + { + return $"Broadcast: {_text}"; + } + + public void OnEventScheduled() + { + World.Broadcast(_hue, true, _text); + } + } +} diff --git a/Projects/Scripts/Engines/Events/EventScheduler.cs b/Projects/Scripts/Engines/Events/EventScheduler.cs index 127b82ce0..312468422 100644 --- a/Projects/Scripts/Engines/Events/EventScheduler.cs +++ b/Projects/Scripts/Engines/Events/EventScheduler.cs @@ -1,89 +1,88 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Server.Engines.Events -{ - public interface IEvent - { - void OnEventScheduled(); - } - - public class EventScheduleEntry - { - public DateTime NextOccurrence { get; private set; } - public TimeSpan Interval { get; private set; } - private TimeSpan _offset; - private IEvent _event; - - public EventScheduleEntry(IEvent e, DateTime firstSpawn, TimeSpan interval, TimeSpan offset) - { - _offset = offset; - _event = e; - Interval = interval; - NextOccurrence = firstSpawn; - } - - public void Occur() - { - NextOccurrence += Interval; - - _event?.OnEventScheduled(); - } - - public override string ToString() - { - return _event?.ToString(); - } - } - public class EventScheduler : Timer - { - private static EventScheduler _instance; - private List _schedule = new List(); - - public static EventScheduler Instance => _instance ??= new EventScheduler(); - public static List AvailableEvents { get; } = new List(); - - private EventScheduler() : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) - { - } - - public static void Initialize() - { - Instance.Start(); - } - - public void ScheduleEvent(IEvent e, int hour, int min) - { - ScheduleEvent(e, hour, min, TimeSpan.FromDays(1.0)); - } - - public void ScheduleEvent(IEvent e, int hour, int min, TimeSpan interval) - { - DateTime now = DateTime.UtcNow; - DateTime firstRun = new DateTime(now.Year, now.Month, now.Day, hour, min, 0); - - while (now > firstRun) - firstRun += interval; - - ScheduleEvent(new EventScheduleEntry(e, firstRun, interval, TimeSpan.FromHours(hour) + TimeSpan.FromMinutes(min))); - } - - public void ScheduleEvent(EventScheduleEntry e) - { - _schedule.Add(e); - } - - public void RemoveEvent(EventScheduleEntry entry) - { - _schedule.Remove(entry); - } - - protected override void OnTick() - { - foreach (EventScheduleEntry entry in _schedule) - if (entry.NextOccurrence <= DateTime.UtcNow) - entry.Occur(); - } - } -} +using System; +using System.Collections.Generic; + +namespace Server.Engines.Events +{ + public interface IEvent + { + void OnEventScheduled(); + } + + public class EventScheduleEntry + { + public DateTime NextOccurrence { get; private set; } + public TimeSpan Interval { get; private set; } + private TimeSpan _offset; + private readonly IEvent _event; + + public EventScheduleEntry(IEvent e, DateTime firstSpawn, TimeSpan interval, TimeSpan offset) + { + _offset = offset; + _event = e; + Interval = interval; + NextOccurrence = firstSpawn; + } + + public void Occur() + { + NextOccurrence += Interval; + + _event?.OnEventScheduled(); + } + + public override string ToString() + { + return _event?.ToString(); + } + } + public class EventScheduler : Timer + { + private static EventScheduler _instance; + private readonly List _schedule = new List(); + + public static EventScheduler Instance => _instance ??= new EventScheduler(); + public static List AvailableEvents { get; } = new List(); + + private EventScheduler() : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) + { + } + + public static void Initialize() + { + Instance.Start(); + } + + public void ScheduleEvent(IEvent e, int hour, int min) + { + ScheduleEvent(e, hour, min, TimeSpan.FromDays(1.0)); + } + + public void ScheduleEvent(IEvent e, int hour, int min, TimeSpan interval) + { + DateTime now = DateTime.UtcNow; + DateTime firstRun = new DateTime(now.Year, now.Month, now.Day, hour, min, 0); + + while (now > firstRun) + firstRun += interval; + + ScheduleEvent(new EventScheduleEntry(e, firstRun, interval, TimeSpan.FromHours(hour) + TimeSpan.FromMinutes(min))); + } + + public void ScheduleEvent(EventScheduleEntry e) + { + _schedule.Add(e); + } + + public void RemoveEvent(EventScheduleEntry entry) + { + _schedule.Remove(entry); + } + + protected override void OnTick() + { + foreach (EventScheduleEntry entry in _schedule) + if (entry.NextOccurrence <= DateTime.UtcNow) + entry.Occur(); + } + } +} diff --git a/Projects/Scripts/Engines/Factions/Core/Election.cs b/Projects/Scripts/Engines/Factions/Core/Election.cs index 03768be17..69f8f7f3d 100644 --- a/Projects/Scripts/Engines/Factions/Core/Election.cs +++ b/Projects/Scripts/Engines/Factions/Core/Election.cs @@ -30,34 +30,34 @@ namespace Server.Factions switch (version) { case 0: - { - Faction = Faction.ReadReference(reader); - - LastStateTime = reader.ReadDateTime(); - CurrentState = (ElectionState)reader.ReadEncodedInt(); - - Candidates = new List(); - - int count = reader.ReadEncodedInt(); - - for (int i = 0; i < count; ++i) { - Candidate cd = new Candidate(reader); + Faction = Faction.ReadReference(reader); - if (cd.Mobile != null) - Candidates.Add(cd); + LastStateTime = reader.ReadDateTime(); + CurrentState = (ElectionState)reader.ReadEncodedInt(); + + Candidates = new List(); + + int count = reader.ReadEncodedInt(); + + for (int i = 0; i < count; ++i) + { + Candidate cd = new Candidate(reader); + + if (cd.Mobile != null) + Candidates.Add(cd); + } + + break; } - - break; - } } StartTimer(); } - public Faction Faction{ get; } + public Faction Faction { get; } - public List Candidates{ get; } + public List Candidates { get; } public ElectionState State { @@ -69,10 +69,10 @@ namespace Server.Factions } } - public DateTime LastStateTime{ get; private set; } + public DateTime LastStateTime { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public ElectionState CurrentState{ get; private set; } + public ElectionState CurrentState { get; private set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public TimeSpan NextStateTime @@ -263,100 +263,100 @@ namespace Server.Factions switch (CurrentState) { case ElectionState.Pending: - { - if (LastStateTime + PendingPeriod > DateTime.UtcNow) - break; - - Faction.Broadcast(1038023); // Campaigning for the Faction Commander election has begun. - - Candidates.Clear(); - State = ElectionState.Campaign; - - break; - } - case ElectionState.Campaign: - { - if (LastStateTime + CampaignPeriod > DateTime.UtcNow) - break; - - if (Candidates.Count == 0) { - Faction.Broadcast(1038025); // Nobody ran for office. - State = ElectionState.Pending; + if (LastStateTime + PendingPeriod > DateTime.UtcNow) + break; + + Faction.Broadcast(1038023); // Campaigning for the Faction Commander election has begun. + + Candidates.Clear(); + State = ElectionState.Campaign; + + break; } - else if (Candidates.Count == 1) + case ElectionState.Campaign: { - Faction.Broadcast(1038029); // Only one member ran for office. + if (LastStateTime + CampaignPeriod > DateTime.UtcNow) + break; - Candidate winner = Candidates[0]; + if (Candidates.Count == 0) + { + Faction.Broadcast(1038025); // Nobody ran for office. + State = ElectionState.Pending; + } + else if (Candidates.Count == 1) + { + Faction.Broadcast(1038029); // Only one member ran for office. - Mobile mob = winner.Mobile; - PlayerState pl = PlayerState.Find(mob); + Candidate winner = Candidates[0]; - if (pl == null || pl.Faction != Faction || mob == Faction.Commander) + Mobile mob = winner.Mobile; + PlayerState pl = PlayerState.Find(mob); + + if (pl == null || pl.Faction != Faction || mob == Faction.Commander) + { + Faction.Broadcast(1038026); // Faction leadership has not changed. + } + else + { + Faction.Broadcast(1038028); // The faction has a new commander. + Faction.Commander = mob; + } + + Candidates.Clear(); + State = ElectionState.Pending; + } + else + { + Faction.Broadcast(1038030); + State = ElectionState.Election; + } + + break; + } + case ElectionState.Election: + { + if (LastStateTime + VotingPeriod > DateTime.UtcNow) + break; + + Faction.Broadcast(1038024); // The results for the Faction Commander election are in + + Candidate winner = null; + + for (int i = 0; i < Candidates.Count; ++i) + { + Candidate cd = Candidates[i]; + + PlayerState pl = PlayerState.Find(cd.Mobile); + + if (pl == null || pl.Faction != Faction) + continue; + + // cd.CleanMuleVotes(); + + if (winner == null || cd.Votes > winner.Votes) + winner = cd; + } + + if (winner == null) { Faction.Broadcast(1038026); // Faction leadership has not changed. } + else if (winner.Mobile == Faction.Commander) + { + Faction.Broadcast(1038027); // The incumbent won the election. + } else { Faction.Broadcast(1038028); // The faction has a new commander. - Faction.Commander = mob; + Faction.Commander = winner.Mobile; } Candidates.Clear(); State = ElectionState.Pending; - } - else - { - Faction.Broadcast(1038030); - State = ElectionState.Election; - } - break; - } - case ElectionState.Election: - { - if (LastStateTime + VotingPeriod > DateTime.UtcNow) break; - - Faction.Broadcast(1038024); // The results for the Faction Commander election are in - - Candidate winner = null; - - for (int i = 0; i < Candidates.Count; ++i) - { - Candidate cd = Candidates[i]; - - PlayerState pl = PlayerState.Find(cd.Mobile); - - if (pl == null || pl.Faction != Faction) - continue; - - //cd.CleanMuleVotes(); - - if (winner == null || cd.Votes > winner.Votes) - winner = cd; } - - if (winner == null) - { - Faction.Broadcast(1038026); // Faction leadership has not changed. - } - else if (winner.Mobile == Faction.Commander) - { - Faction.Broadcast(1038027); // The incumbent won the election. - } - else - { - Faction.Broadcast(1038028); // The faction has a new commander. - Faction.Commander = winner.Mobile; - } - - Candidates.Clear(); - State = ElectionState.Pending; - - break; - } } } } @@ -385,23 +385,23 @@ namespace Server.Factions switch (version) { case 0: - { - From = reader.ReadMobile(); - Address = Utility.Intern(reader.ReadIPAddress()); - Time = reader.ReadDateTime(); + { + From = reader.ReadMobile(); + Address = Utility.Intern(reader.ReadIPAddress()); + Time = reader.ReadDateTime(); - break; - } + break; + } } } - public Mobile From{ get; } + public Mobile From { get; } - public Mobile Candidate{ get; } + public Mobile Candidate { get; } - public IPAddress Address{ get; } + public IPAddress Address { get; } - public DateTime Time{ get; } + public DateTime Time { get; } public object[] AcquireFields() { @@ -458,40 +458,40 @@ namespace Server.Factions switch (version) { case 1: - { - Mobile = reader.ReadMobile(); - - int count = reader.ReadEncodedInt(); - Voters = new List(count); - - for (int i = 0; i < count; ++i) { - Voter voter = new Voter(reader, Mobile); + Mobile = reader.ReadMobile(); - if (voter.From != null) - Voters.Add(voter); + int count = reader.ReadEncodedInt(); + Voters = new List(count); + + for (int i = 0; i < count; ++i) + { + Voter voter = new Voter(reader, Mobile); + + if (voter.From != null) + Voters.Add(voter); + } + + break; } - - break; - } case 0: - { - Mobile = reader.ReadMobile(); + { + Mobile = reader.ReadMobile(); - List mobs = reader.ReadStrongMobileList(); - Voters = new List(mobs.Count); + List mobs = reader.ReadStrongMobileList(); + Voters = new List(mobs.Count); - for (int i = 0; i < mobs.Count; ++i) - Voters.Add(new Voter(mobs[i], Mobile)); + for (int i = 0; i < mobs.Count; ++i) + Voters.Add(new Voter(mobs[i], Mobile)); - break; - } + break; + } } } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public List Voters{ get; } + public List Voters { get; } public int Votes => Voters.Count; diff --git a/Projects/Scripts/Engines/Factions/Core/Faction.cs b/Projects/Scripts/Engines/Factions/Core/Faction.cs index c3d0443a5..16607da6b 100644 --- a/Projects/Scripts/Engines/Factions/Core/Faction.cs +++ b/Projects/Scripts/Engines/Factions/Core/Faction.cs @@ -28,7 +28,7 @@ namespace Server.Factions public Faction() => State = new FactionState(this); - public StrongholdRegion StrongholdRegion{ get; set; } + public StrongholdRegion StrongholdRegion { get; set; } public FactionDefinition Definition { @@ -40,7 +40,7 @@ namespace Server.Factions } } - public FactionState State{ get; set; } + public FactionState State { get; set; } public Election Election { @@ -312,8 +312,8 @@ namespace Server.Factions int killPoints = pl.KillPoints; - //Ordinarily, through normal faction removal, this will never find any sigils. - //Only with a leave delay less than the ReturnPeriod or a Faction Kick/Ban, will this ever do anything + // Ordinarily, through normal faction removal, this will never find any sigils. + // Only with a leave delay less than the ReturnPeriod or a Faction Kick/Ban, will this ever do anything mob.Backpack?.FindItemsByType().ForEach(sigil => sigil.ReturnHome()); if (pl.RankIndex != -1) @@ -451,8 +451,7 @@ namespace Server.Factions pm.SendLocalizedMessage( 1042161); // You cannot join a faction because your guild is an Order or Chaos type. } - else if (!Guild.NewGuildSystem && guild.Enemies?.Count > 0 - ) //CAN join w/wars in new system + else if (!Guild.NewGuildSystem && guild.Enemies?.Count > 0) // CAN join w/wars in new system { pm.SendLocalizedMessage(1005056); // You cannot join a faction with active Wars } @@ -735,7 +734,7 @@ namespace Server.Factions if (faction != null) from.SendGump(new ElectionManagementGump(faction.Election)); - //from.SendGump( new Gumps.PropertiesGump( from, faction.Election ) ); + // from.SendGump( new Gumps.PropertiesGump( from, faction.Election ) ); else from.SendMessage("That stone has no faction assigned."); } @@ -944,8 +943,6 @@ namespace Server.Factions silver.ToString("N0")); // Thou hast earned ~1_AMOUNT~ silver for vanquishing the vile creature. } - #region Ethics - if (bc.Map == Facet && bc.GetEthicAllegiance(killer) == BaseCreature.Allegiance.Enemy) { Player killerEPL = Player.Find(killer); @@ -957,8 +954,6 @@ namespace Server.Factions } } - #endregion - return; } @@ -967,13 +962,9 @@ namespace Server.Factions if (victimState == null) return; - #region Dueling - if (victim.Region.IsPartOf()) return; - #endregion - if (killer == victim || killerState.Faction != victimState.Faction) ApplySkillLoss(victim); @@ -983,8 +974,6 @@ namespace Server.Factions { killer?.SendLocalizedMessage(501693); // This victim is not worth enough to get kill points from. - #region Ethics - Player killerEPL = Player.Find(killer); Player victimEPL = Player.Find(victim); @@ -1005,8 +994,6 @@ namespace Server.Factions victimState.OnGivenSilverTo(killer); } } - - #endregion } else { @@ -1023,7 +1010,7 @@ namespace Server.Factions { victimState.IsActive = true; - if (1 > Utility.Random(3)) + if (Utility.Random(3) < 1) killerState.IsActive = true; int silver = killerState.Faction.AwardSilver(killer, award * 40); @@ -1045,8 +1032,6 @@ namespace Server.Factions victim.SendLocalizedMessage(1042738 + offset, args); // Thou has lost ~1_KILL_POINTS~ kill point(s) to ~3_ATTACKER_NAME~ for being vanquished! - #region Ethics - Player killerEPL = Player.Find(killer); Player victimEPL = Player.Find(victim); @@ -1066,8 +1051,6 @@ namespace Server.Factions } } - #endregion - victimState.OnGivenSilverTo(killer); } else @@ -1139,7 +1122,7 @@ namespace Server.Factions private class BroadcastPrompt : Prompt { - private Faction m_Faction; + private readonly Faction m_Faction; public BroadcastPrompt(Faction faction) => m_Faction = faction; @@ -1149,12 +1132,10 @@ namespace Server.Factions } } - #region Skill Loss - public const double SkillLossFactor = 1.0 / 3; public static readonly TimeSpan SkillLossPeriod = TimeSpan.FromMinutes(20.0); - private static Dictionary m_SkillLoss = new Dictionary(); + private static readonly Dictionary m_SkillLoss = new Dictionary(); private class SkillLossContext { @@ -1207,8 +1188,6 @@ namespace Server.Factions return true; } - - #endregion } public enum FactionKickType @@ -1220,7 +1199,7 @@ namespace Server.Factions public class FactionKickCommand : BaseCommand { - private FactionKickType m_KickType; + private readonly FactionKickType m_KickType; public FactionKickCommand(FactionKickType kickType) { @@ -1233,28 +1212,28 @@ namespace Server.Factions switch (m_KickType) { case FactionKickType.Kick: - { - Commands = new[] { "FactionKick" }; - Usage = "FactionKick"; - Description = - "Kicks the targeted player out of his current faction. This does not prevent them from rejoining."; - break; - } + { + Commands = new[] { "FactionKick" }; + Usage = "FactionKick"; + Description = + "Kicks the targeted player out of his current faction. This does not prevent them from rejoining."; + break; + } case FactionKickType.Ban: - { - Commands = new[] { "FactionBan" }; - Usage = "FactionBan"; - Description = - "Bans the account of a targeted player from joining factions. All players on the account are removed from their current faction, if any."; - break; - } + { + Commands = new[] { "FactionBan" }; + Usage = "FactionBan"; + Description = + "Bans the account of a targeted player from joining factions. All players on the account are removed from their current faction, if any."; + break; + } case FactionKickType.Unban: - { - Commands = new[] { "FactionUnban" }; - Usage = "FactionUnban"; - Description = "Unbans the account of a targeted player from joining factions."; - break; - } + { + Commands = new[] { "FactionUnban" }; + Usage = "FactionUnban"; + Description = "Unbans the account of a targeted player from joining factions."; + break; + } } } @@ -1265,81 +1244,81 @@ namespace Server.Factions switch (m_KickType) { case FactionKickType.Kick: - { - PlayerState pl = PlayerState.Find(mob); + { + PlayerState pl = PlayerState.Find(mob); - if (pl != null) - { - pl.Faction.RemoveMember(mob); - mob.SendMessage("You have been kicked from your faction."); - AddResponse("They have been kicked from their faction."); - } - else - { - LogFailure("They are not in a faction."); - } - - break; - } - case FactionKickType.Ban: - { - if (mob.Account is Account acct) - { - if (acct.GetTag("FactionBanned") == null) + if (pl != null) { - acct.SetTag("FactionBanned", "true"); - AddResponse("The account has been banned from joining factions."); + pl.Faction.RemoveMember(mob); + mob.SendMessage("You have been kicked from your faction."); + AddResponse("They have been kicked from their faction."); } else { - AddResponse("The account is already banned from joining factions."); + LogFailure("They are not in a faction."); } - for (int i = 0; i < acct.Length; ++i) + break; + } + case FactionKickType.Ban: + { + if (mob.Account is Account acct) { - mob = acct[i]; - - if (mob != null) + if (acct.GetTag("FactionBanned") == null) { - PlayerState pl = PlayerState.Find(mob); + acct.SetTag("FactionBanned", "true"); + AddResponse("The account has been banned from joining factions."); + } + else + { + AddResponse("The account is already banned from joining factions."); + } - if (pl != null) + for (int i = 0; i < acct.Length; ++i) + { + mob = acct[i]; + + if (mob != null) { - pl.Faction.RemoveMember(mob); - mob.SendMessage("You have been kicked from your faction."); - AddResponse("They have been kicked from their faction."); + PlayerState pl = PlayerState.Find(mob); + + if (pl != null) + { + pl.Faction.RemoveMember(mob); + mob.SendMessage("You have been kicked from your faction."); + AddResponse("They have been kicked from their faction."); + } } } } - } - else - { - LogFailure("They have no assigned account."); - } - - break; - } - case FactionKickType.Unban: - { - if (mob.Account is Account acct) - { - if (acct.GetTag("FactionBanned") == null) + else { - AddResponse("The account is not already banned from joining factions."); + LogFailure("They have no assigned account."); + } + + break; + } + case FactionKickType.Unban: + { + if (mob.Account is Account acct) + { + if (acct.GetTag("FactionBanned") == null) + { + AddResponse("The account is not already banned from joining factions."); + } + else + { + acct.RemoveTag("FactionBanned"); + AddResponse("The account may now freely join factions."); + } } else { - acct.RemoveTag("FactionBanned"); - AddResponse("The account may now freely join factions."); + LogFailure("They have no assigned account."); } - } - else - { - LogFailure("They have no assigned account."); - } - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Core/FactionItem.cs b/Projects/Scripts/Engines/Factions/Core/FactionItem.cs index 7500b2317..031f206fd 100644 --- a/Projects/Scripts/Engines/Factions/Core/FactionItem.cs +++ b/Projects/Scripts/Engines/Factions/Core/FactionItem.cs @@ -4,7 +4,7 @@ namespace Server.Factions { public interface IFactionItem { - FactionItem FactionItemState{ get; set; } + FactionItem FactionItemState { get; set; } } public class FactionItem @@ -24,21 +24,21 @@ namespace Server.Factions switch (version) { case 0: - { - Item = reader.ReadItem(); - Expiration = reader.ReadDateTime(); - break; - } + { + Item = reader.ReadItem(); + Expiration = reader.ReadDateTime(); + break; + } } Faction = faction; } - public Item Item{ get; } + public Item Item { get; } - public Faction Faction{ get; } + public Faction Faction { get; } - public DateTime Expiration{ get; private set; } + public DateTime Expiration { get; private set; } public bool HasExpired { diff --git a/Projects/Scripts/Engines/Factions/Core/FactionState.cs b/Projects/Scripts/Engines/Factions/Core/FactionState.cs index 9746dff48..5b430083f 100644 --- a/Projects/Scripts/Engines/Factions/Core/FactionState.cs +++ b/Projects/Scripts/Engines/Factions/Core/FactionState.cs @@ -8,9 +8,9 @@ namespace Server.Factions private const int BroadcastsPerPeriod = 2; private static readonly TimeSpan BroadcastPeriod = TimeSpan.FromHours(1.0); private Mobile m_Commander; - private Faction m_Faction; + private readonly Faction m_Faction; - private DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod]; + private readonly DateTime[] m_LastBroadcasts = new DateTime[BroadcastsPerPeriod]; public FactionState(Faction faction) { @@ -29,113 +29,113 @@ namespace Server.Factions switch (version) { case 5: - { - LastAtrophy = reader.ReadDateTime(); - goto case 4; - } - case 4: - { - int count = reader.ReadEncodedInt(); - - for (int i = 0; i < count; ++i) { - DateTime time = reader.ReadDateTime(); - - if (i < m_LastBroadcasts.Length) - m_LastBroadcasts[i] = time; + LastAtrophy = reader.ReadDateTime(); + goto case 4; } + case 4: + { + int count = reader.ReadEncodedInt(); - goto case 3; - } + for (int i = 0; i < count; ++i) + { + DateTime time = reader.ReadDateTime(); + + if (i < m_LastBroadcasts.Length) + m_LastBroadcasts[i] = time; + } + + goto case 3; + } case 3: case 2: case 1: - { - Election = new Election(reader); + { + Election = new Election(reader); - goto case 0; - } + goto case 0; + } case 0: - { - m_Faction = Faction.ReadReference(reader); - - m_Commander = reader.ReadMobile(); - - if (version < 5) - LastAtrophy = DateTime.UtcNow; - - if (version < 4) { - DateTime time = reader.ReadDateTime(); + m_Faction = Faction.ReadReference(reader); - if (m_LastBroadcasts.Length > 0) - m_LastBroadcasts[0] = time; - } + m_Commander = reader.ReadMobile(); - Tithe = reader.ReadEncodedInt(); - Silver = reader.ReadEncodedInt(); + if (version < 5) + LastAtrophy = DateTime.UtcNow; - int memberCount = reader.ReadEncodedInt(); - - Members = new List(); - - for (int i = 0; i < memberCount; ++i) - { - PlayerState pl = new PlayerState(reader, m_Faction, Members); - - if (pl.Mobile != null) - Members.Add(pl); - } - - m_Faction.State = this; - - m_Faction.ZeroRankOffset = Members.Count; - Members.Sort(); - - for (int i = Members.Count - 1; i >= 0; i--) - { - PlayerState player = Members[i]; - - if (player.KillPoints <= 0) - m_Faction.ZeroRankOffset = i; - else - player.RankIndex = i; - } - - FactionItems = new List(); - - if (version >= 2) - { - int factionItemCount = reader.ReadEncodedInt(); - - for (int i = 0; i < factionItemCount; ++i) + if (version < 4) { - FactionItem factionItem = new FactionItem(reader, m_Faction); + DateTime time = reader.ReadDateTime(); - Timer.DelayCall(TimeSpan.Zero, factionItem.CheckAttach); // sandbox attachment + if (m_LastBroadcasts.Length > 0) + m_LastBroadcasts[0] = time; } + + Tithe = reader.ReadEncodedInt(); + Silver = reader.ReadEncodedInt(); + + int memberCount = reader.ReadEncodedInt(); + + Members = new List(); + + for (int i = 0; i < memberCount; ++i) + { + PlayerState pl = new PlayerState(reader, m_Faction, Members); + + if (pl.Mobile != null) + Members.Add(pl); + } + + m_Faction.State = this; + + m_Faction.ZeroRankOffset = Members.Count; + Members.Sort(); + + for (int i = Members.Count - 1; i >= 0; i--) + { + PlayerState player = Members[i]; + + if (player.KillPoints <= 0) + m_Faction.ZeroRankOffset = i; + else + player.RankIndex = i; + } + + FactionItems = new List(); + + if (version >= 2) + { + int factionItemCount = reader.ReadEncodedInt(); + + for (int i = 0; i < factionItemCount; ++i) + { + FactionItem factionItem = new FactionItem(reader, m_Faction); + + Timer.DelayCall(TimeSpan.Zero, factionItem.CheckAttach); // sandbox attachment + } + } + + Traps = new List(); + + if (version >= 3) + { + int factionTrapCount = reader.ReadEncodedInt(); + + for (int i = 0; i < factionTrapCount; ++i) + if (reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay()) + Traps.Add(trap); + } + + break; } - - Traps = new List(); - - if (version >= 3) - { - int factionTrapCount = reader.ReadEncodedInt(); - - for (int i = 0; i < factionTrapCount; ++i) - if (reader.ReadItem() is BaseFactionTrap trap && !trap.CheckDecay()) - Traps.Add(trap); - } - - break; - } } if (version < 1) Election = new Election(m_Faction); } - public DateTime LastAtrophy{ get; set; } + public DateTime LastAtrophy { get; set; } public bool FactionMessageReady { @@ -151,11 +151,11 @@ namespace Server.Factions public bool IsAtrophyReady => DateTime.UtcNow >= LastAtrophy + TimeSpan.FromHours(47.0); - public List FactionItems{ get; set; } + public List FactionItems { get; set; } - public List Traps{ get; set; } + public List Traps { get; set; } - public Election Election{ get; set; } + public Election Election { get; set; } public Mobile Commander { @@ -183,11 +183,11 @@ namespace Server.Factions } } - public int Tithe{ get; set; } + public int Tithe { get; set; } - public int Silver{ get; set; } + public int Silver { get; set; } - public List Members{ get; set; } + public List Members { get; set; } public int CheckAtrophy() { diff --git a/Projects/Scripts/Engines/Factions/Core/GuardList.cs b/Projects/Scripts/Engines/Factions/Core/GuardList.cs index 07d4c697d..eb899ea79 100644 --- a/Projects/Scripts/Engines/Factions/Core/GuardList.cs +++ b/Projects/Scripts/Engines/Factions/Core/GuardList.cs @@ -1,6 +1,5 @@ -using Server.Utilities; -using System; using System.Collections.Generic; +using Server.Utilities; namespace Server.Factions { @@ -12,9 +11,9 @@ namespace Server.Factions Guards = new List(); } - public GuardDefinition Definition{ get; } + public GuardDefinition Definition { get; } - public List Guards{ get; } + public List Guards { get; } public BaseFactionGuard Construct() { diff --git a/Projects/Scripts/Engines/Factions/Core/Keywords.cs b/Projects/Scripts/Engines/Factions/Core/Keywords.cs index 86211d1b3..f988080d2 100644 --- a/Projects/Scripts/Engines/Factions/Core/Keywords.cs +++ b/Projects/Scripts/Engines/Factions/Core/Keywords.cs @@ -26,128 +26,128 @@ namespace Server.Factions switch (keywords[i]) { case 0x00E4: // *i wish to access the city treasury* - { - Town town = Town.FromRegion(from.Region); - - if (town?.IsFinance(from) != true || !from.Alive) - break; - - if (FactionGump.Exists(from)) - from.SendLocalizedMessage(1042160); // You already have a faction menu open. - else if (town.Owner != null && from is PlayerMobile mobile) - mobile.SendGump(new FinanceGump(mobile, town.Owner, town)); - - break; - } - case 0x0ED: // *i am sheriff* - { - Town town = Town.FromRegion(from.Region); - - if (town?.IsSheriff(from) != true || !from.Alive) - break; - - if (FactionGump.Exists(from)) - from.SendLocalizedMessage(1042160); // You already have a faction menu open. - else if (town.Owner != null) - from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town)); - - break; - } - case 0x00EF: // *you are fired* - { - Town town = Town.FromRegion(from.Region); - - if (town == null) - break; - - if (town.IsFinance(from) || town.IsSheriff(from)) - town.BeginOrderFiring(from); - - break; - } - case 0x00E5: // *i wish to resign as finance minister* - { - PlayerState pl = PlayerState.Find(from); - - if (pl?.Finance != null) { - pl.Finance.Finance = null; - from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister - } + Town town = Town.FromRegion(from.Region); - break; - } - case 0x00EE: // *i wish to resign as sheriff* - { - PlayerState pl = PlayerState.Find(from); - - if (pl?.Sheriff != null) - { - pl.Sheriff.Sheriff = null; - from.SendLocalizedMessage(1010270); // You have been fired as Sheriff - } - - break; - } - case 0x00E9: // *what is my faction term status* - { - PlayerState pl = PlayerState.Find(from); - - if (pl?.IsLeaving == true) - { - if (Faction.CheckLeaveTimer(from)) + if (town?.IsFinance(from) != true || !from.Alive) break; - TimeSpan remaining = pl.Leaving + Faction.LeavePeriod - DateTime.UtcNow; + if (FactionGump.Exists(from)) + from.SendLocalizedMessage(1042160); // You already have a faction menu open. + else if (town.Owner != null && from is PlayerMobile mobile) + mobile.SendGump(new FinanceGump(mobile, town.Owner, town)); - if (remaining.TotalDays >= 1) - from.SendLocalizedMessage(1042743, - remaining.TotalDays - .ToString("N0")); // Your term of service will come to an end in ~1_DAYS~ days. - else if (remaining.TotalHours >= 1) - from.SendLocalizedMessage(1042741, - remaining.TotalHours - .ToString("N0")); // Your term of service will come to an end in ~1_HOURS~ hours. - else - from.SendLocalizedMessage( - 1042742); // Your term of service will come to an end in less than one hour. - } - else if (pl != null) - { - from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction. - } - - break; - } - case 0x00EA: // *message faction* - { - Faction faction = Faction.Find(from); - - if (faction?.IsCommander(from) != true) break; + } + case 0x0ED: // *i am sheriff* + { + Town town = Town.FromRegion(from.Region); - if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady) - from.SendLocalizedMessage( - 1010264); // The required time has not yet passed since the last message was sent - else - faction.BeginBroadcast(from); + if (town?.IsSheriff(from) != true || !from.Alive) + break; - break; - } + if (FactionGump.Exists(from)) + from.SendLocalizedMessage(1042160); // You already have a faction menu open. + else if (town.Owner != null) + from.SendGump(new SheriffGump((PlayerMobile)from, town.Owner, town)); + + break; + } + case 0x00EF: // *you are fired* + { + Town town = Town.FromRegion(from.Region); + + if (town == null) + break; + + if (town.IsFinance(from) || town.IsSheriff(from)) + town.BeginOrderFiring(from); + + break; + } + case 0x00E5: // *i wish to resign as finance minister* + { + PlayerState pl = PlayerState.Find(from); + + if (pl?.Finance != null) + { + pl.Finance.Finance = null; + from.SendLocalizedMessage(1005081); // You have been fired as Finance Minister + } + + break; + } + case 0x00EE: // *i wish to resign as sheriff* + { + PlayerState pl = PlayerState.Find(from); + + if (pl?.Sheriff != null) + { + pl.Sheriff.Sheriff = null; + from.SendLocalizedMessage(1010270); // You have been fired as Sheriff + } + + break; + } + case 0x00E9: // *what is my faction term status* + { + PlayerState pl = PlayerState.Find(from); + + if (pl?.IsLeaving == true) + { + if (Faction.CheckLeaveTimer(from)) + break; + + TimeSpan remaining = pl.Leaving + Faction.LeavePeriod - DateTime.UtcNow; + + if (remaining.TotalDays >= 1) + from.SendLocalizedMessage(1042743, + remaining.TotalDays + .ToString("N0")); // Your term of service will come to an end in ~1_DAYS~ days. + else if (remaining.TotalHours >= 1) + from.SendLocalizedMessage(1042741, + remaining.TotalHours + .ToString("N0")); // Your term of service will come to an end in ~1_HOURS~ hours. + else + from.SendLocalizedMessage( + 1042742); // Your term of service will come to an end in less than one hour. + } + else if (pl != null) + { + from.SendLocalizedMessage(1042233); // You are not in the process of quitting the faction. + } + + break; + } + case 0x00EA: // *message faction* + { + Faction faction = Faction.Find(from); + + if (faction?.IsCommander(from) != true) + break; + + if (from.AccessLevel == AccessLevel.Player && !faction.FactionMessageReady) + from.SendLocalizedMessage( + 1010264); // The required time has not yet passed since the last message was sent + else + faction.BeginBroadcast(from); + + break; + } case 0x00EC: // *showscore* - { - PlayerState pl = PlayerState.Find(from); + { + PlayerState pl = PlayerState.Find(from); - if (pl != null) - Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl); + if (pl != null) + Timer.DelayCall(TimeSpan.Zero, ShowScore_Sandbox, pl); - break; - } + break; + } case 0x0178: // i honor your leadership - { - Faction.Find(from)?.BeginHonorLeadership(from); - break; - } + { + Faction.Find(from)?.BeginHonorLeadership(from); + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Core/MerchantTitles.cs b/Projects/Scripts/Engines/Factions/Core/MerchantTitles.cs index b69512c3a..c7195bd7b 100644 --- a/Projects/Scripts/Engines/Factions/Core/MerchantTitles.cs +++ b/Projects/Scripts/Engines/Factions/Core/MerchantTitles.cs @@ -22,20 +22,20 @@ namespace Server.Factions Assigned = assigned; } - public SkillName Skill{ get; } + public SkillName Skill { get; } - public double Requirement{ get; } + public double Requirement { get; } - public TextDefinition Title{ get; } + public TextDefinition Title { get; } - public TextDefinition Label{ get; } + public TextDefinition Label { get; } - public TextDefinition Assigned{ get; } + public TextDefinition Assigned { get; } } public class MerchantTitles { - public static MerchantTitleInfo[] Info{ get; } = + public static MerchantTitleInfo[] Info { get; } = { new MerchantTitleInfo(SkillName.Inscribe, 90.0, new TextDefinition(1060773, "Scribe"), new TextDefinition(1011468, "SCRIBE"), diff --git a/Projects/Scripts/Engines/Factions/Core/Persistance.cs b/Projects/Scripts/Engines/Factions/Core/Persistance.cs index 717dfed90..a273a7e55 100644 --- a/Projects/Scripts/Engines/Factions/Core/Persistance.cs +++ b/Projects/Scripts/Engines/Factions/Core/Persistance.cs @@ -16,7 +16,7 @@ namespace Server.Factions public FactionPersistance(Serial serial) : base(serial) => Instance = this; - public static FactionPersistance Instance{ get; private set; } + public static FactionPersistance Instance { get; private set; } public override string DefaultName => "Faction Persistance - Internal"; @@ -54,22 +54,22 @@ namespace Server.Factions switch (version) { case 0: - { - PersistedType type; + { + PersistedType type; - while ((type = (PersistedType)reader.ReadEncodedInt()) != PersistedType.Terminator) - switch (type) - { - case PersistedType.Faction: - new FactionState(reader); - break; - case PersistedType.Town: - new TownState(reader); - break; - } + while ((type = (PersistedType)reader.ReadEncodedInt()) != PersistedType.Terminator) + switch (type) + { + case PersistedType.Faction: + new FactionState(reader); + break; + case PersistedType.Town: + new TownState(reader); + break; + } - break; - } + break; + } } } diff --git a/Projects/Scripts/Engines/Factions/Core/PlayerState.cs b/Projects/Scripts/Engines/Factions/Core/PlayerState.cs index 41b564f94..0cafab3e2 100644 --- a/Projects/Scripts/Engines/Factions/Core/PlayerState.cs +++ b/Projects/Scripts/Engines/Factions/Core/PlayerState.cs @@ -36,32 +36,32 @@ namespace Server.Factions switch (version) { case 1: - { - IsActive = reader.ReadBool(); - LastHonorTime = reader.ReadDateTime(); - goto case 0; - } + { + IsActive = reader.ReadBool(); + LastHonorTime = reader.ReadDateTime(); + goto case 0; + } case 0: - { - Mobile = reader.ReadMobile(); + { + Mobile = reader.ReadMobile(); - m_KillPoints = reader.ReadEncodedInt(); - m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt(); + m_KillPoints = reader.ReadEncodedInt(); + m_MerchantTitle = (MerchantTitle)reader.ReadEncodedInt(); - Leaving = reader.ReadDateTime(); + Leaving = reader.ReadDateTime(); - break; - } + break; + } } Attach(); } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public Faction Faction{ get; } + public Faction Faction { get; } - public List Owner{ get; } + public List Owner { get; } public MerchantTitle MerchantTitle { @@ -93,7 +93,7 @@ namespace Server.Factions } } - public List SilverGiven{ get; private set; } + public List SilverGiven { get; private set; } public int KillPoints { @@ -233,13 +233,13 @@ namespace Server.Factions } } - public DateTime LastHonorTime{ get; set; } + public DateTime LastHonorTime { get; set; } - public DateTime Leaving{ get; set; } + public DateTime Leaving { get; set; } public bool IsLeaving => Leaving > DateTime.MinValue; - public bool IsActive{ get; set; } + public bool IsActive { get; set; } public int CompareTo(PlayerState ps) => (ps?.m_KillPoints ?? 0) - m_KillPoints; diff --git a/Projects/Scripts/Engines/Factions/Core/Reflector.cs b/Projects/Scripts/Engines/Factions/Core/Reflector.cs index 6b5a28062..45e31e7ee 100644 --- a/Projects/Scripts/Engines/Factions/Core/Reflector.cs +++ b/Projects/Scripts/Engines/Factions/Core/Reflector.cs @@ -1,8 +1,8 @@ -using Server.Utilities; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; +using Server.Utilities; namespace Server.Factions { diff --git a/Projects/Scripts/Engines/Factions/Core/SilverGivenEntry.cs b/Projects/Scripts/Engines/Factions/Core/SilverGivenEntry.cs index 1a3478848..acf77f189 100644 --- a/Projects/Scripts/Engines/Factions/Core/SilverGivenEntry.cs +++ b/Projects/Scripts/Engines/Factions/Core/SilverGivenEntry.cs @@ -12,9 +12,9 @@ namespace Server.Factions TimeOfGift = DateTime.UtcNow; } - public Mobile GivenTo{ get; } + public Mobile GivenTo { get; } - public DateTime TimeOfGift{ get; } + public DateTime TimeOfGift { get; } public bool IsExpired => TimeOfGift + ExpirePeriod < DateTime.UtcNow; } diff --git a/Projects/Scripts/Engines/Factions/Core/StrongholdRegion.cs b/Projects/Scripts/Engines/Factions/Core/StrongholdRegion.cs index 353647968..544c4f2d7 100644 --- a/Projects/Scripts/Engines/Factions/Core/StrongholdRegion.cs +++ b/Projects/Scripts/Engines/Factions/Core/StrongholdRegion.cs @@ -13,7 +13,7 @@ namespace Server.Factions Register(); } - public Faction Faction{ get; set; } + public Faction Faction { get; set; } public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) { diff --git a/Projects/Scripts/Engines/Factions/Core/Town.cs b/Projects/Scripts/Engines/Factions/Core/Town.cs index ea6980227..8bc724314 100644 --- a/Projects/Scripts/Engines/Factions/Core/Town.cs +++ b/Projects/Scripts/Engines/Factions/Core/Town.cs @@ -23,7 +23,7 @@ namespace Server.Factions StartIncomeTimer(); } - public TownDefinition Definition{ get; set; } + public TownDefinition Definition { get; set; } public TownState State { @@ -125,9 +125,9 @@ namespace Server.Factions set => m_State.LastIncome = value; } - public List VendorLists{ get; set; } + public List VendorLists { get; set; } - public List GuardLists{ get; set; } + public List GuardLists { get; set; } public static List Towns => Reflector.Towns; diff --git a/Projects/Scripts/Engines/Factions/Core/TownState.cs b/Projects/Scripts/Engines/Factions/Core/TownState.cs index 0c3825b70..883236a1a 100644 --- a/Projects/Scripts/Engines/Factions/Core/TownState.cs +++ b/Projects/Scripts/Engines/Factions/Core/TownState.cs @@ -16,42 +16,42 @@ namespace Server.Factions switch (version) { case 3: - { - LastIncome = reader.ReadDateTime(); + { + LastIncome = reader.ReadDateTime(); - goto case 2; - } + goto case 2; + } case 2: - { - Tax = reader.ReadEncodedInt(); - LastTaxChange = reader.ReadDateTime(); + { + Tax = reader.ReadEncodedInt(); + LastTaxChange = reader.ReadDateTime(); - goto case 1; - } + goto case 1; + } case 1: - { - Silver = reader.ReadEncodedInt(); + { + Silver = reader.ReadEncodedInt(); - goto case 0; - } + goto case 0; + } case 0: - { - Town = Town.ReadReference(reader); - Owner = Faction.ReadReference(reader); + { + Town = Town.ReadReference(reader); + Owner = Faction.ReadReference(reader); - m_Sheriff = reader.ReadMobile(); - m_Finance = reader.ReadMobile(); + m_Sheriff = reader.ReadMobile(); + m_Finance = reader.ReadMobile(); - Town.State = this; + Town.State = this; - break; - } + break; + } } } - public Town Town{ get; set; } + public Town Town { get; set; } - public Faction Owner{ get; set; } + public Faction Owner { get; set; } public Mobile Sheriff { @@ -103,13 +103,13 @@ namespace Server.Factions } } - public int Silver{ get; set; } + public int Silver { get; set; } - public int Tax{ get; set; } + public int Tax { get; set; } - public DateTime LastTaxChange{ get; set; } + public DateTime LastTaxChange { get; set; } - public DateTime LastIncome{ get; set; } + public DateTime LastIncome { get; set; } public void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Engines/Factions/Core/VendorList.cs b/Projects/Scripts/Engines/Factions/Core/VendorList.cs index f86ac1b34..87c66d0fd 100644 --- a/Projects/Scripts/Engines/Factions/Core/VendorList.cs +++ b/Projects/Scripts/Engines/Factions/Core/VendorList.cs @@ -1,6 +1,5 @@ -using Server.Utilities; -using System; using System.Collections.Generic; +using Server.Utilities; namespace Server.Factions { @@ -12,9 +11,9 @@ namespace Server.Factions Vendors = new List(); } - public VendorDefinition Definition{ get; } + public VendorDefinition Definition { get; } - public List Vendors{ get; } + public List Vendors { get; } public BaseFactionVendor Construct(Town town, Faction faction) { diff --git a/Projects/Scripts/Engines/Factions/Definitions/FactionDefinition.cs b/Projects/Scripts/Engines/Factions/Definitions/FactionDefinition.cs index 309bacfe1..84d1846ad 100644 --- a/Projects/Scripts/Engines/Factions/Definitions/FactionDefinition.cs +++ b/Projects/Scripts/Engines/Factions/Definitions/FactionDefinition.cs @@ -36,54 +36,54 @@ namespace Server.Factions Guards = guards; } - public int Sort{ get; } + public int Sort { get; } - public int HuePrimary{ get; } + public int HuePrimary { get; } - public int HueSecondary{ get; } + public int HueSecondary { get; } - public int HueJoin{ get; } + public int HueJoin { get; } - public int HueBroadcast{ get; } + public int HueBroadcast { get; } - public int WarHorseBody{ get; } + public int WarHorseBody { get; } - public int WarHorseItem{ get; } + public int WarHorseItem { get; } - public string FriendlyName{ get; } + public string FriendlyName { get; } - public string Keyword{ get; } + public string Keyword { get; } - public string Abbreviation{ get; } + public string Abbreviation { get; } - public TextDefinition Name{ get; } + public TextDefinition Name { get; } - public TextDefinition PropName{ get; } + public TextDefinition PropName { get; } - public TextDefinition Header{ get; } + public TextDefinition Header { get; } - public TextDefinition About{ get; } + public TextDefinition About { get; } - public TextDefinition CityControl{ get; } + public TextDefinition CityControl { get; } - public TextDefinition SigilControl{ get; } + public TextDefinition SigilControl { get; } - public TextDefinition SignupName{ get; } + public TextDefinition SignupName { get; } - public TextDefinition FactionStoneName{ get; } + public TextDefinition FactionStoneName { get; } - public TextDefinition OwnerLabel{ get; } + public TextDefinition OwnerLabel { get; } - public TextDefinition GuardIgnore{ get; } + public TextDefinition GuardIgnore { get; } - public TextDefinition GuardWarn{ get; } + public TextDefinition GuardWarn { get; } - public TextDefinition GuardAttack{ get; } + public TextDefinition GuardAttack { get; } - public StrongholdDefinition Stronghold{ get; } + public StrongholdDefinition Stronghold { get; } - public RankDefinition[] Ranks{ get; } + public RankDefinition[] Ranks { get; } - public GuardDefinition[] Guards{ get; } + public GuardDefinition[] Guards { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Definitions/FactionItemDefinition.cs b/Projects/Scripts/Engines/Factions/Definitions/FactionItemDefinition.cs index 8b48fb621..2daa61970 100644 --- a/Projects/Scripts/Engines/Factions/Definitions/FactionItemDefinition.cs +++ b/Projects/Scripts/Engines/Factions/Definitions/FactionItemDefinition.cs @@ -6,12 +6,12 @@ namespace Server.Factions { public class FactionItemDefinition { - private static FactionItemDefinition m_MetalArmor = new FactionItemDefinition(1000, typeof(Blacksmith)); - private static FactionItemDefinition m_Weapon = new FactionItemDefinition(1000, typeof(Blacksmith)); - private static FactionItemDefinition m_RangedWeapon = new FactionItemDefinition(1000, typeof(Bowyer)); - private static FactionItemDefinition m_LeatherArmor = new FactionItemDefinition(750, typeof(Tailor)); - private static FactionItemDefinition m_Clothing = new FactionItemDefinition(200, typeof(Tailor)); - private static FactionItemDefinition m_Scroll = new FactionItemDefinition(500, typeof(Mage)); + private static readonly FactionItemDefinition m_MetalArmor = new FactionItemDefinition(1000, typeof(Blacksmith)); + private static readonly FactionItemDefinition m_Weapon = new FactionItemDefinition(1000, typeof(Blacksmith)); + private static readonly FactionItemDefinition m_RangedWeapon = new FactionItemDefinition(1000, typeof(Bowyer)); + private static readonly FactionItemDefinition m_LeatherArmor = new FactionItemDefinition(750, typeof(Tailor)); + private static readonly FactionItemDefinition m_Clothing = new FactionItemDefinition(200, typeof(Tailor)); + private static readonly FactionItemDefinition m_Scroll = new FactionItemDefinition(500, typeof(Mage)); public FactionItemDefinition(int silverCost, Type vendorType) { @@ -19,9 +19,9 @@ namespace Server.Factions VendorType = vendorType; } - public int SilverCost{ get; } + public int SilverCost { get; } - public Type VendorType{ get; } + public Type VendorType { get; } public static FactionItemDefinition Identify(Item item) { diff --git a/Projects/Scripts/Engines/Factions/Definitions/GuardDefinition.cs b/Projects/Scripts/Engines/Factions/Definitions/GuardDefinition.cs index a2471710d..898587918 100644 --- a/Projects/Scripts/Engines/Factions/Definitions/GuardDefinition.cs +++ b/Projects/Scripts/Engines/Factions/Definitions/GuardDefinition.cs @@ -18,18 +18,18 @@ namespace Server.Factions Label = label; } - public Type Type{ get; } + public Type Type { get; } - public int Price{ get; } + public int Price { get; } - public int Upkeep{ get; } + public int Upkeep { get; } - public int Maximum{ get; } + public int Maximum { get; } - public int ItemID{ get; } + public int ItemID { get; } - public TextDefinition Header{ get; } + public TextDefinition Header { get; } - public TextDefinition Label{ get; } + public TextDefinition Label { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Definitions/RankDefinition.cs b/Projects/Scripts/Engines/Factions/Definitions/RankDefinition.cs index 4481c9aa8..fead57da9 100644 --- a/Projects/Scripts/Engines/Factions/Definitions/RankDefinition.cs +++ b/Projects/Scripts/Engines/Factions/Definitions/RankDefinition.cs @@ -10,12 +10,12 @@ namespace Server.Factions MaxWearables = maxWearables; } - public int Rank{ get; } + public int Rank { get; } - public int Required{ get; } + public int Required { get; } - public int MaxWearables{ get; } + public int MaxWearables { get; } - public TextDefinition Title{ get; } + public TextDefinition Title { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Definitions/StrongholdDefintion.cs b/Projects/Scripts/Engines/Factions/Definitions/StrongholdDefintion.cs index e74595e21..3786265cb 100644 --- a/Projects/Scripts/Engines/Factions/Definitions/StrongholdDefintion.cs +++ b/Projects/Scripts/Engines/Factions/Definitions/StrongholdDefintion.cs @@ -10,12 +10,12 @@ namespace Server.Factions Monoliths = monoliths; } - public Rectangle2D[] Area{ get; } + public Rectangle2D[] Area { get; } - public Point3D JoinStone{ get; } + public Point3D JoinStone { get; } - public Point3D FactionStone{ get; } + public Point3D FactionStone { get; } - public Point3D[] Monoliths{ get; } + public Point3D[] Monoliths { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Definitions/TownDefinition.cs b/Projects/Scripts/Engines/Factions/Definitions/TownDefinition.cs index a7a4ca727..fa3076522 100644 --- a/Projects/Scripts/Engines/Factions/Definitions/TownDefinition.cs +++ b/Projects/Scripts/Engines/Factions/Definitions/TownDefinition.cs @@ -22,30 +22,30 @@ namespace Server.Factions TownStone = townStone; } - public int Sort{ get; } + public int Sort { get; } - public int SigilID{ get; } + public int SigilID { get; } - public string Region{ get; } + public string Region { get; } - public string FriendlyName{ get; } + public string FriendlyName { get; } - public TextDefinition TownName{ get; } + public TextDefinition TownName { get; } - public TextDefinition TownStoneHeader{ get; } + public TextDefinition TownStoneHeader { get; } - public TextDefinition StrongholdMonolithName{ get; } + public TextDefinition StrongholdMonolithName { get; } - public TextDefinition TownMonolithName{ get; } + public TextDefinition TownMonolithName { get; } - public TextDefinition TownStoneName{ get; } + public TextDefinition TownStoneName { get; } - public TextDefinition SigilName{ get; } + public TextDefinition SigilName { get; } - public TextDefinition CorruptedSigilName{ get; } + public TextDefinition CorruptedSigilName { get; } - public Point3D Monolith{ get; } + public Point3D Monolith { get; } - public Point3D TownStone{ get; } + public Point3D TownStone { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Definitions/VendorDefinition.cs b/Projects/Scripts/Engines/Factions/Definitions/VendorDefinition.cs index 61176533d..a55f7acf0 100644 --- a/Projects/Scripts/Engines/Factions/Definitions/VendorDefinition.cs +++ b/Projects/Scripts/Engines/Factions/Definitions/VendorDefinition.cs @@ -18,57 +18,52 @@ namespace Server.Factions Label = label; } - public Type Type{ get; } + public Type Type { get; } - public int Price{ get; } + public int Price { get; } - public int Upkeep{ get; } + public int Upkeep { get; } - public int Maximum{ get; } + public int Maximum { get; } - public int ItemID{ get; } + public int ItemID { get; } - public TextDefinition Header{ get; } + public TextDefinition Header { get; } - public TextDefinition Label{ get; } + public TextDefinition Label { get; } - public static VendorDefinition[] Definitions{ get; } = + public static VendorDefinition[] Definitions { get; } = { new VendorDefinition(typeof(FactionBottleVendor), 0xF0E, 5000, 1000, 10, new TextDefinition(1011549, "POTION BOTTLE VENDOR"), - new TextDefinition(1011544, "Buy Potion Bottle Vendor") - ), + new TextDefinition(1011544, "Buy Potion Bottle Vendor")), new VendorDefinition(typeof(FactionBoardVendor), 0x1BD7, 3000, 500, 10, new TextDefinition(1011552, "WOOD VENDOR"), - new TextDefinition(1011545, "Buy Wooden Board Vendor") - ), + new TextDefinition(1011545, "Buy Wooden Board Vendor")), new VendorDefinition(typeof(FactionOreVendor), 0x19B8, 3000, 500, 10, new TextDefinition(1011553, "IRON ORE VENDOR"), - new TextDefinition(1011546, "Buy Iron Ore Vendor") - ), + new TextDefinition(1011546, "Buy Iron Ore Vendor")), new VendorDefinition(typeof(FactionReagentVendor), 0xF86, 5000, 1000, 10, new TextDefinition(1011554, "REAGENT VENDOR"), - new TextDefinition(1011547, "Buy Reagent Vendor") - ), + new TextDefinition(1011547, "Buy Reagent Vendor")), new VendorDefinition(typeof(FactionHorseVendor), 0x20DD, 5000, 1000, 1, new TextDefinition(1011556, "HORSE BREEDER"), - new TextDefinition(1011555, "Buy Horse Breeder") - ) + new TextDefinition(1011555, "Buy Horse Breeder")) }; } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Gumps/ElectionGump.cs b/Projects/Scripts/Engines/Factions/Gumps/ElectionGump.cs index 227c4b442..6efcca991 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/ElectionGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/ElectionGump.cs @@ -7,8 +7,8 @@ namespace Server.Factions { public class ElectionGump : FactionGump { - private Election m_Election; - private PlayerMobile m_From; + private readonly Election m_Election; + private readonly PlayerMobile m_From; public ElectionGump(PlayerMobile from, Election election) : base(50, 50) { @@ -27,71 +27,71 @@ namespace Server.Factions switch (election.State) { case ElectionState.Pending: - { - TimeSpan toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow; - int days = (int)(toGo.TotalDays + 0.5); - - AddHtmlLocalized(20, 40, 380, 20, 1038034); // A new election campaign is pending - - if (days > 0) { - AddHtmlLocalized(20, 60, 280, 20, 1018062); // Days until next election : - AddLabel(300, 60, 0, days.ToString()); - } - else - { - AddHtmlLocalized(20, 60, 280, 20, 1018059); // Election campaigning begins tonight. - } + TimeSpan toGo = election.LastStateTime + Election.PendingPeriod - DateTime.UtcNow; + int days = (int)(toGo.TotalDays + 0.5); - break; - } + AddHtmlLocalized(20, 40, 380, 20, 1038034); // A new election campaign is pending + + if (days > 0) + { + AddHtmlLocalized(20, 60, 280, 20, 1018062); // Days until next election : + AddLabel(300, 60, 0, days.ToString()); + } + else + { + AddHtmlLocalized(20, 60, 280, 20, 1018059); // Election campaigning begins tonight. + } + + break; + } case ElectionState.Campaign: - { - TimeSpan toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow; - int days = (int)(toGo.TotalDays + 0.5); - - AddHtmlLocalized(20, 40, 380, 20, 1018058); // There is an election campaign in progress. - - if (days > 0) { - AddHtmlLocalized(20, 60, 280, 20, 1038033); // Days to go: - AddLabel(300, 60, 0, days.ToString()); - } - else - { - AddHtmlLocalized(20, 60, 280, 20, 1018061); // Campaign in progress. Voting begins tonight. - } + TimeSpan toGo = election.LastStateTime + Election.CampaignPeriod - DateTime.UtcNow; + int days = (int)(toGo.TotalDays + 0.5); - if (m_Election.CanBeCandidate(m_From)) - { - AddButton(20, 110, 4005, 4007, 2); - AddHtmlLocalized(55, 110, 350, 20, 1011427); // CAMPAIGN FOR LEADERSHIP - } - else - { - PlayerState pl = PlayerState.Find(m_From); + AddHtmlLocalized(20, 40, 380, 20, 1018058); // There is an election campaign in progress. - if (pl == null || pl.Rank.Rank < Election.CandidateRank) - AddHtmlLocalized(20, 100, 380, 20, 1010118); // You must have a higher rank to run for office - } + if (days > 0) + { + AddHtmlLocalized(20, 60, 280, 20, 1038033); // Days to go: + AddLabel(300, 60, 0, days.ToString()); + } + else + { + AddHtmlLocalized(20, 60, 280, 20, 1018061); // Campaign in progress. Voting begins tonight. + } - break; - } + if (m_Election.CanBeCandidate(m_From)) + { + AddButton(20, 110, 4005, 4007, 2); + AddHtmlLocalized(55, 110, 350, 20, 1011427); // CAMPAIGN FOR LEADERSHIP + } + else + { + PlayerState pl = PlayerState.Find(m_From); + + if (pl == null || pl.Rank.Rank < Election.CandidateRank) + AddHtmlLocalized(20, 100, 380, 20, 1010118); // You must have a higher rank to run for office + } + + break; + } case ElectionState.Election: - { - TimeSpan toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow; - int days = (int)Math.Ceiling(toGo.TotalDays); + { + TimeSpan toGo = election.LastStateTime + Election.VotingPeriod - DateTime.UtcNow; + int days = (int)Math.Ceiling(toGo.TotalDays); - AddHtmlLocalized(20, 40, 380, 20, 1018060); // There is an election vote in progress. + AddHtmlLocalized(20, 40, 380, 20, 1018060); // There is an election vote in progress. - AddHtmlLocalized(20, 60, 280, 20, 1038033); - AddLabel(300, 60, 0, days.ToString()); + AddHtmlLocalized(20, 60, 280, 20, 1038033); + AddLabel(300, 60, 0, days.ToString()); - AddHtmlLocalized(55, 100, 380, 20, 1011428); // VOTE FOR LEADERSHIP - AddButton(20, 100, 4005, 4007, 1); + AddHtmlLocalized(55, 100, 380, 20, 1011428); // VOTE FOR LEADERSHIP + AddButton(20, 100, 4005, 4007, 1); - break; - } + break; + } } AddButton(20, 140, 4005, 4007, 0); @@ -103,24 +103,24 @@ namespace Server.Factions switch (info.ButtonID) { case 0: // back - { - m_From.SendGump(new FactionStoneGump(m_From, m_Election.Faction)); - break; - } + { + m_From.SendGump(new FactionStoneGump(m_From, m_Election.Faction)); + break; + } case 1: // vote - { - if (m_Election.State == ElectionState.Election) - m_From.SendGump(new VoteGump(m_From, m_Election)); + { + if (m_Election.State == ElectionState.Election) + m_From.SendGump(new VoteGump(m_From, m_Election)); - break; - } + break; + } case 2: // campaign - { - if (m_Election.CanBeCandidate(m_From)) - m_Election.AddCandidate(m_From); + { + if (m_Election.CanBeCandidate(m_From)) + m_Election.AddCandidate(m_From); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs b/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs index 0740c3252..6a5fb1f69 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/ElectionManagementGump.cs @@ -8,10 +8,10 @@ namespace Server.Factions public class ElectionManagementGump : Gump { public const int LabelColor = 0xFFFFFF; - private Candidate m_Candidate; + private readonly Candidate m_Candidate; - private Election m_Election; - private int m_Page; + private readonly Election m_Election; + private readonly int m_Page; public ElectionManagementGump(Election election, Candidate candidate = null, int page = 0) : base(40, 40) { @@ -53,7 +53,6 @@ namespace Server.Factions else AddImage(414, 104, 0x25E6); - AddHtml(14, 120, 30, 20, Color(Center("DEL"), LabelColor)); AddHtml(47, 120, 150, 20, Color("Name", LabelColor)); AddHtml(195, 120, 100, 20, Color(Center("Address"), LabelColor)); diff --git a/Projects/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs b/Projects/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs index 8627dfb5a..4afb17db1 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/FactionImbueGump.cs @@ -7,14 +7,14 @@ namespace Server.Factions { public class FactionImbueGump : FactionGump { - private CraftSystem m_CraftSystem; + private readonly CraftSystem m_CraftSystem; - private FactionItemDefinition m_Definition; - private Faction m_Faction; - private Item m_Item; - private Mobile m_Mobile; - private object m_Notice; - private BaseTool m_Tool; + private readonly FactionItemDefinition m_Definition; + private readonly Faction m_Faction; + private readonly Item m_Item; + private readonly Mobile m_Mobile; + private readonly object m_Notice; + private readonly BaseTool m_Tool; public FactionImbueGump(int quality, Item item, Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, int availableSilver, Faction faction, FactionItemDefinition def) : base(100, 200) @@ -34,9 +34,8 @@ namespace Server.Factions AddHtmlLocalized(20, 20, 210, 25, 1011569); // Imbue with Faction properties? - AddHtmlLocalized(20, 60, 170, 25, 1018302); // Item quality: - AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality); // Exceptional, Average, Low + AddHtmlLocalized(175, 60, 100, 25, 1018305 - quality); // Exceptional, Average, Low AddHtmlLocalized(20, 80, 170, 25, 1011572); // Item Cost : AddLabel(175, 80, 0x34, def.SilverCost.ToString("N0")); // NOTE: Added 'N0' @@ -44,7 +43,6 @@ namespace Server.Factions AddHtmlLocalized(20, 100, 170, 25, 1011573); // Your Silver : AddLabel(175, 100, 0x34, availableSilver.ToString("N0")); // NOTE: Added 'N0' - AddRadio(20, 140, 210, 211, true, 1); AddLabel(55, 140, m_Faction.Definition.HuePrimary - 1, "*****"); AddHtmlLocalized(150, 140, 150, 25, 1011570); // Primary Color @@ -53,7 +51,6 @@ namespace Server.Factions AddLabel(55, 160, m_Faction.Definition.HueSecondary - 1, "*****"); AddHtmlLocalized(150, 160, 150, 25, 1011571); // Secondary Color - AddHtmlLocalized(55, 200, 200, 25, 1011011); // CONTINUE AddButton(20, 200, 4005, 4007, 1); diff --git a/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs b/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs index ac307a999..d3268183d 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/FactionStoneGump.cs @@ -7,8 +7,8 @@ namespace Server.Factions { public class FactionStoneGump : FactionGump { - private Faction m_Faction; - private PlayerMobile m_From; + private readonly Faction m_Faction; + private readonly PlayerMobile m_From; public FactionStoneGump(PlayerMobile from, Faction faction) : base(20, 30) { @@ -20,8 +20,6 @@ namespace Server.Factions AddBackground(0, 0, 550, 440, 5054); AddBackground(10, 10, 530, 420, 3000); - #region General - AddPage(1); AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false); @@ -79,10 +77,6 @@ namespace Server.Factions AddHtmlLocalized(55, 300, 200, 20, 1011441); // EXIT AddButton(20, 300, 4005, 4007, 0); - #endregion - - #region City Status - AddPage(2); AddHtmlLocalized(20, 30, 250, 20, 1011430); // CITY STATUS @@ -109,7 +103,6 @@ namespace Server.Factions } } - AddImage(20, 300, 2361); AddHtmlLocalized(45, 295, 300, 20, 1011491); // sigil may be recaptured @@ -119,10 +112,6 @@ namespace Server.Factions AddHtmlLocalized(55, 350, 100, 20, 1011447); // BACK AddButton(20, 350, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region Statistics - AddPage(4); AddHtmlLocalized(20, 30, 150, 20, 1011444); // STATISTICS @@ -139,10 +128,6 @@ namespace Server.Factions AddHtmlLocalized(55, 250, 100, 20, 1011447); // BACK AddButton(20, 250, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region Merchant Options - if ((pl == null || pl.MerchantTitle == MerchantTitle.None) && isMerchantQualified) { AddPage(5); @@ -169,14 +154,8 @@ namespace Server.Factions AddButton(20, 340, 4005, 4007, 0, GumpButtonType.Page, 1); } - #endregion - - #region Commander Options - if (faction.IsCommander(from)) { - #region General - AddPage(6); AddHtmlLocalized(20, 30, 200, 20, 1011461); // COMMANDER OPTIONS @@ -202,10 +181,6 @@ namespace Server.Factions AddHtmlLocalized(55, 310, 100, 20, 1011447); // BACK AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region Town Finance - if (faction.Silver >= 10000) { AddPage(7); @@ -230,10 +205,6 @@ namespace Server.Factions AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1); } - #endregion - - #region Change Tithe Rate - AddPage(8); AddHtmlLocalized(20, 30, 400, 20, 1011479); // Select the % for the new tithe rate @@ -256,11 +227,7 @@ namespace Server.Factions AddHtmlLocalized(55, 310, 300, 20, 1011447); // BACK AddButton(20, 310, 4005, 4007, 0, GumpButtonType.Page, 1); - - #endregion } - - #endregion } public override int ButtonTypes => 4; @@ -273,84 +240,84 @@ namespace Server.Factions switch (type) { case 0: // general - { - switch (index) { - case 0: // vote + switch (index) { - m_From.SendGump(new ElectionGump(m_From, m_Faction.Election)); - break; + case 0: // vote + { + m_From.SendGump(new ElectionGump(m_From, m_Faction.Election)); + break; + } + case 1: // leave + { + m_From.SendGump(new LeaveFactionGump(m_From, m_Faction)); + break; + } } - case 1: // leave - { - m_From.SendGump(new LeaveFactionGump(m_From, m_Faction)); - break; - } - } - break; - } + break; + } case 1: // merchant title - { - if (index >= 0 && index <= MerchantTitles.Info.Length) { - PlayerState pl = PlayerState.Find(m_From); - - MerchantTitle newTitle = (MerchantTitle)index; - MerchantTitleInfo mti = MerchantTitles.GetInfo(newTitle); - - if (mti == null) + if (index >= 0 && index <= MerchantTitles.Info.Length) { - m_From.SendLocalizedMessage(1010120); // Your merchant title has been removed + PlayerState pl = PlayerState.Find(m_From); - if (pl != null) - pl.MerchantTitle = newTitle; - } - else if (MerchantTitles.IsQualified(m_From, mti)) - { - m_From.SendLocalizedMessage(mti.Assigned); + MerchantTitle newTitle = (MerchantTitle)index; + MerchantTitleInfo mti = MerchantTitles.GetInfo(newTitle); - if (pl != null) - pl.MerchantTitle = newTitle; - } - } - - break; - } - case 2: // transfer silver - { - if (!m_Faction.IsCommander(m_From)) - return; - - List towns = Town.Towns; - - if (index >= 0 && index < towns.Count) - { - Town town = towns[index]; - - if (town.Owner == m_Faction) - if (m_Faction.Silver >= 10000) + if (mti == null) { - m_Faction.Silver -= 10000; - town.Silver += 10000; + m_From.SendLocalizedMessage(1010120); // Your merchant title has been removed - // 10k in silver has been received by: - m_From.SendLocalizedMessage(1042726, true, $" {town.Definition.FriendlyName}"); + if (pl != null) + pl.MerchantTitle = newTitle; } + else if (MerchantTitles.IsQualified(m_From, mti)) + { + m_From.SendLocalizedMessage(mti.Assigned); + + if (pl != null) + pl.MerchantTitle = newTitle; + } + } + + break; } + case 2: // transfer silver + { + if (!m_Faction.IsCommander(m_From)) + return; - break; - } + List towns = Town.Towns; + + if (index >= 0 && index < towns.Count) + { + Town town = towns[index]; + + if (town.Owner == m_Faction) + if (m_Faction.Silver >= 10000) + { + m_Faction.Silver -= 10000; + town.Silver += 10000; + + // 10k in silver has been received by: + m_From.SendLocalizedMessage(1042726, true, $" {town.Definition.FriendlyName}"); + } + } + + break; + } case 3: // change tithe - { - if (!m_Faction.IsCommander(m_From)) - return; + { + if (!m_Faction.IsCommander(m_From)) + return; - if (index >= 0 && index <= 10) - m_Faction.Tithe = index * 10; + if (index >= 0 && index <= 10) + m_Faction.Tithe = index * 10; - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs b/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs index 35426e605..8597459f4 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/FinanceGump.cs @@ -9,15 +9,15 @@ namespace Server.Factions { public class FinanceGump : FactionGump { - private static int[] m_PriceOffsets = + private static readonly int[] m_PriceOffsets = { -30, -25, -20, -15, -10, -5, +50, +100, +150, +200, +250, +300 }; - private Faction m_Faction; - private PlayerMobile m_From; - private Town m_Town; + private readonly Faction m_Faction; + private readonly PlayerMobile m_From; + private readonly Town m_Town; public FinanceGump(PlayerMobile from, Faction faction, Town town) : base(50, 50) { @@ -25,19 +25,15 @@ namespace Server.Factions m_Faction = faction; m_Town = town; - AddPage(0); AddBackground(0, 0, 320, 410, 5054); AddBackground(10, 10, 300, 390, 3000); - #region General - AddPage(1); AddHtmlLocalized(20, 30, 260, 25, 1011541); // FINANCE MINISTER - AddHtmlLocalized(55, 90, 200, 25, 1011539); // CHANGE PRICES AddButton(20, 90, 4005, 4007, 0, GumpButtonType.Page, 2); @@ -50,10 +46,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011441); // EXIT AddButton(20, 360, 4005, 4007, 0); - #endregion - - #region Change Prices - AddPage(2); AddHtmlLocalized(20, 30, 200, 25, 1011539); // CHANGE PRICES @@ -82,10 +74,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region Buy Shopkeepers - AddPage(3); AddHtmlLocalized(20, 30, 200, 25, 1011540); // BUY SHOPKEEPERS @@ -101,13 +89,9 @@ namespace Server.Factions AddHtmlText(100, 90 + i * 40, 200, 25, list.Definition.Label, false, false); } - AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page + AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region View Finances - AddPage(4); int financeUpkeep = town.FinanceUpkeep; @@ -115,7 +99,6 @@ namespace Server.Factions int dailyIncome = town.DailyIncome; int netCashFlow = town.NetCashFlow; - AddHtmlLocalized(20, 30, 300, 25, 1011524); // FINANCE STATEMENT AddHtmlLocalized(20, 80, 300, 25, 1011538); // Current total money for town : @@ -136,10 +119,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region Shopkeeper Pages - for (int i = 0; i < vendorLists.Count; ++i) { VendorList vendorList = vendorLists[i]; @@ -176,8 +155,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3); } - - #endregion } public override int ButtonTypes => 2; @@ -196,96 +173,96 @@ namespace Server.Factions switch (type) { case 0: // general - { - switch (index) { - case 0: // set price + switch (index) { - int[] switches = info.Switches; + case 0: // set price + { + int[] switches = info.Switches; - if (switches.Length == 0) - break; + if (switches.Length == 0) + break; - int opt = switches[0]; - int newTax = 0; + int opt = switches[0]; + int newTax = 0; - if (opt >= 1 && opt <= m_PriceOffsets.Length) - newTax = m_PriceOffsets[opt - 1]; + if (opt >= 1 && opt <= m_PriceOffsets.Length) + newTax = m_PriceOffsets[opt - 1]; - if (m_Town.Tax == newTax) - break; + if (m_Town.Tax == newTax) + break; - if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady) - { - TimeSpan remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod); + if (m_From.AccessLevel == AccessLevel.Player && !m_Town.TaxChangeReady) + { + TimeSpan remaining = DateTime.UtcNow - (m_Town.LastTaxChange + Town.TaxChangePeriod); - if (remaining.TotalMinutes < 4) - m_From.SendLocalizedMessage( - 1042165); // You must wait a short while before changing prices again. - else if (remaining.TotalMinutes < 10) - m_From.SendLocalizedMessage( - 1042166); // You must wait several minutes before changing prices again. - else if (remaining.TotalHours < 1) - m_From.SendLocalizedMessage( - 1042167); // You must wait up to an hour before changing prices again. - else if (remaining.TotalHours < 4) - m_From.SendLocalizedMessage( - 1042168); // You must wait a few hours before changing prices again. - else - m_From.SendLocalizedMessage( - 1042169); // You must wait several hours before changing prices again. - } - else - { - m_Town.Tax = newTax; + if (remaining.TotalMinutes < 4) + m_From.SendLocalizedMessage( + 1042165); // You must wait a short while before changing prices again. + else if (remaining.TotalMinutes < 10) + m_From.SendLocalizedMessage( + 1042166); // You must wait several minutes before changing prices again. + else if (remaining.TotalHours < 1) + m_From.SendLocalizedMessage( + 1042167); // You must wait up to an hour before changing prices again. + else if (remaining.TotalHours < 4) + m_From.SendLocalizedMessage( + 1042168); // You must wait a few hours before changing prices again. + else + m_From.SendLocalizedMessage( + 1042169); // You must wait several hours before changing prices again. + } + else + { + m_Town.Tax = newTax; - if (m_From.AccessLevel == AccessLevel.Player) - m_Town.LastTaxChange = DateTime.UtcNow; - } + if (m_From.AccessLevel == AccessLevel.Player) + m_Town.LastTaxChange = DateTime.UtcNow; + } - break; + break; + } } - } - break; - } + break; + } case 1: // make vendor - { - List vendorLists = m_Town.VendorLists; - - if (index >= 0 && index < vendorLists.Count) { - VendorList vendorList = vendorLists[index]; + List vendorLists = m_Town.VendorLists; - if (Town.FromRegion(m_From.Region) != m_Town) + if (index >= 0 && index < vendorLists.Count) { - m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items - } - else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum) - { - m_From.SendLocalizedMessage( - 1010306); // You currently have too many of this enhancement type to place another - } - else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null) - { - m_From.SendMessage("You cannot place a vendor here"); - } - else if (m_Town.Silver >= vendorList.Definition.Price) - { - BaseFactionVendor vendor = vendorList.Construct(m_Town, m_Faction); + VendorList vendorList = vendorLists[index]; - if (vendor != null) + if (Town.FromRegion(m_From.Region) != m_Town) { - m_Town.Silver -= vendorList.Definition.Price; + m_From.SendLocalizedMessage(1010305); // You must be in your controlled city to buy Items + } + else if (vendorList.Vendors.Count >= vendorList.Definition.Maximum) + { + m_From.SendLocalizedMessage( + 1010306); // You currently have too many of this enhancement type to place another + } + else if (BaseBoat.FindBoatAt(m_From.Location, m_From.Map) != null) + { + m_From.SendMessage("You cannot place a vendor here"); + } + else if (m_Town.Silver >= vendorList.Definition.Price) + { + BaseFactionVendor vendor = vendorList.Construct(m_Town, m_Faction); - vendor.MoveToWorld(m_From.Location, m_From.Map); - vendor.Home = vendor.Location; + if (vendor != null) + { + m_Town.Silver -= vendorList.Definition.Price; + + vendor.MoveToWorld(m_From.Location, m_From.Map); + vendor.Home = vendor.Location; + } } } - } - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs b/Projects/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs index 97aedfca3..37dd44b6a 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/HorseBreederGump.cs @@ -7,8 +7,8 @@ namespace Server.Factions { public class HorseBreederGump : FactionGump { - private Faction m_Faction; - private PlayerMobile m_From; + private readonly Faction m_Faction; + private readonly PlayerMobile m_From; public HorseBreederGump(PlayerMobile from, Faction faction) : base(20, 30) { diff --git a/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs b/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs index f68d5d060..22fb4cdea 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/JoinStoneGump.cs @@ -6,8 +6,8 @@ namespace Server.Factions { public class JoinStoneGump : FactionGump { - private Faction m_Faction; - private PlayerMobile m_From; + private readonly Faction m_Faction; + private readonly PlayerMobile m_From; public JoinStoneGump(PlayerMobile from, Faction faction) : base(20, 30) { @@ -19,11 +19,9 @@ namespace Server.Factions AddBackground(0, 0, 550, 440, 5054); AddBackground(10, 10, 530, 420, 3000); - AddHtmlText(20, 30, 510, 20, faction.Definition.Header, false, false); AddHtmlText(20, 130, 510, 100, faction.Definition.About, true, true); - AddHtmlLocalized(20, 60, 100, 20, 1011429); // Led By : AddHtml(125, 60, 200, 20, faction.Commander != null ? faction.Commander.Name : "Nobody"); @@ -33,7 +31,6 @@ namespace Server.Factions else AddHtml(125, 80, 350, 20, $"{faction.Tithe}%"); - AddButton(20, 400, 4005, 4007, 1); AddHtmlLocalized(55, 400, 200, 20, 1011425); // JOIN THIS FACTION diff --git a/Projects/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs b/Projects/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs index 5c3ac78b7..38b5cfaf9 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/LeaveFactionGump.cs @@ -9,7 +9,7 @@ namespace Server.Factions public class LeaveFactionGump : FactionGump { private Faction m_Faction; - private PlayerMobile m_From; + private readonly PlayerMobile m_From; public LeaveFactionGump(PlayerMobile from, Faction faction) : base(20, 30) { @@ -37,56 +37,56 @@ namespace Server.Factions switch (info.ButtonID) { case 1: // continue - { - if (!(m_From.Guild is Guild guild)) { - PlayerState pl = PlayerState.Find(m_From); - - if (pl != null) + if (!(m_From.Guild is Guild guild)) { - pl.Leaving = DateTime.UtcNow; - - if (Faction.LeavePeriod == TimeSpan.FromDays(3.0)) - m_From.SendLocalizedMessage(1005065); // You will be removed from the faction in 3 days - else - m_From.SendMessage("You will be removed from the faction in {0} days.", - Faction.LeavePeriod.TotalDays); - } - } - else if (guild.Leader != m_From) - { - m_From.SendLocalizedMessage( - 1005061); // You cannot quit the faction because you are not the guild master - } - else - { - m_From.SendLocalizedMessage(1042285); // Your guild is now quitting the faction. - - for (int i = 0; i < guild.Members.Count; ++i) - { - Mobile mob = guild.Members[i]; - PlayerState pl = PlayerState.Find(mob); + PlayerState pl = PlayerState.Find(m_From); if (pl != null) { pl.Leaving = DateTime.UtcNow; - if (Faction.LeavePeriod == TimeSpan.FromDays(3.0)) - mob.SendLocalizedMessage(1005060); // Your guild will quit the faction in 3 days + if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod) + m_From.SendLocalizedMessage(1005065); // You will be removed from the faction in 3 days else - mob.SendMessage("Your guild will quit the faction in {0} days.", + m_From.SendMessage("You will be removed from the faction in {0} days.", Faction.LeavePeriod.TotalDays); } } - } + else if (guild.Leader != m_From) + { + m_From.SendLocalizedMessage( + 1005061); // You cannot quit the faction because you are not the guild master + } + else + { + m_From.SendLocalizedMessage(1042285); // Your guild is now quitting the faction. - break; - } + for (int i = 0; i < guild.Members.Count; ++i) + { + Mobile mob = guild.Members[i]; + PlayerState pl = PlayerState.Find(mob); + + if (pl != null) + { + pl.Leaving = DateTime.UtcNow; + + if (TimeSpan.FromDays(3.0) == Faction.LeavePeriod) + mob.SendLocalizedMessage(1005060); // Your guild will quit the faction in 3 days + else + mob.SendMessage("Your guild will quit the faction in {0} days.", + Faction.LeavePeriod.TotalDays); + } + } + } + + break; + } case 2: // cancel - { - m_From.SendLocalizedMessage(500737); // Canceled resignation. - break; - } + { + m_From.SendLocalizedMessage(500737); // Canceled resignation. + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Gumps/SheriffGump.cs b/Projects/Scripts/Engines/Factions/Gumps/SheriffGump.cs index 0eaa77a09..9481572ab 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/SheriffGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/SheriffGump.cs @@ -8,9 +8,9 @@ namespace Server.Factions { public class SheriffGump : FactionGump { - private Faction m_Faction; - private PlayerMobile m_From; - private Town m_Town; + private readonly Faction m_Faction; + private readonly PlayerMobile m_From; + private readonly Town m_Town; public SheriffGump(PlayerMobile from, Faction faction, Town town) : base(50, 50) { @@ -18,14 +18,11 @@ namespace Server.Factions m_Faction = faction; m_Town = town; - AddPage(0); AddBackground(0, 0, 320, 410, 5054); AddBackground(10, 10, 300, 390, 3000); - #region General - AddPage(1); AddHtmlLocalized(20, 30, 260, 25, 1011431); // Sheriff @@ -39,10 +36,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011441); // Exit AddButton(20, 360, 4005, 4007, 0); - #endregion - - #region Finances - AddPage(2); int financeUpkeep = town.FinanceUpkeep; @@ -70,10 +63,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region Hire Guards - AddPage(3); AddHtmlLocalized(20, 30, 300, 25, 1011494); // HIRE GUARDS @@ -93,10 +82,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 1); - #endregion - - #region Guard Pages - for (int i = 0; i < guardLists.Count; ++i) { GuardList guardList = guardLists[i]; @@ -130,8 +115,6 @@ namespace Server.Factions AddHtmlLocalized(55, 360, 200, 25, 1011067); // Previous page AddButton(20, 360, 4005, 4007, 0, GumpButtonType.Page, 3); } - - #endregion } private void CenterItem(int itemID, int x, int y, int w, int h) diff --git a/Projects/Scripts/Engines/Factions/Gumps/TownStoneGump.cs b/Projects/Scripts/Engines/Factions/Gumps/TownStoneGump.cs index ddae02bb0..083cad6cb 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/TownStoneGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/TownStoneGump.cs @@ -7,9 +7,9 @@ namespace Server.Factions { public class TownStoneGump : FactionGump { - private Faction m_Faction; - private PlayerMobile m_From; - private Town m_Town; + private readonly Faction m_Faction; + private readonly PlayerMobile m_From; + private readonly Town m_Town; public TownStoneGump(PlayerMobile from, Faction faction, Town town) : base(50, 50) { @@ -51,65 +51,65 @@ namespace Server.Factions switch (info.ButtonID) { case 1: // hire sheriff - { - if (m_Town.Sheriff != null) { - m_From.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one - } - else - { - m_From.SendLocalizedMessage(1010347); // Who shall be your new sheriff - m_From.BeginTarget(12, false, TargetFlags.None, HireSheriff_OnTarget); - } + if (m_Town.Sheriff != null) + { + m_From.SendLocalizedMessage(1010342); // You must fire your Sheriff before you can elect a new one + } + else + { + m_From.SendLocalizedMessage(1010347); // Who shall be your new sheriff + m_From.BeginTarget(12, false, TargetFlags.None, HireSheriff_OnTarget); + } - break; - } + break; + } case 2: // hire finance minister - { - if (m_Town.Finance != null) { - m_From.SendLocalizedMessage( - 1010345); // You must fire your finance minister before you can elect a new one - } - else - { - m_From.SendLocalizedMessage(1010348); // Who shall be your new Minister of Finances? - m_From.BeginTarget(12, false, TargetFlags.None, HireFinanceMinister_OnTarget); - } + if (m_Town.Finance != null) + { + m_From.SendLocalizedMessage( + 1010345); // You must fire your finance minister before you can elect a new one + } + else + { + m_From.SendLocalizedMessage(1010348); // Who shall be your new Minister of Finances? + m_From.BeginTarget(12, false, TargetFlags.None, HireFinanceMinister_OnTarget); + } - break; - } + break; + } case 3: // fire sheriff - { - if (m_Town.Sheriff == null) { - m_From.SendLocalizedMessage(1010350); // You need to elect a sheriff before you can fire one - } - else - { - m_From.SendLocalizedMessage(1010349); // You have fired your sheriff - m_Town.Sheriff.SendLocalizedMessage(1010270); // You have been fired as Sheriff - m_Town.Sheriff = null; - } + if (m_Town.Sheriff == null) + { + m_From.SendLocalizedMessage(1010350); // You need to elect a sheriff before you can fire one + } + else + { + m_From.SendLocalizedMessage(1010349); // You have fired your sheriff + m_Town.Sheriff.SendLocalizedMessage(1010270); // You have been fired as Sheriff + m_Town.Sheriff = null; + } - break; - } + break; + } case 4: // fire finance minister - { - if (m_Town.Finance == null) { - m_From.SendLocalizedMessage( - 1010352); // You need to elect a financial minister before you can fire one - } - else - { - m_From.SendLocalizedMessage(1010351); // You have fired your financial Minister - m_Town.Finance.SendLocalizedMessage(1010151); // You have been fired as Finance Minister - m_Town.Finance = null; - } + if (m_Town.Finance == null) + { + m_From.SendLocalizedMessage( + 1010352); // You need to elect a financial minister before you can fire one + } + else + { + m_From.SendLocalizedMessage(1010351); // You have fired your financial Minister + m_Town.Finance.SendLocalizedMessage(1010151); // You have been fired as Finance Minister + m_Town.Finance = null; + } - break; - } + break; + } } } diff --git a/Projects/Scripts/Engines/Factions/Gumps/VoteGump.cs b/Projects/Scripts/Engines/Factions/Gumps/VoteGump.cs index 98a697b06..8d21dd21b 100644 --- a/Projects/Scripts/Engines/Factions/Gumps/VoteGump.cs +++ b/Projects/Scripts/Engines/Factions/Gumps/VoteGump.cs @@ -6,8 +6,8 @@ namespace Server.Factions { public class VoteGump : FactionGump { - private Election m_Election; - private PlayerMobile m_From; + private readonly Election m_Election; + private readonly PlayerMobile m_From; public VoteGump(PlayerMobile from, Election election) : base(50, 50) { diff --git a/Projects/Scripts/Engines/Factions/Instances/Factions/CouncilOfMages.cs b/Projects/Scripts/Engines/Factions/Instances/Factions/CouncilOfMages.cs index bfd26b307..5fc4142bf 100644 --- a/Projects/Scripts/Engines/Factions/Instances/Factions/CouncilOfMages.cs +++ b/Projects/Scripts/Engines/Factions/Instances/Factions/CouncilOfMages.cs @@ -97,10 +97,9 @@ namespace Server.Factions new TextDefinition(1011507, "SORCERESS"), new TextDefinition(1011501, "Hire Sorceress")), new GuardDefinition(typeof(FactionWizard), 0x13F8, 8000, 4000, 10, new TextDefinition(1011508, "ELDER WIZARD"), new TextDefinition(1011502, "Hire Elder Wizard")) - } - ); + }); } - public static Faction Instance{ get; private set; } + public static Faction Instance { get; private set; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Instances/Factions/Minax.cs b/Projects/Scripts/Engines/Factions/Instances/Factions/Minax.cs index 5fd3ca359..a7fb613d1 100644 --- a/Projects/Scripts/Engines/Factions/Instances/Factions/Minax.cs +++ b/Projects/Scripts/Engines/Factions/Instances/Factions/Minax.cs @@ -74,10 +74,9 @@ namespace Server.Factions new TextDefinition(1011505, "BERSERKER"), new TextDefinition(1011499, "Hire Berserker")), new GuardDefinition(typeof(FactionDragoon), 0x1439, 8000, 4000, 10, new TextDefinition(1011506, "DRAGOON"), new TextDefinition(1011500, "Hire Dragoon")) - } - ); + }); } - public static Faction Instance{ get; private set; } + public static Faction Instance { get; private set; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Instances/Factions/Shadowlords.cs b/Projects/Scripts/Engines/Factions/Instances/Factions/Shadowlords.cs index e3f5598da..23c2f0292 100644 --- a/Projects/Scripts/Engines/Factions/Instances/Factions/Shadowlords.cs +++ b/Projects/Scripts/Engines/Factions/Instances/Factions/Shadowlords.cs @@ -74,10 +74,9 @@ namespace Server.Factions new TextDefinition(1011512, "DEATH KNIGHT"), new TextDefinition(1011503, "Hire Death Knight")), new GuardDefinition(typeof(FactionNecromancer), 0x13F8, 8000, 4000, 10, new TextDefinition(1011513, "SHADOW MAGE"), new TextDefinition(1011504, "Hire Shadow Mage")) - } - ); + }); } - public static Faction Instance{ get; private set; } + public static Faction Instance { get; private set; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Instances/Factions/TrueBritannians.cs b/Projects/Scripts/Engines/Factions/Instances/Factions/TrueBritannians.cs index cd9215d10..8a531d6b8 100644 --- a/Projects/Scripts/Engines/Factions/Instances/Factions/TrueBritannians.cs +++ b/Projects/Scripts/Engines/Factions/Instances/Factions/TrueBritannians.cs @@ -79,10 +79,9 @@ namespace Server.Factions new TextDefinition(1011528, "KNIGHT"), new TextDefinition(1011497, "Hire Knight")), new GuardDefinition(typeof(FactionPaladin), 0x143F, 8000, 4000, 10, new TextDefinition(1011529, "PALADIN"), new TextDefinition(1011498, "Hire Paladin")) - } - ); + }); } - public static Faction Instance{ get; private set; } + public static Faction Instance { get; private set; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Factions/Items/BaseMonolith.cs b/Projects/Scripts/Engines/Factions/Items/BaseMonolith.cs index 2aba748c4..2353d34d8 100644 --- a/Projects/Scripts/Engines/Factions/Items/BaseMonolith.cs +++ b/Projects/Scripts/Engines/Factions/Items/BaseMonolith.cs @@ -64,7 +64,7 @@ namespace Server.Factions } } - public static List Monoliths{ get; set; } = new List(); + public static List Monoliths { get; set; } = new List(); public override void OnLocationChange(Point3D oldLocation) { @@ -117,12 +117,12 @@ namespace Server.Factions switch (version) { case 0: - { - Town = Town.ReadReference(reader); - Faction = Faction.ReadReference(reader); - m_Sigil = reader.ReadItem() as Sigil; - break; - } + { + Town = Town.ReadReference(reader); + Faction = Faction.ReadReference(reader); + m_Sigil = reader.ReadItem() as Sigil; + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Items/FactionStone.cs b/Projects/Scripts/Engines/Factions/Items/FactionStone.cs index 3e3e2e4bc..ff98a3617 100644 --- a/Projects/Scripts/Engines/Factions/Items/FactionStone.cs +++ b/Projects/Scripts/Engines/Factions/Items/FactionStone.cs @@ -89,10 +89,10 @@ namespace Server.Factions switch (version) { case 0: - { - Faction = Faction.ReadReference(reader); - break; - } + { + Faction = Faction.ReadReference(reader); + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Items/JoinStone.cs b/Projects/Scripts/Engines/Factions/Items/JoinStone.cs index d80fd2e9c..a498a9d7b 100644 --- a/Projects/Scripts/Engines/Factions/Items/JoinStone.cs +++ b/Projects/Scripts/Engines/Factions/Items/JoinStone.cs @@ -64,10 +64,10 @@ namespace Server.Factions switch (version) { case 0: - { - Faction = Faction.ReadReference(reader); - break; - } + { + Faction = Faction.ReadReference(reader); + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs index a1d4ab714..0f3565168 100644 --- a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs +++ b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/ClarityPotion.cs @@ -40,7 +40,7 @@ namespace Server from.PlaySound(0x1EE); from.AddStatMod(new StatMod(StatType.Int, "clarity-potion", amount, TimeSpan.FromMinutes(time))); - Timer.DelayCall(TimeSpan.FromMinutes(time), delegate { from.EndAction(); }); + Timer.DelayCall(TimeSpan.FromMinutes(time), from.EndAction); return true; } @@ -62,4 +62,4 @@ namespace Server int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs index 8d7c828bf..ec2806b44 100644 --- a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs +++ b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/PowerFactionItem.cs @@ -9,7 +9,7 @@ namespace Server { public abstract class PowerFactionItem : Item { - private static WeightedItem[] _items = + private static readonly WeightedItem[] _items = { new WeightedItem(30, typeof(GemOfEmpowerment)), new WeightedItem(25, typeof(BloodRose)), @@ -61,8 +61,7 @@ namespace Server killer.SendSound(1470); killer.LocalOverheadMessage( MessageType.Regular, 2119, false, - "You notice a strange item on the corpse, and decide to pick it up." - ); + "You notice a strange item on the corpse, and decide to pick it up."); try { @@ -101,19 +100,16 @@ namespace Server "The object vanishes from your hands as you touch it."); Timer.DelayCall(TimeSpan.FromSeconds(1.0), - delegate - { - from.LocalOverheadMessage(MessageType.Regular, 2118, false, - "You feel a strange tingling sensation throughout your body."); - }); + () => from.LocalOverheadMessage(MessageType.Regular, 2118, false, + "You feel a strange tingling sensation throughout your body.")); Timer.DelayCall(TimeSpan.FromSeconds(4.0), - delegate { from.LocalOverheadMessage(MessageType.Regular, 2118, false, "Your skin begins to burn."); }); + () => { from.LocalOverheadMessage(MessageType.Regular, 2118, false, "Your skin begins to burn."); }); new DestructionTimer(from).Start(); Delete(); - //from.SendMessage( "You must be in a faction to use this item." ); + // from.SendMessage( "You must be in a faction to use this item." ); } else if (Use(from)) { @@ -138,7 +134,7 @@ namespace Server private sealed class DestructionTimer : Timer { - private Mobile _mobile; + private readonly Mobile _mobile; private bool _screamed; @@ -171,9 +167,9 @@ namespace Server Type = type; } - public int Weight{ get; } + public int Weight { get; } - public Type Type{ get; } + public Type Type { get; } public Item Construct() => ActivatorUtil.CreateInstance(Type) as Item; } diff --git a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs index 334c831bb..2e7f5acb5 100644 --- a/Projects/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs +++ b/Projects/Scripts/Engines/Factions/Items/Power Faction Items/StormsEye.cs @@ -23,7 +23,7 @@ namespace Server public override bool Use(Mobile user) { if (Movable) - user.BeginTarget(12, true, TargetFlags.None, delegate(Mobile from, object obj) + user.BeginTarget(12, true, TargetFlags.None, (from, obj) => { if (Movable && !Deleted) if (obj is IPoint3D pt) @@ -40,10 +40,9 @@ namespace Server Effects.SendMovingEffect( from, new Entity(Serial.Zero, origin, facet), - ItemID & 0x3FFF, 7, 0, false, false, Hue - 1 - ); + ItemID & 0x3FFF, 7, 0, false, false, Hue - 1); - Timer.DelayCall(TimeSpan.FromSeconds(0.5), delegate + Timer.DelayCall(TimeSpan.FromSeconds(0.5), () => { Delete(); @@ -52,10 +51,9 @@ namespace Server Effects.SendLocationEffect( origin, facet, - 14284, 96, 1, 0, 2 - ); + 14284, 96, 1, 0, 2); - Timer.DelayCall(TimeSpan.FromSeconds(1.0), delegate + Timer.DelayCall(TimeSpan.FromSeconds(1.0), () => { List targets = facet.GetMobilesInRange(origin, 12).Where(mob => from.CanBeHarmful(mob, false) && mob.InLOS(new Point3D(origin, origin.Z + 1)) && @@ -72,8 +70,7 @@ namespace Server Effects.SendMovingEffect( new Entity(Serial.Zero, new Point3D(origin, origin.Z + 4), facet), mob, - 14068, 1, 32, false, false, 1111, 2 - ); + 14068, 1, 32, false, false, 1111, 2); from.DoHarmful(mob); @@ -84,7 +81,7 @@ namespace Server SpellHelper.Damage(TimeSpan.FromSeconds(1.00), mob, from, damage / 3.0, 0, 0, 0, 0, 100); - Timer.DelayCall(TimeSpan.FromSeconds(0.50), delegate { mob.PlaySound(0x1FB); }); + Timer.DelayCall(TimeSpan.FromSeconds(0.50), mob.PlaySound, 0x1FB); } }); }); diff --git a/Projects/Scripts/Engines/Factions/Items/Sigil.cs b/Projects/Scripts/Engines/Factions/Items/Sigil.cs index 0cc85046b..2511353a2 100644 --- a/Projects/Scripts/Engines/Factions/Items/Sigil.cs +++ b/Projects/Scripts/Engines/Factions/Items/Sigil.cs @@ -41,16 +41,16 @@ namespace Server.Factions } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] - public DateTime LastStolen{ get; set; } + public DateTime LastStolen { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] - public DateTime GraceStart{ get; set; } + public DateTime GraceStart { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] - public DateTime CorruptionStart{ get; set; } + public DateTime CorruptionStart { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] - public DateTime PurificationStart{ get; set; } + public DateTime PurificationStart { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] public Town Town @@ -86,7 +86,7 @@ namespace Server.Factions } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] - public BaseMonolith LastMonolith{ get; set; } + public BaseMonolith LastMonolith { get; set; } [CommandProperty(AccessLevel.Counselor)] public bool IsBeingCorrupted => LastMonolith is StrongholdMonolith && LastMonolith.Faction == m_Corrupting && @@ -118,7 +118,7 @@ namespace Server.Factions } } - public static List Sigils{ get; } = new List(); + public static List Sigils { get; } = new List(); public void Update() { @@ -240,8 +240,6 @@ namespace Server.Factions if (Deleted || !IsChildOf(from.Backpack)) return; - #region Give To Mobile - if (obj is Mobile) { if (obj is PlayerMobile targ) @@ -274,16 +272,11 @@ namespace Server.Factions } else { - from.SendLocalizedMessage(1005221); //You cannot give the sigil to them + from.SendLocalizedMessage(1005221); // You cannot give the sigil to them } } - - #endregion - else if (obj is BaseMonolith) { - #region Put in Stronghold - if (obj is StrongholdMonolith sm) { if (sm.Faction == null || sm.Faction != Faction.Find(from)) @@ -327,11 +320,6 @@ namespace Server.Factions PurificationStart = DateTime.MinValue; } } - - #endregion - - #region Put in Town - else if (obj is TownMonolith tm) { if (tm.Town == null || tm.Town != m_Town) @@ -355,12 +343,10 @@ namespace Server.Factions m_Corrupted = null; } } - - #endregion } else { - from.SendLocalizedMessage(1005224); // You can't use the sigil on that + from.SendLocalizedMessage(1005224); // You can't use the sigil on that } Update(); @@ -393,25 +379,25 @@ namespace Server.Factions switch (version) { case 0: - { - m_Town = Town.ReadReference(reader); - m_Corrupted = Faction.ReadReference(reader); - m_Corrupting = Faction.ReadReference(reader); + { + m_Town = Town.ReadReference(reader); + m_Corrupted = Faction.ReadReference(reader); + m_Corrupting = Faction.ReadReference(reader); - LastMonolith = reader.ReadItem() as BaseMonolith; + LastMonolith = reader.ReadItem() as BaseMonolith; - LastStolen = reader.ReadDateTime(); - GraceStart = reader.ReadDateTime(); - CorruptionStart = reader.ReadDateTime(); - PurificationStart = reader.ReadDateTime(); + LastStolen = reader.ReadDateTime(); + GraceStart = reader.ReadDateTime(); + CorruptionStart = reader.ReadDateTime(); + PurificationStart = reader.ReadDateTime(); - Update(); + Update(); - if (RootParent is Mobile mob) - mob.SolidHueOverride = OwnershipHue; + if (RootParent is Mobile mob) + mob.SolidHueOverride = OwnershipHue; - break; - } + break; + } } } diff --git a/Projects/Scripts/Engines/Factions/Items/StrongholdMonolith.cs b/Projects/Scripts/Engines/Factions/Items/StrongholdMonolith.cs index 011658a65..fda116e90 100644 --- a/Projects/Scripts/Engines/Factions/Items/StrongholdMonolith.cs +++ b/Projects/Scripts/Engines/Factions/Items/StrongholdMonolith.cs @@ -4,7 +4,6 @@ namespace Server.Factions { public StrongholdMonolith(Town town = null, Faction faction = null) : base(town, faction) { - } public StrongholdMonolith(Serial serial) : base(serial) diff --git a/Projects/Scripts/Engines/Factions/Items/TownStone.cs b/Projects/Scripts/Engines/Factions/Items/TownStone.cs index c22e870ef..f87d7b481 100644 --- a/Projects/Scripts/Engines/Factions/Items/TownStone.cs +++ b/Projects/Scripts/Engines/Factions/Items/TownStone.cs @@ -41,7 +41,7 @@ namespace Server.Factions if (faction == null && from.AccessLevel < AccessLevel.GameMaster) return; // TODO: Message? - if (m_Town.Owner == null || from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner) + if (m_Town.Owner == null || (from.AccessLevel < AccessLevel.GameMaster && faction != m_Town.Owner)) from.SendLocalizedMessage(1010332); // Your faction does not control this town else if (!m_Town.Owner.IsCommander(from)) from.SendLocalizedMessage(1005242); // Only faction Leaders can use townstones @@ -69,10 +69,10 @@ namespace Server.Factions switch (version) { case 0: - { - Town = Town.ReadReference(reader); - break; - } + { + Town = Town.ReadReference(reader); + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs b/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs index 5de86b716..bc52ffc65 100644 --- a/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs +++ b/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrap.cs @@ -31,13 +31,13 @@ namespace Server.Factions } [CommandProperty(AccessLevel.GameMaster)] - public Faction Faction{ get; set; } + public Faction Faction { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Placer{ get; set; } + public Mobile Placer { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime TimeOfPlacement{ get; set; } + public DateTime TimeOfPlacement { get; set; } public virtual int EffectSound => 0; @@ -120,32 +120,32 @@ namespace Server.Factions switch (AllowedPlacing) { case AllowedPlacing.FactionStronghold: - { - StrongholdRegion region = Region.Find(p, m).GetRegion(); + { + StrongholdRegion region = Region.Find(p, m).GetRegion(); - if (region != null && region.Faction == Faction) - return 0; + if (region != null && region.Faction == Faction) + return 0; - return 1010355; // This trap can only be placed in your stronghold - } + return 1010355; // This trap can only be placed in your stronghold + } case AllowedPlacing.AnyFactionTown: - { - Town town = Town.FromRegion(Region.Find(p, m)); + { + Town town = Town.FromRegion(Region.Find(p, m)); - if (town != null) - return 0; + if (town != null) + return 0; - return 1010356; // This trap can only be placed in a faction town - } + return 1010356; // This trap can only be placed in a faction town + } case AllowedPlacing.ControlledFactionTown: - { - Town town = Town.FromRegion(Region.Find(p, m)); + { + Town town = Town.FromRegion(Region.Find(p, m)); - if (town != null && town.Owner == Faction) - return 0; + if (town != null && town.Owner == Faction) + return 0; - return 1010357; // This trap can only be placed in a town your faction controls - } + return 1010357; // This trap can only be placed in a town your faction controls + } } return 0; diff --git a/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs b/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs index bceb7c86e..817ab05c6 100644 --- a/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs +++ b/Projects/Scripts/Engines/Factions/Items/Traps/BaseFactionTrapDeed.cs @@ -9,7 +9,7 @@ namespace Server.Factions { private Faction m_Faction; - public BaseFactionTrapDeed(int itemID= 0x14F0) : base(itemID) + public BaseFactionTrapDeed(int itemID = 0x14F0) : base(itemID) { Weight = 1.0; LootType = LootType.Blessed; @@ -19,7 +19,7 @@ namespace Server.Factions { } - public abstract Type TrapType{ get; } + public abstract Type TrapType { get; } [CommandProperty(AccessLevel.GameMaster)] public Faction Faction @@ -34,8 +34,6 @@ namespace Server.Factions } } - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -45,8 +43,6 @@ namespace Server.Factions return 1; } - #endregion - public virtual BaseFactionTrap Construct(Mobile from) { try diff --git a/Projects/Scripts/Engines/Factions/Items/Traps/FactionTrapRemovalKit.cs b/Projects/Scripts/Engines/Factions/Items/Traps/FactionTrapRemovalKit.cs index 059821335..89ef35787 100644 --- a/Projects/Scripts/Engines/Factions/Items/Traps/FactionTrapRemovalKit.cs +++ b/Projects/Scripts/Engines/Factions/Items/Traps/FactionTrapRemovalKit.cs @@ -14,7 +14,7 @@ namespace Server.Factions } [CommandProperty(AccessLevel.GameMaster)] - public int Charges{ get; set; } + public int Charges { get; set; } public override int LabelNumber => 1041508; // a faction trap removal kit @@ -56,15 +56,15 @@ namespace Server.Factions switch (version) { case 1: - { - Charges = reader.ReadEncodedInt(); - break; - } + { + Charges = reader.ReadEncodedInt(); + break; + } case 0: - { - Charges = 25; - break; - } + { + Charges = 25; + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs b/Projects/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs index ba6ad51d9..33055cf1e 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/FactionWarHorse.cs @@ -98,10 +98,10 @@ namespace Server.Factions switch (version) { case 0: - { - Faction = Faction.ReadReference(reader); - break; - } + { + Faction = Faction.ReadReference(reader); + break; + } } } } diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs b/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs index eddfdfa22..670f5b758 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Guards/BaseFactionGuard.cs @@ -11,7 +11,7 @@ namespace Server.Factions { private const int ListenRange = 12; - private static Type[] m_StrongPotions = + private static readonly Type[] m_StrongPotions = { typeof(GreaterHealPotion), typeof(GreaterHealPotion), typeof(GreaterHealPotion), typeof(GreaterCurePotion), typeof(GreaterCurePotion), typeof(GreaterCurePotion), @@ -21,7 +21,7 @@ namespace Server.Factions typeof(GreaterExplosionPotion) }; - private static Type[] m_WeakPotions = + private static readonly Type[] m_WeakPotions = { typeof(HealPotion), typeof(HealPotion), typeof(HealPotion), typeof(CurePotion), typeof(CurePotion), typeof(CurePotion), @@ -62,7 +62,7 @@ namespace Server.Factions } } - public Orders Orders{ get; private set; } + public Orders Orders { get; private set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public Town Town @@ -76,7 +76,7 @@ namespace Server.Factions } } - public abstract GuardAI GuardAI{ get; } + public abstract GuardAI GuardAI { get; } protected override BaseAI ForcedAI => new FactionGuardAI(this); @@ -443,7 +443,7 @@ namespace Server.Factions public class VirtualMount : IMount { - private VirtualMountItem m_Item; + private readonly VirtualMountItem m_Item; public VirtualMount(VirtualMountItem item) => m_Item = item; @@ -460,7 +460,7 @@ namespace Server.Factions public class VirtualMountItem : Item, IMountItem { - private VirtualMount m_Mount; + private readonly VirtualMount m_Mount; public VirtualMountItem(Mobile mob) : base(0x3EA0) { @@ -472,7 +472,7 @@ namespace Server.Factions public VirtualMountItem(Serial serial) : base(serial) => m_Mount = new VirtualMount(this); - public Mobile Rider{ get; private set; } + public Mobile Rider { get; private set; } public IMount Mount => m_Mount; diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs index 322db9c39..e991e889e 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -39,11 +39,11 @@ namespace Server.Factions Hold = hold; } - public Type Spell{ get; } + public Type Spell { get; } - public TimeSpan Hold{ get; } + public TimeSpan Hold { get; } - public int Chance{ get; } + public int Chance { get; } } public class SpellCombo @@ -52,8 +52,7 @@ namespace Server.Factions new ComboEntry(typeof(ParalyzeSpell), 20), new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)), new ComboEntry(typeof(PoisonSpell), 30), - new ComboEntry(typeof(EnergyBoltSpell)) - ); + new ComboEntry(typeof(EnergyBoltSpell))); public static readonly SpellCombo Strong = new SpellCombo(90, new ComboEntry(typeof(ParalyzeSpell), 20), @@ -62,8 +61,7 @@ namespace Server.Factions new ComboEntry(typeof(ExplosionSpell), 100, TimeSpan.FromSeconds(2.8)), new ComboEntry(typeof(EnergyBoltSpell)), new ComboEntry(typeof(PoisonSpell), 30), - new ComboEntry(typeof(EnergyBoltSpell)) - ); + new ComboEntry(typeof(EnergyBoltSpell))); public SpellCombo(int mana, params ComboEntry[] entries) { @@ -71,9 +69,9 @@ namespace Server.Factions Entries = entries; } - public int Mana{ get; } + public int Mana { get; } - public ComboEntry[] Entries{ get; } + public ComboEntry[] Entries { get; } public static Spell Process(Mobile mob, Mobile targ, ref SpellCombo combo, ref int index, ref DateTime releaseTime) { @@ -106,7 +104,7 @@ namespace Server.Factions private SpellCombo m_Combo; private int m_ComboIndex = -1; - private BaseFactionGuard m_Guard; + private readonly BaseFactionGuard m_Guard; private DateTime m_ReleaseTarget; public FactionGuardAI(BaseFactionGuard guard) : base(guard) => m_Guard = guard; @@ -344,11 +342,11 @@ namespace Server.Factions public void RunTo(Mobile m) { - /*if ( m.Paralyzed || m.Frozen ) + /*if (m.Paralyzed || m.Frozen) { - if ( m_Mobile.InRange( m, 1 ) ) + if (m_Mobile.InRange( m, 1 )) RunFrom( m ); - else if ( !m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 ) ) + else if (!m_Mobile.InRange( m, m_Mobile.RangeFight > 2 ? m_Mobile.RangeFight : 2 ) && !MoveTo( m, true, 1 )) OnFailedMove(); } else @@ -373,9 +371,9 @@ namespace Server.Factions public void OnFailedMove() { - /*if ( !m_Mobile.DisallowAllMoves && 20 > Utility.Random( 100 ) && IsAllowed( GuardAI.Magic ) ) + /*if (!m_Mobile.DisallowAllMoves && 20 > Utility.Random( 100 ) && IsAllowed( GuardAI.Magic )) { - if ( m_Mobile.Target != null ) + if (m_Mobile.Target != null) m_Mobile.Target.Cancel( m_Mobile, TargetCancelType.Canceled ); new TeleportSpell( m_Mobile, null ).Cast(); @@ -590,7 +588,7 @@ namespace Server.Factions else if (dispelTarget != null && (IsAllowed(GuardAI.Magic) || IsAllowed(GuardAI.Bless) || IsAllowed(GuardAI.Curse))) { - if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && 40 > Utility.Random(100)) + if (!dispelTarget.Paralyzed && m_Guard.Mana > ManaReserve + 20 && Utility.Random(100) < 40) spell = new ParalyzeSpell(m_Guard); else spell = new DispelSpell(m_Guard); @@ -610,9 +608,9 @@ namespace Server.Factions m_ComboIndex = -1; } } - else if (20 > Utility.Random(100) && IsAllowed(GuardAI.Magic)) + else if (Utility.Random(100) < 20 && IsAllowed(GuardAI.Magic)) { - if (80 > Utility.Random(100)) + if (Utility.Random(100) < 80) { m_Combo = IsAllowed(GuardAI.Smart) ? SpellCombo.Simple : SpellCombo.Strong; m_ComboIndex = -1; @@ -635,7 +633,7 @@ namespace Server.Factions } } - if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= ManaReserve + 10) + if (spell == null && Utility.Random(100) < 2 && m_Guard.Mana >= ManaReserve + 10) { int strMod = GetStatMod(m_Guard, StatType.Str); int dexMod = GetStatMod(m_Guard, StatType.Dex); @@ -668,10 +666,10 @@ namespace Server.Factions } } - if (spell == null && 2 > Utility.Random(100) && m_Guard.Mana >= ManaReserve + 10 && + if (spell == null && Utility.Random(100) < 2 && m_Guard.Mana >= ManaReserve + 10 && IsAllowed(GuardAI.Curse)) { - if (!combatant.Poisoned && 40 > Utility.Random(100)) + if (!combatant.Poisoned && Utility.Random(100) < 40) { spell = new PoisonSpell(m_Guard); } diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Guards/Orders.cs b/Projects/Scripts/Engines/Factions/Mobiles/Guards/Orders.cs index eb7b54868..336ed4aa5 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Guards/Orders.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Guards/Orders.cs @@ -31,18 +31,18 @@ namespace Server.Factions.AI switch (version) { case 0: - { - Faction = Faction.ReadReference(reader); - Type = (ReactionType)reader.ReadEncodedInt(); + { + Faction = Faction.ReadReference(reader); + Type = (ReactionType)reader.ReadEncodedInt(); - break; - } + break; + } } } - public Faction Faction{ get; } + public Faction Faction { get; } - public ReactionType Type{ get; set; } + public ReactionType Type { get; set; } public void Serialize(IGenericWriter writer) { @@ -55,7 +55,7 @@ namespace Server.Factions.AI public class Orders { - private List m_Reactions; + private readonly List m_Reactions; public Orders(BaseFactionGuard guard) { @@ -73,30 +73,30 @@ namespace Server.Factions.AI switch (version) { case 1: - { - Follow = reader.ReadMobile(); - goto case 0; - } + { + Follow = reader.ReadMobile(); + goto case 0; + } case 0: - { - int count = reader.ReadEncodedInt(); - m_Reactions = new List(count); + { + int count = reader.ReadEncodedInt(); + m_Reactions = new List(count); - for (int i = 0; i < count; ++i) - m_Reactions.Add(new Reaction(reader)); + for (int i = 0; i < count; ++i) + m_Reactions.Add(new Reaction(reader)); - Movement = (MovementType)reader.ReadEncodedInt(); + Movement = (MovementType)reader.ReadEncodedInt(); - break; - } + break; + } } } - public BaseFactionGuard Guard{ get; } + public BaseFactionGuard Guard { get; } - public MovementType Movement{ get; set; } + public MovementType Movement { get; set; } - public Mobile Follow{ get; set; } + public Mobile Follow { get; set; } public Reaction GetReaction(Faction faction) { diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs index 639fec176..c3b157037 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/BaseFactionVendor.cs @@ -51,7 +51,7 @@ namespace Server.Factions } } - protected override List SBInfos{ get; } = new List(); + protected override List SBInfos { get; } = new List(); public void Register() { @@ -104,12 +104,12 @@ namespace Server.Factions switch (version) { case 0: - { - m_Town = Town.ReadReference(reader); - m_Faction = Faction.ReadReference(reader); - Register(); - break; - } + { + m_Town = Town.ReadReference(reader); + m_Faction = Faction.ReadReference(reader); + Register(); + break; + } } Frozen = true; diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs index ed54b6886..8e2722176 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBoardVendor.cs @@ -6,8 +6,7 @@ namespace Server.Factions { public class FactionBoardVendor : BaseFactionVendor { - public FactionBoardVendor(Town town, Faction faction) : - base(town, faction, "the LumberMan") // NOTE: title inconsistant, as OSI + public FactionBoardVendor(Town town, Faction faction) : base(town, faction, "the LumberMan") // NOTE: title inconsistant, as OSI { SetSkill(SkillName.Carpentry, 85.0, 100.0); SetSkill(SkillName.Lumberjacking, 60.0, 83.0); @@ -46,9 +45,9 @@ namespace Server.Factions public class SBFactionBoard : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs index a7d81b94f..315de7944 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionBottleVendor.cs @@ -47,9 +47,9 @@ namespace Server.Factions public class SBFactionBottle : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs index b16176389..bdaeac477 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionOreVendor.cs @@ -48,9 +48,9 @@ namespace Server.Factions { private static readonly object[] m_FixedSizeArgs = { true }; - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionReagentVendor.cs b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionReagentVendor.cs index eacddcaae..0198a1f01 100644 --- a/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionReagentVendor.cs +++ b/Projects/Scripts/Engines/Factions/Mobiles/Vendors/FactionReagentVendor.cs @@ -52,9 +52,9 @@ namespace Server.Factions public class SBFactionReagent : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Engines/Harvest/Core/BonusHarvestResource.cs b/Projects/Scripts/Engines/Harvest/Core/BonusHarvestResource.cs index ce189171a..ef92a20f9 100644 --- a/Projects/Scripts/Engines/Harvest/Core/BonusHarvestResource.cs +++ b/Projects/Scripts/Engines/Harvest/Core/BonusHarvestResource.cs @@ -13,13 +13,13 @@ namespace Server.Engines.Harvest SuccessMessage = message; } - public Type Type{ get; set; } + public Type Type { get; set; } - public double ReqSkill{ get; set; } + public double ReqSkill { get; set; } - public double Chance{ get; set; } + public double Chance { get; set; } - public TextDefinition SuccessMessage{ get; } + public TextDefinition SuccessMessage { get; } public void SendSuccessTo(Mobile m) { diff --git a/Projects/Scripts/Engines/Harvest/Core/FurnitureAttribute.cs b/Projects/Scripts/Engines/Harvest/Core/FurnitureAttribute.cs new file mode 100644 index 000000000..b421847bf --- /dev/null +++ b/Projects/Scripts/Engines/Harvest/Core/FurnitureAttribute.cs @@ -0,0 +1,10 @@ +using System; + +namespace Server +{ + [AttributeUsage(AttributeTargets.Class)] + public class FurnitureAttribute : Attribute + { + public static bool Check(Item item) => item?.GetType().IsDefined(typeof(FurnitureAttribute), false) == true; + } +} diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestBank.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestBank.cs index 887449f33..7c80dff2f 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestBank.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestBank.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Harvest public class HarvestBank { private int m_Current; - private int m_Maximum; + private readonly int m_Maximum; private DateTime m_NextRespawn; private HarvestVein m_Vein, m_DefaultVein; @@ -19,7 +19,7 @@ namespace Server.Engines.Harvest Definition = def; } - public HarvestDefinition Definition{ get; } + public HarvestDefinition Definition { get; } public int Current { @@ -56,7 +56,7 @@ namespace Server.Engines.Harvest m_Current = m_Maximum; - if (Definition.RandomizeVeins) m_DefaultVein = Definition.GetVeinFrom(Utility.RandomDouble()); + if (Definition.RandomizeVeins) m_DefaultVein = Definition.GetVeinFrom(Utility.Random(Definition.VeinWeights)); m_Vein = m_DefaultVein; } @@ -74,8 +74,8 @@ namespace Server.Engines.Harvest m_Current = m_Maximum - amount; double minutes = min + rnd * (max - min); - if (Definition.RaceBonus && from.Race == Race.Elf) //def.RaceBonus = Core.ML - minutes *= .75; //25% off the time. + if (Definition.RaceBonus && from.Race == Race.Elf) // def.RaceBonus = Core.ML + minutes *= .75; // 25% off the time. m_NextRespawn = DateTime.UtcNow + TimeSpan.FromMinutes(minutes); } @@ -88,4 +88,4 @@ namespace Server.Engines.Harvest m_Current = 0; } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestDefinition.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestDefinition.cs index 135c05fec..dad691252 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestDefinition.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestDefinition.cs @@ -1,71 +1,84 @@ using System; using System.Collections.Generic; +using System.Linq; namespace Server.Engines.Harvest { public class HarvestDefinition { - public int BankWidth{ get; set; } + public int BankWidth { get; set; } - public int BankHeight{ get; set; } + public int BankHeight { get; set; } - public int MinTotal{ get; set; } + public int MinTotal { get; set; } - public int MaxTotal{ get; set; } + public int MaxTotal { get; set; } - public int[] Tiles{ get; set; } + public int[] Tiles { get; set; } - public bool RangedTiles{ get; set; } + public bool RangedTiles { get; set; } - public TimeSpan MinRespawn{ get; set; } + public TimeSpan MinRespawn { get; set; } - public TimeSpan MaxRespawn{ get; set; } + public TimeSpan MaxRespawn { get; set; } - public int MaxRange{ get; set; } + public int MaxRange { get; set; } - public int ConsumedPerHarvest{ get; set; } + public int ConsumedPerHarvest { get; set; } - public int ConsumedPerFeluccaHarvest{ get; set; } + public int ConsumedPerFeluccaHarvest { get; set; } - public bool PlaceAtFeetIfFull{ get; set; } + public bool PlaceAtFeetIfFull { get; set; } - public SkillName Skill{ get; set; } + public SkillName Skill { get; set; } - public int[] EffectActions{ get; set; } + public int[] EffectActions { get; set; } - public int[] EffectCounts{ get; set; } + public int[] EffectCounts { get; set; } - public int[] EffectSounds{ get; set; } + public int[] EffectSounds { get; set; } - public TimeSpan EffectSoundDelay{ get; set; } + public TimeSpan EffectSoundDelay { get; set; } - public TimeSpan EffectDelay{ get; set; } + public TimeSpan EffectDelay { get; set; } - public object NoResourcesMessage{ get; set; } + public TextDefinition NoResourcesMessage { get; set; } - public object OutOfRangeMessage{ get; set; } + public TextDefinition OutOfRangeMessage { get; set; } - public object TimedOutOfRangeMessage{ get; set; } + public TextDefinition TimedOutOfRangeMessage { get; set; } - public object DoubleHarvestMessage{ get; set; } + public TextDefinition DoubleHarvestMessage { get; set; } - public object FailMessage{ get; set; } + public TextDefinition FailMessage { get; set; } - public object PackFullMessage{ get; set; } + public TextDefinition PackFullMessage { get; set; } - public object ToolBrokeMessage{ get; set; } + public TextDefinition ToolBrokeMessage { get; set; } - public HarvestResource[] Resources{ get; set; } + public HarvestResource[] Resources { get; set; } - public HarvestVein[] Veins{ get; set; } + private HarvestVein[] m_Veins; - public BonusHarvestResource[] BonusResources{ get; set; } + public HarvestVein[] Veins + { + get => m_Veins; + set + { + m_Veins = value; + VeinWeights = m_Veins.Aggregate(0, (current, t) => current + t.VeinChance); + } + } - public bool RaceBonus{ get; set; } + public BonusHarvestResource[] BonusResources { get; set; } - public bool RandomizeVeins{ get; set; } + public bool RaceBonus { get; set; } - public Dictionary> Banks{ get; } + public bool RandomizeVeins { get; set; } + + public uint VeinWeights { get; private set; } + + public Dictionary> Banks { get; } = new Dictionary>(); public void SendMessageTo(Mobile from, object message) @@ -100,28 +113,18 @@ namespace Server.Engines.Harvest if (Veins.Length == 1) return Veins[0]; - double randomValue; + if (RandomizeVeins) return GetVeinFrom(Utility.Random(1000u)); - if (RandomizeVeins) - { - randomValue = Utility.RandomDouble(); - } - else - { - Random random = new Random(x * 17 + y * 11 + map.MapID * 3); - randomValue = random.NextDouble(); - } - - return GetVeinFrom(randomValue); + // TODO: Introduce pulling primes from a config and writing them if they don't exist to the config + using Xoshiro256PlusPlus random = new Xoshiro256PlusPlus((ulong)(x * 17 + y * 11 + map.MapID * 3)); + return GetVeinFrom(random.Next(VeinWeights)); } - public HarvestVein GetVeinFrom(double randomValue) + public HarvestVein GetVeinFrom(uint randomValue) { if (Veins.Length == 1) return Veins[0]; - randomValue *= 100; - for (int i = 0; i < Veins.Length; ++i) { if (randomValue <= Veins[i].VeinChance) diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestResource.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestResource.cs index e48fb8d91..014a7cc3f 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestResource.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestResource.cs @@ -13,15 +13,15 @@ namespace Server.Engines.Harvest SuccessMessage = message; } - public Type[] Types{ get; set; } + public Type[] Types { get; set; } - public double ReqSkill{ get; set; } + public double ReqSkill { get; set; } - public double MinSkill{ get; set; } + public double MinSkill { get; set; } - public double MaxSkill{ get; set; } + public double MaxSkill { get; set; } - public object SuccessMessage{ get; } + public object SuccessMessage { get; } public void SendSuccessTo(Mobile m) { diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestSoundTimer.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestSoundTimer.cs index 076031bd8..885247b70 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestSoundTimer.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestSoundTimer.cs @@ -2,12 +2,13 @@ namespace Server.Engines.Harvest { public class HarvestSoundTimer : Timer { - private HarvestDefinition m_Definition; - private Mobile m_From; - private bool m_Last; - private HarvestSystem m_System; - private object m_ToHarvest, m_Locked; - private Item m_Tool; + private readonly HarvestDefinition m_Definition; + private readonly Mobile m_From; + private readonly bool m_Last; + private readonly HarvestSystem m_System; + private readonly object m_ToHarvest; + private readonly object m_Locked; + private readonly Item m_Tool; public HarvestSoundTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest, object locked, bool last) : base(def.EffectSoundDelay) diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs index 98b561f91..66ff56436 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestSystem.cs @@ -11,11 +11,11 @@ namespace Server.Engines.Harvest { public HarvestSystem() => Definitions = new List(); - public List Definitions{ get; } + public List Definitions { get; } public virtual bool CheckTool(Mobile from, Item tool) { - bool wornOut = tool?.Deleted != false || tool is IUsesRemaining remaining && remaining.UsesRemaining <= 0; + bool wornOut = tool?.Deleted != false || (tool as IUsesRemaining)?.UsesRemaining <= 0; if (wornOut) from.SendLocalizedMessage(1044038); // You have worn out your tool! @@ -139,7 +139,7 @@ namespace Server.Engines.Harvest } else { - //The whole harvest system is kludgy and I'm sure this is just adding to it. + // The whole harvest system is kludgy and I'm sure this is just adding to it. if (item.Stackable) { int amount = def.ConsumedPerHarvest; @@ -152,11 +152,11 @@ namespace Server.Engines.Harvest bool inFelucca = map == Map.Felucca; if (eligableForRacialBonus && inFelucca && bank.Current >= feluccaRacialAmount && - 0.1 > Utility.RandomDouble()) + Utility.RandomDouble() < 0.1) item.Amount = feluccaRacialAmount; else if (inFelucca && bank.Current >= feluccaAmount) item.Amount = feluccaAmount; - else if (eligableForRacialBonus && bank.Current >= racialAmount && 0.1 > Utility.RandomDouble()) + else if (eligableForRacialBonus && bank.Current >= racialAmount && Utility.RandomDouble() < 0.1) item.Amount = racialAmount; else item.Amount = amount; @@ -180,8 +180,7 @@ namespace Server.Engines.Harvest { Item bonusItem = Construct(bonus.Type, from); - if (Give(from, bonusItem, true) - ) //Bonuses always allow placing at feet, even if pack is full irregrdless of def + if (Give(from, bonusItem, true)) // Bonuses always allow placing at feet, even if pack is full irregrdless of def bonus.SendSuccessTo(from); else item.Delete(); @@ -349,10 +348,10 @@ namespace Server.Engines.Harvest from.Animate(Utility.RandomList(def.EffectActions), 5, 1, true, false, 0); } - public virtual HarvestDefinition GetDefinition(int tileID) - { - return Definitions.FirstOrDefault(check => check.Validate(tileID)); - } + public virtual HarvestDefinition GetDefinition() => Definitions.First(); + + public virtual HarvestDefinition GetDefinition(int tileID) => + Definitions.FirstOrDefault(check => check.Validate(tileID)); public virtual void StartHarvesting(Mobile from, Item tool, object toHarvest) { @@ -425,17 +424,3 @@ namespace Server.Engines.Harvest } } } - -namespace Server -{ - public interface IChopable - { - void OnChop(Mobile from); - } - - [AttributeUsage(AttributeTargets.Class)] - public class FurnitureAttribute : Attribute - { - public static bool Check(Item item) => item?.GetType().IsDefined(typeof(FurnitureAttribute), false) == true; - } -} diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestTarget.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestTarget.cs index 9b0c0e390..75c979280 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestTarget.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestTarget.cs @@ -8,8 +8,8 @@ namespace Server.Engines.Harvest { public class HarvestTarget : Target { - private HarvestSystem m_System; - private Item m_Tool; + private readonly HarvestSystem m_System; + private readonly Item m_Tool; public HarvestTarget(Item tool, HarvestSystem system) : base(-1, true, TargetFlags.None) { @@ -47,7 +47,7 @@ namespace Server.Engines.Harvest } } - if (m_System is Lumberjacking && targeted is IChopable chopable) + if (m_System is Lumberjacking && targeted is IChoppable chopable) { chopable.OnChop(from); } diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestTimer.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestTimer.cs index dae664e40..92bf73683 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestTimer.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestTimer.cs @@ -4,12 +4,14 @@ namespace Server.Engines.Harvest { public class HarvestTimer : Timer { - private HarvestDefinition m_Definition; - private Mobile m_From; - private int m_Index, m_Count; - private HarvestSystem m_System; - private object m_ToHarvest, m_Locked; - private Item m_Tool; + private readonly HarvestDefinition m_Definition; + private readonly Mobile m_From; + private int m_Index; + private readonly int m_Count; + private readonly HarvestSystem m_System; + private readonly object m_ToHarvest; + private readonly object m_Locked; + private readonly Item m_Tool; public HarvestTimer(Mobile from, Item tool, HarvestSystem system, HarvestDefinition def, object toHarvest, object locked) : base(TimeSpan.Zero, def.EffectDelay) diff --git a/Projects/Scripts/Engines/Harvest/Core/HarvestVein.cs b/Projects/Scripts/Engines/Harvest/Core/HarvestVein.cs index fde929958..87a67ee43 100644 --- a/Projects/Scripts/Engines/Harvest/Core/HarvestVein.cs +++ b/Projects/Scripts/Engines/Harvest/Core/HarvestVein.cs @@ -2,7 +2,7 @@ namespace Server.Engines.Harvest { public class HarvestVein { - public HarvestVein(double veinChance, double chanceToFallback, HarvestResource primaryResource, + public HarvestVein(uint veinChance, double chanceToFallback, HarvestResource primaryResource, HarvestResource fallbackResource) { VeinChance = veinChance; @@ -11,12 +11,12 @@ namespace Server.Engines.Harvest FallbackResource = fallbackResource; } - public double VeinChance{ get; set; } + public uint VeinChance { get; set; } - public double ChanceToFallback{ get; set; } + public double ChanceToFallback { get; set; } - public HarvestResource PrimaryResource{ get; set; } + public HarvestResource PrimaryResource { get; set; } - public HarvestResource FallbackResource{ get; set; } + public HarvestResource FallbackResource { get; set; } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Harvest/Core/IChoppable..cs b/Projects/Scripts/Engines/Harvest/Core/IChoppable..cs new file mode 100644 index 000000000..c9d71da89 --- /dev/null +++ b/Projects/Scripts/Engines/Harvest/Core/IChoppable..cs @@ -0,0 +1,7 @@ +namespace Server +{ + public interface IChoppable + { + void OnChop(Mobile from); + } +} diff --git a/Projects/Scripts/Engines/Harvest/Fishing.cs b/Projects/Scripts/Engines/Harvest/Fishing.cs index 1b1f7af0d..94898c9f1 100644 --- a/Projects/Scripts/Engines/Harvest/Fishing.cs +++ b/Projects/Scripts/Engines/Harvest/Fishing.cs @@ -14,7 +14,7 @@ namespace Server.Engines.Harvest { private static Fishing m_System; - private static MutateEntry[] m_MutateTable = + private static readonly MutateEntry[] m_MutateTable = { new MutateEntry(80.0, 80.0, 4080.0, true, typeof(SpecialFishingNet)), new MutateEntry(80.0, 80.0, 4080.0, true, typeof(BigFish)), @@ -26,7 +26,7 @@ namespace Server.Engines.Harvest new MutateEntry(0.0, 200.0, -200.0, false, new Type[] { null }) }; - private static int[] m_WaterTiles = + private static readonly int[] m_WaterTiles = { 0x00A8, 0x00AB, 0x0136, 0x0137, @@ -53,7 +53,7 @@ namespace Server.Engines.Harvest ConsumedPerHarvest = 1, ConsumedPerFeluccaHarvest = 1, EffectActions = new[] { 12 }, - EffectSounds = new int[0], + EffectSounds = Array.Empty(), EffectCounts = new[] { 1 }, EffectDelay = TimeSpan.Zero, EffectSoundDelay = TimeSpan.FromSeconds(8.0), @@ -70,7 +70,7 @@ namespace Server.Engines.Harvest }; HarvestVein[] veins = { - new HarvestVein(100.0, 0.0, res[0], null) + new HarvestVein(1000, 0.0, res[0], null) }; fish.Resources = res; @@ -79,18 +79,15 @@ namespace Server.Engines.Harvest if (Core.ML) fish.BonusResources = new[] { - new BonusHarvestResource(0, 99.4, null, null), //set to same chance as mining ml gems + new BonusHarvestResource(0, 99.4, null, null), // set to same chance as mining ml gems new BonusHarvestResource(80.0, .6, 1072597, typeof(WhitePearl)) }; - Definition = fish; Definitions.Add(fish); } public static Fishing System => m_System ?? (m_System = new Fishing()); - public HarvestDefinition Definition{ get; } - public override void OnConcurrentHarvest(Mobile from, Item tool, HarvestDefinition def, object toHarvest) { from.SendLocalizedMessage(500972); // You are already fishing. @@ -199,72 +196,72 @@ namespace Server.Engines.Harvest switch (Utility.Random(8)) { case 0: // Body parts - { - int[] list = { - 0x1CDD, 0x1CE5, // arm - 0x1CE0, 0x1CE8, // torso - 0x1CE1, 0x1CE9, // head - 0x1CE2, 0x1CEC // leg - }; + int[] list = + { + 0x1CDD, 0x1CE5, // arm + 0x1CE0, 0x1CE8, // torso + 0x1CE1, 0x1CE9, // head + 0x1CE2, 0x1CEC // leg + }; - preLoot = new ShipwreckedItem(Utility.RandomList(list)); - break; - } - case 1: // Bone parts - { - int[] list = - { - 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls - 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles - 0x1B15, 0x1B16 // pelvis bones - }; - - preLoot = new ShipwreckedItem(Utility.RandomList(list)); - break; - } - case 2: // Paintings and portraits - { - preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10)); - break; - } - case 3: // Pillows - { - preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); - break; - } - case 4: // Shells - { - preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); - break; - } - case 5: //Hats - { - if (Utility.RandomBool()) - preLoot = new SkullCap(); - else - preLoot = new TricorneHat(); - - break; - } - case 6: // Misc - { - int[] list = - { - 0x1EB5, // unfinished barrel - 0xA2A, // stool - 0xC1F, // broken clock - 0x1047, 0x1048, // globe - 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves - }; - - if (Utility.Random(list.Length + 1) == 0) - preLoot = new Candelabra(); - else preLoot = new ShipwreckedItem(Utility.RandomList(list)); + break; + } + case 1: // Bone parts + { + int[] list = + { + 0x1AE0, 0x1AE1, 0x1AE2, 0x1AE3, 0x1AE4, // skulls + 0x1B09, 0x1B0A, 0x1B0B, 0x1B0C, 0x1B0D, 0x1B0E, 0x1B0F, 0x1B10, // bone piles + 0x1B15, 0x1B16 // pelvis bones + }; - break; - } + preLoot = new ShipwreckedItem(Utility.RandomList(list)); + break; + } + case 2: // Paintings and portraits + { + preLoot = new ShipwreckedItem(Utility.Random(0xE9F, 10)); + break; + } + case 3: // Pillows + { + preLoot = new ShipwreckedItem(Utility.Random(0x13A4, 11)); + break; + } + case 4: // Shells + { + preLoot = new ShipwreckedItem(Utility.Random(0xFC4, 9)); + break; + } + case 5: // Hats + { + if (Utility.RandomBool()) + preLoot = new SkullCap(); + else + preLoot = new TricorneHat(); + + break; + } + case 6: // Misc + { + int[] list = + { + 0x1EB5, // unfinished barrel + 0xA2A, // stool + 0xC1F, // broken clock + 0x1047, 0x1048, // globe + 0x1EB1, 0x1EB2, 0x1EB3, 0x1EB4 // barrel staves + }; + + if (Utility.Random(list.Length + 1) == 0) + preLoot = new Candelabra(); + else + preLoot = new ShipwreckedItem(Utility.RandomList(list)); + + break; + } } if (preLoot != null) @@ -309,7 +306,7 @@ namespace Server.Engines.Harvest { BaseCreature serp; - if (0.25 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.25) serp = new DeepSeaSerpent(); else serp = new SeaSerpent(); @@ -325,7 +322,7 @@ namespace Server.Engines.Harvest LandTile t = map.Tiles.GetLandTile(tx, ty); - if (t.Z == -5 && (t.ID >= 0xA8 && t.ID <= 0xAB || t.ID >= 0x136 && t.ID <= 0x137) && + if (t.Z == -5 && ((t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137)) && !SpellHelper.CheckMulti(new Point3D(tx, ty, -5), map)) { x = tx; @@ -425,7 +422,7 @@ namespace Server.Engines.Harvest if (GetHarvestDetails(from, tool, toHarvest, out _, out Map map, out Point3D loc)) Timer.DelayCall(TimeSpan.FromSeconds(1.5), - delegate + () => { if (Core.ML) from.RevealingAction(); @@ -485,9 +482,11 @@ namespace Server.Engines.Harvest private class MutateEntry { - public bool m_DeepWater; - public double m_ReqSkill, m_MinSkill, m_MaxSkill; - public Type[] m_Types; + public readonly bool m_DeepWater; + public readonly double m_ReqSkill; + public readonly double m_MinSkill; + public readonly double m_MaxSkill; + public readonly Type[] m_Types; public MutateEntry(double reqSkill, double minSkill, double maxSkill, bool deepWater, params Type[] types) { diff --git a/Projects/Scripts/Engines/Harvest/Lumberjacking.cs b/Projects/Scripts/Engines/Harvest/Lumberjacking.cs index c66eead6c..c13dd2240 100644 --- a/Projects/Scripts/Engines/Harvest/Lumberjacking.cs +++ b/Projects/Scripts/Engines/Harvest/Lumberjacking.cs @@ -9,9 +9,7 @@ namespace Server.Engines.Harvest { private static Lumberjacking m_System; - #region Tile lists - - private static int[] m_TreeTiles = + private static readonly int[] m_TreeTiles = { 0x4CCA, 0x4CCB, 0x4CCC, 0x4CCD, 0x4CD0, 0x4CD3, 0x4CD6, 0x4CD8, 0x4CDA, 0x4CDD, 0x4CE0, 0x4CE3, 0x4CE6, 0x4CF8, 0x4CFB, 0x4CFE, @@ -36,8 +34,6 @@ namespace Server.Engines.Harvest 0x52C6, 0x52C7 }; - #endregion - private Lumberjacking() { HarvestResource[] res; @@ -81,21 +77,20 @@ namespace Server.Engines.Harvest new HarvestResource(100.0, 60.0, 140.0, 1072546, typeof(FrostwoodLog)) }; - veins = new[] { - new HarvestVein(49.0, 0.0, res[0], null), // Ordinary Logs - new HarvestVein(30.0, 0.5, res[1], res[0]), // Oak - new HarvestVein(10.0, 0.5, res[2], res[0]), // Ash - new HarvestVein(05.0, 0.5, res[3], res[0]), // Yew - new HarvestVein(03.0, 0.5, res[4], res[0]), // Heartwood - new HarvestVein(02.0, 0.5, res[5], res[0]), // Bloodwood - new HarvestVein(01.0, 0.5, res[6], res[0]) // Frostwood + new HarvestVein(490, 0.0, res[0], null), // Ordinary Logs + new HarvestVein(300, 0.5, res[1], res[0]), // Oak + new HarvestVein(100, 0.5, res[2], res[0]), // Ash + new HarvestVein(050, 0.5, res[3], res[0]), // Yew + new HarvestVein(030, 0.5, res[4], res[0]), // Heartwood + new HarvestVein(020, 0.5, res[5], res[0]), // Bloodwood + new HarvestVein(010, 0.5, res[6], res[0]) // Frostwood }; lumber.BonusResources = new[] { - new BonusHarvestResource(0, 83.9, null, null), //Nothing + new BonusHarvestResource(0, 83.9, null, null), // Nothing new BonusHarvestResource(100, 10.0, 1072548, typeof(BarkFragment)), new BonusHarvestResource(100, 03.0, 1072550, typeof(LuminescentFungi)), new BonusHarvestResource(100, 02.0, 1072547, typeof(SwitchItem)), @@ -112,7 +107,7 @@ namespace Server.Engines.Harvest veins = new[] { - new HarvestVein(100.0, 0.0, res[0], null) + new HarvestVein(1000, 0.0, res[0], null) }; } @@ -122,14 +117,11 @@ namespace Server.Engines.Harvest lumber.RaceBonus = Core.ML; lumber.RandomizeVeins = Core.ML; - Definition = lumber; Definitions.Add(lumber); } public static Lumberjacking System => m_System ?? (m_System = new Lumberjacking()); - public HarvestDefinition Definition{ get; } - public override bool CheckHarvest(Mobile from, Item tool) { if (!base.CheckHarvest(from, tool)) diff --git a/Projects/Scripts/Engines/Harvest/Mining.cs b/Projects/Scripts/Engines/Harvest/Mining.cs index 806029ec6..8242b4b00 100644 --- a/Projects/Scripts/Engines/Harvest/Mining.cs +++ b/Projects/Scripts/Engines/Harvest/Mining.cs @@ -10,7 +10,7 @@ namespace Server.Engines.Harvest { private static Mining m_System; - private static int[] m_Offsets = + private static readonly int[] m_Offsets = { -1, -1, -1, 0, @@ -24,8 +24,6 @@ namespace Server.Engines.Harvest private Mining() { - #region Mining for ore and stone - OreAndStone = new HarvestDefinition { BankWidth = 8, @@ -74,15 +72,15 @@ namespace Server.Engines.Harvest }; HarvestVein[] veins = { - new HarvestVein(49.6, 0.0, res[0], null), // Iron - new HarvestVein(11.2, 0.5, res[1], res[0]), // Dull Copper - new HarvestVein(09.8, 0.5, res[2], res[0]), // Shadow Iron - new HarvestVein(08.4, 0.5, res[3], res[0]), // Copper - new HarvestVein(07.0, 0.5, res[4], res[0]), // Bronze - new HarvestVein(05.6, 0.5, res[5], res[0]), // Gold - new HarvestVein(04.2, 0.5, res[6], res[0]), // Agapite - new HarvestVein(02.8, 0.5, res[7], res[0]), // Verite - new HarvestVein(01.4, 0.5, res[8], res[0]) // Valorite + new HarvestVein(496, 0.0, res[0], null), // Iron + new HarvestVein(112, 0.5, res[1], res[0]), // Dull Copper + new HarvestVein(098, 0.5, res[2], res[0]), // Shadow Iron + new HarvestVein(084, 0.5, res[3], res[0]), // Copper + new HarvestVein(070, 0.5, res[4], res[0]), // Bronze + new HarvestVein(056, 0.5, res[5], res[0]), // Gold + new HarvestVein(042, 0.5, res[6], res[0]), // Agapite + new HarvestVein(028, 0.5, res[7], res[0]), // Verite + new HarvestVein(014, 0.5, res[8], res[0]) // Valorite }; OreAndStone.Resources = res; @@ -91,7 +89,7 @@ namespace Server.Engines.Harvest if (Core.ML) OreAndStone.BonusResources = new[] { - new BonusHarvestResource(0, 99.4, null, null), //Nothing + new BonusHarvestResource(0, 99.4, null, null), // Nothing new BonusHarvestResource(100, .1, 1072562, typeof(BlueDiamond)), new BonusHarvestResource(100, .1, 1072567, typeof(DarkSapphire)), new BonusHarvestResource(100, .1, 1072570, typeof(EcruCitrine)), @@ -105,10 +103,6 @@ namespace Server.Engines.Harvest Definitions.Add(OreAndStone); - #endregion - - #region Mining for sand - Sand = new HarvestDefinition { BankWidth = 8, @@ -143,22 +137,20 @@ namespace Server.Engines.Harvest veins = new[] { - new HarvestVein(100.0, 0.0, res[0], null) + new HarvestVein(1000, 0.0, res[0], null) }; Sand.Resources = res; Sand.Veins = veins; Definitions.Add(Sand); - - #endregion } public static Mining System => m_System ?? (m_System = new Mining()); - public HarvestDefinition OreAndStone{ get; } + public HarvestDefinition OreAndStone { get; } - public HarvestDefinition Sand{ get; } + public HarvestDefinition Sand { get; } public override Type GetResourceType(Mobile from, Item tool, HarvestDefinition def, Map map, Point3D loc, HarvestResource resource) @@ -166,13 +158,11 @@ namespace Server.Engines.Harvest if (def != OreAndStone) return base.GetResourceType(from, tool, def, map, loc, resource); - if (from.Skills.Mining.Base >= 100.0 && from is PlayerMobile pm && pm.StoneMining && pm.ToggleMiningStone - && 0.1 > Utility.RandomDouble()) + && Utility.RandomDouble() < 0.1) return resource.Types[1]; return resource.Types[0]; - } public override bool CheckHarvest(Mobile from, Item tool) @@ -247,7 +237,7 @@ namespace Server.Engines.Harvest public override void OnHarvestFinished(Mobile from, Item tool, HarvestDefinition def, HarvestVein vein, HarvestBank bank, HarvestResource resource, object harvested) { - if (tool is GargoylesPickaxe && def == OreAndStone && 0.1 > Utility.RandomDouble()) + if (tool is GargoylesPickaxe && def == OreAndStone && Utility.RandomDouble() < 0.1) { HarvestResource res = vein.PrimaryResource; @@ -324,9 +314,7 @@ namespace Server.Engines.Harvest from.SendLocalizedMessage(501863); // You can't mine that. } - #region Tile lists - - private static int[] m_MountainAndCaveTiles = + private static readonly int[] m_MountainAndCaveTiles = { 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 236, 237, 238, 239, 240, 241, 242, 243, @@ -365,7 +353,7 @@ namespace Server.Engines.Harvest 0x4549, 0x454A, 0x454B, 0x454C, 0x454D, 0x454E, 0x454F }; - private static int[] m_SandTiles = + private static readonly int[] m_SandTiles = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, @@ -389,7 +377,5 @@ namespace Server.Engines.Harvest 1617, 1618, 1623, 1624, 1625, 1626, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1647, 1648, 1649, 1650 }; - - #endregion } } diff --git a/Projects/Scripts/Engines/Help/HelpGump.cs b/Projects/Scripts/Engines/Help/HelpGump.cs index 151c9b99c..de2a2b75e 100644 --- a/Projects/Scripts/Engines/Help/HelpGump.cs +++ b/Projects/Scripts/Engines/Help/HelpGump.cs @@ -13,7 +13,7 @@ namespace Server.Engines.Help { public class ContainedMenu : QuestionMenu { - private Mobile m_From; + private readonly Mobile m_From; public ContainedMenu(Mobile from) : base( "You already have an open help request. We will have someone assist you as soon as possible. What would you like to do?", @@ -141,50 +141,54 @@ namespace Server.Engines.Help AddPage(3); AddButton(80, 90, 5540, 5541, 7); + + /*
Another player is harassing me (or Exploiting).

+ * VERBAL HARASSMENT
+ * 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? - + * 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.
+ * 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? + */ AddHtmlLocalized(110, 90, 450, 145, 1062572, true, - true); /*
Another player is harassing me (or Exploiting).

- * VERBAL HARASSMENT
- * 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? - - * 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.
- * 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? - */ + true); AddButton(80, 240, 5540, 5541, 8); + + /*
Another player is harassing me using game mechanics.

+ *
+ * PHYSICAL HARASSMENT
+ * 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? + * 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.
+ * 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. + * Abuse of this system is a violation of the Rules of Conduct. + */ AddHtmlLocalized(110, 240, 450, 145, 1062573, true, - true); /*
Another player is harassing me using game mechanics.

- *
- * PHYSICAL HARASSMENT
- * 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? - * 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.
- * 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. - * Abuse of this system is a violation of the Rules of Conduct. - */ + true); AddButton(150, 390, 5540, 5541, 0, GumpButtonType.Page, 1); AddHtmlLocalized(180, 390, 335, 40, 1001015); // NO - I meant to ask for help with another matter. @@ -232,93 +236,93 @@ namespace Server.Engines.Help switch (info.ButtonID) { case 0: // Close/Cancel - { - from.SendLocalizedMessage(501235, "", 0x35); // Help request aborted. + { + from.SendLocalizedMessage(501235, "", 0x35); // Help request aborted. - break; - } + break; + } case 1: // General question - { - type = PageType.Question; - break; - } + { + type = PageType.Question; + break; + } case 2: // Stuck - { - BaseHouse house = BaseHouse.FindHouseAt(from); + { + BaseHouse house = BaseHouse.FindHouseAt(from); - if (house?.IsAosRules == true && !from.Region.IsPartOf()) // Dueling - { - from.Location = house.BanLocation; - } - else if (from.Region.IsPartOf()) - { - from.SendLocalizedMessage(1114345, "", 0x35); // You'll need a better jailbreak plan than that! - } - else if (Sigil.ExistsOn(from)) - { - from.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. - } - else if (from is PlayerMobile mobile && mobile.CanUseStuckMenu() && - mobile.Region.CanUseStuckMenu(mobile) && !CheckCombat(mobile) && !mobile.Frozen && - !mobile.Criminal && (Core.AOS || mobile.Kills < 5)) - { - StuckMenu menu = new StuckMenu(mobile, mobile, true); - - menu.BeginClose(); - - mobile.SendGump(menu); - } - else - { - type = PageType.Stuck; - } - - break; - } - case 3: // Report bug or contact Origin - { - type = PageType.Bug; - break; - } - case 4: // Game suggestion - { - type = PageType.Suggestion; - break; - } - case 5: // Account management - { - type = PageType.Account; - break; - } - case 6: // Other - { - type = PageType.Other; - break; - } - case 7: // Harassment: verbal/exploit - { - type = PageType.VerbalHarassment; - break; - } - case 8: // Harassment: physical - { - type = PageType.PhysicalHarassment; - break; - } - case 9: // Young player transport - { - if (IsYoung(from)) - { - if (from.Region.IsPartOf()) + if (house?.IsAosRules == true && !from.Region.IsPartOf()) // Dueling + { + from.Location = house.BanLocation; + } + else if (from.Region.IsPartOf()) + { from.SendLocalizedMessage(1114345, "", 0x35); // You'll need a better jailbreak plan than that! - else if (from.Region.IsPartOf("Haven Island")) - from.SendLocalizedMessage(1041529); // You're already in Haven - else - from.MoveToWorld(new Point3D(3503, 2574, 14), Map.Trammel); - } + } + else if (Sigil.ExistsOn(from)) + { + from.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. + } + else if (from is PlayerMobile mobile && mobile.CanUseStuckMenu() && + mobile.Region.CanUseStuckMenu(mobile) && !CheckCombat(mobile) && !mobile.Frozen && + !mobile.Criminal && (Core.AOS || mobile.Kills < 5)) + { + StuckMenu menu = new StuckMenu(mobile, mobile, true); - break; - } + menu.BeginClose(); + + mobile.SendGump(menu); + } + else + { + type = PageType.Stuck; + } + + break; + } + case 3: // Report bug or contact Origin + { + type = PageType.Bug; + break; + } + case 4: // Game suggestion + { + type = PageType.Suggestion; + break; + } + case 5: // Account management + { + type = PageType.Account; + break; + } + case 6: // Other + { + type = PageType.Other; + break; + } + case 7: // Harassment: verbal/exploit + { + type = PageType.VerbalHarassment; + break; + } + case 8: // Harassment: physical + { + type = PageType.PhysicalHarassment; + break; + } + case 9: // Young player transport + { + if (IsYoung(from)) + { + if (from.Region.IsPartOf()) + from.SendLocalizedMessage(1114345, "", 0x35); // You'll need a better jailbreak plan than that! + else if (from.Region.IsPartOf("Haven Island")) + from.SendLocalizedMessage(1041529); // You're already in Haven + else + from.MoveToWorld(new Point3D(3503, 2574, 14), Map.Trammel); + } + + break; + } } if (type != (PageType)(-1) && PageQueue.CheckAllowedToPage(from)) diff --git a/Projects/Scripts/Engines/Help/PagePrompt.cs b/Projects/Scripts/Engines/Help/PagePrompt.cs index 4ab9e3a79..a5e8e9717 100644 --- a/Projects/Scripts/Engines/Help/PagePrompt.cs +++ b/Projects/Scripts/Engines/Help/PagePrompt.cs @@ -4,7 +4,7 @@ namespace Server.Engines.Help { public class PagePrompt : Prompt { - private PageType m_Type; + private readonly PageType m_Type; public PagePrompt(PageType type) => m_Type = type; @@ -15,12 +15,12 @@ namespace Server.Engines.Help public override void OnResponse(Mobile from, string text) { - from.SendLocalizedMessage(501234, "", - 0x35); /* The next available Counselor/Game Master will respond as soon as possible. - * Please check your Journal for messages every few minutes. - */ + /* The next available Counselor/Game Master will respond as soon as possible. + * Please check your Journal for messages every few minutes. + */ + from.SendLocalizedMessage(501234, "", 0x35); PageQueue.Enqueue(new PageEntry(from, text, m_Type)); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Help/PagePromptGump.cs b/Projects/Scripts/Engines/Help/PagePromptGump.cs index 982991a35..8c738fee5 100644 --- a/Projects/Scripts/Engines/Help/PagePromptGump.cs +++ b/Projects/Scripts/Engines/Help/PagePromptGump.cs @@ -5,8 +5,8 @@ namespace Server.Engines.Help { public class PagePromptGump : Gump { - private Mobile m_From; - private PageType m_Type; + private readonly Mobile m_From; + private readonly PageType m_Type; public PagePromptGump(Mobile from, PageType type) : base(0, 0) { @@ -47,10 +47,10 @@ namespace Server.Engines.Help } else { - m_From.SendLocalizedMessage(501234, "", - 0x35); /* The next available Counselor/Game Master will respond as soon as possible. - * Please check your Journal for messages every few minutes. - */ + /* The next available Counselor/Game Master will respond as soon as possible. + * Please check your Journal for messages every few minutes. + */ + m_From.SendLocalizedMessage(501234, "", 0x35); PageQueue.Enqueue(new PageEntry(m_From, text, m_Type)); } diff --git a/Projects/Scripts/Engines/Help/PageQueue.cs b/Projects/Scripts/Engines/Help/PageQueue.cs index bce872da8..377222f43 100644 --- a/Projects/Scripts/Engines/Help/PageQueue.cs +++ b/Projects/Scripts/Engines/Help/PageQueue.cs @@ -79,9 +79,9 @@ namespace Server.Engines.Help private class InternalTimer : Timer { - private static TimeSpan StatusDelay = TimeSpan.FromMinutes(2.0); + private static readonly TimeSpan StatusDelay = TimeSpan.FromMinutes(2.0); - private PageEntry m_Entry; + private readonly PageEntry m_Entry; public InternalTimer(PageEntry entry) : base(TimeSpan.FromSeconds(1.0), StatusDelay) => m_Entry = entry; @@ -112,8 +112,8 @@ namespace Server.Engines.Help public class PageQueue { - private static Dictionary m_KeyedByHandler = new Dictionary(); - private static Dictionary m_KeyedBySender = new Dictionary(); + private static readonly Dictionary m_KeyedByHandler = new Dictionary(); + private static readonly Dictionary m_KeyedBySender = new Dictionary(); public static List List { get; } = new List(); @@ -204,7 +204,6 @@ namespace Server.Engines.Help Remove(GetEntry(sender)); } - public static void Enqueue(PageEntry entry) { List.Add(entry); @@ -231,6 +230,5 @@ namespace Server.Engines.Help if (Email.FROM_ADDRESS != null && Email.SPEECH_LOG_PAGE_ADDRESS != null && entry.SpeechLog != null) Email.SendQueueEmail(entry, GetPageTypeName(entry.Type)); } - } } diff --git a/Projects/Scripts/Engines/Help/PageQueueGump.cs b/Projects/Scripts/Engines/Help/PageQueueGump.cs index 5fbb7defa..869551bf1 100644 --- a/Projects/Scripts/Engines/Help/PageQueueGump.cs +++ b/Projects/Scripts/Engines/Help/PageQueueGump.cs @@ -8,8 +8,9 @@ namespace Server.Engines.Help { public class MessageSentGump : Gump { - private Mobile m_Mobile; - private string m_Name, m_Text; + private readonly Mobile m_Mobile; + private readonly string m_Name; + private readonly string m_Text; public MessageSentGump(Mobile mobile, string name, string text) : base(30, 30) { @@ -36,19 +37,19 @@ namespace Server.Engines.Help { m_Mobile.SendGump(new PageResponseGump(m_Mobile, m_Name, m_Text)); - //m_Mobile.SendMessage( 0x482, "{0} tells you:", m_Name ); - //m_Mobile.SendMessage( 0x482, m_Text ); + // m_Mobile.SendMessage( 0x482, "{0} tells you:", m_Name ); + // m_Mobile.SendMessage( 0x482, m_Text ); } } public class PageQueueGump : Gump { - private PageEntry[] m_List; + private readonly PageEntry[] m_List; public PageQueueGump() : base(30, 30) { Add(new GumpPage(0)); - //Add( new GumpBackground( 0, 0, 410, 448, 9200 ) ); + // Add( new GumpBackground( 0, 0, 410, 448, 9200 ) ); Add(new GumpImageTiled(0, 0, 410, 448, 0xA40)); Add(new GumpAlphaRegion(1, 1, 408, 446)); @@ -56,7 +57,7 @@ namespace Server.Engines.Help List list = PageQueue.List; - for (int i = 0;i < list.Count;) + for (int i = 0; i < list.Count;) { PageEntry e = list[i]; @@ -127,11 +128,11 @@ namespace Server.Engines.Help Message = message; } - public string Title{ get; set; } + public string Title { get; set; } - public string Message{ get; set; } + public string Message { get; set; } - public static List List{ get; private set; } = Load(); + public static List List { get; private set; } = Load(); public static PredefinedResponse Add(string title, string message) { @@ -203,8 +204,8 @@ namespace Server.Engines.Help { private const int LabelColor32 = 0xFFFFFF; - private Mobile m_From; - private PredefinedResponse m_Response; + private readonly Mobile m_From; + private readonly PredefinedResponse m_Response; public PredefGump(Mobile from, PredefinedResponse response) : base(30, 30) { @@ -343,36 +344,36 @@ namespace Server.Engines.Help switch (type) { case 0: // edit - { - m_From.SendGump(new PredefGump(m_From, resp)); - break; - } + { + m_From.SendGump(new PredefGump(m_From, resp)); + break; + } case 1: // move up - { - if (index > 0) { - list.RemoveAt(index); - list.Insert(index - 1, resp); + if (index > 0) + { + list.RemoveAt(index); + list.Insert(index - 1, resp); - PredefinedResponse.Save(); - m_From.SendGump(new PredefGump(m_From, null)); + PredefinedResponse.Save(); + m_From.SendGump(new PredefGump(m_From, null)); + } + + break; } - - break; - } case 2: // move down - { - if (index < list.Count - 1) { - list.RemoveAt(index); - list.Insert(index + 1, resp); + if (index < list.Count - 1) + { + list.RemoveAt(index); + list.Insert(index + 1, resp); - PredefinedResponse.Save(); - m_From.SendGump(new PredefGump(m_From, null)); + PredefinedResponse.Save(); + m_From.SendGump(new PredefGump(m_From, null)); + } + + break; } - - break; - } } } } @@ -384,37 +385,37 @@ namespace Server.Engines.Help switch (info.ButtonID) { case 1: - { - list.Remove(m_Response); + { + list.Remove(m_Response); - PredefinedResponse.Save(); - m_From.SendGump(new PredefGump(m_From, null)); - break; - } + PredefinedResponse.Save(); + m_From.SendGump(new PredefGump(m_From, null)); + break; + } case 2: - { - TextRelay te = info.GetTextEntry(0); + { + TextRelay te = info.GetTextEntry(0); - if (te != null) - m_Response.Title = te.Text; + if (te != null) + m_Response.Title = te.Text; - PredefinedResponse.Save(); - m_From.SendGump(new PredefGump(m_From, m_Response)); + PredefinedResponse.Save(); + m_From.SendGump(new PredefGump(m_From, m_Response)); - break; - } + break; + } case 3: - { - TextRelay te = info.GetTextEntry(1); + { + TextRelay te = info.GetTextEntry(1); - if (te != null) - m_Response.Message = te.Text; + if (te != null) + m_Response.Message = te.Text; - PredefinedResponse.Save(); - m_From.SendGump(new PredefGump(m_From, m_Response)); + PredefinedResponse.Save(); + m_From.SendGump(new PredefGump(m_From, m_Response)); - break; - } + break; + } } } } @@ -422,7 +423,7 @@ namespace Server.Engines.Help public class PageEntryGump : Gump { - private static int[] m_AccessLevelHues = + private static readonly int[] m_AccessLevelHues = { 2100, 2122, @@ -433,8 +434,8 @@ namespace Server.Engines.Help 2415 }; - private PageEntry m_Entry; - private Mobile m_Mobile; + private readonly PageEntry m_Entry; + private readonly Mobile m_Mobile; public PageEntryGump(Mobile m, PageEntry entry) : base(30, 30) { @@ -564,217 +565,217 @@ namespace Server.Engines.Help switch (info.ButtonID) { case 0: // close - { - if (m_Entry.Handler != state.Mobile) { - PageQueueGump g = new PageQueueGump(); + if (m_Entry.Handler != state.Mobile) + { + PageQueueGump g = new PageQueueGump(); - g.SendTo(state); + g.SendTo(state); + } + + break; } - - break; - } case 1: // go to sender - { - Mobile m = state.Mobile; - - if (m_Entry.Sender.Deleted) { - m.SendMessage("That character no longer exists."); - } - else if (m_Entry.Sender.Map == null || m_Entry.Sender.Map == Map.Internal) - { - m.SendMessage("That character is not in the world."); - } - else - { - // m_Entry.AddResponse(state.Mobile, "[Go Sender]"); - m.MoveToWorld(m_Entry.Sender.Location, m_Entry.Sender.Map); + Mobile m = state.Mobile; - m.SendMessage("You have been teleported to that page's sender."); - - Resend(state); - } - - break; - } - case 2: // go to handler - { - Mobile m = state.Mobile; - Mobile h = m_Entry.Handler; - - if (h != null) - { - if (h.Deleted) + if (m_Entry.Sender.Deleted) { m.SendMessage("That character no longer exists."); } - else if (h.Map == null || h.Map == Map.Internal) + else if (m_Entry.Sender.Map == null || m_Entry.Sender.Map == Map.Internal) { m.SendMessage("That character is not in the world."); } else { - // m_Entry.AddResponse(state.Mobile, "[Go Handler]"); - m.MoveToWorld(h.Location, h.Map); + // m_Entry.AddResponse(state.Mobile, "[Go Sender]"); + m.MoveToWorld(m_Entry.Sender.Location, m_Entry.Sender.Map); + + m.SendMessage("You have been teleported to that page's sender."); - m.SendMessage("You have been teleported to that page's handler."); Resend(state); } - } - else - { - m.SendMessage("Nobody is handling that page."); - Resend(state); - } - break; - } + break; + } + case 2: // go to handler + { + Mobile m = state.Mobile; + Mobile h = m_Entry.Handler; + + if (h != null) + { + if (h.Deleted) + { + m.SendMessage("That character no longer exists."); + } + else if (h.Map == null || h.Map == Map.Internal) + { + m.SendMessage("That character is not in the world."); + } + else + { + // m_Entry.AddResponse(state.Mobile, "[Go Handler]"); + m.MoveToWorld(h.Location, h.Map); + + m.SendMessage("You have been teleported to that page's handler."); + Resend(state); + } + } + else + { + m.SendMessage("Nobody is handling that page."); + Resend(state); + } + + break; + } case 3: // go to page location - { - Mobile m = state.Mobile; - - if (m_Entry.PageMap == null || m_Entry.PageMap == Map.Internal) { - m.SendMessage("That location is not in the world."); + Mobile m = state.Mobile; + + if (m_Entry.PageMap == null || m_Entry.PageMap == Map.Internal) + { + m.SendMessage("That location is not in the world."); + } + else + { + // m_Entry.AddResponse(state.Mobile, "[Go PageLoc]"); + m.MoveToWorld(m_Entry.PageLocation, m_Entry.PageMap); + + state.Mobile.SendMessage("You have been teleported to the original page location."); + + Resend(state); + } + + break; } - else - { - // m_Entry.AddResponse(state.Mobile, "[Go PageLoc]"); - m.MoveToWorld(m_Entry.PageLocation, m_Entry.PageMap); - - state.Mobile.SendMessage("You have been teleported to the original page location."); - - Resend(state); - } - - break; - } case 4: // handle page - { - if (m_Entry.Handler == null) { - // m_Entry.AddResponse(state.Mobile, "[Handling]"); - m_Entry.Handler = state.Mobile; + if (m_Entry.Handler == null) + { + // m_Entry.AddResponse(state.Mobile, "[Handling]"); + m_Entry.Handler = state.Mobile; - state.Mobile.SendMessage("You are now handling the page."); + state.Mobile.SendMessage("You are now handling the page."); + } + else + { + state.Mobile.SendMessage("Someone is already handling that page."); + } + + Resend(state); + + break; } - else - { - state.Mobile.SendMessage("Someone is already handling that page."); - } - - Resend(state); - - break; - } case 5: // delete page - { - if (m_Entry.Handler == null) { - // m_Entry.AddResponse(state.Mobile, "[Deleting]"); - PageQueue.Remove(m_Entry); + if (m_Entry.Handler == null) + { + // m_Entry.AddResponse(state.Mobile, "[Deleting]"); + PageQueue.Remove(m_Entry); - state.Mobile.SendMessage("You delete the page."); + state.Mobile.SendMessage("You delete the page."); - PageQueueGump g = new PageQueueGump(); + PageQueueGump g = new PageQueueGump(); - g.SendTo(state); + g.SendTo(state); + } + else + { + state.Mobile.SendMessage("Someone is handling that page, it can not be deleted."); + + Resend(state); + } + + break; } - else - { - state.Mobile.SendMessage("Someone is handling that page, it can not be deleted."); - - Resend(state); - } - - break; - } case 6: // abandon page - { - if (m_Entry.Handler == state.Mobile) { - // m_Entry.AddResponse(state.Mobile, "[Abandoning]"); - state.Mobile.SendMessage("You abandon the page."); + if (m_Entry.Handler == state.Mobile) + { + // m_Entry.AddResponse(state.Mobile, "[Abandoning]"); + state.Mobile.SendMessage("You abandon the page."); - m_Entry.Handler = null; - } - else - { - state.Mobile.SendMessage("You are not handling that page."); - } - - Resend(state); - - break; - } - case 7: // page handled - { - if (m_Entry.Handler == state.Mobile) - { - // m_Entry.AddResponse(state.Mobile, "[Handled]"); - PageQueue.Remove(m_Entry); - - m_Entry.Handler = null; - - state.Mobile.SendMessage("You mark the page as handled, and remove it from the queue."); - - PageQueueGump g = new PageQueueGump(); - - g.SendTo(state); - } - else - { - state.Mobile.SendMessage("You are not handling that page."); + m_Entry.Handler = null; + } + else + { + state.Mobile.SendMessage("You are not handling that page."); + } Resend(state); + + break; } + case 7: // page handled + { + if (m_Entry.Handler == state.Mobile) + { + // m_Entry.AddResponse(state.Mobile, "[Handled]"); + PageQueue.Remove(m_Entry); - break; - } + m_Entry.Handler = null; + + state.Mobile.SendMessage("You mark the page as handled, and remove it from the queue."); + + PageQueueGump g = new PageQueueGump(); + + g.SendTo(state); + } + else + { + state.Mobile.SendMessage("You are not handling that page."); + + Resend(state); + } + + break; + } case 8: // Send message - { - TextRelay text = info.GetTextEntry(0); + { + TextRelay text = info.GetTextEntry(0); - if (text != null) - // m_Entry.AddResponse(state.Mobile, "[Response] " + text.Text); - m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, text.Text)); - //m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name ); - //m_Entry.Sender.SendMessage( 0x482, text.Text ); + if (text != null) + // m_Entry.AddResponse(state.Mobile, "[Response] " + text.Text); + m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, text.Text)); + // m_Entry.Sender.SendMessage( 0x482, "{0} tells you:", state.Mobile.Name ); + // m_Entry.Sender.SendMessage( 0x482, text.Text ); - Resend(state); + Resend(state); - break; - } + break; + } case 9: // predef overview - { - Resend(state); - state.Mobile.SendGump(new PredefGump(state.Mobile, null)); + { + Resend(state); + state.Mobile.SendGump(new PredefGump(state.Mobile, null)); - break; - } + break; + } case 10: // View Speech Log - { - Resend(state); + { + Resend(state); - if (m_Entry.SpeechLog != null) state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog)); + if (m_Entry.SpeechLog != null) state.Mobile.SendGump(new SpeechLogGump(m_Entry.Sender, m_Entry.SpeechLog)); - break; - } + break; + } default: - { - int index = info.ButtonID - 100; - List preresp = PredefinedResponse.List; + { + int index = info.ButtonID - 100; + List preresp = PredefinedResponse.List; - if (index >= 0 && index < preresp.Count) - // m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title); - m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, - preresp[index].Message)); + if (index >= 0 && index < preresp.Count) + // m_Entry.AddResponse(state.Mobile, "[PreDef] " + preresp[index].Title); + m_Entry.Sender.SendGump(new MessageSentGump(m_Entry.Sender, state.Mobile.Name, + preresp[index].Message)); - Resend(state); + Resend(state); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/Help/PageResponseGump.cs b/Projects/Scripts/Engines/Help/PageResponseGump.cs index c3c6a6a80..240d35024 100644 --- a/Projects/Scripts/Engines/Help/PageResponseGump.cs +++ b/Projects/Scripts/Engines/Help/PageResponseGump.cs @@ -5,8 +5,9 @@ namespace Server.Engines.Help { public class PageResponseGump : Gump { - private Mobile m_From; - private string m_Name, m_Text; + private readonly Mobile m_From; + private readonly string m_Name; + private readonly string m_Text; public PageResponseGump(Mobile from, string name, string text) : base(0, 0) { diff --git a/Projects/Scripts/Engines/Help/SpeechLog.cs b/Projects/Scripts/Engines/Help/SpeechLog.cs index 2dc5ad7dc..941ddb727 100644 --- a/Projects/Scripts/Engines/Help/SpeechLog.cs +++ b/Projects/Scripts/Engines/Help/SpeechLog.cs @@ -19,24 +19,16 @@ namespace Server.Engines.Help // What is the maximum number of entries a log can contain? (0 -> no limit) public static readonly int MaxLength = 0; - private Queue m_Queue; + private readonly Queue m_Queue; public SpeechLog() => m_Queue = new Queue(); public int Count => m_Queue.Count; - #region IEnumerable Members - IEnumerator IEnumerable.GetEnumerator() => m_Queue.GetEnumerator(); - #endregion - - #region IEnumerable Members - IEnumerator IEnumerable.GetEnumerator() => m_Queue.GetEnumerator(); - #endregion - public static void Initialize() { CommandSystem.Register("SpeechLog", AccessLevel.Counselor, SpeechLog_OnCommand); @@ -127,10 +119,10 @@ namespace Server.Engines.Help Created = DateTime.UtcNow; } - public Mobile From{ get; } + public Mobile From { get; } - public string Speech{ get; } + public string Speech { get; } - public DateTime Created{ get; } + public DateTime Created { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Help/SpeechLogGump.cs b/Projects/Scripts/Engines/Help/SpeechLogGump.cs index 7996e18f7..a25eb1308 100644 --- a/Projects/Scripts/Engines/Help/SpeechLogGump.cs +++ b/Projects/Scripts/Engines/Help/SpeechLogGump.cs @@ -10,10 +10,10 @@ namespace Server.Engines.Help public class SpeechLogGump : Gump { public static readonly int MaxEntriesPerPage = 30; - private List m_Log; - private int m_Page; + private readonly List m_Log; + private readonly int m_Page; - private Mobile m_Player; + private readonly Mobile m_Player; public SpeechLogGump(Mobile player, SpeechLog log) : this(player, new List(log)) @@ -94,19 +94,19 @@ namespace Server.Engines.Help switch (info.ButtonID) { case 1: // Previous page - { - if (m_Page - 1 >= 0) - from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page - 1)); + { + if (m_Page - 1 >= 0) + from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page - 1)); - break; - } + break; + } case 2: // Next page - { - if ((m_Page + 1) * MaxEntriesPerPage < m_Log.Count) - from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page + 1)); + { + if ((m_Page + 1) * MaxEntriesPerPage < m_Log.Count) + from.SendGump(new SpeechLogGump(m_Player, m_Log, m_Page + 1)); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/Help/StuckMenu.cs b/Projects/Scripts/Engines/Help/StuckMenu.cs index 9c6519417..3c20535aa 100644 --- a/Projects/Scripts/Engines/Help/StuckMenu.cs +++ b/Projects/Scripts/Engines/Help/StuckMenu.cs @@ -14,14 +14,14 @@ namespace Server.Menus.Questions Locations = locations; } - public int Name{ get; } + public int Name { get; } - public Point3D[] Locations{ get; } + public Point3D[] Locations { get; } } public class StuckMenu : Gump { - private static StuckMenuEntry[] m_Entries = + private static readonly StuckMenuEntry[] m_Entries = { // Britain new StuckMenuEntry(1011028, new[] @@ -84,7 +84,7 @@ namespace Server.Menus.Questions }) }; - private static StuckMenuEntry[] m_T2AEntries = + private static readonly StuckMenuEntry[] m_T2AEntries = { // Papua new StuckMenuEntry(1011057, new[] @@ -107,9 +107,10 @@ namespace Server.Menus.Questions }) }; - private bool m_MarkUse; + private readonly bool m_MarkUse; - private Mobile m_Mobile, m_Sender; + private readonly Mobile m_Mobile; + private readonly Mobile m_Sender; private Timer m_Timer; @@ -143,7 +144,7 @@ namespace Server.Menus.Questions private static bool IsInSecondAgeArea(Mobile m) => (m.Map == Map.Trammel || m.Map == Map.Felucca) && - (m.X >= 5120 && m.Y >= 2304 || m.Region.IsPartOf("Terathan Keep")); + ((m.X >= 5120 && m.Y >= 2304) || m.Region.IsPartOf("Terathan Keep")); public void BeginClose() { @@ -204,8 +205,8 @@ namespace Server.Menus.Questions private class CloseTimer : Timer { - private DateTime m_End; - private Mobile m_Mobile; + private readonly DateTime m_End; + private readonly Mobile m_Mobile; public CloseTimer(Mobile m) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) { @@ -231,9 +232,9 @@ namespace Server.Menus.Questions private class TeleportTimer : Timer { - private StuckMenuEntry m_Destination; - private DateTime m_End; - private Mobile m_Mobile; + private readonly StuckMenuEntry m_Destination; + private readonly DateTime m_End; + private readonly Mobile m_Mobile; public TeleportTimer(Mobile mobile, StuckMenuEntry destination, TimeSpan delay) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Engines/Khaldun/Books/GrimmochJournal.cs b/Projects/Scripts/Engines/Khaldun/Books/GrimmochJournal.cs index 661b210df..ae117bd49 100644 --- a/Projects/Scripts/Engines/Khaldun/Books/GrimmochJournal.cs +++ b/Projects/Scripts/Engines/Khaldun/Books/GrimmochJournal.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class GrimmochJournal1 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day One :", "", "'Tis a grand sight, this", @@ -14,10 +12,8 @@ namespace Server.Items "with Tavara on that.", "And we've a good crew", "here, they've strong", - "backs and a good" - ), - new BookPageInfo - ( + "backs and a good"), + new BookPageInfo( "attitude. I'm a bit", "concerned by those", "that worked as guides", @@ -25,10 +21,8 @@ namespace Server.Items "seemed well enough", "until we revealed the", "immense stone doors", - "of the tomb structure" - ), - new BookPageInfo - ( + "of the tomb structure"), + new BookPageInfo( "itself. Seemed to send", "a shiver up their", "spines and get them all", @@ -36,10 +30,8 @@ namespace Server.Items "whispering. I'll", "watch the lot of them", "with a close eye, but", - "I'm confident we won't" - ), - new BookPageInfo - ( + "I'm confident we won't"), + new BookPageInfo( "have any real", "problems on the dig.", "I'm especially proud to", @@ -47,10 +39,8 @@ namespace Server.Items "out - he was a good", "hire, despite the", "warnings from his", - "previous employers." - ), - new BookPageInfo - ( + "previous employers."), + new BookPageInfo( "He's drummed up the", "workers into a", "furious pace - we've", @@ -58,9 +48,7 @@ namespace Server.Items "estimate on the", "timeline for", "excavating the Tomb's", - "entrance." - ) - ); + "entrance.")); [Constructible] public GrimmochJournal1() : base(Utility.Random(0xFF1, 2), false) @@ -90,11 +78,9 @@ namespace Server.Items public class GrimmochJournal2 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Two :", "", "We managed to dig out", @@ -102,10 +88,8 @@ namespace Server.Items "remaining rubble", "today, revealing the", "entirety of the giant", - "stone doors that sealed" - ), - new BookPageInfo - ( + "stone doors that sealed"), + new BookPageInfo( "ol' Khal Ankur and", "his folk up ages ago.", "Actually getting them", @@ -113,10 +97,8 @@ namespace Server.Items "matter altogether,", "however. As the", "workers set to the", - "task with picks and" - ), - new BookPageInfo - ( + "task with picks and"), + new BookPageInfo( "crowbars, I could have", "sworn I saw Lysander", "Gathenwale fiddling", @@ -124,10 +106,8 @@ namespace Server.Items "musty old tome of his.", " I've no great", "knowledge of things", - "magical, but the way" - ), - new BookPageInfo - ( + "magical, but the way"), + new BookPageInfo( "his hand moved over", "that book, and the look", "of concentration on his", @@ -135,10 +115,8 @@ namespace Server.Items "something to himself", "looked like every", "description of an", - "incantation I've ever" - ), - new BookPageInfo - ( + "incantation I've ever"), + new BookPageInfo( "heard. The strange", "thing is, this set of", "doors that an entire", @@ -146,10 +124,8 @@ namespace Server.Items "was laboring over for", "hours, right when", "Gathenwale finishes", - "with his mumbling..." - ), - new BookPageInfo - ( + "with his mumbling..."), + new BookPageInfo( "well, I swore the doors", "just gave open at the", "exact moment he", @@ -157,17 +133,13 @@ namespace Server.Items "whisper and shut the", "tome tight in his", "hands. When he", - "looked up, it was" - ), - new BookPageInfo - ( + "looked up, it was"), + new BookPageInfo( "almost as if he was", "expecting the doors to", "be open, rather than", "shocked that they'd", - "finally given way." - ) - ); + "finally given way.")); [Constructible] public GrimmochJournal2() : base(Utility.Random(0xFF1, 2), false) @@ -197,11 +169,9 @@ namespace Server.Items public class GrimmochJournal3 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Three - Day Five:", "", "I might have", @@ -209,10 +179,8 @@ namespace Server.Items "my first entry - this", "place doesn't seem too", "bent on giving up any", - "secrets. Though the" - ), - new BookPageInfo - ( + "secrets. Though the"), + new BookPageInfo( "main antechamber is", "open to us, the main", "exit hall is blocked by", @@ -220,10 +188,8 @@ namespace Server.Items "rubble. Doesn't look a", "bit like anything", "caused by a quake or", - "instability in the" - ), - new BookPageInfo - ( + "instability in the"), + new BookPageInfo( "stonework... I swear it", "looks as if someone", "actually piled the", @@ -231,10 +197,8 @@ namespace Server.Items "some time after the", "tomb was built. The", "stones aren't of the", - "same set nor quality" - ), - new BookPageInfo - ( + "same set nor quality"), + new BookPageInfo( "of the carved work", "that surrounds them", "- if anything, they", @@ -242,10 +206,8 @@ namespace Server.Items "common rock we saw", "in great quantities on", "the trip here. Which", - "makes it feel all the" - ), - new BookPageInfo - ( + "makes it feel all the"), + new BookPageInfo( "more like someone", "hauled them in and", "deliberately covered", @@ -253,10 +215,8 @@ namespace Server.Items "why not decorate them", "in the same ornate", "manner as the rest of", - "the stone in this" - ), - new BookPageInfo - ( + "the stone in this"), + new BookPageInfo( "place? Lysander", "wouldn't hear a word", "of what I had to say -", @@ -264,14 +224,10 @@ namespace Server.Items "some time in the", "history of the tomb,", "and that was it, shut", - "up and move on. So I" - ), - new BookPageInfo - ( + "up and move on. So I"), + new BookPageInfo( "shut up, and got back", - "to work." - ) - ); + "to work.")); [Constructible] public GrimmochJournal3() : base(Utility.Random(0xFF1, 2), false) @@ -301,11 +257,9 @@ namespace Server.Items public class GrimmochJournal6 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Six :", "", "The camp was", @@ -313,10 +267,8 @@ namespace Server.Items "a pack of, well, I don't", "have a clue. I've never", "seen the like of these", - "beasts anywhere." - ), - new BookPageInfo - ( + "beasts anywhere."), + new BookPageInfo( "Huge things, with", "fangs the size of your", "forefinger, covered in", @@ -324,10 +276,8 @@ namespace Server.Items "strangest arched back", "I've ever seen. And so", "many of them. We", - "were forced back into" - ), - new BookPageInfo - ( + "were forced back into"), + new BookPageInfo( "the Tomb for the", "night, just to keep our", "hides on us. And", @@ -335,10 +285,8 @@ namespace Server.Items "practically orders us", "all to move the entire", "exterior camp into the", - "Tomb. Now, I don't" - ), - new BookPageInfo - ( + "Tomb. Now, I don't"), + new BookPageInfo( "disagree that we'd be", "well off to use the", "place as a point of", @@ -346,10 +294,8 @@ namespace Server.Items "don't like it one bit, in", "any case. I don't like", "the look of this place,", - "nor the sound of it." - ), - new BookPageInfo - ( + "nor the sound of it."), + new BookPageInfo( "The way the wind", "gets into the", "passageways,", @@ -357,10 +303,8 @@ namespace Server.Items "strangest noises.", "Deep, sustained echoes", "of the wind, not so", - "much flute-like as..." - ), - new BookPageInfo - ( + "much flute-like as..."), + new BookPageInfo( "well, it sounds", "ridiculous. In any", "case, we've set to work", @@ -368,9 +312,7 @@ namespace Server.Items "exterior camp into the", "main antechamber, so", "there's no use moaning", - "about it now." - ) - ); + "about it now.")); [Constructible] public GrimmochJournal6() : base(Utility.Random(0xFF1, 2), false) @@ -400,11 +342,9 @@ namespace Server.Items public class GrimmochJournal7 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Seven - Day Ten:", "", "I cannot stand this", @@ -412,10 +352,8 @@ namespace Server.Items "I've got to get out.", "Something evil lurks", "in this ancient place,", - "something best left" - ), - new BookPageInfo - ( + "something best left"), + new BookPageInfo( "alone. I hear them,", "yet none of the others", "do. And yet they", @@ -423,10 +361,8 @@ namespace Server.Items "scratching at stone,", "the awful scratching", "and the piteous cries", - "that sound almost like" - ), - new BookPageInfo - ( + "that sound almost like"), + new BookPageInfo( "laughter. I can hear", "them above even the", "cracks of the", @@ -434,10 +370,8 @@ namespace Server.Items "at night they are all I", "can hear. And yet the", "others hear nothing.", - "We must leave this" - ), - new BookPageInfo - ( + "We must leave this"), + new BookPageInfo( "place, we must.", "Three workers have", "gone missing - Tavara", @@ -445,19 +379,15 @@ namespace Server.Items "abandoned us - and I", "count them lucky if", "they have. I don't care", - "what the others say," - ), - new BookPageInfo - ( + "what the others say,"), + new BookPageInfo( "we must leave this", "place. We must do as", "those before and pile", "up the stones, block all", "access to this primeval", "crypt, seal it up again", - "for all eternity." - ) - ); + "for all eternity.")); [Constructible] public GrimmochJournal7() : base(Utility.Random(0xFF1, 2), false) @@ -487,11 +417,9 @@ namespace Server.Items public class GrimmochJournal11 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Eleven - Day", "Thirteen :", "", @@ -499,10 +427,8 @@ namespace Server.Items "two more workers", "with him. Good", "riddance to the first.", - "He knows something." - ), - new BookPageInfo - ( + "He knows something."), + new BookPageInfo( "He heard them too, I", "know he did - and yet", "he scowled at me", @@ -510,10 +436,8 @@ namespace Server.Items "them. I cannot stop", "the noise in my head,", "the scratching, the", - "clawing tears at my" - ), - new BookPageInfo - ( + "clawing tears at my"), + new BookPageInfo( "senses. What is it?", "What does Lysander", "seek that I can only", @@ -521,13 +445,9 @@ namespace Server.Items "has he gone? The", "only answer to my", "questions comes as", - "laughter from behind" - ), - new BookPageInfo - ( - "the stones." - ) - ); + "laughter from behind"), + new BookPageInfo( + "the stones.")); [Constructible] public GrimmochJournal11() : base(Utility.Random(0xFF1, 2), false) @@ -557,11 +477,9 @@ namespace Server.Items public class GrimmochJournal14 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Fourteen - Day", "Sixteen :", "", @@ -569,10 +487,8 @@ namespace Server.Items "lost... all is lost. The", "dead are piled up at", "my feet. Bergen and I", - "somehow managed in" - ), - new BookPageInfo - ( + "somehow managed in"), + new BookPageInfo( "the madness to piece", "together a barricade,", "barring access to the", @@ -580,10 +496,8 @@ namespace Server.Items "He knows as well as I", "that we cannot hold it", "forever. The dead", - "come. They took" - ), - new BookPageInfo - ( + "come. They took"), + new BookPageInfo( "Lysander before our", "eyes. I pity the soul", "of even such a", @@ -591,10 +505,8 @@ namespace Server.Items "should die in such a", "manner. And yet so", "many have. We're", - "trapped here in this" - ), - new BookPageInfo - ( + "trapped here in this"), + new BookPageInfo( "horror. So many have", "died, and for what?", "What curse have we", @@ -602,19 +514,15 @@ namespace Server.Items "cannot bear it, the", "moaning, wailing cries", "of the dead. Poor", - "Thomas, cut to pieces" - ), - new BookPageInfo - ( + "Thomas, cut to pieces"), + new BookPageInfo( "by their blades. We", "had only an hour to", "properly bury those", "we could, before the", "undead legions struck", "again. I cannot go on...", - "I cannot go on." - ) - ); + "I cannot go on.")); [Constructible] public GrimmochJournal14() : base(Utility.Random(0xFF1, 2), false) @@ -644,11 +552,9 @@ namespace Server.Items public class GrimmochJournal17 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Seventeen - Day", "Twenty-Two :", "", @@ -656,10 +562,8 @@ namespace Server.Items "ceases... the blood", "never stops flowing,", "like a river through", - "the bloated corpses of" - ), - new BookPageInfo - ( + "the bloated corpses of"), + new BookPageInfo( "the dead. And yet", "there are still more.", "Always more, with", @@ -667,10 +571,8 @@ namespace Server.Items "in their eyes. My", "arm aches, I've taken", "to the sword as my", - "bow seems to do little" - ), - new BookPageInfo - ( + "bow seems to do little"), + new BookPageInfo( "good... the dull ache in", "my arm... so many", "swings, cleaving a", @@ -678,10 +580,8 @@ namespace Server.Items "flesh. And Thomas...", "he was there, in the", "thick of it... Thomas", - "was beside me..." - ), - new BookPageInfo - ( + "was beside me..."), + new BookPageInfo( "his face cleaved in", "twain - and yet beside", "me, fighting with us", @@ -689,10 +589,8 @@ namespace Server.Items "he was cut down once", "again. And I swear I", "see him even now,", - "there in the dark" - ), - new BookPageInfo - ( + "there in the dark"), + new BookPageInfo( "corner of the", "antechamber, his eyes", "flickering in the last", @@ -700,13 +598,9 @@ namespace Server.Items "fire... and he stares at", "me, and a scream fills", "the vault - whether", - "his or mine, I can no" - ), - new BookPageInfo - ( - "longer tell." - ) - ); + "his or mine, I can no"), + new BookPageInfo( + "longer tell.")); [Constructible] public GrimmochJournal17() : base(Utility.Random(0xFF1, 2), false) @@ -736,17 +630,13 @@ namespace Server.Items public class GrimmochJournal23 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The daily journal of Grimmoch Drummel", "Grimmoch", - new BookPageInfo - ( + new BookPageInfo( "Day Twenty-Three :", "", "We no longer bury the", - "dead." - ) - ); + "dead.")); [Constructible] public GrimmochJournal23() : base(Utility.Random(0xFF1, 2), false) @@ -773,4 +663,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Khaldun/Books/LysanderNotebook.cs b/Projects/Scripts/Engines/Khaldun/Books/LysanderNotebook.cs index 864cd7a2d..8e5c62f7f 100644 --- a/Projects/Scripts/Engines/Khaldun/Books/LysanderNotebook.cs +++ b/Projects/Scripts/Engines/Khaldun/Books/LysanderNotebook.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class LysanderNotebook1 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Lysander's Notebook", "L. Gathenwale", - new BookPageInfo - ( + new BookPageInfo( "Day One :", "", "At last, it stands", @@ -14,10 +12,8 @@ namespace Server.Items "of Thy Sanctum will", "open to me now, after", "all these years of", - "searching. I give" - ), - new BookPageInfo - ( + "searching. I give"), + new BookPageInfo( "myself unto Thee,", "Khal Ankur, I have", "come for Thy secrets", @@ -25,13 +21,9 @@ namespace Server.Items "prostrate before Thee.", " Blessed are the", "Keepers, praise unto", - "Thee, a thousand" - ), - new BookPageInfo - ( - "fortunes in the night." - ) - ); + "Thee, a thousand"), + new BookPageInfo( + "fortunes in the night.")); [Constructible] public LysanderNotebook1() : base(Utility.Random(0xFF1, 2), false) @@ -61,11 +53,9 @@ namespace Server.Items public class LysanderNotebook2 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Lysander's Notebook", "L. Gathenwale", - new BookPageInfo - ( + new BookPageInfo( "Day Two:", "", "The woman, Tavara", @@ -73,10 +63,8 @@ namespace Server.Items "Her entire demeanor", "sickens me. I would", "take her life for Thee", - "now, my Lord. But I" - ), - new BookPageInfo - ( + "now, my Lord. But I"), + new BookPageInfo( "cannot alert the", "others. Progress is", "made too slowly, I", @@ -84,10 +72,8 @@ namespace Server.Items "perpetual waiting.", "Today I knelt down", "with the workers,", - "tossing stones and dirt" - ), - new BookPageInfo - ( + "tossing stones and dirt"), + new BookPageInfo( "aside with my very", "hands as they dug at", "the last of the rubble", @@ -95,10 +81,8 @@ namespace Server.Items "to Thy Sanctum. The", "Sewel woman was", "shocked at my", - "demeanor, dirtying" - ), - new BookPageInfo - ( + "demeanor, dirtying"), + new BookPageInfo( "my robes, on my", "knees in the muck as I", "clawed at the rocks.", @@ -106,10 +90,8 @@ namespace Server.Items "for those sickly", "scholars, or for her,", "or for what she", - "laughably calls 'The" - ), - new BookPageInfo - ( + "laughably calls 'The"), + new BookPageInfo( "Gift of Discovery', of", "learning. As if I did", "not know what I went", @@ -117,16 +99,12 @@ namespace Server.Items "Thee, Master. Soon", "shall I receive Thy", "gifts, Thy blessings.", - "Patience, eternal" - ), - new BookPageInfo - ( + "Patience, eternal"), + new BookPageInfo( "patience. I must take", "my lessons well. I", "have learned from", - "Thee, Master, I have." - ) - ); + "Thee, Master, I have.")); [Constructible] public LysanderNotebook2() : base(Utility.Random(0xFF1, 2), false) @@ -156,11 +134,9 @@ namespace Server.Items public class LysanderNotebook3 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Lysander's Notebook", "L. Gathenwale", - new BookPageInfo - ( + new BookPageInfo( "Day Three - Day Six:", "", "What are these Beasts", @@ -168,10 +144,8 @@ namespace Server.Items "presence here? Hast", "Thou sent them,", "Master? To tear", - "apart these foolish" - ), - new BookPageInfo - ( + "apart these foolish"), + new BookPageInfo( "ones that accompany", "me? That repugnant", "pustule, Drummel, put", @@ -179,10 +153,8 @@ namespace Server.Items "theories as to the", "nature of the Beasts", "that attacked our", - "camp, but I'll have" - ), - new BookPageInfo - ( + "camp, but I'll have"), + new BookPageInfo( "none of his words. He", "asks too many", "questions. He is a", @@ -190,10 +162,8 @@ namespace Server.Items "of Thy Sanctum,", "Master - I will deal", "with him after the", - "Sewel woman." - ), - new BookPageInfo - ( + "Sewel woman."), + new BookPageInfo( "Speaking of Sewel, I", "have convinced that", "empty-headed harlot", @@ -201,10 +171,8 @@ namespace Server.Items "our encampment", "within the", "antechamber. She", - "thinks I worry for" - ), - new BookPageInfo - ( + "thinks I worry for"), + new BookPageInfo( "her safety. I come", "for thee, Master. I", "make my camp in Thy", @@ -212,9 +180,7 @@ namespace Server.Items "under Thy roof. I can", "feel Thine presence", "even now. Soon,", - "Master. Soon." - ) - ); + "Master. Soon.")); [Constructible] public LysanderNotebook3() : base(Utility.Random(0xFF1, 2), false) @@ -244,11 +210,9 @@ namespace Server.Items public class LysanderNotebook7 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Lysander's Notebook", "L. Gathenwale", - new BookPageInfo - ( + new BookPageInfo( "Day Seven :", "", "The Sewel woman", @@ -256,10 +220,8 @@ namespace Server.Items "And she dares to", "speak Thy Name,", "Master! I wish so", - "vehemently to take a" - ), - new BookPageInfo - ( + "vehemently to take a"), + new BookPageInfo( "knife to that little", "neck of hers. She", "struts around the", @@ -267,10 +229,8 @@ namespace Server.Items "Sanctum with her", "repugnant airs, her", "scholarly conjecture", - "on this or that. That I" - ), - new BookPageInfo - ( + "on this or that. That I"), + new BookPageInfo( "could peel the skin", "from her face and", "show her how vile and", @@ -278,10 +238,8 @@ namespace Server.Items "unworthy of entrance", "to Thy Sanctum. I", "must take her,", - "Master. I must rend" - ), - new BookPageInfo - ( + "Master. I must rend"), + new BookPageInfo( "that little wench to", "pieces. I ask this gift", "of Thee, that I might", @@ -289,10 +247,8 @@ namespace Server.Items "of her presence. Give", "me the Sewel woman", "and I shall show you", - "my mastery of Death," - ), - new BookPageInfo - ( + "my mastery of Death,"), + new BookPageInfo( "Master. I shall cut", "her to bits and scatter", "them before the", @@ -300,10 +256,8 @@ namespace Server.Items "I cannot stand her", "presence, I cannot", "abide it. And", - "Drummel! He is a" - ), - new BookPageInfo - ( + "Drummel! He is a"), + new BookPageInfo( "pustule that must be", "lanced, a sickness that", "I must cure by blade", @@ -311,15 +265,11 @@ namespace Server.Items "of him will be left", "when I'm done with", "him. Praises to Thee,", - "Master. I shall honor" - ), - new BookPageInfo - ( + "Master. I shall honor"), + new BookPageInfo( "Thee with many", "sacrifices, soon", - "enough." - ) - ); + "enough.")); [Constructible] public LysanderNotebook7() : base(Utility.Random(0xFF1, 2), false) @@ -349,11 +299,9 @@ namespace Server.Items public class LysanderNotebook8 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Lysander's Notebook", "L. Gathenwale", - new BookPageInfo - ( + new BookPageInfo( "Day Eight - Day Ten :", "", "Have you taken them,", @@ -361,10 +309,8 @@ namespace Server.Items "not have found a way", "past the stones that", "block our path! The", - "three workers, My" - ), - new BookPageInfo - ( + "three workers, My"), + new BookPageInfo( "Master, where have", "they gone? Curses", "upon them! I'll cut", @@ -372,10 +318,8 @@ namespace Server.Items "they show their faces", "again, then burn the", "rest alive upon a pyre,", - "for all to see, as a" - ), - new BookPageInfo - ( + "for all to see, as a"), + new BookPageInfo( "warning of Thy", "Power. How could", "they have gotten past", @@ -383,10 +327,8 @@ namespace Server.Items "the very walls, to", "hear Thy Words, to", "feel Thy Breath. I", - "can find no egress" - ), - new BookPageInfo - ( + "can find no egress"), + new BookPageInfo( "from the chambers", "that the Sewel woman", "does not know of nor", @@ -394,10 +336,8 @@ namespace Server.Items "excavating. Where", "have they gone,", "Master? Have you", - "taken them, or do they" - ), - new BookPageInfo - ( + "taken them, or do they"), + new BookPageInfo( "truly flee from Thy", "Presence? I will kill", "them if they show", @@ -405,16 +345,12 @@ namespace Server.Items "Give me Strength, my", "Master, to let them", "live a while longer,", - "until they have" - ), - new BookPageInfo - ( + "until they have"), + new BookPageInfo( "fulfilled their", "purpose and I kneel", "before Thee, covered", - "in their blood." - ) - ); + "in their blood.")); [Constructible] public LysanderNotebook8() : base(Utility.Random(0xFF1, 2), false) @@ -444,11 +380,9 @@ namespace Server.Items public class LysanderNotebook11 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Lysander's Notebook", "L. Gathenwale", - new BookPageInfo - ( + new BookPageInfo( "Day Eleven - Day", "Thirteen:", "", @@ -456,10 +390,8 @@ namespace Server.Items "Master. I come! The", "way is clear, I have", "found Thy path and", - "washed it in the blood" - ), - new BookPageInfo - ( + "washed it in the blood"), + new BookPageInfo( "of the two workers", "that caught sight of", "me. Ah, how sweet it", @@ -467,10 +399,8 @@ namespace Server.Items "to see the blood pour", "out in great torrents, to", "stand in it, to revel in", - "it. If only I had time" - ), - new BookPageInfo - ( + "it. If only I had time"), + new BookPageInfo( "for the Sewel woman.", "But there will be time", "enough for her. I", @@ -478,10 +408,8 @@ namespace Server.Items "Patience, Master. I", "come for Thee. I walk", "Thy halls in penance,", - "my last steps in this" - ), - new BookPageInfo - ( + "my last steps in this"), + new BookPageInfo( "repulsive living", "frame. I come for", "Thee and Thy Gifts,", @@ -489,10 +417,8 @@ namespace Server.Items "Unto Thee, Khal", "Ankur, Keeper of the", "Seventh Death,", - "Master, Leader of the" - ), - new BookPageInfo - ( + "Master, Leader of the"), + new BookPageInfo( "Chosen, the Khaldun.", "Praises in Thy", "Name, Master of Life", @@ -500,13 +426,9 @@ namespace Server.Items " Khal Ankur, Master,", "Prophet, I join Thy", "ranks this night, a", - "member of the" - ), - new BookPageInfo - ( - "Khaldun at last!" - ) - ); + "member of the"), + new BookPageInfo( + "Khaldun at last!")); [Constructible] public LysanderNotebook11() : base(Utility.Random(0xFF1, 2), false) diff --git a/Projects/Scripts/Engines/Khaldun/Books/TavarasJournal.cs b/Projects/Scripts/Engines/Khaldun/Books/TavarasJournal.cs index 42b46a306..38c7fb192 100644 --- a/Projects/Scripts/Engines/Khaldun/Books/TavarasJournal.cs +++ b/Projects/Scripts/Engines/Khaldun/Books/TavarasJournal.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class TavarasJournal1 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day One:", "", "The workers continue", @@ -14,10 +12,8 @@ namespace Server.Items "efforts to unload our", "supplies even as light", "fades. I feel I should", - "lend a hand in the" - ), - new BookPageInfo - ( + "lend a hand in the"), + new BookPageInfo( "effort, and yet I", "cannot bear to take my", "attention away from", @@ -25,10 +21,8 @@ namespace Server.Items "doors of the tomb.", "Every inch of their", "massive frame is", - "covered with" - ), - new BookPageInfo - ( + "covered with"), + new BookPageInfo( "intricately carved", "design work - 'tis", "truly a sight to see.", @@ -36,10 +30,8 @@ namespace Server.Items "sketching and", "cataloging what I can", "of them while my", - "companions set up our" - ), - new BookPageInfo - ( + "companions set up our"), + new BookPageInfo( "camp and make", "preparations for", "tomorrow's work.", @@ -47,10 +39,8 @@ namespace Server.Items "symbols inspire me to", "new flights of fancy,", "some of the workers", - "seem strangely" - ), - new BookPageInfo - ( + "seem strangely"), + new BookPageInfo( "fearful of them. I", "cannot wait 'til the", "morrow when those", @@ -58,14 +48,10 @@ namespace Server.Items "shall swing open and", "deliver unto me", "everything I have", - "dreamed of for the" - ), - new BookPageInfo - ( + "dreamed of for the"), + new BookPageInfo( "last ten years of my", - "life." - ) - ); + "life.")); [Constructible] public TavarasJournal1() : base(Utility.Random(0xFF1, 2), false) @@ -95,11 +81,9 @@ namespace Server.Items public class TavarasJournal2 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Two:", "", "Everything we'd", @@ -107,10 +91,8 @@ namespace Server.Items "tomb has proved", "correct - and yet,", "nothing could prepare", - "me for the sight of it" - ), - new BookPageInfo - ( + "me for the sight of it"), + new BookPageInfo( "with my own eyes.", "The Tomb of Khal", "Ankur has given up", @@ -118,10 +100,8 @@ namespace Server.Items "intricate stonework", "that covered the tomb", "doors seems to", - "continue throughout" - ), - new BookPageInfo - ( + "continue throughout"), + new BookPageInfo( "the entirety of the", "catacombs, each", "hallway and room", @@ -129,10 +109,8 @@ namespace Server.Items "endless amount of", "information for my", "companions and I to", - "record. It will take" - ), - new BookPageInfo - ( + "record. It will take"), + new BookPageInfo( "years to catalogue the", "entirety of the Tomb,", "if those legends of its", @@ -140,10 +118,8 @@ namespace Server.Items "true. Sadly, a good", "deal of the Tomb's", "interior has been", - "damaged or utterly" - ), - new BookPageInfo - ( + "damaged or utterly"), + new BookPageInfo( "destroyed, whether", "by seismic activity in", "the surrounding", @@ -151,10 +127,8 @@ namespace Server.Items "merely the slow", "efforts of Time", "itself, I do not know.", - "A good deal of the" - ), - new BookPageInfo - ( + "A good deal of the"), + new BookPageInfo( "stonework has been", "cracked or collapsed", "entirely, especially", @@ -162,10 +136,8 @@ namespace Server.Items "supports of the main", "hall. Our passage has", "indeed already been", - "entirely blocked in the" - ), - new BookPageInfo - ( + "entirely blocked in the"), + new BookPageInfo( "first major room", "we've discovered, a", "massive pile of", @@ -173,10 +145,8 @@ namespace Server.Items "blocking any exit", "from the", "antechamber. What", - "could have caused" - ), - new BookPageInfo - ( + "could have caused"), + new BookPageInfo( "such a localized", "disruption of the", "support structures,", @@ -184,17 +154,13 @@ namespace Server.Items "but it will surely take", "an entire afternoon's", "effort to remove even", - "a fraction of it. I look" - ), - new BookPageInfo - ( + "a fraction of it. I look"), + new BookPageInfo( "forward to more", "progress tomorrow", "once the workers have", "set to excavating the", - "hall." - ) - ); + "hall.")); [Constructible] public TavarasJournal2() : base(Utility.Random(0xFF1, 2), false) @@ -224,11 +190,9 @@ namespace Server.Items public class TavarasJournal3 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Three - Day Five:", "", "I do not understand", @@ -236,10 +200,8 @@ namespace Server.Items "once thought I did.", "Something palatable", "seems to hinder our", - "every attempt to" - ), - new BookPageInfo - ( + "every attempt to"), + new BookPageInfo( "investigate this", "ancient site.", "Excavation work on", @@ -247,10 +209,8 @@ namespace Server.Items "hallway finished only", "yesterday - the", "amount of stone and", - "rubble blocking the" - ), - new BookPageInfo - ( + "rubble blocking the"), + new BookPageInfo( "egress was", "astounding, it stands", "in immense piles", @@ -258,10 +218,8 @@ namespace Server.Items "entrance, as if we", "were digging the", "tunnels of this", - "abhorred place" - ), - new BookPageInfo - ( + "abhorred place"), + new BookPageInfo( "ourselves! The", "satisfaction of", "completing our efforts", @@ -269,10 +227,8 @@ namespace Server.Items "however, as we", "discovered the end of", "the hallway we had", - "just revealed was" - ), - new BookPageInfo - ( + "just revealed was"), + new BookPageInfo( "blocked by yet another", "colossal pile of stone.", "I've had a few of the", @@ -280,18 +236,14 @@ namespace Server.Items "primitive scaffolding", "in the main", "antechamber so that I", - "can spend my time" - ), - new BookPageInfo - ( + "can spend my time"), + new BookPageInfo( "pouring over the detail", "work on the stone", "carvings while the", "rest of our crew", "continue excavating", - "the inner halls." - ) - ); + "the inner halls.")); [Constructible] public TavarasJournal3() : base(Utility.Random(0xFF1, 2), false) @@ -321,11 +273,9 @@ namespace Server.Items public class TavarasJournal6 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Six:", "", "Late last night our", @@ -333,10 +283,8 @@ namespace Server.Items "a pack of wild beasts", "- behemoth creatures", "with a speed and", - "viciousness I'd n'ere" - ), - new BookPageInfo - ( + "viciousness I'd n'ere"), + new BookPageInfo( "before seen. Even", "Grimmoch, well", "versed in all manner", @@ -344,10 +292,8 @@ namespace Server.Items "unsure as to their", "nature - though I lay", "blame upon the", - "darkness covering" - ), - new BookPageInfo - ( + "darkness covering"), + new BookPageInfo( "their movements", "rather than on his", "skill as a huntsman.", @@ -355,10 +301,8 @@ namespace Server.Items "up the entire night,", "and we were", "eventually forced to", - "flee into the Tomb" - ), - new BookPageInfo - ( + "flee into the Tomb"), + new BookPageInfo( "itself to take refuge", "from the ravenous", "creatures - e'en", @@ -366,10 +310,8 @@ namespace Server.Items "could not keep the foul", "things from attacking", "in great numbers.", - "The Tomb performed" - ), - new BookPageInfo - ( + "The Tomb performed"), + new BookPageInfo( "well as an impromptu", "fortress, and we", "managed to spend the", @@ -377,10 +319,8 @@ namespace Server.Items "Morning's light", "seemed to have", "scattered the beasts,", - "as not a single one of" - ), - new BookPageInfo - ( + "as not a single one of"), + new BookPageInfo( "them was to be seen as", "we exited the Tomb -", "not even a carcass of", @@ -388,10 +328,8 @@ namespace Server.Items "slain a'fore we fled.", "Lysander set the crew", "to work, moving our", - "supplies and gear into" - ), - new BookPageInfo - ( + "supplies and gear into"), + new BookPageInfo( "the Tomb, in case the", "creatures did opt to", "return. Such savage", @@ -399,9 +337,7 @@ namespace Server.Items "and not a single one", "ever turned to run,", "even in the face of", - "certain death." - ) - ); + "certain death.")); [Constructible] public TavarasJournal6() : base(Utility.Random(0xFF1, 2), false) @@ -431,11 +367,9 @@ namespace Server.Items public class TavarasJournal7 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Seven:", "", "T'was written that,", @@ -443,10 +377,8 @@ namespace Server.Items "Ankur's followers,", "those known as the", "Keepers of the", - "Seventh Death, sealed" - ), - new BookPageInfo - ( + "Seventh Death, sealed"), + new BookPageInfo( "themselves within the", "Sanctum they had", "carved from the", @@ -454,10 +386,8 @@ namespace Server.Items "honor. The Zealots of", "his order entombed", "the lesser followers", - "alive, then, when all" - ), - new BookPageInfo - ( + "alive, then, when all"), + new BookPageInfo( "but two remained, slit", "their throats and", "joined Khal Ankur in", @@ -465,10 +395,8 @@ namespace Server.Items "not surprising for a", "Cult that worshipped", "death and sacrifice so", - "vehemently as it is" - ), - new BookPageInfo - ( + "vehemently as it is"), + new BookPageInfo( "said that the Keepers", "did - and yet, to be in", "this Tomb, to know", @@ -476,10 +404,8 @@ namespace Server.Items "depths hundreds upon", "hundreds of bodies", "lay, sealed alive at", - "their own behest..." - ), - new BookPageInfo - ( + "their own behest..."), + new BookPageInfo( "I must confess that", "the very thought of it", "troubles my dreams at", @@ -487,19 +413,15 @@ namespace Server.Items "Lysander if we might", "reestablish the camp", "outside the Tomb,", - "setting up night" - ), - new BookPageInfo - ( + "setting up night"), + new BookPageInfo( "watches and some sort", "of fortification, but", "he'll have none of it. I", "did not press the", "issue, as I suddenly", "felt foolish even at", - "my askance." - ) - ); + "my askance.")); [Constructible] public TavarasJournal7() : base(Utility.Random(0xFF1, 2), false) @@ -529,11 +451,9 @@ namespace Server.Items public class TavarasJournal8 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Eight :", "", "Astounding progress", @@ -541,10 +461,8 @@ namespace Server.Items "my very head spins", "with the excitement", "of it. Upon full", - "excavation of the far" - ), - new BookPageInfo - ( + "excavation of the far"), + new BookPageInfo( "western hall, another", "large antechamber", "was revealed. By the", @@ -552,10 +470,8 @@ namespace Server.Items "the wall carvings and", "their framing, as well", "as the numerous", - "vellum scrolls and" - ), - new BookPageInfo - ( + "vellum scrolls and"), + new BookPageInfo( "tomes held within, the", "room appears to have", "been a great museum", @@ -563,10 +479,8 @@ namespace Server.Items "The sheer amount of", "written information", "encased within this", - "room would surely" - ), - new BookPageInfo - ( + "room would surely"), + new BookPageInfo( "take me decades to", "study e'en if I could", "immediately decipher", @@ -574,10 +488,8 @@ namespace Server.Items "which it was written.", "My sheer joy at the", "discovery was quickly", - "noted by the brute" - ), - new BookPageInfo - ( + "noted by the brute"), + new BookPageInfo( "known as Morg", "Bergen, who, even in", "his simple way,", @@ -585,10 +497,8 @@ namespace Server.Items "delighted as I that", "some progress had", "been made. I must", - "confess, upon his" - ), - new BookPageInfo - ( + "confess, upon his"), + new BookPageInfo( "inclusion in our party", "at the beginning of", "this journey I was", @@ -596,10 +506,8 @@ namespace Server.Items "his nature, but he has", "a startlingly quick wit", "about him for such a", - "massive, calloused" - ), - new BookPageInfo - ( + "massive, calloused"), + new BookPageInfo( "warrior. While", "Lysander and e'en", "Grimmoch always", @@ -607,17 +515,13 @@ namespace Server.Items "tomb with a scowling", "determination, Bergen", "seems to feel the same", - "thrill of discovery as" - ), - new BookPageInfo - ( + "thrill of discovery as"), + new BookPageInfo( "I. I am proud to now", "count him as a friend,", "and am thankful for", "his laughter as well", - "as his strength." - ) - ); + "as his strength.")); [Constructible] public TavarasJournal8() : base(Utility.Random(0xFF1, 2), false) @@ -647,11 +551,9 @@ namespace Server.Items public class TavarasJournal9 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Nine - Day Ten:", "", "The excavation of the", @@ -659,10 +561,8 @@ namespace Server.Items "has ceased, as three", "of the workers have", "gone missing in the", - "night. Bergen voiced" - ), - new BookPageInfo - ( + "night. Bergen voiced"), + new BookPageInfo( "the opinion that they", "had most likely", "abandoned our group", @@ -670,10 +570,8 @@ namespace Server.Items "back, as they were of", "the number that", "seemed especially", - "disturbed by the" - ), - new BookPageInfo - ( + "disturbed by the"), + new BookPageInfo( "Tomb. Lysander had", "other ideas, however.", "In the middle of our", @@ -681,10 +579,8 @@ namespace Server.Items "matter, he went into a", "wild tirade on the", "possibility that they", - "had somehow" - ), - new BookPageInfo - ( + "had somehow"), + new BookPageInfo( "infiltrated the tomb's", "interior without us.", "The pure, hateful", @@ -692,10 +588,8 @@ namespace Server.Items "when he spoke of the", "workers shocked me,", "as I had always", - "thought him to be a" - ), - new BookPageInfo - ( + "thought him to be a"), + new BookPageInfo( "levelheaded man of", "great learning. As we", "are still at work", @@ -703,15 +597,11 @@ namespace Server.Items "that blocks all access", "to the inner chambers,", "I cannot help but", - "believe the workers" - ), - new BookPageInfo - ( + "believe the workers"), + new BookPageInfo( "must have fled the", "site altogether, as", - "Bergen said." - ) - ); + "Bergen said.")); [Constructible] public TavarasJournal9() : base(Utility.Random(0xFF1, 2), false) @@ -741,11 +631,9 @@ namespace Server.Items public class TavarasJournal11 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Eleven - Day", "Thirteen:", "", @@ -753,10 +641,8 @@ namespace Server.Items "have gone missing.", "Even more disturbing", "is the fact that", - "Lysander has joined" - ), - new BookPageInfo - ( + "Lysander has joined"), + new BookPageInfo( "them. Late last night", "the workers finished", "excavating the next", @@ -764,10 +650,8 @@ namespace Server.Items "retired to the main", "antechamber and our", "camp to rest up for", - "exploration on the" - ), - new BookPageInfo - ( + "exploration on the"), + new BookPageInfo( "'morrow. In the", "middle of the night we", "woke to a strange", @@ -775,10 +659,8 @@ namespace Server.Items "the men prepared", "themselves for", "another onslaught of", - "the beasts that had" - ), - new BookPageInfo - ( + "the beasts that had"), + new BookPageInfo( "troubled our outer", "camp, it was noticed", "that Lysander was", @@ -786,10 +668,8 @@ namespace Server.Items "number. I cannot", "fathom where he has", "gone - the newly", - "revealed chamber" - ), - new BookPageInfo - ( + "revealed chamber"), + new BookPageInfo( "holds no immediate", "egress, blocked again", "by piles of stone and", @@ -797,10 +677,8 @@ namespace Server.Items "believe that Lysander,", "of all people, would", "have fled this site -", - "indeed, he had lately" - ), - new BookPageInfo - ( + "indeed, he had lately"), + new BookPageInfo( "grown almost fanatical", "in his work to", "discover more of the", @@ -808,10 +686,8 @@ namespace Server.Items "by the consistently", "slow progress of", "excavating each new", - "hallway. The men are" - ), - new BookPageInfo - ( + "hallway. The men are"), + new BookPageInfo( "at work even now, and", "as the ceaseless", "thumps and cracks of", @@ -819,17 +695,13 @@ namespace Server.Items "reverberate", "throughout the", "entirety of the tomb,", - "the dust continues to" - ), - new BookPageInfo - ( + "the dust continues to"), + new BookPageInfo( "pour down from the", "ancient stonework", "above us like some", "horrible, eldritch", - "curse upon us all." - ) - ); + "curse upon us all.")); [Constructible] public TavarasJournal11() : base(Utility.Random(0xFF1, 2), false) @@ -859,11 +731,9 @@ namespace Server.Items public class TavarasJournal14 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Fourteen - Day", "Fifteen:", "", @@ -871,10 +741,8 @@ namespace Server.Items "returned... and yet,", "how can I describe the", "horror of it? He", - "stands across the" - ), - new BookPageInfo - ( + "stands across the"), + new BookPageInfo( "chamber from me", "even now, a changed", "man. His hair hangs", @@ -882,10 +750,8 @@ namespace Server.Items "his face, his clothes", "filthy and torn in", "places... and the blood", - "- covered in blood, his" - ), - new BookPageInfo - ( + "- covered in blood, his"), + new BookPageInfo( "skin shining in", "scarlet reflections of", "the torchlight. He", @@ -893,10 +759,8 @@ namespace Server.Items "approach; a thick,", "rusted dagger in his", "hand warding off any", - "attempts to overcome" - ), - new BookPageInfo - ( + "attempts to overcome"), + new BookPageInfo( "him. And the blood,", "which runs down in", "great rivulets from", @@ -904,10 +768,8 @@ namespace Server.Items "it is not his own, and", "this is enough to keep", "us at a wary distance.", - "Morg Bergen wishes" - ), - new BookPageInfo - ( + "Morg Bergen wishes"), + new BookPageInfo( "to subdue him", "quickly, but there is", "something in", @@ -915,10 +777,8 @@ namespace Server.Items "I remember the power", "of his spells, even as", "he swings the jagged", - "dagger back and forth" - ), - new BookPageInfo - ( + "dagger back and forth"), + new BookPageInfo( "in a wide swath", "before him.", "Something about the", @@ -926,19 +786,15 @@ namespace Server.Items "stomach churn.", "Something has", "happened, something", - "that changes" - ), - new BookPageInfo - ( + "that changes"), + new BookPageInfo( "everything. Lysander", "has lost his sanity to", "this tomb... or to", "something within it.", "Do we dare approach?", "We must make a", - "decision soon." - ) - ); + "decision soon.")); [Constructible] public TavarasJournal14() : base(Utility.Random(0xFF1, 2), false) @@ -968,11 +824,9 @@ namespace Server.Items public class TavarasJournal16 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Sixteen:", "", "Why do I write? I", @@ -980,10 +834,8 @@ namespace Server.Items "because there must be", "some record of", "this... what's", - "happened here... as" - ), - new BookPageInfo - ( + "happened here... as"), + new BookPageInfo( "for my own sanity.", "The act of putting pen", "to paper calms me,", @@ -991,10 +843,8 @@ namespace Server.Items "this madness.", "Lysander is dead. So", "many are dead. And", - "we're trapped here," - ), - new BookPageInfo - ( + "we're trapped here,"), + new BookPageInfo( "trapped forever in", "this nightmare. He", "would not let us pass,", @@ -1002,10 +852,8 @@ namespace Server.Items "furious, spitting,", "covered in blood, he", "swung the ancient", - "dagger at any who" - ), - new BookPageInfo - ( + "dagger at any who"), + new BookPageInfo( "approached. He", "babbled incoherently,", "cursed at us, the most", @@ -1013,10 +861,8 @@ namespace Server.Items "prophecy, doom upon", "us. Bergen would", "have none of it.", - "Finally, he leapt at" - ), - new BookPageInfo - ( + "Finally, he leapt at"), + new BookPageInfo( "Lysander, his", "massive axe at his", "side. But he would not", @@ -1024,10 +870,8 @@ namespace Server.Items "mage... no... they", "were... those hands,", "covered in the dirt of", - "the grave, maggots," - ), - new BookPageInfo - ( + "the grave, maggots,"), + new BookPageInfo( "filth. They rose up", "behind Lysander.", "That look of curiosity", @@ -1035,10 +879,8 @@ namespace Server.Items "Bergen skidded to a", "halt... t'was almost a", "moment of sanity for", - "him, surely, to" - ), - new BookPageInfo - ( + "him, surely, to"), + new BookPageInfo( "attempt to comprehend", "what could have", "stopped the warrior in", @@ -1046,10 +888,8 @@ namespace Server.Items "they were upon him.", "Skeletal hands, arms", "and faces with loose,", - "corrupted flesh" - ), - new BookPageInfo - ( + "corrupted flesh"), + new BookPageInfo( "hanging from yellow", "bone. Inhuman, yet", "once human,", @@ -1057,9 +897,7 @@ namespace Server.Items "as their companions", "tore at Lysander,", "coming towards us in", - "droves." - ) - ); + "droves.")); [Constructible] public TavarasJournal16() : base(Utility.Random(0xFF1, 2), false) @@ -1089,11 +927,9 @@ namespace Server.Items public class TavarasJournal16b : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Sixteen, Later :", "", "We ran. What could", @@ -1101,10 +937,8 @@ namespace Server.Items "towards the entrance,", "cutting at them when", "we could. T'was a", - "nightmare, and yet" - ), - new BookPageInfo - ( + "nightmare, and yet"), + new BookPageInfo( "nothing to prepare us", "for what would come.", "We were almost there,", @@ -1112,10 +946,8 @@ namespace Server.Items "abhorred crypt in", "sight. Then the earth", "shook with such a", - "force that we were" - ), - new BookPageInfo - ( + "force that we were"), + new BookPageInfo( "dropped to our hands", "and knees, stumbling", "in the darkness with", @@ -1123,10 +955,8 @@ namespace Server.Items "surely behind us.", "The noise of falling", "rock and crumbling", - "stone drowned out our" - ), - new BookPageInfo - ( + "stone drowned out our"), + new BookPageInfo( "piteous cries. No sign", "of the entrance", "remained.", @@ -1134,10 +964,8 @@ namespace Server.Items "Bergen, whose wits", "returned quickly.", "That he could make us", - "hurry back into the" - ), - new BookPageInfo - ( + "hurry back into the"), + new BookPageInfo( "main antechamber...", "actually run back", "towards those eldritch", @@ -1145,10 +973,8 @@ namespace Server.Items "But we did, the", "strength of his", "convictions enough for", - "us in the moment." - ), - new BookPageInfo - ( + "us in the moment."), + new BookPageInfo( "And at our campsite", "we erected our last", "defense, a pitiable", @@ -1156,10 +982,8 @@ namespace Server.Items "stone, anything at", "hand that might block", "the tide of those", - "nightmare creatures." - ), - new BookPageInfo - ( + "nightmare creatures."), + new BookPageInfo( "And I sit against it", "even now. I can hear", "their moans, their", @@ -1167,9 +991,7 @@ namespace Server.Items "distance - they'll be", "here soon, even at the", "unhurried pace of the", - "shuffling dead." - ) - ); + "shuffling dead.")); [Constructible] public TavarasJournal16b() : base(Utility.Random(0xFF1, 2), false) @@ -1199,11 +1021,9 @@ namespace Server.Items public class TavarasJournal17 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Seventeen - Day", "Eighteen :", "", @@ -1211,10 +1031,8 @@ namespace Server.Items "longer. I know now", "t'was no work of the", "earth that trapped us", - "here - I can feel His" - ), - new BookPageInfo - ( + "here - I can feel His"), + new BookPageInfo( "force in it. It was His", "will, His power that", "has sealed us here in", @@ -1222,10 +1040,8 @@ namespace Server.Items "barricade will not be", "enough. So many of", "them. They come like", - "unto the ocean's waves" - ), - new BookPageInfo - ( + "unto the ocean's waves"), + new BookPageInfo( "- ceaseless,", "neverending. For", "every five we strike", @@ -1233,14 +1049,10 @@ namespace Server.Items "up against us. And", "like the sands we", "cannot help but be", - "brought down, wasted" - ), - new BookPageInfo - ( + "brought down, wasted"), + new BookPageInfo( "away in this ocean of", - "blood." - ) - ); + "blood.")); [Constructible] public TavarasJournal17() : base(Utility.Random(0xFF1, 2), false) @@ -1270,11 +1082,9 @@ namespace Server.Items public class TavarasJournal19 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal: Discovery of the Tomb", "Tavara Sewel", - new BookPageInfo - ( + new BookPageInfo( "Day Nineteen - Day", "Twenty-One :", "", @@ -1282,10 +1092,8 @@ namespace Server.Items "hold - never, and", "they'll come, they", "come even now. I", - "would tear the last of" - ), - new BookPageInfo - ( + "would tear the last of"), + new BookPageInfo( "it down, let them in to", "devour us all, if only", "to stop the screaming", @@ -1293,14 +1101,10 @@ namespace Server.Items "cries that fill the tomb", "with their presence.", "May my ancestors", - "forgive me, but it" - ), - new BookPageInfo - ( + "forgive me, but it"), + new BookPageInfo( "must be done. I must", - "end this." - ) - ); + "end this.")); [Constructible] public TavarasJournal19() : base(Utility.Random(0xFF1, 2), false) diff --git a/Projects/Scripts/Engines/Khaldun/KhaldunPitTeleporter.cs b/Projects/Scripts/Engines/Khaldun/KhaldunPitTeleporter.cs index 9ec669969..98c1d0f96 100644 --- a/Projects/Scripts/Engines/Khaldun/KhaldunPitTeleporter.cs +++ b/Projects/Scripts/Engines/Khaldun/KhaldunPitTeleporter.cs @@ -25,13 +25,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool Active{ get; set; } + public bool Active { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D PointDest{ get; set; } + public Point3D PointDest { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Map MapDest{ get; set; } + public Map MapDest { get; set; } public override int LabelNumber => 1016511; // the floor of the cavern seems to have collapsed here - a faint light is visible at the bottom of the pit diff --git a/Projects/Scripts/Engines/Khaldun/Mobiles/GrimmochDrummel.cs b/Projects/Scripts/Engines/Khaldun/Mobiles/GrimmochDrummel.cs index 5a5abbbe9..bcfa4fec0 100644 --- a/Projects/Scripts/Engines/Khaldun/Mobiles/GrimmochDrummel.cs +++ b/Projects/Scripts/Engines/Khaldun/Mobiles/GrimmochDrummel.cs @@ -12,7 +12,7 @@ namespace Server.Mobiles Hue = 0x8596; Body = 0x190; - HairItemID = 0x204A; //Krisna + HairItemID = 0x204A; // Krisna Bow bow = new Bow(); bow.Movable = false; @@ -59,10 +59,10 @@ namespace Server.Mobiles PackItem(new Arrow(40)); - if (3 > Utility.Random(100)) + if (Utility.Random(100) < 3) PackItem(new FireHorn()); - if (1 > Utility.Random(3)) + if (Utility.Random(3) < 1) PackItem(Loot.RandomGrimmochJournal()); } diff --git a/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs b/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs index f38943b20..77db83872 100644 --- a/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs +++ b/Projects/Scripts/Engines/Khaldun/PuzzleChest.cs @@ -47,7 +47,7 @@ namespace Server.Items int version = reader.ReadEncodedInt(); int length = reader.ReadEncodedInt(); - for (int i = 0;; i++) + for (int i = 0; ; i++) if (i < length) { PuzzleChestCylinder cylinder = (PuzzleChestCylinder)reader.ReadInt(); @@ -65,7 +65,7 @@ namespace Server.Items } } - public PuzzleChestCylinder[] Cylinders{ get; } = new PuzzleChestCylinder[Length]; + public PuzzleChestCylinder[] Cylinders { get; } = new PuzzleChestCylinder[Length]; public PuzzleChestCylinder First { @@ -162,7 +162,7 @@ namespace Server.Items When = reader.ReadDeltaTime(); } - public DateTime When{ get; } + public DateTime When { get; } public override void Serialize(IGenericWriter writer) { @@ -179,7 +179,7 @@ namespace Server.Items public const int HintsCount = 3; public readonly TimeSpan CleanupTime = TimeSpan.FromHours(1.0); - private Dictionary m_Guesses = + private readonly Dictionary m_Guesses = new Dictionary(); private PuzzleChestSolution m_Solution; @@ -202,7 +202,7 @@ namespace Server.Items } } - public PuzzleChestCylinder[] Hints{ get; private set; } = new PuzzleChestCylinder[HintsCount]; + public PuzzleChestCylinder[] Hints { get; private set; } = new PuzzleChestCylinder[HintsCount]; public PuzzleChestCylinder FirstHint { @@ -295,44 +295,44 @@ namespace Server.Items switch (Utility.Random(4)) { case 0: - { - Effects.SendLocationEffect(to, to.Map, 0x113A, 20, 10); - to.PlaySound(0x231); - to.LocalOverheadMessage(MessageType.Regular, 0x44, 1010523); // A toxic vapor envelops thee. + { + Effects.SendLocationEffect(to, to.Map, 0x113A, 20, 10); + to.PlaySound(0x231); + to.LocalOverheadMessage(MessageType.Regular, 0x44, 1010523); // A toxic vapor envelops thee. - to.ApplyPoison(to, Poison.Regular); + to.ApplyPoison(to, Poison.Regular); - break; - } + break; + } case 1: - { - Effects.SendLocationEffect(to, to.Map, 0x3709, 30); - to.PlaySound(0x54); - to.LocalOverheadMessage(MessageType.Regular, 0xEE, 1010524); // Searing heat scorches thy skin. + { + Effects.SendLocationEffect(to, to.Map, 0x3709, 30); + to.PlaySound(0x54); + to.LocalOverheadMessage(MessageType.Regular, 0xEE, 1010524); // Searing heat scorches thy skin. - AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 0, 100, 0, 0, 0); + AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 0, 100, 0, 0, 0); - break; - } + break; + } case 2: - { - to.PlaySound(0x223); - to.LocalOverheadMessage(MessageType.Regular, 0x62, - 1010525); // Pain lances through thee from a sharp metal blade. + { + to.PlaySound(0x223); + to.LocalOverheadMessage(MessageType.Regular, 0x62, + 1010525); // Pain lances through thee from a sharp metal blade. - AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 100, 0, 0, 0, 0); + AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 100, 0, 0, 0, 0); - break; - } + break; + } default: - { - to.BoltEffect(0); - to.LocalOverheadMessage(MessageType.Regular, 0xDA, 1010526); // Lightning arcs through thy body. + { + to.BoltEffect(0); + to.LocalOverheadMessage(MessageType.Regular, 0xDA, 1010526); // Lightning arcs through thy body. - AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 0, 0, 0, 0, 100); + AOS.Damage(to, to, Utility.RandomMinMax(10, 40), 0, 0, 0, 0, 100); - break; - } + break; + } } } @@ -404,7 +404,7 @@ namespace Server.Items foreach (Item gem in gems) DropItem(gem); - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) DropItem(new BagOfReagents()); for (int i = 0; i < 2; i++) @@ -538,9 +538,9 @@ namespace Server.Items private class PuzzleGump : Gump { - private PuzzleChest m_Chest; - private Mobile m_From; - private PuzzleChestSolution m_Solution; + private readonly PuzzleChest m_Chest; + private readonly Mobile m_From; + private readonly PuzzleChestSolution m_Solution; public PuzzleGump(Mobile from, PuzzleChest chest, PuzzleChestSolution solution, int check) : base(50, 50) { diff --git a/Projects/Scripts/Engines/Khaldun/RaisableItem.cs b/Projects/Scripts/Engines/Khaldun/RaisableItem.cs index 89ee5c76c..8ec46d3bb 100644 --- a/Projects/Scripts/Engines/Khaldun/RaisableItem.cs +++ b/Projects/Scripts/Engines/Khaldun/RaisableItem.cs @@ -50,13 +50,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int MoveSound{ get; set; } + public int MoveSound { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int StopSound{ get; set; } + public int StopSound { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan CloseDelay{ get; set; } + public TimeSpan CloseDelay { get; set; } public bool IsRaisable => m_RaiseTimer == null; @@ -100,8 +100,8 @@ namespace Server.Items private class RaiseTimer : Timer { - private DateTime m_CloseTime; - private RaisableItem m_Item; + private readonly DateTime m_CloseTime; + private readonly RaisableItem m_Item; private int m_Step; private bool m_Up; diff --git a/Projects/Scripts/Engines/Khaldun/RaiseSwitch.cs b/Projects/Scripts/Engines/Khaldun/RaiseSwitch.cs index a4c2b4983..cf80c5346 100644 --- a/Projects/Scripts/Engines/Khaldun/RaiseSwitch.cs +++ b/Projects/Scripts/Engines/Khaldun/RaiseSwitch.cs @@ -16,7 +16,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public RaisableItem RaisableItem{ get; set; } + public RaisableItem RaisableItem { get; set; } public override void OnDoubleClick(Mobile m) { @@ -110,7 +110,7 @@ namespace Server.Items private class ResetTimer : Timer { - private RaiseSwitch m_RaiseSwitch; + private readonly RaiseSwitch m_RaiseSwitch; public ResetTimer(RaiseSwitch raiseSwitch, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs b/Projects/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs index e239cb841..dc3afa566 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/AGhostOfCovetous.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class AGhostOfCovetous : MLQuest { public AGhostOfCovetous() @@ -109,10 +107,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - public class Ben : BaseCreature { [Constructible] @@ -284,6 +278,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Bedlam.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Bedlam.cs index a96a64a16..0964c068e 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Bedlam.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Bedlam.cs @@ -5,8 +5,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class Momento : MLQuest { public Momento() @@ -82,10 +80,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - [QuesterName("Kia (Bedlam)")] public class Kia : BaseCreature { @@ -225,6 +219,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/BlightedGrove.cs b/Projects/Scripts/Engines/MLQuests/Definitions/BlightedGrove.cs index c8e9cb308..1c62f1aa6 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/BlightedGrove.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/BlightedGrove.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class VilePoison : MLQuest { public VilePoison() @@ -184,10 +182,6 @@ namespace Server.Engines.MLQuests.Definitions public override bool IsChainTriggered => true; } - #endregion - - #region Mobiles - [QuesterName("Jamal (near Blighted Grove)")] public class Jamal : BaseCreature { @@ -264,8 +258,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074209, // Hey, could you help me out with something? - 1074215 // Don’t test my patience you sniveling worm! - )); + 1074215)); // Don’t test my patience you sniveling worm! } public override void Serialize(IGenericWriter writer) @@ -282,6 +275,4 @@ namespace Server.Engines.MLQuests.Definitions reader.ReadInt(); } } - - #endregion } \ No newline at end of file diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Britannia.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Britannia.cs index ab2bfd801..8bb57031c 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Britannia.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Britannia.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class Aemaeth1 : MLQuest { public Aemaeth1() @@ -111,10 +109,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - public class Aurelia : BaseCreature { [Constructible] @@ -199,6 +193,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Heartwood.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Heartwood.cs index f68ae536c..2d8d8f2f7 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Heartwood.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Heartwood.cs @@ -5,8 +5,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class TheyreBreedingLikeRabbits : MLQuest { public TheyreBreedingLikeRabbits() @@ -1934,10 +1932,6 @@ namespace Server.Engines.MLQuests.Definitions } */ - #endregion - - #region Mobiles - [QuesterName("Saril (The Heartwood)")] public class Saril : BaseCreature { @@ -1981,8 +1975,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074186, // Come here, I have a task. - 1074183 // You there! I have a job for you. - )); + 1074183)); // You there! I have a job for you. } public override void Serialize(IGenericWriter writer) @@ -2044,8 +2037,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074187, // Want a job? - 1074210 // Hi.� Looking for something to do? - )); + 1074210)); // Hi.� Looking for something to do? } public override void Serialize(IGenericWriter writer) @@ -2105,8 +2097,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074213, // Hey buddy.� Looking for work? - 1074187 // Want a job? - )); + 1074187)); // Want a job? } public override void Serialize(IGenericWriter writer) @@ -2167,8 +2158,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074211, // I could use some help. - 1074218 // Hey!� I want to talk to you, now. - )); + 1074218)); // Hey!� I want to talk to you, now. } public override void Serialize(IGenericWriter writer) @@ -2287,8 +2277,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074219, // Hello there, can I have a moment of your time? - 1074223 // Have you done it yet?� Oh, I haven�t told you, have I? - )); + 1074223)); // Have you done it yet?� Oh, I haven�t told you, have I? } public override void Serialize(IGenericWriter writer) @@ -2350,8 +2339,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074206, // Excuse me please traveler, might I have a little of your time? - 1074186 // Come here, I have a task. - )); + 1074186)); // Come here, I have a task. } public override void Serialize(IGenericWriter writer) @@ -2409,8 +2397,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074220, // May I call you friend?� I have a favor to beg of you. - 1074222 // Could I trouble you for some assistance? - )); + 1074222)); // Could I trouble you for some assistance? } public override void Serialize(IGenericWriter writer) @@ -2482,8 +2469,7 @@ namespace Server.Engines.MLQuests.Definitions MLQuestSystem.Tell(this, 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 // You there, in the stupid hat! Come here. - )); + 1074195)); // You there, in the stupid hat! Come here. } public override void Serialize(IGenericWriter writer) @@ -2537,8 +2523,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074212, // *yawn* You busy? - 1074210 // Hi.� Looking for something to do? - )); + 1074210)); // Hi.� Looking for something to do? } public override void Serialize(IGenericWriter writer) @@ -2596,8 +2581,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 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. - )); + 1074201)); // Waste not a minute! There�s work to be done. } public override void Serialize(IGenericWriter writer) @@ -2654,8 +2638,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074211, // I could use some help. - 1074186 // Come here, I have a task. - )); + 1074186)); // Come here, I have a task. } public override void Serialize(IGenericWriter writer) @@ -2725,8 +2708,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074185, // Hey you! Want to help me out? - 1074186 //Come here, I have a task. - )); + 1074186)); // Come here, I have a task. } public override void Serialize(IGenericWriter writer) @@ -2804,8 +2786,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 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? - )); + 1074209)); // Hey, could you help me out with something? } public override void Serialize(IGenericWriter writer) @@ -2867,8 +2848,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074210, // Hi.� Looking for something to do? - 1074220 // May I call you friend?� I have a favor to beg of you. - )); + 1074220)); // May I call you friend?� I have a favor to beg of you. } public override void Serialize(IGenericWriter writer) @@ -2932,8 +2912,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074209, // Hey, could you help me out with something? - 1074184 // Come here, I have work for you. - )); + 1074184)); // Come here, I have work for you. } public override void Serialize(IGenericWriter writer) @@ -2990,8 +2969,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074187, // Want a job? - 1074222 // Could I trouble you for some assistance? - )); + 1074222)); // Could I trouble you for some assistance? } public override void Serialize(IGenericWriter writer) @@ -3055,8 +3033,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074221, // Greetings!� I have a small task for you good traveler. - 1074201 // Waste not a minute! There�s work to be done. - )); + 1074201)); // Waste not a minute! There�s work to be done. } public override void Serialize(IGenericWriter writer) @@ -3114,8 +3091,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 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? - )); + 1074206)); // Excuse me please traveler, might I have a little of your time? } public override void Serialize(IGenericWriter writer) @@ -3172,8 +3148,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074186, // Come here, I have a task. - 1074209 // Hey, could you help me out with something? - )); + 1074209)); // Hey, could you help me out with something? } public override void Serialize(IGenericWriter writer) @@ -3289,8 +3264,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074210, // Hi.� Looking for something to do? - 1074213 // Hey buddy.� Looking for work? - )); + 1074213)); // Hey buddy.� Looking for work? } public override void Serialize(IGenericWriter writer) @@ -3347,8 +3321,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074223, // Have you done it yet?� Oh, I haven�t told you, have I? - 1074213 // Hey buddy.� Looking for work? - )); + 1074213)); // Hey buddy.� Looking for work? } public override void Serialize(IGenericWriter writer) @@ -3412,8 +3385,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074187, // Want a job? - 1074209 // Hey, could you help me out with something? - )); + 1074209)); // Hey, could you help me out with something? } public override void Serialize(IGenericWriter writer) @@ -3472,8 +3444,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074187, // Want a job? - 1074185 // Hey you! Want to help me out? - )); + 1074185)); // Hey you! Want to help me out? } public override void Serialize(IGenericWriter writer) @@ -3531,8 +3502,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074221, // Greetings!� I have a small task for you good traveler. - 1074212 // *yawn* You busy? - )); + 1074212)); // *yawn* You busy? } public override void Serialize(IGenericWriter writer) @@ -3590,8 +3560,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074206, // Excuse me please traveler, might I have a little of your time? - 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. - )); + 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. } public override void Serialize(IGenericWriter writer) @@ -4437,8 +4406,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 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. - )); + 1074200)); // Thank goodness you are here, there�s no time to lose. } public override void Serialize(IGenericWriter writer) @@ -4675,6 +4643,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Heritage.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Heritage.cs index 9ac3039e6..bb353c1da 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Heritage.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Heritage.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Human To Elf Quests - public class Seasons : MLQuest { public Seasons() @@ -257,10 +255,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Human To Elf Mobiles - [QuesterName("Maul")] public class MaulTheBear : GrizzlyBear { @@ -522,10 +516,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Elf To Human Quests - public class Ingenuity : MLQuest { public Ingenuity() @@ -664,10 +654,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Elf To Human Mobiles - [QuesterName("Sledge (Buc's Den)")] public class Sledge : BaseCreature { @@ -700,8 +686,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074188, // Weakling! You are not up to the task I have. - 1074195 // You there, in the stupid hat! Come here. - )); + 1074195)); // You there, in the stupid hat! Come here. } public override void Serialize(IGenericWriter writer) @@ -813,6 +798,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs b/Projects/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs index 164866a3e..95b7572dd 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/HonestBeggar.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class HonestBeggar : MLQuest { public HonestBeggar() @@ -70,10 +68,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - public class Evan : BaseCreature { [Constructible] @@ -159,6 +153,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs index f46ad6a36..5253e5631 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Ilshenar.cs @@ -24,10 +24,10 @@ namespace Server.Engines.MLQuests.Definitions } // OSI sends this instead, but it doesn't make sense for an escortable - //public override void OnComplete( MLQuestInstance instance ) - //{ - // instance.Player.SendLocalizedMessage( 1073775, "", 0x23 ); // Your quest is complete. Return for your reward. - //} + // public override void OnComplete( MLQuestInstance instance ) + // { + // instance.Player.SendLocalizedMessage( 1073775, "", 0x23 ); // Your quest is complete. Return for your reward. + // } public override void Generate() { @@ -151,8 +151,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074204, // Greetings seeker.  I have an urgent matter for you, if you are willing. - 1074222 // Could I trouble you for some assistance? - )); + 1074222)); // Could I trouble you for some assistance? } public override void InitBody() diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/LostItems.cs b/Projects/Scripts/Engines/MLQuests/Definitions/LostItems.cs index 9674e62bd..4014ae12b 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/LostItems.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/LostItems.cs @@ -7,8 +7,6 @@ namespace Server.Engines.MLQuests.Definitions { // TODO: Assassination Contract, Evidence, Lost in Transit, Last Words - #region Quests - public class LostAndFound : MLQuest { public LostAndFound() @@ -30,10 +28,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Items - public class BatteredBucket : TransientQuestGiverItem { [Constructible] @@ -46,7 +40,7 @@ namespace Server.Engines.MLQuests.Definitions { } // Original label, doesn't fit the expiration message well - //public override int LabelNumber => 1073129; // A battered bucket. + // public override int LabelNumber => 1073129; // A battered bucket. public override string DefaultName => "battered bucket"; @@ -64,6 +58,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } \ No newline at end of file diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Malas.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Malas.cs index 7823c93fe..a57d57dfd 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Malas.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Malas.cs @@ -5,8 +5,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class PointyEars : MLQuest { public PointyEars() @@ -32,10 +30,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - [QuesterName("Drithen (Umbra)")] public class Drithen : BaseCreature { @@ -88,6 +82,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } \ No newline at end of file diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs b/Projects/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs index 0b7d7643d..d2b1ea38b 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/MistakenIdentity.cs @@ -7,8 +7,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class MistakenIdentity : MLQuest { public MistakenIdentity() @@ -190,10 +188,6 @@ namespace Server.Engines.MLQuests.Definitions public override bool IsChainTriggered => true; } - #endregion - - #region Mobiles - [QuesterName("Aernya (Umbra)")] public class Aernya : BaseCreature { @@ -274,8 +268,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 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. - )); + 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. } public override void Serialize(IGenericWriter writer) @@ -351,6 +344,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs b/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs index ce28123f4..8886ad529 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenSkillTraining.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class CleansingOldHaven : MLQuest { public CleansingOldHaven() @@ -823,10 +821,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - public class Aelorn : KeeperOfChivalry { [Constructible] @@ -1949,7 +1943,7 @@ namespace Server.Engines.MLQuests.Definitions public class Ryuichi : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Ryuichi() @@ -2172,8 +2166,7 @@ namespace Server.Engines.MLQuests.Definitions MLQuestSystem.Tell(this, pm, 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 // I can lead a horse to water and make it drink. - )); + 1078214)); // I can lead a horse to water and make it drink. } public override void Serialize(IGenericWriter writer) @@ -2193,7 +2186,7 @@ namespace Server.Engines.MLQuests.Definitions public class Hamato : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Hamato() @@ -2525,6 +2518,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } \ No newline at end of file diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs b/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs index 36fe27cfb..f46ecf7a6 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/NewHavenTraining.cs @@ -5,8 +5,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class SplitEnds : MLQuest { public SplitEnds() @@ -345,10 +343,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - public class Andric : BaseCreature { [Constructible] @@ -404,8 +398,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 // Hey buddy.� Looking for work? - )); + 1074213)); // Hey buddy.� Looking for work? } public override void Serialize(IGenericWriter writer) @@ -521,8 +514,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 // Hey buddy.� Looking for work? - )); + 1074213)); // Hey buddy.� Looking for work? } public override void Serialize(IGenericWriter writer) @@ -540,7 +532,7 @@ namespace Server.Engines.MLQuests.Definitions } } - //[QuesterName( "Clarisse" )] // On OSI the gumps refer to her as this, different from actual name + // [QuesterName( "Clarisse" )] // On OSI the gumps refer to her as this, different from actual name public class Clairesse : BaseCreature { [Constructible] @@ -574,8 +566,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 // Hey buddy.� Looking for work? - )); + 1074213)); // Hey buddy.� Looking for work? } public override void Serialize(IGenericWriter writer) @@ -638,8 +629,7 @@ namespace Server.Engines.MLQuests.Definitions MLQuestSystem.Tell(this, 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 // I could use some help. - )); + 1074211)); // I could use some help. } public override void Serialize(IGenericWriter writer) @@ -745,8 +735,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 // Hey buddy.� Looking for work? - )); + 1074213)); // Hey buddy.� Looking for work? } public override void Serialize(IGenericWriter writer) @@ -797,8 +786,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074205, // Oh great adventurer, would you please assist a weak soul in need of aid? - 1074213 // Hey buddy.� Looking for work? - )); + 1074213)); // Hey buddy.� Looking for work? } public override void Serialize(IGenericWriter writer) @@ -896,8 +884,7 @@ namespace Server.Engines.MLQuests.Definitions MLQuestSystem.Tell(this, 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 // I could use some help. - )); + 1074211)); // I could use some help. } public override void Serialize(IGenericWriter writer) @@ -952,8 +939,7 @@ namespace Server.Engines.MLQuests.Definitions MLQuestSystem.Tell(this, 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 // I could use some help. - )); + 1074211)); // I could use some help. } public override void Serialize(IGenericWriter writer) @@ -1013,8 +999,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074213, // Hey buddy.� Looking for work? - 1074211 // I could use some help. - )); + 1074211)); // I could use some help. } public override void Serialize(IGenericWriter writer) @@ -1031,6 +1016,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs index 64cedde24..23ebc49a7 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Sanctuary.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class BrokenShaft : MLQuest { public BrokenShaft() @@ -720,10 +718,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - [QuesterName("Beotham (Sanctuary)")] public class Beotham : BaseCreature { @@ -768,8 +762,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074187, // Want a job? - 1074184 // Come here, I have work for you. - )); + 1074184)); // Come here, I have work for you. } public override void Serialize(IGenericWriter writer) @@ -883,8 +876,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074188, // Weakling! You are not up to the task I have. - 1074211 // I could use some help. - )); + 1074211)); // I could use some help. } public override void Serialize(IGenericWriter writer) @@ -951,8 +943,7 @@ 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. - )); + 1074218)); // Hey!� I want to talk to you, now. } public override void Serialize(IGenericWriter writer) @@ -1072,8 +1063,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 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. - )); + 1074197)); // Pardon me, but if you could spare some time I�d greatly appreciate it. } public override void Serialize(IGenericWriter writer) @@ -1131,8 +1121,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074185, // Hey you! Want to help me out? - 1074195 // You there, in the stupid hat! Come here. - )); + 1074195)); // You there, in the stupid hat! Come here. } public override void Serialize(IGenericWriter writer) @@ -1189,8 +1178,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074193, // You there! Yes you. Stop looking about like a toadie and come here. - 1074186 // Come here, I have a task. - )); + 1074186)); // Come here, I have a task. } public override void Serialize(IGenericWriter writer) @@ -1291,8 +1279,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074217, // I want to make you an offer you�d be a fool to �refuse. - 1074218 // Hey!� I want to talk to you, now. - )); + 1074218)); // Hey!� I want to talk to you, now. } public override void Serialize(IGenericWriter writer) @@ -1309,6 +1296,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs b/Projects/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs index 6b29967d2..b57fb6832 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/Spellweaving.cs @@ -35,8 +35,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #region Patience - public class Patience : MLQuest { public Patience() @@ -178,10 +176,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Discipline - public class Discipline : MLQuest { public Discipline() @@ -305,10 +299,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Friend of the Fey - public class FriendOfTheFey : MLQuest { public FriendOfTheFey() @@ -390,10 +380,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Fiendish Friends - public class FiendishFriends : MLQuest { public FiendishFriends() @@ -477,10 +463,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - [QuesterName("Aeluva (The Heartwood)")] public class Aeluva : BaseCreature { @@ -587,8 +569,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074186, // Come here, I have a task. - 1074218 // Hey! I want to talk to you, now. - )); + 1074218)); // Hey! I want to talk to you, now. } public override void Serialize(IGenericWriter writer) @@ -704,8 +685,7 @@ namespace Server.Engines.MLQuests.Definitions { MLQuestSystem.Tell(this, pm, Utility.RandomList( 1074215, // Don’t test my patience you sniveling worm! - 1074218 // Hey!  I want to talk to you, now. - )); + 1074218)); // Hey!  I want to talk to you, now. } public override void Serialize(IGenericWriter writer) @@ -722,6 +702,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs b/Projects/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs index 07c7c276a..cc453ba57 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/TheAncientWorld.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class TheAncientWorld : MLQuest { public TheAncientWorld() @@ -104,10 +102,6 @@ namespace Server.Engines.MLQuests.Definitions public override bool IsChainTriggered => true; } - #endregion - - #region Mobiles - [QuesterName("Broolol (The Heartwood)")] public class LorekeeperBroolol : BaseCreature { @@ -161,6 +155,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs b/Projects/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs index 134e42f61..c38f60854 100644 --- a/Projects/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs +++ b/Projects/Scripts/Engines/MLQuests/Definitions/UnfadingMemories.cs @@ -6,8 +6,6 @@ using Server.Mobiles; namespace Server.Engines.MLQuests.Definitions { - #region Quests - public class UnfadingMemoriesPartOne : MLQuest { public UnfadingMemoriesPartOne() @@ -97,10 +95,6 @@ namespace Server.Engines.MLQuests.Definitions } } - #endregion - - #region Mobiles - [QuesterName("Emilio (Britain)")] // OSI's description is "Artist", not very helpful public class Emilio : BaseCreature { @@ -191,6 +185,4 @@ namespace Server.Engines.MLQuests.Definitions int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs index 1852dcacf..2fe75f8aa 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/BaseQuestGump.cs @@ -29,11 +29,11 @@ namespace Server.Engines.MLQuests.Gumps { private struct ButtonInfo { - public ButtonPosition Position{ get; } + public ButtonPosition Position { get; } - public ButtonGraphic Graphic{ get; } + public ButtonGraphic Graphic { get; } - public int ButtonID{ get; } + public int ButtonID { get; } public ButtonInfo(ButtonPosition position, ButtonGraphic graphic, int buttonID) { @@ -47,7 +47,7 @@ namespace Server.Engines.MLQuests.Gumps private int m_MaxPages; private int m_Label; private string m_Title; - private List m_Buttons; + private readonly List m_Buttons; // RunUO optimized version public BaseQuestGump(int label) @@ -76,7 +76,7 @@ namespace Server.Engines.MLQuests.Gumps AddImageTiled(51, 479, 392, 17, 0x2775); AddImageTiled(415, 29, 44, 450, 0xA2D); AddImageTiled(415, 29, 30, 450, 0x28DC); - //AddLabel( 100, 50, 0x481, "" ); + // AddLabel( 100, 50, 0x481, "" ); AddImage(370, 50, 0x589); AddImage(379, 60, 0x15A9); AddImage(425, 0, 0x28C9); @@ -123,8 +123,6 @@ namespace Server.Engines.MLQuests.Gumps m_Buttons.Add(new ButtonInfo(position, graphic, buttonID)); } - #region Elaborate Formatting Shortcuts - public void AddDescription(MLQuest quest) { AddHtmlLocalized(98, 140, 312, 16, quest.IsChainTriggered || quest.NextQuest != null ? 1075024 : 1072202, 0x2710); // Description [(quest chain)] @@ -212,8 +210,6 @@ namespace Server.Engines.MLQuests.Gumps TextDefinition.AddHtmlText(this, 98, 140, 312, 180, text, false, true, 0x15F90, 0xBDE784); } - #endregion - /* OSI gump IDs: * 800 - QuestOfferGump * 801 - QuestCancelConfirmGump @@ -233,7 +229,7 @@ namespace Server.Engines.MLQuests.Gumps pm.CloseGump(); pm.CloseGump(); pm.CloseGump(); - //pm.CloseGump( typeof( UnknownGump807 ) ); + // pm.CloseGump( typeof( UnknownGump807 ) ); pm.CloseGump(); } } diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs index 8dbdde61c..382606493 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/QuestCancelConfirmGump.cs @@ -5,8 +5,8 @@ namespace Server.Engines.MLQuests.Gumps { public class QuestCancelConfirmGump : Gump { - private bool m_CloseGumps; - private MLQuestInstance m_Instance; + private readonly bool m_CloseGumps; + private readonly MLQuestInstance m_Instance; public QuestCancelConfirmGump(MLQuestInstance instance, bool closeGumps = true) : base(120, 50) @@ -82,15 +82,15 @@ namespace Server.Engines.MLQuests.Gumps switch (info.ButtonID) { case 7: // Okay - { - if (info.IsSwitched(2)) - m_Instance.Cancel(true); - else if (info.IsSwitched(1)) - m_Instance.Cancel(false); + { + if (info.IsSwitched(2)) + m_Instance.Cancel(true); + else if (info.IsSwitched(1)) + m_Instance.Cancel(false); - sender.Mobile.SendGump(new QuestLogGump(m_Instance.Player, m_CloseGumps)); - break; - } + sender.Mobile.SendGump(new QuestLogGump(m_Instance.Player, m_CloseGumps)); + break; + } } } } diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs index 5a74e17bc..b837e7b80 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogDetailedGump.cs @@ -6,8 +6,8 @@ namespace Server.Engines.MLQuests.Gumps { public class QuestLogDetailedGump : BaseQuestGump { - private bool m_CloseGumps; - private MLQuestInstance m_Instance; + private readonly bool m_CloseGumps; + private readonly MLQuestInstance m_Instance; public QuestLogDetailedGump(MLQuestInstance instance, bool closeGumps = true) : base(1046026) // Quest Log @@ -51,23 +51,23 @@ namespace Server.Engines.MLQuests.Gumps switch (info.ButtonID) { case 1: // Resign - { - // TODO: Custom reward loss protection? OSI doesn't have this - //if ( m_Instance.ClaimReward ) - // pm.SendMessage( "You cannot cancel a quest with rewards pending." ); - //else + { + // TODO: Custom reward loss protection? OSI doesn't have this + // if (m_Instance.ClaimReward) + // pm.SendMessage( "You cannot cancel a quest with rewards pending." ); + // else - sender.Mobile.SendGump(new QuestCancelConfirmGump(m_Instance, m_CloseGumps)); + sender.Mobile.SendGump(new QuestCancelConfirmGump(m_Instance, m_CloseGumps)); - break; - } + break; + } case 2: // Okay - { - sender.Mobile.SendGump(new QuestLogGump(m_Instance.Player, m_CloseGumps)); + { + sender.Mobile.SendGump(new QuestLogGump(m_Instance.Player, m_CloseGumps)); - break; - } + break; + } } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs index 84f13cdcf..3ee72b3c0 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/QuestLogGump.cs @@ -7,8 +7,8 @@ namespace Server.Engines.MLQuests.Gumps { public class QuestLogGump : BaseQuestGump { - private bool m_CloseGumps; - private PlayerMobile m_Owner; + private readonly bool m_CloseGumps; + private readonly PlayerMobile m_Owner; public QuestLogGump(PlayerMobile pm, bool closeGumps = true) : base(1046026) // Quest Log diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs index 565e575dc..92872d979 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/QuestOfferGump.cs @@ -6,8 +6,8 @@ namespace Server.Engines.MLQuests.Gumps { public class QuestOfferGump : BaseQuestGump { - private MLQuest m_Quest; - private IQuestGiver m_Quester; + private readonly MLQuest m_Quest; + private readonly IQuestGiver m_Quester; public QuestOfferGump(MLQuest quest, IQuestGiver quester, PlayerMobile pm) : base(1049010) // Quest Offer @@ -42,15 +42,15 @@ namespace Server.Engines.MLQuests.Gumps switch (info.ButtonID) { case 1: // Accept - { - m_Quest.OnAccept(m_Quester, pm); - break; - } + { + m_Quest.OnAccept(m_Quester, pm); + break; + } case 2: // Refuse - { - m_Quest.OnRefuse(m_Quester, pm); - break; - } + { + m_Quest.OnRefuse(m_Quester, pm); + break; + } } } } diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/QuestReportBackGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/QuestReportBackGump.cs index 26c8f596c..58c4c29eb 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/QuestReportBackGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/QuestReportBackGump.cs @@ -6,7 +6,7 @@ namespace Server.Engines.MLQuests.Gumps { public class QuestReportBackGump : BaseQuestGump { - private MLQuestInstance m_Instance; + private readonly MLQuestInstance m_Instance; public QuestReportBackGump(MLQuestInstance instance) : base(3006156) // Quest Conversation diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/QuestRewardGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/QuestRewardGump.cs index 60bf5a53a..660ed7a40 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/QuestRewardGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/QuestRewardGump.cs @@ -6,7 +6,7 @@ namespace Server.Engines.MLQuests.Gumps { public class QuestRewardGump : BaseQuestGump { - private MLQuestInstance m_Instance; + private readonly MLQuestInstance m_Instance; public QuestRewardGump(MLQuestInstance instance) : base(1072201) // Reward diff --git a/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs b/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs index a160b874c..603095f8c 100644 --- a/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs +++ b/Projects/Scripts/Engines/MLQuests/Gumps/RaceChangeGump.cs @@ -20,10 +20,10 @@ namespace Server.Engines.MLQuests.Gumps public class RaceChangeConfirmGump : Gump { private static Dictionary m_Pending; - private PlayerMobile m_From; + private readonly PlayerMobile m_From; - private IRaceChanger m_Owner; - private Race m_Race; + private readonly IRaceChanger m_Owner; + private readonly Race m_Race; public RaceChangeConfirmGump(IRaceChanger owner, PlayerMobile from, Race targetRace) : base(50, 50) @@ -53,18 +53,18 @@ namespace Server.Engines.MLQuests.Gumps switch (info.ButtonID) { case 0: // Cancel - { - m_Owner?.OnCancel(m_From); + { + m_Owner?.OnCancel(m_From); - break; - } + break; + } case 1: // Okay - { - if (m_Owner?.CheckComplete(m_From) != false) - Offer(m_Owner, m_From, m_Race); + { + if (m_Owner?.CheckComplete(m_From) != false) + Offer(m_Owner, m_From, m_Race); - break; - } + break; + } } } @@ -120,13 +120,13 @@ namespace Server.Engines.MLQuests.Gumps case Layer.Backpack: case Layer.Mount: case Layer.Bank: - { - continue; // ignore - } + { + continue; // ignore + } default: - { - return true; - } + { + return true; + } } return false; @@ -227,9 +227,9 @@ namespace Server.Engines.MLQuests.Gumps { private static readonly TimeSpan m_TimeoutDelay = TimeSpan.FromMinutes(1); - public IRaceChanger m_Owner; - public Race m_TargetRace; - public Timer m_Timeout; + public readonly IRaceChanger m_Owner; + public readonly Race m_TargetRace; + public readonly Timer m_Timeout; public RaceChangeState(IRaceChanger owner, NetState ns, Race targetRace) { @@ -247,9 +247,9 @@ namespace Server.Engines.MLQuests.Gumps { EnsureCapacity(7); - m_Stream.Write((short)0x2A); - m_Stream.Write((byte)(female ? 1 : 0)); - m_Stream.Write((byte)(targetRace.RaceID + 1)); + Stream.Write((short)0x2A); + Stream.Write((byte)(female ? 1 : 0)); + Stream.Write((byte)(targetRace.RaceID + 1)); } } @@ -262,14 +262,12 @@ namespace Server.Engines.MLQuests.Gumps { EnsureCapacity(7); - m_Stream.Write((short)0x2A); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0xFF); + Stream.Write((short)0x2A); + Stream.Write((byte)0); + Stream.Write((byte)0xFF); } } - #region For testing - public class RaceChangeDeed : Item, IRaceChanger { [Constructible] @@ -330,6 +328,4 @@ namespace Server.Engines.MLQuests.Gumps int version = reader.ReadInt(); } } - - #endregion } diff --git a/Projects/Scripts/Engines/MLQuests/IQuestGiver.cs b/Projects/Scripts/Engines/MLQuests/IQuestGiver.cs index 3b26f11e1..59bd6b5a6 100644 --- a/Projects/Scripts/Engines/MLQuests/IQuestGiver.cs +++ b/Projects/Scripts/Engines/MLQuests/IQuestGiver.cs @@ -5,10 +5,10 @@ namespace Server.Engines.MLQuests { public interface IQuestGiver { - List MLQuests{ get; } + List MLQuests { get; } - Serial Serial{ get; } - bool Deleted{ get; } + Serial Serial { get; } + bool Deleted { get; } Type GetType(); } diff --git a/Projects/Scripts/Engines/MLQuests/Items/CraftmansSatchel.cs b/Projects/Scripts/Engines/MLQuests/Items/CraftmansSatchel.cs index b2e9a4bf7..3b6409ffe 100644 --- a/Projects/Scripts/Engines/MLQuests/Items/CraftmansSatchel.cs +++ b/Projects/Scripts/Engines/MLQuests/Items/CraftmansSatchel.cs @@ -128,11 +128,11 @@ namespace Server.Engines.MLQuests.Items case 1: AddRecipe(DefAlchemy.CraftSystem); break; - // TODO - //case 2: AddNonArtifactRecipe( DefTailoring.CraftSystem ); break; - //case 3: AddNonArtifactRecipe( DefBlacksmithy.CraftSystem ); break; - //case 4: AddNonArtifactRecipe( DefCarpentry.CraftSystem ); break; - //case 5: AddNonArtifactRecipe( DefBowFletching.CraftSystem ); break; + // TODO + // case 2: AddNonArtifactRecipe( DefTailoring.CraftSystem ); break; + // case 3: AddNonArtifactRecipe( DefBlacksmithy.CraftSystem ); break; + // case 4: AddNonArtifactRecipe( DefCarpentry.CraftSystem ); break; + // case 5: AddNonArtifactRecipe( DefBowFletching.CraftSystem ); break; } } diff --git a/Projects/Scripts/Engines/MLQuests/Items/Teleporters.cs b/Projects/Scripts/Engines/MLQuests/Items/Teleporters.cs index bc04f3aad..9baa4986f 100644 --- a/Projects/Scripts/Engines/MLQuests/Items/Teleporters.cs +++ b/Projects/Scripts/Engines/MLQuests/Items/Teleporters.cs @@ -40,7 +40,7 @@ namespace Server.Engines.MLQuests.Items } [CommandProperty(AccessLevel.GameMaster)] - public TextDefinition Message{ get; set; } + public TextDefinition Message { get; set; } public override bool CanTeleport(Mobile m) { @@ -135,7 +135,7 @@ namespace Server.Engines.MLQuests.Items } [CommandProperty(AccessLevel.GameMaster)] - public TextDefinition Message{ get; set; } + public TextDefinition Message { get; set; } public override bool CanTeleport(Mobile m) { diff --git a/Projects/Scripts/Engines/MLQuests/MLQuest.cs b/Projects/Scripts/Engines/MLQuests/MLQuest.cs index 78b09e7df..66d437768 100644 --- a/Projects/Scripts/Engines/MLQuests/MLQuest.cs +++ b/Projects/Scripts/Engines/MLQuests/MLQuest.cs @@ -41,25 +41,25 @@ namespace Server.Engines.MLQuests SaveEnabled = true; } - public bool Deserialized{ get; set; } + public bool Deserialized { get; set; } - public bool SaveEnabled{ get; set; } + public bool SaveEnabled { get; set; } // TODO: Flags? (Deserialized, SaveEnabled, Activated) - public bool Activated{ get; set; } + public bool Activated { get; set; } - public List Objectives{ get; set; } + public List Objectives { get; set; } - public ObjectiveType ObjectiveType{ get; set; } + public ObjectiveType ObjectiveType { get; set; } - public List Rewards{ get; set; } + public List Rewards { get; set; } - public List Instances{ get; set; } + public List Instances { get; set; } - public bool OneTimeOnly{ get; set; } + public bool OneTimeOnly { get; set; } - public bool HasRestartDelay{ get; set; } + public bool HasRestartDelay { get; set; } public bool IsEscort => HasObjective(); @@ -72,17 +72,17 @@ namespace Server.Engines.MLQuests public virtual bool IsChainTriggered => false; public virtual Type NextQuest => null; - public TextDefinition Title{ get; set; } + public TextDefinition Title { get; set; } - public TextDefinition Description{ get; set; } + public TextDefinition Description { get; set; } - public TextDefinition RefusalMessage{ get; set; } + public TextDefinition RefusalMessage { get; set; } - public TextDefinition InProgressMessage{ get; set; } + public TextDefinition InProgressMessage { get; set; } - public TextDefinition CompletionMessage{ get; set; } + public TextDefinition CompletionMessage { get; set; } - public TextDefinition CompletionNotice{ get; set; } + public TextDefinition CompletionNotice { get; set; } public virtual int Version => 0; @@ -233,8 +233,6 @@ namespace Server.Engines.MLQuests { } - #region Generation Methods - public void PutSpawner(Spawner s, Point3D loc, Map map) { string name = $"MLQS-{GetType().Name}"; @@ -258,7 +256,5 @@ namespace Server.Engines.MLQuests deco.MoveToWorld(loc, map); } - - #endregion } } diff --git a/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs b/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs index 1f8864d33..e131ec531 100644 --- a/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs +++ b/Projects/Scripts/Engines/MLQuests/MLQuestContext.cs @@ -17,7 +17,7 @@ namespace Server.Engines.MLQuests [PropertyObject] public class MLQuestContext { - private List m_DoneQuests; + private readonly List m_DoneQuests; private MLQuestFlag m_Flags; public MLQuestContext(PlayerMobile owner) @@ -69,11 +69,11 @@ namespace Server.Engines.MLQuests m_Flags = (MLQuestFlag)reader.ReadEncodedInt(); } - public PlayerMobile Owner{ get; } + public PlayerMobile Owner { get; } - public List QuestInstances{ get; } + public List QuestInstances { get; } - public List ChainOffers{ get; } + public List ChainOffers { get; } [CommandProperty(AccessLevel.GameMaster)] public bool IsFull => QuestInstances.Count >= MLQuestSystem.MaxConcurrentQuests; @@ -240,7 +240,7 @@ namespace Server.Engines.MLQuests private class MLDoneQuestInfo { public DateTime m_NextAvailable; - public MLQuest m_Quest; + public readonly MLQuest m_Quest; public MLDoneQuestInfo(MLQuest quest, DateTime nextAvailable) { diff --git a/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs b/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs index 1d582ad1b..37d6f75f0 100644 --- a/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs +++ b/Projects/Scripts/Engines/MLQuests/MLQuestEntry.cs @@ -53,7 +53,7 @@ namespace Server.Engines.MLQuests m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5), Slice); } - public MLQuest Quest{ get; set; } + public MLQuest Quest { get; set; } public IQuestGiver Quester { @@ -65,13 +65,13 @@ namespace Server.Engines.MLQuests } } - public Type QuesterType{ get; private set; } + public Type QuesterType { get; private set; } - public PlayerMobile Player{ get; set; } + public PlayerMobile Player { get; set; } public MLQuestContext PlayerContext => MLQuestSystem.GetOrCreateContext(Player); - public DateTime Accepted{ get; set; } + public DateTime Accepted { get; set; } public bool ClaimReward { @@ -91,7 +91,7 @@ namespace Server.Engines.MLQuests set => SetFlag(MLQuestInstanceFlags.Failed, value); } - public BaseObjectiveInstance[] Objectives{ get; set; } + public BaseObjectiveInstance[] Objectives { get; set; } public bool SkipReportBack => TextDefinition.IsNullOrEmpty(Quest.CompletionMessage); @@ -158,8 +158,7 @@ namespace Server.Engines.MLQuests * For quests that require collections, this is done later when * the player double clicks the quester. */ - if (!Removed && SkipReportBack && !Quest.RequiresCollection - ) // An OnQuestCompleted can potentially have removed this instance already + if (!Removed && SkipReportBack && !Quest.RequiresCollection) // An OnQuestCompleted can potentially have removed this instance already ContinueReportBack(false); } } @@ -198,7 +197,7 @@ namespace Server.Engines.MLQuests } } - if (Quest.ObjectiveType == ObjectiveType.All && hasAnyFails || !hasAnyLeft) + if ((Quest.ObjectiveType == ObjectiveType.All && hasAnyFails) || !hasAnyLeft) Fail(); if (!hasAnyLeft) diff --git a/Projects/Scripts/Engines/MLQuests/MLQuestSystem.cs b/Projects/Scripts/Engines/MLQuests/MLQuestSystem.cs index 9973f4571..e9e2f23a8 100644 --- a/Projects/Scripts/Engines/MLQuests/MLQuestSystem.cs +++ b/Projects/Scripts/Engines/MLQuests/MLQuestSystem.cs @@ -23,7 +23,7 @@ namespace Server.Engines.MLQuests public static readonly List EmptyList = new List(); - private static List m_EligiblePool = new List(); + private static readonly List m_EligiblePool = new List(); static MLQuestSystem() { @@ -96,11 +96,11 @@ namespace Server.Engines.MLQuests public static bool Enabled => Core.ML; - public static Dictionary Quests{ get; } + public static Dictionary Quests { get; } - public static Dictionary> QuestGivers{ get; } + public static Dictionary> QuestGivers { get; } - public static Dictionary Contexts{ get; } + public static Dictionary Contexts { get; } private static void Register(Type type, MLQuest quest) { @@ -266,7 +266,7 @@ namespace Server.Engines.MLQuests MLQuestInstance instance = context.FindInstance(questEntry); if (instance != null && (instance.Quester == quester || - !questEntry.IsEscort && instance.QuesterType == questerType)) + (!questEntry.IsEscort && instance.QuesterType == questerType))) { entry = instance; quest = questEntry; @@ -460,8 +460,8 @@ namespace Server.Engines.MLQuests MLQuestInstance instance = instances[i]; // Do NOT skip quests on ClaimReward, because the quester still needs the quest ref! - //if ( instance.ClaimReward ) - // continue; + // if (instance.ClaimReward) + // continue; foreach (BaseObjectiveInstance objective in instance.Objectives) // Note: On OSI, expired deliveries can still be completed. Bug? diff --git a/Projects/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs b/Projects/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs index 2f92671d6..dce888f06 100644 --- a/Projects/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs +++ b/Projects/Scripts/Engines/MLQuests/Mobiles/BoonCollector.cs @@ -26,10 +26,10 @@ namespace Server.Engines.MLQuests.Mobiles public override bool IsInvulnerable => true; - public abstract TextDefinition[] Offer{ get; } - public abstract TextDefinition[] Incomplete{ get; } - public abstract TextDefinition[] Complete{ get; } - public abstract Type[] Needed{ get; } + public abstract TextDefinition[] Offer { get; } + public abstract TextDefinition[] Incomplete { get; } + public abstract TextDefinition[] Complete { get; } + public abstract Type[] Needed { get; } public bool CheckComplete(PlayerMobile pm) { @@ -171,11 +171,11 @@ namespace Server.Engines.MLQuests.Mobiles private class InternalTimer : Timer { - private IList m_Conversation; + private readonly IList m_Conversation; private int m_Index; - private bool m_IsComplete; - private DoneQuestCollector m_Owner; - private PlayerMobile m_Target; + private readonly bool m_IsComplete; + private readonly DoneQuestCollector m_Owner; + private readonly PlayerMobile m_Target; public InternalTimer(DoneQuestCollector owner, PlayerMobile target, IList conversation, bool isComplete) diff --git a/Projects/Scripts/Engines/MLQuests/Mobiles/SirHelper.cs b/Projects/Scripts/Engines/MLQuests/Mobiles/SirHelper.cs index 30255f3b4..0d26ba21e 100644 --- a/Projects/Scripts/Engines/MLQuests/Mobiles/SirHelper.cs +++ b/Projects/Scripts/Engines/MLQuests/Mobiles/SirHelper.cs @@ -83,7 +83,7 @@ namespace Server.Engines.MLQuests.Mobiles from.SendGump(m_Gump); // Paperdoll doesn't open - //base.OnDoubleClick( from ); + // base.OnDoubleClick( from ); } public override void OnThink() diff --git a/Projects/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs b/Projects/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs index 7d8e5aa16..581afc23b 100644 --- a/Projects/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs +++ b/Projects/Scripts/Engines/MLQuests/Objectives/BaseObjective.cs @@ -34,13 +34,13 @@ namespace Server.Engines.MLQuests.Objectives EndTime = DateTime.UtcNow + obj.Duration; } - public MLQuestInstance Instance{ get; } + public MLQuestInstance Instance { get; } public bool IsTimed => EndTime != DateTime.MinValue; - public DateTime EndTime{ get; set; } + public DateTime EndTime { get; set; } - public bool Expired{ get; set; } + public bool Expired { get; set; } public virtual DataType ExtraDataType => DataType.None; @@ -142,32 +142,32 @@ namespace Server.Engines.MLQuests.Objectives switch (extraDataType) { case DataType.EscortObjective: - { - bool completed = reader.ReadBool(); + { + bool completed = reader.ReadBool(); - if (objInstance is EscortObjectiveInstance instance) - instance.HasCompleted = completed; + if (objInstance is EscortObjectiveInstance instance) + instance.HasCompleted = completed; - break; - } + break; + } case DataType.KillObjective: - { - int slain = reader.ReadInt(); + { + int slain = reader.ReadInt(); - if (objInstance is KillObjectiveInstance instance) - instance.Slain = slain; + if (objInstance is KillObjectiveInstance instance) + instance.Slain = slain; - break; - } + break; + } case DataType.DeliverObjective: - { - bool completed = reader.ReadBool(); + { + bool completed = reader.ReadBool(); - if (objInstance is DeliverObjectiveInstance instance) - instance.HasCompleted = completed; + if (objInstance is DeliverObjectiveInstance instance) + instance.HasCompleted = completed; - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs b/Projects/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs index d113f1832..1224fe093 100644 --- a/Projects/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs +++ b/Projects/Scripts/Engines/MLQuests/Objectives/CollectObjective.cs @@ -23,11 +23,11 @@ namespace Server.Engines.MLQuests.Objectives } } - public int DesiredAmount{ get; set; } + public int DesiredAmount { get; set; } - public Type AcceptedType{ get; set; } + public Type AcceptedType { get; set; } - public TextDefinition Name{ get; set; } + public TextDefinition Name { get; set; } public virtual bool ShowDetailed => true; @@ -75,8 +75,6 @@ namespace Server.Engines.MLQuests.Objectives public override BaseObjectiveInstance CreateInstance(MLQuestInstance instance) => new CollectObjectiveInstance(this, instance); } - #region Timed - public class TimedCollectObjective : CollectObjective { public TimedCollectObjective(TimeSpan duration, int amount, Type type, TextDefinition name) @@ -84,18 +82,16 @@ namespace Server.Engines.MLQuests.Objectives Duration = duration; public override bool IsTimed => true; - public override TimeSpan Duration{ get; } + public override TimeSpan Duration { get; } } - #endregion - public class CollectObjectiveInstance : BaseObjectiveInstance { public CollectObjectiveInstance(CollectObjective objective, MLQuestInstance instance) : base(instance, objective) => Objective = objective; - public CollectObjective Objective{ get; set; } + public CollectObjective Objective { get; set; } private int GetCurrentTotal() { @@ -124,8 +120,7 @@ namespace Server.Engines.MLQuests.Objectives Item[] items = pack.FindItemsByType(checkType, false); foreach (Item item in items) - if (item.QuestItem && !MLQuestSystem.CanMarkQuestItem(pm, item, checkType) - ) // does another quest still need this item? (OSI just unmarks everything) + if (item.QuestItem && !MLQuestSystem.CanMarkQuestItem(pm, item, checkType)) // does another quest still need this item? (OSI just unmarks everything) item.QuestItem = false; } diff --git a/Projects/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs b/Projects/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs index d7800b0d6..2d6b7ec31 100644 --- a/Projects/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs +++ b/Projects/Scripts/Engines/MLQuests/Objectives/DeliverObjective.cs @@ -27,15 +27,15 @@ namespace Server.Engines.MLQuests.Objectives } } - public Type Delivery{ get; set; } + public Type Delivery { get; set; } - public int Amount{ get; set; } + public int Amount { get; set; } - public TextDefinition Name{ get; set; } + public TextDefinition Name { get; set; } - public Type Destination{ get; set; } + public Type Destination { get; set; } - public bool SpawnsDelivery{ get; set; } + public bool SpawnsDelivery { get; set; } public virtual void SpawnDelivery(Container pack) { @@ -90,8 +90,6 @@ namespace Server.Engines.MLQuests.Objectives public override BaseObjectiveInstance CreateInstance(MLQuestInstance instance) => new DeliverObjectiveInstance(this, instance); } - #region Timed - public class TimedDeliverObjective : DeliverObjective { public TimedDeliverObjective(TimeSpan duration, Type delivery, int amount, TextDefinition name, Type destination, @@ -100,20 +98,18 @@ namespace Server.Engines.MLQuests.Objectives Duration = duration; public override bool IsTimed => true; - public override TimeSpan Duration{ get; } + public override TimeSpan Duration { get; } } - #endregion - public class DeliverObjectiveInstance : BaseObjectiveInstance { public DeliverObjectiveInstance(DeliverObjective objective, MLQuestInstance instance) : base(instance, objective) => Objective = objective; - public DeliverObjective Objective{ get; set; } + public DeliverObjective Objective { get; set; } - public bool HasCompleted{ get; set; } + public bool HasCompleted { get; set; } public override DataType ExtraDataType => DataType.DeliverObjective; diff --git a/Projects/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs b/Projects/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs index de055d226..58ff9b3b4 100644 --- a/Projects/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs +++ b/Projects/Scripts/Engines/MLQuests/Objectives/EscortObjective.cs @@ -9,12 +9,12 @@ namespace Server.Engines.MLQuests.Objectives { public EscortObjective(QuestArea destination = null) => Destination = destination; - public QuestArea Destination{ get; set; } + public QuestArea Destination { get; set; } public override bool CanOffer(IQuestGiver quester, PlayerMobile pm, bool message) { - if (quester is BaseCreature creature && creature.Controlled || - quester is BaseEscortable escortable && escortable.IsBeingDeleted) + if ((quester is BaseCreature creature && creature.Controlled) || + (quester is BaseEscortable escortable && escortable.IsBeingDeleted)) return false; MLQuestContext context = MLQuestSystem.GetContext(pm); @@ -73,9 +73,9 @@ namespace Server.Engines.MLQuests.Objectives public class EscortObjectiveInstance : BaseObjectiveInstance { - private BaseCreature m_Escort; + private readonly BaseCreature m_Escort; private DateTime m_LastSeenEscorter; - private EscortObjective m_Objective; + private readonly EscortObjective m_Objective; private Timer m_Timer; public EscortObjectiveInstance(EscortObjective objective, MLQuestInstance instance) @@ -92,7 +92,7 @@ namespace Server.Engines.MLQuests.Objectives instance.Quester.GetType().Name); } - public bool HasCompleted{ get; set; } + public bool HasCompleted { get; set; } public override DataType ExtraDataType => DataType.EscortObjective; @@ -212,7 +212,7 @@ namespace Server.Engines.MLQuests.Objectives } // Note: this sound is sent twice on OSI (once here and once in Cancel()) - //m_Player.SendSound( 0x5B3 ); // private sound + // m_Player.SendSound( 0x5B3 ); // private sound pm.SendLocalizedMessage(1071194); // You have failed your escort quest... if (!instance.Removed) @@ -230,7 +230,7 @@ namespace Server.Engines.MLQuests.Objectives public override void OnPlayerDeath() { // Note: OSI also cancels it when the quest is already complete - if ( /*IsCompleted() ||*/ Instance.Removed) + if (/*IsCompleted() ||*/ Instance.Removed) return; Instance.Cancel(); diff --git a/Projects/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs b/Projects/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs index ff829b636..4ff6a9e6a 100644 --- a/Projects/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs +++ b/Projects/Scripts/Engines/MLQuests/Objectives/GainSkillObjective.cs @@ -29,9 +29,9 @@ namespace Server.Engines.MLQuests.Objectives m_Flags |= GainSkillObjectiveFlags.Accelerate; } - public SkillName Skill{ get; set; } + public SkillName Skill { get; set; } - public int ThresholdFixed{ get; set; } + public int ThresholdFixed { get; set; } public bool UseReal { @@ -91,7 +91,7 @@ namespace Server.Engines.MLQuests.Objectives : base(instance, objective) => Objective = objective; - public GainSkillObjective Objective{ get; set; } + public GainSkillObjective Objective { get; set; } public bool Handles(SkillName skill) => Objective.Skill == skill; diff --git a/Projects/Scripts/Engines/MLQuests/Objectives/KillObjective.cs b/Projects/Scripts/Engines/MLQuests/Objectives/KillObjective.cs index e938ceb40..78cc1e010 100644 --- a/Projects/Scripts/Engines/MLQuests/Objectives/KillObjective.cs +++ b/Projects/Scripts/Engines/MLQuests/Objectives/KillObjective.cs @@ -6,8 +6,7 @@ namespace Server.Engines.MLQuests.Objectives { public class KillObjective : BaseObjective { - - public KillObjective( +public KillObjective( int amount = 0, Type[] types = null, TextDefinition name = null, QuestArea area = null) { DesiredAmount = amount; @@ -16,13 +15,13 @@ namespace Server.Engines.MLQuests.Objectives Area = area; } - public int DesiredAmount{ get; set; } + public int DesiredAmount { get; set; } - public Type[] AcceptedTypes{ get; set; } + public Type[] AcceptedTypes { get; set; } - public TextDefinition Name{ get; set; } + public TextDefinition Name { get; set; } - public QuestArea Area{ get; set; } + public QuestArea Area { get; set; } public override void WriteToGump(Gump g, ref int y) { @@ -38,8 +37,6 @@ namespace Server.Engines.MLQuests.Objectives y += 16; - #region Location - if (Area != null) { g.AddHtmlLocalized(103, y, 312, 20, 1018327, 0x15F90); // Location @@ -51,15 +48,11 @@ namespace Server.Engines.MLQuests.Objectives y += 16; } - - #endregion } public override BaseObjectiveInstance CreateInstance(MLQuestInstance instance) => new KillObjectiveInstance(this, instance); } - #region Timed - public class TimedKillObjective : KillObjective { public TimedKillObjective(TimeSpan duration, int amount, Type[] types, TextDefinition name, QuestArea area = null) @@ -67,11 +60,9 @@ namespace Server.Engines.MLQuests.Objectives Duration = duration; public override bool IsTimed => true; - public override TimeSpan Duration{ get; } + public override TimeSpan Duration { get; } } - #endregion - public class KillObjectiveInstance : BaseObjectiveInstance { public KillObjectiveInstance(KillObjective objective, MLQuestInstance instance) @@ -81,9 +72,9 @@ namespace Server.Engines.MLQuests.Objectives Slain = 0; } - public KillObjective Objective{ get; set; } + public KillObjective Objective { get; set; } - public int Slain{ get; set; } + public int Slain { get; set; } public override DataType ExtraDataType => DataType.KillObjective; diff --git a/Projects/Scripts/Engines/MLQuests/QuestArea.cs b/Projects/Scripts/Engines/MLQuests/QuestArea.cs index 92e2986a4..0066b0998 100644 --- a/Projects/Scripts/Engines/MLQuests/QuestArea.cs +++ b/Projects/Scripts/Engines/MLQuests/QuestArea.cs @@ -4,7 +4,6 @@ namespace Server.Engines.MLQuests { public class QuestArea { - public QuestArea(TextDefinition name, string region, Map forceMap = null) { Name = name; @@ -15,17 +14,17 @@ namespace Server.Engines.MLQuests ValidationQueue.Add(this); } - public TextDefinition Name{ get; set; } + public TextDefinition Name { get; set; } - public string RegionName{ get; set; } + public string RegionName { get; set; } - public Map ForceMap{ get; set; } + public Map ForceMap { get; set; } public bool Contains(Mobile mob) => Contains(mob.Region); public bool Contains(Region reg) { - if (reg == null || ForceMap != null && reg.Map != ForceMap) + if (reg == null || (ForceMap != null && reg.Map != ForceMap)) return false; return reg.IsPartOf(RegionName); diff --git a/Projects/Scripts/Engines/MLQuests/QuesterNameAttribute.cs b/Projects/Scripts/Engines/MLQuests/QuesterNameAttribute.cs index ffe0db292..16758a375 100644 --- a/Projects/Scripts/Engines/MLQuests/QuesterNameAttribute.cs +++ b/Projects/Scripts/Engines/MLQuests/QuesterNameAttribute.cs @@ -11,7 +11,7 @@ namespace Server.Engines.MLQuests public QuesterNameAttribute(string questerName) => QuesterName = questerName; - public string QuesterName{ get; } + public string QuesterName { get; } public static string GetQuesterNameFor(Type t) { diff --git a/Projects/Scripts/Engines/MLQuests/Rewards/BaseReward.cs b/Projects/Scripts/Engines/MLQuests/Rewards/BaseReward.cs index 7054471df..0cee80628 100644 --- a/Projects/Scripts/Engines/MLQuests/Rewards/BaseReward.cs +++ b/Projects/Scripts/Engines/MLQuests/Rewards/BaseReward.cs @@ -8,7 +8,7 @@ namespace Server.Engines.MLQuests.Rewards { public BaseReward(TextDefinition name) => Name = name; - public TextDefinition Name{ get; set; } + public TextDefinition Name { get; set; } protected virtual int LabelHeight => 16; diff --git a/Projects/Scripts/Engines/MLQuests/Rewards/ItemReward.cs b/Projects/Scripts/Engines/MLQuests/Rewards/ItemReward.cs index 7593bdac5..0886b1f51 100644 --- a/Projects/Scripts/Engines/MLQuests/Rewards/ItemReward.cs +++ b/Projects/Scripts/Engines/MLQuests/Rewards/ItemReward.cs @@ -37,9 +37,9 @@ namespace Server.Engines.MLQuests.Rewards public static readonly ItemReward TinkerSatchel = new ItemReward(1074282, typeof(TinkerSatchel)); // Craftsman's Satchel - private int m_Amount; + private readonly int m_Amount; - private Type m_Type; + private readonly Type m_Type; public ItemReward(TextDefinition name = null, Type type = null, int amount = 1) : base(name) diff --git a/Projects/Scripts/Engines/Party/DeclineTimer.cs b/Projects/Scripts/Engines/Party/DeclineTimer.cs index 4d714b5c7..d3c18db49 100644 --- a/Projects/Scripts/Engines/Party/DeclineTimer.cs +++ b/Projects/Scripts/Engines/Party/DeclineTimer.cs @@ -5,8 +5,9 @@ namespace Server.Engines.PartySystem { public class DeclineTimer : Timer { - private static Dictionary m_Table = new Dictionary(); - private Mobile m_Mobile, m_Leader; + private static readonly Dictionary m_Table = new Dictionary(); + private readonly Mobile m_Mobile; + private readonly Mobile m_Leader; private DeclineTimer(Mobile m, Mobile leader) : base(TimeSpan.FromSeconds(30.0)) { diff --git a/Projects/Scripts/Engines/Party/Packets.cs b/Projects/Scripts/Engines/Party/Packets.cs index e417d0b3c..47b7ce3e1 100644 --- a/Projects/Scripts/Engines/Party/Packets.cs +++ b/Projects/Scripts/Engines/Party/Packets.cs @@ -8,10 +8,10 @@ namespace Server.Engines.PartySystem { EnsureCapacity(7); - m_Stream.Write((short)0x0006); - m_Stream.Write((byte)0x02); - m_Stream.Write((byte)0); - m_Stream.Write(m.Serial); + Stream.Write((short)0x0006); + Stream.Write((byte)0x02); + Stream.Write((byte)0); + Stream.Write(m.Serial); } } @@ -21,12 +21,12 @@ namespace Server.Engines.PartySystem { EnsureCapacity(7 + p.Count * 4); - m_Stream.Write((short)0x0006); - m_Stream.Write((byte)0x01); - m_Stream.Write((byte)p.Count); + Stream.Write((short)0x0006); + Stream.Write((byte)0x01); + Stream.Write((byte)p.Count); for (int i = 0; i < p.Count; ++i) - m_Stream.Write(p[i].Mobile.Serial); + Stream.Write(p[i].Mobile.Serial); } } @@ -36,14 +36,14 @@ namespace Server.Engines.PartySystem { EnsureCapacity(11 + p.Count * 4); - m_Stream.Write((short)0x0006); - m_Stream.Write((byte)0x02); - m_Stream.Write((byte)p.Count); + Stream.Write((short)0x0006); + Stream.Write((byte)0x02); + Stream.Write((byte)p.Count); - m_Stream.Write(removed.Serial); + Stream.Write(removed.Serial); for (int i = 0; i < p.Count; ++i) - m_Stream.Write(p[i].Mobile.Serial); + Stream.Write(p[i].Mobile.Serial); } } @@ -56,10 +56,10 @@ namespace Server.Engines.PartySystem EnsureCapacity(12 + text.Length * 2); - m_Stream.Write((short)0x0006); - m_Stream.Write((byte)(toAll ? 0x04 : 0x03)); - m_Stream.Write(from.Serial); - m_Stream.WriteBigUniNull(text); + Stream.Write((short)0x0006); + Stream.Write((byte)(toAll ? 0x04 : 0x03)); + Stream.Write(from.Serial); + Stream.WriteBigUniNull(text); } } @@ -69,9 +69,9 @@ namespace Server.Engines.PartySystem { EnsureCapacity(10); - m_Stream.Write((short)0x0006); - m_Stream.Write((byte)0x07); - m_Stream.Write(leader.Serial); + Stream.Write((short)0x0006); + Stream.Write((byte)0x07); + Stream.Write(leader.Serial); } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Party/Party.cs b/Projects/Scripts/Engines/Party/Party.cs index 682559df0..6d2c7bfb8 100644 --- a/Projects/Scripts/Engines/Party/Party.cs +++ b/Projects/Scripts/Engines/Party/Party.cs @@ -9,7 +9,7 @@ namespace Server.Engines.PartySystem public class Party : IParty { public const int Capacity = 10; - private List m_Listeners; // staff listening + private readonly List m_Listeners; // staff listening public Party(Mobile leader) { @@ -24,11 +24,11 @@ namespace Server.Engines.PartySystem public int Count => Members.Count; public bool Active => Members.Count > 1; - public Mobile Leader{ get; } + public Mobile Leader { get; } - public List Members{ get; } + public List Members { get; } - public List Candidates{ get; } + public List Candidates { get; } public PartyMemberInfo this[int index] => Members[index]; @@ -217,7 +217,7 @@ namespace Server.Engines.PartySystem if (!force && ourFaction != null && theirFaction != null && ourFaction != theirFaction) return; - // : joined the party. + // : joined the party. SendToAll(new MessageLocalizedAffix(Serial.MinusOne, -1, MessageType.Label, 0x3B2, 3, 1008094, "", AffixType.Prepend | AffixType.System, from.Name, "")); @@ -229,7 +229,7 @@ namespace Server.Engines.PartySystem public void OnDecline(Mobile from, Mobile leader) { - // : Does not wish to join the party. + // : Does not wish to join the party. leader.SendLocalizedMessage(1008091, false, from.Name); from.SendLocalizedMessage(1008092); // You notify them that you do not wish to join the party. @@ -316,7 +316,7 @@ namespace Server.Engines.PartySystem if (!p.Candidates.Contains(target)) p.Candidates.Add(target); - // : You are invited to join the party. Type /accept to join or /decline to decline the offer. + // : You are invited to join the party. Type /accept to join or /decline to decline the offer. target.Send(new MessageLocalizedAffix(Serial.MinusOne, -1, MessageType.Label, 0x3B2, 3, 1008089, "", AffixType.Prepend | AffixType.System, from.Name, "")); @@ -421,7 +421,7 @@ namespace Server.Engines.PartySystem private class RejoinTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public RejoinTimer(Mobile m) : base(TimeSpan.FromSeconds(1.0)) => m_Mobile = m; diff --git a/Projects/Scripts/Engines/Party/PartyMemberInfo.cs b/Projects/Scripts/Engines/Party/PartyMemberInfo.cs index 59f56060f..8992cbf20 100644 --- a/Projects/Scripts/Engines/Party/PartyMemberInfo.cs +++ b/Projects/Scripts/Engines/Party/PartyMemberInfo.cs @@ -8,8 +8,8 @@ namespace Server.Engines.PartySystem CanLoot = !Core.ML; } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public bool CanLoot{ get; set; } + public bool CanLoot { get; set; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Party/RemoveFromParty.cs b/Projects/Scripts/Engines/Party/RemoveFromParty.cs index 9e6413dd9..105ec3d93 100644 --- a/Projects/Scripts/Engines/Party/RemoveFromParty.cs +++ b/Projects/Scripts/Engines/Party/RemoveFromParty.cs @@ -4,8 +4,8 @@ namespace Server.ContextMenus { public class RemoveFromPartyEntry : ContextMenuEntry { - private Mobile m_From; - private Mobile m_Target; + private readonly Mobile m_From; + private readonly Mobile m_Target; public RemoveFromPartyEntry(Mobile from, Mobile target) : base(0198, 12) { diff --git a/Projects/Scripts/Engines/Pathing/FastAStarAlgorithm.cs b/Projects/Scripts/Engines/Pathing/FastAStarAlgorithm.cs index 312e995c0..36573e5b1 100644 --- a/Projects/Scripts/Engines/Pathing/FastAStarAlgorithm.cs +++ b/Projects/Scripts/Engines/Pathing/FastAStarAlgorithm.cs @@ -24,11 +24,11 @@ namespace Server.PathAlgorithms.FastAStar private const int PlaneHeight = 20; public static PathAlgorithm Instance = new FastAStarAlgorithm(); - private static Direction[] m_Path = new Direction[AreaSize * AreaSize]; - private static PathNode[] m_Nodes = new PathNode[NodeCount]; - private static BitArray m_Touched = new BitArray(NodeCount); - private static BitArray m_OnOpen = new BitArray(NodeCount); - private static int[] m_Successors = new int[8]; + private static readonly Direction[] m_Path = new Direction[AreaSize * AreaSize]; + private static readonly PathNode[] m_Nodes = new PathNode[NodeCount]; + private static readonly BitArray m_Touched = new BitArray(NodeCount); + private static readonly BitArray m_OnOpen = new BitArray(NodeCount); + private static readonly int[] m_Successors = new int[8]; private static int m_xOffset, m_yOffset; private static int m_OpenList; @@ -158,26 +158,26 @@ namespace Server.PathAlgorithms.FastAStar if (wasTouched) continue; - + int newCost = m_Nodes[bestNode].cost + 1; int newTotal = newCost + Heuristic(newNode % AreaSize, newNode / AreaSize % AreaSize, - m_Nodes[newNode].z); + m_Nodes[newNode].z); if (m_Nodes[newNode].total <= newTotal) continue; - + m_Nodes[newNode].parent = bestNode; m_Nodes[newNode].cost = newCost; m_Nodes[newNode].total = newTotal; if (m_OnOpen[newNode]) continue; - + AddToChain(newNode); if (newNode != destNode) continue; - + int pathCount = 0; int parent = m_Nodes[newNode].parent; @@ -311,4 +311,4 @@ namespace Server.PathAlgorithms.FastAStar return count; } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Pathing/FastMovement.cs b/Projects/Scripts/Engines/Pathing/FastMovement.cs index d71530a80..74cffe328 100644 --- a/Projects/Scripts/Engines/Pathing/FastMovement.cs +++ b/Projects/Scripts/Engines/Pathing/FastMovement.cs @@ -1,13 +1,9 @@ -#region References - using System; using System.Collections.Generic; using System.Linq; using Server.Items; using Server.Mobiles; -#endregion - namespace Server.Movement { public class FastMovementImpl : IMovementImpl @@ -156,7 +152,7 @@ namespace Server.Movement if ((itemData.Flags & ImpassableSurface) == 0) return true; if (((itemData.Flags & TileFlag.Door) != 0 || itemID == 0x692 || itemID == 0x846 || itemID == 0x873 || - itemID >= 0x6F5 && itemID <= 0x6F6) && ignoreDoors) + (itemID >= 0x6F5 && itemID <= 0x6F6)) && ignoreDoors) return true; if ((itemID == 0x82 || itemID == 0x3946 || itemID == 0x3956) && ignoreSpellFields) return true; @@ -217,14 +213,10 @@ namespace Server.Movement ItemData itemData; TileFlag flags; - #region Tiles - foreach (StaticTile tile in tiles) { itemData = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; - #region SA - if (m.Flying && Insensitive.Equals(itemData.Name, "hover over")) { newZ = tile.Z; @@ -242,7 +234,7 @@ namespace Server.Movement } else if (x >= 42 && x <= 89) { - if (y >= 333 && y <= 399 || y >= 531 && y <= 597 || y >= 739 && y <= 805) + if ((y >= 333 && y <= 399) || (y >= 531 && y <= 597) || (y >= 739 && y <= 805)) { if (tile.Z > newZ) newZ = tile.Z; @@ -251,8 +243,6 @@ namespace Server.Movement } } - #endregion - flags = itemData.Flags; if ((flags & ImpassableSurface) != TileFlag.Surface && (!canSwim || (flags & TileFlag.Wet) == 0)) continue; @@ -269,7 +259,7 @@ namespace Server.Movement { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) continue; + if (cmp > 0 || (cmp == 0 && ourZ > newZ)) continue; } if (ourTop > testTop) testTop = ourTop; @@ -293,25 +283,17 @@ namespace Server.Movement moveIsOk = true; } - #endregion - - #region Items - foreach (Item item in items) { itemData = item.ItemData; flags = itemData.Flags; - #region SA - if (m.Flying && Insensitive.Equals(itemData.Name, "hover over")) { newZ = item.Z; return true; } - #endregion - if (item.Movable) continue; if ((flags & ImpassableSurface) != TileFlag.Surface && (!m.CanSwim || (flags & TileFlag.Wet) == 0)) continue; @@ -328,7 +310,7 @@ namespace Server.Movement { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) continue; + if (cmp > 0 || (cmp == 0 && ourZ > newZ)) continue; } if (ourTop > testTop) testTop = ourTop; @@ -352,8 +334,6 @@ namespace Server.Movement moveIsOk = true; } - #endregion - if (!considerLand || landBlocks || stepTop < landZ) return moveIsOk; ourZ = landCenter; @@ -368,7 +348,7 @@ namespace Server.Movement { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) shouldCheck = false; + if (cmp > 0 || (cmp == 0 && ourZ > newZ)) shouldCheck = false; } if (!shouldCheck || !IsOk(ignoreDoors, ignoreSpellFields, ourZ, testTop, tiles, items)) return moveIsOk; diff --git a/Projects/Scripts/Engines/Pathing/Movement.cs b/Projects/Scripts/Engines/Pathing/Movement.cs index e04e7b1a8..917457aa0 100644 --- a/Projects/Scripts/Engines/Pathing/Movement.cs +++ b/Projects/Scripts/Engines/Pathing/Movement.cs @@ -12,29 +12,29 @@ namespace Server.Movement private const TileFlag ImpassableSurface = TileFlag.Impassable | TileFlag.Surface; - private List[] m_MobPools = { + private readonly List[] m_MobPools = { new List(), new List(), new List() }; - private List[] m_Pools = { + private readonly List[] m_Pools = { new List(), new List(), new List(), new List() }; - private List m_Sectors = new List(); + private readonly List m_Sectors = new List(); private MovementImpl() { } - public static bool AlwaysIgnoreDoors{ get; set; } + public static bool AlwaysIgnoreDoors { get; set; } - public static bool IgnoreMovableImpassables{ get; set; } + public static bool IgnoreMovableImpassables { get; set; } - public static bool IgnoreSpellFields{ get; set; } + public static bool IgnoreSpellFields { get; set; } - public static Point3D Goal{ get; set; } + public static Point3D Goal { get; set; } public bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ) { @@ -299,7 +299,7 @@ namespace Server.Movement if ((flags & ImpassableSurface) != 0) // Impassable || Surface { if (ignoreDoors && ((flags & TileFlag.Door) != 0 || itemID == 0x692 || itemID == 0x846 || - itemID == 0x873 || itemID >= 0x6F5 && itemID <= 0x6F6)) + itemID == 0x873 || (itemID >= 0x6F5 && itemID <= 0x6F6))) continue; if (ignoreSpellFields && (itemID == 0x82 || itemID == 0x3946 || itemID == 0x3956)) @@ -327,11 +327,9 @@ namespace Server.Movement bool landBlocks = (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0; bool considerLand = !landTile.Ignored; - if (landBlocks && canSwim && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0 - ) //Impassable, Can Swim, and Is water. Don't block it. + if (landBlocks && canSwim && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) != 0) // Impassable, Can Swim, and Is water. Don't block it. landBlocks = false; - else if (cantWalk && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) == 0 - ) //Can't walk and it's not water + else if (cantWalk && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Wet) == 0) // Can't walk and it's not water landBlocks = true; int landZ = 0, landCenter = 0, landTop = 0; @@ -346,7 +344,6 @@ namespace Server.Movement bool ignoreDoors = AlwaysIgnoreDoors || !m.Alive || m.Body.BodyID == 0x3DB || m.IsDeadBondedPet; bool ignoreSpellFields = m is PlayerMobile && map != Map.Felucca; - #region Tiles for (int i = 0; i < tiles.Length; ++i) { StaticTile tile = tiles[i]; @@ -369,7 +366,7 @@ namespace Server.Movement { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) + if (cmp > 0 || (cmp == 0 && ourZ > newZ)) continue; } @@ -399,10 +396,6 @@ namespace Server.Movement } } - #endregion - - #region Items - for (int i = 0; i < items.Count; ++i) { Item item = items[i]; @@ -410,7 +403,7 @@ namespace Server.Movement TileFlag flags = itemData.Flags; if (!item.Movable && ((flags & ImpassableSurface) == TileFlag.Surface || - m.CanSwim && (flags & TileFlag.Wet) != 0)) // Surface && !Impassable && !Movable + (m.CanSwim && (flags & TileFlag.Wet) != 0))) // Surface && !Impassable && !Movable { if (cantWalk && (flags & TileFlag.Wet) == 0) continue; @@ -424,7 +417,7 @@ namespace Server.Movement { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) + if (cmp > 0 || (cmp == 0 && ourZ > newZ)) continue; } @@ -455,8 +448,6 @@ namespace Server.Movement } } - #endregion - if (considerLand && !landBlocks && stepTop >= landZ) { int ourZ = landCenter; @@ -471,7 +462,7 @@ namespace Server.Movement { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); - if (cmp > 0 || cmp == 0 && ourZ > newZ) + if (cmp > 0 || (cmp == 0 && ourZ > newZ)) shouldCheck = false; } @@ -482,8 +473,6 @@ namespace Server.Movement } } - #region Mobiles - for (int i = 0; moveIsOk && i < mobiles.Count; ++i) { Mobile mob = mobiles[i]; @@ -491,14 +480,13 @@ namespace Server.Movement if (mob != m && mob.Z + 15 > newZ && newZ + 15 > mob.Z && !CanMoveOver(m, mob)) moveIsOk = false; } - #endregion return moveIsOk; } private bool CanMoveOver(Mobile m, Mobile t) => !t.Alive || !m.Alive || t.IsDeadBondedPet || m.IsDeadBondedPet || - t.Hidden && t.AccessLevel > AccessLevel.Player; + (t.Hidden && t.AccessLevel > AccessLevel.Player); private void GetStartZ(Mobile m, Map map, Point3D loc, List itemList, out int zLow, out int zTop) { @@ -542,7 +530,7 @@ namespace Server.Movement int calcTop = tile.Z + id.CalcHeight; if ((!isSet || calcTop >= zCenter) && - ((id.Flags & TileFlag.Surface) != 0 || m.CanSwim && (id.Flags & TileFlag.Wet) != 0) && loc.Z >= calcTop) + ((id.Flags & TileFlag.Surface) != 0 || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)) && loc.Z >= calcTop) { if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) continue; @@ -564,7 +552,7 @@ namespace Server.Movement int calcTop = item.Z + id.CalcHeight; if ((!isSet || calcTop >= zCenter) && - ((id.Flags & TileFlag.Surface) != 0 || m.CanSwim && (id.Flags & TileFlag.Wet) != 0) && loc.Z >= calcTop) + ((id.Flags & TileFlag.Surface) != 0 || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)) && loc.Z >= calcTop) { if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) continue; diff --git a/Projects/Scripts/Engines/Pathing/MovementPath.cs b/Projects/Scripts/Engines/Pathing/MovementPath.cs index 17a7f7409..ff54bbbd3 100644 --- a/Projects/Scripts/Engines/Pathing/MovementPath.cs +++ b/Projects/Scripts/Engines/Pathing/MovementPath.cs @@ -38,17 +38,17 @@ namespace Server } } - public Map Map{ get; } + public Map Map { get; } - public Point3D Start{ get; } + public Point3D Start { get; } - public Point3D Goal{ get; } + public Point3D Goal { get; } - public Direction[] Directions{ get; } + public Direction[] Directions { get; } public bool Success => Directions?.Length > 0; - public static PathAlgorithm OverrideAlgorithm{ get; set; } + public static PathAlgorithm OverrideAlgorithm { get; set; } public static void Initialize() { diff --git a/Projects/Scripts/Engines/Pathing/PathAlgorithm.cs b/Projects/Scripts/Engines/Pathing/PathAlgorithm.cs index 07500b988..a2fdb8455 100644 --- a/Projects/Scripts/Engines/Pathing/PathAlgorithm.cs +++ b/Projects/Scripts/Engines/Pathing/PathAlgorithm.cs @@ -2,7 +2,7 @@ namespace Server.PathAlgorithms { public abstract class PathAlgorithm { - private static Direction[] m_CalcDirections = { + private static readonly Direction[] m_CalcDirections = { Direction.Up, Direction.North, Direction.Right, diff --git a/Projects/Scripts/Engines/Pathing/PathFollower.cs b/Projects/Scripts/Engines/Pathing/PathFollower.cs index 6780ba930..e63993197 100644 --- a/Projects/Scripts/Engines/Pathing/PathFollower.cs +++ b/Projects/Scripts/Engines/Pathing/PathFollower.cs @@ -6,11 +6,11 @@ namespace Server public class PathFollower { // Should we use pathfinding? 'false' for not - private static bool Enabled = true; + private static readonly bool Enabled = true; - private static TimeSpan RepathDelay = TimeSpan.FromSeconds(2.0); + private static readonly TimeSpan RepathDelay = TimeSpan.FromSeconds(2.0); - private Mobile m_From; + private readonly Mobile m_From; private int m_Index; private DateTime m_LastPathTime; private Point3D m_Next, m_LastGoalLoc; @@ -22,9 +22,9 @@ namespace Server Goal = goal; } - public MoveMethod Mover{ get; set; } + public MoveMethod Mover { get; set; } - public IPoint3D Goal{ get; } + public IPoint3D Goal { get; } public MoveResult Move(Direction d) { @@ -72,7 +72,7 @@ namespace Server Point3D goal = GetGoalLocation(); - if (m_Path != null && (m_Path.Success && goal == m_LastGoalLoc || m_LastPathTime + RepathDelay > DateTime.Now) && + if (m_Path != null && ((m_Path.Success && goal == m_LastGoalLoc) || m_LastPathTime + RepathDelay > DateTime.Now) && !(m_Path.Success && Check(m_From.Location, m_LastGoalLoc, 0))) return false; @@ -87,7 +87,6 @@ namespace Server Advance(ref m_Next, m_Index); return true; - } public bool Check(Point3D loc, Point3D goal, int range) => Utility.InRange(loc, goal, range) && (range > 1 || Math.Abs(loc.Z - goal.Z) < 16); diff --git a/Projects/Scripts/Engines/Pathing/SlowAStarAlgorithm.cs b/Projects/Scripts/Engines/Pathing/SlowAStarAlgorithm.cs index 1ca44ef83..45c5a1520 100644 --- a/Projects/Scripts/Engines/Pathing/SlowAStarAlgorithm.cs +++ b/Projects/Scripts/Engines/Pathing/SlowAStarAlgorithm.cs @@ -19,10 +19,10 @@ namespace Server.PathAlgorithms.SlowAStar private const int MaxNodes = MaxDepth * 16; public static PathAlgorithm Instance = new SlowAStarAlgorithm(); - private static PathNode[] m_Closed = new PathNode[MaxNodes]; - private static PathNode[] m_Open = new PathNode[MaxNodes]; - private static PathNode[] m_Successors = new PathNode[8]; - private static Direction[] m_Path = new Direction[MaxNodes]; + private static readonly PathNode[] m_Closed = new PathNode[MaxNodes]; + private static readonly PathNode[] m_Open = new PathNode[MaxNodes]; + private static readonly PathNode[] m_Successors = new PathNode[8]; + private static readonly Direction[] m_Path = new Direction[MaxNodes]; private Point3D m_Goal; diff --git a/Projects/Scripts/Engines/Plants/EmptyTheBowlGump.cs b/Projects/Scripts/Engines/Plants/EmptyTheBowlGump.cs index fdd97d00e..a67237003 100644 --- a/Projects/Scripts/Engines/Plants/EmptyTheBowlGump.cs +++ b/Projects/Scripts/Engines/Plants/EmptyTheBowlGump.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Plants { public class EmptyTheBowlGump : Gump { - private PlantItem m_Plant; + private readonly PlantItem m_Plant; public EmptyTheBowlGump(PlantItem plant) : base(20, 20) { @@ -68,53 +68,53 @@ namespace Server.Engines.Plants switch (info.ButtonID) { case 1: // Cancel - { - from.SendGump(new MainPlantGump(m_Plant)); - - break; - } - case 2: // Help - { - from.Send(new DisplayHelpTopic(71, true)); // EMPTYING THE BOWL - - from.SendGump(new EmptyTheBowlGump(m_Plant)); - - break; - } - case 3: // Ok - { - PlantBowl bowl = new PlantBowl(); - - if (!from.PlaceInBackpack(bowl)) { - bowl.Delete(); - - m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack! from.SendGump(new MainPlantGump(m_Plant)); break; } - - if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant) + case 2: // Help { - Seed seed = new Seed(m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType); + from.Send(new DisplayHelpTopic(71, true)); // EMPTYING THE BOWL - if (!from.PlaceInBackpack(seed)) + from.SendGump(new EmptyTheBowlGump(m_Plant)); + + break; + } + case 3: // Ok + { + PlantBowl bowl = new PlantBowl(); + + if (!from.PlaceInBackpack(bowl)) { bowl.Delete(); - seed.Delete(); m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack! from.SendGump(new MainPlantGump(m_Plant)); break; } + + if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant) + { + Seed seed = new Seed(m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType); + + if (!from.PlaceInBackpack(seed)) + { + bowl.Delete(); + seed.Delete(); + + m_Plant.LabelTo(from, 1053047); // You cannot empty a bowl with a full pack! + from.SendGump(new MainPlantGump(m_Plant)); + + break; + } + } + + m_Plant.Delete(); + + break; } - - m_Plant.Delete(); - - break; - } } } } diff --git a/Projects/Scripts/Engines/Plants/MainPlantGump.cs b/Projects/Scripts/Engines/Plants/MainPlantGump.cs index 835b8ed10..e2dacc43d 100644 --- a/Projects/Scripts/Engines/Plants/MainPlantGump.cs +++ b/Projects/Scripts/Engines/Plants/MainPlantGump.cs @@ -7,7 +7,7 @@ namespace Server.Engines.Plants { public class MainPlantGump : Gump { - private PlantItem m_Plant; + private readonly PlantItem m_Plant; public MainPlantGump(PlantItem plant) : base(20, 20) { @@ -138,41 +138,41 @@ namespace Server.Engines.Plants switch (m_Plant.PlantSystem.Health) { case PlantHealth.Dying: - { - AddItem(92, 167, 0x1B9D); - AddItem(161, 167, 0x1B9D); + { + AddItem(92, 167, 0x1B9D); + AddItem(161, 167, 0x1B9D); - AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00); + AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00); - break; - } + break; + } case PlantHealth.Wilted: - { - AddItem(91, 164, 0x18E6); - AddItem(161, 164, 0x18E6); + { + AddItem(91, 164, 0x18E6); + AddItem(161, 164, 0x18E6); - AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207); + AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207); - break; - } + break; + } case PlantHealth.Healthy: - { - AddItem(96, 168, 0xC61); - AddItem(162, 168, 0xC61); + { + AddItem(96, 168, 0xC61); + AddItem(162, 168, 0xC61); - AddHtmlLocalized(129, 167, 42, 20, message, 0x008200); + AddHtmlLocalized(129, 167, 42, 20, message, 0x008200); - break; - } + break; + } case PlantHealth.Vibrant: - { - AddItem(93, 162, 0x1A99); - AddItem(162, 162, 0x1A99); + { + AddItem(93, 162, 0x1A99); + AddItem(162, 162, 0x1A99); - AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0); + AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0); - break; - } + break; + } } } } @@ -246,7 +246,7 @@ namespace Server.Engines.Plants if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant) return; - if ((info.ButtonID >= 6 && info.ButtonID <= 10 || info.ButtonID == 12) && + if (((info.ButtonID >= 6 && info.ButtonID <= 10) || info.ButtonID == 12) && !from.InRange(m_Plant.GetWorldLocation(), 3)) { from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away. @@ -262,110 +262,110 @@ namespace Server.Engines.Plants switch (info.ButtonID) { case 1: // Reproduction menu - { - if (m_Plant.PlantStatus > PlantStatus.BowlOfDirt) { - from.SendGump(new ReproductionGump(m_Plant)); + if (m_Plant.PlantStatus > PlantStatus.BowlOfDirt) + { + from.SendGump(new ReproductionGump(m_Plant)); + } + else + { + from.SendLocalizedMessage(1061885); // You need to plant a seed in the bowl first. + + from.SendGump(new MainPlantGump(m_Plant)); + } + + break; } - else + case 2: // Infestation { - from.SendLocalizedMessage(1061885); // You need to plant a seed in the bowl first. + from.Send(new DisplayHelpTopic(54, true)); // INFESTATION LEVEL from.SendGump(new MainPlantGump(m_Plant)); + + break; } - - break; - } - case 2: // Infestation - { - from.Send(new DisplayHelpTopic(54, true)); // INFESTATION LEVEL - - from.SendGump(new MainPlantGump(m_Plant)); - - break; - } case 3: // Fungus - { - from.Send(new DisplayHelpTopic(56, true)); // FUNGUS LEVEL + { + from.Send(new DisplayHelpTopic(56, true)); // FUNGUS LEVEL - from.SendGump(new MainPlantGump(m_Plant)); + from.SendGump(new MainPlantGump(m_Plant)); - break; - } + break; + } case 4: // Poison - { - from.Send(new DisplayHelpTopic(58, true)); // POISON LEVEL + { + from.Send(new DisplayHelpTopic(58, true)); // POISON LEVEL - from.SendGump(new MainPlantGump(m_Plant)); + from.SendGump(new MainPlantGump(m_Plant)); - break; - } + break; + } case 5: // Disease - { - from.Send(new DisplayHelpTopic(60, true)); // DISEASE LEVEL + { + from.Send(new DisplayHelpTopic(60, true)); // DISEASE LEVEL - from.SendGump(new MainPlantGump(m_Plant)); + from.SendGump(new MainPlantGump(m_Plant)); - break; - } + break; + } case 6: // Water - { - BaseBeverage bev = from.Backpack.FindItemsByType().Find(beverage => - beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water); - - if (bev == null) { - from.Target = new PlantPourTarget(m_Plant); - from.SendLocalizedMessage(1060808, - $"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~. - } - else - { - m_Plant.Pour(from, bev); - } + BaseBeverage bev = from.Backpack.FindItemsByType().Find(beverage => + beverage.IsEmpty && beverage.Pourable && beverage.Content == BeverageType.Water); - from.SendGump(new MainPlantGump(m_Plant)); + if (bev == null) + { + from.Target = new PlantPourTarget(m_Plant); + from.SendLocalizedMessage(1060808, + $"#{m_Plant.GetLocalizedPlantStatus()}"); // Target the container you wish to use to water the ~1_val~. + } + else + { + m_Plant.Pour(from, bev); + } - break; - } + from.SendGump(new MainPlantGump(m_Plant)); + + break; + } case 7: // Poison potion - { - AddPotion(from, PotionEffect.PoisonGreater, PotionEffect.PoisonDeadly); + { + AddPotion(from, PotionEffect.PoisonGreater, PotionEffect.PoisonDeadly); - break; - } + break; + } case 8: // Cure potion - { - AddPotion(from, PotionEffect.CureGreater); + { + AddPotion(from, PotionEffect.CureGreater); - break; - } + break; + } case 9: // Heal potion - { - AddPotion(from, PotionEffect.HealGreater); + { + AddPotion(from, PotionEffect.HealGreater); - break; - } + break; + } case 10: // Strength potion - { - AddPotion(from, PotionEffect.StrengthGreater); + { + AddPotion(from, PotionEffect.StrengthGreater); - break; - } + break; + } case 11: // Help - { - from.Send(new DisplayHelpTopic(48, true)); // PLANT GROWING + { + from.Send(new DisplayHelpTopic(48, true)); // PLANT GROWING - from.SendGump(new MainPlantGump(m_Plant)); + from.SendGump(new MainPlantGump(m_Plant)); - break; - } + break; + } case 12: // Empty the bowl - { - from.SendGump(new EmptyTheBowlGump(m_Plant)); + { + from.SendGump(new EmptyTheBowlGump(m_Plant)); - break; - } + break; + } } } diff --git a/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs b/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs index 3e592db06..13d77f51e 100644 --- a/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs +++ b/Projects/Scripts/Engines/Plants/MiscItems/GreenThorns.cs @@ -58,7 +58,7 @@ namespace Server.Items private class InternalTarget : Target { - private GreenThorns m_Thorn; + private readonly GreenThorns m_Thorn; public InternalTarget(GreenThorns thorn) : base(3, true, TargetFlags.None) => m_Thorn = thorn; @@ -126,7 +126,7 @@ namespace Server.Items private class EndActionTimer : Timer { - private Mobile m_From; + private readonly Mobile m_From; public EndActionTimer(Mobile from) : base(TimeSpan.FromMinutes(3.0)) { @@ -143,7 +143,7 @@ namespace Server.Items public abstract class GreenThornsEffect : Timer { - private static TilesAndEffect[] m_Table = + private static readonly TilesAndEffect[] m_Table = { new TilesAndEffect(new[] { @@ -258,11 +258,11 @@ namespace Server.Items Priority = TimerPriority.TwoFiftyMS; } - public Point3D Location{ get; } + public Point3D Location { get; } - public Map Map{ get; } + public Map Map { get; } - public Mobile From{ get; } + public Mobile From { get; } public static GreenThornsEffect Create(Mobile from, LandTarget land) { @@ -361,9 +361,9 @@ namespace Server.Items Effect = effect; } - public int[] Tiles{ get; } + public int[] Tiles { get; } - public Type Effect{ get; } + public Type Effect { get; } } } @@ -378,65 +378,65 @@ namespace Server.Items switch (step) { case 0: - { - Effects.PlaySound(Location, Map, 0x106); - Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, - 182, 0xBE3); + { + Effects.PlaySound(Location, Map, 0x106); + Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, + 182, 0xBE3); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 1: - { - Effects.PlaySound(Location, Map, 0x222); + { + Effects.PlaySound(Location, Map, 0x222); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 2: - { - Effects.PlaySound(Location, Map, 0x21F); + { + Effects.PlaySound(Location, Map, 0x21F); - return TimeSpan.FromSeconds(5.0); - } + return TimeSpan.FromSeconds(5.0); + } case 3: - { - EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); - dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, - "* The ground erupts with chaotic growth! *"); + { + EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); + dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, + "* The ground erupts with chaotic growth! *"); - Effects.PlaySound(Location, Map, 0x12D); + Effects.PlaySound(Location, Map, 0x12D); - SpawnReagents(); - SpawnReagents(); + SpawnReagents(); + SpawnReagents(); - return TimeSpan.FromSeconds(2.0); - } + return TimeSpan.FromSeconds(2.0); + } case 4: - { - Effects.PlaySound(Location, Map, 0x12D); + { + Effects.PlaySound(Location, Map, 0x12D); - SpawnReagents(); - SpawnReagents(); + SpawnReagents(); + SpawnReagents(); - return TimeSpan.FromSeconds(2.0); - } + return TimeSpan.FromSeconds(2.0); + } case 5: - { - Effects.PlaySound(Location, Map, 0x12D); + { + Effects.PlaySound(Location, Map, 0x12D); - SpawnReagents(); - SpawnReagents(); + SpawnReagents(); + SpawnReagents(); - return TimeSpan.FromSeconds(3.0); - } + return TimeSpan.FromSeconds(3.0); + } default: - { - Effects.PlaySound(Location, Map, 0x12D); + { + Effects.PlaySound(Location, Map, 0x12D); - SpawnReagents(); - SpawnReagents(); + SpawnReagents(); + SpawnReagents(); - return TimeSpan.Zero; - } + return TimeSpan.Zero; + } } } @@ -474,40 +474,40 @@ namespace Server.Items switch (step) { case 0: - { - Effects.PlaySound(Location, Map, 0x106); - Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, - 182, 0xBE3); + { + Effects.PlaySound(Location, Map, 0x106); + Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, + 182, 0xBE3); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 1: - { - EffectItem hole = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(10.0)); - hole.ItemID = 0x913; + { + EffectItem hole = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(10.0)); + hole.ItemID = 0x913; - Effects.PlaySound(Location, Map, 0x222); + Effects.PlaySound(Location, Map, 0x222); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 2: - { - Effects.PlaySound(Location, Map, 0x21F); + { + Effects.PlaySound(Location, Map, 0x21F); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } default: - { - EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); - dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, - "* A magical bunny leaps out of its hole, disturbed by the thorn's effect! *"); + { + EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); + dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, + "* A magical bunny leaps out of its hole, disturbed by the thorn's effect! *"); - BaseCreature spawn = new VorpalBunny(); - if (!SpawnCreature(spawn)) - spawn.Delete(); + BaseCreature spawn = new VorpalBunny(); + if (!SpawnCreature(spawn)) + spawn.Delete(); - return TimeSpan.Zero; - } + return TimeSpan.Zero; + } } } } @@ -523,38 +523,38 @@ namespace Server.Items switch (step) { case 0: - { - Effects.PlaySound(Location, Map, 0x106); - Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, - 182, 0xBE3); + { + Effects.PlaySound(Location, Map, 0x106); + Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, + 182, 0xBE3); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 1: - { - Effects.PlaySound(Location, Map, 0x222); + { + Effects.PlaySound(Location, Map, 0x222); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 2: - { - Effects.PlaySound(Location, Map, 0x21F); + { + Effects.PlaySound(Location, Map, 0x21F); - return TimeSpan.FromSeconds(1.0); - } + return TimeSpan.FromSeconds(1.0); + } default: - { - EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); - dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, - "* Strange green tendrils rise from the ground, whipping wildly! *"); - Effects.PlaySound(Location, Map, 0x2B0); + { + EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); + dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, + "* Strange green tendrils rise from the ground, whipping wildly! *"); + Effects.PlaySound(Location, Map, 0x2B0); - BaseCreature spawn = new WhippingVine(); - if (!SpawnCreature(spawn)) - spawn.Delete(); + BaseCreature spawn = new WhippingVine(); + if (!SpawnCreature(spawn)) + spawn.Delete(); - return TimeSpan.Zero; - } + return TimeSpan.Zero; + } } } } @@ -570,44 +570,44 @@ namespace Server.Items switch (step) { case 0: - { - Effects.PlaySound(Location, Map, 0x106); - Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, - 182, 0xBE3); - - return TimeSpan.FromSeconds(4.0); - } - case 1: - { - Effects.PlaySound(Location, Map, 0x222); - - return TimeSpan.FromSeconds(4.0); - } - case 2: - { - Effects.PlaySound(Location, Map, 0x21F); - - return TimeSpan.FromSeconds(4.0); - } - default: - { - EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); - dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, - "* Slithering ice serpents rise to the surface to investigate the disturbance! *"); - - BaseCreature spawn = new GiantIceWorm(); - if (!SpawnCreature(spawn)) - spawn.Delete(); - - for (int i = 0; i < 3; i++) { - BaseCreature snake = new IceSnake(); - if (!SpawnCreature(snake)) - snake.Delete(); - } + Effects.PlaySound(Location, Map, 0x106); + Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, + 182, 0xBE3); - return TimeSpan.Zero; - } + return TimeSpan.FromSeconds(4.0); + } + case 1: + { + Effects.PlaySound(Location, Map, 0x222); + + return TimeSpan.FromSeconds(4.0); + } + case 2: + { + Effects.PlaySound(Location, Map, 0x21F); + + return TimeSpan.FromSeconds(4.0); + } + default: + { + EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); + dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, + "* Slithering ice serpents rise to the surface to investigate the disturbance! *"); + + BaseCreature spawn = new GiantIceWorm(); + if (!SpawnCreature(spawn)) + spawn.Delete(); + + for (int i = 0; i < 3; i++) + { + BaseCreature snake = new IceSnake(); + if (!SpawnCreature(snake)) + snake.Delete(); + } + + return TimeSpan.Zero; + } } } } @@ -623,35 +623,35 @@ namespace Server.Items switch (step) { case 0: - { - Effects.PlaySound(Location, Map, 0x106); - Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, - 182, 0xBE3); + { + Effects.PlaySound(Location, Map, 0x106); + Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3735, 1, + 182, 0xBE3); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 1: - { - Effects.PlaySound(Location, Map, 0x222); + { + Effects.PlaySound(Location, Map, 0x222); - return TimeSpan.FromSeconds(4.0); - } + return TimeSpan.FromSeconds(4.0); + } case 2: - { - Effects.PlaySound(Location, Map, 0x21F); + { + Effects.PlaySound(Location, Map, 0x21F); - return TimeSpan.FromSeconds(5.0); - } + return TimeSpan.FromSeconds(5.0); + } default: - { - EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); - dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, - "* The sand collapses, revealing a dark hole. *"); + { + EffectItem dummy = EffectItem.Create(Location, Map, TimeSpan.FromSeconds(20.0)); + dummy.PublicOverheadMessage(MessageType.Regular, 0x3B2, true, + "* The sand collapses, revealing a dark hole. *"); - GreenThornsSHTeleporter.Create(Location, Map); + GreenThornsSHTeleporter.Create(Location, Map); - return TimeSpan.Zero; - } + return TimeSpan.Zero; + } } } } @@ -713,7 +713,7 @@ namespace Server.Items private class InternalTimer : Timer { - private GreenThornsSHTeleporter m_Teleporter; + private readonly GreenThornsSHTeleporter m_Teleporter; public InternalTimer(GreenThornsSHTeleporter teleporter) : base(TimeSpan.FromMinutes(1.0)) { diff --git a/Projects/Scripts/Engines/Plants/MiscItems/OrangePetals.cs b/Projects/Scripts/Engines/Plants/MiscItems/OrangePetals.cs index 8b447adc2..3ae595cf1 100644 --- a/Projects/Scripts/Engines/Plants/MiscItems/OrangePetals.cs +++ b/Projects/Scripts/Engines/Plants/MiscItems/OrangePetals.cs @@ -6,7 +6,7 @@ namespace Server.Items { public class OrangePetals : Item { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public OrangePetals(int amount = 1) : base(0x1021) @@ -103,7 +103,7 @@ namespace Server.Items private class OrangePetalsTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public OrangePetalsTimer(Mobile from) : base(TimeSpan.FromMinutes(5.0)) => m_Mobile = from; @@ -121,7 +121,7 @@ namespace Server.Items { public OrangePetalsContext(Timer timer) => Timer = timer; - public Timer Timer{ get; } + public Timer Timer { get; } } } } diff --git a/Projects/Scripts/Engines/Plants/MiscItems/RedLeaves.cs b/Projects/Scripts/Engines/Plants/MiscItems/RedLeaves.cs index 9438806a5..4acffc221 100644 --- a/Projects/Scripts/Engines/Plants/MiscItems/RedLeaves.cs +++ b/Projects/Scripts/Engines/Plants/MiscItems/RedLeaves.cs @@ -48,7 +48,7 @@ namespace Server.Items private class InternalTarget : Target { - private RedLeaves m_RedLeaves; + private readonly RedLeaves m_RedLeaves; public InternalTarget(RedLeaves redLeaves) : base(3, false, TargetFlags.None) => m_RedLeaves = redLeaves; diff --git a/Projects/Scripts/Engines/Plants/Network/DisplayHelpTopic.cs b/Projects/Scripts/Engines/Plants/Network/DisplayHelpTopic.cs index e026d8a03..9a7f0060a 100644 --- a/Projects/Scripts/Engines/Plants/Network/DisplayHelpTopic.cs +++ b/Projects/Scripts/Engines/Plants/Network/DisplayHelpTopic.cs @@ -6,10 +6,10 @@ namespace Server.Network { EnsureCapacity(11); - m_Stream.Write((short)0x17); - m_Stream.Write((byte)1); - m_Stream.Write(topicID); - m_Stream.Write(display); + Stream.Write((short)0x17); + Stream.Write((byte)1); + Stream.Write(topicID); + Stream.Write(display); } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/Plants/PlantBowl.cs b/Projects/Scripts/Engines/Plants/PlantBowl.cs index df220baf5..c19a52563 100644 --- a/Projects/Scripts/Engines/Plants/PlantBowl.cs +++ b/Projects/Scripts/Engines/Plants/PlantBowl.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Plants { public class PlantBowl : Item { - private static int[] m_DirtPatchTiles = + private static readonly int[] m_DirtPatchTiles = { 0x9, 0x15, 0x71, 0x7C, @@ -105,7 +105,7 @@ namespace Server.Engines.Plants private class InternalTarget : Target { - private PlantBowl m_PlantBowl; + private readonly PlantBowl m_PlantBowl; public InternalTarget(PlantBowl plantBowl) : base(3, true, TargetFlags.None) => m_PlantBowl = plantBowl; diff --git a/Projects/Scripts/Engines/Plants/PlantHue.cs b/Projects/Scripts/Engines/Plants/PlantHue.cs index b19b76e39..384a157b5 100644 --- a/Projects/Scripts/Engines/Plants/PlantHue.cs +++ b/Projects/Scripts/Engines/Plants/PlantHue.cs @@ -39,7 +39,7 @@ namespace Server.Engines.Plants public class PlantHueInfo { - private static Dictionary m_Table; + private static readonly Dictionary m_Table; static PlantHueInfo() => m_Table = new Dictionary @@ -77,13 +77,13 @@ namespace Server.Engines.Plants GumpHue = gumpHue; } - public int Hue{ get; } + public int Hue { get; } - public int Name{ get; } + public int Name { get; } - public PlantHue PlantHue{ get; } + public PlantHue PlantHue { get; } - public int GumpHue{ get; } + public int GumpHue { get; } public static PlantHueInfo GetInfo(PlantHue plantHue) => m_Table.TryGetValue(plantHue, out PlantHueInfo info) ? info : m_Table[PlantHue.Plain]; diff --git a/Projects/Scripts/Engines/Plants/PlantItem.cs b/Projects/Scripts/Engines/Plants/PlantItem.cs index c47312bea..297db5ee4 100644 --- a/Projects/Scripts/Engines/Plants/PlantItem.cs +++ b/Projects/Scripts/Engines/Plants/PlantItem.cs @@ -57,7 +57,7 @@ namespace Server.Engines.Plants { } - public PlantSystem PlantSystem{ get; private set; } + public PlantSystem PlantSystem { get; private set; } public override bool ForceShowProperties => ObjectPropertyList.Enabled; @@ -139,7 +139,6 @@ namespace Server.Engines.Plants if (IsLockedDown && RootParent == null) return true; - if (!(RootParent is Mobile owner)) return false; @@ -156,10 +155,10 @@ namespace Server.Engines.Plants [CommandProperty(AccessLevel.GameMaster)] public bool Reproduces => PlantHueInfo.CanReproduce(PlantHue) && PlantTypeInfo.CanReproduce(PlantType); - public static List Plants{ get; } = new List(); + public static List Plants { get; } = new List(); [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override void OnSingleClick(Mobile from) { @@ -281,8 +280,8 @@ namespace Server.Engines.Plants } public bool IsUsableBy(Mobile from) => - IsChildOf(from.Backpack) || IsChildOf(from.FindBankNoCreate()) || IsLockedDown && IsAccessibleTo(from) || - RootParent is Item root && root.IsSecure && root.IsAccessibleTo(from); + IsChildOf(from.Backpack) || IsChildOf(from.FindBankNoCreate()) || (IsLockedDown && IsAccessibleTo(from)) || + (RootParent is Item root && root.IsSecure && root.IsAccessibleTo(from)); public override void OnDoubleClick(Mobile from) { @@ -515,28 +514,28 @@ namespace Server.Engines.Plants { case 2: case 1: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 0; + } case 0: - { - if (version < 1) - Level = SecureLevel.CoOwners; + { + if (version < 1) + Level = SecureLevel.CoOwners; - m_PlantStatus = (PlantStatus)reader.ReadInt(); - m_PlantType = (PlantType)reader.ReadInt(); - m_PlantHue = (PlantHue)reader.ReadInt(); - m_ShowType = reader.ReadBool(); + m_PlantStatus = (PlantStatus)reader.ReadInt(); + m_PlantType = (PlantType)reader.ReadInt(); + m_PlantHue = (PlantHue)reader.ReadInt(); + m_ShowType = reader.ReadBool(); - if (m_PlantStatus < PlantStatus.DecorativePlant) - PlantSystem = new PlantSystem(this, reader); + if (m_PlantStatus < PlantStatus.DecorativePlant) + PlantSystem = new PlantSystem(this, reader); - if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue)) - m_PlantHue |= PlantHue.Reproduces; + if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue)) + m_PlantHue |= PlantHue.Reproduces; - break; - } + break; + } } Plants.Add(this); diff --git a/Projects/Scripts/Engines/Plants/PlantPourTarget.cs b/Projects/Scripts/Engines/Plants/PlantPourTarget.cs index 83708b8ba..be0507a7a 100644 --- a/Projects/Scripts/Engines/Plants/PlantPourTarget.cs +++ b/Projects/Scripts/Engines/Plants/PlantPourTarget.cs @@ -4,7 +4,7 @@ namespace Server.Engines.Plants { public class PlantPourTarget : Target { - private PlantItem m_Plant; + private readonly PlantItem m_Plant; public PlantPourTarget(PlantItem plant) : base(3, true, TargetFlags.None) => m_Plant = plant; diff --git a/Projects/Scripts/Engines/Plants/PlantResources.cs b/Projects/Scripts/Engines/Plants/PlantResources.cs index 57c59232b..8e9b0e6b3 100644 --- a/Projects/Scripts/Engines/Plants/PlantResources.cs +++ b/Projects/Scripts/Engines/Plants/PlantResources.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Plants { public class PlantResourceInfo { - private static PlantResourceInfo[] m_ResourceList = + private static readonly PlantResourceInfo[] m_ResourceList = { new PlantResourceInfo(PlantType.ElephantEarPlant, PlantHue.BrightRed, typeof(RedLeaves)), new PlantResourceInfo(PlantType.PonytailPalm, PlantHue.BrightRed, typeof(RedLeaves)), @@ -26,11 +26,11 @@ namespace Server.Engines.Plants ResourceType = resourceType; } - public PlantType PlantType{ get; } + public PlantType PlantType { get; } - public PlantHue PlantHue{ get; } + public PlantHue PlantHue { get; } - public Type ResourceType{ get; } + public Type ResourceType { get; } public static PlantResourceInfo GetInfo(PlantType plantType, PlantHue plantHue) { diff --git a/Projects/Scripts/Engines/Plants/PlantSystem.cs b/Projects/Scripts/Engines/Plants/PlantSystem.cs index 95b1fc057..bda31f570 100644 --- a/Projects/Scripts/Engines/Plants/PlantSystem.cs +++ b/Projects/Scripts/Engines/Plants/PlantSystem.cs @@ -98,13 +98,13 @@ namespace Server.Engines.Plants m_SeedHue |= PlantHue.Reproduces; } - public PlantItem Plant{ get; } + public PlantItem Plant { get; } - public bool FertileDirt{ get; set; } + public bool FertileDirt { get; set; } - public DateTime NextGrowth{ get; private set; } + public DateTime NextGrowth { get; private set; } - public PlantGrowthIndicator GrowthIndicator{ get; private set; } + public PlantGrowthIndicator GrowthIndicator { get; private set; } public bool IsFullWater => m_Water >= 4; @@ -288,7 +288,7 @@ namespace Server.Engines.Plants public bool PollenProducing => Plant.IsCrossable && Plant.PlantStatus >= PlantStatus.FullGrownPlant; - public bool Pollinated{ get; set; } + public bool Pollinated { get; set; } public PlantType SeedType { @@ -624,7 +624,6 @@ namespace Server.Engines.Plants if (Utility.RandomDouble() < infestationChance) Infestation++; - double fungusChance = 0.15 - StrengthPotion * 0.075 + (Water - 2) * 0.10; if (Utility.RandomDouble() < fungusChance) diff --git a/Projects/Scripts/Engines/Plants/PlantType.cs b/Projects/Scripts/Engines/Plants/PlantType.cs index aaeb5ea27..089ed4353 100644 --- a/Projects/Scripts/Engines/Plants/PlantType.cs +++ b/Projects/Scripts/Engines/Plants/PlantType.cs @@ -61,7 +61,7 @@ namespace Server.Engines.Plants public class PlantTypeInfo { - private static PlantTypeInfo[] m_Table = + private static readonly PlantTypeInfo[] m_Table = { new PlantTypeInfo(0xC83, 0, 0, PlantType.CampionFlowers, false, true, true, true, PlantCategory.Default), new PlantTypeInfo(0xC86, 0, 0, PlantType.Poppies, false, true, true, true, PlantCategory.Default), @@ -115,14 +115,14 @@ namespace Server.Engines.Plants 1080536, 1080536, 1080534, 1080531, 1080533, 1113716) }; - private int m_PlantLabelDecorative; - private int m_PlantLabelFullGrown; - private int m_PlantLabelPlant; + private readonly int m_PlantLabelDecorative; + private readonly int m_PlantLabelFullGrown; + private readonly int m_PlantLabelPlant; // Cliloc overrides - private int m_PlantLabelSeed; - private int m_SeedLabel; - private int m_SeedLabelPlural; + private readonly int m_PlantLabelSeed; + private readonly int m_SeedLabel; + private readonly int m_SeedLabelPlural; private PlantTypeInfo(int itemID, int offsetX, int offsetY, PlantType plantType, bool containsPlant, bool flowery, bool crossable, bool reproduces, PlantCategory plantCategory, int plantLabelSeed = -1, int plantLabelPlant = -1, @@ -145,25 +145,25 @@ namespace Server.Engines.Plants m_SeedLabelPlural = seedLabelPlural; } - public int ItemID{ get; } + public int ItemID { get; } - public int OffsetX{ get; } + public int OffsetX { get; } - public int OffsetY{ get; } + public int OffsetY { get; } - public PlantType PlantType{ get; } + public PlantType PlantType { get; } - public PlantCategory PlantCategory{ get; } + public PlantCategory PlantCategory { get; } public int Name => ItemID < 0x4000 ? 1020000 + ItemID : 1078872 + ItemID; - public bool ContainsPlant{ get; } + public bool ContainsPlant { get; } - public bool Flowery{ get; } + public bool Flowery { get; } - public bool Crossable{ get; } + public bool Crossable { get; } - public bool Reproduces{ get; } + public bool Reproduces { get; } public static PlantTypeInfo GetInfo(PlantType plantType) { diff --git a/Projects/Scripts/Engines/Plants/PollinateTarget.cs b/Projects/Scripts/Engines/Plants/PollinateTarget.cs index f7d0ded40..43b5ce371 100644 --- a/Projects/Scripts/Engines/Plants/PollinateTarget.cs +++ b/Projects/Scripts/Engines/Plants/PollinateTarget.cs @@ -4,7 +4,7 @@ namespace Server.Engines.Plants { public class PollinateTarget : Target { - private PlantItem m_Plant; + private readonly PlantItem m_Plant; public PollinateTarget(PlantItem plant) : base(3, true, TargetFlags.None) => m_Plant = plant; diff --git a/Projects/Scripts/Engines/Plants/ReproductionGump.cs b/Projects/Scripts/Engines/Plants/ReproductionGump.cs index ead5ca625..717eb07e3 100644 --- a/Projects/Scripts/Engines/Plants/ReproductionGump.cs +++ b/Projects/Scripts/Engines/Plants/ReproductionGump.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Plants { public class ReproductionGump : Gump { - private PlantItem m_Plant; + private readonly PlantItem m_Plant; public ReproductionGump(PlantItem plant) : base(20, 20) { @@ -125,138 +125,138 @@ namespace Server.Engines.Plants switch (info.ButtonID) { case 1: // Main menu - { - from.SendGump(new MainPlantGump(m_Plant)); - - break; - } - case 2: // Set to decorative - { - if (m_Plant.PlantStatus == PlantStatus.Stage9) from.SendGump(new SetToDecorativeGump(m_Plant)); - - break; - } - case 3: // Pollination - { - from.Send(new DisplayHelpTopic(67, true)); // POLLINATION STATE - - from.SendGump(new ReproductionGump(m_Plant)); - - break; - } - case 4: // Resources - { - from.Send(new DisplayHelpTopic(69, true)); // RESOURCE PRODUCTION - - from.SendGump(new ReproductionGump(m_Plant)); - - break; - } - case 5: // Seeds - { - from.Send(new DisplayHelpTopic(68, true)); // SEED PRODUCTION - - from.SendGump(new ReproductionGump(m_Plant)); - - break; - } - case 6: // Gather pollen - { - if (!m_Plant.IsCrossable) { - m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant! - } - else if (!m_Plant.PlantSystem.PollenProducing) - { - m_Plant.LabelTo(from, - 1053051); // You cannot gather pollen from a plant in this stage of development! - } - else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy) - { - m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant! - } - else - { - from.Target = new PollinateTarget(m_Plant); - from.SendLocalizedMessage(1053054); // Target the plant you wish to cross-pollinate to. + from.SendGump(new MainPlantGump(m_Plant)); break; } + case 2: // Set to decorative + { + if (m_Plant.PlantStatus == PlantStatus.Stage9) from.SendGump(new SetToDecorativeGump(m_Plant)); - from.SendGump(new ReproductionGump(m_Plant)); + break; + } + case 3: // Pollination + { + from.Send(new DisplayHelpTopic(67, true)); // POLLINATION STATE - break; - } + from.SendGump(new ReproductionGump(m_Plant)); + + break; + } + case 4: // Resources + { + from.Send(new DisplayHelpTopic(69, true)); // RESOURCE PRODUCTION + + from.SendGump(new ReproductionGump(m_Plant)); + + break; + } + case 5: // Seeds + { + from.Send(new DisplayHelpTopic(68, true)); // SEED PRODUCTION + + from.SendGump(new ReproductionGump(m_Plant)); + + break; + } + case 6: // Gather pollen + { + if (!m_Plant.IsCrossable) + { + m_Plant.LabelTo(from, 1053050); // You cannot gather pollen from a mutated plant! + } + else if (!m_Plant.PlantSystem.PollenProducing) + { + m_Plant.LabelTo(from, + 1053051); // You cannot gather pollen from a plant in this stage of development! + } + else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy) + { + m_Plant.LabelTo(from, 1053052); // You cannot gather pollen from an unhealthy plant! + } + else + { + from.Target = new PollinateTarget(m_Plant); + from.SendLocalizedMessage(1053054); // Target the plant you wish to cross-pollinate to. + + break; + } + + from.SendGump(new ReproductionGump(m_Plant)); + + break; + } case 7: // Gather resources - { - PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue); - PlantSystem system = m_Plant.PlantSystem; - - if (resInfo == null) { - if (m_Plant.IsCrossable) + PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue); + PlantSystem system = m_Plant.PlantSystem; + + if (resInfo == null) + { + if (m_Plant.IsCrossable) + m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather! + else + m_Plant.LabelTo(from, 1053055); // Mutated plants do not produce resources! + } + else if (system.AvailableResources == 0) + { m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather! - else - m_Plant.LabelTo(from, 1053055); // Mutated plants do not produce resources! - } - else if (system.AvailableResources == 0) - { - m_Plant.LabelTo(from, 1053056); // This plant has no resources to gather! - } - else - { - Item resource = resInfo.CreateResource(); - - if (from.PlaceInBackpack(resource)) - { - system.AvailableResources--; - m_Plant.LabelTo(from, 1053059); // You gather resources from the plant. } else { - resource.Delete(); - m_Plant.LabelTo(from, - 1053058); // You attempt to gather as many resources as you can hold, but your backpack is full. + Item resource = resInfo.CreateResource(); + + if (from.PlaceInBackpack(resource)) + { + system.AvailableResources--; + m_Plant.LabelTo(from, 1053059); // You gather resources from the plant. + } + else + { + resource.Delete(); + m_Plant.LabelTo(from, + 1053058); // You attempt to gather as many resources as you can hold, but your backpack is full. + } } + + from.SendGump(new ReproductionGump(m_Plant)); + + break; } - - from.SendGump(new ReproductionGump(m_Plant)); - - break; - } case 8: // Gather seeds - { - PlantSystem system = m_Plant.PlantSystem; + { + PlantSystem system = m_Plant.PlantSystem; - if (!m_Plant.Reproduces) - { - m_Plant.LabelTo(from, 1053060); // Mutated plants do not produce seeds! - } - else if (system.AvailableSeeds == 0) - { - m_Plant.LabelTo(from, 1053061); // This plant has no seeds to gather! - } - else - { - Seed seed = new Seed(system.SeedType, system.SeedHue, true); - - if (from.PlaceInBackpack(seed)) + if (!m_Plant.Reproduces) { - system.AvailableSeeds--; - m_Plant.LabelTo(from, 1053063); // You gather seeds from the plant. + m_Plant.LabelTo(from, 1053060); // Mutated plants do not produce seeds! + } + else if (system.AvailableSeeds == 0) + { + m_Plant.LabelTo(from, 1053061); // This plant has no seeds to gather! } else { - seed.Delete(); - m_Plant.LabelTo(from, - 1053062); // You attempt to gather as many seeds as you can hold, but your backpack is full. + Seed seed = new Seed(system.SeedType, system.SeedHue, true); + + if (from.PlaceInBackpack(seed)) + { + system.AvailableSeeds--; + m_Plant.LabelTo(from, 1053063); // You gather seeds from the plant. + } + else + { + seed.Delete(); + m_Plant.LabelTo(from, + 1053062); // You attempt to gather as many seeds as you can hold, but your backpack is full. + } } + + from.SendGump(new ReproductionGump(m_Plant)); + + break; } - - from.SendGump(new ReproductionGump(m_Plant)); - - break; - } } } } diff --git a/Projects/Scripts/Engines/Plants/Seed.cs b/Projects/Scripts/Engines/Plants/Seed.cs index 45a9fe9ae..78b26c22e 100644 --- a/Projects/Scripts/Engines/Plants/Seed.cs +++ b/Projects/Scripts/Engines/Plants/Seed.cs @@ -186,7 +186,7 @@ namespace Server.Engines.Plants private class InternalTarget : Target { - private Seed m_Seed; + private readonly Seed m_Seed; public InternalTarget(Seed seed) : base(-1, false, TargetFlags.None) { diff --git a/Projects/Scripts/Engines/Plants/SetToDecorativeGump.cs b/Projects/Scripts/Engines/Plants/SetToDecorativeGump.cs index 5b3a60bce..8e1317bd2 100644 --- a/Projects/Scripts/Engines/Plants/SetToDecorativeGump.cs +++ b/Projects/Scripts/Engines/Plants/SetToDecorativeGump.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Plants { public class SetToDecorativeGump : Gump { - private PlantItem m_Plant; + private readonly PlantItem m_Plant; public SetToDecorativeGump(PlantItem plant) : base(20, 20) { @@ -57,27 +57,27 @@ namespace Server.Engines.Plants switch (info.ButtonID) { case 1: // Cancel - { - from.SendGump(new ReproductionGump(m_Plant)); + { + from.SendGump(new ReproductionGump(m_Plant)); - break; - } + break; + } case 2: // Help - { - from.Send(new DisplayHelpTopic(70, true)); // DECORATIVE MODE + { + from.Send(new DisplayHelpTopic(70, true)); // DECORATIVE MODE - from.SendGump(new SetToDecorativeGump(m_Plant)); + from.SendGump(new SetToDecorativeGump(m_Plant)); - break; - } + break; + } case 3: // Ok - { - m_Plant.PlantStatus = PlantStatus.DecorativePlant; - m_Plant.LabelTo(from, - 1053077); // You prune the plant. This plant will no longer produce resources or seeds, but will require no upkeep. + { + m_Plant.PlantStatus = PlantStatus.DecorativePlant; + m_Plant.LabelTo(from, + 1053077); // You prune the plant. This plant will no longer produce resources or seeds, but will require no upkeep. - break; - } + break; + } } } } diff --git a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/AmbitiousQueenQuest.cs b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/AmbitiousQueenQuest.cs index e671aa5ae..b06f65c3c 100644 --- a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/AmbitiousQueenQuest.cs +++ b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/AmbitiousQueenQuest.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Quests.Ambitious { public class AmbitiousQueenQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(DontOfferConversation), typeof(AcceptConversation), @@ -40,7 +40,7 @@ namespace Server.Engines.Quests.Ambitious public override int Picture => 0x15C9; - public bool RedSolen{ get; private set; } + public bool RedSolen { get; private set; } public override void ChildDeserialize(IGenericReader reader) { diff --git a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Conversations.cs b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Conversations.cs index 69a870c1c..81827773d 100644 --- a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Conversations.cs +++ b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Conversations.cs @@ -65,7 +65,7 @@ namespace Server.Engines.Quests.Ambitious private bool m_BagOfSending; private bool m_Gold; - private bool m_Logged; + private readonly bool m_Logged; private bool m_PowderOfTranslocation; public FullBackpackConversation(bool logged, bool bagOfSending, bool powderOfTranslocation, bool gold) diff --git a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs index b1f73fa98..2c9b57f1d 100644 --- a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs +++ b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Mobiles/AmbitiousSolenQueen.cs @@ -13,7 +13,7 @@ namespace Server.Engines.Quests.Ambitious { } - public abstract bool RedSolen{ get; } + public abstract bool RedSolen { get; } public override string DefaultName => "an ambitious solen queen"; public override bool DisallowAllMoves => false; @@ -54,7 +54,7 @@ namespace Server.Engines.Quests.Ambitious else { GetRewardObjective lastObj = qs.FindObjective(); - + if (lastObj?.Completed == false) { bool bagOfSending = lastObj.BagOfSending; diff --git a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs index 2d2196f5a..b651cbe54 100644 --- a/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/Ambitious Solen Queen/Objectives.cs @@ -95,11 +95,11 @@ namespace Server.Engines.Quests.Ambitious public override object Message => 1054148; - public bool BagOfSending{ get; set; } + public bool BagOfSending { get; set; } - public bool PowderOfTranslocation{ get; set; } + public bool PowderOfTranslocation { get; set; } - public bool Gold{ get; set; } + public bool Gold { get; set; } public override void OnComplete() { diff --git a/Projects/Scripts/Engines/Quests/Collector/CollectorQuest.cs b/Projects/Scripts/Engines/Quests/Collector/CollectorQuest.cs index d8b24691a..5b0563ec7 100644 --- a/Projects/Scripts/Engines/Quests/Collector/CollectorQuest.cs +++ b/Projects/Scripts/Engines/Quests/Collector/CollectorQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Collector { public class CollectorQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(DontOfferConversation), typeof(DeclineConversation), diff --git a/Projects/Scripts/Engines/Quests/Collector/Conversations.cs b/Projects/Scripts/Engines/Quests/Collector/Conversations.cs index 960e812cc..f5a8cc334 100644 --- a/Projects/Scripts/Engines/Quests/Collector/Conversations.cs +++ b/Projects/Scripts/Engines/Quests/Collector/Conversations.cs @@ -241,7 +241,7 @@ namespace Server.Engines.Quests.Collector public class FullEndConversation : QuestConversation { - private bool m_Logged; + private readonly bool m_Logged; public FullEndConversation(bool logged) => m_Logged = logged; diff --git a/Projects/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs b/Projects/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs index dd3c45468..7c8477c71 100644 --- a/Projects/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs +++ b/Projects/Scripts/Engines/Quests/Collector/Items/EnchantedPaints.cs @@ -54,7 +54,7 @@ namespace Server.Engines.Quests.Collector private class InternalTarget : Target { - private EnchantedPaints m_Paints; + private readonly EnchantedPaints m_Paints; public InternalTarget(EnchantedPaints paints) : base(-1, false, TargetFlags.None) { @@ -78,7 +78,7 @@ namespace Server.Engines.Quests.Collector if (obj?.Completed != false) return; - + if (targeted is Mobile) { CaptureResponse response = obj.CaptureImage( @@ -89,27 +89,27 @@ namespace Server.Engines.Quests.Collector switch (response) { case CaptureResponse.Valid: - { - player.SendLocalizedMessage( - 1055125); // The enchanted paints swirl for a moment then an image begins to take shape. *Click* - player.AddToBackpack(new PaintedImage(image)); + { + player.SendLocalizedMessage( + 1055125); // The enchanted paints swirl for a moment then an image begins to take shape. *Click* + player.AddToBackpack(new PaintedImage(image)); - break; - } + break; + } case CaptureResponse.AlreadyDone: - { - player.SendAsciiMessage(0x2C, - "You have already captured the image of this creature"); + { + player.SendAsciiMessage(0x2C, + "You have already captured the image of this creature"); - break; - } + break; + } case CaptureResponse.Invalid: - { - player.SendLocalizedMessage( - 1055124); // You have no interest in capturing the image of this creature. + { + player.SendLocalizedMessage( + 1055124); // You have no interest in capturing the image of this creature. - break; - } + break; + } } } else diff --git a/Projects/Scripts/Engines/Quests/Collector/Items/ImageTypeInfo.cs b/Projects/Scripts/Engines/Quests/Collector/Items/ImageTypeInfo.cs index 6df35d442..067319b75 100644 --- a/Projects/Scripts/Engines/Quests/Collector/Items/ImageTypeInfo.cs +++ b/Projects/Scripts/Engines/Quests/Collector/Items/ImageTypeInfo.cs @@ -66,13 +66,13 @@ namespace Server.Engines.Quests.Collector Y = y; } - public int Figurine{ get; } + public int Figurine { get; } - public Type Type{ get; } + public Type Type { get; } public int Name => Figurine < 0x4000 ? 1020000 + Figurine : 1078872 + Figurine; - public int X{ get; } - public int Y{ get; } + public int X { get; } + public int Y { get; } public static ImageTypeInfo Get(ImageType image) { @@ -88,7 +88,7 @@ namespace Server.Engines.Quests.Collector for (int i = 0; i < m_Table.Length; i++) m_ImageTypeList[i] = (ImageType)i; } - + ImageType[] array = m_ImageTypeList.ToArray(); Utility.Shuffle(array); return array.Take(count).ToArray(); diff --git a/Projects/Scripts/Engines/Quests/Collector/Items/Obsidian.cs b/Projects/Scripts/Engines/Quests/Collector/Items/Obsidian.cs index 66101b2af..08b806e91 100644 --- a/Projects/Scripts/Engines/Quests/Collector/Items/Obsidian.cs +++ b/Projects/Scripts/Engines/Quests/Collector/Items/Obsidian.cs @@ -197,7 +197,7 @@ namespace Server.Engines.Quests.Collector private class DisassembleEntry : ContextMenuEntry { - private Obsidian m_Obsidian; + private readonly Obsidian m_Obsidian; public DisassembleEntry(Obsidian obsidian) : base(6142) => m_Obsidian = obsidian; @@ -217,7 +217,7 @@ namespace Server.Engines.Quests.Collector private class InternalTarget : Target { - private Obsidian m_Obsidian; + private readonly Obsidian m_Obsidian; public InternalTarget(Obsidian obsidian) : base(-1, false, TargetFlags.None) => m_Obsidian = obsidian; diff --git a/Projects/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs b/Projects/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs index ad94ed57b..c3f0c8c8a 100644 --- a/Projects/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs +++ b/Projects/Scripts/Engines/Quests/Collector/Mobiles/Impresario.cs @@ -152,7 +152,6 @@ namespace Server.Engines.Quests.Collector { if (player.FindBankNoCreate()?.ConsumeTotal(typeof(Gold), 10) == true) obj.Complete(); - else player.SendLocalizedMessage( 1055108); // You don't have enough gold to buy the sheet music. diff --git a/Projects/Scripts/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs b/Projects/Scripts/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs index 51bc55c74..af0d859cf 100644 --- a/Projects/Scripts/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs +++ b/Projects/Scripts/Engines/Quests/Collector/Mobiles/TomasONeerlan.cs @@ -33,7 +33,7 @@ namespace Server.Engines.Quests.Collector AddItem(new Boots(0x452)); AddItem(new FullApron(0x455)); - HairItemID = 0x203B; //ShortHair + HairItemID = 0x203B; // ShortHair HairHue = 0x455; } diff --git a/Projects/Scripts/Engines/Quests/Core/BaseQuester.cs b/Projects/Scripts/Engines/Quests/Core/BaseQuester.cs index 774f90a7c..a0f0f621c 100644 --- a/Projects/Scripts/Engines/Quests/Core/BaseQuester.cs +++ b/Projects/Scripts/Engines/Quests/Core/BaseQuester.cs @@ -7,7 +7,7 @@ namespace Server.Engines.Quests { public class TalkEntry : ContextMenuEntry { - private BaseQuester m_Quester; + private readonly BaseQuester m_Quester; public TalkEntry(BaseQuester quester) : base(quester.TalkNumber) => m_Quester = quester; diff --git a/Projects/Scripts/Engines/Quests/Core/Items/EnchantedSextant.cs b/Projects/Scripts/Engines/Quests/Core/Items/EnchantedSextant.cs index 4e96bd24b..d671bb7d1 100644 --- a/Projects/Scripts/Engines/Quests/Core/Items/EnchantedSextant.cs +++ b/Projects/Scripts/Engines/Quests/Core/Items/EnchantedSextant.cs @@ -8,7 +8,7 @@ namespace Server.Items private const double m_ShortDistance = 5.0; - //TODO: Trammel/Haven + // TODO: Trammel/Haven private static readonly Point2D[] m_TrammelBanks = { new Point2D(652, 820), @@ -99,8 +99,8 @@ namespace Server.Items else if (from.Map == Map.Ilshenar) { #if false - banks = m_IlshenarBanks; - moongates = PMList.Ilshenar; + banks = m_IlshenarBanks; + moongates = PMList.Ilshenar; #else from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, 0x482, 3, 1061684, "", "")); // The magic of the sextant fails... @@ -183,4 +183,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Quests/Core/Items/HornOfRetreat.cs b/Projects/Scripts/Engines/Quests/Core/Items/HornOfRetreat.cs index be8aeb068..e479ccf19 100644 --- a/Projects/Scripts/Engines/Quests/Core/Items/HornOfRetreat.cs +++ b/Projects/Scripts/Engines/Quests/Core/Items/HornOfRetreat.cs @@ -23,10 +23,10 @@ namespace Server.Engines.Quests } [CommandProperty(AccessLevel.GameMaster)] - public Point3D DestLoc{ get; set; } + public Point3D DestLoc { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Map DestMap{ get; set; } + public Map DestMap { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Charges @@ -120,19 +120,19 @@ namespace Server.Engines.Quests switch (version) { case 0: - { - DestLoc = reader.ReadPoint3D(); - DestMap = reader.ReadMap(); - m_Charges = reader.ReadInt(); - break; - } + { + DestLoc = reader.ReadPoint3D(); + DestMap = reader.ReadMap(); + m_Charges = reader.ReadInt(); + break; + } } } } public class HornOfRetreatMoongate : Moongate { - private Mobile m_Caster; + private readonly Mobile m_Caster; public HornOfRetreatMoongate(Point3D destLoc, Map destMap, Mobile caster, int hue) { diff --git a/Projects/Scripts/Engines/Quests/Core/QuestCallbackEntry.cs b/Projects/Scripts/Engines/Quests/Core/QuestCallbackEntry.cs index a9b13569b..42c3cdc78 100644 --- a/Projects/Scripts/Engines/Quests/Core/QuestCallbackEntry.cs +++ b/Projects/Scripts/Engines/Quests/Core/QuestCallbackEntry.cs @@ -4,7 +4,7 @@ namespace Server.Engines.Quests { public class QuestCallbackEntry : ContextMenuEntry { - private QuestCallback m_Callback; + private readonly QuestCallback m_Callback; public QuestCallbackEntry(int number, QuestCallback callback) : this(number, -1, callback) { diff --git a/Projects/Scripts/Engines/Quests/Core/QuestConversation.cs b/Projects/Scripts/Engines/Quests/Core/QuestConversation.cs index fe1db70a8..37ea14ac5 100644 --- a/Projects/Scripts/Engines/Quests/Core/QuestConversation.cs +++ b/Projects/Scripts/Engines/Quests/Core/QuestConversation.cs @@ -6,14 +6,14 @@ namespace Server.Engines.Quests { public abstract class QuestConversation { - public abstract object Message{ get; } + public abstract object Message { get; } public virtual QuestItemInfo[] Info => null; public virtual bool Logged => true; - public QuestSystem System{ get; set; } + public QuestSystem System { get; set; } - public bool HasBeenRead{ get; set; } + public bool HasBeenRead { get; set; } public virtual void BaseDeserialize(IGenericReader reader) { @@ -22,11 +22,11 @@ namespace Server.Engines.Quests switch (version) { case 0: - { - HasBeenRead = reader.ReadBool(); + { + HasBeenRead = reader.ReadBool(); - break; - } + break; + } } ChildDeserialize(reader); @@ -58,9 +58,9 @@ namespace Server.Engines.Quests public class QuestConversationsGump : BaseQuestGump { - private List m_Conversations; + private readonly List m_Conversations; - public QuestConversationsGump(QuestConversation conv) : this(new List{ conv }) + public QuestConversationsGump(QuestConversation conv) : this(new List { conv }) { } diff --git a/Projects/Scripts/Engines/Quests/Core/QuestItemInfo.cs b/Projects/Scripts/Engines/Quests/Core/QuestItemInfo.cs index 22f0066c1..1529bd954 100644 --- a/Projects/Scripts/Engines/Quests/Core/QuestItemInfo.cs +++ b/Projects/Scripts/Engines/Quests/Core/QuestItemInfo.cs @@ -8,9 +8,9 @@ namespace Server.Engines.Quests ItemID = itemID; } - public object Name{ get; set; } + public object Name { get; set; } - public int ItemID{ get; set; } + public int ItemID { get; set; } } public class QuestItemInfoGump : BaseQuestGump diff --git a/Projects/Scripts/Engines/Quests/Core/QuestObjective.cs b/Projects/Scripts/Engines/Quests/Core/QuestObjective.cs index b93792b66..a06baedb2 100644 --- a/Projects/Scripts/Engines/Quests/Core/QuestObjective.cs +++ b/Projects/Scripts/Engines/Quests/Core/QuestObjective.cs @@ -10,14 +10,14 @@ namespace Server.Engines.Quests { private int m_CurProgress; - public abstract object Message{ get; } + public abstract object Message { get; } public virtual int MaxProgress => 1; public virtual QuestItemInfo[] Info => null; - public QuestSystem System{ get; set; } + public QuestSystem System { get; set; } - public bool HasBeenRead{ get; set; } + public bool HasBeenRead { get; set; } public int CurProgress { @@ -29,7 +29,7 @@ namespace Server.Engines.Quests } } - public bool HasCompleted{ get; set; } + public bool HasCompleted { get; set; } public virtual bool Completed => m_CurProgress >= MaxProgress; @@ -42,17 +42,17 @@ namespace Server.Engines.Quests switch (version) { case 1: - { - HasBeenRead = reader.ReadBool(); - goto case 0; - } + { + HasBeenRead = reader.ReadBool(); + goto case 0; + } case 0: - { - m_CurProgress = reader.ReadEncodedInt(); - HasCompleted = reader.ReadBool(); + { + m_CurProgress = reader.ReadEncodedInt(); + HasCompleted = reader.ReadBool(); - break; - } + break; + } } ChildDeserialize(reader); @@ -128,7 +128,7 @@ namespace Server.Engines.Quests public class QuestLogUpdatedGump : BaseQuestGump { - private QuestSystem m_System; + private readonly QuestSystem m_System; public QuestLogUpdatedGump(QuestSystem system) : base(3, 30) { @@ -155,9 +155,9 @@ namespace Server.Engines.Quests public class QuestObjectivesGump : BaseQuestGump { - private List m_Objectives; + private readonly List m_Objectives; - public QuestObjectivesGump(QuestObjective obj) : this(new List{ obj }) + public QuestObjectivesGump(QuestObjective obj) : this(new List { obj }) { } diff --git a/Projects/Scripts/Engines/Quests/Core/QuestRestartInfo.cs b/Projects/Scripts/Engines/Quests/Core/QuestRestartInfo.cs index c65298902..8764271d3 100644 --- a/Projects/Scripts/Engines/Quests/Core/QuestRestartInfo.cs +++ b/Projects/Scripts/Engines/Quests/Core/QuestRestartInfo.cs @@ -16,9 +16,9 @@ namespace Server.Engines.Quests RestartTime = restartTime; } - public Type QuestType{ get; set; } + public Type QuestType { get; set; } - public DateTime RestartTime{ get; set; } + public DateTime RestartTime { get; set; } public void Reset(TimeSpan restartDelay) { diff --git a/Projects/Scripts/Engines/Quests/Core/QuestSerializer.cs b/Projects/Scripts/Engines/Quests/Core/QuestSerializer.cs index c92f4f365..a9b347ff0 100644 --- a/Projects/Scripts/Engines/Quests/Core/QuestSerializer.cs +++ b/Projects/Scripts/Engines/Quests/Core/QuestSerializer.cs @@ -1,5 +1,5 @@ -using Server.Utilities; using System; +using Server.Utilities; namespace Server.Engines.Quests { @@ -45,27 +45,27 @@ namespace Server.Engines.Quests switch (encoding) { default: - { - return null; - } - case 0x01: // indexed - { - int index = reader.ReadEncodedInt(); - - if (index >= 0 && index < referenceTable.Length) - return referenceTable[index]; - - return null; - } - case 0x02: // by name - { - string fullName = reader.ReadString(); - - if (fullName == null) + { return null; + } + case 0x01: // indexed + { + int index = reader.ReadEncodedInt(); - return AssemblyHandler.FindFirstTypeForName(fullName, false); - } + if (index >= 0 && index < referenceTable.Length) + return referenceTable[index]; + + return null; + } + case 0x02: // by name + { + string fullName = reader.ReadString(); + + if (fullName == null) + return null; + + return AssemblyHandler.FindFirstTypeForName(fullName, false); + } } } @@ -76,19 +76,19 @@ namespace Server.Engines.Quests switch (encoding) { default: - { - return null; - } + { + return null; + } case 0x01: - { - Type type = ReadType(QuestSystem.QuestTypes, reader); + { + Type type = ReadType(QuestSystem.QuestTypes, reader); - QuestSystem qs = Construct(type) as QuestSystem; + QuestSystem qs = Construct(type) as QuestSystem; - qs?.BaseDeserialize(reader); + qs?.BaseDeserialize(reader); - return qs; - } + return qs; + } } } @@ -115,19 +115,19 @@ namespace Server.Engines.Quests switch (encoding) { default: - { - return null; - } + { + return null; + } case 0x01: - { - Type type = ReadType(referenceTable, reader); + { + Type type = ReadType(referenceTable, reader); - QuestObjective obj = Construct(type) as QuestObjective; + QuestObjective obj = Construct(type) as QuestObjective; - obj?.BaseDeserialize(reader); + obj?.BaseDeserialize(reader); - return obj; - } + return obj; + } } } @@ -154,19 +154,19 @@ namespace Server.Engines.Quests switch (encoding) { default: - { - return null; - } + { + return null; + } case 0x01: - { - Type type = ReadType(referenceTable, reader); + { + Type type = ReadType(referenceTable, reader); - QuestConversation conv = Construct(type) as QuestConversation; + QuestConversation conv = Construct(type) as QuestConversation; - conv?.BaseDeserialize(reader); + conv?.BaseDeserialize(reader); - return conv; - } + return conv; + } } } diff --git a/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs b/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs index f02deb1c9..4692a0141 100644 --- a/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs +++ b/Projects/Scripts/Engines/Quests/Core/QuestSystem.cs @@ -51,21 +51,21 @@ namespace Server.Engines.Quests { } - public abstract object Name{ get; } - public abstract object OfferMessage{ get; } + public abstract object Name { get; } + public abstract object OfferMessage { get; } - public abstract int Picture{ get; } + public abstract int Picture { get; } - public abstract bool IsTutorial{ get; } - public abstract TimeSpan RestartDelay{ get; } + public abstract bool IsTutorial { get; } + public abstract TimeSpan RestartDelay { get; } - public abstract Type[] TypeReferenceTable{ get; } + public abstract Type[] TypeReferenceTable { get; } - public PlayerMobile From{ get; set; } + public PlayerMobile From { get; set; } - public List Objectives{ get; set; } + public List Objectives { get; set; } - public List Conversations{ get; set; } + public List Conversations { get; set; } public virtual void StartTimer() { @@ -126,39 +126,39 @@ namespace Server.Engines.Quests switch (version) { case 0: - { - int count = reader.ReadEncodedInt(); - - Objectives = new List(count); - - for (int i = 0; i < count; ++i) { - QuestObjective obj = QuestSerializer.DeserializeObjective(referenceTable, reader); + int count = reader.ReadEncodedInt(); - if (obj != null) + Objectives = new List(count); + + for (int i = 0; i < count; ++i) { - obj.System = this; - Objectives.Add(obj); + QuestObjective obj = QuestSerializer.DeserializeObjective(referenceTable, reader); + + if (obj != null) + { + obj.System = this; + Objectives.Add(obj); + } } - } - count = reader.ReadEncodedInt(); + count = reader.ReadEncodedInt(); - Conversations = new List(count); + Conversations = new List(count); - for (int i = 0; i < count; ++i) - { - QuestConversation conv = QuestSerializer.DeserializeConversation(referenceTable, reader); - - if (conv != null) + for (int i = 0; i < count; ++i) { - conv.System = this; - Conversations.Add(conv); - } - } + QuestConversation conv = QuestSerializer.DeserializeConversation(referenceTable, reader); - break; - } + if (conv != null) + { + conv.System = this; + Conversations.Add(conv); + } + } + + break; + } } ChildDeserialize(reader); @@ -324,7 +324,7 @@ namespace Server.Engines.Quests TimeSpan restartDelay = RestartDelay; - if (completed && restartDelay > TimeSpan.Zero || !completed && restartDelay == TimeSpan.MaxValue) + if ((completed && restartDelay > TimeSpan.Zero) || (!completed && restartDelay == TimeSpan.MaxValue)) { From.DoneQuests ??= new List(); @@ -405,8 +405,7 @@ namespace Server.Engines.Quests if (questType == typeof(DarkTidesQuest) && pm.Profession != 4) // necromancer return false; - if (questType == typeof(UzeraanTurmoilQuest) && pm.Profession != 1 && pm.Profession != 2 && pm.Profession != 5 - ) // warrior / magician / paladin + if (questType == typeof(UzeraanTurmoilQuest) && pm.Profession != 1 && pm.Profession != 2 && pm.Profession != 5) // warrior / magician / paladin return false; if (questType == typeof(HaochisTrialsQuest) && pm.Profession != 6) // samurai @@ -463,7 +462,7 @@ namespace Server.Engines.Quests public static int RandomBrightHue() { - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) return Utility.RandomList(0x62, 0x71); return Utility.RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59); @@ -472,7 +471,7 @@ namespace Server.Engines.Quests public class QuestCancelGump : BaseQuestGump { - private QuestSystem m_System; + private readonly QuestSystem m_System; public QuestCancelGump(QuestSystem system) : base(120, 50) { @@ -542,7 +541,7 @@ namespace Server.Engines.Quests public class QuestOfferGump : BaseQuestGump { - private QuestSystem m_System; + private readonly QuestSystem m_System; public QuestOfferGump(QuestSystem system) : base(75, 25) { diff --git a/Projects/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs b/Projects/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs index 8f94a2528..60b3816d8 100644 --- a/Projects/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs +++ b/Projects/Scripts/Engines/Quests/Core/Regions/CancelQuestRegion.cs @@ -7,7 +7,7 @@ namespace Server.Engines.Quests { public class CancelQuestRegion : BaseRegion { - private Type m_Quest; + private readonly Type m_Quest; public CancelQuestRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent) { diff --git a/Projects/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs b/Projects/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs index 787827427..e511056f0 100644 --- a/Projects/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs +++ b/Projects/Scripts/Engines/Quests/Core/Regions/QuestCompleteObjectiveRegion.cs @@ -7,8 +7,8 @@ namespace Server.Engines.Quests { public class QuestCompleteObjectiveRegion : BaseRegion { - private Type m_Objective; - private Type m_Quest; + private readonly Type m_Objective; + private readonly Type m_Quest; public QuestCompleteObjectiveRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent) { diff --git a/Projects/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs b/Projects/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs index 81c680721..28281a09b 100644 --- a/Projects/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs +++ b/Projects/Scripts/Engines/Quests/Core/Regions/QuestNoEntryRegion.cs @@ -7,10 +7,10 @@ namespace Server.Engines.Quests { public class QuestNoEntryRegion : BaseRegion { - private Type m_MaxObjective; - private int m_Message; - private Type m_MinObjective; - private Type m_Quest; + private readonly Type m_MaxObjective; + private readonly int m_Message; + private readonly Type m_MinObjective; + private readonly Type m_Quest; public QuestNoEntryRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent) { diff --git a/Projects/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs b/Projects/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs index e64194085..b06e1b105 100644 --- a/Projects/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs +++ b/Projects/Scripts/Engines/Quests/Core/Regions/QuestOfferRegion.cs @@ -8,7 +8,7 @@ namespace Server.Engines.Quests { public class QuestOfferRegion : BaseRegion { - private Type m_Quest; + private readonly Type m_Quest; public QuestOfferRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent) { diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Conversations.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Conversations.cs index 241ea9fa4..0837a8483 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/Conversations.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/Conversations.cs @@ -20,7 +20,7 @@ namespace Server.Engines.Quests.Necro public class ReanimateMaabusConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1026153, 6178), // teleporter new QuestItemInfo(1049117, 4036), // Horn of Retreat @@ -39,7 +39,7 @@ namespace Server.Engines.Quests.Necro public class MaabasConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1026153, 6178) // teleporter }; @@ -76,7 +76,7 @@ namespace Server.Engines.Quests.Necro public class VaultOfSecretsConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1023643, 8787) // spellbook }; diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs b/Projects/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs index 8faecadfd..c0bc30dad 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/DarkTidesQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Necro { public class DarkTidesQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(AcceptConversation), typeof(AnimateMaabusCorpseObjective), diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs index 5b81b4506..ecf6b808e 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/Items/KronusScroll.cs @@ -89,7 +89,7 @@ namespace Server.Engines.Quests.Necro private class CallingTimer : Timer { - private PlayerMobile m_Player; + private readonly PlayerMobile m_Player; private int m_Step; public CallingTimer(PlayerMobile player) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0), 6) diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs index aa77109a6..3c2049a63 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/Items/MaabusCoffin.cs @@ -24,10 +24,10 @@ namespace Server.Engines.Quests.Necro } [CommandProperty(AccessLevel.GameMaster)] - public Maabus Maabus{ get; private set; } + public Maabus Maabus { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D SpawnLocation{ get; set; } + public Point3D SpawnLocation { get; set; } public void Awake(Mobile caller) { diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Horus.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Horus.cs index a8f0d1091..978587747 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Horus.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Horus.cs @@ -166,8 +166,8 @@ namespace Server.Engines.Quests.Necro private class SpeakPasswordEntry : ContextMenuEntry { - private PlayerMobile m_From; - private Horus m_Horus; + private readonly PlayerMobile m_From; + private readonly Horus m_Horus; public SpeakPasswordEntry(Horus horus, PlayerMobile from, bool enabled) : base(6193, 3) { diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs index c4f993412..70a945c75 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/Mardoth.cs @@ -48,7 +48,7 @@ namespace Server.Engines.Quests.Necro } else { - player.SendLocalizedMessage(1114333); //You must be young to have this item recharged. + player.SendLocalizedMessage(1114333); // You must be young to have this item recharged. } return false; diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs index 27594d82e..8f0de24a2 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/Mobiles/SummonedPaladin.cs @@ -148,7 +148,7 @@ namespace Server.Engines.Quests.Necro private class SummonTimer : Timer { private SummonedPaladin m_Paladin; - private PlayerMobile m_Player; + private readonly PlayerMobile m_Player; private int m_Step; public SummonTimer(PlayerMobile player) : base(TimeSpan.FromSeconds(4.0)) diff --git a/Projects/Scripts/Engines/Quests/Dark Tides/Objectives.cs b/Projects/Scripts/Engines/Quests/Dark Tides/Objectives.cs index facdae06c..a11a6820b 100644 --- a/Projects/Scripts/Engines/Quests/Dark Tides/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/Dark Tides/Objectives.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Quests.Necro { public class AnimateMaabusCorpseObjective : QuestObjective { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1023643, 8787) // spellbook }; @@ -91,7 +91,7 @@ namespace Server.Engines.Quests.Necro public class FindVaultOfSecretsObjective : QuestObjective { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1023676, 3679) // glowing rune }; @@ -156,7 +156,7 @@ namespace Server.Engines.Quests.Necro public class ReturnToCrystalCaveObjective : QuestObjective { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1026153, 6178) // teleporter }; diff --git a/Projects/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs b/Projects/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs index 56f375783..79bdc6be6 100644 --- a/Projects/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs +++ b/Projects/Scripts/Engines/Quests/Emino's Undertaking/EminosUndertakingQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Ninja { public class EminosUndertakingQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(AcceptConversation), typeof(FindZoelConversation), diff --git a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs index 23799ab0d..ceb27bd63 100644 --- a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs +++ b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/Emino.cs @@ -151,7 +151,7 @@ namespace Server.Engines.Quests.Ninja bool stolenTreasure = false; HallwayWalkObjective walk = qs.FindObjective(); - + if (walk != null) stolenTreasure = walk.StolenTreasure; diff --git a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs index dcb51b8c9..5757f2d90 100644 --- a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs +++ b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Mobiles/HiddenFigure.cs @@ -20,7 +20,7 @@ namespace Server.Engines.Quests.Ninja } [CommandProperty(AccessLevel.GameMaster)] - public int Message{ get; set; } + public int Message { get; set; } public override int TalkNumber => -1; diff --git a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs index 21a53e703..769618ce0 100644 --- a/Projects/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/Emino's Undertaking/Objectives.cs @@ -41,7 +41,7 @@ namespace Server.Engines.Quests.Ninja public class SneakPastGuardiansObjective : QuestObjective { - public bool TaughtHowToUseSkills{ get; set; } + public bool TaughtHowToUseSkills { get; set; } public override object Message => 1063261; @@ -131,7 +131,7 @@ namespace Server.Engines.Quests.Ninja public class HallwayWalkObjective : QuestObjective { - public bool StolenTreasure{ get; set; } + public bool StolenTreasure { get; set; } public override object Message => 1063202; diff --git a/Projects/Scripts/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs b/Projects/Scripts/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs index 1c4ec3a51..b833106af 100644 --- a/Projects/Scripts/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs +++ b/Projects/Scripts/Engines/Quests/Haochi's Trials/HaochisTrialsQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Samurai { public class HaochisTrialsQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(AcceptConversation), typeof(RadarConversation), diff --git a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs index 7137109c6..bf45e6148 100644 --- a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs +++ b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Haochi.cs @@ -117,7 +117,7 @@ namespace Server.Engines.Quests.Samurai HaochisKatana katana = player.Backpack?.FindItemByType(); if (katana == null) return; - + katana.Delete(); obj.Complete(); diff --git a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs index 2bccebb66..d4627a45e 100644 --- a/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs +++ b/Projects/Scripts/Engines/Quests/Haochi's Trials/Mobiles/Relnia.cs @@ -10,7 +10,6 @@ namespace Server.Engines.Quests.Samurai { } - public Relnia(Serial serial) : base(serial) { } diff --git a/Projects/Scripts/Engines/Quests/Haochi's Trials/Objectives.cs b/Projects/Scripts/Engines/Quests/Haochi's Trials/Objectives.cs index a644aae1e..0d7c426f3 100644 --- a/Projects/Scripts/Engines/Quests/Haochi's Trials/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/Haochi's Trials/Objectives.cs @@ -138,7 +138,7 @@ namespace Server.Engines.Quests.Samurai public override object Message => 1063229; - public bool Dragon{ get; private set; } + public bool Dragon { get; private set; } public override void OnComplete() { @@ -230,7 +230,7 @@ namespace Server.Engines.Quests.Samurai public override object Message => 1063242; - public bool KilledCat{ get; private set; } + public bool KilledCat { get; private set; } public override void OnComplete() { @@ -256,7 +256,7 @@ namespace Server.Engines.Quests.Samurai { public override object Message => 1063072; - public bool StolenTreasure{ get; set; } + public bool StolenTreasure { get; set; } public override void OnComplete() { diff --git a/Projects/Scripts/Engines/Quests/Solen Matriarch/Conversations.cs b/Projects/Scripts/Engines/Quests/Solen Matriarch/Conversations.cs index a0fbc828f..a61d3ab88 100644 --- a/Projects/Scripts/Engines/Quests/Solen Matriarch/Conversations.cs +++ b/Projects/Scripts/Engines/Quests/Solen Matriarch/Conversations.cs @@ -142,7 +142,7 @@ namespace Server.Engines.Quests.Matriarch public class FullBackpackConversation : QuestConversation { - private bool m_Logged; + private readonly bool m_Logged; public FullBackpackConversation(bool logged) => m_Logged = logged; diff --git a/Projects/Scripts/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs b/Projects/Scripts/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs index ed8c6027a..afd1a2950 100644 --- a/Projects/Scripts/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs +++ b/Projects/Scripts/Engines/Quests/Solen Matriarch/Mobiles/SolenMatriarch.cs @@ -23,7 +23,7 @@ namespace Server.Engines.Quests.Matriarch { } - public abstract bool RedSolen{ get; } + public abstract bool RedSolen { get; } public override string DefaultName => "the solen matriarch"; public override bool DisallowAllMoves => false; @@ -193,8 +193,8 @@ namespace Server.Engines.Quests.Matriarch private class ProcessZoogiFungusEntry : ContextMenuEntry { - private PlayerMobile m_From; - private BaseSolenMatriarch m_Matriarch; + private readonly PlayerMobile m_From; + private readonly BaseSolenMatriarch m_Matriarch; public ProcessZoogiFungusEntry(BaseSolenMatriarch matriarch, PlayerMobile from) : base(6184) { @@ -211,8 +211,8 @@ namespace Server.Engines.Quests.Matriarch private class ProcessFungiTarget : Target { - private PlayerMobile m_From; - private BaseSolenMatriarch m_Matriarch; + private readonly PlayerMobile m_From; + private readonly BaseSolenMatriarch m_Matriarch; public ProcessFungiTarget(BaseSolenMatriarch matriarch, PlayerMobile from) : base(-1, false, TargetFlags.None) { diff --git a/Projects/Scripts/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs b/Projects/Scripts/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs index c5f74d132..e727e047f 100644 --- a/Projects/Scripts/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs +++ b/Projects/Scripts/Engines/Quests/Solen Matriarch/SolenMatriarchQuest.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Quests.Matriarch { public class SolenMatriarchQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(DontOfferConversation), typeof(AcceptConversation), @@ -74,7 +74,7 @@ namespace Server.Engines.Quests.Matriarch public override int Picture => 0x15C9; - public bool RedSolen{ get; private set; } + public bool RedSolen { get; private set; } public override void ChildDeserialize(IGenericReader reader) { diff --git a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs index ad4360cb1..6282577fc 100644 --- a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs +++ b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Mobiles/Naturalist.cs @@ -32,7 +32,6 @@ namespace Server.Engines.Quests.Naturalist AddItem(new LongPants(0x59B)); AddItem(new Boots()); - Utility.AssignRandomHair(this); Utility.AssignRandomFacialHair(this, HairHue); } @@ -44,7 +43,7 @@ namespace Server.Engines.Quests.Naturalist StudyNestsObjective study = qs.FindObjective(); if (study == null) return; - + if (!study.Completed) { PlaySound(0x41F); diff --git a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs index 1e50d6c2b..0287483e8 100644 --- a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs +++ b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/NestArea.cs @@ -21,7 +21,7 @@ namespace Server.Engines.Quests.Naturalist new Rectangle2D(5672, 1857, 6, 20)) }; - private Rectangle2D[] m_Rects; + private readonly Rectangle2D[] m_Rects; private NestArea(bool special, params Rectangle2D[] rects) { @@ -31,7 +31,7 @@ namespace Server.Engines.Quests.Naturalist public static int NonSpecialCount => m_Areas.Count(area => !area.Special); - public bool Special{ get; } + public bool Special { get; } public int ID { diff --git a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs index 165b79db7..677f678b7 100644 --- a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/Objectives.cs @@ -8,7 +8,7 @@ namespace Server.Engines.Quests.Naturalist { private NestArea m_CurrentNest; - private List m_StudiedNests = new List(); + private readonly List m_StudiedNests = new List(); private DateTime m_StudyBegin; private StudyState m_StudyState; @@ -16,7 +16,7 @@ namespace Server.Engines.Quests.Naturalist public override int MaxProgress => NestArea.NonSpecialCount; - public bool StudiedSpecialNest{ get; private set; } + public bool StudiedSpecialNest { get; private set; } public override bool GetTimerEvent() => true; diff --git a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/StudyOfSolenQuest.cs b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/StudyOfSolenQuest.cs index 16c7d0946..cd057ce0c 100644 --- a/Projects/Scripts/Engines/Quests/Study of the Solen Hive/StudyOfSolenQuest.cs +++ b/Projects/Scripts/Engines/Quests/Study of the Solen Hive/StudyOfSolenQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Naturalist { public class StudyOfSolenQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(StudyNestsObjective), typeof(ReturnToNaturalistObjective), @@ -35,7 +35,7 @@ namespace Server.Engines.Quests.Naturalist public override int Picture => 0x15C7; - public Naturalist Naturalist{ get; private set; } + public Naturalist Naturalist { get; private set; } public override void ChildDeserialize(IGenericReader reader) { diff --git a/Projects/Scripts/Engines/Quests/Terrible Hatchlings/TerribleHatchlingsQuest.cs b/Projects/Scripts/Engines/Quests/Terrible Hatchlings/TerribleHatchlingsQuest.cs index 24c16ec95..e7c724e69 100644 --- a/Projects/Scripts/Engines/Quests/Terrible Hatchlings/TerribleHatchlingsQuest.cs +++ b/Projects/Scripts/Engines/Quests/Terrible Hatchlings/TerribleHatchlingsQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Zento { public class TerribleHatchlingsQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(AcceptConversation), typeof(DirectionConversation), diff --git a/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs b/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs index 5883f9d39..b461dc919 100644 --- a/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs +++ b/Projects/Scripts/Engines/Quests/The Summoning/Items/BellOfTheDead.cs @@ -21,13 +21,13 @@ namespace Server.Engines.Quests.Doom public override int LabelNumber => 1050018; // bell of the dead [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public Chyloth Chyloth{ get; set; } + public Chyloth Chyloth { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public SkeletalDragon Dragon{ get; set; } + public SkeletalDragon Dragon { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public bool Summoning{ get; set; } + public bool Summoning { get; set; } public override void OnDoubleClick(Mobile from) { diff --git a/Projects/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs b/Projects/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs index aaedbd420..8ef295114 100644 --- a/Projects/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs +++ b/Projects/Scripts/Engines/Quests/The Summoning/Mobiles/Chyloth.cs @@ -9,7 +9,7 @@ namespace Server.Engines.Quests.Doom { public class Chyloth : BaseQuester { - private static int[] m_Offsets = + private static readonly int[] m_Offsets = { -1, -1, -1, 0, @@ -32,9 +32,9 @@ namespace Server.Engines.Quests.Doom public override string DefaultName => "Chyloth"; - public BellOfTheDead Bell{ get; set; } + public BellOfTheDead Bell { get; set; } - public Mobile AngryAt{ get; set; } + public Mobile AngryAt { get; set; } public override void InitBody() { @@ -226,8 +226,8 @@ namespace Server.Engines.Quests.Doom public class ChylothPartyGump : Gump { - private Mobile m_Leader; - private Mobile m_Member; + private readonly Mobile m_Leader; + private readonly Mobile m_Member; public ChylothPartyGump(Mobile leader, Mobile member) : base(150, 50) { diff --git a/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs b/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs index 6443b4eee..a4555f46e 100644 --- a/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/The Summoning/Objectives.cs @@ -79,7 +79,7 @@ namespace Server.Engines.Quests.Doom { } - public Corpse CorpseWithSkull{ get; set; } + public Corpse CorpseWithSkull { get; set; } public override object Message => 1050037; diff --git a/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs b/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs index 788f1157d..3421ed1ab 100644 --- a/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs +++ b/Projects/Scripts/Engines/Quests/The Summoning/TheSummoningQuest.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Quests.Doom { public class TheSummoningQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(AcceptConversation), typeof(CollectBonesObjective), @@ -22,9 +22,9 @@ namespace Server.Engines.Quests.Doom public override Type[] TypeReferenceTable => m_TypeReferenceTable; - public Victoria Victoria{ get; private set; } + public Victoria Victoria { get; private set; } - public bool WaitForSummon{ get; set; } + public bool WaitForSummon { get; set; } public override object Name => 1050025; diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Conversations.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Conversations.cs index 70770ad78..64bdb1f4d 100644 --- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Conversations.cs +++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Conversations.cs @@ -22,7 +22,7 @@ namespace Server.Engines.Quests.Haven public class UzeraanFirstTaskConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1023676, 0xE68) // glowing rune }; @@ -36,29 +36,29 @@ namespace Server.Engines.Quests.Haven if (System.From.Profession == 2) // magician return 1049386; -/* Uzeraan nods at you with approval and begins to speak...

- * - * Now that you are ready, let me give you your first task.

- * - * As I mentioned earlier, we have been trying to fight back the wicked - * Horde Minions which have recently begun attacking our cities - * - but to no avail. Our need is great!

- * - * Your first task will be to assess the situation in the mountain pass, - * and help our troops defeat the Horde Minions there.

- * - * Take the road marked with glowing runes, that starts just outside of this mansion. - * Before you go into battle, it would be prudent to - * review combat techniques as well as - * information on healing yourself, - * using your Paladin ability 'Close Wounds'.

- * - * To aid you in your fight, you may also wish to - * purchase equipment from Frank the Blacksmith, - * who is standing just South of here.

- * - * Good luck young Paladin! - */ + /* Uzeraan nods at you with approval and begins to speak...

+ * + * Now that you are ready, let me give you your first task.

+ * + * As I mentioned earlier, we have been trying to fight back the wicked + * Horde Minions which have recently begun attacking our cities + * - but to no avail. Our need is great!

+ * + * Your first task will be to assess the situation in the mountain pass, + * and help our troops defeat the Horde Minions there.

+ * + * Take the road marked with glowing runes, that starts just outside of this mansion. + * Before you go into battle, it would be prudent to + * review combat techniques as well as + * information on healing yourself, + * using your Paladin ability 'Close Wounds'.

+ * + * To aid you in your fight, you may also wish to + * purchase equipment from Frank the Blacksmith, + * who is standing just South of here.

+ * + * Good luck young Paladin! + */ return 1060388; } } @@ -73,7 +73,7 @@ namespace Server.Engines.Quests.Haven public class UzeraanReportConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1026153, 0x1822), // teleporter new QuestItemInfo(1048032, 0xE76) // a bag @@ -126,7 +126,7 @@ namespace Server.Engines.Quests.Haven public class SchmendrickConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1023637, 0xE34) // scroll }; @@ -169,7 +169,7 @@ namespace Server.Engines.Quests.Haven public class UzeraanScrollOfPowerConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1048030, 0x14EB), // a Treasure Map new QuestItemInfo(1023969, 0xF81), // Fertile Dirt @@ -198,7 +198,7 @@ namespace Server.Engines.Quests.Haven public class UzeraanFertileDirtConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1023965, 0xF7D), // Daemon Blood new QuestItemInfo(1022581, 0xA22) // lantern @@ -245,12 +245,12 @@ namespace Server.Engines.Quests.Haven public class UzeraanDaemonBloodConversation : QuestConversation { - private static QuestItemInfo[] m_Info = + private static readonly QuestItemInfo[] m_Info = { new QuestItemInfo(1017412, 0xF80) // Daemon Bone }; - private static QuestItemInfo[] m_InfoPaladin = + private static readonly QuestItemInfo[] m_InfoPaladin = { new QuestItemInfo(1017412, 0xF80), // Daemon Bone new QuestItemInfo(1060577, 0x1F14) // Recall Rune diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs index e1ee94569..2ea01a7ff 100644 --- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs +++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Items/Cannon.cs @@ -20,37 +20,37 @@ namespace Server.Engines.Quests.Haven switch (direction) { case CannonDirection.North: - { - AddComponent(new CannonComponent(0xE8D), 0, 0, 0); - AddComponent(new CannonComponent(0xE8C), 0, 1, 0); - AddComponent(new CannonComponent(0xE8B), 0, 2, 0); + { + AddComponent(new CannonComponent(0xE8D), 0, 0, 0); + AddComponent(new CannonComponent(0xE8C), 0, 1, 0); + AddComponent(new CannonComponent(0xE8B), 0, 2, 0); - break; - } + break; + } case CannonDirection.East: - { - AddComponent(new CannonComponent(0xE96), 0, 0, 0); - AddComponent(new CannonComponent(0xE95), -1, 0, 0); - AddComponent(new CannonComponent(0xE94), -2, 0, 0); + { + AddComponent(new CannonComponent(0xE96), 0, 0, 0); + AddComponent(new CannonComponent(0xE95), -1, 0, 0); + AddComponent(new CannonComponent(0xE94), -2, 0, 0); - break; - } + break; + } case CannonDirection.South: - { - AddComponent(new CannonComponent(0xE91), 0, 0, 0); - AddComponent(new CannonComponent(0xE92), 0, -1, 0); - AddComponent(new CannonComponent(0xE93), 0, -2, 0); + { + AddComponent(new CannonComponent(0xE91), 0, 0, 0); + AddComponent(new CannonComponent(0xE92), 0, -1, 0); + AddComponent(new CannonComponent(0xE93), 0, -2, 0); - break; - } + break; + } default: - { - AddComponent(new CannonComponent(0xE8E), 0, 0, 0); - AddComponent(new CannonComponent(0xE8F), 1, 0, 0); - AddComponent(new CannonComponent(0xE90), 2, 0, 0); + { + AddComponent(new CannonComponent(0xE8E), 0, 0, 0); + AddComponent(new CannonComponent(0xE8F), 1, 0, 0); + AddComponent(new CannonComponent(0xE90), 2, 0, 0); - break; - } + break; + } } } @@ -59,10 +59,10 @@ namespace Server.Engines.Quests.Haven } [CommandProperty(AccessLevel.GameMaster)] - public CannonDirection CannonDirection{ get; private set; } + public CannonDirection CannonDirection { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public MilitiaCanoneer Canoneer{ get; set; } + public MilitiaCanoneer Canoneer { get; set; } public override bool HandlesOnMovement => Canoneer?.Deleted == false && Canoneer.Active; @@ -97,10 +97,10 @@ namespace Server.Engines.Quests.Haven var canFire = CannonDirection switch { - CannonDirection.North => (m.X >= X - 7 && m.X <= X + 7 && m.Y == Y - 7 && oldLocation.Y < Y - 7), - CannonDirection.East => (m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X + 7 && oldLocation.X > X + 7), - CannonDirection.South => (m.X >= X - 7 && m.X <= X + 7 && m.Y == Y + 7 && oldLocation.Y > Y + 7), - _ => (m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X - 7 && oldLocation.X < X - 7) + CannonDirection.North => m.X >= X - 7 && m.X <= X + 7 && m.Y == Y - 7 && oldLocation.Y < Y - 7, + CannonDirection.East => m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X + 7 && oldLocation.X > X + 7, + CannonDirection.South => m.X >= X - 7 && m.X <= X + 7 && m.Y == Y + 7 && oldLocation.Y > Y + 7, + _ => m.Y >= Y - 7 && m.Y <= Y + 7 && m.X == X - 7 && oldLocation.X < X - 7 }; if (canFire && Canoneer.WillFire(this, m)) diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs index fd5c6ffe8..ec675b0a8 100644 --- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs +++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Dryad.cs @@ -144,9 +144,9 @@ namespace Server.Engines.Quests.Haven public class SBDryad : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs index f705414bd..14d9bcdb5 100644 --- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs +++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/MilitiaCanoneer.cs @@ -13,7 +13,7 @@ namespace Server.Engines.Quests.Haven } [CommandProperty(AccessLevel.GameMaster)] - public bool Active{ get; set; } + public bool Active { get; set; } public override void InitBody() { diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs index 3b09c5d73..681e0e824 100644 --- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs +++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Mobiles/Uzeraan.cs @@ -211,7 +211,7 @@ namespace Server.Engines.Quests.Haven } else { - player.SendLocalizedMessage(1114333); //You must be young to have this item recharged. + player.SendLocalizedMessage(1114333); // You must be young to have this item recharged. } return false; diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs index 8521db6e2..c55b1bf81 100644 --- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/Objectives.cs @@ -70,7 +70,7 @@ namespace Server.Engines.Quests.Haven public KillHordeMinionsObjective(KillHordeMinionsStep step) => Step = step; - public KillHordeMinionsStep Step{ get; private set; } + public KillHordeMinionsStep Step { get; private set; } public override object Message { @@ -168,24 +168,24 @@ namespace Server.Engines.Quests.Haven switch (Step) { case KillHordeMinionsStep.First: - { - QuestObjective obj = new KillHordeMinionsObjective(KillHordeMinionsStep.LearnKarma); - System.AddObjective(obj); - obj.CurProgress = CurProgress; - break; - } + { + QuestObjective obj = new KillHordeMinionsObjective(KillHordeMinionsStep.LearnKarma); + System.AddObjective(obj); + obj.CurProgress = CurProgress; + break; + } case KillHordeMinionsStep.LearnKarma: - { - QuestObjective obj = new KillHordeMinionsObjective(KillHordeMinionsStep.Others); - System.AddObjective(obj); - obj.CurProgress = CurProgress; - break; - } + { + QuestObjective obj = new KillHordeMinionsObjective(KillHordeMinionsStep.Others); + System.AddObjective(obj); + obj.CurProgress = CurProgress; + break; + } default: - { - System.AddObjective(new FindUzeraanAboutReportObjective()); - break; - } + { + System.AddObjective(new FindUzeraanAboutReportObjective()); + break; + } } else System.AddObjective(new FindUzeraanAboutReportObjective()); @@ -338,7 +338,7 @@ namespace Server.Engines.Quests.Haven public class GetDaemonBoneObjective : QuestObjective { - public Container CorpseWithBone{ get; set; } + public Container CorpseWithBone { get; set; } public override object Message { diff --git a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs index 5d554d9f5..3a25ccb9f 100644 --- a/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs +++ b/Projects/Scripts/Engines/Quests/Uzeraan Turmoil/UzeraanTurmoilQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Haven { public class UzeraanTurmoilQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(AcceptConversation), typeof(UzeraanTitheConversation), diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Conversations.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Conversations.cs index b591d6734..bbcc1b1f1 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Conversations.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Conversations.cs @@ -99,7 +99,7 @@ namespace Server.Engines.Quests.Hag public override void OnRead() { - System.AddObjective(new FindIngredientObjective(new Ingredient[0])); + System.AddObjective(new FindIngredientObjective(global::System.Array.Empty())); } } @@ -282,4 +282,4 @@ namespace Server.Engines.Quests.Hag public override bool Logged => false; } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Ingredient.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Ingredient.cs index 5589c845d..27ac5ffd1 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Ingredient.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Ingredient.cs @@ -24,7 +24,7 @@ namespace Server.Engines.Quests.Hag public class IngredientInfo { - private static IngredientInfo[] m_Table = + private static readonly IngredientInfo[] m_Table = { // sheep liver new IngredientInfo(1055020, 5, typeof(Sheep)), @@ -65,11 +65,11 @@ namespace Server.Engines.Quests.Hag Quantity = quantity; } - public int Name{ get; } + public int Name { get; } - public Type[] Creatures{ get; } + public Type[] Creatures { get; } - public int Quantity{ get; } + public int Quantity { get; } public static IngredientInfo Get(Ingredient ingredient) { diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagCauldron.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagCauldron.cs index afa3fbd7f..058d47fa5 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagCauldron.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagCauldron.cs @@ -7,10 +7,10 @@ namespace Server.Items { AddonComponent pot; pot = new AddonComponent(2420); - AddComponent(pot, 0, 0, 0); //pot w/ support + AddComponent(pot, 0, 0, 0); // pot w/ support AddonComponent fire; - fire = new AddonComponent(4012); //fire pit + fire = new AddonComponent(4012); // fire pit fire.Light = LightType.Circle150; AddComponent(fire, 0, 0, 0); } diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs index 2d1b00685..de5b43bc8 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HagStew.cs @@ -11,7 +11,7 @@ namespace Server.Items stew = new AddonComponent(2416); stew.Name = "stew"; stew.Visible = true; - AddComponent(stew, 0, 0, -7); //stew + AddComponent(stew, 0, 0, -7); // stew } public HagStew(Serial serial) : base(serial) @@ -28,7 +28,7 @@ namespace Server.Items { stew.Visible = false; - BreadLoaf hagstew = new BreadLoaf(); //this decides your fillrate + BreadLoaf hagstew = new BreadLoaf(); // this decides your fillrate hagstew.Eat(from); Timer m_timer = new ShowStew(stew); @@ -52,7 +52,7 @@ namespace Server.Items public class ShowStew : Timer { - private AddonComponent stew; + private readonly AddonComponent stew; public ShowStew(AddonComponent ac) : base(TimeSpan.FromSeconds(30)) { diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HangoverCure.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HangoverCure.cs index 255af1927..5fcff0340 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HangoverCure.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/HangoverCure.cs @@ -18,7 +18,7 @@ namespace Server.Engines.Quests.Hag public override int LabelNumber => 1055060; // Grizelda's Extra Strength Hangover Cure [CommandProperty(AccessLevel.GameMaster)] - public int Uses{ get; set; } + public int Uses { get; set; } public override void OnDoubleClick(Mobile from) { @@ -66,15 +66,15 @@ namespace Server.Engines.Quests.Hag switch (version) { case 1: - { - Uses = reader.ReadEncodedInt(); - break; - } + { + Uses = reader.ReadEncodedInt(); + break; + } case 0: - { - Uses = 20; - break; - } + { + Uses = 20; + break; + } } } } diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/MagicFlute.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/MagicFlute.cs index 6c95080f4..ec29a37b3 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/MagicFlute.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Items/MagicFlute.cs @@ -32,7 +32,7 @@ namespace Server.Engines.Quests.Hag FindZeefzorpulObjective obj = qs.FindObjective(); if (obj?.Completed == false) { - if (player.Map != Map.Trammel && player.Map != Map.Felucca || !player.InRange(obj.ImpLocation, 8)) + if ((player.Map != Map.Trammel && player.Map != Map.Felucca) || !player.InRange(obj.ImpLocation, 8)) { player.SendLocalizedMessage( 1055053); // Nothing happens. Zeefzorpul must not be hiding in this area. diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs index b525656fc..3b0ba89a4 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Mobiles/Grizelda.cs @@ -159,8 +159,7 @@ namespace Server.Engines.Quests.Hag { bool gainedPath = false; - if (VirtueHelper.Award(player, VirtueName.Sacrifice, 250, ref gainedPath) - ) // TODO: Check amount on OSI. + if (VirtueHelper.Award(player, VirtueName.Sacrifice, 250, ref gainedPath)) // TODO: Check amount on OSI. player.SendLocalizedMessage(1054160); // You have gained in sacrifice. PlaySound(0x253); diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs index ef8280c77..487db2a85 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/Objectives.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Quests.Hag { public class FindApprenticeObjective : QuestObjective { - private static Point3D[] m_CorpseLocations = + private static readonly Point3D[] m_CorpseLocations = { new Point3D(778, 1158, 0), new Point3D(698, 1443, 0), @@ -29,7 +29,7 @@ namespace Server.Engines.Quests.Hag public override object Message => 1055014; - public Corpse Corpse{ get; private set; } + public Corpse Corpse { get; private set; } private static Point3D RandomCorpseLocation() { @@ -43,7 +43,7 @@ namespace Server.Engines.Quests.Hag PlayerMobile player = System.From; Map map = player.Map; - if (Corpse?.Deleted == false || map != Map.Trammel && map != Map.Felucca || + if (Corpse?.Deleted == false || (map != Map.Trammel && map != Map.Felucca) || !player.InRange(m_CorpseLocation, 8)) return; @@ -85,15 +85,15 @@ namespace Server.Engines.Quests.Hag switch (version) { case 1: - { - m_CorpseLocation = reader.ReadPoint3D(); - goto case 0; - } + { + m_CorpseLocation = reader.ReadPoint3D(); + goto case 0; + } case 0: - { - Corpse = (Corpse)reader.ReadItem(); - break; - } + { + Corpse = (Corpse)reader.ReadItem(); + break; + } } if (version == 0) @@ -197,7 +197,7 @@ namespace Server.Engines.Quests.Hag public override object Message => 1055017; - public Point3D ImpLocation{ get; private set; } + public Point3D ImpLocation { get; private set; } public override void OnComplete() { @@ -322,11 +322,11 @@ namespace Server.Engines.Quests.Hag } } - public Ingredient[] Ingredients{ get; private set; } + public Ingredient[] Ingredients { get; private set; } public Ingredient Ingredient => Ingredients[Ingredients.Length - 1]; public int Step => Ingredients.Length; - public bool BlackheartMet{ get; private set; } + public bool BlackheartMet { get; private set; } public override void RenderProgress(BaseQuestGump gump) { diff --git a/Projects/Scripts/Engines/Quests/Witch Apprentice/WitchApprenticeQuest.cs b/Projects/Scripts/Engines/Quests/Witch Apprentice/WitchApprenticeQuest.cs index a6bef283e..899513be9 100644 --- a/Projects/Scripts/Engines/Quests/Witch Apprentice/WitchApprenticeQuest.cs +++ b/Projects/Scripts/Engines/Quests/Witch Apprentice/WitchApprenticeQuest.cs @@ -5,7 +5,7 @@ namespace Server.Engines.Quests.Hag { public class WitchApprenticeQuest : QuestSystem { - private static Type[] m_TypeReferenceTable = + private static readonly Type[] m_TypeReferenceTable = { typeof(FindApprenticeObjective), typeof(FindGrizeldaAboutMurderObjective), @@ -31,7 +31,7 @@ namespace Server.Engines.Quests.Hag typeof(RecentlyFinishedConversation) }; - private static Point3D[] m_ZeefzorpulLocations = + private static readonly Point3D[] m_ZeefzorpulLocations = { new Point3D(1226, 1573, 0), new Point3D(1929, 1148, 0), diff --git a/Projects/Scripts/Engines/Spawner/ProximitySpawner.cs b/Projects/Scripts/Engines/Spawner/ProximitySpawner.cs index d42f15f35..90aa6ba6c 100644 --- a/Projects/Scripts/Engines/Spawner/ProximitySpawner.cs +++ b/Projects/Scripts/Engines/Spawner/ProximitySpawner.cs @@ -52,13 +52,13 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.Developer)] - public int TriggerRange{ get; set; } + public int TriggerRange { get; set; } [CommandProperty(AccessLevel.Developer)] - public TextDefinition SpawnMessage{ get; set; } + public TextDefinition SpawnMessage { get; set; } [CommandProperty(AccessLevel.Developer)] - public bool InstantFlag{ get; set; } + public bool InstantFlag { get; set; } public override string DefaultName => "Proximity Spawner"; @@ -84,7 +84,7 @@ namespace Server.Mobiles if (m is BaseCreature bc && (bc.IsDeadBondedPet || !(bc.Controlled || bc.Summoned))) return false; - return m.AccessLevel == AccessLevel.Player && (m.Player || m.Alive && !m.Hidden && m.CanBeDamaged()); + return m.AccessLevel == AccessLevel.Player && (m.Player || (m.Alive && !m.Hidden && m.CanBeDamaged())); } public override void OnMovement(Mobile m, Point3D oldLocation) diff --git a/Projects/Scripts/Engines/Spawner/Spawner.cs b/Projects/Scripts/Engines/Spawner/Spawner.cs index 1c6fd374f..f947c6091 100644 --- a/Projects/Scripts/Engines/Spawner/Spawner.cs +++ b/Projects/Scripts/Engines/Spawner/Spawner.cs @@ -23,14 +23,14 @@ namespace Server.Mobiles private InternalTimer m_Timer; private int m_WalkingRange = -1; -// [Constructible] + // [Constructible] public Spawner(int amount, int minDelay, int maxDelay, int team, int homeRange, string spawnedNames) : base(0x1f13) { InitSpawn(amount, TimeSpan.FromMinutes(minDelay), TimeSpan.FromMinutes(maxDelay), team, homeRange); AddEntry(spawnedNames, 100, amount, false); } -// [Constructible] + // [Constructible] public Spawner(string spawnedName) : base(0x1f13) { InitSpawn(1, TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(10), 0, 4); @@ -58,11 +58,11 @@ namespace Server.Mobiles public override string DefaultName => "Spawner"; public bool IsFull => Spawned?.Count >= m_Count; public bool IsEmpty => Spawned?.Count == 0; - public DateTime End{ get; set; } + public DateTime End { get; set; } - public List Entries{ get; private set; } + public List Entries { get; private set; } - public Dictionary Spawned{ get; private set; } + public Dictionary Spawned { get; private set; } [CommandProperty(AccessLevel.Developer)] public int Count @@ -73,7 +73,7 @@ namespace Server.Mobiles m_Count = value; if (m_Timer != null) - if (!IsFull && !m_Timer.Running || IsFull && m_Timer.Running) + if ((!IsFull && !m_Timer.Running) || (IsFull && m_Timer.Running)) DoTimer(); InvalidateProperties(); @@ -81,7 +81,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.Developer)] - public WayPoint WayPoint{ get; set; } + public virtual WayPoint WayPoint { get; set; } [CommandProperty(AccessLevel.Developer)] public bool Running @@ -326,7 +326,7 @@ namespace Server.Mobiles for (int i = 0; i < m_Count; i++) Spawn(); - DoTimer(); //Turn off the timer! + DoTimer(); // Turn off the timer! } public virtual void Spawn() @@ -415,7 +415,7 @@ namespace Server.Mobiles return null; CPA attr = Properties.GetCPA(thisProp); - if (attr == null || AccessLevel.Developer < attr.WriteLevel || !thisProp.CanWrite || attr.ReadOnly) + if (attr == null || attr.WriteLevel > AccessLevel.Developer || !thisProp.CanWrite || attr.ReadOnly) return null; realProps[i] = thisProp; } @@ -440,8 +440,8 @@ namespace Server.Mobiles if (map == null || map == Map.Internal || Parent != null) return false; - //Defrag taken care of in Spawn(), beforehand - //Count check taken care of in Spawn(), beforehand + // Defrag taken care of in Spawn(), beforehand + // Count check taken care of in Spawn(), beforehand Type type = SpawnerType.GetType(entry.SpawnedName); @@ -454,7 +454,7 @@ namespace Server.Mobiles string[] propargs; if (string.IsNullOrEmpty(entry.Properties)) - propargs = new string[0]; + propargs = Array.Empty(); else propargs = CommandSystem.Split(entry.Properties.Trim()); @@ -469,7 +469,7 @@ namespace Server.Mobiles } if (string.IsNullOrEmpty(entry.Parameters)) - paramargs = new string[0]; + paramargs = Array.Empty(); else paramargs = entry.Parameters.Trim().Split(' '); @@ -542,7 +542,7 @@ namespace Server.Mobiles int walkrange = GetWalkingRange(); c.RangeHome = walkrange >= 0 ? walkrange : m_HomeRange; - c.CurrentWayPoint = GetWayPoint(); + c.CurrentWayPoint = WayPoint; if (m_Team > 0) c.Team = m_Team; @@ -591,8 +591,6 @@ namespace Server.Mobiles public virtual int GetWalkingRange() => m_WalkingRange; - public virtual WayPoint GetWayPoint() => WayPoint; - public virtual Point3D GetSpawnPosition(ISpawnable spawned, Map map) { if (map == null || map == Map.Internal) @@ -717,7 +715,7 @@ namespace Server.Mobiles InvalidateProperties(); } - public void RemoveSpawn(int index) //Entry + public void RemoveSpawn(int index) // Entry { if (index >= 0 && index < Entries.Count) RemoveSpawn(Entries[index]); @@ -823,126 +821,126 @@ namespace Server.Mobiles switch (version) { case 7: - { - int size = reader.ReadInt(); + { + int size = reader.ReadInt(); - Entries = new List(size); + Entries = new List(size); - for (int i = 0; i < size; ++i) - Entries.Add(new SpawnerEntry(this, reader)); + for (int i = 0; i < size; ++i) + Entries.Add(new SpawnerEntry(this, reader)); - goto case 4; //Skip the other crap - } + goto case 4; // Skip the other crap + } case 6: - { - int size = reader.ReadInt(); - - bool addentries = Entries.Count == 0; - - for (int i = 0; i < size; ++i) - if (addentries) - Entries.Add(new SpawnerEntry(string.Empty, 100, reader.ReadInt())); - else - Entries[i].SpawnedMaxCount = reader.ReadInt(); - - goto case 5; - } - case 5: - { - int size = reader.ReadInt(); - - bool addentries = Entries.Count == 0; - - for (int i = 0; i < size; ++i) - if (addentries) - Entries.Add(new SpawnerEntry(string.Empty, reader.ReadInt(), 1)); - else - Entries[i].SpawnedProbability = reader.ReadInt(); - - goto case 4; - } - case 4: - { - m_WalkingRange = reader.ReadInt(); - - goto case 3; - } - case 3: - case 2: - { - WayPoint = reader.ReadItem() as WayPoint; - - goto case 1; - } - - case 1: - { - m_Group = reader.ReadBool(); - - goto case 0; - } - - case 0: - { - m_MinDelay = reader.ReadTimeSpan(); - m_MaxDelay = reader.ReadTimeSpan(); - m_Count = reader.ReadInt(); - m_Team = reader.ReadInt(); - m_HomeRange = reader.ReadInt(); - m_Running = reader.ReadBool(); - - TimeSpan ts = TimeSpan.Zero; - - if (m_Running) - ts = reader.ReadDeltaTime() - DateTime.UtcNow; - - if (version < 7) { int size = reader.ReadInt(); bool addentries = Entries.Count == 0; for (int i = 0; i < size; ++i) - { - string typeName = reader.ReadString(); - if (addentries) - Entries.Add(new SpawnerEntry(typeName, 100, 1)); + Entries.Add(new SpawnerEntry(string.Empty, 100, reader.ReadInt())); else - Entries[i].SpawnedName = typeName; + Entries[i].SpawnedMaxCount = reader.ReadInt(); - if (SpawnerType.GetType(typeName) == null) - { - m_WarnTimer ??= new WarnTimer(); + goto case 5; + } + case 5: + { + int size = reader.ReadInt(); - m_WarnTimer.Add(Location, Map, typeName); - } - } + bool addentries = Entries.Count == 0; - int count = reader.ReadInt(); + for (int i = 0; i < size; ++i) + if (addentries) + Entries.Add(new SpawnerEntry(string.Empty, reader.ReadInt(), 1)); + else + Entries[i].SpawnedProbability = reader.ReadInt(); - for (int i = 0; i < count; ++i) - if (reader.ReadEntity() is ISpawnable e) - { - if (e is BaseCreature creature) - creature.RemoveIfUntamed = true; + goto case 4; + } + case 4: + { + m_WalkingRange = reader.ReadInt(); - e.Spawner = this; + goto case 3; + } + case 3: + case 2: + { + WayPoint = reader.ReadItem() as WayPoint; - for (int j = 0; j < Entries.Count; j++) - if (SpawnerType.GetType(Entries[j].SpawnedName) == e.GetType()) - { - Entries[j].Spawned.Add(e); - Spawned.Add(e, Entries[j]); - break; - } - } + goto case 1; } - DoTimer(ts); + case 1: + { + m_Group = reader.ReadBool(); - break; - } + goto case 0; + } + + case 0: + { + m_MinDelay = reader.ReadTimeSpan(); + m_MaxDelay = reader.ReadTimeSpan(); + m_Count = reader.ReadInt(); + m_Team = reader.ReadInt(); + m_HomeRange = reader.ReadInt(); + m_Running = reader.ReadBool(); + + TimeSpan ts = TimeSpan.Zero; + + if (m_Running) + ts = reader.ReadDeltaTime() - DateTime.UtcNow; + + if (version < 7) + { + int size = reader.ReadInt(); + + bool addentries = Entries.Count == 0; + + for (int i = 0; i < size; ++i) + { + string typeName = reader.ReadString(); + + if (addentries) + Entries.Add(new SpawnerEntry(typeName, 100, 1)); + else + Entries[i].SpawnedName = typeName; + + if (SpawnerType.GetType(typeName) == null) + { + m_WarnTimer ??= new WarnTimer(); + + m_WarnTimer.Add(Location, Map, typeName); + } + } + + int count = reader.ReadInt(); + + for (int i = 0; i < count; ++i) + if (reader.ReadEntity() is ISpawnable e) + { + if (e is BaseCreature creature) + creature.RemoveIfUntamed = true; + + e.Spawner = this; + + for (int j = 0; j < Entries.Count; j++) + if (SpawnerType.GetType(Entries[j].SpawnedName) == e.GetType()) + { + Entries[j].Spawned.Add(e); + Spawned.Add(e, Entries[j]); + break; + } + } + } + + DoTimer(ts); + + break; + } } if (version < 4) @@ -970,7 +968,7 @@ namespace Server.Mobiles private class InternalTimer : Timer { - private Spawner m_Spawner; + private readonly Spawner m_Spawner; public InternalTimer(Spawner spawner, TimeSpan delay) : base(delay) { @@ -992,7 +990,7 @@ namespace Server.Mobiles private class WarnTimer : Timer { - private List m_List; + private readonly List m_List; public WarnTimer() : base(TimeSpan.FromSeconds(1.0)) { @@ -1031,8 +1029,8 @@ namespace Server.Mobiles private class WarnEntry { - public Map m_Map; - public string m_Name; + public readonly Map m_Map; + public readonly string m_Name; public Point3D m_Point; public WarnEntry(Point3D p, Map map, string name) @@ -1081,7 +1079,7 @@ namespace Server.Mobiles Spawned = new List(count); for (int i = 0; i < count; ++i) - //IEntity e = World.FindEntity( reader.ReadInt() ); + // IEntity e = World.FindEntity( reader.ReadInt() ); if (reader.ReadEntity() is ISpawnable e) { @@ -1097,19 +1095,19 @@ namespace Server.Mobiles } } - public int SpawnedProbability{ get; set; } + public int SpawnedProbability { get; set; } - public int SpawnedMaxCount{ get; set; } + public int SpawnedMaxCount { get; set; } - public string SpawnedName{ get; set; } + public string SpawnedName { get; set; } - public string Properties{ get; set; } + public string Properties { get; set; } - public string Parameters{ get; set; } + public string Parameters { get; set; } - public EntryFlags Valid{ get; set; } + public EntryFlags Valid { get; set; } - public List Spawned{ get; } + public List Spawned { get; } public bool IsFull => Spawned.Count >= SpawnedMaxCount; @@ -1162,16 +1160,16 @@ namespace Server.Mobiles { if (c.Controlled || c.IsStabled) remove = true; -/* - else if ( c.Combatant == null && ( c.GetDistanceToSqrt( Location ) > (c.RangeHome * 4) ) ) - { - //m_Spawned[i].Delete(); - m_Spawned.RemoveAt( i ); - --i; - c.Delete(); - remove = true; - } -*/ + /* + else if (c.Combatant == null && ( c.GetDistanceToSqrt( Location ) > (c.RangeHome * 4) )) + { + //m_Spawned[i].Delete(); + m_Spawned.RemoveAt( i ); + --i; + c.Delete(); + remove = true; + } + */ } else if (m.Spawner == null) { diff --git a/Projects/Scripts/Engines/Spawner/SpawnerGump.cs b/Projects/Scripts/Engines/Spawner/SpawnerGump.cs index 7be5f298d..e673d7ba7 100644 --- a/Projects/Scripts/Engines/Spawner/SpawnerGump.cs +++ b/Projects/Scripts/Engines/Spawner/SpawnerGump.cs @@ -9,7 +9,7 @@ namespace Server.Mobiles { private SpawnerEntry m_Entry; private int m_Page; - private Spawner m_Spawner; + private readonly Spawner m_Spawner; public SpawnerGump(Spawner spawner, SpawnerEntry focusentry = null, int page = 0) : base(50, 50) { @@ -25,7 +25,7 @@ namespace Server.Mobiles AddHtml(245, 1, 250, 20, "#"); AddHtml(282, 1, 250, 20, "Prb"); - //AddLabel( 95, 1, 0, "Creatures List" ); + // AddLabel( 95, 1, 0, "Creatures List" ); int offset = 0; @@ -41,21 +41,21 @@ namespace Server.Mobiles if (entry == null || m_Entry != entry) AddButton(5, 22 * i + 21 + offset, entry != null ? 0xFBA : 0xFA5, entry != null ? 0xFBC : 0xFA7, - GetButtonID(2, i * 2)); //Expand + GetButtonID(2, i * 2)); // Expand else AddButton(5, 22 * i + 21 + offset, 0xFBB, 0xFBC, - GetButtonID(2, i * 2)); //Unexpand + GetButtonID(2, i * 2)); // Unexpand - AddButton(38, 22 * i + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + i * 2)); //Delete + AddButton(38, 22 * i + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + i * 2)); // Delete - AddImageTiled(71, 22 * i + 20 + offset, 161, 23, 0xA40); //creature text box - AddImageTiled(72, 22 * i + 21 + offset, 159, 21, 0xBBC); //creature text box + AddImageTiled(71, 22 * i + 20 + offset, 161, 23, 0xA40); // creature text box + AddImageTiled(72, 22 * i + 21 + offset, 159, 21, 0xBBC); // creature text box - AddImageTiled(235, 22 * i + 20 + offset, 35, 23, 0xA40); //maxcount text box - AddImageTiled(236, 22 * i + 21 + offset, 33, 21, 0xBBC); //maxcount text box + AddImageTiled(235, 22 * i + 20 + offset, 35, 23, 0xA40); // maxcount text box + AddImageTiled(236, 22 * i + 21 + offset, 33, 21, 0xBBC); // maxcount text box - AddImageTiled(273, 22 * i + 20 + offset, 35, 23, 0xA40); //probability text box - AddImageTiled(274, 22 * i + 21 + offset, 33, 21, 0xBBC); //probability text box + AddImageTiled(273, 22 * i + 20 + offset, 35, 23, 0xA40); // probability text box + AddImageTiled(274, 22 * i + 21 + offset, 33, 21, 0xBBC); // probability text box string name = ""; string probability = ""; @@ -73,24 +73,24 @@ namespace Server.Mobiles } AddTextEntry(75, 22 * i + 21 + offset, 156, 21, (flags & EntryFlags.InvalidType) != 0 ? 33 : 0, textindex, - name); //creature - AddTextEntry(239, 22 * i + 21 + offset, 30, 21, 0, textindex + 1, maxcount); //max count - AddTextEntry(277, 22 * i + 21 + offset, 30, 21, 0, textindex + 2, probability); //probability + name); // creature + AddTextEntry(239, 22 * i + 21 + offset, 30, 21, 0, textindex + 1, maxcount); // max count + AddTextEntry(277, 22 * i + 21 + offset, 30, 21, 0, textindex + 2, probability); // probability if (entry != null && m_Entry == entry) { AddLabel(5, 22 * i + 42, 0x384, "Params"); - AddImageTiled(55, 22 * i + 42, 253, 23, 0xA40); //Parameters - AddImageTiled(56, 22 * i + 43, 251, 21, 0xBBC); //Parameters + AddImageTiled(55, 22 * i + 42, 253, 23, 0xA40); // Parameters + AddImageTiled(56, 22 * i + 43, 251, 21, 0xBBC); // Parameters AddLabel(5, 22 * i + 64, 0x384, "Props"); - AddImageTiled(55, 22 * i + 64, 253, 23, 0xA40); //Properties - AddImageTiled(56, 22 * i + 65, 251, 21, 0xBBC); //Properties + AddImageTiled(55, 22 * i + 64, 253, 23, 0xA40); // Properties + AddImageTiled(56, 22 * i + 65, 251, 21, 0xBBC); // Properties AddTextEntry(59, 22 * i + 42, 248, 21, (flags & EntryFlags.InvalidParams) != 0 ? 33 : 0, textindex + 3, - entry.Parameters); //parameters + entry.Parameters); // parameters AddTextEntry(59, 22 * i + 62, 248, 21, (flags & EntryFlags.InvalidProps) != 0 ? 33 : 0, textindex + 4, - entry.Properties); //properties + entry.Properties); // properties offset += 44; } @@ -218,73 +218,73 @@ namespace Server.Mobiles switch (type) { - case 0: //Cancel + case 0: // Cancel return; case 1: - { - switch (index) { - case 0: + switch (index) { - if (m_Spawner.Entries != null && m_Page > 0) - { - m_Page--; - m_Entry = null; - } + case 0: + { + if (m_Spawner.Entries != null && m_Page > 0) + { + m_Page--; + m_Entry = null; + } - break; - } - case 1: - { - if ((m_Page + 1) * 13 <= m_Spawner.Entries?.Count) - { - m_Page++; - m_Entry = null; - } + break; + } + case 1: + { + if ((m_Page + 1) * 13 <= m_Spawner.Entries?.Count) + { + m_Page++; + m_Entry = null; + } - break; - } - case 2: //Okay - { - CreateArray(info, state.Mobile, m_Spawner); - return; - } - case 3: - { - m_Spawner.BringToHome(); - break; - } - case 4: // Complete respawn - { - m_Spawner.Respawn(); - break; - } - case 5: - { - CreateArray(info, state.Mobile, m_Spawner); - break; + break; + } + case 2: // Okay + { + CreateArray(info, state.Mobile, m_Spawner); + return; + } + case 3: + { + m_Spawner.BringToHome(); + break; + } + case 4: // Complete respawn + { + m_Spawner.Respawn(); + break; + } + case 5: + { + CreateArray(info, state.Mobile, m_Spawner); + break; + } } + + break; } - - break; - } case 2: - { - int entryindex = index / 2 + m_Page * 13; - int buttontype = index % 2; - - if (entryindex >= 0 && entryindex < m_Spawner.Entries.Count) { - SpawnerEntry entry = m_Spawner.Entries[entryindex]; - if (buttontype == 0) // Spawn creature - m_Entry = m_Entry != entry ? entry : null; - else // Remove creatures - m_Spawner.RemoveSpawn(entryindex); - } + int entryindex = index / 2 + m_Page * 13; + int buttontype = index % 2; - CreateArray(info, state.Mobile, m_Spawner); - break; - } + if (entryindex >= 0 && entryindex < m_Spawner.Entries.Count) + { + SpawnerEntry entry = m_Spawner.Entries[entryindex]; + if (buttontype == 0) // Spawn creature + m_Entry = m_Entry != entry ? entry : null; + else // Remove creatures + m_Spawner.RemoveSpawn(entryindex); + } + + CreateArray(info, state.Mobile, m_Spawner); + break; + } } if (m_Entry != null && m_Spawner.Entries?.Contains(m_Entry) == true) diff --git a/Projects/Scripts/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs b/Projects/Scripts/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs index c3daa8dde..a341529af 100644 --- a/Projects/Scripts/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs +++ b/Projects/Scripts/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs @@ -7,7 +7,7 @@ namespace Server.Items { public abstract class BasePigmentsOfTokuno : Item, IUsesRemaining { - private static Type[] m_Glasses = + private static readonly Type[] m_Glasses = { typeof(MaritimeGlasses), typeof(WizardsGlasses), @@ -23,7 +23,7 @@ namespace Server.Items typeof(AnthropomorphistGlasses) }; - private static Type[] m_Replicas = + private static readonly Type[] m_Replicas = { typeof(ANecromancerShroud), typeof(BraveKnightOfTheBritannia), @@ -50,7 +50,7 @@ namespace Server.Items typeof(Subdue) }; - private static Type[] m_DyableHeritageItems = + private static readonly Type[] m_DyableHeritageItems = { typeof(ChargerOfTheFallen), typeof(SamuraiHelm), @@ -91,13 +91,9 @@ namespace Server.Items } } - #region Old Item Serialization Vars - /* DO NOT USE! Only used in serialization of pigments that originally derived from Item */ - protected bool InheritsItem{ get; private set; } - - #endregion + protected bool InheritsItem { get; private set; } public override void GetProperties(ObjectPropertyList list) { @@ -124,8 +120,7 @@ namespace Server.Items private void InternalCallback(Mobile from, object targeted) { - - if (Deleted || UsesRemaining <= 0 || !from.InRange(GetWorldLocation(), 3) || +if (Deleted || UsesRemaining <= 0 || !from.InRange(GetWorldLocation(), 3) || !IsAccessibleTo(from)) return; @@ -169,7 +164,7 @@ namespace Server.Items } else { - //Notes: on OSI there IS no hue check to see if it's already hued. and no messages on successful hue either + // Notes: on OSI there IS no hue check to see if it's already hued. and no messages on successful hue either i.Hue = Hue; if (--UsesRemaining <= 0) @@ -242,30 +237,28 @@ namespace Server.Items switch (version) { case 1: - { - m_UsesRemaining = reader.ReadEncodedInt(); - break; - } + { + m_UsesRemaining = reader.ReadEncodedInt(); + break; + } case 0: // Old pigments that inherited from item - { - InheritsItem = true; + { + InheritsItem = true; - if (this is LesserPigmentsOfTokuno) - ((LesserPigmentsOfTokuno)this).Type = (LesserPigmentType)reader.ReadEncodedInt(); - else if (this is PigmentsOfTokuno) - ((PigmentsOfTokuno)this).Type = (PigmentType)reader.ReadEncodedInt(); - else if (this is MetalPigmentsOfTokuno) - reader.ReadEncodedInt(); + if (this is LesserPigmentsOfTokuno) + ((LesserPigmentsOfTokuno)this).Type = (LesserPigmentType)reader.ReadEncodedInt(); + else if (this is PigmentsOfTokuno) + ((PigmentsOfTokuno)this).Type = (PigmentType)reader.ReadEncodedInt(); + else if (this is MetalPigmentsOfTokuno) + reader.ReadEncodedInt(); - m_UsesRemaining = reader.ReadEncodedInt(); + m_UsesRemaining = reader.ReadEncodedInt(); - break; - } + break; + } } } - #region IUsesRemaining Members - [CommandProperty(AccessLevel.GameMaster)] public int UsesRemaining { @@ -282,7 +275,5 @@ namespace Server.Items get => true; set { } } - - #endregion } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs b/Projects/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs index feb3fef7d..ce0a82bf7 100644 --- a/Projects/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs +++ b/Projects/Scripts/Engines/Treasures of Tokuno/GreaterArtifacts.cs @@ -330,7 +330,6 @@ namespace Server.Items Attributes.DefendChance = 10; } - public WindsEdge(Serial serial) : base(serial) { } @@ -388,7 +387,7 @@ namespace Server.Items public class PigmentsOfTokuno : BasePigmentsOfTokuno { - private static int[][] m_Table = + private static readonly int[][] m_Table = { // Hue, Label new[] diff --git a/Projects/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs b/Projects/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs index 254cfbe38..2df7b98f1 100644 --- a/Projects/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs +++ b/Projects/Scripts/Engines/Treasures of Tokuno/LesserArtifacts.cs @@ -292,7 +292,6 @@ namespace Server.Items Attributes.WeaponSpeed = 20; } - public Exiler(Serial serial) : base(serial) { } @@ -622,7 +621,7 @@ namespace Server.Items } } - //Non weapon/armor ones: + // Non weapon/armor ones: public class AncientUrn : Item { @@ -644,7 +643,7 @@ namespace Server.Items { } - public static string[] Names{ get; } = + public static string[] Names { get; } = { "Akira", "Avaniaga", @@ -870,7 +869,7 @@ namespace Server.Items public FluteOfRenewal() { Slayer = SlayerGroup.Groups[Utility.Random(SlayerGroup.Groups.Length - 1)].Super - .Name; //-1 to exclude Fey slayer. Try to confrim no fey slayer on this on OSI + .Name; // -1 to exclude Fey slayer. Try to confrim no fey slayer on this on OSI ReplenishesCharges = true; } @@ -919,7 +918,7 @@ namespace Server.Items public class LesserPigmentsOfTokuno : BasePigmentsOfTokuno { - private static int[][] m_Table = + private static readonly int[][] m_Table = { // Hue, Label new[] diff --git a/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs b/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs index 90bcaed6c..01c9b87cc 100644 --- a/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs +++ b/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs @@ -24,7 +24,7 @@ namespace Server.Misc { public const int ItemsPerReward = 10; - private static Type[][] m_LesserArtifacts = + private static readonly Type[][] m_LesserArtifacts = { // ToT One Rewards new[] @@ -68,7 +68,7 @@ namespace Server.Misc private static Type[][] m_GreaterArtifacts; - public static Type[] LesserArtifactsTotal{ get; } = + public static Type[] LesserArtifactsTotal { get; } = { typeof(AncientFarmersKasa), typeof(AncientSamuraiDo), typeof(ArmsOfTacticalExcellence), typeof(BlackLotusHood), typeof(DaimyosHelm), typeof(DemonForks), typeof(DragonNunchaku), typeof(Exiler), typeof(GlovesOfTheSun), @@ -80,9 +80,9 @@ namespace Server.Misc typeof(ChestOfHeirlooms) }; - public static TreasuresOfTokunoEra DropEra{ get; set; } = TreasuresOfTokunoEra.None; + public static TreasuresOfTokunoEra DropEra { get; set; } = TreasuresOfTokunoEra.None; - public static TreasuresOfTokunoEra RewardEra{ get; set; } = TreasuresOfTokunoEra.ToTOne; + public static TreasuresOfTokunoEra RewardEra { get; set; } = TreasuresOfTokunoEra.ToTOne; public static Type[] LesserArtifacts => m_LesserArtifacts[(int)RewardEra - 1]; @@ -113,7 +113,7 @@ namespace Server.Misc if (r.IsPartOf() || BaseBoat.FindBoatAt(m, m.Map) != null) return false; - //TODO: a CanReach of something check as opposed to above? + // TODO: a CanReach of something check as opposed to above? if (r.IsPartOf("Yomotsu Mines") || r.IsPartOf("Fan Dancer's Dojo")) return true; @@ -130,19 +130,19 @@ namespace Server.Misc if (bc.Controlled || bc.Owners.Count > 0 || bc.Fame <= 0) return; - //25000 for 1/100 chance, 10 hyrus - //1500, 1/1000 chance, 20 lizard men for that chance. + // 25000 for 1/100 chance, 10 hyrus + // 1500, 1/1000 chance, 20 lizard men for that chance. pm.ToTTotalMonsterFame += (int)(bc.Fame * (1 + Math.Sqrt(pm.Luck) / 100)); - //This is the Exponentional regression with only 2 datapoints. - //A log. func would also work, but it didn't make as much sense. - //This function isn't OSI exact being that I don't know OSI's func they used ;p + // This is the Exponentional regression with only 2 datapoints. + // A log. func would also work, but it didn't make as much sense. + // This function isn't OSI exact being that I don't know OSI's func they used ;p int x = pm.ToTTotalMonsterFame; - //const double A = 8.63316841 * Math.Pow( 10, -4 ); + // const double A = 8.63316841 * Math.Pow( 10, -4 ); const double A = 0.000863316841; - //const double B = 4.25531915 * Math.Pow( 10, -6 ); + // const double B = 4.25531915 * Math.Pow( 10, -6 ); const double B = 0.00000425531915; double chance = A * Math.Pow(10, B * x); @@ -260,7 +260,7 @@ namespace Server.Mobiles SayTo(pm, 1070980); // Congratulations! You have turned in enough minor treasures to earn a greater reward. - pm.CloseGump(); //Sanity + pm.CloseGump(); // Sanity if (!pm.HasGump()) pm.SendGump(new ToTRedeemGump(this, false)); @@ -305,15 +305,14 @@ namespace Server.Gumps i.Name == null || i.Name.Length <= 0 ? (TextDefinition)i.LabelNumber : (TextDefinition)i.Name) => Item = i; - public Item Item{ get; set; } + public Item Item { get; set; } } public class ToTTurnInGump : BaseImageTileButtonsGump { - private Mobile m_Collector; + private readonly Mobile m_Collector; - public ToTTurnInGump(Mobile collector, List buttons) : - base(1071012, Utility.CastListContravariant(buttons)) // Click a minor artifact to give it to Ihara Soko. + public ToTTurnInGump(Mobile collector, List buttons) : base(1071012, Utility.CastListContravariant(buttons)) // Click a minor artifact to give it to Ihara Soko. => m_Collector = collector; @@ -361,7 +360,7 @@ namespace Server.Gumps m_Collector.SayTo(pm, 1070980); // Congratulations! You have turned in enough minor treasures to earn a greater reward. - pm.CloseGump(); //Sanity + pm.CloseGump(); // Sanity if (!pm.HasGump()) pm.SendGump(new ToTRedeemGump(m_Collector, false)); @@ -373,7 +372,7 @@ namespace Server.Gumps List buttons = FindRedeemableItems(pm); - pm.CloseGump(); //Sanity + pm.CloseGump(); // Sanity if (buttons.Count > 0) pm.SendGump(new ToTTurnInGump(m_Collector, buttons)); @@ -388,30 +387,25 @@ namespace Server.Gumps if (pm.ToTItemsTurnedIn == 0) m_Collector.SayTo(pm, 1071013); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item. - else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward - ) //This case should ALWAYS be true with this gump, jsut a sanity check + else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward) // This case should ALWAYS be true with this gump, jsut a sanity check m_Collector.SayTo(pm, 1070981, $"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward. else m_Collector.SayTo(pm, 1070982); // When you wish to choose your reward, you have but to approach me again. } } -} -namespace Server.Gumps -{ public class ToTRedeemGump : BaseImageTileButtonsGump { - private Mobile m_Collector; + private readonly Mobile m_Collector; public ToTRedeemGump(Mobile collector, bool pigments) : base(pigments ? 1070986 : 1070985, pigments ? PigmentRewards[(int)TreasuresOfTokuno.RewardEra - 1].ToArray() - : NormalRewards[(int)TreasuresOfTokuno.RewardEra - 1].ToArray() - ) => + : NormalRewards[(int)TreasuresOfTokuno.RewardEra - 1].ToArray()) => m_Collector = collector; - public static TypeTileButtonInfo[][] NormalRewards{ get; } = + public static TypeTileButtonInfo[][] NormalRewards { get; } = { // ToT One Rewards new[] @@ -456,7 +450,7 @@ namespace Server.Gumps } }; - public static PigmentsTileButtonInfo[][] PigmentRewards{ get; } = + public static PigmentsTileButtonInfo[][] PigmentRewards { get; } = { // ToT One Pigment Rewards new[] @@ -517,9 +511,9 @@ namespace Server.Gumps { TypeTileButtonInfo t = (TypeTileButtonInfo)buttonInfo; - if (t.Type == typeof(PigmentsOfTokuno)) //Special case of course. + if (t.Type == typeof(PigmentsOfTokuno)) // Special case of course. { - pm.CloseGump(); //Sanity + pm.CloseGump(); // Sanity pm.CloseGump(); pm.SendGump(new ToTRedeemGump(m_Collector, true)); @@ -538,7 +532,7 @@ namespace Server.Gumps } if (item == null) - return; //Sanity + return; // Sanity if (pm.AddToBackpack(item)) { @@ -556,7 +550,6 @@ namespace Server.Gumps } } - public override void HandleCancel(NetState sender) { if (!(sender.Mobile is PlayerMobile pm) || !pm.InRange(m_Collector.Location, 7)) @@ -565,8 +558,7 @@ namespace Server.Gumps if (pm.ToTItemsTurnedIn == 0) m_Collector.SayTo(pm, 1071013); // Bring me 10 of the lost treasures of Tokuno and I will reward you with a valuable item. - else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward - ) //This and above case should ALWAYS be FALSE with this gump, jsut a sanity check + else if (pm.ToTItemsTurnedIn < TreasuresOfTokuno.ItemsPerReward) // This and above case should ALWAYS be FALSE with this gump, jsut a sanity check m_Collector.SayTo(pm, 1070981, $"{pm.ToTItemsTurnedIn}\t{TreasuresOfTokuno.ItemsPerReward}"); // You have turned in ~1_COUNT~ minor artifacts. Turn in ~2_NUM~ to receive a reward. else @@ -584,7 +576,7 @@ namespace Server.Gumps itemID, hue, label, localizedToolTip) => Type = type; - public Type Type{ get; } + public Type Type { get; } } public class PigmentsTileButtonInfo : ImageTileButtonInfo @@ -593,16 +585,8 @@ namespace Server.Gumps PigmentsOfTokuno.GetInfo(p)[1]) => Pigment = p; - public PigmentType Pigment{ get; set; } + public PigmentType Pigment { get; set; } } - - #region ToT Normal Rewards Table - - #endregion - - #region ToT Pigment Rewards Table - - #endregion } } diff --git a/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs b/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs index 425d9d931..368c0bc3c 100644 --- a/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs +++ b/Projects/Scripts/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs @@ -14,7 +14,7 @@ namespace Server.Misc public TreasuresOfTokunoPersistance(Serial serial) : base(serial) => Instance = this; - public static TreasuresOfTokunoPersistance Instance{ get; private set; } + public static TreasuresOfTokunoPersistance Instance { get; private set; } public override string DefaultName => "TreasuresOfTokuno Persistance - Internal"; @@ -43,12 +43,12 @@ namespace Server.Misc switch (version) { case 0: - { - TreasuresOfTokuno.RewardEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt(); - TreasuresOfTokuno.DropEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt(); + { + TreasuresOfTokuno.RewardEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt(); + TreasuresOfTokuno.DropEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt(); - break; - } + break; + } } } diff --git a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs index b5c08596f..c73f9eb56 100644 --- a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs +++ b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/CharacterStatue.cs @@ -115,12 +115,12 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public DateTime SculptedOn{ get; set; } + public DateTime SculptedOn { get; set; } - public CharacterStatuePlinth Plinth{ get; set; } + public CharacterStatuePlinth Plinth { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnDoubleClick(Mobile from) { @@ -385,7 +385,7 @@ namespace Server.Mobiles private class DemolishEntry : ContextMenuEntry { - private CharacterStatue m_Statue; + private readonly CharacterStatue m_Statue; public DemolishEntry(CharacterStatue statue) : base(6275, 2) => m_Statue = statue; @@ -442,7 +442,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public CharacterStatue Statue{ get; set; } + public CharacterStatue Statue { get; set; } [CommandProperty(AccessLevel.GameMaster)] public StatueType StatueType @@ -547,8 +547,8 @@ namespace Server.Mobiles public class CharacterStatueTarget : Target { - private Item m_Maker; - private StatueType m_Type; + private readonly Item m_Maker; + private readonly StatueType m_Type; public CharacterStatueTarget(Item maker, StatueType type) : base(-1, true, TargetFlags.None) { @@ -651,7 +651,7 @@ namespace Server.Mobiles int doorHeight = door.ItemData.CalcHeight; if (Utility.InRange(doorLoc, p, 1) && - (p.Z == doorLoc.Z || p.Z + height > doorLoc.Z && doorLoc.Z + doorHeight > p.Z)) + (p.Z == doorLoc.Z || (p.Z + height > doorLoc.Z && doorLoc.Z + doorHeight > p.Z))) return AddonFitResult.DoorTooClose; } diff --git a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs index 48e429d14..ae6011e85 100644 --- a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs +++ b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Gumps/CharacterStatueGump.cs @@ -5,9 +5,9 @@ namespace Server.Gumps { public class CharacterStatueGump : Gump { - private Item m_Maker; - private Mobile m_Owner; - private CharacterStatue m_Statue; + private readonly Item m_Maker; + private readonly Mobile m_Owner; + private readonly CharacterStatue m_Statue; public CharacterStatueGump(Item maker, CharacterStatue statue, Mobile owner) : base(60, 36) { diff --git a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Packets.cs b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Packets.cs index b13fd47b9..a21a75c77 100644 --- a/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Packets.cs +++ b/Projects/Scripts/Engines/VeteranRewards/Character Statue Maker/Packets.cs @@ -4,17 +4,17 @@ namespace Server.Network { public UpdateStatueAnimation(Mobile m, int status, int animation, int frame) : base(0xBF, 17) { - m_Stream.Write((short)0x11); - m_Stream.Write((short)0x19); - m_Stream.Write((byte)0x5); - m_Stream.Write(m.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0xFF); - m_Stream.Write((byte)status); - m_Stream.Write((byte)0); - m_Stream.Write((byte)animation); - m_Stream.Write((byte)0); - m_Stream.Write((byte)frame); + Stream.Write((short)0x11); + Stream.Write((short)0x19); + Stream.Write((byte)0x5); + Stream.Write(m.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0xFF); + Stream.Write((byte)status); + Stream.Write((byte)0); + Stream.Write((byte)animation); + Stream.Write((byte)0); + Stream.Write((byte)frame); } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardCategory.cs b/Projects/Scripts/Engines/VeteranRewards/RewardCategory.cs index 4ba977c9f..d9bc078c1 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardCategory.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardCategory.cs @@ -16,10 +16,10 @@ namespace Server.Engines.VeteranRewards Entries = new List(); } - public int Name{ get; } + public int Name { get; } - public string NameString{ get; } + public string NameString { get; } - public List Entries{ get; } + public List Entries { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs b/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs index 102d07a25..63761e4c7 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardChoiceGump.cs @@ -7,7 +7,7 @@ namespace Server.Engines.VeteranRewards { public class RewardChoiceGump : Gump { - private Mobile m_From; + private readonly Mobile m_From; public RewardChoiceGump(Mobile from) : base(0, 0) { diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs b/Projects/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs index bd4410893..0baccb5c7 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardConfirmGump.cs @@ -6,8 +6,8 @@ namespace Server.Engines.VeteranRewards { public class RewardConfirmGump : Gump { - private RewardEntry m_Entry; - private Mobile m_From; + private readonly RewardEntry m_Entry; + private readonly Mobile m_From; public RewardConfirmGump(Mobile from, RewardEntry entry) : base(0, 0) { diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs b/Projects/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs index 70dea01f2..d6ef6abde 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardDemolitionGump.cs @@ -6,7 +6,7 @@ namespace Server.Gumps { public class RewardDemolitionGump : Gump { - private IAddon m_Addon; + private readonly IAddon m_Addon; public RewardDemolitionGump(IAddon addon, int question) : base(150, 50) { diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardEntry.cs b/Projects/Scripts/Engines/VeteranRewards/RewardEntry.cs index eb4194ad4..c0aa633d1 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardEntry.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardEntry.cs @@ -1,5 +1,5 @@ -using Server.Utilities; using System; +using Server.Utilities; namespace Server.Engines.VeteranRewards { @@ -47,19 +47,19 @@ namespace Server.Engines.VeteranRewards category.Entries.Add(this); } - public RewardList List{ get; set; } + public RewardList List { get; set; } - public RewardCategory Category{ get; } + public RewardCategory Category { get; } - public Type ItemType{ get; } + public Type ItemType { get; } - public Expansion RequiredExpansion{ get; } + public Expansion RequiredExpansion { get; } - public int Name{ get; } + public int Name { get; } - public string NameString{ get; } + public string NameString { get; } - public object[] Args{ get; } + public object[] Args { get; } public Item Construct() { diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardList.cs b/Projects/Scripts/Engines/VeteranRewards/RewardList.cs index 4e8f85a94..5f5eab211 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardList.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardList.cs @@ -13,8 +13,8 @@ namespace Server.Engines.VeteranRewards entries[i].List = this; } - public TimeSpan Age{ get; } + public TimeSpan Age { get; } - public RewardEntry[] Entries{ get; } + public RewardEntry[] Entries { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs b/Projects/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs index 3e9a8aac9..691d24382 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardNoticeGump.cs @@ -5,7 +5,7 @@ namespace Server.Engines.VeteranRewards { public class RewardNoticeGump : Gump { - private Mobile m_From; + private readonly Mobile m_From; public RewardNoticeGump(Mobile from) : base(0, 0) { diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardOptionGump.cs b/Projects/Scripts/Engines/VeteranRewards/RewardOptionGump.cs index 4bdd1b2c9..077c50952 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardOptionGump.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardOptionGump.cs @@ -11,8 +11,8 @@ namespace Server.Gumps public class RewardOptionGump : Gump { - private IRewardOption m_Option; - private RewardOptionList m_Options = new RewardOptionList(); + private readonly IRewardOption m_Option; + private readonly RewardOptionList m_Options = new RewardOptionList(); public RewardOptionGump(IRewardOption option, int title = 0) : base(60, 36) { @@ -72,9 +72,9 @@ namespace Server.Gumps Cliloc = cliloc; } - public int ID{ get; } + public int ID { get; } - public int Cliloc{ get; } + public int Cliloc { get; } } public class RewardOptionList : List diff --git a/Projects/Scripts/Engines/VeteranRewards/RewardSystem.cs b/Projects/Scripts/Engines/VeteranRewards/RewardSystem.cs index c140c2edb..e99de53b4 100644 --- a/Projects/Scripts/Engines/VeteranRewards/RewardSystem.cs +++ b/Projects/Scripts/Engines/VeteranRewards/RewardSystem.cs @@ -46,7 +46,7 @@ namespace Server.Engines.VeteranRewards List entries = category.Entries; for (int j = 0; j < entries.Count; ++j) - //RewardEntry entry = entries[j]; + // RewardEntry entry = entries[j]; if (HasAccess(mob, entries[j])) return true; return false; @@ -131,7 +131,7 @@ namespace Server.Engines.VeteranRewards if (!(mob.Account is Account acct)) return false; - //if ( mob.AccessLevel < AccessLevel.GameMaster ) + // if (mob.AccessLevel < AccessLevel.GameMaster) acct.SetTag("numRewardsChosen", (cur + 1).ToString()); return true; @@ -192,14 +192,13 @@ namespace Server.Engines.VeteranRewards if (args == null && entries[j].Args.Length == 0) { - if (isRelaxedRules && i <= 0 || HasAccess(from, list, out TimeSpan ts)) + if ((isRelaxedRules && i <= 0) || HasAccess(from, list, out TimeSpan ts)) return true; from.SendLocalizedMessage(1008126, true, Math.Ceiling(ts.TotalDays / 30.0) .ToString()); // Your account is not old enough to use this item. Months until you can use this item : return false; - } if (args?.Length != entries[j].Args.Length) @@ -212,7 +211,7 @@ namespace Server.Engines.VeteranRewards if (match) { - if (isRelaxedRules && i <= 0 || HasAccess(from, list, out TimeSpan ts)) + if ((isRelaxedRules && i <= 0) || HasAccess(from, list, out TimeSpan ts)) return true; from.SendLocalizedMessage(1008126, true, @@ -501,6 +500,6 @@ namespace Server.Engines.VeteranRewards public interface IRewardItem { - bool IsRewardItem{ get; set; } + bool IsRewardItem { get; set; } } } diff --git a/Projects/Scripts/Engines/Virtues/Compassion.cs b/Projects/Scripts/Engines/Virtues/Compassion.cs index 362989d4b..eba89fd68 100644 --- a/Projects/Scripts/Engines/Virtues/Compassion.cs +++ b/Projects/Scripts/Engines/Virtues/Compassion.cs @@ -6,7 +6,7 @@ namespace Server public class CompassionVirtue { private const int LossAmount = 500; - private static TimeSpan LossDelay = TimeSpan.FromDays(7.0); + private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0); public static void Initialize() { @@ -28,7 +28,7 @@ namespace Server if (pm.LastCompassionLoss + LossDelay < DateTime.UtcNow) { VirtueHelper.Atrophy(from, VirtueName.Compassion, LossAmount); - //OSI has no cliloc message for losing compassion. Weird. + // OSI has no cliloc message for losing compassion. Weird. pm.LastCompassionLoss = DateTime.UtcNow; } } diff --git a/Projects/Scripts/Engines/Virtues/Honor.cs b/Projects/Scripts/Engines/Virtues/Honor.cs index 576d0d42d..230db01c2 100644 --- a/Projects/Scripts/Engines/Virtues/Honor.cs +++ b/Projects/Scripts/Engines/Virtues/Honor.cs @@ -81,7 +81,7 @@ namespace Server pm.SendLocalizedMessage(1063235); // You embrace your honor Timer.DelayCall(TimeSpan.FromSeconds(duration), - delegate + () => { pm.HonorActive = false; pm.LastHonorUse = DateTime.UtcNow; @@ -116,20 +116,20 @@ namespace Server return; } - if (target.Body.IsHuman && (!(target is BaseCreature cret) || !cret.AlwaysAttackable && !cret.AlwaysMurderer)) + if (target.Body.IsHuman && (!(target is BaseCreature cret) || (!cret.AlwaysAttackable && !cret.AlwaysMurderer))) { if (reg?.IsDisabled() != true) { - //Allow honor on blue if Out of guardzone + // Allow honor on blue if Out of guardzone } else if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) { - //Allow honor on blue if in Fel + // Allow honor on blue if in Fel } else { source.SendLocalizedMessage(1001018); // You cannot perform negative acts - return; //cannot honor in trammel town on blue + return; // cannot honor in trammel town on blue } } @@ -173,18 +173,18 @@ namespace Server public interface IHonorTarget { - HonorContext ReceivedHonorContext{ get; set; } + HonorContext ReceivedHonorContext { get; set; } } public class HonorContext { private FirstHit m_FirstHit; private double m_HonorDamage; - private Point3D m_InitialLocation; - private Map m_InitialMap; + private readonly Point3D m_InitialLocation; + private readonly Map m_InitialMap; private bool m_Poisoned; - private InternalTimer m_Timer; + private readonly InternalTimer m_Timer; private int m_TotalDamage; public HonorContext(PlayerMobile source, Mobile target) @@ -206,17 +206,17 @@ namespace Server source.m_hontime = DateTime.UtcNow + TimeSpan.FromMinutes(40); Timer.DelayCall(TimeSpan.FromMinutes(40), - delegate + () => { if (source.m_hontime < DateTime.UtcNow && source.SentHonorContext != null) Cancel(); }); } - public PlayerMobile Source{ get; } + public PlayerMobile Source { get; } - public Mobile Target{ get; } + public Mobile Target { get; } - public int PerfectionDamageBonus{ get; private set; } + public int PerfectionDamageBonus { get; private set; } public int PerfectionLuckBonus => PerfectionDamageBonus * PerfectionDamageBonus / 10; @@ -252,8 +252,8 @@ namespace Server if (from == Source) { if (Target.CanSee(Source) && Target.InLOS(Source) && (Source.InRange(Target, 1) - || Source.Location == m_InitialLocation && - Source.Map == m_InitialMap)) + || (Source.Location == m_InitialLocation && + Source.Map == m_InitialMap))) m_HonorDamage += amount; else m_HonorDamage += amount * 0.8; @@ -339,17 +339,17 @@ namespace Server return; double dGain = - targetFame / 100.0 * (m_HonorDamage / m_TotalDamage); //Initial honor gain is 100th of the monsters honor + targetFame / 100.0 * (m_HonorDamage / m_TotalDamage); // Initial honor gain is 100th of the monsters honor if (m_HonorDamage == m_TotalDamage && m_FirstHit == FirstHit.Granted) - dGain = dGain * 1.5; //honor gain is increased alot more if the combat was fully honorable + dGain = dGain * 1.5; // honor gain is increased alot more if the combat was fully honorable else dGain = dGain * 0.9; int gain = Math.Min((int)dGain, 200); if (gain < 1) - gain = 1; //Minimum gain of 1 honor when the honor is under the monsters fame + gain = 1; // Minimum gain of 1 honor when the honor is under the monsters fame if (VirtueHelper.IsHighestPath(Source, VirtueName.Honor)) { @@ -386,7 +386,7 @@ namespace Server private class InternalTimer : Timer { - private HonorContext m_Context; + private readonly HonorContext m_Context; public InternalTimer(HonorContext context) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) => m_Context = context; diff --git a/Projects/Scripts/Engines/Virtues/Justice.cs b/Projects/Scripts/Engines/Virtues/Justice.cs index 259ab4598..4ea83165a 100644 --- a/Projects/Scripts/Engines/Virtues/Justice.cs +++ b/Projects/Scripts/Engines/Virtues/Justice.cs @@ -9,7 +9,7 @@ namespace Server public class JusticeVirtue { private const int LossAmount = 950; - private static TimeSpan LossDelay = TimeSpan.FromDays(7.0); + private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0); public static void Initialize() { @@ -177,8 +177,8 @@ namespace Server public class AcceptProtectorGump : Gump { - private PlayerMobile m_Protectee; - private PlayerMobile m_Protector; + private readonly PlayerMobile m_Protectee; + private readonly PlayerMobile m_Protector; public AcceptProtectorGump(PlayerMobile protector, PlayerMobile protectee) : base(150, 50) { diff --git a/Projects/Scripts/Engines/Virtues/Sacrifice.cs b/Projects/Scripts/Engines/Virtues/Sacrifice.cs index 02f362c76..cbafe0ef5 100644 --- a/Projects/Scripts/Engines/Virtues/Sacrifice.cs +++ b/Projects/Scripts/Engines/Virtues/Sacrifice.cs @@ -9,8 +9,8 @@ namespace Server public class SacrificeVirtue { private const int LossAmount = 500; - private static TimeSpan GainDelay = TimeSpan.FromDays(1.0); - private static TimeSpan LossDelay = TimeSpan.FromDays(7.0); + private static readonly TimeSpan GainDelay = TimeSpan.FromDays(1.0); + private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0); public static void Initialize() { diff --git a/Projects/Scripts/Engines/Virtues/Valor.cs b/Projects/Scripts/Engines/Virtues/Valor.cs index 87c6a0da0..a9f0146e0 100644 --- a/Projects/Scripts/Engines/Virtues/Valor.cs +++ b/Projects/Scripts/Engines/Virtues/Valor.cs @@ -8,7 +8,7 @@ namespace Server public class ValorVirtue { private const int LossAmount = 250; - private static TimeSpan LossDelay = TimeSpan.FromDays(7.0); + private static readonly TimeSpan LossDelay = TimeSpan.FromDays(7.0); public static void Initialize() { @@ -64,34 +64,34 @@ namespace Server VirtueLevel vl = VirtueHelper.GetLevel(from, VirtueName.Valor); if (idol.Spawn.Active) { - if (idol.Spawn.Champion != null) //TODO: Message? + if (idol.Spawn.Champion != null) // TODO: Message? return; int needed, consumed; switch (idol.Spawn.GetSubLevel()) { case 0: - { - needed = consumed = 2500; - break; - } + { + needed = consumed = 2500; + break; + } case 1: - { - needed = consumed = 5000; - break; - } + { + needed = consumed = 5000; + break; + } case 2: - { - needed = 10000; - consumed = 7500; - break; - } + { + needed = 10000; + consumed = 7500; + break; + } default: - { - needed = 20000; - consumed = 10000; - break; - } + { + needed = 20000; + consumed = 10000; + break; + } } if (from.Virtues.GetValue((int)VirtueName.Valor) >= needed) diff --git a/Projects/Scripts/Engines/Virtues/VirtueGump.cs b/Projects/Scripts/Engines/Virtues/VirtueGump.cs index 9f226496b..06cbc19fc 100644 --- a/Projects/Scripts/Engines/Virtues/VirtueGump.cs +++ b/Projects/Scripts/Engines/Virtues/VirtueGump.cs @@ -8,9 +8,9 @@ namespace Server public class VirtueGump : Gump { - private static Dictionary m_Callbacks = new Dictionary(); + private static readonly Dictionary m_Callbacks = new Dictionary(); - private static int[] m_Table = { + private static readonly int[] m_Table = { 0x0481, 0x0963, 0x0965, 0x060A, 0x060F, 0x002A, 0x08A4, 0x08A7, 0x0034, @@ -21,7 +21,8 @@ namespace Server 0x0543, 0x0547, 0x0061 }; - private Mobile m_Beholder, m_Beheld; + private readonly Mobile m_Beholder; + private readonly Mobile m_Beheld; public VirtueGump(Mobile beholder, Mobile beheld) : base(0, 0) { @@ -83,7 +84,6 @@ namespace Server beholder.SendLocalizedMessage(1052066); // That virtue is not active yet. } - private static void EventSink_VirtueMacroRequest(Mobile beholder, int virtue) { var virtueID = virtue switch @@ -121,8 +121,7 @@ namespace Server return 2402; if (value >= 30000) - value = 20000; //Sanity - + value = 20000; // Sanity int vl; @@ -137,7 +136,6 @@ namespace Server else vl = 1; - return m_Table[index * 3 + vl]; } @@ -149,7 +147,7 @@ namespace Server private class InternalEntry : GumpImage { - private static byte[] m_Class = StringToBuffer(" class=VirtueGumpItem"); + private static readonly byte[] m_Class = StringToBuffer(" class=VirtueGumpItem"); public InternalEntry(int x, int y, int gumpID, int hue) : base(x, y, gumpID, hue) { diff --git a/Projects/Scripts/Engines/Virtues/VirtueInfoGump.cs b/Projects/Scripts/Engines/Virtues/VirtueInfoGump.cs index f642321a9..08053a059 100644 --- a/Projects/Scripts/Engines/Virtues/VirtueInfoGump.cs +++ b/Projects/Scripts/Engines/Virtues/VirtueInfoGump.cs @@ -5,10 +5,10 @@ namespace Server { public class VirtueInfoGump : Gump { - private Mobile m_Beholder; - private int m_Desc; - private string m_Page; - private VirtueName m_Virtue; + private readonly Mobile m_Beholder; + private readonly int m_Desc; + private readonly string m_Page; + private readonly VirtueName m_Virtue; public VirtueInfoGump(Mobile beholder, VirtueName virtue, int description, string webPage = null) : base(0, 0) { @@ -47,7 +47,6 @@ namespace Server for (int i = 0; i < 10; ++i) AddImage(95 + i * 17, 50, i < dots ? 2362 : 2360); - if (value < 1) valueDesc = 1052044; // You have not started on the path of this Virtue. else if (value < 400) @@ -67,7 +66,6 @@ namespace Server else valueDesc = 1052050; // You have achieved the highest path in this Virtue. - AddHtmlLocalized(157, 73, 200, 40, 1051000 + (int)virtue); AddHtmlLocalized(75, 95, 220, 140, description); AddHtmlLocalized(70, 224, 229, 60, valueDesc); @@ -84,18 +82,18 @@ namespace Server switch (info.ButtonID) { case 1: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, m_Virtue, m_Desc, m_Page)); + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, m_Virtue, m_Desc, m_Page)); - if (m_Page != null) - state.Send(new LaunchBrowser(m_Page)); //No message about web browser starting on OSI - break; - } + if (m_Page != null) + state.Send(new LaunchBrowser(m_Page)); // No message about web browser starting on OSI + break; + } case 2: - { - m_Beholder.SendGump(new VirtueStatusGump(m_Beholder)); - break; - } + { + m_Beholder.SendGump(new VirtueStatusGump(m_Beholder)); + break; + } } } } diff --git a/Projects/Scripts/Engines/Virtues/VirtueStatusGump.cs b/Projects/Scripts/Engines/Virtues/VirtueStatusGump.cs index 911cc7774..b892be402 100644 --- a/Projects/Scripts/Engines/Virtues/VirtueStatusGump.cs +++ b/Projects/Scripts/Engines/Virtues/VirtueStatusGump.cs @@ -5,7 +5,7 @@ namespace Server { public class VirtueStatusGump : Gump { - private Mobile m_Beholder; + private readonly Mobile m_Beholder; public VirtueStatusGump(Mobile beholder) : base(0, 0) { @@ -52,55 +52,55 @@ namespace Server switch (info.ButtonID) { case 1: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Humility, 1052051)); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Humility, 1052051)); + break; + } case 2: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Sacrifice, 1052053, - @"http://update.uo.com/design_389.html")); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Sacrifice, 1052053, + @"http://update.uo.com/design_389.html")); + break; + } case 3: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Compassion, 1053000, - @"http://update.uo.com/design_412.html")); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Compassion, 1053000, + @"http://update.uo.com/design_412.html")); + break; + } case 4: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Spirituality, 1052056)); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Spirituality, 1052056)); + break; + } case 5: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Valor, 1054033, - @"http://update.uo.com/design_427.html")); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Valor, 1054033, + @"http://update.uo.com/design_427.html")); + break; + } case 6: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honor, 1052058, - @"http://guide.uo.com/virtues_2.html")); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honor, 1052058, + @"http://guide.uo.com/virtues_2.html")); + break; + } case 7: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Justice, 1052059, - @"http://update.uo.com/design_413.html")); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Justice, 1052059, + @"http://update.uo.com/design_413.html")); + break; + } case 8: - { - m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honesty, 1052060)); - break; - } + { + m_Beholder.SendGump(new VirtueInfoGump(m_Beholder, VirtueName.Honesty, 1052060)); + break; + } case 9: - { - m_Beholder.SendGump(new VirtueGump(m_Beholder, m_Beholder)); - break; - } + { + m_Beholder.SendGump(new VirtueGump(m_Beholder, m_Beholder)); + break; + } } } } diff --git a/Projects/Scripts/Gumps/AddDoorGump.cs b/Projects/Scripts/Gumps/AddDoorGump.cs index e03575788..81b035895 100644 --- a/Projects/Scripts/Gumps/AddDoorGump.cs +++ b/Projects/Scripts/Gumps/AddDoorGump.cs @@ -15,7 +15,7 @@ namespace Server.Gumps new DoorInfo(typeof(StrongWoodDoor), 0x6E5) }; - private int m_Type; + private readonly int m_Type; public AddDoorGump(int type = -1) : base(50, 40) { diff --git a/Projects/Scripts/Gumps/AddGump.cs b/Projects/Scripts/Gumps/AddGump.cs index 2c5f1a9e2..5a69d54d9 100644 --- a/Projects/Scripts/Gumps/AddGump.cs +++ b/Projects/Scripts/Gumps/AddGump.cs @@ -9,10 +9,11 @@ namespace Server.Gumps { public class AddGump : Gump { - private static Type typeofItem = typeof(Item), typeofMobile = typeof(Mobile); - private int m_Page; - private Type[] m_SearchResults; - private string m_SearchString; + private static readonly Type typeofItem = typeof(Item); + private static readonly Type typeofMobile = typeof(Mobile); + private readonly int m_Page; + private readonly Type[] m_SearchResults; + private readonly string m_SearchString; public AddGump(Mobile from, string searchString, int page, Type[] searchResults, bool explicitSearch) : base(50, 50) { @@ -156,48 +157,48 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Search - { - TextRelay te = info.GetTextEntry(0); - string match = te?.Text.Trim() ?? ""; - - if (match.Length < 3) { - from.SendMessage("Invalid search string."); - from.SendGump(new AddGump(from, match, m_Page, m_SearchResults, false)); - } - else - { - from.SendGump(new AddGump(from, match, 0, Match(match).ToArray(), true)); - } + TextRelay te = info.GetTextEntry(0); + string match = te?.Text.Trim() ?? ""; - break; - } + if (match.Length < 3) + { + from.SendMessage("Invalid search string."); + from.SendGump(new AddGump(from, match, m_Page, m_SearchResults, false)); + } + else + { + from.SendGump(new AddGump(from, match, 0, Match(match).ToArray(), true)); + } + + break; + } case 2: // Previous page - { - if (m_Page > 0) - from.SendGump(new AddGump(from, m_SearchString, m_Page - 1, m_SearchResults, true)); - - break; - } - case 3: // Next page - { - if ((m_Page + 1) * 10 < m_SearchResults.Length) - from.SendGump(new AddGump(from, m_SearchString, m_Page + 1, m_SearchResults, true)); - - break; - } - default: - { - int index = info.ButtonID - 4; - - if (index >= 0 && index < m_SearchResults.Length) { - from.SendMessage("Where do you wish to place this object? to cancel."); - from.Target = new InternalTarget(m_SearchResults[index], m_SearchResults, m_SearchString, m_Page); - } + if (m_Page > 0) + from.SendGump(new AddGump(from, m_SearchString, m_Page - 1, m_SearchResults, true)); - break; - } + break; + } + case 3: // Next page + { + if ((m_Page + 1) * 10 < m_SearchResults.Length) + from.SendGump(new AddGump(from, m_SearchString, m_Page + 1, m_SearchResults, true)); + + break; + } + default: + { + int index = info.ButtonID - 4; + + if (index >= 0 && index < m_SearchResults.Length) + { + from.SendMessage("Where do you wish to place this object? to cancel."); + from.Target = new InternalTarget(m_SearchResults[index], m_SearchResults, m_SearchString, m_Page); + } + + break; + } } } @@ -208,10 +209,10 @@ namespace Server.Gumps public class InternalTarget : Target { - private int m_Page; - private Type[] m_SearchResults; - private string m_SearchString; - private Type m_Type; + private readonly int m_Page; + private readonly Type[] m_SearchResults; + private readonly string m_SearchString; + private readonly Type m_Type; public InternalTarget(Type type, Type[] searchResults, string searchString, int page) : base(-1, true, TargetFlags.None) diff --git a/Projects/Scripts/Gumps/AdminGump.cs b/Projects/Scripts/Gumps/AdminGump.cs index 5742830db..99a7ad73e 100644 --- a/Projects/Scripts/Gumps/AdminGump.cs +++ b/Projects/Scripts/Gumps/AdminGump.cs @@ -56,7 +56,7 @@ namespace Server.Gumps private const int GreenHue = 0x40; private const int RedHue = 0x20; - private static string[] m_AccessLevelStrings = + private static readonly string[] m_AccessLevelStrings = { "Player", "Counselor", @@ -67,11 +67,11 @@ namespace Server.Gumps "Owner" }; - private Mobile m_From; - private List m_List; - private int m_ListPage; - private AdminGumpPage m_PageType; - private object m_State; + private readonly Mobile m_From; + private readonly List m_List; + private readonly int m_ListPage; + private readonly AdminGumpPage m_PageType; + private readonly object m_State; public AdminGump(Mobile from, AdminGumpPage pageType, int listPage = 0, List list = null, string notice = null, object state = null) : base(50, 40) @@ -113,1026 +113,1026 @@ namespace Server.Gumps switch (pageType) { case AdminGumpPage.Information_General: - { - int banned = 0; - int active = 0; - - foreach (Account acct in Accounts.GetAccounts()) - if (acct.Banned) - ++banned; - else - ++active; - - AddLabel(20, 130, LabelHue, "Active Accounts:"); - AddLabel(150, 130, LabelHue, active.ToString()); - - AddLabel(20, 150, LabelHue, "Banned Accounts:"); - AddLabel(150, 150, LabelHue, banned.ToString()); - - AddLabel(20, 170, LabelHue, "Firewalled:"); - AddLabel(150, 170, LabelHue, Firewall.List.Count.ToString()); - - AddLabel(20, 190, LabelHue, "Clients:"); - AddLabel(150, 190, LabelHue, TcpServer.Instances.Count.ToString()); - - AddLabel(20, 210, LabelHue, "Mobiles:"); - AddLabel(150, 210, LabelHue, World.Mobiles.Count.ToString()); - - AddLabel(20, 230, LabelHue, "Mobile Scripts:"); - AddLabel(150, 230, LabelHue, Core.ScriptMobiles.ToString()); - - AddLabel(20, 250, LabelHue, "Items:"); - AddLabel(150, 250, LabelHue, World.Items.Count.ToString()); - - AddLabel(20, 270, LabelHue, "Item Scripts:"); - AddLabel(150, 270, LabelHue, Core.ScriptItems.ToString()); - - AddLabel(20, 290, LabelHue, "Uptime:"); - AddLabel(150, 290, LabelHue, FormatTimeSpan(DateTime.UtcNow - Clock.ServerStart)); - - AddLabel(20, 310, LabelHue, "Memory:"); - AddLabel(150, 310, LabelHue, FormatByteAmount(GC.GetTotalMemory(false))); - - AddLabel(20, 330, LabelHue, "Framework:"); - AddLabel(150, 330, LabelHue, Environment.Version.ToString()); - - AddLabel(20, 350, LabelHue, "Operating System: "); - string os = Environment.OSVersion.ToString(); - - os = os.Replace("Microsoft", "MSFT"); - os = os.Replace("Service Pack", "SP"); - - AddLabel(150, 350, LabelHue, os); - - /*string str; - - try{ str = FormatTimeSpan( Core.Process.TotalProcessorTime ); } - catch{ str = "(unable to retrieve)"; } - - AddLabel( 20, 330, LabelHue, "Process Time:" ); - AddLabel( 250, 330, LabelHue, str );*/ - - /*try{ str = Core.Process.PriorityClass.ToString(); } - catch{ str = "(unable to retrieve)"; } - - AddLabel( 20, 350, LabelHue, "Process Priority:" ); - AddLabel( 250, 350, LabelHue, str );*/ - - AddPageButton(200, 20, GetButtonID(0, 0), "General", AdminGumpPage.Information_General); - AddPageButton(200, 40, GetButtonID(0, 5), "Performance", AdminGumpPage.Information_Perf); - - break; - } - case AdminGumpPage.Information_Perf: - { - AddLabel(20, 130, LabelHue, "Cycles Per Second:"); - AddLabel(40, 150, LabelHue, $"Current: {Core.CyclesPerSecond:N2}"); - AddLabel(40, 170, LabelHue, $"Average: {Core.AverageCPS:N2}"); - - StringBuilder sb = new StringBuilder(); - - ThreadPool.GetAvailableThreads(out int curUser, out int curIOCP); - ThreadPool.GetMaxThreads(out int maxUser, out int maxIOCP); - - sb.Append("Worker Threads:
Capacity: "); - sb.Append(maxUser); - sb.Append("
Available: "); - sb.Append(curUser); - sb.Append("
Usage: "); - sb.Append((maxUser - curUser) * 100 / maxUser); - sb.Append("%

IOCP Threads:
Capacity: "); - sb.Append(maxIOCP); - sb.Append("
Available: "); - sb.Append(curIOCP); - sb.Append("
Usage: "); - sb.Append((maxIOCP - curIOCP) * 100 / maxIOCP); - sb.Append("%"); - - AddLabel(20, 200, LabelHue, "Pooling:"); - AddHtml(20, 220, 380, 150, sb.ToString(), true, true); - - AddPageButton(200, 20, GetButtonID(0, 0), "General", AdminGumpPage.Information_General); - AddPageButton(200, 40, GetButtonID(0, 5), "Performance", AdminGumpPage.Information_Perf); - - break; - } - case AdminGumpPage.Administer_WorldBuilding: - { - AddHtml(10, 125, 400, 20, Color(Center("Generating"), LabelColor32)); - - AddButtonLabeled(20, 150, GetButtonID(3, 100), "Documentation"); - AddButtonLabeled(220, 150, GetButtonID(3, 107), "Rebuild Categorization"); - - AddButtonLabeled(20, 175, GetButtonID(3, 101), "Teleporters"); - AddButtonLabeled(220, 175, GetButtonID(3, 102), "Moongates"); - - AddButtonLabeled(20, 200, GetButtonID(3, 103), "Vendors"); - AddButtonLabeled(220, 200, GetButtonID(3, 106), "Decoration"); - - AddButtonLabeled(20, 225, GetButtonID(3, 104), "Doors"); - AddButtonLabeled(220, 225, GetButtonID(3, 105), "Signs"); - - AddHtml(20, 275, 400, 30, Color(Center("Statics"), LabelColor32)); - - AddButtonLabeled(20, 300, GetButtonID(3, 110), "Freeze (Target)"); - AddButtonLabeled(20, 325, GetButtonID(3, 111), "Freeze (World)"); - AddButtonLabeled(20, 350, GetButtonID(3, 112), "Freeze (Map)"); - - AddButtonLabeled(220, 300, GetButtonID(3, 120), "Unfreeze (Target)"); - AddButtonLabeled(220, 325, GetButtonID(3, 121), "Unfreeze (World)"); - AddButtonLabeled(220, 350, GetButtonID(3, 122), "Unfreeze (Map)"); - - goto case AdminGumpPage.Administer; - } - case AdminGumpPage.Administer_Server: - { - AddHtml(10, 125, 400, 20, Color(Center("Server"), LabelColor32)); - - AddButtonLabeled(20, 150, GetButtonID(3, 200), "Save"); - - /*if ( !Core.Service ) - {*/ - AddButtonLabeled(20, 180, GetButtonID(3, 201), "Shutdown (With Save)"); - AddButtonLabeled(20, 200, GetButtonID(3, 202), "Shutdown (Without Save)"); - - AddButtonLabeled(20, 230, GetButtonID(3, 203), "Shutdown & Restart (With Save)"); - AddButtonLabeled(20, 250, GetButtonID(3, 204), "Shutdown & Restart (Without Save)"); - /*} - else { - AddLabel( 20, 215, LabelHue, "Shutdown/Restart not available." ); - }*/ + int banned = 0; + int active = 0; - AddHtml(10, 295, 400, 20, Color(Center("Broadcast"), LabelColor32)); + foreach (Account acct in Accounts.GetAccounts()) + if (acct.Banned) + ++banned; + else + ++active; - AddTextField(20, 320, 380, 20, 0); - AddButtonLabeled(20, 350, GetButtonID(3, 210), "To Everyone"); - AddButtonLabeled(220, 350, GetButtonID(3, 211), "To Staff"); + AddLabel(20, 130, LabelHue, "Active Accounts:"); + AddLabel(150, 130, LabelHue, active.ToString()); - goto case AdminGumpPage.Administer; - } - case AdminGumpPage.Administer_Access_Lockdown: - { - AddHtml(10, 125, 400, 20, Color(Center("Server Lockdown"), LabelColor32)); + AddLabel(20, 150, LabelHue, "Banned Accounts:"); + AddLabel(150, 150, LabelHue, banned.ToString()); - AddHtml(20, 150, 380, 80, - Color( - "When enabled, only clients with an access level equal to or greater than the specified lockdown level may access the server. After setting a lockdown level, use the Purge Invalid Clients button to disconnect those clients without access.", - LabelColor32)); + AddLabel(20, 170, LabelHue, "Firewalled:"); + AddLabel(150, 170, LabelHue, Firewall.List.Count.ToString()); - AccessLevel level = AccountHandler.LockdownLevel; - bool isLockedDown = level > AccessLevel.Player; + AddLabel(20, 190, LabelHue, "Clients:"); + AddLabel(150, 190, LabelHue, TcpServer.Instances.Count.ToString()); - AddSelectedButton(20, 230, GetButtonID(3, 500), "Not Locked Down", !isLockedDown); - AddSelectedButton(20, 260, GetButtonID(3, 504), "Administrators", - isLockedDown && level <= AccessLevel.Administrator); - AddSelectedButton(20, 280, GetButtonID(3, 503), "Seers", isLockedDown && level <= AccessLevel.Seer); - AddSelectedButton(20, 300, GetButtonID(3, 502), "Game Masters", - isLockedDown && level <= AccessLevel.GameMaster); - AddSelectedButton(20, 320, GetButtonID(3, 501), "Counselors", - isLockedDown && level <= AccessLevel.Counselor); + AddLabel(20, 210, LabelHue, "Mobiles:"); + AddLabel(150, 210, LabelHue, World.Mobiles.Count.ToString()); - AddButtonLabeled(20, 350, GetButtonID(3, 510), "Purge Invalid Clients"); + AddLabel(20, 230, LabelHue, "Mobile Scripts:"); + AddLabel(150, 230, LabelHue, Core.ScriptMobiles.ToString()); - goto case AdminGumpPage.Administer; - } - case AdminGumpPage.Administer_Access: - { - AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32)); + AddLabel(20, 250, LabelHue, "Items:"); + AddLabel(150, 250, LabelHue, World.Items.Count.ToString()); - AddHtml(10, 155, 400, 20, Color(Center("Connectivity"), LabelColor32)); + AddLabel(20, 270, LabelHue, "Item Scripts:"); + AddLabel(150, 270, LabelHue, Core.ScriptItems.ToString()); - AddButtonLabeled(20, 180, GetButtonID(3, 300), "Kick"); - AddButtonLabeled(220, 180, GetButtonID(3, 301), "Ban"); + AddLabel(20, 290, LabelHue, "Uptime:"); + AddLabel(150, 290, LabelHue, FormatTimeSpan(DateTime.UtcNow - Clock.ServerStart)); - AddButtonLabeled(20, 210, GetButtonID(3, 302), "Firewall"); - AddButtonLabeled(220, 210, GetButtonID(3, 303), "Lockdown"); + AddLabel(20, 310, LabelHue, "Memory:"); + AddLabel(150, 310, LabelHue, FormatByteAmount(GC.GetTotalMemory(false))); - AddHtml(10, 245, 400, 20, Color(Center("Staff"), LabelColor32)); + AddLabel(20, 330, LabelHue, "Framework:"); + AddLabel(150, 330, LabelHue, Environment.Version.ToString()); - AddButtonLabeled(20, 270, GetButtonID(3, 310), "Make Player"); - AddButtonLabeled(20, 290, GetButtonID(3, 311), "Make Counselor"); - AddButtonLabeled(20, 310, GetButtonID(3, 312), "Make Game Master"); - AddButtonLabeled(20, 330, GetButtonID(3, 313), "Make Seer"); + AddLabel(20, 350, LabelHue, "Operating System: "); + string os = Environment.OSVersion.ToString(); - if (from.AccessLevel > AccessLevel.Administrator) - { - AddButtonLabeled(220, 270, GetButtonID(3, 314), "Make Administrator"); + os = os.Replace("Microsoft", "MSFT"); + os = os.Replace("Service Pack", "SP"); - if (from.AccessLevel > AccessLevel.Developer) - { - AddButtonLabeled(220, 290, GetButtonID(3, 315), "Make Developer"); + AddLabel(150, 350, LabelHue, os); - if (from.AccessLevel >= AccessLevel.Owner) - AddButtonLabeled(220, 310, GetButtonID(3, 316), "Make Owner"); - } - } + /*string str; - goto case AdminGumpPage.Administer; - } - case AdminGumpPage.Administer_Commands: - { - AddHtml(10, 125, 400, 20, Color(Center("Commands"), LabelColor32)); + try{ str = FormatTimeSpan( Core.Process.TotalProcessorTime ); } + catch{ str = "(unable to retrieve)"; } - AddButtonLabeled(20, 150, GetButtonID(3, 400), "Add"); - AddButtonLabeled(220, 150, GetButtonID(3, 401), "Remove"); + AddLabel( 20, 330, LabelHue, "Process Time:" ); + AddLabel( 250, 330, LabelHue, str );*/ - AddButtonLabeled(20, 170, GetButtonID(3, 402), "Dupe"); - AddButtonLabeled(220, 170, GetButtonID(3, 403), "Dupe in bag"); + /*try{ str = Core.Process.PriorityClass.ToString(); } + catch{ str = "(unable to retrieve)"; } - AddButtonLabeled(20, 200, GetButtonID(3, 404), "Properties"); - AddButtonLabeled(220, 200, GetButtonID(3, 405), "Skills"); + AddLabel( 20, 350, LabelHue, "Process Priority:" ); + AddLabel( 250, 350, LabelHue, str );*/ - AddButtonLabeled(20, 230, GetButtonID(3, 406), "Mortal"); - AddButtonLabeled(220, 230, GetButtonID(3, 407), "Immortal"); + AddPageButton(200, 20, GetButtonID(0, 0), "General", AdminGumpPage.Information_General); + AddPageButton(200, 40, GetButtonID(0, 5), "Performance", AdminGumpPage.Information_Perf); - AddButtonLabeled(20, 250, GetButtonID(3, 408), "Squelch"); - AddButtonLabeled(220, 250, GetButtonID(3, 409), "Unsquelch"); - - AddButtonLabeled(20, 270, GetButtonID(3, 410), "Freeze"); - AddButtonLabeled(220, 270, GetButtonID(3, 411), "Unfreeze"); - - AddButtonLabeled(20, 290, GetButtonID(3, 412), "Hide"); - AddButtonLabeled(220, 290, GetButtonID(3, 413), "Unhide"); - - AddButtonLabeled(20, 310, GetButtonID(3, 414), "Kill"); - AddButtonLabeled(220, 310, GetButtonID(3, 415), "Resurrect"); - - AddButtonLabeled(20, 330, GetButtonID(3, 416), "Move"); - AddButtonLabeled(220, 330, GetButtonID(3, 417), "Wipe"); - - AddButtonLabeled(20, 350, GetButtonID(3, 418), "Teleport"); - AddButtonLabeled(220, 350, GetButtonID(3, 419), "Teleport (Multiple)"); - - goto case AdminGumpPage.Administer; - } - case AdminGumpPage.Administer: - { - AddPageButton(200, 20, GetButtonID(3, 0), "World Building", AdminGumpPage.Administer_WorldBuilding); - AddPageButton(200, 40, GetButtonID(3, 1), "Server", AdminGumpPage.Administer_Server); - AddPageButton(200, 60, GetButtonID(3, 2), "Access", AdminGumpPage.Administer_Access, - AdminGumpPage.Administer_Access_Lockdown); - AddPageButton(200, 80, GetButtonID(3, 3), "Commands", AdminGumpPage.Administer_Commands); - - break; - } - case AdminGumpPage.Clients: - { - if (m_List == null) - { - List states = TcpServer.Instances; - states.Sort(NetStateComparer.Instance); - - m_List = states.ToList(); - } - - AddClientHeader(); - - AddLabelCropped(12, 120, 81, 20, LabelHue, "Name"); - AddLabelCropped(95, 120, 81, 20, LabelHue, "Account"); - AddLabelCropped(178, 120, 81, 20, LabelHue, "Access Level"); - AddLabelCropped(273, 120, 109, 20, LabelHue, "IP Address"); - - if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); - else - AddImage(375, 122, 0x25EA); - - if ((listPage + 1) * 12 < m_List.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); - else - AddImage(392, 122, 0x25E6); - - if (m_List.Count == 0) - AddLabel(12, 140, LabelHue, "There are no clients to display."); - - for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index) - { - if (!(m_List[index] is NetState ns)) - continue; - - Mobile m = ns.Mobile; - Account a = ns.Account as Account; - int offset = 140 + i * 20; - - if (m == null) - AddLabelCropped(12, offset, 81, 20, LabelHue, "(logging in)"); - else - AddLabelCropped(12, offset, 81, 20, GetHueFor(m), m.Name); - AddLabelCropped(95, offset, 81, 20, LabelHue, a == null ? "(no account)" : a.Username); - AddLabelCropped(178, offset, 81, 20, LabelHue, - m == null - ? a != null ? FormatAccessLevel(a.AccessLevel) : "" - : FormatAccessLevel(m.AccessLevel)); - AddLabelCropped(273, offset, 109, 20, LabelHue, ns.ToString()); - - if (a != null || m != null) - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(4, index + 2)); - } - - break; - } - case AdminGumpPage.ClientInfo: - { - if (!(state is Mobile m)) break; - - AddClientHeader(); - - AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32)); - - int y = 146; - - AddLabel(20, y, LabelHue, "Name:"); - AddLabel(200, y, GetHueFor(m), m.Name); - y += 20; - - Account a = m.Account as Account; - - AddLabel(20, y, LabelHue, "Account:"); - AddLabel(200, y, a?.Banned == true ? RedHue : LabelHue, a == null ? "(no account)" : a.Username); - AddButton(380, y, 0xFA5, 0xFA7, GetButtonID(7, 14)); - y += 20; - - NetState ns = m.NetState; - - if (ns == null) - { - AddLabel(20, y, LabelHue, "Address:"); - AddLabel(200, y, RedHue, "Offline"); - y += 20; - - AddLabel(20, y, LabelHue, "Location:"); - AddLabel(200, y, LabelHue, $"{m.Location} [{m.Map}]"); - y += 44; } - else + case AdminGumpPage.Information_Perf: { - AddLabel(20, y, LabelHue, "Address:"); - AddLabel(200, y, GreenHue, ns.ToString()); - y += 20; + AddLabel(20, 130, LabelHue, "Cycles Per Second:"); + AddLabel(40, 150, LabelHue, $"Current: {Core.CyclesPerSecond:N2}"); + AddLabel(40, 170, LabelHue, $"Average: {Core.AverageCPS:N2}"); - ClientVersion v = ns.Version; + StringBuilder sb = new StringBuilder(); - AddLabel(20, y, LabelHue, "Version:"); - AddLabel(200, y, LabelHue, v == null ? "(null)" : v.ToString()); - y += 20; + ThreadPool.GetAvailableThreads(out int curUser, out int curIOCP); + ThreadPool.GetMaxThreads(out int maxUser, out int maxIOCP); - AddLabel(20, y, LabelHue, "Location:"); - AddLabel(200, y, LabelHue, $"{m.Location} [{m.Map}]"); - y += 24; + sb.Append("Worker Threads:
Capacity: "); + sb.Append(maxUser); + sb.Append("
Available: "); + sb.Append(curUser); + sb.Append("
Usage: "); + sb.Append((maxUser - curUser) * 100 / maxUser); + sb.Append("%

IOCP Threads:
Capacity: "); + sb.Append(maxIOCP); + sb.Append("
Available: "); + sb.Append(curIOCP); + sb.Append("
Usage: "); + sb.Append((maxIOCP - curIOCP) * 100 / maxIOCP); + sb.Append("%"); + + AddLabel(20, 200, LabelHue, "Pooling:"); + AddHtml(20, 220, 380, 150, sb.ToString(), true, true); + + AddPageButton(200, 20, GetButtonID(0, 0), "General", AdminGumpPage.Information_General); + AddPageButton(200, 40, GetButtonID(0, 5), "Performance", AdminGumpPage.Information_Perf); + + break; } - - AddButtonLabeled(20, y, GetButtonID(7, 0), "Go to"); - AddButtonLabeled(200, y, GetButtonID(7, 1), "Get"); - y += 20; - - AddButtonLabeled(20, y, GetButtonID(7, 2), "Kick"); - AddButtonLabeled(200, y, GetButtonID(7, 3), "Ban"); - y += 20; - - AddButtonLabeled(20, y, GetButtonID(7, 4), "Properties"); - AddButtonLabeled(200, y, GetButtonID(7, 5), "Skills"); - y += 20; - - AddButtonLabeled(20, y, GetButtonID(7, 6), "Mortal"); - AddButtonLabeled(200, y, GetButtonID(7, 7), "Immortal"); - y += 20; - - AddButtonLabeled(20, y, GetButtonID(7, 8), "Squelch"); - AddButtonLabeled(200, y, GetButtonID(7, 9), "Unsquelch"); - y += 20; - - /*AddButtonLabeled( 20, y, GetButtonID( 7, 10 ), "Hide" ); - AddButtonLabeled( 200, y, GetButtonID( 7, 11 ), "Unhide" ); - y += 20;*/ - - AddButtonLabeled(20, y, GetButtonID(7, 12), "Kill"); - AddButtonLabeled(200, y, GetButtonID(7, 13), "Resurrect"); - - break; - } - case AdminGumpPage.Accounts_Shared: - { - List>> sharedAccounts; - - if (m_List == null) + case AdminGumpPage.Administer_WorldBuilding: { - sharedAccounts = GetAllSharedAccounts(); - m_List = Utility.CastListContravariant>, object>(sharedAccounts); + AddHtml(10, 125, 400, 20, Color(Center("Generating"), LabelColor32)); + + AddButtonLabeled(20, 150, GetButtonID(3, 100), "Documentation"); + AddButtonLabeled(220, 150, GetButtonID(3, 107), "Rebuild Categorization"); + + AddButtonLabeled(20, 175, GetButtonID(3, 101), "Teleporters"); + AddButtonLabeled(220, 175, GetButtonID(3, 102), "Moongates"); + + AddButtonLabeled(20, 200, GetButtonID(3, 103), "Vendors"); + AddButtonLabeled(220, 200, GetButtonID(3, 106), "Decoration"); + + AddButtonLabeled(20, 225, GetButtonID(3, 104), "Doors"); + AddButtonLabeled(220, 225, GetButtonID(3, 105), "Signs"); + + AddHtml(20, 275, 400, 30, Color(Center("Statics"), LabelColor32)); + + AddButtonLabeled(20, 300, GetButtonID(3, 110), "Freeze (Target)"); + AddButtonLabeled(20, 325, GetButtonID(3, 111), "Freeze (World)"); + AddButtonLabeled(20, 350, GetButtonID(3, 112), "Freeze (Map)"); + + AddButtonLabeled(220, 300, GetButtonID(3, 120), "Unfreeze (Target)"); + AddButtonLabeled(220, 325, GetButtonID(3, 121), "Unfreeze (World)"); + AddButtonLabeled(220, 350, GetButtonID(3, 122), "Unfreeze (Map)"); + + goto case AdminGumpPage.Administer; } - else + case AdminGumpPage.Administer_Server: { - sharedAccounts = Utility.CastListCovariant>>(m_List); - } + AddHtml(10, 125, 400, 20, Color(Center("Server"), LabelColor32)); - AddLabelCropped(12, 120, 60, 20, LabelHue, "Count"); - AddLabelCropped(72, 120, 120, 20, LabelHue, "Address"); - AddLabelCropped(192, 120, 180, 20, LabelHue, "Accounts"); + AddButtonLabeled(20, 150, GetButtonID(3, 200), "Save"); - if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); - else - AddImage(375, 122, 0x25EA); + /*if (!Core.Service) + {*/ + AddButtonLabeled(20, 180, GetButtonID(3, 201), "Shutdown (With Save)"); + AddButtonLabeled(20, 200, GetButtonID(3, 202), "Shutdown (Without Save)"); - if ((listPage + 1) * 12 < sharedAccounts.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); - else - AddImage(392, 122, 0x25E6); - - if (sharedAccounts.Count == 0) - AddLabel(12, 140, LabelHue, "There are no accounts to display."); - - StringBuilder sb = new StringBuilder(); - - for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < sharedAccounts.Count; ++i, ++index) - { - KeyValuePair> kvp = sharedAccounts[index]; - - IPAddress ipAddr = kvp.Key; - List accts = kvp.Value; - - int offset = 140 + i * 20; - - AddLabelCropped(12, offset, 60, 20, LabelHue, accts.Count.ToString()); - AddLabelCropped(72, offset, 120, 20, LabelHue, ipAddr.ToString()); - - if (sb.Length > 0) - sb.Length = 0; - - for (int j = 0; j < accts.Count; ++j) + AddButtonLabeled(20, 230, GetButtonID(3, 203), "Shutdown & Restart (With Save)"); + AddButtonLabeled(20, 250, GetButtonID(3, 204), "Shutdown & Restart (Without Save)"); + /*} + else { - if (j > 0) - sb.Append(", "); + AddLabel( 20, 215, LabelHue, "Shutdown/Restart not available." ); + }*/ - if (j < 4) + AddHtml(10, 295, 400, 20, Color(Center("Broadcast"), LabelColor32)); + + AddTextField(20, 320, 380, 20, 0); + AddButtonLabeled(20, 350, GetButtonID(3, 210), "To Everyone"); + AddButtonLabeled(220, 350, GetButtonID(3, 211), "To Staff"); + + goto case AdminGumpPage.Administer; + } + case AdminGumpPage.Administer_Access_Lockdown: + { + AddHtml(10, 125, 400, 20, Color(Center("Server Lockdown"), LabelColor32)); + + AddHtml(20, 150, 380, 80, + Color( + "When enabled, only clients with an access level equal to or greater than the specified lockdown level may access the server. After setting a lockdown level, use the Purge Invalid Clients button to disconnect those clients without access.", + LabelColor32)); + + AccessLevel level = AccountHandler.LockdownLevel; + bool isLockedDown = level > AccessLevel.Player; + + AddSelectedButton(20, 230, GetButtonID(3, 500), "Not Locked Down", !isLockedDown); + AddSelectedButton(20, 260, GetButtonID(3, 504), "Administrators", + isLockedDown && level <= AccessLevel.Administrator); + AddSelectedButton(20, 280, GetButtonID(3, 503), "Seers", isLockedDown && level <= AccessLevel.Seer); + AddSelectedButton(20, 300, GetButtonID(3, 502), "Game Masters", + isLockedDown && level <= AccessLevel.GameMaster); + AddSelectedButton(20, 320, GetButtonID(3, 501), "Counselors", + isLockedDown && level <= AccessLevel.Counselor); + + AddButtonLabeled(20, 350, GetButtonID(3, 510), "Purge Invalid Clients"); + + goto case AdminGumpPage.Administer; + } + case AdminGumpPage.Administer_Access: + { + AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32)); + + AddHtml(10, 155, 400, 20, Color(Center("Connectivity"), LabelColor32)); + + AddButtonLabeled(20, 180, GetButtonID(3, 300), "Kick"); + AddButtonLabeled(220, 180, GetButtonID(3, 301), "Ban"); + + AddButtonLabeled(20, 210, GetButtonID(3, 302), "Firewall"); + AddButtonLabeled(220, 210, GetButtonID(3, 303), "Lockdown"); + + AddHtml(10, 245, 400, 20, Color(Center("Staff"), LabelColor32)); + + AddButtonLabeled(20, 270, GetButtonID(3, 310), "Make Player"); + AddButtonLabeled(20, 290, GetButtonID(3, 311), "Make Counselor"); + AddButtonLabeled(20, 310, GetButtonID(3, 312), "Make Game Master"); + AddButtonLabeled(20, 330, GetButtonID(3, 313), "Make Seer"); + + if (from.AccessLevel > AccessLevel.Administrator) + { + AddButtonLabeled(220, 270, GetButtonID(3, 314), "Make Administrator"); + + if (from.AccessLevel > AccessLevel.Developer) { - Account acct = accts[j]; + AddButtonLabeled(220, 290, GetButtonID(3, 315), "Make Developer"); - sb.Append(acct.Username); + if (from.AccessLevel >= AccessLevel.Owner) + AddButtonLabeled(220, 310, GetButtonID(3, 316), "Make Owner"); + } + } + + goto case AdminGumpPage.Administer; + } + case AdminGumpPage.Administer_Commands: + { + AddHtml(10, 125, 400, 20, Color(Center("Commands"), LabelColor32)); + + AddButtonLabeled(20, 150, GetButtonID(3, 400), "Add"); + AddButtonLabeled(220, 150, GetButtonID(3, 401), "Remove"); + + AddButtonLabeled(20, 170, GetButtonID(3, 402), "Dupe"); + AddButtonLabeled(220, 170, GetButtonID(3, 403), "Dupe in bag"); + + AddButtonLabeled(20, 200, GetButtonID(3, 404), "Properties"); + AddButtonLabeled(220, 200, GetButtonID(3, 405), "Skills"); + + AddButtonLabeled(20, 230, GetButtonID(3, 406), "Mortal"); + AddButtonLabeled(220, 230, GetButtonID(3, 407), "Immortal"); + + AddButtonLabeled(20, 250, GetButtonID(3, 408), "Squelch"); + AddButtonLabeled(220, 250, GetButtonID(3, 409), "Unsquelch"); + + AddButtonLabeled(20, 270, GetButtonID(3, 410), "Freeze"); + AddButtonLabeled(220, 270, GetButtonID(3, 411), "Unfreeze"); + + AddButtonLabeled(20, 290, GetButtonID(3, 412), "Hide"); + AddButtonLabeled(220, 290, GetButtonID(3, 413), "Unhide"); + + AddButtonLabeled(20, 310, GetButtonID(3, 414), "Kill"); + AddButtonLabeled(220, 310, GetButtonID(3, 415), "Resurrect"); + + AddButtonLabeled(20, 330, GetButtonID(3, 416), "Move"); + AddButtonLabeled(220, 330, GetButtonID(3, 417), "Wipe"); + + AddButtonLabeled(20, 350, GetButtonID(3, 418), "Teleport"); + AddButtonLabeled(220, 350, GetButtonID(3, 419), "Teleport (Multiple)"); + + goto case AdminGumpPage.Administer; + } + case AdminGumpPage.Administer: + { + AddPageButton(200, 20, GetButtonID(3, 0), "World Building", AdminGumpPage.Administer_WorldBuilding); + AddPageButton(200, 40, GetButtonID(3, 1), "Server", AdminGumpPage.Administer_Server); + AddPageButton(200, 60, GetButtonID(3, 2), "Access", AdminGumpPage.Administer_Access, + AdminGumpPage.Administer_Access_Lockdown); + AddPageButton(200, 80, GetButtonID(3, 3), "Commands", AdminGumpPage.Administer_Commands); + + break; + } + case AdminGumpPage.Clients: + { + if (m_List == null) + { + List states = TcpServer.Instances; + states.Sort(NetStateComparer.Instance); + + m_List = states.ToList(); + } + + AddClientHeader(); + + AddLabelCropped(12, 120, 81, 20, LabelHue, "Name"); + AddLabelCropped(95, 120, 81, 20, LabelHue, "Account"); + AddLabelCropped(178, 120, 81, 20, LabelHue, "Access Level"); + AddLabelCropped(273, 120, 109, 20, LabelHue, "IP Address"); + + if (listPage > 0) + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); + else + AddImage(375, 122, 0x25EA); + + if ((listPage + 1) * 12 < m_List.Count) + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); + else + AddImage(392, 122, 0x25E6); + + if (m_List.Count == 0) + AddLabel(12, 140, LabelHue, "There are no clients to display."); + + for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index) + { + if (!(m_List[index] is NetState ns)) + continue; + + Mobile m = ns.Mobile; + Account a = ns.Account as Account; + int offset = 140 + i * 20; + + if (m == null) + AddLabelCropped(12, offset, 81, 20, LabelHue, "(logging in)"); + else + AddLabelCropped(12, offset, 81, 20, GetHueFor(m), m.Name); + AddLabelCropped(95, offset, 81, 20, LabelHue, a == null ? "(no account)" : a.Username); + AddLabelCropped(178, offset, 81, 20, LabelHue, + m == null + ? a != null ? FormatAccessLevel(a.AccessLevel) : "" + : FormatAccessLevel(m.AccessLevel)); + AddLabelCropped(273, offset, 109, 20, LabelHue, ns.ToString()); + + if (a != null || m != null) + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(4, index + 2)); + } + + break; + } + case AdminGumpPage.ClientInfo: + { + if (!(state is Mobile m)) + break; + + AddClientHeader(); + + AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32)); + + int y = 146; + + AddLabel(20, y, LabelHue, "Name:"); + AddLabel(200, y, GetHueFor(m), m.Name); + y += 20; + + Account a = m.Account as Account; + + AddLabel(20, y, LabelHue, "Account:"); + AddLabel(200, y, a?.Banned == true ? RedHue : LabelHue, a == null ? "(no account)" : a.Username); + AddButton(380, y, 0xFA5, 0xFA7, GetButtonID(7, 14)); + y += 20; + + NetState ns = m.NetState; + + if (ns == null) + { + AddLabel(20, y, LabelHue, "Address:"); + AddLabel(200, y, RedHue, "Offline"); + y += 20; + + AddLabel(20, y, LabelHue, "Location:"); + AddLabel(200, y, LabelHue, $"{m.Location} [{m.Map}]"); + y += 44; + } + else + { + AddLabel(20, y, LabelHue, "Address:"); + AddLabel(200, y, GreenHue, ns.ToString()); + y += 20; + + ClientVersion v = ns.Version; + + AddLabel(20, y, LabelHue, "Version:"); + AddLabel(200, y, LabelHue, v == null ? "(null)" : v.ToString()); + y += 20; + + AddLabel(20, y, LabelHue, "Location:"); + AddLabel(200, y, LabelHue, $"{m.Location} [{m.Map}]"); + y += 24; + } + + AddButtonLabeled(20, y, GetButtonID(7, 0), "Go to"); + AddButtonLabeled(200, y, GetButtonID(7, 1), "Get"); + y += 20; + + AddButtonLabeled(20, y, GetButtonID(7, 2), "Kick"); + AddButtonLabeled(200, y, GetButtonID(7, 3), "Ban"); + y += 20; + + AddButtonLabeled(20, y, GetButtonID(7, 4), "Properties"); + AddButtonLabeled(200, y, GetButtonID(7, 5), "Skills"); + y += 20; + + AddButtonLabeled(20, y, GetButtonID(7, 6), "Mortal"); + AddButtonLabeled(200, y, GetButtonID(7, 7), "Immortal"); + y += 20; + + AddButtonLabeled(20, y, GetButtonID(7, 8), "Squelch"); + AddButtonLabeled(200, y, GetButtonID(7, 9), "Unsquelch"); + y += 20; + + /*AddButtonLabeled( 20, y, GetButtonID( 7, 10 ), "Hide" ); + AddButtonLabeled( 200, y, GetButtonID( 7, 11 ), "Unhide" ); + y += 20;*/ + + AddButtonLabeled(20, y, GetButtonID(7, 12), "Kill"); + AddButtonLabeled(200, y, GetButtonID(7, 13), "Resurrect"); + + break; + } + case AdminGumpPage.Accounts_Shared: + { + List>> sharedAccounts; + + if (m_List == null) + { + sharedAccounts = GetAllSharedAccounts(); + m_List = Utility.CastListContravariant>, object>(sharedAccounts); + } + else + { + sharedAccounts = Utility.CastListCovariant>>(m_List); + } + + AddLabelCropped(12, 120, 60, 20, LabelHue, "Count"); + AddLabelCropped(72, 120, 120, 20, LabelHue, "Address"); + AddLabelCropped(192, 120, 180, 20, LabelHue, "Accounts"); + + if (listPage > 0) + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); + else + AddImage(375, 122, 0x25EA); + + if ((listPage + 1) * 12 < sharedAccounts.Count) + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); + else + AddImage(392, 122, 0x25E6); + + if (sharedAccounts.Count == 0) + AddLabel(12, 140, LabelHue, "There are no accounts to display."); + + StringBuilder sb = new StringBuilder(); + + for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < sharedAccounts.Count; ++i, ++index) + { + KeyValuePair> kvp = sharedAccounts[index]; + + IPAddress ipAddr = kvp.Key; + List accts = kvp.Value; + + int offset = 140 + i * 20; + + AddLabelCropped(12, offset, 60, 20, LabelHue, accts.Count.ToString()); + AddLabelCropped(72, offset, 120, 20, LabelHue, ipAddr.ToString()); + + if (sb.Length > 0) + sb.Length = 0; + + for (int j = 0; j < accts.Count; ++j) + { + if (j > 0) + sb.Append(", "); + + if (j < 4) + { + Account acct = accts[j]; + + sb.Append(acct.Username); + } + else + { + sb.Append("..."); + break; + } + } + + AddLabelCropped(192, offset, 180, 20, LabelHue, sb.ToString()); + + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); + } + + break; + } + case AdminGumpPage.Accounts: + { + m_List ??= new List(); + + List rads = state as List; + + AddAccountHeader(); + + if (rads == null) + AddLabelCropped(12, 120, 120, 20, LabelHue, "Name"); + else + AddLabelCropped(32, 120, 100, 20, LabelHue, "Name"); + + AddLabelCropped(132, 120, 120, 20, LabelHue, "Access Level"); + AddLabelCropped(252, 120, 120, 20, LabelHue, "Status"); + + if (listPage > 0) + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); + else + AddImage(375, 122, 0x25EA); + + if ((listPage + 1) * 12 < m_List.Count) + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); + else + AddImage(392, 122, 0x25E6); + + if (m_List.Count == 0) + AddLabel(12, 140, LabelHue, "There are no accounts to display."); + + if (rads != null && notice == null) + { + AddButtonLabeled(10, 390, GetButtonID(5, 27), "Ban marked"); + AddButtonLabeled(10, 410, GetButtonID(5, 28), "Delete marked"); + + AddButtonLabeled(210, 390, GetButtonID(5, 29), "Mark all"); + AddButtonLabeled(210, 410, GetButtonID(5, 35), "Unmark house owners"); + } + + for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index) + { + if (!(m_List[index] is Account a)) + continue; + + int offset = 140 + i * 20; + + GetAccountInfo(a, out AccessLevel accessLevel, out bool online); + + if (rads == null) + { + AddLabelCropped(12, offset, 120, 20, LabelHue, a.Username); } else { - sb.Append("..."); - break; + AddCheck(10, offset, 0xD2, 0xD3, rads.Contains(a), index); + AddLabelCropped(32, offset, 100, 20, LabelHue, a.Username); + } + + AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(accessLevel)); + + if (online) + AddLabelCropped(252, offset, 120, 20, GreenHue, "Online"); + else if (a.Banned) + AddLabelCropped(252, offset, 120, 20, RedHue, "Banned"); + else + AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); + + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); + } + + break; + } + case AdminGumpPage.AccountDetails: + { + AddPageButton(190, 10, GetButtonID(5, 0), "Information", AdminGumpPage.AccountDetails_Information, + AdminGumpPage.AccountDetails_ChangeAccess, AdminGumpPage.AccountDetails_ChangePassword); + AddPageButton(190, 30, GetButtonID(5, 1), "Characters", AdminGumpPage.AccountDetails_Characters); + AddPageButton(190, 50, GetButtonID(5, 13), "Access", AdminGumpPage.AccountDetails_Access, + AdminGumpPage.AccountDetails_Access_ClientIPs, AdminGumpPage.AccountDetails_Access_Restrictions); + AddPageButton(190, 70, GetButtonID(5, 2), "Comments", AdminGumpPage.AccountDetails_Comments); + AddPageButton(190, 90, GetButtonID(5, 3), "Tags", AdminGumpPage.AccountDetails_Tags); + break; + } + case AdminGumpPage.AccountDetails_ChangePassword: + { + if (!(state is Account a)) + break; + + AddHtml(10, 125, 400, 20, Color(Center("Change Password"), LabelColor32)); + + AddLabel(20, 150, LabelHue, "Username:"); + AddLabel(200, 150, LabelHue, a.Username); + + AddLabel(20, 180, LabelHue, "Password:"); + AddTextField(200, 180, 160, 20, 0); + + AddLabel(20, 210, LabelHue, "Confirm:"); + AddTextField(200, 210, 160, 20, 1); + + AddButtonLabeled(20, 240, GetButtonID(5, 12), "Submit Change"); + + goto case AdminGumpPage.AccountDetails; + } + case AdminGumpPage.AccountDetails_ChangeAccess: + { + if (!(state is Account a)) + break; + + AddHtml(10, 125, 400, 20, Color(Center("Change Access Level"), LabelColor32)); + + AddLabel(20, 150, LabelHue, "Username:"); + AddLabel(200, 150, LabelHue, a.Username); + + AddLabel(20, 170, LabelHue, "Current Level:"); + AddLabel(200, 170, LabelHue, FormatAccessLevel(a.AccessLevel)); + + AddButtonLabeled(20, 200, GetButtonID(5, 20), "Player"); + AddButtonLabeled(20, 220, GetButtonID(5, 21), "Counselor"); + AddButtonLabeled(20, 240, GetButtonID(5, 22), "Game Master"); + AddButtonLabeled(20, 260, GetButtonID(5, 23), "Seer"); + + if (from.AccessLevel > AccessLevel.Administrator) + { + AddButtonLabeled(20, 280, GetButtonID(5, 24), "Administrator"); + + if (from.AccessLevel > AccessLevel.Developer) + { + AddButtonLabeled(20, 300, GetButtonID(5, 33), "Developer"); + + if (from.AccessLevel >= AccessLevel.Owner) + AddButtonLabeled(20, 320, GetButtonID(5, 34), "Owner"); } } - AddLabelCropped(192, offset, 180, 20, LabelHue, sb.ToString()); - - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); + goto case AdminGumpPage.AccountDetails; } - - break; - } - case AdminGumpPage.Accounts: - { - m_List ??= new List(); - - List rads = state as List; - - AddAccountHeader(); - - if (rads == null) - AddLabelCropped(12, 120, 120, 20, LabelHue, "Name"); - else - AddLabelCropped(32, 120, 100, 20, LabelHue, "Name"); - - AddLabelCropped(132, 120, 120, 20, LabelHue, "Access Level"); - AddLabelCropped(252, 120, 120, 20, LabelHue, "Status"); - - if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); - else - AddImage(375, 122, 0x25EA); - - if ((listPage + 1) * 12 < m_List.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); - else - AddImage(392, 122, 0x25E6); - - if (m_List.Count == 0) - AddLabel(12, 140, LabelHue, "There are no accounts to display."); - - if (rads != null && notice == null) - { - AddButtonLabeled(10, 390, GetButtonID(5, 27), "Ban marked"); - AddButtonLabeled(10, 410, GetButtonID(5, 28), "Delete marked"); - - AddButtonLabeled(210, 390, GetButtonID(5, 29), "Mark all"); - AddButtonLabeled(210, 410, GetButtonID(5, 35), "Unmark house owners"); - } - - for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < m_List.Count; ++i, ++index) - { - if (!(m_List[index] is Account a)) - continue; - - int offset = 140 + i * 20; - - GetAccountInfo(a, out AccessLevel accessLevel, out bool online); - - if (rads == null) - { - AddLabelCropped(12, offset, 120, 20, LabelHue, a.Username); - } - else - { - AddCheck(10, offset, 0xD2, 0xD3, rads.Contains(a), index); - AddLabelCropped(32, offset, 100, 20, LabelHue, a.Username); - } - - AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(accessLevel)); - - if (online) - AddLabelCropped(252, offset, 120, 20, GreenHue, "Online"); - else if (a.Banned) - AddLabelCropped(252, offset, 120, 20, RedHue, "Banned"); - else - AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); - - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); - } - - break; - } - case AdminGumpPage.AccountDetails: - { - AddPageButton(190, 10, GetButtonID(5, 0), "Information", AdminGumpPage.AccountDetails_Information, - AdminGumpPage.AccountDetails_ChangeAccess, AdminGumpPage.AccountDetails_ChangePassword); - AddPageButton(190, 30, GetButtonID(5, 1), "Characters", AdminGumpPage.AccountDetails_Characters); - AddPageButton(190, 50, GetButtonID(5, 13), "Access", AdminGumpPage.AccountDetails_Access, - AdminGumpPage.AccountDetails_Access_ClientIPs, AdminGumpPage.AccountDetails_Access_Restrictions); - AddPageButton(190, 70, GetButtonID(5, 2), "Comments", AdminGumpPage.AccountDetails_Comments); - AddPageButton(190, 90, GetButtonID(5, 3), "Tags", AdminGumpPage.AccountDetails_Tags); - break; - } - case AdminGumpPage.AccountDetails_ChangePassword: - { - if (!(state is Account a)) - break; - - AddHtml(10, 125, 400, 20, Color(Center("Change Password"), LabelColor32)); - - AddLabel(20, 150, LabelHue, "Username:"); - AddLabel(200, 150, LabelHue, a.Username); - - AddLabel(20, 180, LabelHue, "Password:"); - AddTextField(200, 180, 160, 20, 0); - - AddLabel(20, 210, LabelHue, "Confirm:"); - AddTextField(200, 210, 160, 20, 1); - - AddButtonLabeled(20, 240, GetButtonID(5, 12), "Submit Change"); - - goto case AdminGumpPage.AccountDetails; - } - case AdminGumpPage.AccountDetails_ChangeAccess: - { - if (!(state is Account a)) - break; - - AddHtml(10, 125, 400, 20, Color(Center("Change Access Level"), LabelColor32)); - - AddLabel(20, 150, LabelHue, "Username:"); - AddLabel(200, 150, LabelHue, a.Username); - - AddLabel(20, 170, LabelHue, "Current Level:"); - AddLabel(200, 170, LabelHue, FormatAccessLevel(a.AccessLevel)); - - AddButtonLabeled(20, 200, GetButtonID(5, 20), "Player"); - AddButtonLabeled(20, 220, GetButtonID(5, 21), "Counselor"); - AddButtonLabeled(20, 240, GetButtonID(5, 22), "Game Master"); - AddButtonLabeled(20, 260, GetButtonID(5, 23), "Seer"); - - if (from.AccessLevel > AccessLevel.Administrator) - { - AddButtonLabeled(20, 280, GetButtonID(5, 24), "Administrator"); - - if (from.AccessLevel > AccessLevel.Developer) - { - AddButtonLabeled(20, 300, GetButtonID(5, 33), "Developer"); - - if (from.AccessLevel >= AccessLevel.Owner) - AddButtonLabeled(20, 320, GetButtonID(5, 34), "Owner"); - } - } - - goto case AdminGumpPage.AccountDetails; - } case AdminGumpPage.AccountDetails_Information: - { - if (!(state is Account a)) - break; - - int charCount = 0; - - for (int i = 0; i < a.Length; ++i) - if (a[i] != null) - ++charCount; - - AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32)); - - AddLabel(20, 150, LabelHue, "Username:"); - AddLabel(200, 150, LabelHue, a.Username); - - AddLabel(20, 170, LabelHue, "Access Level:"); - AddLabel(200, 170, LabelHue, FormatAccessLevel(a.AccessLevel)); - - AddLabel(20, 190, LabelHue, "Status:"); - AddLabel(200, 190, a.Banned ? RedHue : GreenHue, a.Banned ? "Banned" : "Active"); - - if (a.Banned && a.GetBanTags(out DateTime banTime, out TimeSpan banDuration)) { - if (banDuration == TimeSpan.MaxValue) + if (!(state is Account a)) + break; + + int charCount = 0; + + for (int i = 0; i < a.Length; ++i) + if (a[i] != null) + ++charCount; + + AddHtml(10, 125, 400, 20, Color(Center("Information"), LabelColor32)); + + AddLabel(20, 150, LabelHue, "Username:"); + AddLabel(200, 150, LabelHue, a.Username); + + AddLabel(20, 170, LabelHue, "Access Level:"); + AddLabel(200, 170, LabelHue, FormatAccessLevel(a.AccessLevel)); + + AddLabel(20, 190, LabelHue, "Status:"); + AddLabel(200, 190, a.Banned ? RedHue : GreenHue, a.Banned ? "Banned" : "Active"); + + if (a.Banned && a.GetBanTags(out DateTime banTime, out TimeSpan banDuration)) { - AddLabel(250, 190, LabelHue, "(Infinite)"); + if (banDuration == TimeSpan.MaxValue) + { + AddLabel(250, 190, LabelHue, "(Infinite)"); + } + else if (banDuration == TimeSpan.Zero) + { + AddLabel(250, 190, LabelHue, "(Zero)"); + } + else + { + TimeSpan remaining = DateTime.UtcNow - banTime; + + if (remaining < TimeSpan.Zero) + remaining = TimeSpan.Zero; + else if (remaining > banDuration) + remaining = banDuration; + + double remMinutes = remaining.TotalMinutes; + double totMinutes = banDuration.TotalMinutes; + + double perc = remMinutes / totMinutes; + + AddLabel(250, 190, LabelHue, $"{FormatTimeSpan(banDuration)} [{perc * 100:F0}%]"); + } } - else if (banDuration == TimeSpan.Zero) - { - AddLabel(250, 190, LabelHue, "(Zero)"); - } - else - { - TimeSpan remaining = DateTime.UtcNow - banTime; - - if (remaining < TimeSpan.Zero) - remaining = TimeSpan.Zero; - else if (remaining > banDuration) - remaining = banDuration; - - double remMinutes = remaining.TotalMinutes; - double totMinutes = banDuration.TotalMinutes; - - double perc = remMinutes / totMinutes; - - AddLabel(250, 190, LabelHue, $"{FormatTimeSpan(banDuration)} [{perc * 100:F0}%]"); - } - } - else if (a.Banned) - { - AddLabel(250, 190, LabelHue, "(Unspecified)"); - } - - AddLabel(20, 210, LabelHue, "Created:"); - AddLabel(200, 210, LabelHue, a.Created.ToString()); - - AddLabel(20, 230, LabelHue, "Last Login:"); - AddLabel(200, 230, LabelHue, a.LastLogin.ToString()); - - AddLabel(20, 250, LabelHue, "Character Count:"); - AddLabel(200, 250, LabelHue, charCount.ToString()); - - AddLabel(20, 270, LabelHue, "Comment Count:"); - AddLabel(200, 270, LabelHue, a.Comments.Count.ToString()); - - AddLabel(20, 290, LabelHue, "Tag Count:"); - AddLabel(200, 290, LabelHue, a.Tags.Count.ToString()); - - AddButtonLabeled(20, 320, GetButtonID(5, 8), "Change Password"); - AddButtonLabeled(200, 320, GetButtonID(5, 9), "Change Access Level"); - - if (!a.Banned) - AddButtonLabeled(20, 350, GetButtonID(5, 10), "Ban Account"); - else - AddButtonLabeled(20, 350, GetButtonID(5, 11), "Unban Account"); - - AddButtonLabeled(200, 350, GetButtonID(5, 25), "Delete Account"); - - goto case AdminGumpPage.AccountDetails; - } - case AdminGumpPage.AccountDetails_Access: - { - if (!(state is Account a)) - break; - - AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32)); - - AddPageButton(20, 150, GetButtonID(5, 14), "View client addresses", - AdminGumpPage.AccountDetails_Access_ClientIPs); - AddPageButton(20, 170, GetButtonID(5, 15), "Manage restrictions", - AdminGumpPage.AccountDetails_Access_Restrictions); - - goto case AdminGumpPage.AccountDetails; - } - case AdminGumpPage.AccountDetails_Access_ClientIPs: - { - if (!(state is Account a)) - break; - - List ipAddresses; - - if (m_List == null) - { - ipAddresses = a.LoginIPs.ToList(); - m_List = Utility.CastListContravariant(ipAddresses); - } - else - ipAddresses = Utility.CastListCovariant(m_List); - - AddHtml(10, 195, 400, 20, Color(Center("Client Addresses"), LabelColor32)); - - AddButtonLabeled(227, 225, GetButtonID(5, 16), "View all shared accounts"); - AddButtonLabeled(227, 245, GetButtonID(5, 17), "Ban all shared accounts"); - AddButtonLabeled(227, 265, GetButtonID(5, 18), "Firewall all addresses"); - AddButtonLabeled(227, 285, GetButtonID(5, 36), "Clear all addresses"); - - AddHtml(225, 315, 180, 80, Color("List of IP addresses which have accessed this account.", LabelColor32)); - - AddImageTiled(15, 219, 206, 156, 0xBBC); - AddBlackAlpha(16, 220, 204, 154); - - AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32)); - - if (listPage > 0) - AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0)); - else - AddImage(184, 223, 0x25EA); - - if ((listPage + 1) * 6 < ipAddresses.Count) - AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1)); - else - AddImage(201, 223, 0x25E6); - - if (ipAddresses.Count == 0) - AddHtml(18, 243, 200, 60, Color("This account has not yet been accessed.", LabelColor32)); - - for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < ipAddresses.Count; ++i, ++index) - { - AddHtml(18, 243 + i * 22, 114, 20, Color(ipAddresses[index].ToString(), LabelColor32)); - AddButton(130, 242 + i * 22, 0xFA2, 0xFA4, GetButtonID(8, index)); - AddButton(160, 242 + i * 22, 0xFA8, 0xFAA, GetButtonID(9, index)); - AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(10, index)); - } - - goto case AdminGumpPage.AccountDetails_Access; - } - case AdminGumpPage.AccountDetails_Access_Restrictions: - { - if (!(state is Account a)) - break; - - List ipRestrictions; - - if (m_List == null) - { - ipRestrictions = a.IPRestrictions.ToList(); - m_List = Utility.CastListContravariant(ipRestrictions); - } - else - ipRestrictions = Utility.CastListCovariant(m_List); - - AddHtml(10, 195, 400, 20, Color(Center("Address Restrictions"), LabelColor32)); - - AddTextField(227, 225, 120, 20, 0); - - AddButtonLabeled(352, 225, GetButtonID(5, 19), "Add"); - - AddHtml(225, 255, 180, 120, - Color( - "Any clients connecting from an address not in this list will be rejected. Or, if the list is empty, any client may connect.", - LabelColor32)); - - AddImageTiled(15, 219, 206, 156, 0xBBC); - AddBlackAlpha(16, 220, 204, 154); - - AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32)); - - if (listPage > 0) - AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0)); - else - AddImage(184, 223, 0x25EA); - - if ((listPage + 1) * 6 < ipRestrictions.Count) - AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1)); - else - AddImage(201, 223, 0x25E6); - - if (ipRestrictions.Count == 0) - AddHtml(18, 243, 200, 60, Color("There are no addresses in this list.", LabelColor32)); - - for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < ipRestrictions.Count; ++i, ++index) - { - AddHtml(18, 243 + i * 22, 114, 20, Color(ipRestrictions[index], LabelColor32)); - AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(8, index)); - } - - goto case AdminGumpPage.AccountDetails_Access; - } - case AdminGumpPage.AccountDetails_Characters: - { - if (!(state is Account a)) - break; - - AddHtml(10, 125, 400, 20, Color(Center("Characters"), LabelColor32)); - - AddLabelCropped(12, 150, 120, 20, LabelHue, "Name"); - AddLabelCropped(132, 150, 120, 20, LabelHue, "Access Level"); - AddLabelCropped(252, 150, 120, 20, LabelHue, "Status"); - - int index = 0; - - for (int i = 0; i < a.Length; ++i) - { - Mobile m = a[i]; - - if (m == null) - continue; - - int offset = 170 + index * 20; - - AddLabelCropped(12, offset, 120, 20, GetHueFor(m), m.Name); - AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(m.AccessLevel)); - - if (m.NetState != null) - AddLabelCropped(252, offset, 120, 20, GreenHue, "Online"); - else - AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); - - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, i + 50)); - - ++index; - } - - if (index == 0) - AddLabel(12, 170, LabelHue, "The character list is empty."); - - goto case AdminGumpPage.AccountDetails; - } - case AdminGumpPage.AccountDetails_Comments: - { - if (!(state is Account a)) - break; - - AddHtml(10, 125, 400, 20, Color(Center("Comments"), LabelColor32)); - - AddButtonLabeled(20, 150, GetButtonID(5, 4), "Add Comment"); - - StringBuilder sb = new StringBuilder(); - - if (a.Comments.Count == 0) - sb.Append("There are no comments for this account."); - - for (int i = 0; i < a.Comments.Count; ++i) - { - if (i > 0) - sb.Append("

"); - - AccountComment c = a.Comments[i]; - - sb.AppendFormat("[{0} on {1}]
{2}", c.AddedBy, c.LastModified, c.Content); - } - - AddHtml(20, 180, 380, 190, sb.ToString(), true, true); - - goto case AdminGumpPage.AccountDetails; - } - case AdminGumpPage.AccountDetails_Tags: - { - if (!(state is Account a)) - break; - - AddHtml(10, 125, 400, 20, Color(Center("Tags"), LabelColor32)); - - AddButtonLabeled(20, 150, GetButtonID(5, 5), "Add Tag"); - - StringBuilder sb = new StringBuilder(); - - if (a.Tags.Count == 0) - sb.Append("There are no tags for this account."); - - for (int i = 0; i < a.Tags.Count; ++i) - { - if (i > 0) - sb.Append("
"); - - AccountTag tag = a.Tags[i]; - - sb.AppendFormat("{0} = {1}", tag.Name, tag.Value); - } - - AddHtml(20, 180, 380, 190, sb.ToString(), true, true); - - goto case AdminGumpPage.AccountDetails; - } - case AdminGumpPage.Firewall: - { - AddFirewallHeader(); - - List firewallEntries; - - if (m_List == null) - { - firewallEntries = Firewall.List; - m_List = Utility.CastListContravariant(firewallEntries); - } - else - firewallEntries = Utility.CastListCovariant(m_List); - - AddLabelCropped(12, 120, 358, 20, LabelHue, "IP Address"); - - if (listPage > 0) - AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); - else - AddImage(375, 122, 0x25EA); - - if ((listPage + 1) * 12 < firewallEntries.Count) - AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); - else - AddImage(392, 122, 0x25E6); - - if (firewallEntries.Count == 0) - AddLabel(12, 140, LabelHue, "The firewall list is empty."); - - for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < firewallEntries.Count; ++i, ++index) - { - Firewall.IFirewallEntry firewallEntry = firewallEntries[index]; - - int offset = 140 + i * 20; - - AddLabelCropped(12, offset, 358, 20, LabelHue, firewallEntry.ToString()); - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(6, index + 4)); - } - - break; - } - case AdminGumpPage.FirewallInfo: - { - AddFirewallHeader(); - - if (!(state is Firewall.IFirewallEntry firewallEntry)) - break; - - AddHtml(10, 125, 400, 20, Color(Center(firewallEntry.ToString()), LabelColor32)); - - AddButtonLabeled(20, 150, GetButtonID(6, 3), "Remove"); - - AddHtml(10, 175, 400, 20, Color(Center("Potentially Affected Accounts"), LabelColor32)); - - List blockedAccts; - - if (m_List == null) - { - blockedAccts = new List(); - - foreach (IAccount ia in Accounts.GetAccounts()) - { - Account acct = (Account)ia; - - IPAddress[] loginList = acct.LoginIPs; - - bool contains = false; - - for (int i = 0; !contains && i < loginList.Length; ++i) - if (firewallEntry.IsBlocked(loginList[i])) - { - blockedAccts.Add(acct); - break; - } - } - - blockedAccts.Sort(AccountComparer.Instance); - m_List = Utility.CastListContravariant(blockedAccts); - } - else - blockedAccts = Utility.CastListCovariant(m_List); - - if (listPage > 0) - AddButton(375, 177, 0x15E3, 0x15E7, GetButtonID(1, 0)); - else - AddImage(375, 177, 0x25EA); - - if ((listPage + 1) * 12 < blockedAccts.Count) - AddButton(392, 177, 0x15E1, 0x15E5, GetButtonID(1, 1)); - else - AddImage(392, 177, 0x25E6); - - if (blockedAccts.Count == 0) - AddLabelCropped(12, 200, 398, 20, LabelHue, "No accounts found."); - - for (int i = 0, index = listPage * 9; i < 9 && index >= 0 && index < blockedAccts.Count; ++i, ++index) - { - Account a = blockedAccts[index]; - - int offset = 200 + i * 20; - - GetAccountInfo(a, out AccessLevel accessLevel, out bool online); - - AddLabelCropped(12, offset, 120, 20, LabelHue, a.Username); - AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(accessLevel)); - - if (online) - AddLabelCropped(252, offset, 120, 20, GreenHue, "Online"); else if (a.Banned) - AddLabelCropped(252, offset, 120, 20, RedHue, "Banned"); + { + AddLabel(250, 190, LabelHue, "(Unspecified)"); + } + + AddLabel(20, 210, LabelHue, "Created:"); + AddLabel(200, 210, LabelHue, a.Created.ToString()); + + AddLabel(20, 230, LabelHue, "Last Login:"); + AddLabel(200, 230, LabelHue, a.LastLogin.ToString()); + + AddLabel(20, 250, LabelHue, "Character Count:"); + AddLabel(200, 250, LabelHue, charCount.ToString()); + + AddLabel(20, 270, LabelHue, "Comment Count:"); + AddLabel(200, 270, LabelHue, a.Comments.Count.ToString()); + + AddLabel(20, 290, LabelHue, "Tag Count:"); + AddLabel(200, 290, LabelHue, a.Tags.Count.ToString()); + + AddButtonLabeled(20, 320, GetButtonID(5, 8), "Change Password"); + AddButtonLabeled(200, 320, GetButtonID(5, 9), "Change Access Level"); + + if (!a.Banned) + AddButtonLabeled(20, 350, GetButtonID(5, 10), "Ban Account"); else - AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); + AddButtonLabeled(20, 350, GetButtonID(5, 11), "Unban Account"); - AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); + AddButtonLabeled(200, 350, GetButtonID(5, 25), "Delete Account"); + + goto case AdminGumpPage.AccountDetails; } + case AdminGumpPage.AccountDetails_Access: + { + if (!(state is Account a)) + break; - break; - } + AddHtml(10, 125, 400, 20, Color(Center("Access"), LabelColor32)); + + AddPageButton(20, 150, GetButtonID(5, 14), "View client addresses", + AdminGumpPage.AccountDetails_Access_ClientIPs); + AddPageButton(20, 170, GetButtonID(5, 15), "Manage restrictions", + AdminGumpPage.AccountDetails_Access_Restrictions); + + goto case AdminGumpPage.AccountDetails; + } + case AdminGumpPage.AccountDetails_Access_ClientIPs: + { + if (!(state is Account a)) + break; + + List ipAddresses; + + if (m_List == null) + { + ipAddresses = a.LoginIPs.ToList(); + m_List = Utility.CastListContravariant(ipAddresses); + } + else + ipAddresses = Utility.CastListCovariant(m_List); + + AddHtml(10, 195, 400, 20, Color(Center("Client Addresses"), LabelColor32)); + + AddButtonLabeled(227, 225, GetButtonID(5, 16), "View all shared accounts"); + AddButtonLabeled(227, 245, GetButtonID(5, 17), "Ban all shared accounts"); + AddButtonLabeled(227, 265, GetButtonID(5, 18), "Firewall all addresses"); + AddButtonLabeled(227, 285, GetButtonID(5, 36), "Clear all addresses"); + + AddHtml(225, 315, 180, 80, Color("List of IP addresses which have accessed this account.", LabelColor32)); + + AddImageTiled(15, 219, 206, 156, 0xBBC); + AddBlackAlpha(16, 220, 204, 154); + + AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32)); + + if (listPage > 0) + AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0)); + else + AddImage(184, 223, 0x25EA); + + if ((listPage + 1) * 6 < ipAddresses.Count) + AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1)); + else + AddImage(201, 223, 0x25E6); + + if (ipAddresses.Count == 0) + AddHtml(18, 243, 200, 60, Color("This account has not yet been accessed.", LabelColor32)); + + for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < ipAddresses.Count; ++i, ++index) + { + AddHtml(18, 243 + i * 22, 114, 20, Color(ipAddresses[index].ToString(), LabelColor32)); + AddButton(130, 242 + i * 22, 0xFA2, 0xFA4, GetButtonID(8, index)); + AddButton(160, 242 + i * 22, 0xFA8, 0xFAA, GetButtonID(9, index)); + AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(10, index)); + } + + goto case AdminGumpPage.AccountDetails_Access; + } + case AdminGumpPage.AccountDetails_Access_Restrictions: + { + if (!(state is Account a)) + break; + + List ipRestrictions; + + if (m_List == null) + { + ipRestrictions = a.IPRestrictions.ToList(); + m_List = Utility.CastListContravariant(ipRestrictions); + } + else + ipRestrictions = Utility.CastListCovariant(m_List); + + AddHtml(10, 195, 400, 20, Color(Center("Address Restrictions"), LabelColor32)); + + AddTextField(227, 225, 120, 20, 0); + + AddButtonLabeled(352, 225, GetButtonID(5, 19), "Add"); + + AddHtml(225, 255, 180, 120, + Color( + "Any clients connecting from an address not in this list will be rejected. Or, if the list is empty, any client may connect.", + LabelColor32)); + + AddImageTiled(15, 219, 206, 156, 0xBBC); + AddBlackAlpha(16, 220, 204, 154); + + AddHtml(18, 221, 114, 20, Color("IP Address", LabelColor32)); + + if (listPage > 0) + AddButton(184, 223, 0x15E3, 0x15E7, GetButtonID(1, 0)); + else + AddImage(184, 223, 0x25EA); + + if ((listPage + 1) * 6 < ipRestrictions.Count) + AddButton(201, 223, 0x15E1, 0x15E5, GetButtonID(1, 1)); + else + AddImage(201, 223, 0x25E6); + + if (ipRestrictions.Count == 0) + AddHtml(18, 243, 200, 60, Color("There are no addresses in this list.", LabelColor32)); + + for (int i = 0, index = listPage * 6; i < 6 && index >= 0 && index < ipRestrictions.Count; ++i, ++index) + { + AddHtml(18, 243 + i * 22, 114, 20, Color(ipRestrictions[index], LabelColor32)); + AddButton(190, 242 + i * 22, 0xFB1, 0xFB3, GetButtonID(8, index)); + } + + goto case AdminGumpPage.AccountDetails_Access; + } + case AdminGumpPage.AccountDetails_Characters: + { + if (!(state is Account a)) + break; + + AddHtml(10, 125, 400, 20, Color(Center("Characters"), LabelColor32)); + + AddLabelCropped(12, 150, 120, 20, LabelHue, "Name"); + AddLabelCropped(132, 150, 120, 20, LabelHue, "Access Level"); + AddLabelCropped(252, 150, 120, 20, LabelHue, "Status"); + + int index = 0; + + for (int i = 0; i < a.Length; ++i) + { + Mobile m = a[i]; + + if (m == null) + continue; + + int offset = 170 + index * 20; + + AddLabelCropped(12, offset, 120, 20, GetHueFor(m), m.Name); + AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(m.AccessLevel)); + + if (m.NetState != null) + AddLabelCropped(252, offset, 120, 20, GreenHue, "Online"); + else + AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); + + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, i + 50)); + + ++index; + } + + if (index == 0) + AddLabel(12, 170, LabelHue, "The character list is empty."); + + goto case AdminGumpPage.AccountDetails; + } + case AdminGumpPage.AccountDetails_Comments: + { + if (!(state is Account a)) + break; + + AddHtml(10, 125, 400, 20, Color(Center("Comments"), LabelColor32)); + + AddButtonLabeled(20, 150, GetButtonID(5, 4), "Add Comment"); + + StringBuilder sb = new StringBuilder(); + + if (a.Comments.Count == 0) + sb.Append("There are no comments for this account."); + + for (int i = 0; i < a.Comments.Count; ++i) + { + if (i > 0) + sb.Append("

"); + + AccountComment c = a.Comments[i]; + + sb.AppendFormat("[{0} on {1}]
{2}", c.AddedBy, c.LastModified, c.Content); + } + + AddHtml(20, 180, 380, 190, sb.ToString(), true, true); + + goto case AdminGumpPage.AccountDetails; + } + case AdminGumpPage.AccountDetails_Tags: + { + if (!(state is Account a)) + break; + + AddHtml(10, 125, 400, 20, Color(Center("Tags"), LabelColor32)); + + AddButtonLabeled(20, 150, GetButtonID(5, 5), "Add Tag"); + + StringBuilder sb = new StringBuilder(); + + if (a.Tags.Count == 0) + sb.Append("There are no tags for this account."); + + for (int i = 0; i < a.Tags.Count; ++i) + { + if (i > 0) + sb.Append("
"); + + AccountTag tag = a.Tags[i]; + + sb.AppendFormat("{0} = {1}", tag.Name, tag.Value); + } + + AddHtml(20, 180, 380, 190, sb.ToString(), true, true); + + goto case AdminGumpPage.AccountDetails; + } + case AdminGumpPage.Firewall: + { + AddFirewallHeader(); + + List firewallEntries; + + if (m_List == null) + { + firewallEntries = Firewall.List; + m_List = Utility.CastListContravariant(firewallEntries); + } + else + firewallEntries = Utility.CastListCovariant(m_List); + + AddLabelCropped(12, 120, 358, 20, LabelHue, "IP Address"); + + if (listPage > 0) + AddButton(375, 122, 0x15E3, 0x15E7, GetButtonID(1, 0)); + else + AddImage(375, 122, 0x25EA); + + if ((listPage + 1) * 12 < firewallEntries.Count) + AddButton(392, 122, 0x15E1, 0x15E5, GetButtonID(1, 1)); + else + AddImage(392, 122, 0x25E6); + + if (firewallEntries.Count == 0) + AddLabel(12, 140, LabelHue, "The firewall list is empty."); + + for (int i = 0, index = listPage * 12; i < 12 && index >= 0 && index < firewallEntries.Count; ++i, ++index) + { + Firewall.IFirewallEntry firewallEntry = firewallEntries[index]; + + int offset = 140 + i * 20; + + AddLabelCropped(12, offset, 358, 20, LabelHue, firewallEntry.ToString()); + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(6, index + 4)); + } + + break; + } + case AdminGumpPage.FirewallInfo: + { + AddFirewallHeader(); + + if (!(state is Firewall.IFirewallEntry firewallEntry)) + break; + + AddHtml(10, 125, 400, 20, Color(Center(firewallEntry.ToString()), LabelColor32)); + + AddButtonLabeled(20, 150, GetButtonID(6, 3), "Remove"); + + AddHtml(10, 175, 400, 20, Color(Center("Potentially Affected Accounts"), LabelColor32)); + + List blockedAccts; + + if (m_List == null) + { + blockedAccts = new List(); + + foreach (IAccount ia in Accounts.GetAccounts()) + { + Account acct = (Account)ia; + + IPAddress[] loginList = acct.LoginIPs; + + bool contains = false; + + for (int i = 0; !contains && i < loginList.Length; ++i) + if (firewallEntry.IsBlocked(loginList[i])) + { + blockedAccts.Add(acct); + break; + } + } + + blockedAccts.Sort(AccountComparer.Instance); + m_List = Utility.CastListContravariant(blockedAccts); + } + else + blockedAccts = Utility.CastListCovariant(m_List); + + if (listPage > 0) + AddButton(375, 177, 0x15E3, 0x15E7, GetButtonID(1, 0)); + else + AddImage(375, 177, 0x25EA); + + if ((listPage + 1) * 12 < blockedAccts.Count) + AddButton(392, 177, 0x15E1, 0x15E5, GetButtonID(1, 1)); + else + AddImage(392, 177, 0x25E6); + + if (blockedAccts.Count == 0) + AddLabelCropped(12, 200, 398, 20, LabelHue, "No accounts found."); + + for (int i = 0, index = listPage * 9; i < 9 && index >= 0 && index < blockedAccts.Count; ++i, ++index) + { + Account a = blockedAccts[index]; + + int offset = 200 + i * 20; + + GetAccountInfo(a, out AccessLevel accessLevel, out bool online); + + AddLabelCropped(12, offset, 120, 20, LabelHue, a.Username); + AddLabelCropped(132, offset, 120, 20, LabelHue, FormatAccessLevel(accessLevel)); + + if (online) + AddLabelCropped(252, offset, 120, 20, GreenHue, "Online"); + else if (a.Banned) + AddLabelCropped(252, offset, 120, 20, RedHue, "Banned"); + else + AddLabelCropped(252, offset, 120, 20, RedHue, "Offline"); + + AddButton(380, offset - 1, 0xFA5, 0xFA7, GetButtonID(5, index + 56)); + } + + break; + } } } @@ -1214,12 +1214,12 @@ namespace Server.Gumps case AccessLevel.GameMaster: return 0x21; case AccessLevel.Counselor: return 0x2; default: - { - if (m.Kills >= 5) - return 0x21; + { + if (m.Kills >= 5) + return 0x21; - return m.Criminal ? 0x3B1 : 0x58; - } + return m.Criminal ? 0x3B1 : 0x58; + } } } @@ -1291,7 +1291,7 @@ namespace Server.Gumps for (int i = 0; i < theirAddresses.Length; ++i) if (!table.ContainsKey(theirAddresses[i])) - table[theirAddresses[i]] = new List{ acct }; + table[theirAddresses[i]] = new List { acct }; } List>> tableEntries = table.ToList(); @@ -1312,7 +1312,6 @@ namespace Server.Gumps return tableEntries; } - private static List GetSharedAccounts(IPAddress ipAddress) { List list = new List(); @@ -1465,7 +1464,7 @@ namespace Server.Gumps { from.SendGump(new NoticeGump(1060637, 30720, $"You have chosen not to {(ban ? "ban" : "delete")} the account{(rads.Count == 1 ? "" : "s")}.", - 0xFFC000, 420, 280, () => ResendGump_Callback(from, list, rads, page ))); + 0xFFC000, 420, 280, () => ResendGump_Callback(from, list, rads, page))); } } @@ -1554,7 +1553,7 @@ namespace Server.Gumps if (ips.Length != 0 && AccountHandler.IPTable.ContainsKey(ips[0])) --AccountHandler.IPTable[ips[0]]; - a.LoginIPs = new IPAddress[0]; + a.LoginIPs = Array.Empty(); notice = "All addresses in the list have been removed."; } @@ -1605,1337 +1604,1337 @@ namespace Server.Gumps switch (type) { case 0: - { - AdminGumpPage page; - - switch (index) { - case 0: - page = AdminGumpPage.Information_General; - break; - case 1: - page = AdminGumpPage.Administer; - break; - case 2: - page = AdminGumpPage.Clients; - break; - case 3: - page = AdminGumpPage.Accounts; - break; - case 4: - page = AdminGumpPage.Firewall; - break; - case 5: - page = AdminGumpPage.Information_Perf; - break; - default: return; - } + AdminGumpPage page; - from.SendGump(new AdminGump(from, page)); - break; - } + switch (index) + { + case 0: + page = AdminGumpPage.Information_General; + break; + case 1: + page = AdminGumpPage.Administer; + break; + case 2: + page = AdminGumpPage.Clients; + break; + case 3: + page = AdminGumpPage.Accounts; + break; + case 4: + page = AdminGumpPage.Firewall; + break; + case 5: + page = AdminGumpPage.Information_Perf; + break; + default: return; + } + + from.SendGump(new AdminGump(from, page)); + break; + } case 1: - { - switch (index) { - case 0: + switch (index) { - if (m_List != null && m_ListPage > 0) - from.SendGump(new AdminGump(from, m_PageType, m_ListPage - 1, m_List, null, m_State)); - - break; - } - case 1: - { - if (m_List != null /*&& (m_ListPage + 1) * 12 < m_List.Count*/) - from.SendGump(new AdminGump(from, m_PageType, m_ListPage + 1, m_List, null, m_State)); - - break; - } - } - - break; - } - case 3: - { - string notice = null; - AdminGumpPage page = AdminGumpPage.Administer; - - if (index >= 500) - page = AdminGumpPage.Administer_Access_Lockdown; - else if (index >= 400) - page = AdminGumpPage.Administer_Commands; - else if (index >= 300) - page = AdminGumpPage.Administer_Access; - else if (index >= 200) - page = AdminGumpPage.Administer_Server; - else if (index >= 100) - page = AdminGumpPage.Administer_WorldBuilding; - - switch (index) - { - case 0: - page = AdminGumpPage.Administer_WorldBuilding; - break; - case 1: - page = AdminGumpPage.Administer_Server; - break; - case 2: - page = AdminGumpPage.Administer_Access; - break; - case 3: - page = AdminGumpPage.Administer_Commands; - break; - - case 100: - InvokeCommand("DocGen"); - notice = "Documentation has been generated."; - break; - case 101: - InvokeCommand("TelGen"); - notice = "Teleporters have been generated."; - break; - case 102: - InvokeCommand("MoonGen"); - notice = "Moongates have been generated."; - break; - case 103: - InvokeCommand("UOAMVendors"); - notice = "Vendor spawners have been generated."; - break; - case 104: - InvokeCommand("DoorGen"); - notice = "Doors have been generated."; - break; - case 105: - InvokeCommand("SignGen"); - notice = "Signs have been generated."; - break; - case 106: - InvokeCommand("Decorate"); - notice = "Decoration has been generated."; - break; - case 107: - InvokeCommand("RebuildCategorization"); - notice = "Categorization menu has been regenerated. The server should be restarted."; - break; - - case 110: - InvokeCommand("Freeze"); - notice = "Target bounding points."; - break; - case 120: - InvokeCommand("Unfreeze"); - notice = "Target bounding points."; - break; - - case 200: - InvokeCommand("Save"); - notice = "The world has been saved."; - break; - case 201: - Shutdown(false, true); - break; - case 202: - Shutdown(false, false); - break; - case 203: - Shutdown(true, true); - break; - case 204: - Shutdown(true, false); - break; - case 210: - case 211: - { - string text = info.GetTextEntry(0)?.Text.Trim(); - - if (string.IsNullOrEmpty(text)) - { - notice = "You must enter text to broadcast it."; - } - else - { - notice = "Your message has been broadcasted."; - InvokeCommand($"{(index == 210 ? "BC" : "SM")} {text}"); - } - - break; - } - - case 300: - InvokeCommand("Kick"); - notice = "Target the player to kick."; - break; - case 301: - InvokeCommand("Ban"); - notice = "Target the player to ban."; - break; - case 302: - InvokeCommand("Firewall"); - notice = "Target the player to firewall."; - break; - - case 303: - page = AdminGumpPage.Administer_Access_Lockdown; - break; - - case 310: - InvokeCommand("Set AccessLevel Player"); - notice = "Target the player to change their access level. (Player)"; - break; - case 311: - InvokeCommand("Set AccessLevel Counselor"); - notice = "Target the player to change their access level. (Counselor)"; - break; - case 312: - InvokeCommand("Set AccessLevel GameMaster"); - notice = "Target the player to change their access level. (Game Master)"; - break; - case 313: - InvokeCommand("Set AccessLevel Seer"); - notice = "Target the player to change their access level. (Seer)"; - break; - - case 314: - { - if (from.AccessLevel > AccessLevel.Administrator) - { - InvokeCommand("Set AccessLevel Administrator"); - notice = "Target the player to change their access level. (Administrator)"; - } - - break; - } - - case 315: - { - if (from.AccessLevel > AccessLevel.Developer) - { - InvokeCommand("Set AccessLevel Developer"); - notice = "Target the player to change their access level. (Developer)"; - } - - break; - } - - case 316: - { - if (from.AccessLevel >= AccessLevel.Owner) - { - InvokeCommand("Set AccessLevel Owner"); - notice = "Target the player to change their access level. (Owner)"; - } - - break; - } - - case 400: - notice = "Enter search terms to add objects."; - break; - case 401: - InvokeCommand("Remove"); - notice = "Target the item or mobile to remove."; - break; - case 402: - InvokeCommand("Dupe"); - notice = "Target the item to dupe."; - break; - case 403: - InvokeCommand("DupeInBag"); - notice = "Target the item to dupe. The item will be duped at it's current location."; - break; - case 404: - InvokeCommand("Props"); - notice = "Target the item or mobile to inspect."; - break; - case 405: - InvokeCommand("Skills"); - notice = "Target a mobile to view their skills."; - break; - case 406: - InvokeCommand("Set Blessed False"); - notice = "Target the mobile to make mortal."; - break; - case 407: - InvokeCommand("Set Blessed True"); - notice = "Target the mobile to make immortal."; - break; - case 408: - InvokeCommand("Set Squelched True"); - notice = "Target the mobile to squelch."; - break; - case 409: - InvokeCommand("Set Squelched False"); - notice = "Target the mobile to unsquelch."; - break; - case 410: - InvokeCommand("Set Frozen True"); - notice = "Target the mobile to freeze."; - break; - case 411: - InvokeCommand("Set Frozen False"); - notice = "Target the mobile to unfreeze."; - break; - case 412: - InvokeCommand("Set Hidden True"); - notice = "Target the mobile to hide."; - break; - case 413: - InvokeCommand("Set Hidden False"); - notice = "Target the mobile to unhide."; - break; - case 414: - InvokeCommand("Kill"); - notice = "Target the mobile to kill."; - break; - case 415: - InvokeCommand("Resurrect"); - notice = "Target the mobile to resurrect."; - break; - case 416: - InvokeCommand("Move"); - notice = "Target the item or mobile to move."; - break; - case 417: - InvokeCommand("Wipe"); - notice = "Target bounding points."; - break; - case 418: - InvokeCommand("Tele"); - notice = "Choose your destination."; - break; - case 419: - InvokeCommand("Multi Tele"); - notice = "Choose your destination."; - break; - - case 500: - case 501: - case 502: - case 503: - case 504: - { - AccountHandler.LockdownLevel = (AccessLevel)(index - 500); - - if (AccountHandler.LockdownLevel > AccessLevel.Player) - notice = "The lockdown level has been changed."; - else - notice = "The server is now accessible to everyone."; - - break; - } - - case 510: - { - AccessLevel level = AccountHandler.LockdownLevel; - - if (level > AccessLevel.Player) - { - List clients = TcpServer.Instances; - int count = 0; - - for (int i = 0; i < clients.Count; ++i) + case 0: { - NetState ns = clients[i]; - IAccount a = ns.Account; + if (m_List != null && m_ListPage > 0) + from.SendGump(new AdminGump(from, m_PageType, m_ListPage - 1, m_List, null, m_State)); - if (a == null) - continue; + break; + } + case 1: + { + if (m_List != null /*&& (m_ListPage + 1) * 12 < m_List.Count*/) + from.SendGump(new AdminGump(from, m_PageType, m_ListPage + 1, m_List, null, m_State)); - bool hasAccess = false; + break; + } + } - if (a.AccessLevel >= level) - hasAccess = true; + break; + } + case 3: + { + string notice = null; + AdminGumpPage page = AdminGumpPage.Administer; + + if (index >= 500) + page = AdminGumpPage.Administer_Access_Lockdown; + else if (index >= 400) + page = AdminGumpPage.Administer_Commands; + else if (index >= 300) + page = AdminGumpPage.Administer_Access; + else if (index >= 200) + page = AdminGumpPage.Administer_Server; + else if (index >= 100) + page = AdminGumpPage.Administer_WorldBuilding; + + switch (index) + { + case 0: + page = AdminGumpPage.Administer_WorldBuilding; + break; + case 1: + page = AdminGumpPage.Administer_Server; + break; + case 2: + page = AdminGumpPage.Administer_Access; + break; + case 3: + page = AdminGumpPage.Administer_Commands; + break; + + case 100: + InvokeCommand("DocGen"); + notice = "Documentation has been generated."; + break; + case 101: + InvokeCommand("TelGen"); + notice = "Teleporters have been generated."; + break; + case 102: + InvokeCommand("MoonGen"); + notice = "Moongates have been generated."; + break; + case 103: + InvokeCommand("UOAMVendors"); + notice = "Vendor spawners have been generated."; + break; + case 104: + InvokeCommand("DoorGen"); + notice = "Doors have been generated."; + break; + case 105: + InvokeCommand("SignGen"); + notice = "Signs have been generated."; + break; + case 106: + InvokeCommand("Decorate"); + notice = "Decoration has been generated."; + break; + case 107: + InvokeCommand("RebuildCategorization"); + notice = "Categorization menu has been regenerated. The server should be restarted."; + break; + + case 110: + InvokeCommand("Freeze"); + notice = "Target bounding points."; + break; + case 120: + InvokeCommand("Unfreeze"); + notice = "Target bounding points."; + break; + + case 200: + InvokeCommand("Save"); + notice = "The world has been saved."; + break; + case 201: + Shutdown(false, true); + break; + case 202: + Shutdown(false, false); + break; + case 203: + Shutdown(true, true); + break; + case 204: + Shutdown(true, false); + break; + case 210: + case 211: + { + string text = info.GetTextEntry(0)?.Text.Trim(); + + if (string.IsNullOrEmpty(text)) + { + notice = "You must enter text to broadcast it."; + } else - for (int j = 0; !hasAccess && j < a.Length; ++j) - { - Mobile m = a[j]; + { + notice = "Your message has been broadcasted."; + InvokeCommand($"{(index == 210 ? "BC" : "SM")} {text}"); + } - if (m?.AccessLevel >= level) + break; + } + + case 300: + InvokeCommand("Kick"); + notice = "Target the player to kick."; + break; + case 301: + InvokeCommand("Ban"); + notice = "Target the player to ban."; + break; + case 302: + InvokeCommand("Firewall"); + notice = "Target the player to firewall."; + break; + + case 303: + page = AdminGumpPage.Administer_Access_Lockdown; + break; + + case 310: + InvokeCommand("Set AccessLevel Player"); + notice = "Target the player to change their access level. (Player)"; + break; + case 311: + InvokeCommand("Set AccessLevel Counselor"); + notice = "Target the player to change their access level. (Counselor)"; + break; + case 312: + InvokeCommand("Set AccessLevel GameMaster"); + notice = "Target the player to change their access level. (Game Master)"; + break; + case 313: + InvokeCommand("Set AccessLevel Seer"); + notice = "Target the player to change their access level. (Seer)"; + break; + + case 314: + { + if (from.AccessLevel > AccessLevel.Administrator) + { + InvokeCommand("Set AccessLevel Administrator"); + notice = "Target the player to change their access level. (Administrator)"; + } + + break; + } + + case 315: + { + if (from.AccessLevel > AccessLevel.Developer) + { + InvokeCommand("Set AccessLevel Developer"); + notice = "Target the player to change their access level. (Developer)"; + } + + break; + } + + case 316: + { + if (from.AccessLevel >= AccessLevel.Owner) + { + InvokeCommand("Set AccessLevel Owner"); + notice = "Target the player to change their access level. (Owner)"; + } + + break; + } + + case 400: + notice = "Enter search terms to add objects."; + break; + case 401: + InvokeCommand("Remove"); + notice = "Target the item or mobile to remove."; + break; + case 402: + InvokeCommand("Dupe"); + notice = "Target the item to dupe."; + break; + case 403: + InvokeCommand("DupeInBag"); + notice = "Target the item to dupe. The item will be duped at it's current location."; + break; + case 404: + InvokeCommand("Props"); + notice = "Target the item or mobile to inspect."; + break; + case 405: + InvokeCommand("Skills"); + notice = "Target a mobile to view their skills."; + break; + case 406: + InvokeCommand("Set Blessed False"); + notice = "Target the mobile to make mortal."; + break; + case 407: + InvokeCommand("Set Blessed True"); + notice = "Target the mobile to make immortal."; + break; + case 408: + InvokeCommand("Set Squelched True"); + notice = "Target the mobile to squelch."; + break; + case 409: + InvokeCommand("Set Squelched False"); + notice = "Target the mobile to unsquelch."; + break; + case 410: + InvokeCommand("Set Frozen True"); + notice = "Target the mobile to freeze."; + break; + case 411: + InvokeCommand("Set Frozen False"); + notice = "Target the mobile to unfreeze."; + break; + case 412: + InvokeCommand("Set Hidden True"); + notice = "Target the mobile to hide."; + break; + case 413: + InvokeCommand("Set Hidden False"); + notice = "Target the mobile to unhide."; + break; + case 414: + InvokeCommand("Kill"); + notice = "Target the mobile to kill."; + break; + case 415: + InvokeCommand("Resurrect"); + notice = "Target the mobile to resurrect."; + break; + case 416: + InvokeCommand("Move"); + notice = "Target the item or mobile to move."; + break; + case 417: + InvokeCommand("Wipe"); + notice = "Target bounding points."; + break; + case 418: + InvokeCommand("Tele"); + notice = "Choose your destination."; + break; + case 419: + InvokeCommand("Multi Tele"); + notice = "Choose your destination."; + break; + + case 500: + case 501: + case 502: + case 503: + case 504: + { + AccountHandler.LockdownLevel = (AccessLevel)(index - 500); + + if (AccountHandler.LockdownLevel > AccessLevel.Player) + notice = "The lockdown level has been changed."; + else + notice = "The server is now accessible to everyone."; + + break; + } + + case 510: + { + AccessLevel level = AccountHandler.LockdownLevel; + + if (level > AccessLevel.Player) + { + List clients = TcpServer.Instances; + int count = 0; + + for (int i = 0; i < clients.Count; ++i) + { + NetState ns = clients[i]; + IAccount a = ns.Account; + + if (a == null) + continue; + + bool hasAccess = false; + + if (a.AccessLevel >= level) hasAccess = true; + else + for (int j = 0; !hasAccess && j < a.Length; ++j) + { + Mobile m = a[j]; + + if (m?.AccessLevel >= level) + hasAccess = true; + } + + if (!hasAccess) + { + ns.Dispose(); + ++count; + } } - if (!hasAccess) - { - ns.Dispose(); - ++count; - } - } - - if (count == 0) - notice = "Nobody without access was found to disconnect."; - else - notice = $"Number of players disconnected: {count}"; - } - else - { - notice = "The server is not currently locked down."; - } - - break; - } - } - - from.SendGump(new AdminGump(from, page, 0, null, notice)); - - switch (index) - { - case 400: - InvokeCommand("Add"); - break; - case 111: - InvokeCommand("FreezeWorld"); - break; - case 112: - InvokeCommand("FreezeMap"); - break; - case 121: - InvokeCommand("UnfreezeWorld"); - break; - case 122: - InvokeCommand("UnfreezeMap"); - break; - } - - break; - } - case 4: - { - switch (index) - { - case 0: - case 1: - { - bool forName = index == 0; - - List results = new List(); - - string match = info.GetTextEntry(0)?.Text.Trim().ToLower(); - string notice = null; - - if (string.IsNullOrEmpty(match)) - { - notice = $"You must enter {(forName ? "a name" : "an ip address")} to search."; - } - else - { - List instances = TcpServer.Instances; - - for (int i = 0; i < instances.Count; ++i) - { - NetState ns = instances[i]; - - bool isMatch; - - if (forName) - { - Mobile m = ns.Mobile; - IAccount a = ns.Account; - - isMatch = m?.Name.ToLower().IndexOf(match) >= 0 - || a?.Username.ToLower().IndexOf(match) >= 0; + if (count == 0) + notice = "Nobody without access was found to disconnect."; + else + notice = $"Number of players disconnected: {count}"; } else { - isMatch = ns.ToString().IndexOf(match) >= 0; + notice = "The server is not currently locked down."; } - if (isMatch) - results.Add(ns); + break; } - - results.Sort(NetStateComparer.Instance); - } - - if (results.Count == 1) - { - NetState ns = results[0]; - object state = ns.Mobile ?? (object)ns.Account; - - if (state is Mobile) - from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, "One match found.", - state)); - else if (state is Account) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - "One match found.", state)); - else - from.SendGump(new AdminGump(from, AdminGumpPage.Clients, 0, - Utility.CastListContravariant(results), "One match found.")); - } - else - { - from.SendGump(new AdminGump(from, AdminGumpPage.Clients, 0, - Utility.CastListContravariant(results), - notice ?? (results.Count == 0 ? "Nothing matched your search terms." : null))); - } - - break; } - default: - { - index -= 2; - if (m_List != null && index >= 0 && index < m_List.Count) + from.SendGump(new AdminGump(from, page, 0, null, notice)); + + switch (index) + { + case 400: + InvokeCommand("Add"); + break; + case 111: + InvokeCommand("FreezeWorld"); + break; + case 112: + InvokeCommand("FreezeMap"); + break; + case 121: + InvokeCommand("UnfreezeWorld"); + break; + case 122: + InvokeCommand("UnfreezeMap"); + break; + } + + break; + } + case 4: + { + switch (index) + { + case 0: + case 1: + { + bool forName = index == 0; + + List results = new List(); + + string match = info.GetTextEntry(0)?.Text.Trim().ToLower(); + string notice = null; + + if (string.IsNullOrEmpty(match)) + { + notice = $"You must enter {(forName ? "a name" : "an ip address")} to search."; + } + else + { + List instances = TcpServer.Instances; + + for (int i = 0; i < instances.Count; ++i) + { + NetState ns = instances[i]; + + bool isMatch; + + if (forName) + { + Mobile m = ns.Mobile; + IAccount a = ns.Account; + + isMatch = m?.Name.ToLower().IndexOf(match) >= 0 + || a?.Username.ToLower().IndexOf(match) >= 0; + } + else + { + isMatch = ns.ToString().IndexOf(match) >= 0; + } + + if (isMatch) + results.Add(ns); + } + + results.Sort(NetStateComparer.Instance); + } + + if (results.Count == 1) + { + NetState ns = results[0]; + object state = ns.Mobile ?? (object)ns.Account; + + if (state is Mobile) + from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, "One match found.", + state)); + else if (state is Account) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + "One match found.", state)); + else + from.SendGump(new AdminGump(from, AdminGumpPage.Clients, 0, + Utility.CastListContravariant(results), "One match found.")); + } + else + { + from.SendGump(new AdminGump(from, AdminGumpPage.Clients, 0, + Utility.CastListContravariant(results), + notice ?? (results.Count == 0 ? "Nothing matched your search terms." : null))); + } + + break; + } + default: + { + index -= 2; + + if (m_List != null && index >= 0 && index < m_List.Count) + { + if (!(m_List[index] is NetState ns)) + break; + + Mobile m = ns.Mobile; + Account a = ns.Account as Account; + + if (m != null) + from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, null, m)); + else if (a != null) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + null, a)); + } + + break; + } + } + + break; + } + case 5: + { + switch (index) + { + case 0: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, null, + m_State)); + break; + case 1: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Characters, 0, null, null, + m_State)); + break; + case 2: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Comments, 0, null, null, + m_State)); + break; + case 3: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Tags, 0, null, null, m_State)); + break; + case 13: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access, 0, null, null, m_State)); + break; + case 14: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, null, + m_State)); + break; + case 15: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, + null, m_State)); + break; + case 4: + from.Prompt = new AddCommentPrompt(m_State as Account); + from.SendMessage("Enter the new account comment."); + break; + case 5: + from.Prompt = new AddTagNamePrompt(m_State as Account); + from.SendMessage("Enter the new tag name."); + break; + case 6: + { + string un = info.GetTextEntry(0)?.Text.Trim(); + string pw = info.GetTextEntry(1)?.Text.Trim(); + + Account dispAccount = null; + string notice; + + if (string.IsNullOrEmpty(un)) + { + notice = "You must enter a username to add an account."; + } + else if (string.IsNullOrEmpty(pw)) + { + notice = "You must enter a password to add an account."; + } + else + { + IAccount account = Accounts.GetAccount(un); + + if (account != null) + { + notice = "There is already an account with that username."; + } + else + { + dispAccount = new Account(un, pw); + notice = $"{un} : Account added."; + CommandLogging.WriteLine(from, "{0} {1} adding new account: {2}", from.AccessLevel, + CommandLogging.Format(from), un); + } + } + + from.SendGump(new AdminGump(from, + dispAccount != null ? AdminGumpPage.AccountDetails_Information : m_PageType, m_ListPage, + m_List, notice, dispAccount ?? m_State)); + break; + } + case 7: + { + List results; + + TextRelay matchEntry = info.GetTextEntry(0); + string match = matchEntry?.Text.Trim().ToLower(); + + if (string.IsNullOrEmpty(match)) + { + results = Accounts.GetAccounts().ToList(); + results.Sort(AccountComparer.Instance); + } + else + { + results = Accounts.GetAccounts().Where(acct => acct.Username.ToLower().IndexOf(match) >= 0).ToList(); + results.Sort(AccountComparer.Instance); + } + + if (results.Count == 1) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + "One match found.", results[0])); + else + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, + Utility.CastListContravariant(results), + results.Count == 0 ? "Nothing matched your search terms." : null, + new List())); + + break; + } + case 8: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_ChangePassword, 0, null, null, + m_State)); + break; + case 9: + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_ChangeAccess, 0, null, null, + m_State)); + break; + case 10: + case 11: + { + if (!(m_State is Account a)) + break; + + a.SetUnspecifiedBan(from); + a.Banned = index == 10; + CommandLogging.WriteLine(from, "{0} {1} {3} account {2}", from.AccessLevel, + CommandLogging.Format(from), a.Username, a.Banned ? "banning" : "unbanning"); + from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, + $"The account has been {(a.Banned ? "banned" : "unbanned")}.", m_State)); + + if (index == 10) + from.SendGump(new BanDurationGump(a)); + + break; + } + case 12: + { + if (!(m_State is Account a)) + break; + + TextRelay passwordEntry = info.GetTextEntry(0); + TextRelay confirmEntry = info.GetTextEntry(1); + + string password = passwordEntry?.Text.Trim(); + string confirm = confirmEntry?.Text.Trim(); + + string notice; + AdminGumpPage page = AdminGumpPage.AccountDetails_ChangePassword; + + if (string.IsNullOrEmpty(password)) + { + notice = "You must enter the password."; + } + else if (confirm != password) + { + notice = + "You must confirm the password. That field must precisely match the password field."; + } + else + { + notice = "The password has been changed."; + a.SetPassword(password); + page = AdminGumpPage.AccountDetails_Information; + CommandLogging.WriteLine(from, "{0} {1} changing password of account {2}", from.AccessLevel, + CommandLogging.Format(from), a.Username); + } + + from.SendGump(new AdminGump(from, page, 0, null, notice, m_State)); + + break; + } + case 16: // view shared + { + if (!(m_State is Account a)) + break; + + List list = GetSharedAccounts(a.LoginIPs); + + if (list.Count > 1 || (list.Count == 1 && !list.Contains(a))) + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, + Utility.CastListContravariant(list), null, new List())); + else if (a.LoginIPs.Length > 0) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, + "There are no other accounts which share an address with this one.", m_State)); + else + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, + "This account has not yet been accessed.", m_State)); + + break; + } + case 17: // ban shared + { + if (!(m_State is Account a)) + break; + + List list = GetSharedAccounts(a.LoginIPs); + + if (list.Count > 0) + { + StringBuilder sb = new StringBuilder(); + + sb.AppendFormat("You are about to ban {0} account{1}. Do you wish to continue?", list.Count, + list.Count != 1 ? "s" : ""); + + for (int i = 0; i < list.Count; ++i) + sb.AppendFormat("
- {0}", list[i].Username); + + from.SendGump(new WarningGump(1060635, 30720, sb.ToString(), 0xFFC000, 420, 400, + okay => BanShared_Callback(from, okay, a))); + } + else if (a.LoginIPs.Length > 0) + { + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, + "There are no accounts which share an address with this one.", m_State)); + } + else + { + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, + "This account has not yet been accessed.", m_State)); + } + + break; + } + case 18: // firewall all + { + if (!(m_State is Account a)) + break; + + if (a.LoginIPs.Length > 0) + from.SendGump(new WarningGump(1060635, 30720, + $"You are about to firewall {a.LoginIPs.Length} address{(a.LoginIPs.Length != 1 ? "s" : "")}. Do you wish to continue?", + 0xFFC000, 420, 400, okay => FirewallShared_Callback(from, okay, a))); + else + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, + "This account has not yet been accessed.", m_State)); + + break; + } + case 19: // add + { + if (!(m_State is Account a)) + break; + + TextRelay entry = info.GetTextEntry(0); + string ip = entry?.Text.Trim(); + + string notice; + + if (string.IsNullOrEmpty(ip)) + { + notice = "You must enter an address to add."; + } + else + { + string[] list = a.IPRestrictions; + + bool contains = false; + for (int i = 0; !contains && i < list.Length; ++i) + contains = list[i] == ip; + + if (contains) + { + notice = "That address is already contained in the list."; + } + else + { + string[] newList = new string[list.Length + 1]; + + for (int i = 0; i < list.Length; ++i) + newList[i] = list[i]; + + newList[list.Length] = ip; + + a.IPRestrictions = newList; + + notice = $"{ip} : Added to restriction list."; + } + } + + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, + notice, m_State)); + + break; + } + case 20: // Change access level + case 21: + case 22: + case 23: + case 24: + { + if (!(m_State is Account a)) + break; + + var newLevel = index switch + { + 20 => AccessLevel.Player, + 21 => AccessLevel.Counselor, + 22 => AccessLevel.GameMaster, + 23 => AccessLevel.Seer, + 24 => AccessLevel.Administrator, + 33 => AccessLevel.Developer, + 34 => AccessLevel.Owner, + _ => AccessLevel.Player + }; + + if (newLevel < from.AccessLevel || from.AccessLevel == AccessLevel.Owner) + { + a.AccessLevel = newLevel; + + CommandLogging.WriteLine(from, "{0} {1} changing access level of account {2} to {3}", + from.AccessLevel, CommandLogging.Format(from), a.Username, a.AccessLevel); + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + "The access level has been changed.", m_State)); + } + + break; + } + case 25: + { + if (!(m_State is Account a)) + break; + + from.SendGump(new WarningGump(1060635, 30720, + $"
Account of {a.Username}

You are about to permanently delete the account. Likewise, all characters on the account will be deleted, including equipped, inventory, and banked items. Any houses tied to the account will be demolished.

Do you wish to continue?", + 0xFFC000, 420, 280, okay => AccountDelete_Callback(from, okay, a))); + break; + } + case 26: // View all shared accounts + { + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts_Shared)); + break; + } + case 27: // Ban marked + { + List list = m_List; + + if (list == null || !(m_State is List rads)) + break; + + if (rads.Count > 0) + from.SendGump(new WarningGump(1060635, 30720, + $"You are about to ban {rads.Count} marked account{(rads.Count == 1 ? "" : "s")}. Be cautioned, the only way to reverse this is by hand--manually unbanning each account.

Do you wish to continue?", + 0xFFC000, 420, 280, okay => Marked_Callback(from, okay, true, list, rads, m_ListPage))); + else + from.SendGump(new NoticeGump(1060637, 30720, + "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", + 0xFFC000, 420, 280, () => ResendGump_Callback(from, list, rads, m_ListPage))); + + break; + } + case 28: // Delete marked + { + List list = m_List; + + if (list == null || !(m_State is List rads)) + break; + + if (rads.Count > 0) + from.SendGump(new WarningGump(1060635, 30720, + string.Format( + "You are about to permanently delete {0} marked account{1}. Likewise, all characters on the account{1} will be deleted, including equipped, inventory, and banked items. Any houses tied to the account{1} will be demolished.

Do you wish to continue?", + rads.Count, rads.Count == 1 ? "" : "s"), 0xFFC000, 420, 280, okay => Marked_Callback(from, okay, false, list, rads, m_ListPage))); + else + from.SendGump(new NoticeGump(1060637, 30720, + "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", + 0xFFC000, 420, 280, () => ResendGump_Callback(from, list, rads, m_ListPage))); + + break; + } + case 29: // Mark all + { + if (m_List == null || !(m_State is List)) + break; + + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, m_ListPage, m_List, null, + m_List.ToList())); + + break; + } + case 30: // View all empty accounts + { + List results = new List(); + + foreach (Account acct in Accounts.GetAccounts()) + { + bool empty = true; + + for (int i = 0; empty && i < acct.Length; ++i) + empty = acct[i] == null; + + if (empty) + results.Add(acct); + } + + if (results.Count == 1) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + "One match found.", results[0])); + else + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, results, + results.Count == 0 ? "Nothing matched your search terms." : null, new List())); + + break; + } + case 31: // View all inactive accounts + { + List results = new List(); + + foreach (Account acct in Accounts.GetAccounts()) + if (acct.Inactive) + results.Add(acct); + + if (results.Count == 1) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + "One match found.", results[0])); + else + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, results, + results.Count == 0 ? "Nothing matched your search terms." : null, new List())); + + break; + } + case 32: // View all banned accounts + { + List results = new List(); + + foreach (Account acct in Accounts.GetAccounts()) + if (acct.Banned) + results.Add(acct); + + if (results.Count == 1) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + "One match found.", results[0])); + else + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, results, + results.Count == 0 ? "Nothing matched your search terms." : null, new List())); + + break; + } + case 33: // Change access level (extended) + case 34: + { + goto case 20; + } + case 35: // Unmark house owners + { + List list = m_List; + List rads = m_State as List; + + if (list == null || rads == null) + break; + + List newRads = new List(); + + foreach (Account acct in rads) + { + bool hasHouse = false; + + for (int i = 0; i < acct.Length && !hasHouse; ++i) + if (acct[i] != null && BaseHouse.HasHouse(acct[i])) + hasHouse = true; + + if (!hasHouse) + newRads.Add(acct); + } + + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, m_ListPage, m_List, null, newRads)); + + break; + } + case 36: // Clear login addresses + { + if (!(m_State is Account a)) + break; + + IPAddress[] ips = a.LoginIPs; + + if (ips.Length == 0) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, + "This account has not yet been accessed.", m_State)); + else + from.SendGump(new WarningGump(1060635, 30720, + $"You are about to clear the address list for account {a} containing {ips.Length} {(ips.Length == 1 ? "entry" : "entries")}. Do you wish to continue?", + 0xFFC000, 420, 280, okay => RemoveLoginIPs_Callback(from, okay, a))); + + break; + } + default: + { + index -= 50; + + if (m_State is Account a && index >= 0 && index < a.Length) + { + Mobile m = a[index]; + + if (m != null) + from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, null, m)); + } + else + { + index -= 6; + + if (m_List != null && index >= 0 && index < m_List.Count) + { + if (m_List[index] is Account) + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, + null, m_List[index])); + else if (m_List[index] is KeyValuePair> kvp) + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, + Utility.CastListContravariant(kvp.Value), null, new List())); + } + } + + break; + } + } + + break; + } + case 6: + { + switch (index) + { + case 0: + { + TextRelay matchEntry = info.GetTextEntry(0); + string match = matchEntry?.Text.Trim(); + + string notice = null; + List results = new List(); + + if (string.IsNullOrEmpty(match)) + notice = "You must enter a username to search."; + else + for (int i = 0; i < Firewall.List.Count; ++i) + { + string check = Firewall.List[i].ToString(); + + if (check.IndexOf(match) >= 0) + results.Add(Firewall.List[i]); + } + + if (results.Count == 1) + from.SendGump(new AdminGump(from, AdminGumpPage.FirewallInfo, 0, null, "One match found.", + results[0])); + else if (results.Count > 1) + from.SendGump(new AdminGump(from, AdminGumpPage.Firewall, 0, results, + $"Search results for : {match}", m_State)); + else + from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, + notice ?? "Nothing matched your search terms.", m_State)); + + break; + } + case 1: + { + TextRelay relay = info.GetTextEntry(0); + string text = relay?.Text.Trim(); + + if (string.IsNullOrEmpty(text)) + { + from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, + "You must enter an address or pattern to add.", m_State)); + } + else if (!Utility.IsValidIP(text)) + { + from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, + "That is not a valid address or pattern.", m_State)); + } + else + { + object toAdd = Firewall.ToFirewallEntry(text); + + CommandLogging.WriteLine(from, "{0} {1} firewalling {2}", from.AccessLevel, + CommandLogging.Format(from), toAdd); + + Firewall.Add(toAdd); + from.SendGump(new AdminGump(from, AdminGumpPage.FirewallInfo, 0, null, + $"{toAdd} : Added to firewall.", toAdd)); + } + + break; + } + case 2: + { + InvokeCommand("Firewall"); + from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, + "Target the player to firewall.", m_State)); + break; + } + case 3: + { + if (m_State is Firewall.IFirewallEntry) + { + CommandLogging.WriteLine(from, "{0} {1} removing {2} from firewall list", from.AccessLevel, + CommandLogging.Format(from), m_State); + + Firewall.Remove(m_State); + from.SendGump(new AdminGump(from, AdminGumpPage.Firewall, 0, null, + $"{m_State} : Removed from firewall.")); + } + + break; + } + default: + { + index -= 4; + + if (m_List != null && index >= 0 && index < m_List.Count) + from.SendGump(new AdminGump(from, AdminGumpPage.FirewallInfo, 0, null, null, m_List[index])); + + break; + } + } + + break; + } + case 7: + { + if (!(m_State is Mobile m)) + break; + + string notice = null; + bool sendGump = true; + + switch (index) + { + case 0: + { + Map map = m.Map; + Point3D loc = m.Location; + + if (map == null || map == Map.Internal) + { + map = m.LogoutMap; + loc = m.LogoutLocation; + } + + if (map != null && map != Map.Internal) + { + from.MoveToWorld(loc, map); + notice = "You have been teleported to their location."; + } + + break; + } + case 1: + { + m.MoveToWorld(from.Location, from.Map); + notice = "They have been teleported to your location."; + break; + } + case 2: + { + NetState ns = m.NetState; + + if (ns != null) + { + CommandLogging.WriteLine(from, "{0} {1} {2} {3}", from.AccessLevel, + CommandLogging.Format(from), "kicking", CommandLogging.Format(m)); + ns.Dispose(); + notice = "They have been kicked."; + } + else + { + notice = "They are already disconnected."; + } + + break; + } + case 3: + { + if (m.Account is Account a) + { + CommandLogging.WriteLine(from, "{0} {1} {2} {3}", from.AccessLevel, + CommandLogging.Format(from), "banning", CommandLogging.Format(m)); + a.Banned = true; + + NetState ns = m.NetState; + + ns?.Dispose(); + + notice = "They have been banned."; + } + + break; + } + case 6: + { + Properties.SetValue(from, m, "Blessed", "False"); + notice = "They are now mortal."; + break; + } + case 7: + { + Properties.SetValue(from, m, "Blessed", "True"); + notice = "They are now immortal."; + break; + } + case 8: + { + Properties.SetValue(from, m, "Squelched", "True"); + notice = "They are now squelched."; + break; + } + case 9: + { + Properties.SetValue(from, m, "Squelched", "False"); + notice = "They are now unsquelched."; + break; + } + case 10: + { + Properties.SetValue(from, m, "Hidden", "True"); + notice = "They are now hidden."; + break; + } + case 11: + { + Properties.SetValue(from, m, "Hidden", "False"); + notice = "They are now unhidden."; + break; + } + case 12: + { + CommandLogging.WriteLine(from, "{0} {1} killing {2}", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(m)); + m.Kill(); + notice = "They have been killed."; + break; + } + case 13: + { + CommandLogging.WriteLine(from, "{0} {1} resurrecting {2}", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(m)); + m.Resurrect(); + notice = "They have been resurrected."; + break; + } + case 14: + { + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, null, + m.Account)); + sendGump = false; + break; + } + } + + if (sendGump) + from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, notice, m_State)); + + switch (index) + { + case 3: + { + if (m.Account is Account a) + from.SendGump(new BanDurationGump(a)); + + break; + } + case 4: + { + from.SendGump(new PropertiesGump(from, m)); + break; + } + case 5: + { + from.SendGump(new SkillsGump(from, m)); + break; + } + } + + break; + } + case 8: + { + if (m_List != null && index >= 0 && index < m_List.Count) + { + if (!(m_State is Account a)) + break; + + if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs) { - if (!(m_List[index] is NetState ns)) + from.SendGump(new WarningGump(1060635, 30720, + $"You are about to firewall {m_List[index]}. All connection attempts from a matching IP will be refused. Are you sure?", + 0xFFC000, 420, 280, okay => Firewall_Callback(from, okay, a, m_List[index]))); + } + else if (m_PageType == AdminGumpPage.AccountDetails_Access_Restrictions) + { + List list = a.IPRestrictions.ToList(); + list.Remove(m_List[index] as string); + a.IPRestrictions = list.ToArray(); + + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, + $"{m_List[index]} : Removed from list.", a)); + } + } + + break; + } + case 9: + { + if (m_List != null && index >= 0 && index < m_List.Count) + if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs) + { + object obj = m_List[index]; + + if (!(obj is IPAddress ip)) break; - Mobile m = ns.Mobile; - Account a = ns.Account as Account; + if (!(m_State is Account a)) + break; - if (m != null) - from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, null, m)); - else if (a != null) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - null, a)); - } + List list = GetSharedAccounts(ip); - break; - } - } - - break; - } - case 5: - { - switch (index) - { - case 0: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, null, - m_State)); - break; - case 1: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Characters, 0, null, null, - m_State)); - break; - case 2: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Comments, 0, null, null, - m_State)); - break; - case 3: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Tags, 0, null, null, m_State)); - break; - case 13: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access, 0, null, null, m_State)); - break; - case 14: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, null, - m_State)); - break; - case 15: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, - null, m_State)); - break; - case 4: - from.Prompt = new AddCommentPrompt(m_State as Account); - from.SendMessage("Enter the new account comment."); - break; - case 5: - from.Prompt = new AddTagNamePrompt(m_State as Account); - from.SendMessage("Enter the new tag name."); - break; - case 6: - { - string un = info.GetTextEntry(0)?.Text.Trim(); - string pw = info.GetTextEntry(1)?.Text.Trim(); - - Account dispAccount = null; - string notice; - - if (string.IsNullOrEmpty(un)) - { - notice = "You must enter a username to add an account."; - } - else if (string.IsNullOrEmpty(pw)) - { - notice = "You must enter a password to add an account."; - } - else - { - IAccount account = Accounts.GetAccount(un); - - if (account != null) - { - notice = "There is already an account with that username."; - } + if (list.Count > 1 || (list.Count == 1 && !list.Contains(a))) + from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, + Utility.CastListContravariant(list), null, new List())); else - { - dispAccount = new Account(un, pw); - notice = $"{un} : Account added."; - CommandLogging.WriteLine(from, "{0} {1} adding new account: {2}", from.AccessLevel, - CommandLogging.Format(from), un); - } + from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, + "There are no other accounts which share that address.", a)); } - from.SendGump(new AdminGump(from, - dispAccount != null ? AdminGumpPage.AccountDetails_Information : m_PageType, m_ListPage, - m_List, notice, dispAccount ?? m_State)); - break; - } - case 7: - { - List results; - - TextRelay matchEntry = info.GetTextEntry(0); - string match = matchEntry?.Text.Trim().ToLower(); - - if (string.IsNullOrEmpty(match)) - { - results = Accounts.GetAccounts().ToList(); - results.Sort(AccountComparer.Instance); - } - else - { - results = Accounts.GetAccounts().Where(acct => acct.Username.ToLower().IndexOf(match) >= 0).ToList(); - results.Sort(AccountComparer.Instance); - } - - if (results.Count == 1) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - "One match found.", results[0])); - else - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, - Utility.CastListContravariant(results), - results.Count == 0 ? "Nothing matched your search terms." : null, - new List())); - - break; - } - case 8: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_ChangePassword, 0, null, null, - m_State)); - break; - case 9: - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_ChangeAccess, 0, null, null, - m_State)); - break; - case 10: - case 11: - { - if (!(m_State is Account a)) - break; - - a.SetUnspecifiedBan(from); - a.Banned = index == 10; - CommandLogging.WriteLine(from, "{0} {1} {3} account {2}", from.AccessLevel, - CommandLogging.Format(from), a.Username, a.Banned ? "banning" : "unbanning"); - from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, - $"The account has been {(a.Banned ? "banned" : "unbanned")}.", m_State)); - - if (index == 10) - from.SendGump(new BanDurationGump(a)); - - break; - } - case 12: - { - if (!(m_State is Account a)) - break; - - TextRelay passwordEntry = info.GetTextEntry(0); - TextRelay confirmEntry = info.GetTextEntry(1); - - string password = passwordEntry?.Text.Trim(); - string confirm = confirmEntry?.Text.Trim(); - - string notice; - AdminGumpPage page = AdminGumpPage.AccountDetails_ChangePassword; - - if (string.IsNullOrEmpty(password)) - { - notice = "You must enter the password."; - } - else if (confirm != password) - { - notice = - "You must confirm the password. That field must precisely match the password field."; - } - else - { - notice = "The password has been changed."; - a.SetPassword(password); - page = AdminGumpPage.AccountDetails_Information; - CommandLogging.WriteLine(from, "{0} {1} changing password of account {2}", from.AccessLevel, - CommandLogging.Format(from), a.Username); - } - - from.SendGump(new AdminGump(from, page, 0, null, notice, m_State)); - - break; - } - case 16: // view shared - { - if (!(m_State is Account a)) - break; - - List list = GetSharedAccounts(a.LoginIPs); - - if (list.Count > 1 || list.Count == 1 && !list.Contains(a)) - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, - Utility.CastListContravariant(list), null, new List())); - else if (a.LoginIPs.Length > 0) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, - "There are no other accounts which share an address with this one.", m_State)); - else - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, - "This account has not yet been accessed.", m_State)); - - break; - } - case 17: // ban shared - { - if (!(m_State is Account a)) - break; - - List list = GetSharedAccounts(a.LoginIPs); - - if (list.Count > 0) - { - StringBuilder sb = new StringBuilder(); - - sb.AppendFormat("You are about to ban {0} account{1}. Do you wish to continue?", list.Count, - list.Count != 1 ? "s" : ""); - - for (int i = 0; i < list.Count; ++i) - sb.AppendFormat("
- {0}", list[i].Username); - - from.SendGump(new WarningGump(1060635, 30720, sb.ToString(), 0xFFC000, 420, 400, - okay => BanShared_Callback(from, okay, a))); - } - else if (a.LoginIPs.Length > 0) - { - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, - "There are no accounts which share an address with this one.", m_State)); - } - else - { - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, - "This account has not yet been accessed.", m_State)); - } - - break; - } - case 18: // firewall all - { - if (!(m_State is Account a)) - break; - - if (a.LoginIPs.Length > 0) - from.SendGump(new WarningGump(1060635, 30720, - $"You are about to firewall {a.LoginIPs.Length} address{(a.LoginIPs.Length != 1 ? "s" : "")}. Do you wish to continue?", - 0xFFC000, 420, 400, okay => FirewallShared_Callback(from, okay, a))); - else - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, - "This account has not yet been accessed.", m_State)); - - break; - } - case 19: // add - { - if (!(m_State is Account a)) - break; - - TextRelay entry = info.GetTextEntry(0); - string ip = entry?.Text.Trim(); - - string notice; - - if (string.IsNullOrEmpty(ip)) - { - notice = "You must enter an address to add."; - } - else - { - string[] list = a.IPRestrictions; - - bool contains = false; - for (int i = 0; !contains && i < list.Length; ++i) - contains = list[i] == ip; - - if (contains) - { - notice = "That address is already contained in the list."; - } - else - { - string[] newList = new string[list.Length + 1]; - - for (int i = 0; i < list.Length; ++i) - newList[i] = list[i]; - - newList[list.Length] = ip; - - a.IPRestrictions = newList; - - notice = $"{ip} : Added to restriction list."; - } - } - - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, - notice, m_State)); - - break; - } - case 20: // Change access level - case 21: - case 22: - case 23: - case 24: - { - if (!(m_State is Account a)) - break; - - var newLevel = index switch - { - 20 => AccessLevel.Player, - 21 => AccessLevel.Counselor, - 22 => AccessLevel.GameMaster, - 23 => AccessLevel.Seer, - 24 => AccessLevel.Administrator, - 33 => AccessLevel.Developer, - 34 => AccessLevel.Owner, - _ => AccessLevel.Player - }; - - if (newLevel < from.AccessLevel || from.AccessLevel == AccessLevel.Owner) - { - a.AccessLevel = newLevel; - - CommandLogging.WriteLine(from, "{0} {1} changing access level of account {2} to {3}", - from.AccessLevel, CommandLogging.Format(from), a.Username, a.AccessLevel); - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - "The access level has been changed.", m_State)); - } - - break; - } - case 25: - { - if (!(m_State is Account a)) - break; - - from.SendGump(new WarningGump(1060635, 30720, - $"
Account of {a.Username}

You are about to permanently delete the account. Likewise, all characters on the account will be deleted, including equipped, inventory, and banked items. Any houses tied to the account will be demolished.

Do you wish to continue?", - 0xFFC000, 420, 280, okay => AccountDelete_Callback(from, okay, a))); - break; - } - case 26: // View all shared accounts - { - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts_Shared)); - break; - } - case 27: // Ban marked - { - List list = m_List; - - if (list == null || !(m_State is List rads)) - break; - - if (rads.Count > 0) - from.SendGump(new WarningGump(1060635, 30720, - $"You are about to ban {rads.Count} marked account{(rads.Count == 1 ? "" : "s")}. Be cautioned, the only way to reverse this is by hand--manually unbanning each account.

Do you wish to continue?", - 0xFFC000, 420, 280, okay => Marked_Callback(from, okay, true, list, rads, m_ListPage ))); - else - from.SendGump(new NoticeGump(1060637, 30720, - "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", - 0xFFC000, 420, 280, () => ResendGump_Callback(from, list, rads, m_ListPage))); - - break; - } - case 28: // Delete marked - { - List list = m_List; - - if (list == null || !(m_State is List rads)) - break; - - if (rads.Count > 0) - from.SendGump(new WarningGump(1060635, 30720, - string.Format( - "You are about to permanently delete {0} marked account{1}. Likewise, all characters on the account{1} will be deleted, including equipped, inventory, and banked items. Any houses tied to the account{1} will be demolished.

Do you wish to continue?", - rads.Count, rads.Count == 1 ? "" : "s"), 0xFFC000, 420, 280, okay => Marked_Callback(from, okay, false, list, rads, m_ListPage ))); - else - from.SendGump(new NoticeGump(1060637, 30720, - "You have not yet marked any accounts. Place a check mark next to the accounts you wish to ban and then try again.", - 0xFFC000, 420, 280, () => ResendGump_Callback(from, list, rads, m_ListPage))); - - break; - } - case 29: // Mark all - { - if (m_List == null || !(m_State is List)) - break; - - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, m_ListPage, m_List, null, - m_List.ToList())); - - break; - } - case 30: // View all empty accounts - { - List results = new List(); - - foreach (Account acct in Accounts.GetAccounts()) - { - bool empty = true; - - for (int i = 0; empty && i < acct.Length; ++i) - empty = acct[i] == null; - - if (empty) - results.Add(acct); - } - - if (results.Count == 1) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - "One match found.", results[0])); - else - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, results, - results.Count == 0 ? "Nothing matched your search terms." : null, new List())); - - break; - } - case 31: // View all inactive accounts - { - List results = new List(); - - foreach (Account acct in Accounts.GetAccounts()) - if (acct.Inactive) - results.Add(acct); - - if (results.Count == 1) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - "One match found.", results[0])); - else - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, results, - results.Count == 0 ? "Nothing matched your search terms." : null, new List())); - - break; - } - case 32: // View all banned accounts - { - List results = new List(); - - foreach (Account acct in Accounts.GetAccounts()) - if (acct.Banned) - results.Add(acct); - - if (results.Count == 1) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - "One match found.", results[0])); - else - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, results, - results.Count == 0 ? "Nothing matched your search terms." : null, new List())); - - break; - } - case 33: // Change access level (extended) - case 34: - { - goto case 20; - } - case 35: // Unmark house owners - { - List list = m_List; - List rads = m_State as List; - - if (list == null || rads == null) - break; - - List newRads = new List(); - - foreach (Account acct in rads) - { - bool hasHouse = false; - - for (int i = 0; i < acct.Length && !hasHouse; ++i) - if (acct[i] != null && BaseHouse.HasHouse(acct[i])) - hasHouse = true; - - if (!hasHouse) - newRads.Add(acct); - } - - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, m_ListPage, m_List, null, newRads)); - - break; - } - case 36: // Clear login addresses - { - if (!(m_State is Account a)) - break; - - IPAddress[] ips = a.LoginIPs; - - if (ips.Length == 0) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, - "This account has not yet been accessed.", m_State)); - else - from.SendGump(new WarningGump(1060635, 30720, - $"You are about to clear the address list for account {a} containing {ips.Length} {(ips.Length == 1 ? "entry" : "entries")}. Do you wish to continue?", - 0xFFC000, 420, 280, okay => RemoveLoginIPs_Callback(from, okay, a))); - - break; - } - default: - { - index -= 50; - - if (m_State is Account a && index >= 0 && index < a.Length) - { - Mobile m = a[index]; - - if (m != null) - from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, null, m)); - } - else - { - index -= 6; - - if (m_List != null && index >= 0 && index < m_List.Count) - { - if (m_List[index] is Account) - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, - null, m_List[index])); - else if (m_List[index] is KeyValuePair> kvp) - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, - Utility.CastListContravariant(kvp.Value), null, new List())); - } - } - - break; - } - } - - break; - } - case 6: - { - switch (index) - { - case 0: - { - TextRelay matchEntry = info.GetTextEntry(0); - string match = matchEntry?.Text.Trim(); - - string notice = null; - List results = new List(); - - if (string.IsNullOrEmpty(match)) - notice = "You must enter a username to search."; - else - for (int i = 0; i < Firewall.List.Count; ++i) - { - string check = Firewall.List[i].ToString(); - - if (check.IndexOf(match) >= 0) - results.Add(Firewall.List[i]); - } - - if (results.Count == 1) - from.SendGump(new AdminGump(from, AdminGumpPage.FirewallInfo, 0, null, "One match found.", - results[0])); - else if (results.Count > 1) - from.SendGump(new AdminGump(from, AdminGumpPage.Firewall, 0, results, - $"Search results for : {match}", m_State)); - else - from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, - notice ?? "Nothing matched your search terms.", m_State)); - - break; - } - case 1: - { - TextRelay relay = info.GetTextEntry(0); - string text = relay?.Text.Trim(); - - if (string.IsNullOrEmpty(text)) - { - from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, - "You must enter an address or pattern to add.", m_State)); - } - else if (!Utility.IsValidIP(text)) - { - from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, - "That is not a valid address or pattern.", m_State)); - } - else - { - object toAdd = Firewall.ToFirewallEntry(text); - - CommandLogging.WriteLine(from, "{0} {1} firewalling {2}", from.AccessLevel, - CommandLogging.Format(from), toAdd); - - Firewall.Add(toAdd); - from.SendGump(new AdminGump(from, AdminGumpPage.FirewallInfo, 0, null, - $"{toAdd} : Added to firewall.", toAdd)); - } - - break; - } - case 2: - { - InvokeCommand("Firewall"); - from.SendGump(new AdminGump(from, m_PageType, m_ListPage, m_List, - "Target the player to firewall.", m_State)); - break; - } - case 3: - { - if (m_State is Firewall.IFirewallEntry) - { - CommandLogging.WriteLine(from, "{0} {1} removing {2} from firewall list", from.AccessLevel, - CommandLogging.Format(from), m_State); - - Firewall.Remove(m_State); - from.SendGump(new AdminGump(from, AdminGumpPage.Firewall, 0, null, - $"{m_State} : Removed from firewall.")); - } - - break; - } - default: - { - index -= 4; - - if (m_List != null && index >= 0 && index < m_List.Count) - from.SendGump(new AdminGump(from, AdminGumpPage.FirewallInfo, 0, null, null, m_List[index])); - - break; - } - } - - break; - } - case 7: - { - if (!(m_State is Mobile m)) break; - - string notice = null; - bool sendGump = true; - - switch (index) - { - case 0: - { - Map map = m.Map; - Point3D loc = m.Location; - - if (map == null || map == Map.Internal) - { - map = m.LogoutMap; - loc = m.LogoutLocation; - } - - if (map != null && map != Map.Internal) - { - from.MoveToWorld(loc, map); - notice = "You have been teleported to their location."; - } - - break; - } - case 1: - { - m.MoveToWorld(from.Location, from.Map); - notice = "They have been teleported to your location."; - break; - } - case 2: - { - NetState ns = m.NetState; - - if (ns != null) - { - CommandLogging.WriteLine(from, "{0} {1} {2} {3}", from.AccessLevel, - CommandLogging.Format(from), "kicking", CommandLogging.Format(m)); - ns.Dispose(); - notice = "They have been kicked."; - } - else - { - notice = "They are already disconnected."; - } - - break; - } - case 3: - { - if (m.Account is Account a) - { - CommandLogging.WriteLine(from, "{0} {1} {2} {3}", from.AccessLevel, - CommandLogging.Format(from), "banning", CommandLogging.Format(m)); - a.Banned = true; - - NetState ns = m.NetState; - - ns?.Dispose(); - - notice = "They have been banned."; - } - - break; - } - case 6: - { - Properties.SetValue(from, m, "Blessed", "False"); - notice = "They are now mortal."; - break; - } - case 7: - { - Properties.SetValue(from, m, "Blessed", "True"); - notice = "They are now immortal."; - break; - } - case 8: - { - Properties.SetValue(from, m, "Squelched", "True"); - notice = "They are now squelched."; - break; - } - case 9: - { - Properties.SetValue(from, m, "Squelched", "False"); - notice = "They are now unsquelched."; - break; - } - case 10: - { - Properties.SetValue(from, m, "Hidden", "True"); - notice = "They are now hidden."; - break; - } - case 11: - { - Properties.SetValue(from, m, "Hidden", "False"); - notice = "They are now unhidden."; - break; - } - case 12: - { - CommandLogging.WriteLine(from, "{0} {1} killing {2}", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(m)); - m.Kill(); - notice = "They have been killed."; - break; - } - case 13: - { - CommandLogging.WriteLine(from, "{0} {1} resurrecting {2}", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(m)); - m.Resurrect(); - notice = "They have been resurrected."; - break; - } - case 14: - { - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Information, 0, null, null, - m.Account)); - sendGump = false; - break; - } } - - if (sendGump) - from.SendGump(new AdminGump(from, AdminGumpPage.ClientInfo, 0, null, notice, m_State)); - - switch (index) - { - case 3: - { - if (m.Account is Account a) - from.SendGump(new BanDurationGump(a)); - - break; - } - case 4: - { - from.SendGump(new PropertiesGump(from, m)); - break; - } - case 5: - { - from.SendGump(new SkillsGump(from, m)); - break; - } - } - - break; - } - case 8: - { - if (m_List != null && index >= 0 && index < m_List.Count) - { - if (!(m_State is Account a)) - break; - - if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs) - { - from.SendGump(new WarningGump(1060635, 30720, - $"You are about to firewall {m_List[index]}. All connection attempts from a matching IP will be refused. Are you sure?", - 0xFFC000, 420, 280, okay => Firewall_Callback(from, okay, a, m_List[index] ))); - } - else if (m_PageType == AdminGumpPage.AccountDetails_Access_Restrictions) - { - List list = a.IPRestrictions.ToList(); - list.Remove(m_List[index] as string); - a.IPRestrictions = list.ToArray(); - - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_Restrictions, 0, null, - $"{m_List[index]} : Removed from list.", a)); - } - } - - break; - } - case 9: - { - if (m_List != null && index >= 0 && index < m_List.Count) - if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs) - { - object obj = m_List[index]; - - if (!(obj is IPAddress ip)) - break; - - if (!(m_State is Account a)) - break; - - List list = GetSharedAccounts(ip); - - if (list.Count > 1 || list.Count == 1 && !list.Contains(a)) - from.SendGump(new AdminGump(from, AdminGumpPage.Accounts, 0, - Utility.CastListContravariant(list), null, new List())); - else - from.SendGump(new AdminGump(from, AdminGumpPage.AccountDetails_Access_ClientIPs, 0, null, - "There are no other accounts which share that address.", a)); - } - - break; - } case 10: - { - if (m_List != null && index >= 0 && index < m_List.Count) - if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs) - { - IPAddress ip = m_List[index] as IPAddress; + { + if (m_List != null && index >= 0 && index < m_List.Count) + if (m_PageType == AdminGumpPage.AccountDetails_Access_ClientIPs) + { + IPAddress ip = m_List[index] as IPAddress; - if (ip == null) - break; + if (ip == null) + break; - if (!(m_State is Account a)) - break; + if (!(m_State is Account a)) + break; - from.SendGump(new WarningGump(1060635, 30720, - $"You are about to remove address {ip} from account {a}. Do you wish to continue?", 0xFFC000, - 420, 280, okay => RemoveLoginIP_Callback(from, okay, a, ip))); - } + from.SendGump(new WarningGump(1060635, 30720, + $"You are about to remove address {ip} from account {a}. Do you wish to continue?", 0xFFC000, + 420, 280, okay => RemoveLoginIP_Callback(from, okay, a, ip))); + } - break; - } + break; + } } } @@ -2984,7 +2983,7 @@ namespace Server.Gumps private class AddCommentPrompt : Prompt { - private Account m_Account; + private readonly Account m_Account; public AddCommentPrompt(Account acct) => m_Account = acct; @@ -3007,7 +3006,7 @@ namespace Server.Gumps private class AddTagNamePrompt : Prompt { - private Account m_Account; + private readonly Account m_Account; public AddTagNamePrompt(Account acct) => m_Account = acct; @@ -3026,8 +3025,8 @@ namespace Server.Gumps private class AddTagValuePrompt : Prompt { - private Account m_Account; - private string m_Name; + private readonly Account m_Account; + private readonly string m_Name; public AddTagValuePrompt(Account acct, string name) { diff --git a/Projects/Scripts/Gumps/BanDurationGump.cs b/Projects/Scripts/Gumps/BanDurationGump.cs index a59b762ba..b174cae40 100644 --- a/Projects/Scripts/Gumps/BanDurationGump.cs +++ b/Projects/Scripts/Gumps/BanDurationGump.cs @@ -7,9 +7,9 @@ namespace Server.Gumps { public class BanDurationGump : Gump { - private List m_List; + private readonly List m_List; - public BanDurationGump(Account a) : this(new List{ a }) + public BanDurationGump(Account a) : this(new List { a }) { } @@ -24,12 +24,12 @@ namespace Server.Gumps AddBackground(0, 0, width, height, 5054); - //AddImageTiled( 10, 10, width - 20, 20, 2624 ); - //AddAlphaRegion( 10, 10, width - 20, 20 ); + // AddImageTiled( 10, 10, width - 20, 20, 2624 ); + // AddAlphaRegion( 10, 10, width - 20, 20 ); AddHtml(10, 10, width - 20, 20, "
Ban Duration
"); - //AddImageTiled( 10, 40, width - 20, height - 50, 2624 ); - //AddAlphaRegion( 10, 40, width - 20, height - 50 ); + // AddImageTiled( 10, 40, width - 20, height - 50, 2624 ); + // AddAlphaRegion( 10, 40, width - 20, height - 50 ); AddButtonLabeled(15, 45, 1, "Infinite"); AddButtonLabeled(15, 65, 2, "From D:H:M:S"); @@ -84,124 +84,124 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: - { - for (int i = 0; i < m_List.Count; ++i) { - Account a = m_List[i]; + for (int i = 0; i < m_List.Count; ++i) + { + Account a = m_List[i]; - a.SetUnspecifiedBan(from); + a.SetUnspecifiedBan(from); + } + + from.SendMessage("Duration unspecified."); + return; } - - from.SendMessage("Duration unspecified."); - return; - } case 1: // infinite - { - duration = TimeSpan.MaxValue; - shouldSet = true; - break; - } + { + duration = TimeSpan.MaxValue; + shouldSet = true; + break; + } case 2: // From D:H:M:S - { - if (d != null && h != null && m != null && s != null) - try - { - duration = new TimeSpan(Utility.ToInt32(d.Text), Utility.ToInt32(h.Text), - Utility.ToInt32(m.Text), Utility.ToInt32(s.Text)); - shouldSet = true; + { + if (d != null && h != null && m != null && s != null) + try + { + duration = new TimeSpan(Utility.ToInt32(d.Text), Utility.ToInt32(h.Text), + Utility.ToInt32(m.Text), Utility.ToInt32(s.Text)); + shouldSet = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - duration = TimeSpan.Zero; - shouldSet = false; + duration = TimeSpan.Zero; + shouldSet = false; - break; - } + break; + } case 3: // From D - { - if (d != null) - try - { - duration = TimeSpan.FromDays(Utility.ToDouble(d.Text)); - shouldSet = true; + { + if (d != null) + try + { + duration = TimeSpan.FromDays(Utility.ToDouble(d.Text)); + shouldSet = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - duration = TimeSpan.Zero; - shouldSet = false; + duration = TimeSpan.Zero; + shouldSet = false; - break; - } + break; + } case 4: // From H - { - if (h != null) - try - { - duration = TimeSpan.FromHours(Utility.ToDouble(h.Text)); - shouldSet = true; + { + if (h != null) + try + { + duration = TimeSpan.FromHours(Utility.ToDouble(h.Text)); + shouldSet = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - duration = TimeSpan.Zero; - shouldSet = false; + duration = TimeSpan.Zero; + shouldSet = false; - break; - } + break; + } case 5: // From M - { - if (m != null) - try - { - duration = TimeSpan.FromMinutes(Utility.ToDouble(m.Text)); - shouldSet = true; + { + if (m != null) + try + { + duration = TimeSpan.FromMinutes(Utility.ToDouble(m.Text)); + shouldSet = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - duration = TimeSpan.Zero; - shouldSet = false; + duration = TimeSpan.Zero; + shouldSet = false; - break; - } + break; + } case 6: // From S - { - if (s != null) - try - { - duration = TimeSpan.FromSeconds(Utility.ToDouble(s.Text)); - shouldSet = true; + { + if (s != null) + try + { + duration = TimeSpan.FromSeconds(Utility.ToDouble(s.Text)); + shouldSet = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - duration = TimeSpan.Zero; - shouldSet = false; + duration = TimeSpan.Zero; + shouldSet = false; - break; - } + break; + } default: return; } diff --git a/Projects/Scripts/Gumps/BaseGridGump.cs b/Projects/Scripts/Gumps/BaseGridGump.cs index 2f34840df..e420ca459 100644 --- a/Projects/Scripts/Gumps/BaseGridGump.cs +++ b/Projects/Scripts/Gumps/BaseGridGump.cs @@ -18,11 +18,11 @@ namespace Server.Gumps { } - public int CurrentPage{ get; private set; } + public int CurrentPage { get; private set; } - public int CurrentX{ get; private set; } + public int CurrentX { get; private set; } - public int CurrentY{ get; private set; } + public int CurrentY { get; private set; } public virtual int BorderSize => 10; public virtual int OffsetSize => 1; diff --git a/Projects/Scripts/Gumps/BaseImageTileButtonsGump.cs b/Projects/Scripts/Gumps/BaseImageTileButtonsGump.cs index a72944a45..80194473d 100644 --- a/Projects/Scripts/Gumps/BaseImageTileButtonsGump.cs +++ b/Projects/Scripts/Gumps/BaseImageTileButtonsGump.cs @@ -46,12 +46,11 @@ namespace Server.Gumps public class BaseImageTileButtonsGump : Gump { - public BaseImageTileButtonsGump(TextDefinition header, List buttons) : - this(header, buttons.ToArray()) + public BaseImageTileButtonsGump(TextDefinition header, List buttons) : this(header, buttons.ToArray()) { } - public BaseImageTileButtonsGump(TextDefinition header, ImageTileButtonInfo[] buttons) : base(10, 10) //Coords are 0, o on OSI, intentional difference + public BaseImageTileButtonsGump(TextDefinition header, ImageTileButtonInfo[] buttons) : base(10, 10) // Coords are 0, o on OSI, intentional difference { Buttons = buttons; AddPage(0); @@ -65,7 +64,7 @@ namespace Server.Gumps AddImageTiled(10, y + 54, x, 20, 0xA40); AddAlphaRegion(10, 10, x, y + 64); - AddButton(10, y + 54, 0xFB1, 0xFB2, 0); //Cancel Button + AddButton(10, y + 54, 0xFB1, 0xFB2, 0); // Cancel Button AddHtmlLocalized(45, y + 56, x - 50, 20, 1060051, 0x7FFF); // CANCEL TextDefinition.AddHtmlText(this, 14, 12, x, 20, header, false, false, 0x7FFF, 0xFFFFFF); @@ -101,7 +100,7 @@ namespace Server.Gumps } } - protected ImageTileButtonInfo[] Buttons{ get; } + protected ImageTileButtonInfo[] Buttons { get; } protected virtual int XItems => 2; protected virtual int YItems => 5; diff --git a/Projects/Scripts/Gumps/CategorizedAddGump.cs b/Projects/Scripts/Gumps/CategorizedAddGump.cs index 9bd657416..b87996b8f 100644 --- a/Projects/Scripts/Gumps/CategorizedAddGump.cs +++ b/Projects/Scripts/Gumps/CategorizedAddGump.cs @@ -8,7 +8,7 @@ namespace Server.Gumps { public abstract class CAGNode { - public abstract string Caption{ get; } + public abstract string Caption { get; } public abstract void OnClick(Mobile from, int page); } @@ -28,13 +28,13 @@ namespace Server.Gumps Hue = XmlConvert.ToInt32(xml.Value); } - public Type Type{ get; } + public Type Type { get; } - public int ItemID{ get; } + public int ItemID { get; } - public int Hue{ get; } + public int Hue { get; } - public CAGCategory Parent{ get; } + public CAGCategory Parent { get; } public override string Caption => Type == null ? "bad type" : Type.Name; @@ -60,7 +60,7 @@ namespace Server.Gumps private CAGCategory() { Title = "no data"; - Nodes = new CAGNode[0]; + Nodes = Array.Empty(); } public CAGCategory(CAGCategory parent, XmlTextReader xml) @@ -77,7 +77,7 @@ namespace Server.Gumps if (xml.IsEmptyElement) { - Nodes = new CAGNode[0]; + Nodes = Array.Empty(); } else { @@ -102,11 +102,11 @@ namespace Server.Gumps } } - public string Title{ get; } + public string Title { get; } - public CAGNode[] Nodes{ get; } + public CAGNode[] Nodes { get; } - public CAGCategory Parent{ get; } + public CAGCategory Parent { get; } public override string Caption => Title; @@ -123,7 +123,6 @@ namespace Server.Gumps { XmlTextReader xml = new XmlTextReader(path) { WhitespaceHandling = WhitespaceHandling.None }; - while (xml.Read()) if (xml.Name == "category" && xml.NodeType == XmlNodeType.Element) { @@ -143,7 +142,7 @@ namespace Server.Gumps { public static bool OldStyle = PropsConfig.OldStyle; - public static readonly int EntryHeight = 24; //PropsConfig.EntryHeight; + public static readonly int EntryHeight = 24; // PropsConfig.EntryHeight; public static readonly int OffsetSize = PropsConfig.OffsetSize; public static readonly int BorderSize = PropsConfig.BorderSize; @@ -184,7 +183,8 @@ namespace Server.Gumps public static readonly int NextButtonID1 = PropsConfig.NextButtonID1; public static readonly int NextButtonID2 = PropsConfig.NextButtonID2; - private static bool PrevLabel = false, NextLabel = false; + private static readonly bool PrevLabel = false; + private static readonly bool NextLabel = false; private static readonly int PrevLabelOffsetX = PrevWidth + 1; private static readonly int PrevLabelOffsetY = 0; @@ -200,9 +200,9 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private CAGCategory m_Category; + private readonly CAGCategory m_Category; - private Mobile m_Owner; + private readonly Mobile m_Owner; private int m_Page; public CategorizedAddGump(Mobile owner) : this(owner, CAGCategory.Root) @@ -340,46 +340,46 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: // Closed - { - return; - } - case 1: // Up - { - if (m_Category.Parent != null) { - int index = Array.IndexOf(m_Category.Parent.Nodes, m_Category) / EntryCount; - - if (index < 0) - index = 0; - - from.SendGump(new CategorizedAddGump(from, m_Category.Parent, index)); + return; } + case 1: // Up + { + if (m_Category.Parent != null) + { + int index = Array.IndexOf(m_Category.Parent.Nodes, m_Category) / EntryCount; - break; - } + if (index < 0) + index = 0; + + from.SendGump(new CategorizedAddGump(from, m_Category.Parent, index)); + } + + break; + } case 2: // Previous - { - if (m_Page > 0) - from.SendGump(new CategorizedAddGump(from, m_Category, m_Page - 1)); + { + if (m_Page > 0) + from.SendGump(new CategorizedAddGump(from, m_Category, m_Page - 1)); - break; - } + break; + } case 3: // Next - { - if ((m_Page + 1) * EntryCount < m_Category.Nodes.Length) - from.SendGump(new CategorizedAddGump(from, m_Category, m_Page + 1)); + { + if ((m_Page + 1) * EntryCount < m_Category.Nodes.Length) + from.SendGump(new CategorizedAddGump(from, m_Category, m_Page + 1)); - break; - } + break; + } default: - { - int index = m_Page * EntryCount + (info.ButtonID - 4); + { + int index = m_Page * EntryCount + (info.ButtonID - 4); - if (index >= 0 && index < m_Category.Nodes.Length) - m_Category.Nodes[index].OnClick(from, m_Page); + if (index >= 0 && index < m_Category.Nodes.Length) + m_Category.Nodes[index].OnClick(from, m_Page); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Gumps/ClientGump.cs b/Projects/Scripts/Gumps/ClientGump.cs index 357851480..6f0c9ab6b 100644 --- a/Projects/Scripts/Gumps/ClientGump.cs +++ b/Projects/Scripts/Gumps/ClientGump.cs @@ -10,7 +10,7 @@ namespace Server.Gumps public class ClientGump : Gump { private const int LabelColor32 = 0xFFFFFF; - private NetState m_State; + private readonly NetState m_State; public ClientGump(Mobile from, NetState state, string initialText = "") : base(30, 20) { @@ -158,137 +158,137 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Tell - { - TextRelay text = info.GetTextEntry(0); - - if (text != null) { - focus.SendMessage(0x482, "{0} tells you:", from.Name); - focus.SendMessage(0x482, text.Text); + TextRelay text = info.GetTextEntry(0); - CommandLogging.WriteLine(from, "{0} {1} telling {2} \"{3}\" ", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(focus), text.Text); + if (text != null) + { + focus.SendMessage(0x482, "{0} tells you:", from.Name); + focus.SendMessage(0x482, text.Text); + + CommandLogging.WriteLine(from, "{0} {1} telling {2} \"{3}\" ", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(focus), text.Text); + } + + from.SendGump(new ClientGump(from, m_State)); + + break; } - - from.SendGump(new ClientGump(from, m_State)); - - break; - } case 4: // Props - { - Resend(from, info); - - if (!BaseCommand.IsAccessible(from, focus)) { - from.SendLocalizedMessage(500447); // That is not accessible. - } - else - { - from.SendGump(new PropertiesGump(from, focus)); - CommandLogging.WriteLine(from, "{0} {1} opening properties gump of {2} ", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(focus)); - } + Resend(from, info); - break; - } + if (!BaseCommand.IsAccessible(from, focus)) + { + from.SendLocalizedMessage(500447); // That is not accessible. + } + else + { + from.SendGump(new PropertiesGump(from, focus)); + CommandLogging.WriteLine(from, "{0} {1} opening properties gump of {2} ", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(focus)); + } + + break; + } case 5: // Go to - { - if (focus.Map == null || focus.Map == Map.Internal) { - from.SendMessage("That character is not in the world."); - } - else - { - from.MoveToWorld(focus.Location, focus.Map); - Resend(from, info); + if (focus.Map == null || focus.Map == Map.Internal) + { + from.SendMessage("That character is not in the world."); + } + else + { + from.MoveToWorld(focus.Location, focus.Map); + Resend(from, info); - CommandLogging.WriteLine(from, "{0} {1} going to {2}, Location {3}, Map {4}", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(focus), focus.Location, focus.Map); - } + CommandLogging.WriteLine(from, "{0} {1} going to {2}, Location {3}, Map {4}", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(focus), focus.Location, focus.Map); + } - break; - } + break; + } case 6: // Get - { - if (from.Map == null || from.Map == Map.Internal) { - from.SendMessage("You cannot bring that person here."); + if (from.Map == null || from.Map == Map.Internal) + { + from.SendMessage("You cannot bring that person here."); + } + else + { + focus.MoveToWorld(from.Location, from.Map); + Resend(from, info); + + CommandLogging.WriteLine(from, "{0} {1} bringing {2} to Location {3}, Map {4}", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(focus), from.Location, from.Map); + } + + break; } - else + case 7: // Move { - focus.MoveToWorld(from.Location, from.Map); + from.Target = new MoveTarget(focus); Resend(from, info); - CommandLogging.WriteLine(from, "{0} {1} bringing {2} to Location {3}, Map {4}", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(focus), from.Location, from.Map); + break; } - - break; - } - case 7: // Move - { - from.Target = new MoveTarget(focus); - Resend(from, info); - - break; - } case 8: // Kick - { - if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel) { - focus.Say("I've been kicked!"); + if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel) + { + focus.Say("I've been kicked!"); - m_State.Dispose(); + m_State.Dispose(); - CommandLogging.WriteLine(from, "{0} {1} kicking {2} ", from.AccessLevel, CommandLogging.Format(from), - CommandLogging.Format(focus)); + CommandLogging.WriteLine(from, "{0} {1} kicking {2} ", from.AccessLevel, CommandLogging.Format(from), + CommandLogging.Format(focus)); + } + + break; } - - break; - } case 9: // Kill - { - if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel) { - focus.Kill(); - CommandLogging.WriteLine(from, "{0} {1} killing {2} ", from.AccessLevel, CommandLogging.Format(from), - CommandLogging.Format(focus)); + if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel) + { + focus.Kill(); + CommandLogging.WriteLine(from, "{0} {1} killing {2} ", from.AccessLevel, CommandLogging.Format(from), + CommandLogging.Format(focus)); + } + + Resend(from, info); + + break; } - - Resend(from, info); - - break; - } - case 10: //Res - { - if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel) + case 10: // Res { - focus.PlaySound(0x214); - focus.FixedEffect(0x376A, 10, 16); + if (from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel) + { + focus.PlaySound(0x214); + focus.FixedEffect(0x376A, 10, 16); - focus.Resurrect(); + focus.Resurrect(); - CommandLogging.WriteLine(from, "{0} {1} resurrecting {2} ", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(focus)); + CommandLogging.WriteLine(from, "{0} {1} resurrecting {2} ", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(focus)); + } + + Resend(from, info); + + break; } - - Resend(from, info); - - break; - } case 11: // Skills - { - Resend(from, info); - - if (from.AccessLevel > focus.AccessLevel) { - from.SendGump(new SkillsGump(from, focus)); - CommandLogging.WriteLine(from, "{0} {1} Opening Skills gump of {2} ", from.AccessLevel, - CommandLogging.Format(from), CommandLogging.Format(focus)); - } + Resend(from, info); - break; - } + if (from.AccessLevel > focus.AccessLevel) + { + from.SendGump(new SkillsGump(from, focus)); + CommandLogging.WriteLine(from, "{0} {1} Opening Skills gump of {2} ", from.AccessLevel, + CommandLogging.Format(from), CommandLogging.Format(focus)); + } + + break; + } } } diff --git a/Projects/Scripts/Gumps/CommentsGump.cs b/Projects/Scripts/Gumps/CommentsGump.cs index f884de9b6..c4cf105d6 100644 --- a/Projects/Scripts/Gumps/CommentsGump.cs +++ b/Projects/Scripts/Gumps/CommentsGump.cs @@ -8,7 +8,7 @@ namespace Server.Gumps { public class CommentsGump : Gump { - private Account m_Acct; + private readonly Account m_Acct; public CommentsGump(Account acct) : base(30, 30) { @@ -89,7 +89,7 @@ namespace Server.Gumps public class CommentPrompt : Prompt { - private Account m_Acct; + private readonly Account m_Acct; public CommentPrompt(Account acct) => m_Acct = acct; @@ -104,7 +104,7 @@ namespace Server.Gumps { base.OnResponse(from, text); from.SendMessage("Comment added."); - //m_Acct.AddComment( from.Name, text ); + // m_Acct.AddComment( from.Name, text ); m_Acct.Comments.Add(new AccountComment(from.Name, text)); from.CloseGump(); from.SendGump(new CommentsGump(m_Acct)); diff --git a/Projects/Scripts/Gumps/ConfirmBreakCrystalGump.cs b/Projects/Scripts/Gumps/ConfirmBreakCrystalGump.cs index 436279a88..0adf559a9 100644 --- a/Projects/Scripts/Gumps/ConfirmBreakCrystalGump.cs +++ b/Projects/Scripts/Gumps/ConfirmBreakCrystalGump.cs @@ -5,7 +5,7 @@ namespace Server.Gumps { public class ConfirmBreakCrystalGump : BaseConfirmGump { - private BaseImprisonedMobile m_Item; + private readonly BaseImprisonedMobile m_Item; public ConfirmBreakCrystalGump(BaseImprisonedMobile item) => m_Item = item; diff --git a/Projects/Scripts/Gumps/ConfirmHeritageGump.cs b/Projects/Scripts/Gumps/ConfirmHeritageGump.cs index 40635d70d..28497d464 100644 --- a/Projects/Scripts/Gumps/ConfirmHeritageGump.cs +++ b/Projects/Scripts/Gumps/ConfirmHeritageGump.cs @@ -7,8 +7,8 @@ namespace Server.Gumps { public class ConfirmHeritageGump : Gump { - private Type[] m_Selected; - private HeritageToken m_Token; + private readonly Type[] m_Selected; + private readonly HeritageToken m_Token; public ConfirmHeritageGump(HeritageToken token, Type[] selected, int cliloc) : base(60, 36) { diff --git a/Projects/Scripts/Gumps/ConfirmHouseResize.cs b/Projects/Scripts/Gumps/ConfirmHouseResize.cs index c572e08e6..02126a76b 100644 --- a/Projects/Scripts/Gumps/ConfirmHouseResize.cs +++ b/Projects/Scripts/Gumps/ConfirmHouseResize.cs @@ -7,8 +7,8 @@ namespace Server.Gumps { public class ConfirmHouseResize : Gump { - private BaseHouse m_House; - private Mobile m_Mobile; + private readonly BaseHouse m_House; + private readonly Mobile m_Mobile; public ConfirmHouseResize(Mobile mobile, BaseHouse house) : base(110, 100) { @@ -65,7 +65,7 @@ namespace Server.Gumps return; } - /*else if ( m_House.PlayerVendors.Count > 0 ) + /*else if (m_House.PlayerVendors.Count > 0) { m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving. return; diff --git a/Projects/Scripts/Gumps/ConfirmReleaseGump.cs b/Projects/Scripts/Gumps/ConfirmReleaseGump.cs index 747791df3..e947eae2b 100644 --- a/Projects/Scripts/Gumps/ConfirmReleaseGump.cs +++ b/Projects/Scripts/Gumps/ConfirmReleaseGump.cs @@ -5,8 +5,8 @@ namespace Server.Gumps { public class ConfirmReleaseGump : Gump { - private Mobile m_From; - private BaseCreature m_Pet; + private readonly Mobile m_From; + private readonly BaseCreature m_Pet; public ConfirmReleaseGump(Mobile from, BaseCreature pet) : base(50, 50) { diff --git a/Projects/Scripts/Gumps/DawnsMusicBoxGump.cs b/Projects/Scripts/Gumps/DawnsMusicBoxGump.cs index 498642551..9a3714c0d 100644 --- a/Projects/Scripts/Gumps/DawnsMusicBoxGump.cs +++ b/Projects/Scripts/Gumps/DawnsMusicBoxGump.cs @@ -5,7 +5,7 @@ namespace Server.Gumps { public class DawnsMusicBoxGump : Gump { - private DawnsMusicBox m_Box; + private readonly DawnsMusicBox m_Box; public DawnsMusicBoxGump(DawnsMusicBox box) : base(60, 36) diff --git a/Projects/Scripts/Gumps/Go/ChildNode.cs b/Projects/Scripts/Gumps/Go/ChildNode.cs index dc4eda4a9..e45222348 100644 --- a/Projects/Scripts/Gumps/Go/ChildNode.cs +++ b/Projects/Scripts/Gumps/Go/ChildNode.cs @@ -11,11 +11,11 @@ namespace Server.Gumps Parse(xml); } - public ParentNode Parent{ get; } + public ParentNode Parent { get; } - public string Name{ get; private set; } + public string Name { get; private set; } - public Point3D Location{ get; private set; } + public Point3D Location { get; private set; } private void Parse(XmlTextReader xml) { diff --git a/Projects/Scripts/Gumps/Go/GoGump.cs b/Projects/Scripts/Gumps/Go/GoGump.cs index ec26774c9..f66457fd9 100644 --- a/Projects/Scripts/Gumps/Go/GoGump.cs +++ b/Projects/Scripts/Gumps/Go/GoGump.cs @@ -44,7 +44,8 @@ namespace Server.Gumps public static readonly int EntryHeight = PropsConfig.EntryHeight; public static readonly int BorderSize = PropsConfig.BorderSize; - private static bool PrevLabel = false, NextLabel = false; + private static readonly bool PrevLabel = false; + private static readonly bool NextLabel = false; private static readonly int PrevLabelOffsetX = PrevWidth + 1; private static readonly int PrevLabelOffsetY = 0; @@ -60,10 +61,10 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private ParentNode m_Node; - private int m_Page; + private readonly ParentNode m_Node; + private readonly int m_Page; - private LocationTree m_Tree; + private readonly LocationTree m_Tree; private GoGump(int page, Mobile from, LocationTree tree, ParentNode node) : base(50, 50) { @@ -194,42 +195,42 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: - { - if (m_Node.Parent != null) - from.SendGump(new GoGump(0, from, m_Tree, m_Node.Parent)); - - break; - } - case 2: - { - if (m_Page > 0) - from.SendGump(new GoGump(m_Page - 1, from, m_Tree, m_Node)); - - break; - } - case 3: - { - if ((m_Page + 1) * EntryCount < m_Node.Children.Length) - from.SendGump(new GoGump(m_Page + 1, from, m_Tree, m_Node)); - - break; - } - default: - { - int index = info.ButtonID - 4; - - if (index >= 0 && index < m_Node.Children.Length) { - IGoNode o = m_Node.Children[index]; + if (m_Node.Parent != null) + from.SendGump(new GoGump(0, from, m_Tree, m_Node.Parent)); - if (o is ParentNode node) - from.SendGump(new GoGump(0, from, m_Tree, node)); - else - from.MoveToWorld(((ChildNode)o).Location, m_Tree.Map); + break; } + case 2: + { + if (m_Page > 0) + from.SendGump(new GoGump(m_Page - 1, from, m_Tree, m_Node)); - break; - } + break; + } + case 3: + { + if ((m_Page + 1) * EntryCount < m_Node.Children.Length) + from.SendGump(new GoGump(m_Page + 1, from, m_Tree, m_Node)); + + break; + } + default: + { + int index = info.ButtonID - 4; + + if (index >= 0 && index < m_Node.Children.Length) + { + IGoNode o = m_Node.Children[index]; + + if (o is ParentNode node) + from.SendGump(new GoGump(0, from, m_Tree, node)); + else + from.MoveToWorld(((ChildNode)o).Location, m_Tree.Map); + } + + break; + } } } } diff --git a/Projects/Scripts/Gumps/Go/LocationTree.cs b/Projects/Scripts/Gumps/Go/LocationTree.cs index c2b73e576..08b62bbca 100644 --- a/Projects/Scripts/Gumps/Go/LocationTree.cs +++ b/Projects/Scripts/Gumps/Go/LocationTree.cs @@ -23,11 +23,11 @@ namespace Server.Gumps } } - public Dictionary LastBranch{ get; } + public Dictionary LastBranch { get; } - public Map Map{ get; } + public Map Map { get; } - public ParentNode Root{ get; } + public ParentNode Root { get; } private ParentNode Parse(XmlTextReader xml) { diff --git a/Projects/Scripts/Gumps/Go/ParentNode.cs b/Projects/Scripts/Gumps/Go/ParentNode.cs index f58b767aa..a0c0da1cb 100644 --- a/Projects/Scripts/Gumps/Go/ParentNode.cs +++ b/Projects/Scripts/Gumps/Go/ParentNode.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Xml; @@ -5,31 +6,31 @@ namespace Server.Gumps { public interface IGoNode { - ParentNode Parent{ get; } - string Name{ get; } + ParentNode Parent { get; } + string Name { get; } } - + public class ParentNode : IGoNode { public ParentNode(XmlTextReader xml, ParentNode parent) { Parent = parent; - + Parse(xml); } - public ParentNode Parent{ get; } + public ParentNode Parent { get; } - public IGoNode[] Children{ get; private set; } + public IGoNode[] Children { get; private set; } - public string Name{ get; private set; } + public string Name { get; private set; } private void Parse(XmlTextReader xml) { Name = xml.MoveToAttribute("name") ? xml.Value : "empty"; if (xml.IsEmptyElement) - Children = new IGoNode[0]; + Children = Array.Empty(); else { List children = new List(); @@ -49,4 +50,4 @@ namespace Server.Gumps } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Gumps/Guilds/GuildAbbrvPrompt.cs b/Projects/Scripts/Gumps/Guilds/GuildAbbrvPrompt.cs index f0f94a1c0..8b5ad63d0 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildAbbrvPrompt.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildAbbrvPrompt.cs @@ -5,8 +5,8 @@ namespace Server.Gumps { public class GuildAbbrvPrompt : Prompt { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildAbbrvPrompt(Mobile m, Guild g) { diff --git a/Projects/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs b/Projects/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs index 018f390ef..16e893918 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildAdminCandidatesGump.cs @@ -29,102 +29,98 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); - break; - } + break; + } case 1: // Accept - { - int[] switches = info.Switches; - - if (switches.Length > 0) { - int index = switches[0]; + int[] switches = info.Switches; - if (index >= 0 && index < m_List.Count) + if (switches.Length > 0) { - Mobile m = m_List[index]; + int index = switches[0]; - if (m?.Deleted == false) + if (index >= 0 && index < m_List.Count) { - #region Factions + Mobile m = m_List[index]; - PlayerState guildState = PlayerState.Find(m_Guild.Leader); - PlayerState targetState = PlayerState.Find(m); - - Faction guildFaction = guildState?.Faction; - Faction targetFaction = targetState?.Faction; - - if (guildFaction != targetFaction) + if (m?.Deleted == false) { - if (guildFaction == null) - m_Mobile.SendLocalizedMessage( - 1013027); // That player cannot join a non-faction guild. - else if (targetFaction == null) - m_Mobile.SendLocalizedMessage( - 1013026); // That player must be in a faction before joining this guild. + PlayerState guildState = PlayerState.Find(m_Guild.Leader); + PlayerState targetState = PlayerState.Find(m); + + Faction guildFaction = guildState?.Faction; + Faction targetFaction = targetState?.Faction; + + if (guildFaction != targetFaction) + { + if (guildFaction == null) + m_Mobile.SendLocalizedMessage( + 1013027); // That player cannot join a non-faction guild. + else if (targetFaction == null) + m_Mobile.SendLocalizedMessage( + 1013026); // That player must be in a faction before joining this guild. + else + m_Mobile.SendLocalizedMessage( + 1013028); // That person has a different faction affiliation. + + break; + } + + if (targetState?.IsLeaving == true) + { + // OSI does this quite strangely, so we'll just do it this way + m_Mobile.SendMessage( + "That person is quitting their faction and so you may not recruit them."); + break; + } + + m_Guild.Candidates.Remove(m); + m_Guild.Accepted.Add(m); + + GuildGump.EnsureClosed(m_Mobile); + + if (m_Guild.Candidates.Count > 0) + m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); else - m_Mobile.SendLocalizedMessage( - 1013028); // That person has a different faction affiliation. - - break; + m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); } - - if (targetState?.IsLeaving == true) - { - // OSI does this quite strangely, so we'll just do it this way - m_Mobile.SendMessage( - "That person is quitting their faction and so you may not recruit them."); - break; - } - - #endregion - - m_Guild.Candidates.Remove(m); - m_Guild.Accepted.Add(m); - - GuildGump.EnsureClosed(m_Mobile); - - if (m_Guild.Candidates.Count > 0) - m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); - else - m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); } } - } - break; - } + break; + } case 2: // Refuse - { - int[] switches = info.Switches; - - if (switches.Length > 0) { - int index = switches[0]; + int[] switches = info.Switches; - if (index >= 0 && index < m_List.Count) + if (switches.Length > 0) { - Mobile m = m_List[index]; + int index = switches[0]; - if (m?.Deleted == false) + if (index >= 0 && index < m_List.Count) { - m_Guild.Candidates.Remove(m); + Mobile m = m_List[index]; - GuildGump.EnsureClosed(m_Mobile); + if (m?.Deleted == false) + { + m_Guild.Candidates.Remove(m); - if (m_Guild.Candidates.Count > 0) - m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); - else - m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + GuildGump.EnsureClosed(m_Mobile); + + if (m_Guild.Candidates.Count > 0) + m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); + else + m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } } } - } - break; - } + break; + } } } } diff --git a/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs b/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs index c5eb72a9a..a3ac3c979 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildChangeTypeGump.cs @@ -8,8 +8,8 @@ namespace Server.Gumps { public class GuildChangeTypeGump : Gump { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildChangeTypeGump(Mobile from, Guild guild) : base(20, 30) { @@ -43,8 +43,8 @@ namespace Server.Gumps public override void OnResponse(NetState state, RelayInfo info) { - if (Guild.NewGuildSystem && !BaseGuildGump.IsLeader(m_Mobile, m_Guild) || - !Guild.NewGuildSystem && GuildGump.BadLeader(m_Mobile, m_Guild)) + if ((Guild.NewGuildSystem && !BaseGuildGump.IsLeader(m_Mobile, m_Guild)) || + (!Guild.NewGuildSystem && GuildGump.BadLeader(m_Mobile, m_Guild))) return; var newType = info.ButtonID switch diff --git a/Projects/Scripts/Gumps/Guilds/GuildCharterGump.cs b/Projects/Scripts/Gumps/Guilds/GuildCharterGump.cs index 16662a04f..b0ca9e220 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildCharterGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildCharterGump.cs @@ -6,8 +6,8 @@ namespace Server.Gumps public class GuildCharterGump : Gump { private const string DefaultWebsite = "https://github.com/runuo/"; - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildCharterGump(Mobile from, Guild guild) : base(20, 30) { @@ -51,15 +51,15 @@ namespace Server.Gumps case 0: return; // Close case 1: break; // Return to main menu case 2: - { - string website; + { + string website; - if ((website = m_Guild.Website) == null || (website = website.Trim()).Length <= 0) - website = DefaultWebsite; + if ((website = m_Guild.Website) == null || (website = website.Trim()).Length <= 0) + website = DefaultWebsite; - m_Mobile.LaunchBrowser(website); - break; - } + m_Mobile.LaunchBrowser(website); + break; + } } GuildGump.EnsureClosed(m_Mobile); diff --git a/Projects/Scripts/Gumps/Guilds/GuildCharterPrompt.cs b/Projects/Scripts/Gumps/Guilds/GuildCharterPrompt.cs index e3f265ba1..66b8d8f31 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildCharterPrompt.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildCharterPrompt.cs @@ -5,8 +5,8 @@ namespace Server.Gumps { public class GuildCharterPrompt : Prompt { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildCharterPrompt(Mobile m, Guild g) { diff --git a/Projects/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs b/Projects/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs index c60b6096c..e3ddef954 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildDeclareWarGump.cs @@ -46,7 +46,7 @@ namespace Server.Gumps { m_Mobile.SendLocalizedMessage(501184); // You cannot declare war against yourself! } - else if (g.WarInvitations.Contains(m_Guild) && m_Guild.WarDeclarations.Contains(g) || + else if ((g.WarInvitations.Contains(m_Guild) && m_Guild.WarDeclarations.Contains(g)) || m_Guild.IsWar(g)) { m_Mobile.SendLocalizedMessage(501183); // You are already at war with that guild. diff --git a/Projects/Scripts/Gumps/Guilds/GuildDeclareWarPrompt.cs b/Projects/Scripts/Gumps/Guilds/GuildDeclareWarPrompt.cs index 9b17dbaa0..281fedcf2 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildDeclareWarPrompt.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildDeclareWarPrompt.cs @@ -6,8 +6,8 @@ namespace Server.Gumps { public class GuildDeclareWarPrompt : Prompt { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildDeclareWarPrompt(Mobile m, Guild g) { diff --git a/Projects/Scripts/Gumps/Guilds/GuildGump.cs b/Projects/Scripts/Gumps/Guilds/GuildGump.cs index 9841c2e59..38094b9bc 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildGump.cs @@ -1,4 +1,3 @@ -using System; using Server.Guilds; using Server.Network; @@ -6,8 +5,8 @@ namespace Server.Gumps { public class GuildGump : Gump { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildGump(Mobile beholder, Guild guild) : base(20, 30) { @@ -122,7 +121,7 @@ namespace Server.Gumps public static bool BadLeader(Mobile m, Guild g) { - if (m.Deleted || g.Disbanded || m.AccessLevel < AccessLevel.GameMaster && g.Leader != m) + if (m.Deleted || g.Disbanded || (m.AccessLevel < AccessLevel.GameMaster && g.Leader != m)) return true; Item stone = g.Guildstone; @@ -132,7 +131,7 @@ namespace Server.Gumps public static bool BadMember(Mobile m, Guild g) { - if (m.Deleted || g.Disbanded || m.AccessLevel < AccessLevel.GameMaster && !g.IsMember(m)) + if (m.Deleted || g.Disbanded || (m.AccessLevel < AccessLevel.GameMaster && !g.IsMember(m))) return true; Item stone = g.Guildstone; @@ -148,71 +147,71 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Loyalty - { - EnsureClosed(m_Mobile); - m_Mobile.SendGump(new DeclareFealtyGump(m_Mobile, m_Guild)); - - break; - } - case 2: // Toggle display abbreviation - { - m_Mobile.DisplayGuildTitle = !m_Mobile.DisplayGuildTitle; - - EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); - - break; - } - case 3: // View the current roster - { - EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildRosterGump(m_Mobile, m_Guild)); - - break; - } - case 4: // Recruit - { - m_Mobile.Target = new GuildRecruitTarget(m_Mobile, m_Guild); - - break; - } - case 5: // Membership candidates - { - EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildCandidatesGump(m_Mobile, m_Guild)); - - break; - } - case 6: // View charter - { - EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildCharterGump(m_Mobile, m_Guild)); - - break; - } - case 7: // Resign - { - m_Guild.RemoveMember(m_Mobile); - - break; - } - case 8: // View wars - { - EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildWarGump(m_Mobile, m_Guild)); - - break; - } - case 9: // Guildmaster functions - { - if (m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Guild.Leader == m_Mobile) { EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); - } + m_Mobile.SendGump(new DeclareFealtyGump(m_Mobile, m_Guild)); - break; - } + break; + } + case 2: // Toggle display abbreviation + { + m_Mobile.DisplayGuildTitle = !m_Mobile.DisplayGuildTitle; + + EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); + + break; + } + case 3: // View the current roster + { + EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildRosterGump(m_Mobile, m_Guild)); + + break; + } + case 4: // Recruit + { + m_Mobile.Target = new GuildRecruitTarget(m_Mobile, m_Guild); + + break; + } + case 5: // Membership candidates + { + EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildCandidatesGump(m_Mobile, m_Guild)); + + break; + } + case 6: // View charter + { + EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildCharterGump(m_Mobile, m_Guild)); + + break; + } + case 7: // Resign + { + m_Guild.RemoveMember(m_Mobile); + + break; + } + case 8: // View wars + { + EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildWarGump(m_Mobile, m_Guild)); + + break; + } + case 9: // Guildmaster functions + { + if (m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Guild.Leader == m_Mobile) + { + EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + } + + break; + } } } } diff --git a/Projects/Scripts/Gumps/Guilds/GuildNamePrompt.cs b/Projects/Scripts/Gumps/Guilds/GuildNamePrompt.cs index 292a23b72..44695a718 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildNamePrompt.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildNamePrompt.cs @@ -5,8 +5,8 @@ namespace Server.Gumps { public class GuildNamePrompt : Prompt { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildNamePrompt(Mobile m, Guild g) { diff --git a/Projects/Scripts/Gumps/Guilds/GuildTitlePrompt.cs b/Projects/Scripts/Gumps/Guilds/GuildTitlePrompt.cs index 35e4655d0..60bda09a1 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildTitlePrompt.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildTitlePrompt.cs @@ -5,8 +5,9 @@ namespace Server.Gumps { public class GuildTitlePrompt : Prompt { - private Guild m_Guild; - private Mobile m_Leader, m_Target; + private readonly Guild m_Guild; + private readonly Mobile m_Leader; + private readonly Mobile m_Target; public GuildTitlePrompt(Mobile leader, Mobile target, Guild g) { diff --git a/Projects/Scripts/Gumps/Guilds/GuildWarAdminGump.cs b/Projects/Scripts/Gumps/Guilds/GuildWarAdminGump.cs index 64d284013..f8401635a 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildWarAdminGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildWarAdminGump.cs @@ -5,8 +5,8 @@ namespace Server.Gumps { public class GuildWarAdminGump : Gump { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildWarAdminGump(Mobile from, Guild guild) : base(20, 30) { @@ -71,47 +71,47 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Declare war - { - m_Mobile.SendLocalizedMessage(1018001); // Declare war through search - Enter Guild Name: - m_Mobile.Prompt = new GuildDeclareWarPrompt(m_Mobile, m_Guild); + { + m_Mobile.SendLocalizedMessage(1018001); // Declare war through search - Enter Guild Name: + m_Mobile.Prompt = new GuildDeclareWarPrompt(m_Mobile, m_Guild); - break; - } + break; + } case 2: // Declare peace - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildDeclarePeaceGump(m_Mobile, m_Guild)); + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildDeclarePeaceGump(m_Mobile, m_Guild)); - break; - } + break; + } case 3: // Accept war - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildAcceptWarGump(m_Mobile, m_Guild)); + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildAcceptWarGump(m_Mobile, m_Guild)); - break; - } + break; + } case 4: // Reject war - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildRejectWarGump(m_Mobile, m_Guild)); + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildRejectWarGump(m_Mobile, m_Guild)); - break; - } + break; + } case 5: // Rescind declarations - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildRescindDeclarationGump(m_Mobile, m_Guild)); + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildRescindDeclarationGump(m_Mobile, m_Guild)); - break; - } + break; + } case 6: // Return - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Gumps/Guilds/GuildWarGump.cs b/Projects/Scripts/Gumps/Guilds/GuildWarGump.cs index d2304dc45..54a8f8579 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildWarGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildWarGump.cs @@ -6,8 +6,8 @@ namespace Server.Gumps { public class GuildWarGump : Gump { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildWarGump(Mobile from, Guild guild) : base(20, 30) { diff --git a/Projects/Scripts/Gumps/Guilds/GuildWebsitePrompt.cs b/Projects/Scripts/Gumps/Guilds/GuildWebsitePrompt.cs index 16aae7a12..ba15f1960 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildWebsitePrompt.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildWebsitePrompt.cs @@ -5,8 +5,8 @@ namespace Server.Gumps { public class GuildWebsitePrompt : Prompt { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildWebsitePrompt(Mobile m, Guild g) { diff --git a/Projects/Scripts/Gumps/Guilds/GuildmasterGump.cs b/Projects/Scripts/Gumps/Guilds/GuildmasterGump.cs index 29a7be63a..c96e30a9d 100644 --- a/Projects/Scripts/Gumps/Guilds/GuildmasterGump.cs +++ b/Projects/Scripts/Gumps/Guilds/GuildmasterGump.cs @@ -6,8 +6,8 @@ namespace Server.Gumps { public class GuildmasterGump : Gump { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildmasterGump(Mobile from, Guild guild) : base(20, 30) { @@ -90,98 +90,98 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Main menu - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); - - break; - } - case 2: // Set guild name - { - m_Mobile.SendLocalizedMessage(1013060); // Enter new guild name (40 characters max): - m_Mobile.Prompt = new GuildNamePrompt(m_Mobile, m_Guild); - - break; - } - case 3: // Set guild abbreviation - { - m_Mobile.SendLocalizedMessage(1013061); // Enter new guild abbreviation (3 characters max): - m_Mobile.Prompt = new GuildAbbrvPrompt(m_Mobile, m_Guild); - - break; - } - case 4: // Change guild type - { - if (!Guild.OrderChaos) - return; - - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildChangeTypeGump(m_Mobile, m_Guild)); - - break; - } - case 5: // Set charter - { - m_Mobile.SendLocalizedMessage(1013071); // Enter the new guild charter (50 characters max): - m_Mobile.Prompt = new GuildCharterPrompt(m_Mobile, m_Guild); - - break; - } - case 6: // Dismiss member - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildDismissGump(m_Mobile, m_Guild)); - - break; - } - case 7: // War menu - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildWarAdminGump(m_Mobile, m_Guild)); - - break; - } - case 8: // Administer candidates - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); - - break; - } - case 9: // Set guildmaster's title - { - m_Mobile.SendLocalizedMessage(1013073); // Enter new guildmaster title (20 characters max): - m_Mobile.Prompt = new GuildTitlePrompt(m_Mobile, m_Mobile, m_Guild); - - break; - } - case 10: // Grant title - { - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GrantGuildTitleGump(m_Mobile, m_Guild)); - - break; - } - case 11: // Move guildstone - { - if (m_Guild.Guildstone != null) { - GuildTeleporter item = new GuildTeleporter(m_Guild.Guildstone); + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildGump(m_Mobile, m_Guild)); - m_Guild.Teleporter?.Delete(); - - m_Mobile.SendLocalizedMessage( - 501133); // Use the teleporting object placed in your backpack to move this guildstone. - - m_Mobile.AddToBackpack(item); - m_Guild.Teleporter = item; + break; } + case 2: // Set guild name + { + m_Mobile.SendLocalizedMessage(1013060); // Enter new guild name (40 characters max): + m_Mobile.Prompt = new GuildNamePrompt(m_Mobile, m_Guild); - GuildGump.EnsureClosed(m_Mobile); - m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + break; + } + case 3: // Set guild abbreviation + { + m_Mobile.SendLocalizedMessage(1013061); // Enter new guild abbreviation (3 characters max): + m_Mobile.Prompt = new GuildAbbrvPrompt(m_Mobile, m_Guild); - break; - } + break; + } + case 4: // Change guild type + { + if (!Guild.OrderChaos) + return; + + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildChangeTypeGump(m_Mobile, m_Guild)); + + break; + } + case 5: // Set charter + { + m_Mobile.SendLocalizedMessage(1013071); // Enter the new guild charter (50 characters max): + m_Mobile.Prompt = new GuildCharterPrompt(m_Mobile, m_Guild); + + break; + } + case 6: // Dismiss member + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildDismissGump(m_Mobile, m_Guild)); + + break; + } + case 7: // War menu + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildWarAdminGump(m_Mobile, m_Guild)); + + break; + } + case 8: // Administer candidates + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildAdminCandidatesGump(m_Mobile, m_Guild)); + + break; + } + case 9: // Set guildmaster's title + { + m_Mobile.SendLocalizedMessage(1013073); // Enter new guildmaster title (20 characters max): + m_Mobile.Prompt = new GuildTitlePrompt(m_Mobile, m_Mobile, m_Guild); + + break; + } + case 10: // Grant title + { + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GrantGuildTitleGump(m_Mobile, m_Guild)); + + break; + } + case 11: // Move guildstone + { + if (m_Guild.Guildstone != null) + { + GuildTeleporter item = new GuildTeleporter(m_Guild.Guildstone); + + m_Guild.Teleporter?.Delete(); + + m_Mobile.SendLocalizedMessage( + 501133); // Use the teleporting object placed in your backpack to move this guildstone. + + m_Mobile.AddToBackpack(item); + m_Guild.Teleporter = item; + } + + GuildGump.EnsureClosed(m_Mobile); + m_Mobile.SendGump(new GuildmasterGump(m_Mobile, m_Guild)); + + break; + } } } } diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs index 07f9d736f..c0e2d7fae 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/AdvancedSearch.cs @@ -8,8 +8,8 @@ namespace Server.Guilds public class GuildAdvancedSearchGump : BaseGuildGump { - private SearchSelectionCallback m_Callback; - private GuildDisplayType m_Display; + private readonly SearchSelectionCallback m_Callback; + private readonly GuildDisplayType m_Display; public GuildAdvancedSearchGump(PlayerMobile pm, Guild g, GuildDisplayType display, SearchSelectionCallback callback) : base(pm, g) @@ -45,7 +45,6 @@ namespace Server.Guilds AddHtmlLocalized(370, 373, 60, 26, 1006045, 0x0); // Cancel } - public override void OnResponse(NetState sender, RelayInfo info) { base.OnResponse(sender, info); diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs index bab0308bf..c504c605c 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildGump.cs @@ -15,11 +15,11 @@ namespace Server.Guilds pm.CloseGump(); } - protected Guild guild{ get; } + protected Guild guild { get; } - protected PlayerMobile player{ get; } + protected PlayerMobile player { get; } - //There's prolly a way to have all the vars set of inherited classes before something is called in the Ctor... but... I can't think of it right now, and I can't use Timer.DelayCall here :< + // There's prolly a way to have all the vars set of inherited classes before something is called in the Ctor... but... I can't think of it right now, and I can't use Timer.DelayCall here :< public virtual void PopulateGump() { @@ -40,7 +40,8 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { - PlayerMobile pm = sender.Mobile as PlayerMobile; + if (!(sender.Mobile is PlayerMobile pm)) + return; if (!IsMember(pm, guild)) return; @@ -48,36 +49,36 @@ namespace Server.Guilds switch (info.ButtonID) { case 1: - { - pm.SendGump(new GuildInfoGump(pm, guild)); - break; - } + { + pm.SendGump(new GuildInfoGump(pm, guild)); + break; + } case 2: - { - pm.SendGump(new GuildRosterGump(pm, guild)); - break; - } + { + pm.SendGump(new GuildRosterGump(pm, guild)); + break; + } case 3: - { - pm.SendGump(new GuildDiplomacyGump(pm, guild)); - break; - } + { + pm.SendGump(new GuildDiplomacyGump(pm, guild)); + break; + } } } public static bool IsLeader(Mobile m, Guild g) => !(m.Deleted || g.Disbanded || !(m is PlayerMobile) || - m.AccessLevel < AccessLevel.GameMaster && g.Leader != m); + (m.AccessLevel < AccessLevel.GameMaster && g.Leader != m)); public static bool IsMember(Mobile m, Guild g) => !(m.Deleted || g.Disbanded || !(m is PlayerMobile) || - m.AccessLevel < AccessLevel.GameMaster && !g.IsMember(m)); + (m.AccessLevel < AccessLevel.GameMaster && !g.IsMember(m))); public static bool CheckProfanity(string s, int maxLength = 50) { - //return NameVerification.Validate( s, 1, 50, true, true, false, int.MaxValue, ProfanityProtection.Exceptions, ProfanityProtection.Disallowed, ProfanityProtection.StartDisallowed ); //What am I doing wrong, this still allows chars like the <3 symbol... 3 AM. someone change this to use this + // return NameVerification.Validate( s, 1, 50, true, true, false, int.MaxValue, ProfanityProtection.Exceptions, ProfanityProtection.Disallowed, ProfanityProtection.StartDisallowed ); //What am I doing wrong, this still allows chars like the <3 symbol... 3 AM. someone change this to use this - //With testing on OSI, Guild stuff seems to follow a 'simpler' method of profanity protection + // With testing on OSI, Guild stuff seems to follow a 'simpler' method of profanity protection if (s.Length < 1 || s.Length > maxLength) return false; diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs index ecb5bb900..5dd867fab 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/BaseGuildListGump.cs @@ -10,9 +10,9 @@ namespace Server.Guilds { private const int itemsPerPage = 8; private bool m_Ascending; - private IComparer m_Comparer; - private InfoField[] m_Fields; - private string m_Filter; + private readonly IComparer m_Comparer; + private readonly InfoField[] m_Fields; + private readonly string m_Filter; private List m_List; private int m_StartNumber; @@ -51,10 +51,9 @@ namespace Server.Guilds m_List.Sort(m_Comparer); m_StartNumber = Math.Max(Math.Min(m_StartNumber, m_List.Count - 1), 0); - AddBackground(130, 75, 385, 30, 0xBB8); AddTextEntry(135, 80, 375, 30, 0x481, 1, m_Filter); - AddButton(520, 75, 0x867, 0x868, 5); //Filter Button + AddButton(520, 75, 0x867, 0x868, 5); // Filter Button int width = 0; for (int i = 0; i < m_Fields.Length; i++) @@ -84,13 +83,12 @@ namespace Server.Guilds else AddButton(95, 80, 0x15E1, 0x15E5, 7); // Forward - int itemNumber = 0; if (m_Ascending) for (int i = m_StartNumber; i < m_StartNumber + itemsPerPage && i < m_List.Count; i++) DrawEntry(m_List[i], i, itemNumber++); - else //descending, go from bottom of list to the top + else // descending, go from bottom of list to the top for (int i = m_List.Count - 1 - m_StartNumber; i >= 0 && i >= m_List.Count - itemsPerPage - m_StartNumber; i--) @@ -121,9 +119,9 @@ namespace Server.Guilds } if (HasRelationship(o)) - AddButton(40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index); //Info Button + AddButton(40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index); // Info Button else - AddButton(40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index); //Info Button + AddButton(40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index); // Info Button } protected abstract TextDefinition[] GetValuesFor(T o, int aryLength); @@ -140,24 +138,24 @@ namespace Server.Guilds switch (id) { - case 5: //Filter - { - TextRelay t = info.GetTextEntry(1); - pm.SendGump(GetResentGump(player, guild, m_Comparer, m_Ascending, t == null ? "" : t.Text, 0)); - break; - } - case 6: //Back - { - pm.SendGump( - GetResentGump(player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber - itemsPerPage)); - break; - } - case 7: //Forward - { - pm.SendGump( - GetResentGump(player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber + itemsPerPage)); - break; - } + case 5: // Filter + { + TextRelay t = info.GetTextEntry(1); + pm.SendGump(GetResentGump(player, guild, m_Comparer, m_Ascending, t == null ? "" : t.Text, 0)); + break; + } + case 6: // Back + { + pm.SendGump( + GetResentGump(player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber - itemsPerPage)); + break; + } + case 7: // Forward + { + pm.SendGump( + GetResentGump(player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber + itemsPerPage)); + break; + } } if (id >= 100 && id < 100 + m_Fields.Length) @@ -175,7 +173,6 @@ namespace Server.Guilds } } - public abstract Gump GetResentGump(PlayerMobile pm, Guild g, IComparer comparer, bool ascending, string filter, int startNumber); @@ -189,11 +186,11 @@ namespace Server.Guilds public struct InfoField { - public TextDefinition Name{ get; } + public TextDefinition Name { get; } - public int Width{ get; } + public int Width { get; } - public IComparer Comparer{ get; } + public IComparer Comparer { get; } public InfoField(TextDefinition name, int width, IComparer comparer) { diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs index ac1407c5d..324a2455e 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/Create Guild Gump.cs @@ -38,74 +38,74 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { if (!(sender.Mobile is PlayerMobile pm) || pm.Guild != null) - return; //Sanity + return; // Sanity switch (info.ButtonID) { case 1: - { - TextRelay tName = info.GetTextEntry(5); - TextRelay tAbbrev = info.GetTextEntry(6); + { + TextRelay tName = info.GetTextEntry(5); + TextRelay tAbbrev = info.GetTextEntry(6); - string guildName = tName == null ? "" : tName.Text; - string guildAbbrev = tAbbrev == null ? "" : tAbbrev.Text; + string guildName = tName == null ? "" : tName.Text; + string guildAbbrev = tAbbrev == null ? "" : tAbbrev.Text; - guildName = Utility.FixHtml(guildName.Trim()); - guildAbbrev = Utility.FixHtml(guildAbbrev.Trim()); + guildName = Utility.FixHtml(guildName.Trim()); + guildAbbrev = Utility.FixHtml(guildAbbrev.Trim()); - if (guildName.Length <= 0) - { - pm.SendLocalizedMessage(1070884); // Guild name cannot be blank. - } - else if (guildAbbrev.Length <= 0) - { - pm.SendLocalizedMessage(1070885); // You must provide a guild abbreviation. - } - else if (guildName.Length > Guild.NameLimit) - { - pm.SendLocalizedMessage(1063036, - Guild.NameLimit.ToString()); // A guild name cannot be more than ~1_val~ characters in length. - } - else if (guildAbbrev.Length > Guild.AbbrevLimit) - { - pm.SendLocalizedMessage(1063037, - Guild.AbbrevLimit.ToString()); // An abbreviation cannot exceed ~1_val~ characters in length. - } - else if (BaseGuild.FindByAbbrev(guildAbbrev) != null || !BaseGuildGump.CheckProfanity(guildAbbrev)) - { - pm.SendLocalizedMessage(501153); // That abbreviation is not available. - } - else if (BaseGuild.FindByName(guildName) != null || !BaseGuildGump.CheckProfanity(guildName)) - { - pm.SendLocalizedMessage(1063000); // That guild name is not available. - } - else if (!Banker.Withdraw(pm, Guild.RegistrationFee)) - { - pm.SendLocalizedMessage(1063001, - Guild.RegistrationFee - .ToString()); // You do not possess the ~1_val~ gold piece fee required to create a guild. - } - else - { - pm.SendLocalizedMessage(1060398, - Guild.RegistrationFee.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. - pm.SendLocalizedMessage(1063238); // Your new guild has been founded. - pm.Guild = new Guild(pm, guildName, guildAbbrev); - } + if (guildName.Length <= 0) + { + pm.SendLocalizedMessage(1070884); // Guild name cannot be blank. + } + else if (guildAbbrev.Length <= 0) + { + pm.SendLocalizedMessage(1070885); // You must provide a guild abbreviation. + } + else if (guildName.Length > Guild.NameLimit) + { + pm.SendLocalizedMessage(1063036, + Guild.NameLimit.ToString()); // A guild name cannot be more than ~1_val~ characters in length. + } + else if (guildAbbrev.Length > Guild.AbbrevLimit) + { + pm.SendLocalizedMessage(1063037, + Guild.AbbrevLimit.ToString()); // An abbreviation cannot exceed ~1_val~ characters in length. + } + else if (BaseGuild.FindByAbbrev(guildAbbrev) != null || !BaseGuildGump.CheckProfanity(guildAbbrev)) + { + pm.SendLocalizedMessage(501153); // That abbreviation is not available. + } + else if (BaseGuild.FindByName(guildName) != null || !BaseGuildGump.CheckProfanity(guildName)) + { + pm.SendLocalizedMessage(1063000); // That guild name is not available. + } + else if (!Banker.Withdraw(pm, Guild.RegistrationFee)) + { + pm.SendLocalizedMessage(1063001, + Guild.RegistrationFee + .ToString()); // You do not possess the ~1_val~ gold piece fee required to create a guild. + } + else + { + pm.SendLocalizedMessage(1060398, + Guild.RegistrationFee.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + pm.SendLocalizedMessage(1063238); // Your new guild has been founded. + pm.Guild = new Guild(pm, guildName, guildAbbrev); + } - break; - } + break; + } case 2: - { - pm.AcceptGuildInvites = !pm.AcceptGuildInvites; + { + pm.AcceptGuildInvites = !pm.AcceptGuildInvites; - if (pm.AcceptGuildInvites) - pm.SendLocalizedMessage(1070699); // You are now accepting guild invitations. - else - pm.SendLocalizedMessage(1070698); // You are now ignoring guild invitations. + if (pm.AcceptGuildInvites) + pm.SendLocalizedMessage(1070699); // You are now accepting guild invitations. + else + pm.SendLocalizedMessage(1070698); // You are now ignoring guild invitations. - break; - } + break; + } } } } diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs index 2c3e175b8..9d7ef253d 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/DiplomacyGump.cs @@ -15,7 +15,7 @@ namespace Server.Guilds public class GuildDiplomacyGump : BaseGuildListGump { private GuildDisplayType m_Display; - private TextDefinition m_LowerText; + private readonly TextDefinition m_LowerText; public GuildDiplomacyGump(PlayerMobile pm, Guild g) : this(pm, g, NameComparer.Instance, true, "", 0, GuildDisplayType.All, @@ -49,9 +49,9 @@ namespace Server.Guilds : base(pm, g, list, currentComparer, ascending, filter, startNumber, new[] { - new InfoField(1062954, 280, NameComparer.Instance), //Guild Name - new InfoField(1062957, 50, AbbrevComparer.Instance), //Abbrev - new InfoField(1062958, 120, new StatusComparer(g)) //Guild Title + new InfoField(1062954, 280, NameComparer.Instance), // Guild Name + new InfoField(1062957, 50, AbbrevComparer.Instance), // Abbrev + new InfoField(1062958, 120, new StatusComparer(g)) // Guild Title }) { m_Display = display; @@ -86,8 +86,7 @@ namespace Server.Guilds defs[0] = g == guild ? Color(g.Name, 0x006600) : g.Name; defs[1] = g.Abbreviation; - defs[2] = 3000085; //Peace - + defs[2] = 3000085; // Peace if (guild.IsAlly(g)) { @@ -120,7 +119,7 @@ namespace Server.Guilds if (leader != null) { - if (guild == leader && alliance.IsPendingMember(g) || g == leader && alliance.IsPendingMember(guild)) + if ((guild == leader && alliance.IsPendingMember(g)) || (g == leader && alliance.IsPendingMember(guild))) return true; } else if (alliance.IsPendingMember(g)) @@ -134,8 +133,8 @@ namespace Server.Guilds public override void DrawEndingEntry(int itemNumber) { - //AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, 1063136 + (int)m_Display, 0xF, false, false ); // Showing All Guilds/Awaiting Action/ w/Relation Ship - //AddHtmlText( 66, 153 + itemNumber * 28, 280, 26, m_LowerText, false, false ); + // AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, 1063136 + (int)m_Display, 0xF, false, false ); // Showing All Guilds/Awaiting Action/ w/Relation Ship + // AddHtmlText( 66, 153 + itemNumber * 28, 280, 26, m_LowerText, false, false ); if (m_LowerText?.Number > 0) AddHtmlLocalized(66, 153 + itemNumber * 28, 280, 26, m_LowerText.Number, 0xF); @@ -150,7 +149,6 @@ namespace Server.Guilds } } - protected override bool IsFiltered(Guild g, string filter) { if (g == null) @@ -159,25 +157,23 @@ namespace Server.Guilds switch (m_Display) { case GuildDisplayType.Relations: - { - //if ( !( guild.IsWar( g ) || guild.IsAlly( g ) ) ) + { + // 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; + 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; - } + return false; + } case GuildDisplayType.AwaitingAction: - { - return !HasRelationship(g); - } + { + return !HasRelationship(g); + } } return !(Insensitive.Contains(g.Name, filter) || Insensitive.Contains(g.Abbreviation, filter)); } - public override Gump GetResentGump(PlayerMobile pm, Guild g, IComparer comparer, bool ascending, string filter, int startNumber) => new GuildDiplomacyGump(pm, g, comparer, ascending, filter, startNumber, m_Display); @@ -207,8 +203,6 @@ namespace Server.Guilds ResendGump(); } - #region Comparers - private class NameComparer : IComparer { public static readonly IComparer Instance = new NameComparer(); @@ -228,7 +222,7 @@ namespace Server.Guilds private class StatusComparer : IComparer { - private Guild m_Guild; + private readonly Guild m_Guild; public StatusComparer(Guild g) => m_Guild = g; @@ -249,7 +243,6 @@ namespace Server.Guilds else if (m_Guild.IsWar(x)) aStatus = GuildCompareStatus.War; - if (m_Guild.IsAlly(y)) bStatus = GuildCompareStatus.Ally; else if (m_Guild.IsWar(y)) @@ -282,7 +275,5 @@ namespace Server.Guilds return Insensitive.Compare(x.Abbreviation, y.Abbreviation); } } - - #endregion } } diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs index 404295ca4..cf94cc0c6 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInfoGump.cs @@ -7,7 +7,7 @@ namespace Server.Guilds { public class GuildInfoGump : BaseGuildGump { - private bool m_IsResigning; + private readonly bool m_IsResigning; public GuildInfoGump(PlayerMobile pm, Guild g, bool isResigning = false) : base(pm, g) { @@ -34,7 +34,7 @@ namespace Server.Guilds if (guild.Alliance?.IsMember(guild) == true) { AddHtml(233, 118, 320, 26, guild.Alliance.Name); - AddButton(40, 120, 0x4B9, 0x4BA, 6); //Alliance Roster + AddButton(40, 120, 0x4B9, 0x4BA, 6); // Alliance Roster } if (Guild.OrderChaos && isLeader) @@ -54,21 +54,20 @@ namespace Server.Guilds AddImageTiled(65, 196, 480, 4, 0x238D); - string s = guild.Charter; if (string.IsNullOrEmpty(s)) s = "The guild leader has not yet set the guild charter."; AddHtml(65, 216, 480, 80, s, true, true); if (isLeader) - AddButton(40, 251, 0x4B9, 0x4BA, 4); //Charter Edit button + AddButton(40, 251, 0x4B9, 0x4BA, 4); // Charter Edit button s = guild.Website; if (string.IsNullOrEmpty(s)) s = "Guild website not yet set."; AddHtml(65, 306, 480, 30, s, true); if (isLeader) - AddButton(40, 313, 0x4B9, 0x4BA, 5); //Website Edit button + AddButton(40, 313, 0x4B9, 0x4BA, 5); // Website Edit button AddCheck(65, 370, 0xD2, 0xD3, player.DisplayGuildTitle, 0); AddHtmlLocalized(95, 370, 150, 26, 1063085, 0x0); // Show Guild Title @@ -87,69 +86,68 @@ namespace Server.Guilds if (!IsMember(pm, guild)) return; - pm.DisplayGuildTitle = info.IsSwitched(0); switch (info.ButtonID) { - //1-3 handled by base.OnResponse + // 1-3 handled by base.OnResponse case 4: - { - if (IsLeader(pm, guild)) { - pm.SendLocalizedMessage(1013071); // Enter the new guild charter (50 characters max): + if (IsLeader(pm, guild)) + { + pm.SendLocalizedMessage(1013071); // Enter the new guild charter (50 characters max): - pm.BeginPrompt(SetCharter_Callback, - true); //Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of "" + pm.BeginPrompt(SetCharter_Callback, + true); // Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of "" + } + + break; } - - break; - } case 5: - { - if (IsLeader(pm, guild)) { - pm.SendLocalizedMessage(1013072); // Enter the new website for the guild (50 characters max): - pm.BeginPrompt(SetWebsite_Callback, - true); //Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of "" - } + if (IsLeader(pm, guild)) + { + pm.SendLocalizedMessage(1013072); // Enter the new website for the guild (50 characters max): + pm.BeginPrompt(SetWebsite_Callback, + true); // Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of "" + } - break; - } + break; + } case 6: - { - //Alliance Roster - if (guild.Alliance?.IsMember(guild) == true) - pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, guild.Alliance)); + { + // Alliance Roster + if (guild.Alliance?.IsMember(guild) == true) + pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, guild.Alliance)); - break; - } + break; + } case 7: - { - //Resign - if (!m_IsResigning) { - pm.SendLocalizedMessage(1063332); // Are you sure you wish to resign from your guild? - pm.SendGump(new GuildInfoGump(pm, guild, true)); - } - else - { - guild.RemoveMember(pm, 1063411); // You resign from your guild. - } + // Resign + if (!m_IsResigning) + { + pm.SendLocalizedMessage(1063332); // Are you sure you wish to resign from your guild? + pm.SendGump(new GuildInfoGump(pm, guild, true)); + } + else + { + guild.RemoveMember(pm, 1063411); // You resign from your guild. + } - break; - } + break; + } case 100: // Custom code to support Order/Chaos in the new guild system - { - // Guild Faction - if (Guild.OrderChaos && IsLeader(pm, guild)) { - pm.CloseGump(); - pm.SendGump(new GuildChangeTypeGump(pm, guild)); - } + // Guild Faction + if (Guild.OrderChaos && IsLeader(pm, guild)) + { + pm.CloseGump(); + pm.SendGump(new GuildChangeTypeGump(pm, guild)); + } - break; - } + break; + } } } diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs index 07fd68e4b..76aecc4e4 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildInvitationRequest.cs @@ -6,7 +6,7 @@ namespace Server.Guilds { public class GuildInvitationRequest : BaseGuildGump { - private PlayerMobile m_Inviter; + private readonly PlayerMobile m_Inviter; public GuildInvitationRequest(PlayerMobile pm, Guild g, PlayerMobile inviter) : base(pm, g) { @@ -28,7 +28,6 @@ namespace Server.Guilds AddHtmlLocalized(45, 130, 150, 30, 1062943, 0x0); // Ignore Guild Invites } - public override void OnResponse(NetState sender, RelayInfo info) { if (guild.Disbanded || player.Guild != null) @@ -37,27 +36,27 @@ namespace Server.Guilds switch (info.ButtonID) { case 0: - { - m_Inviter.SendLocalizedMessage(1063250, - $"{player.Name}\t{guild.Name}"); // ~1_val~ has declined your invitation to join ~2_val~. - break; - } + { + m_Inviter.SendLocalizedMessage(1063250, + $"{player.Name}\t{guild.Name}"); // ~1_val~ has declined your invitation to join ~2_val~. + break; + } case 1: - { - guild.AddMember(player); - player.SendLocalizedMessage(1063056, guild.Name); // You have joined ~1_val~. - m_Inviter.SendLocalizedMessage(1063249, - $"{player.Name}\t{guild.Name}"); // ~1_val~ has accepted your invitation to join ~2_val~. + { + guild.AddMember(player); + player.SendLocalizedMessage(1063056, guild.Name); // You have joined ~1_val~. + m_Inviter.SendLocalizedMessage(1063249, + $"{player.Name}\t{guild.Name}"); // ~1_val~ has accepted your invitation to join ~2_val~. - break; - } + break; + } case 2: - { - player.AcceptGuildInvites = false; - player.SendLocalizedMessage(1070698); // You are now ignoring guild invitations. + { + player.AcceptGuildInvites = false; + player.SendLocalizedMessage(1070698); // You are now ignoring guild invitations. - break; - } + break; + } } } } diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs index 5e547223d..84b7ce1e0 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildMemberInfoGump.cs @@ -6,11 +6,11 @@ namespace Server.Guilds { public class GuildMemberInfoGump : BaseGuildGump { - private PlayerMobile m_Member; - private bool m_ToLeader, m_toKick; + private readonly PlayerMobile m_Member; + private readonly bool m_ToLeader; + private readonly bool m_toKick; - public GuildMemberInfoGump(PlayerMobile pm, Guild g, PlayerMobile member, bool toKick, bool toPromoteToLeader) : - base(pm, g, 10, 40) + public GuildMemberInfoGump(PlayerMobile pm, Guild g, PlayerMobile member, bool toKick, bool toPromoteToLeader) : base(pm, g, 10, 40) { m_ToLeader = toPromoteToLeader; m_toKick = toKick; @@ -68,146 +68,145 @@ namespace Server.Guilds switch (info.ButtonID) { - case 1: //Promote - { - if (playerRank.GetFlag(RankFlags.CanPromoteDemote) && - (playerRank.Rank - 1 > targetRank.Rank || - playerRank == RankDefinition.Leader && playerRank.Rank > targetRank.Rank)) + case 1: // Promote { - targetRank = RankDefinition.Ranks[targetRank.Rank + 1]; - - if (targetRank == RankDefinition.Leader) + if (playerRank.GetFlag(RankFlags.CanPromoteDemote) && + (playerRank.Rank - 1 > targetRank.Rank || + (playerRank == RankDefinition.Leader && playerRank.Rank > targetRank.Rank))) { - if (m_ToLeader) + targetRank = RankDefinition.Ranks[targetRank.Rank + 1]; + + if (targetRank == RankDefinition.Leader) + { + if (m_ToLeader) + { + m_Member.GuildRank = targetRank; + pm.SendLocalizedMessage(1063156, + m_Member.Name); // The guild information for ~1_val~ has been updated. + pm.SendLocalizedMessage(1063156, + pm.Name); // The guild information for ~1_val~ has been updated. + guild.Leader = m_Member; + } + else + { + pm.SendLocalizedMessage( + 1063144); // Are you sure you wish to make this member the new guild leader? + pm.SendGump(new GuildMemberInfoGump(player, guild, m_Member, false, true)); + } + } + else { m_Member.GuildRank = targetRank; pm.SendLocalizedMessage(1063156, m_Member.Name); // The guild information for ~1_val~ has been updated. - pm.SendLocalizedMessage(1063156, - pm.Name); // The guild information for ~1_val~ has been updated. - guild.Leader = m_Member; + } + } + else + { + pm.SendLocalizedMessage(1063143); // You don't have permission to promote this member. + } + + break; + } + case 2: // Demote + { + if (playerRank.GetFlag(RankFlags.CanPromoteDemote) && playerRank.Rank > targetRank.Rank) + { + if (targetRank == RankDefinition.Lowest) + { + if (RankDefinition.Lowest.Name.Number == 1062963) + pm.SendLocalizedMessage(1063333); // You can't demote a ronin. + else + pm.SendMessage("You can't demote a {0}.", RankDefinition.Lowest.Name); } else { - pm.SendLocalizedMessage( - 1063144); // Are you sure you wish to make this member the new guild leader? - pm.SendGump(new GuildMemberInfoGump(player, guild, m_Member, false, true)); + m_Member.GuildRank = RankDefinition.Ranks[targetRank.Rank - 1]; + pm.SendLocalizedMessage(1063156, + m_Member.Name); // The guild information for ~1_val~ has been updated. } } else { - m_Member.GuildRank = targetRank; - pm.SendLocalizedMessage(1063156, - m_Member.Name); // The guild information for ~1_val~ has been updated. + pm.SendLocalizedMessage(1063146); // You don't have permission to demote this member. } - } - else - { - pm.SendLocalizedMessage(1063143); // You don't have permission to promote this member. - } - break; - } - case 2: //Demote - { - if (playerRank.GetFlag(RankFlags.CanPromoteDemote) && playerRank.Rank > targetRank.Rank) + break; + } + case 3: // Set Guild title { - if (targetRank == RankDefinition.Lowest) + if (playerRank.GetFlag(RankFlags.CanSetGuildTitle) && + (playerRank.Rank > targetRank.Rank || m_Member == player)) { - if (RankDefinition.Lowest.Name.Number == 1062963) - pm.SendLocalizedMessage(1063333); // You can't demote a ronin. + pm.SendLocalizedMessage( + 1011128); // Enter the new title for this guild member or 'none' to remove a title: + + pm.BeginPrompt(SetTitle_Callback); + } + else if (m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0) + { + pm.SendLocalizedMessage(1070746); // You don't have the permission to set that member's guild title. + } + else + { + pm.SendLocalizedMessage(1063148); // You don't have permission to change this member's guild title. + } + + break; + } + case 4: // Vote + { + if (m_Member == pm.GuildFealty && guild.Leader != m_Member) + { + pm.SendLocalizedMessage(1063158); // You have cleared your vote for guild leader. + } + else if (guild.CanVote(m_Member)) + { + if (m_Member == guild.Leader) + { + pm.SendLocalizedMessage(1063424); // You can't vote for the current guild leader. + } + else if (!guild.CanBeVotedFor(m_Member)) + { + pm.SendLocalizedMessage(1063425); // You can't vote for an inactive guild member. + } else - pm.SendMessage("You can't demote a {0}.", RankDefinition.Lowest.Name); + { + pm.GuildFealty = m_Member; + pm.SendLocalizedMessage(1063159, + m_Member.Name); // You cast your vote for ~1_val~ for guild leader. + } } else { - m_Member.GuildRank = RankDefinition.Ranks[targetRank.Rank - 1]; - pm.SendLocalizedMessage(1063156, - m_Member.Name); // The guild information for ~1_val~ has been updated. + pm.SendLocalizedMessage(1063149); // You don't have permission to vote. } - } - else - { - pm.SendLocalizedMessage(1063146); // You don't have permission to demote this member. - } - - break; - } - case 3: //Set Guild title - { - if (playerRank.GetFlag(RankFlags.CanSetGuildTitle) && - (playerRank.Rank > targetRank.Rank || m_Member == player)) - { - pm.SendLocalizedMessage( - 1011128); // Enter the new title for this guild member or 'none' to remove a title: - - pm.BeginPrompt(SetTitle_Callback); + break; } - else if (m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0) + case 5: // Kick { - pm.SendLocalizedMessage(1070746); // You don't have the permission to set that member's guild title. - } - else - { - pm.SendLocalizedMessage(1063148); // You don't have permission to change this member's guild title. - } - - break; - } - case 4: //Vote - { - if (m_Member == pm.GuildFealty && guild.Leader != m_Member) - { - pm.SendLocalizedMessage(1063158); // You have cleared your vote for guild leader. - } - else if (guild.CanVote(m_Member)) //( playerRank.GetFlag( RankFlags.CanVote ) ) - { - if (m_Member == guild.Leader) + if ((playerRank.GetFlag(RankFlags.RemovePlayers) && playerRank.Rank > targetRank.Rank) || + (playerRank.GetFlag(RankFlags.RemoveLowestRank) && targetRank == RankDefinition.Lowest)) { - pm.SendLocalizedMessage(1063424); // You can't vote for the current guild leader. - } - else if (!guild.CanBeVotedFor(m_Member)) - { - pm.SendLocalizedMessage(1063425); // You can't vote for an inactive guild member. + if (m_toKick) + { + guild.RemoveMember(m_Member); + pm.SendLocalizedMessage(1063157); // The member has been removed from your guild. + } + else + { + pm.SendLocalizedMessage(1063152); // Are you sure you wish to kick this member from the guild? + pm.SendGump(new GuildMemberInfoGump(player, guild, m_Member, true, false)); + } } else { - pm.GuildFealty = m_Member; - pm.SendLocalizedMessage(1063159, - m_Member.Name); // You cast your vote for ~1_val~ for guild leader. + pm.SendLocalizedMessage(1063151); // You don't have permission to remove this member. } - } - else - { - pm.SendLocalizedMessage(1063149); // You don't have permission to vote. - } - break; - } - case 5: //Kick - { - if (playerRank.GetFlag(RankFlags.RemovePlayers) && playerRank.Rank > targetRank.Rank || - playerRank.GetFlag(RankFlags.RemoveLowestRank) && targetRank == RankDefinition.Lowest) - { - if (m_toKick) - { - guild.RemoveMember(m_Member); - pm.SendLocalizedMessage(1063157); // The member has been removed from your guild. - } - else - { - pm.SendLocalizedMessage(1063152); // Are you sure you wish to kick this member from the guild? - pm.SendGump(new GuildMemberInfoGump(player, guild, m_Member, true, false)); - } + break; } - else - { - pm.SendLocalizedMessage(1063151); // You don't have permission to remove this member. - } - - break; - } } } @@ -228,7 +227,6 @@ namespace Server.Guilds return; } - string title = Utility.FixHtml(text.Trim()); if (title.Length > 20) diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs index 17389398f..c4132ab9d 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/GuildRosterGump.cs @@ -9,12 +9,12 @@ namespace Server.Guilds { public class GuildRosterGump : BaseGuildListGump { - private static InfoField[] m_Fields = + private static readonly InfoField[] m_Fields = { - new InfoField(1062955, 130, NameComparer.Instance), //Name - new InfoField(1062956, 80, RankComparer.Instance), //Rank - new InfoField(1062952, 80, LastOnComparer.Instance), //Last On - new InfoField(1062953, 150, TitleComparer.Instance) //Guild Title + new InfoField(1062955, 130, NameComparer.Instance), // Name + new InfoField(1062956, 80, RankComparer.Instance), // Rank + new InfoField(1062952, 80, LastOnComparer.Instance), // Last On + new InfoField(1062953, 150, TitleComparer.Instance) // Guild Title }; public GuildRosterGump(PlayerMobile pm, Guild g) : this(pm, g, LastOnComparer.Instance) @@ -130,14 +130,10 @@ namespace Server.Guilds { pm.SendLocalizedMessage(1063051, targ.Name); // ~1_val~ is already a member of a guild. } - else if (targ.HasGump() || targ.HasGump() - ) //TODO: Check message if CreateGuildGump Open + else if (targ.HasGump() || targ.HasGump()) // TODO: Check message if CreateGuildGump Open { pm.SendLocalizedMessage(1063052, targ.Name); // ~1_val~ is currently considering another guild invitation. } - - #region Factions - else if (targ.Young && guildFaction != null) { pm.SendLocalizedMessage(1070766); // You cannot invite a young player to your faction-aligned guild. @@ -156,9 +152,6 @@ namespace Server.Guilds // OSI does this quite strangely, so we'll just do it this way pm.SendMessage("That person is quitting their faction and so you may not recruit them."); } - - #endregion - else { pm.SendLocalizedMessage(1063053, targ.Name); // You invite ~1_val~ to join your guild. @@ -166,8 +159,6 @@ namespace Server.Guilds } } - #region Comparers - private class NameComparer : IComparer { public static readonly IComparer Instance = new NameComparer(); @@ -244,7 +235,5 @@ namespace Server.Guilds return x.GuildRank.Rank.CompareTo(y.GuildRank.Rank); } } - - #endregion } } diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs index e2d1f648f..964da47e2 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/OtherGuildInfo.cs @@ -8,7 +8,7 @@ namespace Server.Guilds { public class OtherGuildInfo : BaseGuildGump { - private Guild m_Other; + private readonly Guild m_Other; public OtherGuildInfo(PlayerMobile pm, Guild g, Guild otherGuild) : base(pm, g, 10, 40) { @@ -36,7 +36,7 @@ namespace Server.Guilds AllianceInfo alliance = guild.Alliance; AllianceInfo otherAlliance = m_Other.Alliance; - //NOTE TO SELF: Only only alliance leader can see pending guild alliance statuses + // NOTE TO SELF: Only only alliance leader can see pending guild alliance statuses bool PendingWar = war != null; bool ActiveWar = activeWar != null; @@ -50,14 +50,12 @@ namespace Server.Guilds AddHtmlLocalized(20, 80, 120, 26, 1063025, 0x0, true); // Alliance - if (otherAlliance != null) - if (otherAlliance.IsMember(m_Other)) - AddHtml(150, 83, 360, 26, otherAlliance.Name); + if (otherAlliance?.IsMember(m_Other) == true) + AddHtml(150, 83, 360, 26, otherAlliance.Name); AddHtmlLocalized(20, 110, 120, 26, 1063139, 0x0, true); // Abbreviation AddHtml(150, 113, 120, 26, m_Other.Abbreviation); - string kills = "0/0"; string time = "00:00"; string otherKills = "0/0"; @@ -73,7 +71,6 @@ namespace Server.Guilds if (activeWar.WarLength != TimeSpan.Zero && activeWar.WarBeginning + activeWar.WarLength > DateTime.UtcNow) timeRemaining = activeWar.WarBeginning + activeWar.WarLength - DateTime.UtcNow; - //time = String.Format( "{0:D2}:{1:D2}", timeRemaining.Hours.ToString(), timeRemaining.Subtract( TimeSpan.FromHours( timeRemaining.Hours ) ).Minutes ); //Is there a formatter for htis? it's 2AM and I'm tired and can't find it time = $"{timeRemaining.Hours:D2}:{DateTime.MinValue + timeRemaining:mm}"; otherWar = m_Other.FindActiveWar(guild); @@ -83,7 +80,7 @@ namespace Server.Guilds else if (PendingWar) { kills = Color($"{war.Kills}/{war.MaxKills}", 0x990000); - //time = Color( String.Format( "{0}:{1}", war.WarLength.Hours, ((TimeSpan)(war.WarLength - TimeSpan.FromHours( war.WarLength.Hours ))).Minutes ), 0xFF0000 ); + // time = Color( String.Format( "{0}:{1}", war.WarLength.Hours, ((TimeSpan)(war.WarLength - TimeSpan.FromHours( war.WarLength.Hours ))).Minutes ), 0xFF0000 ); time = Color($"{war.WarLength.Hours:D2}:{DateTime.MinValue + war.WarLength:mm}", 0x990000); otherWar = m_Other.FindPendingWar(guild); @@ -104,7 +101,6 @@ namespace Server.Guilds int number = 1062973; //
You are at peace with this guild.
- if (PendingWar) { if (war.WarRequester) @@ -116,7 +112,7 @@ namespace Server.Guilds number = 1062969; //
This guild has challenged you to war!
AddButtonAndBackground(20, 260, 5, 1062981); // Accept Challenge - AddButtonAndBackground(275, 260, 6, 1062983); //Modify Terms + AddButtonAndBackground(275, 260, 6, 1062983); // Modify Terms } AddButtonAndBackground(20, 290, 7, 1062982); // Dismiss Challenge @@ -126,9 +122,9 @@ namespace Server.Guilds number = 1062965; //
You are at war with this guild!
AddButtonAndBackground(20, 290, 8, 1062980); // Surrender } - else if (alliance != null && alliance == otherAlliance) //alliance, Same Alliance + else if (alliance != null && alliance == otherAlliance) // alliance, Same Alliance { - if (alliance.IsMember(guild) && alliance.IsMember(m_Other)) //Both in Same alliance, full members + if (alliance.IsMember(guild) && alliance.IsMember(m_Other)) // Both in Same alliance, full members { number = 1062970; //
You are allied with this guild.
@@ -137,21 +133,21 @@ namespace Server.Guilds AddButtonAndBackground(20, 260, 12, 1062984); // Remove Guild from Alliance AddButtonAndBackground(275, 260, 13, 1063433); // Promote to Alliance Leader //Note: No 'confirmation' like the other leader guild promotion things - //Remove guild from alliance //Promote to Alliance Leader + // Remove guild from alliance //Promote to Alliance Leader } - //Show roster, Centered, up - AddButtonAndBackground(148, 215, 10, 1063164); //Show Alliance Roster - //Leave Alliance + // Show roster, Centered, up + AddButtonAndBackground(148, 215, 10, 1063164); // Show Alliance Roster + // Leave Alliance AddButtonAndBackground(20, 290, 11, 1062985); // Leave Alliance } else if (alliance.Leader == guild && alliance.IsPendingMember(m_Other)) { number = 1062971; //
You have requested an alliance with this guild.
- //Show Alliance Roster, Centered, down. - AddButtonAndBackground(148, 245, 10, 1063164); //Show Alliance Roster - //Withdraw Request + // Show Alliance Roster, Centered, down. + AddButtonAndBackground(148, 245, 10, 1063164); // Show Alliance Roster + // Withdraw Request AddButtonAndBackground(20, 290, 14, 1062986); // Withdraw Request AddHtml(150, 83, 360, 26, Color(alliance.Name, 0x99)); @@ -160,10 +156,10 @@ namespace Server.Guilds { number = 1062972; //
This guild has requested an alliance.
- //Show alliance Roster, top - AddButtonAndBackground(148, 215, 10, 1063164); //Show Alliance Roster - //Deny Request - //Accept Request + // Show alliance Roster, top + AddButtonAndBackground(148, 215, 10, 1063164); // Show Alliance Roster + // Deny Request + // Accept Request AddButtonAndBackground(20, 260, 15, 1062988); // Deny Request AddButtonAndBackground(20, 290, 16, 1062987); // Accept Request @@ -176,13 +172,12 @@ namespace Server.Guilds AddButtonAndBackground(20, 290, 1, 1062989); // Declare War! } - AddButtonAndBackground(275, 290, 0, 3000091); //Cancel + AddButtonAndBackground(275, 290, 0, 3000091); // Cancel AddHtmlLocalized(20, 180, 480, 30, number, 0x0, true); AddImageTiled(20, 245, 480, 2, 0x2711); } - public override void OnResponse(NetState sender, RelayInfo info) { if (!(sender.Mobile is PlayerMobile pm && IsMember(pm, guild))) @@ -202,11 +197,122 @@ namespace Server.Guilds switch (info.ButtonID) { - #region War + case 5: // Accept the war + { + if (war?.WarRequester == false && activeWar == null) + { + if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) + { + pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. + } + else if (alliance != null && alliance.Leader != guild) + { + pm.SendLocalizedMessage(1063239, + $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. + pm.SendLocalizedMessage(1070707, + alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + } + else + { + // Accept the war + guild.PendingWars.Remove(war); + war.WarBeginning = DateTime.UtcNow; + guild.AcceptedWars.Add(war); - case 5: //Accept the war - { - if (war?.WarRequester == false && activeWar == null) + if (alliance?.IsMember(guild) == true) + { + alliance.AllianceMessage(1070769, + otherAlliance != null + ? otherAlliance.Name + : otherGuild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ + alliance.InvalidateMemberProperties(); + } + else + { + guild.GuildMessage(1070769, + otherAlliance != null + ? otherAlliance.Name + : otherGuild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ + guild.InvalidateMemberProperties(); + } + // Technically SHOULD say Your guild is now at war w/out any info, intentional diff. + + otherGuild.PendingWars.Remove(otherWar); + otherWar.WarBeginning = DateTime.UtcNow; + otherGuild.AcceptedWars.Add(otherWar); + + if (otherAlliance != null && m_Other.Alliance.IsMember(m_Other)) + { + otherAlliance.AllianceMessage(1070769, + alliance != null + ? alliance.Name + : guild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ + otherAlliance.InvalidateMemberProperties(); + } + else + { + otherGuild.GuildMessage(1070769, + alliance != null + ? alliance.Name + : guild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ + otherGuild.InvalidateMemberProperties(); + } + } + } + + break; + } + case 6: // Modify war terms + { + if (war?.WarRequester == false && activeWar == null) + { + if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) + { + pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. + } + else if (alliance != null && alliance.Leader != guild) + { + pm.SendLocalizedMessage(1063239, + $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. + pm.SendLocalizedMessage(1070707, + alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + } + else + { + pm.SendGump(new WarDeclarationGump(pm, guild, otherGuild)); + } + } + + break; + } + case 7: // Dismiss war + { + if (war != null) + { + if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) + { + pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. + } + else if (alliance != null && alliance.Leader != guild) + { + pm.SendLocalizedMessage(1063239, + $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. + pm.SendLocalizedMessage(1070707, + alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + } + else + { + // Dismiss the war + guild.PendingWars.Remove(war); + otherGuild.PendingWars.Remove(otherWar); + pm.SendLocalizedMessage(1070752); // The proposal has been updated. + // Messages to opposing guild? (Testing on OSI says no) + } + } + + break; + } + case 8: // Surrender { if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { @@ -216,421 +322,299 @@ namespace Server.Guilds { pm.SendLocalizedMessage(1063239, $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, - alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. } else { - //Accept the war - guild.PendingWars.Remove(war); - war.WarBeginning = DateTime.UtcNow; - guild.AcceptedWars.Add(war); + if (activeWar != null) + { + if (alliance?.IsMember(guild) == true) + { + alliance.AllianceMessage(1070740, + otherAlliance != null + ? otherAlliance.Name + : otherGuild.Name); // You have lost the war with ~1_val~. + alliance.InvalidateMemberProperties(); + } + else + { + guild.GuildMessage(1070740, + otherAlliance != null + ? otherAlliance.Name + : otherGuild.Name); // You have lost the war with ~1_val~. + guild.InvalidateMemberProperties(); + } - if (alliance?.IsMember(guild) == true) - { - alliance.AllianceMessage(1070769, - otherAlliance != null - ? otherAlliance.Name - : otherGuild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ - alliance.InvalidateMemberProperties(); - } - else - { - guild.GuildMessage(1070769, - otherAlliance != null - ? otherAlliance.Name - : otherGuild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ - guild.InvalidateMemberProperties(); - } - //Technically SHOULD say Your guild is now at war w/out any info, intentional diff. + guild.AcceptedWars.Remove(activeWar); - otherGuild.PendingWars.Remove(otherWar); - otherWar.WarBeginning = DateTime.UtcNow; - otherGuild.AcceptedWars.Add(otherWar); + if (otherAlliance?.IsMember(otherGuild) == true) + { + otherAlliance.AllianceMessage(1070739, + guild.Alliance != null + ? guild.Alliance.Name + : guild.Name); // You have won the war against ~1_val~! + otherAlliance.InvalidateMemberProperties(); + } + else + { + otherGuild.GuildMessage(1070739, + guild.Alliance != null + ? guild.Alliance.Name + : guild.Name); // You have won the war against ~1_val~! + otherGuild.InvalidateMemberProperties(); + } - if (otherAlliance != null && m_Other.Alliance.IsMember(m_Other)) - { - otherAlliance.AllianceMessage(1070769, - alliance != null - ? alliance.Name - : guild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ - otherAlliance.InvalidateMemberProperties(); - } - else - { - otherGuild.GuildMessage(1070769, - alliance != null - ? alliance.Name - : guild.Name); // Guild Message: Your guild is now at war with ~1_GUILDNAME~ - otherGuild.InvalidateMemberProperties(); + otherGuild.AcceptedWars.Remove(otherGuild.FindActiveWar(guild)); } } + + break; + } + case 1: // Declare War + { + if (war == null && activeWar == null) + { + if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) + { + pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. + } + else if (alliance != null && alliance.Leader != guild) + { + pm.SendLocalizedMessage(1063239, + $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. + pm.SendLocalizedMessage(1070707, + alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + } + else if (otherAlliance != null && otherAlliance.Leader != m_Other) + { + pm.SendLocalizedMessage(1063239, + $"{m_Other.Name}\t{otherAlliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. + pm.SendLocalizedMessage(1070707, + otherAlliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + } + else + { + pm.SendGump(new WarDeclarationGump(pm, guild, m_Other)); + } + } + + break; } - break; - } - case 6: //Modify war terms - { - if (war?.WarRequester == false && activeWar == null) + case 2: // Request Alliance { - if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) + if (alliance == null) { - pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. - } - else if (alliance != null && alliance.Leader != guild) - { - pm.SendLocalizedMessage(1063239, - $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, - alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + if (!playerRank.GetFlag(RankFlags.AllianceControl)) + { + pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance. + } + else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader)) + { + pm.SendLocalizedMessage( + 1070758); // You cannot propose an alliance to a guild with a different faction allegiance. + } + else if (otherAlliance != null) + { + if (otherAlliance.IsPendingMember(m_Other)) + pm.SendLocalizedMessage(1063416, + m_Other.Name); // ~1_val~ is currently considering another alliance proposal. + else + pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance. + } + else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) + { + pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war. + } + else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0) + { + pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war. + } + else + { + pm.SendLocalizedMessage(1063439); // Enter a name for the new alliance: + pm.BeginPrompt(CreateAlliance_Callback); + } } else { - pm.SendGump(new WarDeclarationGump(pm, guild, otherGuild)); - } - } - - break; - } - case 7: //Dismiss war - { - if (war != null) - { - if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) - { - pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. - } - else if (alliance != null && alliance.Leader != guild) - { - pm.SendLocalizedMessage(1063239, - $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, - alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. - } - else - { - //Dismiss the war - guild.PendingWars.Remove(war); - otherGuild.PendingWars.Remove(otherWar); - pm.SendLocalizedMessage(1070752); // The proposal has been updated. - //Messages to opposing guild? (Testing on OSI says no) - } - } - - break; - } - case 8: //Surrender - { - if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) - { - pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. - } - else if (alliance != null && alliance.Leader != guild) - { - pm.SendLocalizedMessage(1063239, - $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. - } - else - { - if (activeWar != null) - { - if (alliance?.IsMember(guild) == true) + if (!playerRank.GetFlag(RankFlags.AllianceControl)) { - alliance.AllianceMessage(1070740, - otherAlliance != null - ? otherAlliance.Name - : otherGuild.Name); // You have lost the war with ~1_val~. - alliance.InvalidateMemberProperties(); + pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } - else + else if (alliance.Leader != guild) { - guild.GuildMessage(1070740, - otherAlliance != null - ? otherAlliance.Name - : otherGuild.Name); // You have lost the war with ~1_val~. - guild.InvalidateMemberProperties(); + pm.SendLocalizedMessage(1063239, + $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. } - - guild.AcceptedWars.Remove(activeWar); - - if (otherAlliance?.IsMember(otherGuild) == true) + else if (otherAlliance != null) { - otherAlliance.AllianceMessage(1070739, - guild.Alliance != null - ? guild.Alliance.Name - : guild.Name); // You have won the war against ~1_val~! - otherAlliance.InvalidateMemberProperties(); + if (otherAlliance.IsPendingMember(m_Other)) + pm.SendLocalizedMessage(1063416, + m_Other.Name); // ~1_val~ is currently considering another alliance proposal. + else + pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance. } - else + else if (alliance.IsPendingMember(guild)) { - otherGuild.GuildMessage(1070739, - guild.Alliance != null - ? guild.Alliance.Name - : guild.Name); // You have won the war against ~1_val~! - otherGuild.InvalidateMemberProperties(); - } - - otherGuild.AcceptedWars.Remove(otherGuild.FindActiveWar(guild)); - } - } - - break; - } - case 1: //Declare War - { - if (war == null && activeWar == null) - { - if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) - { - pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. - } - else if (alliance != null && alliance.Leader != guild) - { - pm.SendLocalizedMessage(1063239, - $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, - alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. - } - else if (otherAlliance != null && otherAlliance.Leader != m_Other) - { - pm.SendLocalizedMessage(1063239, - $"{m_Other.Name}\t{otherAlliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, - otherAlliance.Leader.Name); // You need to negotiate via ~1_val~ instead. - } - else - { - pm.SendGump(new WarDeclarationGump(pm, guild, m_Other)); - } - } - - break; - } - - #endregion - - case 2: //Request Alliance - { - #region New alliance - - if (alliance == null) - { - if (!playerRank.GetFlag(RankFlags.AllianceControl)) - { - pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance. - } - else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader)) - { - pm.SendLocalizedMessage( - 1070758); // You cannot propose an alliance to a guild with a different faction allegiance. - } - else if (otherAlliance != null) - { - if (otherAlliance.IsPendingMember(m_Other)) pm.SendLocalizedMessage(1063416, - m_Other.Name); // ~1_val~ is currently considering another alliance proposal. + guild.Name); // ~1_val~ is currently considering another alliance proposal. + } + else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) + { + pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war. + } + else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0) + { + pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war. + } + else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader)) + { + pm.SendLocalizedMessage( + 1070758); // You cannot propose an alliance to a guild with a different faction allegiance. + } else - pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance. - } - else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) - { - pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war. - } - else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0) - { - pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war. - } - else - { - pm.SendLocalizedMessage(1063439); // Enter a name for the new alliance: - pm.BeginPrompt(CreateAlliance_Callback); + { + pm.SendLocalizedMessage(1070750, + m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~. + + m_Other.GuildMessage(1070780, guild.Name); // ~1_val~ has proposed an alliance. + + m_Other.Alliance = alliance; // Calls addPendingGuild + // alliance.AddPendingGuild( m_Other ); + } } + + break; } + case 10: // Show Alliance Roster + { + if (alliance != null && alliance == otherAlliance) + pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, alliance)); - #endregion - - #region Existing Alliance - - else + break; + } + case 11: // Leave Alliance { if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } - else if (alliance.Leader != guild) + else if (alliance?.IsMember(guild) == true) + { + guild.Alliance = null; // Calls alliance.Removeguild + // alliance.RemoveGuild( guild ); + + m_Other.InvalidateWarNotoriety(); + + guild.InvalidateMemberNotoriety(); + } + + break; + } + case 12: // Remove Guild from alliance + { + if (!playerRank.GetFlag(RankFlags.AllianceControl)) + { + pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. + } + else if (alliance != null && alliance.Leader != guild) { pm.SendLocalizedMessage(1063239, $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. } - else if (otherAlliance != null) + else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other)) { - if (otherAlliance.IsPendingMember(m_Other)) - pm.SendLocalizedMessage(1063416, - m_Other.Name); // ~1_val~ is currently considering another alliance proposal. - else - pm.SendLocalizedMessage(1063426, m_Other.Name); // ~1_val~ already belongs to an alliance. + m_Other.Alliance = null; + + m_Other.InvalidateMemberNotoriety(); + + guild.InvalidateWarNotoriety(); } - else if (alliance.IsPendingMember(guild)) + + break; + } + case 13: // Promote to Alliance leader + { + if (!playerRank.GetFlag(RankFlags.AllianceControl)) { - pm.SendLocalizedMessage(1063416, - guild.Name); // ~1_val~ is currently considering another alliance proposal. + pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } - else if (m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0) + else if (alliance != null && alliance.Leader != guild) { - pm.SendLocalizedMessage(1063427, m_Other.Name); // ~1_val~ is currently involved in a guild war. + pm.SendLocalizedMessage(1063239, + $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. } - else if (guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0) + else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other)) { - pm.SendLocalizedMessage(1063427, guild.Name); // ~1_val~ is currently involved in a guild war. + pm.SendLocalizedMessage(1063434, + $"{m_Other.Name}\t{alliance.Name}"); // ~1_val~ is now the leader of ~2_val~. + + alliance.Leader = m_Other; } - else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader)) + + break; + } + case 14: // Withdraw Request + { + if (!playerRank.GetFlag(RankFlags.AllianceControl)) { - pm.SendLocalizedMessage( - 1070758); // You cannot propose an alliance to a guild with a different faction allegiance. + pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. } - else + else if (alliance != null && alliance.Leader == guild && alliance.IsPendingMember(m_Other)) { - pm.SendLocalizedMessage(1070750, - m_Other.Name); // An invitation to join your alliance has been sent to ~1_val~. - - m_Other.GuildMessage(1070780, guild.Name); // ~1_val~ has proposed an alliance. - - m_Other.Alliance = alliance; //Calls addPendingGuild - //alliance.AddPendingGuild( m_Other ); + m_Other.Alliance = null; + pm.SendLocalizedMessage(1070752); // The proposal has been updated. } + + break; } - - #endregion - - break; - } - case 10: //Show Alliance Roster - { - if (alliance != null && alliance == otherAlliance) - pm.SendGump(new AllianceInfo.AllianceRosterGump(pm, guild, alliance)); - - break; - } - case 11: //Leave Alliance - { - if (!playerRank.GetFlag(RankFlags.AllianceControl)) + case 15: // Deny Alliance Request { - pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. + if (!playerRank.GetFlag(RankFlags.AllianceControl)) + { + pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. + } + else if (alliance != null && otherAlliance != null && alliance.Leader == m_Other && + otherAlliance.IsPendingMember(guild)) + { + // The proposal has been updated. + // m_Other.GuildMessage( 1070782 ); + // // ~1_val~ has responded to your proposal. + // //Per OSI commented out. + pm.SendLocalizedMessage(1070752); + guild.Alliance = null; + } + + break; } - else if (alliance?.IsMember(guild) == true) + case 16: // Accept Alliance Request { - guild.Alliance = null; //Calls alliance.Removeguild - // alliance.RemoveGuild( guild ); + if (!playerRank.GetFlag(RankFlags.AllianceControl)) + { + pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. + } + else if (otherAlliance != null && otherAlliance.Leader == m_Other && + otherAlliance.IsPendingMember(guild)) + { + pm.SendLocalizedMessage(1070752); // The proposal has been updated. - m_Other.InvalidateWarNotoriety(); + otherAlliance + .TurnToMember( + m_Other); // No need to verify it's in the guild or already a member, the function does this - guild.InvalidateMemberNotoriety(); + otherAlliance.TurnToMember(guild); + } + + break; } - - break; - } - case 12: //Remove Guild from alliance - { - if (!playerRank.GetFlag(RankFlags.AllianceControl)) - { - pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. - } - else if (alliance != null && alliance.Leader != guild) - { - pm.SendLocalizedMessage(1063239, - $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - } - else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other)) - { - m_Other.Alliance = null; - - m_Other.InvalidateMemberNotoriety(); - - guild.InvalidateWarNotoriety(); - } - - break; - } - case 13: //Promote to Alliance leader - { - if (!playerRank.GetFlag(RankFlags.AllianceControl)) - { - pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. - } - else if (alliance != null && alliance.Leader != guild) - { - pm.SendLocalizedMessage(1063239, - $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - } - else if (alliance?.IsMember(guild) == true && alliance.IsMember(m_Other)) - { - pm.SendLocalizedMessage(1063434, - $"{m_Other.Name}\t{alliance.Name}"); // ~1_val~ is now the leader of ~2_val~. - - alliance.Leader = m_Other; - } - - break; - } - case 14: //Withdraw Request - { - if (!playerRank.GetFlag(RankFlags.AllianceControl)) - { - pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. - } - else if (alliance != null && alliance.Leader == guild && alliance.IsPendingMember(m_Other)) - { - m_Other.Alliance = null; - pm.SendLocalizedMessage(1070752); // The proposal has been updated. - } - - break; - } - case 15: //Deny Alliance Request - { - if (!playerRank.GetFlag(RankFlags.AllianceControl)) - { - pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. - } - else if (alliance != null && otherAlliance != null && alliance.Leader == m_Other && - otherAlliance.IsPendingMember(guild)) - { - pm.SendLocalizedMessage(1070752); // The proposal has been updated. - //m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal. //Per OSI commented out. - - guild.Alliance = null; - } - - break; - } - case 16: //Accept Alliance Request - { - if (!playerRank.GetFlag(RankFlags.AllianceControl)) - { - pm.SendLocalizedMessage(1063436); // You don't have permission to negotiate an alliance. - } - else if (otherAlliance != null && otherAlliance.Leader == m_Other && - otherAlliance.IsPendingMember(guild)) - { - pm.SendLocalizedMessage(1070752); // The proposal has been updated. - - otherAlliance - .TurnToMember( - m_Other); //No need to verify it's in the guild or already a member, the function does this - - otherAlliance.TurnToMember(guild); - } - - break; - } } } public void CreateAlliance_Callback(Mobile from, string text) { - PlayerMobile pm = from as PlayerMobile; - + if (!(from is PlayerMobile pm)) + return; AllianceInfo alliance = guild.Alliance; AllianceInfo otherAlliance = m_Other.Alliance; @@ -638,17 +622,15 @@ namespace Server.Guilds if (!IsMember(from, guild) || alliance != null) return; - RankDefinition playerRank = pm.GuildRank; - if (!playerRank.GetFlag(RankFlags.AllianceControl)) { pm.SendLocalizedMessage(1070747); // You don't have permission to create an alliance. } else if (Faction.Find(guild.Leader) != Faction.Find(m_Other.Leader)) { - //Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later. + // Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later. pm.SendLocalizedMessage( 1070758); // You cannot propose an alliance to a guild with a different faction allegiance. } diff --git a/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs b/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs index 3fe208642..f3798fa6b 100644 --- a/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs +++ b/Projects/Scripts/Gumps/Guilds/New Guild System/War Declaration gump.cs @@ -7,7 +7,7 @@ namespace Server.Guilds { public class WarDeclarationGump : BaseGuildGump { - private Guild m_Other; + private readonly Guild m_Other; public WarDeclarationGump(PlayerMobile pm, Guild g, Guild otherGuild) : base(pm, g) { @@ -48,91 +48,91 @@ namespace Server.Guilds switch (info.ButtonID) { case 1: - { - AllianceInfo alliance = guild.Alliance; - AllianceInfo otherAlliance = m_Other.Alliance; + { + AllianceInfo alliance = guild.Alliance; + AllianceInfo otherAlliance = m_Other.Alliance; - if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) - { - pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. - } - else if (alliance != null && alliance.Leader != guild) - { - pm.SendLocalizedMessage(1063239, - $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. - } - else if (otherAlliance != null && otherAlliance.Leader != m_Other) - { - pm.SendLocalizedMessage(1063239, - $"{m_Other.Name}\t{otherAlliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. - pm.SendLocalizedMessage(1070707, - otherAlliance.Leader.Name); // You need to negotiate via ~1_val~ instead. - } - else - { - WarDeclaration activeWar = guild.FindActiveWar(m_Other); - - if (activeWar == null) + if (!playerRank.GetFlag(RankFlags.ControlWarStatus)) { - WarDeclaration war = guild.FindPendingWar(m_Other); - WarDeclaration otherWar = m_Other.FindPendingWar(guild); - - //Note: OSI differs from what it says on website. unlimited war = 0 kills/ 0 hrs. Not > 999. (sidenote: they both cap at 65535, 7.5 years, but, still.) - TextRelay tKills = info.GetTextEntry(11); - TextRelay tWarLength = info.GetTextEntry(10); - - int maxKills = tKills == null - ? 0 - : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(11).Text), 0xFFFF), 0); - TimeSpan warLength = TimeSpan.FromHours(tWarLength == null - ? 0 - : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(10).Text), 0xFFFF), 0)); - - if (war != null) - { - war.MaxKills = maxKills; - war.WarLength = warLength; - war.WarRequester = true; - } - else - { - guild.PendingWars.Add(new WarDeclaration(guild, m_Other, maxKills, warLength, true)); - } - - if (otherWar != null) - { - otherWar.MaxKills = maxKills; - otherWar.WarLength = warLength; - otherWar.WarRequester = false; - } - else - { - m_Other.PendingWars.Add(new WarDeclaration(m_Other, guild, maxKills, warLength, false)); - } - - if (war != null) - pm.SendLocalizedMessage(1070752); // The proposal has been updated. - else - m_Other.GuildMessage(1070781, - guild.Alliance != null - ? guild.Alliance.Name - : guild.Name); // ~1_val~ has proposed a war. - - pm.SendLocalizedMessage(1070751, - m_Other.Alliance != null - ? m_Other.Alliance.Name - : m_Other.Name); // War proposal has been sent to ~1_val~. + pm.SendLocalizedMessage(1063440); // You don't have permission to negotiate wars. } - } + else if (alliance != null && alliance.Leader != guild) + { + pm.SendLocalizedMessage(1063239, + $"{guild.Name}\t{alliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. + pm.SendLocalizedMessage(1070707, alliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + } + else if (otherAlliance != null && otherAlliance.Leader != m_Other) + { + pm.SendLocalizedMessage(1063239, + $"{m_Other.Name}\t{otherAlliance.Name}"); // ~1_val~ is not the leader of the ~2_val~ alliance. + pm.SendLocalizedMessage(1070707, + otherAlliance.Leader.Name); // You need to negotiate via ~1_val~ instead. + } + else + { + WarDeclaration activeWar = guild.FindActiveWar(m_Other); - break; - } + if (activeWar == null) + { + WarDeclaration war = guild.FindPendingWar(m_Other); + WarDeclaration otherWar = m_Other.FindPendingWar(guild); + + // Note: OSI differs from what it says on website. unlimited war = 0 kills/ 0 hrs. Not > 999. (sidenote: they both cap at 65535, 7.5 years, but, still.) + TextRelay tKills = info.GetTextEntry(11); + TextRelay tWarLength = info.GetTextEntry(10); + + int maxKills = tKills == null + ? 0 + : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(11).Text), 0xFFFF), 0); + TimeSpan warLength = TimeSpan.FromHours(tWarLength == null + ? 0 + : Math.Max(Math.Min(Utility.ToInt32(info.GetTextEntry(10).Text), 0xFFFF), 0)); + + if (war != null) + { + war.MaxKills = maxKills; + war.WarLength = warLength; + war.WarRequester = true; + } + else + { + guild.PendingWars.Add(new WarDeclaration(guild, m_Other, maxKills, warLength, true)); + } + + if (otherWar != null) + { + otherWar.MaxKills = maxKills; + otherWar.WarLength = warLength; + otherWar.WarRequester = false; + } + else + { + m_Other.PendingWars.Add(new WarDeclaration(m_Other, guild, maxKills, warLength, false)); + } + + if (war != null) + pm.SendLocalizedMessage(1070752); // The proposal has been updated. + else + m_Other.GuildMessage(1070781, + guild.Alliance != null + ? guild.Alliance.Name + : guild.Name); // ~1_val~ has proposed a war. + + pm.SendLocalizedMessage(1070751, + m_Other.Alliance != null + ? m_Other.Alliance.Name + : m_Other.Name); // War proposal has been sent to ~1_val~. + } + } + + break; + } default: - { - pm.SendGump(new OtherGuildInfo(pm, guild, m_Other)); - break; - } + { + pm.SendGump(new OtherGuildInfo(pm, guild, m_Other)); + break; + } } } } diff --git a/Projects/Scripts/Gumps/Guilds/RecruitTarget.cs b/Projects/Scripts/Gumps/Guilds/RecruitTarget.cs index 3a03aa905..adb1117c1 100644 --- a/Projects/Scripts/Gumps/Guilds/RecruitTarget.cs +++ b/Projects/Scripts/Gumps/Guilds/RecruitTarget.cs @@ -6,8 +6,8 @@ namespace Server.Gumps { public class GuildRecruitTarget : Target { - private Guild m_Guild; - private Mobile m_Mobile; + private readonly Guild m_Guild; + private readonly Mobile m_Mobile; public GuildRecruitTarget(Mobile m, Guild guild) : base(10, false, TargetFlags.None) { @@ -53,9 +53,6 @@ namespace Server.Gumps { m_Mobile.SendLocalizedMessage(501166); // You can only recruit candidates who are not already in a guild. } - - #region Factions - else if (guildFaction != targetFaction) { if (guildFaction == null) @@ -71,9 +68,6 @@ namespace Server.Gumps // OSI does this quite strangely, so we'll just do it this way m_Mobile.SendMessage("That person is quitting their faction and so you may not recruit them."); } - - #endregion - else if (m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Guild.Leader == m_Mobile) { m_Guild.Accepted.Add(m); diff --git a/Projects/Scripts/Gumps/HeritageTokenGump.cs b/Projects/Scripts/Gumps/HeritageTokenGump.cs index aca14cc31..63eae3c00 100644 --- a/Projects/Scripts/Gumps/HeritageTokenGump.cs +++ b/Projects/Scripts/Gumps/HeritageTokenGump.cs @@ -7,7 +7,7 @@ namespace Server.Gumps { public class HeritageTokenGump : Gump { - private HeritageToken m_Token; + private readonly HeritageToken m_Token; public HeritageTokenGump(HeritageToken token) : base(60, 36) { diff --git a/Projects/Scripts/Gumps/HonorSelf.cs b/Projects/Scripts/Gumps/HonorSelf.cs index 3fae52cba..f76e65445 100644 --- a/Projects/Scripts/Gumps/HonorSelf.cs +++ b/Projects/Scripts/Gumps/HonorSelf.cs @@ -5,7 +5,7 @@ namespace Server.Gumps { public class HonorSelf : Gump { - private PlayerMobile m_from; + private readonly PlayerMobile m_from; public HonorSelf(PlayerMobile from) : base(150, 50) { diff --git a/Projects/Scripts/Gumps/HouseDemolishGump.cs b/Projects/Scripts/Gumps/HouseDemolishGump.cs index 1ec189cff..7ddd19997 100644 --- a/Projects/Scripts/Gumps/HouseDemolishGump.cs +++ b/Projects/Scripts/Gumps/HouseDemolishGump.cs @@ -8,8 +8,8 @@ namespace Server.Gumps { public class HouseDemolishGump : Gump { - private BaseHouse m_House; - private Mobile m_Mobile; + private readonly BaseHouse m_House; + private readonly Mobile m_Mobile; public HouseDemolishGump(Mobile mobile, BaseHouse house) : base(110, 100) { @@ -32,13 +32,14 @@ namespace Server.Gumps AddImageTiled(10, 40, 400, 200, 2624); AddAlphaRegion(10, 40, 400, 200); - AddHtmlLocalized(10, 40, 400, 200, 1061795, 32512, false, true); /* You are about to demolish your house. - * You will be refunded the house's value directly to your bank box. - * All items in the house will remain behind and can be freely picked up by anyone. - * Once the house is demolished, anyone can attempt to place a new house on the vacant land. - * This action will not un-condemn any other houses on your account, nor will it end your 7-day waiting period (if it applies to you). - * Are you sure you wish to continue? - */ + /* You are about to demolish your house. + * You will be refunded the house's value directly to your bank box. + * All items in the house will remain behind and can be freely picked up by anyone. + * Once the house is demolished, anyone can attempt to place a new house on the vacant land. + * This action will not un-condemn any other houses on your account, nor will it end your 7-day waiting period (if it applies to you). + * Are you sure you wish to continue? + */ + AddHtmlLocalized(10, 40, 400, 200, 1061795, 32512, false, true); AddImageTiled(10, 250, 400, 20, 2624); AddAlphaRegion(10, 250, 400, 20); @@ -64,7 +65,7 @@ namespace Server.Gumps return; } - /*else if ( m_House.PlayerVendors.Count > 0 ) + /*else if (m_House.PlayerVendors.Count > 0) { m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving. return; @@ -90,7 +91,6 @@ namespace Server.Gumps return; } - if (m_Mobile.AccessLevel >= AccessLevel.GameMaster) { m_Mobile.SendMessage("You do not get a refund for your house as you are not a player"); diff --git a/Projects/Scripts/Gumps/HouseGump.cs b/Projects/Scripts/Gumps/HouseGump.cs index c3a65e70a..c99047b4a 100644 --- a/Projects/Scripts/Gumps/HouseGump.cs +++ b/Projects/Scripts/Gumps/HouseGump.cs @@ -8,7 +8,7 @@ namespace Server.Gumps { public class HouseListGump : Gump { - private BaseHouse m_House; + private readonly BaseHouse m_House; public HouseListGump(int number, List list, BaseHouse house, bool accountOf) : base(20, 30) { @@ -67,10 +67,11 @@ namespace Server.Gumps public class HouseRemoveGump : Gump { - private bool m_AccountOf; - private BaseHouse m_House; - private List m_List, m_Copy; - private int m_Number; + private readonly bool m_AccountOf; + private readonly BaseHouse m_House; + private readonly List m_List; + private readonly List m_Copy; + private readonly int m_Number; public HouseRemoveGump(int number, List list, BaseHouse house, bool accountOf) : base(20, 30) { @@ -163,7 +164,7 @@ namespace Server.Gumps public class HouseGump : Gump { - private BaseHouse m_House; + private readonly BaseHouse m_House; public HouseGump(Mobile from, BaseHouse house) : base(20, 30) { @@ -311,7 +312,7 @@ namespace Server.Gumps } else { - //AddHtmlLocalized( 45, 280, 350, 30, 1011250, false, false ); // Change the sign type + // AddHtmlLocalized( 45, 280, 350, 30, 1011250, false, false ); // Change the sign type AddHtmlLocalized(45, 210, 350, 30, 1011250); // Change the sign type AddButton(20, 210, 2714, 2715, 0, GumpButtonType.Page, 4); @@ -450,266 +451,266 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Rename sign - { - from.Prompt = new RenamePrompt(m_House); - from.SendLocalizedMessage(501302); // What dost thou wish the sign to say? + { + from.Prompt = new RenamePrompt(m_House); + from.SendLocalizedMessage(501302); // What dost thou wish the sign to say? - break; - } + break; + } case 2: // List of co-owners - { - from.CloseGump(); - from.CloseGump(); - from.CloseGump(); - from.SendGump(new HouseListGump(1011275, m_House.CoOwners, m_House, false)); + { + from.CloseGump(); + from.CloseGump(); + from.CloseGump(); + from.SendGump(new HouseListGump(1011275, m_House.CoOwners, m_House, false)); - break; - } + break; + } case 3: // Add co-owner - { - if (isOwner) - { - from.SendLocalizedMessage( - 501328); // Target the person you wish to name a co-owner of your household. - from.Target = new CoOwnerTarget(true, m_House); - } - else - { - from.SendLocalizedMessage(501327); // Only the house owner may add Co-owners. - } - - break; - } - case 4: // Remove co-owner - { - if (isOwner) - { - from.CloseGump(); - from.CloseGump(); - from.CloseGump(); - from.SendGump(new HouseRemoveGump(1011274, m_House.CoOwners, m_House, false)); - } - else - { - from.SendLocalizedMessage(501329); // Only the house owner may remove co-owners. - } - - break; - } - case 5: // Clear co-owners - { - if (isOwner) - { - m_House.CoOwners?.Clear(); - - from.SendLocalizedMessage(501333); // All co-owners have been removed from this house. - } - else - { - from.SendLocalizedMessage(501330); // Only the house owner may remove co-owners. - } - - break; - } - case 6: // List friends - { - from.CloseGump(); - from.CloseGump(); - from.CloseGump(); - from.SendGump(new HouseListGump(1011273, m_House.Friends, m_House, false)); - - break; - } - case 7: // Add friend - { - if (isCoOwner) - { - from.SendLocalizedMessage(501317); // Target the person you wish to name a friend of your household. - from.Target = new HouseFriendTarget(true, m_House); - } - else - { - from.SendLocalizedMessage(501316); // Only the house owner may add friends. - } - - break; - } - case 8: // Remove friend - { - if (isCoOwner) - { - from.CloseGump(); - from.CloseGump(); - from.CloseGump(); - from.SendGump(new HouseRemoveGump(1011272, m_House.Friends, m_House, false)); - } - else - { - from.SendLocalizedMessage(501318); // Only the house owner may remove friends. - } - - break; - } - case 9: // Clear friends - { - if (isCoOwner) - { - m_House.Friends?.Clear(); - - from.SendLocalizedMessage(501332); // All friends have been removed from this house. - } - else - { - from.SendLocalizedMessage(501319); // Only the house owner may remove friends. - } - - break; - } - case 10: // Ban - { - from.SendLocalizedMessage(501325); // Target the individual to ban from this house. - from.Target = new HouseBanTarget(true, m_House); - - break; - } - case 11: // Eject - { - from.SendLocalizedMessage(501326); // Target the individual to eject from this house. - from.Target = new HouseKickTarget(m_House); - - break; - } - case 12: // List bans - { - from.CloseGump(); - from.CloseGump(); - from.CloseGump(); - from.SendGump(new HouseListGump(1011271, m_House.Bans, m_House, true)); - - break; - } - case 13: // Remove ban - { - from.CloseGump(); - from.CloseGump(); - from.CloseGump(); - from.SendGump(new HouseRemoveGump(1011269, m_House.Bans, m_House, true)); - - break; - } - case 14: // Transfer ownership - { - if (isOwner) - { - from.SendLocalizedMessage(501309); // Target the person to whom you wish to give this house. - from.Target = new HouseOwnerTarget(m_House); - } - else - { - from.SendLocalizedMessage(501310); // Only the house owner may do this. - } - - break; - } - case 15: // Demolish house - { - if (isOwner) - { - if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null) - { - from.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside. - } - else - { - from.CloseGump(); - from.SendGump(new HouseDemolishGump(from, m_House)); - } - } - else - { - from.SendLocalizedMessage(501320); // Only the house owner may do this. - } - - break; - } - case 16: // Change locks - { - if (m_House.Public) - { - from.SendLocalizedMessage(501669); // Public houses are always unlocked. - } - else { if (isOwner) { - m_House.RemoveKeys(from); - m_House.ChangeLocks(from); - from.SendLocalizedMessage( - 501306); // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack. + 501328); // Target the person you wish to name a co-owner of your household. + from.Target = new CoOwnerTarget(true, m_House); } else { - from.SendLocalizedMessage(501303); // Only the house owner may change the house locks. + from.SendLocalizedMessage(501327); // Only the house owner may add Co-owners. } - } - break; - } + break; + } + case 4: // Remove co-owner + { + if (isOwner) + { + from.CloseGump(); + from.CloseGump(); + from.CloseGump(); + from.SendGump(new HouseRemoveGump(1011274, m_House.CoOwners, m_House, false)); + } + else + { + from.SendLocalizedMessage(501329); // Only the house owner may remove co-owners. + } + + break; + } + case 5: // Clear co-owners + { + if (isOwner) + { + m_House.CoOwners?.Clear(); + + from.SendLocalizedMessage(501333); // All co-owners have been removed from this house. + } + else + { + from.SendLocalizedMessage(501330); // Only the house owner may remove co-owners. + } + + break; + } + case 6: // List friends + { + from.CloseGump(); + from.CloseGump(); + from.CloseGump(); + from.SendGump(new HouseListGump(1011273, m_House.Friends, m_House, false)); + + break; + } + case 7: // Add friend + { + if (isCoOwner) + { + from.SendLocalizedMessage(501317); // Target the person you wish to name a friend of your household. + from.Target = new HouseFriendTarget(true, m_House); + } + else + { + from.SendLocalizedMessage(501316); // Only the house owner may add friends. + } + + break; + } + case 8: // Remove friend + { + if (isCoOwner) + { + from.CloseGump(); + from.CloseGump(); + from.CloseGump(); + from.SendGump(new HouseRemoveGump(1011272, m_House.Friends, m_House, false)); + } + else + { + from.SendLocalizedMessage(501318); // Only the house owner may remove friends. + } + + break; + } + case 9: // Clear friends + { + if (isCoOwner) + { + m_House.Friends?.Clear(); + + from.SendLocalizedMessage(501332); // All friends have been removed from this house. + } + else + { + from.SendLocalizedMessage(501319); // Only the house owner may remove friends. + } + + break; + } + case 10: // Ban + { + from.SendLocalizedMessage(501325); // Target the individual to ban from this house. + from.Target = new HouseBanTarget(true, m_House); + + break; + } + case 11: // Eject + { + from.SendLocalizedMessage(501326); // Target the individual to eject from this house. + from.Target = new HouseKickTarget(m_House); + + break; + } + case 12: // List bans + { + from.CloseGump(); + from.CloseGump(); + from.CloseGump(); + from.SendGump(new HouseListGump(1011271, m_House.Bans, m_House, true)); + + break; + } + case 13: // Remove ban + { + from.CloseGump(); + from.CloseGump(); + from.CloseGump(); + from.SendGump(new HouseRemoveGump(1011269, m_House.Bans, m_House, true)); + + break; + } + case 14: // Transfer ownership + { + if (isOwner) + { + from.SendLocalizedMessage(501309); // Target the person to whom you wish to give this house. + from.Target = new HouseOwnerTarget(m_House); + } + else + { + from.SendLocalizedMessage(501310); // Only the house owner may do this. + } + + break; + } + case 15: // Demolish house + { + if (isOwner) + { + if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null) + { + from.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside. + } + else + { + from.CloseGump(); + from.SendGump(new HouseDemolishGump(from, m_House)); + } + } + else + { + from.SendLocalizedMessage(501320); // Only the house owner may do this. + } + + break; + } + case 16: // Change locks + { + if (m_House.Public) + { + from.SendLocalizedMessage(501669); // Public houses are always unlocked. + } + else + { + if (isOwner) + { + m_House.RemoveKeys(from); + m_House.ChangeLocks(from); + + from.SendLocalizedMessage( + 501306); // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack. + } + else + { + from.SendLocalizedMessage(501303); // Only the house owner may change the house locks. + } + } + + break; + } case 17: // Declare public/private - { - if (isOwner) { - if (m_House.Public && m_House.PlayerVendors.Count > 0) + if (isOwner) { - from.SendLocalizedMessage( - 501887); // You have vendors working out of this building. It cannot be declared private until there are no vendors in place. - break; - } + if (m_House.Public && m_House.PlayerVendors.Count > 0) + { + from.SendLocalizedMessage( + 501887); // You have vendors working out of this building. It cannot be declared private until there are no vendors in place. + break; + } - m_House.Public = !m_House.Public; - if (!m_House.Public) - { - m_House.ChangeLocks(from); + m_House.Public = !m_House.Public; + if (!m_House.Public) + { + m_House.ChangeLocks(from); - from.SendLocalizedMessage(501888); // This house is now private. - from.SendLocalizedMessage( - 501306); // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack. + from.SendLocalizedMessage(501888); // This house is now private. + from.SendLocalizedMessage( + 501306); // The locks on your front door have been changed, and new master keys have been placed in your bank and your backpack. + } + else + { + m_House.RemoveKeys(from); + m_House.RemoveLocks(); + from.SendLocalizedMessage( + 501886); // This house is now public. Friends of the house my now have vendors working out of this building. + } } else { - m_House.RemoveKeys(from); - m_House.RemoveLocks(); - from.SendLocalizedMessage( - 501886); //This house is now public. Friends of the house my now have vendors working out of this building. + from.SendLocalizedMessage(501307); // Only the house owner may do this. } - } - else - { - from.SendLocalizedMessage(501307); // Only the house owner may do this. - } - break; - } + break; + } case 18: // Change type - { - if (isOwner) { - if (m_House.Public && info.Switches.Length > 0) + if (isOwner) { - int index = info.Switches[0] - 1; + if (m_House.Public && info.Switches.Length > 0) + { + int index = info.Switches[0] - 1; - if (index >= 0 && index < 53) - m_House.ChangeSignType(2980 + index * 2); + if (index >= 0 && index < 53) + m_House.ChangeSignType(2980 + index * 2); + } + } + else + { + from.SendLocalizedMessage(501307); // Only the house owner may do this. } - } - else - { - from.SendLocalizedMessage(501307); // Only the house owner may do this. - } - break; - } + break; + } } } } @@ -719,7 +720,7 @@ namespace Server.Prompts { public class RenamePrompt : Prompt { - private BaseHouse m_House; + private readonly BaseHouse m_House; public RenamePrompt(BaseHouse house) => m_House = house; diff --git a/Projects/Scripts/Gumps/HouseGumpAOS.cs b/Projects/Scripts/Gumps/HouseGumpAOS.cs index a29c9454e..ea748ea89 100644 --- a/Projects/Scripts/Gumps/HouseGumpAOS.cs +++ b/Projects/Scripts/Gumps/HouseGumpAOS.cs @@ -42,13 +42,13 @@ namespace Server.Gumps private const int LabelHue = 0x481; private const int HighlightedLabelHue = 0x64; - private static int[] m_HangerNumbers = + private static readonly int[] m_HangerNumbers = { 2968, 2970, 2972, 2974, 2976, 2978 }; - private static int[] m_FoundationNumbers = Core.ML + private static readonly int[] m_FoundationNumbers = Core.ML ? new[] { 20, 189, 765, 65, 101, 0x2DF7, 0x2DFB, 0x3672, 0x3676 @@ -58,7 +58,7 @@ namespace Server.Gumps 20, 189, 765, 65, 101 }; - private static int[] m_PostNumbers = + private static readonly int[] m_PostNumbers = { 9, 29, 54, 90, 147, 169, 177, 204, 251, 257, 263, @@ -68,11 +68,11 @@ namespace Server.Gumps 974, 982 }; - private static List _HouseSigns = new List(); - private BaseHouse m_House; + private static readonly List _HouseSigns = new List(); + private readonly BaseHouse m_House; private List m_List; - private HouseGumpPageAOS m_Page; + private readonly HouseGumpPageAOS m_Page; public HouseGumpAOS(HouseGumpPageAOS page, Mobile from, BaseHouse house) : base(50, 40) { @@ -80,8 +80,8 @@ namespace Server.Gumps m_Page = page; from.CloseGump(); - //from.CloseGump( typeof( HouseListGump ) ); - //from.CloseGump( typeof( HouseRemoveGump ) ); + // from.CloseGump( typeof( HouseListGump ) ); + // from.CloseGump( typeof( HouseRemoveGump ) ); bool isCombatRestricted = house.IsCombatRestricted(from); @@ -155,325 +155,325 @@ namespace Server.Gumps switch (page) { case HouseGumpPageAOS.Information: - { - AddHtmlLocalized(20, 130, 200, 20, 1011242, LabelColor); // Owned By: - AddLabel(210, 130, LabelHue, GetOwnerName()); - - AddHtmlLocalized(20, 170, 380, 20, 1018032, SelectedColor); // This house is properly placed. - AddHtmlLocalized(20, 190, 380, 20, 1018035, SelectedColor); // This house is of modern design. - AddHtmlLocalized(20, 210, 380, 20, house is HouseFoundation ? 1060681 : 1060680, SelectedColor); // This is a (pre | custom)-built house. - AddHtmlLocalized(20, 230, 380, 20, house.Public ? 1060678 : 1060679, SelectedColor); // This house is (private | open to the public). - - switch (house.DecayType) { - case DecayType.Ageless: - case DecayType.AutoRefresh: + AddHtmlLocalized(20, 130, 200, 20, 1011242, LabelColor); // Owned By: + AddLabel(210, 130, LabelHue, GetOwnerName()); + + AddHtmlLocalized(20, 170, 380, 20, 1018032, SelectedColor); // This house is properly placed. + AddHtmlLocalized(20, 190, 380, 20, 1018035, SelectedColor); // This house is of modern design. + AddHtmlLocalized(20, 210, 380, 20, house is HouseFoundation ? 1060681 : 1060680, SelectedColor); // This is a (pre | custom)-built house. + AddHtmlLocalized(20, 230, 380, 20, house.Public ? 1060678 : 1060679, SelectedColor); // This house is (private | open to the public). + + switch (house.DecayType) { - AddHtmlLocalized(20, 250, 380, 20, 1062209, SelectedColor); // This house is Automatically refreshed. - break; - } - case DecayType.ManualRefresh: - { - AddHtmlLocalized(20, 250, 380, 20, 1062208, SelectedColor); // This house is Grandfathered. - break; - } - case DecayType.Condemned: - { - AddHtmlLocalized(20, 250, 380, 20, 1062207, WarningColor); // This house is Condemned. - break; + case DecayType.Ageless: + case DecayType.AutoRefresh: + { + AddHtmlLocalized(20, 250, 380, 20, 1062209, SelectedColor); // This house is Automatically refreshed. + break; + } + case DecayType.ManualRefresh: + { + AddHtmlLocalized(20, 250, 380, 20, 1062208, SelectedColor); // This house is Grandfathered. + break; + } + case DecayType.Condemned: + { + AddHtmlLocalized(20, 250, 380, 20, 1062207, WarningColor); // This house is Condemned. + break; + } } + + AddHtmlLocalized(20, 290, 200, 20, 1060692, SelectedColor); // Built On: + AddLabel(250, 290, LabelHue, GetDateTime(house.BuiltOn)); + + AddHtmlLocalized(20, 310, 200, 20, 1060693, SelectedColor); // Last Traded: + AddLabel(250, 310, LabelHue, GetDateTime(house.LastTraded)); + + AddHtmlLocalized(20, 330, 200, 20, 1061793, SelectedColor); // House Value + AddLabel(250, 330, LabelHue, house.Price.ToString()); + + AddHtmlLocalized(20, 360, 300, 20, 1011241, SelectedColor); // Number of visits this building has had: + AddLabel(350, 360, LabelHue, house.Visits.ToString()); + + break; } - - AddHtmlLocalized(20, 290, 200, 20, 1060692, SelectedColor); // Built On: - AddLabel(250, 290, LabelHue, GetDateTime(house.BuiltOn)); - - AddHtmlLocalized(20, 310, 200, 20, 1060693, SelectedColor); // Last Traded: - AddLabel(250, 310, LabelHue, GetDateTime(house.LastTraded)); - - AddHtmlLocalized(20, 330, 200, 20, 1061793, SelectedColor); // House Value - AddLabel(250, 330, LabelHue, house.Price.ToString()); - - AddHtmlLocalized(20, 360, 300, 20, 1011241, SelectedColor); // Number of visits this building has had: - AddLabel(350, 360, LabelHue, house.Visits.ToString()); - - break; - } case HouseGumpPageAOS.Security: - { - AddButtonLabeled(10, 130, GetButtonID(3, 0), 1011266, isCoOwner); // View Co-Owner List - AddButtonLabeled(10, 150, GetButtonID(3, 1), 1011267, isOwner); // Add a Co-Owner - AddButtonLabeled(10, 170, GetButtonID(3, 2), 1018036, isOwner); // Remove a Co-Owner - AddButtonLabeled(10, 190, GetButtonID(3, 3), 1011268, isOwner); // Clear Co-Owner List - - AddButtonLabeled(10, 220, GetButtonID(3, 4), 1011243); // View Friends List - AddButtonLabeled(10, 240, GetButtonID(3, 5), 1011244, isCoOwner); // Add a Friend - AddButtonLabeled(10, 260, GetButtonID(3, 6), 1018037, isCoOwner); // Remove a Friend - AddButtonLabeled(10, 280, GetButtonID(3, 7), 1011245, isCoOwner); // Clear Friend List - - if (house.Public) { - AddButtonLabeled(10, 310, GetButtonID(3, 8), 1011260); // View Ban List - AddButtonLabeled(10, 330, GetButtonID(3, 9), 1060698); // Clear Ban List + AddButtonLabeled(10, 130, GetButtonID(3, 0), 1011266, isCoOwner); // View Co-Owner List + AddButtonLabeled(10, 150, GetButtonID(3, 1), 1011267, isOwner); // Add a Co-Owner + AddButtonLabeled(10, 170, GetButtonID(3, 2), 1018036, isOwner); // Remove a Co-Owner + AddButtonLabeled(10, 190, GetButtonID(3, 3), 1011268, isOwner); // Clear Co-Owner List - AddButtonLabeled(210, 130, GetButtonID(3, 12), 1060695, isOwner); // Change to Private + AddButtonLabeled(10, 220, GetButtonID(3, 4), 1011243); // View Friends List + AddButtonLabeled(10, 240, GetButtonID(3, 5), 1011244, isCoOwner); // Add a Friend + AddButtonLabeled(10, 260, GetButtonID(3, 6), 1018037, isCoOwner); // Remove a Friend + AddButtonLabeled(10, 280, GetButtonID(3, 7), 1011245, isCoOwner); // Clear Friend List - AddHtmlLocalized(245, 150, 240, 20, 1060694, SelectedColor); // Change to Public + if (house.Public) + { + AddButtonLabeled(10, 310, GetButtonID(3, 8), 1011260); // View Ban List + AddButtonLabeled(10, 330, GetButtonID(3, 9), 1060698); // Clear Ban List + + AddButtonLabeled(210, 130, GetButtonID(3, 12), 1060695, isOwner); // Change to Private + + AddHtmlLocalized(245, 150, 240, 20, 1060694, SelectedColor); // Change to Public + } + else + { + AddButtonLabeled(10, 310, GetButtonID(3, 10), 1060699); // View Access List + AddButtonLabeled(10, 330, GetButtonID(3, 11), 1060700); // Clear Access List + + AddHtmlLocalized(245, 130, 240, 20, 1060695, SelectedColor); // Change to Private + + AddButtonLabeled(210, 150, GetButtonID(3, 13), 1060694, isOwner); // Change to Public + } + + break; } - else - { - AddButtonLabeled(10, 310, GetButtonID(3, 10), 1060699); // View Access List - AddButtonLabeled(10, 330, GetButtonID(3, 11), 1060700); // Clear Access List - - AddHtmlLocalized(245, 130, 240, 20, 1060695, SelectedColor); // Change to Private - - AddButtonLabeled(210, 150, GetButtonID(3, 13), 1060694, isOwner); // Change to Public - } - - break; - } case HouseGumpPageAOS.Storage: - { - AddHtmlLocalized(10, 130, 400, 20, 1060682, LabelColor); //
HOUSE STORAGE SUMMARY
- - // This is not as OSI; storage changes not yet implemented - - /*AddHtmlLocalized( 10, 170, 275, 20, 1011237, LabelColor, false, false ); // Number of locked down items: - AddLabel( 310, 170, LabelHue, m_House.LockDownCount.ToString() ); - - AddHtmlLocalized( 10, 190, 275, 20, 1011238, LabelColor, false, false ); // Maximum locked down items: - AddLabel( 310, 190, LabelHue, m_House.MaxLockDowns.ToString() ); - - AddHtmlLocalized( 10, 210, 275, 20, 1011239, LabelColor, false, false ); // Number of secure containers: - AddLabel( 310, 210, LabelHue, m_House.SecureCount.ToString() ); - - AddHtmlLocalized( 10, 230, 275, 20, 1011240, LabelColor, false, false ); // Maximum number of secure containers: - AddLabel( 310, 230, LabelHue, m_House.MaxSecures.ToString() );*/ - - int maxSecures = house.GetAosMaxSecures(); - int curSecures = house.GetAosCurSecures(out int fromSecures, out int fromVendors, out int fromLockdowns, - out int fromMovingCrate); - - int maxLockdowns = house.GetAosMaxLockdowns(); - int curLockdowns = house.GetAosCurLockdowns(); - - int bonusStorage = (int)(house.BonusStorageScalar * 100 - 100); - - if (bonusStorage > 0) { - AddHtmlLocalized(10, 150, 300, 20, 1072519, LabelColor); // Increased Storage - AddLabel(310, 150, LabelHue, $"{bonusStorage}%"); + AddHtmlLocalized(10, 130, 400, 20, 1060682, LabelColor); //
HOUSE STORAGE SUMMARY
+ + // This is not as OSI; storage changes not yet implemented + + /*AddHtmlLocalized( 10, 170, 275, 20, 1011237, LabelColor, false, false ); // Number of locked down items: + AddLabel( 310, 170, LabelHue, m_House.LockDownCount.ToString() ); + + AddHtmlLocalized( 10, 190, 275, 20, 1011238, LabelColor, false, false ); // Maximum locked down items: + AddLabel( 310, 190, LabelHue, m_House.MaxLockDowns.ToString() ); + + AddHtmlLocalized( 10, 210, 275, 20, 1011239, LabelColor, false, false ); // Number of secure containers: + AddLabel( 310, 210, LabelHue, m_House.SecureCount.ToString() ); + + AddHtmlLocalized( 10, 230, 275, 20, 1011240, LabelColor, false, false ); // Maximum number of secure containers: + AddLabel( 310, 230, LabelHue, m_House.MaxSecures.ToString() );*/ + + int maxSecures = house.GetAosMaxSecures(); + int curSecures = house.GetAosCurSecures(out int fromSecures, out int fromVendors, out int fromLockdowns, + out int fromMovingCrate); + + int maxLockdowns = house.GetAosMaxLockdowns(); + int curLockdowns = house.GetAosCurLockdowns(); + + int bonusStorage = (int)(house.BonusStorageScalar * 100 - 100); + + if (bonusStorage > 0) + { + AddHtmlLocalized(10, 150, 300, 20, 1072519, LabelColor); // Increased Storage + AddLabel(310, 150, LabelHue, $"{bonusStorage}%"); + } + + AddHtmlLocalized(10, 170, 300, 20, 1060683, LabelColor); // Maximum Secure Storage + AddLabel(310, 170, LabelHue, maxSecures.ToString()); + + AddHtmlLocalized(10, 190, 300, 20, 1060685, LabelColor); // Used by Moving Crate + AddLabel(310, 190, LabelHue, fromMovingCrate.ToString()); + + AddHtmlLocalized(10, 210, 300, 20, 1060686, LabelColor); // Used by Lockdowns + AddLabel(310, 210, LabelHue, fromLockdowns.ToString()); + + if (BaseHouse.NewVendorSystem) + { + AddHtmlLocalized(10, 230, 300, 20, 1060688, LabelColor); // Used by Secure Containers + AddLabel(310, 230, LabelHue, fromSecures.ToString()); + + AddHtmlLocalized(10, 250, 300, 20, 1060689, LabelColor); // Available Storage + AddLabel(310, 250, LabelHue, Math.Max(maxSecures - curSecures, 0).ToString()); + + AddHtmlLocalized(10, 290, 300, 20, 1060690, LabelColor); // Maximum Lockdowns + AddLabel(310, 290, LabelHue, maxLockdowns.ToString()); + + AddHtmlLocalized(10, 310, 300, 20, 1060691, LabelColor); // Available Lockdowns + AddLabel(310, 310, LabelHue, Math.Max(maxLockdowns - curLockdowns, 0).ToString()); + + int maxVendors = house.GetNewVendorSystemMaxVendors(); + int vendors = house.PlayerVendors.Count + house.VendorRentalContracts.Count; + + AddHtmlLocalized(10, 350, 300, 20, 1062391, LabelColor); // Vendor Count + AddLabel(310, 350, LabelHue, $"{vendors} / {maxVendors}"); + } + else + { + AddHtmlLocalized(10, 230, 300, 20, 1060687, LabelColor); // Used by Vendors + AddLabel(310, 230, LabelHue, fromVendors.ToString()); + + AddHtmlLocalized(10, 250, 300, 20, 1060688, LabelColor); // Used by Secure Containers + AddLabel(310, 250, LabelHue, fromSecures.ToString()); + + AddHtmlLocalized(10, 270, 300, 20, 1060689, LabelColor); // Available Storage + AddLabel(310, 270, LabelHue, Math.Max(maxSecures - curSecures, 0).ToString()); + + AddHtmlLocalized(10, 330, 300, 20, 1060690, LabelColor); // Maximum Lockdowns + AddLabel(310, 330, LabelHue, maxLockdowns.ToString()); + + AddHtmlLocalized(10, 350, 300, 20, 1060691, LabelColor); // Available Lockdowns + AddLabel(310, 350, LabelHue, Math.Max(maxLockdowns - curLockdowns, 0).ToString()); + } + + break; } - - AddHtmlLocalized(10, 170, 300, 20, 1060683, LabelColor); // Maximum Secure Storage - AddLabel(310, 170, LabelHue, maxSecures.ToString()); - - AddHtmlLocalized(10, 190, 300, 20, 1060685, LabelColor); // Used by Moving Crate - AddLabel(310, 190, LabelHue, fromMovingCrate.ToString()); - - AddHtmlLocalized(10, 210, 300, 20, 1060686, LabelColor); // Used by Lockdowns - AddLabel(310, 210, LabelHue, fromLockdowns.ToString()); - - if (BaseHouse.NewVendorSystem) - { - AddHtmlLocalized(10, 230, 300, 20, 1060688, LabelColor); // Used by Secure Containers - AddLabel(310, 230, LabelHue, fromSecures.ToString()); - - AddHtmlLocalized(10, 250, 300, 20, 1060689, LabelColor); // Available Storage - AddLabel(310, 250, LabelHue, Math.Max(maxSecures - curSecures, 0).ToString()); - - AddHtmlLocalized(10, 290, 300, 20, 1060690, LabelColor); // Maximum Lockdowns - AddLabel(310, 290, LabelHue, maxLockdowns.ToString()); - - AddHtmlLocalized(10, 310, 300, 20, 1060691, LabelColor); // Available Lockdowns - AddLabel(310, 310, LabelHue, Math.Max(maxLockdowns - curLockdowns, 0).ToString()); - - int maxVendors = house.GetNewVendorSystemMaxVendors(); - int vendors = house.PlayerVendors.Count + house.VendorRentalContracts.Count; - - AddHtmlLocalized(10, 350, 300, 20, 1062391, LabelColor); // Vendor Count - AddLabel(310, 350, LabelHue, $"{vendors} / {maxVendors}"); - } - else - { - AddHtmlLocalized(10, 230, 300, 20, 1060687, LabelColor); // Used by Vendors - AddLabel(310, 230, LabelHue, fromVendors.ToString()); - - AddHtmlLocalized(10, 250, 300, 20, 1060688, LabelColor); // Used by Secure Containers - AddLabel(310, 250, LabelHue, fromSecures.ToString()); - - AddHtmlLocalized(10, 270, 300, 20, 1060689, LabelColor); // Available Storage - AddLabel(310, 270, LabelHue, Math.Max(maxSecures - curSecures, 0).ToString()); - - AddHtmlLocalized(10, 330, 300, 20, 1060690, LabelColor); // Maximum Lockdowns - AddLabel(310, 330, LabelHue, maxLockdowns.ToString()); - - AddHtmlLocalized(10, 350, 300, 20, 1060691, LabelColor); // Available Lockdowns - AddLabel(310, 350, LabelHue, Math.Max(maxLockdowns - curLockdowns, 0).ToString()); - } - - break; - } case HouseGumpPageAOS.Customize: - { - bool isCustomizable = isOwner && house is HouseFoundation; + { + bool isCustomizable = isOwner && house is HouseFoundation; - AddButtonLabeled(10, 120, GetButtonID(5, 0), 1060759, - isOwner && !isCustomizable && house.ConvertEntry != null); // Convert Into Customizable House - AddButtonLabeled(10, 160, GetButtonID(5, 1), 1060765, isOwner && isCustomizable); // Customize This House - AddButtonLabeled(10, 180, GetButtonID(5, 2), 1060760, - isOwner && house.MovingCrate != null); // Relocate Moving Crate - AddButtonLabeled(10, 210, GetButtonID(5, 3), 1060761, isOwner && house.Public); // Change House Sign - AddButtonLabeled(10, 230, GetButtonID(5, 4), 1060762, - isOwner && isCustomizable); // Change House Sign Hanger - AddButtonLabeled(10, 250, GetButtonID(5, 5), 1060763, - isOwner && isCustomizable && ((HouseFoundation)house).Signpost != null); // Change Signpost - AddButtonLabeled(10, 280, GetButtonID(5, 6), 1062004, - isOwner && isCustomizable); // Change Foundation Style - AddButtonLabeled(10, 310, GetButtonID(5, 7), 1060764, isCoOwner); // Rename House + AddButtonLabeled(10, 120, GetButtonID(5, 0), 1060759, + isOwner && !isCustomizable && house.ConvertEntry != null); // Convert Into Customizable House + AddButtonLabeled(10, 160, GetButtonID(5, 1), 1060765, isOwner && isCustomizable); // Customize This House + AddButtonLabeled(10, 180, GetButtonID(5, 2), 1060760, + isOwner && house.MovingCrate != null); // Relocate Moving Crate + AddButtonLabeled(10, 210, GetButtonID(5, 3), 1060761, isOwner && house.Public); // Change House Sign + AddButtonLabeled(10, 230, GetButtonID(5, 4), 1060762, + isOwner && isCustomizable); // Change House Sign Hanger + AddButtonLabeled(10, 250, GetButtonID(5, 5), 1060763, + isOwner && isCustomizable && ((HouseFoundation)house).Signpost != null); // Change Signpost + AddButtonLabeled(10, 280, GetButtonID(5, 6), 1062004, + isOwner && isCustomizable); // Change Foundation Style + AddButtonLabeled(10, 310, GetButtonID(5, 7), 1060764, isCoOwner); // Rename House - break; - } + break; + } case HouseGumpPageAOS.Ownership: - { - AddButtonLabeled(10, 130, GetButtonID(6, 0), 1061794, - isOwner && house.MovingCrate == null && house.InternalizedVendors.Count == 0); // Demolish House - AddButtonLabeled(10, 150, GetButtonID(6, 1), 1061797, isOwner); // Trade House - AddButtonLabeled(10, 190, GetButtonID(6, 2), 1061798, false); // Make Primary + { + AddButtonLabeled(10, 130, GetButtonID(6, 0), 1061794, + isOwner && house.MovingCrate == null && house.InternalizedVendors.Count == 0); // Demolish House + AddButtonLabeled(10, 150, GetButtonID(6, 1), 1061797, isOwner); // Trade House + AddButtonLabeled(10, 190, GetButtonID(6, 2), 1061798, false); // Make Primary - break; - } + break; + } case HouseGumpPageAOS.ChangeHanger: - { - for (int i = 0; i < m_HangerNumbers.Length; ++i) { - int x = 50 + i % 3 * 100; - int y = 180 + i / 3 * 80; + for (int i = 0; i < m_HangerNumbers.Length; ++i) + { + int x = 50 + i % 3 * 100; + int y = 180 + i / 3 * 80; - AddButton(x, y, 4005, 4007, GetButtonID(7, i)); - AddItem(x + 20, y, m_HangerNumbers[i]); + AddButton(x, y, 4005, 4007, GetButtonID(7, i)); + AddItem(x + 20, y, m_HangerNumbers[i]); + } + + break; } - - break; - } case HouseGumpPageAOS.ChangeFoundation: - { - for (int i = 0; i < m_FoundationNumbers.Length; ++i) { - int x = 15 + i % 5 * 80; - int y = 180 + i / 5 * 100; + for (int i = 0; i < m_FoundationNumbers.Length; ++i) + { + int x = 15 + i % 5 * 80; + int y = 180 + i / 5 * 100; - AddButton(x, y, 4005, 4007, GetButtonID(8, i)); - AddItem(x + 25, y, m_FoundationNumbers[i]); + AddButton(x, y, 4005, 4007, GetButtonID(8, i)); + AddItem(x + 25, y, m_FoundationNumbers[i]); + } + + break; } - - break; - } case HouseGumpPageAOS.ChangeSign: - { - int index = 0; - - if (_HouseSigns.Count == 0) { - // Add standard signs - for (int i = 0; i < 54; ++i) _HouseSigns.Add(2980 + i * 2); + int index = 0; - // Add library and beekeeper signs ( ML ) - _HouseSigns.Add(2966); - _HouseSigns.Add(3140); - } - - int signsPerPage = Core.ML ? 24 : 18; - int totalSigns = Core.ML ? 56 : 54; - int pages = (int)Math.Ceiling((double)totalSigns / signsPerPage); - - for (int i = 0; i < pages; ++i) - { - AddPage(i + 1); - - AddButton(10, 360, 4005, 4007, 0, GumpButtonType.Page, (i + 1) % pages + 1); - - for (int j = 0; j < signsPerPage && totalSigns - signsPerPage * i - j > 0; ++j) + if (_HouseSigns.Count == 0) { - int x = 30 + j % 6 * 60; - int y = 130 + j / 6 * 60; + // Add standard signs + for (int i = 0; i < 54; ++i) _HouseSigns.Add(2980 + i * 2); - AddButton(x, y, 4005, 4007, GetButtonID(9, index)); - AddItem(x + 20, y, _HouseSigns[index++]); + // Add library and beekeeper signs ( ML ) + _HouseSigns.Add(2966); + _HouseSigns.Add(3140); } - } - break; - } + int signsPerPage = Core.ML ? 24 : 18; + int totalSigns = Core.ML ? 56 : 54; + int pages = (int)Math.Ceiling((double)totalSigns / signsPerPage); + + for (int i = 0; i < pages; ++i) + { + AddPage(i + 1); + + AddButton(10, 360, 4005, 4007, 0, GumpButtonType.Page, (i + 1) % pages + 1); + + for (int j = 0; j < signsPerPage && totalSigns - signsPerPage * i - j > 0; ++j) + { + int x = 30 + j % 6 * 60; + int y = 130 + j / 6 * 60; + + AddButton(x, y, 4005, 4007, GetButtonID(9, index)); + AddItem(x + 20, y, _HouseSigns[index++]); + } + } + + break; + } case HouseGumpPageAOS.RemoveCoOwner: - { - AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor); //
CO-OWNER LIST
- AddList(house.CoOwners, 10, false, true, from); - break; - } - case HouseGumpPageAOS.ListCoOwner: - { - AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor); //
CO-OWNER LIST
- AddList(house.CoOwners, -1, false, true, from); - break; - } - case HouseGumpPageAOS.RemoveFriend: - { - AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor); //
FRIENDS LIST
- AddList(house.Friends, 11, false, true, from); - break; - } - case HouseGumpPageAOS.ListFriend: - { - AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor); //
FRIENDS LIST
- AddList(house.Friends, -1, false, true, from); - break; - } - case HouseGumpPageAOS.RemoveBan: - { - AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor); //
BAN LIST
- AddList(house.Bans, 12, true, true, from); - break; - } - case HouseGumpPageAOS.ListBan: - { - AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor); //
BAN LIST
- AddList(house.Bans, -1, true, true, from); - break; - } - case HouseGumpPageAOS.RemoveAccess: - { - AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor); //
ACCESS LIST
- AddList(house.Access, 13, false, true, from); - break; - } - case HouseGumpPageAOS.ListAccess: - { - AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor); //
ACCESS LIST
- AddList(house.Access, -1, false, true, from); - break; - } - case HouseGumpPageAOS.ChangePost: - { - int index = 0; - - for (int i = 0; i < 2; ++i) { - AddPage(i + 1); - - AddButton(10, 360, 4005, 4007, 0, GumpButtonType.Page, (i + 1) % 2 + 1); - - for (int j = 0; j < 16 && index < m_PostNumbers.Length; ++j) - { - int x = 15 + j % 8 * 50; - int y = 130 + j / 8 * 110; - - AddButton(x, y, 4005, 4007, GetButtonID(14, index)); - AddItem(x + 10, y, m_PostNumbers[index++]); - } + AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor); //
CO-OWNER LIST
+ AddList(house.CoOwners, 10, false, true, from); + break; } + case HouseGumpPageAOS.ListCoOwner: + { + AddHtmlLocalized(10, 120, 400, 20, 1060730, LabelColor); //
CO-OWNER LIST
+ AddList(house.CoOwners, -1, false, true, from); + break; + } + case HouseGumpPageAOS.RemoveFriend: + { + AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor); //
FRIENDS LIST
+ AddList(house.Friends, 11, false, true, from); + break; + } + case HouseGumpPageAOS.ListFriend: + { + AddHtmlLocalized(10, 120, 400, 20, 1060731, LabelColor); //
FRIENDS LIST
+ AddList(house.Friends, -1, false, true, from); + break; + } + case HouseGumpPageAOS.RemoveBan: + { + AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor); //
BAN LIST
+ AddList(house.Bans, 12, true, true, from); + break; + } + case HouseGumpPageAOS.ListBan: + { + AddHtmlLocalized(10, 120, 400, 20, 1060733, LabelColor); //
BAN LIST
+ AddList(house.Bans, -1, true, true, from); + break; + } + case HouseGumpPageAOS.RemoveAccess: + { + AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor); //
ACCESS LIST
+ AddList(house.Access, 13, false, true, from); + break; + } + case HouseGumpPageAOS.ListAccess: + { + AddHtmlLocalized(10, 120, 400, 20, 1060732, LabelColor); //
ACCESS LIST
+ AddList(house.Access, -1, false, true, from); + break; + } + case HouseGumpPageAOS.ChangePost: + { + int index = 0; - break; - } + for (int i = 0; i < 2; ++i) + { + AddPage(i + 1); + + AddButton(10, 360, 4005, 4007, 0, GumpButtonType.Page, (i + 1) % 2 + 1); + + for (int j = 0; j < 16 && index < m_PostNumbers.Length; ++j) + { + int x = 15 + j % 8 * 50; + int y = 130 + j / 8 * 110; + + AddButton(x, y, 4005, 4007, GetButtonID(14, index)); + AddItem(x + 10, y, m_PostNumbers[index++]); + } + } + + break; + } } } @@ -534,7 +534,6 @@ namespace Server.Gumps lastPage = page; } - Mobile m = list[i]; string name; @@ -573,7 +572,7 @@ namespace Server.Gumps } } - public int GetButtonID(int type, int index) => 1 + index * 15 + type; + public static int GetButtonID(int type, int index) => 1 + index * 15 + type; public static void PublicPrivateNotice_Callback(Mobile from, BaseHouse house) { @@ -672,92 +671,92 @@ namespace Server.Gumps if (e == null) return; - int cost = e.Cost - house.Price; + int cost = e.Cost - house.Price; - if (cost > 0) + if (cost > 0) + { + if (Banker.Withdraw(from, cost)) { - if (Banker.Withdraw(from, cost)) - { - from.SendLocalizedMessage(1060398, - cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. - } - else - { - from.SendLocalizedMessage( - 1061624); // You do not have enough funds in your bank to cover the difference between your old house and your new one. - return; - } + from.SendLocalizedMessage(1060398, + cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. } - else if (cost < 0) + else { - if (Banker.Deposit(from, -cost)) - from.SendLocalizedMessage(1060397, - (-cost).ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. - else - return; - } - - BaseHouse newHouse = e.ConstructHouse(from); - - if (newHouse != null) - { - newHouse.Price = e.Cost; - - house.MoveAllToCrate(); - - newHouse.Friends = new List(house.Friends); - newHouse.CoOwners = new List(house.CoOwners); - newHouse.Bans = new List(house.Bans); - newHouse.Access = new List(house.Access); - newHouse.BuiltOn = house.BuiltOn; - newHouse.LastTraded = house.LastTraded; - newHouse.Public = house.Public; - - newHouse.VendorInventories.AddRange(house.VendorInventories); - house.VendorInventories.Clear(); - - foreach (VendorInventory inventory in newHouse.VendorInventories) inventory.House = newHouse; - - newHouse.InternalizedVendors.AddRange(house.InternalizedVendors); - house.InternalizedVendors.Clear(); - - foreach (Mobile mobile in newHouse.InternalizedVendors) - if (mobile is PlayerVendor vendor) - vendor.House = newHouse; - else if (mobile is PlayerBarkeeper barkeeper) - barkeeper.House = newHouse; - - if (house.MovingCrate != null) - { - newHouse.MovingCrate = house.MovingCrate; - newHouse.MovingCrate.House = newHouse; - house.MovingCrate = null; - } - - List items = house.GetItems(); - List mobiles = house.GetMobiles(); - - newHouse.MoveToWorld( - new Point3D(house.X + house.ConvertOffsetX, house.Y + house.ConvertOffsetY, - house.Z + house.ConvertOffsetZ), house.Map); - house.Delete(); - - foreach (Item item in items) item.Location = newHouse.BanLocation; - - foreach (Mobile mobile in mobiles) mobile.Location = newHouse.BanLocation; - - /* You have successfully replaced your original house with a new house. - * The value of the replaced house has been deposited into your bank box. - * All of the items in your original house have been relocated to a Moving Crate in the new house. - * Any deed-based house add-ons have been converted back into deeds. - * Vendors and barkeeps in the house, if any, have been stored in the Moving Crate as well. - * Use the Get Vendor context-sensitive menu option on your character to retrieve them. - * These containers can be used to re-create the vendor in a new location. - * Any barkeepers have been converted into deeds. - */ - from.SendGump(new NoticeGump(1060637, 30720, 1060012, 32512, 420, 280)); + from.SendLocalizedMessage( + 1061624); // You do not have enough funds in your bank to cover the difference between your old house and your new one. return; } + } + else if (cost < 0) + { + if (Banker.Deposit(from, -cost)) + from.SendLocalizedMessage(1060397, + (-cost).ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. + else + return; + } + + BaseHouse newHouse = e.ConstructHouse(from); + + if (newHouse != null) + { + newHouse.Price = e.Cost; + + house.MoveAllToCrate(); + + newHouse.Friends = new List(house.Friends); + newHouse.CoOwners = new List(house.CoOwners); + newHouse.Bans = new List(house.Bans); + newHouse.Access = new List(house.Access); + newHouse.BuiltOn = house.BuiltOn; + newHouse.LastTraded = house.LastTraded; + newHouse.Public = house.Public; + + newHouse.VendorInventories.AddRange(house.VendorInventories); + house.VendorInventories.Clear(); + + foreach (VendorInventory inventory in newHouse.VendorInventories) inventory.House = newHouse; + + newHouse.InternalizedVendors.AddRange(house.InternalizedVendors); + house.InternalizedVendors.Clear(); + + foreach (Mobile mobile in newHouse.InternalizedVendors) + if (mobile is PlayerVendor vendor) + vendor.House = newHouse; + else if (mobile is PlayerBarkeeper barkeeper) + barkeeper.House = newHouse; + + if (house.MovingCrate != null) + { + newHouse.MovingCrate = house.MovingCrate; + newHouse.MovingCrate.House = newHouse; + house.MovingCrate = null; + } + + List items = house.GetItems(); + List mobiles = house.GetMobiles(); + + newHouse.MoveToWorld( + new Point3D(house.X + house.ConvertOffsetX, house.Y + house.ConvertOffsetY, + house.Z + house.ConvertOffsetZ), house.Map); + house.Delete(); + + foreach (Item item in items) item.Location = newHouse.BanLocation; + + foreach (Mobile mobile in mobiles) mobile.Location = newHouse.BanLocation; + + /* You have successfully replaced your original house with a new house. + * The value of the replaced house has been deposited into your bank box. + * All of the items in your original house have been relocated to a Moving Crate in the new house. + * Any deed-based house add-ons have been converted back into deeds. + * Vendors and barkeeps in the house, if any, have been stored in the Moving Crate as well. + * Use the Get Vendor context-sensitive menu option on your character to retrieve them. + * These containers can be used to re-create the vendor in a new location. + * Any barkeepers have been converted into deeds. + */ + from.SendGump(new NoticeGump(1060637, 30720, 1060012, 32512, 420, 280)); + return; + } } from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, house)); @@ -800,7 +799,7 @@ namespace Server.Gumps if (m_Page == HouseGumpPageAOS.Vendors) { - if (index >= 0 && index < m_List.Count) + if (index < m_List.Count) { PlayerVendor vendor = (PlayerVendor)m_List[index]; @@ -825,569 +824,563 @@ namespace Server.Gumps switch (type) { case 0: - { - switch (index) { - case 0: // Banish + switch (index) { - if (m_House.Public) - { - from.SendLocalizedMessage(501325); // Target the individual to ban from this house. - from.Target = new HouseBanTarget(true, m_House); - } + case 0: // Banish + { + if (m_House.Public) + { + from.SendLocalizedMessage(501325); // Target the individual to ban from this house. + from.Target = new HouseBanTarget(true, m_House); + } - break; - } - case 1: // Lift Ban - { - if (m_House.Public) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, from, m_House)); + break; + } + case 1: // Lift Ban + { + if (m_House.Public) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, from, m_House)); - break; - } - case 2: // Grant Access - { - if (!m_House.Public) - { - from.SendLocalizedMessage(1060711); // Target the person you would like to grant access to. - from.Target = new HouseAccessTarget(m_House); - } + break; + } + case 2: // Grant Access + { + if (!m_House.Public) + { + from.SendLocalizedMessage(1060711); // Target the person you would like to grant access to. + from.Target = new HouseAccessTarget(m_House); + } - break; - } - case 3: // Revoke Access - { - if (!m_House.Public) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, from, m_House)); + break; + } + case 3: // Revoke Access + { + if (!m_House.Public) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, from, m_House)); - break; + break; + } } + + break; } - - break; - } case 1: - { - HouseGumpPageAOS page; - - switch (index) { - case 0: - page = HouseGumpPageAOS.Information; - break; - case 1: - page = HouseGumpPageAOS.Security; - break; - case 2: - page = HouseGumpPageAOS.Storage; - break; - case 3: - page = HouseGumpPageAOS.Customize; - break; - case 4: - page = HouseGumpPageAOS.Ownership; - break; - default: return; - } + HouseGumpPageAOS page; - from.SendGump(new HouseGumpAOS(page, from, m_House)); - break; - } + switch (index) + { + case 0: + page = HouseGumpPageAOS.Information; + break; + case 1: + page = HouseGumpPageAOS.Security; + break; + case 2: + page = HouseGumpPageAOS.Storage; + break; + case 3: + page = HouseGumpPageAOS.Customize; + break; + case 4: + page = HouseGumpPageAOS.Ownership; + break; + default: return; + } + + from.SendGump(new HouseGumpAOS(page, from, m_House)); + break; + } case 3: - { - switch (index) { - case 0: // View Co-Owner List + switch (index) { - if (isCoOwner) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListCoOwner, from, m_House)); - - break; - } - case 1: // Add a Co-Owner - { - if (isOwner) - { - from.SendLocalizedMessage( - 501328); // Target the person you wish to name a co-owner of your household. - from.Target = new CoOwnerTarget(true, m_House); - } - - break; - } - case 2: // Remove a Co-Owner - { - if (isOwner) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, from, m_House)); - - break; - } - case 3: // Clear Co-Owner List - { - if (isOwner) - from.SendGump(new WarningGump(1060635, 30720, 1060736, 32512, 420, 280, - okay => ClearCoOwners_Callback(from, okay, m_House))); - - break; - } - case 4: // View Friends List - { - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListFriend, from, m_House)); - - break; - } - case 5: // Add a Friend - { - if (isCoOwner) - { - from.SendLocalizedMessage( - 501317); // Target the person you wish to name a friend of your household. - from.Target = new HouseFriendTarget(true, m_House); - } - - break; - } - case 6: // Remove a Friend - { - if (isCoOwner) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, from, m_House)); - - break; - } - case 7: // Clear Friend List - { - if (isCoOwner) - from.SendGump(new WarningGump(1060635, 30720, 1018039, 32512, 420, 280, - okay => ClearFriends_Callback(from, okay, m_House))); - - break; - } - case 8: // View Ban List - { - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListBan, from, m_House)); - - break; - } - case 9: // Clear Ban List - { - from.SendGump(new WarningGump(1060635, 30720, 1060753, 32512, 420, 280, - okay => ClearBans_Callback(from, okay, m_House))); - - break; - } - case 10: // View Access List - { - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListAccess, from, m_House)); - - break; - } - case 11: // Clear Access List - { - from.SendGump(new WarningGump(1060635, 30720, 1061842, 32512, 420, 280, - okay => ClearAccess_Callback(from, okay, m_House))); - - break; - } - case 12: // Make Private - { - if (isOwner) - { - if (m_House.PlayerVendors.Count > 0) + case 0: // View Co-Owner List { - // You have vendors working out of this building. It cannot be declared private until there are no vendors in place. - from.SendGump(new NoticeGump(1060637, 30720, 501887, 32512, 320, 180, - () => PublicPrivateNotice_Callback(from, m_House))); + if (isCoOwner) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListCoOwner, from, m_House)); + break; } - - if (m_House.VendorRentalContracts.Count > 0) + case 1: // Add a Co-Owner { - // You cannot currently take this action because you have vendor contracts locked down in your home. You must remove them first. - from.SendGump(new NoticeGump(1060637, 30720, 1062351, 32512, 320, 180, - () => PublicPrivateNotice_Callback(from, m_House))); + if (isOwner) + { + from.SendLocalizedMessage( + 501328); // Target the person you wish to name a co-owner of your household. + from.Target = new CoOwnerTarget(true, m_House); + } + break; } - - m_House.Public = false; - - m_House.ChangeLocks(from); - - // This house is now private. - from.SendGump(new NoticeGump(1060637, 30720, 501888, 32512, 320, 180, - () => PublicPrivateNotice_Callback(from, m_House))); - - Region r = m_House.Region; - List list = r.GetMobiles(); - - for (int i = 0; i < list.Count; ++i) + case 2: // Remove a Co-Owner { - Mobile m = list[i]; + if (isOwner) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, from, m_House)); - if (!m_House.HasAccess(m) && m_House.IsInside(m)) - m.Location = m_House.BanLocation; + break; } - } - - break; - } - case 13: // Make Public - { - if (isOwner) - { - m_House.Public = true; - - m_House.RemoveKeys(from); - m_House.RemoveLocks(); - - if (BaseHouse.NewVendorSystem) - from.SendGump(new NoticeGump(1060637, 30720, 501886, 32512, 320, 180, - () => PublicPrivateNotice_Callback(from, m_House))); - else - from.SendGump(new NoticeGump(1060637, 30720, - "This house is now public. Friends of the house may now have vendors working out of this building.", - 0xF8C000, 320, 180, () => PublicPrivateNotice_Callback(from, m_House))); - - Region r = m_House.Region; - List list = r.GetMobiles(); - - for (int i = 0; i < list.Count; ++i) + case 3: // Clear Co-Owner List { - Mobile m = list[i]; + if (isOwner) + from.SendGump(new WarningGump(1060635, 30720, 1060736, 32512, 420, 280, + okay => ClearCoOwners_Callback(from, okay, m_House))); - if (m_House.IsBanned(m) && m_House.IsInside(m)) - m.Location = m_House.BanLocation; + break; } - } + case 4: // View Friends List + { + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListFriend, from, m_House)); - break; + break; + } + case 5: // Add a Friend + { + if (isCoOwner) + { + from.SendLocalizedMessage( + 501317); // Target the person you wish to name a friend of your household. + from.Target = new HouseFriendTarget(true, m_House); + } + + break; + } + case 6: // Remove a Friend + { + if (isCoOwner) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, from, m_House)); + + break; + } + case 7: // Clear Friend List + { + if (isCoOwner) + from.SendGump(new WarningGump(1060635, 30720, 1018039, 32512, 420, 280, + okay => ClearFriends_Callback(from, okay, m_House))); + + break; + } + case 8: // View Ban List + { + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListBan, from, m_House)); + + break; + } + case 9: // Clear Ban List + { + from.SendGump(new WarningGump(1060635, 30720, 1060753, 32512, 420, 280, + okay => ClearBans_Callback(from, okay, m_House))); + + break; + } + case 10: // View Access List + { + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ListAccess, from, m_House)); + + break; + } + case 11: // Clear Access List + { + from.SendGump(new WarningGump(1060635, 30720, 1061842, 32512, 420, 280, + okay => ClearAccess_Callback(from, okay, m_House))); + + break; + } + case 12: // Make Private + { + if (isOwner) + { + if (m_House.PlayerVendors.Count > 0) + { + // You have vendors working out of this building. It cannot be declared private until there are no vendors in place. + from.SendGump(new NoticeGump(1060637, 30720, 501887, 32512, 320, 180, + () => PublicPrivateNotice_Callback(from, m_House))); + break; + } + + if (m_House.VendorRentalContracts.Count > 0) + { + // You cannot currently take this action because you have vendor contracts locked down in your home. You must remove them first. + from.SendGump(new NoticeGump(1060637, 30720, 1062351, 32512, 320, 180, + () => PublicPrivateNotice_Callback(from, m_House))); + break; + } + + m_House.Public = false; + + m_House.ChangeLocks(from); + + // This house is now private. + from.SendGump(new NoticeGump(1060637, 30720, 501888, 32512, 320, 180, + () => PublicPrivateNotice_Callback(from, m_House))); + + Region r = m_House.Region; + List list = r.GetMobiles(); + + for (int i = 0; i < list.Count; ++i) + { + Mobile m = list[i]; + + if (!m_House.HasAccess(m) && m_House.IsInside(m)) + m.Location = m_House.BanLocation; + } + } + + break; + } + case 13: // Make Public + { + if (isOwner) + { + m_House.Public = true; + + m_House.RemoveKeys(from); + m_House.RemoveLocks(); + + if (BaseHouse.NewVendorSystem) + from.SendGump(new NoticeGump(1060637, 30720, 501886, 32512, 320, 180, + () => PublicPrivateNotice_Callback(from, m_House))); + else + from.SendGump(new NoticeGump(1060637, 30720, + "This house is now public. Friends of the house may now have vendors working out of this building.", + 0xF8C000, 320, 180, () => PublicPrivateNotice_Callback(from, m_House))); + + Region r = m_House.Region; + List list = r.GetMobiles(); + + for (int i = 0; i < list.Count; ++i) + { + Mobile m = list[i]; + + if (m_House.IsBanned(m) && m_House.IsInside(m)) + m.Location = m_House.BanLocation; + } + } + + break; + } } + + break; } - - break; - } case 5: - { - switch (index) { - case 0: // Convert Into Customizable House + switch (index) { - if (isOwner && !isCustomizable) - { - if (m_House.HasRentedVendors) + case 0: // Convert Into Customizable House { - // You cannot perform this action while you still have vendors rented out in this house. - from.SendGump(new NoticeGump(1060637, 30720, 1062395, 32512, 320, 180, - () => CustomizeNotice_Callback(from, m_House))); + if (isOwner && !isCustomizable) + { + if (m_House.HasRentedVendors) + { + // You cannot perform this action while you still have vendors rented out in this house. + from.SendGump(new NoticeGump(1060637, 30720, 1062395, 32512, 320, 180, + () => CustomizeNotice_Callback(from, m_House))); + } + else + { + HousePlacementEntry e = m_House.ConvertEntry; + + if (e != null) + from.SendGump(new WarningGump(1060635, 30720, 1060013, 32512, 420, 280, + okay => ConvertHouse_Callback(from, okay, m_House))); + } + } + + break; } - else + case 1: // Customize This House { - HousePlacementEntry e = m_House.ConvertEntry; + if (isOwner && isCustomizable) + { + if (m_House.HasRentedVendors) + from.SendGump(new NoticeGump(1060637, 30720, 1062395, 32512, 320, 180, + () => CustomizeNotice_Callback(from, m_House))); + else if (m_House.HasAddonContainers) + from.SendGump(new NoticeGump(1060637, 30720, 1074863, 32512, 320, 180, + () => CustomizeNotice_Callback(from, m_House))); + else + foundation.BeginCustomize(from); + } - if (e != null) - from.SendGump(new WarningGump(1060635, 30720, 1060013, 32512, 420, 280, - okay => ConvertHouse_Callback(from, okay, m_House))); + break; } - } - - break; - } - case 1: // Customize This House - { - if (isOwner && isCustomizable) - { - if (m_House.HasRentedVendors) - from.SendGump(new NoticeGump(1060637, 30720, 1062395, 32512, 320, 180, - () => CustomizeNotice_Callback(from, m_House))); - - #region Mondain's Legacy - - else if (m_House.HasAddonContainers) - from.SendGump(new NoticeGump(1060637, 30720, 1074863, 32512, 320, 180, - () => CustomizeNotice_Callback(from, m_House))); - - #endregion - - else - foundation.BeginCustomize(from); - } - - break; - } - case 2: // Relocate Moving Crate - { - MovingCrate crate = m_House.MovingCrate; - - if (isOwner && crate != null) - { - if (!m_House.IsInside(from)) + case 2: // Relocate Moving Crate { - from.SendLocalizedMessage(502092); // You must be in your house to do this. + MovingCrate crate = m_House.MovingCrate; + + if (isOwner && crate != null) + { + if (!m_House.IsInside(from)) + { + from.SendLocalizedMessage(502092); // You must be in your house to do this. + } + else + { + crate.MoveToWorld(from.Location, from.Map); + crate.RestartTimer(); + } + } + + break; } - else + case 3: // Change House Sign { - crate.MoveToWorld(from.Location, from.Map); - crate.RestartTimer(); + if (isOwner && m_House.Public) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeSign, from, m_House)); + + break; } - } + case 4: // Change House Sign Hanger + { + if (isOwner && isCustomizable) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeHanger, from, m_House)); - break; - } - case 3: // Change House Sign - { - if (isOwner && m_House.Public) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeSign, from, m_House)); + break; + } + case 5: // Change Signpost + { + if (isOwner && isCustomizable && foundation.Signpost != null) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangePost, from, m_House)); - break; - } - case 4: // Change House Sign Hanger - { - if (isOwner && isCustomizable) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeHanger, from, m_House)); + break; + } + case 6: // Change Foundation Style + { + if (isOwner && isCustomizable) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeFoundation, from, m_House)); - break; - } - case 5: // Change Signpost - { - if (isOwner && isCustomizable && foundation.Signpost != null) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangePost, from, m_House)); + break; + } + case 7: // Rename House + { + if (isCoOwner) + { + from.Prompt = new RenamePrompt(m_House); + from.SendLocalizedMessage(501302); // What dost thou wish the sign to say? + } - break; + break; + } } - case 6: // Change Foundation Style - { - if (isOwner && isCustomizable) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.ChangeFoundation, from, m_House)); - break; - } - case 7: // Rename House - { - if (isCoOwner) - { - from.Prompt = new RenamePrompt(m_House); - from.SendLocalizedMessage(501302); // What dost thou wish the sign to say? - } - - break; - } + break; } - - break; - } case 6: - { - switch (index) { - case 0: // Demolish + switch (index) { - if (isOwner && m_House.MovingCrate == null && m_House.InternalizedVendors.Count == 0) - { - if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null) + case 0: // Demolish { - from.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside. - } - else if (Core.ML && from.AccessLevel < AccessLevel.GameMaster && - DateTime.UtcNow <= m_House.BuiltOn.AddHours(1)) - { - from.SendLocalizedMessage( - 1080178); // You must wait one hour between each house demolition. - } - else - { - from.CloseGump(); - from.SendGump(new HouseDemolishGump(from, m_House)); - } - } + if (isOwner && m_House.MovingCrate == null && m_House.InternalizedVendors.Count == 0) + { + if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null) + { + from.SendLocalizedMessage(501389); // You cannot redeed a house with a guildstone inside. + } + else if (Core.ML && from.AccessLevel < AccessLevel.GameMaster && + DateTime.UtcNow <= m_House.BuiltOn.AddHours(1)) + { + from.SendLocalizedMessage( + 1080178); // You must wait one hour between each house demolition. + } + else + { + from.CloseGump(); + from.SendGump(new HouseDemolishGump(from, m_House)); + } + } - break; - } - case 1: // Trade House - { - if (isOwner) - { - if (BaseHouse.NewVendorSystem && m_House.HasPersonalVendors) - { - from.SendLocalizedMessage( - 1062467); // You cannot trade this house while you still have personal vendors inside. + break; } - else if (m_House.DecayLevel == DecayLevel.DemolitionPending) + case 1: // Trade House { - from.SendLocalizedMessage( - 1005321); // This house has been marked for demolition, and it cannot be transferred. - } - else - { - from.SendLocalizedMessage( - 501309); // Target the person to whom you wish to give this house. - from.Target = new HouseOwnerTarget(m_House); - } - } + if (isOwner) + { + if (BaseHouse.NewVendorSystem && m_House.HasPersonalVendors) + { + from.SendLocalizedMessage( + 1062467); // You cannot trade this house while you still have personal vendors inside. + } + else if (m_House.DecayLevel == DecayLevel.DemolitionPending) + { + from.SendLocalizedMessage( + 1005321); // This house has been marked for demolition, and it cannot be transferred. + } + else + { + from.SendLocalizedMessage( + 501309); // Target the person to whom you wish to give this house. + from.Target = new HouseOwnerTarget(m_House); + } + } - break; + break; + } + case 2: // Make Primary + break; } - case 2: // Make Primary - break; + + break; } - - break; - } case 7: - { - if (isOwner && isCustomizable && index >= 0 && index < m_HangerNumbers.Length) { - Item hanger = foundation.SignHanger; + if (isOwner && isCustomizable && index < m_HangerNumbers.Length) + { + Item hanger = foundation.SignHanger; - if (hanger != null) - hanger.ItemID = m_HangerNumbers[index]; + if (hanger != null) + hanger.ItemID = m_HangerNumbers[index]; - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); + } + + break; } - - break; - } case 8: - { - if (isOwner && isCustomizable) { - FoundationType newType; + if (isOwner && isCustomizable) + { + FoundationType newType; - if (Core.ML && index >= 5) - switch (index) - { - case 5: - newType = FoundationType.ElvenGrey; - break; - case 6: - newType = FoundationType.ElvenNatural; - break; - case 7: - newType = FoundationType.Crystal; - break; - case 8: - newType = FoundationType.Shadow; - break; - default: return; - } - else - switch (index) - { - case 0: - newType = FoundationType.DarkWood; - break; - case 1: - newType = FoundationType.LightWood; - break; - case 2: - newType = FoundationType.Dungeon; - break; - case 3: - newType = FoundationType.Brick; - break; - case 4: - newType = FoundationType.Stone; - break; - default: return; - } + if (Core.ML && index >= 5) + switch (index) + { + case 5: + newType = FoundationType.ElvenGrey; + break; + case 6: + newType = FoundationType.ElvenNatural; + break; + case 7: + newType = FoundationType.Crystal; + break; + case 8: + newType = FoundationType.Shadow; + break; + default: return; + } + else + switch (index) + { + case 0: + newType = FoundationType.DarkWood; + break; + case 1: + newType = FoundationType.LightWood; + break; + case 2: + newType = FoundationType.Dungeon; + break; + case 3: + newType = FoundationType.Brick; + break; + case 4: + newType = FoundationType.Stone; + break; + default: return; + } - foundation.Type = newType; + foundation.Type = newType; - DesignState state = foundation.BackupState; - HouseFoundation.ApplyFoundation(newType, state.Components); - state.OnRevised(); + DesignState state = foundation.BackupState; + HouseFoundation.ApplyFoundation(newType, state.Components); + state.OnRevised(); - state = foundation.DesignState; - HouseFoundation.ApplyFoundation(newType, state.Components); - state.OnRevised(); + state = foundation.DesignState; + HouseFoundation.ApplyFoundation(newType, state.Components); + state.OnRevised(); - state = foundation.CurrentState; - HouseFoundation.ApplyFoundation(newType, state.Components); - state.OnRevised(); + state = foundation.CurrentState; + HouseFoundation.ApplyFoundation(newType, state.Components); + state.OnRevised(); - foundation.Delta(ItemDelta.Update); + foundation.Delta(ItemDelta.Update); - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); + } + + break; } - - break; - } case 9: - { - if (isOwner && m_House.Public && index >= 0 && index < _HouseSigns.Count) { - m_House.ChangeSignType(_HouseSigns[index]); - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); - } + if (isOwner && m_House.Public && index < _HouseSigns.Count) + { + m_House.ChangeSignType(_HouseSigns[index]); + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); + } - break; - } + break; + } case 10: - { - if (isOwner && m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveCoOwner(from, m_List[index]); + if (isOwner && index < m_List?.Count) + { + m_House.RemoveCoOwner(from, m_List[index]); - if (m_House.CoOwners.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, from, m_House)); - else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + if (m_House.CoOwners.Count > 0) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveCoOwner, from, m_House)); + else + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + } + + break; } - - break; - } case 11: - { - if (isCoOwner && m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveFriend(from, m_List[index]); + if (isCoOwner && index < m_List?.Count) + { + m_House.RemoveFriend(from, m_List[index]); - if (m_House.Friends.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, from, m_House)); - else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + if (m_House.Friends.Count > 0) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveFriend, from, m_House)); + else + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + } + + break; } - - break; - } case 12: - { - if (m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveBan(from, m_List[index]); + if (index < m_List?.Count) + { + m_House.RemoveBan(from, m_List[index]); - if (m_House.Bans.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, from, m_House)); - else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + if (m_House.Bans.Count > 0) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveBan, from, m_House)); + else + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + } + + break; } - - break; - } case 13: - { - if (m_List != null && index >= 0 && index < m_List.Count) { - m_House.RemoveAccess(from, m_List[index]); + if (index < m_List?.Count) + { + m_House.RemoveAccess(from, m_List[index]); - if (m_House.Access.Count > 0) - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, from, m_House)); - else - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + if (m_House.Access.Count > 0) + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.RemoveAccess, from, m_House)); + else + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Security, from, m_House)); + } + + break; } - - break; - } case 14: - { - if (isOwner && isCustomizable && index >= 0 && index < m_PostNumbers.Length) { - foundation.SignpostGraphic = m_PostNumbers[index]; - foundation.CheckSignpost(); + if (isOwner && isCustomizable && index < m_PostNumbers.Length) + { + foundation.SignpostGraphic = m_PostNumbers[index]; + foundation.CheckSignpost(); - from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); + from.SendGump(new HouseGumpAOS(HouseGumpPageAOS.Customize, from, m_House)); + } + + break; } - - break; - } } } @@ -1404,7 +1397,7 @@ namespace Server.Gumps { string val = values[i]; - string v = current.Length == 0 ? val : $"{current}{' '}{val}"; + string v = current.Length == 0 ? val : $"{current} {val}"; if (v.Length < 10) { diff --git a/Projects/Scripts/Gumps/HouseTransferGump.cs b/Projects/Scripts/Gumps/HouseTransferGump.cs index fc3926804..8af408063 100644 --- a/Projects/Scripts/Gumps/HouseTransferGump.cs +++ b/Projects/Scripts/Gumps/HouseTransferGump.cs @@ -5,8 +5,9 @@ namespace Server.Gumps { public class HouseTransferGump : Gump { - private Mobile m_From, m_To; - private BaseHouse m_House; + private readonly Mobile m_From; + private readonly Mobile m_To; + private readonly BaseHouse m_House; public HouseTransferGump(Mobile from, Mobile to, BaseHouse house) : base(110, 100) { diff --git a/Projects/Scripts/Gumps/NoticeGump.cs b/Projects/Scripts/Gumps/NoticeGump.cs index af0ef55d6..15416f4c6 100644 --- a/Projects/Scripts/Gumps/NoticeGump.cs +++ b/Projects/Scripts/Gumps/NoticeGump.cs @@ -6,7 +6,7 @@ namespace Server.Gumps public class NoticeGump : Gump { - private NoticeGumpCallback m_Callback; + private readonly NoticeGumpCallback m_Callback; public NoticeGump(int header, int headerColor, object content, int contentColor, int width, int height, NoticeGumpCallback callback = null) : base((640 - width) / 2, (480 - height) / 2) diff --git a/Projects/Scripts/Gumps/PetResurrectGump.cs b/Projects/Scripts/Gumps/PetResurrectGump.cs index 494505e9e..ee9228fe8 100644 --- a/Projects/Scripts/Gumps/PetResurrectGump.cs +++ b/Projects/Scripts/Gumps/PetResurrectGump.cs @@ -5,8 +5,8 @@ namespace Server.Gumps { public class PetResurrectGump : Gump { - private double m_HitsScalar; - private BaseCreature m_Pet; + private readonly double m_HitsScalar; + private readonly BaseCreature m_Pet; public PetResurrectGump(Mobile from, BaseCreature pet, double hitsScalar = 0.0) : base(50, 50) { @@ -48,7 +48,7 @@ namespace Server.Gumps return; } - if (m_Pet.Region?.IsPartOf("Khaldun") == true) //TODO: Confirm for pets, as per Bandage's script. + if (m_Pet.Region?.IsPartOf("Khaldun") == true) // TODO: Confirm for pets, as per Bandage's script. { from.SendLocalizedMessage( 1010395); // The veil of death in this area is too strong and resists thy efforts to restore life. @@ -66,7 +66,7 @@ namespace Server.Gumps else decreaseAmount = 0.2; - for (int i = 0; i < m_Pet.Skills.Length; ++i) //Decrease all skills on pet. + for (int i = 0; i < m_Pet.Skills.Length; ++i) // Decrease all skills on pet. m_Pet.Skills[i].Base -= decreaseAmount; if (!m_Pet.IsDeadPet && m_HitsScalar > 0) diff --git a/Projects/Scripts/Gumps/PlayerVendorGumps.cs b/Projects/Scripts/Gumps/PlayerVendorGumps.cs index 93c2e375b..e2d11f629 100644 --- a/Projects/Scripts/Gumps/PlayerVendorGumps.cs +++ b/Projects/Scripts/Gumps/PlayerVendorGumps.cs @@ -10,8 +10,8 @@ namespace Server.Gumps { public class PlayerVendorBuyGump : Gump { - private PlayerVendor m_Vendor; - private VendorItem m_VI; + private readonly PlayerVendor m_Vendor; + private readonly VendorItem m_VI; public PlayerVendorBuyGump(PlayerVendor vendor, VendorItem vi) : base(100, 200) { @@ -99,7 +99,7 @@ namespace Server.Gumps public class PlayerVendorOwnerGump : Gump { - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public PlayerVendorOwnerGump(PlayerVendor vendor) : base(50, 200) { @@ -122,7 +122,7 @@ namespace Server.Gumps AddHtmlLocalized(40, 96, 260, 20, 1038322); // Gold held in my account: AddLabel(300, 96, 0, m_Vendor.BankAccount.ToString()); - //AddHtmlLocalized( 40, 120, 260, 20, 1038324, false, false ); // My charge per day is: + // AddHtmlLocalized( 40, 120, 260, 20, 1038324, false, false ); // My charge per day is: // Localization has changed, we must use a string here AddHtml(40, 120, 260, 20, "My charge per day is:"); AddLabel(300, 120, 0, perDay.ToString()); @@ -145,24 +145,24 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: - { - m_Vendor.OpenBackpack(from); + { + m_Vendor.OpenBackpack(from); - break; - } + break; + } case 2: - { - from.SendGump(new PlayerVendorCustomizeGump(m_Vendor, from)); + { + from.SendGump(new PlayerVendorCustomizeGump(m_Vendor, from)); - break; - } + break; + } } } } public class NewPlayerVendorOwnerGump : Gump { - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public NewPlayerVendorOwnerGump(PlayerVendor vendor) : base(50, 200) { @@ -251,54 +251,54 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // See goods - { - m_Vendor.OpenBackpack(from); + { + m_Vendor.OpenBackpack(from); - break; - } + break; + } case 2: // Customize - { - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + { + from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - break; - } + break; + } case 3: // Rename Shop - { - m_Vendor.RenameShop(from); + { + m_Vendor.RenameShop(from); - break; - } + break; + } case 4: // Rename Vendor - { - m_Vendor.Rename(from); + { + m_Vendor.Rename(from); - break; - } + break; + } case 5: // Open Paperdoll - { - m_Vendor.DisplayPaperdollTo(from); + { + m_Vendor.DisplayPaperdollTo(from); - break; - } + break; + } case 6: // Collect Gold - { - m_Vendor.CollectGold(from); + { + m_Vendor.CollectGold(from); - break; - } + break; + } case 7: // Dismiss Vendor - { - m_Vendor.Dismiss(from); + { + m_Vendor.Dismiss(from); - break; - } + break; + } } } } public class PlayerVendorCustomizeGump : Gump { - private static CustomCategory[] Categories = + private static readonly CustomCategory[] Categories = { new CustomCategory(Layer.InnerTorso, 1011357, true, new[] { @@ -312,7 +312,7 @@ namespace Server.Gumps new CustomCategory(Layer.MiddleTorso, 1011371, true, new[] { - //Over chest + // Over chest new CustomItem(typeof(Doublet), 1011358, 8059), new CustomItem(typeof(Tunic), 1011361, 8097), new CustomItem(typeof(JesterSuit), 1011366, 8095), @@ -324,7 +324,7 @@ namespace Server.Gumps new CustomCategory(Layer.Shoes, 1011388, true, new[] { - //Footwear + // Footwear new CustomItem(typeof(Sandals), 1011389, 5901), new CustomItem(typeof(Shoes), 1011390, 5904), new CustomItem(typeof(Boots), 1011391, 5899), @@ -333,7 +333,7 @@ namespace Server.Gumps new CustomCategory(Layer.Helm, 1011375, true, new[] { - //Hats + // Hats new CustomItem(typeof(SkullCap), 1011376, 5444), new CustomItem(typeof(Bandana), 1011377, 5440), new CustomItem(typeof(FloppyHat), 1011378, 5907), @@ -344,7 +344,7 @@ namespace Server.Gumps new CustomCategory(Layer.Helm, 1015319, true, new[] { - //More Hats + // More Hats new CustomItem(typeof(StrawHat), 1011382, 5911), new CustomItem(typeof(WizardsHat), 1011383, 5912), new CustomItem(typeof(Bonnet), 1011384, 5913), @@ -355,7 +355,7 @@ namespace Server.Gumps new CustomCategory(Layer.Pants, 1011367, true, new[] { - //Lower Torso + // Lower Torso new CustomItem(typeof(LongPants), 1011368, 5433), new CustomItem(typeof(Kilt), 1011369, 5431), new CustomItem(typeof(Skirt), 1011370, 5398) @@ -383,7 +383,7 @@ namespace Server.Gumps new CustomCategory(Layer.FacialHair, 1015320, true, new[] { - //Facial Hair + // Facial Hair new CustomItem(0x2041, 1011062), new CustomItem(0x203F, 1011060), new CustomItem(0x204B, 1015321, true), @@ -395,7 +395,7 @@ namespace Server.Gumps new CustomCategory(Layer.FirstValid, 1011397, false, new[] { - //Held items + // Held items new CustomItem(typeof(FishingPole), 1011406, 3520), new CustomItem(typeof(Pickaxe), 1011407, 3717), new CustomItem(typeof(Pitchfork), 1011408, 3720), @@ -409,7 +409,7 @@ namespace Server.Gumps new CustomCategory(Layer.FirstValid, 1015325, false, new[] { - //More held items + // More held items new CustomItem(typeof(Crossbow), 1011414, 3920), new CustomItem(typeof(WarMace), 1011415, 5126), new CustomItem(typeof(TwoHandedAxe), 1011416, 5186), @@ -419,7 +419,7 @@ namespace Server.Gumps }) }; - private Mobile m_Vendor; + private readonly Mobile m_Vendor; public PlayerVendorCustomizeGump(Mobile v, Mobile from) : base(30, 40) { @@ -494,7 +494,7 @@ namespace Server.Gumps if (m_Vendor is PlayerVendor) // do nothing for barkeeps { m_Vendor.Direction = m_Vendor.GetDirectionTo(from); - m_Vendor.Animate(32, 5, 1, true, false, 0); //bow + m_Vendor.Animate(32, 5, 1, true, false, 0); // bow m_Vendor.SayTo(from, 1043310 + Utility.Random(12)); // a little random speech } } @@ -612,7 +612,7 @@ namespace Server.Gumps { cat -= 100; - if (cat < Categories.Length && cat >= 0) + if (cat < Categories.Length) { CustomCategory category = Categories[cat]; @@ -669,15 +669,15 @@ namespace Server.Gumps LongText = longText; } - public Type Type{ get; } + public Type Type { get; } - public int ItemID{ get; } + public int ItemID { get; } - public int LocNumber{ get; } + public int LocNumber { get; } - public int ArtNumber{ get; } + public int ArtNumber { get; } - public bool LongText{ get; } + public bool LongText { get; } public Item Create() { @@ -688,7 +688,7 @@ namespace Server.Gumps try { - ConstructorInfo ctor = Type.GetConstructor(new Type[0]); + ConstructorInfo ctor = Type.GetConstructor(Array.Empty()); if (ctor != null) i = ctor.Invoke(null) as Item; } @@ -711,20 +711,20 @@ namespace Server.Gumps LocNumber = loc; } - public bool CanDye{ get; } + public bool CanDye { get; } - public CustomItem[] Entries{ get; } + public CustomItem[] Entries { get; } - public Layer Layer{ get; } + public Layer Layer { get; } - public int LocNumber{ get; } + public int LocNumber { get; } } private class PVHuePicker : HuePicker { - private Item m_Item; - private Mobile m_Mob; - private Mobile m_Vendor; + private readonly Item m_Item; + private readonly Mobile m_Mob; + private readonly Mobile m_Vendor; public PVHuePicker(Item item, Mobile v, Mobile from) : base(item.ItemID) { @@ -751,9 +751,9 @@ namespace Server.Gumps private class PVHairHuePicker : HuePicker { - private bool m_FacialHair; - private Mobile m_Mob; - private Mobile m_Vendor; + private readonly bool m_FacialHair; + private readonly Mobile m_Mob; + private readonly Mobile m_Vendor; public PVHairHuePicker(bool facialHair, Mobile v, Mobile from) : base(0xFAB) { @@ -785,7 +785,7 @@ namespace Server.Gumps public class NewPlayerVendorCustomizeGump : Gump { - private static HairOrBeard[] m_HairStyles = + private static readonly HairOrBeard[] m_HairStyles = { new HairOrBeard(0x203B, 1011052), // Short new HairOrBeard(0x203C, 1011053), // Long @@ -798,7 +798,7 @@ namespace Server.Gumps new HairOrBeard(0x2049, 1011049) // 2-tails }; - private static HairOrBeard[] m_BeardStyles = + private static readonly HairOrBeard[] m_BeardStyles = { new HairOrBeard(0x2041, 1011062), // Mustache new HairOrBeard(0x203F, 1011060), // Short beard @@ -809,7 +809,7 @@ namespace Server.Gumps new HairOrBeard(0x204D, 1011401) // Vandyke }; - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public NewPlayerVendorCustomizeGump(PlayerVendor vendor) : base(50, 50) { @@ -887,116 +887,116 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: // CLOSE - { - m_Vendor.Direction = m_Vendor.GetDirectionTo(from); - m_Vendor.Animate(32, 5, 1, true, false, 0); // bow - m_Vendor.SayTo(from, 1043310 + Utility.Random(12)); // a little random speech + { + m_Vendor.Direction = m_Vendor.GetDirectionTo(from); + m_Vendor.Animate(32, 5, 1, true, false, 0); // bow + m_Vendor.SayTo(from, 1043310 + Utility.Random(12)); // a little random speech - break; - } + break; + } case 1: // Female/Male - { - if (m_Vendor.Female) - { - m_Vendor.BodyValue = 400; - m_Vendor.Female = false; - } - else - { - m_Vendor.BodyValue = 401; - m_Vendor.Female = true; - - m_Vendor.FacialHairItemID = 0; - } - - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - - break; - } - case 2: // Remove hair - { - m_Vendor.HairItemID = 0; - - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - - break; - } - case 3: // Color hair - { - if (m_Vendor.HairItemID > 0) - new PVHuePicker(m_Vendor, false, from).SendTo(from.NetState); - else - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - - break; - } - case 4: // Remove beard - { - m_Vendor.FacialHairItemID = 0; - - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - - break; - } - case 5: // Color beard - { - if (m_Vendor.FacialHairItemID > 0) - new PVHuePicker(m_Vendor, true, from).SendTo(from.NetState); - else - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - - break; - } - default: - { - int hairhue = 0; - - if ((info.ButtonID & 0x100) != 0) // Hair style selected - { - int index = info.ButtonID & 0xFF; - - if (index >= m_HairStyles.Length) - return; - - HairOrBeard hairStyle = m_HairStyles[index]; - - hairhue = m_Vendor.HairHue; - - m_Vendor.HairItemID = 0; - m_Vendor.ProcessDelta(); - - m_Vendor.HairItemID = hairStyle.ItemID; - - m_Vendor.HairHue = hairhue; - - from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - } - else if ((info.ButtonID & 0x200) != 0) // Beard style selected { if (m_Vendor.Female) - return; + { + m_Vendor.BodyValue = 400; + m_Vendor.Female = false; + } + else + { + m_Vendor.BodyValue = 401; + m_Vendor.Female = true; - int index = info.ButtonID & 0xFF; - - if (index >= m_BeardStyles.Length) - return; - - HairOrBeard beardStyle = m_BeardStyles[index]; - - hairhue = m_Vendor.FacialHairHue; - - m_Vendor.FacialHairItemID = 0; - m_Vendor.ProcessDelta(); - - m_Vendor.FacialHairItemID = beardStyle.ItemID; - - m_Vendor.FacialHairHue = hairhue; + m_Vendor.FacialHairItemID = 0; + } from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); - } - break; - } + break; + } + case 2: // Remove hair + { + m_Vendor.HairItemID = 0; + + from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + + break; + } + case 3: // Color hair + { + if (m_Vendor.HairItemID > 0) + new PVHuePicker(m_Vendor, false, from).SendTo(from.NetState); + else + from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + + break; + } + case 4: // Remove beard + { + m_Vendor.FacialHairItemID = 0; + + from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + + break; + } + case 5: // Color beard + { + if (m_Vendor.FacialHairItemID > 0) + new PVHuePicker(m_Vendor, true, from).SendTo(from.NetState); + else + from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + + break; + } + default: + { + int hairhue; + + if ((info.ButtonID & 0x100) != 0) // Hair style selected + { + int index = info.ButtonID & 0xFF; + + if (index >= m_HairStyles.Length) + return; + + HairOrBeard hairStyle = m_HairStyles[index]; + + hairhue = m_Vendor.HairHue; + + m_Vendor.HairItemID = 0; + m_Vendor.ProcessDelta(); + + m_Vendor.HairItemID = hairStyle.ItemID; + + m_Vendor.HairHue = hairhue; + + from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + } + else if ((info.ButtonID & 0x200) != 0) // Beard style selected + { + if (m_Vendor.Female) + return; + + int index = info.ButtonID & 0xFF; + + if (index >= m_BeardStyles.Length) + return; + + HairOrBeard beardStyle = m_BeardStyles[index]; + + hairhue = m_Vendor.FacialHairHue; + + m_Vendor.FacialHairItemID = 0; + m_Vendor.ProcessDelta(); + + m_Vendor.FacialHairItemID = beardStyle.ItemID; + + m_Vendor.FacialHairHue = hairhue; + + from.SendGump(new NewPlayerVendorCustomizeGump(m_Vendor)); + } + + break; + } } } @@ -1008,16 +1008,16 @@ namespace Server.Gumps Name = name; } - public int ItemID{ get; } + public int ItemID { get; } - public int Name{ get; } + public int Name { get; } } private class PVHuePicker : HuePicker { - private bool m_FacialHair; - private Mobile m_From; - private PlayerVendor m_Vendor; + private readonly bool m_FacialHair; + private readonly Mobile m_From; + private readonly PlayerVendor m_Vendor; public PVHuePicker(PlayerVendor vendor, bool facialHair, Mobile from) : base(0xFAB) { diff --git a/Projects/Scripts/Gumps/PolymorphGump.cs b/Projects/Scripts/Gumps/PolymorphGump.cs index 4d6717b53..600b5be08 100644 --- a/Projects/Scripts/Gumps/PolymorphGump.cs +++ b/Projects/Scripts/Gumps/PolymorphGump.cs @@ -25,31 +25,29 @@ namespace Server.Gumps public static readonly PolymorphEntry Ettin = new PolymorphEntry(8408, 0x02, 1015252, 25, 8); public static readonly PolymorphEntry Daemon = new PolymorphEntry(8403, 0x09, 1015253, 25, 8); - - private PolymorphEntry(int Art, int Body, int LocNum, int X, int Y) + private PolymorphEntry(int art, int body, int locNum, int x, int y) { - ArtID = Art; - BodyID = Body; - LocNumber = LocNum; - this.X = X; - this.Y = Y; + ArtID = art; + BodyID = body; + LocNumber = locNum; + this.X = x; + this.Y = y; } - public int ArtID{ get; } + public int ArtID { get; } - public int BodyID{ get; } + public int BodyID { get; } - public int LocNumber{ get; } + public int LocNumber { get; } - public int X{ get; } + public int X { get; } - public int Y{ get; } + public int Y { get; } } - public class PolymorphGump : Gump { - private static PolymorphCategory[] Categories = + private static readonly PolymorphCategory[] Categories = { new PolymorphCategory(1015235, // Animals PolymorphEntry.Chicken, @@ -74,9 +72,8 @@ namespace Server.Gumps PolymorphEntry.HumanFemale) }; - - private Mobile m_Caster; - private Item m_Scroll; + private readonly Mobile m_Caster; + private readonly Item m_Scroll; public PolymorphGump(Mobile caster, Item scroll) : base(50, 50) { @@ -145,9 +142,9 @@ namespace Server.Gumps Entries = entries; } - public PolymorphEntry[] Entries{ get; } + public PolymorphEntry[] Entries { get; } - public int LocNumber{ get; } + public int LocNumber { get; } } } @@ -175,8 +172,8 @@ namespace Server.Gumps PolymorphEntry.Daemon }; - private Mobile m_Caster; - private Item m_Scroll; + private readonly Mobile m_Caster; + private readonly Item m_Scroll; public NewPolymorphGump(Mobile caster, Item scroll) : base(0, 0) { diff --git a/Projects/Scripts/Gumps/Props/PropsGump.cs b/Projects/Scripts/Gumps/Props/PropsGump.cs index 3d7623263..b5ee03e01 100644 --- a/Projects/Scripts/Gumps/Props/PropsGump.cs +++ b/Projects/Scripts/Gumps/Props/PropsGump.cs @@ -56,8 +56,9 @@ namespace Server.Gumps public static readonly int EntryHeight = PropsConfig.EntryHeight; public static readonly int BorderSize = PropsConfig.BorderSize; - private static bool PrevLabel = OldStyle, NextLabel = OldStyle; - private static bool TypeLabel = !OldStyle; + private static readonly bool PrevLabel = OldStyle; + private static readonly bool NextLabel = OldStyle; + private static readonly bool TypeLabel = !OldStyle; private static readonly int PrevLabelOffsetX = PrevWidth + 1; private static readonly int PrevLabelOffsetY = 0; @@ -88,30 +89,30 @@ namespace Server.Gumps public static object[] m_PoisonValues = { null, Poison.Lesser, Poison.Regular, Poison.Greater, Poison.Deadly, Poison.Lethal }; - private static Type typeofMobile = typeof(Mobile); - private static Type typeofItem = typeof(Item); - private static Type typeofType = typeof(Type); - private static Type typeofPoint3D = typeof(Point3D); - private static Type typeofPoint2D = typeof(Point2D); - private static Type typeofTimeSpan = typeof(TimeSpan); - private static Type typeofCustomEnum = typeof(CustomEnumAttribute); - private static Type typeofEnum = typeof(Enum); - private static Type typeofBool = typeof(bool); - private static Type typeofString = typeof(string); - private static Type typeofText = typeof(TextDefinition); - private static Type typeofPoison = typeof(Poison); - private static Type typeofMap = typeof(Map); - private static Type typeofSkills = typeof(Skills); - private static Type typeofPropertyObject = typeof(PropertyObjectAttribute); - private static Type typeofNoSort = typeof(NoSortAttribute); + private static readonly Type typeofMobile = typeof(Mobile); + private static readonly Type typeofItem = typeof(Item); + private static readonly Type typeofType = typeof(Type); + private static readonly Type typeofPoint3D = typeof(Point3D); + private static readonly Type typeofPoint2D = typeof(Point2D); + private static readonly Type typeofTimeSpan = typeof(TimeSpan); + private static readonly Type typeofCustomEnum = typeof(CustomEnumAttribute); + private static readonly Type typeofEnum = typeof(Enum); + private static readonly Type typeofBool = typeof(bool); + private static readonly Type typeofString = typeof(string); + private static readonly Type typeofText = typeof(TextDefinition); + private static readonly Type typeofPoison = typeof(Poison); + private static readonly Type typeofMap = typeof(Map); + private static readonly Type typeofSkills = typeof(Skills); + private static readonly Type typeofPropertyObject = typeof(PropertyObjectAttribute); + private static readonly Type typeofNoSort = typeof(NoSortAttribute); - private static Type[] typeofReal = + private static readonly Type[] typeofReal = { typeof(float), typeof(double) }; - private static Type[] typeofNumeric = + private static readonly Type[] typeofNumeric = { typeof(byte), typeof(short), @@ -123,14 +124,14 @@ namespace Server.Gumps typeof(ulong) }; - private static Type typeofCPA = typeof(CPA); - private static Type typeofObject = typeof(object); - private List m_List; - private Mobile m_Mobile; - private object m_Object; + private static readonly Type typeofCPA = typeof(CPA); + private static readonly Type typeofObject = typeof(object); + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; private int m_Page; - private Stack m_Stack; - private Type m_Type; + private readonly Stack m_Stack; + private readonly Type m_Type; public PropertiesGump(Mobile mobile, object o) : base(GumpOffsetX, GumpOffsetY) { @@ -292,115 +293,115 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: // Closed - { - if (m_Stack?.Count > 0) { - StackEntry entry = m_Stack.Pop(); - from.SendGump(new PropertiesGump(from, entry.m_Object, m_Stack, null)); - } + if (m_Stack?.Count > 0) + { + StackEntry entry = m_Stack.Pop(); + from.SendGump(new PropertiesGump(from, entry.m_Object, m_Stack, null)); + } - break; - } + break; + } case 1: // Previous - { - if (m_Page > 0) - from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page - 1)); - - break; - } - case 2: // Next - { - if ((m_Page + 1) * EntryCount < m_List.Count) - from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page + 1)); - - break; - } - default: - { - int index = m_Page * EntryCount + (info.ButtonID - 3); - - if (index >= 0 && index < m_List.Count) { - PropertyInfo prop = m_List[index] as PropertyInfo; + if (m_Page > 0) + from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page - 1)); - if (prop == null) - return; - - CPA attr = GetCPA(prop); - - if (prop.GetType().IsValueType && !prop.CanWrite || attr == null || from.AccessLevel < attr.WriteLevel || attr.ReadOnly) - return; - - Type type = prop.PropertyType; - - if (IsType(type, typeofMobile) || IsType(type, typeofItem)) - { - from.SendGump(new SetObjectGump(prop, from, m_Object, m_Stack, type, m_Page, m_List)); - } - else if (IsType(type, typeofType)) - { - from.Target = new SetObjectTarget(prop, from, m_Object, m_Stack, type, m_Page, m_List); - } - else if (IsType(type, typeofPoint3D)) - { - from.SendGump(new SetPoint3DGump(prop, from, m_Object, m_Stack, m_Page, m_List)); - } - else if (IsType(type, typeofPoint2D)) - { - from.SendGump(new SetPoint2DGump(prop, from, m_Object, m_Stack, m_Page, m_List)); - } - else if (IsType(type, typeofTimeSpan)) - { - from.SendGump(new SetTimeSpanGump(prop, from, m_Object, m_Stack, m_Page, m_List)); - } - else if (IsCustomEnum(type)) - { - from.SendGump(new SetCustomEnumGump(prop, from, m_Object, m_Stack, m_Page, m_List, - GetCustomEnumNames(type))); - } - else if (IsType(type, typeofEnum)) - { - from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, - Enum.GetNames(type), GetObjects(Enum.GetValues(type)))); - } - else if (IsType(type, typeofBool)) - { - from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, m_BoolNames, - m_BoolValues)); - } - else if (IsType(type, typeofString) || IsType(type, typeofReal) || IsType(type, typeofNumeric) || - IsType(type, typeofText)) - { - from.SendGump(new SetGump(prop, from, m_Object, m_Stack, m_Page, m_List)); - } - else if (IsType(type, typeofPoison)) - { - from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, - m_PoisonValues)); - } - else if (IsType(type, typeofMap)) - { - from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, - Map.GetMapNames(), Map.GetMapValues().ToArray())); - } - else if (IsType(type, typeofSkills) && m_Object is Mobile mobile) - { - from.SendGump(new PropertiesGump(from, mobile, m_Stack, m_List, m_Page)); - from.SendGump(new SkillsGump(from, mobile)); - } - else if (HasAttribute(type, typeofPropertyObject, true)) - { - object obj = prop.GetValue(m_Object, null); - - if (obj != null) - from.SendGump(new PropertiesGump(from, obj, m_Stack, new StackEntry(m_Object, prop))); - else - from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page)); - } + break; } + case 2: // Next + { + if ((m_Page + 1) * EntryCount < m_List.Count) + from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page + 1)); - break; - } + break; + } + default: + { + int index = m_Page * EntryCount + (info.ButtonID - 3); + + if (index >= 0 && index < m_List.Count) + { + PropertyInfo prop = m_List[index] as PropertyInfo; + + if (prop == null) + return; + + CPA attr = GetCPA(prop); + + if ((prop.GetType().IsValueType && !prop.CanWrite) || attr == null || from.AccessLevel < attr.WriteLevel || attr.ReadOnly) + return; + + Type type = prop.PropertyType; + + if (IsType(type, typeofMobile) || IsType(type, typeofItem)) + { + from.SendGump(new SetObjectGump(prop, from, m_Object, m_Stack, type, m_Page, m_List)); + } + else if (IsType(type, typeofType)) + { + from.Target = new SetObjectTarget(prop, from, m_Object, m_Stack, type, m_Page, m_List); + } + else if (IsType(type, typeofPoint3D)) + { + from.SendGump(new SetPoint3DGump(prop, from, m_Object, m_Stack, m_Page, m_List)); + } + else if (IsType(type, typeofPoint2D)) + { + from.SendGump(new SetPoint2DGump(prop, from, m_Object, m_Stack, m_Page, m_List)); + } + else if (IsType(type, typeofTimeSpan)) + { + from.SendGump(new SetTimeSpanGump(prop, from, m_Object, m_Stack, m_Page, m_List)); + } + else if (IsCustomEnum(type)) + { + from.SendGump(new SetCustomEnumGump(prop, from, m_Object, m_Stack, m_Page, m_List, + GetCustomEnumNames(type))); + } + else if (IsType(type, typeofEnum)) + { + from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, + Enum.GetNames(type), GetObjects(Enum.GetValues(type)))); + } + else if (IsType(type, typeofBool)) + { + from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, m_BoolNames, + m_BoolValues)); + } + else if (IsType(type, typeofString) || IsType(type, typeofReal) || IsType(type, typeofNumeric) || + IsType(type, typeofText)) + { + from.SendGump(new SetGump(prop, from, m_Object, m_Stack, m_Page, m_List)); + } + else if (IsType(type, typeofPoison)) + { + from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, + m_PoisonValues)); + } + else if (IsType(type, typeofMap)) + { + from.SendGump(new SetListOptionGump(prop, from, m_Object, m_Stack, m_Page, m_List, + Map.GetMapNames(), Map.GetMapValues().ToArray())); + } + else if (IsType(type, typeofSkills) && m_Object is Mobile mobile) + { + from.SendGump(new PropertiesGump(from, mobile, m_Stack, m_List, m_Page)); + from.SendGump(new SkillsGump(from, mobile)); + } + else if (HasAttribute(type, typeofPropertyObject, true)) + { + object obj = prop.GetValue(m_Object, null); + + if (obj != null) + from.SendGump(new PropertiesGump(from, obj, m_Stack, new StackEntry(m_Object, prop))); + else + from.SendGump(new PropertiesGump(from, m_Object, m_Stack, m_List, m_Page)); + } + } + + break; + } } } @@ -435,10 +436,10 @@ namespace Server.Gumps object[] attrs = type.GetCustomAttributes(typeofCustomEnum, false); if (attrs.Length == 0) - return new string[0]; + return Array.Empty(); if (!(attrs[0] is CustomEnumAttribute ce)) - return new string[0]; + return Array.Empty(); return ce.Names; } @@ -561,7 +562,7 @@ namespace Server.Gumps } if (type != null && !groups.ContainsKey(type)) - groups[type] = new List{ prop }; + groups[type] = new List { prop }; else groups[type].Add(prop); } @@ -650,7 +651,7 @@ namespace Server.Gumps private class GroupComparer : IComparer>> { - private Type m_Start; + private readonly Type m_Start; public GroupComparer(Type start) => m_Start = start; diff --git a/Projects/Scripts/Gumps/Props/SetBodyGump.cs b/Projects/Scripts/Gumps/Props/SetBodyGump.cs index 6669f04d1..08dd08cf0 100644 --- a/Projects/Scripts/Gumps/Props/SetBodyGump.cs +++ b/Projects/Scripts/Gumps/Props/SetBodyGump.cs @@ -13,15 +13,15 @@ namespace Server.Gumps private const int TextColor32 = 0xFFFFFF; private static List m_Monster, m_Animal, m_Sea, m_Human; - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private List m_OurList; - private int m_OurPage; - private ModelBodyType m_OurType; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly List m_OurList; + private readonly int m_OurPage; + private readonly ModelBodyType m_OurType; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public SetBodyGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list, int ourPage = 0, List ourList = null, ModelBodyType ourType = ModelBodyType.Invalid) @@ -236,7 +236,7 @@ namespace Server.Gumps public class InternalEntry : IComparable { - private static string[] m_GroupNames = + private static readonly string[] m_GroupNames = { "ogres_", "ettins_", "walking_dead_", "gargoyles_", "orcs_", "flails_", "daemons_", "arachnids_", @@ -273,13 +273,13 @@ namespace Server.Gumps DisplayName = DisplayName.Replace('_', ' '); } - public int Body{ get; } + public int Body { get; } - public int ItemID{ get; } + public int ItemID { get; } - public string Name{ get; } + public string Name { get; } - public string DisplayName{ get; } + public string DisplayName { get; } public int CompareTo(InternalEntry comp) { diff --git a/Projects/Scripts/Gumps/Props/SetCustomEnumGump.cs b/Projects/Scripts/Gumps/Props/SetCustomEnumGump.cs index 9ce0eec48..db3cb4d14 100644 --- a/Projects/Scripts/Gumps/Props/SetCustomEnumGump.cs +++ b/Projects/Scripts/Gumps/Props/SetCustomEnumGump.cs @@ -8,7 +8,7 @@ namespace Server.Gumps { public class SetCustomEnumGump : SetListOptionGump { - private string[] m_Names; + private readonly string[] m_Names; public SetCustomEnumGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int propspage, List list, string[] names) : base(prop, mobile, o, stack, propspage, list, names, null) => diff --git a/Projects/Scripts/Gumps/Props/SetGump.cs b/Projects/Scripts/Gumps/Props/SetGump.cs index 1f66ed375..ba2f95b0f 100644 --- a/Projects/Scripts/Gumps/Props/SetGump.cs +++ b/Projects/Scripts/Gumps/Props/SetGump.cs @@ -49,12 +49,12 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public SetGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list) : base( GumpOffsetX, GumpOffsetY) @@ -163,65 +163,65 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: - { - TextRelay text = info.GetTextEntry(0); - - if (text != null) { - try + TextRelay text = info.GetTextEntry(0); + + if (text != null) { - toSet = PropertiesGump.GetObjectFromString(m_Property.PropertyType, text.Text); - shouldSet = true; + try + { + toSet = PropertiesGump.GetObjectFromString(m_Property.PropertyType, text.Text); + shouldSet = true; + } + catch + { + toSet = null; + shouldSet = false; + m_Mobile.SendMessage("Bad format"); + } } - catch + else { toSet = null; shouldSet = false; - m_Mobile.SendMessage("Bad format"); } + + break; } - else + case 2: // Null + { + toSet = null; + shouldSet = true; + + break; + } + case 3: // Hue Picker { toSet = null; shouldSet = false; + shouldSend = false; + + m_Mobile.SendHuePicker(new InternalPicker(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List)); + + break; } - - break; - } - case 2: // Null - { - toSet = null; - shouldSet = true; - - break; - } - case 3: // Hue Picker - { - toSet = null; - shouldSet = false; - shouldSend = false; - - m_Mobile.SendHuePicker(new InternalPicker(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List)); - - break; - } case 4: // Body Picker - { - toSet = null; - shouldSet = false; - shouldSend = false; + { + toSet = null; + shouldSet = false; + shouldSend = false; - m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List)); + m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List)); - break; - } + break; + } default: - { - toSet = null; - shouldSet = false; + { + toSet = null; + shouldSet = false; - break; - } + break; + } } if (shouldSet) @@ -243,12 +243,12 @@ namespace Server.Gumps private class InternalPicker : HuePicker { - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public InternalPicker(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list) : base(((IHued)o).HuedItemID) diff --git a/Projects/Scripts/Gumps/Props/SetListOptionGump.cs b/Projects/Scripts/Gumps/Props/SetListOptionGump.cs index 37c274288..898108055 100644 --- a/Projects/Scripts/Gumps/Props/SetListOptionGump.cs +++ b/Projects/Scripts/Gumps/Props/SetListOptionGump.cs @@ -48,7 +48,8 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; - private static bool PrevLabel = OldStyle, NextLabel = OldStyle; + private static readonly bool PrevLabel = OldStyle; + private static readonly bool NextLabel = OldStyle; private static readonly int PrevLabelOffsetX = PrevWidth + 1; private static readonly int PrevLabelOffsetY = 0; @@ -62,7 +63,7 @@ namespace Server.Gumps protected PropertyInfo m_Property; protected Stack m_Stack; - private object[] m_Values; + private readonly object[] m_Values; public SetListOptionGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int propspage, List list, string[] names, object[] values) : base(GumpOffsetX, GumpOffsetY) @@ -96,7 +97,6 @@ namespace Server.Gumps AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID); - int x = BorderSize + OffsetSize; int y = BorderSize + OffsetSize; @@ -134,7 +134,6 @@ namespace Server.Gumps AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next"); } - AddRect(0, prop.Name, 0); for (int i = 0; i < count; ++i) diff --git a/Projects/Scripts/Gumps/Props/SetObjectGump.cs b/Projects/Scripts/Gumps/Props/SetObjectGump.cs index 30d79a680..348c20726 100644 --- a/Projects/Scripts/Gumps/Props/SetObjectGump.cs +++ b/Projects/Scripts/Gumps/Props/SetObjectGump.cs @@ -51,13 +51,13 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; - private Type m_Type; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; + private readonly Type m_Type; public SetObjectGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, List list) : base(GumpOffsetX, GumpOffsetY) @@ -145,53 +145,53 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: // closed - { - m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); - shouldSend = false; - break; - } + { + m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page)); + shouldSend = false; + break; + } case 1: // Change by Target - { - m_Mobile.Target = new SetObjectTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List); - shouldSend = false; - break; - } + { + m_Mobile.Target = new SetObjectTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List); + shouldSend = false; + break; + } case 2: // Change by Serial - { - shouldSend = false; + { + shouldSend = false; - m_Mobile.SendMessage("Enter the serial you wish to find:"); - m_Mobile.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List); + m_Mobile.SendMessage("Enter the serial you wish to find:"); + m_Mobile.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List); - break; - } + break; + } case 3: // Nullify - { - try { - CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "(null)"); - m_Property.SetValue(m_Object, null, null); - PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); + try + { + CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, "(null)"); + m_Property.SetValue(m_Object, null, null); + PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack); + } + catch + { + m_Mobile.SendMessage("An exception was caught. The property may not have changed."); + } + break; } - catch - { - m_Mobile.SendMessage("An exception was caught. The property may not have changed."); - } - break; - } case 4: // View Properties - { - object obj = m_Property.GetValue(m_Object, null); + { + object obj = m_Property.GetValue(m_Object, null); - if (obj == null) - m_Mobile.SendMessage("The property is null and so you cannot view its properties."); - else if (!BaseCommand.IsAccessible(m_Mobile, obj)) - m_Mobile.SendMessage("You may not view their properties."); - else - viewProps = obj; + if (obj == null) + m_Mobile.SendMessage("The property is null and so you cannot view its properties."); + else if (!BaseCommand.IsAccessible(m_Mobile, obj)) + m_Mobile.SendMessage("You may not view their properties."); + else + viewProps = obj; - break; - } + break; + } } if (shouldSend) @@ -203,13 +203,13 @@ namespace Server.Gumps private class InternalPrompt : Prompt { - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; - private Type m_Type; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; + private readonly Type m_Type; public InternalPrompt(PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, List list) diff --git a/Projects/Scripts/Gumps/Props/SetObjectTarget.cs b/Projects/Scripts/Gumps/Props/SetObjectTarget.cs index 4cc256154..568582130 100644 --- a/Projects/Scripts/Gumps/Props/SetObjectTarget.cs +++ b/Projects/Scripts/Gumps/Props/SetObjectTarget.cs @@ -9,13 +9,13 @@ namespace Server.Gumps { public class SetObjectTarget : Target { - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; - private Type m_Type; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; + private readonly Type m_Type; public SetObjectTarget(PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, List list) : base(-1, false, TargetFlags.None) diff --git a/Projects/Scripts/Gumps/Props/SetPoint2DGump.cs b/Projects/Scripts/Gumps/Props/SetPoint2DGump.cs index 21f466303..7c650f031 100644 --- a/Projects/Scripts/Gumps/Props/SetPoint2DGump.cs +++ b/Projects/Scripts/Gumps/Props/SetPoint2DGump.cs @@ -50,12 +50,12 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public SetPoint2DGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list) : base(GumpOffsetX, GumpOffsetY) @@ -133,42 +133,42 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Current location - { - toSet = new Point2D(m_Mobile.Location); - shouldSet = true; - shouldSend = true; + { + toSet = new Point2D(m_Mobile.Location); + shouldSet = true; + shouldSend = true; - break; - } + break; + } case 2: // Pick location - { - m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List); + { + m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List); - toSet = Point2D.Zero; - shouldSet = false; - shouldSend = false; + toSet = Point2D.Zero; + shouldSet = false; + shouldSend = false; - break; - } + break; + } case 3: // Use values - { - TextRelay x = info.GetTextEntry(0); - TextRelay y = info.GetTextEntry(1); + { + TextRelay x = info.GetTextEntry(0); + TextRelay y = info.GetTextEntry(1); - toSet = new Point2D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text)); - shouldSet = true; - shouldSend = true; + toSet = new Point2D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text)); + shouldSet = true; + shouldSend = true; - break; - } + break; + } default: - { - toSet = Point2D.Zero; - shouldSet = false; - shouldSend = true; + { + toSet = Point2D.Zero; + shouldSet = false; + shouldSend = true; - break; - } + break; + } } if (shouldSet) @@ -189,12 +189,12 @@ namespace Server.Gumps private class InternalTarget : Target { - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list) : base(-1, true, TargetFlags.None) diff --git a/Projects/Scripts/Gumps/Props/SetPoint3DGump.cs b/Projects/Scripts/Gumps/Props/SetPoint3DGump.cs index 1183bf047..176793a96 100644 --- a/Projects/Scripts/Gumps/Props/SetPoint3DGump.cs +++ b/Projects/Scripts/Gumps/Props/SetPoint3DGump.cs @@ -50,12 +50,12 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public SetPoint3DGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list) : base(GumpOffsetX, GumpOffsetY) @@ -138,44 +138,44 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Current location - { - toSet = m_Mobile.Location; - shouldSet = true; - shouldSend = true; + { + toSet = m_Mobile.Location; + shouldSet = true; + shouldSend = true; - break; - } + break; + } case 2: // Pick location - { - m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List); + { + m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List); - toSet = Point3D.Zero; - shouldSet = false; - shouldSend = false; + toSet = Point3D.Zero; + shouldSet = false; + shouldSend = false; - break; - } + break; + } case 3: // Use values - { - TextRelay x = info.GetTextEntry(0); - TextRelay y = info.GetTextEntry(1); - TextRelay z = info.GetTextEntry(2); + { + TextRelay x = info.GetTextEntry(0); + TextRelay y = info.GetTextEntry(1); + TextRelay z = info.GetTextEntry(2); - toSet = new Point3D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text), - z == null ? 0 : Utility.ToInt32(z.Text)); - shouldSet = true; - shouldSend = true; + toSet = new Point3D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text), + z == null ? 0 : Utility.ToInt32(z.Text)); + shouldSet = true; + shouldSend = true; - break; - } + break; + } default: - { - toSet = Point3D.Zero; - shouldSet = false; - shouldSend = true; + { + toSet = Point3D.Zero; + shouldSet = false; + shouldSend = true; - break; - } + break; + } } if (shouldSet) @@ -196,12 +196,12 @@ namespace Server.Gumps private class InternalTarget : Target { - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public InternalTarget(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list) : base(-1, true, TargetFlags.None) diff --git a/Projects/Scripts/Gumps/Props/SetTimeSpanGump.cs b/Projects/Scripts/Gumps/Props/SetTimeSpanGump.cs index 48e819126..90beb48f1 100644 --- a/Projects/Scripts/Gumps/Props/SetTimeSpanGump.cs +++ b/Projects/Scripts/Gumps/Props/SetTimeSpanGump.cs @@ -49,12 +49,12 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private List m_List; - private Mobile m_Mobile; - private object m_Object; - private int m_Page; - private PropertyInfo m_Property; - private Stack m_Stack; + private readonly List m_List; + private readonly Mobile m_Mobile; + private readonly object m_Object; + private readonly int m_Page; + private readonly PropertyInfo m_Property; + private readonly Stack m_Stack; public SetTimeSpanGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, List list) : base(GumpOffsetX, GumpOffsetY) @@ -115,99 +115,99 @@ namespace Server.Gumps switch (info.ButtonID) { case 1: // Zero - { - toSet = TimeSpan.Zero; - shouldSet = true; - shouldSend = true; - - break; - } - case 2: // From H:M:S - { - bool successfulParse = false; - if (h != null && m != null && s != null) - successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet); - else + { toSet = TimeSpan.Zero; + shouldSet = true; + shouldSend = true; - shouldSet = shouldSend = successfulParse; + break; + } + case 2: // From H:M:S + { + bool successfulParse = false; + if (h != null && m != null && s != null) + successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet); + else + toSet = TimeSpan.Zero; - break; - } + shouldSet = shouldSend = successfulParse; + + break; + } case 3: // From H - { - if (h != null) - try - { - toSet = TimeSpan.FromHours(Utility.ToDouble(h.Text)); - shouldSet = true; - shouldSend = true; + { + if (h != null) + try + { + toSet = TimeSpan.FromHours(Utility.ToDouble(h.Text)); + shouldSet = true; + shouldSend = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - toSet = TimeSpan.Zero; - shouldSet = false; - shouldSend = false; + toSet = TimeSpan.Zero; + shouldSet = false; + shouldSend = false; - break; - } + break; + } case 4: // From M - { - if (m != null) - try - { - toSet = TimeSpan.FromMinutes(Utility.ToDouble(m.Text)); - shouldSet = true; - shouldSend = true; + { + if (m != null) + try + { + toSet = TimeSpan.FromMinutes(Utility.ToDouble(m.Text)); + shouldSet = true; + shouldSend = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - toSet = TimeSpan.Zero; - shouldSet = false; - shouldSend = false; + toSet = TimeSpan.Zero; + shouldSet = false; + shouldSend = false; - break; - } + break; + } case 5: // From S - { - if (s != null) - try - { - toSet = TimeSpan.FromSeconds(Utility.ToDouble(s.Text)); - shouldSet = true; - shouldSend = true; + { + if (s != null) + try + { + toSet = TimeSpan.FromSeconds(Utility.ToDouble(s.Text)); + shouldSet = true; + shouldSend = true; - break; - } - catch - { - // ignored - } + break; + } + catch + { + // ignored + } - toSet = TimeSpan.Zero; - shouldSet = false; - shouldSend = false; + toSet = TimeSpan.Zero; + shouldSet = false; + shouldSend = false; - break; - } + break; + } default: - { - toSet = TimeSpan.Zero; - shouldSet = false; - shouldSend = true; + { + toSet = TimeSpan.Zero; + shouldSet = false; + shouldSend = true; - break; - } + break; + } } if (shouldSet) diff --git a/Projects/Scripts/Gumps/ReclaimVendorGump.cs b/Projects/Scripts/Gumps/ReclaimVendorGump.cs index 7f1a0ce6e..6239d4a8b 100644 --- a/Projects/Scripts/Gumps/ReclaimVendorGump.cs +++ b/Projects/Scripts/Gumps/ReclaimVendorGump.cs @@ -7,8 +7,8 @@ namespace Server.Gumps { public class ReclaimVendorGump : Gump { - private BaseHouse m_House; - private List m_Vendors; + private readonly BaseHouse m_House; + private readonly List m_Vendors; public ReclaimVendorGump(BaseHouse house) : base(50, 50) { diff --git a/Projects/Scripts/Gumps/ReportMurderer.cs b/Projects/Scripts/Gumps/ReportMurderer.cs index 6eec239b0..85790bcc7 100644 --- a/Projects/Scripts/Gumps/ReportMurderer.cs +++ b/Projects/Scripts/Gumps/ReportMurderer.cs @@ -9,7 +9,7 @@ namespace Server.Gumps public class ReportMurdererGump : Gump { private int m_Idx; - private List m_Killers; + private readonly List m_Killers; private Mobile m_Victum; public static void Initialize() @@ -20,11 +20,11 @@ namespace Server.Gumps public static void EventSink_PlayerDeath(Mobile m) { List killers = new List(); - List toGive = new List(); + List toGive = new List(); - foreach ( AggressorInfo ai in m.Aggressors ) + foreach (AggressorInfo ai in m.Aggressors) { - if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported ) + if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported) if (!Core.SE || !((PlayerMobile)m).RecentlyReported.Contains(ai.Attacker)) { killers.Add(ai.Attacker); @@ -32,17 +32,17 @@ namespace Server.Gumps ai.CanReportMurder = false; } - if ( ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) ) - toGive.Add( ai.Attacker ); + if (ai.Attacker.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Attacker)) + toGive.Add(ai.Attacker); } - foreach ( AggressorInfo ai in m.Aggressed ) - if ( ai.Defender.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) ) - toGive.Add( ai.Defender ); + foreach (AggressorInfo ai in m.Aggressed) + if (ai.Defender.Player && DateTime.UtcNow - ai.LastCombatTime < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Defender)) + toGive.Add(ai.Defender); - foreach ( Mobile g in toGive ) + foreach (Mobile g in toGive) { - int n = Notoriety.Compute( g, m ); + int n = Notoriety.Compute(g, m); int ourKarma = g.Karma; bool innocent = n == Notoriety.Innocent; @@ -51,28 +51,28 @@ namespace Server.Gumps int fameAward = m.Fame / 200; int karmaAward = 0; - if ( innocent ) + if (innocent) karmaAward = ourKarma > -2500 ? -850 : -110 - m.Karma / 100; - else if ( criminal ) + else if (criminal) karmaAward = 50; - Titles.AwardFame( g, fameAward, false ); - Titles.AwardKarma( g, karmaAward, true ); + Titles.AwardFame(g, fameAward, false); + Titles.AwardKarma(g, karmaAward, true); } - if ( m is PlayerMobile mobile && mobile.NpcGuild == NpcGuild.ThievesGuild ) + if (m is PlayerMobile mobile && mobile.NpcGuild == NpcGuild.ThievesGuild) return; - if ( killers.Count > 0 ) - new GumpTimer( m, killers ).Start(); + if (killers.Count > 0) + new GumpTimer(m, killers).Start(); } private class GumpTimer : Timer { - private Mobile m_Victim; - private List m_Killers; + private readonly Mobile m_Victim; + private readonly List m_Killers; - public GumpTimer( Mobile victim, List killers ) : base( TimeSpan.FromSeconds( 4.0 ) ) + public GumpTimer(Mobile victim, List killers) : base(TimeSpan.FromSeconds(4.0)) { m_Victim = victim; m_Killers = killers; @@ -80,11 +80,11 @@ namespace Server.Gumps protected override void OnTick() { - m_Victim.SendGump( new ReportMurdererGump( m_Victim, m_Killers ) ); + m_Victim.SendGump(new ReportMurdererGump(m_Victim, m_Killers)); } } - private ReportMurdererGump(Mobile victum, List killers, int idx = 0) : base( 0, 0 ) + private ReportMurdererGump(Mobile victum, List killers, int idx = 0) : base(0, 0) { m_Killers = killers; m_Victum = victum; @@ -94,80 +94,80 @@ namespace Server.Gumps private void BuildGump() { - AddBackground( 265, 205, 320, 290, 5054 ); + AddBackground(265, 205, 320, 290, 5054); Closable = false; Resizable = false; - AddPage( 0 ); + AddPage(0); - AddImageTiled( 225, 175, 50, 45, 0xCE ); //Top left corner - AddImageTiled( 267, 175, 315, 44, 0xC9 ); //Top bar - AddImageTiled( 582, 175, 43, 45, 0xCF ); //Top right corner - AddImageTiled( 225, 219, 44, 270, 0xCA ); //Left side - AddImageTiled( 582, 219, 44, 270, 0xCB ); //Right side - AddImageTiled( 225, 489, 44, 43, 0xCC ); //Lower left corner - AddImageTiled( 267, 489, 315, 43, 0xE9 ); //Lower Bar - AddImageTiled( 582, 489, 43, 43, 0xCD ); //Lower right corner + AddImageTiled(225, 175, 50, 45, 0xCE); // Top left corner + AddImageTiled(267, 175, 315, 44, 0xC9); // Top bar + AddImageTiled(582, 175, 43, 45, 0xCF); // Top right corner + AddImageTiled(225, 219, 44, 270, 0xCA); // Left side + AddImageTiled(582, 219, 44, 270, 0xCB); // Right side + AddImageTiled(225, 489, 44, 43, 0xCC); // Lower left corner + AddImageTiled(267, 489, 315, 43, 0xE9); // Lower Bar + AddImageTiled(582, 489, 43, 43, 0xCD); // Lower right corner - AddPage( 1 ); + AddPage(1); - AddHtml( 260, 234, 300, 140, m_Killers[m_Idx].Name ); // Player's Name - AddHtmlLocalized( 260, 254, 300, 140, 1049066 ); // Would you like to report... + AddHtml(260, 234, 300, 140, m_Killers[m_Idx].Name); // Player's Name + AddHtmlLocalized(260, 254, 300, 140, 1049066); // Would you like to report... - AddButton( 260, 300, 0xFA5, 0xFA7, 1 ); - AddHtmlLocalized( 300, 300, 300, 50, 1046362 ); // Yes + AddButton(260, 300, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(300, 300, 300, 50, 1046362); // Yes - AddButton( 360, 300, 0xFA5, 0xFA7, 2 ); - AddHtmlLocalized( 400, 300, 300, 50, 1046363 ); // No + AddButton(360, 300, 0xFA5, 0xFA7, 2); + AddHtmlLocalized(400, 300, 300, 50, 1046363); // No } - public static void ReportedListExpiry_Callback( PlayerMobile from, Mobile killer ) + public static void ReportedListExpiry_Callback(PlayerMobile from, Mobile killer) { if (from.RecentlyReported.Contains(killer)) from.RecentlyReported.Remove(killer); } - public override void OnResponse( NetState state, RelayInfo info ) + public override void OnResponse(NetState state, RelayInfo info) { PlayerMobile from = (PlayerMobile)state.Mobile; - switch ( info.ButtonID ) + switch (info.ButtonID) { case 1: - { - Mobile killer = m_Killers[m_Idx]; - if (killer?.Deleted == false) { - killer.Kills++; - killer.ShortTermMurders++; - - if (Core.SE) + Mobile killer = m_Killers[m_Idx]; + if (killer?.Deleted == false) { - from.RecentlyReported.Add(killer); - Timer.DelayCall(TimeSpan.FromMinutes(10), () => ReportedListExpiry_Callback(from, killer)); - } + killer.Kills++; + killer.ShortTermMurders++; - if (killer is PlayerMobile pk) - { - pk.ResetKillTime(); - pk.SendLocalizedMessage(1049067);//You have been reported for murder! + if (Core.SE) + { + from.RecentlyReported.Add(killer); + Timer.DelayCall(TimeSpan.FromMinutes(10), () => ReportedListExpiry_Callback(from, killer)); + } - if (pk.Kills == 5) - pk.SendLocalizedMessage(502134);//You are now known as a murderer! - else if (SkillHandlers.Stealing.SuspendOnMurder && pk.Kills == 1 && pk.NpcGuild == NpcGuild.ThievesGuild) pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild. + if (killer is PlayerMobile pk) + { + pk.ResetKillTime(); + pk.SendLocalizedMessage(1049067);// You have been reported for murder! + + if (pk.Kills == 5) + pk.SendLocalizedMessage(502134);// You are now known as a murderer! + else if (SkillHandlers.Stealing.SuspendOnMurder && pk.Kills == 1 && pk.NpcGuild == NpcGuild.ThievesGuild) pk.SendLocalizedMessage(501562); // You have been suspended by the Thieves Guild. + } } + break; } - break; - } case 2: - { - break; - } + { + break; + } } m_Idx++; - if ( m_Idx < m_Killers.Count ) - from.SendGump( new ReportMurdererGump( from, m_Killers, m_Idx ) ); + if (m_Idx < m_Killers.Count) + from.SendGump(new ReportMurdererGump(from, m_Killers, m_Idx)); } } } diff --git a/Projects/Scripts/Gumps/ResurrectGump.cs b/Projects/Scripts/Gumps/ResurrectGump.cs index 0a13fc88d..451be294e 100644 --- a/Projects/Scripts/Gumps/ResurrectGump.cs +++ b/Projects/Scripts/Gumps/ResurrectGump.cs @@ -15,10 +15,10 @@ namespace Server.Gumps public class ResurrectGump : Gump { - private Mobile m_Healer; - private int m_Price; - private bool m_FromSacrifice; - private double m_HitsScalar; + private readonly Mobile m_Healer; + private readonly int m_Price; + private readonly bool m_FromSacrifice; + private readonly double m_HitsScalar; public ResurrectGump(Mobile owner, double hitsScalar) : this(owner, owner, ResurrectMessage.Generic, false, hitsScalar) @@ -36,87 +36,88 @@ namespace Server.Gumps public ResurrectGump(Mobile owner, Mobile healer, ResurrectMessage msg = ResurrectMessage.Generic, bool fromSacrifice = false, double hitsScalar = 0.0) - : base( 100, 0 ) + : base(100, 0) { m_Healer = healer; m_FromSacrifice = fromSacrifice; m_HitsScalar = hitsScalar; - AddPage( 0 ); + AddPage(0); - AddBackground( 0, 0, 400, 350, 2600 ); + AddBackground(0, 0, 400, 350, 2600); - AddHtmlLocalized( 0, 20, 400, 35, 1011022 ); //
Resurrection
+ AddHtmlLocalized(0, 20, 400, 35, 1011022); //
Resurrection
- AddHtmlLocalized( 50, 55, 300, 140, 1011023 + (int)msg, true, true ); /* It is possible for you to be resurrected here by this healer. Do you wish to try?
- * CONTINUE - You chose to try to come back to life now.
- * CANCEL - You prefer to remain a ghost for now. - */ + /* It is possible for you to be resurrected here by this healer. Do you wish to try?
+ * CONTINUE - You chose to try to come back to life now.
+ * CANCEL - You prefer to remain a ghost for now. + */ + AddHtmlLocalized(50, 55, 300, 140, 1011023 + (int)msg, true, true); - AddButton( 200, 227, 4005, 4007, 0); - AddHtmlLocalized( 235, 230, 110, 35, 1011012 ); // CANCEL + AddButton(200, 227, 4005, 4007, 0); + AddHtmlLocalized(235, 230, 110, 35, 1011012); // CANCEL - AddButton( 65, 227, 4005, 4007, 1); - AddHtmlLocalized( 100, 230, 110, 35, 1011011 ); // CONTINUE + AddButton(65, 227, 4005, 4007, 1); + AddHtmlLocalized(100, 230, 110, 35, 1011011); // CONTINUE } - public ResurrectGump( Mobile owner, Mobile healer, int price ) - : base( 150, 50 ) + public ResurrectGump(Mobile owner, Mobile healer, int price) + : base(150, 50) { m_Healer = healer; m_Price = price; Closable = false; - AddPage( 0 ); + AddPage(0); - AddImage( 0, 0, 3600 ); + AddImage(0, 0, 3600); - AddImageTiled( 0, 14, 15, 200, 3603 ); - AddImageTiled( 380, 14, 14, 200, 3605 ); + AddImageTiled(0, 14, 15, 200, 3603); + AddImageTiled(380, 14, 14, 200, 3605); - AddImage( 0, 201, 3606 ); + AddImage(0, 201, 3606); - AddImageTiled( 15, 201, 370, 16, 3607 ); - AddImageTiled( 15, 0, 370, 16, 3601 ); + AddImageTiled(15, 201, 370, 16, 3607); + AddImageTiled(15, 0, 370, 16, 3601); - AddImage( 380, 0, 3602 ); + AddImage(380, 0, 3602); - AddImage( 380, 201, 3608 ); + AddImage(380, 201, 3608); - AddImageTiled( 15, 15, 365, 190, 2624 ); + AddImageTiled(15, 15, 365, 190, 2624); - AddRadio( 30, 140, 9727, 9730, true, 1 ); - AddHtmlLocalized( 65, 145, 300, 25, 1060015, 0x7FFF ); // Grudgingly pay the money + AddRadio(30, 140, 9727, 9730, true, 1); + AddHtmlLocalized(65, 145, 300, 25, 1060015, 0x7FFF); // Grudgingly pay the money - AddRadio( 30, 175, 9727, 9730, false, 0 ); - AddHtmlLocalized( 65, 178, 300, 25, 1060016, 0x7FFF ); // I'd rather stay dead, you scoundrel!!! + AddRadio(30, 175, 9727, 9730, false, 0); + AddHtmlLocalized(65, 178, 300, 25, 1060016, 0x7FFF); // I'd rather stay dead, you scoundrel!!! - AddHtmlLocalized( 30, 20, 360, 35, 1060017, 0x7FFF ); // Wishing to rejoin the living, are you? I can restore your body... for a price of course... + AddHtmlLocalized(30, 20, 360, 35, 1060017, 0x7FFF); // Wishing to rejoin the living, are you? I can restore your body... for a price of course... - AddHtmlLocalized( 30, 105, 345, 40, 1060018, 0x5B2D ); // Do you accept the fee, which will be withdrawn from your bank? + AddHtmlLocalized(30, 105, 345, 40, 1060018, 0x5B2D); // Do you accept the fee, which will be withdrawn from your bank? - AddImage( 65, 72, 5605 ); + AddImage(65, 72, 5605); - AddImageTiled( 80, 90, 200, 1, 9107 ); - AddImageTiled( 95, 92, 200, 1, 9157 ); + AddImageTiled(80, 90, 200, 1, 9107); + AddImageTiled(95, 92, 200, 1, 9157); - AddLabel( 90, 70, 1645, price.ToString() ); - AddHtmlLocalized( 140, 70, 100, 25, 1023823, 0x7FFF ); // gold coins + AddLabel(90, 70, 1645, price.ToString()); + AddHtmlLocalized(140, 70, 100, 25, 1023823, 0x7FFF); // gold coins - AddButton( 290, 175, 247, 248, 2 ); + AddButton(290, 175, 247, 248, 2); - AddImageTiled( 15, 14, 365, 1, 9107 ); - AddImageTiled( 380, 14, 1, 190, 9105 ); - AddImageTiled( 15, 205, 365, 1, 9107 ); - AddImageTiled( 15, 14, 1, 190, 9105 ); - AddImageTiled( 0, 0, 395, 1, 9157 ); - AddImageTiled( 394, 0, 1, 217, 9155 ); - AddImageTiled( 0, 216, 395, 1, 9157 ); - AddImageTiled( 0, 0, 1, 217, 9155 ); + AddImageTiled(15, 14, 365, 1, 9107); + AddImageTiled(380, 14, 1, 190, 9105); + AddImageTiled(15, 205, 365, 1, 9107); + AddImageTiled(15, 14, 1, 190, 9105); + AddImageTiled(0, 0, 395, 1, 9157); + AddImageTiled(394, 0, 1, 217, 9155); + AddImageTiled(0, 216, 395, 1, 9157); + AddImageTiled(0, 0, 1, 217, 9155); } - public override void OnResponse( NetState state, RelayInfo info ) + public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; @@ -125,42 +126,42 @@ namespace Server.Gumps if (info.ButtonID != 1 && info.ButtonID != 2) return; - if (from.Map?.CanFit( from.Location, 16, false, false ) != true) + if (from.Map?.CanFit(from.Location, 16, false, false) != true) { - from.SendLocalizedMessage( 502391 ); // Thou can not be resurrected there! + from.SendLocalizedMessage(502391); // Thou can not be resurrected there! return; } - if ( m_Price > 0 ) + if (m_Price > 0) { - if ( info.IsSwitched( 1 ) ) + if (info.IsSwitched(1)) { - if ( Banker.Withdraw( from, m_Price ) ) + if (Banker.Withdraw(from, m_Price)) { - from.SendLocalizedMessage( 1060398, m_Price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box. - from.SendLocalizedMessage( 1060022, Banker.GetBalance( from ).ToString() ); // You have ~1_AMOUNT~ gold in cash remaining in your bank box. + from.SendLocalizedMessage(1060398, m_Price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + from.SendLocalizedMessage(1060022, Banker.GetBalance(from).ToString()); // You have ~1_AMOUNT~ gold in cash remaining in your bank box. } else { - from.SendLocalizedMessage( 1060020 ); // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing. + from.SendLocalizedMessage(1060020); // Unfortunately, you do not have enough cash in your bank to cover the cost of the healing. return; } } else { - from.SendLocalizedMessage( 1060019 ); // You decide against paying the healer, and thus remain dead. + from.SendLocalizedMessage(1060019); // You decide against paying the healer, and thus remain dead. return; } } - from.PlaySound( 0x214 ); - from.FixedEffect( 0x376A, 10, 16 ); + from.PlaySound(0x214); + from.FixedEffect(0x376A, 10, 16); from.Resurrect(); - if ( m_Healer != null && from != m_Healer ) + if (m_Healer != null && from != m_Healer) { - VirtueLevel level = VirtueHelper.GetLevel( m_Healer, VirtueName.Compassion ); + VirtueLevel level = VirtueHelper.GetLevel(m_Healer, VirtueName.Compassion); from.Hits = level switch { @@ -171,56 +172,56 @@ namespace Server.Gumps }; } - if ( m_FromSacrifice && from is PlayerMobile mobile ) + if (m_FromSacrifice && from is PlayerMobile mobile) { mobile.AvailableResurrects -= 1; Container pack = mobile.Backpack; Container corpse = mobile.Corpse; - if ( pack != null && corpse != null ) + if (pack != null && corpse != null) { - List items = new List( corpse.Items ); + List items = new List(corpse.Items); - for ( int i = 0; i < items.Count; ++i ) + for (int i = 0; i < items.Count; ++i) { Item item = items[i]; - if ( item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable ) - pack.DropItem( item ); + if (item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable) + pack.DropItem(item); } } } - if ( from.Fame > 0 ) + if (from.Fame > 0) { int amount = from.Fame / 10; - Misc.Titles.AwardFame( from, -amount, true ); + Misc.Titles.AwardFame(from, -amount, true); } - if ( !Core.AOS && from.ShortTermMurders >= 5 ) + if (!Core.AOS && from.ShortTermMurders >= 5) { double loss = (100.0 - (4.0 + from.ShortTermMurders / 5.0)) / 100.0; // 5 to 15% loss - if ( loss < 0.85 ) + if (loss < 0.85) loss = 0.85; - else if ( loss > 0.95 ) + else if (loss > 0.95) loss = 0.95; - if ( from.RawStr * loss > 10 ) + if (from.RawStr * loss > 10) from.RawStr = (int)(from.RawStr * loss); - if ( from.RawInt * loss > 10 ) + if (from.RawInt * loss > 10) from.RawInt = (int)(from.RawInt * loss); - if ( from.RawDex * loss > 10 ) + if (from.RawDex * loss > 10) from.RawDex = (int)(from.RawDex * loss); - for ( int s = 0; s < from.Skills.Length; s++ ) - if ( from.Skills[s].Base * loss > 35 ) + for (int s = 0; s < from.Skills.Length; s++) + if (from.Skills[s].Base * loss > 35) from.Skills[s].Base *= loss; } - if ( from.Alive && m_HitsScalar > 0 ) + if (from.Alive && m_HitsScalar > 0) from.Hits = (int)(from.HitsMax * m_HitsScalar); } } diff --git a/Projects/Scripts/Gumps/RewardGump.cs b/Projects/Scripts/Gumps/RewardGump.cs index 233e5567f..bb53683f1 100644 --- a/Projects/Scripts/Gumps/RewardGump.cs +++ b/Projects/Scripts/Gumps/RewardGump.cs @@ -9,11 +9,11 @@ namespace Server.Gumps public interface IRewardEntry { - int Price{ get; } - int ItemID{ get; } - int Hue{ get; } - int Tooltip{ get; } - TextDefinition Description{ get; } + int Price { get; } + int ItemID { get; } + int Hue { get; } + int Tooltip { get; } + TextDefinition Description { get; } } public delegate void RewardPickedHandler(Mobile from, int index); @@ -100,13 +100,13 @@ namespace Server.Gumps } } - public TextDefinition Title{ get; } + public TextDefinition Title { get; } - public IRewardEntry[] Rewards{ get; } + public IRewardEntry[] Rewards { get; } - public int Points{ get; } + public int Points { get; } - public RewardPickedHandler OnPicked{ get; } + public RewardPickedHandler OnPicked { get; } public override void OnResponse(NetState sender, RelayInfo info) { @@ -129,8 +129,8 @@ namespace Server.Gumps public class RewardConfirmGump : Gump { - private int m_Index; - private RewardGump m_Parent; + private readonly int m_Index; + private readonly RewardGump m_Parent; public RewardConfirmGump(RewardGump parent, int index, IRewardEntry entry) : base(120, 50) diff --git a/Projects/Scripts/Gumps/RunebookGump.cs b/Projects/Scripts/Gumps/RunebookGump.cs index 845ed5628..1899a0a71 100644 --- a/Projects/Scripts/Gumps/RunebookGump.cs +++ b/Projects/Scripts/Gumps/RunebookGump.cs @@ -32,7 +32,7 @@ namespace Server.Gumps } } - public Runebook Book{ get; } + public Runebook Book { get; } public int GetMapHue(Map map) { @@ -243,138 +243,22 @@ namespace Server.Gumps switch (type) { case 0: // Use charges - { - if (Book.CurCharges <= 0) { - from.CloseGump(); - from.SendGump(new RunebookGump(from, Book)); - - from.SendLocalizedMessage(502412); // There are no charges left on that item. - } - else - { - int xLong = 0, yLat = 0; - int xMins = 0, yMins = 0; - bool xEast = false, ySouth = false; - - if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, - ref ySouth)) + if (Book.CurCharges <= 0) { - string location = - $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; - from.SendMessage(location); - } - - Book.OnTravel(); - new RecallSpell(from, e, Book, Book).Cast(); - - Book.Openers.Remove(from); - } - - break; - } - case 1: // Drop rune - { - if (!Book.IsLockedDown || from.AccessLevel >= AccessLevel.GameMaster) - { - Book.DropRune(from, e, index); - - from.CloseGump(); - if (!Core.ML) + from.CloseGump(); from.SendGump(new RunebookGump(from, Book)); - } - else - { - Book.Openers.Remove(from); - from.SendLocalizedMessage(502413, null, - 0x35); // That cannot be done while the book is locked down. - } - - break; - } - case 2: // Set default - { - if (Book.CheckAccess(from)) - { - Book.Default = e; - - from.CloseGump(); - from.SendGump(new RunebookGump(from, Book)); - - from.SendLocalizedMessage(502417); // New default location set. - } - - break; - } - case 3: // Recall - { - if (HasSpell(from, 31)) - { - int xLong = 0, yLat = 0; - int xMins = 0, yMins = 0; - bool xEast = false, ySouth = false; - - if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, - ref ySouth)) - { - string location = - $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; - from.SendMessage(location); + from.SendLocalizedMessage(502412); // There are no charges left on that item. } - - Book.OnTravel(); - new RecallSpell(from, e).Cast(); - } - else - { - from.SendLocalizedMessage(500015); // You do not have that spell! - } - - Book.Openers.Remove(from); - - break; - } - case 4: // Gate - { - if (HasSpell(from, 51)) - { - int xLong = 0, yLat = 0; - int xMins = 0, yMins = 0; - bool xEast = false, ySouth = false; - - if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, - ref ySouth)) - { - string location = - $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; - from.SendMessage(location); - } - - Book.OnTravel(); - new GateTravelSpell(from, e).Cast(); - } - else - { - from.SendLocalizedMessage(500015); // You do not have that spell! - } - - Book.Openers.Remove(from); - - break; - } - case 5: // Sacred Journey - { - if (Core.AOS) - { - if (HasSpell(from, 209)) + else { int xLong = 0, yLat = 0; int xMins = 0, yMins = 0; bool xEast = false, ySouth = false; - if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, - ref xEast, ref ySouth)) + if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, + ref ySouth)) { string location = $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; @@ -382,18 +266,134 @@ namespace Server.Gumps } Book.OnTravel(); - new SacredJourneySpell(from, e).Cast(); + new RecallSpell(from, e, Book, Book).Cast(); + + Book.Openers.Remove(from); + } + + break; + } + case 1: // Drop rune + { + if (!Book.IsLockedDown || from.AccessLevel >= AccessLevel.GameMaster) + { + Book.DropRune(from, e, index); + + from.CloseGump(); + if (!Core.ML) + from.SendGump(new RunebookGump(from, Book)); + } + else + { + Book.Openers.Remove(from); + + from.SendLocalizedMessage(502413, null, + 0x35); // That cannot be done while the book is locked down. + } + + break; + } + case 2: // Set default + { + if (Book.CheckAccess(from)) + { + Book.Default = e; + + from.CloseGump(); + from.SendGump(new RunebookGump(from, Book)); + + from.SendLocalizedMessage(502417); // New default location set. + } + + break; + } + case 3: // Recall + { + if (HasSpell(from, 31)) + { + int xLong = 0, yLat = 0; + int xMins = 0, yMins = 0; + bool xEast = false, ySouth = false; + + if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, + ref ySouth)) + { + string location = + $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + from.SendMessage(location); + } + + Book.OnTravel(); + new RecallSpell(from, e).Cast(); } else { from.SendLocalizedMessage(500015); // You do not have that spell! } + + Book.Openers.Remove(from); + + break; } + case 4: // Gate + { + if (HasSpell(from, 51)) + { + int xLong = 0, yLat = 0; + int xMins = 0, yMins = 0; + bool xEast = false, ySouth = false; - Book.Openers.Remove(from); + if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, + ref ySouth)) + { + string location = + $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + from.SendMessage(location); + } - break; - } + Book.OnTravel(); + new GateTravelSpell(from, e).Cast(); + } + else + { + from.SendLocalizedMessage(500015); // You do not have that spell! + } + + Book.Openers.Remove(from); + + break; + } + case 5: // Sacred Journey + { + if (Core.AOS) + { + if (HasSpell(from, 209)) + { + int xLong = 0, yLat = 0; + int xMins = 0, yMins = 0; + bool xEast = false, ySouth = false; + + if (Sextant.Format(e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, + ref xEast, ref ySouth)) + { + string location = + $"{yLat}� {yMins}'{(ySouth ? "S" : "N")}, {xLong}� {xMins}'{(xEast ? "E" : "W")}"; + from.SendMessage(location); + } + + Book.OnTravel(); + new SacredJourneySpell(from, e).Cast(); + } + else + { + from.SendLocalizedMessage(500015); // You do not have that spell! + } + } + + Book.Openers.Remove(from); + + break; + } } } else @@ -405,7 +405,7 @@ namespace Server.Gumps private class InternalPrompt : Prompt { - private Runebook m_Book; + private readonly Runebook m_Book; public InternalPrompt(Runebook book) => m_Book = book; diff --git a/Projects/Scripts/Gumps/SetSecureLevelGump.cs b/Projects/Scripts/Gumps/SetSecureLevelGump.cs index 149491e73..1c05318ce 100644 --- a/Projects/Scripts/Gumps/SetSecureLevelGump.cs +++ b/Projects/Scripts/Gumps/SetSecureLevelGump.cs @@ -6,12 +6,12 @@ namespace Server.Gumps { public interface ISecurable { - SecureLevel Level{ get; set; } + SecureLevel Level { get; set; } } public class SetSecureLevelGump : Gump { - private ISecurable m_Info; + private readonly ISecurable m_Info; public SetSecureLevelGump(Mobile owner, ISecurable info, BaseHouse house) : base(50, 50) { @@ -45,8 +45,7 @@ namespace Server.Gumps Mobile houseOwner = house.Owner; if (Guild.NewGuildSystem && houseOwner?.Guild != null && - ((Guild)houseOwner.Guild).Leader == houseOwner - ) //Only the actual House owner AND guild master can set guild secures + ((Guild)houseOwner.Guild).Leader == houseOwner) // Only the actual House owner AND guild master can set guild secures { AddButton(10, 130, GetFirstID(SecureLevel.Guild), 4007, 5); AddHtmlLocalized(45, 130, 150, 20, 1063455, GetColor(SecureLevel.Guild)); // Guild Members diff --git a/Projects/Scripts/Gumps/SkillsGump.cs b/Projects/Scripts/Gumps/SkillsGump.cs index 6ef7dd730..d2433812a 100644 --- a/Projects/Scripts/Gumps/SkillsGump.cs +++ b/Projects/Scripts/Gumps/SkillsGump.cs @@ -49,11 +49,11 @@ namespace Server.Gumps private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize; private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; - private Mobile m_From; + private readonly Mobile m_From; - private SkillsGumpGroup m_Selected; - private Skill m_Skill; - private Mobile m_Target; + private readonly SkillsGumpGroup m_Selected; + private readonly Skill m_Skill; + private readonly Mobile m_Target; public EditSkillGump(Mobile from, Mobile target, Skill skill, SkillsGumpGroup selected) : base(GumpOffsetX, GumpOffsetY) @@ -190,11 +190,11 @@ namespace Server.Gumps private static readonly int IndentWidth = 12; - private Mobile m_From; + private readonly Mobile m_From; - private SkillsGumpGroup[] m_Groups; - private SkillsGumpGroup m_Selected; - private Mobile m_Target; + private readonly SkillsGumpGroup[] m_Groups; + private readonly SkillsGumpGroup m_Selected; + private readonly Mobile m_Target; public SkillsGump(Mobile from, Mobile target, SkillsGumpGroup selected = null) : base(GumpOffsetX, GumpOffsetY) { @@ -363,78 +363,78 @@ namespace Server.Gumps switch (type) { case 0: - { - if (index >= 0 && index < m_Groups.Length) { - SkillsGumpGroup newSelection = m_Groups[index]; - - if (m_Selected != newSelection) - m_From.SendGump(new SkillsGump(m_From, m_Target, newSelection)); - else - m_From.SendGump(new SkillsGump(m_From, m_Target)); - } - - break; - } - case 1: - { - if (m_Selected != null && index >= 0 && index < m_Selected.Skills.Length) - { - Skill sk = m_Target.Skills[m_Selected.Skills[index]]; - - if (sk != null) + if (index >= 0 && index < m_Groups.Length) { - if (m_From.AccessLevel >= AccessLevel.GameMaster) + SkillsGumpGroup newSelection = m_Groups[index]; + + if (m_Selected != newSelection) + m_From.SendGump(new SkillsGump(m_From, m_Target, newSelection)); + else + m_From.SendGump(new SkillsGump(m_From, m_Target)); + } + + break; + } + case 1: + { + if (m_Selected != null && index >= 0 && index < m_Selected.Skills.Length) + { + Skill sk = m_Target.Skills[m_Selected.Skills[index]]; + + if (sk != null) { - m_From.SendGump(new EditSkillGump(m_From, m_Target, sk, m_Selected)); + if (m_From.AccessLevel >= AccessLevel.GameMaster) + { + m_From.SendGump(new EditSkillGump(m_From, m_Target, sk, m_Selected)); + } + else + { + m_From.SendMessage("You may not change that."); + m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected)); + } } else { - m_From.SendMessage("You may not change that."); m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected)); } } - else - { - m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected)); - } - } - break; - } + break; + } case 2: - { - if (m_Selected != null && index >= 0 && index < m_Selected.Skills.Length) { - Skill sk = m_Target.Skills[m_Selected.Skills[index]]; - - if (sk != null) + if (m_Selected != null && index >= 0 && index < m_Selected.Skills.Length) { - if (m_From.AccessLevel >= AccessLevel.GameMaster) - switch (sk.Lock) - { - case SkillLock.Up: - sk.SetLockNoRelay(SkillLock.Down); - sk.Update(); - break; - case SkillLock.Down: - sk.SetLockNoRelay(SkillLock.Locked); - sk.Update(); - break; - case SkillLock.Locked: - sk.SetLockNoRelay(SkillLock.Up); - sk.Update(); - break; - } - else - m_From.SendMessage("You may not change that."); + Skill sk = m_Target.Skills[m_Selected.Skills[index]]; - m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected)); + if (sk != null) + { + if (m_From.AccessLevel >= AccessLevel.GameMaster) + switch (sk.Lock) + { + case SkillLock.Up: + sk.SetLockNoRelay(SkillLock.Down); + sk.Update(); + break; + case SkillLock.Down: + sk.SetLockNoRelay(SkillLock.Locked); + sk.Update(); + break; + case SkillLock.Locked: + sk.SetLockNoRelay(SkillLock.Up); + sk.Update(); + break; + } + else + m_From.SendMessage("You may not change that."); + + m_From.SendGump(new SkillsGump(m_From, m_Target, m_Selected)); + } } - } - break; - } + break; + } } } @@ -451,11 +451,11 @@ namespace Server.Gumps Array.Sort(Skills, new SkillNameComparer()); } - public string Name{ get; } + public string Name { get; } - public SkillName[] Skills{ get; } + public SkillName[] Skills { get; } - public static SkillsGumpGroup[] Groups{ get; } = + public static SkillsGumpGroup[] Groups { get; } = { new SkillsGumpGroup("Crafting", new[] { diff --git a/Projects/Scripts/Gumps/TithingGump.cs b/Projects/Scripts/Gumps/TithingGump.cs index 3b2786608..04a637cc9 100644 --- a/Projects/Scripts/Gumps/TithingGump.cs +++ b/Projects/Scripts/Gumps/TithingGump.cs @@ -5,7 +5,7 @@ namespace Server.Gumps { public class TithingGump : Gump { - private Mobile m_From; + private readonly Mobile m_From; private int m_Offer; public TithingGump(Mobile from, int offer) : base(160, 40) @@ -56,66 +56,66 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: - { - // You have decided to tithe no gold to the shrine. - m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193); - break; - } - case 1: - case 2: - case 3: - case 4: - { - var offer = info.ButtonID switch - { - 1 => (m_Offer - 100), - 2 => 0, - 3 => (m_Offer + 100), - 4 => m_From.TotalGold, - _ => 0 - }; - - m_From.SendGump(new TithingGump(m_From, offer)); - break; - } - case 5: - { - int totalGold = m_From.TotalGold; - - if (m_Offer > totalGold) - m_Offer = totalGold; - else if (m_Offer < 0) - m_Offer = 0; - - if (m_From.TithingPoints + m_Offer > 100000) // TODO: What's the maximum? - m_Offer = 100000 - m_From.TithingPoints; - - if (m_Offer <= 0) { // You have decided to tithe no gold to the shrine. m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193); break; } - - Container pack = m_From.Backpack; - - if (pack?.ConsumeTotal(typeof(Gold), m_Offer) == true) + case 1: + case 2: + case 3: + case 4: { - // You tithe gold to the shrine as a sign of devotion. - m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060195); - m_From.TithingPoints += m_Offer; + var offer = info.ButtonID switch + { + 1 => m_Offer - 100, + 2 => 0, + 3 => m_Offer + 100, + 4 => m_From.TotalGold, + _ => 0 + }; - m_From.PlaySound(0x243); - m_From.PlaySound(0x2E6); + m_From.SendGump(new TithingGump(m_From, offer)); + break; } - else + case 5: { - // You do not have enough gold to tithe that amount! - m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060194); - } + int totalGold = m_From.TotalGold; - break; - } + if (m_Offer > totalGold) + m_Offer = totalGold; + else if (m_Offer < 0) + m_Offer = 0; + + if (m_From.TithingPoints + m_Offer > 100000) // TODO: What's the maximum? + m_Offer = 100000 - m_From.TithingPoints; + + if (m_Offer <= 0) + { + // You have decided to tithe no gold to the shrine. + m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060193); + break; + } + + Container pack = m_From.Backpack; + + if (pack?.ConsumeTotal(typeof(Gold), m_Offer) == true) + { + // You tithe gold to the shrine as a sign of devotion. + m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060195); + m_From.TithingPoints += m_Offer; + + m_From.PlaySound(0x243); + m_From.PlaySound(0x2E6); + } + else + { + // You do not have enough gold to tithe that amount! + m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1060194); + } + + break; + } } } } diff --git a/Projects/Scripts/Gumps/ToTAdminGump.cs b/Projects/Scripts/Gumps/ToTAdminGump.cs index cb74d3bb1..8a740186e 100644 --- a/Projects/Scripts/Gumps/ToTAdminGump.cs +++ b/Projects/Scripts/Gumps/ToTAdminGump.cs @@ -6,30 +6,30 @@ namespace Server.Gumps { public class ToTAdminGump : Gump { - private static string[] m_ToTInfo = + private static readonly string[] m_ToTInfo = { - //Opening Message + // Opening Message "
Treasures of Tokuno Admin

" + "-Use the gems to switch eras
" + "-Drop era and Reward era can be changed seperately
" + "-Drop era can be deactivated, Reward era is always activated", - //Treasures of Tokuno 1 message + // Treasures of Tokuno 1 message "
Treasures of Tokuno 1

" + "-10 charge Bleach Pigment can drop as a Lesser Artifact
" + "-50 charge Neon Pigments available as a reward
", - //Treasures of Tokuno 2 message + // Treasures of Tokuno 2 message "
Treasures of Tokuno 2

" + "-30 types of 1 charge Metallic Pigments drop as Lesser Artifacts
" + "-1 charge Bleach Pigment can drop as a Lesser Artifact
" + "-10 charge Greater Metallic Pigments available as a reward", - //Treasures of Tokuno 3 message + // Treasures of Tokuno 3 message "
Treasures of Tokuno 3

" + "-10 types of 1 charge Fresh Pigments drop as Lesser Artifacts
" + "-1 charge Bleach Pigment can drop as a Lesser Artifact
" + "-Leurocian's Mempo Of Fortune can drop as a Lesser Artifact" }; - private int m_ToTEras; + private readonly int m_ToTEras; public ToTAdminGump() : base(30, 50) { diff --git a/Projects/Scripts/Gumps/VendorInventoryGump.cs b/Projects/Scripts/Gumps/VendorInventoryGump.cs index 84435f090..0d4fe4efd 100644 --- a/Projects/Scripts/Gumps/VendorInventoryGump.cs +++ b/Projects/Scripts/Gumps/VendorInventoryGump.cs @@ -9,8 +9,8 @@ namespace Server.Gumps { public class VendorInventoryGump : Gump { - private BaseHouse m_House; - private List m_Inventories; + private readonly BaseHouse m_House; + private readonly List m_Inventories; public VendorInventoryGump(BaseHouse house, Mobile from) : base(50, 50) { diff --git a/Projects/Scripts/Gumps/VendorRentalGumps.cs b/Projects/Scripts/Gumps/VendorRentalGumps.cs index 01c140d51..2e68a811e 100644 --- a/Projects/Scripts/Gumps/VendorRentalGumps.cs +++ b/Projects/Scripts/Gumps/VendorRentalGumps.cs @@ -18,266 +18,264 @@ namespace Server.Gumps VendorRenter } - protected BaseVendorRentalGump( GumpType type, VendorRentalDuration duration, int price, int renewalPrice, - Mobile landlord, Mobile renter, bool landlordRenew, bool renterRenew, bool renew ) : base( 100, 100 ) + protected BaseVendorRentalGump(GumpType type, VendorRentalDuration duration, int price, int renewalPrice, + Mobile landlord, Mobile renter, bool landlordRenew, bool renterRenew, bool renew) : base(100, 100) { - if ( type == GumpType.Offer ) + if (type == GumpType.Offer) Closable = false; - AddPage( 0 ); + AddPage(0); - AddImage( 0, 0, 0x1F40 ); - AddImageTiled( 20, 37, 300, 308, 0x1F42 ); - AddImage( 20, 325, 0x1F43 ); + AddImage(0, 0, 0x1F40); + AddImageTiled(20, 37, 300, 308, 0x1F42); + AddImage(20, 325, 0x1F43); - AddImage( 35, 8, 0x39 ); - AddImageTiled( 65, 8, 257, 10, 0x3A ); - AddImage( 290, 8, 0x3B ); + AddImage(35, 8, 0x39); + AddImageTiled(65, 8, 257, 10, 0x3A); + AddImage(290, 8, 0x3B); - AddImageTiled( 70, 55, 230, 2, 0x23C5 ); + AddImageTiled(70, 55, 230, 2, 0x23C5); - AddImage( 32, 33, 0x2635 ); - AddHtmlLocalized( 70, 35, 270, 20, 1062353, 0x1 ); // Vendor Rental Contract + AddImage(32, 33, 0x2635); + AddHtmlLocalized(70, 35, 270, 20, 1062353, 0x1); // Vendor Rental Contract + AddPage(1); - AddPage( 1 ); - - if ( type != GumpType.UnlockedContract ) + if (type != GumpType.UnlockedContract) { - AddImage( 65, 60, 0x827 ); - AddHtmlLocalized( 79, 58, 270, 20, 1062370, 0x1 ); // Landlord: - AddLabel( 150, 58, 0x64, landlord != null ? landlord.Name : "" ); + AddImage(65, 60, 0x827); + AddHtmlLocalized(79, 58, 270, 20, 1062370, 0x1); // Landlord: + AddLabel(150, 58, 0x64, landlord != null ? landlord.Name : ""); - AddImageTiled( 70, 80, 230, 2, 0x23C5 ); + AddImageTiled(70, 80, 230, 2, 0x23C5); } - if ( type == GumpType.UnlockedContract || type == GumpType.LockedContract ) - AddButton( 30, 96, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 2 ); - AddHtmlLocalized( 50, 95, 150, 20, 1062354, 0x1 ); // Contract Length - AddHtmlLocalized( 230, 95, 270, 20, duration.Name, 0x1 ); + if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) + AddButton(30, 96, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 2); + AddHtmlLocalized(50, 95, 150, 20, 1062354, 0x1); // Contract Length + AddHtmlLocalized(230, 95, 270, 20, duration.Name, 0x1); - if ( type == GumpType.UnlockedContract || type == GumpType.LockedContract ) - AddButton( 30, 116, 0x15E1, 0x15E5, 1); - AddHtmlLocalized( 50, 115, 150, 20, 1062356, 0x1 ); // Price Per Rental - AddLabel( 230, 115, 0x64, price > 0 ? price.ToString() : "FREE" ); + if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) + AddButton(30, 116, 0x15E1, 0x15E5, 1); + AddHtmlLocalized(50, 115, 150, 20, 1062356, 0x1); // Price Per Rental + AddLabel(230, 115, 0x64, price > 0 ? price.ToString() : "FREE"); - AddImageTiled( 50, 160, 250, 2, 0x23BF ); + AddImageTiled(50, 160, 250, 2, 0x23BF); - if ( type == GumpType.Offer ) + if (type == GumpType.Offer) { - AddButton( 67, 180, 0x482, 0x483, 2); - AddHtmlLocalized( 100, 180, 270, 20, 1049011, 0x28 ); // I accept! + AddButton(67, 180, 0x482, 0x483, 2); + AddHtmlLocalized(100, 180, 270, 20, 1049011, 0x28); // I accept! - AddButton( 67, 210, 0x47F, 0x480, 0); - AddHtmlLocalized( 100, 210, 270, 20, 1049012, 0x28 ); // No thanks, I decline. + AddButton(67, 210, 0x47F, 0x480, 0); + AddHtmlLocalized(100, 210, 270, 20, 1049012, 0x28); // No thanks, I decline. } else { - AddImage( 49, 170, 0x61 ); - AddHtmlLocalized( 60, 170, 250, 20, 1062355, 0x1 ); // Renew On Expiration? + AddImage(49, 170, 0x61); + AddHtmlLocalized(60, 170, 250, 20, 1062355, 0x1); // Renew On Expiration? - if ( type == GumpType.LockedContract || type == GumpType.UnlockedContract || type == GumpType.VendorLandlord ) - AddButton( 30, 192, 0x15E1, 0x15E5, 3); - AddHtmlLocalized( 85, 190, 250, 20, 1062359, 0x1 ); // Landlord: - AddHtmlLocalized( 230, 190, 270, 20, landlordRenew ? 1049717 : 1049718, 0x1 ); // YES / NO + if (type == GumpType.LockedContract || type == GumpType.UnlockedContract || type == GumpType.VendorLandlord) + AddButton(30, 192, 0x15E1, 0x15E5, 3); + AddHtmlLocalized(85, 190, 250, 20, 1062359, 0x1); // Landlord: + AddHtmlLocalized(230, 190, 270, 20, landlordRenew ? 1049717 : 1049718, 0x1); // YES / NO - if ( type == GumpType.VendorRenter ) - AddButton( 30, 212, 0x15E1, 0x15E5, 4); - AddHtmlLocalized( 85, 210, 250, 20, 1062360, 0x1 ); // Renter: - AddHtmlLocalized( 230, 210, 270, 20, renterRenew ? 1049717 : 1049718, 0x1 ); // YES / NO + if (type == GumpType.VendorRenter) + AddButton(30, 212, 0x15E1, 0x15E5, 4); + AddHtmlLocalized(85, 210, 250, 20, 1062360, 0x1); // Renter: + AddHtmlLocalized(230, 210, 270, 20, renterRenew ? 1049717 : 1049718, 0x1); // YES / NO - if ( renew ) + if (renew) { - AddImage( 49, 233, 0x939 ); - AddHtmlLocalized( 70, 230, 250, 20, 1062482, 0x1 ); // Contract WILL renew + AddImage(49, 233, 0x939); + AddHtmlLocalized(70, 230, 250, 20, 1062482, 0x1); // Contract WILL renew } else { - AddImage( 49, 233, 0x938 ); - AddHtmlLocalized( 70, 230, 250, 20, 1062483, 0x1 ); // Contract WILL NOT renew + AddImage(49, 233, 0x938); + AddHtmlLocalized(70, 230, 250, 20, 1062483, 0x1); // Contract WILL NOT renew } } - AddImageTiled( 30, 283, 257, 30, 0x5D ); - AddImage( 285, 283, 0x5E ); - AddImage( 20, 288, 0x232C ); + AddImageTiled(30, 283, 257, 30, 0x5D); + AddImage(285, 283, 0x5E); + AddImage(20, 288, 0x232C); - if ( type == GumpType.LockedContract ) + if (type == GumpType.LockedContract) { - AddButton( 67, 295, 0x15E1, 0x15E5, 5); - AddHtmlLocalized( 85, 294, 270, 20, 1062358, 0x28 ); // Offer Contract To Someone + 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 == GumpType.VendorLandlord || type == GumpType.VendorRenter) { - if ( type == GumpType.VendorLandlord ) - AddButton( 30, 250, 0x15E1, 0x15E1, 6); - AddHtmlLocalized( 85, 250, 250, 20, 1062499, 0x1 ); // Renewal Price - AddLabel( 230, 250, 0x64, renewalPrice.ToString() ); + if (type == GumpType.VendorLandlord) + AddButton(30, 250, 0x15E1, 0x15E1, 6); + AddHtmlLocalized(85, 250, 250, 20, 1062499, 0x1); // Renewal Price + AddLabel(230, 250, 0x64, renewalPrice.ToString()); - AddHtmlLocalized( 60, 294, 270, 20, 1062369, 0x1 ); // Renter: - AddLabel( 120, 293, 0x64, renter != null ? renter.Name : "" ); + AddHtmlLocalized(60, 294, 270, 20, 1062369, 0x1); // Renter: + AddLabel(120, 293, 0x64, renter != null ? renter.Name : ""); } - - if ( type == GumpType.UnlockedContract || type == GumpType.LockedContract ) + if (type == GumpType.UnlockedContract || type == GumpType.LockedContract) { - AddPage( 2 ); + AddPage(2); - for ( int i = 0; i < VendorRentalDuration.Instances.Length; i++ ) + for (int i = 0; i < VendorRentalDuration.Instances.Length; i++) { VendorRentalDuration durationItem = VendorRentalDuration.Instances[i]; - AddButton( 30, 76 + i * 20, 0x15E1, 0x15E5, 0x10 | i, GumpButtonType.Reply, 1 ); - AddHtmlLocalized( 50, 75 + i * 20, 150, 20, durationItem.Name, 0x1 ); + AddButton(30, 76 + i * 20, 0x15E1, 0x15E5, 0x10 | i, GumpButtonType.Reply, 1); + AddHtmlLocalized(50, 75 + i * 20, 150, 20, durationItem.Name, 0x1); } } } - public override void OnResponse( NetState sender, RelayInfo info ) + public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; - if ( !IsValidResponse( from ) ) + if (!IsValidResponse(from)) return; - if ( (info.ButtonID & 0x10) != 0 ) // Contract duration + if ((info.ButtonID & 0x10) != 0) // Contract duration { int index = info.ButtonID & 0xF; - if ( index < VendorRentalDuration.Instances.Length ) SetContractDuration( from, VendorRentalDuration.Instances[index] ); + if (index < VendorRentalDuration.Instances.Length) SetContractDuration(from, VendorRentalDuration.Instances[index]); } else { - switch ( info.ButtonID ) + switch (info.ButtonID) { case 1: // Price Per Rental - SetPricePerRental( from ); + SetPricePerRental(from); break; case 2: // Accept offer - AcceptOffer( from ); + AcceptOffer(from); break; case 3: // Renew on expiration - landlord - LandlordRenewOnExpiration( from ); + LandlordRenewOnExpiration(from); break; case 4: // Renew on expiration - renter - RenterRenewOnExpiration( from ); + RenterRenewOnExpiration(from); break; case 5: // Offer Contract To Someone - OfferContract( from ); + OfferContract(from); break; case 6: // Renewal price - SetRenewalPrice( from ); + SetRenewalPrice(from); break; default: - Cancel( from ); + Cancel(from); break; } } } - protected abstract bool IsValidResponse( Mobile from ); + protected abstract bool IsValidResponse(Mobile from); - protected virtual void SetContractDuration( Mobile from, VendorRentalDuration duration ) + protected virtual void SetContractDuration(Mobile from, VendorRentalDuration duration) { } - protected virtual void SetPricePerRental( Mobile from ) + protected virtual void SetPricePerRental(Mobile from) { } - protected virtual void AcceptOffer( Mobile from ) + protected virtual void AcceptOffer(Mobile from) { } - protected virtual void LandlordRenewOnExpiration( Mobile from ) + protected virtual void LandlordRenewOnExpiration(Mobile from) { } - protected virtual void RenterRenewOnExpiration( Mobile from ) + protected virtual void RenterRenewOnExpiration(Mobile from) { } - protected virtual void OfferContract( Mobile from ) + protected virtual void OfferContract(Mobile from) { } - protected virtual void SetRenewalPrice( Mobile from ) + protected virtual void SetRenewalPrice(Mobile from) { } - protected virtual void Cancel( Mobile from ) + protected virtual void Cancel(Mobile from) { } } public class VendorRentalContractGump : BaseVendorRentalGump { - private VendorRentalContract m_Contract; + private readonly VendorRentalContract m_Contract; - public VendorRentalContractGump( VendorRentalContract contract, Mobile from ) : base( + public VendorRentalContractGump(VendorRentalContract contract, Mobile from) : base( contract.IsLockedDown ? GumpType.LockedContract : GumpType.UnlockedContract, contract.Duration, - contract.Price, contract.Price, from, null, contract.LandlordRenew, false, false ) => + contract.Price, contract.Price, from, null, contract.LandlordRenew, false, false) => m_Contract = contract; - protected override bool IsValidResponse( Mobile from ) => m_Contract.IsUsableBy( from, true, true, true, true ); + protected override bool IsValidResponse(Mobile from) => m_Contract.IsUsableBy(from, true, true, true, true); - protected override void SetContractDuration( Mobile from, VendorRentalDuration duration ) + protected override void SetContractDuration(Mobile from, VendorRentalDuration duration) { m_Contract.Duration = duration; - from.SendGump( new VendorRentalContractGump( m_Contract, from ) ); + from.SendGump(new VendorRentalContractGump(m_Contract, from)); } - protected override void SetPricePerRental( Mobile from ) + protected override void SetPricePerRental(Mobile from) { - from.SendLocalizedMessage( 1062365 ); // Please enter the amount of gold that should be charged for this contract (ESC to cancel): - from.Prompt = new PricePerRentalPrompt( m_Contract ); + from.SendLocalizedMessage(1062365); // Please enter the amount of gold that should be charged for this contract (ESC to cancel): + from.Prompt = new PricePerRentalPrompt(m_Contract); } - protected override void LandlordRenewOnExpiration( Mobile from ) + protected override void LandlordRenewOnExpiration(Mobile from) { m_Contract.LandlordRenew = !m_Contract.LandlordRenew; - from.SendGump( new VendorRentalContractGump( m_Contract, from ) ); + from.SendGump(new VendorRentalContractGump(m_Contract, from)); } - protected override void OfferContract( Mobile from ) + protected override void OfferContract(Mobile from) { - if ( m_Contract.IsLandlord( from ) ) + if (m_Contract.IsLandlord(from)) { - from.SendLocalizedMessage( 1062371 ); // Please target the person you wish to offer this contract to. - from.Target = new OfferContractTarget( m_Contract ); + from.SendLocalizedMessage(1062371); // Please target the person you wish to offer this contract to. + from.Target = new OfferContractTarget(m_Contract); } } private class PricePerRentalPrompt : Prompt { - private VendorRentalContract m_Contract; + private readonly VendorRentalContract m_Contract; - public PricePerRentalPrompt( VendorRentalContract contract ) => m_Contract = contract; + public PricePerRentalPrompt(VendorRentalContract contract) => m_Contract = contract; - public override void OnResponse( Mobile from, string text ) + public override void OnResponse(Mobile from, string text) { - if ( !m_Contract.IsUsableBy( from, true, true, true, true ) ) + if (!m_Contract.IsUsableBy(from, true, true, true, true)) return; text = text.Trim(); - if ( !int.TryParse( text, out int price ) ) + if (!int.TryParse(text, out int price)) price = -1; - if ( price < 0 ) + if (price < 0) { - from.SendLocalizedMessage( 1062485 ); // Invalid entry. Rental fee set to 0. + from.SendLocalizedMessage(1062485); // Invalid entry. Rental fee set to 0. m_Contract.Price = 0; } - else if ( price > 5000000 ) + else if (price > 5000000) { m_Contract.Price = 5000000; } @@ -286,104 +284,104 @@ namespace Server.Gumps m_Contract.Price = price; } - from.SendGump( new VendorRentalContractGump( m_Contract, from ) ); + from.SendGump(new VendorRentalContractGump(m_Contract, from)); } - public override void OnCancel( Mobile from ) + public override void OnCancel(Mobile from) { - if ( m_Contract.IsUsableBy( from, true, true, true, true ) ) - from.SendGump( new VendorRentalContractGump( m_Contract, from ) ); + if (m_Contract.IsUsableBy(from, true, true, true, true)) + from.SendGump(new VendorRentalContractGump(m_Contract, from)); } } private class OfferContractTarget : Target { - private VendorRentalContract m_Contract; + private readonly VendorRentalContract m_Contract; - public OfferContractTarget( VendorRentalContract contract ) : base( -1, false, TargetFlags.None ) => m_Contract = contract; + public OfferContractTarget(VendorRentalContract contract) : base(-1, false, TargetFlags.None) => m_Contract = contract; - protected override void OnTarget( Mobile from, object targeted ) + protected override void OnTarget(Mobile from, object targeted) { - if ( !m_Contract.IsUsableBy( from, true, false, true, true ) ) + if (!m_Contract.IsUsableBy(from, true, false, true, true)) return; - if ( !(targeted is Mobile mob) || !mob.Player || !mob.Alive || mob == from ) + if (!(targeted is Mobile mob) || !mob.Player || !mob.Alive || mob == from) { - from.SendLocalizedMessage(1071984); //That is not a valid target for a rental contract! + from.SendLocalizedMessage(1071984); // That is not a valid target for a rental contract! } - else if ( !mob.InRange( m_Contract, 5 ) ) + else if (!mob.InRange(m_Contract, 5)) { - from.SendLocalizedMessage( 501853 ); // Target is too far away. + from.SendLocalizedMessage(501853); // Target is too far away. } else { - from.SendLocalizedMessage( 1062372 ); // Please wait while that person considers your offer. + from.SendLocalizedMessage(1062372); // Please wait while that person considers your offer. - mob.SendLocalizedMessage( 1062373, from.Name ); // ~1_NAME~ is offering you a vendor rental. If you choose to accept this offer, you have 30 seconds to do so. - mob.SendGump( new VendorRentalOfferGump( m_Contract, from ) ); + mob.SendLocalizedMessage(1062373, from.Name); // ~1_NAME~ is offering you a vendor rental. If you choose to accept this offer, you have 30 seconds to do so. + mob.SendGump(new VendorRentalOfferGump(m_Contract, from)); m_Contract.Offeree = mob; } } - protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType ) + protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType) { - from.SendLocalizedMessage( 1062380 ); // You decide against offering the contract to anyone. + from.SendLocalizedMessage(1062380); // You decide against offering the contract to anyone. } } } public class VendorRentalOfferGump : BaseVendorRentalGump { - private VendorRentalContract m_Contract; - private Mobile m_Landlord; + private readonly VendorRentalContract m_Contract; + private readonly Mobile m_Landlord; - public VendorRentalOfferGump( VendorRentalContract contract, Mobile landlord ) : base( + public VendorRentalOfferGump(VendorRentalContract contract, Mobile landlord) : base( GumpType.Offer, contract.Duration, contract.Price, contract.Price, - landlord, null, contract.LandlordRenew, false, false ) + landlord, null, contract.LandlordRenew, false, false) { m_Contract = contract; m_Landlord = landlord; } - protected override bool IsValidResponse( Mobile from ) => m_Contract.IsUsableBy( m_Landlord, true, false, false, false ) && from.CheckAlive() && m_Contract.Offeree == from; + protected override bool IsValidResponse(Mobile from) => m_Contract.IsUsableBy(m_Landlord, true, false, false, false) && from.CheckAlive() && m_Contract.Offeree == from; - protected override void AcceptOffer( Mobile from ) + protected override void AcceptOffer(Mobile from) { m_Contract.Offeree = null; - if ( !m_Contract.Map.CanFit( m_Contract.Location, 16, false, false ) ) + if (!m_Contract.Map.CanFit(m_Contract.Location, 16, false, false)) { - m_Landlord.SendLocalizedMessage( 1062486 ); // A vendor cannot exist at that location. Please try again. + m_Landlord.SendLocalizedMessage(1062486); // A vendor cannot exist at that location. Please try again. return; } - BaseHouse house = BaseHouse.FindHouseAt( m_Contract ); - if ( house == null ) + BaseHouse house = BaseHouse.FindHouseAt(m_Contract); + if (house == null) return; int price = m_Contract.Price; int goldToGive; - if ( price > 0 ) + if (price > 0) { - if ( Banker.Withdraw( from, price ) ) + if (Banker.Withdraw(from, price)) { - from.SendLocalizedMessage( 1060398, price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + from.SendLocalizedMessage(1060398, price.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. - int depositedGold = Banker.DepositUpTo( m_Landlord, price ); + int depositedGold = Banker.DepositUpTo(m_Landlord, price); goldToGive = price - depositedGold; - if ( depositedGold > 0 ) - m_Landlord.SendLocalizedMessage( 1060397, price.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + if (depositedGold > 0) + m_Landlord.SendLocalizedMessage(1060397, price.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. - if ( goldToGive > 0 ) - m_Landlord.SendLocalizedMessage( 500390 ); // Your bank box is full. + if (goldToGive > 0) + m_Landlord.SendLocalizedMessage(500390); // Your bank box is full. } else { - from.SendLocalizedMessage( 1062378 ); // You do not have enough gold in your bank account to cover the cost of the contract. - m_Landlord.SendLocalizedMessage( 1062374, from.Name ); // ~1_NAME~ has declined your vendor rental offer. + from.SendLocalizedMessage(1062378); // You do not have enough gold in your bank account to cover the cost of the contract. + m_Landlord.SendLocalizedMessage(1062374, from.Name); // ~1_NAME~ has declined your vendor rental offer. return; } @@ -393,90 +391,90 @@ namespace Server.Gumps goldToGive = 0; } - PlayerVendor vendor = new RentedVendor( from, house, m_Contract.Duration, price, m_Contract.LandlordRenew, goldToGive ); - vendor.MoveToWorld( m_Contract.Location, m_Contract.Map ); + PlayerVendor vendor = new RentedVendor(from, house, m_Contract.Duration, price, m_Contract.LandlordRenew, goldToGive); + vendor.MoveToWorld(m_Contract.Location, m_Contract.Map); m_Contract.Delete(); - from.SendLocalizedMessage( 1062377 ); // You have accepted the offer and now own a vendor in this house. Rental contract options and details may be viewed on this vendor via the 'Contract Options' context menu. - m_Landlord.SendLocalizedMessage( 1062376, from.Name ); // ~1_NAME~ has accepted your vendor rental offer. Rental contract details and options may be viewed on this vendor via the 'Contract Options' context menu. + from.SendLocalizedMessage(1062377); // You have accepted the offer and now own a vendor in this house. Rental contract options and details may be viewed on this vendor via the 'Contract Options' context menu. + m_Landlord.SendLocalizedMessage(1062376, from.Name); // ~1_NAME~ has accepted your vendor rental offer. Rental contract details and options may be viewed on this vendor via the 'Contract Options' context menu. } - protected override void Cancel( Mobile from ) + protected override void Cancel(Mobile from) { m_Contract.Offeree = null; - from.SendLocalizedMessage( 1062375 ); // You decline the offer for a vendor space rental. - m_Landlord.SendLocalizedMessage( 1062374, from.Name ); // ~1_NAME~ has declined your vendor rental offer. + from.SendLocalizedMessage(1062375); // You decline the offer for a vendor space rental. + m_Landlord.SendLocalizedMessage(1062374, from.Name); // ~1_NAME~ has declined your vendor rental offer. } } public class RenterVendorRentalGump : BaseVendorRentalGump { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; - public RenterVendorRentalGump( RentedVendor vendor ) : base( + public RenterVendorRentalGump(RentedVendor vendor) : base( GumpType.VendorRenter, vendor.RentalDuration, vendor.RentalPrice, vendor.RenewalPrice, - vendor.Landlord, vendor.Owner, vendor.LandlordRenew, vendor.RenterRenew, vendor.Renew ) => + vendor.Landlord, vendor.Owner, vendor.LandlordRenew, vendor.RenterRenew, vendor.Renew) => m_Vendor = vendor; - protected override bool IsValidResponse( Mobile from ) => m_Vendor.CanInteractWith( from, true ); + protected override bool IsValidResponse(Mobile from) => m_Vendor.CanInteractWith(from, true); - protected override void RenterRenewOnExpiration( Mobile from ) + protected override void RenterRenewOnExpiration(Mobile from) { m_Vendor.RenterRenew = !m_Vendor.RenterRenew; - from.SendGump( new RenterVendorRentalGump( m_Vendor ) ); + from.SendGump(new RenterVendorRentalGump(m_Vendor)); } } public class LandlordVendorRentalGump : BaseVendorRentalGump { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; - public LandlordVendorRentalGump( RentedVendor vendor ) : base( + public LandlordVendorRentalGump(RentedVendor vendor) : base( GumpType.VendorLandlord, vendor.RentalDuration, vendor.RentalPrice, vendor.RenewalPrice, - vendor.Landlord, vendor.Owner, vendor.LandlordRenew, vendor.RenterRenew, vendor.Renew ) => + vendor.Landlord, vendor.Owner, vendor.LandlordRenew, vendor.RenterRenew, vendor.Renew) => m_Vendor = vendor; - protected override bool IsValidResponse( Mobile from ) => m_Vendor.CanInteractWith( from, false ) && m_Vendor.IsLandlord( from ); + protected override bool IsValidResponse(Mobile from) => m_Vendor.CanInteractWith(from, false) && m_Vendor.IsLandlord(from); - protected override void LandlordRenewOnExpiration( Mobile from ) + protected override void LandlordRenewOnExpiration(Mobile from) { m_Vendor.LandlordRenew = !m_Vendor.LandlordRenew; - from.SendGump( new LandlordVendorRentalGump( m_Vendor ) ); + from.SendGump(new LandlordVendorRentalGump(m_Vendor)); } - protected override void SetRenewalPrice( Mobile from ) + protected override void SetRenewalPrice(Mobile from) { - from.SendLocalizedMessage( 1062500 ); // Enter contract renewal price: + from.SendLocalizedMessage(1062500); // Enter contract renewal price: - from.Prompt = new ContractRenewalPricePrompt( m_Vendor ); + from.Prompt = new ContractRenewalPricePrompt(m_Vendor); } private class ContractRenewalPricePrompt : Prompt { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; - public ContractRenewalPricePrompt( RentedVendor vendor ) => m_Vendor = vendor; + public ContractRenewalPricePrompt(RentedVendor vendor) => m_Vendor = vendor; - public override void OnResponse( Mobile from, string text ) + public override void OnResponse(Mobile from, string text) { - if ( !m_Vendor.CanInteractWith( from, false ) || !m_Vendor.IsLandlord( from ) ) + if (!m_Vendor.CanInteractWith(from, false) || !m_Vendor.IsLandlord(from)) return; text = text.Trim(); - if ( !int.TryParse( text, out int price ) ) + if (!int.TryParse(text, out int price)) price = -1; - if ( price < 0 ) + if (price < 0) { - from.SendLocalizedMessage( 1062485 ); // Invalid entry. Rental fee set to 0. + from.SendLocalizedMessage(1062485); // Invalid entry. Rental fee set to 0. m_Vendor.RenewalPrice = 0; } - else if ( price > 5000000 ) + else if (price > 5000000) { m_Vendor.RenewalPrice = 5000000; } @@ -487,33 +485,33 @@ namespace Server.Gumps m_Vendor.RenterRenew = false; - from.SendGump( new LandlordVendorRentalGump( m_Vendor ) ); + from.SendGump(new LandlordVendorRentalGump(m_Vendor)); } - public override void OnCancel( Mobile from ) + public override void OnCancel(Mobile from) { - if ( m_Vendor.CanInteractWith( from, false ) && m_Vendor.IsLandlord( from ) ) - from.SendGump( new LandlordVendorRentalGump( m_Vendor ) ); + if (m_Vendor.CanInteractWith(from, false) && m_Vendor.IsLandlord(from)) + from.SendGump(new LandlordVendorRentalGump(m_Vendor)); } } } public class VendorRentalRefundGump : Gump { - private RentedVendor m_Vendor; - private Mobile m_Landlord; - private int m_RefundAmount; + private readonly RentedVendor m_Vendor; + private readonly Mobile m_Landlord; + private readonly int m_RefundAmount; - public VendorRentalRefundGump( RentedVendor vendor, Mobile landlord, int refundAmount ) : base( 50, 50 ) + public VendorRentalRefundGump(RentedVendor vendor, Mobile landlord, int refundAmount) : base(50, 50) { m_Vendor = vendor; m_Landlord = landlord; m_RefundAmount = refundAmount; - AddBackground( 0, 0, 420, 320, 0x13BE ); + AddBackground(0, 0, 420, 320, 0x13BE); - AddImageTiled( 10, 10, 400, 300, 0xA40 ); - AddAlphaRegion( 10, 10, 400, 300 ); + AddImageTiled(10, 10, 400, 300, 0xA40); + AddAlphaRegion(10, 10, 400, 300); /* The landlord for this vendor is offering you a partial refund of your rental fee * in exchange for immediate termination of your rental contract.

@@ -522,56 +520,56 @@ namespace Server.Gumps * be able to claim the inventory and any funds the vendor may be holding for you via * a context menu on the house sign for this house. */ - AddHtmlLocalized( 10, 10, 400, 150, 1062501, 0x7FFF, false, true ); + AddHtmlLocalized(10, 10, 400, 150, 1062501, 0x7FFF, false, true); - AddHtmlLocalized( 10, 180, 150, 20, 1062508, 0x7FFF ); // Vendor Name: - AddLabel( 160, 180, 0x480, vendor.Name ); + AddHtmlLocalized(10, 180, 150, 20, 1062508, 0x7FFF); // Vendor Name: + AddLabel(160, 180, 0x480, vendor.Name); - AddHtmlLocalized( 10, 200, 150, 20, 1062509, 0x7FFF ); // Shop Name: - AddLabel( 160, 200, 0x480, vendor.ShopName ); + AddHtmlLocalized(10, 200, 150, 20, 1062509, 0x7FFF); // Shop Name: + AddLabel(160, 200, 0x480, vendor.ShopName); - AddHtmlLocalized( 10, 220, 150, 20, 1062510, 0x7FFF ); // Refund Amount: - AddLabel( 160, 220, 0x480, refundAmount.ToString() ); + AddHtmlLocalized(10, 220, 150, 20, 1062510, 0x7FFF); // Refund Amount: + AddLabel(160, 220, 0x480, refundAmount.ToString()); - AddButton( 10, 268, 0xFA5, 0xFA7, 1); - AddHtmlLocalized( 45, 268, 350, 20, 1062511, 0x7FFF ); // Agree, and dismiss vendor + AddButton(10, 268, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(45, 268, 350, 20, 1062511, 0x7FFF); // Agree, and dismiss vendor - AddButton( 10, 288, 0xFA5, 0xFA7, 0); - AddHtmlLocalized( 45, 288, 350, 20, 1062512, 0x7FFF ); // No, I want to keep my vendor + AddButton(10, 288, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(45, 288, 350, 20, 1062512, 0x7FFF); // No, I want to keep my vendor } - public override void OnResponse( NetState sender, RelayInfo info ) + public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; - if ( !m_Vendor.CanInteractWith( from, true ) || !m_Vendor.CanInteractWith( m_Landlord, false ) || !m_Vendor.IsLandlord( m_Landlord ) ) + if (!m_Vendor.CanInteractWith(from, true) || !m_Vendor.CanInteractWith(m_Landlord, false) || !m_Vendor.IsLandlord(m_Landlord)) return; - if ( info.ButtonID == 1 ) + if (info.ButtonID == 1) { - if ( Banker.Withdraw( m_Landlord, m_RefundAmount ) ) + if (Banker.Withdraw(m_Landlord, m_RefundAmount)) { - m_Landlord.SendLocalizedMessage( 1060398, m_RefundAmount.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + m_Landlord.SendLocalizedMessage(1060398, m_RefundAmount.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. - int depositedGold = Banker.DepositUpTo( from, m_RefundAmount ); + int depositedGold = Banker.DepositUpTo(from, m_RefundAmount); - if ( depositedGold > 0 ) - from.SendLocalizedMessage( 1060397, depositedGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box. + if (depositedGold > 0) + from.SendLocalizedMessage(1060397, depositedGold.ToString()); // ~1_AMOUNT~ gold has been deposited into your bank box. m_Vendor.HoldGold += m_RefundAmount - depositedGold; - m_Vendor.Destroy( false ); + m_Vendor.Destroy(false); - from.SendLocalizedMessage(1071990); //Remember to claim your vendor's belongings from the house sign! + from.SendLocalizedMessage(1071990); // Remember to claim your vendor's belongings from the house sign! } else { - m_Landlord.SendLocalizedMessage( 1062507 ); // You do not have that much money in your bank account. + m_Landlord.SendLocalizedMessage(1062507); // You do not have that much money in your bank account. } } else { - m_Landlord.SendLocalizedMessage( 1062513 ); // The renter declined your offer. + m_Landlord.SendLocalizedMessage(1062513); // The renter declined your offer. } } } diff --git a/Projects/Scripts/Gumps/ViewHousesGump.cs b/Projects/Scripts/Gumps/ViewHousesGump.cs index 05c45a688..7fee93eb1 100644 --- a/Projects/Scripts/Gumps/ViewHousesGump.cs +++ b/Projects/Scripts/Gumps/ViewHousesGump.cs @@ -12,9 +12,9 @@ namespace Server.Gumps private const int White16 = 0x7FFF; private const int White = 0xFFFFFF; - private Mobile m_From; - private List m_List; - private BaseHouse m_Selection; + private readonly Mobile m_From; + private readonly List m_List; + private readonly BaseHouse m_Selection; public ViewHousesGump(Mobile from, List list, BaseHouse sel) : base(50, 40) { @@ -186,46 +186,46 @@ namespace Server.Gumps switch (info.ButtonID) { case 0: - { - m_From.SendGump(new ViewHousesGump(m_From, m_List, null)); - break; - } + { + m_From.SendGump(new ViewHousesGump(m_From, m_List, null)); + break; + } case 1: - { - Map map = m_Selection.Map; + { + Map map = m_Selection.Map; - if (map != null && map != Map.Internal) - m_From.MoveToWorld(m_Selection.BanLocation, map); + if (map != null && map != Map.Internal) + m_From.MoveToWorld(m_Selection.BanLocation, map); - m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); + m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); - break; - } + break; + } case 2: - { - m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); + { + m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); - HouseSign sign = m_Selection.Sign; + HouseSign sign = m_Selection.Sign; - if (sign?.Deleted == false) - sign.OnDoubleClick(m_From); + if (sign?.Deleted == false) + sign.OnDoubleClick(m_From); - break; - } + break; + } case 3: - { - m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); - m_From.SendGump(new HouseDemolishGump(m_From, m_Selection)); + { + m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); + m_From.SendGump(new HouseDemolishGump(m_From, m_Selection)); - break; - } + break; + } case 4: - { - m_Selection.RefreshDecay(); - m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); + { + m_Selection.RefreshDecay(); + m_From.SendGump(new ViewHousesGump(m_From, m_List, m_Selection)); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Gumps/WarningGump.cs b/Projects/Scripts/Gumps/WarningGump.cs index 3c9a63dac..3ccee7be9 100644 --- a/Projects/Scripts/Gumps/WarningGump.cs +++ b/Projects/Scripts/Gumps/WarningGump.cs @@ -1,55 +1,55 @@ namespace Server.Gumps { - public delegate void WarningGumpCallback( bool okay ); + public delegate void WarningGumpCallback(bool okay); public class WarningGump : Gump { - private WarningGumpCallback m_Callback; + private readonly WarningGumpCallback m_Callback; - public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback = null, bool cancelButton = true) : base( (640 - width) / 2, (480 - height) / 2 ) + public WarningGump(int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback = null, bool cancelButton = true) : base((640 - width) / 2, (480 - height) / 2) { m_Callback = callback; Closable = false; - AddPage( 0 ); + AddPage(0); - AddBackground( 0, 0, width, height, 5054 ); + AddBackground(0, 0, width, height, 5054); - AddImageTiled( 10, 10, width - 20, 20, 2624 ); - AddAlphaRegion( 10, 10, width - 20, 20 ); - AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor ); + AddImageTiled(10, 10, width - 20, 20, 2624); + AddAlphaRegion(10, 10, width - 20, 20); + AddHtmlLocalized(10, 10, width - 20, 20, header, headerColor); - AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); - AddAlphaRegion( 10, 40, width - 20, height - 80 ); + AddImageTiled(10, 40, width - 20, height - 80, 2624); + AddAlphaRegion(10, 40, width - 20, height - 80); - if ( content is int i ) - AddHtmlLocalized( 10, 40, width - 20, height - 80, i, contentColor, false, true ); - else if ( content is string ) - AddHtml( 10, 40, width - 20, height - 80, $"{content}", false, true ); + if (content is int i) + AddHtmlLocalized(10, 40, width - 20, height - 80, i, contentColor, false, true); + else if (content is string) + AddHtml(10, 40, width - 20, height - 80, $"{content}", false, true); - AddImageTiled( 10, height - 30, width - 20, 20, 2624 ); - AddAlphaRegion( 10, height - 30, width - 20, 20 ); + AddImageTiled(10, height - 30, width - 20, 20, 2624); + AddAlphaRegion(10, height - 30, width - 20, 20); - AddButton( 10, height - 30, 4005, 4007, 1 ); - AddHtmlLocalized( 40, height - 30, 170, 20, 1011036, 32767 ); // OKAY + AddButton(10, height - 30, 4005, 4007, 1); + AddHtmlLocalized(40, height - 30, 170, 20, 1011036, 32767); // OKAY - if ( cancelButton ) + if (cancelButton) { - AddButton( 10 + (width - 20) / 2, height - 30, 4005, 4007, 0 ); - AddHtmlLocalized( 40 + (width - 20) / 2, height - 30, 170, 20, 1011012, 32767 ); // CANCEL + AddButton(10 + (width - 20) / 2, height - 30, 4005, 4007, 0); + AddHtmlLocalized(40 + (width - 20) / 2, height - 30, 170, 20, 1011012, 32767); // CANCEL } } - public override void OnResponse( Network.NetState sender, RelayInfo info ) + public override void OnResponse(Network.NetState sender, RelayInfo info) { if (m_Callback == null) return; - if ( info.ButtonID == 1) - m_Callback( true ); + if (info.ButtonID == 1) + m_Callback(true); else - m_Callback.Invoke( false ); + m_Callback.Invoke(false); } } } diff --git a/Projects/Scripts/Gumps/WhoGump.cs b/Projects/Scripts/Gumps/WhoGump.cs index 098c4f41d..39d13eb17 100644 --- a/Projects/Scripts/Gumps/WhoGump.cs +++ b/Projects/Scripts/Gumps/WhoGump.cs @@ -9,16 +9,16 @@ namespace Server.Gumps { public static void Initialize() { - CommandSystem.Register( "Who", AccessLevel.Counselor, WhoList_OnCommand ); - CommandSystem.Register( "WhoList", AccessLevel.Counselor, WhoList_OnCommand ); + CommandSystem.Register("Who", AccessLevel.Counselor, WhoList_OnCommand); + CommandSystem.Register("WhoList", AccessLevel.Counselor, WhoList_OnCommand); } - [Usage( "WhoList [filter]" )] - [Aliases( "Who" )] - [Description( "Lists all connected clients. Optionally filters results by name." )] - private static void WhoList_OnCommand( CommandEventArgs e ) + [Usage("WhoList [filter]")] + [Aliases("Who")] + [Description("Lists all connected clients. Optionally filters results by name.")] + private static void WhoList_OnCommand(CommandEventArgs e) { - e.Mobile.SendGump( new WhoGump( e.Mobile, e.ArgString ) ); + e.Mobile.SendGump(new WhoGump(e.Mobile, e.ArgString)); } public static bool OldStyle = PropsConfig.OldStyle; @@ -31,9 +31,9 @@ namespace Server.Gumps public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID; public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID; - public static readonly int EntryGumpID = PropsConfig.EntryGumpID; - public static readonly int BackGumpID = PropsConfig.BackGumpID; - public static readonly int SetGumpID = PropsConfig.SetGumpID; + public static readonly int EntryGumpID = PropsConfig.EntryGumpID; + public static readonly int BackGumpID = PropsConfig.BackGumpID; + public static readonly int SetGumpID = PropsConfig.SetGumpID; public static readonly int SetWidth = PropsConfig.SetWidth; public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY; @@ -55,7 +55,8 @@ namespace Server.Gumps public static readonly int EntryHeight = PropsConfig.EntryHeight; public static readonly int BorderSize = PropsConfig.BorderSize; - private static bool PrevLabel = false, NextLabel = false; + private static readonly bool PrevLabel = false; + private static readonly bool NextLabel = false; private static readonly int PrevLabelOffsetX = PrevWidth + 1; private static readonly int PrevLabelOffsetY = 0; @@ -73,27 +74,27 @@ namespace Server.Gumps private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize; private Mobile m_Owner; - private List m_Mobiles; + private readonly List m_Mobiles; private int m_Page; private class InternalComparer : IComparer { public static readonly IComparer Instance = new InternalComparer(); - public int Compare( Mobile x, Mobile y ) + public int Compare(Mobile x, Mobile y) { - if ( x == null || y == null ) + if (x == null || y == null) throw new ArgumentException(); - if ( x.AccessLevel > y.AccessLevel ) + if (x.AccessLevel > y.AccessLevel) return -1; - if ( x.AccessLevel < y.AccessLevel ) + if (x.AccessLevel < y.AccessLevel) return 1; - return Insensitive.Compare( x.Name, y.Name ); + return Insensitive.Compare(x.Name, y.Name); } } - public WhoGump(Mobile owner, string filter) : this(owner, BuildList( owner, filter )) + public WhoGump(Mobile owner, string filter) : this(owner, BuildList(owner, filter)) { } @@ -104,7 +105,7 @@ namespace Server.Gumps m_Owner = owner; m_Mobiles = list; - Initialize( page ); + Initialize(page); } public static List BuildList(Mobile owner, string rawFilter) @@ -114,104 +115,104 @@ namespace Server.Gumps List list = new List(); List states = TcpServer.Instances; - for ( int i = 0; i < states.Count; ++i ) + for (int i = 0; i < states.Count; ++i) { Mobile m = states[i].Mobile; - if ( m != null && (m == owner || !m.Hidden || owner.AccessLevel >= m.AccessLevel || m is PlayerMobile mobile && mobile.VisibilityList.Contains( owner ) ) ) + if (m != null && (m == owner || !m.Hidden || owner.AccessLevel >= m.AccessLevel || (m is PlayerMobile mobile && mobile.VisibilityList.Contains(owner)))) { - if ( filter != null && !(m.Name?.ToLower().IndexOf(filter) >= 0) ) + if (filter != null && !(m.Name?.ToLower().IndexOf(filter) >= 0)) continue; - list.Add( m ); + list.Add(m); } } - list.Sort( InternalComparer.Instance ); + list.Sort(InternalComparer.Instance); return list; } - public void Initialize( int page ) + public void Initialize(int page) { m_Page = page; int count = m_Mobiles.Count - page * EntryCount; - if ( count < 0 ) + if (count < 0) count = 0; - else if ( count > EntryCount ) + else if (count > EntryCount) count = EntryCount; int totalHeight = OffsetSize + (EntryHeight + OffsetSize) * (count + 1); - AddPage( 0 ); + AddPage(0); - AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID ); - AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID ); + AddBackground(0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID); + AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID); int x = BorderSize + OffsetSize; int y = BorderSize + OffsetSize; int emptyWidth = TotalWidth - PrevWidth - NextWidth - OffsetSize * 4 - (OldStyle ? SetWidth + OffsetSize : 0); - if ( !OldStyle ) - AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID ); + if (!OldStyle) + AddImageTiled(x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID); - AddLabel( x + TextOffsetX, y, TextHue, + AddLabel(x + TextOffsetX, y, TextHue, $"Page {page + 1} of {(m_Mobiles.Count + EntryCount - 1) / EntryCount} ({m_Mobiles.Count})"); x += emptyWidth + OffsetSize; - if ( OldStyle ) - AddImageTiled( x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID ); + if (OldStyle) + AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID); else - AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID ); + AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID); - if ( page > 0 ) + if (page > 0) { - AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1 ); + AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1); - if ( PrevLabel ) - AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" ); + if (PrevLabel) + AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous"); } x += PrevWidth + OffsetSize; - if ( !OldStyle ) - AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID ); + if (!OldStyle) + AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID); - if ( (page + 1) * EntryCount < m_Mobiles.Count ) + if ((page + 1) * EntryCount < m_Mobiles.Count) { - AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1 ); + AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1); - if ( NextLabel ) - AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" ); + if (NextLabel) + AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next"); } - for ( int i = 0, index = page * EntryCount; i < EntryCount && index < m_Mobiles.Count; ++i, ++index ) + for (int i = 0, index = page * EntryCount; i < EntryCount && index < m_Mobiles.Count; ++i, ++index) { x = BorderSize + OffsetSize; y += EntryHeight + OffsetSize; Mobile m = m_Mobiles[index]; - AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID ); - AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, GetHueFor( m ), m.Deleted ? "(deleted)" : m.Name ); + AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID); + AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, GetHueFor(m), m.Deleted ? "(deleted)" : m.Name); x += EntryWidth + OffsetSize; - if ( SetGumpID != 0 ) - AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID ); + if (SetGumpID != 0) + AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID); - if ( m.NetState != null && !m.Deleted ) - AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3 ); + if (m.NetState != null && !m.Deleted) + AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3); } } - private static int GetHueFor( Mobile m ) + private static int GetHueFor(Mobile m) { - switch ( m.AccessLevel ) + switch (m.AccessLevel) { case AccessLevel.Owner: case AccessLevel.Developer: @@ -220,67 +221,67 @@ namespace Server.Gumps case AccessLevel.GameMaster: return 0x21; case AccessLevel.Counselor: return 0x2; default: - { - return m.Kills >= 5 ? 0x21 : m.Criminal ? 0x3B1 : 0x58; - } + { + return m.Kills >= 5 ? 0x21 : m.Criminal ? 0x3B1 : 0x58; + } } } - public override void OnResponse( NetState state, RelayInfo info ) + public override void OnResponse(NetState state, RelayInfo info) { Mobile from = state.Mobile; - switch ( info.ButtonID ) + switch (info.ButtonID) { case 0: // Closed - { - return; - } - case 1: // Previous - { - if ( m_Page > 0 ) - from.SendGump( new WhoGump( from, m_Mobiles, m_Page - 1 ) ); - - break; - } - case 2: // Next - { - if ( (m_Page + 1) * EntryCount < m_Mobiles.Count ) - from.SendGump( new WhoGump( from, m_Mobiles, m_Page + 1 ) ); - - break; - } - default: - { - int index = m_Page * EntryCount + (info.ButtonID - 3); - - if ( index >= 0 && index < m_Mobiles.Count ) { - Mobile m = m_Mobiles[index]; - - if ( m.Deleted ) - { - from.SendMessage( "That player has deleted their character." ); - from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) ); - } - else if ( m.NetState == null ) - { - from.SendMessage( "That player is no longer online." ); - from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) ); - } - else if ( m == from || !m.Hidden || from.AccessLevel >= m.AccessLevel || m is PlayerMobile mobile && mobile.VisibilityList.Contains( from )) - { - from.SendGump( new ClientGump( from, m.NetState ) ); - } - else - { - from.SendMessage( "You cannot see them." ); - from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) ); - } + return; } + case 1: // Previous + { + if (m_Page > 0) + from.SendGump(new WhoGump(from, m_Mobiles, m_Page - 1)); - break; - } + break; + } + case 2: // Next + { + if ((m_Page + 1) * EntryCount < m_Mobiles.Count) + from.SendGump(new WhoGump(from, m_Mobiles, m_Page + 1)); + + break; + } + default: + { + int index = m_Page * EntryCount + (info.ButtonID - 3); + + if (index >= 0 && index < m_Mobiles.Count) + { + Mobile m = m_Mobiles[index]; + + if (m.Deleted) + { + from.SendMessage("That player has deleted their character."); + from.SendGump(new WhoGump(from, m_Mobiles, m_Page)); + } + else if (m.NetState == null) + { + from.SendMessage("That player is no longer online."); + from.SendGump(new WhoGump(from, m_Mobiles, m_Page)); + } + else if (m == from || !m.Hidden || from.AccessLevel >= m.AccessLevel || (m is PlayerMobile mobile && mobile.VisibilityList.Contains(from))) + { + from.SendGump(new ClientGump(from, m.NetState)); + } + else + { + from.SendMessage("You cannot see them."); + from.SendGump(new WhoGump(from, m_Mobiles, m_Page)); + } + } + + break; + } } } } diff --git a/Projects/Scripts/Gumps/YoungGumps.cs b/Projects/Scripts/Gumps/YoungGumps.cs index f94a949dc..2891b10c0 100644 --- a/Projects/Scripts/Gumps/YoungGumps.cs +++ b/Projects/Scripts/Gumps/YoungGumps.cs @@ -5,54 +5,54 @@ namespace Server.Gumps { public class YoungDungeonWarning : Gump { - public YoungDungeonWarning() : base( 150, 200 ) + public YoungDungeonWarning() : base(150, 200) { - AddBackground( 0, 0, 250, 170, 0xA28 ); + AddBackground(0, 0, 250, 170, 0xA28); - AddHtmlLocalized( 20, 43, 215, 70, 1018030, true, true ); // Warning: monsters may attack you on site down here in the dungeons! + AddHtmlLocalized(20, 43, 215, 70, 1018030, true, true); // Warning: monsters may attack you on site down here in the dungeons! - AddButton( 70, 123, 0xFA5, 0xFA7, 0); - AddHtmlLocalized( 105, 125, 100, 35, 1011036 ); // OKAY + AddButton(70, 123, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(105, 125, 100, 35, 1011036); // OKAY } } public class YoungDeathNotice : Gump { - public YoungDeathNotice() : base( 100, 15 ) + public YoungDeathNotice() : base(100, 15) { Closable = false; - AddBackground( 25, 10, 425, 444, 0x13BE ); + AddBackground(25, 10, 425, 444, 0x13BE); - AddImageTiled( 33, 20, 407, 425, 0xA40 ); - AddAlphaRegion( 33, 20, 407, 425 ); + AddImageTiled(33, 20, 407, 425, 0xA40); + AddAlphaRegion(33, 20, 407, 425); - AddHtmlLocalized( 190, 24, 120, 20, 1046287, 0x7D00 ); // You have died. + AddHtmlLocalized(190, 24, 120, 20, 1046287, 0x7D00); // You have died. // As a ghost you cannot interact with the world. You cannot touch items nor can you use them. - AddHtmlLocalized( 50, 50, 380, 40, 1046288, 0xFFFFFF ); + AddHtmlLocalized(50, 50, 380, 40, 1046288, 0xFFFFFF); // You can pass through doors as though they do not exist. However, you cannot pass through walls. - AddHtmlLocalized( 50, 100, 380, 45, 1046289, 0xFFFFFF ); + AddHtmlLocalized(50, 100, 380, 45, 1046289, 0xFFFFFF); // Since you are a new player, any items you had on your person at the time of your death will be in your backpack upon resurrection. - AddHtmlLocalized( 50, 140, 380, 60, 1046291, 0xFFFFFF ); + AddHtmlLocalized(50, 140, 380, 60, 1046291, 0xFFFFFF); // To be resurrected you must find a healer in town or wandering in the wilderness. Some powerful players may also be able to resurrect you. - AddHtmlLocalized( 50, 204, 380, 65, 1046292, 0xFFFFFF ); + AddHtmlLocalized(50, 204, 380, 65, 1046292, 0xFFFFFF); // While you are still in young status, you will be transported to the nearest healer (along with your items) at the time of your death. - AddHtmlLocalized( 50, 269, 380, 65, 1046293, 0xFFFFFF ); + AddHtmlLocalized(50, 269, 380, 65, 1046293, 0xFFFFFF); // To rejoin the world of the living simply walk near one of the NPC healers, and they will resurrect you as long as you are not marked as a criminal. - AddHtmlLocalized( 50, 334, 380, 70, 1046294, 0xFFFFFF ); + AddHtmlLocalized(50, 334, 380, 70, 1046294, 0xFFFFFF); - AddButton( 195, 410, 0xF8, 0xF9, 0); + AddButton(195, 410, 0xF8, 0xF9, 0); } } public class RenounceYoungGump : Gump { - public RenounceYoungGump() : base( 150, 50 ) + public RenounceYoungGump() : base(150, 50) { - AddBackground( 0, 0, 450, 400, 0xA28 ); + AddBackground(0, 0, 450, 400, 0xA28); - AddHtmlLocalized( 0, 30, 450, 35, 1013004 ); //
Renouncing 'Young Player' Status
+ AddHtmlLocalized(0, 30, 450, 35, 1013004); //
Renouncing 'Young Player' Status
/* As a 'Young' player, you are currently under a system of protection that prevents * you from being attacked by other players and certain monsters.

@@ -64,26 +64,26 @@ namespace Server.Gumps * Select OKAY now if you wish to renounce your status as a 'Young' player, otherwise * press CANCEL. */ - AddHtmlLocalized( 30, 70, 390, 210, 1013005, true, true ); + AddHtmlLocalized(30, 70, 390, 210, 1013005, true, true); - AddButton( 45, 298, 0xFA5, 0xFA7, 1); - AddHtmlLocalized( 78, 300, 100, 35, 1011036 ); // OKAY + AddButton(45, 298, 0xFA5, 0xFA7, 1); + AddHtmlLocalized(78, 300, 100, 35, 1011036); // OKAY - AddButton( 178, 298, 0xFA5, 0xFA7, 0); - AddHtmlLocalized( 211, 300, 100, 35, 1011012 ); // CANCEL + AddButton(178, 298, 0xFA5, 0xFA7, 0); + AddHtmlLocalized(211, 300, 100, 35, 1011012); // CANCEL } - public override void OnResponse( NetState sender, RelayInfo info ) + public override void OnResponse(NetState sender, RelayInfo info) { Mobile from = sender.Mobile; - if ( info.ButtonID == 1 ) + if (info.ButtonID == 1) { - if ( from.Account is Account acc ) acc.RemoveYoungStatus( 502085 ); // You have chosen to renounce your `Young' player status. + if (from.Account is Account acc) acc.RemoveYoungStatus(502085); // You have chosen to renounce your `Young' player status. } else { - from.SendLocalizedMessage( 502086 ); // You have chosen not to renounce your `Young' player status. + from.SendLocalizedMessage(502086); // You have chosen not to renounce your `Young' player status. } } } diff --git a/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs b/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs index 80529fc66..d73ea708f 100644 --- a/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs +++ b/Projects/Scripts/Holiday Stuff/Christmas/2010/Addons/FireFliesDeed.cs @@ -149,8 +149,8 @@ namespace Server.Items private class FacingGump : Gump { - private FirefliesDeed m_Deed; - private Mobile m_Placer; + private readonly FirefliesDeed m_Deed; + private readonly Mobile m_Placer; public FacingGump(FirefliesDeed deed, Mobile player) : base(150, 50) @@ -202,8 +202,8 @@ namespace Server.Items private class InternalTarget : Target { - private FirefliesDeed m_FirefliesDeed; - private int m_ItemID; + private readonly FirefliesDeed m_FirefliesDeed; + private readonly int m_ItemID; public InternalTarget(FirefliesDeed m_Deed, int itemid) : base(-1, true, TargetFlags.None) @@ -243,7 +243,7 @@ namespace Server.Items bool isclear = !Map.Malas.GetItemsInRange(p3d, 0).OfType().Any(); - if ((m_ItemID == 0x2336 && north || m_ItemID == 0x2332 && west) && isclear) + if (((m_ItemID == 0x2336 && north) || (m_ItemID == 0x2332 && west)) && isclear) { Fireflies flies = new Fireflies(m_ItemID); @@ -253,7 +253,6 @@ namespace Server.Items m_FirefliesDeed.Delete(); } - else { from.SendLocalizedMessage(1150065); // Holiday fireflies must be placed next to a wall. diff --git a/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs b/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs index b1216ff0f..b71f09738 100644 --- a/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs +++ b/Projects/Scripts/Holiday Stuff/Halloween/2006/Engines/TrickOrTreat.cs @@ -139,8 +139,6 @@ namespace Server.Engines.Events DateTime now = DateTime.UtcNow; - - if (CheckMobile(begged)) { if (begged.NextTrickOrTreat > now) @@ -202,7 +200,7 @@ namespace Server.Engines.Events public class NaughtyTwin : BaseCreature { - private static Point3D[] Felucca_Locations = + private static readonly Point3D[] Felucca_Locations = { new Point3D(4467, 1283, 5), // Moonglow new Point3D(1336, 1997, 5), // Britain @@ -214,13 +212,13 @@ namespace Server.Engines.Events new Point3D(3563, 2139, Map.Trammel.GetAverageZ(3563, 2139)) // (New) Magincia }; - private static Point3D[] Malas_Locations = + private static readonly Point3D[] Malas_Locations = { new Point3D(1015, 527, -65), // Luna new Point3D(1997, 1386, -85) // Umbra }; - private static Point3D[] Ilshenar_Locations = + private static readonly Point3D[] Ilshenar_Locations = { new Point3D(1215, 467, -13), // Compassion new Point3D(722, 1366, -60), // Honesty @@ -233,14 +231,14 @@ namespace Server.Engines.Events new Point3D(1721, 218, 96) // Chaos }; - private static Point3D[] Tokuno_Locations = + private static readonly Point3D[] Tokuno_Locations = { new Point3D(1169, 998, 41), // Isamu-Jima new Point3D(802, 1204, 25), // Makoto-Jima new Point3D(270, 628, 15) // Homare-Jima }; - private Mobile m_From; + private readonly Mobile m_From; public NaughtyTwin(Mobile from) : base(AIType.AI_Melee, FightMode.None, 10, 1, 0.2, 0.4) diff --git a/Projects/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs b/Projects/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs index f84e9a357..ee0ebfc64 100644 --- a/Projects/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs +++ b/Projects/Scripts/Holiday Stuff/Halloween/2009/Engines/PumpkinPatch.cs @@ -9,7 +9,7 @@ namespace Server.Engines.Events { private static Timer m_Timer; - private static Rectangle2D[] m_PumpkinFields = + private static readonly Rectangle2D[] m_PumpkinFields = { new Rectangle2D(4557, 1471, 20, 10), new Rectangle2D(796, 2152, 36, 24), diff --git a/Projects/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs b/Projects/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs index f1d526f04..b39705c95 100644 --- a/Projects/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs +++ b/Projects/Scripts/Holiday Stuff/Halloween/2011/Items/BasePaintedMask.cs @@ -1,11 +1,11 @@ -//using System.Collections.Generic; +// using System.Collections.Generic; namespace Server.Items.Holiday { [TypeAlias("Server.Items.ClownMask", "Server.Items.DaemonMask", "Server.Items.PlagueMask")] public class BasePaintedMask : Item { - private static string[] m_Staffers = + private static readonly string[] m_Staffers = { "Ryan", "Mark", diff --git a/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs b/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs index 8797effab..c9e3303ba 100644 --- a/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs +++ b/Projects/Scripts/Holiday Stuff/Halloween/2012/Engines/PlayerZombies.cs @@ -1,8 +1,8 @@ using System; -using Server.Items; -using Server.Mobiles; using System.Collections.Generic; using Server.Events.Halloween; +using Server.Items; +using Server.Mobiles; namespace Server.Engines.Events { @@ -20,24 +20,24 @@ namespace Server.Engines.Events private static List m_DeathQueue; - private static Rectangle2D[] m_Cemetaries = { - new Rectangle2D(1272,3712,30,20), // Jhelom - new Rectangle2D(1337,1444,48,52), // Britain - new Rectangle2D(2424,1098,20,28), // Trinsic - new Rectangle2D(2728,840,54,54), // Vesper - new Rectangle2D(4528,1314,20,28), // Moonglow - new Rectangle2D(712,1104,30,22), // Yew - new Rectangle2D(5824,1464,22,6), // Fire Dungeon - new Rectangle2D(5224,3655,14,5), // T2A + private static readonly Rectangle2D[] m_Cemetaries = { + new Rectangle2D(1272, 3712, 30, 20), // Jhelom + new Rectangle2D(1337, 1444, 48, 52), // Britain + new Rectangle2D(2424, 1098, 20, 28), // Trinsic + new Rectangle2D(2728, 840, 54, 54), // Vesper + new Rectangle2D(4528, 1314, 20, 28), // Moonglow + new Rectangle2D(712, 1104, 30, 22), // Yew + new Rectangle2D(5824, 1464, 22, 6), // Fire Dungeon + new Rectangle2D(5224, 3655, 14, 5), // T2A - new Rectangle2D(1272,3712,20,30), // Jhelom - new Rectangle2D(1337,1444,52,48), // Britain - new Rectangle2D(2424,1098,28,20), // Trinsic - new Rectangle2D(2728,840,54,54), // Vesper - new Rectangle2D(4528,1314,28,20), // Moonglow - new Rectangle2D(712,1104,22,30), // Yew - new Rectangle2D(5824,1464,6,22), // Fire Dungeon - new Rectangle2D(5224,3655,5,14) // T2A + new Rectangle2D(1272, 3712, 20, 30), // Jhelom + new Rectangle2D(1337, 1444, 52, 48), // Britain + new Rectangle2D(2424, 1098, 28, 20), // Trinsic + new Rectangle2D(2728, 840, 54, 54), // Vesper + new Rectangle2D(4528, 1314, 28, 20), // Moonglow + new Rectangle2D(712, 1104, 22, 30), // Yew + new Rectangle2D(5824, 1464, 6, 22), // Fire Dungeon + new Rectangle2D(5224, 3655, 5, 14) // T2A }; public static void Initialize() @@ -48,17 +48,17 @@ namespace Server.Engines.Events m_QueueClearIntervalSeconds = 1800; DateTime today = DateTime.UtcNow; - TimeSpan tick = TimeSpan.FromSeconds( m_QueueDelaySeconds ); - TimeSpan clear = TimeSpan.FromSeconds( m_QueueClearIntervalSeconds ); + TimeSpan tick = TimeSpan.FromSeconds(m_QueueDelaySeconds); + TimeSpan clear = TimeSpan.FromSeconds(m_QueueClearIntervalSeconds); ReAnimated = new Dictionary(); m_DeathQueue = new List(); - if ( today >= HolidaySettings.StartHalloween && today <= HolidaySettings.FinishHalloween ) + if (today >= HolidaySettings.StartHalloween && today <= HolidaySettings.FinishHalloween) { - m_Timer = Timer.DelayCall( tick, tick, Timer_Callback ); + m_Timer = Timer.DelayCall(tick, tick, Timer_Callback); - m_ClearTimer = Timer.DelayCall( clear, clear, Clear_Callback ); + m_ClearTimer = Timer.DelayCall(clear, clear, Clear_Callback); EventSink.PlayerDeath += EventSink_PlayerDeath; } @@ -76,40 +76,40 @@ namespace Server.Engines.Events m_DeathQueue.Clear(); - if ( DateTime.UtcNow <= HolidaySettings.FinishHalloween ) m_ClearTimer.Stop(); + if (DateTime.UtcNow <= HolidaySettings.FinishHalloween) m_ClearTimer.Stop(); } private static void Timer_Callback() { PlayerMobile player = null; - if ( DateTime.UtcNow <= HolidaySettings.FinishHalloween ) + if (DateTime.UtcNow <= HolidaySettings.FinishHalloween) { - for ( int index = 0; m_DeathQueue.Count > 0 && index < m_DeathQueue.Count; index++ ) - if ( !ReAnimated.ContainsKey( m_DeathQueue[ index ] ) ) + for (int index = 0; m_DeathQueue.Count > 0 && index < m_DeathQueue.Count; index++) + if (!ReAnimated.ContainsKey(m_DeathQueue[index])) { - player = m_DeathQueue[ index ]; + player = m_DeathQueue[index]; break; } - if (player?.Deleted == false && ReAnimated.Count < m_TotalZombieLimit ) + if (player?.Deleted == false && ReAnimated.Count < m_TotalZombieLimit) { Map map = Utility.RandomBool() ? Map.Trammel : Map.Felucca; - Point3D home = GetRandomPointInRect( m_Cemetaries[ Utility.Random( m_Cemetaries.Length ) ], map ); + Point3D home = GetRandomPointInRect(m_Cemetaries[Utility.Random(m_Cemetaries.Length)], map); - if ( map.CanSpawnMobile( home ) ) + if (map.CanSpawnMobile(home)) { - ZombieSkeleton zombieskel = new ZombieSkeleton( player ); + ZombieSkeleton zombieskel = new ZombieSkeleton(player); - ReAnimated.Add( player, zombieskel ); + ReAnimated.Add(player, zombieskel); zombieskel.Home = home; zombieskel.RangeHome = 10; - zombieskel.MoveToWorld( home, map ); + zombieskel.MoveToWorld(home, map); - m_DeathQueue.Remove( player ); + m_DeathQueue.Remove(player); } } } @@ -119,20 +119,20 @@ namespace Server.Engines.Events } } - private static Point3D GetRandomPointInRect( Rectangle2D rect, Map map ) + private static Point3D GetRandomPointInRect(Rectangle2D rect, Map map) { - int x = Utility.Random( rect.X, rect.Width ); - int y = Utility.Random( rect.Y, rect.Height ); + int x = Utility.Random(rect.X, rect.Width); + int y = Utility.Random(rect.Y, rect.Height); - return new Point3D( x, y, map.GetAverageZ( x, y ) ); + return new Point3D(x, y, map.GetAverageZ(x, y)); } } public class PlayerBones : BaseContainer { [Constructible] - public PlayerBones( string name ) - : base( Utility.RandomMinMax( 0x0ECA, 0x0ED2 ) ) + public PlayerBones(string name) + : base(Utility.RandomMinMax(0x0ECA, 0x0ED2)) { Name = $"{name}'s bones"; @@ -145,20 +145,20 @@ namespace Server.Engines.Events }; } - public PlayerBones( Serial serial ) - : base( serial ) + public PlayerBones(Serial serial) + : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); - writer.Write( 0 ); + base.Serialize(writer); + writer.Write(0); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } } @@ -171,7 +171,7 @@ namespace Server.Engines.Events private PlayerMobile m_DeadPlayer; public ZombieSkeleton(PlayerMobile player = null) - : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4 ) + : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { m_DeadPlayer = player; @@ -180,28 +180,28 @@ namespace Server.Engines.Events Body = 0x93; BaseSoundID = 0x1c3; - SetStr( 500 ); - SetDex( 500 ); - SetInt( 500 ); + SetStr(500); + SetDex(500); + SetInt(500); - SetHits( 2500 ); - SetMana( 500 ); - SetStam( 500 ); + SetHits(2500); + SetMana(500); + SetStam(500); - SetDamage( 8, 18 ); + SetDamage(8, 18); - SetDamageType( ResistanceType.Physical, 40 ); - SetDamageType( ResistanceType.Cold, 60 ); + SetDamageType(ResistanceType.Physical, 40); + SetDamageType(ResistanceType.Cold, 60); - SetResistance( ResistanceType.Fire, 50 ); - SetResistance( ResistanceType.Energy, 50 ); - SetResistance( ResistanceType.Physical, 50 ); - SetResistance( ResistanceType.Cold, 50 ); - SetResistance( ResistanceType.Poison, 50 ); + SetResistance(ResistanceType.Fire, 50); + SetResistance(ResistanceType.Energy, 50); + SetResistance(ResistanceType.Physical, 50); + SetResistance(ResistanceType.Cold, 50); + SetResistance(ResistanceType.Poison, 50); - SetSkill( SkillName.MagicResist, 65.1, 80.0 ); - SetSkill( SkillName.Tactics, 95.1, 100 ); - SetSkill( SkillName.Wrestling, 85.1, 95 ); + SetSkill(SkillName.MagicResist, 65.1, 80.0); + SetSkill(SkillName.Tactics, 95.1, 100); + SetSkill(SkillName.Wrestling, 85.1, 95); Fame = 1000; Karma = -1000; @@ -211,48 +211,49 @@ namespace Server.Engines.Events public override void GenerateLoot() { - switch( Utility.Random( 10 ) ) + switch (Utility.Random(10)) { - case 0: PackItem( new LeftArm() ); break; - case 1: PackItem( new RightArm() ); break; - case 2: PackItem( new Torso() ); break; - case 3: PackItem( new Bone() ); break; - case 4: PackItem( new RibCage() ); break; - case 5: if (m_DeadPlayer?.Deleted == false) PackItem( new PlayerBones( m_DeadPlayer.Name ) ); + case 0: PackItem(new LeftArm()); break; + case 1: PackItem(new RightArm()); break; + case 2: PackItem(new Torso()); break; + case 3: PackItem(new Bone()); break; + case 4: PackItem(new RibCage()); break; + case 5: + if (m_DeadPlayer?.Deleted == false) PackItem(new PlayerBones(m_DeadPlayer.Name)); break; } - AddLoot( LootPack.Meager ); + AddLoot(LootPack.Meager); } public override bool BleedImmune => true; public override Poison PoisonImmune => Poison.Regular; - public ZombieSkeleton( Serial serial ) - : base( serial ) + public ZombieSkeleton(Serial serial) + : base(serial) { } public override void OnDelete() { - if ( HalloweenHauntings.ReAnimated != null ) + if (HalloweenHauntings.ReAnimated != null) if (m_DeadPlayer?.Deleted == false) - if ( HalloweenHauntings.ReAnimated.ContainsKey( m_DeadPlayer ) ) - HalloweenHauntings.ReAnimated.Remove( m_DeadPlayer ); + if (HalloweenHauntings.ReAnimated.ContainsKey(m_DeadPlayer)) + HalloweenHauntings.ReAnimated.Remove(m_DeadPlayer); } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); - writer.Write( 0 ); + base.Serialize(writer); + writer.Write(0); - writer.WriteMobile( m_DeadPlayer ); + writer.WriteMobile(m_DeadPlayer); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); m_DeadPlayer = reader.ReadMobile(); diff --git a/Projects/Scripts/Holiday Stuff/Halloween/HolidaySettings.cs b/Projects/Scripts/Holiday Stuff/Halloween/HolidaySettings.cs index afa69bac4..85b0fc2e0 100644 --- a/Projects/Scripts/Holiday Stuff/Halloween/HolidaySettings.cs +++ b/Projects/Scripts/Holiday Stuff/Halloween/HolidaySettings.cs @@ -6,7 +6,7 @@ namespace Server.Events.Halloween { internal class HolidaySettings { - private static Type[] m_GMBeggarTreats = + private static readonly Type[] m_GMBeggarTreats = { typeof(CreepyCake), typeof(PumpkinPizza), @@ -21,7 +21,7 @@ namespace Server.Events.Halloween typeof(ColoredSmallWebs) }; - private static Type[] m_Treats = + private static readonly Type[] m_Treats = { typeof(Lollipops), typeof(WrappedCandy), diff --git a/Projects/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs b/Projects/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs index 7849e8941..4b35030d0 100644 --- a/Projects/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs +++ b/Projects/Scripts/Holiday Stuff/Valentine/2011/Items/StValentinesBears.cs @@ -79,7 +79,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public DateTime EditLimit{ get; set; } + public DateTime EditLimit { get; set; } public bool IsSigned => m_Line1 != null || m_Line2 != null || m_Line3 != null; @@ -158,7 +158,7 @@ namespace Server.Items private class InternalGump : Gump { - private StValentinesBear m_Bear; + private readonly StValentinesBear m_Bear; public InternalGump(StValentinesBear bear) : base(50, 50) diff --git a/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs b/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs index c20b3558a..09a104001 100644 --- a/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs +++ b/Projects/Scripts/Holiday Stuff/Valentine/2012/Items/CupidsArrow.cs @@ -12,14 +12,14 @@ namespace Server.Items private string m_From; private string m_To; - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public string From { get => m_From; set { m_From = value; InvalidateProperties(); } } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public string To { get => m_To; @@ -30,59 +30,59 @@ namespace Server.Items [Constructible] public CupidsArrow() - : base( 0x4F7F ) => + : base(0x4F7F) => LootType = LootType.Blessed; - public override void AddNameProperty( ObjectPropertyList list ) + public override void AddNameProperty(ObjectPropertyList list) { - base.AddNameProperty( list ); + base.AddNameProperty(list); - if ( IsSigned ) - list.Add( 1152273, $"{m_From}\t{m_To}"); // ~1_val~ is madly in love with ~2_val~ + if (IsSigned) + list.Add(1152273, $"{m_From}\t{m_To}"); // ~1_val~ is madly in love with ~2_val~ } - public static bool CheckSeason( Mobile from ) + public static bool CheckSeason(Mobile from) { - if ( DateTime.UtcNow.Month == 2 ) + if (DateTime.UtcNow.Month == 2) return true; - from.SendLocalizedMessage( 1152318 ); // You may not use this item out of season. + from.SendLocalizedMessage(1152318); // You may not use this item out of season. return false; } - public override void OnSingleClick( Mobile from ) + public override void OnSingleClick(Mobile from) { - base.OnSingleClick( from ); + base.OnSingleClick(from); - if ( IsSigned ) - LabelTo( from, 1152273, $"{m_From}\t{m_To}"); // ~1_val~ is madly in love with ~2_val~ + if (IsSigned) + LabelTo(from, 1152273, $"{m_From}\t{m_To}"); // ~1_val~ is madly in love with ~2_val~ } - public override void OnDoubleClick( Mobile from ) + public override void OnDoubleClick(Mobile from) { - if ( IsSigned || !CheckSeason( from ) ) + if (IsSigned || !CheckSeason(from)) return; - if ( !IsChildOf( from.Backpack ) ) + if (!IsChildOf(from.Backpack)) { - from.SendLocalizedMessage( 1080063 ); // This must be in your backpack to use it. + from.SendLocalizedMessage(1080063); // This must be in your backpack to use it. return; } - from.BeginTarget( 10, false, TargetFlags.None, OnTarget ); - from.SendMessage( "Who do you wish to use this on?" ); + from.BeginTarget(10, false, TargetFlags.None, OnTarget); + from.SendMessage("Who do you wish to use this on?"); } - private void OnTarget( Mobile from, object targeted ) + private void OnTarget(Mobile from, object targeted) { - if ( IsSigned || !IsChildOf( from.Backpack ) ) + if (IsSigned || !IsChildOf(from.Backpack)) return; - if ( targeted is Mobile m ) + if (targeted is Mobile m) { - if ( !m.Alive ) + if (!m.Alive) { - from.SendLocalizedMessage( 1152269 ); // That target is dead and even Cupid's arrow won't make them love you. + from.SendLocalizedMessage(1152269); // That target is dead and even Cupid's arrow won't make them love you. return; } @@ -91,37 +91,37 @@ namespace Server.Items InvalidateProperties(); - from.SendMessage( "You inscribe the arrow." ); + from.SendMessage("You inscribe the arrow."); } else { - from.SendMessage( "That is not a person." ); + from.SendMessage("That is not a person."); } } - public CupidsArrow( Serial serial ) - : base( serial ) + public CupidsArrow(Serial serial) + : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); + writer.Write(0); - writer.Write( m_From ); - writer.Write( m_To ); + writer.Write(m_From); + writer.Write(m_To); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); - m_From = Utility.Intern( reader.ReadString() ); - m_To = Utility.Intern( reader.ReadString() ); + m_From = Utility.Intern(reader.ReadString()); + m_To = Utility.Intern(reader.ReadString()); } } } diff --git a/Projects/Scripts/Items/Addons/AddonComponent.cs b/Projects/Scripts/Items/Addons/AddonComponent.cs index 15fee0b74..c03d1393a 100644 --- a/Projects/Scripts/Items/Addons/AddonComponent.cs +++ b/Projects/Scripts/Items/Addons/AddonComponent.cs @@ -98,17 +98,17 @@ namespace Server.Items switch (version) { case 0: - { - m_LabelNumber = reader.ReadInt(); - break; - } + { + m_LabelNumber = reader.ReadInt(); + break; + } } } } - public class AddonComponent : Item, IChopable + public class AddonComponent : Item, IChoppable { - private static LightEntry[] m_Entries = + private static readonly LightEntry[] m_Entries = { new LightEntry(LightType.WestSmall, 1122, 1123, 1124, 1141, 1142, 1143, 1144, 1145, 1146, 2347, 2359, 2360, 2361, 2362, 2363, 2364, 2387, 2388, 2389, 2390, 2391, 2392), @@ -130,10 +130,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public BaseAddon Addon{ get; set; } + public BaseAddon Addon { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Offset{ get; set; } + public Point3D Offset { get; set; } [Hue] [CommandProperty(AccessLevel.GameMaster)] @@ -204,16 +204,16 @@ namespace Server.Items { case 1: case 0: - { - Addon = reader.ReadItem() as BaseAddon; - Offset = reader.ReadPoint3D(); + { + Addon = reader.ReadItem() as BaseAddon; + Offset = reader.ReadPoint3D(); - Addon?.OnComponentLoaded(this); + Addon?.OnComponentLoaded(this); - ApplyLightTo(this); + ApplyLightTo(this); - break; - } + break; + } } if (version < 1 && Weight == 0) @@ -246,8 +246,8 @@ namespace Server.Items private class LightEntry { - public int[] m_ItemIDs; - public LightType m_Light; + public readonly int[] m_ItemIDs; + public readonly LightType m_Light; public LightEntry(LightType light, params int[] itemIDs) { diff --git a/Projects/Scripts/Items/Addons/AddonContainerComponent.cs b/Projects/Scripts/Items/Addons/AddonContainerComponent.cs index 919c0084f..19e5dd99c 100644 --- a/Projects/Scripts/Items/Addons/AddonContainerComponent.cs +++ b/Projects/Scripts/Items/Addons/AddonContainerComponent.cs @@ -3,7 +3,7 @@ using Server.ContextMenus; namespace Server.Items { - public class AddonContainerComponent : Item, IChopable + public class AddonContainerComponent : Item, IChoppable { [Constructible] public AddonContainerComponent(int itemID) : base(itemID) @@ -21,10 +21,10 @@ namespace Server.Items public virtual Point3D WallPosition => Point3D.Zero; [CommandProperty(AccessLevel.GameMaster)] - public BaseAddonContainer Addon{ get; set; } + public BaseAddonContainer Addon { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Offset{ get; set; } + public Point3D Offset { get; set; } [Hue] [CommandProperty(AccessLevel.GameMaster)] diff --git a/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs b/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs index 617b1dec1..98cc76710 100644 --- a/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs +++ b/Projects/Scripts/Items/Addons/ArcheryButteAddon.cs @@ -4,29 +4,29 @@ using Server.Network; namespace Server.Items { - [FlippableAttribute( 0x100A/*East*/, 0x100B/*South*/ )] + [FlippableAttribute(0x100A/*East*/, 0x100B/*South*/)] public class ArcheryButte : AddonComponent { - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public double MinSkill { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public double MaxSkill { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public DateTime LastUse { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public bool FacingEast { get => ItemID == 0x100A; set => ItemID = value ? 0x100A : 0x100B; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public int Arrows { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public int Bolts { get; set; } [Constructible] @@ -36,27 +36,27 @@ namespace Server.Items MaxSkill = +25.0; } - public ArcheryButte( Serial serial ) : base( serial ) + public ArcheryButte(Serial serial) : base(serial) { } - public override void OnDoubleClick( Mobile from ) + public override void OnDoubleClick(Mobile from) { - if ( (Arrows > 0 || Bolts > 0) && from.InRange( GetWorldLocation(), 1 ) ) - Gather( from ); + if ((Arrows > 0 || Bolts > 0) && from.InRange(GetWorldLocation(), 1)) + Gather(from); else - Fire( from ); + Fire(from); } - public void Gather( Mobile from ) + public void Gather(Mobile from) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500592 ); // You gather the arrows and bolts. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500592); // You gather the arrows and bolts. - if ( Arrows > 0 ) - from.AddToBackpack( new Arrow( Arrows ) ); + if (Arrows > 0) + from.AddToBackpack(new Arrow(Arrows)); - if ( Bolts > 0 ) - from.AddToBackpack( new Bolt( Bolts ) ); + if (Bolts > 0) + from.AddToBackpack(new Bolt(Bolts)); Arrows = 0; Bolts = 0; @@ -64,7 +64,7 @@ namespace Server.Items m_Entries = null; } - private static TimeSpan UseDelay = TimeSpan.FromSeconds( 2.0 ); + private static readonly TimeSpan UseDelay = TimeSpan.FromSeconds(2.0); private class ScoreEntry { @@ -72,7 +72,7 @@ namespace Server.Items public int Count { get; set; } - public void Record( int score ) + public void Record(int score) { Total += score; Count += 1; @@ -81,9 +81,9 @@ namespace Server.Items private Dictionary m_Entries; - private ScoreEntry GetEntryFor( Mobile from ) + private ScoreEntry GetEntryFor(Mobile from) { - if ( m_Entries == null ) + if (m_Entries == null) m_Entries = new Dictionary(); if (!m_Entries.TryGetValue(from, out ScoreEntry e)) @@ -92,105 +92,105 @@ namespace Server.Items return e; } - public void Fire( Mobile from ) + public void Fire(Mobile from) { - if ( !(from.Weapon is BaseRanged bow) ) + if (!(from.Weapon is BaseRanged bow)) { - SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this. + SendLocalizedMessageTo(from, 500593); // You must practice with ranged weapons on this. return; } - if ( DateTime.UtcNow < LastUse + UseDelay ) + if (DateTime.UtcNow < LastUse + UseDelay) return; Point3D worldLoc = GetWorldLocation(); - if ( FacingEast ? from.X <= worldLoc.X : from.Y <= worldLoc.Y ) + if (FacingEast ? from.X <= worldLoc.X : from.Y <= worldLoc.Y) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500596 ); // You would do better to stand in front of the archery butte. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500596); // You would do better to stand in front of the archery butte. return; } - if ( FacingEast ? from.Y != worldLoc.Y : from.X != worldLoc.X ) + if (FacingEast ? from.Y != worldLoc.Y : from.X != worldLoc.X) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500597 ); // You aren't properly lined up with the archery butte to get an accurate shot. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500597); // You aren't properly lined up with the archery butte to get an accurate shot. return; } - if ( !from.InRange( worldLoc, 6 ) ) + if (!from.InRange(worldLoc, 6)) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500598 ); // You are too far away from the archery butte to get an accurate shot. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500598); // You are too far away from the archery butte to get an accurate shot. return; } - if ( from.InRange( worldLoc, 4 ) ) + if (from.InRange(worldLoc, 4)) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500599 ); // You are too close to the target. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500599); // You are too close to the target. return; } Container pack = from.Backpack; Type ammoType = bow.AmmoType; - bool isArrow = ammoType == typeof( Arrow ); - bool isBolt = ammoType == typeof( Bolt ); + bool isArrow = ammoType == typeof(Arrow); + bool isBolt = ammoType == typeof(Bolt); bool isKnown = isArrow || isBolt; - if (pack?.ConsumeTotal( ammoType ) != true) + if (pack?.ConsumeTotal(ammoType) != true) { - if ( isArrow ) - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500594 ); // You do not have any arrows with which to practice. - else if ( isBolt ) - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 500595 ); // You do not have any crossbow bolts with which to practice. + if (isArrow) + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500594); // You do not have any arrows with which to practice. + else if (isBolt) + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500595); // You do not have any crossbow bolts with which to practice. else - SendLocalizedMessageTo( from, 500593 ); // You must practice with ranged weapons on this. + SendLocalizedMessageTo(from, 500593); // You must practice with ranged weapons on this. return; } LastUse = DateTime.UtcNow; - from.Direction = from.GetDirectionTo( GetWorldLocation() ); - bow.PlaySwingAnimation( from ); - from.MovingEffect( this, bow.EffectID, 18, 1, false, false ); + from.Direction = from.GetDirectionTo(GetWorldLocation()); + bow.PlaySwingAnimation(from); + from.MovingEffect(this, bow.EffectID, 18, 1, false, false); - ScoreEntry se = GetEntryFor( from ); + ScoreEntry se = GetEntryFor(from); - if ( !from.CheckSkill( bow.Skill, MinSkill, MaxSkill ) ) + if (!from.CheckSkill(bow.Skill, MinSkill, MaxSkill)) { - from.PlaySound( bow.MissSound ); + from.PlaySound(bow.MissSound); - PublicOverheadMessage( MessageType.Regular, 0x3B2, 500604, from.Name ); // You miss the target altogether. + PublicOverheadMessage(MessageType.Regular, 0x3B2, 500604, from.Name); // You miss the target altogether. - se.Record( 0 ); + se.Record(0); - if ( se.Count == 1 ) - PublicOverheadMessage( MessageType.Regular, 0x3B2, 1062719, se.Total.ToString() ); + if (se.Count == 1) + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1062719, se.Total.ToString()); else - PublicOverheadMessage( MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}"); + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}"); return; } - Effects.PlaySound( Location, Map, 0x2B1 ); + Effects.PlaySound(Location, Map, 0x2B1); double rand = Utility.RandomDouble(); int area, score, splitScore; - if ( 0.10 > rand ) + if (rand < 0.10) { area = 0; // bullseye score = 50; splitScore = 100; } - else if ( 0.25 > rand ) + else if (rand < 0.25) { area = 1; // inner ring score = 10; splitScore = 20; } - else if ( 0.50 > rand ) + else if (rand < 0.50) { area = 2; // middle ring score = 5; @@ -205,64 +205,64 @@ namespace Server.Items bool split = isKnown && (Arrows + Bolts) * 0.02 > Utility.RandomDouble(); - if ( split ) + if (split) { - PublicOverheadMessage( MessageType.Regular, 0x3B2, 1010027 + area, + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1010027 + area, $"{from.Name}\t{(isArrow ? "arrow" : "bolt")}"); } else { - PublicOverheadMessage( MessageType.Regular, 0x3B2, 1010035 + area, from.Name ); + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1010035 + area, from.Name); - if ( isArrow ) + if (isArrow) ++Arrows; - else if ( isBolt ) + else if (isBolt) ++Bolts; } - se.Record( split ? splitScore : score ); + se.Record(split ? splitScore : score); - if ( se.Count == 1 ) - PublicOverheadMessage( MessageType.Regular, 0x3B2, 1062719, se.Total.ToString() ); + if (se.Count == 1) + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1062719, se.Total.ToString()); else - PublicOverheadMessage( MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}"); + PublicOverheadMessage(MessageType.Regular, 0x3B2, 1042683, $"{se.Total}\t{se.Count}"); } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); + writer.Write(0); - writer.Write( MinSkill ); - writer.Write( MaxSkill ); - writer.Write( Arrows ); - writer.Write( Bolts ); + writer.Write(MinSkill); + writer.Write(MaxSkill); + writer.Write(Arrows); + writer.Write(Bolts); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); - switch ( version ) + switch (version) { case 0: - { - MinSkill = reader.ReadDouble(); - MaxSkill = reader.ReadDouble(); - Arrows = reader.ReadInt(); - Bolts = reader.ReadInt(); - - if ( MinSkill == 0.0 && MaxSkill == 30.0 ) { - MinSkill = -25.0; - MaxSkill = +25.0; - } + MinSkill = reader.ReadDouble(); + MaxSkill = reader.ReadDouble(); + Arrows = reader.ReadInt(); + Bolts = reader.ReadInt(); - break; - } + if (MinSkill == 0.0 && MaxSkill == 30.0) + { + MinSkill = -25.0; + MaxSkill = +25.0; + } + + break; + } } } } @@ -274,23 +274,23 @@ namespace Server.Items [Constructible] public ArcheryButteAddon() { - AddComponent( new ArcheryButte(), 0, 0, 0 ); + AddComponent(new ArcheryButte(), 0, 0, 0); } - public ArcheryButteAddon( Serial serial ) : base( serial ) + public ArcheryButteAddon(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); // version + writer.Write(0); // version } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } @@ -306,20 +306,20 @@ namespace Server.Items { } - public ArcheryButteDeed( Serial serial ) : base( serial ) + public ArcheryButteDeed(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); // version + writer.Write(0); // version } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } diff --git a/Projects/Scripts/Items/Addons/BallotBox.cs b/Projects/Scripts/Items/Addons/BallotBox.cs index 6b563ab64..81da2cd47 100644 --- a/Projects/Scripts/Items/Addons/BallotBox.cs +++ b/Projects/Scripts/Items/Addons/BallotBox.cs @@ -14,7 +14,7 @@ namespace Server.Items [Constructible] public BallotBox() : base(0x9A8) { - Topic = new string[0]; + Topic = Array.Empty(); Yes = new List(); No = new List(); } @@ -25,15 +25,15 @@ namespace Server.Items public override int LabelNumber => 1041006; // a ballot box - public string[] Topic{ get; private set; } + public string[] Topic { get; private set; } - public List Yes{ get; private set; } + public List Yes { get; private set; } - public List No{ get; private set; } + public List No { get; private set; } public void ClearTopic() { - Topic = new string[0]; + Topic = Array.Empty(); ClearVotes(); } @@ -120,7 +120,7 @@ namespace Server.Items private class InternalGump : Gump { - private BallotBox m_Box; + private readonly BallotBox m_Box; public InternalGump(BallotBox box, bool isOwner) : base(110, 70) { @@ -199,74 +199,74 @@ namespace Server.Items switch (info.ButtonID) { case 1: // change topic - { - if (isOwner) { - m_Box.ClearTopic(); + if (isOwner) + { + m_Box.ClearTopic(); - from.SendLocalizedMessage(500370, "", - 0x35); // Enter a line of text for your ballot, and hit ENTER. Hit ESC after the last line is entered. - from.Prompt = new TopicPrompt(m_Box); + from.SendLocalizedMessage(500370, "", + 0x35); // Enter a line of text for your ballot, and hit ENTER. Hit ESC after the last line is entered. + from.Prompt = new TopicPrompt(m_Box); + } + + break; } - - break; - } case 2: // reset votes - { - if (isOwner) { - m_Box.ClearVotes(); - from.SendLocalizedMessage(500371); // Votes zeroed out. - } + if (isOwner) + { + m_Box.ClearVotes(); + from.SendLocalizedMessage(500371); // Votes zeroed out. + } - goto default; - } + goto default; + } case 3: // aye - { - if (!isOwner) { - if (m_Box.HasVoted(from)) + if (!isOwner) { - from.SendLocalizedMessage(500374); // You have already voted on this ballot. + if (m_Box.HasVoted(from)) + { + from.SendLocalizedMessage(500374); // You have already voted on this ballot. + } + else + { + m_Box.Yes.Add(from); + from.SendLocalizedMessage(500373); // Your vote has been registered. + } } - else - { - m_Box.Yes.Add(from); - from.SendLocalizedMessage(500373); // Your vote has been registered. - } - } - goto default; - } + goto default; + } case 4: // nay - { - if (!isOwner) { - if (m_Box.HasVoted(from)) + if (!isOwner) { - from.SendLocalizedMessage(500374); // You have already voted on this ballot. + if (m_Box.HasVoted(from)) + { + from.SendLocalizedMessage(500374); // You have already voted on this ballot. + } + else + { + m_Box.No.Add(from); + from.SendLocalizedMessage(500373); // Your vote has been registered. + } } - else - { - m_Box.No.Add(from); - from.SendLocalizedMessage(500373); // Your vote has been registered. - } - } - goto default; - } + goto default; + } default: - { - from.SendGump(new InternalGump(m_Box, isOwner)); - break; - } + { + from.SendGump(new InternalGump(m_Box, isOwner)); + break; + } } } } private class TopicPrompt : Prompt { - private BallotBox m_Box; + private readonly BallotBox m_Box; public TopicPrompt(BallotBox box) => m_Box = box; diff --git a/Projects/Scripts/Items/Addons/BaseAddon.cs b/Projects/Scripts/Items/Addons/BaseAddon.cs index f11b60e14..d86221711 100644 --- a/Projects/Scripts/Items/Addons/BaseAddon.cs +++ b/Projects/Scripts/Items/Addons/BaseAddon.cs @@ -15,12 +15,12 @@ namespace Server.Items public interface IAddon { - Item Deed{ get; } + Item Deed { get; } bool CouldFit(IPoint3D p, Map map); } - public abstract class BaseAddon : Item, IChopable, IAddon + public abstract class BaseAddon : Item, IChoppable, IAddon { public BaseAddon() : base(1) { @@ -38,7 +38,7 @@ namespace Server.Items public virtual BaseAddonDeed Deed => null; - public List Components{ get; private set; } + public List Components { get; private set; } public virtual bool ShareHue => true; @@ -155,7 +155,7 @@ namespace Server.Items if (Utility.InRange(doorLoc, addonLoc, 1) && (addonLoc.Z == doorLoc.Z || - addonLoc.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLoc.Z)) + (addonLoc.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLoc.Z))) return AddonFitResult.DoorTooClose; } } @@ -237,18 +237,16 @@ namespace Server.Items { case 1: case 0: - { - Components = reader.ReadStrongItemList(); - break; - } + { + Components = reader.ReadStrongItemList(); + break; + } } if (version < 1 && Weight == 0) Weight = -1; } - #region Mondain's Legacy - private CraftResource m_Resource; [CommandProperty(AccessLevel.GameMaster)] @@ -266,7 +264,5 @@ namespace Server.Items } } } - - #endregion } } diff --git a/Projects/Scripts/Items/Addons/BaseAddonContainer.cs b/Projects/Scripts/Items/Addons/BaseAddonContainer.cs index 150309a95..34f1ade94 100644 --- a/Projects/Scripts/Items/Addons/BaseAddonContainer.cs +++ b/Projects/Scripts/Items/Addons/BaseAddonContainer.cs @@ -3,7 +3,7 @@ using Server.Multis; namespace Server.Items { - public abstract class BaseAddonContainer : BaseContainer, IChopable, IAddon + public abstract class BaseAddonContainer : BaseContainer, IChoppable, IAddon { private CraftResource m_Resource; @@ -64,7 +64,7 @@ namespace Server.Items public virtual Point3D WallPosition => Point3D.Zero; public virtual BaseAddonContainerDeed Deed => null; - public List Components{ get; private set; } + public List Components { get; private set; } Item IAddon.Deed => Deed; @@ -269,7 +269,7 @@ namespace Server.Items if (Utility.InRange(doorLoc, addonLoc, 1) && (addonLoc.Z == doorLoc.Z || - addonLoc.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLoc.Z)) + (addonLoc.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLoc.Z))) return AddonFitResult.DoorTooClose; } @@ -277,7 +277,7 @@ namespace Server.Items addonHeight = ItemData.CalcHeight; if (Utility.InRange(doorLoc, addonLo, 1) && - (addonLo.Z == doorLoc.Z || addonLo.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLo.Z)) + (addonLo.Z == doorLoc.Z || (addonLo.Z + addonHeight > doorLoc.Z && doorLoc.Z + doorHeight > addonLo.Z))) return AddonFitResult.DoorTooClose; } } diff --git a/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs b/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs index b424b7b15..b0ac8d8c2 100644 --- a/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs +++ b/Projects/Scripts/Items/Addons/BaseAddonContainerDeed.cs @@ -23,7 +23,7 @@ namespace Server.Items { } - public abstract BaseAddonContainer Addon{ get; } + public abstract BaseAddonContainer Addon { get; } [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource @@ -41,8 +41,6 @@ namespace Server.Items } } - #region ICraftable - public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -58,8 +56,6 @@ namespace Server.Items return quality; } - #endregion - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); @@ -101,7 +97,7 @@ namespace Server.Items private class InternalTarget : Target { - private BaseAddonContainerDeed m_Deed; + private readonly BaseAddonContainerDeed m_Deed; public InternalTarget(BaseAddonContainerDeed deed) : base(-1, true, TargetFlags.None) { diff --git a/Projects/Scripts/Items/Addons/BaseAddonDeed.cs b/Projects/Scripts/Items/Addons/BaseAddonDeed.cs index 8cb8d563a..c12146af1 100644 --- a/Projects/Scripts/Items/Addons/BaseAddonDeed.cs +++ b/Projects/Scripts/Items/Addons/BaseAddonDeed.cs @@ -19,7 +19,7 @@ namespace Server.Items { } - public abstract BaseAddon Addon{ get; } + public abstract BaseAddon Addon { get; } public override void Serialize(IGenericWriter writer) { @@ -48,7 +48,7 @@ namespace Server.Items private class InternalTarget : Target { - private BaseAddonDeed m_Deed; + private readonly BaseAddonDeed m_Deed; public InternalTarget(BaseAddonDeed deed) : base(-1, true, TargetFlags.None) { @@ -103,8 +103,6 @@ namespace Server.Items } } - #region Mondain's Legacy - private CraftResource m_Resource; [CommandProperty(AccessLevel.GameMaster)] @@ -122,7 +120,5 @@ namespace Server.Items } } } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Addons/ElvenSpinningwheelEastAddon.cs b/Projects/Scripts/Items/Addons/ElvenSpinningwheelEastAddon.cs index fb59f1938..c925398b1 100644 --- a/Projects/Scripts/Items/Addons/ElvenSpinningwheelEastAddon.cs +++ b/Projects/Scripts/Items/Addons/ElvenSpinningwheelEastAddon.cs @@ -84,10 +84,10 @@ namespace Server.Items private class SpinTimer : Timer { - private SpinCallback m_Callback; - private Mobile m_From; - private int m_Hue; - private ElvenSpinningwheelEastAddon m_Wheel; + private readonly SpinCallback m_Callback; + private readonly Mobile m_From; + private readonly int m_Hue; + private readonly ElvenSpinningwheelEastAddon m_Wheel; public SpinTimer(ElvenSpinningwheelEastAddon wheel, SpinCallback callback, Mobile from, int hue) : base( TimeSpan.FromSeconds(3.0)) diff --git a/Projects/Scripts/Items/Addons/ElvenSpinningwheelSouthAddon.cs b/Projects/Scripts/Items/Addons/ElvenSpinningwheelSouthAddon.cs index b923b12f3..3beae227f 100644 --- a/Projects/Scripts/Items/Addons/ElvenSpinningwheelSouthAddon.cs +++ b/Projects/Scripts/Items/Addons/ElvenSpinningwheelSouthAddon.cs @@ -86,10 +86,10 @@ namespace Server.Items private class SpinTimer : Timer { - private SpinCallback m_Callback; - private Mobile m_From; - private int m_Hue; - private ElvenSpinningwheelSouthAddon m_Wheel; + private readonly SpinCallback m_Callback; + private readonly Mobile m_From; + private readonly int m_Hue; + private readonly ElvenSpinningwheelSouthAddon m_Wheel; public SpinTimer(ElvenSpinningwheelSouthAddon wheel, SpinCallback callback, Mobile from, int hue) : base( TimeSpan.FromSeconds(3.0)) diff --git a/Projects/Scripts/Items/Addons/FlourMillEastAddon.cs b/Projects/Scripts/Items/Addons/FlourMillEastAddon.cs index 1bbfaef93..576ba6702 100644 --- a/Projects/Scripts/Items/Addons/FlourMillEastAddon.cs +++ b/Projects/Scripts/Items/Addons/FlourMillEastAddon.cs @@ -6,8 +6,8 @@ namespace Server.Items { public interface IFlourMill { - int MaxFlour{ get; } - int CurFlour{ get; set; } + int MaxFlour { get; } + int CurFlour { get; set; } } public enum FlourMillStage @@ -19,7 +19,7 @@ namespace Server.Items public class FlourMillEastAddon : BaseAddon, IFlourMill { - private static int[][] m_StageTable = + private static readonly int[][] m_StageTable = { new[] { 0x1920, 0x1921, 0x1925 }, new[] { 0x1922, 0x1923, 0x1926 }, @@ -87,7 +87,6 @@ namespace Server.Items { SackFlour flour = new SackFlour { ItemID = Utility.RandomBool() ? 4153 : 4165 }; - if (from.PlaceInBackpack(flour)) { m_Flour = 0; @@ -172,10 +171,10 @@ namespace Server.Items switch (version) { case 1: - { - m_Flour = reader.ReadInt(); - break; - } + { + m_Flour = reader.ReadInt(); + break; + } } UpdateStage(); diff --git a/Projects/Scripts/Items/Addons/FlourMillSouthAddon.cs b/Projects/Scripts/Items/Addons/FlourMillSouthAddon.cs index 17d005c8f..8a03c6c2a 100644 --- a/Projects/Scripts/Items/Addons/FlourMillSouthAddon.cs +++ b/Projects/Scripts/Items/Addons/FlourMillSouthAddon.cs @@ -6,7 +6,7 @@ namespace Server.Items { public class FlourMillSouthAddon : BaseAddon, IFlourMill { - private static int[][] m_StageTable = + private static readonly int[][] m_StageTable = { new[] { 0x192C, 0x192D, 0x1931 }, new[] { 0x192E, 0x192F, 0x1932 }, @@ -160,10 +160,10 @@ namespace Server.Items switch (version) { case 1: - { - m_Flour = reader.ReadInt(); - break; - } + { + m_Flour = reader.ReadInt(); + break; + } } UpdateStage(); diff --git a/Projects/Scripts/Items/Addons/JackOLantern.cs b/Projects/Scripts/Items/Addons/JackOLantern.cs index 489faab0e..422f068bf 100644 --- a/Projects/Scripts/Items/Addons/JackOLantern.cs +++ b/Projects/Scripts/Items/Addons/JackOLantern.cs @@ -6,7 +6,7 @@ namespace Server.Items { [Constructible] public JackOLantern() - : this(1 > Utility.Random(2)) + : this(Utility.Random(2) < 1) { } @@ -16,7 +16,7 @@ namespace Server.Items AddComponent(new AddonComponent(5703), 0, 0, +0); int hue = 1161; - //( 1 > Utility.Random( 5 ) ? 2118 : 1161 ); + // ( 1 > Utility.Random( 5 ) ? 2118 : 1161 ); if (!south) { @@ -63,7 +63,7 @@ namespace Server.Items int version = reader.ReadByte(); if (version == 0) - Timer.DelayCall(TimeSpan.Zero, delegate + Timer.DelayCall(TimeSpan.Zero, () => { for (int i = 0; i < Components.Count; ++i) if (Components[i] is AddonComponent ac && ac.Hue == 2118) @@ -71,7 +71,7 @@ namespace Server.Items }); if (version <= 1) - Timer.DelayCall(TimeSpan.Zero, delegate + Timer.DelayCall(TimeSpan.Zero, () => { for (int i = 0; i < Components.Count; ++i) if (Components[i] is AddonComponent ac) @@ -79,4 +79,4 @@ namespace Server.Items }); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Addons/LoomEastAddon.cs b/Projects/Scripts/Items/Addons/LoomEastAddon.cs index 5e9c2cfdf..a645ac28b 100644 --- a/Projects/Scripts/Items/Addons/LoomEastAddon.cs +++ b/Projects/Scripts/Items/Addons/LoomEastAddon.cs @@ -2,7 +2,7 @@ namespace Server.Items { public interface ILoom { - int Phase{ get; set; } + int Phase { get; set; } } public class LoomEastAddon : BaseAddon, ILoom @@ -20,7 +20,7 @@ namespace Server.Items public override BaseAddonDeed Deed => new LoomEastDeed(); - public int Phase{ get; set; } + public int Phase { get; set; } public override void Serialize(IGenericWriter writer) { @@ -40,10 +40,10 @@ namespace Server.Items switch (version) { case 1: - { - Phase = reader.ReadInt(); - break; - } + { + Phase = reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Addons/LoomSouthAddon.cs b/Projects/Scripts/Items/Addons/LoomSouthAddon.cs index f5d4ffaa7..a3b0b32bf 100644 --- a/Projects/Scripts/Items/Addons/LoomSouthAddon.cs +++ b/Projects/Scripts/Items/Addons/LoomSouthAddon.cs @@ -15,7 +15,7 @@ namespace Server.Items public override BaseAddonDeed Deed => new LoomSouthDeed(); - public int Phase{ get; set; } + public int Phase { get; set; } public override void Serialize(IGenericWriter writer) { @@ -35,10 +35,10 @@ namespace Server.Items switch (version) { case 1: - { - Phase = reader.ReadInt(); - break; - } + { + Phase = reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Addons/PickpocketDips.cs b/Projects/Scripts/Items/Addons/PickpocketDips.cs index 0a13dead7..6cf3f33b7 100644 --- a/Projects/Scripts/Items/Addons/PickpocketDips.cs +++ b/Projects/Scripts/Items/Addons/PickpocketDips.cs @@ -18,10 +18,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public double MinSkill{ get; set; } + public double MinSkill { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public double MaxSkill{ get; set; } + public double MaxSkill { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Swinging => m_Timer != null; @@ -106,18 +106,18 @@ namespace Server.Items switch (version) { case 0: - { - MinSkill = reader.ReadDouble(); - MaxSkill = reader.ReadDouble(); - - if (MinSkill == 0.0 && MaxSkill == 30.0) { - MinSkill = -25.0; - MaxSkill = +25.0; - } + MinSkill = reader.ReadDouble(); + MaxSkill = reader.ReadDouble(); - break; - } + if (MinSkill == 0.0 && MaxSkill == 30.0) + { + MinSkill = -25.0; + MaxSkill = +25.0; + } + + break; + } } UpdateItemID(); @@ -125,7 +125,7 @@ namespace Server.Items private class InternalTimer : Timer { - private PickpocketDip m_Dip; + private readonly PickpocketDip m_Dip; public InternalTimer(PickpocketDip dip) : base(TimeSpan.FromSeconds(3.0)) { diff --git a/Projects/Scripts/Items/Addons/SHTeleporter.cs b/Projects/Scripts/Items/Addons/SHTeleporter.cs index 6ae108f8f..1b3996e3f 100644 --- a/Projects/Scripts/Items/Addons/SHTeleporter.cs +++ b/Projects/Scripts/Items/Addons/SHTeleporter.cs @@ -42,7 +42,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Point3D TeleOffset{ get; set; } + public Point3D TeleOffset { get; set; } [CommandProperty(AccessLevel.GameMaster)] public Point3D TelePoint @@ -164,15 +164,15 @@ namespace Server.Items public SHTeleporter(Serial serial) : base(serial) => m_Changing = false; [CommandProperty(AccessLevel.GameMaster)] - public bool External{ get; private set; } + public bool External { get; private set; } - public SHTeleComponent UpTele{ get; private set; } + public SHTeleComponent UpTele { get; private set; } - public SHTeleComponent RightTele{ get; private set; } + public SHTeleComponent RightTele { get; private set; } - public SHTeleComponent DownTele{ get; private set; } + public SHTeleComponent DownTele { get; private set; } - public SHTeleComponent LeftTele{ get; private set; } + public SHTeleComponent LeftTele { get; private set; } public override bool ShareHue => false; diff --git a/Projects/Scripts/Items/Addons/SolenAntHole.cs b/Projects/Scripts/Items/Addons/SolenAntHole.cs index f71175d27..9527a559b 100644 --- a/Projects/Scripts/Items/Addons/SolenAntHole.cs +++ b/Projects/Scripts/Items/Addons/SolenAntHole.cs @@ -49,7 +49,6 @@ namespace Server.Items } } - public class SolenAntHole : BaseAddon { private List m_Spawned; @@ -90,7 +89,7 @@ namespace Server.Items for (int i = 0; i < count; i++) SpawnAnt(); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) SpawnAnt(new Beetle()); } } diff --git a/Projects/Scripts/Items/Addons/SpinningwheelEastAddon.cs b/Projects/Scripts/Items/Addons/SpinningwheelEastAddon.cs index 9862510a1..bb3bac255 100644 --- a/Projects/Scripts/Items/Addons/SpinningwheelEastAddon.cs +++ b/Projects/Scripts/Items/Addons/SpinningwheelEastAddon.cs @@ -6,7 +6,7 @@ namespace Server.Items public interface ISpinningWheel { - bool Spinning{ get; } + bool Spinning { get; } void BeginSpin(SpinCallback callback, Mobile from, int hue); } @@ -94,10 +94,10 @@ namespace Server.Items private class SpinTimer : Timer { - private SpinCallback m_Callback; - private Mobile m_From; - private int m_Hue; - private SpinningwheelEastAddon m_Wheel; + private readonly SpinCallback m_Callback; + private readonly Mobile m_From; + private readonly int m_Hue; + private readonly SpinningwheelEastAddon m_Wheel; public SpinTimer(SpinningwheelEastAddon wheel, SpinCallback callback, Mobile from, int hue) : base( TimeSpan.FromSeconds(3.0)) diff --git a/Projects/Scripts/Items/Addons/SpinningwheelSouthAddon.cs b/Projects/Scripts/Items/Addons/SpinningwheelSouthAddon.cs index 643f9637c..4933f7bbe 100644 --- a/Projects/Scripts/Items/Addons/SpinningwheelSouthAddon.cs +++ b/Projects/Scripts/Items/Addons/SpinningwheelSouthAddon.cs @@ -86,10 +86,10 @@ namespace Server.Items private class SpinTimer : Timer { - private SpinCallback m_Callback; - private Mobile m_From; - private int m_Hue; - private SpinningwheelSouthAddon m_Wheel; + private readonly SpinCallback m_Callback; + private readonly Mobile m_From; + private readonly int m_Hue; + private readonly SpinningwheelSouthAddon m_Wheel; public SpinTimer(SpinningwheelSouthAddon wheel, SpinCallback callback, Mobile from, int hue) : base( TimeSpan.FromSeconds(3.0)) diff --git a/Projects/Scripts/Items/Addons/TrainingDummies.cs b/Projects/Scripts/Items/Addons/TrainingDummies.cs index c61ba5f2c..375aca6a2 100644 --- a/Projects/Scripts/Items/Addons/TrainingDummies.cs +++ b/Projects/Scripts/Items/Addons/TrainingDummies.cs @@ -19,10 +19,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public double MinSkill{ get; set; } + public double MinSkill { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public double MaxSkill{ get; set; } + public double MaxSkill { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Swinging => m_Timer != null; @@ -105,18 +105,18 @@ namespace Server.Items switch (version) { case 0: - { - MinSkill = reader.ReadDouble(); - MaxSkill = reader.ReadDouble(); - - if (MinSkill == 0.0 && MaxSkill == 30.0) { - MinSkill = -25.0; - MaxSkill = +25.0; - } + MinSkill = reader.ReadDouble(); + MaxSkill = reader.ReadDouble(); - break; - } + if (MinSkill == 0.0 && MaxSkill == 30.0) + { + MinSkill = -25.0; + MaxSkill = +25.0; + } + + break; + } } UpdateItemID(); @@ -125,7 +125,7 @@ namespace Server.Items private class InternalTimer : Timer { private bool m_Delay = true; - private TrainingDummy m_Dummy; + private readonly TrainingDummy m_Dummy; public InternalTimer(TrainingDummy dummy) : base(TimeSpan.FromSeconds(0.25), TimeSpan.FromSeconds(2.75)) { diff --git a/Projects/Scripts/Items/Aquarium/Aquarium.cs b/Projects/Scripts/Items/Aquarium/Aquarium.cs index bfec0d143..4ee51b5c2 100644 --- a/Projects/Scripts/Items/Aquarium/Aquarium.cs +++ b/Projects/Scripts/Items/Aquarium/Aquarium.cs @@ -60,7 +60,7 @@ namespace Server.Items // items info [CommandProperty(AccessLevel.GameMaster)] - public int LiveCreatures{ get; private set; } + public int LiveCreatures { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public int DeadCreatures @@ -136,7 +136,7 @@ namespace Server.Items [CommandProperty(AccessLevel.GameMaster)] public bool OptimalState => m_Food.State == (int)FoodState.Full && m_Water.State == (int)WaterState.Strong; - public List Events{ get; private set; } + public List Events { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public bool RewardAvailable @@ -178,8 +178,7 @@ namespace Server.Items public virtual bool HasAccess(Mobile from) => from?.Deleted == false && ( from.AccessLevel >= AccessLevel.GameMaster || - BaseHouse.FindHouseAt(this)?.IsCoOwner(from) == true - ); + BaseHouse.FindHouseAt(this)?.IsCoOwner(from) == true); public override bool OnDragDrop(Mobile from, Item dropped) { @@ -451,38 +450,38 @@ namespace Server.Items case 3: case 2: case 1: - { - DateTime next = reader.ReadDateTime(); + { + DateTime next = reader.ReadDateTime(); - if (next < DateTime.UtcNow) - next = DateTime.UtcNow; + if (next < DateTime.UtcNow) + next = DateTime.UtcNow; - m_Timer = Timer.DelayCall(next - DateTime.UtcNow, EvaluationInterval, Evaluate); + m_Timer = Timer.DelayCall(next - DateTime.UtcNow, EvaluationInterval, Evaluate); - goto case 0; - } + goto case 0; + } case 0: - { - LiveCreatures = reader.ReadInt(); - m_VacationLeft = reader.ReadInt(); + { + LiveCreatures = reader.ReadInt(); + m_VacationLeft = reader.ReadInt(); - m_Food = new AquariumState(); - m_Water = new AquariumState(); + m_Food = new AquariumState(); + m_Water = new AquariumState(); - m_Food.Deserialize(reader); - m_Water.Deserialize(reader); + m_Food.Deserialize(reader); + m_Water.Deserialize(reader); - Events = new List(); + Events = new List(); - int count = reader.ReadInt(); + int count = reader.ReadInt(); - for (int i = 0; i < count; i++) - Events.Add(reader.ReadInt()); + for (int i = 0; i < count; i++) + Events.Add(reader.ReadInt()); - m_RewardAvailable = reader.ReadBool(); + m_RewardAvailable = reader.ReadBool(); - break; - } + break; + } } if (version < 2) @@ -511,8 +510,6 @@ namespace Server.Items RecountLiveCreatures(); } - #region Members - public int FoodNumber() { if (m_Food.State == (int)FoodState.Full) @@ -526,10 +523,6 @@ namespace Server.Items public int WaterNumber() => 1074242 + m_Water.State; - #endregion - - #region Virtual members - public virtual void KillFish(int amount) { List toKill = new List(); @@ -574,17 +567,15 @@ namespace Server.Items // food events if ( - m_Food.Added < m_Food.Maintain && m_Food.State != (int)FoodState.Overfed && - m_Food.State != (int)FoodState.Dead || - m_Food.Added >= m_Food.Improve && m_Food.State == (int)FoodState.Full - ) + (m_Food.Added < m_Food.Maintain && m_Food.State != (int)FoodState.Overfed && + m_Food.State != (int)FoodState.Dead) || + (m_Food.Added >= m_Food.Improve && m_Food.State == (int)FoodState.Full)) Events.Add(1074368); // The tank looks worse than it did yesterday. if ( - m_Food.Added >= m_Food.Improve && m_Food.State != (int)FoodState.Full && - m_Food.State != (int)FoodState.Overfed || - m_Food.Added < m_Food.Maintain && m_Food.State == (int)FoodState.Overfed - ) + (m_Food.Added >= m_Food.Improve && m_Food.State != (int)FoodState.Full && + m_Food.State != (int)FoodState.Overfed) || + (m_Food.Added < m_Food.Maintain && m_Food.State == (int)FoodState.Overfed)) Events.Add(1074367); // The tank looks healthier today. // water events @@ -613,41 +604,41 @@ namespace Server.Items switch (Utility.Random(6)) { case 0: - { - message = 1074371; // Brine shrimp have hatched overnight in the tank. - fish = new BrineShrimp(); - break; - } + { + message = 1074371; // Brine shrimp have hatched overnight in the tank. + fish = new BrineShrimp(); + break; + } case 1: - { - message = 1074365; // A new creature has hatched overnight in the tank. - fish = new Coral(); - break; - } + { + message = 1074365; // A new creature has hatched overnight in the tank. + fish = new Coral(); + break; + } case 2: - { - message = 1074365; // A new creature has hatched overnight in the tank. - fish = new FullMoonFish(); - break; - } + { + message = 1074365; // A new creature has hatched overnight in the tank. + fish = new FullMoonFish(); + break; + } case 3: - { - message = 1074373; // A sea horse has hatched overnight in the tank. - fish = new SeaHorseFish(); - break; - } + { + message = 1074373; // A sea horse has hatched overnight in the tank. + fish = new SeaHorseFish(); + break; + } case 4: - { - message = 1074365; // A new creature has hatched overnight in the tank. - fish = new StrippedFlakeFish(); - break; - } + { + message = 1074365; // A new creature has hatched overnight in the tank. + fish = new StrippedFlakeFish(); + break; + } case 5: - { - message = 1074365; // A new creature has hatched overnight in the tank. - fish = new StrippedSosarianSwill(); - break; - } + { + message = 1074365; // A new creature has hatched overnight in the tank. + fish = new StrippedSosarianSwill(); + break; + } } if (Utility.RandomDouble() < 0.05) @@ -876,16 +867,12 @@ namespace Server.Items return true; } - #endregion - - #region Static members - public static FishBowl GetEmptyBowl(Mobile from) { return from?.Backpack?.FindItemsByType().Find(bowl => bowl.Empty); } - private static Type[] m_Decorations = + private static readonly Type[] m_Decorations = { typeof(FishBones), typeof(WaterloggedBoots), @@ -912,18 +899,14 @@ namespace Server.Items return false; } - public static int[] FishHues{ get; } = + public static int[] FishHues { get; } = { 0x1C2, 0x1C3, 0x2A3, 0x47E, 0x51D }; - #endregion - - #region Context entries - private class ExamineEntry : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public ExamineEntry(Aquarium aquarium) : base(6235, 2) // Examine Aquarium => @@ -940,7 +923,7 @@ namespace Server.Items private class CollectRewardEntry : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public CollectRewardEntry(Aquarium aquarium) : base(6237, 2) // Collect Reward => @@ -957,7 +940,7 @@ namespace Server.Items private class ViewEventEntry : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public ViewEventEntry(Aquarium aquarium) : base(6239, 2) // View events => @@ -980,7 +963,7 @@ namespace Server.Items private class CancelVacationMode : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public CancelVacationMode(Aquarium aquarium) : base(6240, 2) // Cancel vacation mode => @@ -1000,7 +983,7 @@ namespace Server.Items // GM context entries private class GMAddFood : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public GMAddFood(Aquarium aquarium) : base(6231) // GM Add Food => @@ -1018,7 +1001,7 @@ namespace Server.Items private class GMAddWater : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public GMAddWater(Aquarium aquarium) : base(6232) // GM Add Water => @@ -1036,7 +1019,7 @@ namespace Server.Items private class GMForceEvaluate : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public GMForceEvaluate(Aquarium aquarium) : base(6233) // GM Force Evaluate => @@ -1053,7 +1036,7 @@ namespace Server.Items private class GMOpen : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public GMOpen(Aquarium aquarium) : base(6234) // GM Open Container => @@ -1070,7 +1053,7 @@ namespace Server.Items private class GMFill : ContextMenuEntry { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public GMFill(Aquarium aquarium) : base(6236) // GM Fill Food and Water => @@ -1086,8 +1069,6 @@ namespace Server.Items m_Aquarium.InvalidateProperties(); } } - - #endregion } public class AquariumEastDeed : BaseAddonContainerDeed diff --git a/Projects/Scripts/Items/Aquarium/AquariumGump.cs b/Projects/Scripts/Items/Aquarium/AquariumGump.cs index f3071ca2b..5f5d636f5 100644 --- a/Projects/Scripts/Items/Aquarium/AquariumGump.cs +++ b/Projects/Scripts/Items/Aquarium/AquariumGump.cs @@ -5,7 +5,7 @@ namespace Server.Items { public class AquariumGump : Gump { - private Aquarium m_Aquarium; + private readonly Aquarium m_Aquarium; public AquariumGump(Aquarium aquarium, bool edit) : base(100, 100) { diff --git a/Projects/Scripts/Items/Aquarium/AquariumState.cs b/Projects/Scripts/Items/Aquarium/AquariumState.cs index 5a5380a95..aa0159ad1 100644 --- a/Projects/Scripts/Items/Aquarium/AquariumState.cs +++ b/Projects/Scripts/Items/Aquarium/AquariumState.cs @@ -40,13 +40,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int Maintain{ get; set; } + public int Maintain { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Improve{ get; set; } + public int Improve { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Added{ get; set; } + public int Added { get; set; } public override string ToString() => "..."; diff --git a/Projects/Scripts/Items/Aquarium/FishBowl.cs b/Projects/Scripts/Items/Aquarium/FishBowl.cs index 5dd6ee05a..91166d253 100644 --- a/Projects/Scripts/Items/Aquarium/FishBowl.cs +++ b/Projects/Scripts/Items/Aquarium/FishBowl.cs @@ -133,7 +133,7 @@ namespace Server.Items private class RemoveCreature : ContextMenuEntry { - private FishBowl m_Bowl; + private readonly FishBowl m_Bowl; public RemoveCreature(FishBowl bowl) : base(6242, 3) // Remove creature => diff --git a/Projects/Scripts/Items/Armor/Artifacts/LeggingsOfBane.cs b/Projects/Scripts/Items/Armor/Artifacts/LeggingsOfBane.cs index dfd454ec5..59f79d30a 100644 --- a/Projects/Scripts/Items/Armor/Artifacts/LeggingsOfBane.cs +++ b/Projects/Scripts/Items/Armor/Artifacts/LeggingsOfBane.cs @@ -8,7 +8,7 @@ namespace Server.Items Hue = 0x4F5; ArmorAttributes.DurabilityBonus = 100; HitPoints = MaxHitPoints = - 255; //Cause the Durability bonus and such and the min/max hits as well as all other hits being whole #'s... + 255; // Cause the Durability bonus and such and the min/max hits as well as all other hits being whole #'s... Attributes.BonusStam = 8; Attributes.AttackChance = 20; } diff --git a/Projects/Scripts/Items/Armor/BaseArmor.cs b/Projects/Scripts/Items/Armor/BaseArmor.cs index 58b8edcfe..925326df6 100644 --- a/Projects/Scripts/Items/Armor/BaseArmor.cs +++ b/Projects/Scripts/Items/Armor/BaseArmor.cs @@ -19,7 +19,6 @@ namespace Server.Items private int m_HitPoints; private bool m_Identified; - /* Armor internals work differently now (Jun 19 2003) * * The attributes defined below default to -1. @@ -67,11 +66,10 @@ namespace Server.Items SkillBonuses = new AosSkillBonuses(this); } - public virtual bool AllowMaleWearer => true; public virtual bool AllowFemaleWearer => true; - public abstract AMT MaterialType{ get; } + public abstract AMT MaterialType { get; } public virtual int RevertArmorBase => ArmorBase; public virtual int ArmorBase => 0; @@ -80,7 +78,6 @@ namespace Server.Items public virtual AMA AosMedAllowance => DefMedAllowance; public virtual AMA OldMedAllowance => DefMedAllowance; - public virtual int AosStrBonus => 0; public virtual int AosDexBonus => 0; public virtual int AosIntBonus => 0; @@ -88,7 +85,6 @@ namespace Server.Items public virtual int AosDexReq => 0; public virtual int AosIntReq => 0; - public virtual int OldStrBonus => 0; public virtual int OldDexBonus => 0; public virtual int OldIntBonus => 0; @@ -252,7 +248,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool PlayerConstructed{ get; set; } + public bool PlayerConstructed { get; set; } [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource @@ -291,7 +287,6 @@ namespace Server.Items } } - [CommandProperty(AccessLevel.GameMaster)] public Mobile Crafter { @@ -303,7 +298,6 @@ namespace Server.Items } } - [CommandProperty(AccessLevel.GameMaster)] public ArmorQuality Quality { @@ -352,13 +346,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public AosAttributes Attributes{ get; private set; } + public AosAttributes Attributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosArmorAttributes ArmorAttributes{ get; private set; } + public AosArmorAttributes ArmorAttributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosSkillBonuses SkillBonuses{ get; private set; } + public AosSkillBonuses SkillBonuses { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public int PhysicalBonus @@ -459,7 +453,7 @@ namespace Server.Items } } - public static double[] ArmorScalars{ get; set; } = { 0.07, 0.07, 0.14, 0.15, 0.22, 0.35 }; + public static double[] ArmorScalars { get; set; } = { 0.07, 0.07, 0.14, 0.15, 0.22, 0.35 }; public virtual CraftResource DefaultResource => CraftResource.Iron; @@ -477,8 +471,6 @@ namespace Server.Items } } - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -499,8 +491,7 @@ namespace Server.Items if (Quality == ArmorQuality.Exceptional) { - if (!(Core.ML && this is BaseShield) - ) // Guessed Core.ML removed exceptional resist bonuses from crafted shields + if (!(Core.ML && this is BaseShield)) // Guessed Core.ML removed exceptional resist bonuses from crafted shields DistributeBonuses(tool is BaseRunicTool ? 6 : Core.SE ? 15 : 14); // Not sure since when, but right now 15 points are added, not 14. @@ -538,8 +529,6 @@ namespace Server.Items return quality; } - #endregion - public bool Scissor(Mobile from, Scissors scissors) { if (!IsChildOf(from.Backpack)) @@ -641,7 +630,7 @@ namespace Server.Items if (absorbed < 2) absorbed = 2; - if (25 > Utility.Random(100)) // 25% chance to lower durability + if (Utility.Random(100) < 25) // 25% chance to lower durability { if (Core.AOS && ArmorAttributes.SelfRepair > Utility.Random(10)) { @@ -1027,246 +1016,246 @@ namespace Server.Items case 7: case 6: case 5: - { - SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.Attributes)) - Attributes = new AosAttributes(this, reader); - else - Attributes = new AosAttributes(this); - - if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) - ArmorAttributes = new AosArmorAttributes(this, reader); - else - ArmorAttributes = new AosArmorAttributes(this); - - if (GetSaveFlag(flags, SaveFlag.PhysicalBonus)) - m_PhysicalBonus = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.FireBonus)) - m_FireBonus = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.ColdBonus)) - m_ColdBonus = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.PoisonBonus)) - m_PoisonBonus = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.EnergyBonus)) - m_EnergyBonus = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.Identified)) - m_Identified = version >= 7 || reader.ReadBool(); - - if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) - m_MaxHitPoints = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.HitPoints)) - m_HitPoints = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.Crafter)) - m_Crafter = reader.ReadMobile(); - - if (GetSaveFlag(flags, SaveFlag.Quality)) - m_Quality = (ArmorQuality)reader.ReadEncodedInt(); - else - m_Quality = ArmorQuality.Regular; - - if (version == 5 && m_Quality == ArmorQuality.Low) - m_Quality = ArmorQuality.Regular; - - if (GetSaveFlag(flags, SaveFlag.Durability)) { - m_Durability = (ArmorDurabilityLevel)reader.ReadEncodedInt(); + SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); - if (m_Durability > ArmorDurabilityLevel.Indestructible) - m_Durability = ArmorDurabilityLevel.Durable; + if (GetSaveFlag(flags, SaveFlag.Attributes)) + Attributes = new AosAttributes(this, reader); + else + Attributes = new AosAttributes(this); + + if (GetSaveFlag(flags, SaveFlag.ArmorAttributes)) + ArmorAttributes = new AosArmorAttributes(this, reader); + else + ArmorAttributes = new AosArmorAttributes(this); + + if (GetSaveFlag(flags, SaveFlag.PhysicalBonus)) + m_PhysicalBonus = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.FireBonus)) + m_FireBonus = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.ColdBonus)) + m_ColdBonus = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.PoisonBonus)) + m_PoisonBonus = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.EnergyBonus)) + m_EnergyBonus = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.Identified)) + m_Identified = version >= 7 || reader.ReadBool(); + + if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) + m_MaxHitPoints = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.HitPoints)) + m_HitPoints = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.Crafter)) + m_Crafter = reader.ReadMobile(); + + if (GetSaveFlag(flags, SaveFlag.Quality)) + m_Quality = (ArmorQuality)reader.ReadEncodedInt(); + else + m_Quality = ArmorQuality.Regular; + + if (version == 5 && m_Quality == ArmorQuality.Low) + m_Quality = ArmorQuality.Regular; + + if (GetSaveFlag(flags, SaveFlag.Durability)) + { + m_Durability = (ArmorDurabilityLevel)reader.ReadEncodedInt(); + + if (m_Durability > ArmorDurabilityLevel.Indestructible) + m_Durability = ArmorDurabilityLevel.Durable; + } + + if (GetSaveFlag(flags, SaveFlag.Protection)) + { + m_Protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); + + if (m_Protection > ArmorProtectionLevel.Invulnerability) + m_Protection = ArmorProtectionLevel.Defense; + } + + if (GetSaveFlag(flags, SaveFlag.Resource)) + m_Resource = (CraftResource)reader.ReadEncodedInt(); + else + m_Resource = DefaultResource; + + if (m_Resource == CraftResource.None) + m_Resource = DefaultResource; + + if (GetSaveFlag(flags, SaveFlag.BaseArmor)) + m_ArmorBase = reader.ReadEncodedInt(); + else + m_ArmorBase = -1; + + if (GetSaveFlag(flags, SaveFlag.StrBonus)) + m_StrBonus = reader.ReadEncodedInt(); + else + m_StrBonus = -1; + + if (GetSaveFlag(flags, SaveFlag.DexBonus)) + m_DexBonus = reader.ReadEncodedInt(); + else + m_DexBonus = -1; + + if (GetSaveFlag(flags, SaveFlag.IntBonus)) + m_IntBonus = reader.ReadEncodedInt(); + else + m_IntBonus = -1; + + if (GetSaveFlag(flags, SaveFlag.StrReq)) + m_StrReq = reader.ReadEncodedInt(); + else + m_StrReq = -1; + + if (GetSaveFlag(flags, SaveFlag.DexReq)) + m_DexReq = reader.ReadEncodedInt(); + else + m_DexReq = -1; + + if (GetSaveFlag(flags, SaveFlag.IntReq)) + m_IntReq = reader.ReadEncodedInt(); + else + m_IntReq = -1; + + if (GetSaveFlag(flags, SaveFlag.MedAllowance)) + m_Meditate = (AMA)reader.ReadEncodedInt(); + else + m_Meditate = (AMA)(-1); + + if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + SkillBonuses = new AosSkillBonuses(this, reader); + + if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) + PlayerConstructed = true; + + break; } - - if (GetSaveFlag(flags, SaveFlag.Protection)) - { - m_Protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); - - if (m_Protection > ArmorProtectionLevel.Invulnerability) - m_Protection = ArmorProtectionLevel.Defense; - } - - if (GetSaveFlag(flags, SaveFlag.Resource)) - m_Resource = (CraftResource)reader.ReadEncodedInt(); - else - m_Resource = DefaultResource; - - if (m_Resource == CraftResource.None) - m_Resource = DefaultResource; - - if (GetSaveFlag(flags, SaveFlag.BaseArmor)) - m_ArmorBase = reader.ReadEncodedInt(); - else - m_ArmorBase = -1; - - if (GetSaveFlag(flags, SaveFlag.StrBonus)) - m_StrBonus = reader.ReadEncodedInt(); - else - m_StrBonus = -1; - - if (GetSaveFlag(flags, SaveFlag.DexBonus)) - m_DexBonus = reader.ReadEncodedInt(); - else - m_DexBonus = -1; - - if (GetSaveFlag(flags, SaveFlag.IntBonus)) - m_IntBonus = reader.ReadEncodedInt(); - else - m_IntBonus = -1; - - if (GetSaveFlag(flags, SaveFlag.StrReq)) - m_StrReq = reader.ReadEncodedInt(); - else - m_StrReq = -1; - - if (GetSaveFlag(flags, SaveFlag.DexReq)) - m_DexReq = reader.ReadEncodedInt(); - else - m_DexReq = -1; - - if (GetSaveFlag(flags, SaveFlag.IntReq)) - m_IntReq = reader.ReadEncodedInt(); - else - m_IntReq = -1; - - if (GetSaveFlag(flags, SaveFlag.MedAllowance)) - m_Meditate = (AMA)reader.ReadEncodedInt(); - else - m_Meditate = (AMA)(-1); - - if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) - SkillBonuses = new AosSkillBonuses(this, reader); - - if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) - PlayerConstructed = true; - - break; - } case 4: - { - Attributes = new AosAttributes(this, reader); - ArmorAttributes = new AosArmorAttributes(this, reader); - goto case 3; - } + { + Attributes = new AosAttributes(this, reader); + ArmorAttributes = new AosArmorAttributes(this, reader); + goto case 3; + } case 3: - { - m_PhysicalBonus = reader.ReadInt(); - m_FireBonus = reader.ReadInt(); - m_ColdBonus = reader.ReadInt(); - m_PoisonBonus = reader.ReadInt(); - m_EnergyBonus = reader.ReadInt(); - goto case 2; - } + { + m_PhysicalBonus = reader.ReadInt(); + m_FireBonus = reader.ReadInt(); + m_ColdBonus = reader.ReadInt(); + m_PoisonBonus = reader.ReadInt(); + m_EnergyBonus = reader.ReadInt(); + goto case 2; + } case 2: case 1: - { - m_Identified = reader.ReadBool(); - goto case 0; - } + { + m_Identified = reader.ReadBool(); + goto case 0; + } case 0: - { - m_ArmorBase = reader.ReadInt(); - m_MaxHitPoints = reader.ReadInt(); - m_HitPoints = reader.ReadInt(); - m_Crafter = reader.ReadMobile(); - m_Quality = (ArmorQuality)reader.ReadInt(); - m_Durability = (ArmorDurabilityLevel)reader.ReadInt(); - m_Protection = (ArmorProtectionLevel)reader.ReadInt(); - - AMT mat = (AMT)reader.ReadInt(); - - if (m_ArmorBase == RevertArmorBase) - m_ArmorBase = -1; - - /*m_BodyPos = (ArmorBodyType)*/ - reader.ReadInt(); - - if (version < 4) { - Attributes = new AosAttributes(this); - ArmorAttributes = new AosArmorAttributes(this); - } + m_ArmorBase = reader.ReadInt(); + m_MaxHitPoints = reader.ReadInt(); + m_HitPoints = reader.ReadInt(); + m_Crafter = reader.ReadMobile(); + m_Quality = (ArmorQuality)reader.ReadInt(); + m_Durability = (ArmorDurabilityLevel)reader.ReadInt(); + m_Protection = (ArmorProtectionLevel)reader.ReadInt(); - if (version < 3 && m_Quality == ArmorQuality.Exceptional) - DistributeBonuses(6); + AMT mat = (AMT)reader.ReadInt(); - if (version >= 2) - { - m_Resource = (CraftResource)reader.ReadInt(); - } - else - { - var info = reader.ReadInt() switch + if (m_ArmorBase == RevertArmorBase) + m_ArmorBase = -1; + + /*m_BodyPos = (ArmorBodyType)*/ + reader.ReadInt(); + + if (version < 4) { - 0 => OreInfo.Iron, - 1 => OreInfo.DullCopper, - 2 => OreInfo.ShadowIron, - 3 => OreInfo.Copper, - 4 => OreInfo.Bronze, - 5 => OreInfo.Gold, - 6 => OreInfo.Agapite, - 7 => OreInfo.Verite, - 8 => OreInfo.Valorite, - _ => OreInfo.Iron - }; + Attributes = new AosAttributes(this); + ArmorAttributes = new AosArmorAttributes(this); + } - m_Resource = CraftResources.GetFromOreInfo(info, mat); - } + if (version < 3 && m_Quality == ArmorQuality.Exceptional) + DistributeBonuses(6); - m_StrBonus = reader.ReadInt(); - m_DexBonus = reader.ReadInt(); - m_IntBonus = reader.ReadInt(); - m_StrReq = reader.ReadInt(); - m_DexReq = reader.ReadInt(); - m_IntReq = reader.ReadInt(); - - if (m_StrBonus == OldStrBonus) - m_StrBonus = -1; - - if (m_DexBonus == OldDexBonus) - m_DexBonus = -1; - - if (m_IntBonus == OldIntBonus) - m_IntBonus = -1; - - if (m_StrReq == OldStrReq) - m_StrReq = -1; - - if (m_DexReq == OldDexReq) - m_DexReq = -1; - - if (m_IntReq == OldIntReq) - m_IntReq = -1; - - m_Meditate = (AMA)reader.ReadInt(); - - if (m_Meditate == OldMedAllowance) - m_Meditate = (AMA)(-1); - - if (m_Resource == CraftResource.None) - { - if (mat == ArmorMaterialType.Studded || mat == ArmorMaterialType.Leather) - m_Resource = CraftResource.RegularLeather; - else if (mat == ArmorMaterialType.Spined) - m_Resource = CraftResource.SpinedLeather; - else if (mat == ArmorMaterialType.Horned) - m_Resource = CraftResource.HornedLeather; - else if (mat == ArmorMaterialType.Barbed) - m_Resource = CraftResource.BarbedLeather; + if (version >= 2) + { + m_Resource = (CraftResource)reader.ReadInt(); + } else - m_Resource = CraftResource.Iron; + { + var info = reader.ReadInt() switch + { + 0 => OreInfo.Iron, + 1 => OreInfo.DullCopper, + 2 => OreInfo.ShadowIron, + 3 => OreInfo.Copper, + 4 => OreInfo.Bronze, + 5 => OreInfo.Gold, + 6 => OreInfo.Agapite, + 7 => OreInfo.Verite, + 8 => OreInfo.Valorite, + _ => OreInfo.Iron + }; + + m_Resource = CraftResources.GetFromOreInfo(info, mat); + } + + m_StrBonus = reader.ReadInt(); + m_DexBonus = reader.ReadInt(); + m_IntBonus = reader.ReadInt(); + m_StrReq = reader.ReadInt(); + m_DexReq = reader.ReadInt(); + m_IntReq = reader.ReadInt(); + + if (m_StrBonus == OldStrBonus) + m_StrBonus = -1; + + if (m_DexBonus == OldDexBonus) + m_DexBonus = -1; + + if (m_IntBonus == OldIntBonus) + m_IntBonus = -1; + + if (m_StrReq == OldStrReq) + m_StrReq = -1; + + if (m_DexReq == OldDexReq) + m_DexReq = -1; + + if (m_IntReq == OldIntReq) + m_IntReq = -1; + + m_Meditate = (AMA)reader.ReadInt(); + + if (m_Meditate == OldMedAllowance) + m_Meditate = (AMA)(-1); + + if (m_Resource == CraftResource.None) + { + if (mat == ArmorMaterialType.Studded || mat == ArmorMaterialType.Leather) + m_Resource = CraftResource.RegularLeather; + else if (mat == ArmorMaterialType.Spined) + m_Resource = CraftResource.SpinedLeather; + else if (mat == ArmorMaterialType.Horned) + m_Resource = CraftResource.HornedLeather; + else if (mat == ArmorMaterialType.Barbed) + m_Resource = CraftResource.BarbedLeather; + else + m_Resource = CraftResource.Iron; + } + + if (m_MaxHitPoints == 0 && m_HitPoints == 0) + m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); + + break; } - - if (m_MaxHitPoints == 0 && m_HitPoints == 0) - m_HitPoints = m_MaxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); - - break; - } } SkillBonuses ??= new AosSkillBonuses(this); @@ -1501,13 +1490,9 @@ namespace Server.Items if (m_Crafter != null) list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ - #region Factions - if (m_FactionState != null) list.Add(1041350); // faction item - #endregion - if (RequiredRace == Race.Elf) list.Add(1075086); // Elves Only @@ -1599,7 +1584,7 @@ namespace Server.Items if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% - base.AddResistanceProperties(list); + this.AddResistanceProperties(list); if ((prop = GetDurabilityBonus()) > 0) list.Add(1060410, prop.ToString()); // durability ~1_val~% @@ -1623,13 +1608,9 @@ namespace Server.Items attrs.Add(new EquipInfoAttribute(1049643)); // cursed } - #region Factions - if (m_FactionState != null) attrs.Add(new EquipInfoAttribute(1041350)); // faction item - #endregion - if (m_Quality == ArmorQuality.Exceptional) attrs.Add(new EquipInfoAttribute(1018305 - (int)m_Quality)); @@ -1641,8 +1622,8 @@ namespace Server.Items if (m_Protection > ArmorProtectionLevel.Regular && m_Protection <= ArmorProtectionLevel.Invulnerability) attrs.Add(new EquipInfoAttribute(1038005 + (int)m_Protection)); } - else if (m_Durability != ArmorDurabilityLevel.Regular || m_Protection > ArmorProtectionLevel.Regular && - m_Protection <= ArmorProtectionLevel.Invulnerability) + else if (m_Durability != ArmorDurabilityLevel.Regular || (m_Protection > ArmorProtectionLevel.Regular && + m_Protection <= ArmorProtectionLevel.Invulnerability)) { attrs.Add(new EquipInfoAttribute(1038000)); // Unidentified } @@ -1698,8 +1679,6 @@ namespace Server.Items PlayerConstructed = 0x01000000 } - #region Factions - private FactionItem m_FactionState; public FactionItem FactionItemState @@ -1715,7 +1694,5 @@ namespace Server.Items LootType = m_FactionState == null ? LootType.Regular : LootType.Blessed; } } - - #endregion } } diff --git a/Projects/Scripts/Items/Armor/Glasses/AnthropomorphistGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/AnthropomorphistGlasses.cs index 6d5acbc8e..08aee505e 100644 --- a/Projects/Scripts/Items/Armor/Glasses/AnthropomorphistGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/AnthropomorphistGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073379; //Anthropomorphist Reading Glasses + public override int LabelNumber => 1073379; // Anthropomorphist Reading Glasses public override int BasePhysicalResistance => 5; public override int BaseFireResistance => 5; diff --git a/Projects/Scripts/Items/Armor/Glasses/ArtsGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/ArtsGlasses.cs index 9259a1682..1c6076583 100644 --- a/Projects/Scripts/Items/Armor/Glasses/ArtsGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/ArtsGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073363; //Reading Glasses of the Arts + public override int LabelNumber => 1073363; // Reading Glasses of the Arts public override int BasePhysicalResistance => 10; public override int BaseFireResistance => 8; diff --git a/Projects/Scripts/Items/Armor/Glasses/ElvenGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/ElvenGlasses.cs index 64656111b..324b8a37d 100644 --- a/Projects/Scripts/Items/Armor/Glasses/ElvenGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/ElvenGlasses.cs @@ -36,7 +36,7 @@ namespace Server.Items public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All; [CommandProperty(AccessLevel.GameMaster)] - public AosWeaponAttributes WeaponAttributes{ get; private set; } + public AosWeaponAttributes WeaponAttributes { get; private set; } public override void AppendChildNameProperties(ObjectPropertyList list) { diff --git a/Projects/Scripts/Items/Armor/Glasses/FoldedSteelGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/FoldedSteelGlasses.cs index fc864dbbe..3a851395d 100644 --- a/Projects/Scripts/Items/Armor/Glasses/FoldedSteelGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/FoldedSteelGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073380; //Folded Steel Reading Glasses + public override int LabelNumber => 1073380; // Folded Steel Reading Glasses public override int BasePhysicalResistance => 20; public override int BaseFireResistance => 10; diff --git a/Projects/Scripts/Items/Armor/Glasses/LightOfWayGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/LightOfWayGlasses.cs index 63785a0fd..6c2b5842e 100644 --- a/Projects/Scripts/Items/Armor/Glasses/LightOfWayGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/LightOfWayGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073378; //Light Of Way Reading Glasses + public override int LabelNumber => 1073378; // Light Of Way Reading Glasses public override int BasePhysicalResistance => 10; public override int BaseFireResistance => 10; diff --git a/Projects/Scripts/Items/Armor/Glasses/LyricalGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/LyricalGlasses.cs index 401385f02..24c365f03 100644 --- a/Projects/Scripts/Items/Armor/Glasses/LyricalGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/LyricalGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073382; //Lyrical Reading Glasses + public override int LabelNumber => 1073382; // Lyrical Reading Glasses public override int BasePhysicalResistance => 10; public override int BaseFireResistance => 10; diff --git a/Projects/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs index 277014717..4ed491a7a 100644 --- a/Projects/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/MaceShieldGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073381; //Mace And Shield Reading Glasses + public override int LabelNumber => 1073381; // Mace And Shield Reading Glasses public override int BasePhysicalResistance => 25; public override int BaseFireResistance => 10; diff --git a/Projects/Scripts/Items/Armor/Glasses/MaritimeGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/MaritimeGlasses.cs index 50c39b28e..9862149e2 100644 --- a/Projects/Scripts/Items/Armor/Glasses/MaritimeGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/MaritimeGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073364; //Maritime Reading Glasses + public override int LabelNumber => 1073364; // Maritime Reading Glasses public override int BasePhysicalResistance => 3; public override int BaseFireResistance => 4; diff --git a/Projects/Scripts/Items/Armor/Glasses/NecromanticGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/NecromanticGlasses.cs index 5d7ae6fa9..3d07cc28a 100644 --- a/Projects/Scripts/Items/Armor/Glasses/NecromanticGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/NecromanticGlasses.cs @@ -15,7 +15,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073377; //Necromantic Reading Glasses + public override int LabelNumber => 1073377; // Necromantic Reading Glasses public override int BasePhysicalResistance => 0; public override int BaseFireResistance => 0; diff --git a/Projects/Scripts/Items/Armor/Glasses/PoisonedGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/PoisonedGlasses.cs index 6abd7bd17..49391e6f8 100644 --- a/Projects/Scripts/Items/Armor/Glasses/PoisonedGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/PoisonedGlasses.cs @@ -15,7 +15,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073376; //Poisoned Reading Glasses + public override int LabelNumber => 1073376; // Poisoned Reading Glasses public override int BasePhysicalResistance => 10; public override int BaseFireResistance => 10; diff --git a/Projects/Scripts/Items/Armor/Glasses/TradeGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/TradeGlasses.cs index 93f1173cd..d2f43192a 100644 --- a/Projects/Scripts/Items/Armor/Glasses/TradeGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/TradeGlasses.cs @@ -13,7 +13,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073362; //Reading Glasses of the Trades + public override int LabelNumber => 1073362; // Reading Glasses of the Trades public override int BasePhysicalResistance => 10; public override int BaseFireResistance => 10; diff --git a/Projects/Scripts/Items/Armor/Glasses/TreasureTrinketGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/TreasureTrinketGlasses.cs index d6f43cbf7..f6f5143c2 100644 --- a/Projects/Scripts/Items/Armor/Glasses/TreasureTrinketGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/TreasureTrinketGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073373; //Treasures and Trinkets Reading Glasses + public override int LabelNumber => 1073373; // Treasures and Trinkets Reading Glasses public override int BasePhysicalResistance => 10; public override int BaseFireResistance => 10; diff --git a/Projects/Scripts/Items/Armor/Glasses/WizardsGlasses.cs b/Projects/Scripts/Items/Armor/Glasses/WizardsGlasses.cs index c612feaf0..58b6203ab 100644 --- a/Projects/Scripts/Items/Armor/Glasses/WizardsGlasses.cs +++ b/Projects/Scripts/Items/Armor/Glasses/WizardsGlasses.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - public override int LabelNumber => 1073374; //Wizard's Crystal Reading Glasses + public override int LabelNumber => 1073374; // Wizard's Crystal Reading Glasses public override int BasePhysicalResistance => 5; public override int BaseFireResistance => 5; diff --git a/Projects/Scripts/Items/Armor/Leather/LeafGloves.cs b/Projects/Scripts/Items/Armor/Leather/LeafGloves.cs index 799785623..f117547dc 100644 --- a/Projects/Scripts/Items/Armor/Leather/LeafGloves.cs +++ b/Projects/Scripts/Items/Armor/Leather/LeafGloves.cs @@ -57,23 +57,21 @@ namespace Server.Items switch (version) { case 0: - { - if (reader.ReadBool()) { - m_CurArcaneCharges = reader.ReadInt(); - m_MaxArcaneCharges = reader.ReadInt(); + if (reader.ReadBool()) + { + m_CurArcaneCharges = reader.ReadInt(); + m_MaxArcaneCharges = reader.ReadInt(); - if (Hue == 2118) - Hue = ArcaneGem.DefaultArcaneHue; + if (Hue == 2118) + Hue = ArcaneGem.DefaultArcaneHue; + } + + break; } - - break; - } } } - #region Arcane Impl - private int m_MaxArcaneCharges, m_CurArcaneCharges; [CommandProperty(AccessLevel.GameMaster)] @@ -137,7 +135,5 @@ namespace Server.Items else if (ItemID == 0x317C) ItemID = 0x2FC6; } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Armor/Leather/LeatherGloves.cs b/Projects/Scripts/Items/Armor/Leather/LeatherGloves.cs index 0bbedc188..7f226cf4d 100644 --- a/Projects/Scripts/Items/Armor/Leather/LeatherGloves.cs +++ b/Projects/Scripts/Items/Armor/Leather/LeatherGloves.cs @@ -56,23 +56,21 @@ namespace Server.Items switch (version) { case 1: - { - if (reader.ReadBool()) { - m_CurArcaneCharges = reader.ReadInt(); - m_MaxArcaneCharges = reader.ReadInt(); + if (reader.ReadBool()) + { + m_CurArcaneCharges = reader.ReadInt(); + m_MaxArcaneCharges = reader.ReadInt(); - if (Hue == 2118) - Hue = ArcaneGem.DefaultArcaneHue; + if (Hue == 2118) + Hue = ArcaneGem.DefaultArcaneHue; + } + + break; } - - break; - } } } - #region Arcane Impl - private int m_MaxArcaneCharges, m_CurArcaneCharges; [CommandProperty(AccessLevel.GameMaster)] @@ -136,7 +134,5 @@ namespace Server.Items else if (ItemID == 0x13CE) ItemID = 0x13C6; } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Armor/Leather/LeatherHaidate.cs b/Projects/Scripts/Items/Armor/Leather/LeatherHaidate.cs index 5c3f27f7d..376336e52 100644 --- a/Projects/Scripts/Items/Armor/Leather/LeatherHaidate.cs +++ b/Projects/Scripts/Items/Armor/Leather/LeatherHaidate.cs @@ -26,7 +26,6 @@ namespace Server.Items public override ArmorMaterialType MaterialType => ArmorMaterialType.Leather; public override CraftResource DefaultResource => CraftResource.RegularLeather; - public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All; public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Items/Armor/Leather/LeatherNinjaMitts.cs b/Projects/Scripts/Items/Armor/Leather/LeatherNinjaMitts.cs index 208fe5fa7..2a64d5636 100644 --- a/Projects/Scripts/Items/Armor/Leather/LeatherNinjaMitts.cs +++ b/Projects/Scripts/Items/Armor/Leather/LeatherNinjaMitts.cs @@ -42,18 +42,18 @@ namespace Server.Items switch (version) { case 1: - { - if (reader.ReadBool()) { - reader.ReadInt(); - reader.ReadInt(); + if (reader.ReadBool()) + { + reader.ReadInt(); + reader.ReadInt(); + } + + Weight = 2.0; + ItemID = 0x2792; + + break; } - - Weight = 2.0; - ItemID = 0x2792; - - break; - } } } } diff --git a/Projects/Scripts/Items/Armor/Plate/FemaleWoodlandChest.cs b/Projects/Scripts/Items/Armor/Plate/FemaleWoodlandChest.cs index 717f70bcc..973aef575 100644 --- a/Projects/Scripts/Items/Armor/Plate/FemaleWoodlandChest.cs +++ b/Projects/Scripts/Items/Armor/Plate/FemaleWoodlandChest.cs @@ -1,6 +1,6 @@ namespace Server.Items { - //Is this a filler-type item? the clilocs don't match up and at a glacnce I can't find direct reference of it + // Is this a filler-type item? the clilocs don't match up and at a glacnce I can't find direct reference of it [Flippable(0x2B6D, 0x3164)] public class FemaleElvenPlateChest : BaseArmor { diff --git a/Projects/Scripts/Items/Body Parts/BonePile.cs b/Projects/Scripts/Items/Body Parts/BonePile.cs index dab766687..9de0438c2 100644 --- a/Projects/Scripts/Items/Body Parts/BonePile.cs +++ b/Projects/Scripts/Items/Body Parts/BonePile.cs @@ -19,7 +19,7 @@ namespace Server.Items if (Deleted || !from.CanSee(this)) return false; - base.ScissorHelper(from, new Bone(), Utility.RandomMinMax(10, 15)); + this.ScissorHelper(from, new Bone(), Utility.RandomMinMax(10, 15)); return true; } diff --git a/Projects/Scripts/Items/Body Parts/Head.cs b/Projects/Scripts/Items/Body Parts/Head.cs index ddd5c7d6a..71c9f96a8 100644 --- a/Projects/Scripts/Items/Body Parts/Head.cs +++ b/Projects/Scripts/Items/Body Parts/Head.cs @@ -28,10 +28,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string PlayerName{ get; set; } + public string PlayerName { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public HeadType HeadType{ get; set; } + public HeadType HeadType { get; set; } public override string DefaultName { diff --git a/Projects/Scripts/Items/Body Parts/RibCage.cs b/Projects/Scripts/Items/Body Parts/RibCage.cs index ad1b21f45..33308d991 100644 --- a/Projects/Scripts/Items/Body Parts/RibCage.cs +++ b/Projects/Scripts/Items/Body Parts/RibCage.cs @@ -19,7 +19,7 @@ namespace Server.Items if (Deleted || !from.CanSee(this)) return false; - base.ScissorHelper(from, new Bone(), Utility.RandomMinMax(3, 5)); + this.ScissorHelper(from, new Bone(), Utility.RandomMinMax(3, 5)); return true; } diff --git a/Projects/Scripts/Items/Books/BaseBook.cs b/Projects/Scripts/Items/Books/BaseBook.cs index 846f41f8c..aca3da2a0 100644 --- a/Projects/Scripts/Items/Books/BaseBook.cs +++ b/Projects/Scripts/Items/Books/BaseBook.cs @@ -11,7 +11,7 @@ namespace Server.Items { public class BookPageInfo { - public BookPageInfo() => Lines = new string[0]; + public BookPageInfo() => Lines = Array.Empty(); public BookPageInfo(params string[] lines) => Lines = lines; @@ -25,7 +25,7 @@ namespace Server.Items Lines[i] = Utility.Intern(reader.ReadString()); } - public string[] Lines{ get; set; } + public string[] Lines { get; set; } public void Serialize(IGenericWriter writer) { @@ -100,12 +100,12 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool Writable{ get; set; } + public bool Writable { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int PagesCount => Pages.Length; - public BookPageInfo[] Pages{ get; private set; } + public BookPageInfo[] Pages { get; private set; } public virtual BookContent DefaultContent => null; @@ -116,8 +116,8 @@ namespace Server.Items StringBuilder sb = new StringBuilder(); foreach (BookPageInfo bpi in Pages) - foreach (string line in bpi.Lines) - sb.AppendLine(line); + foreach (string line in bpi.Lines) + sb.AppendLine(line); return sb.ToString(); } @@ -135,12 +135,8 @@ namespace Server.Items } } - #region ISecurable Members - [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } - - #endregion + public SecureLevel Level { get; set; } public override void GetContextMenuEntries(Mobile from, List list) { @@ -168,7 +164,6 @@ namespace Server.Items if (content?.IsMatch(Pages) != true) flags |= SaveFlags.Content; - writer.Write(4); // version writer.Write((int)Level); @@ -199,72 +194,72 @@ namespace Server.Items switch (version) { case 4: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 3; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 3; + } case 3: case 2: - { - BookContent content = DefaultContent; - - SaveFlags flags = (SaveFlags)reader.ReadByte(); - - if ((flags & SaveFlags.Title) != 0) - m_Title = Utility.Intern(reader.ReadString()); - else if (content != null) - m_Title = content.Title; - - if ((flags & SaveFlags.Author) != 0) - m_Author = reader.ReadString(); - else if (content != null) - m_Author = content.Author; - - Writable = (flags & SaveFlags.Writable) != 0; - - if ((flags & SaveFlags.Content) != 0) - { - Pages = new BookPageInfo[reader.ReadEncodedInt()]; - - for (int i = 0; i < Pages.Length; ++i) - Pages[i] = new BookPageInfo(reader); - } - else - { - if (content != null) - Pages = content.Copy(); - else - Pages = new BookPageInfo[0]; - } - - break; - } - case 1: - case 0: - { - m_Title = reader.ReadString(); - m_Author = reader.ReadString(); - Writable = reader.ReadBool(); - - if (version == 0 || reader.ReadBool()) - { - Pages = new BookPageInfo[reader.ReadInt()]; - - for (int i = 0; i < Pages.Length; ++i) - Pages[i] = new BookPageInfo(reader); - } - else { BookContent content = DefaultContent; - if (content != null) - Pages = content.Copy(); - else - Pages = new BookPageInfo[0]; - } + SaveFlags flags = (SaveFlags)reader.ReadByte(); - break; - } + if ((flags & SaveFlags.Title) != 0) + m_Title = Utility.Intern(reader.ReadString()); + else if (content != null) + m_Title = content.Title; + + if ((flags & SaveFlags.Author) != 0) + m_Author = reader.ReadString(); + else if (content != null) + m_Author = content.Author; + + Writable = (flags & SaveFlags.Writable) != 0; + + if ((flags & SaveFlags.Content) != 0) + { + Pages = new BookPageInfo[reader.ReadEncodedInt()]; + + for (int i = 0; i < Pages.Length; ++i) + Pages[i] = new BookPageInfo(reader); + } + else + { + if (content != null) + Pages = content.Copy(); + else + Pages = Array.Empty(); + } + + break; + } + case 1: + case 0: + { + m_Title = reader.ReadString(); + m_Author = reader.ReadString(); + Writable = reader.ReadBool(); + + if (version == 0 || reader.ReadBool()) + { + Pages = new BookPageInfo[reader.ReadInt()]; + + for (int i = 0; i < Pages.Length; ++i) + Pages[i] = new BookPageInfo(reader); + } + else + { + BookContent content = DefaultContent; + + if (content != null) + Pages = content.Copy(); + else + Pages = Array.Empty(); + } + + break; + } } if (version < 3 && (Weight == 1 || Weight == 2)) @@ -283,13 +278,13 @@ namespace Server.Items { base.GetProperties( list ); - if ( m_Title?.Length > 0 ) + if (m_Title?.Length > 0) list.Add( 1060658, "Title\t{0}", m_Title ); // ~1_val~: ~2_val~ - if ( m_Author?.Length > 0 ) + if (m_Author?.Length > 0) list.Add( 1060659, "Author\t{0}", m_Author ); // ~1_val~: ~2_val~ - if ( m_Pages?.Length > 0 ) + if (m_Pages?.Length > 0) list.Add( 1060660, "Pages\t{0}", m_Pages.Length ); // ~1_val~: ~2_val~ }*/ @@ -425,22 +420,22 @@ namespace Server.Items { EnsureCapacity(256); - m_Stream.Write(book.Serial); - m_Stream.Write((ushort)book.PagesCount); + Stream.Write(book.Serial); + Stream.Write((ushort)book.PagesCount); for (int i = 0; i < book.PagesCount; ++i) { BookPageInfo page = book.Pages[i]; - m_Stream.Write((ushort)(i + 1)); - m_Stream.Write((ushort)page.Lines.Length); + Stream.Write((ushort)(i + 1)); + Stream.Write((ushort)page.Lines.Length); for (int j = 0; j < page.Lines.Length; ++j) { byte[] buffer = Utility.UTF8.GetBytes(page.Lines[j]); - m_Stream.Write(buffer, 0, buffer.Length); - m_Stream.Write((byte)0); + Stream.Write(buffer, 0, buffer.Length); + Stream.Write((byte)0); } } } @@ -458,18 +453,18 @@ namespace Server.Items EnsureCapacity(15 + titleBuffer.Length + authorBuffer.Length); - m_Stream.Write(book.Serial); - m_Stream.Write(true); - m_Stream.Write(book.Writable && from.InRange(book.GetWorldLocation(), 1)); - m_Stream.Write((ushort)book.PagesCount); + Stream.Write(book.Serial); + Stream.Write(true); + Stream.Write(book.Writable && from.InRange(book.GetWorldLocation(), 1)); + Stream.Write((ushort)book.PagesCount); - m_Stream.Write((ushort)(titleBuffer.Length + 1)); - m_Stream.Write(titleBuffer, 0, titleBuffer.Length); - m_Stream.Write((byte)0); // terminate + Stream.Write((ushort)(titleBuffer.Length + 1)); + Stream.Write(titleBuffer, 0, titleBuffer.Length); + Stream.Write((byte)0); // terminate - m_Stream.Write((ushort)(authorBuffer.Length + 1)); - m_Stream.Write(authorBuffer, 0, authorBuffer.Length); - m_Stream.Write((byte)0); // terminate + Stream.Write((ushort)(authorBuffer.Length + 1)); + Stream.Write(authorBuffer, 0, authorBuffer.Length); + Stream.Write((byte)0); // terminate } } } diff --git a/Projects/Scripts/Items/Books/Defined/BlackthornWelcomeBook.cs b/Projects/Scripts/Items/Books/Defined/BlackthornWelcomeBook.cs index 3b4652492..19726b58c 100644 --- a/Projects/Scripts/Items/Books/Defined/BlackthornWelcomeBook.cs +++ b/Projects/Scripts/Items/Books/Defined/BlackthornWelcomeBook.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class BlackthornWelcomeBook : RedBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "A Welcome", "Lord Blackthorn", - new BookPageInfo - ( + new BookPageInfo( " Greetings to you,", "new member of the", "Trusted.", @@ -14,10 +12,8 @@ namespace Server.Items "words because you", "have been deemed", "worthy to join the", - "ranks of" - ), - new BookPageInfo - ( + "ranks of"), + new BookPageInfo( "Britannia's defenders.", "Some will call you a", "betrayer of mankind, I", @@ -25,10 +21,8 @@ namespace Server.Items "misguided. I call you", "a defender for Sosaria", "needs saving from", - "itself." - ), - new BookPageInfo - ( + "itself."), + new BookPageInfo( " The forces of order", "once ruled our world.", "Like a great", @@ -36,10 +30,8 @@ namespace Server.Items "lives we lived under", "the oppressive watch", "of a king who", - "dictated our actions" - ), - new BookPageInfo - ( + "dictated our actions"), + new BookPageInfo( "and passed judgment", "on our character. He", "suppressed our way of", @@ -47,10 +39,8 @@ namespace Server.Items "freedom and the", "ability to determine", "who we are and what", - "we stand for. Even" - ), - new BookPageInfo - ( + "we stand for. Even"), + new BookPageInfo( "today in the absence", "of this man we still", "see the symbol of his", @@ -58,10 +48,8 @@ namespace Server.Items "personal guards patrol", "the cities to", "intimidate us, and we", - "feel his laws like a" - ), - new BookPageInfo - ( + "feel his laws like a"), + new BookPageInfo( "vice on our lives.", " You are here", "because you choose to", @@ -69,10 +57,8 @@ namespace Server.Items "Britannians you have", "felt the oppression of", "one man's ideas", - "weighing down upon" - ), - new BookPageInfo - ( + "weighing down upon"), + new BookPageInfo( "you like chains. You", "have felt the embrace", "of fear, wondering if", @@ -80,10 +66,8 @@ namespace Server.Items "for simply having", "ideas not in harmony", "with those forced upon", - "you. You have seen" - ), - new BookPageInfo - ( + "you. You have seen"), + new BookPageInfo( "men fight and die for", "the principles of a", "zealot and wondered,", @@ -91,10 +75,8 @@ namespace Server.Items "my principles should", "they be opposed?'", "You tire of living", - "under the shadow of" - ), - new BookPageInfo - ( + "under the shadow of"), + new BookPageInfo( "dreams that do not", "belong to you. And", "most of all, you have", @@ -102,10 +84,8 @@ namespace Server.Items "can do to live free.", " Your journey to", "freedom begins here.", - " I, like you, once" - ), - new BookPageInfo - ( + " I, like you, once"), + new BookPageInfo( "desired my freedom", "from the limits placed", "on me. I watched in", @@ -113,10 +93,8 @@ namespace Server.Items "became engrossed with", "the preaching of", "virtue and none of the", - "practice. I held my" - ), - new BookPageInfo - ( + "practice. I held my"), + new BookPageInfo( "convictions in check,", "fearful of the reaction", "of men blinded by", @@ -124,10 +102,8 @@ namespace Server.Items "myself to bury the", "very ideology that", "made me an individual.", - "I was fortunate that" - ), - new BookPageInfo - ( + "I was fortunate that"), + new BookPageInfo( "a being of unique", "power and", "unimaginable", @@ -135,10 +111,8 @@ namespace Server.Items "through to the true", "person I was, the", "person I was meant to", - "be. Exodus found" - ), - new BookPageInfo - ( + "be. Exodus found"), + new BookPageInfo( "within me a man of", "free will,", "determination, and", @@ -146,10 +120,8 @@ namespace Server.Items "the plight of", "oppression forced on so", "many Britannians.", - " Exodus has also" - ), - new BookPageInfo - ( + " Exodus has also"), + new BookPageInfo( "chosen you because of", "the strength of your", "character.", @@ -157,10 +129,8 @@ namespace Server.Items "who were once my", "peers look upon me", "and see a betrayer of", - "humanity. They" - ), - new BookPageInfo - ( + "humanity. They"), + new BookPageInfo( "claim my newfound", "form is unnatural and", "wrong. Because they", @@ -168,10 +138,8 @@ namespace Server.Items "me, they show fear.", "They disapprove of", "my choices and in", - "their ignorance see" - ), - new BookPageInfo - ( + "their ignorance see"), + new BookPageInfo( "evil. Yet I hide my", "true self no longer", "from these men. My", @@ -179,10 +147,8 @@ namespace Server.Items "personal morality have", "been liberated in the", "face of the oppression", - "that once consumed me." - ), - new BookPageInfo - ( + "that once consumed me."), + new BookPageInfo( "Where they see a", "man no longer human.", "I see a man that has", @@ -190,10 +156,8 @@ namespace Server.Items "humanity but has been", "freed from it. This", "is the power that has", - "been granted to me by" - ), - new BookPageInfo - ( + "been granted to me by"), + new BookPageInfo( "Exodus. I have been", "given my freedom. I", "have been released", @@ -201,10 +165,8 @@ namespace Server.Items " Exodus will give", "you the power to", "conquer your fears as", - "well." - ), - new BookPageInfo - ( + "well."), + new BookPageInfo( " When your fear", "of this world is gone,", "then the world truly", @@ -212,10 +174,8 @@ namespace Server.Items "way it never has", "before. You, trusted", "one, will soon be given", - "a gift. Your body," - ), - new BookPageInfo - ( + "a gift. Your body,"), + new BookPageInfo( "like mine, will be", "enlightened and raised", "to a level no mortal", @@ -223,10 +183,8 @@ namespace Server.Items "to control your own", "destiny will belong to", "you for the first time", - "in your life." - ), - new BookPageInfo - ( + "in your life."), + new BookPageInfo( " You will, at long", "last, be cleansed of", "fear.", @@ -234,10 +192,8 @@ namespace Server.Items "power of Exodus", "behind us, we shall", "finally wage war on", - "the oppression that" - ), - new BookPageInfo - ( + "the oppression that"), + new BookPageInfo( "once held us back", "from our full", "potential. We shall", @@ -245,10 +201,8 @@ namespace Server.Items "reshape it in an image", "of freedom for all of", "us. Those who once", - "told you who you are" - ), - new BookPageInfo - ( + "told you who you are"), + new BookPageInfo( "and how you should", "live will no longer be", "able to stand in the", @@ -256,14 +210,10 @@ namespace Server.Items "Many say you will", "be abandoning your", "humanity but in truth,", - "you will be more than" - ), - new BookPageInfo - ( + "you will be more than"), + new BookPageInfo( "human.", - " You will be freed." - ) - ); + " You will be freed.")); [Constructible] public BlackthornWelcomeBook() : base(false) => Hue = 0x89B; diff --git a/Projects/Scripts/Items/Books/Defined/BookContent.cs b/Projects/Scripts/Items/Books/Defined/BookContent.cs index 7f5e865e6..48d3cd25a 100644 --- a/Projects/Scripts/Items/Books/Defined/BookContent.cs +++ b/Projects/Scripts/Items/Books/Defined/BookContent.cs @@ -9,11 +9,11 @@ namespace Server.Items Pages = pages; } - public string Title{ get; } + public string Title { get; } - public string Author{ get; } + public string Author { get; } - public BookPageInfo[] Pages{ get; } + public BookPageInfo[] Pages { get; } public BookPageInfo[] Copy() { diff --git a/Projects/Scripts/Items/Books/Defined/DrakovsJournal.cs b/Projects/Scripts/Items/Books/Defined/DrakovsJournal.cs index e74a2f450..67f6c2865 100644 --- a/Projects/Scripts/Items/Books/Defined/DrakovsJournal.cs +++ b/Projects/Scripts/Items/Books/Defined/DrakovsJournal.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class DrakovsJournal : BlueBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Drakov's Journal", "Drakov", - new BookPageInfo - ( + new BookPageInfo( "My Master", "", "This journal was", @@ -14,18 +12,14 @@ namespace Server.Items "our controllers. It", "seems he has lost", "faith in you. Know", - "that he has been" - ), - new BookPageInfo - ( + "that he has been"), + new BookPageInfo( "dealth with and will", "never again speak", "ill of you or our", "cause.", - " -Galzon" - ), - new BookPageInfo - ( + " -Galzon"), + new BookPageInfo( "We have completted", "construction of the", "devices needed to", @@ -33,10 +27,8 @@ namespace Server.Items "overseers and minions", "as per the request of", "the Master. The", - "gargoyles have been" - ), - new BookPageInfo - ( + "gargoyles have been"), + new BookPageInfo( "most useful and their", "knowledge of the", "techniques for the", @@ -44,10 +36,8 @@ namespace Server.Items "creatures will serve", "us well.", " -----", - "I am not one to" - ), - new BookPageInfo - ( + "I am not one to"), + new BookPageInfo( "criticize the Master,", "but I believe he may", "have erred in his", @@ -55,10 +45,8 @@ namespace Server.Items "the wingless ones.", "Already our forces", "are weakened by the", - "constant attacks of" - ), - new BookPageInfo - ( + "constant attacks of"), + new BookPageInfo( "the humans Their", "strength and", "unquestioning", @@ -66,10 +54,8 @@ namespace Server.Items "have made them very", "useful in the fight", "against the humans.", - "But the Master felt" - ), - new BookPageInfo - ( + "But the Master felt"), + new BookPageInfo( "their presence to be", "an annoyance and", "a distraction to the", @@ -77,10 +63,8 @@ namespace Server.Items "not difficult at all", "to remove them from", "this world. But now", - "I fear without more" - ), - new BookPageInfo - ( + "I fear without more"), + new BookPageInfo( "allies, willing or", "not, we stand", "little chance of", @@ -88,15 +72,11 @@ namespace Server.Items "humans from our", "lands. Perhaps if", "the Master had", - "shown a little" - ), - new BookPageInfo - ( + "shown a little"), + new BookPageInfo( "mercy and forsight", "we would not be", - "in such dire peril." - ) - ); + "in such dire peril.")); [Constructible] public DrakovsJournal() : base(false) diff --git a/Projects/Scripts/Items/Books/Defined/FropozJournal.cs b/Projects/Scripts/Items/Books/Defined/FropozJournal.cs index e0db95720..aa43f6e78 100644 --- a/Projects/Scripts/Items/Books/Defined/FropozJournal.cs +++ b/Projects/Scripts/Items/Books/Defined/FropozJournal.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class FropozJournal : RedBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal", "Fropoz", - new BookPageInfo - ( + new BookPageInfo( "I have done as my", "Master has", "instructed me.", @@ -14,10 +12,8 @@ namespace Server.Items "The painted humans", "have been driven into", "Britannia and are even", - "now wreaking havoc" - ), - new BookPageInfo - ( + "now wreaking havoc"), + new BookPageInfo( "across the land,", "providing us with the", "distraction my Master", @@ -25,10 +21,8 @@ namespace Server.Items "have provided them", "with the masks", "necessary to defeat", - "the orcs, thus" - ), - new BookPageInfo - ( + "the orcs, thus"), + new BookPageInfo( "causing even more", "distress for the people", "of Britannia. The", @@ -36,10 +30,8 @@ namespace Server.Items "are too busy dealing", "with the orc hordes to", "continue their", - "exploration of our" - ), - new BookPageInfo - ( + "exploration of our"), + new BookPageInfo( "lands. We are", "safe...for now.", " ----", @@ -47,10 +39,8 @@ namespace Server.Items "continue exactly as", "planned. My Master", "is pleased with my", - "work and we are" - ), - new BookPageInfo - ( + "work and we are"), + new BookPageInfo( "closer to our goals than", "ever before. The", "gargoyles have proven", @@ -58,10 +48,8 @@ namespace Server.Items "than we first", "anticipated, but I", "believe we can", - "subjugate them fully" - ), - new BookPageInfo - ( + "subjugate them fully"), + new BookPageInfo( "given enough time. It's", "unfortunate that we", "did not discover their", @@ -69,10 +57,8 @@ namespace Server.Items "Even now they", "prepare our armies", "for battle, but not", - "without resistance." - ), - new BookPageInfo - ( + "without resistance."), + new BookPageInfo( "Now that some of", "them know of the", "other lands and of", @@ -80,10 +66,8 @@ namespace Server.Items "double their efforts to", "seek help. This", "cannot be allowed.", - " -----" - ), - new BookPageInfo - ( + " -----"), + new BookPageInfo( "Damn them!! The", "humans proved", "more resourcefull than", @@ -91,10 +75,8 @@ namespace Server.Items "capable of. Already", "their homes are free", "of orcs and savages", - "and they once again" - ), - new BookPageInfo - ( + "and they once again"), + new BookPageInfo( "are treading in our", "lands. We may have to", "move sooner than we", @@ -102,10 +84,8 @@ namespace Server.Items "prepar my brethern", "and our golems.", "Hopefully, we can", - "buy our Master some" - ), - new BookPageInfo - ( + "buy our Master some"), + new BookPageInfo( "more time before the", "humans discover us.", " -----", @@ -113,10 +93,8 @@ namespace Server.Items "gargoyles whom have", "evaded our capture", "have opened the doors", - "to our land." - ), - new BookPageInfo - ( + "to our land."), + new BookPageInfo( "They pray the", "humans will help", "them, despite the", @@ -124,22 +102,16 @@ namespace Server.Items "cousins in Britannia. I", "fear they are right.", "I must go to warn", - "the MastKai Hohiro," - ), - new BookPageInfo - ( - ), - new BookPageInfo - ( + "the MastKai Hohiro,"), + new BookPageInfo(), + new BookPageInfo( "10.11.2001", "first one to be here", "", "Congrats. I didn't really", "care to log on earlier,", "nor did I come straight", - "here. 2pm, Magus" - ) - ); + "here. 2pm, Magus")); [Constructible] public FropozJournal() : base(false) diff --git a/Projects/Scripts/Items/Books/Defined/KaburJournal.cs b/Projects/Scripts/Items/Books/Defined/KaburJournal.cs index 4b30bc912..5f1a7beb9 100644 --- a/Projects/Scripts/Items/Books/Defined/KaburJournal.cs +++ b/Projects/Scripts/Items/Books/Defined/KaburJournal.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class KaburJournal : RedBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Journal", "Kabur", - new BookPageInfo - ( + new BookPageInfo( "The campaign to slaughter", "the Meer goes well.", "Although they seem to", @@ -14,10 +12,8 @@ namespace Server.Items "ours at every turn, we", "still defeat them in", "combat. Spies of the", - "Meer have been found and" - ), - new BookPageInfo - ( + "Meer have been found and"), + new BookPageInfo( "slain outside of the", "fortress of ours. The", "fools underestimate us.", @@ -25,10 +21,8 @@ namespace Server.Items "Lord Exodus behind us.", "Soon they will learn to", "serve the Juka and I", - "shall carry the head of" - ), - new BookPageInfo - ( + "shall carry the head of"), + new BookPageInfo( "the wench, Dasha, on a", "spike for all the warriors", "of ours to share triumph", @@ -36,10 +30,8 @@ namespace Server.Items "", "One of the warriors of", "the Juka died today.", - "During the training" - ), - new BookPageInfo - ( + "During the training"), + new BookPageInfo( "exercises of ours he", "spoke out in favor of", "the warriors of the", @@ -47,10 +39,8 @@ namespace Server.Items "were indeed powerful and", "would provide a challenge", "to the Juka. A Juka in", - "fear is no Juka. I gave" - ), - new BookPageInfo - ( + "fear is no Juka. I gave"), + new BookPageInfo( "him the death of a", "coward, outside of battle.", "", @@ -58,10 +48,8 @@ namespace Server.Items "have been found around", "the fortress of ours.", "Many have been seen and", - "escaped the wrath of the" - ), - new BookPageInfo - ( + "escaped the wrath of the"), + new BookPageInfo( "warriors of ours. Those", "who have been captured", "and tortured have", @@ -69,10 +57,8 @@ namespace Server.Items "even when subjected to", "the spells of the females.", " I know the Meer must", - "have plans against us if" - ), - new BookPageInfo - ( + "have plans against us if"), + new BookPageInfo( "they send so many spies.", " I may send the troops", "of the Juka to invade", @@ -80,10 +66,8 @@ namespace Server.Items "warning.", "", "I have met Dasha in", - "battle this day. The" - ), - new BookPageInfo - ( + "battle this day. The"), + new BookPageInfo( "efforts of hers to draw", "me into a Black Duel", "were foolish. Had we", @@ -91,10 +75,8 @@ namespace Server.Items "the cave I would have", "ended the life of hers", "but I will have to wait", - "for another battle. Lord" - ), - new BookPageInfo - ( + "for another battle. Lord"), + new BookPageInfo( "Exodus has ordered more", "patrols around the", "fortress of ours. If", @@ -102,10 +84,8 @@ namespace Server.Items "the Meer will strike soon.", "", "More Meer stand outside", - "of the fortress of ours" - ), - new BookPageInfo - ( + "of the fortress of ours"), + new BookPageInfo( "than I have ever seen at", "once. They must seek", "vengeance for the", @@ -113,10 +93,8 @@ namespace Server.Items "forest. Many Juka stand", "ready at the base of the", "mountain to face the", - "forces of theirs but" - ), - new BookPageInfo - ( + "forces of theirs but"), + new BookPageInfo( "today may be the final", "battle. Exodus has", "summoned me, I must", @@ -124,10 +102,8 @@ namespace Server.Items "", "Dusk has passed and the", "Juka now live in a new", - "age, a later time. I have" - ), - new BookPageInfo - ( + "age, a later time. I have"), + new BookPageInfo( "just returned from", "exploring the new world", "that surrounds the", @@ -135,10 +111,8 @@ namespace Server.Items "During the attack of the", "Meer the madman", "Adranath tried to destroy", - "the fortress of ours" - ), - new BookPageInfo - ( + "the fortress of ours"), + new BookPageInfo( "with great magic. At", "once he was still and", "light surrounded the", @@ -146,10 +120,8 @@ namespace Server.Items "faded from view. When I", "regained the senses of", "mine I saw no sign of", - "the Meer but Dasha." - ), - new BookPageInfo - ( + "the Meer but Dasha."), + new BookPageInfo( "She has not been found", "since this new being,", "Blackthorn, blasted her", @@ -157,10 +129,8 @@ namespace Server.Items "fortress.", "The forest was gone, now", "replaced by grasslands.", - "In the far distance I" - ), - new BookPageInfo - ( + "In the far distance I"), + new BookPageInfo( "could see humans that", "had covered the bodies of", "theirs in marks. Even", @@ -168,10 +138,8 @@ namespace Server.Items "place. Exodus has", "explained to me that the", "Juka and the fortress of", - "ours have been pulled" - ), - new BookPageInfo - ( + "ours have been pulled"), + new BookPageInfo( "forward in time. The", "world we knew is now", "thousands of years in the", @@ -179,20 +147,16 @@ namespace Server.Items "he has has saved the", "Juka from extinction. I", "do not want to believe", - "him. I asked this" - ), - new BookPageInfo - ( + "him. I asked this"), + new BookPageInfo( "stranger about the Meer,", "but he tells me a new", "enemy remains to be", "destroyed. It seems the", "enemies of ours have", "passed away to dust like", - "the forest." - ), - new BookPageInfo - ( + "the forest."), + new BookPageInfo( "I have spoken with other", "Juka and I suspect I have", "been told the truth. All", @@ -200,10 +164,8 @@ namespace Server.Items "dreams. In the dreams", "of ours the Meer invaded", "the fortress of ours and", - "a great battle took place." - ), - new BookPageInfo - ( + "a great battle took place."), + new BookPageInfo( " All the Juka and all the", "Meer perished and the", "fortress was destroyed", @@ -211,10 +173,8 @@ namespace Server.Items "would not like to believe", "that the Meer could ever", "destroy us, but now it", - "seems we have seen a" - ), - new BookPageInfo - ( + "seems we have seen a"), + new BookPageInfo( "vision of the fate of", "ours now lost in time. I", "must now wonder if the", @@ -222,9 +182,7 @@ namespace Server.Items "battle with the Juka, how", "did they die? And more", "importantly, where is", - "Dasha?" - ) - ); + "Dasha?")); [Constructible] public KaburJournal() : base(false) diff --git a/Projects/Scripts/Items/Books/Defined/LibraryBooks.cs b/Projects/Scripts/Items/Books/Defined/LibraryBooks.cs index b25ab32c4..290f22564 100644 --- a/Projects/Scripts/Items/Books/Defined/LibraryBooks.cs +++ b/Projects/Scripts/Items/Books/Defined/LibraryBooks.cs @@ -1,14 +1,10 @@ namespace Server.Items { - #region A Grammar of Orcish - public class GrammarOfOrcish : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "A Grammar of Orcish", "Yorick of Yew", - new BookPageInfo - ( + new BookPageInfo( "This volume, and", "others in the series,", "are sponsored by", @@ -16,10 +12,8 @@ namespace Server.Items "Blackthorn, ever a", "supporter of", "understanding the", - "other sentient races" - ), - new BookPageInfo - ( + "other sentient races"), + new BookPageInfo( "of Britannia.", "-", "", @@ -27,10 +21,8 @@ namespace Server.Items "may fall unpleasingly", "'pon the ear, yet it", "has within it a", - "complex grammar oft" - ), - new BookPageInfo - ( + "complex grammar oft"), + new BookPageInfo( "misunderstood by", "those who merely", "hear the few broken", @@ -38,10 +30,8 @@ namespace Server.Items "orcish brothers", "manage without", "education.", - " These are the basic" - ), - new BookPageInfo - ( + " These are the basic"), + new BookPageInfo( "rules of orcish:", " Orcish has five", "tenses: present, past,", @@ -49,10 +39,8 @@ namespace Server.Items "present interjectional,", "and prehensile.", " Examples: gugroflu,", - "gugrofloog, gugrobo," - ), - new BookPageInfo - ( + "gugrofloog, gugrobo,"), + new BookPageInfo( "gugroglu!, gugrogug.", " All transitive verbs", "in the prehensile", @@ -60,10 +48,8 @@ namespace Server.Items " Examples:", "urgleighug,", "biggugdaghgug,", - "curdakalmug." - ), - new BookPageInfo - ( + "curdakalmug."), + new BookPageInfo( " All present", "interjectional", "conjugations start", @@ -71,10 +57,8 @@ namespace Server.Items "unless the contain the", "third declensive", "accent of the letter U.", - " Examples:" - ), - new BookPageInfo - ( + " Examples:"), + new BookPageInfo( "ghothudunglug, but not", "azhbuugub.", " The past tense can", @@ -82,10 +66,8 @@ namespace Server.Items "since the last meal,", "but the prehensile", "tense can refer to", - "any event within" - ), - new BookPageInfo - ( + "any event within"), + new BookPageInfo( "reach.", " The present tense", "is conjugated like the", @@ -93,10 +75,8 @@ namespace Server.Items "tense, when the", "interrogative mode is", "used by pitching the", - "sound a quarter-tone" - ), - new BookPageInfo - ( + "sound a quarter-tone"), + new BookPageInfo( "higher.", "Orcish hath no", "concept of person, as", @@ -104,10 +84,8 @@ namespace Server.Items "person, I, we, etc.", " Orcish grammar", "relies upon the three", - "cardinal rules of" - ), - new BookPageInfo - ( + "cardinal rules of"), + new BookPageInfo( "accretion, prefixing,", "and agglutination, in", "addition to pitch. In", @@ -115,10 +93,8 @@ namespace Server.Items "combine into larger", "words which may", "contain full phrasal", - "significance. In the" - ), - new BookPageInfo - ( + "significance. In the"), + new BookPageInfo( "second, prefixing", "specific phonetic", "sounds changes the", @@ -126,10 +102,8 @@ namespace Server.Items "sentence into object,", "interrogative,", "addressed individual,", - "or dinner." - ), - new BookPageInfo - ( + "or dinner."), + new BookPageInfo( " Agglutination occurs", "whenever four of the", "same letter are", @@ -137,10 +111,8 @@ namespace Server.Items "which case, any two", "of them may be", "removed or slurred.", - " Pitch changes the" - ), - new BookPageInfo - ( + " Pitch changes the"), + new BookPageInfo( "phoneme value of", "individual syllables,", "thus completely", @@ -148,10 +120,8 @@ namespace Server.Items "may mean. The", "classic example is", "\"Aktgluthugrot", - "bigglogubuu" - ), - new BookPageInfo - ( + "bigglogubuu"), + new BookPageInfo( "dargilgaglug lublublub\"", "which can mean \"You", "are such a pretty", @@ -159,10 +129,8 @@ namespace Server.Items "your primroses,\" or", "\"Jellyfish nose paints", "alms potato,\"", - "depending on pitch." - ), - new BookPageInfo - ( + "depending on pitch."), + new BookPageInfo( " Orcish poetry often", "relies upon repeating", "the same phrase in", @@ -170,10 +138,8 @@ namespace Server.Items "changing pitch", "midword. None of", "this great art is", - "translatable." - ), - new BookPageInfo - ( + "translatable."), + new BookPageInfo( " The orcish language", "uses the following", "vowels: ab, ad, ag, akt,", @@ -181,10 +147,8 @@ namespace Server.Items "i, o, oo, u, uu. The", "vowel sound a is not", "recognized as a vowel", - "and does not exist in" - ), - new BookPageInfo - ( + "and does not exist in"), + new BookPageInfo( "their alphabet.", "The orcish alphabet is", "best learned using the", @@ -192,10 +156,8 @@ namespace Server.Items "repeated at 23", "different pitches:", " Lugnog ghu blat", - "suggaroglug," - ), - new BookPageInfo - ( + "suggaroglug,"), + new BookPageInfo( "Gaghbuu dakdar ab", "highugbo,", " Gothnogbuim ad", @@ -203,10 +165,8 @@ namespace Server.Items "Bilgeaugh thurggulg", "stuiggro!", "", - "A translation of the" - ), - new BookPageInfo - ( + "A translation of the"), + new BookPageInfo( "first pitch:", "Eat food, the first", "letter is ab,", @@ -214,10 +174,8 @@ namespace Server.Items "is ad,", "I forget the rest", "But augh is in there", - "somewhere!" - ), - new BookPageInfo - ( + "somewhere!"), + new BookPageInfo( "", " What follows is a", "complete phonetic", @@ -225,10 +183,8 @@ namespace Server.Items "language:", "ab, ad, ag, akt, alm,", "at, augh, auh, azh,", - "ba, ba, bag, bar, baz," - ), - new BookPageInfo - ( + "ba, ba, bag, bar, baz,"), + new BookPageInfo( "bid, bilge, bo, bog, bog,", "brui, bu, buad, bug,", "bug, buil, buim, bum,", @@ -236,10 +192,8 @@ namespace Server.Items "car, clog, cro, cuk,", "cur, da, dagh, dagh,", "dak, dar, deak, der,", - "dil, dit, dor, dre, dri," - ), - new BookPageInfo - ( + "dil, dit, dor, dre, dri,"), + new BookPageInfo( "dru, du, dud, duf,", "dug, dug, duh, dun,", "eag, eg, egg, eichel,", @@ -247,10 +201,8 @@ namespace Server.Items "fid, flu, fog, foo,", "foz, fruk, fu, fub,", "fud, fun, fup, fur,", - "gaa, gag, gagh, gan," - ), - new BookPageInfo - ( + "gaa, gag, gagh, gan,"), + new BookPageInfo( "gar, gh, gha, ghat,", "ghed, ghig, gho, ghu,", "gig, gil, gka, glu, glu,", @@ -258,9 +210,7 @@ namespace Server.Items "gol, gom, goth, grunt,", "grut, gu, gub, gub,", "gug, gug, gugh, guk,", - "guk," - ) - ); + "guk,")); [Constructible] public GrammarOfOrcish() : base(Utility.Random(0xFEF, 2), false) @@ -288,17 +238,11 @@ namespace Server.Items } } - #endregion - - #region A Politic Call to Anarchy - public class CallToAnarchy : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "A Politic Call to Anarchy", "Lord Blackthorn", - new BookPageInfo - ( + new BookPageInfo( " Let it never be said", "that I have aught as", "quarrel with my liege", @@ -306,10 +250,8 @@ namespace Server.Items "indeed we be of the", "best of friends,", "sharing amicable", - "games of chess 'pon a" - ), - new BookPageInfo - ( + "games of chess 'pon a"), + new BookPageInfo( "winter's night, and", "talking at length into", "the wee hours of the", @@ -317,10 +259,8 @@ namespace Server.Items "realm of Britannia.", " Yet true friendship", "doth not prevent true", - "philosophical" - ), - new BookPageInfo - ( + "philosophical"), + new BookPageInfo( "disagreement either.", "While I view with", "approval my lord's", @@ -328,10 +268,8 @@ namespace Server.Items "carefully crafted", "philosophy of the", "Eight Virtues,", - "wherein moral" - ), - new BookPageInfo - ( + "wherein moral"), + new BookPageInfo( "behavior is", "encouraged in the", "populace, I view with", @@ -339,10 +277,8 @@ namespace Server.Items "expenditure of public", "funds upon the", "construction of", - "\"shrines\" to said" - ), - new BookPageInfo - ( + "\"shrines\" to said"), + new BookPageInfo( "ideals.", " The issue is not one", "of funds, however,", @@ -350,10 +286,8 @@ namespace Server.Items "most intellectual over", "the proper way of", "humankind in an", - "ethical sense. Surely" - ), - new BookPageInfo - ( + "ethical sense. Surely"), + new BookPageInfo( "freedom of decision", "must be regarded as", "paramount in any", @@ -361,10 +295,8 @@ namespace Server.Items "Though none fail to", "censure the", "murderer, a subtler", - "question arises when" - ), - new BookPageInfo - ( + "question arises when"), + new BookPageInfo( "we ask if his", "behavior would be", "ethical if he were", @@ -372,10 +304,8 @@ namespace Server.Items " I say to thee, the", "reader, quite flatly,", "that no ethical system", - "shall have sway over" - ), - new BookPageInfo - ( + "shall have sway over"), + new BookPageInfo( "me unless it", "convinceth me, for", "that freely made", @@ -383,10 +313,8 @@ namespace Server.Items "sign that the system", "hath validity.", " Whereas the system", - "of \"Virtues\" that my" - ), - new BookPageInfo - ( + "of \"Virtues\" that my"), + new BookPageInfo( "liege espouses is", "indeed a compilation", "of commonly approved", @@ -394,10 +322,8 @@ namespace Server.Items "it. Where it seeks to", "control the populace", "and restrict their", - "diversity and their" - ), - new BookPageInfo - ( + "diversity and their"), + new BookPageInfo( "range of behaviors, I", "quarrel with it. And", "thus do I issue this", @@ -405,10 +331,8 @@ namespace Server.Items "whilst humbly", "begging forgiveness", "of Lord British for", - "my impertinence:" - ), - new BookPageInfo - ( + "my impertinence:"), + new BookPageInfo( " Celebrate thy", "differences. Take", "thy actions according", @@ -416,10 +340,8 @@ namespace Server.Items "Question from what", "source a law, a rule,", "a judge, and a virtue", - "may arise. 'Twere" - ), - new BookPageInfo - ( + "may arise. 'Twere"), + new BookPageInfo( "possible (though I", "suggest it not", "seriously) that a", @@ -427,10 +349,8 @@ namespace Server.Items "seed of these", "\"Virtues\" in my Lord", "British's mind; 'twere", - "possible that the" - ), - new BookPageInfo - ( + "possible that the"), + new BookPageInfo( "Shrines were but a", "plan to destroy this", "world. Thou canst not", @@ -438,10 +358,8 @@ namespace Server.Items "questioneth, doubteth,", "and in the end,", "unless thou relyest", - "upon THYSELF and" - ), - new BookPageInfo - ( + "upon THYSELF and"), + new BookPageInfo( "thy judgement.", " I offer these words", "as mere philosophical", @@ -449,15 +367,11 @@ namespace Server.Items "who seek", "enlightenment, for", "'tis the issue that", - "hath occupied mine" - ), - new BookPageInfo - ( + "hath occupied mine"), + new BookPageInfo( "interest and that of", "Lord British for", - "some time now." - ) - ); + "some time now.")); [Constructible] public CallToAnarchy() : base(Utility.Random(0xFEF, 2), false) @@ -485,17 +399,11 @@ namespace Server.Items } } - #endregion - - #region A Primer on Arms and Weapons - public class ArmsAndWeaponsPrimer : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "A Primer on Arms and Weapons", "Martin", - new BookPageInfo - ( + new BookPageInfo( " These are the", "basic elements to", "consider in assessing", @@ -503,10 +411,8 @@ namespace Server.Items "all warriors who", "regard themselves as", "more than mere", - "mercenaries should be" - ), - new BookPageInfo - ( + "mercenaries should be"), + new BookPageInfo( "aware.", " First and most", "obvious is the amount", @@ -514,10 +420,8 @@ namespace Server.Items "weapon may do", "against unprotected", "flesh. While 'tis this", - "which first attracts" - ), - new BookPageInfo - ( + "which first attracts"), + new BookPageInfo( "the attention of the", "novice, 'tis a deadly", "mistake to regard it", @@ -525,10 +429,8 @@ namespace Server.Items "weapon. While it may", "prove devastating", "indeed as a means of", - "causing damage, a" - ), - new BookPageInfo - ( + "causing damage, a"), + new BookPageInfo( "weapon must also", "serve as stout shield", "when engaged in", @@ -536,10 +438,8 @@ namespace Server.Items " Hence the second", "issue to which to pay", "attention is the", - "amount of protection" - ), - new BookPageInfo - ( + "amount of protection"), + new BookPageInfo( "that a weapon may", "offer. Pay close", "attention to the guard", @@ -547,10 +447,8 @@ namespace Server.Items "or the stoutness of", "its wood if it is a pole", "arm.", - " Oft related to this" - ), - new BookPageInfo - ( + " Oft related to this"), + new BookPageInfo( "is the weight of the", "weapon, for a heavy", "weapon is more", @@ -558,10 +456,8 @@ namespace Server.Items "to block with, though", "it may do more", "damage to thy", - "opponent." - ), - new BookPageInfo - ( + "opponent."), + new BookPageInfo( " If a weapon is too", "heavy for the wielder", "to move it freely,", @@ -569,10 +465,8 @@ namespace Server.Items "another and not", "attempt to prove their", "prowess by the size", - "of their sword." - ), - new BookPageInfo - ( + "of their sword."), + new BookPageInfo( " The reach of a", "weapon both increases", "its defensive ability,", @@ -580,10 +474,8 @@ namespace Server.Items "useful in open spaces", "as it allows attack", "against the opponent", - "without the need to" - ), - new BookPageInfo - ( + "without the need to"), + new BookPageInfo( "close. But be aware of", "the limitations of thy", "weapon! For a", @@ -591,10 +483,8 @@ namespace Server.Items "reach may be useless", "in close quarters, for", "lack of space to", - "maneuver it. Should" - ), - new BookPageInfo - ( + "maneuver it. Should"), + new BookPageInfo( "that dagger-wielding", "enemy close on thee", "and thy halberd, 'tis", @@ -602,10 +492,8 @@ namespace Server.Items " Lastly, a factor", "that must always be", "considered is the", - "condition of the" - ), - new BookPageInfo - ( + "condition of the"), + new BookPageInfo( "weapon. It might be a", "wondrous magical", "blade of surpassing", @@ -613,10 +501,8 @@ namespace Server.Items "leap to block blows", "with a mind of its", "own. It also might be", - "of such flimsy" - ), - new BookPageInfo - ( + "of such flimsy"), + new BookPageInfo( "construction, or", "damaged to such an", "extent, that the first", @@ -624,10 +510,8 @@ namespace Server.Items "steel, 'twill shatter", "into useless shards.", " Seek ye a good", - "blacksmith should thy" - ), - new BookPageInfo - ( + "blacksmith should thy"), + new BookPageInfo( "weapon become", "damaged, but be", "aware that their", @@ -635,10 +519,8 @@ namespace Server.Items "simply make the", "matter worse.", " While mages of", - "some ability oft create" - ), - new BookPageInfo - ( + "some ability oft create"), + new BookPageInfo( "magical weapons", "which enhance skill,", "are preternaturally", @@ -646,10 +528,8 @@ namespace Server.Items "the enemy as they", "fall, to my mind the", "greatest gift that they", - "can grant a stout" - ), - new BookPageInfo - ( + "can grant a stout"), + new BookPageInfo( "sword is to make it", "resistant to damage,", "for thy own skill can", @@ -657,15 +537,11 @@ namespace Server.Items "difference. Except", "for the fireball, but", "if the corpse is", - "charred, then so will" - ), - new BookPageInfo - ( + "charred, then so will"), + new BookPageInfo( "be the possessions,", "which maketh looting", - "difficult!" - ) - ); + "difficult!")); [Constructible] public ArmsAndWeaponsPrimer() : base(Utility.Random(0xFEF, 2), false) @@ -693,17 +569,11 @@ namespace Server.Items } } - #endregion - - #region A Song of Samlethe - public class SongOfSamlethe : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "A Song of Samlethe", "Sandra", - new BookPageInfo - ( + new BookPageInfo( "The first bear did", "swim by day,", "And it did sleep by", @@ -711,10 +581,8 @@ namespace Server.Items "It kept itself within", "its cave", "and ate by starry", - "light." - ), - new BookPageInfo - ( + "light."), + new BookPageInfo( "", "The second bear it did", "cavort", @@ -722,10 +590,8 @@ namespace Server.Items "trees,", "And danced its", "strange bearish sort", - "Of joy for all to see." - ), - new BookPageInfo - ( + "Of joy for all to see."), + new BookPageInfo( "", "The first bear, well,", "'twas hunted,", @@ -733,10 +599,8 @@ namespace Server.Items "floor.", "Its ruggish face has", "been dented", - "By footfalls and the" - ), - new BookPageInfo - ( + "By footfalls and the"), + new BookPageInfo( "door.", "", "The second bear did", @@ -744,10 +608,8 @@ namespace Server.Items "Into a mushroom ring,", "And now does dance", "the dunce", - "For wisps and" - ), - new BookPageInfo - ( + "For wisps and"), + new BookPageInfo( "unseen things.", "", "So do not dance, and", @@ -755,13 +617,9 @@ namespace Server.Items "Or else be led astray!", "For bears all end up", "six feet deep", - "At the end of" - ), - new BookPageInfo - ( - "Samlethe's day." - ) - ); + "At the end of"), + new BookPageInfo( + "Samlethe's day.")); [Constructible] public SongOfSamlethe() : base(Utility.Random(0xFEF, 2), false) @@ -789,17 +647,11 @@ namespace Server.Items } } - #endregion - - #region A Tale of Three Tribes - public class TaleOfThreeTribes : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "A Tale of Three Tribes", "Janet, Scribe", - new BookPageInfo - ( + new BookPageInfo( " The dungeon known", "as Despise is in fact", "not a dungeon as", @@ -807,10 +659,8 @@ namespace Server.Items "large natural cave.", "Inhospitable and", "unfriendly to", - "visitors, it is filled" - ), - new BookPageInfo - ( + "visitors, it is filled"), + new BookPageInfo( "with damp spots", "where the deadly", "Exploding Red Spotted", @@ -818,10 +668,8 @@ namespace Server.Items "abundance.", " According to the", "oldest of historical", - "texts, in days gone" - ), - new BookPageInfo - ( + "texts, in days gone"), + new BookPageInfo( "by the cave was once", "the home of three", "separate tribes who", @@ -829,10 +677,8 @@ namespace Server.Items "accommodation with", "each other. Oddly", "enough, the three", - "tribes were of" - ), - new BookPageInfo - ( + "tribes were of"), + new BookPageInfo( "dragons, lizard men,", "and rat men. While", "today few except", @@ -840,10 +686,8 @@ namespace Server.Items "with Lord Blackthorn", "regard these latter", "two as being", - "intelligent beings," - ), - new BookPageInfo - ( + "intelligent beings,"), + new BookPageInfo( "apparently they have", "indeed fallen from a", "more evolved state", @@ -851,10 +695,8 @@ namespace Server.Items " 'Tis said that these", "three races did dwell", "in relative harmony", - "within the vast cave," - ), - new BookPageInfo - ( + "within the vast cave,"), + new BookPageInfo( "building when they", "required it, and", "trading amongst", @@ -862,10 +704,8 @@ namespace Server.Items " But over time,", "something happened,", "and they were forced", - "to withdraw from" - ), - new BookPageInfo - ( + "to withdraw from"), + new BookPageInfo( "their society, until", "today thou mayst", "find individuals of", @@ -873,10 +713,8 @@ namespace Server.Items "the dungeon, but", "never again as a", "civilization.", - " 'Tis also said that" - ), - new BookPageInfo - ( + " 'Tis also said that"), + new BookPageInfo( "someday the three", "tribes may return to", "Despise, to once again", @@ -884,10 +722,8 @@ namespace Server.Items " Until then, nothing", "remains as token of", "this save an oddly", - "intelligent skeleton," - ), - new BookPageInfo - ( + "intelligent skeleton,"), + new BookPageInfo( "magically enchanted,", "that doth speak when", "questions are asked,", @@ -895,16 +731,12 @@ namespace Server.Items "obtained these tales", "one day, when I was", "pursued by evil", - "monsters and fled" - ), - new BookPageInfo - ( + "monsters and fled"), + new BookPageInfo( "into his skeletal arms.", " Fortunately, I", "escaped and lived to", - "write it all down!" - ) - ); + "write it all down!")); [Constructible] public TaleOfThreeTribes() : base(Utility.Random(0xFEF, 2), false) @@ -932,17 +764,11 @@ namespace Server.Items } } - #endregion - - #region Beltran's Guide to Guilds - public class GuideToGuilds : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Beltran's Guide to Guilds", "Beltran", - new BookPageInfo - ( + new BookPageInfo( " This reference", "work is intended", "merely to serve as", @@ -950,30 +776,24 @@ namespace Server.Items "curious as to the full", "range of trades and", "societies extant in", - "Britannia and nearby" - ), - new BookPageInfo - ( + "Britannia and nearby"), + new BookPageInfo( "nations. For each", "trade or guild, their", "blazon is given.", "", " Armourer's Guild.", "Gold bar above black", - "bar." - ), - new BookPageInfo - ( + "bar."), + new BookPageInfo( " Association of", "Warriors. Blue cross", "on a red field.", "", " Barters' Guild.", "Green and white", - "stripes, diagonal." - ), - new BookPageInfo - ( + "stripes, diagonal."), + new BookPageInfo( " Blacksmith's Guild.", "Gold alongside black.", "", @@ -981,20 +801,16 @@ namespace Server.Items "Rogues and Beggars.", "Red above black.", "", - " Fighters and" - ), - new BookPageInfo - ( + " Fighters and"), + new BookPageInfo( "Footmen. Blue", "horzontal bar on red", "field.", "", " Guild of Archers.", "A gold swath parting", - "red and blue." - ), - new BookPageInfo - ( + "red and blue."), + new BookPageInfo( " Guild of", "Armaments. Swath of", "gold on black field,", @@ -1002,10 +818,8 @@ namespace Server.Items "", " Guild of Assassins.", "Black and red", - "quartered." - ), - new BookPageInfo - ( + "quartered."), + new BookPageInfo( "", " Guild of Barbers.", "Red and white", @@ -1013,10 +827,8 @@ namespace Server.Items "", " Guild of Cavalry and", "Horse. Vertical blue", - "on a red field." - ), - new BookPageInfo - ( + "on a red field."), + new BookPageInfo( "", " Guild of", "Fishermen. Blue and", @@ -1024,10 +836,8 @@ namespace Server.Items "", " Guild of Mages.", "Purple and blue, in a", - "crossed pennant" - ), - new BookPageInfo - ( + "crossed pennant"), + new BookPageInfo( "pattern.", "", " Guild of", @@ -1035,20 +845,16 @@ namespace Server.Items "bar above green bar.", "", " Guild of Sorcery. A", - "field divided" - ), - new BookPageInfo - ( + "field divided"), + new BookPageInfo( "diagonally in blue and", "purple.", "", " Healers Guild. Gold", "swath dividing green", "from purple, gold", - "accents." - ), - new BookPageInfo - ( + "accents."), + new BookPageInfo( " Lord British's", "Healers of Virtue.", "Golden ankh on dark", @@ -1056,10 +862,8 @@ namespace Server.Items "", " Masters of Illusion.", "Blue and purple", - "checkers." - ), - new BookPageInfo - ( + "checkers."), + new BookPageInfo( "", " Merchants' Guild.", "Gold coins on green", @@ -1067,10 +871,8 @@ namespace Server.Items "", " Mining Cooperative.", "A gold cross,", - "quartering blue and" - ), - new BookPageInfo - ( + "quartering blue and"), + new BookPageInfo( "black.", "", " Order of Engineers.", @@ -1078,20 +880,16 @@ namespace Server.Items "vertical.", "", " Sailors' Maritime", - "Association. A white" - ), - new BookPageInfo - ( + "Association. A white"), + new BookPageInfo( "bar centered on a blue", "field.", "", " Seamen's Chapter.", "Blue and white in a", "crossed pennant", - "pattern." - ), - new BookPageInfo - ( + "pattern."), + new BookPageInfo( " Society of Cooks and", "Chefs. White and red", "diagonal fields", @@ -1099,10 +897,8 @@ namespace Server.Items "field.", "", " Society of", - "Shipwrights. White" - ), - new BookPageInfo - ( + "Shipwrights. White"), + new BookPageInfo( "diagonal above blue.", "", " Society of Thieves.", @@ -1110,10 +906,8 @@ namespace Server.Items "stripes.", "", " Society of", - "Weaponsmakers. Gold" - ), - new BookPageInfo - ( + "Weaponsmakers. Gold"), + new BookPageInfo( "diagonal above black.", "", " Tailor's Hall. Purple", @@ -1121,17 +915,13 @@ namespace Server.Items "", " The Bardic", "Collegium. Purple and", - "red checkers on gold" - ), - new BookPageInfo - ( + "red checkers on gold"), + new BookPageInfo( "field.", "", " Traders' Guild.", "White bar centered", - "down green field." - ) - ); + "down green field.")); [Constructible] public GuideToGuilds() : base(Utility.Random(0xFEF, 2), false) @@ -1159,17 +949,11 @@ namespace Server.Items } } - #endregion - - #region Birds of Britannia - public class BirdsOfBritannia : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Birds of Britannia", "Thom the Heathen", - new BookPageInfo - ( + new BookPageInfo( " The WREN is a", "tiny insect-eating", "bird with a loud voice.", @@ -1177,10 +961,8 @@ namespace Server.Items "of Wrens are", "extraordinarily", "varied and melodious.", - " The SWALLOW" - ), - new BookPageInfo - ( + " The SWALLOW"), + new BookPageInfo( "is easily recognized", "by its forked tail.", "Swallows catch", @@ -1188,10 +970,8 @@ namespace Server.Items "have squeaky,", "twittering songs.", " The WARBLER is", - "an exceptional singer," - ), - new BookPageInfo - ( + "an exceptional singer,"), + new BookPageInfo( "whose extensive", "songs combine the", "best qualities of", @@ -1199,10 +979,8 @@ namespace Server.Items " The NUTHATCH", "climbs down trees", "head first, searching", - "for insects in the" - ), - new BookPageInfo - ( + "for insects in the"), + new BookPageInfo( "bark. It sings a", "repetitive series of", "notes with a nasal", @@ -1210,10 +988,8 @@ namespace Server.Items " The agile", "CHICKADEE has a", "buzzy", - "\"chick-a-dee-dee\"" - ), - new BookPageInfo - ( + "\"chick-a-dee-dee\""), + new BookPageInfo( "call, from which its", "name is derived. Its", "song is a series of", @@ -1221,10 +997,8 @@ namespace Server.Items " The THRUSH is a", "brown bird with a", "spotted breast, which", - "eats worms and" - ), - new BookPageInfo - ( + "eats worms and"), + new BookPageInfo( "snails, and has a", "beautiful singing", "voice. Thrushes use", @@ -1232,10 +1006,8 @@ namespace Server.Items "smash the shells of", "snails.", " The little", - "NIGHTINGALE is" - ), - new BookPageInfo - ( + "NIGHTINGALE is"), + new BookPageInfo( "also known for its", "beautiful song, which", "it sings even at night.", @@ -1243,10 +1015,8 @@ namespace Server.Items "is a small dark bird", "with a yellow bill and", "a squeaky,", - "high-pitched song." - ), - new BookPageInfo - ( + "high-pitched song."), + new BookPageInfo( "Starlings can mimic", "the sounds of other", "birds.", @@ -1254,10 +1024,8 @@ namespace Server.Items "sings a series of", "high-pitched", "melodious trills in", - "flight." - ), - new BookPageInfo - ( + "flight."), + new BookPageInfo( " The FINCH is a", "small seed-eating bird", "with a conical beak", @@ -1265,10 +1033,8 @@ namespace Server.Items "warbling song.", " The CROSSBILL", "is a kind of Finch", - "with a strange" - ), - new BookPageInfo - ( + "with a strange"), + new BookPageInfo( "crossed bill, which it", "uses to extract seeds", "from pine cones.", @@ -1276,10 +1042,8 @@ namespace Server.Items "kind of Finch that is", "often kept as a pet.", "Miners would often", - "take Canaries" - ), - new BookPageInfo - ( + "take Canaries"), + new BookPageInfo( "underground with", "them, to warn them", "of the presence of", @@ -1287,10 +1051,8 @@ namespace Server.Items "the air.", " The SPARROW", "weaves a nest of", - "grass, and has an" - ), - new BookPageInfo - ( + "grass, and has an"), + new BookPageInfo( "unmusical chirp for a", "voice.", " The TOWHEE is a", @@ -1298,10 +1060,8 @@ namespace Server.Items "continually reminds", "listeners to drink", "their tea.", - " The SHRIKE is a" - ), - new BookPageInfo - ( + " The SHRIKE is a"), + new BookPageInfo( "gray bird with a", "hooked bill. Shrikes", "have the habit of", @@ -1309,10 +1069,8 @@ namespace Server.Items "on thorns.", " The", "WOODPECKER has a", - "pointed beak that is" - ), - new BookPageInfo - ( + "pointed beak that is"), + new BookPageInfo( "suitable for pecking at", "wood to get at the", "insects inside.", @@ -1320,10 +1078,8 @@ namespace Server.Items "KINGFISHER dives", "for fish, which it", "catches with its long,", - "pointed beak." - ), - new BookPageInfo - ( + "pointed beak."), + new BookPageInfo( " The TERN", "migrates over great", "distances, from one", @@ -1331,10 +1087,8 @@ namespace Server.Items "the other each year.", "Terns dive from the", "air to catch fish.", - " The PLOVER is a" - ), - new BookPageInfo - ( + " The PLOVER is a"), + new BookPageInfo( "bird that distracts", "predators by", "pretending to have a", @@ -1342,10 +1096,8 @@ namespace Server.Items " The LAPWING is", "a kind of Plover that", "has a long black crest.", - " The HAWK is a" - ), - new BookPageInfo - ( + " The HAWK is a"), + new BookPageInfo( "predator that feeds on", "small birds, mice,", "squirrels, and other", @@ -1353,10 +1105,8 @@ namespace Server.Items "hawks are known as", "Kites.", " The DOVE is a", - "seed-eating bird with" - ), - new BookPageInfo - ( + "seed-eating bird with"), + new BookPageInfo( "a peaceful reputation.", " Doves have a", "low-pitched cooing", @@ -1364,10 +1114,8 @@ namespace Server.Items " The PARROT is a", "brightly colored bird", "with a hooked bill,", - "favored as a" - ), - new BookPageInfo - ( + "favored as a"), + new BookPageInfo( "companion by pirates.", " Parrots can be", "taught to imitate the", @@ -1375,10 +1123,8 @@ namespace Server.Items " The CUCKOO is a", "devious bird that lays", "eggs in the nests of", - "Warblers and other" - ), - new BookPageInfo - ( + "Warblers and other"), + new BookPageInfo( "small birds. Cuckoos", "have the uncanny", "ability to keep track", @@ -1386,10 +1132,8 @@ namespace Server.Items "at the beginning of", "each hour.", " The", - "ROADRUNNER is" - ), - new BookPageInfo - ( + "ROADRUNNER is"), + new BookPageInfo( "an unusual bird with", "a long tail, which", "runs swiftly along", @@ -1397,10 +1141,8 @@ namespace Server.Items "for lizards and", "snakes.", " The SWIFT is a", - "very agile bird that" - ), - new BookPageInfo - ( + "very agile bird that"), + new BookPageInfo( "spends nearly its", "entire life in the air.", "With their mouths", @@ -1408,10 +1150,8 @@ namespace Server.Items "capture insects in", "mid-flight.", " The", - "HUMMINGBIRD is a" - ), - new BookPageInfo - ( + "HUMMINGBIRD is a"), + new BookPageInfo( "cross between a", "Swift and a Fairy.", "These tiny, brightly", @@ -1419,10 +1159,8 @@ namespace Server.Items "magically near", "flowers, and live on", "the nectar they", - "provide." - ), - new BookPageInfo - ( + "provide."), + new BookPageInfo( " The OWL is a", "reputedly wise bird", "that is active at night,", @@ -1430,10 +1168,8 @@ namespace Server.Items "Owls have excellent", "night vision and", "low-pitched hooting", - "calls. Their wings" - ), - new BookPageInfo - ( + "calls. Their wings"), + new BookPageInfo( "are silent in flight.", " The", "GOATSUCKER is a", @@ -1441,10 +1177,8 @@ namespace Server.Items "that is thought to live", "on the milk of goats.", "These mysterious", - "birds make jarring" - ), - new BookPageInfo - ( + "birds make jarring"), + new BookPageInfo( "sounds at night, for", "which reason they", "are also called", @@ -1452,10 +1186,8 @@ namespace Server.Items " The DUCK is a", "bird that swims more", "often than it flies,", - "and has a nasal voice" - ), - new BookPageInfo - ( + "and has a nasal voice"), + new BookPageInfo( "that is described as a", "\"quack\".", " The SWAN is a", @@ -1463,14 +1195,10 @@ namespace Server.Items "Duck that is all white.", " Swans are usually", "voiceless, but they", - "are said to have an" - ), - new BookPageInfo - ( + "are said to have an"), + new BookPageInfo( "extraordinarily", - "beautiful song." - ) - ); + "beautiful song.")); [Constructible] public BirdsOfBritannia() : base(Utility.Random(0xFEF, 2), false) @@ -1498,17 +1226,11 @@ namespace Server.Items } } - #endregion - - #region Britannian Flora: A Casual Guide - public class BritannianFlora : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Britannian Flora: A Casual Guide", "Herbert the Lost", - new BookPageInfo - ( + new BookPageInfo( " Oft 'pon rambling", "through the woods", "avoiding bears have I", @@ -1516,10 +1238,8 @@ namespace Server.Items "whose like I have", "never seen before,", "and concluded that I", - "was a blithering idiot" - ), - new BookPageInfo - ( + "was a blithering idiot"), + new BookPageInfo( "for failing to notice it", "in the past. Equally", "as oft have I", @@ -1527,10 +1247,8 @@ namespace Server.Items "worse idiot for not", "running faster from", "the bear.", - " While not all my" - ), - new BookPageInfo - ( + " While not all my"), + new BookPageInfo( "readers may share", "my proclivities for", "tree-climbing, it", @@ -1538,10 +1256,8 @@ namespace Server.Items "mayhap mine", "information might", "serve some humble", - "purpose." - ), - new BookPageInfo - ( + "purpose."), + new BookPageInfo( " The two most", "unique flowering", "plants in the", @@ -1549,10 +1265,8 @@ namespace Server.Items "countryside are the", "orfleur and the", "whiteflower, also", - "called white horns." - ), - new BookPageInfo - ( + "called white horns."), + new BookPageInfo( " The orfleur is", "notable for its", "massive orange-red", @@ -1560,10 +1274,8 @@ namespace Server.Items "dwarf marigolds like", "the sun dwarfs your", "common fireball spell.", - "The odor of said" - ), - new BookPageInfo - ( + "The odor of said"), + new BookPageInfo( "blooms is best", "described as", "peppermint-apple,", @@ -1571,10 +1283,8 @@ namespace Server.Items "'Tis a popular potted", "plant despite, or", "perhaps because of,", - "its exotic nature." - ), - new BookPageInfo - ( + "its exotic nature."), + new BookPageInfo( " Whiteflowers exude", "a subtle fragrance not", "unlike that of freshly", @@ -1582,10 +1292,8 @@ namespace Server.Items "with cool lemon ice.", "Their tall stands", "always droop with the", - "heavy weight of the" - ), - new BookPageInfo - ( + "heavy weight of the"), + new BookPageInfo( "massive blooms, oft", "as large as a child's", "head.", @@ -1593,10 +1301,8 @@ namespace Server.Items "large that one may", "scoop out the pollen in", "handfuls, and during", - "the spring season" - ), - new BookPageInfo - ( + "the spring season"), + new BookPageInfo( "many a prank hath", "been played by idle", "boys 'pon their", @@ -1604,10 +1310,8 @@ namespace Server.Items "said pollen into their", "clothing drawers,", "causing sneezes for", - "days." - ), - new BookPageInfo - ( + "days."), + new BookPageInfo( " The most", "interesting native tree", "to Britannia is the", @@ -1615,10 +1319,8 @@ namespace Server.Items "reason for its naming", "is obscure, but may", "have to do with the", - "twisted gray stalks" - ), - new BookPageInfo - ( + "twisted gray stalks"), + new BookPageInfo( "from which the", "spherical canopy", "sprouts. 'Tis", @@ -1626,10 +1328,8 @@ namespace Server.Items "misnomer to term", "these \"trunks\" as", "they are spindly and", - "flexible. Spider trees" - ), - new BookPageInfo - ( + "flexible. Spider trees"), + new BookPageInfo( "provide a fresh,", "piney smell to a room", "and are therefore", @@ -1637,10 +1337,8 @@ namespace Server.Items " In jungle climes,", "one finds the blade", "plant, whose sharp", - "leaves oft collect" - ), - new BookPageInfo - ( + "leaves oft collect"), + new BookPageInfo( "water for the thirsty", "traveler, yet can", "draw blood easily.", @@ -1648,10 +1346,8 @@ namespace Server.Items "if you can call a", "fungus such, is the", "Exploding Red Spotted", - "Toadstool. No pattern" - ), - new BookPageInfo - ( + "Toadstool. No pattern"), + new BookPageInfo( "can be discerned to", "its habitats save", "malice, for merely", @@ -1659,10 +1355,8 @@ namespace Server.Items "the cap exploding", "with powder, noxious", "gas, and tiny painful", - "pellets flying in all" - ), - new BookPageInfo - ( + "pellets flying in all"), + new BookPageInfo( "directions.", "Unfortunately, 'tis", "impossible to tell it", @@ -1670,10 +1364,8 @@ namespace Server.Items "Ordinary Red Spotted", "Toadstool save through", "experimentation.", - " Truly odd among the" - ), - new BookPageInfo - ( + " Truly odd among the"), + new BookPageInfo( "varied flora of", "Britannia, however,", "are those which bear", @@ -1681,10 +1373,8 @@ namespace Server.Items "our tongue. Among", "these I name the", "Tuscany pine (for I", - "have never seen a" - ), - new BookPageInfo - ( + "have never seen a"), + new BookPageInfo( "region of this world", "named Tuscany), the", "o'hii tree, whose very", @@ -1692,19 +1382,15 @@ namespace Server.Items "some tropical isle, and", "the welsh poppy,", "which while", - "different from the" - ), - new BookPageInfo - ( + "different from the"), + new BookPageInfo( "ordinary poppy in", "color and appearance,", "is prefaced with the", "odd word \"welsh,\"", "which as far as I", "know means to forgo", - "paying a debt." - ) - ); + "paying a debt.")); [Constructible] public BritannianFlora() : base(Utility.Random(0xFEF, 2), false) @@ -1732,17 +1418,11 @@ namespace Server.Items } } - #endregion - - #region Classic Children's Tales, Volume 2 - public class ChildrenTalesVol2 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Classic Children's Tales, Volume 2", "Guilhem, Editor", - new BookPageInfo - ( + new BookPageInfo( "Clarke's Printery", "is Honored to", "Present Tales from", @@ -1750,10 +1430,8 @@ namespace Server.Items " Guilhem the", "Scholar Shall End", "EachVolume with", - "Staid Commentary." - ), - new BookPageInfo - ( + "Staid Commentary."), + new BookPageInfo( "", "THE RHYME", "Dance in the Star", @@ -1761,10 +1439,8 @@ namespace Server.Items "And Dance in the Pit", "And Eat of your", "Entrees", - "In the Glass House" - ), - new BookPageInfo - ( + "In the Glass House"), + new BookPageInfo( "you Sit", "", "COMMENTARY", @@ -1772,10 +1448,8 @@ namespace Server.Items "rhyme for little", "babies, 'tis thought", "that this little ditty is", - "part of the corpus of" - ), - new BookPageInfo - ( + "part of the corpus of"), + new BookPageInfo( "legendary tales", "regarding the world", "before Sosaria (see", @@ -1783,10 +1457,8 @@ namespace Server.Items "of Fabio the Poor for", "fictionalized versions", "of these stories, also", - "available from this" - ), - new BookPageInfo - ( + "available from this"), + new BookPageInfo( "same publisher).", " According to these", "old tales, which", @@ -1794,10 +1466,8 @@ namespace Server.Items "hills and remote", "villages where Lord", "British is as yet a", - "distant and mythical" - ), - new BookPageInfo - ( + "distant and mythical"), + new BookPageInfo( "ruler, the gods of old", "(a fanciful notion!)", "met to discuss the", @@ -1805,10 +1475,8 @@ namespace Server.Items "the world in mystical", "rooms. A simple", "analysis reveals these", - "rooms to be mere" - ), - new BookPageInfo - ( + "rooms to be mere"), + new BookPageInfo( "mythological", "generalizations.", " \"The Star", @@ -1816,10 +1484,8 @@ namespace Server.Items "reference to the sky.", "\"The Pit\" is certainly", "an Underworld", - "analogous to the" - ), - new BookPageInfo - ( + "analogous to the"), + new BookPageInfo( "Snakehills of other", "tales, and \"the Glass", "House\" is no doubt the", @@ -1827,10 +1493,8 @@ namespace Server.Items "which the gods", "observed their", "creation. All is simple", - "when seen from this" - ), - new BookPageInfo - ( + "when seen from this"), + new BookPageInfo( "perspective, leaving", "only the mysterious", "reference to dinners.", @@ -1838,12 +1502,8 @@ namespace Server.Items "rhyme is universally", "used only for", "midnight feedings,", - "never during the day." - ), - new BookPageInfo - ( - ) - ); + "never during the day."), + new BookPageInfo()); [Constructible] public ChildrenTalesVol2() : base(Utility.Random(0xFEF, 2), false) @@ -1871,17 +1531,11 @@ namespace Server.Items } } - #endregion - - #region Classic Tales of Vesper, Volume 1 - public class TalesOfVesperVol1 : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Classic Tales of Vesper, Volume 1", "Clarke's Printery", - new BookPageInfo - ( + new BookPageInfo( "'Tis an Honor to", "present to Thee these", "Tales collected from", @@ -1889,10 +1543,8 @@ namespace Server.Items "Inaugural Volume, we", "present this Verse", "oft Recited as a", - "Lullabye for sleepy" - ), - new BookPageInfo - ( + "Lullabye for sleepy"), + new BookPageInfo( "Children.", "", "Preface", @@ -1900,10 +1552,8 @@ namespace Server.Items "Scholar", "", " The meaning of this", - "verse has oft been" - ), - new BookPageInfo - ( + "verse has oft been"), + new BookPageInfo( "discussed in halls of", "scholarly sorts, for", "its mysterious", @@ -1911,10 +1561,8 @@ namespace Server.Items "oddly disturbing to", "adult ears, though", "children seem to find", - "it restful as they" - ), - new BookPageInfo - ( + "it restful as they"), + new BookPageInfo( "sleep. Perhaps it is", "but the remnant of a", "longer ballad once", @@ -1922,10 +1570,8 @@ namespace Server.Items "internal indications", "that it once told a", "longer story about", - "ill-fated lovers, and a" - ), - new BookPageInfo - ( + "ill-fated lovers, and a"), + new BookPageInfo( "magical experiment", "gone awry. However,", "poetic license and the", @@ -1933,10 +1579,8 @@ namespace Server.Items "distorted the words", "until now the locale of", "the tale is no more", - "than \"in the wind,\"" - ), - new BookPageInfo - ( + "than \"in the wind,\""), + new BookPageInfo( "which while it serves", "a pleasingly", "metaphorical purpose,", @@ -1944,10 +1588,8 @@ namespace Server.Items "listener as to any real", "locale!", " Another possibility", - "is that this is some" - ), - new BookPageInfo - ( + "is that this is some"), + new BookPageInfo( "form of creation", "myth explaining the", "genesis of the various", @@ -1955,10 +1597,8 @@ namespace Server.Items "that roam the lands of", "Britannia. It does not", "take a stretch of the", - "imagination to name" - ), - new BookPageInfo - ( + "imagination to name"), + new BookPageInfo( "the middle verse's", "\"girl becomes tree\" as", "a possible explanation", @@ -1966,10 +1606,8 @@ namespace Server.Items "the area surrounding", "Minoc, reapers are", "oft referred to among", - "the lumberjacking" - ), - new BookPageInfo - ( + "the lumberjacking"), + new BookPageInfo( "community as", "\"widowmakers.\" That", "these creatures are", @@ -1977,10 +1615,8 @@ namespace Server.Items "assumed, but the", "verse seems to imply", "a long ago creator, and", - "uses the antique" - ), - new BookPageInfo - ( + "uses the antique"), + new BookPageInfo( "magickal terminology", "of \"plaiting strands", "of ether\" that is so", @@ -1988,10 +1624,8 @@ namespace Server.Items "ancient texts. In", "addition, the", "reference to", - "\"snakehills\" may" - ), - new BookPageInfo - ( + "\"snakehills\" may"), + new BookPageInfo( "profitably be regarded", "as a reference to an", "actual location, such", @@ -1999,10 +1633,8 @@ namespace Server.Items "term for the", "Serpent's Spine.", " A commoner", - "interpretation is that" - ), - new BookPageInfo - ( + "interpretation is that"), + new BookPageInfo( "like many nursery", "rhymes, it is a", "simple explanation", @@ -2010,10 +1642,8 @@ namespace Server.Items "the wind snatches up", "boys and girls and", "when they sleep in", - "order to keep the" - ), - new BookPageInfo - ( + "order to keep the"), + new BookPageInfo( "balance of the world.", "Notable tales have", "been written for", @@ -2021,10 +1651,8 @@ namespace Server.Items "adventures in \"the", "Snakehills,\" which", "are presumed to be an", - "Afterworld whence" - ), - new BookPageInfo - ( + "Afterworld whence"), + new BookPageInfo( "the spirit lives on. A", "grim lullabye, to be", "sure, but no worse", @@ -2032,10 +1660,8 @@ namespace Server.Items "I wake\" surely.", " In either case, 'tis", "an old favorite,", - "herein printed for" - ), - new BookPageInfo - ( + "herein printed for"), + new BookPageInfo( "the first time for", "thy enjoyment and", "perusal!", @@ -2043,10 +1669,8 @@ namespace Server.Items "In the Wind where", "the Balance", "Is Whispered in", - "Hallways" - ), - new BookPageInfo - ( + "Hallways"), + new BookPageInfo( "In the Wind where", "the Magic", "Flows All through the", @@ -2054,10 +1678,8 @@ namespace Server.Items "There live Mages and", "Mages", "With Robes made of", - "Whole Days" - ), - new BookPageInfo - ( + "Whole Days"), + new BookPageInfo( "Reading Books full of", "Doings", "Printed on Light", @@ -2065,10 +1687,8 @@ namespace Server.Items "In the Wind where", "the Lovers", "Are Crossed under", - "Shadows" - ), - new BookPageInfo - ( + "Shadows"), + new BookPageInfo( "Where they Meet and", "are Parted", "By the Orders of", @@ -2076,10 +1696,8 @@ namespace Server.Items "The Girl becomes", "Tree,", "And thus becomes", - "Widow" - ), - new BookPageInfo - ( + "Widow"), + new BookPageInfo( "The Boy becomes", "Earth", "And Wanders Till", @@ -2087,10 +1705,8 @@ namespace Server.Items "", "In the Wind are the", "Monsters", - "First Born First" - ), - new BookPageInfo - ( + "First Born First"), + new BookPageInfo( "Created", "When Chanting and", "Ether", @@ -2098,15 +1714,11 @@ namespace Server.Items "Nigh", "Fear going to Wind,", "Fear Finding its", - "Plaitings," - ), - new BookPageInfo - ( + "Plaitings,"), + new BookPageInfo( "Go Not to the", "Snakehills", - "Lest You Care to Die" - ) - ); + "Lest You Care to Die")); [Constructible] public TalesOfVesperVol1() : base(Utility.Random(0xFEF, 2), false) @@ -2134,17 +1746,11 @@ namespace Server.Items } } - #endregion - - #region Deceit: A Dungeon of Horrors - public class DeceitDungeonOfHorror : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Deceit: A Dungeon of Horrors", "Mercenary Justin", - new BookPageInfo - ( + new BookPageInfo( " My employers have", "oft taken me into this", "den of hideous", @@ -2152,10 +1758,8 @@ namespace Server.Items "thought that it", "behooved me to write", "down what I know of", - "it, now that I am" - ), - new BookPageInfo - ( + "it, now that I am"), + new BookPageInfo( "retired from the life", "of an adventurer for", "hire.", @@ -2163,10 +1767,8 @@ namespace Server.Items "temple to forgotten", "powers of old. It was", "taken over by mages", - "who eventually were" - ), - new BookPageInfo - ( + "who eventually were"), + new BookPageInfo( "driven out by the", "depredations of their", "own evil lackeys.", @@ -2174,10 +1776,8 @@ namespace Server.Items "the magical traps and", "devices that they", "placed for their", - "defenses remain," - ), - new BookPageInfo - ( + "defenses remain,"), + new BookPageInfo( "particularly those the", "wizards used to", "protect their", @@ -2185,10 +1785,8 @@ namespace Server.Items " The dungeon is", "mystically linked by", "crystal balls placed in", - "different locations." - ), - new BookPageInfo - ( + "different locations."), + new BookPageInfo( "These magical orbs do", "transmit speech, and", "even have memory of", @@ -2196,10 +1794,8 @@ namespace Server.Items "said near them. No", "doubt they once", "served as a warning", - "system" - ), - new BookPageInfo - ( + "system"), + new BookPageInfo( " Be wary of a", "brazier that giveth", "warning when", @@ -2207,10 +1803,8 @@ namespace Server.Items "use it to summon", "deadly creatures.", " There be a", - "tantalizing chest," - ), - new BookPageInfo - ( + "tantalizing chest,"), + new BookPageInfo( "undoubtedly full of", "treasure, that cannot", "be reached save past a", @@ -2218,10 +1812,8 @@ namespace Server.Items "pressure plates that", "trigger deadly spikes.", "As I never had", - "sufficient folk with" - ), - new BookPageInfo - ( + "sufficient folk with"), + new BookPageInfo( "me to unlock the", "puzzle, I never", "obtained the riches", @@ -2229,10 +1821,8 @@ namespace Server.Items " Do not investigate", "iron maidens too", "closely, for they may", - "suck you within" - ), - new BookPageInfo - ( + "suck you within"), + new BookPageInfo( "them!", " There is one place", "where a deadly trap", @@ -2240,10 +1830,8 @@ namespace Server.Items "by making use of a", "statue that cleverly", "conceals a lever.", - " Oft one encounters" - ), - new BookPageInfo - ( + " Oft one encounters"), + new BookPageInfo( "the deadly exploding", "toadstool; the ones in", "Deceit are deadlier", @@ -2251,10 +1839,8 @@ namespace Server.Items "explode continually.", "Likewise, the very", "pools of water and", - "slime on the floor" - ), - new BookPageInfo - ( + "slime on the floor"), + new BookPageInfo( "may poison thee.", " The most magical", "device in the dungeon", @@ -2262,16 +1848,12 @@ namespace Server.Items "that can only be", "triggered by a level", "embedded in the floor.", - "Be wary however," - ), - new BookPageInfo - ( + "Be wary however,"), + new BookPageInfo( "for the bridge thus", "created doth burst", "into flame when one", - "passeth across it!" - ) - ); + "passeth across it!")); [Constructible] public DeceitDungeonOfHorror() : base(Utility.Random(0xFEF, 2), false) @@ -2299,17 +1881,11 @@ namespace Server.Items } } - #endregion - - #region Dimensional Travel, a Monograph - public class DimensionalTravel : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Dimensional Travel, a Monograph", "Dryus Doost, Mage", - new BookPageInfo - ( + new BookPageInfo( " 'Tis beyond the", "scope of this small", "monograph to discuss", @@ -2317,10 +1893,8 @@ namespace Server.Items "moongates, and the", "manners in which", "they distort the", - "fabric of reality in" - ), - new BookPageInfo - ( + "fabric of reality in"), + new BookPageInfo( "such a manner as to", "permit the passage of", "living flesh from", @@ -2328,10 +1902,8 @@ namespace Server.Items "world, or indeed from", "dimension to", "dimension.", - " Instead, allow me to" - ), - new BookPageInfo - ( + " Instead, allow me to"), + new BookPageInfo( "bring thy attention,", "Gentle Reader, to the", "curious", @@ -2339,10 +1911,8 @@ namespace Server.Items "are shared by certain", "individuals within", "our realm.", - " Long has it been" - ), - new BookPageInfo - ( + " Long has it been"), + new BookPageInfo( "known that the blue", "moongate permits", "travel from place to", @@ -2350,10 +1920,8 @@ namespace Server.Items "trouble in taking this", "path. Yet 'tis also", "known, albeit only to a", - "few, that certain" - ), - new BookPageInfo - ( + "few, that certain"), + new BookPageInfo( "individuals are unable", "to traverse the black", "moongates that permit", @@ -2361,10 +1929,8 @@ namespace Server.Items "dimension to another.", " The noted mage and", "peer of our realm,", - "Lord Blackthorn, once" - ), - new BookPageInfo - ( + "Lord Blackthorn, once"), + new BookPageInfo( "told me in", "conversation that his", "arcane research had", @@ -2372,10 +1938,8 @@ namespace Server.Items "issue was one of", "conversation of ether.", "To wit, given the", - "postulate that matter" - ), - new BookPageInfo - ( + "postulate that matter"), + new BookPageInfo( "within a given", "dimension may be but", "a cross-section of", @@ -2383,10 +1947,8 @@ namespace Server.Items "exists in multiple", "dimensions, it", "becomes obvious that", - "said ethereal" - ), - new BookPageInfo - ( + "said ethereal"), + new BookPageInfo( "structure cannot", "enter dimensions in", "which it is already", @@ -2394,10 +1956,8 @@ namespace Server.Items " Imagine an", "individual (and the", "Lord Blackthorn", - "hinted that he was" - ), - new BookPageInfo - ( + "hinted that he was"), + new BookPageInfo( "one such) who exists", "already in some form", "in multiple", @@ -2405,10 +1965,8 @@ namespace Server.Items "individual would not", "be able to cross into", "another dimension", - "because HE IS" - ), - new BookPageInfo - ( + "because HE IS"), + new BookPageInfo( "ALREADY THERE.", " The implications of", "this are staggering,", @@ -2416,10 +1974,8 @@ namespace Server.Items "study. 'Tis well", "known by theorists in", "the field that", - "divisions in the" - ), - new BookPageInfo - ( + "divisions in the"), + new BookPageInfo( "ethereal structure of", "an individual are", "already implicit at the", @@ -2427,10 +1983,8 @@ namespace Server.Items "causality forces", "divisions upon the", "ether. This is the", - "basic operating" - ), - new BookPageInfo - ( + "basic operating"), + new BookPageInfo( "mechanism by which", "white moongates", "function, permitting", @@ -2438,10 +1992,8 @@ namespace Server.Items " As time travel is", "not barred by the", "presence of an earlier", - "self (though" - ), - new BookPageInfo - ( + "self (though"), + new BookPageInfo( "encountering said", "earlier self can prove", "arcanely perilous),", @@ -2449,10 +2001,8 @@ namespace Server.Items "rigidity to the", "ethereal structure", "that bars multiple", - "instantiations of" - ), - new BookPageInfo - ( + "instantiations of"), + new BookPageInfo( "structures from", "manifesting within", "the same context.", @@ -2460,10 +2010,8 @@ namespace Server.Items "and causal bifurcation", "as a web, perhaps the", "appropriate analogy", - "for dimensional" - ), - new BookPageInfo - ( + "for dimensional"), + new BookPageInfo( "matrices is that of a", "crystalline structure,", "with rigid linkages.", @@ -2471,10 +2019,8 @@ namespace Server.Items "which an individual", "such as Lord", "Blackthorn, who", - "exists in multiple" - ), - new BookPageInfo - ( + "exists in multiple"), + new BookPageInfo( "dimensional matrices,", "can cross worlds via", "a black moongate,", @@ -2482,10 +2028,8 @@ namespace Server.Items "entire crystalline", "structure of the", "dimension to", - "perfectly match the" - ), - new BookPageInfo - ( + "perfectly match the"), + new BookPageInfo( "ethereal resonance of", "the destination", "dimension.", @@ -2493,10 +2037,8 @@ namespace Server.Items "certain individuals", "are already replicated", "in multiple crystalline", - "matrices is one that I" - ), - new BookPageInfo - ( + "matrices is one that I"), + new BookPageInfo( "fail to provide any", "schema for in these", "poor theories. It is", @@ -2504,9 +2046,7 @@ namespace Server.Items "someday someone", "shall conquer that", "thorny problem and", - "enlighten the world." - ) - ); + "enlighten the world.")); [Constructible] public DimensionalTravel() : base(Utility.Random(0xFEF, 2), false) @@ -2534,17 +2074,11 @@ namespace Server.Items } } - #endregion - - #region Ethical Hedonism: An Introduction - public class EthicalHedonism : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Ethical Hedonism: An Introduction", "Richard Garriott", - new BookPageInfo - ( + new BookPageInfo( " Societies oft have", "common codes of", "conduct which it", @@ -2552,10 +2086,8 @@ namespace Server.Items "to abide by. Now,", "while 'tis true that", "this can offer some", - "advantages, most of" - ), - new BookPageInfo - ( + "advantages, most of"), + new BookPageInfo( "the codes I see today", "around Britannia have", "fatal flaws. Let us", @@ -2563,10 +2095,8 @@ namespace Server.Items " First, there is", "Blackthorn's code of", "Chaos or basically", - "Anarchy. Whereas" - ), - new BookPageInfo - ( + "Anarchy. Whereas"), + new BookPageInfo( "this affords the", "individual maximum", "opportunity for", @@ -2574,10 +2104,8 @@ namespace Server.Items "pursuit of personal", "happiness, it does not", "offer even basic", - "interpersonal conduct" - ), - new BookPageInfo - ( + "interpersonal conduct"), + new BookPageInfo( "codes to prevent", "people from killing", "each other.", @@ -2585,10 +2113,8 @@ namespace Server.Items "tenets, all the people", "will need to spend a", "significant portion of", - "their time and effort" - ), - new BookPageInfo - ( + "their time and effort"), + new BookPageInfo( "towards personal", "protection and thus", "less time towards", @@ -2596,10 +2122,8 @@ namespace Server.Items "pursuits.", " Then there are the", "moral codes that are", - "so popular today." - ), - new BookPageInfo - ( + "so popular today."), + new BookPageInfo( "These codes are built", "largely on historical", "tradition rather than", @@ -2607,10 +2131,8 @@ namespace Server.Items "are also antiquated.", "For example many", "moral codes we see", - "today include" - ), - new BookPageInfo - ( + "today include"), + new BookPageInfo( "statements about not", "eating certain foods", "that once were often", @@ -2618,10 +2140,8 @@ namespace Server.Items "can be prepared", "safely.", " Many forbid contact", - "between young people" - ), - new BookPageInfo - ( + "between young people"), + new BookPageInfo( "of the opposite", "gender, which can in", "fact be hazardous; but", @@ -2629,10 +2149,8 @@ namespace Server.Items "lost the context as to", "why this is done,", "instead merely calling", - "it amoral. In this day" - ), - new BookPageInfo - ( + "it amoral. In this day"), + new BookPageInfo( "and age to call that a", "necessary moral", "would need a new", @@ -2640,10 +2158,8 @@ namespace Server.Items "that tradition is not", "enough", " Then there are", - "Lord British's" - ), - new BookPageInfo - ( + "Lord British's"), + new BookPageInfo( "Virtues. It strikes me", "that while a system", "of virtues is", @@ -2651,10 +2167,8 @@ namespace Server.Items "touchstone to guide a", "society to good", "behavior, these are", - "but shades of the" - ), - new BookPageInfo - ( + "but shades of the"), + new BookPageInfo( "underlying truth as to", "why one may wish to", "live a life according to", @@ -2662,10 +2176,8 @@ namespace Server.Items "conduct.", " On the other hand,", "clearly the Virtues", - "that I have heard" - ), - new BookPageInfo - ( + "that I have heard"), + new BookPageInfo( "Lord British speak of", "are clearly positive", "codes of conduct, far", @@ -2673,10 +2185,8 @@ namespace Server.Items "of anarchy that Lord", "Blackthorn suggests.", "Yet, are not these", - "Virtues still derived" - ), - new BookPageInfo - ( + "Virtues still derived"), + new BookPageInfo( "from a set of", "principles which", "though they sound", @@ -2684,10 +2194,8 @@ namespace Server.Items "pin down as actual,", "undeniable, rational", "truths?", - " Worse yet though" - ), - new BookPageInfo - ( + " Worse yet though"), + new BookPageInfo( "imagine a society", "who's code of", "conduct was based on", @@ -2695,10 +2203,8 @@ namespace Server.Items "strongest. While this", "society may function", "and even accomplish", - "much, it can be" - ), - new BookPageInfo - ( + "much, it can be"), + new BookPageInfo( "fairly argued that", "personal happiness", "would suffer greatly,", @@ -2706,10 +2212,8 @@ namespace Server.Items "the top. To rule that", "out, however, we", "must first believe", - "that people have a" - ), - new BookPageInfo - ( + "that people have a"), + new BookPageInfo( "right to pursue", "happiness.", " I hope is a safe", @@ -2717,10 +2221,8 @@ namespace Server.Items "beings wish to be", "happy; I will broadly", "describe this as", - "Hedonism. Yet, if all" - ), - new BookPageInfo - ( + "Hedonism. Yet, if all"), + new BookPageInfo( "people did is live a", "life of hedonism,", "their hedonism might", @@ -2728,10 +2230,8 @@ namespace Server.Items "those near them, so I", "will use the term", "Ethics to describe", - "limits one might put" - ), - new BookPageInfo - ( + "limits one might put"), + new BookPageInfo( "on one's hedonistic", "tendencies to allow", "others to pursue their", @@ -2739,10 +2239,8 @@ namespace Server.Items " Allow me to give", "this example: If one", "were to live alone on a", - "desert isle, one could" - ), - new BookPageInfo - ( + "desert isle, one could"), + new BookPageInfo( "live a life of pure", "hedonism, for no", "action one might take", @@ -2750,10 +2248,8 @@ namespace Server.Items "another's right to", "pursue their", "happiness. Poison the", - "lake if you like, there" - ), - new BookPageInfo - ( + "lake if you like, there"), + new BookPageInfo( "is no one to blame but", "yourself!", " Now suppose two", @@ -2761,10 +2257,8 @@ namespace Server.Items "island. Thou dost not", "want thy neighbor to", "feel free to poison the", - "lake. Would it not be" - ), - new BookPageInfo - ( + "lake. Would it not be"), + new BookPageInfo( "better to consider it", "unethical to poison the", "lake without first", @@ -2772,10 +2266,8 @@ namespace Server.Items "whose pursuit of", "happiness might be", "affected by this", - "action?" - ), - new BookPageInfo - ( + "action?"), + new BookPageInfo( " I put forth that it is", "the fact that we as a", "people choose to live in", @@ -2783,10 +2275,8 @@ namespace Server.Items "society that causes us", "to compromise our", "pure hedonism with", - "logical ethics." - ), - new BookPageInfo - ( + "logical ethics."), + new BookPageInfo( "Likewise we accept", "not being able to kill", "others without", @@ -2794,10 +2284,8 @@ namespace Server.Items "own pursuit of", "happiness would be", "greatly interfered", - "with if we feared" - ), - new BookPageInfo - ( + "with if we feared"), + new BookPageInfo( "others would do the", "same to us. From", "this basis of logic can", @@ -2805,15 +2293,11 @@ namespace Server.Items "of Ethical Hedonism.", " For more on this", "subject, see The", - "Tenants of Ethical" - ), - new BookPageInfo - ( + "Tenants of Ethical"), + new BookPageInfo( "Hedonism, by", "Richard Garriott and", - "Herman Miller." - ) - ); + "Herman Miller.")); [Constructible] public EthicalHedonism() : base(Utility.Random(0xFEF, 2), false) @@ -2841,17 +2325,11 @@ namespace Server.Items } } - #endregion - - #region My Story - public class MyStory : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "My Story", "Sherry the Mouse", - new BookPageInfo - ( + new BookPageInfo( " 'Twas on a chill", "night, when the moon", "shone pasty-faced", @@ -2859,10 +2337,8 @@ namespace Server.Items "balanced on the", "towers of Lord", "British's castle, that", - "the events I am about" - ), - new BookPageInfo - ( + "the events I am about"), + new BookPageInfo( "to relate took place,", "some years ago now. I", "witnessed them all", @@ -2870,10 +2346,8 @@ namespace Server.Items "mousehole.", " Milords British and", "Blackthorn are", - "accustomed to a game" - ), - new BookPageInfo - ( + "accustomed to a game"), + new BookPageInfo( "of chess 'pon an", "evening, over which", "they argue the issues", @@ -2881,10 +2355,8 @@ namespace Server.Items "of the realm. Lord", "Blackthorn was on his", "way to Lord British's", - "chambers, and Lord" - ), - new BookPageInfo - ( + "chambers, and Lord"), + new BookPageInfo( "British stood by a", "window casement,", "just having finished", @@ -2892,10 +2364,8 @@ namespace Server.Items "upon the board.", " Suddenly the", "shutters blew open,", - "and Lord British fell" - ), - new BookPageInfo - ( + "and Lord British fell"), + new BookPageInfo( "to the ground, one", "hand shielding his", "eyes. A chill wind", @@ -2903,10 +2373,8 @@ namespace Server.Items "it seemed a gash was", "torn in the very air.", "Through the gash I", - "could see stars and" - ), - new BookPageInfo - ( + "could see stars and"), + new BookPageInfo( "swirling clouds of", "stellar dust, and a", "coldness sucked all", @@ -2914,10 +2382,8 @@ namespace Server.Items "air. A terrible wind", "tossed books and", "blankets across the", - "room, and furniture" - ), - new BookPageInfo - ( + "room, and furniture"), + new BookPageInfo( "toppled.", " From within this", "gash issued a great", @@ -2925,10 +2391,8 @@ namespace Server.Items "have ever heard. And", "these are the words it", "spoke (for I", - "memorized them most" - ), - new BookPageInfo - ( + "memorized them most"), + new BookPageInfo( "carefully):", " \"Greetings, Lord", "British. I am the", @@ -2936,10 +2400,8 @@ namespace Server.Items "from beyond your", "dimension, as thou", "art from a world", - "other than Sosaria. I" - ), - new BookPageInfo - ( + "other than Sosaria. I"), + new BookPageInfo( "am here to bring thee", "warning. Dost thou", "recall how long ago a", @@ -2947,10 +2409,8 @@ namespace Server.Items "came to Sosaria and", "saved the world from", "the evil wizard", - "Mondain? He" - ), - new BookPageInfo - ( + "Mondain? He"), + new BookPageInfo( "shattered the Gem of", "Immortality, within", "which dwelled a", @@ -2958,10 +2418,8 @@ namespace Server.Items "this world.\"", " Lord British slowly", "stood and faced the", - "hole in the air. \"I" - ), - new BookPageInfo - ( + "hole in the air. \"I"), + new BookPageInfo( "remember,\" he said.", "\"Oft have I wished", "that stranger would", @@ -2969,10 +2427,8 @@ namespace Server.Items " \"He hath returned,\"", "spoke the voice. \"But", "not to here. When the", - "Gem was shattered, a" - ), - new BookPageInfo - ( + "Gem was shattered, a"), + new BookPageInfo( "thousand shards were", "scattered across the", "dimensions, and in", @@ -2980,10 +2436,8 @@ namespace Server.Items "perfect likeness of", "this world. And thou", "dost live upon one", - "such shard, for thou" - ), - new BookPageInfo - ( + "such shard, for thou"), + new BookPageInfo( "art not of the true", "world-thou art", "merely a reflection.\"", @@ -2991,10 +2445,8 @@ namespace Server.Items "shaken by this, and I", "did not know what to", "think! Was I merely a", - "shadow of the real" - ), - new BookPageInfo - ( + "shadow of the real"), + new BookPageInfo( "me, which lives still", "somewhere else", "across uncounted", @@ -3002,10 +2454,8 @@ namespace Server.Items " \"My task is to heal", "this shattered world,", "Lord British,\" said", - "the voice. \"And I seek" - ), - new BookPageInfo - ( + "the voice. \"And I seek"), + new BookPageInfo( "to enlist thee in my", "cause. Be warned that", "in this case, healing", @@ -3013,10 +2463,8 @@ namespace Server.Items "terrible price.\"", " Concern warred", "with curiosity on my", - "liege's face, but ever" - ), - new BookPageInfo - ( + "liege's face, but ever"), + new BookPageInfo( "one to shoulder a", "burden, he", "straightened and", @@ -3024,10 +2472,8 @@ namespace Server.Items "air bravely. \"Name", "thy price.\"", " \"A shard of a", - "universe is a" - ), - new BookPageInfo - ( + "universe is a"), + new BookPageInfo( "powerful thing, and a", "universe shattered is", "always in danger", @@ -3035,10 +2481,8 @@ namespace Server.Items "darkness. Already", "three shards were", "turned to evil, and", - "sent to plague the" - ), - new BookPageInfo - ( + "sent to plague the"), + new BookPageInfo( "original universe in", "the form of", "Shadowlords. Many", @@ -3046,10 +2490,8 @@ namespace Server.Items "the Stranger back to", "Britannia, to preserve", "it from its own folly", - "or from outside" - ), - new BookPageInfo - ( + "or from outside"), + new BookPageInfo( "dangers. Yet as long", "as the world", "remaineth in pieces,", @@ -3057,10 +2499,8 @@ namespace Server.Items "vulnerable. We must", "bring the shards into", "harmony, so that they", - "resonate in such a" - ), - new BookPageInfo - ( + "resonate in such a"), + new BookPageInfo( "manner that matches", "the original universe.", "Then the two", @@ -3068,10 +2508,8 @@ namespace Server.Items "merge, and be again", "as one.\"", " \"But if we are only", - "shadows...\" Lord" - ), - new BookPageInfo - ( + "shadows...\" Lord"), + new BookPageInfo( "British said", "wonderingly.", " The light from the", @@ -3079,10 +2517,8 @@ namespace Server.Items "seemed to dim.", "\"Indeed, the", "reflections shall", - "become one with the" - ), - new BookPageInfo - ( + "become one with the"), + new BookPageInfo( "original. Thou wouldst", "cease to be as thou", "art, and become part", @@ -3090,10 +2526,8 @@ namespace Server.Items "Thou shalt not die;", "however, uncounted", "generations have", - "passed and borne" - ), - new BookPageInfo - ( + "passed and borne"), + new BookPageInfo( "children since that", "day, and they have no", "counterparts. They", @@ -3101,10 +2535,8 @@ namespace Server.Items " Lord British sagged", "in shock, realizing", "the terrible price that", - "would be paid to heal" - ), - new BookPageInfo - ( + "would be paid to heal"), + new BookPageInfo( "the universe. \"All of", "my people,\" he", "breathed.", @@ -3112,10 +2544,8 @@ namespace Server.Items "good.\"", " Lord British bowed", "his head.", - " 'Twas then I saw" - ), - new BookPageInfo - ( + " 'Twas then I saw"), + new BookPageInfo( "the movement by the", "door, half-hid by the", "heavy red curtains.", @@ -3123,10 +2553,8 @@ namespace Server.Items "there, concealed from", "the rest of the room,", "his face white. How", - "long had he been" - ), - new BookPageInfo - ( + "long had he been"), + new BookPageInfo( "listening? I cannot", "say, yet I suspect", "that he had heard all", @@ -3134,10 +2562,8 @@ namespace Server.Items "voice had to say.", " \"How then, shall I", "aid thee?\" Lord", - "British said," - ), - new BookPageInfo - ( + "British said,"), + new BookPageInfo( "weariness in his", "voice.", " \"Aid the nobilty that", @@ -3145,10 +2571,8 @@ namespace Server.Items "human heart. Protect", "the Virtues that so", "recently came to thee", - "in thought late at" - ), - new BookPageInfo - ( + "in thought late at"), + new BookPageInfo( "night. They are the", "Virtues of life, as", "your counterpart", @@ -3156,10 +2580,8 @@ namespace Server.Items "be. For when thy", "populace doth live and", "breathe these Virtues,", - "shall it match the" - ), - new BookPageInfo - ( + "shall it match the"), + new BookPageInfo( "true Britannia, and", "thy shard shall", "rejoin with it.\"", @@ -3167,10 +2589,8 @@ namespace Server.Items "began to close, and", "with it warmth stole", "back into the room.", - " \"I was going to" - ), - new BookPageInfo - ( + " \"I was going to"), + new BookPageInfo( "discuss my idea with", "Blackthorn tonight,\"", "Lord British", @@ -3178,10 +2598,8 @@ namespace Server.Items "thoughts that are my", "own? Is my life but", "a reflection of", - "another me?\"" - ), - new BookPageInfo - ( + "another me?\""), + new BookPageInfo( " \"Nay,\" said the", "voice, smaller through", "the diminished", @@ -3189,10 +2607,8 @@ namespace Server.Items "that you are parallel,", "for there is no", "guarantee that thou", - "shalt accomplish what" - ), - new BookPageInfo - ( + "shalt accomplish what"), + new BookPageInfo( "I have set thee to. I", "speak tonight to a", "thousand of thee, and", @@ -3200,10 +2616,8 @@ namespace Server.Items "Perhaps not all shall", "seek to aid me.\" And", "with that, the gash", - "closed, and the voice" - ), - new BookPageInfo - ( + "closed, and the voice"), + new BookPageInfo( "was gone, leaving a", "room that appeare", "tossed by a mighty", @@ -3211,10 +2625,8 @@ namespace Server.Items " \"Destroy the world", "to save the universe,\"", "Lord British said", - "bitterly. \"I do not" - ), - new BookPageInfo - ( + "bitterly. \"I do not"), + new BookPageInfo( "wonder that some", "may balk.\"", " Lord Blackthorn", @@ -3222,10 +2634,8 @@ namespace Server.Items "strode into the room,", "a decent mimicry of", "surprise on his face.", - "\"My liege! What has" - ), - new BookPageInfo - ( + "\"My liege! What has"), + new BookPageInfo( "happened here?\" he", "exclaimed, feigning", "dismay well. But not", @@ -3233,10 +2643,8 @@ namespace Server.Items "his old friend, whose", "eyes narrowed at", "seeing him there.", - " \"How much didst" - ), - new BookPageInfo - ( + " \"How much didst"), + new BookPageInfo( "thou hear?\" demanded", "Lord British.", " \"Why, nothing,\"", @@ -3244,10 +2652,8 @@ namespace Server.Items "his head ducked away", "from his friend, as", "he bent to retrieve the", - "fallen chess pieces. \"I" - ), - new BookPageInfo - ( + "fallen chess pieces. \"I"), + new BookPageInfo( "merely came for our", "game of chess.\"", " Together they", @@ -3255,10 +2661,8 @@ namespace Server.Items "table, and set the", "pieces upon the black", "and white squares.", - "\"Such simplicity to" - ), - new BookPageInfo - ( + "\"Such simplicity to"), + new BookPageInfo( "the game, Blackthorn,\"", "mused Lord British,", "idly brushing one", @@ -3266,10 +2670,8 @@ namespace Server.Items "board. \"Black and", "white, each to its own", "color, as if life were", - "so simple. What think" - ), - new BookPageInfo - ( + "so simple. What think"), + new BookPageInfo( "you?\"", " Blackthorn sat", "heavily on a hassock", @@ -3277,10 +2679,8 @@ namespace Server.Items "\"I think that matters", "are never so simple,", "my liege. And that I", - "would regret it deeply" - ), - new BookPageInfo - ( + "would regret it deeply"), + new BookPageInfo( "if someone, such as a", "friend, saw it thus.\"", " Lord British's eyes", @@ -3288,10 +2688,8 @@ namespace Server.Items "sometimes one must", "sacrifice a pawn to", "save a king.\"", - " Lord Blackthorn met" - ), - new BookPageInfo - ( + " Lord Blackthorn met"), + new BookPageInfo( "his gaze squarely.", "\"Even pawns have", "lives and loves at", @@ -3299,10 +2697,8 @@ namespace Server.Items "he reached out for a", "pawn, and firmly", "moved it forward two", - "squares. \"Shall we" - ), - new BookPageInfo - ( + "squares. \"Shall we"), + new BookPageInfo( "play a game?\" he", "asked.", " The chess game that", @@ -3310,10 +2706,8 @@ namespace Server.Items "and they played", "grimly.", " And the next day,", - "Lord British gathered" - ), - new BookPageInfo - ( + "Lord British gathered"), + new BookPageInfo( "the nobles to proclaim", "the idea of a new", "system of Virtues,", @@ -3321,10 +2715,8 @@ namespace Server.Items "shrines should be", "built across the land.", " Lord Blackthorn", - "opposed it bitterly," - ), - new BookPageInfo - ( + "opposed it bitterly,"), + new BookPageInfo( "and many thought", "him strange for doing", "so, for ever had he", @@ -3332,10 +2724,8 @@ namespace Server.Items "upright man, and", "ever had he and Lord", "British been in", - "accord. Declaring that" - ), - new BookPageInfo - ( + "accord. Declaring that"), + new BookPageInfo( "he should start his", "own shrine, he", "departed the castle", @@ -3343,10 +2733,8 @@ namespace Server.Items "tower in a lake on the", "north side of the", "city.", - " They are still the" - ), - new BookPageInfo - ( + " They are still the"), + new BookPageInfo( "best of friends, yet a", "sadness hangs", "between them, as if", @@ -3354,10 +2742,8 @@ namespace Server.Items "making choices that", "appealed not to them.", "And at night, when I", - "creep softly from one" - ), - new BookPageInfo - ( + "creep softly from one"), + new BookPageInfo( "corner of my liege's", "bedchamber to", "another, I sometimes", @@ -3365,10 +2751,8 @@ namespace Server.Items "from his night table,", "and hold it in his", "hand, and quietly", - "weep." - ), - new BookPageInfo - ( + "weep."), + new BookPageInfo( " But I am but a", "mouse, and none hear", "me. This tale goes", @@ -3376,16 +2760,12 @@ namespace Server.Items "my writing these", "enormous letters with", "mine ink-stained tiny", - "paws for thee to" - ), - new BookPageInfo - ( + "paws for thee to"), + new BookPageInfo( "read, for I fear", "indeed for our world", "and for our people in", - "these perilous times." - ) - ); + "these perilous times.")); [Constructible] public MyStory() : base(Utility.Random(0xFEF, 2), false) @@ -3413,17 +2793,11 @@ namespace Server.Items } } - #endregion - - #region On the Diversity of Our Land - public class DiversityOfOurLand : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "On the Diversity of Our Land", "Lord Blackthorn", - new BookPageInfo - ( + new BookPageInfo( " While I deplore the", "depredations of the", "misguided and", @@ -3431,10 +2805,8 @@ namespace Server.Items "which we share our", "fair Britannia, and", "alongside the populace,", - "do mourn the needless" - ), - new BookPageInfo - ( + "do mourn the needless"), + new BookPageInfo( "deaths that their", "raids cause, I cannot", "countenance the policy", @@ -3442,10 +2814,8 @@ namespace Server.Items "of these races that", "seems to be the habit", "of our soldierly", - "element." - ), - new BookPageInfo - ( + "element."), + new BookPageInfo( " Can we not regard", "the ratmen, lizard", "men, and orcs are", @@ -3453,10 +2823,8 @@ namespace Server.Items "beings with whom we", "share a planet? Why", "must we slay them", - "on sight, rather than" - ), - new BookPageInfo - ( + "on sight, rather than"), + new BookPageInfo( "attempt to engage", "them in dialogue?", "There is no policy of", @@ -3464,10 +2832,8 @@ namespace Server.Items "when they grace us", "with their presence", "(not that an arrow", - "could do much to" - ), - new BookPageInfo - ( + "could do much to"), + new BookPageInfo( "pierce them!).", " To view these", "creatures as vermin", @@ -3475,10 +2841,8 @@ namespace Server.Items "intelligence, and we", "cannot underestimate", "the repercussions", - "that their slaughter" - ), - new BookPageInfo - ( + "that their slaughter"), + new BookPageInfo( "may have. If we", "regard the slaying of", "fellow humans as a", @@ -3486,10 +2850,8 @@ namespace Server.Items "regard the killing of", "an orc.", " At the same time,", - "should a lizardman" - ), - new BookPageInfo - ( + "should a lizardman"), + new BookPageInfo( "slay a human, should", "we not forgive their", "ignorance and", @@ -3497,10 +2859,8 @@ namespace Server.Items "not surrender the", "high moral ground by", "descending to", - "bestiality." - ), - new BookPageInfo - ( + "bestiality."), + new BookPageInfo( " Now, I say not that", "we should fail to", "defend ourselves in", @@ -3508,10 +2868,8 @@ namespace Server.Items "even amongst humans", "we see war, we see", "famine, and we see", - "assault (though we" - ), - new BookPageInfo - ( + "assault (though we"), + new BookPageInfo( "owe a debt of", "gratitude to our Lord", "British for", @@ -3519,10 +2877,8 @@ namespace Server.Items "the worst of these!).", "However, incursions", "such as the recent", - "tragedy which cost us" - ), - new BookPageInfo - ( + "tragedy which cost us"), + new BookPageInfo( "the life of Japheth,", "Guildmaster of", "Trinsic's Paladins,", @@ -3530,10 +2886,8 @@ namespace Server.Items " I had met Japheth,", "and like all paladins,", "he burned with an", - "inner fire. Yet" - ), - new BookPageInfo - ( + "inner fire. Yet"), + new BookPageInfo( "though I had the", "utmost respect for", "him, none could deny", @@ -3541,10 +2895,8 @@ namespace Server.Items "flashed in his eyes at", "the mere mention of", "orcs. And thus he", - "carried his battle to" - ), - new BookPageInfo - ( + "carried his battle to"), + new BookPageInfo( "the orc camps, and", "died there, unable to", "rise above his own", @@ -3552,10 +2904,8 @@ namespace Server.Items "depicted in his book,", "\"The Burning of", "Trinsic.\" 'Tis a", - "shame that even our" - ), - new BookPageInfo - ( + "shame that even our"), + new BookPageInfo( "mightiest men fall", "prey to this", "ignorance!", @@ -3563,10 +2913,8 @@ namespace Server.Items "legends of orcs", "adopting human", "children to raise as", - "their own? Tales of" - ), - new BookPageInfo - ( + "their own? Tales of"), + new BookPageInfo( "complex societies built", "underground by races", "we regard as bestial?", @@ -3574,17 +2922,13 @@ namespace Server.Items "the mistake of", "Japheth of the", "Paladins, and let us", - "cease to persecute the" - ), - new BookPageInfo - ( + "cease to persecute the"), + new BookPageInfo( "nonhuman races,", "before we discover", "that we are harming", "ourselves in the", - "process." - ) - ); + "process.")); [Constructible] public DiversityOfOurLand() : base(Utility.Random(0xFEF, 2), false) @@ -3612,17 +2956,11 @@ namespace Server.Items } } - #endregion - - #region Quest of the Virtues - public class QuestOfVirtues : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Quest of the Virtues", "Autenil", - new BookPageInfo - ( + new BookPageInfo( "Volume 1", "Chapter 1: Starting out", "I begin my Quest in the", @@ -3630,10 +2968,8 @@ namespace Server.Items "My Quest is to travel by", "foot to the eight shrines", "of Britannia. Although", - "this may sound easy, it" - ), - new BookPageInfo - ( + "this may sound easy, it"), + new BookPageInfo( "is hampered because I", "have forsaken my abilities", "and worldly possessions.", @@ -3641,10 +2977,8 @@ namespace Server.Items "to live by are a set of", "plain clothes, a ship to", "sail the seas and my", - "diary in which to record" - ), - new BookPageInfo - ( + "diary in which to record"), + new BookPageInfo( "my adventures. Onward", "Ho towards the Shrine of", "Spirituality!", @@ -3652,10 +2986,8 @@ namespace Server.Items "Chapter 2: The Road to", "Spirituality", "", - "Since I have forsaken" - ), - new BookPageInfo - ( + "Since I have forsaken"), + new BookPageInfo( "magic as a form of", "travel, I must find a way", "to the mainland from this", @@ -3663,10 +2995,8 @@ namespace Server.Items "I was able to barter a", "ride from the ferryman.", "Upon reaching the", - "mainland, I followed the" - ), - new BookPageInfo - ( + "mainland, I followed the"), + new BookPageInfo( "road until it turned", "North, yet I must", "continue Eastward. I", @@ -3674,10 +3004,8 @@ namespace Server.Items "pleasant sounds of the", "birds chirping and enjoyed", "the peace away from the", - "busy life. Upon reaching" - ), - new BookPageInfo - ( + "busy life. Upon reaching"), + new BookPageInfo( "the Hedge Maze I recalled", "a story about the mage", "Relvinian in the days of", @@ -3685,10 +3013,8 @@ namespace Server.Items "go around it. Possessing", "no weapons and having", "forsaken my training, I", - "heeded the sign that said," - ), - new BookPageInfo - ( + "heeded the sign that said,"), + new BookPageInfo( "\"Enter and Become One", "Among Ghosts.\" The River", "forced me to turn South", @@ -3696,10 +3022,8 @@ namespace Server.Items "", "Chapter 3: Spirituality", "", - "Spirituality is the leader" - ), - new BookPageInfo - ( + "Spirituality is the leader"), + new BookPageInfo( "of the Virtues. It is the", "meditation and", "understanding of all other", @@ -3707,10 +3031,8 @@ namespace Server.Items "Spirituality, one cannot", "completely follow the", "Virtues, for It is the", - "dedication and adherance" - ), - new BookPageInfo - ( + "dedication and adherance"), + new BookPageInfo( "to them.", "", "Chapter 4: Finding Honor", @@ -3718,10 +3040,8 @@ namespace Server.Items "My next visit will be to", "the Shrine of Honor,", "which lies a fair distance", - "to the South. There is a" - ), - new BookPageInfo - ( + "to the South. There is a"), + new BookPageInfo( "road to my East that I", "will follow to the town", "of Trinsic. I found a", @@ -3729,10 +3049,8 @@ namespace Server.Items "Traveller's Inn, and woke", "refreshed in the morning", "to hear the sounds of", - "nature as I prepared to" - ), - new BookPageInfo - ( + "nature as I prepared to"), + new BookPageInfo( "continue my journeys. I", "thanked the kind innkeeper", "and headed out of Trinsic", @@ -3740,10 +3058,8 @@ namespace Server.Items "briefly with one lucky", "enough to own a house in", "the beautiful country and", - "he bade me good fortune" - ), - new BookPageInfo - ( + "he bade me good fortune"), + new BookPageInfo( "on my travels. I used my", "rusty blade to cut", "through dense jungles", @@ -3751,10 +3067,8 @@ namespace Server.Items "realm, now inhabited only", "by the Undead. Many a", "mongbat did hamper my", - "journey, but finally I" - ), - new BookPageInfo - ( + "journey, but finally I"), + new BookPageInfo( "arrived at the Shrine of", "Honor.", "", @@ -3762,10 +3076,8 @@ namespace Server.Items "", "Many link Honor and", "battle, but it can be", - "used with any aspect of" - ), - new BookPageInfo - ( + "used with any aspect of"), + new BookPageInfo( "Life. Honor is to abide", "by the rules, dishonor is", "to cheat; to seek the", @@ -3773,10 +3085,8 @@ namespace Server.Items "to always live life with", "Honor.", "", - "Chapter 6: Seeking Valor" - ), - new BookPageInfo - ( + "Chapter 6: Seeking Valor"), + new BookPageInfo( "I must now embark on my", "trusty small ship, the", "Hollandia, to the South", @@ -3784,10 +3094,8 @@ namespace Server.Items "island where few have", "travelled. I know not yet", "what I will encounter at", - "sea, so I bid the Virtues" - ), - new BookPageInfo - ( + "sea, so I bid the Virtues"), + new BookPageInfo( "grant me safety. So", "begins my voyage. I", "managed to sail unnoticed", @@ -3795,10 +3103,8 @@ namespace Server.Items "elementals which took a", "fair bit of navigation", "from my tillerman.", - "However, I arrived without" - ), - new BookPageInfo - ( + "However, I arrived without"), + new BookPageInfo( "incident.", "", "Chapter 7: Valor", @@ -3806,10 +3112,8 @@ namespace Server.Items "The Shrine of Valor is", "protected by many a", "beast far too poisonous", - "and foul for myself to" - ), - new BookPageInfo - ( + "and foul for myself to"), + new BookPageInfo( "vanquish. One mush show", "Valor to approach the", "Shrine! Valor is often", @@ -3817,10 +3121,8 @@ namespace Server.Items "to fight what maybe a", "losing battle upon which", "he believes. It takes", - "Valor to stand your" - ), - new BookPageInfo - ( + "Valor to stand your"), + new BookPageInfo( "ground against the many", "murderers and lawbreakers", "in our lands. You may", @@ -3828,10 +3130,8 @@ namespace Server.Items "in that you fight that", "which must be opposed.", "Fight the fights you", - "believe in, not just the" - ), - new BookPageInfo - ( + "believe in, not just the"), + new BookPageInfo( "fights you think you can", "win.", "", @@ -3839,10 +3139,8 @@ namespace Server.Items "Humility", "", "My journey will continue", - "to the East towards the" - ), - new BookPageInfo - ( + "to the East towards the"), + new BookPageInfo( "Shrine of Humility. I", "launch my boat from the", "West side of the Island", @@ -3850,10 +3148,8 @@ namespace Server.Items "my daring escape from", "the many Giant Serpents", "chasing me with their", - "poisonous venom and" - ), - new BookPageInfo - ( + "poisonous venom and"), + new BookPageInfo( "hissing tongues. Beautiful", "blue waves washed over", "the bow of the boat as", @@ -3861,10 +3157,8 @@ namespace Server.Items "leading me on. The voyage", "is long and the water", "turbulent but finally land", - "was struck. Quickly I ran," - ), - new BookPageInfo - ( + "was struck. Quickly I ran,"), + new BookPageInfo( "eager to find my final", "destination for the day.", "", @@ -3872,10 +3166,8 @@ namespace Server.Items "", "The Shrine of Humility is", "surprisingly spartan; it is", - "merely a grove of stone" - ), - new BookPageInfo - ( + "merely a grove of stone"), + new BookPageInfo( "pillars with an ankh and", "the Humility stone at its", "center. I would", @@ -3883,10 +3175,8 @@ namespace Server.Items "this Quest; returning to", "my roots in this world. I", "have rejected my", - "possessions and my wealth" - ), - new BookPageInfo - ( + "possessions and my wealth"), + new BookPageInfo( "in order to rely only", "upon my cunning and", "instincts. No longer have", @@ -3894,19 +3184,15 @@ namespace Server.Items "Glorious to others, but I", "have only that which I", "need to survive. I may no", - "longer rely upon myself, I" - ), - new BookPageInfo - ( + "longer rely upon myself, I"), + new BookPageInfo( "must rely upon others", "for my survival. My", "journey to Humility has", "only made me realize even", "more how Blessed I have", - "been." - ), - new BookPageInfo - ( + "been."), + new BookPageInfo( "Chapter 10: Onward to", "Honesty", "", @@ -3914,10 +3200,8 @@ namespace Server.Items "South towards the Island", "of Ice. However, my", "voyages and excursions", - "into the jungle have made" - ), - new BookPageInfo - ( + "into the jungle have made"), + new BookPageInfo( "me quite tired, so I will", "camp here beside a river", "near the Shrine of", @@ -3925,10 +3209,8 @@ namespace Server.Items "awake the next morning", "refreshed and invigorated,", "but also under attack! A", - "Headless One has noticed" - ), - new BookPageInfo - ( + "Headless One has noticed"), + new BookPageInfo( "my rise from slumber and", "attacks viciously. My", "trusty cleaver was in my", @@ -3936,10 +3218,8 @@ namespace Server.Items "lack of skill with the", "weapon delayed the death", "of the creature. I", - "launched the Hollandia and" - ), - new BookPageInfo - ( + "launched the Hollandia and"), + new BookPageInfo( "set sail for the Island of", "Ice, seeking the Shrine of", "Honesty. As I sail the", @@ -3947,10 +3227,8 @@ namespace Server.Items "desiring the company of", "my fellow man. Hopefully I", "shall meet some kind of", - "traveller with whom I may" - ), - new BookPageInfo - ( + "traveller with whom I may"), + new BookPageInfo( "exchange a few words.", "Shortly I was landing my", "boat on the North end of", @@ -3958,10 +3236,8 @@ namespace Server.Items "quickly made my way", "through snow across the", "frigid tundra while trying", - "to keep warm. The Shrine" - ), - new BookPageInfo - ( + "to keep warm. The Shrine"), + new BookPageInfo( "of Honesty bid me", "welcome as I felth the", "warmth radiate throughout", @@ -3969,10 +3245,8 @@ namespace Server.Items "", "Chapter 11: Honesty", "", - "Honesty is to uphold and" - ), - new BookPageInfo - ( + "Honesty is to uphold and"), + new BookPageInfo( "defend the truth at all", "times. Furthermore,", "Honesty requires us to", @@ -3980,10 +3254,8 @@ namespace Server.Items "fellow man; not taking", "undue advantage. Honesty", "is a Virtue often lacking", - "in today's world. It seems" - ), - new BookPageInfo - ( + "in today's world. It seems"), + new BookPageInfo( "as though people are out", "to gain wealth with no", "regard to Honesty", @@ -3991,10 +3263,8 @@ namespace Server.Items "Honesty is the foundation", "upon which trust is built.", "If the foundation", - "crumbles, everything built" - ), - new BookPageInfo - ( + "crumbles, everything built"), + new BookPageInfo( "upon it must fall. The", "cold environment which", "houses the Shrine of", @@ -4002,20 +3272,16 @@ namespace Server.Items "to its value in today's", "society. The symbolic cold", "and secluded location", - "shows us that only the" - ), - new BookPageInfo - ( + "shows us that only the"), + new BookPageInfo( "most dedicated to", "pursuing Honesty will", "achieve it. May we all be", "Honest with our fellow", "man and remember to", "treat them how we would", - "like to be treated." - ), - new BookPageInfo - ( + "like to be treated."), + new BookPageInfo( "Chapter 12: The Path to", "Sacrifice.", "", @@ -4023,10 +3289,8 @@ namespace Server.Items "West side of the Island", "of Ice. From there I", "launch the Hollandia and", - "sail slightly to the North" - ), - new BookPageInfo - ( + "sail slightly to the North"), + new BookPageInfo( "and West. I land my boat", "just East of the Shrine", "of Sacrifice, so my road", @@ -4034,9 +3298,7 @@ namespace Server.Items "the sea, I am happy to", "be back on the mainland", "for the final three", - "Shrines." - ) - ); + "Shrines.")); [Constructible] public QuestOfVirtues() : base(Utility.Random(0xFEF, 2), false) @@ -4064,17 +3326,11 @@ namespace Server.Items } } - #endregion - - #region Regarding Llamas - public class RegardingLlamas : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Regarding Llamas", "Simon", - new BookPageInfo - ( + new BookPageInfo( " Llamas are curious", "beasts, shaggy and", "sought after for their", @@ -4082,10 +3338,8 @@ namespace Server.Items "curiously arrogant", "disposition reflected", "in their eyes. They", - "live in mountainous" - ), - new BookPageInfo - ( + "live in mountainous"), + new BookPageInfo( "areas, though who", "may have first tamed", "them is lost in the", @@ -4093,10 +3347,8 @@ namespace Server.Items " 'Tis a well-known", "fact that llamas can", "indeed be tamed, and", - "used as grazing" - ), - new BookPageInfo - ( + "used as grazing"), + new BookPageInfo( "animals, for their", "meat, and of course", "for their wool. Yet", @@ -4104,18 +3356,14 @@ namespace Server.Items "their ornery", "disposition and", "tendency to spit at", - "those they dislike" - ), - new BookPageInfo - ( + "those they dislike"), + new BookPageInfo( "makes them appealing", "guard creatures as", "well, though they", "have little sound with", "which to sound an", - "alarum." - ) - ); + "alarum.")); [Constructible] public RegardingLlamas() : base(Utility.Random(0xFEF, 2), false) @@ -4143,17 +3391,11 @@ namespace Server.Items } } - #endregion - - #region Talking to Wisps - public class TalkingToWisps : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Talking to Wisps", "Yorick ofMoonglow", - new BookPageInfo - ( + new BookPageInfo( "This volume was", "sponsored by", "donations from Lord", @@ -4161,10 +3403,8 @@ namespace Server.Items "supporter of", "understanding the", "other sentient races", - "of Britannia." - ), - new BookPageInfo - ( + "of Britannia."), + new BookPageInfo( "-", " Wisps are the most", "intelligent of the", @@ -4172,10 +3412,8 @@ namespace Server.Items "inhabiting Britannia.", "'Tis claimed by the", "great sages that", - "someday we shall be" - ), - new BookPageInfo - ( + "someday we shall be"), + new BookPageInfo( "able to converse with", "them openly in our", "native", @@ -4183,10 +3421,8 @@ namespace Server.Items "must hope that wisps", "learn our language,", "for it is not possible", - "for humans to" - ), - new BookPageInfo - ( + "for humans to"), + new BookPageInfo( "pronounce wispish!", " The wispish", "language seems to", @@ -4194,10 +3430,8 @@ namespace Server.Items "vowel, the letter Y.", "However, the letters", "W, C, M, and L seem", - "to be treated" - ), - new BookPageInfo - ( + "to be treated"), + new BookPageInfo( "grammatically as", "vowels, and in", "addition every letter", @@ -4205,10 +3439,8 @@ namespace Server.Items "sounds to the human", "ear like a glottal stop.", "It is possible that the", - "glottal stop is" - ), - new BookPageInfo - ( + "glottal stop is"), + new BookPageInfo( "considered a vowel as", "well.", " Wisps do make use", @@ -4216,10 +3448,8 @@ namespace Server.Items "like pitch and", "emphasis shifts", "similar to", - "exclamations and" - ), - new BookPageInfo - ( + "exclamations and"), + new BookPageInfo( "questions.", " The average word is", "wispish seems to", @@ -4227,10 +3457,8 @@ namespace Server.Items "phonemes and three", "glottal stops, plus", "possibly a pitch shift.", - "It often sounds like a" - ), - new BookPageInfo - ( + "It often sounds like a"), + new BookPageInfo( "fire burning or", "crackling. Some have", "speculated that what", @@ -4238,14 +3466,10 @@ namespace Server.Items "in fact nothing more", "than the very air", "crackling near the", - "wisp's glow, and not" - ), - new BookPageInfo - ( + "wisp's glow, and not"), + new BookPageInfo( "language, but this is", - "of course unlikely." - ) - ); + "of course unlikely.")); [Constructible] public TalkingToWisps() : base(Utility.Random(0xFEF, 2), false) @@ -4273,17 +3497,11 @@ namespace Server.Items } } - #endregion - - #region Taming Dragons - public class TamingDragons : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Taming Dragons", "Wyrd Beastmaster", - new BookPageInfo - ( + new BookPageInfo( " I have not much to", "tell about dragons. The", "sole time I approached", @@ -4291,10 +3509,8 @@ namespace Server.Items "towards taming it,", "my initial attempts at", "calming it met with", - "failure. It fixed a" - ), - new BookPageInfo - ( + "failure. It fixed a"), + new BookPageInfo( "massive beady eye", "upon me, and began", "its slithering", @@ -4302,10 +3518,8 @@ namespace Server.Items "doubt to insert me", "into its maw and bear", "down with its teeth.", - " However, as I was" - ), - new BookPageInfo - ( + " However, as I was"), + new BookPageInfo( "engaged in what", "remains to this day", "the most terrifying", @@ -4313,10 +3527,8 @@ namespace Server.Items "the dragon suddenly", "whirled as if in a", "panic, ran a short", - "distance, took off into" - ), - new BookPageInfo - ( + "distance, took off into"), + new BookPageInfo( "the air, then", "transformed into a", "whirlwind. Lastly, it", @@ -4324,10 +3536,8 @@ namespace Server.Items "gouts of black blood", "and heaving, stinking", "flesh upon miles of", - "countryside. The" - ), - new BookPageInfo - ( + "countryside. The"), + new BookPageInfo( "fireball was massive,", "enough to light a city,", "I should surmise.", @@ -4335,10 +3545,8 @@ namespace Server.Items "the exact cause of", "this strange behavior,", "except to assume that", - "it was not typical for" - ), - new BookPageInfo - ( + "it was not typical for"), + new BookPageInfo( "this reptilian species.", "My best guesses", "revolve around a", @@ -4346,10 +3554,8 @@ namespace Server.Items "the nature of reality,", "which is far too", "esoteric a territory", - "for one of my limited" - ), - new BookPageInfo - ( + "for one of my limited"), + new BookPageInfo( "scholarship.", " Hence my basic", "advice to those who", @@ -4357,14 +3563,10 @@ namespace Server.Items "dragon-be sure that", "thou hast mastered", "the twin skills of", - "taming animals, and" - ), - new BookPageInfo - ( + "taming animals, and"), + new BookPageInfo( "running away very", - "very fast." - ) - ); + "very fast.")); [Constructible] public TamingDragons() : base(Utility.Random(0xFEF, 2), false) @@ -4392,17 +3594,11 @@ namespace Server.Items } } - #endregion - - #region The Bold Stranger - public class BoldStranger : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The Bold Stranger", "Old Fabio the Poor", - new BookPageInfo - ( + new BookPageInfo( " In a time before", "time, the Gods that Be", "assembled a group of", @@ -4410,10 +3606,8 @@ namespace Server.Items "and lore masters", "(for, yes, even in", "those days, art", - "existed) to create the" - ), - new BookPageInfo - ( + "existed) to create the"), + new BookPageInfo( "world of Sosaria. To", "this group, the gods", "gave a tiny world,", @@ -4421,10 +3615,8 @@ namespace Server.Items "test their works, to", "see if they were of", "the quality desired", - "for the true world in" - ), - new BookPageInfo - ( + "for the true world in"), + new BookPageInfo( "which they would be", "placed. And though", "the gods were tight", @@ -4432,10 +3624,8 @@ namespace Server.Items "this small crew", "worked hard and long,", "and were happy in", - "their tasks." - ), - new BookPageInfo - ( + "their tasks."), + new BookPageInfo( " A small corner of", "Rytabul had been", "claimed by the artisan", @@ -4443,10 +3633,8 @@ namespace Server.Items "Though he was not", "the fastest of the", "assembled workers,", - "the gods smiled upon" - ), - new BookPageInfo - ( + "the gods smiled upon"), + new BookPageInfo( "his work, even", "presenting him with", "a mystic talisman", @@ -4454,10 +3642,8 @@ namespace Server.Items "the best among the", "newer artisans. And", "so Selrahc went about", - "his business, creating" - ), - new BookPageInfo - ( + "his business, creating"), + new BookPageInfo( "hundreds of designs", "which would one day", "add color and variety", @@ -4465,10 +3651,8 @@ namespace Server.Items " One day a", "stranger appeared to", "Selrahc. His chest", - "was bare and he wore" - ), - new BookPageInfo - ( + "was bare and he wore"), + new BookPageInfo( "trousers of the", "brightest green, and", "wherever he went,", @@ -4476,10 +3660,8 @@ namespace Server.Items "footsteps. This", "caused Selrahc no end", "of trouble, the", - "stranger always" - ), - new BookPageInfo - ( + "stranger always"), + new BookPageInfo( "looking over his", "shoulder, and the", "plants sprouting in", @@ -4487,10 +3669,8 @@ namespace Server.Items "required to ply his", "art. And so Selrahc", "approached the", - "stranger and bade" - ), - new BookPageInfo - ( + "stranger and bade"), + new BookPageInfo( "him speak. But this", "man in green", "remained silent.", @@ -4498,10 +3678,8 @@ namespace Server.Items "the stranger to give", "his name, and would", "he please leave", - "Selrahc to his work." - ), - new BookPageInfo - ( + "Selrahc to his work."), + new BookPageInfo( "But this mysterious", "stranger remained", "mute.", @@ -4509,10 +3687,8 @@ namespace Server.Items "Selrahc mightily. Who", "was this silent man,", "interfering with", - "tasks the gods" - ), - new BookPageInfo - ( + "tasks the gods"), + new BookPageInfo( "themselves had", "entrusted to Selrahc?", "In an attempt to", @@ -4520,10 +3696,8 @@ namespace Server.Items "interloper, Selrahc", "stole his green", "trousers, leaving him", - "naked and open to" - ), - new BookPageInfo - ( + "naked and open to"), + new BookPageInfo( "comments about his", "very manhood, and", "still the stranger", @@ -4531,10 +3705,8 @@ namespace Server.Items "would not leave this", "tiny corner of", "Rytabul.", - " Vexed to his very" - ), - new BookPageInfo - ( + " Vexed to his very"), + new BookPageInfo( "limits, Selrahc took", "his war axe and", "smote the silent one", @@ -4542,17 +3714,13 @@ namespace Server.Items "again, until the silent", "stranger ran away,", "having never said a", - "word, and never" - ), - new BookPageInfo - ( + "word, and never"), + new BookPageInfo( "showed himself in", "Rytabul again.", " Thus endeth the", "tale of the bold", - "stranger." - ) - ); + "stranger.")); [Constructible] public BoldStranger() : base(Utility.Random(0xFEF, 2), false) @@ -4580,17 +3748,11 @@ namespace Server.Items } } - #endregion - - #region The Burning of Trinsic - public class BurningOfTrinsic : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The Burning of Trinsic", "Japheth of Trinsic", - new BookPageInfo - ( + new BookPageInfo( " 'Twas a sight to", "see, the sunlight", "falling lightly on the", @@ -4598,10 +3760,8 @@ namespace Server.Items "Trinsic 'pon a", "morning in spring.", " Children ran along", - "the parapets and" - ), - new BookPageInfo - ( + "the parapets and"), + new BookPageInfo( "walkways, their", "laughter and running", "providing music to the", @@ -4609,10 +3769,8 @@ namespace Server.Items "their oft-ragged", "clothing.", " And I was one of", - "those young ones," - ), - new BookPageInfo - ( + "those young ones,"), + new BookPageInfo( "letting my joy rise", "up to the skies.", " Little did we all", @@ -4620,10 +3778,8 @@ namespace Server.Items "days that would lie", "ahead, for we were", "too young.", - " Had we but gained" - ), - new BookPageInfo - ( + " Had we but gained"), + new BookPageInfo( "access to the quiet", "councils held in the", "Paladin tower as it", @@ -4631,10 +3787,8 @@ namespace Server.Items "councils lit by", "candlelight and", "worry, we would", - "have learned more of" - ), - new BookPageInfo - ( + "have learned more of"), + new BookPageInfo( "the fears of", "imminent attack from", "the forest, where", @@ -4642,10 +3796,8 @@ namespace Server.Items "of dank caves and", "darkness were", "marauding ever more", - "often into the lands" - ), - new BookPageInfo - ( + "often into the lands"), + new BookPageInfo( "around Trinsic's", "moat.", " But we were", @@ -4653,10 +3805,8 @@ namespace Server.Items "parapets and the moat", "were places to play,", "not stout defenses,", - "and we gave no" - ), - new BookPageInfo - ( + "and we gave no"), + new BookPageInfo( "thought to the", "necessities that must", "have required their", @@ -4664,10 +3814,8 @@ namespace Server.Items " We used to reach", "the sheltered", "orchards on the lee", - "side of the parapet" - ), - new BookPageInfo - ( + "side of the parapet"), + new BookPageInfo( "walls, where the", "southern river cut", "through the city, by", @@ -4675,10 +3823,8 @@ namespace Server.Items "water.", " The rich folk who", "lived in the great", - "manses there would" - ), - new BookPageInfo - ( + "manses there would"), + new BookPageInfo( "shout from their", "windows and shake", "their fists, for we", @@ -4686,10 +3832,8 @@ namespace Server.Items "their gardens and", "tear up the delicate", "foxgloves and", - "orfleurs with our" - ), - new BookPageInfo - ( + "orfleurs with our"), + new BookPageInfo( "unshod dirty feet.", "Then we would dive", "into the water and", @@ -4697,10 +3841,8 @@ namespace Server.Items "fruit trees.", " The southern", "river lazily slid", - "under the an ungated" - ), - new BookPageInfo - ( + "under the an ungated"), + new BookPageInfo( "arch in the mighty", "wall, and we would", "lay on the grassy", @@ -4708,10 +3850,8 @@ namespace Server.Items "gurgle by the lily", "pads.", " That spring that", - "pleasant spot became" - ), - new BookPageInfo - ( + "pleasant spot became"), + new BookPageInfo( "the doorway through", "which our city of", "Trinsic let in the", @@ -4719,10 +3859,8 @@ namespace Server.Items "humanoids that", "savaged us. I lay upon", "that grassy bank and", - "watched them wade" - ), - new BookPageInfo - ( + "watched them wade"), + new BookPageInfo( "in, their coarse hair", "wet and matted, algae", "and muck festooning", @@ -4730,10 +3868,8 @@ namespace Server.Items " They caught sight", "of a quicksilver girl", "with bright blond hair", - "and lively eyes. Her" - ), - new BookPageInfo - ( + "and lively eyes. Her"), + new BookPageInfo( "name was Leyla, and", "that spring I had held", "fond dreams of", @@ -4741,10 +3877,8 @@ namespace Server.Items "sharing flavored ice", "while dangling our", "feet off the small", - "bridge by Smugglers" - ), - new BookPageInfo - ( + "bridge by Smugglers"), + new BookPageInfo( "Gate.", " And I said nothing", "when they caught", @@ -4752,10 +3886,8 @@ namespace Server.Items "out when they", "dragged her off", "through that breach in", - "our wall, and did not" - ), - new BookPageInfo - ( + "our wall, and did not"), + new BookPageInfo( "warn the city when I", "saw the helmeted orc", "captains call the", @@ -4763,10 +3895,8 @@ namespace Server.Items "mansions.", " Blame me not, for", "I was but a child, and", - "one who hid in the" - ), - new BookPageInfo - ( + "one who hid in the"), + new BookPageInfo( "branches of the peach", "trees, all a-tremble", "whilst I watched the", @@ -4774,10 +3904,8 @@ namespace Server.Items "the tailor's, and fire", "lash out at the roof of", "witchy Eleanor's", - "tavern." - ), - new BookPageInfo - ( + "tavern."), + new BookPageInfo( " To this day I have", "had no word of", "Leyla, and to this", @@ -4785,10 +3913,8 @@ namespace Server.Items "burning wood can", "conjure terrible", "dreams. Yet with the", - "eyes of adulthood, 'tis" - ), - new BookPageInfo - ( + "eyes of adulthood, 'tis"), + new BookPageInfo( "possible to examine", "the flaws in the", "defense of Trinsic on", @@ -4796,10 +3922,8 @@ namespace Server.Items "the reasons why our", "walls are now", "double-thick, and", - "why our buildings" - ), - new BookPageInfo - ( + "why our buildings"), + new BookPageInfo( "are now built as", "fortresses within a", "somber fortified city.", @@ -4807,10 +3931,8 @@ namespace Server.Items "out from the top of", "the new Paladin", "tower, and spy the", - "mighty white sails" - ), - new BookPageInfo - ( + "mighty white sails"), + new BookPageInfo( "across the barrier", "island, and can", "descry the small", @@ -4818,10 +3940,8 @@ namespace Server.Items "city where gypsies", "are wont to camp, I", "can also envision the", - "city as it might be" - ), - new BookPageInfo - ( + "city as it might be"), + new BookPageInfo( "burning, and I bless", "the bargain we made:", "space for safety,", @@ -4829,18 +3949,14 @@ namespace Server.Items "and wood for stone.", " Whilst I live, I", "shall not see Trinsic", - "burn, and no more" - ), - new BookPageInfo - ( + "burn, and no more"), + new BookPageInfo( "cries of little girls", "will haunt the sleep", "of our fair citizens.", " - Japheth, Paladin", "Guildmaster of the", - "City of Trinsic" - ) - ); + "City of Trinsic")); [Constructible] public BurningOfTrinsic() : base(Utility.Random(0xFEF, 2), false) @@ -4868,17 +3984,11 @@ namespace Server.Items } } - #endregion - - #region The Fight - public class TheFight : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The Fight", "M. de la Garza", - new BookPageInfo - ( + new BookPageInfo( " A cold autumn's", "morning with misty", "fog secures a dozen", @@ -4886,10 +3996,8 @@ namespace Server.Items "supplying hidden", "shelter from prying", "eyes deep in the", - "foothills of the" - ), - new BookPageInfo - ( + "foothills of the"), + new BookPageInfo( "vibrant valley.", "Dragons soar like", "fierce warriors,", @@ -4897,10 +4005,8 @@ namespace Server.Items "around, then roaring", "like thunder, rallying", "all that listen. The", - "dragons land swiftly" - ), - new BookPageInfo - ( + "dragons land swiftly"), + new BookPageInfo( "beside the proud", "warriors, bending", "necks and extending", @@ -4908,10 +4014,8 @@ namespace Server.Items "claws and allowing", "valiant fighters to", "ride forth and win an", - "arisen battle. The" - ), - new BookPageInfo - ( + "arisen battle. The"), + new BookPageInfo( "increasing winds", "silence the sounds of", "combat, and they", @@ -4919,10 +4023,8 @@ namespace Server.Items "ground like mothers", "protecting their", "childern, bright", - "armor flashing as" - ), - new BookPageInfo - ( + "armor flashing as"), + new BookPageInfo( "each one falls.", " A cold autumn's", "evening with misty", @@ -4930,10 +4032,8 @@ namespace Server.Items "battered corpses of", "knights, creasing", "them in currents of", - "winds that run deep" - ), - new BookPageInfo - ( + "winds that run deep"), + new BookPageInfo( "in the foothills of the", "desolate valley.", "Dragons glide like", @@ -4941,10 +4041,8 @@ namespace Server.Items "around and around,", "then calling like", "banshees; keening", - "cries of mourning." - ), - new BookPageInfo - ( + "cries of mourning."), + new BookPageInfo( "The dragons land", "heavily beside the", "peaceful bodies,", @@ -4952,10 +4050,8 @@ namespace Server.Items "extending wings,", "lifting black claws", "and allowing valiant", - "fighters to ride forth" - ), - new BookPageInfo - ( + "fighters to ride forth"), + new BookPageInfo( "and win an arisen", "battle. The increasing", "winds silence the", @@ -4963,10 +4059,8 @@ namespace Server.Items "they fight, standing", "their ground like", "mothers protecting", - "their childern, bright" - ), - new BookPageInfo - ( + "their childern, bright"), + new BookPageInfo( "armor flashing as", "each one falls.", " A cold autumn's", @@ -4974,10 +4068,8 @@ namespace Server.Items "fog cradles a dozen", "battered corpses of", "knights, creasing", - "them in currents of" - ), - new BookPageInfo - ( + "them in currents of"), + new BookPageInfo( "winds that run deep", "in the foothills of the", "desolate valley.", @@ -4985,10 +4077,8 @@ namespace Server.Items "silent angels, circling", "around and around,", "then calling like", - "banshees; keening" - ), - new BookPageInfo - ( + "banshees; keening"), + new BookPageInfo( "cries of mourning.", "The dragons land", "heavily beside the", @@ -4996,10 +4086,8 @@ namespace Server.Items "bending necks and", "extending wings,", "lifting black claws", - "and pinching the" - ), - new BookPageInfo - ( + "and pinching the"), + new BookPageInfo( "sacred ground and", "new eternal home.", "The dying winds", @@ -5007,16 +4095,12 @@ namespace Server.Items "dead in somber", "procession, and they", "lie, grasping weapons", - "to protect themselves" - ), - new BookPageInfo - ( + "to protect themselves"), + new BookPageInfo( "like knights still in", "battle, shattered", "armor shining like", - "newly born stars." - ) - ); + "newly born stars.")); [Constructible] public TheFight() : base(Utility.Random(0xFEF, 2), false) @@ -5044,17 +4128,11 @@ namespace Server.Items } } - #endregion - - #region The Life of a Travelling Minstrel - public class LifeOfATravellingMinstrel : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The Life of a Travelling Minstrel", "Sarah of Yew", - new BookPageInfo - ( + new BookPageInfo( " While 'tis true that", "the musician who", "seeketh only to make", @@ -5062,10 +4140,8 @@ namespace Server.Items "herself and for", "others needs little", "more than some", - "talent, and stern" - ), - new BookPageInfo - ( + "talent, and stern"), + new BookPageInfo( "practice at the chosen", "instrument, those of", "us who seek the open", @@ -5073,10 +4149,8 @@ namespace Server.Items "that a greater skill is", "required. Herein", "discover those secrets", - "which I have learned" - ), - new BookPageInfo - ( + "which I have learned"), + new BookPageInfo( "over the years as an", "itinerant performer...", " Once I was in", @@ -5084,10 +4158,8 @@ namespace Server.Items "accidentally angered a", "bravo of some local", "repute, whose blade", - "flickered all too" - ), - new BookPageInfo - ( + "flickered all too"), + new BookPageInfo( "eagerly near my", "slender neck (for I", "was young then).", @@ -5095,10 +4167,8 @@ namespace Server.Items "to \"ruin my pretty", "face\" this bravo", "grabbed my arm in a", - "most unseemly" - ), - new BookPageInfo - ( + "most unseemly"), + new BookPageInfo( "fashion and tossed", "me into a barbaric", "enclosure locally", @@ -5106,10 +4176,8 @@ namespace Server.Items "My plaintive cries", "for help went", "unheeded by the", - "guards, for the" - ), - new BookPageInfo - ( + "guards, for the"), + new BookPageInfo( "inhabitants of Jhelom", "are eager indeed to", "measure fighting", @@ -5117,10 +4185,8 @@ namespace Server.Items " What saved me was", "the ability to", "improvise a melody", - "and tune that" - ), - new BookPageInfo - ( + "and tune that"), + new BookPageInfo( "satirized the", "proceedings, and", "sufficiently angered", @@ -5128,10 +4194,8 @@ namespace Server.Items "him to coming to my", "defense. Once that", "fight was underway,", - "I was able to make" - ), - new BookPageInfo - ( + "I was able to make"), + new BookPageInfo( "good my escape.", "Hence, I regard the", "ability to incite fights", @@ -5139,10 +4203,8 @@ namespace Server.Items "the prudent bard.", " Upon another", "occasion, 'twas the", - "obverse side of that" - ), - new BookPageInfo - ( + "obverse side of that"), + new BookPageInfo( "coin which saved me,", "for I was being held", "prisoner by a", @@ -5150,10 +4212,8 @@ namespace Server.Items "band of ruffians who", "had seized me", "unawares from the", - "road to Vesper." - ), - new BookPageInfo - ( + "road to Vesper."), + new BookPageInfo( " They had worked", "themselves into a", "frenzy and were", @@ -5161,10 +4221,8 @@ namespace Server.Items "fear, tear me limb", "from limb, when I", "began to sing", - "frantically, tapping" - ), - new BookPageInfo - ( + "frantically, tapping"), + new BookPageInfo( "my falled drum with", "my tied up feet. The", "melody developed into", @@ -5172,10 +4230,8 @@ namespace Server.Items "the brigands slowly", "calmed down to the", "extent of apologizing,", - "and they let me go!" - ), - new BookPageInfo - ( + "and they let me go!"), + new BookPageInfo( " A final example I", "would pray you grant", "your attention: once I", @@ -5183,10 +4239,8 @@ namespace Server.Items "isle far to the east of", "the mainland, well", "beyond Serpent's", - "Hold, where lava" - ), - new BookPageInfo - ( + "Hold, where lava"), + new BookPageInfo( "made its sluggish", "way across the", "surface landscape.", @@ -5194,10 +4248,8 @@ namespace Server.Items "land was filled with", "vile beasts and", "cunning dragons.", - " I was being pursued" - ), - new BookPageInfo - ( + " I was being pursued"), + new BookPageInfo( "by one of said fell", "dragons when I found", "myself trapped. I", @@ -5205,10 +4257,8 @@ namespace Server.Items "bubbling pool of molten", "rock and attempted to", "hide.", - " The dragon scented" - ), - new BookPageInfo - ( + " The dragon scented"), + new BookPageInfo( "me and was", "preparing to skirt the", "pool, when I began to", @@ -5216,10 +4266,8 @@ namespace Server.Items "upon my lute that", "attracted its attention.", "Mesmerized and", - "enticed by the" - ), - new BookPageInfo - ( + "enticed by the"), + new BookPageInfo( "melody, it stepped", "directly toward sme,", "and into the", @@ -5227,10 +4275,8 @@ namespace Server.Items "was so burned that it", "quickly hopped away,", "undignified and", - "annoyed." - ), - new BookPageInfo - ( + "annoyed."), + new BookPageInfo( " 'Tis my fond hope", "that other travelling", "minstrels shall learn", @@ -5238,13 +4284,9 @@ namespace Server.Items "and apply themselves", "to practicing these", "skills in order to", - "preserve life and" - ), - new BookPageInfo - ( - "limb." - ) - ); + "preserve life and"), + new BookPageInfo( + "limb.")); [Constructible] public LifeOfATravellingMinstrel() : base(Utility.Random(0xFEF, 2), false) @@ -5272,17 +4314,11 @@ namespace Server.Items } } - #endregion - - #region The Major Trade Associations - public class MajorTradeAssociation : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The Major Trade Associations", "Pieter of Vesper", - new BookPageInfo - ( + new BookPageInfo( " There are ten major", "trade associations that", "operate legitimately in", @@ -5290,10 +4326,8 @@ namespace Server.Items "and among its trading", "partners. Many of", "these guilds are", - "divided into local or" - ), - new BookPageInfo - ( + "divided into local or"), + new BookPageInfo( "specialty subguilds,", "who use the same", "colors but vary the", @@ -5301,10 +4335,8 @@ namespace Server.Items " There are many", "lesser trade", "associations that have", - "closed membership," - ), - new BookPageInfo - ( + "closed membership,"), + new BookPageInfo( "and one can join them", "only by invitation.", "Beltran's Guide to", @@ -5312,10 +4344,8 @@ namespace Server.Items "definitive text on the", "full range of guilds", "and other associations", - "in Britannia, and I" - ), - new BookPageInfo - ( + "in Britannia, and I"), + new BookPageInfo( "heartily recommend", "it.", " In what follows I", @@ -5323,10 +4353,8 @@ namespace Server.Items "bring together the", "known information", "regarding these", - "guilds. I offer thee" - ), - new BookPageInfo - ( + "guilds. I offer thee"), + new BookPageInfo( "the name, typical", "membership, heraldic", "colors, known", @@ -5334,10 +4362,8 @@ namespace Server.Items "organizations within", "the larger guild, and", "any known", - "affiliations to other" - ), - new BookPageInfo - ( + "affiliations to other"), + new BookPageInfo( "guilds, which often", "occur because of", "trade reasons.", @@ -5345,10 +4371,8 @@ namespace Server.Items "The Guild of Arcane", "Arts", "Members: alchemists", - "and wizards" - ), - new BookPageInfo - ( + "and wizards"), + new BookPageInfo( "Colors: blue and purple", "Subguilds: Illusionists,", "Mages, Wizards", @@ -5356,10 +4380,8 @@ namespace Server.Items "Guild", "", "The Warrior's Guild", - "Members:" - ), - new BookPageInfo - ( + "Members:"), + new BookPageInfo( "mercenaries,", "soldiery, guardsmen,", "weapons masters,", @@ -5367,10 +4389,8 @@ namespace Server.Items "Colors: Blue and red", "Subguilds: Cavalry,", "Fighters, Warriors", - "Affiliations: League" - ), - new BookPageInfo - ( + "Affiliations: League"), + new BookPageInfo( "of Rangers", "", "League of Rangers", @@ -5378,30 +4398,24 @@ namespace Server.Items "bowyers, animal", "trainers", "Colors: Red, gold and", - "blue" - ), - new BookPageInfo - ( + "blue"), + new BookPageInfo( "", "Guild of Healers", "Members: healers", "Colors: Green, gold,", "and purple", "Affiliations: Guild of", - "Arcane Arts" - ), - new BookPageInfo - ( + "Arcane Arts"), + new BookPageInfo( "Mining Cooperative", "Members: miners", "Colors: blue and black", "checkers, with a gold", "cross", "Affiliations: Order of", - "Engineers" - ), - new BookPageInfo - ( + "Engineers"), + new BookPageInfo( "Merchants'", "Association", "Members:", @@ -5409,30 +4423,24 @@ namespace Server.Items "tavernkeepers,", "jewelers,", "provisioners", - "Colors: gold coins on a" - ), - new BookPageInfo - ( + "Colors: gold coins on a"), + new BookPageInfo( "green field for", "Merchants. White", "and green for the", "others.", "Subguilds: Barters,", "Provisioners,", - "Traders, Merchants" - ), - new BookPageInfo - ( + "Traders, Merchants"), + new BookPageInfo( "Order of Engineers", "Members: tinkers and", "engineers", "Colors: Blue, gold, and", "purple vertical bars", "Affiliations: Mining", - "Cooperative" - ), - new BookPageInfo - ( + "Cooperative"), + new BookPageInfo( "Society of Clothiers", "Members: tailors and", "weavers", @@ -5440,30 +4448,24 @@ namespace Server.Items "and red horizontal", "bars", "", - "Maritime Guild" - ), - new BookPageInfo - ( + "Maritime Guild"), + new BookPageInfo( "Members: fishermen,", "sailors, mapmakers,", "shipwrights", "Colors: blue and white", "Subguilds:", "Fishermen, Sailors,", - "Shipwrights" - ), - new BookPageInfo - ( + "Shipwrights"), + new BookPageInfo( "Bardic Collegium", "Members: bards,", "musicians,", "storytellers, and other", "performers", "Colors: Purple, red", - "and gold checkerboard" - ), - new BookPageInfo - ( + "and gold checkerboard"), + new BookPageInfo( "Society of Thieves", "Members: beggars,", "cutpurses, assassins,", @@ -5471,9 +4473,7 @@ namespace Server.Items "Colors: red and black", "Subguilds: Rogues", "(beggars), Assassins,", - "Thieves" - ) - ); + "Thieves")); [Constructible] public MajorTradeAssociation() : base(Utility.Random(0xFEF, 2), false) @@ -5501,17 +4501,11 @@ namespace Server.Items } } - #endregion - - #region The Rankings of Trades - public class RankingsOfTrades : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The Rankings of Trades", "Lord Higginbotham", - new BookPageInfo - ( + new BookPageInfo( " Whilst 'tis true that", "within each trade, one", "finds differing titles", @@ -5519,10 +4513,8 @@ namespace Server.Items "to the members of a", "given guild,", "nonetheless for the", - "betterment of trade" - ), - new BookPageInfo - ( + "betterment of trade"), + new BookPageInfo( "and understanding,", "we must have a", "commonality of", @@ -5530,10 +4522,8 @@ namespace Server.Items " For those who may", "find themselves", "ignorant of the finer", - "distinctions between a" - ), - new BookPageInfo - ( + "distinctions between a"), + new BookPageInfo( "three-knot member of", "the Sailors' Maritime", "Association and a", @@ -5541,10 +4531,8 @@ namespace Server.Items "this book shall serve", "as a simple", "introduction to the", - "common cant used" - ), - new BookPageInfo - ( + "common cant used"), + new BookPageInfo( "when members of", "differing guilds and", "trade organizations", @@ -5552,10 +4540,8 @@ namespace Server.Items "other and must", "establish relative", "credentials.", - " Neophyte" - ), - new BookPageInfo - ( + " Neophyte"), + new BookPageInfo( "Has shown interest", "in learning the craft", "and some meager", @@ -5563,10 +4549,8 @@ namespace Server.Items " Novice", "Is practicing basic", "skills but has not been", - "admitted to full" - ), - new BookPageInfo - ( + "admitted to full"), + new BookPageInfo( "standing.", " Apprentice", "A student of the", @@ -5574,10 +4558,8 @@ namespace Server.Items " Journeyman", "Warranted to practice", "the discipline under", - "the eyes of a tutor." - ), - new BookPageInfo - ( + "the eyes of a tutor."), + new BookPageInfo( " Expert", "A full member of the", "guild.", @@ -5585,10 +4567,8 @@ namespace Server.Items "A member of the", "guild qualified to", "teach others.", - " Master" - ), - new BookPageInfo - ( + " Master"), + new BookPageInfo( "Acknowledged as", "qualified to lead a hall", "or business.", @@ -5596,15 +4576,11 @@ namespace Server.Items "Rarely a permanent", "title, granted in", "common parlance to", - "those who have" - ), - new BookPageInfo - ( + "those who have"), + new BookPageInfo( "shown extreme", "mastery of their", - "craft recently." - ) - ); + "craft recently.")); [Constructible] public RankingsOfTrades() : base(Utility.Random(0xFEF, 2), false) @@ -5632,17 +4608,11 @@ namespace Server.Items } } - #endregion - - #region The Wild Girl of the Forest - public class WildGirlOfTheForest : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "The Wild Girl of the Forest", "Horace the Trader", - new BookPageInfo - ( + new BookPageInfo( " Her name was", "Leyla, she said, and", "her hair was braided", @@ -5650,10 +4620,8 @@ namespace Server.Items "and thorns. I", "marveled that they", "did not hurt her, but", - "when I asked, she but" - ), - new BookPageInfo - ( + "when I asked, she but"), + new BookPageInfo( "shrugged and let her", "eyes roam once more", "across the woods.", @@ -5661,10 +4629,8 @@ namespace Server.Items "hands securely", "fastened by her", "ropes, I itched to", - "reach out and comb" - ), - new BookPageInfo - ( + "reach out and comb"), + new BookPageInfo( "that unruly golden", "mane, dirtied and", "leaf-ridden.", @@ -5672,10 +4638,8 @@ namespace Server.Items "she told me over", "nights illumined by", "campfires, was once", - "the city of Trinsic." - ), - new BookPageInfo - ( + "the city of Trinsic."), + new BookPageInfo( "She claimed to have", "been kidnapped and", "raised by orcs, which", @@ -5683,10 +4647,8 @@ namespace Server.Items "tale, for all know orcs", "delight in eating the", "meat of honest folk.", - "When I told her this," - ), - new BookPageInfo - ( + "When I told her this,"), + new BookPageInfo( "she laughed a fey", "laugh, and gaily", "admitted that honest", @@ -5694,10 +4656,8 @@ namespace Server.Items "had she stolen folk", "away from caravans", "to loot their", - "possessions from an" - ), - new BookPageInfo - ( + "possessions from an"), + new BookPageInfo( "unconscious body!", " At this, I began to", "fear for my life, and", @@ -5705,10 +4665,8 @@ namespace Server.Items "of teeth sharper than", "a human ought to", "have, for the tale of", - "orcish raising had" - ), - new BookPageInfo - ( + "orcish raising had"), + new BookPageInfo( "struck fear into the", "marrow of my bones.", "\"Wilt thou eat me?\" I", @@ -5716,10 +4674,8 @@ namespace Server.Items "fearing the answer.", " And she cocked", "her head at me, like a", - "wild animal facing a" - ), - new BookPageInfo - ( + "wild animal facing a"), + new BookPageInfo( "word that it dost not", "understand, and the", "fixity in her eyes", @@ -5727,10 +4683,8 @@ namespace Server.Items "the deeper reaches of", "the Abyss. But she", "finally grunted, and", - "said, \"Nay,\" in a" - ), - new BookPageInfo - ( + "said, \"Nay,\" in a"), + new BookPageInfo( "voice that recalled to", "me a child. \"Nay,\"", "she said, \"for thou", @@ -5738,10 +4692,8 @@ namespace Server.Items "boy I knew once,", "when I was a girl", "who played in a city", - "of great sandstone" - ), - new BookPageInfo - ( + "of great sandstone"), + new BookPageInfo( "walls, before I was", "taken. He had sandy", "hair like thee, and I", @@ -5749,10 +4701,8 @@ namespace Server.Items "holding his hand and", "sharing flavored ice.", "His name was", - "Japheth.\"" - ), - new BookPageInfo - ( + "Japheth.\""), + new BookPageInfo( " The next morning", "she let me go,", "stripped of my pouch", @@ -5760,10 +4710,8 @@ namespace Server.Items "me run through the", "woods, and to fear", "recapture, for surely", - "her heart would not" - ), - new BookPageInfo - ( + "her heart would not"), + new BookPageInfo( "soften again. 'Twas a", "fearful run, and I", "came to the road to", @@ -5771,10 +4719,8 @@ namespace Server.Items "scratches run", "rampant crost my", "skin, but I did not see", - "her again." - ), - new BookPageInfo - ( + "her again."), + new BookPageInfo( " Oft have I", "wondered of the boy", "named Japheth, and", @@ -5782,10 +4728,8 @@ namespace Server.Items "remembers a girl who", "lived in sandstone", "walls. The only", - "Japheth I know is the" - ), - new BookPageInfo - ( + "Japheth I know is the"), + new BookPageInfo( "Guildmaster of", "Paladins who died", "last year warring", @@ -5793,10 +4737,8 @@ namespace Server.Items "though he had indeed", "sandy hair, I cannot", "picture him side by", - "side with a feral girl" - ), - new BookPageInfo - ( + "side with a feral girl"), + new BookPageInfo( "whose tongue has", "tasted of human", "flesh.", @@ -5804,18 +4746,14 @@ namespace Server.Items "fate are strange", "indeed, and I suppose", "'tis possible that this", - "paladin died" - ), - new BookPageInfo - ( + "paladin died"), + new BookPageInfo( "defending his", "remembered lady's", "honor, unknowingly", "struck down by the", "orc that she called", - "father." - ) - ); + "father.")); [Constructible] public WildGirlOfTheForest() : base(Utility.Random(0xFEF, 2), false) @@ -5843,17 +4781,11 @@ namespace Server.Items } } - #endregion - - #region Treatise on Alchemy - public class TreatiseOnAlchemy : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Treatise on Alchemy", "Felicia Hierophant", - new BookPageInfo - ( + new BookPageInfo( " The alchemical", "arts are notable for", "their deceptive", @@ -5861,10 +4793,8 @@ namespace Server.Items "that to our best", "knowledge currently,", "there are but eight", - "valid potions that can" - ), - new BookPageInfo - ( + "valid potions that can"), + new BookPageInfo( "be made (though I", "emphasize that new", "discoveries may", @@ -5872,10 +4802,8 @@ namespace Server.Items "However, the delicate", "balance of confecting", "the potions is", - "difficult indeed, and" - ), - new BookPageInfo - ( + "difficult indeed, and"), + new BookPageInfo( "requires great skill.", " To give thee an", "example of the", @@ -5883,10 +4811,8 @@ namespace Server.Items "can be created by", "those well-versed in", "the subtleties of", - "alchemy:" - ), - new BookPageInfo - ( + "alchemy:"), + new BookPageInfo( " Black pearl, that", "rare substance that is", "oft found lying", @@ -5894,10 +4820,8 @@ namespace Server.Items "surface of the", "ground, when", "properly crushed", - "with mortar and" - ), - new BookPageInfo - ( + "with mortar and"), + new BookPageInfo( "pestle, can yield a", "fine powder. Said", "powder in the proper", @@ -5905,10 +4829,8 @@ namespace Server.Items "mixed via the", "alchemical arts can", "yield a wonderfully", - "refreshing drink." - ), - new BookPageInfo - ( + "refreshing drink."), + new BookPageInfo( " The revolting blood", "moss so gingerly", "scraped off of", @@ -5916,10 +4838,8 @@ namespace Server.Items "fastidious housewives", "is but a tiny cousin to", "the wilder version,", - "which when properly" - ), - new BookPageInfo - ( + "which when properly"), + new BookPageInfo( "prepared yields a", "magical liquid that for", "a time can make the", @@ -5927,10 +4847,8 @@ namespace Server.Items "and dextrous", "individual.", " However, beware", - "of the deadly" - ), - new BookPageInfo - ( + "of the deadly"), + new BookPageInfo( "nightshade, for it", "yields a deceptively", "sweet-tasting poison", @@ -5938,10 +4856,8 @@ namespace Server.Items "fatal to the drinker,", "and in fact is also", "used by assassins to", - "coat their blades." - ), - new BookPageInfo - ( + "coat their blades."), + new BookPageInfo( "Fortunately, this", "latter art of poisoning", "is little known!", @@ -5949,10 +4865,8 @@ namespace Server.Items "reward the student of", "alchemy, indeed. The", "rumours of longtime", - "alchemists losing" - ), - new BookPageInfo - ( + "alchemists losing"), + new BookPageInfo( "their hair and", "acquiring an", "unhealthy pallor, not", @@ -5960,10 +4874,8 @@ namespace Server.Items "blotches upon their", "once-fair skin, are", "unhappily, true. Yet", - "the joys of the mind" - ), - new BookPageInfo - ( + "the joys of the mind"), + new BookPageInfo( "make up for the", "complete loss of", "interest that others", @@ -5971,13 +4883,9 @@ namespace Server.Items "an object of", "courtship, and I have", "never regretted that", - "choice. Honestly," - ), - new BookPageInfo - ( - "truly. Not once." - ) - ); + "choice. Honestly,"), + new BookPageInfo( + "truly. Not once.")); [Constructible] public TreatiseOnAlchemy() : base(Utility.Random(0xFEF, 2), false) @@ -6005,17 +4913,11 @@ namespace Server.Items } } - #endregion - - #region Virtue - public class VirtueBook : BaseBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Virtue", "Lord British", - new BookPageInfo - ( + new BookPageInfo( " Within this world", "live people with many", "different ideals, and", @@ -6023,10 +4925,8 @@ namespace Server.Items "is it within the people", "of our land that sorts", "out the good from the", - "evil, the cherished" - ), - new BookPageInfo - ( + "evil, the cherished"), + new BookPageInfo( "form the disdained?", "Virtue, I say it is,", "and virtue is the", @@ -6034,10 +4934,8 @@ namespace Server.Items "people who wish to", "live together in a", "bonded society.", - " For without Virtues" - ), - new BookPageInfo - ( + " For without Virtues"), + new BookPageInfo( "as a code of conduct", "which people maintain", "in their relations", @@ -6045,10 +4943,8 @@ namespace Server.Items "fabric of that society", "will become weakened.", "For a society to grow", - "and prosper for all," - ), - new BookPageInfo - ( + "and prosper for all,"), + new BookPageInfo( "each must grant the", "others a common base", "of consideration.", @@ -6056,10 +4952,8 @@ namespace Server.Items "Virtues. For though", "one person might gain", "personal advantage by", - "breaching such a" - ), - new BookPageInfo - ( + "breaching such a"), + new BookPageInfo( "code, the society as a", "whole would suffer.", " There are three", @@ -6067,10 +4961,8 @@ namespace Server.Items "should guide people to", "enlightenment. These", "are: Truth, Love and", - "Courage. From all the" - ), - new BookPageInfo - ( + "Courage. From all the"), + new BookPageInfo( "infinite reasons one", "may have to found an", "action, such as greed", @@ -6078,10 +4970,8 @@ namespace Server.Items "pity, the three", "Principle Virtues", "stand out.", - " In fact all other" - ), - new BookPageInfo - ( + " In fact all other"), + new BookPageInfo( "virtues and vices can", "be show to be built", "from these principles", @@ -6089,10 +4979,8 @@ namespace Server.Items "corruption's of", "Falsehood, Hatred and", "Cowardice. These", - "three Principles can" - ), - new BookPageInfo - ( + "three Principles can"), + new BookPageInfo( "be combined in eight", "ways, which I will", "call the eight virtues.", @@ -6100,10 +4988,8 @@ namespace Server.Items "which we should", "build our society upon", "follow.", - " Truth alone becomes" - ), - new BookPageInfo - ( + " Truth alone becomes"), + new BookPageInfo( "Honesty, for without", "honesty between our", "people, how can we", @@ -6111,10 +4997,8 @@ namespace Server.Items "is needed to", "maximize our", "successes.", - " Love alone becomes" - ), - new BookPageInfo - ( + " Love alone becomes"), + new BookPageInfo( "compassion, for at", "some time or another", "all of us will need the", @@ -6122,10 +5006,8 @@ namespace Server.Items "and most likely", "compassion will be", "shown to those who", - "have shown it." - ), - new BookPageInfo - ( + "have shown it."), + new BookPageInfo( " Courage alone", "becomes Valor,", "without valor our", @@ -6133,10 +5015,8 @@ namespace Server.Items "reach into the", "unknown or to the", "risky and will never", - "achieve." - ), - new BookPageInfo - ( + "achieve."), + new BookPageInfo( " Truth tempered by", "Love give us Justice,", "for only in a loving", @@ -6144,10 +5024,8 @@ namespace Server.Items "can one dispense fair", "Justice, rather than", "create a cold and", - "callous people." - ), - new BookPageInfo - ( + "callous people."), + new BookPageInfo( " Love and Courage", "give us Sacrifice, for", "a people who love each", @@ -6155,10 +5033,8 @@ namespace Server.Items "to make personal", "sacrifices to help", "other in need, which", - "one day, may be" - ), - new BookPageInfo - ( + "one day, may be"), + new BookPageInfo( "needed in return.", " Courage and Truth", "give us Honor, great", @@ -6166,10 +5042,8 @@ namespace Server.Items "well, that chivalric", "honor can be found", "by adhering to this", - "code of conduct." - ), - new BookPageInfo - ( + "code of conduct."), + new BookPageInfo( " Combining Truth,", "Love and Courage", "suggest the virtue of", @@ -6177,10 +5051,8 @@ namespace Server.Items "that causes one to be", "introspective, to", "wonder about ones", - "place in this world" - ), - new BookPageInfo - ( + "place in this world"), + new BookPageInfo( "and whether one's", "deeds will be recorded", "as a gift to the world", @@ -6188,10 +5060,8 @@ namespace Server.Items " The final Virtue is", "more complicated. For", "the eighth combination", - "is that devoid of" - ), - new BookPageInfo - ( + "is that devoid of"), + new BookPageInfo( "Truth, Love or", "Courage which can", "only exist in a state", @@ -6199,10 +5069,8 @@ namespace Server.Items "of course is not a", "virtue at all. Perhaps", "this trick of fate is a", - "test to see if one can" - ), - new BookPageInfo - ( + "test to see if one can"), + new BookPageInfo( "realize that the true", "virtue is that of", "Humility. I feel that", @@ -6210,10 +5078,8 @@ namespace Server.Items "Magincia fail to see", "this to such a degree", "that I would not be", - "surprised if some ill" - ), - new BookPageInfo - ( + "surprised if some ill"), + new BookPageInfo( "fate awaited their", "future.", " Thus from the", @@ -6221,18 +5087,14 @@ namespace Server.Items "which spawned the", "Three Principles of", "Truth, Love and", - "Courage, come the" - ), - new BookPageInfo - ( + "Courage, come the"), + new BookPageInfo( "Eight Virtues of", "Honesty, Compassion,", "Valor, Justice,", "Sacrifice, Honor,", "Spirituality, and", - "Humility." - ) - ); + "Humility.")); [Constructible] public VirtueBook() : base(Utility.Random(0xFEF, 2), false) @@ -6259,6 +5121,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } - - #endregion } \ No newline at end of file diff --git a/Projects/Scripts/Items/Books/Defined/NewAquariumBook.cs b/Projects/Scripts/Items/Books/Defined/NewAquariumBook.cs index 27e14d3b8..c3b78e54d 100644 --- a/Projects/Scripts/Items/Books/Defined/NewAquariumBook.cs +++ b/Projects/Scripts/Items/Books/Defined/NewAquariumBook.cs @@ -2,20 +2,16 @@ namespace Server.Items { public class NewAquariumBook : BlueBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Your New Aquarium", "Les Bilgewater", - new BookPageInfo - ( + new BookPageInfo( "Welcome to the", "wonderful world", "of aquarium ownership.", "With a little time and", "skill your aquarium can", - "become a work of art!" - ), - new BookPageInfo - ( + "become a work of art!"), + new BookPageInfo( "Catching Fish:", "You will need to", "aquire a fishing net,", @@ -23,10 +19,8 @@ namespace Server.Items "bowls, from your local", "fisherman.", "To use the net,", - "select it from your" - ), - new BookPageInfo - ( + "select it from your"), + new BookPageInfo( "backpack, and cast it", "into shallow water.", "Then we wait.", @@ -34,19 +28,15 @@ namespace Server.Items "happy to be in your", "aquarium, they will", "jump right into your", - "fish bowl when caught!" - ), - new BookPageInfo - ( + "fish bowl when caught!"), + new BookPageInfo( "Just take them home", "and pour them into", "your aquarium, and", "BING! You have a happy", "new addition to your", - "collection!" - ), - new BookPageInfo - ( + "collection!"), + new BookPageInfo( "Caring for our", "Underwater Allies:", "", @@ -54,10 +44,8 @@ namespace Server.Items "water and food to", "survive.", " Our aquarium comes", - "with a status monitoring" - ), - new BookPageInfo - ( + "with a status monitoring"), + new BookPageInfo( "aid. Must be Magic!", " Just look at the", "front of your aquarium", @@ -65,10 +53,8 @@ namespace Server.Items "helpful and friendly", "guide? It tells how much", "food and water is", - "needed to maintain," - ), - new BookPageInfo - ( + "needed to maintain,"), + new BookPageInfo( "and improve the quality", "of your tank.", " You dont want to", @@ -76,10 +62,8 @@ namespace Server.Items "very often. In fact,", "you only want to feed", "them every other day.", - "But, remember to keep" - ), - new BookPageInfo - ( + "But, remember to keep"), + new BookPageInfo( "the water strong and", "healthy, and add more", "on a regular basis", @@ -87,18 +71,14 @@ namespace Server.Items "a pretty, sparkely blue.", "", " Well, I hope you", - "get as much enjoyment," - ), - new BookPageInfo - ( + "get as much enjoyment,"), + new BookPageInfo( "collecting a beautiful", "array of our fine, finned,", "friends from the sea,", "as I do!", "", - "Happy Fishing!" - ) - ); + "Happy Fishing!")); [Constructible] public NewAquariumBook() : base(false) => Hue = 0; diff --git a/Projects/Scripts/Items/Books/Defined/TranslatedGargoyleJournal.cs b/Projects/Scripts/Items/Books/Defined/TranslatedGargoyleJournal.cs index decdc3936..5b00f6f6b 100644 --- a/Projects/Scripts/Items/Books/Defined/TranslatedGargoyleJournal.cs +++ b/Projects/Scripts/Items/Books/Defined/TranslatedGargoyleJournal.cs @@ -2,11 +2,9 @@ namespace Server.Items { public class TranslatedGargoyleJournal : BlueBook { - public static readonly BookContent Content = new BookContent - ( + public static readonly BookContent Content = new BookContent( "Translated Journal", "Velis", - new BookPageInfo - ( + new BookPageInfo( "This text has been", "translated from a", "gargoyle's journal", @@ -14,10 +12,8 @@ namespace Server.Items "and subsequent", "reeducation.", "", - " -Velis" - ), - new BookPageInfo - ( + " -Velis"), + new BookPageInfo( "I write this in the", "hopes that someday a", "soul of pure heart and", @@ -25,10 +21,8 @@ namespace Server.Items "are not the evil beings", "that our cousin", "gargoyles have made", - "us out to be. We" - ), - new BookPageInfo - ( + "us out to be. We"), + new BookPageInfo( "consider them", "uncivilized and they", "have no concept of the", @@ -36,10 +30,8 @@ namespace Server.Items "who reads this, I beg", "for your help in", "saving my brethern", - "and preserving my" - ), - new BookPageInfo - ( + "and preserving my"), + new BookPageInfo( "race. We stand at the", "edge of destruction as", "does the rest of the", @@ -47,10 +39,8 @@ namespace Server.Items "written law that we", "would not allow the", "knowledge of our", - "civilization to spread" - ), - new BookPageInfo - ( + "civilization to spread"), + new BookPageInfo( "into the world, no we", "are left with little", "choice...contact the", @@ -58,10 +48,8 @@ namespace Server.Items "of finding help to save", "it or becoming the", "unwilling bringers of", - "its damnation." - ), - new BookPageInfo - ( + "its damnation."), + new BookPageInfo( " I fear my capture is", "certain, the", "controllers grow ever", @@ -69,10 +57,8 @@ namespace Server.Items "place and I know if", "they discover me, my", "fate will be as that of", - "my brothers." - ), - new BookPageInfo - ( + "my brothers."), + new BookPageInfo( "Although we resisted", "with all our strength", "it is now clear that we", @@ -80,10 +66,8 @@ namespace Server.Items "or our people will be", "gone. And if our", "oppressor achieves", - "his goals our race will" - ), - new BookPageInfo - ( + "his goals our race will"), + new BookPageInfo( "surely be joined buy", "others.", " Those of us who", @@ -91,10 +75,8 @@ namespace Server.Items "taken hope to open a", "path from the outside", "world into the city.", - "We believe we have" - ), - new BookPageInfo - ( + "We believe we have"), + new BookPageInfo( "found weak areas in", "the mountains that we", "can successfully", @@ -102,26 +84,16 @@ namespace Server.Items "our limited supplies.", "We will have to work", "quickly and the risk", - "of being discovered is" - ), - new BookPageInfo - ( + "of being discovered is"), + new BookPageInfo( "great, but no choice", - "remains..." - ), - new BookPageInfo - ( - ), - new BookPageInfo - ( - ), - new BookPageInfo - ( + "remains..."), + new BookPageInfo(), + new BookPageInfo(), + new BookPageInfo( "Kai Hohiro, 12pm.", "10.11.2001", - "first one to be here" - ) - ); + "first one to be here")); [Constructible] public TranslatedGargoyleJournal() : base(false) diff --git a/Projects/Scripts/Items/Champion Artifacts/Decorative/Pier.cs b/Projects/Scripts/Items/Champion Artifacts/Decorative/Pier.cs index 61841b84d..aa22818dc 100644 --- a/Projects/Scripts/Items/Champion Artifacts/Decorative/Pier.cs +++ b/Projects/Scripts/Items/Champion Artifacts/Decorative/Pier.cs @@ -8,15 +8,15 @@ namespace Server.Items * to do with piers. The three items here are basically * permutations of the same "drop", or item that * will be randomly selected when the item drops. - * + * * It was either this, or make 2 * new classes named to reflect that they are rocks * in water, or put them all in one class. Either * is kind of senseless, so it is what it is. - * + * */ - private static int[] m_itemids = + private static readonly int[] m_itemids = { 0x3486, 0x348b, 0x3ae }; diff --git a/Projects/Scripts/Items/Champion Artifacts/Decorative/Web.cs b/Projects/Scripts/Items/Champion Artifacts/Decorative/Web.cs index 7e5d943fa..c8018d093 100644 --- a/Projects/Scripts/Items/Champion Artifacts/Decorative/Web.cs +++ b/Projects/Scripts/Items/Champion Artifacts/Decorative/Web.cs @@ -2,7 +2,7 @@ namespace Server.Items { public class Web : Item { - private static int[] m_itemids = + private static readonly int[] m_itemids = { 0x10d7, 0x10d8, 0x10dd }; diff --git a/Projects/Scripts/Items/Clothing/Artifacts/DivineCountenance.cs b/Projects/Scripts/Items/Clothing/Artifacts/DivineCountenance.cs index 264e3bff0..71df83612 100644 --- a/Projects/Scripts/Items/Clothing/Artifacts/DivineCountenance.cs +++ b/Projects/Scripts/Items/Clothing/Artifacts/DivineCountenance.cs @@ -45,13 +45,13 @@ namespace Server.Items switch (version) { case 0: - { - Resistances.Physical = 0; - Resistances.Fire = 0; - Resistances.Cold = 0; - Resistances.Energy = 0; - break; - } + { + Resistances.Physical = 0; + Resistances.Fire = 0; + Resistances.Cold = 0; + Resistances.Energy = 0; + break; + } } } } diff --git a/Projects/Scripts/Items/Clothing/Artifacts/HatOfTheMagi.cs b/Projects/Scripts/Items/Clothing/Artifacts/HatOfTheMagi.cs index ffb766347..03fa2d6ed 100644 --- a/Projects/Scripts/Items/Clothing/Artifacts/HatOfTheMagi.cs +++ b/Projects/Scripts/Items/Clothing/Artifacts/HatOfTheMagi.cs @@ -42,11 +42,11 @@ namespace Server.Items switch (version) { case 0: - { - Resistances.Poison = 0; - Resistances.Energy = 0; - break; - } + { + Resistances.Poison = 0; + Resistances.Energy = 0; + break; + } } } } diff --git a/Projects/Scripts/Items/Clothing/Artifacts/HuntersHeaddress.cs b/Projects/Scripts/Items/Clothing/Artifacts/HuntersHeaddress.cs index 646012aa3..05ece8103 100644 --- a/Projects/Scripts/Items/Clothing/Artifacts/HuntersHeaddress.cs +++ b/Projects/Scripts/Items/Clothing/Artifacts/HuntersHeaddress.cs @@ -42,10 +42,10 @@ namespace Server.Items switch (version) { case 0: - { - Resistances.Cold = 0; - break; - } + { + Resistances.Cold = 0; + break; + } } } } diff --git a/Projects/Scripts/Items/Clothing/Artifacts/SpiritOfTheTotem.cs b/Projects/Scripts/Items/Clothing/Artifacts/SpiritOfTheTotem.cs index 6e22a9b6a..6b63788b0 100644 --- a/Projects/Scripts/Items/Clothing/Artifacts/SpiritOfTheTotem.cs +++ b/Projects/Scripts/Items/Clothing/Artifacts/SpiritOfTheTotem.cs @@ -41,10 +41,10 @@ namespace Server.Items switch (version) { case 0: - { - Resistances.Physical = 0; - break; - } + { + Resistances.Physical = 0; + break; + } } } } diff --git a/Projects/Scripts/Items/Clothing/BaseClothing.cs b/Projects/Scripts/Items/Clothing/BaseClothing.cs index b024c7632..05b82c747 100644 --- a/Projects/Scripts/Items/Clothing/BaseClothing.cs +++ b/Projects/Scripts/Items/Clothing/BaseClothing.cs @@ -17,9 +17,9 @@ namespace Server.Items public interface IArcaneEquip { - bool IsArcane{ get; } - int CurArcaneCharges{ get; set; } - int MaxArcaneCharges{ get; set; } + bool IsArcane { get; } + int CurArcaneCharges { get; set; } + int MaxArcaneCharges { get; set; } } public abstract class BaseClothing : Item, IDyable, IScissorable, IFactionItem, ICraftable, IWearableDurability @@ -86,7 +86,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool PlayerConstructed{ get; set; } + public bool PlayerConstructed { get; set; } public virtual CraftResource DefaultResource => CraftResource.None; @@ -103,16 +103,16 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public AosAttributes Attributes{ get; private set; } + public AosAttributes Attributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosArmorAttributes ClothingAttributes{ get; private set; } + public AosArmorAttributes ClothingAttributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosSkillBonuses SkillBonuses{ get; private set; } + public AosSkillBonuses SkillBonuses { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosElementAttributes Resistances{ get; private set; } + public AosElementAttributes Resistances { get; private set; } public virtual int BasePhysicalResistance => 0; public virtual int BaseFireResistance => 0; @@ -141,8 +141,6 @@ namespace Server.Items public virtual bool AllowFemaleWearer => true; public virtual bool CanBeBlessed => true; - #region ICraftable Members - public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -172,8 +170,6 @@ namespace Server.Items return quality; } - #endregion - public virtual bool Dye(Mobile from, DyeTub sender) { if (Deleted) @@ -273,7 +269,7 @@ namespace Server.Items if (damageTaken < 0) damageTaken = 0; - if (25 > Utility.Random(100)) // 25% chance to lower durability + if (Utility.Random(100) < 25) // 25% chance to lower durability { if (Core.AOS && ClothingAttributes.SelfRepair > Utility.Random(10)) { @@ -404,7 +400,7 @@ namespace Server.Items { int v; - //if ( type == StatType.Str ) + // if (type == StatType.Str) v = StrRequirement; return AOS.Scale(v, 100 - GetLowerStatReq()); @@ -600,13 +596,9 @@ namespace Server.Items if (m_Crafter != null) list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ - #region Factions - if (m_FactionState != null) list.Add(1041350); // faction item - #endregion - if (m_Quality == ClothingQuality.Exceptional) list.Add(1060636); // exceptional @@ -701,7 +693,7 @@ namespace Server.Items if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% - base.AddResistanceProperties(list); + this.AddResistanceProperties(list); if ((prop = ClothingAttributes.DurabilityBonus) > 0) list.Add(1060410, prop.ToString()); // durability ~1_val~% @@ -749,13 +741,9 @@ namespace Server.Items attrs.Add(new EquipInfoAttribute(1049643)); // cursed } - #region Factions - if (m_FactionState != null) attrs.Add(new EquipInfoAttribute(1041350)); // faction item - #endregion - if (m_Quality == ClothingQuality.Exceptional) attrs.Add(new EquipInfoAttribute(1018305 - (int)m_Quality)); } @@ -785,8 +773,6 @@ namespace Server.Items InvalidateProperties(); } - #region Factions - private FactionItem m_FactionState; public FactionItem FactionItemState @@ -803,10 +789,6 @@ namespace Server.Items } } - #endregion - - #region Serialization - private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) @@ -894,90 +876,90 @@ namespace Server.Items switch (version) { case 5: - { - SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); + { + SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.Resource)) - m_Resource = (CraftResource)reader.ReadEncodedInt(); - else - m_Resource = DefaultResource; + if (GetSaveFlag(flags, SaveFlag.Resource)) + m_Resource = (CraftResource)reader.ReadEncodedInt(); + else + m_Resource = DefaultResource; - if (GetSaveFlag(flags, SaveFlag.Attributes)) - Attributes = new AosAttributes(this, reader); - else - Attributes = new AosAttributes(this); + if (GetSaveFlag(flags, SaveFlag.Attributes)) + Attributes = new AosAttributes(this, reader); + else + Attributes = new AosAttributes(this); - if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) - ClothingAttributes = new AosArmorAttributes(this, reader); - else - ClothingAttributes = new AosArmorAttributes(this); + if (GetSaveFlag(flags, SaveFlag.ClothingAttributes)) + ClothingAttributes = new AosArmorAttributes(this, reader); + else + ClothingAttributes = new AosArmorAttributes(this); - if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) - SkillBonuses = new AosSkillBonuses(this, reader); - else - SkillBonuses = new AosSkillBonuses(this); + if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + SkillBonuses = new AosSkillBonuses(this, reader); + else + SkillBonuses = new AosSkillBonuses(this); - if (GetSaveFlag(flags, SaveFlag.Resistances)) - Resistances = new AosElementAttributes(this, reader); - else - Resistances = new AosElementAttributes(this); + if (GetSaveFlag(flags, SaveFlag.Resistances)) + Resistances = new AosElementAttributes(this, reader); + else + Resistances = new AosElementAttributes(this); - if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) - m_MaxHitPoints = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.MaxHitPoints)) + m_MaxHitPoints = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.HitPoints)) - m_HitPoints = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.HitPoints)) + m_HitPoints = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.Crafter)) - m_Crafter = reader.ReadMobile(); + if (GetSaveFlag(flags, SaveFlag.Crafter)) + m_Crafter = reader.ReadMobile(); - if (GetSaveFlag(flags, SaveFlag.Quality)) - m_Quality = (ClothingQuality)reader.ReadEncodedInt(); - else - m_Quality = ClothingQuality.Regular; + if (GetSaveFlag(flags, SaveFlag.Quality)) + m_Quality = (ClothingQuality)reader.ReadEncodedInt(); + else + m_Quality = ClothingQuality.Regular; - if (GetSaveFlag(flags, SaveFlag.StrReq)) - m_StrReq = reader.ReadEncodedInt(); - else - m_StrReq = -1; + if (GetSaveFlag(flags, SaveFlag.StrReq)) + m_StrReq = reader.ReadEncodedInt(); + else + m_StrReq = -1; - if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) - PlayerConstructed = true; + if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) + PlayerConstructed = true; - break; - } + break; + } case 4: - { - m_Resource = (CraftResource)reader.ReadInt(); + { + m_Resource = (CraftResource)reader.ReadInt(); - goto case 3; - } + goto case 3; + } case 3: - { - Attributes = new AosAttributes(this, reader); - ClothingAttributes = new AosArmorAttributes(this, reader); - SkillBonuses = new AosSkillBonuses(this, reader); - Resistances = new AosElementAttributes(this, reader); + { + Attributes = new AosAttributes(this, reader); + ClothingAttributes = new AosArmorAttributes(this, reader); + SkillBonuses = new AosSkillBonuses(this, reader); + Resistances = new AosElementAttributes(this, reader); - goto case 2; - } + goto case 2; + } case 2: - { - PlayerConstructed = reader.ReadBool(); - goto case 1; - } + { + PlayerConstructed = reader.ReadBool(); + goto case 1; + } case 1: - { - m_Crafter = reader.ReadMobile(); - m_Quality = (ClothingQuality)reader.ReadInt(); - break; - } + { + m_Crafter = reader.ReadMobile(); + m_Quality = (ClothingQuality)reader.ReadInt(); + break; + } case 0: - { - m_Crafter = null; - m_Quality = ClothingQuality.Regular; - break; - } + { + m_Crafter = null; + m_Quality = ClothingQuality.Regular; + break; + } } if (version < 2) @@ -1006,7 +988,5 @@ namespace Server.Items parent.CheckStatTimers(); } } - - #endregion } } diff --git a/Projects/Scripts/Items/Clothing/Cloaks.cs b/Projects/Scripts/Items/Clothing/Cloaks.cs index 640094e60..02d23e035 100644 --- a/Projects/Scripts/Items/Clothing/Cloaks.cs +++ b/Projects/Scripts/Items/Clothing/Cloaks.cs @@ -64,26 +64,24 @@ namespace Server.Items switch (version) { case 1: - { - if (reader.ReadBool()) { - m_CurArcaneCharges = reader.ReadInt(); - m_MaxArcaneCharges = reader.ReadInt(); + if (reader.ReadBool()) + { + m_CurArcaneCharges = reader.ReadInt(); + m_MaxArcaneCharges = reader.ReadInt(); - if (Hue == 2118) - Hue = ArcaneGem.DefaultArcaneHue; + if (Hue == 2118) + Hue = ArcaneGem.DefaultArcaneHue; + } + + break; } - - break; - } } if (Weight == 4.0) Weight = 5.0; } - #region Arcane Impl - private int m_MaxArcaneCharges, m_CurArcaneCharges; [CommandProperty(AccessLevel.GameMaster)] @@ -147,8 +145,6 @@ namespace Server.Items else if (ItemID == 0x1530) ItemID = 0x1515; } - - #endregion } [Flippable] @@ -194,7 +190,7 @@ namespace Server.Items public override int BasePhysicalResistance => 3; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnAdded(IEntity parent) { @@ -254,11 +250,11 @@ namespace Server.Items switch (version) { case 0: - { - m_LabelNumber = reader.ReadInt(); - IsRewardItem = reader.ReadBool(); - break; - } + { + m_LabelNumber = reader.ReadInt(); + IsRewardItem = reader.ReadBool(); + break; + } } if (Parent is Mobile mobile) diff --git a/Projects/Scripts/Items/Clothing/Hats.cs b/Projects/Scripts/Items/Clothing/Hats.cs index d8a3a5113..1029a4c9b 100644 --- a/Projects/Scripts/Items/Clothing/Hats.cs +++ b/Projects/Scripts/Items/Clothing/Hats.cs @@ -17,7 +17,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool IsShipwreckedItem{ get; set; } + public bool IsShipwreckedItem { get; set; } public override void Serialize(IGenericWriter writer) { @@ -37,10 +37,10 @@ namespace Server.Items switch (version) { case 1: - { - IsShipwreckedItem = reader.ReadBool(); - break; - } + { + IsShipwreckedItem = reader.ReadBool(); + break; + } } } @@ -67,7 +67,7 @@ namespace Server.Items if (Quality == ClothingQuality.Exceptional) DistributeBonuses(tool is BaseRunicTool ? 6 : - Core.SE ? 15 : 14); //BLAME OSI. (We can't confirm it's an OSI bug yet.) + Core.SE ? 15 : 14); // BLAME OSI. (We can't confirm it's an OSI bug yet.) return base.OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, craftItem, resHue); } @@ -623,7 +623,7 @@ namespace Server.Items int version = reader.ReadInt(); - /*if ( Hue != 0x8A4 ) + /*if (Hue != 0x8A4) Hue = 0x8A4;*/ } } @@ -631,7 +631,7 @@ namespace Server.Items public class SavageMask : BaseHat { [Constructible] - public SavageMask() : this(GetRandomHue()) {} + public SavageMask() : this(GetRandomHue()) { } [Constructible] public SavageMask(int hue) : base(0x154B, hue) => Weight = 2.0; @@ -678,7 +678,7 @@ namespace Server.Items int version = reader.ReadInt(); - /*if ( Hue != 0 && (Hue < 2101 || Hue > 2130) ) + /*if (Hue != 0 && (Hue < 2101 || Hue > 2130)) Hue = GetRandomHue();*/ } } diff --git a/Projects/Scripts/Items/Clothing/OuterTorso.cs b/Projects/Scripts/Items/Clothing/OuterTorso.cs index 5f23a9084..6a08f7d86 100644 --- a/Projects/Scripts/Items/Clothing/OuterTorso.cs +++ b/Projects/Scripts/Items/Clothing/OuterTorso.cs @@ -80,7 +80,7 @@ namespace Server.Items public class DeathRobe : Robe { - private static TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(1.0); + private static readonly TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(1.0); private DateTime m_DecayTime; private Timer m_DecayTimer; @@ -165,22 +165,22 @@ namespace Server.Items switch (version) { case 2: - { - if (reader.ReadBool()) { - m_DecayTime = reader.ReadDeltaTime(); - BeginDecay(m_DecayTime - DateTime.UtcNow); - } + if (reader.ReadBool()) + { + m_DecayTime = reader.ReadDeltaTime(); + BeginDecay(m_DecayTime - DateTime.UtcNow); + } - break; - } + break; + } case 1: case 0: - { - if (Parent == null) - BeginDecay(m_DefaultDecayTime); - break; - } + { + if (Parent == null) + BeginDecay(m_DefaultDecayTime); + break; + } } if (version < 1 && Hue == 0) @@ -189,7 +189,7 @@ namespace Server.Items private class InternalTimer : Timer { - private DeathRobe m_Robe; + private readonly DeathRobe m_Robe; public InternalTimer(DeathRobe c, TimeSpan delay) : base(delay) { @@ -250,7 +250,7 @@ namespace Server.Items public override int BasePhysicalResistance => 3; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnAdded(IEntity parent) { @@ -310,11 +310,11 @@ namespace Server.Items switch (version) { case 0: - { - m_LabelNumber = reader.ReadInt(); - IsRewardItem = reader.ReadBool(); - break; - } + { + m_LabelNumber = reader.ReadInt(); + IsRewardItem = reader.ReadBool(); + break; + } } if (Parent is Mobile mobile) @@ -365,7 +365,7 @@ namespace Server.Items public override int BasePhysicalResistance => 3; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnAdded(IEntity parent) { @@ -425,11 +425,11 @@ namespace Server.Items switch (version) { case 0: - { - m_LabelNumber = reader.ReadInt(); - IsRewardItem = reader.ReadBool(); - break; - } + { + m_LabelNumber = reader.ReadInt(); + IsRewardItem = reader.ReadBool(); + break; + } } if (Parent is Mobile mobile) @@ -474,23 +474,21 @@ namespace Server.Items switch (version) { case 1: - { - if (reader.ReadBool()) { - m_CurArcaneCharges = reader.ReadInt(); - m_MaxArcaneCharges = reader.ReadInt(); + if (reader.ReadBool()) + { + m_CurArcaneCharges = reader.ReadInt(); + m_MaxArcaneCharges = reader.ReadInt(); - if (Hue == 2118) - Hue = ArcaneGem.DefaultArcaneHue; + if (Hue == 2118) + Hue = ArcaneGem.DefaultArcaneHue; + } + + break; } - - break; - } } } - #region Arcane Impl - private int m_MaxArcaneCharges, m_CurArcaneCharges; [CommandProperty(AccessLevel.GameMaster)] @@ -554,8 +552,6 @@ namespace Server.Items else if (ItemID == 0x1F04) ItemID = 0x1F03; } - - #endregion } public class MonkRobe : BaseOuterTorso diff --git a/Projects/Scripts/Items/Clothing/Shoes.cs b/Projects/Scripts/Items/Clothing/Shoes.cs index a49d69cb1..28754a817 100644 --- a/Projects/Scripts/Items/Clothing/Shoes.cs +++ b/Projects/Scripts/Items/Clothing/Shoes.cs @@ -36,15 +36,15 @@ namespace Server.Items { case 2: break; // empty, resource removed case 1: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } case 0: - { - m_Resource = DefaultResource; - break; - } + { + m_Resource = DefaultResource; + break; + } } } } @@ -140,23 +140,21 @@ namespace Server.Items switch (version) { case 1: - { - if (reader.ReadBool()) { - m_CurArcaneCharges = reader.ReadInt(); - m_MaxArcaneCharges = reader.ReadInt(); + if (reader.ReadBool()) + { + m_CurArcaneCharges = reader.ReadInt(); + m_MaxArcaneCharges = reader.ReadInt(); - if (Hue == 2118) - Hue = ArcaneGem.DefaultArcaneHue; + if (Hue == 2118) + Hue = ArcaneGem.DefaultArcaneHue; + } + + break; } - - break; - } } } - #region Arcane Impl - private int m_MaxArcaneCharges, m_CurArcaneCharges; [CommandProperty(AccessLevel.GameMaster)] @@ -220,8 +218,6 @@ namespace Server.Items else if (ItemID == 0x1712) ItemID = 0x1711; } - - #endregion } [Flippable(0x170f, 0x1710)] diff --git a/Projects/Scripts/Items/Construction/Ankhs.cs b/Projects/Scripts/Items/Construction/Ankhs.cs index 3bc627548..2a31bc35a 100644 --- a/Projects/Scripts/Items/Construction/Ankhs.cs +++ b/Projects/Scripts/Items/Construction/Ankhs.cs @@ -44,8 +44,8 @@ namespace Server.Items private class ResurrectEntry : ContextMenuEntry { - private Item m_Item; - private Mobile m_Mobile; + private readonly Item m_Item; + private readonly Mobile m_Mobile; public ResurrectEntry(Mobile mobile, Item item) : base(6195, ResurrectRange) { @@ -63,7 +63,7 @@ namespace Server.Items private class LockKarmaEntry : ContextMenuEntry { - private PlayerMobile m_Mobile; + private readonly PlayerMobile m_Mobile; public LockKarmaEntry(PlayerMobile mobile) : base(mobile.KarmaLocked ? 6197 : 6196, LockRange) => m_Mobile = mobile; @@ -81,7 +81,7 @@ namespace Server.Items private class TitheEntry : ContextMenuEntry { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public TitheEntry(Mobile mobile) : base(6198, TitheRange) { diff --git a/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs b/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs index 9d224bb53..505810a4c 100644 --- a/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs +++ b/Projects/Scripts/Items/Construction/Doors/BaseDoor.cs @@ -7,7 +7,7 @@ namespace Server.Items { public abstract class BaseDoor : Item, ILockable, ITelekinesisable { - private static Point3D[] m_Offsets = + private static readonly Point3D[] m_Offsets = { new Point3D(-1, 1, 0), new Point3D(1, 1, 0), @@ -74,19 +74,19 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int OpenedID{ get; set; } + public int OpenedID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ClosedID{ get; set; } + public int ClosedID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int OpenedSound{ get; set; } + public int OpenedSound { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ClosedSound{ get; set; } + public int ClosedSound { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Offset{ get; set; } + public Point3D Offset { get; set; } [CommandProperty(AccessLevel.GameMaster)] public BaseDoor Link @@ -104,10 +104,10 @@ namespace Server.Items public virtual bool UseChainedFunctionality => false; [CommandProperty(AccessLevel.GameMaster)] - public bool Locked{ get; set; } + public bool Locked { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public uint KeyValue{ get; set; } + public uint KeyValue { get; set; } public void OnTelekinesis(Mobile from) { @@ -376,7 +376,7 @@ namespace Server.Items { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502502); // That is locked, but you open it with your godly powers. - //from.Send( new MessageLocalized( Serial, ItemID, MessageType.Regular, 0x3B2, 3, 502502, "", "" ) ); // That is locked, but you open it with your godly powers. + // from.Send( new MessageLocalized( Serial, ItemID, MessageType.Regular, 0x3B2, 3, 502502, "", "" ) ); // That is locked, but you open it with your godly powers. } else if (Key.ContainsKey(from.Backpack, KeyValue)) { @@ -470,30 +470,30 @@ namespace Server.Items switch (version) { case 0: - { - KeyValue = reader.ReadUInt(); - m_Open = reader.ReadBool(); - Locked = reader.ReadBool(); - OpenedID = reader.ReadInt(); - ClosedID = reader.ReadInt(); - OpenedSound = reader.ReadInt(); - ClosedSound = reader.ReadInt(); - Offset = reader.ReadPoint3D(); - m_Link = reader.ReadItem() as BaseDoor; + { + KeyValue = reader.ReadUInt(); + m_Open = reader.ReadBool(); + Locked = reader.ReadBool(); + OpenedID = reader.ReadInt(); + ClosedID = reader.ReadInt(); + OpenedSound = reader.ReadInt(); + ClosedSound = reader.ReadInt(); + Offset = reader.ReadPoint3D(); + m_Link = reader.ReadItem() as BaseDoor; - m_Timer = new InternalTimer(this); + m_Timer = new InternalTimer(this); - if (m_Open) - m_Timer.Start(); + if (m_Open) + m_Timer.Start(); - break; - } + break; + } } } private class InternalTimer : Timer { - private BaseDoor m_Door; + private readonly BaseDoor m_Door; public InternalTimer(BaseDoor door) : base(TimeSpan.FromSeconds(20.0), TimeSpan.FromSeconds(10.0)) { diff --git a/Projects/Scripts/Items/Construction/Doors/Doors.cs b/Projects/Scripts/Items/Construction/Doors/Doors.cs index 61ae175c0..3e4f9434c 100644 --- a/Projects/Scripts/Items/Construction/Doors/Doors.cs +++ b/Projects/Scripts/Items/Construction/Doors/Doors.cs @@ -11,7 +11,7 @@ namespace Server.Items SouthCCW, NorthCW, - //Sliding Doors + // Sliding Doors SouthSW, SouthSE, WestSS, diff --git a/Projects/Scripts/Items/Construction/Doors/HouseDoors.cs b/Projects/Scripts/Items/Construction/Doors/HouseDoors.cs index e19d142d9..6fbebdf4c 100644 --- a/Projects/Scripts/Items/Construction/Doors/HouseDoors.cs +++ b/Projects/Scripts/Items/Construction/Doors/HouseDoors.cs @@ -102,10 +102,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public DoorFacing Facing{ get; set; } + public DoorFacing Facing { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override void GetContextMenuEntries(Mobile from, List list) { @@ -182,18 +182,18 @@ namespace Server.Items switch (version) { case 1: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 0; + } case 0: - { - if (version < 1) - Level = SecureLevel.Anyone; + { + if (version < 1) + Level = SecureLevel.Anyone; - Facing = (DoorFacing)reader.ReadInt(); - break; - } + Facing = (DoorFacing)reader.ReadInt(); + break; + } } } @@ -239,7 +239,7 @@ namespace Server.Items h = bs; break; - //No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until further information gained + // No way to test the 'insideness' of SE Sliding doors on OSI, so leaving them default to false until further information gained default: return false; } diff --git a/Projects/Scripts/Items/Construction/Signs/LocalizedSign.cs b/Projects/Scripts/Items/Construction/Signs/LocalizedSign.cs index bd22bfa9a..a81a468a7 100644 --- a/Projects/Scripts/Items/Construction/Signs/LocalizedSign.cs +++ b/Projects/Scripts/Items/Construction/Signs/LocalizedSign.cs @@ -45,10 +45,10 @@ namespace Server.Items switch (version) { case 0: - { - m_LabelNumber = reader.ReadInt(); - break; - } + { + m_LabelNumber = reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Containers/BaseTreasureChest.cs b/Projects/Scripts/Items/Containers/BaseTreasureChest.cs index 5956d4809..449347b2b 100644 --- a/Projects/Scripts/Items/Containers/BaseTreasureChest.cs +++ b/Projects/Scripts/Items/Containers/BaseTreasureChest.cs @@ -32,13 +32,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public TreasureLevel Level{ get; set; } + public TreasureLevel Level { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public short MaxSpawnTime{ get; set; } = 60; + public short MaxSpawnTime { get; set; } = 60; [CommandProperty(AccessLevel.GameMaster)] - public short MinSpawnTime{ get; set; } = 10; + public short MinSpawnTime { get; set; } = 10; [CommandProperty(AccessLevel.GameMaster)] public override bool Locked @@ -97,12 +97,12 @@ namespace Server.Items { RequiredSkill = Level switch { - TreasureLevel.Level1 => (LockLevel = 5), - TreasureLevel.Level2 => (LockLevel = 20), - TreasureLevel.Level3 => (LockLevel = 50), - TreasureLevel.Level4 => (LockLevel = 70), - TreasureLevel.Level5 => (LockLevel = 90), - TreasureLevel.Level6 => (LockLevel = 100), + TreasureLevel.Level1 => LockLevel = 5, + TreasureLevel.Level2 => LockLevel = 20, + TreasureLevel.Level3 => LockLevel = 50, + TreasureLevel.Level4 => LockLevel = 70, + TreasureLevel.Level5 => LockLevel = 90, + TreasureLevel.Level6 => LockLevel = 100, _ => RequiredSkill }; } @@ -178,7 +178,7 @@ namespace Server.Items private class TreasureResetTimer : Timer { - private BaseTreasureChest m_Chest; + private readonly BaseTreasureChest m_Chest; public TreasureResetTimer(BaseTreasureChest chest) : base( TimeSpan.FromMinutes(Utility.Random(chest.MinSpawnTime, chest.MaxSpawnTime))) diff --git a/Projects/Scripts/Items/Containers/Container.cs b/Projects/Scripts/Items/Containers/Container.cs index 314a7610d..35ebbeade 100644 --- a/Projects/Scripts/Items/Containers/Container.cs +++ b/Projects/Scripts/Items/Containers/Container.cs @@ -66,8 +66,8 @@ namespace Server.Items if (house?.HasLockedDownItem(this) == true) { - if (dropped is VendorRentalContract || dropped is Container container && - container.FindItemByType() != null) + if (dropped is VendorRentalContract || (dropped is Container container && + container.FindItemByType() != null)) { from.SendLocalizedMessage(1062492); // You cannot place a rental contract in a locked down container. return false; @@ -101,8 +101,8 @@ namespace Server.Items if (house?.HasLockedDownItem(this) == true) { - if (item is VendorRentalContract || item is Container container && - container.FindItemByType() != null) + if (item is VendorRentalContract || (item is Container container && + container.FindItemByType() != null)) { from.SendLocalizedMessage(1062492); // You cannot place a rental contract in a locked down container. return false; @@ -153,7 +153,7 @@ namespace Server.Items } } - public class CreatureBackpack : Backpack //Used on BaseCreature + public class CreatureBackpack : Backpack // Used on BaseCreature { [Constructible] public CreatureBackpack(string name) @@ -215,7 +215,7 @@ namespace Server.Items } } - public class StrongBackpack : Backpack //Used on Pack animals + public class StrongBackpack : Backpack // Used on Pack animals { [Constructible] public StrongBackpack() @@ -233,7 +233,7 @@ namespace Server.Items public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) => base.CheckHold(m, item, false, checkItems, plusItems, plusWeight); public override bool CheckContentDisplay(Mobile from) => - RootParent is BaseCreature creature && creature.Controlled && creature.ControlMaster == from || + (RootParent is BaseCreature creature && creature.Controlled && creature.ControlMaster == from) || base.CheckContentDisplay(from); public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Items/Containers/FillableContainers.cs b/Projects/Scripts/Items/Containers/FillableContainers.cs index fb0410071..a61b6c46e 100644 --- a/Projects/Scripts/Items/Containers/FillableContainers.cs +++ b/Projects/Scripts/Items/Containers/FillableContainers.cs @@ -151,7 +151,7 @@ namespace Server.Items RequiredSkill = difficulty; } - if (IsTrappable && (m_Content.Level > 1 || 4 > Utility.Random(5))) + if (IsTrappable && (m_Content.Level > 1 || Utility.Random(5) < 4)) { if (m_Content.Level > Utility.Random(5)) TrapType = TrapType.PoisonTrap; @@ -240,26 +240,26 @@ namespace Server.Items switch (version) { case 1: - { - m_Content = FillableContent.Lookup((FillableContentType)reader.ReadInt()); - goto case 0; - } + { + m_Content = FillableContent.Lookup((FillableContentType)reader.ReadInt()); + goto case 0; + } case 0: - { - if (reader.ReadBool()) { - m_NextRespawnTime = reader.ReadDeltaTime(); + if (reader.ReadBool()) + { + m_NextRespawnTime = reader.ReadDeltaTime(); - TimeSpan delay = m_NextRespawnTime - DateTime.UtcNow; - m_RespawnTimer = Timer.DelayCall(delay > TimeSpan.Zero ? delay : TimeSpan.Zero, Respawn); - } - else - { - CheckRespawn(); - } + TimeSpan delay = m_NextRespawnTime - DateTime.UtcNow; + m_RespawnTimer = Timer.DelayCall(delay > TimeSpan.Zero ? delay : TimeSpan.Zero, Respawn); + } + else + { + CheckRespawn(); + } - break; - } + break; + } } } } @@ -621,7 +621,7 @@ namespace Server.Items : base(weight, type) => Content = content; - public BeverageType Content{ get; } + public BeverageType Content { get; } public override Item Construct() { @@ -802,7 +802,7 @@ namespace Server.Items new FillableEntry(8, typeof(SmithHammer)), new FillableEntry(8, typeof(Tongs)), new FillableEntry(8, typeof(SledgeHammer)), - //new FillableEntry( 8, typeof( IronOre ) ), TODO: Smaller ore + // new FillableEntry( 8, typeof( IronOre ) ), TODO: Smaller ore new FillableEntry(8, typeof(IronIngot)), new FillableEntry(1, typeof(IronWire)), new FillableEntry(1, typeof(SilverWire)), @@ -893,10 +893,10 @@ namespace Server.Items new FillableEntry(1, typeof(LightYarnUnraveled)), new FillableEntry(1, typeof(SpoolOfThread)), // Four different types - //new FillableEntry( 1, typeof( FoldedCloth ) ), - //new FillableEntry( 1, typeof( FoldedCloth ) ), - //new FillableEntry( 1, typeof( FoldedCloth ) ), - //new FillableEntry( 1, typeof( FoldedCloth ) ), + // new FillableEntry( 1, typeof( FoldedCloth ) ), + // new FillableEntry( 1, typeof( FoldedCloth ) ), + // new FillableEntry( 1, typeof( FoldedCloth ) ), + // new FillableEntry( 1, typeof( FoldedCloth ) ), new FillableEntry(1, typeof(Dyes)), new FillableEntry(2, typeof(Leather)) }); @@ -926,8 +926,8 @@ namespace Server.Items { new FillableEntry(1, typeof(FishingPole)), // Two different types - //new FillableEntry( 1, typeof( SmallFish ) ), - //new FillableEntry( 1, typeof( SmallFish ) ), + // new FillableEntry( 1, typeof( SmallFish ) ), + // new FillableEntry( 1, typeof( SmallFish ) ), new FillableEntry(4, typeof(Fish)) }); @@ -1163,7 +1163,7 @@ namespace Server.Items new FillableEntry(2, typeof(Pickaxe)), new FillableEntry(2, typeof(Shovel)), new FillableEntry(2, typeof(IronIngot)), - //new FillableEntry( 2, typeof( IronOre ) ), TODO: Smaller Ore + // new FillableEntry( 2, typeof( IronOre ) ), TODO: Smaller Ore new FillableEntry(1, typeof(ForgedMetal)) }); @@ -1302,7 +1302,7 @@ namespace Server.Items }, new[] { - //new FillableEntry( 1, typeof( Wheat ) ), + // new FillableEntry( 1, typeof( Wheat ) ), new FillableEntry(1, typeof(Carrot)) }); @@ -1369,13 +1369,13 @@ namespace Server.Items new[] { new FillableEntry(1, typeof(Lockpick)), - //new FillableEntry( 1, typeof( KeyRing ) ), + // new FillableEntry( 1, typeof( KeyRing ) ), new FillableEntry(2, typeof(Clock)), new FillableEntry(2, typeof(ClockParts)), new FillableEntry(2, typeof(AxleGears)), new FillableEntry(2, typeof(Gears)), new FillableEntry(2, typeof(Hinge)), - //new FillableEntry( 1, typeof( ArrowShafts ) ), + // new FillableEntry( 1, typeof( ArrowShafts ) ), new FillableEntry(2, typeof(Sextant)), new FillableEntry(2, typeof(SextantParts)), new FillableEntry(2, typeof(Axle)), @@ -1398,7 +1398,7 @@ namespace Server.Items new FillableEntry(1, typeof(Bandage)), new FillableEntry(1, typeof(MortarPestle)), new FillableEntry(1, typeof(LesserHealPotion)), - //new FillableEntry( 1, typeof( Wheat ) ), + // new FillableEntry( 1, typeof( Wheat ) ), new FillableEntry(1, typeof(Carrot)) }); @@ -1416,7 +1416,7 @@ namespace Server.Items private static Dictionary m_AcquireTable; - private static FillableContent[] m_ContentTypes = + private static readonly FillableContent[] m_ContentTypes = { Weaponsmith, Provisioner, Mage, Alchemist, Armorer, ArtisanGuild, @@ -1432,8 +1432,8 @@ namespace Server.Items Tinker, Veterinarian }; - private FillableEntry[] m_Entries; - private int m_Weight; + private readonly FillableEntry[] m_Entries; + private readonly int m_Weight; public FillableContent(int level, Type[] vendors, FillableEntry[] entries) { @@ -1445,9 +1445,9 @@ namespace Server.Items m_Weight += entries[i].Weight; } - public int Level{ get; } + public int Level { get; } - public Type[] Vendors{ get; } + public Type[] Vendors { get; } public FillableContentType TypeID => Lookup(this); diff --git a/Projects/Scripts/Items/Containers/FurnitureContainer.cs b/Projects/Scripts/Items/Containers/FurnitureContainer.cs index b272f538c..c319d118d 100644 --- a/Projects/Scripts/Items/Containers/FurnitureContainer.cs +++ b/Projects/Scripts/Items/Containers/FurnitureContainer.cs @@ -51,7 +51,6 @@ namespace Server.Items } } - [Furniture] [Flippable(0x2857, 0x2858)] public class RedArmoire : BaseContainer @@ -316,7 +315,7 @@ namespace Server.Items public class DynamicFurniture { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public static bool Open(Container c, Mobile m) { @@ -370,8 +369,8 @@ namespace Server.Items public class FurnitureTimer : Timer { - private Container m_Container; - private Mobile m_Mobile; + private readonly Container m_Container; + private readonly Mobile m_Mobile; public FurnitureTimer(Container c, Mobile m) : base(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5)) { diff --git a/Projects/Scripts/Items/Containers/LockableContainer.cs b/Projects/Scripts/Items/Containers/LockableContainer.cs index 1e90c5ef7..20b70dec1 100644 --- a/Projects/Scripts/Items/Containers/LockableContainer.cs +++ b/Projects/Scripts/Items/Containers/LockableContainer.cs @@ -17,12 +17,10 @@ namespace Server.Items public override bool TrapOnOpen => !TrapOnLockpick; [CommandProperty(AccessLevel.GameMaster)] - public bool TrapOnLockpick{ get; set; } + public bool TrapOnLockpick { get; set; } public override bool DisplaysContent => !m_Locked; - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -61,8 +59,6 @@ namespace Server.Items return 1; } - #endregion - [CommandProperty(AccessLevel.GameMaster)] public virtual bool Locked { @@ -79,19 +75,19 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public uint KeyValue{ get; set; } + public uint KeyValue { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Picker{ get; set; } + public Mobile Picker { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int MaxLockLevel{ get; set; } + public int MaxLockLevel { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int LockLevel{ get; set; } + public int LockLevel { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int RequiredSkill{ get; set; } + public int RequiredSkill { get; set; } public virtual void LockPick(Mobile from) { @@ -101,12 +97,8 @@ namespace Server.Items if (TrapOnLockpick && ExecuteTrap(from)) TrapOnLockpick = false; } - #region IShipwreckedItem Members - [CommandProperty(AccessLevel.GameMaster)] - public bool IsShipwreckedItem{ get; set; } - - #endregion + public bool IsShipwreckedItem { get; set; } public override void Serialize(IGenericWriter writer) { @@ -136,64 +128,64 @@ namespace Server.Items switch (version) { case 6: - { - IsShipwreckedItem = reader.ReadBool(); - - goto case 5; - } - case 5: - { - TrapOnLockpick = reader.ReadBool(); - - goto case 4; - } - case 4: - { - RequiredSkill = reader.ReadInt(); - - goto case 3; - } - case 3: - { - MaxLockLevel = reader.ReadInt(); - - goto case 2; - } - case 2: - { - KeyValue = reader.ReadUInt(); - - goto case 1; - } - case 1: - { - LockLevel = reader.ReadInt(); - - goto case 0; - } - case 0: - { - if (version < 3) - MaxLockLevel = 100; - - if (version < 4) { - if (MaxLockLevel - LockLevel == 40) - { - RequiredSkill = LockLevel + 6; - LockLevel = RequiredSkill - 10; - MaxLockLevel = RequiredSkill + 39; - } - else - { - RequiredSkill = LockLevel; - } + IsShipwreckedItem = reader.ReadBool(); + + goto case 5; } + case 5: + { + TrapOnLockpick = reader.ReadBool(); - m_Locked = reader.ReadBool(); + goto case 4; + } + case 4: + { + RequiredSkill = reader.ReadInt(); - break; - } + goto case 3; + } + case 3: + { + MaxLockLevel = reader.ReadInt(); + + goto case 2; + } + case 2: + { + KeyValue = reader.ReadUInt(); + + goto case 1; + } + case 1: + { + LockLevel = reader.ReadInt(); + + goto case 0; + } + case 0: + { + if (version < 3) + MaxLockLevel = 100; + + if (version < 4) + { + if (MaxLockLevel - LockLevel == 40) + { + RequiredSkill = LockLevel + 6; + LockLevel = RequiredSkill - 10; + MaxLockLevel = RequiredSkill + 39; + } + else + { + RequiredSkill = LockLevel; + } + } + + m_Locked = reader.ReadBool(); + + break; + } } } @@ -320,7 +312,7 @@ namespace Server.Items base.OnSingleClick(from); if (IsShipwreckedItem) - LabelTo(from, 1041645); //recovered from a shipwreck + LabelTo(from, 1041645); // recovered from a shipwreck } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Containers/MarkContainer.cs b/Projects/Scripts/Items/Containers/MarkContainer.cs index 072dd3adb..d4dd66cf1 100644 --- a/Projects/Scripts/Items/Containers/MarkContainer.cs +++ b/Projects/Scripts/Items/Containers/MarkContainer.cs @@ -43,10 +43,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Map TargetMap{ get; set; } + public Map TargetMap { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Target{ get; set; } + public Point3D Target { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Bone @@ -60,7 +60,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string Description{ get; set; } + public string Description { get; set; } public override bool IsDecoContainer => false; @@ -217,9 +217,9 @@ namespace Server.Items Start(); } - public MarkContainer Container{ get; } + public MarkContainer Container { get; } - public DateTime RelockTime{ get; } + public DateTime RelockTime { get; } protected override void OnTick() { diff --git a/Projects/Scripts/Items/Containers/ParagonChest.cs b/Projects/Scripts/Items/Containers/ParagonChest.cs index c423df466..aa02fa032 100644 --- a/Projects/Scripts/Items/Containers/ParagonChest.cs +++ b/Projects/Scripts/Items/Containers/ParagonChest.cs @@ -3,12 +3,12 @@ namespace Server.Items [Flippable] public class ParagonChest : LockableContainer { - private static int[] m_ItemIDs = + private static readonly int[] m_ItemIDs = { 0x9AB, 0xE40, 0xE41, 0xE7C }; - private static int[] m_Hues = + private static readonly int[] m_Hues = { 0x0, 0x455, 0x47E, 0x89F, 0x8A5, 0x8AB, 0x966, 0x96D, 0x972, 0x973, 0x979 diff --git a/Projects/Scripts/Items/Containers/SalvageBag.cs b/Projects/Scripts/Items/Containers/SalvageBag.cs index 41c0a0453..662552a08 100644 --- a/Projects/Scripts/Items/Containers/SalvageBag.cs +++ b/Projects/Scripts/Items/Containers/SalvageBag.cs @@ -40,8 +40,6 @@ namespace Server.Items } } - #region Resmelt.cs - private bool Resmelt(Mobile from, Item item, CraftResource resource) { try @@ -80,9 +78,9 @@ namespace Server.Items Type resourceType = info.ResourceTypes[0]; Item ingot = (Item)ActivatorUtil.CreateInstance(resourceType); - if (item is DragonBardingDeed || item is BaseArmor armor && armor.PlayerConstructed || - item is BaseWeapon weapon && weapon.PlayerConstructed || - item is BaseClothing clothing && clothing.PlayerConstructed) + if (item is DragonBardingDeed || (item is BaseArmor armor && armor.PlayerConstructed) || + (item is BaseWeapon weapon && weapon.PlayerConstructed) || + (item is BaseClothing clothing && clothing.PlayerConstructed)) { double mining = from.Skills.Mining.Value; if (mining > 100.0) @@ -123,22 +121,18 @@ namespace Server.Items return false; } - #endregion - - #region Checks - - private bool Resmeltables() //Where context menu checks for metal items and dragon barding deeds + private bool Resmeltables() // Where context menu checks for metal items and dragon barding deeds { foreach (Item i in Items) return i?.Deleted == false && ( - i is BaseWeapon weapon && CraftResources.GetType(weapon.Resource) == CraftResourceType.Metal || - i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Metal || + (i is BaseWeapon weapon && CraftResources.GetType(weapon.Resource) == CraftResourceType.Metal) || + (i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Metal) || i is DragonBardingDeed); return false; } - private bool Scissorables() //Where context menu checks for Leather items and cloth items + private bool Scissorables() // Where context menu checks for Leather items and cloth items { foreach (Item i in Items) { @@ -146,17 +140,13 @@ namespace Server.Items 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) + (i is BaseArmor armor && CraftResources.GetType(armor.Resource) == CraftResourceType.Leather)) return true; } return false; } - #endregion - - #region Salvaging - private void SalvageIngots(Mobile from) { if (from.Backpack.FindItemsByType().All(tool => tool.CraftSystem != DefBlacksmithy.CraftSystem)) @@ -185,8 +175,8 @@ namespace Server.Items if (item?.Deleted != false) continue; - if (item is BaseArmor armor && Resmelt(from, armor, armor.Resource) || - item is BaseWeapon weapon && Resmelt(from, weapon, weapon.Resource) || + if ((item is BaseArmor armor && Resmelt(from, armor, armor.Resource)) || + (item is BaseWeapon weapon && Resmelt(from, weapon, weapon.Resource)) || item is DragonBardingDeed) salvaged++; else @@ -253,13 +243,9 @@ namespace Server.Items SalvageCloth(from); } - #endregion - - #region ContextMenuEntries - private class SalvageAllEntry : ContextMenuEntry { - private SalvageBag m_Bag; + private readonly SalvageBag m_Bag; public SalvageAllEntry(SalvageBag bag, bool enabled) : base(6276) @@ -284,7 +270,7 @@ namespace Server.Items private class SalvageIngotsEntry : ContextMenuEntry { - private SalvageBag m_Bag; + private readonly SalvageBag m_Bag; public SalvageIngotsEntry(SalvageBag bag, bool enabled) : base(6277) @@ -309,7 +295,7 @@ namespace Server.Items private class SalvageClothEntry : ContextMenuEntry { - private SalvageBag m_Bag; + private readonly SalvageBag m_Bag; public SalvageClothEntry(SalvageBag bag, bool enabled) : base(6278) @@ -332,10 +318,6 @@ namespace Server.Items } } - #endregion - - #region Serialization - public SalvageBag(Serial serial) : base(serial) { @@ -354,7 +336,5 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } - - #endregion } } diff --git a/Projects/Scripts/Items/Containers/Strongbox.cs b/Projects/Scripts/Items/Containers/Strongbox.cs index 8248de48f..bb21cf6c0 100644 --- a/Projects/Scripts/Items/Containers/Strongbox.cs +++ b/Projects/Scripts/Items/Containers/Strongbox.cs @@ -5,7 +5,7 @@ using Server.Multis; namespace Server.Items { [Flippable(0xE80, 0x9A8)] - public class StrongBox : BaseContainer, IChopable + public class StrongBox : BaseContainer, IChoppable { private BaseHouse m_House; private Mobile m_Owner; @@ -38,7 +38,7 @@ namespace Server.Items public override int DefaultMaxWeight => 0; - public override bool Decays => m_House == null || m_Owner?.Deleted != false || !m_House.IsCoOwner(m_Owner); + public override bool Decays => m_House == null || m_Owner?.Deleted != false || !m_House.IsCoOwner(m_Owner); public override TimeSpan DecayTime => TimeSpan.FromMinutes(30.0); @@ -67,12 +67,12 @@ namespace Server.Items switch (version) { case 0: - { - m_Owner = reader.ReadMobile(); - m_House = reader.ReadItem() as BaseHouse; + { + m_Owner = reader.ReadMobile(); + m_House = reader.ReadItem() as BaseHouse; - break; - } + break; + } } Timer.DelayCall(TimeSpan.FromSeconds(1.0), Validate); @@ -113,7 +113,7 @@ namespace Server.Items public override bool IsAccessibleTo(Mobile m) => m_Owner?.Deleted != false || m_House?.Deleted != false || m.AccessLevel >= AccessLevel.GameMaster || - m == m_Owner && m_House.IsCoOwner(m) && base.IsAccessibleTo(m); + (m == m_Owner && m_House.IsCoOwner(m) && base.IsAccessibleTo(m)); private void Chop(Mobile from) { diff --git a/Projects/Scripts/Items/Containers/TrappableContainer.cs b/Projects/Scripts/Items/Containers/TrappableContainer.cs index def0e81ab..c1499cdd7 100644 --- a/Projects/Scripts/Items/Containers/TrappableContainer.cs +++ b/Projects/Scripts/Items/Containers/TrappableContainer.cs @@ -23,13 +23,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public TrapType TrapType{ get; set; } + public TrapType TrapType { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int TrapPower{ get; set; } + public int TrapPower { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int TrapLevel{ get; set; } + public int TrapLevel { get; set; } public virtual bool TrapOnOpen => true; @@ -73,99 +73,99 @@ namespace Server.Items switch (TrapType) { case TrapType.ExplosionTrap: - { - SendMessageTo(from, 502999, 0x3B2); // You set off a trap! - - if (from.InRange(loc, 3)) { - int damage; + SendMessageTo(from, 502999, 0x3B2); // You set off a trap! - if (TrapLevel > 0) - damage = Utility.RandomMinMax(10, 30) * TrapLevel; - else - damage = TrapPower; + if (from.InRange(loc, 3)) + { + int damage; - AOS.Damage(from, damage, 0, 100, 0, 0, 0); + if (TrapLevel > 0) + damage = Utility.RandomMinMax(10, 30) * TrapLevel; + else + damage = TrapPower; - // Your skin blisters from the heat! - from.LocalOverheadMessage(MessageType.Regular, 0x2A, 503000); + AOS.Damage(from, damage, 0, 100, 0, 0, 0); + + // Your skin blisters from the heat! + from.LocalOverheadMessage(MessageType.Regular, 0x2A, 503000); + } + + Effects.SendLocationEffect(loc, facet, 0x36BD, 15, 10); + Effects.PlaySound(loc, facet, 0x307); + + break; } - - Effects.SendLocationEffect(loc, facet, 0x36BD, 15, 10); - Effects.PlaySound(loc, facet, 0x307); - - break; - } case TrapType.MagicTrap: - { - if (from.InRange(loc, 1)) - from.Damage(TrapPower); - //AOS.Damage( from, m_TrapPower, 0, 100, 0, 0, 0 ); + { + if (from.InRange(loc, 1)) + from.Damage(TrapPower); + // AOS.Damage( from, m_TrapPower, 0, 100, 0, 0, 0 ); - Effects.PlaySound(loc, Map, 0x307); + Effects.PlaySound(loc, Map, 0x307); - Effects.SendLocationEffect(new Point3D(loc.X - 1, loc.Y, loc.Z), Map, 0x36BD, 15); - Effects.SendLocationEffect(new Point3D(loc.X + 1, loc.Y, loc.Z), Map, 0x36BD, 15); + Effects.SendLocationEffect(new Point3D(loc.X - 1, loc.Y, loc.Z), Map, 0x36BD, 15); + Effects.SendLocationEffect(new Point3D(loc.X + 1, loc.Y, loc.Z), Map, 0x36BD, 15); - Effects.SendLocationEffect(new Point3D(loc.X, loc.Y - 1, loc.Z), Map, 0x36BD, 15); - Effects.SendLocationEffect(new Point3D(loc.X, loc.Y + 1, loc.Z), Map, 0x36BD, 15); + Effects.SendLocationEffect(new Point3D(loc.X, loc.Y - 1, loc.Z), Map, 0x36BD, 15); + Effects.SendLocationEffect(new Point3D(loc.X, loc.Y + 1, loc.Z), Map, 0x36BD, 15); - Effects.SendLocationEffect(new Point3D(loc.X + 1, loc.Y + 1, loc.Z + 11), Map, 0x36BD, 15); + Effects.SendLocationEffect(new Point3D(loc.X + 1, loc.Y + 1, loc.Z + 11), Map, 0x36BD, 15); - break; - } + break; + } case TrapType.DartTrap: - { - SendMessageTo(from, 502999, 0x3B2); // You set off a trap! - - if (from.InRange(loc, 3)) { - int damage; + SendMessageTo(from, 502999, 0x3B2); // You set off a trap! - if (TrapLevel > 0) - damage = Utility.RandomMinMax(5, 15) * TrapLevel; - else - damage = TrapPower; + if (from.InRange(loc, 3)) + { + int damage; - AOS.Damage(from, damage, 100, 0, 0, 0, 0); + if (TrapLevel > 0) + damage = Utility.RandomMinMax(5, 15) * TrapLevel; + else + damage = TrapPower; - // A dart imbeds itself in your flesh! - from.LocalOverheadMessage(MessageType.Regular, 0x62, 502998); + AOS.Damage(from, damage, 100, 0, 0, 0, 0); + + // A dart imbeds itself in your flesh! + from.LocalOverheadMessage(MessageType.Regular, 0x62, 502998); + } + + Effects.PlaySound(loc, facet, 0x223); + + break; } - - Effects.PlaySound(loc, facet, 0x223); - - break; - } case TrapType.PoisonTrap: - { - SendMessageTo(from, 502999, 0x3B2); // You set off a trap! - - if (from.InRange(loc, 3)) { - Poison poison; + SendMessageTo(from, 502999, 0x3B2); // You set off a trap! - if (TrapLevel > 0) + if (from.InRange(loc, 3)) { - poison = Poison.GetPoison(Math.Max(0, Math.Min(4, TrapLevel - 1))); - } - else - { - AOS.Damage(from, TrapPower, 0, 0, 0, 100, 0); - poison = Poison.Greater; + Poison poison; + + if (TrapLevel > 0) + { + poison = Poison.GetPoison(Math.Max(0, Math.Min(4, TrapLevel - 1))); + } + else + { + AOS.Damage(from, TrapPower, 0, 0, 0, 100, 0); + poison = Poison.Greater; + } + + from.ApplyPoison(from, poison); + + // You are enveloped in a noxious green cloud! + from.LocalOverheadMessage(MessageType.Regular, 0x44, 503004); } - from.ApplyPoison(from, poison); + Effects.SendLocationEffect(loc, facet, 0x113A, 10, 20); + Effects.PlaySound(loc, facet, 0x231); - // You are enveloped in a noxious green cloud! - from.LocalOverheadMessage(MessageType.Regular, 0x44, 503004); + break; } - - Effects.SendLocationEffect(loc, facet, 0x113A, 10, 20); - Effects.PlaySound(loc, facet, 0x231); - - break; - } } TrapType = TrapType.None; @@ -204,20 +204,20 @@ namespace Server.Items switch (version) { case 2: - { - TrapLevel = reader.ReadInt(); - goto case 1; - } + { + TrapLevel = reader.ReadInt(); + goto case 1; + } case 1: - { - TrapPower = reader.ReadInt(); - goto case 0; - } + { + TrapPower = reader.ReadInt(); + goto case 0; + } case 0: - { - TrapType = (TrapType)reader.ReadInt(); - break; - } + { + TrapType = (TrapType)reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Containers/TreasureChest.cs b/Projects/Scripts/Items/Containers/TreasureChest.cs index 627eda2d3..1f49ff3b3 100644 --- a/Projects/Scripts/Items/Containers/TreasureChest.cs +++ b/Projects/Scripts/Items/Containers/TreasureChest.cs @@ -16,7 +16,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -43,7 +43,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -70,7 +70,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Items/Containers/TreasureMapChest.cs b/Projects/Scripts/Items/Containers/TreasureMapChest.cs index 67d639daa..e447024bf 100644 --- a/Projects/Scripts/Items/Containers/TreasureMapChest.cs +++ b/Projects/Scripts/Items/Containers/TreasureMapChest.cs @@ -40,7 +40,7 @@ namespace Server.Items public override int LabelNumber => 3000541; - public static Type[] Artifacts{ get; } = + public static Type[] Artifacts { get; } = { typeof(CandelabraOfSouls), typeof(GoldBricks), typeof(PhillipsWoodenSteed), typeof(ArcticDeathDealer), typeof(BlazeOfDeath), typeof(BurglarsBandana), @@ -52,18 +52,18 @@ namespace Server.Items }; [CommandProperty(AccessLevel.GameMaster)] - public int Level{ get; set; } + public int Level { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime DeleteTime{ get; private set; } + public DateTime DeleteTime { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public bool Temporary{ get; set; } + public bool Temporary { get; set; } - public List Guardians{ get; private set; } + public List Guardians { get; private set; } public override bool IsDecoContainer => false; @@ -174,10 +174,10 @@ namespace Server.Items cont.LockLevel = cont.RequiredSkill - 10; cont.MaxLockLevel = cont.RequiredSkill + 40; - //Publish 67 gold change - //if ( Core.SA ) - // cont.DropItem( new Gold( level * 5000 ) ); - //else + // Publish 67 gold change + // if (Core.SA) + // cont.DropItem( new Gold( level * 5000 ) ); + // else cont.DropItem(new Gold(level * 1000)); for (int i = 0; i < level * 5; ++i) @@ -353,7 +353,7 @@ namespace Server.Items { m_Lifted.Add(item); - if (0.1 >= Utility.RandomDouble()) // 10% chance to spawn a new monster + if (Utility.RandomDouble() <= 0.1) // 10% chance to spawn a new monster TreasureMap.Spawn(Level, GetWorldLocation(), Map, from, false); } @@ -396,29 +396,29 @@ namespace Server.Items switch (version) { case 2: - { - Guardians = reader.ReadStrongMobileList(); - Temporary = reader.ReadBool(); + { + Guardians = reader.ReadStrongMobileList(); + Temporary = reader.ReadBool(); - goto case 1; - } + goto case 1; + } case 1: - { - Owner = reader.ReadMobile(); + { + Owner = reader.ReadMobile(); - goto case 0; - } + goto case 0; + } case 0: - { - Level = reader.ReadInt(); - DeleteTime = reader.ReadDeltaTime(); - m_Lifted = reader.ReadStrongItemList(); + { + Level = reader.ReadInt(); + DeleteTime = reader.ReadDeltaTime(); + m_Lifted = reader.ReadStrongItemList(); - if (version < 2) - Guardians = new List(); + if (version < 2) + Guardians = new List(); - break; - } + break; + } } if (!Temporary) @@ -469,8 +469,8 @@ namespace Server.Items private class RemoveGump : Gump { - private TreasureMapChest m_Chest; - private Mobile m_From; + private readonly TreasureMapChest m_Chest; + private readonly Mobile m_From; public RemoveGump(Mobile from, TreasureMapChest chest) : base(15, 15) { @@ -503,8 +503,8 @@ namespace Server.Items private class RemoveEntry : ContextMenuEntry { - private TreasureMapChest m_Chest; - private Mobile m_From; + private readonly TreasureMapChest m_Chest; + private readonly Mobile m_From; public RemoveEntry(Mobile from, TreasureMapChest chest) : base(6149, 3) { @@ -525,7 +525,7 @@ namespace Server.Items private class DeleteTimer : Timer { - private Item m_Item; + private readonly Item m_Item; public DeleteTimer(Item item, DateTime time) : base(time - DateTime.UtcNow) { diff --git a/Projects/Scripts/Items/Decoration Artifacts/BaseDecorationArtifact.cs b/Projects/Scripts/Items/Decoration Artifacts/BaseDecorationArtifact.cs index e3377627c..1e1981c50 100644 --- a/Projects/Scripts/Items/Decoration Artifacts/BaseDecorationArtifact.cs +++ b/Projects/Scripts/Items/Decoration Artifacts/BaseDecorationArtifact.cs @@ -8,7 +8,7 @@ namespace Server.Items { } - public abstract int ArtifactRarity{ get; } + public abstract int ArtifactRarity { get; } public override bool ForceShowProperties => true; @@ -42,7 +42,7 @@ namespace Server.Items { } - public abstract int ArtifactRarity{ get; } + public abstract int ArtifactRarity { get; } public override bool ForceShowProperties => true; diff --git a/Projects/Scripts/Items/Decoration Artifacts/DoomDecorationArtifacts.cs b/Projects/Scripts/Items/Decoration Artifacts/DoomDecorationArtifacts.cs index e1e5ba444..90e89d8c1 100644 --- a/Projects/Scripts/Items/Decoration Artifacts/DoomDecorationArtifacts.cs +++ b/Projects/Scripts/Items/Decoration Artifacts/DoomDecorationArtifacts.cs @@ -1,7 +1,5 @@ namespace Server.Items { - #region BackpackArtifact - public class BackpackArtifact : BaseDecorationContainerArtifact { [Constructible] @@ -30,10 +28,6 @@ namespace Server.Items } } - #endregion - - #region BloodyWaterArtifact - public class BloodyWaterArtifact : BaseDecorationArtifact { [Constructible] @@ -62,10 +56,6 @@ namespace Server.Items } } - #endregion - - #region BooksWestArtifact - public class BooksWestArtifact : BaseDecorationArtifact { [Constructible] @@ -94,10 +84,6 @@ namespace Server.Items } } - #endregion - - #region BooksNorthArtifact - public class BooksNorthArtifact : BaseDecorationArtifact { [Constructible] @@ -126,10 +112,6 @@ namespace Server.Items } } - #endregion - - #region BooksFaceDownArtifact - public class BooksFaceDownArtifact : BaseDecorationArtifact { [Constructible] @@ -158,10 +140,6 @@ namespace Server.Items } } - #endregion - - #region BottleArtifact - public class BottleArtifact : BaseDecorationArtifact { [Constructible] @@ -190,10 +168,6 @@ namespace Server.Items } } - #endregion - - #region BrazierArtifact - public class BrazierArtifact : BaseDecorationArtifact { [Constructible] @@ -220,10 +194,6 @@ namespace Server.Items } } - #endregion - - #region CocoonArtifact - public class CocoonArtifact : BaseDecorationArtifact { [Constructible] @@ -252,10 +222,6 @@ namespace Server.Items } } - #endregion - - #region DamagedBooksArtifact - public class DamagedBooksArtifact : BaseDecorationArtifact { [Constructible] @@ -284,10 +250,6 @@ namespace Server.Items } } - #endregion - - #region EggCaseArtifact - public class EggCaseArtifact : BaseDecorationArtifact { [Constructible] @@ -316,10 +278,6 @@ namespace Server.Items } } - #endregion - - #region GruesomeStandardArtifact - public class GruesomeStandardArtifact : BaseDecorationArtifact { [Constructible] @@ -348,10 +306,6 @@ namespace Server.Items } } - #endregion - - #region LampPostArtifact - public class LampPostArtifact : BaseDecorationArtifact { [Constructible] @@ -378,10 +332,6 @@ namespace Server.Items } } - #endregion - - #region LeatherTunicArtifact - public class LeatherTunicArtifact : BaseDecorationArtifact { [Constructible] @@ -410,10 +360,6 @@ namespace Server.Items } } - #endregion - - #region RockArtifact - public class RockArtifact : BaseDecorationArtifact { [Constructible] @@ -442,10 +388,6 @@ namespace Server.Items } } - #endregion - - #region RuinedPaintingArtifact - public class RuinedPaintingArtifact : BaseDecorationArtifact { [Constructible] @@ -474,10 +416,6 @@ namespace Server.Items } } - #endregion - - #region SaddleArtifact - public class SaddleArtifact : BaseDecorationArtifact { [Constructible] @@ -506,10 +444,6 @@ namespace Server.Items } } - #endregion - - #region SkinnedDeerArtifact - public class SkinnedDeerArtifact : BaseDecorationArtifact { [Constructible] @@ -538,10 +472,6 @@ namespace Server.Items } } - #endregion - - #region SkinnedGoatArtifact - public class SkinnedGoatArtifact : BaseDecorationArtifact { [Constructible] @@ -570,10 +500,6 @@ namespace Server.Items } } - #endregion - - #region SkullCandleArtifact - public class SkullCandleArtifact : BaseDecorationArtifact { [Constructible] @@ -600,10 +526,6 @@ namespace Server.Items } } - #endregion - - #region StretchedHideArtifact - public class StretchedHideArtifact : BaseDecorationArtifact { [Constructible] @@ -632,10 +554,6 @@ namespace Server.Items } } - #endregion - - #region StuddedLeggingsArtifact - public class StuddedLeggingsArtifact : BaseDecorationArtifact { [Constructible] @@ -664,10 +582,6 @@ namespace Server.Items } } - #endregion - - #region StuddedTunicArtifact - public class StuddedTunicArtifact : BaseDecorationArtifact { [Constructible] @@ -696,10 +610,6 @@ namespace Server.Items } } - #endregion - - #region TarotCardsArtifact - public class TarotCardsArtifact : BaseDecorationArtifact { [Constructible] @@ -727,6 +637,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } - - #endregion } \ No newline at end of file diff --git a/Projects/Scripts/Items/Decoration Artifacts/SEDecorationArtifacts.cs b/Projects/Scripts/Items/Decoration Artifacts/SEDecorationArtifacts.cs index c01cb2bd9..de0c4dbfc 100644 --- a/Projects/Scripts/Items/Decoration Artifacts/SEDecorationArtifacts.cs +++ b/Projects/Scripts/Items/Decoration Artifacts/SEDecorationArtifacts.cs @@ -2,8 +2,6 @@ using Server.Network; namespace Server.Items { - #region Basket1Artifact - public class Basket1Artifact : BaseDecorationContainerArtifact { [Constructible] @@ -32,10 +30,6 @@ namespace Server.Items } } - #endregion - - #region Basket2Artifact - public class Basket2Artifact : BaseDecorationContainerArtifact { [Constructible] @@ -64,10 +58,6 @@ namespace Server.Items } } - #endregion - - #region Basket3WestArtifact - public class Basket3WestArtifact : BaseDecorationContainerArtifact { [Constructible] @@ -96,10 +86,6 @@ namespace Server.Items } } - #endregion - - #region Basket3NorthArtifact - public class Basket3NorthArtifact : BaseDecorationContainerArtifact { [Constructible] @@ -128,10 +114,6 @@ namespace Server.Items } } - #endregion - - #region Basket4Artifact - public class Basket4Artifact : BaseDecorationContainerArtifact { [Constructible] @@ -160,10 +142,6 @@ namespace Server.Items } } - #endregion - - #region Basket5WestArtifact - public class Basket5WestArtifact : BaseDecorationContainerArtifact { [Constructible] @@ -192,10 +170,6 @@ namespace Server.Items } } - #endregion - - #region Basket5NorthArtifact - public class Basket5NorthArtifact : BaseDecorationContainerArtifact { [Constructible] @@ -224,10 +198,6 @@ namespace Server.Items } } - #endregion - - #region Basket6Artifact - public class Basket6Artifact : BaseDecorationContainerArtifact { [Constructible] @@ -256,10 +226,6 @@ namespace Server.Items } } - #endregion - - #region BowlArtifact - public class BowlArtifact : BaseDecorationArtifact { [Constructible] @@ -288,10 +254,6 @@ namespace Server.Items } } - #endregion - - #region BowlsVerticalArtifact - public class BowlsVerticalArtifact : BaseDecorationArtifact { [Constructible] @@ -320,10 +282,6 @@ namespace Server.Items } } - #endregion - - #region BowlsHorizontalArtifact - public class BowlsHorizontalArtifact : BaseDecorationArtifact { [Constructible] @@ -352,10 +310,6 @@ namespace Server.Items } } - #endregion - - #region CupsArtifact - public class CupsArtifact : BaseDecorationArtifact { [Constructible] @@ -384,10 +338,6 @@ namespace Server.Items } } - #endregion - - #region FanWestArtifact - public class FanWestArtifact : BaseDecorationArtifact { [Constructible] @@ -416,10 +366,6 @@ namespace Server.Items } } - #endregion - - #region FanNorthArtifact - public class FanNorthArtifact : BaseDecorationArtifact { [Constructible] @@ -448,10 +394,6 @@ namespace Server.Items } } - #endregion - - #region TripleFanWestArtifact - public class TripleFanWestArtifact : BaseDecorationArtifact { [Constructible] @@ -480,10 +422,6 @@ namespace Server.Items } } - #endregion - - #region TripleFanNorthArtifact - public class TripleFanNorthArtifact : BaseDecorationArtifact { [Constructible] @@ -512,10 +450,6 @@ namespace Server.Items } } - #endregion - - #region FlowersArtifact - public class FlowersArtifact : BaseDecorationArtifact { [Constructible] @@ -544,10 +478,6 @@ namespace Server.Items } } - #endregion - - #region Painting1WestArtifact - public class Painting1WestArtifact : BaseDecorationArtifact { [Constructible] @@ -576,10 +506,6 @@ namespace Server.Items } } - #endregion - - #region Painting1NorthArtifact - public class Painting1NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -608,10 +534,6 @@ namespace Server.Items } } - #endregion - - #region Painting2WestArtifact - public class Painting2WestArtifact : BaseDecorationArtifact { [Constructible] @@ -640,10 +562,6 @@ namespace Server.Items } } - #endregion - - #region Painting2NorthArtifact - public class Painting2NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -672,10 +590,6 @@ namespace Server.Items } } - #endregion - - #region Painting3Artifact - public class Painting3Artifact : BaseDecorationArtifact { [Constructible] @@ -704,10 +618,6 @@ namespace Server.Items } } - #endregion - - #region Painting4WestArtifact - public class Painting4WestArtifact : BaseDecorationArtifact { [Constructible] @@ -736,10 +646,6 @@ namespace Server.Items } } - #endregion - - #region Painting4NorthArtifact - public class Painting4NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -768,10 +674,6 @@ namespace Server.Items } } - #endregion - - #region Painting5WestArtifact - public class Painting5WestArtifact : BaseDecorationArtifact { [Constructible] @@ -800,10 +702,6 @@ namespace Server.Items } } - #endregion - - #region Painting5NorthArtifact - public class Painting5NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -832,10 +730,6 @@ namespace Server.Items } } - #endregion - - #region Painting6WestArtifact - public class Painting6WestArtifact : BaseDecorationArtifact { [Constructible] @@ -864,10 +758,6 @@ namespace Server.Items } } - #endregion - - #region Painting6NorthArtifact - public class Painting6NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -896,10 +786,6 @@ namespace Server.Items } } - #endregion - - #region SakeArtifact - public class SakeArtifact : BaseDecorationArtifact { [Constructible] @@ -928,10 +814,6 @@ namespace Server.Items } } - #endregion - - #region Sculpture1Artifact - public class Sculpture1Artifact : BaseDecorationArtifact { [Constructible] @@ -960,10 +842,6 @@ namespace Server.Items } } - #endregion - - #region Sculpture2Artifact - public class Sculpture2Artifact : BaseDecorationArtifact { [Constructible] @@ -992,10 +870,6 @@ namespace Server.Items } } - #endregion - - #region DolphinLeftArtifact - public class DolphinLeftArtifact : BaseDecorationArtifact { [Constructible] @@ -1024,10 +898,6 @@ namespace Server.Items } } - #endregion - - #region DolphinRightArtifact - public class DolphinRightArtifact : BaseDecorationArtifact { [Constructible] @@ -1056,10 +926,6 @@ namespace Server.Items } } - #endregion - - #region ManStatuetteSouthArtifact - public class ManStatuetteSouthArtifact : BaseDecorationArtifact { [Constructible] @@ -1088,10 +954,6 @@ namespace Server.Items } } - #endregion - - #region ManStatuetteEastArtifact - public class ManStatuetteEastArtifact : BaseDecorationArtifact { [Constructible] @@ -1120,10 +982,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay1WestArtifact - public class SwordDisplay1WestArtifact : BaseDecorationArtifact { [Constructible] @@ -1152,10 +1010,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay1NorthArtifact - public class SwordDisplay1NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -1184,10 +1038,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay2WestArtifact - public class SwordDisplay2WestArtifact : BaseDecorationArtifact { [Constructible] @@ -1216,10 +1066,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay2NorthArtifact - public class SwordDisplay2NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -1248,10 +1094,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay3SouthArtifact - public class SwordDisplay3SouthArtifact : BaseDecorationArtifact { [Constructible] @@ -1280,10 +1122,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay3EastArtifact - public class SwordDisplay3EastArtifact : BaseDecorationArtifact { [Constructible] @@ -1312,10 +1150,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay4WestArtifact - public class SwordDisplay4WestArtifact : BaseDecorationArtifact { [Constructible] @@ -1344,10 +1178,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay4NorthArtifact - public class SwordDisplay4NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -1376,10 +1206,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay5WestArtifact - public class SwordDisplay5WestArtifact : BaseDecorationArtifact { [Constructible] @@ -1408,10 +1234,6 @@ namespace Server.Items } } - #endregion - - #region SwordDisplay5NorthArtifact - public class SwordDisplay5NorthArtifact : BaseDecorationArtifact { [Constructible] @@ -1440,10 +1262,6 @@ namespace Server.Items } } - #endregion - - #region TeapotWestArtifact - public class TeapotWestArtifact : BaseDecorationArtifact { [Constructible] @@ -1472,10 +1290,6 @@ namespace Server.Items } } - #endregion - - #region TeapotNorthArtifact - public class TeapotNorthArtifact : BaseDecorationArtifact { [Constructible] @@ -1504,10 +1318,6 @@ namespace Server.Items } } - #endregion - - #region TowerLanternArtifact - public class TowerLanternArtifact : BaseDecorationArtifact { [Constructible] @@ -1565,10 +1375,6 @@ namespace Server.Items } } - #endregion - - #region Urn1Artifact - public class Urn1Artifact : BaseDecorationArtifact { [Constructible] @@ -1597,10 +1403,6 @@ namespace Server.Items } } - #endregion - - #region Urn2Artifact - public class Urn2Artifact : BaseDecorationArtifact { [Constructible] @@ -1629,10 +1431,6 @@ namespace Server.Items } } - #endregion - - #region ZenRock1Artifact - public class ZenRock1Artifact : BaseDecorationArtifact { [Constructible] @@ -1661,10 +1459,6 @@ namespace Server.Items } } - #endregion - - #region ZenRock2Artifact - public class ZenRock2Artifact : BaseDecorationArtifact { [Constructible] @@ -1693,10 +1487,6 @@ namespace Server.Items } } - #endregion - - #region ZenRock3Artifact - public class ZenRock3Artifact : BaseDecorationArtifact { [Constructible] @@ -1724,6 +1514,4 @@ namespace Server.Items int version = reader.ReadEncodedInt(); } } - - #endregion } \ No newline at end of file diff --git a/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs b/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs index 1767a6ecd..7b3ec1256 100644 --- a/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs +++ b/Projects/Scripts/Items/Decoration Artifacts/StealableArtifactsSpawner.cs @@ -1,6 +1,6 @@ -using Server.Utilities; using System; using System.Collections.Generic; +using Server.Utilities; namespace Server.Items { @@ -27,7 +27,7 @@ namespace Server.Items public StealableArtifactsSpawner(Serial serial) : base(serial) => Instance = this; - public static StealableEntry[] Entries{ get; } = + public static StealableEntry[] Entries { get; } = { // Doom - Artifact rarity 1 new StealableEntry(Map.Malas, new Point3D(317, 56, -1), 72, 108, typeof(RockArtifact)), @@ -151,19 +151,18 @@ namespace Server.Items } } - public static StealableArtifactsSpawner Instance{ get; private set; } + public static StealableArtifactsSpawner Instance { get; private set; } public override string DefaultName => "Stealable Artifacts Spawner - Internal"; private static int GetLampPostHue() { - if (0.9 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.9) return 0; return Utility.RandomList(0x455, 0x47E, 0x482, 0x486, 0x48F, 0x4F2, 0x58C, 0x66C); } - public static void Initialize() { CommandSystem.Register("GenStealArties", AccessLevel.Administrator, GenStealArties_OnCommand); @@ -303,17 +302,17 @@ namespace Server.Items Hue = hue; } - public Map Map{ get; } + public Map Map { get; } - public Point3D Location{ get; } + public Point3D Location { get; } - public int MinDelay{ get; } + public int MinDelay { get; } - public int MaxDelay{ get; } + public int MaxDelay { get; } - public Type Type{ get; } + public Type Type { get; } - public int Hue{ get; } + public int Hue { get; } public Item CreateInstance() { @@ -329,7 +328,6 @@ namespace Server.Items } } - public class StealableInstance { private Item m_Item; @@ -345,7 +343,7 @@ namespace Server.Items Entry = entry; } - public StealableEntry Entry{ get; } + public StealableEntry Entry { get; } public Item Item { @@ -371,7 +369,7 @@ namespace Server.Items } } - public DateTime NextRespawn{ get; set; } + public DateTime NextRespawn { get; set; } public void CheckRespawn() { diff --git a/Projects/Scripts/Items/Deeds/BarkeepContract.cs b/Projects/Scripts/Items/Deeds/BarkeepContract.cs index 803c8112f..e4c300214 100644 --- a/Projects/Scripts/Items/Deeds/BarkeepContract.cs +++ b/Projects/Scripts/Items/Deeds/BarkeepContract.cs @@ -23,7 +23,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Items/Deeds/ClothingBlessDeed.cs b/Projects/Scripts/Items/Deeds/ClothingBlessDeed.cs index 257bd4944..2a5ba8df0 100644 --- a/Projects/Scripts/Items/Deeds/ClothingBlessDeed.cs +++ b/Projects/Scripts/Items/Deeds/ClothingBlessDeed.cs @@ -4,7 +4,7 @@ namespace Server.Items { public class ClothingBlessTarget : Target // Create our targeting class (which we derive from the base target class) { - private ClothingBlessDeed m_Deed; + private readonly ClothingBlessDeed m_Deed; public ClothingBlessTarget(ClothingBlessDeed deed) : base(1, false, TargetFlags.None) => m_Deed = deed; @@ -21,8 +21,7 @@ namespace Server.Items return; } - if (item.LootType == LootType.Blessed || item.BlessedFor == from || Mobile.InsuranceEnabled && item.Insured - ) // Check if its already newbied (blessed) + if (item.LootType == LootType.Blessed || item.BlessedFor == from || (Mobile.InsuranceEnabled && item.Insured)) // Check if its already newbied (blessed) { from.SendLocalizedMessage(1045113); // That item is already blessed } diff --git a/Projects/Scripts/Items/Deeds/CommodityDeed.cs b/Projects/Scripts/Items/Deeds/CommodityDeed.cs index 465cf71cb..0d8874751 100644 --- a/Projects/Scripts/Items/Deeds/CommodityDeed.cs +++ b/Projects/Scripts/Items/Deeds/CommodityDeed.cs @@ -4,8 +4,8 @@ namespace Server.Items { public interface ICommodity /* added IsDeedable prop so expansion-based deedables can determine true/false */ { - int DescriptionNumber{ get; } - bool IsDeedable{ get; } + int DescriptionNumber { get; } + bool IsDeedable { get; } } public class CommodityDeed : Item @@ -26,7 +26,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Item Commodity{ get; private set; } + public Item Commodity { get; private set; } public override int LabelNumber => Commodity == null ? 1047016 : 1047017; @@ -66,10 +66,10 @@ namespace Server.Items switch (version) { case 0: - { - if (Commodity != null) Hue = 0x592; - break; - } + { + if (Commodity != null) Hue = 0x592; + break; + } } } @@ -182,7 +182,7 @@ namespace Server.Items private class InternalTarget : Target { - private CommodityDeed m_Deed; + private readonly CommodityDeed m_Deed; public InternalTarget(CommodityDeed deed) : base(3, false, TargetFlags.None) => m_Deed = deed; @@ -203,8 +203,8 @@ namespace Server.Items CommodityDeedBox cox = CommodityDeedBox.Find(m_Deed); // Veteran Rewards mods - if (box != null && m_Deed.IsChildOf(box) && item.IsChildOf(box) || - cox?.IsSecure != true && item.IsChildOf(cox)) + if ((box != null && m_Deed.IsChildOf(box) && item.IsChildOf(box)) || + (cox?.IsSecure != true && item.IsChildOf(cox))) { if (m_Deed.SetCommodity(item)) { diff --git a/Projects/Scripts/Items/Deeds/DragonBardingDeed.cs b/Projects/Scripts/Items/Deeds/DragonBardingDeed.cs index c190eac1e..2d60d1207 100644 --- a/Projects/Scripts/Items/Deeds/DragonBardingDeed.cs +++ b/Projects/Scripts/Items/Deeds/DragonBardingDeed.cs @@ -54,8 +54,6 @@ namespace Server.Items } } - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -76,8 +74,6 @@ namespace Server.Items return quality; } - #endregion - public override void GetProperties(ObjectPropertyList list) { base.GetProperties(list); @@ -153,16 +149,16 @@ namespace Server.Items { case 1: case 0: - { - m_Exceptional = reader.ReadBool(); - m_Crafter = reader.ReadMobile(); + { + m_Exceptional = reader.ReadBool(); + m_Crafter = reader.ReadMobile(); - if (version < 1) - reader.ReadInt(); + if (version < 1) + reader.ReadInt(); - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + m_Resource = (CraftResource)reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Deeds/HairRestylingDeed.cs b/Projects/Scripts/Items/Deeds/HairRestylingDeed.cs index d87408946..709a9e353 100644 --- a/Projects/Scripts/Items/Deeds/HairRestylingDeed.cs +++ b/Projects/Scripts/Items/Deeds/HairRestylingDeed.cs @@ -42,7 +42,7 @@ namespace Server.Items private class InternalGump : Gump { - private int[][] ElvenArray = + private readonly int[][] ElvenArray = { new[] { 0 }, new[] { 1011064, 1011064, 0, 0, 0, 0 }, // bald @@ -56,10 +56,10 @@ namespace Server.Items new[] { 1074393, 1074390, 0x2fd0, 0x2fcd, 0xedde, 0xc6cb } // buns, long }; -/* - racial arrays are: cliloc_F, cliloc_M, ItemID_F, ItemID_M, gump_img_F, gump_img_M -*/ - private int[][] HumanArray = /* why on earth cant these utilies be consistent with hex/dec */ + /* + racial arrays are: cliloc_F, cliloc_M, ItemID_F, ItemID_M, gump_img_F, gump_img_M + */ + private readonly int[][] HumanArray = /* why on earth cant these utilies be consistent with hex/dec */ { new[] { 0 }, new[] { 1011064, 1011064, 0, 0, 0, 0 }, // bald @@ -73,11 +73,11 @@ namespace Server.Items new[] { 1011050, 1011050, 0x204A, 0x204A, 0xED29, 0xED29 }, // Topknot new[] { 1011396, 1011396, 0x2047, 0x2047, 0xed25, 0xc618 } // Curly }; -/* - gump data: bgX, bgY, htmlX, htmlY, imgX, imgY, butX, butY -*/ + /* + gump data: bgX, bgY, htmlX, htmlY, imgX, imgY, butX, butY + */ - private int[][] LayoutArray = + private readonly int[][] LayoutArray = { new[] { 0 }, /* padding: its more efficient than code to ++ the index/buttonid */ new[] { 425, 280, 342, 295, 000, 000, 310, 292 }, @@ -92,8 +92,8 @@ namespace Server.Items new[] { 235, 280, 150, 295, 168, 245, 118, 292 } // slot 10, Curly - N/A for elfs. }; - private HairRestylingDeed m_Deed; - private Mobile m_From; + private readonly HairRestylingDeed m_Deed; + private readonly Mobile m_From; public InternalGump(Mobile from, HairRestylingDeed deed) : base(50, 50) { diff --git a/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs b/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs index 38cd6b731..bc129bfb9 100644 --- a/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs +++ b/Projects/Scripts/Items/Deeds/HolidayTreeDeed.cs @@ -91,11 +91,12 @@ namespace Server.Items Point3D loc = new Point3D(p); if (p is StaticTarget target) + /* NOTE: OSI does not properly normalize Z positioning here. + * A side affect is that you can only place on floors (due to the CanFit call). + * That functionality may be desired. And so, it's included in this script. + */ loc.Z -= TileData.ItemTable[target.ItemID] - .CalcHeight; /* NOTE: OSI does not properly normalize Z positioning here. - * A side affect is that you can only place on floors (due to the CanFit call). - * That functionality may be desired. And so, it's included in this script. - */ + .CalcHeight; if (ValidatePlacement(from, loc)) EndPlace(from, type, loc); @@ -117,8 +118,8 @@ namespace Server.Items public class HolidayTreeChoiceGump : Gump { - private HolidayTreeDeed m_Deed; - private Mobile m_From; + private readonly HolidayTreeDeed m_Deed; + private readonly Mobile m_From; public HolidayTreeChoiceGump(Mobile from, HolidayTreeDeed deed) : base(200, 200) { @@ -145,15 +146,15 @@ namespace Server.Items switch (info.ButtonID) { case 1: - { - m_Deed.BeginPlace(m_From, HolidayTreeType.Classic); - break; - } + { + m_Deed.BeginPlace(m_From, HolidayTreeType.Classic); + break; + } case 2: - { - m_Deed.BeginPlace(m_From, HolidayTreeType.Modern); - break; - } + { + m_Deed.BeginPlace(m_From, HolidayTreeType.Modern); + break; + } } } } diff --git a/Projects/Scripts/Items/Deeds/NameChangeDeed.cs b/Projects/Scripts/Items/Deeds/NameChangeDeed.cs index cd02ac2be..319116cc1 100644 --- a/Projects/Scripts/Items/Deeds/NameChangeDeed.cs +++ b/Projects/Scripts/Items/Deeds/NameChangeDeed.cs @@ -45,7 +45,7 @@ namespace Server.Items public class NameChangeDeedGump : Gump { - private Item m_Sender; + private readonly Item m_Sender; public NameChangeDeedGump(Item sender) : base(50, 50) { @@ -99,7 +99,6 @@ namespace Server.Items string newName = nameEntry?.Text.Trim(); - if (!NameVerification.Validate(newName, 2, 16, true, false, true, 1, NameVerification.SpaceDashPeriodQuote)) { m.SendMessage("That name is unacceptable."); diff --git a/Projects/Scripts/Items/Deeds/NewPlayerTicket.cs b/Projects/Scripts/Items/Deeds/NewPlayerTicket.cs index 7460ae6a7..0c12f2ae7 100644 --- a/Projects/Scripts/Items/Deeds/NewPlayerTicket.cs +++ b/Projects/Scripts/Items/Deeds/NewPlayerTicket.cs @@ -18,7 +18,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } public override int LabelNumber => 1062094; // a young player ticket @@ -49,10 +49,10 @@ namespace Server.Items switch (version) { case 0: - { - Owner = reader.ReadMobile(); - break; - } + { + Owner = reader.ReadMobile(); + break; + } } if (Name == "a young player ticket") @@ -78,7 +78,7 @@ namespace Server.Items private class InternalTarget : Target { - private NewPlayerTicket m_Ticket; + private readonly NewPlayerTicket m_Ticket; public InternalTarget(NewPlayerTicket ticket) : base(2, false, TargetFlags.None) => m_Ticket = ticket; @@ -115,8 +115,8 @@ namespace Server.Items private class InternalGump : Gump { - private Mobile m_From; - private NewPlayerTicket m_Ticket; + private readonly Mobile m_From; + private readonly NewPlayerTicket m_Ticket; public InternalGump(Mobile from, NewPlayerTicket ticket) : base(50, 50) { diff --git a/Projects/Scripts/Items/Deeds/VendorRentalContract.cs b/Projects/Scripts/Items/Deeds/VendorRentalContract.cs index 18edbc0c8..12b790403 100644 --- a/Projects/Scripts/Items/Deeds/VendorRentalContract.cs +++ b/Projects/Scripts/Items/Deeds/VendorRentalContract.cs @@ -42,10 +42,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int Price{ get; set; } + public int Price { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool LandlordRenew{ get; set; } + public bool LandlordRenew { get; set; } public Mobile Offeree { @@ -223,7 +223,7 @@ namespace Server.Items private class ContractOptionEntry : ContextMenuEntry { - private VendorRentalContract m_Contract; + private readonly VendorRentalContract m_Contract; public ContractOptionEntry(VendorRentalContract contract) : base(6209) => m_Contract = contract; @@ -241,7 +241,7 @@ namespace Server.Items private class RentTarget : Target { - private VendorRentalContract m_Contract; + private readonly VendorRentalContract m_Contract; public RentTarget(VendorRentalContract contract) : base(-1, false, TargetFlags.None) => m_Contract = contract; @@ -318,7 +318,7 @@ namespace Server.Items private class OfferExpireTimer : Timer { - private VendorRentalContract m_Contract; + private readonly VendorRentalContract m_Contract; public OfferExpireTimer(VendorRentalContract contract) : base(TimeSpan.FromSeconds(30.0)) { diff --git a/Projects/Scripts/Items/Facial/Beard.cs b/Projects/Scripts/Items/Facial/Beard.cs index 443ea43f5..f6c1e4d94 100644 --- a/Projects/Scripts/Items/Facial/Beard.cs +++ b/Projects/Scripts/Items/Facial/Beard.cs @@ -6,7 +6,7 @@ namespace Server.Items public static int ShortBeard = 0x203f; public static int Goatee = 0x2040; public static int Mustache = 0x2041; - + public static int MediumShortBeard = 0x204B; public static int MediumLongBeard = 0x204C; public static int Vandyke = 0x204D; diff --git a/Projects/Scripts/Items/Facial/Hair.cs b/Projects/Scripts/Items/Facial/Hair.cs index e5e1e1349..28abe8fa4 100644 --- a/Projects/Scripts/Items/Facial/Hair.cs +++ b/Projects/Scripts/Items/Facial/Hair.cs @@ -3,29 +3,29 @@ namespace Server.Items public static class Hair { // Human - public static int Long = 0x203C; - public static int Shor = 0x203B; - public static int PonyTail = 0x203D; + public static readonly int Long = 0x203C; + public static readonly int Shor = 0x203B; + public static readonly int PonyTail = 0x203D; + + public static readonly int Mohawk = 0x2044; + public static readonly int Pageboy = 0x2045; + public static readonly int Bun = 0x2046; // Female Only + public static readonly int Afro = 0x2047; + public static readonly int Receding = 0x2048; // Male Only + public static readonly int TwoPigTails = 0x2049; + public static readonly int Krisna = 0x204A; - public static int Mohawk = 0x2044; - public static int Pageboy = 0x2045; - public static int Bun = 0x2046; // Female Only - public static int Afro = 0x2047; - public static int Receding = 0x2048; // Male Only - public static int TwoPigTails = 0x2049; - public static int Krisna = 0x204A; - // Elf - public static int MidLongElf = 0x2FBF; // Male Only - public static int LongFeather = 0x2FC0; - public static int ShortElf = 0x2FC1; - public static int Mullet = 0x2FC2; - - public static int Flower = 0x2FCC; // Female only - public static int LongElf = 0x2FCD; // Male Only - public static int Knob = 0x2FCE; - public static int Braided = 0x2FCF; - public static int BunElf = 0x2FD0; // Female Only - public static int Spiked = 0x2FD1; + public static readonly int MidLongElf = 0x2FBF; // Male Only + public static readonly int LongFeather = 0x2FC0; + public static readonly int ShortElf = 0x2FC1; + public static readonly int Mullet = 0x2FC2; + + public static readonly int Flower = 0x2FCC; // Female only + public static readonly int LongElf = 0x2FCD; // Male Only + public static readonly int Knob = 0x2FCE; + public static readonly int Braided = 0x2FCF; + public static readonly int BunElf = 0x2FD0; // Female Only + public static readonly int Spiked = 0x2FD1; } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Food/Beverage.cs b/Projects/Scripts/Items/Food/Beverage.cs index 8e154f955..24f21c620 100644 --- a/Projects/Scripts/Items/Food/Beverage.cs +++ b/Projects/Scripts/Items/Food/Beverage.cs @@ -23,7 +23,7 @@ namespace Server.Items public interface IHasQuantity { - int Quantity{ get; set; } + int Quantity { get; set; } } public interface IWaterSource : IHasQuantity @@ -81,29 +81,29 @@ namespace Server.Items switch (version) { case 0: - { - if (CheckType("BottleAle")) { - Quantity = MaxQuantity; - Content = BeverageType.Ale; - } - else if (CheckType("BottleLiquor")) - { - Quantity = MaxQuantity; - Content = BeverageType.Liquor; - } - else if (CheckType("BottleWine")) - { - Quantity = MaxQuantity; - Content = BeverageType.Wine; - } - else - { - throw new Exception(World.LoadingType); - } + if (CheckType("BottleAle")) + { + Quantity = MaxQuantity; + Content = BeverageType.Ale; + } + else if (CheckType("BottleLiquor")) + { + Quantity = MaxQuantity; + Content = BeverageType.Liquor; + } + else if (CheckType("BottleWine")) + { + Quantity = MaxQuantity; + Content = BeverageType.Wine; + } + else + { + throw new Exception(World.LoadingType); + } - break; - } + break; + } } } } @@ -300,12 +300,12 @@ namespace Server.Items return Content switch { - BeverageType.Ale => (ItemID == 0x9EF ? 0x9EF : 0x9EE), - BeverageType.Cider => (ItemID >= 0x1F7D && ItemID <= 0x1F80 ? ItemID : 0x1F7D), - BeverageType.Liquor => (ItemID >= 0x1F85 && ItemID <= 0x1F88 ? ItemID : 0x1F85), - BeverageType.Milk => (ItemID >= 0x1F89 && ItemID <= 0x1F8C ? ItemID : 0x1F89), - BeverageType.Wine => (ItemID >= 0x1F8D && ItemID <= 0x1F90 ? ItemID : 0x1F8D), - BeverageType.Water => (ItemID >= 0x1F91 && ItemID <= 0x1F94 ? ItemID : 0x1F91), + BeverageType.Ale => ItemID == 0x9EF ? 0x9EF : 0x9EE, + BeverageType.Cider => ItemID >= 0x1F7D && ItemID <= 0x1F80 ? ItemID : 0x1F7D, + BeverageType.Liquor => ItemID >= 0x1F85 && ItemID <= 0x1F88 ? ItemID : 0x1F85, + BeverageType.Milk => ItemID >= 0x1F89 && ItemID <= 0x1F8C ? ItemID : 0x1F89, + BeverageType.Wine => ItemID >= 0x1F8D && ItemID <= 0x1F90 ? ItemID : 0x1F8D, + BeverageType.Water => ItemID >= 0x1F91 && ItemID <= 0x1F94 ? ItemID : 0x1F91, _ => 0 }; } @@ -326,44 +326,44 @@ namespace Server.Items switch (version) { case 0: - { - if (CheckType("MugAle")) { - Quantity = MaxQuantity; - Content = BeverageType.Ale; - } - else if (CheckType("GlassCider")) - { - Quantity = MaxQuantity; - Content = BeverageType.Cider; - } - else if (CheckType("GlassLiquor")) - { - Quantity = MaxQuantity; - Content = BeverageType.Liquor; - } - else if (CheckType("GlassMilk")) - { - Quantity = MaxQuantity; - Content = BeverageType.Milk; - } - else if (CheckType("GlassWine")) - { - Quantity = MaxQuantity; - Content = BeverageType.Wine; - } - else if (CheckType("GlassWater")) - { - Quantity = MaxQuantity; - Content = BeverageType.Water; - } - else - { - throw new Exception(World.LoadingType); - } + if (CheckType("MugAle")) + { + Quantity = MaxQuantity; + Content = BeverageType.Ale; + } + else if (CheckType("GlassCider")) + { + Quantity = MaxQuantity; + Content = BeverageType.Cider; + } + else if (CheckType("GlassLiquor")) + { + Quantity = MaxQuantity; + Content = BeverageType.Liquor; + } + else if (CheckType("GlassMilk")) + { + Quantity = MaxQuantity; + Content = BeverageType.Milk; + } + else if (CheckType("GlassWine")) + { + Quantity = MaxQuantity; + Content = BeverageType.Wine; + } + else if (CheckType("GlassWater")) + { + Quantity = MaxQuantity; + Content = BeverageType.Water; + } + else + { + throw new Exception(World.LoadingType); + } - break; - } + break; + } } } } @@ -402,47 +402,47 @@ namespace Server.Items switch (Content) { case BeverageType.Ale: - { - if (ItemID == 0x1F96) - return ItemID; + { + if (ItemID == 0x1F96) + return ItemID; - return 0x1F95; - } + return 0x1F95; + } case BeverageType.Cider: - { - if (ItemID == 0x1F98) - return ItemID; + { + if (ItemID == 0x1F98) + return ItemID; - return 0x1F97; - } + return 0x1F97; + } case BeverageType.Liquor: - { - if (ItemID == 0x1F9A) - return ItemID; + { + if (ItemID == 0x1F9A) + return ItemID; - return 0x1F99; - } + return 0x1F99; + } case BeverageType.Milk: - { - if (ItemID == 0x9AD) - return ItemID; + { + if (ItemID == 0x9AD) + return ItemID; - return 0x9F0; - } + return 0x9F0; + } case BeverageType.Wine: - { - if (ItemID == 0x1F9C) - return ItemID; + { + if (ItemID == 0x1F9C) + return ItemID; - return 0x1F9B; - } + return 0x1F9B; + } case BeverageType.Water: - { - if (ItemID == 0xFF8 || ItemID == 0xFF9 || ItemID == 0x1F9E) - return ItemID; + { + if (ItemID == 0xFF8 || ItemID == 0xFF9 || ItemID == 0x1F9E) + return ItemID; - return 0x1F9D; - } + return 0x1F9D; + } } return 0; @@ -467,56 +467,56 @@ namespace Server.Items switch (version) { case 0: - { - if (CheckType("PitcherAle")) { - Quantity = MaxQuantity; - Content = BeverageType.Ale; - } - else if (CheckType("PitcherCider")) - { - Quantity = MaxQuantity; - Content = BeverageType.Cider; - } - else if (CheckType("PitcherLiquor")) - { - Quantity = MaxQuantity; - Content = BeverageType.Liquor; - } - else if (CheckType("PitcherMilk")) - { - Quantity = MaxQuantity; - Content = BeverageType.Milk; - } - else if (CheckType("PitcherWine")) - { - Quantity = MaxQuantity; - Content = BeverageType.Wine; - } - else if (CheckType("PitcherWater")) - { - Quantity = MaxQuantity; - Content = BeverageType.Water; - } - else if (CheckType("GlassPitcher")) - { - Quantity = 0; - Content = BeverageType.Water; - } - else - { - throw new Exception(World.LoadingType); - } + if (CheckType("PitcherAle")) + { + Quantity = MaxQuantity; + Content = BeverageType.Ale; + } + else if (CheckType("PitcherCider")) + { + Quantity = MaxQuantity; + Content = BeverageType.Cider; + } + else if (CheckType("PitcherLiquor")) + { + Quantity = MaxQuantity; + Content = BeverageType.Liquor; + } + else if (CheckType("PitcherMilk")) + { + Quantity = MaxQuantity; + Content = BeverageType.Milk; + } + else if (CheckType("PitcherWine")) + { + Quantity = MaxQuantity; + Content = BeverageType.Wine; + } + else if (CheckType("PitcherWater")) + { + Quantity = MaxQuantity; + Content = BeverageType.Water; + } + else if (CheckType("GlassPitcher")) + { + Quantity = 0; + Content = BeverageType.Water; + } + else + { + throw new Exception(World.LoadingType); + } - break; - } + break; + } } } } public abstract class BaseBeverage : Item, IHasQuantity { - private static int[] m_SwampTiles = + private static readonly int[] m_SwampTiles = { 0x9C4, 0x9EB, 0x3D65, 0x3D65, @@ -564,7 +564,7 @@ namespace Server.Items public virtual int EmptyLabelNumber => base.LabelNumber; public virtual int BaseLabelNumber => 0; - public abstract int MaxQuantity{ get; } + public abstract int MaxQuantity { get; } [CommandProperty(AccessLevel.GameMaster)] public bool IsEmpty => m_Quantity <= 0; @@ -576,10 +576,10 @@ namespace Server.Items public bool IsFull => m_Quantity >= MaxQuantity; [CommandProperty(AccessLevel.GameMaster)] - public Poison Poison{ get; set; } + public Poison Poison { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Poisoner{ get; set; } + public Mobile Poisoner { get; set; } [CommandProperty(AccessLevel.GameMaster)] public BeverageType Content @@ -711,7 +711,7 @@ namespace Server.Items } else if (targ is BaseWaterContainer bwc) { - if (Quantity == 0 || Content == BeverageType.Water && !IsFull) + if (Quantity == 0 || (Content == BeverageType.Water && !IsFull)) { int iNeed = Math.Min(MaxQuantity - Quantity, bwc.Quantity); @@ -910,7 +910,7 @@ namespace Server.Items BaseAddon vat = component.Addon; if (vat.X > 5784 && vat.X < 5814 && vat.Y > 1903 && vat.Y < 1934 && - (qs.RedSolen && vat.Map == Map.Trammel || !qs.RedSolen && vat.Map == Map.Felucca)) + ((qs.RedSolen && vat.Map == Map.Trammel) || (!qs.RedSolen && vat.Map == Map.Felucca))) { if (obj.CurProgress + Quantity > obj.MaxProgress) { @@ -1025,23 +1025,21 @@ namespace Server.Items switch (version) { case 1: - { - Poisoner = reader.ReadMobile(); - goto case 0; - } + { + Poisoner = reader.ReadMobile(); + goto case 0; + } case 0: - { - Poison = Poison.Deserialize(reader); - m_Content = (BeverageType)reader.ReadInt(); - m_Quantity = reader.ReadInt(); - break; - } + { + Poison = Poison.Deserialize(reader); + m_Content = (BeverageType)reader.ReadInt(); + m_Quantity = reader.ReadInt(); + break; + } } } - #region Effects of achohol - - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public static void Initialize() { @@ -1080,7 +1078,7 @@ namespace Server.Items private class HeaveTimer : Timer { - private Mobile m_Drunk; + private readonly Mobile m_Drunk; public HeaveTimer(Mobile drunk) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) @@ -1103,7 +1101,7 @@ namespace Server.Items m_Drunk.BAC = 60; // chance to get sober - if (10 > Utility.Random(100)) + if (Utility.Random(100) < 10) --m_Drunk.BAC; // lose some stats @@ -1135,7 +1133,5 @@ namespace Server.Items } } } - - #endregion } } diff --git a/Projects/Scripts/Items/Food/CookableFood.cs b/Projects/Scripts/Items/Food/CookableFood.cs index f2c8a181d..de6fe142a 100644 --- a/Projects/Scripts/Items/Food/CookableFood.cs +++ b/Projects/Scripts/Items/Food/CookableFood.cs @@ -6,7 +6,7 @@ namespace Server.Items public abstract class CookableFood : Item { [CommandProperty(AccessLevel.GameMaster)] - public int CookingLevel{ get; set; } + public int CookingLevel { get; set; } public CookableFood(int itemID, int cookingLevel) : base(itemID) => CookingLevel = cookingLevel; @@ -34,24 +34,14 @@ namespace Server.Items switch (version) { case 1: - { - CookingLevel = reader.ReadInt(); + { + CookingLevel = reader.ReadInt(); - break; - } + break; + } } } -#if false - public override void OnDoubleClick( Mobile from ) - { - if ( !Movable ) - return; - - from.Target = new InternalTarget( this ); - } -#endif - public static bool IsHeatSource(object targeted) { int itemID; @@ -83,7 +73,7 @@ namespace Server.Items private class InternalTarget : Target { - private CookableFood m_Item; + private readonly CookableFood m_Item; public InternalTarget(CookableFood item) : base(1, false, TargetFlags.None) => m_Item = item; @@ -111,10 +101,10 @@ namespace Server.Items private class InternalTimer : Timer { - private CookableFood m_CookableFood; - private Mobile m_From; - private Map m_Map; - private IPoint3D m_Point; + private readonly CookableFood m_CookableFood; + private readonly Mobile m_From; + private readonly Map m_Map; + private readonly IPoint3D m_Point; public InternalTimer(Mobile from, IPoint3D p, Map map, CookableFood cookableFood) : base( TimeSpan.FromSeconds(5.0)) @@ -129,7 +119,7 @@ namespace Server.Items { m_From.EndAction(); - if (m_From.Map != m_Map || m_Point != null && m_From.GetDistanceToSqrt(m_Point) > 3) + if (m_From.Map != m_Map || (m_Point != null && m_From.GetDistanceToSqrt(m_Point) > 3)) { m_From.SendLocalizedMessage(500686); // You burn the food to a crisp! It's ruined. return; @@ -183,7 +173,6 @@ namespace Server.Items public override Food Cook() => new Ribs(); } - // ********** RawLambLeg ********** public class RawLambLeg : CookableFood { @@ -249,7 +238,6 @@ namespace Server.Items public override Food Cook() => new ChickenLeg(); } - // ********** RawBird ********** public class RawBird : CookableFood { @@ -282,7 +270,6 @@ namespace Server.Items public override Food Cook() => new CookedBird(); } - // ********** UnbakedPeachCobbler ********** public class UnbakedPeachCobbler : CookableFood { diff --git a/Projects/Scripts/Items/Food/Cooking.cs b/Projects/Scripts/Items/Food/Cooking.cs index 2aee9482c..7e736c11c 100644 --- a/Projects/Scripts/Items/Food/Cooking.cs +++ b/Projects/Scripts/Items/Food/Cooking.cs @@ -46,19 +46,9 @@ namespace Server.Items int version = reader.ReadInt(); } -#if false - public override void OnDoubleClick( Mobile from ) - { - if ( !Movable ) - return; - - from.Target = new InternalTarget( this ); - } -#endif - private class InternalTarget : Target { - private Dough m_Item; + private readonly Dough m_Item; public InternalTarget(Dough item) : base(1, false, TargetFlags.None) => m_Item = item; @@ -134,19 +124,9 @@ namespace Server.Items Hue = 150; } -#if false - public override void OnDoubleClick( Mobile from ) - { - if ( !Movable ) - return; - - from.Target = new InternalTarget( this ); - } -#endif - private class InternalTarget : Target { - private SweetDough m_Item; + private readonly SweetDough m_Item; public InternalTarget(SweetDough item) : base(1, false, TargetFlags.None) => m_Item = item; @@ -172,8 +152,8 @@ namespace Server.Items private class InternalTimer : Timer { - private Campfire m_Campfire; - private Mobile m_From; + private readonly Campfire m_Campfire; + private readonly Mobile m_From; public InternalTimer(Mobile from, Campfire campfire) : base(TimeSpan.FromSeconds(5.0)) { @@ -234,7 +214,7 @@ namespace Server.Items /*public override void OnDoubleClick( Mobile from ) { - if ( !Movable ) + if (!Movable) return; from.Target = new InternalTarget( this ); @@ -242,7 +222,7 @@ namespace Server.Items private class InternalTarget : Target { - private JarHoney m_Item; + private readonly JarHoney m_Item; public InternalTarget(JarHoney item) : base(1, false, TargetFlags.None) => m_Item = item; @@ -348,7 +328,7 @@ namespace Server.Items public override void OnDoubleClick( Mobile from ) { - if ( !Movable ) + if (!Movable) return; from.Target = new InternalTarget( this ); @@ -365,9 +345,9 @@ namespace Server.Items protected override void OnTarget( Mobile from, object targeted ) { - if ( m_Item.Deleted ) return; + if (m_Item.Deleted ) return; - if ( targeted is BowlFlour ) + if (targeted is BowlFlour) { m_Item.Delete(); ((BowlFlour)targeted).Delete(); @@ -430,15 +410,15 @@ namespace Server.Items { case 2: case 1: - { - m_Quantity = reader.ReadInt(); - break; - } + { + m_Quantity = reader.ReadInt(); + break; + } case 0: - { - m_Quantity = 20; - break; - } + { + m_Quantity = 20; + break; + } } if (version < 2 && Weight == 1.0) @@ -452,12 +432,6 @@ namespace Server.Items if (ItemID == 0x1039 || ItemID == 0x1045) ++ItemID; - -#if false - this.Delete(); - - from.AddToBackpack( new SackFlourOpen() ); -#endif } } diff --git a/Projects/Scripts/Items/Food/Food.cs b/Projects/Scripts/Items/Food/Food.cs index 685b6f873..dd1e135fe 100644 --- a/Projects/Scripts/Items/Food/Food.cs +++ b/Projects/Scripts/Items/Food/Food.cs @@ -17,13 +17,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Poisoner{ get; set; } + public Mobile Poisoner { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Poison Poison{ get; set; } + public Poison Poison { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int FillFactor{ get; set; } + public int FillFactor { get; set; } public override void GetContextMenuEntries(Mobile from, List list) { @@ -121,35 +121,35 @@ namespace Server.Items switch (version) { case 1: - { - Poison = reader.ReadInt() switch { - 0 => null, - 1 => Poison.Lesser, - 2 => Poison.Regular, - 3 => Poison.Greater, - 4 => Poison.Deadly, - _ => Poison - }; + Poison = reader.ReadInt() switch + { + 0 => null, + 1 => Poison.Lesser, + 2 => Poison.Regular, + 3 => Poison.Greater, + 4 => Poison.Deadly, + _ => Poison + }; - break; - } + break; + } case 2: - { - Poison = Poison.Deserialize(reader); - break; - } + { + Poison = Poison.Deserialize(reader); + break; + } case 3: - { - Poison = Poison.Deserialize(reader); - FillFactor = reader.ReadInt(); - break; - } + { + Poison = Poison.Deserialize(reader); + FillFactor = reader.ReadInt(); + break; + } case 4: - { - Poisoner = reader.ReadMobile(); - goto case 3; - } + { + Poisoner = reader.ReadMobile(); + goto case 3; + } } } } @@ -370,7 +370,6 @@ namespace Server.Items } } - public class FriedEggs : Food { [Constructible] diff --git a/Projects/Scripts/Items/Games/BaseBoard.cs b/Projects/Scripts/Items/Games/BaseBoard.cs index 6a3838e2b..a369ac47f 100644 --- a/Projects/Scripts/Items/Games/BaseBoard.cs +++ b/Projects/Scripts/Items/Games/BaseBoard.cs @@ -27,7 +27,7 @@ namespace Server.Items public override TimeSpan DecayTime => TimeSpan.FromDays(1.0); [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public abstract void CreatePieces(); @@ -101,15 +101,15 @@ 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.Deleted && (from.AccessLevel >= AccessLevel.GameMaster || (from.Alive && + (board.IsChildOf(from.Backpack) || (!(board.RootParent is Mobile) && board.Map == from.Map && from.InRange(board.GetWorldLocation(), 1) && - BaseHouse.FindHouseAt(board)?.IsOwner(from) == true)); + BaseHouse.FindHouseAt(board)?.IsOwner(from) == true)))); public class DefaultEntry : ContextMenuEntry { - private BaseBoard m_Board; - private Mobile m_From; + private readonly BaseBoard m_Board; + private readonly Mobile m_From; public DefaultEntry(Mobile from, BaseBoard board) : base(6162, from.AccessLevel >= AccessLevel.GameMaster ? -1 : 1) diff --git a/Projects/Scripts/Items/Games/BasePiece.cs b/Projects/Scripts/Items/Games/BasePiece.cs index d15dde059..93949ffe6 100644 --- a/Projects/Scripts/Items/Games/BasePiece.cs +++ b/Projects/Scripts/Items/Games/BasePiece.cs @@ -8,7 +8,7 @@ namespace Server.Items { } - public BaseBoard Board{ get; set; } + public BaseBoard Board { get; set; } public override bool IsVirtualItem => true; @@ -31,14 +31,14 @@ namespace Server.Items switch (version) { case 0: - { - Board = (BaseBoard)reader.ReadItem(); + { + Board = (BaseBoard)reader.ReadItem(); - if (Board == null || Parent == null) - Delete(); + if (Board == null || Parent == null) + Delete(); - break; - } + break; + } } } diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongDealerIndicator.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongDealerIndicator.cs index 60bd72f8b..73122cc70 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongDealerIndicator.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongDealerIndicator.cs @@ -21,13 +21,13 @@ namespace Server.Engines.Mahjong Wind = (MahjongWind)reader.ReadInt(); } - public MahjongGame Game{ get; } + public MahjongGame Game { get; } - public Point2D Position{ get; private set; } + public Point2D Position { get; private set; } - public MahjongPieceDirection Direction{ get; private set; } + public MahjongPieceDirection Direction { get; private set; } - public MahjongWind Wind{ get; private set; } + public MahjongWind Wind { get; private set; } public MahjongPieceDim Dimensions => GetDimensions(Position, Direction); diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongDices.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongDices.cs index 45ab04737..49e607b59 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongDices.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongDices.cs @@ -19,11 +19,11 @@ namespace Server.Engines.Mahjong Second = reader.ReadInt(); } - public MahjongGame Game{ get; } + public MahjongGame Game { get; } - public int First{ get; private set; } + public int First { get; private set; } - public int Second{ get; private set; } + public int Second { get; private set; } public void RollDices(Mobile from) { diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongGame.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongGame.cs index 29c4f019b..91f60d32f 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongGame.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongGame.cs @@ -34,15 +34,15 @@ namespace Server.Engines.Mahjong { } - public MahjongTile[] Tiles{ get; private set; } + public MahjongTile[] Tiles { get; private set; } - public MahjongDealerIndicator DealerIndicator{ get; private set; } + public MahjongDealerIndicator DealerIndicator { get; private set; } - public MahjongWallBreakIndicator WallBreakIndicator{ get; private set; } + public MahjongWallBreakIndicator WallBreakIndicator { get; private set; } - public MahjongDices Dices{ get; private set; } + public MahjongDices Dices { get; private set; } - public MahjongPlayers Players{ get; private set; } + public MahjongPlayers Players { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public bool ShowScores @@ -87,7 +87,7 @@ namespace Server.Engines.Mahjong } [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } private void BuildHorizontalWall(ref int index, int x, int y, int stackLevel, MahjongPieceDirection direction, MahjongTileTypeGenerator typeGenerator) @@ -242,43 +242,43 @@ namespace Server.Engines.Mahjong switch (version) { case 1: - { - Level = (SecureLevel)reader.ReadInt(); + { + Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } + goto case 0; + } case 0: - { - if (version < 1) - Level = SecureLevel.CoOwners; + { + if (version < 1) + Level = SecureLevel.CoOwners; - int length = reader.ReadInt(); - Tiles = new MahjongTile[length]; + int length = reader.ReadInt(); + Tiles = new MahjongTile[length]; - for (int i = 0; i < length; i++) - Tiles[i] = new MahjongTile(this, reader); + for (int i = 0; i < length; i++) + Tiles[i] = new MahjongTile(this, reader); - DealerIndicator = new MahjongDealerIndicator(this, reader); + DealerIndicator = new MahjongDealerIndicator(this, reader); - WallBreakIndicator = new MahjongWallBreakIndicator(this, reader); + WallBreakIndicator = new MahjongWallBreakIndicator(this, reader); - Dices = new MahjongDices(this, reader); + Dices = new MahjongDices(this, reader); - Players = new MahjongPlayers(this, reader); + Players = new MahjongPlayers(this, reader); - m_ShowScores = reader.ReadBool(); - m_SpectatorVision = reader.ReadBool(); + m_ShowScores = reader.ReadBool(); + m_SpectatorVision = reader.ReadBool(); - m_LastReset = DateTime.UtcNow; + m_LastReset = DateTime.UtcNow; - break; - } + break; + } } } private class ResetGameEntry : ContextMenuEntry { - private MahjongGame m_Game; + private readonly MahjongGame m_Game; public ResetGameEntry(MahjongGame game) : base(6162) => m_Game = game; diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs index 9683f3363..eb5816ead 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongPacketHandlers.cs @@ -6,7 +6,7 @@ namespace Server.Engines.Mahjong public sealed class MahjongPacketHandlers { - private static OnMahjongPacketReceive[] m_SubCommandDelegates = new OnMahjongPacketReceive[0x100]; + private static readonly OnMahjongPacketReceive[] m_SubCommandDelegates = new OnMahjongPacketReceive[0x100]; public static void RegisterSubCommand(int subCmd, OnMahjongPacketReceive onReceive) { diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongPieceDim.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongPieceDim.cs index cc1f4af8e..2a4248cda 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongPieceDim.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongPieceDim.cs @@ -2,11 +2,11 @@ namespace Server.Engines.Mahjong { public struct MahjongPieceDim { - public Point2D Position{ get; } + public Point2D Position { get; } - public int Width{ get; } + public int Width { get; } - public int Height{ get; } + public int Height { get; } public MahjongPieceDim(Point2D position, int width, int height) { diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongPlayers.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongPlayers.cs index b19624703..18697cf8c 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongPlayers.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongPlayers.cs @@ -4,11 +4,11 @@ namespace Server.Engines.Mahjong { public class MahjongPlayers { - private bool[] m_InGame; - private Mobile[] m_Players; - private bool[] m_PublicHand; - private int[] m_Scores; - private List m_Spectators; + private readonly bool[] m_InGame; + private readonly Mobile[] m_Players; + private readonly bool[] m_PublicHand; + private readonly int[] m_Scores; + private readonly List m_Spectators; public MahjongPlayers(MahjongGame game, int maxPlayers, int baseScore) { @@ -47,11 +47,11 @@ namespace Server.Engines.Mahjong DealerPosition = reader.ReadInt(); } - public MahjongGame Game{ get; } + public MahjongGame Game { get; } public int Seats => m_Players.Length; public Mobile Dealer => m_Players[DealerPosition]; - public int DealerPosition{ get; private set; } + public int DealerPosition { get; private set; } public Mobile GetPlayer(int index) { diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongTile.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongTile.cs index 31d5ca540..3e0480978 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongTile.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongTile.cs @@ -30,18 +30,18 @@ namespace Server.Engines.Mahjong Flipped = reader.ReadBool(); } - public MahjongGame Game{ get; } + public MahjongGame Game { get; } - public int Number{ get; } + public int Number { get; } - public MahjongTileType Value{ get; } + public MahjongTileType Value { get; } public Point2D Position => m_Position; - public int StackLevel{ get; private set; } + public int StackLevel { get; private set; } - public MahjongPieceDirection Direction{ get; private set; } + public MahjongPieceDirection Direction { get; private set; } - public bool Flipped{ get; private set; } + public bool Flipped { get; private set; } public MahjongPieceDim Dimensions => GetDimensions(m_Position, Direction); @@ -60,8 +60,8 @@ namespace Server.Engines.Mahjong int curHandArea = Dimensions.GetHandArea(); int newHandArea = dim.GetHandArea(); - if (!IsMovable || !dim.IsValid() || validHandArea >= 0 && - (curHandArea >= 0 && curHandArea != validHandArea || newHandArea >= 0 && newHandArea != validHandArea)) + if (!IsMovable || !dim.IsValid() || (validHandArea >= 0 && + ((curHandArea >= 0 && curHandArea != validHandArea) || (newHandArea >= 0 && newHandArea != validHandArea)))) return; m_Position = position; diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongTileTypeGenerator.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongTileTypeGenerator.cs index b65dff705..239c8960f 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongTileTypeGenerator.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongTileTypeGenerator.cs @@ -18,7 +18,7 @@ namespace Server.Engines.Mahjong } } - public List LeftTileTypes{ get; } + public List LeftTileTypes { get; } public MahjongTileType Next() { diff --git a/Projects/Scripts/Items/Games/Mahjong/MahjongWallBreakIndicator.cs b/Projects/Scripts/Items/Games/Mahjong/MahjongWallBreakIndicator.cs index 1ac60c0f3..e918553aa 100644 --- a/Projects/Scripts/Items/Games/Mahjong/MahjongWallBreakIndicator.cs +++ b/Projects/Scripts/Items/Games/Mahjong/MahjongWallBreakIndicator.cs @@ -17,9 +17,9 @@ namespace Server.Engines.Mahjong Position = reader.ReadPoint2D(); } - public MahjongGame Game{ get; } + public MahjongGame Game { get; } - public Point2D Position{ get; private set; } + public Point2D Position { get; private set; } public MahjongPieceDim Dimensions => GetDimensions(Position); diff --git a/Projects/Scripts/Items/Games/Mahjong/Packets.cs b/Projects/Scripts/Items/Games/Mahjong/Packets.cs index 39be5ea77..920cc18c1 100644 --- a/Projects/Scripts/Items/Games/Mahjong/Packets.cs +++ b/Projects/Scripts/Items/Games/Mahjong/Packets.cs @@ -9,9 +9,9 @@ namespace Server.Engines.Mahjong { EnsureCapacity(9); - m_Stream.Write(game.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0x19); + Stream.Write(game.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0x19); } } @@ -23,12 +23,12 @@ namespace Server.Engines.Mahjong EnsureCapacity(11 + 45 * players.Seats); - m_Stream.Write(game.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0x2); + Stream.Write(game.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0x2); - m_Stream.Write((byte)0); - m_Stream.Write((byte)players.Seats); + Stream.Write((byte)0); + Stream.Write((byte)players.Seats); int n = 0; for (int i = 0; i < players.Seats; i++) @@ -37,40 +37,40 @@ namespace Server.Engines.Mahjong if (mobile != null) { - m_Stream.Write(mobile.Serial); - m_Stream.Write(players.DealerPosition == i ? (byte)0x1 : (byte)0x2); - m_Stream.Write((byte)i); + Stream.Write(mobile.Serial); + Stream.Write(players.DealerPosition == i ? (byte)0x1 : (byte)0x2); + Stream.Write((byte)i); if (game.ShowScores || mobile == to) - m_Stream.Write(players.GetScore(i)); + Stream.Write(players.GetScore(i)); else - m_Stream.Write(0); + Stream.Write(0); - m_Stream.Write((short)0); - m_Stream.Write((byte)0); + Stream.Write((short)0); + Stream.Write((byte)0); - m_Stream.Write(players.IsPublic(i)); + Stream.Write(players.IsPublic(i)); - m_Stream.WriteAsciiFixed(mobile.Name, 30); - m_Stream.Write(!players.IsInGamePlayer(i)); + Stream.WriteAsciiFixed(mobile.Name, 30); + Stream.Write(!players.IsInGamePlayer(i)); n++; } else if (game.ShowScores) { - m_Stream.Write(0); - m_Stream.Write((byte)0x2); - m_Stream.Write((byte)i); + Stream.Write(0); + Stream.Write((byte)0x2); + Stream.Write((byte)i); - m_Stream.Write(players.GetScore(i)); + Stream.Write(players.GetScore(i)); - m_Stream.Write((short)0); - m_Stream.Write((byte)0); + Stream.Write((short)0); + Stream.Write((byte)0); - m_Stream.Write(players.IsPublic(i)); + Stream.Write(players.IsPublic(i)); - m_Stream.WriteAsciiFixed("", 30); - m_Stream.Write(true); + Stream.WriteAsciiFixed("", 30); + Stream.Write(true); n++; } @@ -78,8 +78,8 @@ namespace Server.Engines.Mahjong if (n != players.Seats) { - m_Stream.Seek(10, SeekOrigin.Begin); - m_Stream.Write((byte)n); + Stream.Seek(10, SeekOrigin.Begin); + Stream.Write((byte)n); } } } @@ -90,25 +90,25 @@ namespace Server.Engines.Mahjong { EnsureCapacity(13); - m_Stream.Write(game.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0x5); + Stream.Write(game.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0x5); - m_Stream.Write((short)0); - m_Stream.Write((byte)0); + Stream.Write((short)0); + Stream.Write((byte)0); - m_Stream.Write((byte)((game.ShowScores ? 0x1 : 0x0) | (game.SpectatorVision ? 0x2 : 0x0))); + Stream.Write((byte)((game.ShowScores ? 0x1 : 0x0) | (game.SpectatorVision ? 0x2 : 0x0))); - m_Stream.Write((byte)game.Dices.First); - m_Stream.Write((byte)game.Dices.Second); + Stream.Write((byte)game.Dices.First); + Stream.Write((byte)game.Dices.Second); - m_Stream.Write((byte)game.DealerIndicator.Wind); - m_Stream.Write((short)game.DealerIndicator.Position.Y); - m_Stream.Write((short)game.DealerIndicator.Position.X); - m_Stream.Write((byte)game.DealerIndicator.Direction); + Stream.Write((byte)game.DealerIndicator.Wind); + Stream.Write((short)game.DealerIndicator.Position.Y); + Stream.Write((short)game.DealerIndicator.Position.X); + Stream.Write((byte)game.DealerIndicator.Direction); - m_Stream.Write((short)game.WallBreakIndicator.Position.Y); - m_Stream.Write((short)game.WallBreakIndicator.Position.X); + Stream.Write((short)game.WallBreakIndicator.Position.Y); + Stream.Write((short)game.WallBreakIndicator.Position.X); } } @@ -121,37 +121,37 @@ namespace Server.Engines.Mahjong EnsureCapacity(11 + 9 * tiles.Length); - m_Stream.Write(game.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0x4); + Stream.Write(game.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0x4); - m_Stream.Write((short)tiles.Length); + Stream.Write((short)tiles.Length); foreach (MahjongTile tile in tiles) { - m_Stream.Write((byte)tile.Number); + Stream.Write((byte)tile.Number); if (tile.Flipped) { int hand = tile.Dimensions.GetHandArea(); if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to || - game.SpectatorVision && players.IsSpectator(to)) - m_Stream.Write((byte)tile.Value); + (game.SpectatorVision && players.IsSpectator(to))) + Stream.Write((byte)tile.Value); else - m_Stream.Write((byte)0); + Stream.Write((byte)0); } else { - m_Stream.Write((byte)0); + Stream.Write((byte)0); } - m_Stream.Write((short)tile.Position.Y); - m_Stream.Write((short)tile.Position.X); - m_Stream.Write((byte)tile.StackLevel); - m_Stream.Write((byte)tile.Direction); + Stream.Write((short)tile.Position.Y); + Stream.Write((short)tile.Position.X); + Stream.Write((byte)tile.StackLevel); + Stream.Write((byte)tile.Direction); - m_Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0); + Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0); } } } @@ -165,33 +165,33 @@ namespace Server.Engines.Mahjong EnsureCapacity(18); - m_Stream.Write(tile.Game.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0x3); + Stream.Write(tile.Game.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0x3); - m_Stream.Write((byte)tile.Number); + Stream.Write((byte)tile.Number); if (tile.Flipped) { int hand = tile.Dimensions.GetHandArea(); if (hand < 0 || players.IsPublic(hand) || players.GetPlayer(hand) == to || - game.SpectatorVision && players.IsSpectator(to)) - m_Stream.Write((byte)tile.Value); + (game.SpectatorVision && players.IsSpectator(to))) + Stream.Write((byte)tile.Value); else - m_Stream.Write((byte)0); + Stream.Write((byte)0); } else { - m_Stream.Write((byte)0); + Stream.Write((byte)0); } - m_Stream.Write((short)tile.Position.Y); - m_Stream.Write((short)tile.Position.X); - m_Stream.Write((byte)tile.StackLevel); - m_Stream.Write((byte)tile.Direction); + Stream.Write((short)tile.Position.Y); + Stream.Write((short)tile.Position.X); + Stream.Write((byte)tile.StackLevel); + Stream.Write((byte)tile.Direction); - m_Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0); + Stream.Write(tile.Flipped ? (byte)0x10 : (byte)0x0); } } @@ -201,9 +201,9 @@ namespace Server.Engines.Mahjong { EnsureCapacity(9); - m_Stream.Write(game.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0x1A); + Stream.Write(game.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0x1A); } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Gems/Amber.cs b/Projects/Scripts/Items/Gems/Amber.cs index 77c736041..60bac43f8 100644 --- a/Projects/Scripts/Items/Gems/Amber.cs +++ b/Projects/Scripts/Items/Gems/Amber.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/Amethyst.cs b/Projects/Scripts/Items/Gems/Amethyst.cs index 5d40210b8..7bd8c130a 100644 --- a/Projects/Scripts/Items/Gems/Amethyst.cs +++ b/Projects/Scripts/Items/Gems/Amethyst.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/Citrine.cs b/Projects/Scripts/Items/Gems/Citrine.cs index 9eb2c3820..8be77e70b 100644 --- a/Projects/Scripts/Items/Gems/Citrine.cs +++ b/Projects/Scripts/Items/Gems/Citrine.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/Diamond.cs b/Projects/Scripts/Items/Gems/Diamond.cs index 253ca397e..be818dd37 100644 --- a/Projects/Scripts/Items/Gems/Diamond.cs +++ b/Projects/Scripts/Items/Gems/Diamond.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/Emerald.cs b/Projects/Scripts/Items/Gems/Emerald.cs index 58c0c0db7..622f017b9 100644 --- a/Projects/Scripts/Items/Gems/Emerald.cs +++ b/Projects/Scripts/Items/Gems/Emerald.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/Ruby.cs b/Projects/Scripts/Items/Gems/Ruby.cs index d3d9ccd32..c933199a3 100644 --- a/Projects/Scripts/Items/Gems/Ruby.cs +++ b/Projects/Scripts/Items/Gems/Ruby.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/Sapphire.cs b/Projects/Scripts/Items/Gems/Sapphire.cs index 2b4658713..cfa3388fd 100644 --- a/Projects/Scripts/Items/Gems/Sapphire.cs +++ b/Projects/Scripts/Items/Gems/Sapphire.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/StarSapphire.cs b/Projects/Scripts/Items/Gems/StarSapphire.cs index 75a108fc2..3ca0ab5bd 100644 --- a/Projects/Scripts/Items/Gems/StarSapphire.cs +++ b/Projects/Scripts/Items/Gems/StarSapphire.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Gems/Tourmaline.cs b/Projects/Scripts/Items/Gems/Tourmaline.cs index cc6330506..4d25610fc 100644 --- a/Projects/Scripts/Items/Gems/Tourmaline.cs +++ b/Projects/Scripts/Items/Gems/Tourmaline.cs @@ -15,7 +15,6 @@ namespace Server.Items public override double DefaultWeight => 0.1; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Guilds/GuildDeed.cs b/Projects/Scripts/Items/Guilds/GuildDeed.cs index c80c13b01..c904eb0bd 100644 --- a/Projects/Scripts/Items/Guilds/GuildDeed.cs +++ b/Projects/Scripts/Items/Guilds/GuildDeed.cs @@ -55,7 +55,7 @@ namespace Server.Items } else if (house.FindGuildstone() != null) { - from.SendLocalizedMessage(501142); //Only one guildstone may reside in a given house. + from.SendLocalizedMessage(501142); // Only one guildstone may reside in a given house. } else if (!house.IsOwner(from)) { @@ -71,7 +71,7 @@ namespace Server.Items private class InternalPrompt : Prompt { - private GuildDeed m_Deed; + private readonly GuildDeed m_Deed; public InternalPrompt(GuildDeed deed) => m_Deed = deed; @@ -98,7 +98,7 @@ namespace Server.Items } else if (house.FindGuildstone() != null) { - from.SendLocalizedMessage(501142); //Only one guildstone may reside in a given house. + from.SendLocalizedMessage(501142); // Only one guildstone may reside in a given house. } else if (!house.IsOwner(from)) { diff --git a/Projects/Scripts/Items/Guilds/GuildTeleporter.cs b/Projects/Scripts/Items/Guilds/GuildTeleporter.cs index ccc189135..bc6fc028c 100644 --- a/Projects/Scripts/Items/Guilds/GuildTeleporter.cs +++ b/Projects/Scripts/Items/Guilds/GuildTeleporter.cs @@ -43,11 +43,11 @@ namespace Server.Items switch (version) { case 0: - { - m_Stone = reader.ReadItem(); + { + m_Stone = reader.ReadItem(); - break; - } + break; + } } if (Weight == 0.0) @@ -83,7 +83,7 @@ namespace Server.Items } else if (house.FindGuildstone() != null) { - from.SendLocalizedMessage(501142); //Only one guildstone may reside in a given house. + from.SendLocalizedMessage(501142); // Only one guildstone may reside in a given house. } else { diff --git a/Projects/Scripts/Items/Guilds/Guildstone.cs b/Projects/Scripts/Items/Guilds/Guildstone.cs index 49d8c35be..2feb980de 100644 --- a/Projects/Scripts/Items/Guilds/Guildstone.cs +++ b/Projects/Scripts/Items/Guilds/Guildstone.cs @@ -8,7 +8,7 @@ using Server.Targeting; namespace Server.Items { - public class Guildstone : Item, IAddon, IChopable + public class Guildstone : Item, IAddon, IChoppable { private bool m_BeforeChangeover; private string m_GuildAbbrev; @@ -54,12 +54,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Guild Guild{ get; private set; } + public Guild Guild { get; private set; } public override int LabelNumber => 1041429; // a guildstone - #region IChopable Members - public void OnChop(Mobile from) { if (!Guild.NewGuildSystem) @@ -69,7 +67,7 @@ namespace Server.Items bool contains = false; - if (house == null && m_BeforeChangeover || house?.IsOwner(from) == true && (contains = house.Addons.Contains(this))) + if ((house == null && m_BeforeChangeover) || (house?.IsOwner(from) == true && (contains = house.Addons.Contains(this)))) { Effects.PlaySound(GetWorldLocation(), Map, 0x3B3); from.SendLocalizedMessage(500461); // You destroy the item. @@ -86,8 +84,6 @@ namespace Server.Items } } - #endregion - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); @@ -117,27 +113,27 @@ namespace Server.Items switch (version) { case 3: - { - m_BeforeChangeover = reader.ReadBool(); - goto case 2; - } + { + m_BeforeChangeover = reader.ReadBool(); + goto case 2; + } case 2: - { - m_GuildName = reader.ReadString(); - m_GuildAbbrev = reader.ReadString(); + { + m_GuildName = reader.ReadString(); + m_GuildAbbrev = reader.ReadString(); - goto case 1; - } + goto case 1; + } case 1: - { - Guild = reader.ReadGuild() as Guild; + { + Guild = reader.ReadGuild() as Guild; - goto case 0; - } + goto case 0; + } case 0: - { - break; - } + { + break; + } } if (Guild.NewGuildSystem && ItemID == 0xED4) @@ -179,7 +175,7 @@ namespace Server.Items if ((abbr = Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0) abbr = ""; - //list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~ + // list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~ list.Add(1060802, $"{Utility.FixHtml(name)} [{Utility.FixHtml(abbr)}]"); } else if (m_GuildName != null && m_GuildAbbrev != null) @@ -228,8 +224,6 @@ namespace Server.Items } else if (Guild.Accepted.Contains(from)) { - #region Factions - PlayerState guildState = PlayerState.Find(Guild.Leader); PlayerState targetState = PlayerState.Find(from); @@ -242,8 +236,6 @@ namespace Server.Items if (guildState != null && targetState != null) targetState.Leaving = guildState.Leaving; - #endregion - Guild.Accepted.Remove(from); Guild.AddMember(from); @@ -262,13 +254,9 @@ namespace Server.Items } } - #region IAddon Members - public Item Deed => new GuildstoneDeed(Guild, m_GuildName, m_GuildAbbrev); public bool CouldFit(IPoint3D p, Map map) => map.CanFit(p.X, p.Y, p.Z, ItemData.Height); - - #endregion } [Flippable(0x14F0, 0x14EF)] @@ -279,8 +267,7 @@ namespace Server.Items private string m_GuildName; [Constructible] - public GuildstoneDeed(Guild g = null, string guildName = null, string abbrev = null) : - base(0x14F0) + public GuildstoneDeed(Guild g = null, string guildName = null, string abbrev = null) : base(0x14F0) { Guild = g; m_GuildName = guildName; @@ -318,7 +305,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Guild Guild{ get; private set; } + public Guild Guild { get; private set; } public override void Serialize(IGenericWriter writer) { @@ -347,14 +334,14 @@ namespace Server.Items switch (version) { case 1: - { - m_GuildName = reader.ReadString(); - m_GuildAbbrev = reader.ReadString(); + { + m_GuildName = reader.ReadString(); + m_GuildAbbrev = reader.ReadString(); - Guild = reader.ReadGuild() as Guild; + Guild = reader.ReadGuild() as Guild; - break; - } + break; + } } } @@ -373,7 +360,7 @@ namespace Server.Items if ((abbr = Guild.Abbreviation) == null || (abbr = abbr.Trim()).Length <= 0) abbr = ""; - //list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~ + // list.Add( 1060802, Utility.FixHtml( name ) ); // Guild name: ~1_val~ list.Add(1060802, $"{Utility.FixHtml(name)} [{Utility.FixHtml(abbr)}]"); } else if (m_GuildName != null && m_GuildAbbrev != null) diff --git a/Projects/Scripts/Items/Jewels/BaseJewel.cs b/Projects/Scripts/Items/Jewels/BaseJewel.cs index d21de181c..55836dfd6 100644 --- a/Projects/Scripts/Items/Jewels/BaseJewel.cs +++ b/Projects/Scripts/Items/Jewels/BaseJewel.cs @@ -73,13 +73,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.Player)] - public AosAttributes Attributes{ get; private set; } + public AosAttributes Attributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosElementAttributes Resistances{ get; private set; } + public AosElementAttributes Resistances { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosSkillBonuses SkillBonuses{ get; private set; } + public AosSkillBonuses SkillBonuses { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource @@ -126,8 +126,6 @@ namespace Server.Items public virtual int ArtifactRarity => 0; - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -140,7 +138,7 @@ namespace Server.Items if (context?.DoNotColor == true) Hue = 0; - if (1 < craftItem.Resources.Count) + if (craftItem.Resources.Count > 1) { resourceType = craftItem.Resources.GetAt(1).ItemType; @@ -167,8 +165,6 @@ namespace Server.Items return 1; } - #endregion - public override void OnAfterDuped(Item newItem) { if (!(newItem is BaseJewel jewel)) @@ -306,7 +302,7 @@ namespace Server.Items if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) list.Add(1075210, prop.ToString()); // Increased Karma Loss ~1val~% - base.AddResistanceProperties(list); + this.AddResistanceProperties(list); if (m_HitPoints >= 0 && m_MaxHitPoints > 0) list.Add(1060639, "{0}\t{1}", m_HitPoints, m_MaxHitPoints); // durability ~1_val~ / ~2_val~ @@ -338,60 +334,60 @@ namespace Server.Items switch (version) { case 3: - { - m_MaxHitPoints = reader.ReadEncodedInt(); - m_HitPoints = reader.ReadEncodedInt(); - - goto case 2; - } - case 2: - { - m_Resource = (CraftResource)reader.ReadEncodedInt(); - m_GemType = (GemType)reader.ReadEncodedInt(); - - goto case 1; - } - case 1: - { - Attributes = new AosAttributes(this, reader); - Resistances = new AosElementAttributes(this, reader); - SkillBonuses = new AosSkillBonuses(this, reader); - - Mobile m = Parent as Mobile; - - if (Core.AOS && m != null) - SkillBonuses.AddTo(m); - - int strBonus = Attributes.BonusStr; - int dexBonus = Attributes.BonusDex; - int intBonus = Attributes.BonusInt; - - if (m != null && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) { - string modName = Serial.ToString(); + m_MaxHitPoints = reader.ReadEncodedInt(); + m_HitPoints = reader.ReadEncodedInt(); - if (strBonus != 0) - m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); - - if (dexBonus != 0) - m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); - - if (intBonus != 0) - m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + goto case 2; } + case 2: + { + m_Resource = (CraftResource)reader.ReadEncodedInt(); + m_GemType = (GemType)reader.ReadEncodedInt(); - m?.CheckStatTimers(); + goto case 1; + } + case 1: + { + Attributes = new AosAttributes(this, reader); + Resistances = new AosElementAttributes(this, reader); + SkillBonuses = new AosSkillBonuses(this, reader); - break; - } + Mobile m = Parent as Mobile; + + if (Core.AOS && m != null) + SkillBonuses.AddTo(m); + + int strBonus = Attributes.BonusStr; + int dexBonus = Attributes.BonusDex; + int intBonus = Attributes.BonusInt; + + if (m != null && (strBonus != 0 || dexBonus != 0 || intBonus != 0)) + { + string modName = Serial.ToString(); + + if (strBonus != 0) + m.AddStatMod(new StatMod(StatType.Str, $"{modName}Str", strBonus, TimeSpan.Zero)); + + if (dexBonus != 0) + m.AddStatMod(new StatMod(StatType.Dex, $"{modName}Dex", dexBonus, TimeSpan.Zero)); + + if (intBonus != 0) + m.AddStatMod(new StatMod(StatType.Int, $"{modName}Int", intBonus, TimeSpan.Zero)); + } + + m?.CheckStatTimers(); + + break; + } case 0: - { - Attributes = new AosAttributes(this); - Resistances = new AosElementAttributes(this); - SkillBonuses = new AosSkillBonuses(this); + { + Attributes = new AosAttributes(this); + Resistances = new AosElementAttributes(this); + SkillBonuses = new AosSkillBonuses(this); - break; - } + break; + } } if (version < 2) diff --git a/Projects/Scripts/Items/Jewels/Necklace.cs b/Projects/Scripts/Items/Jewels/Necklace.cs index 67a1d2629..93ab4f3ae 100644 --- a/Projects/Scripts/Items/Jewels/Necklace.cs +++ b/Projects/Scripts/Items/Jewels/Necklace.cs @@ -99,7 +99,6 @@ namespace Server.Items } } - public class SilverNecklace : BaseNecklace { [Constructible] diff --git a/Projects/Scripts/Items/Lights/BaseLight.cs b/Projects/Scripts/Items/Lights/BaseLight.cs index 31c5d818b..895d5f6dd 100644 --- a/Projects/Scripts/Items/Lights/BaseLight.cs +++ b/Projects/Scripts/Items/Lights/BaseLight.cs @@ -19,7 +19,7 @@ namespace Server.Items { } - public abstract int LitItemID{ get; } + public abstract int LitItemID { get; } public virtual int UnlitItemID => 0; public virtual int BurntOutItemID => 0; @@ -43,10 +43,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool BurntOut{ get; set; } + public bool BurntOut { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool Protected{ get; set; } + public bool Protected { get; set; } [CommandProperty(AccessLevel.GameMaster)] public TimeSpan Duration @@ -77,7 +77,6 @@ namespace Server.Items if (BurntOut && BurntOutSound != 0) sound = BurntOutSound; - if (sound != 0) { Point3D loc = GetWorldLocation(); @@ -182,23 +181,23 @@ namespace Server.Items switch (version) { case 0: - { - BurntOut = reader.ReadBool(); - m_Burning = reader.ReadBool(); - m_Duration = reader.ReadTimeSpan(); - Protected = reader.ReadBool(); + { + BurntOut = reader.ReadBool(); + m_Burning = reader.ReadBool(); + m_Duration = reader.ReadTimeSpan(); + Protected = reader.ReadBool(); - if (m_Burning && m_Duration != TimeSpan.Zero) - DoTimer(reader.ReadDeltaTime() - DateTime.UtcNow); + if (m_Burning && m_Duration != TimeSpan.Zero) + DoTimer(reader.ReadDeltaTime() - DateTime.UtcNow); - break; - } + break; + } } } private class InternalTimer : Timer { - private BaseLight m_Light; + private readonly BaseLight m_Light; public InternalTimer(BaseLight light, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Items/Lights/Candelabra.cs b/Projects/Scripts/Items/Lights/Candelabra.cs index 774f6c7d5..645fd66db 100644 --- a/Projects/Scripts/Items/Lights/Candelabra.cs +++ b/Projects/Scripts/Items/Lights/Candelabra.cs @@ -20,12 +20,8 @@ namespace Server.Items public override int LitItemID => 0xB1D; public override int UnlitItemID => 0xA27; - #region IShipwreckedItem Members - [CommandProperty(AccessLevel.GameMaster)] - public bool IsShipwreckedItem{ get; set; } - - #endregion + public bool IsShipwreckedItem { get; set; } public override void Serialize(IGenericWriter writer) { @@ -43,10 +39,10 @@ namespace Server.Items switch (version) { case 1: - { - IsShipwreckedItem = reader.ReadBool(); - break; - } + { + IsShipwreckedItem = reader.ReadBool(); + break; + } } } @@ -63,7 +59,7 @@ namespace Server.Items base.OnSingleClick(from); if (IsShipwreckedItem) - LabelTo(from, 1041645); //recovered from a shipwreck + LabelTo(from, 1041645); // recovered from a shipwreck } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Maps/MapItem.cs b/Projects/Scripts/Items/Maps/MapItem.cs index 7e8262c42..84f3d177a 100644 --- a/Projects/Scripts/Items/Maps/MapItem.cs +++ b/Projects/Scripts/Items/Maps/MapItem.cs @@ -25,20 +25,18 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool Protected{ get; set; } + public bool Protected { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Rectangle2D Bounds{ get; set; } + public Rectangle2D Bounds { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Width{ get; set; } + public int Width { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Height{ get; set; } + public int Height { get; set; } - public List Pins{ get; } = new List(); - - #region ICraftable Members + public List Pins { get; } = new List(); public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) @@ -47,8 +45,6 @@ namespace Server.Items return 1; } - #endregion - public virtual void CraftInit(Mobile from) { } @@ -249,20 +245,20 @@ namespace Server.Items switch (version) { case 0: - { - Bounds = reader.ReadRect2D(); + { + Bounds = reader.ReadRect2D(); - Width = reader.ReadInt(); - Height = reader.ReadInt(); + Width = reader.ReadInt(); + Height = reader.ReadInt(); - Protected = reader.ReadBool(); + Protected = reader.ReadBool(); - int count = reader.ReadInt(); - for (int i = 0; i < count; i++) - Pins.Add(reader.ReadPoint2D()); + int count = reader.ReadInt(); + for (int i = 0; i < count; i++) + Pins.Add(reader.ReadPoint2D()); - break; - } + break; + } } } @@ -311,14 +307,14 @@ namespace Server.Items { public MapDetails(MapItem map) : base(0x90, 19) { - m_Stream.Write(map.Serial); - m_Stream.Write((short)0x139D); - m_Stream.Write((short)map.Bounds.Start.X); - m_Stream.Write((short)map.Bounds.Start.Y); - m_Stream.Write((short)map.Bounds.End.X); - m_Stream.Write((short)map.Bounds.End.Y); - m_Stream.Write((short)map.Width); - m_Stream.Write((short)map.Height); + Stream.Write(map.Serial); + Stream.Write((short)0x139D); + Stream.Write((short)map.Bounds.Start.X); + Stream.Write((short)map.Bounds.Start.Y); + Stream.Write((short)map.Bounds.End.X); + Stream.Write((short)map.Bounds.End.Y); + Stream.Write((short)map.Width); + Stream.Write((short)map.Height); } } @@ -344,11 +340,11 @@ namespace Server.Items { public MapCommand(MapItem map, int command, int number, int x, int y) : base(0x56, 11) { - m_Stream.Write(map.Serial); - m_Stream.Write((byte)command); - m_Stream.Write((byte)number); - m_Stream.Write((short)x); - m_Stream.Write((short)y); + Stream.Write(map.Serial); + Stream.Write((byte)command); + Stream.Write((byte)number); + Stream.Write((short)x); + Stream.Write((short)y); } } diff --git a/Projects/Scripts/Items/Maps/PresetMap.cs b/Projects/Scripts/Items/Maps/PresetMap.cs index 769c70acb..23dccbb54 100644 --- a/Projects/Scripts/Items/Maps/PresetMap.cs +++ b/Projects/Scripts/Items/Maps/PresetMap.cs @@ -52,10 +52,10 @@ namespace Server.Items switch (version) { case 0: - { - m_LabelNumber = reader.ReadInt(); - break; - } + { + m_LabelNumber = reader.ReadInt(); + break; + } } } } @@ -70,15 +70,15 @@ namespace Server.Items Bounds = new Rectangle2D(xLeft, yTop, xRight - xLeft, yBottom - yTop); } - public int Name{ get; } + public int Name { get; } - public int Width{ get; } + public int Width { get; } - public int Height{ get; } + public int Height { get; } - public Rectangle2D Bounds{ get; } + public Rectangle2D Bounds { get; } - public static PresetMapEntry[] Table{ get; } = + public static PresetMapEntry[] Table { get; } = { new PresetMapEntry(1041189, 200, 200, 1092, 1396, 1736, 1924), // map of Britain new PresetMapEntry(1041203, 200, 200, 0256, 1792, 1736, 2560), // map of Britain to Skara Brae diff --git a/Projects/Scripts/Items/Maps/TreasureMap.cs b/Projects/Scripts/Items/Maps/TreasureMap.cs index 66c2b9540..845626361 100644 --- a/Projects/Scripts/Items/Maps/TreasureMap.cs +++ b/Projects/Scripts/Items/Maps/TreasureMap.cs @@ -18,7 +18,7 @@ namespace Server.Items private static Point2D[] m_Locations; private static Point2D[] m_HavenLocations; - private static Type[][] m_SpawnTypes = + private static readonly Type[][] m_SpawnTypes = { new[] { typeof(HeadlessOne), typeof(Skeleton) }, new[] { typeof(Mongbat), typeof(Ratman), typeof(HeadlessOne), typeof(Skeleton), typeof(Zombie) }, @@ -139,7 +139,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Point2D ChestLocation{ get; set; } + public Point2D ChestLocation { get; set; } public override int LabelNumber { @@ -312,7 +312,7 @@ namespace Server.Items from.SendLocalizedMessage(1046447); // Only a young player may use this treasure map. } /* - else if ( from != m_Decoder ) + else if (from != m_Decoder) { from.SendLocalizedMessage( 503016 ); // Only the person who decoded this map may actually dig up the treasure. } @@ -528,24 +528,24 @@ namespace Server.Items switch (version) { case 1: - { - m_CompletedBy = reader.ReadMobile(); + { + m_CompletedBy = reader.ReadMobile(); - goto case 0; - } + goto case 0; + } case 0: - { - m_Level = reader.ReadInt(); - m_Completed = reader.ReadBool(); - m_Decoder = reader.ReadMobile(); - m_Map = reader.ReadMap(); - ChestLocation = reader.ReadPoint2D(); + { + m_Level = reader.ReadInt(); + m_Completed = reader.ReadBool(); + m_Decoder = reader.ReadMobile(); + m_Map = reader.ReadMap(); + ChestLocation = reader.ReadPoint2D(); - if (version == 0 && m_Completed) - m_CompletedBy = m_Decoder; + if (version == 0 && m_Completed) + m_CompletedBy = m_Decoder; - break; - } + break; + } } if (Core.AOS && m_Decoder != null && LootType == LootType.Regular) @@ -554,7 +554,7 @@ namespace Server.Items private class DigTarget : Target { - private TreasureMap m_Map; + private readonly TreasureMap m_Map; public DigTarget(TreasureMap map) : base(6, true, TargetFlags.None) => m_Map = map; @@ -570,7 +570,7 @@ namespace Server.Items from.SendLocalizedMessage(503028); // The treasure for this map has already been found. } /* - else if ( from != m_Map.m_Decoder ) + else if (from != m_Map.m_Decoder) { from.SendLocalizedMessage( 503016 ); // Only the person who decoded this map may actually dig up the treasure. } @@ -679,16 +679,16 @@ namespace Server.Items private TreasureChestDirt m_Dirt1; private TreasureChestDirt m_Dirt2; - private Mobile m_From; - private long m_LastMoveTime; + private readonly Mobile m_From; + private readonly long m_LastMoveTime; private Point3D m_Location; - private Map m_Map; - private long m_NextActionTime; + private readonly Map m_Map; + private readonly long m_NextActionTime; - private long m_NextSkillTime; - private long m_NextSpellTime; - private TreasureMap m_TreasureMap; + private readonly long m_NextSkillTime; + private readonly long m_NextSpellTime; + private readonly TreasureMap m_TreasureMap; public DigTimer(Mobile from, TreasureMap treasureMap, Point3D location, Map map) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) @@ -827,8 +827,8 @@ namespace Server.Items private class SoundTimer : Timer { - private Mobile m_From; - private int m_SoundID; + private readonly Mobile m_From; + private readonly int m_SoundID; public SoundTimer(Mobile from, int soundID) : base(TimeSpan.FromSeconds(0.9)) { @@ -847,7 +847,7 @@ namespace Server.Items private class DecodeMapEntry : ContextMenuEntry { - private TreasureMap m_Map; + private readonly TreasureMap m_Map; public DecodeMapEntry(TreasureMap map) : base(6147, 2) => m_Map = map; @@ -860,7 +860,7 @@ namespace Server.Items private class OpenMapEntry : ContextMenuEntry { - private TreasureMap m_Map; + private readonly TreasureMap m_Map; public OpenMapEntry(TreasureMap map) : base(6150, 2) => m_Map = map; @@ -873,7 +873,7 @@ namespace Server.Items private class DigEntry : ContextMenuEntry { - private TreasureMap m_Map; + private readonly TreasureMap m_Map; public DigEntry(TreasureMap map, bool enabled) : base(6148, 2) { diff --git a/Projects/Scripts/Items/Minor Artifacts/IolosLute.cs b/Projects/Scripts/Items/Minor Artifacts/IolosLute.cs index e8ccc4a19..f2789a8ed 100644 --- a/Projects/Scripts/Items/Minor Artifacts/IolosLute.cs +++ b/Projects/Scripts/Items/Minor Artifacts/IolosLute.cs @@ -7,7 +7,7 @@ namespace Server.Items { Hue = 0x47E; Slayer = SlayerName.Silver; - //Slayer2 = SlayerName.DaemonDismissal; + // Slayer2 = SlayerName.DaemonDismissal; Slayer2 = SlayerName.Exorcism; } diff --git a/Projects/Scripts/Items/Misc/AcidSlime.cs b/Projects/Scripts/Items/Misc/AcidSlime.cs index f25cd53eb..158c8ada3 100644 --- a/Projects/Scripts/Items/Misc/AcidSlime.cs +++ b/Projects/Scripts/Items/Misc/AcidSlime.cs @@ -6,12 +6,12 @@ namespace Server.Items { public class AcidSlime : Item { - private DateTime m_Created; + private readonly DateTime m_Created; private bool m_Drying; - private TimeSpan m_Duration; - private int m_MaxDamage; - private int m_MinDamage; - private Timer m_Timer; + private readonly TimeSpan m_Duration; + private readonly int m_MaxDamage; + private readonly int m_MinDamage; + private readonly Timer m_Timer; [Constructible] public AcidSlime() : this(TimeSpan.FromSeconds(10.0), 5, 10) diff --git a/Projects/Scripts/Items/Misc/BankCheck.cs b/Projects/Scripts/Items/Misc/BankCheck.cs index 1ea2d595f..e57040b9b 100644 --- a/Projects/Scripts/Items/Misc/BankCheck.cs +++ b/Projects/Scripts/Items/Misc/BankCheck.cs @@ -62,10 +62,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Worth = reader.ReadInt(); - break; - } + { + m_Worth = reader.ReadInt(); + break; + } } } diff --git a/Projects/Scripts/Items/Misc/Beeswax.cs b/Projects/Scripts/Items/Misc/Beeswax.cs index 3cb14d464..4b9a7411a 100644 --- a/Projects/Scripts/Items/Misc/Beeswax.cs +++ b/Projects/Scripts/Items/Misc/Beeswax.cs @@ -14,7 +14,6 @@ namespace Server.Items { } - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs b/Projects/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs index da9e24d79..0266a9682 100644 --- a/Projects/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs +++ b/Projects/Scripts/Items/Misc/Blighted Grove/MelisandesHairDye.cs @@ -49,7 +49,7 @@ namespace Server.Items private class ConfirmGump : BaseConfirmGump { - private Item m_Item; + private readonly Item m_Item; public ConfirmGump(Item item) => m_Item = item; diff --git a/Projects/Scripts/Items/Misc/Blocker.cs b/Projects/Scripts/Items/Misc/Blocker.cs index 543819e5d..a1b07b0d3 100644 --- a/Projects/Scripts/Items/Misc/Blocker.cs +++ b/Projects/Scripts/Items/Misc/Blocker.cs @@ -63,18 +63,18 @@ namespace Server.Items else serial &= 0x7FFFFFFF; - m_Stream.Write(serial); - m_Stream.Write((short)(itemID & 0x7FFF)); + Stream.Write(serial); + Stream.Write((short)(itemID & 0x7FFF)); if (amount != 0) - m_Stream.Write((short)amount); + Stream.Write((short)amount); x &= 0x7FFF; if (direction != 0) x |= 0x8000; - m_Stream.Write((short)x); + Stream.Write((short)x); y &= 0x3FFF; @@ -84,18 +84,18 @@ namespace Server.Items if (flags != 0) y |= 0x4000; - m_Stream.Write((short)y); + Stream.Write((short)y); if (direction != 0) - m_Stream.Write((byte)direction); + Stream.Write((byte)direction); - m_Stream.Write((sbyte)loc.Z); + Stream.Write((sbyte)loc.Z); if (hue != 0) - m_Stream.Write((ushort)hue); + Stream.Write((ushort)hue); if (flags != 0) - m_Stream.Write((byte)flags); + Stream.Write((byte)flags); } } } diff --git a/Projects/Scripts/Items/Misc/Blood.cs b/Projects/Scripts/Items/Misc/Blood.cs index bf7edf598..cae0cb1c6 100644 --- a/Projects/Scripts/Items/Misc/Blood.cs +++ b/Projects/Scripts/Items/Misc/Blood.cs @@ -38,7 +38,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Item m_Blood; + private readonly Item m_Blood; public InternalTimer(Item blood) : base(TimeSpan.FromSeconds(5.0)) { diff --git a/Projects/Scripts/Items/Misc/Bola.cs b/Projects/Scripts/Items/Misc/Bola.cs index 26534d88a..1fda9073d 100644 --- a/Projects/Scripts/Items/Misc/Bola.cs +++ b/Projects/Scripts/Items/Misc/Bola.cs @@ -145,7 +145,7 @@ namespace Server.Items public class BolaTarget : Target { - private Bola m_Bola; + private readonly Bola m_Bola; public BolaTarget(Bola bola) : base(8, false, TargetFlags.Harmful) => m_Bola = bola; diff --git a/Projects/Scripts/Items/Misc/BulletinBoards.cs b/Projects/Scripts/Items/Misc/BulletinBoards.cs index 57129f671..a83adc79f 100644 --- a/Projects/Scripts/Items/Misc/BulletinBoards.cs +++ b/Projects/Scripts/Items/Misc/BulletinBoards.cs @@ -35,13 +35,13 @@ namespace Server.Items public abstract class BaseBulletinBoard : Item { // Threads will be removed six hours after the last post was made - private static TimeSpan ThreadDeletionTime = TimeSpan.FromHours(6.0); + private static readonly TimeSpan ThreadDeletionTime = TimeSpan.FromHours(6.0); // A player may only create a thread once every two minutes - private static TimeSpan ThreadCreateTime = TimeSpan.FromMinutes(2.0); + private static readonly TimeSpan ThreadCreateTime = TimeSpan.FromMinutes(2.0); // A player may only reply once every thirty seconds - private static TimeSpan ThreadReplyTime = TimeSpan.FromSeconds(30.0); + private static readonly TimeSpan ThreadReplyTime = TimeSpan.FromSeconds(30.0); public BaseBulletinBoard(int itemID) : base(itemID) { @@ -54,7 +54,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string BoardName{ get; set; } + public string BoardName { get; set; } public static bool CheckTime(DateTime time, TimeSpan range) => time + range < DateTime.UtcNow; @@ -192,10 +192,10 @@ namespace Server.Items switch (version) { case 0: - { - BoardName = reader.ReadString(); - break; - } + { + BoardName = reader.ReadString(); + break; + } } } @@ -344,25 +344,25 @@ namespace Server.Items { } - public Mobile Poster{ get; private set; } + public Mobile Poster { get; private set; } - public BulletinMessage Thread{ get; private set; } + public BulletinMessage Thread { get; private set; } - public string Subject{ get; private set; } + public string Subject { get; private set; } - public DateTime Time{ get; private set; } + public DateTime Time { get; private set; } - public DateTime LastPostTime{ get; set; } + public DateTime LastPostTime { get; set; } - public string PostedName{ get; private set; } + public string PostedName { get; private set; } - public int PostedBody{ get; private set; } + public int PostedBody { get; private set; } - public int PostedHue{ get; private set; } + public int PostedHue { get; private set; } - public BulletinEquip[] PostedEquip{ get; private set; } + public BulletinEquip[] PostedEquip { get; private set; } - public string[] Lines{ get; private set; } + public string[] Lines { get; private set; } public string GetTimeAsString() => Time.ToString("MMM dd, yyyy"); @@ -410,38 +410,38 @@ namespace Server.Items { case 1: case 0: - { - Poster = reader.ReadMobile(); - Subject = reader.ReadString(); - Time = reader.ReadDateTime(); - LastPostTime = reader.ReadDateTime(); - bool hasThread = reader.ReadBool(); - Thread = reader.ReadItem() as BulletinMessage; - PostedName = reader.ReadString(); - PostedBody = reader.ReadInt(); - PostedHue = reader.ReadInt(); - - PostedEquip = new BulletinEquip[reader.ReadInt()]; - - for (int i = 0; i < PostedEquip.Length; ++i) { - PostedEquip[i].itemID = reader.ReadInt(); - PostedEquip[i].hue = reader.ReadInt(); + Poster = reader.ReadMobile(); + Subject = reader.ReadString(); + Time = reader.ReadDateTime(); + LastPostTime = reader.ReadDateTime(); + bool hasThread = reader.ReadBool(); + Thread = reader.ReadItem() as BulletinMessage; + PostedName = reader.ReadString(); + PostedBody = reader.ReadInt(); + PostedHue = reader.ReadInt(); + + PostedEquip = new BulletinEquip[reader.ReadInt()]; + + for (int i = 0; i < PostedEquip.Length; ++i) + { + PostedEquip[i].itemID = reader.ReadInt(); + PostedEquip[i].hue = reader.ReadInt(); + } + + Lines = new string[reader.ReadInt()]; + + for (int i = 0; i < Lines.Length; ++i) + Lines[i] = reader.ReadString(); + + if (hasThread && Thread == null) + Delete(); + + if (version == 0) + ValidationQueue.Add(this); + + break; } - - Lines = new string[reader.ReadInt()]; - - for (int i = 0; i < Lines.Length; ++i) - Lines[i] = reader.ReadString(); - - if (hasThread && Thread == null) - Delete(); - - if (version == 0) - ValidationQueue.Add(this); - - break; - } } } @@ -460,19 +460,19 @@ namespace Server.Items byte[] buffer = Utility.UTF8.GetBytes(board.BoardName ?? ""); - m_Stream.Write((byte)0x00); // PacketID - m_Stream.Write(board.Serial); // Bulletin board serial + Stream.Write((byte)0x00); // PacketID + Stream.Write(board.Serial); // Bulletin board serial // Bulletin board name if (buffer.Length >= 29) { - m_Stream.Write(buffer, 0, 29); - m_Stream.Write((byte)0); + Stream.Write(buffer, 0, 29); + Stream.Write((byte)0); } else { - m_Stream.Write(buffer, 0, buffer.Length); - m_Stream.Fill(30 - buffer.Length); + Stream.Write(buffer, 0, buffer.Length); + Stream.Fill(30 - buffer.Length); } } } @@ -487,16 +487,16 @@ namespace Server.Items EnsureCapacity(22 + poster.Length + subject.Length + time.Length); - m_Stream.Write((byte)0x01); // PacketID - m_Stream.Write(board.Serial); // Bulletin board serial - m_Stream.Write(msg.Serial); // Message serial + Stream.Write((byte)0x01); // PacketID + Stream.Write(board.Serial); // Bulletin board serial + Stream.Write(msg.Serial); // Message serial BulletinMessage thread = msg.Thread; if (thread == null) - m_Stream.Write(0); // Thread serial--root + Stream.Write(0); // Thread serial--root else - m_Stream.Write(thread.Serial); // Thread serial--parent + Stream.Write(thread.Serial); // Thread serial--parent WriteString(poster); WriteString(subject); @@ -511,9 +511,9 @@ namespace Server.Items if (len > 255) len = 255; - m_Stream.Write((byte)len); - m_Stream.Write(buffer, 0, len - 1); - m_Stream.Write((byte)0); + Stream.Write((byte)len); + Stream.Write(buffer, 0, len - 1); + Stream.Write((byte)0); } public string SafeString(string v) => v ?? string.Empty; @@ -529,30 +529,30 @@ namespace Server.Items EnsureCapacity(22 + poster.Length + subject.Length + time.Length); - m_Stream.Write((byte)0x02); // PacketID - m_Stream.Write(board.Serial); // Bulletin board serial - m_Stream.Write(msg.Serial); // Message serial + Stream.Write((byte)0x02); // PacketID + Stream.Write(board.Serial); // Bulletin board serial + Stream.Write(msg.Serial); // Message serial WriteString(poster); WriteString(subject); WriteString(time); - m_Stream.Write((short)msg.PostedBody); - m_Stream.Write((short)msg.PostedHue); + Stream.Write((short)msg.PostedBody); + Stream.Write((short)msg.PostedHue); int len = msg.PostedEquip.Length; if (len > 255) len = 255; - m_Stream.Write((byte)len); + Stream.Write((byte)len); for (int i = 0; i < len; ++i) { BulletinEquip eq = msg.PostedEquip[i]; - m_Stream.Write((short)eq.itemID); - m_Stream.Write((short)eq.hue); + Stream.Write((short)eq.itemID); + Stream.Write((short)eq.hue); } len = msg.Lines.Length; @@ -560,7 +560,7 @@ namespace Server.Items if (len > 255) len = 255; - m_Stream.Write((byte)len); + Stream.Write((byte)len); for (int i = 0; i < len; ++i) WriteString(msg.Lines[i], true); @@ -580,13 +580,13 @@ namespace Server.Items if (len > 255) len = 255; - m_Stream.Write((byte)len); - m_Stream.Write(buffer, 0, len - tail); + Stream.Write((byte)len); + Stream.Write(buffer, 0, len - tail); if (padding) - m_Stream.Write((short)0); // padding compensates for a client bug + Stream.Write((short)0); // padding compensates for a client bug else - m_Stream.Write((byte)0); + Stream.Write((byte)0); } public string SafeString(string v) diff --git a/Projects/Scripts/Items/Misc/ClockworkAssembly.cs b/Projects/Scripts/Items/Misc/ClockworkAssembly.cs index 2c1c3c894..fba6d3c02 100644 --- a/Projects/Scripts/Items/Misc/ClockworkAssembly.cs +++ b/Projects/Scripts/Items/Misc/ClockworkAssembly.cs @@ -76,39 +76,39 @@ namespace Server.Items switch (res) { case 0: - { - from.SendMessage("You must have a power crystal to construct the golem."); - break; - } - case 1: - { - from.SendMessage("You must have 50 iron ingots to construct the golem."); - break; - } - case 2: - { - from.SendMessage("You must have 50 bronze ingots to construct the golem."); - break; - } - case 3: - { - from.SendMessage("You must have 5 gears to construct the golem."); - break; - } - default: - { - Golem g = new Golem(true, scalar); - - if (g.SetControlMaster(from)) { - Delete(); - - g.MoveToWorld(from.Location, from.Map); - from.PlaySound(0x241); + from.SendMessage("You must have a power crystal to construct the golem."); + break; } + case 1: + { + from.SendMessage("You must have 50 iron ingots to construct the golem."); + break; + } + case 2: + { + from.SendMessage("You must have 50 bronze ingots to construct the golem."); + break; + } + case 3: + { + from.SendMessage("You must have 5 gears to construct the golem."); + break; + } + default: + { + Golem g = new Golem(true, scalar); - break; - } + if (g.SetControlMaster(from)) + { + Delete(); + + g.MoveToWorld(from.Location, from.Map); + from.PlaySound(0x241); + } + + break; + } } } diff --git a/Projects/Scripts/Items/Misc/CommunicationCrystals.cs b/Projects/Scripts/Items/Misc/CommunicationCrystals.cs index 8b58ef8a3..e9abc8b90 100644 --- a/Projects/Scripts/Items/Misc/CommunicationCrystals.cs +++ b/Projects/Scripts/Items/Misc/CommunicationCrystals.cs @@ -25,9 +25,9 @@ namespace Server.Items Amount = amount; } - public Type Type{ get; } + public Type Type { get; } - public int Amount{ get; } + public int Amount { get; } public static CrystalRechargeInfo Get(Type type) { @@ -83,7 +83,7 @@ namespace Server.Items } } - public List Receivers{ get; private set; } + public List Receivers { get; private set; } public override bool HandlesOnSpeech => true; @@ -113,7 +113,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 Mobile))) return; if (e.Type == MessageType.Emote) @@ -172,7 +172,7 @@ namespace Server.Items private class InternalTarget : Target { - private BroadcastCrystal m_Crystal; + private readonly BroadcastCrystal m_Crystal; public InternalTarget(BroadcastCrystal crystal) : base(2, false, TargetFlags.None) => m_Crystal = crystal; @@ -380,7 +380,7 @@ namespace Server.Items private class InternalTarget : Target { - private ReceiverCrystal m_Crystal; + private readonly ReceiverCrystal m_Crystal; public InternalTarget(ReceiverCrystal crystal) : base(-1, false, TargetFlags.None) => m_Crystal = crystal; diff --git a/Projects/Scripts/Items/Misc/Corpses/Corpse.cs b/Projects/Scripts/Items/Misc/Corpses/Corpse.cs index 9c501617f..e22403f74 100644 --- a/Projects/Scripts/Items/Misc/Corpses/Corpse.cs +++ b/Projects/Scripts/Items/Misc/Corpses/Corpse.cs @@ -69,8 +69,8 @@ namespace Server.Items public static readonly TimeSpan InstancedCorpseTime = TimeSpan.FromMinutes(3.0); - private static TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(7.0); - private static TimeSpan m_BoneDecayTime = TimeSpan.FromMinutes(7.0); + private static readonly TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(7.0); + private static readonly TimeSpan m_BoneDecayTime = TimeSpan.FromMinutes(7.0); private string m_CorpseName; // Value of the CorpseNameAttribute attached to the owner when he died -or- null if the owner had no CorpseNameAttribute; use "the remains of ~name~" @@ -131,7 +131,7 @@ namespace Server.Items EquipItems = equipItems; Aggressors = new List(owner.Aggressors.Count + owner.Aggressed.Count); - //bool addToAggressors = !( owner is BaseCreature ); + // bool addToAggressors = !( owner is BaseCreature ); bool isBaseCreature = owner is BaseCreature; @@ -198,13 +198,13 @@ namespace Server.Items public override bool IsDecoContainer => false; [CommandProperty(AccessLevel.GameMaster)] - public DateTime TimeOfDeath{ get; set; } + public DateTime TimeOfDeath { get; set; } public override bool DisplayWeight => false; - public HairInfo Hair{ get; } + public HairInfo Hair { get; } - public FacialHairInfo FacialHair{ get; } + public FacialHairInfo FacialHair { get; } [CommandProperty(AccessLevel.GameMaster)] public bool IsBones => GetFlag(CorpseFlag.IsBones); @@ -248,23 +248,23 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public AccessLevel AccessLevel{ get; private set; } + public AccessLevel AccessLevel { get; private set; } - public List Aggressors{ get; private set; } + public List Aggressors { get; private set; } - public List Looters{ get; private set; } + public List Looters { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Killer{ get; private set; } + public Mobile Killer { get; private set; } - public List EquipItems{ get; private set; } + public List EquipItems { get; private set; } - public List RestoreEquip{ get; set; } + public List RestoreEquip { get; set; } - public Guild Guild{ get; } + public Guild Guild { get; } [CommandProperty(AccessLevel.GameMaster)] - public int Kills{ get; set; } + public int Kills { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Criminal @@ -274,7 +274,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; private set; } + public Mobile Owner { get; private set; } public override bool DisplaysContent => false; @@ -330,7 +330,7 @@ namespace Server.Items public override bool IsChildVisibleTo(Mobile m, Item child) => !m.Player || m.AccessLevel > AccessLevel.Player || m_InstancedItems == null || - !m_InstancedItems.TryGetValue(child, out InstancedItemInfo info) || !InstancedCorpse && !info.Perpetual + !m_InstancedItems.TryGetValue(child, out InstancedItemInfo info) || (!InstancedCorpse && !info.Perpetual) || info.IsOwner(m); private void AssignInstancedLoot() @@ -347,7 +347,7 @@ namespace Server.Items { Item item = Items[i]; - if (item.LootType != LootType.Cursed) //Don't have cursed items take up someone's item spot.. (?) + if (item.LootType != LootType.Cursed) // Don't have cursed items take up someone's item spot.. (?) { if (item.Stackable) m_Stackables.Add(item); @@ -358,7 +358,7 @@ namespace Server.Items List attackers = new List(Aggressors); - for (int i = 1; i < attackers.Count - 1; i++) //randomize + for (int i = 1; i < attackers.Count - 1; i++) // randomize { int rand = Utility.Random(i + 1); @@ -383,11 +383,11 @@ namespace Server.Items Item splitItem = Mobile.LiftItemDupe(item, item.Amount - - amountPerAttacker); //LiftItemDupe automagically adds it as a child item to the corpse + amountPerAttacker); // LiftItemDupe automagically adds it as a child item to the corpse m_InstancedItems.Add(splitItem, new InstancedItemInfo(splitItem, attackers[j])); - //What happens to the remaining portion? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item. + // What happens to the remaining portion? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item. } if (remainder == 0) @@ -397,7 +397,7 @@ namespace Server.Items } else { - //What happens in this case? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item. + // What happens in this case? TEMP FOR NOW UNTIL OSI VERIFICATION: Treat as Single Item. m_Unstackables.Add(item); } } @@ -579,144 +579,144 @@ namespace Server.Items switch (version) { case 12: - { - if (reader.ReadBool()) - RestoreEquip = reader.ReadStrongItemList(); + { + if (reader.ReadBool()) + RestoreEquip = reader.ReadStrongItemList(); - goto case 11; - } + goto case 11; + } case 11: - { - // Version 11, we move all bools to a CorpseFlag - m_Flags = (CorpseFlag)reader.ReadInt(); - - TimeOfDeath = reader.ReadDeltaTime(); - - int count = reader.ReadInt(); - - for (int i = 0; i < count; ++i) { - Item item = reader.ReadItem(); + // Version 11, we move all bools to a CorpseFlag + m_Flags = (CorpseFlag)reader.ReadInt(); + + TimeOfDeath = reader.ReadDeltaTime(); + + int count = reader.ReadInt(); + + for (int i = 0; i < count; ++i) + { + Item item = reader.ReadItem(); + + if (reader.ReadBool()) + SetRestoreInfo(item, reader.ReadPoint3D()); + else if (item != null) + SetRestoreInfo(item, item.Location); + } if (reader.ReadBool()) - SetRestoreInfo(item, reader.ReadPoint3D()); - else if (item != null) - SetRestoreInfo(item, item.Location); + BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); + + Looters = reader.ReadStrongMobileList(); + Killer = reader.ReadMobile(); + + Aggressors = reader.ReadStrongMobileList(); + Owner = reader.ReadMobile(); + + m_CorpseName = reader.ReadString(); + + AccessLevel = (AccessLevel)reader.ReadInt(); + reader.ReadInt(); // guild reserve + Kills = reader.ReadInt(); + + EquipItems = reader.ReadStrongItemList(); + break; } - - if (reader.ReadBool()) - BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); - - Looters = reader.ReadStrongMobileList(); - Killer = reader.ReadMobile(); - - Aggressors = reader.ReadStrongMobileList(); - Owner = reader.ReadMobile(); - - m_CorpseName = reader.ReadString(); - - AccessLevel = (AccessLevel)reader.ReadInt(); - reader.ReadInt(); // guild reserve - Kills = reader.ReadInt(); - - EquipItems = reader.ReadStrongItemList(); - break; - } case 10: - { - TimeOfDeath = reader.ReadDeltaTime(); - - goto case 9; - } - case 9: - { - int count = reader.ReadInt(); - - for (int i = 0; i < count; ++i) { - Item item = reader.ReadItem(); + TimeOfDeath = reader.ReadDeltaTime(); - if (reader.ReadBool()) - SetRestoreInfo(item, reader.ReadPoint3D()); - else if (item != null) - SetRestoreInfo(item, item.Location); + goto case 9; } + case 9: + { + int count = reader.ReadInt(); - goto case 8; - } + for (int i = 0; i < count; ++i) + { + Item item = reader.ReadItem(); + + if (reader.ReadBool()) + SetRestoreInfo(item, reader.ReadPoint3D()); + else if (item != null) + SetRestoreInfo(item, item.Location); + } + + goto case 8; + } case 8: - { - SetFlag(CorpseFlag.VisitedByTaxidermist, reader.ReadBool()); + { + SetFlag(CorpseFlag.VisitedByTaxidermist, reader.ReadBool()); - goto case 7; - } + goto case 7; + } case 7: - { - if (reader.ReadBool()) - BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); + { + if (reader.ReadBool()) + BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); - goto case 6; - } + goto case 6; + } case 6: - { - Looters = reader.ReadStrongMobileList(); - Killer = reader.ReadMobile(); + { + Looters = reader.ReadStrongMobileList(); + Killer = reader.ReadMobile(); - goto case 5; - } + goto case 5; + } case 5: - { - SetFlag(CorpseFlag.Carved, reader.ReadBool()); + { + SetFlag(CorpseFlag.Carved, reader.ReadBool()); - goto case 4; - } + goto case 4; + } case 4: - { - Aggressors = reader.ReadStrongMobileList(); + { + Aggressors = reader.ReadStrongMobileList(); - goto case 3; - } + goto case 3; + } case 3: - { - Owner = reader.ReadMobile(); + { + Owner = reader.ReadMobile(); - goto case 2; - } + goto case 2; + } case 2: - { - SetFlag(CorpseFlag.NoBones, reader.ReadBool()); + { + SetFlag(CorpseFlag.NoBones, reader.ReadBool()); - goto case 1; - } + goto case 1; + } case 1: - { - m_CorpseName = reader.ReadString(); + { + m_CorpseName = reader.ReadString(); - goto case 0; - } + goto case 0; + } case 0: - { - if (version < 10) - TimeOfDeath = DateTime.UtcNow; + { + if (version < 10) + TimeOfDeath = DateTime.UtcNow; - if (version < 7) - BeginDecay(m_DefaultDecayTime); + if (version < 7) + BeginDecay(m_DefaultDecayTime); - if (version < 6) - Looters = new List(); + if (version < 6) + Looters = new List(); - if (version < 4) - Aggressors = new List(); + if (version < 4) + Aggressors = new List(); - AccessLevel = (AccessLevel)reader.ReadInt(); - reader.ReadInt(); // guild reserve - Kills = reader.ReadInt(); - SetFlag(CorpseFlag.Criminal, reader.ReadBool()); + AccessLevel = (AccessLevel)reader.ReadInt(); + reader.ReadInt(); // guild reserve + Kills = reader.ReadInt(); + SetFlag(CorpseFlag.Criminal, reader.ReadBool()); - EquipItems = reader.ReadStrongItemList(); + EquipItems = reader.ReadStrongItemList(); - break; - } + break; + } } } @@ -865,8 +865,6 @@ namespace Server.Items return; } - #region Self Looting - if (checkSelfLoot && from == Owner && !GetFlag(CorpseFlag.SelfLooted) && Items.Count != 0) { if (from.FindItemOnLayer(Layer.OuterTorso) is DeathRobe robe) @@ -947,13 +945,9 @@ namespace Server.Items SetFlag(CorpseFlag.SelfLooted, true); } - #endregion - if (!CheckLoot(from, null)) return; - #region Quests - if (!(from is PlayerMobile player)) return; QuestSystem qs = player.Quest; @@ -1007,8 +1001,6 @@ namespace Server.Items } } - #endregion - base.OnDoubleClick(from); } @@ -1062,8 +1054,8 @@ namespace Server.Items private class InstancedItemInfo { - private Item m_Item; - private Mobile m_Mobile; + private readonly Item m_Item; + private readonly Mobile m_Mobile; public InstancedItemInfo(Item i, Mobile m) { @@ -1071,15 +1063,15 @@ namespace Server.Items m_Mobile = m; } - public bool Perpetual{ get; set; } + public bool Perpetual { get; set; } public bool IsOwner(Mobile m) { - if (m_Item.LootType == LootType.Cursed) //Cursed Items are part of everyone's instanced corpse... (?) + if (m_Item.LootType == LootType.Cursed) // Cursed Items are part of everyone's instanced corpse... (?) return true; if (m == null) - return false; //sanity + return false; // sanity if (m_Mobile == m) return true; @@ -1092,7 +1084,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Corpse m_Corpse; + private readonly Corpse m_Corpse; public InternalTimer(Corpse c, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Items/Misc/Corpses/CorpseNameAttribute.cs b/Projects/Scripts/Items/Misc/Corpses/CorpseNameAttribute.cs index 7338c269f..412d473a5 100644 --- a/Projects/Scripts/Items/Misc/Corpses/CorpseNameAttribute.cs +++ b/Projects/Scripts/Items/Misc/Corpses/CorpseNameAttribute.cs @@ -7,6 +7,6 @@ namespace Server { public CorpseNameAttribute(string name) => Name = name; - public string Name{ get; } + public string Name { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Misc/Corpses/DecayedCorpse.cs b/Projects/Scripts/Items/Misc/Corpses/DecayedCorpse.cs index f12b9d528..ad2192868 100644 --- a/Projects/Scripts/Items/Misc/Corpses/DecayedCorpse.cs +++ b/Projects/Scripts/Items/Misc/Corpses/DecayedCorpse.cs @@ -4,7 +4,7 @@ namespace Server.Items { public class DecayedCorpse : Container { - private static TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(7.0); + private static readonly TimeSpan m_DefaultDecayTime = TimeSpan.FromMinutes(7.0); private DateTime m_DecayTime; private Timer m_DecayTimer; @@ -74,24 +74,24 @@ namespace Server.Items switch (version) { case 0: - { - BeginDecay(m_DefaultDecayTime); + { + BeginDecay(m_DefaultDecayTime); - break; - } + break; + } case 1: - { - if (reader.ReadBool()) - BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); + { + if (reader.ReadBool()) + BeginDecay(reader.ReadDeltaTime() - DateTime.UtcNow); - break; - } + break; + } } } private class InternalTimer : Timer { - private DecayedCorpse m_Corpse; + private readonly DecayedCorpse m_Corpse; public InternalTimer(DecayedCorpse c, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Items/Misc/Corpses/Packets.cs b/Projects/Scripts/Items/Misc/Corpses/Packets.cs index 9a23769d5..e36c4630e 100644 --- a/Projects/Scripts/Items/Misc/Corpses/Packets.cs +++ b/Projects/Scripts/Items/Misc/Corpses/Packets.cs @@ -18,7 +18,7 @@ namespace Server.Network EnsureCapacity(8 + count * 5); - m_Stream.Write(beheld.Serial); + Stream.Write(beheld.Serial); for (int i = 0; i < list.Count; ++i) { @@ -26,24 +26,24 @@ namespace Server.Network if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld) { - m_Stream.Write((byte)(item.Layer + 1)); - m_Stream.Write(item.Serial); + Stream.Write((byte)(item.Layer + 1)); + Stream.Write(item.Serial); } } if (beheld.Hair?.ItemID > 0) { - m_Stream.Write((byte)(Layer.Hair + 1)); - m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2); + Stream.Write((byte)(Layer.Hair + 1)); + Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2); } if (beheld.FacialHair?.ItemID > 0) { - m_Stream.Write((byte)(Layer.FacialHair + 1)); - m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2); + Stream.Write((byte)(Layer.FacialHair + 1)); + Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2); } - m_Stream.Write((byte)Layer.Invalid); + Stream.Write((byte)Layer.Invalid); } } @@ -62,11 +62,11 @@ namespace Server.Network EnsureCapacity(5 + count * 19); - long pos = m_Stream.Position; + long pos = Stream.Position; int written = 0; - m_Stream.Write((ushort)0); + Stream.Write((ushort)0); for (int i = 0; i < items.Count; ++i) { @@ -74,14 +74,14 @@ namespace Server.Network if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child)) { - m_Stream.Write(child.Serial); - m_Stream.Write((ushort)child.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)child.Amount); - m_Stream.Write((short)child.X); - m_Stream.Write((short)child.Y); - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)child.Hue); + Stream.Write(child.Serial); + Stream.Write((ushort)child.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)child.Amount); + Stream.Write((short)child.X); + Stream.Write((short)child.Y); + Stream.Write(beheld.Serial); + Stream.Write((ushort)child.Hue); ++written; } @@ -89,34 +89,34 @@ namespace Server.Network if (beheld.Hair?.ItemID > 0) { - m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2); - m_Stream.Write((ushort)beheld.Hair.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)1); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)beheld.Hair.Hue); + Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2); + Stream.Write((ushort)beheld.Hair.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)1); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write(beheld.Serial); + Stream.Write((ushort)beheld.Hair.Hue); ++written; } if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0) { - m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2); - m_Stream.Write((ushort)beheld.FacialHair.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)1); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)beheld.FacialHair.Hue); + Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2); + Stream.Write((ushort)beheld.FacialHair.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)1); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write(beheld.Serial); + Stream.Write((ushort)beheld.FacialHair.Hue); ++written; } - m_Stream.Seek(pos, SeekOrigin.Begin); - m_Stream.Write((ushort)written); + Stream.Seek(pos, SeekOrigin.Begin); + Stream.Write((ushort)written); } } @@ -135,11 +135,11 @@ namespace Server.Network EnsureCapacity(5 + count * 20); - long pos = m_Stream.Position; + long pos = Stream.Position; int written = 0; - m_Stream.Write((ushort)0); + Stream.Write((ushort)0); for (int i = 0; i < items.Count; ++i) { @@ -147,15 +147,15 @@ namespace Server.Network if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child)) { - m_Stream.Write(child.Serial); - m_Stream.Write((ushort)child.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)child.Amount); - m_Stream.Write((short)child.X); - m_Stream.Write((short)child.Y); - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)child.Hue); + Stream.Write(child.Serial); + Stream.Write((ushort)child.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)child.Amount); + Stream.Write((short)child.X); + Stream.Write((short)child.Y); + Stream.Write((byte)0); // Grid Location? + Stream.Write(beheld.Serial); + Stream.Write((ushort)child.Hue); ++written; } @@ -163,36 +163,36 @@ namespace Server.Network if (beheld.Hair?.ItemID > 0) { - m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2); - m_Stream.Write((ushort)beheld.Hair.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)1); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)beheld.Hair.Hue); + Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2); + Stream.Write((ushort)beheld.Hair.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)1); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write((byte)0); // Grid Location? + Stream.Write(beheld.Serial); + Stream.Write((ushort)beheld.Hair.Hue); ++written; } if (beheld.FacialHair?.ItemID > 0) { - m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2); - m_Stream.Write((ushort)beheld.FacialHair.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)1); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)beheld.FacialHair.Hue); + Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2); + Stream.Write((ushort)beheld.FacialHair.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)1); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write((byte)0); // Grid Location? + Stream.Write(beheld.Serial); + Stream.Write((ushort)beheld.FacialHair.Hue); ++written; } - m_Stream.Seek(pos, SeekOrigin.Begin); - m_Stream.Write((ushort)written); + Stream.Seek(pos, SeekOrigin.Begin); + Stream.Write((ushort)written); } } } diff --git a/Projects/Scripts/Items/Misc/DeceitBrazier.cs b/Projects/Scripts/Items/Misc/DeceitBrazier.cs index 8560eb87f..18e838d7c 100644 --- a/Projects/Scripts/Items/Misc/DeceitBrazier.cs +++ b/Projects/Scripts/Items/Misc/DeceitBrazier.cs @@ -23,94 +23,38 @@ namespace Server.Items { } - public static Type[] Creatures{ get; } = + public static Type[] Creatures { get; } = { - #region Animals - - typeof(FireSteed), //Set the tents up people! - - #endregion - - #region Undead + typeof(FireSteed), // Set the tents up people! typeof(Skeleton), typeof(SkeletalKnight), typeof(SkeletalMage), typeof(Mummy), typeof(BoneKnight), typeof(Lich), typeof(LichLord), typeof(BoneMagi), typeof(Wraith), typeof(Shade), typeof(Spectre), typeof(Zombie), - typeof(RottingCorpse), typeof(Ghoul), - - #endregion - - #region Demons - - typeof(Balron), typeof(Daemon), typeof(Imp), typeof(GreaterMongbat), + typeof(RottingCorpse), typeof(Ghoul), typeof(Balron), typeof(Daemon), typeof(Imp), typeof(GreaterMongbat), typeof(Mongbat), typeof(IceFiend), typeof(Gargoyle), typeof(StoneGargoyle), - typeof(FireGargoyle), typeof(HordeMinion), - - #endregion - - #region Gazers - - typeof(Gazer), typeof(ElderGazer), typeof(GazerLarva), - - #endregion - - #region Uncategorized - - typeof(Harpy), typeof(StoneHarpy), typeof(HeadlessOne), typeof(HellHound), + typeof(FireGargoyle), typeof(HordeMinion), typeof(Gazer), typeof(ElderGazer), typeof(GazerLarva), typeof(Harpy), typeof(StoneHarpy), typeof(HeadlessOne), typeof(HellHound), typeof(HellCat), typeof(Phoenix), typeof(LavaLizard), typeof(SandVortex), - typeof(ShadowWisp), typeof(SwampTentacle), typeof(PredatorHellCat), typeof(Wisp), - - #endregion - - #region Arachnid - - typeof(GiantSpider), typeof(DreadSpider), typeof(FrostSpider), typeof(Scorpion), - - #endregion - - #region Repond - - typeof(ArcticOgreLord), typeof(Cyclops), typeof(Ettin), typeof(EvilMage), + typeof(ShadowWisp), typeof(SwampTentacle), typeof(PredatorHellCat), typeof(Wisp), typeof(GiantSpider), typeof(DreadSpider), typeof(FrostSpider), typeof(Scorpion), typeof(ArcticOgreLord), typeof(Cyclops), typeof(Ettin), typeof(EvilMage), typeof(FrostTroll), typeof(Ogre), typeof(OgreLord), typeof(Orc), typeof(OrcishLord), typeof(OrcishMage), typeof(OrcBrute), typeof(Ratman), typeof(RatmanMage), typeof(OrcCaptain), typeof(Troll), typeof(Titan), - typeof(EvilMageLord), typeof(OrcBomber), typeof(RatmanArcher), - - #endregion - - #region Reptilian - - typeof(Dragon), typeof(Drake), typeof(Snake), typeof(GreaterDragon), + typeof(EvilMageLord), typeof(OrcBomber), typeof(RatmanArcher), typeof(Dragon), typeof(Drake), typeof(Snake), typeof(GreaterDragon), typeof(IceSerpent), typeof(GiantSerpent), typeof(IceSnake), typeof(LavaSerpent), typeof(Lizardman), typeof(Wyvern), typeof(WhiteWyrm), - typeof(ShadowWyrm), typeof(SilverSerpent), typeof(LavaSnake), - - #endregion - - #region Elementals - - typeof(EarthElemental), typeof(PoisonElemental), typeof(FireElemental), typeof(SnowElemental), + typeof(ShadowWyrm), typeof(SilverSerpent), typeof(LavaSnake), typeof(EarthElemental), typeof(PoisonElemental), typeof(FireElemental), typeof(SnowElemental), typeof(IceElemental), typeof(AcidElemental), typeof(WaterElemental), typeof(Efreet), - typeof(AirElemental), typeof(Golem), - - #endregion - - #region Random Critters - - typeof(SewerRat), typeof(GiantRat), typeof(DireWolf), typeof(TimberWolf), + typeof(AirElemental), typeof(Golem), typeof(SewerRat), typeof(GiantRat), typeof(DireWolf), typeof(TimberWolf), typeof(Cougar), typeof(Alligator) - - #endregion }; [CommandProperty(AccessLevel.GameMaster)] - public DateTime NextSpawn{ get; private set; } + public DateTime NextSpawn { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int SpawnRange{ get; set; } + public int SpawnRange { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan NextSpawnDelay{ get; set; } + public TimeSpan NextSpawnDelay { get; set; } public override int LabelNumber => 1023633; // Brazier @@ -202,7 +146,7 @@ namespace Server.Items DoEffect(spawnLoc, map); - Timer.DelayCall(TimeSpan.FromSeconds(1), delegate + Timer.DelayCall(TimeSpan.FromSeconds(1), () => { bc.Home = Location; bc.RangeHome = SpawnRange; diff --git a/Projects/Scripts/Items/Misc/EffectController.cs b/Projects/Scripts/Items/Misc/EffectController.cs index 1d23419ef..621d72c54 100644 --- a/Projects/Scripts/Items/Misc/EffectController.cs +++ b/Projects/Scripts/Items/Misc/EffectController.cs @@ -38,23 +38,22 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public ECEffectType EffectType{ get; set; } + public ECEffectType EffectType { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public EffectTriggerType TriggerType{ get; set; } + public EffectTriggerType TriggerType { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public EffectLayer EffectLayer{ get; set; } + public EffectLayer EffectLayer { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan EffectDelay{ get; set; } + public TimeSpan EffectDelay { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan TriggerDelay{ get; set; } + public TimeSpan TriggerDelay { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan SoundDelay{ get; set; } - + public TimeSpan SoundDelay { get; set; } [CommandProperty(AccessLevel.GameMaster)] public Item SourceItem @@ -80,7 +79,6 @@ namespace Server.Items } } - [CommandProperty(AccessLevel.GameMaster)] public Item TargetItem { @@ -105,53 +103,50 @@ namespace Server.Items } } + [CommandProperty(AccessLevel.GameMaster)] + public EffectController Sequence { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public EffectController Sequence{ get; set; } - + private bool FixedDirection { get; set; } [CommandProperty(AccessLevel.GameMaster)] - private bool FixedDirection{ get; set; } + private bool Explodes { get; set; } [CommandProperty(AccessLevel.GameMaster)] - private bool Explodes{ get; set; } + private bool PlaySoundAtTrigger { get; set; } [CommandProperty(AccessLevel.GameMaster)] - private bool PlaySoundAtTrigger{ get; set; } - + public int EffectItemID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int EffectItemID{ get; set; } + public int EffectHue { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int EffectHue{ get; set; } + public int RenderMode { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int RenderMode{ get; set; } + public int Speed { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Speed{ get; set; } + public int Duration { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Duration{ get; set; } + public int ParticleEffect { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ParticleEffect{ get; set; } + public int ExplodeParticleEffect { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ExplodeParticleEffect{ get; set; } + public int ExplodeSound { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ExplodeSound{ get; set; } + public int Unknown { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Unknown{ get; set; } + public int SoundID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int SoundID{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public int TriggerRange{ get; set; } + public int TriggerRange { get; set; } public override string DefaultName => "Effect Controller"; @@ -225,37 +220,37 @@ namespace Server.Items switch (version) { case 0: - { - EffectDelay = reader.ReadTimeSpan(); - TriggerDelay = reader.ReadTimeSpan(); - SoundDelay = reader.ReadTimeSpan(); + { + EffectDelay = reader.ReadTimeSpan(); + TriggerDelay = reader.ReadTimeSpan(); + SoundDelay = reader.ReadTimeSpan(); - m_Source = ReadEntity(reader); - m_Target = ReadEntity(reader); - Sequence = reader.ReadItem() as EffectController; + m_Source = ReadEntity(reader); + m_Target = ReadEntity(reader); + Sequence = reader.ReadItem() as EffectController; - FixedDirection = reader.ReadBool(); - Explodes = reader.ReadBool(); - PlaySoundAtTrigger = reader.ReadBool(); + FixedDirection = reader.ReadBool(); + Explodes = reader.ReadBool(); + PlaySoundAtTrigger = reader.ReadBool(); - EffectType = (ECEffectType)reader.ReadEncodedInt(); - EffectLayer = (EffectLayer)reader.ReadEncodedInt(); - TriggerType = (EffectTriggerType)reader.ReadEncodedInt(); + EffectType = (ECEffectType)reader.ReadEncodedInt(); + EffectLayer = (EffectLayer)reader.ReadEncodedInt(); + TriggerType = (EffectTriggerType)reader.ReadEncodedInt(); - EffectItemID = reader.ReadEncodedInt(); - EffectHue = reader.ReadEncodedInt(); - RenderMode = reader.ReadEncodedInt(); - Speed = reader.ReadEncodedInt(); - Duration = reader.ReadEncodedInt(); - ParticleEffect = reader.ReadEncodedInt(); - ExplodeParticleEffect = reader.ReadEncodedInt(); - ExplodeSound = reader.ReadEncodedInt(); - Unknown = reader.ReadEncodedInt(); - SoundID = reader.ReadEncodedInt(); - TriggerRange = reader.ReadEncodedInt(); + EffectItemID = reader.ReadEncodedInt(); + EffectHue = reader.ReadEncodedInt(); + RenderMode = reader.ReadEncodedInt(); + Speed = reader.ReadEncodedInt(); + Duration = reader.ReadEncodedInt(); + ParticleEffect = reader.ReadEncodedInt(); + ExplodeParticleEffect = reader.ReadEncodedInt(); + ExplodeSound = reader.ReadEncodedInt(); + Unknown = reader.ReadEncodedInt(); + SoundID = reader.ReadEncodedInt(); + TriggerRange = reader.ReadEncodedInt(); - break; - } + break; + } } } @@ -292,34 +287,34 @@ namespace Server.Items switch (EffectType) { case ECEffectType.Lightning: - { - Effects.SendBoltEffect(from, false, EffectHue); - break; - } + { + Effects.SendBoltEffect(from, false, EffectHue); + break; + } case ECEffectType.Location: - { - Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), - EffectItemID, Speed, Duration, EffectHue, RenderMode, ParticleEffect, Unknown); - break; - } + { + Effects.SendLocationParticles(EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration), + EffectItemID, Speed, Duration, EffectHue, RenderMode, ParticleEffect, Unknown); + break; + } case ECEffectType.Moving: - { - if (from == this) - from = EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration); + { + if (from == this) + from = EffectItem.Create(from.Location, from.Map, EffectItem.DefaultDuration); - if (to == this) - to = EffectItem.Create(to.Location, to.Map, EffectItem.DefaultDuration); + if (to == this) + to = EffectItem.Create(to.Location, to.Map, EffectItem.DefaultDuration); - Effects.SendMovingParticles(from, to, EffectItemID, Speed, Duration, FixedDirection, Explodes, EffectHue, - RenderMode, ParticleEffect, ExplodeParticleEffect, ExplodeSound, EffectLayer, Unknown); - break; - } + Effects.SendMovingParticles(from, to, EffectItemID, Speed, Duration, FixedDirection, Explodes, EffectHue, + RenderMode, ParticleEffect, ExplodeParticleEffect, ExplodeSound, EffectLayer, Unknown); + break; + } case ECEffectType.Target: - { - Effects.SendTargetParticles(from, EffectItemID, Speed, Duration, EffectHue, RenderMode, ParticleEffect, - EffectLayer, Unknown); - break; - } + { + Effects.SendTargetParticles(from, EffectItemID, Speed, Duration, EffectHue, RenderMode, ParticleEffect, + EffectLayer, Unknown); + break; + } } } } diff --git a/Projects/Scripts/Items/Misc/EffectItem.cs b/Projects/Scripts/Items/Misc/EffectItem.cs index c44eb4c8d..475931025 100644 --- a/Projects/Scripts/Items/Misc/EffectItem.cs +++ b/Projects/Scripts/Items/Misc/EffectItem.cs @@ -5,7 +5,7 @@ namespace Server.Items { public class EffectItem : Item { - private static List m_Free = new List(); // List of available EffectItems + private static readonly List m_Free = new List(); // List of available EffectItems public static readonly TimeSpan DefaultDuration = TimeSpan.FromSeconds(5.0); @@ -67,7 +67,7 @@ namespace Server.Items private class FreeTimer : Timer { - private EffectItem m_Item; + private readonly EffectItem m_Item; public FreeTimer(EffectItem item, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Items/Misc/Firebomb.cs b/Projects/Scripts/Items/Misc/Firebomb.cs index ea1bb7115..1b429745e 100644 --- a/Projects/Scripts/Items/Misc/Firebomb.cs +++ b/Projects/Scripts/Items/Misc/Firebomb.cs @@ -17,7 +17,7 @@ namespace Server.Items [Constructible] public Firebomb(int itemID = 0x99B) : base(itemID) { - //Name = "a firebomb"; + // Name = "a firebomb"; Weight = 2.0; Hue = 1260; } @@ -90,64 +90,64 @@ namespace Server.Items case 0: case 1: case 2: - { - ++m_Ticks; + { + ++m_Ticks; - if (HeldBy != null) - HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); - else if (RootParent == null) - PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); - else if (RootParent is Mobile mobile) - mobile.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); + if (HeldBy != null) + HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); + else if (RootParent == null) + PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); + else if (RootParent is Mobile mobile) + mobile.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString()); - break; - } + break; + } default: - { - HeldBy?.DropHolding(); - - if (m_Users != null) { - foreach (Mobile m in m_Users) - if (m.Target is ThrowTarget targ && targ.Bomb == this) - Target.Cancel(m); + HeldBy?.DropHolding(); - m_Users.Clear(); - m_Users = null; - } - - if (RootParent is Mobile parent) - { - parent.SendLocalizedMessage(1060583); // The firebomb explodes in your hand! - AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0); - } - else if (RootParent == null) - { - IPooledEnumerable eable = Map.GetMobilesInRange(Location, 1); - List toDamage = eable.ToList(); - - eable.Free(); - - for (int i = 0; i < toDamage.Count; ++i) + if (m_Users != null) { - Mobile victim = toDamage[i]; + foreach (Mobile m in m_Users) + if (m.Target is ThrowTarget targ && targ.Bomb == this) + Target.Cancel(m); - if (m_LitBy == null || SpellHelper.ValidIndirectTarget(m_LitBy, victim) && - m_LitBy.CanBeHarmful(victim, false)) - { - m_LitBy?.DoHarmful(victim); - - AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0); - } + m_Users.Clear(); + m_Users = null; } - new FirebombField(m_LitBy, toDamage).MoveToWorld(Location, Map); - } + if (RootParent is Mobile parent) + { + parent.SendLocalizedMessage(1060583); // The firebomb explodes in your hand! + AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0); + } + else if (RootParent == null) + { + IPooledEnumerable eable = Map.GetMobilesInRange(Location, 1); + List toDamage = eable.ToList(); - m_Timer.Stop(); - Delete(); - break; - } + eable.Free(); + + for (int i = 0; i < toDamage.Count; ++i) + { + Mobile victim = toDamage[i]; + + if (m_LitBy == null || (SpellHelper.ValidIndirectTarget(m_LitBy, victim) && + m_LitBy.CanBeHarmful(victim, false))) + { + m_LitBy?.DoHarmful(victim); + + AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0); + } + } + + new FirebombField(m_LitBy, toDamage).MoveToWorld(Location, Map); + } + + m_Timer.Stop(); + Delete(); + break; + } } } @@ -185,7 +185,7 @@ namespace Server.Items : base(12, true, TargetFlags.None) => Bomb = bomb; - public Firebomb Bomb{ get; } + public Firebomb Bomb { get; } protected override void OnTarget(Mobile from, object targeted) { @@ -196,10 +196,10 @@ namespace Server.Items public class FirebombField : Item { - private List m_Burning; - private DateTime m_Expire; - private Mobile m_LitBy; - private Timer m_Timer; + private readonly List m_Burning; + private readonly DateTime m_Expire; + private readonly Mobile m_LitBy; + private readonly Timer m_Timer; public FirebombField(Mobile litBy, List toDamage) : base(0x376A) { @@ -225,8 +225,8 @@ namespace Server.Items public override bool OnMoveOver(Mobile m) { - if (ItemID == 0x398C && m_LitBy == null || - SpellHelper.ValidIndirectTarget(m_LitBy, m) && m_LitBy.CanBeHarmful(m, false)) + if ((ItemID == 0x398C && m_LitBy == null) || + (SpellHelper.ValidIndirectTarget(m_LitBy, m) && m_LitBy.CanBeHarmful(m, false))) { m_LitBy?.DoHarmful(m); @@ -259,8 +259,8 @@ namespace Server.Items Mobile victim = m_Burning[i]; if (victim.Location == Location && victim.Map == Map && - (m_LitBy == null || SpellHelper.ValidIndirectTarget(m_LitBy, victim) && - m_LitBy.CanBeHarmful(victim, false))) + (m_LitBy == null || (SpellHelper.ValidIndirectTarget(m_LitBy, victim) && + m_LitBy.CanBeHarmful(victim, false)))) { m_LitBy?.DoHarmful(victim); diff --git a/Projects/Scripts/Items/Misc/FlippableAddonAttribute.cs b/Projects/Scripts/Items/Misc/FlippableAddonAttribute.cs index b1266ea8d..1f83e24ca 100644 --- a/Projects/Scripts/Items/Misc/FlippableAddonAttribute.cs +++ b/Projects/Scripts/Items/Misc/FlippableAddonAttribute.cs @@ -7,16 +7,16 @@ namespace Server.Items [AttributeUsage(AttributeTargets.Class)] public class FlippableAddonAttribute : Attribute { - private static string m_MethodName = "Flip"; + private static readonly string m_MethodName = "Flip"; - private static Type[] m_Params = + private static readonly Type[] m_Params = { typeof(Mobile), typeof(Direction) }; public FlippableAddonAttribute(params Direction[] directions) => Directions = directions; - public Direction[] Directions{ get; } + public Direction[] Directions { get; } public virtual void Flip(Mobile from, Item addon) { diff --git a/Projects/Scripts/Items/Misc/FlippableAttribute.cs b/Projects/Scripts/Items/Misc/FlippableAttribute.cs index 7f8c20041..364883443 100644 --- a/Projects/Scripts/Items/Misc/FlippableAttribute.cs +++ b/Projects/Scripts/Items/Misc/FlippableAttribute.cs @@ -56,7 +56,7 @@ namespace Server.Items { public FlippableAttribute(params int[] itemIDs) => ItemIDs = itemIDs; - public int[] ItemIDs{ get; } + public int[] ItemIDs { get; } public virtual void Flip(Item item) { @@ -64,7 +64,7 @@ namespace Server.Items { try { - item.GetType().GetMethod("Flip", Type.EmptyTypes)?.Invoke(item, new object[0]); + item.GetType().GetMethod("Flip", Type.EmptyTypes)?.Invoke(item, Array.Empty()); } catch { diff --git a/Projects/Scripts/Items/Misc/GlassItems.cs b/Projects/Scripts/Items/Misc/GlassItems.cs index 3ca34e04f..ec831f641 100644 --- a/Projects/Scripts/Items/Misc/GlassItems.cs +++ b/Projects/Scripts/Items/Misc/GlassItems.cs @@ -191,7 +191,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -219,7 +219,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -247,7 +247,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -275,7 +275,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -303,7 +303,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -331,7 +331,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -342,7 +342,7 @@ namespace Server.Items } } - //remove + // remove public class SmallBlueFlask : Item { [Constructible] @@ -360,7 +360,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -388,7 +388,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -416,7 +416,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -444,7 +444,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -472,7 +472,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -500,7 +500,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -528,7 +528,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -556,7 +556,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -584,7 +584,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -612,7 +612,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -640,7 +640,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -668,7 +668,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -696,7 +696,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -724,7 +724,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -752,7 +752,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -780,7 +780,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -808,7 +808,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -836,7 +836,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -864,7 +864,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -892,7 +892,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -920,7 +920,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -948,7 +948,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -976,7 +976,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1004,7 +1004,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1032,7 +1032,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1061,7 +1061,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1090,7 +1090,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1101,7 +1101,6 @@ namespace Server.Items } } - public class EmptyVial : Item { [Constructible] @@ -1119,7 +1118,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1147,7 +1146,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1175,7 +1174,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -1203,7 +1202,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Items/Misc/Guillotine.cs b/Projects/Scripts/Items/Misc/Guillotine.cs index 026a7d00a..dfdf87b0b 100644 --- a/Projects/Scripts/Items/Misc/Guillotine.cs +++ b/Projects/Scripts/Items/Misc/Guillotine.cs @@ -28,7 +28,7 @@ namespace Server.Items { Point3D p = GetWorldLocation(); - if (1 > Utility.Random(Math.Max(Math.Abs(from.X - p.X), Math.Abs(from.Y - p.Y)))) + if (Utility.Random(Math.Max(Math.Abs(from.X - p.X), Math.Abs(from.Y - p.Y))) < 1) { Effects.PlaySound(from.Location, from.Map, from.GetHurtSound()); from.PublicOverheadMessage(MessageType.Regular, from.SpeechHue, true, "Ouch!"); diff --git a/Projects/Scripts/Items/Misc/HairDye.cs b/Projects/Scripts/Items/Misc/HairDye.cs index dd46e1ae9..07dace4b5 100644 --- a/Projects/Scripts/Items/Misc/HairDye.cs +++ b/Projects/Scripts/Items/Misc/HairDye.cs @@ -44,7 +44,7 @@ namespace Server.Items public class HairDyeGump : Gump { - private static HairDyeEntry[] m_Entries = + private static readonly HairDyeEntry[] m_Entries = { new HairDyeEntry("*****", 1602, 26), new HairDyeEntry("*****", 1628, 27), @@ -60,7 +60,7 @@ namespace Server.Items new HairDyeEntry("*****", 1134, 16) }; - private HairDye m_HairDye; + private readonly HairDye m_HairDye; public HairDyeGump(HairDye dye) : base(50, 50) { @@ -106,7 +106,7 @@ namespace Server.Items if (!m_HairDye.IsChildOf(m.Backpack)) { - m.SendLocalizedMessage(1042010); //You must have the objectin your backpack to use it. + m.SendLocalizedMessage(1042010); // You must have the objectin your backpack to use it. return; } @@ -156,11 +156,11 @@ namespace Server.Items HueCount = hueCount; } - public string Name{ get; } + public string Name { get; } - public int HueStart{ get; } + public int HueStart { get; } - public int HueCount{ get; } + public int HueCount { get; } } } } diff --git a/Projects/Scripts/Items/Misc/IDurability.cs b/Projects/Scripts/Items/Misc/IDurability.cs index 8a3181805..bbd9fbb21 100644 --- a/Projects/Scripts/Items/Misc/IDurability.cs +++ b/Projects/Scripts/Items/Misc/IDurability.cs @@ -2,13 +2,13 @@ namespace Server.Items { internal interface IDurability { - bool CanFortify{ get; } + bool CanFortify { get; } - int InitMinHits{ get; } - int InitMaxHits{ get; } + int InitMinHits { get; } + int InitMaxHits { get; } - int HitPoints{ get; set; } - int MaxHitPoints{ get; set; } + int HitPoints { get; set; } + int MaxHitPoints { get; set; } void ScaleDurability(); void UnscaleDurability(); diff --git a/Projects/Scripts/Items/Misc/InteriorDecorator.cs b/Projects/Scripts/Items/Misc/InteriorDecorator.cs index 21265ed77..83c69930e 100644 --- a/Projects/Scripts/Items/Misc/InteriorDecorator.cs +++ b/Projects/Scripts/Items/Misc/InteriorDecorator.cs @@ -84,7 +84,7 @@ namespace Server.Items public static bool CheckUse(InteriorDecorator tool, Mobile from) { - /*if ( tool.Deleted || !tool.IsChildOf( from.Backpack ) ) + /*if (tool.Deleted || !tool.IsChildOf( from.Backpack )) from.SendLocalizedMessage( 1042001 ); // That must be in your pack for you to use it. else*/ if (!InHouse(from)) @@ -97,7 +97,7 @@ namespace Server.Items private class InternalGump : Gump { - private InteriorDecorator m_Decorator; + private readonly InteriorDecorator m_Decorator; public InternalGump(InteriorDecorator decorator) : base(150, 50) { @@ -140,7 +140,7 @@ namespace Server.Items private class InternalTarget : Target { - private InteriorDecorator m_Decorator; + private readonly InteriorDecorator m_Decorator; public InternalTarget(InteriorDecorator decorator) : base(-1, false, TargetFlags.None) { diff --git a/Projects/Scripts/Items/Misc/Key.cs b/Projects/Scripts/Items/Misc/Key.cs index 9b2211b99..4c07b471d 100644 --- a/Projects/Scripts/Items/Misc/Key.cs +++ b/Projects/Scripts/Items/Misc/Key.cs @@ -14,8 +14,8 @@ namespace Server.Items public interface ILockable { - bool Locked{ get; set; } - uint KeyValue{ get; set; } + bool Locked { get; set; } + uint KeyValue { get; set; } } public class Key : Item @@ -53,7 +53,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int MaxRange{ get; set; } + public int MaxRange { get; set; } [CommandProperty(AccessLevel.GameMaster)] public uint KeyValue @@ -68,7 +68,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Item Link{ get; set; } + public Item Link { get; set; } public static uint RandomValue() => (uint)(0xFFFFFFFE * Utility.RandomDouble()) + 1; @@ -149,28 +149,28 @@ namespace Server.Items switch (version) { case 2: - { - MaxRange = reader.ReadInt(); + { + MaxRange = reader.ReadInt(); - goto case 1; - } + goto case 1; + } case 1: - { - Link = reader.ReadItem(); + { + Link = reader.ReadItem(); - goto case 0; - } + goto case 0; + } case 0: - { - if (version < 2 || MaxRange == 0) - MaxRange = 3; + { + if (version < 2 || MaxRange == 0) + MaxRange = 3; - m_Description = reader.ReadString(); + m_Description = reader.ReadString(); - m_KeyVal = reader.ReadUInt(); + m_KeyVal = reader.ReadUInt(); - break; - } + break; + } } } @@ -268,7 +268,7 @@ namespace Server.Items private class RenamePrompt : Prompt { - private Key m_Key; + private readonly Key m_Key; public RenamePrompt(Key key) => m_Key = key; @@ -286,7 +286,7 @@ namespace Server.Items private class UnlockTarget : Target { - private Key m_Key; + private readonly Key m_Key; public UnlockTarget(Key key) : base(key.MaxRange, false, TargetFlags.None) { @@ -328,7 +328,7 @@ namespace Server.Items private class CopyTarget : Target { - private Key m_Key; + private readonly Key m_Key; public CopyTarget(Key key) : base(3, false, TargetFlags.None) => m_Key = key; diff --git a/Projects/Scripts/Items/Misc/KeyRing.cs b/Projects/Scripts/Items/Misc/KeyRing.cs index 7129b7ed4..db53727a8 100644 --- a/Projects/Scripts/Items/Misc/KeyRing.cs +++ b/Projects/Scripts/Items/Misc/KeyRing.cs @@ -19,7 +19,7 @@ namespace Server.Items { } - public List Keys{ get; private set; } + public List Keys { get; private set; } public override bool OnDragDrop(Mobile from, Item dropped) { @@ -150,7 +150,7 @@ namespace Server.Items private class InternalTarget : Target { - private KeyRing m_KeyRing; + private readonly KeyRing m_KeyRing; public InternalTarget(KeyRing keyRing) : base(-1, false, TargetFlags.None) => m_KeyRing = keyRing; diff --git a/Projects/Scripts/Items/Misc/LOSBlocker.cs b/Projects/Scripts/Items/Misc/LOSBlocker.cs index 5a26d76d4..d501a3513 100644 --- a/Projects/Scripts/Items/Misc/LOSBlocker.cs +++ b/Projects/Scripts/Items/Misc/LOSBlocker.cs @@ -71,18 +71,18 @@ namespace Server.Items else serial &= 0x7FFFFFFF; - m_Stream.Write(serial); - m_Stream.Write((short)(itemID & 0x7FFF)); + Stream.Write(serial); + Stream.Write((short)(itemID & 0x7FFF)); if (amount != 0) - m_Stream.Write((short)amount); + Stream.Write((short)amount); x &= 0x7FFF; if (direction != 0) x |= 0x8000; - m_Stream.Write((short)x); + Stream.Write((short)x); y &= 0x3FFF; @@ -92,18 +92,18 @@ namespace Server.Items if (flags != 0) y |= 0x4000; - m_Stream.Write((short)y); + Stream.Write((short)y); if (direction != 0) - m_Stream.Write((byte)direction); + Stream.Write((byte)direction); - m_Stream.Write((sbyte)loc.Z); + Stream.Write((sbyte)loc.Z); if (hue != 0) - m_Stream.Write((ushort)hue); + Stream.Write((ushort)hue); if (flags != 0) - m_Stream.Write((byte)flags); + Stream.Write((byte)flags); } } } diff --git a/Projects/Scripts/Items/Misc/Moonstone.cs b/Projects/Scripts/Items/Misc/Moonstone.cs index 432887f49..cb3c1f4da 100644 --- a/Projects/Scripts/Items/Misc/Moonstone.cs +++ b/Projects/Scripts/Items/Misc/Moonstone.cs @@ -69,7 +69,7 @@ namespace Server.Items { from.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. } - else if (from.Map == GetTargetMap() || from.Map != Map.Trammel && from.Map != Map.Felucca) + else if (from.Map == GetTargetMap() || (from.Map != Map.Trammel && from.Map != Map.Felucca)) { from.SendLocalizedMessage(1005401); // You cannot bury the stone here. } @@ -126,21 +126,22 @@ namespace Server.Items switch (version) { case 0: - { - m_Type = (MoonstoneType)reader.ReadInt(); + { + m_Type = (MoonstoneType)reader.ReadInt(); - break; - } + break; + } } } private class SettleTimer : Timer { - private Mobile m_Caster; + private readonly Mobile m_Caster; private int m_Count; - private Point3D m_Location; - private Map m_Map, m_TargetMap; - private Item m_Stone; + private readonly Point3D m_Location; + private readonly Map m_Map; + private readonly Map m_TargetMap; + private readonly Item m_Stone; public SettleTimer(Item stone, Point3D loc, Map map, Map targetMap, Mobile caster) : base( TimeSpan.FromSeconds(2.5), TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Items/Misc/MoonstoneGate.cs b/Projects/Scripts/Items/Misc/MoonstoneGate.cs index bbb224224..dab0b5896 100644 --- a/Projects/Scripts/Items/Misc/MoonstoneGate.cs +++ b/Projects/Scripts/Items/Misc/MoonstoneGate.cs @@ -5,7 +5,7 @@ namespace Server.Items { public class MoonstoneGate : Moongate { - private Mobile m_Caster; + private readonly Mobile m_Caster; public MoonstoneGate(Point3D loc, Map map, Map targetMap, Mobile caster, int hue) : base(loc, targetMap) { @@ -32,7 +32,7 @@ namespace Server.Items Party casterParty = Party.Get(m_Caster); Party userParty = Party.Get(m); - if (m == m_Caster || casterParty != null && userParty == casterParty) + if (m == m_Caster || (casterParty != null && userParty == casterParty)) base.CheckGate(m, range); } @@ -44,7 +44,7 @@ namespace Server.Items Party casterParty = Party.Get(m_Caster); Party userParty = Party.Get(m); - if (m == m_Caster || casterParty != null && userParty == casterParty) + if (m == m_Caster || (casterParty != null && userParty == casterParty)) base.UseGate(m); } @@ -66,7 +66,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Item m_Item; + private readonly Item m_Item; public InternalTimer(Item item) : base(TimeSpan.FromSeconds(30.0)) { diff --git a/Projects/Scripts/Items/Misc/MorphItem.cs b/Projects/Scripts/Items/Misc/MorphItem.cs index 806b81561..cc49b5707 100644 --- a/Projects/Scripts/Items/Misc/MorphItem.cs +++ b/Projects/Scripts/Items/Misc/MorphItem.cs @@ -29,10 +29,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int InactiveItemID{ get; set; } + public int InactiveItemID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ActiveItemID{ get; set; } + public int ActiveItemID { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int InsideRange @@ -101,21 +101,21 @@ namespace Server.Items switch (version) { case 1: - { - m_OutsideRange = reader.ReadInt(); - goto case 0; - } + { + m_OutsideRange = reader.ReadInt(); + goto case 0; + } case 0: - { - InactiveItemID = reader.ReadInt(); - ActiveItemID = reader.ReadInt(); - m_InsideRange = reader.ReadInt(); + { + InactiveItemID = reader.ReadInt(); + ActiveItemID = reader.ReadInt(); + m_InsideRange = reader.ReadInt(); - if (version < 1) - m_OutsideRange = m_InsideRange; + if (version < 1) + m_OutsideRange = m_InsideRange; - break; - } + break; + } } Timer.DelayCall(TimeSpan.Zero, Refresh); diff --git a/Projects/Scripts/Items/Misc/OilCloth.cs b/Projects/Scripts/Items/Misc/OilCloth.cs index 7a7574443..fb413e5cb 100644 --- a/Projects/Scripts/Items/Misc/OilCloth.cs +++ b/Projects/Scripts/Items/Misc/OilCloth.cs @@ -33,7 +33,7 @@ namespace Server.Items if (Deleted || !from.CanSee(this)) return false; - base.ScissorHelper(from, new Bandage(), 1); + this.ScissorHelper(from, new Bandage(), 1); return true; } @@ -102,9 +102,6 @@ namespace Server.Items 1005422); // Hmmmm... this does not need to be cleaned. } } - - #region Firebomb - else if (obj is BaseBeverage beverage) { if (beverage.Content == BeverageType.Liquor) @@ -122,9 +119,6 @@ namespace Server.Items { from.SendLocalizedMessage(1060579); // That is already a firebomb! } - - #endregion - else { from.SendLocalizedMessage(1005426); // The cloth will not work on that. @@ -145,4 +139,4 @@ namespace Server.Items int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs b/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs index 5dc87828d..a71296938 100644 --- a/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs +++ b/Projects/Scripts/Items/Misc/PlayerBulletinBoards.cs @@ -14,22 +14,22 @@ namespace Server.Items public override int LabelNumber => 1062421; // bulletin board (south) [Constructible] - public PlayerBBSouth() : base( 0x2311 ) => Weight = 15.0; + public PlayerBBSouth() : base(0x2311) => Weight = 15.0; - public PlayerBBSouth( Serial serial ) : base( serial ) + public PlayerBBSouth(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); // version + writer.Write(0); // version } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } @@ -40,22 +40,22 @@ namespace Server.Items public override int LabelNumber => 1062420; // bulletin board (east) [Constructible] - public PlayerBBEast() : base( 0x2312 ) => Weight = 15.0; + public PlayerBBEast() : base(0x2312) => Weight = 15.0; - public PlayerBBEast( Serial serial ) : base( serial ) + public PlayerBBEast(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); // version + writer.Write(0); // version } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } @@ -67,117 +67,117 @@ namespace Server.Items public PlayerBBMessage Greeting { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public string Title { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public SecureLevel Level { get; set; } - public BasePlayerBB( int itemID ) : base( itemID ) + public BasePlayerBB(int itemID) : base(itemID) { Messages = new List(); Level = SecureLevel.Anyone; } - public BasePlayerBB( Serial serial ) : base( serial ) + public BasePlayerBB(Serial serial) : base(serial) { } - public override void GetContextMenuEntries( Mobile from, List list ) + public override void GetContextMenuEntries(Mobile from, List list) { - base.GetContextMenuEntries( from, list ); - SetSecureLevelEntry.AddTo( from, this, list ); + base.GetContextMenuEntries(from, list); + SetSecureLevelEntry.AddTo(from, this, list); } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 1 ); + writer.Write(1); - writer.Write( (int) Level ); + writer.Write((int)Level); - writer.Write( Title ); + writer.Write(Title); - if ( Greeting != null ) + if (Greeting != null) { - writer.Write( true ); - Greeting.Serialize( writer ); + writer.Write(true); + Greeting.Serialize(writer); } else { - writer.Write( false ); + writer.Write(false); } - writer.WriteEncodedInt( Messages.Count ); + writer.WriteEncodedInt(Messages.Count); - for ( int i = 0; i < Messages.Count; ++i ) - Messages[i].Serialize( writer ); + for (int i = 0; i < Messages.Count; ++i) + Messages[i].Serialize(writer); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); - switch ( version ) + switch (version) { case 1: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 0; + } case 0: - { - if ( version < 1 ) - Level = SecureLevel.Anyone; + { + if (version < 1) + Level = SecureLevel.Anyone; - Title = reader.ReadString(); + Title = reader.ReadString(); - if ( reader.ReadBool() ) - Greeting = new PlayerBBMessage( reader ); + if (reader.ReadBool()) + Greeting = new PlayerBBMessage(reader); - int count = reader.ReadEncodedInt(); + int count = reader.ReadEncodedInt(); - Messages = new List( count ); + Messages = new List(count); - for ( int i = 0; i < count; ++i ) - Messages.Add( new PlayerBBMessage( reader ) ); + for (int i = 0; i < count; ++i) + Messages.Add(new PlayerBBMessage(reader)); - break; - } + break; + } } } - public static bool CheckAccess( BaseHouse house, Mobile from ) + public static bool CheckAccess(BaseHouse house, Mobile from) { - if ( house.Public || !house.IsAosRules ) - return !house.IsBanned( from ); + if (house.Public || !house.IsAosRules) + return !house.IsBanned(from); - return house.HasAccess( from ); + return house.HasAccess(from); } - public override void OnDoubleClick( Mobile from ) + public override void OnDoubleClick(Mobile from) { - BaseHouse house = BaseHouse.FindHouseAt( this ); + BaseHouse house = BaseHouse.FindHouseAt(this); - if ( house?.HasLockedDownItem( this ) != true ) - from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable. - else if ( !from.InRange( GetWorldLocation(), 2 ) || !from.InLOS( this ) ) - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. - else if ( CheckAccess( house, from ) ) - from.SendGump( new PlayerBBGump( from, house, this, 0 ) ); + if (house?.HasLockedDownItem(this) != true) + from.SendLocalizedMessage(1062396); // This bulletin board must be locked down in a house to be usable. + else if (!from.InRange(GetWorldLocation(), 2) || !from.InLOS(this)) + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. + else if (CheckAccess(house, from)) + from.SendGump(new PlayerBBGump(from, house, this, 0)); } public class PostPrompt : Prompt { - private int m_Page; - private BaseHouse m_House; - private BasePlayerBB m_Board; - private bool m_Greeting; + private readonly int m_Page; + private readonly BaseHouse m_House; + private readonly BasePlayerBB m_Board; + private readonly bool m_Greeting; - public PostPrompt( int page, BaseHouse house, BasePlayerBB board, bool greeting ) + public PostPrompt(int page, BaseHouse house, BasePlayerBB board, bool greeting) { m_Page = page; m_House = house; @@ -185,334 +185,334 @@ namespace Server.Items m_Greeting = greeting; } - public override void OnCancel( Mobile from ) + public override void OnCancel(Mobile from) { - OnResponse( from, "" ); + OnResponse(from, ""); } - public override void OnResponse( Mobile from, string text ) + public override void OnResponse(Mobile from, string text) { int page = m_Page; BaseHouse house = m_House; BasePlayerBB board = m_Board; - if ( house?.HasLockedDownItem( board ) != true ) + if (house?.HasLockedDownItem(board) != true) { - from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable. + from.SendLocalizedMessage(1062396); // This bulletin board must be locked down in a house to be usable. return; } - if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) ) + if (!from.InRange(board.GetWorldLocation(), 2) || !from.InLOS(board)) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } - if ( !CheckAccess( house, from ) ) + if (!CheckAccess(house, from)) { - from.SendLocalizedMessage( 1062398 ); // You are not allowed to post to this bulletin board. + from.SendLocalizedMessage(1062398); // You are not allowed to post to this bulletin board. return; } - if ( m_Greeting && !house.IsOwner( from ) ) return; + if (m_Greeting && !house.IsOwner(from)) return; text = text.Trim(); - if ( text.Length > 255 ) - text = text.Substring( 0, 255 ); + if (text.Length > 255) + text = text.Substring(0, 255); - if ( text.Length > 0 ) + if (text.Length > 0) { - PlayerBBMessage message = new PlayerBBMessage( DateTime.UtcNow, from, text ); + PlayerBBMessage message = new PlayerBBMessage(DateTime.UtcNow, from, text); - if ( m_Greeting ) + if (m_Greeting) { board.Greeting = message; } else { - board.Messages.Add( message ); + board.Messages.Add(message); - if ( board.Messages.Count > 50 ) + if (board.Messages.Count > 50) { - board.Messages.RemoveAt( 0 ); + board.Messages.RemoveAt(0); - if ( page > 0 ) + if (page > 0) --page; } } } - from.SendGump( new PlayerBBGump( from, house, board, page ) ); + from.SendGump(new PlayerBBGump(from, house, board, page)); } } public class SetTitlePrompt : Prompt { - private int m_Page; - private BaseHouse m_House; - private BasePlayerBB m_Board; + private readonly int m_Page; + private readonly BaseHouse m_House; + private readonly BasePlayerBB m_Board; - public SetTitlePrompt( int page, BaseHouse house, BasePlayerBB board ) + public SetTitlePrompt(int page, BaseHouse house, BasePlayerBB board) { m_Page = page; m_House = house; m_Board = board; } - public override void OnCancel( Mobile from ) + public override void OnCancel(Mobile from) { - OnResponse( from, "" ); + OnResponse(from, ""); } - public override void OnResponse( Mobile from, string text ) + public override void OnResponse(Mobile from, string text) { int page = m_Page; BaseHouse house = m_House; BasePlayerBB board = m_Board; - if ( house?.HasLockedDownItem( board ) != true ) + if (house?.HasLockedDownItem(board) != true) { - from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable. + from.SendLocalizedMessage(1062396); // This bulletin board must be locked down in a house to be usable. return; } - if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) ) + if (!from.InRange(board.GetWorldLocation(), 2) || !from.InLOS(board)) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } - if ( !CheckAccess( house, from ) ) + if (!CheckAccess(house, from)) { - from.SendLocalizedMessage( 1062398 ); // You are not allowed to post to this bulletin board. + from.SendLocalizedMessage(1062398); // You are not allowed to post to this bulletin board. return; } text = text.Trim(); - if ( text.Length > 255 ) - text = text.Substring( 0, 255 ); + if (text.Length > 255) + text = text.Substring(0, 255); - if ( text.Length > 0 ) + if (text.Length > 0) board.Title = text; - from.SendGump( new PlayerBBGump( from, house, board, page ) ); + from.SendGump(new PlayerBBGump(from, house, board, page)); } } } public class PlayerBBMessage { - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public DateTime Time { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public Mobile Poster { get; set; } - [CommandProperty( AccessLevel.GameMaster )] + [CommandProperty(AccessLevel.GameMaster)] public string Message { get; set; } - public PlayerBBMessage( DateTime time, Mobile poster, string message ) + public PlayerBBMessage(DateTime time, Mobile poster, string message) { Time = time; Poster = poster; Message = message; } - public PlayerBBMessage( IGenericReader reader ) + public PlayerBBMessage(IGenericReader reader) { int version = reader.ReadEncodedInt(); - switch ( version ) + switch (version) { case 0: - { - Time = reader.ReadDateTime(); - Poster = reader.ReadMobile(); - Message = reader.ReadString(); - break; - } + { + Time = reader.ReadDateTime(); + Poster = reader.ReadMobile(); + Message = reader.ReadString(); + break; + } } } - public void Serialize(IGenericWriter writer ) + public void Serialize(IGenericWriter writer) { - writer.WriteEncodedInt( 0 ); // version + writer.WriteEncodedInt(0); // version - writer.Write( Time ); - writer.Write( Poster ); - writer.Write( Message ); + writer.Write(Time); + writer.Write(Poster); + writer.Write(Message); } } public class PlayerBBGump : Gump { - private int m_Page; - private Mobile m_From; - private BaseHouse m_House; - private BasePlayerBB m_Board; + private readonly int m_Page; + private readonly Mobile m_From; + private readonly BaseHouse m_House; + private readonly BasePlayerBB m_Board; private const int LabelColor = 0x7FFF; private const int LabelHue = 1153; - public override void OnResponse( NetState sender, RelayInfo info ) + public override void OnResponse(NetState sender, RelayInfo info) { int page = m_Page; Mobile from = m_From; BaseHouse house = m_House; BasePlayerBB board = m_Board; - if ( house?.HasLockedDownItem( board ) != true ) + if (house?.HasLockedDownItem(board) != true) { - from.SendLocalizedMessage( 1062396 ); // This bulletin board must be locked down in a house to be usable. + from.SendLocalizedMessage(1062396); // This bulletin board must be locked down in a house to be usable. return; } - if ( !from.InRange( board.GetWorldLocation(), 2 ) || !from.InLOS( board ) ) + if (!from.InRange(board.GetWorldLocation(), 2) || !from.InLOS(board)) { - from.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. + from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return; } - if ( !BasePlayerBB.CheckAccess( house, from ) ) + if (!BasePlayerBB.CheckAccess(house, from)) { - from.SendLocalizedMessage( 1062398 ); // You are not allowed to post to this bulletin board. + from.SendLocalizedMessage(1062398); // You are not allowed to post to this bulletin board. return; } - switch ( info.ButtonID ) + switch (info.ButtonID) { case 1: // Post message - { - from.Prompt = new BasePlayerBB.PostPrompt( page, house, board, false ); - from.SendLocalizedMessage( 1062397 ); // Please enter your message: + { + from.Prompt = new BasePlayerBB.PostPrompt(page, house, board, false); + from.SendLocalizedMessage(1062397); // Please enter your message: - break; - } + break; + } case 2: // Set title - { - if ( house.IsOwner( from ) ) { - from.Prompt = new BasePlayerBB.SetTitlePrompt( page, house, board ); - from.SendLocalizedMessage( 1062402 ); // Enter new title: - } - - break; - } - case 3: // Post greeting - { - if ( house.IsOwner( from ) ) - { - from.Prompt = new BasePlayerBB.PostPrompt( page, house, board, true ); - from.SendLocalizedMessage( 1062404 ); // Enter new greeting (this will always be the first post): - } - - break; - } - case 4: // Scroll up - { - if ( page == 0 ) - page = board.Messages.Count; - else - page -= 1; - - from.SendGump( new PlayerBBGump( from, house, board, page ) ); - - break; - } - case 5: // Scroll down - { - page += 1; - page %= board.Messages.Count + 1; - - from.SendGump( new PlayerBBGump( from, house, board, page ) ); - - break; - } - case 6: // Banish poster - { - if ( house.IsOwner( from ) ) - { - if ( page >= 1 && page <= board.Messages.Count ) + if (house.IsOwner(from)) { - PlayerBBMessage message = board.Messages[page - 1]; - Mobile poster = message.Poster; - - if ( poster == null ) - { - from.SendGump( new PlayerBBGump( from, house, board, page ) ); - return; - } - - if ( poster.AccessLevel > AccessLevel.Player && from.AccessLevel <= poster.AccessLevel ) - { - from.SendLocalizedMessage( 501354 ); // Uh oh...a bigger boot may be required. - } - else if ( house.IsFriend( poster ) ) - { - from.SendLocalizedMessage( 1060750 ); // That person is a friend, co-owner, or owner of this house, and therefore cannot be banished! - } - else if ( poster is PlayerVendor ) - { - from.SendLocalizedMessage( 501351 ); // You cannot eject a vendor. - } - else if ( house.Bans.Count >= BaseHouse.MaxBans ) - { - from.SendLocalizedMessage( 501355 ); // The ban limit for this house has been reached! - } - else if ( house.IsBanned( poster ) ) - { - from.SendLocalizedMessage( 501356 ); // This person is already banned! - } - else if ( poster is BaseCreature creature && creature.NoHouseRestrictions ) - { - from.SendLocalizedMessage( 1062040 ); // You cannot ban that. - } - else - { - if ( !house.Bans.Contains( poster ) ) - house.Bans.Add( poster ); - - from.SendLocalizedMessage( 1062417 ); // That person has been banned from this house. - - if ( house.IsInside( poster ) && !BasePlayerBB.CheckAccess( house, poster ) ) - poster.MoveToWorld( house.BanLocation, house.Map ); - } + from.Prompt = new BasePlayerBB.SetTitlePrompt(page, house, board); + from.SendLocalizedMessage(1062402); // Enter new title: } - from.SendGump( new PlayerBBGump( from, house, board, page ) ); + break; } + case 3: // Post greeting + { + if (house.IsOwner(from)) + { + from.Prompt = new BasePlayerBB.PostPrompt(page, house, board, true); + from.SendLocalizedMessage(1062404); // Enter new greeting (this will always be the first post): + } - break; - } + break; + } + case 4: // Scroll up + { + if (page == 0) + page = board.Messages.Count; + else + page -= 1; + + from.SendGump(new PlayerBBGump(from, house, board, page)); + + break; + } + case 5: // Scroll down + { + page += 1; + page %= board.Messages.Count + 1; + + from.SendGump(new PlayerBBGump(from, house, board, page)); + + break; + } + case 6: // Banish poster + { + if (house.IsOwner(from)) + { + if (page >= 1 && page <= board.Messages.Count) + { + PlayerBBMessage message = board.Messages[page - 1]; + Mobile poster = message.Poster; + + if (poster == null) + { + from.SendGump(new PlayerBBGump(from, house, board, page)); + return; + } + + if (poster.AccessLevel > AccessLevel.Player && from.AccessLevel <= poster.AccessLevel) + { + from.SendLocalizedMessage(501354); // Uh oh...a bigger boot may be required. + } + else if (house.IsFriend(poster)) + { + from.SendLocalizedMessage(1060750); // That person is a friend, co-owner, or owner of this house, and therefore cannot be banished! + } + else if (poster is PlayerVendor) + { + from.SendLocalizedMessage(501351); // You cannot eject a vendor. + } + else if (house.Bans.Count >= BaseHouse.MaxBans) + { + from.SendLocalizedMessage(501355); // The ban limit for this house has been reached! + } + else if (house.IsBanned(poster)) + { + from.SendLocalizedMessage(501356); // This person is already banned! + } + else if (poster is BaseCreature creature && creature.NoHouseRestrictions) + { + from.SendLocalizedMessage(1062040); // You cannot ban that. + } + else + { + if (!house.Bans.Contains(poster)) + house.Bans.Add(poster); + + from.SendLocalizedMessage(1062417); // That person has been banned from this house. + + if (house.IsInside(poster) && !BasePlayerBB.CheckAccess(house, poster)) + poster.MoveToWorld(house.BanLocation, house.Map); + } + } + + from.SendGump(new PlayerBBGump(from, house, board, page)); + } + + break; + } case 7: // Delete message - { - if ( house.IsOwner( from ) ) { - if ( page >= 1 && page <= board.Messages.Count ) - board.Messages.RemoveAt( page - 1 ); + if (house.IsOwner(from)) + { + if (page >= 1 && page <= board.Messages.Count) + board.Messages.RemoveAt(page - 1); - from.SendGump( new PlayerBBGump( from, house, board, 0 ) ); + from.SendGump(new PlayerBBGump(from, house, board, 0)); + } + + break; } - - break; - } case 8: // Post props - { - if ( from.AccessLevel >= AccessLevel.GameMaster ) { - PlayerBBMessage message = board.Greeting; + if (from.AccessLevel >= AccessLevel.GameMaster) + { + PlayerBBMessage message = board.Greeting; - if ( page >= 1 && page <= board.Messages.Count ) - message = board.Messages[page - 1]; + if (page >= 1 && page <= board.Messages.Count) + message = board.Messages[page - 1]; - from.SendGump( new PlayerBBGump( from, house, board, page ) ); - from.SendGump( new PropertiesGump( from, message ) ); + from.SendGump(new PlayerBBGump(from, house, board, page)); + from.SendGump(new PropertiesGump(from, message)); + } + + break; } - - break; - } } } - public PlayerBBGump( Mobile from, BaseHouse house, BasePlayerBB board, int page ) : base( 50, 10 ) + public PlayerBBGump(Mobile from, BaseHouse house, BasePlayerBB board, int page) : base(50, 10) { from.CloseGump(); @@ -521,70 +521,70 @@ namespace Server.Items m_House = house; m_Board = board; - AddPage( 0 ); + AddPage(0); - AddImage( 30, 30, 5400 ); + AddImage(30, 30, 5400); - AddButton( 393, 145, 2084, 2084, 4); // Scroll up - AddButton( 390, 371, 2085, 2085, 5); // Scroll down + AddButton(393, 145, 2084, 2084, 4); // Scroll up + AddButton(390, 371, 2085, 2085, 5); // Scroll down - AddButton( 32, 183, 5412, 5413, 1); // Post message + AddButton(32, 183, 5412, 5413, 1); // Post message - if ( house.IsOwner( from ) ) + if (house.IsOwner(from)) { - AddButton( 63, 90, 5601, 5605, 2); - AddHtmlLocalized( 81, 89, 230, 20, 1062400, LabelColor ); // Set title + AddButton(63, 90, 5601, 5605, 2); + AddHtmlLocalized(81, 89, 230, 20, 1062400, LabelColor); // Set title - AddButton( 63, 109, 5601, 5605, 3); - AddHtmlLocalized( 81, 108, 230, 20, 1062401, LabelColor ); // Post greeting + AddButton(63, 109, 5601, 5605, 3); + AddHtmlLocalized(81, 108, 230, 20, 1062401, LabelColor); // Post greeting } string title = board.Title; - if ( title != null ) - AddHtml( 183, 68, 180, 23, title ); + if (title != null) + AddHtml(183, 68, 180, 23, title); - AddHtmlLocalized( 385, 89, 60, 20, 1062409, LabelColor ); // Post + AddHtmlLocalized(385, 89, 60, 20, 1062409, LabelColor); // Post - AddLabel( 440, 89, LabelHue, page.ToString() ); - AddLabel( 455, 89, LabelHue, "/" ); - AddLabel( 470, 89, LabelHue, board.Messages.Count.ToString() ); + AddLabel(440, 89, LabelHue, page.ToString()); + AddLabel(455, 89, LabelHue, "/"); + AddLabel(470, 89, LabelHue, board.Messages.Count.ToString()); PlayerBBMessage message = board.Greeting; - if ( page >= 1 && page <= board.Messages.Count ) + if (page >= 1 && page <= board.Messages.Count) message = board.Messages[page - 1]; - AddImageTiled( 150, 220, 240, 1, 2700 ); // Separator + AddImageTiled(150, 220, 240, 1, 2700); // Separator - AddHtmlLocalized( 150, 180, 100, 20, 1062405, 16715 ); // Posted On: - AddHtmlLocalized( 150, 200, 100, 20, 1062406, 16715 ); // Posted By: + AddHtmlLocalized(150, 180, 100, 20, 1062405, 16715); // Posted On: + AddHtmlLocalized(150, 200, 100, 20, 1062406, 16715); // Posted By: - if ( message != null ) + if (message != null) { - AddHtml( 255, 180, 150, 20, message.Time.ToString( "yyyy-MM-dd HH:mm:ss" ) ); + AddHtml(255, 180, 150, 20, message.Time.ToString("yyyy-MM-dd HH:mm:ss")); Mobile poster = message.Poster; string name = poster?.Name; - if ( name == null || (name = name.Trim()).Length == 0 ) + if (name == null || (name = name.Trim()).Length == 0) name = "Someone"; - AddHtml( 255, 200, 150, 20, name ); + AddHtml(255, 200, 150, 20, name); - AddHtml( 150, 240, 250, 100, message.Message ?? "" ); + AddHtml(150, 240, 250, 100, message.Message ?? ""); - if ( message != board.Greeting && house.IsOwner( from ) ) + if (message != board.Greeting && house.IsOwner(from)) { - AddButton( 130, 395, 1209, 1210, 6); - AddHtmlLocalized( 150, 393, 150, 20, 1062410, LabelColor ); // Banish Poster + AddButton(130, 395, 1209, 1210, 6); + AddHtmlLocalized(150, 393, 150, 20, 1062410, LabelColor); // Banish Poster - AddButton( 310, 395, 1209, 1210, 7); - AddHtmlLocalized( 330, 393, 150, 20, 1062411, LabelColor ); // Delete Message + AddButton(310, 395, 1209, 1210, 7); + AddHtmlLocalized(330, 393, 150, 20, 1062411, LabelColor); // Delete Message } - if ( from.AccessLevel >= AccessLevel.GameMaster ) - AddButton( 135, 242, 1209, 1210, 8); // Post props + if (from.AccessLevel >= AccessLevel.GameMaster) + AddButton(135, 242, 1209, 1210, 8); // Post props } } } diff --git a/Projects/Scripts/Items/Misc/PlayerVendorDeed.cs b/Projects/Scripts/Items/Misc/PlayerVendorDeed.cs index 14979225d..d1d964159 100644 --- a/Projects/Scripts/Items/Misc/PlayerVendorDeed.cs +++ b/Projects/Scripts/Items/Misc/PlayerVendorDeed.cs @@ -18,7 +18,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Items/Misc/PoolOfAcid.cs b/Projects/Scripts/Items/Misc/PoolOfAcid.cs index 0c1255a52..e12156ecb 100644 --- a/Projects/Scripts/Items/Misc/PoolOfAcid.cs +++ b/Projects/Scripts/Items/Misc/PoolOfAcid.cs @@ -1,28 +1,28 @@ using System; -using Server.Mobiles; using System.Collections.Generic; +using Server.Mobiles; namespace Server.Items { public class PoolOfAcid : Item { - private TimeSpan m_Duration; - private int m_MinDamage; - private int m_MaxDamage; - private DateTime m_Created; + private readonly TimeSpan m_Duration; + private readonly int m_MinDamage; + private readonly int m_MaxDamage; + private readonly DateTime m_Created; private bool m_Drying; - private Timer m_Timer; + private readonly Timer m_Timer; [Constructible] - public PoolOfAcid() : this( TimeSpan.FromSeconds( 10.0 ), 2, 5 ) + public PoolOfAcid() : this(TimeSpan.FromSeconds(10.0), 2, 5) { } public override string DefaultName => "a pool of acid"; [Constructible] - public PoolOfAcid( TimeSpan duration, int minDamage, int maxDamage ) - : base( 0x122A ) + public PoolOfAcid(TimeSpan duration, int minDamage, int maxDamage) + : base(0x122A) { Hue = 0x3F; Movable = false; @@ -32,7 +32,7 @@ namespace Server.Items m_Created = DateTime.UtcNow; m_Duration = duration; - m_Timer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 1 ), OnTick ); + m_Timer = Timer.DelayCall(TimeSpan.Zero, TimeSpan.FromSeconds(1), OnTick); } public override void OnAfterDelete() @@ -45,10 +45,13 @@ namespace Server.Items DateTime now = DateTime.UtcNow; TimeSpan age = now - m_Created; - if ( age > m_Duration ) { + if (age > m_Duration) + { Delete(); - } else { - if ( !m_Drying && age > m_Duration - age ) + } + else + { + if (!m_Drying && age > m_Duration - age) { m_Drying = true; ItemID = 0x122B; @@ -56,35 +59,35 @@ namespace Server.Items List toDamage = new List(); - foreach( Mobile m in GetMobilesInRange( 0 ) ) - if ( m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned) ) - toDamage.Add( m ); + foreach (Mobile m in GetMobilesInRange(0)) + if (m.Alive && !m.IsDeadBondedPet && (!(m is BaseCreature bc) || bc.Controlled || bc.Summoned)) + toDamage.Add(m); - for ( int i = 0; i < toDamage.Count; i++ ) - Damage( toDamage[i] ); + for (int i = 0; i < toDamage.Count; i++) + Damage(toDamage[i]); } } - public override bool OnMoveOver( Mobile m ) + public override bool OnMoveOver(Mobile m) { - Damage( m ); + Damage(m); return true; } - public void Damage ( Mobile m ) + public void Damage(Mobile m) { - m.Damage( Utility.RandomMinMax( m_MinDamage, m_MaxDamage ) ); + m.Damage(Utility.RandomMinMax(m_MinDamage, m_MaxDamage)); } - public PoolOfAcid( Serial serial ) : base( serial ) + public PoolOfAcid(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - //Don't serialize these + // Don't serialize these } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { } } diff --git a/Projects/Scripts/Items/Misc/PowerGenerator.cs b/Projects/Scripts/Items/Misc/PowerGenerator.cs index 9bb157aa6..a587cd0d8 100644 --- a/Projects/Scripts/Items/Misc/PowerGenerator.cs +++ b/Projects/Scripts/Items/Misc/PowerGenerator.cs @@ -57,7 +57,7 @@ namespace Server.Items { private static readonly TimeSpan m_UseTimeout = TimeSpan.FromMinutes(2.0); - private HashSet m_DamageTable = new HashSet(); + private readonly HashSet m_DamageTable = new HashSet(); private DateTime m_LastUse; private int m_SideLength; @@ -94,7 +94,7 @@ namespace Server.Items } } - public Node[] Path{ get; private set; } + public Node[] Path { get; private set; } public override string DefaultName => "a control panel"; @@ -275,9 +275,9 @@ namespace Server.Items public struct Node { - public int X{ get; set; } + public int X { get; set; } - public int Y{ get; set; } + public int Y { get; set; } public Node(int x, int y) { @@ -296,10 +296,10 @@ namespace Server.Items private class GameGump : Gump { - private Mobile m_From; + private readonly Mobile m_From; - private ControlPanel m_Panel; - private int m_Step; + private readonly ControlPanel m_Panel; + private readonly int m_Step; public GameGump(ControlPanel panel, Mobile from, int step, bool hint) : base(5, 30) { @@ -341,12 +341,12 @@ namespace Server.Items AddBackground(100, 125, 10 + 40 * sideLength, 10 + 40 * sideLength, 0x1400); for (int i = 0; i < sideLength; i++) - for (int j = 0; j < sideLength - 1; j++) - AddImage(120 + 40 * i, 162 + 40 * j, 0x13F9); + for (int j = 0; j < sideLength - 1; j++) + AddImage(120 + 40 * i, 162 + 40 * j, 0x13F9); for (int i = 0; i < sideLength - 1; i++) - for (int j = 0; j < sideLength; j++) - AddImage(138 + 40 * i, 147 + 40 * j, 0x13FD); + for (int j = 0; j < sideLength; j++) + AddImage(138 + 40 * i, 147 + 40 * j, 0x13FD); Node[] path = panel.Path; @@ -362,8 +362,8 @@ namespace Server.Items hues[lastNode.X, lastNode.Y] = NodeHue.Red; for (int i = 0; i < sideLength; i++) - for (int j = 0; j < sideLength; j++) - AddNode(110 + 40 * i, 135 + 40 * j, hues[i, j]); + for (int j = 0; j < sideLength; j++) + AddNode(110 + 40 * i, 135 + 40 * j, hues[i, j]); Node curNode = path[step]; AddImage(118 + 40 * curNode.X, 143 + 40 * curNode.Y, 0x13A8); @@ -490,9 +490,9 @@ namespace Server.Items private class DamageTimer : Timer { - private ControlPanel m_Panel; + private readonly ControlPanel m_Panel; private int m_Step; - private Mobile m_To; + private readonly Mobile m_To; public DamageTimer(ControlPanel panel, Mobile to) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) { diff --git a/Projects/Scripts/Items/Misc/PromotionalToken.cs b/Projects/Scripts/Items/Misc/PromotionalToken.cs index 050764052..858b75ced 100644 --- a/Projects/Scripts/Items/Misc/PromotionalToken.cs +++ b/Projects/Scripts/Items/Misc/PromotionalToken.cs @@ -5,40 +5,40 @@ namespace Server.Items { public abstract class PromotionalToken : Item { - public abstract Item CreateItemFor( Mobile from ); + public abstract Item CreateItemFor(Mobile from); - public abstract TextDefinition ItemName{ get; } + public abstract TextDefinition ItemName { get; } public abstract TextDefinition ItemReceiveMessage { get; } public abstract TextDefinition ItemGumpName { get; } - public PromotionalToken() : base( 0x2AAA ) + public PromotionalToken() : base(0x2AAA) { LootType = LootType.Blessed; Light = LightType.Circle300; Weight = 5.0; } - public PromotionalToken( Serial serial ) : base( serial ) + public PromotionalToken(Serial serial) : base(serial) { } - public override void GetProperties( ObjectPropertyList list ) + public override void GetProperties(ObjectPropertyList list) { - base.GetProperties( list ); + base.GetProperties(list); - list.Add( 1070998, ItemName.ToString() ); // Use this to redeem
your ~1_PROMO~ + list.Add(1070998, ItemName.ToString()); // Use this to redeem
your ~1_PROMO~ } - public override void OnDoubleClick( Mobile from ) + public override void OnDoubleClick(Mobile from) { - if ( !IsChildOf( from.Backpack ) ) + if (!IsChildOf(from.Backpack)) { - from.SendLocalizedMessage( 1062334 ); // This item must be in your backpack to be used. + from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used. } else { from.CloseGump(); - from.SendGump( new PromotionalTokenGump( this ) ); + from.SendGump(new PromotionalTokenGump(this)); } } @@ -46,68 +46,67 @@ namespace Server.Items { Mobile m = null; - if ( parent is Item item ) + if (parent is Item item) m = item.RootParent as Mobile; - else if ( parent is Mobile mobile ) + else if (parent is Mobile mobile) m = mobile; m?.CloseGump(); } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); + writer.Write(0); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } public override int LabelNumber => 1070997; // A promotional token - private class PromotionalTokenGump : Gump { - private PromotionalToken m_Token; + private readonly PromotionalToken m_Token; - public PromotionalTokenGump( PromotionalToken token ) : base( 10, 10 ) + public PromotionalTokenGump(PromotionalToken token) : base(10, 10) { m_Token = token; - AddPage( 0 ); + AddPage(0); - AddBackground( 0, 0, 240, 135, 0x2422 ); - AddHtmlLocalized( 15, 15, 210, 75, 1070972, 0x0, true ); // Click "OKAY" to redeem the following promotional item: - TextDefinition.AddHtmlText( this, 15, 60, 210, 75, m_Token.ItemGumpName, false, false ); + AddBackground(0, 0, 240, 135, 0x2422); + AddHtmlLocalized(15, 15, 210, 75, 1070972, 0x0, true); // Click "OKAY" to redeem the following promotional item: + TextDefinition.AddHtmlText(this, 15, 60, 210, 75, m_Token.ItemGumpName, false, false); - AddButton( 160, 95, 0xF7, 0xF8, 1); //Okay - AddButton( 90, 95, 0xF2, 0xF1, 0); //Cancel + AddButton(160, 95, 0xF7, 0xF8, 1); // Okay + AddButton(90, 95, 0xF2, 0xF1, 0); // Cancel } - public override void OnResponse( NetState sender, RelayInfo info ) + public override void OnResponse(NetState sender, RelayInfo info) { - if ( info.ButtonID != 1 ) + if (info.ButtonID != 1) return; Mobile from = sender.Mobile; - if ( !m_Token.IsChildOf( from.Backpack ) ) + if (!m_Token.IsChildOf(from.Backpack)) { - from.SendLocalizedMessage( 1062334 ); // This item must be in your backpack to be used. + from.SendLocalizedMessage(1062334); // This item must be in your backpack to be used. } else { - Item i = m_Token.CreateItemFor( from ); + Item i = m_Token.CreateItemFor(from); - if ( i != null ) + if (i != null) { - from.BankBox.AddItem( i ); - TextDefinition.SendMessageTo( from, m_Token.ItemReceiveMessage ); + from.BankBox.AddItem(i); + TextDefinition.SendMessageTo(from, m_Token.ItemReceiveMessage); m_Token.Delete(); } } @@ -117,17 +116,16 @@ namespace Server.Items public class SoulstoneFragmentToken : PromotionalToken { - - public override Item CreateItemFor( Mobile from ) +public override Item CreateItemFor(Mobile from) { - if ( from?.Account != null ) - return new SoulstoneFragment( from.Account.ToString() ); + if (from?.Account != null) + return new SoulstoneFragment(from.Account.ToString()); return null; } public override TextDefinition ItemGumpName => 1070999;//
Soulstone Fragment
- public override TextDefinition ItemName => 1071000;//soulstone fragment + public override TextDefinition ItemName => 1071000;// soulstone fragment public override TextDefinition ItemReceiveMessage => 1070976; // A soulstone fragment has been created in your bank box. [Constructible] @@ -135,20 +133,20 @@ namespace Server.Items { } - public SoulstoneFragmentToken( Serial serial ) : base( serial ) + public SoulstoneFragmentToken(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); + writer.Write(0); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } diff --git a/Projects/Scripts/Items/Misc/PublicMoongate.cs b/Projects/Scripts/Items/Misc/PublicMoongate.cs index 4b6f438eb..7ddb7c86b 100644 --- a/Projects/Scripts/Items/Misc/PublicMoongate.cs +++ b/Projects/Scripts/Items/Misc/PublicMoongate.cs @@ -156,9 +156,9 @@ namespace Server.Items Number = number; } - public Point3D Location{ get; } + public Point3D Location { get; } - public int Number{ get; } + public int Number { get; } } public class PMList @@ -241,20 +241,20 @@ namespace Server.Items Entries = entries; } - public int Number{ get; } + public int Number { get; } - public int SelNumber{ get; } + public int SelNumber { get; } - public Map Map{ get; } + public Map Map { get; } - public PMEntry[] Entries{ get; } + public PMEntry[] Entries { get; } } public class MoongateGump : Gump { - private PMList[] m_Lists; - private Mobile m_Mobile; - private Item m_Moongate; + private readonly PMList[] m_Lists; + private readonly Mobile m_Mobile; + private readonly Item m_Moongate; public MoongateGump(Mobile mobile, Item moongate) : base(100, 100) { diff --git a/Projects/Scripts/Items/Misc/Rares.cs b/Projects/Scripts/Items/Misc/Rares.cs index 97dc724ed..16fddbffd 100644 --- a/Projects/Scripts/Items/Misc/Rares.cs +++ b/Projects/Scripts/Items/Misc/Rares.cs @@ -10,7 +10,6 @@ namespace Server.Items Amount = amount; } - public Rope(Serial serial) : base(serial) { } @@ -40,7 +39,6 @@ namespace Server.Items Amount = amount; } - public IronWire(Serial serial) : base(serial) { } @@ -73,7 +71,6 @@ namespace Server.Items Amount = amount; } - public SilverWire(Serial serial) : base(serial) { } @@ -106,7 +103,6 @@ namespace Server.Items Amount = amount; } - public GoldWire(Serial serial) : base(serial) { } @@ -139,7 +135,6 @@ namespace Server.Items Amount = amount; } - public CopperWire(Serial serial) : base(serial) { } @@ -172,7 +167,6 @@ namespace Server.Items Amount = amount; } - public WhiteDriedFlowers(Serial serial) : base(serial) { } @@ -202,7 +196,6 @@ namespace Server.Items Amount = amount; } - public GreenDriedFlowers(Serial serial) : base(serial) { } @@ -232,7 +225,6 @@ namespace Server.Items Amount = amount; } - public DriedOnions(Serial serial) : base(serial) { } @@ -262,7 +254,6 @@ namespace Server.Items Amount = amount; } - public DriedHerbs(Serial serial) : base(serial) { } diff --git a/Projects/Scripts/Items/Misc/Scales.cs b/Projects/Scripts/Items/Misc/Scales.cs index 53aed8594..75ec10342 100644 --- a/Projects/Scripts/Items/Misc/Scales.cs +++ b/Projects/Scripts/Items/Misc/Scales.cs @@ -33,7 +33,7 @@ namespace Server.Items private class InternalTarget : Target { - private Scales m_Item; + private readonly Scales m_Item; public InternalTarget(Scales item) : base(1, false, TargetFlags.None) => m_Item = item; @@ -49,7 +49,7 @@ namespace Server.Items { IEntity root = item.RootParent; - if (root != null && root != from || item.Parent == from) + if ((root != null && root != from) || item.Parent == from) { message = "You decide that item's current location is too awkward to get an accurate result."; } diff --git a/Projects/Scripts/Items/Misc/SerpentPillar.cs b/Projects/Scripts/Items/Misc/SerpentPillar.cs index e015a2e15..7e66f60f4 100644 --- a/Projects/Scripts/Items/Misc/SerpentPillar.cs +++ b/Projects/Scripts/Items/Misc/SerpentPillar.cs @@ -23,13 +23,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool Active{ get; set; } + public bool Active { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string Word{ get; set; } + public string Word { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Rectangle2D Destination{ get; set; } + public Rectangle2D Destination { get; set; } public override bool HandlesOnSpeech => true; diff --git a/Projects/Scripts/Items/Misc/SpecialBeardDye.cs b/Projects/Scripts/Items/Misc/SpecialBeardDye.cs index c2cae8985..338ca14d7 100644 --- a/Projects/Scripts/Items/Misc/SpecialBeardDye.cs +++ b/Projects/Scripts/Items/Misc/SpecialBeardDye.cs @@ -48,7 +48,7 @@ namespace Server.Items public class SpecialBeardDyeGump : Gump { - private static SpecialBeardDyeEntry[] m_Entries = + private static readonly SpecialBeardDyeEntry[] m_Entries = { new SpecialBeardDyeEntry("*****", 12, 10), new SpecialBeardDyeEntry("*****", 32, 5), @@ -60,7 +60,7 @@ namespace Server.Items new SpecialBeardDyeEntry("*****", 1153, 2) }; - private SpecialBeardDye m_SpecialBeardDye; + private readonly SpecialBeardDye m_SpecialBeardDye; public SpecialBeardDyeGump(SpecialBeardDye dye) : base(0, 0) { @@ -103,7 +103,7 @@ namespace Server.Items if (!m_SpecialBeardDye.IsChildOf(m.Backpack)) { - m.SendLocalizedMessage(1042010); //You must have the objectin your backpack to use it. + m.SendLocalizedMessage(1042010); // You must have the objectin your backpack to use it. return; } @@ -152,11 +152,11 @@ namespace Server.Items HueCount = hueCount; } - public string Name{ get; } + public string Name { get; } - public int HueStart{ get; } + public int HueStart { get; } - public int HueCount{ get; } + public int HueCount { get; } } } } diff --git a/Projects/Scripts/Items/Misc/SpecialHairDye.cs b/Projects/Scripts/Items/Misc/SpecialHairDye.cs index ae47d905e..643e6d2ad 100644 --- a/Projects/Scripts/Items/Misc/SpecialHairDye.cs +++ b/Projects/Scripts/Items/Misc/SpecialHairDye.cs @@ -48,7 +48,7 @@ namespace Server.Items public class SpecialHairDyeGump : Gump { - private static SpecialHairDyeEntry[] m_Entries = + private static readonly SpecialHairDyeEntry[] m_Entries = { new SpecialHairDyeEntry("*****", 12, 10), new SpecialHairDyeEntry("*****", 32, 5), @@ -60,7 +60,7 @@ namespace Server.Items new SpecialHairDyeEntry("*****", 1153, 2) }; - private SpecialHairDye m_SpecialHairDye; + private readonly SpecialHairDye m_SpecialHairDye; public SpecialHairDyeGump(SpecialHairDye dye) : base(0, 0) { @@ -103,7 +103,7 @@ namespace Server.Items if (!m_SpecialHairDye.IsChildOf(m.Backpack)) { - m.SendLocalizedMessage(1042010); //You must have the objectin your backpack to use it. + m.SendLocalizedMessage(1042010); // You must have the objectin your backpack to use it. return; } @@ -153,11 +153,11 @@ namespace Server.Items HueCount = hueCount; } - public string Name{ get; } + public string Name { get; } - public int HueStart{ get; } + public int HueStart { get; } - public int HueCount{ get; } + public int HueCount { get; } } } } diff --git a/Projects/Scripts/Items/Misc/Static.cs b/Projects/Scripts/Items/Misc/Static.cs index ea96a3398..0472d7b82 100644 --- a/Projects/Scripts/Items/Misc/Static.cs +++ b/Projects/Scripts/Items/Misc/Static.cs @@ -80,10 +80,10 @@ namespace Server.Items switch (version) { case 0: - { - m_LabelNumber = reader.ReadEncodedInt(); - break; - } + { + m_LabelNumber = reader.ReadEncodedInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Misc/Teleporter.cs b/Projects/Scripts/Items/Misc/Teleporter.cs index 6ea179586..078ac25ae 100644 --- a/Projects/Scripts/Items/Misc/Teleporter.cs +++ b/Projects/Scripts/Items/Misc/Teleporter.cs @@ -286,38 +286,38 @@ namespace Server.Items switch (version) { case 4: - { - m_CriminalCheck = reader.ReadBool(); - goto case 3; - } + { + m_CriminalCheck = reader.ReadBool(); + goto case 3; + } case 3: - { - m_CombatCheck = reader.ReadBool(); - goto case 2; - } + { + m_CombatCheck = reader.ReadBool(); + goto case 2; + } case 2: - { - m_SourceEffect = reader.ReadBool(); - m_DestEffect = reader.ReadBool(); - m_Delay = reader.ReadTimeSpan(); - m_SoundID = reader.ReadEncodedInt(); + { + m_SourceEffect = reader.ReadBool(); + m_DestEffect = reader.ReadBool(); + m_Delay = reader.ReadTimeSpan(); + m_SoundID = reader.ReadEncodedInt(); - goto case 1; - } + goto case 1; + } case 1: - { - m_Creatures = reader.ReadBool(); + { + m_Creatures = reader.ReadBool(); - goto case 0; - } + goto case 0; + } case 0: - { - m_Active = reader.ReadBool(); - m_PointDest = reader.ReadPoint3D(); - m_MapDest = reader.ReadMap(); + { + m_Active = reader.ReadBool(); + m_PointDest = reader.ReadPoint3D(); + m_MapDest = reader.ReadMap(); - break; - } + break; + } } } } @@ -451,14 +451,14 @@ namespace Server.Items switch (version) { case 0: - { - m_Skill = (SkillName)reader.ReadInt(); - m_Required = reader.ReadDouble(); - m_MessageString = reader.ReadString(); - m_MessageNumber = reader.ReadInt(); + { + m_Skill = (SkillName)reader.ReadInt(); + m_Required = reader.ReadDouble(); + m_MessageString = reader.ReadString(); + m_MessageNumber = reader.ReadInt(); - break; - } + break; + } } } } @@ -583,13 +583,13 @@ namespace Server.Items switch (version) { case 0: - { - m_Substring = reader.ReadString(); - m_Keyword = reader.ReadInt(); - m_Range = reader.ReadInt(); + { + m_Substring = reader.ReadString(); + m_Keyword = reader.ReadInt(); + m_Range = reader.ReadInt(); - break; - } + break; + } } } } @@ -609,19 +609,19 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int StartNumber{ get; set; } + public int StartNumber { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string StartMessage{ get; set; } + public string StartMessage { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ProgressNumber{ get; set; } + public int ProgressNumber { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string ProgressMessage{ get; set; } + public string ProgressMessage { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool ShowTimeRemaining{ get; set; } + public bool ShowTimeRemaining { get; set; } public static void Initialize() { @@ -739,9 +739,9 @@ namespace Server.Items Timer = t; } - public WaitTeleporter Teleporter{ get; } + public WaitTeleporter Teleporter { get; } - public Timer Timer{ get; } + public Timer Timer { get; } } } @@ -765,7 +765,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan TimeoutDelay{ get; set; } + public TimeSpan TimeoutDelay { get; set; } public void StartTimer(Mobile m) { @@ -864,7 +864,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public TimeoutTeleporter Teleporter{ get; set; } + public TimeoutTeleporter Teleporter { get; set; } public override string DefaultName => "timeout teleporter goal"; @@ -1022,7 +1022,7 @@ namespace Server.Items } if (GetFlag(ConditionFlag.DenyFollowers) && - (m.Followers != 0 || m is PlayerMobile mobile && mobile.AutoStabled.Count != 0)) + (m.Followers != 0 || (m is PlayerMobile mobile && mobile.AutoStabled.Count != 0))) { m.SendLocalizedMessage(1077250); // No pets permitted beyond this point. return false; @@ -1039,7 +1039,7 @@ namespace Server.Items } if (GetFlag(ConditionFlag.DenyPackEthereals) && - pack.FindItemByType(new []{typeof(EtherealMount), typeof(BaseImprisonedMobile)}) != null) + pack.FindItemByType(new[] { typeof(EtherealMount), typeof(BaseImprisonedMobile) }) != null) { m.SendMessage("You must empty your backpack of ethereal mounts before proceeding."); return false; @@ -1061,14 +1061,14 @@ namespace Server.Items case Layer.Backpack: case Layer.Mount: case Layer.Bank: - { - continue; // ignore - } + { + continue; // ignore + } default: - { - m.SendMessage("You must remove all of your equipment before proceeding."); - return false; - } + { + m.SendMessage("You must remove all of your equipment before proceeding."); + return false; + } } if (GetFlag(ConditionFlag.DenyTransformed) && m.IsBodyMod) diff --git a/Projects/Scripts/Items/Misc/TrashBarrel.cs b/Projects/Scripts/Items/Misc/TrashBarrel.cs index 575a1e4ce..bac195841 100644 --- a/Projects/Scripts/Items/Misc/TrashBarrel.cs +++ b/Projects/Scripts/Items/Misc/TrashBarrel.cs @@ -5,7 +5,7 @@ using Server.Network; namespace Server.Items { - public class TrashBarrel : Container, IChopable + public class TrashBarrel : Container, IChoppable { private Timer m_Timer; @@ -130,7 +130,7 @@ namespace Server.Items private class EmptyTimer : Timer { - private TrashBarrel m_Barrel; + private readonly TrashBarrel m_Barrel; public EmptyTimer(TrashBarrel barrel) : base(TimeSpan.FromMinutes(3.0)) { diff --git a/Projects/Scripts/Items/Misc/TribalBerry.cs b/Projects/Scripts/Items/Misc/TribalBerry.cs index 9323c3771..5517d6a8a 100644 --- a/Projects/Scripts/Items/Misc/TribalBerry.cs +++ b/Projects/Scripts/Items/Misc/TribalBerry.cs @@ -17,7 +17,6 @@ namespace Server.Items public override int LabelNumber => 1040001; // tribal berry - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Misc/UnholyBone.cs b/Projects/Scripts/Items/Misc/UnholyBone.cs index 4cb966de2..e792efff8 100644 --- a/Projects/Scripts/Items/Misc/UnholyBone.cs +++ b/Projects/Scripts/Items/Misc/UnholyBone.cs @@ -28,7 +28,7 @@ namespace Server.Items Effects.PlaySound(GetWorldLocation(), Map, 0x48F); Effects.SendLocationEffect(GetWorldLocation(), Map, 0x3728, 10, 10, 0, 0); - if (0.3 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.3) { if (ItemID == 0xF7E) from.SendMessage("You destroy the bone."); @@ -71,7 +71,7 @@ namespace Server.Items private class SpawnTimer : Timer { - private Item m_Item; + private readonly Item m_Item; public SpawnTimer(Item item) : base(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 10))) { diff --git a/Projects/Scripts/Items/Misc/WarningItem.cs b/Projects/Scripts/Items/Misc/WarningItem.cs index fba9ea6af..f7c24dddf 100644 --- a/Projects/Scripts/Items/Misc/WarningItem.cs +++ b/Projects/Scripts/Items/Misc/WarningItem.cs @@ -40,10 +40,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string WarningString{ get; set; } + public string WarningString { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int WarningNumber{ get; set; } + public int WarningNumber { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Range @@ -57,7 +57,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan ResetDelay{ get; set; } + public TimeSpan ResetDelay { get; set; } public virtual bool OnlyToTriggerer => false; public virtual int NeighborRange => 5; @@ -142,14 +142,14 @@ namespace Server.Items switch (version) { case 0: - { - WarningString = reader.ReadString(); - WarningNumber = reader.ReadInt(); - m_Range = reader.ReadInt(); - ResetDelay = reader.ReadTimeSpan(); + { + WarningString = reader.ReadString(); + WarningNumber = reader.ReadInt(); + m_Range = reader.ReadInt(); + ResetDelay = reader.ReadTimeSpan(); - break; - } + break; + } } } } @@ -167,10 +167,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string HintString{ get; set; } + public string HintString { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int HintNumber{ get; set; } + public int HintNumber { get; set; } public override bool OnlyToTriggerer => true; @@ -198,12 +198,12 @@ namespace Server.Items switch (version) { case 0: - { - HintString = reader.ReadString(); - HintNumber = reader.ReadInt(); + { + HintString = reader.ReadString(); + HintNumber = reader.ReadInt(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Misc/Waypoint.cs b/Projects/Scripts/Items/Misc/Waypoint.cs index 256facf8c..581c0d2e8 100644 --- a/Projects/Scripts/Items/Misc/Waypoint.cs +++ b/Projects/Scripts/Items/Misc/Waypoint.cs @@ -12,7 +12,7 @@ namespace Server.Items { Hue = 0x498; Visible = false; - //this.Movable = false; + // this.Movable = false; if (prev != null) prev.NextPoint = this; } @@ -74,10 +74,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Next = reader.ReadItem() as WayPoint; - break; - } + { + m_Next = reader.ReadItem() as WayPoint; + break; + } } } @@ -93,7 +93,7 @@ namespace Server.Items public class NextPointTarget : Target { - private WayPoint m_Point; + private readonly WayPoint m_Point; public NextPointTarget(WayPoint pt) : base(-1, false, TargetFlags.None) => m_Point = pt; @@ -108,7 +108,7 @@ namespace Server.Items public class WayPointSeqTarget : Target { - private WayPoint m_Last; + private readonly WayPoint m_Last; public WayPointSeqTarget(WayPoint last) : base(-1, true, TargetFlags.None) => m_Last = last; diff --git a/Projects/Scripts/Items/Misc/WindChimes.cs b/Projects/Scripts/Items/Misc/WindChimes.cs index 98544f490..eade32de0 100644 --- a/Projects/Scripts/Items/Misc/WindChimes.cs +++ b/Projects/Scripts/Items/Misc/WindChimes.cs @@ -27,7 +27,7 @@ namespace Server.Items } } - public static int[] Sounds{ get; } = { 0x505, 0x506, 0x507 }; + public static int[] Sounds { get; } = { 0x505, 0x506, 0x507 }; public override bool HandlesOnMovement => m_TurnedOn && IsLockedDown; @@ -78,16 +78,16 @@ namespace Server.Items switch (version) { case 0: - { - m_TurnedOn = reader.ReadBool(); - break; - } + { + m_TurnedOn = reader.ReadBool(); + break; + } } } private class OnOffGump : Gump { - private BaseWindChimes m_Chimes; + private readonly BaseWindChimes m_Chimes; public OnOffGump(BaseWindChimes chimes) : base(150, 200) { diff --git a/Projects/Scripts/Items/New Haven Quest Rewards/HammerOfHephaestus.cs b/Projects/Scripts/Items/New Haven Quest Rewards/HammerOfHephaestus.cs index c47376f0c..77242a8c7 100644 --- a/Projects/Scripts/Items/New Haven Quest Rewards/HammerOfHephaestus.cs +++ b/Projects/Scripts/Items/New Haven Quest Rewards/HammerOfHephaestus.cs @@ -33,8 +33,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (!IsChildOf(from.Backpack) && Parent != from - ) // TODO: These checks don't match EA, but they match BaseTool for now + if (!IsChildOf(from.Backpack) && Parent != from) // TODO: These checks don't match EA, but they match BaseTool for now from.SendLocalizedMessage(1042001); // That must be in your pack for you to use it. else if (UsesRemaining <= 0) from.SendLocalizedMessage(1072306); // You must wait a moment for it to recharge. @@ -45,7 +44,7 @@ namespace Server.Items private void StartRechargeTimer() { // TODO: Needs work - //Timer.DelayCall( RechargeDelay, RechargeDelay, new TimerCallback( Recharge ) ); + // Timer.DelayCall( RechargeDelay, RechargeDelay, new TimerCallback( Recharge ) ); } public void Recharge() diff --git a/Projects/Scripts/Items/Quivers/BaseQuiver.cs b/Projects/Scripts/Items/Quivers/BaseQuiver.cs index 0d4710578..e8f5643a9 100644 --- a/Projects/Scripts/Items/Quivers/BaseQuiver.cs +++ b/Projects/Scripts/Items/Quivers/BaseQuiver.cs @@ -5,7 +5,7 @@ namespace Server.Items { public class BaseQuiver : Container, ICraftable { - private static Type[] m_Ammo = + private static readonly Type[] m_Ammo = { typeof(Arrow), typeof(Bolt) }; @@ -39,7 +39,7 @@ namespace Server.Items public override double DefaultWeight => 2.0; [CommandProperty(AccessLevel.GameMaster)] - public AosAttributes Attributes{ get; private set; } + public AosAttributes Attributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public int Capacity @@ -109,8 +109,6 @@ namespace Server.Items public Item Ammo => Items.Count > 0 ? Items[0] : null; - #region ICraftable - public virtual int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -122,8 +120,6 @@ namespace Server.Items return quality; } - #endregion - public override void OnAfterDuped(Item newItem) { if (!(newItem is BaseQuiver quiver)) @@ -172,9 +168,9 @@ namespace Server.Items public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { if (CheckType(item)) - return Items.Count >= DefaultMaxItems && !checkItems && Ammo?.Deleted == false && - Ammo.Amount + item.Amount <= m_Capacity || item.Amount <= m_Capacity && - base.CheckHold(m, item, message, checkItems, plusItems, plusWeight); + return (Items.Count >= DefaultMaxItems && !checkItems && Ammo?.Deleted == false && + Ammo.Amount + item.Amount <= m_Capacity) || (item.Amount <= m_Capacity && + base.CheckHold(m, item, message, checkItems, plusItems, plusWeight)); if (message) m.SendLocalizedMessage(1074836); // The container can not hold that type of object. diff --git a/Projects/Scripts/Items/Resources/Arrows/Arrow.cs b/Projects/Scripts/Items/Resources/Arrows/Arrow.cs index 5808e9e1d..fdefaee2e 100644 --- a/Projects/Scripts/Items/Resources/Arrows/Arrow.cs +++ b/Projects/Scripts/Items/Resources/Arrows/Arrow.cs @@ -17,7 +17,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Arrows/Bolt.cs b/Projects/Scripts/Items/Resources/Arrows/Bolt.cs index d8bf120ac..690b35c79 100644 --- a/Projects/Scripts/Items/Resources/Arrows/Bolt.cs +++ b/Projects/Scripts/Items/Resources/Arrows/Bolt.cs @@ -17,7 +17,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Arrows/Shaft.cs b/Projects/Scripts/Items/Resources/Arrows/Shaft.cs index d40564a3e..282681ab9 100644 --- a/Projects/Scripts/Items/Resources/Arrows/Shaft.cs +++ b/Projects/Scripts/Items/Resources/Arrows/Shaft.cs @@ -17,7 +17,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs b/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs index e8656dffd..eae5b333b 100644 --- a/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs +++ b/Projects/Scripts/Items/Resources/Blacksmithing/Ingots.cs @@ -62,29 +62,29 @@ namespace Server.Items switch (version) { case 1: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } - case 0: - { - var info = reader.ReadInt() switch { - 0 => OreInfo.Iron, - 1 => OreInfo.DullCopper, - 2 => OreInfo.ShadowIron, - 3 => OreInfo.Copper, - 4 => OreInfo.Bronze, - 5 => OreInfo.Gold, - 6 => OreInfo.Agapite, - 7 => OreInfo.Verite, - 8 => OreInfo.Valorite, - _ => null - }; + m_Resource = (CraftResource)reader.ReadInt(); + break; + } + case 0: + { + var info = reader.ReadInt() switch + { + 0 => OreInfo.Iron, + 1 => OreInfo.DullCopper, + 2 => OreInfo.ShadowIron, + 3 => OreInfo.Copper, + 4 => OreInfo.Bronze, + 5 => OreInfo.Gold, + 6 => OreInfo.Agapite, + 7 => OreInfo.Verite, + 8 => OreInfo.Valorite, + _ => null + }; - m_Resource = CraftResources.GetFromOreInfo(info); - break; - } + m_Resource = CraftResources.GetFromOreInfo(info); + break; + } } } diff --git a/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs b/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs index 2bf24b3eb..c34ddf4fb 100644 --- a/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs +++ b/Projects/Scripts/Items/Resources/Blacksmithing/Ore.cs @@ -63,29 +63,29 @@ namespace Server.Items switch (version) { case 1: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } - case 0: - { - var info = reader.ReadInt() switch { - 0 => OreInfo.Iron, - 1 => OreInfo.DullCopper, - 2 => OreInfo.ShadowIron, - 3 => OreInfo.Copper, - 4 => OreInfo.Bronze, - 5 => OreInfo.Gold, - 6 => OreInfo.Agapite, - 7 => OreInfo.Verite, - 8 => OreInfo.Valorite, - _ => null - }; + m_Resource = (CraftResource)reader.ReadInt(); + break; + } + case 0: + { + var info = reader.ReadInt() switch + { + 0 => OreInfo.Iron, + 1 => OreInfo.DullCopper, + 2 => OreInfo.ShadowIron, + 3 => OreInfo.Copper, + 4 => OreInfo.Bronze, + 5 => OreInfo.Gold, + 6 => OreInfo.Agapite, + 7 => OreInfo.Verite, + 8 => OreInfo.Valorite, + _ => null + }; - m_Resource = CraftResources.GetFromOreInfo(info); - break; - } + m_Resource = CraftResources.GetFromOreInfo(info); + break; + } } } @@ -152,7 +152,7 @@ namespace Server.Items private class InternalTarget : Target { - private BaseOre m_Ore; + private readonly BaseOre m_Ore; public InternalTarget(BaseOre ore) : base(2, false, TargetFlags.None) => m_Ore = ore; @@ -171,7 +171,7 @@ namespace Server.Items else if (obj is StaticTarget target) itemID = target.ItemID; - return itemID == 4017 || itemID >= 6522 && itemID <= 6569; + return itemID == 4017 || (itemID >= 6522 && itemID <= 6569); } protected override void OnTarget(Mobile from, object targeted) @@ -185,8 +185,6 @@ namespace Server.Items return; } - #region Combine Ore - if (targeted is BaseOre ore) { if (!ore.Movable) return; @@ -243,9 +241,9 @@ namespace Server.Items } } - if (ore.ItemID == 0x19B9 && worth > 120000 || - (ore.ItemID == 0x19B8 || ore.ItemID == 0x19BA) && worth > 60000 || - ore.ItemID == 0x19B7 && worth > 30000) + if ((ore.ItemID == 0x19B9 && worth > 120000) || + ((ore.ItemID == 0x19B8 || ore.ItemID == 0x19BA) && worth > 60000) || + (ore.ItemID == 0x19B7 && worth > 30000)) { from.SendLocalizedMessage(1062844); // There is too much ore to combine. return; @@ -271,8 +269,6 @@ namespace Server.Items return; } - #endregion - if (IsForge(targeted)) { var difficulty = m_Ore.Resource switch @@ -341,7 +337,7 @@ namespace Server.Items m_Ore.Consume(toConsume); from.AddToBackpack(ingot); - //from.PlaySound( 0x57 ); + // from.PlaySound( 0x57 ); from.SendLocalizedMessage( 501988); // You smelt the ore removing the impurities and put the metal in your backpack. diff --git a/Projects/Scripts/Items/Resources/Blacksmithing/Scales.cs b/Projects/Scripts/Items/Resources/Blacksmithing/Scales.cs index f2ae7aac2..6724955f0 100644 --- a/Projects/Scripts/Items/Resources/Blacksmithing/Scales.cs +++ b/Projects/Scripts/Items/Resources/Blacksmithing/Scales.cs @@ -53,10 +53,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Resources/Fishing/BigFish.cs b/Projects/Scripts/Items/Resources/Fishing/BigFish.cs index 8b7b7e77f..fe5a39827 100644 --- a/Projects/Scripts/Items/Resources/Fishing/BigFish.cs +++ b/Projects/Scripts/Items/Resources/Fishing/BigFish.cs @@ -10,7 +10,7 @@ namespace Server.Items public BigFish() : base(0x09CC) { Weight = Utility.RandomMinMax(3, - 200); //TODO: Find correct formula. max on OSI currently 200, OSI dev says it's not 200 as max, and ~ 1/1,000,000 chance to get highest + 200); // TODO: Find correct formula. max on OSI currently 200, OSI dev says it's not 200 as max, and ~ 1/1,000,000 chance to get highest Hue = Utility.RandomBool() ? 0x847 : 0x58C; } @@ -33,7 +33,7 @@ namespace Server.Items public void Carve(Mobile from, Item item) { - base.ScissorHelper(from, new RawFishSteak(), Math.Max(16, (int)Weight) / 4, false); + this.ScissorHelper(from, new RawFishSteak(), Math.Max(16, (int)Weight) / 4, false); } public override void GetProperties(ObjectPropertyList list) @@ -67,16 +67,16 @@ namespace Server.Items switch (version) { case 1: - { - m_Fisher = reader.ReadMobile(); - break; - } + { + m_Fisher = reader.ReadMobile(); + break; + } case 0: - { - Weight = Utility.RandomMinMax(3, 200); - break; - } + { + Weight = Utility.RandomMinMax(3, 200); + break; + } } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Resources/Fishing/Fish.cs b/Projects/Scripts/Items/Resources/Fishing/Fish.cs index edfbd98a2..8d0d9ef39 100644 --- a/Projects/Scripts/Items/Resources/Fishing/Fish.cs +++ b/Projects/Scripts/Items/Resources/Fishing/Fish.cs @@ -10,14 +10,13 @@ namespace Server.Items Amount = amount; } - public Fish(Serial serial) : base(serial) { } public void Carve(Mobile from, Item item) { - base.ScissorHelper(from, new RawFishSteak(), 4); + this.ScissorHelper(from, new RawFishSteak(), 4); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Items/Resources/Masonry/Granite.cs b/Projects/Scripts/Items/Resources/Masonry/Granite.cs index a5bedbe8c..6a030dfb7 100644 --- a/Projects/Scripts/Items/Resources/Masonry/Granite.cs +++ b/Projects/Scripts/Items/Resources/Masonry/Granite.cs @@ -50,10 +50,10 @@ namespace Server.Items { case 1: case 0: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } } if (version < 1) diff --git a/Projects/Scripts/Items/Resources/MiscMLResources.cs b/Projects/Scripts/Items/Resources/MiscMLResources.cs index d6333ee7c..7107777fd 100644 --- a/Projects/Scripts/Items/Resources/MiscMLResources.cs +++ b/Projects/Scripts/Items/Resources/MiscMLResources.cs @@ -60,7 +60,6 @@ namespace Server.Items } } - public class CapturedEssence : Item { [Constructible] @@ -91,7 +90,6 @@ namespace Server.Items } } - public class EyeOfTheTravesty : Item { [Constructible] @@ -128,7 +126,6 @@ namespace Server.Items } } - public class Corruption : Item { [Constructible] @@ -165,7 +162,6 @@ namespace Server.Items } } - public class DreadHornMane : Item { [Constructible] @@ -202,7 +198,6 @@ namespace Server.Items } } - public class ParasiticPlant : Item { [Constructible] @@ -239,7 +234,6 @@ namespace Server.Items } } - public class Muculent : Item { [Constructible] @@ -276,7 +270,6 @@ namespace Server.Items } } - public class DiseasedBark : Item { [Constructible] @@ -313,7 +306,6 @@ namespace Server.Items } } - public class BarkFragment : Item { [Constructible] @@ -350,7 +342,6 @@ namespace Server.Items } } - public class GrizzledBones : Item { [Constructible] @@ -390,7 +381,6 @@ namespace Server.Items } } - public class LardOfParoxysmus : Item { [Constructible] @@ -499,7 +489,6 @@ namespace Server.Items } } - public class Turquoise : Item { [Constructible] @@ -536,7 +525,6 @@ namespace Server.Items } } - public class EcruCitrine : Item { [Constructible] @@ -573,7 +561,6 @@ namespace Server.Items } } - public class WhitePearl : Item { [Constructible] @@ -610,7 +597,6 @@ namespace Server.Items } } - public class FireRuby : Item { [Constructible] @@ -647,7 +633,6 @@ namespace Server.Items } } - public class BlueDiamond : Item { [Constructible] @@ -684,7 +669,6 @@ namespace Server.Items } } - public class BrilliantAmber : Item { [Constructible] @@ -758,7 +742,6 @@ namespace Server.Items } } - public class Putrefication : Item { [Constructible] @@ -796,7 +779,6 @@ namespace Server.Items } } - public class Taint : Item { [Constructible] diff --git a/Projects/Scripts/Items/Resources/Reagents/BatWing.cs b/Projects/Scripts/Items/Resources/Reagents/BatWing.cs index 1e24dca7c..5b9b2f629 100644 --- a/Projects/Scripts/Items/Resources/Reagents/BatWing.cs +++ b/Projects/Scripts/Items/Resources/Reagents/BatWing.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/Bloodmoss.cs b/Projects/Scripts/Items/Resources/Reagents/Bloodmoss.cs index 513e19a9e..cb02b9805 100644 --- a/Projects/Scripts/Items/Resources/Reagents/Bloodmoss.cs +++ b/Projects/Scripts/Items/Resources/Reagents/Bloodmoss.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/DaemonBlood.cs b/Projects/Scripts/Items/Resources/Reagents/DaemonBlood.cs index 116f133ef..d455556e3 100644 --- a/Projects/Scripts/Items/Resources/Reagents/DaemonBlood.cs +++ b/Projects/Scripts/Items/Resources/Reagents/DaemonBlood.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/DaemonBone.cs b/Projects/Scripts/Items/Resources/Reagents/DaemonBone.cs index efbdf1fe6..6395910ca 100644 --- a/Projects/Scripts/Items/Resources/Reagents/DaemonBone.cs +++ b/Projects/Scripts/Items/Resources/Reagents/DaemonBone.cs @@ -14,7 +14,6 @@ namespace Server.Items public override double DefaultWeight => 1.0; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/Garlic.cs b/Projects/Scripts/Items/Resources/Reagents/Garlic.cs index 442937058..fa717e240 100644 --- a/Projects/Scripts/Items/Resources/Reagents/Garlic.cs +++ b/Projects/Scripts/Items/Resources/Reagents/Garlic.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/Ginseng.cs b/Projects/Scripts/Items/Resources/Reagents/Ginseng.cs index 3da70a2cd..3334a770d 100644 --- a/Projects/Scripts/Items/Resources/Reagents/Ginseng.cs +++ b/Projects/Scripts/Items/Resources/Reagents/Ginseng.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/GraveDust.cs b/Projects/Scripts/Items/Resources/Reagents/GraveDust.cs index 734681315..139c00f60 100644 --- a/Projects/Scripts/Items/Resources/Reagents/GraveDust.cs +++ b/Projects/Scripts/Items/Resources/Reagents/GraveDust.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/MandrakeRoot.cs b/Projects/Scripts/Items/Resources/Reagents/MandrakeRoot.cs index 8c0d0cfee..209223583 100644 --- a/Projects/Scripts/Items/Resources/Reagents/MandrakeRoot.cs +++ b/Projects/Scripts/Items/Resources/Reagents/MandrakeRoot.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/Nightshade.cs b/Projects/Scripts/Items/Resources/Reagents/Nightshade.cs index b7aa5f7a7..032223a75 100644 --- a/Projects/Scripts/Items/Resources/Reagents/Nightshade.cs +++ b/Projects/Scripts/Items/Resources/Reagents/Nightshade.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/NoxCrystal.cs b/Projects/Scripts/Items/Resources/Reagents/NoxCrystal.cs index cf75cec4f..14a1524b9 100644 --- a/Projects/Scripts/Items/Resources/Reagents/NoxCrystal.cs +++ b/Projects/Scripts/Items/Resources/Reagents/NoxCrystal.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/PigIron.cs b/Projects/Scripts/Items/Resources/Reagents/PigIron.cs index 8d6ba55e6..64dba1a6a 100644 --- a/Projects/Scripts/Items/Resources/Reagents/PigIron.cs +++ b/Projects/Scripts/Items/Resources/Reagents/PigIron.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/SpidersSilk.cs b/Projects/Scripts/Items/Resources/Reagents/SpidersSilk.cs index c1fd9f1c7..96bc4d2e6 100644 --- a/Projects/Scripts/Items/Resources/Reagents/SpidersSilk.cs +++ b/Projects/Scripts/Items/Resources/Reagents/SpidersSilk.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Reagents/SulfurousAsh.cs b/Projects/Scripts/Items/Resources/Reagents/SulfurousAsh.cs index 021f830fb..c9039ea75 100644 --- a/Projects/Scripts/Items/Resources/Reagents/SulfurousAsh.cs +++ b/Projects/Scripts/Items/Resources/Reagents/SulfurousAsh.cs @@ -14,7 +14,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Tailor/BoltOfCloth.cs b/Projects/Scripts/Items/Resources/Tailor/BoltOfCloth.cs index 45ee6946b..cd9b4437a 100644 --- a/Projects/Scripts/Items/Resources/Tailor/BoltOfCloth.cs +++ b/Projects/Scripts/Items/Resources/Tailor/BoltOfCloth.cs @@ -33,7 +33,7 @@ namespace Server.Items { if (Deleted || !from.CanSee(this)) return false; - base.ScissorHelper(from, new Cloth(), 50); + this.ScissorHelper(from, new Cloth(), 50); return true; } diff --git a/Projects/Scripts/Items/Resources/Tailor/Bone.cs b/Projects/Scripts/Items/Resources/Tailor/Bone.cs index 06f005a92..da71368c7 100644 --- a/Projects/Scripts/Items/Resources/Tailor/Bone.cs +++ b/Projects/Scripts/Items/Resources/Tailor/Bone.cs @@ -17,7 +17,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => true; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Resources/Tailor/Cloth.cs b/Projects/Scripts/Items/Resources/Tailor/Cloth.cs index 14096cbe1..632aad31e 100644 --- a/Projects/Scripts/Items/Resources/Tailor/Cloth.cs +++ b/Projects/Scripts/Items/Resources/Tailor/Cloth.cs @@ -34,7 +34,7 @@ namespace Server.Items { if (Deleted || !from.CanSee(this)) return false; - base.ScissorHelper(from, new Bandage(), 1); + this.ScissorHelper(from, new Bandage(), 1); return true; } diff --git a/Projects/Scripts/Items/Resources/Tailor/Cotton.cs b/Projects/Scripts/Items/Resources/Tailor/Cotton.cs index 490acce15..e66b6299f 100644 --- a/Projects/Scripts/Items/Resources/Tailor/Cotton.cs +++ b/Projects/Scripts/Items/Resources/Tailor/Cotton.cs @@ -64,7 +64,7 @@ namespace Server.Items private class PickWheelTarget : Target { - private Cotton m_Cotton; + private readonly Cotton m_Cotton; public PickWheelTarget(Cotton cotton) : base(3, false, TargetFlags.None) => m_Cotton = cotton; diff --git a/Projects/Scripts/Items/Resources/Tailor/Flax.cs b/Projects/Scripts/Items/Resources/Tailor/Flax.cs index 44b2bcd6e..0835ead29 100644 --- a/Projects/Scripts/Items/Resources/Tailor/Flax.cs +++ b/Projects/Scripts/Items/Resources/Tailor/Flax.cs @@ -54,7 +54,7 @@ namespace Server.Items private class PickWheelTarget : Target { - private Flax m_Flax; + private readonly Flax m_Flax; public PickWheelTarget(Flax flax) : base(3, false, TargetFlags.None) => m_Flax = flax; diff --git a/Projects/Scripts/Items/Resources/Tailor/Hides.cs b/Projects/Scripts/Items/Resources/Tailor/Hides.cs index fb9c61fb1..5bffaed59 100644 --- a/Projects/Scripts/Items/Resources/Tailor/Hides.cs +++ b/Projects/Scripts/Items/Resources/Tailor/Hides.cs @@ -61,17 +61,17 @@ namespace Server.Items switch (version) { case 1: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } case 0: - { - OreInfo info = new OreInfo(reader.ReadInt(), reader.ReadInt(), reader.ReadString()); + { + OreInfo info = new OreInfo(reader.ReadInt(), reader.ReadInt(), reader.ReadString()); - m_Resource = CraftResources.GetFromOreInfo(info); - break; - } + m_Resource = CraftResources.GetFromOreInfo(info); + break; + } } } @@ -121,7 +121,7 @@ namespace Server.Items return false; } - base.ScissorHelper(from, new Leather(), 1); + this.ScissorHelper(from, new Leather(), 1); return true; } @@ -163,7 +163,7 @@ namespace Server.Items return false; } - base.ScissorHelper(from, new SpinedLeather(), 1); + this.ScissorHelper(from, new SpinedLeather(), 1); return true; } @@ -205,7 +205,7 @@ namespace Server.Items return false; } - base.ScissorHelper(from, new HornedLeather(), 1); + this.ScissorHelper(from, new HornedLeather(), 1); return true; } @@ -247,7 +247,7 @@ namespace Server.Items return false; } - base.ScissorHelper(from, new BarbedLeather(), 1); + this.ScissorHelper(from, new BarbedLeather(), 1); return true; } diff --git a/Projects/Scripts/Items/Resources/Tailor/Leathers.cs b/Projects/Scripts/Items/Resources/Tailor/Leathers.cs index 035e0aed2..eff4a0567 100644 --- a/Projects/Scripts/Items/Resources/Tailor/Leathers.cs +++ b/Projects/Scripts/Items/Resources/Tailor/Leathers.cs @@ -61,17 +61,17 @@ namespace Server.Items switch (version) { case 1: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } case 0: - { - OreInfo info = new OreInfo(reader.ReadInt(), reader.ReadInt(), reader.ReadString()); + { + OreInfo info = new OreInfo(reader.ReadInt(), reader.ReadInt(), reader.ReadString()); - m_Resource = CraftResources.GetFromOreInfo(info); - break; - } + m_Resource = CraftResources.GetFromOreInfo(info); + break; + } } } diff --git a/Projects/Scripts/Items/Resources/Tailor/UncutCloth.cs b/Projects/Scripts/Items/Resources/Tailor/UncutCloth.cs index 8054b8191..b6b7bf4cd 100644 --- a/Projects/Scripts/Items/Resources/Tailor/UncutCloth.cs +++ b/Projects/Scripts/Items/Resources/Tailor/UncutCloth.cs @@ -34,7 +34,7 @@ namespace Server.Items { if (Deleted || !from.CanSee(this)) return false; - base.ScissorHelper(from, new Bandage(), 1); + this.ScissorHelper(from, new Bandage(), 1); return true; } diff --git a/Projects/Scripts/Items/Resources/Tailor/Wool.cs b/Projects/Scripts/Items/Resources/Tailor/Wool.cs index d0e9ca165..d8be830cd 100644 --- a/Projects/Scripts/Items/Resources/Tailor/Wool.cs +++ b/Projects/Scripts/Items/Resources/Tailor/Wool.cs @@ -64,7 +64,7 @@ namespace Server.Items private class PickWheelTarget : Target { - private Wool m_Wool; + private readonly Wool m_Wool; public PickWheelTarget(Wool wool) : base(3, false, TargetFlags.None) => m_Wool = wool; diff --git a/Projects/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs b/Projects/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs index b25f0834f..6b87a0549 100644 --- a/Projects/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs +++ b/Projects/Scripts/Items/Resources/Tailor/YarnsAndThreads.cs @@ -54,7 +54,7 @@ namespace Server.Items private class PickLoomTarget : Target { - private BaseClothMaterial m_Material; + private readonly BaseClothMaterial m_Material; public PickLoomTarget(BaseClothMaterial material) : base(3, false, TargetFlags.None) => m_Material = material; diff --git a/Projects/Scripts/Items/Shields/BaseShield.cs b/Projects/Scripts/Items/Shields/BaseShield.cs index aaa5d242b..b2cb94566 100644 --- a/Projects/Scripts/Items/Shields/BaseShield.cs +++ b/Projects/Scripts/Items/Shields/BaseShield.cs @@ -31,7 +31,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(1); //version + writer.Write(1); // version } public override void Deserialize(IGenericReader reader) @@ -138,7 +138,7 @@ namespace Server.Items owner.FixedEffect(0x37B9, 10, 16); - if (25 > Utility.Random(100)) // 25% chance to lower durability + if (Utility.Random(100) < 25) // 25% chance to lower durability { int wear = Utility.Random(2); diff --git a/Projects/Scripts/Items/Shields/BronzeShield.cs b/Projects/Scripts/Items/Shields/BronzeShield.cs index ce2fe33e0..85ff13e9e 100644 --- a/Projects/Scripts/Items/Shields/BronzeShield.cs +++ b/Projects/Scripts/Items/Shields/BronzeShield.cs @@ -33,7 +33,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Shields/Buckler.cs b/Projects/Scripts/Items/Shields/Buckler.cs index 98c019029..55d8885db 100644 --- a/Projects/Scripts/Items/Shields/Buckler.cs +++ b/Projects/Scripts/Items/Shields/Buckler.cs @@ -33,7 +33,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Shields/ChaosShield.cs b/Projects/Scripts/Items/Shields/ChaosShield.cs index 28b768380..8d3d1f50d 100644 --- a/Projects/Scripts/Items/Shields/ChaosShield.cs +++ b/Projects/Scripts/Items/Shields/ChaosShield.cs @@ -41,7 +41,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override bool OnEquip(Mobile from) => Validate(from) && base.OnEquip(from); diff --git a/Projects/Scripts/Items/Shields/HeaterShield.cs b/Projects/Scripts/Items/Shields/HeaterShield.cs index 74866cd0d..f07854469 100644 --- a/Projects/Scripts/Items/Shields/HeaterShield.cs +++ b/Projects/Scripts/Items/Shields/HeaterShield.cs @@ -33,7 +33,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Shields/MetalKiteShield.cs b/Projects/Scripts/Items/Shields/MetalKiteShield.cs index edcf28546..b467e54b1 100644 --- a/Projects/Scripts/Items/Shields/MetalKiteShield.cs +++ b/Projects/Scripts/Items/Shields/MetalKiteShield.cs @@ -46,7 +46,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Shields/MetalShield.cs b/Projects/Scripts/Items/Shields/MetalShield.cs index 118a94379..b04362adb 100644 --- a/Projects/Scripts/Items/Shields/MetalShield.cs +++ b/Projects/Scripts/Items/Shields/MetalShield.cs @@ -33,7 +33,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Shields/OrderShield.cs b/Projects/Scripts/Items/Shields/OrderShield.cs index aff721b0b..fffa9cd70 100644 --- a/Projects/Scripts/Items/Shields/OrderShield.cs +++ b/Projects/Scripts/Items/Shields/OrderShield.cs @@ -44,7 +44,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override bool OnEquip(Mobile from) => Validate(from) && base.OnEquip(from); diff --git a/Projects/Scripts/Items/Shields/WoodenKiteShield.cs b/Projects/Scripts/Items/Shields/WoodenKiteShield.cs index f21e2c07a..cdc6dc511 100644 --- a/Projects/Scripts/Items/Shields/WoodenKiteShield.cs +++ b/Projects/Scripts/Items/Shields/WoodenKiteShield.cs @@ -36,7 +36,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Shields/WoodenShield.cs b/Projects/Scripts/Items/Shields/WoodenShield.cs index 00e70b3f3..4a25ed7b2 100644 --- a/Projects/Scripts/Items/Shields/WoodenShield.cs +++ b/Projects/Scripts/Items/Shields/WoodenShield.cs @@ -33,7 +33,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Skill Items/Camping/Bedroll.cs b/Projects/Scripts/Items/Skill Items/Camping/Bedroll.cs index d334d8501..01dc756b1 100644 --- a/Projects/Scripts/Items/Skill Items/Camping/Bedroll.cs +++ b/Projects/Scripts/Items/Skill Items/Camping/Bedroll.cs @@ -65,10 +65,10 @@ namespace Server.Items private class LogoutGump : Gump { - private Bedroll m_Bedroll; - private Timer m_CloseTimer; + private readonly Bedroll m_Bedroll; + private readonly Timer m_CloseTimer; - private CampfireEntry m_Entry; + private readonly CampfireEntry m_Entry; public LogoutGump(CampfireEntry entry, Bedroll bedroll) : base(100, 0) { diff --git a/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs b/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs index 1f2e0391c..64626e67d 100644 --- a/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs +++ b/Projects/Scripts/Items/Skill Items/Camping/Campfire.cs @@ -19,9 +19,9 @@ namespace Server.Items private static readonly Dictionary m_Table = new Dictionary(); - private List m_Entries; + private readonly List m_Entries; - private Timer m_Timer; + private readonly Timer m_Timer; public Campfire() : base(0xDE3) { @@ -39,7 +39,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public DateTime Created{ get; } + public DateTime Created { get; } [CommandProperty(AccessLevel.GameMaster)] public CampfireStatus Status @@ -176,11 +176,11 @@ namespace Server.Items m_Safe = false; } - public PlayerMobile Player{ get; } + public PlayerMobile Player { get; } - public Campfire Fire{ get; } + public Campfire Fire { get; } - public DateTime Start{ get; } + public DateTime Start { get; } public bool Valid => !Fire.Deleted && Fire.Status != CampfireStatus.Off && Player.Map == Fire.Map && Player.InRange(Fire, Campfire.SecureRange); diff --git a/Projects/Scripts/Items/Skill Items/Camping/Kindling.cs b/Projects/Scripts/Items/Skill Items/Camping/Kindling.cs index 5fa1ed366..d82121810 100644 --- a/Projects/Scripts/Items/Skill Items/Camping/Kindling.cs +++ b/Projects/Scripts/Items/Skill Items/Camping/Kindling.cs @@ -18,7 +18,6 @@ namespace Server.Items { } - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs b/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs index 5a70c0fe9..b28a33635 100644 --- a/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs +++ b/Projects/Scripts/Items/Skill Items/Carpenter Items/Board.cs @@ -49,7 +49,7 @@ namespace Server.Items { CraftResource.Bloodwood => 1075055, CraftResource.Frostwood => 1075056, - CraftResource.Heartwood => 1075062, //WHY Osi. Why? + CraftResource.Heartwood => 1075062, // WHY Osi. Why? _ => LabelNumber }; } @@ -72,7 +72,6 @@ namespace Server.Items } } - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); @@ -92,13 +91,13 @@ namespace Server.Items { case 3: case 2: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } } - if (version == 0 && Weight == 0.1 || version <= 2 && Weight == 2) + if ((version == 0 && Weight == 0.1) || (version <= 2 && Weight == 2)) Weight = -1; if (version <= 1) @@ -106,7 +105,6 @@ namespace Server.Items } } - public class HeartwoodBoard : Board { [Constructible] diff --git a/Projects/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs b/Projects/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs index 623cb903a..4f6780cb7 100644 --- a/Projects/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs +++ b/Projects/Scripts/Items/Skill Items/Carpenter Items/TaxidermyKit.cs @@ -8,7 +8,7 @@ namespace Server.Items [Flippable(0x1EBA, 0x1EBB)] public class TaxidermyKit : Item { - private static TrophyInfo[] m_Table = + private static readonly TrophyInfo[] m_Table = { new TrophyInfo(typeof(BrownBear), 0x1E60, 1041093, 1041107), new TrophyInfo(typeof(GreatHart), 0x1E61, 1041095, 1041109), @@ -69,19 +69,18 @@ namespace Server.Items AddonNumber = addonNum; } - public Type CreatureType{ get; } + public Type CreatureType { get; } - public int NorthID{ get; } + public int NorthID { get; } - public int DeedNumber{ get; } + public int DeedNumber { get; } - public int AddonNumber{ get; } + public int AddonNumber { get; } } - private class CorpseTarget : Target { - private TaxidermyKit m_Kit; + private readonly TaxidermyKit m_Kit; public CorpseTarget(TaxidermyKit kit) : base(3, false, TargetFlags.None) => m_Kit = kit; @@ -136,7 +135,6 @@ namespace Server.Items fish.Consume(); } - from.AddToBackpack(new TrophyDeed(t, hunter, weight)); if (corpse != null) @@ -186,13 +184,13 @@ namespace Server.Items public override bool ForceShowProperties => ObjectPropertyList.Enabled; [CommandProperty(AccessLevel.GameMaster)] - public int WestID{ get; set; } + public int WestID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int NorthID{ get; set; } + public int NorthID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int DeedNumber{ get; set; } + public int DeedNumber { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int AddonNumber @@ -278,19 +276,19 @@ namespace Server.Items switch (version) { case 1: - { - m_Hunter = reader.ReadMobile(); - m_AnimalWeight = reader.ReadInt(); - goto case 0; - } + { + m_Hunter = reader.ReadMobile(); + m_AnimalWeight = reader.ReadInt(); + goto case 0; + } case 0: - { - WestID = reader.ReadInt(); - NorthID = reader.ReadInt(); - DeedNumber = reader.ReadInt(); - m_AddonNumber = reader.ReadInt(); - break; - } + { + WestID = reader.ReadInt(); + NorthID = reader.ReadInt(); + DeedNumber = reader.ReadInt(); + m_AddonNumber = reader.ReadInt(); + break; + } } Timer.DelayCall(TimeSpan.Zero, FixMovingCrate); @@ -367,10 +365,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int WestID{ get; set; } + public int WestID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int NorthID{ get; set; } + public int NorthID { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int DeedNumber @@ -384,7 +382,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int AddonNumber{ get; set; } + public int AddonNumber { get; set; } [CommandProperty(AccessLevel.GameMaster)] public Mobile Hunter @@ -447,19 +445,19 @@ namespace Server.Items switch (version) { case 1: - { - m_Hunter = reader.ReadMobile(); - m_AnimalWeight = reader.ReadInt(); - goto case 0; - } + { + m_Hunter = reader.ReadMobile(); + m_AnimalWeight = reader.ReadInt(); + goto case 0; + } case 0: - { - WestID = reader.ReadInt(); - NorthID = reader.ReadInt(); - m_DeedNumber = reader.ReadInt(); - AddonNumber = reader.ReadInt(); - break; - } + { + WestID = reader.ReadInt(); + NorthID = reader.ReadInt(); + m_DeedNumber = reader.ReadInt(); + AddonNumber = reader.ReadInt(); + break; + } } } diff --git a/Projects/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs b/Projects/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs index 8c024d63c..07f38a982 100644 --- a/Projects/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs +++ b/Projects/Scripts/Items/Skill Items/Fishing/Misc/MessageInABottle.cs @@ -27,7 +27,7 @@ namespace Server.Items public override int LabelNumber => 1041080; // a message in a bottle [CommandProperty(AccessLevel.GameMaster)] - public Map TargetMap{ get; set; } + public Map TargetMap { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Level @@ -38,7 +38,7 @@ namespace Server.Items public static int GetRandomLevel() { - if (Core.AOS && 1 > Utility.Random(25)) + if (Core.AOS && Utility.Random(25) < 1) return 4; // ancient return Utility.RandomMinMax(1, 3); @@ -65,20 +65,20 @@ namespace Server.Items { case 3: case 2: - { - m_Level = reader.ReadInt(); - goto case 1; - } + { + m_Level = reader.ReadInt(); + goto case 1; + } case 1: - { - TargetMap = reader.ReadMap(); - break; - } + { + TargetMap = reader.ReadMap(); + break; + } case 0: - { - TargetMap = Map.Trammel; - break; - } + { + TargetMap = Map.Trammel; + break; + } } if (version < 2) diff --git a/Projects/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs b/Projects/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs index 3ccd083ac..28c2c77d1 100644 --- a/Projects/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs +++ b/Projects/Scripts/Items/Skill Items/Fishing/Misc/SOS.cs @@ -35,13 +35,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Map TargetMap{ get; set; } + public Map TargetMap { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D TargetLocation{ get; set; } + public Point3D TargetLocation { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int MessageIndex{ get; set; } + public int MessageIndex { get; set; } public void UpdateHue() { @@ -97,30 +97,30 @@ namespace Server.Items case 4: case 3: case 2: - { - m_Level = reader.ReadInt(); - goto case 1; - } + { + m_Level = reader.ReadInt(); + goto case 1; + } case 1: - { - TargetMap = reader.ReadMap(); - TargetLocation = reader.ReadPoint3D(); - MessageIndex = reader.ReadInt(); + { + TargetMap = reader.ReadMap(); + TargetLocation = reader.ReadPoint3D(); + MessageIndex = reader.ReadInt(); - break; - } + break; + } case 0: - { - TargetMap = Map; + { + TargetMap = Map; - if (TargetMap == null || TargetMap == Map.Internal) - TargetMap = Map.Trammel; + if (TargetMap == null || TargetMap == Map.Internal) + TargetMap = Map.Trammel; - TargetLocation = FindLocation(TargetMap); - MessageIndex = Utility.Random(MessageEntry.Entries.Length); + TargetLocation = FindLocation(TargetMap); + MessageIndex = Utility.Random(MessageEntry.Entries.Length); - break; - } + break; + } } if (version < 2) @@ -144,7 +144,7 @@ namespace Server.Items else entry = MessageEntry.Entries[MessageIndex = Utility.Random(MessageEntry.Entries.Length)]; - //from.CloseGump( typeof( MessageGump ) ); + // from.CloseGump( typeof( MessageGump ) ); from.SendGump(new MessageGump(entry, TargetMap, TargetLocation)); } else @@ -153,18 +153,18 @@ namespace Server.Items } } - private static int[] m_WaterTiles = + private static readonly int[] m_WaterTiles = { 0x00A8, 0x00AB, 0x0136, 0x0137 }; - private static Rectangle2D[] m_BritRegions = { new Rectangle2D(0, 0, 5120, 4096) }; + private static readonly Rectangle2D[] m_BritRegions = { new Rectangle2D(0, 0, 5120, 4096) }; - private static Rectangle2D[] m_IlshRegions = + private static readonly Rectangle2D[] m_IlshRegions = { new Rectangle2D(1472, 272, 304, 240), new Rectangle2D(1240, 1000, 312, 160) }; - private static Rectangle2D[] m_MalasRegions = { new Rectangle2D(1376, 1520, 464, 280) }; + private static readonly Rectangle2D[] m_MalasRegions = { new Rectangle2D(1376, 1520, 464, 280) }; public static Point3D FindLocation(Map map) { @@ -242,12 +242,13 @@ namespace Server.Items AddBackground(0, 40, 350, 300, 2520); + /* This is a message hastily scribbled by a passenger aboard a sinking ship. + * While it is probably too late to save the passengers and crew, + * perhaps some treasure went down with the ship! + * The message gives the ship's last known sextant co-ordinates. + */ AddHtmlLocalized(30, 80, 285, 160, 1018326, true, - true); /* This is a message hastily scribbled by a passenger aboard a sinking ship. - * While it is probably too late to save the passengers and crew, - * perhaps some treasure went down with the ship! - * The message gives the ship's last known sextant co-ordinates. - */ + true); AddHtml(35, 240, 230, 20, fmt); @@ -265,13 +266,13 @@ namespace Server.Items Message = message; } - public int Width{ get; } + public int Width { get; } - public int Height{ get; } + public int Height { get; } - public string Message{ get; } + public string Message { get; } - public static MessageEntry[] Entries{ get; } = + public static MessageEntry[] Entries { get; } = { new MessageEntry(280, 180, "...Ar! {0} and a fair wind! No chance... storms, though--ar! Is that a sea serp...

uh oh."), diff --git a/Projects/Scripts/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs b/Projects/Scripts/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs index 91f01eca2..9fbfef0ca 100644 --- a/Projects/Scripts/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs +++ b/Projects/Scripts/Items/Skill Items/Fishing/Misc/ShipwreckedItem.cs @@ -2,7 +2,7 @@ namespace Server.Items { public interface IShipwreckedItem { - bool IsShipwreckedItem{ get; set; } + bool IsShipwreckedItem { get; set; } } public class ShipwreckedItem : Item, IDyable, IShipwreckedItem @@ -36,16 +36,12 @@ namespace Server.Items return false; } - #region IShipwreckedItem Members - bool IShipwreckedItem.IsShipwreckedItem { get => true; set { } } - #endregion - public override void OnSingleClick(Mobile from) { LabelTo(from, 1050039, $"#{LabelNumber}\t#1041645"); diff --git a/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs b/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs index 4ab69a393..07355ee3c 100644 --- a/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs +++ b/Projects/Scripts/Items/Skill Items/Fishing/Misc/SpecialFishingNet.cs @@ -8,7 +8,7 @@ namespace Server.Items { public class SpecialFishingNet : Item { - private static int[] m_Hues = + private static readonly int[] m_Hues = { 0x09B, 0x0CD, @@ -26,13 +26,13 @@ namespace Server.Items 0x8AA }; - private static int[] m_WaterTiles = + private static readonly int[] m_WaterTiles = { 0x00A8, 0x00AB, 0x0136, 0x0137 }; - private static int[] m_UndeepWaterTiles = + private static readonly int[] m_UndeepWaterTiles = { 0x1797, 0x179C }; @@ -42,7 +42,7 @@ namespace Server.Items { Weight = 1.0; - if (0.01 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.01) Hue = Utility.RandomList(m_Hues); else Hue = 0x8A0; @@ -55,7 +55,7 @@ namespace Server.Items public override int LabelNumber => 1041079; // a special fishing net [CommandProperty(AccessLevel.GameMaster)] - public bool InUse{ get; set; } + public bool InUse { get; set; } public virtual bool RequireDeepWater => true; @@ -90,14 +90,14 @@ namespace Server.Items switch (version) { case 1: - { - InUse = reader.ReadBool(); + { + InUse = reader.ReadBool(); - if (InUse) - Delete(); + if (InUse) + Delete(); - break; - } + break; + } } Stackable = false; @@ -276,7 +276,7 @@ namespace Server.Items LandTile t = map.Tiles.GetLandTile(tx, ty); - if (t.Z == p.Z && (t.ID >= 0xA8 && t.ID <= 0xAB || t.ID >= 0x136 && t.ID <= 0x137) && + if (t.Z == p.Z && ((t.ID >= 0xA8 && t.ID <= 0xAB) || (t.ID >= 0x136 && t.ID <= 0x137)) && !SpellHelper.CheckMulti(new Point3D(tx, ty, p.Z), map)) { x = tx; @@ -287,7 +287,7 @@ namespace Server.Items spawn.MoveToWorld(new Point3D(x, y, p.Z), map); - if (spawn is Kraken && 0.2 > Utility.RandomDouble()) + if (spawn is Kraken && Utility.RandomDouble() < 0.2) spawn.PackItem(new MessageInABottle(map == Map.Felucca ? Map.Felucca : Map.Trammel)); } diff --git a/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs b/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs index 510319e21..befeb5c52 100644 --- a/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs +++ b/Projects/Scripts/Items/Skill Items/Harvest Tools/BaseHarvestTool.cs @@ -10,8 +10,8 @@ namespace Server.Items { public interface IUsesRemaining { - int UsesRemaining{ get; set; } - bool ShowUsesRemaining{ get; set; } + int UsesRemaining { get; set; } + bool ShowUsesRemaining { get; set; } } public abstract class BaseHarvestTool : Item, IUsesRemaining, ICraftable @@ -54,9 +54,7 @@ namespace Server.Items } } - public abstract HarvestSystem HarvestSystem{ get; } - - #region ICraftable Members + public abstract HarvestSystem HarvestSystem { get; } public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) @@ -69,8 +67,6 @@ namespace Server.Items return quality; } - #endregion - [CommandProperty(AccessLevel.GameMaster)] public int UsesRemaining { @@ -112,8 +108,8 @@ namespace Server.Items base.GetProperties(list); // Makers mark not displayed on OSI - //if ( m_Crafter != null ) - // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ + // if (m_Crafter != null) + // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ if (m_Quality == ToolQuality.Exceptional) list.Add(1060636); // exceptional @@ -188,23 +184,23 @@ namespace Server.Items switch (version) { case 1: - { - m_Crafter = reader.ReadMobile(); - m_Quality = (ToolQuality)reader.ReadInt(); - goto case 0; - } + { + m_Crafter = reader.ReadMobile(); + m_Quality = (ToolQuality)reader.ReadInt(); + goto case 0; + } case 0: - { - m_UsesRemaining = reader.ReadInt(); - break; - } + { + m_UsesRemaining = reader.ReadInt(); + break; + } } } private class ToggleMiningStoneEntry : ContextMenuEntry { - private PlayerMobile m_Mobile; - private bool m_Value; + private readonly PlayerMobile m_Mobile; + private readonly bool m_Value; public ToggleMiningStoneEntry(PlayerMobile mobile, bool value, int number) : base(number) { @@ -213,7 +209,7 @@ namespace Server.Items bool stoneMining = mobile.StoneMining && mobile.Skills.Mining.Base >= 100.0; - if (mobile.ToggleMiningStone == value || value && !stoneMining) + if (mobile.ToggleMiningStone == value || (value && !stoneMining)) Flags |= CMEFlags.Disabled; } diff --git a/Projects/Scripts/Items/Skill Items/Harvest Tools/ProspectorsTool.cs b/Projects/Scripts/Items/Skill Items/Harvest Tools/ProspectorsTool.cs index 09aeff82f..901d05f48 100644 --- a/Projects/Scripts/Items/Skill Items/Harvest Tools/ProspectorsTool.cs +++ b/Projects/Scripts/Items/Skill Items/Harvest Tools/ProspectorsTool.cs @@ -147,21 +147,21 @@ namespace Server.Items switch (version) { case 1: - { - m_UsesRemaining = reader.ReadInt(); - break; - } + { + m_UsesRemaining = reader.ReadInt(); + break; + } case 0: - { - m_UsesRemaining = 50; - break; - } + { + m_UsesRemaining = 50; + break; + } } } private class InternalTarget : Target { - private ProspectorsTool m_Tool; + private readonly ProspectorsTool m_Tool; public InternalTarget(ProspectorsTool tool) : base(2, true, TargetFlags.None) => m_Tool = tool; diff --git a/Projects/Scripts/Items/Skill Items/Lumberjack/Log.cs b/Projects/Scripts/Items/Skill Items/Lumberjack/Log.cs index 6876b62ef..92c03f3fa 100644 --- a/Projects/Scripts/Items/Skill Items/Lumberjack/Log.cs +++ b/Projects/Scripts/Items/Skill Items/Lumberjack/Log.cs @@ -90,10 +90,10 @@ namespace Server.Items switch (version) { case 1: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } } if (version == 0) @@ -112,7 +112,7 @@ namespace Server.Items return false; } - base.ScissorHelper(from, item, 1, false); + this.ScissorHelper(from, item, 1, false); return true; } } diff --git a/Projects/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs b/Projects/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs index 3859ca44c..ea9a4521f 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Misc/Bottle.cs @@ -17,7 +17,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => Core.ML; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs b/Projects/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs index a621a0725..55af9759d 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Misc/Moongate.cs @@ -11,10 +11,8 @@ namespace Server.Items [DispellableField] public class Moongate : Item { - - [Constructible] - public Moongate(bool dispellable = true) : - this(Point3D.Zero, null, dispellable) +[Constructible] + public Moongate(bool dispellable = true) : this(Point3D.Zero, null, dispellable) { } @@ -34,13 +32,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Target{ get; set; } + public Point3D Target { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Map TargetMap{ get; set; } + public Map TargetMap { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool Dispellable{ get; set; } + public bool Dispellable { get; set; } public virtual bool ShowFeluccaWarning => false; @@ -65,13 +63,9 @@ namespace Server.Items public virtual void CheckGate(Mobile m, int range) { - #region Mondain's Legacy - if (m.Hidden && m.AccessLevel == AccessLevel.Player && Core.ML) m.RevealingAction(); - #endregion - new DelayTimer(m, this, range).Start(); } @@ -91,10 +85,10 @@ namespace Server.Items { mobile.SendLocalizedMessage(1049543); // You decide against traveling to Felucca while you are still young. } - else if (m.Kills >= 5 && TargetMap != Map.Felucca || - TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0 || - TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0 || - TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0) + else if ((m.Kills >= 5 && TargetMap != Map.Felucca) || + (TargetMap == Map.Tokuno && (flags & ClientFlags.Tokuno) == 0) || + (TargetMap == Map.Malas && (flags & ClientFlags.Malas) == 0) || + (TargetMap == Map.Ilshenar && (flags & ClientFlags.Ilshenar) == 0)) { m.SendLocalizedMessage(1019004); // You are not allowed to travel there. } @@ -163,8 +157,8 @@ namespace Server.Items public virtual void BeginConfirmation(Mobile from) { - if (IsInTown(from.Location, from.Map) && !IsInTown(Target, TargetMap) || - from.Map != Map.Felucca && TargetMap == Map.Felucca && ShowFeluccaWarning) + if ((IsInTown(from.Location, from.Map) && !IsInTown(Target, TargetMap)) || + (from.Map != Map.Felucca && TargetMap == Map.Felucca && ShowFeluccaWarning)) { if (from.AccessLevel == AccessLevel.Player || !from.Hidden) from.Send(new PlaySound(0x20E, from.Location)); @@ -200,9 +194,9 @@ namespace Server.Items private class DelayTimer : Timer { - private Mobile m_From; - private Moongate m_Gate; - private int m_Range; + private readonly Mobile m_From; + private readonly Moongate m_Gate; + private readonly int m_Range; public DelayTimer(Mobile from, Moongate gate, int range) : base(TimeSpan.FromSeconds(1.0)) { @@ -235,25 +229,25 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int GumpWidth{ get; set; } + public int GumpWidth { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int GumpHeight{ get; set; } + public int GumpHeight { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int TitleColor{ get; set; } + public int TitleColor { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int MessageColor{ get; set; } + public int MessageColor { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int TitleNumber{ get; set; } + public int TitleNumber { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int MessageNumber{ get; set; } + public int MessageNumber { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string MessageString{ get; set; } + public string MessageString { get; set; } public virtual void Warning_Callback(Mobile from, bool okay) { @@ -267,7 +261,7 @@ namespace Server.Items { from.CloseGump(); from.SendGump(new WarningGump(TitleNumber, TitleColor, - MessageString == null ? MessageNumber : (object)MessageString, MessageColor, GumpWidth, GumpHeight, + MessageString ?? (object)MessageNumber, MessageColor, GumpWidth, GumpHeight, okay => Warning_Callback(from, okay))); } else @@ -303,28 +297,28 @@ namespace Server.Items switch (version) { case 0: - { - GumpWidth = reader.ReadEncodedInt(); - GumpHeight = reader.ReadEncodedInt(); + { + GumpWidth = reader.ReadEncodedInt(); + GumpHeight = reader.ReadEncodedInt(); - TitleColor = reader.ReadEncodedInt(); - MessageColor = reader.ReadEncodedInt(); + TitleColor = reader.ReadEncodedInt(); + MessageColor = reader.ReadEncodedInt(); - TitleNumber = reader.ReadEncodedInt(); - MessageNumber = reader.ReadEncodedInt(); + TitleNumber = reader.ReadEncodedInt(); + MessageNumber = reader.ReadEncodedInt(); - MessageString = reader.ReadString(); + MessageString = reader.ReadString(); - break; - } + break; + } } } } public class MoongateConfirmGump : Gump { - private Mobile m_From; - private Moongate m_Gate; + private readonly Mobile m_From; + private readonly Moongate m_Gate; public MoongateConfirmGump(Mobile from, Moongate gate) : base(Core.AOS ? 110 : 20, Core.AOS ? 100 : 30) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs b/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs index fa59ffb9c..e481c9d63 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Misc/PotionKeg.cs @@ -82,12 +82,12 @@ namespace Server.Items { case 1: case 0: - { - m_Type = (PotionEffect)reader.ReadInt(); - m_Held = reader.ReadInt(); + { + m_Type = (PotionEffect)reader.ReadInt(); + m_Held = reader.ReadInt(); - break; - } + break; + } } if (version < 1) @@ -220,16 +220,12 @@ namespace Server.Items if (m_Held == 0) { - #region Mondain's Legacy - if ((int)pot.PotionEffect >= (int)PotionEffect.Invisibility) { from.SendLocalizedMessage(502232); // The keg is not designed to hold that type of object. return false; } - #endregion - if (GiveBottle(from, toHold)) { m_Type = pot.PotionEffect; diff --git a/Projects/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs b/Projects/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs index 4576b430b..f7d853b83 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Misc/RecallRune.cs @@ -69,7 +69,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public Point3D Target{ get; set; } + public Point3D Target { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public Map TargetMap @@ -116,21 +116,21 @@ namespace Server.Items switch (version) { case 1: - { - m_House = reader.ReadItem() as BaseHouse; - goto case 0; - } + { + m_House = reader.ReadItem() as BaseHouse; + goto case 0; + } case 0: - { - m_Description = reader.ReadString(); - m_Marked = reader.ReadBool(); - Target = reader.ReadPoint3D(); - m_TargetMap = reader.ReadMap(); + { + m_Description = reader.ReadString(); + m_Marked = reader.ReadBool(); + Target = reader.ReadPoint3D(); + m_TargetMap = reader.ReadMap(); - CalculateHue(); + CalculateHue(); - break; - } + break; + } } } @@ -288,7 +288,7 @@ namespace Server.Items private class RenamePrompt : Prompt { - private RecallRune m_Rune; + private readonly RecallRune m_Rune; public RenamePrompt(RecallRune rune) => m_Rune = rune; diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs index 0600aec2f..e993c8b40 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Agility Potions/BaseAgilityPotion.cs @@ -14,8 +14,8 @@ namespace Server.Items { } - public abstract int DexOffset{ get; } - public abstract TimeSpan Duration{ get; } + public abstract int DexOffset { get; } + public abstract TimeSpan Duration { get; } public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs index fdcefb224..c0bbb0d8a 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/BasePotion.cs @@ -72,8 +72,6 @@ namespace Server.Items int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => Core.ML; - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -93,8 +91,8 @@ namespace Server.Items PotionKeg keg = kegs[i]; // Should never happen -// if (keg == null) -// continue; + // if (keg == null) + // continue; if (keg.Held <= 0 || keg.Held >= 100) continue; @@ -115,8 +113,6 @@ namespace Server.Items return 1; } - #endregion - public static bool HasFreeHand(Mobile m) { Item handOne = m.FindItemOnLayer(Layer.OneHanded); @@ -187,10 +183,10 @@ namespace Server.Items { case 1: case 0: - { - m_PotionEffect = (PotionEffect)reader.ReadInt(); - break; - } + { + m_PotionEffect = (PotionEffect)reader.ReadInt(); + break; + } } if (version == 0) @@ -205,13 +201,9 @@ namespace Server.Items m.PlaySound(0x2D6); - #region Dueling - if (!DuelContext.IsFreeConsume(m)) m.AddToBackpack(new Bottle()); - #endregion - if (m.Body.IsHuman && !m.Mounted) m.Animate(34, 5, 1, true, false, 0); } diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs index b6c7fcc76..cd02aad96 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Conflagration Potions/BaseConflagrationPotion.cs @@ -7,7 +7,7 @@ namespace Server.Items { public abstract class BaseConflagrationPotion : BasePotion { - private List m_Users = new List(); + private readonly List m_Users = new List(); public BaseConflagrationPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x489; @@ -15,8 +15,8 @@ namespace Server.Items { } - public abstract int MinDamage{ get; } - public abstract int MaxDamage{ get; } + public abstract int MinDamage { get; } + public abstract int MaxDamage { get; } public override bool RequireFreeHand => false; @@ -78,20 +78,20 @@ namespace Server.Items Effects.PlaySound(loc, map, 0x20C); for (int i = -2; i <= 2; i++) - for (int j = -2; j <= 2; j++) - { - Point3D p = new Point3D(loc.X + i, loc.Y + j, loc.Z); + for (int j = -2; j <= 2; j++) + { + Point3D p = new Point3D(loc.X + i, loc.Y + j, loc.Z); - if (map.CanFit(p, 12, true, false) && from.InLOS(p)) - new InternalItem(from, p, map, MinDamage, MaxDamage); - } + if (map.CanFit(p, 12, true, false) && from.InLOS(p)) + new InternalItem(from, p, map, MinDamage, MaxDamage); + } } private class ThrowTarget : Target { public ThrowTarget(BaseConflagrationPotion potion) : base(12, true, TargetFlags.None) => Potion = potion; - public BaseConflagrationPotion Potion{ get; } + public BaseConflagrationPotion Potion { get; } protected override void OnTarget(Mobile from, object targeted) { @@ -147,7 +147,7 @@ namespace Server.Items { } - public Mobile From{ get; private set; } + public Mobile From { get; private set; } public override bool BlocksFit => true; @@ -222,8 +222,8 @@ namespace Server.Items private class InternalTimer : Timer { - private DateTime m_End; - private InternalItem m_Item; + private readonly DateTime m_End; + private readonly InternalItem m_Item; public InternalTimer(InternalItem item, DateTime end) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) { @@ -263,9 +263,7 @@ namespace Server.Items } } - #region Delay - - private static Dictionary m_Delay = new Dictionary(); + private static readonly Dictionary m_Delay = new Dictionary(); public static void AddDelay(Mobile m) { @@ -290,7 +288,5 @@ namespace Server.Items m_Delay.Remove(m); } } - - #endregion } } diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs index babe1cf19..e6fc8e3fd 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Confusion Blast Potions/BaseConfusionBlastPotion.cs @@ -9,7 +9,7 @@ namespace Server.Items { public abstract class BaseConfusionBlastPotion : BasePotion { - private List m_Users = new List(); + private readonly List m_Users = new List(); public BaseConfusionBlastPotion(PotionEffect effect) : base(0xF06, effect) => Hue = 0x48D; @@ -17,7 +17,7 @@ namespace Server.Items { } - public abstract int Radius{ get; } + public abstract int Radius { get; } public override bool RequireFreeHand => false; @@ -96,7 +96,7 @@ namespace Server.Items { public ThrowTarget(BaseConfusionBlastPotion potion) : base(12, true, TargetFlags.None) => Potion = potion; - public BaseConfusionBlastPotion Potion{ get; } + public BaseConfusionBlastPotion Potion { get; } protected override void OnTarget(Mobile from, object targeted) { @@ -125,8 +125,6 @@ namespace Server.Items } } - #region Effects - public virtual void BlastEffect(Point3D p, Map map) { if (map.CanFit(p, 12, true, false)) @@ -138,11 +136,7 @@ namespace Server.Items Geometry.Circle2D(p, m, Radius, BlastEffect, 90, 270); } - #endregion - - #region Delay - - private static Dictionary m_Delay = new Dictionary(); + private static readonly Dictionary m_Delay = new Dictionary(); public static void AddDelay(Mobile m) { @@ -167,7 +161,5 @@ namespace Server.Items m_Delay.Remove(m); } } - - #endregion } } diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs index d1a6d2e44..77447cf5b 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/BaseCurePotion.cs @@ -12,9 +12,9 @@ namespace Server.Items Chance = chance; } - public Poison Poison{ get; } + public Poison Poison { get; } - public double Chance{ get; } + public double Chance { get; } } public abstract class BaseCurePotion : BasePotion @@ -27,7 +27,7 @@ namespace Server.Items { } - public abstract CureLevelInfo[] LevelInfo{ get; } + public abstract CureLevelInfo[] LevelInfo { get; } public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs index 9a4b0c37a..2ae310659 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/CurePotion.cs @@ -2,7 +2,7 @@ namespace Server.Items { public class CurePotion : BaseCurePotion { - private static CureLevelInfo[] m_OldLevelInfo = + private static readonly CureLevelInfo[] m_OldLevelInfo = { new CureLevelInfo(Poison.Lesser, 1.00), // 100% chance to cure lesser poison new CureLevelInfo(Poison.Regular, 0.75), // 75% chance to cure regular poison @@ -10,7 +10,7 @@ namespace Server.Items new CureLevelInfo(Poison.Deadly, 0.15) // 15% chance to cure deadly poison }; - private static CureLevelInfo[] m_AosLevelInfo = + private static readonly CureLevelInfo[] m_AosLevelInfo = { new CureLevelInfo(Poison.Lesser, 1.00), new CureLevelInfo(Poison.Regular, 0.95), diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs index 6235c9363..cf9543b51 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/GreaterCurePotion.cs @@ -2,7 +2,7 @@ namespace Server.Items { public class GreaterCurePotion : BaseCurePotion { - private static CureLevelInfo[] m_OldLevelInfo = + private static readonly CureLevelInfo[] m_OldLevelInfo = { new CureLevelInfo(Poison.Lesser, 1.00), // 100% chance to cure lesser poison new CureLevelInfo(Poison.Regular, 1.00), // 100% chance to cure regular poison @@ -11,7 +11,7 @@ namespace Server.Items new CureLevelInfo(Poison.Lethal, 0.25) // 25% chance to cure lethal poison }; - private static CureLevelInfo[] m_AosLevelInfo = + private static readonly CureLevelInfo[] m_AosLevelInfo = { new CureLevelInfo(Poison.Lesser, 1.00), new CureLevelInfo(Poison.Regular, 1.00), diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs index cc6fd2cbc..2196a9bd9 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Cure Potions/LesserCurePotion.cs @@ -2,14 +2,14 @@ namespace Server.Items { public class LesserCurePotion : BaseCurePotion { - private static CureLevelInfo[] m_OldLevelInfo = + private static readonly CureLevelInfo[] m_OldLevelInfo = { new CureLevelInfo(Poison.Lesser, 0.75), // 75% chance to cure lesser poison new CureLevelInfo(Poison.Regular, 0.50), // 50% chance to cure regular poison new CureLevelInfo(Poison.Greater, 0.15) // 15% chance to cure greater poison }; - private static CureLevelInfo[] m_AosLevelInfo = + private static readonly CureLevelInfo[] m_AosLevelInfo = { new CureLevelInfo(Poison.Lesser, 0.75), new CureLevelInfo(Poison.Regular, 0.50), diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs index 30dc3abfc..97c5eaaa3 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Explosion Potions/BaseExplosionPotion.cs @@ -11,9 +11,9 @@ namespace Server.Items { private const int ExplosionRange = 2; // How long is the blast radius? - private static bool LeveledExplosion = false; // Should explosion potions explode other nearby potions? - private static bool InstantExplosion = false; // Should explosion potions explode on impact? - private static bool RelativeLocation = false; // Is the explosion target location relative for mobiles? + private static readonly bool LeveledExplosion = false; // Should explosion potions explode other nearby potions? + private static readonly bool InstantExplosion = false; // Should explosion potions explode on impact? + private static readonly bool RelativeLocation = false; // Is the explosion target location relative for mobiles? private Timer m_Timer; @@ -25,12 +25,12 @@ namespace Server.Items { } - public abstract int MinDamage{ get; } - public abstract int MaxDamage{ get; } + public abstract int MinDamage { get; } + public abstract int MaxDamage { get; } public override bool RequireFreeHand => false; - public List Users{ get; private set; } + public List Users { get; private set; } public override void Serialize(IGenericWriter writer) { @@ -179,8 +179,8 @@ namespace Server.Items List toExplode = eable.Where(o => { - if (!(o is Mobile mobile) || from != null && - (!SpellHelper.ValidIndirectTarget(from, mobile) || !from.CanBeHarmful(mobile, false))) + if (!(o is Mobile mobile) || (from != null && + (!SpellHelper.ValidIndirectTarget(from, mobile) || !from.CanBeHarmful(mobile, false)))) return o is BaseExplosionPotion && o != this; ++toDamage; @@ -222,7 +222,7 @@ namespace Server.Items { public ThrowTarget(BaseExplosionPotion potion) : base(12, true, TargetFlags.None) => Potion = potion; - public BaseExplosionPotion Potion{ get; } + public BaseExplosionPotion Potion { get; } protected override void OnTarget(Mobile from, object targeted) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs index 537283643..ef31f5781 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Heal Potions/BaseHealPotion.cs @@ -14,9 +14,9 @@ namespace Server.Items { } - public abstract int MinHeal{ get; } - public abstract int MaxHeal{ get; } - public abstract double Delay{ get; } + public abstract int MinHeal { get; } + public abstract int MaxHeal { get; } + public abstract double Delay { get; } public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs index 656592240..168346a82 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/InvisibilityPotion.cs @@ -5,7 +5,7 @@ namespace Server.Items { public class InvisibilityPotion : BasePotion { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public InvisibilityPotion() : base(0xF0A, PotionEffect.Invisibility) => Hue = 0x48D; @@ -44,7 +44,7 @@ namespace Server.Items m.Hidden = true; BuffInfo.RemoveBuff(m, BuffIcon.HidingAndOrStealth); - BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Invisibility, 1075825)); //Invisibility/Invisible + BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Invisibility, 1075825)); // Invisibility/Invisible RemoveTimer(m); diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs index cecdc3bbf..fb2ea428c 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Poison Potions/BasePoisonPotion.cs @@ -12,10 +12,10 @@ namespace Server.Items { } - public abstract Poison Poison{ get; } + public abstract Poison Poison { get; } - public abstract double MinPoisoningSkill{ get; } - public abstract double MaxPoisoningSkill{ get; } + public abstract double MinPoisoningSkill { get; } + public abstract double MaxPoisoningSkill { get; } public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs index 67260ee74..60ff135e4 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Refresh Potions/BaseRefreshPotion.cs @@ -12,7 +12,7 @@ namespace Server.Items { } - public abstract double Refresh{ get; } + public abstract double Refresh { get; } public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs b/Projects/Scripts/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs index d0cf76778..4caa3daeb 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Potions/Strength Potions/BaseStrengthPotion.cs @@ -14,8 +14,8 @@ namespace Server.Items { } - public abstract int StrOffset{ get; } - public abstract TimeSpan Duration{ get; } + public abstract int StrOffset { get; } + public abstract TimeSpan Duration { get; } public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Runebook.cs b/Projects/Scripts/Items/Skill Items/Magical/Runebook.cs index 89714da67..dcfd6c70a 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Runebook.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Runebook.cs @@ -58,7 +58,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public DateTime NextUse{ get; set; } + public DateTime NextUse { get; set; } [CommandProperty(AccessLevel.GameMaster)] public Mobile Crafter @@ -83,16 +83,16 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int CurCharges{ get; set; } + public int CurCharges { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int MaxCharges{ get; set; } + public int MaxCharges { get; set; } - public List Openers{ get; set; } = new List(); + public List Openers { get; set; } = new List(); public override int LabelNumber => 1041267; // runebook - public List Entries{ get; private set; } + public List Entries { get; private set; } public RunebookEntry Default { @@ -114,8 +114,6 @@ namespace Server.Items public override bool DisplayLootType => Core.AOS; - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -134,10 +132,8 @@ namespace Server.Items return quality; } - #endregion - [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override bool AllowEquippedCast(Mobile from) => true; @@ -184,36 +180,36 @@ namespace Server.Items switch (version) { case 3: - { - m_Quality = (BookQuality)reader.ReadByte(); - goto case 2; - } + { + m_Quality = (BookQuality)reader.ReadByte(); + goto case 2; + } case 2: - { - m_Crafter = reader.ReadMobile(); - goto case 1; - } + { + m_Crafter = reader.ReadMobile(); + goto case 1; + } case 1: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 0; + } case 0: - { - int count = reader.ReadInt(); + { + int count = reader.ReadInt(); - Entries = new List(count); + Entries = new List(count); - for (int i = 0; i < count; ++i) - Entries.Add(new RunebookEntry(reader)); + for (int i = 0; i < count; ++i) + Entries.Add(new RunebookEntry(reader)); - m_Description = reader.ReadString(); - CurCharges = reader.ReadInt(); - MaxCharges = reader.ReadInt(); - m_DefaultIndex = reader.ReadInt(); + m_Description = reader.ReadString(); + CurCharges = reader.ReadInt(); + MaxCharges = reader.ReadInt(); + m_DefaultIndex = reader.ReadInt(); - break; - } + break; + } } } @@ -346,7 +342,7 @@ namespace Server.Items BaseHouse house = BaseHouse.FindHouseAt(this); - return (house?.IsAosRules != true || house.Public && !house.IsBanned(m) || house.HasAccess(m)) && + return (house?.IsAosRules != true || (house.Public && !house.IsBanned(m)) || house.HasAccess(m)) && house?.HasSecureAccess(m, Level) == true; } @@ -437,28 +433,28 @@ namespace Server.Items switch (version) { case 1: - { - House = reader.ReadItem() as BaseHouse; - goto case 0; - } + { + House = reader.ReadItem() as BaseHouse; + goto case 0; + } case 0: - { - Location = reader.ReadPoint3D(); - Map = reader.ReadMap(); - Description = reader.ReadString(); + { + Location = reader.ReadPoint3D(); + Map = reader.ReadMap(); + Description = reader.ReadString(); - break; - } + break; + } } } - public Point3D Location{ get; } + public Point3D Location { get; } - public Map Map{ get; } + public Map Map { get; } - public string Description{ get; } + public string Description { get; } - public BaseHouse House{ get; } + public BaseHouse House { get; } public void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs b/Projects/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs index 63e3e4d5d..d140f8b25 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Scrolls/SpellScroll.cs @@ -21,7 +21,7 @@ namespace Server.Items { } - public int SpellID{ get; private set; } + public int SpellID { get; private set; } int ICommodity.DescriptionNumber => LabelNumber; bool ICommodity.IsDeedable => Core.ML; @@ -44,11 +44,11 @@ namespace Server.Items switch (version) { case 0: - { - SpellID = reader.ReadInt(); + { + SpellID = reader.ReadInt(); - break; - } + break; + } } } diff --git a/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs b/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs index 94e8a6bfe..38e2c4e86 100644 --- a/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs +++ b/Projects/Scripts/Items/Skill Items/Magical/Spellbook.cs @@ -30,9 +30,9 @@ namespace Server.Items public class Spellbook : Item, ICraftable, ISlayer { - private static Dictionary> m_Table = new Dictionary>(); + private static readonly Dictionary> m_Table = new Dictionary>(); - private static int[] m_LegendPropertyCounts = + private static readonly int[] m_LegendPropertyCounts = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 properties : 21/52 : 40% 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 property : 15/52 : 29% @@ -40,7 +40,7 @@ namespace Server.Items 3, 3, 3, 3, 3, 3 // 3 properties : 6/52 : 12% }; - private static int[] m_ElderPropertyCounts = + private static readonly int[] m_ElderPropertyCounts = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 properties : 15/34 : 44% 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 1 property : 10/34 : 29% @@ -48,7 +48,7 @@ namespace Server.Items 3, 3, 3 // 3 properties : 3/34 : 9% }; - private static int[] m_GrandPropertyCounts = + private static readonly int[] m_GrandPropertyCounts = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 properties : 10/20 : 50% 1, 1, 1, 1, 1, 1, // 1 property : 6/20 : 30% @@ -56,14 +56,14 @@ namespace Server.Items 3 // 3 properties : 1/20 : 5% }; - private static int[] m_MasterPropertyCounts = + private static readonly int[] m_MasterPropertyCounts = { 0, 0, 0, 0, 0, 0, // 0 properties : 6/10 : 60% 1, 1, 1, // 1 property : 3/10 : 30% 2 // 2 properties : 1/10 : 10% }; - private static int[] m_AdeptPropertyCounts = + private static readonly int[] m_AdeptPropertyCounts = { 0, 0, 0, // 0 properties : 3/4 : 75% 1 // 1 property : 1/4 : 25% @@ -75,7 +75,6 @@ namespace Server.Items private string m_EngravedText; private BookQuality m_Quality; - private SlayerName m_Slayer; private SlayerName m_Slayer2; @@ -121,10 +120,10 @@ namespace Server.Items public override bool DisplayWeight => false; [CommandProperty(AccessLevel.GameMaster)] - public AosAttributes Attributes{ get; private set; } + public AosAttributes Attributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosSkillBonuses SkillBonuses{ get; private set; } + public AosSkillBonuses SkillBonuses { get; private set; } public virtual SpellbookType SpellbookType => SpellbookType.Regular; public virtual int BookOffset => 0; @@ -154,7 +153,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int SpellCount{ get; private set; } + public int SpellCount { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public Mobile Crafter @@ -217,7 +216,7 @@ namespace Server.Items return quality; } - //Currently though there are no dual slayer spellbooks, OSI has a habit of putting dual slayer stuff in later + // Currently though there are no dual slayer spellbooks, OSI has a habit of putting dual slayer stuff in later [CommandProperty(AccessLevel.GameMaster)] public SlayerName Slayer @@ -318,7 +317,7 @@ namespace Server.Items if (move != null) SpecialMove.SetCurrentMove(from, move); else - SpellRegistry.NewSpell(spellId, @from, null)?.Cast(); + SpellRegistry.NewSpell(spellId, from, null)?.Cast(); } private static void EventSink_CastSpellRequest(Mobile from, int spellID, Item item) @@ -432,7 +431,7 @@ namespace Server.Items Spellbook book = list[i]; - if (!book.Deleted && (book.Parent == from || pack != null && book.Parent == pack) && + if (!book.Deleted && (book.Parent == from || (pack != null && book.Parent == pack)) && ValidateSpellbook(book, spellID, type)) return book; @@ -704,7 +703,7 @@ namespace Server.Items if ((prop = Attributes.RegenMana) != 0) list.Add(1060440, prop.ToString()); // mana regeneration ~1_val~ - if ((Attributes.NightSight) != 0) + if (Attributes.NightSight != 0) list.Add(1060441); // night sight if ((prop = Attributes.ReflectPhysical) != 0) @@ -716,7 +715,7 @@ namespace Server.Items if ((prop = Attributes.RegenHits) != 0) list.Add(1060444, prop.ToString()); // hit point regeneration ~1_val~ - if ((Attributes.SpellChanneling) != 0) + if (Attributes.SpellChanneling != 0) list.Add(1060482); // spell channeling if ((prop = Attributes.SpellDamage) != 0) @@ -751,7 +750,7 @@ namespace Server.Items { Container pack = from.Backpack; - if (Parent == from || pack != null && Parent == pack) + if (Parent == from || (pack != null && Parent == pack)) DisplayTo(from); else from.SendLocalizedMessage( @@ -789,42 +788,42 @@ namespace Server.Items switch (version) { case 5: - { - m_Quality = (BookQuality)reader.ReadByte(); + { + m_Quality = (BookQuality)reader.ReadByte(); - goto case 4; - } + goto case 4; + } case 4: - { - m_EngravedText = reader.ReadString(); + { + m_EngravedText = reader.ReadString(); - goto case 3; - } + goto case 3; + } case 3: - { - m_Crafter = reader.ReadMobile(); - goto case 2; - } + { + m_Crafter = reader.ReadMobile(); + goto case 2; + } case 2: - { - m_Slayer = (SlayerName)reader.ReadInt(); - m_Slayer2 = (SlayerName)reader.ReadInt(); - goto case 1; - } + { + m_Slayer = (SlayerName)reader.ReadInt(); + m_Slayer2 = (SlayerName)reader.ReadInt(); + goto case 1; + } case 1: - { - Attributes = new AosAttributes(this, reader); - SkillBonuses = new AosSkillBonuses(this, reader); + { + Attributes = new AosAttributes(this, reader); + SkillBonuses = new AosSkillBonuses(this, reader); - goto case 0; - } + goto case 0; + } case 0: - { - m_Content = reader.ReadULong(); - SpellCount = reader.ReadInt(); + { + m_Content = reader.ReadULong(); + SpellCount = reader.ReadInt(); - break; - } + break; + } } Attributes ??= new AosAttributes(this); diff --git a/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs b/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs index 8b154506c..8bdbffcc9 100644 --- a/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs +++ b/Projects/Scripts/Items/Skill Items/Misc/Bandage.cs @@ -95,7 +95,7 @@ namespace Server.Items private class InternalTarget : Target { - private Bandage m_Bandage; + private readonly Bandage m_Bandage; public InternalTarget(Bandage bandage) : base(Bandage.Range, false, TargetFlags.Beneficial) => m_Bandage = bandage; @@ -144,7 +144,7 @@ namespace Server.Items public class BandageContext { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public BandageContext(Mobile healer, Mobile patient, TimeSpan delay) { @@ -155,13 +155,13 @@ namespace Server.Items Timer.Start(); } - public Mobile Healer{ get; } + public Mobile Healer { get; } - public Mobile Patient{ get; } + public Mobile Patient { get; } - public int Slips{ get; set; } + public int Slips { get; set; } - public Timer Timer{ get; private set; } + public Timer Timer { get; private set; } public void Slip() { @@ -227,9 +227,8 @@ namespace Server.Items double anatomy = Healer.Skills[secondarySkill].Value; double chance = (healing - 68.0) / 50.0 - Slips * 0.02; - if ((checkSkills = healing >= 80.0 && anatomy >= 80.0) && chance > Utility.RandomDouble() - || Core.SE && petPatient is FactionWarHorse && petPatient.ControlMaster == Healer - ) //TODO: Dbl check doesn't check for faction of the horse here? + if (((checkSkills = healing >= 80.0 && anatomy >= 80.0) && chance > Utility.RandomDouble()) + || (Core.SE && petPatient is FactionWarHorse && petPatient.ControlMaster == Healer)) // TODO: Dbl check doesn't check for faction of the horse here? { if (Patient.Map?.CanFit(Patient.Location, 16, false, false) != true) { @@ -494,7 +493,7 @@ namespace Server.Items m_Table[healer] = context; if (!onSelf) - patient.SendLocalizedMessage(1008078, false, healer.Name); // : Attempting to heal you. + patient.SendLocalizedMessage(1008078, false, healer.Name); // : Attempting to heal you. healer.SendLocalizedMessage(500956); // You begin applying the bandages. return context; @@ -505,7 +504,7 @@ namespace Server.Items private class InternalTimer : Timer { - private BandageContext m_Context; + private readonly BandageContext m_Context; public InternalTimer(BandageContext context, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Items/Skill Items/Misc/FireHorn.cs b/Projects/Scripts/Items/Skill Items/Misc/FireHorn.cs index 44835c7ba..f6e72dd31 100644 --- a/Projects/Scripts/Items/Skill Items/Misc/FireHorn.cs +++ b/Projects/Scripts/Items/Skill Items/Misc/FireHorn.cs @@ -89,14 +89,13 @@ namespace Server.Items List targets = eable.Where(m => { if (from == m || !SpellHelper.ValidIndirectTarget(from, m) || !from.CanBeHarmful(m, false) - || Core.AOS && !from.InLOS(m)) + || (Core.AOS && !from.InLOS(m))) return false; if (m.Player) playerVsPlayer = true; return true; - }).ToList(); eable.Free(); @@ -194,7 +193,7 @@ namespace Server.Items private class InternalTarget : Target { - private FireHorn m_Horn; + private readonly FireHorn m_Horn; public InternalTarget(FireHorn horn) : base(Core.AOS ? 3 : 2, true, TargetFlags.Harmful) => m_Horn = horn; diff --git a/Projects/Scripts/Items/Skill Items/Misc/RecipeScroll.cs b/Projects/Scripts/Items/Skill Items/Misc/RecipeScroll.cs index 53e190a8d..ea745b4ab 100644 --- a/Projects/Scripts/Items/Skill Items/Misc/RecipeScroll.cs +++ b/Projects/Scripts/Items/Skill Items/Misc/RecipeScroll.cs @@ -105,11 +105,11 @@ namespace Server.Items switch (version) { case 0: - { - m_RecipeID = reader.ReadInt(); + { + m_RecipeID = reader.ReadInt(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs b/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs index c501e85fb..861b18554 100644 --- a/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs +++ b/Projects/Scripts/Items/Skill Items/Misc/RepairDeed.cs @@ -23,8 +23,7 @@ namespace Server.Items private double m_SkillLevel; [Constructible] - public RepairDeed(RepairSkillType skill, double level, bool normalizeLevel) : - this(skill, level, null, normalizeLevel) + public RepairDeed(RepairSkillType skill, double level, bool normalizeLevel) : this(skill, level, null, normalizeLevel) { } @@ -95,7 +94,7 @@ namespace Server.Items if (m_Crafter != null) list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ - //On OSI it says it's exceptional. Intentional difference. + // On OSI it says it's exceptional. Intentional difference. } public override void OnSingleClick(Mobile from) @@ -176,13 +175,13 @@ namespace Server.Items switch (version) { case 0: - { - m_Skill = (RepairSkillType)reader.ReadInt(); - m_SkillLevel = reader.ReadDouble(); - m_Crafter = reader.ReadMobile(); + { + m_Skill = (RepairSkillType)reader.ReadInt(); + m_SkillLevel = reader.ReadDouble(); + m_Crafter = reader.ReadMobile(); - break; - } + break; + } } } @@ -202,16 +201,15 @@ namespace Server.Items { } - public TextDefinition NotNearbyMessage{ get; } + public TextDefinition NotNearbyMessage { get; } - public TextDefinition Name{ get; } + public TextDefinition Name { get; } + public CraftSystem System { get; } - public CraftSystem System{ get; } + public Type[] NearbyTypes { get; } - public Type[] NearbyTypes{ get; } - - public static RepairSkillInfo[] Table{ get; } = + public static RepairSkillInfo[] Table { get; } = { new RepairSkillInfo(DefBlacksmithy.CraftSystem, typeof(Blacksmith), 1047013, 1023015), new RepairSkillInfo(DefTailoring.CraftSystem, typeof(Tailor), 1061132, 1022981), diff --git a/Projects/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Projects/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs index 343099f3b..27f87d889 100644 --- a/Projects/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Projects/Scripts/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -18,7 +18,7 @@ namespace Server.Items public abstract class BaseInstrument : Item, ICraftable, ISlayer { - private static Dictionary m_Instruments = new Dictionary(); + private static readonly Dictionary m_Instruments = new Dictionary(); private Mobile m_Crafter; private DateTime m_LastReplenished; @@ -40,10 +40,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int SuccessSound{ get; set; } + public int SuccessSound { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int FailureSound{ get; set; } + public int FailureSound { get; set; } [CommandProperty(AccessLevel.GameMaster)] public InstrumentQuality Quality @@ -113,8 +113,6 @@ namespace Server.Items } } - #region ICraftable Members - public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) { @@ -126,8 +124,6 @@ namespace Server.Items return quality; } - #endregion - [CommandProperty(AccessLevel.GameMaster)] public SlayerName Slayer { @@ -160,7 +156,7 @@ namespace Server.Items TimeSpan timeDifference = DateTime.UtcNow - m_LastReplenished; m_UsesRemaining = Math.Min(m_UsesRemaining + (int)(timeDifference.Ticks / ChargeReplenishRate.Ticks), - InitMaxUses); //How rude of TimeSpan to not allow timespan division. + InitMaxUses); // How rude of TimeSpan to not allow timespan division. m_LastReplenished = DateTime.UtcNow; if (invalidate) @@ -171,7 +167,7 @@ namespace Server.Items public void ScaleUses() { UsesRemaining = UsesRemaining * GetUsesScalar() / 100; - //InvalidateProperties(); + // InvalidateProperties(); } public void UnscaleUses() @@ -425,7 +421,6 @@ namespace Server.Items if (m_ReplenishesCharges) writer.Write(m_LastReplenished); - writer.Write(m_Crafter); writer.WriteEncodedInt((int)m_Quality); @@ -447,51 +442,51 @@ namespace Server.Items switch (version) { case 3: - { - m_ReplenishesCharges = reader.ReadBool(); + { + m_ReplenishesCharges = reader.ReadBool(); - if (m_ReplenishesCharges) - m_LastReplenished = reader.ReadDateTime(); + if (m_ReplenishesCharges) + m_LastReplenished = reader.ReadDateTime(); - goto case 2; - } + goto case 2; + } case 2: - { - m_Crafter = reader.ReadMobile(); + { + m_Crafter = reader.ReadMobile(); - m_Quality = (InstrumentQuality)reader.ReadEncodedInt(); - m_Slayer = (SlayerName)reader.ReadEncodedInt(); - m_Slayer2 = (SlayerName)reader.ReadEncodedInt(); + m_Quality = (InstrumentQuality)reader.ReadEncodedInt(); + m_Slayer = (SlayerName)reader.ReadEncodedInt(); + m_Slayer2 = (SlayerName)reader.ReadEncodedInt(); - UsesRemaining = reader.ReadEncodedInt(); + UsesRemaining = reader.ReadEncodedInt(); - SuccessSound = reader.ReadEncodedInt(); - FailureSound = reader.ReadEncodedInt(); + SuccessSound = reader.ReadEncodedInt(); + FailureSound = reader.ReadEncodedInt(); - break; - } + break; + } case 1: - { - m_Crafter = reader.ReadMobile(); + { + m_Crafter = reader.ReadMobile(); - m_Quality = (InstrumentQuality)reader.ReadEncodedInt(); - m_Slayer = (SlayerName)reader.ReadEncodedInt(); + m_Quality = (InstrumentQuality)reader.ReadEncodedInt(); + m_Slayer = (SlayerName)reader.ReadEncodedInt(); - UsesRemaining = reader.ReadEncodedInt(); + UsesRemaining = reader.ReadEncodedInt(); - SuccessSound = reader.ReadEncodedInt(); - FailureSound = reader.ReadEncodedInt(); + SuccessSound = reader.ReadEncodedInt(); + FailureSound = reader.ReadEncodedInt(); - break; - } + break; + } case 0: - { - SuccessSound = reader.ReadInt(); - FailureSound = reader.ReadInt(); - UsesRemaining = Utility.RandomMinMax(InitMinUses, InitMaxUses); + { + SuccessSound = reader.ReadInt(); + FailureSound = reader.ReadInt(); + UsesRemaining = Utility.RandomMinMax(InitMinUses, InitMaxUses); - break; - } + break; + } } CheckReplenishUses(); @@ -540,7 +535,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_From; + private readonly Mobile m_From; public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(6.0)) { diff --git a/Projects/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs b/Projects/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs index 60afa590e..9ecbcc502 100644 --- a/Projects/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs +++ b/Projects/Scripts/Items/Skill Items/Ninjitsu/Fukiya.cs @@ -24,11 +24,11 @@ namespace Server.Items { } - public virtual int WrongAmmoMessage => 1063329; //You can only load fukiya darts - public virtual int NoFreeHandMessage => 1063327; //You must have a free hand to use a fukiya. - public virtual int EmptyWeaponMessage => 1063325; //You have no fukiya darts! - public virtual int RecentlyUsedMessage => 1063326; //You are already using that fukiya. - public virtual int FullWeaponMessage => 1063330; //You can only load fukiya darts + public virtual int WrongAmmoMessage => 1063329; // You can only load fukiya darts + public virtual int NoFreeHandMessage => 1063327; // You must have a free hand to use a fukiya. + public virtual int EmptyWeaponMessage => 1063325; // You have no fukiya darts! + public virtual int RecentlyUsedMessage => 1063326; // You are already using that fukiya. + public virtual int FullWeaponMessage => 1063330; // You can only load fukiya darts public virtual int WeaponMinRange => 0; public virtual int WeaponMaxRange => 6; @@ -131,14 +131,14 @@ namespace Server.Items switch (version) { case 0: - { - m_UsesRemaining = reader.ReadInt(); + { + m_UsesRemaining = reader.ReadInt(); - m_Poison = Poison.Deserialize(reader); - m_PoisonCharges = reader.ReadInt(); + m_Poison = Poison.Deserialize(reader); + m_PoisonCharges = reader.ReadInt(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs b/Projects/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs index 09b5eb0c7..69154296c 100644 --- a/Projects/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs +++ b/Projects/Scripts/Items/Skill Items/Ninjitsu/FukiyaDarts.cs @@ -100,14 +100,14 @@ namespace Server.Items switch (version) { case 0: - { - m_UsesRemaining = reader.ReadInt(); + { + m_UsesRemaining = reader.ReadInt(); - m_Poison = Poison.Deserialize(reader); - m_PoisonCharges = reader.ReadInt(); + m_Poison = Poison.Deserialize(reader); + m_PoisonCharges = reader.ReadInt(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs b/Projects/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs index b97692191..e0162bb3b 100644 --- a/Projects/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs +++ b/Projects/Scripts/Items/Skill Items/Ninjitsu/LeatherNinjaBelt.cs @@ -15,7 +15,6 @@ namespace Server.Items [Constructible] public LeatherNinjaBelt() : base(0x2790) - { Weight = 1.0; Layer = Layer.Waist; @@ -27,11 +26,11 @@ namespace Server.Items public override CraftResource DefaultResource => CraftResource.RegularLeather; - public virtual int WrongAmmoMessage => 1063301; //You can only place shuriken in a ninja belt. - public virtual int NoFreeHandMessage => 1063299; //You must have a free hand to throw shuriken. - public virtual int EmptyWeaponMessage => 1063297; //You have no shuriken in your ninja belt! - public virtual int RecentlyUsedMessage => 1063298; //You cannot throw another shuriken yet. - public virtual int FullWeaponMessage => 1063302; //You cannot add any more shuriken. + public virtual int WrongAmmoMessage => 1063301; // You can only place shuriken in a ninja belt. + public virtual int NoFreeHandMessage => 1063299; // You must have a free hand to throw shuriken. + public virtual int EmptyWeaponMessage => 1063297; // You have no shuriken in your ninja belt! + public virtual int RecentlyUsedMessage => 1063298; // You cannot throw another shuriken yet. + public virtual int FullWeaponMessage => 1063302; // You cannot add any more shuriken. public virtual int WeaponMinRange => 2; public virtual int WeaponMaxRange => 10; @@ -145,14 +144,14 @@ namespace Server.Items switch (version) { case 0: - { - m_UsesRemaining = reader.ReadInt(); + { + m_UsesRemaining = reader.ReadInt(); - m_Poison = Poison.Deserialize(reader); - m_PoisonCharges = reader.ReadInt(); + m_Poison = Poison.Deserialize(reader); + m_PoisonCharges = reader.ReadInt(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs b/Projects/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs index 2209703f1..085846c3d 100644 --- a/Projects/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs +++ b/Projects/Scripts/Items/Skill Items/Ninjitsu/NinjaWeapons.cs @@ -18,23 +18,23 @@ namespace Server.Items { public interface INinjaAmmo : IUsesRemaining { - int PoisonCharges{ get; set; } - Poison Poison{ get; set; } + int PoisonCharges { get; set; } + Poison Poison { get; set; } } public interface INinjaWeapon : IUsesRemaining { - int NoFreeHandMessage{ get; } - int EmptyWeaponMessage{ get; } - int RecentlyUsedMessage{ get; } - int FullWeaponMessage{ get; } - int WrongAmmoMessage{ get; } - Type AmmoType{ get; } - int PoisonCharges{ get; set; } - Poison Poison{ get; set; } - int WeaponDamage{ get; } - int WeaponMinRange{ get; } - int WeaponMaxRange{ get; } + int NoFreeHandMessage { get; } + int EmptyWeaponMessage { get; } + int RecentlyUsedMessage { get; } + int FullWeaponMessage { get; } + int WrongAmmoMessage { get; } + Type AmmoType { get; } + int PoisonCharges { get; set; } + Poison Poison { get; set; } + int WeaponDamage { get; } + int WeaponMinRange { get; } + int WeaponMaxRange { get; } void AttackAnimation(Mobile from, Mobile to); } @@ -114,8 +114,8 @@ namespace Server.Items else { if (weapon.UsesRemaining > 0) - if (weapon.Poison == null && ammo.Poison != null - || weapon.Poison != null && ammo.Poison != null && weapon.Poison.Level != ammo.Poison.Level) + if ((weapon.Poison == null && ammo.Poison != null) + || (weapon.Poison != null && ammo.Poison != null && weapon.Poison.Level != ammo.Poison.Level)) { Unload(from, weapon); need = Math.Min(MaxUses, ammo.UsesRemaining); @@ -276,7 +276,7 @@ namespace Server.Items public class LoadEntry : ContextMenuEntry { - private INinjaWeapon weapon; + private readonly INinjaWeapon weapon; public LoadEntry(INinjaWeapon wep, int entry) : base(entry, 0) => @@ -291,7 +291,7 @@ namespace Server.Items public class UnloadEntry : ContextMenuEntry { - private INinjaWeapon weapon; + private readonly INinjaWeapon weapon; public UnloadEntry(INinjaWeapon wep, int entry) : base(entry, 0) diff --git a/Projects/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs b/Projects/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs index 7e017a788..38654d935 100644 --- a/Projects/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs +++ b/Projects/Scripts/Items/Skill Items/Ninjitsu/Shuriken.cs @@ -101,14 +101,14 @@ namespace Server.Items switch (version) { case 0: - { - m_UsesRemaining = reader.ReadInt(); + { + m_UsesRemaining = reader.ReadInt(); - m_Poison = Poison.Deserialize(reader); - m_PoisonCharges = reader.ReadInt(); + m_Poison = Poison.Deserialize(reader); + m_PoisonCharges = reader.ReadInt(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs index e5ba3d041..37e7bb7c1 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/CustomHuePicker.cs @@ -17,11 +17,11 @@ namespace Server.Items Hues = hues; } - public int Name{ get; } + public int Name { get; } - public string NameString{ get; } + public string NameString { get; } - public int[] Hues{ get; } + public int[] Hues { get; } } public class CustomHuePicker @@ -94,26 +94,25 @@ namespace Server.Items TitleString = title; } - public bool DefaultSupported{ get; } + public bool DefaultSupported { get; } - public CustomHueGroup[] Groups{ get; } + public CustomHueGroup[] Groups { get; } - public int Title{ get; } + public int Title { get; } - public string TitleString{ get; } + public string TitleString { get; } } public delegate void CustomHuePickerCallback(Mobile from, T state, int hue); public class CustomHuePickerGump : Gump { - private CustomHuePickerCallback m_Callback; - private CustomHuePicker m_Definition; - private Mobile m_From; - private T m_State; + private readonly CustomHuePickerCallback m_Callback; + private readonly CustomHuePicker m_Definition; + private readonly Mobile m_From; + private readonly T m_State; - public CustomHuePickerGump(Mobile from, CustomHuePicker definition, CustomHuePickerCallback callback, T state) : - base(50, 50) + public CustomHuePickerGump(Mobile from, CustomHuePicker definition, CustomHuePickerCallback callback, T state) : base(50, 50) { m_From = from; m_Definition = definition; @@ -181,34 +180,34 @@ namespace Server.Items switch (info.ButtonID) { case 1: // Okay - { - int[] switches = info.Switches; - - if (switches.Length > 0) { - int index = switches[0]; + int[] switches = info.Switches; - int group = index % m_Definition.Groups.Length; - index /= m_Definition.Groups.Length; - - if (group >= 0 && group < m_Definition.Groups.Length) + if (switches.Length > 0) { - int[] hues = m_Definition.Groups[group].Hues; + int index = switches[0]; - if (index >= 0 && index < hues.Length) - m_Callback(m_From, m_State, hues[index]); + int group = index % m_Definition.Groups.Length; + index /= m_Definition.Groups.Length; + + if (group >= 0 && group < m_Definition.Groups.Length) + { + int[] hues = m_Definition.Groups[group].Hues; + + if (index >= 0 && index < hues.Length) + m_Callback(m_From, m_State, hues[index]); + } } + + break; } - - break; - } case 2: // Default - { - if (m_Definition.DefaultSupported) - m_Callback(m_From, m_State, 0); + { + if (m_Definition.DefaultSupported) + m_Callback(m_From, m_State, 0); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs index f81e14aa8..f036e493a 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs @@ -70,7 +70,7 @@ namespace Server.Items public virtual int FailMessage => 1042083; [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override void Serialize(IGenericWriter writer) { @@ -92,17 +92,17 @@ namespace Server.Items switch (version) { case 1: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 0; + } case 0: - { - m_Redyable = reader.ReadBool(); - m_DyedHue = reader.ReadInt(); + { + m_Redyable = reader.ReadBool(); + m_DyedHue = reader.ReadInt(); - break; - } + break; + } } } @@ -127,7 +127,7 @@ namespace Server.Items private class InternalTarget : Target { - private DyeTub m_Tub; + private readonly DyeTub m_Tub; public InternalTarget(DyeTub tub) : base(1, false, TargetFlags.None) => m_Tub = tub; @@ -164,7 +164,7 @@ namespace Server.Items { BaseHouse house = BaseHouse.FindHouseAt(item); - if (house == null || !house.HasLockedDownItem(item) && !house.HasSecureItem(item)) + if (house == null || (!house.HasLockedDownItem(item) && !house.HasSecureItem(item))) from.SendLocalizedMessage(501022); // Furniture must be locked down to paint it. else if (!house.IsCoOwner(from)) from.SendLocalizedMessage(501023); // You must be the owner to use this item. @@ -217,9 +217,9 @@ namespace Server.Items from.PlaySound(0x23E); } } - else if ((item is BaseArmor armor && + else if (((item is BaseArmor armor && (armor.MaterialType == ArmorMaterialType.Leather || - armor.MaterialType == ArmorMaterialType.Studded) || item is ElvenBoots || + armor.MaterialType == ArmorMaterialType.Studded)) || item is ElvenBoots || item is WoodlandBelt) && m_Tub.AllowLeather) { if (!from.InRange(m_Tub.GetWorldLocation(), 1) || !from.InRange(item.GetWorldLocation(), 1)) diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs index 09502f5de..11903513d 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/FurnitureDyeTub.cs @@ -18,7 +18,7 @@ namespace Server.Items public override int LabelNumber => 1041246; // Furniture Dye Tub [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnDoubleClick(Mobile from) { @@ -54,10 +54,10 @@ namespace Server.Items switch (version) { case 1: - { - IsRewardItem = reader.ReadBool(); - break; - } + { + IsRewardItem = reader.ReadBool(); + break; + } } if (LootType == LootType.Regular) diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs index e1bc46dd9..67b6dddc6 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/LeatherDyeTub.cs @@ -19,7 +19,7 @@ namespace Server.Items public override CustomHuePicker CustomHuePicker => CustomHuePicker.LeatherDyeTub; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnDoubleClick(Mobile from) { @@ -55,10 +55,10 @@ namespace Server.Items switch (version) { case 1: - { - IsRewardItem = reader.ReadBool(); - break; - } + { + IsRewardItem = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs index 4a2f9a02b..99a211c8a 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/MetallicHuePicker.cs @@ -5,10 +5,10 @@ namespace Server.Items { public class MetallicHuePicker : Gump { - private CustomHuePickerCallback m_Callback; + private readonly CustomHuePickerCallback m_Callback; - private Mobile m_From; - private T m_State; + private readonly Mobile m_From; + private readonly T m_State; public MetallicHuePicker(Mobile from, CustomHuePickerCallback callback, T state) : base(450, 450) @@ -61,16 +61,16 @@ namespace Server.Items switch (info.ButtonID) { case 1: // Okay - { - if (info.Switches.Length > 0) m_Callback(m_From, m_State, info.Switches[0]); - break; - } + { + if (info.Switches.Length > 0) m_Callback(m_From, m_State, info.Switches[0]); + break; + } case 2: // Default - { - m_Callback(m_From, m_State, 0); + { + m_Callback(m_From, m_State, 0); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs index c3fe60482..c57c1238e 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RewardBlackDyeTub.cs @@ -19,7 +19,7 @@ namespace Server.Items public override int LabelNumber => 1006008; // Black Dye Tub [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnDoubleClick(Mobile from) { @@ -55,10 +55,10 @@ namespace Server.Items switch (version) { case 1: - { - IsRewardItem = reader.ReadBool(); - break; - } + { + IsRewardItem = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs index 728c0bd6a..096a06afc 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/RunebookDyeTub.cs @@ -19,7 +19,7 @@ namespace Server.Items public override CustomHuePicker CustomHuePicker => CustomHuePicker.LeatherDyeTub; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnDoubleClick(Mobile from) { @@ -55,10 +55,10 @@ namespace Server.Items switch (version) { case 1: - { - IsRewardItem = reader.ReadBool(); - break; - } + { + IsRewardItem = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs index 492ac58e5..63c603d37 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/SpecialDyeTub.cs @@ -15,7 +15,7 @@ namespace Server.Items public override int LabelNumber => 1041285; // Special Dye Tub [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnDoubleClick(Mobile from) { @@ -51,10 +51,10 @@ namespace Server.Items switch (version) { case 1: - { - IsRewardItem = reader.ReadBool(); - break; - } + { + IsRewardItem = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs index fe6240a71..83644ada5 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/StatuetteDyeTub.cs @@ -19,7 +19,7 @@ namespace Server.Items public override CustomHuePicker CustomHuePicker => CustomHuePicker.LeatherDyeTub; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnDoubleClick(Mobile from) { @@ -55,10 +55,10 @@ namespace Server.Items switch (version) { case 1: - { - IsRewardItem = reader.ReadBool(); - break; - } + { + IsRewardItem = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/WhiteLeatherDyeTub.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/WhiteLeatherDyeTub.cs index 992213ced..b489715f0 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/WhiteLeatherDyeTub.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Dyetubs/WhiteLeatherDyeTub.cs @@ -9,7 +9,6 @@ namespace Server.Items LootType = LootType.Blessed; } - public WhiteLeatherDyeTub(Serial serial) : base(serial) { diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Dyes.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Dyes.cs index c513c420f..dc23c16c7 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Dyes.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Dyes.cs @@ -89,7 +89,7 @@ namespace Server.Items private class InternalPicker : HuePicker { - private DyeTub m_Tub; + private readonly DyeTub m_Tub; public InternalPicker(DyeTub tub) : base(tub.ItemID) => m_Tub = tub; diff --git a/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Scissors.cs b/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Scissors.cs index 06e862aa9..28174d041 100644 --- a/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Scissors.cs +++ b/Projects/Scripts/Items/Skill Items/Tailor Items/Misc/Scissors.cs @@ -53,7 +53,7 @@ namespace Server.Items private class InternalTarget : Target { - private Scissors m_Item; + private readonly Scissors m_Item; public InternalTarget(Scissors item) : base(2, false, TargetFlags.None) => m_Item = item; @@ -62,7 +62,7 @@ namespace Server.Items if (m_Item.Deleted) return; - /*if ( targeted is Item && !((Item)targeted).IsStandardLoot() ) + /*if (targeted is Item && !((Item)targeted).IsStandardLoot()) { from.SendLocalizedMessage( 502440 ); // Scissors can not be used on that to produce anything. } @@ -71,7 +71,7 @@ namespace Server.Items { from.SendLocalizedMessage( 1062845 + Utility - .Random(3)); //"That doesn't seem like the smartest thing to do." / "That was an encounter you don't wish to repeat." / "Ha! You missed!" + .Random(3)); // "That doesn't seem like the smartest thing to do." / "That was an encounter you don't wish to repeat." / "Ha! You missed!" } else if (Core.SE && Utility.RandomDouble() > .20 && (from.Direction & Direction.Running) != 0 && Core.TickCount - from.LastMoveTime < from.ComputeMovementSpeed(from.Direction)) @@ -110,4 +110,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Skill Items/Thief/DisguiseKit.cs b/Projects/Scripts/Items/Skill Items/Thief/DisguiseKit.cs index b3310ac29..aeaee2db3 100644 --- a/Projects/Scripts/Items/Skill Items/Thief/DisguiseKit.cs +++ b/Projects/Scripts/Items/Skill Items/Thief/DisguiseKit.cs @@ -71,7 +71,7 @@ namespace Server.Items public class DisguiseGump : Gump { - private static DisguiseEntry[] m_HairEntries = + private static readonly DisguiseEntry[] m_HairEntries = { new DisguiseEntry(8251, 50700, 0, 5, 1011052), // Short new DisguiseEntry(8261, 60710, 0, 3, 1011047), // Pageboy @@ -85,7 +85,7 @@ namespace Server.Items new DisguiseEntry(0, 0, 0, 0, 1011051) // None }; - private static DisguiseEntry[] m_BeardEntries = + private static readonly DisguiseEntry[] m_BeardEntries = { new DisguiseEntry(8269, 50906, 0, 0, 1011401), // Vandyke new DisguiseEntry(8257, 50808, 0, -2, 1011062), // Mustache @@ -97,9 +97,9 @@ namespace Server.Items new DisguiseEntry(0, 0, 0, 0, 1011051) // None }; - private Mobile m_From; - private DisguiseKit m_Kit; - private bool m_Used; + private readonly Mobile m_From; + private readonly DisguiseKit m_Kit; + private readonly bool m_Used; public DisguiseGump(Mobile from, DisguiseKit kit, bool startAtHair, bool used) : base(50, 50) { @@ -228,11 +228,11 @@ namespace Server.Items private class DisguiseEntry { - public int m_GumpID; - public int m_ItemID; - public int m_Number; - public int m_OffsetX; - public int m_OffsetY; + public readonly int m_GumpID; + public readonly int m_ItemID; + public readonly int m_Number; + public readonly int m_OffsetX; + public readonly int m_OffsetY; public DisguiseEntry(int itemID, int gumpID, int ox, int oy, int name) { @@ -247,7 +247,7 @@ namespace Server.Items public class DisguiseTimers { - public static Dictionary Timers{ get; } = new Dictionary(); + public static Dictionary Timers { get; } = new Dictionary(); public static void Initialize() { @@ -294,7 +294,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_Player; + private readonly Mobile m_Player; public InternalTimer(Mobile m, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs b/Projects/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs index ee89b6bd6..62b3c0e36 100644 --- a/Projects/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs +++ b/Projects/Scripts/Items/Skill Items/Thief/DisguisePersistance.cs @@ -17,7 +17,7 @@ namespace Server.Items public DisguisePersistance(Serial serial) : base(serial) => Instance = this; - public static DisguisePersistance Instance{ get; private set; } + public static DisguisePersistance Instance { get; private set; } public override string DefaultName => "Disguise Persistance - Internal"; @@ -50,18 +50,18 @@ namespace Server.Items switch (version) { case 0: - { - int count = reader.ReadInt(); - - for (int i = 0; i < count; ++i) { - Mobile m = reader.ReadMobile(); - DisguiseTimers.CreateTimer(m, reader.ReadTimeSpan()); - m.NameMod = reader.ReadString(); - } + int count = reader.ReadInt(); - break; - } + for (int i = 0; i < count; ++i) + { + Mobile m = reader.ReadMobile(); + DisguiseTimers.CreateTimer(m, reader.ReadTimeSpan()); + m.NameMod = reader.ReadString(); + } + + break; + } } } diff --git a/Projects/Scripts/Items/Skill Items/Thief/LockPick.cs b/Projects/Scripts/Items/Skill Items/Thief/LockPick.cs index f0687218e..b2d09502e 100644 --- a/Projects/Scripts/Items/Skill Items/Thief/LockPick.cs +++ b/Projects/Scripts/Items/Skill Items/Thief/LockPick.cs @@ -5,16 +5,15 @@ namespace Server.Items { public interface ILockpickable : IPoint2D { - int LockLevel{ get; set; } - bool Locked{ get; set; } - Mobile Picker{ get; set; } - int MaxLockLevel{ get; set; } - int RequiredSkill{ get; set; } + int LockLevel { get; set; } + bool Locked { get; set; } + Mobile Picker { get; set; } + int MaxLockLevel { get; set; } + int RequiredSkill { get; set; } void LockPick(Mobile from); } - [Flippable(0x14fc, 0x14fb)] public class Lockpick : Item { @@ -54,7 +53,7 @@ namespace Server.Items private class InternalTarget : Target { - private Lockpick m_Item; + private readonly Lockpick m_Item; public InternalTarget(Lockpick item) : base(1, false, TargetFlags.None) => m_Item = item; @@ -88,9 +87,9 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_From; - private ILockpickable m_Item; - private Lockpick m_Lockpick; + private readonly Mobile m_From; + private readonly ILockpickable m_Item; + private readonly Lockpick m_Lockpick; public InternalTimer(Mobile from, ILockpickable item, Lockpick lockpick) : base(TimeSpan.FromSeconds(3.0)) { diff --git a/Projects/Scripts/Items/Skill Items/Tinkering/Clocks.cs b/Projects/Scripts/Items/Skill Items/Tinkering/Clocks.cs index 363692451..1c4d22165 100644 --- a/Projects/Scripts/Items/Skill Items/Tinkering/Clocks.cs +++ b/Projects/Scripts/Items/Skill Items/Tinkering/Clocks.cs @@ -20,7 +20,7 @@ namespace Server.Items public const double SecondsPerUOMinute = 5.0; public const double MinutesPerUODay = SecondsPerUOMinute * 24; - private static DateTime WorldStart = new DateTime(1997, 9, 1); + private static readonly DateTime WorldStart = new DateTime(1997, 9, 1); [Constructible] public Clock(int itemID = 0x104B) : base(itemID) => Weight = 3.0; @@ -29,7 +29,7 @@ namespace Server.Items { } - public static DateTime ServerStart{ get; private set; } + public static DateTime ServerStart { get; private set; } public static void Initialize() { diff --git a/Projects/Scripts/Items/Skill Items/Tinkering/Spyglass.cs b/Projects/Scripts/Items/Skill Items/Tinkering/Spyglass.cs index eaa92166c..b97c8f5d9 100644 --- a/Projects/Scripts/Items/Skill Items/Tinkering/Spyglass.cs +++ b/Projects/Scripts/Items/Skill Items/Tinkering/Spyglass.cs @@ -33,7 +33,7 @@ namespace Server.Items return; FindIngredientObjective obj = qs.FindObjective(); - + if (obj?.Completed == false && obj.Ingredient == Ingredient.StarChart) { Clock.GetTime(from.Map, from.X, from.Y, out int hours, out int _); diff --git a/Projects/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs b/Projects/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs index 5b742e8ae..a7d22357b 100644 --- a/Projects/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs +++ b/Projects/Scripts/Items/Skill Items/Tools/BaseRunicTool.cs @@ -11,7 +11,7 @@ namespace Server.Items private static bool m_IsRunicTool; private static int m_LuckChance; - private static SkillName[] m_PossibleBonusSkills = + private static readonly SkillName[] m_PossibleBonusSkills = { SkillName.Swords, SkillName.Fencing, @@ -43,7 +43,7 @@ namespace Server.Items SkillName.Ninjitsu }; - private static SkillName[] m_PossibleSpellbookSkills = + private static readonly SkillName[] m_PossibleSpellbookSkills = { SkillName.Magery, SkillName.Meditation, @@ -51,8 +51,8 @@ namespace Server.Items SkillName.MagicResist }; - private static BitArray m_Props = new BitArray(MaxProperties); - private static int[] m_Possible = new int[MaxProperties]; + private static readonly BitArray m_Props = new BitArray(MaxProperties); + private static readonly int[] m_Possible = new int[MaxProperties]; private CraftResource m_Resource; public BaseRunicTool(CraftResource resource, int itemID) : base(itemID) => m_Resource = resource; @@ -92,10 +92,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Resource = (CraftResource)reader.ReadInt(); - break; - } + { + m_Resource = (CraftResource)reader.ReadInt(); + break; + } } } @@ -291,62 +291,62 @@ namespace Server.Items switch (random) { case 0: - { - switch (Utility.Random(5)) { - case 0: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitPhysicalArea, 2, 50, 2); - break; - case 1: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitFireArea, 2, 50, 2); - break; - case 2: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitColdArea, 2, 50, 2); - break; - case 3: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitPoisonArea, 2, 50, 2); - break; - case 4: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitEnergyArea, 2, 50, 2); - break; - } + switch (Utility.Random(5)) + { + case 0: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitPhysicalArea, 2, 50, 2); + break; + case 1: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitFireArea, 2, 50, 2); + break; + case 2: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitColdArea, 2, 50, 2); + break; + case 3: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitPoisonArea, 2, 50, 2); + break; + case 4: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitEnergyArea, 2, 50, 2); + break; + } - break; - } + break; + } case 1: - { - switch (Utility.Random(4)) { - case 0: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitMagicArrow, 2, 50, 2); - break; - case 1: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitHarm, 2, 50, 2); - break; - case 2: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitFireball, 2, 50, 2); - break; - case 3: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLightning, 2, 50, 2); - break; - } + switch (Utility.Random(4)) + { + case 0: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitMagicArrow, 2, 50, 2); + break; + case 1: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitHarm, 2, 50, 2); + break; + case 2: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitFireball, 2, 50, 2); + break; + case 3: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.HitLightning, 2, 50, 2); + break; + } - break; - } + break; + } case 2: - { - switch (Utility.Random(2)) { - case 0: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.UseBestSkill, 1, 1); - break; - case 1: - ApplyAttribute(secondary, min, max, AosWeaponAttribute.MageWeapon, 1, 10); - break; - } + switch (Utility.Random(2)) + { + case 0: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.UseBestSkill, 1, 1); + break; + case 1: + ApplyAttribute(secondary, min, max, AosWeaponAttribute.MageWeapon, 1, 10); + break; + } - break; - } + break; + } case 3: ApplyAttribute(primary, min, max, AosAttribute.WeaponDamage, 1, 50); break; @@ -446,22 +446,20 @@ namespace Server.Items attrs[rand] = temp; } - /* - totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Cold, totalDamage ); - totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Energy, totalDamage ); - totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Fire, totalDamage ); - totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Poison, totalDamage ); + totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Cold, totalDamage ); + totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Energy, totalDamage ); + totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Fire, totalDamage ); + totalDamage = AssignElementalDamage( weapon, AosElementAttribute.Poison, totalDamage ); - weapon.AosElementDamages[AosElementAttribute.Physical] = 100 - totalDamage; + weapon.AosElementDamages[AosElementAttribute.Physical] = 100 - totalDamage; * */ for (int i = 0; i < attrs.Length; i++) totalDamage = AssignElementalDamage(weapon, attrs[i], totalDamage); - - //Order is Cold, Energy, Fire, Poison -> Physical left - //Cannot be looped, AoselementAttribute is 'out of order' + // Order is Cold, Energy, Fire, Poison -> Physical left + // Cannot be looped, AoselementAttribute is 'out of order' weapon.Hue = weapon.GetElementalDamageHue(); } @@ -489,10 +487,10 @@ namespace Server.Items SlayerGroup group = groups[ Utility.Random(groups.Length - - 1)]; //-1 To Exclude the Fey Slayer which appears ONLY on a certain artifact. + 1)]; // -1 To Exclude the Fey Slayer which appears ONLY on a certain artifact. SlayerEntry entry; - if (10 > Utility.Random(100)) // 10% chance to do super slayer + if (Utility.Random(100) < 10) // 10% chance to do super slayer { entry = group.Super; } @@ -646,7 +644,7 @@ namespace Server.Items case 23: ApplyResistance(armor, min, max, ResistanceType.Energy, 1, 15); break; - /* End Armor */ + /* End Armor */ } } } @@ -869,14 +867,14 @@ namespace Server.Items case 1: case 2: case 3: - { - ApplyAttribute(primary, min, max, AosAttribute.BonusInt, 1, 8); + { + ApplyAttribute(primary, min, max, AosAttribute.BonusInt, 1, 8); - for (int j = 0; j < 4; ++j) - m_Props.Set(j, true); + for (int j = 0; j < 4; ++j) + m_Props.Set(j, true); - break; - } + break; + } case 4: ApplyAttribute(primary, min, max, AosAttribute.BonusMana, 1, 8); break; @@ -917,4 +915,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs b/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs index 82a928404..18ac64e21 100644 --- a/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs +++ b/Projects/Scripts/Items/Skill Items/Tools/BaseTool.cs @@ -57,9 +57,7 @@ namespace Server.Items public virtual bool BreakOnDepletion => true; - public abstract CraftSystem CraftSystem{ get; } - - #region ICraftable Members + public abstract CraftSystem CraftSystem { get; } public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) @@ -72,8 +70,6 @@ namespace Server.Items return quality; } - #endregion - [CommandProperty(AccessLevel.GameMaster)] public int UsesRemaining { @@ -85,7 +81,7 @@ namespace Server.Items } } - private bool ShowUsesRemaining{ get; set; } = true; + private bool ShowUsesRemaining { get; set; } = true; bool IUsesRemaining.ShowUsesRemaining { @@ -117,8 +113,8 @@ namespace Server.Items base.GetProperties(list); // Makers mark not displayed on OSI - //if ( m_Crafter != null ) - // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ + // if (m_Crafter != null) + // list.Add( 1050043, m_Crafter.Name ); // crafted by ~1_NAME~ if (m_Quality == ToolQuality.Exceptional) list.Add(1060636); // exceptional @@ -163,8 +159,7 @@ namespace Server.Items int num = system.CanCraft(from, this, null); - if (num > 0 && (num != 1044267 || !Core.SE) - ) // Blacksmithing shows the gump regardless of proximity of an anvil and forge after SE + if (num > 0 && (num != 1044267 || !Core.SE)) // Blacksmithing shows the gump regardless of proximity of an anvil and forge after SE { from.SendLocalizedMessage(num); } @@ -202,17 +197,17 @@ namespace Server.Items switch (version) { case 1: - { - m_Crafter = reader.ReadMobile(); - m_Quality = (ToolQuality)reader.ReadInt(); - goto case 0; - } + { + m_Crafter = reader.ReadMobile(); + m_Quality = (ToolQuality)reader.ReadInt(); + goto case 0; + } case 0: - { - m_UsesRemaining = reader.ReadInt(); - break; - } + { + m_UsesRemaining = reader.ReadInt(); + break; + } } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs b/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs index 2db5df996..89df2f2d7 100644 --- a/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs +++ b/Projects/Scripts/Items/Special/11th Year promo/EarringsOfProtection.cs @@ -97,11 +97,11 @@ { return element switch { - AosElementAttribute.Physical => (label ? 1071091 : 0), // Earring of Protection (Physical) 1071091 - AosElementAttribute.Fire => (label ? 1071092 : 0x4ec), // Earring of Protection (Fire) 1071092 - AosElementAttribute.Cold => (label ? 1071093 : 0x4f2), // Earring of Protection (Cold) 1071093 - AosElementAttribute.Poison => (label ? 1071094 : 0x4f8), // Earring of Protection (Poison) 1071094 - AosElementAttribute.Energy => (label ? 1071095 : 0x4fe), // Earring of Protection (Energy) 1071095 + AosElementAttribute.Physical => label ? 1071091 : 0, // Earring of Protection (Physical) 1071091 + AosElementAttribute.Fire => label ? 1071092 : 0x4ec, // Earring of Protection (Fire) 1071092 + AosElementAttribute.Cold => label ? 1071093 : 0x4f2, // Earring of Protection (Cold) 1071093 + AosElementAttribute.Poison => label ? 1071094 : 0x4f8, // Earring of Protection (Poison) 1071094 + AosElementAttribute.Energy => label ? 1071095 : 0x4fe, // Earring of Protection (Energy) 1071095 _ => -1 }; } diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs index 1831fde61..9e38224bd 100644 --- a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs +++ b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicBox.cs @@ -13,7 +13,7 @@ namespace Server.Items public StopMusic() : base(0x6D, 3) { - m_Stream.Write((short)0x1FFF); + Stream.Write((short)0x1FFF); } } @@ -76,10 +76,10 @@ namespace Server.Items public override int LabelNumber => 1075198; // Dawn�s Music Box - public List Tracks{ get; private set; } + public List Tracks { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override void OnAfterDuped(Item newItem) { diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs index 60daa9602..f4400f69b 100644 --- a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs +++ b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicGear.cs @@ -30,7 +30,7 @@ namespace Server.Items public static DawnsMusicGear RandomRare => new DawnsMusicGear(DawnsMusicBox.RandomTrack(DawnsMusicRarity.Rare)); [CommandProperty(AccessLevel.GameMaster)] - public MusicName Music{ get; set; } + public MusicName Music { get; set; } public override void AddNameProperty(ObjectPropertyList list) { @@ -76,10 +76,10 @@ namespace Server.Items switch (version) { case 1: - { - Music = (MusicName)reader.ReadInt(); - break; - } + { + Music = (MusicName)reader.ReadInt(); + break; + } } if (version == 0) // Music wasn't serialized in version 0, pick a new track of random rarity @@ -100,7 +100,7 @@ namespace Server.Items public class InternalTarget : Target { - private DawnsMusicGear m_Gear; + private readonly DawnsMusicGear m_Gear; public InternalTarget(DawnsMusicGear gear) : base(2, false, TargetFlags.None) => m_Gear = gear; diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicInfo.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicInfo.cs index 3f7245464..c02d3663b 100644 --- a/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicInfo.cs +++ b/Projects/Scripts/Items/Special/8th Anniversary Items/Dawn's Music Box/DawnsMusicInfo.cs @@ -15,8 +15,8 @@ Rarity = rarity; } - public int Name{ get; } + public int Name { get; } - public DawnsMusicRarity Rarity{ get; } + public DawnsMusicRarity Rarity { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/DupresShield.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/DupresShield.cs index e840b5d53..26a826e97 100644 --- a/Projects/Scripts/Items/Special/8th Anniversary Items/DupresShield.cs +++ b/Projects/Scripts/Items/Special/8th Anniversary Items/DupresShield.cs @@ -37,7 +37,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs index 175f3ebd6..41fce1e8d 100644 --- a/Projects/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs +++ b/Projects/Scripts/Items/Special/8th Anniversary Items/FountainOfLife.cs @@ -31,7 +31,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version } public override void Deserialize(IGenericReader reader) @@ -135,7 +135,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version writer.Write(m_Charges); writer.Write(m_Timer.Next); @@ -231,7 +231,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version writer.Write(m_Charges); } diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/OssianGrimoire.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/OssianGrimoire.cs index 8bdeeed98..1f12f8163 100644 --- a/Projects/Scripts/Items/Special/8th Anniversary Items/OssianGrimoire.cs +++ b/Projects/Scripts/Items/Special/8th Anniversary Items/OssianGrimoire.cs @@ -23,7 +23,7 @@ { base.Serialize(writer); - writer.WriteEncodedInt(1); //version + writer.WriteEncodedInt(1); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Items/Special/8th Anniversary Items/Talismans.cs b/Projects/Scripts/Items/Special/8th Anniversary Items/Talismans.cs index 7d498b7ad..f43c85e52 100644 --- a/Projects/Scripts/Items/Special/8th Anniversary Items/Talismans.cs +++ b/Projects/Scripts/Items/Special/8th Anniversary Items/Talismans.cs @@ -36,7 +36,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version } public override void Deserialize(IGenericReader reader) @@ -85,7 +85,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version } public override void Deserialize(IGenericReader reader) @@ -113,7 +113,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version } public override void Deserialize(IGenericReader reader) @@ -141,7 +141,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version } public override void Deserialize(IGenericReader reader) @@ -169,7 +169,7 @@ namespace Server.Items { base.Serialize(writer); - writer.WriteEncodedInt(0); //version + writer.WriteEncodedInt(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Items/Special/AoS Promotional/LuckyNecklace.cs b/Projects/Scripts/Items/Special/AoS Promotional/LuckyNecklace.cs index d3dcd03d5..71b4086d6 100644 --- a/Projects/Scripts/Items/Special/AoS Promotional/LuckyNecklace.cs +++ b/Projects/Scripts/Items/Special/AoS Promotional/LuckyNecklace.cs @@ -15,7 +15,7 @@ } public override int Hue => 1150; - public override int LabelNumber => 1075239; //Lucky Necklace 1075239 + public override int LabelNumber => 1075239; // Lucky Necklace 1075239 public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs b/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs index 34127658d..59b7049dd 100644 --- a/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs +++ b/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenBed.cs @@ -93,7 +93,7 @@ namespace Server.Items private class InternalGump : Gump { - private BrokenBedDeed m_Deed; + private readonly BrokenBedDeed m_Deed; public InternalGump(BrokenBedDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs b/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs index 97f1c599d..4a165d653 100644 --- a/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs +++ b/Projects/Scripts/Items/Special/Broken Furniture Collection/BrokenVanity.cs @@ -89,7 +89,7 @@ namespace Server.Items private class InternalGump : Gump { - private BrokenVanityDeed m_Deed; + private readonly BrokenVanityDeed m_Deed; public InternalGump(BrokenVanityDeed deed) : base(60, 63) { diff --git a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs index 8e7f9e7a6..920db89c4 100644 --- a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs +++ b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/AncientSmithyHammer.cs @@ -99,10 +99,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Bonus = reader.ReadInt(); - break; - } + { + m_Bonus = reader.ReadInt(); + break; + } } if (m_Bonus != 0 && Parent is Mobile mobile) diff --git a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs index 8f0f237eb..279c55e87 100644 --- a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs +++ b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/GlovesOfMining.cs @@ -221,10 +221,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Bonus = reader.ReadInt(); - break; - } + { + m_Bonus = reader.ReadInt(); + break; + } } if (m_Bonus != 0 && Parent is Mobile mobile) diff --git a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs index 51246e962..df90d976f 100644 --- a/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs +++ b/Projects/Scripts/Items/Special/Bulk Order Rewards/Blacksmithy/PowderOfTemperament.cs @@ -55,10 +55,10 @@ namespace Server.Items switch (version) { case 0: - { - m_UsesRemaining = reader.ReadInt(); - break; - } + { + m_UsesRemaining = reader.ReadInt(); + break; + } } } @@ -91,7 +91,7 @@ namespace Server.Items private class InternalTarget : Target { - private PowderOfTemperament m_Powder; + private readonly PowderOfTemperament m_Powder; public InternalTarget(PowderOfTemperament powder) : base(2, false, TargetFlags.None) => m_Powder = powder; @@ -111,7 +111,7 @@ namespace Server.Items return; } - if ((item.IsChildOf(from.Backpack) || Core.ML && item.Parent == from) && + if ((item.IsChildOf(from.Backpack) || (Core.ML && item.Parent == from)) && m_Powder.IsChildOf(from.Backpack)) { int origMaxHP = wearable.MaxHitPoints; diff --git a/Projects/Scripts/Items/Special/Community Collection/JesterHatofChuckles.cs b/Projects/Scripts/Items/Special/Community Collection/JesterHatofChuckles.cs index b37b5adba..b96cb743d 100644 --- a/Projects/Scripts/Items/Special/Community Collection/JesterHatofChuckles.cs +++ b/Projects/Scripts/Items/Special/Community Collection/JesterHatofChuckles.cs @@ -18,7 +18,7 @@ { } - public override int LabelNumber => 1073256; //Jester Hat of Chuckles - Museum of Vesper Replica 1073256 + public override int LabelNumber => 1073256; // Jester Hat of Chuckles - Museum of Vesper Replica 1073256 public override int BasePhysicalResistance => 12; public override int BaseFireResistance => 12; diff --git a/Projects/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs b/Projects/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs index ed9e4f990..310e5b786 100644 --- a/Projects/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs +++ b/Projects/Scripts/Items/Special/Evil Home Decor Collection/AwesomeDisturbingPortrait.cs @@ -105,7 +105,7 @@ namespace Server.Items private class InternalTimer : Timer { - private AwesomeDisturbingPortraitComponent m_Component; + private readonly AwesomeDisturbingPortraitComponent m_Component; public InternalTimer(AwesomeDisturbingPortraitComponent c, TimeSpan delay) : base(delay, TimeSpan.FromMinutes(10)) diff --git a/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs b/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs index beb7aa83b..75222e397 100644 --- a/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs +++ b/Projects/Scripts/Items/Special/Evil Home Decor Collection/BedOfNails.cs @@ -113,7 +113,7 @@ namespace Server.Items private class InternalTimer : Timer { private Point3D m_Location; - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1), 5) diff --git a/Projects/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs b/Projects/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs index 10fe9ffea..e05c89c9d 100644 --- a/Projects/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs +++ b/Projects/Scripts/Items/Special/Gifts/HearthOfHomeFire.cs @@ -97,7 +97,7 @@ namespace Server.Items private class InternalGump : Gump { - private HearthOfHomeFireDeed m_Deed; + private readonly HearthOfHomeFireDeed m_Deed; public InternalGump(HearthOfHomeFireDeed deed) : base(150, 50) { diff --git a/Projects/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs b/Projects/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs index 0a4725c49..2c402febc 100644 --- a/Projects/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs +++ b/Projects/Scripts/Items/Special/Gifts/RoseOfTrinsic.cs @@ -59,7 +59,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override void GetProperties(ObjectPropertyList list) { @@ -134,7 +134,7 @@ namespace Server.Items private class SpawnTimer : Timer { - private RoseOfTrinsic m_Rose; + private readonly RoseOfTrinsic m_Rose; public SpawnTimer(RoseOfTrinsic rose, TimeSpan delay) : base(delay) { @@ -172,7 +172,6 @@ namespace Server.Items public override int LabelNumber => 1062926; // Petal of the Rose of Trinsic - public override void OnDoubleClick(Mobile from) { if (!IsChildOf(from.Backpack)) diff --git a/Projects/Scripts/Items/Special/Gifts/TapestryOfSosaria.cs b/Projects/Scripts/Items/Special/Gifts/TapestryOfSosaria.cs index 98a57b91b..b840fd19c 100644 --- a/Projects/Scripts/Items/Special/Gifts/TapestryOfSosaria.cs +++ b/Projects/Scripts/Items/Special/Gifts/TapestryOfSosaria.cs @@ -23,7 +23,7 @@ namespace Server.Items public override int LabelNumber => 1062917; // The Tapestry of Sosaria [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override void GetContextMenuEntries(Mobile from, List list) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/Curtains.cs b/Projects/Scripts/Items/Special/Heritage Items/Curtains.cs index 84d9f851b..009f3c237 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/Curtains.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/Curtains.cs @@ -15,9 +15,7 @@ namespace Server.Items public override bool DisplayWeight => false; [CommandProperty(AccessLevel.GameMaster)] - public int ClosedID{ get; set; } - - #region IDyable + public int ClosedID { get; set; } public virtual bool Dye(Mobile from, DyeTub sender) { @@ -28,8 +26,6 @@ namespace Server.Items return true; } - #endregion - public override void OnDoubleClick(Mobile from) { base.OnDoubleClick(from); @@ -159,7 +155,7 @@ namespace Server.Items private class InternalGump : Gump { - private CurtainsDeed m_Deed; + private readonly CurtainsDeed m_Deed; public InternalGump(CurtainsDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/FruitTrees.cs b/Projects/Scripts/Items/Special/Heritage Items/FruitTrees.cs index 5b7bf5959..dfc8e6654 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/FruitTrees.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/FruitTrees.cs @@ -16,8 +16,8 @@ namespace Server.Items { } - public abstract override BaseAddonDeed Deed{ get; } - public abstract Item Fruit{ get; } + public abstract override BaseAddonDeed Deed { get; } + public abstract Item Fruit { get; } [CommandProperty(AccessLevel.GameMaster)] public int Fruits diff --git a/Projects/Scripts/Items/Special/Heritage Items/HangingAxes.cs b/Projects/Scripts/Items/Special/Heritage Items/HangingAxes.cs index 49e80ddb3..7053fcc3e 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/HangingAxes.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/HangingAxes.cs @@ -89,7 +89,7 @@ namespace Server.Items private class InternalGump : Gump { - private HangingAxesDeed m_Deed; + private readonly HangingAxesDeed m_Deed; public InternalGump(HangingAxesDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/HangingSwords.cs b/Projects/Scripts/Items/Special/Heritage Items/HangingSwords.cs index 37870e242..b7849cdc9 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/HangingSwords.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/HangingSwords.cs @@ -89,7 +89,7 @@ namespace Server.Items private class InternalGump : Gump { - private HangingSwordsDeed m_Deed; + private readonly HangingSwordsDeed m_Deed; public InternalGump(HangingSwordsDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/HouseLadder.cs b/Projects/Scripts/Items/Special/Heritage Items/HouseLadder.cs index 4f50d613b..4a504c202 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/HouseLadder.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/HouseLadder.cs @@ -114,7 +114,7 @@ namespace Server.Items private class InternalGump : Gump { - private HouseLadderDeed m_Deed; + private readonly HouseLadderDeed m_Deed; public InternalGump(HouseLadderDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/IronMaiden.cs b/Projects/Scripts/Items/Special/Heritage Items/IronMaiden.cs index b1a250f3a..aa70d57c0 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/IronMaiden.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/IronMaiden.cs @@ -60,7 +60,7 @@ namespace Server.Items if (c.ItemID < 0x124D) return; - + // blood int amount = Utility.RandomMinMax(3, 7); diff --git a/Projects/Scripts/Items/Special/Heritage Items/Statue.cs b/Projects/Scripts/Items/Special/Heritage Items/Statue.cs index cf05382b3..c66fd356d 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/Statue.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/Statue.cs @@ -91,7 +91,7 @@ namespace Server.Items private class InternalGump : Gump { - private StoneStatueDeed m_Deed; + private readonly StoneStatueDeed m_Deed; public InternalGump(StoneStatueDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/UnmadeBed.cs b/Projects/Scripts/Items/Special/Heritage Items/UnmadeBed.cs index d57073405..42a55f9ec 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/UnmadeBed.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/UnmadeBed.cs @@ -93,7 +93,7 @@ namespace Server.Items private class InternalGump : Gump { - private UnmadeBedDeed m_Deed; + private readonly UnmadeBedDeed m_Deed; public InternalGump(UnmadeBedDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/Vanity.cs b/Projects/Scripts/Items/Special/Heritage Items/Vanity.cs index 87ff95b26..5803f6c26 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/Vanity.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/Vanity.cs @@ -86,7 +86,7 @@ namespace Server.Items private class InternalGump : Gump { - private VanityDeed m_Deed; + private readonly VanityDeed m_Deed; public InternalGump(VanityDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs b/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs index aedfee5ef..61fcaccfd 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/WallTorch.cs @@ -51,7 +51,6 @@ namespace Server.Items } } - public class WallTorchAddon : BaseAddon { public WallTorchAddon() diff --git a/Projects/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs b/Projects/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs index 29eb4a75e..e7a4071f6 100644 --- a/Projects/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs +++ b/Projects/Scripts/Items/Special/Heritage Items/WoodenCoffin.cs @@ -118,7 +118,7 @@ namespace Server.Items private class InternalGump : Gump { - private WoodenCoffinDeed m_Deed; + private readonly WoodenCoffinDeed m_Deed; public InternalGump(WoodenCoffinDeed deed) : base(60, 36) { diff --git a/Projects/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs b/Projects/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs index c66d6f883..82a3599d6 100644 --- a/Projects/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs +++ b/Projects/Scripts/Items/Special/Holiday/Christmas/HolidayTree.cs @@ -25,71 +25,71 @@ namespace Server.Items switch (type) { case HolidayTreeType.Classic: - { - ItemID = 0xCD7; + { + ItemID = 0xCD7; - AddItem(0, 0, 0, new TreeTrunk(this, 0xCD6)); + AddItem(0, 0, 0, new TreeTrunk(this, 0xCD6)); - AddOrnament(0, 0, 2, 0xF22); - AddOrnament(0, 0, 9, 0xF18); - AddOrnament(0, 0, 15, 0xF20); - AddOrnament(0, 0, 19, 0xF17); - AddOrnament(0, 0, 20, 0xF24); - AddOrnament(0, 0, 20, 0xF1F); - AddOrnament(0, 0, 20, 0xF19); - AddOrnament(0, 0, 21, 0xF1B); - AddOrnament(0, 0, 28, 0xF2F); - AddOrnament(0, 0, 30, 0xF23); - AddOrnament(0, 0, 32, 0xF2A); - AddOrnament(0, 0, 33, 0xF30); - AddOrnament(0, 0, 34, 0xF29); - AddOrnament(0, 1, 7, 0xF16); - AddOrnament(0, 1, 7, 0xF1E); - AddOrnament(0, 1, 12, 0xF0F); - AddOrnament(0, 1, 13, 0xF13); - AddOrnament(0, 1, 18, 0xF12); - AddOrnament(0, 1, 19, 0xF15); - AddOrnament(0, 1, 25, 0xF28); - AddOrnament(0, 1, 29, 0xF1A); - AddOrnament(0, 1, 37, 0xF2B); - AddOrnament(1, 0, 13, 0xF10); - AddOrnament(1, 0, 14, 0xF1C); - AddOrnament(1, 0, 16, 0xF14); - AddOrnament(1, 0, 17, 0xF26); - AddOrnament(1, 0, 22, 0xF27); + AddOrnament(0, 0, 2, 0xF22); + AddOrnament(0, 0, 9, 0xF18); + AddOrnament(0, 0, 15, 0xF20); + AddOrnament(0, 0, 19, 0xF17); + AddOrnament(0, 0, 20, 0xF24); + AddOrnament(0, 0, 20, 0xF1F); + AddOrnament(0, 0, 20, 0xF19); + AddOrnament(0, 0, 21, 0xF1B); + AddOrnament(0, 0, 28, 0xF2F); + AddOrnament(0, 0, 30, 0xF23); + AddOrnament(0, 0, 32, 0xF2A); + AddOrnament(0, 0, 33, 0xF30); + AddOrnament(0, 0, 34, 0xF29); + AddOrnament(0, 1, 7, 0xF16); + AddOrnament(0, 1, 7, 0xF1E); + AddOrnament(0, 1, 12, 0xF0F); + AddOrnament(0, 1, 13, 0xF13); + AddOrnament(0, 1, 18, 0xF12); + AddOrnament(0, 1, 19, 0xF15); + AddOrnament(0, 1, 25, 0xF28); + AddOrnament(0, 1, 29, 0xF1A); + AddOrnament(0, 1, 37, 0xF2B); + AddOrnament(1, 0, 13, 0xF10); + AddOrnament(1, 0, 14, 0xF1C); + AddOrnament(1, 0, 16, 0xF14); + AddOrnament(1, 0, 17, 0xF26); + AddOrnament(1, 0, 22, 0xF27); - break; - } + break; + } case HolidayTreeType.Modern: - { - ItemID = 0x1B7E; + { + ItemID = 0x1B7E; - AddOrnament(0, 0, 2, 0xF2F); - AddOrnament(0, 0, 2, 0xF20); - AddOrnament(0, 0, 2, 0xF22); - AddOrnament(0, 0, 5, 0xF30); - AddOrnament(0, 0, 5, 0xF15); - AddOrnament(0, 0, 5, 0xF1F); - AddOrnament(0, 0, 5, 0xF2B); - AddOrnament(0, 0, 6, 0xF0F); - AddOrnament(0, 0, 7, 0xF1E); - AddOrnament(0, 0, 7, 0xF24); - AddOrnament(0, 0, 8, 0xF29); - AddOrnament(0, 0, 9, 0xF18); - AddOrnament(0, 0, 14, 0xF1C); - AddOrnament(0, 0, 15, 0xF13); - AddOrnament(0, 0, 15, 0xF20); - AddOrnament(0, 0, 16, 0xF26); - AddOrnament(0, 0, 17, 0xF12); - AddOrnament(0, 0, 18, 0xF17); - AddOrnament(0, 0, 20, 0xF1B); - AddOrnament(0, 0, 23, 0xF28); - AddOrnament(0, 0, 25, 0xF18); - AddOrnament(0, 0, 25, 0xF2A); - AddOrnament(0, 1, 7, 0xF16); + AddOrnament(0, 0, 2, 0xF2F); + AddOrnament(0, 0, 2, 0xF20); + AddOrnament(0, 0, 2, 0xF22); + AddOrnament(0, 0, 5, 0xF30); + AddOrnament(0, 0, 5, 0xF15); + AddOrnament(0, 0, 5, 0xF1F); + AddOrnament(0, 0, 5, 0xF2B); + AddOrnament(0, 0, 6, 0xF0F); + AddOrnament(0, 0, 7, 0xF1E); + AddOrnament(0, 0, 7, 0xF24); + AddOrnament(0, 0, 8, 0xF29); + AddOrnament(0, 0, 9, 0xF18); + AddOrnament(0, 0, 14, 0xF1C); + AddOrnament(0, 0, 15, 0xF13); + AddOrnament(0, 0, 15, 0xF20); + AddOrnament(0, 0, 16, 0xF26); + AddOrnament(0, 0, 17, 0xF12); + AddOrnament(0, 0, 18, 0xF17); + AddOrnament(0, 0, 20, 0xF1B); + AddOrnament(0, 0, 23, 0xF28); + AddOrnament(0, 0, 25, 0xF18); + AddOrnament(0, 0, 25, 0xF2A); + AddOrnament(0, 1, 7, 0xF16); - break; - } + break; + } } } @@ -98,7 +98,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Placer{ get; set; } + public Mobile Placer { get; set; } public override int LabelNumber => 1041117; // a tree for the holidays @@ -147,27 +147,27 @@ namespace Server.Items switch (version) { case 1: - { - Placer = reader.ReadMobile(); - - goto case 0; - } - case 0: - { - int count = reader.ReadInt(); - - m_Components = new List(count); - - for (int i = 0; i < count; ++i) { - Item item = reader.ReadItem(); + Placer = reader.ReadMobile(); - if (item != null) - m_Components.Add(item); + goto case 0; } + case 0: + { + int count = reader.ReadInt(); - break; - } + m_Components = new List(count); + + for (int i = 0; i < count; ++i) + { + Item item = reader.ReadItem(); + + if (item != null) + m_Components.Add(item); + } + + break; + } } Timer.DelayCall(TimeSpan.Zero, ValidatePlacement); @@ -183,7 +183,6 @@ namespace Server.Items } } - public override void OnDoubleClick(Mobile from) { if (from.InRange(GetWorldLocation(), 1)) @@ -279,14 +278,14 @@ namespace Server.Items switch (version) { case 0: - { - m_Tree = reader.ReadItem() as HolidayTree; + { + m_Tree = reader.ReadItem() as HolidayTree; - if (m_Tree == null) - Delete(); + if (m_Tree == null) + Delete(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Special/Holiday/GingerBreadHouseDeed.cs b/Projects/Scripts/Items/Special/Holiday/GingerBreadHouseDeed.cs index a427a4e9f..e168434b8 100644 --- a/Projects/Scripts/Items/Special/Holiday/GingerBreadHouseDeed.cs +++ b/Projects/Scripts/Items/Special/Holiday/GingerBreadHouseDeed.cs @@ -44,7 +44,7 @@ namespace Server.Items { } - public override int LabelNumber => 1077394; //a Gingerbread House Deed + public override int LabelNumber => 1077394; // a Gingerbread House Deed public override BaseAddon Addon => new GingerBreadHouseAddon(); public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Items/Special/Holiday/HolidayBell.cs b/Projects/Scripts/Items/Special/Holiday/HolidayBell.cs index bc75ece41..b09361d8e 100644 --- a/Projects/Scripts/Items/Special/Holiday/HolidayBell.cs +++ b/Projects/Scripts/Items/Special/Holiday/HolidayBell.cs @@ -2,7 +2,7 @@ { public class HolidayBell : Item { - private static string[] m_StaffNames = + private static readonly string[] m_StaffNames = { "Adrick", "Alai", @@ -28,7 +28,7 @@ "Vex" }; - private static int[] m_Hues = + private static readonly int[] m_Hues = { 0xA, 0x24, 0x42, 0x56, 0x1A, 0x4C, 0x3C, 0x60, 0x2E, 0x55, 0x23, 0x38, 0x482, 0x6, 0x10 }; diff --git a/Projects/Scripts/Items/Special/Holiday/HolidayFoods.cs b/Projects/Scripts/Items/Special/Holiday/HolidayFoods.cs index 6ecdb347f..9bfd78f15 100644 --- a/Projects/Scripts/Items/Special/Holiday/HolidayFoods.cs +++ b/Projects/Scripts/Items/Special/Holiday/HolidayFoods.cs @@ -22,7 +22,7 @@ namespace Server.Items { } - private static Dictionary m_ToothAches = new Dictionary(); + private static readonly Dictionary m_ToothAches = new Dictionary(); private static CandyCaneTimer EnsureTimer(Mobile from) { @@ -69,9 +69,9 @@ namespace Server.Items Start(); } - public Mobile Eater{ get; } + public Mobile Eater { get; } - public int Eaten{ get; set; } + public int Eaten { get; set; } protected override void OnTick() { diff --git a/Projects/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs b/Projects/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs index 68c74d463..8018df4b1 100644 --- a/Projects/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs +++ b/Projects/Scripts/Items/Special/Holiday/HolidayPottedPlant.cs @@ -83,7 +83,7 @@ namespace Server.Items private class InternalGump : Gump { - private PottedPlantDeed m_Deed; + private readonly PottedPlantDeed m_Deed; public InternalGump(PottedPlantDeed deed) : base(100, 200) { diff --git a/Projects/Scripts/Items/Special/Holiday/IcyPatch.cs b/Projects/Scripts/Items/Special/Holiday/IcyPatch.cs index 6556addfb..f8a0800d5 100644 --- a/Projects/Scripts/Items/Special/Holiday/IcyPatch.cs +++ b/Projects/Scripts/Items/Special/Holiday/IcyPatch.cs @@ -23,7 +23,7 @@ namespace Server.Items { } - public override int LabelNumber => 1095159; //An Icy Patch + public override int LabelNumber => 1095159; // An Icy Patch public override double DefaultWeight => 5.0; public override bool OnMoveOver(Mobile m) @@ -33,13 +33,13 @@ namespace Server.Items { case 0: RunSequence(m, 1095160, false); - break; //You steadily walk over the slippery surface. + break; // You steadily walk over the slippery surface. case 1: RunSequence(m, 1095161, true); - break; //You skillfully manage to maintain your balance. + break; // You skillfully manage to maintain your balance. default: RunSequence(m, 1095162, true); - break; //You lose your footing and ungracefully splatter on the ground. + break; // You lose your footing and ungracefully splatter on the ground. } return base.OnMoveOver(m); } @@ -53,7 +53,7 @@ namespace Server.Items } m.SendLocalizedMessage(message); - + int action = 0; int sound = 0; @@ -84,7 +84,7 @@ namespace Server.Items { if (!m.Mounted) m.Animate(action, 1, 1, false, true, 0); - + m.PlaySound(sound); } diff --git a/Projects/Scripts/Items/Special/Holiday/SnowGlobes.cs b/Projects/Scripts/Items/Special/Holiday/SnowGlobes.cs index 79a8b6a1e..7ad3598a3 100644 --- a/Projects/Scripts/Items/Special/Holiday/SnowGlobes.cs +++ b/Projects/Scripts/Items/Special/Holiday/SnowGlobes.cs @@ -102,10 +102,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Type = (SnowGlobeTypeOne)reader.ReadEncodedInt(); - break; - } + { + m_Type = (SnowGlobeTypeOne)reader.ReadEncodedInt(); + break; + } } } } @@ -216,10 +216,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Type = (SnowGlobeTypeTwo)reader.ReadEncodedInt(); - break; - } + { + m_Type = (SnowGlobeTypeTwo)reader.ReadEncodedInt(); + break; + } } } } @@ -301,10 +301,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Type = (SnowGlobeTypeThree)reader.ReadEncodedInt(); - break; - } + { + m_Type = (SnowGlobeTypeThree)reader.ReadEncodedInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Special/Holiday/SnowStatue.cs b/Projects/Scripts/Items/Special/Holiday/SnowStatue.cs index 1089fe837..c02856648 100644 --- a/Projects/Scripts/Items/Special/Holiday/SnowStatue.cs +++ b/Projects/Scripts/Items/Special/Holiday/SnowStatue.cs @@ -171,7 +171,7 @@ namespace Server.Items private class InternalGump : Gump { - private SnowStatueDeed m_Deed; + private readonly SnowStatueDeed m_Deed; public InternalGump(SnowStatueDeed deed) : base(100, 200) { diff --git a/Projects/Scripts/Items/Special/Holiday/Snowman.cs b/Projects/Scripts/Items/Special/Holiday/Snowman.cs index 753eccdea..7afb42130 100644 --- a/Projects/Scripts/Items/Special/Holiday/Snowman.cs +++ b/Projects/Scripts/Items/Special/Holiday/Snowman.cs @@ -147,10 +147,10 @@ namespace Server.Items switch (version) { case 1: - { - m_Title = reader.ReadString(); - break; - } + { + m_Title = reader.ReadString(); + break; + } } Utility.Intern(ref m_Title); diff --git a/Projects/Scripts/Items/Special/Holiday/Wreath.cs b/Projects/Scripts/Items/Special/Holiday/Wreath.cs index 20163d07e..b4171d6ab 100644 --- a/Projects/Scripts/Items/Special/Holiday/Wreath.cs +++ b/Projects/Scripts/Items/Special/Holiday/Wreath.cs @@ -117,8 +117,8 @@ namespace Server.Items private class WreathAddonGump : Gump { - private WreathAddon m_Addon; - private Mobile m_From; + private readonly WreathAddon m_Addon; + private readonly Mobile m_From; public WreathAddonGump(Mobile from, WreathAddon addon) : base(150, 50) { @@ -276,9 +276,9 @@ namespace Server.Items private class WreathDeedGump : Gump { - private WreathDeed m_Deed; - private Mobile m_From; - private Point3D m_Loc; + private readonly WreathDeed m_Deed; + private readonly Mobile m_From; + private readonly Point3D m_Loc; public WreathDeedGump(Mobile from, Point3D loc, WreathDeed deed) : base(150, 50) { diff --git a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs index c0d44dff5..fd90572ea 100644 --- a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs +++ b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleDeed.cs @@ -100,7 +100,7 @@ namespace Server.Items if (IsExpired) list.Add(1150487); // [Expired] - //list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~ + // list.Add( 1060660, "shard\t{0}", ServerList.ServerName ); // ~1_val~: ~2_val~ } public override void OnDoubleClick(Mobile from) @@ -140,19 +140,19 @@ namespace Server.Items switch (version) { case 1: - { - m_Stone = reader.ReadItem(); + { + m_Stone = reader.ReadItem(); - goto case 0; - } + goto case 0; + } case 0: - { - m_PlotLocation = reader.ReadPoint3D(); - m_Facet = reader.ReadMap(); - m_AwardedTo = reader.ReadMobile(); + { + m_PlotLocation = reader.ReadPoint3D(); + m_Facet = reader.ReadMap(); + m_AwardedTo = reader.ReadMobile(); - break; - } + break; + } } } diff --git a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs index 3334198af..81aebdaef 100644 --- a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs +++ b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleManagementGump.cs @@ -17,11 +17,11 @@ namespace Server.Gumps public const int LabelColor = 0xFFFFFF; public const int HighlightColor = 0x11EE11; - private List m_List; + private readonly List m_List; private int m_Page; - private SortMethod m_Sort; + private readonly SortMethod m_Sort; - private HouseRaffleStone m_Stone; + private readonly HouseRaffleStone m_Stone; public HouseRaffleManagementGump(HouseRaffleStone stone, SortMethod sort = SortMethod.Default, int page = 0) : base(40, 40) @@ -35,23 +35,23 @@ namespace Server.Gumps switch (m_Sort) { case SortMethod.Name: - { - m_List.Sort(NameComparer.Instance); + { + m_List.Sort(NameComparer.Instance); - break; - } + break; + } case SortMethod.Account: - { - m_List.Sort(AccountComparer.Instance); + { + m_List.Sort(AccountComparer.Instance); - break; - } + break; + } case SortMethod.Address: - { - m_List.Sort(AddressComparer.Instance); + { + m_List.Sort(AddressComparer.Instance); - break; - } + break; + } } AddPage(0); @@ -158,57 +158,57 @@ namespace Server.Gumps switch (buttonId) { case 1: // Previous - { - if (m_Page > 0) - m_Page--; - - from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); - - break; - } - case 2: // Next - { - if ((m_Page + 1) * 10 < m_Stone.Entries.Count) - m_Page++; - - from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); - - break; - } - case 3: // Sort by name - { - from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Name)); - - break; - } - case 4: // Sort by account - { - from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Account)); - - break; - } - case 5: // Sort by address - { - from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Address)); - - break; - } - default: // Delete - { - buttonId -= 6; - - if (buttonId >= 0 && buttonId < m_List.Count) { - m_Stone.Entries.Remove(m_List[buttonId]); - - if (m_Page > 0 && m_Page * 10 >= m_List.Count - 1) + if (m_Page > 0) m_Page--; from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); - } - break; - } + break; + } + case 2: // Next + { + if ((m_Page + 1) * 10 < m_Stone.Entries.Count) + m_Page++; + + from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); + + break; + } + case 3: // Sort by name + { + from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Name)); + + break; + } + case 4: // Sort by account + { + from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Account)); + + break; + } + case 5: // Sort by address + { + from.SendGump(new HouseRaffleManagementGump(m_Stone, SortMethod.Address)); + + break; + } + default: // Delete + { + buttonId -= 6; + + if (buttonId >= 0 && buttonId < m_List.Count) + { + m_Stone.Entries.Remove(m_List[buttonId]); + + if (m_Page > 0 && m_Page * 10 >= m_List.Count - 1) + m_Page--; + + from.SendGump(new HouseRaffleManagementGump(m_Stone, m_Sort, m_Page)); + } + + break; + } } } diff --git a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs index 35fa20d43..90705f151 100644 --- a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs +++ b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleRegion.cs @@ -7,7 +7,7 @@ namespace Server.Regions { public class HouseRaffleRegion : BaseRegion { - private HouseRaffleStone m_Stone; + private readonly HouseRaffleStone m_Stone; public HouseRaffleRegion(HouseRaffleStone stone) : base(null, stone.PlotFacet, DefaultPriority, stone.PlotBounds) => diff --git a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs index 7be6fb65f..9e2304d29 100644 --- a/Projects/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs +++ b/Projects/Scripts/Items/Special/House Raffle/HouseRaffleStone.cs @@ -29,21 +29,21 @@ namespace Server.Items case 2: case 1: case 0: - { - From = reader.ReadMobile(); - Address = Utility.Intern(reader.ReadIPAddress()); - Date = reader.ReadDateTime(); + { + From = reader.ReadMobile(); + Address = Utility.Intern(reader.ReadIPAddress()); + Date = reader.ReadDateTime(); - break; - } + break; + } } } - public Mobile From{ get; } + public Mobile From { get; } - public IPAddress Address{ get; } + public IPAddress Address { get; } - public DateTime Date{ get; } + public DateTime Date { get; } public void Serialize(IGenericWriter writer) { @@ -77,7 +77,7 @@ namespace Server.Items public static readonly TimeSpan DefaultDuration = TimeSpan.FromDays(7.0); public static readonly TimeSpan ExpirationTime = TimeSpan.FromDays(30.0); - private static List m_AllStones = new List(); + private static readonly List m_AllStones = new List(); private Rectangle2D m_Bounds; private TimeSpan m_Duration; private Map m_Facet; @@ -179,7 +179,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)] - public HouseRaffleDeed Deed{ get; set; } + public HouseRaffleDeed Deed { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)] public DateTime Started @@ -216,7 +216,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)] - public HouseRaffleExpireAction ExpireAction{ get; set; } + public HouseRaffleExpireAction ExpireAction { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Seer)] public int TicketPrice @@ -229,7 +229,7 @@ namespace Server.Items } } - public List Entries{ get; private set; } + public List Entries { get; private set; } public override string DefaultName => "a house raffle stone"; @@ -251,20 +251,20 @@ namespace Server.Items switch (stone.ExpireAction) { case HouseRaffleExpireAction.HideStone: - { - if (stone.Visible) { - stone.Visible = false; - stone.ItemID = 0x1B7B; // Non-blocking ItemID - } + if (stone.Visible) + { + stone.Visible = false; + stone.ItemID = 0x1B7B; // Non-blocking ItemID + } - break; - } + break; + } case HouseRaffleExpireAction.DeleteStone: - { - stone.Delete(); - break; - } + { + stone.Delete(); + break; + } } } @@ -372,16 +372,16 @@ namespace Server.Items switch (m_State) { case HouseRaffleState.Active: - { - list.Add(1060658, "ticket price\t{0}", FormatPrice()); // ~1_val~: ~2_val~ - list.Add(1060659, "ends\t{0}", m_Started + m_Duration); // ~1_val~: ~2_val~ - break; - } + { + list.Add(1060658, "ticket price\t{0}", FormatPrice()); // ~1_val~: ~2_val~ + list.Add(1060659, "ends\t{0}", m_Started + m_Duration); // ~1_val~: ~2_val~ + break; + } case HouseRaffleState.Completed: - { - list.Add(1060658, "winner\t{0}", m_Winner == null ? "unknown" : m_Winner.Name); // ~1_val~: ~2_val~ - break; - } + { + list.Add(1060658, "winner\t{0}", m_Winner == null ? "unknown" : m_Winner.Name); // ~1_val~: ~2_val~ + break; + } } } @@ -392,15 +392,15 @@ namespace Server.Items switch (m_State) { case HouseRaffleState.Active: - { - LabelTo(from, 1060658, $"Ends\t{m_Started + m_Duration}"); // ~1_val~: ~2_val~ - break; - } + { + LabelTo(from, 1060658, $"Ends\t{m_Started + m_Duration}"); // ~1_val~: ~2_val~ + break; + } case HouseRaffleState.Completed: - { - LabelTo(from, 1060658, $"Winner\t{(m_Winner == null ? "Unknown" : m_Winner.Name)}"); // ~1_val~: ~2_val~ - break; - } + { + LabelTo(from, 1060658, $"Winner\t{(m_Winner == null ? "Unknown" : m_Winner.Name)}"); // ~1_val~: ~2_val~ + break; + } } } @@ -555,72 +555,72 @@ namespace Server.Items switch (version) { case 3: - { - m_State = (HouseRaffleState)reader.ReadEncodedInt(); + { + m_State = (HouseRaffleState)reader.ReadEncodedInt(); - goto case 2; - } + goto case 2; + } case 2: - { - ExpireAction = (HouseRaffleExpireAction)reader.ReadEncodedInt(); + { + ExpireAction = (HouseRaffleExpireAction)reader.ReadEncodedInt(); - goto case 1; - } + goto case 1; + } case 1: - { - Deed = reader.ReadItem(); + { + Deed = reader.ReadItem(); - goto case 0; - } + goto case 0; + } case 0: - { - bool oldActive = version < 3 && reader.ReadBool(); - - m_Bounds = reader.ReadRect2D(); - m_Facet = reader.ReadMap(); - - m_Winner = reader.ReadMobile(); - - m_TicketPrice = reader.ReadInt(); - m_Started = reader.ReadDateTime(); - m_Duration = reader.ReadTimeSpan(); - - int entryCount = reader.ReadInt(); - Entries = new List(entryCount); - - for (int i = 0; i < entryCount; i++) { - RaffleEntry entry = new RaffleEntry(reader, version); + bool oldActive = version < 3 && reader.ReadBool(); - if (entry.From == null) - continue; // Character was deleted + m_Bounds = reader.ReadRect2D(); + m_Facet = reader.ReadMap(); - Entries.Add(entry); + m_Winner = reader.ReadMobile(); + + m_TicketPrice = reader.ReadInt(); + m_Started = reader.ReadDateTime(); + m_Duration = reader.ReadTimeSpan(); + + int entryCount = reader.ReadInt(); + Entries = new List(entryCount); + + for (int i = 0; i < entryCount; i++) + { + RaffleEntry entry = new RaffleEntry(reader, version); + + if (entry.From == null) + continue; // Character was deleted + + Entries.Add(entry); + } + + InvalidateRegion(); + + m_AllStones.Add(this); + + if (version < 3) + { + if (oldActive) + m_State = HouseRaffleState.Active; + else if (m_Winner != null) + m_State = HouseRaffleState.Completed; + else + m_State = HouseRaffleState.Inactive; + } + + break; } - - InvalidateRegion(); - - m_AllStones.Add(this); - - if (version < 3) - { - if (oldActive) - m_State = HouseRaffleState.Active; - else if (m_Winner != null) - m_State = HouseRaffleState.Completed; - else - m_State = HouseRaffleState.Inactive; - } - - break; - } } } private class RaffleContextMenuEntry : ContextMenuEntry { - protected Mobile m_From; - protected HouseRaffleStone m_Stone; + protected readonly Mobile m_From; + protected readonly HouseRaffleStone m_Stone; public RaffleContextMenuEntry(Mobile from, HouseRaffleStone stone, int label) : base(label) diff --git a/Projects/Scripts/Items/Special/ML/BaseImprisonedMobile.cs b/Projects/Scripts/Items/Special/ML/BaseImprisonedMobile.cs index 5a124d773..304ac8689 100644 --- a/Projects/Scripts/Items/Special/ML/BaseImprisonedMobile.cs +++ b/Projects/Scripts/Items/Special/ML/BaseImprisonedMobile.cs @@ -14,7 +14,7 @@ namespace Server.Items { } - public abstract BaseCreature Summon{ get; } + public abstract BaseCreature Summon { get; } public override void OnDoubleClick(Mobile from) { diff --git a/Projects/Scripts/Items/Special/MiniHouses.cs b/Projects/Scripts/Items/Special/MiniHouses.cs index a8ed1e6cb..39c363b4f 100644 --- a/Projects/Scripts/Items/Special/MiniHouses.cs +++ b/Projects/Scripts/Items/Special/MiniHouses.cs @@ -47,9 +47,9 @@ namespace Server.Items int num = 0; for (int y = 0; y < size; ++y) - for (int x = 0; x < size; ++x) - if (info.Graphics[num] != 0x1) // Veteran Rewards Mod - AddComponent(new AddonComponent(info.Graphics[num++]), size - x - 1, size - y - 1, 0); + for (int x = 0; x < size; ++x) + if (info.Graphics[num] != 0x1) // Veteran Rewards Mod + AddComponent(new AddonComponent(info.Graphics[num++]), size - x - 1, size - y - 1, 0); } public override void Serialize(IGenericWriter writer) @@ -70,10 +70,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Type = (MiniHouseType)reader.ReadInt(); - break; - } + { + m_Type = (MiniHouseType)reader.ReadInt(); + break; + } } } } @@ -134,10 +134,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Type = (MiniHouseType)reader.ReadInt(); - break; - } + { + m_Type = (MiniHouseType)reader.ReadInt(); + break; + } } if (Weight == 0.0) @@ -167,13 +167,13 @@ namespace Server.Items SandstoneHouseWithPatio, SmallStoneWorkshop, SmallMarbleWorkshop, - MalasMountainPass, //Veteran reward house - ChurchAtNight //Veteran reward house + MalasMountainPass, // Veteran reward house + ChurchAtNight // Veteran reward house } public class MiniHouseInfo { - private static MiniHouseInfo[] m_Info = + private static readonly MiniHouseInfo[] m_Info = { /* Stone and plaster house */ new MiniHouseInfo(0x22C4, 1, 1011303), /* Field stone house */ new MiniHouseInfo(0x22DE, 1, 1011304), @@ -217,9 +217,9 @@ namespace Server.Items Graphics = graphics; } - public int[] Graphics{ get; } + public int[] Graphics { get; } - public int LabelNumber{ get; } + public int LabelNumber { get; } public static MiniHouseInfo GetInfo(MiniHouseType type) { diff --git a/Projects/Scripts/Items/Special/MonsterStatuette.cs b/Projects/Scripts/Items/Special/MonsterStatuette.cs index c1eb5168c..3d8226e13 100644 --- a/Projects/Scripts/Items/Special/MonsterStatuette.cs +++ b/Projects/Scripts/Items/Special/MonsterStatuette.cs @@ -51,7 +51,7 @@ namespace Server.Items public class MonsterStatuetteInfo { - private static MonsterStatuetteInfo[] m_Table = + private static readonly MonsterStatuetteInfo[] m_Table = { /* Crocodile */ new MonsterStatuetteInfo(1041249, 0x20DA, 660), /* Daemon */ new MonsterStatuetteInfo(1041250, 0x20D3, 357), @@ -109,11 +109,11 @@ namespace Server.Items Sounds = sounds; } - public int LabelNumber{ get; } + public int LabelNumber { get; } - public int ItemID{ get; } + public int ItemID { get; } - public int[] Sounds{ get; } + public int[] Sounds { get; } public static MonsterStatuetteInfo GetInfo(MonsterStatuetteType type) { @@ -132,8 +132,7 @@ namespace Server.Items private MonsterStatuetteType m_Type; [Constructible] - public MonsterStatuette(MonsterStatuetteType type = MonsterStatuetteType.Crocodile) : - base(MonsterStatuetteInfo.GetInfo(type).ItemID) + public MonsterStatuette(MonsterStatuetteType type = MonsterStatuetteType.Crocodile) : base(MonsterStatuetteInfo.GetInfo(type).ItemID) { LootType = LootType.Blessed; @@ -191,7 +190,7 @@ namespace Server.Items public override bool HandlesOnMovement => m_TurnedOn && IsLockedDown; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void OnMovement(Mobile m, Point3D oldLocation) { @@ -255,18 +254,18 @@ namespace Server.Items switch (version) { case 0: - { - m_Type = (MonsterStatuetteType)reader.ReadEncodedInt(); - m_TurnedOn = reader.ReadBool(); - IsRewardItem = reader.ReadBool(); - break; - } + { + m_Type = (MonsterStatuetteType)reader.ReadEncodedInt(); + m_TurnedOn = reader.ReadBool(); + IsRewardItem = reader.ReadBool(); + break; + } } } private class OnOffGump : Gump { - private MonsterStatuette m_Statuette; + private readonly MonsterStatuette m_Statuette; public OnOffGump(MonsterStatuette statuette) : base(150, 200) { diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs index 16342bc19..769f23f18 100644 --- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs +++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBackpack.cs @@ -4,14 +4,14 @@ namespace Server.Items { public class PlagueBeastBackpack : BaseContainer { - private static int[,,] m_Positions = + private static readonly int[,,] m_Positions = { { { 275, 85 }, { 360, 111 }, { 375, 184 }, { 332, 228 }, { 141, 105 }, { 189, 75 } }, { { 274, 34 }, { 327, 89 }, { 354, 168 }, { 304, 225 }, { 113, 86 }, { 189, 75 } }, { { 276, 79 }, { 369, 117 }, { 372, 192 }, { 336, 230 }, { 141, 116 }, { 189, 75 } } }; - private static int[] m_BrainHues = + private static readonly int[] m_BrainHues = { 0x2B, 0x42, 0x54, 0x60 }; diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs index 30dc5131b..fc24d46bc 100644 --- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs +++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastBlood.cs @@ -5,7 +5,7 @@ namespace Server.Items { public class PlagueBeastBlood : PlagueBeastComponent { - private Timer m_Timer; + private readonly Timer m_Timer; public PlagueBeastBlood() : base(0x122C, 0) => m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(1.5), TimeSpan.FromSeconds(1.5), 3, Hemorrhage); diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs index cbb520f27..4995c4613 100644 --- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs +++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastHeart.cs @@ -42,7 +42,7 @@ namespace Server.Items private class InternalTimer : Timer { private bool m_Delay; - private PlagueBeastHeart m_Heart; + private readonly PlagueBeastHeart m_Heart; public InternalTimer(PlagueBeastHeart heart) : base(TimeSpan.FromSeconds(0.5), TimeSpan.FromSeconds(0.5)) => m_Heart = heart; diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs index 6d732c2fd..836cd73e7 100644 --- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs +++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastInnard.cs @@ -76,7 +76,7 @@ namespace Server.Items { } - public PlagueBeastOrgan Organ{ get; set; } + public PlagueBeastOrgan Organ { get; set; } public bool IsBrain => ItemID == 0x1CF0; @@ -95,7 +95,7 @@ namespace Server.Items public override bool OnDragDrop(Mobile from, Item dropped) { if (Organ?.OnDropped(from, dropped, this) == true && dropped is PlagueBeastComponent component) - Organ.Components.Add(component); + Organ.Components.Add(component); return true; } diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastMutationCore.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastMutationCore.cs index 78456208d..7bbedc4d0 100644 --- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastMutationCore.cs +++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastMutationCore.cs @@ -19,7 +19,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool Cut{ get; set; } + public bool Cut { get; set; } public override string DefaultName => "a plague beast mutation core"; diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs index e22ccdf97..bfe5cd859 100644 --- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs +++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastOrgans.cs @@ -24,11 +24,11 @@ namespace Server.Items public virtual bool IsCuttable => false; - public List Components{ get; private set; } + public List Components { get; private set; } - public int BrainHue{ get; set; } + public int BrainHue { get; set; } - public bool Opened{ get; set; } + public bool Opened { get; set; } public virtual void Initialize() { @@ -212,7 +212,7 @@ namespace Server.Items public class PlagueBeastRubbleOrgan : PlagueBeastOrgan { - private static int[] m_Hues = + private static readonly int[] m_Hues = { 0xD, 0x17, 0x2B, 0x42, 0x54, 0x5D }; diff --git a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs index 8d5e8055c..1ba8c256c 100644 --- a/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs +++ b/Projects/Scripts/Items/Special/Mutation Core/PlagueBeastVein.cs @@ -13,7 +13,7 @@ namespace Server.Items { } - public bool Cut{ get; private set; } + public bool Cut { get; private set; } public override bool Scissor(Mobile from, Scissors scissors) { diff --git a/Projects/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs b/Projects/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs index 389a81ab5..8b38f4509 100644 --- a/Projects/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs +++ b/Projects/Scripts/Items/Special/Rares/Containers/BaseWaterContainer.cs @@ -4,8 +4,8 @@ { private int m_Quantity; - public BaseWaterContainer(int Item_Id, bool filled) - : base(Item_Id) => + public BaseWaterContainer(int item_Id, bool filled) + : base(item_Id) => m_Quantity = filled ? MaxQuantity : 0; public BaseWaterContainer(Serial serial) @@ -13,9 +13,9 @@ { } - public abstract int voidItem_ID{ get; } - public abstract int fullItem_ID{ get; } - public abstract int MaxQuantity{ get; } + public abstract int voidItem_ID { get; } + public abstract int fullItem_ID { get; } + public abstract int MaxQuantity { get; } public override int DefaultGumpID => 0x3e; diff --git a/Projects/Scripts/Items/Special/Rares/Containers/Bucket.cs b/Projects/Scripts/Items/Special/Rares/Containers/Bucket.cs index 3aaf92c5f..2daa14a86 100644 --- a/Projects/Scripts/Items/Special/Rares/Containers/Bucket.cs +++ b/Projects/Scripts/Items/Special/Rares/Containers/Bucket.cs @@ -2,8 +2,8 @@ { internal class Bucket : BaseWaterContainer { - private static int vItemID = 0x14e0; - private static int fItemID = 0x2004; + private static readonly int vItemID = 0x14e0; + private static readonly int fItemID = 0x2004; [Constructible] public Bucket(bool filled = false) diff --git a/Projects/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs b/Projects/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs index d511c21ae..c37f4acfb 100644 --- a/Projects/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs +++ b/Projects/Scripts/Items/Special/Rares/Containers/WaterBarrel.cs @@ -2,8 +2,8 @@ { internal class WaterBarrel : BaseWaterContainer { - private static int vItemID = 0xe77; - private static int fItemID = 0x154d; + private static readonly int vItemID = 0xe77; + private static readonly int fItemID = 0x154d; [Constructible] public WaterBarrel(bool filled = false) diff --git a/Projects/Scripts/Items/Special/Rares/Containers/WaterTub.cs b/Projects/Scripts/Items/Special/Rares/Containers/WaterTub.cs index 78e31aced..8d9f43cba 100644 --- a/Projects/Scripts/Items/Special/Rares/Containers/WaterTub.cs +++ b/Projects/Scripts/Items/Special/Rares/Containers/WaterTub.cs @@ -2,8 +2,8 @@ { internal class Tub : BaseWaterContainer { - private static int vItemID = 0xe83; - private static int fItemID = 0xe7b; + private static readonly int vItemID = 0xe83; + private static readonly int fItemID = 0xe7b; [Constructible] public Tub(bool filled = false) diff --git a/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs b/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs index b1e38c985..b73ac8947 100644 --- a/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs +++ b/Projects/Scripts/Items/Special/Solen Items/BagOfSending.cs @@ -170,22 +170,22 @@ namespace Server.Items switch (version) { case 1: - { - m_Recharges = reader.ReadEncodedInt(); - goto case 0; - } + { + m_Recharges = reader.ReadEncodedInt(); + goto case 0; + } case 0: - { - m_Charges = Math.Min(reader.ReadEncodedInt(), MaxCharges); - m_BagOfSendingHue = (BagOfSendingHue)reader.ReadEncodedInt(); - break; - } + { + m_Charges = Math.Min(reader.ReadEncodedInt(), MaxCharges); + m_BagOfSendingHue = (BagOfSendingHue)reader.ReadEncodedInt(); + break; + } } } private class UseBagEntry : ContextMenuEntry { - private BagOfSending m_Bag; + private readonly BagOfSending m_Bag; public UseBagEntry(BagOfSending bag, bool enabled) : base(6189) { @@ -209,7 +209,7 @@ namespace Server.Items private class SendTarget : Target { - private BagOfSending m_Bag; + private readonly BagOfSending m_Bag; public SendTarget(BagOfSending bag) : base(-1, false, TargetFlags.None) => m_Bag = bag; @@ -265,7 +265,7 @@ namespace Server.Items } else if (Core.ML && reqCharges > m_Bag.Charges) { - from.SendLocalizedMessage(1079932); //You don't have enough charges to send that much weight + from.SendLocalizedMessage(1079932); // You don't have enough charges to send that much weight } else { diff --git a/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs b/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs index 4fb9761a1..5dd245275 100644 --- a/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs +++ b/Projects/Scripts/Items/Special/Solen Items/BallOfSummoning.cs @@ -53,7 +53,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string PetName{ get; private set; } + public string PetName { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public int Charges @@ -134,8 +134,7 @@ namespace Server.Items public override void OnDoubleClick(Mobile from) { - if (RootParent != from - ) // TODO: Previous implementation allowed use on ground, without house protection checks. What is the correct behavior? + if (RootParent != from) // TODO: Previous implementation allowed use on ground, without house protection checks. What is the correct behavior? { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1042001); // That must be in your pack for you to use it. @@ -221,7 +220,6 @@ namespace Server.Items } } - public void SummonPet(Mobile from) { BaseCreature pet = Pet; @@ -300,17 +298,17 @@ namespace Server.Items switch (version) { case 1: - { - m_Recharges = reader.ReadEncodedInt(); - goto case 0; - } + { + m_Recharges = reader.ReadEncodedInt(); + goto case 0; + } case 0: - { - m_Charges = Math.Min(reader.ReadEncodedInt(), MaxCharges); - Pet = (BaseCreature)reader.ReadMobile(); - PetName = reader.ReadString(); - break; - } + { + m_Charges = Math.Min(reader.ReadEncodedInt(), MaxCharges); + Pet = (BaseCreature)reader.ReadMobile(); + PetName = reader.ReadString(); + break; + } } } @@ -318,7 +316,7 @@ namespace Server.Items private class BallEntry : ContextMenuEntry { - private BallCallback m_Callback; + private readonly BallCallback m_Callback; public BallEntry(BallCallback callback, int number) : base(number, 2) => m_Callback = callback; @@ -333,7 +331,7 @@ namespace Server.Items private class PetLinkTarget : Target { - private BallOfSummoning m_Ball; + private readonly BallOfSummoning m_Ball; public PetLinkTarget(BallOfSummoning ball) : base(-1, false, TargetFlags.None) => m_Ball = ball; @@ -382,10 +380,10 @@ namespace Server.Items private class PetSummoningSpell : Spell { - private static SpellInfo m_Info = new SpellInfo("Ball Of Summoning", "", 230); + private static readonly SpellInfo m_Info = new SpellInfo("Ball Of Summoning", "", 230); - private BallOfSummoning m_Ball; - private Mobile m_Caster; + private readonly BallOfSummoning m_Ball; + private readonly Mobile m_Caster; private bool m_Stop; diff --git a/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs b/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs index f688ed823..7bc4a4623 100644 --- a/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs +++ b/Projects/Scripts/Items/Special/Solen Items/BraceletOfBinding.cs @@ -327,17 +327,17 @@ namespace Server.Items switch (version) { case 1: - { - m_Recharges = reader.ReadEncodedInt(); - goto case 0; - } + { + m_Recharges = reader.ReadEncodedInt(); + goto case 0; + } case 0: - { - m_Charges = Math.Min(reader.ReadEncodedInt(), MaxCharges); - m_Inscription = reader.ReadString(); - Bound = (BraceletOfBinding)reader.ReadItem(); - break; - } + { + m_Charges = Math.Min(reader.ReadEncodedInt(), MaxCharges); + m_Inscription = reader.ReadString(); + Bound = (BraceletOfBinding)reader.ReadItem(); + break; + } } } @@ -345,7 +345,7 @@ namespace Server.Items private class BraceletEntry : ContextMenuEntry { - private BraceletCallback m_Callback; + private readonly BraceletCallback m_Callback; public BraceletEntry(BraceletCallback callback, int number, bool enabled) : base(number) { @@ -366,8 +366,8 @@ namespace Server.Items private class TransportTimer : Timer { - private BraceletOfBinding m_Bracelet; - private Mobile m_From; + private readonly BraceletOfBinding m_Bracelet; + private readonly Mobile m_From; public TransportTimer(BraceletOfBinding bracelet, Mobile from) : base(TimeSpan.FromSeconds(2.0)) { @@ -397,7 +397,7 @@ namespace Server.Items private class BindTarget : Target { - private BraceletOfBinding m_Bracelet; + private readonly BraceletOfBinding m_Bracelet; public BindTarget(BraceletOfBinding bracelet) : base(-1, false, TargetFlags.None) => m_Bracelet = bracelet; @@ -438,7 +438,7 @@ namespace Server.Items private class InscribePrompt : Prompt { - private BraceletOfBinding m_Bracelet; + private readonly BraceletOfBinding m_Bracelet; public InscribePrompt(BraceletOfBinding bracelet) => m_Bracelet = bracelet; diff --git a/Projects/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs b/Projects/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs index 96653afa7..45240e5f2 100644 --- a/Projects/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs +++ b/Projects/Scripts/Items/Special/Solen Items/PowderOfTranslocation.cs @@ -5,11 +5,11 @@ namespace Server.Items { public interface TranslocationItem { - int Charges{ get; set; } - int Recharges{ get; set; } - int MaxCharges{ get; } - int MaxRecharges{ get; } - string TranslocationItemName{ get; } + int Charges { get; set; } + int Recharges { get; set; } + int MaxCharges { get; } + int MaxRecharges { get; } + string TranslocationItemName { get; } } public class PowderOfTranslocation : Item @@ -50,7 +50,7 @@ namespace Server.Items private class InternalTarget : Target { - private PowderOfTranslocation m_Powder; + private readonly PowderOfTranslocation m_Powder; public InternalTarget(PowderOfTranslocation powder) : base(-1, false, TargetFlags.None) => m_Powder = powder; diff --git a/Projects/Scripts/Items/Special/SoulStone.cs b/Projects/Scripts/Items/Special/SoulStone.cs index 0abb3c193..4c8c55bfc 100644 --- a/Projects/Scripts/Items/Special/SoulStone.cs +++ b/Projects/Scripts/Items/Special/SoulStone.cs @@ -21,8 +21,7 @@ namespace Server.Items private double m_SkillValue; [Constructible] - public SoulStone(string account = null, int inactiveItemID = 0x2A93, int activeItemID = 0x2A94) : - base(inactiveItemID) + public SoulStone(string account = null, int inactiveItemID = 0x2A93, int activeItemID = 0x2A94) : base(inactiveItemID) { Light = LightType.Circle300; LootType = LootType.Blessed; @@ -66,7 +65,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string Account{ get; set; } + public string Account { get; set; } [CommandProperty(AccessLevel.GameMaster)] public string LastUserName @@ -111,7 +110,7 @@ namespace Server.Items public bool IsEmpty => m_SkillValue <= 0.0; [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public override void GetProperties(ObjectPropertyList list) { @@ -210,8 +209,6 @@ namespace Server.Items return false; } - #region Scroll of Alacrity - if (pm.AcceleratedStart > DateTime.UtcNow) { from.SendLocalizedMessage( @@ -219,8 +216,6 @@ namespace Server.Items return false; } - #endregion - return true; } @@ -247,17 +242,17 @@ namespace Server.Items writer.WriteEncodedInt(3); // version - //version 3 + // version 3 writer.Write(m_LastUserName); - //version 2 + // version 2 writer.Write((int)Level); writer.Write(m_ActiveItemID); writer.Write(m_InactiveItemID); writer.Write(Account); - writer.Write(m_NextUse); //TODO: delete it in a harmless way + writer.Write(m_NextUse); // TODO: delete it in a harmless way writer.WriteEncodedInt((int)m_Skill); writer.Write(m_SkillValue); @@ -272,31 +267,31 @@ namespace Server.Items switch (version) { case 3: - { - m_LastUserName = reader.ReadString(); - goto case 2; - } + { + m_LastUserName = reader.ReadString(); + goto case 2; + } case 2: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 1; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 1; + } case 1: - { - m_ActiveItemID = reader.ReadInt(); - m_InactiveItemID = reader.ReadInt(); + { + m_ActiveItemID = reader.ReadInt(); + m_InactiveItemID = reader.ReadInt(); - goto case 0; - } + goto case 0; + } case 0: - { - Account = reader.ReadString(); - m_NextUse = reader.ReadDateTime(); //TODO: delete it in a harmless way + { + Account = reader.ReadString(); + m_NextUse = reader.ReadDateTime(); // TODO: delete it in a harmless way - m_Skill = (SkillName)reader.ReadEncodedInt(); - m_SkillValue = reader.ReadDouble(); - break; - } + m_Skill = (SkillName)reader.ReadEncodedInt(); + m_SkillValue = reader.ReadDouble(); + break; + } } if (version == 0) @@ -308,7 +303,7 @@ namespace Server.Items private class SelectSkillGump : Gump { - private SoulStone m_Stone; + private readonly SoulStone m_Stone; public SelectSkillGump(SoulStone stone, Mobile from) : base(50, 50) { @@ -391,8 +386,8 @@ namespace Server.Items private class ConfirmSkillGump : Gump { - private Skill m_Skill; - private SoulStone m_Stone; + private readonly Skill m_Skill; + private readonly SoulStone m_Stone; public ConfirmSkillGump(SoulStone stone, Skill skill) : base(50, 50) { @@ -506,7 +501,7 @@ namespace Server.Items private class ConfirmTransferGump : Gump { - private SoulStone m_Stone; + private readonly SoulStone m_Stone; public ConfirmTransferGump(SoulStone stone, Mobile from) : base(50, 50) { @@ -655,8 +650,6 @@ namespace Server.Items return; } - #region Scroll of ALacrity - PlayerMobile pm = from as PlayerMobile; if (pm.AcceleratedStart > DateTime.UtcNow) { @@ -670,8 +663,6 @@ namespace Server.Items return; } - #endregion - if (requiredAmount > 0) for (int i = 0; i < from.Skills.Length; ++i) { @@ -715,7 +706,7 @@ namespace Server.Items private class ConfirmRemovalGump : Gump { - private SoulStone m_Stone; + private readonly SoulStone m_Stone; public ConfirmRemovalGump(SoulStone stone) : base(50, 50) { @@ -764,7 +755,7 @@ namespace Server.Items private class ErrorGump : Gump { - private SoulStone m_Stone; + private readonly SoulStone m_Stone; public ErrorGump(SoulStone stone, int title, int message) : base(50, 50) { @@ -817,8 +808,7 @@ namespace Server.Items } [Constructible] - public SoulstoneFragment(int usesRemaining = 5, string account = null) : - base(account, Utility.Random(0x2AA1, 9)) => + public SoulstoneFragment(int usesRemaining = 5, string account = null) : base(account, Utility.Random(0x2AA1, 9)) => m_UsesRemaining = usesRemaining; public SoulstoneFragment(Serial serial) : base(serial) @@ -838,7 +828,6 @@ namespace Server.Items } } - bool IUsesRemaining.ShowUsesRemaining { get => true; @@ -991,10 +980,10 @@ namespace Server.Items switch (version) { case 1: - { - m_IsRewardItem = reader.ReadBool(); - break; - } + { + m_IsRewardItem = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Items/Special/Special Scrolls/PowerScroll.cs b/Projects/Scripts/Items/Special/Special Scrolls/PowerScroll.cs index 694832ff7..fe0fc813b 100644 --- a/Projects/Scripts/Items/Special/Special Scrolls/PowerScroll.cs +++ b/Projects/Scripts/Items/Special/Special Scrolls/PowerScroll.cs @@ -4,7 +4,7 @@ namespace Server.Items { public class PowerScroll : SpecialScroll { - private static SkillName[] m_Skills = + private static readonly SkillName[] m_Skills = { SkillName.Blacksmith, SkillName.Tailoring, @@ -30,7 +30,7 @@ namespace Server.Items SkillName.Peacemaking }; - private static SkillName[] m_AOSSkills = + private static readonly SkillName[] m_AOSSkills = { SkillName.Chivalry, SkillName.Focus, @@ -40,13 +40,13 @@ namespace Server.Items SkillName.SpiritSpeak }; - private static SkillName[] m_SESkills = + private static readonly SkillName[] m_SESkills = { SkillName.Ninjitsu, SkillName.Bushido }; - private static SkillName[] m_MLSkills = + private static readonly SkillName[] m_MLSkills = { SkillName.Spellweaving }; @@ -65,7 +65,7 @@ namespace Server.Items }; */ - private static List _Skills = new List(); + private static readonly List _Skills = new List(); [Constructible] public PowerScroll(SkillName skill = SkillName.Alchemy, double value = 0.0) : base(skill, value) @@ -80,11 +80,13 @@ namespace Server.Items { } + /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics. + * When used, the effect is not immediately seen without a gain of points with that skill or statistics. + * You can view your maximum skill values in your skills window. + * You can view your maximum statistic value in your statistics window. + */ public override int Message => - 1049469; /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics. - * When used, the effect is not immediately seen without a gain of points with that skill or statistics. - * You can view your maximum skill values in your skills window. - * You can view your maximum statistic value in your statistics window. */ + 1049469; public override int Title { @@ -92,11 +94,13 @@ namespace Server.Items { double level = (Value - 105.0) / 5.0; + /* Wonderous Scroll (105 Skill): OR + * Exalted Scroll (110 Skill): OR + * Mythical Scroll (115 Skill): OR + * Legendary Scroll (120 Skill): + */ if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0) - return 1049635 + (int)level; /* Wonderous Scroll (105 Skill): OR - * Exalted Scroll (110 Skill): OR - * Mythical Scroll (115 Skill): OR - * Legendary Scroll (120 Skill): */ + return 1049635 + (int)level; return 0; } @@ -154,10 +158,12 @@ namespace Server.Items double level = (Value - 105.0) / 5.0; if (level >= 0.0 && level <= 3.0 && Value % 5.0 == 0.0) - list.Add(1049639 + (int)level, GetNameLocalized()); /* a wonderous scroll of ~1_type~ (105 Skill) OR - * an exalted scroll of ~1_type~ (110 Skill) OR - * a mythical scroll of ~1_type~ (115 Skill) OR - * a legendary scroll of ~1_type~ (120 Skill) */ + /* a wonderous scroll of ~1_type~ (105 Skill) OR + * an exalted scroll of ~1_type~ (110 Skill) OR + * a mythical scroll of ~1_type~ (115 Skill) OR + * a legendary scroll of ~1_type~ (120 Skill) + */ + list.Add(1049639 + (int)level, GetNameLocalized()); else list.Add("a power scroll of {0} ({1} Skill)", GetName(), Value); } diff --git a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs index cbdd0ac09..26d51c773 100644 --- a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs +++ b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofAlacrity.cs @@ -20,10 +20,12 @@ namespace Server.Items public override int LabelNumber => 1078604; // Scroll of Alacrity + /* Using a Scroll of Transcendence for a given skill will permanently increase your current + * level in that skill by the amount of points displayed on the scroll. + * As you may not gain skills beyond your maximum skill cap, any excess points will be lost. + */ public override int Message => - 1078602; /*Using a Scroll of Transcendence for a given skill will permanently increase your current - *level in that skill by the amount of points displayed on the scroll. - *As you may not gain skills beyond your maximum skill cap, any excess points will be lost.*/ + 1078602; public override string DefaultTitle => "Scroll of Alacrity:"; @@ -39,20 +41,17 @@ namespace Server.Items if (!(base.CanUse(from) && from is PlayerMobile pm)) return false; - #region Mondain's Legacy MLQuestContext context = MLQuestSystem.GetContext(pm); if (context != null) foreach (MLQuestInstance instance in context.QuestInstances) - foreach (BaseObjectiveInstance objective in instance.Objectives) - if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && - objectiveInstance.Handles(Skill)) - { - from.SendMessage("You are already under the effect of an enhanced skillgain quest."); - return false; - } - - #endregion + foreach (BaseObjectiveInstance objective in instance.Objectives) + if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && + objectiveInstance.Handles(Skill)) + { + from.SendMessage("You are already under the effect of an enhanced skillgain quest."); + return false; + } if (pm.AcceleratedStart > DateTime.UtcNow) { @@ -73,9 +72,10 @@ namespace Server.Items if (tskill >= tcap || from.Skills[Skill].Lock != SkillLock.Up) { - from.SendLocalizedMessage( - 1094935); /*You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu. - *If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.*/ + /* You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu. + * If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap. + */ + from.SendLocalizedMessage(1094935); return; } @@ -112,7 +112,7 @@ namespace Server.Items { base.Deserialize(reader); - int version = InheritsItem ? 0 : reader.ReadInt(); //Required for SpecialScroll insertion + int version = InheritsItem ? 0 : reader.ReadInt(); // Required for SpecialScroll insertion LootType = LootType.Cursed; Insured = false; diff --git a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs index 1c64608c1..c2873cb6b 100644 --- a/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs +++ b/Projects/Scripts/Items/Special/Special Scrolls/ScrollofTranscendence.cs @@ -20,10 +20,12 @@ namespace Server.Items public override int LabelNumber => 1094934; // Scroll of Transcendence + /* Using a Scroll of Transcendence for a given skill will permanently increase your current + * level in that skill by the amount of points displayed on the scroll. + * As you may not gain skills beyond your maximum skill cap, any excess points will be lost. + */ public override int Message => - 1094933; /*Using a Scroll of Transcendence for a given skill will permanently increase your current - *level in that skill by the amount of points displayed on the scroll. - *As you may not gain skills beyond your maximum skill cap, any excess points will be lost.*/ + 1094933; public override string DefaultTitle => $"Scroll of Transcendence ({Value} Skill):"; @@ -50,20 +52,17 @@ namespace Server.Items if (!(base.CanUse(from) && from is PlayerMobile pm)) return false; - #region Mondain's Legacy MLQuestContext context = MLQuestSystem.GetContext(pm); if (context != null) foreach (MLQuestInstance instance in context.QuestInstances) - foreach (BaseObjectiveInstance objective in instance.Objectives) - if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && - objectiveInstance.Handles(Skill)) - { - from.SendMessage("You are already under the effect of an enhanced skillgain quest."); - return false; - } - - #endregion + foreach (BaseObjectiveInstance objective in instance.Objectives) + if (!objective.Expired && objective is GainSkillObjectiveInstance objectiveInstance && + objectiveInstance.Handles(Skill)) + { + from.SendMessage("You are already under the effect of an enhanced skillgain quest."); + return false; + } if (pm.AcceleratedStart > DateTime.UtcNow) { @@ -111,9 +110,11 @@ namespace Server.Items if (!canGain) { + /* You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu. + * If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap. + */ from.SendLocalizedMessage( - 1094935); /*You cannot increase this skill at this time. The skill may be locked or set to lower in your skill menu. - *If you are at your total skill cap, you must use a Powerscroll to increase your current skill cap.*/ + 1094935); return; } @@ -140,7 +141,7 @@ namespace Server.Items { base.Deserialize(reader); - int version = InheritsItem ? 0 : reader.ReadInt(); //Required for SpecialScroll insertion + int version = InheritsItem ? 0 : reader.ReadInt(); // Required for SpecialScroll insertion LootType = LootType.Cursed; Insured = false; diff --git a/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs b/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs index 565d4da50..c58c93a3b 100644 --- a/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs +++ b/Projects/Scripts/Items/Special/Special Scrolls/SpecialScroll.cs @@ -18,23 +18,19 @@ namespace Server.Items { } - #region Old Item Serialization Vars - /* DO NOT USE! Only used in serialization of special scrolls that originally derived from Item */ - protected bool InheritsItem{ get; private set; } + protected bool InheritsItem { get; private set; } - #endregion - - public abstract int Message{ get; } + public abstract int Message { get; } public virtual int Title => 0; - public abstract string DefaultTitle{ get; } + public abstract string DefaultTitle { get; } [CommandProperty(AccessLevel.GameMaster)] - public SkillName Skill{ get; set; } + public SkillName Skill { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public double Value{ get; set; } + public double Value { get; set; } public virtual string GetNameLocalized() => $"#{AosSkillBonuses.GetLabel(Skill)}"; @@ -94,36 +90,36 @@ namespace Server.Items switch (version) { case 1: - { - Skill = (SkillName)reader.ReadInt(); - Value = reader.ReadDouble(); - break; - } - case 0: - { - InheritsItem = true; - - if (!(this is StatCapScroll)) + { Skill = (SkillName)reader.ReadInt(); - else - Skill = SkillName.Alchemy; - - if (this is ScrollofAlacrity) - Value = 0.0; - else if (this is StatCapScroll) - Value = reader.ReadInt(); - else Value = reader.ReadDouble(); + break; + } + case 0: + { + InheritsItem = true; - break; - } + if (!(this is StatCapScroll)) + Skill = (SkillName)reader.ReadInt(); + else + Skill = SkillName.Alchemy; + + if (this is ScrollofAlacrity) + Value = 0.0; + else if (this is StatCapScroll) + Value = reader.ReadInt(); + else + Value = reader.ReadDouble(); + + break; + } } } public class InternalGump : Gump { - private Mobile m_Mobile; - private SpecialScroll m_Scroll; + private readonly Mobile m_Mobile; + private readonly SpecialScroll m_Scroll; public InternalGump(Mobile mobile, SpecialScroll scroll) : base(25, 50) { diff --git a/Projects/Scripts/Items/Special/Special Scrolls/StatScroll.cs b/Projects/Scripts/Items/Special/Special Scrolls/StatScroll.cs index a9b9be2ab..16f6b61d1 100644 --- a/Projects/Scripts/Items/Special/Special Scrolls/StatScroll.cs +++ b/Projects/Scripts/Items/Special/Special Scrolls/StatScroll.cs @@ -11,11 +11,13 @@ namespace Server.Items { } + /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics. + * When used, the effect is not immediately seen without a gain of points with that skill or statistics. + * You can view your maximum skill values in your skills window. + * You can view your maximum statistic value in your statistics window. + */ public override int Message => - 1049469; /* Using a scroll increases the maximum amount of a specific skill or your maximum statistics. - * When used, the effect is not immediately seen without a gain of points with that skill or statistics. - * You can view your maximum skill values in your skills window. - * You can view your maximum statistic value in your statistics window. */ + 1049469; public override int Title { @@ -23,12 +25,14 @@ namespace Server.Items { int level = ((int)Value - 230) / 5; + /* Wonderous Scroll (+5 Maximum Stats): OR + * Exalted Scroll (+10 Maximum Stats): OR + * Mythical Scroll (+15 Maximum Stats): OR + * Legendary Scroll (+20 Maximum Stats): OR + * Ultimate Scroll (+25 Maximum Stats): + */ if (level >= 0 && level <= 4 && Value % 5 == 0) - return 1049458 + level; /* Wonderous Scroll (+5 Maximum Stats): OR - * Exalted Scroll (+10 Maximum Stats): OR - * Mythical Scroll (+15 Maximum Stats): OR - * Legendary Scroll (+20 Maximum Stats): OR - * Ultimate Scroll (+25 Maximum Stats): */ + return 1049458 + level; return 0; } @@ -42,11 +46,13 @@ namespace Server.Items int level = ((int)Value - 230) / 5; if (level >= 0 && level <= 4 && (int)Value % 5 == 0) - list.Add(1049463 + level, "#1049476"); /* a wonderous scroll of ~1_type~ (+5 Maximum Stats) OR - * an exalted scroll of ~1_type~ (+10 Maximum Stats) OR - * a mythical scroll of ~1_type~ (+15 Maximum Stats) OR - * a legendary scroll of ~1_type~ (+20 Maximum Stats) OR - * an ultimate scroll of ~1_type~ (+25 Maximum Stats) */ + /* a wonderous scroll of ~1_type~ (+5 Maximum Stats) OR + * an exalted scroll of ~1_type~ (+10 Maximum Stats) OR + * a mythical scroll of ~1_type~ (+15 Maximum Stats) OR + * a legendary scroll of ~1_type~ (+20 Maximum Stats) OR + * an ultimate scroll of ~1_type~ (+25 Maximum Stats) + */ + list.Add(1049463 + level, "#1049476"); else list.Add("a scroll of power ({0}{1} Maximum Stats)", Value - 225 >= 0 ? "+" : "", Value - 225); } @@ -119,7 +125,7 @@ namespace Server.Items { base.Deserialize(reader); - int version = InheritsItem ? 0 : reader.ReadInt(); //Required for SpecialScroll insertion + int version = InheritsItem ? 0 : reader.ReadInt(); // Required for SpecialScroll insertion LootType = LootType.Cursed; Insured = false; diff --git a/Projects/Scripts/Items/Special/Valentines/2007/ValentinesCard.cs b/Projects/Scripts/Items/Special/Valentines/2007/ValentinesCard.cs index 55e9e5c95..7554f858d 100644 --- a/Projects/Scripts/Items/Special/Valentines/2007/ValentinesCard.cs +++ b/Projects/Scripts/Items/Special/Valentines/2007/ValentinesCard.cs @@ -5,7 +5,7 @@ namespace Server.Items { public class ValentinesCard : Item { - private static string Unsigned = "___"; + private static readonly string Unsigned = "___"; private string m_From; private int m_LabelNumber; @@ -73,7 +73,7 @@ namespace Server.Items { from.BeginTarget(10, false, TargetFlags.None, OnTarget); - from.SendLocalizedMessage(1077497); //To whom do you wish to give this card? + from.SendLocalizedMessage(1077497); // To whom do you wish to give this card? } else { @@ -95,22 +95,22 @@ namespace Server.Items m_From = from.Name; m_To = to.Name; from.SendLocalizedMessage( - 1077498); //You fill out the card. Hopefully the other person actually likes you... + 1077498); // You fill out the card. Hopefully the other person actually likes you... InvalidateProperties(); } else { - from.SendLocalizedMessage(1077495); //You can't give yourself a card, silly! + from.SendLocalizedMessage(1077495); // You can't give yourself a card, silly! } } else { - from.SendLocalizedMessage(1077496); //You can't possibly be THAT lonely! + from.SendLocalizedMessage(1077496); // You can't possibly be THAT lonely! } } else { - from.SendLocalizedMessage(1077488); //That's not another player! + from.SendLocalizedMessage(1077488); // That's not another player! } } } diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs b/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs index fa77be17b..64cdc3689 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/AnkhOfSacrifice.cs @@ -80,8 +80,8 @@ namespace Server.Items private class ResurrectEntry : ContextMenuEntry { - private AnkhOfSacrificeAddon m_Ankh; - private Mobile m_Mobile; + private readonly AnkhOfSacrificeAddon m_Ankh; + private readonly Mobile m_Mobile; public ResurrectEntry(Mobile mobile, AnkhOfSacrificeAddon ankh) : base(6195, 2) { @@ -100,8 +100,8 @@ namespace Server.Items private class LockKarmaEntry : ContextMenuEntry { - private AnkhOfSacrificeAddon m_Ankh; - private PlayerMobile m_Mobile; + private readonly AnkhOfSacrificeAddon m_Ankh; + private readonly PlayerMobile m_Mobile; public LockKarmaEntry(PlayerMobile mobile, AnkhOfSacrificeAddon ankh) : base(mobile.KarmaLocked ? 6197 : 6196, 2) { diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs b/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs index f233361ad..156173cf3 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/Banner.cs @@ -201,7 +201,7 @@ namespace Server.Items public const int Start = 0x15AE; public const int End = 0x15F4; - private BannerDeed m_Banner; + private readonly BannerDeed m_Banner; public InternalGump(BannerDeed banner) : base(100, 200) { @@ -217,7 +217,6 @@ namespace Server.Items AddBackground(25, 0, 520, 230, 0xA28); AddLabel(70, 12, 0x3E3, "Choose a Banner:"); - int itemID = Start; for (int i = 1; i <= 4; i++) @@ -254,8 +253,8 @@ namespace Server.Items private class InternalTarget : Target { - private BannerDeed m_Banner; - private int m_ItemID; + private readonly BannerDeed m_Banner; + private readonly int m_ItemID; public InternalTarget(BannerDeed banner, int itemID) : base(-1, true, TargetFlags.None) { @@ -336,10 +335,10 @@ namespace Server.Items private class FacingGump : Gump { - private BannerDeed m_Banner; - private BaseHouse m_House; - private int m_ItemID; - private Point3D m_Location; + private readonly BannerDeed m_Banner; + private readonly BaseHouse m_House; + private readonly int m_ItemID; + private readonly Point3D m_Location; public FacingGump(BannerDeed banner, int itemID, Point3D location, BaseHouse house) : base(150, 50) { diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/Brazier.cs b/Projects/Scripts/Items/Special/Veteran Rewards/Brazier.cs index 5cf050e98..c295c2ff3 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/Brazier.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/Brazier.cs @@ -7,7 +7,7 @@ namespace Server.Items { public class RewardBrazier : Item, IRewardItem { - private static int[] m_Art = + private static readonly int[] m_Art = { 0x19AA, 0x19BB }; @@ -204,7 +204,7 @@ namespace Server.Items private class InternalGump : Gump { - private RewardBrazierDeed m_Brazier; + private readonly RewardBrazierDeed m_Brazier; public InternalGump(RewardBrazierDeed brazier) : base(100, 200) { diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs b/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs index 85ab7b05a..a24287e8e 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/Cannon.cs @@ -47,7 +47,7 @@ namespace Server.Items public class CannonAddon : BaseAddon { - private static int[] m_Effects = + private static readonly int[] m_Effects = { 0x36B0, 0x3728, 0x3709, 0x36FE }; @@ -63,37 +63,37 @@ namespace Server.Items switch (direction) { case CannonDirection.North: - { - AddComponent(new CannonAddonComponent(0xE8D), 0, 0, 0); - AddComponent(new CannonAddonComponent(0xE8C), 0, 1, 0); - AddComponent(new CannonAddonComponent(0xE8B), 0, 2, 0); + { + AddComponent(new CannonAddonComponent(0xE8D), 0, 0, 0); + AddComponent(new CannonAddonComponent(0xE8C), 0, 1, 0); + AddComponent(new CannonAddonComponent(0xE8B), 0, 2, 0); - break; - } + break; + } case CannonDirection.East: - { - AddComponent(new CannonAddonComponent(0xE96), 0, 0, 0); - AddComponent(new CannonAddonComponent(0xE95), -1, 0, 0); - AddComponent(new CannonAddonComponent(0xE94), -2, 0, 0); + { + AddComponent(new CannonAddonComponent(0xE96), 0, 0, 0); + AddComponent(new CannonAddonComponent(0xE95), -1, 0, 0); + AddComponent(new CannonAddonComponent(0xE94), -2, 0, 0); - break; - } + break; + } case CannonDirection.South: - { - AddComponent(new CannonAddonComponent(0xE91), 0, 0, 0); - AddComponent(new CannonAddonComponent(0xE92), 0, -1, 0); - AddComponent(new CannonAddonComponent(0xE93), 0, -2, 0); + { + AddComponent(new CannonAddonComponent(0xE91), 0, 0, 0); + AddComponent(new CannonAddonComponent(0xE92), 0, -1, 0); + AddComponent(new CannonAddonComponent(0xE93), 0, -2, 0); - break; - } + break; + } default: - { - AddComponent(new CannonAddonComponent(0xE8E), 0, 0, 0); - AddComponent(new CannonAddonComponent(0xE8F), 1, 0, 0); - AddComponent(new CannonAddonComponent(0xE90), 2, 0, 0); + { + AddComponent(new CannonAddonComponent(0xE8E), 0, 0, 0); + AddComponent(new CannonAddonComponent(0xE8F), 1, 0, 0); + AddComponent(new CannonAddonComponent(0xE90), 2, 0, 0); - break; - } + break; + } } } @@ -114,7 +114,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public CannonDirection CannonDirection{ get; private set; } + public CannonDirection CannonDirection { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public int Charges @@ -245,7 +245,7 @@ namespace Server.Items private class InternalTarget : Target { - private CannonAddon m_Cannon; + private readonly CannonAddon m_Cannon; public InternalTarget(CannonAddon cannon) : base(12, true, TargetFlags.None) => m_Cannon = cannon; @@ -314,8 +314,8 @@ namespace Server.Items private class InternalGump : Gump { - private CannonAddon m_Cannon; - private PotionKeg m_Keg; + private readonly CannonAddon m_Cannon; + private readonly PotionKeg m_Keg; public InternalGump(CannonAddon cannon, PotionKeg keg) : base(50, 50) { @@ -373,7 +373,8 @@ namespace Server.Items public override BaseAddon Addon => new CannonAddon(m_Direction) { - Charges = m_Charges, IsRewardItem = m_IsRewardItem + Charges = m_Charges, + IsRewardItem = m_IsRewardItem }; [CommandProperty(AccessLevel.GameMaster)] diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs b/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs index c2ba2cd2b..b4bc75eb2 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/DecorativeShield.cs @@ -42,8 +42,8 @@ namespace Server.Items } public bool CouldFit(IPoint3D p, Map map) => - map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) == true && (FacingSouth - && BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map) + map?.CanFit(p.X, p.Y, p.Z, ItemData.Height) == true && ((FacingSouth + && BaseAddon.IsWall(p.X, p.Y - 1, p.Z, map)) || BaseAddon.IsWall(p.X - 1, p.Y, p.Z, map)); [CommandProperty(AccessLevel.GameMaster)] @@ -185,7 +185,7 @@ namespace Server.Items 0x1583 => 0x1634, 0x1584 => 0x1637, 0x1585 => 0x1636, - _ => (east + 1) + _ => east + 1 }; } @@ -195,7 +195,7 @@ namespace Server.Items public const int End = 0x1585; private int m_Page; - private DecorativeShieldDeed m_Shield; + private readonly DecorativeShieldDeed m_Shield; public InternalGump(DecorativeShieldDeed shield, int page = 1) : base(150, 50) { @@ -243,8 +243,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)) + (((info.ButtonID & 0x1) != 0 || info.ButtonID >= 0x1582) && + (info.ButtonID < 0x1582 || info.ButtonID > 0x1585))) return; sender.Mobile.SendLocalizedMessage(1049780); // Where would you like to place this decoration? @@ -254,8 +254,8 @@ namespace Server.Items private class InternalTarget : Target { - private int m_ItemID; - private DecorativeShieldDeed m_Shield; + private readonly int m_ItemID; + private readonly DecorativeShieldDeed m_Shield; public InternalTarget(DecorativeShieldDeed shield, int itemID) : base(-1, true, TargetFlags.None) { @@ -332,10 +332,10 @@ namespace Server.Items private class FacingGump : Gump { - private BaseHouse m_House; - private int m_ItemID; - private Point3D m_Location; - private DecorativeShieldDeed m_Shield; + private readonly BaseHouse m_House; + private readonly int m_ItemID; + private readonly Point3D m_Location; + private readonly DecorativeShieldDeed m_Shield; public FacingGump(DecorativeShieldDeed shield, int itemID, Point3D location, BaseHouse house) : base(150, 50) { diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs b/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs index 67affbed2..2847462fb 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/FlamingHead.cs @@ -194,7 +194,7 @@ namespace Server.Items private class InternalTarget : Target { - private FlamingHeadDeed m_Head; + private readonly FlamingHeadDeed m_Head; public InternalTarget(FlamingHeadDeed head) : base(-1, true, TargetFlags.None) => m_Head = head; diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs b/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs index 7d62123c6..a16db8a78 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/HangingSkeleton.cs @@ -202,13 +202,13 @@ namespace Server.Items { 0x1B1E => 0x1B1D, 0x1B7F => 0x1B7C, - _ => (south + 1) + _ => south + 1 }; } private class InternalGump : Gump { - private HangingSkeletonDeed m_Skeleton; + private readonly HangingSkeletonDeed m_Skeleton; public InternalGump(HangingSkeletonDeed skeleton) : base(100, 200) { @@ -243,8 +243,8 @@ namespace Server.Items public override void OnResponse(NetState sender, RelayInfo info) { - if (m_Skeleton?.Deleted != false || info.ButtonID != 0x1A03 && info.ButtonID != 0x1A05 && - info.ButtonID != 0x1A09 && info.ButtonID != 0x1B1E && info.ButtonID != 0x1B7F) + if (m_Skeleton?.Deleted != false || (info.ButtonID != 0x1A03 && info.ButtonID != 0x1A05 && + info.ButtonID != 0x1A09 && info.ButtonID != 0x1B1E && info.ButtonID != 0x1B7F)) return; sender.Mobile.SendLocalizedMessage(1049780); // Where would you like to place this decoration? @@ -254,8 +254,8 @@ namespace Server.Items private class InternalTarget : Target { - private int m_ItemID; - private HangingSkeletonDeed m_Skeleton; + private readonly int m_ItemID; + private readonly HangingSkeletonDeed m_Skeleton; public InternalTarget(HangingSkeletonDeed banner, int itemID) : base(-1, true, TargetFlags.None) { @@ -332,10 +332,10 @@ namespace Server.Items private class FacingGump : Gump { - private BaseHouse m_House; - private int m_ItemID; - private Point3D m_Location; - private HangingSkeletonDeed m_Skeleton; + private readonly BaseHouse m_House; + private readonly int m_ItemID; + private readonly Point3D m_Location; + private readonly HangingSkeletonDeed m_Skeleton; public FacingGump(HangingSkeletonDeed banner, int itemID, Point3D location, BaseHouse house) : base(150, 50) { diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs b/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs index 250667841..b5c40ef45 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/MiningCart.cs @@ -88,16 +88,16 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public MiningCartType CartType{ get; private set; } + public MiningCartType CartType { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int Gems{ get; set; } + public int Gems { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Ore{ get; set; } + public int Ore { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } private void GiveResources() { @@ -236,12 +236,8 @@ namespace Server.Items writer.WriteEncodedInt(1); // version - #region version 1 - writer.Write((int)CartType); - #endregion - writer.Write(IsRewardItem); writer.Write(Gems); writer.Write(Ore); @@ -308,10 +304,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int Gems{ get; set; } + public int Gems { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Ore{ get; set; } + public int Ore { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsRewardItem diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs b/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs index db87638c3..b4f034af6 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/PottedCactus.cs @@ -100,7 +100,6 @@ namespace Server.Items } } - public override void GetProperties(ObjectPropertyList list) { base.GetProperties(list); @@ -129,7 +128,7 @@ namespace Server.Items private class InternalGump : Gump { - private PottedCactusDeed m_Cactus; + private readonly PottedCactusDeed m_Cactus; public InternalGump(PottedCactusDeed cactus) : base(100, 200) { diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs b/Projects/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs index 95846c0d2..958820b56 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/StoneAnkh.cs @@ -223,7 +223,7 @@ namespace Server.Items private class InternalGump : Gump { - private StoneAnkhDeed m_Deed; + private readonly StoneAnkhDeed m_Deed; public InternalGump(StoneAnkhDeed deed) : base(150, 50) { diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/WallBanner.cs b/Projects/Scripts/Items/Special/Veteran Rewards/WallBanner.cs index 9ed91dfc8..a87386635 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/WallBanner.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/WallBanner.cs @@ -139,7 +139,6 @@ namespace Server.Items AddComponent(new WallBannerComponent(0x159D), 2, 0, 0); break; - case 17: AddComponent(new WallBannerComponent(0x1610), 0, 0, 0); AddComponent(new WallBannerComponent(0x160F), 0, 1, 0); @@ -350,11 +349,11 @@ namespace Server.Items private class InternalGump : Gump { - private WallBannerDeed m_WallBanner; + private readonly WallBannerDeed m_WallBanner; - public InternalGump(WallBannerDeed WallBanner) : base(150, 50) + public InternalGump(WallBannerDeed wallBanner) : base(150, 50) { - m_WallBanner = WallBanner; + m_WallBanner = wallBanner; Closable = true; Disposable = true; diff --git a/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs b/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs index 1965e105f..3e05269dd 100644 --- a/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs +++ b/Projects/Scripts/Items/Special/Veteran Rewards/WeaponEngravingTool.cs @@ -189,7 +189,7 @@ namespace Server.Items private class TargetWeapon : Target { - private WeaponEngravingTool m_Tool; + private readonly WeaponEngravingTool m_Tool; public TargetWeapon(WeaponEngravingTool tool) : base(-1, true, TargetFlags.None) => m_Tool = tool; @@ -212,8 +212,8 @@ namespace Server.Items private class InternalGump : Gump { - private BaseWeapon m_Target; - private WeaponEngravingTool m_Tool; + private readonly BaseWeapon m_Target; + private readonly WeaponEngravingTool m_Tool; public InternalGump(WeaponEngravingTool tool, BaseWeapon target) : base(0, 0) { @@ -285,8 +285,8 @@ namespace Server.Items public class ConfirmGump : Gump { - private WeaponEngravingTool m_Engraver; - private Mobile m_Guildmaster; + private readonly WeaponEngravingTool m_Engraver; + private readonly Mobile m_Guildmaster; public ConfirmGump(WeaponEngravingTool engraver, Mobile guildmaster) : base(200, 200) { diff --git a/Projects/Scripts/Items/Suits/BaseSuit.cs b/Projects/Scripts/Items/Suits/BaseSuit.cs index c56533927..0ca89e3e6 100644 --- a/Projects/Scripts/Items/Suits/BaseSuit.cs +++ b/Projects/Scripts/Items/Suits/BaseSuit.cs @@ -18,7 +18,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.Administrator)] - public AccessLevel AccessLevel{ get; set; } + public AccessLevel AccessLevel { get; set; } public override void Serialize(IGenericWriter writer) { @@ -38,10 +38,10 @@ namespace Server.Items switch (version) { case 0: - { - AccessLevel = (AccessLevel)reader.ReadInt(); - break; - } + { + AccessLevel = (AccessLevel)reader.ReadInt(); + break; + } } } @@ -52,7 +52,6 @@ namespace Server.Items Delete(); return false; - } public override void OnSingleClick(Mobile from) diff --git a/Projects/Scripts/Items/Talismans/BaseTalisman.cs b/Projects/Scripts/Items/Talismans/BaseTalisman.cs index 2ce77776e..efe5b3b1b 100644 --- a/Projects/Scripts/Items/Talismans/BaseTalisman.cs +++ b/Projects/Scripts/Items/Talismans/BaseTalisman.cs @@ -520,56 +520,56 @@ namespace Server.Items switch (version) { case 0: - { - SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); + { + SaveFlag flags = (SaveFlag)reader.ReadEncodedInt(); - Attributes = GetSaveFlag(flags, SaveFlag.Attributes) ? new AosAttributes(this, reader) : new AosAttributes(this); - SkillBonuses = GetSaveFlag(flags, SaveFlag.SkillBonuses) - ? new AosSkillBonuses(this, reader) - : new AosSkillBonuses(this); + Attributes = GetSaveFlag(flags, SaveFlag.Attributes) ? new AosAttributes(this, reader) : new AosAttributes(this); + SkillBonuses = GetSaveFlag(flags, SaveFlag.SkillBonuses) + ? new AosSkillBonuses(this, reader) + : new AosSkillBonuses(this); - // Backward compatibility - if (GetSaveFlag(flags, SaveFlag.Owner)) - BlessedFor = reader.ReadMobile(); + // Backward compatibility + if (GetSaveFlag(flags, SaveFlag.Owner)) + BlessedFor = reader.ReadMobile(); - m_Protection = GetSaveFlag(flags, SaveFlag.Protection) ? new TalismanAttribute(reader) : new TalismanAttribute(); - m_Killer = GetSaveFlag(flags, SaveFlag.Killer) ? new TalismanAttribute(reader) : new TalismanAttribute(); - m_Summoner = GetSaveFlag(flags, SaveFlag.Summoner) ? new TalismanAttribute(reader) : new TalismanAttribute(); + m_Protection = GetSaveFlag(flags, SaveFlag.Protection) ? new TalismanAttribute(reader) : new TalismanAttribute(); + m_Killer = GetSaveFlag(flags, SaveFlag.Killer) ? new TalismanAttribute(reader) : new TalismanAttribute(); + m_Summoner = GetSaveFlag(flags, SaveFlag.Summoner) ? new TalismanAttribute(reader) : new TalismanAttribute(); - if (GetSaveFlag(flags, SaveFlag.Removal)) - m_Removal = (TalismanRemoval)reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.Removal)) + m_Removal = (TalismanRemoval)reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.OldKarmaLoss)) - Attributes.IncreasedKarmaLoss = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.OldKarmaLoss)) + Attributes.IncreasedKarmaLoss = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.Skill)) - m_Skill = (SkillName)reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.Skill)) + m_Skill = (SkillName)reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.SuccessBonus)) - m_SuccessBonus = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.SuccessBonus)) + m_SuccessBonus = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus)) - m_ExceptionalBonus = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.ExceptionalBonus)) + m_ExceptionalBonus = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.MaxCharges)) - m_MaxCharges = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.MaxCharges)) + m_MaxCharges = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.Charges)) - m_Charges = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.Charges)) + m_Charges = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.MaxChargeTime)) - m_MaxChargeTime = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.MaxChargeTime)) + m_MaxChargeTime = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.ChargeTime)) - m_ChargeTime = reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.ChargeTime)) + m_ChargeTime = reader.ReadEncodedInt(); - if (GetSaveFlag(flags, SaveFlag.Slayer)) - m_Slayer = (TalismanSlayerName)reader.ReadEncodedInt(); + if (GetSaveFlag(flags, SaveFlag.Slayer)) + m_Slayer = (TalismanSlayerName)reader.ReadEncodedInt(); - m_Blessed = GetSaveFlag(flags, SaveFlag.Blessed); + m_Blessed = GetSaveFlag(flags, SaveFlag.Blessed); - break; - } + break; + } } if (Parent is Mobile m) @@ -637,7 +637,7 @@ namespace Server.Items private class TalismanTarget : Target { - private BaseTalisman m_Talisman; + private readonly BaseTalisman m_Talisman; public TalismanTarget(BaseTalisman talisman) : base(12, false, TargetFlags.Beneficial) => @@ -761,8 +761,6 @@ namespace Server.Items } } - #region Slayer - private TalismanSlayerName m_Slayer; [CommandProperty(AccessLevel.GameMaster)] @@ -776,10 +774,6 @@ namespace Server.Items } } - #endregion - - #region Summoner/Removal - private TalismanAttribute m_Summoner; private TalismanRemoval m_Removal; private Mobile m_Creature; @@ -806,10 +800,6 @@ namespace Server.Items } } - #endregion - - #region Protection/Killer - private TalismanAttribute m_Protection; private TalismanAttribute m_Killer; @@ -835,10 +825,6 @@ namespace Server.Items } } - #endregion - - #region Craft bonuses - private SkillName m_Skill; private int m_SuccessBonus; private int m_ExceptionalBonus; @@ -876,19 +862,11 @@ namespace Server.Items } } - #endregion - - #region AOS bonuses + [CommandProperty(AccessLevel.GameMaster)] + public AosAttributes Attributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosAttributes Attributes{ get; private set; } - - [CommandProperty(AccessLevel.GameMaster)] - public AosSkillBonuses SkillBonuses{ get; private set; } - - #endregion - - #region Timer + public AosSkillBonuses SkillBonuses { get; private set; } private Timer m_Timer; @@ -920,18 +898,14 @@ namespace Server.Items InvalidateProperties(); } - #endregion - - #region Randomize - - private static int[] m_ItemIDs = + private static readonly int[] m_ItemIDs = { 0x2F58, 0x2F59, 0x2F5A, 0x2F5B }; public static int GetRandomItemID() => Utility.RandomList(m_ItemIDs); - private static Type[] m_Summons = + private static readonly Type[] m_Summons = { typeof(SummonedAntLion), typeof(SummonedCow), @@ -956,7 +930,7 @@ namespace Server.Items typeof(Bandage) }; - private static int[] m_SummonLabels = + private static readonly int[] m_SummonLabels = { 1075211, // Ant Lion 1072494, // Cow @@ -985,7 +959,7 @@ namespace Server.Items public static TalismanAttribute GetRandomSummoner() { - if (0.025 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.025) return new TalismanAttribute(); int num = Utility.Random(m_Summons.Length); @@ -997,13 +971,13 @@ namespace Server.Items public static TalismanRemoval GetRandomRemoval() { - if (0.65 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.65) return (TalismanRemoval)Utility.RandomList(390, 404, 407); return TalismanRemoval.None; } - private static Type[] m_Killers = + private static readonly Type[] m_Killers = { typeof(OrcBomber), typeof(OrcBrute), typeof(SewerRat), typeof(Rat), typeof(GiantRat), typeof(Ratman), typeof(RatmanArcher), typeof(GiantSpider), typeof(FrostSpider), typeof(GiantBlackWidow), @@ -1017,11 +991,11 @@ namespace Server.Items typeof(Crane), typeof(SnowLeopard), typeof(IceFiend), typeof(FrostOoze), typeof(FrostTroll), typeof(IceElemental), typeof(SnowElemental), typeof(GiantIceWorm), typeof(LadyOfTheSnow), typeof(FireElemental), typeof(FireSteed), typeof(HellHound), typeof(HellCat), typeof(PredatorHellCat), typeof(LavaLizard), - typeof(FireBeetle), typeof(Cow), typeof(Bull), typeof(Gaman) //, typeof( Minotaur) + typeof(FireBeetle), typeof(Cow), typeof(Bull), typeof(Gaman) // , typeof( Minotaur) // TODO Meraktus, Tormented Minotaur, Minotaur }; - private static int[] m_KillerLabels = + private static readonly int[] m_KillerLabels = { 1072413, 1072414, 1072418, 1072419, 1072420, 1072421, 1072423, 1072424, 1072425, 1072426, @@ -1062,7 +1036,7 @@ namespace Server.Items return new TalismanAttribute(m_Killers[num], m_KillerLabels[num], Utility.RandomMinMax(5, 60)); } - private static SkillName[] m_Skills = + private static readonly SkillName[] m_Skills = { SkillName.Alchemy, SkillName.Blacksmith, @@ -1079,7 +1053,7 @@ namespace Server.Items public static int GetRandomExceptional() { - if (0.3 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.3) { double num = 40 - Math.Log(Utility.RandomMinMax(7, 403)) * 5; @@ -1091,7 +1065,7 @@ namespace Server.Items public static int GetRandomSuccessful() { - if (0.75 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.75) { double num = 40 - Math.Log(Utility.RandomMinMax(7, 403)) * 5; @@ -1101,12 +1075,10 @@ namespace Server.Items return 0; } - public static bool GetRandomBlessed() => 0.02 > Utility.RandomDouble(); + public static bool GetRandomBlessed() => Utility.RandomDouble() < 0.02; - public static TalismanSlayerName GetRandomSlayer() => 0.01 > Utility.RandomDouble() ? (TalismanSlayerName)Utility.RandomMinMax(1, 9) : TalismanSlayerName.None; + public static TalismanSlayerName GetRandomSlayer() => Utility.RandomDouble() < 0.01 ? (TalismanSlayerName)Utility.RandomMinMax(1, 9) : TalismanSlayerName.None; - public static int GetRandomCharges() => 0.5 > Utility.RandomDouble() ? Utility.RandomMinMax(10, 50) : 0; - - #endregion + public static int GetRandomCharges() => Utility.RandomDouble() < 0.5 ? Utility.RandomMinMax(10, 50) : 0; } } diff --git a/Projects/Scripts/Items/Talismans/Items/RunedSwitch.cs b/Projects/Scripts/Items/Talismans/Items/RunedSwitch.cs index e7a6b3f31..b6b106e01 100644 --- a/Projects/Scripts/Items/Talismans/Items/RunedSwitch.cs +++ b/Projects/Scripts/Items/Talismans/Items/RunedSwitch.cs @@ -42,7 +42,7 @@ namespace Server.Items private class InternalTarget : Target { - private RunedSwitch m_Item; + private readonly RunedSwitch m_Item; public InternalTarget(RunedSwitch item) : base(0, false, TargetFlags.None) => m_Item = item; diff --git a/Projects/Scripts/Items/Talismans/TalismanAttribute.cs b/Projects/Scripts/Items/Talismans/TalismanAttribute.cs index 1f22f4fa2..8f9082092 100644 --- a/Projects/Scripts/Items/Talismans/TalismanAttribute.cs +++ b/Projects/Scripts/Items/Talismans/TalismanAttribute.cs @@ -43,13 +43,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Type Type{ get; set; } + public Type Type { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TextDefinition Name{ get; set; } + public TextDefinition Name { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Amount{ get; set; } + public int Amount { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsEmpty => Type == null; diff --git a/Projects/Scripts/Items/Talismans/TalismanSlayer.cs b/Projects/Scripts/Items/Talismans/TalismanSlayer.cs index badbeea1a..f1f0debbb 100644 --- a/Projects/Scripts/Items/Talismans/TalismanSlayer.cs +++ b/Projects/Scripts/Items/Talismans/TalismanSlayer.cs @@ -28,12 +28,12 @@ namespace Server.Items { [TalismanSlayerName.Bear] = new[] { - typeof(GrizzlyBear), typeof(BlackBear), typeof(BrownBear), typeof(PolarBear) //, typeof( Grobu ) + typeof(GrizzlyBear), typeof(BlackBear), typeof(BrownBear), typeof(PolarBear) // , typeof( Grobu ) }, [TalismanSlayerName.Vermin] = new[] { typeof(RatmanMage), typeof(RatmanMage), typeof(RatmanArcher), typeof(Barracoon), typeof(Ratman), typeof(SewerRat), - typeof(Rat), typeof(GiantRat) //, typeof( Chiikkaha ) + typeof(Rat), typeof(GiantRat) // , typeof( Chiikkaha ) }, [TalismanSlayerName.Bat] = new[] { typeof(Mongbat), typeof(StrongMongbat), typeof(VampireBat) }, [TalismanSlayerName.Mage] = @@ -73,8 +73,7 @@ namespace Server.Items }, [TalismanSlayerName.Bovine] = new[] { - typeof(Cow), typeof(Bull), typeof(Gaman) /*, typeof( MinotaurCaptain ), - typeof( MinotaurScout ), typeof( Minotaur )*/ + typeof(Cow), typeof(Bull), typeof(Gaman) /*, typeof( MinotaurCaptain ), typeof( MinotaurScout ), typeof( Minotaur ) */ // TODO TormentedMinotaur } }; diff --git a/Projects/Scripts/Items/Talismans/TalismanSummons.cs b/Projects/Scripts/Items/Talismans/TalismanSummons.cs index f636087c1..a12ff8a44 100644 --- a/Projects/Scripts/Items/Talismans/TalismanSummons.cs +++ b/Projects/Scripts/Items/Talismans/TalismanSummons.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class BaseTalismanSummon : BaseCreature { - //public override bool IsInvulnerable => true; // TODO: Wailing banshees are NOT invulnerable, are any of the others? + // public override bool IsInvulnerable => true; // TODO: Wailing banshees are NOT invulnerable, are any of the others? public BaseTalismanSummon() : base(AIType.AI_Melee, FightMode.None, 10, 1, 0.2, 0.4) { @@ -43,7 +43,7 @@ namespace Server.Mobiles private class TalismanReleaseEntry : ContextMenuEntry { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public TalismanReleaseEntry(Mobile m) : base(6118, 3) => m_Mobile = m; @@ -377,7 +377,7 @@ namespace Server.Mobiles public override void OnThink() { /* - if ( m_NextWave < DateTime.UtcNow ) + if (m_NextWave < DateTime.UtcNow) AreaHeatDamage(); */ } @@ -405,11 +405,11 @@ namespace Server.Mobiles { Mobile mob = ControlMaster; - if ( mob != null ) + if (mob != null) { - if ( mob.InRange( Location, 2 ) ) + if (mob.InRange( Location, 2 )) { - if ( mob.AccessLevel != AccessLevel.Player ) + if (mob.AccessLevel != AccessLevel.Player) { AOS.Damage( mob, Utility.Random( 2, 3 ), 0, 100, 0, 0, 0 ); mob.SendLocalizedMessage( 1008112 ); // The intense heat is damaging you! @@ -418,11 +418,11 @@ namespace Server.Mobiles GuardedRegion r = Region as GuardedRegion; - if ( r != null && mob.Alive ) + if (r != null && mob.Alive) { foreach ( Mobile m in GetMobilesInRange( 2 ) ) { - if ( !mob.CanBeHarmful( m ) ) + if (!mob.CanBeHarmful( m )) mob.CriminalAction( false ); } } @@ -509,7 +509,6 @@ namespace Server.Mobiles public override string DefaultName => "a sheep"; - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); @@ -631,4 +630,4 @@ namespace Server.Mobiles int version = reader.ReadEncodedInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Traps/FireColumnTrap.cs b/Projects/Scripts/Items/Traps/FireColumnTrap.cs index 94bef1b10..5c31ee07b 100644 --- a/Projects/Scripts/Items/Traps/FireColumnTrap.cs +++ b/Projects/Scripts/Items/Traps/FireColumnTrap.cs @@ -95,12 +95,12 @@ namespace Server.Items switch (version) { case 1: - { - m_WarningFlame = reader.ReadBool(); - m_MinDamage = reader.ReadInt(); - m_MaxDamage = reader.ReadInt(); - break; - } + { + m_WarningFlame = reader.ReadBool(); + m_MinDamage = reader.ReadInt(); + m_MaxDamage = reader.ReadInt(); + break; + } } if (version == 0) diff --git a/Projects/Scripts/Items/Traps/FlameSpurtTrap.cs b/Projects/Scripts/Items/Traps/FlameSpurtTrap.cs index c98651238..a7ec5e3d8 100644 --- a/Projects/Scripts/Items/Traps/FlameSpurtTrap.cs +++ b/Projects/Scripts/Items/Traps/FlameSpurtTrap.cs @@ -147,15 +147,15 @@ namespace Server.Items switch (version) { case 0: - { - Item item = reader.ReadItem(); + { + Item item = reader.ReadItem(); - item?.Delete(); + item?.Delete(); - CheckTimer(); + CheckTimer(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Items/Traps/GasTrap.cs b/Projects/Scripts/Items/Traps/GasTrap.cs index dccda2f15..cd33b5221 100644 --- a/Projects/Scripts/Items/Traps/GasTrap.cs +++ b/Projects/Scripts/Items/Traps/GasTrap.cs @@ -30,7 +30,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Poison Poison{ get; set; } + public Poison Poison { get; set; } [CommandProperty(AccessLevel.GameMaster)] public GasTrapType Type @@ -95,10 +95,10 @@ namespace Server.Items switch (version) { case 0: - { - Poison = Poison.Deserialize(reader); - break; - } + { + Poison = Poison.Deserialize(reader); + break; + } } } } diff --git a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel1.cs b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel1.cs index a74666b22..33df9c693 100644 --- a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel1.cs +++ b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel1.cs @@ -34,7 +34,7 @@ namespace Server.Items DropItem(new Gold(Utility.Random(30, 100))); // Drop bolts - //DropItem( new Bolt( 10 ) ); + // DropItem( new Bolt( 10 ) ); // Gems if (Utility.RandomBool()) diff --git a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs index 45c775c26..d7eb93190 100644 --- a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs +++ b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel2.cs @@ -33,7 +33,7 @@ namespace Server.Items DropItem(new Gold(Utility.Random(70, 100))); // Drop bolts - //DropItem( new Arrow( 10 ) ); + // DropItem( new Arrow( 10 ) ); // Reagents for (int i = Utility.Random(1, m_Level); i > 1; i--) diff --git a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs index 7b651db43..75d8a65fe 100644 --- a/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs +++ b/Projects/Scripts/Items/TreasureChests/TreasureChestLevel3.cs @@ -38,7 +38,7 @@ namespace Server.Items DropItem(new Gold(Utility.Random(180, 240))); // Drop bolts - //DropItem( new Arrow( 10 ) ); + // DropItem( new Arrow( 10 ) ); // Reagents for (int i = Utility.Random(1, m_Level); i > 1; i--) diff --git a/Projects/Scripts/Items/Wands/BaseWand.cs b/Projects/Scripts/Items/Wands/BaseWand.cs index 0a523ac3f..50c789b88 100644 --- a/Projects/Scripts/Items/Wands/BaseWand.cs +++ b/Projects/Scripts/Items/Wands/BaseWand.cs @@ -144,12 +144,12 @@ namespace Server.Items switch (version) { case 0: - { - m_WandEffect = (WandEffect)reader.ReadInt(); - m_Charges = reader.ReadInt(); + { + m_WandEffect = (WandEffect)reader.ReadInt(); + m_Charges = reader.ReadInt(); - break; - } + break; + } } } diff --git a/Projects/Scripts/Items/Wands/WandTarget.cs b/Projects/Scripts/Items/Wands/WandTarget.cs index 29d2fc9fc..35edc5cec 100644 --- a/Projects/Scripts/Items/Wands/WandTarget.cs +++ b/Projects/Scripts/Items/Wands/WandTarget.cs @@ -4,7 +4,7 @@ namespace Server.Targeting { public class WandTarget : Target { - private BaseWand m_Item; + private readonly BaseWand m_Item; public WandTarget(BaseWand item) : base(6, false, TargetFlags.None) => m_Item = item; diff --git a/Projects/Scripts/Items/Weapons/Abilities/BleedAttack.cs b/Projects/Scripts/Items/Weapons/Abilities/BleedAttack.cs index e95ac29ba..08396c021 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/BleedAttack.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/BleedAttack.cs @@ -14,7 +14,7 @@ namespace Server.Items /// public class BleedAttack : WeaponAbility { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 30; @@ -28,8 +28,8 @@ namespace Server.Items // Necromancers under Lich or Wraith Form are immune to Bleed Attacks. TransformContext context = TransformationSpellHelper.GetContext(defender); - if (context != null && (context.Type == typeof(LichFormSpell) || context.Type == typeof(WraithFormSpell)) || - defender is BaseCreature creature && creature.BleedImmune) + if ((context != null && (context.Type == typeof(LichFormSpell) || context.Type == typeof(WraithFormSpell))) || + (defender is BaseCreature creature && creature.BleedImmune)) { attacker.SendLocalizedMessage(1062052); // Your target is not affected by the bleed attack! return; @@ -98,8 +98,8 @@ namespace Server.Items private class InternalTimer : Timer { private int m_Count; - private Mobile m_From; - private Mobile m_Mobile; + private readonly Mobile m_From; + private readonly Mobile m_Mobile; public InternalTimer(Mobile from, Mobile m) : base(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.0)) { diff --git a/Projects/Scripts/Items/Weapons/Abilities/Block.cs b/Projects/Scripts/Items/Weapons/Abilities/Block.cs index 06aea5584..f9f3b884d 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/Block.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/Block.cs @@ -8,7 +8,7 @@ namespace Server.Items /// public class Block : WeaponAbility { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 30; @@ -68,8 +68,8 @@ namespace Server.Items private class BlockInfo { - public int m_Bonus; - public Timer m_Timer; + public readonly int m_Bonus; + public readonly Timer m_Timer; public BlockInfo(Mobile target, int bonus) { @@ -80,7 +80,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m) : base(TimeSpan.FromSeconds(6.0)) { diff --git a/Projects/Scripts/Items/Weapons/Abilities/CrushingBlow.cs b/Projects/Scripts/Items/Weapons/Abilities/CrushingBlow.cs index d45108a82..16dfdb62b 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/CrushingBlow.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/CrushingBlow.cs @@ -8,7 +8,6 @@ namespace Server.Items public override int BaseMana => 25; public override double DamageScalar => 1.5; - public override void OnHit(Mobile attacker, Mobile defender, int damage) { if (!Validate(attacker) || !CheckMana(attacker, true)) diff --git a/Projects/Scripts/Items/Weapons/Abilities/DefenseMastery.cs b/Projects/Scripts/Items/Weapons/Abilities/DefenseMastery.cs index adb6c70b4..839a98205 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/DefenseMastery.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/DefenseMastery.cs @@ -9,7 +9,7 @@ namespace Server.Items /// public class DefenseMastery : WeaponAbility { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 30; @@ -80,9 +80,9 @@ namespace Server.Items private class DefenseMasteryInfo { - public int m_DamageMalus; - public Mobile m_From; - public ResistanceMod m_Mod; + public readonly int m_DamageMalus; + public readonly Mobile m_From; + public readonly ResistanceMod m_Mod; public Timer m_Timer; public DefenseMasteryInfo(Mobile from, int damageMalus, ResistanceMod mod) diff --git a/Projects/Scripts/Items/Weapons/Abilities/Disarm.cs b/Projects/Scripts/Items/Weapons/Abilities/Disarm.cs index 4284dae7c..589c1073a 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/Disarm.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/Disarm.cs @@ -15,15 +15,15 @@ namespace Server.Items // No longer active in pub21: /*public override bool CheckSkills( Mobile from ) { - if ( !base.CheckSkills( from ) ) + if (!base.CheckSkills( from )) return false; - if ( !(from.Weapon is Fists) ) + if (!(from.Weapon is Fists)) return true; Skill skill = from.Skills.ArmsLore; - if ( skill?.Base >= 80.0 ) + if (skill?.Base >= 80.0) return true; from.SendLocalizedMessage( 1061812 ); // You lack the required skill in armslore to perform that attack! @@ -57,7 +57,7 @@ namespace Server.Items { attacker.SendLocalizedMessage(1004001); // You cannot disarm your opponent. } - else if (!Core.ML && toDisarm == null || toDisarm is BaseShield || toDisarm is Spellbook) + else if ((!Core.ML && toDisarm == null) || toDisarm is BaseShield || toDisarm is Spellbook) { attacker.SendLocalizedMessage(1060849); // Your target is already unarmed! } diff --git a/Projects/Scripts/Items/Weapons/Abilities/Dismount.cs b/Projects/Scripts/Items/Weapons/Abilities/Dismount.cs index 8b3dd43cf..3c34153b4 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/Dismount.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/Dismount.cs @@ -38,8 +38,7 @@ namespace Server.Items if (defender is ChaosDragoon || defender is ChaosDragoonElite) return; - if (attacker.Mounted && (!(attacker.Weapon is Lance) || !(defender.Weapon is Lance)) - ) // TODO: Should there be a message here? + if (attacker.Mounted && (!(attacker.Weapon is Lance) || !(defender.Weapon is Lance))) // TODO: Should there be a message here? return; ClearCurrentAbility(attacker); @@ -55,8 +54,8 @@ namespace Server.Items if (!CheckMana(attacker, true)) return; - if (Core.ML && attacker is LesserHiryu && 0.8 >= Utility.RandomDouble()) - return; //Lesser Hiryu have an 80% chance of missing this attack + if (Core.ML && attacker is LesserHiryu && Utility.RandomDouble() <= 0.8) + return; // Lesser Hiryu have an 80% chance of missing this attack attacker.SendLocalizedMessage(1060082); // The force of your attack has dislodged them from their mount! diff --git a/Projects/Scripts/Items/Weapons/Abilities/Disrobe.cs b/Projects/Scripts/Items/Weapons/Abilities/Disrobe.cs index 598236c8a..213bee565 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/Disrobe.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/Disrobe.cs @@ -30,11 +30,11 @@ namespace Server.Items } else if (CheckMana(attacker, true)) { - //attacker.SendLocalizedMessage( 1060092 ); // You disarm their weapon! + // attacker.SendLocalizedMessage( 1060092 ); // You disarm their weapon! defender.SendLocalizedMessage(1062002); // You can no longer wear your ~1_ARMOR~ defender.PlaySound(0x3B9); - //defender.FixedParticles( 0x37BE, 232, 25, 9948, EffectLayer.InnerTorso ); + // defender.FixedParticles( 0x37BE, 232, 25, 9948, EffectLayer.InnerTorso ); pack.DropItem(toDisrobe); diff --git a/Projects/Scripts/Items/Weapons/Abilities/DoubleShot.cs b/Projects/Scripts/Items/Weapons/Abilities/DoubleShot.cs index 973f8219d..e0aa90b60 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/DoubleShot.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/DoubleShot.cs @@ -44,7 +44,7 @@ namespace Server.Items public void Use(Mobile attacker, Mobile defender) { - if (!Validate(attacker) || !CheckMana(attacker, true) || attacker.Weapon == null) //sanity + if (!Validate(attacker) || !CheckMana(attacker, true) || attacker.Weapon == null) // sanity return; ClearCurrentAbility(attacker); diff --git a/Projects/Scripts/Items/Weapons/Abilities/DoubleStrike.cs b/Projects/Scripts/Items/Weapons/Abilities/DoubleStrike.cs index ba0e9bd99..926846602 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/DoubleStrike.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/DoubleStrike.cs @@ -34,7 +34,7 @@ namespace Server.Items IWeapon weapon = attacker.Weapon; - if (!(weapon != null && attacker.InRange(defender, weapon.MaxRange) &&attacker.InLOS(defender))) + if (!(weapon != null && attacker.InRange(defender, weapon.MaxRange) && attacker.InLOS(defender))) return; BaseWeapon.InDoubleStrike = true; diff --git a/Projects/Scripts/Items/Weapons/Abilities/DualWield.cs b/Projects/Scripts/Items/Weapons/Abilities/DualWield.cs index 2b972e6f2..f168e4325 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/DualWield.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/DualWield.cs @@ -8,7 +8,7 @@ namespace Server.Items /// public class DualWield : WeaponAbility { - public static Dictionary Registry{ get; } = new Dictionary(); + public static Dictionary Registry { get; } = new Dictionary(); public override int BaseMana => 30; @@ -41,7 +41,7 @@ namespace Server.Items attacker.FixedParticles(0x3779, 1, 15, 0x7F6, 0x3E8, 3, EffectLayer.LeftHand); timer = new DualWieldTimer(attacker, - (int)(20.0 + 3.0 * (attacker.Skills.Ninjitsu.Value - 50.0) / 7.0)); //20-50 % increase + (int)(20.0 + 3.0 * (attacker.Skills.Ninjitsu.Value - 50.0) / 7.0)); // 20-50 % increase timer.Start(); Registry.Add(attacker, timer); @@ -49,7 +49,7 @@ namespace Server.Items public class DualWieldTimer : Timer { - private Mobile m_Owner; + private readonly Mobile m_Owner; public DualWieldTimer(Mobile owner, int bonusSwingSpeed) : base(TimeSpan.FromSeconds(6.0)) @@ -59,7 +59,7 @@ namespace Server.Items Priority = TimerPriority.FiftyMS; } - public int BonusSwingSpeed{ get; } + public int BonusSwingSpeed { get; } protected override void OnTick() { diff --git a/Projects/Scripts/Items/Weapons/Abilities/Feint.cs b/Projects/Scripts/Items/Weapons/Abilities/Feint.cs index 1421da2d9..11dd2c803 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/Feint.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/Feint.cs @@ -8,7 +8,7 @@ namespace Server.Items /// public class Feint : WeaponAbility { - public static Dictionary Registry{ get; } = new Dictionary(); + public static Dictionary Registry { get; } = new Dictionary(); public override int BaseMana => 30; @@ -44,7 +44,7 @@ namespace Server.Items timer = new FeintTimer(defender, (int)(20.0 + 3.0 * (Math.Max(attacker.Skills.Ninjitsu.Value, - attacker.Skills.Bushido.Value) - 50.0) / 7.0)); //20-50 % decrease + attacker.Skills.Bushido.Value) - 50.0) / 7.0)); // 20-50 % decrease timer.Start(); Registry.Add(defender, timer); @@ -52,7 +52,7 @@ namespace Server.Items public class FeintTimer : Timer { - private Mobile m_Defender; + private readonly Mobile m_Defender; public FeintTimer(Mobile defender, int swingSpeedReduction) : base(TimeSpan.FromSeconds(6.0)) @@ -62,7 +62,7 @@ namespace Server.Items Priority = TimerPriority.FiftyMS; } - public int SwingSpeedReduction{ get; } + public int SwingSpeedReduction { get; } protected override void OnTick() { diff --git a/Projects/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs b/Projects/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs index fec1d0d80..7233fb514 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/FrenziedWhirlwind.cs @@ -12,7 +12,7 @@ namespace Server.Items { public override int BaseMana => 30; - public static Dictionary Registry{ get; } = new Dictionary(); + public static Dictionary Registry { get; } = new Dictionary(); public override bool CheckSkills(Mobile from) { @@ -28,7 +28,7 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { - if (!Validate(attacker)) //Mana check after check that there are targets + if (!Validate(attacker)) // Mana check after check that there are targets return; ClearCurrentAbility(attacker); @@ -81,10 +81,10 @@ namespace Server.Items public class FrenziedWirlwindTimer : Timer { private readonly double DamagePerTick; - private Mobile m_Attacker; + private readonly Mobile m_Attacker; private double m_DamageRemaining; private double m_DamageToDo; - private Mobile m_Defender; + private readonly Mobile m_Defender; public FrenziedWirlwindTimer(Mobile attacker, Mobile defender, int totalDamage) : base(TimeSpan.Zero, TimeSpan.FromSeconds(0.25), @@ -112,7 +112,7 @@ namespace Server.Items m_DamageToDo += DamagePerTick; if (m_DamageRemaining <= 0 && m_DamageToDo < 1) - m_DamageToDo = 1.0; //Confirm this 'round up' at the end + m_DamageToDo = 1.0; // Confirm this 'round up' at the end int damage = (int)m_DamageToDo; diff --git a/Projects/Scripts/Items/Weapons/Abilities/MortalStrike.cs b/Projects/Scripts/Items/Weapons/Abilities/MortalStrike.cs index 2888acdce..48db510ca 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/MortalStrike.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/MortalStrike.cs @@ -13,7 +13,7 @@ namespace Server.Items public static readonly TimeSpan PlayerDuration = TimeSpan.FromSeconds(6.0); public static readonly TimeSpan NPCDuration = TimeSpan.FromSeconds(12.0); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 30; @@ -61,7 +61,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m, TimeSpan duration) : base(duration) { diff --git a/Projects/Scripts/Items/Weapons/Abilities/MovingShot.cs b/Projects/Scripts/Items/Weapons/Abilities/MovingShot.cs index 9cdbf1d2c..429548843 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/MovingShot.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/MovingShot.cs @@ -15,7 +15,7 @@ namespace Server.Items public override void OnMiss(Mobile attacker, Mobile defender) { - //Validates in OnSwing for accuracy scalar + // Validates in OnSwing for accuracy scalar ClearCurrentAbility(attacker); @@ -24,7 +24,7 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, int damage) { - //Validates in OnSwing for accuracy scalar + // Validates in OnSwing for accuracy scalar ClearCurrentAbility(attacker); diff --git a/Projects/Scripts/Items/Weapons/Abilities/NerveStrike.cs b/Projects/Scripts/Items/Weapons/Abilities/NerveStrike.cs index e83c1448e..ec47b778a 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/NerveStrike.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/NerveStrike.cs @@ -60,7 +60,7 @@ namespace Server.Items { AOS.Damage(defender, attacker, (int)(15.0 * (attacker.Skills.Bushido.Value - 50.0) / 70.0 + Utility.Random(10)), true, 100, - 0, 0, 0, 0); //0-25 + 0, 0, 0, 0); // 0-25 if (!cantpara && (150.0 / 7.0 + 4.0 * attacker.Skills.Bushido.Value / 7.0) / 100.0 > Utility.RandomDouble()) @@ -72,7 +72,7 @@ namespace Server.Items else if (!cantpara) { AOS.Damage(defender, attacker, (int)(15.0 * (attacker.Skills.Bushido.Value - 50.0) / 70.0 + 10), - true, 100, 0, 0, 0, 0); //10-25 + true, 100, 0, 0, 0, 0); // 10-25 defender.Freeze(TimeSpan.FromSeconds(2.0)); Items.ParalyzingBlow.BeginImmunity(defender, Items.ParalyzingBlow.FreezeDelayDuration); } diff --git a/Projects/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs b/Projects/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs index 53a3185cc..6dbcd5126 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/ParalyzingBlow.cs @@ -13,22 +13,22 @@ namespace Server.Items public static readonly TimeSpan FreezeDelayDuration = TimeSpan.FromSeconds(8.0); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 30; // No longer active in pub21: /*public override bool CheckSkills( Mobile from ) { - if ( !base.CheckSkills( from ) ) + if (!base.CheckSkills( from )) return false; - if ( !(from.Weapon is Fists) ) + if (!(from.Weapon is Fists)) return true; Skill skill = from.Skills.Anatomy; - if ( skill?.Base >= 80.0 ) + if (skill?.Base >= 80.0) return true; from.SendLocalizedMessage( 1061811 ); // You lack the required anatomy skill to perform that attack! @@ -56,7 +56,7 @@ namespace Server.Items ClearCurrentAbility(attacker); - if (IsImmune(defender)) //Intentionally going after Mana consumption + if (IsImmune(defender)) // Intentionally going after Mana consumption { attacker.SendLocalizedMessage(1070804); // Your target resists paralysis. defender.SendLocalizedMessage(1070813); // You resist paralysis. @@ -99,7 +99,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m, TimeSpan duration) : base(duration) { diff --git a/Projects/Scripts/Items/Weapons/Abilities/RidingSwipe.cs b/Projects/Scripts/Items/Weapons/Abilities/RidingSwipe.cs index eb5daa97f..ef023f043 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/RidingSwipe.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/RidingSwipe.cs @@ -45,14 +45,14 @@ namespace Server.Items Mobile mount = defender.Mount as Mobile; BaseMount.Dismount(defender); - if (mount != null) //Ethy mounts don't take damage + if (mount != null) // Ethy mounts don't take damage { int amount = 10 + (int)(10.0 * (attacker.Skills.Bushido.Value - 50.0) / 70.0 + 5); AOS.Damage(mount, null, amount, 100, 0, 0, 0, - 0); //The mount just takes damage, there's no flagging as if it was attacking the mount directly + 0); // The mount just takes damage, there's no flagging as if it was attacking the mount directly - //TODO: Mount prevention until mount healed + // TODO: Mount prevention until mount healed } } else @@ -61,7 +61,7 @@ namespace Server.Items AOS.Damage(defender, attacker, amount, 100, 0, 0, 0, 0); - if (Items.ParalyzingBlow.IsImmune(defender)) //Does it still do damage? + if (Items.ParalyzingBlow.IsImmune(defender)) // Does it still do damage? { attacker.SendLocalizedMessage(1070804); // Your target resists paralysis. defender.SendLocalizedMessage(1070813); // You resist paralysis. diff --git a/Projects/Scripts/Items/Weapons/Abilities/TalonStrike.cs b/Projects/Scripts/Items/Weapons/Abilities/TalonStrike.cs index 3d77db0be..a57cf461f 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/TalonStrike.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/TalonStrike.cs @@ -8,7 +8,7 @@ namespace Server.Items /// public class TalonStrike : WeaponAbility { - private static HashSet m_Table = new HashSet(); + private static readonly HashSet m_Table = new HashSet(); public override int BaseMana => 30; public override double DamageScalar => 1.2; @@ -38,7 +38,7 @@ namespace Server.Items defender.FixedParticles(0x373A, 1, 17, 0x26BC, 0x662, 0, EffectLayer.Waist); InternalTimer timer = new InternalTimer(defender, - (int)(10.0 * (attacker.Skills.Ninjitsu.Value - 50.0) / 70.0 + 5)); //5 - 15 damage + (int)(10.0 * (attacker.Skills.Ninjitsu.Value - 50.0) / 70.0 + 5)); // 5 - 15 damage timer.Start(); @@ -50,7 +50,7 @@ namespace Server.Items private readonly double DamagePerTick; private double m_DamageRemaining; private double m_DamageToDo; - private Mobile m_Defender; + private readonly Mobile m_Defender; public InternalTimer(Mobile defender, int totalDamage) : base(TimeSpan.Zero, TimeSpan.FromSeconds(0.25), @@ -76,14 +76,14 @@ namespace Server.Items m_DamageToDo += DamagePerTick; if (m_DamageRemaining <= 0 && m_DamageToDo < 1) - m_DamageToDo = 1.0; //Confirm this 'round up' at the end + m_DamageToDo = 1.0; // Confirm this 'round up' at the end int damage = (int)m_DamageToDo; if (damage > 0) { - //m_Defender.Damage( damage, m_Attacker, false ); - m_Defender.Hits -= damage; //Don't show damage, don't disrupt + // m_Defender.Damage( damage, m_Attacker, false ); + m_Defender.Hits -= damage; // Don't show damage, don't disrupt m_DamageToDo -= damage; } diff --git a/Projects/Scripts/Items/Weapons/Abilities/WeaponAbility.cs b/Projects/Scripts/Items/Weapons/Abilities/WeaponAbility.cs index 09d7a973f..1a8fa2a36 100644 --- a/Projects/Scripts/Items/Weapons/Abilities/WeaponAbility.cs +++ b/Projects/Scripts/Items/Weapons/Abilities/WeaponAbility.cs @@ -12,7 +12,7 @@ namespace Server.Items { public abstract class WeaponAbility { - public static WeaponAbility[] Abilities{ get; } = { + public static WeaponAbility[] Abilities { get; } = { null, new ArmorIgnore(), new BleedAttack(), @@ -81,7 +81,7 @@ namespace Server.Items public static readonly WeaponAbility Disrobe = Abilities[30]; - private static Dictionary m_PlayersTable = new Dictionary(); + private static readonly Dictionary m_PlayersTable = new Dictionary(); public virtual int BaseMana => 0; @@ -90,7 +90,7 @@ namespace Server.Items public virtual bool RequiresSE => false; - public static Dictionary Table{ get; } = new Dictionary(); + public static Dictionary Table { get; } = new Dictionary(); public virtual bool ValidatesDuringHit => true; @@ -254,8 +254,6 @@ namespace Server.Items return false; } - #region Dueling - string option = null; if (this is ArmorIgnore) @@ -305,18 +303,15 @@ namespace Server.Items else if (this is ArmorPierce) option = "Armor Pierce"; - if (option != null && !DuelContext.AllowSpecialAbility(from, option, true)) return false; - #endregion - return CheckSkills(from) && CheckMana(from, false); } public static bool IsWeaponAbility(Mobile m, WeaponAbility a) => - a == null || !m.Player || m.Weapon is BaseWeapon weapon && - (weapon.PrimaryAbility == a || weapon.SecondaryAbility == a); + a == null || !m.Player || (m.Weapon is BaseWeapon weapon && + (weapon.PrimaryAbility == a || weapon.SecondaryAbility == a)); public static WeaponAbility GetCurrentAbility(Mobile m) { @@ -425,7 +420,7 @@ namespace Server.Items private class WeaponAbilityTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public WeaponAbilityTimer(Mobile from) : base(TimeSpan.FromSeconds(3.0)) { @@ -444,7 +439,7 @@ namespace Server.Items { public WeaponAbilityContext(Timer timer) => Timer = timer; - public Timer Timer{ get; } + public Timer Timer { get; } } } } diff --git a/Projects/Scripts/Items/Weapons/Artifacts/BladeOfTheRighteous.cs b/Projects/Scripts/Items/Weapons/Artifacts/BladeOfTheRighteous.cs index e59d159bc..be9e641ff 100644 --- a/Projects/Scripts/Items/Weapons/Artifacts/BladeOfTheRighteous.cs +++ b/Projects/Scripts/Items/Weapons/Artifacts/BladeOfTheRighteous.cs @@ -6,7 +6,7 @@ namespace Server.Items public BladeOfTheRighteous() { Hue = 0x47E; - //Slayer = SlayerName.DaemonDismissal; + // Slayer = SlayerName.DaemonDismissal; Slayer = SlayerName.Exorcism; WeaponAttributes.HitLeechHits = 50; WeaponAttributes.UseBestSkill = 1; diff --git a/Projects/Scripts/Items/Weapons/Artifacts/TheDryadBow.cs b/Projects/Scripts/Items/Weapons/Artifacts/TheDryadBow.cs index 9e8bfbfa4..de165d560 100644 --- a/Projects/Scripts/Items/Weapons/Artifacts/TheDryadBow.cs +++ b/Projects/Scripts/Items/Weapons/Artifacts/TheDryadBow.cs @@ -2,7 +2,7 @@ namespace Server.Items { public class TheDryadBow : Bow { - private static SkillName[] m_PossibleBonusSkills = + private static readonly SkillName[] m_PossibleBonusSkills = { SkillName.Archery, SkillName.Healing, diff --git a/Projects/Scripts/Items/Weapons/Axes/BaseAxe.cs b/Projects/Scripts/Items/Weapons/Axes/BaseAxe.cs index 724aed4e6..d1543676d 100644 --- a/Projects/Scripts/Items/Weapons/Axes/BaseAxe.cs +++ b/Projects/Scripts/Items/Weapons/Axes/BaseAxe.cs @@ -136,22 +136,22 @@ namespace Server.Items switch (version) { case 2: - { - m_ShowUsesRemaining = reader.ReadBool(); - goto case 1; - } + { + m_ShowUsesRemaining = reader.ReadBool(); + goto case 1; + } case 1: - { - m_UsesRemaining = reader.ReadInt(); - goto case 0; - } + { + m_UsesRemaining = reader.ReadInt(); + goto case 0; + } case 0: - { - if (m_UsesRemaining < 1) - m_UsesRemaining = 150; + { + if (m_UsesRemaining < 1) + m_UsesRemaining = 150; - break; - } + break; + } } } diff --git a/Projects/Scripts/Items/Weapons/BaseMeleeWeapon.cs b/Projects/Scripts/Items/Weapons/BaseMeleeWeapon.cs index 589a142ad..75704f903 100644 --- a/Projects/Scripts/Items/Weapons/BaseMeleeWeapon.cs +++ b/Projects/Scripts/Items/Weapons/BaseMeleeWeapon.cs @@ -51,14 +51,16 @@ namespace Server.Items return damage; } + // ReSharper disable once RedundantOverriddenMember public override void Serialize(IGenericWriter writer) { base.Serialize(writer); } + // ReSharper disable once RedundantOverriddenMember public override void Deserialize(IGenericReader reader) { base.Deserialize(reader); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Weapons/BaseWeapon.cs b/Projects/Scripts/Items/Weapons/BaseWeapon.cs index c938c653b..98ef0c5e5 100644 --- a/Projects/Scripts/Items/Weapons/BaseWeapon.cs +++ b/Projects/Scripts/Items/Weapons/BaseWeapon.cs @@ -19,8 +19,8 @@ namespace Server.Items { public interface ISlayer { - SlayerName Slayer{ get; set; } - SlayerName Slayer2{ get; set; } + SlayerName Slayer { get; set; } + SlayerName Slayer2 { get; set; } } public abstract class BaseWeapon : Item, IWeapon, IFactionItem, ICraftable, ISlayer, IDurability @@ -71,11 +71,11 @@ namespace Server.Items } public virtual Race RequiredRace => - null; //On OSI, there are no weapons with race requirements, this is for custom stuff + null; // On OSI, there are no weapons with race requirements, this is for custom stuff public virtual bool UseSkillMod => !Core.AOS; - public static bool InDoubleStrike{ get; set; } + public static bool InDoubleStrike { get; set; } public virtual int VirtualDamageBonus => 0; @@ -93,9 +93,7 @@ namespace Server.Items public virtual int ArtifactRarity => 0; - public static BaseWeapon Fists{ get; set; } - - #region ICraftable Members + public static BaseWeapon Fists { get; set; } public int OnCraft(int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue) @@ -155,67 +153,67 @@ namespace Server.Items switch (thisResource) { case CraftResource.DullCopper: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Durable; - AccuracyLevel = WeaponAccuracyLevel.Accurate; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Durable; + AccuracyLevel = WeaponAccuracyLevel.Accurate; + break; + } case CraftResource.ShadowIron: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Durable; - DamageLevel = WeaponDamageLevel.Ruin; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Durable; + DamageLevel = WeaponDamageLevel.Ruin; + break; + } case CraftResource.Copper: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Fortified; - DamageLevel = WeaponDamageLevel.Ruin; - AccuracyLevel = WeaponAccuracyLevel.Surpassingly; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Fortified; + DamageLevel = WeaponDamageLevel.Ruin; + AccuracyLevel = WeaponAccuracyLevel.Surpassingly; + break; + } case CraftResource.Bronze: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Fortified; - DamageLevel = WeaponDamageLevel.Might; - AccuracyLevel = WeaponAccuracyLevel.Surpassingly; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Fortified; + DamageLevel = WeaponDamageLevel.Might; + AccuracyLevel = WeaponAccuracyLevel.Surpassingly; + break; + } case CraftResource.Gold: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Indestructible; - DamageLevel = WeaponDamageLevel.Force; - AccuracyLevel = WeaponAccuracyLevel.Eminently; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Indestructible; + DamageLevel = WeaponDamageLevel.Force; + AccuracyLevel = WeaponAccuracyLevel.Eminently; + break; + } case CraftResource.Agapite: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Indestructible; - DamageLevel = WeaponDamageLevel.Power; - AccuracyLevel = WeaponAccuracyLevel.Eminently; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Indestructible; + DamageLevel = WeaponDamageLevel.Power; + AccuracyLevel = WeaponAccuracyLevel.Eminently; + break; + } case CraftResource.Verite: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Indestructible; - DamageLevel = WeaponDamageLevel.Power; - AccuracyLevel = WeaponAccuracyLevel.Exceedingly; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Indestructible; + DamageLevel = WeaponDamageLevel.Power; + AccuracyLevel = WeaponAccuracyLevel.Exceedingly; + break; + } case CraftResource.Valorite: - { - Identified = true; - DurabilityLevel = WeaponDurabilityLevel.Indestructible; - DamageLevel = WeaponDamageLevel.Vanq; - AccuracyLevel = WeaponAccuracyLevel.Supremely; - break; - } + { + Identified = true; + DurabilityLevel = WeaponDurabilityLevel.Indestructible; + DamageLevel = WeaponDamageLevel.Vanq; + AccuracyLevel = WeaponAccuracyLevel.Supremely; + break; + } } } } @@ -223,8 +221,6 @@ namespace Server.Items return quality; } - #endregion - public virtual void UnscaleDurability() { int scale = 100 + GetDurabilityBonus(); @@ -781,10 +777,8 @@ namespace Server.Items if (canSwing) canSwing = !(attacker is PlayerMobile p) || p.PeacedUntil <= DateTime.UtcNow; } - #region Dueling if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false) canSwing = false; - #endregion if (canSwing && attacker.HarmfulCheck(defender)) { @@ -1017,7 +1011,7 @@ namespace Server.Items if (attacker.Player || defender.Player) return 0; - if (!(attacker is BaseCreature bc) || bc.PackInstinct == PackInstinct.None || !bc.Controlled && !bc.Summoned) + if (!(attacker is BaseCreature bc) || bc.PackInstinct == PackInstinct.None || (!bc.Controlled && !bc.Summoned)) return 0; Mobile master = bc.ControlMaster ?? bc.SummonMaster; @@ -1027,7 +1021,7 @@ namespace Server.Items IPooledEnumerable eable = defender.GetMobilesInRange(1); int inPack = 1 + eable.Where(m => m != attacker && (m.PackInstinct & bc.PackInstinct) != 0 && (m.Controlled || m.Summoned)) - .Count(m => master == (m.ControlMaster ?? m.SummonMaster) && m.Combatant == defender); + .Count(m => master == (m.ControlMaster ?? m.SummonMaster) && m.Combatant == defender); eable.Free(); @@ -1068,8 +1062,6 @@ namespace Server.Items int damage = ComputeDamage(attacker, defender); - #region Damage Multipliers - /* * The following damage bonuses multiply damage by a factor. * Capped at x3 (300%). @@ -1146,8 +1138,6 @@ namespace Server.Items damage = AOS.Scale(damage, 100 + percentageBonus); - #endregion - BaseCreature bcAtt = attacker as BaseCreature; BaseCreature bcDef = defender as BaseCreature; @@ -1159,8 +1149,8 @@ namespace Server.Items if (!Core.AOS && damage < 1) damage = 1; else if (Core.AOS && damage == 0) // parried - if (a?.Validate(attacker) == true /*&& a.CheckMana( attacker, true )*/ - ) // Parried special moves have no mana cost + if (a?.Validate(attacker) == true) /*&& a.CheckMana( attacker, true )*/ + // Parried special moves have no mana cost { a = null; WeaponAbility.ClearCurrentAbility(attacker); @@ -1292,7 +1282,7 @@ namespace Server.Items attacker.PlaySound(0x44D); } - if (m_MaxHits > 0 && (MaxRange <= 1 && (defender is Slime || defender is AcidElemental) || + if (m_MaxHits > 0 && ((MaxRange <= 1 && (defender is Slime || defender is AcidElemental)) || Utility.RandomDouble() < .04)) // Stratics says 50% chance, seems more like 4%.. { if (MaxRange <= 1 && (defender is Slime || defender is AcidElemental)) @@ -1420,12 +1410,11 @@ namespace Server.Items public virtual double GetAosDamage(Mobile attacker, int bonus, uint dice, uint sides) { int damage = Utility.Dice(dice, sides, bonus) * 100; - int damageBonus = 0; // Inscription bonus int inscribeSkill = attacker.Skills.Inscribe.Fixed; - damageBonus += inscribeSkill / 200; + var damageBonus = inscribeSkill / 200; if (inscribeSkill >= 1000) damageBonus += 5; @@ -1711,8 +1700,6 @@ namespace Server.Items attacker.CheckSkill(SkillName.Lumberjacking, 0.0, 100.0); // Passively check Lumberjacking for gain } - #region Physical bonuses - /* * These are the bonuses given by the physical characteristics of the mobile. * No caps apply. @@ -1725,10 +1712,6 @@ namespace Server.Items if (Type != WeaponType.Axe) lumberBonus = 0.0; - #endregion - - #region Modifiers - /* * The following are damage modifiers whose effect shows on the status bar. * Capped at 100% total. @@ -1758,8 +1741,6 @@ namespace Server.Items if (damageBonus > 100) damageBonus = 100; - #endregion - double totalBonus = strengthBonus + anatomyBonus + tacticsBonus + lumberBonus + (GetDamageBonus() + damageBonus) / 100.0; @@ -1788,7 +1769,6 @@ namespace Server.Items */ damage += damage * ((attacker.Skills.Tactics.Value - 50.0) / 100.0); - /* Compute strength modifier * : 1% bonus for every 5 strength */ @@ -1865,23 +1845,23 @@ namespace Server.Items { case BodyType.Sea: case BodyType.Animal: - { - action = 7; - frames = 5; - break; - } + { + action = 7; + frames = 5; + break; + } case BodyType.Monster: - { - action = 10; - frames = 4; - break; - } + { + action = 10; + frames = 4; + break; + } case BodyType.Human: - { - action = 20; - frames = 5; - break; - } + { + action = 20; + frames = 5; + break; + } default: return; } @@ -1899,44 +1879,44 @@ namespace Server.Items { case BodyType.Sea: case BodyType.Animal: - { - action = Utility.Random(5, 2); - break; - } - case BodyType.Monster: - { - switch (Animation) { - default: - action = Utility.Random(4, 3); - break; - case WeaponAnimation.ShootBow: return; // 7 - case WeaponAnimation.ShootXBow: return; // 8 + action = Utility.Random(5, 2); + break; } - - break; - } - case BodyType.Human: - { - if (!from.Mounted) - action = (int)Animation; - else - action = Animation switch + case BodyType.Monster: + { + switch (Animation) { - WeaponAnimation.Wrestle => 26, - WeaponAnimation.Bash1H => 26, - WeaponAnimation.Pierce1H => 26, - WeaponAnimation.Slash1H => 26, - WeaponAnimation.Bash2H => 29, - WeaponAnimation.Pierce2H => 29, - WeaponAnimation.Slash2H => 29, - WeaponAnimation.ShootBow => 27, - WeaponAnimation.ShootXBow => 28, - _ => 26 - }; + default: + action = Utility.Random(4, 3); + break; + case WeaponAnimation.ShootBow: return; // 7 + case WeaponAnimation.ShootXBow: return; // 8 + } - break; - } + break; + } + case BodyType.Human: + { + if (!from.Mounted) + action = (int)Animation; + else + action = Animation switch + { + WeaponAnimation.Wrestle => 26, + WeaponAnimation.Bash1H => 26, + WeaponAnimation.Pierce1H => 26, + WeaponAnimation.Slash1H => 26, + WeaponAnimation.Bash2H => 29, + WeaponAnimation.Pierce2H => 29, + WeaponAnimation.Slash2H => 29, + WeaponAnimation.ShootBow => 27, + WeaponAnimation.ShootXBow => 28, + _ => 26 + }; + + break; + } default: return; } @@ -1948,7 +1928,7 @@ namespace Server.Items public int GetElementalDamageHue() { GetDamageTypes(null, out _, out int fire, out int cold, out int pois, out int nrgy, out _, out _); - //Order is Cold, Energy, Fire, Poison, Physical left + // Order is Cold, Energy, Fire, Poison, Physical left int currentMax = 50; int hue = 0; @@ -2053,13 +2033,9 @@ namespace Server.Items if (m_Crafter != null) list.Add(1050043, m_Crafter.Name); // crafted by ~1_NAME~ - #region Factions - if (m_FactionState != null) list.Add(1041350); // faction item - #endregion - SkillBonuses?.GetProperties(list); if (m_Quality == WeaponQuality.Exceptional) @@ -2091,8 +2067,7 @@ namespace Server.Items list.Add(entry.Title); } - - base.AddResistanceProperties(list); + this.AddResistanceProperties(list); int prop; @@ -2313,13 +2288,9 @@ namespace Server.Items attrs.Add(new EquipInfoAttribute(1049643)); // cursed } - #region Factions - if (m_FactionState != null) attrs.Add(new EquipInfoAttribute(1041350)); // faction item - #endregion - if (m_Quality == WeaponQuality.Exceptional) attrs.Add(new EquipInfoAttribute(1018305 - (int)m_Quality)); @@ -2380,7 +2351,7 @@ namespace Server.Items private class ResetEquipTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public ResetEquipTimer(Mobile m, TimeSpan duration) : base(duration) => m_Mobile = m; @@ -2390,8 +2361,6 @@ namespace Server.Items } } - #region Factions - private FactionItem m_FactionState; public FactionItem FactionItemState @@ -2408,8 +2377,6 @@ namespace Server.Items } } - #endregion - /* Weapon internals work differently now (Mar 13 2003) * * The attributes defined below default to -1. @@ -2426,8 +2393,6 @@ namespace Server.Items * - MaxRange */ - #region Var declarations - // Instance values. These values are unique to each weapon. private WeaponDamageLevel m_DamageLevel; private WeaponAccuracyLevel m_AccuracyLevel; @@ -2454,10 +2419,6 @@ namespace Server.Items private WeaponType m_Type; private WeaponAnimation m_Animation; - #endregion - - #region Virtual Properties - public virtual WeaponAbility PrimaryAbility => null; public virtual WeaponAbility SecondaryAbility => null; @@ -2508,27 +2469,23 @@ namespace Server.Items public virtual SkillName AccuracySkill => SkillName.Tactics; - #endregion - - #region Getters & Setters + [CommandProperty(AccessLevel.GameMaster)] + public AosAttributes Attributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosAttributes Attributes{ get; private set; } + public AosWeaponAttributes WeaponAttributes { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosWeaponAttributes WeaponAttributes{ get; private set; } + public AosSkillBonuses SkillBonuses { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosSkillBonuses SkillBonuses{ get; private set; } + public AosElementAttributes AosElementDamages { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public AosElementAttributes AosElementDamages{ get; private set; } + public bool Cursed { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool Cursed{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public bool Consecrated{ get; set; } + public bool Consecrated { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Identified @@ -2677,7 +2634,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool PlayerConstructed{ get; set; } + public bool PlayerConstructed { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int MaxRange @@ -2832,10 +2789,6 @@ namespace Server.Items } } - #endregion - - #region Sounds - public virtual int GetHitAttackSound(Mobile attacker, Mobile defender) { int sound = attacker.GetAttackSound(); @@ -2852,10 +2805,6 @@ namespace Server.Items public virtual int GetMissDefendSound(Mobile attacker, Mobile defender) => -1; - #endregion - - #region Do - public virtual void DoMagicArrow(Mobile attacker, Mobile defender) { if (!attacker.CanBeHarmful(defender, false)) @@ -3007,10 +2956,6 @@ namespace Server.Items } } - #endregion - - #region Serialization/Deserialization - private static void SetSaveFlag(ref SaveFlag flags, SaveFlag toSet, bool setIf) { if (setIf) @@ -3201,283 +3146,283 @@ namespace Server.Items case 7: case 6: case 5: - { - SaveFlag flags = (SaveFlag)reader.ReadInt(); - - if (GetSaveFlag(flags, SaveFlag.DamageLevel)) { - m_DamageLevel = (WeaponDamageLevel)reader.ReadInt(); + SaveFlag flags = (SaveFlag)reader.ReadInt(); - if (m_DamageLevel > WeaponDamageLevel.Vanq) - m_DamageLevel = WeaponDamageLevel.Ruin; + if (GetSaveFlag(flags, SaveFlag.DamageLevel)) + { + m_DamageLevel = (WeaponDamageLevel)reader.ReadInt(); + + if (m_DamageLevel > WeaponDamageLevel.Vanq) + m_DamageLevel = WeaponDamageLevel.Ruin; + } + + if (GetSaveFlag(flags, SaveFlag.AccuracyLevel)) + { + m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt(); + + if (m_AccuracyLevel > WeaponAccuracyLevel.Supremely) + m_AccuracyLevel = WeaponAccuracyLevel.Accurate; + } + + if (GetSaveFlag(flags, SaveFlag.DurabilityLevel)) + { + m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt(); + + if (m_DurabilityLevel > WeaponDurabilityLevel.Indestructible) + m_DurabilityLevel = WeaponDurabilityLevel.Durable; + } + + if (GetSaveFlag(flags, SaveFlag.Quality)) + m_Quality = (WeaponQuality)reader.ReadInt(); + else + m_Quality = WeaponQuality.Regular; + + if (GetSaveFlag(flags, SaveFlag.Hits)) + m_Hits = reader.ReadInt(); + + if (GetSaveFlag(flags, SaveFlag.MaxHits)) + m_MaxHits = reader.ReadInt(); + + if (GetSaveFlag(flags, SaveFlag.Slayer)) + m_Slayer = (SlayerName)reader.ReadInt(); + + if (GetSaveFlag(flags, SaveFlag.Poison)) + m_Poison = Poison.Deserialize(reader); + + if (GetSaveFlag(flags, SaveFlag.PoisonCharges)) + m_PoisonCharges = reader.ReadInt(); + + if (GetSaveFlag(flags, SaveFlag.Crafter)) + m_Crafter = reader.ReadMobile(); + + if (GetSaveFlag(flags, SaveFlag.Identified)) + m_Identified = version >= 6 || reader.ReadBool(); + + if (GetSaveFlag(flags, SaveFlag.StrReq)) + m_StrReq = reader.ReadInt(); + else + m_StrReq = -1; + + if (GetSaveFlag(flags, SaveFlag.DexReq)) + m_DexReq = reader.ReadInt(); + else + m_DexReq = -1; + + if (GetSaveFlag(flags, SaveFlag.IntReq)) + m_IntReq = reader.ReadInt(); + else + m_IntReq = -1; + + if (GetSaveFlag(flags, SaveFlag.MinDamage)) + m_MinDamage = reader.ReadInt(); + else + m_MinDamage = -1; + + if (GetSaveFlag(flags, SaveFlag.MaxDamage)) + m_MaxDamage = reader.ReadInt(); + else + m_MaxDamage = -1; + + if (GetSaveFlag(flags, SaveFlag.HitSound)) + m_HitSound = reader.ReadInt(); + else + m_HitSound = -1; + + if (GetSaveFlag(flags, SaveFlag.MissSound)) + m_MissSound = reader.ReadInt(); + else + m_MissSound = -1; + + if (GetSaveFlag(flags, SaveFlag.Speed)) + { + if (version < 9) + m_Speed = reader.ReadInt(); + else + m_Speed = reader.ReadFloat(); + } + else + { + m_Speed = -1; + } + + if (GetSaveFlag(flags, SaveFlag.MaxRange)) + m_MaxRange = reader.ReadInt(); + else + m_MaxRange = -1; + + if (GetSaveFlag(flags, SaveFlag.Skill)) + m_Skill = (SkillName)reader.ReadInt(); + else + m_Skill = (SkillName)(-1); + + if (GetSaveFlag(flags, SaveFlag.Type)) + m_Type = (WeaponType)reader.ReadInt(); + else + m_Type = (WeaponType)(-1); + + if (GetSaveFlag(flags, SaveFlag.Animation)) + m_Animation = (WeaponAnimation)reader.ReadInt(); + else + m_Animation = (WeaponAnimation)(-1); + + if (GetSaveFlag(flags, SaveFlag.Resource)) + m_Resource = (CraftResource)reader.ReadInt(); + else + m_Resource = CraftResource.Iron; + + if (GetSaveFlag(flags, SaveFlag.xAttributes)) + Attributes = new AosAttributes(this, reader); + else + Attributes = new AosAttributes(this); + + if (GetSaveFlag(flags, SaveFlag.xWeaponAttributes)) + WeaponAttributes = new AosWeaponAttributes(this, reader); + else + WeaponAttributes = new AosWeaponAttributes(this); + + if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && parentMobile != null) + { + m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5); + parentMobile.AddSkillMod(m_SkillMod); + } + + if (version < 7 && WeaponAttributes.MageWeapon != 0) + WeaponAttributes.MageWeapon = 30 - WeaponAttributes.MageWeapon; + + if (Core.AOS && WeaponAttributes.MageWeapon != 0 && WeaponAttributes.MageWeapon != 30 && + parentMobile != null) + { + m_MageMod = new DefaultSkillMod(SkillName.Magery, true, -30 + WeaponAttributes.MageWeapon); + parentMobile.AddSkillMod(m_MageMod); + } + + if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) + PlayerConstructed = true; + + if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) + SkillBonuses = new AosSkillBonuses(this, reader); + else + SkillBonuses = new AosSkillBonuses(this); + + if (GetSaveFlag(flags, SaveFlag.Slayer2)) + m_Slayer2 = (SlayerName)reader.ReadInt(); + + if (GetSaveFlag(flags, SaveFlag.ElementalDamages)) + AosElementDamages = new AosElementAttributes(this, reader); + else + AosElementDamages = new AosElementAttributes(this); + + if (GetSaveFlag(flags, SaveFlag.EngravedText)) + m_EngravedText = reader.ReadString(); + + break; } - - if (GetSaveFlag(flags, SaveFlag.AccuracyLevel)) + case 4: { - m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt(); - - if (m_AccuracyLevel > WeaponAccuracyLevel.Supremely) - m_AccuracyLevel = WeaponAccuracyLevel.Accurate; - } - - if (GetSaveFlag(flags, SaveFlag.DurabilityLevel)) - { - m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt(); - - if (m_DurabilityLevel > WeaponDurabilityLevel.Indestructible) - m_DurabilityLevel = WeaponDurabilityLevel.Durable; - } - - if (GetSaveFlag(flags, SaveFlag.Quality)) - m_Quality = (WeaponQuality)reader.ReadInt(); - else - m_Quality = WeaponQuality.Regular; - - if (GetSaveFlag(flags, SaveFlag.Hits)) - m_Hits = reader.ReadInt(); - - if (GetSaveFlag(flags, SaveFlag.MaxHits)) - m_MaxHits = reader.ReadInt(); - - if (GetSaveFlag(flags, SaveFlag.Slayer)) m_Slayer = (SlayerName)reader.ReadInt(); - if (GetSaveFlag(flags, SaveFlag.Poison)) - m_Poison = Poison.Deserialize(reader); + goto case 3; + } + case 3: + { + m_StrReq = reader.ReadInt(); + m_DexReq = reader.ReadInt(); + m_IntReq = reader.ReadInt(); - if (GetSaveFlag(flags, SaveFlag.PoisonCharges)) - m_PoisonCharges = reader.ReadInt(); + goto case 2; + } + case 2: + { + m_Identified = reader.ReadBool(); + + goto case 1; + } + case 1: + { + m_MaxRange = reader.ReadInt(); + + goto case 0; + } + case 0: + { + if (version == 0) + m_MaxRange = 1; // default + + if (version < 5) + { + m_Resource = CraftResource.Iron; + Attributes = new AosAttributes(this); + WeaponAttributes = new AosWeaponAttributes(this); + AosElementDamages = new AosElementAttributes(this); + SkillBonuses = new AosSkillBonuses(this); + } + + m_MinDamage = reader.ReadInt(); + m_MaxDamage = reader.ReadInt(); + + m_Speed = reader.ReadInt(); + + m_HitSound = reader.ReadInt(); + m_MissSound = reader.ReadInt(); + + m_Skill = (SkillName)reader.ReadInt(); + m_Type = (WeaponType)reader.ReadInt(); + m_Animation = (WeaponAnimation)reader.ReadInt(); + m_DamageLevel = (WeaponDamageLevel)reader.ReadInt(); + m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt(); + m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt(); + m_Quality = (WeaponQuality)reader.ReadInt(); - if (GetSaveFlag(flags, SaveFlag.Crafter)) m_Crafter = reader.ReadMobile(); - if (GetSaveFlag(flags, SaveFlag.Identified)) - m_Identified = version >= 6 || reader.ReadBool(); + m_Poison = Poison.Deserialize(reader); + m_PoisonCharges = reader.ReadInt(); - if (GetSaveFlag(flags, SaveFlag.StrReq)) - m_StrReq = reader.ReadInt(); - else - m_StrReq = -1; + if (m_StrReq == OldStrengthReq) + m_StrReq = -1; - if (GetSaveFlag(flags, SaveFlag.DexReq)) - m_DexReq = reader.ReadInt(); - else - m_DexReq = -1; + if (m_DexReq == OldDexterityReq) + m_DexReq = -1; - if (GetSaveFlag(flags, SaveFlag.IntReq)) - m_IntReq = reader.ReadInt(); - else - m_IntReq = -1; + if (m_IntReq == OldIntelligenceReq) + m_IntReq = -1; - if (GetSaveFlag(flags, SaveFlag.MinDamage)) - m_MinDamage = reader.ReadInt(); - else - m_MinDamage = -1; + if (m_MinDamage == OldMinDamage) + m_MinDamage = -1; - if (GetSaveFlag(flags, SaveFlag.MaxDamage)) - m_MaxDamage = reader.ReadInt(); - else - m_MaxDamage = -1; + if (m_MaxDamage == OldMaxDamage) + m_MaxDamage = -1; - if (GetSaveFlag(flags, SaveFlag.HitSound)) - m_HitSound = reader.ReadInt(); - else - m_HitSound = -1; + if (m_HitSound == OldHitSound) + m_HitSound = -1; - if (GetSaveFlag(flags, SaveFlag.MissSound)) - m_MissSound = reader.ReadInt(); - else - m_MissSound = -1; + if (m_MissSound == OldMissSound) + m_MissSound = -1; - if (GetSaveFlag(flags, SaveFlag.Speed)) - { - if (version < 9) - m_Speed = reader.ReadInt(); - else - m_Speed = reader.ReadFloat(); + if (m_Speed == OldSpeed) + m_Speed = -1; + + if (m_MaxRange == OldMaxRange) + m_MaxRange = -1; + + if (m_Skill == OldSkill) + m_Skill = (SkillName)(-1); + + if (m_Type == OldType) + m_Type = (WeaponType)(-1); + + if (m_Animation == OldAnimation) + m_Animation = (WeaponAnimation)(-1); + + if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && parentMobile != null) + { + m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5); + parentMobile.AddSkillMod(m_SkillMod); + } + + break; } - else - { - m_Speed = -1; - } - - if (GetSaveFlag(flags, SaveFlag.MaxRange)) - m_MaxRange = reader.ReadInt(); - else - m_MaxRange = -1; - - if (GetSaveFlag(flags, SaveFlag.Skill)) - m_Skill = (SkillName)reader.ReadInt(); - else - m_Skill = (SkillName)(-1); - - if (GetSaveFlag(flags, SaveFlag.Type)) - m_Type = (WeaponType)reader.ReadInt(); - else - m_Type = (WeaponType)(-1); - - if (GetSaveFlag(flags, SaveFlag.Animation)) - m_Animation = (WeaponAnimation)reader.ReadInt(); - else - m_Animation = (WeaponAnimation)(-1); - - if (GetSaveFlag(flags, SaveFlag.Resource)) - m_Resource = (CraftResource)reader.ReadInt(); - else - m_Resource = CraftResource.Iron; - - if (GetSaveFlag(flags, SaveFlag.xAttributes)) - Attributes = new AosAttributes(this, reader); - else - Attributes = new AosAttributes(this); - - if (GetSaveFlag(flags, SaveFlag.xWeaponAttributes)) - WeaponAttributes = new AosWeaponAttributes(this, reader); - else - WeaponAttributes = new AosWeaponAttributes(this); - - if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && parentMobile != null) - { - m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5); - parentMobile.AddSkillMod(m_SkillMod); - } - - if (version < 7 && WeaponAttributes.MageWeapon != 0) - WeaponAttributes.MageWeapon = 30 - WeaponAttributes.MageWeapon; - - if (Core.AOS && WeaponAttributes.MageWeapon != 0 && WeaponAttributes.MageWeapon != 30 && - parentMobile != null) - { - m_MageMod = new DefaultSkillMod(SkillName.Magery, true, -30 + WeaponAttributes.MageWeapon); - parentMobile.AddSkillMod(m_MageMod); - } - - if (GetSaveFlag(flags, SaveFlag.PlayerConstructed)) - PlayerConstructed = true; - - if (GetSaveFlag(flags, SaveFlag.SkillBonuses)) - SkillBonuses = new AosSkillBonuses(this, reader); - else - SkillBonuses = new AosSkillBonuses(this); - - if (GetSaveFlag(flags, SaveFlag.Slayer2)) - m_Slayer2 = (SlayerName)reader.ReadInt(); - - if (GetSaveFlag(flags, SaveFlag.ElementalDamages)) - AosElementDamages = new AosElementAttributes(this, reader); - else - AosElementDamages = new AosElementAttributes(this); - - if (GetSaveFlag(flags, SaveFlag.EngravedText)) - m_EngravedText = reader.ReadString(); - - break; - } - case 4: - { - m_Slayer = (SlayerName)reader.ReadInt(); - - goto case 3; - } - case 3: - { - m_StrReq = reader.ReadInt(); - m_DexReq = reader.ReadInt(); - m_IntReq = reader.ReadInt(); - - goto case 2; - } - case 2: - { - m_Identified = reader.ReadBool(); - - goto case 1; - } - case 1: - { - m_MaxRange = reader.ReadInt(); - - goto case 0; - } - case 0: - { - if (version == 0) - m_MaxRange = 1; // default - - if (version < 5) - { - m_Resource = CraftResource.Iron; - Attributes = new AosAttributes(this); - WeaponAttributes = new AosWeaponAttributes(this); - AosElementDamages = new AosElementAttributes(this); - SkillBonuses = new AosSkillBonuses(this); - } - - m_MinDamage = reader.ReadInt(); - m_MaxDamage = reader.ReadInt(); - - m_Speed = reader.ReadInt(); - - m_HitSound = reader.ReadInt(); - m_MissSound = reader.ReadInt(); - - m_Skill = (SkillName)reader.ReadInt(); - m_Type = (WeaponType)reader.ReadInt(); - m_Animation = (WeaponAnimation)reader.ReadInt(); - m_DamageLevel = (WeaponDamageLevel)reader.ReadInt(); - m_AccuracyLevel = (WeaponAccuracyLevel)reader.ReadInt(); - m_DurabilityLevel = (WeaponDurabilityLevel)reader.ReadInt(); - m_Quality = (WeaponQuality)reader.ReadInt(); - - m_Crafter = reader.ReadMobile(); - - m_Poison = Poison.Deserialize(reader); - m_PoisonCharges = reader.ReadInt(); - - if (m_StrReq == OldStrengthReq) - m_StrReq = -1; - - if (m_DexReq == OldDexterityReq) - m_DexReq = -1; - - if (m_IntReq == OldIntelligenceReq) - m_IntReq = -1; - - if (m_MinDamage == OldMinDamage) - m_MinDamage = -1; - - if (m_MaxDamage == OldMaxDamage) - m_MaxDamage = -1; - - if (m_HitSound == OldHitSound) - m_HitSound = -1; - - if (m_MissSound == OldMissSound) - m_MissSound = -1; - - if (m_Speed == OldSpeed) - m_Speed = -1; - - if (m_MaxRange == OldMaxRange) - m_MaxRange = -1; - - if (m_Skill == OldSkill) - m_Skill = (SkillName)(-1); - - if (m_Type == OldType) - m_Type = (WeaponType)(-1); - - if (m_Animation == OldAnimation) - m_Animation = (WeaponAnimation)(-1); - - if (UseSkillMod && m_AccuracyLevel != WeaponAccuracyLevel.Regular && parentMobile != null) - { - m_SkillMod = new DefaultSkillMod(AccuracySkill, true, (int)m_AccuracyLevel * 5); - parentMobile.AddSkillMod(m_SkillMod); - } - - break; - } } if (Core.AOS && parentMobile != null) @@ -3508,8 +3453,6 @@ namespace Server.Items if (version < 6) PlayerConstructed = true; // we don't know, so, assume it's crafted } - - #endregion } public enum CheckSlayerResult diff --git a/Projects/Scripts/Items/Weapons/Fists.cs b/Projects/Scripts/Items/Weapons/Fists.cs index c04bb0a74..a18c27929 100644 --- a/Projects/Scripts/Items/Weapons/Fists.cs +++ b/Projects/Scripts/Items/Weapons/Fists.cs @@ -221,13 +221,9 @@ namespace Server.Items if (Core.AOS) return; - #region Dueling - if (!DuelContext.AllowSpecialAbility(m, "Disarm", true)) return; - #endregion - double armsValue = m.Skills.ArmsLore.Value; double wresValue = m.Skills.Wrestling.Value; @@ -254,13 +250,9 @@ namespace Server.Items if (Core.AOS) return; - #region Dueling - if (!DuelContext.AllowSpecialAbility(m, "Stun", true)) return; - #endregion - double anatValue = m.Skills.Anatomy.Value; double wresValue = m.Skills.Wrestling.Value; @@ -289,7 +281,7 @@ namespace Server.Items private class MoveDelayTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public MoveDelayTimer(Mobile m) : base(TimeSpan.FromSeconds(10.0)) { diff --git a/Projects/Scripts/Items/Weapons/HitLower.cs b/Projects/Scripts/Items/Weapons/HitLower.cs index fddfaac65..fd3e4f924 100644 --- a/Projects/Scripts/Items/Weapons/HitLower.cs +++ b/Projects/Scripts/Items/Weapons/HitLower.cs @@ -8,8 +8,8 @@ namespace Server.Items public static readonly TimeSpan AttackEffectDuration = TimeSpan.FromSeconds(10.0); public static readonly TimeSpan DefenseEffectDuration = TimeSpan.FromSeconds(8.0); - private static HashSet m_AttackTable = new HashSet(); - private static HashSet m_DefenseTable = new HashSet(); + private static readonly HashSet m_AttackTable = new HashSet(); + private static readonly HashSet m_DefenseTable = new HashSet(); public static bool IsUnderAttackEffect(Mobile m) => m_AttackTable.Contains(m); @@ -53,7 +53,7 @@ namespace Server.Items private class AttackTimer : Timer { - private Mobile m_Player; + private readonly Mobile m_Player; public AttackTimer(Mobile player) : base(AttackEffectDuration) { @@ -69,7 +69,7 @@ namespace Server.Items private class DefenseTimer : Timer { - private Mobile m_Player; + private readonly Mobile m_Player; public DefenseTimer(Mobile player) : base(DefenseEffectDuration) { diff --git a/Projects/Scripts/Items/Weapons/Knives/ThrowingDagger.cs b/Projects/Scripts/Items/Weapons/Knives/ThrowingDagger.cs index a5c4758a2..49ae2fd39 100644 --- a/Projects/Scripts/Items/Weapons/Knives/ThrowingDagger.cs +++ b/Projects/Scripts/Items/Weapons/Knives/ThrowingDagger.cs @@ -48,7 +48,7 @@ namespace Server.Items private class InternalTarget : Target { - private ThrowingDagger m_Dagger; + private readonly ThrowingDagger m_Dagger; public InternalTarget(ThrowingDagger dagger) : base(10, false, TargetFlags.Harmful) => m_Dagger = dagger; diff --git a/Projects/Scripts/Items/Weapons/Maces/FireworksWand.cs b/Projects/Scripts/Items/Weapons/Maces/FireworksWand.cs index 2a98d41a1..e3f983b1f 100644 --- a/Projects/Scripts/Items/Weapons/Maces/FireworksWand.cs +++ b/Projects/Scripts/Items/Weapons/Maces/FireworksWand.cs @@ -120,10 +120,10 @@ namespace Server.Items switch (version) { case 0: - { - m_Charges = reader.ReadInt(); - break; - } + { + m_Charges = reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Items/Weapons/PoleArms/BasePoleArm.cs b/Projects/Scripts/Items/Weapons/PoleArms/BasePoleArm.cs index dd0cee40d..dcdad4fb7 100644 --- a/Projects/Scripts/Items/Weapons/PoleArms/BasePoleArm.cs +++ b/Projects/Scripts/Items/Weapons/PoleArms/BasePoleArm.cs @@ -88,22 +88,22 @@ namespace Server.Items switch (version) { case 2: - { - m_ShowUsesRemaining = reader.ReadBool(); - goto case 1; - } + { + m_ShowUsesRemaining = reader.ReadBool(); + goto case 1; + } case 1: - { - m_UsesRemaining = reader.ReadInt(); - goto case 0; - } + { + m_UsesRemaining = reader.ReadInt(); + goto case 0; + } case 0: - { - if (m_UsesRemaining < 1) - m_UsesRemaining = 150; + { + if (m_UsesRemaining < 1) + m_UsesRemaining = 150; - break; - } + break; + } } } diff --git a/Projects/Scripts/Items/Weapons/Ranged/BaseRanged.cs b/Projects/Scripts/Items/Weapons/Ranged/BaseRanged.cs index fff827dc4..bc1a20121 100644 --- a/Projects/Scripts/Items/Weapons/Ranged/BaseRanged.cs +++ b/Projects/Scripts/Items/Weapons/Ranged/BaseRanged.cs @@ -20,9 +20,9 @@ namespace Server.Items { } - public abstract int EffectID{ get; } - public abstract Type AmmoType{ get; } - public abstract Item Ammo{ get; } + public abstract int EffectID { get; } + public abstract Type AmmoType { get; } + public abstract Item Ammo { get; } public override int DefHitSound => 0x234; public override int DefMissSound => 0x238; @@ -61,7 +61,7 @@ namespace Server.Items // Make sure we've been standing still for .25/.5/1 second depending on Era if (Core.TickCount - attacker.LastMoveTime >= (Core.SE ? 250 : Core.AOS ? 500 : 1000) || - Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot) + (Core.AOS && WeaponAbility.GetCurrentAbility(attacker) is MovingShot)) { bool canSwing = true; @@ -73,10 +73,8 @@ namespace Server.Items canSwing = !(attacker.Spell is Spell sp) || !sp.IsCasting || !sp.BlocksMovement; } - #region Dueling if ((attacker as PlayerMobile)?.DuelContext?.CheckItemEquip(attacker, this) == false) canSwing = false; - #endregion if (canSwing && attacker.HarmfulCheck(defender)) { @@ -105,7 +103,7 @@ namespace Server.Items public override void OnHit(Mobile attacker, Mobile defender, double damageBonus = 1) { if (attacker.Player && !defender.Player && (defender.Body.IsAnimal || defender.Body.IsMonster) && - 0.4 >= Utility.RandomDouble()) + Utility.RandomDouble() <= 0.4) defender.AddToBackpack(Ammo); if (Core.ML && m_Velocity > 0) @@ -129,7 +127,7 @@ namespace Server.Items public override void OnMiss(Mobile attacker, Mobile defender) { - if (attacker.Player && 0.4 >= Utility.RandomDouble()) + if (attacker.Player && Utility.RandomDouble() <= 0.4) { if (Core.SE) { @@ -208,23 +206,23 @@ namespace Server.Items switch (version) { case 3: - { - m_Balanced = reader.ReadBool(); - m_Velocity = reader.ReadInt(); + { + m_Balanced = reader.ReadBool(); + m_Velocity = reader.ReadInt(); - goto case 2; - } + goto case 2; + } case 2: case 1: - { - break; - } + { + break; + } case 0: - { - /*m_EffectID =*/ - reader.ReadInt(); - break; - } + { + /*m_EffectID =*/ + reader.ReadInt(); + break; + } } if (version < 2) diff --git a/Projects/Scripts/Items/Weapons/SlayerEntry.cs b/Projects/Scripts/Items/Weapons/SlayerEntry.cs index ac6caf0ff..8e24df147 100644 --- a/Projects/Scripts/Items/Weapons/SlayerEntry.cs +++ b/Projects/Scripts/Items/Weapons/SlayerEntry.cs @@ -4,7 +4,7 @@ namespace Server.Items { public class SlayerEntry { - private static int[] m_AosTitles = + private static readonly int[] m_AosTitles = { 1060479, // undead slayer 1060470, // orc slayer @@ -35,7 +35,7 @@ namespace Server.Items 1070855 // fey slayer }; - private static int[] m_OldTitles = + private static readonly int[] m_OldTitles = { 1017384, // Silver 1017385, // Orc Slaying @@ -72,11 +72,11 @@ namespace Server.Items Types = types; } - public SlayerGroup Group{ get; set; } + public SlayerGroup Group { get; set; } - public SlayerName Name{ get; } + public SlayerName Name { get; } - public Type[] Types{ get; } + public Type[] Types { get; } public int Title { diff --git a/Projects/Scripts/Items/Weapons/SlayerGroup.cs b/Projects/Scripts/Items/Weapons/SlayerGroup.cs index 1f33b7279..67a733988 100644 --- a/Projects/Scripts/Items/Weapons/SlayerGroup.cs +++ b/Projects/Scripts/Items/Weapons/SlayerGroup.cs @@ -39,13 +39,13 @@ namespace Server.Items typeof(PestilentBandage), typeof(Revenant), typeof(RevenantLion), typeof(RottingCorpse), typeof(Shade), typeof(ShadowKnight), typeof(SkeletalKnight), typeof(SkeletalMage), typeof(SkeletalMount), typeof(Skeleton), typeof(Spectre), typeof(Wraith), typeof(Zombie)); - undead.Entries = new SlayerEntry[0]; + undead.Entries = Array.Empty(); fey.Opposition = new[] { abyss }; fey.Super = new SlayerEntry(SlayerName.Fey, typeof(Centaur), typeof(CuSidhe), typeof(EtherealWarrior), typeof(Kirin), typeof(LordOaks), typeof(Pixie), typeof(Silvani), typeof(Treefellow), typeof(Unicorn), typeof(Wisp), typeof(MLDryad), typeof(Satyr)); - fey.Entries = new SlayerEntry[0]; + fey.Entries = Array.Empty(); elemental.Opposition = new[] { abyss }; elemental.FoundOn = new[] { typeof(Balron), typeof(Daemon) }; @@ -163,17 +163,17 @@ namespace Server.Items TotalEntries = CompileEntries(Groups); } - public static SlayerEntry[] TotalEntries{ get; } + public static SlayerEntry[] TotalEntries { get; } - public static SlayerGroup[] Groups{ get; } + public static SlayerGroup[] Groups { get; } - public SlayerGroup[] Opposition{ get; set; } + public SlayerGroup[] Opposition { get; set; } - public SlayerEntry Super{ get; set; } + public SlayerEntry Super { get; set; } - public SlayerEntry[] Entries{ get; set; } + public SlayerEntry[] Entries { get; set; } - public Type[] FoundOn{ get; set; } + public Type[] FoundOn { get; set; } public static SlayerEntry GetEntryByName(SlayerName name) { @@ -242,4 +242,4 @@ namespace Server.Items return false; } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Items/Weapons/Staves/GlacialStaff.cs b/Projects/Scripts/Items/Weapons/Staves/GlacialStaff.cs index 5f67900db..cd577fd77 100644 --- a/Projects/Scripts/Items/Weapons/Staves/GlacialStaff.cs +++ b/Projects/Scripts/Items/Weapons/Staves/GlacialStaff.cs @@ -16,7 +16,7 @@ namespace Server.Items { } - //TODO: Pre-AoS stuff + // TODO: Pre-AoS stuff public override int LabelNumber => 1017413; // Glacial Staff public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs b/Projects/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs index 501b6a4a6..84b731318 100644 --- a/Projects/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs +++ b/Projects/Scripts/Items/Weapons/Staves/ShepherdsCrook.cs @@ -58,7 +58,7 @@ namespace Server.Items private class HerdingTarget : Target { - private static Type[] m_ChampTamables = + private static readonly Type[] m_ChampTamables = { typeof(StrongMongbat), typeof(Imp), typeof(Scorpion), typeof(GiantSpider), typeof(Snake), typeof(LavaLizard), typeof(Drake), typeof(Dragon), @@ -128,7 +128,7 @@ namespace Server.Items private class InternalTarget : Target { - private BaseCreature m_Creature; + private readonly BaseCreature m_Creature; public InternalTarget(BaseCreature c) : base(10, true, TargetFlags.None) => m_Creature = c; diff --git a/Projects/Scripts/Items/Weapons/Swords/BoneMachete.cs b/Projects/Scripts/Items/Weapons/Swords/BoneMachete.cs index bdaf31e54..8d9f292d3 100644 --- a/Projects/Scripts/Items/Weapons/Swords/BoneMachete.cs +++ b/Projects/Scripts/Items/Weapons/Swords/BoneMachete.cs @@ -24,8 +24,6 @@ namespace Server.Items public override int InitMinHits => 5; public override int InitMaxHits => 5; - #region ITicket Members - public void OnTicketUsed(Mobile from) { if (Utility.RandomDouble() < 0.25) @@ -41,8 +39,6 @@ namespace Server.Items } } - #endregion - public override void Serialize(IGenericWriter writer) { base.Serialize(writer); diff --git a/Projects/Scripts/Misc/AOS.cs b/Projects/Scripts/Misc/AOS.cs index 84a8c963d..e4a115a65 100644 --- a/Projects/Scripts/Misc/AOS.cs +++ b/Projects/Scripts/Misc/AOS.cs @@ -134,8 +134,6 @@ namespace Server totalDamage += totalDamage * quiver.DamageIncrease / 100; } - #region Dragon Barding - if (from?.Player != true && m.Player && m.Mount is SwampDragon pet) if (pet.HasBarding) { @@ -154,8 +152,6 @@ namespace Server } } - #endregion - if (keepAlive && totalDamage > m.Hits) totalDamage = m.Hits; @@ -921,7 +917,6 @@ namespace Server { } - [CommandProperty(AccessLevel.GameMaster)] public double Skill_1_Value { @@ -1006,7 +1001,7 @@ namespace Server SkillName.EvalInt => 1002070, // Evaluate Intelligence SkillName.Forensics => 1002078, // Forensic Evaluation SkillName.Lockpicking => 1002097, // Lockpicking - _ => (1044060 + (int)skill) + _ => 1044060 + (int)skill }; } @@ -1254,7 +1249,7 @@ namespace Server [PropertyObject] public abstract class BaseAttributes { - private static int[] m_Empty = new int[0]; + private static readonly int[] m_Empty = Array.Empty(); private uint m_Names; private int[] m_Values; @@ -1281,30 +1276,30 @@ namespace Server switch (version) { case 1: - { - m_Names = reader.ReadUInt(); - m_Values = new int[reader.ReadEncodedInt()]; + { + m_Names = reader.ReadUInt(); + m_Values = new int[reader.ReadEncodedInt()]; - for (int i = 0; i < m_Values.Length; ++i) - m_Values[i] = reader.ReadEncodedInt(); + for (int i = 0; i < m_Values.Length; ++i) + m_Values[i] = reader.ReadEncodedInt(); - break; - } + break; + } case 0: - { - m_Names = reader.ReadUInt(); - m_Values = new int[reader.ReadInt()]; + { + m_Names = reader.ReadUInt(); + m_Values = new int[reader.ReadInt()]; - for (int i = 0; i < m_Values.Length; ++i) - m_Values[i] = reader.ReadInt(); + for (int i = 0; i < m_Values.Length; ++i) + m_Values[i] = reader.ReadInt(); - break; - } + break; + } } } public bool IsEmpty => m_Names == 0; - public Item Owner{ get; } + public Item Owner { get; } public void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Misc/AttackMessage.cs b/Projects/Scripts/Misc/AttackMessage.cs index fffec074d..0d74b5f31 100644 --- a/Projects/Scripts/Misc/AttackMessage.cs +++ b/Projects/Scripts/Misc/AttackMessage.cs @@ -10,7 +10,7 @@ namespace Server.Misc private const string AggressedFormat = "{0} is attacking you!"; private const int Hue = 0x22; - private static TimeSpan Delay = TimeSpan.FromMinutes(1.0); + private static readonly TimeSpan Delay = TimeSpan.FromMinutes(1.0); public static void Initialize() { diff --git a/Projects/Scripts/Misc/AutoRestart.cs b/Projects/Scripts/Misc/AutoRestart.cs index 39ac545b0..ab262d278 100644 --- a/Projects/Scripts/Misc/AutoRestart.cs +++ b/Projects/Scripts/Misc/AutoRestart.cs @@ -6,13 +6,13 @@ namespace Server.Misc { public static bool Enabled; // is the script enabled? - private static TimeSpan RestartTime = TimeSpan.FromHours(2.0); // time of day at which to restart + private static readonly TimeSpan RestartTime = TimeSpan.FromHours(2.0); // time of day at which to restart - private static TimeSpan + private static readonly TimeSpan RestartDelay = TimeSpan.Zero; // how long the server should remain active before restart (period of 'server wars') - private static TimeSpan + private static readonly TimeSpan WarningDelay = TimeSpan.FromMinutes(1.0); // at what interval should the shutdown message be displayed? private static DateTime m_RestartTime; @@ -27,7 +27,7 @@ namespace Server.Misc m_RestartTime += TimeSpan.FromDays(1.0); } - public static bool Restarting{ get; private set; } + public static bool Restarting { get; private set; } public static void Initialize() { diff --git a/Projects/Scripts/Misc/AutoSave.cs b/Projects/Scripts/Misc/AutoSave.cs index 1d206f72b..a2e91f9a2 100644 --- a/Projects/Scripts/Misc/AutoSave.cs +++ b/Projects/Scripts/Misc/AutoSave.cs @@ -5,10 +5,10 @@ namespace Server.Misc { public class AutoSave : Timer { - private static TimeSpan m_Delay = TimeSpan.FromMinutes(5.0); - private static TimeSpan m_Warning = TimeSpan.Zero; + private static readonly TimeSpan m_Delay = TimeSpan.FromMinutes(5.0); + private static readonly TimeSpan m_Warning = TimeSpan.Zero; - private static string[] m_Backups = + private static readonly string[] m_Backups = { "Third Backup", "Second Backup", @@ -17,8 +17,8 @@ namespace Server.Misc public AutoSave() : base(m_Delay - m_Warning, m_Delay) => Priority = TimerPriority.OneMinute; - public static bool SavesEnabled{ get; set; } = true; - //private static TimeSpan m_Warning = TimeSpan.FromSeconds( 15.0 ); + public static bool SavesEnabled { get; set; } = true; + // private static TimeSpan m_Warning = TimeSpan.FromSeconds( 15.0 ); public static void Initialize() { diff --git a/Projects/Scripts/Misc/BuffIcons.cs b/Projects/Scripts/Misc/BuffIcons.cs index 6a06ae139..c2dd80e70 100644 --- a/Projects/Scripts/Misc/BuffIcons.cs +++ b/Projects/Scripts/Misc/BuffIcons.cs @@ -20,27 +20,21 @@ namespace Server Timer.DelayCall(TimeSpan.Zero, pm.ResendBuffs); } - #region Properties + public BuffIcon ID { get; } - public BuffIcon ID{ get; } + public int TitleCliloc { get; } - public int TitleCliloc{ get; } + public int SecondaryCliloc { get; } - public int SecondaryCliloc{ get; } + public TimeSpan TimeLength { get; } - public TimeSpan TimeLength{ get; } + public DateTime TimeStart { get; } - public DateTime TimeStart{ get; } + public Timer Timer { get; } - public Timer Timer{ get; } + public bool RetainThroughDeath { get; } - public bool RetainThroughDeath{ get; } - - public TextDefinition Args{ get; } - - #endregion - - #region Constructors + public TextDefinition Args { get; } public BuffInfo(BuffIcon iconID, int titleCliloc) : this(iconID, titleCliloc, titleCliloc + 1) @@ -59,14 +53,14 @@ namespace Server { } - //Only the timed one needs to Mobile to know when to automagically remove it. + // Only the timed one needs to Mobile to know when to automagically remove it. public BuffInfo(BuffIcon iconID, int titleCliloc, int secondaryCliloc, TimeSpan length, Mobile m) : this(iconID, titleCliloc, secondaryCliloc) { TimeLength = length; TimeStart = DateTime.UtcNow; - Timer = Timer.DelayCall(length, delegate + Timer = Timer.DelayCall(length, () => { if (!(m is PlayerMobile pm)) return; @@ -75,7 +69,6 @@ namespace Server }); } - public BuffInfo(BuffIcon iconID, int titleCliloc, TextDefinition args) : this(iconID, titleCliloc, titleCliloc + 1, args) { @@ -127,10 +120,6 @@ namespace Server RetainThroughDeath = retainThroughDeath; } - #endregion - - #region Convenience Methods - public static void AddBuff(Mobile m, BuffInfo b) { if (m is PlayerMobile pm) @@ -148,8 +137,6 @@ namespace Server if (m is PlayerMobile pm) pm.RemoveBuff(b); } - - #endregion } public enum BuffIcon : short @@ -157,51 +144,51 @@ namespace Server DismountPrevention = 0x3E9, NoRearm = 0x3EA, - //Currently, no 0x3EB or 0x3EC - NightSight = 0x3ED, //* + // Currently, no 0x3EB or 0x3EC + NightSight = 0x3ED, // * DeathStrike, EvilOmen, - UnknownStandingSwirl, //Which is healing throttle & Stamina throttle? + UnknownStandingSwirl, // Which is healing throttle & Stamina throttle? UnknownKneelingSword, - DivineFury, //* - EnemyOfOne, //* - HidingAndOrStealth, //* - ActiveMeditation, //* - BloodOathCaster, //* - BloodOathCurse, //* - CorpseSkin, //* - Mindrot, //* - PainSpike, //* + DivineFury, // * + EnemyOfOne, // * + HidingAndOrStealth, // * + ActiveMeditation, // * + BloodOathCaster, // * + BloodOathCurse, // * + CorpseSkin, // * + Mindrot, // * + PainSpike, // * Strangle, - GiftOfRenewal, //* - AttuneWeapon, //* - Thunderstorm, //* - EssenceOfWind, //* - EtherealVoyage, //* - GiftOfLife, //* - ArcaneEmpowerment, //* + GiftOfRenewal, // * + AttuneWeapon, // * + Thunderstorm, // * + EssenceOfWind, // * + EtherealVoyage, // * + GiftOfLife, // * + ArcaneEmpowerment, // * MortalStrike, - ReactiveArmor, //* - Protection, //* + ReactiveArmor, // * + Protection, // * ArchProtection, - MagicReflection, //* - Incognito, //* + MagicReflection, // * + Incognito, // * Disguised, AnimalForm, Polymorph, - Invisibility, //* - Paralyze, //* + Invisibility, // * + Paralyze, // * Poison, Bleed, - Clumsy, //* - FeebleMind, //* - Weaken, //* - Curse, //* + Clumsy, // * + FeebleMind, // * + Weaken, // * + Curse, // * MassCurse, - Agility, //* - Cunning, //* - Strength, //* - Bless, //* + Agility, // * + Cunning, // * + Strength, // * + Bless, // * Sleep, StoneForm, SpellPlague, @@ -225,44 +212,43 @@ namespace Server bool hasArgs = args != null; EnsureCapacity(hasArgs ? 48 + args.ToString().Length * 2 : 44); - m_Stream.Write(mob.Serial); + Stream.Write(mob.Serial); + Stream.Write((short)iconID); // ID + Stream.Write((short)0x1); // Type 0 for removal. 1 for add 2 for Data - m_Stream.Write((short)iconID); //ID - m_Stream.Write((short)0x1); //Type 0 for removal. 1 for add 2 for Data + Stream.Fill(4); - m_Stream.Fill(4); + Stream.Write((short)iconID); // ID + Stream.Write((short)0x01); // Type 0 for removal. 1 for add 2 for Data - m_Stream.Write((short)iconID); //ID - m_Stream.Write((short)0x01); //Type 0 for removal. 1 for add 2 for Data - - m_Stream.Fill(4); + Stream.Fill(4); if (length < TimeSpan.Zero) length = TimeSpan.Zero; - m_Stream.Write((short)length.TotalSeconds); //Time in seconds + Stream.Write((short)length.TotalSeconds); // Time in seconds - m_Stream.Fill(3); - m_Stream.Write(titleCliloc); - m_Stream.Write(secondaryCliloc); + Stream.Fill(3); + Stream.Write(titleCliloc); + Stream.Write(secondaryCliloc); if (!hasArgs) { - //m_Stream.Fill( 2 ); - m_Stream.Fill(10); + // m_Stream.Fill( 2 ); + Stream.Fill(10); } else { - m_Stream.Fill(4); - m_Stream.Write((short)0x1); //Unknown -> Possibly something saying 'hey, I have more data!'? - m_Stream.Fill(2); + Stream.Fill(4); + Stream.Write((short)0x1); // Unknown -> Possibly something saying 'hey, I have more data!'? + Stream.Fill(2); - //m_Stream.WriteLittleUniNull( "\t#1018280" ); - m_Stream.WriteLittleUniNull($"\t{args}"); + // m_Stream.WriteLittleUniNull( "\t#1018280" ); + Stream.WriteLittleUniNull($"\t{args}"); - m_Stream.Write((short)0x1); //Even more Unknown -> Possibly something saying 'hey, I have more data!'? - m_Stream.Fill(2); + Stream.Write((short)0x1); // Even more Unknown -> Possibly something saying 'hey, I have more data!'? + Stream.Fill(2); } } } @@ -278,12 +264,12 @@ namespace Server : base(0xDF) { EnsureCapacity(13); - m_Stream.Write(mob.Serial); + Stream.Write(mob.Serial); - m_Stream.Write((short)iconID); //ID - m_Stream.Write((short)0x0); //Type 0 for removal. 1 for add 2 for Data + Stream.Write((short)iconID); // ID + Stream.Write((short)0x0); // Type 0 for removal. 1 for add 2 for Data - m_Stream.Fill(4); + Stream.Fill(4); } } } diff --git a/Projects/Scripts/Misc/CharacterCreation.cs b/Projects/Scripts/Misc/CharacterCreation.cs index 9c5b32566..d4de0f5cc 100644 --- a/Projects/Scripts/Misc/CharacterCreation.cs +++ b/Projects/Scripts/Misc/CharacterCreation.cs @@ -7,7 +7,7 @@ using Server.Network; namespace Server.Misc { - public class CharacterCreation + public static class CharacterCreation { private static readonly CityInfo m_NewHavenInfo = new CityInfo("New Haven", "The Bountiful Harvest Inn", 3503, 2574, 14, Map.Trammel); @@ -74,10 +74,8 @@ namespace Server.Misc m.StatCap = 250; - Container cont; - // Begin box of money cont = new WoodenBox(); cont.ItemID = 0xE7D; @@ -95,7 +93,6 @@ namespace Server.Misc PlaceItemIn(bank, 18, 169, cont); // End box of money - // Begin bag of potion kegs cont = new Backpack(); cont.Name = "Various Potion Kegs"; @@ -111,7 +108,6 @@ namespace Server.Misc PlaceItemIn(bank, 53, 169, cont); // End bag of potion kegs - // Begin bag of tools cont = new Bag(); cont.Name = "Tool Bag"; @@ -143,7 +139,6 @@ namespace Server.Misc PlaceItemIn(bank, 118, 169, cont); // End bag of tools - // Begin bag of archery ammo cont = new Bag(); cont.Name = "Bag Of Archery Ammo"; @@ -154,7 +149,6 @@ namespace Server.Misc PlaceItemIn(bank, 118, 124, cont); // End bag of archery ammo - // Begin bag of treasure maps cont = new Bag(); cont.Name = "Bag Of Treasure Maps"; @@ -179,7 +173,6 @@ namespace Server.Misc PlaceItemIn(bank, 98, 124, cont); // End bag of treasure maps - // Begin bag of raw materials cont = new Bag(); cont.Hue = 0x835; @@ -214,17 +207,16 @@ namespace Server.Misc PlaceItemIn(bank, 98, 169, cont); // End bag of raw materials - // Begin bag of spell casting stuff cont = new Backpack(); cont.Hue = 0x480; cont.Name = "Spell Casting Stuff"; PlaceItemIn(cont, 45, 105, new Spellbook(ulong.MaxValue)); - PlaceItemIn(cont, 65, 105, new NecromancerSpellbook((ulong)0xFFFF)); + PlaceItemIn(cont, 65, 105, new NecromancerSpellbook(0xFFFFUL)); PlaceItemIn(cont, 85, 105, new BookOfChivalry()); - PlaceItemIn(cont, 105, 105, new BookOfBushido()); //Default ctor = full - PlaceItemIn(cont, 125, 105, new BookOfNinjitsu()); //Default ctor = full + PlaceItemIn(cont, 105, 105, new BookOfBushido()); // Default ctor = full + PlaceItemIn(cont, 125, 105, new BookOfNinjitsu()); // Default ctor = full Runebook runebook = new Runebook(10); runebook.CurCharges = runebook.MaxCharges; @@ -248,7 +240,6 @@ namespace Server.Misc PlaceItemIn(bank, 78, 169, cont); // End bag of spell casting stuff - // Begin bag of ethereals cont = new Backpack(); cont.Hue = 0x490; @@ -266,7 +257,6 @@ namespace Server.Misc PlaceItemIn(bank, 38, 124, cont); // End bag of ethereals - // Begin first bag of artifacts cont = new Backpack(); cont.Hue = 0x48F; @@ -280,7 +270,6 @@ namespace Server.Misc PlaceItemIn(bank, 58, 124, cont); // End first bag of artifacts - // Begin second bag of artifacts cont = new Backpack(); cont.Hue = 0x48F; @@ -328,7 +317,6 @@ namespace Server.Misc cont.Hue = 0x48F; cont.Name = "Bag of Minor Artifacts"; - PlaceItemIn(cont, 45, 66, new LunaLance()); PlaceItemIn(cont, 69, 82, new VioletCourage()); PlaceItemIn(cont, 93, 99, new CavortingClub()); @@ -396,7 +384,7 @@ namespace Server.Misc PlaceItemIn(bank, 58, 124, cont); } - if (Core.SE) //This bag came only after SE. + if (Core.SE) // This bag came only after SE. { cont = new Bag(); cont.Name = "Bag of Bows"; @@ -639,14 +627,14 @@ namespace Server.Misc newChar.Player = true; newChar.AccessLevel = args.Account.AccessLevel; newChar.Female = args.Female; - //newChar.Body = newChar.Female ? 0x191 : 0x190; + // newChar.Body = newChar.Female ? 0x191 : 0x190; if (Core.Expansion >= args.Race.RequiredExpansion) - newChar.Race = args.Race; //Sets body + newChar.Race = args.Race; // Sets body else newChar.Race = Race.DefaultRace; - //newChar.Hue = Utility.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000; + // newChar.Hue = Utility.ClipSkinHue( args.Hue & 0x3FFF ) | 0x8000; newChar.Hue = newChar.Race.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000; newChar.Hunger = 20; @@ -726,7 +714,7 @@ namespace Server.Misc private static CityInfo GetStartLocation(CharacterCreatedEventArgs args, bool isYoung) { - if (Core.ML) return m_NewHavenInfo; //We don't get the client Version until AFTER Character creation + if (Core.ML) return m_NewHavenInfo; // We don't get the client Version until AFTER Character creation bool useHaven = isYoung; @@ -735,64 +723,66 @@ namespace Server.Misc switch (args.Profession) { - case 4: //Necro - { - if ((flags & ClientFlags.Malas) != 0) - return new CityInfo("Umbra", "Mardoth's Tower", 2114, 1301, -50, Map.Malas); + case 4: // Necro + { + if ((flags & ClientFlags.Malas) != 0) + return new CityInfo("Umbra", "Mardoth's Tower", 2114, 1301, -50, Map.Malas); - useHaven = true; + useHaven = true; - new BadStartMessage(m, 1062205); - /* - * Unfortunately you are playing on a *NON-Age-Of-Shadows* game - * installation and cannot be transported to Malas. - * You will not be able to take your new player quest in Malas - * without an AOS client. You are now being taken to the city of - * Haven on the Trammel facet. - * */ + // ReSharper disable once CA1806 + new BadStartMessage(m, 1062205); + /* + * Unfortunately you are playing on a *NON-Age-Of-Shadows* game + * installation and cannot be transported to Malas. + * You will not be able to take your new player quest in Malas + * without an AOS client. You are now being taken to the city of + * Haven on the Trammel facet. + * */ - break; - } - case 5: //Paladin - { - return m_NewHavenInfo; - } - case 6: //Samurai - { - if ((flags & ClientFlags.Tokuno) != 0) - return new CityInfo("Samurai DE", "Haoti's Grounds", 368, 780, -1, Map.Malas); + break; + } + case 5: // Paladin + { + return m_NewHavenInfo; + } + case 6: // Samurai + { + if ((flags & ClientFlags.Tokuno) != 0) + return new CityInfo("Samurai DE", "Haoti's Grounds", 368, 780, -1, Map.Malas); - useHaven = true; + useHaven = true; - new BadStartMessage(m, 1063487); - /* - * Unfortunately you are playing on a *NON-Samurai-Empire* game - * installation and cannot be transported to Tokuno. - * You will not be able to take your new player quest in Tokuno - * without an SE client. You are now being taken to the city of - * Haven on the Trammel facet. - * */ + // ReSharper disable once CA1806 + new BadStartMessage(m, 1063487); + /* + * Unfortunately you are playing on a *NON-Samurai-Empire* game + * installation and cannot be transported to Tokuno. + * You will not be able to take your new player quest in Tokuno + * without an SE client. You are now being taken to the city of + * Haven on the Trammel facet. + * */ - break; - } - case 7: //Ninja - { - if ((flags & ClientFlags.Tokuno) != 0) - return new CityInfo("Ninja DE", "Enimo's Residence", 414, 823, -1, Map.Malas); + break; + } + case 7: // Ninja + { + if ((flags & ClientFlags.Tokuno) != 0) + return new CityInfo("Ninja DE", "Enimo's Residence", 414, 823, -1, Map.Malas); - useHaven = true; + useHaven = true; - new BadStartMessage(m, 1063487); - /* - * Unfortunately you are playing on a *NON-Samurai-Empire* game - * installation and cannot be transported to Tokuno. - * You will not be able to take your new player quest in Tokuno - * without an SE client. You are now being taken to the city of - * Haven on the Trammel facet. - * */ + new BadStartMessage(m, 1063487); + /* + * Unfortunately you are playing on a *NON-Samurai-Empire* game + * installation and cannot be transported to Tokuno. + * You will not be able to take your new player quest in Tokuno + * without an SE client. You are now being taken to the city of + * Haven on the Trammel facet. + * */ - break; - } + break; + } } if (useHaven) @@ -898,95 +888,95 @@ namespace Server.Misc switch (prof) { case 1: // Warrior - { - skills = new[] { - new SkillNameValue(SkillName.Anatomy, 30), - new SkillNameValue(SkillName.Healing, 45), - new SkillNameValue(SkillName.Swords, 35), - new SkillNameValue(SkillName.Tactics, 50) - }; + skills = new[] + { + new SkillNameValue(SkillName.Anatomy, 30), + new SkillNameValue(SkillName.Healing, 45), + new SkillNameValue(SkillName.Swords, 35), + new SkillNameValue(SkillName.Tactics, 50) + }; - break; - } + break; + } case 2: // Magician - { - skills = new[] { - new SkillNameValue(SkillName.EvalInt, 30), - new SkillNameValue(SkillName.Wrestling, 30), - new SkillNameValue(SkillName.Magery, 50), - new SkillNameValue(SkillName.Meditation, 50) - }; + skills = new[] + { + new SkillNameValue(SkillName.EvalInt, 30), + new SkillNameValue(SkillName.Wrestling, 30), + new SkillNameValue(SkillName.Magery, 50), + new SkillNameValue(SkillName.Meditation, 50) + }; - break; - } + break; + } case 3: // Blacksmith - { - skills = new[] { - new SkillNameValue(SkillName.Mining, 30), - new SkillNameValue(SkillName.ArmsLore, 30), - new SkillNameValue(SkillName.Blacksmith, 50), - new SkillNameValue(SkillName.Tinkering, 50) - }; + skills = new[] + { + new SkillNameValue(SkillName.Mining, 30), + new SkillNameValue(SkillName.ArmsLore, 30), + new SkillNameValue(SkillName.Blacksmith, 50), + new SkillNameValue(SkillName.Tinkering, 50) + }; - break; - } + break; + } case 4: // Necromancer - { - skills = new[] { - new SkillNameValue(SkillName.Necromancy, 50), - new SkillNameValue(SkillName.Focus, 30), - new SkillNameValue(SkillName.SpiritSpeak, 30), - new SkillNameValue(SkillName.Swords, 30), - new SkillNameValue(SkillName.Tactics, 20) - }; + skills = new[] + { + new SkillNameValue(SkillName.Necromancy, 50), + new SkillNameValue(SkillName.Focus, 30), + new SkillNameValue(SkillName.SpiritSpeak, 30), + new SkillNameValue(SkillName.Swords, 30), + new SkillNameValue(SkillName.Tactics, 20) + }; - break; - } + break; + } case 5: // Paladin - { - skills = new[] { - new SkillNameValue(SkillName.Chivalry, 51), - new SkillNameValue(SkillName.Swords, 49), - new SkillNameValue(SkillName.Focus, 30), - new SkillNameValue(SkillName.Tactics, 30) - }; + skills = new[] + { + new SkillNameValue(SkillName.Chivalry, 51), + new SkillNameValue(SkillName.Swords, 49), + new SkillNameValue(SkillName.Focus, 30), + new SkillNameValue(SkillName.Tactics, 30) + }; - break; - } - case 6: //Samurai - { - skills = new[] + break; + } + case 6: // Samurai { - new SkillNameValue(SkillName.Bushido, 50), - new SkillNameValue(SkillName.Swords, 50), - new SkillNameValue(SkillName.Anatomy, 30), - new SkillNameValue(SkillName.Healing, 30) - }; - break; - } - case 7: //Ninja - { - skills = new[] + skills = new[] + { + new SkillNameValue(SkillName.Bushido, 50), + new SkillNameValue(SkillName.Swords, 50), + new SkillNameValue(SkillName.Anatomy, 30), + new SkillNameValue(SkillName.Healing, 30) + }; + break; + } + case 7: // Ninja { - new SkillNameValue(SkillName.Ninjitsu, 50), - new SkillNameValue(SkillName.Hiding, 50), - new SkillNameValue(SkillName.Fencing, 30), - new SkillNameValue(SkillName.Stealth, 30) - }; - break; - } + skills = new[] + { + new SkillNameValue(SkillName.Ninjitsu, 50), + new SkillNameValue(SkillName.Hiding, 50), + new SkillNameValue(SkillName.Fencing, 30), + new SkillNameValue(SkillName.Stealth, 30) + }; + break; + } default: - { - if (!ValidSkills(skills)) - return; + { + if (!ValidSkills(skills)) + return; - break; - } + break; + } } bool addSkillItems = true; @@ -995,145 +985,145 @@ namespace Server.Misc switch (prof) { case 1: // Warrior - { - if (elf) - EquipItem(new LeafChest()); - else - EquipItem(new LeatherChest()); - break; - } + { + if (elf) + EquipItem(new LeafChest()); + else + EquipItem(new LeatherChest()); + break; + } case 4: // Necromancer - { - Container regs = new BagOfNecroReagents(); - - if (!Core.AOS) - foreach (Item item in regs.Items) - item.LootType = LootType.Newbied; - - PackItem(regs); - - regs.LootType = LootType.Regular; - - EquipItem(new BoneHelm()); - - if (elf) { - EquipItem(new ElvenMachete()); - EquipItem(NecroHue(new LeafChest())); - EquipItem(NecroHue(new LeafArms())); - EquipItem(NecroHue(new LeafGloves())); - EquipItem(NecroHue(new LeafGorget())); - EquipItem(NecroHue(new LeafGorget())); - EquipItem(NecroHue(new ElvenPants())); //TODO: Verify the pants - EquipItem(new ElvenBoots()); + Container regs = new BagOfNecroReagents(); + + if (!Core.AOS) + foreach (Item item in regs.Items) + item.LootType = LootType.Newbied; + + PackItem(regs); + + regs.LootType = LootType.Regular; + + EquipItem(new BoneHelm()); + + if (elf) + { + EquipItem(new ElvenMachete()); + EquipItem(NecroHue(new LeafChest())); + EquipItem(NecroHue(new LeafArms())); + EquipItem(NecroHue(new LeafGloves())); + EquipItem(NecroHue(new LeafGorget())); + EquipItem(NecroHue(new LeafGorget())); + EquipItem(NecroHue(new ElvenPants())); // TODO: Verify the pants + EquipItem(new ElvenBoots()); + } + else + { + EquipItem(new BoneHarvester()); + EquipItem(NecroHue(new LeatherChest())); + EquipItem(NecroHue(new LeatherArms())); + EquipItem(NecroHue(new LeatherGloves())); + EquipItem(NecroHue(new LeatherGorget())); + EquipItem(NecroHue(new LeatherLegs())); + EquipItem(NecroHue(new Skirt())); + EquipItem(new Sandals(0x8FD)); + } + + Spellbook + book = new NecromancerSpellbook( + (ulong)0x8981); // animate dead, evil omen, pain spike, summon familiar, wraith form + + PackItem(book); + + book.LootType = LootType.Blessed; + + addSkillItems = false; + + break; } - else - { - EquipItem(new BoneHarvester()); - EquipItem(NecroHue(new LeatherChest())); - EquipItem(NecroHue(new LeatherArms())); - EquipItem(NecroHue(new LeatherGloves())); - EquipItem(NecroHue(new LeatherGorget())); - EquipItem(NecroHue(new LeatherLegs())); - EquipItem(NecroHue(new Skirt())); - EquipItem(new Sandals(0x8FD)); - } - - Spellbook - book = new NecromancerSpellbook( - (ulong)0x8981); // animate dead, evil omen, pain spike, summon familiar, wraith form - - PackItem(book); - - book.LootType = LootType.Blessed; - - addSkillItems = false; - - break; - } case 5: // Paladin - { - if (elf) { - EquipItem(new ElvenMachete()); - EquipItem(new WingedHelm()); - EquipItem(new LeafGorget()); - EquipItem(new LeafArms()); - EquipItem(new LeafChest()); - EquipItem(new LeafLegs()); - EquipItem(new ElvenBoots()); //Verify hue + if (elf) + { + EquipItem(new ElvenMachete()); + EquipItem(new WingedHelm()); + EquipItem(new LeafGorget()); + EquipItem(new LeafArms()); + EquipItem(new LeafChest()); + EquipItem(new LeafLegs()); + EquipItem(new ElvenBoots()); // Verify hue + } + else + { + EquipItem(new Broadsword()); + EquipItem(new Helmet()); + EquipItem(new PlateGorget()); + EquipItem(new RingmailArms()); + EquipItem(new RingmailChest()); + EquipItem(new RingmailLegs()); + EquipItem(new ThighBoots(0x748)); + EquipItem(new Cloak(0xCF)); + EquipItem(new BodySash(0xCF)); + } + + Spellbook book = new BookOfChivalry(); + + PackItem(book); + + book.LootType = LootType.Blessed; + + addSkillItems = false; + + break; } - else - { - EquipItem(new Broadsword()); - EquipItem(new Helmet()); - EquipItem(new PlateGorget()); - EquipItem(new RingmailArms()); - EquipItem(new RingmailChest()); - EquipItem(new RingmailLegs()); - EquipItem(new ThighBoots(0x748)); - EquipItem(new Cloak(0xCF)); - EquipItem(new BodySash(0xCF)); - } - - Spellbook book = new BookOfChivalry(); - - PackItem(book); - - book.LootType = LootType.Blessed; - - addSkillItems = false; - - break; - } case 6: // Samurai - { - addSkillItems = false; - EquipItem(new HakamaShita(0x2C3)); - EquipItem(new Hakama(0x2C3)); - EquipItem(new SamuraiTabi(0x2C3)); - EquipItem(new TattsukeHakama(0x22D)); - EquipItem(new Bokuto()); + { + addSkillItems = false; + EquipItem(new HakamaShita(0x2C3)); + EquipItem(new Hakama(0x2C3)); + EquipItem(new SamuraiTabi(0x2C3)); + EquipItem(new TattsukeHakama(0x22D)); + EquipItem(new Bokuto()); - if (elf) - EquipItem(new RavenHelm()); - else - EquipItem(new LeatherJingasa()); + if (elf) + EquipItem(new RavenHelm()); + else + EquipItem(new LeatherJingasa()); - PackItem(new Scissors()); - PackItem(new Bandage(50)); + PackItem(new Scissors()); + PackItem(new Bandage(50)); - Spellbook book = new BookOfBushido(); - PackItem(book); + Spellbook book = new BookOfBushido(); + PackItem(book); - break; - } + break; + } case 7: // Ninja - { - addSkillItems = false; - EquipItem(new Kasa()); + { + addSkillItems = false; + EquipItem(new Kasa()); - int[] hues = { 0x1A8, 0xEC, 0x99, 0x90, 0xB5, 0x336, 0x89 }; - //TODO: Verify that's ALL the hues for that above. + int[] hues = { 0x1A8, 0xEC, 0x99, 0x90, 0xB5, 0x336, 0x89 }; + // TODO: Verify that's ALL the hues for that above. - EquipItem(new TattsukeHakama(hues[Utility.Random(hues.Length)])); + EquipItem(new TattsukeHakama(hues[Utility.Random(hues.Length)])); - EquipItem(new HakamaShita(0x2C3)); - EquipItem(new NinjaTabi(0x2C3)); + EquipItem(new HakamaShita(0x2C3)); + EquipItem(new NinjaTabi(0x2C3)); - if (elf) - EquipItem(new AssassinSpike()); - else - EquipItem(new Tekagi()); + if (elf) + EquipItem(new AssassinSpike()); + else + EquipItem(new Tekagi()); - PackItem(new SmokeBomb()); + PackItem(new SmokeBomb()); - Spellbook book = new BookOfNinjitsu(); - PackItem(book); + Spellbook book = new BookOfNinjitsu(); + PackItem(book); - break; - } + break; + } } for (int i = 0; i < skills.Length; ++i) @@ -1303,449 +1293,449 @@ namespace Server.Misc switch (skill) { case SkillName.Alchemy: - { - PackItem(new Bottle(4)); - PackItem(new MortarPestle()); - - int hue = Utility.RandomPinkHue(); - - if (elf) { - if (m.Female) - EquipItem(new FemaleElvenRobe(hue)); + PackItem(new Bottle(4)); + PackItem(new MortarPestle()); + + int hue = Utility.RandomPinkHue(); + + if (elf) + { + if (m.Female) + EquipItem(new FemaleElvenRobe(hue)); + else + EquipItem(new MaleElvenRobe(hue)); + } else - EquipItem(new MaleElvenRobe(hue)); - } - else - { - EquipItem(new Robe(Utility.RandomPinkHue())); - } + { + EquipItem(new Robe(Utility.RandomPinkHue())); + } - break; - } + break; + } case SkillName.Anatomy: - { - PackItem(new Bandage(3)); - - int hue = Utility.RandomYellowHue(); - - if (elf) { - if (m.Female) - EquipItem(new FemaleElvenRobe(hue)); + PackItem(new Bandage(3)); + + int hue = Utility.RandomYellowHue(); + + if (elf) + { + if (m.Female) + EquipItem(new FemaleElvenRobe(hue)); + else + EquipItem(new MaleElvenRobe(hue)); + } else - EquipItem(new MaleElvenRobe(hue)); - } - else - { - EquipItem(new Robe(hue)); - } + { + EquipItem(new Robe(hue)); + } - break; - } + break; + } case SkillName.AnimalLore: - { - int hue = Utility.RandomBlueHue(); - - if (elf) { - EquipItem(new WildStaff()); + int hue = Utility.RandomBlueHue(); - if (m.Female) - EquipItem(new FemaleElvenRobe(hue)); + if (elf) + { + EquipItem(new WildStaff()); + + if (m.Female) + EquipItem(new FemaleElvenRobe(hue)); + else + EquipItem(new MaleElvenRobe(hue)); + } else - EquipItem(new MaleElvenRobe(hue)); - } - else - { - EquipItem(new ShepherdsCrook()); - EquipItem(new Robe(hue)); - } + { + EquipItem(new ShepherdsCrook()); + EquipItem(new Robe(hue)); + } - break; - } + break; + } case SkillName.Archery: - { - PackItem(new Arrow(25)); - - if (elf) - EquipItem(new ElvenCompositeLongbow()); - else - EquipItem(new Bow()); - - break; - } - case SkillName.ArmsLore: - { - if (elf) - switch (Utility.Random(3)) - { - case 0: - EquipItem(new Leafblade()); - break; - case 1: - EquipItem(new RuneBlade()); - break; - case 2: - EquipItem(new DiamondMace()); - break; - } - else - switch (Utility.Random(3)) - { - case 0: - EquipItem(new Kryss()); - break; - case 1: - EquipItem(new Katana()); - break; - case 2: - EquipItem(new Club()); - break; - } - - break; - } - case SkillName.Begging: - { - if (elf) - EquipItem(new WildStaff()); - else - EquipItem(new GnarledStaff()); - break; - } - case SkillName.Blacksmith: - { - PackItem(new Tongs()); - PackItem(new Pickaxe()); - PackItem(new Pickaxe()); - PackItem(new IronIngot(50)); - EquipItem(new HalfApron(Utility.RandomYellowHue())); - break; - } - case SkillName.Bushido: - { - EquipItem(new Hakama()); - EquipItem(new Kasa()); - EquipItem(new BookOfBushido()); - break; - } - case SkillName.Fletching: - { - PackItem(new Board(14)); - PackItem(new Feather(5)); - PackItem(new Shaft(5)); - break; - } - case SkillName.Camping: - { - PackItem(new Bedroll()); - PackItem(new Kindling(5)); - break; - } - case SkillName.Carpentry: - { - PackItem(new Board(10)); - PackItem(new Saw()); - EquipItem(new HalfApron(Utility.RandomYellowHue())); - break; - } - case SkillName.Cartography: - { - PackItem(new BlankMap()); - PackItem(new BlankMap()); - PackItem(new BlankMap()); - PackItem(new BlankMap()); - PackItem(new Sextant()); - break; - } - case SkillName.Cooking: - { - PackItem(new Kindling(2)); - PackItem(new RawLambLeg()); - PackItem(new RawChickenLeg()); - PackItem(new RawFishSteak()); - PackItem(new SackFlour()); - PackItem(new Pitcher(BeverageType.Water)); - break; - } - case SkillName.Chivalry: - { - if (Core.ML) - PackItem(new BookOfChivalry()); - - break; - } - case SkillName.DetectHidden: - { - EquipItem(new Cloak(0x455)); - break; - } - case SkillName.Discordance: - { - PackInstrument(); - break; - } - case SkillName.Fencing: - { - if (elf) - EquipItem(new Leafblade()); - else - EquipItem(new Kryss()); - - break; - } - case SkillName.Fishing: - { - EquipItem(new FishingPole()); - - int hue = Utility.RandomYellowHue(); - - if (elf) { - Item i = new Circlet(); - i.Hue = hue; - EquipItem(i); - } - else - { - EquipItem(new FloppyHat(hue)); - } + PackItem(new Arrow(25)); - break; - } - case SkillName.Healing: - { - PackItem(new Bandage(50)); - PackItem(new Scissors()); - break; - } - case SkillName.Herding: - { - if (elf) - EquipItem(new WildStaff()); - else - EquipItem(new ShepherdsCrook()); - - break; - } - case SkillName.Hiding: - { - EquipItem(new Cloak(0x455)); - break; - } - case SkillName.Inscribe: - { - PackItem(new BlankScroll(2)); - PackItem(new BlueBook()); - break; - } - case SkillName.ItemID: - { - if (elf) - EquipItem(new WildStaff()); - else - EquipItem(new GnarledStaff()); - break; - } - case SkillName.Lockpicking: - { - PackItem(new Lockpick(20)); - break; - } - case SkillName.Lumberjacking: - { - EquipItem(new Hatchet()); - break; - } - case SkillName.Macing: - { - if (elf) - EquipItem(new DiamondMace()); - else - EquipItem(new Club()); - - break; - } - case SkillName.Magery: - { - BagOfReagents regs = new BagOfReagents(30); - - if (!Core.AOS) - foreach (Item item in regs.Items) - item.LootType = LootType.Newbied; - - PackItem(regs); - - regs.LootType = LootType.Regular; - - PackScroll(0); - PackScroll(1); - PackScroll(2); - - Spellbook book = new Spellbook((ulong)0x382A8C38); - - EquipItem(book); - - book.LootType = LootType.Blessed; - - if (elf) - { - EquipItem(new Circlet()); - - if (m.Female) - EquipItem(new FemaleElvenRobe(Utility.RandomBlueHue())); + if (elf) + EquipItem(new ElvenCompositeLongbow()); else - EquipItem(new MaleElvenRobe(Utility.RandomBlueHue())); - } - else - { - EquipItem(new WizardsHat()); - EquipItem(new Robe(Utility.RandomBlueHue())); - } + EquipItem(new Bow()); - break; - } - case SkillName.Mining: - { - PackItem(new Pickaxe()); - break; - } - case SkillName.Musicianship: - { - PackInstrument(); - break; - } - case SkillName.Necromancy: - { - if (Core.ML) + break; + } + case SkillName.ArmsLore: { - Container regs = new BagOfNecroReagents(); + if (elf) + switch (Utility.Random(3)) + { + case 0: + EquipItem(new Leafblade()); + break; + case 1: + EquipItem(new RuneBlade()); + break; + case 2: + EquipItem(new DiamondMace()); + break; + } + else + switch (Utility.Random(3)) + { + case 0: + EquipItem(new Kryss()); + break; + case 1: + EquipItem(new Katana()); + break; + case 2: + EquipItem(new Club()); + break; + } + + break; + } + case SkillName.Begging: + { + if (elf) + EquipItem(new WildStaff()); + else + EquipItem(new GnarledStaff()); + break; + } + case SkillName.Blacksmith: + { + PackItem(new Tongs()); + PackItem(new Pickaxe()); + PackItem(new Pickaxe()); + PackItem(new IronIngot(50)); + EquipItem(new HalfApron(Utility.RandomYellowHue())); + break; + } + case SkillName.Bushido: + { + EquipItem(new Hakama()); + EquipItem(new Kasa()); + EquipItem(new BookOfBushido()); + break; + } + case SkillName.Fletching: + { + PackItem(new Board(14)); + PackItem(new Feather(5)); + PackItem(new Shaft(5)); + break; + } + case SkillName.Camping: + { + PackItem(new Bedroll()); + PackItem(new Kindling(5)); + break; + } + case SkillName.Carpentry: + { + PackItem(new Board(10)); + PackItem(new Saw()); + EquipItem(new HalfApron(Utility.RandomYellowHue())); + break; + } + case SkillName.Cartography: + { + PackItem(new BlankMap()); + PackItem(new BlankMap()); + PackItem(new BlankMap()); + PackItem(new BlankMap()); + PackItem(new Sextant()); + break; + } + case SkillName.Cooking: + { + PackItem(new Kindling(2)); + PackItem(new RawLambLeg()); + PackItem(new RawChickenLeg()); + PackItem(new RawFishSteak()); + PackItem(new SackFlour()); + PackItem(new Pitcher(BeverageType.Water)); + break; + } + case SkillName.Chivalry: + { + if (Core.ML) + PackItem(new BookOfChivalry()); + + break; + } + case SkillName.DetectHidden: + { + EquipItem(new Cloak(0x455)); + break; + } + case SkillName.Discordance: + { + PackInstrument(); + break; + } + case SkillName.Fencing: + { + if (elf) + EquipItem(new Leafblade()); + else + EquipItem(new Kryss()); + + break; + } + case SkillName.Fishing: + { + EquipItem(new FishingPole()); + + int hue = Utility.RandomYellowHue(); + + if (elf) + { + Item i = new Circlet(); + i.Hue = hue; + EquipItem(i); + } + else + { + EquipItem(new FloppyHat(hue)); + } + + break; + } + case SkillName.Healing: + { + PackItem(new Bandage(50)); + PackItem(new Scissors()); + break; + } + case SkillName.Herding: + { + if (elf) + EquipItem(new WildStaff()); + else + EquipItem(new ShepherdsCrook()); + + break; + } + case SkillName.Hiding: + { + EquipItem(new Cloak(0x455)); + break; + } + case SkillName.Inscribe: + { + PackItem(new BlankScroll(2)); + PackItem(new BlueBook()); + break; + } + case SkillName.ItemID: + { + if (elf) + EquipItem(new WildStaff()); + else + EquipItem(new GnarledStaff()); + break; + } + case SkillName.Lockpicking: + { + PackItem(new Lockpick(20)); + break; + } + case SkillName.Lumberjacking: + { + EquipItem(new Hatchet()); + break; + } + case SkillName.Macing: + { + if (elf) + EquipItem(new DiamondMace()); + else + EquipItem(new Club()); + + break; + } + case SkillName.Magery: + { + BagOfReagents regs = new BagOfReagents(30); + + if (!Core.AOS) + foreach (Item item in regs.Items) + item.LootType = LootType.Newbied; PackItem(regs); regs.LootType = LootType.Regular; + + PackScroll(0); + PackScroll(1); + PackScroll(2); + + Spellbook book = new Spellbook((ulong)0x382A8C38); + + EquipItem(book); + + book.LootType = LootType.Blessed; + + if (elf) + { + EquipItem(new Circlet()); + + if (m.Female) + EquipItem(new FemaleElvenRobe(Utility.RandomBlueHue())); + else + EquipItem(new MaleElvenRobe(Utility.RandomBlueHue())); + } + else + { + EquipItem(new WizardsHat()); + EquipItem(new Robe(Utility.RandomBlueHue())); + } + + break; } + case SkillName.Mining: + { + PackItem(new Pickaxe()); + break; + } + case SkillName.Musicianship: + { + PackInstrument(); + break; + } + case SkillName.Necromancy: + { + if (Core.ML) + { + Container regs = new BagOfNecroReagents(); - break; - } + PackItem(regs); + + regs.LootType = LootType.Regular; + } + + break; + } case SkillName.Ninjitsu: - { - EquipItem(new Hakama(0x2C3)); //Only ninjas get the hued one. - EquipItem(new Kasa()); - EquipItem(new BookOfNinjitsu()); - break; - } + { + EquipItem(new Hakama(0x2C3)); // Only ninjas get the hued one. + EquipItem(new Kasa()); + EquipItem(new BookOfNinjitsu()); + break; + } case SkillName.Parry: - { - EquipItem(new WoodenShield()); - break; - } + { + EquipItem(new WoodenShield()); + break; + } case SkillName.Peacemaking: - { - PackInstrument(); - break; - } + { + PackInstrument(); + break; + } case SkillName.Poisoning: - { - PackItem(new LesserPoisonPotion()); - PackItem(new LesserPoisonPotion()); - break; - } + { + PackItem(new LesserPoisonPotion()); + PackItem(new LesserPoisonPotion()); + break; + } case SkillName.Provocation: - { - PackInstrument(); - break; - } + { + PackInstrument(); + break; + } case SkillName.Snooping: - { - PackItem(new Lockpick(20)); - break; - } + { + PackItem(new Lockpick(20)); + break; + } case SkillName.SpiritSpeak: - { - EquipItem(new Cloak(0x455)); - break; - } + { + EquipItem(new Cloak(0x455)); + break; + } case SkillName.Stealing: - { - PackItem(new Lockpick(20)); - break; - } + { + PackItem(new Lockpick(20)); + break; + } case SkillName.Swords: - { - if (elf) - EquipItem(new RuneBlade()); - else - EquipItem(new Katana()); + { + if (elf) + EquipItem(new RuneBlade()); + else + EquipItem(new Katana()); - break; - } + break; + } case SkillName.Tactics: - { - if (elf) - EquipItem(new RuneBlade()); - else - EquipItem(new Katana()); + { + if (elf) + EquipItem(new RuneBlade()); + else + EquipItem(new Katana()); - break; - } + break; + } case SkillName.Tailoring: - { - PackItem(new BoltOfCloth()); - PackItem(new SewingKit()); - break; - } + { + PackItem(new BoltOfCloth()); + PackItem(new SewingKit()); + break; + } case SkillName.Tracking: - { - Item shoes = m_Mobile?.FindItemOnLayer(Layer.Shoes); + { + Item shoes = m_Mobile?.FindItemOnLayer(Layer.Shoes); - shoes?.Delete(); + shoes?.Delete(); - int hue = Utility.RandomYellowHue(); + int hue = Utility.RandomYellowHue(); - if (elf) - EquipItem(new ElvenBoots(hue)); - else - EquipItem(new Boots(hue)); + if (elf) + EquipItem(new ElvenBoots(hue)); + else + EquipItem(new Boots(hue)); - EquipItem(new SkinningKnife()); - break; - } + EquipItem(new SkinningKnife()); + break; + } case SkillName.Veterinary: - { - PackItem(new Bandage(5)); - PackItem(new Scissors()); - break; - } + { + PackItem(new Bandage(5)); + PackItem(new Scissors()); + break; + } case SkillName.Wrestling: - { - if (elf) - EquipItem(new LeafGloves()); - else - EquipItem(new LeatherGloves()); + { + if (elf) + EquipItem(new LeafGloves()); + else + EquipItem(new LeatherGloves()); - break; - } - } - } - - private class BadStartMessage : Timer - { - private int m_Message; - private Mobile m_Mobile; - - public BadStartMessage(Mobile m, int message) : base(TimeSpan.FromSeconds(3.5)) - { - m_Mobile = m; - m_Message = message; - Start(); - } - - protected override void OnTick() - { - m_Mobile.SendLocalizedMessage(m_Message); + break; + } } } } + + class BadStartMessage : Timer + { + private readonly int m_Message; + private readonly Mobile m_Mobile; + + public BadStartMessage(Mobile m, int message) : base(TimeSpan.FromSeconds(3.5)) + { + m_Mobile = m; + m_Message = message; + Start(); + } + + protected override void OnTick() + { + m_Mobile.SendLocalizedMessage(m_Message); + } + } } diff --git a/Projects/Scripts/Misc/Cleanup.cs b/Projects/Scripts/Misc/Cleanup.cs index 407f1d0a0..a712ae3bc 100644 --- a/Projects/Scripts/Misc/Cleanup.cs +++ b/Projects/Scripts/Misc/Cleanup.cs @@ -44,8 +44,8 @@ namespace Server.Misc validItems.Add(item1); foreach (VendorInventory inventory in house.VendorInventories) - foreach (Item subItem in inventory.Items) - validItems.Add(subItem); + foreach (Item subItem in inventory.Items) + validItems.Add(subItem); } else if (item is BankBox box) { @@ -133,11 +133,7 @@ namespace Server.Misc || item is TreasureMap || item is MessageInABottle || item is BaseArmor || item is BaseWeapon || item is BaseClothing - || item is BaseJewel && Core.AOS - - #region Champion artifacts - - || item is SkullPole + || (item is BaseJewel && Core.AOS) || item is SkullPole || item is EvilIdolSkull || item is MonsterStatuette || item is Pier @@ -154,9 +150,6 @@ namespace Server.Misc || item is WindSpirit || item is DirtPatch || item is Futon) - - #endregion - return true; return false; diff --git a/Projects/Scripts/Misc/ClientVerification.cs b/Projects/Scripts/Misc/ClientVerification.cs index 22a64f755..36896ae85 100644 --- a/Projects/Scripts/Misc/ClientVerification.cs +++ b/Projects/Scripts/Misc/ClientVerification.cs @@ -9,28 +9,28 @@ namespace Server.Misc { public class ClientVerification { - private static bool m_DetectClientRequirement = true; - private static OldClientResponse m_OldClientResponse = OldClientResponse.LenientKick; + private static readonly bool m_DetectClientRequirement = true; + private static readonly OldClientResponse m_OldClientResponse = OldClientResponse.LenientKick; - private static TimeSpan m_AgeLeniency = TimeSpan.FromDays(10); - private static TimeSpan m_GameTimeLeniency = TimeSpan.FromHours(25); + private static readonly TimeSpan m_AgeLeniency = TimeSpan.FromDays(10); + private static readonly TimeSpan m_GameTimeLeniency = TimeSpan.FromHours(25); - public static ClientVersion Required{ get; set; } + public static ClientVersion Required { get; set; } - public static bool AllowRegular{ get; set; } = true; + public static bool AllowRegular { get; set; } = true; - public static bool AllowUOTD{ get; set; } = true; + public static bool AllowUOTD { get; set; } = true; - public static bool AllowGod{ get; set; } = true; + public static bool AllowGod { get; set; } = true; - public static TimeSpan KickDelay{ get; set; } = TimeSpan.FromSeconds(20.0); + public static TimeSpan KickDelay { get; set; } = TimeSpan.FromSeconds(20.0); public static void Initialize() { EventSink.ClientVersionReceived += EventSink_ClientVersionReceived; - //ClientVersion.Required = null; - //Required = new ClientVersion( "6.0.0.0" ); + // ClientVersion.Required = null; + // Required = new ClientVersion( "6.0.0.0" ); if (m_DetectClientRequirement) { @@ -64,10 +64,10 @@ namespace Server.Misc return; if (Required != null && version < Required && (m_OldClientResponse == OldClientResponse.Kick || - m_OldClientResponse == OldClientResponse.LenientKick && + (m_OldClientResponse == OldClientResponse.LenientKick && DateTime.UtcNow - state.Mobile.CreationTime > m_AgeLeniency && state.Mobile is PlayerMobile mobile && - mobile.GameTime > m_GameTimeLeniency)) + mobile.GameTime > m_GameTimeLeniency))) { kickMessage = $"This server requires your client version be at least {Required}."; } @@ -104,7 +104,7 @@ namespace Server.Misc state.Mobile.SendMessage(0x22, kickMessage); state.Mobile.SendMessage(0x22, "You will be disconnected in {0} seconds.", KickDelay.TotalSeconds); - Timer.DelayCall(KickDelay, delegate + Timer.DelayCall(KickDelay, () => { if (state.Connection != null) { @@ -118,18 +118,18 @@ namespace Server.Misc switch (m_OldClientResponse) { case OldClientResponse.Warn: - { - state.Mobile.SendMessage(0x22, "Your client is out of date. Please update your client.", Required); - state.Mobile.SendMessage(0x22, "This server recommends that your client version be at least {0}.", - Required); - break; - } + { + state.Mobile.SendMessage(0x22, "Your client is out of date. Please update your client.", Required); + state.Mobile.SendMessage(0x22, "This server recommends that your client version be at least {0}.", + Required); + break; + } case OldClientResponse.LenientKick: case OldClientResponse.Annoy: - { - SendAnnoyGump(state.Mobile); - break; - } + { + SendAnnoyGump(state.Mobile); + break; + } } } } diff --git a/Projects/Scripts/Misc/CrashGuard.cs b/Projects/Scripts/Misc/CrashGuard.cs index 9ff027311..f45b60a28 100644 --- a/Projects/Scripts/Misc/CrashGuard.cs +++ b/Projects/Scripts/Misc/CrashGuard.cs @@ -30,8 +30,7 @@ namespace Server.Misc if (SaveBackup) Backup(); - - /*if ( Core.Service ) + /*if (Core.Service) e.Close = true; else */ if (RestartServer) @@ -44,7 +43,6 @@ namespace Server.Misc if (Email.FROM_ADDRESS != null && Email.CRASH_ADDRESS != null) Email.SendCrashEmail(filePath); - } private static string GetRoot() diff --git a/Projects/Scripts/Misc/CurrentExpansion.cs b/Projects/Scripts/Misc/CurrentExpansion.cs index 3ff96d7ed..11c203c84 100644 --- a/Projects/Scripts/Misc/CurrentExpansion.cs +++ b/Projects/Scripts/Misc/CurrentExpansion.cs @@ -1,4 +1,5 @@ using Server.Accounting; +using Server.Items; using Server.Network; namespace Server @@ -37,4 +38,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Misc/DoorGenerator.cs b/Projects/Scripts/Misc/DoorGenerator.cs index 865160c48..822b33774 100644 --- a/Projects/Scripts/Misc/DoorGenerator.cs +++ b/Projects/Scripts/Misc/DoorGenerator.cs @@ -5,7 +5,7 @@ namespace Server { public class DoorGenerator { - private static Rectangle2D[] m_BritRegions = + private static readonly Rectangle2D[] m_BritRegions = { new Rectangle2D(new Point2D(250, 750), new Point2D(775, 1330)), new Rectangle2D(new Point2D(525, 2095), new Point2D(925, 2430)), @@ -25,17 +25,17 @@ namespace Server new Rectangle2D(new Point2D(5120, 2300), new Point2D(6143, 4095)) }; - private static Rectangle2D[] m_IlshRegions = + private static readonly Rectangle2D[] m_IlshRegions = { new Rectangle2D(new Point2D(0, 0), new Point2D(288 * 8, 200 * 8)) }; - private static Rectangle2D[] m_MalasRegions = + private static readonly Rectangle2D[] m_MalasRegions = { new Rectangle2D(new Point2D(0, 0), new Point2D(320 * 8, 256 * 8)) }; - private static int[] m_SouthFrames = + private static readonly int[] m_SouthFrames = { 0x0006, 0x0008, @@ -109,7 +109,7 @@ namespace Server 0x020A }; - private static int[] m_NorthFrames = + private static readonly int[] m_NorthFrames = { 0x0006, 0x0008, @@ -182,7 +182,7 @@ namespace Server 0x020A }; - private static int[] m_EastFrames = + private static readonly int[] m_EastFrames = { 0x0007, 0x000A, @@ -256,7 +256,7 @@ namespace Server 0x0209 }; - private static int[] m_WestFrames = + private static readonly int[] m_WestFrames = { 0x0007, 0x000C, @@ -475,70 +475,70 @@ namespace Server public static void Generate(Rectangle2D region) { for (int rx = 0; rx < region.Width; ++rx) - for (int ry = 0; ry < region.Height; ++ry) - { - int vx = rx + region.X; - int vy = ry + region.Y; - - StaticTile[] tiles = m_Map.Tiles.GetStaticTiles(vx, vy); - - for (int i = 0; i < tiles.Length; ++i) + for (int ry = 0; ry < region.Height; ++ry) { - StaticTile tile = tiles[i]; + int vx = rx + region.X; + int vy = ry + region.Y; - int id = tile.ID; - int z = tile.Z; + StaticTile[] tiles = m_Map.Tiles.GetStaticTiles(vx, vy); - if (IsWestFrame(id)) + for (int i = 0; i < tiles.Length; ++i) { - if (IsEastFrame(vx + 2, vy, z)) - { - AddDoor(vx + 1, vy, z, DoorFacing.WestCW); - } - else if (IsEastFrame(vx + 3, vy, z)) - { - BaseDoor first = AddDoor(vx + 1, vy, z, DoorFacing.WestCW); - BaseDoor second = AddDoor(vx + 2, vy, z, DoorFacing.EastCCW); + StaticTile tile = tiles[i]; - if (first != null && second != null) + int id = tile.ID; + int z = tile.Z; + + if (IsWestFrame(id)) + { + if (IsEastFrame(vx + 2, vy, z)) { - first.Link = second; - second.Link = first; + AddDoor(vx + 1, vy, z, DoorFacing.WestCW); } - else + else if (IsEastFrame(vx + 3, vy, z)) { - first?.Delete(); + BaseDoor first = AddDoor(vx + 1, vy, z, DoorFacing.WestCW); + BaseDoor second = AddDoor(vx + 2, vy, z, DoorFacing.EastCCW); - second?.Delete(); + if (first != null && second != null) + { + first.Link = second; + second.Link = first; + } + else + { + first?.Delete(); + + second?.Delete(); + } } } - } - else if (IsNorthFrame(id)) - { - if (IsSouthFrame(vx, vy + 2, z)) + else if (IsNorthFrame(id)) { - AddDoor(vx, vy + 1, z, DoorFacing.SouthCW); - } - else if (IsSouthFrame(vx, vy + 3, z)) - { - BaseDoor first = AddDoor(vx, vy + 1, z, DoorFacing.NorthCCW); - BaseDoor second = AddDoor(vx, vy + 2, z, DoorFacing.SouthCW); - - if (first != null && second != null) + if (IsSouthFrame(vx, vy + 2, z)) { - first.Link = second; - second.Link = first; + AddDoor(vx, vy + 1, z, DoorFacing.SouthCW); } - else + else if (IsSouthFrame(vx, vy + 3, z)) { - first?.Delete(); + BaseDoor first = AddDoor(vx, vy + 1, z, DoorFacing.NorthCCW); + BaseDoor second = AddDoor(vx, vy + 2, z, DoorFacing.SouthCW); - second?.Delete(); + if (first != null && second != null) + { + first.Link = second; + second.Link = first; + } + else + { + first?.Delete(); + + second?.Delete(); + } } } } } - } } } } diff --git a/Projects/Scripts/Misc/Email.cs b/Projects/Scripts/Misc/Email.cs index dd9b05329..7e8c77865 100644 --- a/Projects/Scripts/Misc/Email.cs +++ b/Projects/Scripts/Misc/Email.cs @@ -1,10 +1,10 @@ +using System; +using System.IO; +using System.Threading.Tasks; using MailKit.Net.Smtp; using MimeKit; using Server.Accounting; using Server.Engines.Help; -using System; -using System.IO; -using System.Threading.Tasks; namespace Server.Misc { @@ -67,7 +67,6 @@ namespace Server.Misc TextBody = writer.ToString(), HtmlBody = null }.ToMessageBody(); - } SendAsync(message); } diff --git a/Projects/Scripts/Misc/Emitter.cs b/Projects/Scripts/Misc/Emitter.cs index 17088f615..b6f7f32bd 100644 --- a/Projects/Scripts/Misc/Emitter.cs +++ b/Projects/Scripts/Misc/Emitter.cs @@ -10,24 +10,23 @@ namespace Server private string m_AssemblyName; private AppDomain m_AppDomain; - private AssemblyBuilder m_AssemblyBuilder; - private ModuleBuilder m_ModuleBuilder; + private readonly AssemblyBuilder m_AssemblyBuilder; + private readonly ModuleBuilder m_ModuleBuilder; - public AssemblyEmitter( string assemblyName ) + public AssemblyEmitter(string assemblyName) { m_AssemblyName = assemblyName; m_AppDomain = AppDomain.CurrentDomain; m_AssemblyBuilder = AssemblyBuilder.DefineDynamicAssembly( - new AssemblyName( assemblyName ), - AssemblyBuilderAccess.Run - ); + new AssemblyName(assemblyName), + AssemblyBuilderAccess.Run); m_ModuleBuilder = m_AssemblyBuilder.DefineDynamicModule(assemblyName); } - public TypeBuilder DefineType( string typeName, TypeAttributes attrs, Type parentType ) => m_ModuleBuilder.DefineType( typeName, attrs, parentType ); + public TypeBuilder DefineType(string typeName, TypeAttributes attrs, Type parentType) => m_ModuleBuilder.DefineType(typeName, attrs, parentType); } public class MethodEmitter @@ -40,13 +39,13 @@ namespace Server private class CallInfo { - public Type type; - public MethodInfo method; + public readonly Type type; + public readonly MethodInfo method; public int index; - public ParameterInfo[] parms; + public readonly ParameterInfo[] parms; - public CallInfo( Type type, MethodInfo method ) + public CallInfo(Type type, MethodInfo method) { this.type = type; this.method = method; @@ -55,14 +54,14 @@ namespace Server } } - private Stack m_Stack; - private Stack m_Calls; + private readonly Stack m_Stack; + private readonly Stack m_Calls; - private Dictionary> m_Temps; + private readonly Dictionary> m_Temps; public MethodBuilder Method { get; private set; } - public MethodEmitter( TypeBuilder typeBuilder ) + public MethodEmitter(TypeBuilder typeBuilder) { Type = typeBuilder; @@ -72,59 +71,59 @@ namespace Server m_Calls = new Stack(); } - public void Define( string name, MethodAttributes attr, Type returnType, Type[] parms ) + public void Define(string name, MethodAttributes attr, Type returnType, Type[] parms) { - Method = Type.DefineMethod( name, attr, returnType, parms ); + Method = Type.DefineMethod(name, attr, returnType, parms); Generator = Method.GetILGenerator(); m_ArgumentTypes = parms; } - public LocalBuilder CreateLocal( Type localType ) => Generator.DeclareLocal( localType ); + public LocalBuilder CreateLocal(Type localType) => Generator.DeclareLocal(localType); - public LocalBuilder AcquireTemp( Type localType ) + public LocalBuilder AcquireTemp(Type localType) { - if (!m_Temps.TryGetValue( localType, out Queue list )) + if (!m_Temps.TryGetValue(localType, out Queue list)) m_Temps[localType] = list = new Queue(); - return list.Count > 0 ? list.Dequeue() : CreateLocal( localType ); + return list.Count > 0 ? list.Dequeue() : CreateLocal(localType); } - public void ReleaseTemp( LocalBuilder local ) + public void ReleaseTemp(LocalBuilder local) { if (local.LocalType == null) return; - if (!m_Temps.TryGetValue( local.LocalType, out Queue list )) + if (!m_Temps.TryGetValue(local.LocalType, out Queue list)) m_Temps[local.LocalType] = list = new Queue(); - list.Enqueue( local ); + list.Enqueue(local); } - public void Branch( Label label ) + public void Branch(Label label) { - Generator.Emit( OpCodes.Br, label ); + Generator.Emit(OpCodes.Br, label); } - public void BranchIfFalse( Label label ) + public void BranchIfFalse(Label label) { - Pop( typeof( object ) ); + Pop(typeof(object)); - Generator.Emit( OpCodes.Brfalse, label ); + Generator.Emit(OpCodes.Brfalse, label); } - public void BranchIfTrue( Label label ) + public void BranchIfTrue(Label label) { - Pop( typeof( object ) ); + Pop(typeof(object)); - Generator.Emit( OpCodes.Brtrue, label ); + Generator.Emit(OpCodes.Brtrue, label); } public Label CreateLabel() => Generator.DefineLabel(); - public void MarkLabel( Label label ) + public void MarkLabel(Label label) { - Generator.MarkLabel( label ); + Generator.MarkLabel(label); } public void Pop() @@ -132,323 +131,323 @@ namespace Server m_Stack.Pop(); } - public void Pop( Type expected ) + public void Pop(Type expected) { - if ( expected == null ) - throw new InvalidOperationException( "Expected type cannot be null." ); + if (expected == null) + throw new InvalidOperationException("Expected type cannot be null."); Type onStack = m_Stack.Pop(); - if ( expected == typeof( bool ) ) - expected = typeof( int ); + if (expected == typeof(bool)) + expected = typeof(int); - if ( onStack == typeof( bool ) ) - onStack = typeof( int ); + if (onStack == typeof(bool)) + onStack = typeof(int); - if ( !expected.IsAssignableFrom( onStack ) ) - throw new InvalidOperationException( "Unexpected stack state." ); + if (!expected.IsAssignableFrom(onStack)) + throw new InvalidOperationException("Unexpected stack state."); } - public void Push( Type type ) + public void Push(Type type) { - m_Stack.Push( type ); + m_Stack.Push(type); } public void Return() { - if ( m_Stack.Count != ( Method.ReturnType == typeof( void ) ? 0 : 1 ) ) - throw new InvalidOperationException( "Stack return mismatch." ); + if (m_Stack.Count != (Method.ReturnType == typeof(void) ? 0 : 1)) + throw new InvalidOperationException("Stack return mismatch."); - Generator.Emit( OpCodes.Ret ); + Generator.Emit(OpCodes.Ret); } public void LoadNull() { - LoadNull( typeof( object ) ); + LoadNull(typeof(object)); } - public void LoadNull( Type type ) + public void LoadNull(Type type) { - Push( type ); + Push(type); - Generator.Emit( OpCodes.Ldnull ); + Generator.Emit(OpCodes.Ldnull); } - public void Load( string value ) + public void Load(string value) { - Push( typeof( string ) ); + Push(typeof(string)); - if ( value != null ) - Generator.Emit( OpCodes.Ldstr, value ); + if (value != null) + Generator.Emit(OpCodes.Ldstr, value); else - Generator.Emit( OpCodes.Ldnull ); + Generator.Emit(OpCodes.Ldnull); } - public void Load( Enum value ) + public void Load(Enum value) { - int toLoad = ((IConvertible)value).ToInt32( null ); - Load( toLoad ); + int toLoad = ((IConvertible)value).ToInt32(null); + Load(toLoad); Pop(); - Push( value.GetType() ); + Push(value.GetType()); } - public void Load( long value ) + public void Load(long value) { - Push( typeof( long ) ); + Push(typeof(long)); - Generator.Emit( OpCodes.Ldc_I8, value ); + Generator.Emit(OpCodes.Ldc_I8, value); } - public void Load( float value ) + public void Load(float value) { - Push( typeof( float ) ); + Push(typeof(float)); - Generator.Emit( OpCodes.Ldc_R4, value ); + Generator.Emit(OpCodes.Ldc_R4, value); } - public void Load( double value ) + public void Load(double value) { - Push( typeof( double ) ); + Push(typeof(double)); - Generator.Emit( OpCodes.Ldc_R8, value ); + Generator.Emit(OpCodes.Ldc_R8, value); } - public void Load( char value ) + public void Load(char value) { - Load( (int) value ); + Load((int)value); Pop(); - Push( typeof( char ) ); + Push(typeof(char)); } - public void Load( bool value ) + public void Load(bool value) { - Push( typeof( bool ) ); + Push(typeof(bool)); - if ( value ) - Generator.Emit( OpCodes.Ldc_I4_1 ); + if (value) + Generator.Emit(OpCodes.Ldc_I4_1); else - Generator.Emit( OpCodes.Ldc_I4_0 ); + Generator.Emit(OpCodes.Ldc_I4_0); } - public void Load( int value ) + public void Load(int value) { - Push( typeof( int ) ); + Push(typeof(int)); - switch ( value ) + switch (value) { case -1: - Generator.Emit( OpCodes.Ldc_I4_M1 ); + Generator.Emit(OpCodes.Ldc_I4_M1); break; case 0: - Generator.Emit( OpCodes.Ldc_I4_0 ); + Generator.Emit(OpCodes.Ldc_I4_0); break; case 1: - Generator.Emit( OpCodes.Ldc_I4_1 ); + Generator.Emit(OpCodes.Ldc_I4_1); break; case 2: - Generator.Emit( OpCodes.Ldc_I4_2 ); + Generator.Emit(OpCodes.Ldc_I4_2); break; case 3: - Generator.Emit( OpCodes.Ldc_I4_3 ); + Generator.Emit(OpCodes.Ldc_I4_3); break; case 4: - Generator.Emit( OpCodes.Ldc_I4_4 ); + Generator.Emit(OpCodes.Ldc_I4_4); break; case 5: - Generator.Emit( OpCodes.Ldc_I4_5 ); + Generator.Emit(OpCodes.Ldc_I4_5); break; case 6: - Generator.Emit( OpCodes.Ldc_I4_6 ); + Generator.Emit(OpCodes.Ldc_I4_6); break; case 7: - Generator.Emit( OpCodes.Ldc_I4_7 ); + Generator.Emit(OpCodes.Ldc_I4_7); break; case 8: - Generator.Emit( OpCodes.Ldc_I4_8 ); + Generator.Emit(OpCodes.Ldc_I4_8); break; default: - if ( value >= sbyte.MinValue && value <= sbyte.MaxValue ) - Generator.Emit( OpCodes.Ldc_I4_S, (sbyte) value ); + if (value >= sbyte.MinValue && value <= sbyte.MaxValue) + Generator.Emit(OpCodes.Ldc_I4_S, (sbyte)value); else - Generator.Emit( OpCodes.Ldc_I4, value ); + Generator.Emit(OpCodes.Ldc_I4, value); break; } } - public void LoadField( FieldInfo field ) + public void LoadField(FieldInfo field) { - Pop( field.DeclaringType ); + Pop(field.DeclaringType); - Push( field.FieldType ); + Push(field.FieldType); - Generator.Emit( OpCodes.Ldfld, field ); + Generator.Emit(OpCodes.Ldfld, field); } - public void LoadLocal( LocalBuilder local ) + public void LoadLocal(LocalBuilder local) { - Push( local.LocalType ); + Push(local.LocalType); int index = local.LocalIndex; - switch ( index ) + switch (index) { case 0: - Generator.Emit( OpCodes.Ldloc_0 ); + Generator.Emit(OpCodes.Ldloc_0); break; case 1: - Generator.Emit( OpCodes.Ldloc_1 ); + Generator.Emit(OpCodes.Ldloc_1); break; case 2: - Generator.Emit( OpCodes.Ldloc_2 ); + Generator.Emit(OpCodes.Ldloc_2); break; case 3: - Generator.Emit( OpCodes.Ldloc_3 ); + Generator.Emit(OpCodes.Ldloc_3); break; default: - if ( index >= byte.MinValue && index <= byte.MinValue ) - Generator.Emit( OpCodes.Ldloc_S, (byte) index ); + if (index >= byte.MinValue && index <= byte.MinValue) + Generator.Emit(OpCodes.Ldloc_S, (byte)index); else - Generator.Emit( OpCodes.Ldloc, (short) index ); + Generator.Emit(OpCodes.Ldloc, (short)index); break; } } - public void StoreLocal( LocalBuilder local ) + public void StoreLocal(LocalBuilder local) { - Pop( local.LocalType ); + Pop(local.LocalType); - Generator.Emit( OpCodes.Stloc, local ); + Generator.Emit(OpCodes.Stloc, local); } - public void LoadArgument( int index ) + public void LoadArgument(int index) { - if ( index > 0 ) - Push( m_ArgumentTypes[index - 1] ); + if (index > 0) + Push(m_ArgumentTypes[index - 1]); else - Push( Type ); + Push(Type); - switch ( index ) + switch (index) { case 0: - Generator.Emit( OpCodes.Ldarg_0 ); + Generator.Emit(OpCodes.Ldarg_0); break; case 1: - Generator.Emit( OpCodes.Ldarg_1 ); + Generator.Emit(OpCodes.Ldarg_1); break; case 2: - Generator.Emit( OpCodes.Ldarg_2 ); + Generator.Emit(OpCodes.Ldarg_2); break; case 3: - Generator.Emit( OpCodes.Ldarg_3 ); + Generator.Emit(OpCodes.Ldarg_3); break; default: - if ( index >= byte.MinValue && index <= byte.MaxValue ) - Generator.Emit( OpCodes.Ldarg_S, (byte) index ); + if (index >= byte.MinValue && index <= byte.MaxValue) + Generator.Emit(OpCodes.Ldarg_S, (byte)index); else - Generator.Emit( OpCodes.Ldarg, (short) index ); + Generator.Emit(OpCodes.Ldarg, (short)index); break; } } - public void CastAs( Type type ) + public void CastAs(Type type) { - Pop( typeof( object ) ); - Push( type ); + Pop(typeof(object)); + Push(type); - Generator.Emit( OpCodes.Isinst, type ); + Generator.Emit(OpCodes.Isinst, type); } public void Neg() { - Pop( typeof( int ) ); + Pop(typeof(int)); - Push( typeof( int ) ); + Push(typeof(int)); - Generator.Emit( OpCodes.Neg ); + Generator.Emit(OpCodes.Neg); } - public void Compare( OpCode opCode ) + public void Compare(OpCode opCode) { Pop(); Pop(); - Push( typeof( int ) ); + Push(typeof(int)); - Generator.Emit( opCode ); + Generator.Emit(opCode); } public void LogicalNot() { - Pop( typeof( int ) ); + Pop(typeof(int)); - Push( typeof( int ) ); + Push(typeof(int)); - Generator.Emit( OpCodes.Ldc_I4_0 ); - Generator.Emit( OpCodes.Ceq ); + Generator.Emit(OpCodes.Ldc_I4_0); + Generator.Emit(OpCodes.Ceq); } public void Xor() { - Pop( typeof( int ) ); - Pop( typeof( int ) ); + Pop(typeof(int)); + Pop(typeof(int)); - Push( typeof( int ) ); + Push(typeof(int)); - Generator.Emit( OpCodes.Xor ); + Generator.Emit(OpCodes.Xor); } public Type Active => m_Stack.Peek(); - public void Chain( Property prop ) + public void Chain(Property prop) { - for ( int i = 0; i < prop.Chain.Length; ++i ) - Call( prop.Chain[i].GetGetMethod() ); + for (int i = 0; i < prop.Chain.Length; ++i) + Call(prop.Chain[i].GetGetMethod()); } - public void Call( MethodInfo method ) + public void Call(MethodInfo method) { - BeginCall( method ); + BeginCall(method); CallInfo call = m_Calls.Peek(); - if ( call.parms.Length > 0 ) - throw new InvalidOperationException( "Method requires parameters." ); + if (call.parms.Length > 0) + throw new InvalidOperationException("Method requires parameters."); FinishCall(); } public delegate void Callback(); - public bool CompareTo( int sign, Callback argGenerator ) + public bool CompareTo(int sign, Callback argGenerator) { Type active = Active; - MethodInfo compareTo = active.GetMethod( "CompareTo", new[] { active } ); + MethodInfo compareTo = active.GetMethod("CompareTo", new[] { active }); - if ( compareTo == null ) + if (compareTo == null) { /* This gets a little tricky... * @@ -475,25 +474,25 @@ namespace Server Type[] ifaces = active.FindInterfaces((type, obj) => type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IComparable<>) - && type.GetGenericArguments()[0].IsAssignableFrom(active), null ); + && type.GetGenericArguments()[0].IsAssignableFrom(active), null); - if ( ifaces.Length > 0 ) + if (ifaces.Length > 0) { - compareTo = ifaces[0].GetMethod( "CompareTo", new[] { active } ); + compareTo = ifaces[0].GetMethod("CompareTo", new[] { active }); } else { - ifaces = active.FindInterfaces((type, obj) => type == typeof(IComparable), null ); + ifaces = active.FindInterfaces((type, obj) => type == typeof(IComparable), null); - if ( ifaces.Length > 0 ) - compareTo = ifaces[0].GetMethod( "CompareTo", new[] { active } ); + if (ifaces.Length > 0) + compareTo = ifaces[0].GetMethod("CompareTo", new[] { active }); } } - if ( compareTo == null ) + if (compareTo == null) return false; - if ( !active.IsValueType ) + if (!active.IsValueType) { /* This object is a reference type, so we have to make it behave * @@ -503,23 +502,23 @@ namespace Server * */ - LocalBuilder aValue = AcquireTemp( active ); - LocalBuilder bValue = AcquireTemp( active ); + LocalBuilder aValue = AcquireTemp(active); + LocalBuilder bValue = AcquireTemp(active); - StoreLocal( aValue ); + StoreLocal(aValue); argGenerator(); - StoreLocal( bValue ); + StoreLocal(bValue); - /* if ( aValue == null ) + /* if (aValue == null) * { - * if ( bValue == null ) + * if (bValue == null) * v = 0; * else * v = +1; * } - * else if ( bValue == null ) + * else if (bValue == null) * { * v = -1; * } @@ -533,65 +532,65 @@ namespace Server Label aNotNull = CreateLabel(); - LoadLocal( aValue ); - BranchIfTrue( aNotNull ); - // if ( aValue == null ) + LoadLocal(aValue); + BranchIfTrue(aNotNull); + // if (aValue == null) { Label bNotNull = CreateLabel(); - LoadLocal( bValue ); - BranchIfTrue( bNotNull ); - // if ( bValue == null ) + LoadLocal(bValue); + BranchIfTrue(bNotNull); + // if (bValue == null) { - Load( 0 ); - Pop( typeof( int ) ); - Branch( store ); + Load(0); + Pop(typeof(int)); + Branch(store); } - MarkLabel( bNotNull ); + MarkLabel(bNotNull); // else { - Load( sign ); - Pop( typeof( int ) ); - Branch( store ); + Load(sign); + Pop(typeof(int)); + Branch(store); } } - MarkLabel( aNotNull ); + MarkLabel(aNotNull); // else { Label bNotNull = CreateLabel(); - LoadLocal( bValue ); - BranchIfTrue( bNotNull ); + LoadLocal(bValue); + BranchIfTrue(bNotNull); // bValue == null { - Load( -sign ); - Pop( typeof( int ) ); - Branch( store ); + Load(-sign); + Pop(typeof(int)); + Branch(store); } - MarkLabel( bNotNull ); + MarkLabel(bNotNull); // else { - LoadLocal( aValue ); - BeginCall( compareTo ); + LoadLocal(aValue); + BeginCall(compareTo); - LoadLocal( bValue ); + LoadLocal(bValue); ArgumentPushed(); FinishCall(); - if ( sign == -1 ) + if (sign == -1) Neg(); } } - MarkLabel( store ); + MarkLabel(store); - ReleaseTemp( aValue ); - ReleaseTemp( bValue ); + ReleaseTemp(aValue); + ReleaseTemp(bValue); } else { - BeginCall( compareTo ); + BeginCall(compareTo); argGenerator(); @@ -599,32 +598,32 @@ namespace Server FinishCall(); - if ( sign == -1 ) + if (sign == -1) Neg(); } return true; } - public void BeginCall( MethodInfo method ) + public void BeginCall(MethodInfo method) { Type type; - if ( ( method.CallingConvention & CallingConventions.HasThis ) != 0 ) + if ((method.CallingConvention & CallingConventions.HasThis) != 0) type = m_Stack.Peek(); else type = method.DeclaringType; - m_Calls.Push( new CallInfo( type, method ) ); + m_Calls.Push(new CallInfo(type, method)); - if ( type.IsValueType ) + if (type.IsValueType) { - LocalBuilder temp = AcquireTemp( type ); + LocalBuilder temp = AcquireTemp(type); - Generator.Emit( OpCodes.Stloc, temp ); - Generator.Emit( OpCodes.Ldloca, temp ); + Generator.Emit(OpCodes.Stloc, temp); + Generator.Emit(OpCodes.Ldloca, temp); - ReleaseTemp( temp ); + ReleaseTemp(temp); } } @@ -632,22 +631,22 @@ namespace Server { CallInfo call = m_Calls.Pop(); - if ( ( call.type.IsValueType || call.type.IsByRef ) && call.method.DeclaringType != call.type ) - Generator.Emit( OpCodes.Constrained, call.type ); + if ((call.type.IsValueType || call.type.IsByRef) && call.method.DeclaringType != call.type) + Generator.Emit(OpCodes.Constrained, call.type); - if ( call.method.DeclaringType?.IsValueType == true || call.method.IsStatic ) - Generator.Emit( OpCodes.Call, call.method ); + if (call.method.DeclaringType?.IsValueType == true || call.method.IsStatic) + Generator.Emit(OpCodes.Call, call.method); else - Generator.Emit( OpCodes.Callvirt, call.method ); + Generator.Emit(OpCodes.Callvirt, call.method); - for ( int i = call.parms.Length - 1; i >= 0; --i ) - Pop( call.parms[i].ParameterType ); + for (int i = call.parms.Length - 1; i >= 0; --i) + Pop(call.parms[i].ParameterType); - if ( ( call.method.CallingConvention & CallingConventions.HasThis ) != 0 ) - Pop( call.method.DeclaringType ); + if ((call.method.CallingConvention & CallingConventions.HasThis) != 0) + Pop(call.method.DeclaringType); - if ( call.method.ReturnType != typeof( void ) ) - Push( call.method.ReturnType ); + if (call.method.ReturnType != typeof(void)) + Push(call.method.ReturnType); } public void ArgumentPushed() @@ -658,11 +657,11 @@ namespace Server Type argumentType = m_Stack.Peek(); - if ( !parm.ParameterType.IsAssignableFrom( argumentType ) ) - throw new InvalidOperationException( "Parameter type mismatch." ); + if (!parm.ParameterType.IsAssignableFrom(argumentType)) + throw new InvalidOperationException("Parameter type mismatch."); - if ( argumentType.IsValueType && !parm.ParameterType.IsValueType ) - Generator.Emit( OpCodes.Box, argumentType ); + if (argumentType.IsValueType && !parm.ParameterType.IsValueType) + Generator.Emit(OpCodes.Box, argumentType); } } } diff --git a/Projects/Scripts/Misc/Fastwalk.cs b/Projects/Scripts/Misc/Fastwalk.cs index a9861974c..a076990d2 100644 --- a/Projects/Scripts/Misc/Fastwalk.cs +++ b/Projects/Scripts/Misc/Fastwalk.cs @@ -6,11 +6,11 @@ namespace Server.Misc // As of B36 PlayerMobile implements movement packet throttling which more reliably controls movement speeds public static class Fastwalk { - private static int MaxSteps = 4; // Maximum number of queued steps until fastwalk is detected - private static bool Enabled = false; // Is fastwalk detection enabled? - private static bool UOTDOverride = false; // Should UO:TD clients not be checked for fastwalk? + private static readonly int MaxSteps = 4; // Maximum number of queued steps until fastwalk is detected + private static readonly bool Enabled = false; // Is fastwalk detection enabled? + private static readonly bool UOTDOverride = false; // Should UO:TD clients not be checked for fastwalk? - private static AccessLevel + private static readonly AccessLevel AccessOverride = AccessLevel.GameMaster; // Anyone with this or higher access level is not checked for fastwalk public static void Initialize() @@ -26,7 +26,7 @@ namespace Server.Misc public static void OnFastWalk(FastWalkEventArgs e) { - e.Blocked = true; //disallow this fastwalk + e.Blocked = true; // disallow this fastwalk Console.WriteLine("Client: {0}: Fast movement detected (name={1})", e.NetState, e.NetState.Mobile.Name); } } diff --git a/Projects/Scripts/Misc/Geometry.cs b/Projects/Scripts/Misc/Geometry.cs index ff3fccdde..dc7469e35 100644 --- a/Projects/Scripts/Misc/Geometry.cs +++ b/Projects/Scripts/Misc/Geometry.cs @@ -211,11 +211,11 @@ namespace Server.Misc Quadrant = quadrant; } - public Point2D Point{ get; } + public Point2D Point { get; } - public int Angle{ get; } + public int Angle { get; } - public int Quadrant{ get; } + public int Quadrant { get; } } } } \ No newline at end of file diff --git a/Projects/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs b/Projects/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs index f176ca4c3..ab76717f1 100644 --- a/Projects/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs +++ b/Projects/Scripts/Misc/Gifts/Winter2004/LightOfTheWinterSolstice.cs @@ -3,7 +3,7 @@ namespace Server.Items [Flippable(0x236E, 0x2371)] public class LightOfTheWinterSolstice : Item { - private static string[] m_StaffNames = + private static readonly string[] m_StaffNames = { "Aenima", "Alkiser", @@ -12,14 +12,14 @@ namespace Server.Items "Krrios", "Mark", "Merlin", - "Merlix", //LordMerlix + "Merlix", // LordMerlix "Phantom", "Phenos", "psz", "Ryan", "Quantos", - "Outkast", //TheOutkastDev - "V", //Admin_V + "Outkast", // TheOutkastDev + "V", // Admin_V "Zippy" }; @@ -39,7 +39,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public string Dipper{ get; set; } + public string Dipper { get; set; } public override void OnSingleClick(Mobile from) { @@ -75,15 +75,15 @@ namespace Server.Items switch (version) { case 1: - { - Dipper = reader.ReadString(); - break; - } + { + Dipper = reader.ReadString(); + break; + } case 0: - { - Dipper = m_StaffNames[Utility.Random(m_StaffNames.Length)]; - break; - } + { + Dipper = m_StaffNames[Utility.Random(m_StaffNames.Length)]; + break; + } } if (Dipper != null) diff --git a/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs b/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs index 83da5427e..a7e1b0cfa 100644 --- a/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs +++ b/Projects/Scripts/Misc/Gifts/Winter2004/Mistletoe.cs @@ -117,8 +117,8 @@ namespace Server.Items private class MistletoeAddonGump : Gump { - private MistletoeAddon m_Addon; - private Mobile m_From; + private readonly MistletoeAddon m_Addon; + private readonly Mobile m_From; public MistletoeAddonGump(Mobile from, MistletoeAddon addon) : base(150, 50) { @@ -282,9 +282,9 @@ namespace Server.Items private class MistletoeDeedGump : Gump { - private MistletoeDeed m_Deed; - private Mobile m_From; - private Point3D m_Loc; + private readonly MistletoeDeed m_Deed; + private readonly Mobile m_From; + private readonly Point3D m_Loc; public MistletoeDeedGump(Mobile from, Point3D loc, MistletoeDeed deed) : base(150, 50) { diff --git a/Projects/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs b/Projects/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs index 38787bade..a46c2293b 100644 --- a/Projects/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs +++ b/Projects/Scripts/Misc/Gifts/Winter2004/PileOfGlacialSnow.cs @@ -64,7 +64,6 @@ namespace Server.Items { from.SendLocalizedMessage(1010097); // You cannot use this while mounted. } - else if (from.CanBeginAction()) { from.SendLocalizedMessage(1005575); // You carefully pack the snow into a ball... @@ -78,7 +77,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_From; + private readonly Mobile m_From; public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0)) => m_From = from; @@ -147,4 +146,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Misc/Gifts/Winter2004/SnowPile.cs b/Projects/Scripts/Misc/Gifts/Winter2004/SnowPile.cs index 96b7a525a..af402e698 100644 --- a/Projects/Scripts/Misc/Gifts/Winter2004/SnowPile.cs +++ b/Projects/Scripts/Misc/Gifts/Winter2004/SnowPile.cs @@ -50,7 +50,6 @@ namespace Server.Items { from.SendLocalizedMessage(1010097); // You cannot use this while mounted. } - else if (from.CanBeginAction()) { from.SendLocalizedMessage(1005575); // You carefully pack the snow into a ball... @@ -64,7 +63,7 @@ namespace Server.Items private class InternalTimer : Timer { - private Mobile m_From; + private readonly Mobile m_From; public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0)) => m_From = from; @@ -133,4 +132,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Misc/Guild.cs b/Projects/Scripts/Misc/Guild.cs index c01b0aefd..a87f6089c 100644 --- a/Projects/Scripts/Misc/Guild.cs +++ b/Projects/Scripts/Misc/Guild.cs @@ -9,8 +9,6 @@ using Server.Targeting; namespace Server.Guilds { - #region Ranks - [Flags] public enum RankFlags { @@ -34,13 +32,13 @@ namespace Server.Guilds { public static RankDefinition[] Ranks = { - new RankDefinition(1062963, 0, RankFlags.None), //Ronin - new RankDefinition(1062962, 1, RankFlags.Member), //Member + new RankDefinition(1062963, 0, RankFlags.None), // Ronin + new RankDefinition(1062962, 1, RankFlags.Member), // Member new RankDefinition(1062961, 2, RankFlags.Member | RankFlags.RemovePlayers | RankFlags.CanInvitePlayer | RankFlags.CanSetGuildTitle | - RankFlags.CanPromoteDemote), //Emmissary - new RankDefinition(1062960, 3, RankFlags.Member | RankFlags.ControlWarStatus), //Warlord - new RankDefinition(1062959, 4, RankFlags.All) //Leader + RankFlags.CanPromoteDemote), // Emmissary + new RankDefinition(1062960, 3, RankFlags.Member | RankFlags.ControlWarStatus), // Warlord + new RankDefinition(1062959, 4, RankFlags.All) // Leader }; public RankDefinition(TextDefinition name, int rank, RankFlags flags) @@ -54,11 +52,11 @@ namespace Server.Guilds public static RankDefinition Member => Ranks[1]; public static RankDefinition Lowest => Ranks[0]; - public TextDefinition Name{ get; } + public TextDefinition Name { get; } - public int Rank{ get; } + public int Rank { get; } - public RankFlags Flags{ get; private set; } + public RankFlags Flags { get; private set; } public bool GetFlag(RankFlags flag) => (Flags & flag) != 0; @@ -71,15 +69,11 @@ namespace Server.Guilds } } - #endregion - - #region Alliances - public class AllianceInfo { private Guild m_Leader; - private List m_Members; - private List m_PendingMembers; + private readonly List m_Members; + private readonly List m_PendingMembers; public AllianceInfo(Guild leader, string name, Guild partner) { @@ -103,21 +97,21 @@ namespace Server.Guilds switch (version) { case 0: - { - Name = reader.ReadString(); - m_Leader = reader.ReadGuild() as Guild; + { + Name = reader.ReadString(); + m_Leader = reader.ReadGuild() as Guild; - m_Members = reader.ReadStrongGuildList(); - m_PendingMembers = reader.ReadStrongGuildList(); + m_Members = reader.ReadStrongGuildList(); + m_PendingMembers = reader.ReadStrongGuildList(); - break; - } + break; + } } } - public static Dictionary Alliances{ get; } = new Dictionary(); + public static Dictionary Alliances { get; } = new Dictionary(); - public string Name{ get; } + public string Name { get; } public Guild Leader { @@ -172,7 +166,7 @@ namespace Server.Guilds public void Serialize(IGenericWriter writer) { - writer.Write(0); //Version + writer.Write(0); // Version writer.Write(Name); writer.Write(m_Leader); @@ -209,7 +203,7 @@ namespace Server.Guilds { if (m_PendingMembers.Contains(g)) m_PendingMembers.Remove(g); - if (m_Members.Contains(g)) //Sanity, just incase someone with a custom script adds a character to BOTH arrays + if (m_Members.Contains(g)) // Sanity, just incase someone with a custom script adds a character to BOTH arrays { m_Members.Remove(g); g.InvalidateMemberProperties(); @@ -218,9 +212,9 @@ namespace Server.Guilds AllianceMessage(1070764, g.Name); // A Guild has left your Alliance: ~1_GUILDNAME~ } - //g.Alliance = null; //NO G.Alliance call here. Set the Guild's Alliance to null, if you JUST use RemoveGuild, it removes it from the alliance, but doesn't remove the link from the guild to the alliance. setting g.Alliance will call this method. - //to check on OSI: have 3 guilds, make 2 of them a member, one pending. remove one of the memebers. alliance still exist? - //ANSWER: NO + // g.Alliance = null; //NO G.Alliance call here. Set the Guild's Alliance to null, if you JUST use RemoveGuild, it removes it from the alliance, but doesn't remove the link from the guild to the alliance. setting g.Alliance will call this method. + // to check on OSI: have 3 guilds, make 2 of them a member, one pending. remove one of the memebers. alliance still exist? + // ANSWER: NO if (g == m_Leader) CalculateAllianceLeader(); @@ -260,7 +254,7 @@ namespace Server.Guilds public class AllianceRosterGump : GuildDiplomacyGump { - private AllianceInfo m_Alliance; + private readonly AllianceInfo m_Alliance; public AllianceRosterGump(PlayerMobile pm, Guild g, AllianceInfo alliance) : base(pm, g, true, "", 0, alliance.m_Members, alliance.Name) => @@ -279,13 +273,11 @@ namespace Server.Guilds public override void OnResponse(NetState sender, RelayInfo info) { - if (info.ButtonID != 8) //So that they can't get to the AdvancedSearch button + if (info.ButtonID != 8) // So that they can't get to the AdvancedSearch button base.OnResponse(sender, info); } } - #region Alliance[Text]Message(...) - public void AllianceMessage(int num, bool append, string format, params object[] args) { AllianceMessage(num, append, string.Format(format, args)); @@ -361,14 +353,8 @@ namespace Server.Guilds AllianceChat(from, pm?.AllianceMessageHue ?? 0x3B2, text); } - - #endregion } - #endregion - - #region Wars - public enum WarStatus { InProgress = -1, @@ -396,36 +382,36 @@ namespace Server.Guilds switch (version) { case 0: - { - Kills = reader.ReadInt(); - MaxKills = reader.ReadInt(); + { + Kills = reader.ReadInt(); + MaxKills = reader.ReadInt(); - WarLength = reader.ReadTimeSpan(); - WarBeginning = reader.ReadDateTime(); + WarLength = reader.ReadTimeSpan(); + WarBeginning = reader.ReadDateTime(); - Guild = reader.ReadGuild() as Guild; - Opponent = reader.ReadGuild() as Guild; + Guild = reader.ReadGuild() as Guild; + Opponent = reader.ReadGuild() as Guild; - WarRequester = reader.ReadBool(); + WarRequester = reader.ReadBool(); - break; - } + break; + } } } - public int Kills{ get; set; } + public int Kills { get; set; } - public int MaxKills{ get; set; } + public int MaxKills { get; set; } - public TimeSpan WarLength{ get; set; } + public TimeSpan WarLength { get; set; } - public Guild Opponent{ get; } + public Guild Opponent { get; } - public Guild Guild{ get; } + public Guild Guild { get; } - public DateTime WarBeginning{ get; set; } + public DateTime WarBeginning { get; set; } - public bool WarRequester{ get; set; } + public bool WarRequester { get; set; } public WarStatus Status { @@ -467,7 +453,7 @@ namespace Server.Guilds public void Serialize(IGenericWriter writer) { - writer.Write(0); //version + writer.Write(0); // version writer.Write(Kills); writer.Write(MaxKills); @@ -499,8 +485,6 @@ namespace Server.Guilds } } - #endregion - public class Guild : BaseGuild { public static readonly int RegistrationFee = 25000; @@ -511,8 +495,6 @@ namespace Server.Guilds public Guild(Mobile leader, string name, string abbreviation) { - #region Ctor mumbo-jumbo - m_Leader = leader; Members = new List(); @@ -539,11 +521,9 @@ namespace Server.Guilds AcceptedWars = new List(); PendingWars = new List(); - - #endregion } - public Guild(uint id) : base(id) //serialization ctor + public Guild(uint id) : base(id) // serialization ctor { } @@ -563,7 +543,7 @@ namespace Server.Guilds set { if (value != null) - AddMember(value); //Also removes from old guild. + AddMember(value); // Also removes from old guild. if (m_Leader is PlayerMobile leader && leader.Guild == this) leader.GuildRank = RankDefinition.Member; @@ -575,7 +555,6 @@ namespace Server.Guilds } } - public override bool Disbanded => m_Leader?.Deleted != false; public static void Configure() @@ -636,7 +615,7 @@ namespace Server.Guilds { m_Leader = null; - List.Remove(Id); + List.Remove(Serial); foreach (Mobile m in Members) { @@ -668,8 +647,6 @@ namespace Server.Guilds Alliance = null; } - #region GuildProps - [Usage("GuildProps")] [Description( "Opens a menu where you can view and edit guild properties of a targeted player or guild stone. If the new Guild system is active, also brings up the guild gump.")] @@ -742,10 +719,6 @@ namespace Server.Guilds } } - #endregion - - #region EventSinks - public static void EventSink_GuildGumpRequest(Mobile m) { if (!NewGuildSystem || !(m is PlayerMobile pm)) @@ -762,11 +735,6 @@ namespace Server.Guilds args.Guild = new Guild(args.Id); } - #endregion - - - #region New Alliances - public AllianceInfo Alliance { get @@ -824,14 +792,9 @@ namespace Server.Guilds return g; } - #endregion - - #region New Wars - - public List PendingWars{ get; private set; } - - public List AcceptedWars{ get; private set; } + public List PendingWars { get; private set; } + public List AcceptedWars { get; private set; } public WarDeclaration FindPendingWar(Guild g) { @@ -919,7 +882,7 @@ namespace Server.Guilds if (w.Status != WarStatus.Pending) { - //All sanity in here + // All sanity in here PendingWars.Remove(w); g?.PendingWars.Remove(g.FindPendingWar(this)); @@ -953,10 +916,6 @@ namespace Server.Guilds victimGuild.CheckExpiredWars(); } - #endregion - - #region Var declarations - private Mobile m_Leader; private string m_Name; @@ -967,15 +926,11 @@ namespace Server.Guilds private AllianceInfo m_AllianceInfo; private Guild m_AllianceLeader; - #endregion - - #region Is(...) - public bool IsMember(Mobile m) => Members.Contains(m); public bool IsAlly(Guild g) => NewGuildSystem ? Alliance?.IsMember(this) == true && Alliance.IsMember(g) : Allies.Contains(g); - public bool IsEnemy(Guild g) => Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type || IsWar(g); + public bool IsEnemy(Guild g) => (Type != GuildType.Regular && g.Type != GuildType.Regular && Type != g.Type) || IsWar(g); public bool IsWar(Guild g) { @@ -989,13 +944,8 @@ namespace Server.Guilds Guild otherGuild = GetAllianceLeader(g); return guild.FindActiveWar(otherGuild) != null; - } - #endregion - - #region Serialization - public override void Serialize(IGenericWriter writer) { if (LastFealty + TimeSpan.FromDays(1.0) < DateTime.UtcNow) @@ -1005,9 +955,7 @@ namespace Server.Guilds Alliance?.CheckLeader(); - writer.Write(5); //version - - #region War Serialization + writer.Write(5); // version writer.Write(PendingWars.Count); @@ -1017,10 +965,6 @@ namespace Server.Guilds for (int i = 0; i < AcceptedWars.Count; i++) AcceptedWars[i].Serialize(writer); - #endregion - - #region Alliances - bool isAllianceLeader = m_AllianceLeader == null && m_AllianceInfo != null; writer.Write(isAllianceLeader); @@ -1029,8 +973,6 @@ namespace Server.Guilds else writer.Write(m_AllianceLeader); - #endregion - // writer.WriteGuildList(AllyDeclarations, true); @@ -1069,78 +1011,77 @@ namespace Server.Guilds switch (version) { case 5: - { - int count = reader.ReadInt(); + { + int count = reader.ReadInt(); - PendingWars = new List(); - for (int i = 0; i < count; i++) PendingWars.Add(new WarDeclaration(reader)); + PendingWars = new List(); + for (int i = 0; i < count; i++) PendingWars.Add(new WarDeclaration(reader)); - count = reader.ReadInt(); - AcceptedWars = new List(); - for (int i = 0; i < count; i++) AcceptedWars.Add(new WarDeclaration(reader)); + count = reader.ReadInt(); + AcceptedWars = new List(); + for (int i = 0; i < count; i++) AcceptedWars.Add(new WarDeclaration(reader)); - bool isAllianceLeader = reader.ReadBool(); + bool isAllianceLeader = reader.ReadBool(); - if (isAllianceLeader) - m_AllianceInfo = new AllianceInfo(reader); - else - m_AllianceLeader = reader.ReadGuild() as Guild; + if (isAllianceLeader) + m_AllianceInfo = new AllianceInfo(reader); + else + m_AllianceLeader = reader.ReadGuild() as Guild; - - goto case 4; - } + goto case 4; + } case 4: - { - AllyDeclarations = reader.ReadStrongGuildList(); - AllyInvitations = reader.ReadStrongGuildList(); + { + AllyDeclarations = reader.ReadStrongGuildList(); + AllyInvitations = reader.ReadStrongGuildList(); - goto case 3; - } + goto case 3; + } case 3: - { - TypeLastChange = reader.ReadDateTime(); + { + TypeLastChange = reader.ReadDateTime(); - goto case 2; - } + goto case 2; + } case 2: - { - m_Type = (GuildType)reader.ReadInt(); + { + m_Type = (GuildType)reader.ReadInt(); - goto case 1; - } + goto case 1; + } case 1: - { - LastFealty = reader.ReadDateTime(); + { + LastFealty = reader.ReadDateTime(); - goto case 0; - } + goto case 0; + } case 0: - { - m_Leader = reader.ReadMobile(); + { + m_Leader = reader.ReadMobile(); - if (m_Leader is PlayerMobile mobile) - mobile.GuildRank = RankDefinition.Leader; + if (m_Leader is PlayerMobile mobile) + mobile.GuildRank = RankDefinition.Leader; - m_Name = reader.ReadString(); - m_Abbreviation = reader.ReadString(); + m_Name = reader.ReadString(); + m_Abbreviation = reader.ReadString(); - Allies = reader.ReadStrongGuildList(); - Enemies = reader.ReadStrongGuildList(); - WarDeclarations = reader.ReadStrongGuildList(); - WarInvitations = reader.ReadStrongGuildList(); + Allies = reader.ReadStrongGuildList(); + Enemies = reader.ReadStrongGuildList(); + WarDeclarations = reader.ReadStrongGuildList(); + WarInvitations = reader.ReadStrongGuildList(); - Members = reader.ReadStrongMobileList(); - Candidates = reader.ReadStrongMobileList(); - Accepted = reader.ReadStrongMobileList(); + Members = reader.ReadStrongMobileList(); + Candidates = reader.ReadStrongMobileList(); + Accepted = reader.ReadStrongMobileList(); - Guildstone = reader.ReadItem(); - Teleporter = reader.ReadItem(); + Guildstone = reader.ReadItem(); + Teleporter = reader.ReadItem(); - Charter = reader.ReadString(); - Website = reader.ReadString(); + Charter = reader.ReadString(); + Website = reader.ReadString(); - break; - } + break; + } } AllyDeclarations ??= new List(); @@ -1153,7 +1094,7 @@ namespace Server.Guilds private void VerifyGuild_Callback() { - if (!NewGuildSystem && Guildstone == null || Members.Count == 0) + if ((!NewGuildSystem && Guildstone == null) || Members.Count == 0) Disband(); CheckExpiredWars(); @@ -1162,17 +1103,12 @@ namespace Server.Guilds alliance?.CheckLeader(); - alliance = Alliance; //CheckLeader could possibly change the value of this.Alliance + alliance = Alliance; // CheckLeader could possibly change the value of this.Alliance - if (alliance?.IsMember(this) == false && !alliance.IsPendingMember(this) - ) //This block is there to fix a bug in the code in an older version. - Alliance = null; //Will call Alliance.RemoveGuild which will set it null & perform all the pertient checks as far as alliacne disbanding + if (alliance?.IsMember(this) == false && !alliance.IsPendingMember(this)) // This block is there to fix a bug in the code in an older version. + Alliance = null; // Will call Alliance.RemoveGuild which will set it null & perform all the pertient checks as far as alliacne disbanding } - #endregion - - #region Add/Remove Member/Old Ally/Old Enemy - public void AddMember(Mobile m) { if (!Members.Contains(m)) @@ -1265,10 +1201,6 @@ namespace Server.Guilds } } - #endregion - - #region Guild[Text]Message(...) - public void GuildMessage(int num, bool append, string format, params object[] args) { GuildMessage(num, append, string.Format(format, args)); @@ -1338,15 +1270,11 @@ namespace Server.Guilds GuildChat(from, (from as PlayerMobile)?.GuildMessageHue ?? 0x3B2, text); } - #endregion - - #region Voting - public bool CanVote(Mobile m) => - (!NewGuildSystem || m is PlayerMobile pm && pm.GuildRank.GetFlag(RankFlags.CanVote)) && + (!NewGuildSystem || (m is PlayerMobile pm && pm.GuildRank.GetFlag(RankFlags.CanVote))) && m?.Deleted == false && m.Guild == this; - public bool CanBeVotedFor(Mobile m) => (!NewGuildSystem || m is PlayerMobile pm && pm.LastOnline + InactiveTime >= DateTime.UtcNow) && m?.Deleted == false && m.Guild == this; + public bool CanBeVotedFor(Mobile m) => (!NewGuildSystem || (m is PlayerMobile pm && pm.LastOnline + InactiveTime >= DateTime.UtcNow)) && m?.Deleted == false && m.Guild == this; public void CalculateGuildmaster() { @@ -1404,15 +1332,11 @@ namespace Server.Guilds LastFealty = DateTime.UtcNow; } - #endregion - - #region Getters & Setters + [CommandProperty(AccessLevel.GameMaster)] + public Item Guildstone { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Item Guildstone{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public Item Teleporter{ get; set; } + public Item Teleporter { get; set; } [CommandProperty(AccessLevel.GameMaster)] public override string Name @@ -1429,7 +1353,7 @@ namespace Server.Guilds } [CommandProperty(AccessLevel.GameMaster)] - public string Website{ get; set; } + public string Website { get; set; } [CommandProperty(AccessLevel.GameMaster)] public override string Abbreviation @@ -1446,7 +1370,7 @@ namespace Server.Guilds } [CommandProperty(AccessLevel.GameMaster)] - public string Charter{ get; set; } + public string Charter { get; set; } [CommandProperty(AccessLevel.GameMaster)] public override GuildType Type @@ -1465,29 +1389,27 @@ namespace Server.Guilds } [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastFealty{ get; set; } + public DateTime LastFealty { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime TypeLastChange{ get; private set; } + public DateTime TypeLastChange { get; private set; } - public List Allies{ get; private set; } + public List Allies { get; private set; } - public List Enemies{ get; private set; } + public List Enemies { get; private set; } - public List AllyDeclarations{ get; private set; } + public List AllyDeclarations { get; private set; } - public List AllyInvitations{ get; private set; } + public List AllyInvitations { get; private set; } - public List WarDeclarations{ get; private set; } + public List WarDeclarations { get; private set; } - public List WarInvitations{ get; private set; } + public List WarInvitations { get; private set; } - public List Candidates{ get; private set; } + public List Candidates { get; private set; } - public List Accepted{ get; private set; } + public List Accepted { get; private set; } - public List Members{ get; private set; } - - #endregion + public List Members { get; private set; } } } diff --git a/Projects/Scripts/Misc/HardwareInfo.cs b/Projects/Scripts/Misc/HardwareInfo.cs index c0fb29bbb..c62017106 100644 --- a/Projects/Scripts/Misc/HardwareInfo.cs +++ b/Projects/Scripts/Misc/HardwareInfo.cs @@ -10,82 +10,82 @@ namespace Server public class HardwareInfo { [CommandProperty(AccessLevel.GameMaster)] - public int CpuModel{ get; private set; } + public int CpuModel { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int CpuClockSpeed{ get; private set; } + public int CpuClockSpeed { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int CpuQuantity{ get; private set; } + public int CpuQuantity { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int OSMajor{ get; private set; } + public int OSMajor { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int OSMinor{ get; private set; } + public int OSMinor { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int OSRevision{ get; private set; } + public int OSRevision { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int InstanceID{ get; private set; } + public int InstanceID { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int ScreenWidth{ get; private set; } + public int ScreenWidth { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int ScreenHeight{ get; private set; } + public int ScreenHeight { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int ScreenDepth{ get; private set; } + public int ScreenDepth { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int PhysicalMemory{ get; private set; } + public int PhysicalMemory { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int CpuManufacturer{ get; private set; } + public int CpuManufacturer { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int CpuFamily{ get; private set; } + public int CpuFamily { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int VCVendorID{ get; private set; } + public int VCVendorID { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int VCDeviceID{ get; private set; } + public int VCDeviceID { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int VCMemory{ get; private set; } + public int VCMemory { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int DXMajor{ get; private set; } + public int DXMajor { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int DXMinor{ get; private set; } + public int DXMinor { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public string VCDescription{ get; private set; } + public string VCDescription { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public string Language{ get; private set; } + public string Language { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int Distribution{ get; private set; } + public int Distribution { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int ClientsRunning{ get; private set; } + public int ClientsRunning { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int ClientsInstalled{ get; private set; } + public int ClientsInstalled { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int PartialInstalled{ get; private set; } + public int PartialInstalled { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public string Unknown{ get; private set; } + public string Unknown { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime TimeReceived{ get; private set; } + public DateTime TimeReceived { get; private set; } public static void Initialize() { diff --git a/Projects/Scripts/Misc/InhumanSpeech.cs b/Projects/Scripts/Misc/InhumanSpeech.cs index 90f365068..bd9b564d9 100644 --- a/Projects/Scripts/Misc/InhumanSpeech.cs +++ b/Projects/Scripts/Misc/InhumanSpeech.cs @@ -7,12 +7,12 @@ namespace Server.Misc [Flags] public enum IHSFlags { - None = 0x00, - OnDamaged = 0x01, - OnDeath = 0x02, - OnMovement = 0x04, - OnSpeech = 0x08, - All = OnDamaged | OnDeath | OnMovement + None = 0x00, + OnDamaged = 0x01, + OnDeath = 0x02, + OnMovement = 0x04, + OnSpeech = 0x08, + All = OnDamaged | OnDeath | OnMovement } // NOTE: To enable monster conversations, add " | OnSpeech" to the "All" line public class InhumanSpeech @@ -23,7 +23,7 @@ namespace Server.Misc { get { - if ( m_RatmanSpeech == null ) + if (m_RatmanSpeech == null) { m_RatmanSpeech = new InhumanSpeech(); @@ -99,7 +99,7 @@ namespace Server.Misc { get { - if ( m_OrcSpeech == null ) + if (m_OrcSpeech == null) { m_OrcSpeech = new InhumanSpeech(); @@ -186,7 +186,7 @@ namespace Server.Misc { get { - if ( m_LizardmanSpeech == null ) + if (m_LizardmanSpeech == null) { m_LizardmanSpeech = new InhumanSpeech(); @@ -250,7 +250,7 @@ namespace Server.Misc { get { - if ( m_WispSpeech == null ) + if (m_WispSpeech == null) { m_WispSpeech = new InhumanSpeech(); @@ -286,8 +286,8 @@ namespace Server.Misc set { m_Keywords = value; - m_KeywordHash = new Dictionary( m_Keywords.Length, StringComparer.OrdinalIgnoreCase ); - for ( int i = 0; i < m_Keywords.Length; ++i ) + m_KeywordHash = new Dictionary(m_Keywords.Length, StringComparer.OrdinalIgnoreCase); + for (int i = 0; i < m_Keywords.Length; ++i) m_KeywordHash[m_Keywords[i]] = m_Keywords[i]; } } @@ -300,174 +300,174 @@ namespace Server.Misc public IHSFlags Flags { get; set; } - public string GetRandomSyllable() => Syllables[Utility.Random( Syllables.Length )]; + public string GetRandomSyllable() => Syllables[Utility.Random(Syllables.Length)]; - public string ConstructWord( int syllableCount ) + public string ConstructWord(int syllableCount) { string[] syllables = new string[syllableCount]; - for ( int i = 0; i < syllableCount; ++i ) + for (int i = 0; i < syllableCount; ++i) syllables[i] = GetRandomSyllable(); - return string.Concat( syllables ); + return string.Concat(syllables); } - public string ConstructSentance( int wordCount ) + public string ConstructSentance(int wordCount) { StringBuilder sentance = new StringBuilder(); bool needUpperCase = true; - for ( int i = 0; i < wordCount; ++i ) + for (int i = 0; i < wordCount; ++i) { - if ( i > 0 ) // not first word ) + if (i > 0) // not first word) { - int random = Utility.RandomMinMax( 1, 15 ); + int random = Utility.RandomMinMax(1, 15); - if ( random < 11 ) + if (random < 11) { - sentance.Append( ' ' ); + sentance.Append(' '); } else { needUpperCase = true; - if ( random > 13 ) - sentance.Append( "! " ); + if (random > 13) + sentance.Append("! "); else - sentance.Append( ". " ); + sentance.Append(". "); } } int syllableCount; - if ( 30 > Utility.Random( 100 ) ) - syllableCount = Utility.Random( 1, 5 ); + if (Utility.Random(100) < 30) + syllableCount = Utility.Random(1, 5); else - syllableCount = Utility.Random( 1, 3 ); + syllableCount = Utility.Random(1, 3); - string word = ConstructWord( syllableCount ); + string word = ConstructWord(syllableCount); - sentance.Append( word ); + sentance.Append(word); - if ( needUpperCase ) - sentance.Replace( word[0], char.ToUpper( word[0] ), sentance.Length - word.Length, 1 ); + if (needUpperCase) + sentance.Replace(word[0], char.ToUpper(word[0]), sentance.Length - word.Length, 1); needUpperCase = false; } - if ( Utility.RandomMinMax( 1, 5 ) == 1 ) - sentance.Append( '!' ); + if (Utility.RandomMinMax(1, 5) == 1) + sentance.Append('!'); else - sentance.Append( '.' ); + sentance.Append('.'); return sentance.ToString(); } - public void SayRandomTranslate( Mobile mob, params string[] sentancesInEnglish ) + public void SayRandomTranslate(Mobile mob, params string[] sentancesInEnglish) { - SaySentance( mob, Utility.RandomMinMax( 2, 3 ) ); - mob.Say( sentancesInEnglish[Utility.Random( sentancesInEnglish.Length )] ); + SaySentance(mob, Utility.RandomMinMax(2, 3)); + mob.Say(sentancesInEnglish[Utility.Random(sentancesInEnglish.Length)]); } - private string GetRandomResponseWord( List keywordsFound ) + private string GetRandomResponseWord(List keywordsFound) { - int random = Utility.Random( keywordsFound.Count + Responses.Length ); + int random = Utility.Random(keywordsFound.Count + Responses.Length); - if ( random < keywordsFound.Count ) + if (random < keywordsFound.Count) return keywordsFound[random]; return Responses[random - keywordsFound.Count]; } - public bool OnSpeech( Mobile mob, Mobile speaker, string text ) + public bool OnSpeech(Mobile mob, Mobile speaker, string text) { - if ( (Flags & IHSFlags.OnSpeech) == 0 || m_Keywords == null || Responses == null || m_KeywordHash == null ) + if ((Flags & IHSFlags.OnSpeech) == 0 || m_Keywords == null || Responses == null || m_KeywordHash == null) return false; // not enabled - if ( !speaker.Alive ) + if (!speaker.Alive) return false; - if ( !speaker.InRange( mob, 3 ) ) + if (!speaker.InRange(mob, 3)) return false; - if ( (speaker.Direction & Direction.Mask) != speaker.GetDirectionTo( mob ) ) + if ((speaker.Direction & Direction.Mask) != speaker.GetDirectionTo(mob)) return false; - if ( (mob.Direction & Direction.Mask) != mob.GetDirectionTo( speaker ) ) + if ((mob.Direction & Direction.Mask) != mob.GetDirectionTo(speaker)) return false; - string[] split = text.Split( ' ' ); + string[] split = text.Split(' '); List keywordsFound = new List(); - for ( int i = 0; i < split.Length; ++i ) - if (m_KeywordHash.TryGetValue( split[i], out string keyword )) - keywordsFound.Add( keyword ); + for (int i = 0; i < split.Length; ++i) + if (m_KeywordHash.TryGetValue(split[i], out string keyword)) + keywordsFound.Add(keyword); - if ( keywordsFound.Count > 0 ) + if (keywordsFound.Count > 0) { string responseWord; - if ( Utility.RandomBool() ) - responseWord = GetRandomResponseWord( keywordsFound ); + if (Utility.RandomBool()) + responseWord = GetRandomResponseWord(keywordsFound); else - responseWord = keywordsFound[Utility.Random( keywordsFound.Count )]; + responseWord = keywordsFound[Utility.Random(keywordsFound.Count)]; - string secondResponseWord = GetRandomResponseWord( keywordsFound ); + string secondResponseWord = GetRandomResponseWord(keywordsFound); StringBuilder response = new StringBuilder(); - switch ( Utility.Random( 6 ) ) + switch (Utility.Random(6)) { default: case 0: - { - response.Append( "Me " ).Append( responseWord ).Append( '?' ); - break; - } + { + response.Append("Me ").Append(responseWord).Append('?'); + break; + } case 1: - { - response.Append( responseWord ).Append( " thee!" ); - response.Replace( responseWord[0], char.ToUpper( responseWord[0] ), 0, 1 ); - break; - } + { + response.Append(responseWord).Append(" thee!"); + response.Replace(responseWord[0], char.ToUpper(responseWord[0]), 0, 1); + break; + } case 2: - { - response.Append( responseWord ).Append( '?' ); - response.Replace( responseWord[0], char.ToUpper( responseWord[0] ), 0, 1 ); - break; - } + { + response.Append(responseWord).Append('?'); + response.Replace(responseWord[0], char.ToUpper(responseWord[0]), 0, 1); + break; + } case 3: - { - response.Append( responseWord ).Append( "! " ).Append( secondResponseWord ).Append( '.' ); - response.Replace( responseWord[0], char.ToUpper( responseWord[0] ), 0, 1 ); - response.Replace( secondResponseWord[0], char.ToUpper( secondResponseWord[0] ), responseWord.Length + 2, 1 ); - break; - } + { + response.Append(responseWord).Append("! ").Append(secondResponseWord).Append('.'); + response.Replace(responseWord[0], char.ToUpper(responseWord[0]), 0, 1); + response.Replace(secondResponseWord[0], char.ToUpper(secondResponseWord[0]), responseWord.Length + 2, 1); + break; + } case 4: - { - response.Append( responseWord ).Append( '.' ); - response.Replace( responseWord[0], char.ToUpper( responseWord[0] ), 0, 1 ); - break; - } + { + response.Append(responseWord).Append('.'); + response.Replace(responseWord[0], char.ToUpper(responseWord[0]), 0, 1); + break; + } case 5: - { - response.Append( responseWord ).Append( "? " ).Append( secondResponseWord ).Append( '.' ); - response.Replace( responseWord[0], char.ToUpper( responseWord[0] ), 0, 1 ); - response.Replace( secondResponseWord[0], char.ToUpper( secondResponseWord[0] ), responseWord.Length + 2, 1 ); - break; - } + { + response.Append(responseWord).Append("? ").Append(secondResponseWord).Append('.'); + response.Replace(responseWord[0], char.ToUpper(responseWord[0]), 0, 1); + response.Replace(secondResponseWord[0], char.ToUpper(secondResponseWord[0]), responseWord.Length + 2, 1); + break; + } } int maxWords = split.Length / 2 + 1; - if ( maxWords < 2 ) + if (maxWords < 2) maxWords = 2; - else if ( maxWords > 6 ) + else if (maxWords > 6) maxWords = 6; - SaySentance( mob, Utility.RandomMinMax( 2, maxWords ) ); - mob.Say( response.ToString() ); + SaySentance(mob, Utility.RandomMinMax(2, maxWords)); + mob.Say(response.ToString()); return true; } @@ -475,15 +475,15 @@ namespace Server.Misc return false; } - public void OnDeath( Mobile mob ) + public void OnDeath(Mobile mob) { - if ( (Flags & IHSFlags.OnDeath) == 0 ) + if ((Flags & IHSFlags.OnDeath) == 0) return; // not enabled - if ( 90 > Utility.Random( 100 ) ) + if (Utility.Random(100) < 90) return; // 90% chance to do nothing; 10% chance to talk - SayRandomTranslate( mob, + SayRandomTranslate(mob, "Revenge!", "NOOooo!", "I... I...", @@ -491,61 +491,61 @@ namespace Server.Misc "Me die!", "Must... not die...", "Oooh, me hurt...", - "Me dying?" ); + "Me dying?"); } - public void OnMovement( Mobile mob, Mobile mover, Point3D oldLocation ) + public void OnMovement(Mobile mob, Mobile mover, Point3D oldLocation) { - if ( (Flags & IHSFlags.OnMovement) == 0 ) + if ((Flags & IHSFlags.OnMovement) == 0) return; // not enabled - if ( !mover.Player || mover.Hidden && mover.AccessLevel > AccessLevel.Player ) + if (!mover.Player || (mover.Hidden && mover.AccessLevel > AccessLevel.Player)) return; - if ( !mob.InRange( mover, 5 ) || mob.InRange( oldLocation, 5 ) ) + if (!mob.InRange(mover, 5) || mob.InRange(oldLocation, 5)) return; // only talk when they enter 5 tile range - if ( 90 > Utility.Random( 100 ) ) + if (Utility.Random(100) < 90) return; // 90% chance to do nothing; 10% chance to talk - SaySentance( mob, 6 ); + SaySentance(mob, 6); } - public void OnDamage( Mobile mob, int amount ) + public void OnDamage(Mobile mob, int amount) { - if ( (Flags & IHSFlags.OnDamaged) == 0 ) + if ((Flags & IHSFlags.OnDamaged) == 0) return; // not enabled - if ( 90 > Utility.Random( 100 ) ) + if (Utility.Random(100) < 90) return; // 90% chance to do nothing; 10% chance to talk - if ( amount < 5 ) - SayRandomTranslate( mob, + if (amount < 5) + SayRandomTranslate(mob, "Ouch!", "Me not hurt bad!", "Thou fight bad.", "Thy blows soft!", - "You bad with weapon!" ); + "You bad with weapon!"); else - SayRandomTranslate( mob, + SayRandomTranslate(mob, "Ouch! Me hurt!", "No, kill me not!", "Me hurt!", "Away with thee!", "Oof! That hurt!", "Aaah! That hurt...", - "Good blow!" ); + "Good blow!"); } - public void OnConstruct( Mobile mob ) + public void OnConstruct(Mobile mob) { mob.SpeechHue = Hue; } - public void SaySentance( Mobile mob, int wordCount ) + public void SaySentance(Mobile mob, int wordCount) { - mob.Say( ConstructSentance( wordCount ) ); - mob.PlaySound( Sound ); + mob.Say(ConstructSentance(wordCount)); + mob.PlaySound(Sound); } } } diff --git a/Projects/Scripts/Misc/Keywords.cs b/Projects/Scripts/Misc/Keywords.cs index 71e04ffc4..74edd8cce 100644 --- a/Projects/Scripts/Misc/Keywords.cs +++ b/Projects/Scripts/Misc/Keywords.cs @@ -21,33 +21,33 @@ namespace Server.Misc switch (keywords[i]) { case 0x002A: // *i resign from my guild* - { - ((Guild)from.Guild)?.RemoveMember(from); + { + ((Guild)from.Guild)?.RemoveMember(from); - break; - } + break; + } case 0x0032: // *i must consider my sins* - { - if (!Core.SE) { - from.SendMessage("Short Term Murders : {0}", from.ShortTermMurders); - from.SendMessage("Long Term Murders : {0}", from.Kills); - } - else - { - from.SendMessage(0x3B2, "Short Term Murders: {0} Long Term Murders: {1}", from.ShortTermMurders, - from.Kills); - } + if (!Core.SE) + { + from.SendMessage("Short Term Murders : {0}", from.ShortTermMurders); + from.SendMessage("Long Term Murders : {0}", from.Kills); + } + else + { + from.SendMessage(0x3B2, "Short Term Murders: {0} Long Term Murders: {1}", from.ShortTermMurders, + from.Kills); + } - break; - } + break; + } case 0x0035: // i renounce my young player status* - { - if (from is PlayerMobile mobile && mobile.Young && !mobile.HasGump()) - mobile.SendGump(new RenounceYoungGump()); + { + if (from is PlayerMobile mobile && mobile.Young && !mobile.HasGump()) + mobile.SendGump(new RenounceYoungGump()); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Misc/LanguageStatistics.cs b/Projects/Scripts/Misc/LanguageStatistics.cs index f5cac3106..d11910cdd 100644 --- a/Projects/Scripts/Misc/LanguageStatistics.cs +++ b/Projects/Scripts/Misc/LanguageStatistics.cs @@ -19,10 +19,9 @@ namespace Server.Misc * If you do not see the above chars, please * enable showing of unicode control chars **/ - public class LanguageStatistics { - private static InternationalCode[] InternationalCodes = + private static readonly InternationalCode[] InternationalCodes = { new InternationalCode("ARA", "Arabic", "Saudi Arabia", "العربية", "السعودية"), new InternationalCode("ARI", "Arabic", "Iraq", "العربية", "العراق"), @@ -161,9 +160,9 @@ namespace Server.Misc new InternationalCode("KOK", "Konkani", "India", "कोंकणी", "भारत") }; - private static bool DefaultLocalNames = false; - private static bool ShowAlternatives = true; - private static bool CountAccounts = true; // will consider only first character's valid language + private static readonly bool DefaultLocalNames = false; + private static readonly bool ShowAlternatives = true; + private static readonly bool CountAccounts = true; // will consider only first character's valid language private static string GetFormattedInfo(string code) { @@ -244,17 +243,17 @@ namespace Server.Misc private struct InternationalCode { - private bool m_HasLocalInfo; + private readonly bool m_HasLocalInfo; - public string Code{ get; } + public string Code { get; } - public string Language{ get; } + public string Language { get; } - public string Country{ get; } + public string Country { get; } - public string Language_LocalName{ get; } + public string Language_LocalName { get; } - public string Country_LocalName{ get; } + public string Country_LocalName { get; } public InternationalCode(string code, string language, string country) : this(code, language, country, null, null) => @@ -301,9 +300,9 @@ namespace Server.Misc Count = 1; } - public string Code{ get; } + public string Code { get; } - public int Count{ get; private set; } + public int Count { get; private set; } public void Increase() { @@ -325,7 +324,6 @@ namespace Server.Misc b = y.Code; cb = y.Count; - if (ca > cb) return -1; diff --git a/Projects/Scripts/Misc/LightCycle.cs b/Projects/Scripts/Misc/LightCycle.cs index 16b39ca18..25cb1d688 100644 --- a/Projects/Scripts/Misc/LightCycle.cs +++ b/Projects/Scripts/Misc/LightCycle.cs @@ -112,7 +112,7 @@ namespace Server public class NightSightTimer : Timer { - private Mobile m_Owner; + private readonly Mobile m_Owner; public NightSightTimer(Mobile owner) : base(TimeSpan.FromMinutes(Utility.Random(15, 25))) { diff --git a/Projects/Scripts/Misc/Loot.cs b/Projects/Scripts/Misc/Loot.cs index 64300f4c0..4687e208f 100644 --- a/Projects/Scripts/Misc/Loot.cs +++ b/Projects/Scripts/Misc/Loot.cs @@ -6,11 +6,7 @@ namespace Server { public class Loot { - #region List definitions - - #region Mondain's Legacy - - public static Type[] MLWeaponTypes{ get; } = + public static Type[] MLWeaponTypes { get; } = { typeof(AssassinSpike), typeof(DiamondMace), typeof(ElvenMachete), typeof(ElvenSpellblade), typeof(Leafblade), typeof(OrnateAxe), @@ -18,12 +14,12 @@ namespace Server typeof(WildStaff) }; - public static Type[] MLRangedWeaponTypes{ get; } = + public static Type[] MLRangedWeaponTypes { get; } = { typeof(ElvenCompositeLongbow), typeof(MagicalShortbow) }; - public static Type[] MLArmorTypes{ get; } = + public static Type[] MLArmorTypes { get; } = { typeof(Circlet), typeof(GemmedCirclet), typeof(LeafTonlet), typeof(RavenHelm), typeof(RoyalCirclet), typeof(VultureHelm), @@ -35,16 +31,14 @@ namespace Server typeof(HidePauldrons) }; - public static Type[] MLClothingTypes{ get; } = + public static Type[] MLClothingTypes { get; } = { typeof(MaleElvenRobe), typeof(FemaleElvenRobe), typeof(ElvenPants), typeof(ElvenShirt), typeof(ElvenDarkShirt), typeof(ElvenBoots), typeof(VultureHelm), typeof(WoodlandBelt) }; - #endregion - - public static Type[] SEWeaponTypes{ get; } = + public static Type[] SEWeaponTypes { get; } = { typeof(Bokuto), typeof(Daisho), typeof(Kama), typeof(Lajatang), typeof(NoDachi), typeof(Nunchaku), @@ -52,14 +46,14 @@ namespace Server typeof(Tetsubo), typeof(Wakizashi) }; - public static Type[] AosWeaponTypes{ get; } = + public static Type[] AosWeaponTypes { get; } = { typeof(Scythe), typeof(BoneHarvester), typeof(Scepter), typeof(BladedStaff), typeof(Pike), typeof(DoubleBladedStaff), typeof(Lance), typeof(CrescentBlade) }; - public static Type[] WeaponTypes{ get; } = + public static Type[] WeaponTypes { get; } = { typeof(Axe), typeof(BattleAxe), typeof(DoubleAxe), typeof(ExecutionersAxe), typeof(Hatchet), typeof(LargeBattleAxe), @@ -75,22 +69,22 @@ namespace Server typeof(Dagger), typeof(SkinningKnife), typeof(ShepherdsCrook) }; - public static Type[] SERangedWeaponTypes{ get; } = + public static Type[] SERangedWeaponTypes { get; } = { typeof(Yumi) }; - public static Type[] AosRangedWeaponTypes{ get; } = + public static Type[] AosRangedWeaponTypes { get; } = { typeof(CompositeBow), typeof(RepeatingCrossbow) }; - public static Type[] RangedWeaponTypes{ get; } = + public static Type[] RangedWeaponTypes { get; } = { typeof(Bow), typeof(Crossbow), typeof(HeavyCrossbow) }; - public static Type[] SEArmorTypes{ get; } = + public static Type[] SEArmorTypes { get; } = { typeof(ChainHatsuburi), typeof(LeatherDo), typeof(LeatherHaidate), typeof(LeatherHiroSode), typeof(LeatherJingasa), typeof(LeatherMempo), @@ -104,7 +98,7 @@ namespace Server typeof(StuddedSuneate) }; - public static Type[] ArmorTypes{ get; } = + public static Type[] ArmorTypes { get; } = { typeof(BoneArms), typeof(BoneChest), typeof(BoneGloves), typeof(BoneLegs), typeof(BoneHelm), typeof(ChainChest), @@ -122,73 +116,69 @@ namespace Server typeof(StuddedGorget), typeof(StuddedLegs) }; - public static Type[] AosShieldTypes{ get; } = + public static Type[] AosShieldTypes { get; } = { typeof(ChaosShield), typeof(OrderShield) }; - public static Type[] ShieldTypes{ get; } = + public static Type[] ShieldTypes { get; } = { typeof(BronzeShield), typeof(Buckler), typeof(HeaterShield), typeof(MetalShield), typeof(MetalKiteShield), typeof(WoodenKiteShield), typeof(WoodenShield) }; - public static Type[] GemTypes{ get; } = + public static Type[] GemTypes { get; } = { typeof(Amber), typeof(Amethyst), typeof(Citrine), typeof(Diamond), typeof(Emerald), typeof(Ruby), typeof(Sapphire), typeof(StarSapphire), typeof(Tourmaline) }; - public static Type[] JewelryTypes{ get; } = + public static Type[] JewelryTypes { get; } = { typeof(GoldRing), typeof(GoldBracelet), typeof(SilverRing), typeof(SilverBracelet) }; - public static Type[] RegTypes{ get; } = + public static Type[] RegTypes { get; } = { typeof(BlackPearl), typeof(Bloodmoss), typeof(Garlic), typeof(Ginseng), typeof(MandrakeRoot), typeof(Nightshade), typeof(SulfurousAsh), typeof(SpidersSilk) }; - public static Type[] NecroRegTypes{ get; } = + public static Type[] NecroRegTypes { get; } = { typeof(BatWing), typeof(GraveDust), typeof(DaemonBlood), typeof(NoxCrystal), typeof(PigIron) }; - public static Type[] PotionTypes{ get; } = + public static Type[] PotionTypes { get; } = { typeof(AgilityPotion), typeof(StrengthPotion), typeof(RefreshPotion), typeof(LesserCurePotion), typeof(LesserHealPotion), typeof(LesserPoisonPotion) }; - public static Type[] SEInstrumentTypes{ get; } = + public static Type[] SEInstrumentTypes { get; } = { typeof(BambooFlute) }; - public static Type[] InstrumentTypes{ get; } = + public static Type[] InstrumentTypes { get; } = { typeof(Drums), typeof(Harp), typeof(LapHarp), typeof(Lute), typeof(Tambourine), typeof(TambourineTassel) }; - public static Type[] StatueTypes{ get; } = + public static Type[] StatueTypes { get; } = { typeof(StatueSouth), typeof(StatueSouth2), typeof(StatueNorth), typeof(StatueWest), typeof(StatueEast), typeof(StatueEast2), typeof(StatueSouthEast), typeof(BustSouth), typeof(BustEast) }; - #region Mondain's Legacy - - #endregion - - public static Type[] RegularScrollTypes{ get; } = + public static Type[] RegularScrollTypes { get; } = { typeof(ReactiveArmorScroll), typeof(ClumsyScroll), typeof(CreateFoodScroll), typeof(FeeblemindScroll), typeof(HealScroll), typeof(MagicArrowScroll), typeof(NightSightScroll), typeof(WeakenScroll), @@ -210,7 +200,7 @@ namespace Server typeof(SummonWaterElementalScroll) }; - public static Type[] NecromancyScrollTypes{ get; } = + public static Type[] NecromancyScrollTypes { get; } = { typeof(AnimateDeadScroll), typeof(BloodOathScroll), typeof(CorpseSkinScroll), typeof(CurseWeaponScroll), typeof(EvilOmenScroll), typeof(HorrificBeastScroll), typeof(LichFormScroll), typeof(MindRotScroll), @@ -218,7 +208,7 @@ namespace Server typeof(VampiricEmbraceScroll), typeof(VengefulSpiritScroll), typeof(WitherScroll), typeof(WraithFormScroll) }; - public static Type[] SENecromancyScrollTypes{ get; } = + public static Type[] SENecromancyScrollTypes { get; } = { typeof(AnimateDeadScroll), typeof(BloodOathScroll), typeof(CorpseSkinScroll), typeof(CurseWeaponScroll), typeof(EvilOmenScroll), typeof(HorrificBeastScroll), typeof(LichFormScroll), typeof(MindRotScroll), @@ -227,37 +217,33 @@ namespace Server typeof(ExorcismScroll) }; - public static Type[] PaladinScrollTypes{ get; } = new Type[0]; + public static Type[] PaladinScrollTypes { get; } = Array.Empty(); - #region Mondain's Legacy - - public static Type[] ArcanistScrollTypes{ get; } = + public static Type[] ArcanistScrollTypes { get; } = { typeof(ArcaneCircleScroll), typeof(GiftOfRenewalScroll), typeof(ImmolatingWeaponScroll), typeof(AttuneWeaponScroll), typeof(ThunderstormScroll), - typeof(NatureFuryScroll), /*typeof( SummonFeyScroll ), typeof( SummonFiendScroll ),*/ + typeof(NatureFuryScroll), /*typeof( SummonFeyScroll ), typeof( SummonFiendScroll ),*/ typeof(ReaperFormScroll), typeof(WildfireScroll), typeof(EssenceOfWindScroll), typeof(DryadAllureScroll), typeof(EtherealVoyageScroll), typeof(WordOfDeathScroll), typeof(GiftOfLifeScroll), typeof(ArcaneEmpowermentScroll) }; - #endregion - - public static Type[] GrimmochJournalTypes{ get; } = + public static Type[] GrimmochJournalTypes { get; } = { typeof(GrimmochJournal1), typeof(GrimmochJournal2), typeof(GrimmochJournal3), typeof(GrimmochJournal6), typeof(GrimmochJournal7), typeof(GrimmochJournal11), typeof(GrimmochJournal14), typeof(GrimmochJournal17), typeof(GrimmochJournal23) }; - public static Type[] LysanderNotebookTypes{ get; } = + public static Type[] LysanderNotebookTypes { get; } = { typeof(LysanderNotebook1), typeof(LysanderNotebook2), typeof(LysanderNotebook3), typeof(LysanderNotebook7), typeof(LysanderNotebook8), typeof(LysanderNotebook11) }; - public static Type[] TavarasJournalTypes{ get; } = + public static Type[] TavarasJournalTypes { get; } = { typeof(TavarasJournal1), typeof(TavarasJournal2), typeof(TavarasJournal3), typeof(TavarasJournal6), typeof(TavarasJournal7), typeof(TavarasJournal8), @@ -266,25 +252,24 @@ namespace Server typeof(TavarasJournal19) }; - - public static Type[] NewWandTypes{ get; } = + public static Type[] NewWandTypes { get; } = { typeof(FireballWand), typeof(LightningWand), typeof(MagicArrowWand), typeof(GreaterHealWand), typeof(HarmWand), typeof(HealWand) }; - public static Type[] WandTypes{ get; } = + public static Type[] WandTypes { get; } = { typeof(ClumsyWand), typeof(FeebleWand), typeof(ManaDrainWand), typeof(WeaknessWand) }; - public static Type[] OldWandTypes{ get; } = + public static Type[] OldWandTypes { get; } = { typeof(IDWand) }; - public static Type[] SEClothingTypes{ get; } = + public static Type[] SEClothingTypes { get; } = { typeof(ClothNinjaJacket), typeof(FemaleKimono), typeof(Hakama), typeof(HakamaShita), typeof(JinBaori), typeof(Kamishimo), @@ -292,13 +277,13 @@ namespace Server typeof(SamuraiTabi), typeof(TattsukeHakama), typeof(Waraji) }; - public static Type[] AosClothingTypes{ get; } = + public static Type[] AosClothingTypes { get; } = { typeof(FurSarong), typeof(FurCape), typeof(FlowerGarland), typeof(GildedDress), typeof(FurBoots), typeof(FormalShirt) }; - public static Type[] ClothingTypes{ get; } = + public static Type[] ClothingTypes { get; } = { typeof(Cloak), typeof(Bonnet), typeof(Cap), typeof(FeatheredHat), @@ -314,18 +299,18 @@ namespace Server typeof(HalfApron) }; - public static Type[] SEHatTypes{ get; } = + public static Type[] SEHatTypes { get; } = { typeof(ClothNinjaHood), typeof(Kasa) }; - public static Type[] AosHatTypes{ get; } = + public static Type[] AosHatTypes { get; } = { typeof(FlowerGarland), typeof(BearMask), - typeof(DeerMask) //Are Bear& Deer mask inside the Pre-AoS loottables too? + typeof(DeerMask) // Are Bear& Deer mask inside the Pre-AoS loottables too? }; - public static Type[] HatTypes{ get; } = + public static Type[] HatTypes { get; } = { typeof(SkullCap), typeof(Bandana), typeof(FloppyHat), typeof(Cap), typeof(WideBrimHat), typeof(StrawHat), @@ -333,7 +318,7 @@ namespace Server typeof(FeatheredHat), typeof(TricorneHat), typeof(JesterHat) }; - public static Type[] LibraryBookTypes{ get; } = + public static Type[] LibraryBookTypes { get; } = { typeof(GrammarOfOrcish), typeof(CallToAnarchy), typeof(ArmsAndWeaponsPrimer), typeof(SongOfSamlethe), typeof(TaleOfThreeTribes), typeof(GuideToGuilds), @@ -347,10 +332,6 @@ namespace Server typeof(VirtueBook) }; - #endregion - - #region Accessors - public static BaseWand RandomWand() { if (Core.ML) @@ -364,13 +345,9 @@ namespace Server public static BaseClothing RandomClothing(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLClothingTypes, AosClothingTypes, ClothingTypes) as BaseClothing; - #endregion - if (Core.SE && inTokuno) return Construct(SEClothingTypes, AosClothingTypes, ClothingTypes) as BaseClothing; @@ -384,13 +361,9 @@ namespace Server public static BaseWeapon RandomRangedWeapon(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLRangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes) as BaseWeapon; - #endregion - if (Core.SE && inTokuno) return Construct(SERangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes) as BaseWeapon; @@ -404,13 +377,9 @@ namespace Server public static BaseWeapon RandomWeapon(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLWeaponTypes, AosWeaponTypes, WeaponTypes) as BaseWeapon; - #endregion - if (Core.SE && inTokuno) return Construct(SEWeaponTypes, AosWeaponTypes, WeaponTypes) as BaseWeapon; @@ -424,13 +393,9 @@ namespace Server public static Item RandomWeaponOrJewelry(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLWeaponTypes, AosWeaponTypes, WeaponTypes, JewelryTypes); - #endregion - if (Core.SE && inTokuno) return Construct(SEWeaponTypes, AosWeaponTypes, WeaponTypes, JewelryTypes); @@ -446,13 +411,9 @@ namespace Server public static BaseArmor RandomArmor(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLArmorTypes, ArmorTypes) as BaseArmor; - #endregion - if (Core.SE && inTokuno) return Construct(SEArmorTypes, ArmorTypes) as BaseArmor; @@ -476,13 +437,9 @@ namespace Server public static Item RandomArmorOrHat(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes); - #endregion - if (Core.SE && inTokuno) return Construct(SEArmorTypes, ArmorTypes, SEHatTypes, AosHatTypes, HatTypes); @@ -504,13 +461,9 @@ namespace Server public static BaseArmor RandomArmorOrShield(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLArmorTypes, ArmorTypes, AosShieldTypes, ShieldTypes) as BaseArmor; - #endregion - if (Core.SE && inTokuno) return Construct(SEArmorTypes, ArmorTypes, AosShieldTypes, ShieldTypes) as BaseArmor; @@ -524,13 +477,9 @@ namespace Server public static Item RandomArmorOrShieldOrJewelry(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes); - #endregion - if (Core.SE && inTokuno) return Construct(SEArmorTypes, ArmorTypes, SEHatTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes); @@ -545,14 +494,10 @@ namespace Server public static Item RandomArmorOrShieldOrWeapon(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLWeaponTypes, AosWeaponTypes, WeaponTypes, MLRangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes, MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes); - #endregion - if (Core.SE && inTokuno) return Construct(SEWeaponTypes, AosWeaponTypes, WeaponTypes, SERangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes, SEArmorTypes, ArmorTypes, SEHatTypes, AosHatTypes, HatTypes, AosShieldTypes, @@ -569,15 +514,11 @@ namespace Server public static Item RandomArmorOrShieldOrWeaponOrJewelry(bool inTokuno, bool isMondain) { - #region Mondain's Legacy - if (Core.ML && isMondain) return Construct(MLWeaponTypes, AosWeaponTypes, WeaponTypes, MLRangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes, MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes); - #endregion - if (Core.SE && inTokuno) return Construct(SEWeaponTypes, AosWeaponTypes, WeaponTypes, SERangedWeaponTypes, AosRangedWeaponTypes, RangedWeaponTypes, SEArmorTypes, ArmorTypes, SEHatTypes, AosHatTypes, HatTypes, AosShieldTypes, @@ -590,12 +531,8 @@ namespace Server return Construct(WeaponTypes, RangedWeaponTypes, ArmorTypes, HatTypes, ShieldTypes, JewelryTypes); } - #region Chest of Heirlooms - public static Item ChestOfHeirloomsContains() => Construct(SEArmorTypes, SEHatTypes, SEWeaponTypes, SERangedWeaponTypes, JewelryTypes); - #endregion - public static Item RandomGem() => Construct(GemTypes); public static Item RandomReagent() => Construct(RegTypes); @@ -627,7 +564,7 @@ namespace Server var types = type switch { SpellbookType.Regular => RegularScrollTypes, - SpellbookType.Necromancer => (Core.SE ? SENecromancyScrollTypes : NecromancyScrollTypes), + SpellbookType.Necromancer => Core.SE ? SENecromancyScrollTypes : NecromancyScrollTypes, SpellbookType.Paladin => PaladinScrollTypes, SpellbookType.Arcanist => ArcanistScrollTypes, _ => RegularScrollTypes @@ -682,10 +619,6 @@ namespace Server return talisman; } - #endregion - - #region Construction methods - public static Item Construct(Type type) { try @@ -736,7 +669,5 @@ namespace Server return null; } - - #endregion } } diff --git a/Projects/Scripts/Misc/LootPack.cs b/Projects/Scripts/Misc/LootPack.cs index 049de4904..b2e31c484 100644 --- a/Projects/Scripts/Misc/LootPack.cs +++ b/Projects/Scripts/Misc/LootPack.cs @@ -18,7 +18,6 @@ namespace Server new LootPackItem(typeof(BaseInstrument), 1) }; - public static readonly LootPackItem[] LowScrollItems = { new LootPackItem(typeof(ClumsyScroll), 1) @@ -49,8 +48,6 @@ namespace Server new LootPackItem(typeof(LesserPoisonPotion), 1) }; - #region Old Magic Items - public static readonly LootPackItem[] OldMagicItems = { new LootPackItem(typeof(BaseJewel), 1), @@ -60,8 +57,6 @@ namespace Server new LootPackItem(typeof(BaseShield), 1) }; - #endregion - public static readonly LootPack LowScrolls = new LootPack(new[] { new LootPackEntry(false, LowScrollItems, 100.00, 1) @@ -87,7 +82,7 @@ namespace Server new LootPackEntry(false, PotionItems, 100.00, 1) }); - private LootPackEntry[] m_Entries; + private readonly LootPackEntry[] m_Entries; public LootPack(LootPackEntry[] entries) => m_Entries = entries; @@ -165,8 +160,6 @@ namespace Server } } - #region ML definitions - public static readonly LootPackItem[] AosMagicItemsRichType1 = { new LootPackItem(typeof(BaseWeapon), 211), @@ -185,10 +178,6 @@ namespace Server new LootPackEntry(false, Instruments, 1.00, 1) }); - #endregion - - #region AOS Magic Items - public static readonly LootPackItem[] AosMagicItemsPoor = { new LootPackItem(typeof(BaseWeapon), 3), @@ -234,7 +223,6 @@ namespace Server new LootPackItem(typeof(BaseJewel), 40) }; - public static readonly LootPackItem[] AosMagicItemsRichType2 = { new LootPackItem(typeof(BaseWeapon), 170), @@ -271,10 +259,6 @@ namespace Server new LootPackItem(typeof(BaseJewel), 207) }; - #endregion - - #region SE definitions - public static readonly LootPack SePoor = new LootPack(new[] { new LootPackEntry(true, Gold, 100.00, "2d10+20"), @@ -345,10 +329,6 @@ namespace Server new LootPackEntry(false, Instruments, 2.00, 1) }); - #endregion - - #region AOS definitions - public static readonly LootPack AosPoor = new LootPack(new[] { new LootPackEntry(true, Gold, 100.00, "1d10+10"), @@ -420,10 +400,6 @@ namespace Server new LootPackEntry(false, Instruments, 2.00, 1) }); - #endregion - - #region Pre-AOS definitions - public static readonly LootPack OldPoor = new LootPack(new[] { new LootPackEntry(true, Gold, 100.00, "1d25"), @@ -494,10 +470,6 @@ namespace Server new LootPackEntry(false, OldMagicItems, 100.00, 1, 1, 70, 100) }); - #endregion - - #region Generic accessors - public static LootPack Poor => Core.SE ? SePoor : Core.AOS ? AosPoor : OldPoor; public static LootPack Meager => Core.SE ? SeMeager : Core.AOS ? AosMeager : OldMeager; public static LootPack Average => Core.SE ? SeAverage : Core.AOS ? AosAverage : OldAverage; @@ -506,11 +478,8 @@ namespace Server public static LootPack UltraRich => Core.SE ? SeUltraRich : Core.AOS ? AosUltraRich : OldUltraRich; public static LootPack SuperBoss => Core.SE ? SeSuperBoss : Core.AOS ? AosSuperBoss : OldSuperBoss; - #endregion - /* - // TODO: Uncomment once added - #region Mondain's Legacy + // TODO: Uncomment once added Legacy public static readonly LootPackItem[] ParrotItem = new LootPackItem[] { new LootPackItem( typeof( ParrotItem ), 1 ) @@ -520,13 +489,12 @@ namespace Server { new LootPackEntry( false, ParrotItem, 10.00, 1 ) } ); - #endregion */ } public class LootPackEntry { - private bool m_AtSpawnTime; + private readonly bool m_AtSpawnTime; public LootPackEntry(bool atSpawnTime, LootPackItem[] items, double chance, string quantity) : this(atSpawnTime, items, chance, new LootPackDice(quantity)) @@ -562,17 +530,17 @@ namespace Server MaxIntensity = maxIntensity; } - public int Chance{ get; set; } + public int Chance { get; set; } - public LootPackDice Quantity{ get; set; } + public LootPackDice Quantity { get; set; } - public int MaxProps{ get; set; } + public int MaxProps { get; set; } - public int MinIntensity{ get; set; } + public int MinIntensity { get; set; } - public int MaxIntensity{ get; set; } + public int MaxIntensity { get; set; } - public LootPackItem[] Items{ get; set; } + public LootPackItem[] Items { get; set; } private static bool IsInTokuno(Mobile m) { @@ -585,12 +553,8 @@ namespace Server return m.Map == Map.Tokuno; } - #region Mondain's Legacy - private static bool IsMondain(Mobile m) => MondainsLegacy.IsMLRegion(m.Region); - #endregion - public Item Construct(Mobile from, int luckChance, bool spawning) { if (m_AtSpawnTime != spawning) @@ -620,19 +584,19 @@ namespace Server { int rnd = Utility.RandomMinMax(MinIntensity, MaxIntensity); - if (50 > rnd) + if (rnd < 50) return 1; rnd -= 50; - if (25 > rnd) + if (rnd < 25) return 2; rnd -= 25; - if (14 > rnd) + if (rnd < 14) return 3; rnd -= 14; - if (8 > rnd) + if (rnd < 8) return 4; return 5; @@ -642,7 +606,7 @@ namespace Server { if (item != null) { - if (item is BaseWeapon && 1 > Utility.Random(100)) + if (item is BaseWeapon && Utility.Random(100) < 1) { item.Delete(); item = new FireHorn(); @@ -680,28 +644,28 @@ namespace Server { if (item is BaseWeapon weapon) { - if (80 > Utility.Random(100)) + if (Utility.Random(100) < 80) weapon.AccuracyLevel = (WeaponAccuracyLevel)GetRandomOldBonus(); - if (60 > Utility.Random(100)) + if (Utility.Random(100) < 60) weapon.DamageLevel = (WeaponDamageLevel)GetRandomOldBonus(); - if (40 > Utility.Random(100)) + if (Utility.Random(100) < 40) weapon.DurabilityLevel = (WeaponDurabilityLevel)GetRandomOldBonus(); - if (5 > Utility.Random(100)) + if (Utility.Random(100) < 5) weapon.Slayer = SlayerName.Silver; if (from != null && weapon.AccuracyLevel == 0 && weapon.DamageLevel == 0 && - weapon.DurabilityLevel == 0 && weapon.Slayer == SlayerName.None && 5 > Utility.Random(100)) + weapon.DurabilityLevel == 0 && weapon.Slayer == SlayerName.None && Utility.Random(100) < 5) weapon.Slayer = SlayerGroup.GetLootSlayerType(from.GetType()); } else if (item is BaseArmor armor) { - if (80 > Utility.Random(100)) + if (Utility.Random(100) < 80) armor.ProtectionLevel = (ArmorProtectionLevel)GetRandomOldBonus(); - if (40 > Utility.Random(100)) + if (Utility.Random(100) < 40) armor.Durability = (ArmorDurabilityLevel)GetRandomOldBonus(); } } @@ -798,9 +762,9 @@ namespace Server public class LootPackItem { - private static Type[] m_BlankTypes = { typeof(BlankScroll) }; + private static readonly Type[] m_BlankTypes = { typeof(BlankScroll) }; - private static Type[][] m_NecroTypes = + private static readonly Type[][] m_NecroTypes = { new[] // low { @@ -830,9 +794,9 @@ namespace Server Chance = chance; } - public Type Type{ get; set; } + public Type Type { get; set; } - public int Chance{ get; set; } + public int Chance { get; set; } public static Item RandomScroll(int index, int minCircle, int maxCircle) { @@ -944,11 +908,11 @@ namespace Server Bonus = bonus; } - public int Count{ get; set; } + public int Count { get; set; } - public int Sides{ get; set; } + public int Sides { get; set; } - public int Bonus{ get; set; } + public int Bonus { get; set; } public int Roll() { diff --git a/Projects/Scripts/Misc/MapDefinitions.cs b/Projects/Scripts/Misc/MapDefinitions.cs index f0558527a..4b50c9ea4 100644 --- a/Projects/Scripts/Misc/MapDefinitions.cs +++ b/Projects/Scripts/Misc/MapDefinitions.cs @@ -5,7 +5,7 @@ namespace Server.Misc public static void Configure() { /* Here we configure all maps. Some notes: - * + * * 1) The first 32 maps are reserved for core use. * 2) Map 0x7F is reserved for core use. * 3) Map 0xFF is reserved for core use. @@ -23,7 +23,7 @@ namespace Server.Misc /* Example of registering a custom map: * RegisterMap( 32, 0, 0, 6144, 4096, 3, "Iceland", MapRules.FeluccaRules ); - * + * * Defined: * RegisterMap( , , , , , , , ); * - : An unreserved unique index for this map diff --git a/Projects/Scripts/Misc/MapUO.cs b/Projects/Scripts/Misc/MapUO.cs index 7263c6530..58a613194 100644 --- a/Projects/Scripts/Misc/MapUO.cs +++ b/Projects/Scripts/Misc/MapUO.cs @@ -25,7 +25,7 @@ namespace Server.Misc { Packets.PartyTrack packet = new Packets.PartyTrack(from, party); - if (packet.UnderlyingStream.Length > 8) + if (packet.Stream.Length > 8) state.Send(packet); } } @@ -40,7 +40,7 @@ namespace Server.Misc Packets.GuildTrack packet = new Packets.GuildTrack(from, guild, locations); - if (packet.UnderlyingStream.Length > (locations ? 9 : 5)) + if (packet.Stream.Length > (locations ? 9 : 5)) state.Send(packet); } else @@ -74,13 +74,13 @@ namespace Server.Misc if (Utility.InUpdateRange(from, mob) && from.CanSee(mob)) continue; - m_Stream.Write(mob.Serial); - m_Stream.Write((short)mob.X); - m_Stream.Write((short)mob.Y); - m_Stream.Write((byte)(mob.Map?.MapID ?? 0)); + Stream.Write(mob.Serial); + Stream.Write((short)mob.X); + Stream.Write((short)mob.Y); + Stream.Write((byte)(mob.Map?.MapID ?? 0)); } - m_Stream.Write(0); + Stream.Write(0); } } @@ -88,14 +88,14 @@ namespace Server.Misc { public GuildTrack() : base(0x02, 5) { - m_Stream.Write((byte)0); - m_Stream.Write(0); + Stream.Write((byte)0); + Stream.Write(0); } public GuildTrack(Mobile from, Guild guild, bool locations) : base(0x02, (guild.Members.Count - 1) * (locations ? 10 : 4) + 5) { - m_Stream.Write((byte)(locations ? 1 : 0)); + Stream.Write((byte)(locations ? 1 : 0)); for (int i = 0; i < guild.Members.Count; ++i) { @@ -107,22 +107,22 @@ namespace Server.Misc if (locations && Utility.InUpdateRange(from, mob) && from.CanSee(mob)) continue; - m_Stream.Write(mob.Serial); + Stream.Write(mob.Serial); if (locations) { - m_Stream.Write((short)mob.X); - m_Stream.Write((short)mob.Y); - m_Stream.Write((byte)(mob.Map?.MapID ?? 0)); + Stream.Write((short)mob.X); + Stream.Write((short)mob.Y); + Stream.Write((byte)(mob.Map?.MapID ?? 0)); if (Settings.GuildHitsPercent && mob.Alive) - m_Stream.Write((byte)(mob.Hits / Math.Max(mob.HitsMax, 1.0) * 100)); + Stream.Write((byte)(mob.Hits / Math.Max(mob.HitsMax, 1.0) * 100)); else - m_Stream.Write((byte)0); + Stream.Write((byte)0); } } - m_Stream.Write(0); + Stream.Write(0); } } } diff --git a/Projects/Scripts/Misc/MondainsLegacy.cs b/Projects/Scripts/Misc/MondainsLegacy.cs index 37e0d646c..656ee15a3 100644 --- a/Projects/Scripts/Misc/MondainsLegacy.cs +++ b/Projects/Scripts/Misc/MondainsLegacy.cs @@ -7,7 +7,7 @@ namespace Server { public static class MondainsLegacy { - public static Type[] Artifacts{ get; } = + public static Type[] Artifacts { get; } = { typeof(AegisOfGrace), typeof(BladeDance), typeof(BloodwoodSpirit), typeof(Bonesmasher), typeof(Boomstick), typeof(BrightsightLenses), typeof(FeyLeggings), typeof(FleshRipper), diff --git a/Projects/Scripts/Misc/NameList.cs b/Projects/Scripts/Misc/NameList.cs index 36ba6a249..360f230ca 100644 --- a/Projects/Scripts/Misc/NameList.cs +++ b/Projects/Scripts/Misc/NameList.cs @@ -11,79 +11,79 @@ namespace Server public string[] List { get; } - public bool ContainsName( string name ) + public bool ContainsName(string name) { - for ( int i = 0; i < List.Length; i++ ) - if ( name == List[i] ) + for (int i = 0; i < List.Length; i++) + if (name == List[i]) return true; return false; } - public NameList( string type, XmlElement xml ) + public NameList(string type, XmlElement xml) { Type = type; - List = xml.InnerText.Split( ',' ); + List = xml.InnerText.Split(','); - for ( int i = 0; i < List.Length; ++i ) - List[i] = Utility.Intern( List[i].Trim() ); + for (int i = 0; i < List.Length; ++i) + List[i] = Utility.Intern(List[i].Trim()); } public string GetRandomName() { - if ( List.Length > 0 ) - return List[Utility.Random( List.Length )]; + if (List.Length > 0) + return List[Utility.Random(List.Length)]; return ""; } - public static NameList GetNameList( string type ) + public static NameList GetNameList(string type) { - m_Table.TryGetValue( type, out NameList n ); + m_Table.TryGetValue(type, out NameList n); return n; } - public static string RandomName( string type ) => GetNameList( type )?.GetRandomName() ?? ""; + public static string RandomName(string type) => GetNameList(type)?.GetRandomName() ?? ""; - private static Dictionary m_Table; + private static readonly Dictionary m_Table; static NameList() { - m_Table = new Dictionary( StringComparer.OrdinalIgnoreCase ); + m_Table = new Dictionary(StringComparer.OrdinalIgnoreCase); - string filePath = Path.Combine( Core.BaseDirectory, "Data/names.xml" ); + string filePath = Path.Combine(Core.BaseDirectory, "Data/names.xml"); - if ( !File.Exists( filePath ) ) + if (!File.Exists(filePath)) return; try { - Load( filePath ); + Load(filePath); } - catch ( Exception e ) + catch (Exception e) { - Console.WriteLine( "Warning: Exception caught loading name lists:" ); - Console.WriteLine( e ); + Console.WriteLine("Warning: Exception caught loading name lists:"); + Console.WriteLine(e); } } - private static void Load( string filePath ) + private static void Load(string filePath) { XmlDocument doc = new XmlDocument(); - doc.Load( filePath ); + doc.Load(filePath); XmlElement root = doc["names"]; - foreach ( XmlElement element in root.GetElementsByTagName( "namelist" ) ) + foreach (XmlElement element in root.GetElementsByTagName("namelist")) { - string type = element.GetAttribute( "type" ); + string type = element.GetAttribute("type"); - if ( string.IsNullOrEmpty( type ) ) + if (string.IsNullOrEmpty(type)) continue; try { - NameList list = new NameList( type, element ); + NameList list = new NameList(type, element); m_Table[type] = list; } diff --git a/Projects/Scripts/Misc/NameVerification.cs b/Projects/Scripts/Misc/NameVerification.cs index 44ef8f68e..ed6cd638c 100644 --- a/Projects/Scripts/Misc/NameVerification.cs +++ b/Projects/Scripts/Misc/NameVerification.cs @@ -7,9 +7,9 @@ namespace Server.Misc ' ', '-', '.', '\'' }; - public static readonly char[] Empty = new char[0]; + public static readonly char[] Empty = System.Array.Empty(); - public static string[] StartDisallowed{ get; } = + public static string[] StartDisallowed { get; } = { "seer", "counselor", @@ -19,7 +19,7 @@ namespace Server.Misc "lord" }; - public static string[] Disallowed{ get; } = + public static string[] Disallowed { get; } = { "jigaboo", "chigaboo", @@ -129,7 +129,7 @@ namespace Server.Misc name = name.ToLower(); if (!allowLetters || !allowDigits || - exceptions.Length > 0 && (noExceptionsAtStart || maxExceptions < int.MaxValue)) + (exceptions.Length > 0 && (noExceptionsAtStart || maxExceptions < int.MaxValue))) for (int i = 0; i < name.Length; ++i) { char c = name[i]; @@ -156,7 +156,7 @@ namespace Server.Misc if (c == exceptions[j]) except = true; - if (!except || i == 0 && noExceptionsAtStart) + if (!except || (i == 0 && noExceptionsAtStart)) return false; if (exceptCount++ == maxExceptions) @@ -195,4 +195,4 @@ namespace Server.Misc return true; } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Misc/Notoriety.cs b/Projects/Scripts/Misc/Notoriety.cs index 5c9d661da..8bf226371 100644 --- a/Projects/Scripts/Misc/Notoriety.cs +++ b/Projects/Scripts/Misc/Notoriety.cs @@ -50,7 +50,7 @@ namespace Server.Misc /*private static bool CheckHarmfulStatus( GuildStatus from, GuildStatus target ) { - if ( from == GuildStatus.Waring && target == GuildStatus.Waring ) + if (from == GuildStatus.Waring && target == GuildStatus.Waring) return true; return false; @@ -62,8 +62,6 @@ namespace Server.Misc target.AccessLevel > AccessLevel.Player) return true; - #region Dueling - PlayerMobile pmFrom = from as PlayerMobile; PlayerMobile pmTarg = target as PlayerMobile; @@ -80,7 +78,7 @@ namespace Server.Misc return false; if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && - (pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied || + ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated)) return false; @@ -103,21 +101,14 @@ namespace Server.Misc if (from.Region.IsPartOf() || target.Region.IsPartOf()) return false; - #endregion - Map map = from.Map; - #region Factions - Faction targetFaction = Faction.Find(target, true); if ((!Core.ML || map == Faction.Facet) && targetFaction != null) if (Faction.Find(from, true) != targetFaction) return false; - #endregion - - if ((map?.Rules & MapRules.BeneficialRestrictions) == 0) return true; // In felucca, anything goes @@ -143,8 +134,6 @@ namespace Server.Misc target.AccessLevel > AccessLevel.Player) return true; - #region Dueling - PlayerMobile pmFrom = from as PlayerMobile; PlayerMobile pmTarg = target as PlayerMobile; BaseCreature bcTarg = target as BaseCreature; @@ -162,7 +151,7 @@ namespace Server.Misc return false; if (pmFrom.DuelContext != null && pmFrom.DuelContext == pmTarg.DuelContext && - (pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started || pmFrom.DuelContext.Tied || + ((pmFrom.DuelContext.StartedReadyCountdown && !pmFrom.DuelContext.Started) || pmFrom.DuelContext.Tied || pmFrom.DuelPlayer.Eliminated || pmTarg.DuelPlayer.Eliminated)) return false; @@ -172,7 +161,7 @@ namespace Server.Misc pmFrom.DuelPlayer.Participant == pmTarg.DuelPlayer.Participant) return false; - if ( pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext) + if (pmFrom.DuelContext?.Started == true && pmFrom.DuelContext == pmTarg.DuelContext) return true; } @@ -182,8 +171,6 @@ namespace Server.Misc if (from.Region.IsPartOf() || target.Region.IsPartOf()) return false; - #endregion - Map map = from.Map; if ((map?.Rules & MapRules.HarmfulRestrictions) == 0) @@ -206,7 +193,7 @@ namespace Server.Misc (fromGuild == targetGuild || fromGuild.IsAlly(targetGuild) || fromGuild.IsEnemy(targetGuild))) return true; // Guild allies or enemies can be harmful - if (bcTarg?.Controlled == true || bcTarg?.Summoned == true && bcTarg?.SummonMaster != from) + if (bcTarg?.Controlled == true || (bcTarg?.Summoned == true && bcTarg?.SummonMaster != from)) return false; // Cannot harm other controlled mobiles if (target.Player) @@ -265,7 +252,7 @@ namespace Server.Misc int actual = Notoriety.CanBeAttacked; - if (target.Kills >= 5 || body.IsMonster && IsSummoned(creature) || creature.AlwaysMurderer || + if (target.Kills >= 5 || (body.IsMonster && IsSummoned(creature)) || creature.AlwaysMurderer || creature.IsAnimatedDead) actual = Notoriety.Murderer; @@ -275,7 +262,7 @@ namespace Server.Misc Party sourceParty = Party.Get(source); for (int i = 0; i < list.Count; ++i) - if (list[i] == source || sourceParty != null && Party.Get(list[i]) == sourceParty) + if (list[i] == source || (sourceParty != null && Party.Get(list[i]) == sourceParty)) return actual; return Notoriety.Innocent; @@ -317,14 +304,10 @@ namespace Server.Misc PlayerMobile pmFrom = source as PlayerMobile; PlayerMobile pmTarg = target as PlayerMobile; - #region Dueling - if (pmFrom != null && pmTarg != null) if (pmFrom.DuelContext?.StartedBeginCountdown == true && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext) return pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy; - #endregion - if (target.AccessLevel > AccessLevel.Player) return Notoriety.CanBeAttacked; @@ -339,7 +322,7 @@ namespace Server.Misc if (Core.ML && master != null) { - if (source == master && CheckAggressor(bcTarg.Aggressors, source) || + if ((source == master && CheckAggressor(bcTarg.Aggressors, source)) || CheckAggressor(source.Aggressors, bcTarg)) return Notoriety.CanBeAttacked; @@ -351,8 +334,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 BaseFamiliar) && !(target is ArcaneFey) && + !(target is Golem)) || bcTarg?.AlwaysMurderer == true || bcTarg?.IsAnimatedDead == true) return Notoriety.Murderer; if (target.Criminal) @@ -385,8 +368,8 @@ namespace Server.Misc return Notoriety.CanBeAttacked; if (bcTarg?.InitialInnocent != true) - if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bcTarg) && pmTarg == null || - !Core.ML && !target.CanBeginAction()) + if ((!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bcTarg) && pmTarg == null) || + (!Core.ML && !target.CanBeginAction())) return Notoriety.CanBeAttacked; if (CheckAggressor(source.Aggressors, target)) diff --git a/Projects/Scripts/Misc/Poison.cs b/Projects/Scripts/Misc/Poison.cs index 18fcb1caf..1e0a92f5b 100644 --- a/Projects/Scripts/Misc/Poison.cs +++ b/Projects/Scripts/Misc/Poison.cs @@ -10,17 +10,19 @@ namespace Server { public class PoisonImpl : Poison { - private int m_Count, m_MessageInterval; + private readonly int m_Count; + private readonly int m_MessageInterval; // Timers - private TimeSpan m_Delay; - private TimeSpan m_Interval; + private readonly TimeSpan m_Delay; + private readonly TimeSpan m_Interval; // Info // Damage - private int m_Minimum, m_Maximum; - private double m_Scalar; + private readonly int m_Minimum; + private readonly int m_Maximum; + private readonly double m_Scalar; public PoisonImpl(string name, int level, int min, int max, double percent, double delay, double interval, int count, int messageInterval) @@ -36,9 +38,9 @@ namespace Server m_MessageInterval = messageInterval; } - public override string Name{ get; } + public override string Name { get; } - public override int Level{ get; } + public override int Level { get; } [CallPriority(10)] public static void Configure() @@ -74,8 +76,8 @@ namespace Server { private int m_Index; private int m_LastDamage; - private Mobile m_Mobile; - private PoisonImpl m_Poison; + private readonly Mobile m_Mobile; + private readonly PoisonImpl m_Poison; public PoisonTimer(Mobile m, PoisonImpl p) : base(p.m_Delay, p.m_Interval) { @@ -84,13 +86,13 @@ namespace Server m_Poison = p; } - public Mobile From{ get; set; } + public Mobile From { get; set; } protected override void OnTick() { - if (Core.AOS && m_Poison.Level < 4 && - TransformationSpellHelper.UnderTransformation(m_Mobile, typeof(VampiricEmbraceSpell)) || - m_Poison.Level < 3 && OrangePetals.UnderEffect(m_Mobile) || + if ((Core.AOS && m_Poison.Level < 4 && + TransformationSpellHelper.UnderTransformation(m_Mobile, typeof(VampiricEmbraceSpell))) || + (m_Poison.Level < 3 && OrangePetals.UnderEffect(m_Mobile)) || AnimalForm.UnderTransformation(m_Mobile, typeof(Unicorn))) if (m_Mobile.CurePoison(m_Mobile)) { @@ -138,8 +140,7 @@ namespace Server AOS.Damage(m_Mobile, From, damage, 0, 0, 0, 100, 0); - if (0.60 <= Utility.RandomDouble() - ) // OSI: randomly revealed between first and third damage tick, guessing 60% chance + if (Utility.RandomDouble() >= 0.60) // OSI: randomly revealed between first and third damage tick, guessing 60% chance m_Mobile.RevealingAction(); if (m_Index % m_Poison.m_MessageInterval == 0) diff --git a/Projects/Scripts/Misc/ProfanityProtection.cs b/Projects/Scripts/Misc/ProfanityProtection.cs index 1e777872c..d9dd2d95e 100644 --- a/Projects/Scripts/Misc/ProfanityProtection.cs +++ b/Projects/Scripts/Misc/ProfanityProtection.cs @@ -12,20 +12,21 @@ namespace Server.Misc public static class ProfanityProtection { - private static bool Enabled = false; + // TODO: Move this to configuration + private static readonly bool Enabled = false; - private static ProfanityAction + private static readonly ProfanityAction Action = ProfanityAction.Disallow; // change here what to do when profanity is detected - public static char[] Exceptions{ get; } = + public static char[] Exceptions { get; } = { ' ', '-', '.', '\'', '"', ',', '_', '+', '=', '~', '`', '!', '^', '*', '\\', '/', ';', ':', '<', '>', '[', ']', '{', '}', '?', '|', '(', ')', '%', '$', '&', '#', '@' }; - public static string[] StartDisallowed{ get; } = { }; + public static string[] StartDisallowed { get; } = { }; - public static string[] Disallowed{ get; } = + public static string[] Disallowed { get; } = { "jigaboo", "chigaboo", @@ -93,16 +94,16 @@ namespace Server.Misc from.CriminalAction(false); return true; case ProfanityAction.Disconnect: - { - from.NetState?.Dispose(); + { + from.NetState?.Dispose(); - return false; - } + return false; + } default: case ProfanityAction.Other: // TODO: Provide custom implementation if this is chosen - { - return true; - } + { + return true; + } } } diff --git a/Projects/Scripts/Misc/ProtocolExtensions.cs b/Projects/Scripts/Misc/ProtocolExtensions.cs index 5aeee0a96..16dd23c08 100644 --- a/Projects/Scripts/Misc/ProtocolExtensions.cs +++ b/Projects/Scripts/Misc/ProtocolExtensions.cs @@ -5,7 +5,7 @@ namespace Server.Misc { public class ProtocolExtensions { - private static PacketHandler[] m_Handlers = new PacketHandler[0x100]; + private static readonly PacketHandler[] m_Handlers = new PacketHandler[0x100]; public static void Initialize() { @@ -58,7 +58,7 @@ namespace Server.Misc { EnsureCapacity(4 + capacity); - m_Stream.Write((byte)packetID); + Stream.Write((byte)packetID); } } } \ No newline at end of file diff --git a/Projects/Scripts/Misc/RaceDefinitions.cs b/Projects/Scripts/Misc/RaceDefinitions.cs index eb9720308..65efac673 100644 --- a/Projects/Scripts/Misc/RaceDefinitions.cs +++ b/Projects/Scripts/Misc/RaceDefinitions.cs @@ -35,8 +35,8 @@ namespace Server.Misc if (itemID == 0) return true; - if (female && itemID == 0x2048 || !female && itemID == 0x2046) - return false; //Buns & Receding Hair + if ((female && itemID == 0x2048) || (!female && itemID == 0x2046)) + return false; // Buns & Receding Hair if (itemID >= 0x203B && itemID <= 0x203D) return true; @@ -47,19 +47,19 @@ namespace Server.Misc return false; } - public override int RandomHair(bool female) //Random hair doesn't include baldness + public override int RandomHair(bool female) // Random hair doesn't include baldness { return Utility.Random(9) switch { - 0 => 0x203B, //Short - 1 => 0x203C, //Long - 2 => 0x203D, //Pony Tail - 3 => 0x2044, //Mohawk - 4 => 0x2045, //Pageboy - 5 => 0x2047, //Afro - 6 => 0x2049, //Pig tails - 7 => 0x204A, //Krisna - _ => (female ? 0x2046 : 0x2048) + 0 => 0x203B, // Short + 1 => 0x203C, // Long + 2 => 0x203D, // Pony Tail + 3 => 0x2044, // Mohawk + 4 => 0x2045, // Pageboy + 5 => 0x2047, // Afro + 6 => 0x2049, // Pig tails + 7 => 0x204A, // Krisna + _ => female ? 0x2046 : 0x2048 }; } @@ -115,7 +115,7 @@ namespace Server.Misc private class Elf : Race { - private static int[] m_SkinHues = + private static readonly int[] m_SkinHues = { 0x0BF, 0x24D, 0x24E, 0x24F, 0x353, 0x361, 0x367, 0x374, 0x375, 0x376, 0x381, 0x382, 0x383, 0x384, 0x385, 0x389, @@ -123,7 +123,7 @@ namespace Server.Misc 0x51D, 0x53F, 0x579, 0x76B, 0x76C, 0x76D, 0x835, 0x903 }; - private static int[] m_HairHues = + private static readonly int[] m_HairHues = { 0x034, 0x035, 0x036, 0x037, 0x038, 0x039, 0x058, 0x08E, 0x08F, 0x090, 0x091, 0x092, 0x101, 0x159, 0x15A, 0x15B, @@ -144,7 +144,7 @@ namespace Server.Misc if (itemID == 0) return true; - if (female && (itemID == 0x2FCD || itemID == 0x2FBF) || !female && (itemID == 0x2FCC || itemID == 0x2FD0)) + if ((female && (itemID == 0x2FCD || itemID == 0x2FBF)) || (!female && (itemID == 0x2FCC || itemID == 0x2FD0))) return false; if (itemID >= 0x2FBF && itemID <= 0x2FC2) @@ -156,18 +156,18 @@ namespace Server.Misc return false; } - public override int RandomHair(bool female) //Random hair doesn't include baldness + public override int RandomHair(bool female) // Random hair doesn't include baldness { return Utility.Random(8) switch { - 0 => 0x2FC0, //Long Feather - 1 => 0x2FC1, //Short - 2 => 0x2FC2, //Mullet - 3 => 0x2FCE, //Knob - 4 => 0x2FCF, //Braided - 5 => 0x2FD1, //Spiked - 6 => (female ? 0x2FCC : 0x2FBF), //Flower or Mid-long - _ => (female ? 0x2FD0 : 0x2FCD) + 0 => 0x2FC0, // Long Feather + 1 => 0x2FC1, // Short + 2 => 0x2FC2, // Mullet + 3 => 0x2FCE, // Knob + 4 => 0x2FCF, // Braided + 5 => 0x2FD1, // Spiked + 6 => female ? 0x2FCC : 0x2FBF, // Flower or Mid-long + _ => female ? 0x2FD0 : 0x2FCD }; } @@ -198,8 +198,6 @@ namespace Server.Misc public override int RandomHairHue() => m_HairHues[Utility.Random(m_HairHues.Length)]; } - #region SA - private class Gargoyle : Race { // Todo Finish body hues @@ -229,7 +227,7 @@ namespace Server.Misc { if (female == false) return itemID >= 0x4258 && itemID <= 0x425F; - return itemID == 0x4261 || itemID == 0x4262 || itemID >= 0x4273 && itemID <= 0x4275 || itemID == 0x42B0 || + return itemID == 0x4261 || itemID == 0x4262 || (itemID >= 0x4273 && itemID <= 0x4275) || itemID == 0x42B0 || itemID == 0x42B1 || itemID == 0x42AA || itemID == 0x42AB; } @@ -273,7 +271,5 @@ namespace Server.Misc public override int RandomHairHue() => m_HornHues[Utility.Random(m_HornHues.Length)]; } - - #endregion } } diff --git a/Projects/Scripts/Misc/RegenRates.cs b/Projects/Scripts/Misc/RegenRates.cs index 457a2f56b..2c4290328 100644 --- a/Projects/Scripts/Misc/RegenRates.cs +++ b/Projects/Scripts/Misc/RegenRates.cs @@ -55,13 +55,13 @@ namespace Server.Misc if (bc?.IsParagon == true || from is Leviathan) points += 40; - if (Core.ML && from.Race == Race.Human) //Is this affected by the cap? + if (Core.ML && from.Race == Race.Human) // Is this affected by the cap? points += 2; if (points < 0) points = 0; - if (Core.ML && from is PlayerMobile) //does racial bonus go before/after? + if (Core.ML && from is PlayerMobile) // does racial bonus go before/after? points = Math.Min(points, 18); if (CheckTransform(from, typeof(HorrificBeastSpell))) @@ -82,7 +82,7 @@ namespace Server.Misc int points = (int)(from.Skills.Focus.Value * 0.1); - if (from is BaseCreature creature && creature.IsParagon || from is Leviathan) + if ((from is BaseCreature creature && creature.IsParagon) || from is Leviathan) points += 40; int cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenStam); @@ -130,7 +130,7 @@ namespace Server.Misc double totalPoints = focusPoints + medPoints + (from.Meditating ? medPoints > 13.0 ? 13.0 : medPoints : 0.0); - if (from is BaseCreature creature && creature.IsParagon || from is Leviathan) + if ((from is BaseCreature creature && creature.IsParagon) || from is Leviathan) totalPoints += 40; int cappedPoints = AosAttributes.GetValue(from, AosAttribute.RegenMana); @@ -205,7 +205,7 @@ namespace Server.Misc return ar.MeditationAllowance switch { ArmorMeditationAllowance.None => ar.BaseArmorRatingScaled, - ArmorMeditationAllowance.Half => (ar.BaseArmorRatingScaled / 2.0), + ArmorMeditationAllowance.Half => ar.BaseArmorRatingScaled / 2.0, ArmorMeditationAllowance.All => 0.0, _ => ar.BaseArmorRatingScaled }; diff --git a/Projects/Scripts/Misc/ResourceInfo.cs b/Projects/Scripts/Misc/ResourceInfo.cs index e962f3993..a90c2a0cb 100644 --- a/Projects/Scripts/Misc/ResourceInfo.cs +++ b/Projects/Scripts/Misc/ResourceInfo.cs @@ -113,7 +113,7 @@ namespace Server.Items dullCopper.WeaponLowerRequirements = 50; dullCopper.RunicMinAttributes = 1; dullCopper.RunicMaxAttributes = 2; - if ( Core.ML ) + if (Core.ML) { dullCopper.RunicMinIntensity = 40; dullCopper.RunicMaxIntensity = 100; @@ -134,7 +134,7 @@ namespace Server.Items shadowIron.WeaponDurability = 50; shadowIron.RunicMinAttributes = 2; shadowIron.RunicMaxAttributes = 2; - if ( Core.ML ) + if (Core.ML) { shadowIron.RunicMinIntensity = 45; shadowIron.RunicMaxIntensity = 100; @@ -155,7 +155,7 @@ namespace Server.Items copper.WeaponEnergyDamage = 20; copper.RunicMinAttributes = 2; copper.RunicMaxAttributes = 3; - if ( Core.ML ) + if (Core.ML) { copper.RunicMinIntensity = 50; copper.RunicMaxIntensity = 100; @@ -175,7 +175,7 @@ namespace Server.Items bronze.WeaponFireDamage = 40; bronze.RunicMinAttributes = 3; bronze.RunicMaxAttributes = 3; - if ( Core.ML ) + if (Core.ML) { bronze.RunicMinIntensity = 55; bronze.RunicMaxIntensity = 100; @@ -198,7 +198,7 @@ namespace Server.Items golden.WeaponLowerRequirements = 50; golden.RunicMinAttributes = 3; golden.RunicMaxAttributes = 4; - if ( Core.ML ) + if (Core.ML) { golden.RunicMinIntensity = 60; golden.RunicMaxIntensity = 100; @@ -220,7 +220,7 @@ namespace Server.Items agapite.WeaponEnergyDamage = 20; agapite.RunicMinAttributes = 4; agapite.RunicMaxAttributes = 4; - if ( Core.ML ) + if (Core.ML) { agapite.RunicMinIntensity = 65; agapite.RunicMaxIntensity = 100; @@ -242,7 +242,7 @@ namespace Server.Items verite.WeaponEnergyDamage = 20; verite.RunicMinAttributes = 4; verite.RunicMaxAttributes = 5; - if ( Core.ML ) + if (Core.ML) { verite.RunicMinIntensity = 70; verite.RunicMaxIntensity = 100; @@ -266,7 +266,7 @@ namespace Server.Items valorite.WeaponEnergyDamage = 20; valorite.RunicMinAttributes = 5; valorite.RunicMaxAttributes = 5; - if ( Core.ML ) + if (Core.ML) { valorite.RunicMinIntensity = 85; valorite.RunicMaxIntensity = 100; @@ -283,7 +283,7 @@ namespace Server.Items spined.ArmorLuck = 40; spined.RunicMinAttributes = 1; spined.RunicMaxAttributes = 3; - if ( Core.ML ) + if (Core.ML) { spined.RunicMinIntensity = 40; spined.RunicMaxIntensity = 100; @@ -303,7 +303,7 @@ namespace Server.Items horned.ArmorEnergyResist = 2; horned.RunicMinAttributes = 3; horned.RunicMaxAttributes = 4; - if ( Core.ML ) + if (Core.ML) { horned.RunicMinIntensity = 45; horned.RunicMaxIntensity = 100; @@ -323,7 +323,7 @@ namespace Server.Items barbed.ArmorEnergyResist = 4; barbed.RunicMinAttributes = 4; barbed.RunicMaxAttributes = 5; - if ( Core.ML ) + if (Core.ML) { barbed.RunicMinIntensity = 50; barbed.RunicMaxIntensity = 100; @@ -364,7 +364,7 @@ namespace Server.Items blue.ArmorPoisonResist = -3; blue.ArmorEnergyResist = 10; - //public static readonly CraftAttributeInfo OakWood, AshWood, YewWood, Heartwood, Bloodwood, Frostwood; + // public static readonly CraftAttributeInfo OakWood, AshWood, YewWood, Heartwood, Bloodwood, Frostwood; CraftAttributeInfo oak = OakWood = new CraftAttributeInfo(); @@ -394,7 +394,7 @@ namespace Server.Items public Type[] ResourceTypes { get; } - public CraftResourceInfo( int hue, int number, string name, CraftAttributeInfo attributeInfo, CraftResource resource, params Type[] resourceTypes ) + public CraftResourceInfo(int hue, int number, string name, CraftAttributeInfo attributeInfo, CraftResource resource, params Type[] resourceTypes) { Hue = hue; Number = number; @@ -403,71 +403,71 @@ namespace Server.Items Resource = resource; ResourceTypes = resourceTypes; - for ( int i = 0; i < resourceTypes.Length; ++i ) - CraftResources.RegisterType( resourceTypes[i], resource ); + for (int i = 0; i < resourceTypes.Length; ++i) + CraftResources.RegisterType(resourceTypes[i], resource); } } - public class CraftResources + public static class CraftResources { - private static CraftResourceInfo[] m_MetalInfo = { - new CraftResourceInfo( 0x000, 1053109, "Iron", CraftAttributeInfo.Blank, CraftResource.Iron, typeof( IronIngot ), typeof( IronOre ), typeof( Granite ) ), - new CraftResourceInfo( 0x973, 1053108, "Dull Copper", CraftAttributeInfo.DullCopper, CraftResource.DullCopper, typeof( DullCopperIngot ), typeof( DullCopperOre ), typeof( DullCopperGranite ) ), - new CraftResourceInfo( 0x966, 1053107, "Shadow Iron", CraftAttributeInfo.ShadowIron, CraftResource.ShadowIron, typeof( ShadowIronIngot ), typeof( ShadowIronOre ), typeof( ShadowIronGranite ) ), - new CraftResourceInfo( 0x96D, 1053106, "Copper", CraftAttributeInfo.Copper, CraftResource.Copper, typeof( CopperIngot ), typeof( CopperOre ), typeof( CopperGranite ) ), - new CraftResourceInfo( 0x972, 1053105, "Bronze", CraftAttributeInfo.Bronze, CraftResource.Bronze, typeof( BronzeIngot ), typeof( BronzeOre ), typeof( BronzeGranite ) ), - new CraftResourceInfo( 0x8A5, 1053104, "Gold", CraftAttributeInfo.Golden, CraftResource.Gold, typeof( GoldIngot ), typeof( GoldOre ), typeof( GoldGranite ) ), - new CraftResourceInfo( 0x979, 1053103, "Agapite", CraftAttributeInfo.Agapite, CraftResource.Agapite, typeof( AgapiteIngot ), typeof( AgapiteOre ), typeof( AgapiteGranite ) ), - new CraftResourceInfo( 0x89F, 1053102, "Verite", CraftAttributeInfo.Verite, CraftResource.Verite, typeof( VeriteIngot ), typeof( VeriteOre ), typeof( VeriteGranite ) ), - new CraftResourceInfo( 0x8AB, 1053101, "Valorite", CraftAttributeInfo.Valorite, CraftResource.Valorite, typeof( ValoriteIngot ), typeof( ValoriteOre ), typeof( ValoriteGranite ) ) + private static readonly CraftResourceInfo[] m_MetalInfo = { + new CraftResourceInfo(0x000, 1053109, "Iron", CraftAttributeInfo.Blank, CraftResource.Iron, typeof(IronIngot), typeof(IronOre), typeof(Granite)), + new CraftResourceInfo(0x973, 1053108, "Dull Copper", CraftAttributeInfo.DullCopper, CraftResource.DullCopper, typeof(DullCopperIngot), typeof(DullCopperOre), typeof(DullCopperGranite)), + new CraftResourceInfo(0x966, 1053107, "Shadow Iron", CraftAttributeInfo.ShadowIron, CraftResource.ShadowIron, typeof(ShadowIronIngot), typeof(ShadowIronOre), typeof(ShadowIronGranite)), + new CraftResourceInfo(0x96D, 1053106, "Copper", CraftAttributeInfo.Copper, CraftResource.Copper, typeof(CopperIngot), typeof(CopperOre), typeof(CopperGranite)), + new CraftResourceInfo(0x972, 1053105, "Bronze", CraftAttributeInfo.Bronze, CraftResource.Bronze, typeof(BronzeIngot), typeof(BronzeOre), typeof(BronzeGranite)), + new CraftResourceInfo(0x8A5, 1053104, "Gold", CraftAttributeInfo.Golden, CraftResource.Gold, typeof(GoldIngot), typeof(GoldOre), typeof(GoldGranite)), + new CraftResourceInfo(0x979, 1053103, "Agapite", CraftAttributeInfo.Agapite, CraftResource.Agapite, typeof(AgapiteIngot), typeof(AgapiteOre), typeof(AgapiteGranite)), + new CraftResourceInfo(0x89F, 1053102, "Verite", CraftAttributeInfo.Verite, CraftResource.Verite, typeof(VeriteIngot), typeof(VeriteOre), typeof(VeriteGranite)), + new CraftResourceInfo(0x8AB, 1053101, "Valorite", CraftAttributeInfo.Valorite, CraftResource.Valorite, typeof(ValoriteIngot), typeof(ValoriteOre), typeof(ValoriteGranite)) }; - private static CraftResourceInfo[] m_ScaleInfo = { - new CraftResourceInfo( 0x66D, 1053129, "Red Scales", CraftAttributeInfo.RedScales, CraftResource.RedScales, typeof( RedScales ) ), - new CraftResourceInfo( 0x8A8, 1053130, "Yellow Scales", CraftAttributeInfo.YellowScales, CraftResource.YellowScales, typeof( YellowScales ) ), - new CraftResourceInfo( 0x455, 1053131, "Black Scales", CraftAttributeInfo.BlackScales, CraftResource.BlackScales, typeof( BlackScales ) ), - new CraftResourceInfo( 0x851, 1053132, "Green Scales", CraftAttributeInfo.GreenScales, CraftResource.GreenScales, typeof( GreenScales ) ), - new CraftResourceInfo( 0x8FD, 1053133, "White Scales", CraftAttributeInfo.WhiteScales, CraftResource.WhiteScales, typeof( WhiteScales ) ), - new CraftResourceInfo( 0x8B0, 1053134, "Blue Scales", CraftAttributeInfo.BlueScales, CraftResource.BlueScales, typeof( BlueScales ) ) + private static readonly CraftResourceInfo[] m_ScaleInfo = { + new CraftResourceInfo(0x66D, 1053129, "Red Scales", CraftAttributeInfo.RedScales, CraftResource.RedScales, typeof(RedScales)), + new CraftResourceInfo(0x8A8, 1053130, "Yellow Scales", CraftAttributeInfo.YellowScales, CraftResource.YellowScales, typeof(YellowScales)), + new CraftResourceInfo(0x455, 1053131, "Black Scales", CraftAttributeInfo.BlackScales, CraftResource.BlackScales, typeof(BlackScales)), + new CraftResourceInfo(0x851, 1053132, "Green Scales", CraftAttributeInfo.GreenScales, CraftResource.GreenScales, typeof(GreenScales)), + new CraftResourceInfo(0x8FD, 1053133, "White Scales", CraftAttributeInfo.WhiteScales, CraftResource.WhiteScales, typeof(WhiteScales)), + new CraftResourceInfo(0x8B0, 1053134, "Blue Scales", CraftAttributeInfo.BlueScales, CraftResource.BlueScales, typeof(BlueScales)) }; - private static CraftResourceInfo[] m_LeatherInfo = { - new CraftResourceInfo( 0x000, 1049353, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularLeather, typeof( Leather ), typeof( Hides ) ), - new CraftResourceInfo( 0x283, 1049354, "Spined", CraftAttributeInfo.Spined, CraftResource.SpinedLeather, typeof( SpinedLeather ), typeof( SpinedHides ) ), - new CraftResourceInfo( 0x227, 1049355, "Horned", CraftAttributeInfo.Horned, CraftResource.HornedLeather, typeof( HornedLeather ), typeof( HornedHides ) ), - new CraftResourceInfo( 0x1C1, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof( BarbedLeather ), typeof( BarbedHides ) ) + private static readonly CraftResourceInfo[] m_LeatherInfo = { + new CraftResourceInfo(0x000, 1049353, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularLeather, typeof(Leather), typeof(Hides)), + new CraftResourceInfo(0x283, 1049354, "Spined", CraftAttributeInfo.Spined, CraftResource.SpinedLeather, typeof(SpinedLeather), typeof(SpinedHides)), + new CraftResourceInfo(0x227, 1049355, "Horned", CraftAttributeInfo.Horned, CraftResource.HornedLeather, typeof(HornedLeather), typeof(HornedHides)), + new CraftResourceInfo(0x1C1, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof(BarbedLeather), typeof(BarbedHides)) }; - private static CraftResourceInfo[] m_AOSLeatherInfo = { - new CraftResourceInfo( 0x000, 1049353, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularLeather, typeof( Leather ), typeof( Hides ) ), - new CraftResourceInfo( 0x8AC, 1049354, "Spined", CraftAttributeInfo.Spined, CraftResource.SpinedLeather, typeof( SpinedLeather ), typeof( SpinedHides ) ), - new CraftResourceInfo( 0x845, 1049355, "Horned", CraftAttributeInfo.Horned, CraftResource.HornedLeather, typeof( HornedLeather ), typeof( HornedHides ) ), - new CraftResourceInfo( 0x851, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof( BarbedLeather ), typeof( BarbedHides ) ) + private static readonly CraftResourceInfo[] m_AOSLeatherInfo = { + new CraftResourceInfo(0x000, 1049353, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularLeather, typeof(Leather), typeof(Hides)), + new CraftResourceInfo(0x8AC, 1049354, "Spined", CraftAttributeInfo.Spined, CraftResource.SpinedLeather, typeof(SpinedLeather), typeof(SpinedHides)), + new CraftResourceInfo(0x845, 1049355, "Horned", CraftAttributeInfo.Horned, CraftResource.HornedLeather, typeof(HornedLeather), typeof(HornedHides)), + new CraftResourceInfo(0x851, 1049356, "Barbed", CraftAttributeInfo.Barbed, CraftResource.BarbedLeather, typeof(BarbedLeather), typeof(BarbedHides)) }; - private static CraftResourceInfo[] m_WoodInfo = { - new CraftResourceInfo( 0x000, 1011542, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularWood, typeof( Log ), typeof( Board ) ), - new CraftResourceInfo( 0x7DA, 1072533, "Oak", CraftAttributeInfo.OakWood, CraftResource.OakWood, typeof( OakLog ), typeof( OakBoard ) ), - new CraftResourceInfo( 0x4A7, 1072534, "Ash", CraftAttributeInfo.AshWood, CraftResource.AshWood, typeof( AshLog ), typeof( AshBoard ) ), - new CraftResourceInfo( 0x4A8, 1072535, "Yew", CraftAttributeInfo.YewWood, CraftResource.YewWood, typeof( YewLog ), typeof( YewBoard ) ), - new CraftResourceInfo( 0x4A9, 1072536, "Heartwood", CraftAttributeInfo.Heartwood, CraftResource.Heartwood, typeof( HeartwoodLog ), typeof( HeartwoodBoard ) ), - new CraftResourceInfo( 0x4AA, 1072538, "Bloodwood", CraftAttributeInfo.Bloodwood, CraftResource.Bloodwood, typeof( BloodwoodLog ), typeof( BloodwoodBoard ) ), - new CraftResourceInfo( 0x47F, 1072539, "Frostwood", CraftAttributeInfo.Frostwood, CraftResource.Frostwood, typeof( FrostwoodLog ), typeof( FrostwoodBoard ) ) + private static readonly CraftResourceInfo[] m_WoodInfo = { + new CraftResourceInfo(0x000, 1011542, "Normal", CraftAttributeInfo.Blank, CraftResource.RegularWood, typeof(Log), typeof(Board)), + new CraftResourceInfo(0x7DA, 1072533, "Oak", CraftAttributeInfo.OakWood, CraftResource.OakWood, typeof(OakLog), typeof(OakBoard)), + new CraftResourceInfo(0x4A7, 1072534, "Ash", CraftAttributeInfo.AshWood, CraftResource.AshWood, typeof(AshLog), typeof(AshBoard)), + new CraftResourceInfo(0x4A8, 1072535, "Yew", CraftAttributeInfo.YewWood, CraftResource.YewWood, typeof(YewLog), typeof(YewBoard)), + new CraftResourceInfo(0x4A9, 1072536, "Heartwood", CraftAttributeInfo.Heartwood, CraftResource.Heartwood, typeof(HeartwoodLog), typeof(HeartwoodBoard)), + new CraftResourceInfo(0x4AA, 1072538, "Bloodwood", CraftAttributeInfo.Bloodwood, CraftResource.Bloodwood, typeof(BloodwoodLog), typeof(BloodwoodBoard)), + new CraftResourceInfo(0x47F, 1072539, "Frostwood", CraftAttributeInfo.Frostwood, CraftResource.Frostwood, typeof(FrostwoodLog), typeof(FrostwoodBoard)) }; /// /// 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 == CraftResource.None || resource == CraftResource.Iron || resource == CraftResource.RegularLeather || resource == CraftResource.RegularWood; private static Dictionary m_TypeTable; /// /// Registers that '' uses '' so that it can later be queried by /// - public static void RegisterType( Type resourceType, CraftResource resource ) + public static void RegisterType(Type resourceType, CraftResource resource) { - if ( m_TypeTable == null ) + if (m_TypeTable == null) m_TypeTable = new Dictionary(); m_TypeTable[resourceType] = resource; @@ -476,9 +476,9 @@ namespace Server.Items /// /// Returns the value for which '' uses -or- CraftResource.None if an unregistered type was specified. /// - public static CraftResource GetFromType( Type resourceType ) + public static CraftResource GetFromType(Type resourceType) { - if ( m_TypeTable == null ) + if (m_TypeTable == null) return CraftResource.None; return m_TypeTable.TryGetValue(resourceType, out CraftResource res) ? res : CraftResource.None; @@ -487,22 +487,22 @@ namespace Server.Items /// /// Returns a instance describing '' -or- null if an invalid resource was specified. /// - public static CraftResourceInfo GetInfo( CraftResource resource ) + public static CraftResourceInfo GetInfo(CraftResource resource) { var list = GetType(resource) switch { CraftResourceType.Metal => m_MetalInfo, - CraftResourceType.Leather => (Core.AOS ? m_AOSLeatherInfo : m_LeatherInfo), + CraftResourceType.Leather => Core.AOS ? m_AOSLeatherInfo : m_LeatherInfo, CraftResourceType.Scales => m_ScaleInfo, CraftResourceType.Wood => m_WoodInfo, _ => null }; - if ( list != null ) + if (list != null) { - int index = GetIndex( resource ); + int index = GetIndex(resource); - if ( index >= 0 && index < list.Length ) + if (index >= 0 && index < list.Length) return list[index]; } @@ -512,18 +512,18 @@ namespace Server.Items /// /// Returns a value indiciating the type of ''. /// - public static CraftResourceType GetType( CraftResource resource ) + public static CraftResourceType GetType(CraftResource resource) { - if ( resource >= CraftResource.Iron && resource <= CraftResource.Valorite ) + if (resource >= CraftResource.Iron && resource <= CraftResource.Valorite) return CraftResourceType.Metal; - if ( resource >= CraftResource.RegularLeather && resource <= CraftResource.BarbedLeather ) + if (resource >= CraftResource.RegularLeather && resource <= CraftResource.BarbedLeather) return CraftResourceType.Leather; - if ( resource >= CraftResource.RedScales && resource <= CraftResource.BlueScales ) + if (resource >= CraftResource.RedScales && resource <= CraftResource.BlueScales) return CraftResourceType.Scales; - if ( resource >= CraftResource.RegularWood && resource <= CraftResource.Frostwood ) + if (resource >= CraftResource.RegularWood && resource <= CraftResource.Frostwood) return CraftResourceType.Wood; return CraftResourceType.None; @@ -532,7 +532,7 @@ namespace Server.Items /// /// Returns the first in the series of resources for which '' belongs. /// - public static CraftResource GetStart( CraftResource resource ) + public static CraftResource GetStart(CraftResource resource) { return GetType(resource) switch { @@ -547,11 +547,11 @@ namespace Server.Items /// /// Returns the index of '' in the seriest of resources for which it belongs. /// - public static int GetIndex( CraftResource resource ) + public static int GetIndex(CraftResource resource) { - CraftResource start = GetStart( resource ); + CraftResource start = GetStart(resource); - if ( start == CraftResource.None ) + if (start == CraftResource.None) return 0; return resource - start; @@ -560,9 +560,9 @@ namespace Server.Items /// /// Returns the property of '' -or- 0 if an invalid resource was specified. /// - public static int GetLocalizationNumber( CraftResource resource ) + public static int GetLocalizationNumber(CraftResource resource) { - CraftResourceInfo info = GetInfo( resource ); + CraftResourceInfo info = GetInfo(resource); return info?.Number ?? 0; } @@ -570,9 +570,9 @@ namespace Server.Items /// /// Returns the property of '' -or- 0 if an invalid resource was specified. /// - public static int GetHue( CraftResource resource ) + public static int GetHue(CraftResource resource) { - CraftResourceInfo info = GetInfo( resource ); + CraftResourceInfo info = GetInfo(resource); return info?.Hue ?? 0; } @@ -580,9 +580,9 @@ namespace Server.Items /// /// Returns the property of '' -or- an empty string if the resource specified was invalid. /// - public static string GetName( CraftResource resource ) + public static string GetName(CraftResource resource) { - CraftResourceInfo info = GetInfo( resource ); + CraftResourceInfo info = GetInfo(resource); return info == null ? string.Empty : info.Name; } @@ -590,34 +590,34 @@ namespace Server.Items /// /// Returns the value which represents '' -or- CraftResource.None if unable to convert. /// - public static CraftResource GetFromOreInfo( OreInfo info ) + public static CraftResource GetFromOreInfo(OreInfo info) { - if ( info.Name.IndexOf( "Spined" ) >= 0 ) + if (info.Name.IndexOf("Spined") >= 0) return CraftResource.SpinedLeather; - if ( info.Name.IndexOf( "Horned" ) >= 0 ) + if (info.Name.IndexOf("Horned") >= 0) return CraftResource.HornedLeather; - if ( info.Name.IndexOf( "Barbed" ) >= 0 ) + if (info.Name.IndexOf("Barbed") >= 0) return CraftResource.BarbedLeather; - if ( info.Name.IndexOf( "Leather" ) >= 0 ) + if (info.Name.IndexOf("Leather") >= 0) return CraftResource.RegularLeather; - if ( info.Level == 0 ) + if (info.Level == 0) return CraftResource.Iron; - if ( info.Level == 1 ) + if (info.Level == 1) return CraftResource.DullCopper; - if ( info.Level == 2 ) + if (info.Level == 2) return CraftResource.ShadowIron; - if ( info.Level == 3 ) + if (info.Level == 3) return CraftResource.Copper; - if ( info.Level == 4 ) + if (info.Level == 4) return CraftResource.Bronze; - if ( info.Level == 5 ) + if (info.Level == 5) return CraftResource.Gold; - if ( info.Level == 6 ) + if (info.Level == 6) return CraftResource.Agapite; - if ( info.Level == 7 ) + if (info.Level == 7) return CraftResource.Verite; - if ( info.Level == 8 ) + if (info.Level == 8) return CraftResource.Valorite; return CraftResource.None; @@ -626,24 +626,24 @@ namespace Server.Items /// /// Returns the value which represents '', using '' to help resolve leather OreInfo instances. /// - public static CraftResource GetFromOreInfo( OreInfo info, ArmorMaterialType material ) + public static CraftResource GetFromOreInfo(OreInfo info, ArmorMaterialType material) { - if ( material == ArmorMaterialType.Studded || material == ArmorMaterialType.Leather || material == ArmorMaterialType.Spined || - material == ArmorMaterialType.Horned || material == ArmorMaterialType.Barbed ) + if (material == ArmorMaterialType.Studded || material == ArmorMaterialType.Leather || material == ArmorMaterialType.Spined || + material == ArmorMaterialType.Horned || material == ArmorMaterialType.Barbed) { - if ( info.Level == 0 ) + if (info.Level == 0) return CraftResource.RegularLeather; - if ( info.Level == 1 ) + if (info.Level == 1) return CraftResource.SpinedLeather; - if ( info.Level == 2 ) + if (info.Level == 2) return CraftResource.HornedLeather; - if ( info.Level == 3 ) + if (info.Level == 3) return CraftResource.BarbedLeather; return CraftResource.None; } - return GetFromOreInfo( info ); + return GetFromOreInfo(info); } } @@ -651,17 +651,17 @@ namespace Server.Items // No changes to it should be required for custom resources. public class OreInfo { - public static readonly OreInfo Iron = new OreInfo( 0, 0x000, "Iron" ); - public static readonly OreInfo DullCopper = new OreInfo( 1, 0x973, "Dull Copper" ); - public static readonly OreInfo ShadowIron = new OreInfo( 2, 0x966, "Shadow Iron" ); - public static readonly OreInfo Copper = new OreInfo( 3, 0x96D, "Copper" ); - public static readonly OreInfo Bronze = new OreInfo( 4, 0x972, "Bronze" ); - public static readonly OreInfo Gold = new OreInfo( 5, 0x8A5, "Gold" ); - public static readonly OreInfo Agapite = new OreInfo( 6, 0x979, "Agapite" ); - public static readonly OreInfo Verite = new OreInfo( 7, 0x89F, "Verite" ); - public static readonly OreInfo Valorite = new OreInfo( 8, 0x8AB, "Valorite" ); + public static readonly OreInfo Iron = new OreInfo(0, 0x000, "Iron"); + public static readonly OreInfo DullCopper = new OreInfo(1, 0x973, "Dull Copper"); + public static readonly OreInfo ShadowIron = new OreInfo(2, 0x966, "Shadow Iron"); + public static readonly OreInfo Copper = new OreInfo(3, 0x96D, "Copper"); + public static readonly OreInfo Bronze = new OreInfo(4, 0x972, "Bronze"); + public static readonly OreInfo Gold = new OreInfo(5, 0x8A5, "Gold"); + public static readonly OreInfo Agapite = new OreInfo(6, 0x979, "Agapite"); + public static readonly OreInfo Verite = new OreInfo(7, 0x89F, "Verite"); + public static readonly OreInfo Valorite = new OreInfo(8, 0x8AB, "Valorite"); - public OreInfo( int level, int hue, string name ) + public OreInfo(int level, int hue, string name) { Level = level; Hue = hue; diff --git a/Projects/Scripts/Misc/ShardPoller.cs b/Projects/Scripts/Misc/ShardPoller.cs index 19ea08382..c9795342e 100644 --- a/Projects/Scripts/Misc/ShardPoller.cs +++ b/Projects/Scripts/Misc/ShardPoller.cs @@ -10,7 +10,7 @@ namespace Server.Misc { public class ShardPoller : Item { - private static List m_ActivePollers = new List(); + private static readonly List m_ActivePollers = new List(); private bool m_Active; private string m_Title; @@ -19,8 +19,8 @@ namespace Server.Misc public ShardPoller() : base(0x1047) { Duration = TimeSpan.FromHours(24.0); - Options = new ShardPollOption[0]; - Addresses = new IPAddress[0]; + Options = Array.Empty(); + Addresses = Array.Empty(); Movable = false; } @@ -29,9 +29,9 @@ namespace Server.Misc { } - public ShardPollOption[] Options{ get; set; } + public ShardPollOption[] Options { get; set; } - public IPAddress[] Addresses{ get; set; } + public IPAddress[] Addresses { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public string Title @@ -41,10 +41,10 @@ namespace Server.Misc } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public TimeSpan Duration{ get; set; } + public TimeSpan Duration { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public DateTime StartTime{ get; set; } + public DateTime StartTime { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public TimeSpan TimeRemaining @@ -220,22 +220,22 @@ namespace Server.Misc switch (version) { case 0: - { - m_Title = reader.ReadString(); - Duration = reader.ReadTimeSpan(); - StartTime = reader.ReadDateTime(); - m_Active = reader.ReadBool(); + { + m_Title = reader.ReadString(); + Duration = reader.ReadTimeSpan(); + StartTime = reader.ReadDateTime(); + m_Active = reader.ReadBool(); - Options = new ShardPollOption[reader.ReadInt()]; + Options = new ShardPollOption[reader.ReadInt()]; - for (int i = 0; i < Options.Length; ++i) - Options[i] = new ShardPollOption(reader); + for (int i = 0; i < Options.Length; ++i) + Options[i] = new ShardPollOption(reader); - if (m_Active) - m_ActivePollers.Add(this); + if (m_Active) + m_ActivePollers.Add(this); - break; - } + break; + } } } @@ -255,7 +255,7 @@ namespace Server.Misc { m_Title = title; LineBreaks = GetBreaks(m_Title); - Voters = new IPAddress[0]; + Voters = Array.Empty(); } public ShardPollOption(IGenericReader reader) @@ -265,17 +265,17 @@ namespace Server.Misc switch (version) { case 0: - { - m_Title = reader.ReadString(); - LineBreaks = GetBreaks(m_Title); + { + m_Title = reader.ReadString(); + LineBreaks = GetBreaks(m_Title); - Voters = new IPAddress[reader.ReadInt()]; + Voters = new IPAddress[reader.ReadInt()]; - for (int i = 0; i < Voters.Length; ++i) - Voters[i] = Utility.Intern(reader.ReadIPAddress()); + for (int i = 0; i < Voters.Length; ++i) + Voters[i] = Utility.Intern(reader.ReadIPAddress()); - break; - } + break; + } } } @@ -289,10 +289,10 @@ namespace Server.Misc } } - public int LineBreaks{ get; private set; } + public int LineBreaks { get; private set; } public int Votes => Voters.Length; - public IPAddress[] Voters{ get; set; } + public IPAddress[] Voters { get; set; } public bool HasAlreadyVoted(NetState ns) { @@ -365,8 +365,8 @@ namespace Server.Misc public class ShardPollGump : Gump { private const int LabelColor32 = 0xFFFFFF; - private Mobile m_From; - private ShardPoller m_Poller; + private readonly Mobile m_From; + private readonly ShardPoller m_Poller; private Queue m_Polls; public ShardPollGump(Mobile from, ShardPoller poller, bool editing, Queue polls) : base(50, 50) @@ -461,7 +461,7 @@ namespace Server.Misc AddButton(314, height - 47, 242, 241, 0); } - public bool Editing{ get; } + public bool Editing { get; } public void QueuePoll(ShardPoller poller) { @@ -539,11 +539,11 @@ namespace Server.Misc public class ShardPollPrompt : Prompt { - private static Regex m_UrlRegex = + private static readonly Regex m_UrlRegex = new Regex(@"\[url(?:=(.*?))?\](.*?)\[/url\]", RegexOptions.IgnoreCase | RegexOptions.Compiled); - private ShardPollOption m_Option; - private ShardPoller m_Poller; + private readonly ShardPollOption m_Option; + private readonly ShardPoller m_Poller; public ShardPollPrompt(ShardPoller poller, ShardPollOption opt) { diff --git a/Projects/Scripts/Misc/ShrinkTable.cs b/Projects/Scripts/Misc/ShrinkTable.cs index 731535b94..2d5b4e48b 100644 --- a/Projects/Scripts/Misc/ShrinkTable.cs +++ b/Projects/Scripts/Misc/ShrinkTable.cs @@ -36,7 +36,7 @@ namespace Server if (!File.Exists(path)) { - m_Table = new int[0]; + m_Table = System.Array.Empty(); return; } @@ -72,4 +72,4 @@ namespace Server } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Misc/SkillCheck.cs b/Projects/Scripts/Misc/SkillCheck.cs index c0ead7ea3..1844512cd 100644 --- a/Projects/Scripts/Misc/SkillCheck.cs +++ b/Projects/Scripts/Misc/SkillCheck.cs @@ -14,16 +14,16 @@ namespace Server.Misc Int } - public const int Allowance = 3; //How many times may we use the same location/target for gain + public const int Allowance = 3; // How many times may we use the same location/target for gain private const int - LocationSize = 5; //The size of eeach location, make this smaller so players dont have to move as far + LocationSize = 5; // The size of eeach location, make this smaller so players dont have to move as far - private static readonly bool AntiMacroCode = !Core.ML; //Change this to false to disable anti-macro code + private static readonly bool AntiMacroCode = !Core.ML; // Change this to false to disable anti-macro code - public static TimeSpan AntiMacroExpire = TimeSpan.FromMinutes(5.0); //How long do we remember targets/locations? + public static TimeSpan AntiMacroExpire = TimeSpan.FromMinutes(5.0); // How long do we remember targets/locations? - private static bool[] UseAntiMacro = + private static readonly bool[] UseAntiMacro = { // true if this skill uses the anti-macro code, false if it does not false, // Alchemy = 0, @@ -79,12 +79,12 @@ namespace Server.Misc false, // Focus = 50, true, // Chivalry = 51 true, // Bushido = 52 - true, //Ninjitsu = 53 + true, // Ninjitsu = 53 true // Spellweaving }; - private static TimeSpan m_StatGainDelay = TimeSpan.FromMinutes(Core.ML ? 0.05 : 15); - private static TimeSpan m_PetStatGainDelay = TimeSpan.FromMinutes(5.0); + private static readonly TimeSpan m_StatGainDelay = TimeSpan.FromMinutes(Core.ML ? 0.05 : 15); + private static readonly TimeSpan m_PetStatGainDelay = TimeSpan.FromMinutes(5.0); public static void Initialize() { @@ -152,7 +152,7 @@ namespace Server.Misc if (from is BaseCreature creature && creature.Controlled) gc *= 2; - if (from.Alive && (gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj) || skill.Base < 10.0)) + if (from.Alive && ((gc >= Utility.RandomDouble() && AllowGain(from, skill, amObj)) || skill.Base < 10.0)) Gain(from, skill); return success; @@ -195,7 +195,7 @@ namespace Server.Misc private static bool AllowGain(Mobile from, Skill skill, object obj) { - if (Core.AOS && Faction.InSkillLoss(from)) //Changed some time between the introduction of AoS and SE. + if (Core.AOS && Faction.InSkillLoss(from)) // Changed some time between the introduction of AoS and SE. return false; if (AntiMacroCode && from is PlayerMobile mobile && UseAntiMacro[skill.Info.SkillID]) @@ -224,7 +224,7 @@ namespace Server.Misc Skills skills = from.Skills; - if (from.Player && skills.Total / skills.Cap >= Utility.RandomDouble()) //( skills.Total >= skills.Cap ) + if (from.Player && skills.Total / skills.Cap >= Utility.RandomDouble()) for (int i = 0; i < skills.Length; ++i) { Skill toLower = skills[i]; @@ -236,14 +236,10 @@ namespace Server.Misc } } - #region Scroll of Alacrity - if (from is PlayerMobile pm && skill.SkillName == pm.AcceleratedSkill && pm.AcceleratedStart > DateTime.UtcNow) toGain *= Utility.RandomMinMax(2, 5); - #endregion - if (!from.Player || skills.Total + toGain <= skills.Cap) skill.BaseFixedPoint += toGain; } @@ -264,9 +260,9 @@ namespace Server.Misc { return stat switch { - Stat.Str => (from.StrLock == StatLockType.Down && from.RawStr > 10), - Stat.Dex => (from.DexLock == StatLockType.Down && from.RawDex > 10), - Stat.Int => (from.IntLock == StatLockType.Down && from.RawInt > 10), + Stat.Str => from.StrLock == StatLockType.Down && from.RawStr > 10, + Stat.Dex => from.DexLock == StatLockType.Down && from.RawDex > 10, + Stat.Int => from.IntLock == StatLockType.Down && from.RawInt > 10, _ => false }; } @@ -279,9 +275,9 @@ namespace Server.Misc return stat switch { - Stat.Str => (from.StrLock == StatLockType.Up && from.RawStr < 125), - Stat.Dex => (from.DexLock == StatLockType.Up && from.RawDex < 125), - Stat.Int => (from.IntLock == StatLockType.Up && from.RawInt < 125), + Stat.Str => from.StrLock == StatLockType.Up && from.RawStr < 125, + Stat.Dex => from.DexLock == StatLockType.Up && from.RawDex < 125, + Stat.Int => from.IntLock == StatLockType.Up && from.RawInt < 125, _ => false }; } @@ -293,50 +289,50 @@ namespace Server.Misc switch (stat) { case Stat.Str: - { - if (atrophy) { - if (CanLower(from, Stat.Dex) && (from.RawDex < from.RawInt || !CanLower(from, Stat.Int))) - --from.RawDex; - else if (CanLower(from, Stat.Int)) - --from.RawInt; + if (atrophy) + { + if (CanLower(from, Stat.Dex) && (from.RawDex < from.RawInt || !CanLower(from, Stat.Int))) + --from.RawDex; + else if (CanLower(from, Stat.Int)) + --from.RawInt; + } + + if (CanRaise(from, Stat.Str)) + ++from.RawStr; + + break; } - - if (CanRaise(from, Stat.Str)) - ++from.RawStr; - - break; - } case Stat.Dex: - { - if (atrophy) { - if (CanLower(from, Stat.Str) && (from.RawStr < from.RawInt || !CanLower(from, Stat.Int))) - --from.RawStr; - else if (CanLower(from, Stat.Int)) - --from.RawInt; + if (atrophy) + { + if (CanLower(from, Stat.Str) && (from.RawStr < from.RawInt || !CanLower(from, Stat.Int))) + --from.RawStr; + else if (CanLower(from, Stat.Int)) + --from.RawInt; + } + + if (CanRaise(from, Stat.Dex)) + ++from.RawDex; + + break; } - - if (CanRaise(from, Stat.Dex)) - ++from.RawDex; - - break; - } case Stat.Int: - { - if (atrophy) { - if (CanLower(from, Stat.Str) && (from.RawStr < from.RawDex || !CanLower(from, Stat.Dex))) - --from.RawStr; - else if (CanLower(from, Stat.Dex)) - --from.RawDex; + if (atrophy) + { + if (CanLower(from, Stat.Str) && (from.RawStr < from.RawDex || !CanLower(from, Stat.Dex))) + --from.RawStr; + else if (CanLower(from, Stat.Dex)) + --from.RawDex; + } + + if (CanRaise(from, Stat.Int)) + ++from.RawInt; + + break; } - - if (CanRaise(from, Stat.Int)) - ++from.RawInt; - - break; - } } } @@ -345,51 +341,50 @@ namespace Server.Misc switch (stat) { case Stat.Str: - { - if (from is BaseCreature creature && creature.Controlled) { - if (creature.LastStrGain + m_PetStatGainDelay >= DateTime.UtcNow) + if (from is BaseCreature creature && creature.Controlled) + { + if (creature.LastStrGain + m_PetStatGainDelay >= DateTime.UtcNow) + return; + } + else if (from.LastStrGain + m_StatGainDelay >= DateTime.UtcNow) + { return; - } - else if (from.LastStrGain + m_StatGainDelay >= DateTime.UtcNow) - { - return; - } + } - from.LastStrGain = DateTime.UtcNow; - break; - } + from.LastStrGain = DateTime.UtcNow; + break; + } case Stat.Dex: - { - if (from is BaseCreature creature && creature.Controlled) { - if (creature.LastDexGain + m_PetStatGainDelay >= DateTime.UtcNow) + if (from is BaseCreature creature && creature.Controlled) + { + if (creature.LastDexGain + m_PetStatGainDelay >= DateTime.UtcNow) + return; + } + else if (from.LastDexGain + m_StatGainDelay >= DateTime.UtcNow) + { return; - } - else if (from.LastDexGain + m_StatGainDelay >= DateTime.UtcNow) - { - return; - } + } - from.LastDexGain = DateTime.UtcNow; - break; - } + from.LastDexGain = DateTime.UtcNow; + break; + } case Stat.Int: - { - if (from is BaseCreature creature && creature.Controlled) { - if (creature.LastIntGain + m_PetStatGainDelay >= DateTime.UtcNow) + if (from is BaseCreature creature && creature.Controlled) + { + if (creature.LastIntGain + m_PetStatGainDelay >= DateTime.UtcNow) + return; + } + else if (from.LastIntGain + m_StatGainDelay >= DateTime.UtcNow) + { return; - } + } - else if (from.LastIntGain + m_StatGainDelay >= DateTime.UtcNow) - { - return; + from.LastIntGain = DateTime.UtcNow; + break; } - - from.LastIntGain = DateTime.UtcNow; - break; - } } bool atrophy = from.RawStatTotal / (double)from.StatCap >= Utility.RandomDouble(); diff --git a/Projects/Scripts/Misc/SocketOptions.cs b/Projects/Scripts/Misc/SocketOptions.cs index 3aa4b1d41..32f0fca9e 100644 --- a/Projects/Scripts/Misc/SocketOptions.cs +++ b/Projects/Scripts/Misc/SocketOptions.cs @@ -5,7 +5,7 @@ namespace Server { public class SocketOptions { - private static IPEndPoint[] m_ListenerEndPoints = + private static readonly IPEndPoint[] m_ListenerEndPoints = { new IPEndPoint(IPAddress.Any, 2593) // Default: Listen on port 2593 on all IP addresses diff --git a/Projects/Scripts/Misc/TextDefinition.cs b/Projects/Scripts/Misc/TextDefinition.cs index 9cdc79ed4..14df190de 100644 --- a/Projects/Scripts/Misc/TextDefinition.cs +++ b/Projects/Scripts/Misc/TextDefinition.cs @@ -17,9 +17,9 @@ namespace Server String = text; } - public int Number{ get; } + public int Number { get; } - public string String{ get; } + public string String { get; } public bool IsEmpty => Number <= 0 && String == null; diff --git a/Projects/Scripts/Misc/Titles.cs b/Projects/Scripts/Misc/Titles.cs index 2ff78569f..53456166b 100644 --- a/Projects/Scripts/Misc/Titles.cs +++ b/Projects/Scripts/Misc/Titles.cs @@ -19,7 +19,7 @@ namespace Server.Misc "Nullifier" }; - private static string[,] m_Levels = + private static readonly string[,] m_Levels = { { "Neophyte", "Neophyte", "Neophyte" }, { "Novice", "Novice", "Novice" }, @@ -33,7 +33,7 @@ namespace Server.Misc { "Legendary", "Kengo", "Ka-ge" } }; - private static FameEntry[] m_FameEntries = + private static readonly FameEntry[] m_FameEntries = { new FameEntry(1249, new[] { @@ -232,7 +232,7 @@ namespace Server.Misc bool showSkillTitle = beheld.ShowFameTitle && (beholder == beheld || fame >= 5000); - /*if ( beheld.Kills >= 5 ) + /*if (beheld.Kills >= 5) { title.AppendFormat( beheld.Fame >= 10000 ? "The Murderer {1} {0}" : "The Murderer {0}", beheld.Name, beheld.Female ? "Lady" : "Lord" ); } diff --git a/Projects/Scripts/Misc/ToggleItem.cs b/Projects/Scripts/Misc/ToggleItem.cs index 59e0a1030..a02acc6d4 100644 --- a/Projects/Scripts/Misc/ToggleItem.cs +++ b/Projects/Scripts/Misc/ToggleItem.cs @@ -21,13 +21,13 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public int InactiveItemID{ get; set; } + public int InactiveItemID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ActiveItemID{ get; set; } + public int ActiveItemID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool PlayersCanToggle{ get; set; } + public bool PlayersCanToggle { get; set; } public static void Initialize() { diff --git a/Projects/Scripts/Misc/VendorGenerator.cs b/Projects/Scripts/Misc/VendorGenerator.cs index b04fe173f..08ee84040 100644 --- a/Projects/Scripts/Misc/VendorGenerator.cs +++ b/Projects/Scripts/Misc/VendorGenerator.cs @@ -7,7 +7,7 @@ namespace Server { public class VendorGenerator { - private static Rectangle2D[] m_BritRegions = + private static readonly Rectangle2D[] m_BritRegions = { new Rectangle2D(new Point2D(250, 750), new Point2D(775, 1330)), new Rectangle2D(new Point2D(525, 2095), new Point2D(925, 2430)), @@ -27,7 +27,7 @@ namespace Server new Rectangle2D(new Point2D(5120, 2300), new Point2D(6143, 4095)) }; - private static Rectangle2D[] m_IlshRegions = + private static readonly Rectangle2D[] m_IlshRegions = { new Rectangle2D(new Point2D(0, 0), new Point2D(288 * 8, 200 * 8)) }; @@ -106,13 +106,13 @@ namespace Server } private static bool IsStaticFloor(int itemID) => - itemID >= 0x495 && itemID <= 0x514 - || itemID >= 0x519 && itemID <= 0x53A; + (itemID >= 0x495 && itemID <= 0x514) + || (itemID >= 0x519 && itemID <= 0x53A); private static bool IsDisplayCase(int itemID) => - itemID >= 0xB00 && itemID <= 0xB02 - || itemID >= 0xB06 && itemID <= 0xB0A - || itemID >= 0xB0D && itemID <= 0xB17; + (itemID >= 0xB00 && itemID <= 0xB02) + || (itemID >= 0xB06 && itemID <= 0xB0A) + || (itemID >= 0xB0D && itemID <= 0xB17); private static void Process(Map map, Rectangle2D[] regions) { @@ -122,9 +122,9 @@ namespace Server World.Broadcast(0x35, true, "Generating vendor spawns for {0}, please wait.", map); for (int i = 0; i < regions.Length; ++i) - for (int x = 0; x < map.Width; ++x) - for (int y = 0; y < map.Height; ++y) - CheckPoint(map, regions[i].X + x, regions[i].Y + y); + for (int x = 0; x < map.Width; ++x) + for (int y = 0; y < map.Height; ++y) + CheckPoint(map, regions[i].X + x, regions[i].Y + y); for (int i = 0; i < m_ShopList.Count; ++i) { @@ -254,22 +254,22 @@ namespace Server } private static bool IsClothes(int itemID) => - itemID >= 0x1515 && itemID <= 0x1518 || itemID >= 0x152E && itemID <= 0x1531 || itemID >= 0x1537 - && itemID <= 0x154C || itemID >= 0x1EFD && itemID <= 0x1F04 || itemID >= 0x170B && itemID <= 0x171C; + (itemID >= 0x1515 && itemID <= 0x1518) || (itemID >= 0x152E && itemID <= 0x1531) || (itemID >= 0x1537 + && itemID <= 0x154C) || (itemID >= 0x1EFD && itemID <= 0x1F04) || (itemID >= 0x170B && itemID <= 0x171C); private static bool IsArmor(int itemID) => - itemID >= 0x13BB && itemID <= 0x13E2 || itemID >= 0x13E5 && itemID <= 0x13F2 || - itemID >= 0x1408 && itemID <= 0x141A || itemID >= 0x144E && itemID <= 0x1457; + (itemID >= 0x13BB && itemID <= 0x13E2) || (itemID >= 0x13E5 && itemID <= 0x13F2) || + (itemID >= 0x1408 && itemID <= 0x141A) || (itemID >= 0x144E && itemID <= 0x1457); private static bool IsMetalWeapon(int itemID) => - itemID >= 0xF43 && itemID <= 0xF4E || itemID >= 0xF51 && itemID <= 0xF52 || - itemID >= 0xF5C && itemID <= 0xF63 || itemID >= 0x13AF && itemID <= 0x13B0 || - itemID >= 0x13B5 && itemID <= 0x13BA || itemID >= 0x13FA && itemID <= 0x13FB || - itemID >= 0x13FE && itemID <= 0x1407 || itemID >= 0x1438 && itemID <= 0x1443; + (itemID >= 0xF43 && itemID <= 0xF4E) || (itemID >= 0xF51 && itemID <= 0xF52) || + (itemID >= 0xF5C && itemID <= 0xF63) || (itemID >= 0x13AF && itemID <= 0x13B0) || + (itemID >= 0x13B5 && itemID <= 0x13BA) || (itemID >= 0x13FA && itemID <= 0x13FB) || + (itemID >= 0x13FE && itemID <= 0x1407) || (itemID >= 0x1438 && itemID <= 0x1443); private static bool IsArcheryWeapon(int itemID) => - itemID >= 0xF4F && itemID <= 0xF50 || itemID >= 0x13B1 && itemID <= 0x13B2 || - itemID >= 0x13FC && itemID <= 0x13FD; + (itemID >= 0xF4F && itemID <= 0xF50) || (itemID >= 0x13B1 && itemID <= 0x13B2) || + (itemID >= 0x13FC && itemID <= 0x13FD); private static ShopFlags ProcessDisplayedItem(int itemID) { @@ -304,8 +304,8 @@ namespace Server if (itemID >= 0xF78 && itemID <= 0xF91) res |= ShopFlags.Reagent; - if (itemID >= 0xE35 && itemID <= 0xE3A || itemID >= 0xEF4 && itemID <= 0xEF9 || - itemID >= 0x1F2D && itemID <= 0x1F72) + if ((itemID >= 0xE35 && itemID <= 0xE3A) || (itemID >= 0xEF4 && itemID <= 0xEF9) || + (itemID >= 0x1F2D && itemID <= 0x1F72)) res |= ShopFlags.Scroll; if (itemID == 0xE38 || itemID == 0xEFA) @@ -410,9 +410,9 @@ namespace Server floor.Add(p); for (int xo = -1; xo <= 1; ++xo) - for (int yo = -1; yo <= 1; ++yo) - if ((xo != 0 || yo != 0) && IsFloor(map, x + xo, y + yo, false)) - RecurseFindFloor(map, x + xo, y + yo, floor); + for (int yo = -1; yo <= 1; ++yo) + if ((xo != 0 || yo != 0) && IsFloor(map, x + xo, y + yo, false)) + RecurseFindFloor(map, x + xo, y + yo, floor); } [Flags] diff --git a/Projects/Scripts/Misc/Weather.cs b/Projects/Scripts/Misc/Weather.cs index 86fa57e24..818b7df78 100644 --- a/Projects/Scripts/Misc/Weather.cs +++ b/Projects/Scripts/Misc/Weather.cs @@ -8,11 +8,11 @@ namespace Server.Misc public class Weather { private static Map[] m_Facets; - private static Dictionary> m_WeatherByFacet = new Dictionary>(); + private static readonly Dictionary> m_WeatherByFacet = new Dictionary>(); public static void Initialize() { - m_Facets = new[]{ Map.Felucca, Map.Trammel }; + m_Facets = new[] { Map.Felucca, Map.Trammel }; /* Static weather: * @@ -21,14 +21,13 @@ namespace Server.Misc */ // ice island - AddWeather( -15, 100, 5, new Rectangle2D( 3850, 160, 390, 320 ), new Rectangle2D( 3900, 480, 380, 180 ), new Rectangle2D( 4160, 660, 150, 110 ) ); + AddWeather(-15, 100, 5, new Rectangle2D(3850, 160, 390, 320), new Rectangle2D(3900, 480, 380, 180), new Rectangle2D(4160, 660, 150, 110)); // covetous entrance, around vesper and minoc - AddWeather( +15, 50, 5, new Rectangle2D( 2425, 725, 250, 250 ) ); + AddWeather(+15, 50, 5, new Rectangle2D(2425, 725, 250, 250)); // despise entrance, north of britain - AddWeather( +15, 50, 5, new Rectangle2D( 1245, 1045, 250, 250 ) ); - + AddWeather(+15, 50, 5, new Rectangle2D(1245, 1045, 250, 250)); /* Dynamic weather: * @@ -36,65 +35,66 @@ namespace Server.Misc * AddDynamicWeather( temperature, chanceOfPercipitation, chanceOfExtremeTemperature, moveSpeed, width, height, bounds ); */ - for ( int i = 0; i < 15; ++i ) - AddDynamicWeather( +15, 100, 5, 8, 400, 400, new Rectangle2D( 0, 0, 5120, 4096 ) ); + for (int i = 0; i < 15; ++i) + AddDynamicWeather(+15, 100, 5, 8, 400, 400, new Rectangle2D(0, 0, 5120, 4096)); } - public static List GetWeatherList( Map facet ) + public static List GetWeatherList(Map facet) { - if ( facet == null ) + if (facet == null) return null; - if (!m_WeatherByFacet.TryGetValue( facet, out List list )) + if (!m_WeatherByFacet.TryGetValue(facet, out List list)) m_WeatherByFacet[facet] = list = new List(); return list; } - public static void AddDynamicWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds ) + public static void AddDynamicWeather(int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, int moveSpeed, int width, int height, Rectangle2D bounds) { - for ( int i = 0; i < m_Facets.Length; ++i ) + for (int i = 0; i < m_Facets.Length; ++i) { Rectangle2D area = new Rectangle2D(); bool isValid = false; - for ( int j = 0; j < 10; ++j ) + for (int j = 0; j < 10; ++j) { - area = new Rectangle2D( bounds.X + Utility.Random( bounds.Width - width ), bounds.Y + Utility.Random( bounds.Height - height ), width, height ); + area = new Rectangle2D(bounds.X + Utility.Random(bounds.Width - width), bounds.Y + Utility.Random(bounds.Height - height), width, height); - if ( !CheckWeatherConflict( m_Facets[i], null, area ) ) + if (!CheckWeatherConflict(m_Facets[i], null, area)) isValid = true; - if ( isValid ) + if (isValid) break; } - if ( !isValid ) + if (!isValid) continue; new Weather(m_Facets[i], new[] { area }, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, - TimeSpan.FromSeconds(30.0)) { Bounds = bounds, MoveSpeed = moveSpeed }; + TimeSpan.FromSeconds(30.0)) + { Bounds = bounds, MoveSpeed = moveSpeed }; } } - public static void AddWeather( int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, params Rectangle2D[] area ) + public static void AddWeather(int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, params Rectangle2D[] area) { - for ( int i = 0; i < m_Facets.Length; ++i ) - new Weather( m_Facets[i], area, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds( 30.0 ) ); + for (int i = 0; i < m_Facets.Length; ++i) + new Weather(m_Facets[i], area, temperature, chanceOfPercipitation, chanceOfExtremeTemperature, TimeSpan.FromSeconds(30.0)); } - public static bool CheckWeatherConflict( Map facet, Weather exclude, Rectangle2D area ) + public static bool CheckWeatherConflict(Map facet, Weather exclude, Rectangle2D area) { - List list = GetWeatherList( facet ); + List list = GetWeatherList(facet); - if ( list == null ) + if (list == null) return false; - for ( int i = 0; i < list.Count; ++i ) + for (int i = 0; i < list.Count; ++i) { Weather w = list[i]; - if ( w != exclude && w.IntersectsWith( area ) ) + if (w != exclude && w.IntersectsWith(area)) return true; } @@ -121,22 +121,22 @@ namespace Server.Misc public int MoveAngleY { get; set; } - public static bool CheckIntersection( Rectangle2D r1, Rectangle2D r2 ) => r1.X < r2.X + r2.Width && r2.X < r1.X + r1.Width && r1.Y < r2.Y + r2.Height && r2.Y < r1.Y + r1.Height; + public static bool CheckIntersection(Rectangle2D r1, Rectangle2D r2) => r1.X < r2.X + r2.Width && r2.X < r1.X + r1.Width && r1.Y < r2.Y + r2.Height && r2.Y < r1.Y + r1.Height; - public static bool CheckContains( Rectangle2D big, Rectangle2D small ) => + public static bool CheckContains(Rectangle2D big, Rectangle2D small) => small.X >= big.X && small.Y >= big.Y && small.X + small.Width <= big.X + big.Width && small.Y + small.Height <= big.Y + big.Height; - public virtual bool IntersectsWith( Rectangle2D area ) + public virtual bool IntersectsWith(Rectangle2D area) { - for ( int i = 0; i < Area.Length; ++i ) - if ( CheckIntersection( area, Area[i] ) ) + for (int i = 0; i < Area.Length; ++i) + if (CheckIntersection(area, Area[i])) return true; return false; } - public Weather( Map facet, Rectangle2D[] area, int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, TimeSpan interval ) + public Weather(Map facet, Rectangle2D[] area, int temperature, int chanceOfPercipitation, int chanceOfExtremeTemperature, TimeSpan interval) { Facet = facet; Area = area; @@ -144,16 +144,16 @@ namespace Server.Misc ChanceOfPercipitation = chanceOfPercipitation; ChanceOfExtremeTemperature = chanceOfExtremeTemperature; - List list = GetWeatherList( facet ); + List list = GetWeatherList(facet); - list?.Add( this ); + list?.Add(this); - Timer.DelayCall( TimeSpan.FromSeconds( (0.2+Utility.RandomDouble()*0.8) * interval.TotalSeconds ), interval, OnTick ); + Timer.DelayCall(TimeSpan.FromSeconds((0.2 + Utility.RandomDouble() * 0.8) * interval.TotalSeconds), interval, OnTick); } public virtual void Reposition() { - if ( Area.Length == 0 ) + if (Area.Length == 0) return; int width = Area[0].Width; @@ -162,18 +162,18 @@ namespace Server.Misc Rectangle2D area = new Rectangle2D(); bool isValid = false; - for ( int j = 0; j < 10; ++j ) + for (int j = 0; j < 10; ++j) { - area = new Rectangle2D( Bounds.X + Utility.Random( Bounds.Width - width ), Bounds.Y + Utility.Random( Bounds.Height - height ), width, height ); + area = new Rectangle2D(Bounds.X + Utility.Random(Bounds.Width - width), Bounds.Y + Utility.Random(Bounds.Height - height), width, height); - if ( !CheckWeatherConflict( Facet, this, area ) ) + if (!CheckWeatherConflict(Facet, this, area)) isValid = true; - if ( isValid ) + if (isValid) break; } - if ( !isValid ) + if (!isValid) return; Area[0] = area; @@ -183,8 +183,8 @@ namespace Server.Misc { double angle = Utility.RandomDouble() * Math.PI * 2.0; - double cos = Math.Cos( angle ); - double sin = Math.Sin( angle ); + double cos = Math.Cos(angle); + double sin = Math.Sin(angle); MoveAngleX = (int)(100 * cos); MoveAngleY = (int)(100 * sin); @@ -192,18 +192,18 @@ namespace Server.Misc public virtual void MoveForward() { - if ( Area.Length == 0 ) + if (Area.Length == 0) return; - for ( int i = 0; i < 5; ++i ) // try 5 times to find a valid spot + for (int i = 0; i < 5; ++i) // try 5 times to find a valid spot { int xOffset = MoveSpeed * MoveAngleX / 100; int yOffset = MoveSpeed * MoveAngleY / 100; Rectangle2D oldArea = Area[0]; - Rectangle2D newArea = new Rectangle2D( oldArea.X + xOffset, oldArea.Y + yOffset, oldArea.Width, oldArea.Height ); + Rectangle2D newArea = new Rectangle2D(oldArea.X + xOffset, oldArea.Y + yOffset, oldArea.Width, oldArea.Height); - if ( !CheckWeatherConflict( Facet, this, newArea ) && CheckContains( Bounds, newArea ) ) + if (!CheckWeatherConflict(Facet, this, newArea) && CheckContains(Bounds, newArea)) { Area[0] = newArea; break; @@ -219,30 +219,30 @@ namespace Server.Misc public virtual void OnTick() { - if ( m_Stage == 0 ) + if (m_Stage == 0) { - m_Active = ChanceOfPercipitation > Utility.Random( 100 ); - m_ExtremeTemperature = ChanceOfExtremeTemperature > Utility.Random( 100 ); + m_Active = ChanceOfPercipitation > Utility.Random(100); + m_ExtremeTemperature = ChanceOfExtremeTemperature > Utility.Random(100); - if ( MoveSpeed > 0 ) + if (MoveSpeed > 0) { Reposition(); RecalculateMovementAngle(); } } - if ( m_Active ) + if (m_Active) { - if ( m_Stage > 0 && MoveSpeed > 0 ) + if (m_Stage > 0 && MoveSpeed > 0) MoveForward(); int type, density; int temperature = Temperature; - if ( m_ExtremeTemperature ) + if (m_ExtremeTemperature) temperature *= -1; - if ( m_Stage < 15 ) + if (m_Stage < 15) { density = m_Stage * 5; } @@ -250,15 +250,15 @@ namespace Server.Misc { density = 150 - m_Stage * 5; - if ( density < 10 ) + if (density < 10) density = 10; - else if ( density > 70 ) + else if (density > 70) density = 70; } - if ( density == 0 ) + if (density == 0) type = 0xFE; - else if ( temperature > 0 ) + else if (temperature > 0) type = 0; else type = 2; @@ -267,29 +267,29 @@ namespace Server.Misc Packet weatherPacket = null; - for ( int i = 0; i < states.Count; ++i ) + for (int i = 0; i < states.Count; ++i) { NetState ns = states[i]; Mobile mob = ns.Mobile; - if ( mob == null || mob.Map != Facet ) + if (mob == null || mob.Map != Facet) continue; bool contains = Area.Length == 0; - for ( int j = 0; !contains && j < Area.Length; ++j ) - contains = Area[j].Contains( mob.Location ); + for (int j = 0; !contains && j < Area.Length; ++j) + contains = Area[j].Contains(mob.Location); - if ( !contains ) + if (!contains) continue; - if ( weatherPacket == null ) - weatherPacket = Packet.Acquire( new Server.Network.Weather( type, density, temperature ) ); + if (weatherPacket == null) + weatherPacket = Packet.Acquire(new Server.Network.Weather(type, density, temperature)); - ns.Send( weatherPacket ); + ns.Send(weatherPacket); } - Packet.Release( weatherPacket ); + Packet.Release(weatherPacket); } m_Stage++; @@ -304,45 +304,45 @@ namespace Server.Misc [Constructible] public WeatherMap() { - SetDisplay( 0, 0, 5119, 4095, 400, 400 ); + SetDisplay(0, 0, 5119, 4095, 400, 400); } - public override void OnDoubleClick( Mobile from ) + public override void OnDoubleClick(Mobile from) { Map facet = from.Map; - if ( facet == null ) + if (facet == null) return; - List list = Weather.GetWeatherList( facet ); + List list = Weather.GetWeatherList(facet); ClearPins(); - for ( int i = 0; i < list.Count; ++i ) + for (int i = 0; i < list.Count; ++i) { Weather w = list[i]; - for ( int j = 0; j < w.Area.Length; ++j ) - AddWorldPin( w.Area[j].X + w.Area[j].Width/2, w.Area[j].Y + w.Area[j].Height/2 ); + for (int j = 0; j < w.Area.Length; ++j) + AddWorldPin(w.Area[j].X + w.Area[j].Width / 2, w.Area[j].Y + w.Area[j].Height / 2); } - base.OnDoubleClick( from ); + base.OnDoubleClick(from); } - public WeatherMap( Serial serial ) : base( serial ) + public WeatherMap(Serial serial) : base(serial) { } - public override void Serialize(IGenericWriter writer ) + public override void Serialize(IGenericWriter writer) { - base.Serialize( writer ); + base.Serialize(writer); - writer.Write( 0 ); + writer.Write(0); } - public override void Deserialize( IGenericReader reader ) + public override void Deserialize(IGenericReader reader) { - base.Deserialize( reader ); + base.Deserialize(reader); int version = reader.ReadInt(); } diff --git a/Projects/Scripts/Misc/WebStatus.cs b/Projects/Scripts/Misc/WebStatus.cs index 961ec3c4d..ad4ab9165 100644 --- a/Projects/Scripts/Misc/WebStatus.cs +++ b/Projects/Scripts/Misc/WebStatus.cs @@ -1,5 +1,3 @@ -#region References - using System; using System.IO; using System.Linq; @@ -8,8 +6,6 @@ using System.Text; using Server.Guilds; using Server.Network; -#endregion - namespace Server.Misc { public class StatusPage : Timer @@ -19,7 +15,7 @@ namespace Server.Misc private static HttpListener _Listener; private static string _StatusPage = string.Empty; - private static byte[] _StatusBuffer = new byte[0]; + private static byte[] _StatusBuffer = Array.Empty(); private static readonly object _StatusLock = new object(); diff --git a/Projects/Scripts/Misc/WeightOverloading.cs b/Projects/Scripts/Misc/WeightOverloading.cs index ed2f5924e..aabf45284 100644 --- a/Projects/Scripts/Misc/WeightOverloading.cs +++ b/Projects/Scripts/Misc/WeightOverloading.cs @@ -14,7 +14,7 @@ namespace Server.Misc { public const int OverloadAllowance = 4; // We can be four stones overweight without getting fatigued - public static DFAlgorithm DFA{ get; set; } + public static DFAlgorithm DFA { get; set; } public static void Initialize() { @@ -28,15 +28,15 @@ namespace Server.Misc switch (DFA) { case DFAlgorithm.Standard: - { - fatigue = damage * (100.0 / m.Hits) * ((double)m.Stam / 100) - 5.0; - break; - } + { + fatigue = damage * (100.0 / m.Hits) * ((double)m.Stam / 100) - 5.0; + break; + } case DFAlgorithm.PainSpike: - { - fatigue = damage * (100.0 / m.Hits + (50.0 + m.Stam) / 100 - 1.0) - 5.0; - break; - } + { + fatigue = damage * (100.0 / m.Hits + (50.0 + m.Stam) / 100 - 1.0) - 5.0; + break; + } } if (fatigue > 0) diff --git a/Projects/Scripts/Misc/WelcomeTimer.cs b/Projects/Scripts/Misc/WelcomeTimer.cs index 24b1fc2bb..66b02554e 100644 --- a/Projects/Scripts/Misc/WelcomeTimer.cs +++ b/Projects/Scripts/Misc/WelcomeTimer.cs @@ -7,7 +7,7 @@ namespace Server.Misc /// public class WelcomeTimer : Timer { - private static string[] m_Messages = TestCenter.Enabled + private static readonly string[] m_Messages = TestCenter.Enabled ? new[] { "Welcome to this test shard. You are able to customize your character's stats and skills at anytime to anything you wish. To see the commands to do this just say 'help'.", @@ -23,13 +23,14 @@ namespace Server.Misc } : new[] { - //Yes, this message is a pathetic message, It's suggested that you change it. + // Yes, this message is a pathetic message, It's suggested that you change it. "Welcome to this shard.", "Please enjoy your stay." }; - private Mobile m_Mobile; - private int m_State, m_Count; + private readonly Mobile m_Mobile; + private int m_State; + private readonly int m_Count; public WelcomeTimer(Mobile m) : this(m, m_Messages.Length) { diff --git a/Projects/Scripts/Misc/uoamVendors.cs b/Projects/Scripts/Misc/uoamVendors.cs index 7ab3f34a9..ce8957b80 100644 --- a/Projects/Scripts/Misc/uoamVendors.cs +++ b/Projects/Scripts/Misc/uoamVendors.cs @@ -9,7 +9,7 @@ namespace Server { public class UOAMVendorGenerator { - //configuration + // configuration private const int NPCCount = 2; // 2 npcs per type (so a mage spawner will spawn 2 npcs, a alchemist and herbalist spawner will spawn 4 npcs total) @@ -17,8 +17,8 @@ namespace Server private const bool TotalRespawn = true; // Should we spawn them up right away? private const int Team = 0; // "team" the npcs are on private static int m_Count; - private static TimeSpan MinTime = TimeSpan.FromMinutes(2.5); //min spawn time - private static TimeSpan MaxTime = TimeSpan.FromMinutes(10.0); //max spawn time + private static readonly TimeSpan MinTime = TimeSpan.FromMinutes(2.5); // min spawn time + private static readonly TimeSpan MaxTime = TimeSpan.FromMinutes(10.0); // max spawn time public static void Initialize() { @@ -164,7 +164,6 @@ namespace Server PlaceNPC(split[1], split[2], split[3], "Beekeeper"); break; - // Guilds & Misc case "-tinkers guild:": PlaceNPC(split[1], split[2], split[3], "TinkerGuildmaster"); @@ -231,9 +230,9 @@ namespace Server case "+Island:": case "+town:": break; - /*default: - Console.WriteLine(split[0]); - break;*/ + /*default: + Console.WriteLine(split[0]); + break;*/ } } } @@ -252,11 +251,11 @@ namespace Server switch (map) { - case 0: //Trammel and Felucca + case 0: // Trammel and Felucca MakeSpawner(types, x, y, Map.Felucca); MakeSpawner(types, x, y, Map.Trammel); break; - case 1: //Felucca + case 1: // Felucca MakeSpawner(types, x, y, Map.Felucca); break; case 2: diff --git a/Projects/Scripts/Mobiles/AI/AIControlMobileTarget.cs b/Projects/Scripts/Mobiles/AI/AIControlMobileTarget.cs index 2cbf93a39..fb74648cd 100644 --- a/Projects/Scripts/Mobiles/AI/AIControlMobileTarget.cs +++ b/Projects/Scripts/Mobiles/AI/AIControlMobileTarget.cs @@ -6,7 +6,7 @@ namespace Server.Targets { public class AIControlMobileTarget : Target { - private List m_List; + private readonly List m_List; public AIControlMobileTarget(BaseAI ai, OrderType order) : base(-1, false, order == OrderType.Attack ? TargetFlags.Harmful : TargetFlags.None) @@ -17,7 +17,7 @@ namespace Server.Targets AddAI(ai); } - public OrderType Order{ get; } + public OrderType Order { get; } public void AddAI(BaseAI ai) { diff --git a/Projects/Scripts/Mobiles/AI/AnimalAI.cs b/Projects/Scripts/Mobiles/AI/AnimalAI.cs index 8912d8e73..f1e13d79e 100644 --- a/Projects/Scripts/Mobiles/AI/AnimalAI.cs +++ b/Projects/Scripts/Mobiles/AI/AnimalAI.cs @@ -1,6 +1,6 @@ // Ideas // When you run on animals the panic -// When if ( distance < 8 && Utility.RandomDouble() * Math.Sqrt( (8 - distance) / 6 ) >= incoming.Skills.AnimalTaming.Value ) +// When if (distance < 8 && Utility.RandomDouble() * Math.Sqrt( (8 - distance) / 6 ) >= incoming.Skills.AnimalTaming.Value) // More your close, the more it can panic /* * AnimalHunterAI, AnimalHidingAI, AnimalDomesticAI... diff --git a/Projects/Scripts/Mobiles/AI/ArcherAI.cs b/Projects/Scripts/Mobiles/AI/ArcherAI.cs index 49522294f..b82a0c043 100644 --- a/Projects/Scripts/Mobiles/AI/ArcherAI.cs +++ b/Projects/Scripts/Mobiles/AI/ArcherAI.cs @@ -74,7 +74,6 @@ namespace Server.Mobiles return true; } - // At 20% we should check if we must leave if (m_Mobile.Hits < m_Mobile.HitsMax * 20 / 100 && m_Mobile.CanFlee) { diff --git a/Projects/Scripts/Mobiles/AI/BaseAI.cs b/Projects/Scripts/Mobiles/AI/BaseAI.cs index 6f5476b28..2003468f7 100644 --- a/Projects/Scripts/Mobiles/AI/BaseAI.cs +++ b/Projects/Scripts/Mobiles/AI/BaseAI.cs @@ -42,7 +42,7 @@ namespace Server.Mobiles public abstract class BaseAI { - private static SkillName[] m_KeywordTable = + private static readonly SkillName[] m_KeywordTable = { SkillName.Parry, SkillName.Healing, @@ -61,7 +61,7 @@ namespace Server.Mobiles SkillName.Cartography, SkillName.Cooking, SkillName.DetectHidden, - SkillName.Discordance, //?? + SkillName.Discordance, // ?? SkillName.EvalInt, SkillName.Fishing, SkillName.Provocation, @@ -94,7 +94,7 @@ namespace Server.Mobiles SkillName.Meditation }; - private static Queue m_Obstacles = new Queue(); + private static readonly Queue m_Obstacles = new Queue(); protected ActionType m_Action; public BaseCreature m_Mobile; @@ -138,7 +138,7 @@ namespace Server.Mobiles } } - public long NextMove{ get; set; } + public long NextMove { get; set; } public virtual bool CanDetectHidden => m_Mobile.Skills.DetectHidden.Value > 0; @@ -433,76 +433,76 @@ namespace Server.Mobiles switch (keyword) { case 0x164: // all come - { - if (!isOwner) - break; - - if (m_Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Come; - } + if (!isOwner) + break; - return; - } + if (m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Come; + } + + return; + } case 0x165: // all follow - { - BeginPickTarget(e.Mobile, OrderType.Follow); - return; - } + { + BeginPickTarget(e.Mobile, OrderType.Follow); + return; + } case 0x166: // all guard case 0x16B: // all guard me - { - if (!isOwner) - break; - - if (m_Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Guard; - } + if (!isOwner) + break; - return; - } + if (m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Guard; + } + + return; + } case 0x167: // all stop - { - if (m_Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stop; - } + if (m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Stop; + } - return; - } + return; + } case 0x168: // all kill case 0x169: // all attack - { - if (!isOwner) - break; + { + if (!isOwner) + break; - BeginPickTarget(e.Mobile, OrderType.Attack); - return; - } + BeginPickTarget(e.Mobile, OrderType.Attack); + return; + } case 0x16C: // all follow me - { - if (m_Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = e.Mobile; - m_Mobile.ControlOrder = OrderType.Follow; - } + if (m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = e.Mobile; + m_Mobile.ControlOrder = OrderType.Follow; + } - return; - } + return; + } case 0x170: // all stay - { - if (m_Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stay; - } + if (m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Stay; + } - return; - } + return; + } } } @@ -514,164 +514,164 @@ namespace Server.Mobiles switch (keyword) { case 0x155: // *come - { - if (!isOwner) - break; - - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Come; - } + if (!isOwner) + break; - return; - } - case 0x156: // *drop - { - if (!isOwner) - break; - - if (!m_Mobile.IsDeadPet && !m_Mobile.Summoned && WasNamed(speech) && - m_Mobile.CheckControlChance(e.Mobile)) - { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Drop; - } - - return; - } - case 0x15A: // *follow - { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - BeginPickTarget(e.Mobile, OrderType.Follow); - - return; - } - case 0x15B: // *friend - { - if (!isOwner) - break; - - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - { - if (m_Mobile.Summoned || m_Mobile is GrizzledMare) - e.Mobile.SendLocalizedMessage( - 1005481); // Summoned creatures are loyal only to their summoners. - else if (e.Mobile.HasTrade) - e.Mobile.SendLocalizedMessage( - 1070947); // You cannot friend a pet with a trade pending - else - BeginPickTarget(e.Mobile, OrderType.Friend); - } - - return; - } - case 0x15C: // *guard - { - if (!isOwner) - break; - - if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Guard; - } - - return; - } - case 0x15D: // *kill - case 0x15E: // *attack - { - if (!isOwner) - break; - - if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - BeginPickTarget(e.Mobile, OrderType.Attack); - - return; - } - case 0x15F: // *patrol - { - if (!isOwner) - break; - - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Patrol; - } - - return; - } - case 0x161: // *stop - { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stop; - } - - return; - } - case 0x163: // *follow me - { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - { - m_Mobile.ControlTarget = e.Mobile; - m_Mobile.ControlOrder = OrderType.Follow; - } - - return; - } - case 0x16D: // *release - { - if (!isOwner) - break; - - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) - { - if (!m_Mobile.Summoned) - { - e.Mobile.SendGump(new ConfirmReleaseGump(e.Mobile, m_Mobile)); - } - else + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Release; + m_Mobile.ControlOrder = OrderType.Come; } - } - return; - } + return; + } + case 0x156: // *drop + { + if (!isOwner) + break; + + if (!m_Mobile.IsDeadPet && !m_Mobile.Summoned && WasNamed(speech) && + m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Drop; + } + + return; + } + case 0x15A: // *follow + { + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + BeginPickTarget(e.Mobile, OrderType.Follow); + + return; + } + case 0x15B: // *friend + { + if (!isOwner) + break; + + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + if (m_Mobile.Summoned || m_Mobile is GrizzledMare) + e.Mobile.SendLocalizedMessage( + 1005481); // Summoned creatures are loyal only to their summoners. + else if (e.Mobile.HasTrade) + e.Mobile.SendLocalizedMessage( + 1070947); // You cannot friend a pet with a trade pending + else + BeginPickTarget(e.Mobile, OrderType.Friend); + } + + return; + } + case 0x15C: // *guard + { + if (!isOwner) + break; + + if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Guard; + } + + return; + } + case 0x15D: // *kill + case 0x15E: // *attack + { + if (!isOwner) + break; + + if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + BeginPickTarget(e.Mobile, OrderType.Attack); + + return; + } + case 0x15F: // *patrol + { + if (!isOwner) + break; + + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Patrol; + } + + return; + } + case 0x161: // *stop + { + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Stop; + } + + return; + } + case 0x163: // *follow me + { + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = e.Mobile; + m_Mobile.ControlOrder = OrderType.Follow; + } + + return; + } + case 0x16D: // *release + { + if (!isOwner) + break; + + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + if (!m_Mobile.Summoned) + { + e.Mobile.SendGump(new ConfirmReleaseGump(e.Mobile, m_Mobile)); + } + else + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Release; + } + } + + return; + } case 0x16E: // *transfer - { - if (!isOwner) - break; - - if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { - if (m_Mobile.Summoned || m_Mobile is GrizzledMare) - e.Mobile.SendLocalizedMessage( - 1005487); // You cannot transfer ownership of a summoned creature. - else if (e.Mobile.HasTrade) - e.Mobile.SendLocalizedMessage( - 1010507); // You cannot transfer a pet with a trade pending - else - BeginPickTarget(e.Mobile, OrderType.Transfer); - } + if (!isOwner) + break; - return; - } + if (!m_Mobile.IsDeadPet && WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + if (m_Mobile.Summoned || m_Mobile is GrizzledMare) + e.Mobile.SendLocalizedMessage( + 1005487); // You cannot transfer ownership of a summoned creature. + else if (e.Mobile.HasTrade) + e.Mobile.SendLocalizedMessage( + 1010507); // You cannot transfer a pet with a trade pending + else + BeginPickTarget(e.Mobile, OrderType.Transfer); + } + + return; + } case 0x16F: // *stay - { - if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) { - m_Mobile.ControlTarget = null; - m_Mobile.ControlOrder = OrderType.Stay; - } + if (WasNamed(speech) && m_Mobile.CheckControlChance(e.Mobile)) + { + m_Mobile.ControlTarget = null; + m_Mobile.ControlOrder = OrderType.Stay; + } - return; - } + return; + } } } } @@ -864,7 +864,7 @@ namespace Server.Mobiles else if (Core.TickCount - m_NextStopGuard < 0) { m_Mobile.DebugSay("I am on guard"); - //m_Mobile.Turn( Utility.Random(0, 2) - 1 ); + // m_Mobile.Turn( Utility.Random(0, 2) - 1 ); } else { @@ -970,7 +970,7 @@ namespace Server.Mobiles m_Mobile.Warmode = true; m_Mobile.Combatant = null; string petname = $"{m_Mobile.Name}"; - m_Mobile.ControlMaster.SendLocalizedMessage(1049671, petname); //~1_PETNAME~ is now guarding you. + m_Mobile.ControlMaster.SendLocalizedMessage(1049671, petname); // ~1_PETNAME~ is now guarding you. break; case OrderType.Attack: @@ -1341,7 +1341,7 @@ namespace Server.Mobiles if (attacker?.Deleted == false && attacker.GetDistanceToSqrt(m_Mobile) <= m_Mobile.RangePerception) if (combatant == null || attacker.GetDistanceToSqrt(controlMaster) < - combatant.GetDistanceToSqrt(controlMaster)) + combatant.GetDistanceToSqrt(controlMaster)) combatant = attacker; } @@ -1483,7 +1483,7 @@ namespace Server.Mobiles else m_Mobile.DebugSay("My master told me to stay"); - //m_Mobile.Direction = m_Mobile.GetDirectionTo( m_Mobile.ControlMaster ); + // m_Mobile.Direction = m_Mobile.GetDirectionTo( m_Mobile.ControlMaster ); return true; } @@ -1759,7 +1759,7 @@ namespace Server.Mobiles MoveResult res = DoMoveImpl(d); return res == MoveResult.Success || res == MoveResult.SuccessAutoTurn || - badStateOk && res == MoveResult.BadState; + (badStateOk && res == MoveResult.BadState); } public virtual MoveResult DoMoveImpl(Direction d) @@ -2257,7 +2257,7 @@ namespace Server.Mobiles if (bFacFriend && !m_Mobile.IsFriend(m)) continue; - //Ignore anyone under EtherealVoyage + // Ignore anyone under EtherealVoyage if (TransformationSpellHelper.UnderTransformation(m, typeof(EtherealVoyageSpell))) continue; @@ -2329,7 +2329,6 @@ namespace Server.Mobiles return false; } - public virtual void DetectHidden() { if (m_Mobile.Deleted || m_Mobile.Map == null) @@ -2422,10 +2421,10 @@ namespace Server.Mobiles private class InternalEntry : ContextMenuEntry { - private BaseAI m_AI; - private Mobile m_From; - private BaseCreature m_Mobile; - private OrderType m_Order; + private readonly BaseAI m_AI; + private readonly Mobile m_From; + private readonly BaseCreature m_Mobile; + private readonly OrderType m_Order; public InternalEntry(Mobile from, int number, int range, BaseCreature mobile, BaseAI ai, OrderType order) : base(number, range) @@ -2463,31 +2462,31 @@ namespace Server.Mobiles case OrderType.Transfer: case OrderType.Friend: case OrderType.Unfriend: - { - if (m_Order == OrderType.Transfer && m_From.HasTrade) - m_From.SendLocalizedMessage(1010507); // You cannot transfer a pet with a trade pending - else if (m_Order == OrderType.Friend && m_From.HasTrade) - m_From.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending - else - m_AI.BeginPickTarget(m_From, m_Order); + { + if (m_Order == OrderType.Transfer && m_From.HasTrade) + m_From.SendLocalizedMessage(1010507); // You cannot transfer a pet with a trade pending + else if (m_Order == OrderType.Friend && m_From.HasTrade) + m_From.SendLocalizedMessage(1070947); // You cannot friend a pet with a trade pending + else + m_AI.BeginPickTarget(m_From, m_Order); - break; - } + break; + } case OrderType.Release: - { - if (m_Mobile.Summoned) - goto default; - m_From.SendGump(new ConfirmReleaseGump(m_From, m_Mobile)); + { + if (m_Mobile.Summoned) + goto default; + m_From.SendGump(new ConfirmReleaseGump(m_From, m_Mobile)); - break; - } + break; + } default: - { - if (m_Mobile.CheckControlChance(m_From)) - m_Mobile.ControlOrder = m_Order; + { + if (m_Mobile.CheckControlChance(m_From)) + m_Mobile.ControlOrder = m_Order; - break; - } + break; + } } } } @@ -2495,7 +2494,7 @@ namespace Server.Mobiles private class TransferItem : Item { - private BaseCreature m_Creature; + private readonly BaseCreature m_Creature; public TransferItem(BaseCreature creature) : base(ShrinkTable.Lookup(creature)) @@ -2510,7 +2509,7 @@ namespace Server.Mobiles creature.GetType().IsDefined(typeof(FriendlyNameAttribute), false) || creature is Reptalon) Name = FriendlyNameAttribute.GetFriendlyNameFor(creature.GetType()).ToString(); - //(As Per OSI)No name. Normally, set by the ItemID of the Shrink Item unless we either explicitly set it with an Attribute, or, no lookup found + // (As Per OSI)No name. Normally, set by the ItemID of the Shrink Item unless we either explicitly set it with an Attribute, or, no lookup found Hue = creature.Hue & 0x0FFF; } @@ -2652,7 +2651,7 @@ namespace Server.Mobiles */ private class AITimer : Timer { - private BaseAI m_Owner; + private readonly BaseAI m_Owner; public AITimer(BaseAI owner) : base(TimeSpan.FromSeconds(Utility.RandomDouble()), @@ -2679,7 +2678,7 @@ namespace Server.Mobiles return; } - if (m_Owner.m_Mobile.PlayerRangeSensitive) //have to check this in the timer.... + if (m_Owner.m_Mobile.PlayerRangeSensitive) // have to check this in the timer.... { Sector sect = m_Owner.m_Mobile.Map.GetSector(m_Owner.m_Mobile); if (!sect.Active) diff --git a/Projects/Scripts/Mobiles/AI/HealerAI.cs b/Projects/Scripts/Mobiles/AI/HealerAI.cs index f5fe4f341..3735229a8 100644 --- a/Projects/Scripts/Mobiles/AI/HealerAI.cs +++ b/Projects/Scripts/Mobiles/AI/HealerAI.cs @@ -8,13 +8,13 @@ namespace Server.Mobiles { public class HealerAI : BaseAI { - private static NeedDelegate m_Cure = NeedCure; - private static NeedDelegate m_GHeal = NeedGHeal; - private static NeedDelegate m_LHeal = NeedLHeal; - private static NeedDelegate[] m_ACure = { m_Cure }; - private static NeedDelegate[] m_AGHeal = { m_GHeal }; - private static NeedDelegate[] m_ALHeal = { m_LHeal }; - private static NeedDelegate[] m_All = { m_Cure, m_GHeal, m_LHeal }; + private static readonly NeedDelegate m_Cure = NeedCure; + private static readonly NeedDelegate m_GHeal = NeedGHeal; + private static readonly NeedDelegate m_LHeal = NeedLHeal; + private static readonly NeedDelegate[] m_ACure = { m_Cure }; + private static readonly NeedDelegate[] m_AGHeal = { m_GHeal }; + private static readonly NeedDelegate[] m_ALHeal = { m_LHeal }; + private static readonly NeedDelegate[] m_All = { m_Cure, m_GHeal, m_LHeal }; public HealerAI(BaseCreature m) : base(m) { diff --git a/Projects/Scripts/Mobiles/AI/MageAI.cs b/Projects/Scripts/Mobiles/AI/MageAI.cs index 2673d6a4c..5f6408526 100644 --- a/Projects/Scripts/Mobiles/AI/MageAI.cs +++ b/Projects/Scripts/Mobiles/AI/MageAI.cs @@ -19,7 +19,7 @@ namespace Server.Mobiles private const double TeleportChance = 0.05; // 5% chance to teleport at gm magery private const double DispelChance = 0.75; // 75% chance to dispel at gm magery - private static int[] m_Offsets = + private static readonly int[] m_Offsets = { -1, -1, -1, 0, @@ -392,64 +392,64 @@ namespace Server.Mobiles { case 0: case 1: // Poison them - { - if (c.Poisoned) - goto default; + { + if (c.Poisoned) + goto default; - m_Mobile.DebugSay("Attempting to poison"); + m_Mobile.DebugSay("Attempting to poison"); - spell = new PoisonSpell(m_Mobile); - break; - } + spell = new PoisonSpell(m_Mobile); + break; + } case 2: // Bless ourselves - { - m_Mobile.DebugSay("Blessing myself"); + { + m_Mobile.DebugSay("Blessing myself"); - spell = new BlessSpell(m_Mobile); - break; - } + spell = new BlessSpell(m_Mobile); + break; + } case 3: case 4: // Curse them - { - m_Mobile.DebugSay("Attempting to curse"); + { + m_Mobile.DebugSay("Attempting to curse"); - spell = GetRandomCurseSpell(); - break; - } + spell = GetRandomCurseSpell(); + break; + } case 5: // Paralyze them - { - if (c.Paralyzed || m_Mobile.Skills.Magery.Value <= 50.0) - goto default; + { + if (c.Paralyzed || m_Mobile.Skills.Magery.Value <= 50.0) + goto default; - m_Mobile.DebugSay("Attempting to paralyze"); + m_Mobile.DebugSay("Attempting to paralyze"); - spell = new ParalyzeSpell(m_Mobile); - break; - } + spell = new ParalyzeSpell(m_Mobile); + break; + } case 6: // Drain mana - { - m_Mobile.DebugSay("Attempting to drain mana"); + { + m_Mobile.DebugSay("Attempting to drain mana"); - spell = GetRandomManaDrainSpell(); - break; - } + spell = GetRandomManaDrainSpell(); + break; + } case 7: // Invis ourselves - { - if (Utility.RandomBool()) - goto default; + { + if (Utility.RandomBool()) + goto default; - m_Mobile.DebugSay("Attempting to invis myself"); + m_Mobile.DebugSay("Attempting to invis myself"); - spell = new InvisibilitySpell(m_Mobile); - break; - } + spell = new InvisibilitySpell(m_Mobile); + break; + } default: // Damage them - { - m_Mobile.DebugSay("Just doing damage"); + { + m_Mobile.DebugSay("Just doing damage"); - spell = GetRandomDamageSpell(); - break; - } + spell = GetRandomDamageSpell(); + break; + } } return spell; @@ -463,50 +463,50 @@ namespace Server.Mobiles switch (Utility.Random(3)) { case 0: // Poison them - { - if (c.Poisoned) - goto case 1; + { + if (c.Poisoned) + goto case 1; - spell = new PoisonSpell(m_Mobile); - break; - } + spell = new PoisonSpell(m_Mobile); + break; + } case 1: // Deal some damage - { - spell = GetRandomDamageSpell(); + { + spell = GetRandomDamageSpell(); - break; - } + break; + } default: // Set up a combo - { - if (m_Mobile.Mana > 15 && m_Mobile.Mana < 40) { - if (c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating) + if (m_Mobile.Mana > 15 && m_Mobile.Mana < 40) { - m_Mobile.DebugSay("I am going to meditate"); + if (c.Paralyzed && !c.Poisoned && !m_Mobile.Meditating) + { + m_Mobile.DebugSay("I am going to meditate"); - m_Mobile.UseSkill(SkillName.Meditation); + m_Mobile.UseSkill(SkillName.Meditation); + } + else if (!c.Poisoned) + { + spell = new ParalyzeSpell(m_Mobile); + } } - else if (!c.Poisoned) + else if (m_Mobile.Mana > 60) { - spell = new ParalyzeSpell(m_Mobile); + if (Utility.RandomBool() && !c.Paralyzed && !c.Frozen && !c.Poisoned) + { + m_Combo = 0; + spell = new ParalyzeSpell(m_Mobile); + } + else + { + m_Combo = 1; + spell = new ExplosionSpell(m_Mobile); + } } - } - else if (m_Mobile.Mana > 60) - { - if (Utility.RandomBool() && !c.Paralyzed && !c.Frozen && !c.Poisoned) - { - m_Combo = 0; - spell = new ParalyzeSpell(m_Mobile); - } - else - { - m_Combo = 1; - spell = new ExplosionSpell(m_Mobile); - } - } - break; - } + break; + } } return spell; @@ -541,34 +541,34 @@ namespace Server.Mobiles switch (Utility.Random(IsNecromancer ? 4 : 3)) { case 0: - { - if (c.Int < c.Dex) - spell = new FeeblemindSpell(m_Mobile); - else - spell = new ClumsySpell(m_Mobile); + { + if (c.Int < c.Dex) + spell = new FeeblemindSpell(m_Mobile); + else + spell = new ClumsySpell(m_Mobile); - ++m_Combo; // Move to next spell + ++m_Combo; // Move to next spell - break; - } + break; + } case 1: - { - spell = new EnergyBoltSpell(m_Mobile); - m_Combo = -1; // Reset combo state - break; - } + { + spell = new EnergyBoltSpell(m_Mobile); + m_Combo = -1; // Reset combo state + break; + } case 2: - { - spell = new FlameStrikeSpell(m_Mobile); - m_Combo = -1; // Reset combo state - break; - } + { + spell = new FlameStrikeSpell(m_Mobile); + m_Combo = -1; // Reset combo state + break; + } default: - { - spell = new PainSpikeSpell(m_Mobile); - m_Combo = -1; // Reset combo state - break; - } + { + spell = new PainSpikeSpell(m_Mobile); + m_Combo = -1; // Reset combo state + break; + } } } else if (m_Combo == 4 && spell == null) @@ -711,8 +711,7 @@ namespace Server.Mobiles { spell = DoCombo(c); } - else if (SmartAI && (c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned - ) // They have a heal spell out + else if (SmartAI && (c.Spell is HealSpell || c.Spell is GreaterHealSpell) && !c.Poisoned) // They have a heal spell out { spell = new PoisonSpell(m_Mobile); } diff --git a/Projects/Scripts/Mobiles/AI/MeleeAI.cs b/Projects/Scripts/Mobiles/AI/MeleeAI.cs index 94c6b571e..997f6848c 100644 --- a/Projects/Scripts/Mobiles/AI/MeleeAI.cs +++ b/Projects/Scripts/Mobiles/AI/MeleeAI.cs @@ -1,8 +1,3 @@ -// -// This is a first simple AI -// -// - namespace Server.Mobiles { public class MeleeAI : BaseAI @@ -70,9 +65,9 @@ namespace Server.Mobiles } } - /*if ( !m_Mobile.InLOS( combatant ) ) + /*if (!m_Mobile.InLOS( combatant )) { - if ( AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true ) ) + if (AcquireFocusMob( m_Mobile.RangePerception, m_Mobile.FightMode, false, false, true )) { m_Mobile.Combatant = combatant = m_Mobile.FocusMob; m_Mobile.FocusMob = null; diff --git a/Projects/Scripts/Mobiles/AI/OppositionGroup.cs b/Projects/Scripts/Mobiles/AI/OppositionGroup.cs index a3828733d..7b66d80cc 100644 --- a/Projects/Scripts/Mobiles/AI/OppositionGroup.cs +++ b/Projects/Scripts/Mobiles/AI/OppositionGroup.cs @@ -5,11 +5,11 @@ namespace Server { public class OppositionGroup { - private Type[][] m_Types; + private readonly Type[][] m_Types; public OppositionGroup(Type[][] types) => m_Types = types; - public static OppositionGroup TerathansAndOphidians{ get; } = new OppositionGroup(new[] + public static OppositionGroup TerathansAndOphidians { get; } = new OppositionGroup(new[] { new[] { @@ -28,7 +28,7 @@ namespace Server } }); - public static OppositionGroup SavagesAndOrcs{ get; } = new OppositionGroup(new[] + public static OppositionGroup SavagesAndOrcs { get; } = new OppositionGroup(new[] { new[] { @@ -49,7 +49,7 @@ namespace Server } }); - public static OppositionGroup FeyAndUndead{ get; } = new OppositionGroup(new[] + public static OppositionGroup FeyAndUndead { get; } = new OppositionGroup(new[] { new[] { diff --git a/Projects/Scripts/Mobiles/AI/PredatorAI.cs b/Projects/Scripts/Mobiles/AI/PredatorAI.cs index 8cf04c365..650babbf6 100644 --- a/Projects/Scripts/Mobiles/AI/PredatorAI.cs +++ b/Projects/Scripts/Mobiles/AI/PredatorAI.cs @@ -1,9 +1,3 @@ -/* - * PredatorAI, its an animal that can attack - * Dont flee but dont attack if not hurt or attacked - * - */ - namespace Server.Mobiles { public class PredatorAI : BaseAI diff --git a/Projects/Scripts/Mobiles/AI/SpeedInfo.cs b/Projects/Scripts/Mobiles/AI/SpeedInfo.cs index eef6cd8cf..69f24ec52 100644 --- a/Projects/Scripts/Mobiles/AI/SpeedInfo.cs +++ b/Projects/Scripts/Mobiles/AI/SpeedInfo.cs @@ -8,11 +8,11 @@ namespace Server public class SpeedInfo { // Should we use the new method of speeds? - private static bool Enabled = true; + private static readonly bool Enabled = true; private static Dictionary m_Table; - private static SpeedInfo[] m_Speeds = + private static readonly SpeedInfo[] m_Speeds = { /* Slow */ new SpeedInfo(0.3, 0.6, new[] @@ -43,11 +43,7 @@ namespace Server typeof(DemonKnight), typeof(GiantBlackWidow), typeof(SummonedAirElemental), typeof(LesserHiryu), typeof(Hiryu), typeof(LadyOfTheSnow), typeof(RaiJu), typeof(Ronin), typeof(RuneBeetle), - typeof(Changeling), - - #region ML named mobs - before Paragon speedboost - - typeof(LadyJennifyr), typeof(LadyMarai), typeof(MasterJonath), + typeof(Changeling), typeof(LadyJennifyr), typeof(LadyMarai), typeof(MasterJonath), typeof(MasterMikael), typeof(MasterTheophilus), typeof(RedDeath), typeof(SirPatrick), typeof(Miasma), typeof(Rend), typeof(Grobu), typeof(Gnaw), typeof(Guile), @@ -55,8 +51,6 @@ namespace Server typeof(LadySabrix), typeof(Malefic), typeof(Silk), typeof(Virulent) // TODO: Where to put Lurg, Putrefier, Swoop and Pyre? They seem slower. - - #endregion }), /* Very Fast */ new SpeedInfo(0.175, 0.350, new[] @@ -155,11 +149,11 @@ namespace Server Types = types; } - public double ActiveSpeed{ get; set; } + public double ActiveSpeed { get; set; } - public double PassiveSpeed{ get; set; } + public double PassiveSpeed { get; set; } - public Type[] Types{ get; set; } + public Type[] Types { get; set; } public static bool Contains(object obj) { diff --git a/Projects/Scripts/Mobiles/AI/ThiefAI.cs b/Projects/Scripts/Mobiles/AI/ThiefAI.cs index 1d8716ed5..f4f04bd7a 100644 --- a/Projects/Scripts/Mobiles/AI/ThiefAI.cs +++ b/Projects/Scripts/Mobiles/AI/ThiefAI.cs @@ -1,10 +1,5 @@ using Server.Items; -// -// This is a first simple AI -// -// - namespace Server.Mobiles { public class ThiefAI : BaseAI diff --git a/Projects/Scripts/Mobiles/AI/VendorAI.cs b/Projects/Scripts/Mobiles/AI/VendorAI.cs index 5038711a2..0b194f61d 100644 --- a/Projects/Scripts/Mobiles/AI/VendorAI.cs +++ b/Projects/Scripts/Mobiles/AI/VendorAI.cs @@ -1,8 +1,3 @@ -// -// This is a first simple AI -// -// - namespace Server.Mobiles { public class VendorAI : BaseAI diff --git a/Projects/Scripts/Mobiles/Animals/Birds/Crane.cs b/Projects/Scripts/Mobiles/Animals/Birds/Crane.cs index 3d41f5853..33b4ba0a4 100644 --- a/Projects/Scripts/Mobiles/Animals/Birds/Crane.cs +++ b/Projects/Scripts/Mobiles/Animals/Birds/Crane.cs @@ -41,7 +41,6 @@ namespace Server.Mobiles public override int Meat => 1; public override int Feathers => 25; - public override int GetAngerSound() => 0x4D9; public override int GetIdleSound() => 0x4D8; diff --git a/Projects/Scripts/Mobiles/Animals/Cows/Bull.cs b/Projects/Scripts/Mobiles/Animals/Cows/Bull.cs index c1fde5a09..ed8613c98 100644 --- a/Projects/Scripts/Mobiles/Animals/Cows/Bull.cs +++ b/Projects/Scripts/Mobiles/Animals/Cows/Bull.cs @@ -8,7 +8,7 @@ namespace Server.Mobiles Body = Utility.RandomList(0xE8, 0xE9); BaseSoundID = 0x64; - if (0.5 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.5) Hue = 0x901; SetStr(77, 111); diff --git a/Projects/Scripts/Mobiles/Animals/Cows/Cow.cs b/Projects/Scripts/Mobiles/Animals/Cows/Cow.cs index bcbb96bcc..30e07f737 100644 --- a/Projects/Scripts/Mobiles/Animals/Cows/Cow.cs +++ b/Projects/Scripts/Mobiles/Animals/Cows/Cow.cs @@ -49,10 +49,10 @@ namespace Server.Mobiles public override string CorpseName => "a cow corpse"; [CommandProperty(AccessLevel.GameMaster)] - public DateTime MilkedOn{ get; set; } + public DateTime MilkedOn { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Milk{ get; set; } + public int Milk { get; set; } public override string DefaultName => "a cow"; diff --git a/Projects/Scripts/Mobiles/Animals/Misc/PackHorse.cs b/Projects/Scripts/Mobiles/Animals/Misc/PackHorse.cs index 53aed277e..863cc60cf 100644 --- a/Projects/Scripts/Mobiles/Animals/Misc/PackHorse.cs +++ b/Projects/Scripts/Mobiles/Animals/Misc/PackHorse.cs @@ -78,8 +78,6 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Pack Animal Methods - public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) @@ -129,14 +127,12 @@ namespace Server.Mobiles PackAnimal.GetContextMenuEntries(this, from, list); } - - #endregion } public class PackAnimalBackpackEntry : ContextMenuEntry { - private BaseCreature m_Animal; - private Mobile m_From; + private readonly BaseCreature m_Animal; + private readonly Mobile m_From; public PackAnimalBackpackEntry(BaseCreature animal, Mobile from) : base(6145, 3) { diff --git a/Projects/Scripts/Mobiles/Animals/Misc/PackLlama.cs b/Projects/Scripts/Mobiles/Animals/Misc/PackLlama.cs index 550e28825..bd576a19f 100644 --- a/Projects/Scripts/Mobiles/Animals/Misc/PackLlama.cs +++ b/Projects/Scripts/Mobiles/Animals/Misc/PackLlama.cs @@ -77,8 +77,6 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Pack Animal Methods - public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) @@ -128,7 +126,5 @@ namespace Server.Mobiles PackAnimal.GetContextMenuEntries(this, from, list); } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Mobiles/Animals/Misc/Sheep.cs b/Projects/Scripts/Mobiles/Animals/Misc/Sheep.cs index 0d1f48f3e..8f77d2743 100644 --- a/Projects/Scripts/Mobiles/Animals/Misc/Sheep.cs +++ b/Projects/Scripts/Mobiles/Animals/Misc/Sheep.cs @@ -105,10 +105,10 @@ namespace Server.Mobiles switch (version) { case 1: - { - NextWoolTime = reader.ReadDeltaTime(); - break; - } + { + NextWoolTime = reader.ReadDeltaTime(); + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/BaseMount.cs b/Projects/Scripts/Mobiles/Animals/Mounts/BaseMount.cs index ac534cb79..6029f8ac9 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/BaseMount.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/BaseMount.cs @@ -28,9 +28,9 @@ namespace Server.Mobiles public virtual TimeSpan MountAbilityDelay => TimeSpan.Zero; [CommandProperty(AccessLevel.GameMaster)] - public DateTime NextMountAbility{ get; set; } + public DateTime NextMountAbility { get; set; } - protected Item InternalItem{ get; private set; } + protected Item InternalItem { get; private set; } public virtual bool AllowMaleRider => true; public virtual bool AllowFemaleRider => true; @@ -160,20 +160,20 @@ namespace Server.Mobiles switch (version) { case 1: - { - NextMountAbility = reader.ReadDateTime(); - goto case 0; - } + { + NextMountAbility = reader.ReadDateTime(); + goto case 0; + } case 0: - { - m_Rider = reader.ReadMobile(); - InternalItem = reader.ReadItem(); + { + m_Rider = reader.ReadMobile(); + InternalItem = reader.ReadItem(); - if (InternalItem == null) - Delete(); + if (InternalItem == null) + Delete(); - break; - } + break; + } } } @@ -224,8 +224,8 @@ namespace Server.Mobiles if (from.InRange(this, 1)) { bool canAccess = from.AccessLevel >= AccessLevel.GameMaster - || Controlled && ControlMaster == from - || Summoned && SummonMaster == from; + || (Controlled && ControlMaster == from) + || (Summoned && SummonMaster == from); if (canAccess) { @@ -334,14 +334,14 @@ namespace Server.Mobiles switch (version) { case 0: - { - m_Mount = reader.ReadMobile() as BaseMount; + { + m_Mount = reader.ReadMobile() as BaseMount; - if (m_Mount == null) - Delete(); + if (m_Mount == null) + Delete(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Beetle.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Beetle.cs index 25c043de2..e5e49df54 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Beetle.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Beetle.cs @@ -7,8 +7,7 @@ namespace Server.Mobiles public class Beetle : BaseMount { [Constructible] - public Beetle(string name = "a giant beetle") : - base(name, 0x317, 0x3EBC, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.25, 0.5) + public Beetle(string name = "a giant beetle") : base(name, 0x317, 0x3EBC, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.25, 0.5) { SetStr(300); SetDex(100); @@ -95,8 +94,6 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Pack Animal Methods - public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) @@ -141,7 +138,5 @@ namespace Server.Mobiles PackAnimal.GetContextMenuEntries(this, from, list); } - - #endregion } } diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs b/Projects/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs index 8d37a3c62..ba8ee5f48 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/DesertOstard.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class DesertOstard : BaseMount { [Constructible] - public DesertOstard(string name = "a desert ostard") : - base(name, 0xD2, 0x3EA3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public DesertOstard(string name = "a desert ostard") : base(name, 0xD2, 0x3EA3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x270; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Ethereals.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Ethereals.cs index 73a38db8d..927759b35 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Ethereals.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Ethereals.cs @@ -122,7 +122,7 @@ namespace Server.Mobiles public IMount Mount => this; [CommandProperty(AccessLevel.GameMaster)] - public bool IsRewardItem{ get; set; } + public bool IsRewardItem { get; set; } public override void GetProperties(ObjectPropertyList list) { @@ -161,7 +161,7 @@ namespace Server.Mobiles return false; } - if (IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this) || !BaseMount.CheckMountAllowed(from)) + if ((IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this)) || !BaseMount.CheckMountAllowed(from)) return false; if (from.Mounted) @@ -228,29 +228,29 @@ namespace Server.Mobiles switch (version) { case 3: - { - m_IsDonationItem = reader.ReadBool(); - goto case 2; - } + { + m_IsDonationItem = reader.ReadBool(); + goto case 2; + } case 2: - { - IsRewardItem = reader.ReadBool(); - goto case 0; - } + { + IsRewardItem = reader.ReadBool(); + goto case 0; + } case 1: reader.ReadInt(); goto case 0; case 0: - { - m_MountedID = reader.ReadInt(); - m_RegularID = reader.ReadInt(); - m_Rider = reader.ReadMobile(); + { + m_MountedID = reader.ReadInt(); + m_RegularID = reader.ReadInt(); + m_Rider = reader.ReadMobile(); - if (m_MountedID == 0x3EA2) - m_MountedID = 0x3EAA; + if (m_MountedID == 0x3EA2) + m_MountedID = 0x3EAA; - break; - } + break; + } } AddFollowers(); @@ -261,7 +261,7 @@ namespace Server.Mobiles public override DeathMoveResult OnParentDeath(Mobile parent) { - Rider = null; //get off, move to pack + Rider = null; // get off, move to pack return DeathMoveResult.RemainEquipped; } @@ -327,10 +327,10 @@ namespace Server.Mobiles private class EtherealSpell : Spell { - private static SpellInfo m_Info = new SpellInfo("Ethereal Mount", "", 230); + private static readonly SpellInfo m_Info = new SpellInfo("Ethereal Mount", "", 230); - private EtherealMount m_Mount; - private Mobile m_Rider; + private readonly EtherealMount m_Mount; + private readonly Mobile m_Rider; private bool m_Stop; @@ -390,7 +390,7 @@ namespace Server.Mobiles Caster.SendLocalizedMessage( 1049455); // You have been disrupted while attempting to summon your ethereal mount! - //m_Mount.UnmountMe(); + // m_Mount.UnmountMe(); } public override void OnCast() diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/FireSteed.cs b/Projects/Scripts/Mobiles/Animals/Mounts/FireSteed.cs index 3b261a42c..ea0e8ea2f 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/FireSteed.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/FireSteed.cs @@ -6,8 +6,7 @@ namespace Server.Mobiles public class FireSteed : BaseMount { [Constructible] - public FireSteed(string name = "a fire steed") : - base(name, 0xBE, 0x3E9E, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public FireSteed(string name = "a fire steed") : base(name, 0xBE, 0x3E9E, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { BaseSoundID = 0xA8; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs b/Projects/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs index 92df7ee34..59ffd61e6 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/ForestOstard.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class ForestOstard : BaseMount { [Constructible] - public ForestOstard(string name = "a forest ostard") : - base(name, 0xDB, 0x3EA5, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public ForestOstard(string name = "a forest ostard") : base(name, 0xDB, 0x3EA5, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { Hue = Utility.RandomSlimeHue() | 0x8000; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs b/Projects/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs index 6248ab17b..74f6e0108 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/FrenziedOstard.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class FrenziedOstard : BaseMount { [Constructible] - public FrenziedOstard(string name = "a frenzied ostard") : - base(name, 0xDA, 0x3EA4, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public FrenziedOstard(string name = "a frenzied ostard") : base(name, 0xDA, 0x3EA4, AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Hue = Race.Human.RandomHairHue() | 0x8000; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/HellSteed.cs b/Projects/Scripts/Mobiles/Animals/Mounts/HellSteed.cs index 5434c7087..4b6731e20 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/HellSteed.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/HellSteed.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class HellSteed : BaseMount { [Constructible] - public HellSteed(string name = "a hellsteed") : - base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public HellSteed(string name = "a hellsteed") : base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { SetStats(this); } diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Hiryu.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Hiryu.cs index 81cdf77d4..98a5eec3f 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Hiryu.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Hiryu.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class Hiryu : BaseMount { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public Hiryu() @@ -73,29 +73,6 @@ namespace Server.Mobiles { int rand = Utility.Random(1075); - /* - 1000 1075 No Hue Color 93.02% 0x0 - * - 10 1075 Ice Green 0.93% 0x847F - 10 1075 Light Blue 0.93% 0x848D - 10 1075 Strong Cyan 0.93% 0x8495 - 10 1075 Agapite 0.93% 0x8899 - 10 1075 Gold 0.93% 0x8032 - * - 8 1075 Blue and Yellow 0.74% 0x8487 - * - 5 1075 Ice Blue 0.47% 0x8482 - * - 3 1075 Cyan 0.28% 0x8123 - 3 1075 Light Green 0.28% 0x8295 - * - 2 1075 Strong Yellow 0.19% 0x8037 - 2 1075 Green 0.19% 0x8030 //this one is an approximation - * - 1 1075 Strong Purple 0.09% 0x8490 - 1 1075 Strong Green 0.09% 0x855C - * */ - if (rand <= 0) return 0x855C; if (rand <= 1) @@ -123,11 +100,9 @@ namespace Server.Mobiles if (rand <= 74) return 0x847F; - return 0; } - public override int GetAngerSound() => 0x4FE; public override int GetIdleSound() => 0x4FD; @@ -148,7 +123,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.1) return; /* Grasping Claw @@ -193,10 +168,10 @@ namespace Server.Mobiles int version = reader.ReadInt(); if (version == 0) - Timer.DelayCall(TimeSpan.Zero, delegate { Hue = GetHue(); }); + Timer.DelayCall(TimeSpan.Zero, () => { Hue = GetHue(); }); if (version <= 1) - Timer.DelayCall(TimeSpan.Zero, delegate + Timer.DelayCall(TimeSpan.Zero, () => { if (InternalItem != null) InternalItem.Hue = Hue; }); @@ -212,8 +187,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; - private ResistanceMod m_Mod; + private readonly Mobile m_Mobile; + private readonly ResistanceMod m_Mod; public ExpireTimer(Mobile m, ResistanceMod mod, TimeSpan delay) : base(delay) diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Horse.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Horse.cs index e851f2db1..b547e59a0 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Horse.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Horse.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles "Server.Mobiles.TanHorse")] public class Horse : BaseMount { - private static int[] m_IDs = + private static readonly int[] m_IDs = { 0xC8, 0x3E9F, 0xE2, 0x3EA0, @@ -13,8 +13,7 @@ namespace Server.Mobiles }; [Constructible] - public Horse(string name = "a horse") : - base(name, 0xE2, 0x3EA0, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public Horse(string name = "a horse") : base(name, 0xE2, 0x3EA0, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { int random = Utility.Random(4); diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Kirin.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Kirin.cs index 3c86160d8..40608f017 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Kirin.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Kirin.cs @@ -7,8 +7,7 @@ namespace Server.Mobiles public class Kirin : BaseMount { [Constructible] - public Kirin(string name = "a ki-rin") : - base(name, 132, 0x3EAD, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) + public Kirin(string name = "a ki-rin") : base(name, 132, 0x3EAD, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3C5; @@ -72,16 +71,15 @@ namespace Server.Mobiles public override bool DoMountAbility(int damage, Mobile attacker) { - if (Rider == null || attacker == null) //sanity + if (Rider == null || attacker == null) // sanity return false; - if (Rider.Hits - damage < 30 && Rider.Map == attacker.Map && Rider.InRange(attacker, 18) - ) //Range and map checked here instead of other base fuction because of abiliites that don't need to check this + if (Rider.Hits - damage < 30 && Rider.Map == attacker.Map && Rider.InRange(attacker, 18)) // Range and map checked here instead of other base fuction because of abiliites that don't need to check this { attacker.BoltEffect(0); // 35~100 damage, unresistable, by the Ki-rin. attacker.Damage(Utility.RandomMinMax(35, 100), this, - false); //Don't inform mount about this damage, Still unsure wether or not it's flagged as the mount doing damage or the player. If changed to player, without the extra bool it'd be an infinite loop + false); // Don't inform mount about this damage, Still unsure wether or not it's flagged as the mount doing damage or the player. If changed to player, without the extra bool it'd be an infinite loop Rider.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1042534); // Your mount calls down the forces of nature on your opponent. diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs b/Projects/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs index bf7a1fbb4..28956f8f6 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/LesserHiryu.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class LesserHiryu : BaseMount { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public LesserHiryu() @@ -72,12 +72,12 @@ namespace Server.Mobiles /* - 500 527 No Hue Color 94.88% 0 - 10 527 Green 1.90% 0x8295 - 10 527 Green 1.90% 0x8163 (Very Close to Above Green) //this one is an approximation - 5 527 Dark Green 0.95% 0x87D4 - 1 527 Valorite 0.19% 0x88AB - 1 527 Midnight Blue 0.19% 0x8258 + 500 527 No Hue Color 94.88% 0 + 10 527 Green 1.90% 0x8295 + 10 527 Green 1.90% 0x8163 (Very Close to Above Green) //this one is an approximation + 5 527 Dark Green 0.95% 0x87D4 + 1 527 Valorite 0.19% 0x88AB + 1 527 Midnight Blue 0.19% 0x8258 * */ @@ -92,11 +92,9 @@ namespace Server.Mobiles if (rand <= 26) return 0x8295; - return 0; } - public override bool OverrideBondingReqs() { if (ControlMaster.Skills.Bushido.Base >= 90.0) @@ -142,7 +140,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.1) return; /* Grasping Claw @@ -187,10 +185,10 @@ namespace Server.Mobiles int version = reader.ReadInt(); if (version == 0) - Timer.DelayCall(TimeSpan.Zero, delegate { Hue = GetHue(); }); + Timer.DelayCall(TimeSpan.Zero, () => Hue = GetHue()); if (version <= 1) - Timer.DelayCall(TimeSpan.Zero, delegate + Timer.DelayCall(TimeSpan.Zero, () => { if (InternalItem != null) InternalItem.Hue = Hue; }); @@ -206,8 +204,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; - private ResistanceMod m_Mod; + private readonly Mobile m_Mobile; + private readonly ResistanceMod m_Mod; public ExpireTimer(Mobile m, ResistanceMod mod, TimeSpan delay) : base(delay) diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Nightmare.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Nightmare.cs index 23638fbfc..57276ec9f 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Nightmare.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Nightmare.cs @@ -5,8 +5,7 @@ namespace Server.Mobiles public class Nightmare : BaseMount { [Constructible] - public Nightmare(string name = "a nightmare") : - base(name, 0x74, 0x3EA7, AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) + public Nightmare(string name = "a nightmare") : base(name, 0x74, 0x3EA7, AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) { BaseSoundID = Core.AOS ? 0xA8 : 0x16A; @@ -46,23 +45,23 @@ namespace Server.Mobiles switch (Utility.Random(3)) { case 0: - { - BodyValue = 116; - ItemID = 16039; - break; - } + { + BodyValue = 116; + ItemID = 16039; + break; + } case 1: - { - BodyValue = 178; - ItemID = 16041; - break; - } + { + BodyValue = 178; + ItemID = 16041; + break; + } case 2: - { - BodyValue = 179; - ItemID = 16055; - break; - } + { + BodyValue = 179; + ItemID = 16055; + break; + } } PackItem(new SulfurousAsh(Utility.RandomMinMax(3, 5))); diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs b/Projects/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs index dae7c91aa..52401242c 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/RidableLlama.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class RidableLlama : BaseMount { [Constructible] - public RidableLlama(string name = "a ridable llama") : - base(name, 0xDC, 0x3EA6, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public RidableLlama(string name = "a ridable llama") : base(name, 0xDC, 0x3EA6, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3F3; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs index 940736e7a..296f2418b 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Ridgeback.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class Ridgeback : BaseMount { [Constructible] - public Ridgeback(string name = "a ridgeback") : - base(name, 187, 0x3EBA, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public Ridgeback(string name = "a ridgeback") : base(name, 187, 0x3EBA, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3F3; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs b/Projects/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs index a7d754912..3fc667dd5 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/SavageRidgeback.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class SavageRidgeback : BaseMount { [Constructible] - public SavageRidgeback(string name = "a savage ridgeback") : - base(name, 188, 0x3EB8, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SavageRidgeback(string name = "a savage ridgeback") : base(name, 188, 0x3EB8, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x3F3; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs b/Projects/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs index 3bef247a3..56268a110 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/ScaledSwampDragon.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class ScaledSwampDragon : BaseMount { [Constructible] - public ScaledSwampDragon(string name = "a swamp dragon") : - base(name, 0x31F, 0x3EBE, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public ScaledSwampDragon(string name = "a swamp dragon") : base(name, 0x31F, 0x3EBE, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) { SetStr(201, 300); SetDex(66, 85); diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs b/Projects/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs index 5523fa95a..68a1970cf 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/SeaHorse.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class SeaHorse : BaseMount { [Constructible] - public SeaHorse(string name = "a sea horse") : - base(name, 0x90, 0x3EB3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SeaHorse(string name = "a sea horse") : base(name, 0x90, 0x3EB3, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { InitStats(Utility.Random(50, 30), Utility.Random(50, 30), 10); Skills.MagicResist.Base = 25.0 + Utility.RandomDouble() * 5.0; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs b/Projects/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs index 1f45ea1be..e8db7d3f4 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/SilverSteed.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class SilverSteed : BaseMount { [Constructible] - public SilverSteed(string name = "a silver steed") : - base(name, 0x75, 0x3EA8, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SilverSteed(string name = "a silver steed") : base(name, 0x75, 0x3EA8, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { InitStats(Utility.Random(50, 30), Utility.Random(50, 30), 10); Skills.MagicResist.Base = 25.0 + Utility.RandomDouble() * 5.0; diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs b/Projects/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs index 442dc55e5..53bf40892 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/SkeletalMount.cs @@ -3,8 +3,7 @@ namespace Server.Mobiles public class SkeletalMount : BaseMount { [Constructible] - public SkeletalMount(string name = null) : - base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SkeletalMount(string name = null) : base(name, 793, 0x3EBB, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { SetStr(91, 100); SetDex(46, 55); @@ -56,12 +55,12 @@ namespace Server.Mobiles switch (version) { case 0: - { - Tamable = false; - MinTameSkill = 0.0; - ControlSlots = 0; - break; - } + { + Tamable = false; + MinTameSkill = 0.0; + ControlSlots = 0; + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs b/Projects/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs index 4f64f4e4c..bf64afe81 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/SwampDragon.cs @@ -11,8 +11,7 @@ namespace Server.Mobiles private bool m_HasBarding; [Constructible] - public SwampDragon(string name = "a swamp dragon") : - base(name, 0x31A, 0x3EBD, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public SwampDragon(string name = "a swamp dragon") : base(name, 0x31A, 0x3EBD, AIType.AI_Melee, FightMode.Aggressor, 10, 1, 0.2, 0.4) { BaseSoundID = 0x16A; @@ -181,14 +180,14 @@ namespace Server.Mobiles switch (version) { case 1: - { - m_BardingExceptional = reader.ReadBool(); - m_BardingCrafter = reader.ReadMobile(); - m_HasBarding = reader.ReadBool(); - m_BardingHP = reader.ReadInt(); - m_BardingResource = (CraftResource)reader.ReadInt(); - break; - } + { + m_BardingExceptional = reader.ReadBool(); + m_BardingCrafter = reader.ReadMobile(); + m_HasBarding = reader.ReadBool(); + m_BardingHP = reader.ReadInt(); + m_BardingResource = (CraftResource)reader.ReadInt(); + break; + } } if (Hue == 0 && !m_HasBarding) diff --git a/Projects/Scripts/Mobiles/Animals/Mounts/Unicorn.cs b/Projects/Scripts/Mobiles/Animals/Mounts/Unicorn.cs index 1ea32c493..15c04748a 100644 --- a/Projects/Scripts/Mobiles/Animals/Mounts/Unicorn.cs +++ b/Projects/Scripts/Mobiles/Animals/Mounts/Unicorn.cs @@ -7,8 +7,7 @@ namespace Server.Mobiles public class Unicorn : BaseMount { [Constructible] - public Unicorn(string name = "a unicorn") : - base(name, 0x7A, 0x3EB4, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) + public Unicorn(string name = "a unicorn") : base(name, 0x7A, 0x3EB4, AIType.AI_Mage, FightMode.Evil, 10, 1, 0.2, 0.4) { BaseSoundID = 0x4BC; @@ -71,7 +70,7 @@ namespace Server.Mobiles public override bool DoMountAbility(int damage, Mobile attacker) { - if (Rider == null || attacker == null) //sanity + if (Rider == null || attacker == null) // sanity return false; if (Rider.Poisoned && Rider.Hits - damage < 40) @@ -85,7 +84,7 @@ namespace Server.Mobiles chanceToCure /= 100; if (chanceToCure > Utility.Random(100)) - if (Rider.CurePoison(this)) //TODO: Confirm if mount is the one flagged for curing it or the rider is + if (Rider.CurePoison(this)) // TODO: Confirm if mount is the one flagged for curing it or the rider is { Rider.LocalOverheadMessage(MessageType.Regular, 0x3B2, true, "Your mount senses you are in danger and aids you with magic."); diff --git a/Projects/Scripts/Mobiles/Animals/Reptiles/GiantSerpent.cs b/Projects/Scripts/Mobiles/Animals/Reptiles/GiantSerpent.cs index e03b55503..807294e82 100644 --- a/Projects/Scripts/Mobiles/Animals/Reptiles/GiantSerpent.cs +++ b/Projects/Scripts/Mobiles/Animals/Reptiles/GiantSerpent.cs @@ -52,7 +52,7 @@ namespace Server.Mobiles public override string DefaultName => "a giant snake"; public override Poison PoisonImmune => Poison.Greater; - public override Poison HitPoison => 0.8 >= Utility.RandomDouble() ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; public override bool DeathAdderCharmable => true; diff --git a/Projects/Scripts/Mobiles/Animals/Reptiles/IceSerpent.cs b/Projects/Scripts/Mobiles/Animals/Reptiles/IceSerpent.cs index 0a1588ef3..983e53a5f 100644 --- a/Projects/Scripts/Mobiles/Animals/Reptiles/IceSerpent.cs +++ b/Projects/Scripts/Mobiles/Animals/Reptiles/IceSerpent.cs @@ -74,7 +74,7 @@ namespace Server.Mobiles break; } - if (0.025 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.025) PackItem(new GlacialStaff()); } diff --git a/Projects/Scripts/Mobiles/BaseCreature.cs b/Projects/Scripts/Mobiles/BaseCreature.cs index 485c9782e..1bbe6ae1b 100644 --- a/Projects/Scripts/Mobiles/BaseCreature.cs +++ b/Projects/Scripts/Mobiles/BaseCreature.cs @@ -27,8 +27,6 @@ using Server.Utilities; namespace Server.Mobiles { - #region Enums - /// /// Summary description for MobileAI. /// @@ -44,25 +42,25 @@ namespace Server.Mobiles public enum OrderType { - None, //When no order, let's roam - Come, //"(All/Name) come" Summons all or one pet to your location. - Drop, //"(Name) drop" Drops its loot to the ground (if it carries any). - Follow, //"(Name) follow" Follows targeted being. + None, // When no order, let's roam + Come, // "(All/Name) come" Summons all or one pet to your location. + Drop, // "(Name) drop" Drops its loot to the ground (if it carries any). + Follow, // "(Name) follow" Follows targeted being. - //"(All/Name) follow me" Makes all or one pet follow you. - Friend, //"(Name) friend" Allows targeted player to confirm resurrection. + // "(All/Name) follow me" Makes all or one pet follow you. + Friend, // "(Name) friend" Allows targeted player to confirm resurrection. Unfriend, // Remove a friend - Guard, //"(Name) guard" Makes the specified pet guard you. Pets can only guard their owner. + Guard, // "(Name) guard" Makes the specified pet guard you. Pets can only guard their owner. - //"(All/Name) guard me" Makes all or one pet guard you. - Attack, //"(All/Name) kill", + // "(All/Name) guard me" Makes all or one pet guard you. + Attack, // "(All/Name) kill", - //"(All/Name) attack" All or the specified pet(s) currently under your control attack the target. - Patrol, //"(Name) patrol" Roves between two or more guarded targets. - Release, //"(Name) release" Releases pet back into the wild (removes "tame" status). - Stay, //"(All/Name) stay" All or the specified pet(s) will stop and stay in current spot. - Stop, //"(All/Name) stop Cancels any current orders to attack, guard or follow. - Transfer //"(Name) transfer" Transfers complete ownership to targeted player. + // "(All/Name) attack" All or the specified pet(s) currently under your control attack the target. + Patrol, // "(Name) patrol" Roves between two or more guarded targets. + Release, // "(Name) release" Releases pet back into the wild (removes "tame" status). + Stay, // "(All/Name) stay" All or the specified pet(s) will stop and stay in current spot. + Stop, // "(All/Name) stop Cancels any current orders to attack, guard or follow. + Transfer // "(Name) transfer" Transfers complete ownership to targeted player. } [Flags] @@ -117,8 +115,6 @@ namespace Server.Mobiles Barbed } - #endregion - public class DamageStore : IComparable { public int m_Damage; @@ -138,9 +134,9 @@ namespace Server.Mobiles public class FriendlyNameAttribute : Attribute { public FriendlyNameAttribute(TextDefinition friendlyName) => FriendlyName = friendlyName; - //future use: Talisman 'Protection/Bonus vs. Specific Creature + // future use: Talisman 'Protection/Bonus vs. Specific Creature - public TextDefinition FriendlyName{ get; } + public TextDefinition FriendlyName { get; } public static TextDefinition GetFriendlyNameFor(Type t) { @@ -173,7 +169,7 @@ namespace Server.Mobiles private const double MinutesToNextChanceMin = 0.25; private const double MinutesToNextChanceMax = 0.75; - private static Type[] m_AnimateDeadTypes = + private static readonly Type[] m_AnimateDeadTypes = { typeof(MoundOfMaggots), typeof(HellSteed), typeof(SkeletalMount), typeof(WailingBanshee), typeof(Wraith), typeof(SkeletalDragon), @@ -182,19 +178,19 @@ namespace Server.Mobiles typeof(SkeletalMage), typeof(BoneMagi), typeof(PatchworkSkeleton) }; - private static double[] m_StandardActiveSpeeds = + private static readonly double[] m_StandardActiveSpeeds = { 0.175, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8 }; - private static double[] m_StandardPassiveSpeeds = + private static readonly double[] m_StandardPassiveSpeeds = { 0.350, 0.2, 0.4, 0.5, 0.6, 0.8, 1.0, 1.2, 1.6, 2.0 }; private static Mobile m_NoDupeGuards; - private static bool EnableRummaging = true; + private static readonly bool EnableRummaging = true; private DateTime m_IdleReleaseTime; @@ -290,10 +286,10 @@ namespace Server.Mobiles /* Do not serialize this till the code is finalized */ [CommandProperty(AccessLevel.GameMaster)] - public bool SeeksHome{ get; set; } + public bool SeeksHome { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public string CorpseNameOverride{ get; set; } + public string CorpseNameOverride { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public bool IsStabled @@ -308,12 +304,12 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] - public Mobile StabledBy{ get; set; } + public Mobile StabledBy { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool IsPrisoner{ get; set; } + public bool IsPrisoner { get; set; } - protected DateTime SummonEnd{ get; set; } + protected DateTime SummonEnd { get; set; } public virtual Faction FactionAllegiance => null; public virtual int FactionSilverWorth => 30; @@ -344,7 +340,7 @@ namespace Server.Mobiles public virtual FoodType FavoriteFood => FoodType.Meat; public virtual PackInstinct PackInstinct => PackInstinct.None; - public List Owners{ get; private set; } + public List Owners { get; private set; } public virtual bool AllowMaleTamer => true; public virtual bool AllowFemaleTamer => true; @@ -369,7 +365,7 @@ namespace Server.Mobiles public virtual bool DeathAdderCharmable => false; - //TODO: Find the pub 31 tweaks to the DispelDifficulty and apply them of course. + // TODO: Find the pub 31 tweaks to the DispelDifficulty and apply them of course. public virtual double DispelDifficulty // at this skill level we dispel 50% chance => 0.0; @@ -382,7 +378,7 @@ namespace Server.Mobiles public virtual bool IsInvulnerable => false; - public BaseAI AIObject{ get; private set; } + public BaseAI AIObject { get; private set; } public virtual OppositionGroup OppositionGroup => null; @@ -418,10 +414,10 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public WayPoint CurrentWayPoint{ get; set; } + public WayPoint CurrentWayPoint { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public IPoint2D TargetLocation{ get; set; } + public IPoint2D TargetLocation { get; set; } public virtual Mobile ConstantFocus => null; @@ -467,7 +463,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public int HitsMaxSeed{ get; set; } = -1; + public int HitsMaxSeed { get; set; } = -1; [CommandProperty(AccessLevel.GameMaster)] public override int StamMax @@ -485,12 +481,11 @@ namespace Server.Mobiles value = 65000; return value; - } } [CommandProperty(AccessLevel.GameMaster)] - public int StamMaxSeed{ get; set; } = -1; + public int StamMaxSeed { get; set; } = -1; [CommandProperty(AccessLevel.GameMaster)] public override int ManaMax @@ -508,12 +503,11 @@ namespace Server.Mobiles value = 65000; return value; - } } [CommandProperty(AccessLevel.GameMaster)] - public int ManaMaxSeed{ get; set; } = -1; + public int ManaMaxSeed { get; set; } = -1; public virtual bool CanOpenDoors => !Body.IsAnimal && !Body.IsSea; @@ -555,7 +549,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.Administrator)] - public bool Debug{ get; set; } + public bool Debug { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int Team @@ -569,25 +563,25 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public Mobile FocusMob{ get; set; } + public Mobile FocusMob { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public FightMode FightMode{ get; set; } + public FightMode FightMode { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int RangePerception{ get; set; } + public int RangePerception { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int RangeFight{ get; set; } + public int RangeFight { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int RangeHome{ get; set; } = 10; + public int RangeHome { get; set; } = 10; [CommandProperty(AccessLevel.GameMaster)] - public double ActiveSpeed{ get; set; } + public double ActiveSpeed { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public double PassiveSpeed{ get; set; } + public double PassiveSpeed { get; set; } [CommandProperty(AccessLevel.GameMaster)] public double CurrentSpeed @@ -611,7 +605,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public Map HomeMap{ get; set; } + public Map HomeMap { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Controlled @@ -666,10 +660,10 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public Mobile ControlTarget{ get; set; } + public Mobile ControlTarget { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D ControlDest{ get; set; } + public Point3D ControlDest { get; set; } [CommandProperty(AccessLevel.GameMaster)] public OrderType ControlOrder @@ -688,22 +682,22 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public bool BardProvoked{ get; set; } + public bool BardProvoked { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool BardPacified{ get; set; } + public bool BardPacified { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile BardMaster{ get; set; } + public Mobile BardMaster { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile BardTarget{ get; set; } + public Mobile BardTarget { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime BardEndTime{ get; set; } + public DateTime BardEndTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public double MinTameSkill{ get; set; } + public double MinTameSkill { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Tamable @@ -731,7 +725,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.Administrator)] - public int ControlSlots{ get; set; } = 1; + public int ControlSlots { get; set; } = 1; public virtual bool NoHouseRestrictions => false; public virtual bool IsHouseSummonable => false; @@ -752,14 +746,10 @@ namespace Server.Mobiles public virtual bool IgnoreYoungProtection => false; - public bool NoKillAwards{ get; set; } - - #region Mondain's Legacy + public bool NoKillAwards { get; set; } public virtual bool GivesMLMinorArtifact => false; - #endregion - /* To save on cpu usage, RunUO creatures only reacquire creatures under the following circumstances: * - 10 seconds have elapsed since the last time it tried * - The creature was attacked @@ -768,20 +758,20 @@ namespace Server.Mobiles * This functionality appears to be implemented on OSI as well */ - public long NextReacquireTime{ get; set; } + public long NextReacquireTime { get; set; } public virtual TimeSpan ReacquireDelay => TimeSpan.FromSeconds(10.0); public virtual bool ReacquireOnMovement => false; public virtual bool AcquireOnApproach => m_Paragon; public virtual int AcquireOnApproachRange => 10; - public static bool Summoning{ get; set; } + public static bool Summoning { get; set; } public virtual bool CanBreath => HasBreath && !Summoned; public virtual bool IsDispellable => Summoned && !IsAnimatedDead; public virtual bool - PlayerRangeSensitive //If they are following a waypoint, they'll continue to follow it even if players aren't around + PlayerRangeSensitive // If they are following a waypoint, they'll continue to follow it even if players aren't around => CurrentWayPoint == null; public virtual bool ReturnsToHome => @@ -790,12 +780,12 @@ namespace Server.Mobiles // used for deleting untamed creatures [in houses] [CommandProperty(AccessLevel.GameMaster)] - public bool RemoveIfUntamed{ get; set; } + public bool RemoveIfUntamed { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int RemoveStep{ get; set; } + public int RemoveStep { get; set; } - public HonorContext ReceivedHonorContext{ get; set; } + public HonorContext ReceivedHonorContext { get; set; } public virtual WeaponAbility GetWeaponAbility() => null; @@ -825,7 +815,7 @@ namespace Server.Mobiles if (TransformationSpellHelper.UnderTransformation(m, typeof(EtherealVoyageSpell))) return false; - if (FightMode == FightMode.Evil && m.Karma < 0 || c.FightMode == FightMode.Evil && Karma < 0) + if ((FightMode == FightMode.Evil && m.Karma < 0) || (c.FightMode == FightMode.Evil && Karma < 0)) return true; return m_Team != c.m_Team || (m_bSummoned || m_Controlled) != (c.m_bSummoned || c.m_Controlled); @@ -920,7 +910,7 @@ namespace Server.Mobiles { int oldHits = Hits; - if (Core.AOS && !Summoned && Controlled && 0.2 > Utility.RandomDouble()) + if (Core.AOS && !Summoned && Controlled && Utility.RandomDouble() < 0.2) amount = (int)(amount * BonusPetDamageScalar); if (EvilOmenSpell.TryEndEffect(this)) @@ -1000,7 +990,7 @@ namespace Server.Mobiles Unpacify(); int disruptThreshold; - //NPCs can use bandages too! + // NPCs can use bandages too! if (!Core.AOS) disruptThreshold = 0; else if (from?.Player == true) @@ -1060,7 +1050,7 @@ namespace Server.Mobiles int hides = Hides; int scales = Scales; - if (feathers == 0 && wool == 0 && meat == 0 && hides == 0 && scales == 0 || Summoned || IsBonded || + if ((feathers == 0 && wool == 0 && meat == 0 && hides == 0 && scales == 0) || Summoned || IsBonded || corpse.Animated) { if (corpse.Animated) @@ -1181,15 +1171,15 @@ namespace Server.Mobiles corpse.AddCarvedItem(new BlueScales(scales), from); break; case ScaleType.All: - { - corpse.AddCarvedItem(new RedScales(scales), from); - corpse.AddCarvedItem(new YellowScales(scales), from); - corpse.AddCarvedItem(new BlackScales(scales), from); - corpse.AddCarvedItem(new GreenScales(scales), from); - corpse.AddCarvedItem(new WhiteScales(scales), from); - corpse.AddCarvedItem(new BlueScales(scales), from); - break; - } + { + corpse.AddCarvedItem(new RedScales(scales), from); + corpse.AddCarvedItem(new YellowScales(scales), from); + corpse.AddCarvedItem(new BlackScales(scales), from); + corpse.AddCarvedItem(new GreenScales(scales), from); + corpse.AddCarvedItem(new WhiteScales(scales), from); + corpse.AddCarvedItem(new BlueScales(scales), from); + break; + } } from.SendMessage("You cut away some scales, but they remain on the corpse."); @@ -1245,7 +1235,7 @@ namespace Server.Mobiles writer.Write((int)m_ControlOrder); writer.Write(MinTameSkill); // Removed in version 9 - //writer.Write( (double) m_dMaxTameSkill ); + // writer.Write( (double) m_dMaxTameSkill ); writer.Write(m_bTamable); writer.Write(m_bSummoned); @@ -1312,7 +1302,7 @@ namespace Server.Mobiles writer.Write(RemoveStep); // Version 17 - if (IsStabled || Controlled && ControlMaster != null) + if (IsStabled || (Controlled && ControlMaster != null)) writer.Write(TimeSpan.Zero); else writer.Write(DeleteTimeLeft); @@ -1516,7 +1506,7 @@ namespace Server.Mobiles if (version >= 17) deleteTime = reader.ReadTimeSpan(); - if (deleteTime > TimeSpan.Zero || LastOwner != null && !Controlled && !IsStabled) + if (deleteTime > TimeSpan.Zero || (LastOwner != null && !Controlled && !IsStabled)) { if (deleteTime == TimeSpan.Zero) deleteTime = TimeSpan.FromDays(3.0); @@ -1531,7 +1521,7 @@ namespace Server.Mobiles if (version >= 19) HomeMap = reader.ReadMap(); - if (version <= 14 && m_Paragon && Hue == 0x31) Hue = Paragon.Hue; //Paragon hue fixed, should now be 0x501. + if (version <= 14 && m_Paragon && Hue == 0x31) Hue = Paragon.Hue; // Paragon hue fixed, should now be 0x501. if (Core.AOS && NameHue == 0x35) NameHue = -1; @@ -1604,7 +1594,7 @@ namespace Server.Mobiles return base.OnDragDrop(from, dropped); } - public void ChangeAIType(AIType NewAI) + public void ChangeAIType(AIType newAI) { AIObject?.m_Timer.Stop(); @@ -1614,7 +1604,7 @@ namespace Server.Mobiles return; } - AIObject = NewAI switch + AIObject = newAI switch { AIType.AI_Melee => (BaseAI)new MeleeAI(this), AIType.AI_Animal => new AnimalAI(this), @@ -1624,7 +1614,7 @@ namespace Server.Mobiles AIType.AI_Vendor => new VendorAI(this), AIType.AI_Mage => new MageAI(this), AIType.AI_Predator => - //m_AI = new PredatorAI(this); + // m_AI = new PredatorAI(this); new MeleeAI(this), AIType.AI_Thief => new ThiefAI(this), _ => null @@ -1767,7 +1757,7 @@ namespace Server.Mobiles return acqType switch { - FightMode.Strongest => (m.Skills.Tactics.Value + m.Str), //returns strongest mobile + FightMode.Strongest => m.Skills.Tactics.Value + m.Str, // returns strongest mobile FightMode.Weakest => -m.Hits, // returns weakest mobile _ => -GetDistanceToSqrt(m) }; @@ -1816,7 +1806,7 @@ namespace Server.Mobiles if (AIObject != null) { - if (!Core.ML || ct != OrderType.Follow && ct != OrderType.Stop && ct != OrderType.Stay) + if (!Core.ML || (ct != OrderType.Follow && ct != OrderType.Stop && ct != OrderType.Stay)) { AIObject.OnAggressiveAction(aggressor); } @@ -1841,7 +1831,7 @@ namespace Server.Mobiles } if (aggressor.ChangingCombatant && (m_Controlled || m_bSummoned) && - (ct == OrderType.Come || !Core.ML && ct == OrderType.Stay || ct == OrderType.Stop || ct == OrderType.None || + (ct == OrderType.Come || (!Core.ML && ct == OrderType.Stay) || ct == OrderType.Stop || ct == OrderType.None || ct == OrderType.Follow)) { ControlTarget = aggressor; @@ -1858,17 +1848,13 @@ namespace Server.Mobiles { if (m is BaseCreature creature && !creature.Controlled) return !Alive || !creature.Alive || IsDeadBondedPet || creature.IsDeadBondedPet || - Hidden && AccessLevel > AccessLevel.Player; - - #region Dueling + (Hidden && AccessLevel > AccessLevel.Player); if (Region.IsPartOf() && m is PlayerMobile pm && (pm.DuelContext?.Started != true || pm.DuelContext.Finished || pm.DuelPlayer?.Eliminated != false)) return true; - #endregion - return base.OnMoveOver(m); } @@ -1912,8 +1898,8 @@ namespace Server.Mobiles } public override bool HandlesOnSpeech(Mobile from) => - (SpeechType?.Flags & IHSFlags.OnSpeech) != 0 && from.InRange(this, 3) || - AIObject?.HandlesOnSpeech(from) == true && from.InRange(this, RangePerception); + ((SpeechType?.Flags & IHSFlags.OnSpeech) != 0 && from.InRange(this, 3)) || + (AIObject?.HandlesOnSpeech(from) == true && from.InRange(this, RangePerception)); public override void OnSpeech(SpeechEventArgs e) { @@ -1947,7 +1933,7 @@ namespace Server.Mobiles { base.DoHarmful(target, indirect); - if (target == this || target == m_ControlMaster || target == m_SummonMaster || !Controlled && !Summoned) + if (target == this || target == m_ControlMaster || target == m_SummonMaster || (!Controlled && !Summoned)) return; List list = Aggressors; @@ -2006,7 +1992,7 @@ namespace Server.Mobiles return true; // still idling } - if (95 > Utility.Random(100)) + if (Utility.Random(100) < 95) return false; // not idling, but don't want to enter idle state m_IdleReleaseTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(15, 25)); @@ -2058,7 +2044,7 @@ namespace Server.Mobiles public virtual void CheckedAnimate(int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay) { if (!Mounted) - base.Animate(action, frameCount, repeatCount, forward, repeat, delay); + this.Animate(action, frameCount, repeatCount, forward, repeat, delay); } private void CheckAIActive() @@ -2250,7 +2236,7 @@ namespace Server.Mobiles } else if (Controlled && Commandable) { - if (IsBonded) //Intentional difference (showing ONLY bonded when bonded instead of bonded & tame) + if (IsBonded) // Intentional difference (showing ONLY bonded when bonded instead of bonded & tame) list.Add(1049608); // (bonded) else list.Add(502006); // (tame) @@ -2297,7 +2283,7 @@ namespace Server.Mobiles { if (m_Paragon && Paragon.ChestChance > Utility.RandomDouble()) PackItem(new ParagonChest(Name, treasureLevel)); - else if ((Map == Map.Felucca || Map == Map.Trammel) && TreasureMap.LootChance >= Utility.RandomDouble()) + else if ((Map == Map.Felucca || Map == Map.Trammel) && Utility.RandomDouble() <= TreasureMap.LootChance) PackItem(new TreasureMap(treasureLevel, Map)); } @@ -2448,11 +2434,10 @@ namespace Server.Mobiles { rights[0].m_Damage = (int)(rights[0].m_Damage * - 1.25 - ); //This would be the first valid person attacking it. Gets a 25% bonus. Per 1/19/07 Five on Friday + 1.25); // This would be the first valid person attacking it. Gets a 25% bonus. Per 1/19/07 Five on Friday if (rights.Count > 1) - rights.Sort(); //Sort by damage + rights.Sort(); // Sort by damage int topDamage = rights[0].m_Damage; int minDamage; @@ -2479,16 +2464,11 @@ namespace Server.Mobiles public virtual void OnKilledBy(Mobile mob) { - #region Mondain's Legacy - if (GivesMLMinorArtifact) { if (MondainsLegacy.CheckArtifactChance(mob, this)) MondainsLegacy.GiveArtifactTo(mob); } - - #endregion - else if (m_Paragon) { if (Paragon.CheckArtifactChance(mob, this)) @@ -2691,7 +2671,7 @@ namespace Server.Mobiles if (target is BaseFactionGuard) 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 || target is TownCrier) { if (message) { @@ -2708,7 +2688,7 @@ namespace Server.Mobiles } public override bool CanBeRenamedBy(Mobile from) => - Controlled && from == ControlMaster && !from.Region.IsPartOf() || + (Controlled && from == ControlMaster && !from.Region.IsPartOf()) || base.CanBeRenamedBy(from); public bool SetControlMaster(Mobile m) @@ -2738,7 +2718,7 @@ namespace Server.Mobiles return false; } - CurrentWayPoint = null; //so tamed animals don't try to go back + CurrentWayPoint = null; // so tamed animals don't try to go back Home = Point3D.Zero; @@ -2826,7 +2806,7 @@ namespace Server.Mobiles { double min, max; - if (ChanceToRummage > Utility.RandomDouble() && Rummage()) + if (Utility.RandomDouble() < ChanceToRummage && Rummage()) { min = MinutesToNextRummageMin; max = MinutesToNextRummageMax; @@ -2841,8 +2821,7 @@ namespace Server.Mobiles m_NextRummageTime = tc + (int)TimeSpan.FromMinutes(delay).TotalMilliseconds; } - if (CanBreath && tc - m_NextBreathTime >= 0 - ) // tested: controlled dragons do breath fire, what about summoned skeletal dragons? + if (CanBreath && tc - m_NextBreathTime >= 0) // tested: controlled dragons do breath fire, what about summoned skeletal dragons? { Mobile target = Combatant; @@ -2927,7 +2906,7 @@ namespace Server.Mobiles { // *rummages through a corpse and takes an item* PublicOverheadMessage(MessageType.Emote, 0x3B2, 1008086); - //TODO: Instancing of Rummaged stuff. + // TODO: Instancing of Rummaged stuff. return true; } } @@ -2970,7 +2949,7 @@ namespace Server.Mobiles if (target is BaseCreature t) { - if (t.Unprovokable || t.IsParagon && BaseInstrument.GetBaseDifficulty(t) >= 160.0) + if (t.Unprovokable || (t.IsParagon && BaseInstrument.GetBaseDifficulty(t) >= 160.0)) return; t.BardProvoked = true; @@ -3029,7 +3008,7 @@ namespace Server.Mobiles foreach (Mobile m in master.GetMobilesInRange(3)) if (m is BaseCreature pet) - if (pet.Controlled && pet.ControlMaster == master && !onlyBonded || pet.IsBonded) + if ((pet.Controlled && pet.ControlMaster == master && !onlyBonded) || pet.IsBonded) if (pet.ControlOrder == OrderType.Guard || pet.ControlOrder == OrderType.Follow || pet.ControlOrder == OrderType.Come) move.Add(pet); @@ -3131,7 +3110,7 @@ namespace Server.Mobiles private class TameEntry : ContextMenuEntry { - private BaseCreature m_Mobile; + private readonly BaseCreature m_Mobile; public TameEntry(Mobile from, BaseCreature creature) : base(6130, 6) { @@ -3158,7 +3137,7 @@ namespace Server.Mobiles private class DeathAdderCharmTarget : Target { - private BaseCreature m_Charmed; + private readonly BaseCreature m_Charmed; public DeathAdderCharmTarget(BaseCreature charmed) : base(-1, false, TargetFlags.Harmful) => m_Charmed = charmed; @@ -3183,8 +3162,6 @@ namespace Server.Mobiles } } - #region Var declarations - private AIType m_CurrentAI; // The current AI private AIType m_DefaultAI; // The default AI @@ -3194,8 +3171,8 @@ namespace Server.Mobiles private Point3D m_Home; // The home position of the creature, used by some AI - private List m_SpellAttack; // List of attack spell/power - private List m_SpellDefense; // List of defensive spell/power + private readonly List m_SpellAttack; // List of attack spell/power + private readonly List m_SpellDefense; // List of defensive spell/power private bool m_Controlled; // Is controlled private Mobile m_ControlMaster; // My master @@ -3226,10 +3203,6 @@ namespace Server.Mobiles private int m_FailedReturnHome; /* return to home failure counter */ - #endregion - - #region ML Quest System - private List m_MLQuests; public List MLQuests @@ -3293,10 +3266,6 @@ namespace Server.Mobiles { } - #endregion - - #region Bonding - public const bool BondingEnabled = true; public virtual bool IsBondable => BondingEnabled && !Summoned; @@ -3337,17 +3306,13 @@ namespace Server.Mobiles } } - public bool IsDeadPet{ get; set; } + public bool IsDeadPet { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime BondingBegin{ get; set; } + public DateTime BondingBegin { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime OwnerAbandonTime{ get; set; } - - #endregion - - #region Delete Previously Tamed Timer + public DateTime OwnerAbandonTime { get; set; } private DeleteTimer m_DeleteTimer; @@ -3365,7 +3330,7 @@ namespace Server.Mobiles private class DeleteTimer : Timer { - private Mobile m; + private readonly Mobile m; public DeleteTimer(Mobile creature, TimeSpan delay) : base(delay) { @@ -3398,10 +3363,6 @@ namespace Server.Mobiles } } - #endregion - - #region Elemental Resistance/Damage - public override int BasePhysicalResistance => m_PhysicalResistance; public override int BaseFireResistance => m_FireResistance; public override int BaseColdResistance => m_ColdResistance; @@ -3464,29 +3425,25 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public int PhysicalDamage{ get; set; } = 100; + public int PhysicalDamage { get; set; } = 100; [CommandProperty(AccessLevel.GameMaster)] - public int FireDamage{ get; set; } + public int FireDamage { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ColdDamage{ get; set; } + public int ColdDamage { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int PoisonDamage{ get; set; } + public int PoisonDamage { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int EnergyDamage{ get; set; } + public int EnergyDamage { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ChaosDamage{ get; set; } + public int ChaosDamage { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int DirectDamage{ get; set; } - - #endregion - - #region Breath ability, like dragon fire breath + public int DirectDamage { get; set; } private long m_NextBreathTime; @@ -3650,10 +3607,6 @@ namespace Server.Mobiles return damage; } - #endregion - - #region Spill Acid - public void SpillAcid(int amount) { SpillAcid(null, amount); @@ -3661,7 +3614,7 @@ namespace Server.Mobiles public void SpillAcid(Mobile target, int amount) { - if (target != null && target.Map == null || Map == null) + if ((target != null && target.Map == null) || Map == null) return; for (int i = 0; i < amount; ++i) @@ -3689,13 +3642,9 @@ namespace Server.Mobiles public virtual Item NewHarmfulItem() => new PoolOfAcid(TimeSpan.FromSeconds(10), 30, 30); - #endregion - - #region Flee!!! - public virtual bool CanFlee => !m_Paragon; - public DateTime EndFleeTime{ get; set; } + public DateTime EndFleeTime { get; set; } public virtual void StopFlee() { @@ -3721,11 +3670,7 @@ namespace Server.Mobiles EndFleeTime = DateTime.UtcNow + maxDuration; } - #endregion - - #region Friends - - public List Friends{ get; private set; } + public List Friends { get; private set; } public virtual bool AllowNewPetFriend => Friends == null || Friends.Count < 5; @@ -3747,10 +3692,6 @@ namespace Server.Mobiles OppositionGroup?.IsEnemy(this, m) != true && m is BaseCreature c && m_Team == c.m_Team && (m_bSummoned || m_Controlled) == (c.m_bSummoned || c.m_Controlled); - #endregion - - #region Allegiance - public virtual Ethic EthicAllegiance => null; public enum Allegiance @@ -3786,10 +3727,6 @@ namespace Server.Mobiles return ethic == EthicAllegiance ? Allegiance.Ally : Allegiance.Enemy; } - #endregion - - #region Alter[...]Damage From/To - public virtual void AlterDamageScalarFrom(Mobile caster, ref double scalar) { } @@ -3814,26 +3751,22 @@ namespace Server.Mobiles { } - #endregion - - #region Food - - private static Type[] m_Eggs = + private static readonly Type[] m_Eggs = { typeof(FriedEggs), typeof(Eggs) }; - private static Type[] m_Fish = + private static readonly Type[] m_Fish = { typeof(FishSteak), typeof(RawFishSteak) }; - private static Type[] m_GrainsAndHay = + private static readonly Type[] m_GrainsAndHay = { typeof(BreadLoaf), typeof(FrenchBread), typeof(SheafOfHay) }; - private static Type[] m_Meat = + private static readonly Type[] m_Meat = { /* Cooked */ typeof(Bacon), typeof(CookedBird), typeof(Sausage), @@ -3849,7 +3782,7 @@ namespace Server.Mobiles typeof(Torso), typeof(RightArm), typeof(RightLeg) }; - private static Type[] m_FruitsAndVegies = + private static readonly Type[] m_FruitsAndVegies = { typeof(HoneydewMelon), typeof(YellowGourd), typeof(GreenGourd), typeof(Banana), typeof(Bananas), typeof(Lemon), typeof(Lime), @@ -3859,7 +3792,7 @@ namespace Server.Mobiles typeof(Onion), typeof(Lettuce), typeof(Pumpkin) }; - private static Type[] m_Gold = + private static readonly Type[] m_Gold = { // white wyrms eat gold.. typeof(Gold) @@ -3931,11 +3864,11 @@ namespace Server.Mobiles else { for (int i = 0; i < amount; ++i) - if (m_Loyalty < MaxLoyalty && 0.5 >= Utility.RandomDouble()) + if (m_Loyalty < MaxLoyalty && Utility.RandomDouble() <= 0.5) m_Loyalty += 10; } - /* if ( happier )*/ + /* if (happier )*/ // looks like in OSI pets say they are happier even if they are at maximum loyalty SayTo(from, 502060); // Your pet looks happier. @@ -3948,11 +3881,11 @@ namespace Server.Mobiles { Mobile master = m_ControlMaster; - if (master != null && master == from) //So friends can't start the bonding process + if (master != null && master == from) // So friends can't start the bonding process { if (MinTameSkill <= 29.1 || master.Skills.AnimalTaming.Base >= MinTameSkill || OverrideBondingReqs() || - Core.ML && master.Skills.AnimalTaming.Value >= MinTameSkill) + (Core.ML && master.Skills.AnimalTaming.Value >= MinTameSkill)) { if (BondingBegin == DateTime.MinValue) { @@ -3982,10 +3915,6 @@ namespace Server.Mobiles return false; } - #endregion - - #region OnAction[...] - public virtual void OnActionWander() { } @@ -4010,10 +3939,6 @@ namespace Server.Mobiles { } - #endregion - - #region Corpse Resources - public virtual int Feathers => 0; public virtual int Wool => 0; @@ -4026,10 +3951,6 @@ namespace Server.Mobiles public virtual int Scales => 0; public virtual ScaleType ScaleType => ScaleType.Red; - #endregion - - #region Teaching - public virtual bool CanTeach => false; public virtual bool CheckTeach(SkillName skill, Mobile from) @@ -4179,57 +4100,53 @@ namespace Server.Mobiles switch (res) { case TeachResult.KnowsMoreThanMe: - { - Say(501508); // I cannot teach thee, for thou knowest more than I! - break; - } + { + Say(501508); // I cannot teach thee, for thou knowest more than I! + break; + } case TeachResult.KnowsWhatIKnow: - { - Say(501509); // I cannot teach thee, for thou knowest all I can teach! - break; - } + { + Say(501509); // I cannot teach thee, for thou knowest all I can teach! + break; + } case TeachResult.NotEnoughFreePoints: case TeachResult.SkillNotRaisable: - { - // Make sure this skill is marked to raise. If you are near the skill cap (700 points) you may need to lose some points in another skill first. - m.SendLocalizedMessage(501510, "", 0x22); - break; - } + { + // Make sure this skill is marked to raise. If you are near the skill cap (700 points) you may need to lose some points in another skill first. + m.SendLocalizedMessage(501510, "", 0x22); + break; + } case TeachResult.Success: - { - if (doTeach) { - Say(501539); // Let me show thee something of how this is done. - m.SendLocalizedMessage(501540); // Your skill level increases. + if (doTeach) + { + Say(501539); // Let me show thee something of how this is done. + m.SendLocalizedMessage(501540); // Your skill level increases. - m_Teaching = (SkillName)(-1); + m_Teaching = (SkillName)(-1); - if (m is PlayerMobile mobile) - mobile.Learning = (SkillName)(-1); + if (m is PlayerMobile mobile) + mobile.Learning = (SkillName)(-1); + } + else + { + // I will teach thee all I know, if paid the amount in full. The price is: + Say(1019077, AffixType.Append, $" {pointsToLearn}", ""); + Say(1043108); // For less I shall teach thee less. + + m_Teaching = skill; + + if (m is PlayerMobile mobile) + mobile.Learning = skill; + } + + return true; } - else - { - // I will teach thee all I know, if paid the amount in full. The price is: - Say(1019077, AffixType.Append, $" {pointsToLearn}", ""); - Say(1043108); // For less I shall teach thee less. - - m_Teaching = skill; - - if (m is PlayerMobile mobile) - mobile.Learning = skill; - } - - return true; - } } return false; } - #endregion - - #region Set[...] - public void SetDamage(int val) { m_DamageMin = val; @@ -4435,12 +4352,6 @@ namespace Server.Mobiles }; } - #endregion - - #region Pack & Loot - - #region Mondain's Legacy - public void PackArcaneScroll(int min, int max) { PackArcaneScroll(Utility.RandomMinMax(min, max)); @@ -4460,8 +4371,6 @@ namespace Server.Mobiles PackItem(Loot.Construct(Loot.ArcanistScrollTypes)); } - #endregion - public void PackPotion() { PackItem(Loot.RandomPotion()); @@ -4477,7 +4386,7 @@ namespace Server.Mobiles public void PackNecroScroll(int index) { - if (!Core.AOS || 0.05 <= Utility.RandomDouble()) + if (!Core.AOS || Utility.RandomDouble() >= 0.05) return; PackItem(Loot.Construct(Loot.NecromancyScrollTypes, index)); @@ -4755,7 +4664,7 @@ namespace Server.Mobiles if (weapon == null) return false; - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) weapon.Slayer = SlayerName.Silver; weapon.DamageLevel = (WeaponDamageLevel)RandomMinMaxScaled(minLevel, maxLevel); @@ -4863,10 +4772,6 @@ namespace Server.Mobiles pack.DropItem(item); // failed, drop it anyway } - #endregion - - #region Healing - public virtual bool CanHeal => false; public virtual bool CanHealOwner => false; public virtual double HealScalar => 1.0; @@ -4893,14 +4798,14 @@ namespace Server.Mobiles { bool onSelf = patient == this; - //DoBeneficial( patient ); + // DoBeneficial( patient ); RevealingAction(); if (!onSelf) { patient.RevealingAction(); - patient.SendLocalizedMessage(1008078, false, Name); // : Attempting to heal you. + patient.SendLocalizedMessage(1008078, false, Name); // : Attempting to heal you. } double seconds = (onSelf ? HealDelay : HealOwnerDelay) + (patient.Alive ? 0.0 : 5.0); @@ -4973,8 +4878,9 @@ namespace Server.Mobiles StopHeal(); - if (onSelf && HealFully && Hits >= HealTrigger * HitsMax && Hits < HitsMax || !onSelf && HealOwnerFully && - patient.Hits >= HealOwnerTrigger * patient.HitsMax && patient.Hits < patient.HitsMax) + if ((onSelf && HealFully && Hits >= HealTrigger * HitsMax && Hits < HitsMax) || + (!onSelf && HealOwnerFully && patient.Hits >= HealOwnerTrigger * patient.HitsMax && + patient.Hits < patient.HitsMax)) HealStart(patient); } @@ -4990,10 +4896,6 @@ namespace Server.Mobiles patient.PlaySound(HealSound); } - #endregion - - #region Damaging Aura - private long m_NextAura; public virtual bool HasAura => false; @@ -5017,7 +4919,7 @@ namespace Server.Mobiles IEnumerable list = eable.Where(m => m != this && CanBeHarmful(m, false) && (Core.AOS || InLOS(m)) && - (m is BaseCreature bc && (bc.Controlled || bc.Summoned || bc.Team != Team) || m.Player)); + ((m is BaseCreature bc && (bc.Controlled || bc.Summoned || bc.Team != Team)) || m.Player)); foreach (Mobile m in list) { @@ -5032,13 +4934,11 @@ namespace Server.Mobiles public virtual void AuraEffect(Mobile m) { } - - #endregion } public class LoyaltyTimer : Timer { - private static TimeSpan InternalDelay = TimeSpan.FromMinutes(5.0); + private static readonly TimeSpan InternalDelay = TimeSpan.FromMinutes(5.0); private DateTime m_NextHourlyCheck; @@ -5119,8 +5019,8 @@ namespace Server.Mobiles } // added lines to check if a wild creature in a house region has to be removed or not - if (!c.Controlled && !c.IsStabled && (c.Region.IsPartOf() && c.CanBeDamaged() || - c.RemoveIfUntamed && c.Spawner == null)) + if (!c.Controlled && !c.IsStabled && ((c.Region.IsPartOf() && c.CanBeDamaged()) || + (c.RemoveIfUntamed && c.Spawner == null))) { c.RemoveStep++; diff --git a/Projects/Scripts/Mobiles/Familiars/BaseFamiliar.cs b/Projects/Scripts/Mobiles/Familiars/BaseFamiliar.cs index 931c4ca9c..1afe4a023 100644 --- a/Projects/Scripts/Mobiles/Familiars/BaseFamiliar.cs +++ b/Projects/Scripts/Mobiles/Familiars/BaseFamiliar.cs @@ -155,8 +155,8 @@ namespace Server.Mobiles private class ReleaseEntry : ContextMenuEntry { - private BaseFamiliar m_Familiar; - private Mobile m_From; + private readonly BaseFamiliar m_Familiar; + private readonly Mobile m_From; public ReleaseEntry(Mobile from, BaseFamiliar familiar) : base(6118, 14) { diff --git a/Projects/Scripts/Mobiles/Familiars/DeathAdder.cs b/Projects/Scripts/Mobiles/Familiars/DeathAdder.cs index ae9885aba..cc9610535 100644 --- a/Projects/Scripts/Mobiles/Familiars/DeathAdder.cs +++ b/Projects/Scripts/Mobiles/Familiars/DeathAdder.cs @@ -37,7 +37,7 @@ namespace Server.Mobiles public override string CorpseName => "a death adder corpse"; public override string DefaultName => "a death adder"; - public override Poison HitPoison => 0.8 >= Utility.RandomDouble() ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; public override void Serialize(IGenericWriter writer) { diff --git a/Projects/Scripts/Mobiles/Familiars/HordeMinion.cs b/Projects/Scripts/Mobiles/Familiars/HordeMinion.cs index 21cefdd1b..ce7687a1f 100644 --- a/Projects/Scripts/Mobiles/Familiars/HordeMinion.cs +++ b/Projects/Scripts/Mobiles/Familiars/HordeMinion.cs @@ -124,8 +124,6 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Pack Animal Methods - public override bool OnBeforeDeath() { if (!base.OnBeforeDeath()) @@ -175,7 +173,5 @@ namespace Server.Mobiles PackAnimal.GetContextMenuEntries(this, from, list); } - - #endregion } } diff --git a/Projects/Scripts/Mobiles/Guards/ArcherGuard.cs b/Projects/Scripts/Mobiles/Guards/ArcherGuard.cs index dd48d7dc0..6daf7f059 100644 --- a/Projects/Scripts/Mobiles/Guards/ArcherGuard.cs +++ b/Projects/Scripts/Mobiles/Guards/ArcherGuard.cs @@ -159,22 +159,22 @@ namespace Server.Mobiles switch (version) { case 0: - { - m_Focus = reader.ReadMobile(); - - if (m_Focus != null) { - m_AttackTimer = new AttackTimer(this); - m_AttackTimer.Start(); - } - else - { - m_IdleTimer = new IdleTimer(this); - m_IdleTimer.Start(); - } + m_Focus = reader.ReadMobile(); - break; - } + if (m_Focus != null) + { + m_AttackTimer = new AttackTimer(this); + m_AttackTimer.Start(); + } + else + { + m_IdleTimer = new IdleTimer(this); + m_IdleTimer.Start(); + } + + break; + } } } @@ -197,10 +197,9 @@ namespace Server.Mobiles private class AvengeTimer : Timer { - private Mobile m_Focus; + private readonly Mobile m_Focus; - public AvengeTimer(Mobile focus) : - base(TimeSpan.FromSeconds(2.5), TimeSpan.FromSeconds(1.0), + public AvengeTimer(Mobile focus) : base(TimeSpan.FromSeconds(2.5), TimeSpan.FromSeconds(1.0), 3) // After 2.5 seconds, one guard will spawn every 1.0 second, three times => m_Focus = focus; @@ -213,8 +212,8 @@ namespace Server.Mobiles private class AttackTimer : Timer { - private ArcherGuard m_Owner; - // private bool m_Shooting; + private readonly ArcherGuard m_Owner; + // private bool m_Shooting; public AttackTimer(ArcherGuard owner) : base(TimeSpan.FromSeconds(0.25), TimeSpan.FromSeconds(0.1)) => m_Owner = owner; @@ -277,48 +276,48 @@ namespace Server.Mobiles Stop(); } // - /*else if ( !m_Owner.InRange( target, 20 ) ) + /*else if (!m_Owner.InRange( target, 20 )) { m_Shooting = false; m_Owner.Focus = null; } - else if ( !m_Owner.InLOS( target ) ) + else if (!m_Owner.InLOS( target )) { m_Shooting = false; TeleportTo( target ); } - else if ( !m_Owner.CanSee( target ) ) + else if (!m_Owner.CanSee( target )) { m_Shooting = false; - if ( !m_Owner.InRange( target, 2 ) ) + if (!m_Owner.InRange( target, 2 )) { - if ( !m_Owner.Move( m_Owner.GetDirectionTo( target ) | Direction.Running ) && OutOfMaxDistance( target ) ) + if (!m_Owner.Move( m_Owner.GetDirectionTo( target ) | Direction.Running ) && OutOfMaxDistance( target )) TeleportTo( target ); } else { - if ( !m_Owner.UseSkill( SkillName.DetectHidden ) && Utility.Random( 50 ) == 0 ) + if (!m_Owner.UseSkill( SkillName.DetectHidden ) && Utility.Random( 50 ) == 0) m_Owner.Say( "Reveal!" ); } } else { - if ( m_Shooting && (TimeToSpare() || OutOfMaxDistance( target )) ) + if (m_Shooting && (TimeToSpare() || OutOfMaxDistance( target ))) m_Shooting = false; - else if ( !m_Shooting && InMinDistance( target ) ) + else if (!m_Shooting && InMinDistance( target )) m_Shooting = true; - if ( !m_Shooting ) + if (!m_Shooting) { - if ( m_Owner.InRange( target, 1 ) ) + if (m_Owner.InRange( target, 1 )) { - if ( !m_Owner.Move( (Direction)(m_Owner.GetDirectionTo( target ) - 4) | Direction.Running ) && OutOfMaxDistance( target ) ) // Too close, move away - TeleportTo( target ); + if (!m_Owner.Move( (Direction)(m_Owner.GetDirectionTo( target ) - 4) | Direction.Running ) && OutOfMaxDistance( target )) + TeleportTo( target ); // Too close, move away } - else if ( !m_Owner.InRange( target, 2 ) ) + else if (!m_Owner.InRange( target, 2 )) { - if ( !m_Owner.Move( m_Owner.GetDirectionTo( target ) | Direction.Running ) && OutOfMaxDistance( target ) ) + if (!m_Owner.Move( m_Owner.GetDirectionTo( target ) | Direction.Running ) && OutOfMaxDistance( target )) TeleportTo( target ); } } @@ -349,7 +348,7 @@ namespace Server.Mobiles private class IdleTimer : Timer { - private ArcherGuard m_Owner; + private readonly ArcherGuard m_Owner; private int m_Stage; public IdleTimer(ArcherGuard owner) : base(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.5)) => m_Owner = owner; diff --git a/Projects/Scripts/Mobiles/Guards/BaseGuard.cs b/Projects/Scripts/Mobiles/Guards/BaseGuard.cs index 32732424d..eae7a0abd 100644 --- a/Projects/Scripts/Mobiles/Guards/BaseGuard.cs +++ b/Projects/Scripts/Mobiles/Guards/BaseGuard.cs @@ -20,7 +20,7 @@ namespace Server.Mobiles { } - public abstract Mobile Focus{ get; set; } + public abstract Mobile Focus { get; set; } public static void Spawn(Mobile caller, Mobile target, int amount = 1, bool onlyAdditional = false) { diff --git a/Projects/Scripts/Mobiles/Guards/WarriorGuard.cs b/Projects/Scripts/Mobiles/Guards/WarriorGuard.cs index 069015ee2..96b3420cd 100644 --- a/Projects/Scripts/Mobiles/Guards/WarriorGuard.cs +++ b/Projects/Scripts/Mobiles/Guards/WarriorGuard.cs @@ -195,22 +195,22 @@ namespace Server.Mobiles switch (version) { case 0: - { - m_Focus = reader.ReadMobile(); - - if (m_Focus != null) { - m_AttackTimer = new AttackTimer(this); - m_AttackTimer.Start(); - } - else - { - m_IdleTimer = new IdleTimer(this); - m_IdleTimer.Start(); - } + m_Focus = reader.ReadMobile(); - break; - } + if (m_Focus != null) + { + m_AttackTimer = new AttackTimer(this); + m_AttackTimer.Start(); + } + else + { + m_IdleTimer = new IdleTimer(this); + m_IdleTimer.Start(); + } + + break; + } } } @@ -233,7 +233,7 @@ namespace Server.Mobiles private class AvengeTimer : Timer { - private Mobile m_Focus; + private readonly Mobile m_Focus; public AvengeTimer(Mobile focus) : base(TimeSpan.FromSeconds(2.5), TimeSpan.FromSeconds(1.0), 3) => m_Focus = focus; @@ -245,7 +245,7 @@ namespace Server.Mobiles private class AttackTimer : Timer { - private WarriorGuard m_Owner; + private readonly WarriorGuard m_Owner; public AttackTimer(WarriorGuard owner) : base(TimeSpan.FromSeconds(0.25), TimeSpan.FromSeconds(0.1)) => m_Owner = owner; @@ -308,22 +308,22 @@ namespace Server.Mobiles Stop(); } // - /*else if ( !m_Owner.InRange( target, 20 ) ) + /*else if (!m_Owner.InRange( target, 20 )) { m_Owner.Focus = null; } - else if ( !m_Owner.InRange( target, 10 ) || !m_Owner.InLOS( target ) ) + else if (!m_Owner.InRange( target, 10 ) || !m_Owner.InLOS( target )) { TeleportTo( target ); } - else if ( !m_Owner.InRange( target, 1 ) ) + else if (!m_Owner.InRange( target, 1 )) { - if ( !m_Owner.Move( m_Owner.GetDirectionTo( target ) | Direction.Running ) ) + if (!m_Owner.Move( m_Owner.GetDirectionTo( target ) | Direction.Running )) TeleportTo( target ); } - else if ( !m_Owner.CanSee( target ) ) + else if (!m_Owner.CanSee( target )) { - if ( !m_Owner.UseSkill( SkillName.DetectHidden ) && Utility.Random( 50 ) == 0 ) + if (!m_Owner.UseSkill( SkillName.DetectHidden ) && Utility.Random( 50 ) == 0) m_Owner.Say( "Reveal!" ); }*/ } @@ -346,7 +346,7 @@ namespace Server.Mobiles private class IdleTimer : Timer { - private WarriorGuard m_Owner; + private readonly WarriorGuard m_Owner; private int m_Stage; public IdleTimer(WarriorGuard owner) : base(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.5)) => m_Owner = owner; diff --git a/Projects/Scripts/Mobiles/Healers/BaseHealer.cs b/Projects/Scripts/Mobiles/Healers/BaseHealer.cs index 4e77852a4..3455dbe1f 100644 --- a/Projects/Scripts/Mobiles/Healers/BaseHealer.cs +++ b/Projects/Scripts/Mobiles/Healers/BaseHealer.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public abstract class BaseHealer : BaseVendor { - private static TimeSpan ResurrectDelay = TimeSpan.FromSeconds(2.0); + private static readonly TimeSpan ResurrectDelay = TimeSpan.FromSeconds(2.0); private DateTime m_NextResurrect; @@ -57,7 +57,7 @@ namespace Server.Mobiles { } - protected override List SBInfos{ get; } = new List(); + protected override List SBInfos { get; } = new List(); public override bool IsActiveVendor => false; public override bool IsInvulnerable => false; diff --git a/Projects/Scripts/Mobiles/Healers/PricedHealer.cs b/Projects/Scripts/Mobiles/Healers/PricedHealer.cs index a17871552..491d4660d 100644 --- a/Projects/Scripts/Mobiles/Healers/PricedHealer.cs +++ b/Projects/Scripts/Mobiles/Healers/PricedHealer.cs @@ -18,7 +18,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public int Price{ get; set; } + public int Price { get; set; } public override bool IsInvulnerable => true; @@ -59,10 +59,10 @@ namespace Server.Mobiles switch (version) { case 0: - { - Price = reader.ReadInt(); - break; - } + { + Price = reader.ReadInt(); + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs b/Projects/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs index 4b42772e3..1740f369c 100644 --- a/Projects/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs +++ b/Projects/Scripts/Mobiles/Monsters/AOS/DemonKnight.cs @@ -61,13 +61,13 @@ namespace Server.Mobiles public override string CorpseName => "a demon knight corpse"; public override bool IgnoreYoungProtection => Core.ML; - public static Type[] ArtifactRarity10{ get; } = + public static Type[] ArtifactRarity10 { get; } = { typeof(LegacyOfTheDreadLord), typeof(TheTaskmaster) }; - public static Type[] ArtifactRarity11{ get; } = + public static Type[] ArtifactRarity11 { get; } = { typeof(TheDragonSlayer), typeof(ArmorOfFortune), @@ -231,7 +231,7 @@ namespace Server.Mobiles MovingEffect(from, 0xECA, 10, 0, false, false, 0, 0); PlaySound(0x491); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) Timer.DelayCall(TimeSpan.FromSeconds(1.0), CreateBones_Callback, from); m_InHere = false; diff --git a/Projects/Scripts/Mobiles/Monsters/AOS/Impaler.cs b/Projects/Scripts/Mobiles/Monsters/AOS/Impaler.cs index 6619cffc2..20e8f4173 100644 --- a/Projects/Scripts/Mobiles/Monsters/AOS/Impaler.cs +++ b/Projects/Scripts/Mobiles/Monsters/AOS/Impaler.cs @@ -53,7 +53,7 @@ namespace Server.Mobiles public override bool Unprovokable => Core.SE; public override bool AreaPeaceImmune => Core.SE; public override Poison PoisonImmune => Poison.Lethal; - public override Poison HitPoison => 0.8 >= Utility.RandomDouble() ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; public override int TreasureMapLevel => 1; diff --git a/Projects/Scripts/Mobiles/Monsters/AOS/Revenant.cs b/Projects/Scripts/Mobiles/Monsters/AOS/Revenant.cs index 8eeed1cc8..86f5bf806 100644 --- a/Projects/Scripts/Mobiles/Monsters/AOS/Revenant.cs +++ b/Projects/Scripts/Mobiles/Monsters/AOS/Revenant.cs @@ -6,8 +6,8 @@ namespace Server.Mobiles { public class Revenant : BaseCreature { - private DateTime m_ExpireTime; - private Mobile m_Target; + private readonly DateTime m_ExpireTime; + private readonly Mobile m_Target; public Revenant(Mobile caster, Mobile target, TimeSpan duration) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.18, 0.36) diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/AntLion.cs b/Projects/Scripts/Mobiles/Monsters/Ants/AntLion.cs index 3bd8bad3a..bbbcc0b26 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/AntLion.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/AntLion.cs @@ -58,7 +58,6 @@ namespace Server.Mobiles // TODO: skeleton } - public AntLion(Serial serial) : base(serial) { } diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs index 2e5634914..469d86a03 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorQueen.cs @@ -39,7 +39,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(0.05 > Utility.RandomDouble() ? 16 : 4)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.05 ? 16 : 4)); } public BlackSolenInfiltratorQueen(Serial serial) : base(serial) diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs index c3623e01d..4d79e0dc5 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenInfiltratorWarrior.cs @@ -39,7 +39,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(0.05 > Utility.RandomDouble() ? 13 : 3)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.05 ? 13 : 3)); } public BlackSolenInfiltratorWarrior(Serial serial) : base(serial) diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenQueen.cs b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenQueen.cs index 5c0e41d2d..50d95d240 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenQueen.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenQueen.cs @@ -51,7 +51,7 @@ namespace Server.Mobiles } public override string CorpseName => "a solen queen corpse"; - public bool BurstSac{ get; private set; } + public bool BurstSac { get; private set; } public override string DefaultName => "a black solen queen"; @@ -122,10 +122,10 @@ namespace Server.Mobiles switch (version) { case 1: - { - BurstSac = reader.ReadBool(); - break; - } + { + BurstSac = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenWarrior.cs b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenWarrior.cs index 03b0e8cf8..f9cea7c5b 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/BlackSolenWarrior.cs @@ -40,7 +40,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(0.05 > Utility.RandomDouble() ? 13 : 3)); + PackItem(new ZoogiFungus(Utility.RandomDouble() < 0.05 ? 13 : 3)); if (Utility.RandomDouble() < 0.05) PackItem(new BraceletOfBinding()); @@ -51,7 +51,7 @@ namespace Server.Mobiles } public override string CorpseName => "a solen warrior corpse"; - public bool BurstSac{ get; private set; } + public bool BurstSac { get; private set; } public override string DefaultName => "a black solen warrior"; @@ -123,10 +123,10 @@ namespace Server.Mobiles switch (version) { case 1: - { - BurstSac = reader.ReadBool(); - break; - } + { + BurstSac = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs index 652fe9a1e..16f39054a 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorQueen.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(0.05 < Utility.RandomDouble() ? 4 : 16)); + PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 4 : 16)); } public RedSolenInfiltratorQueen(Serial serial) : base(serial) diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs index ecc12dea4..904b38ccb 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenInfiltratorWarrior.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(0.05 < Utility.RandomDouble() ? 3 : 13)); + PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 3 : 13)); } public RedSolenInfiltratorWarrior(Serial serial) : base(serial) diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenQueen.cs b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenQueen.cs index 0afcd3f75..e8487eec2 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenQueen.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenQueen.cs @@ -50,7 +50,7 @@ namespace Server.Mobiles } public override string CorpseName => "a solen queen corpse"; - public bool BurstSac{ get; private set; } + public bool BurstSac { get; private set; } public override string DefaultName => "a red solen queen"; @@ -69,7 +69,6 @@ namespace Server.Mobiles AddLoot(LootPack.Rich); } - public override bool IsEnemy(Mobile m) { if (SolenHelper.CheckRedFriendship(m)) @@ -122,10 +121,10 @@ namespace Server.Mobiles switch (version) { case 1: - { - BurstSac = reader.ReadBool(); - break; - } + { + BurstSac = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenWarrior.cs b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenWarrior.cs index 744b5db9a..b61a47f97 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/RedSolenWarrior.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles VirtualArmor = 35; SolenHelper.PackPicnicBasket(this); - PackItem(new ZoogiFungus(0.05 < Utility.RandomDouble() ? 3 : 13)); + PackItem(new ZoogiFungus(Utility.RandomDouble() > 0.05 ? 3 : 13)); if (Utility.RandomDouble() < 0.05) PackItem(new BraceletOfBinding()); @@ -49,7 +49,7 @@ namespace Server.Mobiles } public override string CorpseName => "a solen warrior corpse"; - public bool BurstSac{ get; private set; } + public bool BurstSac { get; private set; } public override string DefaultName => "a red solen warrior"; @@ -121,10 +121,10 @@ namespace Server.Mobiles switch (version) { case 1: - { - BurstSac = reader.ReadBool(); - break; - } + { + BurstSac = reader.ReadBool(); + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Monsters/Ants/SolenHelper.cs b/Projects/Scripts/Mobiles/Monsters/Ants/SolenHelper.cs index 1f69404d1..d7e741cb2 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ants/SolenHelper.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ants/SolenHelper.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public static void PackPicnicBasket(BaseCreature solen) { - if (1 > Utility.Random(100)) + if (Utility.Random(100) < 1) { PicnicBasket basket = new PicnicBasket(); diff --git a/Projects/Scripts/Mobiles/Monsters/Elemental/Magic/Efreet.cs b/Projects/Scripts/Mobiles/Monsters/Elemental/Magic/Efreet.cs index c4f6cf6b9..00cf15b53 100644 --- a/Projects/Scripts/Mobiles/Monsters/Elemental/Magic/Efreet.cs +++ b/Projects/Scripts/Mobiles/Monsters/Elemental/Magic/Efreet.cs @@ -54,7 +54,7 @@ namespace Server.Mobiles AddLoot(LootPack.Average); AddLoot(LootPack.Gems); - if (0.02 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.02) switch (Utility.Random(5)) { case 0: diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs index 13c7a96c3..35a5e6747 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Betrayer.cs @@ -46,7 +46,7 @@ namespace Server.Mobiles PackItem(new PowerCrystal()); - if (0.02 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.02) PackItem(new BlackthornWelcomeBook()); m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(5, 30)); @@ -71,11 +71,11 @@ namespace Server.Mobiles { base.OnDeath(c); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) { if (!IsParagon) { - if (0.75 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.75) c.DropItem(DawnsMusicGear.RandomCommon); else c.DropItem(DawnsMusicGear.RandomUncommon); @@ -104,7 +104,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (!m_Stunning && 0.3 > Utility.RandomDouble()) + if (!m_Stunning && Utility.RandomDouble() < 0.3) { m_Stunning = true; diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs index 02930ac38..89a35de22 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Gargoyle.cs @@ -36,7 +36,7 @@ namespace Server.Mobiles VirtualArmor = 32; - if (0.025 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.025) PackItem(new GargoylesPickaxe()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs index 398a7c425..1b441c471 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleDestroyer.cs @@ -40,7 +40,7 @@ namespace Server.Mobiles VirtualArmor = 50; - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new GargoylesPickaxe()); } @@ -65,7 +65,7 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile from) { - if (from?.Alive == true && 0.4 > Utility.RandomDouble()) + if (from?.Alive == true && Utility.RandomDouble() < 0.4) ThrowHatchet(from); } @@ -73,7 +73,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) + if (attacker?.Alive == true && attacker.Weapon is BaseRanged && Utility.RandomDouble() < 0.4) ThrowHatchet(attacker); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs index 3fbab03c8..f76ed6fd3 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GargoyleEnforcer.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles VirtualArmor = 50; - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new GargoylesPickaxe()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GolemController.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GolemController.cs index b5557f55c..6d402afe1 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GolemController.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/GolemController.cs @@ -46,7 +46,7 @@ namespace Server.Mobiles VirtualArmor = 16; - if (0.7 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.7) PackItem(new ArcaneGem()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Lich.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Lich.cs index 4cb3ccbde..cb022c95a 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Lich.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Lich.cs @@ -28,7 +28,6 @@ namespace Server.Mobiles SetResistance(ResistanceType.Poison, 55, 65); SetResistance(ResistanceType.Energy, 40, 50); - SetSkill(SkillName.Necromancy, 89, 99.1); SetSkill(SkillName.SpiritSpeak, 90.0, 99.0); diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs index 1dd8fbdaa..a54cbbd48 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/OrcishMage.cs @@ -38,10 +38,9 @@ namespace Server.Mobiles VirtualArmor = 30; - PackReg(6); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) PackItem(new OrcishKinMask()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs index 6bcfe7378..695667f40 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/RatmanMage.cs @@ -40,7 +40,7 @@ namespace Server.Mobiles PackReg(6); - if (0.02 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.02) PackStatue(); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs index 4e9efe2e1..6421c017f 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/SavageShaman.cs @@ -47,7 +47,7 @@ namespace Server.Mobiles PackReg(10, 15); PackItem(new Bandage(Utility.RandomMinMax(1, 15))); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) PackItem(new TribalBerry()); AddItem(new BoneArms()); @@ -109,7 +109,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) BeginSavageDance(); } @@ -151,116 +151,116 @@ namespace Server.Mobiles return; IPooledEnumerable eable = GetMobilesInRange(8); - + switch (Utility.Random(3)) { case 0: /* greater heal */ - { - foreach (Mobile m in eable) { - bool isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; + foreach (Mobile m in eable) + { + bool isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; - if (!isFriendly) - continue; + if (!isFriendly) + continue; - if (m.Poisoned || MortalStrike.IsWounded(m) || !CanBeBeneficial(m)) - continue; + if (m.Poisoned || MortalStrike.IsWounded(m) || !CanBeBeneficial(m)) + continue; - DoBeneficial(m); + DoBeneficial(m); - // Algorithm: (40% of magery) + (1-10) + // Algorithm: (40% of magery) + (1-10) - int toHeal = (int)(Skills.Magery.Value * 0.4); - toHeal += Utility.Random(1, 10); + int toHeal = (int)(Skills.Magery.Value * 0.4); + toHeal += Utility.Random(1, 10); - m.Heal(toHeal, this); + m.Heal(toHeal, this); - m.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist); - m.PlaySound(0x202); + m.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist); + m.PlaySound(0x202); + } + + break; } - - break; - } case 1: /* lightning */ - { - foreach (Mobile m in eable) { - bool isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; - - if (isFriendly) - continue; - - if (!CanBeHarmful(m)) - continue; - - DoHarmful(m); - - double damage; - - if (Core.AOS) + foreach (Mobile m in eable) { - int baseDamage = 6 + (int)(Skills.EvalInt.Value / 5.0); + bool isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; - damage = Utility.RandomMinMax(baseDamage, baseDamage + 3); - } - else - { - damage = Utility.Random(12, 9); + if (isFriendly) + continue; + + if (!CanBeHarmful(m)) + continue; + + DoHarmful(m); + + double damage; + + if (Core.AOS) + { + int baseDamage = 6 + (int)(Skills.EvalInt.Value / 5.0); + + damage = Utility.RandomMinMax(baseDamage, baseDamage + 3); + } + else + { + damage = Utility.Random(12, 9); + } + + m.BoltEffect(0); + + SpellHelper.Damage(TimeSpan.FromSeconds(0.25), m, this, damage, 0, 0, 0, 0, 100); } - m.BoltEffect(0); - - SpellHelper.Damage(TimeSpan.FromSeconds(0.25), m, this, damage, 0, 0, 0, 0, 100); + break; } - - break; - } case 2: /* poison */ - { - foreach (Mobile m in eable) { - bool isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; + foreach (Mobile m in eable) + { + bool isFriendly = m is Savage || m is SavageRider || m is SavageShaman || m is SavageRidgeback; - if (isFriendly) - continue; + if (isFriendly) + continue; - if (!CanBeHarmful(m)) - continue; + if (!CanBeHarmful(m)) + continue; - DoHarmful(m); + DoHarmful(m); - m.Spell?.OnCasterHurt(); + m.Spell?.OnCasterHurt(); - m.Paralyzed = false; + m.Paralyzed = false; - double total = Skills.Magery.Value + Skills.Poisoning.Value; + double total = Skills.Magery.Value + Skills.Poisoning.Value; - double dist = GetDistanceToSqrt(m); + double dist = GetDistanceToSqrt(m); - if (dist >= 3.0) - total -= (dist - 3.0) * 10.0; + if (dist >= 3.0) + total -= (dist - 3.0) * 10.0; - int level; + int level; - if (total >= 200.0 && Utility.Random(1, 100) <= 10) - level = 3; - else if (total > 170.0) - level = 2; - else if (total > 130.0) - level = 1; - else - level = 0; + if (total >= 200.0 && Utility.Random(1, 100) <= 10) + level = 3; + else if (total > 170.0) + level = 2; + else if (total > 130.0) + level = 1; + else + level = 0; - m.ApplyPoison(this, Poison.GetPoison(level)); + m.ApplyPoison(this, Poison.GetPoison(level)); - m.FixedParticles(0x374A, 10, 15, 5021, EffectLayer.Waist); - m.PlaySound(0x474); + m.FixedParticles(0x374A, 10, 15, 5021, EffectLayer.Waist); + m.PlaySound(0x474); + } + + break; } - - break; - } } - + eable.Free(); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs index d95848ad5..50252d175 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Magic/Succubus.cs @@ -61,8 +61,8 @@ namespace Server.Mobiles foreach (Mobile m in eable) { if (m == this || !CanBeHarmful(m) || - !(m.Player || m is BaseCreature creature && - (creature.Controlled || creature.Summoned || creature.Team != Team))) + !(m.Player || (m is BaseCreature creature && + (creature.Controlled || creature.Summoned || creature.Team != Team)))) continue; DoHarmful(m); @@ -70,7 +70,7 @@ namespace Server.Mobiles m.FixedParticles(0x374A, 10, 15, 5013, 0x496, 0, EffectLayer.Waist); m.PlaySound(0x231); - //m.SendMessage( "You feel the life drain out of you!" ); + // m.SendMessage( "You feel the life drain out of you!" ); int toDrain = Utility.RandomMinMax(10, 40); @@ -85,7 +85,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.1) DrainLife(); } @@ -93,7 +93,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (0.1 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.1) DrainLife(); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Cursed.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Cursed.cs index 67915525e..aa4c2e676 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Cursed.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Cursed.cs @@ -61,7 +61,7 @@ namespace Server.Mobiles public override void GenerateLoot() { AddLoot(LootPack.Meager); - //AddLoot( LootPack.Miscellaneous ); + // AddLoot( LootPack.Miscellaneous ); } public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs index 3c76151c0..3d32af64f 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/EnslavedGargoyle.cs @@ -33,7 +33,7 @@ namespace Server.Mobiles VirtualArmor = 35; - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new GargoylesPickaxe()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Guardian.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Guardian.cs index 9ec62091e..5639dae7f 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Guardian.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Guardian.cs @@ -46,7 +46,6 @@ namespace Server.Mobiles helm.Hue = 0x966; AddItem(helm); - Bow bow = new Bow(); bow.Movable = false; @@ -73,7 +72,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs index d49fd1864..98183e9be 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Juggernaut.cs @@ -13,7 +13,6 @@ namespace Server.Mobiles { Body = 768; - SetStr(301, 400); SetDex(51, 70); SetInt(51, 100); @@ -42,10 +41,10 @@ namespace Server.Mobiles VirtualArmor = 70; - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) PackItem(new PowerCrystal()); - if (0.4 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.4) PackItem(new ClockworkAssembly()); } @@ -68,11 +67,11 @@ namespace Server.Mobiles { base.OnDeath(c); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) { if (!IsParagon) { - if (0.75 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.75) c.DropItem(DawnsMusicGear.RandomCommon); else c.DropItem(DawnsMusicGear.RandomUncommon); @@ -100,7 +99,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (!m_Stunning && 0.3 > Utility.RandomDouble()) + if (!m_Stunning && Utility.RandomDouble() < 0.3) { m_Stunning = true; diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs index 4d1fc3a75..4076f48ec 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/KhaldunRevenant.cs @@ -7,10 +7,10 @@ namespace Server.Mobiles { public class KhaldunRevenant : BaseCreature { - private static HashSet m_Set = new HashSet(); - private DateTime m_ExpireTime; + private static readonly HashSet m_Set = new HashSet(); + private readonly DateTime m_ExpireTime; - private Mobile m_Target; + private readonly Mobile m_Target; public KhaldunRevenant(Mobile target) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.18, 0.36) { @@ -116,8 +116,8 @@ namespace Server.Mobiles return; } - //Combatant = m_Target; - //FocusMob = m_Target; + // Combatant = m_Target; + // FocusMob = m_Target; if (AIObject != null) AIObject.Action = ActionType.Combat; diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Orc.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Orc.cs index 89b1c3144..5aca5fbe8 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Orc.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Orc.cs @@ -74,7 +74,7 @@ namespace Server.Mobiles break; } - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new BolaBall()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs index a4df50363..725e2627c 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBomber.cs @@ -48,7 +48,7 @@ namespace Server.Mobiles PackItem(new MortarPestle()); PackItem(new LesserExplosionPotion()); - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new BolaBall()); } @@ -108,7 +108,7 @@ namespace Server.Mobiles m_Thrown++; - if (0.75 >= Utility.RandomDouble() && m_Thrown % 2 == 1) // 75% chance to quickly throw another bomb + if (Utility.RandomDouble() <= 0.75 && m_Thrown % 2 == 1) // 75% chance to quickly throw another bomb m_NextBomb = DateTime.UtcNow + TimeSpan.FromSeconds(3.0); else m_NextBomb = DateTime.UtcNow + TimeSpan.FromSeconds(5.0 + 10.0 * Utility.RandomDouble()); // 5-15 seconds @@ -138,7 +138,8 @@ namespace Server.Mobiles private class InternalTimer : Timer { - private Mobile m_Mobile, m_From; + private readonly Mobile m_Mobile; + private readonly Mobile m_From; public InternalTimer(Mobile m, Mobile from) : base(TimeSpan.FromSeconds(1.0)) { diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs index 57e58f5b0..85253d2ba 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcBrute.cs @@ -42,10 +42,10 @@ namespace Server.Mobiles PackItem(ore); PackItem(new IronIngot(10)); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) PackItem(new OrcishKinMask()); - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new BolaBall()); } @@ -113,7 +113,7 @@ namespace Server.Mobiles if (eable.Count() < 10) { - BaseCreature orc = new SpawnedOrcishLord{ Team = Team }; + BaseCreature orc = new SpawnedOrcishLord { Team = Team }; orc.MoveToWorld(map.GetRandomNearbyLocation(target.Location), map); orc.Combatant = target; diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs index 2a592f0c8..b99367d49 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/OrcishLord.cs @@ -56,10 +56,10 @@ namespace Server.Mobiles PackItem(new RingmailChest()); - if (0.3 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.3) PackItem(Loot.RandomPossibleReagent()); - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new BolaBall()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs index 19d317f9b..9bb89d76c 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/RestlessSoul.cs @@ -76,8 +76,7 @@ namespace Server.Mobiles public override bool IsEnemy(Mobile m) { - if (m is PlayerMobile player && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865 - ) // Schmendrick's cave + if (m is PlayerMobile player && Map == Map.Trammel && X >= 5199 && X <= 5271 && Y >= 1812 && Y <= 1865) // Schmendrick's cave { QuestSystem qs = player.Quest; diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Savage.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Savage.cs index 5708fb52b..d881dfcd2 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Savage.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/Savage.cs @@ -35,18 +35,18 @@ namespace Server.Mobiles PackItem(new Bandage(Utility.RandomMinMax(1, 15))); - if (Female && 0.1 > Utility.RandomDouble()) + if (Female && Utility.RandomDouble() < 0.1) PackItem(new TribalBerry()); - else if (!Female && 0.1 > Utility.RandomDouble()) + else if (!Female && Utility.RandomDouble() < 0.1) PackItem(new BolaBall()); AddItem(new Spear()); AddItem(new BoneArms()); AddItem(new BoneLegs()); - if (0.5 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.5) AddItem(new SavageMask()); - else if (0.1 > Utility.RandomDouble()) + else if (Utility.RandomDouble() < 0.1) AddItem(new OrcishKinMask()); } diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs index bfb30b38d..491111843 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/SavageRider.cs @@ -36,7 +36,7 @@ namespace Server.Mobiles PackItem(new Bandage(Utility.RandomMinMax(1, 15))); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) PackItem(new BolaBall()); AddItem(new TribalSpear()); diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs index 71cde62a6..a08e1de6c 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/ShadowFiend.cs @@ -100,7 +100,7 @@ namespace Server.Mobiles private class UnhideTimer : Timer { - private ShadowFiend m_Owner; + private readonly ShadowFiend m_Owner; public UnhideTimer(ShadowFiend owner) : base(TimeSpan.FromSeconds(30.0)) { diff --git a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs index dab7a20a4..242deb88b 100644 --- a/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs +++ b/Projects/Scripts/Mobiles/Monsters/Humanoid/Melee/StoneGargoyle.cs @@ -37,7 +37,7 @@ namespace Server.Mobiles PackItem(new IronIngot(12)); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) PackItem(new GargoylesPickaxe()); } diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs index 2f69edf50..f4df143e8 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusMinion.cs @@ -56,7 +56,7 @@ namespace Server.Mobiles } public override string CorpseName => "a minion's corpse"; - public bool FieldActive{ get; private set; } + public bool FieldActive { get; private set; } public bool CanUseField // TODO: an OSI bug prevents to verify this => Hits >= HitsMax * 9 / 10; @@ -100,7 +100,7 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile from) { - if (from?.Alive == true && 0.4 > Utility.RandomDouble()) SendEBolt(from); + if (from?.Alive == true && Utility.RandomDouble() < 0.4) SendEBolt(from); if (!FieldActive) { @@ -129,7 +129,7 @@ namespace Server.Mobiles attacker.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier"); } - if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) + if (attacker?.Alive == true && attacker.Weapon is BaseRanged && Utility.RandomDouble() < 0.4) SendEBolt(attacker); } diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs index c36e5e3ff..a77c61407 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Exodus/ExodusOverseer.cs @@ -47,7 +47,7 @@ namespace Server.Mobiles } public override string CorpseName => "an overseer's corpse"; - public bool FieldActive{ get; private set; } + public bool FieldActive { get; private set; } public bool CanUseField // TODO: an OSI bug prevents to verify this => Hits >= HitsMax * 9 / 10; @@ -90,7 +90,7 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile from) { - if (from?.Alive == true && 0.4 > Utility.RandomDouble()) SendEBolt(from); + if (from?.Alive == true && Utility.RandomDouble() < 0.4) SendEBolt(from); if (!FieldActive) { @@ -119,7 +119,7 @@ namespace Server.Mobiles attacker.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier"); } - if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble()) + if (attacker?.Alive == true && attacker.Weapon is BaseRanged && Utility.RandomDouble() < 0.4) SendEBolt(attacker); } diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs index 9ea475fd3..0a664ac58 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoon.cs @@ -23,11 +23,11 @@ namespace Server.Mobiles SetDamageType(ResistanceType.Cold, 25); SetDamageType(ResistanceType.Energy, 25); - //SetResistance( ResistanceType.Physical, 25, 38 ); - //SetResistance( ResistanceType.Fire, 25, 38 ); - //SetResistance( ResistanceType.Cold, 25, 38 ); - //SetResistance( ResistanceType.Poison, 25, 38 ); - //SetResistance( ResistanceType.Energy, 25, 38 ); + // SetResistance( ResistanceType.Physical, 25, 38 ); + // SetResistance( ResistanceType.Fire, 25, 38 ); + // SetResistance( ResistanceType.Cold, 25, 38 ); + // SetResistance( ResistanceType.Poison, 25, 38 ); + // SetResistance( ResistanceType.Energy, 25, 38 ); SetSkill(SkillName.Fencing, 77.6, 92.5); SetSkill(SkillName.Healing, 60.3, 90.0); @@ -146,7 +146,7 @@ namespace Server.Mobiles public override void GenerateLoot() { AddLoot(LootPack.Rich); - //AddLoot( LootPack.Gems ); + // AddLoot( LootPack.Gems ); } public override bool OnBeforeDeath() diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs index 631ac80bf..075811a83 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/ChaosDragoonElite.cs @@ -27,7 +27,6 @@ namespace Server.Mobiles SetResistance(ResistanceType.Poison, 25, 35); SetResistance(ResistanceType.Energy, 25, 35);*/ - SetSkill(SkillName.Tactics, 80.1, 100.0); SetSkill(SkillName.MagicResist, 100.1, 110.0); SetSkill(SkillName.Anatomy, 80.1, 100.0); diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs index eb9d2e6b5..99625e60c 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaLord.cs @@ -74,7 +74,7 @@ namespace Server.Mobiles public override void OnDamage(int amount, Mobile from, bool willKill) { - if (!willKill && amount > 5 && from?.Player == true && 5 > Utility.Random(100)) + if (!willKill && amount > 5 && from?.Player == true && Utility.Random(100) < 5) { string[] toSay = { diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs index 947930a50..b43475cc3 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Jukas/JukaWarrior.cs @@ -73,29 +73,29 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.2 < Utility.RandomDouble()) + if (Utility.RandomDouble() > 0.2) return; switch (Utility.Random(3)) { case 0: - { - defender.SendLocalizedMessage(1004014); // You have been stunned! - defender.Freeze(TimeSpan.FromSeconds(4.0)); - break; - } + { + defender.SendLocalizedMessage(1004014); // You have been stunned! + defender.Freeze(TimeSpan.FromSeconds(4.0)); + break; + } case 1: - { - defender.SendAsciiMessage("You have been hit by a paralyzing blow!"); - defender.Freeze(TimeSpan.FromSeconds(3.0)); - break; - } + { + defender.SendAsciiMessage("You have been hit by a paralyzing blow!"); + defender.Freeze(TimeSpan.FromSeconds(3.0)); + break; + } case 2: - { - AOS.Damage(defender, this, Utility.Random(10, 5), 100, 0, 0, 0, 0); - defender.SendAsciiMessage("You have been hit by a critical strike!"); - break; - } + { + AOS.Damage(defender, this, Utility.Random(10, 5), 100, 0, 0, 0, 0); + defender.SendAsciiMessage("You have been hit by a critical strike!"); + break; + } } } diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs index 52b289cf1..f408b5f09 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/EnragedCreatures.cs @@ -190,7 +190,6 @@ namespace Server.Mobiles given "come" command, ie they wander towards their summoner, but never actually "follow". */ - else if (!Combat(this)) { AIObject?.MoveTo(SummonMaster, false, 5); @@ -201,10 +200,9 @@ namespace Server.Mobiles is a player or controlled/summoned, and the summoner is not already engaged in combat. */ - else if (!Combat(SummonMaster)) { - if (Combatant.Player || Combatant is BaseCreature bc && (bc.Controlled || bc.SummonMaster != null)) + if (Combatant.Player || (Combatant is BaseCreature bc && (bc.Controlled || bc.SummonMaster != null))) SummonMaster.Combatant = Combatant; } else diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs index 1a6cea73b..2396e2554 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerCaptain.cs @@ -133,7 +133,7 @@ namespace Server.Mobiles if (!(m is MeerWarrior) || !IsFriend(m) || !CanBeBeneficial(m) || m.Hits >= m.HitsMax || m.Poisoned || MortalStrike.IsWounded(m)) continue; - + DoBeneficial(m); int toHeal = Utility.RandomMinMax(20, 30); @@ -145,7 +145,7 @@ namespace Server.Mobiles m.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist); m.PlaySound(0x202); } - + eable.Free(); } diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs index 4a9c6e611..c31bb1125 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerEternal.cs @@ -179,7 +179,7 @@ namespace Server.Mobiles case 3: DoAreaLeech(); break; - // TODO: Resurrect ability + // TODO: Resurrect ability } } } diff --git a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs index 3c801498d..bbef13b23 100644 --- a/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs +++ b/Projects/Scripts/Mobiles/Monsters/LBR/Meers/MeerMage.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class MeerMage : BaseCreature { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); private DateTime m_NextAbilityTime; @@ -121,7 +121,7 @@ namespace Server.Mobiles rabid.MoveToWorld(loc, combatant.Map); } - Say(1071932); //Creatures of the forest, I call to thee! Aid me in the fight against all that is evil! + Say(1071932); // Creatures of the forest, I call to thee! Aid me in the fight against all that is evil! } else if (combatant.Player) { diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs b/Projects/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs index 3e9fd25d4..2389b2c28 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Animal/CuSidhe.cs @@ -5,8 +5,7 @@ namespace Server.Mobiles public class CuSidhe : BaseMount { [Constructible] - public CuSidhe(string name = null) : - base(name, 277, 0x3E91, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) + public CuSidhe(string name = null) : base(name, 277, 0x3E91, AIType.AI_Animal, FightMode.Aggressor, 10, 1, 0.2, 0.4) { double chance = Utility.RandomDouble() * 23301; @@ -41,8 +40,8 @@ namespace Server.Mobiles SetSkill(SkillName.Anatomy, 65.5, 69.4); SetSkill(SkillName.Healing, 72.2, 98.9); - Fame = 5000; //Guessing here - Karma = 5000; //Guessing here + Fame = 5000; // Guessing here + Karma = 5000; // Guessing here Tamable = true; ControlSlots = 4; @@ -51,8 +50,8 @@ namespace Server.Mobiles if (Utility.RandomDouble() < 0.2) PackItem(new TreasureMap(5, Map.Trammel)); - //if ( Utility.RandomDouble() < 0.1 ) - //PackItem( new ParrotItem() ); + // if (Utility.RandomDouble() < 0.1) + // PackItem( new ParrotItem() ); PackGold(500, 800); diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Animal/Ferret.cs b/Projects/Scripts/Mobiles/Monsters/ML/Animal/Ferret.cs index 39d7d6bb8..cfba6c1d5 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Animal/Ferret.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Animal/Ferret.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Ferret : BaseCreature { - private static string[] m_Vocabulary = + private static readonly string[] m_Vocabulary = { "dook", "dook dook", @@ -77,11 +77,11 @@ namespace Server.Mobiles Say(m_Vocabulary[Utility.Random(m_Vocabulary.Length)]); if (to != null && Utility.RandomBool()) - Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 8)), delegate { to.Talk(); }); + Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(5, 8)), to.Talk); m_CanTalk = false; - Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(20, 30)), delegate { m_CanTalk = true; }); + Timer.DelayCall(TimeSpan.FromSeconds(Utility.RandomMinMax(20, 30)), () => { m_CanTalk = true; }); } } @@ -101,4 +101,4 @@ namespace Server.Mobiles m_CanTalk = true; } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Animal/RagingGrizzlyBear.cs b/Projects/Scripts/Mobiles/Monsters/ML/Animal/RagingGrizzlyBear.cs index 633c6753e..217c56223 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Animal/RagingGrizzlyBear.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Animal/RagingGrizzlyBear.cs @@ -30,8 +30,8 @@ namespace Server.Mobiles SetSkill(SkillName.MagicResist, 32.8, 54.6); SetSkill(SkillName.Anatomy, 0, 0); - Fame = 10000; //Guessing here - Karma = 10000; //Guessing here + Fame = 10000; // Guessing here + Karma = 10000; // Guessing here VirtualArmor = 24; diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs index 143655501..f22b7de50 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyJennifyr.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class LadyJennifyr : SkeletalKnight { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public LadyJennifyr() @@ -54,10 +54,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.15 ) + if (Utility.RandomDouble() < 0.15) c.DropItem( new DisintegratingThesisNotes() ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -107,8 +107,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; - private ResistanceMod m_Mod; + private readonly Mobile m_Mobile; + private readonly ResistanceMod m_Mod; public ExpireTimer(Mobile m, ResistanceMod mod) : base(TimeSpan.FromSeconds(10)) diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyMarai.cs b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyMarai.cs index 7a9ab59b9..01331aea4 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyMarai.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/LadyMarai.cs @@ -51,10 +51,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.15 ) + if (Utility.RandomDouble() < 0.15) c.DropItem( new DisintegratingThesisNotes() ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -82,4 +82,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs index f50f5df13..b639ebaba 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterJonath.cs @@ -62,10 +62,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.05 ) + if (Utility.RandomDouble() < 0.05) c.DropItem( new ParrotItem() ); - if ( Utility.RandomDouble() < 0.15 ) + if (Utility.RandomDouble() < 0.15) c.DropItem( new DisintegratingThesisNotes() ); } */ @@ -92,4 +92,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs index 15c63a9c8..8390de4d6 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/MasterMikael.cs @@ -61,10 +61,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.15 ) + if (Utility.RandomDouble() < 0.15) c.DropItem( new DisintegratingThesisNotes() ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -90,4 +90,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs index 027395517..8549a1908 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Bedlam/SirPatrick.cs @@ -51,10 +51,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.15 ) + if (Utility.RandomDouble() < 0.15) c.DropItem( new DisintegratingThesisNotes() ); - if ( Utility.RandomDouble() < 0.05 ) + if (Utility.RandomDouble() < 0.05) c.DropItem( new AssassinChest() ); } */ @@ -88,7 +88,7 @@ namespace Server.Mobiles foreach (Mobile m in GetMobilesInRange(2)) { - if (m == this || !CanBeHarmful(m, false) || Core.AOS && !InLOS(m)) + if (m == this || !CanBeHarmful(m, false) || (Core.AOS && !InLOS(m))) continue; if (m is BaseCreature bc) @@ -130,4 +130,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Coil.cs b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Coil.cs index 430c824d4..1e7e8dfef 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Coil.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Coil.cs @@ -71,7 +71,7 @@ namespace Server.Mobiles /* // TODO: uncomment once added - if ( Utility.RandomDouble() < 0.025 ) + if (Utility.RandomDouble() < 0.025) { switch ( Utility.Random( 5 ) ) { @@ -99,4 +99,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/EnslavedSatyr.cs b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/EnslavedSatyr.cs index bcf587886..15b8d53e1 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/EnslavedSatyr.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/EnslavedSatyr.cs @@ -13,7 +13,7 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -40,4 +40,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Hydra.cs b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Hydra.cs index f319f09e0..593f54002 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Hydra.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Hydra.cs @@ -65,10 +65,10 @@ namespace Server.Mobiles /* // TODO: uncomment once added - if ( Utility.RandomDouble() < 0.2 ) + if (Utility.RandomDouble() < 0.2) c.DropItem( new ParrotItem() ); - if ( Utility.RandomDouble() < 0.05 ) + if (Utility.RandomDouble() < 0.05) c.DropItem( new ThorvaldsMedallion() ); */ } @@ -87,4 +87,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/InsaneDryad.cs b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/InsaneDryad.cs index 8b2a0a521..371008609 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/InsaneDryad.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/InsaneDryad.cs @@ -14,7 +14,7 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -43,4 +43,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Saliva.cs b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Saliva.cs index 8f98dbb3d..a9be02a19 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Saliva.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Blighted Grove/Saliva.cs @@ -55,8 +55,8 @@ namespace Server.Mobiles c.DropItem(new SalivasFeather()); // TODO: uncomment once added - //if ( Utility.RandomDouble() < 0.1 ) - // c.DropItem( new ParrotItem() ); + // if (Utility.RandomDouble() < 0.1) + // c.DropItem( new ParrotItem() ); } public override void Serialize(IGenericWriter writer) @@ -73,4 +73,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs index a233e5f3e..b18eee9ca 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/MLDryad.cs @@ -86,13 +86,11 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Area Peace - private DateTime m_NextPeace; public void AreaPeace() { - if (Combatant == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || 0.1 < Utility.RandomDouble()) + if (Combatant == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || Utility.RandomDouble() > 0.1) return; TimeSpan duration = TimeSpan.FromSeconds(Utility.RandomMinMax(20, 80)); @@ -118,15 +116,11 @@ namespace Server.Mobiles m?.PeacedUntil < DateTime.UtcNow && !m.Hidden && m.AccessLevel == AccessLevel.Player && CanBeHarmful(m); - #endregion - - #region Undress - private DateTime m_NextUndress; public void AreaUndress() { - if (Combatant == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || 0.005 < Utility.RandomDouble()) + if (Combatant == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || Utility.RandomDouble() > 0.005) return; foreach (Mobile m in GetMobilesInRange(RangePerception)) @@ -153,7 +147,5 @@ namespace Server.Mobiles if (item?.Movable == true) m.PlaceInBackpack(item); } - - #endregion } } diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs index 61dedc07f..089d7ffb4 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Magic/Satyr.cs @@ -79,13 +79,11 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Peace - private DateTime m_NextPeace; public void Peace(Mobile target) { - if (target == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || 0.1 < Utility.RandomDouble()) + if (target == null || Deleted || !Alive || m_NextPeace > DateTime.UtcNow || Utility.RandomDouble() > 0.1) return; if (target is PlayerMobile p && p.PeacedUntil < DateTime.UtcNow && !p.Hidden && CanBeHarmful(p)) @@ -101,17 +99,13 @@ namespace Server.Mobiles m_NextPeace = DateTime.UtcNow + TimeSpan.FromSeconds(10); } - #endregion - - #region Suppress - - private static Dictionary m_Suppressed = new Dictionary(); + private static readonly Dictionary m_Suppressed = new Dictionary(); private DateTime m_NextSuppress; public void Suppress(Mobile target) { if (target == null || m_Suppressed.ContainsKey(target) || Deleted || !Alive || - m_NextSuppress > DateTime.UtcNow || 0.1 < Utility.RandomDouble()) + m_NextSuppress > DateTime.UtcNow || Utility.RandomDouble() > 0.1) return; TimeSpan delay = TimeSpan.FromSeconds(Utility.RandomMinMax(20, 80)); @@ -155,7 +149,7 @@ namespace Server.Mobiles private class AnimateTimer : Timer { private int m_Count; - private Mobile m_Owner; + private readonly Mobile m_Owner; public AnimateTimer(Mobile owner, int count) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.25)) { @@ -172,15 +166,11 @@ namespace Server.Mobiles } } - #endregion - - #region Undress - private DateTime m_NextUndress; public void Undress(Mobile target) { - if (target == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || 0.005 < Utility.RandomDouble()) + if (target == null || Deleted || !Alive || m_NextUndress > DateTime.UtcNow || Utility.RandomDouble() > 0.005) return; if (target.Player && target.Female && !target.Hidden && CanBeHarmful(target)) @@ -206,15 +196,11 @@ namespace Server.Mobiles m.PlaceInBackpack(item); } - #endregion - - #region Provoke - private DateTime m_NextProvoke; public void Provoke(Mobile target) { - if (target == null || Deleted || !Alive || m_NextProvoke > DateTime.UtcNow || 0.05 < Utility.RandomDouble()) + if (target == null || Deleted || !Alive || m_NextProvoke > DateTime.UtcNow || Utility.RandomDouble() > 0.05) return; foreach (Mobile m in GetMobilesInRange(RangePerception)) @@ -235,7 +221,5 @@ namespace Server.Mobiles m_NextProvoke = DateTime.UtcNow + TimeSpan.FromSeconds(10); } - - #endregion } } diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/FerelTreefellow.cs b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/FerelTreefellow.cs index 3e611535d..11c221234 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/FerelTreefellow.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/FerelTreefellow.cs @@ -29,8 +29,8 @@ namespace Server.Mobiles SetSkill(SkillName.Tactics, 65.1, 90.0); // Unknown SetSkill(SkillName.Wrestling, 65.1, 85.0); // Unknown - Fame = 12500; //Unknown - Karma = 12500; //Unknown + Fame = 12500; // Unknown + Karma = 12500; // Unknown VirtualArmor = 24; PackItem(new Log(Utility.RandomMinMax(23, 34))); @@ -58,7 +58,7 @@ namespace Server.Mobiles public override void GenerateLoot() { - AddLoot(LootPack.Average); //Unknown + AddLoot(LootPack.Average); // Unknown } public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/MinotaurScout.cs b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/MinotaurScout.cs index 05834d0bd..5c03aeefa 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/MinotaurScout.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/MinotaurScout.cs @@ -25,10 +25,10 @@ namespace Server.Mobiles SetResistance(ResistanceType.Poison, 30, 40); SetResistance(ResistanceType.Energy, 30, 40); - //SetSkill( SkillName.Meditation, Unknown ); - //SetSkill( SkillName.EvalInt, Unknown ); - //SetSkill( SkillName.Magery, Unknown ); - //SetSkill( SkillName.Poisoning, Unknown ); + // SetSkill( SkillName.Meditation, Unknown ); + // SetSkill( SkillName.EvalInt, Unknown ); + // SetSkill( SkillName.Magery, Unknown ); + // SetSkill( SkillName.Poisoning, Unknown ); SetSkill(SkillName.Anatomy, 0); SetSkill(SkillName.MagicResist, 60.6, 67.5); SetSkill(SkillName.Tactics, 86.9, 103.6); diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/Tormented Minotaur.cs b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/Tormented Minotaur.cs index 5aa821294..2f921a8df 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/Tormented Minotaur.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Humanoid/Melee/Tormented Minotaur.cs @@ -29,7 +29,6 @@ namespace Server.Mobiles SetSkill(SkillName.Tactics, 100.7, 102.8); SetSkill(SkillName.MagicResist, 104.3, 116.3); - Fame = 20000; Karma = -20000; } diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Labyrinth/Miasma.cs b/Projects/Scripts/Mobiles/Monsters/ML/Labyrinth/Miasma.cs index 351d027a7..278785c59 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Labyrinth/Miasma.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Labyrinth/Miasma.cs @@ -45,7 +45,7 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.025 ) + if (Utility.RandomDouble() < 0.025) { switch ( Utility.Random( 16 ) ) { @@ -107,4 +107,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Misc/Melee/CorrosiveSlime.cs b/Projects/Scripts/Mobiles/Monsters/ML/Misc/Melee/CorrosiveSlime.cs index e51043334..9b83a1650 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Misc/Melee/CorrosiveSlime.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Misc/Melee/CorrosiveSlime.cs @@ -39,7 +39,7 @@ namespace Server.Mobiles MinTameSkill = 23.1; } - //TODO: Damage weapon via acid + // TODO: Damage weapon via acid public CorrosiveSlime(Serial serial) : base(serial) { diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Painted Caves/Grobu.cs b/Projects/Scripts/Mobiles/Monsters/ML/Painted Caves/Grobu.cs index eb5f2c38d..355978c19 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Painted Caves/Grobu.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Painted Caves/Grobu.cs @@ -55,7 +55,6 @@ namespace Server.Mobiles AddLoot(LootPack.FilthyRich, 2); } - public override void OnDeath(Container c) { base.OnDeath(c); diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Palace of Paroxysmus/Putrefier.cs b/Projects/Scripts/Mobiles/Monsters/ML/Palace of Paroxysmus/Putrefier.cs index 0ee022833..e53c78820 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Palace of Paroxysmus/Putrefier.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Palace of Paroxysmus/Putrefier.cs @@ -60,7 +60,7 @@ namespace Server.Mobiles c.DropItem( new SpleenOfThePutrefier() ); - if ( Utility.RandomDouble() < 0.6 ) + if (Utility.RandomDouble() < 0.6) c.DropItem( new ParrotItem() ); } */ @@ -88,4 +88,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalDaemon.cs b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalDaemon.cs index 91056c6c4..9af8f3240 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalDaemon.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalDaemon.cs @@ -47,7 +47,7 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.4 ) + if (Utility.RandomDouble() < 0.4) c.DropItem( new ScatteredCrystals() ); } */ @@ -79,4 +79,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs index 0a1b9e2bc..7b08a6b1f 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalLatticeSeeker.cs @@ -53,10 +53,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.75 ) + if (Utility.RandomDouble() < 0.75) c.DropItem( new CrystallineFragments() ); - if ( Utility.RandomDouble() < 0.07 ) + if (Utility.RandomDouble() < 0.07) c.DropItem( new PiecesOfCrystal() ); } */ @@ -68,7 +68,7 @@ namespace Server.Mobiles { AddLoot(LootPack.FilthyRich, 4); // TODO: uncomment once added - //AddLoot( LootPack.Parrot ); + // AddLoot( LootPack.Parrot ); AddLoot(LootPack.Gems); } @@ -95,35 +95,35 @@ namespace Server.Mobiles switch (Utility.Random(3)) { case 0: - { - Say(1042156); // I can grant life, and I can sap it as easily. - PlaySound(0x1E6); + { + Say(1042156); // I can grant life, and I can sap it as easily. + PlaySound(0x1E6); - toDrain = Utility.RandomMinMax(3, 6); - Hits += toDrain; - m.Hits -= toDrain; - break; - } + toDrain = Utility.RandomMinMax(3, 6); + Hits += toDrain; + m.Hits -= toDrain; + break; + } case 1: - { - Say(1042157); // You'll go nowhere, unless I deem it should be so. - PlaySound(0x1DF); + { + Say(1042157); // You'll go nowhere, unless I deem it should be so. + PlaySound(0x1DF); - toDrain = Utility.RandomMinMax(10, 25); - Stam += toDrain; - m.Stam -= toDrain; - break; - } + toDrain = Utility.RandomMinMax(10, 25); + Stam += toDrain; + m.Stam -= toDrain; + break; + } case 2: - { - Say(1042155); // Your power is mine to use as I will. - PlaySound(0x1F8); + { + Say(1042155); // Your power is mine to use as I will. + PlaySound(0x1F8); - toDrain = Utility.RandomMinMax(15, 25); - Mana += toDrain; - m.Mana -= toDrain; - break; - } + toDrain = Utility.RandomMinMax(15, 25); + Mana += toDrain; + m.Mana -= toDrain; + break; + } } } @@ -151,4 +151,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalSeaSerpent.cs b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalSeaSerpent.cs index d3dd53054..ba761e1b1 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalSeaSerpent.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalSeaSerpent.cs @@ -32,13 +32,13 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.05 ) + if (Utility.RandomDouble() < 0.05) c.DropItem( new CrushedCrystals() ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new IcyHeart() ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new LuckyDagger() ); } */ @@ -65,4 +65,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalVortex.cs b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalVortex.cs index 85fb9d9db..94947837b 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalVortex.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/CrystalVortex.cs @@ -51,7 +51,7 @@ namespace Server.Mobiles { AddLoot(LootPack.FilthyRich, 2); // TODO: uncomment once added - //AddLoot( LootPack.Parrot ); + // AddLoot( LootPack.Parrot ); } /* @@ -60,10 +60,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.75 ) + if (Utility.RandomDouble() < 0.75) c.DropItem( new CrystallineFragments() ); - if ( Utility.RandomDouble() < 0.06 ) + if (Utility.RandomDouble() < 0.06) c.DropItem( new JaggedCrystals() ); } */ @@ -86,4 +86,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/Protector.cs b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/Protector.cs index baed7d624..af565ce7f 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/Protector.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/Protector.cs @@ -85,7 +85,7 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.4 ) + if (Utility.RandomDouble() < 0.4) c.DropItem( new ProtectorsEssence() ); } */ @@ -104,4 +104,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/UnfrozenMummy.cs b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/UnfrozenMummy.cs index 18f7aa1a6..19c7da547 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/UnfrozenMummy.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Prism of Light/UnfrozenMummy.cs @@ -47,10 +47,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.6 ) + if (Utility.RandomDouble() < 0.6) c.DropItem( new BrokenCrystals() ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -67,7 +67,7 @@ namespace Server.Mobiles { AddLoot(LootPack.UltraRich, 2); // TODO: uncomment once added - //AddLoot( LootPack.Parrot ); + // AddLoot( LootPack.Parrot ); } public override void Serialize(IGenericWriter writer) @@ -84,4 +84,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs b/Projects/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs index 65e7e280c..4b17e58bc 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Special/Ilhenir.cs @@ -9,7 +9,7 @@ namespace Server.Mobiles { public class Ilhenir : BaseChampion { - private static HashSet m_Table = new HashSet(); + private static readonly HashSet m_Table = new HashSet(); [Constructible] public Ilhenir() @@ -92,7 +92,7 @@ namespace Server.Mobiles public override Poison PoisonImmune => Poison.Lethal; - //public override bool GivesMLMinorArtifact => true; // TODO: Needs verification + // public override bool GivesMLMinorArtifact => true; // TODO: Needs verification public override int TreasureMapLevel => 5; public virtual void PackResources(int amount) @@ -149,7 +149,7 @@ namespace Server.Mobiles c.DropItem(new GrizzledBones()); // TODO: Parrots - /*if ( Utility.RandomDouble() < 0.6 ) + /*if (Utility.RandomDouble() < 0.6) c.DropItem( new ParrotItem() ); */ if (Utility.RandomDouble() < 0.05) @@ -159,7 +159,7 @@ namespace Server.Mobiles c.DropItem(new CrimsonCincture()); // TODO: Armor sets - /*if ( Utility.RandomDouble() < 0.05 ) + /*if (Utility.RandomDouble() < 0.05) { switch ( Utility.Random(5) ) { @@ -303,7 +303,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public bool Corrosive{ get; set; } + public bool Corrosive { get; set; } public override void OnAfterDelete() { diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs b/Projects/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs index a905126af..458563b7a 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Special/Meraktus.cs @@ -31,10 +31,10 @@ namespace Server.Mobiles SetResistance(ResistanceType.Poison, 40, 60); SetResistance(ResistanceType.Energy, 50, 55); - //SetSkill( SkillName.Meditation, Unknown ); - //SetSkill( SkillName.EvalInt, Unknown ); - //SetSkill( SkillName.Magery, Unknown ); - //SetSkill( SkillName.Poisoning, Unknown ); + // SetSkill( SkillName.Meditation, Unknown ); + // SetSkill( SkillName.EvalInt, Unknown ); + // SetSkill( SkillName.Magery, Unknown ); + // SetSkill( SkillName.Poisoning, Unknown ); SetSkill(SkillName.Anatomy, 0); SetSkill(SkillName.MagicResist, 107.0, 111.3); SetSkill(SkillName.Tactics, 107.0, 117.0); @@ -169,7 +169,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.2 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.2) Earthquake(); } @@ -179,8 +179,8 @@ namespace Server.Mobiles foreach (Mobile m in eable) { - if (m == this || !CanBeHarmful(m) || m.Deleted || !m.Player && - !(m is BaseCreature creature && (creature.Controlled || creature.Summoned || creature.Team != Team))) + if (m == this || !CanBeHarmful(m) || m.Deleted || (!m.Player && + !(m is BaseCreature creature && (creature.Controlled || creature.Summoned || creature.Team != Team)))) continue; if (m is PlayerMobile pm && pm.Mounted) @@ -212,8 +212,6 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region SpawnHelpers - public void SpawnTormented() { BaseCreature spawna = new TormentedMinotaur(); @@ -228,7 +226,5 @@ namespace Server.Mobiles BaseCreature spawnd = new TormentedMinotaur(); spawnd.MoveToWorld(Location, Map); } - - #endregion } } diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Special/Twaulo.cs b/Projects/Scripts/Mobiles/Monsters/ML/Special/Twaulo.cs index 9ee21f37e..6abdc6093 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Special/Twaulo.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Special/Twaulo.cs @@ -101,7 +101,7 @@ namespace Server.Mobiles public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) { - if (0.1 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.1) SpawnPixies(caster); } @@ -118,7 +118,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (0.1 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.1) SpawnPixies(attacker); } diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Gnaw.cs b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Gnaw.cs index d5c1e193f..2fce7af3e 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Gnaw.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Gnaw.cs @@ -41,7 +41,7 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.3 ) + if (Utility.RandomDouble() < 0.3) c.DropItem( new GnawsFang() ); } */ @@ -77,4 +77,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Irk.cs b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Irk.cs index bb6240106..06a5a3885 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Irk.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Irk.cs @@ -42,10 +42,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.25 ) + if (Utility.RandomDouble() < 0.25) c.DropItem( new IrksBrain() ); - if ( Utility.RandomDouble() < 0.025 ) + if (Utility.RandomDouble() < 0.025) c.DropItem( new PaladinGloves() ); } */ @@ -82,4 +82,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadyLissith.cs b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadyLissith.cs index 3a8255eff..3547410a1 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadyLissith.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadyLissith.cs @@ -52,13 +52,13 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.025 ) + if (Utility.RandomDouble() < 0.025) c.DropItem( new GreymistChest() ); - if ( Utility.RandomDouble() < 0.45 ) + if (Utility.RandomDouble() < 0.45) c.DropItem( new LissithsSilk() ); - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -86,4 +86,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadySabrix.cs b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadySabrix.cs index c5a538224..16687a6d7 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadySabrix.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/LadySabrix.cs @@ -52,10 +52,10 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.2 ) + if (Utility.RandomDouble() < 0.2) c.DropItem( new SabrixsEye() ); - if ( Utility.RandomDouble() < 0.25 ) + if (Utility.RandomDouble() < 0.25) { switch ( Utility.Random( 2 ) ) { @@ -64,7 +64,7 @@ namespace Server.Mobiles } } - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -92,4 +92,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Malefic.cs b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Malefic.cs index b7d760630..d266ef1a1 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Malefic.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Malefic.cs @@ -41,7 +41,7 @@ namespace Server.Mobiles /* // TODO: uncomment once added - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) PackItem( new ParrotItem() ); */ } @@ -77,4 +77,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs index bb0c46c45..a028dacff 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Swoop.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Swoop : Eagle { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public Swoop() @@ -48,13 +48,13 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.025 ) + if (Utility.RandomDouble() < 0.025) { switch ( Utility.Random( 18 ) ) { case 0: c.DropItem( new AssassinChest() ); break; case 1: c.DropItem( new AssassinArms() ); break; - case 2: c.DropItem( new DeathChest() ); break; + case 2: c.DropItem( new DeathChest() ); break; case 3: c.DropItem( new MyrmidonArms() ); break; case 4: c.DropItem( new MyrmidonLegs() ); break; case 5: c.DropItem( new MyrmidonGorget() ); break; @@ -73,7 +73,7 @@ namespace Server.Mobiles } } - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -100,7 +100,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.1) return; if (m_Table.TryGetValue(defender, out ExpireTimer timer)) @@ -142,8 +142,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; - private ResistanceMod m_Mod; + private readonly Mobile m_Mobile; + private readonly ResistanceMod m_Mod; public ExpireTimer(Mobile m, ResistanceMod mod, TimeSpan delay) : base(delay) diff --git a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Virulent.cs b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Virulent.cs index a74aee986..4dfc129de 100644 --- a/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Virulent.cs +++ b/Projects/Scripts/Mobiles/Monsters/ML/Twisted Weald/Virulent.cs @@ -54,7 +54,7 @@ namespace Server.Mobiles { base.OnDeath( c ); - if ( Utility.RandomDouble() < 0.025 ) + if (Utility.RandomDouble() < 0.025) { switch ( Utility.Random( 2 ) ) { @@ -63,7 +63,7 @@ namespace Server.Mobiles } } - if ( Utility.RandomDouble() < 0.1 ) + if (Utility.RandomDouble() < 0.1) c.DropItem( new ParrotItem() ); } */ @@ -91,4 +91,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs index 404c3f1d3..273058914 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Magic/EtherealWarrior.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class EtherealWarrior : BaseCreature { - private static TimeSpan ResurrectDelay = TimeSpan.FromSeconds(2.0); + private static readonly TimeSpan ResurrectDelay = TimeSpan.FromSeconds(2.0); private DateTime m_NextResurrect; diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Magic/Pixie.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Magic/Pixie.cs index ea17ee201..569cc61c9 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Magic/Pixie.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Magic/Pixie.cs @@ -38,7 +38,7 @@ namespace Server.Mobiles Karma = 7000; VirtualArmor = 100; - if (0.02 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.02) PackStatue(); } diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs index 81ed82950..088e89259 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/EnergyVortex.cs @@ -10,7 +10,7 @@ namespace Server.Mobiles public EnergyVortex() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { - if (Core.SE && 0.002 > Utility.RandomDouble()) // Per OSI FoF, it's a 1/500 chance. + if (Core.SE && Utility.RandomDouble() < 0.002) // Per OSI FoF, it's a 1/500 chance. { // Llama vortex! Body = 0xDC; @@ -51,7 +51,6 @@ namespace Server.Mobiles ControlSlots = Core.SE ? 2 : 1; } - public EnergyVortex(Serial serial) : base(serial) { diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs index 2c6aa136c..36b3e56bb 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/Golem.cs @@ -9,8 +9,7 @@ namespace Server.Mobiles private bool m_Stunning; [Constructible] - public Golem(bool summoned = false, double scalar = 1.0) : - base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.4, 0.8) + public Golem(bool summoned = false, double scalar = 1.0) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.4, 0.8) { Body = 752; @@ -57,16 +56,16 @@ namespace Server.Mobiles { PackItem(new IronIngot(Utility.RandomMinMax(13, 21))); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) PackItem(new PowerCrystal()); - if (0.15 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.15) PackItem(new ClockworkAssembly()); - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) PackItem(new ArcaneGem()); - if (0.25 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.25) PackItem(new Gears()); } @@ -102,11 +101,11 @@ namespace Server.Mobiles { base.OnDeath(c); - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) { if (!IsParagon) { - if (0.75 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.75) c.DropItem(DawnsMusicGear.RandomCommon); else c.DropItem(DawnsMusicGear.RandomUncommon); @@ -150,7 +149,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (!m_Stunning && 0.3 > Utility.RandomDouble()) + if (!m_Stunning && Utility.RandomDouble() < 0.3) { m_Stunning = true; diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs index f14797165..0b7b731e4 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeast.cs @@ -57,7 +57,7 @@ namespace Server.Mobiles public override string CorpseName => "a plague beast corpse"; [CommandProperty(AccessLevel.GameMaster)] - public int TotalDevoured{ get; set; } + public int TotalDevoured { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int DevourGoal @@ -67,15 +67,13 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public bool HasMetalChest{ get; private set; } + public bool HasMetalChest { get; private set; } public override string DefaultName => "a plague beast"; public override bool AutoDispel => true; public override Poison PoisonImmune => Poison.Lethal; - #region IDevourer Members - public bool Devour(Corpse corpse) { if (corpse?.Owner == null) // sorry we can't devour because the corpse's owner is null @@ -99,8 +97,6 @@ namespace Server.Mobiles return true; } - #endregion - public override void GenerateLoot() { AddLoot(LootPack.FilthyRich); @@ -119,7 +115,7 @@ namespace Server.Mobiles public override void OnDamagedBySpell(Mobile caster) { - if (Map != null && caster != this && 0.25 > Utility.RandomDouble()) + if (Map != null && caster != this && Utility.RandomDouble() < 0.25) { BaseCreature spawn = new PlagueSpawn(this); @@ -135,7 +131,7 @@ namespace Server.Mobiles public override void OnGotMeleeAttack(Mobile attacker) { - if (Map != null && attacker != this && 0.25 > Utility.RandomDouble()) + if (Map != null && attacker != this && Utility.RandomDouble() < 0.25) { BaseCreature spawn = new PlagueSpawn(this); @@ -175,12 +171,12 @@ namespace Server.Mobiles switch (version) { case 1: - { - HasMetalChest = reader.ReadBool(); - TotalDevoured = reader.ReadInt(); - m_DevourGoal = reader.ReadInt(); - break; - } + { + HasMetalChest = reader.ReadBool(); + TotalDevoured = reader.ReadInt(); + m_DevourGoal = reader.ReadInt(); + break; + } } } diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs index 9c6655414..8ffa4be7e 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueBeastLord.cs @@ -50,7 +50,7 @@ namespace Server.Mobiles public override Poison PoisonImmune => Poison.Lethal; [CommandProperty(AccessLevel.GameMaster)] - public Mobile OpenedBy{ get; set; } + public Mobile OpenedBy { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsBleeding @@ -268,7 +268,7 @@ namespace Server.Mobiles private class DecayTimer : Timer { - private PlagueBeastLord m_Lord; + private readonly PlagueBeastLord m_Lord; public DecayTimer(PlagueBeastLord lord, int count = 0, int deadline = 120) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1)) { @@ -277,9 +277,9 @@ namespace Server.Mobiles Deadline = deadline; } - public int Count{ get; private set; } + public int Count { get; private set; } - public int Deadline{ get; private set; } + public int Deadline { get; private set; } protected override void OnTick() { diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs index 882857e13..6eee2b11c 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/PlagueSpawn.cs @@ -7,8 +7,7 @@ namespace Server.Mobiles public class PlagueSpawn : BaseCreature { [Constructible] - public PlagueSpawn(Mobile owner = null) : - base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public PlagueSpawn(Mobile owner = null) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Owner = owner; ExpireTime = DateTime.UtcNow + TimeSpan.FromMinutes(1.0); @@ -75,10 +74,10 @@ namespace Server.Mobiles public override string CorpseName => "a plague spawn corpse"; [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime ExpireTime{ get; set; } + public DateTime ExpireTime { get; set; } public override bool AlwaysMurderer => true; diff --git a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs index bd0b29206..463dfb513 100644 --- a/Projects/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs +++ b/Projects/Scripts/Mobiles/Monsters/Misc/Melee/SandVortex.cs @@ -93,7 +93,8 @@ namespace Server.Mobiles private class InternalTimer : Timer { - private Mobile m_Mobile, m_From; + private readonly Mobile m_Mobile; + private readonly Mobile m_From; public InternalTimer(Mobile m, Mobile from) : base(TimeSpan.FromSeconds(1.0)) { diff --git a/Projects/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs b/Projects/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs index 958797810..fea21812f 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ore Elementals/BronzeElemental.cs @@ -5,8 +5,7 @@ namespace Server.Mobiles public class BronzeElemental : BaseCreature { [Constructible] - public BronzeElemental(int oreAmount = 2) : - base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public BronzeElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { // TODO: Gas attack Body = 108; diff --git a/Projects/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs b/Projects/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs index 257270e45..3e3ccf58e 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ore Elementals/DullCopperElemental.cs @@ -5,8 +5,7 @@ namespace Server.Mobiles public class DullCopperElemental : BaseCreature { [Constructible] - public DullCopperElemental(int oreAmount = 2) : - base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public DullCopperElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 110; BaseSoundID = 268; diff --git a/Projects/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs b/Projects/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs index ae2252e38..131fcbf1d 100644 --- a/Projects/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs +++ b/Projects/Scripts/Mobiles/Monsters/Ore Elementals/GoldenElemental.cs @@ -5,8 +5,7 @@ namespace Server.Mobiles public class GoldenElemental : BaseCreature { [Constructible] - public GoldenElemental(int oreAmount = 2) : - base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public GoldenElemental(int oreAmount = 2) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Body = 166; BaseSoundID = 268; diff --git a/Projects/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs b/Projects/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs index c43843983..953bced6d 100644 --- a/Projects/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs +++ b/Projects/Scripts/Mobiles/Monsters/Plant/Melee/BogThing.cs @@ -37,7 +37,7 @@ namespace Server.Mobiles VirtualArmor = 28; - if (0.25 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.25) PackItem(new Board(10)); else PackItem(new Log(10)); @@ -116,10 +116,10 @@ namespace Server.Mobiles if (Hits > HitsMax / 4) { - if (0.25 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.25) SpawnBogling(attacker); } - else if (0.25 >= Utility.RandomDouble()) + else if (Utility.RandomDouble() <= 0.25) EatBoglings(); } } diff --git a/Projects/Scripts/Mobiles/Monsters/Plant/Melee/Corpser.cs b/Projects/Scripts/Mobiles/Monsters/Plant/Melee/Corpser.cs index b92aaec98..c3a3122b6 100644 --- a/Projects/Scripts/Mobiles/Monsters/Plant/Melee/Corpser.cs +++ b/Projects/Scripts/Mobiles/Monsters/Plant/Melee/Corpser.cs @@ -36,7 +36,7 @@ namespace Server.Mobiles VirtualArmor = 18; - if (0.25 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.25) PackItem(new Board(10)); else PackItem(new Log(10)); diff --git a/Projects/Scripts/Mobiles/Monsters/Plant/Melee/WhippingVine.cs b/Projects/Scripts/Mobiles/Monsters/Plant/Melee/WhippingVine.cs index 641fa48c4..03d9dc247 100644 --- a/Projects/Scripts/Mobiles/Monsters/Plant/Melee/WhippingVine.cs +++ b/Projects/Scripts/Mobiles/Monsters/Plant/Melee/WhippingVine.cs @@ -40,7 +40,7 @@ namespace Server.Mobiles PackReg(3); PackItem(new FertileDirt(Utility.RandomMinMax(1, 10))); - if (0.2 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.2) PackItem(new ExecutionersCap()); PackItem(new Vines()); diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs index f38c70a5c..bae79a3c8 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/DeepSeaSerpent.cs @@ -44,7 +44,7 @@ namespace Server.Mobiles else PackItem(new BlackPearl(4)); - //PackItem( new SpecialFishingNet() ); + // PackItem( new SpecialFishingNet() ); } public DeepSeaSerpent(Serial serial) : base(serial) diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs index c410ec313..41e16d675 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/Leviathan.cs @@ -6,8 +6,7 @@ namespace Server.Mobiles public class Leviathan : BaseCreature { [Constructible] - public Leviathan(Mobile fisher = null) : - base(AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) + public Leviathan(Mobile fisher = null) : base(AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) { Fisher = fisher; @@ -66,7 +65,7 @@ namespace Server.Mobiles public override string CorpseName => "a leviathan corpse"; - public Mobile Fisher{ get; set; } + public Mobile Fisher { get; set; } public override string DefaultName => "a leviathan"; @@ -81,7 +80,7 @@ namespace Server.Mobiles public override int TreasureMapLevel => 5; - public static Type[] Artifacts{ get; } = + public static Type[] Artifacts { get; } = { // Decorations typeof(CandelabraOfSouls), @@ -161,7 +160,7 @@ namespace Server.Mobiles { base.OnDeath(c); - if (Fisher != null && 25 > Utility.Random(100)) + if (Fisher != null && Utility.Random(100) < 25) GiveArtifactTo(Fisher); Fisher = null; diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianArchmage.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianArchmage.cs index 7bb69da07..5f08184e0 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianArchmage.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianArchmage.cs @@ -3,7 +3,7 @@ namespace Server.Mobiles [TypeAlias("Server.Mobiles.OphidianJusticar", "Server.Mobiles.OphidianZealot")] public class OphidianArchmage : BaseCreature { - private static string[] m_Names = + private static readonly string[] m_Names = { "an ophidian justicar", "an ophidian zealot" diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianMage.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianMage.cs index 9f5714239..73f5c916d 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianMage.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/OphidianMage.cs @@ -3,7 +3,7 @@ namespace Server.Mobiles [TypeAlias("Server.Mobiles.OphidianShaman")] public class OphidianMage : BaseCreature { - private static string[] m_Names = + private static readonly string[] m_Names = { "an ophidian apprentice mage", "an ophidian shaman" diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs index 595699d9e..4e2692d90 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SeaSerpent.cs @@ -47,7 +47,7 @@ namespace Server.Mobiles PackItem(new RawFishSteak()); - //PackItem( new SpecialFishingNet() ); + // PackItem( new SpecialFishingNet() ); } public SeaSerpent(Serial serial) : base(serial) diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs index 1a13d50b7..c7d60ea02 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Magic/SerpentineDragon.cs @@ -82,7 +82,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (!Core.SE && 0.2 > Utility.RandomDouble() && attacker is BaseCreature c && c.Controlled && + if (!Core.SE && Utility.RandomDouble() < 0.2 && attacker is BaseCreature c && c.Controlled && c.ControlMaster != null) { c.ControlTarget = c.ControlMaster; diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Kraken.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Kraken.cs index b408a932b..75581154e 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Kraken.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Kraken.cs @@ -47,7 +47,7 @@ namespace Server.Mobiles if (Utility.RandomDouble() < .05) PackItem(new MessageInABottle()); - PackItem(new SpecialFishingNet()); //Confirm? + PackItem(new SpecialFishingNet()); // Confirm? } public Kraken(Serial serial) : base(serial) diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianKnight.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianKnight.cs index 6c67698f6..05aaee060 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianKnight.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianKnight.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles [TypeAlias("Server.Mobiles.OphidianAvenger")] public class OphidianKnight : BaseCreature { - private static string[] m_Names = + private static readonly string[] m_Names = { "an ophidian knight-errant", "an ophidian avenger" diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianWarrior.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianWarrior.cs index a1788f2e7..27ab097d8 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/OphidianWarrior.cs @@ -2,7 +2,7 @@ namespace Server.Mobiles { public class OphidianWarrior : BaseCreature { - private static string[] m_Names = + private static readonly string[] m_Names = { "an ophidian warrior", "an ophidian enforcer" diff --git a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Scorpion.cs b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Scorpion.cs index 484b6ce5f..6a99d65e8 100644 --- a/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Scorpion.cs +++ b/Projects/Scripts/Mobiles/Monsters/Reptile/Melee/Scorpion.cs @@ -56,7 +56,7 @@ namespace Server.Mobiles public override FoodType FavoriteFood => FoodType.Meat; public override PackInstinct PackInstinct => PackInstinct.Arachnid; public override Poison PoisonImmune => Poison.Greater; - public override Poison HitPoison => 0.8 >= Utility.RandomDouble() ? Poison.Greater : Poison.Deadly; + public override Poison HitPoison => Utility.RandomDouble() <= 0.8 ? Poison.Greater : Poison.Deadly; public override void GenerateLoot() { diff --git a/Projects/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs b/Projects/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs index 04b7626d1..1018d5277 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/BakeKitsune.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class BakeKitsune : BaseCreature { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public BakeKitsune() : base(AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) @@ -44,7 +44,6 @@ namespace Server.Mobiles ControlSlots = 2; MinTameSkill = 80.7; - if (Utility.RandomDouble() < .25) PackItem(Seed.RandomBonsaiSeed()); } @@ -88,7 +87,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.1) return; /* Blood Bath @@ -150,8 +149,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { private int m_Count; - private Mobile m_From; - private Mobile m_Mobile; + private readonly Mobile m_From; + private readonly Mobile m_Mobile; public ExpireTimer(Mobile m, Mobile from) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) { @@ -186,8 +185,6 @@ namespace Server.Mobiles } } - #region Disguise - private Timer m_DisguiseTimer; public void Disguise() @@ -263,7 +260,5 @@ namespace Server.Mobiles { FindItemOnLayer(layer)?.Delete(); } - - #endregion } } diff --git a/Projects/Scripts/Mobiles/Monsters/SE/DeathWatchBeetleHatchling.cs b/Projects/Scripts/Mobiles/Monsters/SE/DeathWatchBeetleHatchling.cs index 67bf6f005..5b6ac9e14 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/DeathWatchBeetleHatchling.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/DeathWatchBeetleHatchling.cs @@ -36,7 +36,6 @@ namespace Server.Mobiles Fame = 700; Karma = -700; - if (Utility.RandomBool()) { Item i = Loot.RandomReagent(); diff --git a/Projects/Scripts/Mobiles/Monsters/SE/EliteNinja.cs b/Projects/Scripts/Mobiles/Monsters/SE/EliteNinja.cs index bab1909ce..6294da946 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/EliteNinja.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/EliteNinja.cs @@ -41,7 +41,6 @@ namespace Server.Mobiles SetSkill(SkillName.Swords, 95.0, 120.0); SetSkill(SkillName.Ninjitsu, 95.0, 120.0); - Fame = 8500; Karma = -8500; @@ -53,7 +52,6 @@ namespace Server.Mobiles Can change weapons during a fight */ - AddItem(new NinjaTabi()); AddItem(new LeatherNinjaJacket()); AddItem(new LeatherNinjaHood()); diff --git a/Projects/Scripts/Mobiles/Monsters/SE/FanDancer.cs b/Projects/Scripts/Mobiles/Monsters/SE/FanDancer.cs index 2e2fedb26..5e00448e4 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/FanDancer.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/FanDancer.cs @@ -8,7 +8,7 @@ namespace Server.Mobiles { public class FanDancer : BaseCreature { - private static HashSet m_Table = new HashSet(); + private static readonly HashSet m_Table = new HashSet(); [Constructible] public FanDancer() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) @@ -48,7 +48,7 @@ namespace Server.Mobiles AddItem(new Tessen()); - if (0.02 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.02) PackItem(new OrigamiPaper()); } @@ -61,7 +61,6 @@ namespace Server.Mobiles public override bool Uncalmable => true; - public override void GenerateLoot() { AddLoot(LootPack.FilthyRich); @@ -79,7 +78,7 @@ namespace Server.Mobiles { base.OnDamagedBySpell(attacker); - if (0.8 > Utility.RandomDouble() && !attacker.InRange(this, 1)) + if (Utility.RandomDouble() < 0.8 && !attacker.InRange(this, 1)) { /* Fan Throw * Effect: - To: "0x57D4F5B" - ItemId: "0x27A3" - ItemIdName: "Tessen" - FromLocation: "(992 299, 24)" - ToLocation: "(992 308, 22)" - Speed: "10" - Duration: "0" - FixedDirection: "False" - Explode: "False" - Hue: "0x0" - Render: "0x0" @@ -96,7 +95,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (0.8 > Utility.RandomDouble() && !attacker.InRange(this, 1)) + if (Utility.RandomDouble() < 0.8 && !attacker.InRange(this, 1)) { /* Fan Throw * Effect: - To: "0x57D4F5B" - ItemId: "0x27A3" - ItemIdName: "Tessen" - FromLocation: "(992 299, 24)" - ToLocation: "(992 308, 22)" - Speed: "10" - Duration: "0" - FixedDirection: "False" - Explode: "False" - Hue: "0x0" - Render: "0x0" @@ -113,7 +112,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (!IsFanned(defender) && 0.05 > Utility.RandomDouble()) + if (!IsFanned(defender) && Utility.RandomDouble() < 0.05) { /* Fanning Fire * Graphic: Type: "3" From: "0x57D4F5B" To: "0x0" ItemId: "0x3709" ItemIdName: "fire column" FromLocation: "(994 325, 16)" ToLocation: "(994 325, 16)" Speed: "10" Duration: "30" FixedDirection: "True" Explode: "False" Hue: "0x0" RenderMode: "0x0" Effect: "0x34" ExplodeEffect: "0x1" ExplodeSound: "0x0" Serial: "0x57D4F5B" Layer: "5" Unknown: "0x0" @@ -136,7 +135,7 @@ namespace Server.Mobiles defender.PlaySound(0x208); // This should be done in place of the normal attack damage. - //AOS.Damage( defender, this, Utility.RandomMinMax( 35, 45 ), 0, 100, 0, 0, 0 ); + // AOS.Damage( defender, this, Utility.RandomMinMax( 35, 45 ), 0, 100, 0, 0, 0 ); defender.AddResistanceMod(mod); @@ -164,8 +163,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; - private ResistanceMod m_Mod; + private readonly Mobile m_Mobile; + private readonly ResistanceMod m_Mod; public ExpireTimer(Mobile m, ResistanceMod mod, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Mobiles/Monsters/SE/FireBeetle.cs b/Projects/Scripts/Mobiles/Monsters/SE/FireBeetle.cs index 73c030416..96d7b4328 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/FireBeetle.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/FireBeetle.cs @@ -53,7 +53,6 @@ namespace Server.Mobiles public virtual double BoostedSpeed => 0.1; public override bool ReduceSpeedWithDamage => false; - public override int Meat => 16; public override FoodType FavoriteFood => FoodType.Meat; diff --git a/Projects/Scripts/Mobiles/Monsters/SE/Kappa.cs b/Projects/Scripts/Mobiles/Monsters/SE/Kappa.cs index 412c49b16..3f4eabd35 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/Kappa.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/Kappa.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class Kappa : BaseCreature { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public Kappa() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) @@ -170,8 +170,8 @@ namespace Server.Mobiles private class InternalTimer : Timer { private int m_Count; - private Mobile m_From; - private Mobile m_Mobile; + private readonly Mobile m_From; + private readonly Mobile m_Mobile; public InternalTimer(Mobile from, Mobile m) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) { diff --git a/Projects/Scripts/Mobiles/Monsters/SE/KazeKemono.cs b/Projects/Scripts/Mobiles/Monsters/SE/KazeKemono.cs index 615241896..f7ce1e3de 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/KazeKemono.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/KazeKemono.cs @@ -5,8 +5,8 @@ namespace Server.Mobiles { public class KazeKemono : BaseCreature { - private static Dictionary m_FlurryOfTwigsTable = new Dictionary(); - private static Dictionary m_ChlorophylBlastTable = new Dictionary(); + private static readonly Dictionary m_FlurryOfTwigsTable = new Dictionary(); + private static readonly Dictionary m_ChlorophylBlastTable = new Dictionary(); [Constructible] public KazeKemono() @@ -54,7 +54,6 @@ namespace Server.Mobiles public override bool BleedImmune => true; - public override void GenerateLoot() { AddLoot(LootPack.Rich, 3); @@ -64,7 +63,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) { /* Flurry of Twigs * Start cliloc: 1070850 @@ -97,7 +96,7 @@ namespace Server.Mobiles return; } - if (0.05 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.05) { /* Chlorophyl Blast * Start cliloc: 1070827 @@ -144,9 +143,9 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; - private ResistanceMod m_Mod; - private Dictionary m_Table; + private readonly Mobile m_Mobile; + private readonly ResistanceMod m_Mod; + private readonly Dictionary m_Table; public ExpireTimer(Mobile m, ResistanceMod mod, Dictionary table, TimeSpan delay) : base(delay) diff --git a/Projects/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs b/Projects/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs index 1d9311952..51d10adc7 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/LadyOfTheSnow.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class LadyOfTheSnow : BaseCreature { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public LadyOfTheSnow() @@ -43,11 +43,10 @@ namespace Server.Mobiles Fame = 15200; Karma = -15200; - PackReg(3); PackItem(new Necklace()); - if (0.25 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.25) PackItem(Seed.RandomBonsaiSeed()); } @@ -77,7 +76,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.1) return; /* Cold Wind @@ -120,8 +119,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { private int m_Count; - private Mobile m_From; - private Mobile m_Mobile; + private readonly Mobile m_From; + private readonly Mobile m_Mobile; public ExpireTimer(Mobile m, Mobile from) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Mobiles/Monsters/SE/RaiJu.cs b/Projects/Scripts/Mobiles/Monsters/SE/RaiJu.cs index 454c62f00..f58014b71 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/RaiJu.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/RaiJu.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class RaiJu : BaseCreature { - private static HashSet m_Table = new HashSet(); + private static readonly HashSet m_Table = new HashSet(); [Constructible] public RaiJu() : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) @@ -60,7 +60,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 <= Utility.RandomDouble() || m_Table.Contains(defender)) + if (Utility.RandomDouble() >= 0.1 || m_Table.Contains(defender)) return; /* Lightning Fist @@ -75,7 +75,7 @@ namespace Server.Mobiles defender.SendLocalizedMessage(1070839); // The creature attacks with stunning force! // This should be done in place of the normal attack damage. - //AOS.Damage( defender, this, Utility.RandomMinMax( 35, 65 ), 0, 0, 0, 0, 100 ); + // AOS.Damage( defender, this, Utility.RandomMinMax( 35, 65 ), 0, 0, 0, 0, 100 ); defender.Frozen = true; @@ -100,7 +100,7 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public ExpireTimer(Mobile m, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Mobiles/Monsters/SE/Ronin.cs b/Projects/Scripts/Mobiles/Monsters/SE/Ronin.cs index a4e306377..faf45bfd9 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/Ronin.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/Ronin.cs @@ -75,7 +75,6 @@ namespace Server.Mobiles break; } - if (Utility.RandomDouble() > .2) AddItem(new NoDachi()); else diff --git a/Projects/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs b/Projects/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs index 1f69e5858..0e4ff10af 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/RuneBeetle.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class RuneBeetle : BaseCreature { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public RuneBeetle() : base(AIType.AI_Mage, FightMode.Closest, 10, 1, 0.2, 0.4) @@ -42,7 +42,6 @@ namespace Server.Mobiles Fame = 15000; Karma = -15000; - if (Utility.RandomDouble() < .25) PackItem(Seed.RandomBonsaiSeed()); @@ -119,7 +118,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.05 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.05) return; /* Rune Corruption @@ -212,8 +211,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private Mobile m_Mobile; - private List m_Mods; + private readonly Mobile m_Mobile; + private readonly List m_Mods; public ExpireTimer(Mobile m, List mods, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs b/Projects/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs index 07738092b..11873ea74 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/TsukiWolf.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class TsukiWolf : BaseCreature { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); [Constructible] public TsukiWolf() @@ -102,7 +102,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 <= Utility.RandomDouble()) + if (Utility.RandomDouble() >= 0.1) return; /* Blood Bath @@ -155,8 +155,8 @@ namespace Server.Mobiles private class ExpireTimer : Timer { private int m_Count; - private Mobile m_From; - private Mobile m_Mobile; + private readonly Mobile m_From; + private readonly Mobile m_Mobile; public ExpireTimer(Mobile m, Mobile from) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Mobiles/Monsters/SE/Yamandon.cs b/Projects/Scripts/Mobiles/Monsters/SE/Yamandon.cs index 4737c5670..8829a711c 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/Yamandon.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/Yamandon.cs @@ -44,7 +44,6 @@ namespace Server.Mobiles PackItem(new Eggs(2)); } - public Yamandon(Serial serial) : base(serial) { } @@ -89,7 +88,7 @@ namespace Server.Mobiles if (attacker is BaseCreature creature && creature.BardProvoked) return; - if (0.2 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.2) { /* Counterattack with Hit Poison Area * 20-25 damage, unresistable @@ -117,7 +116,7 @@ namespace Server.Mobiles foreach (Mobile m in eable) { - if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + if (m == this || !(CanBeHarmful(m) || (m.Player && m.Alive))) continue; if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) diff --git a/Projects/Scripts/Mobiles/Monsters/SE/YomotsuElder.cs b/Projects/Scripts/Mobiles/Monsters/SE/YomotsuElder.cs index 0252508a4..05b50af4c 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/YomotsuElder.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/YomotsuElder.cs @@ -36,7 +36,6 @@ namespace Server.Mobiles Fame = 12000; Karma = -12000; - PackItem(new GreenGourd()); PackItem(new ExecutionersAxe()); @@ -86,7 +85,6 @@ namespace Server.Mobiles public override WeaponAbility GetWeaponAbility() => WeaponAbility.DoubleStrike; - public override void GenerateLoot() { AddLoot(LootPack.FilthyRich, 3); @@ -99,7 +97,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) { /* Maniacal laugh * Cliloc: 1070840 diff --git a/Projects/Scripts/Mobiles/Monsters/SE/YomotsuPriest.cs b/Projects/Scripts/Mobiles/Monsters/SE/YomotsuPriest.cs index be6629fc0..5cbab0686 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/YomotsuPriest.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/YomotsuPriest.cs @@ -38,7 +38,6 @@ namespace Server.Mobiles Fame = 9000; Karma = -9000; - PackItem(new GreenGourd()); PackItem(new ExecutionersAxe()); @@ -86,7 +85,6 @@ namespace Server.Mobiles public override WeaponAbility GetWeaponAbility() => WeaponAbility.DoubleStrike; - public override void GenerateLoot() { AddLoot(LootPack.FilthyRich); @@ -100,7 +98,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) { /* Maniacal laugh * Cliloc: 1070840 diff --git a/Projects/Scripts/Mobiles/Monsters/SE/YomotsuWarrior.cs b/Projects/Scripts/Mobiles/Monsters/SE/YomotsuWarrior.cs index cdcbaddda..697f42e74 100644 --- a/Projects/Scripts/Mobiles/Monsters/SE/YomotsuWarrior.cs +++ b/Projects/Scripts/Mobiles/Monsters/SE/YomotsuWarrior.cs @@ -93,7 +93,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 > Utility.RandomDouble()) + if (Utility.RandomDouble() < 0.1) { /* Maniacal laugh * Cliloc: 1070840 diff --git a/Projects/Scripts/Mobiles/PlayerMobile.cs b/Projects/Scripts/Mobiles/PlayerMobile.cs index dbc0134d6..2c74b21fe 100644 --- a/Projects/Scripts/Mobiles/PlayerMobile.cs +++ b/Projects/Scripts/Mobiles/PlayerMobile.cs @@ -40,8 +40,6 @@ using RankDefinition = Server.Guilds.RankDefinition; namespace Server.Mobiles { - #region Enums - [Flags] public enum PlayerFlag // First 16 bits are reserved for default-distro use, start custom flags at 0x00010000 { @@ -95,15 +93,13 @@ namespace Server.Mobiles DismountRecovery = 1070859 } - #endregion - public class PlayerMobile : Mobile, IHonorTarget { private static bool m_NoRecursion; private List m_AllFollowers; - private Dictionary> m_AntiMacroTable; + private readonly Dictionary> m_AntiMacroTable; private TimeSpan m_GameTime; /* @@ -164,15 +160,15 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public DateTime AnkhNextUse{ get; set; } + public DateTime AnkhNextUse { get; set; } [CommandProperty(AccessLevel.GameMaster)] public TimeSpan DisguiseTimeLeft => DisguiseTimers.TimeRemaining(this); [CommandProperty(AccessLevel.GameMaster)] - public DateTime PeacedUntil{ get; set; } + public DateTime PeacedUntil { get; set; } - public DesignContext DesignContext{ get; set; } + public DesignContext DesignContext { get; set; } public BlockMountType MountBlockReason => CheckBlock(m_MountBlock) ? m_MountBlock.m_Type : BlockMountType.None; @@ -182,7 +178,7 @@ namespace Server.Mobiles { get { - //BaseArmor ar; + // BaseArmor ar; double rating = 0.0; AddArmorRating(ref rating, NeckArmor); @@ -197,7 +193,7 @@ namespace Server.Mobiles } } - public SkillName[] AnimalFormRestrictedSkills{ get; } = + public SkillName[] AnimalFormRestrictedSkills { get; } = { SkillName.ArmsLore, SkillName.Begging, SkillName.Discordance, SkillName.Forensics, SkillName.Inscribe, SkillName.ItemID, SkillName.Meditation, SkillName.Peacemaking, @@ -216,9 +212,9 @@ namespace Server.Mobiles } } - public List EquipSnapshot{ get; private set; } + public List EquipSnapshot { get; private set; } - public SkillName Learning{ get; set; } = (SkillName)(-1); + public SkillName Learning { get; set; } = (SkillName)(-1); [CommandProperty(AccessLevel.GameMaster)] public TimeSpan SavagePaintExpiration @@ -286,21 +282,21 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastEscortTime{ get; set; } + public DateTime LastEscortTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastPetBallTime{ get; set; } + public DateTime LastPetBallTime { get; set; } - public List VisibilityList{ get; } + public List VisibilityList { get; } - public List PermaFlags{ get; private set; } + public List PermaFlags { get; private set; } public override int Luck => AosAttributes.GetValue(this, AosAttribute.Luck); - public BOBFilter BOBFilter{ get; private set; } + public BOBFilter BOBFilter { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime SessionStart{ get; private set; } + public DateTime SessionStart { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public TimeSpan GameTime @@ -315,7 +311,7 @@ namespace Server.Mobiles public override bool NewGuildDisplay => Guilds.Guild.NewGuildSystem; - public bool BedrollLogout{ get; set; } + public bool BedrollLogout { get; set; } [CommandProperty(AccessLevel.GameMaster)] public override bool Paralyzed @@ -326,26 +322,16 @@ namespace Server.Mobiles base.Paralyzed = value; if (value) - AddBuff(new BuffInfo(BuffIcon.Paralyze, 1075827)); //Paralyze/You are frozen and can not move + AddBuff(new BuffInfo(BuffIcon.Paralyze, 1075827)); // Paralyze/You are frozen and can not move else RemoveBuff(BuffIcon.Paralyze); } } - #region Ethics - [CommandProperty(AccessLevel.GameMaster)] - public Player EthicPlayer{ get; set; } + public Player EthicPlayer { get; set; } - #endregion - - #region Factions - - public PlayerState FactionPlayerState{ get; set; } - - #endregion - - #region Stygian Abyss + public PlayerState FactionPlayerState { get; set; } public override void ToggleFlying() { @@ -410,8 +396,6 @@ namespace Server.Mobiles } } - #endregion - public static Direction GetDirection4(Point3D from, Point3D to) { int dx = from.X - to.X; @@ -470,7 +454,7 @@ namespace Server.Mobiles { int[] itemIDs = fp.ItemIDs; - Point3D oldWorldLoc = bi.m_WorldLoc; + Point3D oldWorldLoc = bi.WorldLoc; Point3D newWorldLoc = location; if (oldWorldLoc.X != newWorldLoc.X || oldWorldLoc.Y != newWorldLoc.Y) @@ -586,7 +570,7 @@ namespace Server.Mobiles if (toMove != null) { - //pack.DropItem(toMove); + // pack.DropItem(toMove); toMove.Internalize(); if (!pm.EquipItem(item)) @@ -617,8 +601,8 @@ namespace Server.Mobiles { foreach (Mobile m in World.Mobiles.Values) if (m is PlayerMobile pm) - if ((!pm.Mounted || pm.Mount is EtherealMount) && pm.AllFollowers.Count > pm.AutoStabled.Count || - pm.Mounted && pm.AllFollowers.Count > pm.AutoStabled.Count + 1) + if (((!pm.Mounted || pm.Mount is EtherealMount) && pm.AllFollowers.Count > pm.AutoStabled.Count) || + (pm.Mounted && pm.AllFollowers.Count > pm.AutoStabled.Count + 1)) pm.AutoStablePets(); /* autostable checks summons, et al: no need here */ } @@ -649,11 +633,11 @@ namespace Server.Mobiles int max = base.GetMaxResistance(type); - if (type != ResistanceType.Physical && 60 < max && CurseSpell.UnderEffect(this)) + if (type != ResistanceType.Physical && max > 60 && CurseSpell.UnderEffect(this)) max = 60; if (Core.ML && Race == Race.Elf && type == ResistanceType.Energy) - max += 5; //Intended to go after the 60 max from curse + max += 5; // Intended to go after the 60 max from curse return max; } @@ -799,20 +783,12 @@ namespace Server.Mobiles int dex = Dex; int intel = Int; - #region Factions - int factionItemCount = 0; - #endregion - Mobile from = this; - #region Ethics - Ethic ethic = Ethic.Find(from); - #endregion - for (int i = items.Count - 1; i >= 0; --i) { if (i >= items.Count) @@ -820,8 +796,6 @@ namespace Server.Mobiles Item item = items[i]; - #region Ethics - if ((item.SavedFlags & 0x100) != 0) { if (item.Hue != Ethic.Hero.Definition.PrimaryHue) @@ -849,8 +823,6 @@ namespace Server.Mobiles } } - #endregion - if (item is BaseWeapon weapon) { bool drop = false; @@ -1070,13 +1042,13 @@ namespace Server.Mobiles base.OnHiddenChanged(); RemoveBuff(BuffIcon - .Invisibility); //Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set + .Invisibility); // Always remove, default to the hiding icon EXCEPT in the invis spell where it's explicitly set if (!Hidden) RemoveBuff(BuffIcon.HidingAndOrStealth); - else // if ( !InvisibilitySpell.HasTimer( this ) ) + else // if (!InvisibilitySpell.HasTimer( this )) BuffInfo.AddBuff(this, - new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655)); //Hidden/Stealthing & You Are Hidden + new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655)); // Hidden/Stealthing & You Are Hidden } public override void OnSubItemAdded(Item item) @@ -1095,10 +1067,10 @@ namespace Server.Mobiles public override bool CanBeHarmful(Mobile target, bool message, bool ignoreOurBlessedness) { - if (DesignContext != null || target is PlayerMobile mobile && mobile.DesignContext != null) + if (DesignContext != null || (target is PlayerMobile mobile && mobile.DesignContext != null)) 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 || target is TownCrier) { if (message) { @@ -1116,7 +1088,7 @@ namespace Server.Mobiles public override bool CanBeBeneficial(Mobile target, bool message, bool allowDead) { - if (DesignContext != null || target is PlayerMobile mobile && mobile.DesignContext != null) + if (DesignContext != null || (target is PlayerMobile mobile && mobile.DesignContext != null)) return false; return base.CanBeBeneficial(target, message, allowDead); @@ -1221,10 +1193,8 @@ namespace Server.Mobiles public override bool AllowItemUse(Item item) { - #region Dueling if (DuelContext?.AllowItemUse(this, item) == false) return false; - #endregion return DesignContext.Check(this); } @@ -1239,10 +1209,8 @@ namespace Server.Mobiles return false; } - #region Dueling if (DuelContext?.AllowSkillUse(this, skill) == false) return false; - #endregion return DesignContext.Check(this); } @@ -1448,15 +1416,9 @@ namespace Server.Mobiles if (!base.CheckEquip(item)) return false; - #region Dueling - if (DuelContext?.AllowItemEquip(this, item) == false) return false; - #endregion - - #region Factions - FactionItem factionItem = FactionItem.Find(item); if (factionItem != null) @@ -1490,20 +1452,18 @@ namespace Server.Mobiles } } - #endregion - if (AccessLevel < AccessLevel.GameMaster && item.Layer != Layer.Mount && HasTrade) { BounceInfo bounce = item.GetBounce(); if (bounce != null) { - if (bounce.m_Parent is Item parent) + if (bounce.Parent is Item parent) { if (parent == Backpack || parent.IsChildOf(Backpack)) return true; } - else if (bounce.m_Parent == this) + else if (bounce.Parent == this) { return true; } @@ -1599,7 +1559,7 @@ namespace Server.Mobiles { BounceInfo bounce = item.GetBounce(); - if (bounce?.m_Parent is Item parent && (parent == pack || parent.IsChildOf(pack))) + if (bounce?.Parent is Item parent && (parent == pack || parent.IsChildOf(pack))) return true; SendLocalizedMessage(1004041); // You can't do that while you have a trade pending. @@ -1613,12 +1573,8 @@ namespace Server.Mobiles { CheckLightLevels(false); - #region Dueling - DuelContext?.OnLocationChanged(this); - #endregion - DesignContext context = DesignContext; if (context == null || m_NoRecursion) @@ -1655,17 +1611,13 @@ namespace Server.Mobiles { if (m is BaseCreature creature && !creature.Controlled) return !Alive || !creature.Alive || IsDeadBondedPet || creature.IsDeadBondedPet || - Hidden && AccessLevel > AccessLevel.Player; - - #region Dueling + (Hidden && AccessLevel > AccessLevel.Player); if (Region.IsPartOf() && m is PlayerMobile pm) if (pm.DuelContext == null || pm.DuelPlayer == null || !pm.DuelContext.Started || pm.DuelContext.Finished || pm.DuelPlayer.Eliminated) return true; - #endregion - return base.OnMoveOver(m); } @@ -1679,15 +1631,11 @@ namespace Server.Mobiles protected override void OnMapChange(Map oldMap) { - if (Map != Faction.Facet && oldMap == Faction.Facet || Map == Faction.Facet && oldMap != Faction.Facet) + if ((Map != Faction.Facet && oldMap == Faction.Facet) || (Map == Faction.Facet && oldMap != Faction.Facet)) InvalidateProperties(); - #region Dueling - DuelContext?.OnMapChanged(this); - #endregion - DesignContext context = DesignContext; if (context == null || m_NoRecursion) @@ -1809,14 +1757,10 @@ namespace Server.Mobiles if (!InsuranceEnabled || !item.Insured) return false; - #region Dueling - if (DuelContext?.Registered == true && DuelContext.Started && m_DuelPlayer?.Eliminated != true) return true; - #endregion - if (AutoRenewInsurance) { int cost = GetInsuranceCost(item); @@ -1848,7 +1792,6 @@ namespace Server.Mobiles pm.m_InsuranceBonus += 300; return true; - } public override DeathMoveResult GetParentMoveResultFor(Item item) @@ -1908,16 +1851,12 @@ namespace Server.Mobiles MeerMage.StopEffect(this, false); - #region Stygian Abyss - if (Flying) { Flying = false; BuffInfo.RemoveBuff(this, BuffIcon.Fly); } - #endregion - StolenItem.ReturnOnDeath(this, c); if (PermaFlags.Count > 0) @@ -1988,12 +1927,8 @@ namespace Server.Mobiles MLQuestSystem.HandleDeath(this); - #region Dueling - DuelContext?.OnDeath(this, c); - #endregion - if (m_BuffTable != null) { List list = new List(); @@ -2039,7 +1974,7 @@ namespace Server.Mobiles { if (g.Alliance?.IsMember(g) == true) { - //g.Alliance.AllianceTextMessage( hue, "[Alliance][{0}]: {1}", this.Name, text ); + // g.Alliance.AllianceTextMessage( hue, "[Alliance][{0}]: {1}", this.Name, text ); g.Alliance.AllianceChat(this, text); SendToStaffMessage(this, "[Alliance]: {0}", text); @@ -2050,7 +1985,7 @@ namespace Server.Mobiles SendLocalizedMessage(1071020); // You are not in an alliance! } } - else //Type == MessageType.Guild + else // Type == MessageType.Guild { GuildMessageHue = hue; @@ -2183,241 +2118,241 @@ namespace Server.Mobiles switch (version) { case 29: - { - if (reader.ReadBool()) { - m_StuckMenuUses = new DateTime[reader.ReadInt()]; - - for (int i = 0; i < m_StuckMenuUses.Length; ++i) m_StuckMenuUses[i] = reader.ReadDateTime(); - } - else - { - m_StuckMenuUses = null; - } - - goto case 28; - } - case 28: - { - PeacedUntil = reader.ReadDateTime(); - - goto case 27; - } - case 27: - { - AnkhNextUse = reader.ReadDateTime(); - - goto case 26; - } - case 26: - { - AutoStabled = reader.ReadStrongMobileList(); - - goto case 25; - } - case 25: - { - int recipeCount = reader.ReadInt(); - - if (recipeCount > 0) - { - m_AcquiredRecipes = new Dictionary(); - - for (int i = 0; i < recipeCount; i++) + if (reader.ReadBool()) { - int r = reader.ReadInt(); - if (reader.ReadBool()) //Don't add in recipes which we haven't gotten or have been removed - m_AcquiredRecipes.Add(r, true); + m_StuckMenuUses = new DateTime[reader.ReadInt()]; + + for (int i = 0; i < m_StuckMenuUses.Length; ++i) m_StuckMenuUses[i] = reader.ReadDateTime(); } + else + { + m_StuckMenuUses = null; + } + + goto case 28; } + case 28: + { + PeacedUntil = reader.ReadDateTime(); - goto case 24; - } + goto case 27; + } + case 27: + { + AnkhNextUse = reader.ReadDateTime(); + + goto case 26; + } + case 26: + { + AutoStabled = reader.ReadStrongMobileList(); + + goto case 25; + } + case 25: + { + int recipeCount = reader.ReadInt(); + + if (recipeCount > 0) + { + m_AcquiredRecipes = new Dictionary(); + + for (int i = 0; i < recipeCount; i++) + { + int r = reader.ReadInt(); + if (reader.ReadBool()) // Don't add in recipes which we haven't gotten or have been removed + m_AcquiredRecipes.Add(r, true); + } + } + + goto case 24; + } case 24: - { - LastHonorLoss = reader.ReadDeltaTime(); - goto case 23; - } + { + LastHonorLoss = reader.ReadDeltaTime(); + goto case 23; + } case 23: - { - ChampionTitles = new ChampionTitleInfo(reader); - goto case 22; - } + { + ChampionTitles = new ChampionTitleInfo(reader); + goto case 22; + } case 22: - { - LastValorLoss = reader.ReadDateTime(); - goto case 21; - } + { + LastValorLoss = reader.ReadDateTime(); + goto case 21; + } case 21: - { - ToTItemsTurnedIn = reader.ReadEncodedInt(); - ToTTotalMonsterFame = reader.ReadInt(); - goto case 20; - } + { + ToTItemsTurnedIn = reader.ReadEncodedInt(); + ToTTotalMonsterFame = reader.ReadInt(); + goto case 20; + } case 20: - { - AllianceMessageHue = reader.ReadEncodedInt(); - GuildMessageHue = reader.ReadEncodedInt(); + { + AllianceMessageHue = reader.ReadEncodedInt(); + GuildMessageHue = reader.ReadEncodedInt(); - goto case 19; - } + goto case 19; + } case 19: - { - int rank = reader.ReadEncodedInt(); - int maxRank = RankDefinition.Ranks.Length - 1; - if (rank > maxRank) - rank = maxRank; + { + int rank = reader.ReadEncodedInt(); + int maxRank = RankDefinition.Ranks.Length - 1; + if (rank > maxRank) + rank = maxRank; - m_GuildRank = RankDefinition.Ranks[rank]; - LastOnline = reader.ReadDateTime(); - goto case 18; - } + m_GuildRank = RankDefinition.Ranks[rank]; + LastOnline = reader.ReadDateTime(); + goto case 18; + } case 18: - { - SolenFriendship = (SolenFriendship)reader.ReadEncodedInt(); + { + SolenFriendship = (SolenFriendship)reader.ReadEncodedInt(); - goto case 17; - } + goto case 17; + } case 17: // changed how DoneQuests is serialized case 16: - { - Quest = QuestSerializer.DeserializeQuest(reader); - - if (Quest != null) - Quest.From = this; - - int count = reader.ReadEncodedInt(); - - if (count > 0) { - DoneQuests = new List(); + Quest = QuestSerializer.DeserializeQuest(reader); - for (int i = 0; i < count; ++i) + if (Quest != null) + Quest.From = this; + + int count = reader.ReadEncodedInt(); + + if (count > 0) { - Type questType = QuestSerializer.ReadType(QuestSystem.QuestTypes, reader); - DateTime restartTime; + DoneQuests = new List(); - if (version < 17) - restartTime = DateTime.MaxValue; - else - restartTime = reader.ReadDateTime(); + for (int i = 0; i < count; ++i) + { + Type questType = QuestSerializer.ReadType(QuestSystem.QuestTypes, reader); + DateTime restartTime; - DoneQuests.Add(new QuestRestartInfo(questType, restartTime)); + if (version < 17) + restartTime = DateTime.MaxValue; + else + restartTime = reader.ReadDateTime(); + + DoneQuests.Add(new QuestRestartInfo(questType, restartTime)); + } } + + Profession = reader.ReadEncodedInt(); + goto case 15; } - - Profession = reader.ReadEncodedInt(); - goto case 15; - } case 15: - { - LastCompassionLoss = reader.ReadDeltaTime(); - goto case 14; - } + { + LastCompassionLoss = reader.ReadDeltaTime(); + goto case 14; + } case 14: - { - CompassionGains = reader.ReadEncodedInt(); + { + CompassionGains = reader.ReadEncodedInt(); - if (CompassionGains > 0) - NextCompassionDay = reader.ReadDeltaTime(); + if (CompassionGains > 0) + NextCompassionDay = reader.ReadDeltaTime(); - goto case 13; - } + goto case 13; + } case 13: // just removed m_PaidInsurance list case 12: - { - BOBFilter = new BOBFilter(reader); - goto case 11; - } + { + BOBFilter = new BOBFilter(reader); + goto case 11; + } case 11: - { - if (version < 13) { - List paid = reader.ReadStrongItemList(); + if (version < 13) + { + List paid = reader.ReadStrongItemList(); - for (int i = 0; i < paid.Count; ++i) - paid[i].PaidInsurance = true; + for (int i = 0; i < paid.Count; ++i) + paid[i].PaidInsurance = true; + } + + goto case 10; } - - goto case 10; - } case 10: - { - if (reader.ReadBool()) { - m_HairModID = reader.ReadInt(); - m_HairModHue = reader.ReadInt(); - m_BeardModID = reader.ReadInt(); - m_BeardModHue = reader.ReadInt(); - } + if (reader.ReadBool()) + { + m_HairModID = reader.ReadInt(); + m_HairModHue = reader.ReadInt(); + m_BeardModID = reader.ReadInt(); + m_BeardModHue = reader.ReadInt(); + } - goto case 9; - } + goto case 9; + } case 9: - { - SavagePaintExpiration = reader.ReadTimeSpan(); - - if (SavagePaintExpiration > TimeSpan.Zero) { - BodyMod = Female ? 184 : 183; - HueMod = 0; - } + SavagePaintExpiration = reader.ReadTimeSpan(); - goto case 8; - } + if (SavagePaintExpiration > TimeSpan.Zero) + { + BodyMod = Female ? 184 : 183; + HueMod = 0; + } + + goto case 8; + } case 8: - { - NpcGuild = (NpcGuild)reader.ReadInt(); - NpcGuildJoinTime = reader.ReadDateTime(); - NpcGuildGameTime = reader.ReadTimeSpan(); - goto case 7; - } + { + NpcGuild = (NpcGuild)reader.ReadInt(); + NpcGuildJoinTime = reader.ReadDateTime(); + NpcGuildGameTime = reader.ReadTimeSpan(); + goto case 7; + } case 7: - { - PermaFlags = reader.ReadStrongMobileList(); - goto case 6; - } + { + PermaFlags = reader.ReadStrongMobileList(); + goto case 6; + } case 6: - { - NextTailorBulkOrder = reader.ReadTimeSpan(); - goto case 5; - } + { + NextTailorBulkOrder = reader.ReadTimeSpan(); + goto case 5; + } case 5: - { - NextSmithBulkOrder = reader.ReadTimeSpan(); - goto case 4; - } + { + NextSmithBulkOrder = reader.ReadTimeSpan(); + goto case 4; + } case 4: - { - LastJusticeLoss = reader.ReadDeltaTime(); - JusticeProtectors = reader.ReadStrongMobileList(); - goto case 3; - } + { + LastJusticeLoss = reader.ReadDeltaTime(); + JusticeProtectors = reader.ReadStrongMobileList(); + goto case 3; + } case 3: - { - LastSacrificeGain = reader.ReadDeltaTime(); - LastSacrificeLoss = reader.ReadDeltaTime(); - AvailableResurrects = reader.ReadInt(); - goto case 2; - } + { + LastSacrificeGain = reader.ReadDeltaTime(); + LastSacrificeLoss = reader.ReadDeltaTime(); + AvailableResurrects = reader.ReadInt(); + goto case 2; + } case 2: - { - Flags = (PlayerFlag)reader.ReadInt(); - goto case 1; - } + { + Flags = (PlayerFlag)reader.ReadInt(); + goto case 1; + } case 1: - { - m_LongTermElapse = reader.ReadTimeSpan(); - m_ShortTermElapse = reader.ReadTimeSpan(); - m_GameTime = reader.ReadTimeSpan(); - goto case 0; - } + { + m_LongTermElapse = reader.ReadTimeSpan(); + m_ShortTermElapse = reader.ReadTimeSpan(); + m_GameTime = reader.ReadTimeSpan(); + goto case 0; + } case 0: - { - if (version < 26) - AutoStabled = new List(); - break; - } + { + if (version < 26) + AutoStabled = new List(); + break; + } } RecentlyReported ??= new List(); @@ -2430,7 +2365,7 @@ namespace Server.Mobiles JusticeProtectors ??= new List(); BOBFilter ??= new BOBFilter(); - //Default to member if going from older version to new version (only time it should be null) + // Default to member if going from older version to new version (only time it should be null) m_GuildRank ??= RankDefinition.Member; if (LastOnline == DateTime.MinValue && Account != null) @@ -2452,13 +2387,13 @@ namespace Server.Mobiles CheckAtrophies(this); - if (Hidden) //Hiding is the only buff where it has an effect that's serialized. + if (Hidden) // Hiding is the only buff where it has an effect that's serialized. AddBuff(new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655)); } public override void Serialize(IGenericWriter writer) { - //cleanup our anti-macro table + // cleanup our anti-macro table foreach (Dictionary t in m_AntiMacroTable.Values) { List toRemove = t.Where(kvp => kvp.Value.TimeStamp + SkillCheck.AntiMacroExpire <= DateTime.UtcNow) @@ -2515,7 +2450,7 @@ namespace Server.Mobiles writer.Write(LastValorLoss); writer.WriteEncodedInt(ToTItemsTurnedIn); - writer.Write(ToTTotalMonsterFame); //This ain't going to be a small #. + writer.Write(ToTTotalMonsterFame); // This ain't going to be a small #. writer.WriteEncodedInt(AllianceMessageHue); writer.WriteEncodedInt(GuildMessageHue); @@ -2657,7 +2592,7 @@ namespace Server.Mobiles public virtual void CheckedAnimate(int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay) { if (!Mounted) - base.Animate(action, frameCount, repeatCount, forward, repeat, delay); + this.Animate(action, frameCount, repeatCount, forward, repeat, delay); } public override bool CanSee(Item item) => DesignContext?.Foundation.IsHiddenToCustomizer(item) != true && base.CanSee(item); @@ -2766,7 +2701,7 @@ namespace Server.Mobiles if (AccessLevel != AccessLevel.Player) return true; - if (Hidden && DesignContext.Find(this) == null) //Hidden & NOT customizing a house + if (Hidden && DesignContext.Find(this) == null) // Hidden & NOT customizing a house { if (!Mounted && Skills.Stealth.Value >= 25.0) { @@ -2898,7 +2833,7 @@ namespace Server.Mobiles { private int m_Count; - public DateTime TimeStamp{ get; private set; } + public DateTime TimeStamp { get; private set; } public int Count { @@ -2913,8 +2848,8 @@ namespace Server.Mobiles private class MountBlock { - public Timer m_Timer; - public BlockMountType m_Type; + public readonly Timer m_Timer; + public readonly BlockMountType m_Type; public MountBlock(TimeSpan duration, BlockMountType type, Mobile mobile) { @@ -2934,7 +2869,7 @@ namespace Server.Mobiles private class CallbackEntry : ContextMenuEntry { - private ContextCallback m_Callback; + private readonly ContextCallback m_Callback; public CallbackEntry(int number, ContextCallback callback) : this(number, -1, callback) { @@ -2948,13 +2883,11 @@ namespace Server.Mobiles } } - #region Getters & Setters + public List RecentlyReported { get; set; } - public List RecentlyReported{ get; set; } + public List AutoStabled { get; private set; } - public List AutoStabled{ get; private set; } - - public bool NinjaWepCooldown{ get; set; } + public bool NinjaWepCooldown { get; set; } public List AllFollowers => m_AllFollowers ?? (m_AllFollowers = new List()); @@ -2965,15 +2898,15 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public int GuildMessageHue{ get; set; } + public int GuildMessageHue { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int AllianceMessageHue{ get; set; } + public int AllianceMessageHue { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Profession{ get; set; } + public int Profession { get; set; } - public int StepsTaken{ get; set; } + public int StepsTaken { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsStealthing // IsStealthing should be moved to Server.Mobiles @@ -2997,30 +2930,30 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public NpcGuild NpcGuild{ get; set; } + public NpcGuild NpcGuild { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime NpcGuildJoinTime{ get; set; } + public DateTime NpcGuildJoinTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime NextBODTurnInTime{ get; set; } + public DateTime NextBODTurnInTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastOnline{ get; set; } + public DateTime LastOnline { get; set; } [CommandProperty(AccessLevel.GameMaster)] public long LastMoved => LastMoveTime; [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan NpcGuildGameTime{ get; set; } + public TimeSpan NpcGuildGameTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ToTItemsTurnedIn{ get; set; } + public int ToTItemsTurnedIn { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int ToTTotalMonsterFame{ get; set; } + public int ToTTotalMonsterFame { get; set; } - public int ExecutesLightningStrike{ get; set; } + public int ExecutesLightningStrike { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int ToothAche @@ -3029,11 +2962,7 @@ namespace Server.Mobiles set => CandyCane.SetToothAche(this, value); } - #endregion - - #region PlayerFlags - - public PlayerFlag Flags{ get; set; } + public PlayerFlag Flags { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool PagingSquelched @@ -3126,11 +3055,7 @@ namespace Server.Mobiles set => SetFlag(PlayerFlag.RefuseTrades, value); } - #endregion - - #region Auto Arrow Recovery - - public Dictionary RecoverableAmmo{ get; } = new Dictionary(); + public Dictionary RecoverableAmmo { get; } = new Dictionary(); public void RecoverAmmo() { @@ -3170,19 +3095,11 @@ namespace Server.Mobiles RecoverableAmmo.Clear(); } - #endregion - - #region Scroll of Alacrity + [CommandProperty(AccessLevel.GameMaster)] + public DateTime AcceleratedStart { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime AcceleratedStart{ get; set; } - - [CommandProperty(AccessLevel.GameMaster)] - public SkillName AcceleratedSkill{ get; set; } - - #endregion - - #region [Stats]Max + public SkillName AcceleratedSkill { get; set; } [CommandProperty(AccessLevel.GameMaster)] public override int HitsMax @@ -3194,7 +3111,7 @@ namespace Server.Mobiles if (Core.AOS) { - strBase = Str; //this.Str already includes GetStatOffset/str + strBase = Str; // this.Str already includes GetStatOffset/str strOffs = AosAttributes.GetValue(this, AosAttribute.BonusHits); if (Core.ML && strOffs > 25 && AccessLevel <= AccessLevel.Player) @@ -3220,10 +3137,6 @@ namespace Server.Mobiles public override int ManaMax => base.ManaMax + AosAttributes.GetValue(this, AosAttribute.BonusMana) + (Core.ML && Race == Race.Elf ? 20 : 0); - #endregion - - #region Stat Getters/Setters - [CommandProperty(AccessLevel.GameMaster)] public override int Str { @@ -3263,10 +3176,6 @@ namespace Server.Mobiles set => base.Dex = value; } - #endregion - - #region Insurance - private static int GetInsuranceCost(Item item) => 600; private void ToggleItemInsurance() @@ -3280,7 +3189,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 || + if ((item is Container && !(item is BaseQuiver)) || item is BagOfSending || item is KeyRing || item is PotionKeg || item is Sigil) return false; @@ -3402,8 +3311,8 @@ namespace Server.Mobiles private class CancelRenewInventoryInsuranceGump : Gump { - private ItemInsuranceMenuGump m_InsuranceGump; - private PlayerMobile m_Player; + private readonly ItemInsuranceMenuGump m_InsuranceGump; + private readonly PlayerMobile m_Player; public CancelRenewInventoryInsuranceGump(PlayerMobile player, ItemInsuranceMenuGump insuranceGump) : base(250, 200) @@ -3476,10 +3385,10 @@ namespace Server.Mobiles private class ItemInsuranceMenuGump : Gump { - private PlayerMobile m_From; - private bool[] m_Insure; - private Item[] m_Items; - private int m_Page; + private readonly PlayerMobile m_From; + private readonly bool[] m_Insure; + private readonly Item[] m_Items; + private readonly int m_Page; public ItemInsuranceMenuGump(PlayerMobile from, Item[] items, bool[] insure = null, int page = 0) : base(25, 50) @@ -3587,61 +3496,61 @@ namespace Server.Mobiles switch (info.ButtonID) { case 1: // Auto Reinsure - { - if (m_From.AutoRenewInsurance) { - if (!m_From.HasGump()) - m_From.SendGump(new CancelRenewInventoryInsuranceGump(m_From, this)); - } - else - { - m_From.AutoRenewInventoryInsurance(); - m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page)); - } + if (m_From.AutoRenewInsurance) + { + if (!m_From.HasGump()) + m_From.SendGump(new CancelRenewInventoryInsuranceGump(m_From, this)); + } + else + { + m_From.AutoRenewInventoryInsurance(); + m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page)); + } - break; - } + break; + } case 2: // OK - { - m_From.SendGump(new ItemInsuranceMenuConfirmGump(m_From, m_Items, m_Insure, m_Page)); + { + m_From.SendGump(new ItemInsuranceMenuConfirmGump(m_From, m_Items, m_Insure, m_Page)); - break; - } + break; + } case 3: // Prev - { - if (m_Page >= 1) - m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page - 1)); + { + if (m_Page >= 1) + m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page - 1)); - break; - } + break; + } case 4: // Next - { - if ((m_Page + 1) * 4 < m_Items.Length) - m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page + 1)); + { + if ((m_Page + 1) * 4 < m_Items.Length) + m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page + 1)); - break; - } + break; + } default: - { - int idx = info.ButtonID - 100; + { + int idx = info.ButtonID - 100; - if (idx >= 0 && idx < m_Items.Length) - m_Insure[idx] = !m_Insure[idx]; + if (idx >= 0 && idx < m_Items.Length) + m_Insure[idx] = !m_Insure[idx]; - m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page)); + m_From.SendGump(new ItemInsuranceMenuGump(m_From, m_Items, m_Insure, m_Page)); - break; - } + break; + } } } } private class ItemInsuranceMenuConfirmGump : Gump { - private PlayerMobile m_From; - private bool[] m_Insure; - private Item[] m_Items; - private int m_Page; + private readonly PlayerMobile m_From; + private readonly bool[] m_Insure; + private readonly Item[] m_Items; + private readonly int m_Page; public ItemInsuranceMenuConfirmGump(PlayerMobile from, Item[] items, bool[] insure, int page) : base(250, 200) @@ -3688,10 +3597,6 @@ namespace Server.Mobiles } } - #endregion - - #region Toggle Quest Item - private void ToggleQuestItem() { if (!CheckAlive()) @@ -3706,8 +3611,8 @@ namespace Server.Mobiles CloseGump(); CloseGump(); CloseGump(); - //CloseGump( typeof( UnknownGump802 ) ); - //CloseGump( typeof( UnknownGump804 ) ); + // CloseGump( typeof( UnknownGump802 ) ); + // CloseGump( typeof( UnknownGump804 ) ); BeginTarget(-1, false, TargetFlags.None, ToggleQuestItem_Callback); SendLocalizedMessage(1072352); // Target the item you wish to toggle Quest Item status on to cancel @@ -3743,10 +3648,6 @@ namespace Server.Mobiles ToggleQuestItemTarget(); } - #endregion - - #region Stuck Menu - private DateTime[] m_StuckMenuUses; public bool CanUseStuckMenu() @@ -3772,10 +3673,6 @@ namespace Server.Mobiles } } - #endregion - - #region Poison - public override ApplyPoisonResult ApplyPoison(Mobile from, Poison poison) { if (!Alive) @@ -3809,13 +3706,9 @@ namespace Server.Mobiles base.OnPoisonImmunity(from, poison); } - #endregion - - #region Dueling - private DuelPlayer m_DuelPlayer; - public DuelContext DuelContext{ get; private set; } + public DuelContext DuelContext { get; private set; } public DuelPlayer DuelPlayer { @@ -3835,22 +3728,14 @@ namespace Server.Mobiles } } - #endregion + public QuestSystem Quest { get; set; } - #region Quests - - public QuestSystem Quest{ get; set; } - - public List DoneQuests{ get; set; } + public List DoneQuests { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public SolenFriendship SolenFriendship{ get; set; } + public SolenFriendship SolenFriendship { get; set; } - #endregion - - #region MyRunUO Invalidation - - public bool ChangedMyRunUO{ get; set; } + public bool ChangedMyRunUO { get; set; } public override void OnKillsChange(int oldValue) { @@ -3903,12 +3788,8 @@ namespace Server.Mobiles SentHonorContext?.Cancel(); } - #endregion - - #region Fastwalk Prevention - - private static bool FastwalkPrevention = true; // Is fastwalk prevention enabled? - private static int FastwalkThreshold = 400; // Fastwalk prevention will become active after 0.4 seconds + private static readonly bool FastwalkPrevention = true; // Is fastwalk prevention enabled? + private static readonly int FastwalkThreshold = 400; // Fastwalk prevention will become active after 0.4 seconds private long m_NextMovementTime; private bool m_HasMoved; @@ -3962,10 +3843,6 @@ namespace Server.Mobiles return ts < FastwalkThreshold ? TimeSpan.Zero : TimeSpan.FromTicks(ts); } - #endregion - - #region Enemy of One - private Type m_EnemyOfOneType; public Type EnemyOfOneType @@ -3985,7 +3862,7 @@ namespace Server.Mobiles } } - public bool WaitingForEnemy{ get; set; } + public bool WaitingForEnemy { get; set; } private void DeltaEnemies(Type oldType, Type newType) { @@ -4008,10 +3885,6 @@ namespace Server.Mobiles } } - #endregion - - #region Hair and beard mods - private int m_HairModID = -1, m_HairModHue; private int m_BeardModID = -1, m_BeardModHue; @@ -4032,7 +3905,7 @@ namespace Server.Mobiles { if (hair) { - //TODO Verification? + // TODO Verification? HairItemID = id; HairHue = hue; } @@ -4053,7 +3926,7 @@ namespace Server.Mobiles else FacialHairItemID = 0; - //if ( id != 0 ) + // if (id != 0) CreateHair(hair, id, hue); id = -1; @@ -4071,48 +3944,40 @@ namespace Server.Mobiles CreateHair(hair, id, 0); } - #endregion + public DateTime LastSacrificeGain { get; set; } - #region Virtues - - public DateTime LastSacrificeGain{ get; set; } - - public DateTime LastSacrificeLoss{ get; set; } + public DateTime LastSacrificeLoss { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int AvailableResurrects{ get; set; } + public int AvailableResurrects { get; set; } private DateTime m_NextJustAward; - public DateTime LastJusticeLoss{ get; set; } + public DateTime LastJusticeLoss { get; set; } - public List JusticeProtectors{ get; set; } + public List JusticeProtectors { get; set; } - public DateTime LastCompassionLoss{ get; set; } + public DateTime LastCompassionLoss { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime NextCompassionDay{ get; set; } + public DateTime NextCompassionDay { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int CompassionGains{ get; set; } + public int CompassionGains { get; set; } - public DateTime LastValorLoss{ get; set; } + public DateTime LastValorLoss { get; set; } public DateTime m_hontime; - public DateTime LastHonorLoss{ get; set; } + public DateTime LastHonorLoss { get; set; } - public DateTime LastHonorUse{ get; set; } + public DateTime LastHonorUse { get; set; } - public bool HonorActive{ get; set; } + public bool HonorActive { get; set; } - public HonorContext ReceivedHonorContext{ get; set; } + public HonorContext ReceivedHonorContext { get; set; } - public HonorContext SentHonorContext{ get; set; } - - #endregion - - #region Young system + public HonorContext SentHonorContext { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Young @@ -4135,8 +4000,6 @@ namespace Server.Mobiles suffix = $"{suffix} (Young)"; } - #region Ethics - if (EthicPlayer != null) { if (suffix.Length == 0) @@ -4145,8 +4008,6 @@ namespace Server.Mobiles suffix = $"{suffix} {EthicPlayer.Ethic.Definition.Adjunct.String}"; } - #endregion - if (Core.ML && Map == Faction.Facet) { Faction faction = Faction.Find(this); @@ -4211,7 +4072,7 @@ namespace Server.Mobiles return false; } - private static Point3D[] m_TrammelDeathDestinations = + private static readonly Point3D[] m_TrammelDeathDestinations = { new Point3D(1481, 1612, 20), new Point3D(2708, 2153, 0), @@ -4230,7 +4091,7 @@ namespace Server.Mobiles new Point3D(3665, 2587, 0) }; - private static Point3D[] m_IlshenarDeathDestinations = + private static readonly Point3D[] m_IlshenarDeathDestinations = { new Point3D(1216, 468, -13), new Point3D(723, 1367, -60), @@ -4243,13 +4104,13 @@ namespace Server.Mobiles new Point3D(1722, 219, 96) }; - private static Point3D[] m_MalasDeathDestinations = + private static readonly Point3D[] m_MalasDeathDestinations = { new Point3D(2079, 1376, -70), new Point3D(944, 519, -71) }; - private static Point3D[] m_TokunoDeathDestinations = + private static readonly Point3D[] m_TokunoDeathDestinations = { new Point3D(1166, 801, 27), new Point3D(782, 1228, 25), @@ -4319,11 +4180,7 @@ namespace Server.Mobiles SendGump(new YoungDeathNotice()); } - #endregion - - #region Speech log - - public SpeechLog SpeechLog{ get; private set; } + public SpeechLog SpeechLog { get; private set; } public override void OnSpeech(SpeechEventArgs e) { @@ -4336,10 +4193,6 @@ namespace Server.Mobiles } } - #endregion - - #region Champion Titles - [CommandProperty(AccessLevel.GameMaster)] public bool DisplayChampionTitle { @@ -4348,7 +4201,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public ChampionTitleInfo ChampionTitles{ get; private set; } + public ChampionTitleInfo ChampionTitles { get; private set; } private void ToggleChampionTitleDisplay() { @@ -4382,24 +4235,24 @@ namespace Server.Mobiles switch (version) { case 0: - { - Harrower = reader.ReadEncodedInt(); - - int length = reader.ReadEncodedInt(); - m_Values = new TitleInfo[length]; - - for (int i = 0; i < length; i++) m_Values[i] = new TitleInfo(reader); - - if (m_Values.Length != ChampionSpawnInfo.Table.Length) { - TitleInfo[] oldValues = m_Values; - m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length]; + Harrower = reader.ReadEncodedInt(); - for (int i = 0; i < m_Values.Length && i < oldValues.Length; i++) m_Values[i] = oldValues[i]; + int length = reader.ReadEncodedInt(); + m_Values = new TitleInfo[length]; + + for (int i = 0; i < length; i++) m_Values[i] = new TitleInfo(reader); + + if (m_Values.Length != ChampionSpawnInfo.Table.Length) + { + TitleInfo[] oldValues = m_Values; + m_Values = new TitleInfo[ChampionSpawnInfo.Table.Length]; + + for (int i = 0; i < m_Values.Length && i < oldValues.Length; i++) m_Values[i] = oldValues[i]; + } + + break; } - - break; - } } } @@ -4460,7 +4313,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public int Harrower{ get; set; } + public int Harrower { get; set; } public int GetValue(ChampionSpawnType type) => GetValue((int)type); @@ -4574,7 +4427,7 @@ namespace Server.Mobiles } public static void - AwardHarrowerTitle(PlayerMobile pm) //Called when killing a harrower. Will give a minimum of 1 point. + AwardHarrowerTitle(PlayerMobile pm) // Called when killing a harrower. Will give a minimum of 1 point. { ChampionTitleInfo t = pm.ChampionTitles; if (t == null) @@ -4584,7 +4437,7 @@ namespace Server.Mobiles int count = 1 + t.m_Values.Count(t1 => t1.Value > 900); - t.Harrower = Math.Max(count, t.Harrower); //Harrower titles never decay. + t.Harrower = Math.Max(count, t.Harrower); // Harrower titles never decay. } private class TitleInfo @@ -4600,17 +4453,17 @@ namespace Server.Mobiles switch (version) { case 0: - { - Value = reader.ReadEncodedInt(); - LastDecay = reader.ReadDateTime(); - break; - } + { + Value = reader.ReadEncodedInt(); + LastDecay = reader.ReadDateTime(); + break; + } } } - public int Value{ get; set; } + public int Value { get; set; } - public DateTime LastDecay{ get; set; } + public DateTime LastDecay { get; set; } public static void Serialize(IGenericWriter writer, TitleInfo info) { @@ -4622,10 +4475,6 @@ namespace Server.Mobiles } } - #endregion - - #region Recipes - private Dictionary m_AcquiredRecipes; public virtual bool HasRecipe(Recipe r) => r != null && HasRecipe(r.ID); @@ -4653,10 +4502,6 @@ namespace Server.Mobiles [CommandProperty(AccessLevel.GameMaster)] public int KnownRecipes => m_AcquiredRecipes?.Count ?? 0; - #endregion - - #region Buff Icons - public void ResendBuffs() { if (!BuffInfo.Enabled || m_BuffTable == null) @@ -4674,7 +4519,7 @@ namespace Server.Mobiles if (!BuffInfo.Enabled || b == null) return; - RemoveBuff(b); //Check & subsequently remove the old one. + RemoveBuff(b); // Check & subsequently remove the old one. m_BuffTable ??= new Dictionary(); @@ -4710,7 +4555,5 @@ namespace Server.Mobiles if (m_BuffTable.Count <= 0) m_BuffTable = null; } - - #endregion } } diff --git a/Projects/Scripts/Mobiles/Special/Barracoon.cs b/Projects/Scripts/Mobiles/Special/Barracoon.cs index d9e68edc0..b7cbed1f7 100644 --- a/Projects/Scripts/Mobiles/Special/Barracoon.cs +++ b/Projects/Scripts/Mobiles/Special/Barracoon.cs @@ -129,7 +129,7 @@ namespace Server.Mobiles if (map == null) return; - IPooledEnumerable eable = GetMobilesInRange(10); + IPooledEnumerable eable = GetMobilesInRange(10); int rats = eable.Aggregate(0, (c, m) => c + (m is Ratman || m is RatmanArcher || m is RatmanMage ? 1 : 0)); eable.Free(); @@ -158,13 +158,13 @@ namespace Server.Mobiles public void DoSpecialAbility(Mobile target) { - if (target?.Deleted != false) //sanity + if (target?.Deleted != false) // sanity return; - if (0.6 >= Utility.RandomDouble()) // 60% chance to polymorph attacker into a ratman + if (Utility.RandomDouble() <= 0.6) // 60% chance to polymorph attacker into a ratman Polymorph(target); - if (0.2 >= Utility.RandomDouble()) // 20% chance to more ratmen + if (Utility.RandomDouble() <= 0.2) // 20% chance to more ratmen SpawnRatmen(target); if (Hits < 500 && !IsBodyMod) // Baracoon is low on life, polymorph into a ratman @@ -201,7 +201,7 @@ namespace Server.Mobiles private class ExpirePolymorphTimer : Timer { - private Mobile m_Owner; + private readonly Mobile m_Owner; public ExpirePolymorphTimer(Mobile owner) : base(TimeSpan.FromMinutes(3.0)) { diff --git a/Projects/Scripts/Mobiles/Special/BaseChampion.cs b/Projects/Scripts/Mobiles/Special/BaseChampion.cs index dc1f93034..340f5f242 100644 --- a/Projects/Scripts/Mobiles/Special/BaseChampion.cs +++ b/Projects/Scripts/Mobiles/Special/BaseChampion.cs @@ -7,8 +7,7 @@ namespace Server.Mobiles { public abstract class BaseChampion : BaseCreature { - public BaseChampion(AIType aiType, FightMode mode = FightMode.Closest) : - base(aiType, mode, 18, 1, 0.1, 0.2) + public BaseChampion(AIType aiType, FightMode mode = FightMode.Closest) : base(aiType, mode, 18, 1, 0.1, 0.2) { } @@ -19,12 +18,12 @@ namespace Server.Mobiles public override bool CanMoveOverObstacles => true; public override bool CanDestroyObstacles => true; - public abstract ChampionSkullType SkullType{ get; } + public abstract ChampionSkullType SkullType { get; } - public abstract Type[] UniqueList{ get; } - public abstract Type[] SharedList{ get; } - public abstract Type[] DecorativeList{ get; } - public abstract MonsterStatuetteType[] StatueTypes{ get; } + public abstract Type[] UniqueList { get; } + public abstract Type[] SharedList { get; } + public abstract Type[] DecorativeList { get; } + public abstract MonsterStatuetteType[] StatueTypes { get; } public virtual bool NoGoodies => false; @@ -45,11 +44,11 @@ namespace Server.Mobiles public Item GetArtifact() { double random = Utility.RandomDouble(); - if (0.05 >= random) + if (random <= 0.05) return CreateArtifact(UniqueList); - if (0.15 >= random) + if (random <= 0.15) return CreateArtifact(SharedList); - if (0.30 >= random) + if (random <= 0.30) return CreateArtifact(DecorativeList); return null; @@ -80,9 +79,9 @@ namespace Server.Mobiles int level; double random = Utility.RandomDouble(); - if (0.05 >= random) + if (random <= 0.05) level = 20; - else if (0.4 >= random) + else if (random <= 0.4) level = 15; else level = 10; @@ -127,7 +126,7 @@ namespace Server.Mobiles else m.SendLocalizedMessage(1054030); // You have gained in Valor! - //No delay on Valor gains + // No delay on Valor gains } } @@ -152,7 +151,7 @@ namespace Server.Mobiles public static void GivePowerScrollTo(Mobile m, PowerScroll ps) { - if (ps == null || m == null) //sanity + if (ps == null || m == null) // sanity return; m.SendLocalizedMessage(1049524); // You have received a scroll of power! @@ -221,13 +220,13 @@ namespace Server.Mobiles if (map != null) for (int x = -12; x <= 12; ++x) - for (int y = -12; y <= 12; ++y) - { - double dist = Math.Sqrt(x * x + y * y); + for (int y = -12; y <= 12; ++y) + { + double dist = Math.Sqrt(x * x + y * y); - if (dist <= 12) - new GoodiesTimer(map, X + x, Y + y).Start(); - } + if (dist <= 12) + new GoodiesTimer(map, X + x, Y + y).Start(); + } } return base.OnBeforeDeath(); @@ -237,7 +236,7 @@ namespace Server.Mobiles { if (Map == Map.Felucca) { - //TODO: Confirm SE change or AoS one too? + // TODO: Confirm SE change or AoS one too? List rights = GetLootingRights(DamageEntries, HitsMax); List toGive = new List(); @@ -260,8 +259,9 @@ namespace Server.Mobiles private class GoodiesTimer : Timer { - private Map m_Map; - private int m_X, m_Y; + private readonly Map m_Map; + private readonly int m_X; + private readonly int m_Y; public GoodiesTimer(Map map, int x, int y) : base(TimeSpan.FromSeconds(Utility.RandomDouble() * 10.0)) { @@ -290,32 +290,32 @@ namespace Server.Mobiles g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); - if (0.5 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.5) switch (Utility.Random(3)) { case 0: // Fire column - { - Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x3709, 10, 30, 5052); - Effects.PlaySound(g, g.Map, 0x208); + { + Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x3709, 10, 30, 5052); + Effects.PlaySound(g, g.Map, 0x208); - break; - } + break; + } case 1: // Explosion - { - Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36BD, 20, 10, 5044); - Effects.PlaySound(g, g.Map, 0x307); + { + Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36BD, 20, 10, 5044); + Effects.PlaySound(g, g.Map, 0x307); - break; - } + break; + } case 2: // Ball of fire - { - Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36FE, 10, 10, 5052); + { + Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36FE, 10, 10, 5052); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Special/BaseShieldGuard.cs b/Projects/Scripts/Mobiles/Special/BaseShieldGuard.cs index d8ec1a1f3..14519bce9 100644 --- a/Projects/Scripts/Mobiles/Special/BaseShieldGuard.cs +++ b/Projects/Scripts/Mobiles/Special/BaseShieldGuard.cs @@ -91,10 +91,10 @@ namespace Server.Mobiles { } - public abstract int Keyword{ get; } - public abstract BaseShield Shield{ get; } - public abstract int SignupNumber{ get; } - public abstract GuildType Type{ get; } + public abstract int Keyword { get; } + public abstract BaseShield Shield { get; } + public abstract int SignupNumber { get; } + public abstract GuildType Type { get; } public override bool HandlesOnSpeech(Mobile from) { @@ -123,7 +123,7 @@ namespace Server.Mobiles Item twoHanded = from.FindItemOnLayer(Layer.TwoHanded); if (pack?.FindItemByType(shield.GetType()) != null || - twoHanded != null && shield.GetType().IsInstanceOfType(twoHanded)) + (twoHanded != null && shield.GetType().IsInstanceOfType(twoHanded))) { Say(1007110); // Why dost thou ask about virtue guards when thou art one? shield.Delete(); diff --git a/Projects/Scripts/Mobiles/Special/Dummy.cs b/Projects/Scripts/Mobiles/Special/Dummy.cs index 74e7bc385..97c6c65d9 100644 --- a/Projects/Scripts/Mobiles/Special/Dummy.cs +++ b/Projects/Scripts/Mobiles/Special/Dummy.cs @@ -128,7 +128,7 @@ namespace Server.Mobiles private class AutokillTimer : Timer { - private Dummy m_Owner; + private readonly Dummy m_Owner; public AutokillTimer(Dummy owner) : base(TimeSpan.FromMinutes(5.0)) { diff --git a/Projects/Scripts/Mobiles/Special/Harrower.cs b/Projects/Scripts/Mobiles/Special/Harrower.cs index 027f45c82..c4116dcb8 100644 --- a/Projects/Scripts/Mobiles/Special/Harrower.cs +++ b/Projects/Scripts/Mobiles/Special/Harrower.cs @@ -8,7 +8,7 @@ namespace Server.Mobiles { public class Harrower : BaseCreature { - private static SpawnEntry[] m_Entries = + private static readonly SpawnEntry[] m_Entries = { new SpawnEntry(new Point3D(5242, 945, -40), new Point3D(1176, 2638, 0)), // Destard new SpawnEntry(new Point3D(5225, 798, 0), new Point3D(1176, 2638, 0)), // Destard @@ -93,7 +93,7 @@ namespace Server.Mobiles public Type[] SharedList => new[] { typeof(TheRobeOfBritanniaAri) }; public Type[] DecorativeList => new[] { typeof(EvilIdolSkull), typeof(SkullPole) }; - public static List Instances{ get; } = new List(); + public static List Instances { get; } = new List(); public static bool CanSpawn => Instances.Count == 0; @@ -219,16 +219,16 @@ namespace Server.Mobiles switch (version) { case 0: - { - m_TrueForm = reader.ReadBool(); - m_GateItem = reader.ReadItem(); - m_Tentacles = reader.ReadStrongMobileList(); + { + m_TrueForm = reader.ReadBool(); + m_GateItem = reader.ReadItem(); + m_Tentacles = reader.ReadStrongMobileList(); - m_Timer = new TeleportTimer(this); - m_Timer.Start(); + m_Timer = new TeleportTimer(this); + m_Timer.Start(); - break; - } + break; + } } } @@ -262,13 +262,13 @@ namespace Server.Mobiles int level; double random = Utility.RandomDouble(); - if (0.1 >= random) + if (random <= 0.1) level = 25; - else if (0.25 >= random) + else if (random <= 0.25) level = 20; - else if (0.45 >= random) + else if (random <= 0.45) level = 15; - else if (0.70 >= random) + else if (random <= 0.70) level = 10; else level = 5; @@ -326,13 +326,13 @@ namespace Server.Mobiles if (map != null) for (int x = -16; x <= 16; ++x) - for (int y = -16; y <= 16; ++y) - { - double dist = Math.Sqrt(x * x + y * y); + for (int y = -16; y <= 16; ++y) + { + double dist = Math.Sqrt(x * x + y * y); - if (dist <= 16) - new GoodiesTimer(map, X + x, Y + y).Start(); - } + if (dist <= 16) + new GoodiesTimer(map, X + x, Y + y).Start(); + } m_DamageEntries = new Dictionary(); @@ -437,18 +437,18 @@ namespace Server.Mobiles 1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. } - public bool IsEligible(Mobile m, Item Artifact) => + public bool IsEligible(Mobile m, Item artifact) => m.Player && m.Alive && m.InRange(Location, 32) && - m.Backpack?.CheckHold(m, Artifact, false) == true; + m.Backpack?.CheckHold(m, artifact, false) == true; public Item GetArtifact() { double random = Utility.RandomDouble(); - if (0.05 >= random) + if (random <= 0.05) return CreateArtifact(UniqueList); - if (0.15 >= random) + if (random <= 0.15) return CreateArtifact(SharedList); - if (0.30 >= random) + if (random <= 0.30) return CreateArtifact(DecorativeList); return null; @@ -468,8 +468,8 @@ namespace Server.Mobiles private class SpawnEntry { - public Point3D m_Entrance; - public Point3D m_Location; + public readonly Point3D m_Entrance; + public readonly Point3D m_Location; public SpawnEntry(Point3D loc, Point3D ent) { @@ -480,7 +480,7 @@ namespace Server.Mobiles private class TeleportTimer : Timer { - private static int[] m_Offsets = + private static readonly int[] m_Offsets = { -1, -1, -1, 0, @@ -492,7 +492,7 @@ namespace Server.Mobiles 1, 1 }; - private Mobile m_Owner; + private readonly Mobile m_Owner; public TeleportTimer(Mobile owner) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) { @@ -514,7 +514,7 @@ namespace Server.Mobiles if (map == null) return; - if (0.25 < Utility.RandomDouble()) + if (Utility.RandomDouble() > 0.25) return; Mobile toTeleport = m_Owner.GetMobilesInRange(16) @@ -571,8 +571,9 @@ namespace Server.Mobiles private class GoodiesTimer : Timer { - private Map m_Map; - private int m_X, m_Y; + private readonly Map m_Map; + private readonly int m_X; + private readonly int m_Y; public GoodiesTimer(Map map, int x, int y) : base(TimeSpan.FromSeconds(Utility.RandomDouble() * 10.0)) { @@ -603,32 +604,32 @@ namespace Server.Mobiles g.MoveToWorld(new Point3D(m_X, m_Y, z), m_Map); - if (0.5 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.5) switch (Utility.Random(3)) { case 0: // Fire column - { - Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x3709, 10, 30, 5052); - Effects.PlaySound(g, g.Map, 0x208); + { + Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x3709, 10, 30, 5052); + Effects.PlaySound(g, g.Map, 0x208); - break; - } + break; + } case 1: // Explosion - { - Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36BD, 20, 10, 5044); - Effects.PlaySound(g, g.Map, 0x307); + { + Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36BD, 20, 10, 5044); + Effects.PlaySound(g, g.Map, 0x307); - break; - } + break; + } case 2: // Ball of fire - { - Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), - 0x36FE, 10, 10, 5052); + { + Effects.SendLocationParticles(EffectItem.Create(g.Location, g.Map, EffectItem.DefaultDuration), + 0x36FE, 10, 10, 5052); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Special/HarrowerTentacles.cs b/Projects/Scripts/Mobiles/Special/HarrowerTentacles.cs index 4898184bf..b5551c05c 100644 --- a/Projects/Scripts/Mobiles/Special/HarrowerTentacles.cs +++ b/Projects/Scripts/Mobiles/Special/HarrowerTentacles.cs @@ -7,8 +7,7 @@ namespace Server.Mobiles private DrainTimer m_Timer; [Constructible] - public HarrowerTentacles(Mobile harrower = null) : - base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) + public HarrowerTentacles(Mobile harrower = null) : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4) { Harrower = harrower; Body = 129; @@ -58,7 +57,7 @@ namespace Server.Mobiles public override string CorpseName => "a tentacles corpse"; [CommandProperty(AccessLevel.GameMaster)] - public Mobile Harrower{ get; set; } + public Mobile Harrower { get; set; } public override string DefaultName => "tentacles of the harrower"; @@ -107,14 +106,14 @@ namespace Server.Mobiles switch (version) { case 0: - { - Harrower = reader.ReadMobile(); + { + Harrower = reader.ReadMobile(); - m_Timer = new DrainTimer(this); - m_Timer.Start(); + m_Timer = new DrainTimer(this); + m_Timer.Start(); - break; - } + break; + } } } @@ -128,7 +127,7 @@ namespace Server.Mobiles private class DrainTimer : Timer { - private HarrowerTentacles m_Owner; + private readonly HarrowerTentacles m_Owner; public DrainTimer(HarrowerTentacles owner) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) { @@ -148,7 +147,7 @@ namespace Server.Mobiles foreach (Mobile m in eable) { - if (m == m_Owner || !(m_Owner.CanBeHarmful(m) || m.Player && m.Alive)) + if (m == m_Owner || !(m_Owner.CanBeHarmful(m) || (m.Player && m.Alive))) continue; if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != m_Owner.Team)) diff --git a/Projects/Scripts/Mobiles/Special/LordOaks.cs b/Projects/Scripts/Mobiles/Special/LordOaks.cs index 67b430df2..9156cd39e 100644 --- a/Projects/Scripts/Mobiles/Special/LordOaks.cs +++ b/Projects/Scripts/Mobiles/Special/LordOaks.cs @@ -145,7 +145,7 @@ namespace Server.Mobiles { scalar *= 0.1; - if (0.1 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.1) SpawnPixies(caster); } } @@ -165,7 +165,7 @@ namespace Server.Mobiles CheckQueen(); - if (m_Queen != null && 0.1 >= Utility.RandomDouble()) + if (m_Queen != null && Utility.RandomDouble() <= 0.1) SpawnPixies(attacker); attacker.Damage(Utility.Random(20, 10), this); @@ -192,12 +192,12 @@ namespace Server.Mobiles switch (version) { case 0: - { - m_Queen = reader.ReadMobile(); - m_SpawnedQueen = reader.ReadBool(); + { + m_Queen = reader.ReadMobile(); + m_SpawnedQueen = reader.ReadBool(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Special/Neira.cs b/Projects/Scripts/Mobiles/Special/Neira.cs index fcd3c6031..2cdd7ba8b 100644 --- a/Projects/Scripts/Mobiles/Special/Neira.cs +++ b/Projects/Scripts/Mobiles/Special/Neira.cs @@ -61,7 +61,7 @@ namespace Server.Mobiles AddItem(weapon); - //new SkeletalMount().Rider = this; + // new SkeletalMount().Rider = this; AddItem(new VirtualMountItem(this)); } @@ -142,7 +142,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.1 >= Utility.RandomDouble()) // 10% chance to drop or throw an unholy bone + if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone AddUnholyBone(defender, 0.25); CheckSpeedBoost(); @@ -152,7 +152,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (0.1 >= Utility.RandomDouble()) // 10% chance to drop or throw an unholy bone + if (Utility.RandomDouble() <= 0.1) // 10% chance to drop or throw an unholy bone AddUnholyBone(attacker, 0.25); } @@ -160,7 +160,7 @@ namespace Server.Mobiles { base.AlterDamageScalarFrom(caster, ref scalar); - if (0.1 >= Utility.RandomDouble()) // 10% chance to throw an unholy bone + if (Utility.RandomDouble() <= 0.1) // 10% chance to throw an unholy bone AddUnholyBone(caster, 1.0); } @@ -198,16 +198,16 @@ namespace Server.Mobiles switch (version) { case 1: - { - m_SpeedBoost = reader.ReadBool(); - break; - } + { + m_SpeedBoost = reader.ReadBool(); + break; + } } } private class VirtualMount : IMount { - private VirtualMountItem m_Item; + private readonly VirtualMountItem m_Item; public VirtualMount(VirtualMountItem item) => m_Item = item; @@ -224,7 +224,7 @@ namespace Server.Mobiles private class VirtualMountItem : Item, IMountItem { - private VirtualMount m_Mount; + private readonly VirtualMount m_Mount; public VirtualMountItem(Mobile mob) : base(0x3EBB) @@ -241,7 +241,7 @@ namespace Server.Mobiles : base(serial) => m_Mount = new VirtualMount(this); - public Mobile Rider{ get; private set; } + public Mobile Rider { get; private set; } public IMount Mount => m_Mount; @@ -269,8 +269,8 @@ namespace Server.Mobiles private class DelayTimer : Timer { - private Mobile m_Mobile; - private Mobile m_Target; + private readonly Mobile m_Mobile; + private readonly Mobile m_Target; public DelayTimer(Mobile m, Mobile target) : base(TimeSpan.FromSeconds(1.0)) { diff --git a/Projects/Scripts/Mobiles/Special/Paragon.cs b/Projects/Scripts/Mobiles/Special/Paragon.cs index 9020f46e9..682932e9e 100644 --- a/Projects/Scripts/Mobiles/Special/Paragon.cs +++ b/Projects/Scripts/Mobiles/Special/Paragon.cs @@ -14,8 +14,8 @@ namespace Server.Mobiles Map.Ilshenar }; - private static TimeSpan FastRegenRate = TimeSpan.FromSeconds(.5); - private static TimeSpan CPUSaverRate = TimeSpan.FromSeconds(2); + private static readonly TimeSpan FastRegenRate = TimeSpan.FromSeconds(.5); + private static readonly TimeSpan CPUSaverRate = TimeSpan.FromSeconds(2); public static Type[] Artifacts = { @@ -191,7 +191,7 @@ namespace Server.Mobiles private class ParagonStamRegen : Timer { - private BaseCreature m_Owner; + private readonly BaseCreature m_Owner; public ParagonStamRegen(Mobile m) : base(FastRegenRate, FastRegenRate) diff --git a/Projects/Scripts/Mobiles/Special/Rikktor.cs b/Projects/Scripts/Mobiles/Special/Rikktor.cs index 47841c3c9..0d320c845 100644 --- a/Projects/Scripts/Mobiles/Special/Rikktor.cs +++ b/Projects/Scripts/Mobiles/Special/Rikktor.cs @@ -83,7 +83,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.2 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.2) Earthquake(); } @@ -100,7 +100,7 @@ namespace Server.Mobiles foreach (Mobile m in eable) { - if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + if (m == this || !(CanBeHarmful(m) || (m.Player && m.Alive))) continue; if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) diff --git a/Projects/Scripts/Mobiles/Special/Semidar.cs b/Projects/Scripts/Mobiles/Special/Semidar.cs index 3e9901c25..bd71899a5 100644 --- a/Projects/Scripts/Mobiles/Special/Semidar.cs +++ b/Projects/Scripts/Mobiles/Special/Semidar.cs @@ -90,7 +90,7 @@ namespace Server.Mobiles foreach (Mobile m in eable) { - if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + if (m == this || !(CanBeHarmful(m) || (m.Player && m.Alive))) continue; if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) @@ -116,7 +116,7 @@ namespace Server.Mobiles { base.OnGaveMeleeAttack(defender); - if (0.25 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.25) DrainLife(); } @@ -124,7 +124,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (0.25 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.25) DrainLife(); } diff --git a/Projects/Scripts/Mobiles/Special/Serado.cs b/Projects/Scripts/Mobiles/Special/Serado.cs index 0a5076fea..c3aef93ae 100644 --- a/Projects/Scripts/Mobiles/Special/Serado.cs +++ b/Projects/Scripts/Mobiles/Special/Serado.cs @@ -121,7 +121,7 @@ namespace Server.Mobiles if (Map == null) return; - if (!(0.2 > Utility.RandomDouble())) + if (!(Utility.RandomDouble() < 0.2)) return; Mobile target = null; @@ -150,7 +150,7 @@ namespace Server.Mobiles foreach (Mobile m in eable) { - if (m == this || !(CanBeHarmful(m) || m.Player && m.Alive)) + if (m == this || !(CanBeHarmful(m) || (m.Player && m.Alive))) continue; if (!(m is BaseCreature bc) || !(bc.Controlled || bc.Summoned || bc.Team != Team)) diff --git a/Projects/Scripts/Mobiles/Special/Silvani.cs b/Projects/Scripts/Mobiles/Special/Silvani.cs index df19aa7eb..8e125a7c2 100644 --- a/Projects/Scripts/Mobiles/Special/Silvani.cs +++ b/Projects/Scripts/Mobiles/Special/Silvani.cs @@ -76,7 +76,7 @@ namespace Server.Mobiles public override void AlterDamageScalarFrom(Mobile caster, ref double scalar) { - if (0.1 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.1) SpawnPixies(caster); } @@ -93,7 +93,7 @@ namespace Server.Mobiles { base.OnGotMeleeAttack(attacker); - if (0.1 >= Utility.RandomDouble()) + if (Utility.RandomDouble() <= 0.1) SpawnPixies(attacker); } diff --git a/Projects/Scripts/Mobiles/Special/Wanderer.cs b/Projects/Scripts/Mobiles/Special/Wanderer.cs index 343534275..1619a0072 100644 --- a/Projects/Scripts/Mobiles/Special/Wanderer.cs +++ b/Projects/Scripts/Mobiles/Special/Wanderer.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Wanderer : Mobile { - private Timer m_Timer; + private readonly Timer m_Timer; [Constructible] public Wanderer() @@ -47,7 +47,7 @@ namespace Server.Mobiles private class InternalTimer : Timer { private int m_Count; - private Wanderer m_Owner; + private readonly Wanderer m_Owner; public InternalTimer(Wanderer owner) : base(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.1)) => m_Owner = owner; diff --git a/Projects/Scripts/Mobiles/Townfolk/Actor.cs b/Projects/Scripts/Mobiles/Townfolk/Actor.cs index a4d9dbcb8..84810e4b9 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Actor.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Actor.cs @@ -46,7 +46,6 @@ namespace Server.Mobiles { } - public override bool ClickTitle => false; public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Mobiles/Townfolk/Artist.cs b/Projects/Scripts/Mobiles/Townfolk/Artist.cs index 06c17647c..5b10331db 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Artist.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Artist.cs @@ -12,12 +12,10 @@ namespace Server.Mobiles SetSkill(SkillName.Healing, 36, 68); - SpeechHue = Utility.RandomDyedHue(); Title = "the artist"; Hue = Race.Human.RandomSkinHue(); - if (Female = Utility.RandomBool()) { Body = 0x191; @@ -45,7 +43,6 @@ namespace Server.Mobiles AddItem(pack); } - public Artist(Serial serial) : base(serial) { diff --git a/Projects/Scripts/Mobiles/Townfolk/Banker.cs b/Projects/Scripts/Mobiles/Townfolk/Banker.cs index 6a5df73ba..50929a0cc 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Banker.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Banker.cs @@ -10,7 +10,7 @@ namespace Server.Mobiles { public class Banker : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Banker() : base("the banker") @@ -66,7 +66,7 @@ namespace Server.Mobiles if (balance > int.MaxValue) { - gold = checks = new Item[0]; + gold = checks = Array.Empty(); return int.MaxValue; } } @@ -84,7 +84,7 @@ namespace Server.Mobiles } else { - gold = checks = new Item[0]; + gold = checks = Array.Empty(); } return Math.Max(0, (int)Math.Min(int.MaxValue, balance)); @@ -265,139 +265,139 @@ namespace Server.Mobiles switch (keyword) { case 0x0000: // *withdraw* - { - e.Handled = true; - - if (e.Mobile.Criminal) { - Say(500389); // I will not do business with a criminal! + e.Handled = true; + + if (e.Mobile.Criminal) + { + Say(500389); // I will not do business with a criminal! + break; + } + + string[] split = e.Speech.Split(' '); + + if (split.Length >= 2) + { + Container pack = e.Mobile.Backpack; + + if (!int.TryParse(split[1], out int amount)) + break; + + if ((!Core.ML && amount > 5000) || (Core.ML && amount > 60000)) + { + Say(500381); // Thou canst not withdraw so much at one time! + } + else if (pack?.Deleted != false || !(pack.TotalWeight < pack.MaxWeight) || + !(pack.TotalItems < pack.MaxItems)) + { + Say(1048147); // Your backpack can't hold anything else. + } + else if (amount > 0) + { + BankBox box = e.Mobile.FindBankNoCreate(); + + if (box == null || !Withdraw(e.Mobile, amount)) + { + Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! + } + else + { + pack.DropItem(new Gold(amount)); + + Say(1010005); // Thou hast withdrawn gold from thy account. + } + } + } + break; } - - string[] split = e.Speech.Split(' '); - - if (split.Length >= 2) - { - Container pack = e.Mobile.Backpack; - - if (!int.TryParse(split[1], out int amount)) - break; - - if (!Core.ML && amount > 5000 || Core.ML && amount > 60000) - { - Say(500381); // Thou canst not withdraw so much at one time! - } - else if (pack?.Deleted != false || !(pack.TotalWeight < pack.MaxWeight) || - !(pack.TotalItems < pack.MaxItems)) - { - Say(1048147); // Your backpack can't hold anything else. - } - else if (amount > 0) - { - BankBox box = e.Mobile.FindBankNoCreate(); - - if (box == null || !Withdraw(e.Mobile, amount)) - { - Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! - } - else - { - pack.DropItem(new Gold(amount)); - - Say(1010005); // Thou hast withdrawn gold from thy account. - } - } - } - - break; - } case 0x0001: // *balance* - { - e.Handled = true; - - if (e.Mobile.Criminal) { - Say(500389); // I will not do business with a criminal! + e.Handled = true; + + if (e.Mobile.Criminal) + { + Say(500389); // I will not do business with a criminal! + break; + } + + if (AccountGold.Enabled && e.Mobile.Account != null) + Say(1155855, + $"{e.Mobile.Account.TotalPlat:#,0}\t{e.Mobile.Account.TotalGold:#,0}"); // Thy current bank balance is ~1_AMOUNT~ platinum and ~2_AMOUNT~ gold. + else + Say(1042759, + GetBalance(e.Mobile).ToString("#,0")); // Thy current bank balance is ~1_AMOUNT~ gold. + break; } - - if (AccountGold.Enabled && e.Mobile.Account != null) - Say(1155855, - $"{e.Mobile.Account.TotalPlat:#,0}\t{e.Mobile.Account.TotalGold:#,0}"); // Thy current bank balance is ~1_AMOUNT~ platinum and ~2_AMOUNT~ gold. - else - Say(1042759, - GetBalance(e.Mobile).ToString("#,0")); // Thy current bank balance is ~1_AMOUNT~ gold. - - break; - } case 0x0002: // *bank* - { - e.Handled = true; - - if (e.Mobile.Criminal) { - Say(500378); // Thou art a criminal and cannot access thy bank box. + e.Handled = true; + + if (e.Mobile.Criminal) + { + Say(500378); // Thou art a criminal and cannot access thy bank box. + break; + } + + e.Mobile.BankBox.Open(); + break; } - - e.Mobile.BankBox.Open(); - - break; - } case 0x0003: // *check* - { - e.Handled = true; - - if (AccountGold.Enabled) - break; - - if (e.Mobile.Criminal) { - Say(500389); // I will not do business with a criminal! - break; - } + e.Handled = true; - string[] split = e.Speech.Split(' '); - - if (split.Length >= 2) - { - if (!int.TryParse(split[1], out int amount)) + if (AccountGold.Enabled) break; - if (amount < 5000) + if (e.Mobile.Criminal) { - Say(1010006); // We cannot create checks for such a paltry amount of gold! + Say(500389); // I will not do business with a criminal! + break; } - else if (amount > 1000000) - { - Say(1010007); // Our policies prevent us from creating checks worth that much! - } - else - { - BankCheck check = new BankCheck(amount); - BankBox box = e.Mobile.BankBox; + string[] split = e.Speech.Split(' '); - if (!box.TryDropItem(e.Mobile, check, false)) + if (split.Length >= 2) + { + if (!int.TryParse(split[1], out int amount)) + break; + + if (amount < 5000) { - Say(500386); // There's not enough room in your bankbox for the check! - check.Delete(); + Say(1010006); // We cannot create checks for such a paltry amount of gold! } - else if (!box.ConsumeTotal(typeof(Gold), amount)) + else if (amount > 1000000) { - Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! - check.Delete(); + Say(1010007); // Our policies prevent us from creating checks worth that much! } else { - Say(1042673, AffixType.Append, amount.ToString(), - ""); // Into your bank box I have placed a check in the amount of: + BankCheck check = new BankCheck(amount); + + BankBox box = e.Mobile.BankBox; + + if (!box.TryDropItem(e.Mobile, check, false)) + { + Say(500386); // There's not enough room in your bankbox for the check! + check.Delete(); + } + else if (!box.ConsumeTotal(typeof(Gold), amount)) + { + Say(500384); // Ah, art thou trying to fool me? Thou hast not so much gold! + check.Delete(); + } + else + { + Say(1042673, AffixType.Append, amount.ToString(), + ""); // Into your bank box I have placed a check in the amount of: + } } } - } - break; - } + break; + } } } diff --git a/Projects/Scripts/Mobiles/Townfolk/BaseEscortable.cs b/Projects/Scripts/Mobiles/Townfolk/BaseEscortable.cs index 9048f4a5f..ae4303ac8 100644 --- a/Projects/Scripts/Mobiles/Townfolk/BaseEscortable.cs +++ b/Projects/Scripts/Mobiles/Townfolk/BaseEscortable.cs @@ -24,7 +24,7 @@ namespace Server.Mobiles // Classic list // Used when: !MLQuestSystem.Enabled && !Core.ML - private static string[] m_TownNames = + private static readonly string[] m_TownNames = { "Cove", "Britain", "Jhelom", "Minoc", "Ocllo", "Trinsic", @@ -34,7 +34,7 @@ namespace Server.Mobiles // ML list, pre-ML quest system // Used when: !MLQuestSystem.Enabled && Core.ML - private static string[] m_MLTownNames = + private static readonly string[] m_MLTownNames = { "Cove", "Serpent's Hold", "Jhelom", "Nujel'm" @@ -42,7 +42,7 @@ namespace Server.Mobiles // ML quest system general list // Used when: MLQuestSystem.Enabled && !Region.IsPartOf( "Haven Island" ) - private static Type[] m_MLQuestTypes = + private static readonly Type[] m_MLQuestTypes = { typeof(EscortToYew), typeof(EscortToVesper), @@ -57,12 +57,12 @@ namespace Server.Mobiles typeof(EscortToCove), typeof(EscortToBritain) // Ocllo was removed in pub 56 - //typeof( EscortToOcllo ) + // typeof( EscortToOcllo ) }; // ML quest system New Haven list // Used when: MLQuestSystem.Enabled && Region.IsPartOf( "Haven Island" ) - private static Type[] m_MLQuestTypesNH = + private static readonly Type[] m_MLQuestTypesNH = { typeof(EscortToNHAlchemist), typeof(EscortToNHBard), @@ -73,7 +73,7 @@ namespace Server.Mobiles typeof(EscortToNHMage), typeof(EscortToNHInn), // Farm destination was removed - //typeof( EscortToNHFarm ), + // typeof( EscortToNHFarm ), typeof(EscortToNHDocks), typeof(EscortToNHBowyer), typeof(EscortToNHBank) @@ -127,7 +127,7 @@ namespace Server.Mobiles } } - public static Dictionary EscortTable{ get; } = new Dictionary(); + public static Dictionary EscortTable { get; } = new Dictionary(); protected override List ConstructQuestList() { @@ -615,7 +615,7 @@ namespace Server.Mobiles private class DeleteTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public DeleteTimer(Mobile m, TimeSpan delay) : base(delay) @@ -642,9 +642,9 @@ namespace Server.Mobiles Region = region; } - public string Name{ get; } + public string Name { get; } - public Region Region{ get; } + public Region Region { get; } public bool Contains(Point3D p) => Region.Contains(p); @@ -677,8 +677,8 @@ namespace Server.Mobiles public class AskDestinationEntry : ContextMenuEntry { - private Mobile m_From; - private BaseEscortable m_Mobile; + private readonly Mobile m_From; + private readonly BaseEscortable m_Mobile; public AskDestinationEntry(BaseEscortable m, Mobile from) : base(6100, 3) @@ -695,8 +695,8 @@ namespace Server.Mobiles public class AcceptEscortEntry : ContextMenuEntry { - private Mobile m_From; - private BaseEscortable m_Mobile; + private readonly Mobile m_From; + private readonly BaseEscortable m_Mobile; public AcceptEscortEntry(BaseEscortable m, Mobile from) : base(6101, 3) @@ -713,7 +713,7 @@ namespace Server.Mobiles public class AbandonEscortEntry : ContextMenuEntry { - private BaseEscortable m_Mobile; + private readonly BaseEscortable m_Mobile; public AbandonEscortEntry(BaseEscortable m) : base(6102, 3) => diff --git a/Projects/Scripts/Mobiles/Townfolk/Gypsy.cs b/Projects/Scripts/Mobiles/Townfolk/Gypsy.cs index 145285214..f33c7b9fc 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Gypsy.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Gypsy.cs @@ -56,7 +56,6 @@ namespace Server.Mobiles { } - public override bool CanTeach => true; public override bool ClickTitle => false; diff --git a/Projects/Scripts/Mobiles/Townfolk/HarborMaster.cs b/Projects/Scripts/Mobiles/Townfolk/HarborMaster.cs index 0cea4a47c..718fd032e 100644 --- a/Projects/Scripts/Mobiles/Townfolk/HarborMaster.cs +++ b/Projects/Scripts/Mobiles/Townfolk/HarborMaster.cs @@ -12,12 +12,10 @@ namespace Server.Mobiles SetSkill(SkillName.Mining, 36, 68); - SpeechHue = Utility.RandomDyedHue(); Hue = Race.Human.RandomSkinHue(); Blessed = true; - if (Female = Utility.RandomBool()) { Body = 0x191; @@ -47,7 +45,6 @@ namespace Server.Mobiles AddItem(pack); } - public HarborMaster(Serial serial) : base(serial) { diff --git a/Projects/Scripts/Mobiles/Townfolk/Merchant.cs b/Projects/Scripts/Mobiles/Townfolk/Merchant.cs index 7365a351a..8958a9ffb 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Merchant.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Merchant.cs @@ -54,9 +54,8 @@ namespace Server.Mobiles if (!Female) AddItem(new BodySash(lowHue)); - - //if ( !Female ) - //AddItem( new Longsword() ); + // if (!Female) + // AddItem( new Longsword() ); Utility.AssignRandomHair(this); @@ -77,4 +76,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Townfolk/Ninja.cs b/Projects/Scripts/Mobiles/Townfolk/Ninja.cs index 9d82834f6..d7e551ad3 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Ninja.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Ninja.cs @@ -43,7 +43,6 @@ namespace Server.Mobiles int hairHue = Utility.RandomNondyedHue(); - Utility.AssignRandomHair(this, hairHue); if (Utility.Random(7) != 0) diff --git a/Projects/Scripts/Mobiles/Townfolk/Peasant.cs b/Projects/Scripts/Mobiles/Townfolk/Peasant.cs index 1a25ef44d..64510ac29 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Peasant.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Peasant.cs @@ -44,13 +44,13 @@ namespace Server.Mobiles else AddItem(new Shoes(lowHue)); - //if ( !Female ) - //AddItem( new BodySash( lowHue ) ); + // if (!Female) + // AddItem( new BodySash( lowHue ) ); - //AddItem( new Cloak( GetRandomHue() ) ); + // AddItem( new Cloak( GetRandomHue() ) ); - //if ( !Female ) - //AddItem( new Longsword() ); + // if (!Female) + // AddItem( new Longsword() ); Utility.AssignRandomHair(this); @@ -71,4 +71,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Townfolk/Samurai.cs b/Projects/Scripts/Mobiles/Townfolk/Samurai.cs index 9f1ba03b5..79de6e20e 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Samurai.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Samurai.cs @@ -79,7 +79,6 @@ namespace Server.Mobiles int hairHue = Utility.RandomNondyedHue(); - Utility.AssignRandomHair(this, hairHue); if (Utility.Random(7) != 0) diff --git a/Projects/Scripts/Mobiles/Townfolk/Sculptor.cs b/Projects/Scripts/Mobiles/Townfolk/Sculptor.cs index 9ee5c4bc3..4f95a8c57 100644 --- a/Projects/Scripts/Mobiles/Townfolk/Sculptor.cs +++ b/Projects/Scripts/Mobiles/Townfolk/Sculptor.cs @@ -27,7 +27,6 @@ namespace Server.Mobiles AddItem(new LongPants(Utility.RandomNeutralHue())); } - AddItem(new Doublet(Utility.RandomNeutralHue())); AddItem(new HalfApron()); diff --git a/Projects/Scripts/Mobiles/Townfolk/SeekerOfAdventure.cs b/Projects/Scripts/Mobiles/Townfolk/SeekerOfAdventure.cs index 6e21b658f..48bc873ae 100644 --- a/Projects/Scripts/Mobiles/Townfolk/SeekerOfAdventure.cs +++ b/Projects/Scripts/Mobiles/Townfolk/SeekerOfAdventure.cs @@ -4,14 +4,14 @@ namespace Server.Mobiles { public class SeekerOfAdventure : BaseEscortable { - private static string[] m_Dungeons = + private static readonly string[] m_Dungeons = { "Covetous", "Deceit", "Despise", "Destard", "Hythloth", "Shame", // Old Code for Pre-ML shards. "Wrong" }; - private static string[] m_MLDestinations = + private static readonly string[] m_MLDestinations = { "Cove", "Serpent's Hold", "Jhelom", // ML List "Nujel'm" diff --git a/Projects/Scripts/Mobiles/Townfolk/TownCrier.cs b/Projects/Scripts/Mobiles/Townfolk/TownCrier.cs index 3354c0948..55d51a11f 100644 --- a/Projects/Scripts/Mobiles/Townfolk/TownCrier.cs +++ b/Projects/Scripts/Mobiles/Townfolk/TownCrier.cs @@ -10,7 +10,7 @@ namespace Server.Mobiles { public interface ITownCrierEntryList { - List Entries{ get; } + List Entries { get; } TownCrierEntry GetRandomEntry(); TownCrierEntry AddEntry(string[] lines, TimeSpan duration); void RemoveEntry(TownCrierEntry entry); @@ -24,7 +24,7 @@ namespace Server.Mobiles public bool IsEmpty => Entries == null || Entries.Count == 0; - public List Entries{ get; private set; } + public List Entries { get; private set; } public TownCrierEntry GetRandomEntry() { @@ -102,16 +102,16 @@ namespace Server.Mobiles ExpireTime = DateTime.UtcNow + duration; } - public string[] Lines{ get; } + public string[] Lines { get; } - public DateTime ExpireTime{ get; } + public DateTime ExpireTime { get; } public bool Expired => DateTime.UtcNow >= ExpireTime; } public class TownCrierDurationPrompt : Prompt { - private ITownCrierEntryList m_Owner; + private readonly ITownCrierEntryList m_Owner; public TownCrierDurationPrompt(ITownCrierEntryList owner) => m_Owner = owner; @@ -142,10 +142,10 @@ namespace Server.Mobiles public class TownCrierLinesPrompt : Prompt { - private TimeSpan m_Duration; - private TownCrierEntry m_Entry; - private List m_Lines; - private ITownCrierEntryList m_Owner; + private readonly TimeSpan m_Duration; + private readonly TownCrierEntry m_Entry; + private readonly List m_Lines; + private readonly ITownCrierEntryList m_Owner; public TownCrierLinesPrompt(ITownCrierEntryList owner, TownCrierEntry entry, List lines, TimeSpan duration) { @@ -187,8 +187,8 @@ namespace Server.Mobiles public class TownCrierGump : Gump { - private Mobile m_From; - private ITownCrierEntryList m_Owner; + private readonly Mobile m_From; + private readonly ITownCrierEntryList m_Owner; public TownCrierGump(Mobile from, ITownCrierEntryList owner) : base(50, 50) { @@ -347,9 +347,9 @@ namespace Server.Mobiles Instances.Add(this); } - public static List Instances{ get; } = new List(); + public static List Instances { get; } = new List(); - public List Entries{ get; private set; } + public List Entries { get; private set; } public TownCrierEntry GetRandomEntry() { diff --git a/Projects/Scripts/Mobiles/Vendors/AnimalBuy.cs b/Projects/Scripts/Mobiles/Vendors/AnimalBuy.cs index 9b51548b0..b041c6514 100644 --- a/Projects/Scripts/Mobiles/Vendors/AnimalBuy.cs +++ b/Projects/Scripts/Mobiles/Vendors/AnimalBuy.cs @@ -13,6 +13,6 @@ namespace Server.Mobiles name, type, price, amount, itemID, hue) => ControlSlots = controlSlots; - public override int ControlSlots{ get; } + public override int ControlSlots { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Mobiles/Vendors/BaseVendor.cs b/Projects/Scripts/Mobiles/Vendors/BaseVendor.cs index 1a2fea1f0..fa8b1cbc3 100644 --- a/Projects/Scripts/Mobiles/Vendors/BaseVendor.cs +++ b/Projects/Scripts/Mobiles/Vendors/BaseVendor.cs @@ -24,10 +24,10 @@ namespace Server.Mobiles { private const int MaxSell = 500; - private static TimeSpan InventoryDecayTime = TimeSpan.FromHours(1.0); + private static readonly TimeSpan InventoryDecayTime = TimeSpan.FromHours(1.0); - private List m_ArmorBuyInfo = new List(); - private List m_ArmorSellInfo = new List(); + private readonly List m_ArmorBuyInfo = new List(); + private readonly List m_ArmorSellInfo = new List(); public BaseVendor(string title = null) : base(AIType.AI_Vendor, FightMode.None, 2, 1, 0.5, 2) @@ -38,7 +38,7 @@ namespace Server.Mobiles InitBody(); InitOutfit(); - //these packs MUST exist, or the client will crash when the packets are sent + // these packs MUST exist, or the client will crash when the packets are sent Container pack = new Backpack { Layer = Layer.ShopBuy, Movable = false, Visible = false }; AddItem(pack); @@ -53,7 +53,7 @@ namespace Server.Mobiles { } - protected abstract List SBInfos{ get; } + protected abstract List SBInfos { get; } public override bool CanTeach => true; @@ -69,7 +69,7 @@ namespace Server.Mobiles public override bool IsInvulnerable => true; - public virtual DateTime NextTrickOrTreat{ get; set; } + public virtual DateTime NextTrickOrTreat { get; set; } public override bool ShowFameTitle => false; @@ -91,7 +91,7 @@ namespace Server.Mobiles public virtual VendorShoeType ShoeType => VendorShoeType.Shoes; - public DateTime LastRestock{ get; set; } + public DateTime LastRestock { get; set; } public virtual TimeSpan RestockDelay => TimeSpan.FromHours(1); @@ -178,7 +178,7 @@ namespace Server.Mobiles if (gbi != null) ProcessSinglePurchase(buy, gbi, validBuy, ref controlSlots, ref fullPurchase, ref totalCost); } - } //foreach + } // foreach if (fullPurchase && validBuy.Count == 0) SayTo(buyer, 500190); // Thou hast bought nothing! @@ -209,7 +209,7 @@ namespace Server.Mobiles } else { - SayTo(buyer, 500191); //Begging thy pardon, but thy bank account lacks these funds. + SayTo(buyer, 500191); // Begging thy pardon, but thy bank account lacks these funds. } } @@ -275,7 +275,7 @@ namespace Server.Mobiles if (gbi != null) ProcessValidPurchase(amount, gbi, buyer, cont); } - } //foreach + } // foreach if (fullPurchase) { @@ -284,10 +284,10 @@ namespace Server.Mobiles else if (fromBank) SayTo(buyer, 1151638, totalCost - .ToString()); //The total of your purchase is ~1_val~ gold, which has been drawn from your bank account. My thanks for the patronage. + .ToString()); // The total of your purchase is ~1_val~ gold, which has been drawn from your bank account. My thanks for the patronage. else SayTo(buyer, 1151639, - totalCost.ToString()); //The total of your purchase is ~1_val~ gold. My thanks for the patronage. + totalCost.ToString()); // The total of your purchase is ~1_val~ gold. My thanks for the patronage. } else { @@ -331,7 +331,7 @@ namespace Server.Mobiles foreach (SellItemResponse resp in list) { if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || - !resp.Item.Movable || resp.Item is Container container && container.Items.Count != 0) + !resp.Item.Movable || (resp.Item is Container container && container.Items.Count != 0)) continue; foreach (IShopSellInfo ssi in info) @@ -353,7 +353,7 @@ namespace Server.Mobiles foreach (SellItemResponse resp in list) { if (resp.Item.RootParent != seller || resp.Amount <= 0 || !resp.Item.IsStandardLoot() || - !resp.Item.Movable || resp.Item is Container container && container.Items.Count != 0) + !resp.Item.Movable || (resp.Item is Container container && container.Items.Count != 0)) continue; foreach (IShopSellInfo ssi in info) @@ -426,7 +426,7 @@ namespace Server.Mobiles seller.AddToBackpack(new Gold(GiveGold)); - seller.PlaySound(0x0037); //Gold dropping sound + seller.PlaySound(0x0037); // Gold dropping sound if (SupportsBulkOrders(seller)) { @@ -438,8 +438,8 @@ namespace Server.Mobiles seller.SendGump(new SmallBODAcceptGump(seller, smallBod)); } } - //no cliloc for this? - //SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold ); + // no cliloc for this? + // SayTo( seller, true, "Thank you! I bought {0} item{1}. Here is your {2}gp.", Sold, (Sold > 1 ? "s" : ""), GiveGold ); return true; } @@ -515,7 +515,7 @@ namespace Server.Mobiles }; } - public virtual int GetShoeHue() => 0.1 > Utility.RandomDouble() ? 0 : Utility.RandomNeutralHue(); + public virtual int GetShoeHue() => Utility.RandomDouble() < 0.1 ? 0 : Utility.RandomNeutralHue(); public virtual void CheckMorph() { @@ -811,9 +811,9 @@ namespace Server.Mobiles } } - //one (not all) of the packets uses a byte to describe number of items in the list. Osi = dumb. - //if ( list.Count > 255 ) - // Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this ); + // one (not all) of the packets uses a byte to describe number of items in the list. Osi = dumb. + // if (list.Count > 255) + // Console.WriteLine( "Vendor Warning: Vendor {0} has more than 255 buy items, may cause client errors!", this ); if (list.Count <= 0) return; @@ -839,7 +839,7 @@ namespace Server.Mobiles else from.Send(new DisplayBuyList(this)); - from.Send(new MobileStatusExtended(from)); //make sure their gold amount is sent + from.Send(new MobileStatusExtended(from)); // make sure their gold amount is sent for (int i = 0; i < opls.Count; ++i) from.Send(opls[i]); @@ -899,14 +899,14 @@ namespace Server.Mobiles List list = new List(); foreach (IShopSellInfo ssi in info) - foreach (Item item in pack.FindItemsByType(ssi.Types)) - { - if (item is Container container && container.Items.Count != 0) - continue; + foreach (Item item in pack.FindItemsByType(ssi.Types)) + { + if (item is Container container && container.Items.Count != 0) + continue; - if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item)) - list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item))); - } + if (item.IsStandardLoot() && item.Movable && ssi.IsSellable(item)) + list.Add(new SellItemState(item, ssi.GetSellPriceFor(item), ssi.GetNameFor(item))); + } if (list.Count > 0) { @@ -1086,7 +1086,7 @@ namespace Server.Mobiles public virtual bool CheckVendorAccess(Mobile from) => Region.GetRegion()?.CheckVendorAccess(this, from) != false || - Region != from.Region && from.Region.GetRegion()?.CheckVendorAccess(this, from) != false; + (Region != from.Region && from.Region.GetRegion()?.CheckVendorAccess(this, from) != false); public override void Serialize(IGenericWriter writer) { @@ -1142,47 +1142,47 @@ namespace Server.Mobiles switch (version) { case 1: - { - int index; - - while ((index = reader.ReadEncodedInt()) > 0) { - int doubled = reader.ReadEncodedInt(); + int index; - if (sbInfos != null) + while ((index = reader.ReadEncodedInt()) > 0) { - index -= 1; - int sbInfoIndex = index % sbInfos.Count; - int buyInfoIndex = index / sbInfos.Count; + int doubled = reader.ReadEncodedInt(); - if (sbInfoIndex >= 0 && sbInfoIndex < sbInfos.Count) + if (sbInfos != null) { - SBInfo sbInfo = sbInfos[sbInfoIndex]; - List buyInfo = sbInfo.BuyInfo; + index -= 1; + int sbInfoIndex = index % sbInfos.Count; + int buyInfoIndex = index / sbInfos.Count; - if (buyInfo != null && buyInfoIndex >= 0 && buyInfoIndex < buyInfo.Count) + if (sbInfoIndex >= 0 && sbInfoIndex < sbInfos.Count) { - GenericBuyInfo gbi = buyInfo[buyInfoIndex]; + SBInfo sbInfo = sbInfos[sbInfoIndex]; + List buyInfo = sbInfo.BuyInfo; - var amount = doubled switch + if (buyInfo != null && buyInfoIndex >= 0 && buyInfoIndex < buyInfo.Count) { - 1 => 40, - 2 => 80, - 3 => 160, - 4 => 320, - 5 => 640, - 6 => 999, - _ => 20 - }; + GenericBuyInfo gbi = buyInfo[buyInfoIndex]; - gbi.Amount = gbi.MaxAmount = amount; + var amount = doubled switch + { + 1 => 40, + 2 => 80, + 3 => 160, + 4 => 320, + 5 => 640, + 6 => 999, + _ => 20 + }; + + gbi.Amount = gbi.MaxAmount = amount; + } } } } - } - break; - } + break; + } } if (IsParagon) @@ -1214,8 +1214,8 @@ namespace Server.Mobiles private class BulkOrderInfoEntry : ContextMenuEntry { - private Mobile m_From; - private BaseVendor m_Vendor; + private readonly Mobile m_From; + private readonly BaseVendor m_Vendor; public BulkOrderInfoEntry(Mobile from, BaseVendor vendor) : base(6152) @@ -1266,8 +1266,6 @@ namespace Server.Mobiles } } - #region Faction - public virtual int GetPriceScalar() => 100 + Town.FromRegion(Region)?.Tax ?? 0; public void UpdateBuyInfo() @@ -1277,8 +1275,6 @@ namespace Server.Mobiles foreach (IBuyItemInfo info in m_ArmorBuyInfo.ToArray()) info.PriceScalar = priceScalar; } - - #endregion } } @@ -1286,7 +1282,7 @@ namespace Server.ContextMenus { public class VendorBuyEntry : ContextMenuEntry { - private BaseVendor m_Vendor; + private readonly BaseVendor m_Vendor; public VendorBuyEntry(Mobile from, BaseVendor vendor) : base(6103, 8) @@ -1303,7 +1299,7 @@ namespace Server.ContextMenus public class VendorSellEntry : ContextMenuEntry { - private BaseVendor m_Vendor; + private readonly BaseVendor m_Vendor; public VendorSellEntry(Mobile from, BaseVendor vendor) : base(6104, 8) @@ -1323,56 +1319,56 @@ namespace Server { public interface IShopSellInfo { - //What do we sell? - Type[] Types{ get; } + // What do we sell? + Type[] Types { get; } - //get display name for an item + // get display name for an item string GetNameFor(Item item); - //get price for an item which the player is selling + // get price for an item which the player is selling int GetSellPriceFor(Item item); - //get price for an item which the player is buying + // get price for an item which the player is buying int GetBuyPriceFor(Item item); - //can we sell this item to this vendor? + // can we sell this item to this vendor? bool IsSellable(Item item); - //does the vendor resell this item? + // does the vendor resell this item? bool IsResellable(Item item); } public interface IBuyItemInfo { - int ControlSlots{ get; } + int ControlSlots { get; } - int PriceScalar{ get; set; } + int PriceScalar { get; set; } - //display price of the item - int Price{ get; } + // display price of the item + int Price { get; } - //display name of the item - string Name{ get; } + // display name of the item + string Name { get; } - //display hue - int Hue{ get; } + // display hue + int Hue { get; } - //display id - int ItemID{ get; } + // display id + int ItemID { get; } - //amount in stock - int Amount{ get; set; } + // amount in stock + int Amount { get; set; } - //max amount in stock - int MaxAmount{ get; } + // max amount in stock + int MaxAmount { get; } - //get a new instance of an object (we just bought it) + // get a new instance of an object (we just bought it) IEntity GetEntity(); - //Attempt to restock with item, (return true if restock successful) + // Attempt to restock with item, (return true if restock successful) bool Restock(Item item, int amount); - //called when its time for the whole shop to restock + // called when its time for the whole shop to restock void OnRestock(); } } diff --git a/Projects/Scripts/Mobiles/Vendors/BeverageBuy.cs b/Projects/Scripts/Mobiles/Vendors/BeverageBuy.cs index f597e6b10..eafdc231c 100644 --- a/Projects/Scripts/Mobiles/Vendors/BeverageBuy.cs +++ b/Projects/Scripts/Mobiles/Vendors/BeverageBuy.cs @@ -6,15 +6,14 @@ namespace Server.Mobiles { public class BeverageBuyInfo : GenericBuyInfo { - private BeverageType m_Content; + private readonly BeverageType m_Content; public BeverageBuyInfo(Type type, BeverageType content, int price, int amount, int itemID, int hue) : this(null, type, content, price, amount, itemID, hue) { } - public BeverageBuyInfo(string name, Type type, BeverageType content, int price, int amount, int itemID, int hue) : - base(name, type, price, amount, itemID, hue) + public BeverageBuyInfo(string name, Type type, BeverageType content, int price, int amount, int itemID, int hue) : base(name, type, price, amount, itemID, hue) { m_Content = content; diff --git a/Projects/Scripts/Mobiles/Vendors/GenericBuy.cs b/Projects/Scripts/Mobiles/Vendors/GenericBuy.cs index 40ac38536..c33827d25 100644 --- a/Projects/Scripts/Mobiles/Vendors/GenericBuy.cs +++ b/Projects/Scripts/Mobiles/Vendors/GenericBuy.cs @@ -31,15 +31,15 @@ namespace Server.Mobiles public virtual bool CanCacheDisplay => false; - public Type Type{ get; set; } + public Type Type { get; set; } - public int DefaultPrice{ get; private set; } + public int DefaultPrice { get; private set; } - public object[] Args{ get; set; } + public object[] Args { get; set; } public virtual int ControlSlots => 0; - public string Name{ get; set; } + public string Name { get; set; } public int PriceScalar { @@ -75,9 +75,9 @@ namespace Server.Mobiles set => m_Price = value; } - public int ItemID{ get; set; } + public int ItemID { get; set; } - public int Hue{ get; set; } + public int Hue { get; set; } public int Amount { @@ -89,19 +89,19 @@ namespace Server.Mobiles } } - public int MaxAmount{ get; set; } + public int MaxAmount { get; set; } - //get a new instance of an object (we just bought it) + // get a new instance of an object (we just bought it) public virtual IEntity GetEntity() { if (Args == null || Args.Length == 0) return (IEntity)ActivatorUtil.CreateInstance(Type); return (IEntity)ActivatorUtil.CreateInstance(Type, Args); - //return (Item)ActivatorUtil.CreateInstance( m_Type ); + // return (Item)ActivatorUtil.CreateInstance( m_Type ); } - //Attempt to restock with item, (return true if restock successful) + // Attempt to restock with item, (return true if restock successful) public bool Restock(Item item, int amount) => false; public void OnRestock() diff --git a/Projects/Scripts/Mobiles/Vendors/GenericSell.cs b/Projects/Scripts/Mobiles/Vendors/GenericSell.cs index 0fca89cbb..4463e6562 100644 --- a/Projects/Scripts/Mobiles/Vendors/GenericSell.cs +++ b/Projects/Scripts/Mobiles/Vendors/GenericSell.cs @@ -6,56 +6,59 @@ namespace Server.Mobiles { public class GenericSellInfo : IShopSellInfo { - private Dictionary m_Table = new Dictionary(); + private readonly Dictionary m_Table = new Dictionary(); private Type[] m_Types; - public void Add( Type type, int price ) + public void Add(Type type, int price) { m_Table[type] = price; m_Types = null; } - public int GetSellPriceFor( Item item ) + public int GetSellPriceFor(Item item) { - m_Table.TryGetValue( item.GetType(), out int price ); + m_Table.TryGetValue(item.GetType(), out int price); - if ( item is BaseArmor armor ) { - if ( armor.Quality == ArmorQuality.Low ) - price = (int)( price * 0.60 ); - else if ( armor.Quality == ArmorQuality.Exceptional ) - price = (int)( price * 1.25 ); + if (item is BaseArmor armor) + { + if (armor.Quality == ArmorQuality.Low) + price = (int)(price * 0.60); + else if (armor.Quality == ArmorQuality.Exceptional) + price = (int)(price * 1.25); price += 100 * (int)armor.Durability; price += 100 * (int)armor.ProtectionLevel; - if ( price < 1 ) + if (price < 1) price = 1; } - else if ( item is BaseWeapon weapon ) { - if ( weapon.Quality == WeaponQuality.Low ) - price = (int)( price * 0.60 ); - else if ( weapon.Quality == WeaponQuality.Exceptional ) - price = (int)( price * 1.25 ); + else if (item is BaseWeapon weapon) + { + if (weapon.Quality == WeaponQuality.Low) + price = (int)(price * 0.60); + else if (weapon.Quality == WeaponQuality.Exceptional) + price = (int)(price * 1.25); price += 100 * (int)weapon.DurabilityLevel; price += 100 * (int)weapon.DamageLevel; - if ( price < 1 ) + if (price < 1) price = 1; } - else if ( item is BaseBeverage bev ) { + else if (item is BaseBeverage bev) + { int price1 = price, price2 = price; - if ( bev is Pitcher ) + if (bev is Pitcher) { price1 = 3; price2 = 5; } - else if ( bev is BeverageBottle ) + else if (bev is BeverageBottle) { price1 = 3; price2 = 3; } - else if ( bev is Jug ) + else if (bev is Jug) { price1 = 6; price2 = 6; } - if ( bev.IsEmpty || bev.Content == BeverageType.Milk ) + if (bev.IsEmpty || bev.Content == BeverageType.Milk) price = price1; else price = price2; @@ -64,51 +67,51 @@ namespace Server.Mobiles return price; } - public int GetBuyPriceFor( Item item ) => (int)( 1.90 * GetSellPriceFor( item ) ); + public int GetBuyPriceFor(Item item) => (int)(1.90 * GetSellPriceFor(item)); public Type[] Types { get { - if ( m_Types == null ) + if (m_Types == null) { m_Types = new Type[m_Table.Keys.Count]; - m_Table.Keys.CopyTo( m_Types, 0 ); + m_Table.Keys.CopyTo(m_Types, 0); } return m_Types; } } - public string GetNameFor( Item item ) + public string GetNameFor(Item item) { - if ( item.Name != null ) + if (item.Name != null) return item.Name; return item.LabelNumber.ToString(); } - public bool IsSellable( Item item ) + public bool IsSellable(Item item) { - if ( item.Nontransferable ) + if (item.Nontransferable) return false; - //if ( item.Hue != 0 ) - //return false; + // if (item.Hue != 0) + // return false; - return IsInList( item.GetType() ); + return IsInList(item.GetType()); } - public bool IsResellable( Item item ) + public bool IsResellable(Item item) { - if ( item.Nontransferable ) + if (item.Nontransferable) return false; - //if ( item.Hue != 0 ) - //return false; + // if (item.Hue != 0) + // return false; - return IsInList( item.GetType() ); + return IsInList(item.GetType()); } - public bool IsInList( Type type ) => m_Table.ContainsKey( type ); + public bool IsInList(Type type) => m_Table.ContainsKey(type); } } diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Alchemist.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Alchemist.cs index 8c9a2cb01..ab99168c5 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Alchemist.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Alchemist.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Alchemist : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Alchemist() : base("the alchemist") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs b/Projects/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs index 022aa2b2e..1285d4a03 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/AnimalTrainer.cs @@ -9,7 +9,7 @@ namespace Server.Mobiles { public class AnimalTrainer : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public AnimalTrainer() : base("the animal trainer") @@ -195,12 +195,12 @@ namespace Server.Mobiles { SayTo(from, 502673); // I can not stable summoned creatures. } -/* - else if ( pet.Allured ) - { - SayTo( from, 1048053 ); // You can't stable that! - } -*/ + /* + else if (pet.Allured) + { + SayTo( from, 1048053 ); // You can't stable that! + } + */ else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack?.Items.Count > 0) { SayTo(from, 1042563); // You need to unload your pet. @@ -368,8 +368,8 @@ namespace Server.Mobiles private class StableEntry : ContextMenuEntry { - private Mobile m_From; - private AnimalTrainer m_Trainer; + private readonly Mobile m_From; + private readonly AnimalTrainer m_Trainer; public StableEntry(AnimalTrainer trainer, Mobile from) : base(6126, 12) { @@ -385,9 +385,9 @@ namespace Server.Mobiles private class ClaimListGump : Gump { - private Mobile m_From; - private List m_List; - private AnimalTrainer m_Trainer; + private readonly Mobile m_From; + private readonly List m_List; + private readonly AnimalTrainer m_Trainer; public ClaimListGump(AnimalTrainer trainer, Mobile from, List list) : base(50, 50) { @@ -427,8 +427,8 @@ namespace Server.Mobiles private class ClaimAllEntry : ContextMenuEntry { - private Mobile m_From; - private AnimalTrainer m_Trainer; + private readonly Mobile m_From; + private readonly AnimalTrainer m_Trainer; public ClaimAllEntry(AnimalTrainer trainer, Mobile from) : base(6127, 12) { @@ -444,7 +444,7 @@ namespace Server.Mobiles private class StableTarget : Target { - private AnimalTrainer m_Trainer; + private readonly AnimalTrainer m_Trainer; public StableTarget(AnimalTrainer trainer) : base(12, false, TargetFlags.None) => m_Trainer = trainer; diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Architect.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Architect.cs index 780b8a3e7..4dce61ad2 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Architect.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Architect.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Architect : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Architect() : base("the architect") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Armorer.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Armorer.cs index 1a909c621..88cfcb4ca 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Armorer.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Armorer.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Armorer : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Armorer() : base("the armorer") @@ -27,39 +27,39 @@ namespace Server.Mobiles switch (Utility.Random(4)) { case 0: - { - m_SBInfos.Add(new SBLeatherArmor()); - m_SBInfos.Add(new SBStuddedArmor()); - m_SBInfos.Add(new SBMetalShields()); - m_SBInfos.Add(new SBPlateArmor()); - m_SBInfos.Add(new SBHelmetArmor()); - m_SBInfos.Add(new SBChainmailArmor()); - m_SBInfos.Add(new SBRingmailArmor()); - break; - } + { + m_SBInfos.Add(new SBLeatherArmor()); + m_SBInfos.Add(new SBStuddedArmor()); + m_SBInfos.Add(new SBMetalShields()); + m_SBInfos.Add(new SBPlateArmor()); + m_SBInfos.Add(new SBHelmetArmor()); + m_SBInfos.Add(new SBChainmailArmor()); + m_SBInfos.Add(new SBRingmailArmor()); + break; + } case 1: - { - m_SBInfos.Add(new SBStuddedArmor()); - m_SBInfos.Add(new SBLeatherArmor()); - m_SBInfos.Add(new SBMetalShields()); - m_SBInfos.Add(new SBHelmetArmor()); - break; - } + { + m_SBInfos.Add(new SBStuddedArmor()); + m_SBInfos.Add(new SBLeatherArmor()); + m_SBInfos.Add(new SBMetalShields()); + m_SBInfos.Add(new SBHelmetArmor()); + break; + } case 2: - { - m_SBInfos.Add(new SBMetalShields()); - m_SBInfos.Add(new SBPlateArmor()); - m_SBInfos.Add(new SBHelmetArmor()); - m_SBInfos.Add(new SBChainmailArmor()); - m_SBInfos.Add(new SBRingmailArmor()); - break; - } + { + m_SBInfos.Add(new SBMetalShields()); + m_SBInfos.Add(new SBPlateArmor()); + m_SBInfos.Add(new SBHelmetArmor()); + m_SBInfos.Add(new SBChainmailArmor()); + m_SBInfos.Add(new SBRingmailArmor()); + break; + } case 3: - { - m_SBInfos.Add(new SBMetalShields()); - m_SBInfos.Add(new SBHelmetArmor()); - break; - } + { + m_SBInfos.Add(new SBMetalShields()); + m_SBInfos.Add(new SBHelmetArmor()); + break; + } } if (IsTokunoVendor) diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Baker.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Baker.cs index 17e421f83..99dac2974 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Baker.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Baker.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Baker : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Baker() : base("the baker") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Bard.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Bard.cs index 5c4095d43..7f275f0f9 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Bard.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Bard.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Bard : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Bard() : base("the bard") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Barkeeper.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Barkeeper.cs index 9aa98a673..83fe5b3d6 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Barkeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Barkeeper.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Barkeeper : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Barkeeper() : base("the barkeeper") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Beekeeper.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Beekeeper.cs index c19ae26f1..37337e543 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Beekeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Beekeeper.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Beekeeper : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Beekeeper() : base("the beekeeper") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Blacksmith.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Blacksmith.cs index d779af18e..dd328267b 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Blacksmith.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Blacksmith.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class Blacksmith : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Blacksmith() : base("the blacksmith") @@ -93,11 +93,9 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Bulk Orders - public override Item CreateBulkOrder(Mobile from, bool fromContextMenu) { - if (from is PlayerMobile pm && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble())) + if (from is PlayerMobile pm && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || Utility.RandomDouble() < 0.2)) { double theirSkill = pm.Skills.Blacksmith.Base; @@ -134,7 +132,5 @@ namespace Server.Mobiles if (Core.SE && from is PlayerMobile mobile) mobile.NextSmithBulkOrder = TimeSpan.Zero; } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Bowyer.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Bowyer.cs index 8d2dc05ed..cc119398d 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Bowyer.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Bowyer.cs @@ -6,7 +6,7 @@ namespace Server.Mobiles [TypeAlias("Server.Mobiles.Bower")] public class Bowyer : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Bowyer() : base("the bowyer") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Butcher.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Butcher.cs index f6980f45e..6d54fd1a0 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Butcher.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Butcher.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Butcher : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Butcher() : base("the butcher") @@ -36,7 +36,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Carpenter.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Carpenter.cs index c652689c9..dc8969b59 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Carpenter.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Carpenter.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Carpenter : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Carpenter() : base("the carpenter") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Cobbler.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Cobbler.cs index 8a99f0118..091176124 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Cobbler.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Cobbler.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Cobbler : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Cobbler() : base("the cobbler") @@ -29,7 +29,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Cook.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Cook.cs index 08514af3f..4e1f28696 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Cook.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Cook.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Cook : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Cook() : base("the cook") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs b/Projects/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs index 495a4f936..1d884d341 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/CustomHairstylist.cs @@ -13,7 +13,7 @@ namespace Server.Mobiles public static readonly object Vendor = new object(); public static readonly object Price = new object(); - private static HairstylistBuyInfo[] m_SellList = + private static readonly HairstylistBuyInfo[] m_SellList = { new HairstylistBuyInfo(1018357, 50000, false, typeof(ChangeHairstyleGump), new[] { From, Vendor, Price, false, ChangeHairstyleEntry.HairEntries }), @@ -42,7 +42,7 @@ namespace Server.Mobiles { } - protected override List SBInfos{ get; } = new List(); + protected override List SBInfos { get; } = new List(); public override bool ClickTitle => false; @@ -106,24 +106,24 @@ namespace Server.Mobiles GumpArgs = args; } - public int Title{ get; } + public int Title { get; } - public string TitleString{ get; } + public string TitleString { get; } - public int Price{ get; } + public int Price { get; } - public bool FacialHair{ get; } + public bool FacialHair { get; } - public Type GumpType{ get; } + public Type GumpType { get; } - public object[] GumpArgs{ get; } + public object[] GumpArgs { get; } } public class HairstylistBuyGump : Gump { - private Mobile m_From; - private HairstylistBuyInfo[] m_SellList; - private Mobile m_Vendor; + private readonly Mobile m_From; + private readonly HairstylistBuyInfo[] m_SellList; + private readonly Mobile m_Vendor; public HairstylistBuyGump(Mobile from, Mobile vendor, HairstylistBuyInfo[] sellList) : base(50, 50) { @@ -254,19 +254,19 @@ namespace Server.Mobiles Hues[i] = start + i; } - public string Name{ get; } + public string Name { get; } - public int[] Hues{ get; } + public int[] Hues { get; } } public class ChangeHairHueGump : Gump { - private ChangeHairHueEntry[] m_Entries; - private bool m_FacialHair; - private Mobile m_From; - private bool m_Hair; - private int m_Price; - private Mobile m_Vendor; + private readonly ChangeHairHueEntry[] m_Entries; + private readonly bool m_FacialHair; + private readonly Mobile m_From; + private readonly bool m_Hair; + private readonly int m_Price; + private readonly Mobile m_Vendor; public ChangeHairHueGump(Mobile from, Mobile vendor, int price, bool hair, bool facialHair, ChangeHairHueEntry[] entries) : base(50, 50) @@ -330,7 +330,7 @@ namespace Server.Mobiles if (index >= 0 && index < m_Entries.Length) if (offset >= 0 && offset < m_Entries[index].Hues.Length) { - if (m_Hair && m_From.HairItemID > 0 || m_FacialHair && m_From.FacialHairItemID > 0) + if ((m_Hair && m_From.HairItemID > 0) || (m_FacialHair && m_From.FacialHairItemID > 0)) { if (!Banker.Withdraw(m_From, m_Price)) { @@ -404,25 +404,24 @@ namespace Server.Mobiles ItemID = itemID; } - public int ItemID{ get; } + public int ItemID { get; } - public int GumpID{ get; } + public int GumpID { get; } - public int X{ get; } + public int X { get; } - public int Y{ get; } + public int Y { get; } } public class ChangeHairstyleGump : Gump { - private ChangeHairstyleEntry[] m_Entries; - private bool m_FacialHair; - private Mobile m_From; - private int m_Price; - private Mobile m_Vendor; + private readonly ChangeHairstyleEntry[] m_Entries; + private readonly bool m_FacialHair; + private readonly Mobile m_From; + private readonly int m_Price; + private readonly Mobile m_Vendor; - public ChangeHairstyleGump(Mobile from, Mobile vendor, int price, bool facialHair, ChangeHairstyleEntry[] entries) : - base(50, 50) + public ChangeHairstyleGump(Mobile from, Mobile vendor, int price, bool facialHair, ChangeHairstyleEntry[] entries) : base(50, 50) { m_From = from; m_Vendor = vendor; diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Farmer.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Farmer.cs index aaa2c6b8d..5364b6f0b 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Farmer.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Farmer.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Farmer : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Farmer() : base("the farmer") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Fisherman.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Fisherman.cs index 71332692c..7886c9fc5 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Fisherman.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Fisherman.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Fisherman : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Fisherman() : base("the fisher") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Furtrader.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Furtrader.cs index 9583d4ac9..568ad92ec 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Furtrader.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Furtrader.cs @@ -4,13 +4,13 @@ namespace Server.Mobiles { public class Furtrader : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Furtrader() : base("the furtrader") { SetSkill(SkillName.Camping, 55.0, 78.0); - //SetSkill( SkillName.Alchemy, 60.0, 83.0 ); + // SetSkill( SkillName.Alchemy, 60.0, 83.0 ); SetSkill(SkillName.AnimalLore, 85.0, 100.0); SetSkill(SkillName.Cooking, 45.0, 68.0); SetSkill(SkillName.Tracking, 36.0, 68.0); diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Glassblower.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Glassblower.cs index 5243e144b..5ef1f6ef5 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Glassblower.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Glassblower.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles [TypeAlias("Server.Mobiles.GargoyleAlchemist")] public class Glassblower : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Glassblower() : base("the alchemist") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/GolemCrafter.cs b/Projects/Scripts/Mobiles/Vendors/NPC/GolemCrafter.cs index 58ba07995..c298259d8 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/GolemCrafter.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/GolemCrafter.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class GolemCrafter : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public GolemCrafter() : base("the golem crafter") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs index c88228620..3c0ded63a 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/BaseGuildmaster.cs @@ -13,7 +13,7 @@ namespace Server.Mobiles { } - protected override List SBInfos{ get; } = new List(); + protected override List SBInfos { get; } = new List(); public override bool IsActiveVendor => false; diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs index 9d9ac760c..87db80c35 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Guildmasters/TinkerGuildmaster.cs @@ -51,8 +51,8 @@ namespace Server.Mobiles private class RechargeEntry : ContextMenuEntry { - private Mobile m_From; - private Mobile m_Vendor; + private readonly Mobile m_From; + private readonly Mobile m_Vendor; public RechargeEntry(Mobile from, Mobile vendor) : base(6271, 6) { diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/GypsyMaiden.cs b/Projects/Scripts/Mobiles/Vendors/NPC/GypsyMaiden.cs index a3055d4ad..2cdcb18f8 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/GypsyMaiden.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/GypsyMaiden.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class GypsyMaiden : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public GypsyMaiden() : base("the gypsy maiden") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/HairStylist.cs b/Projects/Scripts/Mobiles/Vendors/NPC/HairStylist.cs index c75b08656..328383380 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/HairStylist.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/HairStylist.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class HairStylist : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public HairStylist() : base("the hair stylist") @@ -29,7 +29,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Herbalist.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Herbalist.cs index fc1d7d7a9..55a0e8736 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Herbalist.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Herbalist.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Herbalist : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Herbalist() : base("the herbalist") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/HolyMage.cs b/Projects/Scripts/Mobiles/Vendors/NPC/HolyMage.cs index 86a6d4a33..5a9a9f63d 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/HolyMage.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/HolyMage.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class HolyMage : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public HolyMage() : base("the Holy Mage") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/InnKeeper.cs b/Projects/Scripts/Mobiles/Vendors/NPC/InnKeeper.cs index 84f673fb8..f81a8ae71 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/InnKeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/InnKeeper.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class InnKeeper : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public InnKeeper() : base("the innkeeper") @@ -31,7 +31,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/IronWorker.cs b/Projects/Scripts/Mobiles/Vendors/NPC/IronWorker.cs index 6d6425672..85dbcb294 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/IronWorker.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/IronWorker.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class IronWorker : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public IronWorker() : base("the iron worker") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Jeweler.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Jeweler.cs index 107a987eb..119e45481 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Jeweler.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Jeweler.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Jeweler : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Jeweler() : base("the jeweler") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/KeeperOfChivalry.cs b/Projects/Scripts/Mobiles/Vendors/NPC/KeeperOfChivalry.cs index 0d781735a..56cefb292 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/KeeperOfChivalry.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/KeeperOfChivalry.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class KeeperOfChivalry : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public KeeperOfChivalry() : base("the Keeper of Chivalry") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/LeatherWorker.cs b/Projects/Scripts/Mobiles/Vendors/NPC/LeatherWorker.cs index 32955dab3..4a570d147 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/LeatherWorker.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/LeatherWorker.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class LeatherWorker : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public LeatherWorker() : base("the leather worker") @@ -28,7 +28,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Mage.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Mage.cs index 0b684e440..e31ffd69d 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Mage.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Mage.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Mage : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Mage() : base("the mage") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Mapmaker.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Mapmaker.cs index 5f7868807..aaabf58be 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Mapmaker.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Mapmaker.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Mapmaker : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Mapmaker() : base("the mapmaker") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Miller.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Miller.cs index b65da65ea..fe724fa1d 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Miller.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Miller.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Miller : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Miller() : base("the miller") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Miner.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Miner.cs index cb52fff18..e24554660 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Miner.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Miner.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Miner : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Miner() : base("the miner") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Monk.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Monk.cs index 98f9f2544..31db24e88 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Monk.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Monk.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Monk : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Monk() : base("the Monk") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Provisioner.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Provisioner.cs index 6bb99910d..c4732f01c 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Provisioner.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Provisioner.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Provisioner : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Provisioner() : base("the provisioner") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Rancher.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Rancher.cs index b7745dbeb..af9df28bc 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Rancher.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Rancher.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Rancher : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Rancher() : base("the rancher") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Ranger.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Ranger.cs index f1e3a13af..cd325fefb 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Ranger.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Ranger.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Ranger : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Ranger() : base("the ranger") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs b/Projects/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs index 1f4c36c73..14ac96992 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/RealEstateBroker.cs @@ -10,7 +10,7 @@ namespace Server.Mobiles public class RealEstateBroker : BaseVendor { private DateTime m_NextCheckPack; - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public RealEstateBroker() : base("the real estate broker") @@ -77,7 +77,7 @@ namespace Server.Mobiles { if (Banker.Deposit(from, price)) { - // For the deed I have placed gold in your bankbox : + // For the deed I have placed gold in your bankbox : PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008000, AffixType.Append, price.ToString()); deed.Delete(); @@ -103,7 +103,7 @@ namespace Server.Mobiles if (price > 0) { - // I will pay you gold for this deed : + // I will pay you gold for this deed : PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008001, AffixType.Append, price.ToString()); PublicOverheadMessage(MessageType.Regular, 0x3B2, diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Scribe.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Scribe.cs index f2956b5e8..368ef62eb 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Scribe.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Scribe.cs @@ -10,7 +10,7 @@ namespace Server.Mobiles public static readonly TimeSpan ShushDelay = TimeSpan.FromMinutes(1); private DateTime m_NextShush; - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Scribe() : base("the scribe") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Shipwright.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Shipwright.cs index 16a688f13..6f6ee6235 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Shipwright.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Shipwright.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Shipwright : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Shipwright() : base("the shipwright") @@ -36,7 +36,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -46,4 +46,4 @@ namespace Server.Mobiles int version = reader.ReadInt(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/StoneCrafter.cs b/Projects/Scripts/Mobiles/Vendors/NPC/StoneCrafter.cs index 2eac5831d..fcb4eec9b 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/StoneCrafter.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/StoneCrafter.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles [TypeAlias("Server.Mobiles.GargoyleStonecrafter")] public class StoneCrafter : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public StoneCrafter() : base("the stone crafter") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Tailor.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Tailor.cs index 40f1a0fb9..fbb6685b7 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Tailor.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Tailor.cs @@ -6,7 +6,7 @@ namespace Server.Mobiles { public class Tailor : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Tailor() : base("the tailor") @@ -43,11 +43,9 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Bulk Orders - public override Item CreateBulkOrder(Mobile from, bool fromContextMenu) { - if (from is PlayerMobile pm && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble())) + if (from is PlayerMobile pm && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || Utility.RandomDouble() < 0.2)) { double theirSkill = pm.Skills.Tailoring.Base; @@ -84,7 +82,5 @@ namespace Server.Mobiles if (Core.SE && from is PlayerMobile mobile) mobile.NextTailorBulkOrder = TimeSpan.Zero; } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Tanner.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Tanner.cs index 92b521b33..6f412296b 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Tanner.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Tanner.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Tanner : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Tanner() : base("the tanner") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/TavernKeeper.cs b/Projects/Scripts/Mobiles/Vendors/NPC/TavernKeeper.cs index 811afcb7b..a6b8bf569 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/TavernKeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/TavernKeeper.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class TavernKeeper : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public TavernKeeper() : base("the tavern keeper") @@ -34,7 +34,7 @@ namespace Server.Mobiles { base.Serialize(writer); - writer.Write(0); // version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Thief.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Thief.cs index d4dd18fa0..e05bb0874 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Thief.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Thief.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Thief : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Thief() : base("the thief") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Tinker.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Tinker.cs index e3cd00fcd..7f49de595 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Tinker.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Tinker.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Tinker : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Tinker() : base("the tinker") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Vagabond.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Vagabond.cs index d784b03a2..31b7ed73d 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Vagabond.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Vagabond.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Vagabond : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Vagabond() : base("the vagabond") @@ -44,7 +44,6 @@ namespace Server.Mobiles break; } - Utility.AssignRandomHair(this); Utility.AssignRandomFacialHair(this, HairHue); diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/VarietyDealer.cs b/Projects/Scripts/Mobiles/Vendors/NPC/VarietyDealer.cs index a05647690..fd0e82387 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/VarietyDealer.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/VarietyDealer.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class VarietyDealer : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public VarietyDealer() : base("the variety dealer") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Veterinarian.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Veterinarian.cs index 98c783b1d..d307e00a1 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Veterinarian.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Veterinarian.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class Veterinarian : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Veterinarian() : base("the vet") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Waiter.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Waiter.cs index 59d1fbbb0..1d8b0ac06 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Waiter.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Waiter.cs @@ -5,7 +5,7 @@ namespace Server.Mobiles { public class Waiter : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Waiter() : base("the waiter") diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Weaponsmith.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Weaponsmith.cs index e042197e3..d946f40ed 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Weaponsmith.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Weaponsmith.cs @@ -7,7 +7,7 @@ namespace Server.Mobiles { public class Weaponsmith : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Weaponsmith() : base("the weaponsmith") @@ -59,11 +59,9 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Bulk Orders - public override Item CreateBulkOrder(Mobile from, bool fromContextMenu) { - if (from is PlayerMobile pm && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble())) + if (from is PlayerMobile pm && pm.NextSmithBulkOrder == TimeSpan.Zero && (fromContextMenu || Utility.RandomDouble() < 0.2)) { double theirSkill = pm.Skills.Blacksmith.Base; @@ -100,7 +98,5 @@ namespace Server.Mobiles if (Core.SE && from is PlayerMobile mobile) mobile.NextSmithBulkOrder = TimeSpan.Zero; } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Mobiles/Vendors/NPC/Weaver.cs b/Projects/Scripts/Mobiles/Vendors/NPC/Weaver.cs index 860799cf6..c343ca8b6 100644 --- a/Projects/Scripts/Mobiles/Vendors/NPC/Weaver.cs +++ b/Projects/Scripts/Mobiles/Vendors/NPC/Weaver.cs @@ -6,7 +6,7 @@ namespace Server.Mobiles { public class Weaver : BaseVendor { - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); [Constructible] public Weaver() : base("the weaver") @@ -43,11 +43,9 @@ namespace Server.Mobiles int version = reader.ReadInt(); } - #region Bulk Orders - public override Item CreateBulkOrder(Mobile from, bool fromContextMenu) { - if (from is PlayerMobile pm && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || 0.2 > Utility.RandomDouble())) + if (from is PlayerMobile pm && pm.NextTailorBulkOrder == TimeSpan.Zero && (fromContextMenu || Utility.RandomDouble() < 0.2)) { double theirSkill = pm.Skills.Tailoring.Base; @@ -84,7 +82,5 @@ namespace Server.Mobiles if (Core.SE && from is PlayerMobile mobile) mobile.NextTailorBulkOrder = TimeSpan.Zero; } - - #endregion } } \ No newline at end of file diff --git a/Projects/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs b/Projects/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs index d9d1be3eb..9c75b39f2 100644 --- a/Projects/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/PlayerBarkeeper.cs @@ -11,8 +11,8 @@ namespace Server.Mobiles { public class ChangeRumorMessagePrompt : Prompt { - private PlayerBarkeeper m_Barkeeper; - private int m_RumorIndex; + private readonly PlayerBarkeeper m_Barkeeper; + private readonly int m_RumorIndex; public ChangeRumorMessagePrompt(PlayerBarkeeper barkeeper, int rumorIndex) { @@ -36,8 +36,8 @@ namespace Server.Mobiles public class ChangeRumorKeywordPrompt : Prompt { - private PlayerBarkeeper m_Barkeeper; - private int m_RumorIndex; + private readonly PlayerBarkeeper m_Barkeeper; + private readonly int m_RumorIndex; public ChangeRumorKeywordPrompt(PlayerBarkeeper barkeeper, int rumorIndex) { @@ -61,7 +61,7 @@ namespace Server.Mobiles public class ChangeTipMessagePrompt : Prompt { - private PlayerBarkeeper m_Barkeeper; + private readonly PlayerBarkeeper m_Barkeeper; public ChangeTipMessagePrompt(PlayerBarkeeper barkeeper) => m_Barkeeper = barkeeper; @@ -87,9 +87,9 @@ namespace Server.Mobiles Keyword = keyword; } - public string Message{ get; set; } + public string Message { get; set; } - public string Keyword{ get; set; } + public string Keyword { get; set; } public static BarkeeperRumor Deserialize(IGenericReader reader) { @@ -116,8 +116,8 @@ namespace Server.Mobiles public class ManageBarkeeperEntry : ContextMenuEntry { - private PlayerBarkeeper m_Barkeeper; - private Mobile m_From; + private readonly PlayerBarkeeper m_Barkeeper; + private readonly Mobile m_From; public ManageBarkeeperEntry(Mobile from, PlayerBarkeeper barkeeper) : base(6151, 12) { @@ -137,7 +137,7 @@ namespace Server.Mobiles private Timer m_NewsTimer; - private List m_SBInfos = new List(); + private readonly List m_SBInfos = new List(); public PlayerBarkeeper(Mobile owner, BaseHouse house) : base("the barkeeper") { @@ -153,7 +153,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } public BaseHouse House { @@ -169,7 +169,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public string TipMessage{ get; set; } + public string TipMessage { get; set; } public override bool IsActiveBuyer => false; public override bool IsActiveSeller => m_SBInfos.Count > 0; @@ -177,7 +177,7 @@ namespace Server.Mobiles public override bool DisallowAllMoves => true; public override bool NoHouseRestrictions => true; - public BarkeeperRumor[] Rumors{ get; private set; } + public BarkeeperRumor[] Rumors { get; private set; } public override VendorShoeType ShoeType => Utility.RandomBool() ? VendorShoeType.ThighBoots : VendorShoeType.Boots; protected override List SBInfos => m_SBInfos; @@ -502,24 +502,24 @@ namespace Server.Mobiles switch (version) { case 1: - { - House = (BaseHouse)reader.ReadItem(); + { + House = (BaseHouse)reader.ReadItem(); - goto case 0; - } + goto case 0; + } case 0: - { - Owner = reader.ReadMobile(); + { + Owner = reader.ReadMobile(); - Rumors = new BarkeeperRumor[reader.ReadEncodedInt()]; + Rumors = new BarkeeperRumor[reader.ReadEncodedInt()]; - for (int i = 0; i < Rumors.Length; ++i) - Rumors[i] = BarkeeperRumor.Deserialize(reader); + for (int i = 0; i < Rumors.Length; ++i) + Rumors[i] = BarkeeperRumor.Deserialize(reader); - TipMessage = reader.ReadString(); + TipMessage = reader.ReadString(); - break; - } + break; + } } if (version < 1) @@ -534,7 +534,7 @@ namespace Server.Mobiles public class BarkeeperTitleGump : Gump { - private static Entry[] m_Entries = + private static readonly Entry[] m_Entries = { new Entry("Alchemist"), new Entry("Animal Tamer"), @@ -598,8 +598,8 @@ namespace Server.Mobiles new Entry("No Title", null) }; - private PlayerBarkeeper m_Barkeeper; - private Mobile m_From; + private readonly PlayerBarkeeper m_Barkeeper; + private readonly Mobile m_From; public BarkeeperTitleGump(Mobile from, PlayerBarkeeper barkeeper) : base(0, 0) { @@ -719,9 +719,9 @@ namespace Server.Mobiles private class Entry { - public string m_Description; - public string m_Title; - public bool m_Vendor; + public readonly string m_Description; + public readonly string m_Title; + public readonly bool m_Vendor; public Entry(string desc, bool vendor = false) : this(desc, $"the {desc.ToLower()}", vendor) { @@ -738,8 +738,8 @@ namespace Server.Mobiles public class BarkeeperGump : Gump { - private PlayerBarkeeper m_Barkeeper; - private Mobile m_From; + private readonly PlayerBarkeeper m_Barkeeper; + private readonly Mobile m_From; public BarkeeperGump(Mobile from, PlayerBarkeeper barkeeper) : base(0, 0) { @@ -985,55 +985,55 @@ namespace Server.Mobiles switch (type) { case 0: // Controls - { - switch (index) { - case 0: // Dismiss + switch (index) { - m_Barkeeper.Dismiss(); - break; + case 0: // Dismiss + { + m_Barkeeper.Dismiss(); + break; + } } - } - break; - } + break; + } case 1: // Change message - { - m_Barkeeper.BeginChangeRumor(m_From, index); - break; - } - case 2: // Remove message - { - m_Barkeeper.RemoveRumor(m_From, index); - break; - } - case 3: // Change tip - { - m_Barkeeper.BeginChangeTip(m_From); - break; - } - case 4: // Remove tip - { - m_Barkeeper.RemoveTip(m_From); - break; - } - case 5: // Appearance category selection - { - switch (index) { - case 0: - m_Barkeeper.BeginChangeTitle(m_From); - break; - case 1: - m_Barkeeper.BeginChangeAppearance(m_From); - break; - case 2: - m_Barkeeper.ChangeGender(m_From); - break; + m_Barkeeper.BeginChangeRumor(m_From, index); + break; } + case 2: // Remove message + { + m_Barkeeper.RemoveRumor(m_From, index); + break; + } + case 3: // Change tip + { + m_Barkeeper.BeginChangeTip(m_From); + break; + } + case 4: // Remove tip + { + m_Barkeeper.RemoveTip(m_From); + break; + } + case 5: // Appearance category selection + { + switch (index) + { + case 0: + m_Barkeeper.BeginChangeTitle(m_From); + break; + case 1: + m_Barkeeper.BeginChangeAppearance(m_From); + break; + case 2: + m_Barkeeper.ChangeGender(m_From); + break; + } - break; - } + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Vendors/PlayerVendor.cs b/Projects/Scripts/Mobiles/Vendors/PlayerVendor.cs index 10cb857ee..bcebe6156 100644 --- a/Projects/Scripts/Mobiles/Vendors/PlayerVendor.cs +++ b/Projects/Scripts/Mobiles/Vendors/PlayerVendor.cs @@ -31,9 +31,9 @@ namespace Server.Mobiles Valid = true; } - public Item Item{ get; } + public Item Item { get; } - public int Price{ get; } + public int Price { get; } public string FormattedPrice { @@ -58,12 +58,12 @@ namespace Server.Mobiles } } - public DateTime Created{ get; } + public DateTime Created { get; } public bool IsForSale => Price >= 0; public bool IsForFree => Price == 0; - public bool Valid{ get; private set; } + public bool Valid { get; private set; } public void Invalidate() { @@ -215,7 +215,7 @@ namespace Server.Mobiles private class BuyEntry : ContextMenuEntry { - private Item m_Item; + private readonly Item m_Item; public BuyEntry(Item item) : base(6103) => m_Item = item; @@ -282,13 +282,13 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int BankAccount{ get; set; } + public int BankAccount { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int HoldGold{ get; set; } + public int HoldGold { get; set; } [CommandProperty(AccessLevel.GameMaster)] public string ShopName @@ -303,9 +303,9 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public DateTime NextPayTime{ get; private set; } + public DateTime NextPayTime { get; private set; } - public PlayerVendorPlaceholder Placeholder{ get; set; } + public PlayerVendorPlaceholder Placeholder { get; set; } public BaseHouse House { @@ -394,41 +394,41 @@ namespace Server.Mobiles { case 2: case 1: - { - newVendorSystem = reader.ReadBool(); - m_ShopName = reader.ReadString(); - NextPayTime = reader.ReadDeltaTime(); - House = (BaseHouse)reader.ReadItem(); - - goto case 0; - } - case 0: - { - Owner = reader.ReadMobile(); - BankAccount = reader.ReadInt(); - HoldGold = reader.ReadInt(); - - int count = reader.ReadInt(); - - m_SellItems = new Dictionary(count); - - for (int i = 0; i < count; i++) { - Item item = reader.ReadItem(); + newVendorSystem = reader.ReadBool(); + m_ShopName = reader.ReadString(); + NextPayTime = reader.ReadDeltaTime(); + House = (BaseHouse)reader.ReadItem(); - int price = reader.ReadInt(); - if (price > 100000000) - price = 100000000; - - string description = reader.ReadString(); - - DateTime created = version < 1 ? DateTime.UtcNow : reader.ReadDateTime(); - - if (item != null) SetVendorItem(item, version < 1 && price <= 0 ? -1 : price, description, created); + goto case 0; } + case 0: + { + Owner = reader.ReadMobile(); + BankAccount = reader.ReadInt(); + HoldGold = reader.ReadInt(); - break; - } + int count = reader.ReadInt(); + + m_SellItems = new Dictionary(count); + + for (int i = 0; i < count; i++) + { + Item item = reader.ReadItem(); + + int price = reader.ReadInt(); + if (price > 100000000) + price = 100000000; + + string description = reader.ReadString(); + + DateTime created = version < 1 ? DateTime.UtcNow : reader.ReadDateTime(); + + if (item != null) SetVendorItem(item, version < 1 && price <= 0 ? -1 : price, description, created); + } + + break; + } } bool newVendorSystemActivated = BaseHouse.NewVendorSystem && !newVendorSystem; @@ -601,8 +601,7 @@ namespace Server.Mobiles House.VendorInventories.Add(inventory); } } - else if ((toBackpack || House?.IsAosRules != true) && Map != Map.Internal - ) // Case 3 - Move to backpack + else if ((toBackpack || House?.IsAosRules != true) && Map != Map.Internal) // Case 3 - Move to backpack { Container backpack = new Backpack(); @@ -1103,7 +1102,7 @@ namespace Server.Mobiles if (e.Handled || !from.Alive || from.GetDistanceToSqrt(this) > 3) return; - if (e.HasKeyword(0x3C) || e.HasKeyword(0x171) && WasNamed(e.Speech)) // vendor buy, *buy* + if (e.HasKeyword(0x3C) || (e.HasKeyword(0x171) && WasNamed(e.Speech))) // vendor buy, *buy* { if (IsOwner(from)) { @@ -1117,7 +1116,7 @@ namespace Server.Mobiles e.Handled = true; } } - else if (e.HasKeyword(0x3D) || e.HasKeyword(0x172) && WasNamed(e.Speech)) // vendor browse, *browse + else if (e.HasKeyword(0x3D) || (e.HasKeyword(0x172) && WasNamed(e.Speech))) // vendor browse, *browse { if (House?.IsBanned(from) == true && !IsOwner(from)) { @@ -1143,7 +1142,7 @@ namespace Server.Mobiles e.Handled = true; } } - else if (e.HasKeyword(0x3E) || e.HasKeyword(0x173) && WasNamed(e.Speech)) // vendor collect, *collect + else if (e.HasKeyword(0x3E) || (e.HasKeyword(0x173) && WasNamed(e.Speech))) // vendor collect, *collect { if (IsOwner(from)) { @@ -1152,7 +1151,7 @@ namespace Server.Mobiles e.Handled = true; } } - else if (e.HasKeyword(0x3F) || e.HasKeyword(0x174) && WasNamed(e.Speech)) // vendor status, *status + else if (e.HasKeyword(0x3F) || (e.HasKeyword(0x174) && WasNamed(e.Speech))) // vendor status, *status { if (IsOwner(from)) { @@ -1165,7 +1164,7 @@ namespace Server.Mobiles SayTo(from, 503226); // What do you care? You don't run this shop. } } - else if (e.HasKeyword(0x40) || e.HasKeyword(0x175) && WasNamed(e.Speech)) // vendor dismiss, *dismiss + else if (e.HasKeyword(0x40) || (e.HasKeyword(0x175) && WasNamed(e.Speech))) // vendor dismiss, *dismiss { if (IsOwner(from)) { @@ -1174,7 +1173,7 @@ namespace Server.Mobiles e.Handled = true; } } - else if (e.HasKeyword(0x41) || e.HasKeyword(0x176) && WasNamed(e.Speech)) // vendor cycle, *cycle + else if (e.HasKeyword(0x41) || (e.HasKeyword(0x176) && WasNamed(e.Speech))) // vendor cycle, *cycle { if (IsOwner(from)) { @@ -1189,7 +1188,7 @@ namespace Server.Mobiles private class ReturnVendorEntry : ContextMenuEntry { - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public ReturnVendorEntry(PlayerVendor vendor) : base(6214) => m_Vendor = vendor; @@ -1204,7 +1203,7 @@ namespace Server.Mobiles private class PayTimer : Timer { - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public PayTimer(PlayerVendor vendor, TimeSpan delay) : base(delay, GetInterval()) { @@ -1276,8 +1275,8 @@ namespace Server.Mobiles private class VendorPricePrompt : Prompt { - private PlayerVendor m_Vendor; - private VendorItem m_VI; + private readonly PlayerVendor m_Vendor; + private readonly VendorItem m_VI; public VendorPricePrompt(PlayerVendor vendor, VendorItem vi) { @@ -1373,7 +1372,7 @@ namespace Server.Mobiles private class CollectGoldPrompt : Prompt { - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public CollectGoldPrompt(PlayerVendor vendor) => m_Vendor = vendor; @@ -1409,7 +1408,7 @@ namespace Server.Mobiles private class VendorNamePrompt : Prompt { - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public VendorNamePrompt(PlayerVendor vendor) => m_Vendor = vendor; @@ -1436,7 +1435,7 @@ namespace Server.Mobiles private class ShopNamePrompt : Prompt { - private PlayerVendor m_Vendor; + private readonly PlayerVendor m_Vendor; public ShopNamePrompt(PlayerVendor vendor) => m_Vendor = vendor; @@ -1462,7 +1461,7 @@ namespace Server.Mobiles public class PlayerVendorPlaceholder : Item { - private ExpireTimer m_Timer; + private readonly ExpireTimer m_Timer; public PlayerVendorPlaceholder(PlayerVendor vendor) : base(0x1F28) { @@ -1480,7 +1479,7 @@ namespace Server.Mobiles } [CommandProperty(AccessLevel.GameMaster)] - public PlayerVendor Vendor{ get; private set; } + public PlayerVendor Vendor { get; private set; } public override void GetProperties(ObjectPropertyList list) { @@ -1527,7 +1526,7 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private PlayerVendorPlaceholder m_Placeholder; + private readonly PlayerVendorPlaceholder m_Placeholder; public ExpireTimer(PlayerVendorPlaceholder placeholder) : base(TimeSpan.FromMinutes(2.0)) { diff --git a/Projects/Scripts/Mobiles/Vendors/PresetMapBuy.cs b/Projects/Scripts/Mobiles/Vendors/PresetMapBuy.cs index 73db5a12f..f0cf585e0 100644 --- a/Projects/Scripts/Mobiles/Vendors/PresetMapBuy.cs +++ b/Projects/Scripts/Mobiles/Vendors/PresetMapBuy.cs @@ -4,7 +4,7 @@ namespace Server.Mobiles { public class PresetMapBuyInfo : GenericBuyInfo { - private PresetMapEntry m_Entry; + private readonly PresetMapEntry m_Entry; public PresetMapBuyInfo(PresetMapEntry entry, int price, int amount) : base(entry.Name.ToString(), null, price, amount, 0x14EC, 0) => diff --git a/Projects/Scripts/Mobiles/Vendors/RentedVendor.cs b/Projects/Scripts/Mobiles/Vendors/RentedVendor.cs index 1b28aa786..f2cb5b18b 100644 --- a/Projects/Scripts/Mobiles/Vendors/RentedVendor.cs +++ b/Projects/Scripts/Mobiles/Vendors/RentedVendor.cs @@ -24,9 +24,9 @@ namespace Server.Mobiles Name = name; } - public TimeSpan Duration{ get; } + public TimeSpan Duration { get; } - public int Name{ get; } + public int Name { get; } public int ID { @@ -64,33 +64,33 @@ namespace Server.Mobiles { } - public VendorRentalDuration RentalDuration{ get; private set; } + public VendorRentalDuration RentalDuration { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public int RentalPrice{ get; set; } + public int RentalPrice { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool LandlordRenew{ get; set; } + public bool LandlordRenew { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool RenterRenew{ get; set; } + public bool RenterRenew { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Renew => LandlordRenew && RenterRenew && House != null && House.DecayType != DecayType.Condemned; [CommandProperty(AccessLevel.GameMaster)] - public int RenewalPrice{ get; set; } + public int RenewalPrice { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int RentalGold{ get; set; } + public int RentalGold { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime RentalExpireTime{ get; private set; } + public DateTime RentalExpireTime { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public Mobile Landlord => House?.Owner; - public override bool IsOwner(Mobile m) => m == Owner || m.AccessLevel >= AccessLevel.GameMaster || Core.ML && AccountHandler.CheckAccount(m, Owner); + public override bool IsOwner(Mobile m) => m == Owner || m.AccessLevel >= AccessLevel.GameMaster || (Core.ML && AccountHandler.CheckAccount(m, Owner)); public bool IsLandlord(Mobile m) => House?.IsOwner(m) == true; @@ -205,7 +205,7 @@ namespace Server.Mobiles private class ContractOptionsEntry : ContextMenuEntry { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; public ContractOptionsEntry(RentedVendor vendor) : base(6209) => m_Vendor = vendor; @@ -235,7 +235,7 @@ namespace Server.Mobiles private class CollectRentEntry : ContextMenuEntry { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; public CollectRentEntry(RentedVendor vendor) : base(6212) => m_Vendor = vendor; @@ -263,7 +263,7 @@ namespace Server.Mobiles private class TerminateContractEntry : ContextMenuEntry { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; public TerminateContractEntry(RentedVendor vendor) : base(6218) => m_Vendor = vendor; @@ -282,7 +282,7 @@ namespace Server.Mobiles private class RefundOfferPrompt : Prompt { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; public RefundOfferPrompt(RentedVendor vendor) => m_Vendor = vendor; @@ -325,7 +325,7 @@ namespace Server.Mobiles private class RentalExpireTimer : Timer { - private RentedVendor m_Vendor; + private readonly RentedVendor m_Vendor; public RentalExpireTimer(RentedVendor vendor, TimeSpan delay) : base(delay, vendor.RentalDuration.Duration) { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBChainmailArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBChainmailArmor.cs index c9d751c8f..f3b80e10e 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBChainmailArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBChainmailArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBChainmailArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBHelmetArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBHelmetArmor.cs index 7dfd52c44..c2515d68b 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBHelmetArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBHelmetArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBHelmetArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBLeatherArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBLeatherArmor.cs index 3bf592d14..c762ea1b4 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBLeatherArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBLeatherArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBLeatherArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBMetalShields.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBMetalShields.cs index 241ede93b..5a3d42e31 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBMetalShields.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBMetalShields.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBMetalShields : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBPlateArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBPlateArmor.cs index 977160127..f9ee2877d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBPlateArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBPlateArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBPlateArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBRingmailArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBRingmailArmor.cs index 9518a340e..4983a420d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBRingmailArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBRingmailArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBRingmailArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBStuddedArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBStuddedArmor.cs index f62112ace..85f44866b 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBStuddedArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBStuddedArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBStuddedArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBWoodenShields.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBWoodenShields.cs index 41f2346e5..b01ed8277 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBWoodenShields.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Armors/SBWoodenShields.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBWoodenShields : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAlchemist.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAlchemist.cs index f15ae5b24..781a08d4c 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAlchemist.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAlchemist.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBAlchemist : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAnimalTrainer.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAnimalTrainer.cs index 86804d9a3..5ca42c3fb 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAnimalTrainer.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBAnimalTrainer.cs @@ -4,9 +4,9 @@ namespace Server.Mobiles { public class SBAnimalTrainer : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBArchitect.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBArchitect.cs index 5325e7669..6bd6b72be 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBArchitect.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBArchitect.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBArchitect : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBaker.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBaker.cs index 4ed914fed..13f01c887 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBaker.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBaker.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBBaker : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -15,7 +15,7 @@ namespace Server.Mobiles { Add(new GenericBuyInfo(typeof(BreadLoaf), 6, 20, 0x103B, 0)); Add(new GenericBuyInfo(typeof(BreadLoaf), 5, 20, 0x103C, 0)); - Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); //OSI just has Pie, not Apple/Fruit/Meat + Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); // OSI just has Pie, not Apple/Fruit/Meat Add(new GenericBuyInfo(typeof(Cake), 13, 20, 0x9E9, 0)); Add(new GenericBuyInfo(typeof(Muffins), 3, 20, 0x9EA, 0)); Add(new GenericBuyInfo(typeof(SackFlour), 3, 20, 0x1039, 0)); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBanker.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBanker.cs index f97986bfd..737cd2a38 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBanker.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBanker.cs @@ -6,9 +6,9 @@ namespace Server.Mobiles { public class SBBanker : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBard.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBard.cs index 8a4bae901..b1fa1264a 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBard.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBard.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBBard : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBarkeeper.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBarkeeper.cs index ade4c1f28..95c99db8b 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBarkeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBarkeeper.cs @@ -6,9 +6,9 @@ namespace Server.Mobiles { public class SBBarkeeper : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -42,7 +42,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(WoodenBowlOfStew), 3, 20, 0x1604, 0)); Add(new GenericBuyInfo(typeof(WoodenBowlOfTomatoSoup), 3, 20, 0x1606, 0)); - Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); //OSI just has Pie, not Apple/Fruit/Meat + Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); // OSI just has Pie, not Apple/Fruit/Meat Add(new GenericBuyInfo("1016450", typeof(Chessboard), 2, 20, 0xFA6, 0)); Add(new GenericBuyInfo("1016449", typeof(CheckerBoard), 2, 20, 0xFA6, 0)); @@ -53,7 +53,7 @@ namespace Server.Mobiles if (BaseHouse.NewVendorSystem) Add(new GenericBuyInfo("1062332", typeof(VendorRentalContract), 1252, 20, 0x14F0, 0x672)); - /*if ( Map == Tokuno ) + /*if (Map == Tokuno) { Add( new GenericBuyInfo( typeof( Wasabi ), 2, 20, 0x24E8, 0 ) ); Add( new GenericBuyInfo( typeof( Wasabi ), 2, 20, 0x24E9, 0 ) ); @@ -100,4 +100,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBeekeeper.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBeekeeper.cs index 02d08aea8..f668bbc43 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBeekeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBeekeeper.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBBeekeeper : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBlacksmith.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBlacksmith.cs index 62cc0db71..aa5cb3491 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBlacksmith.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBlacksmith.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBBlacksmith : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBowyer.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBowyer.cs index 8a25a670b..2d2a79938 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBowyer.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBBowyer.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBBowyer : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBButcher.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBButcher.cs index 325a9b54d..d8740e46a 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBButcher.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBButcher.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBButcher : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCarpenter.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCarpenter.cs index 077da73e4..1bb0c6f42 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCarpenter.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCarpenter.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBCarpenter : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCobbler.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCobbler.cs index 635eb3be4..04bf8bc39 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCobbler.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCobbler.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBCobbler : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCook.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCook.cs index 7687c433a..1ff31da15 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCook.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBCook.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBCook : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -15,7 +15,7 @@ namespace Server.Mobiles { Add(new GenericBuyInfo(typeof(BreadLoaf), 5, 20, 0x103B, 0)); Add(new GenericBuyInfo(typeof(BreadLoaf), 5, 20, 0x103C, 0)); - Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); //OSI just has Pie, not Apple/Fruit/Meat + Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); // OSI just has Pie, not Apple/Fruit/Meat Add(new GenericBuyInfo(typeof(Cake), 13, 20, 0x9E9, 0)); Add(new GenericBuyInfo(typeof(Muffins), 3, 20, 0x9EA, 0)); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFarmer.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFarmer.cs index c8d901748..c2f98452d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFarmer.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFarmer.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBFarmer : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -23,9 +23,9 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(Pumpkin), 11, 20, 0xC6A, 0)); Add(new GenericBuyInfo(typeof(GreenGourd), 3, 20, 0xC66, 0)); Add(new GenericBuyInfo(typeof(YellowGourd), 3, 20, 0xC64, 0)); - //Add( new GenericBuyInfo( typeof( Turnip ), 6, 20, XXXXXX, 0 ) ); + // Add( new GenericBuyInfo( typeof( Turnip ), 6, 20, XXXXXX, 0 ) ); Add(new GenericBuyInfo(typeof(Watermelon), 7, 20, 0xC5C, 0)); - //Add( new GenericBuyInfo( typeof( EarOfCorn ), 3, 20, XXXXXX, 0 ) ); + // Add( new GenericBuyInfo( typeof( EarOfCorn ), 3, 20, XXXXXX, 0 ) ); Add(new GenericBuyInfo(typeof(Eggs), 3, 20, 0x9B5, 0)); Add(new BeverageBuyInfo(typeof(Pitcher), BeverageType.Milk, 7, 20, 0x9AD, 0)); Add(new GenericBuyInfo(typeof(Peach), 3, 20, 0x9D2, 0)); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFisherman.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFisherman.cs index 43e6cc7bd..49fe3c5c8 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFisherman.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFisherman.cs @@ -5,25 +5,23 @@ namespace Server.Mobiles { public class SBFisherman : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { public InternalBuyInfo() { Add(new GenericBuyInfo(typeof(RawFishSteak), 3, 20, 0x97A, 0)); - //TODO: Add( new GenericBuyInfo( typeof( SmallFish ), 3, 20, 0xDD6, 0 ) ); - //TODO: Add( new GenericBuyInfo( typeof( SmallFish ), 3, 20, 0xDD7, 0 ) ); + // TODO: Add( new GenericBuyInfo( typeof( SmallFish ), 3, 20, 0xDD6, 0 ) ); + // TODO: Add( new GenericBuyInfo( typeof( SmallFish ), 3, 20, 0xDD7, 0 ) ); Add(new GenericBuyInfo(typeof(Fish), 6, 80, 0x9CC, 0)); Add(new GenericBuyInfo(typeof(Fish), 6, 80, 0x9CD, 0)); Add(new GenericBuyInfo(typeof(Fish), 6, 80, 0x9CE, 0)); Add(new GenericBuyInfo(typeof(Fish), 6, 80, 0x9CF, 0)); Add(new GenericBuyInfo(typeof(FishingPole), 15, 20, 0xDC0, 0)); - #region Mondain's Legacy - Add(new GenericBuyInfo(typeof(AquariumFishNet), 250, 20, 0xDC8, 0x240)); Add(new GenericBuyInfo(typeof(AquariumFood), 62, 20, 0xEFC, 0)); Add(new GenericBuyInfo(typeof(FishBowl), 6312, 20, 0x241C, 0x482)); @@ -31,8 +29,6 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(AquariumNorthDeed), 250002, 20, 0x14F0, 0)); Add(new GenericBuyInfo(typeof(AquariumEastDeed), 250002, 20, 0x14F0, 0)); Add(new GenericBuyInfo(typeof(NewAquariumBook), 15, 20, 0xFF2, 0)); - - #endregion } } @@ -42,7 +38,7 @@ namespace Server.Mobiles { Add(typeof(RawFishSteak), 1); Add(typeof(Fish), 1); - //TODO: Add( typeof( SmallFish ), 1 ); + // TODO: Add( typeof( SmallFish ), 1 ); Add(typeof(FishingPole), 7); } } diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFortuneTeller.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFortuneTeller.cs index 69547b5d3..faa73a8bc 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFortuneTeller.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFortuneTeller.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBFortuneTeller : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFurtrader.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFurtrader.cs index 7ff0fb717..df3785f6d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFurtrader.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBFurtrader.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBFurtrader : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBGlassblower.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBGlassblower.cs index 31cc4cd9b..56d0ad1f0 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBGlassblower.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBGlassblower.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBGlassblower : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHairStylist.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHairStylist.cs index 6fbc2773d..42b1599f3 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHairStylist.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHairStylist.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBHairStylist : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHealer.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHealer.cs index 9da118cb2..47c9ed342 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHealer.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHealer.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBHealer : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHerbalist.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHerbalist.cs index 66284ba87..527e19be9 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHerbalist.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHerbalist.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBHerbalist : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHolyMage.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHolyMage.cs index 23b390eff..e7dfd364a 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHolyMage.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHolyMage.cs @@ -6,9 +6,9 @@ namespace Server.Mobiles { public class SBHolyMage : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHouseDeed.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHouseDeed.cs index 2c322aee2..3f8b40601 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHouseDeed.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBHouseDeed.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBHouseDeed : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInfo.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInfo.cs index e09238467..0691651a5 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInfo.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInfo.cs @@ -6,7 +6,7 @@ namespace Server.Mobiles { public static readonly List Empty = new List(); - public abstract IShopSellInfo SellInfo{ get; } - public abstract List BuyInfo{ get; } + public abstract IShopSellInfo SellInfo { get; } + public abstract List BuyInfo { get; } } } \ No newline at end of file diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInnKeeper.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInnKeeper.cs index eafd6d350..3ff17525b 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInnKeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBInnKeeper.cs @@ -6,9 +6,9 @@ namespace Server.Mobiles { public class SBInnKeeper : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -44,7 +44,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(WoodenBowlOfStew), 3, 20, 0x1604, 0)); Add(new GenericBuyInfo(typeof(WoodenBowlOfTomatoSoup), 3, 20, 0x1606, 0)); - Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); //OSI just has Pie, not Apple/Fruit/Meat + Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); // OSI just has Pie, not Apple/Fruit/Meat Add(new GenericBuyInfo(typeof(Peach), 3, 20, 0x9D2, 0)); Add(new GenericBuyInfo(typeof(Pear), 3, 20, 0x994, 0)); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBJewel.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBJewel.cs index 0fc73eb36..e2cb6643e 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBJewel.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBJewel.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBJewel : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBKeeperOfChivalry.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBKeeperOfChivalry.cs index c902fc9d5..0edec20f3 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBKeeperOfChivalry.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBKeeperOfChivalry.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBKeeperOfChivalry : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBLeatherWorker.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBLeatherWorker.cs index 5807b0b67..efe6f8f77 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBLeatherWorker.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBLeatherWorker.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBLeatherWorker : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMage.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMage.cs index defa29c22..2f1d155ff 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMage.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMage.cs @@ -6,9 +6,9 @@ namespace Server.Mobiles { public class SBMage : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMapmaker.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMapmaker.cs index aa31be373..50c14c7dc 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMapmaker.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMapmaker.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBMapmaker : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -33,7 +33,7 @@ namespace Server.Mobiles Add(typeof(LocalMap), 3); Add(typeof(WorldMap), 3); Add(typeof(PresetMapEntry), 3); - //TODO: Buy back maps that the mapmaker sells!!! + // TODO: Buy back maps that the mapmaker sells!!! } } } diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiller.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiller.cs index c3005d563..433506f22 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiller.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiller.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBMiller : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiner.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiner.cs index 111056f41..a74c9c3b8 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiner.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMiner.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBMiner : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -17,7 +17,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(Candle), 6, 10, 0xA28, 0)); Add(new GenericBuyInfo(typeof(Torch), 8, 10, 0xF6B, 0)); Add(new GenericBuyInfo(typeof(Lantern), 2, 10, 0xA25, 0)); - //Add( new GenericBuyInfo( typeof( OilFlask ), 8, 10, 0x####, 0 ) ); + // Add( new GenericBuyInfo( typeof( OilFlask ), 8, 10, 0x####, 0 ) ); Add(new GenericBuyInfo(typeof(Pickaxe), 25, 10, 0xE86, 0)); Add(new GenericBuyInfo(typeof(Shovel), 12, 10, 0xF39, 0)); } @@ -30,7 +30,7 @@ namespace Server.Mobiles Add(typeof(Pickaxe), 12); Add(typeof(Shovel), 6); Add(typeof(Lantern), 1); - //Add( typeof( OilFlask ), 4 ); + // Add( typeof( OilFlask ), 4 ); Add(typeof(Torch), 3); Add(typeof(Bag), 3); Add(typeof(Candle), 3); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMonk.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMonk.cs index f3e252b25..3c988dcda 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMonk.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBMonk.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBMonk : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBNinja.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBNinja.cs index 507b4a6b2..f56d895d5 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBNinja.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBNinja.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBNinja : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBPlayerBarkeeper.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBPlayerBarkeeper.cs index ffc3ef4d6..821a1e827 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBPlayerBarkeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBPlayerBarkeeper.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBPlayerBarkeeper : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBProvisioner.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBProvisioner.cs index 5b28385c1..1230e4e37 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBProvisioner.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBProvisioner.cs @@ -9,21 +9,17 @@ namespace Server.Mobiles { public class SBProvisioner : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { public InternalBuyInfo() { - #region Salvage Bag - if (Core.ML) Add(new GenericBuyInfo("1079931", typeof(SalvageBag), 1255, 20, 0xE76, Utility.RandomBlueHue())); - #endregion - Add(new GenericBuyInfo("1060834", typeof(PlantBowl), 2, 20, 0x15FD, 0)); Add(new GenericBuyInfo(typeof(Arrow), 2, 20, 0xF3F, 0)); @@ -37,7 +33,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(Torch), 8, 20, 0xF6B, 0)); Add(new GenericBuyInfo(typeof(Lantern), 2, 20, 0xA25, 0)); - //TODO: Oil Flask @ 8GP + // TODO: Oil Flask @ 8GP Add(new GenericBuyInfo(typeof(Lockpick), 12, 20, 0x14FC, 0)); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRancher.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRancher.cs index e8db7d8f6..e632a7d09 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRancher.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRancher.cs @@ -4,9 +4,9 @@ namespace Server.Mobiles { public class SBRancher : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRanger.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRanger.cs index fd4d0d9e5..6c35f6b01 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRanger.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRanger.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBRanger : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRealEstateBroker.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRealEstateBroker.cs index 6914df1ae..cf552f14d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRealEstateBroker.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBRealEstateBroker.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBRealEstateBroker : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSECook.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSECook.cs index c8bf63d9b..6bda3e7d9 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSECook.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSECook.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSECook : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSEHats.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSEHats.cs index fdcab5486..30ebcfbac 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSEHats.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSEHats.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSEHats : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSamurai.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSamurai.cs index 33ecff1d4..3968b6d79 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSamurai.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSamurai.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSamurai : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBScribe.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBScribe.cs index dcb69111d..4641ca519 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBScribe.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBScribe.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBScribe : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -19,7 +19,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(BrownBook), 15, 10, 0xFEF, 0)); Add(new GenericBuyInfo(typeof(TanBook), 15, 10, 0xFF0, 0)); Add(new GenericBuyInfo(typeof(BlueBook), 15, 10, 0xFF2, 0)); - //Add( new GenericBuyInfo( "1041267", typeof( Runebook ), 3500, 10, 0xEFA, 0x461 ) ); + // Add( new GenericBuyInfo( "1041267", typeof( Runebook ), 3500, 10, 0xEFA, 0x461 ) ); } } diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBShipwright.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBShipwright.cs index aa8da3c61..44ee2c634 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBShipwright.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBShipwright.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBShipwright : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSmithTools.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSmithTools.cs index 82ec939e6..b48605d6c 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSmithTools.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBSmithTools.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSmithTools : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBStoneCrafter.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBStoneCrafter.cs index c29bee499..073adf8fc 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBStoneCrafter.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBStoneCrafter.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBStoneCrafter : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTailor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTailor.cs index a1a2dd246..dce0fb0b8 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTailor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTailor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBTailor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTanner.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTanner.cs index 8e2ca742f..3c3263564 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTanner.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTanner.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBTanner : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs index 30e5e1772..5718f3bfa 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTavernKeeper.cs @@ -6,9 +6,9 @@ namespace Server.Mobiles { public class SBTavernKeeper : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -44,7 +44,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(WoodenBowlOfStew), 3, 20, 0x1604, 0)); Add(new GenericBuyInfo(typeof(WoodenBowlOfTomatoSoup), 3, 20, 0x1606, 0)); - Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); //OSI just has Pie, not Apple/Fruit/Meat + Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); // OSI just has Pie, not Apple/Fruit/Meat Add(new GenericBuyInfo("1016450", typeof(Chessboard), 2, 20, 0xFA6, 0)); Add(new GenericBuyInfo("1016449", typeof(CheckerBoard), 2, 20, 0xFA6, 0)); @@ -56,7 +56,7 @@ namespace Server.Mobiles if (BaseHouse.NewVendorSystem) Add(new GenericBuyInfo("1062332", typeof(VendorRentalContract), 1252, 20, 0x14F0, 0x672)); - /*if ( Map == Tokuno ) + /*if (Map == Tokuno) { Add( new GenericBuyInfo( typeof( Wasabi ), 2, 20, 0x24E8, 0 ) ); Add( new GenericBuyInfo( typeof( Wasabi ), 2, 20, 0x24E9, 0 ) ); @@ -103,4 +103,4 @@ namespace Server.Mobiles } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBThief.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBThief.cs index 6e74b1b09..ce4d7562b 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBThief.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBThief.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBThief : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -17,7 +17,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(Pouch), 6, 20, 0xE79, 0)); Add(new GenericBuyInfo(typeof(Torch), 8, 20, 0xF6B, 0)); Add(new GenericBuyInfo(typeof(Lantern), 2, 20, 0xA25, 0)); - //Add( new GenericBuyInfo( typeof( OilFlask ), 8, 20, 0x####, 0 ) ); + // Add( new GenericBuyInfo( typeof( OilFlask ), 8, 20, 0x####, 0 ) ); Add(new GenericBuyInfo(typeof(Lockpick), 12, 20, 0x14FC, 0)); Add(new GenericBuyInfo(typeof(WoodenBox), 14, 20, 0x9AA, 0)); Add(new GenericBuyInfo(typeof(Key), 2, 20, 0x100E, 0)); @@ -33,7 +33,7 @@ namespace Server.Mobiles Add(typeof(Pouch), 3); Add(typeof(Torch), 3); Add(typeof(Lantern), 1); - //Add( typeof( OilFlask ), 4 ); + // Add( typeof( OilFlask ), 4 ); Add(typeof(Lockpick), 6); Add(typeof(WoodenBox), 7); Add(typeof(HairDye), 19); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTinker.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTinker.cs index 98d81172b..ff18a045c 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTinker.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBTinker.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBTinker : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -62,7 +62,6 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(Pickaxe), 25, 20, 0xE86, 0)); - Add(new GenericBuyInfo(typeof(Drums), 21, 20, 0x0E9C, 0)); Add(new GenericBuyInfo(typeof(Tambourine), 21, 20, 0x0E9E, 0)); Add(new GenericBuyInfo(typeof(LapHarp), 21, 20, 0x0EB2, 0)); diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVagabond.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVagabond.cs index 73881b51c..f8c65712e 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVagabond.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVagabond.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBVagabond : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs index 2cb6e18f4..6104d3bb9 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVarietyDealer.cs @@ -6,9 +6,9 @@ namespace Server.Mobiles { public class SBVarietyDealer : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVeterinarian.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVeterinarian.cs index a1735f8e3..a36b7ff4d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVeterinarian.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBVeterinarian.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBVeterinarian : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWaiter.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWaiter.cs index f6f2f0a8e..2ea866a70 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWaiter.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWaiter.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBWaiter : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -41,7 +41,7 @@ namespace Server.Mobiles Add(new GenericBuyInfo(typeof(WoodenBowlOfStew), 3, 20, 0x1604, 0)); Add(new GenericBuyInfo(typeof(WoodenBowlOfTomatoSoup), 3, 20, 0x1606, 0)); - Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); //OSI just has Pie, not Apple/Fruit/Meat + Add(new GenericBuyInfo(typeof(ApplePie), 7, 20, 0x1041, 0)); // OSI just has Pie, not Apple/Fruit/Meat } } diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaponSmith.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaponSmith.cs index 12639b278..c086a37d9 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaponSmith.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaponSmith.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBWeaponSmith : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { @@ -39,60 +39,60 @@ namespace Server.Mobiles switch (Utility.Random(3)) { case 0: - { - Add(new GenericBuyInfo(typeof(ExecutionersAxe), 30, 20, 0xF45, 0)); - Add(new GenericBuyInfo(typeof(Bardiche), 60, 20, 0xF4D, 0)); - Add(new GenericBuyInfo(typeof(BattleAxe), 26, 20, 0xF47, 0)); - Add(new GenericBuyInfo(typeof(TwoHandedAxe), 32, 20, 0x1443, 0)); - - Add(new GenericBuyInfo(typeof(Bow), 35, 20, 0x13B2, 0)); - - Add(new GenericBuyInfo(typeof(ButcherKnife), 14, 20, 0x13F6, 0)); - - Add(new GenericBuyInfo(typeof(Crossbow), 46, 20, 0xF50, 0)); - Add(new GenericBuyInfo(typeof(HeavyCrossbow), 55, 20, 0x13FD, 0)); - - Add(new GenericBuyInfo(typeof(Cutlass), 24, 20, 0x1441, 0)); - Add(new GenericBuyInfo(typeof(Dagger), 21, 20, 0xF52, 0)); - Add(new GenericBuyInfo(typeof(Halberd), 42, 20, 0x143E, 0)); - - Add(new GenericBuyInfo(typeof(HammerPick), 26, 20, 0x143D, 0)); - - Add(new GenericBuyInfo(typeof(Katana), 33, 20, 0x13FF, 0)); - Add(new GenericBuyInfo(typeof(Kryss), 32, 20, 0x1401, 0)); - Add(new GenericBuyInfo(typeof(Broadsword), 35, 20, 0xF5E, 0)); - Add(new GenericBuyInfo(typeof(Longsword), 55, 20, 0xF61, 0)); - Add(new GenericBuyInfo(typeof(ThinLongsword), 27, 20, 0x13B8, 0)); - Add(new GenericBuyInfo(typeof(VikingSword), 55, 20, 0x13B9, 0)); - - Add(new GenericBuyInfo(typeof(Cleaver), 15, 20, 0xEC3, 0)); - Add(new GenericBuyInfo(typeof(Axe), 40, 20, 0xF49, 0)); - Add(new GenericBuyInfo(typeof(DoubleAxe), 52, 20, 0xF4B, 0)); - Add(new GenericBuyInfo(typeof(Pickaxe), 22, 20, 0xE86, 0)); - - Add(new GenericBuyInfo(typeof(Pitchfork), 19, 20, 0xE87, 0)); - - Add(new GenericBuyInfo(typeof(Scimitar), 36, 20, 0x13B6, 0)); - - Add(new GenericBuyInfo(typeof(SkinningKnife), 14, 20, 0xEC4, 0)); - - Add(new GenericBuyInfo(typeof(LargeBattleAxe), 33, 20, 0x13FB, 0)); - Add(new GenericBuyInfo(typeof(WarAxe), 29, 20, 0x13B0, 0)); - - if (Core.AOS) { - Add(new GenericBuyInfo(typeof(BoneHarvester), 35, 20, 0x26BB, 0)); - Add(new GenericBuyInfo(typeof(CrescentBlade), 37, 20, 0x26C1, 0)); - Add(new GenericBuyInfo(typeof(DoubleBladedStaff), 35, 20, 0x26BF, 0)); - Add(new GenericBuyInfo(typeof(Lance), 34, 20, 0x26C0, 0)); - Add(new GenericBuyInfo(typeof(Pike), 39, 20, 0x26BE, 0)); - Add(new GenericBuyInfo(typeof(Scythe), 39, 20, 0x26BA, 0)); - Add(new GenericBuyInfo(typeof(CompositeBow), 50, 20, 0x26C2, 0)); - Add(new GenericBuyInfo(typeof(RepeatingCrossbow), 57, 20, 0x26C3, 0)); - } + Add(new GenericBuyInfo(typeof(ExecutionersAxe), 30, 20, 0xF45, 0)); + Add(new GenericBuyInfo(typeof(Bardiche), 60, 20, 0xF4D, 0)); + Add(new GenericBuyInfo(typeof(BattleAxe), 26, 20, 0xF47, 0)); + Add(new GenericBuyInfo(typeof(TwoHandedAxe), 32, 20, 0x1443, 0)); - break; - } + Add(new GenericBuyInfo(typeof(Bow), 35, 20, 0x13B2, 0)); + + Add(new GenericBuyInfo(typeof(ButcherKnife), 14, 20, 0x13F6, 0)); + + Add(new GenericBuyInfo(typeof(Crossbow), 46, 20, 0xF50, 0)); + Add(new GenericBuyInfo(typeof(HeavyCrossbow), 55, 20, 0x13FD, 0)); + + Add(new GenericBuyInfo(typeof(Cutlass), 24, 20, 0x1441, 0)); + Add(new GenericBuyInfo(typeof(Dagger), 21, 20, 0xF52, 0)); + Add(new GenericBuyInfo(typeof(Halberd), 42, 20, 0x143E, 0)); + + Add(new GenericBuyInfo(typeof(HammerPick), 26, 20, 0x143D, 0)); + + Add(new GenericBuyInfo(typeof(Katana), 33, 20, 0x13FF, 0)); + Add(new GenericBuyInfo(typeof(Kryss), 32, 20, 0x1401, 0)); + Add(new GenericBuyInfo(typeof(Broadsword), 35, 20, 0xF5E, 0)); + Add(new GenericBuyInfo(typeof(Longsword), 55, 20, 0xF61, 0)); + Add(new GenericBuyInfo(typeof(ThinLongsword), 27, 20, 0x13B8, 0)); + Add(new GenericBuyInfo(typeof(VikingSword), 55, 20, 0x13B9, 0)); + + Add(new GenericBuyInfo(typeof(Cleaver), 15, 20, 0xEC3, 0)); + Add(new GenericBuyInfo(typeof(Axe), 40, 20, 0xF49, 0)); + Add(new GenericBuyInfo(typeof(DoubleAxe), 52, 20, 0xF4B, 0)); + Add(new GenericBuyInfo(typeof(Pickaxe), 22, 20, 0xE86, 0)); + + Add(new GenericBuyInfo(typeof(Pitchfork), 19, 20, 0xE87, 0)); + + Add(new GenericBuyInfo(typeof(Scimitar), 36, 20, 0x13B6, 0)); + + Add(new GenericBuyInfo(typeof(SkinningKnife), 14, 20, 0xEC4, 0)); + + Add(new GenericBuyInfo(typeof(LargeBattleAxe), 33, 20, 0x13FB, 0)); + Add(new GenericBuyInfo(typeof(WarAxe), 29, 20, 0x13B0, 0)); + + if (Core.AOS) + { + Add(new GenericBuyInfo(typeof(BoneHarvester), 35, 20, 0x26BB, 0)); + Add(new GenericBuyInfo(typeof(CrescentBlade), 37, 20, 0x26C1, 0)); + Add(new GenericBuyInfo(typeof(DoubleBladedStaff), 35, 20, 0x26BF, 0)); + Add(new GenericBuyInfo(typeof(Lance), 34, 20, 0x26C0, 0)); + Add(new GenericBuyInfo(typeof(Pike), 39, 20, 0x26BE, 0)); + Add(new GenericBuyInfo(typeof(Scythe), 39, 20, 0x26BA, 0)); + Add(new GenericBuyInfo(typeof(CompositeBow), 50, 20, 0x26C2, 0)); + Add(new GenericBuyInfo(typeof(RepeatingCrossbow), 57, 20, 0x26C3, 0)); + } + + break; + } } } } diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaver.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaver.cs index e3d427314..7bdba6d71 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaver.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SBWeaver.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBWeaver : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEArmor.cs index 4c680ef11..f26cf51ae 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSEArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEBowyer.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEBowyer.cs index 55b120cf8..55bf5c738 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEBowyer.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEBowyer.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSEBowyer : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSECarpenter.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSECarpenter.cs index 7bff0eb92..bf1d01db1 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSECarpenter.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSECarpenter.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSECarpenter : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEFood.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEFood.cs index be03374b2..4490801f5 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEFood.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEFood.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSEFood : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSELeatherArmor.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSELeatherArmor.cs index 7bd5fa9ea..c80246d4f 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSELeatherArmor.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSELeatherArmor.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSELeatherArmor : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEWeapons.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEWeapons.cs index a97354d95..b8b75cd7c 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEWeapons.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/SE/SBSEWeapons.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSEWeapons : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBAxeWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBAxeWeapon.cs index 304746d00..4cfe320c1 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBAxeWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBAxeWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBAxeWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBKnifeWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBKnifeWeapon.cs index 1df846f6e..84f961598 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBKnifeWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBKnifeWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBKnifeWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBMaceWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBMaceWeapon.cs index b881944b5..e1a88346f 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBMaceWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBMaceWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBMaceWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBPoleArmWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBPoleArmWeapon.cs index 7ab86d4de..ceac524c7 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBPoleArmWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBPoleArmWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBPoleArmWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBRangedWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBRangedWeapon.cs index 9d62a0176..245a17f05 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBRangedWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBRangedWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBRangedWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSpearForkWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSpearForkWeapon.cs index e044dbf7e..e8eb14b4d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSpearForkWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSpearForkWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSpearForkWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBStavesWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBStavesWeapon.cs index 5b06d87dd..3a119d27d 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBStavesWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBStavesWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBStavesWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSwordWeapon.cs b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSwordWeapon.cs index a9797b0f5..4c7cb6eb3 100644 --- a/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSwordWeapon.cs +++ b/Projects/Scripts/Mobiles/Vendors/SBInfo/Weapons/SBSwordWeapon.cs @@ -5,9 +5,9 @@ namespace Server.Mobiles { public class SBSwordWeapon : SBInfo { - public override IShopSellInfo SellInfo{ get; } = new InternalSellInfo(); + public override IShopSellInfo SellInfo { get; } = new InternalSellInfo(); - public override List BuyInfo{ get; } = new InternalBuyInfo(); + public override List BuyInfo { get; } = new InternalBuyInfo(); public class InternalBuyInfo : List { diff --git a/Projects/Scripts/Mobiles/Vendors/VendorInventory.cs b/Projects/Scripts/Mobiles/Vendors/VendorInventory.cs index 039e8dadc..204d310b2 100644 --- a/Projects/Scripts/Mobiles/Vendors/VendorInventory.cs +++ b/Projects/Scripts/Mobiles/Vendors/VendorInventory.cs @@ -8,7 +8,7 @@ namespace Server.Mobiles { public static readonly TimeSpan GracePeriod = TimeSpan.FromDays(7.0); - private Timer m_ExpireTimer; + private readonly Timer m_ExpireTimer; public VendorInventory(BaseHouse house, Mobile owner, string vendorName, string shopName) { @@ -51,19 +51,19 @@ namespace Server.Mobiles } } - public BaseHouse House{ get; set; } + public BaseHouse House { get; set; } - public string VendorName{ get; set; } + public string VendorName { get; set; } - public string ShopName{ get; set; } + public string ShopName { get; set; } - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } - public List Items{ get; } + public List Items { get; } - public int Gold{ get; set; } + public int Gold { get; set; } - public DateTime ExpireTime{ get; } + public DateTime ExpireTime { get; } public void AddItem(Item item) { @@ -99,7 +99,7 @@ namespace Server.Mobiles private class ExpireTimer : Timer { - private VendorInventory m_Inventory; + private readonly VendorInventory m_Inventory; public ExpireTimer(VendorInventory inventory, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Multis/BaseHouse.cs b/Projects/Scripts/Multis/BaseHouse.cs index b8ab229ee..1c28c4905 100644 --- a/Projects/Scripts/Multis/BaseHouse.cs +++ b/Projects/Scripts/Multis/BaseHouse.cs @@ -24,7 +24,7 @@ namespace Server.Multis public const int MaximumBarkeepCount = 2; - private static Dictionary> m_Table = new Dictionary>(); + private static readonly Dictionary> m_Table = new Dictionary>(); private DecayLevel m_LastDecayLevel; @@ -37,7 +37,7 @@ namespace Server.Multis private Point3D m_RelativeBanLocation; private TrashBarrel m_Trash; - public BaseHouse(int multiID, Mobile owner, int MaxLockDown, int MaxSecure) : base(multiID) + public BaseHouse(int multiID, Mobile owner, int maxLockDown, int maxSecure) : base(multiID) { AllHouses.Add(this); @@ -61,8 +61,8 @@ namespace Server.Multis m_Owner = owner; - MaxLockDowns = MaxLockDown; - MaxSecures = MaxSecure; + MaxLockDowns = maxLockDown; + MaxSecures = maxSecure; m_RelativeBanLocation = BaseBanLocation; @@ -91,10 +91,10 @@ namespace Server.Multis public static int MaxBans => !Core.AOS ? 50 : 140; [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastRefreshed{ get; set; } + public DateTime LastRefreshed { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool RestrictDecay{ get; set; } + public bool RestrictDecay { get; set; } public virtual TimeSpan DecayPeriod => TimeSpan.FromDays(5.0); @@ -184,7 +184,7 @@ namespace Server.Multis { DecayLevel stage = m_CurrentStage; - if (stage == DecayLevel.Ageless || DynamicDecay.Decays(stage) && NextDecayStage <= DateTime.UtcNow) + if (stage == DecayLevel.Ageless || (DynamicDecay.Decays(stage) && NextDecayStage <= DateTime.UtcNow)) SetDynamicDecay(++stage); if (stage == DecayLevel.Collapsed && (HasRentedVendors || VendorInventories.Count > 0)) @@ -242,8 +242,6 @@ namespace Server.Multis } } - #region Mondain's Legacy - public bool HasAddonContainers { get @@ -256,12 +254,10 @@ namespace Server.Multis } } - #endregion + public static List AllHouses { get; } = new List(); - public static List AllHouses{ get; } = new List(); - - public abstract Rectangle2D[] Area{ get; } - public abstract Point3D BaseBanLocation{ get; } + public abstract Rectangle2D[] Area { get; } + public abstract Point3D BaseBanLocation { get; } public override bool Decays => false; @@ -296,7 +292,7 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public int Visits{ get; set; } + public int Visits { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Public @@ -317,7 +313,7 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public int MaxSecures{ get; set; } + public int MaxSecures { get; set; } [CommandProperty(AccessLevel.GameMaster)] public Point3D BanLocation @@ -347,18 +343,18 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public int MaxLockDowns{ get; set; } + public int MaxLockDowns { get; set; } public Region Region => m_Region; - public List CoOwners{ get; set; } + public List CoOwners { get; set; } - public List Friends{ get; set; } + public List Friends { get; set; } - public List Access{ get; set; } + public List Access { get; set; } - public List Bans{ get; set; } + public List Bans { get; set; } - public List Doors{ get; set; } + public List Doors { get; set; } public int LockDownCount { @@ -406,31 +402,31 @@ namespace Server.Multis } } - public List Addons{ get; set; } + public List Addons { get; set; } - public List LockDowns{ get; private set; } + public List LockDowns { get; private set; } - public List Secures{ get; private set; } + public List Secures { get; private set; } - public HouseSign Sign{ get; set; } + public HouseSign Sign { get; set; } - public List PlayerVendors{ get; } = new List(); + public List PlayerVendors { get; } = new List(); - public List PlayerBarkeepers{ get; } = new List(); + public List PlayerBarkeepers { get; } = new List(); - public List VendorRentalContracts{ get; private set; } + public List VendorRentalContracts { get; private set; } - public List VendorInventories{ get; } = new List(); + public List VendorInventories { get; } = new List(); - public List RelocatedEntities{ get; } = new List(); + public List RelocatedEntities { get; } = new List(); - public MovingCrate MovingCrate{ get; set; } + public MovingCrate MovingCrate { get; set; } - public List InternalizedVendors{ get; private set; } + public List InternalizedVendors { get; private set; } - public DateTime BuiltOn{ get; set; } + public DateTime BuiltOn { get; set; } - public DateTime LastTraded{ get; set; } + public DateTime LastTraded { get; set; } public virtual HousePlacementEntry ConvertEntry => null; public virtual int ConvertOffsetX => 0; @@ -440,7 +436,7 @@ namespace Server.Multis public virtual int DefaultPrice => 0; [CommandProperty(AccessLevel.GameMaster)] - public int Price{ get; set; } + public int Price { get; set; } public static void Decay_OnTick() { @@ -592,8 +588,7 @@ namespace Server.Multis public override bool InRange(IPoint2D from, int range) { return Region?.Area.Any(rect => - from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range - ) == true; + from.X >= rect.Start.X - range && from.Y >= rect.Start.Y - range && from.X < rect.End.X + range && from.Y < rect.End.Y + range) == true; } public virtual int GetNewVendorSystemMaxVendors() @@ -739,8 +734,6 @@ namespace Server.Multis if (deed != null) { - #region Mondain's Legacy - if (deed is BaseAddonContainerDeed containerDeed && addon is BaseAddonContainer c) { c.DropItemsToGround(); @@ -751,8 +744,6 @@ namespace Server.Multis addonDeed.Resource = ba.Resource; } - #endregion - addon.Delete(); if (retainDeedHue) @@ -888,11 +879,10 @@ namespace Server.Multis if (addon != null) { Item deed = addon.Deed; - bool retainDeedHue = false; //if the items aren't hued but the deed itself is + bool retainDeedHue = false; // if the items aren't hued but the deed itself is int hue = 0; - if (item is BaseAddon ba && ba.RetainDeedHue - ) //There are things that are IAddon which aren't BaseAddon + if (item is BaseAddon ba && ba.RetainDeedHue) // There are things that are IAddon which aren't BaseAddon { retainDeedHue = true; @@ -905,8 +895,6 @@ namespace Server.Multis } } - #region Mondain's Legacy - if (deed != null) { if (deed is BaseAddonContainerDeed containerDeed && item is BaseAddonContainer c) @@ -922,8 +910,6 @@ namespace Server.Multis deed.Hue = hue; } - #endregion - relocateItem = deed; item.Delete(); } @@ -1200,7 +1186,7 @@ namespace Server.Multis continue; // Signs and signposts are not considered part of the multi - if (id >= 0xB95 && id <= 0xC0E || id >= 0xC43 && id <= 0xC44) + if ((id >= 0xB95 && id <= 0xC0E) || (id >= 0xC43 && id <= 0xC44)) continue; int tileZ = tile.Z + Z; @@ -1275,9 +1261,9 @@ namespace Server.Multis if (LockDowns == null) return; - int x = base.Location.X - oldLocation.X; - int y = base.Location.Y - oldLocation.Y; - int z = base.Location.Z - oldLocation.Z; + int x = this.Location.X - oldLocation.X; + int y = this.Location.Y - oldLocation.Y; + int z = this.Location.Z - oldLocation.Z; if (Sign?.Deleted == false) Sign.Location = new Point3D(Sign.X + x, Sign.Y + y, Sign.Z + z); @@ -1382,7 +1368,7 @@ namespace Server.Multis if (itemID >= 0x675 && itemID < 0x6F5) { int type = (itemID - 0x675) / 16; - DoorFacing facing = (DoorFacing)(((itemID - 0x675) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x675) / 2 % 8); door = type switch { @@ -1400,53 +1386,53 @@ namespace Server.Multis else if (itemID >= 0x314 && itemID < 0x364) { int type = (itemID - 0x314) / 16; - DoorFacing facing = (DoorFacing)(((itemID - 0x314) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x314) / 2 % 8); door = new GenericHouseDoor(facing, 0x314 + (type * 16), 0xED, 0xF4); } else if (itemID >= 0x824 && itemID < 0x834) { - DoorFacing facing = (DoorFacing)(((itemID - 0x824) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x824) / 2 % 8); door = new GenericHouseDoor(facing, 0x824, 0xEC, 0xF3); } else if (itemID >= 0x839 && itemID < 0x849) { - DoorFacing facing = (DoorFacing)(((itemID - 0x839) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x839) / 2 % 8); door = new GenericHouseDoor(facing, 0x839, 0xEB, 0xF2); } else if (itemID >= 0x84C && itemID < 0x85C) { - DoorFacing facing = (DoorFacing)(((itemID - 0x84C) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x84C) / 2 % 8); door = new GenericHouseDoor(facing, 0x84C, 0xEC, 0xF3); } else if (itemID >= 0x866 && itemID < 0x876) { - DoorFacing facing = (DoorFacing)(((itemID - 0x866) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x866) / 2 % 8); door = new GenericHouseDoor(facing, 0x866, 0xEB, 0xF2); } else if (itemID >= 0xE8 && itemID < 0xF8) { - DoorFacing facing = (DoorFacing)(((itemID - 0xE8) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0xE8) / 2 % 8); door = new GenericHouseDoor(facing, 0xE8, 0xED, 0xF4); } else if (itemID >= 0x1FED && itemID < 0x1FFD) { - DoorFacing facing = (DoorFacing)(((itemID - 0x1FED) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x1FED) / 2 % 8); door = new GenericHouseDoor(facing, 0x1FED, 0xEC, 0xF3); } else if (itemID >= 0x241F && itemID < 0x2421) { - //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); + // DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); door = new GenericHouseDoor(DoorFacing.NorthCCW, 0x2415, -1, -1); } else if (itemID >= 0x2423 && itemID < 0x2425) { - //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); - //This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these + // DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); + // This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these door = new GenericHouseDoor(DoorFacing.WestCW, 0x2423, -1, -1); } else if (itemID >= 0x2A05 && itemID < 0x2A1D) { - DoorFacing facing = (DoorFacing)((((itemID - 0x2A05) / 2) % 4) + 8); + DoorFacing facing = (DoorFacing)(((itemID - 0x2A05) / 2 % 4) + 8); int sound = (itemID >= 0x2A0D && itemID < 0x2a15) ? 0x539 : -1; @@ -1463,7 +1449,7 @@ namespace Server.Multis else if (itemID >= 0x2D63 && itemID < 0x2D70) { int mod = (itemID - 0x2D63) / 2 % 2; - DoorFacing facing = ((mod == 0) ? DoorFacing.SouthCCW : DoorFacing.WestCCW); + DoorFacing facing = (mod == 0) ? DoorFacing.SouthCCW : DoorFacing.WestCCW; int type = (itemID - 0x2D63) / 4; @@ -1475,14 +1461,14 @@ namespace Server.Multis } else if (itemID >= 0x319C && itemID < 0x31AE) { - //special case for 0x31aa <-> 0x31a8 (a9) + // special case for 0x31aa <-> 0x31a8 (a9) int mod = (itemID - 0x319C) / 2 % 2; var facing = itemID switch { - 0x31AA => ((mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW), - 0x31A8 => ((mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW), - _ => ((mod == 0) ? DoorFacing.EastCW : DoorFacing.NorthCW) + 0x31AA => (mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW, + 0x31A8 => (mod == 0) ? DoorFacing.NorthCW : DoorFacing.EastCW, + _ => (mod == 0) ? DoorFacing.EastCW : DoorFacing.NorthCW }; int type = (itemID - 0x319C) / 4; @@ -1492,7 +1478,7 @@ namespace Server.Multis else if (itemID >= 0x367B && itemID < 0x369B) { int type = (itemID - 0x367B) / 16; - DoorFacing facing = (DoorFacing)(((itemID - 0x367B) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x367B) / 2 % 8); door = type switch { @@ -1520,8 +1506,8 @@ namespace Server.Multis else if (itemID >= 0x436E && itemID < 0x437E) { /* These ones had to be different... - * Offset 0 2 4 6 8 10 12 14 - * DoorFacing 2 3 2 3 6 7 6 7 + * Offset 0 2 4 6 8 10 12 14 + * DoorFacing 2 3 2 3 6 7 6 7 */ int offset = itemID - 0x436E; DoorFacing facing = (DoorFacing)((offset / 2 + 2 * ((1 + offset / 4) % 2)) % 8); @@ -1550,19 +1536,19 @@ namespace Server.Multis else if (itemID >= 0x9AD7 && itemID <= 0x9AE6) { int type = (itemID - 0x9AD7) / 16; - DoorFacing facing = (DoorFacing)(((itemID - 0x9AD7) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x9AD7) / 2 % 8); door = new GenericHouseDoor(facing, 0x9AD7 + (type * 16), 0xED, 0xF4); } else if (itemID >= 0x9B3C && itemID <= 0x9B4B) { int type = (itemID - 0x9B3C) / 16; - DoorFacing facing = (DoorFacing)(((itemID - 0x9B3C) / 2) % 8); + DoorFacing facing = (DoorFacing)((itemID - 0x9B3C) / 2 % 8); door = new GenericHouseDoor(facing, 0x9B3C + (type * 16), 0xED, 0xF4); } if (door != null) { - if (from != null) door.KeyValue = CreateKeys(@from); + if (from != null) door.KeyValue = CreateKeys(from); AddDoor(door, xOffset, yOffset, zOffset); } @@ -1574,13 +1560,10 @@ namespace Server.Multis return door; } - private static DoorFacing GetSADoorFacing(int offset) - { - /* Offset 0 2 4 6 - * DoorFacing 2 3 6 7 - */ - return (DoorFacing)((offset / 2 + 2 * (1 + offset / 4)) % 8); - } + /* Offset 0 2 4 6 + * DoorFacing 2 3 6 7 + */ + private static DoorFacing GetSADoorFacing(int offset) => (DoorFacing)((offset / 2 + 2 * (1 + offset / 4)) % 8); public uint CreateKeys(Mobile m) { @@ -1663,9 +1646,11 @@ namespace Server.Multis m_Trash = new TrashBarrel { Movable = false }; m_Trash.MoveToWorld(from.Location, from.Map); - from.SendLocalizedMessage(502121); /* You have a new trash barrel. - * Three minutes after you put something in the barrel, the trash will be emptied. - * Be forewarned, this is permanent! */ + /* You have a new trash barrel. + * Three minutes after you put something in the barrel, the trash will be emptied. + * Be forewarned, this is permanent! + */ + from.SendLocalizedMessage(502121); } else { @@ -1726,7 +1711,7 @@ namespace Server.Multis if (!IsCoOwner(m) || !IsActive) return false; - if (item is BaseAddonContainer || item.Movable && !HasSecureItem(item)) + if (item is BaseAddonContainer || (item.Movable && !HasSecureItem(item))) { int amt = 1 + item.TotalItems; @@ -1735,15 +1720,15 @@ namespace Server.Multis if (checkIsInside && item.RootParent is Mobile) { - m.SendLocalizedMessage(1005525); //That is not in your house + m.SendLocalizedMessage(1005525); // That is not in your house } else if (checkIsInside && !IsInside(item.GetWorldLocation(), item.ItemData.Height)) { - m.SendLocalizedMessage(1005525); //That is not in your house + m.SendLocalizedMessage(1005525); // That is not in your house } else if (Ethic.IsImbued(item)) { - m.SendLocalizedMessage(1005377); //You cannot lock that down + m.SendLocalizedMessage(1005377); // You cannot lock that down } else if (HasSecureItem(rootItem)) { @@ -1757,7 +1742,7 @@ namespace Server.Multis ? !CheckAosLockdowns(amt) || !CheckAosStorage(amt) : LockDownCount + amt > MaxLockDowns)) { - m.SendLocalizedMessage(1005379); //That would exceed the maximum lock down limit for this house + m.SendLocalizedMessage(1005379); // That would exceed the maximum lock down limit for this house } else { @@ -1767,7 +1752,7 @@ namespace Server.Multis } else if (LockDowns.IndexOf(item) != -1) { - m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1005526); //That is already locked down + m.LocalOverheadMessage(MessageType.Regular, 0x3E9, 1005526); // That is already locked down return true; } else if (item is HouseSign || item is Static) @@ -1776,7 +1761,7 @@ namespace Server.Multis } else { - m.SendLocalizedMessage(1005377); //You cannot lock that down + m.SendLocalizedMessage(1005377); // You cannot lock that down } return false; @@ -1943,9 +1928,9 @@ namespace Server.Multis if (HasLockedDownItem(item)) { - item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501657); //[no longer locked down] + item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501657); // [no longer locked down] SetLockdown(item, false); - //TidyItemList( m_LockDowns ); + // TidyItemList( m_LockDowns ); (item as RewardBrazier)?.TurnOff(); } @@ -2030,7 +2015,7 @@ namespace Server.Multis public virtual bool IsCombatRestricted(Mobile m) { - if (m?.Player != true || m.AccessLevel >= AccessLevel.GameMaster || !IsAosRules || m_Owner != null && m_Owner.AccessLevel >= AccessLevel.GameMaster) + if (m?.Player != true || m.AccessLevel >= AccessLevel.GameMaster || !IsAosRules || (m_Owner != null && m_Owner.AccessLevel >= AccessLevel.GameMaster)) return false; for (int i = 0; i < m.Aggressed.Count; ++i) @@ -2040,7 +2025,7 @@ namespace Server.Multis if (info.Defender.Player && info.Defender.Alive && DateTime.UtcNow - info.LastCombatTime < HouseRegion.CombatHeatDelay && (!(m.Guild is Guild attackerGuild) || !(info.Defender.Guild is Guild defenderGuild) || - defenderGuild != attackerGuild && !defenderGuild.IsEnemy(attackerGuild))) + (defenderGuild != attackerGuild && !defenderGuild.IsEnemy(attackerGuild)))) return true; } @@ -2080,23 +2065,18 @@ namespace Server.Multis item.IsLockedDown = false; item.IsSecure = false; - #region Mondain's Legacy - if (item is BaseAddonContainer) item.Movable = false; else - - #endregion - item.Movable = true; item.SetLastMoved(); - item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501656); //[no longer secure] + item.PublicOverheadMessage(MessageType.Label, 0x3B2, 501656); // [no longer secure] Secures.RemoveAt(i); return; } } - m.SendLocalizedMessage(501717); //This isn't secure... + m.SendLocalizedMessage(501717); // This isn't secure... } public void AddStrongBox(Mobile from) @@ -2112,7 +2092,7 @@ namespace Server.Multis if (IsAosRules ? !CheckAosLockdowns(1) : LockDownCount + 1 > MaxLockDowns) { - from.SendLocalizedMessage(1005379); //That would exceed the maximum lock down limit for this house + from.SendLocalizedMessage(1005379); // That would exceed the maximum lock down limit for this house return; } @@ -2122,7 +2102,7 @@ namespace Server.Multis if (!c.Deleted && c is StrongBox box && box.Owner == from) { - from.SendLocalizedMessage(502112); //You already have a strong box + from.SendLocalizedMessage(502112); // You already have a strong box return; } } @@ -2178,9 +2158,10 @@ namespace Server.Multis targ.MoveToWorld(BanLocation, Map); from.SendLocalizedMessage(1042840, targ.Name); // ~1_PLAYER NAME~ has been ejected from this house. - targ.SendLocalizedMessage(501341); /* You have been ejected from this house. - * If you persist in entering, you may be banned from the house. - */ + /* You have been ejected from this house. + * If you persist in entering, you may be banned from the house. + */ + targ.SendLocalizedMessage(501341); } } @@ -2476,7 +2457,7 @@ namespace Server.Multis writer.Write(m_Public); - //writer.Write( BanLocation ); + // writer.Write( BanLocation ); writer.Write(m_Owner); @@ -2496,7 +2477,7 @@ namespace Server.Multis writer.WriteItemList(Doors, true); writer.WriteItemList(LockDowns, true); - //writer.WriteItemList( m_Secures, true ); + // writer.WriteItemList( m_Secures, true ); writer.Write(MaxLockDowns); writer.Write(MaxSecures); @@ -2533,192 +2514,192 @@ namespace Server.Multis switch (version) { case 15: - { - int stage = reader.ReadInt(); - - if (stage != -1) { - m_CurrentStage = (DecayLevel)stage; - NextDecayStage = reader.ReadDateTime(); - loadedDynamicDecay = true; - } + int stage = reader.ReadInt(); - goto case 14; - } + if (stage != -1) + { + m_CurrentStage = (DecayLevel)stage; + NextDecayStage = reader.ReadDateTime(); + loadedDynamicDecay = true; + } + + goto case 14; + } case 14: - { - m_RelativeBanLocation = reader.ReadPoint3D(); - goto case 13; - } + { + m_RelativeBanLocation = reader.ReadPoint3D(); + goto case 13; + } case 13: // removed ban location serialization case 12: - { - VendorRentalContracts = reader.ReadStrongItemList(); - InternalizedVendors = reader.ReadStrongMobileList(); - - int relocatedCount = reader.ReadEncodedInt(); - for (int i = 0; i < relocatedCount; i++) { - Point3D relLocation = reader.ReadPoint3D(); - IEntity entity = World.FindEntity(reader.ReadUInt()); + VendorRentalContracts = reader.ReadStrongItemList(); + InternalizedVendors = reader.ReadStrongMobileList(); - if (entity != null) - RelocatedEntities.Add(new RelocatedEntity(entity, relLocation)); + int relocatedCount = reader.ReadEncodedInt(); + for (int i = 0; i < relocatedCount; i++) + { + Point3D relLocation = reader.ReadPoint3D(); + IEntity entity = World.FindEntity(reader.ReadUInt()); + + if (entity != null) + RelocatedEntities.Add(new RelocatedEntity(entity, relLocation)); + } + + int inventoryCount = reader.ReadEncodedInt(); + for (int i = 0; i < inventoryCount; i++) + { + VendorInventory inventory = new VendorInventory(this, reader); + VendorInventories.Add(inventory); + } + + goto case 11; } - - int inventoryCount = reader.ReadEncodedInt(); - for (int i = 0; i < inventoryCount; i++) - { - VendorInventory inventory = new VendorInventory(this, reader); - VendorInventories.Add(inventory); - } - - goto case 11; - } case 11: - { - LastRefreshed = reader.ReadDateTime(); - RestrictDecay = reader.ReadBool(); - goto case 10; - } + { + LastRefreshed = reader.ReadDateTime(); + RestrictDecay = reader.ReadBool(); + goto case 10; + } case 10: // just a signal for updates case 9: - { - Visits = reader.ReadInt(); - goto case 8; - } + { + Visits = reader.ReadInt(); + goto case 8; + } case 8: - { - Price = reader.ReadInt(); - goto case 7; - } + { + Price = reader.ReadInt(); + goto case 7; + } case 7: - { - Access = reader.ReadStrongMobileList(); - goto case 6; - } + { + Access = reader.ReadStrongMobileList(); + goto case 6; + } case 6: - { - BuiltOn = reader.ReadDateTime(); - LastTraded = reader.ReadDateTime(); - goto case 5; - } + { + BuiltOn = reader.ReadDateTime(); + LastTraded = reader.ReadDateTime(); + goto case 5; + } case 5: // just removed fields case 4: - { - Addons = reader.ReadStrongItemList(); - goto case 3; - } + { + Addons = reader.ReadStrongItemList(); + goto case 3; + } case 3: - { - count = reader.ReadInt(); - Secures = new List(count); - - for (int i = 0; i < count; ++i) - { - SecureInfo info = new SecureInfo(reader); - - if (info.Item != null) - { - info.Item.IsSecure = true; - Secures.Add(info); - } - } - - goto case 2; - } - case 2: - { - m_Public = reader.ReadBool(); - goto case 1; - } - case 1: - { - if (version < 13) - reader.ReadPoint3D(); // house ban location - goto case 0; - } - case 0: - { - if (version < 14) - m_RelativeBanLocation = BaseBanLocation; - - if (version < 12) - { - VendorRentalContracts = new List(); - InternalizedVendors = new List(); - } - - if (version < 4) - Addons = new List(); - - if (version < 7) - Access = new List(); - - if (version < 8) - Price = DefaultPrice; - - m_Owner = reader.ReadMobile(); - - if (version < 5) { count = reader.ReadInt(); + Secures = new List(count); - for (int i = 0; i < count; i++) - reader.ReadRect2D(); - } + for (int i = 0; i < count; ++i) + { + SecureInfo info = new SecureInfo(reader); - UpdateRegion(); - - CoOwners = reader.ReadStrongMobileList(); - Friends = reader.ReadStrongMobileList(); - Bans = reader.ReadStrongMobileList(); - - Sign = reader.ReadItem() as HouseSign; - m_Trash = reader.ReadItem() as TrashBarrel; - - Doors = reader.ReadStrongItemList(); - LockDowns = reader.ReadStrongItemList(); - - for (int i = 0; i < LockDowns.Count; ++i) - LockDowns[i].IsLockedDown = true; - - for (int i = 0; i < VendorRentalContracts.Count; ++i) - VendorRentalContracts[i].IsLockedDown = true; - - if (version < 3) - { - List items = reader.ReadStrongItemList(); - Secures = new List(items.Count); - - for (int i = 0; i < items.Count; ++i) - if (items[i] is Container c) + if (info.Item != null) { - c.IsSecure = true; - Secures.Add(new SecureInfo(c, SecureLevel.CoOwners)); + info.Item.IsSecure = true; + Secures.Add(info); } + } + + goto case 2; } - - MaxLockDowns = reader.ReadInt(); - MaxSecures = reader.ReadInt(); - - if ((Map == null || Map == Map.Internal) && Location == Point3D.Zero) - Delete(); - - if (m_Owner != null) + case 2: { - if (!m_Table.TryGetValue(m_Owner, out List list)) - m_Table[m_Owner] = list = new List(); - - list.Add(this); + m_Public = reader.ReadBool(); + goto case 1; } + case 1: + { + if (version < 13) + reader.ReadPoint3D(); // house ban location + goto case 0; + } + case 0: + { + if (version < 14) + m_RelativeBanLocation = BaseBanLocation; - break; - } + if (version < 12) + { + VendorRentalContracts = new List(); + InternalizedVendors = new List(); + } + + if (version < 4) + Addons = new List(); + + if (version < 7) + Access = new List(); + + if (version < 8) + Price = DefaultPrice; + + m_Owner = reader.ReadMobile(); + + if (version < 5) + { + count = reader.ReadInt(); + + for (int i = 0; i < count; i++) + reader.ReadRect2D(); + } + + UpdateRegion(); + + CoOwners = reader.ReadStrongMobileList(); + Friends = reader.ReadStrongMobileList(); + Bans = reader.ReadStrongMobileList(); + + Sign = reader.ReadItem() as HouseSign; + m_Trash = reader.ReadItem() as TrashBarrel; + + Doors = reader.ReadStrongItemList(); + LockDowns = reader.ReadStrongItemList(); + + for (int i = 0; i < LockDowns.Count; ++i) + LockDowns[i].IsLockedDown = true; + + for (int i = 0; i < VendorRentalContracts.Count; ++i) + VendorRentalContracts[i].IsLockedDown = true; + + if (version < 3) + { + List items = reader.ReadStrongItemList(); + Secures = new List(items.Count); + + for (int i = 0; i < items.Count; ++i) + if (items[i] is Container c) + { + c.IsSecure = true; + Secures.Add(new SecureInfo(c, SecureLevel.CoOwners)); + } + } + + MaxLockDowns = reader.ReadInt(); + MaxSecures = reader.ReadInt(); + + if ((Map == null || Map == Map.Internal) && Location == Point3D.Zero) + Delete(); + + if (m_Owner != null) + { + if (!m_Table.TryGetValue(m_Owner, out List list)) + m_Table[m_Owner] = list = new List(); + + list.Add(this); + } + + break; + } } if (version <= 1) - ChangeSignType(0xBD2); //private house, plain brass sign + ChangeSignType(0xBD2); // private house, plain brass sign if (version < 10) Timer.DelayCall(TimeSpan.Zero, FixLockdowns_Sandbox); @@ -2915,11 +2896,10 @@ namespace Server.Multis if (!item.Deleted && item is IAddon addon) { Item deed = addon.Deed; - bool retainDeedHue = false; //if the items aren't hued but the deed itself is + bool retainDeedHue = false; // if the items aren't hued but the deed itself is int hue = 0; - if (addon is BaseAddon ba && ba.RetainDeedHue - ) //There are things that are IAddon which aren't BaseAddon + if (addon is BaseAddon ba && ba.RetainDeedHue) // There are things that are IAddon which aren't BaseAddon { retainDeedHue = true; @@ -2974,11 +2954,11 @@ namespace Server.Multis public bool IsOwner(Mobile m) => m != null && (m == m_Owner || m.AccessLevel >= AccessLevel.GameMaster || - IsAosRules && AccountHandler.CheckAccount(m, m_Owner)); + (IsAosRules && AccountHandler.CheckAccount(m, m_Owner))); public bool IsCoOwner(Mobile m) => m != null && CoOwners != null && - (IsOwner(m) || CoOwners.Contains(m) || !IsAosRules && AccountHandler.CheckAccount(m, m_Owner)); + (IsOwner(m) || CoOwners.Contains(m) || (!IsAosRules && AccountHandler.CheckAccount(m, m_Owner))); public bool IsGuildMember(Mobile m) => m != null && Owner?.Guild != null && m.Guild == Owner.Guild; @@ -3064,7 +3044,7 @@ namespace Server.Multis public bool HasLockedDownItem(Item check) => LockDowns?.Contains(check) == true || - check is VendorRentalContract contract && VendorRentalContracts.Contains(contract); + (check is VendorRentalContract contract && VendorRentalContracts.Contains(contract)); public bool HasSecureItem(Item item) { @@ -3096,7 +3076,7 @@ namespace Server.Multis private class TransferItem : Item { - private BaseHouse m_House; + private readonly BaseHouse m_House; public TransferItem(BaseHouse house) : base(0x14F0) { @@ -3179,15 +3159,16 @@ namespace Server.Multis if (m_House?.Deleted != false || !m_House.IsOwner(from) || !from.CheckAlive() || !to.CheckAlive()) return; - if (!accepted) return; from.SendLocalizedMessage(501338); // You have transferred ownership of the house. - to.SendLocalizedMessage(501339); /* You are now the owner of this house. - * The house's co-owner, friend, ban, and access lists have been cleared. - * You should double-check the security settings on any doors and teleporters in the house. - */ + + /* You are now the owner of this house. + * The house's co-owner, friend, ban, and access lists have been cleared. + * You should double-check the security settings on any doors and teleporters in the house. + */ + to.SendLocalizedMessage(501339); m_House.RemoveKeys(from); m_House.Owner = to; @@ -3201,8 +3182,11 @@ namespace Server.Multis private class FixColumnTimer : Timer { - private Map m_Map; - private int m_StartX, m_StartY, m_EndX, m_EndY; + private readonly Map m_Map; + private readonly int m_StartX; + private readonly int m_StartY; + private readonly int m_EndX; + private readonly int m_EndY; public FixColumnTimer(BaseMulti multi) : base(TimeSpan.Zero) { @@ -3222,17 +3206,15 @@ namespace Server.Multis return; for (int x = m_StartX; x <= m_EndX; ++x) - for (int y = m_StartY; y <= m_EndY; ++y) - m_Map.FixColumn(x, y); + for (int y = m_StartY; y <= m_EndY; ++y) + m_Map.FixColumn(x, y); } } - #region Dynamic decay system - private DecayLevel m_CurrentStage; [CommandProperty(AccessLevel.GameMaster)] - public DateTime NextDecayStage{ get; set; } + public DateTime NextDecayStage { get; set; } public void ResetDynamicDecay() { @@ -3249,8 +3231,6 @@ namespace Server.Multis else NextDecayStage = DateTime.MinValue; } - - #endregion } public enum DecayType @@ -3304,9 +3284,9 @@ namespace Server.Multis Level = (SecureLevel)reader.ReadByte(); } - public Container Item{ get; } + public Container Item { get; } - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public void Serialize(IGenericWriter writer) { @@ -3323,17 +3303,15 @@ namespace Server.Multis RelativeLocation = relativeLocation; } - public IEntity Entity{ get; } + public IEntity Entity { get; } - public Point3D RelativeLocation{ get; } + public Point3D RelativeLocation { get; } } - #region Targets - public class LockdownTarget : Target { - private BaseHouse m_House; - private bool m_Release; + private readonly BaseHouse m_House; + private readonly bool m_Release; public LockdownTarget(bool release, BaseHouse house) : base(12, false, TargetFlags.None) { @@ -3399,15 +3377,15 @@ namespace Server.Multis } else { - from.SendLocalizedMessage(1005377); //You cannot lock that down + from.SendLocalizedMessage(1005377); // You cannot lock that down } } } public class SecureTarget : Target { - private BaseHouse m_House; - private bool m_Release; + private readonly BaseHouse m_House; + private readonly bool m_Release; public SecureTarget(bool release, BaseHouse house) : base(12, false, TargetFlags.None) { @@ -3465,14 +3443,14 @@ namespace Server.Multis } else { - from.SendLocalizedMessage(1010424); //You cannot secure this + from.SendLocalizedMessage(1010424); // You cannot secure this } } } public class HouseKickTarget : Target { - private BaseHouse m_House; + private readonly BaseHouse m_House; public HouseKickTarget(BaseHouse house) : base(-1, false, TargetFlags.None) { @@ -3489,14 +3467,14 @@ namespace Server.Multis if (targeted is Mobile mobile) m_House.Kick(from, mobile); else - from.SendLocalizedMessage(501347); //You cannot eject that from the house! + from.SendLocalizedMessage(501347); // You cannot eject that from the house! } } public class HouseBanTarget : Target { - private bool m_Banning; - private BaseHouse m_House; + private readonly bool m_Banning; + private readonly BaseHouse m_House; public HouseBanTarget(bool ban, BaseHouse house) : base(-1, false, TargetFlags.None) { @@ -3520,14 +3498,14 @@ namespace Server.Multis } else { - from.SendLocalizedMessage(501347); //You cannot eject that from the house! + from.SendLocalizedMessage(501347); // You cannot eject that from the house! } } } public class HouseAccessTarget : Target { - private BaseHouse m_House; + private readonly BaseHouse m_House; public HouseAccessTarget(BaseHouse house) : base(-1, false, TargetFlags.None) { @@ -3550,8 +3528,8 @@ namespace Server.Multis public class CoOwnerTarget : Target { - private bool m_Add; - private BaseHouse m_House; + private readonly bool m_Add; + private readonly BaseHouse m_House; public CoOwnerTarget(bool add, BaseHouse house) : base(12, false, TargetFlags.None) { @@ -3575,15 +3553,15 @@ namespace Server.Multis } else { - from.SendLocalizedMessage(501362); //That can't be a coowner + from.SendLocalizedMessage(501362); // That can't be a coowner } } } public class HouseFriendTarget : Target { - private bool m_Add; - private BaseHouse m_House; + private readonly bool m_Add; + private readonly BaseHouse m_House; public HouseFriendTarget(bool add, BaseHouse house) : base(12, false, TargetFlags.None) { @@ -3614,7 +3592,7 @@ namespace Server.Multis public class HouseOwnerTarget : Target { - private BaseHouse m_House; + private readonly BaseHouse m_House; public HouseOwnerTarget(BaseHouse house) : base(12, false, TargetFlags.None) { @@ -3632,11 +3610,9 @@ namespace Server.Multis } } - #endregion - public class SetSecureLevelEntry : ContextMenuEntry { - private Item m_Item; + private readonly Item m_Item; private ISecurable m_Securable; public SetSecureLevelEntry(Item item, ISecurable securable) : base(6203, 6) @@ -3705,7 +3681,7 @@ namespace Server.Multis public class TempNoHousingRegion : BaseRegion { - private Mobile m_RegionOwner; + private readonly Mobile m_RegionOwner; public TempNoHousingRegion(BaseHouse house, Mobile regionowner) : base(null, house.Map, DefaultPriority, house.Region.Area) diff --git a/Projects/Scripts/Multis/Boats/BaseBoat.cs b/Projects/Scripts/Multis/Boats/BaseBoat.cs index 2b0b00ce5..9adac6165 100644 --- a/Projects/Scripts/Multis/Boats/BaseBoat.cs +++ b/Projects/Scripts/Multis/Boats/BaseBoat.cs @@ -28,34 +28,34 @@ namespace Server.Multis Decaying } - private static Rectangle2D[] m_BritWrap = + private static readonly Rectangle2D[] m_BritWrap = { new Rectangle2D(16, 16, 5120 - 32, 4096 - 32), new Rectangle2D(5136, 2320, 992, 1760) }; - private static Rectangle2D[] m_IlshWrap = { new Rectangle2D(16, 16, 2304 - 32, 1600 - 32) }; - private static Rectangle2D[] m_TokunoWrap = { new Rectangle2D(16, 16, 1448 - 32, 1448 - 32) }; + private static readonly Rectangle2D[] m_IlshWrap = { new Rectangle2D(16, 16, 2304 - 32, 1600 - 32) }; + private static readonly Rectangle2D[] m_TokunoWrap = { new Rectangle2D(16, 16, 1448 - 32, 1448 - 32) }; - private static TimeSpan BoatDecayDelay = TimeSpan.FromDays(9.0); + private static readonly TimeSpan BoatDecayDelay = TimeSpan.FromDays(9.0); - private static TimeSpan SlowInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.50 : 0.75); - private static TimeSpan FastInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.25 : 0.75); + private static readonly TimeSpan SlowInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.50 : 0.75); + private static readonly TimeSpan FastInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.25 : 0.75); - private static int SlowSpeed = 1; - private static int FastSpeed = NewBoatMovement ? 1 : 3; + private static readonly int SlowSpeed = 1; + private static readonly int FastSpeed = NewBoatMovement ? 1 : 3; - private static TimeSpan SlowDriftInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.50 : 1.50); - private static TimeSpan FastDriftInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.25 : 0.75); + private static readonly TimeSpan SlowDriftInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.50 : 1.50); + private static readonly TimeSpan FastDriftInterval = TimeSpan.FromSeconds(NewBoatMovement ? 0.25 : 0.75); - private static int SlowDriftSpeed = 1; - private static int FastDriftSpeed = 1; + private static readonly int SlowDriftSpeed = 1; + private static readonly int FastDriftSpeed = 1; - private static Direction Forward = Direction.North; - private static Direction ForwardLeft = Direction.Up; - private static Direction ForwardRight = Direction.Right; - private static Direction Backward = Direction.South; - private static Direction BackwardLeft = Direction.Left; - private static Direction BackwardRight = Direction.Down; - private static Direction Left = Direction.West; - private static Direction Right = Direction.East; + private static readonly Direction Forward = Direction.North; + private static readonly Direction ForwardLeft = Direction.Up; + private static readonly Direction ForwardRight = Direction.Right; + private static readonly Direction Backward = Direction.South; + private static readonly Direction BackwardLeft = Direction.Left; + private static readonly Direction BackwardRight = Direction.Down; + private static readonly Direction Left = Direction.West; + private static readonly Direction Right = Direction.East; private static Direction Port = Left; private static Direction Starboard = Right; @@ -99,19 +99,19 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public Hold Hold{ get; set; } + public Hold Hold { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public TillerMan TillerMan{ get; set; } + public TillerMan TillerMan { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Plank PPlank{ get; set; } + public Plank PPlank { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Plank SPlank{ get; set; } + public Plank SPlank { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } [CommandProperty(AccessLevel.GameMaster)] public Direction Facing @@ -121,16 +121,16 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public Direction Moving{ get; set; } + public Direction Moving { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsMoving => m_MoveTimer != null; [CommandProperty(AccessLevel.GameMaster)] - public int Speed{ get; set; } + public int Speed { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool Anchored{ get; set; } + public bool Anchored { get; set; } [CommandProperty(AccessLevel.GameMaster)] public string ShipName @@ -144,13 +144,13 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public BoatOrder Order{ get; set; } + public BoatOrder Order { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public MapItem MapItem{ get; set; } + public MapItem MapItem { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int NextNavPoint{ get; set; } + public int NextNavPoint { get; set; } [CommandProperty(AccessLevel.GameMaster)] public DateTime TimeOfDecay @@ -201,7 +201,7 @@ namespace Server.Multis public virtual BaseDockedBoat DockedBoat => null; - public static List Boats{ get; } = new List(); + public static List Boats { get; } = new List(); /* * Intervals: @@ -309,54 +309,54 @@ namespace Server.Multis switch (version) { case 3: - { - MapItem = (MapItem)reader.ReadItem(); - NextNavPoint = reader.ReadInt(); - - goto case 2; - } - case 2: - { - m_Facing = (Direction)reader.ReadInt(); - - goto case 1; - } - case 1: - { - m_DecayTime = reader.ReadDeltaTime(); - - goto case 0; - } - case 0: - { - if (version < 3) - NextNavPoint = -1; - - if (version < 2) { - if (ItemID == NorthID) - m_Facing = Direction.North; - else if (ItemID == SouthID) - m_Facing = Direction.South; - else if (ItemID == EastID) - m_Facing = Direction.East; - else if (ItemID == WestID) - m_Facing = Direction.West; + MapItem = (MapItem)reader.ReadItem(); + NextNavPoint = reader.ReadInt(); + + goto case 2; } + case 2: + { + m_Facing = (Direction)reader.ReadInt(); - Owner = reader.ReadMobile(); - PPlank = reader.ReadItem() as Plank; - SPlank = reader.ReadItem() as Plank; - TillerMan = reader.ReadItem() as TillerMan; - Hold = reader.ReadItem() as Hold; - Anchored = reader.ReadBool(); - m_ShipName = reader.ReadString(); + goto case 1; + } + case 1: + { + m_DecayTime = reader.ReadDeltaTime(); - if (version < 1) - Refresh(); + goto case 0; + } + case 0: + { + if (version < 3) + NextNavPoint = -1; - break; - } + if (version < 2) + { + if (ItemID == NorthID) + m_Facing = Direction.North; + else if (ItemID == SouthID) + m_Facing = Direction.South; + else if (ItemID == EastID) + m_Facing = Direction.East; + else if (ItemID == WestID) + m_Facing = Direction.West; + } + + Owner = reader.ReadMobile(); + PPlank = reader.ReadItem() as Plank; + SPlank = reader.ReadItem() as Plank; + TillerMan = reader.ReadItem() as TillerMan; + Hold = reader.ReadItem() as Hold; + Anchored = reader.ReadBool(); + m_ShipName = reader.ReadString(); + + if (version < 1) + Refresh(); + + break; + } } Boats.Add(this); @@ -902,7 +902,7 @@ namespace Server.Multis return false; } - if (Map != Map.Trammel && Map != Map.Felucca || NextNavPoint < 0 || NextNavPoint >= MapItem.Pins.Count) + if ((Map != Map.Trammel && Map != Map.Felucca) || NextNavPoint < 0 || NextNavPoint >= MapItem.Pins.Count) { if (message) TillerMan?.Say(1042551); // I don't see that navpoint, sir. @@ -1185,44 +1185,44 @@ namespace Server.Multis MultiComponentList newComponents = MultiData.GetComponents(itemID); for (int x = 0; x < newComponents.Width; ++x) - for (int y = 0; y < newComponents.Height; ++y) - { - int tx = p.X + newComponents.Min.X + x; - int ty = p.Y + newComponents.Min.Y + y; - - if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty)) - continue; - - LandTile landTile = map.Tiles.GetLandTile(tx, ty); - StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true); - - bool hasWater = landTile.Z == p.Z && - (landTile.ID >= 168 && landTile.ID <= 171 || landTile.ID >= 310 && landTile.ID <= 311); - - // int z = p.Z; - - //int landZ = 0, landAvg = 0, landTop = 0; - - //map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop ); - - //if ( !landTile.Ignored && top > landZ && landTop > z ) - // return false; - - for (int i = 0; i < tiles.Length; ++i) + for (int y = 0; y < newComponents.Height; ++y) { - StaticTile tile = tiles[i]; - bool isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2; + int tx = p.X + newComponents.Min.X + x; + int ty = p.Y + newComponents.Min.Y + y; - if (tile.Z == p.Z && isWater) - hasWater = true; - else if (tile.Z >= p.Z && !isWater) + if (newComponents.Tiles[x][y].Length == 0 || Contains(tx, ty)) + continue; + + LandTile landTile = map.Tiles.GetLandTile(tx, ty); + StaticTile[] tiles = map.Tiles.GetStaticTiles(tx, ty, true); + + bool hasWater = landTile.Z == p.Z && + ((landTile.ID >= 168 && landTile.ID <= 171) || (landTile.ID >= 310 && landTile.ID <= 311)); + + // int z = p.Z; + + // int landZ = 0, landAvg = 0, landTop = 0; + + // map.GetAverageZ( tx, ty, ref landZ, ref landAvg, ref landTop ); + + // if (!landTile.Ignored && top > landZ && landTop > z) + // return false; + + for (int i = 0; i < tiles.Length; ++i) + { + StaticTile tile = tiles[i]; + bool isWater = tile.ID >= 0x1796 && tile.ID <= 0x17B2; + + if (tile.Z == p.Z && isWater) + hasWater = true; + else if (tile.Z >= p.Z && !isWater) + return false; + } + + if (!hasWater) return false; } - if (!hasWater) - return false; - } - IPooledEnumerable eable = map.GetItemsInBounds(new Rectangle2D(p.X + newComponents.Min.X, p.Y + newComponents.Min.Y, newComponents.Width, newComponents.Height)); @@ -1234,8 +1234,8 @@ namespace Server.Multis int x = item.X - p.X + newComponents.Min.X; int y = item.Y - p.Y + newComponents.Min.Y; - return x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height && - newComponents.Tiles[x][y].Length == 0 || Contains(item); + return (x >= 0 && x < newComponents.Width && y >= 0 && y < newComponents.Height && + newComponents.Tiles[x][y].Length == 0) || Contains(item); }); eable.Free(); @@ -1259,10 +1259,10 @@ namespace Server.Multis public override bool Contains(int x, int y) => base.Contains(x, y) || - TillerMan?.X == x && y == TillerMan.Y || - Hold?.X == x && Hold.Y == y || - PPlank?.X == x && PPlank.Y == y || - SPlank?.X == x && SPlank.Y == y; + (TillerMan?.X == x && y == TillerMan.Y) || + (Hold?.X == x && Hold.Y == y) || + (PPlank?.X == x && PPlank.Y == y) || + (SPlank?.X == x && SPlank.Y == y); public static bool IsValidLocation(Point3D p, Map map) { @@ -1322,7 +1322,7 @@ namespace Server.Multis return false; } - else if (Map != Map.Trammel && Map != Map.Felucca || NextNavPoint < 0 || NextNavPoint >= MapItem.Pins.Count) + else if ((Map != Map.Trammel && Map != Map.Felucca) || NextNavPoint < 0 || NextNavPoint >= MapItem.Pins.Count) { if (message) TillerMan?.Say(1042551); // I don't see that navpoint, sir. @@ -1535,8 +1535,7 @@ namespace Server.Multis MultiComponentList mcl = Components; - foreach (IEntity o in map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height)) - ) + foreach (IEntity o in map.GetObjectsInBounds(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height))) { if (o == this || o is TillerMan || o is Hold || o is Plank) continue; @@ -1657,7 +1656,7 @@ namespace Server.Multis private class DecayTimer : Timer { - private BaseBoat m_Boat; + private readonly BaseBoat m_Boat; private int m_Count; public DecayTimer(BaseBoat boat) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(5.0)) @@ -1687,8 +1686,8 @@ namespace Server.Multis private class TurnTimer : Timer { - private BaseBoat m_Boat; - private int m_Offset; + private readonly BaseBoat m_Boat; + private readonly int m_Offset; public TurnTimer(BaseBoat boat, int offset) : base(TimeSpan.FromSeconds(0.5)) { @@ -1707,7 +1706,7 @@ namespace Server.Multis private class MoveTimer : Timer { - private BaseBoat m_Boat; + private readonly BaseBoat m_Boat; public MoveTimer(BaseBoat boat, TimeSpan interval, bool single) : base(interval, interval, single ? 1 : 0) { @@ -1734,8 +1733,6 @@ namespace Server.Multis } } - #region High Seas - public override bool AllowsRelativeDrop => true; /* @@ -1747,7 +1744,7 @@ namespace Server.Multis /* protected override Packet GetWorldPacketFor( NetState state ) { - if ( NewBoatMovement && state.HighSeas ) + if (NewBoatMovement && state.HighSeas) return new DisplayBoatHS( state.Mobile, this ); else return base.GetWorldPacketFor( state ); @@ -1762,14 +1759,14 @@ namespace Server.Multis { EnsureCapacity(3 + 15 + ents.Count * 10); - m_Stream.Write(boat.Serial); - m_Stream.Write((byte)speed); - m_Stream.Write((byte)d); - m_Stream.Write((byte)boat.Facing); - m_Stream.Write((short)(boat.X + xOffset)); - m_Stream.Write((short)(boat.Y + yOffset)); - m_Stream.Write((short)boat.Z); - m_Stream.Write((short)0); // count placeholder + Stream.Write(boat.Serial); + Stream.Write((byte)speed); + Stream.Write((byte)d); + Stream.Write((byte)boat.Facing); + Stream.Write((short)(boat.X + xOffset)); + Stream.Write((short)(boat.Y + yOffset)); + Stream.Write((short)boat.Z); + Stream.Write((short)0); // count placeholder int count = 0; @@ -1778,15 +1775,15 @@ namespace Server.Multis if (!beholder.CanSee(ent)) continue; - m_Stream.Write(ent.Serial); - m_Stream.Write((short)(ent.X + xOffset)); - m_Stream.Write((short)(ent.Y + yOffset)); - m_Stream.Write((short)ent.Z); + Stream.Write(ent.Serial); + Stream.Write((short)(ent.X + xOffset)); + Stream.Write((short)(ent.Y + yOffset)); + Stream.Write((short)ent.Z); ++count; } - m_Stream.Seek(16, SeekOrigin.Begin); - m_Stream.Write((short)count); + Stream.Seek(16, SeekOrigin.Begin); + Stream.Write((short)count); } } @@ -1806,7 +1803,7 @@ namespace Server.Multis EnsureCapacity(3 + 2 + ents.Count * 26); - m_Stream.Write((short)0); // count placeholder + Stream.Write((short)0); // count placeholder int count = 0; @@ -1816,74 +1813,72 @@ namespace Server.Multis continue; // Embedded WorldItemHS packets - m_Stream.Write((byte)0xF3); - m_Stream.Write((short)0x1); + Stream.Write((byte)0xF3); + Stream.Write((short)0x1); if (ent is BaseMulti bm) { - m_Stream.Write((byte)0x02); - m_Stream.Write(bm.Serial); + Stream.Write((byte)0x02); + Stream.Write(bm.Serial); // TODO: Mask no longer needed, merge with Item case? - m_Stream.Write((ushort)(bm.ItemID & 0x3FFF)); - m_Stream.Write((byte)0); + Stream.Write((ushort)(bm.ItemID & 0x3FFF)); + Stream.Write((byte)0); - m_Stream.Write((short)bm.Amount); - m_Stream.Write((short)bm.Amount); + Stream.Write((short)bm.Amount); + Stream.Write((short)bm.Amount); - m_Stream.Write((short)(bm.X & 0x7FFF)); - m_Stream.Write((short)(bm.Y & 0x3FFF)); - m_Stream.Write((sbyte)bm.Z); + Stream.Write((short)(bm.X & 0x7FFF)); + Stream.Write((short)(bm.Y & 0x3FFF)); + Stream.Write((sbyte)bm.Z); - m_Stream.Write((byte)bm.Light); - m_Stream.Write((short)bm.Hue); - m_Stream.Write((byte)bm.GetPacketFlags()); + Stream.Write((byte)bm.Light); + Stream.Write((short)bm.Hue); + Stream.Write((byte)bm.GetPacketFlags()); } else if (ent is Mobile m) { - m_Stream.Write((byte)0x01); - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.Body); - m_Stream.Write((byte)0); + Stream.Write((byte)0x01); + Stream.Write(m.Serial); + Stream.Write((short)m.Body); + Stream.Write((byte)0); - m_Stream.Write((short)1); - m_Stream.Write((short)1); + Stream.Write((short)1); + Stream.Write((short)1); - m_Stream.Write((short)(m.X & 0x7FFF)); - m_Stream.Write((short)(m.Y & 0x3FFF)); - m_Stream.Write((sbyte)m.Z); + Stream.Write((short)(m.X & 0x7FFF)); + Stream.Write((short)(m.Y & 0x3FFF)); + Stream.Write((sbyte)m.Z); - m_Stream.Write((byte)m.Direction); - m_Stream.Write((short)m.Hue); - m_Stream.Write((byte)m.GetPacketFlags()); + Stream.Write((byte)m.Direction); + Stream.Write((short)m.Hue); + Stream.Write((byte)m.GetPacketFlags()); } else if (ent is Item item) { - m_Stream.Write((byte)0x00); - m_Stream.Write(item.Serial); - m_Stream.Write((ushort)(item.ItemID & 0xFFFF)); - m_Stream.Write((byte)0); + Stream.Write((byte)0x00); + Stream.Write(item.Serial); + Stream.Write((ushort)(item.ItemID & 0xFFFF)); + Stream.Write((byte)0); - m_Stream.Write((short)item.Amount); - m_Stream.Write((short)item.Amount); + Stream.Write((short)item.Amount); + Stream.Write((short)item.Amount); - m_Stream.Write((short)(item.X & 0x7FFF)); - m_Stream.Write((short)(item.Y & 0x3FFF)); - m_Stream.Write((sbyte)item.Z); + Stream.Write((short)(item.X & 0x7FFF)); + Stream.Write((short)(item.Y & 0x3FFF)); + Stream.Write((sbyte)item.Z); - m_Stream.Write((byte)item.Light); - m_Stream.Write((short)item.Hue); - m_Stream.Write((byte)item.GetPacketFlags()); + Stream.Write((byte)item.Light); + Stream.Write((short)item.Hue); + Stream.Write((byte)item.GetPacketFlags()); } - m_Stream.Write((short)0x00); + Stream.Write((short)0x00); ++count; } - m_Stream.Seek(3, SeekOrigin.Begin); - m_Stream.Write((short)count); + Stream.Seek(3, SeekOrigin.Begin); + Stream.Write((short)count); } } - - #endregion } } diff --git a/Projects/Scripts/Multis/Boats/BaseBoatDeed.cs b/Projects/Scripts/Multis/Boats/BaseBoatDeed.cs index f66164edf..06953de35 100644 --- a/Projects/Scripts/Multis/Boats/BaseBoatDeed.cs +++ b/Projects/Scripts/Multis/Boats/BaseBoatDeed.cs @@ -23,12 +23,12 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public int MultiID{ get; set; } + public int MultiID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Offset{ get; set; } + public Point3D Offset { get; set; } - public abstract BaseBoat Boat{ get; } + public abstract BaseBoat Boat { get; } public override void Serialize(IGenericWriter writer) { @@ -49,12 +49,12 @@ namespace Server.Multis switch (version) { case 0: - { - MultiID = reader.ReadInt(); - Offset = reader.ReadPoint3D(); + { + MultiID = reader.ReadInt(); + Offset = reader.ReadPoint3D(); - break; - } + break; + } } if (Weight == 0.0) @@ -144,7 +144,7 @@ namespace Server.Multis private class InternalTarget : MultiTarget { - private BaseBoatDeed m_Deed; + private readonly BaseBoatDeed m_Deed; public InternalTarget(BaseBoatDeed deed) : base(deed.MultiID, deed.Offset) => m_Deed = deed; diff --git a/Projects/Scripts/Multis/Boats/BaseDockedBoat.cs b/Projects/Scripts/Multis/Boats/BaseDockedBoat.cs index 65c168702..8ca82acd7 100644 --- a/Projects/Scripts/Multis/Boats/BaseDockedBoat.cs +++ b/Projects/Scripts/Multis/Boats/BaseDockedBoat.cs @@ -24,10 +24,10 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public int MultiID{ get; set; } + public int MultiID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Offset{ get; set; } + public Point3D Offset { get; set; } [CommandProperty(AccessLevel.GameMaster)] public string ShipName @@ -40,7 +40,7 @@ namespace Server.Multis } } - public abstract BaseBoat Boat{ get; } + public abstract BaseBoat Boat { get; } public override void Serialize(IGenericWriter writer) { @@ -63,16 +63,16 @@ namespace Server.Multis { case 1: case 0: - { - MultiID = reader.ReadInt(); - Offset = reader.ReadPoint3D(); - m_ShipName = reader.ReadString(); + { + MultiID = reader.ReadInt(); + Offset = reader.ReadPoint3D(); + m_ShipName = reader.ReadString(); - if (version == 0) - reader.ReadUInt(); + if (version == 0) + reader.ReadUInt(); - break; - } + break; + } } if (LootType == LootType.Newbied) @@ -163,7 +163,7 @@ namespace Server.Multis private class InternalTarget : MultiTarget { - private BaseDockedBoat m_Model; + private readonly BaseDockedBoat m_Model; public InternalTarget(BaseDockedBoat model) : base(model.MultiID, model.Offset) => m_Model = model; diff --git a/Projects/Scripts/Multis/Boats/ConfirmDryDockGump.cs b/Projects/Scripts/Multis/Boats/ConfirmDryDockGump.cs index 920eecaa5..e11d1488c 100644 --- a/Projects/Scripts/Multis/Boats/ConfirmDryDockGump.cs +++ b/Projects/Scripts/Multis/Boats/ConfirmDryDockGump.cs @@ -5,8 +5,8 @@ namespace Server.Multis { public class ConfirmDryDockGump : Gump { - private BaseBoat m_Boat; - private Mobile m_From; + private readonly BaseBoat m_Boat; + private readonly Mobile m_From; public ConfirmDryDockGump(Mobile from, BaseBoat boat) : base(150, 200) { diff --git a/Projects/Scripts/Multis/Boats/Hold.cs b/Projects/Scripts/Multis/Boats/Hold.cs index 9b057084a..225291745 100644 --- a/Projects/Scripts/Multis/Boats/Hold.cs +++ b/Projects/Scripts/Multis/Boats/Hold.cs @@ -96,16 +96,16 @@ namespace Server.Items switch (version) { case 0: - { - m_Boat = reader.ReadItem() as BaseBoat; + { + m_Boat = reader.ReadItem() as BaseBoat; - if (m_Boat == null || Parent != null) - Delete(); + if (m_Boat == null || Parent != null) + Delete(); - Movable = false; + Movable = false; - break; - } + break; + } } } } diff --git a/Projects/Scripts/Multis/Boats/Plank.cs b/Projects/Scripts/Multis/Boats/Plank.cs index 99dd05a22..0536656b6 100644 --- a/Projects/Scripts/Multis/Boats/Plank.cs +++ b/Projects/Scripts/Multis/Boats/Plank.cs @@ -32,10 +32,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public BaseBoat Boat{ get; set; } + public BaseBoat Boat { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public PlankSide Side{ get; set; } + public PlankSide Side { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool IsOpen => ItemID == 0x3ED5 || ItemID == 0x3ED4 || ItemID == 0x3E84 || ItemID == 0x3E89; @@ -44,16 +44,16 @@ namespace Server.Items public bool Starboard => Side == PlankSide.Starboard; [CommandProperty(AccessLevel.GameMaster)] - public bool Locked{ get; set; } + public bool Locked { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public uint KeyValue{ get; set; } + public uint KeyValue { get; set; } public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version writer.Write(Boat); writer.Write((int)Side); @@ -70,17 +70,17 @@ namespace Server.Items switch (version) { case 0: - { - Boat = reader.ReadItem() as BaseBoat; - Side = (PlankSide)reader.ReadInt(); - Locked = reader.ReadBool(); - KeyValue = reader.ReadUInt(); + { + Boat = reader.ReadItem() as BaseBoat; + Side = (PlankSide)reader.ReadInt(); + Locked = reader.ReadBool(); + KeyValue = reader.ReadUInt(); - if (Boat == null) - Delete(); + if (Boat == null) + Delete(); - break; - } + break; + } } if (IsOpen) @@ -95,19 +95,19 @@ namespace Server.Items if (IsOpen) ItemID = dir switch { - Direction.North => (Starboard ? 0x3ED4 : 0x3ED5), - Direction.East => (Starboard ? 0x3E84 : 0x3E89), - Direction.South => (Starboard ? 0x3ED5 : 0x3ED4), - Direction.West => (Starboard ? 0x3E89 : 0x3E84), + Direction.North => Starboard ? 0x3ED4 : 0x3ED5, + Direction.East => Starboard ? 0x3E84 : 0x3E89, + Direction.South => Starboard ? 0x3ED5 : 0x3ED4, + Direction.West => Starboard ? 0x3E89 : 0x3E84, _ => ItemID }; else ItemID = dir switch { - Direction.North => (Starboard ? 0x3EB2 : 0x3EB1), - Direction.East => (Starboard ? 0x3E85 : 0x3E8A), - Direction.South => (Starboard ? 0x3EB1 : 0x3EB2), - Direction.West => (Starboard ? 0x3E8A : 0x3E85), + Direction.North => Starboard ? 0x3EB2 : 0x3EB1, + Direction.East => Starboard ? 0x3E85 : 0x3E8A, + Direction.South => Starboard ? 0x3EB1 : 0x3EB2, + Direction.West => Starboard ? 0x3E8A : 0x3E85, _ => ItemID }; } @@ -281,7 +281,7 @@ namespace Server.Items private class CloseTimer : Timer { - private Plank m_Plank; + private readonly Plank m_Plank; public CloseTimer(Plank plank) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) { diff --git a/Projects/Scripts/Multis/Boats/RenameBoatPrompt.cs b/Projects/Scripts/Multis/Boats/RenameBoatPrompt.cs index 4448bbed8..5661a9adb 100644 --- a/Projects/Scripts/Multis/Boats/RenameBoatPrompt.cs +++ b/Projects/Scripts/Multis/Boats/RenameBoatPrompt.cs @@ -4,7 +4,7 @@ namespace Server.Multis { public class RenameBoatPrompt : Prompt { - private BaseBoat m_Boat; + private readonly BaseBoat m_Boat; public RenameBoatPrompt(BaseBoat boat) => m_Boat = boat; diff --git a/Projects/Scripts/Multis/Boats/Strandedness.cs b/Projects/Scripts/Multis/Boats/Strandedness.cs index b758cb6e1..fca0119ea 100644 --- a/Projects/Scripts/Multis/Boats/Strandedness.cs +++ b/Projects/Scripts/Multis/Boats/Strandedness.cs @@ -2,7 +2,7 @@ namespace Server.Misc { public class Strandedness { - private static Point2D[] m_Felucca = + private static readonly Point2D[] m_Felucca = { new Point2D(2528, 3568), new Point2D(2376, 3400), new Point2D(2528, 3896), new Point2D(2168, 3904), new Point2D(1136, 3416), new Point2D(1432, 3648), @@ -37,9 +37,9 @@ namespace Server.Misc new Point2D(1840, 2640), new Point2D(1928, 2952), new Point2D(2120, 2712) }; - private static Point2D[] m_Trammel = m_Felucca; + private static readonly Point2D[] m_Trammel = m_Felucca; - private static Point2D[] m_Ilshenar = + private static readonly Point2D[] m_Ilshenar = { new Point2D(1252, 1180), new Point2D(1562, 1090), new Point2D(1444, 1016), new Point2D(1324, 968), new Point2D(1418, 806), new Point2D(1722, 874), @@ -49,9 +49,9 @@ namespace Server.Misc new Point2D(1358, 866), new Point2D(510, 302), new Point2D(510, 392) }; - private static Point2D[] m_Tokuno = + private static readonly Point2D[] m_Tokuno = { - //Makoto-Jima + // Makoto-Jima new Point2D(837, 1351), new Point2D(941, 1241), new Point2D(959, 1185), new Point2D(923, 1091), new Point2D(904, 983), new Point2D(845, 944), new Point2D(829, 896), new Point2D(794, 852), new Point2D(766, 821), @@ -61,7 +61,7 @@ namespace Server.Misc new Point2D(526, 1271), new Point2D(562, 1295), new Point2D(616, 1335), new Point2D(789, 1347), new Point2D(712, 1359), - //Homare-Jima + // Homare-Jima new Point2D(202, 498), new Point2D(116, 600), new Point2D(107, 699), new Point2D(162, 799), new Point2D(158, 889), new Point2D(169, 989), new Point2D(194, 1101), new Point2D(250, 1163), new Point2D(295, 1176), @@ -72,7 +72,7 @@ namespace Server.Misc new Point2D(672, 379), new Point2D(626, 332), new Point2D(494, 291), new Point2D(371, 336), new Point2D(324, 334), new Point2D(270, 362), - //Isamu-Jima + // Isamu-Jima new Point2D(1240, 1076), new Point2D(1189, 1115), new Point2D(1046, 1039), new Point2D(1025, 885), new Point2D(907, 809), new Point2D(840, 506), new Point2D(799, 396), new Point2D(720, 258), new Point2D(744, 158), @@ -101,8 +101,8 @@ namespace Server.Misc { int id = tile.ID; - return id >= 168 && id <= 171 - || id >= 310 && id <= 311; + return (id >= 168 && id <= 171) + || (id >= 310 && id <= 311); } if (surface is StaticTile staticTile) @@ -157,17 +157,17 @@ namespace Server.Misc canFit = map.CanSpawnMobile(x, y, z); for (int i = 1; !canFit && i <= 40; i += 2) - for (int xo = -1; !canFit && xo <= 1; ++xo) - for (int yo = -1; !canFit && yo <= 1; ++yo) - { - if (xo == 0 && yo == 0) - continue; + for (int xo = -1; !canFit && xo <= 1; ++xo) + for (int yo = -1; !canFit && yo <= 1; ++yo) + { + if (xo == 0 && yo == 0) + continue; - x = p.X + xo * i; - y = p.Y + yo * i; - z = map.GetAverageZ(x, y); - canFit = map.CanSpawnMobile(x, y, z); - } + x = p.X + xo * i; + y = p.Y + yo * i; + z = map.GetAverageZ(x, y); + canFit = map.CanSpawnMobile(x, y, z); + } if (canFit) from.Location = new Point3D(x, y, z); diff --git a/Projects/Scripts/Multis/Boats/TillerMan.cs b/Projects/Scripts/Multis/Boats/TillerMan.cs index a80852e25..33115dbaf 100644 --- a/Projects/Scripts/Multis/Boats/TillerMan.cs +++ b/Projects/Scripts/Multis/Boats/TillerMan.cs @@ -87,7 +87,7 @@ namespace Server.Items { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version writer.Write(m_Boat); } @@ -101,14 +101,14 @@ namespace Server.Items switch (version) { case 0: - { - m_Boat = reader.ReadItem() as BaseBoat; + { + m_Boat = reader.ReadItem() as BaseBoat; - if (m_Boat == null) - Delete(); + if (m_Boat == null) + Delete(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Multis/Camps/BaseCamp.cs b/Projects/Scripts/Multis/Camps/BaseCamp.cs index b32ebe470..59f82d4a2 100644 --- a/Projects/Scripts/Multis/Camps/BaseCamp.cs +++ b/Projects/Scripts/Multis/Camps/BaseCamp.cs @@ -155,15 +155,15 @@ namespace Server.Multis switch (version) { case 0: - { - m_Items = reader.ReadStrongItemList(); - m_Mobiles = reader.ReadStrongMobileList(); - m_DecayTime = reader.ReadDeltaTime(); + { + m_Items = reader.ReadStrongItemList(); + m_Mobiles = reader.ReadStrongMobileList(); + m_DecayTime = reader.ReadDeltaTime(); - RefreshDecay(false); + RefreshDecay(false); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Multis/Camps/BrigandCamp.cs b/Projects/Scripts/Multis/Camps/BrigandCamp.cs index c3ea86616..9dcf28eb1 100644 --- a/Projects/Scripts/Multis/Camps/BrigandCamp.cs +++ b/Projects/Scripts/Multis/Camps/BrigandCamp.cs @@ -23,7 +23,7 @@ namespace Server.Multis public override void AddComponents() { BaseCreature bc; - //BaseEscortable be; + // BaseEscortable be; Visible = false; DecayDelay = TimeSpan.FromMinutes(5.0); @@ -34,21 +34,21 @@ namespace Server.Multis switch (Utility.Random(3)) { case 0: - { - AddItem(new Item(0xDE3), 0, 7, 0); // Campfire - AddItem(new Item(0x974), 0, 7, 1); // Cauldron - break; - } + { + AddItem(new Item(0xDE3), 0, 7, 0); // Campfire + AddItem(new Item(0x974), 0, 7, 1); // Cauldron + break; + } case 1: - { - AddItem(new Item(0x1E95), 0, 7, 1); // Rabbit on a spit - break; - } + { + AddItem(new Item(0x1E95), 0, 7, 1); // Rabbit on a spit + break; + } default: - { - AddItem(new Item(0x1E94), 0, 7, 1); // Chicken on a spit - break; - } + { + AddItem(new Item(0x1E94), 0, 7, 1); // Chicken on a spit + break; + } } AddCampChests(); @@ -61,8 +61,8 @@ namespace Server.Multis _ => new SeekerOfAdventure() }; - //be = (BaseEscortable)m_Prisoner; - //be.m_Captive = true; + // be = (BaseEscortable)m_Prisoner; + // be.m_Captive = true; bc = (BaseCreature)m_Prisoner; bc.IsPrisoner = true; @@ -182,10 +182,10 @@ namespace Server.Multis switch (version) { case 0: - { - m_Prisoner = reader.ReadMobile(); - break; - } + { + m_Prisoner = reader.ReadMobile(); + break; + } } } } diff --git a/Projects/Scripts/Multis/Camps/LizardmenCamp.cs b/Projects/Scripts/Multis/Camps/LizardmenCamp.cs index 614e3d791..611ca3d69 100644 --- a/Projects/Scripts/Multis/Camps/LizardmenCamp.cs +++ b/Projects/Scripts/Multis/Camps/LizardmenCamp.cs @@ -22,7 +22,7 @@ namespace Server.Multis public override void AddComponents() { BaseCreature bc; - //BaseEscortable be; + // BaseEscortable be; Visible = false; DecayDelay = TimeSpan.FromMinutes(5.0); @@ -32,21 +32,21 @@ namespace Server.Multis switch (Utility.Random(3)) { case 0: - { - AddItem(new Item(0xDE3), 0, 7, 0); // Campfire - AddItem(new Item(0x974), 0, 7, 1); // Cauldron - break; - } + { + AddItem(new Item(0xDE3), 0, 7, 0); // Campfire + AddItem(new Item(0x974), 0, 7, 1); // Cauldron + break; + } case 1: - { - AddItem(new Item(0x1E95), 0, 7, 1); // Rabbit on a spit - break; - } + { + AddItem(new Item(0x1E95), 0, 7, 1); // Rabbit on a spit + break; + } default: - { - AddItem(new Item(0x1E94), 0, 7, 1); // Chicken on a spit - break; - } + { + AddItem(new Item(0x1E94), 0, 7, 1); // Chicken on a spit + break; + } } AddItem(new Item(0x41F), 4, 4, 0); // Gruesome Standart South @@ -61,8 +61,8 @@ namespace Server.Multis _ => new SeekerOfAdventure() }; - //be = (BaseEscortable)m_Prisoner; - //be.m_Captive = true; + // be = (BaseEscortable)m_Prisoner; + // be.m_Captive = true; bc = (BaseCreature)m_Prisoner; bc.IsPrisoner = true; @@ -182,10 +182,10 @@ namespace Server.Multis switch (version) { case 0: - { - m_Prisoner = reader.ReadMobile(); - break; - } + { + m_Prisoner = reader.ReadMobile(); + break; + } } } } diff --git a/Projects/Scripts/Multis/Camps/OrcCamp.cs b/Projects/Scripts/Multis/Camps/OrcCamp.cs index 5714f32f2..8639140bc 100644 --- a/Projects/Scripts/Multis/Camps/OrcCamp.cs +++ b/Projects/Scripts/Multis/Camps/OrcCamp.cs @@ -22,7 +22,7 @@ namespace Server.Multis public override void AddComponents() { BaseCreature bc; - //BaseEscortable be; + // BaseEscortable be; Visible = false; DecayDelay = TimeSpan.FromMinutes(5.0); @@ -32,21 +32,21 @@ namespace Server.Multis switch (Utility.Random(3)) { case 0: - { - AddItem(new Item(0xDE3), 0, 7, 0); // Campfire - AddItem(new Item(0x974), 0, 7, 1); // Cauldron - break; - } + { + AddItem(new Item(0xDE3), 0, 7, 0); // Campfire + AddItem(new Item(0x974), 0, 7, 1); // Cauldron + break; + } case 1: - { - AddItem(new Item(0x1E95), 0, 7, 1); // Rabbit on a spit - break; - } + { + AddItem(new Item(0x1E95), 0, 7, 1); // Rabbit on a spit + break; + } default: - { - AddItem(new Item(0x1E94), 0, 7, 1); // Chicken on a spit - break; - } + { + AddItem(new Item(0x1E94), 0, 7, 1); // Chicken on a spit + break; + } } AddItem(new Item(0x428), -5, -4, 0); // Gruesome Standart West @@ -62,8 +62,8 @@ namespace Server.Multis _ => new SeekerOfAdventure() }; - //be = (BaseEscortable)m_Prisoner; - //be.m_Captive = true; + // be = (BaseEscortable)m_Prisoner; + // be.m_Captive = true; bc = (BaseCreature)m_Prisoner; bc.IsPrisoner = true; @@ -183,16 +183,16 @@ namespace Server.Multis switch (version) { case 1: - { - m_Prisoner = reader.ReadMobile(); - break; - } + { + m_Prisoner = reader.ReadMobile(); + break; + } case 0: - { - m_Prisoner = reader.ReadMobile(); - reader.ReadItem(); - break; - } + { + m_Prisoner = reader.ReadMobile(); + reader.ReadItem(); + break; + } } } } diff --git a/Projects/Scripts/Multis/Camps/RatCamp.cs b/Projects/Scripts/Multis/Camps/RatCamp.cs index 10f7c3e51..133220015 100644 --- a/Projects/Scripts/Multis/Camps/RatCamp.cs +++ b/Projects/Scripts/Multis/Camps/RatCamp.cs @@ -22,7 +22,7 @@ namespace Server.Multis public override void AddComponents() { BaseCreature bc; - //BaseEscortable be; + // BaseEscortable be; Visible = false; DecayDelay = TimeSpan.FromMinutes(5.0); @@ -32,21 +32,21 @@ namespace Server.Multis switch (Utility.Random(3)) { case 0: - { - AddItem(new Item(0xDE3), 0, 6, 0); // Campfire - AddItem(new Item(0x974), 0, 6, 1); // Cauldron - break; - } + { + AddItem(new Item(0xDE3), 0, 6, 0); // Campfire + AddItem(new Item(0x974), 0, 6, 1); // Cauldron + break; + } case 1: - { - AddItem(new Item(0x1E95), 0, 6, 1); // Rabbit on a spit - break; - } + { + AddItem(new Item(0x1E95), 0, 6, 1); // Rabbit on a spit + break; + } default: - { - AddItem(new Item(0x1E94), 0, 6, 1); // Chicken on a spit - break; - } + { + AddItem(new Item(0x1E94), 0, 6, 1); // Chicken on a spit + break; + } } AddItem(new Item(0x41F), 5, 5, 0); // Gruesome Standart South @@ -61,8 +61,8 @@ namespace Server.Multis _ => new SeekerOfAdventure() }; - //be = (BaseEscortable)m_Prisoner; - //be.m_Captive = true; + // be = (BaseEscortable)m_Prisoner; + // be.m_Captive = true; bc = (BaseCreature)m_Prisoner; bc.IsPrisoner = true; @@ -182,16 +182,16 @@ namespace Server.Multis switch (version) { case 1: - { - m_Prisoner = reader.ReadMobile(); - break; - } + { + m_Prisoner = reader.ReadMobile(); + break; + } case 0: - { - m_Prisoner = reader.ReadMobile(); - reader.ReadItem(); - break; - } + { + m_Prisoner = reader.ReadMobile(); + reader.ReadItem(); + break; + } } } } diff --git a/Projects/Scripts/Multis/ComponentVerification.cs b/Projects/Scripts/Multis/ComponentVerification.cs index 105e407db..9c90f8fd6 100644 --- a/Projects/Scripts/Multis/ComponentVerification.cs +++ b/Projects/Scripts/Multis/ComponentVerification.cs @@ -6,8 +6,8 @@ namespace Server.Multis { public class ComponentVerification { - private int[] m_ItemTable; - private int[] m_MultiTable; + private readonly int[] m_ItemTable; + private readonly int[] m_MultiTable; public ComponentVerification() { @@ -90,7 +90,7 @@ namespace Server.Multis public class Spreadsheet { - private ColumnInfo[] m_Columns; + private readonly ColumnInfo[] m_Columns; public Spreadsheet(string path) { @@ -118,15 +118,15 @@ namespace Server.Multis switch (ci.m_Type) { case "int": - { - data[i] = Utility.ToInt32(values[ci.m_DataIndex]); - break; - } + { + data[i] = Utility.ToInt32(values[ci.m_DataIndex]); + break; + } case "string": - { - data[i] = values[ci.m_DataIndex]; - break; - } + { + data[i] = values[ci.m_DataIndex]; + break; + } } } @@ -136,7 +136,7 @@ namespace Server.Multis Records = records.ToArray(); } - public DataRecord[] Records{ get; } + public DataRecord[] Records { get; } public int GetColumnID(string name) { @@ -160,10 +160,10 @@ namespace Server.Multis private class ColumnInfo { - public int m_DataIndex; - public string m_Name; + public readonly int m_DataIndex; + public readonly string m_Name; - public string m_Type; + public readonly string m_Type; public ColumnInfo(int dataIndex, string type, string name) { @@ -183,9 +183,9 @@ namespace Server.Multis Data = data; } - public Spreadsheet Spreadsheet{ get; } + public Spreadsheet Spreadsheet { get; } - public object[] Data{ get; } + public object[] Data { get; } public object this[string name] => this[Spreadsheet.GetColumnID(name)]; diff --git a/Projects/Scripts/Multis/ContestHouses.cs b/Projects/Scripts/Multis/ContestHouses.cs index 6362da749..446c541d1 100644 --- a/Projects/Scripts/Multis/ContestHouses.cs +++ b/Projects/Scripts/Multis/ContestHouses.cs @@ -31,8 +31,8 @@ namespace Server.Multis } } - public BaseContestHouse(ContestHouseType type, int multiID, Mobile owner, int MaxLockDown, int MaxSecure) - : base(multiID, owner, MaxLockDown, MaxSecure) + public BaseContestHouse(ContestHouseType type, int multiID, Mobile owner, int maxLockDown, int maxSecure) + : base(multiID, owner, maxLockDown, maxSecure) { HouseType = type; @@ -71,9 +71,9 @@ namespace Server.Multis { base.OnLocationChange(oldLocation); - int x = base.Location.X - oldLocation.X; - int y = base.Location.Y - oldLocation.Y; - int z = base.Location.Z - oldLocation.Z; + int x = this.Location.X - oldLocation.X; + int y = this.Location.Y - oldLocation.Y; + int z = this.Location.Z - oldLocation.Z; if (Fixtures == null) return; @@ -122,38 +122,38 @@ namespace Server.Multis var teleporters = new Dictionary>(); - foreach (var entry in components.List.Where(e => e.m_Flags == 0)) + foreach (var entry in components.List.Where(e => e.Flags == 0)) // Teleporters - if (entry.m_ItemID >= 0x181D && entry.m_ItemID <= 0x1828) + if (entry.ItemId >= 0x181D && entry.ItemId <= 0x1828) { - if (teleporters.ContainsKey(entry.m_ItemID)) - teleporters[entry.m_ItemID].Add(entry); + if (teleporters.ContainsKey(entry.ItemId)) + teleporters[entry.ItemId].Add(entry); else - teleporters[entry.m_ItemID] = new List { entry }; + teleporters[entry.ItemId] = new List { entry }; } else { - ItemData data = TileData.ItemTable[entry.m_ItemID & TileData.MaxItemValue]; + ItemData data = TileData.ItemTable[entry.ItemId & TileData.MaxItemValue]; // door if ((data.Flags & TileFlag.Door) != 0) - AddDoor(entry.m_ItemID, entry.m_OffsetX, entry.m_OffsetY, entry.m_OffsetZ); + AddDoor(entry.ItemId, entry.OffsetX, entry.OffsetY, entry.OffsetZ); else { - Item st = new Static((int)entry.m_ItemID); + Item st = new Static((int)entry.ItemId); - st.MoveToWorld(new Point3D(X + entry.m_OffsetX, Y + entry.m_OffsetY, entry.m_OffsetZ), Map); + st.MoveToWorld(new Point3D(X + entry.OffsetX, Y + entry.OffsetY, entry.OffsetZ), Map); AddFixture(st); } } foreach (var door in Doors) - foreach (var check in Doors.Where(d => d != door)) - if (door.InRange(check.Location, 1)) - { - door.Link = check; - check.Link = door; - } + foreach (var check in Doors.Where(d => d != door)) + if (door.InRange(check.Location, 1)) + { + door.Link = check; + check.Link = door; + } foreach (var (key, value) in teleporters) { @@ -168,9 +168,8 @@ namespace Server.Multis AddTeleporters( key, - new Point3D(value[0].m_OffsetX, value[0].m_OffsetY, value[0].m_OffsetZ), - new Point3D(value[1].m_OffsetX, value[1].m_OffsetY, value[1].m_OffsetZ) - ); + new Point3D(value[0].OffsetX, value[0].OffsetY, value[0].OffsetZ), + new Point3D(value[1].OffsetX, value[1].OffsetY, value[1].OffsetZ)); } teleporters.Clear(); @@ -202,7 +201,7 @@ namespace Server.Multis int count = reader.ReadInt(); - for(int i = 0; i < count; i++) + for (int i = 0; i < count; i++) AddFixture(reader.ReadItem()); } } diff --git a/Projects/Scripts/Multis/Deeds.cs b/Projects/Scripts/Multis/Deeds.cs index 3060fd01e..cdc8ba4f8 100644 --- a/Projects/Scripts/Multis/Deeds.cs +++ b/Projects/Scripts/Multis/Deeds.cs @@ -6,7 +6,7 @@ namespace Server.Multis.Deeds { public class HousePlacementTarget : MultiTarget { - private HouseDeed m_Deed; + private readonly HouseDeed m_Deed; public HousePlacementTarget(HouseDeed deed) : base(deed.MultiID, deed.Offset) => m_Deed = deed; @@ -53,12 +53,12 @@ namespace Server.Multis.Deeds } [CommandProperty(AccessLevel.GameMaster)] - public int MultiID{ get; set; } + public int MultiID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public Point3D Offset{ get; set; } + public Point3D Offset { get; set; } - public abstract Rectangle2D[] Area{ get; } + public abstract Rectangle2D[] Area { get; } public override void Serialize(IGenericWriter writer) { @@ -80,17 +80,17 @@ namespace Server.Multis.Deeds switch (version) { case 1: - { - Offset = reader.ReadPoint3D(); + { + Offset = reader.ReadPoint3D(); - goto case 0; - } + goto case 0; + } case 0: - { - MultiID = reader.ReadInt(); + { + MultiID = reader.ReadInt(); - break; - } + break; + } } if (Weight == 0.0) @@ -109,9 +109,10 @@ namespace Server.Multis.Deeds } else { - from.SendLocalizedMessage(1010433); /* House placement cancellation could result in a - * 60 second delay in the return of your deed. - */ + /* House placement cancellation could result in a + * 60 second delay in the return of your deed. + */ + from.SendLocalizedMessage(1010433); from.Target = new HousePlacementTarget(this); } @@ -140,55 +141,55 @@ namespace Server.Multis.Deeds switch (res) { case HousePlacementResult.Valid: - { - BaseHouse house = GetHouse(from); - house.MoveToWorld(center, from.Map); - Delete(); - - for (int i = 0; i < toMove.Count; ++i) { - object o = toMove[i]; + BaseHouse house = GetHouse(from); + house.MoveToWorld(center, from.Map); + Delete(); - if (o is Mobile mobile) - mobile.Location = house.BanLocation; - else if (o is Item item) - item.Location = house.BanLocation; + for (int i = 0; i < toMove.Count; ++i) + { + object o = toMove[i]; + + if (o is Mobile mobile) + mobile.Location = house.BanLocation; + else if (o is Item item) + item.Location = house.BanLocation; + } + + break; } - - break; - } case HousePlacementResult.BadItem: case HousePlacementResult.BadLand: case HousePlacementResult.BadStatic: case HousePlacementResult.BadRegionHidden: - { - from.SendLocalizedMessage( - 1043287); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. - break; - } + { + from.SendLocalizedMessage( + 1043287); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + break; + } case HousePlacementResult.NoSurface: - { - from.SendMessage( - "The house could not be created here. Part of the foundation would not be on any surface."); - break; - } + { + from.SendMessage( + "The house could not be created here. Part of the foundation would not be on any surface."); + break; + } case HousePlacementResult.BadRegion: - { - from.SendLocalizedMessage(501265); // Housing cannot be created in this area. - break; - } + { + from.SendLocalizedMessage(501265); // Housing cannot be created in this area. + break; + } case HousePlacementResult.BadRegionTemp: - { - from.SendLocalizedMessage( - 501270); //Lord British has decreed a 'no build' period, thus you cannot build this house at this time. - break; - } + { + from.SendLocalizedMessage( + 501270); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + break; + } case HousePlacementResult.BadRegionRaffle: - { - from.SendLocalizedMessage( - 1150493); // You must have a deed for this plot of land in order to build here. - break; - } + { + from.SendLocalizedMessage( + 1150493); // You must have a deed for this plot of land in order to build here. + break; + } } } } diff --git a/Projects/Scripts/Multis/DynamicDecay.cs b/Projects/Scripts/Multis/DynamicDecay.cs index 8976f294a..e7ef808bf 100644 --- a/Projects/Scripts/Multis/DynamicDecay.cs +++ b/Projects/Scripts/Multis/DynamicDecay.cs @@ -5,7 +5,7 @@ namespace Server.Multis { public class DynamicDecay { - private static Dictionary m_Stages; + private static readonly Dictionary m_Stages; static DynamicDecay() { @@ -48,8 +48,8 @@ namespace Server.Multis MaxDuration = max; } - public TimeSpan MinDuration{ get; } + public TimeSpan MinDuration { get; } - public TimeSpan MaxDuration{ get; } + public TimeSpan MaxDuration { get; } } } diff --git a/Projects/Scripts/Multis/HouseFoundation.cs b/Projects/Scripts/Multis/HouseFoundation.cs index 5a44ddc72..8e82b1740 100644 --- a/Projects/Scripts/Multis/HouseFoundation.cs +++ b/Projects/Scripts/Multis/HouseFoundation.cs @@ -35,7 +35,7 @@ namespace Server.Multis /* Stair block IDs * (sorted ascending) */ - private static int[] m_BlockIDs = + private static readonly int[] m_BlockIDs = { 0x3EE, 0x709, 0x71E, 0x721, 0x738, 0x750, 0x76C, 0x788, @@ -47,7 +47,7 @@ namespace Server.Multis * (sorted ascending) * Use this for stairs in the proper N,W,S,E sequence */ - private static int[] m_StairSeqs = + private static readonly int[] m_StairSeqs = { 0x3EF, 0x70A, 0x722, 0x739, 0x751, 0x76D, 0x789, 0x7A4 @@ -57,7 +57,7 @@ namespace Server.Multis * Listed in order: north, west, south, east * Use this for stairs not in the proper sequence */ - private static int[] m_StairIDs = + private static readonly int[] m_StairIDs = { 0x71F, 0x736, 0x737, 0x749, 0x35D4, 0x35D3, 0x35D6, 0x35D5, @@ -99,19 +99,19 @@ namespace Server.Multis { } - public FoundationType Type{ get; set; } + public FoundationType Type { get; set; } - public int LastRevision{ get; set; } + public int LastRevision { get; set; } - public List Fixtures{ get; private set; } + public List Fixtures { get; private set; } - public Item SignHanger{ get; private set; } + public Item SignHanger { get; private set; } - public Item Signpost{ get; private set; } + public Item Signpost { get; private set; } - public int SignpostGraphic{ get; set; } + public int SignpostGraphic { get; set; } - public Mobile Customizer{ get; set; } + public Mobile Customizer { get; set; } public override bool IsAosRules => true; @@ -307,7 +307,7 @@ namespace Server.Multis for (int i = 0; i < list.Length; ++i) { MultiTileEntry mte = list[i]; - int itemID = mte.m_ItemID; + int itemID = mte.ItemId; if (itemID >= 0x181D && itemID < 0x1829) { @@ -375,13 +375,13 @@ namespace Server.Multis } else if (itemID >= 0x241F && itemID < 0x2421) { - //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); + // DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); door = new GenericHouseDoor(DoorFacing.NorthCCW, 0x2415, -1, -1); } else if (itemID >= 0x2423 && itemID < 0x2425) { - //DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); - //This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these + // DoorFacing facing = (DoorFacing)(((itemID - 0x241F) / 2) % 8); + // This one and the above one are 'special' cases, ie: OSI had the ItemID pattern discombobulated for these door = new GenericHouseDoor(DoorFacing.WestCW, 0x2423, -1, -1); } else if (itemID >= 0x2A05 && itemID < 0x2A1D) @@ -415,7 +415,7 @@ namespace Server.Multis } else if (itemID >= 0x319C && itemID < 0x31AE) { - //special case for 0x31aa <-> 0x31a8 (a9) + // special case for 0x31aa <-> 0x31a8 (a9) int mod = (itemID - 0x319C) / 2 % 2; @@ -463,8 +463,8 @@ namespace Server.Multis else if (itemID >= 0x436E && itemID < 0x437E) { /* These ones had to be different... - * Offset 0 2 4 6 8 10 12 14 - * DoorFacing 2 3 2 3 6 7 6 7 + * Offset 0 2 4 6 8 10 12 14 + * DoorFacing 2 3 2 3 6 7 6 7 */ int offset = itemID - 0x436E; DoorFacing facing = (DoorFacing)((offset / 2 + 2 * ((1 + offset / 4) % 2)) % 8); @@ -499,7 +499,7 @@ namespace Server.Multis door.Locked = true; door.KeyValue = keyValue; - AddDoor(door, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ); + AddDoor(door, mte.OffsetX, mte.OffsetY, mte.OffsetZ); Fixtures.Add(door); } } @@ -607,7 +607,7 @@ namespace Server.Multis public void AddFixture(Item item, MultiTileEntry mte) { Fixtures.Add(item); - item.MoveToWorld(new Point3D(X + mte.m_OffsetX, Y + mte.m_OffsetY, Z + mte.m_OffsetZ), Map); + item.MoveToWorld(new Point3D(X + mte.OffsetX, Y + mte.OffsetY, Z + mte.OffsetZ), Map); } public static void GetFoundationGraphics(FoundationType type, out int east, out int south, out int post, @@ -847,48 +847,48 @@ namespace Server.Multis { case 5: case 4: - { - Signpost = reader.ReadItem(); - SignpostGraphic = reader.ReadInt(); + { + Signpost = reader.ReadItem(); + SignpostGraphic = reader.ReadInt(); - goto case 3; - } + goto case 3; + } case 3: - { - Type = (FoundationType)reader.ReadInt(); + { + Type = (FoundationType)reader.ReadInt(); - goto case 2; - } + goto case 2; + } case 2: - { - SignHanger = reader.ReadItem(); + { + SignHanger = reader.ReadItem(); - goto case 1; - } + goto case 1; + } case 1: - { - if (version < 5) - m_DefaultPrice = reader.ReadInt(); + { + if (version < 5) + m_DefaultPrice = reader.ReadInt(); - goto case 0; - } + goto case 0; + } case 0: - { - if (version < 3) - Type = FoundationType.Stone; + { + if (version < 3) + Type = FoundationType.Stone; - if (version < 4) - SignpostGraphic = 9; + if (version < 4) + SignpostGraphic = 9; - LastRevision = reader.ReadInt(); - Fixtures = reader.ReadStrongItemList(); + LastRevision = reader.ReadInt(); + Fixtures = reader.ReadStrongItemList(); - m_Current = new DesignState(this, reader); - m_Design = new DesignState(this, reader); - m_Backup = new DesignState(this, reader); + m_Current = new DesignState(this, reader); + m_Design = new DesignState(this, reader); + m_Backup = new DesignState(this, reader); - break; - } + break; + } } base.Deserialize(reader); @@ -1216,7 +1216,7 @@ namespace Server.Multis public static bool IsStair(int id, ref int dir) { - //dir n=0 w=1 s=2 e=3 + // dir n=0 w=1 s=2 e=3 int delta = -4; for (int i = 0; delta < -3 && i < m_StairSeqs.Length; ++i) @@ -1281,37 +1281,37 @@ namespace Server.Multis switch (dir) { default: - { - xStart = x; - yStart = y + height; - xInc = 0; - yInc = -1; - break; - } + { + xStart = x; + yStart = y + height; + xInc = 0; + yInc = -1; + break; + } case 1: // West - { - xStart = x + height; - yStart = y; - xInc = -1; - yInc = 0; - break; - } + { + xStart = x + height; + yStart = y; + xInc = -1; + yInc = 0; + break; + } case 2: // South - { - xStart = x; - yStart = y - height; - xInc = 0; - yInc = 1; - break; - } + { + xStart = x; + yStart = y - height; + xInc = 0; + yInc = 1; + break; + } case 3: // East - { - xStart = x - height; - yStart = y; - xInc = 1; - yInc = 0; - break; - } + { + xStart = x - height; + yStart = y; + xInc = 1; + yInc = 0; + break; + } } int zStart = z - height * 5; @@ -1471,8 +1471,8 @@ namespace Server.Multis { MultiTileEntry entry = stairs.List[i]; - if (entry.m_ItemID != 1) - mcl.Add(entry.m_ItemID, x + entry.m_OffsetX, y + entry.m_OffsetY, z + entry.m_OffsetZ); + if (entry.ItemId != 1) + mcl.Add(entry.ItemId, x + entry.OffsetX, y + entry.OffsetY, z + entry.OffsetZ); } // Update revision @@ -1628,7 +1628,7 @@ namespace Server.Multis Mobile from = state.Mobile; DesignContext context = DesignContext.Find(from); - if (context == null || !Core.SE && from.AccessLevel < AccessLevel.GameMaster) + if (context == null || (!Core.SE && from.AccessLevel < AccessLevel.GameMaster)) return; // Read data detailing component graphic and location @@ -1658,10 +1658,10 @@ namespace Server.Multis { MultiTileEntry mte = list[i]; - if (mte.m_OffsetX == x && mte.m_OffsetY == y && - GetZLevel(mte.m_OffsetZ, context.Foundation) == context.Level && - (TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0) - mcl.Remove(mte.m_ItemID, x, y, mte.m_OffsetZ); + if (mte.OffsetX == x && mte.OffsetY == y && + GetZLevel(mte.OffsetZ, context.Foundation) == context.Level && + (TileData.ItemTable[mte.ItemId & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0) + mcl.Remove(mte.ItemId, x, y, mte.OffsetZ); } mcl.Add(itemID, x, y, z); @@ -1709,7 +1709,7 @@ namespace Server.Multis { Foundation = foundation; Components = components; - Fixtures = new MultiTileEntry[0]; + Fixtures = Array.Empty(); } public DesignState(DesignState toCopy) @@ -1732,26 +1732,26 @@ namespace Server.Multis switch (version) { case 0: - { - Components = new MultiComponentList(reader); - - int length = reader.ReadInt(); - - Fixtures = new MultiTileEntry[length]; - - for (int i = 0; i < length; ++i) { - Fixtures[i].m_ItemID = reader.ReadUShort(); - Fixtures[i].m_OffsetX = reader.ReadShort(); - Fixtures[i].m_OffsetY = reader.ReadShort(); - Fixtures[i].m_OffsetZ = reader.ReadShort(); - Fixtures[i].m_Flags = (TileFlag)reader.ReadInt(); + Components = new MultiComponentList(reader); + + int length = reader.ReadInt(); + + Fixtures = new MultiTileEntry[length]; + + for (int i = 0; i < length; ++i) + { + Fixtures[i].ItemId = reader.ReadUShort(); + Fixtures[i].OffsetX = reader.ReadShort(); + Fixtures[i].OffsetY = reader.ReadShort(); + Fixtures[i].OffsetZ = reader.ReadShort(); + Fixtures[i].Flags = (TileFlag)reader.ReadInt(); + } + + Revision = reader.ReadInt(); + + break; } - - Revision = reader.ReadInt(); - - break; - } } } @@ -1769,13 +1769,13 @@ namespace Server.Multis } } - public HouseFoundation Foundation{ get; } + public HouseFoundation Foundation { get; } - public MultiComponentList Components{ get; } + public MultiComponentList Components { get; } - public MultiTileEntry[] Fixtures{ get; private set; } + public MultiTileEntry[] Fixtures { get; private set; } - public int Revision{ get; set; } + public int Revision { get; set; } public void Serialize(IGenericWriter writer) { @@ -1789,11 +1789,11 @@ namespace Server.Multis { MultiTileEntry ent = Fixtures[i]; - writer.Write(ent.m_ItemID); - writer.Write(ent.m_OffsetX); - writer.Write(ent.m_OffsetY); - writer.Write(ent.m_OffsetZ); - writer.Write((int)ent.m_Flags); + writer.Write(ent.ItemId); + writer.Write(ent.OffsetX); + writer.Write(ent.OffsetY); + writer.Write(ent.OffsetZ); + writer.Write((int)ent.Flags); } writer.Write(Revision); @@ -1836,10 +1836,10 @@ namespace Server.Multis { MultiTileEntry mte = Fixtures[i]; - Components.Add(mte.m_ItemID, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ); + Components.Add(mte.ItemId, mte.OffsetX, mte.OffsetY, mte.OffsetZ); } - Fixtures = new MultiTileEntry[0]; + Fixtures = Array.Empty(); } public void MeltFixtures() @@ -1853,7 +1853,7 @@ namespace Server.Multis { MultiTileEntry mte = list[i]; - if (IsFixture(mte.m_ItemID)) + if (IsFixture(mte.ItemId)) ++length; } @@ -1863,10 +1863,10 @@ namespace Server.Multis { MultiTileEntry mte = list[i]; - if (IsFixture(mte.m_ItemID)) + if (IsFixture(mte.ItemId)) { Fixtures[--length] = mte; - Components.Remove(mte.m_ItemID, mte.m_OffsetX, mte.m_OffsetY, mte.m_OffsetZ); + Components.Remove(mte.ItemId, mte.OffsetX, mte.OffsetY, mte.OffsetZ); } } } @@ -1937,7 +1937,7 @@ namespace Server.Multis public class ConfirmCommitGump : Gump { - private HouseFoundation m_Foundation; + private readonly HouseFoundation m_Foundation; public ConfirmCommitGump(Mobile from, HouseFoundation foundation, int bankBalance, int oldPrice, int newPrice) : base(50, 50) @@ -2000,13 +2000,13 @@ namespace Server.Multis Level = 1; } - public HouseFoundation Foundation{ get; } + public HouseFoundation Foundation { get; } - public int Level{ get; set; } + public int Level { get; set; } public int MaxLevels => Foundation.MaxLevels; - public static Dictionary Table{ get; } = new Dictionary(); + public static Dictionary Table { get; } = new Dictionary(); public static DesignContext Find(Mobile from) { @@ -2025,7 +2025,6 @@ namespace Server.Multis m.SendLocalizedMessage(1062206); // You cannot do that while customizing a house. return false; - } public static void Add(Mobile from, HouseFoundation foundation) @@ -2112,13 +2111,13 @@ namespace Server.Multis { EnsureCapacity(17); - m_Stream.Write((short)0x20); - m_Stream.Write(house.Serial); - m_Stream.Write((byte)0x04); - m_Stream.Write((ushort)0x0000); - m_Stream.Write((ushort)0xFFFF); - m_Stream.Write((ushort)0xFFFF); - m_Stream.Write((byte)0xFF); + Stream.Write((short)0x20); + Stream.Write(house.Serial); + Stream.Write((byte)0x04); + Stream.Write((ushort)0x0000); + Stream.Write((ushort)0xFFFF); + Stream.Write((ushort)0xFFFF); + Stream.Write((byte)0xFF); } } @@ -2129,13 +2128,13 @@ namespace Server.Multis { EnsureCapacity(17); - m_Stream.Write((short)0x20); - m_Stream.Write(house.Serial); - m_Stream.Write((byte)0x05); - m_Stream.Write((ushort)0x0000); - m_Stream.Write((ushort)0xFFFF); - m_Stream.Write((ushort)0xFFFF); - m_Stream.Write((byte)0xFF); + Stream.Write((short)0x20); + Stream.Write(house.Serial); + Stream.Write((byte)0x05); + Stream.Write((ushort)0x0000); + Stream.Write((ushort)0xFFFF); + Stream.Write((ushort)0xFFFF); + Stream.Write((byte)0xFF); } } @@ -2146,9 +2145,9 @@ namespace Server.Multis { EnsureCapacity(13); - m_Stream.Write((short)0x1D); - m_Stream.Write(house.Serial); - m_Stream.Write(state.Revision); + Stream.Write((short)0x1D); + Stream.Write(house.Serial); + Stream.Write(state.Revision); } } @@ -2156,14 +2155,14 @@ namespace Server.Multis { public const int MaxItemsPerStairBuffer = 750; - private static ConcurrentQueue m_SendQueue; - private static AutoResetEvent m_Sync; + private static readonly ConcurrentQueue m_SendQueue; + private static readonly AutoResetEvent m_Sync; - private byte[][] m_PlaneBuffers; + private readonly byte[][] m_PlaneBuffers; - private bool[] m_PlaneUsed = new bool[9]; - private byte[] m_PrimBuffer = new byte[4]; - private byte[][] m_StairBuffers; + private readonly bool[] m_PlaneUsed = new bool[9]; + private readonly byte[] m_PrimBuffer = new byte[4]; + private readonly byte[][] m_StairBuffers; static DesignStateDetailed() { @@ -2214,10 +2213,10 @@ namespace Server.Multis for (int i = 0; i < tiles.Length; ++i) { MultiTileEntry mte = tiles[i]; - int x = mte.m_OffsetX - xMin; - int y = mte.m_OffsetY - yMin; - int z = mte.m_OffsetZ; - bool floor = TileData.ItemTable[mte.m_ItemID & TileData.MaxItemValue].Height <= 0; + int x = mte.OffsetX - xMin; + int y = mte.OffsetY - yMin; + int z = mte.OffsetZ; + bool floor = TileData.ItemTable[mte.ItemId & TileData.MaxItemValue].Height <= 0; int plane, size; switch (z) @@ -2238,23 +2237,23 @@ namespace Server.Multis plane = 4; break; default: - { - int stairBufferIndex = totalStairsUsed / MaxItemsPerStairBuffer; - byte[] stairBuffer = m_StairBuffers[stairBufferIndex]; + { + int stairBufferIndex = totalStairsUsed / MaxItemsPerStairBuffer; + byte[] stairBuffer = m_StairBuffers[stairBufferIndex]; - int byteIndex = totalStairsUsed % MaxItemsPerStairBuffer * 5; + int byteIndex = totalStairsUsed % MaxItemsPerStairBuffer * 5; - stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8); - stairBuffer[byteIndex++] = (byte)mte.m_ItemID; + stairBuffer[byteIndex++] = (byte)(mte.ItemId >> 8); + stairBuffer[byteIndex++] = (byte)mte.ItemId; - stairBuffer[byteIndex++] = (byte)mte.m_OffsetX; - stairBuffer[byteIndex++] = (byte)mte.m_OffsetY; - stairBuffer[byteIndex++] = (byte)mte.m_OffsetZ; + stairBuffer[byteIndex++] = (byte)mte.OffsetX; + stairBuffer[byteIndex++] = (byte)mte.OffsetY; + stairBuffer[byteIndex++] = (byte)mte.OffsetZ; - ++totalStairsUsed; + ++totalStairsUsed; - continue; - } + continue; + } } if (plane == 0) @@ -2282,20 +2281,20 @@ namespace Server.Multis int byteIndex = totalStairsUsed % MaxItemsPerStairBuffer * 5; - stairBuffer[byteIndex++] = (byte)(mte.m_ItemID >> 8); - stairBuffer[byteIndex++] = (byte)mte.m_ItemID; + stairBuffer[byteIndex++] = (byte)(mte.ItemId >> 8); + stairBuffer[byteIndex++] = (byte)mte.ItemId; - stairBuffer[byteIndex++] = (byte)mte.m_OffsetX; - stairBuffer[byteIndex++] = (byte)mte.m_OffsetY; - stairBuffer[byteIndex++] = (byte)mte.m_OffsetZ; + stairBuffer[byteIndex++] = (byte)mte.OffsetX; + stairBuffer[byteIndex++] = (byte)mte.OffsetY; + stairBuffer[byteIndex++] = (byte)mte.OffsetZ; ++totalStairsUsed; } else { m_PlaneUsed[plane] = true; - m_PlaneBuffers[plane][index] = (byte)(mte.m_ItemID >> 8); - m_PlaneBuffers[plane][index + 1] = (byte)mte.m_ItemID; + m_PlaneBuffers[plane][index] = (byte)(mte.ItemId >> 8); + m_PlaneBuffers[plane][index + 1] = (byte)mte.ItemId; } } @@ -2325,7 +2324,7 @@ namespace Server.Multis byte[] inflatedBuffer = m_PlaneBuffers[i]; int deflatedLength = m_DeflatedBuffer.Length; - ZLibError ce = Compression.Pack(m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, + ZLibError ce = NetworkCompression.Pack(m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, ZLibQuality.Default); if (ce != ZLibError.Okay) @@ -2361,7 +2360,7 @@ namespace Server.Multis byte[] inflatedBuffer = m_StairBuffers[i]; int deflatedLength = m_DeflatedBuffer.Length; - ZLibError ce = Compression.Pack(m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, + ZLibError ce = NetworkCompression.Pack(m_DeflatedBuffer, ref deflatedLength, inflatedBuffer, size, ZLibQuality.Default); if (ce != ZLibError.Okay) @@ -2385,7 +2384,7 @@ namespace Server.Multis ArrayPool.Shared.Return(m_DeflatedBuffer); - m_Stream.Seek(15, SeekOrigin.Begin); + Stream.Seek(15, SeekOrigin.Begin); Write((short)totalLength); // Buffer length Write((byte)planeCount); // Plane count @@ -2398,7 +2397,7 @@ namespace Server.Multis m_PrimBuffer[2] = (byte)(value >> 8); m_PrimBuffer[3] = (byte)value; - m_Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 4); + Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 4); } public void Write(uint value) @@ -2408,7 +2407,7 @@ namespace Server.Multis m_PrimBuffer[2] = (byte)(value >> 8); m_PrimBuffer[3] = (byte)value; - m_Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 4); + Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 4); } public void Write(short value) @@ -2416,17 +2415,17 @@ namespace Server.Multis m_PrimBuffer[0] = (byte)(value >> 8); m_PrimBuffer[1] = (byte)value; - m_Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 2); + Stream.UnderlyingStream.Write(m_PrimBuffer, 0, 2); } public void Write(byte value) { - m_Stream.UnderlyingStream.WriteByte(value); + Stream.UnderlyingStream.WriteByte(value); } public void Write(byte[] buffer, int offset, int size) { - m_Stream.UnderlyingStream.Write(buffer, offset, size); + Stream.UnderlyingStream.Write(buffer, offset, size); } public static void Clear(byte[] buffer, int size) @@ -2498,12 +2497,15 @@ namespace Server.Multis private class SendQueueEntry { - public NetState m_NetState; - public DesignState m_Root; - public int m_Revision; - public uint m_Serial; - public MultiTileEntry[] m_Tiles; - public int m_xMin, m_yMin, m_xMax, m_yMax; + public readonly NetState m_NetState; + public readonly DesignState m_Root; + public readonly int m_Revision; + public readonly uint m_Serial; + public readonly MultiTileEntry[] m_Tiles; + public readonly int m_xMin; + public readonly int m_yMin; + public readonly int m_xMax; + public readonly int m_yMax; public SendQueueEntry(NetState ns, HouseFoundation foundation, DesignState state) { diff --git a/Projects/Scripts/Multis/HousePlacement.cs b/Projects/Scripts/Multis/HousePlacement.cs index a41b615f4..5181fa7e9 100644 --- a/Projects/Scripts/Multis/HousePlacement.cs +++ b/Projects/Scripts/Multis/HousePlacement.cs @@ -23,7 +23,7 @@ namespace Server.Multis private const int YardSize = 5; // Any land tile which matches one of these ID numbers is considered a road and cannot be placed over. - private static int[] m_RoadIDs = + private static readonly int[] m_RoadIDs = { 0x0071, 0x0078, 0x00E8, 0x00EB, @@ -84,190 +84,190 @@ namespace Server.Multis */ for (int x = 0; x < mcl.Width; ++x) - for (int y = 0; y < mcl.Height; ++y) - { - int tileX = start.X + x; - int tileY = start.Y + y; - - StaticTile[] addTiles = mcl.Tiles[x][y]; - - if (addTiles.Length == 0) - continue; // There are no tiles here, continue checking somewhere else - - Point3D testPoint = new Point3D(tileX, tileY, center.Z); - - Region reg = Region.Find(testPoint, map); - - if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc + for (int y = 0; y < mcl.Height; ++y) { - if (reg.IsPartOf()) - return HousePlacementResult.BadRegionTemp; + int tileX = start.X + x; + int tileY = start.Y + y; - if (reg.IsPartOf() || reg.IsPartOf()) - return HousePlacementResult.BadRegionHidden; + StaticTile[] addTiles = mcl.Tiles[x][y]; - if (reg.IsPartOf()) - return HousePlacementResult.BadRegionRaffle; + if (addTiles.Length == 0) + continue; // There are no tiles here, continue checking somewhere else - return HousePlacementResult.BadRegion; - } + Point3D testPoint = new Point3D(tileX, tileY, center.Z); - LandTile landTile = map.Tiles.GetLandTile(tileX, tileY); - int landID = landTile.ID & TileData.MaxLandValue; + Region reg = Region.Find(testPoint, map); - StaticTile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true); - - Sector sector = map.GetSector(tileX, tileY); - - items.Clear(); - - for (int i = 0; i < sector.Items.Count; ++i) - { - Item item = sector.Items[i]; - - if (item.Visible && item.X == tileX && item.Y == tileY) - items.Add(item); - } - - mobiles.Clear(); - - for (int i = 0; i < sector.Mobiles.Count; ++i) - { - Mobile m = sector.Mobiles[i]; - - if (m.X == tileX && m.Y == tileY) - mobiles.Add(m); - } - - int landStartZ = 0, landAvgZ = 0, landTopZ = 0; - - map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ); - - bool hasFoundation = false; - - for (int i = 0; i < addTiles.Length; ++i) - { - StaticTile addTile = addTiles[i]; - - if (addTile.ID == 0x1) // Nodraw - continue; - - TileFlag addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags; - - bool isFoundation = addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0; - bool hasSurface = false; - - if (isFoundation) - hasFoundation = true; - - int addTileZ = center.Z + addTile.Z; - int addTileTop = addTileZ + addTile.Height; - - if ((addTileFlags & TileFlag.Surface) != 0) - addTileTop += 16; - - if (addTileTop > landStartZ && landAvgZ > addTileZ) - return HousePlacementResult.BadLand; // Broke rule #2 - - if (isFoundation && - (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0 && - landAvgZ == center.Z) - hasSurface = true; - - for (int j = 0; j < oldTiles.Length; ++j) + if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc { - StaticTile oldTile = oldTiles[j]; - ItemData id = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue]; + if (reg.IsPartOf()) + return HousePlacementResult.BadRegionTemp; - if ((id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0) && - addTileTop > oldTile.Z && oldTile.Z + id.CalcHeight > addTileZ) - return HousePlacementResult.BadStatic; // Broke rule #2 - /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z ) - hasSurface = true;*/ + if (reg.IsPartOf() || reg.IsPartOf()) + return HousePlacementResult.BadRegionHidden; + + if (reg.IsPartOf()) + return HousePlacementResult.BadRegionRaffle; + + return HousePlacementResult.BadRegion; } - for (int j = 0; j < items.Count; ++j) + LandTile landTile = map.Tiles.GetLandTile(tileX, tileY); + int landID = landTile.ID & TileData.MaxLandValue; + + StaticTile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true); + + Sector sector = map.GetSector(tileX, tileY); + + items.Clear(); + + for (int i = 0; i < sector.Items.Count; ++i) { - Item item = items[j]; - ItemData id = item.ItemData; + Item item = sector.Items[i]; - if (addTileTop > item.Z && item.Z + id.CalcHeight > addTileZ) - { - if (item.Movable) - toMove.Add(item); - else if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0) - return HousePlacementResult.BadItem; // Broke rule #2 - } - - /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z ) - { - hasSurface = true; - }*/ + if (item.Visible && item.X == tileX && item.Y == tileY) + items.Add(item); } - if (isFoundation && !hasSurface) - return HousePlacementResult.NoSurface; // Broke rule #4 + mobiles.Clear(); - for (int j = 0; j < mobiles.Count; ++j) + for (int i = 0; i < sector.Mobiles.Count; ++i) { - Mobile m = mobiles[j]; + Mobile m = sector.Mobiles[i]; - if (addTileTop > m.Z && m.Z + 16 > addTileZ) - toMove.Add(m); - } - } - - for (int i = 0; i < m_RoadIDs.Length; i += 2) - if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) - return HousePlacementResult.BadLand; // Broke rule #5 - - if (hasFoundation) - { - for (int xOffset = -1; xOffset <= 1; ++xOffset) - for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset) - { - Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset); - - if (!yard.Contains(yardPoint)) - yard.Add(yardPoint); + if (m.X == tileX && m.Y == tileY) + mobiles.Add(m); } - for (int xOffset = -1; xOffset <= 1; ++xOffset) - for (int yOffset = -1; yOffset <= 1; ++yOffset) + int landStartZ = 0, landAvgZ = 0, landTopZ = 0; + + map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ); + + bool hasFoundation = false; + + for (int i = 0; i < addTiles.Length; ++i) { - if (xOffset == 0 && yOffset == 0) + StaticTile addTile = addTiles[i]; + + if (addTile.ID == 0x1) // Nodraw continue; - // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8) + TileFlag addTileFlags = TileData.ItemTable[addTile.ID & TileData.MaxItemValue].Flags; - int vx = x + xOffset; - int vy = y + yOffset; + bool isFoundation = addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0; + bool hasSurface = false; - if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height) + if (isFoundation) + hasFoundation = true; + + int addTileZ = center.Z + addTile.Z; + int addTileTop = addTileZ + addTile.Height; + + if ((addTileFlags & TileFlag.Surface) != 0) + addTileTop += 16; + + if (addTileTop > landStartZ && landAvgZ > addTileZ) + return HousePlacementResult.BadLand; // Broke rule #2 + + if (isFoundation && + (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) == 0 && + landAvgZ == center.Z) + hasSurface = true; + + for (int j = 0; j < oldTiles.Length; ++j) { - StaticTile[] breakTiles = mcl.Tiles[vx][vy]; - bool shouldBreak = false; + StaticTile oldTile = oldTiles[j]; + ItemData id = TileData.ItemTable[oldTile.ID & TileData.MaxItemValue]; - for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i) - { - StaticTile breakTile = breakTiles[i]; - - if (breakTile.Height == 0 && breakTile.Z <= 8 && - TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface) - shouldBreak = true; - } - - if (shouldBreak) - continue; + if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && + addTileTop > oldTile.Z && oldTile.Z + id.CalcHeight > addTileZ) + return HousePlacementResult.BadStatic; // Broke rule #2 + /*else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z) + hasSurface = true;*/ } - Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset); + for (int j = 0; j < items.Count; ++j) + { + Item item = items[j]; + ItemData id = item.ItemData; - if (!borders.Contains(borderPoint)) - borders.Add(borderPoint); + if (addTileTop > item.Z && item.Z + id.CalcHeight > addTileZ) + { + if (item.Movable) + toMove.Add(item); + else if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) + return HousePlacementResult.BadItem; // Broke rule #2 + } + + /*else if (isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z) + { + hasSurface = true; + }*/ + } + + if (isFoundation && !hasSurface) + return HousePlacementResult.NoSurface; // Broke rule #4 + + for (int j = 0; j < mobiles.Count; ++j) + { + Mobile m = mobiles[j]; + + if (addTileTop > m.Z && m.Z + 16 > addTileZ) + toMove.Add(m); + } + } + + for (int i = 0; i < m_RoadIDs.Length; i += 2) + if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) + return HousePlacementResult.BadLand; // Broke rule #5 + + if (hasFoundation) + { + for (int xOffset = -1; xOffset <= 1; ++xOffset) + for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset) + { + Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset); + + if (!yard.Contains(yardPoint)) + yard.Add(yardPoint); + } + + for (int xOffset = -1; xOffset <= 1; ++xOffset) + for (int yOffset = -1; yOffset <= 1; ++yOffset) + { + if (xOffset == 0 && yOffset == 0) + continue; + + // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8) + + int vx = x + xOffset; + int vy = y + yOffset; + + if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height) + { + StaticTile[] breakTiles = mcl.Tiles[vx][vy]; + bool shouldBreak = false; + + for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i) + { + StaticTile breakTile = breakTiles[i]; + + if (breakTile.Height == 0 && breakTile.Z <= 8 && + TileData.ItemTable[breakTile.ID & TileData.MaxItemValue].Surface) + shouldBreak = true; + } + + if (shouldBreak) + continue; + } + + Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset); + + if (!borders.Contains(borderPoint)) + borders.Add(borderPoint); + } } } - } for (int i = 0; i < borders.Count; ++i) { @@ -290,8 +290,8 @@ namespace Server.Multis StaticTile tile = tiles[j]; ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; - if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0 && - tile.Z + id.CalcHeight > center.Z + 2) + if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && + tile.Z + id.CalcHeight > center.Z + 2)) return HousePlacementResult.BadStatic; // Broke rule #1 } @@ -307,8 +307,8 @@ namespace Server.Multis ItemData id = item.ItemData; - if (id.Impassable || id.Surface && (id.Flags & TileFlag.Background) == 0 && - item.Z + id.CalcHeight > center.Z + 2) + if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && + item.Z + id.CalcHeight > center.Z + 2)) return HousePlacementResult.BadItem; // Broke rule #1 } } @@ -345,7 +345,7 @@ namespace Server.Multis { for ( int j = 0; j < tile.Length; ++j ) { - if ( (TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 ) + if ((TileData.ItemTable[tile[j].ID & TileData.MaxItemValue].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0) { eable.Free(); return HousePlacementResult.BadStatic; // Broke rule #3 diff --git a/Projects/Scripts/Multis/HousePlacementTool.cs b/Projects/Scripts/Multis/HousePlacementTool.cs index 6bac50918..ca919870f 100644 --- a/Projects/Scripts/Multis/HousePlacementTool.cs +++ b/Projects/Scripts/Multis/HousePlacementTool.cs @@ -56,7 +56,7 @@ namespace Server.Items { private const int LabelColor = 0x7FFF; private const int LabelColorDisabled = 0x4210; - private Mobile m_From; + private readonly Mobile m_From; public HousePlacementCategoryGump(Mobile from) : base(50, 50) { @@ -95,21 +95,21 @@ namespace Server.Items switch (info.ButtonID) { case 1: // Classic Houses - { - // TODO: Add flag to use ClassicHouses or EJ - m_From.SendGump(new HousePlacementListGump(m_From, HousePlacementEntry.HousesEJ)); - break; - } + { + // TODO: Add flag to use ClassicHouses or EJ + m_From.SendGump(new HousePlacementListGump(m_From, HousePlacementEntry.HousesEJ)); + break; + } case 2: // 2-Story Customizable Houses - { - m_From.SendGump(new HousePlacementListGump(m_From, HousePlacementEntry.TwoStoryFoundations)); - break; - } + { + m_From.SendGump(new HousePlacementListGump(m_From, HousePlacementEntry.TwoStoryFoundations)); + break; + } case 3: // 3-Story Customizable Houses - { - m_From.SendGump(new HousePlacementListGump(m_From, HousePlacementEntry.ThreeStoryFoundations)); - break; - } + { + m_From.SendGump(new HousePlacementListGump(m_From, HousePlacementEntry.ThreeStoryFoundations)); + break; + } } } } @@ -118,8 +118,8 @@ namespace Server.Items { private const int LabelColor = 0x7FFF; private const int LabelHue = 0x480; - private HousePlacementEntry[] m_Entries; - private Mobile m_From; + private readonly HousePlacementEntry[] m_Entries; + private readonly Mobile m_From; public HousePlacementListGump(Mobile from, HousePlacementEntry[] entries) : base(50, 50) { @@ -218,8 +218,8 @@ namespace Server.Items public class NewHousePlacementTarget : MultiTarget { - private HousePlacementEntry[] m_Entries; - private HousePlacementEntry m_Entry; + private readonly HousePlacementEntry[] m_Entries; + private readonly HousePlacementEntry m_Entry; private bool m_Placed; @@ -273,11 +273,11 @@ namespace Server.Items public class HousePlacementEntry { - private static Dictionary m_Table; - private int m_Lockdowns; - private int m_NewLockdowns; - private int m_NewStorage; - private int m_Storage; + private static readonly Dictionary m_Table; + private readonly int m_Lockdowns; + private readonly int m_NewLockdowns; + private readonly int m_NewStorage; + private readonly int m_Storage; static HousePlacementEntry() { @@ -305,19 +305,19 @@ namespace Server.Items MultiID = multiID; } - public Type Type{ get; } + public Type Type { get; } - public int Description{ get; } + public int Description { get; } public int Storage => BaseHouse.NewVendorSystem ? m_NewStorage : m_Storage; public int Lockdowns => BaseHouse.NewVendorSystem ? m_NewLockdowns : m_Lockdowns; - public int Vendors{ get; } + public int Vendors { get; } - public int Cost{ get; } + public int Cost { get; } - public int MultiID{ get; } + public int MultiID { get; } - public Point3D Offset{ get; } + public Point3D Offset { get; } public static HousePlacementEntry[] ClassicHouses { get; } = { @@ -343,50 +343,49 @@ namespace Server.Items new HousePlacementEntry(typeof(Castle), 1011314, 4076, 2038, 4688, 2344, 78, 865250, 0, 16, 0, 0x007E) }; - public static HousePlacementEntry[] HousesEJ { get; } = { - new HousePlacementEntry(typeof(SmallOldHouse), 1011303, 425, 212, 489, 244, 10, 36750, 0, 4, 0, 0x0064), - new HousePlacementEntry(typeof(SmallOldHouse), 1011304, 425, 212, 489, 244, 10, 36750, 0, 4, 0, 0x0066), - new HousePlacementEntry(typeof(SmallOldHouse), 1011305, 425, 212, 489, 244, 10, 36500, 0, 4, 0, 0x0068), - new HousePlacementEntry(typeof(SmallOldHouse), 1011306, 425, 212, 489, 244, 10, 35000, 0, 4, 0, 0x006A), - new HousePlacementEntry(typeof(SmallOldHouse), 1011307, 425, 212, 489, 244, 10, 36500, 0, 4, 0, 0x006C), - new HousePlacementEntry(typeof(SmallOldHouse), 1011308, 425, 212, 489, 244, 10, 36500, 0, 4, 0, 0x006E), - new HousePlacementEntry(typeof(SmallShop), 1011321, 425, 212, 489, 244, 10, 50250, -1, 4, 0, 0x00A0), - new HousePlacementEntry(typeof(SmallShop), 1011322, 425, 212, 489, 244, 10, 52250, 0, 4, 0, 0x00A2), - new HousePlacementEntry(typeof(SmallTower), 1011317, 580, 290, 667, 333, 14, 73250, 3, 4, 0, 0x0098), - new HousePlacementEntry(typeof(TwoStoryVilla), 1011319, 1100, 550, 1265, 632, 24, 113500, 3, 6, 0, 0x009E), - new HousePlacementEntry(typeof(SandStonePatio), 1011320, 850, 425, 1265, 632, 24, 76250, -1, 4, 0, 0x009C), - new HousePlacementEntry(typeof(LogCabin), 1011318, 1100, 550, 1265, 632, 24, 81250, 1, 6, 0, 0x009A), - new HousePlacementEntry(typeof(GuildHouse), 1011309, 1370, 685, 1576, 788, 28, 131250, -1, 7, 0, 0x0074), - new HousePlacementEntry(typeof(TwoStoryHouse), 1011310, 1370, 685, 1576, 788, 28, 162500, -3, 7, 0, 0x0076), - new HousePlacementEntry(typeof(TwoStoryHouse), 1011311, 1370, 685, 1576, 788, 28, 162750, -3, 7, 0, 0x0078), - new HousePlacementEntry(typeof(LargePatioHouse), 1011315, 1370, 685, 1576, 788, 28, 129000, -4, 7, 0, 0x008C), - new HousePlacementEntry(typeof(LargeMarbleHouse), 1011316, 1370, 685, 1576, 788, 28, 160250, -4, 7, 0, 0x0096), - new HousePlacementEntry(typeof(Tower), 1011312, 2119, 1059, 2437, 1218, 42, 366250, 0, 7, 0, 0x007A), - new HousePlacementEntry(typeof(Keep), 1011313, 2625, 1312, 3019, 1509, 52, 562500, 0, 11, 0, 0x007C), - new HousePlacementEntry(typeof(Castle), 1011314, 4076, 2038, 4688, 2344, 78, 865000, 0, 16, 0, 0x007E), + public static HousePlacementEntry[] HousesEJ { get; } = { + new HousePlacementEntry(typeof(SmallOldHouse), 1011303, 425, 212, 489, 244, 10, 36750, 0, 4, 0, 0x0064), + new HousePlacementEntry(typeof(SmallOldHouse), 1011304, 425, 212, 489, 244, 10, 36750, 0, 4, 0, 0x0066), + new HousePlacementEntry(typeof(SmallOldHouse), 1011305, 425, 212, 489, 244, 10, 36500, 0, 4, 0, 0x0068), + new HousePlacementEntry(typeof(SmallOldHouse), 1011306, 425, 212, 489, 244, 10, 35000, 0, 4, 0, 0x006A), + new HousePlacementEntry(typeof(SmallOldHouse), 1011307, 425, 212, 489, 244, 10, 36500, 0, 4, 0, 0x006C), + new HousePlacementEntry(typeof(SmallOldHouse), 1011308, 425, 212, 489, 244, 10, 36500, 0, 4, 0, 0x006E), + new HousePlacementEntry(typeof(SmallShop), 1011321, 425, 212, 489, 244, 10, 50250, -1, 4, 0, 0x00A0), + new HousePlacementEntry(typeof(SmallShop), 1011322, 425, 212, 489, 244, 10, 52250, 0, 4, 0, 0x00A2), + new HousePlacementEntry(typeof(SmallTower), 1011317, 580, 290, 667, 333, 14, 73250, 3, 4, 0, 0x0098), + new HousePlacementEntry(typeof(TwoStoryVilla), 1011319, 1100, 550, 1265, 632, 24, 113500, 3, 6, 0, 0x009E), + new HousePlacementEntry(typeof(SandStonePatio), 1011320, 850, 425, 1265, 632, 24, 76250, -1, 4, 0, 0x009C), + new HousePlacementEntry(typeof(LogCabin), 1011318, 1100, 550, 1265, 632, 24, 81250, 1, 6, 0, 0x009A), + new HousePlacementEntry(typeof(GuildHouse), 1011309, 1370, 685, 1576, 788, 28, 131250, -1, 7, 0, 0x0074), + new HousePlacementEntry(typeof(TwoStoryHouse), 1011310, 1370, 685, 1576, 788, 28, 162500, -3, 7, 0, 0x0076), + new HousePlacementEntry(typeof(TwoStoryHouse), 1011311, 1370, 685, 1576, 788, 28, 162750, -3, 7, 0, 0x0078), + new HousePlacementEntry(typeof(LargePatioHouse), 1011315, 1370, 685, 1576, 788, 28, 129000, -4, 7, 0, 0x008C), + new HousePlacementEntry(typeof(LargeMarbleHouse), 1011316, 1370, 685, 1576, 788, 28, 160250, -4, 7, 0, 0x0096), + new HousePlacementEntry(typeof(Tower), 1011312, 2119, 1059, 2437, 1218, 42, 366250, 0, 7, 0, 0x007A), + new HousePlacementEntry(typeof(Keep), 1011313, 2625, 1312, 3019, 1509, 52, 562500, 0, 11, 0, 0x007C), + new HousePlacementEntry(typeof(Castle), 1011314, 4076, 2038, 4688, 2344, 78, 865000, 0, 16, 0, 0x007E), - new HousePlacementEntry(typeof(TrinsicKeep), 1158748, 2625, 1312, 3019, 1509, 52, 29643750, 0, 11, 0, 0x147E), - new HousePlacementEntry(typeof(GothicRoseCastle), 1158749, 4076, 2038, 4688, 2344, 78, 44808750, 0, 16, 0, 0x147F), - new HousePlacementEntry(typeof(ElsaCastle), 1158750, 4076, 2038, 4688, 2344, 78, 45450000, 0, 16, 0, 0x1480), - new HousePlacementEntry(typeof(Spires), 1158761, 4076, 2038, 4688, 2344, 78, 47025000, 0, 16, 0, 0x1481), - new HousePlacementEntry(typeof(CastleOfOceania), 1158760, 4076, 2038, 4688, 2344, 78, 48971250, 0, 16, 0, 0x1482), - new HousePlacementEntry(typeof(FeudalCastle), 1158762, 4076, 2038, 4688, 2344, 78, 27337500, 0, 16, 0, 0x1483), - new HousePlacementEntry(typeof(RobinsNest), 1158850, 2625, 1312, 3019, 1509, 52, 25301250, 0, 11, 0, 0x1484), - new HousePlacementEntry(typeof(TraditionalKeep), 1158851, 2625, 1312, 3019, 1509, 52, 26685000, 0, 11, 0, 0x1485), - new HousePlacementEntry(typeof(VillaCrowley), 1158852, 2625, 1312, 3019, 1509, 52, 21813750, 0, 11, 0, 0x1486), - new HousePlacementEntry(typeof(DarkthornKeep), 1158853, 2625, 1312, 3019, 1509, 52, 27990000, 0, 11, 0, 0x1487), - new HousePlacementEntry(typeof(SandalwoodKeep), 1158854, 2625, 1312, 3019, 1509, 52, 23456250, 0, 11, 0, 0x1488), - new HousePlacementEntry(typeof(CasaMoga), 1158855, 2625, 1312, 3019, 1509, 52, 26313750, 0, 11, 0, 0x1489), + new HousePlacementEntry(typeof(TrinsicKeep), 1158748, 2625, 1312, 3019, 1509, 52, 29643750, 0, 11, 0, 0x147E), + new HousePlacementEntry(typeof(GothicRoseCastle), 1158749, 4076, 2038, 4688, 2344, 78, 44808750, 0, 16, 0, 0x147F), + new HousePlacementEntry(typeof(ElsaCastle), 1158750, 4076, 2038, 4688, 2344, 78, 45450000, 0, 16, 0, 0x1480), + new HousePlacementEntry(typeof(Spires), 1158761, 4076, 2038, 4688, 2344, 78, 47025000, 0, 16, 0, 0x1481), + new HousePlacementEntry(typeof(CastleOfOceania), 1158760, 4076, 2038, 4688, 2344, 78, 48971250, 0, 16, 0, 0x1482), + new HousePlacementEntry(typeof(FeudalCastle), 1158762, 4076, 2038, 4688, 2344, 78, 27337500, 0, 16, 0, 0x1483), + new HousePlacementEntry(typeof(RobinsNest), 1158850, 2625, 1312, 3019, 1509, 52, 25301250, 0, 11, 0, 0x1484), + new HousePlacementEntry(typeof(TraditionalKeep), 1158851, 2625, 1312, 3019, 1509, 52, 26685000, 0, 11, 0, 0x1485), + new HousePlacementEntry(typeof(VillaCrowley), 1158852, 2625, 1312, 3019, 1509, 52, 21813750, 0, 11, 0, 0x1486), + new HousePlacementEntry(typeof(DarkthornKeep), 1158853, 2625, 1312, 3019, 1509, 52, 27990000, 0, 11, 0, 0x1487), + new HousePlacementEntry(typeof(SandalwoodKeep), 1158854, 2625, 1312, 3019, 1509, 52, 23456250, 0, 11, 0, 0x1488), + new HousePlacementEntry(typeof(CasaMoga), 1158855, 2625, 1312, 3019, 1509, 52, 26313750, 0, 11, 0, 0x1489), - new HousePlacementEntry(typeof(RobinsRoost), 1158960, 4076, 2038, 4688, 2344, 78, 43863750, 0, 16, 0, 0x148A), - new HousePlacementEntry(typeof(Camelot), 1158961, 4076, 2038, 4688, 2344, 78, 47092500, 0, 16, 0, 0x148B), - new HousePlacementEntry(typeof(LacrimaeInCaelo), 1158962, 4076, 2038, 4688, 2344, 78, 45315000, 0, 16, 0, 0x148C), - new HousePlacementEntry(typeof(OkinawaSweetDreamCastle), 1158963, 4076, 2038, 4688, 2344, 78, 40128750, 0, 16, 0, 0x148D), - new HousePlacementEntry(typeof(TheSandstoneCastle), 1158964, 4076, 2038, 4688, 2344, 78, 48690000, 0, 16, 0, 0x148E), + new HousePlacementEntry(typeof(RobinsRoost), 1158960, 4076, 2038, 4688, 2344, 78, 43863750, 0, 16, 0, 0x148A), + new HousePlacementEntry(typeof(Camelot), 1158961, 4076, 2038, 4688, 2344, 78, 47092500, 0, 16, 0, 0x148B), + new HousePlacementEntry(typeof(LacrimaeInCaelo), 1158962, 4076, 2038, 4688, 2344, 78, 45315000, 0, 16, 0, 0x148C), + new HousePlacementEntry(typeof(OkinawaSweetDreamCastle), 1158963, 4076, 2038, 4688, 2344, 78, 40128750, 0, 16, 0, 0x148D), + new HousePlacementEntry(typeof(TheSandstoneCastle), 1158964, 4076, 2038, 4688, 2344, 78, 48690000, 0, 16, 0, 0x148E), new HousePlacementEntry(typeof(GrimswindSisters), 1158965, 4076, 2038, 4688, 2344, 78, 42142500, 0, 16, 0, 0x148F) }; - public static HousePlacementEntry[] TwoStoryFoundations { get; } = { new HousePlacementEntry(typeof(HouseFoundation), 1060241, 425, 212, 489, 244, 10, 30500, 0, 4, 0, @@ -485,7 +484,6 @@ namespace Server.Items 0x143A) // 13x13 2-Story Customizable House }; - public static HousePlacementEntry[] ThreeStoryFoundations { get; } = { new HousePlacementEntry(typeof(HouseFoundation), 1060272, 1150, 575, 1323, 661, 24, 73500, 0, 8, 0, @@ -648,94 +646,94 @@ namespace Server.Items prevHouse.Delete(); - //Point3D center = new Point3D( p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z ); + // Point3D center = new Point3D( p.X - m_Offset.X, p.Y - m_Offset.Y, p.Z - m_Offset.Z ); HousePlacementResult res = HousePlacement.Check(from, MultiID, center, out List toMove); switch (res) { case HousePlacementResult.Valid: - { - if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from)) { - from.SendLocalizedMessage(501271); // You already own a house, you may not place another! - } - else - { - BaseHouse house = ConstructHouse(from); - - if (house == null) - return; - - house.Price = Cost; - - if (from.AccessLevel >= AccessLevel.GameMaster) + if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from)) { - from.SendMessage("{0} gold would have been withdrawn from your bank if you were not a GM.", - Cost.ToString()); + from.SendLocalizedMessage(501271); // You already own a house, you may not place another! } else { - if (Banker.Withdraw(from, Cost)) + BaseHouse house = ConstructHouse(from); + + if (house == null) + return; + + house.Price = Cost; + + if (from.AccessLevel >= AccessLevel.GameMaster) { - from.SendLocalizedMessage(1060398, - Cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + from.SendMessage("{0} gold would have been withdrawn from your bank if you were not a GM.", + Cost.ToString()); } else { - house.RemoveKeys(from); - house.Delete(); - from.SendLocalizedMessage( - 1060646); // You do not have the funds available in your bank box to purchase this house. Try placing a smaller house, or adding gold or checks to your bank box. - return; + if (Banker.Withdraw(from, Cost)) + { + from.SendLocalizedMessage(1060398, + Cost.ToString()); // ~1_AMOUNT~ gold has been withdrawn from your bank box. + } + else + { + house.RemoveKeys(from); + house.Delete(); + from.SendLocalizedMessage( + 1060646); // You do not have the funds available in your bank box to purchase this house. Try placing a smaller house, or adding gold or checks to your bank box. + return; + } + } + + house.MoveToWorld(center, from.Map); + + for (int i = 0; i < toMove.Count; ++i) + { + object o = toMove[i]; + + if (o is Mobile mobile) + mobile.Location = house.BanLocation; + else if (o is Item item) + item.Location = house.BanLocation; } } - house.MoveToWorld(center, from.Map); - - for (int i = 0; i < toMove.Count; ++i) - { - object o = toMove[i]; - - if (o is Mobile mobile) - mobile.Location = house.BanLocation; - else if (o is Item item) - item.Location = house.BanLocation; - } + break; } - - break; - } case HousePlacementResult.BadItem: case HousePlacementResult.BadLand: case HousePlacementResult.BadStatic: case HousePlacementResult.BadRegionHidden: case HousePlacementResult.NoSurface: - { - from.SendLocalizedMessage( - 1043287); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. - break; - } + { + from.SendLocalizedMessage( + 1043287); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + break; + } case HousePlacementResult.BadRegion: - { - from.SendLocalizedMessage(501265); // Housing cannot be created in this area. - break; - } + { + from.SendLocalizedMessage(501265); // Housing cannot be created in this area. + break; + } case HousePlacementResult.BadRegionTemp: - { - from.SendLocalizedMessage( - 501270); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. - break; - } + { + from.SendLocalizedMessage( + 501270); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + break; + } case HousePlacementResult.BadRegionRaffle: - { - from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. - break; - } + { + from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. + break; + } case HousePlacementResult.InvalidCastleKeep: - { - from.SendLocalizedMessage(1061122); // Castles and keeps cannot be created here. - break; - } + { + from.SendLocalizedMessage(1061122); // Castles and keeps cannot be created here. + break; + } } } @@ -750,96 +748,96 @@ namespace Server.Items switch (res) { case HousePlacementResult.Valid: - { - if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from)) { - from.SendLocalizedMessage(501271); // You already own a house, you may not place another! - } - else - { - from.SendLocalizedMessage(1011576); // This is a valid location. - - PreviewHouse prev = new PreviewHouse(MultiID); - - MultiComponentList mcl = prev.Components; - - Point3D banLoc = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Max.Y + 1, center.Z); - - for (int i = 0; i < mcl.List.Length; ++i) + if (from.AccessLevel < AccessLevel.GameMaster && BaseHouse.HasAccountHouse(from)) { - MultiTileEntry entry = mcl.List[i]; + from.SendLocalizedMessage(501271); // You already own a house, you may not place another! + } + else + { + from.SendLocalizedMessage(1011576); // This is a valid location. - int itemID = entry.m_ItemID; + PreviewHouse prev = new PreviewHouse(MultiID); - if (itemID >= 0xBA3 && itemID <= 0xC0E) + MultiComponentList mcl = prev.Components; + + Point3D banLoc = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Max.Y + 1, center.Z); + + for (int i = 0; i < mcl.List.Length; ++i) { - banLoc = new Point3D(center.X + entry.m_OffsetX, center.Y + entry.m_OffsetY, center.Z); - break; + MultiTileEntry entry = mcl.List[i]; + + int itemID = entry.ItemId; + + if (itemID >= 0xBA3 && itemID <= 0xC0E) + { + banLoc = new Point3D(center.X + entry.OffsetX, center.Y + entry.OffsetY, center.Z); + break; + } } + + for (int i = 0; i < toMove.Count; ++i) + { + object o = toMove[i]; + + if (o is Mobile mobile) + mobile.Location = banLoc; + else if (o is Item item) + item.Location = banLoc; + } + + prev.MoveToWorld(center, from.Map); + + /* You are about to place a new house. + * Placing this house will condemn any and all of your other houses that you may have. + * All of your houses on all shards will be affected. + * + * In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week. + * + * Once you accept these terms, these effects cannot be reversed. + * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one week timer be removed. + * + * If you are absolutely certain you wish to proceed, click the button next to OKAY below. + * If you do not wish to trade for this house, click CANCEL. + */ + from.SendGump(new WarningGump(1060635, 30720, 1049583, 32512, 420, 280, okay => PlacementWarning_Callback(from, okay, prev))); + + return true; } - for (int i = 0; i < toMove.Count; ++i) - { - object o = toMove[i]; - - if (o is Mobile mobile) - mobile.Location = banLoc; - else if (o is Item item) - item.Location = banLoc; - } - - prev.MoveToWorld(center, from.Map); - - /* You are about to place a new house. - * Placing this house will condemn any and all of your other houses that you may have. - * All of your houses on all shards will be affected. - * - * In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week. - * - * Once you accept these terms, these effects cannot be reversed. - * Re-deeding or transferring your new house will not uncondemn your other house(s) nor will the one week timer be removed. - * - * If you are absolutely certain you wish to proceed, click the button next to OKAY below. - * If you do not wish to trade for this house, click CANCEL. - */ - from.SendGump(new WarningGump(1060635, 30720, 1049583, 32512, 420, 280, okay => PlacementWarning_Callback(from, okay, prev))); - - return true; + break; } - - break; - } case HousePlacementResult.BadItem: case HousePlacementResult.BadLand: case HousePlacementResult.BadStatic: case HousePlacementResult.BadRegionHidden: case HousePlacementResult.NoSurface: - { - from.SendLocalizedMessage( - 1043287); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. - break; - } + { + from.SendLocalizedMessage( + 1043287); // The house could not be created here. Either something is blocking the house, or the house would not be on valid terrain. + break; + } case HousePlacementResult.BadRegion: - { - from.SendLocalizedMessage(501265); // Housing cannot be created in this area. - break; - } + { + from.SendLocalizedMessage(501265); // Housing cannot be created in this area. + break; + } case HousePlacementResult.BadRegionTemp: - { - from.SendLocalizedMessage( - 501270); //Lord British has decreed a 'no build' period, thus you cannot build this house at this time. - break; - } + { + from.SendLocalizedMessage( + 501270); // Lord British has decreed a 'no build' period, thus you cannot build this house at this time. + break; + } case HousePlacementResult.BadRegionRaffle: - { - from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. - break; - } + { + from.SendLocalizedMessage(1150493); // You must have a deed for this plot of land in order to build here. + break; + } case HousePlacementResult.InvalidCastleKeep: - { - from.SendLocalizedMessage(1061122); // Castles and keeps cannot be created here. - break; - } + { + from.SendLocalizedMessage(1061122); // Castles and keeps cannot be created here. + break; + } } return false; diff --git a/Projects/Scripts/Multis/HouseSign.cs b/Projects/Scripts/Multis/HouseSign.cs index 1649f04b9..5661be363 100644 --- a/Projects/Scripts/Multis/HouseSign.cs +++ b/Projects/Scripts/Multis/HouseSign.cs @@ -18,7 +18,7 @@ namespace Server.Multis { } - public BaseHouse Owner{ get; private set; } + public BaseHouse Owner { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public bool RestrictDecay @@ -32,11 +32,11 @@ namespace Server.Multis } [CommandProperty(AccessLevel.GameMaster)] - public Mobile OriginalOwner{ get; private set; } + public Mobile OriginalOwner { get; private set; } public override bool ForceShowProperties => ObjectPropertyList.Enabled; - public bool GettingProperties{ get; private set; } + public bool GettingProperties { get; private set; } public string GetName() => Name ?? "An Unnamed House"; @@ -109,13 +109,9 @@ namespace Server.Multis { if (Owner.IsFriend(m) && m.AccessLevel < AccessLevel.GameMaster) { - #region Mondain's Legacy - - if (Core.ML && Owner.IsOwner(m) || !Core.ML) + if ((Core.ML && Owner.IsOwner(m)) || !Core.ML) Owner.RefreshDecay(); - #endregion - if (!Core.AOS) m.SendLocalizedMessage(501293); // Welcome back to the house, friend! } @@ -131,7 +127,7 @@ namespace Server.Multis { if (okay && Owner != null && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending) { - bool canClaim = Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from) || Owner.IsFriend(from); + bool canClaim = (Owner.CoOwners?.Count > 0 && Owner.IsCoOwner(from)) || Owner.IsFriend(from); if (canClaim && !BaseHouse.HasAccountHouse(from)) { @@ -151,7 +147,7 @@ namespace Server.Multis if (m.AccessLevel < AccessLevel.GameMaster && Owner.Owner == null && Owner.DecayLevel != DecayLevel.DemolitionPending) { - bool canClaim = Owner?.CoOwners.Count > 0 && Owner.IsCoOwner(m) || Owner.IsFriend(m); + bool canClaim = (Owner?.CoOwners.Count > 0 && Owner.IsCoOwner(m)) || Owner.IsFriend(m); if (canClaim && !BaseHouse.HasAccountHouse(m)) m.SendGump(new WarningGump(501036, 32512, 1049719, 32512, 420, 280, okay => ClaimGump_Callback(m, okay))); @@ -193,12 +189,12 @@ namespace Server.Multis switch (version) { case 0: - { - Owner = reader.ReadItem() as BaseHouse; - OriginalOwner = reader.ReadMobile(); + { + Owner = reader.ReadItem() as BaseHouse; + OriginalOwner = reader.ReadMobile(); - break; - } + break; + } } if (Name == "a house sign") @@ -207,7 +203,7 @@ namespace Server.Multis private class VendorsEntry : ContextMenuEntry { - private HouseSign m_Sign; + private readonly HouseSign m_Sign; public VendorsEntry(HouseSign sign) : base(6211) => m_Sign = sign; @@ -228,7 +224,7 @@ namespace Server.Multis private class ReclaimVendorInventoryEntry : ContextMenuEntry { - private HouseSign m_Sign; + private readonly HouseSign m_Sign; public ReclaimVendorInventoryEntry(HouseSign sign) : base(6213) => m_Sign = sign; diff --git a/Projects/Scripts/Multis/HouseTeleporter.cs b/Projects/Scripts/Multis/HouseTeleporter.cs index ff0c2ab0c..39d9d94fc 100644 --- a/Projects/Scripts/Multis/HouseTeleporter.cs +++ b/Projects/Scripts/Multis/HouseTeleporter.cs @@ -23,16 +23,16 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public Item Target{ get; set; } + public Item Target { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public SecureLevel Level{ get; set; } + public SecureLevel Level { get; set; } public bool CheckAccess(Mobile m) { BaseHouse house = BaseHouse.FindHouseAt(this); - return (house == null || house.Public && !house.IsBanned(m) || house.HasAccess(m)) && + return (house == null || (house.Public && !house.IsBanned(m)) || house.HasAccess(m)) && house?.HasSecureAccess(m, Level) == true; } @@ -82,28 +82,28 @@ namespace Server.Items switch (version) { case 1: - { - Level = (SecureLevel)reader.ReadInt(); - goto case 0; - } + { + Level = (SecureLevel)reader.ReadInt(); + goto case 0; + } case 0: - { - Target = reader.ReadItem(); + { + Target = reader.ReadItem(); - if (version < 0) - Level = SecureLevel.Anyone; + if (version < 0) + Level = SecureLevel.Anyone; - break; - } + break; + } } } private class EffectTimer : Timer { - private int m_EffectID; - private Point3D m_Location; - private Map m_Map; - private int m_SoundID; + private readonly int m_EffectID; + private readonly Point3D m_Location; + private readonly Map m_Map; + private readonly int m_SoundID; public EffectTimer(Point3D p, Map map, int effectID, int soundID, TimeSpan delay) : base(delay) { @@ -125,8 +125,8 @@ namespace Server.Items private class DelayTimer : Timer { - private Mobile m_Mobile; - private HouseTeleporter m_Teleporter; + private readonly Mobile m_Mobile; + private readonly HouseTeleporter m_Teleporter; public DelayTimer(HouseTeleporter tp, Mobile m) : base(TimeSpan.FromSeconds(1.0)) { diff --git a/Projects/Scripts/Multis/Houses.cs b/Projects/Scripts/Multis/Houses.cs index 66b737ad2..b1582b112 100644 --- a/Projects/Scripts/Multis/Houses.cs +++ b/Projects/Scripts/Multis/Houses.cs @@ -44,7 +44,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -88,7 +88,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -137,7 +137,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -185,7 +185,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -195,7 +195,7 @@ namespace Server.Multis } } - public class Keep : BaseHouse //warning: ODD shape! + public class Keep : BaseHouse // warning: ODD shape! { public static Rectangle2D[] AreaArray = { @@ -227,7 +227,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -268,7 +268,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -312,7 +312,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -352,7 +352,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -391,7 +391,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -432,7 +432,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -472,7 +472,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -514,7 +514,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) @@ -543,7 +543,7 @@ namespace Server.Multis AddDoor(door, -2, 0, id == 0xA2 ? 24 : 27); - //AddSouthDoor( false, -2, 0, 27 - (id == 0xA2 ? 3 : 0), keyValue ); + // AddSouthDoor( false, -2, 0, 27 - (id == 0xA2 ? 3 : 0), keyValue ); SetSign(3, 4, 7 - (id == 0xA2 ? 2 : 0)); } @@ -572,7 +572,7 @@ namespace Server.Multis public override void Serialize(IGenericWriter writer) { base.Serialize(writer); - writer.Write(0); //version + writer.Write(0); // version } public override void Deserialize(IGenericReader reader) diff --git a/Projects/Scripts/Multis/MovingCrate.cs b/Projects/Scripts/Multis/MovingCrate.cs index 13f8cebfd..9d85597aa 100644 --- a/Projects/Scripts/Multis/MovingCrate.cs +++ b/Projects/Scripts/Multis/MovingCrate.cs @@ -29,7 +29,7 @@ namespace Server.Multis public override int LabelNumber => 1061690; // Packing Crate - public BaseHouse House{ get; set; } + public BaseHouse House { get; set; } public override int DefaultMaxItems => 0; public override int DefaultMaxWeight => 0; @@ -41,7 +41,7 @@ namespace Server.Multis { base.AddNameProperties( list ); - if ( House != null && House.InternalizedVendors.Count > 0 ) + if (House != null && House.InternalizedVendors.Count > 0) list.Add( 1061833, House.InternalizedVendors.Count.ToString() ); // This packing crate contains ~1_COUNT~ vendors/barkeepers. } */ @@ -116,14 +116,14 @@ namespace Server.Multis } for (int i = 0; i < Rows; i++) - for (int j = 0; j < Columns; j++) - if (!positions[i, j]) - { - int x = Bounds.X + j * HorizontalSpacing; - int y = Bounds.Y + i * VerticalSpacing; + for (int j = 0; j < Columns; j++) + if (!positions[i, j]) + { + int x = Bounds.X + j * HorizontalSpacing; + int y = Bounds.Y + i * VerticalSpacing; - return new Point3D(x, y, 0); - } + return new Point3D(x, y, 0); + } return Point3D.Zero; } @@ -230,7 +230,7 @@ namespace Server.Multis public class InternalizeTimer : Timer { - private MovingCrate m_Crate; + private readonly MovingCrate m_Crate; public InternalizeTimer(MovingCrate crate) : base(TimeSpan.FromMinutes(5.0)) { diff --git a/Projects/Scripts/Multis/PreviewHouse.cs b/Projects/Scripts/Multis/PreviewHouse.cs index 8c38b89ab..c93635118 100644 --- a/Projects/Scripts/Multis/PreviewHouse.cs +++ b/Projects/Scripts/Multis/PreviewHouse.cs @@ -19,11 +19,11 @@ namespace Server.Multis { MultiTileEntry entry = mcl.List[i]; - if (entry.m_Flags == 0) + if (entry.Flags == 0) { - Item item = new Static((int)entry.m_ItemID); + Item item = new Static((int)entry.ItemId); - item.MoveToWorld(new Point3D(X + entry.m_OffsetX, Y + entry.m_OffsetY, Z + entry.m_OffsetZ), Map); + item.MoveToWorld(new Point3D(X + entry.OffsetX, Y + entry.OffsetY, Z + entry.OffsetZ), Map); m_Components.Add(item); } @@ -113,11 +113,11 @@ namespace Server.Multis switch (version) { case 0: - { - m_Components = reader.ReadStrongItemList(); + { + m_Components = reader.ReadStrongItemList(); - break; - } + break; + } } Timer.DelayCall(TimeSpan.Zero, Delete); @@ -125,7 +125,7 @@ namespace Server.Multis private class DecayTimer : Timer { - private Item m_Item; + private readonly Item m_Item; public DecayTimer(Item item) : base(TimeSpan.FromSeconds(20.0)) { diff --git a/Projects/Scripts/Regions/BaseRegion.cs b/Projects/Scripts/Regions/BaseRegion.cs index 75b5a4303..9b09f07d4 100644 --- a/Projects/Scripts/Regions/BaseRegion.cs +++ b/Projects/Scripts/Regions/BaseRegion.cs @@ -16,11 +16,11 @@ namespace Server.Regions public class BaseRegion : Region { - private static List m_RectBuffer1 = new List(); - private static List m_RectBuffer2 = new List(); + private static readonly List m_RectBuffer1 = new List(); + private static readonly List m_RectBuffer2 = new List(); - private static List m_SpawnBuffer1 = new List(); - private static List m_SpawnBuffer2 = new List(); + private static readonly List m_SpawnBuffer1 = new List(); + private static readonly List m_SpawnBuffer2 = new List(); private bool m_ExcludeFromParentSpawns; private Rectangle3D[] m_Rectangles; @@ -55,7 +55,6 @@ namespace Server.Regions ReadBoolean(xml["logoutDelay"], "active", ref logoutDelayActive, false); NoLogoutDelay = !logoutDelayActive; - XmlElement spawning = xml["spawning"]; if (spawning != null) { @@ -65,7 +64,6 @@ namespace Server.Regions ReadEnum(spawning, "zLevel", ref zLevel, false); SpawnZLevel = zLevel; - List list = new List(); foreach (XmlNode node in spawning.ChildNodes) @@ -121,7 +119,7 @@ namespace Server.Regions set => m_RuneName = value; } - public bool NoLogoutDelay{ get; set; } + public bool NoLogoutDelay { get; set; } public SpawnEntry[] Spawns { @@ -136,7 +134,7 @@ namespace Server.Regions } } - public SpawnZLevel SpawnZLevel{ get; set; } + public SpawnZLevel SpawnZLevel { get; set; } public bool ExcludeFromParentSpawns { @@ -395,7 +393,6 @@ namespace Server.Regions } } - Sector sector = map.GetSector(x, y); for (int j = 0; j < sector.Items.Count; j++) @@ -425,7 +422,6 @@ namespace Server.Regions } } - if (m_SpawnBuffer1.Count == 0) { m_SpawnBuffer1.Clear(); @@ -437,45 +433,44 @@ namespace Server.Regions switch (SpawnZLevel) { case SpawnZLevel.Lowest: - { - z = int.MaxValue; - - for (int j = 0; j < m_SpawnBuffer1.Count; j++) { - int l = m_SpawnBuffer1[j]; + z = int.MaxValue; - if (l < z) - z = l; + for (int j = 0; j < m_SpawnBuffer1.Count; j++) + { + int l = m_SpawnBuffer1[j]; + + if (l < z) + z = l; + } + + break; } - - break; - } case SpawnZLevel.Highest: - { - z = int.MinValue; - - for (int j = 0; j < m_SpawnBuffer1.Count; j++) { - int l = m_SpawnBuffer1[j]; + z = int.MinValue; - if (l > z) - z = l; + for (int j = 0; j < m_SpawnBuffer1.Count; j++) + { + int l = m_SpawnBuffer1[j]; + + if (l > z) + z = l; + } + + break; } - - break; - } default: // SpawnZLevel.Random - { - int index = Utility.Random(m_SpawnBuffer1.Count); - z = m_SpawnBuffer1[index]; + { + int index = Utility.Random(m_SpawnBuffer1.Count); + z = m_SpawnBuffer1[index]; - break; - } + break; + } } m_SpawnBuffer1.Clear(); - if (!Find(new Point3D(x, y, z), map).AcceptsSpawnsFrom(this)) { m_SpawnBuffer2.Clear(); diff --git a/Projects/Scripts/Regions/DungeonRegion.cs b/Projects/Scripts/Regions/DungeonRegion.cs index 9cc8fc508..d364fa1a9 100644 --- a/Projects/Scripts/Regions/DungeonRegion.cs +++ b/Projects/Scripts/Regions/DungeonRegion.cs @@ -25,7 +25,7 @@ namespace Server.Regions set => m_EntranceLocation = value; } - public Map EntranceMap{ get; set; } + public Map EntranceMap { get; set; } public override bool AllowHousing(Mobile from, Point3D p) => false; diff --git a/Projects/Scripts/Regions/GuardedRegion.cs b/Projects/Scripts/Regions/GuardedRegion.cs index d4e781f6d..73efad56e 100644 --- a/Projects/Scripts/Regions/GuardedRegion.cs +++ b/Projects/Scripts/Regions/GuardedRegion.cs @@ -9,10 +9,10 @@ namespace Server.Regions { public class GuardedRegion : BaseRegion { - private static object[] m_GuardParams = new object[1]; + private static readonly object[] m_GuardParams = new object[1]; - private Dictionary m_GuardCandidates = new Dictionary(); - private Type m_GuardType; + private readonly Dictionary m_GuardCandidates = new Dictionary(); + private readonly Type m_GuardType; public GuardedRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area) => m_GuardType = DefaultGuardType; @@ -42,7 +42,7 @@ namespace Server.Regions Disabled = disabled; } - public bool Disabled{ get; set; } + public bool Disabled { get; set; } public virtual bool AllowReds => Core.AOS; @@ -298,7 +298,7 @@ namespace Server.Regions foreach (Mobile m in eable) if (IsGuardCandidate(m) && - (!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this) || m_GuardCandidates.ContainsKey(m))) + ((!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this)) || m_GuardCandidates.ContainsKey(m))) { if (m_GuardCandidates.TryGetValue(m, out GuardTimer timer)) { @@ -317,16 +317,16 @@ namespace Server.Regions public bool IsGuardCandidate(Mobile m) { if (m is BaseGuard || !m.Alive || m.AccessLevel > AccessLevel.Player || m.Blessed || - m is BaseCreature creature && creature.IsInvulnerable || IsDisabled()) + (m is BaseCreature creature && creature.IsInvulnerable) || IsDisabled()) return false; - return !AllowReds && m.Kills >= 5 || m.Criminal; + return (!AllowReds && m.Kills >= 5) || m.Criminal; } private class GuardTimer : Timer { - private Mobile m_Mobile; - private Dictionary m_Table; + private readonly Mobile m_Mobile; + private readonly Dictionary m_Table; public GuardTimer(Mobile m, Dictionary table) : base(TimeSpan.FromSeconds(15.0)) { diff --git a/Projects/Scripts/Regions/HouseRegion.cs b/Projects/Scripts/Regions/HouseRegion.cs index 9413238f5..750bd7b6f 100644 --- a/Projects/Scripts/Regions/HouseRegion.cs +++ b/Projects/Scripts/Regions/HouseRegion.cs @@ -23,7 +23,7 @@ namespace Server.Regions GoLocation = new Point3D(house.X + ban.X, house.Y + ban.Y, house.Z + ban.Z); } - public BaseHouse House{ get; } + public BaseHouse House { get; } public static void Initialize() { diff --git a/Projects/Scripts/Regions/NoHousingRegion.cs b/Projects/Scripts/Regions/NoHousingRegion.cs index 4a009645b..a3ef2d18b 100644 --- a/Projects/Scripts/Regions/NoHousingRegion.cs +++ b/Projects/Scripts/Regions/NoHousingRegion.cs @@ -7,7 +7,7 @@ namespace Server.Regions /* - False: this uses 'stupid OSI' house placement checking: part of the house may be placed here provided that the center is not in the region * - True: this uses 'smart RunUO' house placement checking: no part of the house may be in the region */ - private bool m_SmartChecking; + private readonly bool m_SmartChecking; public NoHousingRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent) { diff --git a/Projects/Scripts/Regions/Spawning/SpawnDefinition.cs b/Projects/Scripts/Regions/Spawning/SpawnDefinition.cs index 8cd6081c4..ebba5073d 100644 --- a/Projects/Scripts/Regions/Spawning/SpawnDefinition.cs +++ b/Projects/Scripts/Regions/Spawning/SpawnDefinition.cs @@ -19,46 +19,46 @@ namespace Server.Regions switch (xml.Name) { case "object": - { - Type type = null; - if (!Region.ReadType(xml, "type", ref type)) - return null; - - if (typeof(Mobile).IsAssignableFrom(type)) return SpawnMobile.Get(type); - - if (typeof(Item).IsAssignableFrom(type)) return SpawnItem.Get(type); - Console.WriteLine("Invalid type '{0}' in a SpawnDefinition", type.FullName); - return null; - } - case "group": - { - string group = null; - if (!Region.ReadString(xml, "name", ref group)) - return null; - - if (!SpawnGroup.Table.TryGetValue(group, out SpawnGroup def)) { - Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group); + Type type = null; + if (!Region.ReadType(xml, "type", ref type)) + return null; + + if (typeof(Mobile).IsAssignableFrom(type)) return SpawnMobile.Get(type); + + if (typeof(Item).IsAssignableFrom(type)) return SpawnItem.Get(type); + Console.WriteLine("Invalid type '{0}' in a SpawnDefinition", type.FullName); return null; } + case "group": + { + string group = null; + if (!Region.ReadString(xml, "name", ref group)) + return null; - return def; - } + if (!SpawnGroup.Table.TryGetValue(group, out SpawnGroup def)) + { + Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group); + return null; + } + + return def; + } case "treasureChest": - { - int itemID = 0xE43; - Region.ReadInt32(xml, "itemID", ref itemID, false); + { + int itemID = 0xE43; + Region.ReadInt32(xml, "itemID", ref itemID, false); - BaseTreasureChest.TreasureLevel level = BaseTreasureChest.TreasureLevel.Level2; + BaseTreasureChest.TreasureLevel level = BaseTreasureChest.TreasureLevel.Level2; - Region.ReadEnum(xml, "level", ref level, false); + Region.ReadEnum(xml, "level", ref level, false); - return new SpawnTreasureChest(itemID, level); - } + return new SpawnTreasureChest(itemID, level); + } default: - { - return null; - } + { + return null; + } } } } @@ -73,11 +73,11 @@ namespace Server.Regions m_Init = false; } - public Type Type{ get; } + public Type Type { get; } - public abstract int Height{ get; } - public abstract bool Land{ get; } - public abstract bool Water{ get; } + public abstract int Height { get; } + public abstract bool Land { get; } + public abstract bool Water { get; } protected void EnsureInit() { @@ -119,7 +119,7 @@ namespace Server.Regions public class SpawnMobile : SpawnType { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); private bool m_Land; private bool m_Water; @@ -192,7 +192,7 @@ namespace Server.Regions public class SpawnItem : SpawnType { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); protected int m_Height; @@ -251,9 +251,9 @@ namespace Server.Regions Level = level; } - public int ItemID{ get; } + public int ItemID { get; } - public BaseTreasureChest.TreasureLevel Level{ get; } + public BaseTreasureChest.TreasureLevel Level { get; } protected override void Init() { @@ -271,14 +271,14 @@ namespace Server.Regions Weight = weight; } - public SpawnDefinition SpawnDefinition{ get; } + public SpawnDefinition SpawnDefinition { get; } - public int Weight{ get; } + public int Weight { get; } } public class SpawnGroup : SpawnDefinition { - private int m_TotalWeight; + private readonly int m_TotalWeight; static SpawnGroup() { @@ -337,11 +337,11 @@ namespace Server.Regions m_TotalWeight += elements[i].Weight; } - public static Dictionary Table{ get; } = new Dictionary(); + public static Dictionary Table { get; } = new Dictionary(); - public string Name{ get; } + public string Name { get; } - public SpawnGroupElement[] Elements{ get; } + public SpawnGroupElement[] Elements { get; } public static void Register(SpawnGroup group) { diff --git a/Projects/Scripts/Regions/Spawning/SpawnEntry.cs b/Projects/Scripts/Regions/Spawning/SpawnEntry.cs index 3c9499f03..253509d14 100644 --- a/Projects/Scripts/Regions/Spawning/SpawnEntry.cs +++ b/Projects/Scripts/Regions/Spawning/SpawnEntry.cs @@ -9,7 +9,6 @@ namespace Server.Regions public static readonly TimeSpan DefaultMinSpawnTime = TimeSpan.FromMinutes(2.0); public static readonly TimeSpan DefaultMaxSpawnTime = TimeSpan.FromMinutes(5.0); - public static readonly Direction InvalidDirection = Direction.Running; private static List m_RemoveList; @@ -38,8 +37,7 @@ namespace Server.Regions Table[id] = this; } - public static Dictionary Table{ get; } = new Dictionary(); - + public static Dictionary Table { get; } = new Dictionary(); // When a creature's AI is deactivated (PlayerRangeSensitive optimization) does it return home? public bool ReturnOnDeactivate => true; @@ -47,23 +45,23 @@ namespace Server.Regions // Are unlinked and untamed creatures removed after 20 hours? public bool RemoveIfUntamed => true; - public int ID{ get; } + public int ID { get; } - public BaseRegion Region{ get; } + public BaseRegion Region { get; } - public Direction Direction{ get; } + public Direction Direction { get; } - public SpawnDefinition Definition{ get; } + public SpawnDefinition Definition { get; } - public List SpawnedObjects{ get; } + public List SpawnedObjects { get; } - public int Max{ get; private set; } + public int Max { get; private set; } - public TimeSpan MinSpawnTime{ get; } + public TimeSpan MinSpawnTime { get; } - public TimeSpan MaxSpawnTime{ get; } + public TimeSpan MaxSpawnTime { get; } - public bool Running{ get; private set; } + public bool Running { get; private set; } public bool Complete => SpawnedObjects.Count >= Max; public bool Spawning => Running && !Complete; @@ -72,9 +70,9 @@ namespace Server.Regions public bool UnlinkOnTaming => false; Region ISpawner.Region => Region; - public Point3D HomeLocation{ get; } + public Point3D HomeLocation { get; } - public int HomeRange{ get; } + public int HomeRange { get; } void ISpawner.Remove(ISpawnable spawn) { diff --git a/Projects/Scripts/Scripts.csproj b/Projects/Scripts/Scripts.csproj index bc6751c31..114419f4f 100644 --- a/Projects/Scripts/Scripts.csproj +++ b/Projects/Scripts/Scripts.csproj @@ -14,17 +14,42 @@ true x64 8.0 - ..\..\Distribution\Assemblies - ..\..\Distribution\Assemblies - ..\..\Distribution\Assemblies + $(SolutionDir)\Distribution\Assemblies + $(SolutionDir)\Distribution\Assemblies + $(SolutionDir)\Distribution\Assemblies true + Debug;Release;Analyze + + + + + + + + + + + + + + + + + + + + + TRACE;DEBUG + false true - - TRACE;DEBUG - false + + true + true + true + $(SolutionDir)\Rules.ruleset @@ -40,4 +65,13 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Projects/Scripts/Skills/Anatomy.cs b/Projects/Scripts/Skills/Anatomy.cs index e4ab479a5..8f5980032 100644 --- a/Projects/Scripts/Skills/Anatomy.cs +++ b/Projects/Scripts/Skills/Anatomy.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Anatomy + public static class Anatomy { public static void Initialize() { @@ -88,4 +88,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/AnimalLore.cs b/Projects/Scripts/Skills/AnimalLore.cs index 08a45b97b..40d59a20e 100644 --- a/Projects/Scripts/Skills/AnimalLore.cs +++ b/Projects/Scripts/Skills/AnimalLore.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class AnimalLore + public static class AnimalLore { public static void Initialize() { @@ -102,9 +102,6 @@ namespace Server.SkillHandlers int pages = Core.AOS ? 5 : 3; int page = 0; - - #region Attributes - AddPage(++page); AddImage(128, 152, 2086); @@ -163,10 +160,6 @@ namespace Server.SkillHandlers AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1); AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, pages); - #endregion - - #region Resistances - if (Core.AOS) { AddPage(++page); @@ -193,10 +186,6 @@ namespace Server.SkillHandlers AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1); } - #endregion - - #region Damage - if (Core.AOS) { AddPage(++page); @@ -219,24 +208,16 @@ namespace Server.SkillHandlers AddHtmlLocalized(153, 240, 160, 18, 1061650, LabelColor); // Energy AddHtml(320, 240, 35, 18, FormatElement(c.EnergyDamage)); - #region Mondain's Legacy - if (Core.ML) { AddHtmlLocalized(153, 258, 160, 18, 1076750, LabelColor); // Base Damage AddHtml(300, 258, 55, 18, FormatDamage(c.DamageMin, c.DamageMax)); } - #endregion - AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1); AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1); } - #endregion - - #region Skills - AddPage(++page); AddImage(128, 152, 2086); @@ -254,8 +235,6 @@ namespace Server.SkillHandlers AddHtmlLocalized(153, 222, 160, 18, 1044061, LabelColor); // Anatomy AddHtml(320, 222, 35, 18, FormatSkill(c, SkillName.Anatomy)); - #region Mondain's Legacy - if (c is CuSidhe) { AddHtmlLocalized(153, 240, 160, 18, 1044077, LabelColor); // Healing @@ -267,8 +246,6 @@ namespace Server.SkillHandlers AddHtml(320, 240, 35, 18, FormatSkill(c, SkillName.Poisoning)); } - #endregion - AddImage(128, 260, 2086); AddHtmlLocalized(147, 258, 160, 18, 3001032, 200); // Lore & Knowledge @@ -284,10 +261,6 @@ namespace Server.SkillHandlers AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, page + 1); AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1); - #endregion - - #region Misc - AddPage(++page); AddImage(128, 152, 2086); @@ -343,8 +316,6 @@ namespace Server.SkillHandlers AddButton(340, 358, 5601, 5605, 0, GumpButtonType.Page, 1); AddButton(317, 358, 5603, 5607, 0, GumpButtonType.Page, page - 1); - - #endregion } private static string FormatSkill(BaseCreature c, SkillName name) @@ -389,8 +360,6 @@ namespace Server.SkillHandlers return $"
{val}%
"; } - #region Mondain's Legacy - private static string FormatDamage(int min, int max) { if (min <= 0 || max <= 0) @@ -398,7 +367,5 @@ namespace Server.SkillHandlers return $"
{min}-{max}
"; } - - #endregion } } diff --git a/Projects/Scripts/Skills/AnimalTaming.cs b/Projects/Scripts/Skills/AnimalTaming.cs index a24a80936..1c8f652fd 100644 --- a/Projects/Scripts/Skills/AnimalTaming.cs +++ b/Projects/Scripts/Skills/AnimalTaming.cs @@ -10,11 +10,11 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class AnimalTaming + public static class AnimalTaming { - private static HashSet m_BeingTamed = new HashSet(); + private static readonly HashSet m_BeingTamed = new HashSet(); - public static bool DisableMessage{ get; set; } + public static bool DisableMessage { get; set; } public static void Initialize() { @@ -191,7 +191,7 @@ namespace Server.SkillHandlers creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502802, from.NetState); // Someone else is already taming this. } - else if (creature.CanAngerOnTame && 0.95 >= Utility.RandomDouble()) + else if (creature.CanAngerOnTame && Utility.RandomDouble() <= 0.95) { creature.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 502805, from.NetState); // You seem to anger the beast! @@ -230,11 +230,11 @@ namespace Server.SkillHandlers private class InternalTimer : Timer { private int m_Count; - private BaseCreature m_Creature; - private int m_MaxCount; + private readonly BaseCreature m_Creature; + private readonly int m_MaxCount; private bool m_Paralyzed; - private DateTime m_StartTime; - private Mobile m_Tamer; + private readonly DateTime m_StartTime; + private readonly Mobile m_Tamer; public InternalTimer(Mobile tamer, BaseCreature creature, int count) : base(TimeSpan.FromSeconds(3.0), TimeSpan.FromSeconds(3.0), count) diff --git a/Projects/Scripts/Skills/ArmsLore.cs b/Projects/Scripts/Skills/ArmsLore.cs index 2800ecd08..bf205c9a4 100644 --- a/Projects/Scripts/Skills/ArmsLore.cs +++ b/Projects/Scripts/Skills/ArmsLore.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class ArmsLore + public static class ArmsLore { public static void Initialize() { @@ -53,15 +53,15 @@ namespace Server.SkillHandlers else damage = (int)Math.Ceiling(Math.Min(damage, 30) / 5.0); /* - else if ( damage < 6 ) + else if (damage < 6) damage = 1; - else if ( damage < 11 ) + else if (damage < 11) damage = 2; - else if ( damage < 16 ) + else if (damage < 16) damage = 3; - else if ( damage < 21 ) + else if (damage < 21) damage = 4; - else if ( damage < 26 ) + else if (damage < 26) damage = 5; else damage = 6; @@ -104,22 +104,21 @@ namespace Server.SkillHandlers from.SendLocalizedMessage(1038285 + hp); } - from.SendLocalizedMessage(1038295 + (int)Math.Ceiling(Math.Min(arm.ArmorRating, 35) / 5.0)); /* - if ( arm.ArmorRating < 1 ) + if (arm.ArmorRating < 1) from.SendLocalizedMessage( 1038295 ); // This armor offers no defense against attackers. - else if ( arm.ArmorRating < 6 ) + else if (arm.ArmorRating < 6) from.SendLocalizedMessage( 1038296 ); // This armor provides almost no protection. - else if ( arm.ArmorRating < 11 ) + else if (arm.ArmorRating < 11) from.SendLocalizedMessage( 1038297 ); // This armor provides very little protection. - else if ( arm.ArmorRating < 16 ) + else if (arm.ArmorRating < 16) from.SendLocalizedMessage( 1038298 ); // This armor offers some protection against blows. - else if ( arm.ArmorRating < 21 ) + else if (arm.ArmorRating < 21) from.SendLocalizedMessage( 1038299 ); // This armor serves as sturdy protection. - else if ( arm.ArmorRating < 26 ) + else if (arm.ArmorRating < 26) from.SendLocalizedMessage( 1038300 ); // This armor is a superior defense against attack. - else if ( arm.ArmorRating < 31 ) + else if (arm.ArmorRating < 31) from.SendLocalizedMessage( 1038301 ); // This armor offers excellent protection. else from.SendLocalizedMessage( 1038302 ); // This armor is superbly crafted to provide maximum protection. @@ -155,4 +154,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/Begging.cs b/Projects/Scripts/Skills/Begging.cs index a0c75d075..9209a01c9 100644 --- a/Projects/Scripts/Skills/Begging.cs +++ b/Projects/Scripts/Skills/Begging.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Begging + public static class Begging { public static void Initialize() { @@ -62,8 +62,7 @@ namespace Server.SkillHandlers else number = 500402; // You are too far away to beg from her. } - else if (!Core.ML && from.Mounted - ) // If we're on a mount, who would give us money? TODO: guessed it's removed since ML + else if (!Core.ML && from.Mounted) // If we're on a mount, who would give us money? TODO: guessed it's removed since ML { number = 500404; // They seem unwilling to give you any money. } @@ -91,7 +90,8 @@ namespace Server.SkillHandlers private class InternalTimer : Timer { - private Mobile m_From, m_Target; + private readonly Mobile m_From; + private readonly Mobile m_Target; public InternalTimer(Mobile from, Mobile target) : base(TimeSpan.FromSeconds(2.0)) { @@ -174,4 +174,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/DetectHidden.cs b/Projects/Scripts/Skills/DetectHidden.cs index 844b37818..f04b55d76 100644 --- a/Projects/Scripts/Skills/DetectHidden.cs +++ b/Projects/Scripts/Skills/DetectHidden.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class DetectHidden + public static class DetectHidden { public static void Initialize() { @@ -15,7 +15,7 @@ namespace Server.SkillHandlers public static TimeSpan OnUse(Mobile src) { - src.SendLocalizedMessage(500819); //Where will you search? + src.SendLocalizedMessage(500819); // Where will you search? src.Target = new InternalTarget(); return TimeSpan.FromSeconds(6.0); @@ -64,7 +64,7 @@ namespace Server.SkillHandlers double ss = srcSkill + Utility.Random(21) - 10; double ts = trg.Skills.Hiding.Value + Utility.Random(21) - 10; - if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || inHouse && house.IsInside(trg))) + if (src.AccessLevel >= trg.AccessLevel && (ss >= ts || (inHouse && house.IsInside(trg)))) { if (trg is ShadowKnight && (trg.X != p.X || trg.Y != p.Y)) continue; diff --git a/Projects/Scripts/Skills/Discordance.cs b/Projects/Scripts/Skills/Discordance.cs index 25ea05e79..623ef7c17 100644 --- a/Projects/Scripts/Skills/Discordance.cs +++ b/Projects/Scripts/Skills/Discordance.cs @@ -6,9 +6,9 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Discordance + public static class Discordance { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public static void Initialize() { @@ -88,12 +88,12 @@ namespace Server.SkillHandlers private class DiscordanceInfo { - public Mobile m_Creature; - public int m_Effect; + public readonly Mobile m_Creature; + public readonly int m_Effect; public bool m_Ending; public DateTime m_EndTime; - public Mobile m_From; - public List m_Mods; + public readonly Mobile m_From; + public readonly List m_Mods; public Timer m_Timer; public DiscordanceInfo(Mobile from, Mobile creature, int effect, List mods) @@ -141,7 +141,7 @@ namespace Server.SkillHandlers public class DiscordanceTarget : Target { - private BaseInstrument m_Instrument; + private readonly BaseInstrument m_Instrument; public DiscordanceTarget(Mobile from, BaseInstrument inst) : base( BaseInstrument.GetBardRange(from, SkillName.Discordance), false, TargetFlags.None) => @@ -159,13 +159,13 @@ namespace Server.SkillHandlers } else if (target is Mobile targ) { - if (targ == from || targ is BaseCreature bc && + if (targ == from || (targ is BaseCreature bc && (bc.BardImmune || !from.CanBeHarmful(bc, false)) && - bc.ControlMaster != from) + bc.ControlMaster != from)) { from.SendLocalizedMessage(1049535); // A song of discord would have no effect on that. } - else if (m_Table.ContainsKey(targ)) //Already discorded + else if (m_Table.ContainsKey(targ)) // Already discorded { from.SendLocalizedMessage(1049537); // Your target is already in discord. } diff --git a/Projects/Scripts/Skills/EvalInt.cs b/Projects/Scripts/Skills/EvalInt.cs index 60524153f..a375f619d 100644 --- a/Projects/Scripts/Skills/EvalInt.cs +++ b/Projects/Scripts/Skills/EvalInt.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class EvalInt + public static class EvalInt { public static void Initialize() { @@ -90,4 +90,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/ForensicEval.cs b/Projects/Scripts/Skills/ForensicEval.cs index 476ace831..f557ff938 100644 --- a/Projects/Scripts/Skills/ForensicEval.cs +++ b/Projects/Scripts/Skills/ForensicEval.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class ForensicEvaluation + public static class ForensicEvaluation { public static void Initialize() { @@ -36,13 +36,13 @@ namespace Server.SkillHandlers if (from.CheckTargetSkill(SkillName.Forensics, target, 40.0, 100.0)) { if (target is PlayerMobile pm && pm.NpcGuild == NpcGuild.ThievesGuild) - from.SendLocalizedMessage(501004); //That individual is a thief! + from.SendLocalizedMessage(501004); // That individual is a thief! else - from.SendLocalizedMessage(501003); //You notice nothing unusual. + from.SendLocalizedMessage(501003); // You notice nothing unusual. } else { - from.SendLocalizedMessage(501001); //You cannot determain anything useful. + from.SendLocalizedMessage(501001); // You cannot determain anything useful. } } else if (target is Corpse c) @@ -57,7 +57,7 @@ namespace Server.SkillHandlers if (((Body)c.Amount).IsHuman) from.SendLocalizedMessage(1042751, - c.Killer == null ? "no one" : c.Killer.Name); //This person was killed by ~1_KILLER_NAME~ + c.Killer == null ? "no one" : c.Killer.Name); // This person was killed by ~1_KILLER_NAME~ if (c.Looters.Count > 0) { @@ -70,26 +70,26 @@ namespace Server.SkillHandlers } from.SendLocalizedMessage(1042752, - sb.ToString()); //This body has been distrubed by ~1_PLAYER_NAMES~ + sb.ToString()); // This body has been distrubed by ~1_PLAYER_NAMES~ } else { - from.SendLocalizedMessage(501002); //The corpse has not be desecrated. + from.SendLocalizedMessage(501002); // The corpse has not be desecrated. } } else { - from.SendLocalizedMessage(501001); //You cannot determain anything useful. + from.SendLocalizedMessage(501001); // You cannot determain anything useful. } } else if (target is ILockpickable p) { if (p.Picker != null) - from.SendLocalizedMessage(1042749, p.Picker.Name); //This lock was opened by ~1_PICKER_NAME~ + from.SendLocalizedMessage(1042749, p.Picker.Name); // This lock was opened by ~1_PICKER_NAME~ else - from.SendLocalizedMessage(501003); //You notice nothing unusual. + from.SendLocalizedMessage(501003); // You notice nothing unusual. } } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/Hiding.cs b/Projects/Scripts/Skills/Hiding.cs index dde7e5e9a..20c251eba 100644 --- a/Projects/Scripts/Skills/Hiding.cs +++ b/Projects/Scripts/Skills/Hiding.cs @@ -6,9 +6,9 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Hiding + public static class Hiding { - public static bool CombatOverride{ get; set; } + public static bool CombatOverride { get; set; } public static void Initialize() { @@ -42,9 +42,9 @@ namespace Server.SkillHandlers bonus = 50.0; } - //int range = 18 - (int)(m.Skills.Hiding.Value / 10); + // int range = 18 - (int)(m.Skills.Hiding.Value / 10); int range = Math.Min((int)((100 - m.Skills.Hiding.Value) / 2) + 8, - 18); //Cap of 18 not OSI-exact, intentional difference + 18); // Cap of 18 not OSI-exact, intentional difference bool badCombat = !CombatOverride && m.Combatant != null && m.InRange(m.Combatant.Location, range) && m.Combatant.InLOS(m); diff --git a/Projects/Scripts/Skills/Inscribe.cs b/Projects/Scripts/Skills/Inscribe.cs index cbd877a32..103b2007f 100644 --- a/Projects/Scripts/Skills/Inscribe.cs +++ b/Projects/Scripts/Skills/Inscribe.cs @@ -6,9 +6,9 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Inscribe + public static class Inscribe { - private static Dictionary m_UseTable = new Dictionary(); + private static readonly Dictionary m_UseTable = new Dictionary(); public static void Initialize() { @@ -106,7 +106,7 @@ namespace Server.SkillHandlers private class InternalTargetDst : Target { - private BaseBook m_BookSrc; + private readonly BaseBook m_BookSrc; public InternalTargetDst(BaseBook bookSrc) : base(3, false, TargetFlags.None) => m_BookSrc = bookSrc; diff --git a/Projects/Scripts/Skills/ItemIdentification.cs b/Projects/Scripts/Skills/ItemIdentification.cs index e3a168a19..0800708d4 100644 --- a/Projects/Scripts/Skills/ItemIdentification.cs +++ b/Projects/Scripts/Skills/ItemIdentification.cs @@ -4,7 +4,7 @@ using Server.Targeting; namespace Server.Items { - public class ItemIdentification + public static class ItemIdentification { public static void Initialize() { @@ -54,4 +54,4 @@ namespace Server.Items } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/Meditation.cs b/Projects/Scripts/Skills/Meditation.cs index 212f046a1..4871abffa 100644 --- a/Projects/Scripts/Skills/Meditation.cs +++ b/Projects/Scripts/Skills/Meditation.cs @@ -4,7 +4,7 @@ using Server.Misc; namespace Server.SkillHandlers { - internal class Meditation + internal static class Meditation { public static void Initialize() { @@ -100,4 +100,4 @@ namespace Server.SkillHandlers return TimeSpan.FromSeconds(10.0); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/Peacemaking.cs b/Projects/Scripts/Skills/Peacemaking.cs index 7396a0202..13dcba302 100644 --- a/Projects/Scripts/Skills/Peacemaking.cs +++ b/Projects/Scripts/Skills/Peacemaking.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Peacemaking + public static class Peacemaking { public static void Initialize() { @@ -32,7 +32,7 @@ namespace Server.SkillHandlers private class InternalTarget : Target { - private BaseInstrument m_Instrument; + private readonly BaseInstrument m_Instrument; private bool m_SetSkillTime = true; public InternalTarget(Mobile from, BaseInstrument instrument) : base( @@ -176,7 +176,7 @@ namespace Server.SkillHandlers from.NextSkillTime = Core.TickCount + 5000; targ.Combatant = null; targ.Warmode = false; - + if (bc != null) { from.SendLocalizedMessage(1049532); // You play hypnotic music, calming your target. @@ -204,4 +204,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/Poisoning.cs b/Projects/Scripts/Skills/Poisoning.cs index c83e5b066..57e37c8e2 100644 --- a/Projects/Scripts/Skills/Poisoning.cs +++ b/Projects/Scripts/Skills/Poisoning.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Poisoning + public static class Poisoning { public static void Initialize() { @@ -43,7 +43,7 @@ namespace Server.SkillHandlers private class InternalTarget : Target { - private BasePoisonPotion m_Potion; + private readonly BasePoisonPotion m_Potion; public InternalTarget(BasePoisonPotion potion) : base(2, false, TargetFlags.None) => m_Potion = potion; @@ -92,10 +92,11 @@ namespace Server.SkillHandlers private class InternalTimer : Timer { - private Mobile m_From; - private double m_MinSkill, m_MaxSkill; - private Poison m_Poison; - private Item m_Target; + private readonly Mobile m_From; + private readonly double m_MinSkill; + private readonly double m_MaxSkill; + private readonly Poison m_Poison; + private readonly Item m_Target; public InternalTimer(Mobile from, Item target, BasePoisonPotion potion) : base(TimeSpan.FromSeconds(2.0)) { diff --git a/Projects/Scripts/Skills/Provocation.cs b/Projects/Scripts/Skills/Provocation.cs index 0d2652e61..23eb3740d 100644 --- a/Projects/Scripts/Skills/Provocation.cs +++ b/Projects/Scripts/Skills/Provocation.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Provocation + public static class Provocation { public static void Initialize() { @@ -30,7 +30,7 @@ namespace Server.SkillHandlers private class InternalFirstTarget : Target { - private BaseInstrument m_Instrument; + private readonly BaseInstrument m_Instrument; public InternalFirstTarget(Mobile from, BaseInstrument instrument) : base( BaseInstrument.GetBardRange(from, SkillName.Provocation), false, TargetFlags.None) => @@ -73,8 +73,8 @@ namespace Server.SkillHandlers private class InternalSecondTarget : Target { - private BaseCreature m_Creature; - private BaseInstrument m_Instrument; + private readonly BaseCreature m_Creature; + private readonly BaseInstrument m_Instrument; public InternalSecondTarget(Mobile from, BaseInstrument instrument, BaseCreature creature) : base( BaseInstrument.GetBardRange(from, SkillName.Provocation), false, TargetFlags.None) @@ -130,8 +130,8 @@ namespace Server.SkillHandlers } else { - //from.DoHarmful( m_Creature ); - //from.DoHarmful( creature ); + // from.DoHarmful( m_Creature ); + // from.DoHarmful( creature ); if (!from.CheckTargetSkill(SkillName.Provocation, creature, diff - 25.0, diff + 25.0)) { @@ -162,4 +162,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/RemoveTrap.cs b/Projects/Scripts/Skills/RemoveTrap.cs index 92e236214..f3b112fc3 100644 --- a/Projects/Scripts/Skills/RemoveTrap.cs +++ b/Projects/Scripts/Skills/RemoveTrap.cs @@ -6,7 +6,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class RemoveTrap + public static class RemoveTrap { public static void Initialize() { @@ -92,8 +92,8 @@ namespace Server.SkillHandlers } else { - if (Core.ML && isOwner || from.CheckTargetSkill(SkillName.RemoveTrap, trap, 80.0, 100.0) && - from.CheckTargetSkill(SkillName.Tinkering, trap, 80.0, 100.0)) + if ((Core.ML && isOwner) || (from.CheckTargetSkill(SkillName.RemoveTrap, trap, 80.0, 100.0) && + from.CheckTargetSkill(SkillName.Tinkering, trap, 80.0, 100.0))) { from.PrivateOverheadMessage(MessageType.Regular, trap.MessageHue, trap.DisarmMessage, from.NetState); diff --git a/Projects/Scripts/Skills/Snooping.cs b/Projects/Scripts/Skills/Snooping.cs index f245ecad5..b748d6ed9 100644 --- a/Projects/Scripts/Skills/Snooping.cs +++ b/Projects/Scripts/Skills/Snooping.cs @@ -6,7 +6,7 @@ using Server.Regions; namespace Server.SkillHandlers { - public class Snooping + public static class Snooping { public static void Configure() { @@ -28,7 +28,7 @@ namespace Server.SkillHandlers if (reg?.IsDisabled() != true) return true; // not in town? we can snoop any npc - return !to.Body.IsHuman || to is BaseCreature cret && (cret.AlwaysAttackable || cret.AlwaysMurderer); + return !to.Body.IsHuman || (to is BaseCreature cret && (cret.AlwaysAttackable || cret.AlwaysMurderer)); } public static void Container_Snoop(Container cont, Mobile from) diff --git a/Projects/Scripts/Skills/SpiritSpeak.cs b/Projects/Scripts/Skills/SpiritSpeak.cs index 9f94e5c60..4ad8011a4 100644 --- a/Projects/Scripts/Skills/SpiritSpeak.cs +++ b/Projects/Scripts/Skills/SpiritSpeak.cs @@ -6,7 +6,7 @@ using Server.Spells; namespace Server.SkillHandlers { - internal class SpiritSpeak + public static class SpiritSpeak { public static void Initialize() { @@ -39,17 +39,17 @@ namespace Server.SkillHandlers if (secs < 15) secs = 15; - t.Delay = TimeSpan.FromSeconds(secs); //15seconds to 3 minutes + t.Delay = TimeSpan.FromSeconds(secs); // 15seconds to 3 minutes t.Start(); m.CanHearGhosts = true; } m.PlaySound(0x24A); - m.SendLocalizedMessage(502444); //You contact the neitherworld. + m.SendLocalizedMessage(502444); // You contact the neitherworld. } else { - m.SendLocalizedMessage(502443); //You fail to contact the neitherworld. + m.SendLocalizedMessage(502443); // You fail to contact the neitherworld. m.CanHearGhosts = false; } @@ -58,7 +58,7 @@ namespace Server.SkillHandlers private class SpiritSpeakTimer : Timer { - private Mobile m_Owner; + private readonly Mobile m_Owner; public SpiritSpeakTimer(Mobile m) : base(TimeSpan.FromMinutes(2.0)) { @@ -69,13 +69,13 @@ namespace Server.SkillHandlers protected override void OnTick() { m_Owner.CanHearGhosts = false; - m_Owner.SendLocalizedMessage(502445); //You feel your contact with the neitherworld fading. + m_Owner.SendLocalizedMessage(502445); // You feel your contact with the neitherworld fading. } } private class SpiritSpeakSpell : Spell { - private static SpellInfo m_Info = new SpellInfo("Spirit Speak", "", 269); + private static readonly SpellInfo m_Info = new SpellInfo("Spirit Speak", "", 269); public SpiritSpeakSpell(Mobile caster) : base(caster, null, m_Info) { diff --git a/Projects/Scripts/Skills/Stealing.cs b/Projects/Scripts/Skills/Stealing.cs index 05094fc81..5d7deca77 100644 --- a/Projects/Scripts/Skills/Stealing.cs +++ b/Projects/Scripts/Skills/Stealing.cs @@ -13,7 +13,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class Stealing + public static class Stealing { public static readonly bool ClassicMode = false; public static readonly bool SuspendOnMurder = false; @@ -61,7 +61,7 @@ namespace Server.SkillHandlers private class StealingTarget : Target { - private Mobile m_Thief; + private readonly Mobile m_Thief; public StealingTarget(Mobile thief) : base(1, false, TargetFlags.None) { @@ -113,9 +113,6 @@ namespace Server.SkillHandlers { m_Thief.SendLocalizedMessage(1048147); // Your backpack can't hold anything else. } - - #region Sigils - else if (toSteal is Sigil sig) { PlayerState pl = PlayerState.Find(m_Thief); @@ -133,15 +130,15 @@ namespace Server.SkillHandlers { if (!m_Thief.CanBeginAction()) { - m_Thief.SendLocalizedMessage(1010581); // You cannot steal the sigil when you are incognito + m_Thief.SendLocalizedMessage(1010581); // You cannot steal the sigil when you are incognito } else if (DisguiseTimers.IsDisguised(m_Thief)) { - m_Thief.SendLocalizedMessage(1010583); // You cannot steal the sigil while disguised + m_Thief.SendLocalizedMessage(1010583); // You cannot steal the sigil while disguised } else if (!m_Thief.CanBeginAction()) { - m_Thief.SendLocalizedMessage(1010582); // You cannot steal the sigil while polymorphed + m_Thief.SendLocalizedMessage(1010582); // You cannot steal the sigil while polymorphed } else if (TransformationSpellHelper.UnderTransformation(m_Thief)) { @@ -158,7 +155,7 @@ namespace Server.SkillHandlers } else if (sig.IsBeingCorrupted && sig.LastMonolith.Faction == faction) { - m_Thief.SendLocalizedMessage(1005590); // You cannot steal your own sigil + m_Thief.SendLocalizedMessage(1005590); // You cannot steal your own sigil } else if (sig.IsPurifying) { @@ -169,12 +166,12 @@ namespace Server.SkillHandlers if (Sigil.ExistsOn(m_Thief)) { m_Thief.SendLocalizedMessage( - 1010258); // The sigil has gone back to its home location because you already have a sigil. + 1010258); // The sigil has gone back to its home location because you already have a sigil. } else if (m_Thief?.Backpack.CheckHold(m_Thief, sig, false, true) != true) { m_Thief.SendLocalizedMessage( - 1010259); // The sigil has gone home because your backpack is full + 1010259); // The sigil has gone home because your backpack is full } else { @@ -194,17 +191,14 @@ namespace Server.SkillHandlers } else { - m_Thief.SendLocalizedMessage(1005594); // You do not have enough skill to steal the sigil + m_Thief.SendLocalizedMessage(1005594); // You do not have enough skill to steal the sigil } } else { - m_Thief.SendLocalizedMessage(1005588); // You must join a faction to do that + m_Thief.SendLocalizedMessage(1005588); // You must join a faction to do that } } - - #endregion - else if (si == null && (toSteal.Parent == null || !toSteal.Movable)) { m_Thief.SendLocalizedMessage(502710); // You can't steal that! @@ -395,7 +389,7 @@ namespace Server.SkillHandlers { public static readonly TimeSpan StealTime = TimeSpan.FromMinutes(2.0); - private static Queue m_Queue = new Queue(); + private static readonly Queue m_Queue = new Queue(); public StolenItem(Item stolen, Mobile thief, Mobile victim) { @@ -406,13 +400,13 @@ namespace Server.SkillHandlers Expires = DateTime.UtcNow + StealTime; } - public Item Stolen{ get; } + public Item Stolen { get; } - public Mobile Thief{ get; } + public Mobile Thief { get; } - public Mobile Victim{ get; } + public Mobile Victim { get; } - public DateTime Expires{ get; private set; } + public DateTime Expires { get; private set; } public bool IsExpired => DateTime.UtcNow >= Expires; diff --git a/Projects/Scripts/Skills/Stealth.cs b/Projects/Scripts/Skills/Stealth.cs index 0fc551acc..30a0f9ebb 100644 --- a/Projects/Scripts/Skills/Stealth.cs +++ b/Projects/Scripts/Skills/Stealth.cs @@ -4,24 +4,27 @@ using Server.Mobiles; namespace Server.SkillHandlers { + // Stealth cannot be static because its used as a generic for CanBeginAction. +#pragma warning disable CA1052 // Static holder types should be Static or NotInheritable public class Stealth { public static double HidingRequirement => Core.ML ? 30.0 : Core.SE ? 50.0 : 80.0; - public static int[,] ArmorTable{ get; } = + // TODO: Move to configuration + public static int[,] ArmorTable { get; } = { - // Gorget Gloves Helmet Arms Legs Chest Shield - /* Cloth */ { 0, 0, 0, 0, 0, 0, 0 }, - /* Leather */ { 0, 0, 0, 0, 0, 0, 0 }, - /* Studded */ { 2, 2, 0, 4, 6, 10, 0 }, - /* Bone */ { 0, 5, 10, 10, 15, 25, 0 }, - /* Spined */ { 0, 0, 0, 0, 0, 0, 0 }, - /* Horned */ { 0, 0, 0, 0, 0, 0, 0 }, - /* Barbed */ { 0, 0, 0, 0, 0, 0, 0 }, - /* Ring */ { 0, 5, 0, 10, 15, 25, 0 }, - /* Chain */ { 0, 0, 10, 0, 15, 25, 0 }, - /* Plate */ { 5, 5, 10, 10, 15, 25, 0 }, - /* Dragon */ { 0, 5, 10, 10, 15, 25, 0 } + // Gorget Glove Helmet Arms Legs Chest Shield + /* Cloth */ { 0, 0, 0, 0, 0, 0, 0 }, + /* Leather */ { 0, 0, 0, 0, 0, 0, 0 }, + /* Studded */ { 2, 2, 0, 4, 6, 10, 0 }, + /* Bone */ { 0, 5, 10, 10, 15, 25, 0 }, + /* Spined */ { 0, 0, 0, 0, 0, 0, 0 }, + /* Horned */ { 0, 0, 0, 0, 0, 0, 0 }, + /* Barbed */ { 0, 0, 0, 0, 0, 0, 0 }, + /* Ring */ { 0, 5, 0, 10, 15, 25, 0 }, + /* Chain */ { 0, 0, 10, 0, 15, 25, 0 }, + /* Plate */ { 5, 5, 10, 10, 15, 25, 0 }, + /* Dragon */ { 0, 5, 10, 10, 15, 25, 0 } }; public static void Initialize() @@ -74,7 +77,7 @@ namespace Server.SkillHandlers { int armorRating = GetArmorRating(m); - if (armorRating >= (Core.AOS ? 42 : 26)) //I have a hunch '42' was chosen cause someone's a fan of DNA + if (armorRating >= (Core.AOS ? 42 : 26)) // I have a hunch '42' was chosen cause someone's a fan of DNA { m.SendLocalizedMessage(502727); // You could not hope to move quietly wearing this much armor. m.RevealingAction(); @@ -106,4 +109,5 @@ namespace Server.SkillHandlers return TimeSpan.FromSeconds(10.0); } } -} \ No newline at end of file +#pragma warning restore CA1052 // Static holder types should be Static or NotInheritable +} diff --git a/Projects/Scripts/Skills/TasteID.cs b/Projects/Scripts/Skills/TasteID.cs index 70b3d9ad5..f029c6770 100644 --- a/Projects/Scripts/Skills/TasteID.cs +++ b/Projects/Scripts/Skills/TasteID.cs @@ -5,7 +5,7 @@ using Server.Targeting; namespace Server.SkillHandlers { - public class TasteID + public static class TasteID { public static void Initialize() { @@ -77,4 +77,4 @@ namespace Server.SkillHandlers } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Skills/Tracking.cs b/Projects/Scripts/Skills/Tracking.cs index db6f9650f..97776fa24 100644 --- a/Projects/Scripts/Skills/Tracking.cs +++ b/Projects/Scripts/Skills/Tracking.cs @@ -8,9 +8,9 @@ using Server.Spells.Necromancy; namespace Server.SkillHandlers { - public class Tracking + public static class Tracking { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public static void Initialize() { @@ -44,12 +44,11 @@ namespace Server.SkillHandlers double bonus = Math.Sqrt(xDelta * xDelta + yDelta * yDelta); - m_Table.Remove(tracker); //Reset as of Pub 40, counting it as bug for Core.SE. + m_Table.Remove(tracker); // Reset as of Pub 40, counting it as bug for Core.SE. return Core.ML ? Math.Min(bonus, 10 + tracker.Skills.Tracking.Value / 10) : bonus; } - public static void ClearTrackingInfo(Mobile tracker) { m_Table.Remove(tracker); @@ -74,8 +73,8 @@ namespace Server.SkillHandlers public class TrackWhatGump : Gump { - private Mobile m_From; - private bool m_Success; + private readonly Mobile m_From; + private readonly bool m_Success; public TrackWhatGump(Mobile from) : base(20, 30) { @@ -117,7 +116,7 @@ namespace Server.SkillHandlers public class TrackWhoGump : Gump { - private static TrackTypeDelegate[] m_Delegates = + private static readonly TrackTypeDelegate[] m_Delegates = { IsAnimal, IsMonster, @@ -125,10 +124,10 @@ namespace Server.SkillHandlers IsPlayer }; - private Mobile m_From; + private readonly Mobile m_From; - private List m_List; - private int m_Range; + private readonly List m_List; + private readonly int m_Range; private TrackWhoGump(Mobile from, List list, int range) : base(20, 30) { @@ -218,12 +217,11 @@ namespace Server.SkillHandlers if (!Core.AOS || !m.Player) return true; - int tracking = from.Skills.Tracking.Fixed; int detectHidden = from.Skills.DetectHidden.Fixed; if (Core.ML && m.Race == Race.Elf) - tracking /= 2; //The 'Guide' says that it requires twice as Much tracking SKILL to track an elf. Not the total difficulty to track. + tracking /= 2; // The 'Guide' says that it requires twice as Much tracking SKILL to track an elf. Not the total difficulty to track. int hiding = m.Skills.Hiding.Fixed; int stealth = m.Skills.Stealth.Fixed; @@ -278,7 +276,7 @@ namespace Server.SkillHandlers private class InternalSorter : IComparer { - private Mobile m_From; + private readonly Mobile m_From; public InternalSorter(Mobile from) => m_From = from; @@ -299,7 +297,7 @@ namespace Server.SkillHandlers public class TrackArrow : QuestArrow { private Mobile m_From; - private Timer m_Timer; + private readonly Timer m_Timer; public TrackArrow(Mobile from, Mobile target, int range) : base(from, target) { @@ -335,10 +333,11 @@ namespace Server.SkillHandlers public class TrackTimer : Timer { - private QuestArrow m_Arrow; - private Mobile m_From, m_Target; + private readonly QuestArrow m_Arrow; + private readonly Mobile m_From; + private readonly Mobile m_Target; private int m_LastX, m_LastY; - private int m_Range; + private readonly int m_Range; public TrackTimer(Mobile from, Mobile target, int range, QuestArrow arrow) : base(TimeSpan.FromSeconds(0.25), TimeSpan.FromSeconds(2.5)) @@ -359,7 +358,7 @@ namespace Server.SkillHandlers } if (m_From.NetState == null || m_From.Deleted || m_Target.Deleted || m_From.Map != m_Target.Map || - !m_From.InRange(m_Target, m_Range) || m_Target.Hidden && m_Target.AccessLevel > m_From.AccessLevel) + !m_From.InRange(m_Target, m_Range) || (m_Target.Hidden && m_Target.AccessLevel > m_From.AccessLevel)) { m_Arrow.Stop(); Stop(); diff --git a/Projects/Scripts/SpecialSystems/Engines/GiftGiving.cs b/Projects/Scripts/SpecialSystems/Engines/GiftGiving.cs index 483c0b0b0..1c38bc1b4 100644 --- a/Projects/Scripts/SpecialSystems/Engines/GiftGiving.cs +++ b/Projects/Scripts/SpecialSystems/Engines/GiftGiving.cs @@ -12,7 +12,7 @@ namespace Server.Misc public class GiftGiving { - private static List m_Givers = new List(); + private static readonly List m_Givers = new List(); public static void Register(GiftGiver giver) { @@ -55,8 +55,8 @@ namespace Server.Misc { public virtual TimeSpan MinimumAge => TimeSpan.FromDays(30.0); - public abstract DateTime Start{ get; } - public abstract DateTime Finish{ get; } + public abstract DateTime Start { get; } + public abstract DateTime Finish { get; } public abstract void GiveGift(Mobile mob); public virtual void DelayGiveGift(TimeSpan delay, Mobile mob) diff --git a/Projects/Scripts/SpecialSystems/Engines/PreventInaccess.cs b/Projects/Scripts/SpecialSystems/Engines/PreventInaccess.cs index e6477956c..1f063c6fa 100644 --- a/Projects/Scripts/SpecialSystems/Engines/PreventInaccess.cs +++ b/Projects/Scripts/SpecialSystems/Engines/PreventInaccess.cs @@ -73,9 +73,9 @@ namespace Server.Misc Map = map; } - public Point3D Location{ get; } + public Point3D Location { get; } - public Map Map{ get; } + public Map Map { get; } } } } diff --git a/Projects/Scripts/SpecialSystems/Engines/TestCenter.cs b/Projects/Scripts/SpecialSystems/Engines/TestCenter.cs index a925ddaf8..ff002d41d 100644 --- a/Projects/Scripts/SpecialSystems/Engines/TestCenter.cs +++ b/Projects/Scripts/SpecialSystems/Engines/TestCenter.cs @@ -121,7 +121,7 @@ namespace Server.Misc private static void ChangeSkill(Mobile from, string name, double value) { - if (!Enum.TryParse(name, true, out SkillName index) || !Core.SE && (int)index > 51 || !Core.AOS && (int)index > 48) + if (!Enum.TryParse(name, true, out SkillName index) || (!Core.SE && (int)index > 51) || (!Core.AOS && (int)index > 48)) { from.SendLocalizedMessage(1005631); // You have specified an invalid skill to set. return; @@ -152,7 +152,6 @@ namespace Server.Misc } } - public class TCHelpGump : Gump { public TCHelpGump() : base(40, 40) @@ -178,52 +177,52 @@ namespace Server.Misc switch (info.ButtonID) { case 1: // RunUO - { - sender.LaunchBrowser("https://github.com/runuo/"); - break; - } - case 2: // List of skills - { - string[] strings = Enum.GetNames(typeof(SkillName)); - - Array.Sort(strings); - - StringBuilder sb = new StringBuilder(); - - if (strings.Length > 0) - sb.Append(strings[0]); - - for (int i = 1; i < strings.Length; ++i) { - string v = strings[i]; - - if (sb.Length + 1 + v.Length >= 256) - { - sender.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3, - "System", sb.ToString())); - sb = new StringBuilder(); - sb.Append(v); - } - else - { - sb.Append(' '); - sb.Append(v); - } + sender.LaunchBrowser("https://github.com/runuo/"); + break; } + case 2: // List of skills + { + string[] strings = Enum.GetNames(typeof(SkillName)); - if (sb.Length > 0) - sender.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3, "System", - sb.ToString())); + Array.Sort(strings); - break; - } + StringBuilder sb = new StringBuilder(); + + if (strings.Length > 0) + sb.Append(strings[0]); + + for (int i = 1; i < strings.Length; ++i) + { + string v = strings[i]; + + if (sb.Length + 1 + v.Length >= 256) + { + sender.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3, + "System", sb.ToString())); + sb = new StringBuilder(); + sb.Append(v); + } + else + { + sb.Append(' '); + sb.Append(v); + } + } + + if (sb.Length > 0) + sender.Send(new AsciiMessage(Server.Serial.MinusOne, -1, MessageType.Label, 0x35, 3, "System", + sb.ToString())); + + break; + } case 3: // Command list - { - sender.Mobile.SendAsciiMessage(0x482, "The command prefix is \"{0}\"", CommandSystem.Prefix); - CommandHandlers.Help_OnCommand(new CommandEventArgs(sender.Mobile, "help", "", new string[0])); + { + sender.Mobile.SendAsciiMessage(0x482, "The command prefix is \"{0}\"", CommandSystem.Prefix); + CommandHandlers.Help_OnCommand(new CommandEventArgs(sender.Mobile, "help", "", new string[0])); - break; - } + break; + } } } } diff --git a/Projects/Scripts/SpecialSystems/Items/Stones/GMStone.cs b/Projects/Scripts/SpecialSystems/Items/Stones/GMStone.cs deleted file mode 100644 index 4b7023151..000000000 --- a/Projects/Scripts/SpecialSystems/Items/Stones/GMStone.cs +++ /dev/null @@ -1,56 +0,0 @@ -#if false -using System; -using Server.Network; -using Server.Commands; - -namespace Server.Items -{ - public class GMStone : Item - { - public override string DefaultName - { - get { return "a GM stone"; } - } - - [Constructible] - public GMStone() : base( 0xED4 ) - { - Movable = false; - Hue = 0x489; - } - - public GMStone( Serial serial ) : base( serial ) - { - } - - public override void Serialize( GenericWriter writer ) - { - base.Serialize( writer ); - - writer.Write( (int) 0 ); // version - } - - public override void Deserialize( GenericReader reader ) - { - base.Deserialize( reader ); - - int version = reader.ReadInt(); - } - - public override void OnDoubleClick( Mobile from ) - { - if ( from.AccessLevel < AccessLevel.GameMaster ) - { - from.AccessLevel = AccessLevel.GameMaster; - - from.SendAsciiMessage( 0x482, "The command prefix is \"{0}\"", CommandSystem.Prefix ); - CommandHandlers.Help_OnCommand( new CommandEventArgs( from, "help", "", new string[0] ) ); - } - else - { - from.SendMessage( "The stone has no effect." ); - } - } - } -} -#endif \ No newline at end of file diff --git a/Projects/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs b/Projects/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs index c6d3fd4f2..6375150a7 100644 --- a/Projects/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs +++ b/Projects/Scripts/SpecialSystems/Items/Stones/GamblingStone.cs @@ -115,11 +115,11 @@ namespace Server.Items switch (version) { case 0: - { - m_GamblePot = reader.ReadInt(); + { + m_GamblePot = reader.ReadInt(); - break; - } + break; + } } } } diff --git a/Projects/Scripts/Spells/Base/MagerySpell.cs b/Projects/Scripts/Spells/Base/MagerySpell.cs index bd546a641..2a20de195 100644 --- a/Projects/Scripts/Spells/Base/MagerySpell.cs +++ b/Projects/Scripts/Spells/Base/MagerySpell.cs @@ -7,14 +7,14 @@ namespace Server.Spells { private const double ChanceOffset = 20.0, ChanceLength = 100.0 / 7.0; - private static int[] m_ManaTable = { 4, 6, 9, 11, 14, 20, 40, 50 }; + private static readonly int[] m_ManaTable = { 4, 6, 9, 11, 14, 20, 40, 50 }; public MagerySpell(Mobile caster, Item scroll, SpellInfo info) : base(caster, scroll, info) { } - public abstract SpellCircle Circle{ get; } + public abstract SpellCircle Circle { get; } public override TimeSpan CastDelayBase => TimeSpan.FromSeconds((3 + (int)Circle) * CastDelaySecondsPerTick); diff --git a/Projects/Scripts/Spells/Base/SpecialMove.cs b/Projects/Scripts/Spells/Base/SpecialMove.cs index c46f4b88f..731b6d062 100644 --- a/Projects/Scripts/Spells/Base/SpecialMove.cs +++ b/Projects/Scripts/Spells/Base/SpecialMove.cs @@ -11,7 +11,7 @@ namespace Server.Spells { public abstract class SpecialMove { - private static Dictionary m_PlayersTable = new Dictionary(); + private static readonly Dictionary m_PlayersTable = new Dictionary(); public virtual int BaseMana => 0; @@ -23,7 +23,7 @@ namespace Server.Spells public virtual bool BlockedByAnimalForm => true; public virtual bool DelayedContext => false; - public static Dictionary Table{ get; } = new Dictionary(); + public static Dictionary Table { get; } = new Dictionary(); public virtual bool ValidatesDuringHit => true; @@ -145,8 +145,6 @@ namespace Server.Spells return false; } - #region Dueling - string option = null; if (this is Backstab) @@ -169,8 +167,6 @@ namespace Server.Spells if (option != null && !DuelContext.AllowSpecialMove(from, option, this)) return false; - #endregion - return CheckSkills(from) && CheckMana(from, false); } @@ -286,7 +282,7 @@ namespace Server.Spells private class SpecialMoveTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public SpecialMoveTimer(Mobile from) : base(TimeSpan.FromSeconds(3.0)) { @@ -309,9 +305,9 @@ namespace Server.Spells Type = type; } - public Timer Timer{ get; } + public Timer Timer { get; } - public Type Type{ get; } + public Type Type { get; } } } } diff --git a/Projects/Scripts/Spells/Base/Spell.cs b/Projects/Scripts/Spells/Base/Spell.cs index b012411b8..18a658e62 100644 --- a/Projects/Scripts/Spells/Base/Spell.cs +++ b/Projects/Scripts/Spells/Base/Spell.cs @@ -16,15 +16,15 @@ namespace Server.Spells { public abstract class Spell : ISpell { - private static TimeSpan NextSpellDelay = TimeSpan.FromSeconds(0.75); + private static readonly TimeSpan NextSpellDelay = TimeSpan.FromSeconds(0.75); - private static 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 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 Dictionary m_ContextTable = + private static readonly Dictionary m_ContextTable = new Dictionary(); private AnimTimer m_AnimTimer; @@ -38,18 +38,18 @@ namespace Server.Spells Info = info; } - public SpellState State{ get; set; } + public SpellState State { get; set; } - public Mobile Caster{ get; } + public Mobile Caster { get; } - public SpellInfo Info{ get; } + public SpellInfo Info { get; } public string Name => Info.Name; public string Mantra => Info.Mantra; public Type[] Reagents => Info.Reagents; - public Item Scroll{ get; } + public Item Scroll { get; } - public long StartCastTime{ get; private set; } + public long StartCastTime { get; private set; } public virtual SkillName CastSkill => SkillName.Magery; public virtual SkillName DamageSkill => SkillName.EvalInt; @@ -73,7 +73,7 @@ namespace Server.Spells public virtual int CastRecoveryPerSecond => 4; public virtual int CastRecoveryMinimum => 0; - public abstract TimeSpan CastDelayBase{ get; } + public abstract TimeSpan CastDelayBase { get; } public virtual double CastDelayFastScalar => 1; public virtual double CastDelaySecondsPerTick => 0.25; @@ -83,7 +83,7 @@ namespace Server.Spells public virtual void OnCasterHurt() { - //Confirm: Monsters and pets cannot be disturbed. + // Confirm: Monsters and pets cannot be disturbed. if (Caster.Player && IsCasting && ProtectionSpell.Registry.TryGetValue(Caster, out double d) && d <= Utility.RandomDouble() * 100.0) Disturb(DisturbType.Hurt, false, true); @@ -131,7 +131,7 @@ namespace Server.Spells public void StartDelayedDamageContext(Mobile m, Timer t) { if (DelayedDamageStacking) - return; //Sanity + return; // Sanity if (!m_ContextTable.TryGetValue(GetType(), out DelayedDamageContextWrapper contexts)) m_ContextTable[GetType()] = contexts = new DelayedDamageContextWrapper(); @@ -233,17 +233,17 @@ namespace Server.Spells { double scalar = 1.0; - if (!Core.AOS) //EvalInt stuff for AoS is handled elsewhere + if (!Core.AOS) // EvalInt stuff for AoS is handled elsewhere { double casterEI = Caster.Skills[DamageSkill].Value; double targetRS = target.Skills.MagicResist.Value; /* - if ( Core.AOS ) + if (Core.AOS) targetRS = 0; */ - //m_Caster.CheckSkill( DamageSkill, 0.0, 120.0 ); + // m_Caster.CheckSkill( DamageSkill, 0.0, 120.0 ); if (casterEI > targetRS) scalar = 1.0 + (casterEI - targetRS) / 500.0; @@ -266,7 +266,7 @@ namespace Server.Spells target.Region.SpellDamageScalar(Caster, target, ref scalar); - if (Evasion.CheckSpellEvasion(target)) //Only single target spells an be evaded + if (Evasion.CheckSpellEvasion(target)) // Only single target spells an be evaded scalar = 0; return scalar; @@ -284,7 +284,7 @@ namespace Server.Spells if (atkSlayer?.Slays(defender) == true || atkSlayer2?.Slays(defender) == true) { - defender.FixedEffect(0x37B9, 10, 5); //TODO: Confirm this displays on OSIs + defender.FixedEffect(0x37B9, 10, 5); // TODO: Confirm this displays on OSIs scalar = 2.0; } @@ -411,9 +411,9 @@ namespace Server.Spells { Caster.SendLocalizedMessage(502642); // You are already casting a spell. } - else if (BlockedByHorrificBeast && - TransformationSpellHelper.UnderTransformation(Caster, typeof(HorrificBeastSpell)) || - BlockedByAnimalForm && AnimalForm.UnderTransformation(Caster)) + else if ((BlockedByHorrificBeast && + TransformationSpellHelper.UnderTransformation(Caster, typeof(HorrificBeastSpell))) || + (BlockedByAnimalForm && AnimalForm.UnderTransformation(Caster))) { Caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form. } @@ -429,15 +429,9 @@ namespace Server.Spells { mobile.SendLocalizedMessage(1072060); // You cannot cast a spell while calmed. } - - #region Dueling - else if ((Caster as PlayerMobile)?.DuelContext?.AllowSpellCast(Caster, this) == false) { } - - #endregion - else if (Caster.Mana >= ScaleMana(GetMana())) { if (Caster.Spell == null && Caster.CheckSpellCast(this) && CheckCast() && @@ -453,7 +447,7 @@ namespace Server.Spells TimeSpan castDelay = GetCastDelay(); - if (ShowHandMovement && (Caster.Body.IsHuman || Caster.Player && Caster.Body.IsMonster)) + if (ShowHandMovement && (Caster.Body.IsHuman || (Caster.Player && Caster.Body.IsMonster))) { int count = (int)Math.Ceiling(castDelay.TotalSeconds / AnimateDelay.TotalSeconds); @@ -477,7 +471,7 @@ namespace Server.Spells WeaponAbility.ClearCurrentAbility(Caster); m_CastTimer = new CastTimer(this, castDelay); - //m_CastTimer.Start(); + // m_CastTimer.Start(); OnBeginCast(); @@ -507,7 +501,7 @@ namespace Server.Spells public virtual void GetCastSkills(out double min, out double max) { - min = max = 0; //Intended but not required for overriding. + min = max = 0; // Intended but not required for overriding. } public virtual bool CheckFizzle() @@ -574,10 +568,10 @@ 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 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() { @@ -591,7 +585,7 @@ namespace Server.Spells int fcMax = 4; if (CastSkill == SkillName.Magery || CastSkill == SkillName.Necromancy || - CastSkill == SkillName.Chivalry && Caster.Skills.Magery.Value >= 70.0) + (CastSkill == SkillName.Chivalry && Caster.Skills.Magery.Value >= 70.0)) fcMax = 2; int fc = AosAttributes.GetValue(Caster, AosAttribute.CastSpeed); @@ -609,13 +603,13 @@ namespace Server.Spells TimeSpan fcDelay = TimeSpan.FromSeconds(-(CastDelayFastScalar * fc * CastDelaySecondsPerTick)); - //int delay = CastDelayBase + circleDelay + fcDelay; + // int delay = CastDelayBase + circleDelay + fcDelay; TimeSpan delay = baseDelay + fcDelay; if (delay < CastDelayMinimum) delay = CastDelayMinimum; - //return TimeSpan.FromSeconds( (double)delay / CastDelayPerSecond ); + // return TimeSpan.FromSeconds( (double)delay / CastDelayPerSecond ); return delay; } @@ -638,8 +632,8 @@ namespace Server.Spells DoFizzle(); } else if (Scroll != null && !(Scroll is Runebook) && - (Scroll.Amount <= 0 || Scroll.Deleted || Scroll.RootParent != Caster || Scroll is BaseWand baseWand && - (baseWand.Charges <= 0 || baseWand.Parent != Caster))) + (Scroll.Amount <= 0 || Scroll.Deleted || Scroll.RootParent != Caster || (Scroll is BaseWand baseWand && + (baseWand.Charges <= 0 || baseWand.Parent != Caster)))) { DoFizzle(); } @@ -759,7 +753,7 @@ namespace Server.Spells private class DelayedDamageContextWrapper { - private Dictionary m_Contexts = new Dictionary(); + private readonly Dictionary m_Contexts = new Dictionary(); public void Add(Mobile m, Timer t) { @@ -780,7 +774,7 @@ namespace Server.Spells private class AnimTimer : Timer { - private Spell m_Spell; + private readonly Spell m_Spell; public AnimTimer(Spell spell, int count) : base(TimeSpan.Zero, AnimateDelay, count) { @@ -812,7 +806,7 @@ namespace Server.Spells private class CastTimer : Timer { - private Spell m_Spell; + private readonly Spell m_Spell; public CastTimer(Spell spell, TimeSpan castDelay) : base(castDelay) { diff --git a/Projects/Scripts/Spells/Base/SpellHelper.cs b/Projects/Scripts/Spells/Base/SpellHelper.cs index b5e31d6a3..7f8c3fa8d 100644 --- a/Projects/Scripts/Spells/Base/SpellHelper.cs +++ b/Projects/Scripts/Spells/Base/SpellHelper.cs @@ -28,7 +28,7 @@ namespace Server private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m) : base(TimeSpan.FromMinutes(1.0)) @@ -61,13 +61,13 @@ namespace Server.Spells public class SpellHelper { - private static TimeSpan AosDamageDelay = TimeSpan.FromSeconds(1.0); - private static TimeSpan OldDamageDelay = TimeSpan.FromSeconds(0.5); + private static readonly TimeSpan AosDamageDelay = TimeSpan.FromSeconds(1.0); + private static readonly TimeSpan OldDamageDelay = TimeSpan.FromSeconds(0.5); - private static TimeSpan CombatHeatDelay = TimeSpan.FromSeconds(30.0); - private static bool RestrictTravelCombat = true; + private static readonly TimeSpan CombatHeatDelay = TimeSpan.FromSeconds(30.0); + private static readonly bool RestrictTravelCombat = true; - private static int[] m_Offsets = + private static readonly int[] m_Offsets = { -1, -1, -1, 0, @@ -79,7 +79,7 @@ namespace Server.Spells 1, 1 }; - private static TravelValidator[] m_Validators = + private static readonly TravelValidator[] m_Validators = { IsFeluccaT2A, IsKhaldun, @@ -102,10 +102,10 @@ namespace Server.Spells IsMLDungeon }; - // TODO: Find a better way - private static bool[,] m_Rules = + // TODO: Move to configuration + private static readonly bool[,] m_Rules = { - /*T2A(Fel), Khaldun, Ilshenar, Wind(Tram), Wind(Fel), Dungeons(Fel), Solen(Tram), Solen(Fel), CrystalCave(Malas), Gauntlet(Malas), Gauntlet(Ferry), SafeZone, Stronghold, ChampionSpawn, Dungeons(Tokuno[Malas]), LampRoom(Doom), GuardianRoom(Doom), Heartwood, MLDungeons */ + /* T2A(Fel), Khaldun, Ilshenar, Wind(Tram), Wind(Fel), Dungeons(Fel), Solen(Tram), Solen(Fel), CrystalCave(Malas), Gauntlet(Malas), Gauntlet(Ferry), SafeZone, Stronghold, ChampionSpawn, Dungeons(Tokuno[Malas]), LampRoom(Doom), GuardianRoom(Doom), Heartwood, MLDungeons */ /* Recall From */ { false, false, true, true, false, false, true, false, false, false, false, true, true, false, true, false, @@ -146,7 +146,7 @@ namespace Server.Spells private static Mobile m_TravelCaster; private static TravelCheckType m_TravelType; - public static bool DisableSkillCheck{ get; set; } + public static bool DisableSkillCheck { get; set; } public static TimeSpan GetDamageDelayForSpell(Spell sp) { @@ -169,7 +169,7 @@ namespace Server.Spells if (multi is BaseHouse bh) { - if (houses && bh.IsInside(p, 16) || housingrange > 0 && bh.InRange(p, housingrange)) + if ((houses && bh.IsInside(p, 16)) || (housingrange > 0 && bh.InRange(p, housingrange))) return true; } else if (multi.Contains(p)) @@ -405,8 +405,6 @@ namespace Server.Spells BaseCreature bcFrom = from as BaseCreature; BaseCreature bcTarg = to as BaseCreature; - #region Dueling - PlayerMobile pmFrom; PlayerMobile pmTarg; @@ -424,8 +422,6 @@ namespace Server.Spells pmFrom.DuelPlayer != null && pmTarg?.DuelPlayer != null) return pmFrom.DuelPlayer.Participant != pmTarg.DuelPlayer.Participant; - #endregion - Guild fromGuild = GetGuildFor(from); Guild toGuild = GetGuildFor(to); @@ -457,7 +453,7 @@ namespace Server.Spells return false; } - return bcTarg?.Controlled == false && bcTarg.InitialInnocent || + return (bcTarg?.Controlled == false && bcTarg.InitialInnocent) || Notoriety.Compute(from, to) != Notoriety.Innocent || from.Kills >= 5; } @@ -494,7 +490,6 @@ namespace Server.Spells return; } - /* int offset = Utility.Random( 8 ) * 2; @@ -503,7 +498,7 @@ namespace Server.Spells int x = caster.X + m_Offsets[(offset + i) % m_Offsets.Length]; int y = caster.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length]; - if ( map.CanSpawnMobile( x, y, caster.Z ) ) + if (map.CanSpawnMobile( x, y, caster.Z )) { BaseCreature.Summon( creature, caster, new Point3D( x, y, caster.Z ), sound, duration ); return; @@ -512,7 +507,7 @@ namespace Server.Spells { int z = map.GetAverageZ( x, y ); - if ( map.CanSpawnMobile( x, y, z ) ) + if (map.CanSpawnMobile( x, y, z )) { BaseCreature.Summon( creature, caster, new Point3D( x, y, z ), sound, duration ); return; @@ -527,12 +522,12 @@ namespace Server.Spells public static bool FindValidSpawnLocation(Map map, ref Point3D p, bool surroundingsOnly) { - if (map == null) //sanity + if (map == null) // sanity return false; if (!surroundingsOnly) { - if (map.CanSpawnMobile(p)) //p's fine. + if (map.CanSpawnMobile(p)) // p's fine. { p = new Point3D(p); return true; @@ -674,22 +669,19 @@ namespace Server.Spells int x = loc.X, y = loc.Y; - return x >= 1182 && y >= 437 && x < 1211 && y < 470 - || x >= 1156 && y >= 470 && x < 1211 && y < 503 - || x >= 1176 && y >= 503 && x < 1208 && y < 509 - || x >= 1188 && y >= 509 && x < 1201 && y < 513; + return (x >= 1182 && y >= 437 && x < 1211 && y < 470) + || (x >= 1156 && y >= 470 && x < 1211 && y < 503) + || (x >= 1176 && y >= 503 && x < 1208 && y < 509) + || (x >= 1188 && y >= 509 && x < 1201 && y < 513); } public static bool IsSafeZone(Map map, Point3D loc) { - #region Duels if (Region.Find(loc, map).IsPartOf() && (m_TravelType == TravelCheckType.TeleportTo || m_TravelType == TravelCheckType.TeleportFrom) && (m_TravelCaster as PlayerMobile)?.DuelPlayer?.Eliminated == false) return true; - #endregion - return false; } @@ -715,7 +707,7 @@ namespace Server.Spells public static bool IsTokunoDungeon(Map map, Point3D loc) { - //The tokuno dungeons are really inside malas + // The tokuno dungeons are really inside malas if (map != Map.Malas) return false; @@ -776,7 +768,7 @@ namespace Server.Spells return x < 0 || y < 0 || x >= map.Width || y >= map.Height; } - //towns + // towns public static bool IsTown(IPoint3D ip, Mobile caster) { if (ip is Item item) @@ -792,13 +784,10 @@ namespace Server.Spells if (map == null) return false; - #region Dueling if (Region.Find(loc, map).GetRegion() != null) if (caster is PlayerMobile pm && (pm.DuelContext?.Started != true || pm.DuelPlayer?.Eliminated != false)) return true; - #endregion - GuardedRegion reg = Region.Find(loc, map).GetRegion(); return reg?.IsDisabled() == false; @@ -823,7 +812,7 @@ namespace Server.Spells return true; } - //magic reflection + // magic reflection public static void CheckReflect(int circle, Mobile caster, ref Mobile target) { CheckReflect(circle, ref caster, ref target); @@ -994,7 +983,7 @@ namespace Server.Spells public static void Heal(int amount, Mobile target, Mobile from, bool message = true) { - //TODO: All Healing *spells* go through ArcaneEmpowerment + // TODO: All Healing *spells* go through ArcaneEmpowerment target.Heal(amount, from, message); } @@ -1003,8 +992,9 @@ namespace Server.Spells private class SpellDamageTimer : Timer { private int m_Damage; - private Spell m_Spell; - private Mobile m_Target, m_From; + private readonly Spell m_Spell; + private readonly Mobile m_Target; + private readonly Mobile m_From; public SpellDamageTimer(Spell s, Mobile target, Mobile from, int damage, TimeSpan delay) : base(delay) @@ -1034,10 +1024,16 @@ namespace Server.Spells private class SpellDamageTimerAOS : Timer { private int m_Damage; - private DFAlgorithm m_DFA; - private int m_Phys, m_Fire, m_Cold, m_Pois, m_Nrgy, m_Chaos; - private Spell m_Spell; - private Mobile m_Target, m_From; + private readonly DFAlgorithm m_DFA; + private readonly int m_Phys; + private readonly int m_Fire; + private readonly int m_Cold; + private readonly int m_Pois; + private readonly int m_Nrgy; + private readonly int m_Chaos; + private readonly Spell m_Spell; + private readonly Mobile m_Target; + private readonly Mobile m_From; public SpellDamageTimerAOS(Spell s, TimeSpan delay, Mobile target, Mobile from, int damage, int phys, int fire, int cold, int pois, int nrgy, int chaos, DFAlgorithm dfa) @@ -1138,7 +1134,7 @@ namespace Server.Spells { caster.SendLocalizedMessage(1061091); // You cannot cast that spell in this form. } - else if (!caster.CanBeginAction() || caster.IsBodyMod && GetContext(caster) == null) + else if (!caster.CanBeginAction() || (caster.IsBodyMod && GetContext(caster) == null)) { spell.DoFizzle(); } @@ -1207,9 +1203,7 @@ namespace Server.Spells return false; } - #region Context Stuff - - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public static void AddContext(Mobile m, TransformContext context) { @@ -1256,29 +1250,26 @@ namespace Server.Spells public static bool UnderTransformation(Mobile m) => GetContext(m) != null; public static bool UnderTransformation(Mobile m, Type type) => GetContext(m)?.Type == type; - - #endregion } public interface ITransformationSpell { - int Body{ get; } - int Hue{ get; } + int Body { get; } + int Hue { get; } - int PhysResistOffset{ get; } - int FireResistOffset{ get; } - int ColdResistOffset{ get; } - int PoisResistOffset{ get; } - int NrgyResistOffset{ get; } + int PhysResistOffset { get; } + int FireResistOffset { get; } + int ColdResistOffset { get; } + int PoisResistOffset { get; } + int NrgyResistOffset { get; } - double TickRate{ get; } + double TickRate { get; } void OnTick(Mobile m); void DoEffect(Mobile m); void RemoveEffect(Mobile m); } - public class TransformContext { public TransformContext(Timer timer, List mods, Type type, ITransformationSpell spell) @@ -1289,19 +1280,19 @@ namespace Server.Spells Spell = spell; } - public Timer Timer{ get; } + public Timer Timer { get; } - public List Mods{ get; } + public List Mods { get; } - public Type Type{ get; } + public Type Type { get; } - public ITransformationSpell Spell{ get; } + public ITransformationSpell Spell { get; } } public class TransformTimer : Timer { - private Mobile m_Mobile; - private ITransformationSpell m_Spell; + private readonly Mobile m_Mobile; + private readonly ITransformationSpell m_Spell; public TransformTimer(Mobile from, ITransformationSpell spell) : base(TimeSpan.FromSeconds(spell.TickRate), TimeSpan.FromSeconds(spell.TickRate)) diff --git a/Projects/Scripts/Spells/Base/SpellInfo.cs b/Projects/Scripts/Spells/Base/SpellInfo.cs index 918a28d26..d5b4acbc4 100644 --- a/Projects/Scripts/Spells/Base/SpellInfo.cs +++ b/Projects/Scripts/Spells/Base/SpellInfo.cs @@ -51,20 +51,20 @@ namespace Server.Spells Amounts[i] = 1; } - public int Action{ get; set; } + public int Action { get; set; } - public bool AllowTown{ get; set; } + public bool AllowTown { get; set; } - public int[] Amounts{ get; set; } + public int[] Amounts { get; set; } - public string Mantra{ get; set; } + public string Mantra { get; set; } - public string Name{ get; set; } + public string Name { get; set; } - public Type[] Reagents{ get; set; } + public Type[] Reagents { get; set; } - public int LeftHandEffect{ get; set; } + public int LeftHandEffect { get; set; } - public int RightHandEffect{ get; set; } + public int RightHandEffect { get; set; } } } \ No newline at end of file diff --git a/Projects/Scripts/Spells/Base/SpellRegistry.cs b/Projects/Scripts/Spells/Base/SpellRegistry.cs index 099ee64bb..82fd99be8 100644 --- a/Projects/Scripts/Spells/Base/SpellRegistry.cs +++ b/Projects/Scripts/Spells/Base/SpellRegistry.cs @@ -1,19 +1,19 @@ -using Server.Utilities; using System; using System.Collections.Generic; +using Server.Utilities; namespace Server.Spells { public class SpellRegistry { - private static Type[] m_Types = new Type[700]; + private static readonly Type[] m_Types = new Type[700]; private static int m_Count; - private static Dictionary m_IDsFromTypes = new Dictionary(m_Types.Length); + private static readonly Dictionary m_IDsFromTypes = new Dictionary(m_Types.Length); - private static object[] m_Params = new object[2]; + private static readonly object[] m_Params = new object[2]; - private static string[] m_CircleNames = + private static readonly string[] m_CircleNames = { "First", "Second", @@ -39,7 +39,7 @@ namespace Server.Spells } } - //What IS this used for anyways. + // What IS this used for anyways. public static int Count { get @@ -57,7 +57,7 @@ namespace Server.Spells } } - public static Dictionary SpecialMoves{ get; } = new Dictionary(); + public static Dictionary SpecialMoves { get; } = new Dictionary(); public static int GetRegistryNumber(ISpell s) => GetRegistryNumber(s.GetType()); diff --git a/Projects/Scripts/Spells/Bushido/Confidence.cs b/Projects/Scripts/Spells/Bushido/Confidence.cs index 44cf819ad..6c49e53fe 100644 --- a/Projects/Scripts/Spells/Bushido/Confidence.cs +++ b/Projects/Scripts/Spells/Bushido/Confidence.cs @@ -5,14 +5,13 @@ namespace Server.Spells.Bushido { public class Confidence : SamuraiSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Confidence", null, -1, - 9002 - ); + 9002); - private static Dictionary m_Table = new Dictionary(); - private static Dictionary m_RegenTable = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_RegenTable = new Dictionary(); public Confidence(Mobile caster, Item scroll) : base(caster, scroll, m_Info) { @@ -93,7 +92,7 @@ namespace Server.Spells.Bushido private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m) : base(TimeSpan.FromSeconds(15.0)) { @@ -110,8 +109,8 @@ namespace Server.Spells.Bushido private class RegenTimer : Timer { - private int m_Hits; - private Mobile m_Mobile; + private readonly int m_Hits; + private readonly Mobile m_Mobile; private int m_Ticks; public RegenTimer(Mobile m) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Spells/Bushido/CounterAttack.cs b/Projects/Scripts/Spells/Bushido/CounterAttack.cs index ef394ce6e..4ef263665 100644 --- a/Projects/Scripts/Spells/Bushido/CounterAttack.cs +++ b/Projects/Scripts/Spells/Bushido/CounterAttack.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Bushido { public class CounterAttack : SamuraiSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "CounterAttack", null, -1, - 9002 - ); + 9002); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public CounterAttack(Mobile caster, Item scroll) : base(caster, scroll, m_Info) { @@ -87,7 +86,7 @@ namespace Server.Spells.Bushido private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m) : base(TimeSpan.FromSeconds(30.0)) { diff --git a/Projects/Scripts/Spells/Bushido/Evasion.cs b/Projects/Scripts/Spells/Bushido/Evasion.cs index 723837ddc..6ff0cc0eb 100644 --- a/Projects/Scripts/Spells/Bushido/Evasion.cs +++ b/Projects/Scripts/Spells/Bushido/Evasion.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Bushido { public class Evasion : SamuraiSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Evasion", null, -1, - 9002 - ); + 9002); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public Evasion(Mobile caster, Item scroll) : base(caster, scroll, m_Info) @@ -26,34 +25,34 @@ namespace Server.Spells.Bushido public override bool CheckCast() => VerifyCast(Caster, true) && base.CheckCast(); - public static bool VerifyCast(Mobile Caster, bool messages) + public static bool VerifyCast(Mobile caster, bool messages) { - if (Caster == null) // Sanity + if (caster == null) // Sanity return false; - if (!(Caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) - weap = Caster.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; + if (!(caster.FindItemOnLayer(Layer.OneHanded) is BaseWeapon weap)) + weap = caster.FindItemOnLayer(Layer.TwoHanded) as BaseWeapon; if (weap != null) { - if (Core.ML && Caster.Skills[weap.Skill].Base < 50) + if (Core.ML && caster.Skills[weap.Skill].Base < 50) { if (messages) - Caster.SendLocalizedMessage( + caster.SendLocalizedMessage( 1076206); // Your skill with your equipped weapon must be 50 or higher to use Evasion. return false; } } - else if (!(Caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) + else if (!(caster.FindItemOnLayer(Layer.TwoHanded) is BaseShield)) { if (messages) - Caster.SendLocalizedMessage(1062944); // You must have a weapon or a shield equipped to use this ability! + caster.SendLocalizedMessage(1062944); // You must have a weapon or a shield equipped to use this ability! return false; } - if (!Caster.CanBeginAction()) + if (!caster.CanBeginAction()) { - if (messages) Caster.SendLocalizedMessage(501789); // You must wait before trying again. + if (messages) caster.SendLocalizedMessage(501789); // You must wait before trying again. return false; } @@ -109,7 +108,7 @@ namespace Server.Spells.Bushido BeginEvasion(Caster); Caster.BeginAction(); - Timer.DelayCall(TimeSpan.FromSeconds(20.0), delegate { Caster.EndAction(); }); + Timer.DelayCall(TimeSpan.FromSeconds(20.0), Caster.EndAction); } FinishSequence(); @@ -135,8 +134,7 @@ namespace Server.Spells.Bushido if (m.Skills.Bushido.Value > 60) 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 + 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 seconds++; return TimeSpan.FromSeconds((int)seconds); @@ -161,8 +159,7 @@ namespace Server.Spells.Bushido if (m.Skills.Bushido.Value >= 60) 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 + 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 bonus += 0.10; return 1.0 + bonus; @@ -190,7 +187,7 @@ namespace Server.Spells.Bushido private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m, TimeSpan delay) : base(delay) diff --git a/Projects/Scripts/Spells/Bushido/HonorableExecution.cs b/Projects/Scripts/Spells/Bushido/HonorableExecution.cs index b5cdb306d..f5cf1f805 100644 --- a/Projects/Scripts/Spells/Bushido/HonorableExecution.cs +++ b/Projects/Scripts/Spells/Bushido/HonorableExecution.cs @@ -5,7 +5,7 @@ namespace Server.Spells.Bushido { public class HonorableExecution : SamuraiMove { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 0; public override double RequiredSkill => 25.0; @@ -90,10 +90,10 @@ namespace Server.Spells.Bushido private class HonorableExecutionInfo { - public Mobile m_Mobile; - public List m_Mods; - public bool m_Penalty; - public int m_SwingBonus; + public readonly Mobile m_Mobile; + public readonly List m_Mods; + public readonly bool m_Penalty; + public readonly int m_SwingBonus; public Timer m_Timer; public HonorableExecutionInfo(Mobile from, List mods) : this(from, 0, mods, mods != null) diff --git a/Projects/Scripts/Spells/Bushido/SamuraiMove.cs b/Projects/Scripts/Spells/Bushido/SamuraiMove.cs index bd5cc5844..2f1e1781e 100644 --- a/Projects/Scripts/Spells/Bushido/SamuraiMove.cs +++ b/Projects/Scripts/Spells/Bushido/SamuraiMove.cs @@ -6,7 +6,7 @@ namespace Server.Spells public override void CheckGain(Mobile m) { - m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5); //Per five on friday 02/16/07 + m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5); // Per five on friday 02/16/07 } } } \ No newline at end of file diff --git a/Projects/Scripts/Spells/Bushido/SamuraiSpell.cs b/Projects/Scripts/Spells/Bushido/SamuraiSpell.cs index 4af7c7ca7..bc17be7ab 100644 --- a/Projects/Scripts/Spells/Bushido/SamuraiSpell.cs +++ b/Projects/Scripts/Spells/Bushido/SamuraiSpell.cs @@ -10,8 +10,8 @@ namespace Server.Spells.Bushido { } - public abstract double RequiredSkill{ get; } - public abstract int RequiredMana{ get; } + public abstract double RequiredSkill { get; } + public abstract int RequiredMana { get; } public override SkillName CastSkill => SkillName.Bushido; public override SkillName DamageSkill => SkillName.Bushido; @@ -20,7 +20,7 @@ namespace Server.Spells.Bushido public override bool BlocksMovement => false; public override bool ShowHandMovement => false; - //public override int CastDelayBase => 1; + // public override int CastDelayBase => 1; public override double CastDelayFastScalar => 0; public override int CastRecoveryBase => 7; @@ -86,7 +86,7 @@ namespace Server.Spells.Bushido public override void GetCastSkills(out double min, out double max) { - min = RequiredSkill - 12.5; //per 5 on friday, 2/16/07 + min = RequiredSkill - 12.5; // per 5 on friday, 2/16/07 max = RequiredSkill + 37.5; } diff --git a/Projects/Scripts/Spells/Chivalry/CleanseByFire.cs b/Projects/Scripts/Spells/Chivalry/CleanseByFire.cs index 7c9404a31..87d97f193 100644 --- a/Projects/Scripts/Spells/Chivalry/CleanseByFire.cs +++ b/Projects/Scripts/Spells/Chivalry/CleanseByFire.cs @@ -6,11 +6,10 @@ namespace Server.Spells.Chivalry { public class CleanseByFireSpell : PaladinSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Cleanse By Fire", "Expor Flamus", -1, - 9002 - ); + 9002); public CleanseByFireSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Chivalry/CloseWounds.cs b/Projects/Scripts/Spells/Chivalry/CloseWounds.cs index 2b66a3fa9..7c6d3f323 100644 --- a/Projects/Scripts/Spells/Chivalry/CloseWounds.cs +++ b/Projects/Scripts/Spells/Chivalry/CloseWounds.cs @@ -9,11 +9,10 @@ namespace Server.Spells.Chivalry { public class CloseWoundsSpell : PaladinSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Close Wounds", "Obsu Vulni", -1, - 9002 - ); + 9002); public CloseWoundsSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Chivalry/ConsecrateWeapon.cs b/Projects/Scripts/Spells/Chivalry/ConsecrateWeapon.cs index 860f380b4..fe600185d 100644 --- a/Projects/Scripts/Spells/Chivalry/ConsecrateWeapon.cs +++ b/Projects/Scripts/Spells/Chivalry/ConsecrateWeapon.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Chivalry { public class ConsecrateWeaponSpell : PaladinSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Consecrate Weapon", "Consecrus Arma", -1, - 9002 - ); + 9002); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public ConsecrateWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -92,7 +91,7 @@ namespace Server.Spells.Chivalry private class ExpireTimer : Timer { - private BaseWeapon m_Weapon; + private readonly BaseWeapon m_Weapon; public ExpireTimer(BaseWeapon weapon, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Spells/Chivalry/DispelEvil.cs b/Projects/Scripts/Spells/Chivalry/DispelEvil.cs index 9677bb90c..5619258e2 100644 --- a/Projects/Scripts/Spells/Chivalry/DispelEvil.cs +++ b/Projects/Scripts/Spells/Chivalry/DispelEvil.cs @@ -9,11 +9,10 @@ namespace Server.Spells.Chivalry { public class DispelEvilSpell : PaladinSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Dispel Evil", "Dispiro Malas", -1, - 9002 - ); + 9002); public DispelEvilSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -82,7 +81,7 @@ namespace Server.Spells.Chivalry } TransformContext context = TransformationSpellHelper.GetContext(m); - if (context?.Spell is NecromancerSpell) //Trees are not evil! TODO: OSI confirm? + if (context?.Spell is NecromancerSpell) // Trees are not evil! TODO: OSI confirm? { // transformed .. diff --git a/Projects/Scripts/Spells/Chivalry/DivineFury.cs b/Projects/Scripts/Spells/Chivalry/DivineFury.cs index f3d8163d8..b17a77fac 100644 --- a/Projects/Scripts/Spells/Chivalry/DivineFury.cs +++ b/Projects/Scripts/Spells/Chivalry/DivineFury.cs @@ -5,13 +5,12 @@ namespace Server.Spells.Chivalry { public class DivineFurySpell : PaladinSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Divine Fury", "Divinum Furis", -1, - 9002 - ); + 9002); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public DivineFurySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Chivalry/EnemyOfOne.cs b/Projects/Scripts/Spells/Chivalry/EnemyOfOne.cs index 191e76466..9a5f51520 100644 --- a/Projects/Scripts/Spells/Chivalry/EnemyOfOne.cs +++ b/Projects/Scripts/Spells/Chivalry/EnemyOfOne.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Chivalry { public class EnemyOfOneSpell : PaladinSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Enemy of One", "Forul Solum", -1, - 9002 - ); + 9002); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public EnemyOfOneSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Chivalry/HolyLight.cs b/Projects/Scripts/Spells/Chivalry/HolyLight.cs index 2a0d3274e..d343f941f 100644 --- a/Projects/Scripts/Spells/Chivalry/HolyLight.cs +++ b/Projects/Scripts/Spells/Chivalry/HolyLight.cs @@ -7,11 +7,10 @@ namespace Server.Spells.Chivalry { public class HolyLightSpell : PaladinSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Holy Light", "Augus Luminos", -1, - 9002 - ); + 9002); public HolyLightSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Chivalry/NobleSacrifice.cs b/Projects/Scripts/Spells/Chivalry/NobleSacrifice.cs index 1bb57d30a..2972a222f 100644 --- a/Projects/Scripts/Spells/Chivalry/NobleSacrifice.cs +++ b/Projects/Scripts/Spells/Chivalry/NobleSacrifice.cs @@ -8,11 +8,10 @@ namespace Server.Spells.Chivalry { public class NobleSacrificeSpell : PaladinSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Noble Sacrifice", "Dium Prostra", -1, - 9002 - ); + 9002); public NobleSacrificeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Chivalry/PaladinSpell.cs b/Projects/Scripts/Spells/Chivalry/PaladinSpell.cs index 25ed680b3..da67440af 100644 --- a/Projects/Scripts/Spells/Chivalry/PaladinSpell.cs +++ b/Projects/Scripts/Spells/Chivalry/PaladinSpell.cs @@ -9,17 +9,17 @@ namespace Server.Spells.Chivalry { } - public abstract double RequiredSkill{ get; } - public abstract int RequiredMana{ get; } - public abstract int RequiredTithing{ get; } - public abstract int MantraNumber{ get; } + public abstract double RequiredSkill { get; } + public abstract int RequiredMana { get; } + public abstract int RequiredTithing { get; } + public abstract int MantraNumber { get; } public override SkillName CastSkill => SkillName.Chivalry; public override SkillName DamageSkill => SkillName.Chivalry; public override bool ClearHandsOnCast => false; - //public override int CastDelayBase => 1; + // public override int CastDelayBase => 1; public override int CastRecoveryBase => 7; diff --git a/Projects/Scripts/Spells/Chivalry/RemoveCurse.cs b/Projects/Scripts/Spells/Chivalry/RemoveCurse.cs index 1e514e348..237348971 100644 --- a/Projects/Scripts/Spells/Chivalry/RemoveCurse.cs +++ b/Projects/Scripts/Spells/Chivalry/RemoveCurse.cs @@ -9,11 +9,10 @@ namespace Server.Spells.Chivalry { public class RemoveCurseSpell : PaladinSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Remove Curse", "Extermo Vomica", -1, - 9002 - ); + 9002); public RemoveCurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Chivalry/SacredJourney.cs b/Projects/Scripts/Spells/Chivalry/SacredJourney.cs index 5ca1a4152..1dd9e79fb 100644 --- a/Projects/Scripts/Spells/Chivalry/SacredJourney.cs +++ b/Projects/Scripts/Spells/Chivalry/SacredJourney.cs @@ -8,18 +8,16 @@ namespace Server.Spells.Chivalry { public class SacredJourneySpell : PaladinSpell, IRecallSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Sacred Journey", "Sanctum Viatas", -1, - 9002 - ); + 9002); - private Runebook m_Book; + private readonly Runebook m_Book; - private RunebookEntry m_Entry; + private readonly RunebookEntry m_Entry; - public SacredJourneySpell(Mobile caster, RunebookEntry entry = null, Runebook book = null, Item scroll = null) : - base(caster, scroll, m_Info) + public SacredJourneySpell(Mobile caster, RunebookEntry entry = null, Runebook book = null, Item scroll = null) : base(caster, scroll, m_Info) { m_Entry = entry; m_Book = book; @@ -79,7 +77,7 @@ namespace Server.Spells.Chivalry { Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. } - else if (map == null || !Core.AOS && Caster.Map != map) + else if (map == null || (!Core.AOS && Caster.Map != map)) { Caster.SendLocalizedMessage(1005569); // You can not recall to another facet. } diff --git a/Projects/Scripts/Spells/Eighth/AirElemental.cs b/Projects/Scripts/Spells/Eighth/AirElemental.cs index fb5c60b0f..112549f1f 100644 --- a/Projects/Scripts/Spells/Eighth/AirElemental.cs +++ b/Projects/Scripts/Spells/Eighth/AirElemental.cs @@ -5,15 +5,14 @@ namespace Server.Spells.Eighth { public class AirElementalSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Air Elemental", "Kal Vas Xen Hur", 269, 9010, false, Reagent.Bloodmoss, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public AirElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Eighth/EarthElemental.cs b/Projects/Scripts/Spells/Eighth/EarthElemental.cs index 53c93a25b..bfb344710 100644 --- a/Projects/Scripts/Spells/Eighth/EarthElemental.cs +++ b/Projects/Scripts/Spells/Eighth/EarthElemental.cs @@ -5,15 +5,14 @@ namespace Server.Spells.Eighth { public class EarthElementalSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Earth Elemental", "Kal Vas Xen Ylem", 269, 9020, false, Reagent.Bloodmoss, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public EarthElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Eighth/Earthquake.cs b/Projects/Scripts/Spells/Eighth/Earthquake.cs index 6c0af3483..bd43ee909 100644 --- a/Projects/Scripts/Spells/Eighth/Earthquake.cs +++ b/Projects/Scripts/Spells/Eighth/Earthquake.cs @@ -6,7 +6,7 @@ namespace Server.Spells.Eighth { public class EarthquakeSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Earthquake", "In Vas Por", 233, 9012, @@ -14,8 +14,7 @@ namespace Server.Spells.Eighth Reagent.Bloodmoss, Reagent.Ginseng, Reagent.MandrakeRoot, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public EarthquakeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Eighth/EnergyVortex.cs b/Projects/Scripts/Spells/Eighth/EnergyVortex.cs index 0ffd6c3bd..0ad0946ca 100644 --- a/Projects/Scripts/Spells/Eighth/EnergyVortex.cs +++ b/Projects/Scripts/Spells/Eighth/EnergyVortex.cs @@ -5,7 +5,7 @@ namespace Server.Spells.Eighth { public class EnergyVortexSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Energy Vortex", "Vas Corp Por", 260, 9032, @@ -13,8 +13,7 @@ namespace Server.Spells.Eighth Reagent.Bloodmoss, Reagent.BlackPearl, Reagent.MandrakeRoot, - Reagent.Nightshade - ); + Reagent.Nightshade); public EnergyVortexSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Eighth/FireElemental.cs b/Projects/Scripts/Spells/Eighth/FireElemental.cs index 62e37ff46..d118da5ae 100644 --- a/Projects/Scripts/Spells/Eighth/FireElemental.cs +++ b/Projects/Scripts/Spells/Eighth/FireElemental.cs @@ -5,7 +5,7 @@ namespace Server.Spells.Eighth { public class FireElementalSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Fire Elemental", "Kal Vas Xen Flam", 269, 9050, @@ -13,8 +13,7 @@ namespace Server.Spells.Eighth Reagent.Bloodmoss, Reagent.MandrakeRoot, Reagent.SpidersSilk, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public FireElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Eighth/Resurrection.cs b/Projects/Scripts/Spells/Eighth/Resurrection.cs index 28d9a219e..2ca436655 100644 --- a/Projects/Scripts/Spells/Eighth/Resurrection.cs +++ b/Projects/Scripts/Spells/Eighth/Resurrection.cs @@ -6,14 +6,13 @@ namespace Server.Spells.Eighth { public class ResurrectionSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Resurrection", "An Corp", 245, 9062, Reagent.Bloodmoss, Reagent.Garlic, - Reagent.Ginseng - ); + Reagent.Ginseng); public ResurrectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Eighth/SummonDaemon.cs b/Projects/Scripts/Spells/Eighth/SummonDaemon.cs index b5853ac02..1fa6122e4 100644 --- a/Projects/Scripts/Spells/Eighth/SummonDaemon.cs +++ b/Projects/Scripts/Spells/Eighth/SummonDaemon.cs @@ -5,7 +5,7 @@ namespace Server.Spells.Eighth { public class SummonDaemonSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Summon Daemon", "Kal Vas Xen Corp", 269, 9050, @@ -13,8 +13,7 @@ namespace Server.Spells.Eighth Reagent.Bloodmoss, Reagent.MandrakeRoot, Reagent.SpidersSilk, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public SummonDaemonSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Eighth/WaterElemental.cs b/Projects/Scripts/Spells/Eighth/WaterElemental.cs index 122871ba5..4f071301e 100644 --- a/Projects/Scripts/Spells/Eighth/WaterElemental.cs +++ b/Projects/Scripts/Spells/Eighth/WaterElemental.cs @@ -5,15 +5,14 @@ namespace Server.Spells.Eighth { public class WaterElementalSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Water Elemental", "Kal Vas Xen An Flam", 269, 9070, false, Reagent.Bloodmoss, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public WaterElementalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fifth/BladeSpirits.cs b/Projects/Scripts/Spells/Fifth/BladeSpirits.cs index 8d0e73ae6..b5218768d 100644 --- a/Projects/Scripts/Spells/Fifth/BladeSpirits.cs +++ b/Projects/Scripts/Spells/Fifth/BladeSpirits.cs @@ -5,15 +5,14 @@ namespace Server.Spells.Fifth { public class BladeSpiritsSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Blade Spirits", "In Jux Hur Ylem", 266, 9040, false, Reagent.BlackPearl, Reagent.MandrakeRoot, - Reagent.Nightshade - ); + Reagent.Nightshade); public BladeSpiritsSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fifth/DispelField.cs b/Projects/Scripts/Spells/Fifth/DispelField.cs index c9662a02b..a08deff87 100644 --- a/Projects/Scripts/Spells/Fifth/DispelField.cs +++ b/Projects/Scripts/Spells/Fifth/DispelField.cs @@ -6,15 +6,14 @@ namespace Server.Spells.Fifth { public class DispelFieldSpell : MagerySpell, ISpellTargetingItem { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Dispel Field", "An Grav", 206, 9002, Reagent.BlackPearl, Reagent.SpidersSilk, Reagent.SulfurousAsh, - Reagent.Garlic - ); + Reagent.Garlic); public DispelFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fifth/Incognito.cs b/Projects/Scripts/Spells/Fifth/Incognito.cs index e28e75943..7c841f8ab 100644 --- a/Projects/Scripts/Spells/Fifth/Incognito.cs +++ b/Projects/Scripts/Spells/Fifth/Incognito.cs @@ -9,16 +9,15 @@ namespace Server.Spells.Fifth { public class IncognitoSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Incognito", "Kal In Ex", 206, 9002, Reagent.Bloodmoss, Reagent.Garlic, - Reagent.Nightshade - ); + Reagent.Nightshade); - private static Dictionary m_Timers = new Dictionary(); + private static readonly Dictionary m_Timers = new Dictionary(); public IncognitoSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -97,7 +96,6 @@ namespace Server.Spells.Fifth StopTimer(Caster); - int timeVal = 6 * Caster.Skills.Magery.Fixed / 50 + 1; if (timeVal > 144) @@ -105,7 +103,6 @@ namespace Server.Spells.Fifth TimeSpan length = TimeSpan.FromSeconds(timeVal); - InternalTimer t = new InternalTimer(Caster, length); m_Timers[Caster] = t; @@ -134,7 +131,7 @@ namespace Server.Spells.Fifth private class InternalTimer : Timer { - private Mobile m_Owner; + private readonly Mobile m_Owner; public InternalTimer(Mobile owner, TimeSpan length) : base(length) { @@ -143,7 +140,7 @@ namespace Server.Spells.Fifth /* int val = ((6 * owner.Skills.Magery.Fixed) / 50) + 1; - if ( val > 144 ) + if (val > 144) val = 144; Delay = TimeSpan.FromSeconds( val ); diff --git a/Projects/Scripts/Spells/Fifth/MagicReflect.cs b/Projects/Scripts/Spells/Fifth/MagicReflect.cs index 609061727..64bd8a3f6 100644 --- a/Projects/Scripts/Spells/Fifth/MagicReflect.cs +++ b/Projects/Scripts/Spells/Fifth/MagicReflect.cs @@ -4,16 +4,15 @@ namespace Server.Spells.Fifth { public class MagicReflectSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Magic Reflection", "In Jux Sanct", 242, 9012, Reagent.Garlic, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public MagicReflectSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -113,7 +112,7 @@ namespace Server.Spells.Fifth if (Caster.BeginAction()) { int value = (int)(Caster.Skills.Magery.Value + Caster.Skills.Inscribe.Value); - value = (int)(8 + value / 200.0 * 7.0); //absorb from 8 to 15 "circles" + value = (int)(8 + value / 200.0 * 7.0); // absorb from 8 to 15 "circles" Caster.MagicDamageAbsorb = value; diff --git a/Projects/Scripts/Spells/Fifth/MindBlast.cs b/Projects/Scripts/Spells/Fifth/MindBlast.cs index 720a02a14..c99bb1185 100644 --- a/Projects/Scripts/Spells/Fifth/MindBlast.cs +++ b/Projects/Scripts/Spells/Fifth/MindBlast.cs @@ -5,15 +5,14 @@ namespace Server.Spells.Fifth { public class MindBlastSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mind Blast", "Por Corp Wis", 218, Core.AOS ? 9002 : 9032, Reagent.BlackPearl, Reagent.MandrakeRoot, Reagent.Nightshade, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public MindBlastSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fifth/Paralyze.cs b/Projects/Scripts/Spells/Fifth/Paralyze.cs index 48f911559..6b1d5dec0 100644 --- a/Projects/Scripts/Spells/Fifth/Paralyze.cs +++ b/Projects/Scripts/Spells/Fifth/Paralyze.cs @@ -7,14 +7,13 @@ namespace Server.Spells.Fifth { public class ParalyzeSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Paralyze", "An Ex Por", 218, 9012, Reagent.Garlic, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public ParalyzeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -35,7 +34,7 @@ namespace Server.Spells.Fifth if (!Caster.CanSee(m)) Caster.SendLocalizedMessage(500237); // Target can not be seen. else if (Core.AOS && (m.Frozen || m.Paralyzed || - m.Spell?.IsCasting == true && !(m.Spell is PaladinSpell))) + (m.Spell?.IsCasting == true && !(m.Spell is PaladinSpell)))) { Caster.SendLocalizedMessage(1061923); // The target is already frozen. } diff --git a/Projects/Scripts/Spells/Fifth/PoisonField.cs b/Projects/Scripts/Spells/Fifth/PoisonField.cs index 8ae3bf8ab..2cc79a3e6 100644 --- a/Projects/Scripts/Spells/Fifth/PoisonField.cs +++ b/Projects/Scripts/Spells/Fifth/PoisonField.cs @@ -9,15 +9,14 @@ namespace Server.Spells.Fifth { public class PoisonFieldSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Poison Field", "In Nox Grav", 230, 9052, false, Reagent.BlackPearl, Reagent.Nightshade, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public PoisonFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -132,20 +131,20 @@ namespace Server.Spells.Fifth switch (version) { case 1: - { - m_Caster = reader.ReadMobile(); + { + m_Caster = reader.ReadMobile(); - goto case 0; - } + goto case 0; + } case 0: - { - m_End = reader.ReadDeltaTime(); + { + m_End = reader.ReadDeltaTime(); - m_Timer = new InternalTimer(this, TimeSpan.Zero, true, true); - m_Timer.Start(); + m_Timer = new InternalTimer(this, TimeSpan.Zero, true, true); + m_Timer.Start(); - break; - } + break; + } } } @@ -197,9 +196,10 @@ namespace Server.Spells.Fifth private class InternalTimer : Timer { - private static Queue m_Queue = new Queue(); - private bool m_InLOS, m_CanFit; - private InternalItem m_Item; + private static readonly Queue m_Queue = new Queue(); + private readonly bool m_InLOS; + private readonly bool m_CanFit; + private readonly InternalItem m_Item; public InternalTimer(InternalItem item, TimeSpan delay, bool inLOS, bool canFit) : base(delay, TimeSpan.FromSeconds(1.5)) diff --git a/Projects/Scripts/Spells/Fifth/SummonCreature.cs b/Projects/Scripts/Spells/Fifth/SummonCreature.cs index 47c6a98c6..109422f5f 100644 --- a/Projects/Scripts/Spells/Fifth/SummonCreature.cs +++ b/Projects/Scripts/Spells/Fifth/SummonCreature.cs @@ -6,18 +6,17 @@ namespace Server.Spells.Fifth { public class SummonCreatureSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Summon Creature", "Kal Xen", 16, false, Reagent.Bloodmoss, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); // NOTE: Creature list based on 1hr of summon/release on OSI. - private static Type[] m_Types = + private static readonly Type[] m_Types = { typeof(PolarBear), typeof(GrizzlyBear), @@ -66,7 +65,7 @@ namespace Server.Spells.Fifth { BaseCreature creature = (BaseCreature)ActivatorUtil.CreateInstance(m_Types[Utility.Random(m_Types.Length)]); - //creature.ControlSlots = 2; + // creature.ControlSlots = 2; TimeSpan duration; diff --git a/Projects/Scripts/Spells/First/Clumsy.cs b/Projects/Scripts/Spells/First/Clumsy.cs index e0d0e1e49..ee013306c 100644 --- a/Projects/Scripts/Spells/First/Clumsy.cs +++ b/Projects/Scripts/Spells/First/Clumsy.cs @@ -5,13 +5,12 @@ namespace Server.Spells.First { public class ClumsySpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Clumsy", "Uus Jux", 212, 9031, Reagent.Bloodmoss, - Reagent.Nightshade - ); + Reagent.Nightshade); public ClumsySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/First/CreateFood.cs b/Projects/Scripts/Spells/First/CreateFood.cs index c4a4883a0..745f36464 100644 --- a/Projects/Scripts/Spells/First/CreateFood.cs +++ b/Projects/Scripts/Spells/First/CreateFood.cs @@ -6,16 +6,15 @@ namespace Server.Spells.First { public class CreateFoodSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Create Food", "In Mani Ylem", 224, 9011, Reagent.Garlic, Reagent.Ginseng, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); - private static FoodInfo[] m_Food = + private static readonly FoodInfo[] m_Food = { new FoodInfo(typeof(Grapes), "a grape bunch"), new FoodInfo(typeof(Ham), "a ham"), @@ -66,9 +65,9 @@ namespace Server.Spells.First Name = name; } - public Type Type{ get; set; } + public Type Type { get; set; } - public string Name{ get; set; } + public string Name { get; set; } public Item Create() { diff --git a/Projects/Scripts/Spells/First/Feeblemind.cs b/Projects/Scripts/Spells/First/Feeblemind.cs index 37344a029..768124e85 100644 --- a/Projects/Scripts/Spells/First/Feeblemind.cs +++ b/Projects/Scripts/Spells/First/Feeblemind.cs @@ -5,13 +5,12 @@ namespace Server.Spells.First { public class FeeblemindSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Feeblemind", "Rel Wis", 212, 9031, Reagent.Ginseng, - Reagent.Nightshade - ); + Reagent.Nightshade); public FeeblemindSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/First/Heal.cs b/Projects/Scripts/Spells/First/Heal.cs index 2e2c80b36..00b2a1044 100644 --- a/Projects/Scripts/Spells/First/Heal.cs +++ b/Projects/Scripts/Spells/First/Heal.cs @@ -8,14 +8,13 @@ namespace Server.Spells.First { public class HealSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Heal", "In Mani", 224, 9061, Reagent.Garlic, Reagent.Ginseng, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public HealSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -84,7 +83,7 @@ namespace Server.Spells.First toHeal += Utility.Random(1, 5); } - //m.Heal( toHeal, Caster ); + // m.Heal( toHeal, Caster ); SpellHelper.Heal(toHeal, m, Caster); m.FixedParticles(0x376A, 9, 32, 5005, EffectLayer.Waist); diff --git a/Projects/Scripts/Spells/First/MagicArrow.cs b/Projects/Scripts/Spells/First/MagicArrow.cs index 9addce105..308a3a399 100644 --- a/Projects/Scripts/Spells/First/MagicArrow.cs +++ b/Projects/Scripts/Spells/First/MagicArrow.cs @@ -4,12 +4,11 @@ namespace Server.Spells.First { public class MagicArrowSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Magic Arrow", "In Por Ylem", 212, 9041, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public MagicArrowSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/First/NightSight.cs b/Projects/Scripts/Spells/First/NightSight.cs index 7de4cf18f..82b9ca289 100644 --- a/Projects/Scripts/Spells/First/NightSight.cs +++ b/Projects/Scripts/Spells/First/NightSight.cs @@ -4,13 +4,12 @@ namespace Server.Spells.First { public class NightSightSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Night Sight", "In Lor", 236, 9031, Reagent.SulfurousAsh, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public NightSightSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -25,7 +24,7 @@ namespace Server.Spells.First private class NightSightTarget : Target { - private Spell m_Spell; + private readonly Spell m_Spell; public NightSightTarget(Spell spell) : base(12, false, TargetFlags.Beneficial) => m_Spell = spell; @@ -52,7 +51,7 @@ namespace Server.Spells.First targ.PlaySound(0x1E3); BuffInfo.AddBuff(targ, - new BuffInfo(BuffIcon.NightSight, 1075643)); //Night Sight/You ignore lighting effects + new BuffInfo(BuffIcon.NightSight, 1075643)); // Night Sight/You ignore lighting effects } else { diff --git a/Projects/Scripts/Spells/First/ReactiveArmor.cs b/Projects/Scripts/Spells/First/ReactiveArmor.cs index 521b6397a..c24f41847 100644 --- a/Projects/Scripts/Spells/First/ReactiveArmor.cs +++ b/Projects/Scripts/Spells/First/ReactiveArmor.cs @@ -4,16 +4,15 @@ namespace Server.Spells.First { public class ReactiveArmorSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Reactive Armor", "Flam Sanct", 236, 9011, Reagent.Garlic, Reagent.SpidersSilk, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public ReactiveArmorSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -62,7 +61,7 @@ namespace Server.Spells.First targ.PlaySound(0x1E9); targ.FixedParticles(0x376A, 9, 32, 5008, EffectLayer.Waist); - mods = new [] + mods = new[] { new ResistanceMod(ResistanceType.Physical, 15 + (int)(targ.Skills.Inscribe.Value / 20)), diff --git a/Projects/Scripts/Spells/First/Weaken.cs b/Projects/Scripts/Spells/First/Weaken.cs index 8584877e0..18ced9b44 100644 --- a/Projects/Scripts/Spells/First/Weaken.cs +++ b/Projects/Scripts/Spells/First/Weaken.cs @@ -5,13 +5,12 @@ namespace Server.Spells.First { public class WeakenSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Weaken", "Des Mani", 212, 9031, Reagent.Garlic, - Reagent.Nightshade - ); + Reagent.Nightshade); public WeakenSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fourth/ArchCure.cs b/Projects/Scripts/Spells/Fourth/ArchCure.cs index 7f9f0d27e..94d8d82c5 100644 --- a/Projects/Scripts/Spells/Fourth/ArchCure.cs +++ b/Projects/Scripts/Spells/Fourth/ArchCure.cs @@ -8,14 +8,13 @@ namespace Server.Spells.Fourth { public class ArchCureSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Arch Cure", "Vas An Nox", 215, 9061, Reagent.Garlic, Reagent.Ginseng, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public ArchCureSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fourth/ArchProtection.cs b/Projects/Scripts/Spells/Fourth/ArchProtection.cs index 3364a501a..f28f7499f 100644 --- a/Projects/Scripts/Spells/Fourth/ArchProtection.cs +++ b/Projects/Scripts/Spells/Fourth/ArchProtection.cs @@ -9,17 +9,16 @@ namespace Server.Spells.Fourth { public class ArchProtectionSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Arch Protection", "Vas Uus Sanct", Core.AOS ? 239 : 215, 9011, Reagent.Garlic, Reagent.Ginseng, Reagent.MandrakeRoot, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); - private static Dictionary _Table = new Dictionary(); + private static readonly Dictionary _Table = new Dictionary(); public ArchProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -108,7 +107,7 @@ namespace Server.Spells.Fourth private class InternalTimer : Timer { - private Mobile m_Owner; + private readonly Mobile m_Owner; public InternalTimer(Mobile target, Mobile caster) : base(TimeSpan.FromSeconds(0)) { diff --git a/Projects/Scripts/Spells/Fourth/Curse.cs b/Projects/Scripts/Spells/Fourth/Curse.cs index 59e66a42a..ff05750c6 100644 --- a/Projects/Scripts/Spells/Fourth/Curse.cs +++ b/Projects/Scripts/Spells/Fourth/Curse.cs @@ -6,16 +6,15 @@ namespace Server.Spells.Fourth { public class CurseSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Curse", "Des Sanct", 227, 9031, Reagent.Nightshade, Reagent.Garlic, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); - private static HashSet m_UnderEffect = new HashSet(); + private static readonly HashSet m_UnderEffect = new HashSet(); public CurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -56,8 +55,7 @@ namespace Server.Spells.Fourth SpellHelper.AddStatCurse(Caster, m, StatType.Int); SpellHelper.DisableSkillCheck = false; - if (Caster.Player && m.Player /*&& Caster != m */ && !UnderEffect(m) - ) //On OSI you CAN curse yourself and get this effect. + if (Caster.Player && m.Player /*&& Caster != m */ && !UnderEffect(m)) // On OSI you CAN curse yourself and get this effect. { TimeSpan duration = SpellHelper.GetDuration(Caster, m); m_UnderEffect.Add(m); diff --git a/Projects/Scripts/Spells/Fourth/FireField.cs b/Projects/Scripts/Spells/Fourth/FireField.cs index 9b38f4a89..36e84dbca 100644 --- a/Projects/Scripts/Spells/Fourth/FireField.cs +++ b/Projects/Scripts/Spells/Fourth/FireField.cs @@ -9,15 +9,14 @@ namespace Server.Spells.Fourth { public class FireFieldSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Fire Field", "In Flam Grav", 215, 9041, false, Reagent.BlackPearl, Reagent.SpidersSilk, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public FireFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -142,25 +141,25 @@ namespace Server.Spells.Fourth switch (version) { case 2: - { - m_Damage = reader.ReadInt(); - goto case 1; - } + { + m_Damage = reader.ReadInt(); + goto case 1; + } case 1: - { - m_Caster = reader.ReadMobile(); + { + m_Caster = reader.ReadMobile(); - goto case 0; - } + goto case 0; + } case 0: - { - m_End = reader.ReadDeltaTime(); + { + m_End = reader.ReadDeltaTime(); - m_Timer = new InternalTimer(this, TimeSpan.Zero, true, true); - m_Timer.Start(); + m_Timer = new InternalTimer(this, TimeSpan.Zero, true, true); + m_Timer.Start(); - break; - } + break; + } } if (version < 2) @@ -197,9 +196,10 @@ namespace Server.Spells.Fourth private class InternalTimer : Timer { - private static Queue m_Queue = new Queue(); - private bool m_InLOS, m_CanFit; - private FireFieldItem m_Item; + private static readonly Queue m_Queue = new Queue(); + private readonly bool m_InLOS; + private readonly bool m_CanFit; + private readonly FireFieldItem m_Item; public InternalTimer(FireFieldItem item, TimeSpan delay, bool inLOS, bool canFit) : base(delay, TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Spells/Fourth/GreaterHeal.cs b/Projects/Scripts/Spells/Fourth/GreaterHeal.cs index 67ee99f2e..e1c8eec8c 100644 --- a/Projects/Scripts/Spells/Fourth/GreaterHeal.cs +++ b/Projects/Scripts/Spells/Fourth/GreaterHeal.cs @@ -8,15 +8,14 @@ namespace Server.Spells.Fourth { public class GreaterHealSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Greater Heal", "In Vas Mani", 204, 9061, Reagent.Garlic, Reagent.Ginseng, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public GreaterHealSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -72,7 +71,7 @@ namespace Server.Spells.Fourth int toHeal = (int)(Caster.Skills.Magery.Value * 0.4); toHeal += Utility.Random(1, 10); - //m.Heal( toHeal, Caster ); + // m.Heal( toHeal, Caster ); SpellHelper.Heal(toHeal, m, Caster); m.FixedParticles(0x376A, 9, 32, 5030, EffectLayer.Waist); diff --git a/Projects/Scripts/Spells/Fourth/Lightning.cs b/Projects/Scripts/Spells/Fourth/Lightning.cs index 151054b36..51f56b636 100644 --- a/Projects/Scripts/Spells/Fourth/Lightning.cs +++ b/Projects/Scripts/Spells/Fourth/Lightning.cs @@ -4,13 +4,12 @@ namespace Server.Spells.Fourth { public class LightningSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Lightning", "Por Ort Grav", 239, 9021, Reagent.MandrakeRoot, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public LightningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fourth/ManaDrain.cs b/Projects/Scripts/Spells/Fourth/ManaDrain.cs index 10765b7f0..4a3f6f8d9 100644 --- a/Projects/Scripts/Spells/Fourth/ManaDrain.cs +++ b/Projects/Scripts/Spells/Fourth/ManaDrain.cs @@ -6,16 +6,15 @@ namespace Server.Spells.Fourth { public class ManaDrainSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mana Drain", "Ort Rel", 215, 9031, Reagent.BlackPearl, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); - private static HashSet m_Table = new HashSet(); + private static readonly HashSet m_Table = new HashSet(); public ManaDrainSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Fourth/Recall.cs b/Projects/Scripts/Spells/Fourth/Recall.cs index 3dd83bcfb..60c6a9368 100644 --- a/Projects/Scripts/Spells/Fourth/Recall.cs +++ b/Projects/Scripts/Spells/Fourth/Recall.cs @@ -8,21 +8,19 @@ namespace Server.Spells.Fourth { public class RecallSpell : MagerySpell, IRecallSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Recall", "Kal Ort Por", 239, 9031, Reagent.BlackPearl, Reagent.Bloodmoss, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); - private Runebook m_Book; + private readonly Runebook m_Book; - private RunebookEntry m_Entry; + private readonly RunebookEntry m_Entry; - public RecallSpell(Mobile caster, RunebookEntry entry = null, Runebook book = null, Item scroll = null) : - base(caster, scroll, m_Info) + public RecallSpell(Mobile caster, RunebookEntry entry = null, Runebook book = null, Item scroll = null) : base(caster, scroll, m_Info) { m_Entry = entry; m_Book = book; @@ -34,7 +32,7 @@ namespace Server.Spells.Fourth { if (TransformationSpellHelper.UnderTransformation(Caster, typeof(WraithFormSpell))) min = max = 0; - else if (Core.SE && m_Book != null) //recall using Runebook charge + else if (Core.SE && m_Book != null) // recall using Runebook charge min = max = 0; else base.GetCastSkills(out min, out max); @@ -83,7 +81,7 @@ namespace Server.Spells.Fourth { Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. } - else if (map == null || !Core.AOS && Caster.Map != map) + else if (map == null || (!Core.AOS && Caster.Map != map)) { Caster.SendLocalizedMessage(1005569); // You can not recall to another facet. } diff --git a/Projects/Scripts/Spells/Initializer.cs b/Projects/Scripts/Spells/Initializer.cs index b027bea18..128e1e004 100644 --- a/Projects/Scripts/Spells/Initializer.cs +++ b/Projects/Scripts/Spells/Initializer.cs @@ -167,34 +167,34 @@ namespace Server.Spells Register(606, typeof(SummonFeySpell)); Register(607, typeof(SummonFiendSpell)); Register(608, typeof(ReaperFormSpell)); - //Register( 609, typeof( Spellweaving.WildfireSpell ) ); + // Register( 609, typeof( Spellweaving.WildfireSpell ) ); Register(610, typeof(EssenceOfWindSpell)); - //Register( 611, typeof( Spellweaving.DryadAllureSpell ) ); + // Register( 611, typeof( Spellweaving.DryadAllureSpell ) ); Register(612, typeof(EtherealVoyageSpell)); Register(613, typeof(WordOfDeathSpell)); Register(614, typeof(GiftOfLifeSpell)); - //Register( 615, typeof( Spellweaving.ArcaneEmpowermentSpell ) ); + // Register( 615, typeof( Spellweaving.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( Mysticism.NetherBoltSpell ) ); + // Register( 678, typeof( Mysticism.HealingStoneSpell ) ); + // Register( 679, typeof( Mysticism.PurgeMagicSpell ) ); + // Register( 680, typeof( Mysticism.EnchantSpell ) ); + // Register( 681, typeof( Mysticism.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( Mysticism.SpellTriggerSpell ) ); + // Register( 686, typeof( Mysticism.MassSleepSpell ) ); + // Register( 687, typeof( Mysticism.CleansingWindsSpell ) ); + // Register( 688, typeof( Mysticism.BombardSpell ) ); Register(689, typeof(SpellPlagueSpell)); Register(690, typeof(HailStormSpell)); Register(691, typeof(NetherCycloneSpell)); - //Register( 692, typeof( Mysticism.RisingColossusSpell ) ); + // Register( 692, typeof( Mysticism.RisingColossusSpell ) ); } } } diff --git a/Projects/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs b/Projects/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs index e60847098..e62368527 100644 --- a/Projects/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs +++ b/Projects/Scripts/Spells/Mysticism/AnimatedWeaponSpell.cs @@ -5,15 +5,14 @@ namespace Server.Spells.Mysticism { public class AnimatedWeaponSpell : MysticSpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Animated Weapon", "In Jux Por Ylem", -1, 9002, Reagent.Bone, Reagent.BlackPearl, Reagent.MandrakeRoot, - Reagent.Nightshade - ); + Reagent.Nightshade); public AnimatedWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -42,7 +41,7 @@ namespace Server.Spells.Mysticism SpellHelper.GetSurfaceTop(ref p); - if (map == null || Caster.Player && !map.CanSpawnMobile(p.X, p.Y, p.Z)) + if (map == null || (Caster.Player && !map.CanSpawnMobile(p.X, p.Y, p.Z))) { Caster.SendLocalizedMessage(501942); // That location is blocked. } diff --git a/Projects/Scripts/Spells/Mysticism/EagleStrikeSpell.cs b/Projects/Scripts/Spells/Mysticism/EagleStrikeSpell.cs index 0fd88b9e0..a0476aa9d 100644 --- a/Projects/Scripts/Spells/Mysticism/EagleStrikeSpell.cs +++ b/Projects/Scripts/Spells/Mysticism/EagleStrikeSpell.cs @@ -5,15 +5,14 @@ namespace Server.Spells.Mysticism { public class EagleStrikeSpell : MysticSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Eagle Strike", "Kal Por Xen", -1, 9002, Reagent.Bloodmoss, Reagent.Bone, Reagent.SpidersSilk, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public EagleStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) diff --git a/Projects/Scripts/Spells/Mysticism/HailStormSpell.cs b/Projects/Scripts/Spells/Mysticism/HailStormSpell.cs index 53c2b8fa4..4c631cd55 100644 --- a/Projects/Scripts/Spells/Mysticism/HailStormSpell.cs +++ b/Projects/Scripts/Spells/Mysticism/HailStormSpell.cs @@ -6,15 +6,14 @@ namespace Server.Spells.Mysticism { public class HailStormSpell : MysticSpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Hail Storm", "Kal Des Ylem", -1, 9002, Reagent.DragonsBlood, Reagent.Bloodmoss, Reagent.BlackPearl, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public HailStormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) diff --git a/Projects/Scripts/Spells/Mysticism/MysticSpell.cs b/Projects/Scripts/Spells/Mysticism/MysticSpell.cs index 81ee230d3..16aeef6f4 100644 --- a/Projects/Scripts/Spells/Mysticism/MysticSpell.cs +++ b/Projects/Scripts/Spells/Mysticism/MysticSpell.cs @@ -9,8 +9,8 @@ namespace Server.Spells.Mysticism { } - public abstract double RequiredSkill{ get; } - public abstract int RequiredMana{ get; } + public abstract double RequiredSkill { get; } + public abstract int RequiredMana { get; } public override SkillName CastSkill => SkillName.Mysticism; diff --git a/Projects/Scripts/Spells/Mysticism/NetherCycloneSpell.cs b/Projects/Scripts/Spells/Mysticism/NetherCycloneSpell.cs index 36ec20616..86ab87e9c 100644 --- a/Projects/Scripts/Spells/Mysticism/NetherCycloneSpell.cs +++ b/Projects/Scripts/Spells/Mysticism/NetherCycloneSpell.cs @@ -6,15 +6,14 @@ namespace Server.Spells.Mysticism { public class NetherCycloneSpell : MysticSpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Nether Cyclone", "Grav Hur", -1, 9002, Reagent.MandrakeRoot, Reagent.Nightshade, Reagent.SulfurousAsh, - Reagent.Bloodmoss - ); + Reagent.Bloodmoss); public NetherCycloneSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) diff --git a/Projects/Scripts/Spells/Mysticism/SpellPlagueSpell.cs b/Projects/Scripts/Spells/Mysticism/SpellPlagueSpell.cs index 3d7a25653..cdf3fb3f1 100644 --- a/Projects/Scripts/Spells/Mysticism/SpellPlagueSpell.cs +++ b/Projects/Scripts/Spells/Mysticism/SpellPlagueSpell.cs @@ -6,17 +6,16 @@ namespace Server.Spells.Mysticism { public class SpellPlagueSpell : MysticSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Spell Plague", "Vas Rel Jux Ort", -1, 9002, Reagent.DaemonBone, Reagent.DragonsBlood, Reagent.Nightshade, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public SpellPlagueSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -111,8 +110,8 @@ namespace Server.Spells.Mysticism private int m_Explosions; private DateTime m_LastExploded; private SpellPlagueContext m_Next; - private SpellPlagueSpell m_Owner; - private Mobile m_Target; + private readonly SpellPlagueSpell m_Owner; + private readonly Mobile m_Target; private Timer m_Timer; public SpellPlagueContext(SpellPlagueSpell owner, Mobile target) @@ -191,7 +190,7 @@ namespace Server.Spells.Mysticism private class InternalTarget : Target { - private SpellPlagueSpell m_Owner; + private readonly SpellPlagueSpell m_Owner; public InternalTarget(SpellPlagueSpell owner) : base(12, false, TargetFlags.Harmful) => diff --git a/Projects/Scripts/Spells/Mysticism/StoneFormSpell.cs b/Projects/Scripts/Spells/Mysticism/StoneFormSpell.cs index d201509df..e367f6236 100644 --- a/Projects/Scripts/Spells/Mysticism/StoneFormSpell.cs +++ b/Projects/Scripts/Spells/Mysticism/StoneFormSpell.cs @@ -10,16 +10,15 @@ namespace Server.Spells.Mysticism { public class StoneFormSpell : MysticSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Stone Form", "In Rel Ylem", -1, 9002, Reagent.Bloodmoss, Reagent.FertileDirt, - Reagent.Garlic - ); + Reagent.Garlic); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public StoneFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -77,7 +76,7 @@ namespace Server.Spells.Mysticism { Caster.SendLocalizedMessage(1061628); // You can't do that while polymorphed. } - else if (!Caster.CanBeginAction() || Caster.IsBodyMod && !UnderEffect(Caster)) + else if (!Caster.CanBeginAction() || (Caster.IsBodyMod && !UnderEffect(Caster))) { Caster.SendLocalizedMessage(1063218); // You cannot use that ability in this form. } diff --git a/Projects/Scripts/Spells/Necromancy/AnimateDeadSpell.cs b/Projects/Scripts/Spells/Necromancy/AnimateDeadSpell.cs index 9895c59a4..47679d858 100644 --- a/Projects/Scripts/Spells/Necromancy/AnimateDeadSpell.cs +++ b/Projects/Scripts/Spells/Necromancy/AnimateDeadSpell.cs @@ -11,18 +11,17 @@ namespace Server.Spells.Necromancy { public class AnimateDeadSpell : NecromancerSpell, ISpellTargetingItem { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Animate Dead", "Uus Corp", 203, 9031, Reagent.GraveDust, - Reagent.DaemonBlood - ); + Reagent.DaemonBlood); - private static CreatureGroup[] m_Groups = + private static readonly CreatureGroup[] m_Groups = { // Undead group--empty - new CreatureGroup(SlayerGroup.GetEntryByName(SlayerName.Silver).Types, new SummonEntry[0]), + new CreatureGroup(SlayerGroup.GetEntryByName(SlayerName.Silver).Types, Array.Empty()), // Insects new CreatureGroup(new[] { @@ -81,7 +80,7 @@ namespace Server.Spells.Necromancy new SummonEntry(0, typeof(PatchworkSkeleton)) }), // Default group - new CreatureGroup(new Type[0], new[] + new CreatureGroup(Array.Empty(), new[] { new SummonEntry(18000, typeof(LichLord)), new SummonEntry(10000, typeof(FleshGolem)), @@ -93,7 +92,7 @@ namespace Server.Spells.Necromancy }) }; - private static Dictionary> m_Table = new Dictionary>(); + private static readonly Dictionary> m_Table = new Dictionary>(); public AnimateDeadSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -164,8 +163,8 @@ namespace Server.Spells.Necromancy if (c.Owner != null) type = c.Owner.GetType(); if (c.ItemID != 0x2006 || c.Animated || type == typeof(PlayerMobile) || type == null || - c.Owner != null && c.Owner.Fame < 100 || c.Owner is BaseCreature creature && - (creature.Summoned || creature.IsBonded)) + (c.Owner != null && c.Owner.Fame < 100) || + (c.Owner is BaseCreature creature && (creature.Summoned || creature.IsBonded))) { Caster.SendLocalizedMessage(1061085); // There's not enough life force there to animate. } @@ -350,8 +349,8 @@ namespace Server.Spells.Necromancy private class CreatureGroup { - public SummonEntry[] m_Entries; - public Type[] m_Types; + public readonly SummonEntry[] m_Entries; + public readonly Type[] m_Types; public CreatureGroup(Type[] types, SummonEntry[] entries) { @@ -362,8 +361,8 @@ namespace Server.Spells.Necromancy private class SummonEntry { - public int m_Requirement; - public Type[] m_ToSummon; + public readonly int m_Requirement; + public readonly Type[] m_ToSummon; public SummonEntry(int requirement, params Type[] toSummon) { diff --git a/Projects/Scripts/Spells/Necromancy/BloodOathSpell.cs b/Projects/Scripts/Spells/Necromancy/BloodOathSpell.cs index d30a5b2f6..75050b1eb 100644 --- a/Projects/Scripts/Spells/Necromancy/BloodOathSpell.cs +++ b/Projects/Scripts/Spells/Necromancy/BloodOathSpell.cs @@ -7,15 +7,14 @@ namespace Server.Spells.Necromancy { public class BloodOathSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Blood Oath", "In Jux Mani Xen", 203, 9031, - Reagent.DaemonBlood - ); + Reagent.DaemonBlood); - private static Dictionary m_OathTable = new Dictionary(); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_OathTable = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public BloodOathSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -76,7 +75,7 @@ namespace Server.Spells.Necromancy m.FixedParticles(0x3728, 1, 13, 9502, 33, 7, (EffectLayer)255); TimeSpan duration = TimeSpan.FromSeconds((GetDamageSkill(Caster) - GetResistSkill(m)) / 8 + 8); - m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); //Skill check for gain + m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); // Skill check for gain timer = new ExpireTimer(Caster, m, duration); timer.Start(); @@ -97,13 +96,13 @@ namespace Server.Spells.Necromancy t?.DoExpire(); } - public static Mobile GetBloodOath(Mobile m) => m == null || m_OathTable.TryGetValue(m, out Mobile oath) && oath == m ? null : oath; + public static Mobile GetBloodOath(Mobile m) => m == null || (m_OathTable.TryGetValue(m, out Mobile oath) && oath == m) ? null : oath; private class ExpireTimer : Timer { - private Mobile m_Caster; - private DateTime m_End; - private Mobile m_Target; + private readonly Mobile m_Caster; + private readonly DateTime m_End; + private readonly Mobile m_Target; public ExpireTimer(Mobile caster, Mobile target, TimeSpan delay) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Spells/Necromancy/CorpseSkin.cs b/Projects/Scripts/Spells/Necromancy/CorpseSkin.cs index 824f5f97b..d3a8d8149 100644 --- a/Projects/Scripts/Spells/Necromancy/CorpseSkin.cs +++ b/Projects/Scripts/Spells/Necromancy/CorpseSkin.cs @@ -6,15 +6,14 @@ namespace Server.Spells.Necromancy { public class CorpseSkinSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Corpse Skin", "In Agle Corp Ylem", 203, 9051, Reagent.BatWing, - Reagent.GraveDust - ); + Reagent.GraveDust); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public CorpseSkinSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -63,7 +62,7 @@ namespace Server.Spells.Necromancy double ss = GetDamageSkill(Caster); double mr = Caster == m ? 0.0 : GetResistSkill(m); - m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); //Skill check for gain + m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); // Skill check for gain TimeSpan duration = TimeSpan.FromSeconds((ss - mr) / 2.5 + 40.0); @@ -102,8 +101,8 @@ namespace Server.Spells.Necromancy private class ExpireTimer : Timer { - private Mobile m_Mobile; - private ResistanceMod[] m_Mods; + private readonly Mobile m_Mobile; + private readonly ResistanceMod[] m_Mods; public ExpireTimer(Mobile m, ResistanceMod[] mods, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Spells/Necromancy/CurseWeapon.cs b/Projects/Scripts/Spells/Necromancy/CurseWeapon.cs index fdce75d67..d733c7756 100644 --- a/Projects/Scripts/Spells/Necromancy/CurseWeapon.cs +++ b/Projects/Scripts/Spells/Necromancy/CurseWeapon.cs @@ -6,14 +6,13 @@ namespace Server.Spells.Necromancy { public class CurseWeaponSpell : NecromancerSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Curse Weapon", "An Sanct Gra Char", 203, 9031, - Reagent.PigIron - ); + Reagent.PigIron); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public CurseWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -63,7 +62,7 @@ namespace Server.Spells.Necromancy private class ExpireTimer : Timer { - private BaseWeapon m_Weapon; + private readonly BaseWeapon m_Weapon; public ExpireTimer(BaseWeapon weapon, TimeSpan delay) : base(delay) { @@ -81,7 +80,7 @@ namespace Server.Spells.Necromancy private class SoundEffectTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public SoundEffectTimer(Mobile m) : base(TimeSpan.FromSeconds(0.75)) { diff --git a/Projects/Scripts/Spells/Necromancy/EvilOmen.cs b/Projects/Scripts/Spells/Necromancy/EvilOmen.cs index d03192c0c..ec39bb179 100644 --- a/Projects/Scripts/Spells/Necromancy/EvilOmen.cs +++ b/Projects/Scripts/Spells/Necromancy/EvilOmen.cs @@ -7,15 +7,14 @@ namespace Server.Spells.Necromancy { public class EvilOmenSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Evil Omen", "Pas Tym An Sanct", 203, 9031, Reagent.BatWing, - Reagent.NoxCrystal - ); + Reagent.NoxCrystal); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public EvilOmenSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) diff --git a/Projects/Scripts/Spells/Necromancy/Exorcism.cs b/Projects/Scripts/Spells/Necromancy/Exorcism.cs index 9d7c8940d..db02bc6fb 100644 --- a/Projects/Scripts/Spells/Necromancy/Exorcism.cs +++ b/Projects/Scripts/Spells/Necromancy/Exorcism.cs @@ -12,13 +12,12 @@ namespace Server.Spells.Necromancy { public class ExorcismSpell : NecromancerSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Exorcism", "Ort Corp Grav", 203, 9031, Reagent.NoxCrystal, - Reagent.GraveDust - ); + Reagent.GraveDust); private static readonly int Range = Core.ML ? 48 : 18; @@ -67,7 +66,6 @@ namespace Server.Spells.Necromancy public override double RequiredSkill => 80.0; public override int RequiredMana => 40; - public override bool DelayedDamage => false; public override bool CheckCast() @@ -99,7 +97,7 @@ namespace Server.Spells.Necromancy IEnumerable targets = r.ChampionSpawn.GetMobilesInRange(Range).Where(IsValidTarget); foreach (Mobile m in targets) - //Surprisingly, no sparkle type effects + // Surprisingly, no sparkle type effects m.Location = GetNearestShrine(m); } } @@ -118,12 +116,12 @@ namespace Server.Spells.Necromancy if (c?.Deleted == false && map != null && c.Map == map) { if (SpellHelper.IsAnyT2A(map, c.Location) && SpellHelper.IsAnyT2A(map, m.Location)) - return false; //Same Map, both in T2A, ie, same 'sub server'. + return false; // Same Map, both in T2A, ie, same 'sub server'. if (m.Region.IsPartOf() == Region.Find(c.Location, map).IsPartOf()) - return false; //Same Map, both in Dungeon region OR They're both NOT in a dungeon region. + return false; // Same Map, both in Dungeon region OR They're both NOT in a dungeon region. - //Just an approximation cause RunUO doesn't divide up the world the same way OSI does ;p + // Just an approximation cause RunUO doesn't divide up the world the same way OSI does ;p } if (Party.Get(m)?.Contains(Caster) == true) @@ -143,7 +141,7 @@ namespace Server.Spells.Necromancy Faction f = Faction.Find(m); - return Faction.Facet != m.Map || f == null || f != Faction.Find(Caster); + return m.Map != Faction.Facet || f == null || f != Faction.Find(Caster); } private static Point3D GetNearestShrine(Mobile m) @@ -152,7 +150,6 @@ namespace Server.Spells.Necromancy Point3D[] locList; - if (map == Map.Felucca || map == Map.Trammel) locList = m_BritanniaLocs; else if (map == Map.Ilshenar) @@ -162,7 +159,7 @@ namespace Server.Spells.Necromancy else if (map == Map.Malas) locList = m_MalasLocs; else - locList = new Point3D[0]; + locList = Array.Empty(); Point3D closest = Point3D.Zero; double minDist = double.MaxValue; diff --git a/Projects/Scripts/Spells/Necromancy/HorrificBeast.cs b/Projects/Scripts/Spells/Necromancy/HorrificBeast.cs index dde8bb17b..372f45b6e 100644 --- a/Projects/Scripts/Spells/Necromancy/HorrificBeast.cs +++ b/Projects/Scripts/Spells/Necromancy/HorrificBeast.cs @@ -4,13 +4,12 @@ namespace Server.Spells.Necromancy { public class HorrificBeastSpell : TransformationSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Horrific Beast", "Rel Xen Vas Bal", 203, 9031, Reagent.BatWing, - Reagent.DaemonBlood - ); + Reagent.DaemonBlood); public HorrificBeastSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Necromancy/LichForm.cs b/Projects/Scripts/Spells/Necromancy/LichForm.cs index 6c36f8acb..42c6c6438 100644 --- a/Projects/Scripts/Spells/Necromancy/LichForm.cs +++ b/Projects/Scripts/Spells/Necromancy/LichForm.cs @@ -4,14 +4,13 @@ namespace Server.Spells.Necromancy { public class LichFormSpell : TransformationSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Lich Form", "Rel Xen Corp Ort", 203, 9031, Reagent.GraveDust, Reagent.DaemonBlood, - Reagent.NoxCrystal - ); + Reagent.NoxCrystal); public LichFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Necromancy/MindRot.cs b/Projects/Scripts/Spells/Necromancy/MindRot.cs index 7e5b282f9..b39917730 100644 --- a/Projects/Scripts/Spells/Necromancy/MindRot.cs +++ b/Projects/Scripts/Spells/Necromancy/MindRot.cs @@ -6,16 +6,15 @@ namespace Server.Spells.Necromancy { public class MindRotSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mind Rot", "Wis An Ben", 203, 9031, Reagent.BatWing, Reagent.PigIron, - Reagent.DaemonBlood - ); + Reagent.DaemonBlood); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public MindRotSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -55,7 +54,7 @@ namespace Server.Spells.Necromancy TimeSpan duration = TimeSpan.FromSeconds( ((GetDamageSkill(Caster) - GetResistSkill(m)) / 5.0 + 20.0) * (m.Player ? 1.0 : 2.0)); - m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); //Skill check for gain + m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); // Skill check for gain SetMindRotScalar(Caster, m, m.Player ? 1.25 : 2.00, duration); @@ -104,8 +103,8 @@ namespace Server.Spells.Necromancy public class MRExpireTimer : Timer { - private DateTime m_End; - private Mobile m_Target; + private readonly DateTime m_End; + private readonly Mobile m_Target; public MRExpireTimer(Mobile caster, Mobile target, TimeSpan delay) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Spells/Necromancy/NecromancerSpell.cs b/Projects/Scripts/Spells/Necromancy/NecromancerSpell.cs index 0ff7ccb7f..eaa58497c 100644 --- a/Projects/Scripts/Spells/Necromancy/NecromancerSpell.cs +++ b/Projects/Scripts/Spells/Necromancy/NecromancerSpell.cs @@ -8,13 +8,13 @@ namespace Server.Spells.Necromancy { } - public abstract double RequiredSkill{ get; } - public abstract int RequiredMana{ get; } + public abstract double RequiredSkill { get; } + public abstract int RequiredMana { get; } public override SkillName CastSkill => SkillName.Necromancy; public override SkillName DamageSkill => SkillName.SpiritSpeak; - //public override int CastDelayBase => base.CastDelayBase; // Reference, 3 + // public override int CastDelayBase => base.CastDelayBase; // Reference, 3 public override bool ClearHandsOnCast => false; @@ -25,12 +25,11 @@ namespace Server.Spells.Necromancy public override int ComputeKarmaAward() { - //TODO: Verify this formula being that Necro spells don't HAVE a circle. - //int karma = -(70 + (10 * (int)Circle)); + // TODO: Verify this formula being that Necro spells don't HAVE a circle. + // int karma = -(70 + (10 * (int)Circle)); int karma = -(40 + (int)(10 * (CastDelayBase.TotalSeconds / CastDelaySecondsPerTick))); - if (Core.ML - ) // Pub 36: "Added a new property called Increased Karma Loss which grants higher karma loss for casting necromancy spells." + if (Core.ML) // Pub 36: "Added a new property called Increased Karma Loss which grants higher karma loss for casting necromancy spells." karma += AOS.Scale(karma, AosAttributes.GetValue(Caster, AosAttribute.IncreasedKarmaLoss)); return karma; diff --git a/Projects/Scripts/Spells/Necromancy/PainSpike.cs b/Projects/Scripts/Spells/Necromancy/PainSpike.cs index 79b03d0f0..c9e563d8e 100644 --- a/Projects/Scripts/Spells/Necromancy/PainSpike.cs +++ b/Projects/Scripts/Spells/Necromancy/PainSpike.cs @@ -7,15 +7,14 @@ namespace Server.Spells.Necromancy { public class PainSpikeSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Pain Spike", "In Sar", 203, 9031, Reagent.GraveDust, - Reagent.PigIron - ); + Reagent.PigIron); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public PainSpikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -42,7 +41,7 @@ namespace Server.Spells.Necromancy { SpellHelper.Turn(Caster, m); - //SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); //Irrelevent after AoS + // SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); //Irrelevent after AoS /* Temporarily causes intense physical pain to the target, dealing direct damage. * After 10 seconds the spell wears off, and if the target is still alive, @@ -54,7 +53,7 @@ namespace Server.Spells.Necromancy m.PlaySound(0x210); double damage = (GetDamageSkill(Caster) - GetResistSkill(m)) / 10 + (m.Player ? 18 : 30); - m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); //Skill check for gain + m.CheckSkill(SkillName.MagicResist, 0.0, 120.0); // Skill check for gain if (damage < 1) damage = 1; @@ -81,7 +80,7 @@ namespace Server.Spells.Necromancy SpellHelper.DoLeech((int)damage, Caster, m); WeightOverloading.DFA = DFAlgorithm.Standard; - //SpellHelper.Damage( this, m, damage, 100, 0, 0, 0, 0, Misc.DFAlgorithm.PainSpike ); + // SpellHelper.Damage( this, m, damage, 100, 0, 0, 0, 0, Misc.DFAlgorithm.PainSpike ); HarmfulSpell(m); } @@ -90,8 +89,8 @@ namespace Server.Spells.Necromancy private class InternalTimer : Timer { - private Mobile m_Mobile; - private int m_ToRestore; + private readonly Mobile m_Mobile; + private readonly int m_ToRestore; public InternalTimer(Mobile m, double toRestore) : base(TimeSpan.FromSeconds(10.0)) { diff --git a/Projects/Scripts/Spells/Necromancy/PoisonStrike.cs b/Projects/Scripts/Spells/Necromancy/PoisonStrike.cs index 98b82aa40..da804d8e2 100644 --- a/Projects/Scripts/Spells/Necromancy/PoisonStrike.cs +++ b/Projects/Scripts/Spells/Necromancy/PoisonStrike.cs @@ -9,12 +9,11 @@ namespace Server.Spells.Necromancy { public class PoisonStrikeSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Poison Strike", "In Vas Nox", 203, 9031, - Reagent.NoxCrystal - ); + Reagent.NoxCrystal); public PoisonStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -47,7 +46,9 @@ namespace Server.Spells.Necromancy * One tile from main target receives 50% damage, two tiles from target receives 33% damage. */ - //CheckResisted( m ); // Check magic resist for skill, but do not use return value //reports from OSI: Necro spells don't give Resist gain + // CheckResisted( m ); + // Check magic resist for skill, but do not use return value + // reports from OSI: Necro spells don't give Resist gain Effects.SendLocationParticles(EffectItem.Create(m.Location, m.Map, EffectItem.DefaultDuration), 0x36B0, 1, 14, 63, 7, 9915, 0); diff --git a/Projects/Scripts/Spells/Necromancy/Strangle.cs b/Projects/Scripts/Spells/Necromancy/Strangle.cs index 5d02a6627..5a8c2ccfd 100644 --- a/Projects/Scripts/Spells/Necromancy/Strangle.cs +++ b/Projects/Scripts/Spells/Necromancy/Strangle.cs @@ -6,15 +6,14 @@ namespace Server.Spells.Necromancy { public class StrangleSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Strangle", "In Bal Nox", 209, 9031, Reagent.DaemonBlood, - Reagent.NoxCrystal - ); + Reagent.NoxCrystal); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public StrangleSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -39,7 +38,8 @@ namespace Server.Spells.Necromancy { SpellHelper.Turn(Caster, m); - //SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); //Irrelevent after AoS + // SpellHelper.CheckReflect( (int)this.Circle, Caster, ref m ); + // Irrelevent after AoS /* Temporarily chokes off the air suply of the target with poisonous fumes. * The target is inflicted with poison damage over time. @@ -70,7 +70,7 @@ namespace Server.Spells.Necromancy HarmfulSpell(m); } - //Calculations for the buff bar + // Calculations for the buff bar double spiritlevel = Caster.Skills.SpiritSpeak.Value / 10; if (spiritlevel < 4) spiritlevel = 4; @@ -123,12 +123,15 @@ namespace Server.Spells.Necromancy private class InternalTimer : Timer { - private int m_Count, m_MaxCount; + private int m_Count; + private readonly int m_MaxCount; private int m_HitDelay; - private double m_MinBaseDamage, m_MaxBaseDamage; + private readonly double m_MinBaseDamage; + private readonly double m_MaxBaseDamage; private DateTime m_NextHit; - private Mobile m_Target, m_From; + private readonly Mobile m_Target; + private readonly Mobile m_From; public InternalTimer(Mobile target, Mobile from) : base(TimeSpan.FromSeconds(0.1), TimeSpan.FromSeconds(0.1)) { @@ -205,8 +208,7 @@ namespace Server.Spells.Necromancy AOS.Damage(m_Target, m_From, (int)damage, 0, 0, 0, 100, 0); - if (0.60 <= Utility.RandomDouble() - ) // OSI: randomly revealed between first and third damage tick, guessing 60% chance + if (Utility.RandomDouble() >= 0.60) // OSI: randomly revealed between first and third damage tick, guessing 60% chance m_Target.RevealingAction(); } } diff --git a/Projects/Scripts/Spells/Necromancy/SummonFamiliar.cs b/Projects/Scripts/Spells/Necromancy/SummonFamiliar.cs index a72cfcde5..1d39ea97e 100644 --- a/Projects/Scripts/Spells/Necromancy/SummonFamiliar.cs +++ b/Projects/Scripts/Spells/Necromancy/SummonFamiliar.cs @@ -9,14 +9,13 @@ namespace Server.Spells.Necromancy { public class SummonFamiliarSpell : NecromancerSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Summon Familiar", "Kal Xen Bal", 203, 9031, Reagent.BatWing, Reagent.GraveDust, - Reagent.DaemonBlood - ); + Reagent.DaemonBlood); public SummonFamiliarSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -27,9 +26,9 @@ namespace Server.Spells.Necromancy public override double RequiredSkill => 30.0; public override int RequiredMana => 17; - public static Dictionary Table{ get; } = new Dictionary(); + public static Dictionary Table { get; } = new Dictionary(); - public static SummonFamiliarEntry[] Entries{ get; } = + public static SummonFamiliarEntry[] Entries { get; } = { new SummonFamiliarEntry(typeof(HordeMinionFamiliar), 1060146, 30.0, 30.0), // Horde Minion new SummonFamiliarEntry(typeof(ShadowWispFamiliar), 1060142, 50.0, 50.0), // Shadow Wisp @@ -69,13 +68,13 @@ namespace Server.Spells.Necromancy ReqSpiritSpeak = reqSpiritSpeak; } - public Type Type{ get; } + public Type Type { get; } - public object Name{ get; } + public object Name { get; } - public double ReqNecromancy{ get; } + public double ReqNecromancy { get; } - public double ReqSpiritSpeak{ get; } + public double ReqSpiritSpeak { get; } } public class SummonFamiliarGump : Gump @@ -86,10 +85,10 @@ namespace Server.Spells.Necromancy private const int EnabledColor32 = 0x18CD00; private const int DisabledColor32 = 0x4A8B52; - private SummonFamiliarEntry[] m_Entries; - private Mobile m_From; + private readonly SummonFamiliarEntry[] m_Entries; + private readonly Mobile m_From; - private SummonFamiliarSpell m_Spell; + private readonly SummonFamiliarSpell m_Spell; public SummonFamiliarGump(Mobile from, SummonFamiliarEntry[] entries, SummonFamiliarSpell spell) : base(200, 100) { @@ -143,11 +142,9 @@ namespace Server.Spells.Necromancy double necro = m_From.Skills.Necromancy.Value; double spirit = m_From.Skills.SpiritSpeak.Value; - #region Dueling if ((m_From as PlayerMobile)?.DuelContext?.AllowSpellCast(m_From, m_Spell) == false) { } - #endregion else if (SummonFamiliarSpell.Table.TryGetValue(m_From, out BaseCreature check) && check?.Deleted == false) { m_From.SendLocalizedMessage(1061605); // You already have a familiar. diff --git a/Projects/Scripts/Spells/Necromancy/TransformationSpell.cs b/Projects/Scripts/Spells/Necromancy/TransformationSpell.cs index a97434930..b0f9c2fcc 100644 --- a/Projects/Scripts/Spells/Necromancy/TransformationSpell.cs +++ b/Projects/Scripts/Spells/Necromancy/TransformationSpell.cs @@ -7,7 +7,7 @@ namespace Server.Spells.Necromancy } public override bool BlockedByHorrificBeast => false; - public abstract int Body{ get; } + public abstract int Body { get; } public virtual int Hue => 0; public virtual int PhysResistOffset => 0; diff --git a/Projects/Scripts/Spells/Necromancy/VampiricEmbrace.cs b/Projects/Scripts/Spells/Necromancy/VampiricEmbrace.cs index 0ae64c73b..0b87d493b 100644 --- a/Projects/Scripts/Spells/Necromancy/VampiricEmbrace.cs +++ b/Projects/Scripts/Spells/Necromancy/VampiricEmbrace.cs @@ -5,14 +5,13 @@ namespace Server.Spells.Necromancy { public class VampiricEmbraceSpell : TransformationSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Vampiric Embrace", "Rel Xen An Sanct", 203, 9031, Reagent.BatWing, Reagent.NoxCrystal, - Reagent.PigIron - ); + Reagent.PigIron); public VampiricEmbraceSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Necromancy/VengefulSpirit.cs b/Projects/Scripts/Spells/Necromancy/VengefulSpirit.cs index ff8d8c7eb..8c7900f2b 100644 --- a/Projects/Scripts/Spells/Necromancy/VengefulSpirit.cs +++ b/Projects/Scripts/Spells/Necromancy/VengefulSpirit.cs @@ -6,14 +6,13 @@ namespace Server.Spells.Necromancy { public class VengefulSpiritSpell : NecromancerSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Vengeful Spirit", "Kal Xen Bal Beh", 203, 9031, Reagent.BatWing, Reagent.GraveDust, - Reagent.PigIron - ); + Reagent.PigIron); public VengefulSpiritSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Necromancy/Wither.cs b/Projects/Scripts/Spells/Necromancy/Wither.cs index 6b9ba0408..12e6eb9ee 100644 --- a/Projects/Scripts/Spells/Necromancy/Wither.cs +++ b/Projects/Scripts/Spells/Necromancy/Wither.cs @@ -7,14 +7,13 @@ namespace Server.Spells.Necromancy { public class WitherSpell : NecromancerSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Wither", "Kal Vas An Flam", 203, 9031, Reagent.NoxCrystal, Reagent.GraveDust, - Reagent.PigIron - ); + Reagent.PigIron); public WitherSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -93,8 +92,8 @@ namespace Server.Spells.Necromancy damage /= 100; // TODO: cap? - //if ( damage > 40 ) - // damage = 40; + // if (damage > 40) + // damage = 40; SpellHelper.Damage(this, m, damage, 0, 0, 100, 0, 0); } diff --git a/Projects/Scripts/Spells/Necromancy/WraithForm.cs b/Projects/Scripts/Spells/Necromancy/WraithForm.cs index 81833224d..6c417e996 100644 --- a/Projects/Scripts/Spells/Necromancy/WraithForm.cs +++ b/Projects/Scripts/Spells/Necromancy/WraithForm.cs @@ -5,13 +5,12 @@ namespace Server.Spells.Necromancy { public class WraithFormSpell : TransformationSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Wraith Form", "Rel Xen Um", 203, 9031, Reagent.NoxCrystal, - Reagent.PigIron - ); + Reagent.PigIron); public WraithFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Ninjitsu/AnimalForm.cs b/Projects/Scripts/Spells/Ninjitsu/AnimalForm.cs index e35548464..eca42db42 100644 --- a/Projects/Scripts/Spells/Ninjitsu/AnimalForm.cs +++ b/Projects/Scripts/Spells/Ninjitsu/AnimalForm.cs @@ -18,14 +18,13 @@ namespace Server.Spells.Ninjitsu NoSkill } - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Animal Form", null, -1, - 9002 - ); + 9002); - private static Dictionary m_LastAnimalForms = new Dictionary(); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_LastAnimalForms = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); private bool m_WasMoving; @@ -42,7 +41,7 @@ namespace Server.Spells.Ninjitsu public override bool BlockedByAnimalForm => false; - public static AnimalFormEntry[] Entries{ get; } = + public static AnimalFormEntry[] Entries { get; } = { new AnimalFormEntry(typeof(Kirin), 1029632, 9632, 0, 1070811, 100.0, 0x84, 0, 0), new AnimalFormEntry(typeof(Unicorn), 1018214, 9678, 0, 1070812, 100.0, 0x7A, 0, 0), @@ -120,7 +119,7 @@ namespace Server.Spells.Ninjitsu { Caster.SendLocalizedMessage(1063219); // You cannot mimic an animal while in that form. } - else if (!Caster.CanBeginAction() || Caster.IsBodyMod && GetContext(Caster) == null) + else if (!Caster.CanBeginAction() || (Caster.IsBodyMod && GetContext(Caster) == null)) { DoFizzle(); } @@ -187,7 +186,7 @@ namespace Server.Spells.Ninjitsu AnimalFormEntry entry = Entries[entryID]; - m_LastAnimalForms[m] = entryID; //On OSI, it's the last /attempted/ one not the last succeeded one + m_LastAnimalForms[m] = entryID; // On OSI, it's the last /attempted/ one not the last succeeded one if (m.Skills.Ninjitsu.Value < entry.ReqSkill) { @@ -198,7 +197,7 @@ namespace Server.Spells.Ninjitsu } /* - if ( !m.CheckSkill( SkillName.Ninjitsu, entry.ReqSkill, entry.ReqSkill + 37.5 ) ) + if (!m.CheckSkill( SkillName.Ninjitsu, entry.ReqSkill, entry.ReqSkill + 37.5 )) return MorphResult.Fail; * * On OSI,it seems you can only gain starting at '0' using Animal form. @@ -311,9 +310,9 @@ namespace Server.Spells.Ninjitsu public class AnimalFormEntry { - private int m_HueModMax; + private readonly int m_HueModMax; - private int m_HueModMin; + private readonly int m_HueModMin; /* private AnimalFormCallback m_TransformCallback; private AnimalFormCallback m_UntransformCallback; @@ -337,33 +336,33 @@ namespace Server.Spells.Ninjitsu StealingBonus = stealingBonus; } - public Type Type{ get; } + public Type Type { get; } - public TextDefinition Name{ get; } + public TextDefinition Name { get; } - public int ItemID{ get; } + public int ItemID { get; } - public int Hue{ get; } + public int Hue { get; } - public int Tooltip{ get; } + public int Tooltip { get; } - public double ReqSkill{ get; } + public double ReqSkill { get; } - public int BodyMod{ get; } + public int BodyMod { get; } public int HueMod => Utility.RandomMinMax(m_HueModMin, m_HueModMax); - public bool StealthBonus{ get; } + public bool StealthBonus { get; } - public bool SpeedBoost{ get; } + public bool SpeedBoost { get; } - public bool StealingBonus{ get; } + public bool StealingBonus { get; } } public class AnimalFormGump : Gump { - //TODO: Convert this for ML to the BaseImageTileButtonsGump - private Mobile m_Caster; - private AnimalForm m_Spell; + // TODO: Convert this for ML to the BaseImageTileButtonsGump + private readonly Mobile m_Caster; + private readonly AnimalForm m_Spell; public AnimalFormGump(Mobile caster, AnimalFormEntry[] entries, AnimalForm spell) : base(50, 50) @@ -449,14 +448,9 @@ namespace Server.Spells.Ninjitsu } else if (BaseFormTalisman.EntryEnabled(sender.Mobile, entry.Type)) { - #region Dueling - if ((m_Caster as PlayerMobile)?.DuelContext?.AllowSpellCast(m_Caster, m_Spell) == false) { } - - #endregion - else if (Morph(m_Caster, entryID) == MorphResult.Fail) { m_Caster.LocalOverheadMessage(MessageType.Regular, 0x3B2, 502632); // The spell fizzles. @@ -484,24 +478,24 @@ namespace Server.Spells.Ninjitsu StealingMod = stealingMod; } - public Timer Timer{ get; } + public Timer Timer { get; } - public SkillMod Mod{ get; } + public SkillMod Mod { get; } - public bool SpeedBoost{ get; } + public bool SpeedBoost { get; } - public Type Type{ get; } + public Type Type { get; } - public SkillMod StealingMod{ get; } + public SkillMod StealingMod { get; } } public class AnimalFormTimer : Timer { - private int m_Body; + private readonly int m_Body; private int m_Counter; - private int m_Hue; + private readonly int m_Hue; private Mobile m_LastTarget; - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public AnimalFormTimer(Mobile from, int body, int hue) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) diff --git a/Projects/Scripts/Spells/Ninjitsu/Backstab.cs b/Projects/Scripts/Spells/Ninjitsu/Backstab.cs index 5e19f08cb..aa7d225c5 100644 --- a/Projects/Scripts/Spells/Ninjitsu/Backstab.cs +++ b/Projects/Scripts/Spells/Ninjitsu/Backstab.cs @@ -38,7 +38,7 @@ namespace Server.Spells.Ninjitsu if (valid) { attacker.BeginAction(); - Timer.DelayCall(TimeSpan.FromSeconds(5.0), delegate { attacker.EndAction(); }); + Timer.DelayCall(TimeSpan.FromSeconds(5.0), attacker.EndAction); } return valid; @@ -46,7 +46,7 @@ namespace Server.Spells.Ninjitsu public override void OnHit(Mobile attacker, Mobile defender, int damage) { - //Validates before swing + // Validates before swing ClearCurrentMove(attacker); @@ -68,4 +68,4 @@ namespace Server.Spells.Ninjitsu attacker.RevealingAction(); } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Spells/Ninjitsu/DeathStrike.cs b/Projects/Scripts/Spells/Ninjitsu/DeathStrike.cs index 1253e4821..cbe9913e8 100644 --- a/Projects/Scripts/Spells/Ninjitsu/DeathStrike.cs +++ b/Projects/Scripts/Spells/Ninjitsu/DeathStrike.cs @@ -7,7 +7,7 @@ namespace Server.Spells.Ninjitsu { public class DeathStrike : NinjaMove { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 30; public override double RequiredSkill => 85.0; @@ -31,7 +31,7 @@ namespace Server.Spells.Ninjitsu // TODO: should be defined onHit method, what if the player hit and remove the weapon before process? ;) bool isRanged = attacker.Weapon is BaseRanged; - if (ninjitsu < 100) //This formula is an approximation from OSI data. TODO: find correct formula + if (ninjitsu < 100) // This formula is an approximation from OSI data. TODO: find correct formula chance = 30 + (ninjitsu - 85) * 2.2; else chance = 63 + (ninjitsu - 100) * 1.1; @@ -130,11 +130,11 @@ namespace Server.Spells.Ninjitsu private class DeathStrikeInfo { - public Mobile m_Attacker; - public int m_DamageBonus; - public bool m_isRanged; + public readonly Mobile m_Attacker; + public readonly int m_DamageBonus; + public readonly bool m_isRanged; public int m_Steps; - public Mobile m_Target; + public readonly Mobile m_Target; public Timer m_Timer; public DeathStrikeInfo(Mobile target, Mobile attacker, int damageBonus, bool isRanged) diff --git a/Projects/Scripts/Spells/Ninjitsu/KiAttack.cs b/Projects/Scripts/Spells/Ninjitsu/KiAttack.cs index e785a4827..85db3f1e8 100644 --- a/Projects/Scripts/Spells/Ninjitsu/KiAttack.cs +++ b/Projects/Scripts/Spells/Ninjitsu/KiAttack.cs @@ -6,7 +6,7 @@ namespace Server.Spells.Ninjitsu { public class KiAttack : NinjaMove { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 25; public override double RequiredSkill => 80.0; @@ -116,7 +116,7 @@ namespace Server.Spells.Ninjitsu private class KiAttackInfo { public Point3D m_Location; - public Mobile m_Mobile; + public readonly Mobile m_Mobile; public Timer m_Timer; public KiAttackInfo(Mobile m) diff --git a/Projects/Scripts/Spells/Ninjitsu/MirrorImage.cs b/Projects/Scripts/Spells/Ninjitsu/MirrorImage.cs index a932a5b21..86f516cf4 100644 --- a/Projects/Scripts/Spells/Ninjitsu/MirrorImage.cs +++ b/Projects/Scripts/Spells/Ninjitsu/MirrorImage.cs @@ -10,13 +10,12 @@ namespace Server.Spells.Ninjitsu { public class MirrorImage : NinjaSpell { - private static Dictionary m_CloneCount = new Dictionary(); + private static readonly Dictionary m_CloneCount = new Dictionary(); - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mirror Image", null, -1, - 9002 - ); + 9002); public MirrorImage(Mobile caster, Item scroll) : base(caster, scroll, m_Info) { @@ -225,7 +224,6 @@ namespace Server.Mobiles } } - namespace Server.Mobiles { public class CloneAI : BaseAI diff --git a/Projects/Scripts/Spells/Ninjitsu/NinjaMove.cs b/Projects/Scripts/Spells/Ninjitsu/NinjaMove.cs index 622d6e4e2..c7fcb05f4 100644 --- a/Projects/Scripts/Spells/Ninjitsu/NinjaMove.cs +++ b/Projects/Scripts/Spells/Ninjitsu/NinjaMove.cs @@ -6,7 +6,7 @@ namespace Server.Spells public override void CheckGain(Mobile m) { - m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5); //Per five on friday 02/16/07 + m.CheckSkill(MoveSkill, RequiredSkill - 12.5, RequiredSkill + 37.5); // Per five on friday 02/16/07 } } } \ No newline at end of file diff --git a/Projects/Scripts/Spells/Ninjitsu/NinjaSpell.cs b/Projects/Scripts/Spells/Ninjitsu/NinjaSpell.cs index 33e7fa06f..410de4220 100644 --- a/Projects/Scripts/Spells/Ninjitsu/NinjaSpell.cs +++ b/Projects/Scripts/Spells/Ninjitsu/NinjaSpell.cs @@ -8,8 +8,8 @@ namespace Server.Spells.Ninjitsu { } - public abstract double RequiredSkill{ get; } - public abstract int RequiredMana{ get; } + public abstract double RequiredSkill { get; } + public abstract int RequiredMana { get; } public override SkillName CastSkill => SkillName.Ninjitsu; public override SkillName DamageSkill => SkillName.Ninjitsu; @@ -20,7 +20,7 @@ namespace Server.Spells.Ninjitsu public override bool BlocksMovement => false; - //public override int CastDelayBase => 1; + // public override int CastDelayBase => 1; public override int CastRecoveryBase => 7; @@ -85,7 +85,7 @@ namespace Server.Spells.Ninjitsu public override void GetCastSkills(out double min, out double max) { - min = RequiredSkill - 12.5; //Per 5 on friday 2/16/07 + min = RequiredSkill - 12.5; // Per 5 on friday 2/16/07 max = RequiredSkill + 37.5; } diff --git a/Projects/Scripts/Spells/Ninjitsu/ShadowJump.cs b/Projects/Scripts/Spells/Ninjitsu/ShadowJump.cs index 1d8abb93b..66b513a6b 100644 --- a/Projects/Scripts/Spells/Ninjitsu/ShadowJump.cs +++ b/Projects/Scripts/Spells/Ninjitsu/ShadowJump.cs @@ -11,11 +11,10 @@ namespace Server.Spells.Ninjitsu { public class Shadowjump : NinjaSpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Shadowjump", null, -1, - 9002 - ); + 9002); public Shadowjump(Mobile caster, Item scroll) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Ninjitsu/SurpriseAttack.cs b/Projects/Scripts/Spells/Ninjitsu/SurpriseAttack.cs index 57669d273..225e9034e 100644 --- a/Projects/Scripts/Spells/Ninjitsu/SurpriseAttack.cs +++ b/Projects/Scripts/Spells/Ninjitsu/SurpriseAttack.cs @@ -6,7 +6,7 @@ namespace Server.Spells.Ninjitsu { public class SurpriseAttack : NinjaMove { - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public override int BaseMana => 20; public override double RequiredSkill => Core.ML ? 60.0 : 30.0; @@ -33,7 +33,7 @@ namespace Server.Spells.Ninjitsu if (valid) { attacker.BeginAction(); - Timer.DelayCall(TimeSpan.FromSeconds(5.0), delegate { attacker.EndAction(); }); + Timer.DelayCall(TimeSpan.FromSeconds(5.0), attacker.EndAction); } return valid; @@ -41,7 +41,7 @@ namespace Server.Spells.Ninjitsu public override void OnHit(Mobile attacker, Mobile defender, int damage) { - //Validates before swing + // Validates before swing ClearCurrentMove(attacker); @@ -99,8 +99,8 @@ namespace Server.Spells.Ninjitsu private class SurpriseAttackInfo { - public int m_Malus; - public Mobile m_Target; + public readonly int m_Malus; + public readonly Mobile m_Target; public Timer m_Timer; public SurpriseAttackInfo(Mobile target, int effect) diff --git a/Projects/Scripts/Spells/Reagent.cs b/Projects/Scripts/Spells/Reagent.cs index 8b0a7e0ac..105a2511d 100644 --- a/Projects/Scripts/Spells/Reagent.cs +++ b/Projects/Scripts/Spells/Reagent.cs @@ -5,7 +5,7 @@ namespace Server.Spells { public class Reagent { - private static Type[] m_Types = + private static readonly Type[] m_Types = { typeof(BlackPearl), typeof(Bloodmoss), diff --git a/Projects/Scripts/Spells/Second/Agility.cs b/Projects/Scripts/Spells/Second/Agility.cs index ce8b7e4c0..1320f8ac3 100644 --- a/Projects/Scripts/Spells/Second/Agility.cs +++ b/Projects/Scripts/Spells/Second/Agility.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Second { public class AgilitySpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Agility", "Ex Uus", 212, 9061, Reagent.Bloodmoss, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public AgilitySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Second/Cunning.cs b/Projects/Scripts/Spells/Second/Cunning.cs index fac065ce5..35926c117 100644 --- a/Projects/Scripts/Spells/Second/Cunning.cs +++ b/Projects/Scripts/Spells/Second/Cunning.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Second { public class CunningSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Cunning", "Uus Wis", 212, 9061, Reagent.MandrakeRoot, - Reagent.Nightshade - ); + Reagent.Nightshade); public CunningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Second/Cure.cs b/Projects/Scripts/Spells/Second/Cure.cs index a880d5984..3d6f9dadc 100644 --- a/Projects/Scripts/Spells/Second/Cure.cs +++ b/Projects/Scripts/Spells/Second/Cure.cs @@ -5,13 +5,12 @@ namespace Server.Spells.Second { public class CureSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Cure", "An Nox", 212, 9061, Reagent.Garlic, - Reagent.Ginseng - ); + Reagent.Ginseng); public CureSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Second/Harm.cs b/Projects/Scripts/Spells/Second/Harm.cs index 714022933..cc2a170e4 100644 --- a/Projects/Scripts/Spells/Second/Harm.cs +++ b/Projects/Scripts/Spells/Second/Harm.cs @@ -4,13 +4,12 @@ namespace Server.Spells.Second { public class HarmSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Harm", "An Mani", 212, Core.AOS ? 9001 : 9041, Reagent.Nightshade, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public HarmSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Second/MagicTrap.cs b/Projects/Scripts/Spells/Second/MagicTrap.cs index 232310a28..111cdf090 100644 --- a/Projects/Scripts/Spells/Second/MagicTrap.cs +++ b/Projects/Scripts/Spells/Second/MagicTrap.cs @@ -5,14 +5,13 @@ namespace Server.Spells.Second { public class MagicTrapSpell : MagerySpell, ISpellTargetingItem { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Magic Trap", "In Jux", 212, 9001, Reagent.Garlic, Reagent.SpidersSilk, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public MagicTrapSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -35,7 +34,7 @@ namespace Server.Spells.Second } else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap) { - base.DoFizzle(); + this.DoFizzle(); } else if (CheckSequence()) { diff --git a/Projects/Scripts/Spells/Second/Protection.cs b/Projects/Scripts/Spells/Second/Protection.cs index f4587ed26..172c3c457 100644 --- a/Projects/Scripts/Spells/Second/Protection.cs +++ b/Projects/Scripts/Spells/Second/Protection.cs @@ -5,22 +5,21 @@ namespace Server.Spells.Second { public class ProtectionSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Protection", "Uus Sanct", 236, 9011, Reagent.Garlic, Reagent.Ginseng, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); - private static Dictionary> m_Table = new Dictionary>(); + private static readonly Dictionary> m_Table = new Dictionary>(); public ProtectionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { } - public static Dictionary Registry{ get; } = new Dictionary(); + public static Dictionary Registry { get; } = new Dictionary(); public override SpellCircle Circle => SpellCircle.Second; @@ -40,7 +39,6 @@ namespace Server.Spells.Second Caster.SendLocalizedMessage(1005385); // The spell will not adhere to you at this time. return false; - } public static void Toggle(Mobile caster, Mobile target) @@ -63,8 +61,7 @@ namespace Server.Spells.Second new ResistanceMod(ResistanceType.Physical, -15 + Math.Min((int)(caster.Skills.Inscribe.Value / 20), 15)), new DefaultSkillMod(SkillName.MagicResist, true, - -35 + Math.Min((int)(caster.Skills.Inscribe.Value / 20), 35)) - ); + -35 + Math.Min((int)(caster.Skills.Inscribe.Value / 20), 35))); m_Table[target] = mods; Registry[target] = 100.0; @@ -157,7 +154,7 @@ namespace Server.Spells.Second private class InternalTimer : Timer { - private Mobile m_Caster; + private readonly Mobile m_Caster; public InternalTimer(Mobile caster) : base(TimeSpan.FromSeconds(0)) { diff --git a/Projects/Scripts/Spells/Second/RemoveTrap.cs b/Projects/Scripts/Spells/Second/RemoveTrap.cs index 340b6e8f1..c600aaa26 100644 --- a/Projects/Scripts/Spells/Second/RemoveTrap.cs +++ b/Projects/Scripts/Spells/Second/RemoveTrap.cs @@ -5,13 +5,12 @@ namespace Server.Spells.Second { public class RemoveTrapSpell : MagerySpell, ISpellTargetingItem { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Remove Trap", "An Jux", 212, 9001, Reagent.Bloodmoss, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public RemoveTrapSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -35,7 +34,7 @@ namespace Server.Spells.Second } else if (cont.TrapType != TrapType.None && cont.TrapType != TrapType.MagicTrap) { - base.DoFizzle(); + this.DoFizzle(); } else if (CheckSequence()) { diff --git a/Projects/Scripts/Spells/Second/Strength.cs b/Projects/Scripts/Spells/Second/Strength.cs index bc05a93ff..31ea36f66 100644 --- a/Projects/Scripts/Spells/Second/Strength.cs +++ b/Projects/Scripts/Spells/Second/Strength.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Second { public class StrengthSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Strength", "Uus Mani", 212, 9061, Reagent.MandrakeRoot, - Reagent.Nightshade - ); + Reagent.Nightshade); public StrengthSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Seventh/ChainLightning.cs b/Projects/Scripts/Spells/Seventh/ChainLightning.cs index 9609f56f3..dee4bdac8 100644 --- a/Projects/Scripts/Spells/Seventh/ChainLightning.cs +++ b/Projects/Scripts/Spells/Seventh/ChainLightning.cs @@ -6,7 +6,7 @@ namespace Server.Spells.Seventh { public class ChainLightningSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Chain Lightning", "Vas Ort Grav", 209, 9022, @@ -14,8 +14,7 @@ namespace Server.Spells.Seventh Reagent.BlackPearl, Reagent.Bloodmoss, Reagent.MandrakeRoot, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public ChainLightningSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -55,7 +54,7 @@ namespace Server.Spells.Seventh targets.AddRange(eable.Where(m => { - if (Core.AOS && (m == Caster || !Caster.InLOS(m)) || !SpellHelper.ValidIndirectTarget(Caster, m) || + if ((Core.AOS && (m == Caster || !Caster.InLOS(m))) || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false)) return false; diff --git a/Projects/Scripts/Spells/Seventh/EnergyField.cs b/Projects/Scripts/Spells/Seventh/EnergyField.cs index abe73f706..546e9fa88 100644 --- a/Projects/Scripts/Spells/Seventh/EnergyField.cs +++ b/Projects/Scripts/Spells/Seventh/EnergyField.cs @@ -8,7 +8,7 @@ namespace Server.Spells.Seventh { public class EnergyFieldSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Energy Field", "In Sanct Grav", 221, 9022, @@ -16,8 +16,7 @@ namespace Server.Spells.Seventh Reagent.BlackPearl, Reagent.MandrakeRoot, Reagent.SpidersSilk, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public EnergyFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -92,8 +91,8 @@ namespace Server.Spells.Seventh [DispellableField] private class InternalItem : Item { - private Mobile m_Caster; - private Timer m_Timer; + private readonly Mobile m_Caster; + private readonly Timer m_Timer; public InternalItem(Point3D loc, Map map, TimeSpan duration, int itemID, Mobile caster) : base(itemID) { @@ -143,7 +142,7 @@ namespace Server.Spells.Seventh { if (!(m is PlayerMobile)) return base.OnMoveOver(m); - + int noto = Notoriety.Compute(m_Caster, m); return noto != Notoriety.Enemy && noto != Notoriety.Ally && base.OnMoveOver(m); } @@ -157,7 +156,7 @@ namespace Server.Spells.Seventh private class InternalTimer : Timer { - private InternalItem m_Item; + private readonly InternalItem m_Item; public InternalTimer(InternalItem item, TimeSpan duration) : base(duration) { diff --git a/Projects/Scripts/Spells/Seventh/FlameStrike.cs b/Projects/Scripts/Spells/Seventh/FlameStrike.cs index e6bf7561b..cca0d45bc 100644 --- a/Projects/Scripts/Spells/Seventh/FlameStrike.cs +++ b/Projects/Scripts/Spells/Seventh/FlameStrike.cs @@ -4,13 +4,12 @@ namespace Server.Spells.Seventh { public class FlameStrikeSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Flame Strike", "Kal Vas Flam", 245, 9042, Reagent.SpidersSilk, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public FlameStrikeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Seventh/GateTravel.cs b/Projects/Scripts/Spells/Seventh/GateTravel.cs index 4f666a4c6..aa1afb8e0 100644 --- a/Projects/Scripts/Spells/Seventh/GateTravel.cs +++ b/Projects/Scripts/Spells/Seventh/GateTravel.cs @@ -9,16 +9,15 @@ namespace Server.Spells.Seventh { public class GateTravelSpell : MagerySpell, IRecallSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Gate Travel", "Vas Rel Por", 263, 9032, Reagent.BlackPearl, Reagent.MandrakeRoot, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); - private RunebookEntry m_Entry; + private readonly RunebookEntry m_Entry; public GateTravelSpell(Mobile caster, RunebookEntry entry = null, Item scroll = null) : base(caster, scroll, m_Info) => m_Entry = entry; @@ -70,7 +69,7 @@ namespace Server.Spells.Seventh { Caster.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil. } - else if (map == null || !Core.AOS && Caster.Map != map) + else if (map == null || (!Core.AOS && Caster.Map != map)) { Caster.SendLocalizedMessage(1005570); // You can not gate to another facet. } @@ -104,8 +103,7 @@ namespace Server.Spells.Seventh { Caster.SendLocalizedMessage(501942); // That location is blocked. } - else if (Core.SE && (GateExistsAt(map, loc) || GateExistsAt(Caster.Map, Caster.Location)) - ) // SE restricted stacking gates + else if (Core.SE && (GateExistsAt(map, loc) || GateExistsAt(Caster.Map, Caster.Location))) // SE restricted stacking gates { Caster.SendLocalizedMessage(1071242); // There is already a gate there. } @@ -163,7 +161,7 @@ namespace Server.Spells.Seventh private class InternalTimer : Timer { - private Item m_Item; + private readonly Item m_Item; public InternalTimer(Item item) : base(TimeSpan.FromSeconds(30.0)) { diff --git a/Projects/Scripts/Spells/Seventh/ManaVampire.cs b/Projects/Scripts/Spells/Seventh/ManaVampire.cs index 70b0792bd..f34bb1d0d 100644 --- a/Projects/Scripts/Spells/Seventh/ManaVampire.cs +++ b/Projects/Scripts/Spells/Seventh/ManaVampire.cs @@ -4,15 +4,14 @@ namespace Server.Spells.Seventh { public class ManaVampireSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mana Vampire", "Ort Sanct", 221, 9032, Reagent.BlackPearl, Reagent.Bloodmoss, Reagent.MandrakeRoot, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public ManaVampireSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Seventh/MassDispel.cs b/Projects/Scripts/Spells/Seventh/MassDispel.cs index 8b6f32123..ee814fc03 100644 --- a/Projects/Scripts/Spells/Seventh/MassDispel.cs +++ b/Projects/Scripts/Spells/Seventh/MassDispel.cs @@ -6,15 +6,14 @@ namespace Server.Spells.Seventh { public class MassDispelSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mass Dispel", "Vas An Ort", 263, 9002, Reagent.Garlic, Reagent.MandrakeRoot, Reagent.BlackPearl, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public MassDispelSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Seventh/MeteorSwarm.cs b/Projects/Scripts/Spells/Seventh/MeteorSwarm.cs index 3acc34147..eb333da66 100644 --- a/Projects/Scripts/Spells/Seventh/MeteorSwarm.cs +++ b/Projects/Scripts/Spells/Seventh/MeteorSwarm.cs @@ -6,7 +6,7 @@ namespace Server.Spells.Seventh { public class MeteorSwarmSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Meteor Swarm", "Flam Kal Des Ylem", 233, 9042, @@ -14,8 +14,7 @@ namespace Server.Spells.Seventh Reagent.Bloodmoss, Reagent.MandrakeRoot, Reagent.SulfurousAsh, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public MeteorSwarmSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -56,7 +55,7 @@ namespace Server.Spells.Seventh targets = eable.Where(m => { if (Caster == m || !SpellHelper.ValidIndirectTarget(Caster, m) || !Caster.CanBeHarmful(m, false) || - Core.AOS && !Caster.InLOS(m)) + (Core.AOS && !Caster.InLOS(m))) return false; if (m.Player) diff --git a/Projects/Scripts/Spells/Seventh/Polymorph.cs b/Projects/Scripts/Spells/Seventh/Polymorph.cs index b1842fbb2..a8609e500 100644 --- a/Projects/Scripts/Spells/Seventh/Polymorph.cs +++ b/Projects/Scripts/Spells/Seventh/Polymorph.cs @@ -10,18 +10,17 @@ namespace Server.Spells.Seventh { public class PolymorphSpell : MagerySpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Polymorph", "Vas Ylem Rel", 221, 9002, Reagent.Bloodmoss, Reagent.SpidersSilk, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); - private static Dictionary m_Timers = new Dictionary(); + private static readonly Dictionary m_Timers = new Dictionary(); - private int m_NewBody; + private readonly int m_NewBody; public PolymorphSpell(Mobile caster, Item scroll, int body = 0) : base(caster, scroll, m_Info) => m_NewBody = body; @@ -29,7 +28,7 @@ namespace Server.Spells.Seventh public override bool CheckCast() { - /*if ( Caster.Mounted ) + /*if (Caster.Mounted) { Caster.SendLocalizedMessage( 1042561 ); //Please dismount first. return false; @@ -81,7 +80,7 @@ namespace Server.Spells.Seventh public override void OnCast() { - /*if ( Caster.Mounted ) + /*if (Caster.Mounted) { Caster.SendLocalizedMessage( 1042561 ); //Please dismount first. } @@ -182,7 +181,7 @@ namespace Server.Spells.Seventh private class InternalTimer : Timer { - private Mobile m_Owner; + private readonly Mobile m_Owner; public InternalTimer(Mobile owner) : base(TimeSpan.FromSeconds(0)) { diff --git a/Projects/Scripts/Spells/Sixth/Dispel.cs b/Projects/Scripts/Spells/Sixth/Dispel.cs index 7ef8bbf72..10b63f4b1 100644 --- a/Projects/Scripts/Spells/Sixth/Dispel.cs +++ b/Projects/Scripts/Spells/Sixth/Dispel.cs @@ -6,14 +6,13 @@ namespace Server.Spells.Sixth { public class DispelSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Dispel", "An Ort", 218, 9002, Reagent.Garlic, Reagent.MandrakeRoot, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public DispelSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Sixth/EnergyBolt.cs b/Projects/Scripts/Spells/Sixth/EnergyBolt.cs index 5e31e04ac..d5a379af7 100644 --- a/Projects/Scripts/Spells/Sixth/EnergyBolt.cs +++ b/Projects/Scripts/Spells/Sixth/EnergyBolt.cs @@ -4,13 +4,12 @@ namespace Server.Spells.Sixth { public class EnergyBoltSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Energy Bolt", "Corp Por", 230, 9022, Reagent.BlackPearl, - Reagent.Nightshade - ); + Reagent.Nightshade); public EnergyBoltSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Sixth/Explosion.cs b/Projects/Scripts/Spells/Sixth/Explosion.cs index da4281d02..2305720ea 100644 --- a/Projects/Scripts/Spells/Sixth/Explosion.cs +++ b/Projects/Scripts/Spells/Sixth/Explosion.cs @@ -5,13 +5,12 @@ namespace Server.Spells.Sixth { public class ExplosionSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Explosion", "Vas Ort Flam", 230, 9041, Reagent.Bloodmoss, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public ExplosionSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -55,9 +54,10 @@ namespace Server.Spells.Sixth private class InternalTimer : Timer { - private Mobile m_Attacker, m_Defender; - private MagerySpell m_Spell; - private Mobile m_Target; + private readonly Mobile m_Attacker; + private readonly Mobile m_Defender; + private readonly MagerySpell m_Spell; + private readonly Mobile m_Target; public InternalTimer(MagerySpell spell, Mobile attacker, Mobile defender, Mobile target) : base(TimeSpan.FromSeconds(Core.AOS ? 3.0 : 2.5)) diff --git a/Projects/Scripts/Spells/Sixth/Invisibility.cs b/Projects/Scripts/Spells/Sixth/Invisibility.cs index e68fb01d2..d339e7b85 100644 --- a/Projects/Scripts/Spells/Sixth/Invisibility.cs +++ b/Projects/Scripts/Spells/Sixth/Invisibility.cs @@ -9,15 +9,14 @@ namespace Server.Spells.Sixth { public class InvisibilitySpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Invisibility", "An Lor Xen", 206, 9002, Reagent.Bloodmoss, - Reagent.Nightshade - ); + Reagent.Nightshade); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public InvisibilitySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -74,7 +73,7 @@ namespace Server.Spells.Sixth Timer t = new InternalTimer(m, duration); BuffInfo.RemoveBuff(m, BuffIcon.HidingAndOrStealth); - BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Invisibility, 1075825, duration, m)); //Invisibility/Invisible + BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Invisibility, 1075825, duration, m)); // Invisibility/Invisible m_Table[m] = t; @@ -97,7 +96,7 @@ namespace Server.Spells.Sixth private class InternalTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public InternalTimer(Mobile m, TimeSpan duration) : base(duration) { diff --git a/Projects/Scripts/Spells/Sixth/Mark.cs b/Projects/Scripts/Spells/Sixth/Mark.cs index 336e25172..dabd844bb 100644 --- a/Projects/Scripts/Spells/Sixth/Mark.cs +++ b/Projects/Scripts/Spells/Sixth/Mark.cs @@ -6,14 +6,13 @@ namespace Server.Spells.Sixth { public class MarkSpell : MagerySpell, ISpellTargetingItem { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mark", "Kal Por Ylem", 218, 9002, Reagent.BlackPearl, Reagent.Bloodmoss, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public MarkSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Sixth/MassCurse.cs b/Projects/Scripts/Spells/Sixth/MassCurse.cs index ba9121c9d..ed7bb52e7 100644 --- a/Projects/Scripts/Spells/Sixth/MassCurse.cs +++ b/Projects/Scripts/Spells/Sixth/MassCurse.cs @@ -4,7 +4,7 @@ namespace Server.Spells.Sixth { public class MassCurseSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Mass Curse", "Vas Des Sanct", 218, 9031, @@ -12,8 +12,7 @@ namespace Server.Spells.Sixth Reagent.Garlic, Reagent.Nightshade, Reagent.MandrakeRoot, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public MassCurseSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Sixth/ParalyzeField.cs b/Projects/Scripts/Spells/Sixth/ParalyzeField.cs index 092910cc8..1f624823a 100644 --- a/Projects/Scripts/Spells/Sixth/ParalyzeField.cs +++ b/Projects/Scripts/Spells/Sixth/ParalyzeField.cs @@ -8,15 +8,14 @@ namespace Server.Spells.Sixth { public class ParalyzeFieldSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Paralyze Field", "In Ex Grav", 230, 9012, false, Reagent.BlackPearl, Reagent.Ginseng, - Reagent.SpidersSilk - ); + Reagent.SpidersSilk); public ParalyzeFieldSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -144,15 +143,15 @@ namespace Server.Spells.Sixth switch (version) { case 0: - { - m_Caster = reader.ReadMobile(); - m_End = reader.ReadDeltaTime(); + { + m_Caster = reader.ReadMobile(); + m_End = reader.ReadDeltaTime(); - m_Timer = new InternalTimer(this, m_End - DateTime.UtcNow); - m_Timer.Start(); + m_Timer = new InternalTimer(this, m_End - DateTime.UtcNow); + m_Timer.Start(); - break; - } + break; + } } } @@ -197,7 +196,7 @@ namespace Server.Spells.Sixth private class InternalTimer : Timer { - private Item m_Item; + private readonly Item m_Item; public InternalTimer(Item item, TimeSpan duration) : base(duration) { diff --git a/Projects/Scripts/Spells/Sixth/Reveal.cs b/Projects/Scripts/Spells/Sixth/Reveal.cs index 7a0b21d3c..0c2221b1e 100644 --- a/Projects/Scripts/Spells/Sixth/Reveal.cs +++ b/Projects/Scripts/Spells/Sixth/Reveal.cs @@ -5,13 +5,12 @@ namespace Server.Spells.Sixth { public class RevealSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Reveal", "Wis Quas", 206, 9002, Reagent.Bloodmoss, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public RevealSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -44,8 +43,8 @@ namespace Server.Spells.Sixth foreach (Mobile m in eable) { if (m is ShadowKnight && - (m.X != p.X || m.Y != p.Y || !m.Hidden || m.AccessLevel != AccessLevel.Player && - Caster.AccessLevel <= m.AccessLevel || + (m.X != p.X || m.Y != p.Y || !m.Hidden || (m.AccessLevel != AccessLevel.Player && + Caster.AccessLevel <= m.AccessLevel) || !CheckDifficulty(Caster, m))) continue; diff --git a/Projects/Scripts/Spells/Spellweaving/ArcaneCircle.cs b/Projects/Scripts/Spells/Spellweaving/ArcaneCircle.cs index 0b9757de1..4ddd85025 100644 --- a/Projects/Scripts/Spells/Spellweaving/ArcaneCircle.cs +++ b/Projects/Scripts/Spells/Spellweaving/ArcaneCircle.cs @@ -8,10 +8,9 @@ namespace Server.Spells.Spellweaving { public class ArcaneCircleSpell : ArcanistSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Arcane Circle", "Myrshalee", - -1 - ); + -1); public ArcaneCircleSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -34,7 +33,7 @@ namespace Server.Spells.Spellweaving if (GetArcanists().Count < 2) { - Caster.SendLocalizedMessage(1080452); //There are not enough spellweavers present to create an Arcane Focus. + Caster.SendLocalizedMessage(1080452); // There are not enough spellweavers present to create an Arcane Focus. return false; } @@ -56,7 +55,7 @@ namespace Server.Spells.Spellweaving Math.Min(Arcanists.Count, IsSanctuary(Caster.Location, Caster.Map) ? 6 - : 5); //The Sanctuary is a special, single location place + : 5); // The Sanctuary is a special, single location place for (int i = 0; i < Arcanists.Count; i++) GiveArcaneFocus(Arcanists[i], duration, strengthBonus); @@ -108,7 +107,7 @@ namespace Server.Spells.Spellweaving { List weavers = new List { Caster }; - //OSI Verified: Even enemies/combatants count + // OSI Verified: Even enemies/combatants count // Everyone gets the Arcane Focus, power capped elsewhere weavers.AddRange(Caster.GetMobilesInRange(1) .Where(m => m != Caster && m is PlayerMobile && Caster.CanBeBeneficial(m, false) && @@ -119,7 +118,7 @@ namespace Server.Spells.Spellweaving private void GiveArcaneFocus(Mobile to, TimeSpan duration, int strengthBonus) { - if (to == null) //Sanity + if (to == null) // Sanity return; ArcaneFocus focus = FindArcaneFocus(to); @@ -137,7 +136,7 @@ namespace Server.Spells.Spellweaving focus.Delete(); } } - else //OSI renewal rules: the new one will override the old one, always. + else // OSI renewal rules: the new one will override the old one, always. { to.SendLocalizedMessage(1072828); // Your arcane focus is renewed. focus.LifeSpan = duration; diff --git a/Projects/Scripts/Spells/Spellweaving/ArcaneForm.cs b/Projects/Scripts/Spells/Spellweaving/ArcaneForm.cs index 7e158cd09..87365573e 100644 --- a/Projects/Scripts/Spells/Spellweaving/ArcaneForm.cs +++ b/Projects/Scripts/Spells/Spellweaving/ArcaneForm.cs @@ -6,7 +6,7 @@ namespace Server.Spells.Spellweaving { } - public abstract int Body{ get; } + public abstract int Body { get; } public virtual int Hue => 0; public virtual int PhysResistOffset => 0; diff --git a/Projects/Scripts/Spells/Spellweaving/ArcaneSummon.cs b/Projects/Scripts/Spells/Spellweaving/ArcaneSummon.cs index 9b3acbb59..411dc2bbc 100644 --- a/Projects/Scripts/Spells/Spellweaving/ArcaneSummon.cs +++ b/Projects/Scripts/Spells/Spellweaving/ArcaneSummon.cs @@ -11,7 +11,7 @@ namespace Server.Spells.Spellweaving { } - public abstract int Sound{ get; } + public abstract int Sound { get; } public override bool CheckCast() { diff --git a/Projects/Scripts/Spells/Spellweaving/ArcanistSpell.cs b/Projects/Scripts/Spells/Spellweaving/ArcanistSpell.cs index 51897829e..e87f27875 100644 --- a/Projects/Scripts/Spells/Spellweaving/ArcanistSpell.cs +++ b/Projects/Scripts/Spells/Spellweaving/ArcanistSpell.cs @@ -13,8 +13,8 @@ namespace Server.Spells.Spellweaving { } - public abstract double RequiredSkill{ get; } - public abstract int RequiredMana{ get; } + public abstract double RequiredSkill { get; } + public abstract int RequiredMana { get; } public override SkillName CastSkill => SkillName.Spellweaving; public override SkillName DamageSkill => SkillName.Spellweaving; @@ -81,7 +81,7 @@ namespace Server.Spells.Spellweaving public override void GetCastSkills(out double min, out double max) { - min = RequiredSkill - 12.5; //per 5 on Friday, 2/16/07 + min = RequiredSkill - 12.5; // per 5 on Friday, 2/16/07 max = RequiredSkill + 37.5; } @@ -123,7 +123,7 @@ namespace Server.Spells.Spellweaving { double percent = (50 + 2 * (GetResistSkill(m) - GetDamageSkill(Caster))) / - 100; //TODO: According to the guide this is it.. but.. is it correct per OSI? + 100; // TODO: According to the guide this is it.. but.. is it correct per OSI? if (percent <= 0) return false; diff --git a/Projects/Scripts/Spells/Spellweaving/AttuneWeapon.cs b/Projects/Scripts/Spells/Spellweaving/AttuneWeapon.cs index 938cfdc44..195d45a17 100644 --- a/Projects/Scripts/Spells/Spellweaving/AttuneWeapon.cs +++ b/Projects/Scripts/Spells/Spellweaving/AttuneWeapon.cs @@ -5,12 +5,11 @@ namespace Server.Spells.Spellweaving { public class AttuneWeaponSpell : ArcanistSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Attune Weapon", "Haeldril", - -1 - ); + -1); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public AttuneWeaponSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -35,7 +34,6 @@ namespace Server.Spells.Spellweaving Caster.SendLocalizedMessage(1075124); // You must wait before casting that spell again. return false; - } public override void OnCast() @@ -94,7 +92,7 @@ namespace Server.Spells.Spellweaving private class ExpireTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public ExpireTimer(Mobile m, TimeSpan delay) : base(delay) => @@ -119,7 +117,7 @@ namespace Server.Spells.Spellweaving m_Table.Remove(m_Mobile); - DelayCall(TimeSpan.FromSeconds(120), delegate { m_Mobile.EndAction(); }); + DelayCall(TimeSpan.FromSeconds(120), m_Mobile.EndAction); BuffInfo.RemoveBuff(m_Mobile, BuffIcon.AttuneWeapon); } } diff --git a/Projects/Scripts/Spells/Spellweaving/EssenceOfWind.cs b/Projects/Scripts/Spells/Spellweaving/EssenceOfWind.cs index 11fc81d31..f48b5dc82 100644 --- a/Projects/Scripts/Spells/Spellweaving/EssenceOfWind.cs +++ b/Projects/Scripts/Spells/Spellweaving/EssenceOfWind.cs @@ -5,9 +5,9 @@ namespace Server.Spells.Spellweaving { public class EssenceOfWindSpell : ArcanistSpell { - private static SpellInfo m_Info = new SpellInfo("Essence of Wind", "Anathrae", -1); + private static readonly SpellInfo m_Info = new SpellInfo("Essence of Wind", "Anathrae", -1); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public EssenceOfWindSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -85,18 +85,18 @@ namespace Server.Spells.Spellweaving Timer.Start(); } - public Mobile Defender{ get; } + public Mobile Defender { get; } - public int FCMalus{ get; } + public int FCMalus { get; } - public int SSIMalus{ get; } + public int SSIMalus { get; } - public ExpireTimer Timer{ get; } + public ExpireTimer Timer { get; } } private class ExpireTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public ExpireTimer(Mobile m, TimeSpan delay) : base(delay) => m_Mobile = m; diff --git a/Projects/Scripts/Spells/Spellweaving/EtherealVoyage.cs b/Projects/Scripts/Spells/Spellweaving/EtherealVoyage.cs index acf1bfad1..414f13394 100644 --- a/Projects/Scripts/Spells/Spellweaving/EtherealVoyage.cs +++ b/Projects/Scripts/Spells/Spellweaving/EtherealVoyage.cs @@ -4,10 +4,9 @@ namespace Server.Spells.Spellweaving { public class EtherealVoyageSpell : ArcaneForm { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Ethereal Voyage", "Orlavdra", - -1 - ); + -1); public EtherealVoyageSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -59,7 +58,7 @@ namespace Server.Spells.Spellweaving Timer.DelayCall(duration, RemoveEffect, Caster); Caster.BeginAction( - typeof(EtherealVoyageSpell)); //Cannot cast this spell for another 5 minutes(300sec) after effect removed. + typeof(EtherealVoyageSpell)); // Cannot cast this spell for another 5 minutes(300sec) after effect removed. BuffInfo.AddBuff(Caster, new BuffInfo(BuffIcon.EtherealVoyage, 1031613, 1075805, duration, Caster)); } @@ -70,7 +69,7 @@ namespace Server.Spells.Spellweaving TransformationSpellHelper.RemoveContext(m, true); - Timer.DelayCall(TimeSpan.FromMinutes(5), delegate { m.EndAction(); }); + Timer.DelayCall(TimeSpan.FromMinutes(5), m.EndAction); BuffInfo.RemoveBuff(m, BuffIcon.EtherealVoyage); } diff --git a/Projects/Scripts/Spells/Spellweaving/GiftOfLife.cs b/Projects/Scripts/Spells/Spellweaving/GiftOfLife.cs index 7a77fd28f..6845bca3f 100644 --- a/Projects/Scripts/Spells/Spellweaving/GiftOfLife.cs +++ b/Projects/Scripts/Spells/Spellweaving/GiftOfLife.cs @@ -8,12 +8,11 @@ namespace Server.Spells.Spellweaving { public class GiftOfLifeSpell : ArcanistSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Gift of Life", "Illorae", - -1 - ); + -1); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public GiftOfLifeSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -63,7 +62,6 @@ namespace Server.Spells.Spellweaving SpellHelper.Turn(Caster, m); } - m.PlaySound(0x244); m.FixedParticles(0x3709, 1, 30, 0x26ED, 5, 2, EffectLayer.Waist); m.FixedParticles(0x376A, 1, 30, 0x251E, 5, 3, EffectLayer.Waist); @@ -128,7 +126,7 @@ namespace Server.Spells.Spellweaving m.SendGump(new ResurrectGump(m, hitsScalar)); } - //Per OSI, buff is removed when gump sent, irregardless of online status or acceptance + // Per OSI, buff is removed when gump sent, irregardless of online status or acceptance timer.DoExpire(); } @@ -142,7 +140,7 @@ namespace Server.Spells.Spellweaving private class ExpireTimer : Timer { - private Mobile m_Mobile; + private readonly Mobile m_Mobile; public ExpireTimer(Mobile m, TimeSpan delay, GiftOfLifeSpell spell) : base(delay) @@ -151,7 +149,7 @@ namespace Server.Spells.Spellweaving Spell = spell; } - public GiftOfLifeSpell Spell{ get; } + public GiftOfLifeSpell Spell { get; } protected override void OnTick() { diff --git a/Projects/Scripts/Spells/Spellweaving/GiftOfRenewal.cs b/Projects/Scripts/Spells/Spellweaving/GiftOfRenewal.cs index b1734b3dd..38bcd5d4b 100644 --- a/Projects/Scripts/Spells/Spellweaving/GiftOfRenewal.cs +++ b/Projects/Scripts/Spells/Spellweaving/GiftOfRenewal.cs @@ -6,12 +6,11 @@ namespace Server.Spells.Spellweaving { public class GiftOfRenewalSpell : ArcanistSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Gift of Renewal", "Olorisstra", - -1 - ); + -1); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public GiftOfRenewalSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -60,7 +59,7 @@ namespace Server.Spells.Spellweaving GiftOfRenewalInfo info = new GiftOfRenewalInfo(Caster, m, hitsPerRound); Timer.DelayCall(duration, - delegate + () => { if (StopEffect(m)) { @@ -69,7 +68,6 @@ namespace Server.Spells.Spellweaving } }); - m_Table[m] = info; Caster.BeginAction(); @@ -92,17 +90,17 @@ namespace Server.Spells.Spellweaving info.m_Timer.Stop(); BuffInfo.RemoveBuff(m, BuffIcon.GiftOfRenewal); - Timer.DelayCall(TimeSpan.FromSeconds(60), delegate { info.m_Caster.EndAction(); }); + Timer.DelayCall(TimeSpan.FromSeconds(60), info.m_Caster.EndAction); return true; } private class GiftOfRenewalInfo { - public Mobile m_Caster; - public int m_HitsPerRound; - public Mobile m_Mobile; - public InternalTimer m_Timer; + public readonly Mobile m_Caster; + public readonly int m_HitsPerRound; + public readonly Mobile m_Mobile; + public readonly InternalTimer m_Timer; public GiftOfRenewalInfo(Mobile caster, Mobile mobile, int hitsPerRound) { @@ -117,7 +115,7 @@ namespace Server.Spells.Spellweaving private class InternalTimer : Timer { - private GiftOfRenewalInfo m_GiftInfo; + private readonly GiftOfRenewalInfo m_GiftInfo; public InternalTimer(GiftOfRenewalInfo info) : base(TimeSpan.FromSeconds(2.0), TimeSpan.FromSeconds(2.0)) => diff --git a/Projects/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs b/Projects/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs index 2bb95d1ed..27d547b16 100644 --- a/Projects/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs +++ b/Projects/Scripts/Spells/Spellweaving/ImmolatingWeapon.cs @@ -6,12 +6,11 @@ namespace Server.Spells.Spellweaving { public class ImmolatingWeaponSpell : ArcanistSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Immolating Weapon", "Thalshara", - -1 - ); + -1); - private static Dictionary m_WeaponDamageTable = + private static readonly Dictionary m_WeaponDamageTable = new Dictionary(); public ImmolatingWeaponSpell(Mobile caster, Item scroll = null) @@ -92,9 +91,9 @@ namespace Server.Spells.Spellweaving private class ImmolatingWeaponEntry { - public Mobile m_Caster; - public int m_Damage; - public Timer m_Timer; + public readonly Mobile m_Caster; + public readonly int m_Damage; + public readonly Timer m_Timer; public ImmolatingWeaponEntry(int damage, Timer stopTimer, Mobile caster) { @@ -106,8 +105,8 @@ namespace Server.Spells.Spellweaving private class DelayedEffectEntry { - public Mobile m_Target; - public BaseWeapon m_Weapon; + public readonly Mobile m_Target; + public readonly BaseWeapon m_Weapon; public DelayedEffectEntry(BaseWeapon weapon, Mobile target) { diff --git a/Projects/Scripts/Spells/Spellweaving/Items/ArcaneFocus.cs b/Projects/Scripts/Spells/Spellweaving/Items/ArcaneFocus.cs index 8d034ccb2..eb39b3faf 100644 --- a/Projects/Scripts/Spells/Spellweaving/Items/ArcaneFocus.cs +++ b/Projects/Scripts/Spells/Spellweaving/Items/ArcaneFocus.cs @@ -29,7 +29,7 @@ namespace Server.Items public override int LabelNumber => 1032629; // Arcane Focus [CommandProperty(AccessLevel.GameMaster)] - public int StrengthBonus{ get; set; } + public int StrengthBonus { get; set; } public override TextDefinition InvalidTransferMessage => 1073480; // Your arcane focus disappears. public override bool Nontransferable => true; diff --git a/Projects/Scripts/Spells/Spellweaving/Items/TransientItem.cs b/Projects/Scripts/Spells/Spellweaving/Items/TransientItem.cs index fd6fa9f2c..83064b980 100644 --- a/Projects/Scripts/Spells/Spellweaving/Items/TransientItem.cs +++ b/Projects/Scripts/Spells/Spellweaving/Items/TransientItem.cs @@ -22,10 +22,10 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public TimeSpan LifeSpan{ get; set; } + public TimeSpan LifeSpan { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime CreationTime{ get; set; } + public DateTime CreationTime { get; set; } public override bool Nontransferable => true; @@ -39,7 +39,6 @@ namespace Server.Items Delete(); } - public virtual void Expire(Mobile parent) { parent?.SendLocalizedMessage(1072515, Name ?? $"#{LabelNumber}"); // The ~1_name~ expired... diff --git a/Projects/Scripts/Spells/Spellweaving/Mobiles/ArcaneFiend.cs b/Projects/Scripts/Spells/Spellweaving/Mobiles/ArcaneFiend.cs index e2cac4fff..4163b2cf7 100644 --- a/Projects/Scripts/Spells/Spellweaving/Mobiles/ArcaneFiend.cs +++ b/Projects/Scripts/Spells/Spellweaving/Mobiles/ArcaneFiend.cs @@ -45,7 +45,7 @@ namespace Server.Mobiles public override double DispelFocus => 20.0; public override PackInstinct PackInstinct => PackInstinct.Daemon; - public override bool BleedImmune => true; //TODO: Verify on OSI. Guide says this. + public override bool BleedImmune => true; // TODO: Verify on OSI. Guide says this. public override string DefaultName => "an imp"; public override void Serialize(IGenericWriter writer) diff --git a/Projects/Scripts/Spells/Spellweaving/NatureFury.cs b/Projects/Scripts/Spells/Spellweaving/NatureFury.cs index 7e93ff453..539dc35d8 100644 --- a/Projects/Scripts/Spells/Spellweaving/NatureFury.cs +++ b/Projects/Scripts/Spells/Spellweaving/NatureFury.cs @@ -7,11 +7,10 @@ namespace Server.Spells.Spellweaving { public class NatureFurySpell : ArcanistSpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Nature's Fury", "Rauvvrae", -1, - false - ); + false); public NatureFurySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) @@ -72,7 +71,7 @@ namespace Server.Spells.Spellweaving private class InternalTimer : Timer { - private NatureFury m_NatureFury; + private readonly NatureFury m_NatureFury; public InternalTimer(NatureFury nf) : base(TimeSpan.FromSeconds(5.0), TimeSpan.FromSeconds(5.0)) => diff --git a/Projects/Scripts/Spells/Spellweaving/ReaperForm.cs b/Projects/Scripts/Spells/Spellweaving/ReaperForm.cs index 120f38e82..5c14cef5a 100644 --- a/Projects/Scripts/Spells/Spellweaving/ReaperForm.cs +++ b/Projects/Scripts/Spells/Spellweaving/ReaperForm.cs @@ -5,7 +5,7 @@ namespace Server.Spells.Spellweaving { public class ReaperFormSpell : ArcaneForm { - private static SpellInfo m_Info = new SpellInfo("Reaper Form", "Tarisstree", -1); + private static readonly SpellInfo m_Info = new SpellInfo("Reaper Form", "Tarisstree", -1); public ReaperFormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Spellweaving/SummonFey.cs b/Projects/Scripts/Spells/Spellweaving/SummonFey.cs index 47f34c69a..b50fcbd5d 100644 --- a/Projects/Scripts/Spells/Spellweaving/SummonFey.cs +++ b/Projects/Scripts/Spells/Spellweaving/SummonFey.cs @@ -6,10 +6,9 @@ namespace Server.Spells.Spellweaving { public class SummonFeySpell : ArcaneSummon { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Summon Fey", "Alalithra", - -1 - ); + -1); public SummonFeySpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) diff --git a/Projects/Scripts/Spells/Spellweaving/SummonFiend.cs b/Projects/Scripts/Spells/Spellweaving/SummonFiend.cs index 8b7233231..1ac43c590 100644 --- a/Projects/Scripts/Spells/Spellweaving/SummonFiend.cs +++ b/Projects/Scripts/Spells/Spellweaving/SummonFiend.cs @@ -6,10 +6,9 @@ namespace Server.Spells.Spellweaving { public class SummonFiendSpell : ArcaneSummon { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Summon Fiend", "Nylisstra", - -1 - ); + -1); public SummonFiendSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) diff --git a/Projects/Scripts/Spells/Spellweaving/Thunderstorm.cs b/Projects/Scripts/Spells/Spellweaving/Thunderstorm.cs index f4d2c558c..57079fe72 100644 --- a/Projects/Scripts/Spells/Spellweaving/Thunderstorm.cs +++ b/Projects/Scripts/Spells/Spellweaving/Thunderstorm.cs @@ -5,12 +5,11 @@ namespace Server.Spells.Spellweaving { public class ThunderstormSpell : ArcanistSpell { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Thunderstorm", "Erelonia", - -1 - ); + -1); - private static Dictionary m_Table = new Dictionary(); + private static readonly Dictionary m_Table = new Dictionary(); public ThunderstormSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) diff --git a/Projects/Scripts/Spells/Spellweaving/WordOfDeath.cs b/Projects/Scripts/Spells/Spellweaving/WordOfDeath.cs index 8c2419230..67f6777db 100644 --- a/Projects/Scripts/Spells/Spellweaving/WordOfDeath.cs +++ b/Projects/Scripts/Spells/Spellweaving/WordOfDeath.cs @@ -5,7 +5,7 @@ namespace Server.Spells.Spellweaving { public class WordOfDeathSpell : ArcanistSpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo("Word of Death", "Nyraxle", -1); + private static readonly SpellInfo m_Info = new SpellInfo("Word of Death", "Nyraxle", -1); public WordOfDeathSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Targeting/IRecallSpell.cs b/Projects/Scripts/Spells/Targeting/IRecallSpell.cs index e986d8c8c..2e356446f 100644 --- a/Projects/Scripts/Spells/Targeting/IRecallSpell.cs +++ b/Projects/Scripts/Spells/Targeting/IRecallSpell.cs @@ -2,7 +2,7 @@ namespace Server.Spells { public interface IRecallSpell { - Mobile Caster{ get; } + Mobile Caster { get; } void Effect(Point3D loc, Map map, bool checkMulti); void FinishSequence(); } diff --git a/Projects/Scripts/Spells/Targeting/ISpellTarget.cs b/Projects/Scripts/Spells/Targeting/ISpellTarget.cs index 69b5a24ca..bb0962284 100644 --- a/Projects/Scripts/Spells/Targeting/ISpellTarget.cs +++ b/Projects/Scripts/Spells/Targeting/ISpellTarget.cs @@ -2,6 +2,6 @@ namespace Server.Spells { public interface ISpellTarget { - ISpell Spell{ get; } + ISpell Spell { get; } } } diff --git a/Projects/Scripts/Spells/Targeting/RecallSpellTarget.cs b/Projects/Scripts/Spells/Targeting/RecallSpellTarget.cs index b74530dfb..b96945677 100644 --- a/Projects/Scripts/Spells/Targeting/RecallSpellTarget.cs +++ b/Projects/Scripts/Spells/Targeting/RecallSpellTarget.cs @@ -7,8 +7,8 @@ namespace Server.Spells { public class RecallSpellTarget : Target { - private IRecallSpell m_Spell; - private bool m_ToBoat; + private readonly IRecallSpell m_Spell; + private readonly bool m_ToBoat; public RecallSpellTarget(IRecallSpell spell, bool toBoat = true) : base(Core.ML ? 10 : 12, false, TargetFlags.None) { diff --git a/Projects/Scripts/Spells/Targeting/SpellTargetItem.cs b/Projects/Scripts/Spells/Targeting/SpellTargetItem.cs index dd7fa7144..d64c53297 100644 --- a/Projects/Scripts/Spells/Targeting/SpellTargetItem.cs +++ b/Projects/Scripts/Spells/Targeting/SpellTargetItem.cs @@ -9,7 +9,7 @@ namespace Server.Spells public class SpellTargetItem : Target, ISpellTarget { - private ISpellTargetingItem m_Spell; + private readonly ISpellTargetingItem m_Spell; public ISpell Spell => m_Spell; public SpellTargetItem(ISpellTargetingItem spell, TargetFlags flags, int range = 12) : base(range, false, flags) => m_Spell = spell; diff --git a/Projects/Scripts/Spells/Targeting/SpellTargetMobile.cs b/Projects/Scripts/Spells/Targeting/SpellTargetMobile.cs index 54a1feed6..becc23639 100644 --- a/Projects/Scripts/Spells/Targeting/SpellTargetMobile.cs +++ b/Projects/Scripts/Spells/Targeting/SpellTargetMobile.cs @@ -9,7 +9,7 @@ namespace Server.Spells public class SpellTargetMobile : Target, ISpellTarget { - private ISpellTargetingMobile m_Spell; + private readonly ISpellTargetingMobile m_Spell; public ISpell Spell => m_Spell; public SpellTargetMobile(ISpellTargetingMobile spell, TargetFlags flags, int range = 12) : base(range, false, flags) => m_Spell = spell; diff --git a/Projects/Scripts/Spells/Targeting/SpellTargetPoint3D.cs b/Projects/Scripts/Spells/Targeting/SpellTargetPoint3D.cs index 1f17046fa..e96ba3bc8 100644 --- a/Projects/Scripts/Spells/Targeting/SpellTargetPoint3D.cs +++ b/Projects/Scripts/Spells/Targeting/SpellTargetPoint3D.cs @@ -13,7 +13,7 @@ namespace Server.Spells private ISpellTargetingPoint3D m_Spell; public ISpell Spell => m_Spell; - private bool m_CheckLOS; + private readonly bool m_CheckLOS; public SpellTargetPoint3D(ISpellTargetingPoint3D spell, TargetFlags flags = TargetFlags.None, int range = 12, bool checkLOS = true) : base(range, true, flags) { diff --git a/Projects/Scripts/Spells/Third/Bless.cs b/Projects/Scripts/Spells/Third/Bless.cs index 47e26354a..be6cd470c 100644 --- a/Projects/Scripts/Spells/Third/Bless.cs +++ b/Projects/Scripts/Spells/Third/Bless.cs @@ -6,13 +6,12 @@ namespace Server.Spells.Third { public class BlessSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Bless", "Rel Sanct", 203, 9061, Reagent.Garlic, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public BlessSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Third/Fireball.cs b/Projects/Scripts/Spells/Third/Fireball.cs index 661486548..cc2154015 100644 --- a/Projects/Scripts/Spells/Third/Fireball.cs +++ b/Projects/Scripts/Spells/Third/Fireball.cs @@ -4,12 +4,11 @@ namespace Server.Spells.Third { public class FireballSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Fireball", "Vas Flam", 203, 9041, - Reagent.BlackPearl - ); + Reagent.BlackPearl); public FireballSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Third/MagicLock.cs b/Projects/Scripts/Spells/Third/MagicLock.cs index edf3ce3f4..3cdb37f78 100644 --- a/Projects/Scripts/Spells/Third/MagicLock.cs +++ b/Projects/Scripts/Spells/Third/MagicLock.cs @@ -7,14 +7,13 @@ namespace Server.Spells.Third { public class MagicLockSpell : MagerySpell, ISpellTargetingItem { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Magic Lock", "An Por", 215, 9001, Reagent.Garlic, Reagent.Bloodmoss, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public MagicLockSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Third/Poison.cs b/Projects/Scripts/Spells/Third/Poison.cs index de77d9fc8..8041efe00 100644 --- a/Projects/Scripts/Spells/Third/Poison.cs +++ b/Projects/Scripts/Spells/Third/Poison.cs @@ -5,12 +5,11 @@ namespace Server.Spells.Third { public class PoisonSpell : MagerySpell, ISpellTargetingMobile { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Poison", "In Nox", 203, 9051, - Reagent.Nightshade - ); + Reagent.Nightshade); public PoisonSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -70,9 +69,7 @@ namespace Server.Spells.Third } else { - //double total = Caster.Skills.Magery.Value + Caster.Skills.Poisoning.Value; - - #region Dueling + // double total = Caster.Skills.Magery.Value + Caster.Skills.Poisoning.Value; double total = Caster.Skills.Magery.Value; @@ -86,14 +83,12 @@ namespace Server.Spells.Third total += Caster.Skills.Poisoning.Value; } - #endregion - double dist = Caster.GetDistanceToSqrt(m); if (dist >= 3.0) total -= (dist - 3.0) * 10.0; - if (total >= 200.0 && 1 > Utility.Random(10)) + if (total >= 200.0 && Utility.Random(10) < 1) level = 3; else if (total > (Core.AOS ? 170.1 : 170.0)) level = 2; diff --git a/Projects/Scripts/Spells/Third/Telekinesis.cs b/Projects/Scripts/Spells/Third/Telekinesis.cs index 42de74425..3815f2120 100644 --- a/Projects/Scripts/Spells/Third/Telekinesis.cs +++ b/Projects/Scripts/Spells/Third/Telekinesis.cs @@ -5,13 +5,12 @@ namespace Server.Spells.Third { public class TelekinesisSpell : MagerySpell, ISpellTargetingItem { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Telekinesis", "Ort Por Ylem", 203, 9031, Reagent.Bloodmoss, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public TelekinesisSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Third/Teleport.cs b/Projects/Scripts/Spells/Third/Teleport.cs index c65f5d0b0..e37d60689 100644 --- a/Projects/Scripts/Spells/Third/Teleport.cs +++ b/Projects/Scripts/Spells/Third/Teleport.cs @@ -11,13 +11,12 @@ namespace Server.Spells.Third { public class TeleportSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Teleport", "Rel Por", 215, 9031, Reagent.Bloodmoss, - Reagent.MandrakeRoot - ); + Reagent.MandrakeRoot); public TeleportSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Third/Unlock.cs b/Projects/Scripts/Spells/Third/Unlock.cs index 86350a80d..91c89f6f1 100644 --- a/Projects/Scripts/Spells/Third/Unlock.cs +++ b/Projects/Scripts/Spells/Third/Unlock.cs @@ -7,13 +7,12 @@ namespace Server.Spells.Third { public class UnlockSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Unlock Spell", "Ex Por", 215, 9001, Reagent.Bloodmoss, - Reagent.SulfurousAsh - ); + Reagent.SulfurousAsh); public UnlockSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { diff --git a/Projects/Scripts/Spells/Third/WallOfStone.cs b/Projects/Scripts/Spells/Third/WallOfStone.cs index 619e61402..481675c34 100644 --- a/Projects/Scripts/Spells/Third/WallOfStone.cs +++ b/Projects/Scripts/Spells/Third/WallOfStone.cs @@ -7,14 +7,13 @@ namespace Server.Spells.Third { public class WallOfStoneSpell : MagerySpell, ISpellTargetingPoint3D { - private static SpellInfo m_Info = new SpellInfo( + private static readonly SpellInfo m_Info = new SpellInfo( "Wall of Stone", "In Sanct Ylem", 227, 9011, false, Reagent.Bloodmoss, - Reagent.Garlic - ); + Reagent.Garlic); public WallOfStoneSpell(Mobile caster, Item scroll = null) : base(caster, scroll, m_Info) { @@ -62,7 +61,7 @@ namespace Server.Spells.Third Point3D loc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z); bool canFit = SpellHelper.AdjustField(ref loc, Caster.Map, 22, true); - //Effects.SendLocationParticles( EffectItem.Create( loc, Caster.Map, EffectItem.DefaultDuration ), 0x376A, 9, 10, 5025 ); + // Effects.SendLocationParticles( EffectItem.Create( loc, Caster.Map, EffectItem.DefaultDuration ), 0x376A, 9, 10, 5025 ); if (!canFit) continue; @@ -71,7 +70,7 @@ namespace Server.Spells.Third Effects.SendLocationParticles(item, 0x376A, 9, 10, 5025); - //new InternalItem( loc, Caster.Map, Caster ); + // new InternalItem( loc, Caster.Map, Caster ); } } @@ -81,7 +80,7 @@ namespace Server.Spells.Third [DispellableField] private class InternalItem : Item { - private Mobile m_Caster; + private readonly Mobile m_Caster; private DateTime m_End; private Timer m_Timer; @@ -132,25 +131,25 @@ namespace Server.Spells.Third switch (version) { case 1: - { - m_End = reader.ReadDeltaTime(); + { + m_End = reader.ReadDeltaTime(); - m_Timer = new InternalTimer(this, m_End - DateTime.UtcNow); - m_Timer.Start(); + m_Timer = new InternalTimer(this, m_End - DateTime.UtcNow); + m_Timer.Start(); - break; - } + break; + } case 0: - { - TimeSpan duration = TimeSpan.FromSeconds(10.0); + { + TimeSpan duration = TimeSpan.FromSeconds(10.0); - m_Timer = new InternalTimer(this, duration); - m_Timer.Start(); + m_Timer = new InternalTimer(this, duration); + m_Timer.Start(); - m_End = DateTime.UtcNow + duration; + m_End = DateTime.UtcNow + duration; - break; - } + break; + } } } @@ -175,7 +174,7 @@ namespace Server.Spells.Third private class InternalTimer : Timer { - private InternalItem m_Item; + private readonly InternalItem m_Item; public InternalTimer(InternalItem item, TimeSpan duration) : base(duration) { diff --git a/Projects/Scripts/Spells/UnsummonTimer.cs b/Projects/Scripts/Spells/UnsummonTimer.cs index 994d48243..c23a3805c 100644 --- a/Projects/Scripts/Spells/UnsummonTimer.cs +++ b/Projects/Scripts/Spells/UnsummonTimer.cs @@ -6,7 +6,7 @@ namespace Server.Spells internal class UnsummonTimer : Timer { private Mobile m_Caster; - private BaseCreature m_Creature; + private readonly BaseCreature m_Creature; public UnsummonTimer(Mobile caster, BaseCreature creature, TimeSpan delay) : base(delay) { diff --git a/Projects/Scripts/Targets/BladedItemTarget.cs b/Projects/Scripts/Targets/BladedItemTarget.cs index fb9cf82c8..d800ea6e3 100644 --- a/Projects/Scripts/Targets/BladedItemTarget.cs +++ b/Projects/Scripts/Targets/BladedItemTarget.cs @@ -9,7 +9,7 @@ namespace Server.Targets { public class BladedItemTarget : Target { - private Item m_Item; + private readonly Item m_Item; public BladedItemTarget(Item item) : base(2, false, TargetFlags.None) => m_Item = item; @@ -63,7 +63,7 @@ namespace Server.Targets } HarvestSystem system = Lumberjacking.System; - HarvestDefinition def = Lumberjacking.System.Definition; + HarvestDefinition def = Lumberjacking.System.GetDefinition(); if (!system.GetHarvestDetails(from, m_Item, targeted, out int tileID, out Map map, out Point3D loc)) { @@ -106,4 +106,4 @@ namespace Server.Targets } } } -} \ No newline at end of file +} diff --git a/Projects/Scripts/Targets/MoveTarget.cs b/Projects/Scripts/Targets/MoveTarget.cs index 9462c3c9d..bdca4f960 100644 --- a/Projects/Scripts/Targets/MoveTarget.cs +++ b/Projects/Scripts/Targets/MoveTarget.cs @@ -6,7 +6,7 @@ namespace Server.Targets { public class MoveTarget : Target { - private object m_Object; + private readonly object m_Object; public MoveTarget(object o) : base(-1, true, TargetFlags.None) => m_Object = o; diff --git a/Projects/Server/AggressorInfo.cs b/Projects/Server/AggressorInfo.cs index 69ce600fe..ef8df62d0 100644 --- a/Projects/Server/AggressorInfo.cs +++ b/Projects/Server/AggressorInfo.cs @@ -47,7 +47,7 @@ namespace Server Refresh(); } - public static TimeSpan ExpireDelay{ get; set; } = TimeSpan.FromMinutes(2.0); + public static TimeSpan ExpireDelay { get; set; } = TimeSpan.FromMinutes(2.0); public bool Expired { @@ -184,7 +184,7 @@ namespace Server public static void DumpAccess() { - using StreamWriter op = new StreamWriter("warnings.log", true); + using var op = new StreamWriter("warnings.log", true); op.WriteLine("Warning: Access to queued AggressorInfo:"); op.WriteLine(new StackTrace()); op.WriteLine(); @@ -200,4 +200,4 @@ namespace Server m_Reported = false; } } -} \ No newline at end of file +} diff --git a/Projects/Server/AssemblyHandler.cs b/Projects/Server/AssemblyHandler.cs index 8a06aca79..f414107eb 100644 --- a/Projects/Server/AssemblyHandler.cs +++ b/Projects/Server/AssemblyHandler.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: AssemblyHandler.cs - Created: 2019/08/02 - Updated: 2020/01/19 * * * @@ -17,13 +17,13 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see . * *************************************************************************/ + using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.Loader; -using System.Collections.Immutable; namespace Server { @@ -33,7 +33,7 @@ namespace Server private static TypeCache m_NullCache; public static Assembly[] Assemblies { get; set; } - public static string AssembliesPath = EnsureDirectory("Assemblies"); + public static readonly string AssembliesPath = EnsureDirectory("Assemblies"); public static void LoadScripts(string path = null) => Assemblies = Directory.GetFiles(path ?? AssembliesPath, "*.dll") @@ -41,15 +41,15 @@ namespace Server public static void Invoke(string method) { - List invoke = new List(); + var invoke = new List(); - for (int a = 0; a < Assemblies.Length; ++a) + for (var a = 0; a < Assemblies.Length; ++a) invoke.AddRange(Assemblies[a].GetTypes() .Select(t => t.GetMethod(method, BindingFlags.Static | BindingFlags.Public)).Where(m => m != null)); invoke.Sort(new CallPriorityComparer()); - for (int i = 0; i < invoke.Count; ++i) + for (var i = 0; i < invoke.Count; ++i) invoke[i].Invoke(null, null); } @@ -57,7 +57,7 @@ namespace Server { if (asm == null) return m_NullCache ??= new TypeCache(null); - if (m_TypeCaches.TryGetValue(asm, out TypeCache c)) + if (m_TypeCaches.TryGetValue(asm, out var c)) return c; return m_TypeCaches[asm] = new TypeCache(asm); @@ -86,10 +86,10 @@ namespace Server public static IEnumerable FindTypesByName(string name, bool ignoreCase = false) { - List types = new List(); - if(ignoreCase) + var types = new List(); + if (ignoreCase) name = name.ToLower(); - for (int i = 0; i < Assemblies.Length; i++) types.AddRange(GetTypeCache(Assemblies[i])[name]); + for (var i = 0; i < Assemblies.Length; i++) types.AddRange(GetTypeCache(Assemblies[i])[name]); if (types.Count == 0) types.AddRange(GetTypeCache(Core.Assembly)[name]); return types; @@ -97,7 +97,7 @@ namespace Server public static string EnsureDirectory(string dir) { - string path = Path.Combine(Core.BaseDirectory, dir); + var path = Path.Combine(Core.BaseDirectory, dir); if (!Directory.Exists(path)) Directory.CreateDirectory(path); @@ -113,7 +113,8 @@ namespace Server public IEnumerable Types => m_Types; public IEnumerable Names => m_NameMap.Keys; - public IEnumerable this[string name] => m_NameMap.TryGetValue(name, out int[] value) ? value.Select(x => m_Types[x]) : new Type[0]; + public IEnumerable this[string name] => + m_NameMap.TryGetValue(name, out var value) ? value.Select(x => m_Types[x]) : Array.Empty(); public TypeCache(Assembly asm) { @@ -123,31 +124,31 @@ namespace Server Action addToRefs = (index, key) => { if (nameMap.TryGetValue(key, out refs)) + { refs.Add(index); + } else { - refs = new HashSet {index}; + refs = new HashSet { index }; nameMap.Add(key, refs); } }; - Type current; - Type aliasType = typeof(TypeAliasAttribute); - TypeAliasAttribute alias; - for (int i = 0; i < m_Types.Length; i++) + var aliasType = typeof(TypeAliasAttribute); + for (var i = 0; i < m_Types.Length; i++) { - current = m_Types[i]; + var current = m_Types[i]; addToRefs(i, current.Name); addToRefs(i, current.Name.ToLower()); addToRefs(i, current.FullName); addToRefs(i, current.FullName?.ToLower()); - alias = current.GetCustomAttribute(aliasType, false) as TypeAliasAttribute; - if (alias != null) - for (int j = 0; j < alias.Aliases.Length; j++) + if (current.GetCustomAttribute(aliasType, false) is TypeAliasAttribute alias) + for (var j = 0; j < alias.Aliases.Length; j++) { addToRefs(i, alias.Aliases[j]); addToRefs(i, alias.Aliases[j].ToLower()); } } + foreach (var (key, value) in nameMap) m_NameMap[key] = value.ToArray(); } diff --git a/Projects/Server/Attributes.cs b/Projects/Server/Attributes.cs index 5cfdc3074..5f37b0bd5 100644 --- a/Projects/Server/Attributes.cs +++ b/Projects/Server/Attributes.cs @@ -49,7 +49,7 @@ namespace Server { public CallPriorityAttribute(int priority) => Priority = priority; - public int Priority{ get; set; } + public int Priority { get; set; } } public class CallPriorityComparer : IComparer @@ -65,8 +65,8 @@ namespace Server if (y == null) return -1; - int xPriority = GetPriority(x); - int yPriority = GetPriority(y); + var xPriority = GetPriority(x); + var yPriority = GetPriority(y); if (xPriority > yPriority) return 1; @@ -79,7 +79,7 @@ namespace Server private int GetPriority(MethodInfo mi) { - object[] objs = mi.GetCustomAttributes(typeof(CallPriorityAttribute), true); + var objs = mi.GetCustomAttributes(typeof(CallPriorityAttribute), true); if (objs.Length == 0) return 0; @@ -96,7 +96,7 @@ namespace Server { public TypeAliasAttribute(params string[] aliases) => Aliases = aliases; - public string[] Aliases{ get; } + public string[] Aliases { get; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] @@ -109,20 +109,19 @@ namespace Server { public CustomEnumAttribute(string[] names) => Names = names; - public string[] Names{ get; } + public string[] Names { get; } } [AttributeUsage(AttributeTargets.Constructor)] public class ConstructibleAttribute : Attribute { - public ConstructibleAttribute() : - this(AccessLevel.Player) //Lowest accesslevel for current functionality (Level determined by access to [add) + public ConstructibleAttribute() : this(AccessLevel.Player) // Lowest accesslevel for current functionality (Level determined by access to [add) { } public ConstructibleAttribute(AccessLevel accessLevel) => AccessLevel = accessLevel; - public AccessLevel AccessLevel{ get; set; } + public AccessLevel AccessLevel { get; set; } } [AttributeUsage(AttributeTargets.Property)] @@ -144,10 +143,10 @@ namespace Server WriteLevel = writeLevel; } - public AccessLevel ReadLevel{ get; } + public AccessLevel ReadLevel { get; } - public AccessLevel WriteLevel{ get; } + public AccessLevel WriteLevel { get; } - public bool ReadOnly{ get; } + public bool ReadOnly { get; } } -} \ No newline at end of file +} diff --git a/Projects/Server/BaseVendor.cs b/Projects/Server/BaseVendor.cs index 5a9f023cd..eb36e3dd0 100644 --- a/Projects/Server/BaseVendor.cs +++ b/Projects/Server/BaseVendor.cs @@ -42,9 +42,9 @@ namespace Server Amount = amount; } - public Serial Serial{ get; } + public Serial Serial { get; } - public int Amount{ get; } + public int Amount { get; } } public class SellItemResponse @@ -55,9 +55,9 @@ namespace Server Amount = amount; } - public Item Item{ get; } + public Item Item { get; } - public int Amount{ get; } + public int Amount { get; } } public class SellItemState @@ -69,11 +69,11 @@ namespace Server Name = name; } - public Item Item{ get; } + public Item Item { get; } - public int Price{ get; } + public int Price { get; } - public string Name{ get; } + public string Name { get; } } public class BuyItemState @@ -89,18 +89,18 @@ namespace Server Hue = hue; } - public int Price{ get; } + public int Price { get; } - public Serial MySerial{ get; } + public Serial MySerial { get; } - public Serial ContainerSerial{ get; } + public Serial ContainerSerial { get; } - public int ItemID{ get; } + public int ItemID { get; } - public int Amount{ get; } + public int Amount { get; } - public int Hue{ get; } + public int Hue { get; } - public string Description{ get; } + public string Description { get; } } -} +} diff --git a/Projects/Server/Body.cs b/Projects/Server/Body.cs index b20101b14..e4a391294 100644 --- a/Projects/Server/Body.cs +++ b/Projects/Server/Body.cs @@ -33,15 +33,15 @@ namespace Server Equipment } - public struct Body + public readonly struct Body : IEquatable, IEquatable, IEquatable { - private static readonly BodyType[] m_Types; + private static readonly BodyType[] m_Types = Array.Empty(); static Body() { if (File.Exists("Data/bodyTable.cfg")) { - using StreamReader ip = new StreamReader("Data/bodyTable.cfg"); + using var ip = new StreamReader("Data/bodyTable.cfg"); m_Types = new BodyType[0x1000]; string line; @@ -51,9 +51,9 @@ namespace Server if (line.Length == 0 || line.StartsWith("#")) continue; - string[] split = line.Split('\t'); + var split = line.Split('\t'); - if (int.TryParse(split[0], out int bodyID) && Enum.TryParse(split[1], true, out BodyType type) && bodyID >= 0 && + if (int.TryParse(split[0], out var bodyID) && Enum.TryParse(split[1], true, out BodyType type) && bodyID >= 0 && bodyID < m_Types.Length) { m_Types[bodyID] = type; @@ -68,8 +68,6 @@ namespace Server else { Console.WriteLine("Warning: Data/bodyTable.cfg does not exist"); - - m_Types = new BodyType[0]; } } @@ -141,7 +139,7 @@ namespace Server && BodyID < m_Types.Length && m_Types[BodyID] == BodyType.Equipment; - public int BodyID{ get; } + public int BodyID { get; } public static implicit operator int(Body a) => a.BodyID; @@ -153,6 +151,10 @@ namespace Server public override bool Equals(object o) => o is Body b && b.BodyID == BodyID; + public bool Equals(Body b) => b.BodyID == BodyID; + + public bool Equals(int number) => number == BodyID; + public static bool operator ==(Body l, Body r) => l.BodyID == r.BodyID; public static bool operator !=(Body l, Body r) => l.BodyID != r.BodyID; diff --git a/Projects/Server/Buffers/BufferReader.cs b/Projects/Server/Buffers/BufferReader.cs index bc6f93eb6..f35d4629d 100644 --- a/Projects/Server/Buffers/BufferReader.cs +++ b/Projects/Server/Buffers/BufferReader.cs @@ -75,10 +75,10 @@ namespace System.Buffers { if (length < 0) { - Debug.Assert(usingSequence, "usingSequence"); // Cast-away readonly to initialize lazy field Volatile.Write(ref Unsafe.AsRef(length), sequence.Length); } + return length; } } @@ -139,27 +139,25 @@ namespace System.Buffers } else { - throw new ArgumentOutOfRangeException($"Rewind went past the start of the memory by {count}.", nameof(count)); + throw new ArgumentOutOfRangeException(nameof(count), $"Rewind went past the start of the memory by {count}."); } } [MethodImpl(MethodImplOptions.NoInlining)] private void RetreatToPreviousSpan(long consumed) { - Debug.Assert(usingSequence, "usingSequence"); ResetReader(); Advance(consumed); } private void ResetReader() { - Debug.Assert(usingSequence, "usingSequence"); CurrentSpanIndex = 0; Consumed = 0; currentPosition = sequence.Start; nextPosition = currentPosition; - if (sequence.TryGet(ref nextPosition, out ReadOnlyMemory memory)) + if (sequence.TryGet(ref nextPosition, out var memory)) { moreData = true; @@ -184,11 +182,10 @@ namespace System.Buffers private void GetNextSpan() { - Debug.Assert(usingSequence, "usingSequence"); if (!sequence.IsSingleSegment) { - SequencePosition previousNextPosition = nextPosition; - while (sequence.TryGet(ref nextPosition, out ReadOnlyMemory memory)) + var previousNextPosition = nextPosition; + while (sequence.TryGet(ref nextPosition, out var memory)) { currentPosition = previousNextPosition; if (memory.Length > 0) @@ -203,6 +200,7 @@ namespace System.Buffers previousNextPosition = nextPosition; } } + moreData = false; } @@ -234,13 +232,12 @@ namespace System.Buffers private void AdvanceToNextSpan(long count) { - Debug.Assert(usingSequence, "usingSequence"); if (count < 0) throw new ArgumentOutOfRangeException(nameof(count)); Consumed += count; while (moreData) { - int remaining = CurrentSpan.Length - CurrentSpanIndex; + var remaining = CurrentSpan.Length - CurrentSpanIndex; if (remaining > count) { @@ -253,7 +250,6 @@ namespace System.Buffers // push the current index to the end of the span. CurrentSpanIndex += remaining; count -= remaining; - Debug.Assert(count >= 0); GetNextSpan(); @@ -275,7 +271,7 @@ namespace System.Buffers // We don't provide an advance option to allow easier utilizing of stack allocated destination spans. // (Because we can make this method readonly we can guarantee that we won't capture the span.) - ReadOnlySpan firstSpan = UnreadSpan; + var firstSpan = UnreadSpan; if (firstSpan.Length >= destination.Length) { firstSpan.Slice(0, destination.Length).CopyTo(destination); @@ -292,17 +288,16 @@ namespace System.Buffers if (Remaining < destination.Length) return false; - ReadOnlySpan firstSpan = UnreadSpan; - Debug.Assert(firstSpan.Length < destination.Length); + var firstSpan = UnreadSpan; firstSpan.CopyTo(destination); - int copied = firstSpan.Length; + var copied = firstSpan.Length; - SequencePosition next = nextPosition; - while (sequence.TryGet(ref next, out ReadOnlyMemory nextSegment)) + var next = nextPosition; + while (sequence.TryGet(ref next, out var nextSegment)) if (nextSegment.Length > 0) { - ReadOnlySpan nextSpan = nextSegment.Span; - int toCopy = Math.Min(nextSpan.Length, destination.Length - copied); + var nextSpan = nextSegment.Span; + var toCopy = Math.Min(nextSpan.Length, destination.Length - copied); nextSpan.Slice(0, toCopy).CopyTo(destination.Slice(copied)); copied += toCopy; if (copied >= destination.Length) break; diff --git a/Projects/Server/Buffers/BufferReaderExtensions.cs b/Projects/Server/Buffers/BufferReaderExtensions.cs index 0365f02db..c848c80c4 100644 --- a/Projects/Server/Buffers/BufferReaderExtensions.cs +++ b/Projects/Server/Buffers/BufferReaderExtensions.cs @@ -14,7 +14,7 @@ namespace System.Buffers private static unsafe bool TryRead(ref this BufferReader reader, out T value) where T : unmanaged { - ReadOnlySpan span = reader.UnreadSpan; + var span = reader.UnreadSpan; if (span.Length < sizeof(T)) return TryReadMultisegment(ref reader, out value); value = Unsafe.ReadUnaligned(ref MemoryMarshal.GetReference(span)); @@ -25,11 +25,9 @@ namespace System.Buffers private static unsafe bool TryReadMultisegment(ref BufferReader reader, out T value) where T : unmanaged { - Debug.Assert(reader.UnreadSpan.Length < sizeof(T), "reader.UnreadSpan.Length < sizeof(T)"); - // Not enough data in the current segment, try to peek for the data we need. T buffer = default; - Span tempSpan = new Span(&buffer, sizeof(T)); + var tempSpan = new Span(&buffer, sizeof(T)); if (!reader.TryCopyTo(tempSpan)) { @@ -153,7 +151,6 @@ namespace System.Buffers return false; } - public static bool TryReadLittleEndian(ref this BufferReader reader, out ulong value) { if (TryReadLittleEndian(ref reader, out long signedvalue)) diff --git a/Projects/Server/Buffers/MemoryPoolSlab.cs b/Projects/Server/Buffers/MemoryPoolSlab.cs index 4461e572d..c79899c1c 100644 --- a/Projects/Server/Buffers/MemoryPoolSlab.cs +++ b/Projects/Server/Buffers/MemoryPoolSlab.cs @@ -16,6 +16,7 @@ namespace System.Buffers /// relocated and enables any subsections of the array to be used as native memory pointers to P/Invoked API calls. /// private GCHandle _gcHandle; + private bool _isDisposed; public MemoryPoolSlab(byte[] data) diff --git a/Projects/Server/Buffers/MemoryPoolThrowHelper.cs b/Projects/Server/Buffers/MemoryPoolThrowHelper.cs index c1ae51b7d..81a521d89 100644 --- a/Projects/Server/Buffers/MemoryPoolThrowHelper.cs +++ b/Projects/Server/Buffers/MemoryPoolThrowHelper.cs @@ -3,7 +3,6 @@ using System.Diagnostics; using System.Runtime.CompilerServices; -using System.Text; namespace System.Buffers { @@ -16,7 +15,9 @@ namespace System.Buffers [MethodImpl(MethodImplOptions.NoInlining)] private static ArgumentOutOfRangeException GetArgumentOutOfRangeException(int sourceLength, int offset) => - (uint)offset > (uint)sourceLength ? new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.offset)) : new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.length)); + (uint)offset > (uint)sourceLength + ? new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.offset)) + : new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.length)); public static void ThrowArgumentOutOfRangeException_BufferRequestTooLarge(int maxSize) { @@ -29,17 +30,15 @@ namespace System.Buffers } [MethodImpl(MethodImplOptions.NoInlining)] - private static ArgumentOutOfRangeException GetArgumentOutOfRangeException_BufferRequestTooLarge(int maxSize) => new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.size), $"Cannot allocate more than {maxSize} bytes in a single buffer"); + private static ArgumentOutOfRangeException GetArgumentOutOfRangeException_BufferRequestTooLarge(int maxSize) => + new ArgumentOutOfRangeException(GetArgumentName(ExceptionArgument.size), + $"Cannot allocate more than {maxSize} bytes in a single buffer"); [MethodImpl(MethodImplOptions.NoInlining)] - private static ObjectDisposedException GetObjectDisposedException(ExceptionArgument argument) => new ObjectDisposedException(GetArgumentName(argument)); + private static ObjectDisposedException GetObjectDisposedException(ExceptionArgument argument) => + new ObjectDisposedException(GetArgumentName(argument)); - private static string GetArgumentName(ExceptionArgument argument) - { - Debug.Assert(Enum.IsDefined(typeof(ExceptionArgument), argument), "The enum value is not defined, please check the ExceptionArgument Enum."); - - return argument.ToString(); - } + private static string GetArgumentName(ExceptionArgument argument) => argument.ToString(); public enum ExceptionArgument { diff --git a/Projects/Server/Buffers/SlabMemoryPool.cs b/Projects/Server/Buffers/SlabMemoryPool.cs index 2a73a87a6..7e7ebdb97 100644 --- a/Projects/Server/Buffers/SlabMemoryPool.cs +++ b/Projects/Server/Buffers/SlabMemoryPool.cs @@ -80,15 +80,17 @@ namespace System.Buffers /// The block that is reserved for the called. It must be passed to Return when it is no longer being used. private MemoryPoolBlock Lease() { - if (_isDisposed) MemoryPoolThrowHelper.ThrowObjectDisposedException(MemoryPoolThrowHelper.ExceptionArgument.MemoryPool); + if (_isDisposed) + MemoryPoolThrowHelper.ThrowObjectDisposedException(MemoryPoolThrowHelper.ExceptionArgument.MemoryPool); - if (_blocks.TryDequeue(out MemoryPoolBlock block)) + if (_blocks.TryDequeue(out var block)) { // block successfully taken from the stack - return it block.Lease(); return block; } + // no blocks available - grow the pool block = AllocateSlab(); block.Lease(); @@ -101,21 +103,21 @@ namespace System.Buffers /// private MemoryPoolBlock AllocateSlab() { +#pragma warning disable CA2000 // Dispose objects before losing scope var slab = MemoryPoolSlab.Create(_slabLength); +#pragma warning restore CA2000 // Dispose objects before losing scope _slabs.Push(slab); var basePtr = slab.NativePointer; // Page align the blocks var offset = (int)((((ulong)basePtr + _blockSize - 1) & ~((uint)_blockSize - 1)) - (ulong)basePtr); - // Ensure page aligned - Debug.Assert(((ulong)basePtr + (uint)offset) % _blockSize == 0); var blockCount = (_slabLength - offset) / _blockSize; Interlocked.Add(ref _totalAllocatedBlocks, blockCount); MemoryPoolBlock block = null; - for (int i = 0; i < blockCount; i++) + for (var i = 0; i < blockCount; i++) { block = new MemoryPoolBlock(this, slab, offset, _blockSize); @@ -143,12 +145,6 @@ namespace System.Buffers /// The block to return. It must have been acquired by calling Lease on the same memory pool instance. internal void Return(MemoryPoolBlock block) { -#if BLOCK_LEASE_TRACKING - Debug.Assert(block.Pool == this, "Returned block was not leased from this pool"); - Debug.Assert(block.IsLeased, $"Block being returned to pool twice: {block.Leaser}{Environment.NewLine}"); - block.IsLeased = false; -#endif - if (!_isDisposed) _blocks.Enqueue(block); else @@ -177,12 +173,12 @@ namespace System.Buffers _isDisposed = true; if (disposing) - while (_slabs.TryPop(out MemoryPoolSlab slab)) + while (_slabs.TryPop(out var slab)) // dispose managed state (managed objects). slab.Dispose(); // Discard blocks in pool - while (_blocks.TryDequeue(out MemoryPoolBlock block)) GC.SuppressFinalize(block); + while (_blocks.TryDequeue(out var block)) GC.SuppressFinalize(block); } } } diff --git a/Projects/Server/Buffers/SpanWriter.cs b/Projects/Server/Buffers/SpanWriter.cs index 4103f462d..175e3787c 100644 --- a/Projects/Server/Buffers/SpanWriter.cs +++ b/Projects/Server/Buffers/SpanWriter.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: SpanWriter.cs - Created: 2019/08/05 - Updated: 2019/12/24 * * * @@ -176,7 +176,7 @@ namespace Server.Buffers /// public void Write(ReadOnlySpan input) { - int size = Math.Min(input.Length, Length - Position); + var size = Math.Min(input.Length, Length - Position); input.Slice(0, size).CopyTo(RawSpan.Slice(Position)); Position += size; @@ -197,7 +197,7 @@ namespace Server.Buffers { value ??= ""; - int length = Math.Min(size, value.Length); + var length = Math.Min(size, value.Length); Encoding.ASCII.GetBytes(value.AsSpan(0, length), RawSpan.Slice(Position)); @@ -207,7 +207,9 @@ namespace Server.Buffers Fill(size - length); } else + { Position += size; + } } /// diff --git a/Projects/Server/CityInfo.cs b/Projects/Server/CityInfo.cs index 1a3384997..c88b80a28 100644 --- a/Projects/Server/CityInfo.cs +++ b/Projects/Server/CityInfo.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: CityInfo.cs - Created: 2019/10/04 - Updated: 2020/01/19 * * * diff --git a/Projects/Server/ClientVersion.cs b/Projects/Server/ClientVersion.cs index fd605b472..81e22d7fd 100644 --- a/Projects/Server/ClientVersion.cs +++ b/Projects/Server/ClientVersion.cs @@ -42,7 +42,7 @@ namespace Server Patch = pat; Type = type; - SourceString = _ToStringImpl(); + SourceString = ToStringImpl(); } public ClientVersion(string fmt) @@ -53,10 +53,10 @@ namespace Server { fmt = fmt.ToLower(); - int br1 = fmt.IndexOf('.'); - int br2 = fmt.IndexOf('.', br1 + 1); + var br1 = fmt.IndexOf('.'); + var br2 = fmt.IndexOf('.', br1 + 1); - int br3 = br2 + 1; + var br3 = br2 + 1; while (br3 < fmt.Length && char.IsDigit(fmt, br3)) br3++; @@ -66,7 +66,7 @@ namespace Server if (br3 < fmt.Length) { - if (Major <= 5 && Minor <= 0 && Revision <= 6) //Anything before 5.0.7 + if (Major <= 5 && Minor <= 0 && Revision <= 6) // Anything before 5.0.7 { if (!char.IsWhiteSpace(fmt, br3)) Patch = fmt[br3] - 'a' + 1; @@ -95,17 +95,17 @@ namespace Server } } - public int Major{ get; } + public int Major { get; } - public int Minor{ get; } + public int Minor { get; } - public int Revision{ get; } + public int Revision { get; } - public int Patch{ get; } + public int Patch { get; } - public ClientType Type{ get; } + public ClientType Type { get; } - public string SourceString{ get; } + public string SourceString { get; } public int CompareTo(ClientVersion o) { @@ -149,7 +149,7 @@ namespace Server public override bool Equals(object obj) { - ClientVersion v = obj as ClientVersion; + var v = obj as ClientVersion; return Major == v?.Major && Minor == v.Minor @@ -158,9 +158,9 @@ namespace Server && Type == v.Type; } - private string _ToStringImpl() + private string ToStringImpl() { - StringBuilder builder = new StringBuilder(16); + var builder = new StringBuilder(16); builder.Append(Major); builder.Append('.'); @@ -168,7 +168,7 @@ namespace Server builder.Append('.'); builder.Append(Revision); - if (Major <= 5 && Minor <= 0 && Revision <= 6) //Anything before 5.0.7 + if (Major <= 5 && Minor <= 0 && Revision <= 6) // Anything before 5.0.7 { if (Patch > 0) builder.Append((char)('a' + (Patch - 1))); @@ -188,7 +188,7 @@ namespace Server return builder.ToString(); } - public override string ToString() => _ToStringImpl(); + public override string ToString() => ToStringImpl(); public static bool IsNull(object x) => ReferenceEquals(x, null); diff --git a/Projects/Server/Collections/ArraySet.cs b/Projects/Server/Collections/ArraySet.cs index 7a3eb5729..4d32c2edf 100644 --- a/Projects/Server/Collections/ArraySet.cs +++ b/Projects/Server/Collections/ArraySet.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: ArraySet.cs - Created: 2019/10/04 - Updated: 2019/12/30 * * * @@ -28,7 +28,11 @@ namespace Server.Collections { private readonly List m_List = new List(); - public T this[int index] { get => m_List[index]; set => m_List[index] = value; } + public T this[int index] + { + get => m_List[index]; + set => m_List[index] = value; + } public int Count => m_List.Count; @@ -36,7 +40,7 @@ namespace Server.Collections public int Add(T item) { - int indexOf = m_List.IndexOf(item); + var indexOf = m_List.IndexOf(item); if (indexOf >= 0) return indexOf; diff --git a/Projects/Server/Commands.cs b/Projects/Server/Commands.cs index f9cd86ed4..4f89ac476 100644 --- a/Projects/Server/Commands.cs +++ b/Projects/Server/Commands.cs @@ -36,13 +36,13 @@ namespace Server Arguments = arguments; } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public string Command{ get; } + public string Command { get; } - public string ArgString{ get; } + public string ArgString { get; } - public string[] Arguments{ get; } + public string[] Arguments { get; } public int Length => Arguments.Length; @@ -110,39 +110,39 @@ namespace Server AccessLevel = accessLevel; } - public string Command{ get; } + public string Command { get; } - public CommandEventHandler Handler{ get; } + public CommandEventHandler Handler { get; } - public AccessLevel AccessLevel{ get; } + public AccessLevel AccessLevel { get; } public int CompareTo(CommandEntry e) => e == null ? 1 : Command.CompareTo(e.Command); } public static class CommandSystem { - public static string Prefix{ get; set; } = "["; + public static string Prefix { get; set; } = "["; - public static Dictionary Entries{ get; } = + public static Dictionary Entries { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase); - public static AccessLevel BadCommandIgnoreLevel{ get; set; } = AccessLevel.Player; + public static AccessLevel BadCommandIgnoreLevel { get; set; } = AccessLevel.Player; public static string[] Split(string value) { - char[] array = value.ToCharArray(); - List list = new List(); + var array = value.ToCharArray(); + var list = new List(); - int start = 0; + var start = 0; while (start < array.Length) { - char c = array[start]; + var c = array[start]; if (c == '"') { ++start; - int end = start; + var end = start; while (end < array.Length) if (array[end] != '"' || array[end - 1] == '\\') @@ -156,7 +156,7 @@ namespace Server } else if (c != ' ') { - int end = start; + var end = start; while (end < array.Length) if (array[end] != ' ') @@ -190,7 +190,7 @@ namespace Server if (type != MessageType.Command) text = text.Substring(Prefix.Length); - int indexOf = text.IndexOf(' '); + var indexOf = text.IndexOf(' '); string command; string[] args; @@ -207,10 +207,10 @@ namespace Server { argString = ""; command = text.ToLower(); - args = new string[0]; + args = Array.Empty(); } - Entries.TryGetValue(command, out CommandEntry entry); + Entries.TryGetValue(command, out var entry); if (entry != null) { @@ -218,7 +218,7 @@ namespace Server { if (entry.Handler != null) { - CommandEventArgs e = new CommandEventArgs(from, command, argString, args); + var e = new CommandEventArgs(from, command, argString, args); entry.Handler(e); EventSink.InvokeCommand(e); } diff --git a/Projects/Server/Configuration.cs b/Projects/Server/Configuration.cs index 0ab2b4ad8..6b9b80b51 100644 --- a/Projects/Server/Configuration.cs +++ b/Projects/Server/Configuration.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: Configuration.cs - Created: 2019/10/04 - Updated: 2020/01/19 * * * @@ -56,13 +56,13 @@ namespace Server private static Configuration ReadConfiguration() { - string relPath = new Uri($"{Core.BaseDirectory}/").MakeRelativeUri(new Uri(FilePath)).ToString(); + var relPath = new Uri($"{Core.BaseDirectory}/").MakeRelativeUri(new Uri(FilePath)).ToString(); Console.Write($"Reading configuration from {relPath}..."); Configuration config; if (File.Exists(FilePath)) { - using FileStream fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var fs = new FileStream(FilePath, FileMode.Open, FileAccess.Read, FileShare.Read); Span configBytes = stackalloc byte[(int)fs.Length]; fs.Read(configBytes); config = JsonSerializer.Deserialize(Utility.UTF8WithEncoding.GetString(configBytes)); @@ -86,10 +86,10 @@ namespace Server public void Flush() { - using FileStream fs = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write); - string configJson = JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true }); + using var fs = new FileStream(FilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Write); + var configJson = JsonSerializer.Serialize(this, new JsonSerializerOptions { WriteIndented = true }); Span data = stackalloc byte[Utility.UTF8WithEncoding.GetMaxByteCount(configJson.Length)]; - int bytesWritten = Utility.UTF8WithEncoding.GetBytes(configJson, data); + var bytesWritten = Utility.UTF8WithEncoding.GetBytes(configJson, data); fs.Write(data.Slice(0, bytesWritten)); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine($"Configuration saved to {FilePath}"); @@ -102,22 +102,31 @@ namespace Server { [JsonPropertyName("fromAddress")] public string FromAddress { get; set; } + [JsonPropertyName("fromName")] public string FromName { get; set; } + [JsonPropertyName("crashAddress")] public string crashAddress { get; set; } + [JsonPropertyName("crashName")] public string crashName { get; set; } + [JsonPropertyName("speechLogPageAddress")] public string speechLogPageAddress { get; set; } + [JsonPropertyName("speechLogPageName")] public string speechLogPageName { get; set; } + [JsonPropertyName("emailServer")] public string emailServer { get; set; } + [JsonPropertyName("emailPort")] public int emailPort { get; set; } + [JsonPropertyName("emailUsername")] public string emailUsername { get; set; } + [JsonPropertyName("emailPassword")] public string emailPassword { get; set; } } diff --git a/Projects/Server/ContextMenus/ContextMenu.cs b/Projects/Server/ContextMenus/ContextMenu.cs index 04ef03911..73b2346b7 100644 --- a/Projects/Server/ContextMenus/ContextMenu.cs +++ b/Projects/Server/ContextMenus/ContextMenu.cs @@ -45,35 +45,35 @@ namespace Server.ContextMenus From = from; Target = target; - List list = new List(); + var list = new List(); if (target is Mobile mobile) mobile.GetContextMenuEntries(from, list); else if (target is Item item) item.GetContextMenuEntries(from, list); - //m_Entries = (ContextMenuEntry[])list.ToArray( typeof( ContextMenuEntry ) ); + // m_Entries = (ContextMenuEntry[])list.ToArray( typeof( ContextMenuEntry ) ); Entries = list.ToArray(); - for (int i = 0; i < Entries.Length; ++i) + for (var i = 0; i < Entries.Length; ++i) Entries[i].Owner = this; } /// /// Gets the who opened this ContextMenu. /// - public Mobile From{ get; } + public Mobile From { get; } /// /// Gets an object of the or for which this ContextMenu is on. /// - public object Target{ get; } + public object Target { get; } /// /// Gets the list of entries contained in this ContextMenu. /// - public ContextMenuEntry[] Entries{ get; } + public ContextMenuEntry[] Entries { get; } /// /// Returns true if this ContextMenu requires packet version 2. @@ -82,7 +82,7 @@ namespace Server.ContextMenus { get { - for (int i = 0; i < Entries.Length; ++i) + for (var i = 0; i < Entries.Length; ++i) if (Entries[i].Number < 3000000 || Entries[i].Number > 3032767) return true; diff --git a/Projects/Server/ContextMenus/ContextMenuEntry.cs b/Projects/Server/ContextMenus/ContextMenuEntry.cs index 1a60e82ce..76c73f4d7 100644 --- a/Projects/Server/ContextMenus/ContextMenuEntry.cs +++ b/Projects/Server/ContextMenus/ContextMenuEntry.cs @@ -55,33 +55,33 @@ namespace Server.ContextMenus /// /// Gets or sets additional flags used in client communication. /// - public CMEFlags Flags{ get; set; } + public CMEFlags Flags { get; set; } /// /// Gets or sets the that owns this entry. /// - public ContextMenu Owner{ get; set; } + public ContextMenu Owner { get; set; } /// /// Gets or sets the localization number containing the name of this entry. /// - public int Number{ get; set; } + public int Number { get; set; } /// /// Gets or sets the maximum range at which this entry may be used, in tiles. A value of -1 signifies no maximum range. /// - public int Range{ get; set; } + public int Range { get; set; } /// /// Gets or sets the color for this entry. Format is A1-R5-G5-B5. /// - public int Color{ get; set; } + public int Color { get; set; } /// /// Gets or sets whether this entry is enabled. When false, the entry will appear in a gray hue and /// will never be invoked. /// - public bool Enabled{ get; set; } + public bool Enabled { get; set; } /// /// Gets a value indicating if non local use of this entry is permitted. diff --git a/Projects/Server/ContextMenus/OpenBackpackEntry.cs b/Projects/Server/ContextMenus/OpenBackpackEntry.cs index 7664bf43e..f72677908 100644 --- a/Projects/Server/ContextMenus/OpenBackpackEntry.cs +++ b/Projects/Server/ContextMenus/OpenBackpackEntry.cs @@ -31,4 +31,4 @@ namespace Server.ContextMenus m_Mobile.Use(m_Mobile.Backpack); } } -} \ No newline at end of file +} diff --git a/Projects/Server/ContextMenus/PaperdollEntry.cs b/Projects/Server/ContextMenus/PaperdollEntry.cs index 717c12fd5..de048b565 100644 --- a/Projects/Server/ContextMenus/PaperdollEntry.cs +++ b/Projects/Server/ContextMenus/PaperdollEntry.cs @@ -32,4 +32,4 @@ namespace Server.ContextMenus m_Mobile.DisplayPaperdollTo(Owner.From); } } -} \ No newline at end of file +} diff --git a/Projects/Server/Diagnostics/BaseProfile.cs b/Projects/Server/Diagnostics/BaseProfile.cs index 086042ade..1d119e153 100644 --- a/Projects/Server/Diagnostics/BaseProfile.cs +++ b/Projects/Server/Diagnostics/BaseProfile.cs @@ -36,23 +36,23 @@ namespace Server.Diagnostics _stopwatch = new Stopwatch(); } - public string Name{ get; } + public string Name { get; } - public long Count{ get; private set; } + public long Count { get; private set; } public TimeSpan AverageTime => TimeSpan.FromTicks(TotalTime.Ticks / Math.Max(1, Count)); - public TimeSpan PeakTime{ get; private set; } + public TimeSpan PeakTime { get; private set; } - public TimeSpan TotalTime{ get; private set; } + public TimeSpan TotalTime { get; private set; } public static void WriteAll(TextWriter op, IEnumerable profiles) where T : BaseProfile { - List list = new List(profiles); + var list = new List(profiles); - list.Sort(delegate(T a, T b) { return -a.TotalTime.CompareTo(b.TotalTime); }); + list.Sort((a, b) => -a.TotalTime.CompareTo(b.TotalTime)); - foreach (T prof in list) + foreach (var prof in list) { prof.WriteTo(op); op.WriteLine(); @@ -68,7 +68,7 @@ namespace Server.Diagnostics public virtual void Finish() { - TimeSpan elapsed = _stopwatch.Elapsed; + var elapsed = _stopwatch.Elapsed; TotalTime += elapsed; @@ -85,4 +85,4 @@ namespace Server.Diagnostics PeakTime.TotalSeconds, TotalTime.TotalSeconds); } } -} \ No newline at end of file +} diff --git a/Projects/Server/Diagnostics/GumpProfile.cs b/Projects/Server/Diagnostics/GumpProfile.cs index 190ba1327..3687cc307 100644 --- a/Projects/Server/Diagnostics/GumpProfile.cs +++ b/Projects/Server/Diagnostics/GumpProfile.cs @@ -38,7 +38,7 @@ namespace Server.Diagnostics if (!Core.Profiling) return null; - if (!_profiles.TryGetValue(type, out GumpProfile prof)) + if (!_profiles.TryGetValue(type, out var prof)) _profiles.Add(type, prof = new GumpProfile(type)); return prof; diff --git a/Projects/Server/Diagnostics/PacketProfile.cs b/Projects/Server/Diagnostics/PacketProfile.cs index 6f9ee132b..d39c906ee 100644 --- a/Projects/Server/Diagnostics/PacketProfile.cs +++ b/Projects/Server/Diagnostics/PacketProfile.cs @@ -32,7 +32,7 @@ namespace Server.Diagnostics { } - public long TotalLength{ get; private set; } + public long TotalLength { get; private set; } public double AverageLength => (double)TotalLength / Math.Max(1, Count); @@ -66,7 +66,7 @@ namespace Server.Diagnostics [MethodImpl(MethodImplOptions.Synchronized)] public static PacketSendProfile Acquire(Type type) { - if (!_profiles.TryGetValue(type, out PacketSendProfile prof)) + if (!_profiles.TryGetValue(type, out var prof)) _profiles.Add(type, prof = new PacketSendProfile(type)); return prof; @@ -99,7 +99,7 @@ namespace Server.Diagnostics [MethodImpl(MethodImplOptions.Synchronized)] public static PacketReceiveProfile Acquire(int packetId) { - if (!_profiles.TryGetValue(packetId, out PacketReceiveProfile prof)) + if (!_profiles.TryGetValue(packetId, out var prof)) _profiles.Add(packetId, prof = new PacketReceiveProfile(packetId)); return prof; diff --git a/Projects/Server/Diagnostics/TargetProfile.cs b/Projects/Server/Diagnostics/TargetProfile.cs index d16312209..67bca020e 100644 --- a/Projects/Server/Diagnostics/TargetProfile.cs +++ b/Projects/Server/Diagnostics/TargetProfile.cs @@ -39,7 +39,7 @@ namespace Server.Diagnostics if (!Core.Profiling) return null; - if (!_profiles.TryGetValue(type, out TargetProfile prof)) + if (!_profiles.TryGetValue(type, out var prof)) _profiles.Add(type, prof = new TargetProfile(type)); return prof; diff --git a/Projects/Server/Diagnostics/TimerProfile.cs b/Projects/Server/Diagnostics/TimerProfile.cs index 90c336397..9f1780e02 100644 --- a/Projects/Server/Diagnostics/TimerProfile.cs +++ b/Projects/Server/Diagnostics/TimerProfile.cs @@ -34,18 +34,18 @@ namespace Server.Diagnostics public static IEnumerable Profiles => _profiles.Values; - public long Created{ get; set; } + public long Created { get; set; } - public long Started{ get; set; } + public long Started { get; set; } - public long Stopped{ get; set; } + public long Stopped { get; set; } public static TimerProfile Acquire(string name) { if (!Core.Profiling) return null; - if (!_profiles.TryGetValue(name, out TimerProfile prof)) + if (!_profiles.TryGetValue(name, out var prof)) _profiles.Add(name, prof = new TimerProfile(name)); return prof; diff --git a/Projects/Server/Effects.cs b/Projects/Server/Effects.cs index e58b1c2b7..929f774e7 100644 --- a/Projects/Server/Effects.cs +++ b/Projects/Server/Effects.cs @@ -42,11 +42,11 @@ namespace Server public static class Effects { - public static ParticleSupportType ParticleSupportType{ get; set; } = ParticleSupportType.Detect; + public static ParticleSupportType ParticleSupportType { get; set; } = ParticleSupportType.Detect; public static bool SendParticlesTo(NetState state) => ParticleSupportType == ParticleSupportType.Full || - ParticleSupportType == ParticleSupportType.Detect && state.IsUOTDClient; + (ParticleSupportType == ParticleSupportType.Detect && state.IsUOTDClient); public static void PlaySound(IPoint3D p, Map map, int soundID) { @@ -57,9 +57,9 @@ namespace Server { Packet playSound = null; - IPooledEnumerable eable = map.GetClientsInRange(new Point3D(p)); + var eable = map.GetClientsInRange(new Point3D(p)); - foreach (NetState state in eable) + foreach (var state in eable) { state.Mobile.ProcessDelta(); @@ -86,7 +86,7 @@ namespace Server public static void SendBoltEffect(IEntity e, bool sound, int hue) { - Map map = e.Map; + var map = e.Map; if (map == null) return; @@ -95,9 +95,9 @@ namespace Server Packet preEffect = null, boltEffect = null, playSound = null; - IPooledEnumerable eable = map.GetClientsInRange(e.Location); + var eable = map.GetClientsInRange(e.Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state.Mobile.CanSee(e)) { if (SendParticlesTo(state)) @@ -160,21 +160,22 @@ namespace Server public static void SendLocationParticles(IEntity e, int itemID, int speed, int duration, int hue, int renderMode, int effect, int unknown) { - Map map = e.Map; + var map = e.Map; if (map != null) { Packet particles = null, regular = null; - IPooledEnumerable eable = map.GetClientsInRange(e.Location); + var eable = map.GetClientsInRange(e.Location); - foreach (NetState state in eable) + foreach (var state in eable) { state.Mobile.ProcessDelta(); if (SendParticlesTo(state)) { - particles ??= Packet.Acquire(new LocationParticleEffect(e, itemID, speed, duration, hue, renderMode, effect, unknown)); + particles ??= + Packet.Acquire(new LocationParticleEffect(e, itemID, speed, duration, hue, renderMode, effect, unknown)); state.Send(particles); } @@ -192,7 +193,7 @@ namespace Server eable.Free(); } - //SendPacket( e.Location, e.Map, new LocationParticleEffect( e, itemID, speed, duration, hue, renderMode, effect, unknown ) ); + // SendPacket( e.Location, e.Map, new LocationParticleEffect( e, itemID, speed, duration, hue, renderMode, effect, unknown ) ); } public static void SendTargetEffect(IEntity target, int itemID, int duration) @@ -236,21 +237,22 @@ namespace Server if (target is Mobile mobile) mobile.ProcessDelta(); - Map map = target.Map; + var map = target.Map; if (map != null) { Packet particles = null, regular = null; - IPooledEnumerable eable = map.GetClientsInRange(target.Location); + var eable = map.GetClientsInRange(target.Location); - foreach (NetState state in eable) + foreach (var state in eable) { state.Mobile.ProcessDelta(); if (SendParticlesTo(state)) { - particles ??= Packet.Acquire(new TargetParticleEffect(target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown)); + particles ??= Packet.Acquire(new TargetParticleEffect(target, itemID, speed, duration, hue, renderMode, effect, + (int)layer, unknown)); state.Send(particles); } @@ -268,7 +270,7 @@ namespace Server eable.Free(); } - //SendPacket( target.Location, target.Map, new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) ); + // SendPacket( target.Location, target.Map, new TargetParticleEffect( target, itemID, speed, duration, hue, renderMode, effect, (int)layer, unknown ) ); } public static void SendMovingEffect(IEntity from, IEntity to, int itemID, int speed, int duration, @@ -316,15 +318,15 @@ namespace Server if (to is Mobile toMob) toMob.ProcessDelta(); - Map map = from.Map; + var map = from.Map; if (map != null) { Packet particles = null, regular = null; - IPooledEnumerable eable = map.GetClientsInRange(from.Location); + var eable = map.GetClientsInRange(from.Location); - foreach (NetState state in eable) + foreach (var state in eable) { state.Mobile.ProcessDelta(); @@ -337,7 +339,8 @@ namespace Server } else if (itemID > 1) { - regular ??= Packet.Acquire(new MovingEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode)); + regular ??= Packet.Acquire(new MovingEffect(from, to, itemID, speed, duration, fixedDirection, explodes, hue, + renderMode)); state.Send(regular); } @@ -349,7 +352,7 @@ namespace Server eable.Free(); } - //SendPacket( from.Location, from.Map, new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, unknown ) ); + // SendPacket( from.Location, from.Map, new MovingParticleEffect( from, to, itemID, speed, duration, fixedDirection, explodes, hue, renderMode, effect, explodeEffect, explodeSound, unknown ) ); } public static void SendPacket(Point3D origin, Map map, Packet p) @@ -357,11 +360,11 @@ namespace Server if (map == null) return; - IPooledEnumerable eable = map.GetClientsInRange(origin); + var eable = map.GetClientsInRange(origin); p.Acquire(); - foreach (NetState state in eable) + foreach (var state in eable) { state.Mobile.ProcessDelta(); state.Send(p); @@ -377,11 +380,11 @@ namespace Server if (map == null) return; - IPooledEnumerable eable = map.GetClientsInRange(new Point3D(origin)); + var eable = map.GetClientsInRange(new Point3D(origin)); p.Acquire(); - foreach (NetState state in eable) + foreach (var state in eable) { state.Mobile.ProcessDelta(); state.Send(p); diff --git a/Projects/Server/Events/AccountLoginEvent.cs b/Projects/Server/Events/AccountLoginEvent.cs index 7fc1df036..b18603080 100644 --- a/Projects/Server/Events/AccountLoginEvent.cs +++ b/Projects/Server/Events/AccountLoginEvent.cs @@ -33,15 +33,15 @@ namespace Server Password = password; } - public NetState State{ get; } + public NetState State { get; } - public string Username{ get; } + public string Username { get; } - public string Password{ get; } + public string Password { get; } - public bool Accepted{ get; set; } + public bool Accepted { get; set; } - public ALRReason RejectReason{ get; set; } + public ALRReason RejectReason { get; set; } } public static partial class EventSink diff --git a/Projects/Server/Events/AggressiveActionEvent.cs b/Projects/Server/Events/AggressiveActionEvent.cs index c4f4ae29e..9baf886c7 100644 --- a/Projects/Server/Events/AggressiveActionEvent.cs +++ b/Projects/Server/Events/AggressiveActionEvent.cs @@ -26,7 +26,7 @@ namespace Server { public class AggressiveActionEventArgs : EventArgs { - private static Queue m_Pool = new Queue(); + private static readonly Queue m_Pool = new Queue(); private AggressiveActionEventArgs(Mobile aggressed, Mobile aggressor, bool criminal) { @@ -35,11 +35,11 @@ namespace Server Criminal = criminal; } - public Mobile Aggressed{ get; private set; } + public Mobile Aggressed { get; private set; } - public Mobile Aggressor{ get; private set; } + public Mobile Aggressor { get; private set; } - public bool Criminal{ get; private set; } + public bool Criminal { get; private set; } public static AggressiveActionEventArgs Create(Mobile aggressed, Mobile aggressor, bool criminal) { diff --git a/Projects/Server/Events/CharacterCreatedEvent.cs b/Projects/Server/Events/CharacterCreatedEvent.cs index 0ed478396..f3f53db35 100644 --- a/Projects/Server/Events/CharacterCreatedEvent.cs +++ b/Projects/Server/Events/CharacterCreatedEvent.cs @@ -51,50 +51,50 @@ namespace Server Race = race; } - public NetState State{ get; } + public NetState State { get; } - public IAccount Account{ get; } + public IAccount Account { get; } - public Mobile Mobile{ get; set; } + public Mobile Mobile { get; set; } - public string Name{ get; } + public string Name { get; } - public bool Female{ get; } + public bool Female { get; } - public int Hue{ get; } + public int Hue { get; } - public int Str{ get; } + public int Str { get; } - public int Dex{ get; } + public int Dex { get; } - public int Int{ get; } + public int Int { get; } - public CityInfo City{ get; } + public CityInfo City { get; } - public SkillNameValue[] Skills{ get; } + public SkillNameValue[] Skills { get; } - public int ShirtHue{ get; } + public int ShirtHue { get; } - public int PantsHue{ get; } + public int PantsHue { get; } - public int HairID{ get; } + public int HairID { get; } - public int HairHue{ get; } + public int HairHue { get; } - public int BeardID{ get; } + public int BeardID { get; } - public int BeardHue{ get; } + public int BeardHue { get; } - public int Profession{ get; set; } + public int Profession { get; set; } - public Race Race{ get; } + public Race Race { get; } } public struct SkillNameValue { - public SkillName Name{ get; } + public SkillName Name { get; } - public int Value{ get; } + public int Value { get; } public SkillNameValue(SkillName name, int value) { @@ -103,7 +103,8 @@ namespace Server } } - public static partial class EventSink { + public static partial class EventSink + { public static event Action CharacterCreated; public static void InvokeCharacterCreated(CharacterCreatedEventArgs e) => CharacterCreated?.Invoke(e); } diff --git a/Projects/Server/Events/CreateGuildEvent.cs b/Projects/Server/Events/CreateGuildEvent.cs index 4020b92f0..fe1e53080 100644 --- a/Projects/Server/Events/CreateGuildEvent.cs +++ b/Projects/Server/Events/CreateGuildEvent.cs @@ -28,9 +28,9 @@ namespace Server { public CreateGuildEventArgs(uint id) => Id = id; - public uint Id{ get; set; } + public uint Id { get; set; } - public BaseGuild Guild{ get; set; } + public BaseGuild Guild { get; set; } } public static partial class EventSink diff --git a/Projects/Server/Events/EventSink.cs b/Projects/Server/Events/EventSink.cs index 3a3ceb79e..6d43d88cf 100644 --- a/Projects/Server/Events/EventSink.cs +++ b/Projects/Server/Events/EventSink.cs @@ -52,10 +52,14 @@ namespace Server public static void InvokeOpenSpellbookRequest(Mobile m, int type) => OpenSpellbookRequest?.Invoke(m, type); public static event Action CastSpellRequest; - public static void InvokeCastSpellRequest(Mobile m, int spellID, Item book) => CastSpellRequest?.Invoke(m, spellID, book); + + public static void InvokeCastSpellRequest(Mobile m, int spellID, Item book) => + CastSpellRequest?.Invoke(m, spellID, book); public static event Action BandageTargetRequest; - public static void InvokeBandageTargetRequest(Mobile m, Item bandage, Mobile target) => BandageTargetRequest?.Invoke(m, bandage, target); + + public static void InvokeBandageTargetRequest(Mobile m, Item bandage, Mobile target) => + BandageTargetRequest?.Invoke(m, bandage, target); public static event Action AnimateRequest; public static void InvokeAnimateRequest(Mobile m, string action) => AnimateRequest?.Invoke(m, action); @@ -70,16 +74,22 @@ namespace Server public static void InvokeDisconnected(Mobile m) => Disconnected?.Invoke(m); public static event Action RenameRequest; - public static void InvokeRenameRequest(Mobile from, Mobile target, string name) => RenameRequest?.Invoke(from, target, name); + + public static void InvokeRenameRequest(Mobile from, Mobile target, string name) => + RenameRequest?.Invoke(from, target, name); public static event Action PlayerDeath; public static void InvokePlayerDeath(Mobile m) => PlayerDeath?.Invoke(m); public static event Action VirtueGumpRequest; - public static void InvokeVirtueGumpRequest(Mobile beholder, Mobile beheld) => VirtueGumpRequest?.Invoke(beholder, beheld); + + public static void InvokeVirtueGumpRequest(Mobile beholder, Mobile beheld) => + VirtueGumpRequest?.Invoke(beholder, beheld); public static event Action VirtueItemRequest; - public static void InvokeVirtueItemRequest(Mobile beholder, Mobile beheld, int gumpID) => VirtueItemRequest?.Invoke(beholder, beheld, gumpID); + + public static void InvokeVirtueItemRequest(Mobile beholder, Mobile beheld, int gumpID) => + VirtueItemRequest?.Invoke(beholder, beheld, gumpID); public static event Action VirtueMacroRequest; public static void InvokeVirtueMacroRequest(Mobile mobile, int virtueID) => VirtueMacroRequest?.Invoke(mobile, virtueID); @@ -87,18 +97,17 @@ namespace Server public static event Action ChatRequest; public static void InvokeChatRequest(Mobile m) => ChatRequest?.Invoke(m); - public static event Action PaperdollRequest; - public static void InvokePaperdollRequest(Mobile beholder, Mobile beheld) => PaperdollRequest?.Invoke(beholder ,beheld); + public static void InvokePaperdollRequest(Mobile beholder, Mobile beheld) => PaperdollRequest?.Invoke(beholder, beheld); public static event Action ProfileRequest; public static void InvokeProfileRequest(Mobile beholder, Mobile beheld) => ProfileRequest?.Invoke(beholder, beheld); public static event Action ChangeProfileRequest; + public static void InvokeChangeProfileRequest(Mobile beholder, Mobile beheld, string text) => ChangeProfileRequest?.Invoke(beholder, beheld, text); - public static event Action DeleteRequest; public static void InvokeDeleteRequest(NetState state, int index) => DeleteRequest?.Invoke(state, index); @@ -121,9 +130,12 @@ namespace Server public static void InvokeQuestGumpRequest(Mobile m) => QuestGumpRequest?.Invoke(m); public static event Action ClientVersionReceived; - public static void InvokeClientVersionReceived(NetState state, ClientVersion cv) => ClientVersionReceived?.Invoke(state, cv); + + public static void InvokeClientVersionReceived(NetState state, ClientVersion cv) => + ClientVersionReceived?.Invoke(state, cv); public static event Action> EquipMacro; + public static void InvokeEquipMacro(Mobile m, List list) { if (list?.Count > 0) @@ -139,12 +151,18 @@ namespace Server } public static event Action TargetedSpell; - public static void InvokeTargetedSpell(Mobile m, IEntity target, int spellId) => TargetedSpell?.Invoke(m, target, spellId); + + public static void InvokeTargetedSpell(Mobile m, IEntity target, int spellId) => + TargetedSpell?.Invoke(m, target, spellId); public static event Action TargetedSkillUse; - public static void InvokeTargetedSkillUse(Mobile m, IEntity target, int skillId) => TargetedSkillUse?.Invoke(m, target, skillId); + + public static void InvokeTargetedSkillUse(Mobile m, IEntity target, int skillId) => + TargetedSkillUse?.Invoke(m, target, skillId); public static event Action TargetByResourceMacro; - public static void InvokeTargetByResourceMacro(Mobile m, Item item, short resourceType) => TargetByResourceMacro?.Invoke(m, item, resourceType); + + public static void InvokeTargetByResourceMacro(Mobile m, Item item, short resourceType) => + TargetByResourceMacro?.Invoke(m, item, resourceType); } } diff --git a/Projects/Server/Events/FastwalkEvent.cs b/Projects/Server/Events/FastwalkEvent.cs index a40757d16..c99dd301a 100644 --- a/Projects/Server/Events/FastwalkEvent.cs +++ b/Projects/Server/Events/FastwalkEvent.cs @@ -32,9 +32,9 @@ namespace Server Blocked = false; } - public NetState NetState{ get; } + public NetState NetState { get; } - public bool Blocked{ get; set; } + public bool Blocked { get; set; } } public static partial class EventSink diff --git a/Projects/Server/Events/GameLoginEvent.cs b/Projects/Server/Events/GameLoginEvent.cs index 054a5db4b..698291286 100644 --- a/Projects/Server/Events/GameLoginEvent.cs +++ b/Projects/Server/Events/GameLoginEvent.cs @@ -33,15 +33,15 @@ namespace Server Password = pw; } - public NetState State{ get; } + public NetState State { get; } - public string Username{ get; } + public string Username { get; } - public string Password{ get; } + public string Password { get; } - public bool Accepted{ get; set; } + public bool Accepted { get; set; } - public CityInfo[] CityInfo{ get; set; } + public CityInfo[] CityInfo { get; set; } } public static partial class EventSink diff --git a/Projects/Server/Events/MovementEvent.cs b/Projects/Server/Events/MovementEvent.cs index 6e63d6d4c..68e29bd56 100644 --- a/Projects/Server/Events/MovementEvent.cs +++ b/Projects/Server/Events/MovementEvent.cs @@ -26,7 +26,7 @@ namespace Server { public class MovementEventArgs : EventArgs { - private static Queue m_Pool = new Queue(); + private static readonly Queue m_Pool = new Queue(); public MovementEventArgs(Mobile mobile, Direction dir) { @@ -34,11 +34,11 @@ namespace Server Direction = dir; } - public Mobile Mobile{ get; private set; } + public Mobile Mobile { get; private set; } - public Direction Direction{ get; private set; } + public Direction Direction { get; private set; } - public bool Blocked{ get; set; } + public bool Blocked { get; set; } public static MovementEventArgs Create(Mobile mobile, Direction dir) { diff --git a/Projects/Server/Events/ServerCrashedEvent.cs b/Projects/Server/Events/ServerCrashedEvent.cs index 0bda10110..a5568810d 100644 --- a/Projects/Server/Events/ServerCrashedEvent.cs +++ b/Projects/Server/Events/ServerCrashedEvent.cs @@ -27,9 +27,9 @@ namespace Server { public ServerCrashedEventArgs(Exception e) => Exception = e; - public Exception Exception{ get; } + public Exception Exception { get; } - public bool Close{ get; set; } + public bool Close { get; set; } } public static partial class EventSink diff --git a/Projects/Server/Events/ServerListEvent.cs b/Projects/Server/Events/ServerListEvent.cs index b403933cf..0e0044b11 100644 --- a/Projects/Server/Events/ServerListEvent.cs +++ b/Projects/Server/Events/ServerListEvent.cs @@ -36,13 +36,13 @@ namespace Server Servers = new List(); } - public NetState State{ get; } + public NetState State { get; } - public IAccount Account{ get; } + public IAccount Account { get; } - public bool Rejected{ get; set; } + public bool Rejected { get; set; } - public List Servers{ get; } + public List Servers { get; } public void AddServer(string name, IPEndPoint address) { diff --git a/Projects/Server/Events/SocketConnectionEvent.cs b/Projects/Server/Events/SocketConnectionEvent.cs index bef6f8c72..870e4152c 100644 --- a/Projects/Server/Events/SocketConnectionEvent.cs +++ b/Projects/Server/Events/SocketConnectionEvent.cs @@ -32,9 +32,9 @@ namespace Server AllowConnection = true; } - public ConnectionContext Context{ get; } + public ConnectionContext Context { get; } - public bool AllowConnection{ get; set; } + public bool AllowConnection { get; set; } } public static partial class EventSink diff --git a/Projects/Server/Events/SpeechEvent.cs b/Projects/Server/Events/SpeechEvent.cs index 2f1a76086..9b1468343 100644 --- a/Projects/Server/Events/SpeechEvent.cs +++ b/Projects/Server/Events/SpeechEvent.cs @@ -14,23 +14,23 @@ namespace Server Keywords = keywords; } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public string Speech{ get; set; } + public string Speech { get; set; } - public MessageType Type{ get; } + public MessageType Type { get; } - public int Hue{ get; } + public int Hue { get; } - public int[] Keywords{ get; } + public int[] Keywords { get; } - public bool Handled{ get; set; } + public bool Handled { get; set; } - public bool Blocked{ get; set; } + public bool Blocked { get; set; } public bool HasKeyword(int keyword) { - for (int i = 0; i < Keywords.Length; ++i) + for (var i = 0; i < Keywords.Length; ++i) if (Keywords[i] == keyword) return true; diff --git a/Projects/Server/ExpansionInfo.cs b/Projects/Server/ExpansionInfo.cs index c04f891ad..450e010a7 100644 --- a/Projects/Server/ExpansionInfo.cs +++ b/Projects/Server/ExpansionInfo.cs @@ -117,11 +117,11 @@ namespace Server NewMovementSystem = 0x00004000, NewFeluccaAreas = 0x00008000, - ExpansionNone = ContextMenus, // - ExpansionT2A = ContextMenus, // - ExpansionUOR = ContextMenus, // None - ExpansionUOTD = ContextMenus, // - ExpansionLBR = ContextMenus, // + ExpansionNone = ContextMenus, + ExpansionT2A = ContextMenus, + ExpansionUOR = ContextMenus, + ExpansionUOTD = ContextMenus, + ExpansionLBR = ContextMenus, ExpansionAOS = ContextMenus | AOS, ExpansionSE = ExpansionAOS | SE, ExpansionML = ExpansionSE | ML, @@ -169,96 +169,84 @@ namespace Server ClientFlags.None, FeatureFlags.ExpansionNone, CharacterListFlags.ExpansionNone, - HousingFlags.None - ), + HousingFlags.None), new ExpansionInfo( 1, "The Second Age", ClientFlags.Felucca, FeatureFlags.ExpansionT2A, CharacterListFlags.ExpansionT2A, - HousingFlags.None - ), + HousingFlags.None), new ExpansionInfo( 2, "Renaissance", ClientFlags.Trammel, FeatureFlags.ExpansionUOR, CharacterListFlags.ExpansionUOR, - HousingFlags.None - ), + HousingFlags.None), new ExpansionInfo( 3, "Third Dawn", ClientFlags.Ilshenar, FeatureFlags.ExpansionUOTD, CharacterListFlags.ExpansionUOTD, - HousingFlags.None - ), + HousingFlags.None), new ExpansionInfo( 4, "Blackthorn's Revenge", ClientFlags.Ilshenar, FeatureFlags.ExpansionLBR, CharacterListFlags.ExpansionLBR, - HousingFlags.None - ), + HousingFlags.None), new ExpansionInfo( 5, "Age of Shadows", ClientFlags.Malas, FeatureFlags.ExpansionAOS, CharacterListFlags.ExpansionAOS, - HousingFlags.HousingAOS - ), + HousingFlags.HousingAOS), new ExpansionInfo( 6, "Samurai Empire", ClientFlags.Tokuno, FeatureFlags.ExpansionSE, CharacterListFlags.ExpansionSE, - HousingFlags.HousingSE - ), + HousingFlags.HousingSE), new ExpansionInfo( 7, "Mondain's Legacy", new ClientVersion("5.0.0a"), FeatureFlags.ExpansionML, CharacterListFlags.ExpansionML, - HousingFlags.HousingML - ), + HousingFlags.HousingML), new ExpansionInfo( 8, "Stygian Abyss", ClientFlags.TerMur, FeatureFlags.ExpansionSA, CharacterListFlags.ExpansionSA, - HousingFlags.HousingSA - ), + HousingFlags.HousingSA), new ExpansionInfo( 9, "High Seas", new ClientVersion("7.0.9.0"), FeatureFlags.ExpansionHS, CharacterListFlags.ExpansionHS, - HousingFlags.HousingHS - ), + HousingFlags.HousingHS), new ExpansionInfo( 10, "Time of Legends", new ClientVersion("7.0.45.65"), FeatureFlags.ExpansionTOL, CharacterListFlags.ExpansionTOL, - HousingFlags.HousingTOL - ), + HousingFlags.HousingTOL), new ExpansionInfo( 11, "Endless Journey", new ClientVersion("7.0.61.0"), FeatureFlags.ExpansionEJ, CharacterListFlags.ExpansionEJ, - HousingFlags.HousingEJ - ) + HousingFlags.HousingEJ) }; } @@ -299,20 +287,20 @@ namespace Server public static ExpansionInfo CoreExpansion => GetInfo(Core.Expansion); - public static ExpansionInfo[] Table{ get; } + public static ExpansionInfo[] Table { get; } - public int ID{ get; } - public string Name{ get; set; } + public int ID { get; } + public string Name { get; set; } - public ClientFlags ClientFlags{ get; set; } - public FeatureFlags SupportedFeatures{ get; set; } - public CharacterListFlags CharacterListFlags{ get; set; } - public ClientVersion RequiredClient{ get; set; } - public HousingFlags CustomHousingFlag{ get; set; } + public ClientFlags ClientFlags { get; set; } + public FeatureFlags SupportedFeatures { get; set; } + public CharacterListFlags CharacterListFlags { get; set; } + public ClientVersion RequiredClient { get; set; } + public HousingFlags CustomHousingFlag { get; set; } public static FeatureFlags GetFeatures(Expansion ex) { - ExpansionInfo info = GetInfo(ex); + var info = GetInfo(ex); if (info != null) return info.SupportedFeatures; @@ -338,7 +326,7 @@ namespace Server public static ExpansionInfo GetInfo(int ex) { - int v = ex; + var v = ex; if (v < 0 || v >= Table.Length) v = 0; diff --git a/Projects/Server/Geometry.cs b/Projects/Server/Geometry.cs index a86248fff..93b960679 100644 --- a/Projects/Server/Geometry.cs +++ b/Projects/Server/Geometry.cs @@ -23,7 +23,7 @@ using System; namespace Server { [Parsable] - public struct Point2D : IPoint2D, IComparable + public struct Point2D : IPoint2D, IComparable, IEquatable, IEquatable { internal int m_X; internal int m_Y; @@ -58,22 +58,22 @@ namespace Server public static Point2D Parse(string value) { - int start = value.IndexOf('('); - int end = value.IndexOf(',', start + 1); + var start = value.IndexOf('('); + var end = value.IndexOf(',', start + 1); - string param1 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param1 = value.Substring(start + 1, end - (start + 1)).Trim(); start = end; end = value.IndexOf(')', start + 1); - string param2 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param2 = value.Substring(start + 1, end - (start + 1)).Trim(); return new Point2D(Convert.ToInt32(param1), Convert.ToInt32(param2)); } public int CompareTo(Point2D other) { - int v = m_X.CompareTo(other.m_X); + var v = m_X.CompareTo(other.m_X); if (v == 0) v = m_Y.CompareTo(other.m_Y); @@ -83,6 +83,8 @@ namespace Server public override bool Equals(object o) => o is IPoint2D p && m_X == p.X && m_Y == p.Y; + public bool Equals(Point2D p) => m_X == p.X && m_Y == p.Y; + public override int GetHashCode() => m_X ^ m_Y; public static bool operator ==(Point2D l, Point2D r) => l.m_X == r.m_X && l.m_Y == r.m_Y; @@ -119,7 +121,7 @@ namespace Server } [Parsable] - public struct Point3D : IPoint3D, IComparable + public struct Point3D : IPoint3D, IComparable, IEquatable, IEquatable { internal int m_X; internal int m_Y; @@ -169,24 +171,26 @@ namespace Server public override bool Equals(object o) => o is IPoint3D p && m_X == p.X && m_Y == p.Y && m_Z == p.Z; + public bool Equals(Point3D p) => m_X == p.X && m_Y == p.Y && m_Z == p.Z; + public override int GetHashCode() => m_X ^ m_Y ^ m_Z; public static Point3D Parse(string value) { - int start = value.IndexOf('('); - int end = value.IndexOf(',', start + 1); + var start = value.IndexOf('('); + var end = value.IndexOf(',', start + 1); - string param1 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param1 = value.Substring(start + 1, end - (start + 1)).Trim(); start = end; end = value.IndexOf(',', start + 1); - string param2 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param2 = value.Substring(start + 1, end - (start + 1)).Trim(); start = end; end = value.IndexOf(')', start + 1); - string param3 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param3 = value.Substring(start + 1, end - (start + 1)).Trim(); return new Point3D(Convert.ToInt32(param1), Convert.ToInt32(param2), Convert.ToInt32(param3)); } @@ -195,13 +199,15 @@ namespace Server public static bool operator !=(Point3D l, Point3D r) => l.m_X != r.m_X || l.m_Y != r.m_Y || l.m_Z != r.m_Z; - public static bool operator ==(Point3D l, IPoint3D r) => !ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z; + public static bool operator ==(Point3D l, IPoint3D r) => + !ReferenceEquals(r, null) && l.m_X == r.X && l.m_Y == r.Y && l.m_Z == r.Z; - public static bool operator !=(Point3D l, IPoint3D r) => !ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z); + public static bool operator !=(Point3D l, IPoint3D r) => + !ReferenceEquals(r, null) && (l.m_X != r.X || l.m_Y != r.Y || l.m_Z != r.Z); public int CompareTo(Point3D other) { - int v = m_X.CompareTo(other.m_X); + var v = m_X.CompareTo(other.m_X); if (v == 0) { @@ -243,25 +249,25 @@ namespace Server public static Rectangle2D Parse(string value) { - int start = value.IndexOf('('); - int end = value.IndexOf(',', start + 1); + var start = value.IndexOf('('); + var end = value.IndexOf(',', start + 1); - string param1 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param1 = value.Substring(start + 1, end - (start + 1)).Trim(); start = end; end = value.IndexOf(',', start + 1); - string param2 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param2 = value.Substring(start + 1, end - (start + 1)).Trim(); start = end; end = value.IndexOf(',', start + 1); - string param3 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param3 = value.Substring(start + 1, end - (start + 1)).Trim(); start = end; end = value.IndexOf(')', start + 1); - string param4 = value.Substring(start + 1, end - (start + 1)).Trim(); + var param4 = value.Substring(start + 1, end - (start + 1)).Trim(); return new Rectangle2D(Convert.ToInt32(param1), Convert.ToInt32(param2), Convert.ToInt32(param3), Convert.ToInt32(param4)); @@ -324,9 +330,11 @@ namespace Server m_End.m_Y = r.m_End.m_Y; } - public bool Contains(Point3D p) => m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y; + public bool Contains(Point3D p) => + m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y; - public bool Contains(Point2D p) => m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y; + public bool Contains(Point2D p) => + m_Start.m_X <= p.m_X && m_Start.m_Y <= p.m_Y && m_End.m_X > p.m_X && m_End.m_Y > p.m_Y; public bool Contains(IPoint2D p) => m_Start <= p && m_End > p; @@ -350,10 +358,10 @@ namespace Server } [CommandProperty(AccessLevel.Counselor)] - public Point3D Start{ get; set; } + public Point3D Start { get; set; } [CommandProperty(AccessLevel.Counselor)] - public Point3D End{ get; set; } + public Point3D End { get; set; } [CommandProperty(AccessLevel.Counselor)] public int Width => End.X - Start.X; diff --git a/Projects/Server/Guild.cs b/Projects/Server/Guild.cs index 55b33fb84..11b8c2168 100644 --- a/Projects/Server/Guild.cs +++ b/Projects/Server/Guild.cs @@ -35,43 +35,42 @@ namespace Server.Guilds private readonly BufferWriter m_SaveBuffer; public BufferWriter SaveBuffer => m_SaveBuffer; - private static uint m_NextID = 1; + private static Serial m_NextID = 1; - protected BaseGuild(uint Id) //serialization ctor + protected BaseGuild(uint id) // serialization ctor { - this.Id = Id; - List.Add(this.Id, this); - if (this.Id + 1 > m_NextID) - m_NextID = this.Id + 1; + this.Serial = id; + List.Add(this.Serial, this); + if (this.Serial + 1 > m_NextID) + m_NextID = this.Serial + 1; m_SaveBuffer = new BufferWriter(true); } protected BaseGuild() { - Id = m_NextID++; - List.Add(Id, this); + Serial = m_NextID++; + List.Add(Serial, this); m_SaveBuffer = new BufferWriter(true); } [CommandProperty(AccessLevel.Counselor)] - public uint Id{ get; } + public Serial Serial { get; } - public abstract string Abbreviation{ get; set; } - public abstract string Name{ get; set; } - public abstract GuildType Type{ get; set; } - public abstract bool Disbanded{ get; } + public abstract string Abbreviation { get; set; } + public abstract string Name { get; set; } + public abstract GuildType Type { get; set; } + public abstract bool Disbanded { get; } - public static Dictionary List{ get; } = new Dictionary(); + public static Dictionary List { get; } = new Dictionary(); - int ISerializable.TypeReference => 0; - - uint ISerializable.SerialIdentity => Id; + public int TypeRef => 0; public void Serialize() { SaveBuffer.Flush(); Serialize(SaveBuffer); } + public abstract void Serialize(IGenericWriter writer); public abstract void Deserialize(IGenericReader reader); @@ -79,7 +78,7 @@ namespace Server.Guilds public static BaseGuild Find(uint id) { - List.TryGetValue(id, out BaseGuild g); + List.TryGetValue(id, out var g); return g; } @@ -90,12 +89,12 @@ namespace Server.Guilds public static List Search(string find) { - string[] words = find.ToLower().Split(' '); - List results = new List(); + var words = find.ToLower().Split(' '); + var results = new List(); - foreach (BaseGuild g in List.Values) + foreach (var g in List.Values) { - string name = g.Name.ToLower(); + var name = g.Name.ToLower(); if (words.All(t => name.IndexOf(t) != -1)) results.Add(g); @@ -104,6 +103,6 @@ namespace Server.Guilds return results; } - public override string ToString() => $"0x{Id:X} \"{Name} [{Abbreviation}]\""; + public override string ToString() => $"0x{Serial:X} \"{Name} [{Abbreviation}]\""; } } diff --git a/Projects/Server/HuePicker.cs b/Projects/Server/HuePicker.cs index a020fb6ff..2f62e2f93 100644 --- a/Projects/Server/HuePicker.cs +++ b/Projects/Server/HuePicker.cs @@ -36,9 +36,9 @@ namespace Server.HuePickers ItemID = itemID; } - public int Serial{ get; } + public int Serial { get; } - public int ItemID{ get; } + public int ItemID { get; } public virtual void OnResponse(int hue) { @@ -50,4 +50,4 @@ namespace Server.HuePickers state.AddHuePicker(this); } } -} \ No newline at end of file +} diff --git a/Projects/Server/IAccount.cs b/Projects/Server/IAccount.cs index cbe1cc46d..eb8afa949 100644 --- a/Projects/Server/IAccount.cs +++ b/Projects/Server/IAccount.cs @@ -57,7 +57,7 @@ namespace Server.Accounting /// 0 to 999,999,999 by default. /// [CommandProperty(AccessLevel.Administrator)] - int TotalGold{ get; } + int TotalGold { get; } /// /// This amount represents the current amount of Platinum owned by the player. @@ -66,7 +66,7 @@ namespace Server.Accounting /// One Platinum represents the value of CurrencyThreshold in Gold. /// [CommandProperty(AccessLevel.Administrator)] - int TotalPlat{ get; } + int TotalPlat { get; } /// /// Attempts to deposit the given amount of Gold into this account. @@ -110,17 +110,17 @@ namespace Server.Accounting public interface IAccount : IGoldAccount, IComparable { - string Username{ get; set; } - string Email{ get; set; } - AccessLevel AccessLevel{ get; set; } + string Username { get; set; } + string Email { get; set; } + AccessLevel AccessLevel { get; set; } - int Length{ get; } - int Limit{ get; } - int Count{ get; } - Mobile this[int index]{ get; set; } + int Length { get; } + int Limit { get; } + int Count { get; } + Mobile this[int index] { get; set; } void Delete(); void SetPassword(string password); bool CheckPassword(string password); } -} \ No newline at end of file +} diff --git a/Projects/Server/IEntity.cs b/Projects/Server/IEntity.cs index 9e63739f9..6ee5e6a13 100644 --- a/Projects/Server/IEntity.cs +++ b/Projects/Server/IEntity.cs @@ -24,10 +24,10 @@ namespace Server { public interface IEntity : IPoint3D, IComparable { - Serial Serial{ get; } - Point3D Location{ get; } - Map Map{ get; } - bool Deleted{ get; } + Serial Serial { get; } + Point3D Location { get; } + Map Map { get; } + bool Deleted { get; } void MoveToWorld(Point3D location, Map map); void Delete(); @@ -54,9 +54,9 @@ namespace Server public int CompareTo(IEntity other) => other == null ? -1 : Serial.CompareTo(other.Serial); - public Serial Serial{ get; } + public Serial Serial { get; } - public Point3D Location{ get; private set; } + public Point3D Location { get; private set; } public int X => Location.X; @@ -64,7 +64,7 @@ namespace Server public int Z => Location.Z; - public Map Map{ get; private set; } + public Map Map { get; private set; } public virtual void MoveToWorld(Point3D newLocation, Map map) { @@ -72,7 +72,7 @@ namespace Server Map = map; } - public bool Deleted{ get; } + public bool Deleted { get; } public void Delete() { diff --git a/Projects/Server/Insensitive.cs b/Projects/Server/Insensitive.cs index 8156b85a1..8b4c54632 100644 --- a/Projects/Server/Insensitive.cs +++ b/Projects/Server/Insensitive.cs @@ -30,7 +30,7 @@ namespace Server public static int Compare(string a, string b) => Comparer.Compare(a, b); public static bool Equals(string a, string b) => - a == null && b == null || a != null && b != null && a.Length == b.Length && Comparer.Compare(a, b) == 0; + (a == null && b == null) || (a != null && b != null && a.Length == b.Length && Comparer.Compare(a, b) == 0); public static bool StartsWith(string a, string b) => a != null && b != null && a.Length >= b.Length && Comparer.Compare(a.Substring(0, b.Length), b) == 0; diff --git a/Projects/Server/Interfaces.cs b/Projects/Server/Interfaces.cs index 0294efa88..8dbfae663 100644 --- a/Projects/Server/Interfaces.cs +++ b/Projects/Server/Interfaces.cs @@ -19,42 +19,18 @@ ***************************************************************************/ using System; -using System.Collections.Generic; - -namespace Server.Mobiles -{ - public interface IMount - { - Mobile Rider{ get; set; } - void OnRiderDamaged(int amount, Mobile from, bool willKill); - } - - public interface IMountItem - { - IMount Mount{ get; } - } -} namespace Server { - public interface IVendor - { - DateTime LastRestock{ get; set; } - TimeSpan RestockDelay{ get; } - bool OnBuyItems(Mobile from, List list); - bool OnSellItems(Mobile from, List list); - void Restock(); - } - public interface IPoint2D { - int X{ get; } - int Y{ get; } + int X { get; } + int Y { get; } } public interface IPoint3D : IPoint2D { - int Z{ get; } + int Z { get; } } public interface ICarvable @@ -64,7 +40,7 @@ namespace Server public interface IWeapon { - int MaxRange{ get; } + int MaxRange { get; } void OnBeforeSwing(Mobile attacker, Mobile defender); TimeSpan OnSwing(Mobile attacker, Mobile defender); void GetStatusDamage(Mobile from, out int min, out int max); @@ -72,12 +48,12 @@ namespace Server public interface IHued { - int HuedItemID{ get; } + int HuedItemID { get; } } public interface ISpell { - bool IsCasting{ get; } + bool IsCasting { get; } void OnCasterHurt(); void OnCasterKilled(); void OnConnectionChanged(); @@ -97,17 +73,17 @@ namespace Server public interface ISpawner { - bool UnlinkOnTaming{ get; } - Point3D HomeLocation{ get; } - int HomeRange{ get; } - Region Region{ get; } + bool UnlinkOnTaming { get; } + Point3D HomeLocation { get; } + int HomeRange { get; } + Region Region { get; } void Remove(ISpawnable spawn); } public interface ISpawnable : IEntity { - ISpawner Spawner{ get; set; } + ISpawner Spawner { get; set; } void OnBeforeSpawn(Point3D location, Map map); void OnAfterSpawn(); } diff --git a/Projects/Server/Item.cs b/Projects/Server/Item.cs index 8fc4db6c2..d900bfd68 100644 --- a/Projects/Server/Item.cs +++ b/Projects/Server/Item.cs @@ -107,33 +107,34 @@ namespace Server public class BounceInfo { - public Point3D m_Location, m_WorldLoc; - public Map m_Map; - public IEntity m_Parent; + public Point3D Location { get; set; } + public Point3D WorldLoc { get; set; } + public Map Map { get; set; } + public IEntity Parent { get; set; } public BounceInfo(Item item) { - m_Map = item.Map; - m_Location = item.Location; - m_WorldLoc = item.GetWorldLocation(); - m_Parent = item.Parent; + Map = item.Map; + Location = item.Location; + WorldLoc = item.GetWorldLocation(); + Parent = item.Parent; } private BounceInfo(Map map, Point3D loc, Point3D worldLoc, IEntity parent) { - m_Map = map; - m_Location = loc; - m_WorldLoc = worldLoc; - m_Parent = parent; + Map = map; + Location = loc; + WorldLoc = worldLoc; + Parent = parent; } public static BounceInfo Deserialize(IGenericReader reader) { if (reader.ReadBool()) { - Map map = reader.ReadMap(); - Point3D loc = reader.ReadPoint3D(); - Point3D worldLoc = reader.ReadPoint3D(); + var map = reader.ReadMap(); + var loc = reader.ReadPoint3D(); + var worldLoc = reader.ReadPoint3D(); IEntity parent; @@ -162,13 +163,13 @@ namespace Server { writer.Write(true); - writer.Write(info.m_Map); - writer.Write(info.m_Location); - writer.Write(info.m_WorldLoc); + writer.Write(info.Map); + writer.Write(info.Location); + writer.Write(info.WorldLoc); - if (info.m_Parent is Mobile mobile) + if (info.Parent is Mobile mobile) writer.Write(mobile); - else if (info.m_Parent is Item item) + else if (info.Parent is Item item) writer.Write(item); else writer.Write((Serial)0); @@ -218,15 +219,13 @@ namespace Server private ItemDelta m_DeltaFlags; private ImplFlag m_Flags; - internal int m_TypeRef; - [Constructible] public Item(int itemID = 0) { m_ItemID = itemID; Serial = Serial.NewItem; - //m_Items = new ArrayList( 1 ); + // m_Items = new ArrayList( 1 ); Visible = true; Movable = true; Amount = 1; @@ -236,14 +235,15 @@ namespace Server World.AddItem(this); - Type ourType = GetType(); - m_TypeRef = World.m_ItemTypes.IndexOf(ourType); + var ourType = GetType(); + TypeRef = World.m_ItemTypes.IndexOf(ourType); - if (m_TypeRef == -1) + if (TypeRef == -1) { World.m_ItemTypes.Add(ourType); - m_TypeRef = World.m_ItemTypes.Count - 1; + TypeRef = World.m_ItemTypes.Count - 1; } + m_SaveBuffer = new BufferWriter(true); } @@ -251,14 +251,15 @@ namespace Server { Serial = serial; - Type ourType = GetType(); - m_TypeRef = World.m_ItemTypes.IndexOf(ourType); + var ourType = GetType(); + TypeRef = World.m_ItemTypes.IndexOf(ourType); - if (m_TypeRef == -1) + if (TypeRef == -1) { World.m_ItemTypes.Add(ourType); - m_TypeRef = World.m_ItemTypes.Count - 1; + TypeRef = World.m_ItemTypes.Count - 1; } + m_SaveBuffer = new BufferWriter(true); } @@ -267,7 +268,7 @@ namespace Server get => LookupCompactInfo()?.m_TempFlags ?? 0; set { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); info.m_TempFlags = value; @@ -281,7 +282,7 @@ namespace Server get => LookupCompactInfo()?.m_SavedFlags ?? 0; set { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); info.m_SavedFlags = value; @@ -298,7 +299,7 @@ namespace Server get => LookupCompactInfo()?.m_HeldBy; set { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); info.m_HeldBy = value; @@ -328,7 +329,7 @@ namespace Server } } - public static TimeSpan DefaultDecayTime{ get; set; } = TimeSpan.FromHours(1.0); + public static TimeSpan DefaultDecayTime { get; set; } = TimeSpan.FromHours(1.0); [CommandProperty(AccessLevel.GameMaster)] public virtual TimeSpan DecayTime => DefaultDecayTime; @@ -336,7 +337,7 @@ namespace Server [CommandProperty(AccessLevel.GameMaster)] public virtual bool Decays => Movable && Visible; - public DateTime LastMoved{ get; set; } + public DateTime LastMoved { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Stackable @@ -384,13 +385,13 @@ namespace Server if (m_Map != null) { - Point3D worldLoc = GetWorldLocation(); + var worldLoc = GetWorldLocation(); - IPooledEnumerable eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); + var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (!m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) state.Send(RemovePacket); @@ -423,9 +424,9 @@ namespace Server public virtual bool HandlesOnMovement => false; - public static int LockedDownFlag{ get; set; } + public static int LockedDownFlag { get; set; } - public static int SecureFlag{ get; set; } + public static int SecureFlag { get; set; } public bool IsLockedDown { @@ -476,7 +477,7 @@ namespace Server if (m_ItemID < 0 || m_ItemID > TileData.MaxItemValue || this is BaseMulti) return 0; - int weight = TileData.ItemTable[m_ItemID].Weight; + var weight = TileData.ItemTable[m_ItemID].Weight; if (weight == 255 || weight == 0) weight = 1; @@ -490,7 +491,7 @@ namespace Server { get { - CompactInfo info = LookupCompactInfo(); + var info = LookupCompactInfo(); return info != null && info.m_Weight != -1 ? info.m_Weight : DefaultWeight; } @@ -498,16 +499,16 @@ namespace Server { if (Weight != value) { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); - int oldPileWeight = PileWeight; + var oldPileWeight = PileWeight; info.m_Weight = value; if (info.m_Weight == -1) VerifyCompactInfo(); - int newPileWeight = PileWeight; + var newPileWeight = PileWeight; UpdateTotal(this, TotalType.Weight, newPileWeight - oldPileWeight); @@ -560,7 +561,7 @@ namespace Server { get { - IEntity p = m_Parent; + var p = m_Parent; while (p is Item item) { @@ -573,7 +574,7 @@ namespace Server } } - public bool NoMoveHS{ get; set; } + public bool NoMoveHS { get; set; } public virtual int PhysicalResistance => 0; public virtual int FireResistance => 0; @@ -589,12 +590,12 @@ namespace Server { if (m_ItemID != value) { - int oldPileWeight = PileWeight; + var oldPileWeight = PileWeight; m_ItemID = value; ReleaseWorldPackets(); - int newPileWeight = PileWeight; + var newPileWeight = PileWeight; UpdateTotal(this, TotalType.Weight, newPileWeight - oldPileWeight); @@ -614,7 +615,7 @@ namespace Server { if (value == null || value != DefaultName) { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); info.m_Name = value; @@ -635,7 +636,7 @@ namespace Server if (m_Parent == value) return; - IEntity oldParent = m_Parent; + var oldParent = m_Parent; m_Parent = value; @@ -687,16 +688,16 @@ namespace Server get => m_Amount; set { - int oldValue = m_Amount; + var oldValue = m_Amount; if (oldValue != value) { - int oldPileWeight = PileWeight; + var oldPileWeight = PileWeight; m_Amount = value; ReleaseWorldPackets(); - int newPileWeight = PileWeight; + var newPileWeight = PileWeight; UpdateTotal(this, TotalType.Weight, newPileWeight - oldPileWeight); @@ -725,7 +726,7 @@ namespace Server public virtual bool CanTarget => true; public virtual bool DisplayLootType => true; - public static bool ScissorCopyLootType{ get; set; } + public static bool ScissorCopyLootType { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool QuestItem @@ -764,7 +765,7 @@ namespace Server get => LookupCompactInfo()?.m_BlessedFor; set { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); info.m_BlessedFor = value; @@ -787,8 +788,8 @@ namespace Server if (Deleted) return; - Point3D oldLocation = GetWorldLocation(); - Point3D oldRealLocation = m_Location; + var oldLocation = GetWorldLocation(); + var oldRealLocation = m_Location; SetLastMoved(); @@ -799,7 +800,7 @@ namespace Server if (m_Map != map) { - Map old = m_Map; + var old = m_Map; if (m_Map != null) { @@ -807,11 +808,11 @@ namespace Server if (oldLocation.m_X != 0) { - IPooledEnumerable eable = m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange()); + var eable = m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (m.InRange(oldLocation, GetUpdateRange(m))) state.Send(RemovePacket); @@ -826,10 +827,10 @@ namespace Server ReleaseWorldPackets(); - List items = LookupItems(); + var items = LookupItems(); if (items != null) - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) items[i].Map = map; m_Map = map; @@ -839,11 +840,11 @@ namespace Server if (m_Map != null) { - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange()); + var eable = m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (m.CanSee(this) && m.InRange(m_Location, GetUpdateRange(m))) SendInfoTo(state); @@ -865,9 +866,9 @@ namespace Server { eable = m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (!m.InRange(location, GetUpdateRange(m))) state.Send(RemovePacket); } @@ -875,7 +876,7 @@ namespace Server eable.Free(); } - Point3D oldInternalLocation = m_Location; + var oldInternalLocation = m_Location; m_Location = location; OnLocationChange(oldRealLocation); @@ -884,9 +885,9 @@ namespace Server eable = m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (m.CanSee(this) && m.InRange(m_Location, GetUpdateRange(m))) SendInfoTo(state); @@ -918,7 +919,7 @@ namespace Server { if (m_Map != value) { - Map old = m_Map; + var old = m_Map; if (m_Map != null && m_Parent == null) { @@ -926,10 +927,10 @@ namespace Server SendRemovePacket(); } - List items = LookupItems(); + var items = LookupItems(); if (items != null) - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) items[i].Map = value; m_Map = value; @@ -949,27 +950,27 @@ namespace Server public virtual void ProcessDelta() { - ItemDelta flags = m_DeltaFlags; + var flags = m_DeltaFlags; SetFlag(ImplFlag.InQueue, false); m_DeltaFlags = ItemDelta.None; - Map map = m_Map; + var map = m_Map; if (map == null || Deleted) return; - Point3D worldLoc = GetWorldLocation(); - bool update = (flags & ItemDelta.Update) != 0; + var worldLoc = GetWorldLocation(); + var update = (flags & ItemDelta.Update) != 0; if (update && m_Parent is Container contParent && !contParent.IsPublicContainer) { - Mobile rootParent = contParent.RootParent as Mobile; + var rootParent = contParent.RootParent as Mobile; Mobile tradeRecip = null; if (rootParent != null) { - NetState ns = rootParent.NetState; + var ns = rootParent.NetState; if (ns != null && rootParent.CanSee(this) && rootParent.InRange(worldLoc, GetUpdateRange(rootParent))) { @@ -983,11 +984,11 @@ namespace Server } } - SecureTrade st = GetSecureTradeCont()?.Trade; + var st = GetSecureTradeCont()?.Trade; if (st != null) { - Mobile test = st.From.Mobile; + var test = st.From.Mobile; if (test != null && test != rootParent) tradeRecip = test; @@ -997,7 +998,7 @@ namespace Server if (test != null && test != rootParent) tradeRecip = test; - NetState ns = tradeRecip?.NetState; + var ns = tradeRecip?.NetState; if (ns != null && tradeRecip.CanSee(this) && tradeRecip.InRange(worldLoc, GetUpdateRange(tradeRecip))) { @@ -1011,25 +1012,27 @@ namespace Server } } - List openers = contParent.Openers; + var openers = contParent.Openers; if (openers != null) lock (openers) { - for (int i = 0; i < openers.Count; ++i) + for (var i = 0; i < openers.Count; ++i) { - Mobile mob = openers[i]; + var mob = openers[i]; - int range = GetUpdateRange(mob); + var range = GetUpdateRange(mob); if (mob.Map != map || !mob.InRange(worldLoc, range)) + { openers.RemoveAt(i--); + } else { if (mob == rootParent || mob == tradeRecip) continue; - NetState ns = mob.NetState; + var ns = mob.NetState; if (ns != null && mob.CanSee(this)) { @@ -1053,22 +1056,26 @@ namespace Server Packet p = null; - IPooledEnumerable eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); + var eable = map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (!m.CanSee(this) || !m.InRange(worldLoc, GetUpdateRange(m))) continue; if (update) { if (m_Parent == null) + { SendInfoTo(state, ObjectPropertyList.Enabled); + } else { if (p != null) + { state.Send(p); + } else if (m_Parent is Item) { if (state.ContainerGridLines) @@ -1094,8 +1101,11 @@ namespace Server if (ObjectPropertyList.Enabled) state.Send(OPLPacket); - } else if (ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0) + } + else if (ObjectPropertyList.Enabled && (flags & ItemDelta.Properties) != 0) + { state.Send(OPLPacket); + } } Packet.Release(p); @@ -1109,10 +1119,10 @@ namespace Server OnDelete(); - List items = LookupItems(); + var items = LookupItems(); if (items != null) - for (int i = items.Count - 1; i >= 0; --i) + for (var i = items.Count - 1; i >= 0; --i) if (i < items.Count) items[i].OnParentDeleted(this); @@ -1142,24 +1152,22 @@ namespace Server } [CommandProperty(AccessLevel.Counselor)] - public Serial Serial{ get; } + public Serial Serial { get; } public virtual int HuedItemID => m_ItemID; - int ISerializable.TypeReference => m_TypeRef; - - uint ISerializable.SerialIdentity => Serial; - + public int TypeRef { get; } public void Serialize() { SaveBuffer.Flush(); Serialize(SaveBuffer); } + public virtual void Serialize(IGenericWriter writer) { writer.Write(9); // version - SaveFlag flags = SaveFlag.None; + var flags = SaveFlag.None; int x = m_Location.m_X, y = m_Location.m_Y, z = m_Location.m_Z; @@ -1185,8 +1193,8 @@ namespace Server } } - CompactInfo info = LookupCompactInfo(); - List items = LookupItems(); + var info = LookupCompactInfo(); + var items = LookupItems(); if (m_Direction != Direction.North) flags |= SaveFlag.Direction; @@ -1210,8 +1218,8 @@ namespace Server flags |= SaveFlag.Items; if (m_Map != Map.Internal) flags |= SaveFlag.Map; - //if ( m_InsuredFor != null && !m_InsuredFor.Deleted ) - //flags |= SaveFlag.InsuredFor; + // if (m_InsuredFor != null && !m_InsuredFor.Deleted) + // flags |= SaveFlag.InsuredFor; if (info != null) { @@ -1242,8 +1250,8 @@ namespace Server } } - ImplFlag implFlags = m_Flags & (ImplFlag.Visible | ImplFlag.Movable | ImplFlag.Stackable | ImplFlag.Insured | - ImplFlag.PaidInsurance | ImplFlag.QuestItem); + var implFlags = m_Flags & (ImplFlag.Visible | ImplFlag.Movable | ImplFlag.Stackable | ImplFlag.Insured | + ImplFlag.PaidInsurance | ImplFlag.QuestItem); if (implFlags != (ImplFlag.Visible | ImplFlag.Movable)) flags |= SaveFlag.ImplFlags; @@ -1251,8 +1259,8 @@ namespace Server writer.Write((int)flags); /* begin last moved time optimization */ - long ticks = LastMoved.Ticks; - long now = DateTime.UtcNow.Ticks; + var ticks = LastMoved.Ticks; + var now = DateTime.UtcNow.Ticks; TimeSpan d; @@ -1266,7 +1274,7 @@ namespace Server else d = TimeSpan.MaxValue; } - double minutes = -d.TotalMinutes; + var minutes = -d.TotalMinutes; if (minutes < int.MinValue) minutes = int.MinValue; @@ -1363,7 +1371,7 @@ namespace Server get => LookupCompactInfo()?.m_Spawner; set { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); info.m_Spawner = value; @@ -1382,7 +1390,7 @@ namespace Server public ExpandFlag GetExpandFlags() { - CompactInfo info = LookupCompactInfo(); + var info = LookupCompactInfo(); ExpandFlag flags = 0; @@ -1430,20 +1438,20 @@ namespace Server private void VerifyCompactInfo() { - CompactInfo info = m_CompactInfo; + var info = m_CompactInfo; if (info == null) return; - bool isValid = info.m_Name != null - || info.m_Items != null - || info.m_Bounce != null - || info.m_HeldBy != null - || info.m_BlessedFor != null - || info.m_Spawner != null - || info.m_TempFlags != 0 - || info.m_SavedFlags != 0 - || info.m_Weight != -1; + var isValid = info.m_Name != null + || info.m_Items != null + || info.m_Bounce != null + || info.m_HeldBy != null + || info.m_BlessedFor != null + || info.m_Spawner != null + || info.m_TempFlags != 0 + || info.m_SavedFlags != 0 + || info.m_Weight != -1; if (!isValid) ReleaseCompactInfo(); @@ -1462,7 +1470,7 @@ namespace Server if (this is Container cont) return cont.m_Items ?? (cont.m_Items = new List()); - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); return info.m_Items ?? (info.m_Items = new List()); } @@ -1485,21 +1493,21 @@ namespace Server public void ClearBounce() { - CompactInfo info = LookupCompactInfo(); + var info = LookupCompactInfo(); - BounceInfo bounce = info?.m_Bounce; + var bounce = info?.m_Bounce; if (bounce == null) return; info.m_Bounce = null; - if (bounce.m_Parent is Item parentItem) + if (bounce.Parent is Item parentItem) { if (!parentItem.Deleted) parentItem.OnItemBounceCleared(this); } - else if (bounce.m_Parent is Mobile parentMobile) + else if (bounce.Parent is Mobile parentMobile) { if (!parentMobile.Deleted) parentMobile.OnItemBounceCleared(this); @@ -1564,7 +1572,7 @@ namespace Server /// public virtual void AddNameProperty(ObjectPropertyList list) { - string name = Name; + var name = Name; if (name == null) { @@ -1601,7 +1609,7 @@ namespace Server /// public virtual void AddResistanceProperties(ObjectPropertyList list) { - int v = PhysicalResistance; + var v = PhysicalResistance; if (v != 0) list.Add(1060448, v.ToString()); // physical resist ~1_val~% @@ -1632,12 +1640,12 @@ namespace Server /// public virtual void AddWeightProperty(ObjectPropertyList list) { - int weight = PileWeight + TotalWeight; + var weight = PileWeight + TotalWeight; if (weight == 1) - list.Add(1072788, weight.ToString()); //Weight: ~1_WEIGHT~ stone + list.Add(1072788, weight.ToString()); // Weight: ~1_WEIGHT~ stone else - list.Add(1072789, weight.ToString()); //Weight: ~1_WEIGHT~ stones + list.Add(1072789, weight.ToString()); // Weight: ~1_WEIGHT~ stones } /// @@ -1654,7 +1662,7 @@ namespace Server else if (IsLockedDown) AddLockedDownProperty(list); - Mobile blessedFor = BlessedFor; + var blessedFor = BlessedFor; if (blessedFor?.Deleted == false) AddBlessedForProperty(list, blessedFor); @@ -1668,7 +1676,6 @@ namespace Server if (QuestItem) AddQuestItemProperty(list); - AppendChildNameProperties(list); } @@ -1752,24 +1759,24 @@ namespace Server m_Parent = null; - BounceInfo bounce = GetBounce(); + var bounce = GetBounce(); if (bounce != null) { - IEntity parent = bounce.m_Parent; + var parent = bounce.Parent; if (parent?.Deleted != false) { - MoveToWorld(bounce.m_WorldLoc, bounce.m_Map); + MoveToWorld(bounce.WorldLoc, bounce.Map); } else if (parent is Item p) { - IEntity root = p.RootParent; + var root = p.RootParent; if (p.IsAccessibleTo(from) && (!(root is Mobile mobileRoot) || mobileRoot.CheckNonlocalDrop(from, this, p))) { - Location = bounce.m_Location; + Location = bounce.Location; p.AddItem(this); } else @@ -1780,11 +1787,11 @@ namespace Server else if (parent is Mobile parentMobile) { if (!parentMobile.EquipItem(this)) - MoveToWorld(bounce.m_WorldLoc, bounce.m_Map); + MoveToWorld(bounce.WorldLoc, bounce.Map); } else { - MoveToWorld(bounce.m_WorldLoc, bounce.m_Map); + MoveToWorld(bounce.WorldLoc, bounce.Map); } ClearBounce(); @@ -1802,13 +1809,13 @@ namespace Server /// True if it may, false if not. /// /// - /// public override bool AllowEquippedCast( Mobile from ) - /// { - /// if ( from.Int >= 100 ) - /// return true; + /// public override bool AllowEquippedCast( Mobile from ) + /// { + /// if (from.Int >= 100) + /// return true; /// - /// return base.AllowEquippedCast( from ); - /// } + /// return base.AllowEquippedCast( from ); + /// } /// When placed in an Item script, the item may be cast when equipped if the has 100 or more /// intelligence. Otherwise, it will drop to their backpack. /// @@ -1918,7 +1925,8 @@ namespace Server public bool AtPoint(int x, int y) => m_Location.m_X == x && m_Location.m_Y == y; - public virtual bool OnDecay() => Decays && Parent == null && Map != Map.Internal && Region.Find(Location, Map).OnDecay(this); + public virtual bool OnDecay() => + Decays && Parent == null && Map != Map.Internal && Region.Find(Location, Map).OnDecay(this); public void SetLastMoved() { @@ -1943,7 +1951,7 @@ namespace Server if (playSound && from != null) { - int soundID = GetDropSound(); + var soundID = GetDropSound(); if (soundID == -1) soundID = 0x42; @@ -1959,8 +1967,8 @@ namespace Server public virtual bool OnDragDrop(Mobile from, Item dropped) { - bool success = Parent is Container container && container.OnStackAttempt(from, this, dropped) || - StackWith(from, dropped); + var success = (Parent is Container container && container.OnStackAttempt(from, this, dropped)) || + StackWith(from, dropped); if (success && Spawner != null) { @@ -1973,12 +1981,12 @@ namespace Server public Rectangle2D GetGraphicBounds() { - int itemID = m_ItemID; - bool doubled = m_Amount > 1; + var itemID = m_ItemID; + var doubled = m_Amount > 1; if (itemID >= 0xEEA && itemID <= 0xEF2) // Are we coins? { - int coinBase = (itemID - 0xEEA) / 3; + var coinBase = (itemID - 0xEEA) / 3; coinBase *= 3; coinBase += 0xEEA; @@ -1992,7 +2000,7 @@ namespace Server itemID = coinBase + 2; } - Rectangle2D bounds = ItemBounds.Table[itemID & 0x3FFF]; + var bounds = ItemBounds.Table[itemID & 0x3FFF]; if (doubled) bounds.Set(bounds.X, bounds.Y, bounds.Width + 5, bounds.Height + 5); @@ -2017,7 +2025,7 @@ namespace Server public ObjectPropertyList NewObjectPropertyList() { - ObjectPropertyList list = new ObjectPropertyList(this); + var list = new ObjectPropertyList(this); GetProperties(list); AppendChildProperties(list); @@ -2040,7 +2048,7 @@ namespace Server if (m_Map != null && m_Map != Map.Internal && !World.Loading) { - ObjectPropertyList oldList = m_PropertyList; + var oldList = m_PropertyList; m_PropertyList = null; if (oldList != null && oldList.Hash != PropertyList.Hash) @@ -2062,7 +2070,7 @@ namespace Server public virtual int GetPacketFlags() { - int flags = 0; + var flags = 0; if (!Visible) flags |= 0x80; @@ -2108,20 +2116,14 @@ namespace Server public IPooledEnumerable GetObjectsInRange(int range) { - Map map = m_Map; + var map = m_Map; - if (map == null) - return Map.NullEnumerable.Instance; - - if (m_Parent == null) - return map.GetObjectsInRange(m_Location, range); - - return map.GetObjectsInRange(GetWorldLocation(), range); + return map == null ? Map.NullEnumerable.Instance : map.GetObjectsInRange(m_Parent == null ? m_Location : GetWorldLocation(), range); } public IPooledEnumerable GetItemsInRange(int range) { - Map map = m_Map; + var map = m_Map; if (map == null) return Map.NullEnumerable.Instance; @@ -2134,7 +2136,7 @@ namespace Server public IPooledEnumerable GetMobilesInRange(int range) { - Map map = m_Map; + var map = m_Map; if (map == null) return Map.NullEnumerable.Instance; @@ -2147,7 +2149,7 @@ namespace Server public IPooledEnumerable GetClientsInRange(int range) { - Map map = m_Map; + var map = m_Map; if (map == null) return Map.NullEnumerable.Instance; @@ -2162,7 +2164,7 @@ namespace Server public void SetTempFlag(int flag, bool value) { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); if (value) info.m_TempFlags |= flag; @@ -2177,7 +2179,7 @@ namespace Server public void SetSavedFlag(int flag, bool value) { - CompactInfo info = AcquireCompactInfo(); + var info = AcquireCompactInfo(); if (value) info.m_SavedFlags |= flag; @@ -2190,7 +2192,7 @@ namespace Server public virtual void Deserialize(IGenericReader reader) { - int version = reader.ReadInt(); + var version = reader.ReadInt(); SetLastMoved(); @@ -2200,112 +2202,231 @@ namespace Server case 8: case 7: case 6: - { - SaveFlag flags = (SaveFlag)reader.ReadInt(); - - if (version < 7) { + var flags = (SaveFlag)reader.ReadInt(); + + if (version < 7) + { + LastMoved = reader.ReadDeltaTime(); + } + else + { + var minutes = reader.ReadEncodedInt(); + + try + { + LastMoved = DateTime.UtcNow - TimeSpan.FromMinutes(minutes); + } + catch + { + LastMoved = DateTime.UtcNow; + } + } + + if (GetSaveFlag(flags, SaveFlag.Direction)) + m_Direction = (Direction)reader.ReadByte(); + + if (GetSaveFlag(flags, SaveFlag.Bounce)) + AcquireCompactInfo().m_Bounce = BounceInfo.Deserialize(reader); + + if (GetSaveFlag(flags, SaveFlag.LootType)) + m_LootType = (LootType)reader.ReadByte(); + + int x = 0, y = 0, z = 0; + + if (GetSaveFlag(flags, SaveFlag.LocationFull)) + { + x = reader.ReadEncodedInt(); + y = reader.ReadEncodedInt(); + z = reader.ReadEncodedInt(); + } + else + { + if (GetSaveFlag(flags, SaveFlag.LocationByteXY)) + { + x = reader.ReadByte(); + y = reader.ReadByte(); + } + else if (GetSaveFlag(flags, SaveFlag.LocationShortXY)) + { + x = reader.ReadShort(); + y = reader.ReadShort(); + } + + if (GetSaveFlag(flags, SaveFlag.LocationSByteZ)) + z = reader.ReadSByte(); + } + + m_Location = new Point3D(x, y, z); + + if (GetSaveFlag(flags, SaveFlag.ItemID)) + m_ItemID = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.Hue)) + m_Hue = reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.Amount)) + m_Amount = reader.ReadEncodedInt(); + else + m_Amount = 1; + + if (GetSaveFlag(flags, SaveFlag.Layer)) + m_Layer = (Layer)reader.ReadByte(); + + if (GetSaveFlag(flags, SaveFlag.Name)) + { + var name = reader.ReadString(); + + if (name != DefaultName) + AcquireCompactInfo().m_Name = name; + } + + if (GetSaveFlag(flags, SaveFlag.Parent)) + { + Serial parent = reader.ReadUInt(); + + if (parent.IsMobile) + m_Parent = World.FindMobile(parent); + else if (parent.IsItem) + m_Parent = World.FindItem(parent); + else + m_Parent = null; + + if (m_Parent == null && (parent.IsMobile || parent.IsItem)) + Delete(); + } + + if (GetSaveFlag(flags, SaveFlag.Items)) + { + var items = reader.ReadStrongItemList(); + + if (this is Container) + (this as Container).m_Items = items; + else + AcquireCompactInfo().m_Items = items; + } + + if (version < 8 || !GetSaveFlag(flags, SaveFlag.NullWeight)) + { + double weight; + + if (GetSaveFlag(flags, SaveFlag.IntWeight)) + weight = reader.ReadEncodedInt(); + else if (GetSaveFlag(flags, SaveFlag.WeightNot1or0)) + weight = reader.ReadDouble(); + else if (GetSaveFlag(flags, SaveFlag.WeightIs0)) + weight = 0.0; + else + weight = 1.0; + + if (weight != DefaultWeight) + AcquireCompactInfo().m_Weight = weight; + } + + if (GetSaveFlag(flags, SaveFlag.Map)) + m_Map = reader.ReadMap(); + else + m_Map = Map.Internal; + + if (GetSaveFlag(flags, SaveFlag.Visible)) + SetFlag(ImplFlag.Visible, reader.ReadBool()); + else + SetFlag(ImplFlag.Visible, true); + + if (GetSaveFlag(flags, SaveFlag.Movable)) + SetFlag(ImplFlag.Movable, reader.ReadBool()); + else + SetFlag(ImplFlag.Movable, true); + + if (GetSaveFlag(flags, SaveFlag.Stackable)) + SetFlag(ImplFlag.Stackable, reader.ReadBool()); + + if (GetSaveFlag(flags, SaveFlag.ImplFlags)) + m_Flags = (ImplFlag)reader.ReadEncodedInt(); + + if (GetSaveFlag(flags, SaveFlag.InsuredFor)) + /*m_InsuredFor = */ + reader.ReadMobile(); + + if (GetSaveFlag(flags, SaveFlag.BlessedFor)) + AcquireCompactInfo().m_BlessedFor = reader.ReadMobile(); + + if (GetSaveFlag(flags, SaveFlag.HeldBy)) + AcquireCompactInfo().m_HeldBy = reader.ReadMobile(); + + if (GetSaveFlag(flags, SaveFlag.SavedFlags)) + AcquireCompactInfo().m_SavedFlags = reader.ReadEncodedInt(); + + if (m_Map != null && m_Parent == null) + m_Map.OnEnter(this); + + break; + } + case 5: + { + var flags = (SaveFlag)reader.ReadInt(); + LastMoved = reader.ReadDeltaTime(); - } - else - { - int minutes = reader.ReadEncodedInt(); - try - { - LastMoved = DateTime.UtcNow - TimeSpan.FromMinutes(minutes); - } - catch - { - LastMoved = DateTime.UtcNow; - } - } + if (GetSaveFlag(flags, SaveFlag.Direction)) + m_Direction = (Direction)reader.ReadByte(); - if (GetSaveFlag(flags, SaveFlag.Direction)) - m_Direction = (Direction)reader.ReadByte(); + if (GetSaveFlag(flags, SaveFlag.Bounce)) + AcquireCompactInfo().m_Bounce = BounceInfo.Deserialize(reader); - if (GetSaveFlag(flags, SaveFlag.Bounce)) - AcquireCompactInfo().m_Bounce = BounceInfo.Deserialize(reader); + if (GetSaveFlag(flags, SaveFlag.LootType)) + m_LootType = (LootType)reader.ReadByte(); - if (GetSaveFlag(flags, SaveFlag.LootType)) - m_LootType = (LootType)reader.ReadByte(); + if (GetSaveFlag(flags, SaveFlag.LocationFull)) + m_Location = reader.ReadPoint3D(); - int x = 0, y = 0, z = 0; + if (GetSaveFlag(flags, SaveFlag.ItemID)) + m_ItemID = reader.ReadInt(); - if (GetSaveFlag(flags, SaveFlag.LocationFull)) - { - x = reader.ReadEncodedInt(); - y = reader.ReadEncodedInt(); - z = reader.ReadEncodedInt(); - } - else - { - if (GetSaveFlag(flags, SaveFlag.LocationByteXY)) - { - x = reader.ReadByte(); - y = reader.ReadByte(); - } - else if (GetSaveFlag(flags, SaveFlag.LocationShortXY)) - { - x = reader.ReadShort(); - y = reader.ReadShort(); - } + if (GetSaveFlag(flags, SaveFlag.Hue)) + m_Hue = reader.ReadInt(); - if (GetSaveFlag(flags, SaveFlag.LocationSByteZ)) - z = reader.ReadSByte(); - } - - m_Location = new Point3D(x, y, z); - - if (GetSaveFlag(flags, SaveFlag.ItemID)) - m_ItemID = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.Hue)) - m_Hue = reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.Amount)) - m_Amount = reader.ReadEncodedInt(); - else - m_Amount = 1; - - if (GetSaveFlag(flags, SaveFlag.Layer)) - m_Layer = (Layer)reader.ReadByte(); - - if (GetSaveFlag(flags, SaveFlag.Name)) - { - string name = reader.ReadString(); - - if (name != DefaultName) - AcquireCompactInfo().m_Name = name; - } - - if (GetSaveFlag(flags, SaveFlag.Parent)) - { - Serial parent = reader.ReadUInt(); - - if (parent.IsMobile) - m_Parent = World.FindMobile(parent); - else if (parent.IsItem) - m_Parent = World.FindItem(parent); + if (GetSaveFlag(flags, SaveFlag.Amount)) + m_Amount = reader.ReadInt(); else - m_Parent = null; + m_Amount = 1; - if (m_Parent == null && (parent.IsMobile || parent.IsItem)) - Delete(); - } + if (GetSaveFlag(flags, SaveFlag.Layer)) + m_Layer = (Layer)reader.ReadByte(); - if (GetSaveFlag(flags, SaveFlag.Items)) - { - List items = reader.ReadStrongItemList(); + if (GetSaveFlag(flags, SaveFlag.Name)) + { + var name = reader.ReadString(); - if (this is Container) - (this as Container).m_Items = items; - else - AcquireCompactInfo().m_Items = items; - } + if (name != DefaultName) + AcquireCompactInfo().m_Name = name; + } + + if (GetSaveFlag(flags, SaveFlag.Parent)) + { + Serial parent = reader.ReadUInt(); + + if (parent.IsMobile) + m_Parent = World.FindMobile(parent); + else if (parent.IsItem) + m_Parent = World.FindItem(parent); + else + m_Parent = null; + + if (m_Parent == null && (parent.IsMobile || parent.IsItem)) + Delete(); + } + + if (GetSaveFlag(flags, SaveFlag.Items)) + { + var items = reader.ReadStrongItemList(); + + if (this is Container cont) + cont.m_Items = items; + else + AcquireCompactInfo().m_Items = items; + } - if (version < 8 || !GetSaveFlag(flags, SaveFlag.NullWeight)) - { double weight; if (GetSaveFlag(flags, SaveFlag.IntWeight)) @@ -2319,88 +2440,63 @@ namespace Server if (weight != DefaultWeight) AcquireCompactInfo().m_Weight = weight; + + if (GetSaveFlag(flags, SaveFlag.Map)) + m_Map = reader.ReadMap(); + else + m_Map = Map.Internal; + + if (GetSaveFlag(flags, SaveFlag.Visible)) + SetFlag(ImplFlag.Visible, reader.ReadBool()); + else + SetFlag(ImplFlag.Visible, true); + + if (GetSaveFlag(flags, SaveFlag.Movable)) + SetFlag(ImplFlag.Movable, reader.ReadBool()); + else + SetFlag(ImplFlag.Movable, true); + + if (GetSaveFlag(flags, SaveFlag.Stackable)) + SetFlag(ImplFlag.Stackable, reader.ReadBool()); + + if (m_Map != null && m_Parent == null) + m_Map.OnEnter(this); + + break; } + case 4: // Just removed variables + case 3: + { + m_Direction = (Direction)reader.ReadInt(); - if (GetSaveFlag(flags, SaveFlag.Map)) - m_Map = reader.ReadMap(); - else - m_Map = Map.Internal; - - if (GetSaveFlag(flags, SaveFlag.Visible)) - SetFlag(ImplFlag.Visible, reader.ReadBool()); - else - SetFlag(ImplFlag.Visible, true); - - if (GetSaveFlag(flags, SaveFlag.Movable)) - SetFlag(ImplFlag.Movable, reader.ReadBool()); - else - SetFlag(ImplFlag.Movable, true); - - if (GetSaveFlag(flags, SaveFlag.Stackable)) - SetFlag(ImplFlag.Stackable, reader.ReadBool()); - - if (GetSaveFlag(flags, SaveFlag.ImplFlags)) - m_Flags = (ImplFlag)reader.ReadEncodedInt(); - - if (GetSaveFlag(flags, SaveFlag.InsuredFor)) - /*m_InsuredFor = */ reader.ReadMobile(); - - if (GetSaveFlag(flags, SaveFlag.BlessedFor)) - AcquireCompactInfo().m_BlessedFor = reader.ReadMobile(); - - if (GetSaveFlag(flags, SaveFlag.HeldBy)) - AcquireCompactInfo().m_HeldBy = reader.ReadMobile(); - - if (GetSaveFlag(flags, SaveFlag.SavedFlags)) - AcquireCompactInfo().m_SavedFlags = reader.ReadEncodedInt(); - - if (m_Map != null && m_Parent == null) - m_Map.OnEnter(this); - - break; - } - case 5: - { - SaveFlag flags = (SaveFlag)reader.ReadInt(); - - LastMoved = reader.ReadDeltaTime(); - - if (GetSaveFlag(flags, SaveFlag.Direction)) - m_Direction = (Direction)reader.ReadByte(); - - if (GetSaveFlag(flags, SaveFlag.Bounce)) + goto case 2; + } + case 2: + { AcquireCompactInfo().m_Bounce = BounceInfo.Deserialize(reader); + LastMoved = reader.ReadDeltaTime(); - if (GetSaveFlag(flags, SaveFlag.LootType)) - m_LootType = (LootType)reader.ReadByte(); + goto case 1; + } + case 1: + { + m_LootType = (LootType)reader.ReadByte(); // m_Newbied = reader.ReadBool(); - if (GetSaveFlag(flags, SaveFlag.LocationFull)) + goto case 0; + } + case 0: + { m_Location = reader.ReadPoint3D(); - - if (GetSaveFlag(flags, SaveFlag.ItemID)) m_ItemID = reader.ReadInt(); - - if (GetSaveFlag(flags, SaveFlag.Hue)) m_Hue = reader.ReadInt(); - - if (GetSaveFlag(flags, SaveFlag.Amount)) m_Amount = reader.ReadInt(); - else - m_Amount = 1; - - if (GetSaveFlag(flags, SaveFlag.Layer)) m_Layer = (Layer)reader.ReadByte(); - if (GetSaveFlag(flags, SaveFlag.Name)) - { - string name = reader.ReadString(); + var name = reader.ReadString(); if (name != DefaultName) AcquireCompactInfo().m_Name = name; - } - if (GetSaveFlag(flags, SaveFlag.Parent)) - { Serial parent = reader.ReadUInt(); if (parent.IsMobile) @@ -2412,158 +2508,66 @@ namespace Server if (m_Parent == null && (parent.IsMobile || parent.IsItem)) Delete(); - } - if (GetSaveFlag(flags, SaveFlag.Items)) - { - List items = reader.ReadStrongItemList(); + var count = reader.ReadInt(); - if (this is Container cont) - cont.m_Items = items; - else - AcquireCompactInfo().m_Items = items; - } - - double weight; - - if (GetSaveFlag(flags, SaveFlag.IntWeight)) - weight = reader.ReadEncodedInt(); - else if (GetSaveFlag(flags, SaveFlag.WeightNot1or0)) - weight = reader.ReadDouble(); - else if (GetSaveFlag(flags, SaveFlag.WeightIs0)) - weight = 0.0; - else - weight = 1.0; - - if (weight != DefaultWeight) - AcquireCompactInfo().m_Weight = weight; - - if (GetSaveFlag(flags, SaveFlag.Map)) - m_Map = reader.ReadMap(); - else - m_Map = Map.Internal; - - if (GetSaveFlag(flags, SaveFlag.Visible)) - SetFlag(ImplFlag.Visible, reader.ReadBool()); - else - SetFlag(ImplFlag.Visible, true); - - if (GetSaveFlag(flags, SaveFlag.Movable)) - SetFlag(ImplFlag.Movable, reader.ReadBool()); - else - SetFlag(ImplFlag.Movable, true); - - if (GetSaveFlag(flags, SaveFlag.Stackable)) - SetFlag(ImplFlag.Stackable, reader.ReadBool()); - - if (m_Map != null && m_Parent == null) - m_Map.OnEnter(this); - - break; - } - case 4: // Just removed variables - case 3: - { - m_Direction = (Direction)reader.ReadInt(); - - goto case 2; - } - case 2: - { - AcquireCompactInfo().m_Bounce = BounceInfo.Deserialize(reader); - LastMoved = reader.ReadDeltaTime(); - - goto case 1; - } - case 1: - { - m_LootType = (LootType)reader.ReadByte(); //m_Newbied = reader.ReadBool(); - - goto case 0; - } - case 0: - { - m_Location = reader.ReadPoint3D(); - m_ItemID = reader.ReadInt(); - m_Hue = reader.ReadInt(); - m_Amount = reader.ReadInt(); - m_Layer = (Layer)reader.ReadByte(); - - string name = reader.ReadString(); - - if (name != DefaultName) - AcquireCompactInfo().m_Name = name; - - Serial parent = reader.ReadUInt(); - - if (parent.IsMobile) - m_Parent = World.FindMobile(parent); - else if (parent.IsItem) - m_Parent = World.FindItem(parent); - else - m_Parent = null; - - if (m_Parent == null && (parent.IsMobile || parent.IsItem)) - Delete(); - - int count = reader.ReadInt(); - - if (count > 0) - { - List items = new List(count); - - for (int i = 0; i < count; ++i) + if (count > 0) { - Item item = reader.ReadItem(); + var items = new List(count); - if (item != null) - items.Add(item); + for (var i = 0; i < count; ++i) + { + var item = reader.ReadItem(); + + if (item != null) + items.Add(item); + } + + if (this is Container cont) + cont.m_Items = items; + else + AcquireCompactInfo().m_Items = items; } - if (this is Container cont) - cont.m_Items = items; - else - AcquireCompactInfo().m_Items = items; + var weight = reader.ReadDouble(); + + if (weight != DefaultWeight) + AcquireCompactInfo().m_Weight = weight; + + if (version <= 3) + { + reader.ReadInt(); + reader.ReadInt(); + reader.ReadInt(); + } + + m_Map = reader.ReadMap(); + SetFlag(ImplFlag.Visible, reader.ReadBool()); + SetFlag(ImplFlag.Movable, reader.ReadBool()); + + if (version <= 3) + /*m_Deleted =*/ + reader.ReadBool(); + + Stackable = reader.ReadBool(); + + if (m_Map != null && m_Parent == null) + m_Map.OnEnter(this); + + break; } - - double weight = reader.ReadDouble(); - - if (weight != DefaultWeight) - AcquireCompactInfo().m_Weight = weight; - - if (version <= 3) - { - reader.ReadInt(); - reader.ReadInt(); - reader.ReadInt(); - } - - m_Map = reader.ReadMap(); - SetFlag(ImplFlag.Visible, reader.ReadBool()); - SetFlag(ImplFlag.Movable, reader.ReadBool()); - - if (version <= 3) - /*m_Deleted =*/ reader.ReadBool(); - - Stackable = reader.ReadBool(); - - if (m_Map != null && m_Parent == null) - m_Map.OnEnter(this); - - break; - } } if (HeldBy != null) Timer.DelayCall(TimeSpan.Zero, FixHolding_Sandbox); - //if ( version < 9 ) + // if (version < 9) VerifyCompactInfo(); } private void FixHolding_Sandbox() { - Mobile heldBy = HeldBy; + var heldBy = HeldBy; if (heldBy != null) { @@ -2634,7 +2638,7 @@ namespace Server public bool ParentsContain() where T : Item { - IEntity p = m_Parent; + var p = m_Parent; while (p is Item item) { @@ -2679,7 +2683,7 @@ namespace Server item.Parent = this; item.Map = m_Map; - List items = AcquireItems(); + var items = AcquireItems(); items.Add(item); @@ -2710,7 +2714,7 @@ namespace Server if (_processing) try { - using StreamWriter op = new StreamWriter("delta-recursion.log", true); + using var op = new StreamWriter("delta-recursion.log", true); op.WriteLine("# {0}", DateTime.UtcNow); op.WriteLine(new StackTrace()); op.WriteLine(); @@ -2737,7 +2741,7 @@ namespace Server if (_processing) try { - using StreamWriter op = new StreamWriter("delta-recursion.log", true); + using var op = new StreamWriter("delta-recursion.log", true); op.WriteLine("# {0}", DateTime.UtcNow); op.WriteLine(new StackTrace()); op.WriteLine(); @@ -2758,7 +2762,7 @@ namespace Server if (m_DeltaQueue.Count >= 512) Parallel.ForEach(m_DeltaQueue, i => i.ProcessDelta()); else - for (int i = 0; i < m_DeltaQueue.Count; i++) + for (var i = 0; i < m_DeltaQueue.Count; i++) m_DeltaQueue[i].ProcessDelta(); m_DeltaQueue.Clear(); @@ -2794,13 +2798,13 @@ namespace Server return; Packet p = null; - Point3D worldLoc = GetWorldLocation(); + var worldLoc = GetWorldLocation(); - IPooledEnumerable eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); + var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) { @@ -2834,13 +2838,13 @@ namespace Server return; Packet p = null; - Point3D worldLoc = GetWorldLocation(); + var worldLoc = GetWorldLocation(); - IPooledEnumerable eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); + var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (m.CanSee(this) && m.InRange(worldLoc, GetUpdateRange(m))) { @@ -2861,7 +2865,7 @@ namespace Server public virtual void RemoveItem(Item item) { - List items = LookupItems(); + var items = LookupItems(); if (items?.Contains(item) == true) { @@ -2995,18 +2999,18 @@ namespace Server if (!from.InRange(p, 2)) return false; - Map map = from.Map; + var map = from.Map; if (map == null) return false; int x = p.m_X, y = p.m_Y; - int z = int.MinValue; + var z = int.MinValue; - int maxZ = from.Z + 16; + var maxZ = from.Z + 16; - LandTile landTile = map.Tiles.GetLandTile(x, y); - TileFlag landFlags = TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags; + var landTile = map.Tiles.GetLandTile(x, y); + var landFlags = TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags; int landZ = 0, landAvg = 0, landTop = 0; map.GetAverageZ(x, y, ref landZ, ref landAvg, ref landTop); @@ -3015,17 +3019,17 @@ namespace Server if (landAvg <= maxZ) z = landAvg; - StaticTile[] tiles = map.Tiles.GetStaticTiles(x, y, true); + var tiles = map.Tiles.GetStaticTiles(x, y, true); - for (int i = 0; i < tiles.Length; ++i) + for (var i = 0; i < tiles.Length; ++i) { - StaticTile tile = tiles[i]; - ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; + var tile = tiles[i]; + var id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; if (!id.Surface) continue; - int top = tile.Z + id.CalcHeight; + var top = tile.Z + id.CalcHeight; if (top > maxZ || top < z) continue; @@ -3033,18 +3037,18 @@ namespace Server z = top; } - IPooledEnumerable eable = map.GetItemsInRange(p, 0); + var eable = map.GetItemsInRange(p, 0); - List items = eable.Where(item => + var items = eable.Where(item => { if (item is BaseMulti || item.ItemID > TileData.MaxItemValue) return false; - ItemData id = item.ItemData; + var id = item.ItemData; if (id.Surface) { - int top = item.Z + id.CalcHeight; + var top = item.Z + id.CalcHeight; if (top <= maxZ && top >= z) z = top; } @@ -3062,21 +3066,21 @@ namespace Server m_OpenSlots = (1 << 20) - 1; - int surfaceZ = z; + var surfaceZ = z; - for (int i = 0; i < tiles.Length; ++i) + for (var i = 0; i < tiles.Length; ++i) { - StaticTile tile = tiles[i]; - ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; + var tile = tiles[i]; + var id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; - int checkZ = tile.Z; - int checkTop = checkZ + id.CalcHeight; + var checkZ = tile.Z; + var checkTop = checkZ + id.CalcHeight; if (checkTop == checkZ && !id.Surface) ++checkTop; - int zStart = checkZ - z; - int zEnd = checkTop - z; + var zStart = checkZ - z; + var zEnd = checkTop - z; if (zStart >= 20 || zEnd < 0) continue; @@ -3087,24 +3091,24 @@ namespace Server if (zEnd > 19) zEnd = 19; - int bitCount = zEnd - zStart; + var bitCount = zEnd - zStart; - m_OpenSlots &= ~((1 << bitCount) - 1 << zStart); + m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart); } - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) { - Item item = items[i]; - ItemData id = item.ItemData; + var item = items[i]; + var id = item.ItemData; - int checkZ = item.Z; - int checkTop = checkZ + id.CalcHeight; + var checkZ = item.Z; + var checkTop = checkZ + id.CalcHeight; if (checkTop == checkZ && !id.Surface) ++checkTop; - int zStart = checkZ - z; - int zEnd = checkTop - z; + var zStart = checkZ - z; + var zEnd = checkTop - z; if (zStart >= 20 || zEnd < 0) continue; @@ -3115,12 +3119,12 @@ namespace Server if (zEnd > 19) zEnd = 19; - int bitCount = zEnd - zStart; + var bitCount = zEnd - zStart; - m_OpenSlots &= ~((1 << bitCount) - 1 << zStart); + m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart); } - int height = ItemData.Height; + var height = ItemData.Height; if (height == 0) ++height; @@ -3128,15 +3132,15 @@ namespace Server if (height > 30) height = 30; - int match = (1 << height) - 1; - bool okay = false; + var match = (1 << height) - 1; + var okay = false; - for (int i = 0; i < 20; ++i) + for (var i = 0; i < 20; ++i) { if (i + height > 20) match >>= 1; - okay = (m_OpenSlots >> i & match) == match; + okay = ((m_OpenSlots >> i) & match) == match; if (okay) { @@ -3159,13 +3163,13 @@ namespace Server if ((landFlags & TileFlag.Impassable) != 0 && landAvg > surfaceZ && z + height > landZ) return false; - for (int i = 0; i < tiles.Length; ++i) + for (var i = 0; i < tiles.Length; ++i) { - StaticTile tile = tiles[i]; - ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; + var tile = tiles[i]; + var id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; - int checkZ = tile.Z; - int checkTop = checkZ + id.CalcHeight; + var checkZ = tile.Z; + var checkTop = checkZ + id.CalcHeight; if (checkTop > z && z + height > checkZ) return false; @@ -3174,13 +3178,13 @@ namespace Server return false; } - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) { - Item item = items[i]; - ItemData id = item.ItemData; + var item = items[i]; + var id = item.ItemData; - //int checkZ = item.Z; - //int checkTop = checkZ + id.CalcHeight; + // int checkZ = item.Z; + // int checkTop = checkZ + id.CalcHeight; if (item.Z + id.CalcHeight > z && z + height > item.Z) return false; @@ -3195,7 +3199,7 @@ namespace Server if (!OnDroppedToWorld(from, p)) return false; - int soundID = GetDropSound(); + var soundID = GetDropSound(); MoveToWorld(p, from.Map); @@ -3208,13 +3212,13 @@ namespace Server { if (Deleted || m_Map == null) return; - Point3D worldLoc = GetWorldLocation(); + var worldLoc = GetWorldLocation(); - IPooledEnumerable eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); + var eable = m_Map.GetClientsInRange(worldLoc, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (m.InRange(worldLoc, GetUpdateRange(m))) state.Send(RemovePacket); } @@ -3226,18 +3230,18 @@ namespace Server public Point3D GetWorldLocation() { - IEntity root = RootParent; + var root = RootParent; if (root == null) return m_Location; return root.Location; - //return root == null ? m_Location : new Point3D( (IPoint3D) root ); + // return root == null ? m_Location : new Point3D( (IPoint3D) root ); } public Point3D GetSurfaceTop() { - IEntity root = RootParent; + var root = RootParent; if (root == null) return new Point3D(m_Location.m_X, m_Location.m_Y, @@ -3246,7 +3250,8 @@ namespace Server return root.Location; } - public Point3D GetWorldTop() => RootParent?.Location ?? new Point3D(m_Location.m_X, m_Location.m_Y, m_Location.m_Z + ItemData.CalcHeight); + public Point3D GetWorldTop() => RootParent?.Location ?? + new Point3D(m_Location.m_X, m_Location.m_Y, m_Location.m_Z + ItemData.CalcHeight); public void SendLocalizedMessageTo(Mobile to, int number) { @@ -3355,13 +3360,13 @@ namespace Server if (m_Parent is Item item) return item.IsAccessibleTo(check); - Region reg = Region.Find(GetWorldLocation(), m_Map); + var reg = Region.Find(GetWorldLocation(), m_Map); return reg.CheckAccessibility(this, check); /*SecureTradeContainer cont = GetSecureTradeCont(); - if ( cont != null && !cont.IsChildOf( check ) ) + if (cont != null && !cont.IsChildOf( check )) return false; return true;*/ @@ -3371,7 +3376,7 @@ namespace Server public bool IsChildOf(IEntity o, bool allowNull) { - IEntity p = m_Parent; + var p = m_Parent; if ((p == null || o == null) && !allowNull) return false; @@ -3422,7 +3427,7 @@ namespace Server public bool CheckLift(Mobile from) { - LRReason reject = LRReason.Inspecific; + var reject = LRReason.Inspecific; return CheckLift(from, this, ref reject); } @@ -3446,7 +3451,7 @@ namespace Server public virtual void OnAosSingleClick(Mobile from) { - ObjectPropertyList opl = PropertyList; + var opl = PropertyList; if (opl.Header > 0) from.Send(new MessageLocalized(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, opl.Header, Name, @@ -3461,7 +3466,7 @@ namespace Server if (DisplayLootType) LabelLootTypeTo(from); - NetState ns = from.NetState; + var ns = from.NetState; if (ns == null) return; @@ -3489,18 +3494,18 @@ namespace Server public virtual void ScissorHelper(Mobile from, Item newItem, int amountPerOldItem, bool carryHue) { - int amount = Amount; + var amount = Amount; if (amount > 60000 / amountPerOldItem) // let's not go over 60000 amount = 60000 / amountPerOldItem; Amount -= amount; - int ourHue = Hue; - Map thisMap = Map; - IEntity thisParent = m_Parent; - Point3D worldLoc = GetWorldLocation(); - LootType type = LootType; + var ourHue = Hue; + var thisMap = Map; + var thisParent = m_Parent; + var worldLoc = GetWorldLocation(); + var type = LootType; if (Amount == 0) Delete(); @@ -3547,7 +3552,7 @@ namespace Server public virtual bool CheckBlessed(Mobile m) { - if (m_LootType == LootType.Blessed || Mobile.InsuranceEnabled && Insured) + if (m_LootType == LootType.Blessed || (Mobile.InsuranceEnabled && Insured)) return true; return m != null && m == BlessedFor; @@ -3641,8 +3646,6 @@ namespace Server NullWeight = 0x04000000 } - #region Standard fields - private Point3D m_Location; private int m_ItemID; private int m_Hue; @@ -3653,10 +3656,6 @@ namespace Server private LootType m_LootType; private Direction m_Direction; - #endregion - - #region Location Location Location! - public virtual void OnLocationChange(Point3D oldLocation) { } @@ -3667,7 +3666,7 @@ namespace Server get => m_Location; set { - Point3D oldLocation = m_Location; + var oldLocation = m_Location; if (oldLocation == value) return; @@ -3681,9 +3680,9 @@ namespace Server { eable = m_Map.GetClientsInRange(oldLocation, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (!m.InRange(value, GetUpdateRange(m))) state.Send(RemovePacket); } @@ -3691,7 +3690,7 @@ namespace Server eable.Free(); } - Point3D oldLoc = m_Location; + var oldLoc = m_Location; m_Location = value; ReleaseWorldPackets(); @@ -3699,9 +3698,9 @@ namespace Server eable = m_Map.GetClientsInRange(m_Location, GetMaxUpdateRange()); - foreach (NetState state in eable) + foreach (var state in eable) { - Mobile m = state.Mobile; + var m = state.Mobile; if (m.CanSee(this) && m.InRange(m_Location, GetUpdateRange(m)) && (!state.HighSeas || !NoMoveHS || (m_DeltaFlags & ItemDelta.Update) != 0 || @@ -3760,9 +3759,6 @@ namespace Server set => Location = new Point3D(m_Location.m_X, m_Location.m_Y, value); } - #endregion - - #region InRange public virtual bool InRange(Point2D p, int range) => p.m_X >= Location.m_X - range && p.m_X <= Location.m_X + range @@ -3780,9 +3776,6 @@ namespace Server && p.X <= Location.m_X + range && p.Y >= Location.m_Y - range && p.Y <= Location.m_Y + range; - #endregion - - #region OnDoubleClick[...] public virtual void OnDoubleClick(Mobile from) { @@ -3810,7 +3803,5 @@ namespace Server { from.SendLocalizedMessage(500447); // That is not accessible. } - - #endregion } } diff --git a/Projects/Server/ItemBounds.cs b/Projects/Server/ItemBounds.cs index de406fa6a..f1d5bdbe6 100644 --- a/Projects/Server/ItemBounds.cs +++ b/Projects/Server/ItemBounds.cs @@ -31,13 +31,13 @@ namespace Server if (File.Exists("Data/Binary/Bounds.bin")) { - using FileStream fs = new FileStream("Data/Binary/Bounds.bin", FileMode.Open, FileAccess.Read, + using var fs = new FileStream("Data/Binary/Bounds.bin", FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader bin = new BinaryReader(fs); + var bin = new BinaryReader(fs); - int count = Math.Min(Table.Length, (int)(fs.Length / 8)); + var count = Math.Min(Table.Length, (int)(fs.Length / 8)); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { int xMin = bin.ReadInt16(); int yMin = bin.ReadInt16(); @@ -50,9 +50,11 @@ namespace Server bin.Close(); } else + { Console.WriteLine("Warning: Data/Binary/Bounds.bin does not exist"); + } } - public static Rectangle2D[] Table{ get; } + public static Rectangle2D[] Table { get; } } -} \ No newline at end of file +} diff --git a/Projects/Server/Items/BaseMulti.cs b/Projects/Server/Items/BaseMulti.cs index 5308d5ff7..f74e7ef97 100644 --- a/Projects/Server/Items/BaseMulti.cs +++ b/Projects/Server/Items/BaseMulti.cs @@ -38,7 +38,7 @@ namespace Server.Items { if (base.ItemID != value) { - Map facet = Parent == null ? Map : null; + var facet = Parent == null ? Map : null; facet?.OnLeave(this); @@ -53,11 +53,11 @@ namespace Server.Items { get { - MultiComponentList mcl = Components; + var mcl = Components; if (mcl.List.Length > 0) { - int id = mcl.List[0].m_ItemID; + int id = mcl.List[0].ItemId; if (id < 0x4000) return 1020000 + id; @@ -77,7 +77,7 @@ namespace Server.Items { if (Parent == null) { - Map facet = Map; + var facet = Map; if (facet != null) { @@ -99,7 +99,7 @@ namespace Server.Items public virtual bool Contains(int x, int y) { - MultiComponentList mcl = Components; + var mcl = Components; x -= X + mcl.Min.m_X; y -= Y + mcl.Min.m_Y; @@ -126,7 +126,7 @@ namespace Server.Items { base.Deserialize(reader); - int version = reader.ReadInt(); + var version = reader.ReadInt(); if (version == 0) if (ItemID >= 0x4000) diff --git a/Projects/Server/Items/Container.cs b/Projects/Server/Items/Container.cs index 5bc03a3f2..26d7e1368 100644 --- a/Projects/Server/Items/Container.cs +++ b/Projects/Server/Items/Container.cs @@ -36,7 +36,7 @@ namespace Server.Items public class Container : Item { - private static readonly QueuePool m_QueuePool = new QueuePool(QueueRef.Generate, preGenerateCount: 2, maxRefrenceRetention: 5); + private static readonly QueuePool m_QueuePool = new QueuePool(QueueRef.Generate, 2, 5); private static readonly List m_FindItemsList = new List(); private ContainerData m_ContainerData; @@ -64,7 +64,7 @@ namespace Server.Items { } - public static ContainerSnoopHandler SnoopHandler{ get; set; } + public static ContainerSnoopHandler SnoopHandler { get; set; } public ContainerData ContainerData { @@ -84,7 +84,7 @@ namespace Server.Items get => base.ItemID; set { - int oldID = ItemID; + var oldID = ItemID; base.ItemID = value; @@ -130,7 +130,7 @@ namespace Server.Items } [CommandProperty(AccessLevel.GameMaster)] - public bool LiftOverride{ get; set; } + public bool LiftOverride { get; set; } public virtual Rectangle2D Bounds => ContainerData.Bounds; @@ -145,13 +145,13 @@ namespace Server.Items public virtual bool IsDecoContainer => !Movable && !IsLockedDown && !IsSecure && Parent == null && !LiftOverride; - public static int GlobalMaxItems{ get; set; } = 125; + public static int GlobalMaxItems { get; set; } = 125; - public static int GlobalMaxWeight{ get; set; } = 400; + public static int GlobalMaxWeight { get; set; } = 400; public virtual bool DisplaysContent => true; - public List Openers{ get; set; } + public List Openers { get; set; } public virtual bool IsPublicContainer => false; @@ -162,7 +162,7 @@ namespace Server.Items public virtual int GetDroppedSound(Item item) { - int dropSound = item.GetDropSound(); + var dropSound = item.GetDropSound(); return dropSound != -1 ? dropSound : DropSound; } @@ -196,7 +196,8 @@ namespace Server.Items public bool CheckHold(Mobile m, Item item, bool message) => CheckHold(m, item, message, true, 0, 0); - public bool CheckHold(Mobile m, Item item, bool message, bool checkItems) => CheckHold(m, item, message, checkItems, 0, 0); + public bool CheckHold(Mobile m, Item item, bool message, bool checkItems) => + CheckHold(m, item, message, checkItems, 0, 0); public virtual bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { @@ -210,7 +211,7 @@ namespace Server.Items return false; } - int maxItems = MaxItems; + var maxItems = MaxItems; if (checkItems && maxItems != 0 && TotalItems + plusItems + item.TotalItems + (item.IsVirtualItem ? 0 : 1) > maxItems) @@ -230,7 +231,7 @@ namespace Server.Items } } - IEntity parent = Parent; + var parent = Parent; while (parent != null) { @@ -274,12 +275,11 @@ namespace Server.Items return true; } - private static bool InTypeList(Item item, Type[] types) { - Type t = item.GetType(); + var t = item.GetType(); - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) if (types[i].IsAssignableFrom(t)) return true; @@ -300,7 +300,7 @@ namespace Server.Items writer.Write(2); // version - SaveFlag flags = SaveFlag.None; + var flags = SaveFlag.None; SetSaveFlag(ref flags, SaveFlag.MaxItems, m_MaxItems != -1); SetSaveFlag(ref flags, SaveFlag.GumpID, m_GumpID != -1); @@ -323,61 +323,61 @@ namespace Server.Items { base.Deserialize(reader); - int version = reader.ReadInt(); + var version = reader.ReadInt(); switch (version) { case 2: - { - SaveFlag flags = (SaveFlag)reader.ReadByte(); + { + var flags = (SaveFlag)reader.ReadByte(); - if (GetSaveFlag(flags, SaveFlag.MaxItems)) - m_MaxItems = reader.ReadEncodedInt(); - else - m_MaxItems = -1; + if (GetSaveFlag(flags, SaveFlag.MaxItems)) + m_MaxItems = reader.ReadEncodedInt(); + else + m_MaxItems = -1; - if (GetSaveFlag(flags, SaveFlag.GumpID)) - m_GumpID = reader.ReadEncodedInt(); - else - m_GumpID = -1; + if (GetSaveFlag(flags, SaveFlag.GumpID)) + m_GumpID = reader.ReadEncodedInt(); + else + m_GumpID = -1; - if (GetSaveFlag(flags, SaveFlag.DropSound)) - m_DropSound = reader.ReadEncodedInt(); - else - m_DropSound = -1; + if (GetSaveFlag(flags, SaveFlag.DropSound)) + m_DropSound = reader.ReadEncodedInt(); + else + m_DropSound = -1; - LiftOverride = GetSaveFlag(flags, SaveFlag.LiftOverride); + LiftOverride = GetSaveFlag(flags, SaveFlag.LiftOverride); - break; - } + break; + } case 1: - { - m_MaxItems = reader.ReadInt(); - goto case 0; - } + { + m_MaxItems = reader.ReadInt(); + goto case 0; + } case 0: - { - if (version < 1) - m_MaxItems = GlobalMaxItems; + { + if (version < 1) + m_MaxItems = GlobalMaxItems; - m_GumpID = reader.ReadInt(); - m_DropSound = reader.ReadInt(); + m_GumpID = reader.ReadInt(); + m_DropSound = reader.ReadInt(); - if (m_GumpID == DefaultGumpID) - m_GumpID = -1; + if (m_GumpID == DefaultGumpID) + m_GumpID = -1; - if (m_DropSound == DefaultDropSound) - m_DropSound = -1; + if (m_DropSound == DefaultDropSound) + m_DropSound = -1; - if (m_MaxItems == DefaultMaxItems) - m_MaxItems = -1; + if (m_MaxItems == DefaultMaxItems) + m_MaxItems = -1; - //m_Bounds = new Rectangle2D( reader.ReadPoint2D(), reader.ReadPoint2D() ); - reader.ReadPoint2D(); - reader.ReadPoint2D(); + // m_Bounds = new Rectangle2D( reader.ReadPoint2D(), reader.ReadPoint2D() ); + reader.ReadPoint2D(); + reader.ReadPoint2D(); - break; - } + break; + } } UpdateContainerData(); @@ -423,14 +423,14 @@ namespace Server.Items m_TotalItems = 0; m_TotalWeight = 0; - List items = m_Items; + var items = m_Items; if (items == null) return; - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) { - Item item = items[i]; + var item = items[i]; item.UpdateTotals(); @@ -443,7 +443,8 @@ namespace Server.Items } } - public virtual bool OnStackAttempt(Mobile from, Item stack, Item dropped) => CheckHold(from, dropped, true, false) && stack.StackWith(from, dropped); + public virtual bool OnStackAttempt(Mobile from, Item stack, Item dropped) => + CheckHold(from, dropped, true, false) && stack.StackWith(from, dropped); public override bool OnDragDrop(Mobile from, Item dropped) { @@ -457,15 +458,16 @@ namespace Server.Items return false; } - public virtual bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage) => TryDropItem(from, dropped, sendFullMessage, false); + public virtual bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage) => + TryDropItem(from, dropped, sendFullMessage, false); public virtual bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage, bool playSound) { - List list = Items; + var list = Items; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - Item item = list[i]; + var item = list[i]; if (!(item is Container) && CheckHold(from, dropped, false, false) && item.StackWith(from, dropped, playSound)) @@ -483,30 +485,30 @@ namespace Server.Items public virtual bool TryDropItems(Mobile from, bool sendFullMessage, params Item[] droppedItems) { - List dropItems = new List(); - List stackItems = new List(); + var dropItems = new List(); + var stackItems = new List(); - int extraItems = 0; - int extraWeight = 0; + var extraItems = 0; + var extraWeight = 0; - for (int i = 0; i < droppedItems.Length; i++) + for (var i = 0; i < droppedItems.Length; i++) { - Item dropped = droppedItems[i]; + var dropped = droppedItems[i]; - List list = Items; + var list = Items; - bool stacked = false; + var stacked = false; - for (int j = 0; j < list.Count; ++j) + for (var j = 0; j < list.Count; ++j) { - Item item = list[j]; + var item = list[j]; if (!(item is Container) && CheckHold(from, dropped, false, false, 0, extraWeight) && item.CanStackWith(dropped)) { stackItems.Add(new ItemStackEntry(item, dropped)); extraWeight += (int)Math.Ceiling(item.Weight * (item.Amount + dropped.Amount)) - - item.PileWeight; //extra weight delta, do not need TotalWeight as we do not have hybrid stackable container types + item.PileWeight; // extra weight delta, do not need TotalWeight as we do not have hybrid stackable container types stacked = true; break; } @@ -520,12 +522,12 @@ namespace Server.Items } } - if (dropItems.Count + stackItems.Count == droppedItems.Length) //All good + if (dropItems.Count + stackItems.Count == droppedItems.Length) // All good { - for (int i = 0; i < dropItems.Count; i++) + for (var i = 0; i < dropItems.Count; i++) DropItem(dropItems[i]); - for (int i = 0; i < stackItems.Count; i++) + for (var i = 0; i < stackItems.Count; i++) stackItems[i].m_StackItem.StackWith(from, stackItems[i].m_DropItem, false); return true; @@ -536,10 +538,10 @@ namespace Server.Items public virtual void Destroy() { - Point3D loc = GetWorldLocation(); - Map map = Map; + var loc = GetWorldLocation(); + var map = Map; - for (int i = Items.Count - 1; i >= 0; --i) + for (var i = Items.Count - 1; i >= 0; --i) if (i < Items.Count) { Items[i].SetLastMoved(); @@ -556,8 +558,8 @@ namespace Server.Items AddItem(dropped); - Rectangle2D bounds = dropped.GetGraphicBounds(); - Rectangle2D ourBounds = Bounds; + var bounds = dropped.GetGraphicBounds(); + var ourBounds = Bounds; int x, y; @@ -586,7 +588,7 @@ namespace Server.Items { DisplayTo(from); - SecureTrade trade = GetSecureTradeCont()?.Trade; + var trade = GetSecureTradeCont()?.Trade; if (trade != null) { @@ -603,7 +605,7 @@ namespace Server.Items } public virtual bool CheckContentDisplay(Mobile from) => - DisplaysContent && RootParent == null || + (DisplaysContent && RootParent == null) || RootParent is Item || RootParent == from || from.AccessLevel > AccessLevel.Player; @@ -613,7 +615,7 @@ namespace Server.Items if (CheckContentDisplay(from)) LabelTo(from, "({0} item{2}, {1} stones)", TotalItems, TotalWeight, TotalItems != 1 ? "s" : string.Empty); - //LabelTo( from, 1050044, String.Format( "{0}\t{1}", TotalItems.ToString(), TotalWeight.ToString() ) ); + // LabelTo( from, 1050044, String.Format( "{0}\t{1}", TotalItems.ToString(), TotalWeight.ToString() ) ); } public override void OnDelete() @@ -627,7 +629,7 @@ namespace Server.Items { ProcessOpeners(to); - NetState ns = to.NetState; + var ns = to.NetState; if (ns != null) { @@ -640,9 +642,9 @@ namespace Server.Items if (ObjectPropertyList.Enabled) { - List items = Items; + var items = Items; - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) to.Send(items[i].OPLPacket); } } @@ -653,16 +655,16 @@ namespace Server.Items if (IsPublicContainer) return; - bool contains = false; + var contains = false; if (Openers != null) { - Point3D worldLoc = GetWorldLocation(); - Map map = Map; + var worldLoc = GetWorldLocation(); + var map = Map; - for (int i = 0; i < Openers.Count; ++i) + for (var i = 0; i < Openers.Count; ++i) { - Mobile mob = Openers[i]; + var mob = Openers[i]; if (mob == opener) { @@ -670,7 +672,7 @@ namespace Server.Items } else { - int range = GetUpdateRange(mob); + var range = GetUpdateRange(mob); if (mob.Map != map || !mob.InRange(worldLoc, range)) Openers.RemoveAt(i--); @@ -705,18 +707,18 @@ namespace Server.Items { base.GetProperties(list); - if (DisplaysContent) //CheckContentDisplay( from ) ) + if (DisplaysContent) // CheckContentDisplay( from )) { if (Core.ML) { - if (ParentsContain()) //Root Parent is the Mobile. Parent could be another containter. + if (ParentsContain()) // Root Parent is the Mobile. Parent could be another containter. list.Add(1073841, "{0}\t{1}\t{2}", TotalItems, MaxItems, TotalWeight); // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~ stones else list.Add(1072241, "{0}\t{1}\t{2}\t{3}", TotalItems, MaxItems, TotalWeight, MaxWeight); // Contents: ~1_COUNT~/~2_MAXCOUNT~ items, ~3_WEIGHT~/~4_MAXWEIGHT~ stones - //TODO: Where do the other clilocs come into play? 1073839 & 1073840? + // TODO: Where do the other clilocs come into play? 1073839 & 1073840? } else { @@ -764,29 +766,27 @@ namespace Server.Items } } - #region Consume[...] - public bool ConsumeTotalGrouped(Type type, int amount, bool recurse, OnItemConsumed callback, CheckItemGroup grouper) { if (grouper == null) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(grouper)); - Item[] typedItems = FindItemsByType(type, recurse); + var typedItems = FindItemsByType(type, recurse); - List> groups = new List>(); - int idx = 0; + var groups = new List>(); + var idx = 0; while (idx < typedItems.Length) { - Item a = typedItems[idx++]; - List group = new List(); + var a = typedItems[idx++]; + var group = new List(); group.Add(a); while (idx < typedItems.Length) { - Item b = typedItems[idx]; - int v = grouper(a, b); + var b = typedItems[idx]; + var v = grouper(a, b); if (v == 0) group.Add(b); @@ -799,16 +799,16 @@ namespace Server.Items groups.Add(group); } - Item[][] items = new Item[groups.Count][]; - int[] totals = new int[groups.Count]; + var items = new Item[groups.Count][]; + var totals = new int[groups.Count]; - bool hasEnough = false; + var hasEnough = false; - for (int i = 0; i < groups.Count; ++i) + for (var i = 0; i < groups.Count; ++i) { items[i] = groups[i].ToArray(); - for (int j = 0; j < items[i].Length; ++j) + for (var j = 0; j < items[i].Length; ++j) totals[i] += items[i][j].Amount; if (totals[i] >= amount) @@ -818,16 +818,16 @@ namespace Server.Items if (!hasEnough) return false; - for (int i = 0; i < items.Length; ++i) + for (var i = 0; i < items.Length; ++i) if (totals[i] >= amount) { - int need = amount; + var need = amount; - for (int j = 0; j < items[i].Length; ++j) + for (var j = 0; j < items[i].Length; ++j) { - Item item = items[i][j]; + var item = items[i][j]; - int theirAmount = item.Amount; + var theirAmount = item.Amount; if (theirAmount < need) { @@ -855,31 +855,31 @@ namespace Server.Items CheckItemGroup grouper) { if (types.Length != amounts.Length) - throw new ArgumentException(); + throw new ArgumentException("length of types and amounts must match"); if (grouper == null) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(grouper)); - Item[][][] items = new Item[types.Length][][]; - int[][] totals = new int[types.Length][]; + var items = new Item[types.Length][][]; + var totals = new int[types.Length][]; - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) { - Item[] typedItems = FindItemsByType(types[i], recurse); + var typedItems = FindItemsByType(types[i], recurse); - List> groups = new List>(); - int idx = 0; + var groups = new List>(); + var idx = 0; while (idx < typedItems.Length) { - Item a = typedItems[idx++]; - List group = new List(); + var a = typedItems[idx++]; + var group = new List(); group.Add(a); while (idx < typedItems.Length) { - Item b = typedItems[idx]; - int v = grouper(a, b); + var b = typedItems[idx]; + var v = grouper(a, b); if (v == 0) group.Add(b); @@ -895,13 +895,13 @@ namespace Server.Items items[i] = new Item[groups.Count][]; totals[i] = new int[groups.Count]; - bool hasEnough = false; + var hasEnough = false; - for (int j = 0; j < groups.Count; ++j) + for (var j = 0; j < groups.Count; ++j) { items[i][j] = groups[j].ToArray(); - for (int k = 0; k < items[i][j].Length; ++k) + for (var k = 0; k < items[i][j].Length; ++k) totals[i][j] += items[i][j][k].Amount; if (totals[i][j] >= amounts[i]) @@ -912,37 +912,37 @@ namespace Server.Items return i; } - for (int i = 0; i < items.Length; ++i) - for (int j = 0; j < items[i].Length; ++j) - if (totals[i][j] >= amounts[i]) - { - int need = amounts[i]; - - for (int k = 0; k < items[i][j].Length; ++k) + for (var i = 0; i < items.Length; ++i) + for (var j = 0; j < items[i].Length; ++j) + if (totals[i][j] >= amounts[i]) { - Item item = items[i][j][k]; + var need = amounts[i]; - int theirAmount = item.Amount; - - if (theirAmount < need) + for (var k = 0; k < items[i][j].Length; ++k) { - callback?.Invoke(item, theirAmount); + var item = items[i][j][k]; - item.Consume(theirAmount); - need -= theirAmount; - } - else - { - callback?.Invoke(item, need); + var theirAmount = item.Amount; - item.Consume(need); - break; + if (theirAmount < need) + { + callback?.Invoke(item, theirAmount); + + item.Consume(theirAmount); + need -= theirAmount; + } + else + { + callback?.Invoke(item, need); + + item.Consume(need); + break; + } } + + break; } - break; - } - return -1; } @@ -950,31 +950,31 @@ namespace Server.Items CheckItemGroup grouper) { if (types.Length != amounts.Length) - throw new ArgumentException(); + throw new ArgumentException("length of types and amounts must match"); if (grouper == null) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(grouper)); - Item[][][] items = new Item[types.Length][][]; - int[][] totals = new int[types.Length][]; + var items = new Item[types.Length][][]; + var totals = new int[types.Length][]; - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) { - Item[] typedItems = FindItemsByType(types[i], recurse); + var typedItems = FindItemsByType(types[i], recurse); - List> groups = new List>(); - int idx = 0; + var groups = new List>(); + var idx = 0; while (idx < typedItems.Length) { - Item a = typedItems[idx++]; - List group = new List(); + var a = typedItems[idx++]; + var group = new List(); group.Add(a); while (idx < typedItems.Length) { - Item b = typedItems[idx]; - int v = grouper(a, b); + var b = typedItems[idx]; + var v = grouper(a, b); if (v == 0) group.Add(b); @@ -990,13 +990,13 @@ namespace Server.Items items[i] = new Item[groups.Count][]; totals[i] = new int[groups.Count]; - bool hasEnough = false; + var hasEnough = false; - for (int j = 0; j < groups.Count; ++j) + for (var j = 0; j < groups.Count; ++j) { items[i][j] = groups[j].ToArray(); - for (int k = 0; k < items[i][j].Length; ++k) + for (var k = 0; k < items[i][j].Length; ++k) totals[i][j] += items[i][j][k].Amount; if (totals[i][j] >= amounts[i]) @@ -1007,68 +1007,68 @@ namespace Server.Items return i; } - for (int i = 0; i < items.Length; ++i) - for (int j = 0; j < items[i].Length; ++j) - if (totals[i][j] >= amounts[i]) - { - int need = amounts[i]; - - for (int k = 0; k < items[i][j].Length; ++k) + for (var i = 0; i < items.Length; ++i) + for (var j = 0; j < items[i].Length; ++j) + if (totals[i][j] >= amounts[i]) { - Item item = items[i][j][k]; + var need = amounts[i]; - int theirAmount = item.Amount; - - if (theirAmount < need) + for (var k = 0; k < items[i][j].Length; ++k) { - callback?.Invoke(item, theirAmount); + var item = items[i][j][k]; - item.Consume(theirAmount); - need -= theirAmount; - } - else - { - callback?.Invoke(item, need); + var theirAmount = item.Amount; - item.Consume(need); - break; + if (theirAmount < need) + { + callback?.Invoke(item, theirAmount); + + item.Consume(theirAmount); + need -= theirAmount; + } + else + { + callback?.Invoke(item, need); + + item.Consume(need); + break; + } } + + break; } - break; - } - return -1; } public int ConsumeTotal(Type[][] types, int[] amounts, bool recurse = true, OnItemConsumed callback = null) { if (types.Length != amounts.Length) - throw new ArgumentException(); + throw new ArgumentException("length of types and amounts must match"); - Item[][] items = new Item[types.Length][]; - int[] totals = new int[types.Length]; + var items = new Item[types.Length][]; + var totals = new int[types.Length]; - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) { items[i] = FindItemsByType(types[i], recurse); - for (int j = 0; j < items[i].Length; ++j) + for (var j = 0; j < items[i].Length; ++j) totals[i] += items[i][j].Amount; if (totals[i] < amounts[i]) return i; } - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) { - int need = amounts[i]; + var need = amounts[i]; - for (int j = 0; j < items[i].Length; ++j) + for (var j = 0; j < items[i].Length; ++j) { - Item item = items[i][j]; + var item = items[i][j]; - int theirAmount = item.Amount; + var theirAmount = item.Amount; if (theirAmount < need) { @@ -1093,31 +1093,31 @@ namespace Server.Items public int ConsumeTotal(Type[] types, int[] amounts, bool recurse = true, OnItemConsumed callback = null) { if (types.Length != amounts.Length) - throw new ArgumentException(); + throw new ArgumentException("length of types and amounts must match"); - Item[][] items = new Item[types.Length][]; - int[] totals = new int[types.Length]; + var items = new Item[types.Length][]; + var totals = new int[types.Length]; - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) { items[i] = FindItemsByType(types[i], recurse); - for (int j = 0; j < items[i].Length; ++j) + for (var j = 0; j < items[i].Length; ++j) totals[i] += items[i][j].Amount; if (totals[i] < amounts[i]) return i; } - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) { - int need = amounts[i]; + var need = amounts[i]; - for (int j = 0; j < items[i].Length; ++j) + for (var j = 0; j < items[i].Length; ++j) { - Item item = items[i][j]; + var item = items[i][j]; - int theirAmount = item.Amount; + var theirAmount = item.Amount; if (theirAmount < need) { @@ -1141,25 +1141,25 @@ namespace Server.Items public bool ConsumeTotal(Type type, int amount = 1, bool recurse = true, OnItemConsumed callback = null) { - Item[] items = FindItemsByType(type, recurse); + var items = FindItemsByType(type, recurse); // First pass, compute total - int total = 0; + var total = 0; - for (int i = 0; i < items.Length; ++i) + for (var i = 0; i < items.Length; ++i) total += items[i].Amount; if (total >= amount) { // We've enough, so consume it - int need = amount; + var need = amount; - for (int i = 0; i < items.Length; ++i) + for (var i = 0; i < items.Length; ++i) { - Item item = items[i]; + var item = items[i]; - int theirAmount = item.Amount; + var theirAmount = item.Amount; if (theirAmount < need) { @@ -1184,9 +1184,9 @@ namespace Server.Items public int ConsumeUpTo(Type type, int amount, bool recurse = true) { - int consumed = 0; + var consumed = 0; - Queue toDelete = new Queue(); + var toDelete = new Queue(); RecurseConsumeUpTo(this, type, amount, recurse, ref consumed, toDelete); @@ -1202,16 +1202,16 @@ namespace Server.Items if (current == null || current.Items.Count == 0) return; - List list = current.Items; + var list = current.Items; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - Item item = list[i]; + var item = list[i]; if (type.IsInstanceOfType(item)) { - int need = amount - consumed; - int theirAmount = item.Amount; + var need = amount - consumed; + var theirAmount = item.Amount; if (theirAmount <= need) { @@ -1233,33 +1233,29 @@ namespace Server.Items } } - #endregion - - #region Get[BestGroup]Amount - public int GetBestGroupAmount(Type type, bool recurse, CheckItemGroup grouper) { if (grouper == null) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(grouper)); - int best = 0; + var best = 0; - Item[] typedItems = FindItemsByType(type, recurse); + var typedItems = FindItemsByType(type, recurse); - List> groups = new List>(); - int idx = 0; + var groups = new List>(); + var idx = 0; while (idx < typedItems.Length) { - Item a = typedItems[idx++]; - List group = new List(); + var a = typedItems[idx++]; + var group = new List(); group.Add(a); while (idx < typedItems.Length) { - Item b = typedItems[idx]; - int v = grouper(a, b); + var b = typedItems[idx]; + var v = grouper(a, b); if (v == 0) group.Add(b); @@ -1272,13 +1268,13 @@ namespace Server.Items groups.Add(group); } - for (int i = 0; i < groups.Count; ++i) + for (var i = 0; i < groups.Count; ++i) { - Item[] items = groups[i].ToArray(); + var items = groups[i].ToArray(); - int total = 0; + var total = 0; - for (int j = 0; j < items.Length; ++j) + for (var j = 0; j < items.Length; ++j) total += items[j].Amount; if (total >= best) @@ -1291,26 +1287,26 @@ namespace Server.Items public int GetBestGroupAmount(Type[] types, bool recurse, CheckItemGroup grouper) { if (grouper == null) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(grouper)); - int best = 0; + var best = 0; - Item[] typedItems = FindItemsByType(types, recurse); + var typedItems = FindItemsByType(types, recurse); - List> groups = new List>(); - int idx = 0; + var groups = new List>(); + var idx = 0; while (idx < typedItems.Length) { - Item a = typedItems[idx++]; - List group = new List(); + var a = typedItems[idx++]; + var group = new List(); group.Add(a); while (idx < typedItems.Length) { - Item b = typedItems[idx]; - int v = grouper(a, b); + var b = typedItems[idx]; + var v = grouper(a, b); if (v == 0) group.Add(b); @@ -1323,10 +1319,10 @@ namespace Server.Items groups.Add(group); } - for (int j = 0; j < groups.Count; ++j) + for (var j = 0; j < groups.Count; ++j) { - Item[] items = groups[j].ToArray(); - int total = items.Sum(t => t.Amount); + var items = groups[j].ToArray(); + var total = items.Sum(t => t.Amount); if (total >= best) best = total; @@ -1338,28 +1334,28 @@ namespace Server.Items public int GetBestGroupAmount(Type[][] types, bool recurse, CheckItemGroup grouper) { if (grouper == null) - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(grouper)); - int best = 0; + var best = 0; - for (int i = 0; i < types.Length; ++i) + for (var i = 0; i < types.Length; ++i) { - Item[] typedItems = FindItemsByType(types[i], recurse); + var typedItems = FindItemsByType(types[i], recurse); - List> groups = new List>(); - int idx = 0; + var groups = new List>(); + var idx = 0; while (idx < typedItems.Length) { - Item a = typedItems[idx++]; - List group = new List(); + var a = typedItems[idx++]; + var group = new List(); group.Add(a); while (idx < typedItems.Length) { - Item b = typedItems[idx]; - int v = grouper(a, b); + var b = typedItems[idx]; + var v = grouper(a, b); if (v == 0) group.Add(b); @@ -1372,12 +1368,12 @@ namespace Server.Items groups.Add(group); } - for (int j = 0; j < groups.Count; ++j) + for (var j = 0; j < groups.Count; ++j) { - Item[] items = groups[j].ToArray(); - int total = 0; + var items = groups[j].ToArray(); + var total = 0; - for (int k = 0; k < items.Length; ++k) + for (var k = 0; k < items.Length; ++k) total += items[k].Amount; if (total >= best) @@ -1392,10 +1388,6 @@ namespace Server.Items public int GetAmount(Type[] types, bool recurse = true) => FindItemsByType(types, recurse).Sum(t => t.Amount); - #endregion - - #region Non-Generic FindItem[s] by Type - public Item[] FindItemsByType(Type type, bool recurse = true) { if (m_FindItemsList.Count > 0) @@ -1411,11 +1403,11 @@ namespace Server.Items if (current == null || current.Items.Count == 0) return; - List items = current.Items; + var items = current.Items; - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) { - Item item = items[i]; + var item = items[i]; if (type.IsInstanceOfType(item)) list.Add(item); @@ -1440,11 +1432,11 @@ namespace Server.Items if (current == null || current.Items.Count == 0) return; - List items = current.Items; + var items = current.Items; - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) { - Item item = items[i]; + var item = items[i]; if (InTypeList(item, types)) list.Add(item); @@ -1461,18 +1453,18 @@ namespace Server.Items if (current == null || current.Items.Count == 0) return null; - List list = current.Items; + var list = current.Items; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - Item item = list[i]; + var item = list[i]; if (type.IsInstanceOfType(item)) return item; if (recurse && item is Container) { - Item check = RecurseFindItemByType(item, type, true); + var check = RecurseFindItemByType(item, type, true); if (check != null) return check; @@ -1489,17 +1481,17 @@ namespace Server.Items if (current == null || current.Items.Count == 0) return null; - List list = current.Items; + var list = current.Items; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - Item item = list[i]; + var item = list[i]; if (InTypeList(item, types)) return item; if (recurse && item is Container) { - Item check = RecurseFindItemByType(item, types, true); + var check = RecurseFindItemByType(item, types, true); if (check != null) return check; @@ -1509,10 +1501,6 @@ namespace Server.Items return null; } - #endregion - - #region Generic FindItem[s] by Type - public List FindItemsByType(Predicate predicate) where T : Item => FindItemsByType(true, predicate); /// @@ -1541,11 +1529,11 @@ namespace Server.Items else if (recurse && item is Container itemContainer) queue.Enqueue(itemContainer); } + return items; } } - /// /// Performs a Breadth-First search through all the s and /// nested s within this . @@ -1573,10 +1561,10 @@ namespace Server.Items queue.Enqueue(itemContainer); } } + return null; } } - #endregion } public class ContainerData @@ -1587,7 +1575,7 @@ namespace Server.Items { m_Table = new Dictionary(); - string path = Path.Combine(Core.BaseDirectory, "Data/containers.cfg"); + var path = Path.Combine(Core.BaseDirectory, "Data/containers.cfg"); if (!File.Exists(path)) { @@ -1595,7 +1583,7 @@ namespace Server.Items return; } - using (StreamReader reader = new StreamReader(path)) + using (var reader = new StreamReader(path)) { string line; @@ -1608,36 +1596,36 @@ namespace Server.Items try { - string[] split = line.Split('\t'); + var split = line.Split('\t'); if (split.Length >= 3) { - int gumpID = Utility.ToInt32(split[0]); + var gumpID = Utility.ToInt32(split[0]); - string[] aRect = split[1].Split(' '); + var aRect = split[1].Split(' '); if (aRect.Length < 4) continue; - int x = Utility.ToInt32(aRect[0]); - int y = Utility.ToInt32(aRect[1]); - int width = Utility.ToInt32(aRect[2]); - int height = Utility.ToInt32(aRect[3]); + var x = Utility.ToInt32(aRect[0]); + var y = Utility.ToInt32(aRect[1]); + var width = Utility.ToInt32(aRect[2]); + var height = Utility.ToInt32(aRect[3]); - Rectangle2D bounds = new Rectangle2D(x, y, width, height); + var bounds = new Rectangle2D(x, y, width, height); - int dropSound = Utility.ToInt32(split[2]); + var dropSound = Utility.ToInt32(split[2]); - ContainerData data = new ContainerData(gumpID, bounds, dropSound); + var data = new ContainerData(gumpID, bounds, dropSound); Default ??= data; if (split.Length >= 4) { - string[] aIDs = split[3].Split(','); + var aIDs = split[3].Split(','); - for (int i = 0; i < aIDs.Length; i++) + for (var i = 0; i < aIDs.Length; i++) { - int id = Utility.ToInt32(aIDs[i]); + var id = Utility.ToInt32(aIDs[i]); if (m_Table.ContainsKey(id)) Console.WriteLine(@"Warning: double ItemID entry in Data\containers.cfg"); @@ -1664,17 +1652,17 @@ namespace Server.Items DropSound = dropSound; } - public static ContainerData Default{ get; set; } + public static ContainerData Default { get; set; } - public int GumpID{ get; } + public int GumpID { get; } - public Rectangle2D Bounds{ get; } + public Rectangle2D Bounds { get; } - public int DropSound{ get; } + public int DropSound { get; } public static ContainerData GetData(int itemID) { - m_Table.TryGetValue(itemID, out ContainerData data); + m_Table.TryGetValue(itemID, out var data); return data ?? Default; } } diff --git a/Projects/Server/Items/Containers.cs b/Projects/Server/Items/Containers.cs index d98987e55..22d868e67 100644 --- a/Projects/Server/Items/Containers.cs +++ b/Projects/Server/Items/Containers.cs @@ -40,11 +40,11 @@ namespace Server.Items public override bool IsVirtualItem => true; - public Mobile Owner{ get; private set; } + public Mobile Owner { get; private set; } - public bool Opened{ get; private set; } + public bool Opened { get; private set; } - public static bool SendDeleteOnClose{ get; set; } + public static bool SendDeleteOnClose { get; set; } public void Open() { @@ -73,20 +73,20 @@ namespace Server.Items { base.Deserialize(reader); - int version = reader.ReadInt(); + var version = reader.ReadInt(); switch (version) { case 0: - { - Owner = reader.ReadMobile(); - Opened = reader.ReadBool(); + { + Owner = reader.ReadMobile(); + Opened = reader.ReadBool(); - if (Owner == null) - Delete(); + if (Owner == null) + Delete(); - break; - } + break; + } } if (ItemID == 0xE41) @@ -111,12 +111,14 @@ namespace Server.Items public override DeathMoveResult OnParentDeath(Mobile parent) => DeathMoveResult.RemainEquipped; - public override bool IsAccessibleTo(Mobile check) => (check == Owner && Opened || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check); + public override bool IsAccessibleTo(Mobile check) => + ((check == Owner && Opened) || check.AccessLevel >= AccessLevel.GameMaster) && base.IsAccessibleTo(check); - public override bool OnDragDrop(Mobile from, Item dropped) => (from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped); + public override bool OnDragDrop(Mobile from, Item dropped) => + ((from == Owner && Opened) || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDrop(from, dropped); public override bool OnDragDropInto(Mobile from, Item item, Point3D p) => - (from == Owner && Opened || from.AccessLevel >= AccessLevel.GameMaster) && + ((from == Owner && Opened) || from.AccessLevel >= AccessLevel.GameMaster) && base.OnDragDropInto(from, item, p); public override int GetTotal(TotalType type) diff --git a/Projects/Server/Items/SecureTradeContainer.cs b/Projects/Server/Items/SecureTradeContainer.cs index 770b80378..e373a6dc5 100644 --- a/Projects/Server/Items/SecureTradeContainer.cs +++ b/Projects/Server/Items/SecureTradeContainer.cs @@ -36,13 +36,13 @@ namespace Server.Items { } - public SecureTrade Trade{ get; } + public SecureTrade Trade { get; } public override bool CheckHold(Mobile m, Item item, bool message, bool checkItems, int plusItems, int plusWeight) { if (item == Trade.From.VirtualCheck || item == Trade.To.VirtualCheck) return true; - Mobile to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile; + var to = Trade.From.Container != this ? Trade.From.Mobile : Trade.To.Mobile; return m.CheckTrade(to, item, this, message, checkItems, plusItems, plusWeight); } @@ -53,7 +53,8 @@ namespace Server.Items return false; } - public override bool IsAccessibleTo(Mobile check) => IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check); + public override bool IsAccessibleTo(Mobile check) => + IsChildOf(check) && Trade?.Valid == true && base.IsAccessibleTo(check); public override void OnItemAdded(Item item) { @@ -109,7 +110,7 @@ namespace Server.Items { base.Deserialize(reader); - int version = reader.ReadInt(); + var version = reader.ReadInt(); } } } diff --git a/Projects/Server/Items/VirtualCheck.cs b/Projects/Server/Items/VirtualCheck.cs index 42ef6fcab..ae7f99946 100644 --- a/Projects/Server/Items/VirtualCheck.cs +++ b/Projects/Server/Items/VirtualCheck.cs @@ -1,16 +1,16 @@ using Server.Gumps; -using Server.Items; using Server.Network; -namespace Server +namespace Server.Items { public sealed class VirtualCheck : Item { + // TODO: Move to configuration public static bool UseEditGump = false; - private int _Gold; + private int m_Gold; - private int _Plat; + private int m_Plat; public VirtualCheck(int plat = 0, int gold = 0) : base(0x14F0) @@ -35,15 +35,15 @@ namespace Server public override string DefaultName => "Offer Of Currency"; - public EditGump Editor{ get; private set; } + public EditGump Editor { get; private set; } [CommandProperty(AccessLevel.Administrator)] public int Plat { - get => _Plat; + get => m_Plat; set { - _Plat = value; + m_Plat = value; InvalidateProperties(); } } @@ -51,17 +51,17 @@ namespace Server [CommandProperty(AccessLevel.Administrator)] public int Gold { - get => _Gold; + get => m_Gold; set { - _Gold = value; + m_Gold = value; InvalidateProperties(); } } public override bool IsAccessibleTo(Mobile check) { - SecureTradeContainer c = GetSecureTradeCont(); + var c = GetSecureTradeCont(); if (check == null || c == null) return base.IsAccessibleTo(check); @@ -108,7 +108,7 @@ namespace Server public void UpdateTrade(Mobile user) { - SecureTradeContainer c = GetSecureTradeCont(); + var c = GetSecureTradeCont(); if (c?.Trade == null) return; @@ -150,7 +150,7 @@ namespace Server AllGold } - private int _Plat, _Gold; + private int m_Plat, m_Gold; public EditGump(Mobile user, VirtualCheck check) : base(50, 50) @@ -158,8 +158,8 @@ namespace Server User = user; Check = check; - _Plat = Check.Plat; - _Gold = Check.Gold; + m_Plat = Check.Plat; + m_Gold = Check.Gold; Closable = true; Disposable = true; @@ -171,8 +171,8 @@ namespace Server CompileLayout(); } - public Mobile User{ get; } - public VirtualCheck Check{ get; private set; } + public Mobile User { get; } + public VirtualCheck Check { get; private set; } public override void OnServerClose(NetState owner) { @@ -232,7 +232,7 @@ namespace Server AddImage(10, 8, 113); AddImage(360, 8, 113); - string title = + var title = $"
BANK OF {User.RawName.ToUpper()}
"; AddHtml(40, 15, 320, 20, title); @@ -247,7 +247,7 @@ namespace Server AddBackground(210, 60, 175, 20, 9300); AddBackground(215, 45, 165, 30, 9350); - AddTextEntry(225, 50, 145, 20, 0, 0, _Plat.ToString(), User.Account.TotalPlat.ToString().Length); + AddTextEntry(225, 50, 145, 20, 0, 0, m_Plat.ToString(), User.Account.TotalPlat.ToString().Length); // Gold Row AddBackground(15, 100, 175, 20, 9300); @@ -259,7 +259,7 @@ namespace Server AddBackground(210, 100, 175, 20, 9300); AddBackground(215, 85, 165, 30, 9350); - AddTextEntry(225, 90, 145, 20, 0, 1, _Gold.ToString(), User.Account.TotalGold.ToString().Length); + AddTextEntry(225, 90, 145, 20, 0, 1, m_Gold.ToString(), User.Account.TotalGold.ToString().Length); // Buttons AddButton(20, 128, 12006, 12007, (int)Buttons.Close); @@ -282,58 +282,58 @@ namespace Server case Buttons.Close: break; case Buttons.Clear: - { - _Plat = _Gold = 0; - refresh = true; - } + { + m_Plat = m_Gold = 0; + refresh = true; + } break; case Buttons.Accept: - { - string platText = info.GetTextEntry(0).Text; - string goldText = info.GetTextEntry(1).Text; + { + var platText = info.GetTextEntry(0).Text; + var goldText = info.GetTextEntry(1).Text; - if (!int.TryParse(platText, out _Plat)) - { - User.SendMessage("That is not a valid amount of platinum."); - refresh = true; - } - else if (!int.TryParse(goldText, out _Gold)) - { - User.SendMessage("That is not a valid amount of gold."); - refresh = true; - } - else - { - int totalPlat = User.Account.TotalPlat; - int totalGold = User.Account.TotalGold; - - if (totalPlat < _Plat || totalGold < _Gold) + if (!int.TryParse(platText, out m_Plat)) { - _Plat = User.Account.TotalPlat; - _Gold = User.Account.TotalGold; - User.SendMessage("You do not have that much currency."); + User.SendMessage("That is not a valid amount of platinum."); + refresh = true; + } + else if (!int.TryParse(goldText, out m_Gold)) + { + User.SendMessage("That is not a valid amount of gold."); refresh = true; } else { - Check.Plat = _Plat; - Check.Gold = _Gold; - updated = true; + var totalPlat = User.Account.TotalPlat; + var totalGold = User.Account.TotalGold; + + if (totalPlat < m_Plat || totalGold < m_Gold) + { + m_Plat = User.Account.TotalPlat; + m_Gold = User.Account.TotalGold; + User.SendMessage("You do not have that much currency."); + refresh = true; + } + else + { + Check.Plat = m_Plat; + Check.Gold = m_Gold; + updated = true; + } } } - } break; case Buttons.AllPlat: - { - _Plat = User.Account.TotalPlat; - refresh = true; - } + { + m_Plat = User.Account.TotalPlat; + refresh = true; + } break; case Buttons.AllGold: - { - _Gold = User.Account.TotalGold; - refresh = true; - } + { + m_Gold = User.Account.TotalGold; + refresh = true; + } break; } diff --git a/Projects/Server/Items/VirtualHair.cs b/Projects/Server/Items/VirtualHair.cs index b3f8d1da7..61491f07f 100644 --- a/Projects/Server/Items/VirtualHair.cs +++ b/Projects/Server/Items/VirtualHair.cs @@ -32,28 +32,28 @@ namespace Server protected BaseHairInfo(IGenericReader reader) { - int version = reader.ReadInt(); + var version = reader.ReadInt(); switch (version) { case 0: - { - ItemID = reader.ReadInt(); - Hue = reader.ReadInt(); - break; - } + { + ItemID = reader.ReadInt(); + Hue = reader.ReadInt(); + break; + } } } [CommandProperty(AccessLevel.GameMaster)] - public int ItemID{ get; set; } + public int ItemID { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int Hue{ get; set; } + public int Hue { get; set; } public virtual void Serialize(IGenericWriter writer) { - writer.Write(0); //version + writer.Write(0); // version writer.Write(ItemID); writer.Write(Hue); } @@ -106,14 +106,14 @@ namespace Server public HairEquipUpdate(Mobile parent) : base(0x2E, 15) { - int hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.HairHue; + var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.HairHue; - m_Stream.Write(HairInfo.FakeSerial(parent)); - m_Stream.Write((short)parent.HairItemID); - m_Stream.Write((byte)0); - m_Stream.Write((byte)Layer.Hair); - m_Stream.Write(parent.Serial); - m_Stream.Write((short)hue); + Stream.Write(HairInfo.FakeSerial(parent)); + Stream.Write((short)parent.HairItemID); + Stream.Write((byte)0); + Stream.Write((byte)Layer.Hair); + Stream.Write(parent.Serial); + Stream.Write((short)hue); } } @@ -122,14 +122,14 @@ namespace Server public FacialHairEquipUpdate(Mobile parent) : base(0x2E, 15) { - int hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.FacialHairHue; + var hue = parent.SolidHueOverride >= 0 ? parent.SolidHueOverride : parent.FacialHairHue; - m_Stream.Write(FacialHairInfo.FakeSerial(parent)); - m_Stream.Write((short)parent.FacialHairItemID); - m_Stream.Write((byte)0); - m_Stream.Write((byte)Layer.FacialHair); - m_Stream.Write(parent.Serial); - m_Stream.Write((short)hue); + Stream.Write(FacialHairInfo.FakeSerial(parent)); + Stream.Write((short)parent.FacialHairItemID); + Stream.Write((byte)0); + Stream.Write((byte)Layer.FacialHair); + Stream.Write(parent.Serial); + Stream.Write((short)hue); } } @@ -138,7 +138,7 @@ namespace Server public RemoveHair(Mobile parent) : base(0x1D, 5) { - m_Stream.Write(HairInfo.FakeSerial(parent)); + Stream.Write(HairInfo.FakeSerial(parent)); } } @@ -147,7 +147,7 @@ namespace Server public RemoveFacialHair(Mobile parent) : base(0x1D, 5) { - m_Stream.Write(FacialHairInfo.FakeSerial(parent)); + Stream.Write(FacialHairInfo.FakeSerial(parent)); } } } diff --git a/Projects/Server/JsonConverters/Point3dConverter.cs b/Projects/Server/JsonConverters/Point3dConverter.cs index 744ae21dc..049cacf8a 100644 --- a/Projects/Server/JsonConverters/Point3dConverter.cs +++ b/Projects/Server/JsonConverters/Point3dConverter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; @@ -13,7 +12,7 @@ namespace Server.Json throw new JsonException("Point3d must be an array of x, y, z"); var data = new int[3]; - int count = 0; + var count = 0; while (true) { @@ -35,6 +34,7 @@ namespace Server.Json return new Point3D(data[0], data[1], data[2]); } + public override void Write(Utf8JsonWriter writer, Point3D value, JsonSerializerOptions options) { writer.WriteStartArray(); diff --git a/Projects/Server/KeywordList.cs b/Projects/Server/KeywordList.cs index a96e6d995..871e1e8e5 100644 --- a/Projects/Server/KeywordList.cs +++ b/Projects/Server/KeywordList.cs @@ -22,7 +22,7 @@ namespace Server { public class KeywordList { - private static readonly int[] m_EmptyInts = new int[0]; + private static readonly int[] m_EmptyInts = System.Array.Empty(); private int[] m_Keywords; public KeywordList() @@ -31,13 +31,13 @@ namespace Server Count = 0; } - public int Count{ get; private set; } + public int Count { get; private set; } public bool Contains(int keyword) { - bool contains = false; + var contains = false; - for (int i = 0; !contains && i < Count; ++i) + for (var i = 0; !contains && i < Count; ++i) contains = keyword == m_Keywords[i]; return contains; @@ -47,10 +47,10 @@ namespace Server { if (Count + 1 > m_Keywords.Length) { - int[] old = m_Keywords; + var old = m_Keywords; m_Keywords = new int[old.Length * 2]; - for (int i = 0; i < old.Length; ++i) + for (var i = 0; i < old.Length; ++i) m_Keywords[i] = old[i]; } @@ -62,9 +62,9 @@ namespace Server if (Count == 0) return m_EmptyInts; - int[] keywords = new int[Count]; + var keywords = new int[Count]; - for (int i = 0; i < Count; ++i) + for (var i = 0; i < Count; ++i) keywords[i] = m_Keywords[i]; Count = 0; @@ -72,4 +72,4 @@ namespace Server return keywords; } } -} \ No newline at end of file +} diff --git a/Projects/Server/Layer.cs b/Projects/Server/Layer.cs index 64652e22f..58c00f41d 100644 --- a/Projects/Server/Layer.cs +++ b/Projects/Server/Layer.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: Layer.cs - Created: 2019/03/15 - Updated: 2020/01/19 * * * diff --git a/Projects/Server/LightType.cs b/Projects/Server/LightType.cs index 298964cac..89596acc2 100644 --- a/Projects/Server/LightType.cs +++ b/Projects/Server/LightType.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: LightType.cs - Created: 2019/03/15 - Updated: 2020/01/19 * * * diff --git a/Projects/Server/Main.cs b/Projects/Server/Main.cs index e9328c0ba..296af60d9 100644 --- a/Projects/Server/Main.cs +++ b/Projects/Server/Main.cs @@ -64,12 +64,12 @@ namespace Server * enabling the usage of DateTime.UtcNow instead. */ - private static readonly bool _HighRes = Stopwatch.IsHighResolution; + private static readonly bool m_HighRes = Stopwatch.IsHighResolution; - private static readonly double _HighFrequency = 1000.0 / Stopwatch.Frequency; - private static readonly double _LowFrequency = 1000.0 / TimeSpan.TicksPerSecond; + private static readonly double m_HighFrequency = 1000.0 / Stopwatch.Frequency; + private static readonly double m_LowFrequency = 1000.0 / TimeSpan.TicksPerSecond; - private static bool _UseHRT; + private static bool m_UseHRT; public static readonly bool Is64Bit = Environment.Is64BitProcess; internal static ConsoleEventHandler m_ConsoleEventHandler; @@ -111,22 +111,22 @@ namespace Server } } - public static bool Service{ get; private set; } + public static bool Service { get; private set; } public static bool Debug { get; private set; } - internal static bool HaltOnWarning{ get; private set; } + internal static bool HaltOnWarning { get; private set; } - public static Assembly Assembly{ get; set; } + public static Assembly Assembly { get; set; } public static Version Version => Assembly.GetName().Version; - public static Process Process{ get; private set; } + public static Process Process { get; private set; } - public static Thread Thread{ get; private set; } + public static Thread Thread { get; private set; } - public static MultiTextWriter MultiConsoleOut{ get; private set; } + public static MultiTextWriter MultiConsoleOut { get; private set; } - public static bool UsingHighResolutionTiming => _UseHRT && _HighRes && !Unix; + public static bool UsingHighResolutionTiming => m_UseHRT && m_HighRes && !Unix; public static long TickCount => (long)Ticks; @@ -134,15 +134,15 @@ namespace Server { get { - if (_UseHRT && _HighRes && !Unix) return Stopwatch.GetTimestamp() * _HighFrequency; + if (m_UseHRT && m_HighRes && !Unix) return Stopwatch.GetTimestamp() * m_HighFrequency; - return DateTime.UtcNow.Ticks * _LowFrequency; + return DateTime.UtcNow.Ticks * m_LowFrequency; } } - public static bool MultiProcessor{ get; private set; } + public static bool MultiProcessor { get; private set; } - public static int ProcessorCount{ get; private set; } + public static int ProcessorCount { get; private set; } public static bool IsWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); public static bool IsDarwin = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); @@ -173,7 +173,7 @@ namespace Server } } - public static bool Closing{ get; private set; } + public static bool Closing { get; private set; } public static float CyclesPerSecond => m_CyclesPerSecond[(m_CycleIndex - 1) % m_CyclesPerSecond.Length]; @@ -183,7 +183,7 @@ namespace Server { get { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); if (Debug) Utility.Separate(sb, "-debug", " "); @@ -200,30 +200,30 @@ namespace Server if (HaltOnWarning) Utility.Separate(sb, "-haltonwarning", " "); - if (_UseHRT) + if (m_UseHRT) Utility.Separate(sb, "-usehrt", " "); return sb.ToString(); } } - public static int GlobalUpdateRange{ get; set; } = 18; + public static int GlobalUpdateRange { get; set; } = 18; - public static int GlobalMaxUpdateRange{ get; set; } = 24; + public static int GlobalMaxUpdateRange { get; set; } = 24; public static int ScriptItems => m_ItemCount; public static int ScriptMobiles => m_MobileCount; public static string FindDataFile(string path) { - Configuration config = Configuration.Instance; + var config = Configuration.Instance; if (config.DataDirectories.Count == 0) throw new InvalidOperationException( "Attempted to FindDataFile before DataDirectories list has been filled."); string fullPath = null; - foreach (string p in config.DataDirectories) + foreach (var p in config.DataDirectories) { fullPath = Path.Combine(p, path); @@ -247,11 +247,11 @@ namespace Server { m_Crashed = true; - bool close = false; + var close = false; try { - ServerCrashedEventArgs args = new ServerCrashedEventArgs(e.ExceptionObject as Exception); + var args = new ServerCrashedEventArgs(e.ExceptionObject as Exception); EventSink.InvokeServerCrashed(args); @@ -283,10 +283,10 @@ namespace Server private static bool OnConsoleEvent(ConsoleEventType type) { - if (World.Saving || Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT) + if (World.Saving || (Service && type == ConsoleEventType.CTRL_LOGOFF_EVENT)) return true; - Kill(); //Kill -> HandleClosed will handle waiting for the completion of flushing to disk + Kill(); // Kill -> HandleClosed will handle waiting for the completion of flushing to disk return true; } @@ -335,7 +335,7 @@ namespace Server AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; - foreach (string a in args) + foreach (var a in args) if (Insensitive.Equals(a, "-debug")) Debug = true; else if (Insensitive.Equals(a, "-service")) @@ -347,7 +347,7 @@ namespace Server else if (Insensitive.Equals(a, "-haltonwarning")) HaltOnWarning = true; else if (Insensitive.Equals(a, "-usehrt")) - _UseHRT = true; + m_UseHRT = true; try { @@ -378,32 +378,32 @@ namespace Server if (BaseDirectory.Length > 0) Directory.SetCurrentDirectory(BaseDirectory); - - Version ver = Assembly.GetName().Version; + var ver = Assembly.GetName().Version; Console.ForegroundColor = ConsoleColor.Green; // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not - Console.WriteLine("ModernUO - [https://github.com/kamronbatman/ModernUO] Version {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, + Console.WriteLine("ModernUO - [https://github.com/kamronbatman/ModernUO] Version {0}.{1}.{2}.{3}", ver.Major, + ver.Minor, ver.Build, ver.Revision); Console.WriteLine("Core: Running on {0}", RuntimeInformation.FrameworkDescription); Console.ResetColor(); Console.WriteLine(); - Configuration config = Configuration.Instance; - foreach (string dir in config.DataDirectories.Where(dir => !Directory.Exists(dir))) + var config = Configuration.Instance; + foreach (var dir in config.DataDirectories.Where(dir => !Directory.Exists(dir))) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Core: Config directory {0} does not exist.", dir); Console.ResetColor(); } - Timer.TimerThread ttObj = new Timer.TimerThread(); + var ttObj = new Timer.TimerThread(); timerThread = new Thread(ttObj.TimerMain) { Name = "Timer Thread" }; - string s = Arguments; + var s = Arguments; if (s.Length > 0) Console.WriteLine("Core: Running with arguments: {0}", s); @@ -426,7 +426,7 @@ namespace Server if (GCSettings.IsServerGC) Console.WriteLine("Core: Server garbage collection mode enabled"); - if (_UseHRT) + if (m_UseHRT) Console.WriteLine("Core: Requested high resolution timing ({0})", UsingHighResolutionTiming ? "Supported" : "Unsupported"); @@ -447,13 +447,13 @@ namespace Server timerThread.Start(); - foreach (Map m in Map.AllMaps) + foreach (var m in Map.AllMaps) m.Tiles.Force(); EventSink.InvokeServerStarted(); // Start net socket server - var host = TcpServer.CreateWebHostBuilder(new string[0]).Build(); + var host = TcpServer.CreateWebHostBuilder().Build(); var life = host.Services.GetRequiredService(); life.ApplicationStopping.Register(() => { Kill(); }); @@ -464,7 +464,7 @@ namespace Server { try { - long last = TickCount; + var last = TickCount; const int sampleInterval = 100; const float ticksPerSecond = 1000.0f * sampleInterval; @@ -477,8 +477,7 @@ namespace Server Task.WaitAll( Task.Run(Mobile.ProcessDeltaQueue), - Task.Run(Item.ProcessDeltaQueue) - ); + Task.Run(Item.ProcessDeltaQueue)); Timer.Slice(); messagePumpService.DoWork(); @@ -490,7 +489,7 @@ namespace Server if (sample++ % sampleInterval != 0) continue; - long now = TickCount; + var now = TickCount; m_CyclesPerSecond[m_CycleIndex++ % m_CyclesPerSecond.Length] = ticksPerSecond / (now - last); last = now; } @@ -506,16 +505,16 @@ namespace Server m_ItemCount = 0; m_MobileCount = 0; - Assembly ca = Assembly.GetCallingAssembly(); + var ca = Assembly.GetCallingAssembly(); VerifySerialization(ca); - foreach (Assembly a in AssemblyHandler.Assemblies.Where(a => a != ca)) VerifySerialization(a); + foreach (var a in AssemblyHandler.Assemblies.Where(a => a != ca)) VerifySerialization(a); } private static void VerifyType(Type t) { - bool isItem = t.IsSubclassOf(typeof(Item)); + var isItem = t.IsSubclassOf(typeof(Item)); if (!isItem && !t.IsSubclassOf(typeof(Mobile))) return; @@ -587,9 +586,7 @@ namespace Server internal static extern bool SetConsoleCtrlHandler(ConsoleEventHandler callback, bool add); } - #region Expansions - - public static Expansion Expansion{ get; set; } + public static Expansion Expansion { get; set; } public static bool T2A => Expansion >= Expansion.T2A; @@ -612,45 +609,43 @@ namespace Server public static bool TOL => Expansion >= Expansion.TOL; public static bool EJ => Expansion >= Expansion.EJ; - - #endregion } public class FileLogger : TextWriter { public const string DateFormat = "[MMMM dd hh:mm:ss.f tt]: "; - private bool _NewLine; + private bool m_NewLine; public FileLogger(string file, bool append = false) { FileName = file; using ( - StreamWriter writer = + var writer = new StreamWriter( new FileStream(FileName, append ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.Read))) { writer.WriteLine(">>>Logging started on {0}.", DateTime.UtcNow.ToString("f")); - //f = Tuesday, April 10, 2001 3:51 PM + // f = Tuesday, April 10, 2001 3:51 PM } - _NewLine = true; + m_NewLine = true; } - public string FileName{ get; } + public string FileName { get; } public override Encoding Encoding => Encoding.Default; public override void Write(char ch) { - using StreamWriter writer = + using var writer = new StreamWriter(new FileStream(FileName, FileMode.Append, FileAccess.Write, FileShare.Read)); - if (_NewLine) + if (m_NewLine) { writer.Write(DateTime.UtcNow.ToString(DateFormat)); - _NewLine = false; + m_NewLine = false; } writer.Write(ch); @@ -658,12 +653,12 @@ namespace Server public override void Write(string str) { - using StreamWriter writer = + using var writer = new StreamWriter(new FileStream(FileName, FileMode.Append, FileAccess.Write, FileShare.Read)); - if (_NewLine) + if (m_NewLine) { writer.Write(DateTime.UtcNow.ToString(DateFormat)); - _NewLine = false; + m_NewLine = false; } writer.Write(str); @@ -671,46 +666,46 @@ namespace Server public override void WriteLine(string line) { - using StreamWriter writer = + using var writer = new StreamWriter(new FileStream(FileName, FileMode.Append, FileAccess.Write, FileShare.Read)); - if (_NewLine) writer.Write(DateTime.UtcNow.ToString(DateFormat)); + if (m_NewLine) writer.Write(DateTime.UtcNow.ToString(DateFormat)); writer.WriteLine(line); - _NewLine = true; + m_NewLine = true; } } public class MultiTextWriter : TextWriter { - private readonly List _Streams; + private readonly List m_Streams; public MultiTextWriter(params TextWriter[] streams) { - _Streams = new List(streams); + m_Streams = new List(streams); - if (_Streams.Count < 0) throw new ArgumentException("You must specify at least one stream."); + if (m_Streams.Count < 0) throw new ArgumentException("You must specify at least one stream."); } public override Encoding Encoding => Encoding.Default; public void Add(TextWriter tw) { - _Streams.Add(tw); + m_Streams.Add(tw); } public void Remove(TextWriter tw) { - _Streams.Remove(tw); + m_Streams.Remove(tw); } public override void Write(char ch) { - foreach (TextWriter t in _Streams) t.Write(ch); + foreach (var t in m_Streams) t.Write(ch); } public override void WriteLine(string line) { - foreach (TextWriter t in _Streams) t.WriteLine(line); + foreach (var t in m_Streams) t.WriteLine(line); } public override void WriteLine(string line, params object[] args) diff --git a/Projects/Server/Map.cs b/Projects/Server/Map.cs index 4751ee7f2..f2ea98043 100644 --- a/Projects/Server/Map.cs +++ b/Projects/Server/Map.cs @@ -63,12 +63,12 @@ namespace Server MultiTileSelector = SelectMultiTiles; } - public static Selector ClientSelector{ get; set; } - public static Selector EntitySelector{ get; set; } - public static Selector MobileSelector{ get; set; } - public static Selector ItemSelector{ get; set; } - public static Selector MultiSelector{ get; set; } - public static Selector MultiTileSelector{ get; set; } + public static Selector ClientSelector { get; set; } + public static Selector EntitySelector { get; set; } + public static Selector MobileSelector { get; set; } + public static Selector ItemSelector { get; set; } + public static Selector MultiSelector { get; set; } + public static Selector MultiTileSelector { get; set; } public static IEnumerable SelectClients(Sector s, Rectangle2D bounds) { @@ -79,7 +79,7 @@ namespace Server public static IEnumerable SelectEntities(Sector s, bool items, bool mobiles, Rectangle2D bounds) { - IEnumerable eable = Enumerable.Empty(); + var eable = Enumerable.Empty(); if (mobiles) eable = eable.Union(s.Mobiles.Where(o => o?.Deleted == false)); if (items) @@ -106,9 +106,9 @@ namespace Server public static IEnumerable SelectMultiTiles(Sector s, Rectangle2D bounds) { - foreach (BaseMulti o in s.Multis.Where(o => o?.Deleted == false)) + foreach (var o in s.Multis.Where(o => o?.Deleted == false)) { - MultiComponentList c = o.Components; + var c = o.Components; int x, y, xo, yo; StaticTile[] t, r; @@ -131,7 +131,7 @@ namespace Server r = new StaticTile[t.Length]; - for (int i = 0; i < t.Length; i++) + for (var i = 0; i < t.Length; i++) { r[i] = t[i]; r[i].Z += o.Z; @@ -143,36 +143,42 @@ namespace Server } } - public static Map.PooledEnumerable GetClients(Map map, Rectangle2D bounds) => Map.PooledEnumerable.Instantiate(map, bounds, ClientSelector ?? SelectClients); + public static Map.PooledEnumerable GetClients(Map map, Rectangle2D bounds) => + Map.PooledEnumerable.Instantiate(map, bounds, ClientSelector ?? SelectClients); - public static Map.PooledEnumerable GetEntities(Map map, Rectangle2D bounds, bool items = true, bool mobiles = true) => Map.PooledEnumerable.Instantiate(map, bounds, EntitySelector ?? SelectEntities); + public static Map.PooledEnumerable GetEntities(Map map, Rectangle2D bounds, bool items = true, + bool mobiles = true) => Map.PooledEnumerable.Instantiate(map, bounds, EntitySelector ?? SelectEntities); public static Map.PooledEnumerable GetMobiles(Map map, Rectangle2D bounds) => GetMobiles(map, bounds); - public static Map.PooledEnumerable GetMobiles(Map map, Rectangle2D bounds) where T : Mobile => Map.PooledEnumerable.Instantiate(map, bounds, SelectMobiles); + public static Map.PooledEnumerable GetMobiles(Map map, Rectangle2D bounds) where T : Mobile => + Map.PooledEnumerable.Instantiate(map, bounds, SelectMobiles); - public static Map.PooledEnumerable GetItems(Map map, Rectangle2D bounds) where T : Item => Map.PooledEnumerable.Instantiate(map, bounds, SelectItems); + public static Map.PooledEnumerable GetItems(Map map, Rectangle2D bounds) where T : Item => + Map.PooledEnumerable.Instantiate(map, bounds, SelectItems); - public static Map.PooledEnumerable GetMultis(Map map, Rectangle2D bounds) => Map.PooledEnumerable.Instantiate(map, bounds, MultiSelector ?? SelectMultis); + public static Map.PooledEnumerable GetMultis(Map map, Rectangle2D bounds) => + Map.PooledEnumerable.Instantiate(map, bounds, MultiSelector ?? SelectMultis); - public static Map.PooledEnumerable GetMultiTiles(Map map, Rectangle2D bounds) => Map.PooledEnumerable.Instantiate(map, bounds, MultiTileSelector ?? SelectMultiTiles); + public static Map.PooledEnumerable GetMultiTiles(Map map, Rectangle2D bounds) => + Map.PooledEnumerable.Instantiate(map, bounds, MultiTileSelector ?? SelectMultiTiles); public static IEnumerable EnumerateSectors(Map map, Rectangle2D bounds) { if (map == null || map == Map.Internal) yield break; - int x1 = bounds.Start.X; - int y1 = bounds.Start.Y; - int x2 = bounds.End.X; - int y2 = bounds.End.Y; + var x1 = bounds.Start.X; + var y1 = bounds.Start.Y; + var x2 = bounds.End.X; + var y2 = bounds.End.Y; - if (!Bound(map, ref x1, ref y1, ref x2, ref y2, out int xSector, out int ySector)) + if (!Bound(map, ref x1, ref y1, ref x2, ref y2, out var xSector, out var ySector)) yield break; - int index = 0; + var index = 0; - while (NextSector(map, x1, y1, x2, y2, ref index, ref xSector, ref ySector, out Sector s)) + while (NextSector(map, x1, y1, x2, y2, ref index, ref xSector, ref ySector, out var s)) yield return s; } @@ -250,16 +256,16 @@ namespace Server } [Parsable] - //[CustomEnum( new string[]{ "Felucca", "Trammel", "Ilshenar", "Malas", "Internal" } )] + // [CustomEnum( new string[]{ "Felucca", "Trammel", "Ilshenar", "Malas", "Internal" } )] public sealed class Map : IComparable { public const int SectorSize = 16; public const int SectorShift = 4; - public static int SectorActiveRange = 2; + public static readonly int SectorActiveRange = 2; - private static readonly Queue> _FixPool = new Queue>(128); + private static readonly Queue> m_FixPool = new Queue>(128); - private static readonly List _EmptyFixItems = new List(); + private static readonly List m_EmptyFixItems = new List(); private Region m_DefaultRegion; private readonly int m_FileIndex; @@ -291,7 +297,7 @@ namespace Server m_Sectors = new Sector[m_SectorsWidth][]; } - public static Map[] Maps{ get; } = new Map[0x100]; + public static Map[] Maps { get; } = new Map[0x100]; public static Map Felucca => Maps[0]; public static Map Trammel => Maps[1]; @@ -301,9 +307,9 @@ namespace Server public static Map TerMur => Maps[5]; public static Map Internal => Maps[0x7F]; - public static List AllMaps{ get; } = new List(); + public static List AllMaps { get; } = new List(); - public int Season{ get; set; } + public int Season { get; set; } public TileMatrix Tiles { @@ -319,26 +325,25 @@ namespace Server } } - public int MapID{ get; } + public int MapID { get; } - public int MapIndex{ get; } + public int MapIndex { get; } - public int Width{ get; } + public int Width { get; } - public int Height{ get; } + public int Height { get; } - public Dictionary Regions{ get; } + public Dictionary Regions { get; } public Region DefaultRegion { - get => m_DefaultRegion ?? - (m_DefaultRegion = new Region(null, this, 0, new Rectangle3D[0])); + get => m_DefaultRegion ??= new Region(null, this, 0, Array.Empty()); set => m_DefaultRegion = value; } - public MapRules Rules{ get; set; } + public MapRules Rules { get; set; } - public Sector InvalidSector{ get; } + public Sector InvalidSector { get; } public string Name { @@ -366,7 +371,7 @@ namespace Server } } - public static int[] InvalidLandTiles{ get; set; } = { 0x244 }; + public static int[] InvalidLandTiles { get; set; } = { 0x244 }; public int CompareTo(Map other) => other == null ? -1 : MapID.CompareTo(other.MapID); @@ -388,7 +393,7 @@ namespace Server if (Insensitive.Equals(value, "Internal")) return Internal; - if (!int.TryParse(value, out int index)) + if (!int.TryParse(value, out var index)) return Maps.FirstOrDefault(m => m != null && Insensitive.Equals(m.Name, value)); return index == 127 ? Internal : Maps.FirstOrDefault(m => m?.MapIndex == index); @@ -407,10 +412,10 @@ namespace Server public void GetAverageZ(int x, int y, ref int z, ref int avg, ref int top) { - int zTop = Tiles.GetLandTile(x, y).Z; - int zLeft = Tiles.GetLandTile(x, y + 1).Z; - int zRight = Tiles.GetLandTile(x + 1, y).Z; - int zBottom = Tiles.GetLandTile(x + 1, y + 1).Z; + var zTop = Tiles.GetLandTile(x, y).Z; + var zLeft = Tiles.GetLandTile(x, y + 1).Z; + var zRight = Tiles.GetLandTile(x + 1, y).Z; + var zBottom = Tiles.GetLandTile(x + 1, y + 1).Z; z = zTop; if (zLeft < z) @@ -428,13 +433,12 @@ namespace Server if (zBottom > top) top = zBottom; - avg = Math.Abs(zTop - zBottom) > Math.Abs(zLeft - zRight) ? - FloorAverage(zLeft, zRight) : FloorAverage(zTop, zBottom); + avg = Math.Abs(zTop - zBottom) > Math.Abs(zLeft - zRight) ? FloorAverage(zLeft, zRight) : FloorAverage(zTop, zBottom); } private static int FloorAverage(int a, int b) { - int v = a + b; + var v = a + b; if (v < 0) --v; @@ -442,24 +446,25 @@ namespace Server return v / 2; } - public IPooledEnumerable GetMultiTilesAt(int x, int y) => PooledEnumeration.GetMultiTiles(this, new Rectangle2D(x, y, 1, 1)); + public IPooledEnumerable GetMultiTilesAt(int x, int y) => + PooledEnumeration.GetMultiTiles(this, new Rectangle2D(x, y, 1, 1)); private static List AcquireFixItems(Map map, int x, int y) { if (map == null || map == Internal || x < 0 || x > map.Width || y < 0 || y > map.Height) - return _EmptyFixItems; + return m_EmptyFixItems; List pool = null; - lock (_FixPool) + lock (m_FixPool) { - if (_FixPool.Count > 0) - pool = _FixPool.Dequeue(); + if (m_FixPool.Count > 0) + pool = m_FixPool.Dequeue(); } pool ??= new List(128); // Arbitrary limit - IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, 0), 0); + var eable = map.GetItemsInRange(new Point3D(x, y, 0), 0); pool.AddRange( eable.Where(item => item.ItemID <= TileData.MaxItemValue && !(item is BaseMulti)) @@ -473,47 +478,47 @@ namespace Server private static void FreeFixItems(List pool) { - if (pool == _EmptyFixItems) + if (pool == m_EmptyFixItems) return; pool.Clear(); - lock (_FixPool) + lock (m_FixPool) { - if (_FixPool.Count < 128) - _FixPool.Enqueue(pool); + if (m_FixPool.Count < 128) + m_FixPool.Enqueue(pool); } } public void FixColumn(int x, int y) { - LandTile landTile = Tiles.GetLandTile(x, y); - StaticTile[] tiles = Tiles.GetStaticTiles(x, y, true); + var landTile = Tiles.GetLandTile(x, y); + var tiles = Tiles.GetStaticTiles(x, y, true); int landZ = 0, landAvg = 0, landTop = 0; GetAverageZ(x, y, ref landZ, ref landAvg, ref landTop); - List items = AcquireFixItems(this, x, y); + var items = AcquireFixItems(this, x, y); - for (int i = 0; i < items.Count; i++) + for (var i = 0; i < items.Count; i++) { - Item toFix = items[i]; + var toFix = items[i]; if (!toFix.Movable) continue; - int z = int.MinValue; - int currentZ = toFix.Z; + var z = int.MinValue; + var currentZ = toFix.Z; if (!landTile.Ignored && landAvg <= currentZ) z = landAvg; - foreach (StaticTile tile in tiles) + foreach (var tile in tiles) { - ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; + var id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; - int checkZ = tile.Z; - int checkTop = checkZ + id.CalcHeight; + var checkZ = tile.Z; + var checkTop = checkZ + id.CalcHeight; if (checkTop == checkZ && !id.Surface) ++checkTop; @@ -522,16 +527,16 @@ namespace Server z = checkTop; } - for (int j = 0; j < items.Count; ++j) + for (var j = 0; j < items.Count; ++j) { if (j == i) continue; - Item item = items[j]; - ItemData id = item.ItemData; + var item = items[j]; + var id = item.ItemData; - int checkZ = item.Z; - int checkTop = checkZ + id.CalcHeight; + var checkZ = item.Z; + var checkTop = checkZ + id.CalcHeight; if (checkTop == checkZ && !id.Surface) ++checkTop; @@ -552,21 +557,21 @@ namespace Server { List list = new List(); - if ( this == Internal ) + if (this == Internal) return list; - if ( land ) + if (land) list.Add( Tiles.GetLandTile( p.m_X, p.m_Y ) ); - if ( statics ) + if (statics) list.AddRange( Tiles.GetStaticTiles( p.m_X, p.m_Y, true ) ); - if ( items ) + if (items) { Sector sector = GetSector( p ); foreach ( Item item in sector.Items ) - if ( item.AtWorldPoint( p.m_X, p.m_Y ) ) + if (item.AtWorldPoint( p.m_X, p.m_Y )) list.Add( new StaticTile( (ushort)item.ItemID, (sbyte) item.Z ) ); } @@ -585,14 +590,13 @@ namespace Server return null; object surface = null; - int surfaceZ = int.MinValue; + var surfaceZ = int.MinValue; - - LandTile lt = Tiles.GetLandTile(p.X, p.Y); + var lt = Tiles.GetLandTile(p.X, p.Y); if (!lt.Ignored) { - int avgZ = GetAverageZ(p.X, p.Y); + var avgZ = GetAverageZ(p.X, p.Y); if (avgZ <= p.Z) { @@ -604,16 +608,16 @@ namespace Server } } - StaticTile[] staticTiles = Tiles.GetStaticTiles(p.X, p.Y, true); + var staticTiles = Tiles.GetStaticTiles(p.X, p.Y, true); - for (int i = 0; i < staticTiles.Length; i++) + for (var i = 0; i < staticTiles.Length; i++) { - StaticTile tile = staticTiles[i]; - ItemData id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; + var tile = staticTiles[i]; + var id = TileData.ItemTable[tile.ID & TileData.MaxItemValue]; if (id.Surface || (id.Flags & TileFlag.Wet) != 0) { - int tileZ = tile.Z + id.CalcHeight; + var tileZ = tile.Z + id.CalcHeight; if (tileZ > surfaceZ && tileZ <= p.Z) { @@ -626,20 +630,20 @@ namespace Server } } - Sector sector = GetSector(p.X, p.Y); + var sector = GetSector(p.X, p.Y); - for (int i = 0; i < sector.Items.Count; i++) + for (var i = 0; i < sector.Items.Count; i++) { - Item item = sector.Items[i]; + var item = sector.Items[i]; if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(p.X, p.Y) && !item.Movable) { - ItemData id = item.ItemData; + var id = item.ItemData; if (id.Surface || (id.Flags & TileFlag.Wet) != 0) { - int itemZ = item.Z + id.CalcHeight; + var itemZ = item.Z + id.CalcHeight; if (itemZ > surfaceZ && itemZ <= p.Z) { @@ -692,35 +696,35 @@ namespace Server public void ActivateSectors(int cx, int cy) { - for (int x = cx - SectorActiveRange; x <= cx + SectorActiveRange; ++x) - for (int y = cy - SectorActiveRange; y <= cy + SectorActiveRange; ++y) - { - Sector sect = GetRealSector(x, y); - if (sect != InvalidSector) - sect.Activate(); - } + for (var x = cx - SectorActiveRange; x <= cx + SectorActiveRange; ++x) + for (var y = cy - SectorActiveRange; y <= cy + SectorActiveRange; ++y) + { + var sect = GetRealSector(x, y); + if (sect != InvalidSector) + sect.Activate(); + } } public void DeactivateSectors(int cx, int cy) { - for (int x = cx - SectorActiveRange; x <= cx + SectorActiveRange; ++x) - for (int y = cy - SectorActiveRange; y <= cy + SectorActiveRange; ++y) - { - Sector sect = GetRealSector(x, y); - if (sect != InvalidSector && !PlayersInRange(sect, SectorActiveRange)) - sect.Deactivate(); - } + for (var x = cx - SectorActiveRange; x <= cx + SectorActiveRange; ++x) + for (var y = cy - SectorActiveRange; y <= cy + SectorActiveRange; ++y) + { + var sect = GetRealSector(x, y); + if (sect != InvalidSector && !PlayersInRange(sect, SectorActiveRange)) + sect.Deactivate(); + } } private bool PlayersInRange(Sector sect, int range) { - for (int x = sect.X - range; x <= sect.X + range; ++x) - for (int y = sect.Y - range; y <= sect.Y + range; ++y) - { - Sector check = GetRealSector(x, y); - if (check != InvalidSector && check.Players.Count > 0) - return true; - } + for (var x = sect.X - range; x <= sect.X + range; ++x) + for (var y = sect.Y - range; y <= sect.Y + range; ++y) + { + var check = GetRealSector(x, y); + if (check != InvalidSector && check.Players.Count > 0) + return true; + } return false; } @@ -746,10 +750,10 @@ namespace Server if (item is BaseMulti m) { - MultiComponentList mcl = m.Components; + var mcl = m.Components; - Sector start = GetMultiMinSector(m.Location, mcl); - Sector end = GetMultiMaxSector(m.Location, mcl); + var start = GetMultiMinSector(m.Location, mcl); + var end = GetMultiMaxSector(m.Location, mcl); AddMulti(m, start, end); } @@ -770,10 +774,10 @@ namespace Server if (item is BaseMulti m) { - MultiComponentList mcl = m.Components; + var mcl = m.Components; - Sector start = GetMultiMinSector(m.Location, mcl); - Sector end = GetMultiMaxSector(m.Location, mcl); + var start = GetMultiMinSector(m.Location, mcl); + var end = GetMultiMaxSector(m.Location, mcl); RemoveMulti(m, start, end); } @@ -784,9 +788,9 @@ namespace Server if (this == Internal) return; - for (int x = start.X; x <= end.X; ++x) - for (int y = start.Y; y <= end.Y; ++y) - InternalGetSector(x, y).OnMultiLeave(m); + for (var x = start.X; x <= end.X; ++x) + for (var y = start.Y; y <= end.Y; ++y) + InternalGetSector(x, y).OnMultiLeave(m); } public void AddMulti(BaseMulti m, Sector start, Sector end) @@ -794,22 +798,24 @@ namespace Server if (this == Internal) return; - for (int x = start.X; x <= end.X; ++x) - for (int y = start.Y; y <= end.Y; ++y) - InternalGetSector(x, y).OnMultiEnter(m); + for (var x = start.X; x <= end.X; ++x) + for (var y = start.Y; y <= end.Y; ++y) + InternalGetSector(x, y).OnMultiEnter(m); } - public Sector GetMultiMinSector(Point3D loc, MultiComponentList mcl) => GetSector(Bound(new Point2D(loc.m_X + mcl.Min.m_X, loc.m_Y + mcl.Min.m_Y))); + public Sector GetMultiMinSector(Point3D loc, MultiComponentList mcl) => + GetSector(Bound(new Point2D(loc.m_X + mcl.Min.m_X, loc.m_Y + mcl.Min.m_Y))); - public Sector GetMultiMaxSector(Point3D loc, MultiComponentList mcl) => GetSector(Bound(new Point2D(loc.m_X + mcl.Max.m_X, loc.m_Y + mcl.Max.m_Y))); + public Sector GetMultiMaxSector(Point3D loc, MultiComponentList mcl) => + GetSector(Bound(new Point2D(loc.m_X + mcl.Max.m_X, loc.m_Y + mcl.Max.m_Y))); public void OnMove(Point3D oldLocation, Mobile m) { if (this == Internal) return; - Sector oldSector = GetSector(oldLocation); - Sector newSector = GetSector(m.Location); + var oldSector = GetSector(oldLocation); + var newSector = GetSector(m.Location); if (oldSector != newSector) { @@ -823,8 +829,8 @@ namespace Server if (this == Internal) return; - Sector oldSector = GetSector(oldLocation); - Sector newSector = GetSector(item.Location); + var oldSector = GetSector(oldLocation); + var newSector = GetSector(item.Location); if (oldSector != newSector) { @@ -834,13 +840,13 @@ namespace Server if (item is BaseMulti m) { - MultiComponentList mcl = m.Components; + var mcl = m.Components; - Sector start = GetMultiMinSector(m.Location, mcl); - Sector end = GetMultiMaxSector(m.Location, mcl); + var start = GetMultiMinSector(m.Location, mcl); + var end = GetMultiMaxSector(m.Location, mcl); - Sector oldStart = GetMultiMinSector(oldLocation, mcl); - Sector oldEnd = GetMultiMaxSector(oldLocation, mcl); + var oldStart = GetMultiMinSector(oldLocation, mcl); + var oldEnd = GetMultiMaxSector(oldLocation, mcl); if (oldStart != start || oldEnd != end) { @@ -852,7 +858,7 @@ namespace Server public void RegisterRegion(Region reg) { - string regName = reg.Name; + var regName = reg.Name; if (regName == null) return; @@ -865,7 +871,7 @@ namespace Server public void UnregisterRegion(Region reg) { - string regName = reg.Name; + var regName = reg.Name; if (regName != null) Regions.Remove(regName); @@ -878,7 +884,7 @@ namespace Server if (o is Mobile mobile) { p = mobile.Location; - p.Z += 14; //eye ? 15 : 10; + p.Z += 14; // eye ? 15 : 10; } else if (o is Item item) { @@ -900,7 +906,7 @@ namespace Server } else if (o is StaticTarget st) { - ItemData id = TileData.ItemTable[st.ItemID & TileData.MaxItemValue]; + var id = TileData.ItemTable[st.ItemID & TileData.MaxItemValue]; p = new Point3D(st.X, st.Y, st.Z - id.CalcHeight + id.Height / 2 + 1); } @@ -921,13 +927,13 @@ namespace Server { public static readonly NullEnumerable Instance = new NullEnumerable(); - private readonly IEnumerable _Empty; + private readonly IEnumerable m_Empty; - private NullEnumerable() => _Empty = Enumerable.Empty(); + private NullEnumerable() => m_Empty = Enumerable.Empty(); - IEnumerator IEnumerable.GetEnumerator() => _Empty.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => m_Empty.GetEnumerator(); - public IEnumerator GetEnumerator() => _Empty.GetEnumerator(); + public IEnumerator GetEnumerator() => m_Empty.GetEnumerator(); public void Free() { @@ -938,35 +944,35 @@ namespace Server { private static readonly Queue> _Buffer = new Queue>(0x400); - private bool _IsDisposed; + private bool m_IsDisposed; - private List _Pool = new List(0x40); + private List m_Pool = new List(0x40); public PooledEnumerable(IEnumerable pool) { - _Pool.AddRange(pool); + m_Pool.AddRange(pool); } public void Dispose() { - _IsDisposed = true; + m_IsDisposed = true; - _Pool.Clear(); - _Pool.TrimExcess(); - _Pool = null; + m_Pool.Clear(); + m_Pool.TrimExcess(); + m_Pool = null; } - IEnumerator IEnumerable.GetEnumerator() => _Pool.GetEnumerator(); + IEnumerator IEnumerable.GetEnumerator() => m_Pool.GetEnumerator(); - public IEnumerator GetEnumerator() => _Pool.GetEnumerator(); + public IEnumerator GetEnumerator() => m_Pool.GetEnumerator(); public void Free() { - if (_IsDisposed) + if (m_IsDisposed) return; - _Pool.Clear(); - _Pool.Capacity = Math.Max(_Pool.Capacity, 0x100); + m_Pool.Clear(); + m_Pool.Capacity = Math.Max(m_Pool.Capacity, 0x100); lock (((ICollection)_Buffer).SyncRoot) { @@ -974,6 +980,7 @@ namespace Server } } +#pragma warning disable CA1000 // Do not declare static members on generic types public static PooledEnumerable Instantiate(Map map, Rectangle2D bounds, PooledEnumeration.Selector selector) { PooledEnumerable e = null; @@ -984,18 +991,16 @@ namespace Server e = _Buffer.Dequeue(); } - IEnumerable pool = PooledEnumeration.EnumerateSectors(map, bounds).SelectMany(s => selector(s, bounds)); + var pool = PooledEnumeration.EnumerateSectors(map, bounds).SelectMany(s => selector(s, bounds)); if (e == null) return new PooledEnumerable(pool); - e._Pool.AddRange(pool); + e.m_Pool.AddRange(pool); return e; - } } - - #region Get*InRange/Bounds +#pragma warning restore CA1000 // Do not declare static members on generic types public IPooledEnumerable GetObjectsInRange(Point3D p) => GetObjectsInRange(p, Core.GlobalMaxUpdateRange); @@ -1003,11 +1008,13 @@ namespace Server GetObjectsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1), items, mobiles); - public IPooledEnumerable GetObjectsInBounds(Rectangle2D bounds, bool items = true, bool mobiles = true) => PooledEnumeration.GetEntities(this, bounds, items, mobiles); + public IPooledEnumerable GetObjectsInBounds(Rectangle2D bounds, bool items = true, bool mobiles = true) => + PooledEnumeration.GetEntities(this, bounds, items, mobiles); public IPooledEnumerable GetClientsInRange(Point3D p) => GetClientsInRange(p, Core.GlobalMaxUpdateRange); - public IPooledEnumerable GetClientsInRange(Point3D p, int range) => GetClientsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); + public IPooledEnumerable GetClientsInRange(Point3D p, int range) => + GetClientsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); public IPooledEnumerable GetClientsInBounds(Rectangle2D bounds) => PooledEnumeration.GetClients(this, bounds); @@ -1015,25 +1022,25 @@ namespace Server public IPooledEnumerable GetItemsInRange(Point3D p, int range) => GetItemsInRange(p, range); - public IPooledEnumerable GetItemsInRange(Point3D p, int range) where T : Item => GetItemsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); + public IPooledEnumerable GetItemsInRange(Point3D p, int range) where T : Item => + GetItemsInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); public IPooledEnumerable GetItemsInBounds(Rectangle2D bounds) => GetItemsInBounds(bounds); - public IPooledEnumerable GetItemsInBounds(Rectangle2D bounds) where T : Item => PooledEnumeration.GetItems(this, bounds); + public IPooledEnumerable GetItemsInBounds(Rectangle2D bounds) where T : Item => + PooledEnumeration.GetItems(this, bounds); public IPooledEnumerable GetMobilesInRange(Point3D p) => GetMobilesInRange(p, Core.GlobalMaxUpdateRange); public IPooledEnumerable GetMobilesInRange(Point3D p, int range) => GetMobilesInRange(p, range); - public IPooledEnumerable GetMobilesInRange(Point3D p, int range) where T : Mobile => GetMobilesInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); + public IPooledEnumerable GetMobilesInRange(Point3D p, int range) where T : Mobile => + GetMobilesInBounds(new Rectangle2D(p.m_X - range, p.m_Y - range, range * 2 + 1, range * 2 + 1)); public IPooledEnumerable GetMobilesInBounds(Rectangle2D bounds) => GetMobilesInBounds(bounds); - public IPooledEnumerable GetMobilesInBounds(Rectangle2D bounds) where T : Mobile => PooledEnumeration.GetMobiles(this, bounds); - - #endregion - - #region CanFit + public IPooledEnumerable GetMobilesInBounds(Rectangle2D bounds) where T : Mobile => + PooledEnumeration.GetMobiles(this, bounds); public bool CanFit(Point3D p, int height, bool checkBlocksFit = false, bool checkMobiles = true, bool requireSurface = true) => @@ -1052,13 +1059,13 @@ namespace Server if (x < 0 || y < 0 || x >= Width || y >= Height) return false; - bool hasSurface = false; + var hasSurface = false; - LandTile lt = Tiles.GetLandTile(x, y); + var lt = Tiles.GetLandTile(x, y); int lowZ = 0, avgZ = 0, topZ = 0; GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ); - TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags; + var landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags; if ((landFlags & TileFlag.Impassable) != 0 && avgZ > z && z + height > lowZ) return false; @@ -1066,13 +1073,13 @@ namespace Server if ((landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored) hasSurface = true; - StaticTile[] staticTiles = Tiles.GetStaticTiles(x, y, true); + var staticTiles = Tiles.GetStaticTiles(x, y, true); bool surface, impassable; - for (int i = 0; i < staticTiles.Length; ++i) + for (var i = 0; i < staticTiles.Length; ++i) { - ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue]; + var id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue]; surface = id.Surface; impassable = id.Impassable; @@ -1083,21 +1090,21 @@ namespace Server hasSurface = true; } - Sector sector = GetSector(x, y); - List items = sector.Items; - List mobs = sector.Mobiles; + var sector = GetSector(x, y); + var items = sector.Items; + var mobs = sector.Mobiles; - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) { - Item item = items[i]; + var item = items[i]; if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y)) { - ItemData id = item.ItemData; + var id = item.ItemData; surface = id.Surface; impassable = id.Impassable; - if ((surface || impassable || checkBlocksFit && item.BlocksFit) && item.Z + id.CalcHeight > z && + if ((surface || impassable || (checkBlocksFit && item.BlocksFit)) && item.Z + id.CalcHeight > z && z + height > item.Z) return false; @@ -1107,9 +1114,9 @@ namespace Server } if (checkMobiles) - for (int i = 0; i < mobs.Count; ++i) + for (var i = 0; i < mobs.Count; ++i) { - Mobile m = mobs[i]; + var m = mobs[i]; if (m.Location.m_X == x && m.Location.m_Y == y && (m.AccessLevel == AccessLevel.Player || !m.Hidden) && m.Z + 16 > z && z + height > m.Z) @@ -1119,10 +1126,6 @@ namespace Server return !requireSurface || hasSurface; } - #endregion - - #region CanSpawnMobile - public bool CanSpawnMobile(Point3D p) => CanSpawnMobile(p.m_X, p.m_Y, p.m_Z); public bool CanSpawnMobile(Point2D p, int z) => CanSpawnMobile(p.m_X, p.m_Y, z); @@ -1135,10 +1138,6 @@ namespace Server return CanFit(x, y, z, 16); } - #endregion - - #region GetSector - public Sector GetSector(Point3D p) => InternalGetSector(p.m_X >> SectorShift, p.m_Y >> SectorShift); public Sector GetSector(Point2D p) => InternalGetSector(p.m_X >> SectorShift, p.m_Y >> SectorShift); @@ -1153,12 +1152,12 @@ namespace Server { if (x >= 0 && x < m_SectorsWidth && y >= 0 && y < m_SectorsHeight) { - Sector[] xSectors = m_Sectors[x]; + var xSectors = m_Sectors[x]; if (xSectors == null) m_Sectors[x] = xSectors = new Sector[m_SectorsHeight]; - Sector sec = xSectors[y]; + var sec = xSectors[y]; if (sec == null) xSectors[y] = sec = new Sector(x, y, this); @@ -1169,11 +1168,7 @@ namespace Server return InvalidSector; } - #endregion - - #region Line Of Sight - - public static int MaxLOSDistance{ get; set; } = 25; + public static int MaxLOSDistance { get; set; } = 25; public bool LineOfSight(Point3D org, Point3D dest) { @@ -1183,18 +1178,18 @@ namespace Server if (!Utility.InRange(org, dest, MaxLOSDistance)) return false; - Point3D end = dest; + var end = dest; - if (org.X > dest.X || org.X == dest.X && org.Y > dest.Y || org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z) + if (org.X > dest.X || (org.X == dest.X && org.Y > dest.Y) || (org.X == dest.X && org.Y == dest.Y && org.Z > dest.Z)) { - Point3D swap = org; + var swap = org; org = dest; dest = swap; } int height; Point3D p; - Point3DList path = new Point3DList(); + var path = new Point3DList(); TileFlag flags; if (org == dest) @@ -1203,14 +1198,14 @@ namespace Server if (path.Count > 0) path.Clear(); - int xd = dest.m_X - org.m_X; - int yd = dest.m_Y - org.m_Y; - int zd = dest.m_Z - org.m_Z; - double zslp = Math.Sqrt(xd * xd + yd * yd); - double sq3d = zd != 0 ? Math.Sqrt(zslp * zslp + zd * zd) : zslp; + var xd = dest.m_X - org.m_X; + var yd = dest.m_Y - org.m_Y; + var zd = dest.m_Z - org.m_Z; + var zslp = Math.Sqrt(xd * xd + yd * yd); + var sq3d = zd != 0 ? Math.Sqrt(zslp * zslp + zd * zd) : zslp; - double rise = yd / sq3d; - double run = xd / sq3d; + var rise = yd / sq3d; + var run = xd / sq3d; zslp = zd / sq3d; double y = org.m_Y; @@ -1219,9 +1214,9 @@ namespace Server while (Utility.NumberBetween(x, dest.m_X, org.m_X, 0.5) && Utility.NumberBetween(y, dest.m_Y, org.m_Y, 0.5) && Utility.NumberBetween(z, dest.m_Z, org.m_Z, 0.5)) { - int ix = (int)Math.Round(x); - int iy = (int)Math.Round(y); - int iz = (int)Math.Round(z); + var ix = (int)Math.Round(x); + var iy = (int)Math.Round(y); + var iz = (int)Math.Round(z); if (path.Count > 0) { p = path.Last; @@ -1240,7 +1235,7 @@ namespace Server } if (path.Count == 0) - return true; //<--should never happen, but to be safe. + return true; // <--should never happen, but to be safe. p = path.Last; @@ -1250,15 +1245,15 @@ namespace Server Point3D pTop = org, pBottom = dest; Utility.FixPoints(ref pTop, ref pBottom); - int pathCount = path.Count; - int endTop = end.m_Z + 1; + var pathCount = path.Count; + var endTop = end.m_Z + 1; - for (int i = 0; i < pathCount; ++i) + for (var i = 0; i < pathCount; ++i) { - Point3D point = path[i]; - int pointTop = point.m_Z + 1; + var point = path[i]; + var pointTop = point.m_Z + 1; - LandTile landTile = Tiles.GetLandTile(point.X, point.Y); + var landTile = Tiles.GetLandTile(point.X, point.Y); int landZ = 0, landAvg = 0, landTop = 0; GetAverageZ(point.m_X, point.m_Y, ref landZ, ref landAvg, ref landTop); @@ -1269,21 +1264,21 @@ namespace Server /* --Do land tiles need to be checked? There is never land between two people, always statics.-- LandTile landTile = Tiles.GetLandTile( point.X, point.Y ); - if ( landTile.Z-1 >= point.Z && landTile.Z+1 <= point.Z && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0 ) + if (landTile.Z-1 >= point.Z && landTile.Z+1 <= point.Z && (TileData.LandTable[landTile.ID & TileData.MaxLandValue].Flags & TileFlag.Impassable) != 0) return false; */ - StaticTile[] statics = Tiles.GetStaticTiles(point.m_X, point.m_Y, true); + var statics = Tiles.GetStaticTiles(point.m_X, point.m_Y, true); - bool contains = false; - int ltID = landTile.ID; + var contains = false; + var ltID = landTile.ID; - for (int j = 0; !contains && j < InvalidLandTiles.Length; ++j) + for (var j = 0; !contains && j < InvalidLandTiles.Length; ++j) contains = ltID == InvalidLandTiles[j]; if (contains && statics.Length == 0) { - IPooledEnumerable eable = GetItemsInRange(point, 0); + var eable = GetItemsInRange(point, 0); contains = !eable.Any(item => item.Visible); @@ -1293,11 +1288,11 @@ namespace Server return false; } - for (int j = 0; j < statics.Length; ++j) + for (var j = 0; j < statics.Length; ++j) { - StaticTile t = statics[j]; + var t = statics[j]; - ItemData id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; + var id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; flags = id.Flags; height = id.CalcHeight; @@ -1310,21 +1305,21 @@ namespace Server return false; } - /*if ( t.Z <= point.Z && t.Z+height >= point.Z && (flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0 + /*if (t.Z <= point.Z && t.Z+height >= point.Z && (flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0 && ( (flags&TileFlag.Wall)!=0 || (flags&TileFlag.Roof)!=0 || (((flags&TileFlag.Surface)!=0 && zd != 0)) ) )*/ /*{ //Console.WriteLine( "LoS: Blocked by Static \"{0}\" Z:{1} T:{3} P:{2} F:x{4:X}", TileData.ItemTable[t.ID&TileData.MaxItemValue].Name, t.Z, point, t.Z+height, flags ); - //Console.WriteLine( "if ( {0} && {1} && {2} && ( {3} || {4} || {5} || ({6} && {7} && {8}) ) )", t.Z <= point.Z, t.Z+height >= point.Z, (flags&TileFlag.Window)==0, (flags&TileFlag.Impassable)!=0, (flags&TileFlag.Wall)!=0, (flags&TileFlag.Roof)!=0, (flags&TileFlag.Surface)!=0, t.Z != dest.Z, zd != 0 ) ; + //Console.WriteLine( "if ({0} && {1} && {2} && ( {3} || {4} || {5} || ({6} && {7} && {8}) ) )", t.Z <= point.Z, t.Z+height >= point.Z, (flags&TileFlag.Window)==0, (flags&TileFlag.Impassable)!=0, (flags&TileFlag.Wall)!=0, (flags&TileFlag.Roof)!=0, (flags&TileFlag.Surface)!=0, t.Z != dest.Z, zd != 0 ) ; return false; }*/ } } - Rectangle2D rect = new Rectangle2D(pTop.m_X, pTop.m_Y, pBottom.m_X - pTop.m_X + 1, pBottom.m_Y - pTop.m_Y + 1); + var rect = new Rectangle2D(pTop.m_X, pTop.m_Y, pBottom.m_X - pTop.m_X + 1, pBottom.m_Y - pTop.m_Y + 1); - IPooledEnumerable area = GetItemsInBounds(rect); + var area = GetItemsInBounds(rect); - foreach (Item i in area) + foreach (var i in area) { if (!i.Visible) continue; @@ -1332,7 +1327,7 @@ namespace Server if (i is BaseMulti || i.ItemID > TileData.MaxItemValue) continue; - ItemData id = i.ItemData; + var id = i.ItemData; flags = id.Flags; if ((flags & (TileFlag.Window | TileFlag.NoShoot)) == 0) @@ -1340,17 +1335,17 @@ namespace Server height = id.CalcHeight; - bool found = false; + var found = false; - int count = path.Count; + var count = path.Count; - for (int j = 0; j < count; ++j) + for (var j = 0; j < count; ++j) { - Point3D point = path[j]; - int pointTop = point.m_Z + 1; - Point3D loc = i.Location; + var point = path[j]; + var pointTop = point.m_Z + 1; + var loc = i.Location; - //if ( t.Z <= point.Z && t.Z+height >= point.Z && ( height != 0 || ( t.Z == dest.Z && zd != 0 ) ) ) + // if (t.Z <= point.Z && t.Z+height >= point.Z && ( height != 0 || ( t.Z == dest.Z && zd != 0 ) )) if (loc.m_X == point.m_X && loc.m_Y == point.m_Y && loc.m_Z <= pointTop && loc.m_Z + height >= point.m_Z) if (loc.m_X != end.m_X || loc.m_Y != end.m_Y || loc.m_Z > endTop || loc.m_Z + height < end.m_Z) { @@ -1365,10 +1360,10 @@ namespace Server area.Free(); return false; - /*if ( (flags & (TileFlag.Impassable | TileFlag.Surface | TileFlag.Roof)) != 0 ) + /*if ((flags & (TileFlag.Impassable | TileFlag.Surface | TileFlag.Roof)) != 0) //flags = TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Flags; - //if ( (flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0 && ( (flags&TileFlag.Wall)!=0 || (flags&TileFlag.Roof)!=0 || (((flags&TileFlag.Surface)!=0 && zd != 0)) ) ) + //if ((flags&TileFlag.Window)==0 && (flags&TileFlag.NoShoot)!=0 && ( (flags&TileFlag.Wall)!=0 || (flags&TileFlag.Roof)!=0 || (((flags&TileFlag.Surface)!=0 && zd != 0)) )) { //height = TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Height; //Console.WriteLine( "LoS: Blocked by ITEM \"{0}\" P:{1} T:{2} F:x{3:X}", TileData.ItemTable[i.ItemID&TileData.MaxItemValue].Name, i.Location, i.Location.Z+height, flags ); @@ -1390,7 +1385,7 @@ namespace Server if (from.AccessLevel > AccessLevel.Player) return true; - Point3D eye = from.Location; + var eye = from.Location; eye.Z += 14; @@ -1402,33 +1397,32 @@ namespace Server if (from == to || from.AccessLevel > AccessLevel.Player) return true; - Point3D eye = from.Location; - Point3D target = to.Location; + var eye = from.Location; + var target = to.Location; eye.Z += 14; - target.Z += 14; //10; + target.Z += 14; // 10; return LineOfSight(eye, target); } - #endregion - - public Point3D GetRandomNearbyLocation(Point3D loc, int maxRange = 2, int minRange = 0, int retryCount = 10, int height = 16, bool checkBlocksFit = false, + public Point3D GetRandomNearbyLocation(Point3D loc, int maxRange = 2, int minRange = 0, int retryCount = 10, + int height = 16, bool checkBlocksFit = false, bool checkMobiles = false) { - int j = 0; - int range = maxRange - minRange; - bool[,] locs = range <= 10 ? new bool[range + 1, range + 1] : null; + var j = 0; + var range = maxRange - minRange; + var locs = range <= 10 ? new bool[range + 1, range + 1] : null; do { - int xRand = Utility.Random(range); - int yRand = Utility.Random(range); + var xRand = Utility.Random(range); + var yRand = Utility.Random(range); if (locs?[xRand, yRand] != true) { - int x = loc.X + xRand + minRange; - int y = loc.Y + yRand + minRange; + var x = loc.X + xRand + minRange; + var y = loc.Y + yRand + minRange; if (CanFit(x, y, loc.Z, height, checkBlocksFit, checkMobiles)) { @@ -1436,7 +1430,7 @@ namespace Server break; } - int z = GetAverageZ(x, y); + var z = GetAverageZ(x, y); if (CanFit(x, y, z, height, checkBlocksFit, checkMobiles)) { @@ -1449,8 +1443,7 @@ namespace Server } j++; - } - while (j < retryCount); + } while (j < retryCount); return loc; } diff --git a/Projects/Server/Menus/IMenu.cs b/Projects/Server/Menus/IMenu.cs index 56405f32e..658367f2e 100644 --- a/Projects/Server/Menus/IMenu.cs +++ b/Projects/Server/Menus/IMenu.cs @@ -24,10 +24,10 @@ namespace Server.Menus { public interface IMenu { - int Serial{ get; } - int EntryLength{ get; } + int Serial { get; } + int EntryLength { get; } void SendTo(NetState state); void OnCancel(NetState state); void OnResponse(NetState state, int index); } -} \ No newline at end of file +} diff --git a/Projects/Server/Menus/ItemListMenu.cs b/Projects/Server/Menus/ItemListMenu.cs index fe014949e..09a3e3293 100644 --- a/Projects/Server/Menus/ItemListMenu.cs +++ b/Projects/Server/Menus/ItemListMenu.cs @@ -31,17 +31,16 @@ namespace Server.Menus.ItemLists Hue = hue; } - public string Name{ get; } + public string Name { get; } - public int ItemID{ get; } + public int ItemID { get; } - public int Hue{ get; } + public int Hue { get; } } public class ItemListMenu : IMenu { private static int m_NextSerial; - private readonly int m_Serial; public ItemListMenu(string question, ItemListEntry[] entries) { @@ -50,20 +49,20 @@ namespace Server.Menus.ItemLists do { - m_Serial = m_NextSerial++; - m_Serial &= 0x7FFFFFFF; - } while (m_Serial == 0); + Serial = m_NextSerial++; + Serial &= 0x7FFFFFFF; + } while (Serial == 0); - m_Serial = (int)((uint)m_Serial | 0x80000000); + Serial = (int)((uint)Serial | 0x80000000); } - public string Question{ get; } + public string Question { get; } - public ItemListEntry[] Entries{ get; set; } + public ItemListEntry[] Entries { get; set; } - int IMenu.Serial => m_Serial; + public int Serial { get; } - int IMenu.EntryLength => Entries.Length; + public int EntryLength => Entries.Length; public virtual void OnCancel(NetState state) { diff --git a/Projects/Server/Menus/QuestionMenu.cs b/Projects/Server/Menus/QuestionMenu.cs index 2d403f537..a8923e422 100644 --- a/Projects/Server/Menus/QuestionMenu.cs +++ b/Projects/Server/Menus/QuestionMenu.cs @@ -25,7 +25,6 @@ namespace Server.Menus.Questions public class QuestionMenu : IMenu { private static int m_NextSerial; - private readonly int m_Serial; public QuestionMenu(string question, string[] answers) { @@ -34,18 +33,18 @@ namespace Server.Menus.Questions do { - m_Serial = ++m_NextSerial; - m_Serial &= 0x7FFFFFFF; - } while (m_Serial == 0); + Serial = ++m_NextSerial; + Serial &= 0x7FFFFFFF; + } while (Serial == 0); } - public string Question{ get; set; } + public string Question { get; set; } - public string[] Answers{ get; } + public string[] Answers { get; } - int IMenu.Serial => m_Serial; + public int Serial { get; } - int IMenu.EntryLength => Answers.Length; + public int EntryLength => Answers.Length; public virtual void OnCancel(NetState state) { @@ -61,4 +60,4 @@ namespace Server.Menus.Questions state.Send(new DisplayQuestionMenu(this)); } } -} \ No newline at end of file +} diff --git a/Projects/Server/Mobile.cs b/Projects/Server/Mobile.cs index 91d558f71..2aa739200 100644 --- a/Projects/Server/Mobile.cs +++ b/Projects/Server/Mobile.cs @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; using Server.Accounting; @@ -40,8 +41,6 @@ using Server.Utilities; namespace Server { - #region Callbacks - public delegate void TargetCallback(Mobile from, object targeted); public delegate void TargetStateCallback(Mobile from, object targeted, T state); @@ -50,10 +49,6 @@ namespace Server public delegate void PromptStateCallback(Mobile from, string text, T state); - #endregion - - #region [...]Mods - public class TimedSkillMod : SkillMod { private readonly DateTime m_Expire; @@ -117,7 +112,7 @@ namespace Server { m_ObeyCap = value; - Skill sk = m_Owner?.Skills[m_Skill]; + var sk = m_Owner?.Skills[m_Skill]; sk?.Update(); } } @@ -146,11 +141,11 @@ namespace Server { if (m_Skill != value) { - Skill oldUpdate = m_Owner?.Skills[m_Skill]; + var oldUpdate = m_Owner?.Skills[m_Skill]; m_Skill = value; - Skill sk = m_Owner?.Skills[m_Skill]; + var sk = m_Owner?.Skills[m_Skill]; sk?.Update(); oldUpdate?.Update(); } @@ -166,7 +161,7 @@ namespace Server { m_Relative = value; - Skill sk = m_Owner?.Skills[m_Skill]; + var sk = m_Owner?.Skills[m_Skill]; sk?.Update(); } } @@ -181,7 +176,7 @@ namespace Server { m_Relative = !value; - Skill sk = m_Owner?.Skills[m_Skill]; + var sk = m_Owner?.Skills[m_Skill]; sk?.Update(); } } @@ -196,7 +191,7 @@ namespace Server { m_Value = value; - Skill sk = m_Owner?.Skills[m_Skill]; + var sk = m_Owner?.Skills[m_Skill]; sk?.Update(); } } @@ -221,7 +216,7 @@ namespace Server m_Offset = offset; } - public Mobile Owner{ get; set; } + public Mobile Owner { get; set; } public ResistanceType Type { @@ -266,11 +261,11 @@ namespace Server m_Added = DateTime.UtcNow; } - public StatType Type{ get; } + public StatType Type { get; } - public string Name{ get; } + public string Name { get; } - public int Offset{ get; } + public int Offset { get; } public bool HasElapsed() { @@ -281,27 +276,23 @@ namespace Server } } - #endregion - public class DamageEntry { public DamageEntry(Mobile damager) => Damager = damager; - public Mobile Damager{ get; } + public Mobile Damager { get; } - public int DamageGiven{ get; set; } + public int DamageGiven { get; set; } - public DateTime LastDamage{ get; set; } + public DateTime LastDamage { get; set; } public bool HasExpired => DateTime.UtcNow > LastDamage + ExpireDelay; - public List Responsible{ get; set; } + public List Responsible { get; set; } - public static TimeSpan ExpireDelay{ get; set; } = TimeSpan.FromMinutes(2.0); + public static TimeSpan ExpireDelay { get; set; } = TimeSpan.FromMinutes(2.0); } - #region Enums - [Flags] public enum StatType { @@ -405,17 +396,21 @@ namespace Server Cured } - #endregion - [Serializable] public class MobileNotConnectedException : Exception { public MobileNotConnectedException(Mobile source, string message) : base(message) => Source = source.ToString(); - } - #region Delegates + public MobileNotConnectedException(Mobile source, string message, Exception innerException) + : base(message, innerException) => + Source = source.ToString(); + + protected MobileNotConnectedException(SerializationInfo info, StreamingContext context) : base(info, context) + { + } + } public delegate bool SkillCheckTargetHandler(Mobile from, SkillName skill, object target, double minSkill, double maxSkill); @@ -437,8 +432,6 @@ namespace Server public delegate int AOSStatusHandler(Mobile from, int index); - #endregion - /// /// Base class representing players, npcs, and creatures. /// @@ -453,7 +446,6 @@ namespace Server private static readonly TimeSpan WarmodeSpamCatch = TimeSpan.FromSeconds(Core.SE ? 1.0 : 0.5); private static readonly TimeSpan WarmodeSpamDelay = TimeSpan.FromSeconds(Core.SE ? 4.0 : 2.0); - private static readonly Packet[][] m_MovingPacketCache = new Packet[][] { new Packet[8], @@ -468,8 +460,6 @@ namespace Server private static readonly List m_Hears = new List(); private static readonly List m_OnSpeech = new List(); - public static bool m_DefaultShowVisibleDamage, m_DefaultCanSeeVisibleDamage; - private static readonly string[] m_AccessLevelNames = { "a player", @@ -523,7 +513,7 @@ namespace Server /* Logout: * * When a client logs into mobile x - * - if ( x is Internalized ) move x to logout location and map + * - if (x is Internalized ) move x to logout location and map * * When a client attached to a mobile disconnects * - LogoutTimer is started @@ -544,9 +534,6 @@ namespace Server private int m_SolidHueOverride = -1; private StatLockType m_StrLock, m_DexLock, m_IntLock; - - internal int m_TypeRef; - private IWeapon m_Weapon; private bool m_YellowHealthbar; @@ -560,14 +547,15 @@ namespace Server NextSkillTime = Core.TickCount; DamageEntries = new List(); - Type ourType = GetType(); - m_TypeRef = World.m_MobileTypes.IndexOf(ourType); + var ourType = GetType(); + TypeRef = World.m_MobileTypes.IndexOf(ourType); - if (m_TypeRef == -1) + if (TypeRef == -1) { World.m_MobileTypes.Add(ourType); - m_TypeRef = World.m_MobileTypes.Count - 1; + TypeRef = World.m_MobileTypes.Count - 1; } + m_SaveBuffer = new BufferWriter(true); } @@ -580,18 +568,19 @@ namespace Server World.AddMobile(this); - Type ourType = GetType(); - m_TypeRef = World.m_MobileTypes.IndexOf(ourType); + var ourType = GetType(); + TypeRef = World.m_MobileTypes.IndexOf(ourType); - if (m_TypeRef == -1) + if (TypeRef == -1) { World.m_MobileTypes.Add(ourType); - m_TypeRef = World.m_MobileTypes.Count - 1; + TypeRef = World.m_MobileTypes.Count - 1; } + m_SaveBuffer = new BufferWriter(true); } - public static bool DragEffects{ get; set; } = true; + public static bool DragEffects { get; set; } = true; [CommandProperty(AccessLevel.GameMaster)] public Race Race @@ -599,7 +588,7 @@ namespace Server get => m_Race ?? (m_Race = Race.DefaultRace); set { - Race oldRace = Race; + var oldRace = Race; m_Race = value ?? Race.DefaultRace; @@ -614,7 +603,7 @@ namespace Server public virtual double RacialSkillBonus => 0; - public int[] Resistances{ get; private set; } + public int[] Resistances { get; private set; } public virtual int BasePhysicalResistance => 0; public virtual int BaseFireResistance => 0; @@ -637,20 +626,20 @@ namespace Server [CommandProperty(AccessLevel.Counselor)] public virtual int EnergyResistance => GetResistance(ResistanceType.Energy); - public List ResistanceMods{ get; set; } + public List ResistanceMods { get; set; } - public static int MaxPlayerResistance{ get; set; } = 70; + public static int MaxPlayerResistance { get; set; } = 70; public virtual bool NewGuildDisplay => false; - public List Stabled{ get; private set; } + public List Stabled { get; private set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public VirtueInfo Virtues{ get; private set; } + public VirtueInfo Virtues { get; private set; } - public object Party{ get; set; } + public object Party { get; set; } - public List SkillMods{ get; private set; } + public List SkillMods { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public int VirtualArmorMod @@ -668,10 +657,10 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public int MeleeDamageAbsorb{ get; set; } + public int MeleeDamageAbsorb { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int MagicDamageAbsorb{ get; set; } + public int MagicDamageAbsorb { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int SkillsTotal => Skills?.Total ?? 0; @@ -688,12 +677,12 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public int BaseSoundID{ get; set; } + public int BaseSoundID { get; set; } - public long NextCombatTime{ get; set; } + public long NextCombatTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int NameHue{ get; set; } = -1; + public int NameHue { get; set; } = -1; [CommandProperty(AccessLevel.GameMaster)] public int Hunger @@ -701,7 +690,7 @@ namespace Server get => m_Hunger; set { - int oldValue = m_Hunger; + var oldValue = m_Hunger; if (oldValue != value) { @@ -713,16 +702,16 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public int Thirst{ get; set; } + public int Thirst { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int BAC{ get; set; } + public int BAC { get; set; } /// /// Gets or sets the number of steps this player may take when hidden before being revealed. /// [CommandProperty(AccessLevel.GameMaster)] - public int AllowedStealthSteps{ get; set; } + public int AllowedStealthSteps { get; set; } public Item Holding { @@ -754,7 +743,7 @@ namespace Server } } - public long LastMoveTime{ get; set; } + public long LastMoveTime { get; set; } [CommandProperty(AccessLevel.GameMaster)] public virtual bool Paralyzed @@ -779,10 +768,10 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public bool DisarmReady{ get; set; } + public bool DisarmReady { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool StunReady{ get; set; } + public bool StunReady { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Frozen @@ -858,13 +847,13 @@ namespace Server } } - public long NextActionTime{ get; set; } + public long NextActionTime { get; set; } - public long NextActionMessage{ get; set; } + public long NextActionMessage { get; set; } - public static int ActionMessageDelay{ get; set; } = 125; + public static int ActionMessageDelay { get; set; } = 125; - public static bool GlobalRegenThroughPoison{ get; set; } = true; + public static bool GlobalRegenThroughPoison { get; set; } = true; public virtual bool RegenThroughPoison => GlobalRegenThroughPoison; @@ -872,11 +861,11 @@ namespace Server public virtual bool CanRegenStam => Alive; public virtual bool CanRegenMana => Alive; - public long NextSkillTime{ get; set; } + public long NextSkillTime { get; set; } - public List Aggressors{ get; private set; } + public List Aggressors { get; private set; } - public List Aggressed{ get; private set; } + public List Aggressed { get; private set; } public bool ChangingCombatant => m_ChangingCombatant > 0; @@ -895,12 +884,12 @@ namespace Server if (m_Combatant != value && value != this) { - Mobile old = m_Combatant; + var old = m_Combatant; ++m_ChangingCombatant; m_Combatant = value; - if (m_Combatant != null && !CanBeHarmful(m_Combatant, false) || + if ((m_Combatant != null && !CanBeHarmful(m_Combatant, false)) || !Region.OnCombatantChange(this, old, m_Combatant)) { m_Combatant = old; @@ -994,15 +983,15 @@ namespace Server } } - public bool TargetLocked{ get; set; } + public bool TargetLocked { get; set; } public Target Target { get => m_Target; set { - Target oldTarget = m_Target; - Target newTarget = value; + var oldTarget = m_Target; + var newTarget = value; if (oldTarget == newTarget) return; @@ -1039,23 +1028,23 @@ namespace Server } } - public bool Pushing{ get; set; } + public bool Pushing { get; set; } - public static int WalkFoot{ get; set; } = 400; + public static int WalkFoot { get; set; } = 400; - public static int RunFoot{ get; set; } = 200; + public static int RunFoot { get; set; } = 200; - public static int WalkMount{ get; set; } = 200; + public static int WalkMount { get; set; } = 200; - public static int RunMount{ get; set; } = 100; + public static int RunMount { get; set; } = 100; - public static AccessLevel FwdAccessOverride{ get; set; } = AccessLevel.Counselor; + public static AccessLevel FwdAccessOverride { get; set; } = AccessLevel.Counselor; - public static bool FwdEnabled{ get; set; } = true; + public static bool FwdEnabled { get; set; } = true; - public static bool FwdUOTDOverride{ get; set; } = false; + public static bool FwdUOTDOverride { get; set; } = false; - public static int FwdMaxSteps{ get; set; } = 4; + public static int FwdMaxSteps { get; set; } = 4; public virtual bool IsDeadBondedPet => false; @@ -1072,10 +1061,10 @@ namespace Server } [CommandProperty(AccessLevel.Administrator)] - public bool AutoPageNotify{ get; set; } + public bool AutoPageNotify { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Owner)] - public IAccount Account{ get; set; } + public IAccount Account { get; set; } [CommandProperty(AccessLevel.GameMaster)] public int VirtualArmor @@ -1102,52 +1091,44 @@ namespace Server [CommandProperty(AccessLevel.Counselor)] public virtual bool Alive => !Deleted && (!m_Player || !m_Body.IsGhost); - public static CreateCorpseHandler CreateCorpseHandler{ get; set; } + public static CreateCorpseHandler CreateCorpseHandler { get; set; } public virtual bool RetainPackLocsOnDeath => Core.AOS; [CommandProperty(AccessLevel.GameMaster)] - public Container Corpse{ get; set; } + public Container Corpse { get; set; } - public static char[] GhostChars{ get; set; } = { 'o', 'O' }; + public static char[] GhostChars { get; set; } = { 'o', 'O' }; - public static bool NoSpeechLOS{ get; set; } + public static bool NoSpeechLOS { get; set; } - public static TimeSpan AutoManifestTimeout{ get; set; } = TimeSpan.FromSeconds(5.0); + public static TimeSpan AutoManifestTimeout { get; set; } = TimeSpan.FromSeconds(5.0); - public static bool InsuranceEnabled{ get; set; } + public static bool InsuranceEnabled { get; set; } - public static int ActionDelay{ get; set; } = 500; + public static int ActionDelay { get; set; } = 500; - public static VisibleDamageType VisibleDamageType{ get; set; } + public static VisibleDamageType VisibleDamageType { get; set; } - public List DamageEntries{ get; private set; } + public List DamageEntries { get; private set; } [CommandProperty(AccessLevel.GameMaster)] - public Mobile LastKiller{ get; set; } + public Mobile LastKiller { get; set; } - public static bool DefaultShowVisibleDamage - { - get => m_DefaultShowVisibleDamage; - set => m_DefaultShowVisibleDamage = value; - } + public static bool DefaultShowVisibleDamage { get; set; } - public static bool DefaultCanSeeVisibleDamage - { - get => m_DefaultCanSeeVisibleDamage; - set => m_DefaultCanSeeVisibleDamage = value; - } + public static bool DefaultCanSeeVisibleDamage { get; set; } - public virtual bool ShowVisibleDamage => m_DefaultShowVisibleDamage; - public virtual bool CanSeeVisibleDamage => m_DefaultCanSeeVisibleDamage; + public virtual bool ShowVisibleDamage => DefaultShowVisibleDamage; + public virtual bool CanSeeVisibleDamage => DefaultCanSeeVisibleDamage; [CommandProperty(AccessLevel.GameMaster)] - public bool Squelched{ get; set; } + public bool Squelched { get; set; } public virtual bool ShouldCheckStatTimers => true; [CommandProperty(AccessLevel.GameMaster)] - public DateTime CreationTime{ get; private set; } + public DateTime CreationTime { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public int LightLevel @@ -1161,17 +1142,17 @@ namespace Server CheckLightLevels(false); - /*if ( m_NetState != null ) + /*if (m_NetState != null) m_NetState.Send( new PersonalLightLevel( this ) );*/ } } } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public string Profile{ get; set; } + public string Profile { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public bool ProfileLocked{ get; set; } + public bool ProfileLocked { get; set; } [CommandProperty(AccessLevel.GameMaster, AccessLevel.Administrator)] public bool Player @@ -1202,14 +1183,14 @@ namespace Server } } - public List Items{ get; private set; } + public List Items { get; private set; } public virtual int MaxWeight => int.MaxValue; - public static IWeapon DefaultWeapon{ get; set; } + public static IWeapon DefaultWeapon { get; set; } [CommandProperty(AccessLevel.Counselor)] - public Skills Skills{ get; private set; } + public Skills Skills { get; private set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.Administrator)] public AccessLevel AccessLevel @@ -1217,7 +1198,7 @@ namespace Server get => m_AccessLevel; set { - AccessLevel oldValue = m_AccessLevel; + var oldValue = m_AccessLevel; if (oldValue != value) { @@ -1241,7 +1222,7 @@ namespace Server get => m_Fame; set { - int oldValue = m_Fame; + var oldValue = m_Fame; if (oldValue != value) { @@ -1261,7 +1242,7 @@ namespace Server get => m_Karma; set { - int old = m_Karma; + var old = m_Karma; if (old != value) { @@ -1316,7 +1297,7 @@ namespace Server } set { - int oldHue = m_Hue; + var oldHue = m_Hue; if (oldHue != value) { @@ -1338,7 +1319,7 @@ namespace Server m_Direction = value; Delta(MobileDelta.Direction); - //ProcessDelta(); + // ProcessDelta(); } } } @@ -1420,7 +1401,7 @@ namespace Server if (m_Hidden != value) { m_Hidden = value; - //Delta( MobileDelta.Flags ); + // Delta( MobileDelta.Flags ); OnHiddenChanged(); } @@ -1443,18 +1424,18 @@ namespace Server m_Spell?.OnConnectionChanged(); - //if ( m_Spell != null ) - // m_Spell.FinishSequence(); + // if (m_Spell != null) + // m_Spell.FinishSequence(); m_NetState?.CancelAllTrades(); - BankBox box = FindBankNoCreate(); + var box = FindBankNoCreate(); if (box?.Opened == true) box.Close(); // REMOVED: - //m_Actions.Clear(); + // m_Actions.Clear(); m_NetState = value; @@ -1491,23 +1472,23 @@ namespace Server } } - for (int i = Items.Count - 1; i >= 0; --i) + for (var i = Items.Count - 1; i >= 0; --i) { if (i >= Items.Count) continue; - Item item = Items[i]; + var item = Items[i]; if (item is SecureTradeContainer) { - for (int j = item.Items.Count - 1; j >= 0; --j) + for (var j = item.Items.Count - 1; j >= 0; --j) if (j < item.Items.Count) { item.Items[j].OnSecureTrade(this, this, this, false); AddToBackpack(item.Items[j]); } - Timer.DelayCall(TimeSpan.Zero, delegate { item.Delete(); }); + Timer.DelayCall(TimeSpan.Zero, item.Delete); } } @@ -1525,16 +1506,16 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public int SpeechHue{ get; set; } + public int SpeechHue { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int EmoteHue{ get; set; } + public int EmoteHue { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int WhisperHue{ get; set; } + public int WhisperHue { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public int YellHue{ get; set; } + public int YellHue { get; set; } [CommandProperty(AccessLevel.GameMaster)] public string GuildTitle @@ -1542,7 +1523,7 @@ namespace Server get => m_GuildTitle; set { - string old = m_GuildTitle; + var old = m_GuildTitle; if (old != value) { @@ -1570,7 +1551,7 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public Mobile GuildFealty{ get; set; } + public Mobile GuildFealty { get; set; } [CommandProperty(AccessLevel.GameMaster)] public string NameMod @@ -1613,7 +1594,7 @@ namespace Server { if (m_Name != value) // I'm leaving out the && m_NameMod == null { - string oldName = m_Name; + var oldName = m_Name; m_Name = value; OnAfterNameChange(oldName, m_Name); Delta(MobileDelta.Name); @@ -1623,19 +1604,19 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastStrGain{ get; set; } + public DateTime LastStrGain { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastIntGain{ get; set; } + public DateTime LastIntGain { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public DateTime LastDexGain{ get; set; } + public DateTime LastDexGain { get; set; } public DateTime LastStatGain { get { - DateTime d = LastStrGain; + var d = LastStrGain; if (LastIntGain > d) d = LastIntGain; @@ -1658,7 +1639,7 @@ namespace Server get => m_Guild; set { - BaseGuild old = m_Guild; + var old = m_Guild; if (old != value) { @@ -1675,7 +1656,7 @@ namespace Server } } - public Region WalkRegion{ get; set; } + public Region WalkRegion { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool Poisoned => m_Poison != null; @@ -1735,10 +1716,10 @@ namespace Server } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public Point3D LogoutLocation{ get; set; } + public Point3D LogoutLocation { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public Map LogoutMap{ get; set; } + public Map LogoutMap { get; set; } public Region Region => m_Region ?? (Map == null ? Map.Internal.DefaultRegion : Map.DefaultRegion); @@ -1820,7 +1801,7 @@ namespace Server public bool HasTrade => m_NetState?.Trades.Count > 0; - public bool NoMoveHS{ get; set; } + public bool NoMoveHS { get; set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public int Kills @@ -1828,7 +1809,7 @@ namespace Server get => m_Kills; set { - int oldValue = m_Kills; + var oldValue = m_Kills; if (m_Kills != value) { @@ -1894,9 +1875,9 @@ namespace Server } } - public static bool DisableDismountInWarmode{ get; set; } + public static bool DisableDismountInWarmode { get; set; } - public static int BodyWeight{ get; set; } = 14; + public static int BodyWeight { get; set; } = 14; [CommandProperty(AccessLevel.GameMaster)] public IMount Mount @@ -1940,15 +1921,15 @@ namespace Server public virtual bool PropertyTitle => OldPropertyTitles ? ClickTitle : true; - public static bool DisableHiddenSelfClick{ get; set; } = true; + public static bool DisableHiddenSelfClick { get; set; } = true; - public static bool AsciiClickMessage{ get; set; } = true; + public static bool AsciiClickMessage { get; set; } = true; - public static bool GuildClickMessage{ get; set; } = true; + public static bool GuildClickMessage { get; set; } = true; - public static bool OldPropertyTitles{ get; set; } + public static bool OldPropertyTitles { get; set; } - public virtual bool ShowFameTitle //(m_Player || m_Body.IsHuman) && m_Fame >= 10000; } + public virtual bool ShowFameTitle // (m_Player || m_Body.IsHuman) && m_Fame >= 10000; } => true; /// @@ -1970,13 +1951,13 @@ namespace Server } [CommandProperty(AccessLevel.GameMaster)] - public bool Meditating{ get; set; } + public bool Meditating { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool CanSwim{ get; set; } + public bool CanSwim { get; set; } [CommandProperty(AccessLevel.GameMaster)] - public bool CantWalk{ get; set; } + public bool CantWalk { get; set; } [CommandProperty(AccessLevel.GameMaster)] public bool CanHearGhosts @@ -1988,9 +1969,9 @@ namespace Server [CommandProperty(AccessLevel.GameMaster)] public int RawStatTotal => RawStr + RawDex + RawInt; - public long NextSpellTime{ get; set; } + public long NextSpellTime { get; set; } - public bool Deleted{ get; private set; } + public bool Deleted { get; private set; } public virtual void Delete() { @@ -2011,17 +1992,17 @@ namespace Server Region.OnRegionChange(this, m_Region, null); m_Region = null; - //Is the above line REALLY needed? The old Region system did NOT have said line - //and worked fine, because of this a LOT of extra checks have to be done everywhere... - //I guess this should be there for Garbage collection purposes, but, still, is it /really/ needed? + // Is the above line REALLY needed? The old Region system did NOT have said line + // and worked fine, because of this a LOT of extra checks have to be done everywhere... + // I guess this should be there for Garbage collection purposes, but, still, is it /really/ needed? OnDelete(); - for (int i = Items.Count - 1; i >= 0; --i) + for (var i = Items.Count - 1; i >= 0; --i) if (i < Items.Count) Items[i].OnParentDeleted(this); - for (int i = 0; i < Stabled.Count; i++) + for (var i = 0; i < Stabled.Count; i++) Stabled[i].Delete(); SendRemovePacket(); @@ -2057,7 +2038,7 @@ namespace Server { m_NetState?.ValidateAllTrades(); - Map oldMap = m_Map; + var oldMap = m_Map; if (m_Map != null) { @@ -2067,7 +2048,7 @@ namespace Server SendRemovePacket(); } - for (int i = 0; i < Items.Count; ++i) + for (var i = 0; i < Items.Count; ++i) Items[i].Map = value; m_Map = value; @@ -2076,7 +2057,7 @@ namespace Server m_Map?.OnEnter(this); - NetState ns = m_NetState; + var ns = m_NetState; if (ns != null && m_Map != null) { @@ -2147,7 +2128,7 @@ namespace Server } [CommandProperty(AccessLevel.Counselor)] - public Serial Serial{ get; } + public Serial Serial { get; } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public Point3D Location @@ -2167,15 +2148,15 @@ namespace Server return; } - BankBox box = FindBankNoCreate(); + var box = FindBankNoCreate(); if (box?.Opened == true) box.Close(); - Point3D oldLocation = m_Location; - Map oldMap = m_Map; + var oldLocation = m_Location; + var oldMap = m_Map; - Region oldRegion = m_Region; + var oldRegion = m_Region; if (oldMap != null) { @@ -2185,14 +2166,14 @@ namespace Server SendRemovePacket(); } - for (int i = 0; i < Items.Count; ++i) + for (var i = 0; i < Items.Count; ++i) Items[i].Map = map; m_Map = map; m_Location = newLocation; - NetState ns = m_NetState; + var ns = m_NetState; if (m_Map != null) { @@ -2297,13 +2278,13 @@ namespace Server public virtual void ProcessDelta() { - Mobile m = this; - MobileDelta delta = m.m_DeltaFlags; + var m = this; + var delta = m.m_DeltaFlags; if (delta == MobileDelta.None) return; - MobileDelta attrs = delta & MobileDelta.Attributes; + var attrs = delta & MobileDelta.Attributes; m.m_DeltaFlags = MobileDelta.None; m.m_InDeltaQueue = false; @@ -2313,7 +2294,7 @@ namespace Server bool sendUpdate = false, sendRemove = false; bool sendPublicStats = false, sendPrivateStats = false; bool sendMoving = false, sendNonlocalMoving = false; - bool sendOPLUpdate = ObjectPropertyList.Enabled && (delta & MobileDelta.Properties) != 0; + var sendOPLUpdate = ObjectPropertyList.Enabled && (delta & MobileDelta.Properties) != 0; bool sendHair = false, sendFacialHair = false, removeHair = false, removeFacialHair = false; @@ -2356,12 +2337,12 @@ namespace Server sendIncoming = true; } - /*if ( (delta & MobileDelta.Hue) != 0 ) + /*if ((delta & MobileDelta.Hue) != 0) { sendNonlocalIncoming = true; sendUpdate = true; } - else if ( (delta & (MobileDelta.Direction | MobileDelta.Body)) != 0 ) + else if ((delta & (MobileDelta.Direction | MobileDelta.Body)) != 0) { sendNonlocalMoving = true; sendUpdate = true; @@ -2402,9 +2383,9 @@ namespace Server sendFacialHair = true; } - Packet[][] cache = new Packet[][] { new Packet[8], new Packet[8] }; + var cache = new[] { new Packet[8], new Packet[8] }; - NetState ourState = m.m_NetState; + var ourState = m.m_NetState; if (ourState != null) { @@ -2427,7 +2408,7 @@ namespace Server { if (sendMoving) { - int noto = Notoriety.Compute(m, m); + var noto = Notoriety.Compute(m, m); ourState.Send(cache[0][noto] = Packet.Acquire(new MobileMoving(m, noto))); } @@ -2441,7 +2422,7 @@ namespace Server { if (sendMoving || sendHealthbarPoison || sendHealthbarYellow) { - int noto = Notoriety.Compute(m, m); + var noto = Notoriety.Compute(m, m); ourState.Send(cache[1][noto] = Packet.Acquire(new MobileMovingOld(m, noto))); } } @@ -2515,9 +2496,9 @@ namespace Server Packet hbpPacket = null; Packet hbyPacket = null; - IPooledEnumerable eable = m.Map.GetClientsInRange(m.m_Location); + var eable = m.Map.GetClientsInRange(m.m_Location); - foreach (NetState state in eable) + foreach (var state in eable) { beholder = state.Mobile; @@ -2542,9 +2523,9 @@ namespace Server { if (sendMoving) { - int noto = Notoriety.Compute(beholder, m); + var noto = Notoriety.Compute(beholder, m); - Packet p = cache[0][noto]; + var p = cache[0][noto]; if (p == null) cache[0][noto] = p = Packet.Acquire(new MobileMoving(m, noto)); @@ -2570,9 +2551,9 @@ namespace Server { if (sendMoving || sendHealthbarPoison || sendHealthbarYellow) { - int noto = Notoriety.Compute(beholder, m); + var noto = Notoriety.Compute(beholder, m); - Packet p = cache[1][noto]; + var p = cache[1][noto]; if (p == null) cache[1][noto] = p = Packet.Acquire(new MobileMovingOld(m, noto)); @@ -2612,7 +2593,9 @@ namespace Server if (sendFacialHair) { - facialhairPacket ??= removeFacialHair ? Packet.Acquire(new RemoveFacialHair(m)) : Packet.Acquire(new FacialHairEquipUpdate(m)); + facialhairPacket ??= removeFacialHair + ? Packet.Acquire(new RemoveFacialHair(m)) + : Packet.Acquire(new FacialHairEquipUpdate(m)); state.Send(facialhairPacket); } @@ -2635,22 +2618,21 @@ namespace Server } if (sendMoving || sendNonlocalMoving || sendHealthbarPoison || sendHealthbarYellow) - for (int i = 0; i < cache.Length; ++i) - for (int j = 0; j < cache[i].Length; ++j) - Packet.Release(ref cache[i][j]); + for (var i = 0; i < cache.Length; ++i) + for (var j = 0; j < cache[i].Length; ++j) + Packet.Release(ref cache[i][j]); } public virtual int HuedItemID => m_Female ? 0x2107 : 0x2106; - int ISerializable.TypeReference => m_TypeRef; - - uint ISerializable.SerialIdentity => Serial; + public int TypeRef { get; } public void Serialize() { SaveBuffer.Flush(); Serialize(SaveBuffer); } + public virtual void Serialize(IGenericWriter writer) { writer.Write(32); // version @@ -2691,10 +2673,10 @@ namespace Server writer.Write(BAC); writer.Write(m_ShortTermMurders); - //writer.Write( m_ShortTermElapse ); - //writer.Write( m_LongTermElapse ); + // writer.Write( m_ShortTermElapse ); + // writer.Write( m_LongTermElapse ); - //writer.Write( m_Followers ); + // writer.Write( m_Followers ); writer.Write(m_FollowersMax); writer.Write(MagicDamageAbsorb); @@ -2718,7 +2700,7 @@ namespace Server writer.Write(DisarmReady); writer.Write(StunReady); - //Poison.Serialize( m_Poison, writer ); + // Poison.Serialize( m_Poison, writer ); writer.Write(m_StatCap); @@ -2773,7 +2755,7 @@ namespace Server writer.Write((byte)m_IntLock); } - public ISpawner Spawner{ get; set; } + public ISpawner Spawner { get; set; } public virtual void OnBeforeSpawn(Point3D location, Map m) { @@ -2808,9 +2790,9 @@ namespace Server { Resistances ??= new[] { int.MinValue, int.MinValue, int.MinValue, int.MinValue, int.MinValue }; - bool delta = false; + var delta = false; - for (int i = 0; i < Resistances.Length; ++i) + for (var i = 0; i < Resistances.Length; ++i) if (Resistances[i] != int.MinValue) { Resistances[i] = int.MinValue; @@ -2825,12 +2807,12 @@ namespace Server { Resistances ??= new[] { int.MinValue, int.MinValue, int.MinValue, int.MinValue, int.MinValue }; - int v = (int)type; + var v = (int)type; if (v < 0 || v >= Resistances.Length) return 0; - int res = Resistances[v]; + var res = Resistances[v]; if (res == int.MinValue) { @@ -2866,7 +2848,7 @@ namespace Server { Resistances ??= new[] { int.MinValue, int.MinValue, int.MinValue, int.MinValue, int.MinValue }; - for (int i = 0; i < Resistances.Length; ++i) + for (var i = 0; i < Resistances.Length; ++i) Resistances[i] = 0; Resistances[0] += BasePhysicalResistance; @@ -2875,18 +2857,18 @@ namespace Server Resistances[3] += BasePoisonResistance; Resistances[4] += BaseEnergyResistance; - for (int i = 0; ResistanceMods != null && i < ResistanceMods.Count; ++i) + for (var i = 0; ResistanceMods != null && i < ResistanceMods.Count; ++i) { - ResistanceMod mod = ResistanceMods[i]; - int v = (int)mod.Type; + var mod = ResistanceMods[i]; + var v = (int)mod.Type; if (v >= 0 && v < Resistances.Length) Resistances[v] += mod.Offset; } - for (int i = 0; i < Items.Count; ++i) + for (var i = 0; i < Items.Count; ++i) { - Item item = Items[i]; + var item = Items[i]; if (item.CheckPropertyConflict(this)) continue; @@ -2898,10 +2880,10 @@ namespace Server Resistances[4] += item.EnergyResistance; } - for (int i = 0; i < Resistances.Length; ++i) + for (var i = 0; i < Resistances.Length; ++i) { - int min = GetMinResistance((ResistanceType)i); - int max = GetMaxResistance((ResistanceType)i); + var min = GetMinResistance((ResistanceType)i); + var max = GetMaxResistance((ResistanceType)i); if (max < min) max = min; @@ -2926,7 +2908,7 @@ namespace Server public virtual void OnAosSingleClick(Mobile from) { - ObjectPropertyList opl = PropertyList; + var opl = PropertyList; if (opl.Header > 0) { @@ -2947,29 +2929,30 @@ namespace Server public virtual void AddNameProperties(ObjectPropertyList list) { - string name = Name ?? string.Empty; + var name = Name ?? string.Empty; - string prefix = ""; + var prefix = ""; if (ShowFameTitle && (m_Player || m_Body.IsHuman) && m_Fame >= 10000) prefix = m_Female ? "Lady" : "Lord"; - string suffix = ""; + var suffix = ""; if (PropertyTitle && !string.IsNullOrEmpty(Title)) suffix = Title; - BaseGuild guild = m_Guild; + var guild = m_Guild; if (guild != null && (m_Player || m_DisplayGuildTitle)) - suffix = suffix.Length > 0 ? $"{suffix} [{Utility.FixHtml(guild.Abbreviation)}]" + suffix = suffix.Length > 0 + ? $"{suffix} [{Utility.FixHtml(guild.Abbreviation)}]" : $"[{Utility.FixHtml(guild.Abbreviation)}]"; suffix = ApplyNameSuffix(suffix); list.Add(1050045, "{0} \t{1}\t {2}", prefix, name, suffix); // ~1_PREFIX~~2_NAME~~3_SUFFIX~ - if (guild != null && (m_DisplayGuildTitle || m_Player && guild.Type != GuildType.Regular)) + if (guild != null && (m_DisplayGuildTitle || (m_Player && guild.Type != GuildType.Regular))) { string type; @@ -2978,7 +2961,7 @@ namespace Server else type = ""; - string title = GuildTitle?.Trim() ?? ""; + var title = GuildTitle?.Trim() ?? ""; if (NewGuildDisplay && title.Length > 0) { @@ -3009,7 +2992,7 @@ namespace Server private void UpdateAggrExpire() { - if (Deleted || Aggressors.Count == 0 && Aggressed.Count == 0) + if (Deleted || (Aggressors.Count == 0 && Aggressed.Count == 0)) { StopAggrExpire(); } @@ -3029,16 +3012,16 @@ namespace Server private void CheckAggrExpire() { - for (int i = Aggressors.Count - 1; i >= 0; --i) + for (var i = Aggressors.Count - 1; i >= 0; --i) { if (i >= Aggressors.Count) continue; - AggressorInfo info = Aggressors[i]; + var info = Aggressors[i]; if (info.Expired) { - Mobile attacker = info.Attacker; + var attacker = info.Attacker; attacker.RemoveAggressed(this); Aggressors.RemoveAt(i); @@ -3049,16 +3032,16 @@ namespace Server } } - for (int i = Aggressed.Count - 1; i >= 0; --i) + for (var i = Aggressed.Count - 1; i >= 0; --i) { if (i >= Aggressed.Count) continue; - AggressorInfo info = Aggressed[i]; + var info = Aggressed[i]; if (info.Expired) { - Mobile defender = info.Defender; + var defender = info.Defender; defender.RemoveAggressor(this); Aggressed.RemoveAt(i); @@ -3083,19 +3066,19 @@ namespace Server { ValidateSkillMods(); - for (int i = 0; i < SkillMods.Count; ++i) + for (var i = 0; i < SkillMods.Count; ++i) { - SkillMod mod = SkillMods[i]; - Skill sk = Skills[mod.Skill]; + var mod = SkillMods[i]; + var sk = Skills[mod.Skill]; sk?.Update(); } } public virtual void ValidateSkillMods() { - for (int i = 0; i < SkillMods.Count;) + for (var i = 0; i < SkillMods.Count;) { - SkillMod mod = SkillMods[i]; + var mod = SkillMods[i]; if (mod.CheckCondition()) ++i; @@ -3116,7 +3099,7 @@ namespace Server SkillMods.Add(mod); mod.Owner = this; - Skill sk = Skills[mod.Skill]; + var sk = Skills[mod.Skill]; sk?.Update(); } } @@ -3138,7 +3121,7 @@ namespace Server SkillMods.Remove(mod); mod.Owner = null; - Skill sk = Skills[mod.Skill]; + var sk = Skills[mod.Skill]; sk?.Update(); } } @@ -3190,7 +3173,7 @@ namespace Server public bool InLOS(object target) => !Deleted && m_Map != null && - (target == this || m_AccessLevel > AccessLevel.Player || target is Item item && item.RootParent == this + (target == this || m_AccessLevel > AccessLevel.Player || (target is Item item && item.RootParent == this) || m_Map.LineOfSight(this, target)); public bool InLOS(Point3D target) => @@ -3287,7 +3270,7 @@ namespace Server { if (item?.Movable == true && !item.AllowEquippedCast(this)) { - Container pack = Backpack; + var pack = Backpack; if (pack == null) AddToBackpack(item); @@ -3314,24 +3297,24 @@ namespace Server public double GetDistanceToSqrt(Point3D p) { - int xDelta = m_Location.m_X - p.m_X; - int yDelta = m_Location.m_Y - p.m_Y; + var xDelta = m_Location.m_X - p.m_X; + var yDelta = m_Location.m_Y - p.m_Y; return Math.Sqrt(xDelta * xDelta + yDelta * yDelta); } public double GetDistanceToSqrt(Mobile m) { - int xDelta = m_Location.m_X - m.m_Location.m_X; - int yDelta = m_Location.m_Y - m.m_Location.m_Y; + var xDelta = m_Location.m_X - m.m_Location.m_X; + var yDelta = m_Location.m_Y - m.m_Location.m_Y; return Math.Sqrt(xDelta * xDelta + yDelta * yDelta); } public double GetDistanceToSqrt(IPoint2D p) { - int xDelta = m_Location.m_X - p.X; - int yDelta = m_Location.m_Y - p.Y; + var xDelta = m_Location.m_X - p.X; + var yDelta = m_Location.m_Y - p.Y; return Math.Sqrt(xDelta * xDelta + yDelta * yDelta); } @@ -3343,7 +3326,7 @@ namespace Server if (aggressor == this) return; - AggressiveActionEventArgs args = AggressiveActionEventArgs.Create(this, aggressor, criminal); + var args = AggressiveActionEventArgs.Create(this, aggressor, criminal); EventSink.InvokeAggressiveAction(args); @@ -3359,13 +3342,13 @@ namespace Server m_ExpireCombatant.Start(); } - bool addAggressor = true; + var addAggressor = true; - List list = Aggressors; + var list = Aggressors; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - AggressorInfo info = list[i]; + var info = list[i]; if (info.Attacker == aggressor) { @@ -3379,9 +3362,9 @@ namespace Server list = aggressor.Aggressors; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - AggressorInfo info = list[i]; + var info = list[i]; if (info.Attacker == this) { @@ -3391,13 +3374,13 @@ namespace Server } } - bool addAggressed = true; + var addAggressed = true; list = Aggressed; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - AggressorInfo info = list[i]; + var info = list[i]; if (info.Defender == aggressor) { @@ -3409,9 +3392,9 @@ namespace Server list = aggressor.Aggressed; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - AggressorInfo info = list[i]; + var info = list[i]; if (info.Defender == this) { @@ -3423,7 +3406,7 @@ namespace Server } } - bool setCombatant = false; + var setCombatant = false; if (addAggressor) { @@ -3462,11 +3445,11 @@ namespace Server if (Deleted) return; - List list = Aggressed; + var list = Aggressed; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - AggressorInfo info = list[i]; + var info = list[i]; if (info.Defender == aggressed) { @@ -3488,11 +3471,11 @@ namespace Server if (Deleted) return; - List list = Aggressors; + var list = Aggressors; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - AggressorInfo info = list[i]; + var info = list[i]; if (info.Attacker == aggressor) { @@ -3547,15 +3530,15 @@ namespace Server if (Items == null) return; - int oldWeight = m_TotalWeight; + var oldWeight = m_TotalWeight; m_TotalGold = 0; m_TotalItems = 0; m_TotalWeight = 0; - for (int i = 0; i < Items.Count; ++i) + for (var i = 0; i < Items.Count; ++i) { - Item item = Items[i]; + var item = Items[i]; item.UpdateTotals(); @@ -3578,7 +3561,8 @@ namespace Server public void ClearTarget() => m_Target = null; - public Target BeginTarget(int range, bool allowGround, TargetFlags flags, TargetCallback callback) => Target = new SimpleTarget(range, flags, allowGround, callback); + public Target BeginTarget(int range, bool allowGround, TargetFlags flags, TargetCallback callback) => + Target = new SimpleTarget(range, flags, allowGround, callback); public Target BeginTarget(int range, bool allowGround, TargetFlags flags, TargetStateCallback callback, T state) => @@ -3598,11 +3582,11 @@ namespace Server if (!OnMove(d)) return false; - MovementEventArgs e = MovementEventArgs.Create(this, d); + var e = MovementEventArgs.Create(this, d); EventSink.InvokeMovement(e); - bool ret = !e.Blocked; + var ret = !e.Blocked; e.Free(); @@ -3637,13 +3621,13 @@ namespace Server if (Deleted) return false; - BankBox box = FindBankNoCreate(); + var box = FindBankNoCreate(); if (box?.Opened == true) box.Close(); - Point3D newLocation = m_Location; - Point3D oldLocation = newLocation; + var newLocation = m_Location; + var oldLocation = newLocation; if ((m_Direction & Direction.Mask) == (d & Direction.Mask)) { @@ -3659,11 +3643,11 @@ namespace Server return false; } - if (CheckMovement(d, out int newZ)) + if (CheckMovement(d, out var newZ)) { int x = oldLocation.m_X, y = oldLocation.m_Y; int oldX = x, oldY = y; - int oldZ = oldLocation.m_Z; + var oldZ = oldLocation.m_Z; switch (d & Direction.Mask) { @@ -3703,57 +3687,57 @@ namespace Server Pushing = false; - Map map = m_Map; + var map = m_Map; if (map != null) { - Sector oldSector = map.GetSector(oldX, oldY); - Sector newSector = map.GetSector(x, y); + var oldSector = map.GetSector(oldX, oldY); + var newSector = map.GetSector(x, y); if (oldSector != newSector) { - for (int i = 0; i < oldSector.Mobiles.Count; ++i) + for (var i = 0; i < oldSector.Mobiles.Count; ++i) { - Mobile m = oldSector.Mobiles[i]; + var m = oldSector.Mobiles[i]; if (m != this && m.X == oldX && m.Y == oldY && m.Z + 15 > oldZ && oldZ + 15 > m.Z && !m.OnMoveOff(this)) return false; } - for (int i = 0; i < oldSector.Items.Count; ++i) + for (var i = 0; i < oldSector.Items.Count; ++i) { - Item item = oldSector.Items[i]; + var item = oldSector.Items[i]; if (item.AtWorldPoint(oldX, oldY) && - (item.Z == oldZ || item.Z + item.ItemData.Height > oldZ && oldZ + 15 > item.Z) && + (item.Z == oldZ || (item.Z + item.ItemData.Height > oldZ && oldZ + 15 > item.Z)) && !item.OnMoveOff(this)) return false; } - for (int i = 0; i < newSector.Mobiles.Count; ++i) + for (var i = 0; i < newSector.Mobiles.Count; ++i) { - Mobile m = newSector.Mobiles[i]; + var m = newSector.Mobiles[i]; if (m.X == x && m.Y == y && m.Z + 15 > newZ && newZ + 15 > m.Z && !m.OnMoveOver(this)) return false; } - for (int i = 0; i < newSector.Items.Count; ++i) + for (var i = 0; i < newSector.Items.Count; ++i) { - Item item = newSector.Items[i]; + var item = newSector.Items[i]; if (item.AtWorldPoint(x, y) && - (item.Z == newZ || item.Z + item.ItemData.Height > newZ && newZ + 15 > item.Z) && + (item.Z == newZ || (item.Z + item.ItemData.Height > newZ && newZ + 15 > item.Z)) && !item.OnMoveOver(this)) return false; } } else { - for (int i = 0; i < oldSector.Mobiles.Count; ++i) + for (var i = 0; i < oldSector.Mobiles.Count; ++i) { - Mobile m = oldSector.Mobiles[i]; + var m = oldSector.Mobiles[i]; if (m != this && m.X == oldX && m.Y == oldY && m.Z + 15 > oldZ && oldZ + 15 > m.Z && !m.OnMoveOff(this)) @@ -3762,16 +3746,16 @@ namespace Server return false; } - for (int i = 0; i < oldSector.Items.Count; ++i) + for (var i = 0; i < oldSector.Items.Count; ++i) { - Item item = oldSector.Items[i]; + var item = oldSector.Items[i]; if (item.AtWorldPoint(oldX, oldY) && - (item.Z == oldZ || item.Z + item.ItemData.Height > oldZ && oldZ + 15 > item.Z) && + (item.Z == oldZ || (item.Z + item.ItemData.Height > oldZ && oldZ + 15 > item.Z)) && !item.OnMoveOff(this)) return false; if (item.AtWorldPoint(x, y) && - (item.Z == newZ || item.Z + item.ItemData.Height > newZ && newZ + 15 > item.Z) && + (item.Z == newZ || (item.Z + item.ItemData.Height > newZ && newZ + 15 > item.Z)) && !item.OnMoveOver(this)) return false; } @@ -3795,7 +3779,7 @@ namespace Server while (m_MoveRecords.Count > 0) { - MovementRecord r = m_MoveRecords.Peek(); + var r = m_MoveRecords.Peek(); if (r.Expired()) m_MoveRecords.Dequeue(); @@ -3805,14 +3789,14 @@ namespace Server if (m_MoveRecords.Count >= FwdMaxSteps) { - FastWalkEventArgs fw = new FastWalkEventArgs(m_NetState); + var fw = new FastWalkEventArgs(m_NetState); EventSink.InvokeFastWalk(fw); if (fw.Blocked) return false; } - int delay = ComputeMovementSpeed(d); + var delay = ComputeMovementSpeed(d); long end; @@ -3837,16 +3821,16 @@ namespace Server } m_NetState?.Send(MovementAck.Instantiate(m_NetState.Sequence, - this)); //new MovementAck( m_NetState.Sequence, this ) ); + this)); // new MovementAck( m_NetState.Sequence, this ) ); SetLocation(newLocation, false); SetDirection(d); if (m_Map != null) { - IPooledEnumerable eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); + var eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); - foreach (IEntity o in eable) + foreach (var o in eable) { if (o == this) continue; @@ -3865,22 +3849,22 @@ namespace Server eable.Free(); - Packet[][] cache = m_MovingPacketCache; + var cache = m_MovingPacketCache; /*for( int i = 0; i < cache.Length; ++i ) for( int j = 0; j < cache[i].Length; ++j ) Packet.Release( ref cache[i][j] );*/ - foreach (Mobile m in m_MoveClientList) + foreach (var m in m_MoveClientList) { - NetState ns = m.NetState; + var ns = m.NetState; if (ns != null && Utility.InUpdateRange(m_Location, m.m_Location) && m.CanSee(this)) { if (ns.StygianAbyss) { - int noto = Notoriety.Compute(m, this); - Packet p = cache[0][noto]; + var noto = Notoriety.Compute(m, this); + var p = cache[0][noto]; if (p == null) cache[0][noto] = p = Packet.Acquire(new MobileMoving(this, noto)); @@ -3889,8 +3873,8 @@ namespace Server } else { - int noto = Notoriety.Compute(m, this); - Packet p = cache[1][noto]; + var noto = Notoriety.Compute(m, this); + var p = cache[1][noto]; if (p == null) cache[1][noto] = p = Packet.Acquire(new MobileMovingOld(this, noto)); @@ -3900,13 +3884,13 @@ namespace Server } } - for (int i = 0; i < cache.Length; ++i) - for (int j = 0; j < cache[i].Length; ++j) - Packet.Release(ref cache[i][j]); + for (var i = 0; i < cache.Length; ++i) + for (var j = 0; j < cache[i].Length; ++j) + Packet.Release(ref cache[i][j]); - for (int i = 0; i < m_MoveList.Count; ++i) + for (var i = 0; i < m_MoveList.Count; ++i) { - IEntity o = m_MoveList[i]; + var o = m_MoveList[i]; if (o is Mobile mobile) mobile.OnMovement(this, oldLocation); @@ -4050,7 +4034,7 @@ namespace Server OnBeforeResurrect(); - BankBox box = FindBankNoCreate(); + var box = FindBankNoCreate(); if (box?.Opened == true) box.Close(); @@ -4068,12 +4052,12 @@ namespace Server ProcessDeltaQueue(); - for (int i = Items.Count - 1; i >= 0; --i) + for (var i = Items.Count - 1; i >= 0; --i) { if (i >= Items.Count) continue; - Item item = Items[i]; + var item = Items[i]; if (item.ItemID == 0x204E) item.Delete(); @@ -4084,13 +4068,13 @@ namespace Server OnAfterResurrect(); - //Send( new DeathStatus( false ) ); + // Send( new DeathStatus( false ) ); } } public void DropHolding() { - Item holding = m_Holding; + var holding = m_Holding; if (holding != null) { @@ -4193,7 +4177,7 @@ namespace Server if (!OnBeforeDeath()) return; - BankBox box = FindBankNoCreate(); + var box = FindBankNoCreate(); if (box?.Opened == true) box.Close(); @@ -4201,7 +4185,7 @@ namespace Server m_NetState?.CancelAllTrades(); m_Spell?.OnCasterKilled(); - //m_Spell.Disturb( DisturbType.Kill ); + // m_Spell.Disturb( DisturbType.Kill ); m_Target?.Cancel(this, TargetCancelType.Canceled); @@ -4232,48 +4216,48 @@ namespace Server m_FrozenTimer?.Stop(); } - List content = new List(); - List equip = new List(); - List moveToPack = new List(); + var content = new List(); + var equip = new List(); + var moveToPack = new List(); - List itemsCopy = new List(Items); + var itemsCopy = new List(Items); - Container pack = Backpack; + var pack = Backpack; - for (int i = 0; i < itemsCopy.Count; ++i) + for (var i = 0; i < itemsCopy.Count; ++i) { - Item item = itemsCopy[i]; + var item = itemsCopy[i]; if (item == pack) continue; - DeathMoveResult res = GetParentMoveResultFor(item); + var res = GetParentMoveResultFor(item); switch (res) { case DeathMoveResult.MoveToCorpse: - { - content.Add(item); - equip.Add(item); - break; - } + { + content.Add(item); + equip.Add(item); + break; + } case DeathMoveResult.MoveToBackpack: - { - moveToPack.Add(item); - break; - } + { + moveToPack.Add(item); + break; + } } } if (pack != null) { - List packCopy = new List(pack.Items); + var packCopy = new List(pack.Items); - for (int i = 0; i < packCopy.Count; ++i) + for (var i = 0; i < packCopy.Count; ++i) { - Item item = packCopy[i]; + var item = packCopy[i]; - DeathMoveResult res = GetInventoryMoveResultFor(item); + var res = GetInventoryMoveResultFor(item); if (res == DeathMoveResult.MoveToCorpse) content.Add(item); @@ -4281,9 +4265,9 @@ namespace Server moveToPack.Add(item); } - for (int i = 0; i < moveToPack.Count; ++i) + for (var i = 0; i < moveToPack.Count; ++i) { - Item item = moveToPack[i]; + var item = moveToPack[i]; if (RetainPackLocsOnDeath && item.Parent == pack) continue; @@ -4300,24 +4284,23 @@ namespace Server if (m_FacialHair != null) facialhair = new FacialHairInfo(m_FacialHair.ItemID, m_FacialHair.Hue); - Container c = CreateCorpseHandler?.Invoke(this, hair, facialhair, content, equip); - + var c = CreateCorpseHandler?.Invoke(this, hair, facialhair, content, equip); /*m_Corpse = c; for ( int i = 0; c != null && i < content.Count; ++i ) c.DropItem( (Item)content[i] ); - if ( c != null ) + if (c != null) c.MoveToWorld( this.Location, this.Map );*/ if (m_Map != null) { Packet animPacket = null; - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state != m_NetState) { animPacket ??= Packet.Acquire(new DeathAnimation(this, c)); @@ -4352,7 +4335,7 @@ namespace Server /// public virtual void OnDeath(Container c) { - int sound = GetDeathSound(); + var sound = GetDeathSound(); if (sound >= 0) Effects.PlaySound(this, Map, sound); @@ -4368,10 +4351,10 @@ namespace Server Warmode = false; BodyMod = 0; - //Body = this.Female ? 0x193 : 0x192; + // Body = this.Female ? 0x193 : 0x192; Body = Race.GhostBody(this); - Item deathShroud = new Item(0x204E) { Movable = false, Layer = Layer.OuterTorso }; + var deathShroud = new Item(0x204E) { Movable = false, Layer = Layer.OuterTorso }; AddItem(deathShroud); @@ -4407,8 +4390,8 @@ namespace Server if (m_Spell?.OnCasterUsingObject(item) == false) return; - IEntity root = item.RootParent; - bool okay = false; + var root = item.RootParent; + var okay = false; if (!Utility.InUpdateRange(this, item.GetWorldLocation())) { @@ -4420,7 +4403,7 @@ namespace Server } else if (!item.IsAccessibleTo(this)) { - Region reg = Region.Find(item.GetWorldLocation(), item.Map); + var reg = Region.Find(item.GetWorldLocation(), item.Map); if (reg?.SendInaccessibleMessage(item, this) != true) item.OnDoubleClickNotAccessible(this); @@ -4488,8 +4471,8 @@ namespace Server if (item == null) return; - Mobile from = this; - NetState state = m_NetState; + var from = this; + var state = m_NetState; if (from.AccessLevel >= AccessLevel.GameMaster || Core.TickCount - from.NextActionTime >= 0) { @@ -4529,7 +4512,7 @@ namespace Server } else { - IEntity root = item.RootParent; + var root = item.RootParent; if (root is Mobile mobile && !mobile.CheckNonlocalLift(from, item)) { @@ -4559,22 +4542,22 @@ namespace Server if (amount > item.Amount) amount = item.Amount; - int oldAmount = item.Amount; - //item.Amount = amount; //Set in LiftItemDupe + var oldAmount = item.Amount; + // item.Amount = amount; //Set in LiftItemDupe if (amount < oldAmount) LiftItemDupe(item, amount); - //item.Dupe( oldAmount - amount ); + // item.Dupe( oldAmount - amount ); - Map map = from.Map; + var map = from.Map; if (DragEffects && map != null && (root == null || root is Item)) { - IPooledEnumerable eable = map.GetClientsInRange(from.Location); + var eable = map.GetClientsInRange(from.Location); Packet p = null; - Item rootItem = root as Item; + var rootItem = root as Item; - foreach (NetState ns in eable) + foreach (var ns in eable) if (ns.Mobile != from && ns.Mobile.CanSee(from) && ns.Mobile.InLOS(from) && ns.Mobile.CanSee(root)) { @@ -4594,9 +4577,9 @@ namespace Server eable.Free(); } - Point3D fixLoc = item.Location; - Map fixMap = item.Map; - bool shouldFix = item.Parent == null; + var fixLoc = item.Location; + var fixMap = item.Map; + var shouldFix = item.Parent == null; item.RecordBounce(); item.OnItemLifted(from, item); @@ -4604,7 +4587,7 @@ namespace Server from.Holding = item; - int liftSound = item.GetLiftSound(from); + var liftSound = item.GetLiftSound(from); if (liftSound != -1) from.Send(new PlaySound(liftSound, from)); @@ -4703,16 +4686,16 @@ namespace Server { if (DragEffects && !item.Deleted) { - Map map = m_Map; - IEntity root = item.RootParent; + var map = m_Map; + var root = item.RootParent; if (map != null && (root == null || root is Item)) { - IPooledEnumerable eable = map.GetClientsInRange(m_Location); + var eable = map.GetClientsInRange(m_Location); Packet p = null; - Item rootItem = root as Item; + var rootItem = root as Item; - foreach (NetState ns in eable) + foreach (var ns in eable) { if (ns.StygianAbyss) continue; @@ -4740,16 +4723,16 @@ namespace Server public virtual bool Drop(Item to, Point3D loc) { - Mobile from = this; - Item item = from.Holding; + var from = this; + var item = from.Holding; - bool valid = item != null && item.HeldBy == from && item.Map == Map.Internal; + var valid = item != null && item.HeldBy == from && item.Map == Map.Internal; from.Holding = null; if (!valid) return false; - bool bounced = true; + var bounced = true; item.SetLastMoved(); @@ -4768,16 +4751,16 @@ namespace Server public virtual bool Drop(Point3D loc) { - Mobile from = this; - Item item = from.Holding; + var from = this; + var item = from.Holding; - bool valid = item != null && item.HeldBy == from && item.Map == Map.Internal; + var valid = item != null && item.HeldBy == from && item.Map == Map.Internal; from.Holding = null; if (!valid) return false; - bool bounced = true; + var bounced = true; item.SetLastMoved(); @@ -4796,16 +4779,16 @@ namespace Server public virtual bool Drop(Mobile to, Point3D loc) { - Mobile from = this; - Item item = from.Holding; + var from = this; + var item = from.Holding; - bool valid = item != null && item.HeldBy == from && item.Map == Map.Internal; + var valid = item != null && item.HeldBy == from && item.Map == Map.Internal; from.Holding = null; if (!valid) return false; - bool bounced = true; + var bounced = true; item.SetLastMoved(); @@ -4827,9 +4810,9 @@ namespace Server if (Alive) return false; - StringBuilder sb = new StringBuilder(text.Length, text.Length); + var sb = new StringBuilder(text.Length, text.Length); - for (int i = 0; i < text.Length; ++i) + for (var i = 0; i < text.Length; ++i) sb.Append(text[i] != ' ' ? GhostChars[Utility.Random(GhostChars.Length)] : ' '); text = sb.ToString(); @@ -4854,7 +4837,7 @@ namespace Server if (Alive) return false; - TimeSpan delay = AutoManifestTimeout; + var delay = AutoManifestTimeout; if (delay > TimeSpan.Zero && (!Warmode || m_AutoManifestTimer != null)) { @@ -4865,13 +4848,14 @@ namespace Server return false; } - public virtual bool CheckHearsMutatedSpeech(Mobile m, object context) => context != m_GhostMutateContext || m.Alive && !m.CanHearGhosts; + public virtual bool CheckHearsMutatedSpeech(Mobile m, object context) => + context != m_GhostMutateContext || (m.Alive && !m.CanHearGhosts); private void AddSpeechItemsFrom(List list, Container cont) { - for (int i = 0; i < cont.Items.Count; ++i) + for (var i = 0; i < cont.Items.Count; ++i) { - Item item = cont.Items[i]; + var item = cont.Items[i]; if (item.HandlesOnSpeech) list.Add(item); @@ -4886,7 +4870,7 @@ namespace Server if (Deleted || CommandSystem.Handle(this, text, type)) return; - int range = 15; + var range = 15; switch (type) { @@ -4925,7 +4909,7 @@ namespace Server break; } - SpeechEventArgs regArgs = new SpeechEventArgs(this, text, type, hue, keywords); + var regArgs = new SpeechEventArgs(this, text, type, hue, keywords); EventSink.InvokeSpeech(regArgs); Region.OnSpeech(regArgs); @@ -4939,17 +4923,17 @@ namespace Server if (string.IsNullOrEmpty(text)) return; - List hears = m_Hears; - List onSpeech = m_OnSpeech; + var hears = m_Hears; + var onSpeech = m_OnSpeech; if (m_Map != null) { - IPooledEnumerable eable = m_Map.GetObjectsInRange(m_Location, range); + var eable = m_Map.GetObjectsInRange(m_Location, range); - foreach (IEntity o in eable) + foreach (var o in eable) if (o is Mobile heard) { - if (!heard.CanSee(this) || !NoSpeechLOS && heard.Player && !heard.InLOS(this)) + if (!heard.CanSee(this) || (!NoSpeechLOS && heard.Player && !heard.InLOS(this))) continue; if (heard.m_NetState != null) @@ -4958,9 +4942,9 @@ namespace Server if (heard.HandlesOnSpeech(this)) onSpeech.Add(heard); - for (int i = 0; i < heard.Items.Count; ++i) + for (var i = 0; i < heard.Items.Count; ++i) { - Item item = heard.Items[i]; + var item = heard.Items[i]; if (item.HandlesOnSpeech) onSpeech.Add(item); @@ -4981,11 +4965,11 @@ namespace Server eable.Free(); object mutateContext = null; - string mutatedText = text; + var mutatedText = text; SpeechEventArgs mutatedArgs = null; if (MutateSpeech(hears, ref mutatedText, ref mutateContext)) - mutatedArgs = new SpeechEventArgs(this, mutatedText, type, hue, new int[0]); + mutatedArgs = new SpeechEventArgs(this, mutatedText, type, hue, Array.Empty()); CheckSpeechManifest(); @@ -4996,15 +4980,15 @@ namespace Server // TODO: Should this be sorted like onSpeech is below? - for (int i = 0; i < hears.Count; ++i) + for (var i = 0; i < hears.Count; ++i) { - Mobile heard = hears[i]; + var heard = hears[i]; if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext)) { heard.OnSpeech(regArgs); - NetState ns = heard.NetState; + var ns = heard.NetState; if (ns != null) { @@ -5017,7 +5001,7 @@ namespace Server { heard.OnSpeech(mutatedArgs); - NetState ns = heard.NetState; + var ns = heard.NetState; if (ns != null) { @@ -5034,9 +5018,9 @@ namespace Server if (onSpeech.Count > 1) onSpeech.Sort(LocationComparer.GetInstance(this)); - for (int i = 0; i < onSpeech.Count; ++i) + for (var i = 0; i < onSpeech.Count; ++i) { - IEntity obj = onSpeech[i]; + var obj = onSpeech[i]; if (obj is Mobile heard) { @@ -5065,12 +5049,12 @@ namespace Server public DamageEntry FindMostRecentDamageEntry(bool allowSelf) { - for (int i = DamageEntries.Count - 1; i >= 0; --i) + for (var i = DamageEntries.Count - 1; i >= 0; --i) { if (i >= DamageEntries.Count) continue; - DamageEntry de = DamageEntries[i]; + var de = DamageEntries[i]; if (de.HasExpired) DamageEntries.RemoveAt(i); @@ -5085,12 +5069,12 @@ namespace Server public DamageEntry FindLeastRecentDamageEntry(bool allowSelf) { - for (int i = 0; i < DamageEntries.Count; ++i) + for (var i = 0; i < DamageEntries.Count; ++i) { if (i < 0) continue; - DamageEntry de = DamageEntries[i]; + var de = DamageEntries[i]; if (de.HasExpired) { @@ -5112,12 +5096,12 @@ namespace Server { DamageEntry mostTotal = null; - for (int i = DamageEntries.Count - 1; i >= 0; --i) + for (var i = DamageEntries.Count - 1; i >= 0; --i) { if (i >= DamageEntries.Count) continue; - DamageEntry de = DamageEntries[i]; + var de = DamageEntries[i]; if (de.HasExpired) DamageEntries.RemoveAt(i); @@ -5134,12 +5118,12 @@ namespace Server { DamageEntry mostTotal = null; - for (int i = DamageEntries.Count - 1; i >= 0; --i) + for (var i = DamageEntries.Count - 1; i >= 0; --i) { if (i >= DamageEntries.Count) continue; - DamageEntry de = DamageEntries[i]; + var de = DamageEntries[i]; if (de.HasExpired) DamageEntries.RemoveAt(i); @@ -5152,12 +5136,12 @@ namespace Server public DamageEntry FindDamageEntryFor(Mobile m) { - for (int i = DamageEntries.Count - 1; i >= 0; --i) + for (var i = DamageEntries.Count - 1; i >= 0; --i) { if (i >= DamageEntries.Count) continue; - DamageEntry de = DamageEntries[i]; + var de = DamageEntries[i]; if (de.HasExpired) DamageEntries.RemoveAt(i); @@ -5172,7 +5156,7 @@ namespace Server public virtual DamageEntry RegisterDamage(int amount, Mobile from) { - DamageEntry de = FindDamageEntryFor(from) ?? new DamageEntry(from); + var de = FindDamageEntryFor(from) ?? new DamageEntry(from); de.DamageGiven += amount; de.LastDamage = DateTime.UtcNow; @@ -5180,16 +5164,16 @@ namespace Server DamageEntries.Remove(de); DamageEntries.Add(de); - Mobile master = from.GetDamageMaster(this); + var master = from.GetDamageMaster(this); if (master != null) { - List list = de.Responsible; + var list = de.Responsible; if (list == null) de.Responsible = list = new List(); - DamageEntry resp = list.FirstOrDefault(check => check.Damager == master); + var resp = list.FirstOrDefault(check => check.Damager == master); if (resp == null) list.Add(resp = new DamageEntry(master)); @@ -5234,13 +5218,13 @@ namespace Server if (amount > 0) { - int oldHits = Hits; - int newHits = oldHits - amount; + var oldHits = Hits; + var newHits = oldHits - amount; m_Spell?.OnCasterHurt(); - //if ( m_Spell != null && m_Spell.State == SpellState.Casting ) - // m_Spell.Disturb( DisturbType.Hurt, false, true ); + // if (m_Spell != null && m_Spell.State == SpellState.Casting) + // m_Spell.Disturb( DisturbType.Hurt, false, true ); if (from != null) RegisterDamage(amount, from); @@ -5252,25 +5236,25 @@ namespace Server switch (VisibleDamageType) { case VisibleDamageType.Related: - { - SendVisibleDamageRelated(from, amount); - break; - } + { + SendVisibleDamageRelated(from, amount); + break; + } case VisibleDamageType.Everyone: - { - SendVisibleDamageEveryone(amount); - break; - } + { + SendVisibleDamageEveryone(amount); + break; + } case VisibleDamageType.Selective: - { - SendVisibleDamageSelective(from, amount); - break; - } + { + SendVisibleDamageSelective(from, amount); + break; + } } OnDamage(amount, from, newHits < 0); - IMount m = Mount; + var m = Mount; if (m != null && informMount) m.OnRiderDamaged(amount, from, newHits < 0); @@ -5296,7 +5280,7 @@ namespace Server if (ourState == null) { - Mobile master = GetDamageMaster(from); + var master = GetDamageMaster(from); if (master != null) ourState = master.m_NetState; @@ -5304,7 +5288,7 @@ namespace Server if (theirState == null && from != null) { - Mobile master = from.GetDamageMaster(this); + var master = from.GetDamageMaster(this); if (master != null) theirState = master.m_NetState; @@ -5316,15 +5300,16 @@ namespace Server if (ourState != null) { - p = ourState.DamagePacket ? Packet.Acquire(new DamagePacket(this, amount)) : - Packet.Acquire(new DamagePacketOld(this, amount)); + p = ourState.DamagePacket + ? Packet.Acquire(new DamagePacket(this, amount)) + : Packet.Acquire(new DamagePacketOld(this, amount)); ourState.Send(p); } if (theirState != null && theirState != ourState) { - bool newPacket = theirState.DamagePacket; + var newPacket = theirState.DamagePacket; if (newPacket && !(p is DamagePacket)) { @@ -5349,17 +5334,17 @@ namespace Server if (amount < 0) return; - Map map = m_Map; + var map = m_Map; if (map == null) return; - IPooledEnumerable eable = map.GetClientsInRange(m_Location); + var eable = map.GetClientsInRange(m_Location); Packet pNew = null; Packet pOld = null; - foreach (NetState ns in eable) + foreach (var ns in eable) if (ns.Mobile.CanSee(this)) { if (ns.DamagePacket) @@ -5386,12 +5371,12 @@ namespace Server { NetState ourState = m_NetState, theirState = from?.m_NetState; - Mobile damager = from; - Mobile damaged = this; + var damager = from; + var damaged = this; if (ourState == null) { - Mobile master = GetDamageMaster(from); + var master = GetDamageMaster(from); if (master != null) { @@ -5405,7 +5390,7 @@ namespace Server if (theirState == null && from != null) { - Mobile master = from.GetDamageMaster(this); + var master = from.GetDamageMaster(this); if (master != null) { @@ -5469,313 +5454,313 @@ namespace Server public virtual void Deserialize(IGenericReader reader) { - int version = reader.ReadInt(); + var version = reader.ReadInt(); switch (version) { case 32: - { - // Removed StuckMenu - goto case 31; - } + { + // Removed StuckMenu + goto case 31; + } case 31: - { - LastStrGain = reader.ReadDeltaTime(); - LastIntGain = reader.ReadDeltaTime(); - LastDexGain = reader.ReadDeltaTime(); + { + LastStrGain = reader.ReadDeltaTime(); + LastIntGain = reader.ReadDeltaTime(); + LastDexGain = reader.ReadDeltaTime(); - goto case 30; - } + goto case 30; + } case 30: - { - byte hairflag = reader.ReadByte(); + { + var hairflag = reader.ReadByte(); - if ((hairflag & 0x01) != 0) - m_Hair = new HairInfo(reader); - if ((hairflag & 0x02) != 0) - m_FacialHair = new FacialHairInfo(reader); + if ((hairflag & 0x01) != 0) + m_Hair = new HairInfo(reader); + if ((hairflag & 0x02) != 0) + m_FacialHair = new FacialHairInfo(reader); - goto case 29; - } + goto case 29; + } case 29: - { - m_Race = reader.ReadRace(); - goto case 28; - } + { + m_Race = reader.ReadRace(); + goto case 28; + } case 28: - { - if (version <= 30) - LastStatGain = reader.ReadDeltaTime(); + { + if (version <= 30) + LastStatGain = reader.ReadDeltaTime(); - goto case 27; - } + goto case 27; + } case 27: - { - m_TithingPoints = reader.ReadInt(); + { + m_TithingPoints = reader.ReadInt(); - goto case 26; - } + goto case 26; + } case 26: case 25: case 24: - { - Corpse = reader.ReadItem() as Container; + { + Corpse = reader.ReadItem() as Container; - goto case 23; - } + goto case 23; + } case 23: - { - CreationTime = reader.ReadDateTime(); + { + CreationTime = reader.ReadDateTime(); - goto case 22; - } + goto case 22; + } case 22: // Just removed followers case 21: - { - Stabled = reader.ReadStrongMobileList(); + { + Stabled = reader.ReadStrongMobileList(); - goto case 20; - } + goto case 20; + } case 20: - { - CantWalk = reader.ReadBool(); + { + CantWalk = reader.ReadBool(); - goto case 19; - } + goto case 19; + } case 19: // Just removed variables case 18: - { - Virtues = new VirtueInfo(reader); + { + Virtues = new VirtueInfo(reader); - goto case 17; - } + goto case 17; + } case 17: - { - Thirst = reader.ReadInt(); - BAC = reader.ReadInt(); + { + Thirst = reader.ReadInt(); + BAC = reader.ReadInt(); - goto case 16; - } + goto case 16; + } case 16: - { - m_ShortTermMurders = reader.ReadInt(); - - if (version <= 24) { - reader.ReadDateTime(); - reader.ReadDateTime(); - } + m_ShortTermMurders = reader.ReadInt(); - goto case 15; - } - case 15: - { - if (version < 22) - reader.ReadInt(); // followers - - m_FollowersMax = reader.ReadInt(); - - goto case 14; - } - case 14: - { - MagicDamageAbsorb = reader.ReadInt(); - - goto case 13; - } - case 13: - { - GuildFealty = reader.ReadMobile(); - - goto case 12; - } - case 12: - { - m_Guild = reader.ReadGuild(); - - goto case 11; - } - case 11: - { - m_DisplayGuildTitle = reader.ReadBool(); - - goto case 10; - } - case 10: - { - CanSwim = reader.ReadBool(); - - goto case 9; - } - case 9: - { - Squelched = reader.ReadBool(); - - goto case 8; - } - case 8: - { - m_Holding = reader.ReadItem(); - - goto case 7; - } - case 7: - { - m_VirtualArmor = reader.ReadInt(); - - goto case 6; - } - case 6: - { - BaseSoundID = reader.ReadInt(); - - goto case 5; - } - case 5: - { - DisarmReady = reader.ReadBool(); - StunReady = reader.ReadBool(); - - goto case 4; - } - case 4: - { - if (version <= 25) Poison.Deserialize(reader); - - goto case 3; - } - case 3: - { - m_StatCap = reader.ReadInt(); - - goto case 2; - } - case 2: - { - NameHue = reader.ReadInt(); - - goto case 1; - } - case 1: - { - m_Hunger = reader.ReadInt(); - - goto case 0; - } - case 0: - { - if (version < 21) - Stabled = new List(); - - if (version < 18) - Virtues = new VirtueInfo(); - - if (version < 11) - m_DisplayGuildTitle = true; - - if (version < 3) - m_StatCap = 225; - - if (version < 15) - { - m_Followers = 0; - m_FollowersMax = 5; - } - - m_Location = reader.ReadPoint3D(); - m_Body = new Body(reader.ReadInt()); - m_Name = reader.ReadString(); - m_GuildTitle = reader.ReadString(); - m_Criminal = reader.ReadBool(); - m_Kills = reader.ReadInt(); - SpeechHue = reader.ReadInt(); - EmoteHue = reader.ReadInt(); - WhisperHue = reader.ReadInt(); - YellHue = reader.ReadInt(); - m_Language = reader.ReadString(); - m_Female = reader.ReadBool(); - m_Warmode = reader.ReadBool(); - m_Hidden = reader.ReadBool(); - m_Direction = (Direction)reader.ReadByte(); - m_Hue = reader.ReadInt(); - m_Str = reader.ReadInt(); - m_Dex = reader.ReadInt(); - m_Int = reader.ReadInt(); - m_Hits = reader.ReadInt(); - m_Stam = reader.ReadInt(); - m_Mana = reader.ReadInt(); - m_Map = reader.ReadMap(); - m_Blessed = reader.ReadBool(); - m_Fame = reader.ReadInt(); - m_Karma = reader.ReadInt(); - m_AccessLevel = (AccessLevel)reader.ReadByte(); - - Skills = new Skills(this, reader); - - Items = reader.ReadStrongItemList(); - - m_Player = reader.ReadBool(); - m_Title = reader.ReadString(); - Profile = reader.ReadString(); - ProfileLocked = reader.ReadBool(); - - if (version <= 18) - { - reader.ReadInt(); - reader.ReadInt(); - reader.ReadInt(); - } - - AutoPageNotify = reader.ReadBool(); - - LogoutLocation = reader.ReadPoint3D(); - LogoutMap = reader.ReadMap(); - - m_StrLock = (StatLockType)reader.ReadByte(); - m_DexLock = (StatLockType)reader.ReadByte(); - m_IntLock = (StatLockType)reader.ReadByte(); - - StatMods = new List(); - SkillMods = new List(); - - if (version < 32) - if (reader.ReadBool()) + if (version <= 24) { - int count = reader.ReadInt(); - for (int i = 0; i < count; ++i) reader.ReadDateTime(); + reader.ReadDateTime(); + reader.ReadDateTime(); } - if (m_Player && m_Map != Map.Internal) - { - LogoutLocation = m_Location; - LogoutMap = m_Map; - - m_Map = Map.Internal; + goto case 15; } - - m_Map?.OnEnter(this); - - if (m_Criminal) + case 15: { - m_ExpireCriminal ??= new ExpireCriminalTimer(this); + if (version < 22) + reader.ReadInt(); // followers - m_ExpireCriminal.Start(); + m_FollowersMax = reader.ReadInt(); + + goto case 14; } + case 14: + { + MagicDamageAbsorb = reader.ReadInt(); - if (ShouldCheckStatTimers) - CheckStatTimers(); + goto case 13; + } + case 13: + { + GuildFealty = reader.ReadMobile(); - if (!m_Player && m_Dex <= 100 && m_CombatTimer != null) - m_CombatTimer.Priority = TimerPriority.FiftyMS; - else if (m_CombatTimer != null) - m_CombatTimer.Priority = TimerPriority.EveryTick; + goto case 12; + } + case 12: + { + m_Guild = reader.ReadGuild(); - UpdateRegion(); + goto case 11; + } + case 11: + { + m_DisplayGuildTitle = reader.ReadBool(); - UpdateResistances(); + goto case 10; + } + case 10: + { + CanSwim = reader.ReadBool(); - break; - } + goto case 9; + } + case 9: + { + Squelched = reader.ReadBool(); + + goto case 8; + } + case 8: + { + m_Holding = reader.ReadItem(); + + goto case 7; + } + case 7: + { + m_VirtualArmor = reader.ReadInt(); + + goto case 6; + } + case 6: + { + BaseSoundID = reader.ReadInt(); + + goto case 5; + } + case 5: + { + DisarmReady = reader.ReadBool(); + StunReady = reader.ReadBool(); + + goto case 4; + } + case 4: + { + if (version <= 25) Poison.Deserialize(reader); + + goto case 3; + } + case 3: + { + m_StatCap = reader.ReadInt(); + + goto case 2; + } + case 2: + { + NameHue = reader.ReadInt(); + + goto case 1; + } + case 1: + { + m_Hunger = reader.ReadInt(); + + goto case 0; + } + case 0: + { + if (version < 21) + Stabled = new List(); + + if (version < 18) + Virtues = new VirtueInfo(); + + if (version < 11) + m_DisplayGuildTitle = true; + + if (version < 3) + m_StatCap = 225; + + if (version < 15) + { + m_Followers = 0; + m_FollowersMax = 5; + } + + m_Location = reader.ReadPoint3D(); + m_Body = new Body(reader.ReadInt()); + m_Name = reader.ReadString(); + m_GuildTitle = reader.ReadString(); + m_Criminal = reader.ReadBool(); + m_Kills = reader.ReadInt(); + SpeechHue = reader.ReadInt(); + EmoteHue = reader.ReadInt(); + WhisperHue = reader.ReadInt(); + YellHue = reader.ReadInt(); + m_Language = reader.ReadString(); + m_Female = reader.ReadBool(); + m_Warmode = reader.ReadBool(); + m_Hidden = reader.ReadBool(); + m_Direction = (Direction)reader.ReadByte(); + m_Hue = reader.ReadInt(); + m_Str = reader.ReadInt(); + m_Dex = reader.ReadInt(); + m_Int = reader.ReadInt(); + m_Hits = reader.ReadInt(); + m_Stam = reader.ReadInt(); + m_Mana = reader.ReadInt(); + m_Map = reader.ReadMap(); + m_Blessed = reader.ReadBool(); + m_Fame = reader.ReadInt(); + m_Karma = reader.ReadInt(); + m_AccessLevel = (AccessLevel)reader.ReadByte(); + + Skills = new Skills(this, reader); + + Items = reader.ReadStrongItemList(); + + m_Player = reader.ReadBool(); + m_Title = reader.ReadString(); + Profile = reader.ReadString(); + ProfileLocked = reader.ReadBool(); + + if (version <= 18) + { + reader.ReadInt(); + reader.ReadInt(); + reader.ReadInt(); + } + + AutoPageNotify = reader.ReadBool(); + + LogoutLocation = reader.ReadPoint3D(); + LogoutMap = reader.ReadMap(); + + m_StrLock = (StatLockType)reader.ReadByte(); + m_DexLock = (StatLockType)reader.ReadByte(); + m_IntLock = (StatLockType)reader.ReadByte(); + + StatMods = new List(); + SkillMods = new List(); + + if (version < 32) + if (reader.ReadBool()) + { + var count = reader.ReadInt(); + for (var i = 0; i < count; ++i) reader.ReadDateTime(); + } + + if (m_Player && m_Map != Map.Internal) + { + LogoutLocation = m_Location; + LogoutMap = m_Map; + + m_Map = Map.Internal; + } + + m_Map?.OnEnter(this); + + if (m_Criminal) + { + m_ExpireCriminal ??= new ExpireCriminalTimer(this); + + m_ExpireCriminal.Start(); + } + + if (ShouldCheckStatTimers) + CheckStatTimers(); + + if (!m_Player && m_Dex <= 100 && m_CombatTimer != null) + m_CombatTimer.Priority = TimerPriority.FiftyMS; + else if (m_CombatTimer != null) + m_CombatTimer.Priority = TimerPriority.EveryTick; + + UpdateRegion(); + + UpdateResistances(); + + break; + } } if (!m_Player) @@ -5783,11 +5768,6 @@ namespace Server Utility.Intern(ref m_Title); Utility.Intern(ref m_Language); - - /* //Moved into cleanup in scripts. - if ( version < 30 ) - Timer.DelayCall( TimeSpan.Zero, new TimerCallback( ConvertHair ) ); - * */ } public void ConvertHair() @@ -5986,7 +5966,7 @@ namespace Server { item.SendRemovePacket(); - //int oldCount = m_Items.Count; + // int oldCount = m_Items.Count; Items.Remove(item); @@ -6010,32 +5990,30 @@ namespace Server public virtual void Animate(int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay) { - Map map = m_Map; + var map = m_Map; if (map == null) return; ProcessDelta(); Packet p = null; - //Packet pNew = null; + // Packet pNew = null; - IPooledEnumerable eable = map.GetClientsInRange(m_Location); + var eable = map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state.Mobile.CanSee(this)) { state.Mobile.ProcessDelta(); - //if ( state.StygianAbyss ) { - //if ( pNew == null ) - //pNew = Packet.Acquire( new NewMobileAnimation( this, action, frameCount, delay ) ); + // if (state.StygianAbyss ) { + // if (pNew == null) + // pNew = Packet.Acquire( new NewMobileAnimation( this, action, frameCount, delay ) ); - //state.Send( pNew ); - //} else { + // state.Send( pNew ); + // } else { if (p == null) { - #region SA - if (Body.IsGargoyle) { frameCount = 10; @@ -6064,18 +6042,16 @@ namespace Server } } - #endregion - p = Packet.Acquire(new MobileAnimation(this, action, frameCount, repeatCount, forward, repeat, delay)); } state.Send(p); - //} + // } } Packet.Release(p); - //Packet.Release( pNew ); + // Packet.Release( pNew ); eable.Free(); } @@ -6097,11 +6073,11 @@ namespace Server if (soundID == -1 || m_Map == null) return; - Packet p = Packet.Acquire(new PlaySound(soundID, this)); + var p = Packet.Acquire(new PlaySound(soundID, this)); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state.Mobile.CanSee(this)) state.Send(p); @@ -6141,9 +6117,9 @@ namespace Server if (m_Map == null) return; - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state != m_NetState && (everyone || !state.Mobile.CanSee(this))) state.Send(RemovePacket); @@ -6155,9 +6131,9 @@ namespace Server if (m_Map == null || m_NetState == null) return; - IPooledEnumerable eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); + var eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); - foreach (IEntity o in eable) + foreach (var o in eable) if (o is Mobile m) { if (m != this && Utility.InUpdateRange(m_Location, m.m_Location)) @@ -6199,7 +6175,7 @@ namespace Server if (Core.ML) SendLocalizedMessage(500168); // You can not say anything, you have been muted. else - SendMessage("You can not say anything, you have been squelched."); //Cliloc ITSELF changed during ML. + SendMessage("You can not say anything, you have been squelched."); // Cliloc ITSELF changed during ML. e.Blocked = true; } @@ -6221,13 +6197,13 @@ namespace Server public void SendEverything() { - NetState ns = m_NetState; + var ns = m_NetState; if (m_Map != null && ns != null) { - IPooledEnumerable eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); + var eable = m_Map.GetObjectsInRange(m_Location, Core.GlobalMaxUpdateRange); - foreach (IEntity o in eable) + foreach (var o in eable) if (o is Item item) { if (CanSee(item) && InRange(item.Location, item.GetUpdateRange(this))) @@ -6264,7 +6240,7 @@ namespace Server if (Deleted) return; - Region newRegion = Region.Find(m_Location, m_Map); + var newRegion = Region.Find(m_Location, m_Map); if (newRegion != m_Region) { @@ -6282,7 +6258,6 @@ namespace Server { } - public void SetDirection(Direction dir) { m_Direction = dir; @@ -6292,7 +6267,7 @@ namespace Server public virtual int GetPacketFlags() { - int flags = 0x0; + var flags = 0x0; if (m_Paralyzed || m_Frozen) flags |= 0x01; @@ -6318,7 +6293,7 @@ namespace Server // Pre-7.0.0.0 Packet Flags public virtual int GetOldPacketFlags() { - int flags = 0x0; + var flags = 0x0; if (m_Paralyzed || m_Frozen) flags |= 0x01; @@ -6363,9 +6338,9 @@ namespace Server if (m_Map == null) return; - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (!state.Mobile.CanSee(this)) { state.Send(RemovePacket); @@ -6432,7 +6407,7 @@ namespace Server if (item is SecureTradeContainer container) { - SecureTrade trade = container.Trade; + var trade = container.Trade; if (trade != null && trade.From.Mobile != this && trade.To.Mobile != this) return false; @@ -6446,14 +6421,15 @@ namespace Server if (Deleted || m.Deleted || m_Map == Map.Internal || m.m_Map == Map.Internal) return false; - return this == m || m.m_Map == m_Map && - (!m.Hidden || m_AccessLevel != AccessLevel.Player && - (m_AccessLevel >= m.AccessLevel || m_AccessLevel >= AccessLevel.Administrator)) && - (m.Alive || Core.SE && Skills.SpiritSpeak.Value >= 100.0 || !Alive || - m_AccessLevel > AccessLevel.Player || m.Warmode); + return this == m || (m.m_Map == m_Map && + (!m.Hidden || (m_AccessLevel != AccessLevel.Player && + (m_AccessLevel >= m.AccessLevel || m_AccessLevel >= AccessLevel.Administrator))) && + (m.Alive || (Core.SE && Skills.SpiritSpeak.Value >= 100.0) || !Alive || + m_AccessLevel > AccessLevel.Player || m.Warmode)); } - public virtual bool CanBeRenamedBy(Mobile from) => from.AccessLevel >= AccessLevel.GameMaster && from.m_AccessLevel > m_AccessLevel; + public virtual bool CanBeRenamedBy(Mobile from) => + from.AccessLevel >= AccessLevel.GameMaster && from.m_AccessLevel > m_AccessLevel; public virtual void OnGuildTitleChange(string oldTitle) { @@ -6469,9 +6445,9 @@ namespace Server public virtual int SafeBody(int body) { - int delta = -1; + var delta = -1; - for (int i = 0; delta < 0 && i < m_InvalidBodies.Length; ++i) + for (var i = 0; delta < 0 && i < m_InvalidBodies.Length; ++i) delta = m_InvalidBodies[i] - body; return delta != 0 ? body : 0; @@ -6486,7 +6462,7 @@ namespace Server public ObjectPropertyList NewObjectPropertyList() { - ObjectPropertyList list = new ObjectPropertyList(this); + var list = new ObjectPropertyList(this); GetProperties(list); @@ -6508,7 +6484,7 @@ namespace Server if (m_Map != null && m_Map != Map.Internal && !World.Loading) { - ObjectPropertyList oldList = m_PropertyList; + var oldList = m_PropertyList; m_PropertyList = null; if (oldList != null && oldList.Hash != PropertyList.Hash) @@ -6528,7 +6504,7 @@ namespace Server if (Deleted) return; - Point3D oldLocation = m_Location; + var oldLocation = m_Location; if (oldLocation == newLocation) return; @@ -6536,7 +6512,7 @@ namespace Server m_Location = newLocation; UpdateRegion(); - BankBox box = FindBankNoCreate(); + var box = FindBankNoCreate(); if (box?.Opened == true) box.Close(); @@ -6557,34 +6533,34 @@ namespace Server ClearFastwalkStack(); } - Map map = m_Map; + var map = m_Map; if (map != null) { // First, send a remove message to everyone who can no longer see us. (inOldRange && !inNewRange) - IPooledEnumerable eable = map.GetClientsInRange(oldLocation); + var eable = map.GetClientsInRange(oldLocation); - foreach (NetState ns in eable) + foreach (var ns in eable) if (ns != m_NetState && !Utility.InUpdateRange(newLocation, ns.Mobile.Location)) ns.Send(RemovePacket); eable.Free(); - NetState ourState = m_NetState; + var ourState = m_NetState; // Check to see if we are attached to a client if (ourState != null) { - IPooledEnumerable eeable = map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange); + var eeable = map.GetObjectsInRange(newLocation, Core.GlobalMaxUpdateRange); // We are attached to a client, so it's a bit more complex. We need to send new items and people to ourself, and ourself to other clients - foreach (IEntity o in eeable) + foreach (var o in eeable) if (o is Item item) { - int range = item.GetUpdateRange(this); - Point3D loc = item.Location; + var range = item.GetUpdateRange(this); + var loc = item.Location; if (!Utility.InRange(oldLocation, loc, range) && Utility.InRange(newLocation, loc, range) && CanSee(item)) @@ -6595,19 +6571,19 @@ namespace Server if (!Utility.InUpdateRange(newLocation, m.m_Location)) continue; - bool inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location); + var inOldRange = Utility.InUpdateRange(oldLocation, m.m_Location); if (m.m_NetState != null && - (isTeleport && (!m.m_NetState.HighSeas || !NoMoveHS) || !inOldRange) && m.CanSee(this)) + ((isTeleport && (!m.m_NetState.HighSeas || !NoMoveHS)) || !inOldRange) && m.CanSee(this)) { m.m_NetState.Send(MobileIncoming.Create(m.m_NetState, m, this)); if (m.m_NetState.StygianAbyss) { - //if ( m_Poison != null ) + // if (m_Poison != null) m.m_NetState.Send(new HealthbarPoison(this)); - //if ( m_Blessed || m_YellowHealthbar ) + // if (m_Blessed || m_YellowHealthbar) m.m_NetState.Send(new HealthbarYellow(this)); } @@ -6624,10 +6600,10 @@ namespace Server if (ourState.StygianAbyss) { - //if ( m.Poisoned ) + // if (m.Poisoned) ourState.Send(new HealthbarPoison(m)); - //if ( m.Blessed || m.YellowHealthbar ) + // if (m.Blessed || m.YellowHealthbar) ourState.Send(new HealthbarYellow(m)); } @@ -6644,18 +6620,18 @@ namespace Server eable = map.GetClientsInRange(newLocation); // We're not attached to a client, so simply send an Incoming - foreach (NetState ns in eable) - if ((isTeleport && (!ns.HighSeas || !NoMoveHS) || + foreach (var ns in eable) + if (((isTeleport && (!ns.HighSeas || !NoMoveHS)) || !Utility.InUpdateRange(oldLocation, ns.Mobile.Location)) && ns.Mobile.CanSee(this)) { ns.Send(MobileIncoming.Create(ns, ns.Mobile, this)); if (ns.StygianAbyss) { - //if ( m_Poison != null ) + // if (m_Poison != null) ns.Send(new HealthbarPoison(this)); - //if ( m_Blessed || m_YellowHealthbar ) + // if (m_Blessed || m_YellowHealthbar) ns.Send(new HealthbarYellow(this)); } @@ -6695,12 +6671,12 @@ namespace Server public Item FindItemOnLayer(Layer layer) { - List eq = Items; - int count = eq.Count; + var eq = Items; + var count = eq.Count; - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - Item item = eq[i]; + var item = eq[i]; if (!item.Deleted && item.Layer == layer) return item; } @@ -6713,9 +6689,9 @@ namespace Server if (m_Map == null) return; - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state.Mobile.CanSee(this)) { state.Send(MobileIncoming.Create(state, state.Mobile, this)); @@ -6753,8 +6729,8 @@ namespace Server if (!PlaceInBackpack(item)) { - Point3D loc = m_Location; - Map map = m_Map; + var loc = m_Location; + var map = m_Map; if ((map == null || map == Map.Internal) && LogoutMap != null) { @@ -6771,7 +6747,8 @@ namespace Server public virtual bool CheckLift(Mobile from, Item item, ref LRReason reject) => true; - public virtual bool CheckNonlocalLift(Mobile from, Item item) => from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster; + public virtual bool CheckNonlocalLift(Mobile from, Item item) => + from == this || (from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster); public virtual bool CheckTrade(Mobile to, Item item, SecureTradeContainer cont, bool message, bool checkItems, int plusItems, int plusWeight) => @@ -6781,12 +6758,12 @@ namespace Server { if (!from.Player || !Player || !from.Alive || !Alive) return false; - NetState ourState = m_NetState; - NetState theirState = from.m_NetState; + var ourState = m_NetState; + var theirState = from.m_NetState; if (ourState == null || theirState == null) return false; - SecureTradeContainer cont = theirState.FindTradeContainer(this); + var cont = theirState.FindTradeContainer(this); if (!from.CheckTrade(this, offer, cont, true, true, 0, 0)) return false; @@ -6808,7 +6785,7 @@ namespace Server { if (from == this) { - Container pack = Backpack; + var pack = Backpack; return pack != null && dropped.DropToItem(from, pack, new Point3D(-1, -1, 0)); } @@ -6817,7 +6794,7 @@ namespace Server public virtual bool CheckEquip(Item item) { - for (int i = 0; i < Items.Count; ++i) + for (var i = 0; i < Items.Count; ++i) if (Items[i].CheckConflictingLayer(this, item, item.Layer) || item.CheckConflictingLayer(this, Items[i], Items[i].Layer)) return false; @@ -6852,13 +6829,13 @@ namespace Server /// /// public override bool OnDragLift( Item item ) /// { - /// if ( item is Pickaxe && this.Str < 60 ) - /// { - /// SendMessage( "That is too heavy for you to lift." ); - /// return false; - /// } + /// if (item is Pickaxe && this.Str < 60) + /// { + /// SendMessage( "That is too heavy for you to lift." ); + /// return false; + /// } /// - /// return base.OnDragLift( item ); + /// return base.OnDragLift( item ); /// } /// public virtual bool OnDragLift(Item item) => true; @@ -6913,7 +6890,8 @@ namespace Server { } - public virtual bool CheckNonlocalDrop(Mobile from, Item item, Item target) => from == this || from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster; + public virtual bool CheckNonlocalDrop(Mobile from, Item item, Item target) => + from == this || (from.AccessLevel > AccessLevel && from.AccessLevel >= AccessLevel.GameMaster); public virtual bool CheckItemUse(Mobile from, Item item) => true; @@ -6928,7 +6906,8 @@ namespace Server public virtual bool AllowItemUse(Item item) => true; - public virtual bool AllowEquipFrom(Mobile mob) => mob == this || mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > AccessLevel; + public virtual bool AllowEquipFrom(Mobile mob) => + mob == this || (mob.AccessLevel >= AccessLevel.GameMaster && mob.AccessLevel > AccessLevel); public virtual bool EquipItem(Item item) { @@ -6940,8 +6919,8 @@ namespace Server if (m_Spell?.OnCasterEquipping(item) == false) return false; - //if ( m_Spell != null && m_Spell.State == SpellState.Casting ) - // m_Spell.Disturb( DisturbType.EquipRequest ); + // if (m_Spell != null && m_Spell.State == SpellState.Casting) + // m_Spell.Disturb( DisturbType.EquipRequest ); AddItem(item); return true; @@ -6988,7 +6967,7 @@ namespace Server try { - using (StreamWriter op = new StreamWriter("delta-recursion.log", true)) + using (var op = new StreamWriter("delta-recursion.log", true)) { op.WriteLine("# {0}", DateTime.UtcNow); op.WriteLine(new StackTrace()); @@ -7016,12 +6995,15 @@ namespace Server Parallel.ForEach(m_DeltaQueue, m => m.ProcessDelta()); m_DeltaQueue.Clear(); } - else while (m_DeltaQueue.TryDequeue(out Mobile m)) - m.ProcessDelta(); + else + { + while (m_DeltaQueue.TryDequeue(out var m)) + m.ProcessDelta(); + } _processing = false; - while (m_DeltaQueueR.TryDequeue(out Mobile m)) + while (m_DeltaQueueR.TryDequeue(out var m)) m.ProcessDelta(); } @@ -7100,7 +7082,7 @@ namespace Server /// /// Overridable. Virtual event invoked when changes. /// - public virtual void OnRegionChange(Region Old, Region New) + public virtual void OnRegionChange(Region old, Region @new) { } @@ -7110,16 +7092,16 @@ namespace Server public virtual void OnSingleClick(Mobile from) { if (Deleted || - AccessLevel == AccessLevel.Player && DisableHiddenSelfClick && Hidden && from == this) + (AccessLevel == AccessLevel.Player && DisableHiddenSelfClick && Hidden && from == this)) return; if (GuildClickMessage) { - BaseGuild guild = m_Guild; + var guild = m_Guild; - if (guild != null && (m_DisplayGuildTitle || m_Player && guild.Type != GuildType.Regular)) + if (guild != null && (m_DisplayGuildTitle || (m_Player && guild.Type != GuildType.Regular))) { - string title = GuildTitle?.Trim() ?? ""; + var title = GuildTitle?.Trim() ?? ""; string type; if (guild.Type >= 0 && (int)guild.Type < m_GuildTypes.Length) @@ -7127,7 +7109,7 @@ namespace Server else type = ""; - string text = string.Format(title.Length <= 0 ? "[{1}]{2}" : "[{0}, {1}]{2}", title, guild.Abbreviation, + var text = string.Format(title.Length <= 0 ? "[{1}]{2}" : "[{0}, {1}]{2}", title, guild.Abbreviation, type); PrivateOverheadMessage(MessageType.Regular, SpeechHue, true, text, from.NetState); @@ -7143,14 +7125,14 @@ namespace Server else hue = Notoriety.GetHue(Notoriety.Compute(from, this)); - string name = Name ?? string.Empty; + var name = Name ?? string.Empty; - string prefix = ""; + var prefix = ""; if (ShowFameTitle && (m_Player || m_Body.IsHuman) && m_Fame >= 10000) prefix = m_Female ? "Lady" : "Lord"; - string suffix = ""; + var suffix = ""; if (ClickTitle && !string.IsNullOrEmpty(Title)) suffix = Title; @@ -7233,7 +7215,7 @@ namespace Server public bool Expired() { - bool v = Core.TickCount - m_End >= 0; + var v = Core.TickCount - m_End >= 0; if (v) m_InstancePool.Enqueue(this); @@ -7253,7 +7235,7 @@ namespace Server Value = value; } - public bool Value{ get; set; } + public bool Value { get; set; } protected override void OnTick() { @@ -7318,7 +7300,7 @@ namespace Server public LocationComparer(IEntity relativeTo) => RelativeTo = relativeTo; - public IEntity RelativeTo{ get; set; } + public IEntity RelativeTo { get; set; } public int Compare(IEntity x, IEntity y) => GetDistance(x) - GetDistance(y); @@ -7334,9 +7316,9 @@ namespace Server private int GetDistance(IEntity p) { - int x = RelativeTo.X - p.X; - int y = RelativeTo.Y - p.Y; - int z = RelativeTo.Z - p.Z; + var x = RelativeTo.X - p.X; + var y = RelativeTo.Y - p.Y; + var z = RelativeTo.Z - p.Z; x *= 11; y *= 11; @@ -7349,37 +7331,31 @@ namespace Server public int CompareTo(Mobile other) => other == null ? -1 : Serial.CompareTo(other.Serial); - #region Handlers + public static AllowBeneficialHandler AllowBeneficialHandler { get; set; } - public static AllowBeneficialHandler AllowBeneficialHandler{ get; set; } + public static AllowHarmfulHandler AllowHarmfulHandler { get; set; } - public static AllowHarmfulHandler AllowHarmfulHandler{ get; set; } + public static SkillCheckTargetHandler SkillCheckTargetHandler { get; set; } - public static SkillCheckTargetHandler SkillCheckTargetHandler{ get; set; } + public static SkillCheckLocationHandler SkillCheckLocationHandler { get; set; } - public static SkillCheckLocationHandler SkillCheckLocationHandler{ get; set; } + public static SkillCheckDirectTargetHandler SkillCheckDirectTargetHandler { get; set; } - public static SkillCheckDirectTargetHandler SkillCheckDirectTargetHandler{ get; set; } + public static SkillCheckDirectLocationHandler SkillCheckDirectLocationHandler { get; set; } - public static SkillCheckDirectLocationHandler SkillCheckDirectLocationHandler{ get; set; } + public static AOSStatusHandler AOSStatusHandler { get; set; } - public static AOSStatusHandler AOSStatusHandler{ get; set; } + public static RegenRateHandler HitsRegenRateHandler { get; set; } - #endregion + public static TimeSpan DefaultHitsRate { get; set; } - #region Regeneration + public static RegenRateHandler StamRegenRateHandler { get; set; } - public static RegenRateHandler HitsRegenRateHandler{ get; set; } + public static TimeSpan DefaultStamRate { get; set; } - public static TimeSpan DefaultHitsRate{ get; set; } + public static RegenRateHandler ManaRegenRateHandler { get; set; } - public static RegenRateHandler StamRegenRateHandler{ get; set; } - - public static TimeSpan DefaultStamRate{ get; set; } - - public static RegenRateHandler ManaRegenRateHandler{ get; set; } - - public static TimeSpan DefaultManaRate{ get; set; } + public static TimeSpan DefaultManaRate { get; set; } public static TimeSpan GetHitsRegenRate(Mobile m) { @@ -7402,10 +7378,6 @@ namespace Server return ManaRegenRateHandler(m); } - #endregion - - #region Var declarations - private Map m_Map; private Point3D m_Location; private Direction m_Direction; @@ -7460,10 +7432,6 @@ namespace Server private Body m_BodyMod; private Race m_Race; - #endregion - - #region Timers - private class ManaTimer : Timer { private readonly Mobile m_Owner; @@ -7477,7 +7445,7 @@ namespace Server protected override void OnTick() { - if (m_Owner.CanRegenMana) // m_Owner.Alive ) + if (m_Owner.CanRegenMana) m_Owner.Mana++; Delay = Interval = GetManaRegenRate(m_Owner); @@ -7497,7 +7465,7 @@ namespace Server protected override void OnTick() { - if (m_Owner.CanRegenHits) // m_Owner.Alive && !m_Owner.Poisoned ) + if (m_Owner.CanRegenHits) m_Owner.Hits++; Delay = Interval = GetHitsRegenRate(m_Owner); @@ -7517,7 +7485,7 @@ namespace Server protected override void OnTick() { - if (m_Owner.CanRegenStam) // m_Owner.Alive ) + if (m_Owner.CanRegenStam) m_Owner.Stam++; Delay = Interval = GetStamRegenRate(m_Owner); @@ -7600,7 +7568,7 @@ namespace Server if (Core.TickCount - m_Mobile.NextCombatTime < 0) return; - Mobile combatant = m_Mobile.Combatant; + var combatant = m_Mobile.Combatant; // If no combatant, wrong map, one of us is a ghost, or cannot see, or deleted, then stop combat if (combatant?.Deleted != false || m_Mobile.Deleted || combatant.m_Map != m_Mobile.m_Map || @@ -7611,7 +7579,7 @@ namespace Server return; } - IWeapon weapon = m_Mobile.Weapon; + var weapon = m_Mobile.Weapon; if (!m_Mobile.InRange(combatant, weapon.MaxRange)) return; @@ -7619,7 +7587,7 @@ namespace Server if (m_Mobile.InLOS(combatant)) { weapon.OnBeforeSwing(m_Mobile, - combatant); //OnBeforeSwing for checking in regards to being hidden and whatnot + combatant); // OnBeforeSwing for checking in regards to being hidden and whatnot m_Mobile.RevealingAction(); m_Mobile.NextCombatTime = Core.TickCount + (int)weapon.OnSwing(m_Mobile, combatant).TotalMilliseconds; @@ -7644,7 +7612,7 @@ namespace Server } } - public static TimeSpan ExpireCriminalDelay{ get; set; } = TimeSpan.FromMinutes(2.0); + public static TimeSpan ExpireCriminalDelay { get; set; } = TimeSpan.FromMinutes(2.0); private class ExpireCriminalTimer : Timer { @@ -7676,17 +7644,13 @@ namespace Server protected override void OnTick() { - if (m_Mobile.Deleted || m_Mobile.Aggressors.Count == 0 && m_Mobile.Aggressed.Count == 0) + if (m_Mobile.Deleted || (m_Mobile.Aggressors.Count == 0 && m_Mobile.Aggressed.Count == 0)) m_Mobile.StopAggrExpire(); else m_Mobile.CheckAggrExpire(); } } - #endregion - - #region Prompts - private class SimplePrompt : Prompt { private readonly PromptCallback m_Callback; @@ -7715,9 +7679,9 @@ namespace Server if (m_CallbackHandlesCancel && m_Callback != null) m_Callback(from, ""); else - m_CancelCallback?.Invoke(@from, ""); - } + m_CancelCallback?.Invoke(from, ""); } + } public Prompt BeginPrompt(PromptCallback callback, PromptCallback cancelCallback) { @@ -7779,8 +7743,8 @@ namespace Server get => m_Prompt; set { - Prompt oldPrompt = m_Prompt; - Prompt newPrompt = value; + var oldPrompt = m_Prompt; + var newPrompt = value; if (oldPrompt == newPrompt) return; @@ -7797,10 +7761,6 @@ namespace Server } } - #endregion - - #region Get*Sound - public virtual int GetAngerSound() { if (BaseSoundID != 0) @@ -7841,15 +7801,11 @@ namespace Server return -1; } - #endregion - - #region Get*InRange - public IPooledEnumerable GetItemsInRange(int range) => GetItemsInRange(range); public IPooledEnumerable GetItemsInRange(int range) where T : Item { - Map map = m_Map; + var map = m_Map; if (map == null) return Map.NullEnumerable.Instance; @@ -7859,7 +7815,7 @@ namespace Server public IPooledEnumerable GetObjectsInRange(int range) { - Map map = m_Map; + var map = m_Map; if (map == null) return Map.NullEnumerable.Instance; @@ -7871,7 +7827,7 @@ namespace Server public IPooledEnumerable GetMobilesInRange(int range) where T : Mobile { - Map map = m_Map; + var map = m_Map; if (map == null) return Map.NullEnumerable.Instance; @@ -7881,7 +7837,7 @@ namespace Server public IPooledEnumerable GetClientsInRange(int range) { - Map map = m_Map; + var map = m_Map; if (map == null) return Map.NullEnumerable.Instance; @@ -7889,10 +7845,6 @@ namespace Server return map.GetClientsInRange(m_Location, range); } - #endregion - - #region Say/SayTo/Emote/Whisper/Yell - public void SayTo(Mobile to, bool ascii, string text) { PrivateOverheadMessage(MessageType.Regular, SpeechHue, ascii, text, to.NetState); @@ -7993,10 +7945,6 @@ namespace Server PublicOverheadMessage(MessageType.Yell, YellHue, number, args); } - #endregion - - #region Gumps/Menus - public bool SendHuePicker(HuePicker p, bool throwOnOffline = false) { if (m_NetState != null) @@ -8020,7 +7968,7 @@ namespace Server if (m_NetState == null) return false; - Gump gump = FindGump(); + var gump = FindGump(); if (gump != null) { @@ -8035,16 +7983,16 @@ namespace Server public bool CloseAllGumps() { - NetState ns = m_NetState; + var ns = m_NetState; if (ns == null) return false; - List gumps = new List(ns.Gumps); + var gumps = new List(ns.Gumps); ns.ClearGumps(); - foreach (Gump gump in gumps) + foreach (var gump in gumps) { ns.Send(new CloseGump(gump.TypeID, 0)); @@ -8074,10 +8022,6 @@ namespace Server return true; } - #endregion - - #region Beneficial Checks/Actions - public virtual bool CanBeBeneficial(Mobile target) => CanBeBeneficial(target, true, false); public virtual bool CanBeBeneficial(Mobile target, bool message) => CanBeBeneficial(target, message, false); @@ -8088,7 +8032,7 @@ namespace Server return false; if (Deleted || target.Deleted || !Alive || IsDeadBondedPet || - !allowDead && (!target.Alive || target.IsDeadBondedPet)) + (!allowDead && (!target.Alive || target.IsDeadBondedPet))) { if (message) SendLocalizedMessage(1001017); // You can not perform beneficial acts on your target. @@ -8099,16 +8043,16 @@ namespace Server if (target == this) return true; - if ( /*m_Player &&*/ !Region.AllowBeneficial(this, target)) + if (/*m_Player &&*/!Region.AllowBeneficial(this, target)) { // TODO: Pets - //if ( !(target.m_Player || target.Body.IsHuman || target.Body.IsAnimal) ) - //{ + // if (!(target.m_Player || target.Body.IsHuman || target.Body.IsAnimal)) + // { if (message) SendLocalizedMessage(1001017); // You can not perform beneficial acts on your target. return false; - //} + // } } return true; @@ -8119,7 +8063,7 @@ namespace Server if (this == target) return false; - int n = Notoriety.Compute(this, target); + var n = Notoriety.Compute(this, target); return n == Notoriety.Criminal || n == Notoriety.Murderer; } @@ -8155,10 +8099,6 @@ namespace Server return false; } - #endregion - - #region Harmful Checks/Actions - public virtual bool CanBeHarmful(Mobile target) => CanBeHarmful(target, true); public virtual bool CanBeHarmful(Mobile target, bool message) => CanBeHarmful(target, message, false); @@ -8168,7 +8108,7 @@ namespace Server if (target == null) return false; - if (Deleted || !ignoreOurBlessedness && m_Blessed || target.Deleted || target.m_Blessed || !Alive || + if (Deleted || (!ignoreOurBlessedness && m_Blessed) || target.Deleted || target.m_Blessed || !Alive || IsDeadBondedPet || !target.Alive || target.IsDeadBondedPet) { if (message) @@ -8181,9 +8121,8 @@ namespace Server return true; // TODO: Pets - if ( /*m_Player &&*/ - !Region.AllowHarmful(this, target) - ) //(target.m_Player || target.Body.IsHuman) && !Region.AllowHarmful( this, target ) ) + if (/*m_Player &&*/ + !Region.AllowHarmful(this, target)) // (target.m_Player || target.Body.IsHuman) && !Region.AllowHarmful( this, target ) ) { if (message) SendLocalizedMessage(1001018); // You can not perform negative acts on your target. @@ -8194,7 +8133,8 @@ namespace Server return true; } - public virtual bool IsHarmfulCriminal(Mobile target) => this != target && Notoriety.Compute(this, target) == Notoriety.Innocent; + public virtual bool IsHarmfulCriminal(Mobile target) => + this != target && Notoriety.Compute(this, target) == Notoriety.Innocent; /// /// Overridable. Event invoked when the Mobile does a harmful action. @@ -8215,7 +8155,7 @@ namespace Server if (target == null || Deleted) return; - bool isCriminal = IsHarmfulCriminal(target); + var isCriminal = IsHarmfulCriminal(target); OnHarmfulAction(target, isCriminal); target.AggressiveAction(this, isCriminal); @@ -8245,20 +8185,16 @@ namespace Server return false; } - #endregion - - #region Stats - /// /// Gets a list of all StatMod's currently active for the Mobile. /// - public List StatMods{ get; private set; } + public List StatMods { get; private set; } public bool RemoveStatMod(string name) { - for (int i = 0; i < StatMods.Count; ++i) + for (var i = 0; i < StatMods.Count; ++i) { - StatMod check = StatMods[i]; + var check = StatMods[i]; if (check.Name == name) { @@ -8274,9 +8210,9 @@ namespace Server public StatMod GetStatMod(string name) { - for (int i = 0; i < StatMods.Count; ++i) + for (var i = 0; i < StatMods.Count; ++i) { - StatMod check = StatMods[i]; + var check = StatMods[i]; if (check.Name == name) return check; @@ -8287,9 +8223,9 @@ namespace Server public void AddStatMod(StatMod mod) { - for (int i = 0; i < StatMods.Count; ++i) + for (var i = 0; i < StatMods.Count; ++i) { - StatMod check = StatMods[i]; + var check = StatMods[i]; if (check.Name == mod.Name) { @@ -8325,11 +8261,11 @@ namespace Server /// public int GetStatOffset(StatType type) { - int offset = 0; + var offset = 0; - for (int i = 0; i < StatMods.Count; ++i) + for (var i = 0; i < StatMods.Count; ++i) { - StatMod mod = StatMods[i]; + var mod = StatMods[i]; if (mod.HasElapsed()) { @@ -8406,7 +8342,7 @@ namespace Server if (m_Str != value) { - int oldValue = m_Str; + var oldValue = m_Str; m_Str = value; Delta(MobileDelta.Stat | MobileDelta.Hits); @@ -8440,7 +8376,7 @@ namespace Server { get { - int value = m_Str + GetStatOffset(StatType.Str); + var value = m_Str + GetStatOffset(StatType.Str); if (value < 1) value = 1; @@ -8476,7 +8412,7 @@ namespace Server if (m_Dex != value) { - int oldValue = m_Dex; + var oldValue = m_Dex; m_Dex = value; Delta(MobileDelta.Stat | MobileDelta.Stam); @@ -8510,7 +8446,7 @@ namespace Server { get { - int value = m_Dex + GetStatOffset(StatType.Dex); + var value = m_Dex + GetStatOffset(StatType.Dex); if (value < 1) value = 1; @@ -8546,7 +8482,7 @@ namespace Server if (m_Int != value) { - int oldValue = m_Int; + var oldValue = m_Int; m_Int = value; Delta(MobileDelta.Stat | MobileDelta.Mana); @@ -8580,7 +8516,7 @@ namespace Server { get { - int value = m_Int + GetStatOffset(StatType.Int); + var value = m_Int + GetStatOffset(StatType.Int); if (value < 1) value = 1; @@ -8632,7 +8568,7 @@ namespace Server m_HitsTimer?.Stop(); - for (int i = 0; i < Aggressors.Count; i++) //reset reports on full HP + for (var i = 0; i < Aggressors.Count; i++) // reset reports on full HP Aggressors[i].CanReportMurder = false; if (DamageEntries.Count > 0) @@ -8655,7 +8591,7 @@ namespace Server if (m_Hits != value) { - int oldValue = m_Hits; + var oldValue = m_Hits; m_Hits = value; Delta(MobileDelta.Hits); OnHitsChange(oldValue); @@ -8708,7 +8644,7 @@ namespace Server if (m_Stam != value) { - int oldValue = m_Stam; + var oldValue = m_Stam; m_Stam = value; Delta(MobileDelta.Stam); OnStamChange(oldValue); @@ -8770,7 +8706,7 @@ namespace Server if (m_Mana != value) { - int oldValue = m_Mana; + var oldValue = m_Mana; m_Mana = value; Delta(MobileDelta.Mana); OnManaChange(oldValue); @@ -8787,11 +8723,7 @@ namespace Server [CommandProperty(AccessLevel.GameMaster)] public virtual int ManaMax => Int; - #endregion - - #region Poison/Curing - - public Timer PoisonTimer{ get; private set; } + public Timer PoisonTimer { get; private set; } [CommandProperty(AccessLevel.GameMaster)] public Poison Poison @@ -8799,7 +8731,7 @@ namespace Server get => m_Poison; set { - /*if ( m_Poison != value && (m_Poison == null || value == null || m_Poison.Level < value.Level) ) + /*if (m_Poison != value && (m_Poison == null || value == null || m_Poison.Level < value.Level)) {*/ m_Poison = value; Delta(MobileDelta.HealthbarPoison); @@ -8938,7 +8870,7 @@ namespace Server return ApplyPoisonResult.Immune; } - Poison oldPoison = m_Poison; + var oldPoison = m_Poison; Poison = poison; OnPoisoned(from, poison, oldPoison); @@ -8982,7 +8914,7 @@ namespace Server { if (CheckCure(from)) { - Poison oldPoison = m_Poison; + var oldPoison = m_Poison; Poison = null; OnCured(from, oldPoison); @@ -8995,10 +8927,6 @@ namespace Server return false; } - #endregion - - #region Hair - private HairInfo m_Hair; private FacialHairInfo m_FacialHair; @@ -9019,8 +8947,8 @@ namespace Server } } - // [CommandProperty( AccessLevel.GameMaster )] - // public int HairSerial { get { return HairInfo.FakeSerial( this ); } } + // [CommandProperty( AccessLevel.GameMaster )] + // public int HairSerial { get { return HairInfo.FakeSerial( this ); } } [CommandProperty(AccessLevel.GameMaster)] public int FacialHairItemID @@ -9039,8 +8967,8 @@ namespace Server } } - // [CommandProperty( AccessLevel.GameMaster )] - // public int FacialHairSerial { get { return FacialHairInfo.FakeSerial( this ); } } + // [CommandProperty( AccessLevel.GameMaster )] + // public int FacialHairSerial { get { return FacialHairInfo.FakeSerial( this ); } } [CommandProperty(AccessLevel.GameMaster)] public int HairHue @@ -9070,10 +8998,6 @@ namespace Server } } - #endregion - - #region Effects & Particles - public void MovingEffect(IEntity to, int itemID, int speed, int duration, bool fixedDirection, bool explodes, int hue, int renderMode) { @@ -9150,20 +9074,16 @@ namespace Server Effects.SendBoltEffect(this, true, hue); } - #endregion - - #region GetDirectionTo[..] - public Direction GetDirectionTo(int x, int y) { - int dx = m_Location.m_X - x; - int dy = m_Location.m_Y - y; + var dx = m_Location.m_X - x; + var dy = m_Location.m_Y - y; - int rx = (dx - dy) * 44; - int ry = (dx + dy) * 44; + var rx = (dx - dy) * 44; + var ry = (dx + dy) * 44; - int ax = Math.Abs(rx); - int ay = Math.Abs(ry); + var ax = Math.Abs(rx); + var ay = Math.Abs(ry); Direction ret; @@ -9195,24 +9115,20 @@ namespace Server return GetDirectionTo(p.X, p.Y); } - #endregion - - #region Overhead messages - public void PublicOverheadMessage(MessageType type, int hue, bool ascii, string text, bool noLineOfSight = true) { if (m_Map == null) return; - Packet p = ascii + var p = ascii ? (Packet)new AsciiMessage(Serial, Body, type, hue, 3, Name, text) : new UnicodeMessage(Serial, Body, type, hue, 3, m_Language, Name, text); p.Acquire(); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) state.Send(p); @@ -9226,11 +9142,11 @@ namespace Server if (m_Map == null) return; - Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); + var p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) state.Send(p); @@ -9245,12 +9161,12 @@ namespace Server if (m_Map == null) return; - Packet p = Packet.Acquire(new MessageLocalizedAffix(Serial, Body, type, hue, 3, number, Name, affixType, + var p = Packet.Acquire(new MessageLocalizedAffix(Serial, Body, type, hue, 3, number, Name, affixType, affix, args)); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this))) state.Send(p); @@ -9282,7 +9198,7 @@ namespace Server public void LocalOverheadMessage(MessageType type, int hue, bool ascii, string text) { - NetState ns = m_NetState; + var ns = m_NetState; if (ns == null) return; @@ -9303,11 +9219,11 @@ namespace Server if (m_Map == null) return; - Packet p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); + var p = Packet.Acquire(new MessageLocalized(Serial, Body, type, hue, 3, number, Name, args)); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state != m_NetState && state.Mobile.CanSee(this)) state.Send(p); @@ -9321,15 +9237,15 @@ namespace Server if (m_Map == null) return; - Packet p = ascii + var p = ascii ? (Packet)new AsciiMessage(Serial, Body, type, hue, 3, Name, text) : new UnicodeMessage(Serial, Body, type, hue, 3, Language, Name, text); p.Acquire(); - IPooledEnumerable eable = m_Map.GetClientsInRange(m_Location); + var eable = m_Map.GetClientsInRange(m_Location); - foreach (NetState state in eable) + foreach (var state in eable) if (state != m_NetState && state.Mobile.CanSee(this)) state.Send(p); @@ -9338,10 +9254,6 @@ namespace Server eable.Free(); } - #endregion - - #region SendLocalizedMessage - public void SendLocalizedMessage(int number) { m_NetState?.Send(MessageLocalized.InstantiateGeneric(number)); @@ -9361,10 +9273,6 @@ namespace Server (append ? AffixType.Append : AffixType.Prepend) | AffixType.System, affix, args)); } - #endregion - - #region Send[ASCII]Message - public void SendMessage(string text) { SendMessage(0x3B2, text); @@ -9405,9 +9313,6 @@ namespace Server SendAsciiMessage(hue, string.Format(format, args)); } - #endregion - - #region InRange public virtual bool InRange(Point2D p, int range) => p.m_X >= Location.m_X - range && p.m_X <= Location.m_X + range @@ -9425,9 +9330,6 @@ namespace Server && p.X <= Location.m_X + range && p.Y >= Location.m_Y - range && p.Y <= Location.m_Y + range; - #endregion - - #region OnDoubleClick[..] /// /// Overridable. Event invoked when the Mobile is double clicked. By default, this method can either dismount or open the @@ -9439,7 +9341,7 @@ namespace Server { if (this == from && (!DisableDismountInWarmode || !m_Warmode)) { - IMount mount = Mount; + var mount = Mount; if (mount != null) { @@ -9481,10 +9383,6 @@ namespace Server DisplayPaperdollTo(from); } - #endregion - - #region Armor - public Item ShieldArmor => FindItemOnLayer(Layer.TwoHanded); public Item NeckArmor => FindItemOnLayer(Layer.Neck); @@ -9500,7 +9398,5 @@ namespace Server public Item ChestArmor => FindItemOnLayer(Layer.InnerTorso) ?? FindItemOnLayer(Layer.Shirt); public Item Talisman => FindItemOnLayer(Layer.Talisman); - - #endregion } } diff --git a/Projects/Server/Mobiles/IMount.cs b/Projects/Server/Mobiles/IMount.cs new file mode 100644 index 000000000..113c92b1f --- /dev/null +++ b/Projects/Server/Mobiles/IMount.cs @@ -0,0 +1,34 @@ +/************************************************************************* + * ModernUO * + * Copyright (C) 2020 - ModernUO Development Team * + * Email: hi@modernuo.com * + * File: IMount.cs * + * Created: 2020/04/25 - Updated: 2020/04/25 * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *************************************************************************/ + +namespace Server.Mobiles +{ + public interface IMount + { + Mobile Rider { get; set; } + void OnRiderDamaged(int amount, Mobile from, bool willKill); + } + + public interface IMountItem + { + IMount Mount { get; } + } +} diff --git a/Projects/Server/Mobiles/IVendor.cs b/Projects/Server/Mobiles/IVendor.cs new file mode 100644 index 000000000..9743c6836 --- /dev/null +++ b/Projects/Server/Mobiles/IVendor.cs @@ -0,0 +1,33 @@ +/************************************************************************* + * ModernUO * + * Copyright (C) 2020 - ModernUO Development Team * + * Email: hi@modernuo.com * + * File: IVendor.cs * + * Created: 2020/04/25 - Updated: 2020/04/25 * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *************************************************************************/ + +using System; +using System.Collections.Generic; +using Server; + +public interface IVendor +{ + DateTime LastRestock { get; set; } + TimeSpan RestockDelay { get; } + bool OnBuyItems(Mobile from, List list); + bool OnSellItems(Mobile from, List list); + void Restock(); +} diff --git a/Projects/Server/Movement.cs b/Projects/Server/Movement.cs index 6544f6767..2ba3b2eab 100644 --- a/Projects/Server/Movement.cs +++ b/Projects/Server/Movement.cs @@ -22,7 +22,7 @@ namespace Server.Movement { public static class Movement { - public static IMovementImpl Impl{ get; set; } + public static IMovementImpl Impl { get; set; } public static bool CheckMovement(Mobile m, Direction d, out int newZ) { @@ -83,4 +83,4 @@ namespace Server.Movement bool CheckMovement(Mobile m, Direction d, out int newZ); bool CheckMovement(Mobile m, Map map, Point3D loc, Direction d, out int newZ); } -} \ No newline at end of file +} diff --git a/Projects/Server/MultiData.cs b/Projects/Server/MultiData.cs index aa0ab0f0b..b7112ffdc 100644 --- a/Projects/Server/MultiData.cs +++ b/Projects/Server/MultiData.cs @@ -37,7 +37,7 @@ namespace Server static MultiData() { - string multiUOPPath = Core.FindDataFile("MultiCollection.uop"); + var multiUOPPath = Core.FindDataFile("MultiCollection.uop"); if (File.Exists(multiUOPPath)) { @@ -46,8 +46,8 @@ namespace Server return; } - string idxPath = Core.FindDataFile("multi.idx"); - string mulPath = Core.FindDataFile("multi.mul"); + var idxPath = Core.FindDataFile("multi.idx"); + var mulPath = Core.FindDataFile("multi.mul"); if (File.Exists(idxPath) && File.Exists(mulPath)) { @@ -57,21 +57,21 @@ namespace Server var stream = new FileStream(mulPath, FileMode.Open, FileAccess.Read, FileShare.Read); m_StreamReader = new BinaryReader(stream); - string vdPath = Core.FindDataFile("verdata.mul"); + var vdPath = Core.FindDataFile("verdata.mul"); if (!File.Exists(vdPath)) return; - using FileStream fs = new FileStream(vdPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader bin = new BinaryReader(fs); + using var fs = new FileStream(vdPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var bin = new BinaryReader(fs); - int count = bin.ReadInt32(); + var count = bin.ReadInt32(); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - int file = bin.ReadInt32(); - int index = bin.ReadInt32(); - int lookup = bin.ReadInt32(); - int length = bin.ReadInt32(); + var file = bin.ReadInt32(); + var index = bin.ReadInt32(); + var lookup = bin.ReadInt32(); + var length = bin.ReadInt32(); bin.ReadInt32(); // extra if (file == 14 && index >= 0 && lookup >= 0 && length > 0) @@ -87,7 +87,9 @@ namespace Server bin.Close(); } else + { Console.WriteLine("Warning: Multi data files not found"); + } } public static MultiComponentList GetComponents(int multiID) @@ -109,7 +111,7 @@ namespace Server public static void LoadUOP(string path) { var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader streamReader = new BinaryReader(stream); + var streamReader = new BinaryReader(stream); // Head Information Start if (streamReader.ReadInt32() != 0x0050594D) // Not a UOP Files @@ -122,34 +124,34 @@ namespace Server UOPHash.BuildChunkIDs(out var chunkIds); // Multi ID List Array End - streamReader.ReadUInt32(); // format timestamp? 0xFD23EC43 - long startAddress = streamReader.ReadInt64(); + streamReader.ReadUInt32(); // format timestamp? 0xFD23EC43 + var startAddress = streamReader.ReadInt64(); streamReader.ReadInt32(); streamReader.ReadInt32(); - stream.Seek(startAddress, SeekOrigin.Begin); // Head Information End + stream.Seek(startAddress, SeekOrigin.Begin); // Head Information End long nextBlock; do { - int blockFileCount = streamReader.ReadInt32(); + var blockFileCount = streamReader.ReadInt32(); nextBlock = streamReader.ReadInt64(); - int index = 0; + var index = 0; do { - long offset = streamReader.ReadInt64(); + var offset = streamReader.ReadInt64(); - int headerSize = streamReader.ReadInt32(); // header length - int compressedSize = streamReader.ReadInt32(); // compressed size - int decompressedSize = streamReader.ReadInt32(); // decompressed size + var headerSize = streamReader.ReadInt32(); // header length + var compressedSize = streamReader.ReadInt32(); // compressed size + var decompressedSize = streamReader.ReadInt32(); // decompressed size - ulong filehash = streamReader.ReadUInt64(); // filename hash (HashLittle2) + var filehash = streamReader.ReadUInt64(); // filename hash (HashLittle2) streamReader.ReadUInt32(); - short compressionMethod = streamReader.ReadInt16(); // compression method (0 = none, 1 = zlib) + var compressionMethod = streamReader.ReadInt16(); // compression method (0 = none, 1 = zlib) index++; @@ -158,7 +160,7 @@ namespace Server chunkIds.TryGetValue(filehash, out var chunkID); - long position = stream.Position; // save current position + var position = stream.Position; // save current position stream.Seek(offset + headerSize, SeekOrigin.Begin); @@ -172,15 +174,17 @@ namespace Server if (compressionMethod == 1) { data = new byte[decompressedSize]; - Compression.Unpack(data, ref decompressedSize, sourceData, compressedSize); + NetworkCompression.Unpack(data, ref decompressedSize, sourceData, compressedSize); } else + { data = sourceData; + } var tileList = new List(); // Skip the first 4 bytes - BufferReader reader = new BufferReader(data); + var reader = new BufferReader(data); reader.Advance(4); // ??? reader.TryReadLittleEndian(out uint count); @@ -193,7 +197,7 @@ namespace Server reader.TryReadLittleEndian(out short z); reader.TryReadLittleEndian(out ushort flagValue); - TileFlag tileFlag = flagValue switch + var tileFlag = flagValue switch { 1 => TileFlag.None, 257 => TileFlag.Generic, @@ -209,10 +213,8 @@ namespace Server Components[chunkID] = new MultiComponentList(tileList); stream.Seek(position, SeekOrigin.Begin); // back to position - } - while (index < blockFileCount); - } - while (stream.Seek(nextBlock, SeekOrigin.Begin) != 0); + } while (index < blockFileCount); + } while (stream.Seek(nextBlock, SeekOrigin.Begin) != 0); } // TODO: Change this to read the file all during load time @@ -222,8 +224,8 @@ namespace Server { m_IndexReader.BaseStream.Seek(multiID * 12, SeekOrigin.Begin); - int lookup = m_IndexReader.ReadInt32(); - int length = m_IndexReader.ReadInt32(); + var lookup = m_IndexReader.ReadInt32(); + var length = m_IndexReader.ReadInt32(); if (lookup < 0 || length <= 0) return MultiComponentList.Empty; @@ -241,17 +243,19 @@ namespace Server public struct MultiTileEntry { - public ushort m_ItemID; - public short m_OffsetX, m_OffsetY, m_OffsetZ; - public TileFlag m_Flags; + public ushort ItemId { get; set; } + public short OffsetX { get; set; } + public short OffsetY { get; set; } + public short OffsetZ { get; set; } + public TileFlag Flags { get; set; } public MultiTileEntry(ushort itemID, short xOffset, short yOffset, short zOffset, TileFlag flags) { - m_ItemID = itemID; - m_OffsetX = xOffset; - m_OffsetY = yOffset; - m_OffsetZ = zOffset; - m_Flags = flags; + ItemId = itemID; + OffsetX = xOffset; + OffsetY = yOffset; + OffsetZ = zOffset; + Flags = flags; } } @@ -273,28 +277,28 @@ namespace Server Tiles = new StaticTile[Width][][]; - for (int x = 0; x < Width; ++x) + for (var x = 0; x < Width; ++x) { Tiles[x] = new StaticTile[Height][]; - for (int y = 0; y < Height; ++y) + for (var y = 0; y < Height; ++y) { Tiles[x][y] = new StaticTile[toCopy.Tiles[x][y].Length]; - for (int i = 0; i < Tiles[x][y].Length; ++i) + for (var i = 0; i < Tiles[x][y].Length; ++i) Tiles[x][y][i] = toCopy.Tiles[x][y][i]; } } List = new MultiTileEntry[toCopy.List.Length]; - for (int i = 0; i < List.Length; ++i) + for (var i = 0; i < List.Length; ++i) List[i] = toCopy.List[i]; } public MultiComponentList(IGenericReader reader) { - int version = reader.ReadInt(); + var version = reader.ReadInt(); m_Min = reader.ReadPoint2D(); m_Max = reader.ReadPoint2D(); @@ -302,90 +306,90 @@ namespace Server Width = reader.ReadInt(); Height = reader.ReadInt(); - int length = reader.ReadInt(); + var length = reader.ReadInt(); - MultiTileEntry[] allTiles = List = new MultiTileEntry[length]; + var allTiles = List = new MultiTileEntry[length]; if (version == 0) - for (int i = 0; i < length; ++i) + for (var i = 0; i < length; ++i) { int id = reader.ReadShort(); if (id >= 0x4000) id -= 0x4000; - allTiles[i].m_ItemID = (ushort)id; - allTiles[i].m_OffsetX = reader.ReadShort(); - allTiles[i].m_OffsetY = reader.ReadShort(); - allTiles[i].m_OffsetZ = reader.ReadShort(); - allTiles[i].m_Flags = (TileFlag)reader.ReadInt(); + allTiles[i].ItemId = (ushort)id; + allTiles[i].OffsetX = reader.ReadShort(); + allTiles[i].OffsetY = reader.ReadShort(); + allTiles[i].OffsetZ = reader.ReadShort(); + allTiles[i].Flags = (TileFlag)reader.ReadInt(); } else - for (int i = 0; i < length; ++i) + for (var i = 0; i < length; ++i) { - allTiles[i].m_ItemID = reader.ReadUShort(); - allTiles[i].m_OffsetX = reader.ReadShort(); - allTiles[i].m_OffsetY = reader.ReadShort(); - allTiles[i].m_OffsetZ = reader.ReadShort(); - allTiles[i].m_Flags = (TileFlag)reader.ReadInt(); + allTiles[i].ItemId = reader.ReadUShort(); + allTiles[i].OffsetX = reader.ReadShort(); + allTiles[i].OffsetY = reader.ReadShort(); + allTiles[i].OffsetZ = reader.ReadShort(); + allTiles[i].Flags = (TileFlag)reader.ReadInt(); } - TileList[][] tiles = new TileList[Width][]; + var tiles = new TileList[Width][]; Tiles = new StaticTile[Width][][]; - for (int x = 0; x < Width; ++x) + for (var x = 0; x < Width; ++x) { tiles[x] = new TileList[Height]; Tiles[x] = new StaticTile[Height][]; - for (int y = 0; y < Height; ++y) + for (var y = 0; y < Height; ++y) tiles[x][y] = new TileList(); } - for (int i = 0; i < allTiles.Length; ++i) - if (i == 0 || allTiles[i].m_Flags != 0) + for (var i = 0; i < allTiles.Length; ++i) + if (i == 0 || allTiles[i].Flags != 0) { - int xOffset = allTiles[i].m_OffsetX + Center.m_X; - int yOffset = allTiles[i].m_OffsetY + Center.m_Y; + var xOffset = allTiles[i].OffsetX + Center.m_X; + var yOffset = allTiles[i].OffsetY + Center.m_Y; - tiles[xOffset][yOffset].Add(allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ); + tiles[xOffset][yOffset].Add(allTiles[i].ItemId, (sbyte)allTiles[i].OffsetZ); } - for (int x = 0; x < Width; ++x) - for (int y = 0; y < Height; ++y) - Tiles[x][y] = tiles[x][y].ToArray(); + for (var x = 0; x < Width; ++x) + for (var y = 0; y < Height; ++y) + Tiles[x][y] = tiles[x][y].ToArray(); } public MultiComponentList(BinaryReader reader, int count) { - MultiTileEntry[] allTiles = List = new MultiTileEntry[count]; + var allTiles = List = new MultiTileEntry[count]; - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - allTiles[i].m_ItemID = reader.ReadUInt16(); - allTiles[i].m_OffsetX = reader.ReadInt16(); - allTiles[i].m_OffsetY = reader.ReadInt16(); - allTiles[i].m_OffsetZ = reader.ReadInt16(); + allTiles[i].ItemId = reader.ReadUInt16(); + allTiles[i].OffsetX = reader.ReadInt16(); + allTiles[i].OffsetY = reader.ReadInt16(); + allTiles[i].OffsetZ = reader.ReadInt16(); if (PostHSFormat) - allTiles[i].m_Flags = (TileFlag)reader.ReadUInt64(); + allTiles[i].Flags = (TileFlag)reader.ReadUInt64(); else - allTiles[i].m_Flags = (TileFlag)reader.ReadUInt32(); + allTiles[i].Flags = (TileFlag)reader.ReadUInt32(); - MultiTileEntry e = allTiles[i]; + var e = allTiles[i]; - if (i == 0 || e.m_Flags != 0) + if (i == 0 || e.Flags != 0) { - if (e.m_OffsetX < m_Min.m_X) - m_Min.m_X = e.m_OffsetX; + if (e.OffsetX < m_Min.m_X) + m_Min.m_X = e.OffsetX; - if (e.m_OffsetY < m_Min.m_Y) - m_Min.m_Y = e.m_OffsetY; + if (e.OffsetY < m_Min.m_Y) + m_Min.m_Y = e.OffsetY; - if (e.m_OffsetX > m_Max.m_X) - m_Max.m_X = e.m_OffsetX; + if (e.OffsetX > m_Max.m_X) + m_Max.m_X = e.OffsetX; - if (e.m_OffsetY > m_Max.m_Y) - m_Max.m_Y = e.m_OffsetY; + if (e.OffsetY > m_Max.m_Y) + m_Max.m_Y = e.OffsetY; } } @@ -393,127 +397,127 @@ namespace Server Width = m_Max.m_X - m_Min.m_X + 1; Height = m_Max.m_Y - m_Min.m_Y + 1; - TileList[][] tiles = new TileList[Width][]; + var tiles = new TileList[Width][]; Tiles = new StaticTile[Width][][]; - for (int x = 0; x < Width; ++x) + for (var x = 0; x < Width; ++x) { tiles[x] = new TileList[Height]; Tiles[x] = new StaticTile[Height][]; - for (int y = 0; y < Height; ++y) + for (var y = 0; y < Height; ++y) tiles[x][y] = new TileList(); } - for (int i = 0; i < allTiles.Length; ++i) - if (i == 0 || allTiles[i].m_Flags != 0) + for (var i = 0; i < allTiles.Length; ++i) + if (i == 0 || allTiles[i].Flags != 0) { - int xOffset = allTiles[i].m_OffsetX + Center.m_X; - int yOffset = allTiles[i].m_OffsetY + Center.m_Y; + var xOffset = allTiles[i].OffsetX + Center.m_X; + var yOffset = allTiles[i].OffsetY + Center.m_Y; - tiles[xOffset][yOffset].Add(allTiles[i].m_ItemID, (sbyte)allTiles[i].m_OffsetZ); + tiles[xOffset][yOffset].Add(allTiles[i].ItemId, (sbyte)allTiles[i].OffsetZ); } - for (int x = 0; x < Width; ++x) - for (int y = 0; y < Height; ++y) - Tiles[x][y] = tiles[x][y].ToArray(); + for (var x = 0; x < Width; ++x) + for (var y = 0; y < Height; ++y) + Tiles[x][y] = tiles[x][y].ToArray(); } public MultiComponentList(List list) { var allTiles = List = new MultiTileEntry[list.Count]; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - allTiles[i].m_ItemID = list[i].m_ItemID; - allTiles[i].m_OffsetX = list[i].m_OffsetX; - allTiles[i].m_OffsetY = list[i].m_OffsetY; - allTiles[i].m_OffsetZ = list[i].m_OffsetZ; + allTiles[i].ItemId = list[i].ItemId; + allTiles[i].OffsetX = list[i].OffsetX; + allTiles[i].OffsetY = list[i].OffsetY; + allTiles[i].OffsetZ = list[i].OffsetZ; - allTiles[i].m_Flags = list[i].m_Flags; + allTiles[i].Flags = list[i].Flags; - MultiTileEntry e = allTiles[i]; + var e = allTiles[i]; - if (i == 0 || e.m_Flags != 0) + if (i == 0 || e.Flags != 0) { - if (e.m_OffsetX < m_Min.m_X) m_Min.m_X = e.m_OffsetX; + if (e.OffsetX < m_Min.m_X) m_Min.m_X = e.OffsetX; - if (e.m_OffsetY < m_Min.m_Y) m_Min.m_Y = e.m_OffsetY; + if (e.OffsetY < m_Min.m_Y) m_Min.m_Y = e.OffsetY; - if (e.m_OffsetX > m_Max.m_X) m_Max.m_X = e.m_OffsetX; + if (e.OffsetX > m_Max.m_X) m_Max.m_X = e.OffsetX; - if (e.m_OffsetY > m_Max.m_Y) m_Max.m_Y = e.m_OffsetY; + if (e.OffsetY > m_Max.m_Y) m_Max.m_Y = e.OffsetY; } } Center = new Point2D(-m_Min.m_X, -m_Min.m_Y); - Width = (m_Max.m_X - m_Min.m_X) + 1; - Height = (m_Max.m_Y - m_Min.m_Y) + 1; + Width = m_Max.m_X - m_Min.m_X + 1; + Height = m_Max.m_Y - m_Min.m_Y + 1; var tiles = new TileList[Width][]; Tiles = new StaticTile[Width][][]; - for (int x = 0; x < Width; ++x) + for (var x = 0; x < Width; ++x) { tiles[x] = new TileList[Height]; Tiles[x] = new StaticTile[Height][]; - for (int y = 0; y < Height; ++y) tiles[x][y] = new TileList(); + for (var y = 0; y < Height; ++y) tiles[x][y] = new TileList(); } - for (int i = 0; i < allTiles.Length; ++i) - if (i == 0 || allTiles[i].m_Flags != 0) + for (var i = 0; i < allTiles.Length; ++i) + if (i == 0 || allTiles[i].Flags != 0) { - int xOffset = allTiles[i].m_OffsetX + Center.m_X; - int yOffset = allTiles[i].m_OffsetY + Center.m_Y; - int itemID = ((allTiles[i].m_ItemID & TileData.MaxItemValue) | 0x10000); + var xOffset = allTiles[i].OffsetX + Center.m_X; + var yOffset = allTiles[i].OffsetY + Center.m_Y; + var itemID = (allTiles[i].ItemId & TileData.MaxItemValue) | 0x10000; - tiles[xOffset][yOffset].Add((ushort)itemID, (sbyte)allTiles[i].m_OffsetZ); + tiles[xOffset][yOffset].Add((ushort)itemID, (sbyte)allTiles[i].OffsetZ); } - for (int x = 0; x < Width; ++x) - for (int y = 0; y < Height; ++y) - Tiles[x][y] = tiles[x][y].ToArray(); + for (var x = 0; x < Width; ++x) + for (var y = 0; y < Height; ++y) + Tiles[x][y] = tiles[x][y].ToArray(); } private MultiComponentList() { - Tiles = new StaticTile[0][][]; - List = new MultiTileEntry[0]; + Tiles = Array.Empty(); + List = Array.Empty(); } - public static bool PostHSFormat{ get; set; } + public static bool PostHSFormat { get; set; } public Point2D Min => m_Min; public Point2D Max => m_Max; - public Point2D Center{ get; } + public Point2D Center { get; } - public int Width{ get; private set; } + public int Width { get; private set; } - public int Height{ get; private set; } + public int Height { get; private set; } - public StaticTile[][][] Tiles{ get; private set; } + public StaticTile[][][] Tiles { get; private set; } - public MultiTileEntry[] List{ get; private set; } + public MultiTileEntry[] List { get; private set; } public void Add(int itemID, int x, int y, int z) { - int vx = x + Center.m_X; - int vy = y + Center.m_Y; + var vx = x + Center.m_X; + var vy = y + Center.m_Y; if (vx >= 0 && vx < Width && vy >= 0 && vy < Height) { - StaticTile[] oldTiles = Tiles[vx][vy]; + var oldTiles = Tiles[vx][vy]; - for (int i = oldTiles.Length - 1; i >= 0; --i) + for (var i = oldTiles.Length - 1; i >= 0; --i) { - ItemData data = TileData.ItemTable[itemID & TileData.MaxItemValue]; + var data = TileData.ItemTable[itemID & TileData.MaxItemValue]; if (oldTiles[i].Z == z && oldTiles[i].Height > 0 == data.Height > 0) { - bool newIsRoof = (data.Flags & TileFlag.Roof) != 0; - bool oldIsRoof = + var newIsRoof = (data.Flags & TileFlag.Roof) != 0; + var oldIsRoof = (TileData.ItemTable[oldTiles[i].ID & TileData.MaxItemValue].Flags & TileFlag.Roof) != 0; if (newIsRoof == oldIsRoof) @@ -523,19 +527,19 @@ namespace Server oldTiles = Tiles[vx][vy]; - StaticTile[] newTiles = new StaticTile[oldTiles.Length + 1]; + var newTiles = new StaticTile[oldTiles.Length + 1]; - for (int i = 0; i < oldTiles.Length; ++i) + for (var i = 0; i < oldTiles.Length; ++i) newTiles[i] = oldTiles[i]; newTiles[oldTiles.Length] = new StaticTile((ushort)itemID, (sbyte)z); Tiles[vx][vy] = newTiles; - MultiTileEntry[] oldList = List; - MultiTileEntry[] newList = new MultiTileEntry[oldList.Length + 1]; + var oldList = List; + var newList = new MultiTileEntry[oldList.Length + 1]; - for (int i = 0; i < oldList.Length; ++i) + for (var i = 0; i < oldList.Length; ++i) newList[i] = oldList[i]; newList[oldList.Length] = new MultiTileEntry((ushort)itemID, (short)x, (short)y, (short)z, TileFlag.Background); @@ -558,25 +562,25 @@ namespace Server public void RemoveXYZH(int x, int y, int z, int minHeight) { - int vx = x + Center.m_X; - int vy = y + Center.m_Y; + var vx = x + Center.m_X; + var vy = y + Center.m_Y; if (vx >= 0 && vx < Width && vy >= 0 && vy < Height) { - StaticTile[] oldTiles = Tiles[vx][vy]; + var oldTiles = Tiles[vx][vy]; - for (int i = 0; i < oldTiles.Length; ++i) + for (var i = 0; i < oldTiles.Length; ++i) { - StaticTile tile = oldTiles[i]; + var tile = oldTiles[i]; if (tile.Z == z && tile.Height >= minHeight) { - StaticTile[] newTiles = new StaticTile[oldTiles.Length - 1]; + var newTiles = new StaticTile[oldTiles.Length - 1]; - for (int j = 0; j < i; ++j) + for (var j = 0; j < i; ++j) newTiles[j] = oldTiles[j]; - for (int j = i + 1; j < oldTiles.Length; ++j) + for (var j = i + 1; j < oldTiles.Length; ++j) newTiles[j - 1] = oldTiles[j]; Tiles[vx][vy] = newTiles; @@ -585,21 +589,21 @@ namespace Server } } - MultiTileEntry[] oldList = List; + var oldList = List; - for (int i = 0; i < oldList.Length; ++i) + for (var i = 0; i < oldList.Length; ++i) { - MultiTileEntry tile = oldList[i]; + var tile = oldList[i]; - if (tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && tile.m_OffsetZ == (short)z && - TileData.ItemTable[tile.m_ItemID & TileData.MaxItemValue].Height >= minHeight) + if (tile.OffsetX == (short)x && tile.OffsetY == (short)y && tile.OffsetZ == (short)z && + TileData.ItemTable[tile.ItemId & TileData.MaxItemValue].Height >= minHeight) { - MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1]; + var newList = new MultiTileEntry[oldList.Length - 1]; - for (int j = 0; j < i; ++j) + for (var j = 0; j < i; ++j) newList[j] = oldList[j]; - for (int j = i + 1; j < oldList.Length; ++j) + for (var j = i + 1; j < oldList.Length; ++j) newList[j - 1] = oldList[j]; List = newList; @@ -612,25 +616,25 @@ namespace Server public void Remove(int itemID, int x, int y, int z) { - int vx = x + Center.m_X; - int vy = y + Center.m_Y; + var vx = x + Center.m_X; + var vy = y + Center.m_Y; if (vx >= 0 && vx < Width && vy >= 0 && vy < Height) { - StaticTile[] oldTiles = Tiles[vx][vy]; + var oldTiles = Tiles[vx][vy]; - for (int i = 0; i < oldTiles.Length; ++i) + for (var i = 0; i < oldTiles.Length; ++i) { - StaticTile tile = oldTiles[i]; + var tile = oldTiles[i]; if (tile.ID == itemID && tile.Z == z) { - StaticTile[] newTiles = new StaticTile[oldTiles.Length - 1]; + var newTiles = new StaticTile[oldTiles.Length - 1]; - for (int j = 0; j < i; ++j) + for (var j = 0; j < i; ++j) newTiles[j] = oldTiles[j]; - for (int j = i + 1; j < oldTiles.Length; ++j) + for (var j = i + 1; j < oldTiles.Length; ++j) newTiles[j - 1] = oldTiles[j]; Tiles[vx][vy] = newTiles; @@ -639,21 +643,21 @@ namespace Server } } - MultiTileEntry[] oldList = List; + var oldList = List; - for (int i = 0; i < oldList.Length; ++i) + for (var i = 0; i < oldList.Length; ++i) { - MultiTileEntry tile = oldList[i]; + var tile = oldList[i]; - if (tile.m_ItemID == itemID && tile.m_OffsetX == (short)x && tile.m_OffsetY == (short)y && - tile.m_OffsetZ == (short)z) + if (tile.ItemId == itemID && tile.OffsetX == (short)x && tile.OffsetY == (short)y && + tile.OffsetZ == (short)z) { - MultiTileEntry[] newList = new MultiTileEntry[oldList.Length - 1]; + var newList = new MultiTileEntry[oldList.Length - 1]; - for (int j = 0; j < i; ++j) + for (var j = 0; j < i; ++j) newList[j] = oldList[j]; - for (int j = i + 1; j < oldList.Length; ++j) + for (var j = i + 1; j < oldList.Length; ++j) newList[j - 1] = oldList[j]; List = newList; @@ -667,22 +671,22 @@ namespace Server public void Resize(int newWidth, int newHeight) { int oldWidth = Width, oldHeight = Height; - StaticTile[][][] oldTiles = Tiles; + var oldTiles = Tiles; - int totalLength = 0; + var totalLength = 0; - StaticTile[][][] newTiles = new StaticTile[newWidth][][]; + var newTiles = new StaticTile[newWidth][][]; - for (int x = 0; x < newWidth; ++x) + for (var x = 0; x < newWidth; ++x) { newTiles[x] = new StaticTile[newHeight][]; - for (int y = 0; y < newHeight; ++y) + for (var y = 0; y < newHeight; ++y) { if (x < oldWidth && y < oldHeight) newTiles[x][y] = oldTiles[x][y]; else - newTiles[x][y] = new StaticTile[0]; + newTiles[x][y] = Array.Empty(); totalLength += newTiles[x][y].Length; } @@ -696,35 +700,35 @@ namespace Server m_Min = Point2D.Zero; m_Max = Point2D.Zero; - int index = 0; + var index = 0; - for (int x = 0; x < newWidth; ++x) - for (int y = 0; y < newHeight; ++y) - { - StaticTile[] tiles = newTiles[x][y]; - - for (int i = 0; i < tiles.Length; ++i) + for (var x = 0; x < newWidth; ++x) + for (var y = 0; y < newHeight; ++y) { - StaticTile tile = tiles[i]; + var tiles = newTiles[x][y]; - int vx = x - Center.X; - int vy = y - Center.Y; + for (var i = 0; i < tiles.Length; ++i) + { + var tile = tiles[i]; - if (vx < m_Min.m_X) - m_Min.m_X = vx; + var vx = x - Center.X; + var vy = y - Center.Y; - if (vy < m_Min.m_Y) - m_Min.m_Y = vy; + if (vx < m_Min.m_X) + m_Min.m_X = vx; - if (vx > m_Max.m_X) - m_Max.m_X = vx; + if (vy < m_Min.m_Y) + m_Min.m_Y = vy; - if (vy > m_Max.m_Y) - m_Max.m_Y = vy; + if (vx > m_Max.m_X) + m_Max.m_X = vx; - List[index++] = new MultiTileEntry((ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, TileFlag.Background); + if (vy > m_Max.m_Y) + m_Max.m_Y = vy; + + List[index++] = new MultiTileEntry((ushort)tile.ID, (short)vx, (short)vy, (short)tile.Z, TileFlag.Background); + } } - } } public void Serialize(IGenericWriter writer) @@ -740,15 +744,15 @@ namespace Server writer.Write(List.Length); - for (int i = 0; i < List.Length; ++i) + for (var i = 0; i < List.Length; ++i) { - MultiTileEntry ent = List[i]; + var ent = List[i]; - writer.Write(ent.m_ItemID); - writer.Write(ent.m_OffsetX); - writer.Write(ent.m_OffsetY); - writer.Write(ent.m_OffsetZ); - writer.Write((int)ent.m_Flags); + writer.Write(ent.ItemId); + writer.Write(ent.OffsetX); + writer.Write(ent.OffsetY); + writer.Write(ent.OffsetZ); + writer.Write((int)ent.Flags); } } } @@ -761,18 +765,18 @@ namespace Server chunkIds = new Dictionary(); - for (int i = 0; i < maxId; ++i) + for (var i = 0; i < maxId; ++i) chunkIds[HashLittle2($"build/multicollection/{i:000000}.bin")] = i; } private static ulong HashLittle2(string s) { - int length = s.Length; + var length = s.Length; uint b, c; - uint a = b = c = 0xDEADBEEF + (uint)length; + var a = b = c = 0xDEADBEEF + (uint)length; - int k = 0; + var k = 0; while (length > 12) { @@ -789,12 +793,24 @@ namespace Server c += (uint)s[k + 10] << 16; c += (uint)s[k + 11] << 24; - a -= c; a ^= (c << 4) | (c >> 28); c += b; - b -= a; b ^= (a << 6) | (a >> 26); a += c; - c -= b; c ^= (b << 8) | (b >> 24); b += a; - a -= c; a ^= (c << 16) | (c >> 16); c += b; - b -= a; b ^= (a << 19) | (a >> 13); a += c; - c -= b; c ^= (b << 4) | (b >> 28); b += a; + a -= c; + a ^= (c << 4) | (c >> 28); + c += b; + b -= a; + b ^= (a << 6) | (a >> 26); + a += c; + c -= b; + c ^= (b << 8) | (b >> 24); + b += a; + a -= c; + a ^= (c << 16) | (c >> 16); + c += b; + b -= a; + b ^= (a << 19) | (a >> 13); + a += c; + c -= b; + c ^= (b << 4) | (b >> 28); + b += a; length -= 12; k += 12; @@ -804,27 +820,58 @@ namespace Server { switch (length) { - case 12: c += (uint)s[k + 11] << 24; goto case 11; - case 11: c += (uint)s[k + 10] << 16; goto case 10; - case 10: c += (uint)s[k + 9] << 8; goto case 9; - case 9: c += s[k + 8]; goto case 8; - case 8: b += (uint)s[k + 7] << 24; goto case 7; - case 7: b += (uint)s[k + 6] << 16; goto case 6; - case 6: b += (uint)s[k + 5] << 8; goto case 5; - case 5: b += s[k + 4]; goto case 4; - case 4: a += (uint)s[k + 3] << 24; goto case 3; - case 3: a += (uint)s[k + 2] << 16; goto case 2; - case 2: a += (uint)s[k + 1] << 8; goto case 1; - case 1: a += s[k]; break; + case 12: + c += (uint)s[k + 11] << 24; + goto case 11; + case 11: + c += (uint)s[k + 10] << 16; + goto case 10; + case 10: + c += (uint)s[k + 9] << 8; + goto case 9; + case 9: + c += s[k + 8]; + goto case 8; + case 8: + b += (uint)s[k + 7] << 24; + goto case 7; + case 7: + b += (uint)s[k + 6] << 16; + goto case 6; + case 6: + b += (uint)s[k + 5] << 8; + goto case 5; + case 5: + b += s[k + 4]; + goto case 4; + case 4: + a += (uint)s[k + 3] << 24; + goto case 3; + case 3: + a += (uint)s[k + 2] << 16; + goto case 2; + case 2: + a += (uint)s[k + 1] << 8; + goto case 1; + case 1: + a += s[k]; + break; } - c ^= b; c -= (b << 14) | (b >> 18); - a ^= c; a -= (c << 11) | (c >> 21); - b ^= a; b -= (a << 25) | (a >> 7); - c ^= b; c -= (b << 16) | (b >> 16); - a ^= c; a -= (c << 4) | (c >> 28); - b ^= a; b -= (a << 14) | (a >> 18); - c ^= b; c -= (b << 24) | (b >> 8); + c ^= b; + c -= (b << 14) | (b >> 18); + a ^= c; + a -= (c << 11) | (c >> 21); + b ^= a; + b -= (a << 25) | (a >> 7); + c ^= b; + c -= (b << 16) | (b >> 16); + a ^= c; + a -= (c << 4) | (c >> 28); + b ^= a; + b -= (a << 14) | (a >> 18); + c ^= b; + c -= (b << 24) | (b >> 8); } return ((ulong)b << 32) | c; diff --git a/Projects/Server/NativeReader.cs b/Projects/Server/NativeReader.cs index c561a051b..c3220f4de 100644 --- a/Projects/Server/NativeReader.cs +++ b/Projects/Server/NativeReader.cs @@ -36,23 +36,23 @@ namespace Server m_NativeReader = new NativeReaderWin32(); } - public static unsafe void Read(IntPtr ptr, void* buffer, int length) + public static unsafe void Read(IntPtr p, void* buffer, int length) { - m_NativeReader.Read(ptr, buffer, length); + m_NativeReader.Read(p, buffer, length); } } public interface INativeReader { - unsafe void Read(IntPtr ptr, void* buffer, int length); + unsafe void Read(IntPtr p, void* buffer, int length); } public sealed class NativeReaderWin32 : INativeReader { - public unsafe void Read(IntPtr ptr, void* buffer, int length) + public unsafe void Read(IntPtr p, void* buffer, int length) { uint lpNumberOfBytesRead = 0; - UnsafeNativeMethods.ReadFile(ptr, buffer, (uint)length, ref lpNumberOfBytesRead, null); + UnsafeNativeMethods.ReadFile(p, buffer, (uint)length, ref lpNumberOfBytesRead, null); } internal static class UnsafeNativeMethods @@ -68,15 +68,15 @@ namespace Server public sealed class NativeReaderUnix : INativeReader { - public unsafe void Read(IntPtr ptr, void* buffer, int length) + public unsafe void Read(IntPtr p, void* buffer, int length) { - UnsafeNativeMethods.read(ptr, buffer, length); + _ = UnsafeNativeMethods.read(p, buffer, length); } internal static class UnsafeNativeMethods { [DllImport("libc")] - internal static extern unsafe int read(IntPtr ptr, void* buffer, int length); + internal static extern unsafe int read(IntPtr p, void* buffer, int length); } } } diff --git a/Projects/Server/Network/EncodedPacketHandler.cs b/Projects/Server/Network/EncodedPacketHandler.cs index c400b5bbe..d6394f79f 100644 --- a/Projects/Server/Network/EncodedPacketHandler.cs +++ b/Projects/Server/Network/EncodedPacketHandler.cs @@ -31,10 +31,10 @@ namespace Server.Network OnReceive = onReceive; } - public int PacketID{ get; } + public int PacketID { get; } - public OnEncodedPacketReceive OnReceive{ get; } + public OnEncodedPacketReceive OnReceive { get; } - public bool Ingame{ get; } + public bool Ingame { get; } } } diff --git a/Projects/Server/Network/EncodedReader.cs b/Projects/Server/Network/EncodedReader.cs index 2ecca2f8a..d360aa834 100644 --- a/Projects/Server/Network/EncodedReader.cs +++ b/Projects/Server/Network/EncodedReader.cs @@ -33,13 +33,14 @@ namespace Server.Network public int ReadInt32() => m_Reader.ReadByte() != 0 ? 0 : m_Reader.ReadInt32(); - public Point3D ReadPoint3D() => m_Reader.ReadByte() != 3 ? Point3D.Zero : - new Point3D(m_Reader.ReadInt16(), m_Reader.ReadInt16(), m_Reader.ReadByte()); + public Point3D ReadPoint3D() => m_Reader.ReadByte() != 3 + ? Point3D.Zero + : new Point3D(m_Reader.ReadInt16(), m_Reader.ReadInt16(), m_Reader.ReadByte()); - public string ReadUnicodeStringSafe() => m_Reader.ReadByte() != 2 ? string.Empty : - m_Reader.ReadUnicodeStringSafe(m_Reader.ReadUInt16()); + public string ReadUnicodeStringSafe() => + m_Reader.ReadByte() != 2 ? string.Empty : m_Reader.ReadUnicodeStringSafe(m_Reader.ReadUInt16()); - public string ReadUnicodeString() => m_Reader.ReadByte() != 2 ? string.Empty : - m_Reader.ReadUnicodeString(m_Reader.ReadUInt16()); + public string ReadUnicodeString() => + m_Reader.ReadByte() != 2 ? string.Empty : m_Reader.ReadUnicodeString(m_Reader.ReadUInt16()); } } diff --git a/Projects/Server/Network/MessagePumpService.cs b/Projects/Server/Network/MessagePumpService.cs index a4a38afd3..5725325b7 100644 --- a/Projects/Server/Network/MessagePumpService.cs +++ b/Projects/Server/Network/MessagePumpService.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: MessagePumpService.cs * * Created: 2020/04/12 - Updated: 2020/04/12 * @@ -42,10 +42,10 @@ namespace Server.Network public void DoWork() { - int count = 0; + var count = 0; while (!m_WorkQueue.IsEmpty && count++ < 250) { - if (!m_WorkQueue.TryDequeue(out Work work)) + if (!m_WorkQueue.TryDequeue(out var work)) break; work.OnReceive(work.State, new PacketReader(new ReadOnlySequence(work.MemoryOwner.Memory))); @@ -56,6 +56,7 @@ namespace Server.Network private class Work { public readonly NetState State; + // TODO: Force dispose? public readonly IMemoryOwner MemoryOwner; public readonly OnPacketReceive OnReceive; diff --git a/Projects/Server/Network/NetState.cs b/Projects/Server/Network/NetState.cs index 3288a5e71..c85b4841c 100644 --- a/Projects/Server/Network/NetState.cs +++ b/Projects/Server/Network/NetState.cs @@ -22,7 +22,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; -using System.IO.Pipelines; using System.Net; using System.Net.Sockets; using System.Threading; @@ -202,11 +201,11 @@ namespace Server.Network public void ValidateAllTrades() { - for (int i = Trades.Count - 1; i >= 0; --i) + for (var i = Trades.Count - 1; i >= 0; --i) { if (i >= Trades.Count) continue; - SecureTrade trade = Trades[i]; + var trade = Trades[i]; if (trade.From.Mobile.Deleted || trade.To.Mobile.Deleted || !trade.From.Mobile.Alive || !trade.To.Mobile.Alive || !trade.From.Mobile.InRange(trade.To.Mobile, 2) || @@ -216,7 +215,7 @@ namespace Server.Network public void CancelAllTrades() { - for (int i = Trades.Count - 1; i >= 0; --i) + for (var i = Trades.Count - 1; i >= 0; --i) if (i < Trades.Count) Trades[i].Cancel(); } @@ -228,9 +227,9 @@ namespace Server.Network public SecureTrade FindTrade(Mobile m) { - for (int i = 0; i < Trades.Count; ++i) + for (var i = 0; i < Trades.Count; ++i) { - SecureTrade trade = Trades[i]; + var trade = Trades[i]; if (trade.From.Mobile == m || trade.To.Mobile == m) return trade; } @@ -240,12 +239,12 @@ namespace Server.Network public SecureTradeContainer FindTradeContainer(Mobile m) { - for (int i = 0; i < Trades.Count; ++i) + for (var i = 0; i < Trades.Count; ++i) { - SecureTrade trade = Trades[i]; + var trade = Trades[i]; - SecureTradeInfo from = trade.From; - SecureTradeInfo to = trade.To; + var from = trade.From; + var to = trade.To; if (from.Mobile == Mobile && to.Mobile == m) return from.Container; @@ -257,7 +256,7 @@ namespace Server.Network public SecureTradeContainer AddTrade(NetState state) { - SecureTrade newTrade = new SecureTrade(Mobile, state.Mobile); + var newTrade = new SecureTrade(Mobile, state.Mobile); Trades.Add(newTrade); state.Trades.Add(newTrade); @@ -300,7 +299,9 @@ namespace Server.Network Menus ??= new List(); if (Menus.Count < MenuCap) + { Menus.Add(menu); + } else { WriteConsole("Exceeded menu cap, disconnecting..."); @@ -328,7 +329,9 @@ namespace Server.Network HuePickers ??= new List(); if (HuePickers.Count < HuePickerCap) + { HuePickers.Add(huePicker); + } else { WriteConsole("Exceeded hue picker cap, disconnecting..."); @@ -356,7 +359,9 @@ namespace Server.Network Gumps ??= new List(); if (Gumps.Count < GumpCap) + { Gumps.Add(gump); + } else { WriteConsole("Exceeded gump cap, disconnecting..."); @@ -394,8 +399,8 @@ namespace Server.Network public IAccount Account { get; set; } public override string ToString() => m_ToString; - public NetState(ConnectionContext connection) + public NetState(ConnectionContext connection) { Connection = connection; Seeded = false; @@ -443,13 +448,13 @@ namespace Server.Network try { - //TODO: Rented memory - ReadOnlyMemory buffer = p.Compile(CompressionEnabled, out int length); + // TODO: Rented memory + ReadOnlyMemory buffer = p.Compile(CompressionEnabled, out var length); if (buffer.Length > 0 && length > 0) try { - FlushResult result = await outPipe.WriteAsync(buffer.Slice(0, length)); + var result = await outPipe.WriteAsync(buffer.Slice(0, length)); if (result.IsCanceled || result.IsCompleted) { @@ -491,8 +496,7 @@ namespace Server.Network } public PacketHandler GetHandler(int packetID) => - ContainerGridLines ? PacketHandlers.Get6017Handler(packetID) : - PacketHandlers.GetHandler(packetID); + ContainerGridLines ? PacketHandlers.Get6017Handler(packetID) : PacketHandlers.GetHandler(packetID); public static void TraceException(Exception ex) { @@ -501,7 +505,7 @@ namespace Server.Network try { - using StreamWriter op = new StreamWriter("network-errors.log", true); + using var op = new StreamWriter("network-errors.log", true); op.WriteLine("# {0}", DateTime.UtcNow); op.WriteLine(ex); @@ -523,7 +527,7 @@ namespace Server.Network public virtual void Dispose() { - int disposing = Interlocked.Exchange(ref m_Disposing, 1); + var disposing = Interlocked.Exchange(ref m_Disposing, 1); if (disposing == 1) return; @@ -545,15 +549,15 @@ namespace Server.Network public static void ProcessDisposedQueue() { - int breakout = 0; + var breakout = 0; while (breakout++ < 200) { - if (!m_Disposed.TryDequeue(out NetState ns)) + if (!m_Disposed.TryDequeue(out var ns)) break; - Mobile m = ns.Mobile; - IAccount a = ns.Account; + var m = ns.Mobile; + var a = ns.Account; if (m != null) { @@ -579,11 +583,11 @@ namespace Server.Network { get { - for (int i = ExpansionInfo.Table.Length - 1; i >= 0; i--) + for (var i = ExpansionInfo.Table.Length - 1; i >= 0; i--) { - ExpansionInfo info = ExpansionInfo.Table[i]; + var info = ExpansionInfo.Table[i]; - if (info.RequiredClient != null && Version >= info.RequiredClient || (Flags & info.ClientFlags) != 0) + if ((info.RequiredClient != null && Version >= info.RequiredClient) || (Flags & info.ClientFlags) != 0) return info; } @@ -597,13 +601,14 @@ namespace Server.Network public bool SupportsExpansion(ExpansionInfo info, bool checkCoreExpansion = true) { - if (info == null || checkCoreExpansion && (int)Core.Expansion < info.ID) + if (info == null || (checkCoreExpansion && (int)Core.Expansion < info.ID)) return false; return info.RequiredClient != null ? Version >= info.RequiredClient : (Flags & info.ClientFlags) != 0; } - public bool SupportsExpansion(Expansion ex, bool checkCoreExpansion = true) => SupportsExpansion(ExpansionInfo.GetInfo(ex), checkCoreExpansion); + public bool SupportsExpansion(Expansion ex, bool checkCoreExpansion = true) => + SupportsExpansion(ExpansionInfo.GetInfo(ex), checkCoreExpansion); public int CompareTo(NetState other) => other == null ? 1 : m_ToString.CompareTo(other.m_ToString); } diff --git a/Projects/Server/Network/Compression.cs b/Projects/Server/Network/NetworkCompression.cs similarity index 71% rename from Projects/Server/Network/Compression.cs rename to Projects/Server/Network/NetworkCompression.cs index 69b72e808..5dea0bc7f 100644 --- a/Projects/Server/Network/Compression.cs +++ b/Projects/Server/Network/NetworkCompression.cs @@ -27,7 +27,7 @@ namespace Server.Network /// /// Handles outgoing packet compression for the network. /// - public static class Compression + public static class NetworkCompression { private const int CountIndex = 0; private const int ValueIndex = 1; @@ -48,7 +48,8 @@ namespace Server.Network // If our input exceeds this length, we may potentially overflow the buffer private const int PossibleOverflow = (BufferSize * 8 - TerminalCodeLength) / MaximalCodeLength; - private static readonly int[] _huffmanTable = { + private static readonly int[] _huffmanTable = + { 0x2, 0x000, 0x5, 0x01F, 0x6, 0x022, 0x7, 0x034, 0x7, 0x075, 0x6, 0x028, 0x6, 0x03B, 0x7, 0x032, 0x8, 0x0E0, 0x8, 0x062, 0x7, 0x056, 0x8, 0x079, 0x9, 0x19D, 0x8, 0x097, 0x6, 0x02A, 0x7, 0x057, 0x8, 0x071, 0x8, 0x05B, 0x9, 0x1CC, 0x8, 0x0A7, 0x7, 0x025, 0x7, 0x04F, 0x8, 0x066, 0x8, 0x07D, @@ -86,7 +87,7 @@ namespace Server.Network public static readonly ICompressor Compressor; - static Compression() + static NetworkCompression() { if (Core.Unix) Compressor = new UnixCompressor(); @@ -100,14 +101,14 @@ namespace Server.Network if (offset < 0 || offset >= input.Length) throw new ArgumentOutOfRangeException(nameof(offset)); if (count < 0 || count > input.Length) throw new ArgumentOutOfRangeException(nameof(count)); - if (input.Length - offset < count) throw new ArgumentException(); + if (input.Length - offset < count) throw new ArgumentOutOfRangeException(nameof(offset)); length = 0; if (count > DefiniteOverflow) return; - int bitCount = 0; - int bitValue = 0; + var bitCount = 0; + var bitValue = 0; fixed (int* pTable = _huffmanTable) { @@ -185,10 +186,11 @@ namespace Server.Network public static unsafe ZLibError Pack(Span dest, ref int destLength, ReadOnlySpan source, int sourceLength) { - ulong destLengthLong = (ulong)destLength; + var destLengthLong = (ulong)destLength; fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) { - ZLibError e = Compressor.Compress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), (ulong)sourceLength); + var e = Compressor.Compress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), + (ulong)sourceLength); destLength = (int)destLengthLong; return e; } @@ -196,21 +198,24 @@ namespace Server.Network public static unsafe ZLibError Pack(Span dest, ref int destLength, ReadOnlySpan source, ZLibQuality quality) { - ulong destLengthLong = (ulong)destLength; + var destLengthLong = (ulong)destLength; fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) { - ZLibError e = Compressor.Compress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), (ulong)source.Length, quality); + var e = Compressor.Compress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), + (ulong)source.Length, quality); destLength = (int)destLengthLong; return e; } } - public static unsafe ZLibError Pack(Span dest, ref int destLength, ReadOnlySpan source, int sourceLength, ZLibQuality quality) + public static unsafe ZLibError Pack(Span dest, ref int destLength, ReadOnlySpan source, int sourceLength, + ZLibQuality quality) { - ulong destLengthLong = (ulong)destLength; + var destLengthLong = (ulong)destLength; fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) { - ZLibError e = Compressor.Compress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), (ulong)sourceLength, quality); + var e = Compressor.Compress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), + (ulong)sourceLength, quality); destLength = (int)destLengthLong; return e; } @@ -218,10 +223,11 @@ namespace Server.Network public static unsafe ZLibError Unpack(Span dest, ref int destLength, ReadOnlySpan source, int sourceLength) { - ulong destLengthLong = (ulong)destLength; + var destLengthLong = (ulong)destLength; fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) { - ZLibError e = Compressor.Decompress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), (ulong)sourceLength); + var e = Compressor.Decompress(Unsafe.AsRef(dPtr), ref destLengthLong, Unsafe.AsRef(sPtr), + (ulong)sourceLength); destLength = (int)destLengthLong; return e; } @@ -231,26 +237,38 @@ namespace Server.Network public static unsafe ZLibError Pack(Span dest, ref ulong destLength, ReadOnlySpan source, ulong sourceLength) { - fixed(byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) + fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) + { return Compressor.Compress(Unsafe.AsRef(dPtr), ref destLength, Unsafe.AsRef(sPtr), sourceLength); + } } - public static unsafe ZLibError Pack(Span dest, ref ulong destLength, ReadOnlySpan source, ZLibQuality quality) + public static unsafe ZLibError Pack(Span dest, ref ulong destLength, ReadOnlySpan source, + ZLibQuality quality) { - fixed(byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) - return Compressor.Compress(Unsafe.AsRef(dPtr), ref destLength, Unsafe.AsRef(sPtr), (ulong)source.Length, quality); + fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) + { + return Compressor.Compress(Unsafe.AsRef(dPtr), ref destLength, Unsafe.AsRef(sPtr), (ulong)source.Length, + quality); + } } - public static unsafe ZLibError Pack(Span dest, ref ulong destLength, ReadOnlySpan source, ulong sourceLength, ZLibQuality quality) + public static unsafe ZLibError Pack(Span dest, ref ulong destLength, ReadOnlySpan source, ulong sourceLength, + ZLibQuality quality) { - fixed(byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) + fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) + { return Compressor.Compress(Unsafe.AsRef(dPtr), ref destLength, Unsafe.AsRef(sPtr), sourceLength, quality); + } } - public static unsafe ZLibError Unpack(Span dest, ref ulong destLength, ReadOnlySpan source, ulong sourceLength) + public static unsafe ZLibError Unpack(Span dest, ref ulong destLength, ReadOnlySpan source, + ulong sourceLength) { - fixed(byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) + fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source)) + { return Compressor.Decompress(Unsafe.AsRef(dPtr), ref destLength, Unsafe.AsRef(sPtr), sourceLength); + } } } @@ -265,66 +283,72 @@ namespace Server.Network public class Compressor : ICompressor { - public string Version => zlibVersion(); + public string Version => SafeNativeMethods.zlibVersion(); public ZLibError Compress(in int dest, ref ulong destLength, in int source, ulong sourceLength) => - compress(dest, ref destLength, source, sourceLength); + SafeNativeMethods.compress(dest, ref destLength, source, sourceLength); public ZLibError Compress(in int dest, ref ulong destLength, in int source, ulong sourceLength, - ZLibQuality quality) => compress2(dest, ref destLength, source, sourceLength, quality); + ZLibQuality quality) => SafeNativeMethods.compress2(dest, ref destLength, source, sourceLength, quality); public ZLibError Decompress(in int dest, ref ulong destLength, in int source, ulong sourceLength) => - uncompress(dest, ref destLength, source, sourceLength); + SafeNativeMethods.uncompress(dest, ref destLength, source, sourceLength); - public ulong CompressBound(ulong sourceLength) => compressBound(sourceLength); + public ulong CompressBound(ulong sourceLength) => SafeNativeMethods.compressBound(sourceLength); - [DllImport("zlib")] - private static extern string zlibVersion(); + private static class SafeNativeMethods + { + [DllImport("zlib", CharSet = CharSet.Unicode)] + internal static extern string zlibVersion(); - [DllImport("zlib")] - private static extern ZLibError compress(in int dest, ref ulong destLength, in int source, ulong sourceLength); + [DllImport("zlib")] + internal static extern ZLibError compress(in int dest, ref ulong destLength, in int source, ulong sourceLength); - [DllImport("zlib")] - private static extern ZLibError compress2(in int dest, ref ulong destLength, in int source, ulong sourceLength, - ZLibQuality quality); + [DllImport("zlib")] + internal static extern ZLibError compress2(in int dest, ref ulong destLength, in int source, ulong sourceLength, + ZLibQuality quality); - [DllImport("zlib")] - private static extern ZLibError uncompress(in int dest, ref ulong destLength, in int source, ulong sourceLength); + [DllImport("zlib")] + internal static extern ZLibError uncompress(in int dest, ref ulong destLength, in int source, ulong sourceLength); - [DllImport("zlib")] - private static extern ulong compressBound(ulong sourceLen); + [DllImport("zlib")] + internal static extern ulong compressBound(ulong sourceLen); + } } public class UnixCompressor : ICompressor { - public string Version => zlibVersion(); + public string Version => SafeNativeMethods.zlibVersion(); public ZLibError Compress(in int dest, ref ulong destLength, in int source, ulong sourceLength) => - compress(dest, ref destLength, source, sourceLength); + SafeNativeMethods.compress(dest, ref destLength, source, sourceLength); public ZLibError Compress(in int dest, ref ulong destLength, in int source, ulong sourceLength, - ZLibQuality quality) => compress2(dest, ref destLength, source, sourceLength, quality); + ZLibQuality quality) => SafeNativeMethods.compress2(dest, ref destLength, source, sourceLength, quality); public ZLibError Decompress(in int dest, ref ulong destLength, in int source, ulong sourceLength) => - uncompress(dest, ref destLength, source, sourceLength); + SafeNativeMethods.uncompress(dest, ref destLength, source, sourceLength); - public ulong CompressBound(ulong sourceLength) => compressBound(sourceLength); + public ulong CompressBound(ulong sourceLength) => SafeNativeMethods.compressBound(sourceLength); - [DllImport("libz")] - private static extern string zlibVersion(); + internal static class SafeNativeMethods + { + [DllImport("libz", CharSet = CharSet.Unicode)] + internal static extern string zlibVersion(); - [DllImport("libz")] - private static extern ZLibError compress(in int dest, ref ulong destLength, in int source, ulong sourceLength); + [DllImport("libz")] + internal static extern ZLibError compress(in int dest, ref ulong destLength, in int source, ulong sourceLength); - [DllImport("libz")] - private static extern ZLibError compress2(in int dest, ref ulong destLength, in int source, ulong sourceLength, - ZLibQuality quality); + [DllImport("libz")] + internal static extern ZLibError compress2(in int dest, ref ulong destLength, in int source, ulong sourceLength, + ZLibQuality quality); - [DllImport("libz")] - private static extern ZLibError uncompress(in int dest, ref ulong destLength, in int source, ulong sourceLength); + [DllImport("libz")] + internal static extern ZLibError uncompress(in int dest, ref ulong destLength, in int source, ulong sourceLength); - [DllImport("libz")] - private static extern ulong compressBound(ulong sourceLen); + [DllImport("libz")] + internal static extern ulong compressBound(ulong sourceLen); + } } public enum ZLibError diff --git a/Projects/Server/Network/Packet.cs b/Projects/Server/Network/Packet.cs index 6f6d54f7c..03c9b31ae 100644 --- a/Projects/Server/Network/Packet.cs +++ b/Projects/Server/Network/Packet.cs @@ -18,11 +18,11 @@ * ***************************************************************************/ -using Server.Diagnostics; using System; using System.Buffers; using System.Diagnostics; using System.IO; +using Server.Diagnostics; namespace Server.Network { @@ -37,15 +37,13 @@ namespace Server.Network private readonly int m_Length; private State m_State; - protected PacketWriter m_Stream; - protected Packet(int packetID) { PacketID = packetID; if (Core.Profiling) { - PacketSendProfile prof = PacketSendProfile.Acquire(GetType()); + var prof = PacketSendProfile.Acquire(GetType()); prof.Increment(); } } @@ -55,25 +53,25 @@ namespace Server.Network PacketID = packetID; m_Length = length; - m_Stream = PacketWriter.CreateInstance(length); // new PacketWriter( length ); - m_Stream.Write((byte)packetID); + Stream = PacketWriter.CreateInstance(length); // new PacketWriter( length ); + Stream.Write((byte)packetID); if (Core.Profiling) { - PacketSendProfile prof = PacketSendProfile.Acquire(GetType()); + var prof = PacketSendProfile.Acquire(GetType()); prof.Increment(); } } public int PacketID { get; } - public PacketWriter UnderlyingStream => m_Stream; + public PacketWriter Stream { get; protected set; } public void EnsureCapacity(int length) { - m_Stream = PacketWriter.CreateInstance(length); // new PacketWriter( length ); - m_Stream.Write((byte)PacketID); - m_Stream.Write((short)0); + Stream = PacketWriter.CreateInstance(length); // new PacketWriter( length ); + Stream.Write((byte)PacketID); + Stream.Write((short)0); } public static Packet SetStatic(Packet p) @@ -154,7 +152,7 @@ namespace Server.Network try { - using StreamWriter op = new StreamWriter("net_opt.log", true); + using var op = new StreamWriter("net_opt.log", true); op.WriteLine("Redundant compile for packet {0}, use Acquire() and Release()", GetType()); op.WriteLine(new StackTrace()); } @@ -164,7 +162,7 @@ namespace Server.Network } } - m_CompiledBuffer = new byte[0]; + m_CompiledBuffer = Array.Empty(); m_CompiledLength = 0; length = m_CompiledLength; @@ -183,35 +181,35 @@ namespace Server.Network { if (m_Length == 0) { - long streamLen = m_Stream.Length; + var streamLen = Stream.Length; - m_Stream.Seek(1, SeekOrigin.Begin); - m_Stream.Write((ushort)streamLen); + Stream.Seek(1, SeekOrigin.Begin); + Stream.Write((ushort)streamLen); } - else if (m_Stream.Length != m_Length) + else if (Stream.Length != m_Length) { - int diff = (int)m_Stream.Length - m_Length; + var diff = (int)Stream.Length - m_Length; Console.WriteLine("Packet: 0x{0:X2}: Bad packet length! ({1}{2} bytes)", PacketID, diff >= 0 ? "+" : "", diff); } - MemoryStream ms = m_Stream.UnderlyingStream; + var ms = Stream.UnderlyingStream; m_CompiledBuffer = ms.GetBuffer(); - int length = (int)ms.Length; + var length = (int)ms.Length; if (compress) { - byte[] buffer = ArrayPool.Shared.Rent(CompressorBufferSize); + var buffer = ArrayPool.Shared.Rent(CompressorBufferSize); - Compression.Compress(m_CompiledBuffer, 0, length, buffer, out length); + NetworkCompression.Compress(m_CompiledBuffer, 0, length, buffer, out length); if (length <= 0) { Console.WriteLine("Warning: Compression buffer overflowed on packet 0x{0:X2} ('{1}') (length={2})", PacketID, GetType().Name, length); - using StreamWriter op = new StreamWriter("compression_overflow.log", true); + using var op = new StreamWriter("compression_overflow.log", true); op.WriteLine("{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})", DateTime.UtcNow, PacketID, GetType().Name, length); op.WriteLine(new StackTrace()); @@ -235,11 +233,13 @@ namespace Server.Network } else if (length > 0) { - byte[] old = m_CompiledBuffer; + var old = m_CompiledBuffer; m_CompiledLength = length; if ((m_State & State.Static) != 0) + { m_CompiledBuffer = new byte[length]; + } else { m_CompiledBuffer = ArrayPool.Shared.Rent(length); @@ -249,8 +249,8 @@ namespace Server.Network Buffer.BlockCopy(old, 0, m_CompiledBuffer, 0, length); } - PacketWriter.ReleaseInstance(m_Stream); - m_Stream = null; + PacketWriter.ReleaseInstance(Stream); + Stream = null; } [Flags] diff --git a/Projects/Server/Network/PacketHandler.cs b/Projects/Server/Network/PacketHandler.cs index 3b87df425..b5942788d 100644 --- a/Projects/Server/Network/PacketHandler.cs +++ b/Projects/Server/Network/PacketHandler.cs @@ -36,14 +36,14 @@ namespace Server.Network OnReceive = onReceive; } - public int PacketID{ get; } + public int PacketID { get; } - public int Length{ get; } + public int Length { get; } - public OnPacketReceive OnReceive{ get; } + public OnPacketReceive OnReceive { get; } - public ThrottlePacketCallback ThrottleCallback{ get; set; } + public ThrottlePacketCallback ThrottleCallback { get; set; } - public bool Ingame{ get; } + public bool Ingame { get; } } } diff --git a/Projects/Server/Network/PacketHandlers.cs b/Projects/Server/Network/PacketHandlers.cs index 5dad2e534..34346b734 100644 --- a/Projects/Server/Network/PacketHandlers.cs +++ b/Projects/Server/Network/PacketHandlers.cs @@ -22,14 +22,10 @@ using System; using System.Buffers; using System.Collections.Generic; using System.IO; -using Server.Accounting; using Server.ContextMenus; using Server.Diagnostics; using Server.Gumps; -using Server.HuePickers; using Server.Items; -using Server.Menus; -using Server.Prompts; using Server.Targeting; using CV = Server.ClientVersion; @@ -62,49 +58,26 @@ namespace Server.Network private const int BadUOTD = unchecked((int)0xFFCEFFCE); private const int m_AuthIDWindowSize = 128; - private static readonly PacketHandler[] m_6017Handlers; + private static readonly PacketHandler[] m_6017Handlers = new PacketHandler[0x100]; - private static readonly PacketHandler[] m_ExtendedHandlersLow; - private static readonly Dictionary m_ExtendedHandlersHigh; + private static readonly PacketHandler[] m_ExtendedHandlersLow = new PacketHandler[0x100]; + private static readonly Dictionary m_ExtendedHandlersHigh = new Dictionary(); - private static readonly EncodedPacketHandler[] m_EncodedHandlersLow; - private static readonly Dictionary m_EncodedHandlersHigh; + private static readonly EncodedPacketHandler[] m_EncodedHandlersLow = new EncodedPacketHandler[0x100]; + private static readonly Dictionary m_EncodedHandlersHigh = new Dictionary(); - private static readonly int[] m_EmptyInts = new int[0]; + private static readonly int[] m_EmptyInts = Array.Empty(); private static readonly KeywordList m_KeywordList = new KeywordList(); - public static int[] m_ValidAnimations = - { - 6, 21, 32, 33, - 100, 101, 102, - 103, 104, 105, - 106, 107, 108, - 109, 110, 111, - 112, 113, 114, - 115, 116, 117, - 118, 119, 120, - 121, 123, 124, - 125, 126, 127, - 128 - }; - - public static PlayCharCallback ThirdPartyAuthCallback = null, ThirdPartyHackedCallback = null; + public static PlayCharCallback ThirdPartyAuthCallback { get; set; } + public static PlayCharCallback ThirdPartyHackedCallback { get; set; } private static readonly Dictionary m_AuthIDWindow = new Dictionary(m_AuthIDWindowSize); static PacketHandlers() { - Handlers = new PacketHandler[0x100]; - m_6017Handlers = new PacketHandler[0x100]; - - m_ExtendedHandlersLow = new PacketHandler[0x100]; - m_ExtendedHandlersHigh = new Dictionary(); - - m_EncodedHandlersLow = new EncodedPacketHandler[0x100]; - m_EncodedHandlersHigh = new Dictionary(); - Register(0x00, 104, false, CreateCharacter); Register(0x01, 5, false, Disconnect); Register(0x02, 7, true, MovementReq); @@ -192,17 +165,26 @@ namespace Server.Network RegisterEncoded(0x32, true, QuestGumpRequest); } - public static PacketHandler[] Handlers{ get; } + public static PacketHandler[] Handlers { get; } = new PacketHandler[0x100]; - public static bool SingleClickProps{ get; set; } + public static bool SingleClickProps { get; set; } - public static int[] ValidAnimations - { - get => m_ValidAnimations; - set => m_ValidAnimations = value; - } + // TODO: Change to outside configuration + public static int[] ValidAnimations { get; set; } = { + 6, 21, 32, 33, + 100, 101, 102, + 103, 104, 105, + 106, 107, 108, + 109, 110, 111, + 112, 113, 114, + 115, 116, 117, + 118, 119, 120, + 121, 123, 124, + 125, 126, 127, + 128 + }; - public static bool ClientVerification{ get; set; } = true; + public static bool ClientVerification { get; set; } = true; public static void Register(int packetID, int length, bool ingame, OnPacketReceive onReceive) { @@ -232,7 +214,7 @@ namespace Server.Network if (packetID >= 0 && packetID < 0x100) return m_ExtendedHandlersLow[packetID]; - m_ExtendedHandlersHigh.TryGetValue(packetID, out PacketHandler handler); + m_ExtendedHandlersHigh.TryGetValue(packetID, out var handler); return handler; } @@ -257,7 +239,7 @@ namespace Server.Network if (packetID >= 0 && packetID < 0x100) return m_EncodedHandlersLow[packetID]; - m_EncodedHandlersHigh.TryGetValue(packetID, out EncodedPacketHandler handler); + m_EncodedHandlersHigh.TryGetValue(packetID, out var handler); return handler; } @@ -271,7 +253,7 @@ namespace Server.Network public static void RegisterThrottler(int packetID, ThrottlePacketCallback t) { - PacketHandler ph = GetHandler(packetID); + var ph = GetHandler(packetID); if (ph != null) ph.ThrottleCallback = t; @@ -286,9 +268,9 @@ namespace Server.Network public static int ProcessPacket(IMessagePumpService pump, NetState ns, in ReadOnlySequence seq) { - PacketReader r = new PacketReader(seq); + var r = new PacketReader(seq); - if (!r.TryReadByte(out byte packetId)) + if (!r.TryReadByte(out var packetId)) { ns.Dispose(); return -1; @@ -298,13 +280,13 @@ namespace Server.Network { if (packetId == 0xEF) { - // new packet in client 6.0.5.0 replaces the traditional seed method with a seed packet - // 0xEF = 239 = multicast IP, so this should never appear in a normal seed. So this is backwards compatible with older clients. + // new packet in client 6.0.5.0 replaces the traditional seed method with a seed packet + // 0xEF = 239 = multicast IP, so this should never appear in a normal seed. So this is backwards compatible with older clients. ns.Seeded = true; } else { - int seed = packetId << 24 | r.ReadByte() << 16 | r.ReadByte() << 8 | r.ReadByte(); + var seed = (packetId << 24) | (r.ReadByte() << 16) | (r.ReadByte() << 8) | r.ReadByte(); if (seed == 0) { @@ -327,7 +309,7 @@ namespace Server.Network } // Get Handlers - PacketHandler handler = ns.GetHandler(packetId); + var handler = ns.GetHandler(packetId); if (handler == null) { @@ -335,7 +317,7 @@ namespace Server.Network return -1; } - int packetLength = handler.Length; + var packetLength = handler.Length; if (handler.Length <= 0 && r.Length >= 3) { packetLength = r.ReadUInt16(); @@ -354,20 +336,19 @@ namespace Server.Network Console.WriteLine( "Client: {0}: Sent ingame packet (0x{1:X2}) without being attached to a valid mobile.", ns, - packetId - ); + packetId); ns.Dispose(); return -1; } - ThrottlePacketCallback throttler = handler.ThrottleCallback; - TimeSpan throttled = handler.ThrottleCallback?.Invoke(ns) ?? TimeSpan.Zero; + var throttler = handler.ThrottleCallback; + var throttled = handler.ThrottleCallback?.Invoke(ns) ?? TimeSpan.Zero; if (throttled > TimeSpan.Zero) ns.ThrottledUntil = DateTime.UtcNow + throttled; - ReadOnlySequence packet = seq.Slice(r.Position); - IMemoryOwner memOwner = _memoryPool.Rent((int)packet.Length); + var packet = seq.Slice(r.Position); + var memOwner = _memoryPool.Rent((int)packet.Length); packet.CopyTo(memOwner.Memory.Span); @@ -401,10 +382,10 @@ namespace Server.Network public static void EncodedCommand(NetState state, PacketReader pvSrc) { - IEntity e = World.FindEntity(pvSrc.ReadUInt32()); + var e = World.FindEntity(pvSrc.ReadUInt32()); int packetId = pvSrc.ReadUInt16(); - EncodedPacketHandler ph = GetEncodedHandler(packetId); + var ph = GetEncodedHandler(packetId); if (ph != null) { @@ -432,8 +413,8 @@ namespace Server.Network public static void RenameRequest(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; - Mobile targ = World.FindMobile(pvSrc.ReadUInt32()); + var from = state.Mobile; + var targ = World.FindMobile(pvSrc.ReadUInt32()); if (targ != null) EventSink.InvokeRenameRequest(from, targ, pvSrc.ReadStringSafe()); @@ -449,67 +430,67 @@ namespace Server.Network switch (pvSrc.ReadByte()) { case 1: // Cancel - { - Serial serial = pvSrc.ReadUInt32(); + { + Serial serial = pvSrc.ReadUInt32(); - if (World.FindItem(serial) is SecureTradeContainer cont && cont.Trade != null && - (cont.Trade.From.Mobile == state.Mobile || cont.Trade.To.Mobile == state.Mobile)) - cont.Trade.Cancel(); + if (World.FindItem(serial) is SecureTradeContainer cont && cont.Trade != null && + (cont.Trade.From.Mobile == state.Mobile || cont.Trade.To.Mobile == state.Mobile)) + cont.Trade.Cancel(); - break; - } + break; + } case 2: // Check - { - Serial serial = pvSrc.ReadUInt32(); - - if (World.FindItem(serial) is SecureTradeContainer cont) { - SecureTrade trade = cont.Trade; + Serial serial = pvSrc.ReadUInt32(); - bool value = pvSrc.ReadInt32() != 0; + if (World.FindItem(serial) is SecureTradeContainer cont) + { + var trade = cont.Trade; - if (trade != null && trade.From.Mobile == state.Mobile) - { - trade.From.Accepted = value; - trade.Update(); - } - else if (trade != null && trade.To.Mobile == state.Mobile) - { - trade.To.Accepted = value; - trade.Update(); + var value = pvSrc.ReadInt32() != 0; + + if (trade != null && trade.From.Mobile == state.Mobile) + { + trade.From.Accepted = value; + trade.Update(); + } + else if (trade != null && trade.To.Mobile == state.Mobile) + { + trade.To.Accepted = value; + trade.Update(); + } } + + break; } - - break; - } case 3: // Update Gold - { - Serial serial = pvSrc.ReadUInt32(); - - if (World.FindItem(serial) is SecureTradeContainer cont) { - int gold = pvSrc.ReadInt32(); - int plat = pvSrc.ReadInt32(); + Serial serial = pvSrc.ReadUInt32(); - SecureTrade trade = cont.Trade; - - if (trade != null) + if (World.FindItem(serial) is SecureTradeContainer cont) { - if (trade.From.Mobile == state.Mobile) + var gold = pvSrc.ReadInt32(); + var plat = pvSrc.ReadInt32(); + + var trade = cont.Trade; + + if (trade != null) { - trade.From.Gold = gold; - trade.From.Plat = plat; - trade.UpdateFromCurrency(); - } - else if (trade.To.Mobile == state.Mobile) - { - trade.To.Gold = gold; - trade.To.Plat = plat; - trade.UpdateToCurrency(); + if (trade.From.Mobile == state.Mobile) + { + trade.From.Gold = gold; + trade.From.Plat = plat; + trade.UpdateFromCurrency(); + } + else if (trade.To.Mobile == state.Mobile) + { + trade.To.Gold = gold; + trade.To.Plat = plat; + trade.UpdateToCurrency(); + } } } } - } break; } } @@ -519,8 +500,8 @@ namespace Server.Network pvSrc.Seek(1, SeekOrigin.Begin); int msgSize = pvSrc.ReadUInt16(); - Mobile vendor = World.FindMobile(pvSrc.ReadUInt32()); - byte flag = pvSrc.ReadByte(); + var vendor = World.FindMobile(pvSrc.ReadUInt32()); + var flag = pvSrc.ReadByte(); if (vendor == null) return; @@ -538,10 +519,10 @@ namespace Server.Network if (msgSize / 7 > 100) return; - List buyList = new List(msgSize / 7); + var buyList = new List(msgSize / 7); while (msgSize > 0) { - byte layer = pvSrc.ReadByte(); + var layer = pvSrc.ReadByte(); Serial serial = pvSrc.ReadUInt32(); int amount = pvSrc.ReadInt16(); @@ -561,7 +542,7 @@ namespace Server.Network public static void VendorSellReply(NetState state, PacketReader pvSrc) { Serial serial = pvSrc.ReadUInt32(); - Mobile vendor = World.FindMobile(serial); + var vendor = World.FindMobile(serial); if (vendor == null) return; @@ -575,15 +556,15 @@ namespace Server.Network if (count < 100 && pvSrc.Length == 4 + 2 + count * 6) { - List sellList = new List(count); + var sellList = new List(count); - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { - Item item = World.FindItem(pvSrc.ReadUInt32()); - int Amount = pvSrc.ReadInt16(); + var item = World.FindItem(pvSrc.ReadUInt32()); + int amount = pvSrc.ReadInt16(); - if (item != null && Amount > 0) - sellList.Add(new SellItemResponse(item, Amount)); + if (item != null && amount > 0) + sellList.Add(new SellItemResponse(item, amount)); } if (sellList.Count > 0 && vendor is IVendor v && v.OnSellItems(state.Mobile, sellList)) @@ -594,7 +575,7 @@ namespace Server.Network public static void DeleteCharacter(NetState state, PacketReader pvSrc) { pvSrc.Seek(30, SeekOrigin.Current); - int index = pvSrc.ReadInt32(); + var index = pvSrc.ReadInt32(); EventSink.InvokeDeleteRequest(state, index); } @@ -606,15 +587,15 @@ namespace Server.Network public static void ObjectHelpRequest(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; Serial serial = pvSrc.ReadUInt32(); int unk = pvSrc.ReadByte(); - string lang = pvSrc.ReadString(3); + var lang = pvSrc.ReadString(3); if (serial.IsItem) { - Item item = World.FindItem(serial); + var item = World.FindItem(serial); if (item != null && from.Map == item.Map && Utility.InUpdateRange(item.GetWorldLocation(), from.Location) && from.CanSee(item)) @@ -622,7 +603,7 @@ namespace Server.Network } else if (serial.IsMobile) { - Mobile m = World.FindMobile(serial); + var m = World.FindMobile(serial); if (m != null && from.Map == m.Map && Utility.InUpdateRange(m.Location, from.Location) && from.CanSee(m)) m.OnHelpRequest(m); @@ -631,7 +612,7 @@ namespace Server.Network public static void MobileNameRequest(NetState state, PacketReader pvSrc) { - Mobile m = World.FindMobile(pvSrc.ReadUInt32()); + var m = World.FindMobile(pvSrc.ReadUInt32()); if (m != null && Utility.InUpdateRange(state.Mobile, m) && state.Mobile.CanSee(m)) state.Send(new MobileName(m)); @@ -645,8 +626,8 @@ namespace Server.Network public static void AttackReq(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; - Mobile m = World.FindMobile(pvSrc.ReadUInt32()); + var from = state.Mobile; + var m = World.FindMobile(pvSrc.ReadUInt32()); if (m != null) from.Attack(m); @@ -654,13 +635,13 @@ namespace Server.Network public static void HuePickerResponse(NetState state, PacketReader pvSrc) { - uint serial = pvSrc.ReadUInt32(); + var serial = pvSrc.ReadUInt32(); int value = pvSrc.ReadInt16(); - int hue = pvSrc.ReadInt16() & 0x3FFF; + var hue = pvSrc.ReadInt16() & 0x3FFF; hue = Utility.ClipDyedHue(hue); - foreach (HuePicker huePicker in state.HuePickers) + foreach (var huePicker in state.HuePickers) if (huePicker.Serial == serial) { state.RemoveHuePicker(huePicker); @@ -676,15 +657,15 @@ namespace Server.Network int v1 = pvSrc.ReadByte(); int v2 = pvSrc.ReadUInt16(); int v3 = pvSrc.ReadByte(); - string s1 = pvSrc.ReadString(32); - string s2 = pvSrc.ReadString(32); - string s3 = pvSrc.ReadString(32); - string s4 = pvSrc.ReadString(32); + var s1 = pvSrc.ReadString(32); + var s2 = pvSrc.ReadString(32); + var s3 = pvSrc.ReadString(32); + var s4 = pvSrc.ReadString(32); int v4 = pvSrc.ReadUInt16(); int v5 = pvSrc.ReadUInt16(); - int v6 = pvSrc.ReadInt32(); - int v7 = pvSrc.ReadInt32(); - int v8 = pvSrc.ReadInt32(); + var v6 = pvSrc.ReadInt32(); + var v7 = pvSrc.ReadInt32(); + var v8 = pvSrc.ReadInt32(); } public static void AccountID(NetState state, PacketReader pvSrc) @@ -694,104 +675,104 @@ namespace Server.Network public static void TextCommand(NetState state, PacketReader pvSrc) { int type = pvSrc.ReadByte(); - string command = pvSrc.ReadString(); + var command = pvSrc.ReadString(); - Mobile m = state.Mobile; + var m = state.Mobile; switch (type) { case 0xC7: // Animate - { - EventSink.InvokeAnimateRequest(m, command); - - break; - } - case 0x24: // Use skill - { - if (!int.TryParse(command.Split(' ')[0], out int skillIndex)) - break; - - Skills.UseSkill(m, skillIndex); - - break; - } - case 0x43: // Open spellbook - { - if (!int.TryParse(command, out int booktype)) - booktype = 1; - - EventSink.InvokeOpenSpellbookRequest(m, booktype); - - break; - } - case 0x27: // Cast spell from book - { - string[] split = command.Split(' '); - - if (split.Length > 0) { - int spellID = Utility.ToInt32(split[0]) - 1; - uint serial = split.Length > 1 ? Utility.ToUInt32(split[1]) : (uint)Serial.MinusOne; + EventSink.InvokeAnimateRequest(m, command); - EventSink.InvokeCastSpellRequest(m, spellID, World.FindItem(serial)); + break; } + case 0x24: // Use skill + { + if (!int.TryParse(command.Split(' ')[0], out var skillIndex)) + break; - break; - } + Skills.UseSkill(m, skillIndex); + + break; + } + case 0x43: // Open spellbook + { + if (!int.TryParse(command, out var booktype)) + booktype = 1; + + EventSink.InvokeOpenSpellbookRequest(m, booktype); + + break; + } + case 0x27: // Cast spell from book + { + var split = command.Split(' '); + + if (split.Length > 0) + { + var spellID = Utility.ToInt32(split[0]) - 1; + var serial = split.Length > 1 ? Utility.ToUInt32(split[1]) : (uint)Serial.MinusOne; + + EventSink.InvokeCastSpellRequest(m, spellID, World.FindItem(serial)); + } + + break; + } case 0x58: // Open door - { - EventSink.InvokeOpenDoorMacroUsed(m); + { + EventSink.InvokeOpenDoorMacroUsed(m); - break; - } + break; + } case 0x56: // Cast spell from macro - { - int spellID = Utility.ToInt32(command) - 1; + { + var spellID = Utility.ToInt32(command) - 1; - EventSink.InvokeCastSpellRequest(m, spellID, null); + EventSink.InvokeCastSpellRequest(m, spellID, null); - break; - } + break; + } case 0xF4: // Invoke virtues from macro - { - int virtueID = Utility.ToInt32(command) - 1; + { + var virtueID = Utility.ToInt32(command) - 1; - EventSink.InvokeVirtueMacroRequest(m, virtueID); + EventSink.InvokeVirtueMacroRequest(m, virtueID); - break; - } + break; + } case 0x2F: // Old scroll double click - { - /* - * This command is still sent for items 0xEF3 - 0xEF9 - * - * Command is one of three, depending on the item ID of the scroll: - * - [scroll serial] - * - [scroll serial] [target serial] - * - [scroll serial] [x] [y] [z] - */ - break; - } + { + /* + * This command is still sent for items 0xEF3 - 0xEF9 + * + * Command is one of three, depending on the item ID of the scroll: + * - [scroll serial] + * - [scroll serial] [target serial] + * - [scroll serial] [x] [y] [z] + */ + break; + } default: - { - Console.WriteLine("Client: {0}: Unknown text-command type 0x{1:X2}: {2}", state, type, command); - break; - } + { + Console.WriteLine("Client: {0}: Unknown text-command type 0x{1:X2}: {2}", state, type, command); + break; + } } } public static void AsciiPromptResponse(NetState state, PacketReader pvSrc) { - uint serial = pvSrc.ReadUInt32(); - int prompt = pvSrc.ReadInt32(); - int type = pvSrc.ReadInt32(); - string text = pvSrc.ReadStringSafe(); + var serial = pvSrc.ReadUInt32(); + var prompt = pvSrc.ReadInt32(); + var type = pvSrc.ReadInt32(); + var text = pvSrc.ReadStringSafe(); if (text.Length > 128) return; - Mobile from = state.Mobile; - Prompt p = from.Prompt; + var from = state.Mobile; + var p = from.Prompt; if (p != null && p.Serial == serial && p.Serial == prompt) { @@ -806,17 +787,17 @@ namespace Server.Network public static void UnicodePromptResponse(NetState state, PacketReader pvSrc) { - uint serial = pvSrc.ReadUInt32(); - int prompt = pvSrc.ReadInt32(); - int type = pvSrc.ReadInt32(); - string lang = pvSrc.ReadString(4); - string text = pvSrc.ReadUnicodeStringLESafe(); + var serial = pvSrc.ReadUInt32(); + var prompt = pvSrc.ReadInt32(); + var type = pvSrc.ReadInt32(); + var lang = pvSrc.ReadString(4); + var text = pvSrc.ReadUnicodeStringLESafe(); if (text.Length > 128) return; - Mobile from = state.Mobile; - Prompt p = from.Prompt; + var from = state.Mobile; + var p = from.Prompt; if (p != null && p.Serial == serial && p.Serial == prompt) { @@ -831,7 +812,7 @@ namespace Server.Network public static void MenuResponse(NetState state, PacketReader pvSrc) { - uint serial = pvSrc.ReadUInt32(); + var serial = pvSrc.ReadUInt32(); int menuID = pvSrc.ReadInt16(); // unused in our implementation int index = pvSrc.ReadInt16(); int itemID = pvSrc.ReadInt16(); @@ -839,7 +820,7 @@ namespace Server.Network index -= 1; // convert from 1-based to 0-based - foreach (IMenu menu in state.Menus) + foreach (var menu in state.Menus) if (menu.Serial == serial) { state.RemoveMenu(menu); @@ -858,8 +839,8 @@ namespace Server.Network int type = pvSrc.ReadByte(); Serial serial = pvSrc.ReadUInt32(); - Mobile beholder = state.Mobile; - Mobile beheld = World.FindMobile(serial); + var beholder = state.Mobile; + var beheld = World.FindMobile(serial); if (beheld == null) return; @@ -867,55 +848,55 @@ namespace Server.Network switch (type) { case 0x00: // display request - { - EventSink.InvokeProfileRequest(beholder, beheld); + { + EventSink.InvokeProfileRequest(beholder, beheld); - break; - } + break; + } case 0x01: // edit request - { - pvSrc.ReadInt16(); // Skip - int length = pvSrc.ReadUInt16(); + { + pvSrc.ReadInt16(); // Skip + int length = pvSrc.ReadUInt16(); - if (length > 511) - return; + if (length > 511) + return; - string text = pvSrc.ReadUnicodeString(length); + var text = pvSrc.ReadUnicodeString(length); - EventSink.InvokeChangeProfileRequest(beholder, beheld, text); + EventSink.InvokeChangeProfileRequest(beholder, beheld, text); - break; - } + break; + } } } public static void Disconnect(NetState state, PacketReader pvSrc) { - int minusOne = pvSrc.ReadInt32(); + var minusOne = pvSrc.ReadInt32(); } public static void LiftReq(NetState state, PacketReader pvSrc) { Serial serial = pvSrc.ReadUInt32(); int amount = pvSrc.ReadUInt16(); - Item item = World.FindItem(serial); + var item = World.FindItem(serial); - state.Mobile.Lift(item, amount, out bool rejected, out LRReason reject); + state.Mobile.Lift(item, amount, out var rejected, out var reject); } public static void EquipReq(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; - Item item = from.Holding; + var from = state.Mobile; + var item = from.Holding; - bool valid = item != null && item.HeldBy == from && item.Map == Map.Internal; + var valid = item != null && item.HeldBy == from && item.Map == Map.Internal; from.Holding = null; if (!valid) return; pvSrc.Seek(5, SeekOrigin.Current); - Mobile to = World.FindMobile(pvSrc.ReadUInt32()) ?? from; + var to = World.FindMobile(pvSrc.ReadUInt32()) ?? from; if (!to.AllowEquipFrom(from) || !to.EquipItem(item)) item.Bounce(from); @@ -931,9 +912,9 @@ namespace Server.Network int z = pvSrc.ReadSByte(); Serial dest = pvSrc.ReadUInt32(); - Point3D loc = new Point3D(x, y, z); + var loc = new Point3D(x, y, z); - Mobile from = state.Mobile; + var from = state.Mobile; if (dest.IsMobile) { @@ -941,7 +922,7 @@ namespace Server.Network } else if (dest.IsItem) { - Item item = World.FindItem(dest); + var item = World.FindItem(dest); if (item is BaseMulti multi && multi.AllowsRelativeDrop) { @@ -969,9 +950,9 @@ namespace Server.Network pvSrc.ReadByte(); // Grid Location? Serial dest = pvSrc.ReadUInt32(); - Point3D loc = new Point3D(x, y, z); + var loc = new Point3D(x, y, z); - Mobile from = state.Mobile; + var from = state.Mobile; if (dest.IsMobile) { @@ -979,7 +960,7 @@ namespace Server.Network } else if (dest.IsItem) { - Item item = World.FindItem(dest); + var item = World.FindItem(dest); if (item is BaseMulti multi && multi.AllowsRelativeDrop) { @@ -1009,7 +990,7 @@ namespace Server.Network public static void ChangeSkillLock(NetState state, PacketReader pvSrc) { - Skill s = state.Mobile.Skills[pvSrc.ReadInt16()]; + var s = state.Mobile.Skills[pvSrc.ReadInt16()]; s?.SetLockNoRelay((SkillLock)pvSrc.ReadByte()); } @@ -1022,7 +1003,7 @@ namespace Server.Network public static void TargetResponse(NetState state, PacketReader pvSrc) { int type = pvSrc.ReadByte(); - int targetID = pvSrc.ReadInt32(); + var targetID = pvSrc.ReadInt32(); int flags = pvSrc.ReadByte(); Serial serial = pvSrc.ReadUInt32(); int x = pvSrc.ReadInt16(), y = pvSrc.ReadInt16(), z = pvSrc.ReadInt16(); @@ -1031,14 +1012,14 @@ namespace Server.Network if (targetID == unchecked((int)0xDEADBEEF)) return; - Mobile from = state.Mobile; + var from = state.Mobile; - Target t = from.Target; + var t = from.Target; if (t == null) return; - TargetProfile prof = TargetProfile.Acquire(t.GetType()); + var prof = TargetProfile.Acquire(t.GetType()); prof?.Start(); try @@ -1064,7 +1045,7 @@ namespace Server.Network } else { - Map map = from.Map; + var map = from.Map; if (map == null || map == Map.Internal) { @@ -1073,17 +1054,17 @@ namespace Server.Network } else { - StaticTile[] tiles = map.Tiles.GetStaticTiles(x, y, !t.DisallowMultis); + var tiles = map.Tiles.GetStaticTiles(x, y, !t.DisallowMultis); - bool valid = false; + var valid = false; if (state.HighSeas) { - ItemData id = TileData.ItemTable[graphic & TileData.MaxItemValue]; + var id = TileData.ItemTable[graphic & TileData.MaxItemValue]; if (id.Surface) z -= id.Height; } - for (int i = 0; !valid && i < tiles.Length; ++i) + for (var i = 0; !valid && i < tiles.Length; ++i) if (tiles[i].Z == z && tiles[i].ID == graphic) valid = true; @@ -1124,18 +1105,18 @@ namespace Server.Network public static void DisplayGumpResponse(NetState state, PacketReader pvSrc) { - uint serial = pvSrc.ReadUInt32(); - int typeID = pvSrc.ReadInt32(); - int buttonID = pvSrc.ReadInt32(); + var serial = pvSrc.ReadUInt32(); + var typeID = pvSrc.ReadInt32(); + var buttonID = pvSrc.ReadInt32(); - foreach (Gump gump in state.Gumps) + foreach (var gump in state.Gumps) { if (gump.Serial != serial || gump.TypeID != typeID) continue; - bool buttonExists = buttonID == 0; // 0 is always 'close' + var buttonExists = buttonID == 0; // 0 is always 'close' if (!buttonExists) - foreach (GumpEntry e in gump.Entries) + foreach (var e in gump.Entries) { if (e is GumpButton button && button.ButtonID == buttonID) { @@ -1157,7 +1138,7 @@ namespace Server.Network return; } - int switchCount = pvSrc.ReadInt32(); + var switchCount = pvSrc.ReadInt32(); if (switchCount < 0 || switchCount > gump.m_Switches) { @@ -1166,12 +1147,12 @@ namespace Server.Network return; } - int[] switches = new int[switchCount]; + var switches = new int[switchCount]; - for (int j = 0; j < switches.Length; ++j) + for (var j = 0; j < switches.Length; ++j) switches[j] = pvSrc.ReadInt32(); - int textCount = pvSrc.ReadInt32(); + var textCount = pvSrc.ReadInt32(); if (textCount < 0 || textCount > gump.m_TextEntries) { @@ -1180,9 +1161,9 @@ namespace Server.Network return; } - TextRelay[] textEntries = new TextRelay[textCount]; + var textEntries = new TextRelay[textCount]; - for (int j = 0; j < textEntries.Length; ++j) + for (var j = 0; j < textEntries.Length; ++j) { int entryID = pvSrc.ReadUInt16(); int textLength = pvSrc.ReadUInt16(); @@ -1194,13 +1175,13 @@ namespace Server.Network return; } - string text = pvSrc.ReadUnicodeStringSafe(textLength); + var text = pvSrc.ReadUnicodeStringSafe(textLength); textEntries[j] = new TextRelay(entryID, text); } state.RemoveGump(gump); - GumpProfile prof = GumpProfile.Acquire(gump.GetType()); + var prof = GumpProfile.Acquire(gump.GetType()); prof?.Start(); @@ -1214,18 +1195,18 @@ namespace Server.Network if (typeID == 461) { // Virtue gump - int switchCount = pvSrc.ReadInt32(); + var switchCount = pvSrc.ReadInt32(); if (buttonID == 1 && switchCount > 0) { - Mobile beheld = World.FindMobile(pvSrc.ReadUInt32()); + var beheld = World.FindMobile(pvSrc.ReadUInt32()); if (beheld != null) EventSink.InvokeVirtueGumpRequest(state.Mobile, beheld); } else { - Mobile beheld = World.FindMobile(serial); + var beheld = World.FindMobile(serial); if (beheld != null) EventSink.InvokeVirtueItemRequest(state.Mobile, beheld, buttonID); @@ -1240,7 +1221,7 @@ namespace Server.Network public static void Resynchronize(NetState state, PacketReader pvSrc) { - Mobile m = state.Mobile; + var m = state.Mobile; if (state.StygianAbyss) state.Send(new MobileUpdate(m)); @@ -1258,12 +1239,12 @@ namespace Server.Network public static void AsciiSpeech(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; - MessageType type = (MessageType)pvSrc.ReadByte(); + var type = (MessageType)pvSrc.ReadByte(); int hue = pvSrc.ReadInt16(); pvSrc.ReadInt16(); // font - string text = pvSrc.ReadStringSafe().Trim(); + var text = pvSrc.ReadStringSafe().Trim(); if (text.Length <= 0 || text.Length > 128) return; @@ -1276,29 +1257,29 @@ namespace Server.Network public static void UnicodeSpeech(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; - MessageType type = (MessageType)pvSrc.ReadByte(); + var type = (MessageType)pvSrc.ReadByte(); int hue = pvSrc.ReadInt16(); pvSrc.ReadInt16(); // font - string lang = pvSrc.ReadString(4); + var lang = pvSrc.ReadString(4); string text; - bool isEncoded = (type & MessageType.Encoded) != 0; + var isEncoded = (type & MessageType.Encoded) != 0; int[] keywords; if (isEncoded) { int value = pvSrc.ReadInt16(); - int count = (value & 0xFFF0) >> 4; - int hold = value & 0xF; + var count = (value & 0xFFF0) >> 4; + var hold = value & 0xF; if (count < 0 || count > 50) return; - KeywordList keyList = m_KeywordList; + var keyList = m_KeywordList; - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { int speechID; @@ -1347,28 +1328,30 @@ namespace Server.Network public static void UseReq(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; if (from.AccessLevel >= AccessLevel.Counselor || Core.TickCount - from.NextActionTime >= 0) { - uint value = pvSrc.ReadUInt32(); + var value = pvSrc.ReadUInt32(); if ((value & ~0x7FFFFFFF) != 0) + { from.OnPaperdollRequest(); + } else { Serial s = value; if (s.IsMobile) { - Mobile m = World.FindMobile(s); + var m = World.FindMobile(s); if (m?.Deleted == false) from.Use(m); } else if (s.IsItem) { - Item item = World.FindItem(s); + var item = World.FindItem(s); if (item?.Deleted == false) from.Use(item); @@ -1378,23 +1361,27 @@ namespace Server.Network from.NextActionTime = Core.TickCount + Mobile.ActionDelay; } else + { from.SendActionMessage(); + } } public static void LookReq(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; Serial s = pvSrc.ReadUInt32(); if (s.IsMobile) { - Mobile m = World.FindMobile(s); + var m = World.FindMobile(s); if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m)) { if (SingleClickProps) + { m.OnAosSingleClick(from); + } else { if (from.Region.OnSingleClick(from, m)) @@ -1404,17 +1391,19 @@ namespace Server.Network } else if (s.IsItem) { - Item item = World.FindItem(s); + var item = World.FindItem(s); if (item?.Deleted == false && from.CanSee(item) && Utility.InUpdateRange(from.Location, item.GetWorldLocation())) { if (SingleClickProps) + { item.OnAosSingleClick(from); + } else if (from.Region.OnSingleClick(from, item)) { - if (item.Parent is Item item1) - item1.OnSingleClickContained(from, item); + if (item.Parent is Item parentItem) + parentItem.OnSingleClickContained(from, item); item.OnSingleClick(from); } @@ -1434,13 +1423,13 @@ namespace Server.Network public static void MovementReq(NetState state, PacketReader pvSrc) { - Direction dir = (Direction)pvSrc.ReadByte(); + var dir = (Direction)pvSrc.ReadByte(); int seq = pvSrc.ReadByte(); - int key = pvSrc.ReadInt32(); + var key = pvSrc.ReadInt32(); - Mobile m = state.Mobile; + var m = state.Mobile; - if (state.Sequence == 0 && seq != 0 || !m.Move(dir)) + if ((state.Sequence == 0 && seq != 0) || !m.Move(dir)) { state.Send(new MovementRej(seq, m)); state.Sequence = 0; @@ -1460,13 +1449,13 @@ namespace Server.Network public static void Animate(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; - int action = pvSrc.ReadInt32(); + var from = state.Mobile; + var action = pvSrc.ReadInt32(); - bool ok = false; + var ok = false; - for (int i = 0; !ok && i < m_ValidAnimations.Length; ++i) - ok = action == m_ValidAnimations[i]; + for (var i = 0; !ok && i < ValidAnimations.Length; ++i) + ok = action == ValidAnimations[i]; if (from != null && ok && from.Alive && from.Body.IsHuman && !from.Mounted) from.Animate(action, 7, 1, true, false, 0); @@ -1474,8 +1463,8 @@ namespace Server.Network public static void QuestArrow(NetState state, PacketReader pvSrc) { - bool rightClick = pvSrc.ReadBoolean(); - Mobile from = state.Mobile; + var rightClick = pvSrc.ReadBoolean(); + var from = state.Mobile; from?.QuestArrow?.OnClick(rightClick); } @@ -1484,7 +1473,7 @@ namespace Server.Network { int packetID = pvSrc.ReadUInt16(); - PacketHandler ph = GetExtendedHandler(packetID); + var ph = GetExtendedHandler(packetID); if (ph == null) { @@ -1501,12 +1490,14 @@ namespace Server.Network state.Dispose(); } else + { ph.OnReceive(state, pvSrc); + } } public static void CastSpell(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; if (from == null) return; @@ -1516,26 +1507,26 @@ namespace Server.Network if (pvSrc.ReadInt16() == 1) spellbook = World.FindItem(pvSrc.ReadUInt32()); - int spellID = pvSrc.ReadInt16() - 1; + var spellID = pvSrc.ReadInt16() - 1; EventSink.InvokeCastSpellRequest(from, spellID, spellbook); } public static void BandageTarget(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; if (from == null) return; if (from.AccessLevel >= AccessLevel.Counselor || Core.TickCount - from.NextActionTime >= 0) { - Item bandage = World.FindItem(pvSrc.ReadUInt32()); + var bandage = World.FindItem(pvSrc.ReadUInt32()); if (bandage == null) return; - Mobile target = World.FindMobile(pvSrc.ReadUInt32()); + var target = World.FindMobile(pvSrc.ReadUInt32()); if (target == null) return; @@ -1560,29 +1551,29 @@ namespace Server.Network if (!ObjectPropertyList.Enabled) return; - Mobile from = state.Mobile; + var from = state.Mobile; - long length = pvSrc.Length; + var length = pvSrc.Length; if (length < 0 || length % 4 != 0) return; - long count = length / 4; + var count = length / 4; - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { Serial s = pvSrc.ReadUInt32(); if (s.IsMobile) { - Mobile m = World.FindMobile(s); + var m = World.FindMobile(s); if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m)) m.SendPropertiesTo(from); } else if (s.IsItem) { - Item item = World.FindItem(s); + var item = World.FindItem(s); if (item?.Deleted == false && from.CanSee(item) && Utility.InUpdateRange(from.Location, item.GetWorldLocation())) @@ -1596,20 +1587,20 @@ namespace Server.Network if (!ObjectPropertyList.Enabled) return; - Mobile from = state.Mobile; + var from = state.Mobile; Serial s = pvSrc.ReadUInt32(); if (s.IsMobile) { - Mobile m = World.FindMobile(s); + var m = World.FindMobile(s); if (m != null && from.CanSee(m) && Utility.InUpdateRange(from, m)) m.SendPropertiesTo(from); } else if (s.IsItem) { - Item item = World.FindItem(s); + var item = World.FindItem(s); if (item?.Deleted == false && from.CanSee(item) && Utility.InUpdateRange(from.Location, item.GetWorldLocation())) @@ -1711,7 +1702,7 @@ namespace Server.Network if (lockValue > 2) lockValue = 0; - Mobile m = state.Mobile; + var m = state.Mobile; if (m != null) switch (stat) @@ -1730,23 +1721,23 @@ namespace Server.Network public static void ScreenSize(NetState state, PacketReader pvSrc) { - int width = pvSrc.ReadInt32(); - int unk = pvSrc.ReadInt32(); + var width = pvSrc.ReadInt32(); + var unk = pvSrc.ReadInt32(); } public static void ContextMenuResponse(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; if (from != null) { - ContextMenu menu = from.ContextMenu; + var menu = from.ContextMenu; from.ContextMenu = null; if (menu != null && from == menu.From) { - IEntity entity = World.FindEntity(pvSrc.ReadUInt32()); + var entity = World.FindEntity(pvSrc.ReadUInt32()); if (entity != null && entity == menu.Target && from.CanSee(entity)) { @@ -1763,9 +1754,9 @@ namespace Server.Network if (index >= 0 && index < menu.Entries.Length) { - ContextMenuEntry e = menu.Entries[index]; + var e = menu.Entries[index]; - int range = e.Range; + var range = e.Range; if (range == -1) range = 18; @@ -1780,15 +1771,15 @@ namespace Server.Network public static void ContextMenuRequest(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; - IEntity target = World.FindEntity(pvSrc.ReadUInt32()); + var from = state.Mobile; + var target = World.FindEntity(pvSrc.ReadUInt32()); if (from != null && target != null && from.Map == target.Map && from.CanSee(target)) { if (target is Mobile && !Utility.InUpdateRange(from.Location, target.Location)) return; - Item item = target as Item; + var item = target as Item; if (item != null && !Utility.InUpdateRange(from.Location, item.GetWorldLocation())) return; @@ -1796,12 +1787,12 @@ namespace Server.Network if (!from.CheckContextMenuDisplay(target)) return; - ContextMenu c = new ContextMenu(from, target); + var c = new ContextMenu(from, target); if (c.Entries.Length > 0) { if (item?.RootParent is Mobile mobile && mobile != from && mobile.AccessLevel >= from.AccessLevel) - for (int i = 0; i < c.Entries.Length; ++i) + for (var i = 0; i < c.Entries.Length; ++i) if (!c.Entries[i].NonLocalUse) c.Entries[i].Enabled = false; @@ -1817,7 +1808,7 @@ namespace Server.Network public static void Language(NetState state, PacketReader pvSrc) { - string lang = pvSrc.ReadString(4); + var lang = pvSrc.ReadString(4); if (state.Mobile != null) state.Mobile.Language = lang; @@ -1825,13 +1816,13 @@ namespace Server.Network public static void AssistVersion(NetState state, PacketReader pvSrc) { - int unk = pvSrc.ReadInt32(); - string av = pvSrc.ReadString(); + var unk = pvSrc.ReadInt32(); + var av = pvSrc.ReadString(); } public static void ClientVersion(NetState state, PacketReader pvSrc) { - CV version = state.Version = new CV(pvSrc.ReadString()); + var version = state.Version = new CV(pvSrc.ReadString()); EventSink.InvokeClientVersionReceived(state, version); } @@ -1841,37 +1832,37 @@ namespace Server.Network pvSrc.ReadUInt16(); int type = pvSrc.ReadUInt16(); - CV version = state.Version = new CV(pvSrc.ReadString()); + var version = state.Version = new CV(pvSrc.ReadString()); EventSink.InvokeClientVersionReceived(state, version); } public static void MobileQuery(NetState state, PacketReader pvSrc) { - Mobile from = state.Mobile; + var from = state.Mobile; pvSrc.ReadInt32(); // 0xEDEDEDED int type = pvSrc.ReadByte(); - Mobile m = World.FindMobile(pvSrc.ReadUInt32()); + var m = World.FindMobile(pvSrc.ReadUInt32()); if (m != null) switch (type) { case 0x04: // Stats - { - m.OnStatsQuery(from); - break; - } + { + m.OnStatsQuery(from); + break; + } case 0x05: - { - m.OnSkillsQuery(from); - break; - } + { + m.OnSkillsQuery(from); + break; + } default: - { - pvSrc.Trace(state); - break; - } + { + pvSrc.Trace(state); + break; + } } } @@ -1879,29 +1870,31 @@ namespace Server.Network { pvSrc.ReadInt32(); // 0xEDEDEDED - string name = pvSrc.ReadString(30); + var name = pvSrc.ReadString(30); pvSrc.Seek(2, SeekOrigin.Current); - int flags = pvSrc.ReadInt32(); + var flags = pvSrc.ReadInt32(); pvSrc.Seek(24, SeekOrigin.Current); - int charSlot = pvSrc.ReadInt32(); - int clientIP = pvSrc.ReadInt32(); + var charSlot = pvSrc.ReadInt32(); + var clientIP = pvSrc.ReadInt32(); - IAccount a = state.Account; + var a = state.Account; if (a == null || charSlot < 0 || charSlot >= a.Length) + { state.Dispose(); + } else { - Mobile m = a[charSlot]; + var m = a[charSlot]; // Check if anyone is using this account - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) { - Mobile check = a[i]; + var check = a[i]; if (check != null && check.Map != Map.Internal && check != m) { @@ -1937,7 +1930,7 @@ namespace Server.Network public static void ShowPublicHouseContent(NetState state, PacketReader pvSrc) { - bool showPublicHouseContent = pvSrc.ReadBoolean(); + var showPublicHouseContent = pvSrc.ReadBoolean(); } public static void DoLogin(NetState state, Mobile m) @@ -1965,7 +1958,7 @@ namespace Server.Network state.Send(new MobileUpdate(m)); state.Send(new MobileIncoming(m, m)); - //state.Send( new MobileAttributes( m ) ); + // state.Send( new MobileAttributes( m ) ); state.Send(new MobileStatus(m, m)); state.Send(Network.SetWarMode.Instantiate(m.Warmode)); @@ -1973,7 +1966,7 @@ namespace Server.Network state.Send(SupportedFeatures.Instantiate(state)); state.Send(new MobileUpdate(m)); - //state.Send( new MobileAttributes( m ) ); + // state.Send( new MobileAttributes( m ) ); state.Send(new MobileStatus(m, m)); state.Send(Network.SetWarMode.Instantiate(m.Warmode)); state.Send(new MobileIncoming(m, m)); @@ -1988,7 +1981,7 @@ namespace Server.Network state.Send(new MobileUpdate(m)); state.Send(new MobileIncomingSA(m, m)); - //state.Send( new MobileAttributes( m ) ); + // state.Send( new MobileAttributes( m ) ); state.Send(new MobileStatus(m, m)); state.Send(Network.SetWarMode.Instantiate(m.Warmode)); @@ -1996,7 +1989,7 @@ namespace Server.Network state.Send(SupportedFeatures.Instantiate(state)); state.Send(new MobileUpdate(m)); - //state.Send( new MobileAttributes( m ) ); + // state.Send( new MobileAttributes( m ) ); state.Send(new MobileStatus(m, m)); state.Send(Network.SetWarMode.Instantiate(m.Warmode)); state.Send(new MobileIncomingSA(m, m)); @@ -2011,7 +2004,7 @@ namespace Server.Network state.Send(new MobileUpdateOld(m)); state.Send(new MobileIncomingOld(m, m)); - //state.Send( new MobileAttributes( m ) ); + // state.Send( new MobileAttributes( m ) ); state.Send(new MobileStatus(m, m)); state.Send(Network.SetWarMode.Instantiate(m.Warmode)); @@ -2019,7 +2012,7 @@ namespace Server.Network state.Send(SupportedFeatures.Instantiate(state)); state.Send(new MobileUpdateOld(m)); - //state.Send( new MobileAttributes( m ) ); + // state.Send( new MobileAttributes( m ) ); state.Send(new MobileStatus(m, m)); state.Send(Network.SetWarMode.Instantiate(m.Warmode)); state.Send(new MobileIncomingOld(m, m)); @@ -2037,13 +2030,13 @@ namespace Server.Network public static void CreateCharacter(NetState state, PacketReader pvSrc) { - int unk1 = pvSrc.ReadInt32(); - int unk2 = pvSrc.ReadInt32(); + var unk1 = pvSrc.ReadInt32(); + var unk2 = pvSrc.ReadInt32(); int unk3 = pvSrc.ReadByte(); - string name = pvSrc.ReadString(30); + var name = pvSrc.ReadString(30); pvSrc.Seek(2, SeekOrigin.Current); - int flags = pvSrc.ReadInt32(); + var flags = pvSrc.ReadInt32(); pvSrc.Seek(8, SeekOrigin.Current); int prof = pvSrc.ReadByte(); pvSrc.Seek(15, SeekOrigin.Current); @@ -2066,8 +2059,8 @@ namespace Server.Network int hairHuef = pvSrc.ReadInt16(); pvSrc.ReadByte(); int cityIndex = pvSrc.ReadByte(); - int charSlot = pvSrc.ReadInt32(); - int clientIP = pvSrc.ReadInt32(); + var charSlot = pvSrc.ReadInt32(); + var clientIP = pvSrc.ReadInt32(); int shirtHue = pvSrc.ReadInt16(); int pantsHue = pvSrc.ReadInt16(); @@ -2083,13 +2076,13 @@ namespace Server.Network 0x05, 0x06 -> Gargoyle Male, Gargoyle Female */ - bool female = genderRace % 2 != 0; + var female = genderRace % 2 != 0; Race race; if (state.StygianAbyss) { - byte raceID = (byte)(genderRace < 4 ? 0 : genderRace / 2 - 1); + var raceID = (byte)(genderRace < 4 ? 0 : genderRace / 2 - 1); race = Race.Races[raceID]; } else @@ -2099,8 +2092,8 @@ namespace Server.Network race ??= Race.DefaultRace; - CityInfo[] info = state.CityInfo; - IAccount a = state.Account; + var info = state.CityInfo; + var a = state.Account; if (info == null || a == null || cityIndex < 0 || cityIndex >= info.Length) { @@ -2109,9 +2102,9 @@ namespace Server.Network else { // Check if anyone is using this account - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) { - Mobile check = a[i]; + var check = a[i]; if (check != null && check.Map != Map.Internal) { @@ -2123,7 +2116,7 @@ namespace Server.Network state.Flags = (ClientFlags)flags; - CharacterCreatedEventArgs args = new CharacterCreatedEventArgs( + var args = new CharacterCreatedEventArgs( state, a, name, female, hue, str, dex, intl, @@ -2138,8 +2131,7 @@ namespace Server.Network hairVal, hairHue, hairValf, hairHuef, prof, - race - ); + race); state.Send(new ClientVersionReq()); @@ -2147,7 +2139,7 @@ namespace Server.Network EventSink.InvokeCharacterCreated(args); - Mobile m = args.Mobile; + var m = args.Mobile; if (m != null) { @@ -2165,13 +2157,13 @@ namespace Server.Network public static void CreateCharacter70160(NetState state, PacketReader pvSrc) { - int unk1 = pvSrc.ReadInt32(); - int unk2 = pvSrc.ReadInt32(); + var unk1 = pvSrc.ReadInt32(); + var unk2 = pvSrc.ReadInt32(); int unk3 = pvSrc.ReadByte(); - string name = pvSrc.ReadString(30); + var name = pvSrc.ReadString(30); pvSrc.Seek(2, SeekOrigin.Current); - int flags = pvSrc.ReadInt32(); + var flags = pvSrc.ReadInt32(); pvSrc.Seek(8, SeekOrigin.Current); int prof = pvSrc.ReadByte(); pvSrc.Seek(15, SeekOrigin.Current); @@ -2197,8 +2189,8 @@ namespace Server.Network int hairHuef = pvSrc.ReadInt16(); pvSrc.ReadByte(); int cityIndex = pvSrc.ReadByte(); - int charSlot = pvSrc.ReadInt32(); - int clientIP = pvSrc.ReadInt32(); + var charSlot = pvSrc.ReadInt32(); + var clientIP = pvSrc.ReadInt32(); int shirtHue = pvSrc.ReadInt16(); int pantsHue = pvSrc.ReadInt16(); @@ -2209,15 +2201,15 @@ namespace Server.Network 0x05, 0x06 -> Gargoyle Male, Gargoyle Female */ - bool female = genderRace % 2 != 0; + var female = genderRace % 2 != 0; Race race; - byte raceID = (byte)(genderRace < 4 ? 0 : genderRace / 2 - 1); + var raceID = (byte)(genderRace < 4 ? 0 : genderRace / 2 - 1); race = Race.Races[raceID] ?? Race.DefaultRace; - CityInfo[] info = state.CityInfo; - IAccount a = state.Account; + var info = state.CityInfo; + var a = state.Account; if (info == null || a == null || cityIndex < 0 || cityIndex >= info.Length) { @@ -2226,9 +2218,9 @@ namespace Server.Network else { // Check if anyone is using this account - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) { - Mobile check = a[i]; + var check = a[i]; if (check != null && check.Map != Map.Internal) { @@ -2240,7 +2232,7 @@ namespace Server.Network state.Flags = (ClientFlags)flags; - CharacterCreatedEventArgs args = new CharacterCreatedEventArgs( + var args = new CharacterCreatedEventArgs( state, a, name, female, hue, str, dex, intl, @@ -2256,8 +2248,7 @@ namespace Server.Network hairVal, hairHue, hairValf, hairHuef, prof, - race - ); + race); state.Send(new ClientVersionReq()); @@ -2265,7 +2256,7 @@ namespace Server.Network EventSink.InvokeCharacterCreated(args); - Mobile m = args.Mobile; + var m = args.Mobile; if (m != null) { @@ -2285,10 +2276,10 @@ namespace Server.Network { if (m_AuthIDWindow.Count == m_AuthIDWindowSize) { - int oldestID = 0; - DateTime oldest = DateTime.MaxValue; + var oldestID = 0; + var oldest = DateTime.MaxValue; - foreach (KeyValuePair kvp in m_AuthIDWindow) + foreach (var kvp in m_AuthIDWindow) if (kvp.Value.Age < oldest) { oldestID = kvp.Key; @@ -2323,9 +2314,9 @@ namespace Server.Network state.SentFirstPacket = true; - int authID = pvSrc.ReadInt32(); + var authID = pvSrc.ReadInt32(); - if (m_AuthIDWindow.TryGetValue(authID, out AuthIDPersistence ap)) + if (m_AuthIDWindow.TryGetValue(authID, out var ap)) { m_AuthIDWindow.Remove(authID); @@ -2352,10 +2343,10 @@ namespace Server.Network return; } - string username = pvSrc.ReadString(30); - string password = pvSrc.ReadString(30); + var username = pvSrc.ReadString(30); + var password = pvSrc.ReadString(30); - GameLoginEventArgs e = new GameLoginEventArgs(state, username, password); + var e = new GameLoginEventArgs(state, username, password); EventSink.InvokeGameLogin(e); @@ -2372,20 +2363,24 @@ namespace Server.Network state.Send(new CharacterListOld(state.Account, state.CityInfo)); } else + { state.Dispose(); + } } public static void PlayServer(NetState state, PacketReader pvSrc) { int index = pvSrc.ReadInt16(); - ServerInfo[] info = state.ServerInfo; - IAccount a = state.Account; + var info = state.ServerInfo; + var a = state.Account; if (info == null || a == null || index < 0 || index >= info.Length) + { state.Dispose(); + } else { - ServerInfo si = info[index]; + var si = info[index]; state.m_AuthID = PlayServerAck.m_AuthID = GenerateAuthID(state); @@ -2406,45 +2401,45 @@ namespace Server.Network return; } - int clientMaj = pvSrc.ReadInt32(); - int clientMin = pvSrc.ReadInt32(); - int clientRev = pvSrc.ReadInt32(); - int clientPat = pvSrc.ReadInt32(); + var clientMaj = pvSrc.ReadInt32(); + var clientMin = pvSrc.ReadInt32(); + var clientRev = pvSrc.ReadInt32(); + var clientPat = pvSrc.ReadInt32(); state.Version = new ClientVersion(clientMaj, clientMin, clientRev, clientPat); } public static void CrashReport(NetState state, PacketReader pvSrc) { - byte clientMaj = pvSrc.ReadByte(); - byte clientMin = pvSrc.ReadByte(); - byte clientRev = pvSrc.ReadByte(); - byte clientPat = pvSrc.ReadByte(); + var clientMaj = pvSrc.ReadByte(); + var clientMin = pvSrc.ReadByte(); + var clientRev = pvSrc.ReadByte(); + var clientPat = pvSrc.ReadByte(); - ushort x = pvSrc.ReadUInt16(); - ushort y = pvSrc.ReadUInt16(); - sbyte z = pvSrc.ReadSByte(); - byte map = pvSrc.ReadByte(); + var x = pvSrc.ReadUInt16(); + var y = pvSrc.ReadUInt16(); + var z = pvSrc.ReadSByte(); + var map = pvSrc.ReadByte(); - string account = pvSrc.ReadString(32); - string character = pvSrc.ReadString(32); - string ip = pvSrc.ReadString(15); + var account = pvSrc.ReadString(32); + var character = pvSrc.ReadString(32); + var ip = pvSrc.ReadString(15); - int unk1 = pvSrc.ReadInt32(); - int exception = pvSrc.ReadInt32(); + var unk1 = pvSrc.ReadInt32(); + var exception = pvSrc.ReadInt32(); - string process = pvSrc.ReadString(100); - string report = pvSrc.ReadString(100); + var process = pvSrc.ReadString(100); + var report = pvSrc.ReadString(100); pvSrc.ReadByte(); // 0x00 - int offset = pvSrc.ReadInt32(); + var offset = pvSrc.ReadInt32(); int count = pvSrc.ReadByte(); - for (int i = 0; i < count; i++) + for (var i = 0; i < count; i++) { - int address = pvSrc.ReadInt32(); + var address = pvSrc.ReadInt32(); } } @@ -2458,10 +2453,10 @@ namespace Server.Network state.SentFirstPacket = true; - string username = pvSrc.ReadString(30); - string password = pvSrc.ReadString(30); + var username = pvSrc.ReadString(30); + var password = pvSrc.ReadString(30); - AccountLoginEventArgs e = new AccountLoginEventArgs(state, username, password); + var e = new AccountLoginEventArgs(state, username, password); EventSink.InvokeAccountLogin(e); @@ -2473,7 +2468,7 @@ namespace Server.Network public static void AccountLogin_ReplyAck(NetState state) { - ServerListEventArgs e = new ServerListEventArgs(state, state.Account); + var e = new ServerListEventArgs(state, state.Account); EventSink.InvokeServerList(e); @@ -2484,7 +2479,7 @@ namespace Server.Network } else { - ServerInfo[] info = e.Servers.ToArray(); + var info = e.Servers.ToArray(); state.ServerInfo = info; @@ -2501,8 +2496,8 @@ namespace Server.Network public static void EquipMacro(NetState ns, PacketReader pvSrc) { int count = pvSrc.ReadByte(); - List serialList = new List(count); - for (int i = 0; i < count; ++i) + var serialList = new List(count); + for (var i = 0; i < count; ++i) serialList.Add(pvSrc.ReadUInt32()); EventSink.InvokeEquipMacro(ns.Mobile, serialList); @@ -2511,8 +2506,8 @@ namespace Server.Network public static void UnequipMacro(NetState ns, PacketReader pvSrc) { int count = pvSrc.ReadByte(); - List layers = new List(count); - for (int i = 0; i < count; ++i) + var layers = new List(count); + for (var i = 0; i < count; ++i) layers.Add((Layer)pvSrc.ReadUInt16()); EventSink.InvokeUnequipMacro(ns.Mobile, layers); @@ -2520,14 +2515,14 @@ namespace Server.Network public static void TargetedSpell(NetState ns, PacketReader pvSrc) { - short spellId = (short)(pvSrc.ReadInt16() - 1); // zero based; + var spellId = (short)(pvSrc.ReadInt16() - 1); // zero based; EventSink.InvokeTargetedSpell(ns.Mobile, World.FindEntity(pvSrc.ReadUInt32()), spellId); } public static void TargetedSkillUse(NetState ns, PacketReader pvSrc) { - short skillId = pvSrc.ReadInt16(); + var skillId = pvSrc.ReadInt16(); EventSink.InvokeTargetedSkillUse(ns.Mobile, World.FindEntity(pvSrc.ReadUInt32()), skillId); } diff --git a/Projects/Server/Network/PacketReader.cs b/Projects/Server/Network/PacketReader.cs index 49625d649..d22cdbdc7 100644 --- a/Projects/Server/Network/PacketReader.cs +++ b/Projects/Server/Network/PacketReader.cs @@ -36,19 +36,19 @@ namespace Server.Network public PacketReader(ReadOnlySequence seq) => m_Reader = new SequenceReader(seq); - public byte Peek() => m_Reader.TryPeek(out byte value) ? value : (byte)0; + public byte Peek() => m_Reader.TryPeek(out var value) ? value : (byte)0; public void Trace(NetState state) { try { - using StreamWriter sw = new StreamWriter("Packets.log", true); - byte[] buffer = m_Reader.Sequence.ToArray(); + using var sw = new StreamWriter("Packets.log", true); + var buffer = m_Reader.Sequence.ToArray(); if (buffer.Length > 0) sw.WriteLine("Client: {0}: Unhandled packet 0x{1:X2}", state, buffer[0]); - using (MemoryStream ms = new MemoryStream(buffer)) + using (var ms = new MemoryStream(buffer)) { Utility.FormatBuffer(sw, ms, buffer.Length); } @@ -79,7 +79,7 @@ namespace Server.Network m_Reader.Advance(Math.Min(m_Reader.Remaining, offset)); break; case SeekOrigin.End: - long count = m_Reader.Remaining - offset; + var count = m_Reader.Remaining - offset; if (count < 0) m_Reader.Rewind(count * -1); else if (count > 0) @@ -96,7 +96,7 @@ namespace Server.Network public short ReadInt16() => m_Reader.TryReadBigEndian(out short value) ? value : (short)0; - public byte ReadByte() => m_Reader.TryRead(out byte value) ? value : (byte)0; + public byte ReadByte() => m_Reader.TryRead(out var value) ? value : (byte)0; public uint ReadUInt32() => (uint)ReadInt32(); @@ -108,7 +108,7 @@ namespace Server.Network public string ReadUnicodeStringLE() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (m_Reader.TryReadLittleEndian(out short c) && c != 0) sb.Append((char)c); @@ -118,7 +118,7 @@ namespace Server.Network public string ReadUnicodeStringLE(int fixedLength) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (fixedLength-- > 0 && m_Reader.TryReadLittleEndian(out short c) && c != 0) sb.Append((char)c); @@ -131,7 +131,7 @@ namespace Server.Network public string ReadUnicodeStringLESafe(int fixedLength) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (fixedLength-- > 0 && m_Reader.TryReadLittleEndian(out short c) && c != 0) if (IsSafeChar(c)) @@ -145,7 +145,7 @@ namespace Server.Network public string ReadUnicodeStringLESafe() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (m_Reader.TryReadLittleEndian(out short c) && c != 0) if (IsSafeChar(c)) @@ -156,7 +156,7 @@ namespace Server.Network public string ReadUnicodeStringSafe() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (m_Reader.TryReadBigEndian(out short c) && c != 0) if (IsSafeChar(c)) @@ -167,7 +167,7 @@ namespace Server.Network public string ReadUnicodeString() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (m_Reader.TryReadBigEndian(out short c) && c != 0) sb.Append((char)c); @@ -182,17 +182,19 @@ namespace Server.Network string s; if (m_Reader.TryReadTo(out ReadOnlySpan span, (byte)'\0')) + { s = Utility.UTF8.GetString(span.Length > fixedLength ? span.Slice(0, fixedLength) : span); + } else { - long size = Math.Min(m_Reader.Remaining, fixedLength); + var size = Math.Min(m_Reader.Remaining, fixedLength); s = Utility.UTF8.GetString(m_Reader.Sequence.Slice(m_Reader.Position, size).ToArray()); m_Reader.Advance(size); } - StringBuilder sb = new StringBuilder(s.Length); + var sb = new StringBuilder(s.Length); - for (int i = 0; i < s.Length; ++i) + for (var i = 0; i < s.Length; ++i) if (IsSafeChar(s[i])) sb.Append(s[i]); @@ -204,16 +206,18 @@ namespace Server.Network string s; if (m_Reader.TryReadTo(out ReadOnlySpan span, (byte)'\0')) + { s = Utility.UTF8.GetString(span); + } else { s = Utility.UTF8.GetString(m_Reader.Sequence.Slice(m_Reader.Position, m_Reader.Remaining).ToArray()); m_Reader.Advance(m_Reader.Remaining); } - StringBuilder sb = new StringBuilder(s.Length); + var sb = new StringBuilder(s.Length); - for (int i = 0; i < s.Length; ++i) + for (var i = 0; i < s.Length; ++i) if (IsSafeChar(s[i])) sb.Append(s[i]); @@ -222,15 +226,15 @@ namespace Server.Network public string ReadUTF8String() => Utility.UTF8.GetString( - m_Reader.TryReadTo(out ReadOnlySpan span, (byte)'\0') ? span : - m_Reader.Sequence.Slice(m_Reader.Position, m_Reader.Remaining).ToArray() - ); + m_Reader.TryReadTo(out ReadOnlySpan span, (byte)'\0') + ? span + : m_Reader.Sequence.Slice(m_Reader.Position, m_Reader.Remaining).ToArray()); public string ReadString() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); - while (m_Reader.TryRead(out byte c)) + while (m_Reader.TryRead(out var c)) sb.Append((char)c); return sb.ToString(); @@ -238,9 +242,9 @@ namespace Server.Network public string ReadStringSafe() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); - while (m_Reader.TryRead(out byte c)) + while (m_Reader.TryRead(out var c)) if (IsSafeChar(c)) sb.Append((char)c); @@ -249,7 +253,7 @@ namespace Server.Network public string ReadUnicodeStringSafe(int fixedLength) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (fixedLength-- > 0 && m_Reader.TryReadBigEndian(out short c) && c != 0) if (IsSafeChar(c)) @@ -263,7 +267,7 @@ namespace Server.Network public string ReadUnicodeString(int fixedLength) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); while (fixedLength-- > 0 && m_Reader.TryReadBigEndian(out short c) && c != 0) sb.Append((char)c); @@ -276,9 +280,9 @@ namespace Server.Network public string ReadStringSafe(int fixedLength) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); - while (fixedLength-- > 0 && m_Reader.TryRead(out byte c) && c != 0) + while (fixedLength-- > 0 && m_Reader.TryRead(out var c) && c != 0) if (IsSafeChar(c)) sb.Append((char)c); @@ -290,9 +294,9 @@ namespace Server.Network public string ReadString(int fixedLength) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); - while (fixedLength-- > 0 && m_Reader.TryRead(out byte c) && c != 0) + while (fixedLength-- > 0 && m_Reader.TryRead(out var c) && c != 0) sb.Append((char)c); if (fixedLength > 0) diff --git a/Projects/Server/Network/PacketWriter.cs b/Projects/Server/Network/PacketWriter.cs index 3419171b9..186907483 100644 --- a/Projects/Server/Network/PacketWriter.cs +++ b/Projects/Server/Network/PacketWriter.cs @@ -70,7 +70,7 @@ namespace Server.Network public static PacketWriter CreateInstance(int capacity = 32) { - if (m_Pool.TryDequeue(out PacketWriter pw)) + if (m_Pool.TryDequeue(out var pw)) { pw.m_Capacity = capacity; pw.UnderlyingStream.SetLength(0); @@ -177,7 +177,7 @@ namespace Server.Network value = string.Empty; } - int length = value.Length; + var length = value.Length; UnderlyingStream.SetLength(UnderlyingStream.Length + size); @@ -204,7 +204,7 @@ namespace Server.Network value = string.Empty; } - int length = value.Length; + var length = value.Length; UnderlyingStream.SetLength(UnderlyingStream.Length + length + 1); @@ -223,11 +223,12 @@ namespace Server.Network value = string.Empty; } - int length = value.Length; + var length = value.Length; UnderlyingStream.SetLength(UnderlyingStream.Length + (length + 1) * 2); - UnderlyingStream.Position += Encoding.Unicode.GetBytes(value, 0, length, UnderlyingStream.GetBuffer(), (int)UnderlyingStream.Position); + UnderlyingStream.Position += + Encoding.Unicode.GetBytes(value, 0, length, UnderlyingStream.GetBuffer(), (int)UnderlyingStream.Position); UnderlyingStream.Position += 2; } @@ -243,7 +244,7 @@ namespace Server.Network value = string.Empty; } - int length = value.Length; + var length = value.Length; size *= 2; UnderlyingStream.SetLength(UnderlyingStream.Length + size); @@ -271,7 +272,7 @@ namespace Server.Network value = string.Empty; } - int length = value.Length; + var length = value.Length; UnderlyingStream.SetLength(UnderlyingStream.Length + (length + 1) * 2); @@ -292,15 +293,16 @@ namespace Server.Network value = string.Empty; } - int length = value.Length; + var length = value.Length; size *= 2; UnderlyingStream.SetLength(UnderlyingStream.Length + size); - if (length * 2 >= size ) + if (length * 2 >= size) { UnderlyingStream.Position += - Encoding.BigEndianUnicode.GetBytes(value, 0, size / 2, UnderlyingStream.GetBuffer(), (int)UnderlyingStream.Position); + Encoding.BigEndianUnicode.GetBytes(value, 0, size / 2, UnderlyingStream.GetBuffer(), + (int)UnderlyingStream.Position); } else { diff --git a/Projects/Server/Network/Packets.cs b/Projects/Server/Network/Packets.cs index 16e20b13a..1b4853de7 100644 --- a/Projects/Server/Network/Packets.cs +++ b/Projects/Server/Network/Packets.cs @@ -74,16 +74,16 @@ namespace Server.Network { EnsureCapacity(11); - m_Stream.Write((short)0x22); - m_Stream.Write((byte)1); - m_Stream.Write(m.Serial); + Stream.Write((short)0x22); + Stream.Write((byte)1); + Stream.Write(m.Serial); if (amount > 255) amount = 255; else if (amount < 0) amount = 0; - m_Stream.Write((byte)amount); + Stream.Write((byte)amount); } } @@ -91,14 +91,14 @@ namespace Server.Network { public DamagePacket(Mobile m, int amount) : base(0x0B, 7) { - m_Stream.Write(m.Serial); + Stream.Write(m.Serial); if (amount > 0xFFFF) amount = 0xFFFF; else if (amount < 0) amount = 0; - m_Stream.Write((ushort)amount); + Stream.Write((ushort)amount); } /*public DamagePacket( Mobile m, int amount ) : base( 0xBF ) @@ -109,9 +109,9 @@ namespace Server.Network m_Stream.Write( (byte) 1 ); m_Stream.Write( (int) m.Serial ); - if ( amount > 255 ) + if (amount > 255) amount = 255; - else if ( amount < 0 ) + else if (amount < 0) amount = 0; m_Stream.Write( (byte)amount ); @@ -122,9 +122,9 @@ namespace Server.Network { public CancelArrow() : base(0xBA, 6) { - m_Stream.Write((byte)0); - m_Stream.Write((short)-1); - m_Stream.Write((short)-1); + Stream.Write((byte)0); + Stream.Write((short)-1); + Stream.Write((short)-1); } } @@ -132,9 +132,9 @@ namespace Server.Network { public SetArrow(int x, int y) : base(0xBA, 6) { - m_Stream.Write((byte)1); - m_Stream.Write((short)x); - m_Stream.Write((short)y); + Stream.Write((byte)1); + Stream.Write((short)x); + Stream.Write((short)y); } } @@ -142,10 +142,10 @@ namespace Server.Network { public CancelArrowHS(int x, int y, Serial s) : base(0xBA, 10) { - m_Stream.Write((byte)0); - m_Stream.Write((short)x); - m_Stream.Write((short)y); - m_Stream.Write(s); + Stream.Write((byte)0); + Stream.Write((short)x); + Stream.Write((short)y); + Stream.Write(s); } } @@ -153,10 +153,10 @@ namespace Server.Network { public SetArrowHS(int x, int y, Serial s) : base(0xBA, 10) { - m_Stream.Write((byte)1); - m_Stream.Write((short)x); - m_Stream.Write((short)y); - m_Stream.Write(s); + Stream.Write((byte)1); + Stream.Write((short)x); + Stream.Write((short)y); + Stream.Write(s); } } @@ -169,13 +169,13 @@ namespace Server.Network EnsureCapacity(18 + name.Length); - m_Stream.Write((byte)0); // Display - m_Stream.Write(them.Serial); - m_Stream.Write(first.Serial); - m_Stream.Write(second.Serial); - m_Stream.Write(true); + Stream.Write((byte)0); // Display + Stream.Write(them.Serial); + Stream.Write(first.Serial); + Stream.Write(second.Serial); + Stream.Write(true); - m_Stream.WriteAsciiFixed(name, 30); + Stream.WriteAsciiFixed(name, 30); } } @@ -186,8 +186,8 @@ namespace Server.Network { EnsureCapacity(8); - m_Stream.Write((byte)1); // Close - m_Stream.Write(cont.Serial); + Stream.Write((byte)1); // Close + Stream.Write(cont.Serial); } } @@ -212,10 +212,10 @@ namespace Server.Network { EnsureCapacity(17); - m_Stream.Write((byte)flag); - m_Stream.Write(cont.Serial); - m_Stream.Write(first); - m_Stream.Write(second); + Stream.Write((byte)flag); + Stream.Write(cont.Serial); + Stream.Write(first); + Stream.Write(second); } } @@ -223,14 +223,14 @@ namespace Server.Network { public SecureTradeEquip(Item item, Mobile m) : base(0x25, 20) { - m_Stream.Write(item.Serial); - m_Stream.Write((short)item.ItemID); - m_Stream.Write((byte)0); - m_Stream.Write((short)item.Amount); - m_Stream.Write((short)item.X); - m_Stream.Write((short)item.Y); - m_Stream.Write(m.Serial); - m_Stream.Write((short)item.Hue); + Stream.Write(item.Serial); + Stream.Write((short)item.ItemID); + Stream.Write((byte)0); + Stream.Write((short)item.Amount); + Stream.Write((short)item.X); + Stream.Write((short)item.Y); + Stream.Write(m.Serial); + Stream.Write((short)item.Hue); } } @@ -238,15 +238,15 @@ namespace Server.Network { public SecureTradeEquip6017(Item item, Mobile m) : base(0x25, 21) { - m_Stream.Write(item.Serial); - m_Stream.Write((short)item.ItemID); - m_Stream.Write((byte)0); - m_Stream.Write((short)item.Amount); - m_Stream.Write((short)item.X); - m_Stream.Write((short)item.Y); - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(m.Serial); - m_Stream.Write((short)item.Hue); + Stream.Write(item.Serial); + Stream.Write((short)item.ItemID); + Stream.Write((byte)0); + Stream.Write((short)item.Amount); + Stream.Write((short)item.X); + Stream.Write((short)item.Y); + Stream.Write((byte)0); // Grid Location? + Stream.Write(m.Serial); + Stream.Write((short)item.Hue); } } @@ -256,21 +256,21 @@ namespace Server.Network { EnsureCapacity(9 + 3 * 8); - m_Stream.Write((short)0x0018); + Stream.Write((short)0x0018); - m_Stream.Write(4); + Stream.Write(4); - m_Stream.Write(Map.Felucca.Tiles.Patch.StaticBlocks); - m_Stream.Write(Map.Felucca.Tiles.Patch.LandBlocks); + Stream.Write(Map.Felucca.Tiles.Patch.StaticBlocks); + Stream.Write(Map.Felucca.Tiles.Patch.LandBlocks); - m_Stream.Write(Map.Trammel.Tiles.Patch.StaticBlocks); - m_Stream.Write(Map.Trammel.Tiles.Patch.LandBlocks); + Stream.Write(Map.Trammel.Tiles.Patch.StaticBlocks); + Stream.Write(Map.Trammel.Tiles.Patch.LandBlocks); - m_Stream.Write(Map.Ilshenar.Tiles.Patch.StaticBlocks); - m_Stream.Write(Map.Ilshenar.Tiles.Patch.LandBlocks); + Stream.Write(Map.Ilshenar.Tiles.Patch.StaticBlocks); + Stream.Write(Map.Ilshenar.Tiles.Patch.LandBlocks); - m_Stream.Write(Map.Malas.Tiles.Patch.StaticBlocks); - m_Stream.Write(Map.Malas.Tiles.Patch.LandBlocks); + Stream.Write(Map.Malas.Tiles.Patch.StaticBlocks); + Stream.Write(Map.Malas.Tiles.Patch.LandBlocks); } } @@ -280,8 +280,8 @@ namespace Server.Network { EnsureCapacity(9 + text.Length * 2); - m_Stream.Write(e.Serial); - m_Stream.WriteBigUniNull(text); + Stream.Write(e.Serial); + Stream.WriteBigUniNull(text); } } @@ -292,24 +292,24 @@ namespace Server.Network { EnsureCapacity(list.Count * 19 + 5); - m_Stream.Write((short)list.Count); + Stream.Write((short)list.Count); - //The client sorts these by their X/Y value. - //OSI sends these in weird order. X/Y highest to lowest and serial lowest to highest - //These are already sorted by serial (done by the vendor class) but we have to send them by x/y - //(the x74 packet is sent in 'correct' order.) - for (int i = list.Count - 1; i >= 0; --i) + // The client sorts these by their X/Y value. + // OSI sends these in weird order. X/Y highest to lowest and serial lowest to highest + // These are already sorted by serial (done by the vendor class) but we have to send them by x/y + // (the x74 packet is sent in 'correct' order.) + for (var i = list.Count - 1; i >= 0; --i) { - BuyItemState bis = list[i]; + var bis = list[i]; - m_Stream.Write(bis.MySerial); - m_Stream.Write((ushort)bis.ItemID); - m_Stream.Write((byte)0); //itemid offset - m_Stream.Write((ushort)bis.Amount); - m_Stream.Write((short)(i + 1)); //x - m_Stream.Write((short)1); //y - m_Stream.Write(bis.ContainerSerial); - m_Stream.Write((ushort)bis.Hue); + Stream.Write(bis.MySerial); + Stream.Write((ushort)bis.ItemID); + Stream.Write((byte)0); // itemid offset + Stream.Write((ushort)bis.Amount); + Stream.Write((short)(i + 1)); // x + Stream.Write((short)1); // y + Stream.Write(bis.ContainerSerial); + Stream.Write((ushort)bis.Hue); } } } @@ -320,25 +320,25 @@ namespace Server.Network { EnsureCapacity(list.Count * 20 + 5); - m_Stream.Write((short)list.Count); + Stream.Write((short)list.Count); - //The client sorts these by their X/Y value. - //OSI sends these in weird order. X/Y highest to lowest and serial loewst to highest - //These are already sorted by serial (done by the vendor class) but we have to send them by x/y - //(the x74 packet is sent in 'correct' order.) - for (int i = list.Count - 1; i >= 0; --i) + // The client sorts these by their X/Y value. + // OSI sends these in weird order. X/Y highest to lowest and serial loewst to highest + // These are already sorted by serial (done by the vendor class) but we have to send them by x/y + // (the x74 packet is sent in 'correct' order.) + for (var i = list.Count - 1; i >= 0; --i) { - BuyItemState bis = list[i]; + var bis = list[i]; - m_Stream.Write(bis.MySerial); - m_Stream.Write((ushort)bis.ItemID); - m_Stream.Write((byte)0); //itemid offset - m_Stream.Write((ushort)bis.Amount); - m_Stream.Write((short)(i + 1)); //x - m_Stream.Write((short)1); //y - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(bis.ContainerSerial); - m_Stream.Write((ushort)bis.Hue); + Stream.Write(bis.MySerial); + Stream.Write((ushort)bis.ItemID); + Stream.Write((byte)0); // itemid offset + Stream.Write((ushort)bis.Amount); + Stream.Write((short)(i + 1)); // x + Stream.Write((short)1); // y + Stream.Write((byte)0); // Grid Location? + Stream.Write(bis.ContainerSerial); + Stream.Write((ushort)bis.Hue); } } } @@ -347,8 +347,8 @@ namespace Server.Network { public DisplayBuyList(Mobile vendor) : base(0x24, 7) { - m_Stream.Write(vendor.Serial); - m_Stream.Write((short)0x30); // buy window id? + Stream.Write(vendor.Serial); + Stream.Write((short)0x30); // buy window id? } } @@ -356,9 +356,9 @@ namespace Server.Network { public DisplayBuyListHS(Mobile vendor) : base(0x24, 9) { - m_Stream.Write(vendor.Serial); - m_Stream.Write((short)0x30); // buy window id? - m_Stream.Write((short)0x00); + Stream.Write(vendor.Serial); + Stream.Write((short)0x30); // buy window id? + Stream.Write((short)0x00); } } @@ -369,20 +369,20 @@ namespace Server.Network { EnsureCapacity(256); - m_Stream.Write(!(vendor.FindItemOnLayer(Layer.ShopBuy) is Container BuyPack) ? Serial.MinusOne : BuyPack.Serial); + Stream.Write(!(vendor.FindItemOnLayer(Layer.ShopBuy) is Container buyPack) ? Serial.MinusOne : buyPack.Serial); - m_Stream.Write((byte)list.Count); + Stream.Write((byte)list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - BuyItemState bis = list[i]; + var bis = list[i]; - m_Stream.Write(bis.Price); + Stream.Write(bis.Price); - string desc = bis.Description ?? ""; + var desc = bis.Description ?? ""; - m_Stream.Write((byte)(desc.Length + 1)); - m_Stream.WriteAsciiNull(desc); + Stream.Write((byte)(desc.Length + 1)); + Stream.WriteAsciiNull(desc); } } } @@ -393,45 +393,45 @@ namespace Server.Network { EnsureCapacity(256); - m_Stream.Write(shopkeeper.Serial); + Stream.Write(shopkeeper.Serial); - m_Stream.Write((ushort)sis.Count); + Stream.Write((ushort)sis.Count); - foreach (SellItemState state in sis) + foreach (var state in sis) { - m_Stream.Write(state.Item.Serial); - m_Stream.Write((ushort)state.Item.ItemID); - m_Stream.Write((ushort)state.Item.Hue); - m_Stream.Write((ushort)state.Item.Amount); - m_Stream.Write((ushort)state.Price); + Stream.Write(state.Item.Serial); + Stream.Write((ushort)state.Item.ItemID); + Stream.Write((ushort)state.Item.Hue); + Stream.Write((ushort)state.Item.Amount); + Stream.Write((ushort)state.Price); - string name = state.Item.Name?.Trim(); + var name = state.Item.Name?.Trim(); if (string.IsNullOrWhiteSpace(name)) name = state.Name ?? ""; - m_Stream.Write((ushort)name.Length); - m_Stream.WriteAsciiFixed(name, (ushort)name.Length); + Stream.Write((ushort)name.Length); + Stream.WriteAsciiFixed(name, (ushort)name.Length); } } } public sealed class EndVendorSell : Packet { - public EndVendorSell(Mobile Vendor) : base(0x3B, 8) + public EndVendorSell(Mobile vendor) : base(0x3B, 8) { - m_Stream.Write((ushort)8); //length - m_Stream.Write(Vendor.Serial); - m_Stream.Write((byte)0); + Stream.Write((ushort)8); // length + Stream.Write(vendor.Serial); + Stream.Write((byte)0); } } public sealed class EndVendorBuy : Packet { - public EndVendorBuy(Mobile Vendor) : base(0x3B, 8) + public EndVendorBuy(Mobile vendor) : base(0x3B, 8) { - m_Stream.Write((ushort)8); //length - m_Stream.Write(Vendor.Serial); - m_Stream.Write((byte)0); + Stream.Write((ushort)8); // length + Stream.Write(vendor.Serial); + Stream.Write((byte)0); } } @@ -439,9 +439,9 @@ namespace Server.Network { public DeathAnimation(Mobile killed, Item corpse) : base(0xAF, 13) { - m_Stream.Write(killed.Serial); - m_Stream.Write(corpse?.Serial ?? Serial.Zero); - m_Stream.Write(0); + Stream.Write(killed.Serial); + Stream.Write(corpse?.Serial ?? Serial.Zero); + Stream.Write(0); } } @@ -451,14 +451,14 @@ namespace Server.Network { EnsureCapacity(12); - m_Stream.Write((short)0x19); - m_Stream.Write((byte)2); - m_Stream.Write(m.Serial); - m_Stream.Write((byte)0); + Stream.Write((short)0x19); + Stream.Write((byte)2); + Stream.Write(m.Serial); + Stream.Write((byte)0); - int lockBits = (int)m.StrLock << 4 | (int)m.DexLock << 2 | (int)m.IntLock; + var lockBits = ((int)m.StrLock << 4) | ((int)m.DexLock << 2) | (int)m.IntLock; - m_Stream.Write((byte)lockBits); + Stream.Write((byte)lockBits); } } @@ -470,9 +470,9 @@ namespace Server.Network Charges = charges; } - public int Number{ get; } + public int Number { get; } - public int Charges{ get; } + public int Charges { get; } } public class EquipmentInfo @@ -485,56 +485,56 @@ namespace Server.Network Attributes = attributes; } - public int Number{ get; } + public int Number { get; } - public Mobile Crafter{ get; } + public Mobile Crafter { get; } - public bool Unidentified{ get; } + public bool Unidentified { get; } - public EquipInfoAttribute[] Attributes{ get; } + public EquipInfoAttribute[] Attributes { get; } } public sealed class DisplayEquipmentInfo : Packet { public DisplayEquipmentInfo(Item item, EquipmentInfo info) : base(0xBF) { - EquipInfoAttribute[] attrs = info.Attributes; + var attrs = info.Attributes; EnsureCapacity(17 + (info.Crafter?.Name.Length ?? 0) + (info.Unidentified ? 4 : 0) + attrs.Length * 6); - m_Stream.Write((short)0x10); - m_Stream.Write(item.Serial); + Stream.Write((short)0x10); + Stream.Write(item.Serial); - m_Stream.Write(info.Number); + Stream.Write(info.Number); if (info.Crafter != null) { - string name = info.Crafter.Name; + var name = info.Crafter.Name; - m_Stream.Write(-3); + Stream.Write(-3); if (name == null) { - m_Stream.Write((ushort)0); + Stream.Write((ushort)0); } else { - int length = name.Length; - m_Stream.Write((ushort)length); - m_Stream.WriteAsciiFixed(name, length); + var length = name.Length; + Stream.Write((ushort)length); + Stream.WriteAsciiFixed(name, length); } } - if (info.Unidentified) m_Stream.Write(-4); + if (info.Unidentified) Stream.Write(-4); - for (int i = 0; i < attrs.Length; ++i) + for (var i = 0; i < attrs.Length; ++i) { - m_Stream.Write(attrs[i].Number); - m_Stream.Write((short)attrs[i].Charges); + Stream.Write(attrs[i].Number); + Stream.Write((short)attrs[i].Charges); } - m_Stream.Write(-1); + Stream.Write(-1); } } @@ -544,13 +544,13 @@ namespace Server.Network public ChangeUpdateRange(int range) : base(0xC8, 2) { - m_Stream.Write((byte)range); + Stream.Write((byte)range); } public static ChangeUpdateRange Instantiate(int range) { - byte idx = (byte)range; - ChangeUpdateRange p = m_Cache[idx]; + var idx = (byte)range; + var p = m_Cache[idx]; if (p == null) { @@ -566,7 +566,7 @@ namespace Server.Network { public ChangeCombatant(Mobile combatant) : base(0xAA, 5) { - m_Stream.Write(combatant?.Serial ?? Serial.Zero); + Stream.Write(combatant?.Serial ?? Serial.Zero); } } @@ -574,9 +574,9 @@ namespace Server.Network { public DisplayHuePicker(HuePicker huePicker) : base(0x95, 9) { - m_Stream.Write(huePicker.Serial); - m_Stream.Write((short)0); - m_Stream.Write((short)huePicker.ItemID); + Stream.Write(huePicker.Serial); + Stream.Write((short)0); + Stream.Write((short)huePicker.ItemID); } } @@ -584,8 +584,8 @@ namespace Server.Network { public TripTimeResponse(int unk) : base(0xC9, 6) { - m_Stream.Write((byte)unk); - m_Stream.Write(Environment.TickCount); + Stream.Write((byte)unk); + Stream.Write(Environment.TickCount); } } @@ -593,8 +593,8 @@ namespace Server.Network { public UTripTimeResponse(int unk) : base(0xCA, 6) { - m_Stream.Write((byte)unk); - m_Stream.Write(Environment.TickCount); + Stream.Write((byte)unk); + Stream.Write(Environment.TickCount); } } @@ -604,11 +604,11 @@ namespace Server.Network { EnsureCapacity(21); - m_Stream.Write(prompt.Serial); - m_Stream.Write(prompt.Serial); - m_Stream.Write(0); - m_Stream.Write(0); - m_Stream.Write((short)0); + Stream.Write(prompt.Serial); + Stream.Write(prompt.Serial); + Stream.Write(0); + Stream.Write(0); + Stream.Write((short)0); } } @@ -618,31 +618,31 @@ namespace Server.Network { EnsureCapacity(305); - int count = 0; + var count = 0; - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) if (a[i] != null) ++count; - m_Stream.Write((byte)count); - m_Stream.Write((byte)0); + Stream.Write((byte)count); + Stream.Write((byte)0); - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) if (a[i] != null) { - string name = a[i].Name; + var name = a[i].Name; if (name == null) name = "-null-"; else if ((name = name.Trim()).Length == 0) name = "-empty-"; - m_Stream.WriteAsciiFixed(name, 30); - m_Stream.Fill(30); // password + Stream.WriteAsciiFixed(name, 30); + Stream.Fill(30); // password } else { - m_Stream.Fill(60); + Stream.Fill(60); } } } @@ -654,7 +654,7 @@ namespace Server.Network public DeathStatus(bool dead) : base(0x2C, 2) { - m_Stream.Write((byte)(dead ? 0 : 2)); + Stream.Write((byte)(dead ? 0 : 2)); } public static Packet Instantiate(bool dead) => dead ? Dead : Alive; @@ -671,8 +671,8 @@ namespace Server.Network { EnsureCapacity(3); - m_Stream.Write((short)0x26); - m_Stream.Write((byte)speedControl); + Stream.Write((short)0x26); + Stream.Write((byte)speedControl); } } @@ -689,10 +689,10 @@ namespace Server.Network { EnsureCapacity(11); - m_Stream.Write((short)0x19); - m_Stream.Write((byte)val1); - m_Stream.Write(serial); - m_Stream.Write((byte)val2); + Stream.Write((short)0x19); + Stream.Write((byte)val1); + Stream.Write(serial); + Stream.Write((byte)val2); } } @@ -703,10 +703,10 @@ namespace Server.Network { EnsureCapacity(7); - m_Stream.Write((short)0x25); + Stream.Write((short)0x25); - m_Stream.Write((short)abilityID); - m_Stream.Write(active); + Stream.Write((short)abilityID); + Stream.Write(active); } } @@ -716,46 +716,46 @@ namespace Server.Network { EnsureCapacity(256); - m_Stream.Write(((IMenu)menu).Serial); - m_Stream.Write((short)0); + Stream.Write(((IMenu)menu).Serial); + Stream.Write((short)0); - string question = menu.Question; + var question = menu.Question; if (question == null) { - m_Stream.Write((byte)0); + Stream.Write((byte)0); } else { - int questionLength = question.Length; - m_Stream.Write((byte)questionLength); - m_Stream.WriteAsciiFixed(question, questionLength); + var questionLength = question.Length; + Stream.Write((byte)questionLength); + Stream.WriteAsciiFixed(question, questionLength); } - ItemListEntry[] entries = menu.Entries; + var entries = menu.Entries; int entriesLength = (byte)entries.Length; - m_Stream.Write((byte)entriesLength); + Stream.Write((byte)entriesLength); - for (int i = 0; i < entriesLength; ++i) + for (var i = 0; i < entriesLength; ++i) { - ItemListEntry e = entries[i]; + var e = entries[i]; - m_Stream.Write((ushort)e.ItemID); - m_Stream.Write((short)e.Hue); + Stream.Write((ushort)e.ItemID); + Stream.Write((short)e.Hue); - string name = e.Name; + var name = e.Name; if (name == null) { - m_Stream.Write((byte)0); + Stream.Write((byte)0); } else { - int nameLength = name.Length; - m_Stream.Write((byte)nameLength); - m_Stream.WriteAsciiFixed(name, nameLength); + var nameLength = name.Length; + Stream.Write((byte)nameLength); + Stream.WriteAsciiFixed(name, nameLength); } } } @@ -767,43 +767,43 @@ namespace Server.Network { EnsureCapacity(256); - m_Stream.Write(((IMenu)menu).Serial); - m_Stream.Write((short)0); + Stream.Write(((IMenu)menu).Serial); + Stream.Write((short)0); - string question = menu.Question; + var question = menu.Question; if (question == null) { - m_Stream.Write((byte)0); + Stream.Write((byte)0); } else { - int questionLength = question.Length; - m_Stream.Write((byte)questionLength); - m_Stream.WriteAsciiFixed(question, questionLength); + var questionLength = question.Length; + Stream.Write((byte)questionLength); + Stream.WriteAsciiFixed(question, questionLength); } - string[] answers = menu.Answers; + var answers = menu.Answers; int answersLength = (byte)answers.Length; - m_Stream.Write((byte)answersLength); + Stream.Write((byte)answersLength); - for (int i = 0; i < answersLength; ++i) + for (var i = 0; i < answersLength; ++i) { - m_Stream.Write(0); + Stream.Write(0); - string answer = answers[i]; + var answer = answers[i]; if (answer == null) { - m_Stream.Write((byte)0); + Stream.Write((byte)0); } else { - int answerLength = answer.Length; - m_Stream.Write((byte)answerLength); - m_Stream.WriteAsciiFixed(answer, answerLength); + var answerLength = answer.Length; + Stream.Write((byte)answerLength); + Stream.WriteAsciiFixed(answer, answerLength); } } } @@ -815,13 +815,13 @@ namespace Server.Network public GlobalLightLevel(int level) : base(0x4F, 2) { - m_Stream.Write((sbyte)level); + Stream.Write((sbyte)level); } public static GlobalLightLevel Instantiate(int level) { - byte lvl = (byte)level; - GlobalLightLevel p = m_Cache[lvl]; + var lvl = (byte)level; + var p = m_Cache[lvl]; if (p == null) { @@ -841,8 +841,8 @@ namespace Server.Network public PersonalLightLevel(Mobile m, int level) : base(0x4E, 6) { - m_Stream.Write(m.Serial); - m_Stream.Write((sbyte)level); + Stream.Write(m.Serial); + Stream.Write((sbyte)level); } } @@ -850,8 +850,8 @@ namespace Server.Network { public PersonalLightLevelZero(Mobile m) : base(0x4E, 6) { - m_Stream.Write(m.Serial); - m_Stream.Write((sbyte)0); + Stream.Write(m.Serial); + Stream.Write((sbyte)0); } } @@ -869,20 +869,20 @@ namespace Server.Network { public DisplayContextMenu(ContextMenu menu) : base(0xBF) { - ContextMenuEntry[] entries = menu.Entries; + var entries = menu.Entries; int length = (byte)entries.Length; EnsureCapacity(12 + length * 8); - m_Stream.Write((short)0x14); - m_Stream.Write((short)0x02); + Stream.Write((short)0x14); + Stream.Write((short)0x02); - IEntity target = menu.Target as IEntity; + var target = menu.Target as IEntity; - m_Stream.Write(target?.Serial ?? Serial.MinusOne); + Stream.Write(target?.Serial ?? Serial.MinusOne); - m_Stream.Write((byte)length); + Stream.Write((byte)length); Point3D p; @@ -893,23 +893,23 @@ namespace Server.Network else p = Point3D.Zero; - for (int i = 0; i < length; ++i) + for (var i = 0; i < length; ++i) { - ContextMenuEntry e = entries[i]; + var e = entries[i]; - m_Stream.Write(e.Number); - m_Stream.Write((short)i); + Stream.Write(e.Number); + Stream.Write((short)i); - int range = e.Range; + var range = e.Range; if (range == -1) range = 18; - CMEFlags flags = e.Enabled && menu.From.InRange(p, range) ? CMEFlags.None : CMEFlags.Disabled; + var flags = e.Enabled && menu.From.InRange(p, range) ? CMEFlags.None : CMEFlags.Disabled; flags |= e.Flags; - m_Stream.Write((short)flags); + Stream.Write((short)flags); } } } @@ -918,20 +918,20 @@ namespace Server.Network { public DisplayContextMenuOld(ContextMenu menu) : base(0xBF) { - ContextMenuEntry[] entries = menu.Entries; + var entries = menu.Entries; int length = (byte)entries.Length; EnsureCapacity(12 + length * 8); - m_Stream.Write((short)0x14); - m_Stream.Write((short)0x01); + Stream.Write((short)0x14); + Stream.Write((short)0x01); - IEntity target = menu.Target as IEntity; + var target = menu.Target as IEntity; - m_Stream.Write(target?.Serial ?? Serial.MinusOne); + Stream.Write(target?.Serial ?? Serial.MinusOne); - m_Stream.Write((byte)length); + Stream.Write((byte)length); Point3D p; @@ -942,31 +942,31 @@ namespace Server.Network else p = Point3D.Zero; - for (int i = 0; i < length; ++i) + for (var i = 0; i < length; ++i) { - ContextMenuEntry e = entries[i]; + var e = entries[i]; - m_Stream.Write((short)i); - m_Stream.Write((ushort)(e.Number - 3000000)); + Stream.Write((short)i); + Stream.Write((ushort)(e.Number - 3000000)); - int range = e.Range; + var range = e.Range; if (range == -1) range = 18; - CMEFlags flags = e.Enabled && menu.From.InRange(p, range) ? CMEFlags.None : CMEFlags.Disabled; + var flags = e.Enabled && menu.From.InRange(p, range) ? CMEFlags.None : CMEFlags.Disabled; - int color = e.Color & 0xFFFF; + var color = e.Color & 0xFFFF; if (color != 0xFFFF) flags |= CMEFlags.Colored; flags |= e.Flags; - m_Stream.Write((short)flags); + Stream.Write((short)flags); if ((flags & CMEFlags.Colored) != 0) - m_Stream.Write((short)color); + Stream.Write((short)color); } } } @@ -981,10 +981,10 @@ namespace Server.Network EnsureCapacity(12 + header.Length + footer.Length * 2 + body.Length * 2); - m_Stream.Write(realSerial ? m.Serial : Serial.Zero); - m_Stream.WriteAsciiNull(header); - m_Stream.WriteBigUniNull(footer); - m_Stream.WriteBigUniNull(body); + Stream.Write(realSerial ? m.Serial : Serial.Zero); + Stream.WriteAsciiNull(header); + Stream.WriteBigUniNull(footer); + Stream.WriteBigUniNull(body); } } @@ -994,9 +994,9 @@ namespace Server.Network { EnsureCapacity(13); - m_Stream.Write((short)0x04); - m_Stream.Write(typeID); - m_Stream.Write(buttonID); + Stream.Write((short)0x04); + Stream.Write(typeID); + Stream.Write(buttonID); } } @@ -1006,7 +1006,7 @@ namespace Server.Network { Serial parentSerial; - Mobile parent = item.Parent as Mobile; + var parent = item.Parent as Mobile; if (parent != null) { @@ -1018,17 +1018,17 @@ namespace Server.Network parentSerial = Serial.Zero; } - int hue = item.Hue; + var hue = item.Hue; if (parent?.SolidHueOverride >= 0) hue = parent.SolidHueOverride; - m_Stream.Write(item.Serial); - m_Stream.Write((short)item.ItemID); - m_Stream.Write((byte)0); - m_Stream.Write((byte)item.Layer); - m_Stream.Write(parentSerial); - m_Stream.Write((short)hue); + Stream.Write(item.Serial); + Stream.Write((short)item.ItemID); + Stream.Write((byte)0); + Stream.Write((byte)item.Layer); + Stream.Write(parentSerial); + Stream.Write((short)hue); } } @@ -1043,35 +1043,35 @@ namespace Server.Network // +2 - Hue // +1 - Flags - uint serial = item.Serial.Value; - int itemID = item.ItemID & 0x3FFF; - int amount = item.Amount; - Point3D loc = item.Location; - int x = loc.m_X; - int y = loc.m_Y; - int hue = item.Hue; - int flags = item.GetPacketFlags(); - int direction = (int)item.Direction; + var serial = item.Serial.Value; + var itemID = item.ItemID & 0x3FFF; + var amount = item.Amount; + var loc = item.Location; + var x = loc.m_X; + var y = loc.m_Y; + var hue = item.Hue; + var flags = item.GetPacketFlags(); + var direction = (int)item.Direction; if (amount != 0) serial |= 0x80000000; else serial &= 0x7FFFFFFF; - m_Stream.Write(serial); + Stream.Write(serial); if (item is BaseMulti) - m_Stream.Write((short)(itemID | 0x4000)); + Stream.Write((short)(itemID | 0x4000)); else - m_Stream.Write((short)itemID); + Stream.Write((short)itemID); - if (amount != 0) m_Stream.Write((short)amount); + if (amount != 0) Stream.Write((short)amount); x &= 0x7FFF; if (direction != 0) x |= 0x8000; - m_Stream.Write((short)x); + Stream.Write((short)x); y &= 0x3FFF; @@ -1079,18 +1079,18 @@ namespace Server.Network if (flags != 0) y |= 0x4000; - m_Stream.Write((short)y); + Stream.Write((short)y); if (direction != 0) - m_Stream.Write((byte)direction); + Stream.Write((byte)direction); - m_Stream.Write((sbyte)loc.m_Z); + Stream.Write((sbyte)loc.m_Z); if (hue != 0) - m_Stream.Write((ushort)hue); + Stream.Write((ushort)hue); if (flags != 0) - m_Stream.Write((byte)flags); + Stream.Write((byte)flags); } } @@ -1098,22 +1098,22 @@ namespace Server.Network { public WorldItemSA(Item item) : base(0xF3, 24) { - m_Stream.Write((short)0x1); + Stream.Write((short)0x1); - int itemID = item.ItemID; + var itemID = item.ItemID; if (item is BaseMulti) { - m_Stream.Write((byte)0x02); + Stream.Write((byte)0x02); - m_Stream.Write(item.Serial); + Stream.Write(item.Serial); itemID &= 0x3FFF; - m_Stream.Write((short)itemID); + Stream.Write((short)itemID); - m_Stream.Write((byte)0); - /*} else if ( ) { + Stream.Write((byte)0); + /*} else if ( ) { m_Stream.Write( (byte) 0x01 ); m_Stream.Write( (int) item.Serial ); @@ -1124,31 +1124,31 @@ namespace Server.Network } else { - m_Stream.Write((byte)0x00); + Stream.Write((byte)0x00); - m_Stream.Write(item.Serial); + Stream.Write(item.Serial); itemID &= 0x7FFF; - m_Stream.Write((short)itemID); + Stream.Write((short)itemID); - m_Stream.Write((byte)0); + Stream.Write((byte)0); } - int amount = item.Amount; - m_Stream.Write((short)amount); - m_Stream.Write((short)amount); + var amount = item.Amount; + Stream.Write((short)amount); + Stream.Write((short)amount); - Point3D loc = item.Location; - int x = loc.m_X & 0x7FFF; - int y = loc.m_Y & 0x3FFF; - m_Stream.Write((short)x); - m_Stream.Write((short)y); - m_Stream.Write((sbyte)loc.m_Z); + var loc = item.Location; + var x = loc.m_X & 0x7FFF; + var y = loc.m_Y & 0x3FFF; + Stream.Write((short)x); + Stream.Write((short)y); + Stream.Write((sbyte)loc.m_Z); - m_Stream.Write((byte)item.Light); - m_Stream.Write((short)item.Hue); - m_Stream.Write((byte)item.GetPacketFlags()); + Stream.Write((byte)item.Light); + Stream.Write((short)item.Hue); + Stream.Write((byte)item.GetPacketFlags()); } } @@ -1156,22 +1156,22 @@ namespace Server.Network { public WorldItemHS(Item item) : base(0xF3, 26) { - m_Stream.Write((short)0x1); + Stream.Write((short)0x1); - int itemID = item.ItemID; + var itemID = item.ItemID; if (item is BaseMulti) { - m_Stream.Write((byte)0x02); + Stream.Write((byte)0x02); - m_Stream.Write(item.Serial); + Stream.Write(item.Serial); itemID &= 0x3FFF; - m_Stream.Write((ushort)itemID); + Stream.Write((ushort)itemID); - m_Stream.Write((byte)0); - /*} else if ( ) { + Stream.Write((byte)0); + /*} else if ( ) { m_Stream.Write( (byte) 0x01 ); m_Stream.Write( (int) item.Serial ); @@ -1182,33 +1182,33 @@ namespace Server.Network } else { - m_Stream.Write((byte)0x00); + Stream.Write((byte)0x00); - m_Stream.Write(item.Serial); + Stream.Write(item.Serial); itemID &= 0xFFFF; - m_Stream.Write((ushort)itemID); + Stream.Write((ushort)itemID); - m_Stream.Write((byte)0); + Stream.Write((byte)0); } - int amount = item.Amount; - m_Stream.Write((short)amount); - m_Stream.Write((short)amount); + var amount = item.Amount; + Stream.Write((short)amount); + Stream.Write((short)amount); - Point3D loc = item.Location; - int x = loc.m_X & 0x7FFF; - int y = loc.m_Y & 0x3FFF; - m_Stream.Write((short)x); - m_Stream.Write((short)y); - m_Stream.Write((sbyte)loc.m_Z); + var loc = item.Location; + var x = loc.m_X & 0x7FFF; + var y = loc.m_Y & 0x3FFF; + Stream.Write((short)x); + Stream.Write((short)y); + Stream.Write((sbyte)loc.m_Z); - m_Stream.Write((byte)item.Light); - m_Stream.Write((short)item.Hue); - m_Stream.Write((byte)item.GetPacketFlags()); + Stream.Write((byte)item.Light); + Stream.Write((short)item.Hue); + Stream.Write((byte)item.GetPacketFlags()); - m_Stream.Write((short)0x00); // ?? + Stream.Write((short)0x00); // ?? } } @@ -1216,7 +1216,7 @@ namespace Server.Network { public LiftRej(LRReason reason) : base(0x27, 2) { - m_Stream.Write((byte)reason); + Stream.Write((byte)reason); } } @@ -1224,7 +1224,7 @@ namespace Server.Network { public LogoutAck() : base(0xD1, 2) { - m_Stream.Write((byte)0x01); + Stream.Write((byte)0x01); } } @@ -1232,9 +1232,9 @@ namespace Server.Network { public Weather(int v1, int v2, int v3) : base(0x65, 4) { - m_Stream.Write((byte)v1); - m_Stream.Write((byte)v2); - m_Stream.Write((byte)v3); + Stream.Write((byte)v1); + Stream.Write((byte)v2); + Stream.Write((byte)v3); } } @@ -1244,40 +1244,40 @@ namespace Server.Network { EnsureCapacity(256); - //int - //short - //short - //short - //byte - //byte - //short - //byte - //byte - //short - //short - //short - //while ( int != 0 ) - //{ - //short - //byte - //short - //} + // int + // short + // short + // short + // byte + // byte + // short + // byte + // byte + // short + // short + // short + // while ( int != 0 ) + // { + // short + // byte + // short + // } - m_Stream.Write(beheld.Serial); - m_Stream.Write((short)beheld.Body); - m_Stream.Write((short)beheld.X); - m_Stream.Write((short)beheld.Y); - m_Stream.Write((sbyte)beheld.Z); - m_Stream.Write((byte)beheld.Direction); - m_Stream.Write((ushort)beheld.Hue); - m_Stream.Write((byte)beheld.GetPacketFlags()); - m_Stream.Write((byte)Notoriety.Compute(beholder, beheld)); + Stream.Write(beheld.Serial); + Stream.Write((short)beheld.Body); + Stream.Write((short)beheld.X); + Stream.Write((short)beheld.Y); + Stream.Write((sbyte)beheld.Z); + Stream.Write((byte)beheld.Direction); + Stream.Write((ushort)beheld.Hue); + Stream.Write((byte)beheld.GetPacketFlags()); + Stream.Write((byte)Notoriety.Compute(beholder, beheld)); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write((short)0); - m_Stream.Write(0); + Stream.Write(0); } } @@ -1287,28 +1287,28 @@ namespace Server.Network { EnsureCapacity(256); - m_Stream.Write(1); - m_Stream.Write(2); // ID - m_Stream.Write(3); // Customer ? (this) - m_Stream.Write(4); // Customer this (?) - m_Stream.Write(0); - m_Stream.Write((short)0); - m_Stream.Write((short)6); - m_Stream.Write((byte)'r'); - m_Stream.Write((byte)'e'); - m_Stream.Write((byte)'g'); - m_Stream.Write((byte)'i'); - m_Stream.Write((byte)'o'); - m_Stream.Write((byte)'n'); - m_Stream.Write(7); // Call time in seconds - m_Stream.Write((short)2); // Map (0=fel,1=tram,2=ilsh) - m_Stream.Write(8); // X - m_Stream.Write(9); // Y - m_Stream.Write(10); // Z - m_Stream.Write(11); // Volume - m_Stream.Write(12); // Rank - m_Stream.Write(-1); - m_Stream.Write(1); // type + Stream.Write(1); + Stream.Write(2); // ID + Stream.Write(3); // Customer ? (this) + Stream.Write(4); // Customer this (?) + Stream.Write(0); + Stream.Write((short)0); + Stream.Write((short)6); + Stream.Write((byte)'r'); + Stream.Write((byte)'e'); + Stream.Write((byte)'g'); + Stream.Write((byte)'i'); + Stream.Write((byte)'o'); + Stream.Write((byte)'n'); + Stream.Write(7); // Call time in seconds + Stream.Write((short)2); // Map (0=fel,1=tram,2=ilsh) + Stream.Write(8); // X + Stream.Write(9); // Y + Stream.Write(10); // Z + Stream.Write(11); // Volume + Stream.Write(12); // Rank + Stream.Write(-1); + Stream.Write(1); // type } } @@ -1319,7 +1319,7 @@ namespace Server.Network { public PlayerMove(Direction d) : base(0x97, 2) { - m_Stream.Write((byte)d); + Stream.Write((byte)d); // @4C63B0 } @@ -1332,8 +1332,8 @@ namespace Server.Network { public GQCount(int unk, int count) : base(0xCB, 7) { - m_Stream.Write((short)unk); - m_Stream.Write(count); + Stream.Write((short)unk); + Stream.Write(count); } } @@ -1357,7 +1357,7 @@ namespace Server.Network { EnsureCapacity(7); - m_Stream.Write(unk); + Stream.Write(unk); } } @@ -1375,60 +1375,60 @@ namespace Server.Network int speed, int duration, bool fixedDirection, bool explode, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, Serial serial, int layer, int unknown) : base(0xC7, 49) { - m_Stream.Write((byte)type); - m_Stream.Write(from); - m_Stream.Write(to); - m_Stream.Write((short)itemID); - m_Stream.Write((short)fromPoint.m_X); - m_Stream.Write((short)fromPoint.m_Y); - m_Stream.Write((sbyte)fromPoint.m_Z); - m_Stream.Write((short)toPoint.m_X); - m_Stream.Write((short)toPoint.m_Y); - m_Stream.Write((sbyte)toPoint.m_Z); - m_Stream.Write((byte)speed); - m_Stream.Write((byte)duration); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0); - m_Stream.Write(fixedDirection); - m_Stream.Write(explode); - m_Stream.Write(hue); - m_Stream.Write(renderMode); - m_Stream.Write((short)effect); - m_Stream.Write((short)explodeEffect); - m_Stream.Write((short)explodeSound); - m_Stream.Write(serial); - m_Stream.Write((byte)layer); - m_Stream.Write((short)unknown); + Stream.Write((byte)type); + Stream.Write(from); + Stream.Write(to); + Stream.Write((short)itemID); + Stream.Write((short)fromPoint.m_X); + Stream.Write((short)fromPoint.m_Y); + Stream.Write((sbyte)fromPoint.m_Z); + Stream.Write((short)toPoint.m_X); + Stream.Write((short)toPoint.m_Y); + Stream.Write((sbyte)toPoint.m_Z); + Stream.Write((byte)speed); + Stream.Write((byte)duration); + Stream.Write((byte)0); + Stream.Write((byte)0); + Stream.Write(fixedDirection); + Stream.Write(explode); + Stream.Write(hue); + Stream.Write(renderMode); + Stream.Write((short)effect); + Stream.Write((short)explodeEffect); + Stream.Write((short)explodeSound); + Stream.Write(serial); + Stream.Write((byte)layer); + Stream.Write((short)unknown); } public ParticleEffect(EffectType type, Serial from, Serial to, int itemID, IPoint3D fromPoint, IPoint3D toPoint, int speed, int duration, bool fixedDirection, bool explode, int hue, int renderMode, int effect, int explodeEffect, int explodeSound, Serial serial, int layer, int unknown) : base(0xC7, 49) { - m_Stream.Write((byte)type); - m_Stream.Write(from); - m_Stream.Write(to); - m_Stream.Write((short)itemID); - m_Stream.Write((short)fromPoint.X); - m_Stream.Write((short)fromPoint.Y); - m_Stream.Write((sbyte)fromPoint.Z); - m_Stream.Write((short)toPoint.X); - m_Stream.Write((short)toPoint.Y); - m_Stream.Write((sbyte)toPoint.Z); - m_Stream.Write((byte)speed); - m_Stream.Write((byte)duration); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0); - m_Stream.Write(fixedDirection); - m_Stream.Write(explode); - m_Stream.Write(hue); - m_Stream.Write(renderMode); - m_Stream.Write((short)effect); - m_Stream.Write((short)explodeEffect); - m_Stream.Write((short)explodeSound); - m_Stream.Write(serial); - m_Stream.Write((byte)layer); - m_Stream.Write((short)unknown); + Stream.Write((byte)type); + Stream.Write(from); + Stream.Write(to); + Stream.Write((short)itemID); + Stream.Write((short)fromPoint.X); + Stream.Write((short)fromPoint.Y); + Stream.Write((sbyte)fromPoint.Z); + Stream.Write((short)toPoint.X); + Stream.Write((short)toPoint.Y); + Stream.Write((sbyte)toPoint.Z); + Stream.Write((byte)speed); + Stream.Write((byte)duration); + Stream.Write((byte)0); + Stream.Write((byte)0); + Stream.Write(fixedDirection); + Stream.Write(explode); + Stream.Write(hue); + Stream.Write(renderMode); + Stream.Write((short)effect); + Stream.Write((short)explodeEffect); + Stream.Write((short)explodeSound); + Stream.Write(serial); + Stream.Write((byte)layer); + Stream.Write((short)unknown); } } @@ -1437,47 +1437,47 @@ namespace Server.Network public HuedEffect(EffectType type, Serial from, Serial to, int itemID, Point3D fromPoint, Point3D toPoint, int speed, int duration, bool fixedDirection, bool explode, int hue, int renderMode) : base(0xC0, 36) { - m_Stream.Write((byte)type); - m_Stream.Write(from); - m_Stream.Write(to); - m_Stream.Write((short)itemID); - m_Stream.Write((short)fromPoint.m_X); - m_Stream.Write((short)fromPoint.m_Y); - m_Stream.Write((sbyte)fromPoint.m_Z); - m_Stream.Write((short)toPoint.m_X); - m_Stream.Write((short)toPoint.m_Y); - m_Stream.Write((sbyte)toPoint.m_Z); - m_Stream.Write((byte)speed); - m_Stream.Write((byte)duration); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0); - m_Stream.Write(fixedDirection); - m_Stream.Write(explode); - m_Stream.Write(hue); - m_Stream.Write(renderMode); + Stream.Write((byte)type); + Stream.Write(from); + Stream.Write(to); + Stream.Write((short)itemID); + Stream.Write((short)fromPoint.m_X); + Stream.Write((short)fromPoint.m_Y); + Stream.Write((sbyte)fromPoint.m_Z); + Stream.Write((short)toPoint.m_X); + Stream.Write((short)toPoint.m_Y); + Stream.Write((sbyte)toPoint.m_Z); + Stream.Write((byte)speed); + Stream.Write((byte)duration); + Stream.Write((byte)0); + Stream.Write((byte)0); + Stream.Write(fixedDirection); + Stream.Write(explode); + Stream.Write(hue); + Stream.Write(renderMode); } public HuedEffect(EffectType type, Serial from, Serial to, int itemID, IPoint3D fromPoint, IPoint3D toPoint, int speed, int duration, bool fixedDirection, bool explode, int hue, int renderMode) : base(0xC0, 36) { - m_Stream.Write((byte)type); - m_Stream.Write(from); - m_Stream.Write(to); - m_Stream.Write((short)itemID); - m_Stream.Write((short)fromPoint.X); - m_Stream.Write((short)fromPoint.Y); - m_Stream.Write((sbyte)fromPoint.Z); - m_Stream.Write((short)toPoint.X); - m_Stream.Write((short)toPoint.Y); - m_Stream.Write((sbyte)toPoint.Z); - m_Stream.Write((byte)speed); - m_Stream.Write((byte)duration); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0); - m_Stream.Write(fixedDirection); - m_Stream.Write(explode); - m_Stream.Write(hue); - m_Stream.Write(renderMode); + Stream.Write((byte)type); + Stream.Write(from); + Stream.Write(to); + Stream.Write((short)itemID); + Stream.Write((short)fromPoint.X); + Stream.Write((short)fromPoint.Y); + Stream.Write((sbyte)fromPoint.Z); + Stream.Write((short)toPoint.X); + Stream.Write((short)toPoint.Y); + Stream.Write((sbyte)toPoint.Z); + Stream.Write((byte)speed); + Stream.Write((byte)duration); + Stream.Write((byte)0); + Stream.Write((byte)0); + Stream.Write(fixedDirection); + Stream.Write(explode); + Stream.Write(hue); + Stream.Write(renderMode); } } @@ -1550,10 +1550,10 @@ namespace Server.Network public ScreenEffect(ScreenEffectType type) : base(0x70, 28) { - m_Stream.Write((byte)0x04); - m_Stream.Fill(8); - m_Stream.Write((short)type); - m_Stream.Fill(16); + Stream.Write((byte)0x04); + Stream.Fill(8); + Stream.Write((short)type); + Stream.Fill(16); } } @@ -1621,7 +1621,7 @@ namespace Server.Network { public DeleteResult(DeleteResultType res) : base(0x85, 2) { - m_Stream.Write((byte)res); + Stream.Write((byte)res); } } @@ -1679,23 +1679,23 @@ namespace Server.Network { public BoltEffect(IEntity target, int hue) : base(0xC0, 36) { - m_Stream.Write((byte)0x01); // type - m_Stream.Write(target.Serial); - m_Stream.Write(Serial.Zero); - m_Stream.Write((short)0); // itemID - m_Stream.Write((short)target.X); - m_Stream.Write((short)target.Y); - m_Stream.Write((sbyte)target.Z); - m_Stream.Write((short)target.X); - m_Stream.Write((short)target.Y); - m_Stream.Write((sbyte)target.Z); - m_Stream.Write((byte)0); // speed - m_Stream.Write((byte)0); // duration - m_Stream.Write((short)0); // unk - m_Stream.Write(false); // fixed direction - m_Stream.Write(false); // explode - m_Stream.Write(hue); - m_Stream.Write(0); // render mode + Stream.Write((byte)0x01); // type + Stream.Write(target.Serial); + Stream.Write(Serial.Zero); + Stream.Write((short)0); // itemID + Stream.Write((short)target.X); + Stream.Write((short)target.Y); + Stream.Write((sbyte)target.Z); + Stream.Write((short)target.X); + Stream.Write((short)target.Y); + Stream.Write((sbyte)target.Z); + Stream.Write((byte)0); // speed + Stream.Write((byte)0); // duration + Stream.Write((short)0); // unk + Stream.Write(false); // fixed direction + Stream.Write(false); // explode + Stream.Write(hue); + Stream.Write(0); // render mode } } @@ -1703,8 +1703,8 @@ namespace Server.Network { public DisplaySpellbook(Item book) : base(0x24, 7) { - m_Stream.Write(book.Serial); - m_Stream.Write((short)-1); + Stream.Write(book.Serial); + Stream.Write((short)-1); } } @@ -1712,9 +1712,9 @@ namespace Server.Network { public DisplaySpellbookHS(Item book) : base(0x24, 9) { - m_Stream.Write(book.Serial); - m_Stream.Write((short)-1); - m_Stream.Write((short)0x7D); + Stream.Write(book.Serial); + Stream.Write((short)-1); + Stream.Write((short)0x7D); } } @@ -1724,15 +1724,15 @@ namespace Server.Network { EnsureCapacity(23); - m_Stream.Write((short)0x1B); - m_Stream.Write((short)0x01); + Stream.Write((short)0x1B); + Stream.Write((short)0x01); - m_Stream.Write(item.Serial); - m_Stream.Write((short)graphic); - m_Stream.Write((short)offset); + Stream.Write(item.Serial); + Stream.Write((short)graphic); + Stream.Write((short)offset); - for (int i = 0; i < 8; ++i) - m_Stream.Write((byte)(content >> i * 8)); + for (var i = 0; i < 8; ++i) + Stream.Write((byte)(content >> (i * 8))); } } @@ -1742,29 +1742,29 @@ namespace Server.Network { EnsureCapacity(5 + count * 19); - int written = 0; + var written = 0; - m_Stream.Write((ushort)0); + Stream.Write((ushort)0); ulong mask = 1; - for (int i = 0; i < 64; ++i, mask <<= 1) + for (var i = 0; i < 64; ++i, mask <<= 1) if ((content & mask) != 0) { - m_Stream.Write(0x7FFFFFFF - i); - m_Stream.Write((ushort)0); - m_Stream.Write((byte)0); - m_Stream.Write((ushort)(i + offset)); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write(item.Serial); - m_Stream.Write((short)0); + Stream.Write(0x7FFFFFFF - i); + Stream.Write((ushort)0); + Stream.Write((byte)0); + Stream.Write((ushort)(i + offset)); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write(item.Serial); + Stream.Write((short)0); ++written; } - m_Stream.Seek(3, SeekOrigin.Begin); - m_Stream.Write((ushort)written); + Stream.Seek(3, SeekOrigin.Begin); + Stream.Write((ushort)written); } } @@ -1774,30 +1774,30 @@ namespace Server.Network { EnsureCapacity(5 + count * 20); - int written = 0; + var written = 0; - m_Stream.Write((ushort)0); + Stream.Write((ushort)0); ulong mask = 1; - for (int i = 0; i < 64; ++i, mask <<= 1) + for (var i = 0; i < 64; ++i, mask <<= 1) if ((content & mask) != 0) { - m_Stream.Write(0x7FFFFFFF - i); - m_Stream.Write((ushort)0); - m_Stream.Write((byte)0); - m_Stream.Write((ushort)(i + offset)); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(item.Serial); - m_Stream.Write((short)0); + Stream.Write(0x7FFFFFFF - i); + Stream.Write((ushort)0); + Stream.Write((byte)0); + Stream.Write((ushort)(i + offset)); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write((byte)0); // Grid Location? + Stream.Write(item.Serial); + Stream.Write((short)0); ++written; } - m_Stream.Seek(3, SeekOrigin.Begin); - m_Stream.Write((ushort)written); + Stream.Seek(3, SeekOrigin.Begin); + Stream.Write((ushort)written); } } @@ -1805,8 +1805,8 @@ namespace Server.Network { public ContainerDisplay(Container c) : base(0x24, 7) { - m_Stream.Write(c.Serial); - m_Stream.Write((short)c.GumpID); + Stream.Write(c.Serial); + Stream.Write((short)c.GumpID); } } @@ -1814,9 +1814,9 @@ namespace Server.Network { public ContainerDisplayHS(Container c) : base(0x24, 9) { - m_Stream.Write(c.Serial); - m_Stream.Write((short)c.GumpID); - m_Stream.Write((short)0x7D); + Stream.Write(c.Serial); + Stream.Write((short)c.GumpID); + Stream.Write((short)0x7D); } } @@ -1836,14 +1836,14 @@ namespace Server.Network parentSerial = Serial.Zero; } - m_Stream.Write(item.Serial); - m_Stream.Write((ushort)item.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)Math.Min(item.Amount, ushort.MaxValue)); - m_Stream.Write((short)item.X); - m_Stream.Write((short)item.Y); - m_Stream.Write(parentSerial); - m_Stream.Write((ushort)(item.QuestItem ? Item.QuestItemHue : item.Hue)); + Stream.Write(item.Serial); + Stream.Write((ushort)item.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)Math.Min(item.Amount, ushort.MaxValue)); + Stream.Write((short)item.X); + Stream.Write((short)item.Y); + Stream.Write(parentSerial); + Stream.Write((ushort)(item.QuestItem ? Item.QuestItemHue : item.Hue)); } } @@ -1863,15 +1863,15 @@ namespace Server.Network parentSerial = Serial.Zero; } - m_Stream.Write(item.Serial); - m_Stream.Write((ushort)item.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)Math.Min(item.Amount, ushort.MaxValue)); - m_Stream.Write((short)item.X); - m_Stream.Write((short)item.Y); - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(parentSerial); - m_Stream.Write((ushort)(item.QuestItem ? Item.QuestItemHue : item.Hue)); + Stream.Write(item.Serial); + Stream.Write((ushort)item.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)Math.Min(item.Amount, ushort.MaxValue)); + Stream.Write((short)item.X); + Stream.Write((short)item.Y); + Stream.Write((byte)0); // Grid Location? + Stream.Write(parentSerial); + Stream.Write((ushort)(item.QuestItem ? Item.QuestItemHue : item.Hue)); } } @@ -1879,40 +1879,40 @@ namespace Server.Network { public ContainerContent(Mobile beholder, Item beheld) : base(0x3C) { - List items = beheld.Items; - int count = items.Count; + var items = beheld.Items; + var count = items.Count; EnsureCapacity(5 + count * 19); - long pos = m_Stream.Position; + var pos = Stream.Position; - int written = 0; + var written = 0; - m_Stream.Write((ushort)0); + Stream.Write((ushort)0); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - Item child = items[i]; + var child = items[i]; if (!child.Deleted && beholder.CanSee(child)) { - Point3D loc = child.Location; + var loc = child.Location; - m_Stream.Write(child.Serial); - m_Stream.Write((ushort)child.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)Math.Min(child.Amount, ushort.MaxValue)); - m_Stream.Write((short)loc.m_X); - m_Stream.Write((short)loc.m_Y); - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)(child.QuestItem ? Item.QuestItemHue : child.Hue)); + Stream.Write(child.Serial); + Stream.Write((ushort)child.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)Math.Min(child.Amount, ushort.MaxValue)); + Stream.Write((short)loc.m_X); + Stream.Write((short)loc.m_Y); + Stream.Write(beheld.Serial); + Stream.Write((ushort)(child.QuestItem ? Item.QuestItemHue : child.Hue)); ++written; } } - m_Stream.Seek(pos, SeekOrigin.Begin); - m_Stream.Write((ushort)written); + Stream.Seek(pos, SeekOrigin.Begin); + Stream.Write((ushort)written); } } @@ -1920,41 +1920,41 @@ namespace Server.Network { public ContainerContent6017(Mobile beholder, Item beheld) : base(0x3C) { - List items = beheld.Items; - int count = items.Count; + var items = beheld.Items; + var count = items.Count; EnsureCapacity(5 + count * 20); - long pos = m_Stream.Position; + var pos = Stream.Position; - int written = 0; + var written = 0; - m_Stream.Write((ushort)0); + Stream.Write((ushort)0); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - Item child = items[i]; + var child = items[i]; if (!child.Deleted && beholder.CanSee(child)) { - Point3D loc = child.Location; + var loc = child.Location; - m_Stream.Write(child.Serial); - m_Stream.Write((ushort)child.ItemID); - m_Stream.Write((byte)0); // signed, itemID offset - m_Stream.Write((ushort)Math.Min(child.Amount, ushort.MaxValue)); - m_Stream.Write((short)loc.m_X); - m_Stream.Write((short)loc.m_Y); - m_Stream.Write((byte)0); // Grid Location? - m_Stream.Write(beheld.Serial); - m_Stream.Write((ushort)(child.QuestItem ? Item.QuestItemHue : child.Hue)); + Stream.Write(child.Serial); + Stream.Write((ushort)child.ItemID); + Stream.Write((byte)0); // signed, itemID offset + Stream.Write((ushort)Math.Min(child.Amount, ushort.MaxValue)); + Stream.Write((short)loc.m_X); + Stream.Write((short)loc.m_Y); + Stream.Write((byte)0); // Grid Location? + Stream.Write(beheld.Serial); + Stream.Write((ushort)(child.QuestItem ? Item.QuestItemHue : child.Hue)); ++written; } } - m_Stream.Seek(pos, SeekOrigin.Begin); - m_Stream.Write((ushort)written); + Stream.Seek(pos, SeekOrigin.Begin); + Stream.Write((ushort)written); } } @@ -1965,11 +1965,11 @@ namespace Server.Network public SetWarMode(bool mode) : base(0x72, 5) { - m_Stream.Write(mode); - m_Stream.Write((byte)0x00); - m_Stream.Write((byte)0x32); - m_Stream.Write((byte)0x00); - //m_Stream.Fill(); + Stream.Write(mode); + Stream.Write((byte)0x00); + Stream.Write((byte)0x32); + Stream.Write((byte)0x00); + // m_Stream.Fill(); } public static Packet Instantiate(bool mode) => mode ? InWarMode : InPeaceMode; @@ -1979,9 +1979,9 @@ namespace Server.Network { public Swing(int flag, Mobile attacker, Mobile defender) : base(0x2F, 10) { - m_Stream.Write((byte)flag); - m_Stream.Write(attacker.Serial); - m_Stream.Write(defender.Serial); + Stream.Write((byte)flag); + Stream.Write(attacker.Serial); + Stream.Write(defender.Serial); } } @@ -1990,13 +1990,13 @@ namespace Server.Network public NullFastwalkStack() : base(0xBF) { EnsureCapacity(256); - m_Stream.Write((short)0x1); - m_Stream.Write(0x0); - m_Stream.Write(0x0); - m_Stream.Write(0x0); - m_Stream.Write(0x0); - m_Stream.Write(0x0); - m_Stream.Write(0x0); + Stream.Write((short)0x1); + Stream.Write(0x0); + Stream.Write(0x0); + Stream.Write(0x0); + Stream.Write(0x0); + Stream.Write(0x0); + Stream.Write(0x0); } } @@ -2004,7 +2004,7 @@ namespace Server.Network { public RemoveEntity(IEntity entity) : base(0x1D, 5) { - m_Stream.Write(entity.Serial); + Stream.Write(entity.Serial); } } @@ -2012,14 +2012,14 @@ namespace Server.Network { public ServerChange(Mobile m, Map map) : base(0x76, 16) { - m_Stream.Write((short)m.X); - m_Stream.Write((short)m.Y); - m_Stream.Write((short)m.Z); - m_Stream.Write((byte)0); - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write((short)map.Width); - m_Stream.Write((short)map.Height); + Stream.Write((short)m.X); + Stream.Write((short)m.Y); + Stream.Write((short)m.Z); + Stream.Write((byte)0); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write((short)map.Width); + Stream.Write((short)map.Height); } } @@ -2029,28 +2029,28 @@ namespace Server.Network { EnsureCapacity(6 + skills.Length * 9); - m_Stream.Write((byte)0x02); // type: absolute, capped + Stream.Write((byte)0x02); // type: absolute, capped - for (int i = 0; i < skills.Length; ++i) + for (var i = 0; i < skills.Length; ++i) { - Skill s = skills[i]; + var s = skills[i]; - double v = s.NonRacialValue; - int uv = (int)(v * 10); + var v = s.NonRacialValue; + var uv = (int)(v * 10); if (uv < 0) uv = 0; else if (uv >= 0x10000) uv = 0xFFFF; - m_Stream.Write((ushort)(s.Info.SkillID + 1)); - m_Stream.Write((ushort)uv); - m_Stream.Write((ushort)s.BaseFixedPoint); - m_Stream.Write((byte)s.Lock); - m_Stream.Write((ushort)s.CapFixedPoint); + Stream.Write((ushort)(s.Info.SkillID + 1)); + Stream.Write((ushort)uv); + Stream.Write((ushort)s.BaseFixedPoint); + Stream.Write((byte)s.Lock); + Stream.Write((ushort)s.CapFixedPoint); } - m_Stream.Write((short)0); // terminate + Stream.Write((short)0); // terminate } } @@ -2058,7 +2058,7 @@ namespace Server.Network { public Sequence(int num) : base(0x7B, 2) { - m_Stream.Write((byte)num); + Stream.Write((byte)num); } } @@ -2068,20 +2068,20 @@ namespace Server.Network { EnsureCapacity(13); - double v = skill.NonRacialValue; - int uv = (int)(v * 10); + var v = skill.NonRacialValue; + var uv = (int)(v * 10); if (uv < 0) uv = 0; else if (uv >= 0x10000) uv = 0xFFFF; - m_Stream.Write((byte)0xDF); // type: delta, capped - m_Stream.Write((ushort)skill.Info.SkillID); - m_Stream.Write((ushort)uv); - m_Stream.Write((ushort)skill.BaseFixedPoint); - m_Stream.Write((byte)skill.Lock); - m_Stream.Write((ushort)skill.CapFixedPoint); + Stream.Write((byte)0xDF); // type: delta, capped + Stream.Write((ushort)skill.Info.SkillID); + Stream.Write((ushort)uv); + Stream.Write((ushort)skill.BaseFixedPoint); + Stream.Write((byte)skill.Lock); + Stream.Write((ushort)skill.CapFixedPoint); /*m_Stream.Write( (short) skill.Info.SkillID ); m_Stream.Write( (short) (skill.Value * 10.0) ); @@ -2093,13 +2093,17 @@ namespace Server.Network public sealed class LaunchBrowser : Packet { + public LaunchBrowser(Uri uri) : this(uri.AbsoluteUri) + { + } + public LaunchBrowser(string url) : base(0xA5) { url ??= ""; EnsureCapacity(4 + url.Length); - m_Stream.WriteAsciiNull(url); + Stream.WriteAsciiNull(url); } } @@ -2120,20 +2124,20 @@ namespace Server.Network EnsureCapacity(50 + args.Length * 2); - m_Stream.Write(serial); - m_Stream.Write((short)graphic); - m_Stream.Write((byte)type); - m_Stream.Write((short)hue); - m_Stream.Write((short)font); - m_Stream.Write(number); - m_Stream.WriteAsciiFixed(name, 30); - m_Stream.WriteLittleUniNull(args); + Stream.Write(serial); + Stream.Write((short)graphic); + Stream.Write((byte)type); + Stream.Write((short)hue); + Stream.Write((short)font); + Stream.Write(number); + Stream.WriteAsciiFixed(name, 30); + Stream.WriteLittleUniNull(args); } public static MessageLocalized InstantiateGeneric(int number) { MessageLocalized[] cache = null; - int index = 0; + var index = 0; if (number >= 3000000) { @@ -2177,22 +2181,22 @@ namespace Server.Network { public MobileMoving(Mobile m, int noto) : base(0x77, 17) { - Point3D loc = m.Location; + var loc = m.Location; - int hue = m.Hue; + var hue = m.Hue; if (m.SolidHueOverride >= 0) hue = m.SolidHueOverride; - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.Body); - m_Stream.Write((short)loc.m_X); - m_Stream.Write((short)loc.m_Y); - m_Stream.Write((sbyte)loc.m_Z); - m_Stream.Write((byte)m.Direction); - m_Stream.Write((short)hue); - m_Stream.Write((byte)m.GetPacketFlags()); - m_Stream.Write((byte)noto); + Stream.Write(m.Serial); + Stream.Write((short)m.Body); + Stream.Write((short)loc.m_X); + Stream.Write((short)loc.m_Y); + Stream.Write((sbyte)loc.m_Z); + Stream.Write((byte)m.Direction); + Stream.Write((short)hue); + Stream.Write((byte)m.GetPacketFlags()); + Stream.Write((byte)noto); } } @@ -2201,22 +2205,22 @@ namespace Server.Network { public MobileMovingOld(Mobile m, int noto) : base(0x77, 17) { - Point3D loc = m.Location; + var loc = m.Location; - int hue = m.Hue; + var hue = m.Hue; if (m.SolidHueOverride >= 0) hue = m.SolidHueOverride; - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.Body); - m_Stream.Write((short)loc.m_X); - m_Stream.Write((short)loc.m_Y); - m_Stream.Write((sbyte)loc.m_Z); - m_Stream.Write((byte)m.Direction); - m_Stream.Write((short)hue); - m_Stream.Write((byte)m.GetOldPacketFlags()); - m_Stream.Write((byte)noto); + Stream.Write(m.Serial); + Stream.Write((short)m.Body); + Stream.Write((short)loc.m_X); + Stream.Write((short)loc.m_Y); + Stream.Write((sbyte)loc.m_Z); + Stream.Write((byte)m.Direction); + Stream.Write((short)hue); + Stream.Write((byte)m.GetOldPacketFlags()); + Stream.Write((byte)noto); } } @@ -2224,17 +2228,17 @@ namespace Server.Network { public MultiTargetReqHS(MultiTarget t) : base(0x99, 30) { - m_Stream.Write(t.AllowGround); - m_Stream.Write(t.TargetID); - m_Stream.Write((byte)t.Flags); + Stream.Write(t.AllowGround); + Stream.Write(t.TargetID); + Stream.Write((byte)t.Flags); - m_Stream.Fill(); + Stream.Fill(); - m_Stream.Seek(18, SeekOrigin.Begin); - m_Stream.Write((short)t.MultiID); - m_Stream.Write((short)t.Offset.X); - m_Stream.Write((short)t.Offset.Y); - m_Stream.Write((short)t.Offset.Z); + Stream.Seek(18, SeekOrigin.Begin); + Stream.Write((short)t.MultiID); + Stream.Write((short)t.Offset.X); + Stream.Write((short)t.Offset.Y); + Stream.Write((short)t.Offset.Z); // DWORD Hue } @@ -2244,17 +2248,17 @@ namespace Server.Network { public MultiTargetReq(MultiTarget t) : base(0x99, 26) { - m_Stream.Write(t.AllowGround); - m_Stream.Write(t.TargetID); - m_Stream.Write((byte)t.Flags); + Stream.Write(t.AllowGround); + Stream.Write(t.TargetID); + Stream.Write((byte)t.Flags); - m_Stream.Fill(); + Stream.Fill(); - m_Stream.Seek(18, SeekOrigin.Begin); - m_Stream.Write((short)t.MultiID); - m_Stream.Write((short)t.Offset.X); - m_Stream.Write((short)t.Offset.Y); - m_Stream.Write((short)t.Offset.Z); + Stream.Seek(18, SeekOrigin.Begin); + Stream.Write((short)t.MultiID); + Stream.Write((short)t.Offset.X); + Stream.Write((short)t.Offset.Y); + Stream.Write((short)t.Offset.Z); } } @@ -2264,10 +2268,10 @@ namespace Server.Network public CancelTarget() : base(0x6C, 19) { - m_Stream.Write((byte)0); - m_Stream.Write(0); - m_Stream.Write((byte)3); - m_Stream.Fill(); + Stream.Write((byte)0); + Stream.Write(0); + Stream.Write((byte)3); + Stream.Fill(); } } @@ -2275,10 +2279,10 @@ namespace Server.Network { public TargetReq(Target t) : base(0x6C, 19) { - m_Stream.Write(t.AllowGround); - m_Stream.Write(t.TargetID); - m_Stream.Write((byte)t.Flags); - m_Stream.Fill(); + Stream.Write(t.AllowGround); + Stream.Write(t.TargetID); + Stream.Write((byte)t.Flags); + Stream.Fill(); } } @@ -2286,25 +2290,25 @@ namespace Server.Network { public DragEffect(IEntity src, IEntity trg, int itemID, int hue, int amount) : base(0x23, 26) { - m_Stream.Write((short)itemID); - m_Stream.Write((byte)0); - m_Stream.Write((short)hue); - m_Stream.Write((short)amount); - m_Stream.Write(src.Serial); - m_Stream.Write((short)src.X); - m_Stream.Write((short)src.Y); - m_Stream.Write((sbyte)src.Z); - m_Stream.Write(trg.Serial); - m_Stream.Write((short)trg.X); - m_Stream.Write((short)trg.Y); - m_Stream.Write((sbyte)trg.Z); + Stream.Write((short)itemID); + Stream.Write((byte)0); + Stream.Write((short)hue); + Stream.Write((short)amount); + Stream.Write(src.Serial); + Stream.Write((short)src.X); + Stream.Write((short)src.Y); + Stream.Write((sbyte)src.Z); + Stream.Write(trg.Serial); + Stream.Write((short)trg.X); + Stream.Write((short)trg.Y); + Stream.Write((sbyte)trg.Z); } } public interface IGumpWriter { - int TextEntries{ get; set; } - int Switches{ get; set; } + int TextEntries { get; set; } + int Switches { get; set; } void AppendLayout(bool val); void AppendLayout(int val); @@ -2344,9 +2348,9 @@ namespace Server.Network m_Strings = PacketWriter.CreateInstance(8192); } - public int TextEntries{ get; set; } + public int TextEntries { get; set; } - public int Switches{ get; set; } + public int Switches { get; set; } public void AppendLayout(bool val) { @@ -2355,24 +2359,24 @@ namespace Server.Network public void AppendLayout(int val) { - string toString = val.ToString(); - int bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; + var toString = val.ToString(); + var bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; m_Layout.Write(m_Buffer, 0, bytes); } public void AppendLayout(uint val) { - string toString = val.ToString(); - int bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; + var toString = val.ToString(); + var bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; m_Layout.Write(m_Buffer, 0, bytes); } public void AppendLayoutNS(int val) { - string toString = val.ToString(); - int bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1); + var toString = val.ToString(); + var bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1); m_Layout.Write(m_Buffer, 1, bytes); } @@ -2395,9 +2399,9 @@ namespace Server.Network { m_StringCount = strings.Count; - for (int i = 0; i < strings.Count; ++i) + for (var i = 0; i < strings.Count; ++i) { - string v = strings[i] ?? ""; + var v = strings[i] ?? ""; m_Strings.Write((ushort)v.Length); m_Strings.WriteBigUniFixed(v, v.Length); @@ -2408,16 +2412,16 @@ namespace Server.Network { EnsureCapacity(28 + (int)m_Layout.Length + (int)m_Strings.Length); - m_Stream.Write(m_Gump.Serial); - m_Stream.Write(m_Gump.TypeID); - m_Stream.Write(m_Gump.X); - m_Stream.Write(m_Gump.Y); + Stream.Write(m_Gump.Serial); + Stream.Write(m_Gump.TypeID); + Stream.Write(m_Gump.X); + Stream.Write(m_Gump.Y); // Note: layout MUST be null terminated (don't listen to krrios) m_Layout.Write((byte)0); WritePacked(m_Layout); - m_Stream.Write(m_StringCount); + Stream.Write(m_StringCount); WritePacked(m_Strings); @@ -2427,29 +2431,29 @@ namespace Server.Network private void WritePacked(PacketWriter src) { - byte[] buffer = src.UnderlyingStream.GetBuffer(); - int length = (int)src.Length; + var buffer = src.UnderlyingStream.GetBuffer(); + var length = (int)src.Length; if (length == 0) { - m_Stream.Write(0); + Stream.Write(0); return; } - int wantLength = 1 + buffer.Length * 1024 / 1000; + var wantLength = 1 + buffer.Length * 1024 / 1000; wantLength += 4095; wantLength &= ~4095; - byte[] packBuffer = ArrayPool.Shared.Rent(wantLength); + var packBuffer = ArrayPool.Shared.Rent(wantLength); - int packLength = wantLength; + var packLength = wantLength; - Compression.Pack(packBuffer, ref packLength, buffer, length, ZLibQuality.Default); + NetworkCompression.Pack(packBuffer, ref packLength, buffer, length, ZLibQuality.Default); - m_Stream.Write(4 + packLength); - m_Stream.Write(length); - m_Stream.Write(packBuffer, 0, packLength); + Stream.Write(4 + packLength); + Stream.Write(length); + Stream.Write(packBuffer, 0, packLength); ArrayPool.Shared.Return(packBuffer); } @@ -2472,16 +2476,16 @@ namespace Server.Network EnsureCapacity(4096); - m_Stream.Write(g.Serial); - m_Stream.Write(g.TypeID); - m_Stream.Write(g.X); - m_Stream.Write(g.Y); - m_Stream.Write((ushort)0xFFFF); + Stream.Write(g.Serial); + Stream.Write(g.TypeID); + Stream.Write(g.X); + Stream.Write(g.Y); + Stream.Write((ushort)0xFFFF); } - public int TextEntries{ get; set; } + public int TextEntries { get; set; } - public int Switches{ get; set; } + public int Switches { get; set; } public void AppendLayout(bool val) { @@ -2490,28 +2494,28 @@ namespace Server.Network public void AppendLayout(int val) { - string toString = val.ToString(); - int bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; + var toString = val.ToString(); + var bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; - m_Stream.Write(m_Buffer, 0, bytes); + Stream.Write(m_Buffer, 0, bytes); m_LayoutLength += bytes; } public void AppendLayout(uint val) { - string toString = val.ToString(); - int bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; + var toString = val.ToString(); + var bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1) + 1; - m_Stream.Write(m_Buffer, 0, bytes); + Stream.Write(m_Buffer, 0, bytes); m_LayoutLength += bytes; } public void AppendLayoutNS(int val) { - string toString = val.ToString(); - int bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1); + var toString = val.ToString(); + var bytes = Encoding.ASCII.GetBytes(toString, 0, toString.Length, m_Buffer, 1); - m_Stream.Write(m_Buffer, 1, bytes); + Stream.Write(m_Buffer, 1, bytes); m_LayoutLength += bytes; } @@ -2519,8 +2523,8 @@ namespace Server.Network { AppendLayout(m_BeginTextSeparator); - int length = text.Length; - m_Stream.WriteAsciiFixed(text, length); + var length = text.Length; + Stream.WriteAsciiFixed(text, length); m_LayoutLength += length; AppendLayout(m_EndTextSeparator); @@ -2528,27 +2532,27 @@ namespace Server.Network public void AppendLayout(byte[] buffer) { - int length = buffer.Length; - m_Stream.Write(buffer, 0, length); + var length = buffer.Length; + Stream.Write(buffer, 0, length); m_LayoutLength += length; } public void WriteStrings(List text) { - m_Stream.Seek(19, SeekOrigin.Begin); - m_Stream.Write((ushort)m_LayoutLength); - m_Stream.Seek(0, SeekOrigin.End); + Stream.Seek(19, SeekOrigin.Begin); + Stream.Write((ushort)m_LayoutLength); + Stream.Seek(0, SeekOrigin.End); - m_Stream.Write((ushort)text.Count); + Stream.Write((ushort)text.Count); - for (int i = 0; i < text.Count; ++i) + for (var i = 0; i < text.Count; ++i) { - string v = text[i] ?? ""; + var v = text[i] ?? ""; int length = (ushort)v.Length; - m_Stream.Write((ushort)length); - m_Stream.WriteBigUniFixed(v, length); + Stream.Write((ushort)length); + Stream.WriteBigUniFixed(v, length); } } @@ -2565,23 +2569,23 @@ namespace Server.Network EnsureCapacity(256); - m_Stream.Write(g.Serial); - m_Stream.Write(g.TypeID); - m_Stream.Write(g.X); - m_Stream.Write(g.Y); - m_Stream.Write((ushort)(layout.Length + 1)); - m_Stream.WriteAsciiNull(layout); + Stream.Write(g.Serial); + Stream.Write(g.TypeID); + Stream.Write(g.X); + Stream.Write(g.Y); + Stream.Write((ushort)(layout.Length + 1)); + Stream.WriteAsciiNull(layout); - m_Stream.Write((ushort)text.Length); + Stream.Write((ushort)text.Length); - for (int i = 0; i < text.Length; ++i) + for (var i = 0; i < text.Length; ++i) { - string v = text[i] ?? ""; + var v = text[i] ?? ""; - ushort length = (ushort)v.Length; + var length = (ushort)v.Length; - m_Stream.Write(length); - m_Stream.WriteBigUniFixed(v, length); + Stream.Write(length); + Stream.WriteBigUniFixed(v, length); } } } @@ -2598,9 +2602,9 @@ namespace Server.Network if (canLift) flags |= 0x02; - m_Stream.Write(m.Serial); - m_Stream.WriteAsciiFixed(text, 60); - m_Stream.Write(flags); + Stream.Write(m.Serial); + Stream.WriteAsciiFixed(text, 60); + Stream.Write(flags); } } @@ -2608,7 +2612,7 @@ namespace Server.Network { public PopupMessage(PMMessage msg) : base(0x53, 2) { - m_Stream.Write((byte)msg); + Stream.Write((byte)msg); } } @@ -2616,12 +2620,12 @@ namespace Server.Network { public PlaySound(int soundID, IPoint3D target) : base(0x54, 12) { - m_Stream.Write((byte)1); // flags - m_Stream.Write((short)soundID); - m_Stream.Write((short)0); // volume - m_Stream.Write((short)target.X); - m_Stream.Write((short)target.Y); - m_Stream.Write((short)target.Z); + Stream.Write((byte)1); // flags + Stream.Write((short)soundID); + Stream.Write((short)0); // volume + Stream.Write((short)target.X); + Stream.Write((short)target.Y); + Stream.Write((short)target.Z); } } @@ -2633,7 +2637,7 @@ namespace Server.Network public PlayMusic(MusicName name) : base(0x6D, 3) { - m_Stream.Write((short)name); + Stream.Write((short)name); } public static Packet GetInstance(MusicName name) @@ -2641,7 +2645,7 @@ namespace Server.Network if (name == MusicName.Invalid) return InvalidInstance; - int v = (int)name; + var v = (int)name; Packet p; if (v >= 0 && v < m_Instances.Length) @@ -2668,10 +2672,10 @@ namespace Server.Network EnsureCapacity(10 + text.Length); - m_Stream.Write((byte)type); - m_Stream.Write(tip); - m_Stream.Write((ushort)text.Length); - m_Stream.WriteAsciiFixed(text, text.Length); + Stream.Write((byte)type); + Stream.Write(tip); + Stream.Write((ushort)text.Length); + Stream.WriteAsciiFixed(text, text.Length); } } @@ -2679,11 +2683,11 @@ namespace Server.Network { public CurrentTime() : base(0x5B, 4) { - DateTime now = DateTime.UtcNow; + var now = DateTime.UtcNow; - m_Stream.Write((byte)now.Hour); - m_Stream.Write((byte)now.Minute); - m_Stream.Write((byte)now.Second); + Stream.Write((byte)now.Hour); + Stream.Write((byte)now.Minute); + Stream.Write((byte)now.Second); } } @@ -2693,8 +2697,8 @@ namespace Server.Network { EnsureCapacity(6); - m_Stream.Write((short)0x08); - m_Stream.Write((byte)(m.Map?.MapID ?? 0)); + Stream.Write((short)0x08); + Stream.Write((byte)(m.Map?.MapID ?? 0)); } } @@ -2711,8 +2715,8 @@ namespace Server.Network public SeasonChange(int season, bool playSound = true) : base(0xBC, 3) { - m_Stream.Write((byte)season); - m_Stream.Write(playSound); + Stream.Write((byte)season); + Stream.Write(playSound); } public static SeasonChange Instantiate(int season) => Instantiate(season, true); @@ -2721,9 +2725,9 @@ namespace Server.Network { if (season >= 0 && season < m_Cache.Length) { - int idx = playSound ? 1 : 0; + var idx = playSound ? 1 : 0; - SeasonChange p = m_Cache[season][idx]; + var p = m_Cache[season][idx]; if (p == null) { @@ -2742,7 +2746,7 @@ namespace Server.Network { public SupportedFeatures(NetState ns) : base(0xB9, ns.ExtendedSupportedFeatures ? 5 : 3) { - FeatureFlags flags = ExpansionInfo.CoreExpansion.SupportedFeatures; + var flags = ExpansionInfo.CoreExpansion.SupportedFeatures; flags |= Value; @@ -2758,21 +2762,21 @@ namespace Server.Network } if (ns.ExtendedSupportedFeatures) - m_Stream.Write((uint)flags); + Stream.Write((uint)flags); else - m_Stream.Write((ushort)flags); + Stream.Write((ushort)flags); } - public static FeatureFlags Value{ get; set; } + public static FeatureFlags Value { get; set; } public static SupportedFeatures Instantiate(NetState ns) => new SupportedFeatures(ns); } public static class AttributeNormalizer { - public static int Maximum{ get; set; } = 25; + public static int Maximum { get; set; } = 25; - public static bool Enabled{ get; set; } = true; + public static bool Enabled { get; set; } = true; public static void Write(PacketWriter stream, int cur, int max) { @@ -2807,9 +2811,9 @@ namespace Server.Network { public MobileHits(Mobile m) : base(0xA1, 9) { - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.HitsMax); - m_Stream.Write((short)m.Hits); + Stream.Write(m.Serial); + Stream.Write((short)m.HitsMax); + Stream.Write((short)m.Hits); } } @@ -2817,8 +2821,8 @@ namespace Server.Network { public MobileHitsN(Mobile m) : base(0xA1, 9) { - m_Stream.Write(m.Serial); - AttributeNormalizer.Write(m_Stream, m.Hits, m.HitsMax); + Stream.Write(m.Serial); + AttributeNormalizer.Write(Stream, m.Hits, m.HitsMax); } } @@ -2826,9 +2830,9 @@ namespace Server.Network { public MobileMana(Mobile m) : base(0xA2, 9) { - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.ManaMax); - m_Stream.Write((short)m.Mana); + Stream.Write(m.Serial); + Stream.Write((short)m.ManaMax); + Stream.Write((short)m.Mana); } } @@ -2836,8 +2840,8 @@ namespace Server.Network { public MobileManaN(Mobile m) : base(0xA2, 9) { - m_Stream.Write(m.Serial); - AttributeNormalizer.Write(m_Stream, m.Mana, m.ManaMax); + Stream.Write(m.Serial); + AttributeNormalizer.Write(Stream, m.Mana, m.ManaMax); } } @@ -2845,9 +2849,9 @@ namespace Server.Network { public MobileStam(Mobile m) : base(0xA3, 9) { - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.StamMax); - m_Stream.Write((short)m.Stam); + Stream.Write(m.Serial); + Stream.Write((short)m.StamMax); + Stream.Write((short)m.Stam); } } @@ -2855,8 +2859,8 @@ namespace Server.Network { public MobileStamN(Mobile m) : base(0xA3, 9) { - m_Stream.Write(m.Serial); - AttributeNormalizer.Write(m_Stream, m.Stam, m.StamMax); + Stream.Write(m.Serial); + AttributeNormalizer.Write(Stream, m.Stam, m.StamMax); } } @@ -2864,16 +2868,16 @@ namespace Server.Network { public MobileAttributes(Mobile m) : base(0x2D, 17) { - m_Stream.Write(m.Serial); + Stream.Write(m.Serial); - m_Stream.Write((short)m.HitsMax); - m_Stream.Write((short)m.Hits); + Stream.Write((short)m.HitsMax); + Stream.Write((short)m.Hits); - m_Stream.Write((short)m.ManaMax); - m_Stream.Write((short)m.Mana); + Stream.Write((short)m.ManaMax); + Stream.Write((short)m.Mana); - m_Stream.Write((short)m.StamMax); - m_Stream.Write((short)m.Stam); + Stream.Write((short)m.StamMax); + Stream.Write((short)m.Stam); } } @@ -2881,11 +2885,11 @@ namespace Server.Network { public MobileAttributesN(Mobile m) : base(0x2D, 17) { - m_Stream.Write(m.Serial); + Stream.Write(m.Serial); - AttributeNormalizer.Write(m_Stream, m.Hits, m.HitsMax); - AttributeNormalizer.Write(m_Stream, m.Mana, m.ManaMax); - AttributeNormalizer.Write(m_Stream, m.Stam, m.StamMax); + AttributeNormalizer.Write(Stream, m.Hits, m.HitsMax); + AttributeNormalizer.Write(Stream, m.Mana, m.ManaMax); + AttributeNormalizer.Write(Stream, m.Stam, m.StamMax); } } @@ -2893,9 +2897,9 @@ namespace Server.Network { public PathfindMessage(IPoint3D p) : base(0x38, 7) { - m_Stream.Write((short)p.X); - m_Stream.Write((short)p.Y); - m_Stream.Write((short)p.Z); + Stream.Write((short)p.X); + Stream.Write((short)p.Y); + Stream.Write((short)p.Z); } } @@ -2906,23 +2910,22 @@ namespace Server.Network { EnsureCapacity(37); - m_Stream.Write(m.Serial); - m_Stream.WriteAsciiFixed(m.Name ?? "", 30); + Stream.Write(m.Serial); + Stream.WriteAsciiFixed(m.Name ?? "", 30); } } public sealed class MobileAnimation : Packet { - public MobileAnimation(Mobile m, int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay) : - base(0x6E, 14) + public MobileAnimation(Mobile m, int action, int frameCount, int repeatCount, bool forward, bool repeat, int delay) : base(0x6E, 14) { - m_Stream.Write(m.Serial); - m_Stream.Write((short)action); - m_Stream.Write((short)frameCount); - m_Stream.Write((short)repeatCount); - m_Stream.Write(!forward); // protocol has really "reverse" but I find this more intuitive - m_Stream.Write(repeat); - m_Stream.Write((byte)delay); + Stream.Write(m.Serial); + Stream.Write((short)action); + Stream.Write((short)frameCount); + Stream.Write((short)repeatCount); + Stream.Write(!forward); // protocol has really "reverse" but I find this more intuitive + Stream.Write(repeat); + Stream.Write((byte)delay); } } @@ -2930,10 +2933,10 @@ namespace Server.Network { public NewMobileAnimation(Mobile m, int action, int frameCount, int delay) : base(0xE2, 10) { - m_Stream.Write(m.Serial); - m_Stream.Write((short)action); - m_Stream.Write((short)frameCount); - m_Stream.Write((byte)delay); + Stream.Write(m.Serial); + Stream.Write((short)action); + Stream.Write((short)frameCount); + Stream.Write((byte)delay); } } @@ -2943,14 +2946,14 @@ namespace Server.Network { EnsureCapacity(43); - m_Stream.Write(m.Serial); - m_Stream.WriteAsciiFixed(m.Name ?? "", 30); + Stream.Write(m.Serial); + Stream.WriteAsciiFixed(m.Name ?? "", 30); - AttributeNormalizer.WriteReverse(m_Stream, m.Hits, m.HitsMax); + AttributeNormalizer.WriteReverse(Stream, m.Hits, m.HitsMax); - m_Stream.Write(canBeRenamed); + Stream.Write(canBeRenamed); - m_Stream.Write((byte)0); // type + Stream.Write((byte)0); // type } } @@ -2962,7 +2965,7 @@ namespace Server.Network public MobileStatusExtended(Mobile m, NetState ns) : base(0x11) { - string name = m.Name ?? ""; + var name = m.Name ?? ""; int type; @@ -2982,71 +2985,71 @@ namespace Server.Network EnsureCapacity(88); } - m_Stream.Write(m.Serial); - m_Stream.WriteAsciiFixed(name, 30); + Stream.Write(m.Serial); + Stream.WriteAsciiFixed(name, 30); - m_Stream.Write((short)m.Hits); - m_Stream.Write((short)m.HitsMax); + Stream.Write((short)m.Hits); + Stream.Write((short)m.HitsMax); - m_Stream.Write(m.CanBeRenamedBy(m)); + Stream.Write(m.CanBeRenamedBy(m)); - m_Stream.Write((byte)type); + Stream.Write((byte)type); - m_Stream.Write(m.Female); + Stream.Write(m.Female); - m_Stream.Write((short)m.Str); - m_Stream.Write((short)m.Dex); - m_Stream.Write((short)m.Int); + Stream.Write((short)m.Str); + Stream.Write((short)m.Dex); + Stream.Write((short)m.Int); - m_Stream.Write((short)m.Stam); - m_Stream.Write((short)m.StamMax); + Stream.Write((short)m.Stam); + Stream.Write((short)m.StamMax); - m_Stream.Write((short)m.Mana); - m_Stream.Write((short)m.ManaMax); + Stream.Write((short)m.Mana); + Stream.Write((short)m.ManaMax); - m_Stream.Write(m.TotalGold); - m_Stream.Write((short)(Core.AOS ? m.PhysicalResistance : (int)(m.ArmorRating + 0.5))); - m_Stream.Write((short)(Mobile.BodyWeight + m.TotalWeight)); + Stream.Write(m.TotalGold); + Stream.Write((short)(Core.AOS ? m.PhysicalResistance : (int)(m.ArmorRating + 0.5))); + Stream.Write((short)(Mobile.BodyWeight + m.TotalWeight)); if (type >= 5) { - m_Stream.Write((short)m.MaxWeight); - m_Stream.Write((byte)(m.Race.RaceID + 1)); // Would be 0x00 if it's a non-ML enabled account but... + Stream.Write((short)m.MaxWeight); + Stream.Write((byte)(m.Race.RaceID + 1)); // Would be 0x00 if it's a non-ML enabled account but... } - m_Stream.Write((short)m.StatCap); + Stream.Write((short)m.StatCap); - m_Stream.Write((byte)m.Followers); - m_Stream.Write((byte)m.FollowersMax); + Stream.Write((byte)m.Followers); + Stream.Write((byte)m.FollowersMax); if (type >= 4) { - m_Stream.Write((short)m.FireResistance); // Fire - m_Stream.Write((short)m.ColdResistance); // Cold - m_Stream.Write((short)m.PoisonResistance); // Poison - m_Stream.Write((short)m.EnergyResistance); // Energy - m_Stream.Write((short)m.Luck); // Luck + Stream.Write((short)m.FireResistance); // Fire + Stream.Write((short)m.ColdResistance); // Cold + Stream.Write((short)m.PoisonResistance); // Poison + Stream.Write((short)m.EnergyResistance); // Energy + Stream.Write((short)m.Luck); // Luck - IWeapon weapon = m.Weapon; + var weapon = m.Weapon; if (weapon != null) { - weapon.GetStatusDamage(m, out int min, out int max); - m_Stream.Write((short)min); // Damage min - m_Stream.Write((short)max); // Damage max + weapon.GetStatusDamage(m, out var min, out var max); + Stream.Write((short)min); // Damage min + Stream.Write((short)max); // Damage max } else { - m_Stream.Write((short)0); // Damage min - m_Stream.Write((short)0); // Damage max + Stream.Write((short)0); // Damage min + Stream.Write((short)0); // Damage max } - m_Stream.Write(m.TithingPoints); + Stream.Write(m.TithingPoints); } if (type >= 6) - for (int i = 0; i < 15; ++i) - m_Stream.Write((short)m.GetAOSStatus(i)); + for (var i = 0; i < 15; ++i) + Stream.Write((short)m.GetAOSStatus(i)); } } @@ -3058,7 +3061,7 @@ namespace Server.Network public MobileStatus(Mobile beholder, Mobile beheld, NetState ns) : base(0x11) { - string name = beheld.Name ?? ""; + var name = beheld.Name ?? ""; int type; @@ -3083,85 +3086,85 @@ namespace Server.Network EnsureCapacity(88); } - m_Stream.Write(beheld.Serial); + Stream.Write(beheld.Serial); - m_Stream.WriteAsciiFixed(name, 30); + Stream.WriteAsciiFixed(name, 30); if (beholder == beheld) WriteAttr(beheld.Hits, beheld.HitsMax); else WriteAttrNorm(beheld.Hits, beheld.HitsMax); - m_Stream.Write(beheld.CanBeRenamedBy(beholder)); + Stream.Write(beheld.CanBeRenamedBy(beholder)); - m_Stream.Write((byte)type); + Stream.Write((byte)type); if (type <= 0) return; - m_Stream.Write(beheld.Female); + Stream.Write(beheld.Female); - m_Stream.Write((short)beheld.Str); - m_Stream.Write((short)beheld.Dex); - m_Stream.Write((short)beheld.Int); + Stream.Write((short)beheld.Str); + Stream.Write((short)beheld.Dex); + Stream.Write((short)beheld.Int); WriteAttr(beheld.Stam, beheld.StamMax); WriteAttr(beheld.Mana, beheld.ManaMax); - m_Stream.Write(beheld.TotalGold); - m_Stream.Write((short)(Core.AOS ? beheld.PhysicalResistance : (int)(beheld.ArmorRating + 0.5))); - m_Stream.Write((short)(Mobile.BodyWeight + beheld.TotalWeight)); + Stream.Write(beheld.TotalGold); + Stream.Write((short)(Core.AOS ? beheld.PhysicalResistance : (int)(beheld.ArmorRating + 0.5))); + Stream.Write((short)(Mobile.BodyWeight + beheld.TotalWeight)); if (type >= 5) { - m_Stream.Write((short)beheld.MaxWeight); - m_Stream.Write((byte)(beheld.Race.RaceID + 1)); // Would be 0x00 if it's a non-ML enabled account but... + Stream.Write((short)beheld.MaxWeight); + Stream.Write((byte)(beheld.Race.RaceID + 1)); // Would be 0x00 if it's a non-ML enabled account but... } - m_Stream.Write((short)beheld.StatCap); + Stream.Write((short)beheld.StatCap); - m_Stream.Write((byte)beheld.Followers); - m_Stream.Write((byte)beheld.FollowersMax); + Stream.Write((byte)beheld.Followers); + Stream.Write((byte)beheld.FollowersMax); if (type >= 4) { - m_Stream.Write((short)beheld.FireResistance); // Fire - m_Stream.Write((short)beheld.ColdResistance); // Cold - m_Stream.Write((short)beheld.PoisonResistance); // Poison - m_Stream.Write((short)beheld.EnergyResistance); // Energy - m_Stream.Write((short)beheld.Luck); // Luck + Stream.Write((short)beheld.FireResistance); // Fire + Stream.Write((short)beheld.ColdResistance); // Cold + Stream.Write((short)beheld.PoisonResistance); // Poison + Stream.Write((short)beheld.EnergyResistance); // Energy + Stream.Write((short)beheld.Luck); // Luck - IWeapon weapon = beheld.Weapon; + var weapon = beheld.Weapon; if (weapon != null) { - weapon.GetStatusDamage(beheld, out int min, out int max); - m_Stream.Write((short)min); // Damage min - m_Stream.Write((short)max); // Damage max + weapon.GetStatusDamage(beheld, out var min, out var max); + Stream.Write((short)min); // Damage min + Stream.Write((short)max); // Damage max } else { - m_Stream.Write((short)0); // Damage min - m_Stream.Write((short)0); // Damage max + Stream.Write((short)0); // Damage min + Stream.Write((short)0); // Damage max } - m_Stream.Write(beheld.TithingPoints); + Stream.Write(beheld.TithingPoints); } if (type >= 6) - for (int i = 0; i < 15; ++i) - m_Stream.Write((short)beheld.GetAOSStatus(i)); + for (var i = 0; i < 15; ++i) + Stream.Write((short)beheld.GetAOSStatus(i)); } private void WriteAttr(int current, int maximum) { - m_Stream.Write((short)current); - m_Stream.Write((short)maximum); + Stream.Write((short)current); + Stream.Write((short)maximum); } private void WriteAttrNorm(int current, int maximum) { - AttributeNormalizer.WriteReverse(m_Stream, current, maximum); + AttributeNormalizer.WriteReverse(Stream, current, maximum); } } @@ -3171,17 +3174,17 @@ namespace Server.Network { EnsureCapacity(12); - m_Stream.Write(m.Serial); - m_Stream.Write((short)1); + Stream.Write(m.Serial); + Stream.Write((short)1); - m_Stream.Write((short)1); + Stream.Write((short)1); - Poison p = m.Poison; + var p = m.Poison; if (p != null) - m_Stream.Write((byte)(p.Level + 1)); + Stream.Write((byte)(p.Level + 1)); else - m_Stream.Write((byte)0); + Stream.Write((byte)0); } } @@ -3191,15 +3194,15 @@ namespace Server.Network { EnsureCapacity(12); - m_Stream.Write(m.Serial); - m_Stream.Write((short)1); + Stream.Write(m.Serial); + Stream.Write((short)1); - m_Stream.Write((short)2); + Stream.Write((short)2); if (m.Blessed || m.YellowHealthbar) - m_Stream.Write((byte)1); + Stream.Write((byte)1); else - m_Stream.Write((byte)0); + Stream.Write((byte)0); } } @@ -3207,21 +3210,21 @@ namespace Server.Network { public MobileUpdate(Mobile m) : base(0x20, 19) { - int hue = m.Hue; + var hue = m.Hue; if (m.SolidHueOverride >= 0) hue = m.SolidHueOverride; - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.Body); - m_Stream.Write((byte)0); - m_Stream.Write((short)hue); - m_Stream.Write((byte)m.GetPacketFlags()); - m_Stream.Write((short)m.X); - m_Stream.Write((short)m.Y); - m_Stream.Write((short)0); - m_Stream.Write((byte)m.Direction); - m_Stream.Write((sbyte)m.Z); + Stream.Write(m.Serial); + Stream.Write((short)m.Body); + Stream.Write((byte)0); + Stream.Write((short)hue); + Stream.Write((byte)m.GetPacketFlags()); + Stream.Write((short)m.X); + Stream.Write((short)m.Y); + Stream.Write((short)0); + Stream.Write((byte)m.Direction); + Stream.Write((sbyte)m.Z); } } @@ -3230,21 +3233,21 @@ namespace Server.Network { public MobileUpdateOld(Mobile m) : base(0x20, 19) { - int hue = m.Hue; + var hue = m.Hue; if (m.SolidHueOverride >= 0) hue = m.SolidHueOverride; - m_Stream.Write(m.Serial); - m_Stream.Write((short)m.Body); - m_Stream.Write((byte)0); - m_Stream.Write((short)hue); - m_Stream.Write((byte)m.GetOldPacketFlags()); - m_Stream.Write((short)m.X); - m_Stream.Write((short)m.Y); - m_Stream.Write((short)0); - m_Stream.Write((byte)m.Direction); - m_Stream.Write((sbyte)m.Z); + Stream.Write(m.Serial); + Stream.Write((short)m.Body); + Stream.Write((byte)0); + Stream.Write((short)hue); + Stream.Write((byte)m.GetOldPacketFlags()); + Stream.Write((short)m.X); + Stream.Write((short)m.Y); + Stream.Write((short)0); + Stream.Write((byte)m.Direction); + Stream.Write((sbyte)m.Z); } } @@ -3253,17 +3256,13 @@ namespace Server.Network private static readonly ThreadLocal m_DupedLayersTL = new ThreadLocal(() => { return new int[256]; }); private static readonly ThreadLocal m_VersionTL = new ThreadLocal(); - public Mobile m_Beheld; - public MobileIncoming(Mobile beholder, Mobile beheld) : base(0x78) { - m_Beheld = beheld; + var m_Version = ++m_VersionTL.Value; + var m_DupedLayers = m_DupedLayersTL.Value; - int m_Version = ++m_VersionTL.Value; - int[] m_DupedLayers = m_DupedLayersTL.Value; - - List eq = beheld.Items; - int count = eq.Count; + var eq = beheld.Items; + var count = eq.Count; if (beheld.HairItemID > 0) count++; @@ -3272,26 +3271,26 @@ namespace Server.Network EnsureCapacity(23 + count * 9); - int hue = beheld.Hue; + var hue = beheld.Hue; if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - m_Stream.Write(beheld.Serial); - m_Stream.Write((short)beheld.Body); - m_Stream.Write((short)beheld.X); - m_Stream.Write((short)beheld.Y); - m_Stream.Write((sbyte)beheld.Z); - m_Stream.Write((byte)beheld.Direction); - m_Stream.Write((short)hue); - m_Stream.Write((byte)beheld.GetPacketFlags()); - m_Stream.Write((byte)Notoriety.Compute(beholder, beheld)); + Stream.Write(beheld.Serial); + Stream.Write((short)beheld.Body); + Stream.Write((short)beheld.X); + Stream.Write((short)beheld.Y); + Stream.Write((sbyte)beheld.Z); + Stream.Write((byte)beheld.Direction); + Stream.Write((short)hue); + Stream.Write((byte)beheld.GetPacketFlags()); + Stream.Write((byte)Notoriety.Compute(beholder, beheld)); - for (int i = 0; i < eq.Count; ++i) + for (var i = 0; i < eq.Count; ++i) { - Item item = eq[i]; + var item = eq[i]; - byte layer = (byte)item.Layer; + var layer = (byte)item.Layer; if (!item.Deleted && beholder.CanSee(item) && m_DupedLayers[layer] != m_Version) { @@ -3302,13 +3301,13 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = item.ItemID & 0xFFFF; + var itemID = item.ItemID & 0xFFFF; - m_Stream.Write(item.Serial); - m_Stream.Write((ushort)itemID); - m_Stream.Write(layer); + Stream.Write(item.Serial); + Stream.Write((ushort)itemID); + Stream.Write(layer); - m_Stream.Write((short)hue); + Stream.Write((short)hue); } } @@ -3321,13 +3320,13 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = beheld.HairItemID & 0xFFFF; + var itemID = beheld.HairItemID & 0xFFFF; - m_Stream.Write(HairInfo.FakeSerial(beheld)); - m_Stream.Write((ushort)itemID); - m_Stream.Write((byte)Layer.Hair); + Stream.Write(HairInfo.FakeSerial(beheld)); + Stream.Write((ushort)itemID); + Stream.Write((byte)Layer.Hair); - m_Stream.Write((short)hue); + Stream.Write((short)hue); } if (beheld.FacialHairItemID > 0) @@ -3339,16 +3338,16 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = beheld.FacialHairItemID & 0xFFFF; + var itemID = beheld.FacialHairItemID & 0xFFFF; - m_Stream.Write(FacialHairInfo.FakeSerial(beheld)); - m_Stream.Write((ushort)itemID); - m_Stream.Write((byte)Layer.FacialHair); + Stream.Write(FacialHairInfo.FakeSerial(beheld)); + Stream.Write((ushort)itemID); + Stream.Write((byte)Layer.FacialHair); - m_Stream.Write((short)hue); + Stream.Write((short)hue); } - m_Stream.Write(0); // terminate + Stream.Write(0); // terminate } public static Packet Create(NetState ns, Mobile beholder, Mobile beheld) @@ -3366,17 +3365,13 @@ namespace Server.Network private static readonly ThreadLocal m_DupedLayersTL = new ThreadLocal(() => { return new int[256]; }); private static readonly ThreadLocal m_VersionTL = new ThreadLocal(); - public Mobile m_Beheld; - public MobileIncomingSA(Mobile beholder, Mobile beheld) : base(0x78) { - m_Beheld = beheld; + var m_Version = ++m_VersionTL.Value; + var m_DupedLayers = m_DupedLayersTL.Value; - int m_Version = ++m_VersionTL.Value; - int[] m_DupedLayers = m_DupedLayersTL.Value; - - List eq = beheld.Items; - int count = eq.Count; + var eq = beheld.Items; + var count = eq.Count; if (beheld.HairItemID > 0) count++; @@ -3385,26 +3380,26 @@ namespace Server.Network EnsureCapacity(23 + count * 9); - int hue = beheld.Hue; + var hue = beheld.Hue; if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - m_Stream.Write(beheld.Serial); - m_Stream.Write((short)beheld.Body); - m_Stream.Write((short)beheld.X); - m_Stream.Write((short)beheld.Y); - m_Stream.Write((sbyte)beheld.Z); - m_Stream.Write((byte)beheld.Direction); - m_Stream.Write((short)hue); - m_Stream.Write((byte)beheld.GetPacketFlags()); - m_Stream.Write((byte)Notoriety.Compute(beholder, beheld)); + Stream.Write(beheld.Serial); + Stream.Write((short)beheld.Body); + Stream.Write((short)beheld.X); + Stream.Write((short)beheld.Y); + Stream.Write((sbyte)beheld.Z); + Stream.Write((byte)beheld.Direction); + Stream.Write((short)hue); + Stream.Write((byte)beheld.GetPacketFlags()); + Stream.Write((byte)Notoriety.Compute(beholder, beheld)); - for (int i = 0; i < eq.Count; ++i) + for (var i = 0; i < eq.Count; ++i) { - Item item = eq[i]; + var item = eq[i]; - byte layer = (byte)item.Layer; + var layer = (byte)item.Layer; if (!item.Deleted && beholder.CanSee(item) && m_DupedLayers[layer] != m_Version) { @@ -3415,18 +3410,18 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = item.ItemID & 0x7FFF; - bool writeHue = hue != 0; + var itemID = item.ItemID & 0x7FFF; + var writeHue = hue != 0; if (writeHue) itemID |= 0x8000; - m_Stream.Write(item.Serial); - m_Stream.Write((ushort)itemID); - m_Stream.Write(layer); + Stream.Write(item.Serial); + Stream.Write((ushort)itemID); + Stream.Write(layer); if (writeHue) - m_Stream.Write((short)hue); + Stream.Write((short)hue); } } @@ -3439,19 +3434,19 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = beheld.HairItemID & 0x7FFF; + var itemID = beheld.HairItemID & 0x7FFF; - bool writeHue = hue != 0; + var writeHue = hue != 0; if (writeHue) itemID |= 0x8000; - m_Stream.Write(HairInfo.FakeSerial(beheld)); - m_Stream.Write((ushort)itemID); - m_Stream.Write((byte)Layer.Hair); + Stream.Write(HairInfo.FakeSerial(beheld)); + Stream.Write((ushort)itemID); + Stream.Write((byte)Layer.Hair); if (writeHue) - m_Stream.Write((short)hue); + Stream.Write((short)hue); } if (beheld.FacialHairItemID > 0) @@ -3463,22 +3458,22 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = beheld.FacialHairItemID & 0x7FFF; + var itemID = beheld.FacialHairItemID & 0x7FFF; - bool writeHue = hue != 0; + var writeHue = hue != 0; if (writeHue) itemID |= 0x8000; - m_Stream.Write(FacialHairInfo.FakeSerial(beheld)); - m_Stream.Write((ushort)itemID); - m_Stream.Write((byte)Layer.FacialHair); + Stream.Write(FacialHairInfo.FakeSerial(beheld)); + Stream.Write((ushort)itemID); + Stream.Write((byte)Layer.FacialHair); if (writeHue) - m_Stream.Write((short)hue); + Stream.Write((short)hue); } - m_Stream.Write(0); // terminate + Stream.Write(0); // terminate } } @@ -3488,17 +3483,13 @@ namespace Server.Network private static readonly ThreadLocal m_DupedLayersTL = new ThreadLocal(() => { return new int[256]; }); private static readonly ThreadLocal m_VersionTL = new ThreadLocal(); - public Mobile m_Beheld; - public MobileIncomingOld(Mobile beholder, Mobile beheld) : base(0x78) { - m_Beheld = beheld; + var m_Version = ++m_VersionTL.Value; + var m_DupedLayers = m_DupedLayersTL.Value; - int m_Version = ++m_VersionTL.Value; - int[] m_DupedLayers = m_DupedLayersTL.Value; - - List eq = beheld.Items; - int count = eq.Count; + var eq = beheld.Items; + var count = eq.Count; if (beheld.HairItemID > 0) count++; @@ -3507,26 +3498,26 @@ namespace Server.Network EnsureCapacity(23 + count * 9); - int hue = beheld.Hue; + var hue = beheld.Hue; if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - m_Stream.Write(beheld.Serial); - m_Stream.Write((short)beheld.Body); - m_Stream.Write((short)beheld.X); - m_Stream.Write((short)beheld.Y); - m_Stream.Write((sbyte)beheld.Z); - m_Stream.Write((byte)beheld.Direction); - m_Stream.Write((short)hue); - m_Stream.Write((byte)beheld.GetOldPacketFlags()); - m_Stream.Write((byte)Notoriety.Compute(beholder, beheld)); + Stream.Write(beheld.Serial); + Stream.Write((short)beheld.Body); + Stream.Write((short)beheld.X); + Stream.Write((short)beheld.Y); + Stream.Write((sbyte)beheld.Z); + Stream.Write((byte)beheld.Direction); + Stream.Write((short)hue); + Stream.Write((byte)beheld.GetOldPacketFlags()); + Stream.Write((byte)Notoriety.Compute(beholder, beheld)); - for (int i = 0; i < eq.Count; ++i) + for (var i = 0; i < eq.Count; ++i) { - Item item = eq[i]; + var item = eq[i]; - byte layer = (byte)item.Layer; + var layer = (byte)item.Layer; if (!item.Deleted && beholder.CanSee(item) && m_DupedLayers[layer] != m_Version) { @@ -3537,18 +3528,18 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = item.ItemID & 0x7FFF; - bool writeHue = hue != 0; + var itemID = item.ItemID & 0x7FFF; + var writeHue = hue != 0; if (writeHue) itemID |= 0x8000; - m_Stream.Write(item.Serial); - m_Stream.Write((ushort)itemID); - m_Stream.Write(layer); + Stream.Write(item.Serial); + Stream.Write((ushort)itemID); + Stream.Write(layer); if (writeHue) - m_Stream.Write((short)hue); + Stream.Write((short)hue); } } @@ -3561,19 +3552,19 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = beheld.HairItemID & 0x7FFF; + var itemID = beheld.HairItemID & 0x7FFF; - bool writeHue = hue != 0; + var writeHue = hue != 0; if (writeHue) itemID |= 0x8000; - m_Stream.Write(HairInfo.FakeSerial(beheld)); - m_Stream.Write((ushort)itemID); - m_Stream.Write((byte)Layer.Hair); + Stream.Write(HairInfo.FakeSerial(beheld)); + Stream.Write((ushort)itemID); + Stream.Write((byte)Layer.Hair); if (writeHue) - m_Stream.Write((short)hue); + Stream.Write((short)hue); } if (beheld.FacialHairItemID > 0) @@ -3585,29 +3576,28 @@ namespace Server.Network if (beheld.SolidHueOverride >= 0) hue = beheld.SolidHueOverride; - int itemID = beheld.FacialHairItemID & 0x7FFF; + var itemID = beheld.FacialHairItemID & 0x7FFF; - bool writeHue = hue != 0; + var writeHue = hue != 0; if (writeHue) itemID |= 0x8000; - m_Stream.Write(FacialHairInfo.FakeSerial(beheld)); - m_Stream.Write((ushort)itemID); - m_Stream.Write((byte)Layer.FacialHair); + Stream.Write(FacialHairInfo.FakeSerial(beheld)); + Stream.Write((ushort)itemID); + Stream.Write((byte)Layer.FacialHair); if (writeHue) - m_Stream.Write((short)hue); + Stream.Write((short)hue); } - m_Stream.Write(0); // terminate + Stream.Write(0); // terminate } } public sealed class AsciiMessage : Packet { - public AsciiMessage(Serial serial, int graphic, MessageType type, int hue, int font, string name, string text) : - base(0x1C) + public AsciiMessage(Serial serial, int graphic, MessageType type, int hue, int font, string name, string text) : base(0x1C) { name ??= ""; text ??= ""; @@ -3617,13 +3607,13 @@ namespace Server.Network EnsureCapacity(45 + text.Length); - m_Stream.Write(serial); - m_Stream.Write((short)graphic); - m_Stream.Write((byte)type); - m_Stream.Write((short)hue); - m_Stream.Write((short)font); - m_Stream.WriteAsciiFixed(name, 30); - m_Stream.WriteAsciiNull(text); + Stream.Write(serial); + Stream.Write((short)graphic); + Stream.Write((byte)type); + Stream.Write((short)hue); + Stream.Write((short)font); + Stream.WriteAsciiFixed(name, 30); + Stream.WriteAsciiNull(text); } } @@ -3641,14 +3631,14 @@ namespace Server.Network EnsureCapacity(50 + text.Length * 2); - m_Stream.Write(serial); - m_Stream.Write((short)graphic); - m_Stream.Write((byte)type); - m_Stream.Write((short)hue); - m_Stream.Write((short)font); - m_Stream.WriteAsciiFixed(lang, 4); - m_Stream.WriteAsciiFixed(name, 30); - m_Stream.WriteBigUniNull(text); + Stream.Write(serial); + Stream.Write((short)graphic); + Stream.Write((byte)type); + Stream.Write((short)hue); + Stream.Write((short)font); + Stream.WriteAsciiFixed(lang, 4); + Stream.WriteAsciiFixed(name, 30); + Stream.WriteBigUniNull(text); } } @@ -3658,12 +3648,12 @@ namespace Server.Network public PingAck(byte ping) : base(0x73, 2) { - m_Stream.Write(ping); + Stream.Write(ping); } public static PingAck Instantiate(byte ping) { - PingAck p = m_Cache[ping]; + var p = m_Cache[ping]; if (p == null) { @@ -3679,11 +3669,11 @@ namespace Server.Network { public MovementRej(int seq, Mobile m) : base(0x21, 8) { - m_Stream.Write((byte)seq); - m_Stream.Write((short)m.X); - m_Stream.Write((short)m.Y); - m_Stream.Write((byte)m.Direction); - m_Stream.Write((sbyte)m.Z); + Stream.Write((byte)seq); + Stream.Write((short)m.X); + Stream.Write((short)m.Y); + Stream.Write((byte)m.Direction); + Stream.Write((sbyte)m.Z); } } @@ -3693,15 +3683,15 @@ namespace Server.Network private MovementAck(int seq, int noto) : base(0x22, 3) { - m_Stream.Write((byte)seq); - m_Stream.Write((byte)noto); + Stream.Write((byte)seq); + Stream.Write((byte)noto); } public static MovementAck Instantiate(int seq, Mobile m) { - int noto = Notoriety.Compute(m, m); + var noto = Notoriety.Compute(m, m); - MovementAck p = m_Cache[noto * seq]; + var p = m_Cache[noto * seq]; if (p == null) { @@ -3717,27 +3707,27 @@ namespace Server.Network { public LoginConfirm(Mobile m) : base(0x1B, 37) { - m_Stream.Write(m.Serial); - m_Stream.Write(0); - m_Stream.Write((short)m.Body); - m_Stream.Write((short)m.X); - m_Stream.Write((short)m.Y); - m_Stream.Write((short)m.Z); - m_Stream.Write((byte)m.Direction); - m_Stream.Write((byte)0); - m_Stream.Write(-1); + Stream.Write(m.Serial); + Stream.Write(0); + Stream.Write((short)m.Body); + Stream.Write((short)m.X); + Stream.Write((short)m.Y); + Stream.Write((short)m.Z); + Stream.Write((byte)m.Direction); + Stream.Write((byte)0); + Stream.Write(-1); - Map map = m.Map; + var map = m.Map; if (map == null || map == Map.Internal) map = m.LogoutMap; - m_Stream.Write((short)0); - m_Stream.Write((short)0); - m_Stream.Write((short)(map?.Width ?? 6144)); - m_Stream.Write((short)(map?.Height ?? 4096)); + Stream.Write((short)0); + Stream.Write((short)0); + Stream.Write((short)(map?.Width ?? 6144)); + Stream.Write((short)(map?.Height ?? 4096)); - m_Stream.Fill(); + Stream.Fill(); } } @@ -3756,28 +3746,28 @@ namespace Server.Network { EnsureCapacity(4 + a.Length * 60); - int highSlot = -1; + var highSlot = -1; - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) if (a[i] != null) highSlot = i; - int count = Math.Max(Math.Max(highSlot + 1, a.Limit), 5); + var count = Math.Max(Math.Max(highSlot + 1, a.Limit), 5); - m_Stream.Write((byte)count); + Stream.Write((byte)count); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - Mobile m = a[i]; + var m = a[i]; if (m != null) { - m_Stream.WriteAsciiFixed(m.Name, 30); - m_Stream.Fill(30); // password + Stream.WriteAsciiFixed(m.Name, 30); + Stream.Fill(30); // password } else { - m_Stream.Fill(60); + Stream.Fill(60); } } } @@ -3826,7 +3816,7 @@ namespace Server.Network public static class FeatureProtection { - public static ThirdPartyFeature DisabledFeatures{ get; private set; } = 0; + public static ThirdPartyFeature DisabledFeatures { get; private set; } = 0; public static void Disable(ThirdPartyFeature feature) { @@ -3849,51 +3839,51 @@ namespace Server.Network public sealed class CharacterList : Packet { - //private static MD5CryptoServiceProvider m_MD5Provider; + // private static MD5CryptoServiceProvider m_MD5Provider; public CharacterList(IAccount a, CityInfo[] info) : base(0xA9) { EnsureCapacity(11 + a.Length * 60 + info.Length * 89); - int highSlot = -1; + var highSlot = -1; - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) if (a[i] != null) highSlot = i; - int count = Math.Max(Math.Max(highSlot + 1, a.Limit), 5); + var count = Math.Max(Math.Max(highSlot + 1, a.Limit), 5); - m_Stream.Write((byte)count); + Stream.Write((byte)count); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (a[i] != null) { - m_Stream.WriteAsciiFixed(a[i].Name, 30); - m_Stream.Fill(30); // password + Stream.WriteAsciiFixed(a[i].Name, 30); + Stream.Fill(30); // password } else { - m_Stream.Fill(60); + Stream.Fill(60); } - m_Stream.Write((byte)info.Length); + Stream.Write((byte)info.Length); - for (int i = 0; i < info.Length; ++i) + for (var i = 0; i < info.Length; ++i) { - CityInfo ci = info[i]; + var ci = info[i]; - m_Stream.Write((byte)i); - m_Stream.WriteAsciiFixed(ci.City, 32); - m_Stream.WriteAsciiFixed(ci.Building, 32); - m_Stream.Write(ci.X); - m_Stream.Write(ci.Y); - m_Stream.Write(ci.Z); - m_Stream.Write(ci.Map.MapID); - m_Stream.Write(ci.Description); - m_Stream.Write(0); + Stream.Write((byte)i); + Stream.WriteAsciiFixed(ci.City, 32); + Stream.WriteAsciiFixed(ci.Building, 32); + Stream.Write(ci.X); + Stream.Write(ci.Y); + Stream.Write(ci.Z); + Stream.Write(ci.Map.MapID); + Stream.Write(ci.Description); + Stream.Write(0); } - CharacterListFlags flags = ExpansionInfo.CoreExpansion.CharacterListFlags; + var flags = ExpansionInfo.CoreExpansion.CharacterListFlags; if (count > 6) flags |= CharacterListFlags.SeventhCharacterSlot | @@ -3904,9 +3894,9 @@ namespace Server.Network flags |= CharacterListFlags.SlotLimit & CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character - m_Stream.Write((int)(flags | AdditionalFlags)); // Additional Flags + Stream.Write((int)(flags | AdditionalFlags)); // Additional Flags - m_Stream.Write((short)-1); + Stream.Write((short)-1); /*ThirdPartyFeature disabled = FeatureProtection.DisabledFeatures; @@ -3938,7 +3928,7 @@ namespace Server.Network }*/ } - public static CharacterListFlags AdditionalFlags{ get; set; } + public static CharacterListFlags AdditionalFlags { get; set; } } public sealed class CharacterListOld : Packet @@ -3949,39 +3939,39 @@ namespace Server.Network { EnsureCapacity(9 + a.Length * 60 + info.Length * 63); - int highSlot = -1; + var highSlot = -1; - for (int i = 0; i < a.Length; ++i) + for (var i = 0; i < a.Length; ++i) if (a[i] != null) highSlot = i; - int count = Math.Max(Math.Max(highSlot + 1, a.Limit), 5); + var count = Math.Max(Math.Max(highSlot + 1, a.Limit), 5); - m_Stream.Write((byte)count); + Stream.Write((byte)count); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (a[i] != null) { - m_Stream.WriteAsciiFixed(a[i].Name, 30); - m_Stream.Fill(30); // password + Stream.WriteAsciiFixed(a[i].Name, 30); + Stream.Fill(30); // password } else { - m_Stream.Fill(60); + Stream.Fill(60); } - m_Stream.Write((byte)info.Length); + Stream.Write((byte)info.Length); - for (int i = 0; i < info.Length; ++i) + for (var i = 0; i < info.Length; ++i) { - CityInfo ci = info[i]; + var ci = info[i]; - m_Stream.Write((byte)i); - m_Stream.WriteAsciiFixed(ci.City, 31); - m_Stream.WriteAsciiFixed(ci.Building, 31); + Stream.Write((byte)i); + Stream.WriteAsciiFixed(ci.City, 31); + Stream.WriteAsciiFixed(ci.Building, 31); } - CharacterListFlags flags = ExpansionInfo.CoreExpansion.CharacterListFlags; + var flags = ExpansionInfo.CoreExpansion.CharacterListFlags; if (count > 6) flags |= CharacterListFlags.SeventhCharacterSlot | @@ -3992,7 +3982,7 @@ namespace Server.Network flags |= CharacterListFlags.SlotLimit & CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character - m_Stream.Write((int)(flags | CharacterList.AdditionalFlags)); // Additional Flags + Stream.Write((int)(flags | CharacterList.AdditionalFlags)); // Additional Flags } } @@ -4004,7 +3994,7 @@ namespace Server.Network { EnsureCapacity(5); - m_Stream.Write((short)0x21); + Stream.Write((short)0x21); } } @@ -4022,7 +4012,7 @@ namespace Server.Network { public AccountLoginRej(ALRReason reason) : base(0x82, 2) { - m_Stream.Write((byte)reason); + Stream.Write((byte)reason); } } @@ -4048,16 +4038,16 @@ namespace Server.Network EnsureCapacity(52 + affix.Length + args.Length * 2); - m_Stream.Write(serial); - m_Stream.Write((short)graphic); - m_Stream.Write((byte)messageType); - m_Stream.Write((short)hue); - m_Stream.Write((short)font); - m_Stream.Write(number); - m_Stream.Write((byte)affixType); - m_Stream.WriteAsciiFixed(name, 30); - m_Stream.WriteAsciiNull(affix); - m_Stream.WriteBigUniNull(args); + Stream.Write(serial); + Stream.Write((short)graphic); + Stream.Write((byte)messageType); + Stream.Write((short)hue); + Stream.Write((short)font); + Stream.Write(number); + Stream.Write((byte)affixType); + Stream.WriteAsciiFixed(name, 30); + Stream.WriteAsciiNull(affix); + Stream.WriteBigUniNull(args); } } @@ -4071,21 +4061,21 @@ namespace Server.Network Address = address; } - public string Name{ get; set; } + public string Name { get; set; } - public int FullPercent{ get; set; } + public int FullPercent { get; set; } - public int TimeZone{ get; set; } + public int TimeZone { get; set; } - public IPEndPoint Address{ get; set; } + public IPEndPoint Address { get; set; } } public sealed class FollowMessage : Packet { public FollowMessage(Serial serial1, Serial serial2) : base(0x15, 9) { - m_Stream.Write(serial1); - m_Stream.Write(serial2); + Stream.Write(serial1); + Stream.Write(serial2); } } @@ -4095,19 +4085,19 @@ namespace Server.Network { EnsureCapacity(6 + info.Length * 40); - m_Stream.Write((byte)0x5D); // Unknown + Stream.Write((byte)0x5D); // Unknown - m_Stream.Write((ushort)info.Length); + Stream.Write((ushort)info.Length); - for (int i = 0; i < info.Length; ++i) + for (var i = 0; i < info.Length; ++i) { - ServerInfo si = info[i]; + var si = info[i]; - m_Stream.Write((ushort)i); - m_Stream.WriteAsciiFixed(si.Name, 32); - m_Stream.Write((byte)si.FullPercent); - m_Stream.Write((sbyte)si.TimeZone); - m_Stream.Write(Utility.GetAddressValue(si.Address.Address)); + Stream.Write((ushort)i); + Stream.WriteAsciiFixed(si.Name, 32); + Stream.Write((byte)si.FullPercent); + Stream.Write((sbyte)si.TimeZone); + Stream.Write(Utility.GetAddressValue(si.Address.Address)); } } } @@ -4121,12 +4111,12 @@ namespace Server.Network EnsureCapacity(16 + unknown.Length + caption.Length); - m_Stream.Write(serial); - m_Stream.Write((short)gumpID); - m_Stream.Write((short)unknown.Length); - m_Stream.WriteAsciiFixed(unknown, unknown.Length); - m_Stream.Write((short)(caption.Length + 1)); - m_Stream.WriteAsciiFixed(caption, caption.Length + 1); + Stream.Write(serial); + Stream.Write((short)gumpID); + Stream.Write((short)unknown.Length); + Stream.WriteAsciiFixed(unknown, unknown.Length); + Stream.Write((short)(caption.Length + 1)); + Stream.WriteAsciiFixed(caption, caption.Length + 1); } } @@ -4136,15 +4126,15 @@ namespace Server.Network public PlayServerAck(ServerInfo si) : base(0x8C, 11) { - int addr = Utility.GetAddressValue(si.Address.Address); + var addr = Utility.GetAddressValue(si.Address.Address); - m_Stream.Write((byte)addr); - m_Stream.Write((byte)(addr >> 8)); - m_Stream.Write((byte)(addr >> 16)); - m_Stream.Write((byte)(addr >> 24)); + Stream.Write((byte)addr); + Stream.Write((byte)(addr >> 8)); + Stream.Write((byte)(addr >> 16)); + Stream.Write((byte)(addr >> 24)); - m_Stream.Write((short)si.Address.Port); - m_Stream.Write(m_AuthID); + Stream.Write((short)si.Address.Port); + Stream.Write(m_AuthID); } } } diff --git a/Projects/Server/Network/ServerConnectionHandler.cs b/Projects/Server/Network/ServerConnectionHandler.cs index ed2137de9..8e4b3c26d 100644 --- a/Projects/Server/Network/ServerConnectionHandler.cs +++ b/Projects/Server/Network/ServerConnectionHandler.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: ServerConnectionHandler.cs * * Created: 2020/04/12 - Updated: 2020/04/12 * @@ -20,8 +20,6 @@ *************************************************************************/ using System; -using System.Buffers; -using System.IO.Pipelines; using System.Threading.Tasks; using Microsoft.AspNetCore.Connections; using Microsoft.Extensions.Logging; @@ -35,8 +33,7 @@ namespace Server.Network public ServerConnectionHandler( IMessagePumpService messagePumpService, - ILogger logger - ) + ILogger logger) { _messagePumpService = messagePumpService; _logger = logger; @@ -50,13 +47,13 @@ namespace Server.Network return; } - NetState ns = new NetState(connection); + var ns = new NetState(connection); TcpServer.Instances.Add(ns); _logger.LogInformation($"Client: {ns}: Connected. [{TcpServer.Instances.Count} Online]"); connection.ConnectionClosed.Register(() => { TcpServer.Instances.Remove(ns); }); - await ProcessIncoming(ns); + await ProcessIncoming(ns).ConfigureAwait(false); } private async Task ProcessIncoming(NetState ns) @@ -70,16 +67,16 @@ namespace Server.Network try { - ReadResult result = await inPipe.ReadAsync(); + var result = await inPipe.ReadAsync(); if (result.IsCanceled || result.IsCompleted) return; - ReadOnlySequence seq = result.Buffer; + var seq = result.Buffer; if (seq.IsEmpty) break; - int pos = PacketHandlers.ProcessPacket(_messagePumpService, ns, seq); + var pos = PacketHandlers.ProcessPacket(_messagePumpService, ns, seq); if (pos <= 0) break; @@ -99,7 +96,7 @@ namespace Server.Network { try { - SocketConnectEventArgs args = new SocketConnectEventArgs(connection); + var args = new SocketConnectEventArgs(connection); EventSink.InvokeSocketConnect(args); diff --git a/Projects/Server/Network/ServerStartup.cs b/Projects/Server/Network/ServerStartup.cs index 37e3797df..56a35c268 100644 --- a/Projects/Server/Network/ServerStartup.cs +++ b/Projects/Server/Network/ServerStartup.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: ServerStartup.cs * * Created: 2020/04/12 - Updated: 2020/04/12 * diff --git a/Projects/Server/Network/StaticPacketHandlers.cs b/Projects/Server/Network/StaticPacketHandlers.cs index 259647f95..cf3175e3f 100644 --- a/Projects/Server/Network/StaticPacketHandlers.cs +++ b/Projects/Server/Network/StaticPacketHandlers.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: StaticPacketHandlers.cs * * Created: 2019/03/15 - Updated: 2019/12/24 * @@ -25,18 +25,26 @@ namespace Server.Network { public static class StaticPacketHandlers { - private static readonly ConcurrentDictionary OPLInfoPackets = new ConcurrentDictionary(); - private static readonly ConcurrentDictionary RemoveEntityPackets = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary OPLInfoPackets = + new ConcurrentDictionary(); - private static readonly ConcurrentDictionary WorldItemPackets = new ConcurrentDictionary(); - private static readonly ConcurrentDictionary WorldItemSAPackets = new ConcurrentDictionary(); - private static readonly ConcurrentDictionary WorldItemHSPackets = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary RemoveEntityPackets = + new ConcurrentDictionary(); + + private static readonly ConcurrentDictionary WorldItemPackets = + new ConcurrentDictionary(); + + private static readonly ConcurrentDictionary WorldItemSAPackets = + new ConcurrentDictionary(); + + private static readonly ConcurrentDictionary WorldItemHSPackets = + new ConcurrentDictionary(); public static OPLInfo GetOPLInfoPacket(IPropertyListObject obj) { return OPLInfoPackets.GetOrAdd(obj, value => { - OPLInfo packet = new OPLInfo(value.PropertyList.Entity.Serial, value.PropertyList.Hash); + var packet = new OPLInfo(value.PropertyList.Entity.Serial, value.PropertyList.Hash); packet.SetStatic(); return packet; }); @@ -44,7 +52,7 @@ namespace Server.Network public static OPLInfo FreeOPLInfoPacket(IPropertyListObject obj) { - if (OPLInfoPackets.TryRemove(obj, out OPLInfo p)) + if (OPLInfoPackets.TryRemove(obj, out var p)) Packet.Release(p); return p; @@ -54,7 +62,7 @@ namespace Server.Network { return RemoveEntityPackets.GetOrAdd(entity, value => { - RemoveEntity packet = new RemoveEntity(value); + var packet = new RemoveEntity(value); packet.SetStatic(); return packet; }); @@ -62,7 +70,7 @@ namespace Server.Network public static void FreeRemoveItemPacket(IEntity entity) { - if (RemoveEntityPackets.TryRemove(entity, out RemoveEntity p)) + if (RemoveEntityPackets.TryRemove(entity, out var p)) Packet.Release(p); } @@ -70,7 +78,7 @@ namespace Server.Network { return WorldItemPackets.GetOrAdd(item, value => { - WorldItem packet = new WorldItem(value); + var packet = new WorldItem(value); packet.SetStatic(); return packet; }); @@ -80,7 +88,7 @@ namespace Server.Network { return WorldItemSAPackets.GetOrAdd(item, value => { - WorldItemSA packet = new WorldItemSA(value); + var packet = new WorldItemSA(value); packet.SetStatic(); return packet; }); @@ -90,7 +98,7 @@ namespace Server.Network { return WorldItemHSPackets.GetOrAdd(item, value => { - WorldItemHS packet = new WorldItemHS(value); + var packet = new WorldItemHS(value); packet.SetStatic(); return packet; }); @@ -98,13 +106,13 @@ namespace Server.Network public static void FreeWorldItemPackets(Item item) { - if (WorldItemPackets.TryRemove(item, out WorldItem wi)) + if (WorldItemPackets.TryRemove(item, out var wi)) Packet.Release(wi); - if (WorldItemSAPackets.TryRemove(item, out WorldItemSA wisa)) + if (WorldItemSAPackets.TryRemove(item, out var wisa)) Packet.Release(wisa); - if (WorldItemHSPackets.TryRemove(item, out WorldItemHS wihs)) + if (WorldItemHSPackets.TryRemove(item, out var wihs)) Packet.Release(wihs); } } diff --git a/Projects/Server/Network/TcpServer.cs b/Projects/Server/Network/TcpServer.cs index 7353a589b..a21067603 100644 --- a/Projects/Server/Network/TcpServer.cs +++ b/Projects/Server/Network/TcpServer.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: TcpServer.cs * * Created: 2020/04/12 - Updated: 2020/04/12 * @@ -30,19 +30,17 @@ using Microsoft.Extensions.DependencyInjection; namespace Server.Network { - public class TcpServer + public static class TcpServer { public static List Listeners { get; } = new List(); + // Make this thread safe public static List Instances { get; } = new List(); - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + public static IWebHostBuilder CreateWebHostBuilder(string[] args = null) => WebHost.CreateDefaultBuilder(args) .UseSetting(WebHostDefaults.SuppressStatusMessagesKey, "True") - .ConfigureServices(services => - { - services.AddSingleton(new MessagePumpService()); - }) + .ConfigureServices(services => { services.AddSingleton(new MessagePumpService()); }) .UseKestrel(options => { foreach (var ipep in Listeners) @@ -60,17 +58,19 @@ namespace Server.Network { if (ipep.Address.Equals(IPAddress.Any) || ipep.Address.Equals(IPAddress.IPv6Any)) { - NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces(); - foreach (NetworkInterface adapter in adapters) + var adapters = NetworkInterface.GetAllNetworkInterfaces(); + foreach (var adapter in adapters) { - IPInterfaceProperties properties = adapter.GetIPProperties(); - foreach (UnicastIPAddressInformation unicast in properties.UnicastAddresses) + var properties = adapter.GetIPProperties(); + foreach (var unicast in properties.UnicastAddresses) if (ipep.AddressFamily == unicast.Address.AddressFamily) Console.WriteLine("Listening: {0}:{1}", unicast.Address, ipep.Port); } } else + { Console.WriteLine("Listening: {0}:{1}", ipep.Address, ipep.Port); + } } } } diff --git a/Projects/Server/Notoriety.cs b/Projects/Server/Notoriety.cs index 32499bf23..6569da11a 100644 --- a/Projects/Server/Notoriety.cs +++ b/Projects/Server/Notoriety.cs @@ -32,9 +32,9 @@ namespace Server public const int Murderer = 6; public const int Invulnerable = 7; - public static NotorietyHandler Handler{ get; set; } + public static NotorietyHandler Handler { get; set; } - public static int[] Hues{ get; set; } = + public static int[] Hues { get; set; } = { 0x000, 0x059, diff --git a/Projects/Server/ObjectPropertyList.cs b/Projects/Server/ObjectPropertyList.cs index b89da34a8..3aba129da 100644 --- a/Projects/Server/ObjectPropertyList.cs +++ b/Projects/Server/ObjectPropertyList.cs @@ -27,7 +27,7 @@ namespace Server public interface IPropertyListObject : IEntity { ObjectPropertyList PropertyList { get; } - OPLInfo OPLPacket { get; } + OPLInfo OPLPacket { get; } void GetProperties(ObjectPropertyList list); } @@ -53,22 +53,22 @@ namespace Server Entity = e; - m_Stream.Write((short)1); - m_Stream.Write(e.Serial); - m_Stream.Write((byte)0); - m_Stream.Write((byte)0); - m_Stream.Write(e.Serial); + Stream.Write((short)1); + Stream.Write(e.Serial); + Stream.Write((byte)0); + Stream.Write((byte)0); + Stream.Write(e.Serial); } - public IEntity Entity{ get; } + public IEntity Entity { get; } public int Hash => 0x40000000 + m_Hash; - public int Header{ get; set; } + public int Header { get; set; } - public string HeaderArgs{ get; set; } + public string HeaderArgs { get; set; } - public static bool Enabled{ get; set; } + public static bool Enabled { get; set; } public void Add(int number) { @@ -83,22 +83,22 @@ namespace Server HeaderArgs = ""; } - m_Stream.Write(number); - m_Stream.Write((short)0); + Stream.Write(number); + Stream.Write((short)0); } public void Terminate() { - m_Stream.Write(0); + Stream.Write(0); - m_Stream.Seek(11, SeekOrigin.Begin); - m_Stream.Write(m_Hash); + Stream.Seek(11, SeekOrigin.Begin); + Stream.Write(m_Hash); } public void AddHash(int val) { m_Hash ^= val & 0x3FFFFFF; - m_Hash ^= val >> 26 & 0x3F; + m_Hash ^= (val >> 26) & 0x3F; } public void Add(int number, string arguments) @@ -117,17 +117,17 @@ namespace Server AddHash(number); AddHash(arguments.GetHashCode()); - m_Stream.Write(number); + Stream.Write(number); - int byteCount = m_Encoding.GetByteCount(arguments); + var byteCount = m_Encoding.GetByteCount(arguments); if (byteCount > m_Buffer.Length) m_Buffer = new byte[byteCount]; byteCount = m_Encoding.GetBytes(arguments, 0, arguments.Length, m_Buffer, 0); - m_Stream.Write((short)byteCount); - m_Stream.Write(m_Buffer, 0, byteCount); + Stream.Write((short)byteCount); + Stream.Write(m_Buffer, 0, byteCount); } public void Add(int number, string format, object arg0) @@ -191,8 +191,8 @@ namespace Server public OPLInfo(Serial serial, int hash) : base(0xDC, 9) { - m_Stream.Write(serial); - m_Stream.Write(hash); + Stream.Write(serial); + Stream.Write(hash); } } } diff --git a/Projects/Server/Party.cs b/Projects/Server/Party.cs index 66739216e..e86a3db45 100644 --- a/Projects/Server/Party.cs +++ b/Projects/Server/Party.cs @@ -22,7 +22,7 @@ namespace Server { public abstract class PartyCommands { - public static PartyCommands Handler{ get; set; } + public static PartyCommands Handler { get; set; } public abstract void OnAdd(Mobile from); public abstract void OnRemove(Mobile from, Mobile target); @@ -32,4 +32,4 @@ namespace Server public abstract void OnAccept(Mobile from, Mobile leader); public abstract void OnDecline(Mobile from, Mobile leader); } -} \ No newline at end of file +} diff --git a/Projects/Server/Persistence/BinaryMemoryWriter.cs b/Projects/Server/Persistence/BinaryMemoryWriter.cs index 04697d869..2946c9019 100644 --- a/Projects/Server/Persistence/BinaryMemoryWriter.cs +++ b/Projects/Server/Persistence/BinaryMemoryWriter.cs @@ -33,14 +33,14 @@ namespace Server protected override int BufferSize => 512; - public int CommitTo(SequentialFileWriter dataFile, SequentialFileWriter indexFile, int typeCode, uint serial) + public int CommitTo(SequentialFileWriterStream dataFile, SequentialFileWriterStream indexFile, int typeCode, uint serial) { Flush(); - byte[] buffer = stream.GetBuffer(); - int length = (int)stream.Length; + var buffer = stream.GetBuffer(); + var length = (int)stream.Length; - long position = dataFile.Position; + var position = dataFile.Position; dataFile.Write(buffer, 0, length); diff --git a/Projects/Server/Persistence/DualSaveStrategy.cs b/Projects/Server/Persistence/DualSaveStrategy.cs index 8e9ce9785..7784e619f 100644 --- a/Projects/Server/Persistence/DualSaveStrategy.cs +++ b/Projects/Server/Persistence/DualSaveStrategy.cs @@ -30,7 +30,7 @@ namespace Server { PermitBackgroundWrite = permitBackgroundWrite; - Thread saveThread = new Thread(delegate() { SaveItems(); }); + var saveThread = new Thread(SaveItems); saveThread.Name = "Item Save Subset"; saveThread.Start(); @@ -40,9 +40,8 @@ namespace Server saveThread.Join(); - if (permitBackgroundWrite && UseSequentialWriters - ) //If we're permitted to write in the background, but we don't anyways, then notify. + if (permitBackgroundWrite && UseSequentialWriters) // If we're permitted to write in the background, but we don't anyways, then notify. World.NotifyDiskWriteComplete(); } } -} \ No newline at end of file +} diff --git a/Projects/Server/Persistence/DynamicSaveStrategy.cs b/Projects/Server/Persistence/DynamicSaveStrategy.cs index 175b168f8..e7bcf0122 100644 --- a/Projects/Server/Persistence/DynamicSaveStrategy.cs +++ b/Projects/Server/Persistence/DynamicSaveStrategy.cs @@ -18,7 +18,6 @@ * ***************************************************************************/ - using System; using System.Collections.Concurrent; using System.Collections.Generic; @@ -30,14 +29,14 @@ namespace Server public sealed class DynamicSaveStrategy : SaveStrategy { private readonly ConcurrentBag _decayBag; - private SequentialFileWriter _guildData, _guildIndex; + private SequentialFileWriterStream _guildData, _guildIndex; private readonly BlockingCollection _guildThreadWriters; - private SequentialFileWriter _itemData, _itemIndex; + private SequentialFileWriterStream _itemData, _itemIndex; private readonly BlockingCollection _itemThreadWriters; - private SequentialFileWriter _mobileData, _mobileIndex; + private SequentialFileWriterStream _mobileData, _mobileIndex; private readonly BlockingCollection _mobileThreadWriters; public DynamicSaveStrategy() @@ -54,7 +53,7 @@ namespace Server { OpenFiles(); - Task[] saveTasks = new Task[3]; + var saveTasks = new Task[3]; saveTasks[0] = SaveItems(); saveTasks[1] = SaveMobiles(); @@ -64,25 +63,28 @@ namespace Server if (permitBackgroundWrite) { - //This option makes it finish the writing to disk in the background, continuing even after Save() returns. +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * + // This option makes it finish the writing to disk in the background, continuing even after Save() returns. Task.Factory.ContinueWhenAll(saveTasks, _ => { CloseFiles(); World.NotifyDiskWriteComplete(); }); +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * } else { - Task.WaitAll(saveTasks); //Waits for the completion of all of the tasks(committing to disk) + Task.WaitAll(saveTasks); // Waits for the completion of all of the tasks(committing to disk) CloseFiles(); } } - private Task StartCommitTask(BlockingCollection threadWriter, SequentialFileWriter data, - SequentialFileWriter index) + private Task StartCommitTask(BlockingCollection threadWriter, SequentialFileWriterStream data, + SequentialFileWriterStream index) { - Task commitTask = Task.Factory.StartNew(() => +#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler * + var commitTask = Task.Factory.StartNew(() => { while (!threadWriter.IsCompleted) { @@ -94,33 +96,34 @@ namespace Server } catch (InvalidOperationException) { - //Per MSDN, it's fine if we're here, successful completion of adding can rarely put us into this state. + // Per MSDN, it's fine if we're here, successful completion of adding can rarely put us into this state. break; } writer.CommitTo(data, index); } }); +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * return commitTask; } private Task SaveItems() { - //Start the blocking consumer; this runs in background. - Task commitTask = StartCommitTask(_itemThreadWriters, _itemData, _itemIndex); + // Start the blocking consumer; this runs in background. + var commitTask = StartCommitTask(_itemThreadWriters, _itemData, _itemIndex); IEnumerable items = World.Items.Values; - //Start the producer. + // Start the producer. Parallel.ForEach(items, () => new QueuedMemoryWriter(), (item, state, writer) => { - long startPosition = writer.Position; + var startPosition = writer.Position; item.Serialize(writer); - int size = (int)(writer.Position - startPosition); + var size = (int)(writer.Position - startPosition); writer.QueueForIndex(item, size); @@ -136,27 +139,27 @@ namespace Server _itemThreadWriters.Add(writer); }); - _itemThreadWriters.CompleteAdding(); //We only get here after the Parallel.ForEach completes. Lets our task + _itemThreadWriters.CompleteAdding(); // We only get here after the Parallel.ForEach completes. Lets our task return commitTask; } private Task SaveMobiles() { - //Start the blocking consumer; this runs in background. - Task commitTask = StartCommitTask(_mobileThreadWriters, _mobileData, _mobileIndex); + // Start the blocking consumer; this runs in background. + var commitTask = StartCommitTask(_mobileThreadWriters, _mobileData, _mobileIndex); IEnumerable mobiles = World.Mobiles.Values; - //Start the producer. + // Start the producer. Parallel.ForEach(mobiles, () => new QueuedMemoryWriter(), (mobile, state, writer) => { - long startPosition = writer.Position; + var startPosition = writer.Position; mobile.Serialize(writer); - int size = (int)(writer.Position - startPosition); + var size = (int)(writer.Position - startPosition); writer.QueueForIndex(mobile, size); @@ -170,27 +173,27 @@ namespace Server }); _mobileThreadWriters - .CompleteAdding(); //We only get here after the Parallel.ForEach completes. Lets our task tell the consumer that we're done + .CompleteAdding(); // We only get here after the Parallel.ForEach completes. Lets our task tell the consumer that we're done return commitTask; } private Task SaveGuilds() { - //Start the blocking consumer; this runs in background. - Task commitTask = StartCommitTask(_guildThreadWriters, _guildData, _guildIndex); + // Start the blocking consumer; this runs in background. + var commitTask = StartCommitTask(_guildThreadWriters, _guildData, _guildIndex); IEnumerable guilds = BaseGuild.List.Values; - //Start the producer. + // Start the producer. Parallel.ForEach(guilds, () => new QueuedMemoryWriter(), (guild, state, writer) => { - long startPosition = writer.Position; + var startPosition = writer.Position; guild.Serialize(writer); - int size = (int)(writer.Position - startPosition); + var size = (int)(writer.Position - startPosition); writer.QueueForIndex(guild, size); @@ -203,28 +206,28 @@ namespace Server _guildThreadWriters.Add(writer); }); - _guildThreadWriters.CompleteAdding(); //We only get here after the Parallel.ForEach completes. Lets our task + _guildThreadWriters.CompleteAdding(); // We only get here after the Parallel.ForEach completes. Lets our task return commitTask; } public override void ProcessDecay() { - while (_decayBag.TryTake(out Item item)) + while (_decayBag.TryTake(out var item)) if (item.OnDecay()) item.Delete(); } private void OpenFiles() { - _itemData = new SequentialFileWriter(World.ItemDataPath); - _itemIndex = new SequentialFileWriter(World.ItemIndexPath); + _itemData = new SequentialFileWriterStream(World.ItemDataPath); + _itemIndex = new SequentialFileWriterStream(World.ItemIndexPath); - _mobileData = new SequentialFileWriter(World.MobileDataPath); - _mobileIndex = new SequentialFileWriter(World.MobileIndexPath); + _mobileData = new SequentialFileWriterStream(World.MobileDataPath); + _mobileIndex = new SequentialFileWriterStream(World.MobileIndexPath); - _guildData = new SequentialFileWriter(World.GuildDataPath); - _guildIndex = new SequentialFileWriter(World.GuildIndexPath); + _guildData = new SequentialFileWriterStream(World.GuildDataPath); + _guildIndex = new SequentialFileWriterStream(World.GuildIndexPath); WriteCount(_itemIndex, World.Items.Count); WriteCount(_mobileIndex, World.Mobiles.Count); @@ -243,10 +246,10 @@ namespace Server _guildIndex.Close(); } - private void WriteCount(SequentialFileWriter indexFile, int count) + private void WriteCount(SequentialFileWriterStream indexFile, int count) { - //Equiv to GenericWriter.Write( (int)count ); - byte[] buffer = new byte[4]; + // Equiv to GenericWriter.Write( (int)count ); + var buffer = new byte[4]; buffer[0] = (byte)count; buffer[1] = (byte)(count >> 8); @@ -264,15 +267,15 @@ namespace Server private void SaveTypeDatabase(string path, List types) { - BinaryFileWriter bfw = new BinaryFileWriter(path, false); + var bfw = new BinaryFileWriter(path, false); bfw.Write(types.Count); - foreach (Type type in types) bfw.Write(type.FullName); + foreach (var type in types) bfw.Write(type.FullName); bfw.Flush(); bfw.Close(); } } -} \ No newline at end of file +} diff --git a/Projects/Server/Persistence/FileOperations.cs b/Projects/Server/Persistence/FileOperations.cs index 7e5eb04c8..39725da69 100644 --- a/Projects/Server/Persistence/FileOperations.cs +++ b/Projects/Server/Persistence/FileOperations.cs @@ -18,7 +18,6 @@ * ***************************************************************************/ - using System; using System.IO; #if !MONO @@ -34,11 +33,11 @@ namespace Server public const int KB = 1024; public const int MB = 1024 * KB; - public static int BufferSize{ get; set; } = 1 * MB; + public static int BufferSize { get; set; } = 1 * MB; - public static int Concurrency{ get; set; } = 1; + public static int Concurrency { get; set; } = 1; - public static bool Unbuffered{ get; set; } = true; + public static bool Unbuffered { get; set; } = true; public static bool AreSynchronous => Concurrency < 1; @@ -46,7 +45,7 @@ namespace Server public static FileStream OpenSequentialStream(string path, FileMode mode, FileAccess access, FileShare share) { - FileOptions options = FileOptions.SequentialScan; + var options = FileOptions.SequentialScan; if (Concurrency > 0) options |= FileOptions.Asynchronous; @@ -59,7 +58,7 @@ namespace Server else return new FileStream(path, mode, access, share, BufferSize, options); - SafeFileHandle fileHandle = + var fileHandle = UnsafeNativeMethods.CreateFile(path, (int)access, share, IntPtr.Zero, mode, (int)options, IntPtr.Zero); if (fileHandle.IsInvalid) throw new IOException(); diff --git a/Projects/Server/Persistence/FileQueue.cs b/Projects/Server/Persistence/FileQueue.cs index f3f3d2e8d..0a4c4fb9b 100644 --- a/Projects/Server/Persistence/FileQueue.cs +++ b/Projects/Server/Persistence/FileQueue.cs @@ -47,10 +47,12 @@ namespace Server public FileQueue(int concurrentWrites, FileCommitCallback callback) { - if (concurrentWrites < 1) throw new ArgumentOutOfRangeException("concurrentWrites"); + if (concurrentWrites < 1) throw new ArgumentOutOfRangeException(nameof(concurrentWrites)); if (bufferSize < 1) - throw new ArgumentOutOfRangeException("bufferSize"); +#pragma warning disable CA2208 // Instantiate argument exceptions correctly + throw new ArgumentOutOfRangeException(nameof(FileOperations.BufferSize)); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly syncRoot = new object(); @@ -62,7 +64,7 @@ namespace Server idle = new ManualResetEvent(true); } - public long Position{ get; private set; } + public long Position { get; private set; } public void Dispose() { @@ -81,7 +83,7 @@ namespace Server ++activeCount; - for (int slot = 0; slot < active.Length; ++slot) + for (var slot = 0; slot < active.Length; ++slot) if (active[slot] == null) { active[slot] = new Chunk(this, slot, page.buffer, 0, page.length); @@ -106,12 +108,12 @@ namespace Server } /*lock ( syncRoot ) { - if ( pending.Count > 0 ) { + if (pending.Count > 0 ) { idle.Reset(); } for ( int slot = 0; slot < active.Length && pending.Count > 0; ++slot ) { - if ( active[slot] == null ) { + if (active[slot] == null ) { Page page = pending.Dequeue(); active[slot] = new Chunk( this, slot, page.buffer, 0, page.length ); @@ -128,17 +130,17 @@ namespace Server private void Commit(Chunk chunk, int slot) { - if (slot < 0 || slot >= active.Length) throw new ArgumentOutOfRangeException("slot"); + if (slot < 0 || slot >= active.Length) throw new ArgumentOutOfRangeException(nameof(slot)); lock (syncRoot) { - if (active[slot] != chunk) throw new ArgumentException(); + if (active[slot] != chunk) throw new ArgumentException("active slot is not the current chunk"); ArrayPool.Shared.Return(chunk.Buffer); if (pending.Count > 0) { - Page page = pending.Dequeue(); + var page = pending.Dequeue(); active[slot] = new Chunk(this, slot, page.buffer, 0, page.length); @@ -157,11 +159,11 @@ namespace Server public void Enqueue(byte[] buffer, int offset, int size) { - if (buffer == null) throw new ArgumentNullException("buffer"); + if (buffer == null) throw new ArgumentNullException(nameof(buffer)); - if (offset < 0) throw new ArgumentOutOfRangeException("offset"); - if (size < 0) throw new ArgumentOutOfRangeException("size"); - if (buffer.Length - offset < size) throw new ArgumentException(); + if (offset < 0) throw new ArgumentOutOfRangeException(nameof(offset)); + if (size < 0) throw new ArgumentOutOfRangeException(nameof(size)); + if (buffer.Length - offset < size) throw new ArgumentOutOfRangeException(nameof(offset)); Position += size; @@ -169,9 +171,9 @@ namespace Server { buffered.buffer ??= ArrayPool.Shared.Rent(bufferSize); - byte[] page = buffered.buffer; // buffer page - int pageSpace = page.Length - buffered.length; // available bytes in page - int byteCount = size > pageSpace ? pageSpace : size; // how many bytes we can copy over + var page = buffered.buffer; // buffer page + var pageSpace = page.Length - buffered.length; // available bytes in page + var byteCount = size > pageSpace ? pageSpace : size; // how many bytes we can copy over Buffer.BlockCopy(buffer, offset, page, buffered.length, byteCount); @@ -192,29 +194,28 @@ namespace Server public sealed class Chunk { - private int offset; - private readonly FileQueue owner; - private readonly int slot; + private readonly FileQueue m_Owner; + private readonly int m_Slot; public Chunk(FileQueue owner, int slot, byte[] buffer, int offset, int size) { - this.owner = owner; - this.slot = slot; + m_Owner = owner; + m_Slot = slot; Buffer = buffer; - this.offset = offset; + Offset = offset; Size = size; } - public byte[] Buffer{ get; } + public byte[] Buffer { get; } - public int Offset => 0; + public int Offset { get; } - public int Size{ get; } + public int Size { get; } public void Commit() { - owner.Commit(this, slot); + m_Owner.Commit(this, m_Slot); } } diff --git a/Projects/Server/Persistence/ParallelSaveStrategy.cs b/Projects/Server/Persistence/ParallelSaveStrategy.cs index 45f28795e..d46b429c3 100644 --- a/Projects/Server/Persistence/ParallelSaveStrategy.cs +++ b/Projects/Server/Persistence/ParallelSaveStrategy.cs @@ -26,7 +26,7 @@ using Server.Guilds; namespace Server { - public sealed class ParallelSaveStrategy : SaveStrategy + public sealed class ParallelSaveStrategy : SaveStrategy, IDisposable { private readonly Queue _decayQueue; @@ -34,11 +34,11 @@ namespace Server private int cycle; private bool finished; - private SequentialFileWriter guildData, guildIndex; + private SequentialFileWriterStream guildData, guildIndex; - private SequentialFileWriter itemData, itemIndex; + private SequentialFileWriterStream itemData, itemIndex; - private SequentialFileWriter mobileData, mobileIndex; + private SequentialFileWriterStream mobileData, mobileIndex; private readonly int processorCount; @@ -59,11 +59,11 @@ namespace Server consumers = new Consumer[GetThreadCount()]; - for (int i = 0; i < consumers.Length; ++i) consumers[i] = new Consumer(this, 256); + for (var i = 0; i < consumers.Length; ++i) consumers[i] = new Consumer(this, 256); IEnumerable collection = new Producer(); - foreach (ISerializable value in collection) + foreach (var value in collection) while (!Enqueue(value)) if (!Commit()) Thread.Sleep(0); @@ -75,9 +75,7 @@ namespace Server WaitHandle.WaitAll( Array.ConvertAll( consumers, - input => input.completionEvent - ) - ); + input => input.completionEvent)); Commit(); @@ -88,7 +86,7 @@ namespace Server { while (_decayQueue.Count > 0) { - Item item = _decayQueue.Dequeue(); + var item = _decayQueue.Dequeue(); if (item.OnDecay()) item.Delete(); } @@ -102,11 +100,11 @@ namespace Server private void SaveTypeDatabase(string path, List types) { - BinaryFileWriter bfw = new BinaryFileWriter(path, false); + var bfw = new BinaryFileWriter(path, false); bfw.Write(types.Count); - foreach (Type type in types) bfw.Write(type.FullName); + foreach (var type in types) bfw.Write(type.FullName); bfw.Flush(); @@ -115,23 +113,23 @@ namespace Server private void OpenFiles() { - itemData = new SequentialFileWriter(World.ItemDataPath); - itemIndex = new SequentialFileWriter(World.ItemIndexPath); + itemData = new SequentialFileWriterStream(World.ItemDataPath); + itemIndex = new SequentialFileWriterStream(World.ItemIndexPath); - mobileData = new SequentialFileWriter(World.MobileDataPath); - mobileIndex = new SequentialFileWriter(World.MobileIndexPath); + mobileData = new SequentialFileWriterStream(World.MobileDataPath); + mobileIndex = new SequentialFileWriterStream(World.MobileIndexPath); - guildData = new SequentialFileWriter(World.GuildDataPath); - guildIndex = new SequentialFileWriter(World.GuildIndexPath); + guildData = new SequentialFileWriterStream(World.GuildDataPath); + guildIndex = new SequentialFileWriterStream(World.GuildIndexPath); WriteCount(itemIndex, World.Items.Count); WriteCount(mobileIndex, World.Mobiles.Count); WriteCount(guildIndex, BaseGuild.List.Count); } - private void WriteCount(SequentialFileWriter indexFile, int count) + private void WriteCount(SequentialFileWriterStream indexFile, int count) { - byte[] buffer = new byte[4]; + var buffer = new byte[4]; buffer[0] = (byte)count; buffer[1] = (byte)(count >> 8); @@ -157,8 +155,8 @@ namespace Server private void OnSerialized(ConsumableEntry entry) { - ISerializable value = entry.value; - BinaryMemoryWriter writer = entry.writer; + var value = entry.value; + var writer = entry.writer; if (value is Item item) Save(item, writer); @@ -170,7 +168,7 @@ namespace Server private void Save(Item item, BinaryMemoryWriter writer) { - writer.CommitTo(itemData, itemIndex, item.m_TypeRef, item.Serial); + writer.CommitTo(itemData, itemIndex, item.TypeRef, item.Serial); if (item.Decays && item.Parent == null && item.Map != Map.Internal && DateTime.UtcNow > item.LastMoved + item.DecayTime) _decayQueue.Enqueue(item); @@ -178,19 +176,19 @@ namespace Server private void Save(Mobile mob, BinaryMemoryWriter writer) { - writer.CommitTo(mobileData, mobileIndex, mob.m_TypeRef, mob.Serial); + writer.CommitTo(mobileData, mobileIndex, mob.TypeRef, mob.Serial); } private void Save(BaseGuild guild, BinaryMemoryWriter writer) { - writer.CommitTo(guildData, guildIndex, 0, guild.Id); + writer.CommitTo(guildData, guildIndex, 0, guild.Serial); } private bool Enqueue(ISerializable value) { - for (int i = 0; i < consumers.Length; ++i) + for (var i = 0; i < consumers.Length; ++i) { - Consumer consumer = consumers[cycle++ % consumers.Length]; + var consumer = consumers[cycle++ % consumers.Length]; if (consumer.tail - consumer.head < consumer.buffer.Length) { @@ -206,11 +204,11 @@ namespace Server private bool Commit() { - bool committed = false; + var committed = false; - for (int i = 0; i < consumers.Length; ++i) + for (var i = 0; i < consumers.Length; ++i) { - Consumer consumer = consumers[i]; + var consumer = consumers[i]; while (consumer.head < consumer.done) { @@ -239,11 +237,11 @@ namespace Server public IEnumerator GetEnumerator() { - foreach (Item item in items) yield return item; + foreach (var item in items) yield return item; - foreach (Mobile mob in mobiles) yield return mob; + foreach (var mob in mobiles) yield return mob; - foreach (BaseGuild guild in guilds) yield return guild; + foreach (var guild in guilds) yield return guild; } IEnumerator IEnumerable.GetEnumerator() => throw new NotImplementedException(); @@ -271,7 +269,7 @@ namespace Server buffer = new ConsumableEntry[bufferSize]; - for (int i = 0; i < buffer.Length; ++i) buffer[i].writer = new BinaryMemoryWriter(); + for (var i = 0; i < buffer.Length; ++i) buffer[i].writer = new BinaryMemoryWriter(); completionEvent = new ManualResetEvent(false); @@ -316,5 +314,39 @@ namespace Server } } } + + private bool disposedValue = false; // To detect redundant calls + + public void Dispose(bool disposing) + { + if (!disposedValue) + { + if (disposing) + { + // TODO: dispose managed state (managed objects). + } + + // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. + // TODO: set large fields to null. + + disposedValue = true; + } + } + + // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources. + // ~ParallelSaveStrategy() + // { + // // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + // Dispose(false); + // } + + // This code added to correctly implement the disposable pattern. + public void Dispose() + { + // Do not change this code. Put cleanup code in Dispose(bool disposing) above. + Dispose(true); + // TODO: uncomment the following line if the finalizer is overridden above. + // GC.SuppressFinalize(this); + } } -} \ No newline at end of file +} diff --git a/Projects/Server/Persistence/Persistence.cs b/Projects/Server/Persistence/Persistence.cs index 9d01d79e3..d2ff00672 100644 --- a/Projects/Server/Persistence/Persistence.cs +++ b/Projects/Server/Persistence/Persistence.cs @@ -1,10 +1,6 @@ -#region References - using System; using System.IO; -#endregion - namespace Server { public static class Persistence @@ -25,8 +21,8 @@ namespace Server file.Refresh(); - using FileStream fs = file.OpenWrite(); - BinaryFileWriter writer = new BinaryFileWriter(fs, true); + using var fs = file.OpenWrite(); + var writer = new BinaryFileWriter(fs, true); try { @@ -79,8 +75,8 @@ namespace Server file.Refresh(); - using FileStream fs = file.OpenRead(); - BinaryFileReader reader = new BinaryFileReader(new BinaryReader(fs)); + using var fs = file.OpenRead(); + var reader = new BinaryFileReader(new BinaryReader(fs)); try { diff --git a/Projects/Server/Persistence/QueuedMemoryWriter.cs b/Projects/Server/Persistence/QueuedMemoryWriter.cs index 6effa9f97..b86891a4b 100644 --- a/Projects/Server/Persistence/QueuedMemoryWriter.cs +++ b/Projects/Server/Persistence/QueuedMemoryWriter.cs @@ -1,4 +1,4 @@ -/*************************************************************************** +/*************************************************************************** * QueuedMemoryWriter.cs * ------------------- * begin : December 16, 2010 @@ -40,36 +40,36 @@ namespace Server info.size = size; - info.typeCode = serializable.TypeReference; //For guilds, this will automagically be zero. - info.serial = serializable.SerialIdentity; + info.typeCode = serializable.TypeRef; // For guilds, this will automagically be zero. + info.serial = serializable.Serial; _orderedIndexInfo.Add(info); } - public void CommitTo(SequentialFileWriter dataFile, SequentialFileWriter indexFile) + public void CommitTo(SequentialFileWriterStream dataFile, SequentialFileWriterStream indexFile) { Flush(); - int memLength = (int)_memStream.Position; + var memLength = (int)_memStream.Position; if (memLength > 0) { - byte[] memBuffer = _memStream.GetBuffer(); + var memBuffer = _memStream.GetBuffer(); - long actualPosition = dataFile.Position; + var actualPosition = dataFile.Position; - dataFile.Write(memBuffer, 0, memLength); //The buffer contains the data from many items. + dataFile.Write(memBuffer, 0, memLength); // The buffer contains the data from many items. - //Console.WriteLine("Writing {0} bytes starting at {1}, with {2} things", memLength, actualPosition, _orderedIndexInfo.Count); + // Console.WriteLine("Writing {0} bytes starting at {1}, with {2} things", memLength, actualPosition, _orderedIndexInfo.Count); - byte[] indexBuffer = new byte[20]; + var indexBuffer = new byte[20]; - //int indexWritten = _orderedIndexInfo.Count * indexBuffer.Length; - //int totalWritten = memLength + indexWritten + // int indexWritten = _orderedIndexInfo.Count * indexBuffer.Length; + // int totalWritten = memLength + indexWritten - for (int i = 0; i < _orderedIndexInfo.Count; i++) + for (var i = 0; i < _orderedIndexInfo.Count; i++) { - IndexInfo info = _orderedIndexInfo[i]; + var info = _orderedIndexInfo[i]; indexBuffer[0] = (byte)info.typeCode; indexBuffer[1] = (byte)(info.typeCode >> 8); @@ -101,7 +101,7 @@ namespace Server } } - Close(); //We're done with this writer. + Close(); // We're done with this writer. } private struct IndexInfo @@ -111,4 +111,4 @@ namespace Server public uint serial; } } -} \ No newline at end of file +} diff --git a/Projects/Server/Persistence/SaveStrategy.cs b/Projects/Server/Persistence/SaveStrategy.cs index dbf7f6938..97225f224 100644 --- a/Projects/Server/Persistence/SaveStrategy.cs +++ b/Projects/Server/Persistence/SaveStrategy.cs @@ -22,13 +22,13 @@ namespace Server { public abstract class SaveStrategy { - public abstract string Name{ get; } + public abstract string Name { get; } public static SaveStrategy Acquire() { if (Core.MultiProcessor) { - int processorCount = Core.ProcessorCount; + var processorCount = Core.ProcessorCount; if (processorCount > 2) return @@ -44,4 +44,4 @@ namespace Server public abstract void ProcessDecay(); } -} \ No newline at end of file +} diff --git a/Projects/Server/Persistence/SequentialFileWriter.cs b/Projects/Server/Persistence/SequentialFileWriterStream.cs similarity index 88% rename from Projects/Server/Persistence/SequentialFileWriter.cs rename to Projects/Server/Persistence/SequentialFileWriterStream.cs index 8682e7185..ade81f0a1 100644 --- a/Projects/Server/Persistence/SequentialFileWriter.cs +++ b/Projects/Server/Persistence/SequentialFileWriterStream.cs @@ -23,23 +23,22 @@ using System.IO; namespace Server { - public sealed class SequentialFileWriter : Stream + public sealed class SequentialFileWriterStream : Stream { private FileQueue fileQueue; private FileStream fileStream; private AsyncCallback writeCallback; - public SequentialFileWriter(string path) + public SequentialFileWriterStream(string path) { - if (path == null) throw new ArgumentNullException("path"); + if (path == null) throw new ArgumentNullException(nameof(path)); fileStream = FileOperations.OpenSequentialStream(path, FileMode.Create, FileAccess.Write, FileShare.None); fileQueue = new FileQueue( Math.Max(1, FileOperations.Concurrency), - FileCallback - ); + FileCallback); } public override long Position @@ -74,7 +73,7 @@ namespace Server private void OnWrite(IAsyncResult asyncResult) { - FileQueue.Chunk chunk = asyncResult.AsyncState as FileQueue.Chunk; + var chunk = asyncResult.AsyncState as FileQueue.Chunk; fileStream.EndWrite(asyncResult); diff --git a/Projects/Server/Persistence/StandardSaveStrategy.cs b/Projects/Server/Persistence/StandardSaveStrategy.cs index 282905229..a9eb8ed21 100644 --- a/Projects/Server/Persistence/StandardSaveStrategy.cs +++ b/Projects/Server/Persistence/StandardSaveStrategy.cs @@ -33,7 +33,8 @@ namespace Server Threaded } - public static SaveOption SaveType = SaveOption.Normal; + // TODO: Move to configuration + public static SaveOption SaveType => SaveOption.Normal; private readonly Queue _decayQueue; @@ -41,7 +42,7 @@ namespace Server public override string Name => "Standard"; - protected bool PermitBackgroundWrite{ get; set; } + protected bool PermitBackgroundWrite { get; set; } protected bool UseSequentialWriters => SaveType == SaveOption.Normal || !PermitBackgroundWrite; @@ -49,16 +50,17 @@ namespace Server { PermitBackgroundWrite = permitBackgroundWrite; +#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler * Task.WaitAll(Task.Factory.StartNew(SaveMobiles), Task.Factory.StartNew(SaveItems), Task.Factory.StartNew(SaveGuilds)); +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * - if (permitBackgroundWrite && UseSequentialWriters - ) //If we're permitted to write in the background, but we don't anyways, then notify. + if (permitBackgroundWrite && UseSequentialWriters) // If we're permitted to write in the background, but we don't anyways, then notify. World.NotifyDiskWriteComplete(); } protected void SaveMobiles() { - Dictionary mobiles = World.Mobiles; + var mobiles = World.Mobiles; IGenericWriter idx; IGenericWriter tdb; @@ -76,27 +78,28 @@ namespace Server tdb = new AsyncWriter(World.MobileTypesPath, false); bin = new AsyncWriter(World.MobileDataPath, true); } - +#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler * Task.Factory.StartNew(() => { tdb.Write(World.m_MobileTypes.Count); - for (int i = 0; i < World.m_MobileTypes.Count; ++i) + for (var i = 0; i < World.m_MobileTypes.Count; ++i) tdb.Write(World.m_MobileTypes[i].FullName); tdb.Close(); }); +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * Parallel.ForEach(mobiles.Values, mobile => mobile.Serialize()); - +#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler * Task.Factory.StartNew(() => { idx.Write(mobiles.Count); - foreach (Mobile m in mobiles.Values) + foreach (var m in mobiles.Values) { - long start = bin.Position; + var start = bin.Position; - idx.Write(m.m_TypeRef); + idx.Write(m.TypeRef); idx.Write(m.Serial); idx.Write(start); idx.Write((int)m.SaveBuffer.Position); @@ -108,11 +111,12 @@ namespace Server idx.Close(); bin.Close(); }); +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * } protected void SaveItems() { - Dictionary items = World.Items; + var items = World.Items; IGenericWriter idx; IGenericWriter tdb; @@ -131,24 +135,27 @@ namespace Server bin = new AsyncWriter(World.ItemDataPath, true); } +#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler * Task.Factory.StartNew(() => { tdb.Write(World.m_ItemTypes.Count); - for (int i = 0; i < World.m_ItemTypes.Count; ++i) + for (var i = 0; i < World.m_ItemTypes.Count; ++i) tdb.Write(World.m_ItemTypes[i].FullName); tdb.Close(); }); - +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * Parallel.ForEach(items.Values, item => item.Serialize()); idx.Write(items.Count); - DateTime n = DateTime.UtcNow; + var n = DateTime.UtcNow; - Task.Factory.StartNew(() => { - foreach (Item item in items.Values) +#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler * + Task.Factory.StartNew(() => + { + foreach (var item in items.Values) { if (item.Decays && item.Parent == null && item.Map != Map.Internal && item.LastMoved + item.DecayTime <= n) { @@ -156,9 +163,9 @@ namespace Server _decayQueue.Enqueue(item); } - long start = bin.Position; + var start = bin.Position; - idx.Write(item.m_TypeRef); + idx.Write(item.TypeRef); idx.Write(item.Serial); idx.Write(start); idx.Write((int)item.SaveBuffer.Position); @@ -170,7 +177,9 @@ namespace Server idx.Close(); bin.Close(); }); +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * } + protected void SaveGuilds() { IGenericWriter idx; @@ -190,15 +199,15 @@ namespace Server Parallel.ForEach(BaseGuild.List.Values, guild => guild.Serialize()); idx.Write(BaseGuild.List.Count); - +#pragma warning disable CA2008 // Do not create tasks without passing a TaskScheduler * Task.Factory.StartNew(() => { - foreach (BaseGuild guild in BaseGuild.List.Values) + foreach (var guild in BaseGuild.List.Values) { - long start = bin.Position; + var start = bin.Position; - idx.Write(0); //guilds have no typeid - idx.Write(guild.Id); + idx.Write(0); // guilds have no typeid + idx.Write(guild.Serial); idx.Write(start); idx.Write((int)guild.SaveBuffer.Position); @@ -208,13 +217,14 @@ namespace Server idx.Close(); bin.Close(); }); +#pragma warning restore CA2008 // Do not create tasks without passing a TaskScheduler * } public override void ProcessDecay() { while (_decayQueue.Count > 0) { - Item item = _decayQueue.Dequeue(); + var item = _decayQueue.Dequeue(); if (item.OnDecay()) item.Delete(); diff --git a/Projects/Server/Point3DList.cs b/Projects/Server/Point3DList.cs index 6b34f72da..4525f75be 100644 --- a/Projects/Server/Point3DList.cs +++ b/Projects/Server/Point3DList.cs @@ -22,7 +22,7 @@ namespace Server { public class Point3DList { - private static readonly Point3D[] m_EmptyList = new Point3D[0]; + private static readonly Point3D[] m_EmptyList = System.Array.Empty(); private Point3D[] m_List; public Point3DList() @@ -31,7 +31,7 @@ namespace Server Count = 0; } - public int Count{ get; private set; } + public int Count { get; private set; } public Point3D Last => m_List[Count - 1]; @@ -46,10 +46,10 @@ namespace Server { if (Count + 1 > m_List.Length) { - Point3D[] old = m_List; + var old = m_List; m_List = new Point3D[old.Length * 2]; - for (int i = 0; i < old.Length; ++i) + for (var i = 0; i < old.Length; ++i) m_List[i] = old[i]; } @@ -63,10 +63,10 @@ namespace Server { if (Count + 1 > m_List.Length) { - Point3D[] old = m_List; + var old = m_List; m_List = new Point3D[old.Length * 2]; - for (int i = 0; i < old.Length; ++i) + for (var i = 0; i < old.Length; ++i) m_List[i] = old[i]; } @@ -81,9 +81,9 @@ namespace Server if (Count == 0) return m_EmptyList; - Point3D[] list = new Point3D[Count]; + var list = new Point3D[Count]; - for (int i = 0; i < Count; ++i) + for (var i = 0; i < Count; ++i) list[i] = m_List[i]; Count = 0; @@ -91,4 +91,4 @@ namespace Server return list; } } -} \ No newline at end of file +} diff --git a/Projects/Server/Poison.cs b/Projects/Server/Poison.cs index 188f378f2..9812028bc 100644 --- a/Projects/Server/Poison.cs +++ b/Projects/Server/Poison.cs @@ -28,8 +28,8 @@ namespace Server { /*public abstract TimeSpan Interval{ get; } public abstract TimeSpan Duration{ get; }*/ - public abstract string Name{ get; } - public abstract int Level{ get; } + public abstract string Name { get; } + public abstract int Level { get; } public static Poison Lesser => GetPoison("Lesser"); public static Poison Regular => GetPoison("Regular"); @@ -37,19 +37,18 @@ namespace Server public static Poison Deadly => GetPoison("Deadly"); public static Poison Lethal => GetPoison("Lethal"); - public static List Poisons{ get; } = new List(); + public static List Poisons { get; } = new List(); public abstract Timer ConstructTimer(Mobile m); /*public abstract void OnDamage( Mobile m, ref object state );*/ public override string ToString() => Name; - public static void Register(Poison reg) { - string regName = reg.Name.ToLower(); + var regName = reg.Name.ToLower(); - for (int i = 0; i < Poisons.Count; i++) + for (var i = 0; i < Poisons.Count; i++) { if (reg.Level == Poisons[i].Level) throw new Exception("A poison with that level already exists."); @@ -60,13 +59,14 @@ namespace Server Poisons.Add(reg); } - public static Poison Parse(string value) => (int.TryParse(value, out int plevel) ? GetPoison(plevel) : null) ?? GetPoison(value); + public static Poison Parse(string value) => + (int.TryParse(value, out var plevel) ? GetPoison(plevel) : null) ?? GetPoison(value); public static Poison GetPoison(int level) { - for (int i = 0; i < Poisons.Count; ++i) + for (var i = 0; i < Poisons.Count; ++i) { - Poison p = Poisons[i]; + var p = Poisons[i]; if (p.Level == level) return p; @@ -77,9 +77,9 @@ namespace Server public static Poison GetPoison(string name) { - for (int i = 0; i < Poisons.Count; ++i) + for (var i = 0; i < Poisons.Count; ++i) { - Poison p = Poisons[i]; + var p = Poisons[i]; if (Utility.InsensitiveCompare(p.Name, name) == 0) return p; @@ -107,7 +107,7 @@ namespace Server { case 1: return GetPoison(reader.ReadByte()); case 2: - //no longer used, safe to remove? + // no longer used, safe to remove? reader.ReadInt(); reader.ReadDouble(); reader.ReadInt(); diff --git a/Projects/Server/Prompt.cs b/Projects/Server/Prompt.cs index 36c9de092..64745e998 100644 --- a/Projects/Server/Prompt.cs +++ b/Projects/Server/Prompt.cs @@ -32,7 +32,7 @@ namespace Server.Prompts } while (Serial == 0); } - public int Serial{ get; } + public int Serial { get; } public virtual void OnCancel(Mobile from) { @@ -42,4 +42,4 @@ namespace Server.Prompts { } } -} \ No newline at end of file +} diff --git a/Projects/Server/QuestArrow.cs b/Projects/Server/QuestArrow.cs index 5dd3cef2e..dc1ab624c 100644 --- a/Projects/Server/QuestArrow.cs +++ b/Projects/Server/QuestArrow.cs @@ -36,11 +36,11 @@ namespace Server Update(x, y); } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public Mobile Target{ get; } + public Mobile Target { get; } - public bool Running{ get; private set; } + public bool Running { get; private set; } public void Update() { @@ -52,7 +52,7 @@ namespace Server if (!Running) return; - NetState ns = Mobile.NetState; + var ns = Mobile.NetState; if (ns == null) return; @@ -75,7 +75,7 @@ namespace Server Mobile.ClearQuestArrow(); - NetState ns = Mobile.NetState; + var ns = Mobile.NetState; if (ns != null) { @@ -97,4 +97,4 @@ namespace Server { } } -} \ No newline at end of file +} diff --git a/Projects/Server/Race.cs b/Projects/Server/Race.cs index 1495b067c..26674ad31 100644 --- a/Projects/Server/Race.cs +++ b/Projects/Server/Race.cs @@ -48,31 +48,31 @@ namespace Server public static Race DefaultRace => Races[0]; - public static Race[] Races{ get; } = new Race[0x100]; + public static Race[] Races { get; } = new Race[0x100]; public static Race Human => Races[0]; public static Race Elf => Races[1]; public static Race Gargoyle => Races[2]; - public static List AllRaces{ get; } = new List(); + public static List AllRaces { get; } = new List(); - public Expansion RequiredExpansion{ get; } + public Expansion RequiredExpansion { get; } - public int MaleBody{ get; } + public int MaleBody { get; } - public int MaleGhostBody{ get; } + public int MaleGhostBody { get; } - public int FemaleBody{ get; } + public int FemaleBody { get; } - public int FemaleGhostBody{ get; } + public int FemaleGhostBody { get; } - public int RaceID{ get; } + public int RaceID { get; } - public int RaceIndex{ get; } + public int RaceIndex { get; } - public string Name{ get; set; } + public string Name { get; set; } - public string PluralName{ get; set; } + public string PluralName { get; set; } public static string[] GetRaceNames() { @@ -90,11 +90,11 @@ namespace Server { CheckNamesAndValues(); - for (int i = 0; i < m_RaceNames.Length; ++i) + for (var i = 0; i < m_RaceNames.Length; ++i) if (Insensitive.Equals(m_RaceNames[i], value)) return m_RaceValues[i]; - if (int.TryParse(value, out int index) && index >= 0 && index < Races.Length && + if (int.TryParse(value, out var index) && index >= 0 && index < Races.Length && Races[index] != null) return Races[index]; @@ -109,9 +109,9 @@ namespace Server m_RaceNames = new string[AllRaces.Count]; m_RaceValues = new Race[AllRaces.Count]; - for (int i = 0; i < AllRaces.Count; ++i) + for (var i = 0; i < AllRaces.Count; ++i) { - Race race = AllRaces[i]; + var race = AllRaces[i]; m_RaceNames[i] = race.Name; m_RaceValues[i] = race; @@ -134,7 +134,7 @@ namespace Server public virtual int RandomFacialHair(Mobile m) => RandomFacialHair(m.Female); - public abstract int RandomFacialHair(bool female); //For the *ahem* bearded ladies + public abstract int RandomFacialHair(bool female); // For the *ahem* bearded ladies public abstract int ClipSkinHue(int hue); public abstract int RandomSkinHue(); diff --git a/Projects/Server/Region.cs b/Projects/Server/Region.cs index dcda3c477..df1c488be 100644 --- a/Projects/Server/Region.cs +++ b/Projects/Server/Region.cs @@ -109,7 +109,6 @@ namespace Server private Point3D m_GoLocation; - private readonly string m_Name; private readonly int m_Priority; @@ -118,7 +117,8 @@ namespace Server { } - public Region(string name, Map map, int priority, params Rectangle3D[] area) : this(name, map, null, area) => m_Priority = priority; + public Region(string name, Map map, int priority, params Rectangle3D[] area) : this(name, map, null, area) => + m_Priority = priority; public Region(string name, Map map, Region parent, params Rectangle2D[] area) : this(name, map, parent, ConvertTo3D(area)) @@ -168,20 +168,17 @@ namespace Server if (parent == null) ReadInt32(xml, "priority", ref m_Priority, false); + var minZ = MinZ; + var maxZ = MaxZ; - int minZ = MinZ; - int maxZ = MaxZ; - - XmlElement zrange = xml["zrange"]; + var zrange = xml["zrange"]; ReadInt32(zrange, "min", ref minZ, false); ReadInt32(zrange, "max", ref maxZ, false); - - List area = new List(); + var area = new List(); foreach (XmlElement xmlRect in xml.SelectNodes("rect")) { - Rectangle3D rect = new Rectangle3D(); - if (ReadRectangle3D(xmlRect, minZ, maxZ, ref rect)) + if (ReadRectangle3D(xmlRect, minZ, maxZ, out var rect)) area.Add(rect); } @@ -190,51 +187,49 @@ namespace Server if (Area.Length == 0) Console.WriteLine("Empty area for region '{0}'", this); - if (!ReadPoint3D(xml["go"], map, ref m_GoLocation, false) && Area.Length > 0) { - Point3D start = Area[0].Start; - Point3D end = Area[0].End; + var start = Area[0].Start; + var end = Area[0].End; - int x = start.X + (end.X - start.X) / 2; - int y = start.Y + (end.Y - start.Y) / 2; + var x = start.X + (end.X - start.X) / 2; + var y = start.Y + (end.Y - start.Y) / 2; m_GoLocation = new Point3D(x, y, Map.GetAverageZ(x, y)); } - - MusicName music = DefaultMusic; + var music = DefaultMusic; ReadEnum(xml["music"], "name", ref music, false); Music = music; } - public static List Regions{ get; } = new List(); + public static List Regions { get; } = new List(); - public static Type DefaultRegionType{ get; set; } = typeof(Region); + public static Type DefaultRegionType { get; set; } = typeof(Region); - public static TimeSpan StaffLogoutDelay{ get; set; } = TimeSpan.Zero; + public static TimeSpan StaffLogoutDelay { get; set; } = TimeSpan.Zero; - public static TimeSpan DefaultLogoutDelay{ get; set; } = TimeSpan.FromMinutes(5.0); + public static TimeSpan DefaultLogoutDelay { get; set; } = TimeSpan.FromMinutes(5.0); public string Name => m_Name; - public Map Map{ get; } + public Map Map { get; } - public Region Parent{ get; } + public Region Parent { get; } - public List Children{ get; } = new List(); + public List Children { get; } = new List(); - public Rectangle3D[] Area{ get; } + public Rectangle3D[] Area { get; } - public Sector[] Sectors{ get; private set; } + public Sector[] Sectors { get; private set; } - public bool Dynamic{ get; } + public bool Dynamic { get; } public int Priority => m_Priority; - public int ChildLevel{ get; } + public int ChildLevel { get; } - public bool Registered{ get; private set; } + public bool Registered { get; private set; } public Point3D GoLocation { @@ -242,7 +237,7 @@ namespace Server set => m_GoLocation = value; } - public MusicName Music{ get; set; } + public MusicName Music { get; set; } public bool IsDefault => Map.DefaultRegion == this; public virtual MusicName DefaultMusic => Parent?.Music ?? MusicName.Invalid; @@ -263,8 +258,8 @@ namespace Server return 1; } - int thisPriority = Priority; - int regPriority = reg.Priority; + var thisPriority = Priority; + var regPriority = reg.Priority; if (thisPriority != regPriority) return regPriority - thisPriority; @@ -277,12 +272,12 @@ namespace Server if (map == null) return Map.Internal.DefaultRegion; - Sector sector = map.GetSector(p); - List list = sector.RegionRects; + var sector = map.GetSector(p); + var list = sector.RegionRects; - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - RegionRect regRect = list[i]; + var regRect = list[i]; if (regRect.Contains(p)) return regRect.Region; @@ -291,13 +286,14 @@ namespace Server return map.DefaultRegion; } - public static Rectangle3D ConvertTo3D(Rectangle2D rect) => new Rectangle3D(new Point3D(rect.Start, MinZ), new Point3D(rect.End, MaxZ)); + public static Rectangle3D ConvertTo3D(Rectangle2D rect) => + new Rectangle3D(new Point3D(rect.Start, MinZ), new Point3D(rect.End, MaxZ)); public static Rectangle3D[] ConvertTo3D(Rectangle2D[] rects) { - Rectangle3D[] ret = new Rectangle3D[rects.Length]; + var ret = new Rectangle3D[rects.Length]; - for (int i = 0; i < ret.Length; i++) ret[i] = ConvertTo3D(rects[i]); + for (var i = 0; i < ret.Length; i++) ret[i] = ConvertTo3D(rects[i]); return ret; } @@ -321,28 +317,28 @@ namespace Server Map.RegisterRegion(this); - List sectors = new List(); + var sectors = new List(); - for (int i = 0; i < Area.Length; i++) + for (var i = 0; i < Area.Length; i++) { - Rectangle3D rect = Area[i]; + var rect = Area[i]; - Point2D start = Map.Bound(new Point2D(rect.Start)); - Point2D end = Map.Bound(new Point2D(rect.End)); + var start = Map.Bound(new Point2D(rect.Start)); + var end = Map.Bound(new Point2D(rect.End)); - Sector startSector = Map.GetSector(start); - Sector endSector = Map.GetSector(end); + var startSector = Map.GetSector(start); + var endSector = Map.GetSector(end); - for (int x = startSector.X; x <= endSector.X; x++) - for (int y = startSector.Y; y <= endSector.Y; y++) - { - Sector sector = Map.GetRealSector(x, y); + for (var x = startSector.X; x <= endSector.X; x++) + for (var y = startSector.Y; y <= endSector.Y; y++) + { + var sector = Map.GetRealSector(x, y); - sector.OnEnter(this, rect); + sector.OnEnter(this, rect); - if (!sectors.Contains(sector)) - sectors.Add(sector); - } + if (!sectors.Contains(sector)) + sectors.Add(sector); + } } Sectors = sectors.ToArray(); @@ -371,7 +367,7 @@ namespace Server Map.UnregisterRegion(this); if (Sectors != null) - for (int i = 0; i < Sectors.Length; i++) + for (var i = 0; i < Sectors.Length; i++) Sectors[i].OnLeave(this); Sectors = null; @@ -379,9 +375,9 @@ namespace Server public bool Contains(Point3D p) { - for (int i = 0; i < Area.Length; i++) + for (var i = 0; i < Area.Length; i++) { - Rectangle3D rect = Area[i]; + var rect = Area[i]; if (rect.Contains(p)) return true; @@ -396,7 +392,7 @@ namespace Server if (region == null) return false; - Region p = Parent; + var p = Parent; while (p != null) { @@ -412,7 +408,7 @@ namespace Server // TODO: Memoize this public T GetRegion() where T : Region { - Region r = this; + var r = this; do { @@ -430,7 +426,7 @@ namespace Server if (regionType == null) return null; - Region r = this; + var r = this; do { @@ -448,7 +444,7 @@ namespace Server if (regionName == null) return null; - Region r = this; + var r = this; do { @@ -467,17 +463,18 @@ namespace Server public bool IsPartOf(string regionName) => GetRegion(regionName) != null; - public virtual bool AcceptsSpawnsFrom(Region region) => AllowSpawn() && (region == this || Parent?.AcceptsSpawnsFrom(region) == true); + public virtual bool AcceptsSpawnsFrom(Region region) => + AllowSpawn() && (region == this || Parent?.AcceptsSpawnsFrom(region) == true); public List GetPlayers() { - List list = new List(); + var list = new List(); - for (int i = 0; i < Sectors?.Length; i++) + for (var i = 0; i < Sectors?.Length; i++) { - Sector sector = Sectors[i]; + var sector = Sectors[i]; - foreach (Mobile player in sector.Players) + foreach (var player in sector.Players) if (player.Region.IsPartOf(this)) list.Add(player); } @@ -487,43 +484,45 @@ namespace Server public int GetPlayerCount() { - int count = 0; + var count = 0; - for (int i = 0; i < Sectors?.Length; i++) + for (var i = 0; i < Sectors?.Length; i++) { - Sector sector = Sectors[i]; + var sector = Sectors[i]; - foreach (Mobile player in sector.Players) + foreach (var player in sector.Players) if (player.Region.IsPartOf(this)) count++; } + return count; } public List GetMobiles() { - List list = new List(); + var list = new List(); - for (int i = 0; i < Sectors?.Length; i++) + for (var i = 0; i < Sectors?.Length; i++) { - Sector sector = Sectors[i]; + var sector = Sectors[i]; - foreach (Mobile mobile in sector.Mobiles) + foreach (var mobile in sector.Mobiles) if (mobile.Region.IsPartOf(this)) list.Add(mobile); } + return list; } public int GetMobileCount() { - int count = 0; + var count = 0; - for (int i = 0; i < Sectors?.Length; i++) + for (var i = 0; i < Sectors?.Length; i++) { - Sector sector = Sectors[i]; + var sector = Sectors[i]; - foreach (Mobile mobile in sector.Mobiles) + foreach (var mobile in sector.Mobiles) if (mobile.Region.IsPartOf(this)) count++; } @@ -533,7 +532,6 @@ namespace Server public override string ToString() => m_Name ?? GetType().Name; - public virtual void OnRegister() { } @@ -550,7 +548,8 @@ namespace Server { } - public virtual bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) => m.WalkRegion == null || AcceptsSpawnsFrom(m.WalkRegion); + public virtual bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation) => + m.WalkRegion == null || AcceptsSpawnsFrom(m.WalkRegion); public virtual void OnEnter(Mobile m) { @@ -591,17 +590,20 @@ namespace Server public virtual bool OnTarget(Mobile m, Target t, object o) => Parent?.OnTarget(m, t, o) != false; - public virtual bool OnCombatantChange(Mobile m, Mobile Old, Mobile New) => Parent?.OnCombatantChange(m, Old, New) != false; + public virtual bool OnCombatantChange(Mobile m, Mobile old, Mobile @new) => + Parent?.OnCombatantChange(m, old, @new) != false; public virtual bool AllowHousing(Mobile from, Point3D p) => Parent?.AllowHousing(from, p) != false; - public virtual bool SendInaccessibleMessage(Item item, Mobile from) => Parent?.SendInaccessibleMessage(item, from) == true; + public virtual bool SendInaccessibleMessage(Item item, Mobile from) => + Parent?.SendInaccessibleMessage(item, from) == true; public virtual bool CheckAccessibility(Item item, Mobile from) => Parent?.CheckAccessibility(item, from) != false; public virtual bool OnDecay(Item item) => Parent?.OnDecay(item) != false; - public virtual bool AllowHarmful(Mobile from, Mobile target) => Parent?.AllowHarmful(from, target) ?? Mobile.AllowHarmfulHandler?.Invoke(from, target) ?? true; + public virtual bool AllowHarmful(Mobile from, Mobile target) => + Parent?.AllowHarmful(from, target) ?? Mobile.AllowHarmfulHandler?.Invoke(from, target) ?? true; public virtual void OnCriminalAction(Mobile m, bool message) { @@ -635,7 +637,7 @@ namespace Server Parent?.OnSpeech(args); } - public virtual bool OnSkillUse(Mobile m, int Skill) => Parent?.OnSkillUse(m, Skill) != false; + public virtual bool OnSkillUse(Mobile m, int skill) => Parent?.OnSkillUse(m, skill) != false; public virtual bool OnBeginSpellCast(Mobile m, ISpell s) => Parent?.OnBeginSpellCast(m, s) != false; @@ -653,9 +655,9 @@ namespace Server Parent?.OnDeath(m); } - public virtual bool OnDamage(Mobile m, ref int Damage) => Parent?.OnDamage(m, ref Damage) != false; + public virtual bool OnDamage(Mobile m, ref int damage) => Parent?.OnDamage(m, ref damage) != false; - public virtual bool OnHeal(Mobile m, ref int Heal) => Parent?.OnHeal(m, ref Heal) != false; + public virtual bool OnHeal(Mobile m, ref int heal) => Parent?.OnHeal(m, ref heal) != false; public virtual bool OnDoubleClick(Mobile m, object o) => Parent?.OnDoubleClick(m, o) != false; @@ -676,11 +678,10 @@ namespace Server return m.AccessLevel > AccessLevel.Player ? StaffLogoutDelay : DefaultLogoutDelay; } - internal static bool CanMove(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation, Map map) { - Region oldRegion = m.Region; - Region newRegion = Find(newLocation, map); + var oldRegion = m.Region; + var newRegion = Find(newLocation, map); while (oldRegion != newRegion) { @@ -705,13 +706,13 @@ namespace Server if (oldRegion == null || oldRegion.Music != newRegion.Music) m.Send(PlayMusic.GetInstance(newRegion.Music)); } - Region oldR = oldRegion; - Region newR = newRegion; + var oldR = oldRegion; + var newR = newRegion; while (oldR != newR) { - int oldRChild = oldR?.ChildLevel ?? -1; - int newRChild = newR?.ChildLevel ?? -1; + var oldRChild = oldR?.ChildLevel ?? -1; + var newRChild = newR?.ChildLevel ?? -1; if (oldRChild >= newRChild) { @@ -727,7 +728,6 @@ namespace Server } } - internal static void Load() { if (!File.Exists("Data/Regions.xml")) @@ -738,10 +738,10 @@ namespace Server Console.Write("Regions: Loading..."); - XmlDocument doc = new XmlDocument(); + var doc = new XmlDocument(); doc.Load(Path.Combine(Core.BaseDirectory, "Data/Regions.xml")); - XmlElement root = doc["ServerRegions"]; + var root = doc["ServerRegions"]; if (root == null) { @@ -768,7 +768,7 @@ namespace Server { foreach (XmlElement xmlReg in xml.SelectNodes("region")) { - Type type = DefaultRegionType; + var type = DefaultRegionType; ReadType(xmlReg, "type", ref type, false); @@ -778,7 +778,7 @@ namespace Server continue; } - Region region = null; + Region region; try { region = (Region)ActivatorUtil.CreateInstance(type, xmlReg, map, parent); @@ -812,11 +812,12 @@ namespace Server return null; } - public static bool ReadString(XmlElement xml, string attribute, ref string value) => ReadString(xml, attribute, ref value, true); + public static bool ReadString(XmlElement xml, string attribute, ref string value) => + ReadString(xml, attribute, ref value, true); public static bool ReadString(XmlElement xml, string attribute, ref string value, bool mandatory) { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; @@ -825,11 +826,12 @@ namespace Server return true; } - public static bool ReadInt32(XmlElement xml, string attribute, ref int value) => ReadInt32(xml, attribute, ref value, true); + public static bool ReadInt32(XmlElement xml, string attribute, ref int value) => + ReadInt32(xml, attribute, ref value, true); public static bool ReadInt32(XmlElement xml, string attribute, ref int value, bool mandatory) { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; @@ -847,11 +849,12 @@ namespace Server return true; } - public static bool ReadBoolean(XmlElement xml, string attribute, ref bool value) => ReadBoolean(xml, attribute, ref value, true); + public static bool ReadBoolean(XmlElement xml, string attribute, ref bool value) => + ReadBoolean(xml, attribute, ref value, true); public static bool ReadBoolean(XmlElement xml, string attribute, ref bool value, bool mandatory) { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; @@ -869,11 +872,12 @@ namespace Server return true; } - public static bool ReadDateTime(XmlElement xml, string attribute, ref DateTime value) => ReadDateTime(xml, attribute, ref value, true); + public static bool ReadDateTime(XmlElement xml, string attribute, ref DateTime value) => + ReadDateTime(xml, attribute, ref value, true); public static bool ReadDateTime(XmlElement xml, string attribute, ref DateTime value, bool mandatory) { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; @@ -891,11 +895,12 @@ namespace Server return true; } - public static bool ReadTimeSpan(XmlElement xml, string attribute, ref TimeSpan value) => ReadTimeSpan(xml, attribute, ref value, true); + public static bool ReadTimeSpan(XmlElement xml, string attribute, ref TimeSpan value) => + ReadTimeSpan(xml, attribute, ref value, true); public static bool ReadTimeSpan(XmlElement xml, string attribute, ref TimeSpan value, bool mandatory) { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; @@ -913,17 +918,18 @@ namespace Server return true; } - public static bool ReadEnum(XmlElement xml, string attribute, ref T value) where T : struct => ReadEnum(xml, attribute, ref value, true); + public static bool ReadEnum(XmlElement xml, string attribute, ref T value) where T : struct => + ReadEnum(xml, attribute, ref value, true); public static bool ReadEnum(XmlElement xml, string attribute, ref T value, bool mandatory) where T : struct // We can't limit the where clause to Enums only { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; - Type type = typeof(T); + var type = typeof(T); if (type.IsEnum && Enum.TryParse(s, true, out T tempVal)) { @@ -939,7 +945,7 @@ namespace Server public static bool ReadMap(XmlElement xml, string attribute, ref Map value, bool mandatory) { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; @@ -957,11 +963,12 @@ namespace Server return true; } - public static bool ReadType(XmlElement xml, string attribute, ref Type value) => ReadType(xml, attribute, ref value, true); + public static bool ReadType(XmlElement xml, string attribute, ref Type value) => + ReadType(xml, attribute, ref value, true); public static bool ReadType(XmlElement xml, string attribute, ref Type value, bool mandatory) { - string s = GetAttribute(xml, attribute, mandatory); + var s = GetAttribute(xml, attribute, mandatory); if (s == null) return false; @@ -969,7 +976,7 @@ namespace Server Type type; try { - type = AssemblyHandler.FindFirstTypeForName(s, false); + type = AssemblyHandler.FindFirstTypeForName(s); } catch { @@ -993,8 +1000,8 @@ namespace Server { int x = 0, y = 0, z = 0; - bool xyOk = ReadInt32(xml, "x", ref x, mandatory) & ReadInt32(xml, "y", ref y, mandatory); - bool zOk = ReadInt32(xml, "z", ref z, mandatory && map == null); + var xyOk = ReadInt32(xml, "x", ref x, mandatory) & ReadInt32(xml, "y", ref y, mandatory); + var zOk = ReadInt32(xml, "z", ref z, mandatory && map == null); if (xyOk && (zOk || map != null)) { @@ -1008,12 +1015,15 @@ namespace Server return false; } - public static bool ReadRectangle3D(XmlElement xml, int defaultMinZ, int defaultMaxZ, ref Rectangle3D value) => ReadRectangle3D(xml, defaultMinZ, defaultMaxZ, ref value, true); + public static bool ReadRectangle3D(XmlElement xml, int defaultMinZ, int defaultMaxZ, out Rectangle3D value) => + ReadRectangle3D(xml, defaultMinZ, defaultMaxZ, out value, true); - public static bool ReadRectangle3D(XmlElement xml, int defaultMinZ, int defaultMaxZ, ref Rectangle3D value, + public static bool ReadRectangle3D(XmlElement xml, int defaultMinZ, int defaultMaxZ, out Rectangle3D value, bool mandatory) { int x1 = 0, y1 = 0, x2 = 0, y2 = 0; + var z1 = defaultMinZ; + var z2 = defaultMaxZ; if (xml.HasAttribute("x")) { @@ -1027,6 +1037,7 @@ namespace Server } else { + value = new Rectangle3D(new Point3D(x1, y1, z1), new Point3D(x2, y2, z2)); return false; } } @@ -1036,12 +1047,12 @@ namespace Server | !ReadInt32(xml, "y1", ref y1, mandatory) | !ReadInt32(xml, "x2", ref x2, mandatory) | !ReadInt32(xml, "y2", ref y2, mandatory)) + { + value = new Rectangle3D(new Point3D(x1, y1, z1), new Point3D(x2, y2, z2)); return false; + } } - int z1 = defaultMinZ; - int z2 = defaultMaxZ; - ReadInt32(xml, "zmin", ref z1, false); ReadInt32(xml, "zmax", ref z2, false); diff --git a/Projects/Server/Sector.cs b/Projects/Server/Sector.cs index 5713accbd..a5132a62a 100644 --- a/Projects/Server/Sector.cs +++ b/Projects/Server/Sector.cs @@ -35,7 +35,7 @@ namespace Server m_Rect = rect; } - public Region Region{ get; } + public Region Region { get; } public Rectangle3D Rect => m_Rect; @@ -44,7 +44,6 @@ namespace Server public bool Contains(Point3D loc) => m_Rect.Contains(loc); } - public class Sector { // TODO: Can we avoid this? @@ -83,11 +82,11 @@ namespace Server public bool Active => m_Active && Owner != Map.Internal; - public Map Owner{ get; } + public Map Owner { get; } - public int X{ get; } + public int X { get; } - public int Y{ get; } + public int Y { get; } private void Add(ref List list, T value) { @@ -110,7 +109,7 @@ namespace Server { if (oldValue != null && newValue != null) { - int index = list?.IndexOf(oldValue) ?? -1; + var index = list?.IndexOf(oldValue) ?? -1; if (index >= 0) list[index] = newValue; @@ -183,9 +182,9 @@ namespace Server { if (m_RegionRects != null) { - for (int i = m_RegionRects.Count - 1; i >= 0; i--) + for (var i = m_RegionRects.Count - 1; i >= 0; i--) { - RegionRect regRect = m_RegionRects[i]; + var regRect = m_RegionRects[i]; if (regRect.Region == region) m_RegionRects.RemoveAt(i); } @@ -200,9 +199,9 @@ namespace Server { if (m_Mobiles != null) { - List sandbox = new List(m_Mobiles); + var sandbox = new List(m_Mobiles); - foreach (Mobile mob in sandbox) mob.UpdateRegion(); + foreach (var mob in sandbox) mob.UpdateRegion(); } } @@ -221,11 +220,11 @@ namespace Server if (!Active && Owner != Map.Internal) { if (m_Items != null) - foreach (Item item in m_Items) + foreach (var item in m_Items) item.OnSectorActivate(); if (m_Mobiles != null) - foreach (Mobile mob in m_Mobiles) + foreach (var mob in m_Mobiles) mob.OnSectorActivate(); m_Active = true; @@ -237,11 +236,11 @@ namespace Server if (Active) { if (m_Items != null) - foreach (Item item in m_Items) + foreach (var item in m_Items) item.OnSectorDeactivate(); if (m_Mobiles != null) - foreach (Mobile mob in m_Mobiles) + foreach (var mob in m_Mobiles) mob.OnSectorDeactivate(); m_Active = false; diff --git a/Projects/Server/SecureTrade.cs b/Projects/Server/SecureTrade.cs index a1d3872e3..d412db917 100644 --- a/Projects/Server/SecureTrade.cs +++ b/Projects/Server/SecureTrade.cs @@ -18,16 +18,11 @@ * ***************************************************************************/ -#region References - using System; -using System.Collections.Generic; using Server.Accounting; using Server.Items; using Server.Network; -#endregion - namespace Server { public class SecureTrade @@ -39,11 +34,11 @@ namespace Server From = new SecureTradeInfo(this, from, new SecureTradeContainer(this)); To = new SecureTradeInfo(this, to, new SecureTradeContainer(this)); - bool from6017 = from.NetState?.ContainerGridLines == true; - bool to6017 = to.NetState?.ContainerGridLines == true; + var from6017 = from.NetState?.ContainerGridLines == true; + var to6017 = to.NetState?.ContainerGridLines == true; - bool from704565 = from.NetState?.NewSecureTrading == true; - bool to704565 = to.NetState?.NewSecureTrading == true; + var from704565 = from.NetState?.NewSecureTrading == true; + var to704565 = to.NetState?.NewSecureTrading == true; from.Send(new MobileStatus(from, to)); from.Send(new UpdateSecureTrade(From.Container, false, false)); @@ -91,22 +86,22 @@ namespace Server to.Account.TotalPlat)); } - public SecureTradeInfo From{ get; } + public SecureTradeInfo From { get; } - public SecureTradeInfo To{ get; } + public SecureTradeInfo To { get; } - public bool Valid{ get; private set; } + public bool Valid { get; private set; } public void Cancel() { if (!Valid) return; - List list = From.Container.Items; + var list = From.Container.Items; - for (int i = list.Count - 1; i >= 0; --i) + for (var i = list.Count - 1; i >= 0; --i) if (i < list.Count) { - Item item = list[i]; + var item = list[i]; if (item == From.VirtualCheck) continue; @@ -117,10 +112,10 @@ namespace Server list = To.Container.Items; - for (int i = list.Count - 1; i >= 0; --i) + for (var i = list.Count - 1; i >= 0; --i) if (i < list.Count) { - Item item = list[i]; + var item = list[i]; if (item == To.VirtualCheck) continue; @@ -141,7 +136,7 @@ namespace Server Valid = false; - NetState ns = From.Mobile.NetState; + var ns = From.Mobile.NetState; ns?.RemoveTrade(this); @@ -167,8 +162,8 @@ namespace Server { if (left.Mobile.NetState?.NewSecureTrading == true) { - int plat = left.Mobile.Account.TotalPlat; - int gold = left.Mobile.Account.TotalGold; + var plat = left.Mobile.Account.TotalPlat; + var gold = left.Mobile.Account.TotalGold; left.Mobile.Send(new UpdateSecureTrade(left.Container, TradeFlag.UpdateLedger, gold, plat)); } @@ -183,14 +178,14 @@ namespace Server if (!From.IsDisposed && From.Accepted && !To.IsDisposed && To.Accepted) { - List list = From.Container.Items; + var list = From.Container.Items; - bool allowed = true; + var allowed = true; - for (int i = list.Count - 1; allowed && i >= 0; --i) + for (var i = list.Count - 1; allowed && i >= 0; --i) if (i < list.Count) { - Item item = list[i]; + var item = list[i]; if (item == From.VirtualCheck) continue; @@ -199,10 +194,10 @@ namespace Server list = To.Container.Items; - for (int i = list.Count - 1; allowed && i >= 0; --i) + for (var i = list.Count - 1; allowed && i >= 0; --i) if (i < list.Count) { - Item item = list[i]; + var item = list[i]; if (item == To.VirtualCheck) continue; @@ -213,8 +208,8 @@ namespace Server { if (From.Mobile.Account != null) { - int totalPlat = From.Mobile.Account.TotalPlat; - int totalGold = From.Mobile.Account.TotalGold; + var totalPlat = From.Mobile.Account.TotalPlat; + var totalGold = From.Mobile.Account.TotalGold; if (totalPlat < From.Plat || totalGold < From.Gold) { @@ -225,8 +220,8 @@ namespace Server if (To.Mobile.Account != null) { - int totalPlat = To.Mobile.Account.TotalPlat; - int totalGold = To.Mobile.Account.TotalGold; + var totalPlat = To.Mobile.Account.TotalPlat; + var totalGold = To.Mobile.Account.TotalGold; if (totalPlat < To.Plat || totalGold < To.Gold) { @@ -252,10 +247,10 @@ namespace Server list = From.Container.Items; - for (int i = list.Count - 1; i >= 0; --i) + for (var i = list.Count - 1; i >= 0; --i) if (i < list.Count) { - Item item = list[i]; + var item = list[i]; if (item == From.VirtualCheck) continue; @@ -266,10 +261,10 @@ namespace Server list = To.Container.Items; - for (int i = list.Count - 1; i >= 0; --i) + for (var i = list.Count - 1; i >= 0; --i) if (i < list.Count) { - Item item = list[i]; + var item = list[i]; if (item == To.VirtualCheck) continue; @@ -292,28 +287,28 @@ namespace Server int fromPlatSend = 0, fromGoldSend = 0, fromPlatRecv = 0, fromGoldRecv = 0; int toPlatSend = 0, toGoldSend = 0, toPlatRecv = 0, toGoldRecv = 0; - if (From.Plat > 0 & From.Mobile.Account.WithdrawPlat(From.Plat)) + if ((From.Plat > 0) & From.Mobile.Account.WithdrawPlat(From.Plat)) { fromPlatSend = From.Plat; if (To.Mobile.Account.DepositPlat(From.Plat)) toPlatRecv = fromPlatSend; } - if (From.Gold > 0 & From.Mobile.Account.WithdrawGold(From.Gold)) + if ((From.Gold > 0) & From.Mobile.Account.WithdrawGold(From.Gold)) { fromGoldSend = From.Gold; if (To.Mobile.Account.DepositGold(From.Gold)) toGoldRecv = fromGoldSend; } - if (To.Plat > 0 & To.Mobile.Account.WithdrawPlat(To.Plat)) + if ((To.Plat > 0) & To.Mobile.Account.WithdrawPlat(To.Plat)) { toPlatSend = To.Plat; if (From.Mobile.Account.DepositPlat(To.Plat)) fromPlatRecv = toPlatSend; } - if (To.Gold > 0 & To.Mobile.Account.WithdrawGold(To.Gold)) + if ((To.Gold > 0) & To.Mobile.Account.WithdrawGold(To.Gold)) { toGoldSend = To.Gold; @@ -368,10 +363,10 @@ namespace Server Container.DropItem(VirtualCheck); } - public SecureTrade Owner{ get; private set; } - public Mobile Mobile{ get; private set; } - public SecureTradeContainer Container{ get; private set; } - public VirtualCheck VirtualCheck{ get; private set; } + public SecureTrade Owner { get; private set; } + public Mobile Mobile { get; private set; } + public SecureTradeContainer Container { get; private set; } + public VirtualCheck VirtualCheck { get; private set; } public int Gold { @@ -385,9 +380,9 @@ namespace Server set => VirtualCheck.Plat = value; } - public bool Accepted{ get; set; } + public bool Accepted { get; set; } - public bool IsDisposed{ get; private set; } + public bool IsDisposed { get; private set; } public void Dispose() { diff --git a/Projects/Server/Serial.cs b/Projects/Server/Serial.cs index b7d7678e9..c518816fd 100644 --- a/Projects/Server/Serial.cs +++ b/Projects/Server/Serial.cs @@ -22,14 +22,14 @@ using System; namespace Server { - public struct Serial : IComparable, IComparable + public readonly struct Serial : IComparable, IComparable, IEquatable { public static readonly Serial MinusOne = new Serial(0xFFFFFFFF); public static readonly Serial Zero = new Serial(0); - public static Serial LastMobile{ get; private set; } = Zero; + public static Serial LastMobile { get; private set; } = Zero; - public static Serial LastItem{ get; private set; } = 0x40000000; + public static Serial LastItem { get; private set; } = 0x40000000; public static Serial NewMobile { @@ -57,7 +57,7 @@ namespace Server private Serial(uint serial) => Value = serial; - public uint Value{ get; } + public uint Value { get; } public bool IsMobile => Value > 0 && Value < 0x40000000; @@ -97,5 +97,9 @@ namespace Server public static implicit operator uint(Serial a) => a.Value; public static implicit operator Serial(uint a) => new Serial(a); + + public bool Equals(Serial other) => Value == other.Value; + + public int ToInt32() => (int)Value; } } diff --git a/Projects/Server/Serialization/AsyncWriter.cs b/Projects/Server/Serialization/AsyncWriter.cs index 7112ea59c..222e70edd 100644 --- a/Projects/Server/Serialization/AsyncWriter.cs +++ b/Projects/Server/Serialization/AsyncWriter.cs @@ -1,22 +1,23 @@ -/*************************************************************************** - * Serialization.cs - * ------------------- - * begin : May 1, 2002 - * copyright : (C) The RunUO Software Team - * email : info@runuo.com - * - * $Id$ - * - ***************************************************************************/ - -/*************************************************************************** - * - * 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 2 of the License, or - * (at your option) any later version. - * - ***************************************************************************/ +/************************************************************************* + * ModernUO * + * Copyright (C) 2020 - ModernUO Development Team * + * Email: hi@modernuo.com * + * File: AsyncWriter.cs * + * Created: 2020/12/30 - Updated: 2020/04/25 * + * * + * 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. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + *************************************************************************/ using System; using System.Collections.Generic; @@ -29,7 +30,7 @@ namespace Server { public sealed class AsyncWriter : IGenericWriter { - private readonly int BufferSize; + private readonly int m_BufferSize; private BinaryWriter m_Bin; private bool m_Closed; private readonly FileStream m_File; @@ -40,26 +41,26 @@ namespace Server private Thread m_WorkerThread; private readonly Queue m_WriteQueue; - private readonly bool PrefixStrings; + private readonly bool m_PrefixStrings; public AsyncWriter(string filename, bool prefix) - : this(filename, 1048576, prefix) //1 mb buffer + : this(filename, 1048576, prefix) // 1 mb buffer { } public AsyncWriter(string filename, int buffSize, bool prefix) { - PrefixStrings = prefix; + m_PrefixStrings = prefix; m_Closed = false; m_WriteQueue = new Queue(); - BufferSize = buffSize; + m_BufferSize = buffSize; m_File = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None); - m_Mem = new MemoryStream(BufferSize + 1024); + m_Mem = new MemoryStream(m_BufferSize + 1024); m_Bin = new BinaryWriter(m_Mem, Utility.UTF8WithEncoding); } - public static int ThreadCount{ get; private set; } + public static int ThreadCount { get; private set; } public MemoryStream MemStream { @@ -95,13 +96,13 @@ namespace Server private void OnWrite() { - long curlen = m_Mem.Length; + var curlen = m_Mem.Length; m_CurPos += curlen - m_LastPos; m_LastPos = curlen; - if (curlen >= BufferSize) + if (curlen >= m_BufferSize) { Enqueue(m_Mem); - m_Mem = new MemoryStream(BufferSize + 1024); + m_Mem = new MemoryStream(m_BufferSize + 1024); m_Bin = new BinaryWriter(m_Mem, Utility.UTF8WithEncoding); m_LastPos = 0; } @@ -121,7 +122,7 @@ namespace Server public void Write(string value) { - if (PrefixStrings) + if (m_PrefixStrings) { if (value == null) { @@ -143,8 +144,8 @@ namespace Server public void WriteDeltaTime(DateTime value) { - long ticks = value.Ticks; - long now = DateTime.UtcNow.Ticks; + var ticks = value.Ticks; + var now = DateTime.UtcNow.Ticks; TimeSpan d; @@ -199,7 +200,7 @@ namespace Server public void WriteEncodedInt(int value) { - uint v = (uint)value; + var v = (uint)value; while (v >= 0x80) { @@ -269,6 +270,7 @@ namespace Server m_Bin.Write(value, 0, length); OnWrite(); } + public void Write(sbyte value) { m_Bin.Write(value); @@ -351,7 +353,7 @@ namespace Server if (value == null) Write(0); else - Write(value.Id); + Write(value.Serial); } public void WriteItem(T value) where T : Item @@ -387,7 +389,7 @@ namespace Server public void WriteItemList(List list, bool tidy) where T : Item { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -395,7 +397,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -410,7 +412,7 @@ namespace Server Write(set.Count); - foreach (Item item in set) Write(item); + foreach (var item in set) Write(item); } public void WriteItemSet(HashSet set) where T : Item @@ -424,7 +426,7 @@ namespace Server Write(set.Count); - foreach (T item in set) Write(item); + foreach (var item in set) Write(item); } public void Write(List list) @@ -435,7 +437,7 @@ namespace Server public void Write(List list, bool tidy) { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -443,7 +445,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -455,7 +457,7 @@ namespace Server public void WriteMobileList(List list, bool tidy) where T : Mobile { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -463,7 +465,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -478,7 +480,7 @@ namespace Server Write(set.Count); - foreach (Mobile mob in set) Write(mob); + foreach (var mob in set) Write(mob); } public void WriteMobileSet(HashSet set) where T : Mobile @@ -492,7 +494,7 @@ namespace Server Write(set.Count); - foreach (T mob in set) Write(mob); + foreach (var mob in set) Write(mob); } public void Write(List list) @@ -503,7 +505,7 @@ namespace Server public void Write(List list, bool tidy) { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Disbanded) list.RemoveAt(i); else @@ -511,7 +513,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -523,7 +525,7 @@ namespace Server public void WriteGuildList(List list, bool tidy) where T : BaseGuild { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Disbanded) list.RemoveAt(i); else @@ -531,7 +533,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -546,7 +548,7 @@ namespace Server Write(set.Count); - foreach (BaseGuild guild in set) Write(guild); + foreach (var guild in set) Write(guild); } public void WriteGuildSet(HashSet set) where T : BaseGuild @@ -560,7 +562,7 @@ namespace Server Write(set.Count); - foreach (T guild in set) Write(guild); + foreach (var guild in set) Write(guild); } private class WorkerThread diff --git a/Projects/Server/Serialization/BinaryFileReader.cs b/Projects/Server/Serialization/BinaryFileReader.cs index 2abbc1d2f..7caf6d87e 100644 --- a/Projects/Server/Serialization/BinaryFileReader.cs +++ b/Projects/Server/Serialization/BinaryFileReader.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: BinaryFileReader.cs * * Created: 2019/12/30 - Updated: 2020/01/18 * @@ -46,8 +46,8 @@ namespace Server public DateTime ReadDeltaTime() { - long ticks = m_File.ReadInt64(); - long now = DateTime.UtcNow.Ticks; + var ticks = m_File.ReadInt64(); + var now = DateTime.UtcNow.Ticks; if (ticks > 0 && ticks + now < 0) return DateTime.MaxValue; @@ -85,8 +85,8 @@ namespace Server public DateTimeOffset ReadDateTimeOffset() { - long ticks = m_File.ReadInt64(); - TimeSpan offset = new TimeSpan(m_File.ReadInt64()); + var ticks = m_File.ReadInt64(); + var offset = new TimeSpan(m_File.ReadInt64()); return new DateTimeOffset(ticks, offset); } @@ -151,13 +151,13 @@ namespace Server public List ReadStrongItemList() where T : Item { - int count = ReadInt(); + var count = ReadInt(); if (count > 0) { - List list = new List(count); + var list = new List(count); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (ReadItem() is T item) list.Add(item); @@ -171,13 +171,13 @@ namespace Server public HashSet ReadItemSet() where T : Item { - int count = ReadInt(); + var count = ReadInt(); if (count > 0) { - HashSet set = new HashSet(); + var set = new HashSet(); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (ReadItem() is T item) set.Add(item); @@ -191,13 +191,13 @@ namespace Server public List ReadStrongMobileList() where T : Mobile { - int count = ReadInt(); + var count = ReadInt(); if (count > 0) { - List list = new List(count); + var list = new List(count); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (ReadMobile() is T m) list.Add(m); @@ -211,13 +211,13 @@ namespace Server public HashSet ReadMobileSet() where T : Mobile { - int count = ReadInt(); + var count = ReadInt(); if (count > 0) { - HashSet set = new HashSet(); + var set = new HashSet(); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (ReadMobile() is T item) set.Add(item); @@ -231,13 +231,13 @@ namespace Server public List ReadStrongGuildList() where T : BaseGuild { - int count = ReadInt(); + var count = ReadInt(); if (count > 0) { - List list = new List(count); + var list = new List(count); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (ReadGuild() is T g) list.Add(g); @@ -251,13 +251,13 @@ namespace Server public HashSet ReadGuildSet() where T : BaseGuild { - int count = ReadInt(); + var count = ReadInt(); if (count > 0) { - HashSet set = new HashSet(); + var set = new HashSet(); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) if (ReadGuild() is T item) set.Add(item); @@ -271,5 +271,4 @@ namespace Server public bool End() => m_File.PeekChar() == -1; } - } diff --git a/Projects/Server/Serialization/BinaryFileWriter.cs b/Projects/Server/Serialization/BinaryFileWriter.cs index bd8bc9783..1bcea6083 100644 --- a/Projects/Server/Serialization/BinaryFileWriter.cs +++ b/Projects/Server/Serialization/BinaryFileWriter.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: BinaryFileWriter.cs * * Created: 2019/12/30 - Updated: 2020/01/18 * @@ -22,8 +22,8 @@ using System; using System.Collections.Generic; using System.IO; -using System.Text; using System.Net; +using System.Text; using Server.Guilds; namespace Server @@ -45,11 +45,11 @@ namespace Server private long m_Position; private readonly char[] m_SingleCharBuffer = new char[1]; - private readonly bool PrefixStrings; + private readonly bool m_PrefixStrings; public BinaryFileWriter(Stream strm, bool prefixStr) { - PrefixStrings = prefixStr; + m_PrefixStrings = prefixStr; m_Encoding = Utility.UTF8; m_Buffer = new byte[BufferSize]; m_File = strm; @@ -57,7 +57,7 @@ namespace Server public BinaryFileWriter(string filename, bool prefixStr) { - PrefixStrings = prefixStr; + m_PrefixStrings = prefixStr; m_Buffer = new byte[BufferSize]; m_File = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None); m_Encoding = Utility.UTF8WithEncoding; @@ -99,7 +99,7 @@ namespace Server public void WriteEncodedInt(int value) { - uint v = (uint)value; + var v = (uint)value; while (v >= 0x80) { @@ -118,7 +118,7 @@ namespace Server internal void InternalWriteString(string value) { - int length = m_Encoding.GetByteCount(value); + var length = m_Encoding.GetByteCount(value); WriteEncodedInt(length); @@ -130,13 +130,13 @@ namespace Server if (length > LargeByteBufferSize) { - int current = 0; - int charsLeft = value.Length; + var current = 0; + var charsLeft = value.Length; while (charsLeft > 0) { - int charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft; - int byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0); + var charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft; + var byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0); if (m_Index + byteLength > m_Buffer.Length) Flush(); @@ -150,7 +150,7 @@ namespace Server } else { - int byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0); + var byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0); if (m_Index + byteLength > m_Buffer.Length) Flush(); @@ -162,7 +162,7 @@ namespace Server public void Write(string value) { - if (PrefixStrings) + if (m_PrefixStrings) { if (value == null) { @@ -200,8 +200,8 @@ namespace Server public void WriteDeltaTime(DateTime value) { - long ticks = value.Ticks; - long now = DateTime.UtcNow.Ticks; + var ticks = value.Ticks; + var now = DateTime.UtcNow.Ticks; TimeSpan d; @@ -229,9 +229,9 @@ namespace Server public void Write(decimal value) { - int[] bits = decimal.GetBits(value); + var bits = decimal.GetBits(value); - for (int i = 0; i < bits.Length; ++i) + for (var i = 0; i < bits.Length; ++i) Write(bits[i]); } @@ -344,7 +344,7 @@ namespace Server m_SingleCharBuffer[0] = value; - int byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index); + var byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index); m_Index += byteCount; } @@ -369,6 +369,7 @@ namespace Server Buffer.BlockCopy(value, 0, m_Buffer, m_Index, length); m_Index += length; } + public void Write(sbyte value) { if (m_Index + 1 > m_Buffer.Length) @@ -455,7 +456,7 @@ namespace Server if (value == null) Write(0); else - Write(value.Id); + Write(value.Serial); } public void WriteItem(T value) where T : Item @@ -491,7 +492,7 @@ namespace Server public void WriteItemList(List list, bool tidy) where T : Item { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i]?.Deleted != false) list.RemoveAt(i); else @@ -499,7 +500,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -514,7 +515,7 @@ namespace Server Write(set.Count); - foreach (Item item in set) Write(item); + foreach (var item in set) Write(item); } public void WriteItemSet(HashSet set) where T : Item @@ -528,7 +529,7 @@ namespace Server Write(set.Count); - foreach (T item in set) Write(item); + foreach (var item in set) Write(item); } public void Write(List list) @@ -539,7 +540,7 @@ namespace Server public void Write(List list, bool tidy) { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -547,7 +548,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -559,7 +560,7 @@ namespace Server public void WriteMobileList(List list, bool tidy) where T : Mobile { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -567,7 +568,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -582,7 +583,7 @@ namespace Server Write(set.Count); - foreach (Mobile mob in set) Write(mob); + foreach (var mob in set) Write(mob); } public void WriteMobileSet(HashSet set) where T : Mobile @@ -596,7 +597,7 @@ namespace Server Write(set.Count); - foreach (T mob in set) Write(mob); + foreach (var mob in set) Write(mob); } public void Write(List list) @@ -607,7 +608,7 @@ namespace Server public void Write(List list, bool tidy) { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Disbanded) list.RemoveAt(i); else @@ -615,7 +616,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -627,7 +628,7 @@ namespace Server public void WriteGuildList(List list, bool tidy) where T : BaseGuild { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Disbanded) list.RemoveAt(i); else @@ -635,7 +636,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -650,7 +651,7 @@ namespace Server Write(set.Count); - foreach (BaseGuild guild in set) Write(guild); + foreach (var guild in set) Write(guild); } public void WriteGuildSet(HashSet set) where T : BaseGuild @@ -664,8 +665,7 @@ namespace Server Write(set.Count); - foreach (T guild in set) Write(guild); + foreach (var guild in set) Write(guild); } } - } diff --git a/Projects/Server/Serialization/BufferWriter.cs b/Projects/Server/Serialization/BufferWriter.cs index e2e06323c..9b765a6bb 100644 --- a/Projects/Server/Serialization/BufferWriter.cs +++ b/Projects/Server/Serialization/BufferWriter.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: BufferWriter.cs * * Created: 2019/12/30 - Updated: 2020/01/18 * @@ -21,8 +21,8 @@ using System; using System.Collections.Generic; -using System.Text; using System.Net; +using System.Text; using Server.Guilds; namespace Server @@ -41,11 +41,11 @@ namespace Server private int m_MaxBufferChars; private readonly char[] m_SingleCharBuffer = new char[1]; - private readonly bool PrefixStrings; + private readonly bool m_PrefixStrings; public BufferWriter(bool prefixStr) { - PrefixStrings = prefixStr; + m_PrefixStrings = prefixStr; m_Encoding = Utility.UTF8; m_Buffer = new byte[BufferSize]; } @@ -59,6 +59,7 @@ namespace Server public void Close() { } + public void Flush() { m_Index = 0; @@ -66,14 +67,14 @@ namespace Server private void Expand() { - byte[] newBuffer = new byte[BufferSize * 2]; + var newBuffer = new byte[BufferSize * 2]; Buffer.BlockCopy(m_Buffer, 0, newBuffer, 0, m_Buffer.Length); m_Buffer = newBuffer; } public void WriteEncodedInt(int value) { - uint v = (uint)value; + var v = (uint)value; while (v >= 0x80) { @@ -92,7 +93,7 @@ namespace Server internal void InternalWriteString(string value) { - int length = m_Encoding.GetByteCount(value); + var length = m_Encoding.GetByteCount(value); WriteEncodedInt(length); @@ -104,13 +105,13 @@ namespace Server if (length > LargeByteBufferSize) { - int current = 0; - int charsLeft = value.Length; + var current = 0; + var charsLeft = value.Length; while (charsLeft > 0) { - int charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft; - int byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0); + var charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft; + var byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0); if (m_Index + byteLength > m_Buffer.Length) Expand(); @@ -124,7 +125,7 @@ namespace Server } else { - int byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0); + var byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0); if (m_Index + byteLength > m_Buffer.Length) Expand(); @@ -136,7 +137,7 @@ namespace Server public void Write(string value) { - if (PrefixStrings) + if (m_PrefixStrings) { if (value == null) { @@ -174,8 +175,8 @@ namespace Server public void WriteDeltaTime(DateTime value) { - long ticks = value.Ticks; - long now = DateTime.UtcNow.Ticks; + var ticks = value.Ticks; + var now = DateTime.UtcNow.Ticks; TimeSpan d; @@ -203,9 +204,9 @@ namespace Server public void Write(decimal value) { - int[] bits = decimal.GetBits(value); + var bits = decimal.GetBits(value); - for (int i = 0; i < bits.Length; ++i) + for (var i = 0; i < bits.Length; ++i) Write(bits[i]); } @@ -318,7 +319,7 @@ namespace Server m_SingleCharBuffer[0] = value; - int byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index); + var byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, m_Index); m_Index += byteCount; } @@ -343,6 +344,7 @@ namespace Server Buffer.BlockCopy(value, 0, m_Buffer, m_Index, length); m_Index += length; } + public void Write(sbyte value) { if (m_Index + 1 > m_Buffer.Length) @@ -420,7 +422,7 @@ namespace Server if (value == null) Write(0); else - Write(value.Id); + Write(value.Serial); } public void WriteItem(T value) where T : Item @@ -456,7 +458,7 @@ namespace Server public void WriteItemList(List list, bool tidy) where T : Item { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -464,7 +466,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -479,7 +481,7 @@ namespace Server Write(set.Count); - foreach (Item item in set) Write(item); + foreach (var item in set) Write(item); } public void WriteItemSet(HashSet set) where T : Item @@ -493,7 +495,7 @@ namespace Server Write(set.Count); - foreach (T item in set) Write(item); + foreach (var item in set) Write(item); } public void Write(List list) @@ -504,7 +506,7 @@ namespace Server public void Write(List list, bool tidy) { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -512,7 +514,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -524,7 +526,7 @@ namespace Server public void WriteMobileList(List list, bool tidy) where T : Mobile { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Deleted) list.RemoveAt(i); else @@ -532,7 +534,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -547,7 +549,7 @@ namespace Server Write(set.Count); - foreach (Mobile mob in set) Write(mob); + foreach (var mob in set) Write(mob); } public void WriteMobileSet(HashSet set) where T : Mobile @@ -561,7 +563,7 @@ namespace Server Write(set.Count); - foreach (T mob in set) Write(mob); + foreach (var mob in set) Write(mob); } public void Write(List list) @@ -572,7 +574,7 @@ namespace Server public void Write(List list, bool tidy) { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Disbanded) list.RemoveAt(i); else @@ -580,7 +582,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -592,7 +594,7 @@ namespace Server public void WriteGuildList(List list, bool tidy) where T : BaseGuild { if (tidy) - for (int i = 0; i < list.Count;) + for (var i = 0; i < list.Count;) if (list[i].Disbanded) list.RemoveAt(i); else @@ -600,7 +602,7 @@ namespace Server Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) Write(list[i]); } @@ -615,7 +617,7 @@ namespace Server Write(set.Count); - foreach (BaseGuild guild in set) Write(guild); + foreach (var guild in set) Write(guild); } public void WriteGuildSet(HashSet set) where T : BaseGuild @@ -629,7 +631,7 @@ namespace Server Write(set.Count); - foreach (T guild in set) Write(guild); + foreach (var guild in set) Write(guild); } public void WriteTo(IGenericWriter writer) diff --git a/Projects/Server/Serialization/IGenericReader.cs b/Projects/Server/Serialization/IGenericReader.cs index 125426a82..8bff436f6 100644 --- a/Projects/Server/Serialization/IGenericReader.cs +++ b/Projects/Server/Serialization/IGenericReader.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: IGenericReader.cs * * Created: 2019/12/30 - Updated: 2020/01/18 * diff --git a/Projects/Server/Serialization/IGenericWriter.cs b/Projects/Server/Serialization/IGenericWriter.cs index ba59ac051..0763165e3 100644 --- a/Projects/Server/Serialization/IGenericWriter.cs +++ b/Projects/Server/Serialization/IGenericWriter.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: IGenericWriter.cs * * Created: 2019/12/30 - Updated: 2020/01/18 * diff --git a/Projects/Server/Serialization/ISerializable.cs b/Projects/Server/Serialization/ISerializable.cs index 17a3df60a..13a82b068 100644 --- a/Projects/Server/Serialization/ISerializable.cs +++ b/Projects/Server/Serialization/ISerializable.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: ISerializable.cs * * Created: 2019/12/30 - Updated: 2020/01/18 * @@ -24,8 +24,8 @@ namespace Server public interface ISerializable { BufferWriter SaveBuffer { get; } - int TypeReference { get; } - uint SerialIdentity { get; } + int TypeRef { get; } + Serial Serial { get; } void Serialize(); void Serialize(IGenericWriter writer); } diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj index 8b9200a2f..629e33fbc 100644 --- a/Projects/Server/Server.csproj +++ b/Projects/Server/Server.csproj @@ -16,13 +16,38 @@ true x64 8.0 - ..\..\Distribution - ..\..\Distribution - ..\..\Distribution + $(SolutionDir)\Distribution + $(SolutionDir)\Distribution + $(SolutionDir)\Distribution true true + false + Debug;Release;Analyze + + + + + + + + + + + + + + + + + + + + + + + TRACE;DEBUG false @@ -30,6 +55,12 @@ true + + true + true + true + $(SolutionDir)\Rules.ruleset + libdrng.dll @@ -55,4 +86,13 @@ + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/Projects/Server/Skills.cs b/Projects/Server/Skills.cs index f9b44c370..805709594 100644 --- a/Projects/Server/Skills.cs +++ b/Projects/Server/Skills.cs @@ -113,39 +113,39 @@ namespace Server switch (version) { case 0: - { - m_Base = reader.ReadUShort(); - m_Cap = reader.ReadUShort(); - Lock = (SkillLock)reader.ReadByte(); - - break; - } - case 0xFF: - { - m_Base = 0; - m_Cap = 1000; - Lock = SkillLock.Up; - - break; - } - default: - { - if ((version & 0xC0) == 0x00) { - if ((version & 0x1) != 0) - m_Base = reader.ReadUShort(); + m_Base = reader.ReadUShort(); + m_Cap = reader.ReadUShort(); + Lock = (SkillLock)reader.ReadByte(); - if ((version & 0x2) != 0) - m_Cap = reader.ReadUShort(); - else - m_Cap = 1000; - - if ((version & 0x4) != 0) - Lock = (SkillLock)reader.ReadByte(); + break; } + case 0xFF: + { + m_Base = 0; + m_Cap = 1000; + Lock = SkillLock.Up; - break; - } + break; + } + default: + { + if ((version & 0xC0) == 0x00) + { + if ((version & 0x1) != 0) + m_Base = reader.ReadUShort(); + + if ((version & 0x2) != 0) + m_Cap = reader.ReadUShort(); + else + m_Cap = 1000; + + if ((version & 0x4) != 0) + Lock = (SkillLock)reader.ReadByte(); + } + + break; + } } if (Lock < SkillLock.Up || Lock > SkillLock.Locked) @@ -164,7 +164,7 @@ namespace Server Lock = skillLock; } - public Skills Owner{ get; } + public Skills Owner { get; } public SkillName SkillName => (SkillName)Info.SkillID; @@ -173,10 +173,10 @@ namespace Server [CommandProperty(AccessLevel.Counselor)] public string Name => Info.Name; - public SkillInfo Info{ get; } + public SkillInfo Info { get; } [CommandProperty(AccessLevel.Counselor)] - public SkillLock Lock{ get; private set; } + public SkillLock Lock { get; private set; } public int BaseFixedPoint { @@ -188,7 +188,7 @@ namespace Server else if (value >= 0x10000) value = 0xFFFF; - ushort sv = (ushort)value; + var sv = (ushort)value; int oldBase = m_Base; @@ -200,7 +200,7 @@ namespace Server Owner.OnSkillChange(this); - Mobile m = Owner.Owner; + var m = Owner.Owner; m?.OnSkillChange(SkillName, (double)oldBase / 10); } @@ -224,7 +224,7 @@ namespace Server else if (value >= 0x10000) value = 0xFFFF; - ushort sv = (ushort)value; + var sv = (ushort)value; if (m_Cap != sv) { @@ -242,7 +242,7 @@ namespace Server set => CapFixedPoint = (int)(value * 10.0); } - public static bool UseStatMods{ get; set; } + public static bool UseStatMods { get; set; } public int Fixed => (int)(Value * 10); @@ -251,10 +251,10 @@ namespace Server { get { - //There has to be this distinction between the racial values and not to account for gaining skills and these skills aren't displayed nor Totaled up. - double value = NonRacialValue; + // There has to be this distinction between the racial values and not to account for gaining skills and these skills aren't displayed nor Totaled up. + var value = NonRacialValue; - double raceBonus = Owner.Owner.RacialSkillBonus; + var raceBonus = Owner.Owner.RacialSkillBonus; if (raceBonus > value) value = raceBonus; @@ -268,34 +268,34 @@ namespace Server { get { - double baseValue = Base; - double inv = 100.0 - baseValue; + var baseValue = Base; + var inv = 100.0 - baseValue; if (inv < 0.0) inv = 0.0; inv /= 100.0; - double statsOffset = (UseStatMods ? Owner.Owner.Str : Owner.Owner.RawStr) * Info.StrScale + - (UseStatMods ? Owner.Owner.Dex : Owner.Owner.RawDex) * Info.DexScale + - (UseStatMods ? Owner.Owner.Int : Owner.Owner.RawInt) * Info.IntScale; - double statTotal = Info.StatTotal * inv; + var statsOffset = (UseStatMods ? Owner.Owner.Str : Owner.Owner.RawStr) * Info.StrScale + + (UseStatMods ? Owner.Owner.Dex : Owner.Owner.RawDex) * Info.DexScale + + (UseStatMods ? Owner.Owner.Int : Owner.Owner.RawInt) * Info.IntScale; + var statTotal = Info.StatTotal * inv; statsOffset *= inv; if (statsOffset > statTotal) statsOffset = statTotal; - double value = baseValue + statsOffset; + var value = baseValue + statsOffset; Owner.Owner.ValidateSkillMods(); - List mods = Owner.Owner.SkillMods; + var mods = Owner.Owner.SkillMods; double bonusObey = 0.0, bonusNotObey = 0.0; - for (int i = 0; i < mods.Count; ++i) + for (var i = 0; i < mods.Count; ++i) { - SkillMod mod = mods[i]; + var mod = mods[i]; if (mod.Skill == (SkillName)Info.SkillID) { @@ -347,7 +347,7 @@ namespace Server } else { - int flags = 0x0; + var flags = 0x0; if (m_Base != 0) flags |= 0x1; @@ -397,31 +397,32 @@ namespace Server StatTotal = strScale + dexScale + intScale; } - public SkillUseCallback Callback{ get; set; } + public SkillUseCallback Callback { get; set; } - public int SkillID{ get; } + public int SkillID { get; } - public string Name{ get; set; } + public string Name { get; set; } - public string Title{ get; set; } + public string Title { get; set; } - public double StrScale{ get; set; } + public double StrScale { get; set; } - public double DexScale{ get; set; } + public double DexScale { get; set; } - public double IntScale{ get; set; } + public double IntScale { get; set; } - public double StatTotal{ get; set; } + public double StatTotal { get; set; } - public double StrGain{ get; set; } + public double StrGain { get; set; } - public double DexGain{ get; set; } + public double DexGain { get; set; } - public double IntGain{ get; set; } + public double IntGain { get; set; } - public double GainFactor{ get; set; } + public double GainFactor { get; set; } - public static SkillInfo[] Table{ get; set; } = { + public static SkillInfo[] Table { get; set; } = + { new SkillInfo(0, "Alchemy", 0.0, 5.0, 5.0, "Alchemist", null, 0.0, 0.5, 0.5, 1.0), new SkillInfo(1, "Anatomy", 0.0, 0.0, 0.0, "Biologist", null, 0.15, 0.15, 0.7, 1.0), new SkillInfo(2, "Animal Lore", 0.0, 0.0, 0.0, "Naturalist", null, 0.0, 0.0, 1.0, 1.0), @@ -494,80 +495,81 @@ namespace Server Owner = owner; Cap = 7000; - SkillInfo[] info = SkillInfo.Table; + var info = SkillInfo.Table; m_Skills = new Skill[info.Length]; - //for ( int i = 0; i < info.Length; ++i ) - // m_Skills[i] = new Skill( this, info[i], 0, 1000, SkillLock.Up ); + // for ( int i = 0; i < info.Length; ++i ) + // m_Skills[i] = new Skill( this, info[i], 0, 1000, SkillLock.Up ); } public Skills(Mobile owner, IGenericReader reader) { Owner = owner; - int version = reader.ReadInt(); + var version = reader.ReadInt(); switch (version) { case 3: case 2: - { - Cap = reader.ReadInt(); + { + Cap = reader.ReadInt(); - goto case 1; - } + goto case 1; + } case 1: - { - if (version < 2) - Cap = 7000; + { + if (version < 2) + Cap = 7000; - if (version < 3) - /*m_Total =*/ reader.ReadInt(); + if (version < 3) + /*m_Total =*/ + reader.ReadInt(); - SkillInfo[] info = SkillInfo.Table; + var info = SkillInfo.Table; - m_Skills = new Skill[info.Length]; + m_Skills = new Skill[info.Length]; - int count = reader.ReadInt(); + var count = reader.ReadInt(); - for (int i = 0; i < count; ++i) - if (i < info.Length) - { - Skill sk = new Skill(this, info[i], reader); - - if (sk.BaseFixedPoint != 0 || sk.CapFixedPoint != 1000 || sk.Lock != SkillLock.Up) + for (var i = 0; i < count; ++i) + if (i < info.Length) { - m_Skills[i] = sk; - Total += sk.BaseFixedPoint; + var sk = new Skill(this, info[i], reader); + + if (sk.BaseFixedPoint != 0 || sk.CapFixedPoint != 1000 || sk.Lock != SkillLock.Up) + { + m_Skills[i] = sk; + Total += sk.BaseFixedPoint; + } + } + else + { + // Will be discarded + _ = new Skill(this, null, reader); } - } - else - { - // Will be discarded - new Skill(this, null, reader); - } - //for ( int i = count; i < info.Length; ++i ) - // m_Skills[i] = new Skill( this, info[i], 0, 1000, SkillLock.Up ); + // for ( int i = count; i < info.Length; ++i ) + // m_Skills[i] = new Skill( this, info[i], 0, 1000, SkillLock.Up ); - break; - } + break; + } case 0: - { - reader.ReadInt(); + { + reader.ReadInt(); - goto case 1; - } + goto case 1; + } } } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] - public int Cap{ get; set; } + public int Cap { get; set; } - public int Total{ get; set; } + public int Total { get; set; } - public Mobile Owner{ get; } + public Mobile Owner { get; } public int Length => m_Skills.Length; @@ -580,7 +582,7 @@ namespace Server if (skillID < 0 || skillID >= m_Skills.Length) return null; - Skill sk = m_Skills[skillID]; + var sk = m_Skills[skillID]; if (sk == null) m_Skills[skillID] = sk = new Skill(this, SkillInfo.Table[skillID], 0, 1000, SkillLock.Up); @@ -596,11 +598,11 @@ namespace Server if (m_Highest == null) { Skill highest = null; - int value = int.MinValue; + var value = int.MinValue; - for (int i = 0; i < m_Skills.Length; ++i) + for (var i = 0; i < m_Skills.Length; ++i) { - Skill sk = m_Skills[i]; + var sk = m_Skills[i]; if (sk != null && sk.BaseFixedPoint > value) { @@ -644,7 +646,7 @@ namespace Server if (skillID >= 0 && skillID < SkillInfo.Table.Length) { - SkillInfo info = SkillInfo.Table[skillID]; + var info = SkillInfo.Table[skillID]; if (info.Callback != null) { @@ -677,9 +679,9 @@ namespace Server writer.Write(Cap); writer.Write(m_Skills.Length); - for (int i = 0; i < m_Skills.Length; ++i) + for (var i = 0; i < m_Skills.Length; ++i) { - Skill sk = m_Skills[i]; + var sk = m_Skills[i]; if (sk == null) { @@ -704,8 +706,6 @@ namespace Server Owner.NetState?.Send(new SkillChange(skill)); } - #region Skill Getters & Setters - [CommandProperty(AccessLevel.Counselor)] public Skill Alchemy => this[SkillName.Alchemy]; @@ -879,7 +879,5 @@ namespace Server [CommandProperty(AccessLevel.Counselor)] public Skill Throwing => this[SkillName.Throwing]; - - #endregion } -} \ No newline at end of file +} diff --git a/Projects/Server/Targeting/LandTarget.cs b/Projects/Server/Targeting/LandTarget.cs index d8e66dcdc..da911f265 100644 --- a/Projects/Server/Targeting/LandTarget.cs +++ b/Projects/Server/Targeting/LandTarget.cs @@ -42,7 +42,7 @@ namespace Server.Targeting public TileFlag Flags => TileData.LandTable[TileID].Flags; [CommandProperty(AccessLevel.Counselor)] - public int TileID{ get; } + public int TileID { get; } [CommandProperty(AccessLevel.Counselor)] public Point3D Location => m_Location; @@ -56,4 +56,4 @@ namespace Server.Targeting [CommandProperty(AccessLevel.Counselor)] public int Z => m_Location.Z; } -} \ No newline at end of file +} diff --git a/Projects/Server/Targeting/MultiTarget.cs b/Projects/Server/Targeting/MultiTarget.cs index b0f7ac754..4b86ec9b0 100644 --- a/Projects/Server/Targeting/MultiTarget.cs +++ b/Projects/Server/Targeting/MultiTarget.cs @@ -24,16 +24,17 @@ namespace Server.Targeting { public abstract class MultiTarget : Target { - protected MultiTarget(int multiID, Point3D offset, int range = 10, bool allowGround = true, TargetFlags flags = TargetFlags.None) + protected MultiTarget(int multiID, Point3D offset, int range = 10, bool allowGround = true, + TargetFlags flags = TargetFlags.None) : base(range, allowGround, flags) { MultiID = multiID; Offset = offset; } - public int MultiID{ get; set; } + public int MultiID { get; set; } - public Point3D Offset{ get; set; } + public Point3D Offset { get; set; } public override Packet GetPacketFor(NetState ns) { diff --git a/Projects/Server/Targeting/StaticTarget.cs b/Projects/Server/Targeting/StaticTarget.cs index e2dcec088..f90396f06 100644 --- a/Projects/Server/Targeting/StaticTarget.cs +++ b/Projects/Server/Targeting/StaticTarget.cs @@ -41,7 +41,7 @@ namespace Server.Targeting public TileFlag Flags => TileData.ItemTable[ItemID].Flags; [CommandProperty(AccessLevel.Counselor)] - public int ItemID{ get; } + public int ItemID { get; } [CommandProperty(AccessLevel.Counselor)] public int X => m_Location.X; @@ -52,4 +52,4 @@ namespace Server.Targeting [CommandProperty(AccessLevel.Counselor)] public int Z => m_Location.Z; } -} \ No newline at end of file +} diff --git a/Projects/Server/Targeting/Target.cs b/Projects/Server/Targeting/Target.cs index 155e41107..ecd32183c 100644 --- a/Projects/Server/Targeting/Target.cs +++ b/Projects/Server/Targeting/Target.cs @@ -39,21 +39,21 @@ namespace Server.Targeting CheckLOS = true; } - public DateTime TimeoutTime{ get; private set; } + public DateTime TimeoutTime { get; private set; } - public bool CheckLOS{ get; set; } + public bool CheckLOS { get; set; } - public bool DisallowMultis{ get; set; } + public bool DisallowMultis { get; set; } - public bool AllowNonlocal{ get; set; } + public bool AllowNonlocal { get; set; } - public int TargetID{ get; } + public int TargetID { get; } - public int Range{ get; set; } + public int Range { get; set; } - public bool AllowGround{ get; set; } + public bool AllowGround { get; set; } - public TargetFlags Flags{ get; set; } + public TargetFlags Flags { get; set; } public static void Cancel(Mobile m) { @@ -114,8 +114,8 @@ namespace Server.Targeting Point3D loc; Map map; - Item item = targeted as Item; - Mobile mobile = targeted as Mobile; + var item = targeted as Item; + var mobile = targeted as Mobile; if (targeted is LandTarget target) { @@ -179,7 +179,7 @@ namespace Server.Targeting return; } - if (map == null || map != from.Map || Range != -1 && !from.InRange(loc, Range)) + if (map == null || map != from.Map || (Range != -1 && !from.InRange(loc, Range))) { OnTargetOutOfRange(from, targeted); } diff --git a/Projects/Server/Targeting/TargetCancelType.cs b/Projects/Server/Targeting/TargetCancelType.cs index f906a7fbd..4accc9265 100644 --- a/Projects/Server/Targeting/TargetCancelType.cs +++ b/Projects/Server/Targeting/TargetCancelType.cs @@ -27,4 +27,4 @@ namespace Server.Targeting Disconnected, Timeout } -} \ No newline at end of file +} diff --git a/Projects/Server/Targeting/TargetFlags.cs b/Projects/Server/Targeting/TargetFlags.cs index fade1b5b4..95e31f5c6 100644 --- a/Projects/Server/Targeting/TargetFlags.cs +++ b/Projects/Server/Targeting/TargetFlags.cs @@ -29,4 +29,4 @@ namespace Server.Targeting Harmful = 0x01, Beneficial = 0x02 } -} \ No newline at end of file +} diff --git a/Projects/Server/TileData.cs b/Projects/Server/TileData.cs index 448409fbe..ab3e85e1f 100644 --- a/Projects/Server/TileData.cs +++ b/Projects/Server/TileData.cs @@ -19,6 +19,7 @@ ***************************************************************************/ using System; +using System.Buffers.Binary; using System.IO; using System.Text; @@ -32,9 +33,9 @@ namespace Server Flags = flags; } - public string Name{ get; set; } + public string Name { get; set; } - public TileFlag Flags{ get; set; } + public TileFlag Flags { get; set; } } public struct ItemData @@ -56,9 +57,9 @@ namespace Server m_Height = (byte)height; } - public string Name{ get; set; } + public string Name { get; set; } - public TileFlag Flags{ get; set; } + public TileFlag Flags { get; set; } public bool Bridge { @@ -181,7 +182,7 @@ namespace Server static TileData() { - string filePath = Core.FindDataFile("tiledata.mul"); + var filePath = Core.FindDataFile("tiledata.mul"); if (!File.Exists(filePath)) { @@ -191,22 +192,25 @@ namespace Server Console.WriteLine("After pressing return an exception will be thrown and the server will terminate"); Console.ResetColor(); - throw new Exception($"TileData: {filePath} not found"); + Utility.PushColor(ConsoleColor.Red); + Console.WriteLine($"TileData: {filePath} not found"); + Utility.PopColor(); + return; } - using FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader bin = new BinaryReader(fs); + using var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); + var bin = new BinaryReader(fs); if (fs.Length == 3188736) { // 7.0.9.0 LandTable = new LandData[0x4000]; - for (int i = 0; i < 0x4000; ++i) + for (var i = 0; i < 0x4000; ++i) { - if (i == 1 || i > 0 && (i & 0x1F) == 0) bin.ReadInt32(); // header + if (i == 1 || (i > 0 && (i & 0x1F) == 0)) bin.ReadInt32(); // header - TileFlag flags = (TileFlag)bin.ReadInt64(); + var flags = (TileFlag)bin.ReadInt64(); bin.ReadInt16(); // skip 2 bytes -- textureID LandTable[i] = new LandData(ReadNameString(bin), flags); @@ -214,11 +218,11 @@ namespace Server ItemTable = new ItemData[0x10000]; - for (int i = 0; i < 0x10000; ++i) + for (var i = 0; i < 0x10000; ++i) { if ((i & 0x1F) == 0) bin.ReadInt32(); // header - TileFlag flags = (TileFlag)bin.ReadInt64(); + var flags = (TileFlag)bin.ReadInt64(); int weight = bin.ReadByte(); int quality = bin.ReadByte(); bin.ReadInt16(); @@ -237,11 +241,11 @@ namespace Server { LandTable = new LandData[0x4000]; - for (int i = 0; i < 0x4000; ++i) + for (var i = 0; i < 0x4000; ++i) { if ((i & 0x1F) == 0) bin.ReadInt32(); // header - TileFlag flags = (TileFlag)bin.ReadInt32(); + var flags = (TileFlag)bin.ReadInt32(); bin.ReadInt16(); // skip 2 bytes -- textureID LandTable[i] = new LandData(ReadNameString(bin), flags); @@ -252,11 +256,11 @@ namespace Server // 7.0.0.0 ItemTable = new ItemData[0x8000]; - for (int i = 0; i < 0x8000; ++i) + for (var i = 0; i < 0x8000; ++i) { if ((i & 0x1F) == 0) bin.ReadInt32(); // header - TileFlag flags = (TileFlag)bin.ReadInt32(); + var flags = (TileFlag)bin.ReadInt32(); int weight = bin.ReadByte(); int quality = bin.ReadByte(); bin.ReadInt16(); @@ -275,11 +279,11 @@ namespace Server { ItemTable = new ItemData[0x4000]; - for (int i = 0; i < 0x4000; ++i) + for (var i = 0; i < 0x4000; ++i) { if ((i & 0x1F) == 0) bin.ReadInt32(); // header - TileFlag flags = (TileFlag)bin.ReadInt32(); + var flags = (TileFlag)bin.ReadInt32(); int weight = bin.ReadByte(); int quality = bin.ReadByte(); bin.ReadInt16(); @@ -300,23 +304,29 @@ namespace Server MaxItemValue = ItemTable.Length - 1; } - public static LandData[] LandTable{ get; } + public static LandData[] LandTable { get; } - public static ItemData[] ItemTable{ get; } + public static ItemData[] ItemTable { get; } - public static int MaxLandValue{ get; } + public static int MaxLandValue { get; } - public static int MaxItemValue{ get; } + public static int MaxItemValue { get; } private static string ReadNameString(BinaryReader bin) { bin.Read(m_StringBuffer, 0, 20); - int count; + int count = 0; - for (count = 0; count < 20 && m_StringBuffer[count] != 0; ++count) ; + while (count < 20) + { + if (m_StringBuffer[count] == 0) + break; - return Encoding.ASCII.GetString(m_StringBuffer, 0, count); + count++; + } + + return Encoding.ASCII.GetString(new ReadOnlySpan(m_StringBuffer, 0, count)); } } } diff --git a/Projects/Server/TileList.cs b/Projects/Server/TileList.cs index 1212a39ae..96efd4afb 100644 --- a/Projects/Server/TileList.cs +++ b/Projects/Server/TileList.cs @@ -22,7 +22,7 @@ namespace Server { public class TileList { - private static readonly StaticTile[] m_EmptyTiles = new StaticTile[0]; + private static readonly StaticTile[] m_EmptyTiles = System.Array.Empty(); private StaticTile[] m_Tiles; public TileList() @@ -31,20 +31,20 @@ namespace Server Count = 0; } - public int Count{ get; private set; } + public int Count { get; private set; } public void AddRange(StaticTile[] tiles) { if (Count + tiles.Length > m_Tiles.Length) { - StaticTile[] old = m_Tiles; + var old = m_Tiles; m_Tiles = new StaticTile[(Count + tiles.Length) * 2]; - for (int i = 0; i < old.Length; ++i) + for (var i = 0; i < old.Length; ++i) m_Tiles[i] = old[i]; } - for (int i = 0; i < tiles.Length; ++i) + for (var i = 0; i < tiles.Length; ++i) m_Tiles[Count++] = tiles[i]; } @@ -52,10 +52,10 @@ namespace Server { if (Count + 1 > m_Tiles.Length) { - StaticTile[] old = m_Tiles; + var old = m_Tiles; m_Tiles = new StaticTile[old.Length * 2]; - for (int i = 0; i < old.Length; ++i) + for (var i = 0; i < old.Length; ++i) m_Tiles[i] = old[i]; } @@ -69,9 +69,9 @@ namespace Server if (Count == 0) return m_EmptyTiles; - StaticTile[] tiles = new StaticTile[Count]; + var tiles = new StaticTile[Count]; - for (int i = 0; i < Count; ++i) + for (var i = 0; i < Count; ++i) tiles[i] = m_Tiles[i]; Count = 0; @@ -79,4 +79,4 @@ namespace Server return tiles; } } -} \ No newline at end of file +} diff --git a/Projects/Server/TileMatrix.cs b/Projects/Server/TileMatrix.cs index 22429b7f5..853d5ea14 100644 --- a/Projects/Server/TileMatrix.cs +++ b/Projects/Server/TileMatrix.cs @@ -66,9 +66,9 @@ namespace Server { lock (m_Instances) { - for (int i = 0; i < m_Instances.Count; ++i) + for (var i = 0; i < m_Instances.Count; ++i) { - TileMatrix tm = m_Instances[i]; + var tm = m_Instances[i]; if (tm.m_FileIndex == fileIndex) lock (m_FileShare) @@ -92,7 +92,7 @@ namespace Server if (fileIndex != 0x7F) { - string mapPath = Core.FindDataFile("map{0}LegacyMUL.uop", fileIndex); + var mapPath = Core.FindDataFile("map{0}LegacyMUL.uop", fileIndex); if (File.Exists(mapPath)) { @@ -107,7 +107,7 @@ namespace Server m_MapStream = new FileStream(mapPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); } - string indexPath = Core.FindDataFile("staidx{0}.mul", fileIndex); + var indexPath = Core.FindDataFile("staidx{0}.mul", fileIndex); if (File.Exists(indexPath)) { @@ -115,7 +115,7 @@ namespace Server m_IndexReader = new BinaryReader(IndexStream); } - string staticsPath = Core.FindDataFile("statics{0}.mul", fileIndex); + var staticsPath = Core.FindDataFile("statics{0}.mul", fileIndex); if (File.Exists(staticsPath)) DataStream = new FileStream(staticsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); @@ -123,12 +123,12 @@ namespace Server EmptyStaticBlock = new StaticTile[8][][]; - for (int i = 0; i < 8; ++i) + for (var i = 0; i < 8; ++i) { EmptyStaticBlock[i] = new StaticTile[8][]; - for (int j = 0; j < 8; ++j) - EmptyStaticBlock[i][j] = new StaticTile[0]; + for (var j = 0; j < 8; ++j) + EmptyStaticBlock[i][j] = Array.Empty(); } m_InvalidLandBlock = new LandTile[196]; @@ -141,13 +141,13 @@ namespace Server Patch = new TileMatrixPatch(this, mapID); } - public TileMatrixPatch Patch{ get; } + public TileMatrixPatch Patch { get; } - public int BlockWidth{ get; } + public int BlockWidth { get; } - public int BlockHeight{ get; } + public int BlockHeight { get; } - public StaticTile[][][] EmptyStaticBlock{ get; } + public StaticTile[][][] EmptyStaticBlock { get; } [MethodImpl(MethodImplOptions.Synchronized)] public void SetStaticBlock(int x, int y, StaticTile[][][] value) @@ -158,7 +158,7 @@ namespace Server m_StaticTiles[x] ??= new StaticTile[BlockHeight][][][]; m_StaticTiles[x][y] = value; - m_StaticPatches[x] ??= new int[BlockHeight + 31 >> 5]; + m_StaticPatches[x] ??= new int[(BlockHeight + 31) >> 5]; m_StaticPatches[x][y >> 5] |= 1 << (y & 0x1F); } @@ -170,31 +170,31 @@ namespace Server m_StaticTiles[x] ??= new StaticTile[BlockHeight][][][]; - StaticTile[][][] tiles = m_StaticTiles[x][y]; + var tiles = m_StaticTiles[x][y]; if (tiles != null) return tiles; lock (m_FileShare) { - for (int i = 0; tiles == null && i < m_FileShare.Count; ++i) + for (var i = 0; tiles == null && i < m_FileShare.Count; ++i) { - TileMatrix shared = m_FileShare[i]; + var shared = m_FileShare[i]; lock (shared) { if (x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight) { - StaticTile[][][][] theirTiles = shared.m_StaticTiles[x]; + var theirTiles = shared.m_StaticTiles[x]; if (theirTiles != null) tiles = theirTiles[y]; if (tiles != null) { - int[] theirBits = shared.m_StaticPatches[x]; + var theirBits = shared.m_StaticPatches[x]; - if (theirBits != null && (theirBits[y >> 5] & 1 << (y & 0x1F)) != 0) + if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0) tiles = null; } } @@ -207,7 +207,7 @@ namespace Server public StaticTile[] GetStaticTiles(int x, int y) { - StaticTile[][][] tiles = GetStaticBlock(x >> 3, y >> 3); + var tiles = GetStaticBlock(x >> 3, y >> 3); return tiles[x & 0x7][y & 0x7]; } @@ -215,19 +215,23 @@ namespace Server [MethodImpl(MethodImplOptions.Synchronized)] public StaticTile[] GetStaticTiles(int x, int y, bool multis) { - StaticTile[][][] tiles = GetStaticBlock(x >> 3, y >> 3); + var tiles = GetStaticBlock(x >> 3, y >> 3); if (!multis) return tiles[x & 0x7][y & 0x7]; - IPooledEnumerable eable = m_Owner.GetMultiTilesAt(x, y); + var eable = m_Owner.GetMultiTilesAt(x, y); if (eable == Map.NullEnumerable.Instance) return tiles[x & 0x7][y & 0x7]; - bool any = false; + var any = false; - m_TilesList.AddRange(eable.SelectMany(t => { any = true; return t; }).ToArray()); + m_TilesList.AddRange(eable.SelectMany(t => + { + any = true; + return t; + }).ToArray()); eable.Free(); @@ -237,7 +241,6 @@ namespace Server m_TilesList.AddRange(tiles[x & 0x7][y & 0x7]); return m_TilesList.ToArray(); - } [MethodImpl(MethodImplOptions.Synchronized)] @@ -249,7 +252,7 @@ namespace Server m_LandTiles[x] ??= new LandTile[BlockHeight][]; m_LandTiles[x][y] = value; - m_LandPatches[x] ??= new int[BlockHeight + 31 >> 5]; + m_LandPatches[x] ??= new int[(BlockHeight + 31) >> 5]; m_LandPatches[x][y >> 5] |= 1 << (y & 0x1F); } @@ -261,31 +264,31 @@ namespace Server m_LandTiles[x] ??= new LandTile[BlockHeight][]; - LandTile[] tiles = m_LandTiles[x][y]; + var tiles = m_LandTiles[x][y]; if (tiles != null) return tiles; lock (m_FileShare) { - for (int i = 0; tiles == null && i < m_FileShare.Count; ++i) + for (var i = 0; tiles == null && i < m_FileShare.Count; ++i) { - TileMatrix shared = m_FileShare[i]; + var shared = m_FileShare[i]; lock (shared) { if (x >= 0 && x < shared.BlockWidth && y >= 0 && y < shared.BlockHeight) { - LandTile[][] theirTiles = shared.m_LandTiles[x]; + var theirTiles = shared.m_LandTiles[x]; if (theirTiles != null) tiles = theirTiles[y]; if (tiles != null) { - int[] theirBits = shared.m_LandPatches[x]; + var theirBits = shared.m_LandPatches[x]; - if (theirBits != null && (theirBits[y >> 5] & 1 << (y & 0x1F)) != 0) + if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0) tiles = null; } } @@ -305,20 +308,20 @@ namespace Server { m_IndexReader.BaseStream.Seek((x * BlockHeight + y) * 12, SeekOrigin.Begin); - int lookup = m_IndexReader.ReadInt32(); - int length = m_IndexReader.ReadInt32(); + var lookup = m_IndexReader.ReadInt32(); + var length = m_IndexReader.ReadInt32(); if (lookup < 0 || length <= 0) return EmptyStaticBlock; - int count = length / 7; + var count = length / 7; DataStream.Seek(lookup, SeekOrigin.Begin); if (m_TileBuffer.Length < count) m_TileBuffer = new StaticTile[count]; - StaticTile[] staTiles = m_TileBuffer; //new StaticTile[tileCount]; + var staTiles = m_TileBuffer; // new StaticTile[tileCount]; fixed (StaticTile* pTiles = staTiles) { @@ -327,16 +330,16 @@ namespace Server { m_Lists = new TileList[8][]; - for (int i = 0; i < 8; ++i) + for (var i = 0; i < 8; ++i) { m_Lists[i] = new TileList[8]; - for (int j = 0; j < 8; ++j) + for (var j = 0; j < 8; ++j) m_Lists[i][j] = new TileList(); } } - TileList[][] lists = m_Lists; + var lists = m_Lists; StaticTile* pCur = pTiles, pEnd = pTiles + count; @@ -346,13 +349,13 @@ namespace Server pCur = pCur + 1; } - StaticTile[][][] tiles = new StaticTile[8][][]; + var tiles = new StaticTile[8][][]; - for (int i = 0; i < 8; ++i) + for (var i = 0; i < 8; ++i) { tiles[i] = new StaticTile[8][]; - for (int j = 0; j < 8; ++j) + for (var j = 0; j < 8; ++j) tiles[i][j] = lists[i][j].ToArray(); } @@ -382,14 +385,14 @@ namespace Server { try { - int offset = (x * BlockHeight + y) * 196 + 4; + var offset = (x * BlockHeight + y) * 196 + 4; if (m_MapIndex != null) offset = m_MapIndex.Lookup(offset); m_MapStream.Seek(offset, SeekOrigin.Begin); - LandTile[] tiles = new LandTile[64]; + var tiles = new LandTile[64]; fixed (LandTile* pTiles = tiles) { @@ -435,7 +438,7 @@ namespace Server public int Height => 0; - public bool Ignored => m_ID == 2 || m_ID == 0x1DB || m_ID >= 0x1AE && m_ID <= 0x1B5; + public bool Ignored => m_ID == 2 || m_ID == 0x1DB || (m_ID >= 0x1AE && m_ID <= 0x1B5); public LandTile(short id, sbyte z) { @@ -539,20 +542,20 @@ namespace Server Version = m_Reader.ReadInt32(); m_Reader.ReadInt32(); - int nextTable = m_Reader.ReadInt32(); + var nextTable = m_Reader.ReadInt32(); - List entries = new List(); + var entries = new List(); do { stream.Seek(nextTable, SeekOrigin.Begin); - int count = m_Reader.ReadInt32(); + var count = m_Reader.ReadInt32(); nextTable = m_Reader.ReadInt32(); m_Reader.ReadInt32(); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - int offset = m_Reader.ReadInt32(); + var offset = m_Reader.ReadInt32(); if (offset == 0) { @@ -561,7 +564,7 @@ namespace Server } m_Reader.ReadInt64(); - int length = m_Reader.ReadInt32(); + var length = m_Reader.ReadInt32(); entries.Add(new UOPEntry(offset, length)); @@ -571,7 +574,7 @@ namespace Server entries.Sort(OffsetComparer.Instance); - for (int i = 0; i < entries.Count; ++i) + for (var i = 0; i < entries.Count; ++i) { stream.Seek(entries[i].m_Offset + 2, SeekOrigin.Begin); @@ -586,15 +589,15 @@ namespace Server m_Entries = entries.ToArray(); } - public int Version{ get; } + public int Version { get; } public int Lookup(int offset) { - int total = 0; + var total = 0; - for (int i = 0; i < m_Entries.Length; ++i) + for (var i = 0; i < m_Entries.Length; ++i) { - int newTotal = total + m_Entries[i].m_Length; + var newTotal = total + m_Entries[i].m_Length; if (offset < newTotal) return m_Entries[i].m_Offset + (offset - total); diff --git a/Projects/Server/TileMatrixPatch.cs b/Projects/Server/TileMatrixPatch.cs index 9c0bb2a0a..66ce371f7 100644 --- a/Projects/Server/TileMatrixPatch.cs +++ b/Projects/Server/TileMatrixPatch.cs @@ -35,21 +35,21 @@ namespace Server if (!Enabled) return; - string mapDataPath = Core.FindDataFile("mapdif{0}.mul", index); - string mapIndexPath = Core.FindDataFile("mapdifl{0}.mul", index); + var mapDataPath = Core.FindDataFile("mapdif{0}.mul", index); + var mapIndexPath = Core.FindDataFile("mapdifl{0}.mul", index); if (File.Exists(mapDataPath) && File.Exists(mapIndexPath)) m_LandBlocks = PatchLand(matrix, mapDataPath, mapIndexPath); - string staDataPath = Core.FindDataFile("stadif{0}.mul", index); - string staIndexPath = Core.FindDataFile("stadifl{0}.mul", index); - string staLookupPath = Core.FindDataFile("stadifi{0}.mul", index); + var staDataPath = Core.FindDataFile("stadif{0}.mul", index); + var staIndexPath = Core.FindDataFile("stadifl{0}.mul", index); + var staLookupPath = Core.FindDataFile("stadifi{0}.mul", index); if (File.Exists(staDataPath) && File.Exists(staIndexPath) && File.Exists(staLookupPath)) m_StaticBlocks = PatchStatics(matrix, staDataPath, staIndexPath, staLookupPath); } - public static bool Enabled{ get; set; } = true; + public static bool Enabled { get; set; } = true; public int LandBlocks { @@ -76,21 +76,21 @@ namespace Server [MethodImpl(MethodImplOptions.Synchronized)] private unsafe int PatchLand(TileMatrix matrix, string dataPath, string indexPath) { - using FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read); - using FileStream fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader indexReader = new BinaryReader(fsIndex); + using var fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var indexReader = new BinaryReader(fsIndex); - int count = (int)(indexReader.BaseStream.Length / 4); + var count = (int)(indexReader.BaseStream.Length / 4); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - int blockID = indexReader.ReadInt32(); - int x = blockID / matrix.BlockHeight; - int y = blockID % matrix.BlockHeight; + var blockID = indexReader.ReadInt32(); + var x = blockID / matrix.BlockHeight; + var y = blockID % matrix.BlockHeight; fsData.Seek(4, SeekOrigin.Current); - LandTile[] tiles = new LandTile[64]; + var tiles = new LandTile[64]; fixed (LandTile* pTiles = tiles) { @@ -108,32 +108,32 @@ namespace Server [MethodImpl(MethodImplOptions.Synchronized)] private unsafe int PatchStatics(TileMatrix matrix, string dataPath, string indexPath, string lookupPath) { - using FileStream fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read); - using FileStream fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read); - using FileStream fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader indexReader = new BinaryReader(fsIndex); - BinaryReader lookupReader = new BinaryReader(fsLookup); + using var fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var fsLookup = new FileStream(lookupPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var indexReader = new BinaryReader(fsIndex); + var lookupReader = new BinaryReader(fsLookup); - int count = (int)(indexReader.BaseStream.Length / 4); + var count = (int)(indexReader.BaseStream.Length / 4); - TileList[][] lists = new TileList[8][]; + var lists = new TileList[8][]; - for (int x = 0; x < 8; ++x) + for (var x = 0; x < 8; ++x) { lists[x] = new TileList[8]; - for (int y = 0; y < 8; ++y) + for (var y = 0; y < 8; ++y) lists[x][y] = new TileList(); } - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - int blockID = indexReader.ReadInt32(); - int blockX = blockID / matrix.BlockHeight; - int blockY = blockID % matrix.BlockHeight; + var blockID = indexReader.ReadInt32(); + var blockX = blockID / matrix.BlockHeight; + var blockY = blockID % matrix.BlockHeight; - int offset = lookupReader.ReadInt32(); - int length = lookupReader.ReadInt32(); + var offset = lookupReader.ReadInt32(); + var length = lookupReader.ReadInt32(); lookupReader.ReadInt32(); // Extra if (offset < 0 || length <= 0) @@ -144,12 +144,12 @@ namespace Server fsData.Seek(offset, SeekOrigin.Begin); - int tileCount = length / 7; + var tileCount = length / 7; if (m_TileBuffer.Length < tileCount) m_TileBuffer = new StaticTile[tileCount]; - StaticTile[] staTiles = m_TileBuffer; + var staTiles = m_TileBuffer; fixed (StaticTile* pTiles = staTiles) { @@ -162,13 +162,13 @@ namespace Server pCur = pCur + 1; } - StaticTile[][][] tiles = new StaticTile[8][][]; + var tiles = new StaticTile[8][][]; - for (int x = 0; x < 8; ++x) + for (var x = 0; x < 8; ++x) { tiles[x] = new StaticTile[8][]; - for (int y = 0; y < 8; ++y) + for (var y = 0; y < 8; ++y) tiles[x][y] = lists[x][y].ToArray(); } diff --git a/Projects/Server/Timer.cs b/Projects/Server/Timer.cs index 5b4d2ef46..a76a1327c 100644 --- a/Projects/Server/Timer.cs +++ b/Projects/Server/Timer.cs @@ -124,7 +124,7 @@ namespace Server } } - public static int BreakCount{ get; set; } = 20000; + public static int BreakCount { get; set; } = 20000; public virtual bool DefRegCreation => true; @@ -140,7 +140,7 @@ namespace Server { if (!Core.Profiling) return null; - string name = ToString(); + var name = ToString(); return TimerProfile.Acquire(name); } @@ -151,12 +151,12 @@ namespace Server { m_QueueCountAtSlice = m_Queue.Count; - int index = 0; + var index = 0; while (index < BreakCount && m_Queue.Count != 0) { - Timer t = m_Queue.Dequeue(); - TimerProfile prof = t.GetProfile(); + var t = m_Queue.Dequeue(); + var prof = t.GetProfile(); prof?.Start(); @@ -171,7 +171,7 @@ namespace Server public void RegCreation() { - TimerProfile prof = GetProfile(); + var prof = GetProfile(); if (prof != null) prof.Created++; } @@ -208,7 +208,7 @@ namespace Server m_Running = true; TimerThread.AddTimer(this); - TimerProfile prof = GetProfile(); + var prof = GetProfile(); if (prof != null) prof.Started++; } @@ -221,7 +221,7 @@ namespace Server m_Running = false; TimerThread.RemoveTimer(this); - TimerProfile prof = GetProfile(); + var prof = GetProfile(); if (prof != null) prof.Stopped++; } @@ -237,7 +237,8 @@ namespace Server private static readonly long[] m_NextPriorities = new long[8]; - private static readonly long[] m_PriorityDelays = { + private static readonly long[] m_PriorityDelays = + { 0, 10, 25, @@ -248,7 +249,8 @@ namespace Server 60000 }; - private static readonly List[] m_Timers = { + private static readonly List[] m_Timers = + { new List(), new List(), new List(), @@ -263,29 +265,29 @@ namespace Server public static void DumpInfo(TextWriter tw) { - for (int i = 0; i < 8; ++i) + for (var i = 0; i < 8; ++i) { tw.WriteLine("Priority: {0}", (TimerPriority)i); tw.WriteLine(); - Dictionary> hash = new Dictionary>(); + var hash = new Dictionary>(); - for (int j = 0; j < m_Timers[i].Count; ++j) + for (var j = 0; j < m_Timers[i].Count; ++j) { - Timer t = m_Timers[i][j]; + var t = m_Timers[i][j]; - string key = t.ToString(); + var key = t.ToString(); - if (!hash.TryGetValue(key, out List list)) + if (!hash.TryGetValue(key, out var list)) hash[key] = list = new List(); list.Add(t); } - foreach (KeyValuePair> kv in hash) + foreach (var kv in hash) { - string key = kv.Key; - List list = kv.Value; + var key = kv.Key; + var list = kv.Value; tw.WriteLine("Type: {0}; Count: {1}; Percent: {2}%", key, list.Count, (int)(100 * (list.Count / (double)m_Timers[i].Count))); @@ -325,12 +327,12 @@ namespace Server { lock (m_Changed) { - long curTicks = Core.TickCount; + var curTicks = Core.TickCount; - foreach (TimerChangeEntry tce in m_Changed.Values) + foreach (var tce in m_Changed.Values) { - Timer timer = tce.m_Timer; - int newIndex = tce.m_NewIndex; + var timer = tce.m_Timer; + var newIndex = tce.m_NewIndex; timer.m_List?.Remove(timer); @@ -374,19 +376,19 @@ namespace Server ProcessChanged(); - bool loaded = false; + var loaded = false; - for (int i = 0; i < m_Timers.Length; i++) + for (var i = 0; i < m_Timers.Length; i++) { - long now = Core.TickCount; + var now = Core.TickCount; if (now < m_NextPriorities[i]) break; m_NextPriorities[i] = now + m_PriorityDelays[i]; - for (int j = 0; j < m_Timers[i].Count; j++) + for (var j = 0; j < m_Timers[i].Count; j++) { - Timer t = m_Timers[i][j]; + var t = m_Timers[i][j]; if (!t.m_Queued && now > t.m_Next) { @@ -462,13 +464,12 @@ namespace Server } } - #region DelayCall(..) - public static Timer DelayCall(TimerCallback callback) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback); public static Timer DelayCall(TimeSpan delay, TimerCallback callback) => DelayCall(delay, TimeSpan.Zero, 1, callback); - public static Timer DelayCall(TimeSpan delay, TimeSpan interval, TimerCallback callback) => DelayCall(delay, interval, 0, callback); + public static Timer DelayCall(TimeSpan delay, TimeSpan interval, TimerCallback callback) => + DelayCall(delay, interval, 0, callback); public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback) { @@ -480,15 +481,14 @@ namespace Server return t; } - #endregion + public static Timer DelayCall(TimerStateCallback callback, T state) => + DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state); - #region DelayCall(..) + public static Timer DelayCall(TimeSpan delay, TimerStateCallback callback, T state) => + DelayCall(delay, TimeSpan.Zero, 1, callback, state); - public static Timer DelayCall(TimerStateCallback callback, T state) => DelayCall(TimeSpan.Zero, TimeSpan.Zero, 1, callback, state); - - public static Timer DelayCall(TimeSpan delay, TimerStateCallback callback, T state) => DelayCall(delay, TimeSpan.Zero, 1, callback, state); - - public static Timer DelayCall(TimeSpan delay, TimeSpan interval, TimerStateCallback callback, T state) => DelayCall(delay, interval, 0, callback, state); + public static Timer DelayCall(TimeSpan delay, TimeSpan interval, TimerStateCallback callback, T state) => + DelayCall(delay, interval, 0, callback, state); public static Timer DelayCall(TimeSpan delay, TimeSpan interval, int count, TimerStateCallback callback, T state) @@ -502,10 +502,6 @@ namespace Server return t; } - #endregion - - #region DelayCall Timers - private class DelayCallTimer : Timer { public DelayCallTimer(TimeSpan delay, TimeSpan interval, int count, TimerCallback callback) : base(delay, @@ -515,7 +511,7 @@ namespace Server RegCreation(); } - public TimerCallback Callback{ get; } + public TimerCallback Callback { get; } public override bool DefRegCreation => false; @@ -540,7 +536,7 @@ namespace Server RegCreation(); } - public TimerStateCallback Callback{ get; } + public TimerStateCallback Callback { get; } public override bool DefRegCreation => false; @@ -552,8 +548,6 @@ namespace Server public override string ToString() => $"DelayStateCall[{FormatDelegate(Callback)}]"; } - #endregion - private class DelayTaskTimer : Timer { private readonly TaskCompletionSource m_TaskCompleter; @@ -572,7 +566,7 @@ namespace Server public static Task Pause(TimeSpan ms) { - DelayTaskTimer t = new DelayTaskTimer(ms); + var t = new DelayTaskTimer(ms); t.Start(); return t.Task; } diff --git a/Projects/Server/Utilities/ActivatorUtil.cs b/Projects/Server/Utilities/ActivatorUtil.cs index 945ee63c6..56b500b91 100644 --- a/Projects/Server/Utilities/ActivatorUtil.cs +++ b/Projects/Server/Utilities/ActivatorUtil.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; @@ -9,11 +8,11 @@ namespace Server.Utilities { public static ConstructorInfo GetConstructor(Type type, Predicate predicate = null) { - ConstructorInfo emptyCtor = type.GetConstructor(Type.EmptyTypes); + var emptyCtor = type.GetConstructor(Type.EmptyTypes); if (emptyCtor != null && predicate?.Invoke(emptyCtor) != false) return emptyCtor; - ConstructorInfo optionalCtor = type.GetConstructors().SingleOrDefault(info => + var optionalCtor = type.GetConstructors().SingleOrDefault(info => predicate?.Invoke(info) != false && info.GetParameters().All(x => x.IsOptional)); if (optionalCtor != null) return optionalCtor; @@ -40,25 +39,25 @@ namespace Server.Utilities { if (predicate?.Invoke(info) == false) return false; - List paramList = info.GetParameters().ToList(); + var paramList = info.GetParameters().ToList(); // If more args are given than parameters, skip. if (args.Length > paramList.Count) return false; // check all given args map to params. - for (int i = 0; i < args.Length; i++) - // if a null reference is passed, but the type is not nullable - if (args[i] == null && paramList[i].ParameterType.IsValueType + for (var i = 0; i < args.Length; i++) + // if a null reference is passed, but the type is not nullable + if ((args[i] == null && paramList[i].ParameterType.IsValueType) // or if an arg is not null and is not assignable to the parameter type, skip. || !(args[i] == null || paramList[i].ParameterType.IsAssignableFrom(args[i]))) return false; // If there are more parameters, check if they any are not optional, if any are not, skip. - // Otherwise all checks have passed. We have found a match + // Otherwise all checks have passed. We have found a match return args.Length <= paramList.Count || paramList.GetRange(args.Length, paramList.Count - args.Length) - .All(x => x.IsOptional); + .All(x => x.IsOptional); }); - + if (ctor != null) return ctor; } @@ -72,12 +71,12 @@ namespace Server.Utilities public static object CreateInstance(Type type, Predicate constructorPredicate = null) { - ConstructorInfo cctor = GetConstructor(type, constructorPredicate); - ParameterInfo[] args = cctor.GetParameters(); + var cctor = GetConstructor(type, constructorPredicate); + var args = cctor.GetParameters(); if (args.Length == 0) return cctor.Invoke(Type.EmptyTypes); - object[] argList = new object[args.Length]; + var argList = new object[args.Length]; Array.Fill(argList, Type.Missing); return cctor.Invoke(argList); } @@ -87,12 +86,15 @@ namespace Server.Utilities { if (args == null || args.Length == 0) return CreateInstance(type, constructorPredicate); - ConstructorInfo cctor = GetConstructor(type, constructorPredicate, args.Select(x => x?.GetType()).ToArray()); + var cctor = GetConstructor(type, constructorPredicate, args.Select(x => x?.GetType()).ToArray()); return cctor.Invoke(args); } public static object CreateInstance(Type type, params object[] args) => CreateInstance(type, null, args); - public static T CreateInstance(Predicate constructorPredicate = null) => (T)CreateInstance(typeof(T), constructorPredicate); + + public static T CreateInstance(Predicate constructorPredicate = null) => + (T)CreateInstance(typeof(T), constructorPredicate); + public static T CreateInstance(params object[] args) => (T)CreateInstance(typeof(T), null, args); } } diff --git a/Projects/Server/Utilities/DRng64.cs b/Projects/Server/Utilities/DRng64.cs index 551dbe145..76ace45e9 100644 --- a/Projects/Server/Utilities/DRng64.cs +++ b/Projects/Server/Utilities/DRng64.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: DRng64.cs - Created: 2019/12/30 - Updated: 2019/12/30 * * * @@ -21,6 +21,7 @@ using System; using System.Runtime.InteropServices; using System.Security.Cryptography; +using Server.Network; namespace Server { @@ -38,21 +39,15 @@ namespace Server Success = 1 } - [DllImport("libdrng", CallingConvention = CallingConvention.Cdecl)] - internal static extern RDRandError rdrand_64(ref ulong rand, bool retry); - - [DllImport("libdrng", CallingConvention = CallingConvention.Cdecl)] - internal static extern unsafe RDRandError rdrand_get_bytes(int n, byte* buffer); - public bool IsSupported() { ulong r = 0; - return rdrand_64(ref r, true) == RDRandError.Success; + return SafeNativeMethods.rdrand_64(ref r, true) == RDRandError.Success; } private static unsafe void GetBytes(byte* pBuffer, int count) { - rdrand_get_bytes(count, pBuffer); + SafeNativeMethods.rdrand_get_bytes(count, pBuffer); } public override void GetBytes(byte[] data) @@ -69,7 +64,10 @@ namespace Server public override unsafe void GetBytes(Span data) { if (data.Length > 0) - fixed (byte* ptr = data) GetBytes(ptr, data.Length); + fixed (byte* ptr = data) + { + GetBytes(ptr, data.Length); + } } public override void GetNonZeroBytes(byte[] data) @@ -86,8 +84,8 @@ namespace Server GetBytes(data); // Find the first zero in the remaining portion. - int indexOfFirst0Byte = data.Length; - for (int i = 0; i < data.Length; i++) + var indexOfFirst0Byte = data.Length; + for (var i = 0; i < data.Length; i++) if (data[i] == 0) { indexOfFirst0Byte = i; @@ -95,13 +93,23 @@ namespace Server } // If there were any zeros, shift down all non-zeros. - for (int i = indexOfFirst0Byte + 1; i < data.Length; i++) - if (data[i] != 0) data[indexOfFirst0Byte++] = data[i]; + for (var i = indexOfFirst0Byte + 1; i < data.Length; i++) + if (data[i] != 0) + data[indexOfFirst0Byte++] = data[i]; // Request new random bytes if necessary; dont re-use // existing bytes since they were shifted down. data = data.Slice(indexOfFirst0Byte); } } + + internal class SafeNativeMethods + { + [DllImport("libdrng", CallingConvention = CallingConvention.Cdecl)] + internal static extern RDRandError rdrand_64(ref ulong rand, bool retry); + + [DllImport("libdrng", CallingConvention = CallingConvention.Cdecl)] + internal static extern unsafe RDRandError rdrand_get_bytes(int n, byte* buffer); + } } } diff --git a/Projects/Server/Utilities/Random.cs b/Projects/Server/Utilities/Random.cs index c0af61c83..e44ff0d4d 100644 --- a/Projects/Server/Utilities/Random.cs +++ b/Projects/Server/Utilities/Random.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: Random.cs - Created: 2019/12/30 - Updated: 2019/01/05 * * * diff --git a/Projects/Server/Utilities/RefPool.cs b/Projects/Server/Utilities/RefPool.cs index 76c0f6178..b016bf4fc 100644 --- a/Projects/Server/Utilities/RefPool.cs +++ b/Projects/Server/Utilities/RefPool.cs @@ -8,7 +8,9 @@ namespace Server.Utilities /// Disposing the reference is expected to return itself back into the /// original pool that created it. /// - public interface IRef : IDisposable { } + public interface IRef : IDisposable + { + } /// /// Base implementation of the interface. @@ -23,6 +25,7 @@ namespace Server.Utilities private readonly RefPool m_Pool; public BaseRef(RefPool pool) => m_Pool = pool; protected abstract void OnDispose(); + public void Dispose() { OnDispose(); @@ -37,6 +40,7 @@ namespace Server.Utilities public class RefPool where TRef : IRef { public delegate TRef Generator(RefPool targetPool); + public const int DEFAULT_RESOURCE_RETENTION = 10; private readonly Stack m_Resources = new Stack(); @@ -68,12 +72,14 @@ namespace Server.Utilities m_MaxRefrenceRetention = maxRefrenceRetention; while (--preGenerateCount >= 0) m_Resources.Push(generator(this)); } + /// /// Retrieves a resource reference that is managed by this . If the pool is has unused resources, /// it will remove one from the pool and return it; otherwise, a new resource will be generated. /// /// Unused resource, or a new resource if no unused resources available. - public TRef Get() => m_Resources.TryPop(out TRef item) ? item : m_Generator(this); + public TRef Get() => m_Resources.TryPop(out var item) ? item : m_Generator(this); + /// /// Returns a resource reference to the pool of unused resources. /// @@ -84,27 +90,37 @@ namespace Server.Utilities m_Resources.Push(queueRef); } } - /// + public class QueueRef : Queue, IRef { private readonly RefPool> m_Pool; private QueueRef(RefPool> pool) => m_Pool = pool; /// Clears the queue and returns this resource to its parent resource pool. - public void Dispose() { Clear(); m_Pool.Return(this); } + public void Dispose() + { + Clear(); + m_Pool.Return(this); + } + /// /// Generator function for creating instances of the resource. /// - public static RefPool>.Generator Generate = (targetPool) => new QueueRef(targetPool); + public static RefPool>.Generator Generate = targetPool => new QueueRef(targetPool); } - /// + public class StackRef : Stack, IRef { private readonly RefPool> m_Pool; private StackRef(RefPool> pool) => m_Pool = pool; /// Clears the stack and returns this resource to its parent resource pool. - public void Dispose() { Clear(); m_Pool.Return(this); } + public void Dispose() + { + Clear(); + m_Pool.Return(this); + } + /// /// Generator function for creating instances of the resource. /// diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index 12c841164..99fbd7cf8 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -141,7 +141,7 @@ namespace Server { _ipAddressTable ??= new Dictionary(); - if (!_ipAddressTable.TryGetValue(ipAddress, out IPAddress interned)) + if (!_ipAddressTable.TryGetValue(ipAddress, out var interned)) { interned = ipAddress; _ipAddressTable[ipAddress] = interned; @@ -157,7 +157,7 @@ namespace Server public static bool IsValidIP(string text) { - IPMatch(text, IPAddress.None, out bool valid); + IPMatch(text, IPAddress.None, out var valid); return valid; } @@ -169,14 +169,14 @@ namespace Server if (str == null) return ""; - bool hasOpen = str.IndexOf('<') >= 0; - bool hasClose = str.IndexOf('>') >= 0; - bool hasPound = str.IndexOf('#') >= 0; + var hasOpen = str.IndexOf('<') >= 0; + var hasClose = str.IndexOf('>') >= 0; + var hasPound = str.IndexOf('#') >= 0; if (!hasOpen && !hasClose && !hasPound) return str; - StringBuilder sb = new StringBuilder(str); + var sb = new StringBuilder(str); if (hasOpen) sb.Replace('<', '('); @@ -193,59 +193,24 @@ namespace Server public static bool IPMatchCIDR(string cidr, IPAddress ip) { if (ip == null || ip.AddressFamily == AddressFamily.InterNetworkV6) - return false; //Just worry about IPv4 for now + return false; // Just worry about IPv4 for now + var bytes = new byte[4]; + var split = cidr.Split('.'); + var cidrBits = false; + var cidrLength = 0; - /* - string[] str = cidr.Split( '/' ); - - if ( str.Length != 2 ) - return false; - - /* ************************************************** - IPAddress cidrPrefix; - - if ( !IPAddress.TryParse( str[0], out cidrPrefix ) ) - return false; - * */ - - /* - string[] dotSplit = str[0].Split( '.' ); - - if ( dotSplit.Length != 4 ) //At this point and time, and for speed sake, we'll only worry about IPv4 - return false; - - byte[] bytes = new byte[4]; - - for ( int i = 0; i < 4; i++ ) + for (var i = 0; i < 4; i++) { - byte.TryParse( dotSplit[i], out bytes[i] ); - } + var part = 0; - uint cidrPrefix = OrderedAddressValue( bytes ); + var partBase = 10; - int cidrLength = Utility.ToInt32( str[1] ); - //The below solution is the fastest solution of the three + var pattern = split[i]; - */ - - byte[] bytes = new byte[4]; - string[] split = cidr.Split('.'); - bool cidrBits = false; - int cidrLength = 0; - - for (int i = 0; i < 4; i++) - { - int part = 0; - - int partBase = 10; - - string pattern = split[i]; - - for (int j = 0; j < pattern.Length; j++) + for (var j = 0; j < pattern.Length; j++) { - char c = pattern[j]; - + var c = pattern[j]; if (c == 'x' || c == 'X') { @@ -253,7 +218,7 @@ namespace Server } else if (c >= '0' && c <= '9') { - int offset = c - '0'; + var offset = c - '0'; if (cidrBits) { @@ -268,7 +233,7 @@ namespace Server } else if (c >= 'a' && c <= 'f') { - int offset = 10 + (c - 'a'); + var offset = 10 + (c - 'a'); if (cidrBits) { @@ -283,7 +248,7 @@ namespace Server } else if (c >= 'A' && c <= 'F') { - int offset = 10 + (c - 'A'); + var offset = 10 + (c - 'A'); if (cidrBits) { @@ -298,7 +263,7 @@ namespace Server } else if (c == '/') { - if (cidrBits || i != 3) //If there's two '/' or the '/' isn't in the last byte + if (cidrBits || i != 3) // If there's two '/' or the '/' isn't in the last byte return false; partBase = 10; @@ -318,12 +283,12 @@ namespace Server public static bool IPMatchCIDR(IPAddress cidrPrefix, IPAddress ip, int cidrLength) { - //Ignore IPv6 for now + // Ignore IPv6 for now if (cidrPrefix == null || ip == null || cidrPrefix.AddressFamily == AddressFamily.InterNetworkV6) return false; - uint cidrValue = SwapUnsignedInt((uint)GetLongAddressValue(cidrPrefix)); - uint ipValue = SwapUnsignedInt((uint)GetLongAddressValue(ip)); + var cidrValue = SwapUnsignedInt((uint)GetLongAddressValue(cidrPrefix)); + var ipValue = SwapUnsignedInt((uint)GetLongAddressValue(ip)); return IPMatchCIDR(cidrValue, ipValue, cidrLength); } @@ -333,17 +298,17 @@ namespace Server if (ip == null || ip.AddressFamily == AddressFamily.InterNetworkV6) return false; - uint ipValue = SwapUnsignedInt((uint)GetLongAddressValue(ip)); + var ipValue = SwapUnsignedInt((uint)GetLongAddressValue(ip)); return IPMatchCIDR(cidrPrefixValue, ipValue, cidrLength); } public static bool IPMatchCIDR(uint cidrPrefixValue, uint ipValue, int cidrLength) { - if (cidrLength <= 0 || cidrLength >= 32) //if invalid cidr Length, just compare IPs + if (cidrLength <= 0 || cidrLength >= 32) // if invalid cidr Length, just compare IPs return cidrPrefixValue == ipValue; - uint mask = uint.MaxValue << 32 - cidrLength; + var mask = uint.MaxValue << (32 - cidrLength); return (cidrPrefixValue & mask) == (ipValue & mask); } @@ -353,33 +318,33 @@ namespace Server if (bytes.Length != 4) return 0; - return (uint)(bytes[0] << 0x18 | bytes[1] << 0x10 | bytes[2] << 8 | bytes[3]) & 0xffffffff; + return (uint)((bytes[0] << 0x18) | (bytes[1] << 0x10) | (bytes[2] << 8) | bytes[3]) & 0xffffffff; } private static uint SwapUnsignedInt(uint source) => - (source & 0x000000FF) << 0x18 - | (source & 0x0000FF00) << 8 - | (source & 0x00FF0000) >> 8 - | (source & 0xFF000000) >> 0x18; + ((source & 0x000000FF) << 0x18) + | ((source & 0x0000FF00) << 8) + | ((source & 0x00FF0000) >> 8) + | ((source & 0xFF000000) >> 0x18); public static bool TryConvertIPv6toIPv4(ref IPAddress address) { if (!Socket.OSSupportsIPv6 || address.AddressFamily == AddressFamily.InterNetwork) return true; - byte[] addr = address.GetAddressBytes(); - if (addr.Length == 16) //sanity 0 - 15 //10 11 //12 13 14 15 + var addr = address.GetAddressBytes(); + if (addr.Length == 16) // sanity 0 - 15 //10 11 //12 13 14 15 { if (addr[10] != 0xFF || addr[11] != 0xFF) return false; - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) if (addr[i] != 0) return false; - byte[] v4Addr = new byte[4]; + var v4Addr = new byte[4]; - for (int i = 0; i < 4; i++) v4Addr[i] = addr[12 + i]; + for (var i = 0; i < 4; i++) v4Addr[i] = addr[12 + i]; address = new IPAddress(v4Addr); return true; @@ -392,9 +357,9 @@ namespace Server { valid = true; - string[] split = val.Split('.'); + var split = val.Split('.'); - for (int i = 0; i < 4; ++i) + for (var i = 0; i < 4; ++i) { int lowPart, highPart; @@ -405,7 +370,7 @@ namespace Server } else { - string pattern = split[i]; + var pattern = split[i]; if (pattern == "*") { @@ -417,13 +382,13 @@ namespace Server lowPart = 0; highPart = 0; - bool highOnly = false; - int lowBase = 10; - int highBase = 10; + var highOnly = false; + var lowBase = 10; + var highBase = 10; - for (int j = 0; j < pattern.Length; ++j) + for (var j = 0; j < pattern.Length; ++j) { - char c = pattern[j]; + var c = pattern[j]; if (c == '?') { @@ -448,7 +413,7 @@ namespace Server } else if (c >= '0' && c <= '9') { - int offset = c - '0'; + var offset = c - '0'; if (!highOnly) { @@ -461,7 +426,7 @@ namespace Server } else if (c >= 'a' && c <= 'f') { - int offset = 10 + (c - 'a'); + var offset = 10 + (c - 'a'); if (!highOnly) { @@ -474,7 +439,7 @@ namespace Server } else if (c >= 'A' && c <= 'F') { - int offset = 10 + (c - 'A'); + var offset = 10 + (c - 'A'); if (!highOnly) { @@ -487,13 +452,13 @@ namespace Server } else { - valid = false; //high & lowp art would be 0 if it got to here. + valid = false; // high & lowp art would be 0 if it got to here. } } } } - int b = (byte)(GetAddressValue(ip) >> i * 8); + int b = (byte)(GetAddressValue(ip) >> (i * 8)); if (b < lowPart || b > highPart) return false; @@ -502,7 +467,8 @@ namespace Server return true; } - public static bool IPMatchClassC(IPAddress ip1, IPAddress ip2) => (GetAddressValue(ip1) & 0xFFFFFF) == (GetAddressValue(ip2) & 0xFFFFFF); + public static bool IPMatchClassC(IPAddress ip1, IPAddress ip2) => + (GetAddressValue(ip1) & 0xFFFFFF) == (GetAddressValue(ip2) & 0xFFFFFF); public static int InsensitiveCompare(string first, string second) => Insensitive.Compare(first, second); @@ -510,11 +476,11 @@ namespace Server public static Direction GetDirection(IPoint2D from, IPoint2D to) { - int dx = to.X - from.X; - int dy = to.Y - from.Y; + var dx = to.X - from.X; + var dy = to.Y - from.Y; - int adx = Math.Abs(dx); - int ady = Math.Abs(dy); + var adx = Math.Abs(dx); + var ady = Math.Abs(dy); if (adx >= ady * 3) return dx > 0 ? Direction.East : Direction.West; @@ -525,55 +491,6 @@ namespace Server return dy > 0 ? Direction.Left : Direction.Up; } - /* Should probably be rewritten to use an ITile interface - - public static bool CanMobileFit( int z, StaticTile[] tiles ) - { - int checkHeight = 15; - int checkZ = z; - - for ( int i = 0; i < tiles.Length; ++i ) - { - StaticTile tile = tiles[i]; - - if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))*/ - /* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*/ /* ) - { - return false; - } - else if ( checkHeight == 0 && tile.Height == 0 && checkZ == tile.Z ) - { - return false; - } - } - - return true; - } - - public static bool IsInContact( StaticTile check, StaticTile[] tiles ) - { - int checkHeight = check.Height; - int checkZ = check.Z; - - for ( int i = 0; i < tiles.Length; ++i ) - { - StaticTile tile = tiles[i]; - - if ( ((checkZ + checkHeight) > tile.Z && checkZ < (tile.Z + tile.Height))*/ - /* || (tile.Z < (checkZ + checkHeight) && (tile.Z + tile.Height) > checkZ)*/ /* ) - { - return true; - } - else if ( checkHeight == 0 && tile.Height == 0 && checkZ == tile.Z ) - { - return true; - } - } - - return false; - } - */ - public static object GetArrayCap(Array array, int index, object emptyValue = null) { if (array.Length > 0) @@ -588,7 +505,8 @@ namespace Server return emptyValue; } - public static SkillName RandomSkill() => m_AllSkills[Random(m_AllSkills.Length - (Core.ML ? 0 : Core.SE ? 1 : Core.AOS ? 3 : 6))]; + public static SkillName RandomSkill() => + m_AllSkills[Random(m_AllSkills.Length - (Core.ML ? 0 : Core.SE ? 1 : Core.AOS ? 3 : 6))]; public static SkillName RandomCombatSkill() => m_CombatSkills[Random(m_CombatSkills.Length)]; @@ -598,21 +516,21 @@ namespace Server { if (bottom.m_X < top.m_X) { - int swap = top.m_X; + var swap = top.m_X; top.m_X = bottom.m_X; bottom.m_X = swap; } if (bottom.m_Y < top.m_Y) { - int swap = top.m_Y; + var swap = top.m_Y; top.m_Y = bottom.m_Y; bottom.m_Y = swap; } if (bottom.m_Z < top.m_Z) { - int swap = top.m_Z; + var swap = top.m_Z; top.m_Z = bottom.m_Z; bottom.m_Z = swap; } @@ -629,19 +547,19 @@ namespace Server output.WriteLine(" 0 1 2 3 4 5 6 7 8 9 A B C D E F"); output.WriteLine(" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"); - int byteIndex = 0; + var byteIndex = 0; - int whole = length >> 4; - int rem = length & 0xF; + var whole = length >> 4; + var rem = length & 0xF; - for (int i = 0; i < whole; ++i, byteIndex += 16) + for (var i = 0; i < whole; ++i, byteIndex += 16) { - StringBuilder bytes = new StringBuilder(49); - StringBuilder chars = new StringBuilder(16); + var bytes = new StringBuilder(49); + var chars = new StringBuilder(16); - for (int j = 0; j < 16; ++j) + for (var j = 0; j < 16; ++j) { - int c = input.ReadByte(); + var c = input.ReadByte(); bytes.Append(c.ToString("X2")); @@ -665,13 +583,13 @@ namespace Server if (rem != 0) { - StringBuilder bytes = new StringBuilder(49); - StringBuilder chars = new StringBuilder(rem); + var bytes = new StringBuilder(49); + var chars = new StringBuilder(rem); - for (int j = 0; j < 16; ++j) + for (var j = 0; j < 16; ++j) if (j < rem) { - int c = input.ReadByte(); + var c = input.ReadByte(); bytes.Append(c.ToString("X2")); @@ -727,7 +645,7 @@ namespace Server { if (bound1 > bound2) { - int i = bound1; + var i = bound1; bound1 = bound2; bound2 = i; } @@ -771,31 +689,38 @@ namespace Server public static List SafeConvertList(List list) where TOutput : class { - List output = new List(list.Capacity); + if ((list?.Capacity ?? 0) == 0) + return new List(); + + var output = new List(list.Capacity); output.AddRange(list.OfType()); return output; } - #region To[Something] - public static bool ToBoolean(string value) { - bool.TryParse(value, out bool b); +#pragma warning disable CA1806 // Do not ignore method results + bool.TryParse(value, out var b); +#pragma warning restore CA1806 // Do not ignore method results return b; } public static double ToDouble(string value) { - double.TryParse(value, out double d); +#pragma warning disable CA1806 // Do not ignore method results + double.TryParse(value, out var d); +#pragma warning restore CA1806 // Do not ignore method results return d; } public static TimeSpan ToTimeSpan(string value) { - TimeSpan.TryParse(value, out TimeSpan t); +#pragma warning disable CA1806 // Do not ignore method results + TimeSpan.TryParse(value, out var t); +#pragma warning restore CA1806 // Do not ignore method results return t; } @@ -804,10 +729,12 @@ namespace Server { int i; +#pragma warning disable CA1806 // Do not ignore method results if (value.StartsWith("0x")) int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i); else int.TryParse(value, out i); +#pragma warning restore CA1806 // Do not ignore method results return i; } @@ -816,17 +743,25 @@ namespace Server { uint i; +#pragma warning disable CA1806 // Do not ignore method results if (value.StartsWith("0x")) uint.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i); else uint.TryParse(value, out i); +#pragma warning restore CA1806 // Do not ignore method results return i; } - #endregion + public static bool ToInt32(string value, out int i) => + value.StartsWith("0x") + ? int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i) + : int.TryParse(value, out i); - #region Get[Something] + public static bool ToUInt32(string value, out uint i) => + value.StartsWith("0x") + ? uint.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i) + : uint.TryParse(value, out i); public static double GetXMLDouble(string doubleString, double defaultValue) { @@ -836,7 +771,7 @@ namespace Server } catch { - return double.TryParse(doubleString, out double val) ? val : defaultValue; + return double.TryParse(doubleString, out var val) ? val : defaultValue; } } @@ -848,7 +783,7 @@ namespace Server } catch { - return int.TryParse(intString, out int val) ? val : defaultValue; + return int.TryParse(intString, out var val) ? val : defaultValue; } } @@ -860,7 +795,7 @@ namespace Server } catch { - return uint.TryParse(uintString, out uint val) ? val : defaultValue; + return uint.TryParse(uintString, out var val) ? val : defaultValue; } } @@ -872,7 +807,7 @@ namespace Server } catch { - return DateTime.TryParse(dateTimeString, out DateTime d) ? d : defaultValue; + return DateTime.TryParse(dateTimeString, out var d) ? d : defaultValue; } } @@ -884,7 +819,7 @@ namespace Server } catch { - return DateTimeOffset.TryParse(dateTimeOffsetString, out DateTimeOffset d) ? d : defaultValue; + return DateTimeOffset.TryParse(dateTimeOffsetString, out var d) ? d : defaultValue; } } @@ -900,7 +835,8 @@ namespace Server } } - public static string GetAttribute(XmlElement node, string attributeName, string defaultValue = null) => node?.Attributes[attributeName]?.Value ?? defaultValue; + public static string GetAttribute(XmlElement node, string attributeName, string defaultValue = null) => + node?.Attributes[attributeName]?.Value ?? defaultValue; public static string GetText(XmlElement node, string defaultValue) => node == null ? defaultValue : node.InnerText; @@ -908,10 +844,6 @@ namespace Server public static long GetLongAddressValue(IPAddress address) => BitConverter.ToInt64(address.GetAddressBytes(), 0); - #endregion - - #region In[...]Range - public static bool InRange(Point3D p1, Point3D p2, int range) => p1.m_X >= p2.m_X - range && p1.m_X <= p2.m_X + range @@ -936,17 +868,13 @@ namespace Server && p1.Y >= p2.Y - 18 && p1.Y <= p2.Y + 18; - #endregion - - #region Random - - //4d6+8 would be: Utility.Dice( 4, 6, 8 ) + // 4d6+8 would be: Utility.Dice( 4, 6, 8 ) public static int Dice(uint numDice, uint numSides, int bonus) { - int total = 0; - uint sides = numSides; + var total = 0; + var sides = numSides; - for (int i = 0; i < numDice; ++i) + for (var i = 0; i < numDice; ++i) total += (int)RandomImpl.Next(sides) + 1; return total + bonus; @@ -954,11 +882,11 @@ namespace Server public static void Shuffle(IList list) { - int count = list.Count; - for (int i = count - 1; i > 0; i--) + var count = list.Count; + for (var i = count - 1; i > 0; i--) { - int r = (int)RandomImpl.Next((uint)count); - T swap = list[r]; + var r = (int)RandomImpl.Next((uint)count); + var swap = list[r]; list[r] = list[i]; list[i] = swap; } @@ -974,12 +902,14 @@ namespace Server { if (min > max) { - int copy = min; + var copy = min; min = max; max = copy; } else if (min == max) + { return min; + } return min + (int)RandomImpl.Next((uint)(max - min + 1)); } @@ -995,7 +925,7 @@ namespace Server public static int Random(int count) => (int)RandomImpl.Next((uint)count); - public static int Random(uint count) => (int)RandomImpl.Next(count); + public static uint Random(uint count) => RandomImpl.Next(count); public static void RandomBytes(byte[] buffer) => RandomImpl.GetBytes(buffer); @@ -1003,10 +933,6 @@ namespace Server public static double RandomDouble() => RandomImpl.NextDouble(); - #endregion - - #region Random Hues - /// /// Random pink, blue, green, orange, red or yellow hue /// @@ -1101,9 +1027,6 @@ namespace Server /// Random hue from 0x62, 0x71, 0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59 /// public static int RandomBrightHue() => - RandomDouble() < 0.1 ? RandomList(0x62, 0x71) : - RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59); - - #endregion + RandomDouble() < 0.1 ? RandomList(0x62, 0x71) : RandomList(0x03, 0x0D, 0x13, 0x1C, 0x21, 0x30, 0x37, 0x3A, 0x44, 0x59); } } diff --git a/Projects/Server/Utilities/Xoshiro256PlusPlus.cs b/Projects/Server/Utilities/Xoshiro256PlusPlus.cs index e718b694b..e0273f289 100644 --- a/Projects/Server/Utilities/Xoshiro256PlusPlus.cs +++ b/Projects/Server/Utilities/Xoshiro256PlusPlus.cs @@ -1,6 +1,6 @@ /************************************************************************* * ModernUO * - * Copyright (C) 2019 - ModernUO Development Team * + * Copyright (C) 2019-2020 - ModernUO Development Team * * Email: hi@modernuo.com * * File: Xoshiro256PlusPlus.cs * * Created: 2019/12/29 - Updated: 2019/12/30 * @@ -36,7 +36,7 @@ namespace Server public Xoshiro256PlusPlus(ulong seed) { var mix = new SplitMix64(seed); - ulong[] state = new ulong[4]; + var state = new ulong[4]; mix.FillArray(state); _s0 = state[0]; _s1 = state[1]; @@ -57,7 +57,7 @@ namespace Server { if (max <= 1u << 12) { - if (max == 0) throw new ArgumentOutOfRangeException(); + if (max == 0) throw new ArgumentOutOfRangeException(nameof(max)); return (uint)(((ulong)NextUInt32() * max) >> 32); } @@ -77,11 +77,11 @@ namespace Server [MethodImpl(MethodImplOptions.AggressiveInlining)] public ulong NextUInt64() { - ulong r1 = (_s1 << 2) + _s1; - ulong r2 = (r1 << 7) | (r1 >> 57); - ulong rslt = (r2 << 3) + r2; + var r1 = (_s1 << 2) + _s1; + var r2 = (r1 << 7) | (r1 >> 57); + var rslt = (r2 << 3) + r2; - ulong t = _s1 << 17; + var t = _s1 << 17; _s2 ^= _s0; _s3 ^= _s1; @@ -100,7 +100,7 @@ namespace Server { if (max <= uint.MaxValue) return Next((uint)max); - if (max <= 1ul << 38) return ((NextUInt32() * max >> 32) + (NextUInt32() & ((1u << 26) - 1)) * max) >> 26; + if (max <= 1ul << 38) return (((NextUInt32() * max) >> 32) + (NextUInt32() & ((1u << 26) - 1)) * max) >> 26; ulong r, v, limit = (ulong)-(long)max; do @@ -112,6 +112,7 @@ namespace Server return v; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool NextBool() => NextUInt64() < 1ul << 63; public override void GetBytes(byte[] data) @@ -124,24 +125,24 @@ namespace Server { if (b.Length == 0) return; - ulong s0 = _s0; - ulong s1 = _s1; - ulong s2 = _s2; - ulong s3 = _s3; + var s0 = _s0; + var s1 = _s1; + var s2 = _s2; + var s3 = _s3; - int i = 0; + var i = 0; fixed (byte* pBuffer = b) { - ulong* pULong = (ulong*)pBuffer; + var pULong = (ulong*)pBuffer; - for (int bound = b.Length / sizeof(ulong); i < bound; i++) + for (var bound = b.Length / sizeof(ulong); i < bound; i++) { - ulong r1 = (s1 << 2) + s1; - ulong r2 = (r1 << 7) | (r1 >> 57); + var r1 = (s1 << 2) + s1; + var r2 = (r1 << 7) | (r1 >> 57); pULong[i] = (r2 << 3) + r2; - ulong t = s1 << 17; + var t = s1 << 17; s2 ^= s0; s3 ^= s1; s1 ^= s2; @@ -157,11 +158,11 @@ namespace Server if (i < b.Length) { - ulong r1 = (s1 << 2) + s1; - ulong r2 = (r1 << 7) | (r1 >> 57); - ulong rslt = (r2 << 3) + r2; + var r1 = (s1 << 2) + s1; + var r2 = (r1 << 7) | (r1 >> 57); + var rslt = (r2 << 3) + r2; - ulong t = s1 << 17; + var t = s1 << 17; s2 ^= s0; s3 ^= s1; @@ -188,10 +189,10 @@ namespace Server public double NextDouble() => (NextUInt64() >> 11) * (1.0 / (1ul << 53)); private static readonly ulong[] JUMP = - {0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c}; + { 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c, 0xa9582618e03fc9aa, 0x39abdc4529b1661c }; private static readonly ulong[] LONG_JUMP = - {0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635}; + { 0x76e15d3efefdcbbf, 0xc5004e441c522fb3, 0x77710069854ee241, 0x39109bb02acbe635 }; public void Jump() => Jump(JUMP); @@ -204,19 +205,19 @@ namespace Server ulong s2 = 0; ulong s3 = 0; - for (int i = 0; i < jumps.Length; i++) - for (int b = 0; b < 64; b++) - { - if ((jumps[i] & 1ul << b) != 0) + for (var i = 0; i < jumps.Length; i++) + for (var b = 0; b < 64; b++) { - s0 ^= _s0; - s1 ^= _s1; - s2 ^= _s2; - s3 ^= _s3; - } + if ((jumps[i] & (1ul << b)) != 0) + { + s0 ^= _s0; + s1 ^= _s1; + s2 ^= _s2; + s3 ^= _s3; + } - NextUInt64(); - } + NextUInt64(); + } _s0 = s0; _s1 = s1; @@ -226,14 +227,14 @@ namespace Server public Xoshiro256PlusPlus Split() { - Xoshiro256PlusPlus rng = new Xoshiro256PlusPlus(_s0, _s1, _s2, _s3); + var rng = new Xoshiro256PlusPlus(_s0, _s1, _s2, _s3); rng.Jump(); return rng; } public Xoshiro256PlusPlus LongSplit() { - Xoshiro256PlusPlus rng = new Xoshiro256PlusPlus(_s0, _s1, _s2, _s3); + var rng = new Xoshiro256PlusPlus(_s0, _s1, _s2, _s3); rng.LongJump(); return rng; } @@ -248,7 +249,7 @@ namespace Server [MethodImpl(MethodImplOptions.AggressiveInlining)] public ulong Next() { - ulong z = x += 0x9e3779b97f4a7c15; + var z = x += 0x9e3779b97f4a7c15; z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9; z = (z ^ (z >> 27)) * 0x94d049bb133111eb; return z ^ (z >> 31); @@ -257,7 +258,7 @@ namespace Server [MethodImpl(MethodImplOptions.AggressiveInlining)] public void FillArray(ulong[] arr) { - for (int i = 0; i < arr.Length; i++) arr[i] = Next(); + for (var i = 0; i < arr.Length; i++) arr[i] = Next(); } } } diff --git a/Projects/Server/VirtueInfo.cs b/Projects/Server/VirtueInfo.cs index 5aa02b815..f96bf3111 100644 --- a/Projects/Server/VirtueInfo.cs +++ b/Projects/Server/VirtueInfo.cs @@ -33,37 +33,37 @@ namespace Server switch (version) { - case 1: //Changed the values throughout the virtue system + case 1: // Changed the values throughout the virtue system case 0: - { - int mask = reader.ReadByte(); - - if (mask != 0) { - Values = new int[8]; + int mask = reader.ReadByte(); - for (int i = 0; i < 8; ++i) - if ((mask & 1 << i) != 0) - Values[i] = reader.ReadInt(); + if (mask != 0) + { + Values = new int[8]; + + for (var i = 0; i < 8; ++i) + if ((mask & (1 << i)) != 0) + Values[i] = reader.ReadInt(); + } + + break; } - - break; - } } if (version == 0) { Compassion *= 200; - Sacrifice *= 250; //Even though 40 (the max) only gives 10k, It's because it was formerly too easy + Sacrifice *= 250; // Even though 40 (the max) only gives 10k, It's because it was formerly too easy - //No direct conversion factor for Justice, this is just an approximation + // No direct conversion factor for Justice, this is just an approximation Justice *= 500; - //All the other virtues haven't been defined at 'version 0' point in time in the scripts. + // All the other virtues haven't been defined at 'version 0' point in time in the scripts. } } - public int[] Values{ get; private set; } + public int[] Values { get; private set; } [CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)] public int Humility @@ -141,15 +141,15 @@ namespace Server } else { - int mask = 0; + var mask = 0; - for (int i = 0; i < 8; ++i) + for (var i = 0; i < 8; ++i) if (info.Values[i] != 0) mask |= 1 << i; writer.Write((byte)mask); - for (int i = 0; i < 8; ++i) + for (var i = 0; i < 8; ++i) if (info.Values[i] != 0) writer.Write(info.Values[i]); } diff --git a/Projects/Server/World.cs b/Projects/Server/World.cs index 4602c7a66..4a8753667 100644 --- a/Projects/Server/World.cs +++ b/Projects/Server/World.cs @@ -53,17 +53,17 @@ namespace Server internal static List m_ItemTypes = new List(); internal static List m_MobileTypes = new List(); - public static bool Saving{ get; private set; } + public static bool Saving { get; private set; } - public static bool Loaded{ get; private set; } + public static bool Loaded { get; private set; } - public static bool Loading{ get; private set; } + public static bool Loading { get; private set; } - public static Dictionary Mobiles{ get; private set; } + public static Dictionary Mobiles { get; private set; } - public static Dictionary Items{ get; private set; } + public static Dictionary Items { get; private set; } - public static string LoadingType{ get; private set; } + public static string LoadingType { get; private set; } public static void NotifyDiskWriteComplete() { @@ -98,11 +98,11 @@ namespace Server else p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text); - List list = TcpServer.Instances; + var list = TcpServer.Instances; p.Acquire(); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) if (list[i].Mobile != null) list[i].Send(p); @@ -116,15 +116,15 @@ namespace Server private static List> ReadTypes(BinaryReader tdbReader) { - int count = tdbReader.ReadInt32(); + var count = tdbReader.ReadInt32(); - List> types = new List>(count); + var types = new List>(count); - for (int i = 0; i < count; ++i) + for (var i = 0; i < count; ++i) { - string typeName = tdbReader.ReadString(); + var typeName = tdbReader.ReadString(); - Type t = AssemblyHandler.FindFirstTypeForName(typeName); + var t = AssemblyHandler.FindFirstTypeForName(typeName); if (t == null) { @@ -151,7 +151,7 @@ namespace Server throw new Exception($"Bad type '{typeName}'"); } - ConstructorInfo ctor = t.GetConstructor(m_SerialTypeArray); + var ctor = t.GetConstructor(m_SerialTypeArray); if (ctor != null) types.Add(new Tuple(ctor, typeName)); @@ -172,7 +172,7 @@ namespace Server Console.Write("World: Loading..."); - Stopwatch watch = Stopwatch.StartNew(); + var watch = Stopwatch.StartNew(); Loading = true; @@ -181,142 +181,138 @@ namespace Server int mobileCount, itemCount, guildCount; - object[] ctorArgs = new object[1]; + var ctorArgs = new object[1]; - List items = new List(); - List mobiles = new List(); - List guilds = new List(); + var items = new List(); + var mobiles = new List(); + var guilds = new List(); if (File.Exists(MobileIndexPath) && File.Exists(MobileTypesPath)) { - using FileStream idx = new FileStream(MobileIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader idxReader = new BinaryReader(idx); + using var idx = new FileStream(MobileIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var idxReader = new BinaryReader(idx); + using var tdb = new FileStream(MobileTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var tdbReader = new BinaryReader(tdb); + var types = ReadTypes(tdbReader); - using (FileStream tdb = new FileStream(MobileTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read)) + mobileCount = idxReader.ReadInt32(); + + Mobiles = new Dictionary(mobileCount); + + for (var i = 0; i < mobileCount; ++i) { - BinaryReader tdbReader = new BinaryReader(tdb); + var typeID = idxReader.ReadInt32(); + var serial = idxReader.ReadUInt32(); + var pos = idxReader.ReadInt64(); + var length = idxReader.ReadInt32(); - List> types = ReadTypes(tdbReader); + var objs = types[typeID]; - mobileCount = idxReader.ReadInt32(); + if (objs == null) + continue; - Mobiles = new Dictionary(mobileCount); + Mobile m = null; + var ctor = objs.Item1; + var typeName = objs.Item2; - for (int i = 0; i < mobileCount; ++i) + try { - int typeID = idxReader.ReadInt32(); - uint serial = idxReader.ReadUInt32(); - long pos = idxReader.ReadInt64(); - int length = idxReader.ReadInt32(); - - Tuple objs = types[typeID]; - - if (objs == null) - continue; - - Mobile m = null; - ConstructorInfo ctor = objs.Item1; - string typeName = objs.Item2; - - try - { - ctorArgs[0] = (Serial)serial; - m = (Mobile)ctor.Invoke(ctorArgs); - } - catch - { - // ignored - } - - if (m != null) - { - mobiles.Add(new MobileEntry(m, typeID, typeName, pos, length)); - AddMobile(m); - } + ctorArgs[0] = (Serial)serial; + m = (Mobile)ctor.Invoke(ctorArgs); + } + catch + { + // ignored } - tdbReader.Close(); + if (m != null) + { + mobiles.Add(new MobileEntry(m, typeID, typeName, pos, length)); + AddMobile(m); + } } + tdbReader.Close(); idxReader.Close(); } else + { Mobiles = new Dictionary(); + } if (File.Exists(ItemIndexPath) && File.Exists(ItemTypesPath)) { - using FileStream idx = new FileStream(ItemIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader idxReader = new BinaryReader(idx); + using var idx = new FileStream(ItemIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var idxReader = new BinaryReader(idx); - using (FileStream tdb = new FileStream(ItemTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read)) + var tdb = new FileStream(ItemTypesPath, FileMode.Open, FileAccess.Read, FileShare.Read); + using var tdbReader = new BinaryReader(tdb); + + var types = ReadTypes(tdbReader); + + itemCount = idxReader.ReadInt32(); + + Items = new Dictionary(itemCount); + + for (var i = 0; i < itemCount; ++i) { - BinaryReader tdbReader = new BinaryReader(tdb); + var typeID = idxReader.ReadInt32(); + var serial = idxReader.ReadUInt32(); + var pos = idxReader.ReadInt64(); + var length = idxReader.ReadInt32(); - List> types = ReadTypes(tdbReader); + var objs = types[typeID]; - itemCount = idxReader.ReadInt32(); + if (objs == null) + continue; - Items = new Dictionary(itemCount); + Item item = null; + var ctor = objs.Item1; + var typeName = objs.Item2; - for (int i = 0; i < itemCount; ++i) + try { - int typeID = idxReader.ReadInt32(); - uint serial = idxReader.ReadUInt32(); - long pos = idxReader.ReadInt64(); - int length = idxReader.ReadInt32(); - - Tuple objs = types[typeID]; - - if (objs == null) - continue; - - Item item = null; - ConstructorInfo ctor = objs.Item1; - string typeName = objs.Item2; - - try - { - ctorArgs[0] = (Serial)serial; - item = (Item)ctor.Invoke(ctorArgs); - } - catch - { - // ignored - } - - if (item != null) - { - items.Add(new ItemEntry(item, typeID, typeName, pos, length)); - AddItem(item); - } + ctorArgs[0] = (Serial)serial; + item = (Item)ctor.Invoke(ctorArgs); + } + catch + { + // ignored } - tdbReader.Close(); + if (item != null) + { + items.Add(new ItemEntry(item, typeID, typeName, pos, length)); + AddItem(item); + } } + tdbReader.Close(); idxReader.Close(); } else + { Items = new Dictionary(); + } if (File.Exists(GuildIndexPath)) { - using FileStream idx = new FileStream(GuildIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryReader idxReader = new BinaryReader(idx); + using var idx = new FileStream(GuildIndexPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var idxReader = new BinaryReader(idx); guildCount = idxReader.ReadInt32(); - CreateGuildEventArgs createEventArgs = new CreateGuildEventArgs(0xFFFFFFFF); - for (int i = 0; i < guildCount; ++i) + var createEventArgs = new CreateGuildEventArgs(0xFFFFFFFF); + for (var i = 0; i < guildCount; ++i) { - idxReader.ReadInt32(); //no typeid for guilds - uint id = idxReader.ReadUInt32(); - long pos = idxReader.ReadInt64(); - int length = idxReader.ReadInt32(); + idxReader.ReadInt32(); // no typeid for guilds + var id = idxReader.ReadUInt32(); + var pos = idxReader.ReadInt64(); + var length = idxReader.ReadInt32(); createEventArgs.Id = id; EventSink.InvokeCreateGuild(createEventArgs); - BaseGuild guild = createEventArgs.Guild; + var guild = createEventArgs.Guild; if (guild != null) guilds.Add(new GuildEntry(guild, pos, length)); } @@ -326,19 +322,19 @@ namespace Server bool failedMobiles = false, failedItems = false, failedGuilds = false; Type failedType = null; - Serial failedSerial = Serial.Zero; + var failedSerial = Serial.Zero; Exception failed = null; - int failedTypeID = 0; + var failedTypeID = 0; if (File.Exists(MobileDataPath)) { - using FileStream bin = new FileStream(MobileDataPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin)); + using var bin = new FileStream(MobileDataPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var reader = new BinaryFileReader(new BinaryReader(bin)); - for (int i = 0; i < mobiles.Count; ++i) + for (var i = 0; i < mobiles.Count; ++i) { - MobileEntry entry = mobiles[i]; - Mobile m = entry.Mobile; + var entry = mobiles[i]; + var m = entry.Mobile; if (m != null) { @@ -372,13 +368,13 @@ namespace Server if (!failedMobiles && File.Exists(ItemDataPath)) { - using FileStream bin = new FileStream(ItemDataPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin)); + using var bin = new FileStream(ItemDataPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var reader = new BinaryFileReader(new BinaryReader(bin)); - for (int i = 0; i < items.Count; ++i) + for (var i = 0; i < items.Count; ++i) { - ItemEntry entry = items[i]; - Item item = entry.Item; + var entry = items[i]; + var item = entry.Item; if (item != null) { @@ -414,13 +410,13 @@ namespace Server if (!failedMobiles && !failedItems && File.Exists(GuildDataPath)) { - using FileStream bin = new FileStream(GuildDataPath, FileMode.Open, FileAccess.Read, FileShare.Read); - BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin)); + using var bin = new FileStream(GuildDataPath, FileMode.Open, FileAccess.Read, FileShare.Read); + var reader = new BinaryFileReader(new BinaryReader(bin)); - for (int i = 0; i < guilds.Count; ++i) + for (var i = 0; i < guilds.Count; ++i) { - GuildEntry entry = guilds[i]; - BaseGuild g = entry.Guild; + var entry = guilds[i]; + var g = entry.Guild; if (g != null) { @@ -431,7 +427,7 @@ namespace Server g.Deserialize(reader); if (reader.Position != entry.Position + entry.Length) - throw new Exception($"***** Bad serialize on Guild {g.Id} *****"); + throw new Exception($"***** Bad serialize on Guild {g.Serial} *****"); } catch (Exception e) { @@ -440,8 +436,8 @@ namespace Server failed = e; failedGuilds = true; failedType = typeof(BaseGuild); - failedTypeID = (int)g.Id; - failedSerial = g.Id; + failedTypeID = g.Serial.ToInt32(); + failedSerial = g.Serial; break; } @@ -471,13 +467,13 @@ namespace Server if (Console.ReadKey(true).Key == ConsoleKey.Y) { if (failedMobiles) - for (int i = 0; i < mobiles.Count;) + for (var i = 0; i < mobiles.Count;) if (mobiles[i].TypeID == failedTypeID) mobiles.RemoveAt(i); else ++i; else if (failedItems) - for (int i = 0; i < items.Count;) + for (var i = 0; i < items.Count;) if (items[i].TypeID == failedTypeID) items.RemoveAt(i); else @@ -509,7 +505,7 @@ namespace Server ProcessSafetyQueues(); - foreach (Item item in Items.Values) + foreach (var item in Items.Values) { if (item.Parent == null) item.UpdateTotals(); @@ -517,7 +513,7 @@ namespace Server item.ClearProperties(); } - foreach (Mobile m in Mobiles.Values) + foreach (var m in Mobiles.Values) { m.UpdateRegion(); // Is this really needed? m.UpdateTotals(); @@ -535,7 +531,7 @@ namespace Server { while (_addQueue.Count > 0) { - IEntity entity = _addQueue.Dequeue(); + var entity = _addQueue.Dequeue(); if (entity is Item item) AddItem(item); @@ -545,7 +541,7 @@ namespace Server while (_deleteQueue.Count > 0) { - IEntity entity = _deleteQueue.Dequeue(); + var entity = _deleteQueue.Dequeue(); if (entity is Item item) item.Delete(); @@ -556,14 +552,14 @@ namespace Server private static void AppendSafetyLog(string action, IEntity entity) { - string message = + var message = $"Warning: Attempted to {action} {entity} during world save.{Environment.NewLine}This action could cause inconsistent state.{Environment.NewLine}It is strongly advised that the offending scripts be corrected."; Console.WriteLine(message); try { - using StreamWriter op = new StreamWriter("world-save-errors.log", true); + using var op = new StreamWriter("world-save-errors.log", true); op.WriteLine("{0}\t{1}", DateTime.UtcNow, message); op.WriteLine(new StackTrace(2).ToString()); op.WriteLine(); @@ -585,14 +581,14 @@ namespace Server if (!Directory.Exists("Saves/Guilds/")) Directory.CreateDirectory("Saves/Guilds/"); - using FileStream idx = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); - BinaryWriter idxWriter = new BinaryWriter(idx); + using var idx = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); + var idxWriter = new BinaryWriter(idx); idxWriter.Write(list.Count); - for (int i = 0; i < list.Count; ++i) + for (var i = 0; i < list.Count; ++i) { - T e = list[i]; + var e = list[i]; idxWriter.Write(e.TypeID); idxWriter.Write(e.Serial); @@ -617,7 +613,7 @@ namespace Server NetState.Pause(); - WaitForWriteCompletion(); //Blocks Save until current disk flush is done. + WaitForWriteCompletion(); // Blocks Save until current disk flush is done. Saving = true; @@ -626,12 +622,12 @@ namespace Server if (message) Broadcast(0x35, true, "The world is saving, please wait."); - SaveStrategy strategy = SaveStrategy.Acquire(); - Console.WriteLine("Core: Using {0} save strategy", strategy.Name.ToLowerInvariant()); + var strategy = SaveStrategy.Acquire(); + Console.WriteLine("Core: Using {0} save strategy", strategy.Name.ToLower()); Console.Write($"[{DateTime.UtcNow.ToLongTimeString()}] World: Saving..."); - Stopwatch watch = Stopwatch.StartNew(); + var watch = Stopwatch.StartNew(); if (!Directory.Exists("Saves/Mobiles/")) Directory.CreateDirectory("Saves/Mobiles/"); @@ -640,7 +636,6 @@ namespace Server if (!Directory.Exists("Saves/Guilds/")) Directory.CreateDirectory("Saves/Guilds/"); - strategy.Save(permitBackgroundWrite); try @@ -657,7 +652,7 @@ namespace Server Saving = false; if (!permitBackgroundWrite) - NotifyDiskWriteComplete(); //Sets the DiskWriteHandle. If we allow background writes, we leave this upto the individual save strategies. + NotifyDiskWriteComplete(); // Sets the DiskWriteHandle. If we allow background writes, we leave this upto the individual save strategies. ProcessSafetyQueues(); @@ -684,7 +679,7 @@ namespace Server public static Mobile FindMobile(Serial serial) { - Mobiles.TryGetValue(serial, out Mobile mob); + Mobiles.TryGetValue(serial, out var mob); return mob; } @@ -704,7 +699,7 @@ namespace Server public static Item FindItem(Serial serial) { - Items.TryGetValue(serial, out Item item); + Items.TryGetValue(serial, out var item); return item; } @@ -734,10 +729,10 @@ namespace Server private interface IEntityEntry { - Serial Serial{ get; } - int TypeID{ get; } - long Position{ get; } - int Length{ get; } + Serial Serial { get; } + int TypeID { get; } + long Position { get; } + int Length { get; } } private sealed class GuildEntry : IEntityEntry @@ -749,15 +744,15 @@ namespace Server Length = length; } - public BaseGuild Guild{ get; } + public BaseGuild Guild { get; } - public Serial Serial => Guild?.Id ?? 0; + public Serial Serial => Guild?.Serial ?? 0; public int TypeID => 0; - public long Position{ get; } + public long Position { get; } - public int Length{ get; } + public int Length { get; } } private sealed class ItemEntry : IEntityEntry @@ -771,17 +766,17 @@ namespace Server Length = length; } - public Item Item{ get; } + public Item Item { get; } - public string TypeName{ get; } + public string TypeName { get; } public Serial Serial => Item?.Serial ?? Serial.MinusOne; - public int TypeID{ get; } + public int TypeID { get; } - public long Position{ get; } + public long Position { get; } - public int Length{ get; } + public int Length { get; } } private sealed class MobileEntry : IEntityEntry @@ -795,17 +790,17 @@ namespace Server Length = length; } - public Mobile Mobile{ get; } + public Mobile Mobile { get; } - public string TypeName{ get; } + public string TypeName { get; } public Serial Serial => Mobile?.Serial ?? Serial.MinusOne; - public int TypeID{ get; } + public int TypeID { get; } - public long Position{ get; } + public long Position { get; } - public int Length{ get; } + public int Length { get; } } } } diff --git a/README.md b/README.md index 0bb1fa8e2..d7806924e 100644 --- a/README.md +++ b/README.md @@ -17,16 +17,15 @@ Ultima Online Server Emulator for the modern era! - [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1) #### Cleaning -- Linux or OSX: `./clean.sh` -- Windows: `clean.cmd` +- `dotnet clean` #### Publishing -- Linux: `./publish-linux.sh` or `publish-linux.cmd` -- OSX: `./publish-osx.sh` or `publish-osx.cmd` -- Windows `./publish-windows.sh` or `publish-windows.cmd` +- Linux: `./Tools/publish-linux.sh` or `Tools/publish-linux.cmd` +- OSX: `./Tools/publish-osx.sh` or `Tools/publish-osx.cmd` +- Windows `./Tools/publish-windows.sh` or `Tools/publish-windows.cmd` ## Deploying / Running Server -- Follow the build instructions +- Follow the [publish](https://github.com/modernuo/ModernUO#publishing-a-build) instructions - Copy `Distribution` directory to production server #### Requirements @@ -34,7 +33,7 @@ Ultima Online Server Emulator for the modern era! - Zlib - Linux: `apt get zlib` or equiv for that distribution - OSX: `brew install zlib` - - Windows is included during publishing + - Windows: Included during publishing - Optional: compile and install [Intel DRNG](https://github.com/modernuo/libdrng) #### Windows diff --git a/Rules.ruleset b/Rules.ruleset new file mode 100644 index 000000000..b75f64bd1 --- /dev/null +++ b/Rules.ruleset @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/clean.cmd b/Tools/clean.cmd similarity index 96% rename from clean.cmd rename to Tools/clean.cmd index 6210bca34..6fe481dfa 100755 --- a/clean.cmd +++ b/Tools/clean.cmd @@ -1,3 +1,5 @@ +del /f .\Projects\*\obj + del /f .\Distribution\Assemblies\BouncyCastle.Crypto.dll del /f .\Distribution\Assemblies\MailKit.dll del /f .\Distribution\Assemblies\Microsoft.AspNetCore.Connections.Abstractions.dll diff --git a/clean.sh b/Tools/clean.sh similarity index 98% rename from clean.sh rename to Tools/clean.sh index 858b55304..d289d4a1b 100755 --- a/clean.sh +++ b/Tools/clean.sh @@ -1,3 +1,5 @@ +rm -rf Projects/*/obj + rm -f Distribution/Assemblies/BouncyCastle.Crypto.dll rm -f Distribution/Assemblies/MailKit.dll rm -f Distribution/Assemblies/Microsoft.AspNetCore.Connections.Abstractions.dll diff --git a/publish-linux-debug.cmd b/Tools/publish-linux-debug.cmd similarity index 100% rename from publish-linux-debug.cmd rename to Tools/publish-linux-debug.cmd diff --git a/publish-linux-debug.sh b/Tools/publish-linux-debug.sh similarity index 100% rename from publish-linux-debug.sh rename to Tools/publish-linux-debug.sh diff --git a/publish-linux.cmd b/Tools/publish-linux.cmd similarity index 100% rename from publish-linux.cmd rename to Tools/publish-linux.cmd diff --git a/publish-linux.sh b/Tools/publish-linux.sh similarity index 100% rename from publish-linux.sh rename to Tools/publish-linux.sh diff --git a/publish-osx-debug.cmd b/Tools/publish-osx-debug.cmd similarity index 100% rename from publish-osx-debug.cmd rename to Tools/publish-osx-debug.cmd diff --git a/publish-osx-debug.sh b/Tools/publish-osx-debug.sh similarity index 100% rename from publish-osx-debug.sh rename to Tools/publish-osx-debug.sh diff --git a/publish-osx.cmd b/Tools/publish-osx.cmd similarity index 100% rename from publish-osx.cmd rename to Tools/publish-osx.cmd diff --git a/publish-osx.sh b/Tools/publish-osx.sh similarity index 100% rename from publish-osx.sh rename to Tools/publish-osx.sh diff --git a/publish-windows-debug.cmd b/Tools/publish-windows-debug.cmd similarity index 100% rename from publish-windows-debug.cmd rename to Tools/publish-windows-debug.cmd diff --git a/publish-windows-debug.sh b/Tools/publish-windows-debug.sh similarity index 100% rename from publish-windows-debug.sh rename to Tools/publish-windows-debug.sh diff --git a/publish-windows.cmd b/Tools/publish-windows.cmd similarity index 100% rename from publish-windows.cmd rename to Tools/publish-windows.cmd diff --git a/publish-windows.sh b/Tools/publish-windows.sh similarity index 100% rename from publish-windows.sh rename to Tools/publish-windows.sh diff --git a/stylecop.json b/stylecop.json new file mode 100644 index 000000000..51f8a2078 --- /dev/null +++ b/stylecop.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", + "settings": { + "indentation": { + "indentationSize": 2 + }, + "orderingRules": { + "usingDirectivesPlacement": "outsideNamespace" + } + } +}