Fix a potential crash when cancelling capture

This commit is contained in:
Gustas
2025-03-15 08:11:14 +02:00
committed by Paul Chote
parent b565f0903a
commit b953f4a40d
2 changed files with 3 additions and 4 deletions

View File

@@ -152,7 +152,7 @@ namespace OpenRA.Mods.Common.Activities
void CancelCapture() void CancelCapture()
{ {
manager.CancelCapture(enterCaptureManager); manager.CancelCapture(enterActor, enterCaptureManager);
} }
} }
} }

View File

@@ -189,7 +189,7 @@ namespace OpenRA.Mods.Common.Traits
if (target != currentTarget) if (target != currentTarget)
{ {
if (currentTargetManager != null) if (currentTargetManager != null)
CancelCapture(currentTargetManager); CancelCapture(currentTarget, currentTargetManager);
targetManager.currentCaptors.Add(self); targetManager.currentCaptors.Add(self);
currentTarget = target; currentTarget = target;
@@ -239,12 +239,11 @@ namespace OpenRA.Mods.Common.Traits
/// This method revokes the capturing conditions on the captor and target /// This method revokes the capturing conditions on the captor and target
/// and resets any capturing progress. /// and resets any capturing progress.
/// </summary> /// </summary>
public void CancelCapture(CaptureManager targetManager) public void CancelCapture(Actor target, CaptureManager targetManager)
{ {
if (currentTarget == null) if (currentTarget == null)
return; return;
var target = targetManager.self;
foreach (var w in progressWatchers) foreach (var w in progressWatchers)
w.Update(self, self, target, 0, 0); w.Update(self, self, target, 0, 0);