From 83134bf964d7449fb347d53c2113ab47389006b9 Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Sat, 27 May 2023 02:25:21 +0800 Subject: [PATCH] fix: :ambulance: fix the bug about locking when treating --- logic/Gaming/ActionManager.cs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/logic/Gaming/ActionManager.cs b/logic/Gaming/ActionManager.cs index 522ac2f4..89d930e7 100644 --- a/logic/Gaming/ActionManager.cs +++ b/logic/Gaming/ActionManager.cs @@ -106,11 +106,7 @@ public bool Fix(Student player)// 自动检查有无发电机可修 gameMap.AddNumOfRepairedGenerators(); if (generatorForFix.DegreeOfRepair == GameData.degreeOfFixedGenerator) { - lock (player.ActionLock) - { - if (stateNum == player.StateNum) - player.SetPlayerState(RunningStateType.Null); - } + player.ResetPlayerState(stateNum); return false; } return true; @@ -211,11 +207,7 @@ public bool Treat(Student player, Student? playerTreated = null) long stateNum = player.SetPlayerState(RunningStateType.Waiting, PlayerStateType.Treating); if (stateNum == -1) { - lock (playerTreated.ActionLock) - { - if (playerTreated.StateNum == stateNumTreated) - player.SetPlayerStateNaturally(); - } + playerTreated.ResetPlayerState(stateNumTreated); return false; } @@ -227,11 +219,7 @@ public bool Treat(Student player, Student? playerTreated = null) if (!player.StartThread(stateNum, RunningStateType.RunningActively)) { player.ThreadNum.Release(); - lock (playerTreated.ActionLock) - { - if (playerTreated.StateNum == stateNumTreated) - playerTreated.SetPlayerStateNaturally(); - } + playerTreated.ResetPlayerState(stateNumTreated); return; } @@ -239,11 +227,7 @@ public bool Treat(Student player, Student? playerTreated = null) if (!playerTreated.StartThread(stateNum, RunningStateType.RunningActively)) { playerTreated.ThreadNum.Release(); - lock (player.ActionLock) - { - if (player.StateNum == stateNum) - player.SetPlayerStateNaturally(); - } + player.ResetPlayerState(stateNum); player.ThreadNum.Release(); return; }