From fbd7a5112e5203af65208c9e8c6097300959e30f Mon Sep 17 00:00:00 2001 From: Metroid_Skittles Date: Sat, 7 Feb 2026 08:40:15 +0100 Subject: [PATCH] Update torchlight_changes_unloze/torchlight3/Torchlight/AudioManager.py --- .../torchlight3/Torchlight/AudioManager.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/torchlight_changes_unloze/torchlight3/Torchlight/AudioManager.py b/torchlight_changes_unloze/torchlight3/Torchlight/AudioManager.py index bfd2d86..7224088 100755 --- a/torchlight_changes_unloze/torchlight3/Torchlight/AudioManager.py +++ b/torchlight_changes_unloze/torchlight3/Torchlight/AudioManager.py @@ -44,6 +44,8 @@ class AudioPlayerFactory(): class AntiSpam(): + GLOBAL_PLAY_TIME_IMMUNITY_LEVEL = 10 + def __init__(self, master): self.Logger = logging.getLogger(__class__.__name__) self.Master = master @@ -52,6 +54,9 @@ class AntiSpam(): self.LastClips = dict() self.DisabledTime = None + def _counts_toward_global_play_time(self, level): + return level < self.GLOBAL_PLAY_TIME_IMMUNITY_LEVEL + def CheckAntiSpam(self, player): if self.DisabledTime and self.DisabledTime > self.Torchlight().Master.Loop.time() and \ not (player.Access and player.Access["level"] >= self.Torchlight().Config["AntiSpam"]["ImmunityLevel"]): @@ -91,6 +96,9 @@ class AntiSpam(): self.LastClips.clear() def OnPlay(self, clip): + if not self._counts_toward_global_play_time(clip.Level): + return + Now = self.Torchlight().Master.Loop.time() self.LastClips[clip] = dict({"timestamp": Now, "duration": 0.0, "dominant": False, "active": True, "last_update_realtime": time.time()}) @@ -103,6 +111,9 @@ class AntiSpam(): self.LastClips[clip]["dominant"] = not HasDominant def OnStop(self, clip): + if not self._counts_toward_global_play_time(clip.Level): + return + if clip not in self.LastClips: return @@ -117,6 +128,9 @@ class AntiSpam(): self.LastClips[clip]["dominant"] = False def OnUpdate(self, clip, old_position, new_position): + if not self._counts_toward_global_play_time(clip.Level): + return + if clip not in self.LastClips: if self.Logger.isEnabledFor(logging.DEBUG): self.Logger.debug( @@ -305,7 +319,11 @@ class AudioManager(): return None self.AudioClips.append(Clip) - if not player.Access or player.Access["level"] < self.Torchlight().Config["AntiSpam"]["ImmunityLevel"]: + anti_spam_track_ceiling = min( + self.Torchlight().Config["AntiSpam"]["ImmunityLevel"], + self.AntiSpam.GLOBAL_PLAY_TIME_IMMUNITY_LEVEL, + ) + if not player.Access or player.Access["level"] < anti_spam_track_ceiling: Clip.AudioPlayer.AddCallback("Play", lambda *args: self.AntiSpam.OnPlay(Clip, *args)) Clip.AudioPlayer.AddCallback("Stop", lambda *args: self.AntiSpam.OnStop(Clip, *args)) Clip.AudioPlayer.AddCallback("Update", lambda *args: self.AntiSpam.OnUpdate(Clip, *args))