NewsSystem fixes (#23969)
This commit is contained in:
@@ -36,7 +36,7 @@ using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.MassMedia.Systems;
|
||||
|
||||
public sealed class NewsSystem : EntitySystem
|
||||
public sealed class NewsSystem : SharedNewsSystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
@@ -50,6 +50,7 @@ public sealed class NewsSystem : EntitySystem
|
||||
[Dependency] private readonly StationRecordsSystem _stationRecords = default!;
|
||||
|
||||
// TODO remove this. Dont store data on systems
|
||||
// Honestly NewsSystem just needs someone to rewrite it entirely.
|
||||
private readonly List<NewsArticle> _articles = new List<NewsArticle>();
|
||||
|
||||
public override void Initialize()
|
||||
@@ -68,7 +69,7 @@ public sealed class NewsSystem : EntitySystem
|
||||
|
||||
private void OnRoundRestart(RoundRestartCleanupEvent ev)
|
||||
{
|
||||
_articles?.Clear();
|
||||
_articles.Clear();
|
||||
}
|
||||
|
||||
public void ToggleUi(EntityUid user, EntityUid deviceEnt, NewsWriteComponent? component)
|
||||
@@ -133,10 +134,12 @@ public sealed class NewsSystem : EntitySystem
|
||||
if (!_accessReader.FindAccessItemsInventory(author, out var items))
|
||||
return;
|
||||
|
||||
if (!_accessReader.FindStationRecordKeys(author, out var stationRecordKeys, items))
|
||||
if (!_accessReader.FindStationRecordKeys(author, out _, items))
|
||||
return;
|
||||
|
||||
string? authorName = null;
|
||||
|
||||
// TODO: There is a dedicated helper for this.
|
||||
foreach (var item in items)
|
||||
{
|
||||
// ID Card
|
||||
@@ -155,13 +158,15 @@ public sealed class NewsSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
NewsArticle article = new NewsArticle
|
||||
var trimmedName = msg.Name.Trim();
|
||||
var trimmedContent = msg.Content.Trim();
|
||||
|
||||
var article = new NewsArticle
|
||||
{
|
||||
Author = authorName,
|
||||
Name = (msg.Name.Length <= 25 ? msg.Name.Trim() : $"{msg.Name.Trim().Substring(0, 25)}..."),
|
||||
Content = msg.Content,
|
||||
Name = trimmedName.Length <= MaxNameLength ? trimmedName : $"{trimmedName[..MaxNameLength]}...",
|
||||
Content = trimmedContent.Length <= MaxArticleLength ? trimmedContent : $"{trimmedContent[..MaxArticleLength]}...",
|
||||
ShareTime = _ticker.RoundDuration()
|
||||
|
||||
};
|
||||
|
||||
_audio.PlayPvs(component.ConfirmSound, uid);
|
||||
|
||||
Reference in New Issue
Block a user