Skip to content

Commit

Permalink
Only send MsgNewAppearance to InGame players
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Jan 24, 2025
1 parent 83ee0f1 commit 808ccab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion OpenDreamClient/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using OpenDreamClient.States;
using OpenDreamShared;
using OpenDreamShared.Network.Messages;
using Robust.Client;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Map;
Expand All @@ -27,6 +28,7 @@ public sealed class EntryPoint : GameClient {
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[Dependency] private readonly IClientNetManager _netManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly IBaseClient _client = default!;

private const string UserAgent =
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729)";
Expand Down Expand Up @@ -114,7 +116,8 @@ private void RxAllAppearances(MsgAllAppearances message) {
}

private void RxNewAppearance(MsgNewAppearance message) {
if (!_entitySystemManager.TryGetEntitySystem<ClientAppearanceSystem>(out var clientAppearanceSystem)) {
if (_client.RunLevel != ClientRunLevel.InGame ||
!_entitySystemManager.TryGetEntitySystem<ClientAppearanceSystem>(out var clientAppearanceSystem)) {
Logger.GetSawmill("opendream").Error("Received MsgNewAppearance before initializing entity systems");
return;
}
Expand Down
9 changes: 8 additions & 1 deletion OpenDreamRuntime/Rendering/ServerAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ private void RegisterAppearance(ImmutableAppearance immutableAppearance) {
ProxyWeakRef proxyWeakRef = new(immutableAppearance);
_appearanceLookup.Add(proxyWeakRef);
_idToAppearance.Add(immutableAppearance.MustGetId(), proxyWeakRef);
_networkManager.ServerSendToAll(new MsgNewAppearance(immutableAppearance));

var msg = new MsgNewAppearance(immutableAppearance);
foreach (var session in _playerManager.Sessions) {
if (session.Status != SessionStatus.InGame)
continue;

_networkManager.ServerSendMessage(msg, session.Channel);
}
}

public ImmutableAppearance AddAppearance(MutableAppearance appearance, bool registerAppearance = true) {
Expand Down

0 comments on commit 808ccab

Please sign in to comment.