Stop network serializing prototypes (#38602)
* Stop network serializing prototypes Send the damn proto ID instead. * Fix sandbox violation
This commit is contained in:
committed by
GitHub
parent
bb7e7c3e5f
commit
73df3b1593
@@ -9,12 +9,14 @@ using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Mind;
|
||||
using Content.Shared.Players.PlayTimeTracking;
|
||||
using Prometheus;
|
||||
using Robust.Shared;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Reflection;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
@@ -33,6 +35,7 @@ public sealed partial class AdminLogManager : SharedAdminLogManager, IAdminLogMa
|
||||
[Dependency] private readonly ISharedPlayerManager _player = default!;
|
||||
[Dependency] private readonly ISharedPlaytimeManager _playtime = default!;
|
||||
[Dependency] private readonly ISharedChatManager _chat = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
|
||||
public const string SawmillId = "admin.logs";
|
||||
|
||||
@@ -330,7 +333,8 @@ public sealed partial class AdminLogManager : SharedAdminLogManager, IAdminLogMa
|
||||
var cachedInfo = adminSys.GetCachedPlayerInfo(new NetUserId(id));
|
||||
if (cachedInfo != null && cachedInfo.Antag)
|
||||
{
|
||||
var subtype = Loc.GetString(cachedInfo.Subtype ?? cachedInfo.RoleProto.Name);
|
||||
var proto = cachedInfo.RoleProto == null ? null : _proto.Index(cachedInfo.RoleProto.Value);
|
||||
var subtype = Loc.GetString(cachedInfo.Subtype ?? proto?.Name ?? RoleTypePrototype.FallbackName);
|
||||
logMessage = Loc.GetString(
|
||||
"admin-alert-antag-label",
|
||||
("message", logMessage),
|
||||
|
||||
@@ -231,7 +231,7 @@ public sealed class AdminSystem : EntitySystem
|
||||
var antag = false;
|
||||
|
||||
// Starting role, antagonist status and role type
|
||||
RoleTypePrototype roleType = new();
|
||||
RoleTypePrototype? roleType = null;
|
||||
var startingRole = string.Empty;
|
||||
LocId? subtype = null;
|
||||
if (_minds.TryGetMind(session, out var mindId, out var mindComp) && mindComp is not null)
|
||||
@@ -244,7 +244,7 @@ public sealed class AdminSystem : EntitySystem
|
||||
subtype = mindComp.Subtype;
|
||||
}
|
||||
else
|
||||
Log.Error($"{ToPrettyString(mindId)} has invalid Role Type '{mindComp.RoleType}'. Displaying '{Loc.GetString(roleType.Name)}' instead");
|
||||
Log.Error($"{ToPrettyString(mindId)} has invalid Role Type '{mindComp.RoleType}'. Displaying '{Loc.GetString(RoleTypePrototype.FallbackName)}' instead");
|
||||
|
||||
antag = _role.MindIsAntagonist(mindId);
|
||||
startingRole = _jobs.MindTryGetJobName(mindId);
|
||||
@@ -270,7 +270,7 @@ public sealed class AdminSystem : EntitySystem
|
||||
identityName,
|
||||
startingRole,
|
||||
antag,
|
||||
roleType,
|
||||
roleType?.ID,
|
||||
subtype,
|
||||
sortWeight,
|
||||
GetNetEntity(session?.AttachedEntity),
|
||||
|
||||
@@ -18,6 +18,7 @@ using Robust.Server.Audio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Map.Events;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -496,14 +497,15 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
return;
|
||||
|
||||
var sources = _deviceLinkSystem.GetSourcePorts(sourceUid, sourceComponent);
|
||||
var sinks = _deviceLinkSystem.GetSinkPorts(sinkUid, sinkComponent);
|
||||
var sinks = _deviceLinkSystem.GetSinkPortIds((sinkUid, sinkComponent));
|
||||
var links = _deviceLinkSystem.GetLinks(sourceUid, sinkUid, sourceComponent);
|
||||
var defaults = _deviceLinkSystem.GetDefaults(sources);
|
||||
var sourceIds = sources.Select(s => (ProtoId<SourcePortPrototype>)s.ID).ToArray();
|
||||
|
||||
var sourceAddress = Resolve(sourceUid, ref sourceNetworkComponent, false) ? sourceNetworkComponent.Address : "";
|
||||
var sinkAddress = Resolve(sinkUid, ref sinkNetworkComponent, false) ? sinkNetworkComponent.Address : "";
|
||||
|
||||
var state = new DeviceLinkUserInterfaceState(sources, sinks, links, sourceAddress, sinkAddress, defaults);
|
||||
var state = new DeviceLinkUserInterfaceState(sourceIds, sinks, links, sourceAddress, sinkAddress, defaults);
|
||||
_uiSystem.SetUiState(configuratorUid, NetworkConfiguratorUiKey.Link, state);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Server.Chat.Systems;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Shared.Chat.Prototypes;
|
||||
using Content.Shared.Speech.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Speech.EntitySystems;
|
||||
|
||||
@@ -9,6 +10,7 @@ public sealed class MumbleAccentSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly ChatSystem _chat = default!;
|
||||
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -23,10 +25,14 @@ public sealed class MumbleAccentSystem : EntitySystem
|
||||
if (args.Handled || !args.Emote.Category.HasFlag(EmoteCategory.Vocal))
|
||||
return;
|
||||
|
||||
if (TryComp<VocalComponent>(ent.Owner, out var vocalComp))
|
||||
if (TryComp<VocalComponent>(ent.Owner, out var vocalComp) && vocalComp.EmoteSounds is { } sounds)
|
||||
{
|
||||
// play a muffled version of the vocal emote
|
||||
args.Handled = _chat.TryPlayEmoteSound(ent.Owner, vocalComp.EmoteSounds, args.Emote, ent.Comp.EmoteAudioParams);
|
||||
args.Handled = _chat.TryPlayEmoteSound(
|
||||
ent.Owner,
|
||||
_prototype.Index(sounds),
|
||||
args.Emote,
|
||||
ent.Comp.EmoteAudioParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +64,11 @@ public sealed class VocalSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.EmoteSounds is not { } sounds)
|
||||
return;
|
||||
|
||||
// just play regular sound based on emote proto
|
||||
args.Handled = _chat.TryPlayEmoteSound(uid, component.EmoteSounds, args.Emote);
|
||||
args.Handled = _chat.TryPlayEmoteSound(uid, _proto.Index(sounds), args.Emote);
|
||||
}
|
||||
|
||||
private void OnScreamAction(EntityUid uid, VocalComponent component, ScreamActionEvent args)
|
||||
@@ -85,7 +88,10 @@ public sealed class VocalSystem : EntitySystem
|
||||
return true;
|
||||
}
|
||||
|
||||
return _chat.TryPlayEmoteSound(uid, component.EmoteSounds, component.ScreamId);
|
||||
if (component.EmoteSounds is not { } sounds)
|
||||
return false;
|
||||
|
||||
return _chat.TryPlayEmoteSound(uid, _proto.Index(sounds), component.ScreamId);
|
||||
}
|
||||
|
||||
private void LoadSounds(EntityUid uid, VocalComponent component, Sex? sex = null)
|
||||
@@ -97,6 +103,10 @@ public sealed class VocalSystem : EntitySystem
|
||||
|
||||
if (!component.Sounds.TryGetValue(sex.Value, out var protoId))
|
||||
return;
|
||||
_proto.TryIndex(protoId, out component.EmoteSounds);
|
||||
|
||||
if (!_proto.HasIndex(protoId))
|
||||
return;
|
||||
|
||||
component.EmoteSounds = protoId;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user