Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random Announcer Fixes #557

Merged
merged 5 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Content.IntegrationTests/Tests/Announcers/AnnouncerAudioTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System.Collections.Generic;
using System.Linq;
using Content.Server.Announcements.Systems;
using Content.Server.StationEvents;
using Content.Shared.Announcements.Prototypes;
using Robust.Client.ResourceManagement;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC.Exceptions;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Serilog;

namespace Content.IntegrationTests.Tests.Announcers;

/// <summary>
/// Checks if every station event wanting the announcerSystem to send audios has a sound file
DEATHB4DEFEAT marked this conversation as resolved.
Show resolved Hide resolved
/// </summary>
[TestFixture]
[TestOf(typeof(AnnouncerPrototype))]
public sealed class AnnouncerAudioTest
{
/// <inheritdoc cref="AnnouncerAudioTest" />
[Test]
public async Task TestEventSounds()
{
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true });
var server = pair.Server;
var client = pair.Client;

var entSysMan = server.ResolveDependency<IEntitySystemManager>();
var proto = server.ResolveDependency<IPrototypeManager>();
var cache = client.ResolveDependency<IResourceCache>();
var announcer = entSysMan.GetEntitySystem<AnnouncerSystem>();
var events = entSysMan.GetEntitySystem<EventManagerSystem>();

await server.WaitAssertion(() =>
{
var succeeded = true;
var why = new List<string>();

foreach (var announcerProto in proto.EnumeratePrototypes<AnnouncerPrototype>().OrderBy(a => a.ID))
{
foreach (var ev in events.AllEvents())
{
if (ev.Value.StartAnnouncement)
{
var announcementId = announcer.GetAnnouncementId(ev.Key.ID);
var path = announcer.GetAnnouncementPath(announcementId, announcerProto);

if (!cache.ContentFileExists(path))
{
succeeded = false;
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{path}\"");
}
}

if (ev.Value.EndAnnouncement)
{
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true);
var path = announcer.GetAnnouncementPath(announcementId, announcerProto);

if (!cache.ContentFileExists(path))
{
succeeded = false;
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{path}\"");
}
}
}
}

Assert.That(succeeded, Is.True, $"The following announcements do not have a valid announcement audio:\n {string.Join("\n ", why)}");
});

await pair.CleanReturnAsync();
}
}
20 changes: 11 additions & 9 deletions Content.IntegrationTests/Tests/Announcers/AnnouncerFallbackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@

namespace Content.IntegrationTests.Tests.Announcers;

/// <summary>
/// Checks if every announcer has a fallback announcement
/// </summary>
[TestFixture]
[TestOf(typeof(AnnouncerPrototype))]
public sealed class AnnouncerPrototypeTests
public sealed class AnnouncerPrototypeTest
{
/// <inheritdoc cref="AnnouncerPrototypeTest"/>
[Test]
public async Task TestAnnouncerFallbacks()
{
// Checks if every announcer has a fallback announcement

await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

Expand All @@ -24,13 +26,13 @@ await server.WaitAssertion(() =>
var success = true;
var why = new List<string>();

foreach (var announcer in prototype.EnumeratePrototypes<AnnouncerPrototype>())
foreach (var announcer in prototype.EnumeratePrototypes<AnnouncerPrototype>().OrderBy(a => a.ID))
{
if (announcer.Announcements.All(a => a.ID.ToLower() != "fallback"))
{
success = false;
why.Add(announcer.ID);
}
if (announcer.Announcements.Any(a => a.ID.ToLower() == "fallback"))
continue;

success = false;
why.Add(announcer.ID);
}

Assert.That(success, Is.True, $"The following announcers do not have a fallback announcement:\n {string.Join("\n ", why)}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
using System.Collections.Generic;
using System.Linq;
using Content.Server.Announcements.Systems;
using Content.Server.StationEvents;
using Content.Shared.Announcements.Prototypes;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.Announcers;

/// <summary>
/// Checks if every station event wanting the announcerSystem to send messages has a localization string
/// If an event doesn't have startAnnouncement or endAnnouncement set to true
/// it will be expected for that system to handle the announcements if it wants them
/// </summary>
[TestFixture]
[TestOf(typeof(AnnouncerPrototype))]
public sealed class AnnouncerLocalizationTest
{
/// <inheritdoc cref="AnnouncerLocalizationTest"/>
[Test]
public async Task TestEventLocalization()
{
// Checks if every station event wanting the announcerSystem to send messages has a localization string
// If an event doesn't have startAnnouncement or endAnnouncement set to true
// it will be expected for that system to handle the announcements if it wants them

await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var locale = server.ResolveDependency<ILocalizationManager>();
var entSysMan = server.ResolveDependency<IEntitySystemManager>();
var proto = server.ResolveDependency<IPrototypeManager>();
var announcer = entSysMan.GetEntitySystem<AnnouncerSystem>();
var events = entSysMan.GetEntitySystem<EventManagerSystem>();

Expand All @@ -31,29 +36,34 @@ await server.WaitAssertion(() =>
var succeeded = true;
var why = new List<string>();

foreach (var ev in events.AllEvents())
foreach (var announcerProto in proto.EnumeratePrototypes<AnnouncerPrototype>().OrderBy(a => a.ID))
{
if (ev.Value.StartAnnouncement)
foreach (var ev in events.AllEvents())
{
var announcementId = announcer.GetAnnouncementId(ev.Key.ID);
var eventLocaleString = announcer.GetEventLocaleString(announcementId);

if (locale.GetString(eventLocaleString) == eventLocaleString)
if (ev.Value.StartAnnouncement)
{
succeeded = false;
why.Add($"\"{announcementId}\": \"{eventLocaleString}\"");
}
}
var announcementId = announcer.GetAnnouncementId(ev.Key.ID);
var eventLocaleString = announcer.GetAnnouncementMessage(announcementId, announcerProto.ID)
?? announcer.GetEventLocaleString(announcementId);

if (ev.Value.EndAnnouncement)
{
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true);
var eventLocaleString = announcer.GetEventLocaleString(announcementId);
if (locale.GetString(eventLocaleString) == eventLocaleString)
{
succeeded = false;
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{eventLocaleString}\"");
}
}

if (locale.GetString(eventLocaleString) == eventLocaleString)
if (ev.Value.EndAnnouncement)
{
succeeded = false;
why.Add($"\"{announcementId}\": \"{eventLocaleString}\"");
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true);
var eventLocaleString = announcer.GetAnnouncementMessage(announcementId, announcerProto.ID)
?? announcer.GetEventLocaleString(announcementId);

if (locale.GetString(eventLocaleString) == eventLocaleString)
{
succeeded = false;
why.Add($"\"{announcerProto.ID}\", \"{announcementId}\": \"{eventLocaleString}\"");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public void SendAnnouncementMessage(string announcementId, string locale, string
sender ??= Loc.GetString($"announcer-{announcerOverride?.ID ?? Announcer.ID}-name");

// If the announcement has a message override, use that instead of the message parameter
if (GetAnnouncementMessage(announcementId, announcerOverride?.ID ?? Announcer.ID, localeArgs) is { } announcementMessage)
locale = announcementMessage;
if (GetAnnouncementMessage(announcementId, announcerOverride?.ID ?? Announcer.ID) is { } announcementMessage)
locale = Loc.GetString(announcementMessage, localeArgs);
else
locale = Loc.GetString(locale, localeArgs);

Expand Down
8 changes: 3 additions & 5 deletions Content.Shared/Announcements/Systems/SharedAnnouncerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public string GetAnnouncementId(string announcementId, bool ended = false)
announcer.Announcements.First(a => a.ID == "fallback");

// Return the announcer.BaseAudioParams if the announcementType doesn't have an override
return announcementType.AudioParams ?? announcer.BaseAudioParams ?? null; // For some reason the formatter doesn't warn me about "?? null" being redundant, so it stays
return announcementType.AudioParams ?? announcer.BaseAudioParams ?? null; // For some reason the formatter doesn't warn me about "?? null" being redundant, so it stays for the funnies
}

/// <summary>
Expand All @@ -117,9 +117,7 @@ public string GetAnnouncementId(string announcementId, bool ended = false)
/// </summary>
/// <param name="announcementId">ID of the announcement from the announcer to get information from</param>
/// <param name="announcerId">ID of the announcer to get information from</param>
/// <param name="localeArgs">Locale arguments to pass to the overwritten announcement</param>
public string? GetAnnouncementMessage(string announcementId, string announcerId,
params (string, object)[] localeArgs)
public string? GetAnnouncementMessage(string announcementId, string announcerId)
{
if (!_proto.TryIndex<AnnouncerPrototype>(announcerId, out var announcer))
return null;
Expand All @@ -130,7 +128,7 @@ public string GetAnnouncementId(string announcementId, bool ended = false)
announcer.Announcements.First(a => a.ID == "fallback");

// Return the announcementType.MessageOverride if it exists, otherwise return null
return announcementType.MessageOverride != null ? Loc.GetString(announcementType.MessageOverride, localeArgs) : null;
return announcementType.MessageOverride != null ? announcementType.MessageOverride : null;
}

/// <summary>
Expand Down
Binary file removed Resources/Audio/Announcements/Intern/aliens.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/animes.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/1.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/13.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/2.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/3.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/4.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/5.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/6.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/7.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/8.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/announce/9.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/anomaly.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/intercept.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/ionstorm.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/meteors.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/newai.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/outbreak7.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/poweroff.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/poweron.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/radiation.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/welcome/1.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/welcome/2.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/welcome/3.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/welcome/4.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/welcome/5.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/Intern/welcome/6.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/aliens.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/animes.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/announce.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/anomaly.ogg
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/fallback.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/intercept.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/ionstorm.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/meteors.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/newai.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/outbreak7.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/poweroff.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/poweron.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/radiation.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/shuttledock.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/MedBot/welcome.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/announce.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/attention.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_blue.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_delta.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_epsilon.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_gamma.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_green.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_red.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_violet.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_white.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/code_yellow.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/fallback.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/kudzu.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/meteors.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/newai.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/outbreak7.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/poweroff.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/poweron.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/radiation.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/shuttlecalled.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/shuttledock.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/NEIL/welcome.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/aliens.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/announce.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/anomaly.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/attention.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/fallback.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/ionstorm.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/meteors.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/newai.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/poweroff.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/poweron.ogg
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/radiation.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/shuttledock.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcements/VoxFem/welcome.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcers/NEIL/events/gasleak.ogg
Binary file not shown.
Binary file not shown.
Binary file removed Resources/Audio/Announcers/NEIL/events/ventclog.ogg
Binary file not shown.
Loading