Stop network serializing prototypes (#38602)

* Stop network serializing prototypes

Send the damn proto ID instead.

* Fix sandbox violation
This commit is contained in:
Pieter-Jan Briers
2025-06-27 01:27:23 +02:00
committed by GitHub
parent bb7e7c3e5f
commit 73df3b1593
28 changed files with 120 additions and 59 deletions

View File

@@ -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);
}
}

View File

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