From 0cb40722606df072e3a8c11b44ff87a449bc1c3e Mon Sep 17 00:00:00 2001 From: shangfengh <3495281661@qq.com> Date: Fri, 26 May 2023 21:23:01 +0800 Subject: [PATCH] fix: :bug: change Environment.TickCount64 to Environment.TickCount --- logic/GameClass/GameObj/Map/Chest.cs | 6 +++--- logic/GameClass/GameObj/Map/Door.cs | 8 ++++---- logic/GameClass/GameObj/Map/Doorway.cs | 10 +++++----- logic/GameClass/GameObj/Map/MapGameTimer.cs | 6 +++--- logic/Gaming/AttackManager.cs | 2 +- .../SkillManager/SkillManager.ActiveSkill.cs | 2 +- .../SkillManager/SkillManager.PassiveSkill.cs | 2 +- logic/Preparation/Interface/IDoorway.cs | 2 +- logic/Preparation/Interface/ISkill.cs | 10 +++++----- logic/Server/CopyInfo.cs | 18 +++++++++--------- logic/Server/GameServer.cs | 2 +- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/logic/GameClass/GameObj/Map/Chest.cs b/logic/GameClass/GameObj/Map/Chest.cs index 03866ed..1d86d3d 100644 --- a/logic/GameClass/GameObj/Map/Chest.cs +++ b/logic/GameClass/GameObj/Map/Chest.cs @@ -19,8 +19,8 @@ namespace GameClass.GameObj private readonly Gadget[] propInChest = new Gadget[GameData.maxNumOfPropInChest] { new NullProp(), new NullProp() }; public Gadget[] PropInChest => propInChest; - private int openStartTime = 0; - public int OpenStartTime => openStartTime; + private long openStartTime = 0; + public long OpenStartTime => openStartTime; private Character? whoOpen = null; public Character? WhoOpen => whoOpen; public bool Open(Character character) @@ -28,7 +28,7 @@ namespace GameClass.GameObj lock (GameObjReaderWriterLock) { if (whoOpen != null) return false; - openStartTime = Environment.TickCount; + openStartTime = Environment.TickCount64; whoOpen = character; } return true; diff --git a/logic/GameClass/GameObj/Map/Door.cs b/logic/GameClass/GameObj/Map/Door.cs index bc7eaaa..c4c6527 100644 --- a/logic/GameClass/GameObj/Map/Door.cs +++ b/logic/GameClass/GameObj/Map/Door.cs @@ -70,8 +70,8 @@ namespace GameClass.GameObj } } - private int openStartTime = 0; - public int OpenStartTime + private long openStartTime = 0; + public long OpenStartTime { get { @@ -86,7 +86,7 @@ namespace GameClass.GameObj { if (isOpen) return false; if (whoLockOrOpen != null) return false; - openStartTime = Environment.TickCount; + openStartTime = Environment.TickCount64; whoLockOrOpen = character; return true; } @@ -97,7 +97,7 @@ namespace GameClass.GameObj { if (whoLockOrOpen != null) { - if ((Environment.TickCount - openStartTime) >= GameData.degreeOfLockingOrOpeningTheDoor / whoLockOrOpen.SpeedOfOpeningOrLocking) + if ((Environment.TickCount64 - openStartTime) >= GameData.degreeOfLockingOrOpeningTheDoor / whoLockOrOpen.SpeedOfOpeningOrLocking) isOpen = true; whoLockOrOpen = null; } diff --git a/logic/GameClass/GameObj/Map/Doorway.cs b/logic/GameClass/GameObj/Map/Doorway.cs index efe4374..1373fd8 100644 --- a/logic/GameClass/GameObj/Map/Doorway.cs +++ b/logic/GameClass/GameObj/Map/Doorway.cs @@ -39,8 +39,8 @@ namespace GameClass.GameObj } } - private int openStartTime = 0; - public int OpenStartTime + private long openStartTime = 0; + public long OpenStartTime { get { @@ -53,7 +53,7 @@ namespace GameClass.GameObj lock (gameObjLock) { if (!powerSupply || openStartTime > 0) return false; - openStartTime = Environment.TickCount; + openStartTime = Environment.TickCount64; return true; } } @@ -62,14 +62,14 @@ namespace GameClass.GameObj { lock (gameObjLock) { - if (Environment.TickCount - openStartTime + openDegree >= GameData.degreeOfOpenedDoorway) + if (Environment.TickCount64 - openStartTime + openDegree >= GameData.degreeOfOpenedDoorway) { openDegree = GameData.degreeOfOpenedDoorway; return true; } else { - openDegree = Environment.TickCount - openStartTime + openDegree; + openDegree = (int)(Environment.TickCount64 - openStartTime) + openDegree; openStartTime = 0; return false; } diff --git a/logic/GameClass/GameObj/Map/MapGameTimer.cs b/logic/GameClass/GameObj/Map/MapGameTimer.cs index 26760b6..c8cb262 100644 --- a/logic/GameClass/GameObj/Map/MapGameTimer.cs +++ b/logic/GameClass/GameObj/Map/MapGameTimer.cs @@ -12,8 +12,8 @@ namespace GameClass.GameObj public class GameTimer : ITimer { - private int startTime; - public int nowTime() => Environment.TickCount - startTime; + private long startTime; + public int nowTime() => (int)(Environment.TickCount64 - startTime); private bool isGaming = false; public bool IsGaming @@ -35,7 +35,7 @@ namespace GameClass.GameObj if (isGaming) return false; isGaming = true; - startTime = Environment.TickCount; + startTime = Environment.TickCount64; } Thread.Sleep(timeInMilliseconds); isGaming = false; diff --git a/logic/Gaming/AttackManager.cs b/logic/Gaming/AttackManager.cs index cd3402d..930e3b1 100644 --- a/logic/Gaming/AttackManager.cs +++ b/logic/Gaming/AttackManager.cs @@ -30,7 +30,7 @@ namespace Gaming }, EndMove: obj => { - Debugger.Output(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount); + Debugger.Output(obj, " end move at " + obj.Position.ToString() + " At time: " + Environment.TickCount64); if (obj.CanMove && ((Bullet)obj).TypeOfBullet != BulletType.JumpyDumpty) BulletBomb((Bullet)obj, null); obj.ReSetCanMove(false); diff --git a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs index e6554f3..dde4cae 100644 --- a/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs +++ b/logic/Gaming/SkillManager/SkillManager.ActiveSkill.cs @@ -162,7 +162,7 @@ namespace Gaming { Character? whoAttacked = gameMap.FindPlayerInPlayerID(AttackID); if (whoAttacked == null || whoAttacked.NoHp()) - return false; + return false; ActiveSkill activeSkill = player.FindActiveSkill(ActiveSkillType.SparksNSplash); return ActiveSkillEffect(activeSkill, player, () => diff --git a/logic/Gaming/SkillManager/SkillManager.PassiveSkill.cs b/logic/Gaming/SkillManager/SkillManager.PassiveSkill.cs index 0fe1925..3cf26ab 100644 --- a/logic/Gaming/SkillManager/SkillManager.PassiveSkill.cs +++ b/logic/Gaming/SkillManager/SkillManager.PassiveSkill.cs @@ -55,7 +55,7 @@ namespace Gaming // 被动技能开局时就释放,持续到游戏结束 } public void Lucky(Character player) { - player.PropInventory[0] = PropFactory.GetConsumables((PropType)((4 * Environment.TickCount) % 5 + 4), new XY(0, 0)); + player.PropInventory[0] = PropFactory.GetConsumables((PropType)((4 * Environment.TickCount64) % 5 + 4), new XY(0, 0)); } } } diff --git a/logic/Preparation/Interface/IDoorway.cs b/logic/Preparation/Interface/IDoorway.cs index e4fe0cc..b48be75 100644 --- a/logic/Preparation/Interface/IDoorway.cs +++ b/logic/Preparation/Interface/IDoorway.cs @@ -4,7 +4,7 @@ namespace Preparation.Interface { public interface IDoorway : IGameObj { - public int OpenStartTime { get; } + public long OpenStartTime { get; } public int OpenDegree { get; } public bool StopOpenning(); public bool TryToOpen(); diff --git a/logic/Preparation/Interface/ISkill.cs b/logic/Preparation/Interface/ISkill.cs index 7f7934a..7671932 100644 --- a/logic/Preparation/Interface/ISkill.cs +++ b/logic/Preparation/Interface/ISkill.cs @@ -30,22 +30,22 @@ namespace Preparation.Interface private readonly object skillLock = new(); public object SkillLock => skillLock; - private int openStartTime = 0; - public int OpenStartTime + private long startTime = 0; + public long StartTime { get { lock (skillLock) - return openStartTime; + return startTime; } } public bool StartSkill() { lock (skillLock) { - if (Environment.TickCount - openStartTime >= SkillCD) + if (Environment.TickCount64 - startTime >= SkillCD) { - openStartTime = Environment.TickCount; + startTime = Environment.TickCount64; return true; } } diff --git a/logic/Server/CopyInfo.cs b/logic/Server/CopyInfo.cs index 94ba0b0..9644826 100644 --- a/logic/Server/CopyInfo.cs +++ b/logic/Server/CopyInfo.cs @@ -8,7 +8,7 @@ namespace Server public static class CopyInfo { - public static MessageOfObj? Auto(GameObj gameObj, int time) + public static MessageOfObj? Auto(GameObj gameObj, long time) { switch (gameObj.Type) { @@ -49,7 +49,7 @@ namespace Server return objMsg; } - private static MessageOfObj? Student(Student player, int time) + private static MessageOfObj? Student(Student player, long time) { if (player.IsGhost()) return null; MessageOfObj msg = new() @@ -82,7 +82,7 @@ namespace Server foreach (var keyValue in player.ActiveSkillDictionary) { - int progress = (keyValue.Value.OpenStartTime - time) + keyValue.Value.SkillCD; + int progress = (int)((keyValue.Value.StartTime - time) + keyValue.Value.SkillCD); msg.StudentMessage.TimeUntilSkillAvailable.Add(progress < 0 ? 0 : progress); } for (int i = 0; i < GameData.maxNumOfSkill - player.ActiveSkillDictionary.Count; ++i) @@ -100,7 +100,7 @@ namespace Server return msg; } - private static MessageOfObj? Tricker(Character player, int time) + private static MessageOfObj? Tricker(Character player, long time) { if (!player.IsGhost()) return null; MessageOfObj msg = new() @@ -126,7 +126,7 @@ namespace Server }; foreach (var keyValue in player.ActiveSkillDictionary) { - int progress = keyValue.Value.SkillCD + (keyValue.Value.OpenStartTime - time); + int progress = (int)(keyValue.Value.SkillCD + (keyValue.Value.StartTime - time)); msg.TrickerMessage.TimeUntilSkillAvailable.Add(progress < 0 ? 0 : progress); } for (int i = 0; i < GameData.maxNumOfSkill - player.ActiveSkillDictionary.Count; ++i) @@ -225,7 +225,7 @@ namespace Server }; return msg; } - private static MessageOfObj Gate(Doorway doorway, int time) + private static MessageOfObj Gate(Doorway doorway, long time) { MessageOfObj msg = new() { @@ -235,7 +235,7 @@ namespace Server Y = doorway.Position.y } }; - int progress = ((doorway.OpenStartTime > 0) ? (time - doorway.OpenStartTime) : 0) + doorway.OpenDegree; + int progress = ((doorway.OpenStartTime > 0) ? ((int)(time - doorway.OpenStartTime)) : 0) + doorway.OpenDegree; msg.GateMessage.Progress = (progress > GameData.degreeOfOpenedDoorway) ? GameData.degreeOfOpenedDoorway : progress; return msg; } @@ -267,7 +267,7 @@ namespace Server }; return msg; } - private static MessageOfObj Chest(Chest chest, int time) + private static MessageOfObj Chest(Chest chest, long time) { MessageOfObj msg = new() { @@ -277,7 +277,7 @@ namespace Server Y = chest.Position.y } }; - int progress = (chest.WhoOpen != null) ? ((time - chest.OpenStartTime) * chest.WhoOpen.SpeedOfOpenChest) : 0; + int progress = (chest.WhoOpen != null) ? (((int)(time - chest.OpenStartTime)) * chest.WhoOpen.SpeedOfOpenChest) : 0; msg.ChestMessage.Progress = (progress > GameData.degreeOfOpenedChest) ? GameData.degreeOfOpenedChest : progress; return msg; } diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index 3e920d1..68e65c6 100644 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -133,7 +133,7 @@ namespace Server currentGameInfo.ObjMessage.Add(currentMapMsg); IsSpectatorJoin = false; } - int time = Environment.TickCount; + long time = Environment.TickCount64; foreach (GameObj gameObj in gameObjList) { MessageOfObj? msg = CopyInfo.Auto(gameObj, time);