From e253333cfa5419a44fd96b85ce4180e51be9f7db Mon Sep 17 00:00:00 2001 From: Shawqeem <1004837646@qq.com> Date: Tue, 16 May 2023 00:57:11 +0800 Subject: [PATCH 1/2] fix: :bug: fix the bug that the mapMessage cannot be received correctly when a spectator joins fix the bug that the mapMessage cannot be received correctly when a spectator joins. --- logic/Client/MainWindow.xaml.cs | 19 ++++++++++++++++--- logic/cmd/gameServerAndClient.cmd | 7 ------- logic/cmd/spectatorForDebug.cmd | 4 ++++ .../{playback.cmd => spectatorForLadder.cmd} | 0 logic/cmd/video.cmd | 4 ---- 5 files changed, 20 insertions(+), 14 deletions(-) delete mode 100644 logic/cmd/gameServerAndClient.cmd create mode 100644 logic/cmd/spectatorForDebug.cmd rename logic/cmd/{playback.cmd => spectatorForLadder.cmd} (100%) delete mode 100644 logic/cmd/video.cmd diff --git a/logic/Client/MainWindow.xaml.cs b/logic/Client/MainWindow.xaml.cs index a676f8f..ebf837f 100644 --- a/logic/Client/MainWindow.xaml.cs +++ b/logic/Client/MainWindow.xaml.cs @@ -482,10 +482,11 @@ namespace Client listOfHiddenGate.Clear(); listOfGate.Clear(); MessageToClient content = responseStream.ResponseStream.Current; + MessageOfMap mapMessage = new MessageOfMap(); + bool mapMessageExist = false; switch (content.GameState) { case GameState.GameStart: - MessageOfMap mapMessage = new MessageOfMap(); foreach (var obj in content.ObjMessage) { switch (obj.MessageOfObjCase) @@ -530,11 +531,12 @@ namespace Client break; } } + listOfAll.Add(content.AllMessage); + countList.Clear(); countList.Add(listOfClassroom.Count); countList.Add(listOfDoor.Count); countList.Add(listOfChest.Count); countList.Add(listOfGate.Count); - listOfAll.Add(content.AllMessage); GetMap(mapMessage); break; case GameState.GameRunning: @@ -581,11 +583,22 @@ namespace Client listOfHiddenGate.Add(obj.HiddenGateMessage); break; case MessageOfObj.MessageOfObjOneofCase.MapMessage: - GetMap(obj.MapMessage); + mapMessage = obj.MapMessage; + mapMessageExist = true;//只有中间加入游戏的旁观者着一种可能,使得在这里收到地图 break; } } listOfAll.Add(content.AllMessage); + if (mapMessageExist) + { + countList.Clear(); + countList.Add(listOfClassroom.Count); + countList.Add(listOfDoor.Count); + countList.Add(listOfChest.Count); + countList.Add(listOfGate.Count); + GetMap(mapMessage); + mapMessageExist = false; + } break; case GameState.GameEnd: MessageBox.Show("Game Over!"); diff --git a/logic/cmd/gameServerAndClient.cmd b/logic/cmd/gameServerAndClient.cmd deleted file mode 100644 index 71f90c7..0000000 --- a/logic/cmd/gameServerAndClient.cmd +++ /dev/null @@ -1,7 +0,0 @@ -@echo off - -start cmd /k ..\Server\bin\Debug\net6.0\Server.exe --ip 0.0.0.0 --port 8888 --studentCount 4 --trickerCount 1 --gameTimeInSecond 600 --fileName test - -ping -n 2 127.0.0.1 > NUL - -start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --port 8888 --characterID 114514 --type 0 --occupation 1 \ No newline at end of file diff --git a/logic/cmd/spectatorForDebug.cmd b/logic/cmd/spectatorForDebug.cmd new file mode 100644 index 0000000..45fa401 --- /dev/null +++ b/logic/cmd/spectatorForDebug.cmd @@ -0,0 +1,4 @@ +@echo off + + +start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --port 8888 --characterID 2030 \ No newline at end of file diff --git a/logic/cmd/playback.cmd b/logic/cmd/spectatorForLadder.cmd similarity index 100% rename from logic/cmd/playback.cmd rename to logic/cmd/spectatorForLadder.cmd diff --git a/logic/cmd/video.cmd b/logic/cmd/video.cmd deleted file mode 100644 index 0518998..0000000 --- a/logic/cmd/video.cmd +++ /dev/null @@ -1,4 +0,0 @@ -@echo off - - -start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --ip thuai6.eesast.com --port 8889 --characterID 2030 \ No newline at end of file From f2181cbd6a457c07f560a38c42599f890c7592fa Mon Sep 17 00:00:00 2001 From: Timothy Liu Date: Tue, 16 May 2023 01:18:38 +0800 Subject: [PATCH 2/2] style --- logic/cmd/spectatorForDebug.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logic/cmd/spectatorForDebug.cmd b/logic/cmd/spectatorForDebug.cmd index 45fa401..a4445e4 100644 --- a/logic/cmd/spectatorForDebug.cmd +++ b/logic/cmd/spectatorForDebug.cmd @@ -1,4 +1,4 @@ @echo off -start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --port 8888 --characterID 2030 \ No newline at end of file +start cmd /k ..\Client\bin\Debug\net6.0-windows\Client.exe --port 8888 --characterID 2030