fix: Message server now can see new user (#611)

This commit is contained in:
Spatison
2024-08-12 13:29:49 +03:00
committed by GitHub
parent 20b728448f
commit 8579ab7602
5 changed files with 94 additions and 74 deletions

View File

@@ -29,6 +29,18 @@ public sealed class SingletonDeviceNetServerSystem : EntitySystem
return Resolve(serverId, ref serverComponent) && serverComponent.Active; 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> /// <summary>
/// Returns the address of the currently active server for the given station id if there is one.<br/> /// 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/> /// What kind of server you're trying to get the active instance of is determined by the component type parameter TComp.<br/>

View File

@@ -44,8 +44,8 @@ public sealed class MessagesCartridgeSystem : EntitySystem
out var address) || !TryComp(uid, out CartridgeComponent? cartComponent)) out var address) || !TryComp(uid, out CartridgeComponent? cartComponent))
return; return;
SendName(uid, component, cartComponent, address);
component.UserUid = cartComponent.LoaderUid?.Id; component.UserUid = cartComponent.LoaderUid?.Id;
SendName(uid, component, cartComponent, address);
} }
private void OnRemove(EntityUid uid, MessagesCartridgeComponent component, ComponentRemove args) private void OnRemove(EntityUid uid, MessagesCartridgeComponent component, ComponentRemove args)
@@ -179,6 +179,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
[MessagesNetworkKeys.UserId] = component.UserUid, [MessagesNetworkKeys.UserId] = component.UserUid,
[MessagesNetworkKeys.NewUser] = messagesUser [MessagesNetworkKeys.NewUser] = messagesUser
}; };
_deviceNetworkSystem.QueuePacket(uid, address, packet); _deviceNetworkSystem.QueuePacket(uid, address, packet);
} }
@@ -199,7 +200,7 @@ public sealed class MessagesCartridgeSystem : EntitySystem
/// <summary> /// <summary>
/// Returns the user's name, job title and job department /// Returns the user's name, job title and job department
/// </summary> /// </summary>
public bool TryGetMessagesUser(MessagesCartridgeComponent component, CartridgeComponent cartridgeComponent, out MessagesUserData messagesUserData) private bool TryGetMessagesUser(MessagesCartridgeComponent component, CartridgeComponent cartridgeComponent, out MessagesUserData messagesUserData)
{ {
messagesUserData = new MessagesUserData(); messagesUserData = new MessagesUserData();

View File

@@ -3,6 +3,7 @@ using Content.Server._White.CartridgeLoader.Cartridges;
using Content.Server._White.Radio.Components; using Content.Server._White.Radio.Components;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Chat.Systems; using Content.Server.Chat.Systems;
using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems; using Content.Server.DeviceNetwork.Systems;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Shared._White.CartridgeLoader.Cartridges; using Content.Shared._White.CartridgeLoader.Cartridges;
@@ -26,18 +27,27 @@ public sealed class MessagesServerSystem : EntitySystem
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<MessagesServerComponent, DeviceNetworkPacketEvent>(OnPacketReceived); SubscribeLocalEvent<MessagesServerComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
SubscribeLocalEvent<MessagesServerComponent, ComponentInit>(OnInit); SubscribeLocalEvent<MessagesServerComponent, MapInitEvent>(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<MessagesCartridgeComponent>(); var query = EntityQueryEnumerator<MessagesCartridgeComponent>();
var stationId = _stationSystem.GetOwningStation(uid);
while (query.MoveNext(out var entityUid, out var cartridge)) while (query.MoveNext(out var entityUid, out var cartridge))
{ {
if (stationId.HasValue && _singletonServerSystem.TryGetActiveServerAddress<MessagesServerComponent>(stationId.Value, out var address) && TryComp(entityUid, out CartridgeComponent? cartComponent)) var stationId = _stationSystem.GetOwningStation(entityUid);
_messagesSystem.SendName(entityUid, cartridge, cartComponent, address); if (stationId.HasValue && stationIdServer == stationId && TryComp(entityUid, out CartridgeComponent? cartComponent))
_messagesSystem.SendName(entityUid, cartridge, cartComponent, device.Address);
} }
} }

View File

@@ -85,70 +85,4 @@
- EncryptionKeyScience - EncryptionKeyScience
- EncryptionKeySecurity - EncryptionKeySecurity
- EncryptionKeyService - EncryptionKeyService
- EncryptionKeyCommand - 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

View File

@@ -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