From 66a257ece2843b1bb4208299dd2c269d93247d94 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Fri, 17 Jan 2025 15:21:45 -0800 Subject: [PATCH] feat: Converts OnLogin to a coded generated event (#2070) --- Projects/UOContent/Accounting/Account.cs | 28 ++++++++----------- .../UOContent/Assistants/AssistantHandler.cs | 15 ++++++---- Projects/UOContent/Commands/VisibilityList.cs | 7 ++--- .../UOContent/Engines/ConPVP/DuelContext.cs | 8 ++---- .../Doom/LeverPuzzle/LeverPuzzleRegions.cs | 8 ++++-- .../Engines/Factions/Core/Faction.cs | 6 +++- Projects/UOContent/Engines/Party/Party.cs | 3 +- .../UOContent/Engines/Plants/PlantSystem.cs | 5 +++- .../PlayerMurderSystem.cs | 5 ++-- .../Engines/Veteran Rewards/RewardSystem.cs | 23 +++++++-------- Projects/UOContent/Items/Food/Beverage.cs | 9 +++--- Projects/UOContent/Misc/LightCycle.cs | 8 +++--- Projects/UOContent/Misc/LoginStats.cs | 7 +++-- Projects/UOContent/Misc/ShardPoller.cs | 7 +++-- Projects/UOContent/Misc/StaminaSystem.cs | 19 ++++++------- Projects/UOContent/Mobiles/PlayerMobile.cs | 4 +++ .../UOContent/Multis/Boats/Strandedness.cs | 6 +++- .../Network/Packets/IncomingAccountPackets.cs | 26 +---------------- Projects/UOContent/Regions/HouseRegion.cs | 10 ++++--- .../Regions/TwistedWealdDesertRegion.cs | 9 ++++-- Projects/UOContent/Skills/AntiMacroSystem.cs | 6 ++-- .../Special Systems/Engines/GiftGiving.cs | 9 ++++-- .../Engines/PreventInaccess.cs | 5 +++- .../UOContent/Spells/Ninjitsu/AnimalForm.cs | 7 +++-- .../Spells/Spellweaving/ReaperForm.cs | 9 ++++-- 25 files changed, 127 insertions(+), 122 deletions(-) diff --git a/Projects/UOContent/Accounting/Account.cs b/Projects/UOContent/Accounting/Account.cs index ac7da1abe..73519eb04 100644 --- a/Projects/UOContent/Accounting/Account.cs +++ b/Projects/UOContent/Accounting/Account.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Net; using System.Runtime.CompilerServices; using System.Xml; +using ModernUO.CodeGeneratedEvents; using ModernUO.Serialization; using Server.Accounting.Security; using Server.Misc; @@ -768,31 +769,24 @@ public partial class Account : IAccount, IComparable acc.TotalGameTime += Core.Now - pm.SessionStart; } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (m is not PlayerMobile pm) + if (pm.Account is not Account acc || !pm.Young || !acc.Young) { return; } - if (m.Account is not Account acc) + var ts = YoungDuration - acc.TotalGameTime; + var hours = Math.Max((int)ts.TotalHours, 0); + + if (hours == 1) { - return; + pm.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hour."); } - - if (pm.Young && acc.Young) + else { - var ts = YoungDuration - acc.TotalGameTime; - var hours = Math.Max((int)ts.TotalHours, 0); - - if (hours == 1) - { - m.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hour."); - } - else - { - m.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hours."); - } + pm.SendAsciiMessage($"You will enjoy the benefits and relatively safe status of a young player for {hours} more hours."); } } diff --git a/Projects/UOContent/Assistants/AssistantHandler.cs b/Projects/UOContent/Assistants/AssistantHandler.cs index 55cf0455d..a42e50224 100644 --- a/Projects/UOContent/Assistants/AssistantHandler.cs +++ b/Projects/UOContent/Assistants/AssistantHandler.cs @@ -1,7 +1,9 @@ using System; using System.Buffers; using System.Collections.Generic; +using ModernUO.CodeGeneratedEvents; using Server.Gumps; +using Server.Mobiles; using Server.Network; namespace Server.Assistants; @@ -45,22 +47,23 @@ public static class AssistantHandler m.NetState.LogInfo("Failed to negotiate assistant features."); } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (m?.NetState?.Running != true || !Enabled) + if (pm?.NetState?.Running != true || !Enabled) { return; } - m.NetState.SendAssistVersionReq(); - m.NetState.SendAssistHandshake(); + pm.NetState.SendAssistVersionReq(); + pm.NetState.SendAssistHandshake(); - if (_handshakes.TryGetValue(m, out var t)) + if (_handshakes.TryGetValue(pm, out var t)) { t?.Stop(); } - _handshakes[m] = Timer.DelayCall(TimeSpan.FromSeconds(30), OnTimeout, m); + _handshakes[pm] = Timer.DelayCall(TimeSpan.FromSeconds(30), OnTimeout, pm); } public static void AssistVersion(NetState state, SpanReader reader) diff --git a/Projects/UOContent/Commands/VisibilityList.cs b/Projects/UOContent/Commands/VisibilityList.cs index efc9f010f..0026398bb 100644 --- a/Projects/UOContent/Commands/VisibilityList.cs +++ b/Projects/UOContent/Commands/VisibilityList.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using ModernUO.CodeGeneratedEvents; using Server.Mobiles; using Server.Network; using Server.Targeting; @@ -15,10 +16,8 @@ namespace Server.Commands CommandSystem.Register("VisClear", AccessLevel.Counselor, VisClear_OnCommand); } - public static void OnLogin(Mobile m) - { - (m as PlayerMobile)?.VisibilityList.Clear(); - } + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) => pm.VisibilityList.Clear(); [Usage("Vis")] [Description("Adds or removes a targeted player from your visibility list. Anyone on your visibility list will be able to see you at all times, even when you're hidden.")] diff --git a/Projects/UOContent/Engines/ConPVP/DuelContext.cs b/Projects/UOContent/Engines/ConPVP/DuelContext.cs index 6004b6ba3..15fd66b07 100644 --- a/Projects/UOContent/Engines/ConPVP/DuelContext.cs +++ b/Projects/UOContent/Engines/ConPVP/DuelContext.cs @@ -1291,13 +1291,9 @@ namespace Server.Engines.ConPVP return false; } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (m is not PlayerMobile pm) - { - return; - } - var dc = pm.DuelContext; if (dc == null) diff --git a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs index 4f16460d1..6c983e0e9 100644 --- a/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs +++ b/Projects/UOContent/Engines/Doom/LeverPuzzle/LeverPuzzleRegions.cs @@ -1,3 +1,4 @@ +using ModernUO.CodeGeneratedEvents; using Server.Mobiles; using Server.Regions; @@ -14,12 +15,13 @@ namespace Server.Engines.Doom Register(); } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { var rect = LeverPuzzleController.lr_Rect; - if (m.X >= rect.X && m.X <= rect.X + 10 && m.Y >= rect.Y && m.Y <= rect.Y + 10 && m.Map == Map.Internal) + if (pm.X >= rect.X && pm.X <= rect.X + 10 && pm.Y >= rect.Y && pm.Y <= rect.Y + 10 && pm.Map == Map.Internal) { - Timer kick = new LeverPuzzleController.LampRoomKickTimer(m); + Timer kick = new LeverPuzzleController.LampRoomKickTimer(pm); kick.Start(); } } diff --git a/Projects/UOContent/Engines/Factions/Core/Faction.cs b/Projects/UOContent/Engines/Factions/Core/Faction.cs index a7171c0c2..7368ebe05 100644 --- a/Projects/UOContent/Engines/Factions/Core/Faction.cs +++ b/Projects/UOContent/Engines/Factions/Core/Faction.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; +using ModernUO.CodeGeneratedEvents; using Server.Accounting; using Server.Commands.Generic; using Server.Engines.ConPVP; @@ -1259,7 +1261,9 @@ public abstract class Faction : IComparable } } - public static void OnLogin(Mobile m) => CheckLeaveTimer(m); + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void OnLogin(PlayerMobile pm) => CheckLeaveTimer(pm); public static void WriteReference(IGenericWriter writer, Faction fact) { diff --git a/Projects/UOContent/Engines/Party/Party.cs b/Projects/UOContent/Engines/Party/Party.cs index e474885c8..d20d80948 100644 --- a/Projects/UOContent/Engines/Party/Party.cs +++ b/Projects/UOContent/Engines/Party/Party.cs @@ -160,7 +160,8 @@ namespace Server.Engines.PartySystem } } - public static void OnLogin(Mobile from) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile from) { var p = Get(from); diff --git a/Projects/UOContent/Engines/Plants/PlantSystem.cs b/Projects/UOContent/Engines/Plants/PlantSystem.cs index 3579d31a5..61d017c0f 100644 --- a/Projects/UOContent/Engines/Plants/PlantSystem.cs +++ b/Projects/UOContent/Engines/Plants/PlantSystem.cs @@ -1,7 +1,9 @@ using System; +using ModernUO.CodeGeneratedEvents; using ModernUO.Serialization; using Server.Items; using Server.Misc; +using Server.Mobiles; namespace Server.Engines.Plants { @@ -432,7 +434,8 @@ namespace Server.Engines.Plants } } - public static void OnLogin(Mobile from) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile from) { Container cont = from.Backpack; if (cont != null) diff --git a/Projects/UOContent/Engines/Player Murder System/PlayerMurderSystem.cs b/Projects/UOContent/Engines/Player Murder System/PlayerMurderSystem.cs index 24ecd4543..8a654a697 100644 --- a/Projects/UOContent/Engines/Player Murder System/PlayerMurderSystem.cs +++ b/Projects/UOContent/Engines/Player Murder System/PlayerMurderSystem.cs @@ -80,9 +80,10 @@ public class PlayerMurderSystem : GenericPersistence UpdateMurderContext(context); } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (m is not PlayerMobile pm || !GetMurderContext(pm, out var context)) + if (!GetMurderContext(pm, out var context)) { return; } diff --git a/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs b/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs index 6d486f7fe..7b802f4a3 100644 --- a/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs +++ b/Projects/UOContent/Engines/Veteran Rewards/RewardSystem.cs @@ -1,4 +1,5 @@ using System; +using ModernUO.CodeGeneratedEvents; using Server.Accounting; using Server.Gumps; using Server.Items; @@ -562,35 +563,31 @@ namespace Server.Engines.VeteranRewards RewardInterval = ServerConfiguration.GetOrUpdateSetting("vetRewards.rewardInterval", TimeSpan.FromDays(30.0)); } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (!Enabled) + if (!Enabled || !pm.Alive) { return; } - if (!m.Alive) - { - return; - } + ComputeRewardInfo(pm, out var cur, out var max, out var level); - ComputeRewardInfo(m, out var cur, out var max, out var level); - - if (m.SkillsCap is 7000 or 7050 or 7100 or 7150 or 7200) + if (pm.SkillsCap is 7000 or 7050 or 7100 or 7150 or 7200) { level = Math.Clamp(level, 0, 4); if (SkillCapRewards) { - m.SkillsCap = 7000 + level * 50; + pm.SkillsCap = 7000 + level * 50; } else { - m.SkillsCap = 7000; + pm.SkillsCap = 7000; } } - if (Core.ML && m is PlayerMobile pm && !pm.HasStatReward && HasHalfLevel(pm)) + if (Core.ML && !pm.HasStatReward && HasHalfLevel(pm)) { pm.HasStatReward = true; pm.StatCap += 5; @@ -598,7 +595,7 @@ namespace Server.Engines.VeteranRewards if (cur < max) { - m.SendGump(new RewardNoticeGump(m)); + pm.SendGump(new RewardNoticeGump(pm)); } } } diff --git a/Projects/UOContent/Items/Food/Beverage.cs b/Projects/UOContent/Items/Food/Beverage.cs index f30c6d21e..dd994bfc9 100644 --- a/Projects/UOContent/Items/Food/Beverage.cs +++ b/Projects/UOContent/Items/Food/Beverage.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.Runtime.CompilerServices; +using ModernUO.CodeGeneratedEvents; using ModernUO.Serialization; using Server.Collections; using Server.Engines.Plants; @@ -711,10 +713,9 @@ public abstract partial class BaseBeverage : Item, IHasQuantity _quantity = reader.ReadInt(); } - public static void OnLogin(Mobile m) - { - CheckHeaveTimer(m); - } + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void OnLogin(PlayerMobile pm) => CheckHeaveTimer(pm); public static void CheckHeaveTimer(Mobile from) { diff --git a/Projects/UOContent/Misc/LightCycle.cs b/Projects/UOContent/Misc/LightCycle.cs index 7277c299b..441fefeb2 100644 --- a/Projects/UOContent/Misc/LightCycle.cs +++ b/Projects/UOContent/Misc/LightCycle.cs @@ -1,5 +1,7 @@ using System; +using ModernUO.CodeGeneratedEvents; using Server.Items; +using Server.Mobiles; using Server.Network; namespace Server @@ -55,10 +57,8 @@ namespace Server } } - public static void OnLogin(Mobile m) - { - m.CheckLightLevels(true); - } + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) => pm.CheckLightLevels(true); public static int ComputeLevelFor(Mobile from) { diff --git a/Projects/UOContent/Misc/LoginStats.cs b/Projects/UOContent/Misc/LoginStats.cs index 44c3e006e..d7f163afd 100644 --- a/Projects/UOContent/Misc/LoginStats.cs +++ b/Projects/UOContent/Misc/LoginStats.cs @@ -1,17 +1,18 @@ +using Server.Mobiles; using Server.Network; namespace Server.Misc { public static class LoginStats { - public static void OnLogin(Mobile m) + public static void OnLogin(PlayerMobile pm) { var userCount = NetState.Instances.Count; var itemCount = World.Items.Count; var mobileCount = World.Mobiles.Count; - m.SendMessage( - $"Welcome, {m.Name}! There {(userCount == 1 ? "is" : "are")} currently {userCount} user{(userCount == 1 ? "" : "s")} " + + pm.SendMessage( + $"Welcome, {pm.Name}! There {(userCount == 1 ? "is" : "are")} currently {userCount} user{(userCount == 1 ? "" : "s")} " + $"online, with {itemCount} item{(itemCount == 1 ? "" : "s")} and {mobileCount} mobile{(mobileCount == 1 ? "" : "s")} in the world." ); } diff --git a/Projects/UOContent/Misc/ShardPoller.cs b/Projects/UOContent/Misc/ShardPoller.cs index 2d408f945..682003c58 100644 --- a/Projects/UOContent/Misc/ShardPoller.cs +++ b/Projects/UOContent/Misc/ShardPoller.cs @@ -2,8 +2,10 @@ using System; using System.Collections.Generic; using System.Net; using System.Text.RegularExpressions; +using ModernUO.CodeGeneratedEvents; using ModernUO.Serialization; using Server.Gumps; +using Server.Mobiles; using Server.Network; using Server.Prompts; @@ -125,14 +127,15 @@ public partial class ShardPoller : Item Options[^1] = option; } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { if (_activePollers.Count == 0) { return; } - Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => EventSink_Login_Callback(m)); + Timer.StartTimer(TimeSpan.FromSeconds(1.0), () => EventSink_Login_Callback(pm)); } private static void EventSink_Login_Callback(Mobile from) diff --git a/Projects/UOContent/Misc/StaminaSystem.cs b/Projects/UOContent/Misc/StaminaSystem.cs index 845496c2e..e4704e310 100644 --- a/Projects/UOContent/Misc/StaminaSystem.cs +++ b/Projects/UOContent/Misc/StaminaSystem.cs @@ -82,17 +82,19 @@ public static class StaminaSystem RemoveEntry(m as IHasSteps); } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { + bool exists; if (EnableMountStamina) { // Start idle for mount - ref var stepsTaken = ref GetStepsTaken(m.Mount, out var exists); + ref var stepsTaken = ref GetStepsTaken(pm.Mount, out exists); if (exists) { if (stepsTaken.Steps <= 0 || Core.Now >= stepsTaken.IdleStartTime + ResetDuration) { - _stepsTaken.Remove(m.Mount); + _stepsTaken.Remove(pm.Mount); } else { @@ -100,16 +102,13 @@ public static class StaminaSystem } } - _resetHash.Remove(m.Mount); + _resetHash.Remove(pm.Mount); } - if (m is PlayerMobile pm) + ref var regenStepsTaken = ref RegenSteps(pm, out exists); + if (exists) { - ref var stepsTaken = ref RegenSteps(pm, out var exists); - if (exists) - { - stepsTaken.IdleStartTime = Core.Now; - } + regenStepsTaken.IdleStartTime = Core.Now; } } diff --git a/Projects/UOContent/Mobiles/PlayerMobile.cs b/Projects/UOContent/Mobiles/PlayerMobile.cs index f2ea4fa28..5e5f9352b 100644 --- a/Projects/UOContent/Mobiles/PlayerMobile.cs +++ b/Projects/UOContent/Mobiles/PlayerMobile.cs @@ -1220,6 +1220,10 @@ namespace Server.Mobiles } } + [GeneratedEvent(nameof(PlayerLoginEvent))] + public static partial void PlayerLoginEvent(PlayerMobile pm); + + [OnEvent(nameof(PlayerLoginEvent))] public static void OnLogin(PlayerMobile from) { if (AccountHandler.LockdownLevel > AccessLevel.Player) diff --git a/Projects/UOContent/Multis/Boats/Strandedness.cs b/Projects/UOContent/Multis/Boats/Strandedness.cs index 5dd6f742f..4779289b8 100644 --- a/Projects/UOContent/Multis/Boats/Strandedness.cs +++ b/Projects/UOContent/Multis/Boats/Strandedness.cs @@ -1,3 +1,6 @@ +using ModernUO.CodeGeneratedEvents; +using Server.Mobiles; + namespace Server.Misc { public static class Strandedness @@ -112,7 +115,8 @@ namespace Server.Misc return false; } - public static void OnLogin(Mobile from) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile from) { if (!IsStranded(from)) { diff --git a/Projects/UOContent/Network/Packets/IncomingAccountPackets.cs b/Projects/UOContent/Network/Packets/IncomingAccountPackets.cs index 099072b36..60f32dc81 100644 --- a/Projects/UOContent/Network/Packets/IncomingAccountPackets.cs +++ b/Projects/UOContent/Network/Packets/IncomingAccountPackets.cs @@ -314,34 +314,10 @@ public static class IncomingAccountPackets state.SendPlayMusic(m.Region.Music); - StaminaSystem.OnLogin(m); - DuelContext.OnLogin(m); - LightCycle.OnLogin(m); - LoginStats.OnLogin(m); - AnimalForm.OnLogin(m); - BaseBeverage.OnLogin(m); - AntiMacroSystem.OnLogin(m); - Strandedness.OnLogin(m); - ShardPoller.OnLogin(m); - ReaperFormSpell.OnLogin(m); - Party.OnLogin(m); - PlantSystem.OnLogin(m); - LampRoomRegion.OnLogin(m); - HouseRegion.OnLogin(m); - Faction.OnLogin(m); - PlayerMurderSystem.OnLogin(m); - AssistantHandler.OnLogin(m); - VisibilityList.OnLogin(m); - if (m is PlayerMobile pm) { - PlayerMobile.OnLogin(pm); + PlayerMobile.PlayerLoginEvent(pm); } - Account.OnLogin(m); - GiftGiving.OnLogin(m); - PreventInaccess.OnLogin(m); - TwistedWealdDesertRegion.OnLogin(m); - RewardSystem.OnLogin(m); } private static int GenerateAuthID(this NetState state) diff --git a/Projects/UOContent/Regions/HouseRegion.cs b/Projects/UOContent/Regions/HouseRegion.cs index cd533c776..6c7ec59b0 100644 --- a/Projects/UOContent/Regions/HouseRegion.cs +++ b/Projects/UOContent/Regions/HouseRegion.cs @@ -1,4 +1,5 @@ using System; +using ModernUO.CodeGeneratedEvents; using Server.Gumps; using Server.Items; using Server.Mobiles; @@ -29,13 +30,14 @@ public class HouseRegion : BaseRegion { } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - var house = BaseHouse.FindHouseAt(m); + var house = BaseHouse.FindHouseAt(pm); - if (house?.Public == false && !house.IsFriend(m)) + if (house?.Public == false && !house.IsFriend(pm)) { - m.Location = house.BanLocation; + pm.Location = house.BanLocation; } } diff --git a/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs b/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs index 558148283..7d4e9b156 100644 --- a/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs +++ b/Projects/UOContent/Regions/TwistedWealdDesertRegion.cs @@ -1,4 +1,6 @@ using System.Text.Json.Serialization; +using ModernUO.CodeGeneratedEvents; +using Server.Mobiles; using Server.Network; using Server.Spells; using Server.Spells.Ninjitsu; @@ -41,11 +43,12 @@ public class TwistedWealdDesertRegion : MondainRegion } } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (m.Region.IsPartOf() && m.AccessLevel == AccessLevel.Player) + if (pm.AccessLevel == AccessLevel.Player && pm.Region.IsPartOf()) { - m.NetState.SendSpeedControl(SpeedControlSetting.Walk); + pm.NetState.SendSpeedControl(SpeedControlSetting.Walk); } } } diff --git a/Projects/UOContent/Skills/AntiMacroSystem.cs b/Projects/UOContent/Skills/AntiMacroSystem.cs index 1ba547775..ffc4e0bc0 100644 --- a/Projects/UOContent/Skills/AntiMacroSystem.cs +++ b/Projects/UOContent/Skills/AntiMacroSystem.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.IO; using System.Runtime.InteropServices; using System.Text.Json.Serialization; +using ModernUO.CodeGeneratedEvents; using Server.Collections; using Server.Json; using Server.Mobiles; @@ -138,10 +139,11 @@ public static class AntiMacroSystem } } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { // Stop the clear out timer - if (_logoutCleanup?.Remove(m, out var timer) == true) + if (_logoutCleanup?.Remove(pm, out var timer) == true) { timer.Stop(); } diff --git a/Projects/UOContent/Special Systems/Engines/GiftGiving.cs b/Projects/UOContent/Special Systems/Engines/GiftGiving.cs index efe4a9ace..763a5efcf 100644 --- a/Projects/UOContent/Special Systems/Engines/GiftGiving.cs +++ b/Projects/UOContent/Special Systems/Engines/GiftGiving.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +using ModernUO.CodeGeneratedEvents; using Server.Accounting; +using Server.Mobiles; namespace Server.Misc { @@ -19,9 +21,10 @@ namespace Server.Misc m_Givers.Add(giver); } - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (m.Account is not Account acct) + if (pm.Account is not Account acct) { return; } @@ -47,7 +50,7 @@ namespace Server.Misc continue; // already got one } - giver.DelayGiveGift(TimeSpan.FromSeconds(5.0), m); + giver.DelayGiveGift(TimeSpan.FromSeconds(5.0), pm); } acct.LastLogin = now; diff --git a/Projects/UOContent/Special Systems/Engines/PreventInaccess.cs b/Projects/UOContent/Special Systems/Engines/PreventInaccess.cs index ccf96144e..8e45c53a7 100644 --- a/Projects/UOContent/Special Systems/Engines/PreventInaccess.cs +++ b/Projects/UOContent/Special Systems/Engines/PreventInaccess.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using ModernUO.CodeGeneratedEvents; +using Server.Mobiles; namespace Server.Misc { @@ -34,7 +36,8 @@ namespace Server.Misc m_MoveHistory = new Dictionary(); } - public static void OnLogin(Mobile from) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile from) { if (!Enabled) { diff --git a/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs b/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs index 24cbeea0a..abe0847d9 100644 --- a/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs +++ b/Projects/UOContent/Spells/Ninjitsu/AnimalForm.cs @@ -64,11 +64,12 @@ public class AnimalForm : NinjaSpell new(typeof(Reptalon), 1075202, 11669, 0, 1075222, 90.0, 0x114, 0, 0, false, false) }; - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - if (GetContext(m)?.SpeedBoost == true) + if (GetContext(pm)?.SpeedBoost == true) { - m.NetState.SendSpeedControl(SpeedControlSetting.Mount); + pm.NetState.SendSpeedControl(SpeedControlSetting.Mount); } } diff --git a/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs b/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs index d853c4d70..59ec73dc1 100644 --- a/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs +++ b/Projects/UOContent/Spells/Spellweaving/ReaperForm.cs @@ -1,4 +1,6 @@ using System; +using ModernUO.CodeGeneratedEvents; +using Server.Mobiles; using Server.Network; namespace Server.Spells.Spellweaving @@ -27,13 +29,14 @@ namespace Server.Spells.Spellweaving public virtual int SwingSpeedBonus => 10 + FocusLevel; public virtual int SpellDamageBonus => 10 + FocusLevel; - public static void OnLogin(Mobile m) + [OnEvent(nameof(PlayerMobile.PlayerLoginEvent))] + public static void OnLogin(PlayerMobile pm) { - var context = TransformationSpellHelper.GetContext(m); + var context = TransformationSpellHelper.GetContext(pm); if (context?.Type == typeof(ReaperFormSpell)) { - m.NetState.SendSpeedControl(SpeedControlSetting.Walk); + pm.NetState.SendSpeedControl(SpeedControlSetting.Walk); } }