From 02e35e070ed56bc6f295910c0e444bebccb2f82d Mon Sep 17 00:00:00 2001 From: JianMiau Date: Thu, 7 Dec 2023 11:11:52 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E6=96=B7=E7=B7=9A=E9=98=B2=E5=91=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/UI/Lobby/SlotList.tsx | 3 +++ src/modules/GameManager.ts | 2 ++ src/utils/setRPCData.ts | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/src/UI/Lobby/SlotList.tsx b/src/UI/Lobby/SlotList.tsx index 04b2bbc..aaf7531 100644 --- a/src/UI/Lobby/SlotList.tsx +++ b/src/UI/Lobby/SlotList.tsx @@ -7,6 +7,7 @@ import Image from "@/components/Image/Image"; import { useGameItems } from "@/context/GameItemsContext"; import { GameLaunchRequest, GameLeaveRequest, RpcGameLaunchResponse } from "@/define/Request/GameRequest"; import { SlotData } from "@/define/gameData"; +import GameManager from "@/modules/GameManager"; import { Button, Flex } from "antd"; import { useEffect, useState } from "react"; import SDGame from "./SDGame"; @@ -34,6 +35,7 @@ const SlotList = () => { return; } setIsGameIn(true); + GameManager.IsInGame = true; const url: string = resp.Data; setGameData({ ...gameData, @@ -55,6 +57,7 @@ const SlotList = () => { gameLeaveReq.Send(); setGameUrl(""); setIsGameIn(false); + GameManager.IsInGame = false; } useEffect(() => { diff --git a/src/modules/GameManager.ts b/src/modules/GameManager.ts index e06e1f0..4f1dc47 100644 --- a/src/modules/GameManager.ts +++ b/src/modules/GameManager.ts @@ -3,6 +3,8 @@ import SlotData from "./data/SlotData"; class GameManager { /** SlotData */ public readonly SlotData: SlotData = new SlotData(); + + public IsInGame: boolean = false; } export default new GameManager(); diff --git a/src/utils/setRPCData.ts b/src/utils/setRPCData.ts index 6e390ec..5359945 100644 --- a/src/utils/setRPCData.ts +++ b/src/utils/setRPCData.ts @@ -2,9 +2,14 @@ import CSMessage from "@/Common/Message/CSMessage"; import { INetResponse } from "@/Engine/CatanEngine/NetManagerV2/Core/INetResponse"; import { gameObj } from "@/context/GameItemsContext"; import { GameInfoRequest } from "@/define/Request/GameRequest"; +import GameManager from "@/modules/GameManager"; export function* gameSync(): IterableIterator { const { gameData, setGameData } = gameObj; + if (GameManager.IsInGame) { + // 不用同步資料,因為已經在遊戲中,所以不用同步資料。 + return; + } let req: GameInfoRequest = new GameInfoRequest(); yield req.SendAsync(); let resp: INetResponse = req.Result;