From 8163db4f40152b6de90a1d64f42bde619af49d0b Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Sat, 27 May 2023 01:39:17 +0800 Subject: [PATCH] fix: :bug: lock the fixSpeed and orgCD --- .../GameClass/GameObj/Character/Character.Skill.cs | 2 +- .../GameObj/Character/Character.Student.cs | 13 +++++++++---- logic/GameClass/GameObj/Character/Character.cs | 12 ++++++++++-- logic/cmd/spectatorForLadder.cmd | 3 +-- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/logic/GameClass/GameObj/Character/Character.Skill.cs b/logic/GameClass/GameObj/Character/Character.Skill.cs index 7c80c68..f2d887e 100644 --- a/logic/GameClass/GameObj/Character/Character.Skill.cs +++ b/logic/GameClass/GameObj/Character/Character.Skill.cs @@ -11,7 +11,7 @@ namespace GameClass.GameObj private readonly IOccupation occupation; public IOccupation Occupation => occupation; - private Dictionary activeSkillDictionary = new(); + private readonly Dictionary activeSkillDictionary = new(); public Dictionary ActiveSkillDictionary => activeSkillDictionary; public ActiveSkill FindActiveSkill(ActiveSkillType activeSkillType) diff --git a/logic/GameClass/GameObj/Character/Character.Student.cs b/logic/GameClass/GameObj/Character/Character.Student.cs index 88e101b..d0a4902 100644 --- a/logic/GameClass/GameObj/Character/Character.Student.cs +++ b/logic/GameClass/GameObj/Character/Character.Student.cs @@ -7,16 +7,21 @@ namespace GameClass.GameObj { public class Student : Character { + private readonly object fixLock = new(); protected int fixSpeed; /// /// 修理电机速度 /// public int FixSpeed { - get => fixSpeed; + get + { + lock (fixLock) + return fixSpeed; + } set { - lock (gameObjLock) + lock (fixLock) { fixSpeed = value; } @@ -25,7 +30,7 @@ namespace GameClass.GameObj /// /// 原初修理电机速度 /// - public int OrgFixSpeed { get; protected set; } + protected readonly int orgFixSpeed; protected int treatSpeed = GameData.basicTreatSpeed; public int TreatSpeed @@ -122,7 +127,7 @@ namespace GameClass.GameObj public Student(XY initPos, int initRadius, CharacterType characterType) : base(initPos, initRadius, characterType) { - this.OrgFixSpeed = this.fixSpeed = ((IStudentType)Occupation).FixSpeed; + this.orgFixSpeed = this.fixSpeed = ((IStudentType)Occupation).FixSpeed; this.TreatSpeed = this.OrgTreatSpeed = ((IStudentType)Occupation).TreatSpeed; this.MaxGamingAddiction = ((IStudentType)Occupation).MaxGamingAddiction; } diff --git a/logic/GameClass/GameObj/Character/Character.cs b/logic/GameClass/GameObj/Character/Character.cs index e138769..3e6b937 100644 --- a/logic/GameClass/GameObj/Character/Character.cs +++ b/logic/GameClass/GameObj/Character/Character.cs @@ -31,7 +31,15 @@ namespace GameClass.GameObj } } } - public int OrgCD { get; protected set; } + private int orgCD; + public int OrgCD + { + get + { + lock (actionLock) + return orgCD; + } + } public readonly BulletType OriBulletOfPlayer; private BulletType bulletOfPlayer; @@ -49,7 +57,7 @@ namespace GameClass.GameObj lock (actionLock) { bulletOfPlayer = value; - cd = OrgCD = (BulletFactory.BulletCD(value)); + cd = orgCD = (BulletFactory.BulletCD(value)); Debugger.Output(this, string.Format("'s CD has been set to: {0}.", cd)); maxBulletNum = bulletNum = (BulletFactory.BulletNum(value)); } diff --git a/logic/cmd/spectatorForLadder.cmd b/logic/cmd/spectatorForLadder.cmd index d6cc7ae..d2dd4ac 100644 --- a/logic/cmd/spectatorForLadder.cmd +++ b/logic/cmd/spectatorForLadder.cmd @@ -1,3 +1,2 @@ @echo off - -start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --port 8891 --characterId 2087 --ip thuai6.eesast.com \ No newline at end of file +start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --port 8894 --characterID 123321123 --type 1 --occupation 1 --ip thuai6.eesast.com --cl \ No newline at end of file