Set max length of battlecry to 12 chars. (#16958)

* Set max length of battlecry to 12 chars. Deleted a duplicate file.

* Also cleanup some leftovers
This commit is contained in:
HerCoyote23
2023-05-30 10:57:53 -07:00
committed by GitHub
parent 159a0a8eb2
commit d1a0f5f09e
4 changed files with 19 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
using Content.Server.Administration.Logs;
using Content.Shared.Speech.Components;
using Content.Shared.Weapons.Melee;
using Content.Shared.Speech.EntitySystems;
using Content.Shared.Database;
@@ -22,10 +22,15 @@ public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
private void OnBattlecryChanged(EntityUid uid, MeleeSpeechComponent comp, MeleeSpeechBattlecryChangedMessage args)
{
if (!TryComp<MeleeSpeechComponent>(uid, out var meleeSpeechUser))
if (!TryComp<MeleeSpeechComponent>(uid, out var meleeSpeechUser))
return;
TryChangeBattlecry(uid, args.Battlecry, meleeSpeechUser);
string battlecry = args.Battlecry;
if (battlecry.Length > comp.MaxBattlecryLength)
battlecry = battlecry[..comp.MaxBattlecryLength];
TryChangeBattlecry(uid, battlecry, meleeSpeechUser);
}
@@ -41,12 +46,14 @@ public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
public bool TryChangeBattlecry(EntityUid uid, string? battlecry, MeleeSpeechComponent? meleeSpeechComp = null)
{
if (!Resolve(uid, ref meleeSpeechComp))
if (!Resolve(uid, ref meleeSpeechComp))
return false;
if (!string.IsNullOrWhiteSpace(battlecry))
{
battlecry = battlecry.Trim();
}
else
{
@@ -56,6 +63,9 @@ public sealed class MeleeSpeechSystem : SharedMeleeSpeechSystem
if (meleeSpeechComp.Battlecry == battlecry)
return true;
meleeSpeechComp.Battlecry = battlecry;
Dirty(meleeSpeechComp);