fix (#687)
This commit is contained in:
@@ -29,18 +29,6 @@ public sealed class SingletonDeviceNetServerSystem : EntitySystem
|
||||
return Resolve(serverId, ref serverComponent) && serverComponent.Active;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set server active. WD EDIT
|
||||
/// </summary>
|
||||
public bool SetServerActive(EntityUid serverId, bool active, SingletonDeviceNetServerComponent? serverComponent = default)
|
||||
{
|
||||
if (!Resolve(serverId, ref serverComponent))
|
||||
return false;
|
||||
|
||||
serverComponent.Active = active;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the address of the currently active server for the given station id if there is one.<br/>
|
||||
/// What kind of server you're trying to get the active instance of is determined by the component type parameter TComp.<br/>
|
||||
|
||||
@@ -10,6 +10,8 @@ using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared._White.CartridgeLoader.Cartridges;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Mind.Components;
|
||||
|
||||
namespace Content.Server._White.CartridgeLoader.Cartridges;
|
||||
|
||||
@@ -22,6 +24,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
||||
[Dependency] private readonly SingletonDeviceNetServerSystem _singletonServerSystem = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -33,18 +36,30 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
SubscribeLocalEvent<MessagesCartridgeComponent, CartridgeDeactivatedEvent>(OnCartDeactivation);
|
||||
SubscribeLocalEvent<MessagesCartridgeComponent, CartridgeAddedEvent>(OnCartInsertion);
|
||||
SubscribeLocalEvent<MessagesCartridgeComponent, ComponentRemove>(OnRemove);
|
||||
|
||||
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(OnPlayerSpawned);
|
||||
}
|
||||
|
||||
public void Send(EntityUid uid, MessagesCartridgeComponent component)
|
||||
private void OnPlayerSpawned(PlayerSpawnCompleteEvent ev)
|
||||
{
|
||||
var stationId = _stationSystem.GetOwningStation(uid);
|
||||
if (!stationId.HasValue ||
|
||||
!_singletonServerSystem.TryGetActiveServerAddress<MessagesServerComponent>(stationId.Value,
|
||||
out var address) || !TryComp(uid, out CartridgeComponent? cartComponent))
|
||||
if (!_inventorySystem.TryGetSlotEntity(ev.Mob, "id", out var pdaUid) || !HasComp<MindContainerComponent>(ev.Mob))
|
||||
return;
|
||||
MessagesCartridgeComponent? comp = null;
|
||||
|
||||
var programs = _cartridgeLoaderSystem.GetInstalled(pdaUid.Value);
|
||||
var program = programs.ToList().Find(program => TryComp(program, out comp));
|
||||
|
||||
if (comp == null)
|
||||
return;
|
||||
|
||||
component.UserUid = cartComponent.LoaderUid?.Id;
|
||||
SendName(uid, component, cartComponent, address);
|
||||
if (!TryComp(program, out CartridgeComponent? cartComponent))
|
||||
return;
|
||||
|
||||
var stationId = _stationSystem.GetOwningStation(pdaUid);
|
||||
if (!stationId.HasValue || !_singletonServerSystem.TryGetActiveServerAddress<MessagesServerComponent>(stationId.Value, out var address))
|
||||
return;
|
||||
|
||||
SendName(pdaUid.Value, comp, cartComponent, address);
|
||||
}
|
||||
|
||||
private void OnRemove(EntityUid uid, MessagesCartridgeComponent component, ComponentRemove args)
|
||||
@@ -172,7 +187,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
|
||||
public void SendName(EntityUid uid, MessagesCartridgeComponent component, CartridgeComponent cartComponent, string? address)
|
||||
{
|
||||
TryGetMessagesUser(component, cartComponent, out var messagesUser);
|
||||
|
||||
;
|
||||
var packet = new NetworkPayload()
|
||||
{
|
||||
[MessagesNetworkKeys.UserId] = component.UserUid,
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
using System.Linq;
|
||||
using Content.Server._White.CartridgeLoader.Cartridges;
|
||||
using Content.Server._White.Radio.Components;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared._White.CartridgeLoader.Cartridges;
|
||||
using Content.Shared.CartridgeLoader;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
|
||||
@@ -18,37 +14,13 @@ public sealed class MessagesServerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
||||
[Dependency] private readonly SingletonDeviceNetServerSystem _singletonServerSystem = default!;
|
||||
[Dependency] private readonly MessagesCartridgeSystem _messagesSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly ChatSystem _chat = default!;
|
||||
[Dependency] private readonly StationSystem _stationSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MessagesServerComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
|
||||
SubscribeLocalEvent<MessagesServerComponent, MapInitEvent>(OnInit);
|
||||
}
|
||||
|
||||
private void OnInit(EntityUid uid, MessagesServerComponent component, MapInitEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out DeviceNetworkComponent? device) || !_singletonServerSystem.SetServerActive(uid, true))
|
||||
return;
|
||||
|
||||
_deviceNetworkSystem.ConnectDevice(uid, device);
|
||||
|
||||
var stationIdServer = _stationSystem.GetOwningStation(uid);
|
||||
if (!stationIdServer.HasValue)
|
||||
return;
|
||||
|
||||
var query = EntityQueryEnumerator<MessagesCartridgeComponent>();
|
||||
|
||||
while (query.MoveNext(out var entityUid, out var cartridge))
|
||||
{
|
||||
var stationId = _stationSystem.GetOwningStation(entityUid);
|
||||
if (stationId.HasValue && stationIdServer == stationId && TryComp(entityUid, out CartridgeComponent? cartComponent))
|
||||
_messagesSystem.SendName(entityUid, cartridge, cartComponent, device.Address);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
- type: entity
|
||||
id: MessagesServer
|
||||
parent: BaseMachinePowered
|
||||
parent: BaseMachine
|
||||
name: PDA messaging server
|
||||
description: Server that allows PDA messaging to function on the station.
|
||||
components:
|
||||
@@ -9,9 +9,6 @@
|
||||
layers:
|
||||
- state: server
|
||||
- state: variant-research
|
||||
- type: ApcPowerReceiver
|
||||
powerLoad: 200
|
||||
- type: ExtensionCableReceiver
|
||||
- type: Destructible
|
||||
thresholds:
|
||||
- trigger:
|
||||
@@ -43,11 +40,11 @@
|
||||
- type: AmbientOnPowered
|
||||
- type: MessagesServer
|
||||
- type: SingletonDeviceNetServer
|
||||
available: true
|
||||
- type: DeviceNetwork
|
||||
deviceNetId: Wireless
|
||||
transmitFrequencyId: NTMessagesServer
|
||||
receiveFrequencyId: NTMessagesClient
|
||||
autoConnect: false
|
||||
- type: StationLimitedNetwork
|
||||
|
||||
- type: entity
|
||||
@@ -59,5 +56,4 @@
|
||||
- type: DeviceNetwork
|
||||
deviceNetId: Wireless
|
||||
transmitFrequencyId: SyndicateMessagesServer
|
||||
receiveFrequencyId: SyndicateMessagesClient
|
||||
autoConnect: false
|
||||
receiveFrequencyId: SyndicateMessagesClient
|
||||
Reference in New Issue
Block a user