From 7389733a0f55c0e19ecc93d387b958bf96c2e183 Mon Sep 17 00:00:00 2001 From: Tayrtahn Date: Thu, 13 Aug 2026 10:18:25 +0000 Subject: [PATCH] Fix `GuidebookDataSystem` late MsgEntity warning (#45298) Send GuidebookData automatically to new clients. --- Content.Client/Guidebook/GuidebookDataSystem.cs | 3 --- Content.Server/Guidebook/GuidebookDataSystem.cs | 16 ++++++++++++---- Content.Shared/Guidebook/Events.cs | 10 ++-------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Content.Client/Guidebook/GuidebookDataSystem.cs b/Content.Client/Guidebook/GuidebookDataSystem.cs index f47ad6ef1b..eb968d960b 100644 --- a/Content.Client/Guidebook/GuidebookDataSystem.cs +++ b/Content.Client/Guidebook/GuidebookDataSystem.cs @@ -17,9 +17,6 @@ public sealed class GuidebookDataSystem : EntitySystem base.Initialize(); SubscribeNetworkEvent(OnServerUpdated); - - // Request data from the server - RaiseNetworkEvent(new RequestGuidebookDataEvent()); } private void OnServerUpdated(UpdateGuidebookDataEvent args) diff --git a/Content.Server/Guidebook/GuidebookDataSystem.cs b/Content.Server/Guidebook/GuidebookDataSystem.cs index cf6761ab7d..a83959edd0 100644 --- a/Content.Server/Guidebook/GuidebookDataSystem.cs +++ b/Content.Server/Guidebook/GuidebookDataSystem.cs @@ -1,5 +1,8 @@ using System.Reflection; using Content.Shared.Guidebook; +using Robust.Server.Player; +using Robust.Shared.Enums; +using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -11,6 +14,8 @@ namespace Content.Server.Guidebook; /// public sealed partial class GuidebookDataSystem : EntitySystem { + [Dependency] private IPlayerManager _player = default!; + private readonly Dictionary> _tagged = []; private GuidebookData _cachedData = new(); @@ -18,18 +23,21 @@ public sealed partial class GuidebookDataSystem : EntitySystem { base.Initialize(); - SubscribeNetworkEvent(OnRequestRules); SubscribeLocalEvent(OnPrototypesReloaded); + _player.PlayerStatusChanged += OnPlayerStatusChanged; // Build initial cache GatherData(ref _cachedData); } - private void OnRequestRules(RequestGuidebookDataEvent ev, EntitySessionEventArgs args) + private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e) { - // Send cached data to requesting client + if (e.NewStatus != SessionStatus.Connected) + return; + + // Send cached data to newly-connected client. var sendEv = new UpdateGuidebookDataEvent(_cachedData); - RaiseNetworkEvent(sendEv, args.SenderSession); + RaiseNetworkEvent(sendEv, e.Session); } private void OnPrototypesReloaded(PrototypesReloadedEventArgs args) diff --git a/Content.Shared/Guidebook/Events.cs b/Content.Shared/Guidebook/Events.cs index e43bf4392c..f42a6df283 100644 --- a/Content.Shared/Guidebook/Events.cs +++ b/Content.Shared/Guidebook/Events.cs @@ -3,14 +3,8 @@ using Robust.Shared.Serialization; namespace Content.Shared.Guidebook; /// -/// Raised by the client on GuidebookDataSystem Initialize to request a -/// full set of guidebook data from the server. -/// -[Serializable, NetSerializable] -public sealed class RequestGuidebookDataEvent : EntityEventArgs { } - -/// -/// Raised by the server at a specific client in response to . +/// Sends all extracted prototype data needed by GuidebookDataSystem. +/// Raised by the server directed at newly-connected clients. /// Also raised by the server at ALL clients when prototype data is hot-reloaded. /// [Serializable, NetSerializable]