Skip to content

Commit

Permalink
Merge pull request #431 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Jan 26, 2024
2 parents d7cc89d + 58ae4b3 commit f1f751c
Show file tree
Hide file tree
Showing 1,013 changed files with 288,684 additions and 321,679 deletions.
28 changes: 24 additions & 4 deletions Content.Client/Corvax/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ public sealed class TTSSystem : EntitySystem
private readonly MemoryContentRoot _contentRoot = new();
private ResPath _prefix;

/// <summary>
/// Reducing the volume of the TTS when whispering. Will be converted to logarithm.
/// </summary>
private const float WhisperFade = 4f;

/// <summary>
/// The volume at which the TTS sound will not be heard.
/// </summary>
private const float MinimalVolume = -10f;

private float _volume = 0.0f;
private ulong _fileIdx = 0;
private static ulong _shareIdx = 0;
Expand Down Expand Up @@ -66,9 +76,7 @@ private void OnPlayTTS(PlayTTSEvent ev)
{
//_sawmill.Debug($"Play TTS audio {ev.Data.Length} bytes from {ev.SourceUid} entity");

var volume = _volume;
if (ev.IsWhisper)
volume -= 4;
var volume = AdjustVolume(ev.IsWhisper);

var filePath = new ResPath($"{_fileIdx++}.ogg");
_contentRoot.AddOrUpdateFile(filePath, ev.Data);
Expand All @@ -79,7 +87,7 @@ private void OnPlayTTS(PlayTTSEvent ev)
{
var sourceUid = GetEntity(ev.SourceUid.Value);
if(sourceUid.Valid)
_audio.PlayEntity(soundPath, EntityUid.Invalid, sourceUid); // recipient arg ignored on client
_audio.PlayEntity(soundPath, Filter.Local(), sourceUid, false, AudioParams.Default); // recipient arg ignored on client
}
else
{
Expand All @@ -88,4 +96,16 @@ private void OnPlayTTS(PlayTTSEvent ev)

_contentRoot.RemoveFile(filePath);
}

private float AdjustVolume(bool isWhisper)
{
var volume = MinimalVolume + SharedAudioSystem.GainToVolume(_volume);

if (isWhisper)
{
volume -= SharedAudioSystem.GainToVolume(WhisperFade);
}

return volume;
}
}
2 changes: 1 addition & 1 deletion Content.Client/Doors/AirlockSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void OnAppearanceChange(EntityUid uid, AirlockComponent comp, ref Appear
if (_appearanceSystem.TryGetData<bool>(uid, DoorVisuals.Powered, out var powered, args.Component) && powered)
{
boltedVisible = _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.BoltLights, out var lights, args.Component)
&& lights && (state == DoorState.Closed || state == DoorState.Open || state == DoorState.Welded);
&& lights && (state == DoorState.Closed || state == DoorState.Welded);

emergencyLightsVisible = _appearanceSystem.TryGetData<bool>(uid, DoorVisuals.EmergencyLights, out var eaLights, args.Component) && eaLights;
unlitVisible =
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Movement/Systems/SpriteMovementSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ private void OnSpriteMoveInput(EntityUid uid, SpriteMovementComponent component,
if (!_timing.IsFirstTimePredicted)
return;

var oldMoving = SharedMoverController.GetNormalizedMovement(args.OldMovement) != MoveButtons.None;
var moving = SharedMoverController.GetNormalizedMovement(args.Component.HeldMoveButtons) != MoveButtons.None;
var oldMoving = (SharedMoverController.GetNormalizedMovement(args.OldMovement) & MoveButtons.AnyDirection) != MoveButtons.None;
var moving = (SharedMoverController.GetNormalizedMovement(args.Component.HeldMoveButtons) & MoveButtons.AnyDirection) != MoveButtons.None;

if (oldMoving == moving || !_spriteQuery.TryGetComponent(uid, out var sprite))
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
MinSize="465 225">
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#25252AAA" />
<graphics:StyleBoxFlat BackgroundColor="#25252ADD" />
</PanelContainer.PanelOverride>

<BoxContainer Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True" VerticalExpand="True">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ public async Task RepairReinforcedWindow()
var comp = Comp<DamageableComponent>();
var damageType = Server.ResolveDependency<IPrototypeManager>().Index<DamageTypePrototype>("Blunt");
var damage = new DamageSpecifier(damageType, FixedPoint2.New(10));
Assert.That(comp.Damage.Total, Is.EqualTo(FixedPoint2.Zero));
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));
await Server.WaitPost(() => sys.TryChangeDamage(SEntMan.GetEntity(Target), damage, ignoreResistances: true));
await RunTicks(5);
Assert.That(comp.Damage.Total, Is.GreaterThan(FixedPoint2.Zero));
Assert.That(comp.Damage.GetTotal(), Is.GreaterThan(FixedPoint2.Zero));

// Repair the entity
await Interact(Weld);
Assert.That(comp.Damage.Total, Is.EqualTo(FixedPoint2.Zero));
Assert.That(comp.Damage.GetTotal(), Is.EqualTo(FixedPoint2.Zero));

// Validate that we can still deconstruct the entity (i.e., that welding deconstruction is not blocked).
await Interact(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Robust.Shared.ContentPack;
using Robust.Shared.Prototypes;
using System.Linq;
using Robust.Shared.Log;

namespace Content.IntegrationTests.Tests.Guidebook;

Expand All @@ -24,20 +23,18 @@ public async Task ValidatePrototypeContents()
var parser = client.ResolveDependency<DocumentParsingManager>();
var prototypes = protoMan.EnumeratePrototypes<GuideEntryPrototype>().ToList();

client.ResolveDependency<ILogManager>().GetSawmill("ui").Level = LogLevel.Error;

await client.WaitAssertion(() =>
foreach (var proto in prototypes)
{
Assert.Multiple(() =>
await client.WaitAssertion(() =>
{
foreach (var proto in prototypes)
{
var text = resMan.ContentFileReadText(proto.Text).ReadToEnd();
Assert.That(parser.TryAddMarkup(new Document(), text), $"Failed to parse guidebook: {proto.Id}");
}
using var reader = resMan.ContentFileReadText(proto.Text);
var text = reader.ReadToEnd();
Assert.That(parser.TryAddMarkup(new Document(), text), $"Failed to parse guidebook: {proto.Id}");
});
});
await client.WaitRunTicks(10);

// Avoid styleguide update limit
await client.WaitRunTicks(1);
}

await pair.CleanReturnAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ await server.WaitAssertion(() =>
Assert.That(damageResult, Is.Not.Null,
"Received null damageResult when attempting to damage restock box.");

Assert.That((int) damageResult!.Total, Is.GreaterThan(0),
Assert.That((int) damageResult!.GetTotal(), Is.GreaterThan(0),
"Box damage result was not greater than 0.");
#pragma warning restore NUnit2045
});
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Administration/Managers/AdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private void UpdateAdminStatus(ICommonSession session)

msg.AvailableCommands = commands.ToArray();

_netMgr.ServerSendMessage(msg, session.ConnectedClient);
_netMgr.ServerSendMessage(msg, session.Channel);
}

private void PlayerStatusChanged(object? sender, SessionStatusEventArgs e)
Expand Down Expand Up @@ -389,7 +389,7 @@ private async void LoginAdminMaybe(ICommonSession session)

private static bool IsLocal(ICommonSession player)
{
var ep = player.ConnectedClient.RemoteEndPoint;
var ep = player.Channel.RemoteEndPoint;
var addr = ep.Address;
if (addr.IsIPv4MappedToIPv6)
{
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Administration/Managers/BanManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private async void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs
if (e.NewStatus != SessionStatus.Connected || _cachedRoleBans.ContainsKey(e.Session.UserId))
return;

var netChannel = e.Session.ConnectedClient;
var netChannel = e.Session.Channel;
ImmutableArray<byte>? hwId = netChannel.UserData.HWId.Length == 0 ? null : netChannel.UserData.HWId;
await CacheDbRoleBans(e.Session.UserId, netChannel.RemoteEndPoint.Address, hwId);

Expand Down Expand Up @@ -175,7 +175,7 @@ public async void CreateServerBan(NetUserId? target, string? targetUsername, Net
return;
// If they are, kick them
var message = banDef.FormatBanMessage(_cfg, _localizationManager);
targetPlayer.ConnectedClient.Disconnect(message);
targetPlayer.Channel.Disconnect(message);
}
#endregion

Expand Down Expand Up @@ -293,7 +293,7 @@ public void SendRoleBans(ICommonSession pSession)
};

_sawmill.Debug($"Sent rolebans to {pSession.Name}");
_netManager.ServerSendMessage(bans, pSession.ConnectedClient);
_netManager.ServerSendMessage(bans, pSession.Channel);
}

public void PostInject()
Expand Down
10 changes: 5 additions & 5 deletions Content.Server/Administration/PlayerLocator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Immutable;
using System.Collections.Immutable;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
Expand Down Expand Up @@ -67,8 +67,8 @@ public PlayerLocator()
if (_playerManager.TryGetSessionByUsername(playerName, out var session))
{
var userId = session.UserId;
var address = session.ConnectedClient.RemoteEndPoint.Address;
var hwId = session.ConnectedClient.UserData.HWId;
var address = session.Channel.RemoteEndPoint.Address;
var hwId = session.Channel.UserData.HWId;
return new LocatedPlayerData(userId, address, hwId, session.Name);
}

Expand Down Expand Up @@ -107,8 +107,8 @@ public PlayerLocator()
// Check people currently on the server, the easiest case.
if (_playerManager.TryGetSessionById(userId, out var session))
{
var address = session.ConnectedClient.RemoteEndPoint.Address;
var hwId = session.ConnectedClient.UserData.HWId;
var address = session.Channel.RemoteEndPoint.Address;
var hwId = session.Channel.UserData.HWId;
return new LocatedPlayerData(userId, address, hwId, session.Name);
}

Expand Down
10 changes: 5 additions & 5 deletions Content.Server/Administration/QuickDialogSystem.OpenDialog.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Shared.Administration;
using Content.Shared.Administration;
using JetBrains.Annotations;
using Robust.Shared.Player;

Expand Down Expand Up @@ -33,7 +33,7 @@ public void OpenDialog<T1>(ICommonSession session, string title, string prompt,
okAction.Invoke(v1);
else
{
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
session.Channel.Disconnect("Replied with invalid quick dialog data.");
cancelAction?.Invoke();
}
}),
Expand Down Expand Up @@ -74,7 +74,7 @@ public void OpenDialog<T1, T2>(ICommonSession session, string title, string prom
okAction.Invoke(v1, v2);
else
{
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
session.Channel.Disconnect("Replied with invalid quick dialog data.");
cancelAction?.Invoke();
}
}),
Expand Down Expand Up @@ -118,7 +118,7 @@ public void OpenDialog<T1, T2, T3>(ICommonSession session, string title, string
okAction.Invoke(v1, v2, v3);
else
{
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
session.Channel.Disconnect("Replied with invalid quick dialog data.");
cancelAction?.Invoke();
}
}),
Expand Down Expand Up @@ -166,7 +166,7 @@ public void OpenDialog<T1, T2, T3, T4>(ICommonSession session, string title, str
okAction.Invoke(v1, v2, v3, v4);
else
{
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
session.Channel.Disconnect("Replied with invalid quick dialog data.");
cancelAction?.Invoke();
}
}),
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Administration/QuickDialogSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Enums;
Expand Down Expand Up @@ -40,7 +40,7 @@ private void Handler(QuickDialogResponseEvent msg, EntitySessionEventArgs args)
{
if (!_openDialogs.ContainsKey(msg.DialogId) || !_openDialogsByUser[args.SenderSession.UserId].Contains(msg.DialogId))
{
args.SenderSession.ConnectedClient.Disconnect($"Replied with invalid quick dialog data with id {msg.DialogId}.");
args.SenderSession.Channel.Disconnect($"Replied with invalid quick dialog data with id {msg.DialogId}.");
return;
}

Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Administration/Systems/AdminSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ private void OnRoundRestartCleanup(RoundRestartCleanupEvent ev)

foreach (var admin in _adminManager.ActiveAdmins)
{
RaiseNetworkEvent(updateEv, admin.ConnectedClient);
RaiseNetworkEvent(updateEv, admin.Channel);
}
}

Expand All @@ -123,7 +123,7 @@ public void UpdatePlayerList(ICommonSession player)

foreach (var admin in _adminManager.ActiveAdmins)
{
RaiseNetworkEvent(playerInfoChangedEvent, admin.ConnectedClient);
RaiseNetworkEvent(playerInfoChangedEvent, admin.Channel);
}
}

Expand Down Expand Up @@ -159,7 +159,7 @@ private void OnAdminPermsChanged(AdminPermsChangedEventArgs obj)

if (!obj.IsAdmin)
{
RaiseNetworkEvent(new FullPlayerListEvent(), obj.Player.ConnectedClient);
RaiseNetworkEvent(new FullPlayerListEvent(), obj.Player.Channel);
return;
}

Expand Down Expand Up @@ -212,7 +212,7 @@ private void SendFullPlayerList(ICommonSession playerSession)

ev.PlayersInfo = _playerList.Values.ToList();

RaiseNetworkEvent(ev, playerSession.ConnectedClient);
RaiseNetworkEvent(ev, playerSession.Channel);
}

private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private void AddAntagVerbs(GetVerbsEvent<Verb> args)
{
Text = Loc.GetString("admin-verb-text-make-head-rev"),
Category = VerbCategory.Antag,
Icon = new SpriteSpecifier.Texture(new("/Textures/Interface/Misc/job_icons.rsi/HeadRevolutionary.png")),
Icon = new SpriteSpecifier.Rsi(new("/Textures/Interface/Misc/job_icons.rsi"), "HeadRevolutionary"),
Act = () =>
{
if (!_minds.TryGetMind(args.Target, out var mindId, out var mind))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/gavel.svg.192dpi.png")),
Act = () =>
{
_ghostKickManager.DoDisconnect(actorComponent.PlayerSession.ConnectedClient, "Smitten.");
_ghostKickManager.DoDisconnect(actorComponent.PlayerSession.Channel, "Smitten.");
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-ghostkick-description")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ private void AddTricksVerbs(GetVerbsEvent<Verb> args)
Act = () =>
{
_batterySystem.SetCharge(args.Target, battery.MaxCharge, battery);
Dirty(args.Target, battery);
},
Impact = LogImpact.Medium,
Message = Loc.GetString("admin-trick-refill-battery-description"),
Expand All @@ -186,7 +185,6 @@ private void AddTricksVerbs(GetVerbsEvent<Verb> args)
Act = () =>
{
_batterySystem.SetCharge(args.Target, 0, battery);
Dirty(args.Target, battery);
},
Impact = LogImpact.Medium,
Message = Loc.GetString("admin-trick-drain-battery-description"),
Expand Down Expand Up @@ -556,7 +554,6 @@ private void AddTricksVerbs(GetVerbsEvent<Verb> args)
continue;
var battery = EnsureComp<BatteryComponent>(ent);
_batterySystem.SetCharge(ent, battery.MaxCharge, battery);
Dirty(ent, battery);
}
},
Impact = LogImpact.Extreme,
Expand All @@ -578,7 +575,6 @@ private void AddTricksVerbs(GetVerbsEvent<Verb> args)
continue;
var battery = EnsureComp<BatteryComponent>(ent);
_batterySystem.SetCharge(ent, 0, battery);
Dirty(ent, battery);
}
},
Impact = LogImpact.Extreme,
Expand Down
Loading

0 comments on commit f1f751c

Please sign in to comment.