Skip to content

Commit

Permalink
Go back to new appearances being an event
Browse files Browse the repository at this point in the history
We can revisit this if the size of these events actually end up being an issue
  • Loading branch information
wixoaGit committed Jan 24, 2025
1 parent 808ccab commit 56a847d
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 48 deletions.
12 changes: 0 additions & 12 deletions OpenDreamClient/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ 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 @@ -87,7 +86,6 @@ public override void PostInit() {
IoCManager.Resolve<IDreamSoundEngine>().Initialize();

_netManager.RegisterNetMessage<MsgAllAppearances>(RxAllAppearances);
_netManager.RegisterNetMessage<MsgNewAppearance>(RxNewAppearance);

if (_configurationManager.GetCVar(CVars.DisplayCompat))
_dreamInterface.OpenAlert(
Expand Down Expand Up @@ -115,16 +113,6 @@ private void RxAllAppearances(MsgAllAppearances message) {
clientAppearanceSystem.SetAllAppearances(message.AllAppearances);
}

private void RxNewAppearance(MsgNewAppearance message) {
if (_client.RunLevel != ClientRunLevel.InGame ||
!_entitySystemManager.TryGetEntitySystem<ClientAppearanceSystem>(out var clientAppearanceSystem)) {
Logger.GetSawmill("opendream").Error("Received MsgNewAppearance before initializing entity systems");
return;
}

clientAppearanceSystem.OnNewAppearance(message);
}

// As of RobustToolbox v0.90.0.0 there's a TileEdgeOverlay that breaks our rendering
// because we don't have an ITileDefinition for each tile.
// This removes that overlay immediately after MapSystem adds it.
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamClient/Interface/DummyDreamInterfaceManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using OpenDreamClient.Interface.Controls;
using OpenDreamClient.Interface.Descriptors;
using OpenDreamShared.Dream;
using OpenDreamShared.Network.Messages;
using Robust.Shared.Network;
Expand All @@ -20,6 +19,7 @@ public sealed class DummyDreamInterfaceManager : IDreamInterfaceManager {
public ControlMap? DefaultMap => null;
public ViewRange View => new(5);
public bool ShowPopupMenus => true;

[Dependency] private readonly IClientNetManager _netManager = default!;

public void Initialize() {
Expand Down
4 changes: 2 additions & 2 deletions OpenDreamClient/Rendering/ClientAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using OpenDreamClient.Resources;
using OpenDreamClient.Resources.ResourceTypes;
using Robust.Shared.Timing;
using OpenDreamShared.Network.Messages;

namespace OpenDreamClient.Rendering;

Expand All @@ -25,6 +24,7 @@ internal sealed class ClientAppearanceSystem : SharedAppearanceSystem {
[Dependency] private readonly DMISpriteSystem _spriteSystem = default!;

public override void Initialize() {
SubscribeNetworkEvent<NewAppearanceEvent>(OnNewAppearance);
SubscribeNetworkEvent<RemoveAppearanceEvent>(e => _appearances.Remove(e.AppearanceId));
SubscribeNetworkEvent<AnimationEvent>(OnAnimation);
SubscribeLocalEvent<DMISpriteComponent, WorldAABBEvent>(OnWorldAABB);
Expand Down Expand Up @@ -75,7 +75,7 @@ public DreamIcon GetTurfIcon(uint turfId) {
return icon;
}

public void OnNewAppearance(MsgNewAppearance e) {
public void OnNewAppearance(NewAppearanceEvent e) {
uint appearanceId = e.Appearance.MustGetId();
_appearances[appearanceId] = e.Appearance;

Expand Down
1 change: 0 additions & 1 deletion OpenDreamRuntime/DreamManager.Connections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ private void InitializeConnectionManager() {
_netManager.RegisterNetMessage<MsgSound>();
_netManager.RegisterNetMessage<MsgUpdateClientInfo>();
_netManager.RegisterNetMessage<MsgAllAppearances>();
_netManager.RegisterNetMessage<MsgNewAppearance>();

var topicPort = _config.GetCVar(OpenDreamCVars.TopicPort);
var worldTopicAddress = new IPEndPoint(IPAddress.Loopback, topicPort);
Expand Down
8 changes: 1 addition & 7 deletions OpenDreamRuntime/Rendering/ServerAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ private void RegisterAppearance(ImmutableAppearance immutableAppearance) {
_appearanceLookup.Add(proxyWeakRef);
_idToAppearance.Add(immutableAppearance.MustGetId(), proxyWeakRef);

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

_networkManager.ServerSendMessage(msg, session.Channel);
}
RaiseNetworkEvent(new NewAppearanceEvent(immutableAppearance));
}

public ImmutableAppearance AddAppearance(MutableAppearance appearance, bool registerAppearance = true) {
Expand Down
22 changes: 0 additions & 22 deletions OpenDreamShared/Network/Messages/MsgNewAppearance.cs

This file was deleted.

5 changes: 2 additions & 3 deletions OpenDreamShared/Rendering/SharedAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ public abstract class SharedAppearanceSystem : EntitySystem {
public abstract void RemoveAppearance(ImmutableAppearance appearance);

[Serializable, NetSerializable]
public sealed class NewAppearanceEvent(uint appearanceId, MutableAppearance appearance) : EntityEventArgs {
public uint AppearanceId { get; } = appearanceId;
public MutableAppearance Appearance { get; } = appearance;
public sealed class NewAppearanceEvent(ImmutableAppearance appearance) : EntityEventArgs {
public ImmutableAppearance Appearance { get; } = appearance;
}

[Serializable, NetSerializable]
Expand Down

0 comments on commit 56a847d

Please sign in to comment.