diff --git a/src/Perpetuum.Bootstrapper/Modules/TerrainsModule.cs b/src/Perpetuum.Bootstrapper/Modules/TerrainsModule.cs index cb49723c8..ede63ef03 100644 --- a/src/Perpetuum.Bootstrapper/Modules/TerrainsModule.cs +++ b/src/Perpetuum.Bootstrapper/Modules/TerrainsModule.cs @@ -28,10 +28,10 @@ protected override void Load(ContainerBuilder builder) { IMineralConfigurationReader reader = ctx.Resolve(); OreNpcSpawner oreNpcSpawnlistener = new OreNpcSpawner(zone, ctx.Resolve(), ctx.Resolve(), reader); - SapAttackerSpawner sapAttackerSpawnlistener = new SapAttackerSpawner(zone, ctx.Resolve(), ctx.Resolve()); + //SapAttackerSpawner sapAttackerSpawnlistener = new SapAttackerSpawner(zone, ctx.Resolve(), ctx.Resolve()); EventListenerService eventListenerService = ctx.Resolve(); eventListenerService.AttachListener(oreNpcSpawnlistener); - eventListenerService.AttachListener(sapAttackerSpawnlistener); + //eventListenerService.AttachListener(sapAttackerSpawnlistener); if (zone is TrainingZone) { GravelRepository repo = ctx.Resolve(); diff --git a/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs b/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs index 7c452c2e0..fcfa664a0 100644 --- a/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs +++ b/src/Perpetuum.Bootstrapper/PerpetuumBootstrapper.cs @@ -556,7 +556,7 @@ private void InitRelayManager() _ = _builder.RegisterType(); _ = _builder.RegisterType().As>(); _ = _builder.RegisterType().As>(); - _ = _builder.RegisterType().As>(); + //_ = _builder.RegisterType().As>(); _ = _builder.RegisterType(); _ = _builder.RegisterType().SingleInstance().OnActivated(e => diff --git a/src/Perpetuum/Network/ClientConnection.cs b/src/Perpetuum/Network/ClientConnection.cs index dfa689c72..29d1424f2 100644 --- a/src/Perpetuum/Network/ClientConnection.cs +++ b/src/Perpetuum/Network/ClientConnection.cs @@ -14,24 +14,24 @@ public class ClientConnection : EncryptedTcpConnection private ClientConnection(Socket socket) : base(socket) { _rc4 = new Rc4(FastRandom.NextBytes(40)); - ObjectHelper.Swap(ref inIncrement,ref outIncrement); - ObjectHelper.Swap(ref inDecodingByte,ref outEncodingByte); + ObjectHelper.Swap(ref inIncrement, ref outIncrement); + ObjectHelper.Swap(ref inDecodingByte, ref outEncodingByte); } protected override void OnReceived(byte[] data) { _rc4.Decrypt(data, 1, data.Length - 1); - var dataOffset = 4; + int dataOffset = 4; - var compressionLevel = data[0]; + byte compressionLevel = data[0]; if (compressionLevel == 2) { data = GZip.Decompress(data, 5); dataOffset--; } - var messageText = Encoding.UTF8.GetString(data,dataOffset,data.Length - dataOffset); + string messageText = Encoding.UTF8.GetString(data, dataOffset, data.Length - dataOffset); OnReceived(messageText); base.OnReceived(data); @@ -39,11 +39,11 @@ protected override void OnReceived(byte[] data) public new event Action Received; - private readonly ConcurrentDictionary>> _commandQueue = new ConcurrentDictionary>>(); + private readonly ConcurrentDictionary>> _commandQueue = new ConcurrentDictionary>>(); public IMessage Send(Command command) { - var t = SendAsync(command); + Task t = SendAsync(command); return t.Result; } @@ -54,49 +54,49 @@ public Task SendAsync(Command command) public IMessage Send(string messageText) { - var t = SendAsync(messageText); + Task t = SendAsync(messageText); return t.Result; } public Task SendAsync(string messageText) { - var m = Message.Parse(messageText); + Message m = Message.Parse(messageText); return SendAsync(m); } public IMessage Send(IMessage clientMessage) { - var t = SendAsync(clientMessage); + Task t = SendAsync(clientMessage); return t.Result; } public Task SendAsync(IMessage clientMessage) { - var source = new TaskCompletionSource(); - EnqueueCompletionSource(clientMessage.Command,source); + TaskCompletionSource source = new TaskCompletionSource(); + EnqueueCompletionSource(clientMessage.Command, source); Send(clientMessage.ToBytes()); return source.Task; } - private void EnqueueCompletionSource(Command command,TaskCompletionSource source) + private void EnqueueCompletionSource(Command command, TaskCompletionSource source) { - var q = _commandQueue.GetOrAdd(command,() => new ConcurrentQueue>()); + ConcurrentQueue> q = _commandQueue.GetOrAdd(command, () => new ConcurrentQueue>()); q.Enqueue(source); } public override void Send(byte[] data) { - var t = new byte[data.Length + 4]; - Array.Copy(data,0,t,4,data.Length); - _rc4.Encrypt(t,1,t.Length - 1); + byte[] t = new byte[data.Length + 4]; + Array.Copy(data, 0, t, 4, data.Length); + _rc4.Encrypt(t, 1, t.Length - 1); base.Send(t); } public static ClientConnection Connect(IPEndPoint endPoint) { - var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); + Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); socket.Connect(endPoint); - var connect = new ClientConnection(socket); + ClientConnection connect = new ClientConnection(socket); connect.Receive(); return connect; } @@ -108,12 +108,12 @@ public void SendHandshake() public Task SendHandshakeAsync() { - var e = Rsa.Encrypt(_rc4.streamKey); - var data = new byte[e.Length + 4]; - Array.Copy((Array) e, (int) 0, (Array) data, (int) 4, (int) e.Length); + byte[] e = Rsa.Encrypt(_rc4.streamKey); + byte[] data = new byte[e.Length + 4]; + Array.Copy(e, 0, data, 4, e.Length); - var source = new TaskCompletionSource(); - EnqueueCompletionSource(Commands.Welcome,source); + TaskCompletionSource source = new TaskCompletionSource(); + EnqueueCompletionSource(Commands.Welcome, source); base.Send(data); return source.Task; @@ -122,11 +122,11 @@ public Task SendHandshakeAsync() public event TcpConnectionEventHandler MessageReceived; protected virtual void OnReceived(string messageText) { - var message = Message.Parse(messageText); - MessageReceived?.Invoke(this,message); + Message message = Message.Parse(messageText); + MessageReceived?.Invoke(this, message); - var q = _commandQueue.GetOrDefault(message.Command); + ConcurrentQueue> q = _commandQueue.GetOrDefault(message.Command); if (q != null) { if (q.TryDequeue(out TaskCompletionSource source)) diff --git a/src/Perpetuum/Services/Channels/ChannelManager.cs b/src/Perpetuum/Services/Channels/ChannelManager.cs index 918f0de89..550590cbd 100644 --- a/src/Perpetuum/Services/Channels/ChannelManager.cs +++ b/src/Perpetuum/Services/Channels/ChannelManager.cs @@ -323,36 +323,6 @@ public void Talk(string channelName, Character sender, string message, IRequest sender.Nick, message)); } - - /* - if (channel.Name == HelpChat) - { - // Sending message to discord - - string webhookId = _globalConfiguration.WebHookId; - string webhookOAuth = _globalConfiguration.WebHookOAuth; - - if (string.IsNullOrEmpty(webhookId) || string.IsNullOrEmpty(webhookOAuth)) - { - return; - } - - string url = $"https://discord.com/api/webhooks/{webhookId}/{webhookOAuth}"; - HttpClient httpClient = new HttpClient(); - DiscordPayload payload = new DiscordPayload - { - content = $"**<{sender.Nick}>**: {message}", - }; - - string json = JsonConvert.SerializeObject(payload); - StringContent content = new StringContent(json, Encoding.UTF8, "application/json"); - - Task.Run(async () => - { - HttpResponseMessage response = await httpClient.PostAsync(url, content); - }); - } - */ } } diff --git a/src/Perpetuum/Services/EventServices/EventListenerService.cs b/src/Perpetuum/Services/EventServices/EventListenerService.cs index 1d6dd7cd1..23f3c0ce4 100644 --- a/src/Perpetuum/Services/EventServices/EventListenerService.cs +++ b/src/Perpetuum/Services/EventServices/EventListenerService.cs @@ -19,8 +19,9 @@ public class EventListenerService : Process private readonly object _lock = new object(); private readonly IDictionary> _observers; private readonly ConcurrentQueue _queue; - private readonly DiscordSocketClient _client; + + //private readonly DiscordSocketClient _client; private readonly GlobalConfiguration _globalConfiguration; public EventListenerService(GlobalConfiguration globalConfiguration) @@ -32,6 +33,7 @@ public EventListenerService(GlobalConfiguration globalConfiguration) { GatewayIntents = GatewayIntents.AllUnprivileged | GatewayIntents.MessageContent }); + _globalConfiguration = globalConfiguration; } diff --git a/src/Perpetuum/Zones/Intrusion/Outpost.cs b/src/Perpetuum/Zones/Intrusion/Outpost.cs index 643f7f79b..a7c431aa7 100644 --- a/src/Perpetuum/Zones/Intrusion/Outpost.cs +++ b/src/Perpetuum/Zones/Intrusion/Outpost.cs @@ -169,6 +169,7 @@ protected override void OnUpdate(TimeSpan time) base.OnUpdate(time); _decay.OnUpdate(time); + /* if (CurrentSap != null && _cultistsAttackTimer != null) { _cultistsAttackTimer.Update(time); @@ -178,6 +179,7 @@ protected override void OnUpdate(TimeSpan time) _eventChannel.PublishMessage(new SapAttackersSpawnMessage(CurrentSap, SapState.Opened, Zone.Id, GetIntrusionSiteStability())); } } + */ if (!Enabled || IntrusionInProgress) { @@ -389,7 +391,7 @@ private void OnSAPTakeOver(SAP sap) TimeSpan randomDelay = FastRandom.NextTimeSpan(TimeSpan.FromMinutes(MinAnnouncementDelay), TimeSpan.FromMinutes(MaxAnnouncementDelay)); DateTime timeStamp = DateTime.UtcNow; - _eventChannel.PublishMessage(new SapAttackersSpawnMessage(CurrentSap, SapState.Completed, Zone.Id, GetIntrusionSiteStability())); + //_eventChannel.PublishMessage(new SapAttackersSpawnMessage(CurrentSap, SapState.Completed, Zone.Id, GetIntrusionSiteStability())); _ = Task.Delay(randomDelay).ContinueWith((t) => { @@ -585,7 +587,7 @@ private void OnSAPTimeOut(SAP sap) TimeSpan randomDelay = FastRandom.NextTimeSpan(TimeSpan.FromMinutes(MinAnnouncementDelay), TimeSpan.FromMinutes(MaxAnnouncementDelay)); DateTime timeStamp = DateTime.UtcNow; - _eventChannel.PublishMessage(new SapAttackersSpawnMessage(CurrentSap, SapState.Closed, Zone.Id, GetIntrusionSiteStability())); + //_eventChannel.PublishMessage(new SapAttackersSpawnMessage(CurrentSap, SapState.Closed, Zone.Id, GetIntrusionSiteStability())); CurrentSap = null; _ = Task.Delay(randomDelay).ContinueWith((t) => diff --git a/src/Perpetuum/Zones/NpcSystem/Npc.cs b/src/Perpetuum/Zones/NpcSystem/Npc.cs index 81386f7d3..492d9f758 100644 --- a/src/Perpetuum/Zones/NpcSystem/Npc.cs +++ b/src/Perpetuum/Zones/NpcSystem/Npc.cs @@ -192,8 +192,8 @@ protected override bool IsHostileFor(Unit unit) internal override bool IsHostile(Npc npc) { - return (npc.ED.Options.Faction == Faction.Syndicate && npc.ED.Options.Faction != Faction.Syndicate) || - (npc.ED.Options.Faction != Faction.Syndicate && npc.ED.Options.Faction == Faction.Syndicate); + return (ED.Options.Faction == Faction.Syndicate && npc.ED.Options.Faction != Faction.Syndicate) || + (ED.Options.Faction != Faction.Syndicate && npc.ED.Options.Faction == Faction.Syndicate); } internal override bool IsHostile(SAP sap)