fix: Moves many EventSinks out of core. (#1783)

This commit is contained in:
Marcelo Paez Sequeira 2024-05-21 14:02:30 -03:00 committed by GitHub
parent 1cb798d807
commit 00908d030f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 133 additions and 276 deletions

View file

@ -21,37 +21,9 @@ namespace Server;
public static partial class EventSink public static partial class EventSink
{ {
public static event Action<Mobile> OpenDoorMacroUsed;
public static void InvokeOpenDoorMacroUsed(Mobile m) => OpenDoorMacroUsed?.Invoke(m);
public static event Action<Mobile> Login;
public static void InvokeLogin(Mobile m) => Login?.Invoke(m);
public static event Action<Mobile, int> HungerChanged;
public static void InvokeHungerChanged(Mobile mobile, int oldValue) => HungerChanged?.Invoke(mobile, oldValue);
public static event Action Shutdown; public static event Action Shutdown;
public static void InvokeShutdown() => Shutdown?.Invoke(); public static void InvokeShutdown() => Shutdown?.Invoke();
public static event Action<Mobile> HelpRequest;
public static void InvokeHelpRequest(Mobile m) => HelpRequest?.Invoke(m);
public static event Action<Mobile, int> OpenSpellbookRequest;
public static void InvokeOpenSpellbookRequest(Mobile m, int type) => OpenSpellbookRequest?.Invoke(m, type);
public static event Action<Mobile, int, Item> CastSpellRequest;
public static void InvokeCastSpellRequest(Mobile m, int spellID, Item book) =>
CastSpellRequest?.Invoke(m, spellID, book);
public static event Action<Mobile, Item, Mobile> BandageTargetRequest;
public static void InvokeBandageTargetRequest(Mobile m, Item bandage, Mobile target) =>
BandageTargetRequest?.Invoke(m, bandage, target);
public static event Action<Mobile, string> AnimateRequest;
public static void InvokeAnimateRequest(Mobile m, string action) => AnimateRequest?.Invoke(m, action);
public static event Action<Mobile> Logout; public static event Action<Mobile> Logout;
public static void InvokeLogout(Mobile m) => Logout?.Invoke(m); public static void InvokeLogout(Mobile m) => Logout?.Invoke(m);
@ -64,11 +36,6 @@ public static partial class EventSink
public static event Action<Mobile> Disconnected; public static event Action<Mobile> Disconnected;
public static void InvokeDisconnected(Mobile m) => Disconnected?.Invoke(m); public static void InvokeDisconnected(Mobile m) => Disconnected?.Invoke(m);
public static event Action<Mobile, Mobile, string> RenameRequest;
public static void InvokeRenameRequest(Mobile from, Mobile target, string name) =>
RenameRequest?.Invoke(from, target, name);
public static event Action<Mobile> PlayerDeath; public static event Action<Mobile> PlayerDeath;
public static void InvokePlayerDeath(Mobile m) => PlayerDeath?.Invoke(m); public static void InvokePlayerDeath(Mobile m) => PlayerDeath?.Invoke(m);
@ -82,64 +49,9 @@ public static partial class EventSink
public static void InvokePaperdollRequest(Mobile beholder, Mobile beheld) => public static void InvokePaperdollRequest(Mobile beholder, Mobile beheld) =>
PaperdollRequest?.Invoke(beholder, beheld); PaperdollRequest?.Invoke(beholder, beheld);
public static event Action<Mobile, Mobile> ProfileRequest;
public static void InvokeProfileRequest(Mobile beholder, Mobile beheld) => ProfileRequest?.Invoke(beholder, beheld);
public static event Action<Mobile, Mobile, string> ChangeProfileRequest;
public static void InvokeChangeProfileRequest(Mobile beholder, Mobile beheld, string text) =>
ChangeProfileRequest?.Invoke(beholder, beheld, text);
public static event Action<NetState, int> DeleteRequest;
public static void InvokeDeleteRequest(NetState state, int index) => DeleteRequest?.Invoke(state, index);
public static event Action<Mobile> PlayerDeleted;
public static void InvokePlayerDeleted(Mobile m) => PlayerDeleted?.Invoke(m);
public static event Action ServerStarted; public static event Action ServerStarted;
public static void InvokeServerStarted() => ServerStarted?.Invoke(); public static void InvokeServerStarted() => ServerStarted?.Invoke();
public static event Action<Mobile> GuildGumpRequest;
public static void InvokeGuildGumpRequest(Mobile m) => GuildGumpRequest?.Invoke(m);
public static event Action<Mobile> QuestGumpRequest;
public static void InvokeQuestGumpRequest(Mobile m) => QuestGumpRequest?.Invoke(m);
public static event Action<NetState, ClientVersion> ClientVersionReceived;
public static void InvokeClientVersionReceived(NetState state, ClientVersion cv) =>
ClientVersionReceived?.Invoke(state, cv);
public static event Action<Mobile, List<Serial>> EquipMacro;
public static void InvokeEquipMacro(Mobile m, List<Serial> list)
{
if (list?.Count > 0)
{
EquipMacro?.Invoke(m, list);
}
}
public static event Action<Mobile, List<Layer>> UnequipMacro;
public static void InvokeUnequipMacro(Mobile m, List<Layer> layers)
{
if (layers?.Count > 0)
{
UnequipMacro?.Invoke(m, layers);
}
}
public static event Action<Mobile, IEntity, int> TargetedSpell;
public static void InvokeTargetedSpell(Mobile m, IEntity target, int spellId) =>
TargetedSpell?.Invoke(m, target, spellId);
public static event Action<Mobile, IEntity, int> TargetedSkillUse;
public static void InvokeTargetedSkillUse(Mobile m, IEntity target, int skillId) =>
TargetedSkillUse?.Invoke(m, target, skillId);
public static event Action<Mobile, Item, short> TargetByResourceMacro; public static event Action<Mobile, Item, short> TargetByResourceMacro;
public static void InvokeTargetByResourceMacro(Mobile m, Item item, short resourceType) => public static void InvokeTargetByResourceMacro(Mobile m, Item item, short resourceType) =>

View file

@ -490,8 +490,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
if (oldValue != value) if (oldValue != value)
{ {
m_Hunger = value; m_Hunger = value;
OnHungerChanged(oldValue);
EventSink.InvokeHungerChanged(this, oldValue);
} }
} }
} }
@ -3698,6 +3697,14 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
{ {
} }
/// <summary>
/// Overridable. Virtual event invoked after the <see cref="Hunger" /> property has changed.
/// <seealso cref="Hunger" />
/// </summary>
public virtual void OnHungerChanged(int oldValue)
{
}
public double GetDistanceToSqrt(Point3D p) public double GetDistanceToSqrt(Point3D p)
{ {
var xDelta = m_Location.m_X - p.m_X; var xDelta = m_Location.m_X - p.m_X;

View file

@ -732,7 +732,6 @@ namespace Server.Accounting
{ {
EventSink.Connected += EventSink_Connected; EventSink.Connected += EventSink_Connected;
EventSink.Disconnected += EventSink_Disconnected; EventSink.Disconnected += EventSink_Disconnected;
EventSink.Login += EventSink_Login;
} }
private static void EventSink_Connected(Mobile m) private static void EventSink_Connected(Mobile m)
@ -770,7 +769,7 @@ namespace Server.Accounting
acc.TotalGameTime += Core.Now - pm.SessionStart; acc.TotalGameTime += Core.Now - pm.SessionStart;
} }
private static void EventSink_Login(Mobile m) public static void OnLogin(Mobile m)
{ {
if (m is not PlayerMobile pm) if (m is not PlayerMobile pm)
{ {

View file

@ -2,7 +2,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using Server.Accounting; using Server.Accounting;
using Server.Engines.CannedEvil;
using Server.Engines.Help; using Server.Engines.Help;
using Server.Engines.PlayerMurderSystem;
using Server.Engines.Virtues;
using Server.Logging; using Server.Logging;
using Server.Network; using Server.Network;
using Server.Regions; using Server.Regions;
@ -64,7 +67,6 @@ public static class AccountHandler
public static void Initialize() public static void Initialize()
{ {
EventSink.DeleteRequest += EventSink_DeleteRequest;
EventSink.AccountLogin += EventSink_AccountLogin; EventSink.AccountLogin += EventSink_AccountLogin;
EventSink.GameLogin += EventSink_GameLogin; EventSink.GameLogin += EventSink_GameLogin;
} }
@ -182,7 +184,7 @@ public static class AccountHandler
} }
} }
private static void EventSink_DeleteRequest(NetState state, int index) public static void DeleteRequest(NetState state, int index)
{ {
if (state.Account is not Account acct) if (state.Account is not Account acct)
{ {
@ -228,7 +230,11 @@ public static class AccountHandler
m.Delete(); m.Delete();
EventSink.InvokePlayerDeleted(m); StaminaSystem.OnPlayerDeleted(m);
JusticeVirtue.OnPlayerDeleted(m);
PlayerMurderSystem.OnPlayerDeleted(m);
ChampionTitleSystem.OnPlayerDeleted(m);
state.SendCharacterListUpdate(acct); state.SendCharacterListUpdate(acct);
return; return;
} }

View file

@ -16,8 +16,6 @@ public static class AssistantHandler
{ {
Enabled = ServerConfiguration.GetOrUpdateSetting("assistants.enableNegotiation", false); Enabled = ServerConfiguration.GetOrUpdateSetting("assistants.enableNegotiation", false);
EventSink.Login += OnLogin;
IncomingPackets.Register(0xBE, 0, false, &AssistVersion); IncomingPackets.Register(0xBE, 0, false, &AssistVersion);
AssistantProtocol.Register(0xFF, false, &HandshakeResponse); AssistantProtocol.Register(0xFF, false, &HandshakeResponse);
} }
@ -47,7 +45,7 @@ public static class AssistantHandler
m.NetState.LogInfo("Failed to negotiate assistant features."); m.NetState.LogInfo("Failed to negotiate assistant features.");
} }
private static void OnLogin(Mobile m) public static void OnLogin(Mobile m)
{ {
if (m?.NetState?.Running != true || !Enabled) if (m?.NetState?.Running != true || !Enabled)
{ {

View file

@ -10,8 +10,6 @@ namespace Server.Commands
{ {
public static void Configure() public static void Configure()
{ {
EventSink.Login += OnLogin;
CommandSystem.Register("Vis", AccessLevel.Counselor, Vis_OnCommand); CommandSystem.Register("Vis", AccessLevel.Counselor, Vis_OnCommand);
CommandSystem.Register("VisList", AccessLevel.Counselor, VisList_OnCommand); CommandSystem.Register("VisList", AccessLevel.Counselor, VisList_OnCommand);
CommandSystem.Register("VisClear", AccessLevel.Counselor, VisClear_OnCommand); CommandSystem.Register("VisClear", AccessLevel.Counselor, VisClear_OnCommand);

View file

@ -22,12 +22,10 @@ public class ChampionTitleSystem : GenericPersistence
public static void Initialize() public static void Initialize()
{ {
EventSink.PlayerDeleted += OnPlayerDeleted;
_championTitleTimer.Start(); _championTitleTimer.Start();
} }
private static void OnPlayerDeleted(Mobile m) public static void OnPlayerDeleted(Mobile m)
{ {
if (m is PlayerMobile pm) if (m is PlayerMobile pm)
{ {

View file

@ -1234,7 +1234,6 @@ namespace Server.Engines.ConPVP
public static void Configure() public static void Configure()
{ {
EventSink.Speech += EventSink_Speech; EventSink.Speech += EventSink_Speech;
EventSink.Login += EventSink_Login;
CommandSystem.Register("vli", AccessLevel.GameMaster, vli_oc); CommandSystem.Register("vli", AccessLevel.GameMaster, vli_oc);
} }
@ -1288,7 +1287,7 @@ namespace Server.Engines.ConPVP
return false; return false;
} }
private static void EventSink_Login(Mobile m) public static void OnLogin(Mobile m)
{ {
if (m is not PlayerMobile pm) if (m is not PlayerMobile pm)
{ {

View file

@ -14,11 +14,6 @@ namespace Server.Engines.Doom
Register(); Register();
} }
public static void Initialize()
{
EventSink.Login += OnLogin;
}
public static void OnLogin(Mobile m) public static void OnLogin(Mobile m)
{ {
var rect = LeverPuzzleController.lr_Rect; var rect = LeverPuzzleController.lr_Rect;

View file

@ -641,7 +641,6 @@ namespace Server.Factions
public static void Configure() public static void Configure()
{ {
EventSink.Login += EventSink_Login;
EventSink.Logout += EventSink_Logout; EventSink.Logout += EventSink_Logout;
CommandSystem.Register("FactionElection", AccessLevel.GameMaster, FactionElection_OnCommand); CommandSystem.Register("FactionElection", AccessLevel.GameMaster, FactionElection_OnCommand);
@ -1278,7 +1277,7 @@ namespace Server.Factions
} }
} }
private static void EventSink_Login(Mobile m) => CheckLeaveTimer(m); public static void OnLogin(Mobile m) => CheckLeaveTimer(m);
public static void WriteReference(IGenericWriter writer, Faction fact) public static void WriteReference(IGenericWriter writer, Faction fact)
{ {

View file

@ -286,12 +286,7 @@ namespace Server.Engines.Help
AddHtmlLocalized(180, 390, 335, 40, 1001015); // NO - I meant to ask for help with another matter. AddHtmlLocalized(180, 390, 335, 40, 1001015); // NO - I meant to ask for help with another matter.
} }
public static void Initialize() public static void HelpRequest(Mobile m)
{
EventSink.HelpRequest += EventSink_HelpRequest;
}
private static void EventSink_HelpRequest(Mobile m)
{ {
foreach (var gump in m.NetState.Gumps) foreach (var gump in m.NetState.Gumps)
{ {

View file

@ -151,8 +151,6 @@ namespace Server.Engines.MLQuests
TargetCommands.Register(new ViewQuestsCommand()); TargetCommands.Register(new ViewQuestsCommand());
TargetCommands.Register(new ViewContextCommand()); TargetCommands.Register(new ViewContextCommand());
EventSink.QuestGumpRequest += EventSink_QuestGumpRequest;
} }
public static void Initialize() public static void Initialize()
@ -649,7 +647,7 @@ namespace Server.Engines.MLQuests
} }
} }
public static void EventSink_QuestGumpRequest(Mobile m) public static void QuestGumpRequest(Mobile m)
{ {
if (!Enabled || m is not PlayerMobile pm) if (!Enabled || m is not PlayerMobile pm)
{ {

View file

@ -99,7 +99,6 @@ namespace Server.Engines.PartySystem
public static void Configure() public static void Configure()
{ {
EventSink.Logout += EventSink_Logout; EventSink.Logout += EventSink_Logout;
EventSink.Login += EventSink_Login;
EventSink.PlayerDeath += EventSink_PlayerDeath; EventSink.PlayerDeath += EventSink_PlayerDeath;
CommandSystem.Register("ListenToParty", AccessLevel.GameMaster, ListenToParty_OnCommand); CommandSystem.Register("ListenToParty", AccessLevel.GameMaster, ListenToParty_OnCommand);
@ -159,7 +158,7 @@ namespace Server.Engines.PartySystem
} }
} }
public static void EventSink_Login(Mobile from) public static void OnLogin(Mobile from)
{ {
var p = Get(from); var p = Get(from);

View file

@ -397,11 +397,9 @@ namespace Server.Engines.Plants
{ {
EventSink.WorldSave += EventSink_WorldSave; EventSink.WorldSave += EventSink_WorldSave;
} }
EventSink.Login += EventSink_Login;
} }
private static void EventSink_Login(Mobile from) public static void OnLogin(Mobile from)
{ {
Container cont = from.Backpack; Container cont = from.Backpack;
if (cont != null) if (cont != null)

View file

@ -39,11 +39,9 @@ public class PlayerMurderSystem : GenericPersistence
public static void Initialize() public static void Initialize()
{ {
EventSink.Disconnected += OnDisconnected; EventSink.Disconnected += OnDisconnected;
EventSink.Login += OnLogin;
EventSink.PlayerDeleted += OnPlayerDeleted;
} }
private static void OnPlayerDeleted(Mobile m) public static void OnPlayerDeleted(Mobile m)
{ {
if (m is PlayerMobile pm && _murderContexts.Remove(pm, out var context)) if (m is PlayerMobile pm && _murderContexts.Remove(pm, out var context))
{ {
@ -80,7 +78,7 @@ public class PlayerMurderSystem : GenericPersistence
UpdateMurderContext(context); UpdateMurderContext(context);
} }
private static void OnLogin(Mobile m) public static void OnLogin(Mobile m)
{ {
if (m is not PlayerMobile pm || !GetMurderContext(pm, out var context)) if (m is not PlayerMobile pm || !GetMurderContext(pm, out var context))
{ {

View file

@ -561,16 +561,13 @@ namespace Server.Engines.VeteranRewards
RewardInterval = ServerConfiguration.GetOrUpdateSetting("vetRewards.rewardInterval", TimeSpan.FromDays(30.0)); RewardInterval = ServerConfiguration.GetOrUpdateSetting("vetRewards.rewardInterval", TimeSpan.FromDays(30.0));
} }
public static void Initialize() public static void OnLogin(Mobile m)
{ {
if (Enabled) if (!Enabled)
{ {
EventSink.Login += EventSink_Login; return;
} }
}
private static void EventSink_Login(Mobile m)
{
if (!m.Alive) if (!m.Alive)
{ {
return; return;

View file

@ -82,10 +82,9 @@ public class JusticeVirtue
public static void Initialize() public static void Initialize()
{ {
VirtueGump.Register(109, OnVirtueUsed); VirtueGump.Register(109, OnVirtueUsed);
EventSink.PlayerDeleted += OnPlayerDeleted;
} }
private static void OnPlayerDeleted(Mobile m) public static void OnPlayerDeleted(Mobile m)
{ {
if (m is PlayerMobile pm) if (m is PlayerMobile pm)
{ {

View file

@ -125,8 +125,6 @@ public abstract partial class BaseDoor : Item, ILockable, ITelekinesisable
public static void Configure() public static void Configure()
{ {
EventSink.OpenDoorMacroUsed += EventSink_OpenDoorMacroUsed;
CommandSystem.Register("Link", AccessLevel.GameMaster, Link_OnCommand); CommandSystem.Register("Link", AccessLevel.GameMaster, Link_OnCommand);
CommandSystem.Register("ChainLink", AccessLevel.GameMaster, ChainLink_OnCommand); CommandSystem.Register("ChainLink", AccessLevel.GameMaster, ChainLink_OnCommand);
} }
@ -225,7 +223,7 @@ public abstract partial class BaseDoor : Item, ILockable, ITelekinesisable
} }
} }
private static void EventSink_OpenDoorMacroUsed(Mobile m) public static void OpenDoorMacroUsed(Mobile m)
{ {
if (m.Map == null || !m.CheckAlive()) if (m.Map == null || !m.CheckAlive())
{ {

View file

@ -711,12 +711,7 @@ public abstract partial class BaseBeverage : Item, IHasQuantity
_quantity = reader.ReadInt(); _quantity = reader.ReadInt();
} }
public static void Initialize() public static void OnLogin(Mobile m)
{
EventSink.Login += EventSink_Login;
}
private static void EventSink_Login(Mobile m)
{ {
CheckHeaveTimer(m); CheckHeaveTimer(m);
} }

View file

@ -215,10 +215,6 @@ public partial class Spellbook : Item, ICraftable, ISlayer, IAosItem
public static void Configure() public static void Configure()
{ {
EventSink.OpenSpellbookRequest += EventSink_OpenSpellbookRequest;
EventSink.CastSpellRequest += EventSink_CastSpellRequest;
EventSink.TargetedSpell += EventSink_TargetedSpell;
CommandSystem.Register("AllSpells", AccessLevel.GameMaster, AllSpells_OnCommand); CommandSystem.Register("AllSpells", AccessLevel.GameMaster, AllSpells_OnCommand);
} }
@ -249,7 +245,7 @@ public partial class Spellbook : Item, ICraftable, ISlayer, IAosItem
} }
} }
private static void EventSink_OpenSpellbookRequest(Mobile from, int typeID) public static void OpenSpellbookRequest(Mobile from, int typeID)
{ {
if (!DesignContext.Check(from)) if (!DesignContext.Check(from))
{ {
@ -273,7 +269,7 @@ public partial class Spellbook : Item, ICraftable, ISlayer, IAosItem
book?.DisplayTo(from); book?.DisplayTo(from);
} }
private static void EventSink_TargetedSpell(Mobile from, IEntity target, int spellId) public static void TargetedSpell(Mobile from, IEntity target, int spellId)
{ {
if (!DesignContext.Check(from)) if (!DesignContext.Check(from))
{ {
@ -300,7 +296,7 @@ public partial class Spellbook : Item, ICraftable, ISlayer, IAosItem
} }
} }
private static void EventSink_CastSpellRequest(Mobile from, int spellID, Item item) public static void CastSpellRequest(Mobile from, int spellID, Item item)
{ {
if (!DesignContext.Check(from)) if (!DesignContext.Check(from))
{ {

View file

@ -35,11 +35,6 @@ public partial class Bandage : Item, IDyable
return true; return true;
} }
public static void Initialize()
{
EventSink.BandageTargetRequest += EventSink_BandageTargetRequest;
}
public override void OnDoubleClick(Mobile from) public override void OnDoubleClick(Mobile from)
{ {
if (from.InRange(GetWorldLocation(), Range)) if (from.InRange(GetWorldLocation(), Range))
@ -56,7 +51,7 @@ public partial class Bandage : Item, IDyable
} }
} }
private static void EventSink_BandageTargetRequest(Mobile from, Item item, Mobile target) public static void BandageTargetRequest(Mobile from, Item item, Mobile target)
{ {
if (item is not Bandage b || b.Deleted) if (item is not Bandage b || b.Deleted)
{ {

View file

@ -2,12 +2,7 @@ namespace Server.Misc
{ {
public static class Animations public static class Animations
{ {
public static void Initialize() public static void AnimateRequest(Mobile from, string actionName)
{
EventSink.AnimateRequest += EventSink_AnimateRequest;
}
private static void EventSink_AnimateRequest(Mobile from, string actionName)
{ {
var action = actionName switch var action = actionName switch
{ {

View file

@ -109,16 +109,13 @@ namespace Server
Enabled = ServerConfiguration.GetOrUpdateSetting("buffIcons.enable", Core.ML); Enabled = ServerConfiguration.GetOrUpdateSetting("buffIcons.enable", Core.ML);
} }
public static void Initialize()
{
if (Enabled)
{
EventSink.ClientVersionReceived += ResendBuffsOnClientVersionReceived;
}
}
public static void ResendBuffsOnClientVersionReceived(NetState ns, ClientVersion cv) public static void ResendBuffsOnClientVersionReceived(NetState ns, ClientVersion cv)
{ {
if (!Enabled)
{
return;
}
if (ns.Mobile is PlayerMobile pm) if (ns.Mobile is PlayerMobile pm)
{ {
Timer.StartTimer(pm.ResendBuffs); Timer.StartTimer(pm.ResendBuffs);

View file

@ -51,8 +51,6 @@ namespace Server.Misc
public static void Initialize() public static void Initialize()
{ {
EventSink.ClientVersionReceived += EventSink_ClientVersionReceived;
if (MinRequired == null && MaxRequired == null) if (MinRequired == null && MaxRequired == null)
{ {
MinRequired = UOClient.ServerClientVersion; MinRequired = UOClient.ServerClientVersion;
@ -117,7 +115,7 @@ namespace Server.Misc
return builder.ToString(); return builder.ToString();
} }
private static void EventSink_ClientVersionReceived(NetState state, ClientVersion version) public static void ClientVersionReceived(NetState state, ClientVersion version)
{ {
var sb = ValueStringBuilder.Create(); var sb = ValueStringBuilder.Create();

View file

@ -772,8 +772,6 @@ namespace Server.Guilds
public static void Configure() public static void Configure()
{ {
EventSink.GuildGumpRequest += EventSink_GuildGumpRequest;
CommandSystem.Register("GuildProps", AccessLevel.Counselor, GuildProps_OnCommand); CommandSystem.Register("GuildProps", AccessLevel.Counselor, GuildProps_OnCommand);
} }
@ -915,7 +913,7 @@ namespace Server.Guilds
} }
} }
public static void EventSink_GuildGumpRequest(Mobile m) public static void GuildGumpRequest(Mobile m)
{ {
if (!NewGuildSystem || m is not PlayerMobile pm) if (!NewGuildSystem || m is not PlayerMobile pm)
{ {

View file

@ -32,7 +32,6 @@ namespace Server
public static void Configure() public static void Configure()
{ {
EventSink.Login += OnLogin;
CommandSystem.Register("GlobalLight", AccessLevel.GameMaster, Light_OnCommand); CommandSystem.Register("GlobalLight", AccessLevel.GameMaster, Light_OnCommand);
} }

View file

@ -4,13 +4,7 @@ namespace Server.Misc
{ {
public static class LoginStats public static class LoginStats
{ {
public static void Initialize() public static void OnLogin(Mobile m)
{
// Register our event handler
EventSink.Login += EventSink_Login;
}
private static void EventSink_Login(Mobile m)
{ {
var userCount = NetState.Instances.Count; var userCount = NetState.Instances.Count;
var itemCount = World.Items.Count; var itemCount = World.Items.Count;

View file

@ -5,13 +5,7 @@ namespace Server.Misc
{ {
public static class Profile public static class Profile
{ {
public static void Initialize() public static void ChangeProfileRequest(Mobile beholder, Mobile beheld, string text)
{
EventSink.ProfileRequest += EventSink_ProfileRequest;
EventSink.ChangeProfileRequest += EventSink_ChangeProfileRequest;
}
public static void EventSink_ChangeProfileRequest(Mobile beholder, Mobile beheld, string text)
{ {
if (beholder.ProfileLocked) if (beholder.ProfileLocked)
{ {
@ -23,7 +17,7 @@ namespace Server.Misc
} }
} }
public static void EventSink_ProfileRequest(Mobile beholder, Mobile beheld) public static void ProfileRequest(Mobile beholder, Mobile beheld)
{ {
if (!beheld.Player) if (!beheld.Player)
{ {

View file

@ -4,12 +4,7 @@ namespace Server.Misc
{ {
public static class RenameRequests public static class RenameRequests
{ {
public static void Initialize() public static void RenameRequest(Mobile from, Mobile targ, string name)
{
EventSink.RenameRequest += EventSink_RenameRequest;
}
private static void EventSink_RenameRequest(Mobile from, Mobile targ, string name)
{ {
if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from)) if (from.CanSee(targ) && from.InRange(targ, 12) && targ.CanBeRenamedBy(from))
{ {

View file

@ -125,12 +125,7 @@ public partial class ShardPoller : Item
Options[^1] = option; Options[^1] = option;
} }
public static void Initialize() public static void OnLogin(Mobile m)
{
EventSink.Login += EventSink_Login;
}
private static void EventSink_Login(Mobile m)
{ {
if (_activePollers.Count == 0) if (_activePollers.Count == 0)
{ {

View file

@ -54,9 +54,7 @@ public static class StaminaSystem
public static void Initialize() public static void Initialize()
{ {
EventSink.Movement += EventSink_Movement; EventSink.Movement += EventSink_Movement;
EventSink.Login += Login;
EventSink.Logout += Logout; EventSink.Logout += Logout;
EventSink.PlayerDeleted += OnPlayerDeleted;
// Credit idle time // Credit idle time
using var queue = PooledRefQueue<IHasSteps>.Create(); using var queue = PooledRefQueue<IHasSteps>.Create();
@ -77,12 +75,12 @@ public static class StaminaSystem
} }
} }
private static void OnPlayerDeleted(Mobile m) public static void OnPlayerDeleted(Mobile m)
{ {
RemoveEntry(m as IHasSteps); RemoveEntry(m as IHasSteps);
} }
private static void Login(Mobile m) public static void OnLogin(Mobile m)
{ {
if (EnableMountStamina) if (EnableMountStamina)
{ {

View file

@ -935,15 +935,10 @@ namespace Server.Mobiles
public static void Initialize() public static void Initialize()
{ {
EventSink.Login += OnLogin;
EventSink.Logout += OnLogout; EventSink.Logout += OnLogout;
EventSink.Connected += EventSink_Connected; EventSink.Connected += EventSink_Connected;
EventSink.Disconnected += EventSink_Disconnected; EventSink.Disconnected += EventSink_Disconnected;
EventSink.TargetedSkillUse += TargetedSkillUse;
EventSink.EquipMacro += EquipMacro;
EventSink.UnequipMacro += UnequipMacro;
if (Core.SE) if (Core.SE)
{ {
Timer.StartTimer(CheckPets); Timer.StartTimer(CheckPets);
@ -962,7 +957,7 @@ namespace Server.Mobiles
} }
} }
private static void TargetedSkillUse(Mobile from, IEntity target, int skillId) public static void TargetedSkillUse(Mobile from, IEntity target, int skillId)
{ {
if (from == null || target == null) if (from == null || target == null)
{ {
@ -1221,7 +1216,7 @@ namespace Server.Mobiles
} }
} }
private static void OnLogin(Mobile from) public static void OnLogin(Mobile from)
{ {
if (AccountHandler.LockdownLevel > AccessLevel.Player) if (AccountHandler.LockdownLevel > AccessLevel.Player)
{ {

View file

@ -83,11 +83,6 @@ namespace Server.Misc
new(1240, 1003) new(1240, 1003)
}; };
public static void Initialize()
{
EventSink.Login += EventSink_Login;
}
private static bool IsStranded(Mobile from) private static bool IsStranded(Mobile from)
{ {
var map = from.Map; var map = from.Map;
@ -117,7 +112,7 @@ namespace Server.Misc
return false; return false;
} }
public static void EventSink_Login(Mobile from) public static void OnLogin(Mobile from)
{ {
if (!IsStranded(from)) if (!IsStranded(from))
{ {

View file

@ -17,6 +17,22 @@ using System;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Server.Accounting;
using Server.Assistants;
using Server.Commands;
using Server.Engines.ConPVP;
using Server.Engines.Doom;
using Server.Engines.PartySystem;
using Server.Engines.Plants;
using Server.Engines.PlayerMurderSystem;
using Server.Engines.VeteranRewards;
using Server.Factions;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
using Server.Regions;
using Server.Spells.Ninjitsu;
using Server.Spells.Spellweaving;
using CV = Server.ClientVersion; using CV = Server.ClientVersion;
namespace Server.Network; namespace Server.Network;
@ -190,7 +206,7 @@ public static class IncomingAccountPackets
reader.Seek(30, SeekOrigin.Current); reader.Seek(30, SeekOrigin.Current);
var index = reader.ReadInt32(); var index = reader.ReadInt32();
EventSink.InvokeDeleteRequest(state, index); AccountHandler.DeleteRequest(state, index);
} }
public static void AccountID(NetState state, SpanReader reader) public static void AccountID(NetState state, SpanReader reader)
@ -201,7 +217,7 @@ public static class IncomingAccountPackets
{ {
var version = state.Version = new CV(reader.ReadAscii()); var version = state.Version = new CV(reader.ReadAscii());
EventSink.InvokeClientVersionReceived(state, version); ClientVerification.ClientVersionReceived(state, version);
} }
public static void ClientType(NetState state, SpanReader reader) public static void ClientType(NetState state, SpanReader reader)
@ -211,7 +227,7 @@ public static class IncomingAccountPackets
int type = reader.ReadUInt16(); int type = reader.ReadUInt16();
var version = state.Version = new CV(reader.ReadAscii()); var version = state.Version = new CV(reader.ReadAscii());
EventSink.InvokeClientVersionReceived(state, version); ClientVerification.ClientVersionReceived(state, version);
} }
public static void PlayCharacter(NetState state, SpanReader reader) public static void PlayCharacter(NetState state, SpanReader reader)
@ -307,7 +323,30 @@ public static class IncomingAccountPackets
state.SendPlayMusic(m.Region.Music); state.SendPlayMusic(m.Region.Music);
EventSink.InvokeLogin(m); 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);
PlayerMobile.OnLogin(m);
Account.OnLogin(m);
GiftGiving.OnLogin(m);
PreventInaccess.OnLogin(m);
TwistedWealdDesertRegion.OnLogin(m);
RewardSystem.OnLogin(m);
} }
private static int GenerateAuthID(this NetState state) private static int GenerateAuthID(this NetState state)

View file

@ -16,6 +16,7 @@
using System.Buffers; using System.Buffers;
using Server.ContextMenus; using Server.ContextMenus;
using Server.Items; using Server.Items;
using Server.Mobiles;
namespace Server.Network; namespace Server.Network;
@ -251,7 +252,7 @@ public static class IncomingExtendedCommandPackets
Item spellbook = reader.ReadInt16() == 1 ? World.FindItem((Serial)reader.ReadUInt32()) : null; Item spellbook = reader.ReadInt16() == 1 ? World.FindItem((Serial)reader.ReadUInt32()) : null;
var spellID = reader.ReadInt16() - 1; var spellID = reader.ReadInt16() - 1;
EventSink.InvokeCastSpellRequest(from, spellID, spellbook); Spellbook.CastSpellRequest(from, spellID, spellbook);
} }
public static void ToggleFlying(NetState state, SpanReader reader) public static void ToggleFlying(NetState state, SpanReader reader)
@ -490,7 +491,7 @@ public static class IncomingExtendedCommandPackets
return; return;
} }
EventSink.InvokeBandageTargetRequest(from, bandage, target); Bandage.BandageTargetRequest(from, bandage, target);
from.NextActionTime = Core.TickCount + Mobile.ActionDelay; from.NextActionTime = Core.TickCount + Mobile.ActionDelay;
} }
@ -504,14 +505,14 @@ public static class IncomingExtendedCommandPackets
{ {
var spellId = (short)(reader.ReadInt16() - 1); // zero based; var spellId = (short)(reader.ReadInt16() - 1); // zero based;
EventSink.InvokeTargetedSpell(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), spellId); Spellbook.TargetedSpell(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), spellId);
} }
public static void TargetedSkillUse(NetState state, SpanReader reader) public static void TargetedSkillUse(NetState state, SpanReader reader)
{ {
var skillId = reader.ReadInt16(); var skillId = reader.ReadInt16();
EventSink.InvokeTargetedSkillUse(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), skillId); PlayerMobile.TargetedSkillUse(state.Mobile, World.FindEntity((Serial)reader.ReadUInt32()), skillId);
} }
public static void TargetByResourceMacro(NetState state, SpanReader reader) public static void TargetByResourceMacro(NetState state, SpanReader reader)

View file

@ -17,6 +17,7 @@ using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using Server.Items; using Server.Items;
using Server.Mobiles;
namespace Server.Network; namespace Server.Network;
@ -117,7 +118,7 @@ public static class IncomingItemPackets
serialList.Add((Serial)reader.ReadUInt32()); serialList.Add((Serial)reader.ReadUInt32());
} }
EventSink.InvokeEquipMacro(state.Mobile, serialList); PlayerMobile.EquipMacro(state.Mobile, serialList);
} }
public static void UnequipMacro(NetState state, SpanReader reader) public static void UnequipMacro(NetState state, SpanReader reader)
@ -129,6 +130,6 @@ public static class IncomingItemPackets
layers.Add((Layer)reader.ReadUInt16()); layers.Add((Layer)reader.ReadUInt16());
} }
EventSink.InvokeUnequipMacro(state.Mobile, layers); PlayerMobile.UnequipMacro(state.Mobile, layers);
} }
} }

View file

@ -15,6 +15,7 @@
using System.Buffers; using System.Buffers;
using Server.Items; using Server.Items;
using Server.Misc;
namespace Server.Network; namespace Server.Network;
@ -35,7 +36,7 @@ public static class IncomingMobilePackets
if (targ != null) if (targ != null)
{ {
EventSink.InvokeRenameRequest(from, targ, reader.ReadAsciiSafe()); RenameRequests.RenameRequest(from, targ, reader.ReadAsciiSafe());
} }
} }
@ -66,7 +67,7 @@ public static class IncomingMobilePackets
{ {
case 0x00: // display request case 0x00: // display request
{ {
EventSink.InvokeProfileRequest(beholder, beheld); Profile.ProfileRequest(beholder, beheld);
break; break;
} }
@ -82,7 +83,7 @@ public static class IncomingMobilePackets
var text = reader.ReadBigUni(length); var text = reader.ReadBigUni(length);
EventSink.InvokeChangeProfileRequest(beholder, beheld, text); Profile.ChangeProfileRequest(beholder, beheld, text);
break; break;
} }

View file

@ -21,9 +21,14 @@ using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CommunityToolkit.HighPerformance; using CommunityToolkit.HighPerformance;
using Server.Diagnostics; using Server.Diagnostics;
using Server.Engines.Help;
using Server.Engines.MLQuests;
using Server.Engines.Virtues; using Server.Engines.Virtues;
using Server.Exceptions; using Server.Exceptions;
using Server.Guilds;
using Server.Gumps; using Server.Gumps;
using Server.Items;
using Server.Misc;
using Server.Mobiles; using Server.Mobiles;
namespace Server.Network; namespace Server.Network;
@ -136,7 +141,7 @@ public static class IncomingPlayerPackets
{ {
case 0xC7: // Animate case 0xC7: // Animate
{ {
EventSink.InvokeAnimateRequest(from, command); Animations.AnimateRequest(from, command);
break; break;
} }
@ -159,7 +164,7 @@ public static class IncomingPlayerPackets
booktype = 1; booktype = 1;
} }
EventSink.InvokeOpenSpellbookRequest(from, booktype); Spellbook.OpenSpellbookRequest(from, booktype);
break; break;
} }
@ -169,13 +174,13 @@ public static class IncomingPlayerPackets
var spellID = (tokenizer.MoveNext() ? Utility.ToInt32(tokenizer.Current) : 0) - 1; var spellID = (tokenizer.MoveNext() ? Utility.ToInt32(tokenizer.Current) : 0) - 1;
var serial = tokenizer.MoveNext() ? (Serial)Utility.ToUInt32(tokenizer.Current) : Serial.MinusOne; var serial = tokenizer.MoveNext() ? (Serial)Utility.ToUInt32(tokenizer.Current) : Serial.MinusOne;
EventSink.InvokeCastSpellRequest(from, spellID, World.FindItem(serial)); Spellbook.CastSpellRequest(from, spellID, World.FindItem(serial));
break; break;
} }
case 0x58: // Open door case 0x58: // Open door
{ {
EventSink.InvokeOpenDoorMacroUsed(from); BaseDoor.OpenDoorMacroUsed(from);
break; break;
} }
@ -183,7 +188,7 @@ public static class IncomingPlayerPackets
{ {
var spellID = Utility.ToInt32(command) - 1; var spellID = Utility.ToInt32(command) - 1;
EventSink.InvokeCastSpellRequest(from, spellID, null); Spellbook.CastSpellRequest(from, spellID, null);
break; break;
} }
@ -341,7 +346,7 @@ public static class IncomingPlayerPackets
public static void HelpRequest(NetState state, SpanReader reader) public static void HelpRequest(NetState state, SpanReader reader)
{ {
EventSink.InvokeHelpRequest(state.Mobile); HelpGump.HelpRequest(state.Mobile);
} }
public static void DisplayGumpResponse(NetState state, SpanReader reader) public static void DisplayGumpResponse(NetState state, SpanReader reader)
@ -617,12 +622,12 @@ public static class IncomingPlayerPackets
public static void GuildGumpRequest(NetState state, IEntity e, EncodedReader reader) public static void GuildGumpRequest(NetState state, IEntity e, EncodedReader reader)
{ {
EventSink.InvokeGuildGumpRequest(state.Mobile); Guild.GuildGumpRequest(state.Mobile);
} }
public static void QuestGumpRequest(NetState state, IEntity e, EncodedReader reader) public static void QuestGumpRequest(NetState state, IEntity e, EncodedReader reader)
{ {
EventSink.InvokeQuestGumpRequest(state.Mobile); MLQuestSystem.QuestGumpRequest(state.Mobile);
} }
public static unsafe void EncodedCommand(NetState state, SpanReader reader) public static unsafe void EncodedCommand(NetState state, SpanReader reader)

View file

@ -27,7 +27,6 @@ public class HouseRegion : BaseRegion
public static void Initialize() public static void Initialize()
{ {
EventSink.Login += OnLogin;
} }
public static void OnLogin(Mobile m) public static void OnLogin(Mobile m)

View file

@ -22,11 +22,6 @@ public class TwistedWealdDesertRegion : MondainRegion
{ {
} }
public static void Initialize()
{
EventSink.Login += Desert_OnLogin;
}
public override void OnEnter(Mobile m) public override void OnEnter(Mobile m)
{ {
var ns = m.NetState; var ns = m.NetState;
@ -46,7 +41,7 @@ public class TwistedWealdDesertRegion : MondainRegion
} }
} }
private static void Desert_OnLogin(Mobile m) public static void OnLogin(Mobile m)
{ {
if (m.Region.IsPartOf<TwistedWealdDesertRegion>() && m.AccessLevel == AccessLevel.Player) if (m.Region.IsPartOf<TwistedWealdDesertRegion>() && m.AccessLevel == AccessLevel.Player)
{ {

View file

@ -108,7 +108,6 @@ public static class AntiMacroSystem
{ {
EventSink.WorldSave += OnWorldSave; EventSink.WorldSave += OnWorldSave;
EventSink.Logout += OnLogout; EventSink.Logout += OnLogout;
EventSink.Login += OnLogin;
} }
private static void OnWorldSave() private static void OnWorldSave()
@ -139,7 +138,7 @@ public static class AntiMacroSystem
} }
} }
private static void OnLogin(Mobile m) public static void OnLogin(Mobile m)
{ {
// Stop the clear out timer // Stop the clear out timer
if (_logoutCleanup?.Remove(m, out var timer) == true) if (_logoutCleanup?.Remove(m, out var timer) == true)

View file

@ -19,12 +19,7 @@ namespace Server.Misc
m_Givers.Add(giver); m_Givers.Add(giver);
} }
public static void Initialize() public static void OnLogin(Mobile m)
{
EventSink.Login += EventSink_Login;
}
private static void EventSink_Login(Mobile m)
{ {
if (m.Account is not Account acct) if (m.Account is not Account acct)
{ {

View file

@ -32,15 +32,15 @@ namespace Server.Misc
public static void Initialize() public static void Initialize()
{ {
m_MoveHistory = new Dictionary<Mobile, LocationInfo>(); m_MoveHistory = new Dictionary<Mobile, LocationInfo>();
if (Enabled)
{
EventSink.Login += OnLogin;
}
} }
public static void OnLogin(Mobile from) public static void OnLogin(Mobile from)
{ {
if (!Enabled)
{
return;
}
if (from == null || from.AccessLevel < AccessLevel.Counselor) if (from == null || from.AccessLevel < AccessLevel.Counselor)
{ {
return; return;

View file

@ -62,11 +62,6 @@ namespace Server.Spells.Ninjitsu
new(typeof(Reptalon), 1075202, 11669, 0, 1075222, 90.0, 0x114, 0, 0, false, false) new(typeof(Reptalon), 1075202, 11669, 0, 1075222, 90.0, 0x114, 0, 0, false, false)
}; };
public static void Initialize()
{
EventSink.Login += OnLogin;
}
public static void OnLogin(Mobile m) public static void OnLogin(Mobile m)
{ {
if (GetContext(m)?.SpeedBoost == true) if (GetContext(m)?.SpeedBoost == true)

View file

@ -27,11 +27,6 @@ namespace Server.Spells.Spellweaving
public virtual int SwingSpeedBonus => 10 + FocusLevel; public virtual int SwingSpeedBonus => 10 + FocusLevel;
public virtual int SpellDamageBonus => 10 + FocusLevel; public virtual int SpellDamageBonus => 10 + FocusLevel;
public static void Initialize()
{
EventSink.Login += OnLogin;
}
public static void OnLogin(Mobile m) public static void OnLogin(Mobile m)
{ {
var context = TransformationSpellHelper.GetContext(m); var context = TransformationSpellHelper.GetContext(m);