fix: Fixes murder context getting lost (#2198)

This commit is contained in:
Kamron Batman 2025-05-25 20:43:59 -07:00 committed by GitHub
parent c5c647bf77
commit 902797bee0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View file

@ -79,11 +79,7 @@ public partial class MurderContext
if (_player.Kills > 0)
{
var timeUntilLong = now + (LongTermElapse - gameTime);
if (_nextElapse > timeUntilLong)
{
_nextElapse = timeUntilLong;
}
_nextElapse = Utility.Min(_nextElapse, now + (LongTermElapse - gameTime));
}
return _nextElapse != DateTime.MaxValue;

View file

@ -101,9 +101,17 @@ public class PlayerMurderSystem : GenericPersistence
private static void OnDisconnected(Mobile m)
{
if (m is PlayerMobile pm && _murderContexts.Remove(pm, out var context))
if (m is not PlayerMobile pm || !_murderContexts.TryGetValue(pm, out var context))
{
_contextTerms.Remove(context);
return;
}
_contextTerms.Remove(context);
UpdateMurderContext(context);
if (pm.Kills <= 0 && context.ShortTermMurders <= 0)
{
_murderContexts.Remove(pm);
}
}
@ -173,13 +181,13 @@ public class PlayerMurderSystem : GenericPersistence
context.ShortTermMurders++;
player.Kills++;
context.ResetKillTime();
UpdateMurderContext(context);
}
private static void UpdateMurderContext(MurderContext context)
{
var player = context.Player;
context.ResetKillTime();
if (!context.CheckStart())
{