Skip to content

Commit

Permalink
Fix Moodlet Popup Spam (#948)
Browse files Browse the repository at this point in the history
# Description

This fixes a bug whereby smoking a cigarette spams your screen with the
funny "I feel as if I have been standing my entire life and I just sat
down" message. Now moodlet popups only play once when the moodlet is
obtained, rather than being constantly spammed. I have tested this
ingame to verify that it works correctly.

# Changelog

:cl:
- fix: Smoking cigarettes or drinking loto oil will no longer spam
moodlet popup messages.
  • Loading branch information
VMSolidus committed Sep 28, 2024
1 parent 320a62c commit 12b4fd2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Content.Server/Mood/MoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,15 @@ private void ApplyEffect(EntityUid uid, MoodComponent component, MoodEffectProto
if (!_prototypeManager.TryIndex<MoodEffectPrototype>(oldPrototypeId, out var oldPrototype))
return;

if (prototype.ID != oldPrototype.ID)
{
// Don't send the moodlet popup if we already have the moodlet.
if (!component.CategorisedEffects.ContainsValue(prototype.ID))
SendEffectText(uid, prototype);

if (prototype.ID != oldPrototype.ID)
component.CategorisedEffects[prototype.Category] = prototype.ID;
}
}
else
{
component.CategorisedEffects.Add(prototype.Category, prototype.ID);
}

if (prototype.Timeout != 0)
Timer.Spawn(TimeSpan.FromSeconds(prototype.Timeout), () => RemoveTimedOutEffect(uid, prototype.ID, prototype.Category));
Expand All @@ -146,7 +145,10 @@ private void ApplyEffect(EntityUid uid, MoodComponent component, MoodEffectProto
if (moodChange == 0)
return;

SendEffectText(uid, prototype);
// Don't send the moodlet popup if we already have the moodlet.
if (!component.UncategorisedEffects.ContainsKey(prototype.ID))
SendEffectText(uid, prototype);

component.UncategorisedEffects.Add(prototype.ID, moodChange);

if (prototype.Timeout != 0)
Expand Down

0 comments on commit 12b4fd2

Please sign in to comment.