From ba6823e71d04c517b1f420d11e5ded4c169fb14c Mon Sep 17 00:00:00 2001 From: DragonAura <32223554+DragonAura@users.noreply.github.com> Date: Wed, 8 May 2024 10:22:24 +0800 Subject: [PATCH 1/3] fix: add cpp retry --- CAPI/cpp/API/src/Communication.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CAPI/cpp/API/src/Communication.cpp b/CAPI/cpp/API/src/Communication.cpp index d1cb86b5..45100a8e 100755 --- a/CAPI/cpp/API/src/Communication.cpp +++ b/CAPI/cpp/API/src/Communication.cpp @@ -227,14 +227,18 @@ bool Communication::Recycle(int32_t playerID, int32_t teamID) bool Communication::TryConnection(int32_t playerID, int32_t teamID) { - protobuf::BoolRes reply; - ClientContext context; + constexpr int maxRetryNum = 10; auto request = THUAI72Proto::THUAI72ProtobufIDMsg(playerID, teamID); - auto status = THUAI7Stub->TryConnection(&context, request, &reply); - if (status.ok()) - return true; - else - return false; + for (int retryNum = 0; retryNum < maxRetryNum; retryNum++) + { + protobuf::BoolRes reply; + ClientContext context; + std::this_thread::sleep_for(std::chrono::milliseconds(2000)); + auto status = THUAI7Stub->TryConnection(&context, request, &reply); + if (status.ok()) + return true; + } + return false; } void Communication::AddPlayer(int32_t playerID, int32_t teamID, THUAI7::ShipType ShipType) @@ -274,4 +278,4 @@ protobuf::MessageToClient Communication::GetMessage2Client() { return haveNewMessage; }); haveNewMessage = false; return message2Client; -} \ No newline at end of file +} From ec86ecf2fb5b96b47e115eba6bbf8bd390b14944 Mon Sep 17 00:00:00 2001 From: DragonAura <32223554+DragonAura@users.noreply.github.com> Date: Wed, 8 May 2024 10:47:05 +0800 Subject: [PATCH 2/3] fix: add python retry --- CAPI/python/PyAPI/Communication.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/CAPI/python/PyAPI/Communication.py b/CAPI/python/PyAPI/Communication.py index d5c785fe..3a997cc9 100644 --- a/CAPI/python/PyAPI/Communication.py +++ b/CAPI/python/PyAPI/Communication.py @@ -235,14 +235,18 @@ def BuildShip( return buildResult.act_success def TryConnection(self, playerID: int, teamID: int) -> bool: - try: - tryResult: Message2Clients.BoolRes = self.__THUAI7Stub.TryConnection( - THUAI72Proto.THUAI72ProtobufIDMsg(playerID, teamID) - ) - except grpc.RpcError: - return False - else: - return tryResult.act_success + maxRetryNum: int = 10 + for _ in range(maxRetryNum): + try: + time.sleep(1) + tryResult: Message2Clients.BoolRes = self.__THUAI7Stub.TryConnection( + THUAI72Proto.THUAI72ProtobufIDMsg(playerID, teamID) + ) + except grpc.RpcError: + continue + else: + return tryResult.act_success + return False def GetMessage2Client(self) -> Message2Clients.MessageToClient: with self.__cvMessage: From 95a2f6468e230a377899ba19c3976a2f28b72b4c Mon Sep 17 00:00:00 2001 From: GuoWQ222 Date: Wed, 8 May 2024 16:06:40 +0800 Subject: [PATCH 3/3] fix: --- logic/Server/GameServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs index 82aa7286..aec7d444 100755 --- a/logic/Server/GameServer.cs +++ b/logic/Server/GameServer.cs @@ -129,7 +129,6 @@ protected void SendGameResult(int[] scores, bool crashed) // 天梯的 Server protected double[] PullScore(double[] scores) { - string? url2 = Environment.GetEnvironmentVariable("SCORE_URL"); if (url2 != null) { @@ -144,6 +143,8 @@ protected double[] PullScore(double[] scores) else { double[] final = LadderCalculate(org, scores); + final[0] -= org[0]; + final[1] -= org[1]; return final; } }