diff --git a/Content.Server/DeviceNetwork/Systems/SingletonDeviceNetServerSystem.cs b/Content.Server/DeviceNetwork/Systems/SingletonDeviceNetServerSystem.cs index 5fdcad7697..8d1291b76d 100644 --- a/Content.Server/DeviceNetwork/Systems/SingletonDeviceNetServerSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/SingletonDeviceNetServerSystem.cs @@ -29,6 +29,18 @@ public sealed class SingletonDeviceNetServerSystem : EntitySystem return Resolve(serverId, ref serverComponent) && serverComponent.Active; } + /// + /// Set server active. WD EDIT + /// + public bool SetServerActive(EntityUid serverId, bool active, SingletonDeviceNetServerComponent? serverComponent = default) + { + if (!Resolve(serverId, ref serverComponent)) + return false; + + serverComponent.Active = active; + return true; + } + /// /// Returns the address of the currently active server for the given station id if there is one.
/// What kind of server you're trying to get the active instance of is determined by the component type parameter TComp.
diff --git a/Content.Server/_White/CartridgeLoader/Cartridges/MessagesCartridgeSystem.cs b/Content.Server/_White/CartridgeLoader/Cartridges/MessagesCartridgeSystem.cs index d1972868c3..6d44d052d1 100644 --- a/Content.Server/_White/CartridgeLoader/Cartridges/MessagesCartridgeSystem.cs +++ b/Content.Server/_White/CartridgeLoader/Cartridges/MessagesCartridgeSystem.cs @@ -44,8 +44,8 @@ public sealed class MessagesCartridgeSystem : EntitySystem out var address) || !TryComp(uid, out CartridgeComponent? cartComponent)) return; - SendName(uid, component, cartComponent, address); component.UserUid = cartComponent.LoaderUid?.Id; + SendName(uid, component, cartComponent, address); } private void OnRemove(EntityUid uid, MessagesCartridgeComponent component, ComponentRemove args) @@ -179,6 +179,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem [MessagesNetworkKeys.UserId] = component.UserUid, [MessagesNetworkKeys.NewUser] = messagesUser }; + _deviceNetworkSystem.QueuePacket(uid, address, packet); } @@ -199,7 +200,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem /// /// Returns the user's name, job title and job department /// - public bool TryGetMessagesUser(MessagesCartridgeComponent component, CartridgeComponent cartridgeComponent, out MessagesUserData messagesUserData) + private bool TryGetMessagesUser(MessagesCartridgeComponent component, CartridgeComponent cartridgeComponent, out MessagesUserData messagesUserData) { messagesUserData = new MessagesUserData(); diff --git a/Content.Server/_White/Radio/EntitySystems/MessagesServerSystem.cs b/Content.Server/_White/Radio/EntitySystems/MessagesServerSystem.cs index 4e0948ccd1..27967e3049 100644 --- a/Content.Server/_White/Radio/EntitySystems/MessagesServerSystem.cs +++ b/Content.Server/_White/Radio/EntitySystems/MessagesServerSystem.cs @@ -3,6 +3,7 @@ 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; @@ -26,18 +27,27 @@ public sealed class MessagesServerSystem : EntitySystem { base.Initialize(); SubscribeLocalEvent(OnPacketReceived); - SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnInit); } - private void OnInit(EntityUid uid, MessagesServerComponent component, ComponentInit args) + 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(); - var stationId = _stationSystem.GetOwningStation(uid); while (query.MoveNext(out var entityUid, out var cartridge)) { - if (stationId.HasValue && _singletonServerSystem.TryGetActiveServerAddress(stationId.Value, out var address) && TryComp(entityUid, out CartridgeComponent? cartComponent)) - _messagesSystem.SendName(entityUid, cartridge, cartComponent, address); + var stationId = _stationSystem.GetOwningStation(entityUid); + if (stationId.HasValue && stationIdServer == stationId && TryComp(entityUid, out CartridgeComponent? cartComponent)) + _messagesSystem.SendName(entityUid, cartridge, cartComponent, device.Address); } } diff --git a/Resources/Prototypes/Entities/Structures/Machines/telecomms.yml b/Resources/Prototypes/Entities/Structures/Machines/telecomms.yml index bf4d7207f6..c2e89197c4 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/telecomms.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/telecomms.yml @@ -85,70 +85,4 @@ - EncryptionKeyScience - EncryptionKeySecurity - EncryptionKeyService - - EncryptionKeyCommand - -- type: entity - id: MessagesServer - parent: BaseMachinePowered - name: PDA messaging server - description: Server that allows PDA messaging to function on the station. - components: - - type: Sprite - sprite: Structures/Machines/server.rsi - layers: - - state: server - - state: variant-research - - type: ApcPowerReceiver - powerLoad: 200 - - type: ExtensionCableReceiver - - type: Destructible - thresholds: - - trigger: - !type:DamageTrigger - damage: 600 - behaviors: - - !type:DoActsBehavior - acts: [ "Destruction" ] - - trigger: - !type:DamageTrigger - damage: 300 - behaviors: - - !type:DoActsBehavior - acts: ["Destruction"] - - !type:PlaySoundBehavior - sound: - collection: MetalBreak - - !type:SpawnEntitiesBehavior - spawn: - SheetSteel1: - min: 1 - max: 2 - - type: Appearance - - type: AmbientSound - volume: -9 - range: 5 - sound: - path: /Audio/Ambience/Objects/server_fans.ogg - - type: MessagesServer - - type: SingletonDeviceNetServer - - type: DeviceNetwork - deviceNetId: Wireless - transmitFrequencyId: NTMessagesServer - receiveFrequencyId: NTMessagesClient - autoConnect: false - - type: StationLimitedNetwork - -- type: entity - id: SyndicateMessagesServer - parent: MessagesServer - name: Syndicate PDA messaging server - description: Server that allows PDA messaging between Syndicate operatives to function. - components: - - type: MessagesServer - - type: StationLimitedNetwork - - type: SingletonDeviceNetServer - - type: DeviceNetwork - deviceNetId: Wireless - transmitFrequencyId: SyndicateMessagesServer - receiveFrequencyId: SyndicateMessagesClient - autoConnect: false \ No newline at end of file + - EncryptionKeyCommand \ No newline at end of file diff --git a/Resources/Prototypes/_White/Entities/Structures/Machine/messege_server.yml b/Resources/Prototypes/_White/Entities/Structures/Machine/messege_server.yml new file mode 100644 index 0000000000..534a6cb2d6 --- /dev/null +++ b/Resources/Prototypes/_White/Entities/Structures/Machine/messege_server.yml @@ -0,0 +1,63 @@ +- type: entity + id: MessagesServer + parent: BaseMachinePowered + name: PDA messaging server + description: Server that allows PDA messaging to function on the station. + components: + - type: Sprite + sprite: Structures/Machines/server.rsi + layers: + - state: server + - state: variant-research + - type: ApcPowerReceiver + powerLoad: 200 + - type: ExtensionCableReceiver + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 600 + behaviors: + - !type:DoActsBehavior + acts: [ "Destruction" ] + - trigger: + !type:DamageTrigger + damage: 300 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - !type:PlaySoundBehavior + sound: + collection: MetalBreak + - !type:SpawnEntitiesBehavior + spawn: + SheetSteel1: + min: 1 + max: 2 + - type: Appearance + - type: AmbientSound + volume: -9 + range: 5 + sound: + path: /Audio/Ambience/Objects/server_fans.ogg + - type: AmbientOnPowered + - type: MessagesServer + - type: SingletonDeviceNetServer + - type: DeviceNetwork + deviceNetId: Wireless + transmitFrequencyId: NTMessagesServer + receiveFrequencyId: NTMessagesClient + autoConnect: false + - type: StationLimitedNetwork + +- type: entity + id: SyndicateMessagesServer + parent: MessagesServer + name: Syndicate PDA messaging server + description: Server that allows PDA messaging between Syndicate operatives to function. + components: + - type: DeviceNetwork + deviceNetId: Wireless + transmitFrequencyId: SyndicateMessagesServer + receiveFrequencyId: SyndicateMessagesClient + autoConnect: false \ No newline at end of file