fix: lock on history when modifying it
This commit is contained in:
parent
02099dd46b
commit
69517f10d1
@ -84,6 +84,8 @@ namespace PeepingTom {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.previousMutex.WaitOne();
|
||||||
|
|
||||||
foreach (PlayerCharacter targeter in targeting) {
|
foreach (PlayerCharacter targeter in targeting) {
|
||||||
// add the targeter to the previous list
|
// add the targeter to the previous list
|
||||||
if (this.previousTargeters.Any(old => old.ActorId == targeter.ActorId)) {
|
if (this.previousTargeters.Any(old => old.ActorId == targeter.ActorId)) {
|
||||||
@ -96,6 +98,8 @@ namespace PeepingTom {
|
|||||||
while (this.previousTargeters.Where(old => targeting.All(actor => actor.ActorId != old.ActorId)).Count() > this.plugin.Config.NumHistory) {
|
while (this.previousTargeters.Where(old => targeting.All(actor => actor.ActorId != old.ActorId)).Count() > this.plugin.Config.NumHistory) {
|
||||||
this.previousTargeters.RemoveAt(this.previousTargeters.Count - 1);
|
this.previousTargeters.RemoveAt(this.previousTargeters.Count - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.previousMutex.ReleaseMutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayerCharacter[] GetTargeting(Actor player) {
|
private PlayerCharacter[] GetTargeting(Actor player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user