From 43bc95f570242872a111f294c4b446d23774371c Mon Sep 17 00:00:00 2001 From: wihn2021 Date: Mon, 14 Nov 2022 10:00:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A6=84=20refactor(logic.h=20&=20logic.cpp?= =?UTF-8?q?):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CAPI/API/src/logic.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/CAPI/API/src/logic.cpp b/CAPI/API/src/logic.cpp index 4dbf6c6..8acdcc4 100644 --- a/CAPI/API/src/logic.cpp +++ b/CAPI/API/src/logic.cpp @@ -20,31 +20,37 @@ Logic::Logic(THUAI6::PlayerType type, int64_t ID, THUAI6::ButcherType butcher, T bufferState = &state[1]; } -std::vector> Logic::GetButchers() const +std::vector> Logic::GetButchers() const { std::lock_guard lock(mtxState); - return currentState->butchers; + std::vector> temp; + temp.assign(currentState->butchers.begin(), currentState->butchers.end()); + return temp; } -std::vector> Logic::GetHumans() const +std::vector> Logic::GetHumans() const { std::lock_guard lock(mtxState); - return currentState->humans; + std::vector> temp; + temp.assign(currentState->humans.begin(), currentState->humans.end()); + return temp; } -std::vector> Logic::GetProps() const +std::vector> Logic::GetProps() const { std::lock_guard lock(mtxState); - return currentState->props; + std::vector> temp; + temp.assign(currentState->props.begin(), currentState->props.end()); + return temp; } -std::shared_ptr Logic::HumanGetSelfInfo() const +std::shared_ptr Logic::HumanGetSelfInfo() const { std::lock_guard lock(mtxState); return currentState->humanSelf; } -std::shared_ptr Logic::ButcherGetSelfInfo() const +std::shared_ptr Logic::ButcherGetSelfInfo() const { std::lock_guard lock(mtxState); return currentState->butcherSelf;