feat(CAPI): ✨ add binary send message
tags/0.1.0
| @@ -61,7 +61,7 @@ public: | |||||
| virtual bool UseProp(THUAI6::PropType prop) = 0; | virtual bool UseProp(THUAI6::PropType prop) = 0; | ||||
| virtual bool ThrowProp(THUAI6::PropType prop) = 0; | virtual bool ThrowProp(THUAI6::PropType prop) = 0; | ||||
| virtual bool UseSkill(int32_t skillID) = 0; | virtual bool UseSkill(int32_t skillID) = 0; | ||||
| virtual bool SendMessage(int64_t toID, std::string message) = 0; | |||||
| virtual bool SendMessage(int64_t toID, std::string message, bool binary) = 0; | |||||
| virtual bool HaveMessage() = 0; | virtual bool HaveMessage() = 0; | ||||
| virtual std::pair<int64_t, std::string> GetMessage() = 0; | virtual std::pair<int64_t, std::string> GetMessage() = 0; | ||||
| @@ -119,7 +119,8 @@ public: | |||||
| virtual std::future<bool> EndAllAction() = 0; | virtual std::future<bool> EndAllAction() = 0; | ||||
| // 发送信息、接受信息,注意收消息时无消息则返回nullopt | // 发送信息、接受信息,注意收消息时无消息则返回nullopt | ||||
| virtual std::future<bool> SendMessage(int64_t, std::string) = 0; | |||||
| virtual std::future<bool> SendTextMessage(int64_t, std::string) = 0; | |||||
| virtual std::future<bool> SendBinaryMessage(int64_t, std::string) = 0; | |||||
| [[nodiscard]] virtual bool HaveMessage() = 0; | [[nodiscard]] virtual bool HaveMessage() = 0; | ||||
| [[nodiscard]] virtual std::pair<int64_t, std::string> GetMessage() = 0; | [[nodiscard]] virtual std::pair<int64_t, std::string> GetMessage() = 0; | ||||
| @@ -246,7 +247,8 @@ public: | |||||
| std::future<bool> StartOpenChest() override; | std::future<bool> StartOpenChest() override; | ||||
| std::future<bool> EndAllAction() override; | std::future<bool> EndAllAction() override; | ||||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||||
| [[nodiscard]] bool HaveMessage() override; | [[nodiscard]] bool HaveMessage() override; | ||||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | ||||
| @@ -336,7 +338,8 @@ public: | |||||
| std::future<bool> StartOpenChest() override; | std::future<bool> StartOpenChest() override; | ||||
| std::future<bool> EndAllAction() override; | std::future<bool> EndAllAction() override; | ||||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||||
| [[nodiscard]] bool HaveMessage() override; | [[nodiscard]] bool HaveMessage() override; | ||||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | ||||
| @@ -418,7 +421,8 @@ public: | |||||
| std::future<bool> StartOpenChest() override; | std::future<bool> StartOpenChest() override; | ||||
| std::future<bool> EndAllAction() override; | std::future<bool> EndAllAction() override; | ||||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||||
| [[nodiscard]] bool HaveMessage() override; | [[nodiscard]] bool HaveMessage() override; | ||||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | ||||
| @@ -493,7 +497,8 @@ public: | |||||
| std::future<bool> StartOpenChest() override; | std::future<bool> StartOpenChest() override; | ||||
| std::future<bool> EndAllAction() override; | std::future<bool> EndAllAction() override; | ||||
| std::future<bool> SendMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendTextMessage(int64_t, std::string) override; | |||||
| std::future<bool> SendBinaryMessage(int64_t, std::string) override; | |||||
| [[nodiscard]] bool HaveMessage() override; | [[nodiscard]] bool HaveMessage() override; | ||||
| [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | [[nodiscard]] std::pair<int64_t, std::string> GetMessage() override; | ||||
| @@ -32,7 +32,7 @@ public: | |||||
| bool UseProp(THUAI6::PropType prop, int64_t playerID); | bool UseProp(THUAI6::PropType prop, int64_t playerID); | ||||
| bool ThrowProp(THUAI6::PropType prop, int64_t playerID); | bool ThrowProp(THUAI6::PropType prop, int64_t playerID); | ||||
| bool UseSkill(int32_t skillID, int64_t playerID); | bool UseSkill(int32_t skillID, int64_t playerID); | ||||
| bool SendMessage(int64_t toID, std::string message, int64_t playerID); | |||||
| bool SendMessage(int64_t toID, std::string message, bool binary, int64_t playerID); | |||||
| bool OpenDoor(int64_t playerID); | bool OpenDoor(int64_t playerID); | ||||
| bool CloseDoor(int64_t playerID); | bool CloseDoor(int64_t playerID); | ||||
| bool SkipWindow(int64_t playerID); | bool SkipWindow(int64_t playerID); | ||||
| @@ -118,7 +118,7 @@ private: | |||||
| bool ThrowProp(THUAI6::PropType prop) override; | bool ThrowProp(THUAI6::PropType prop) override; | ||||
| bool UseSkill(int32_t skillID) override; | bool UseSkill(int32_t skillID) override; | ||||
| bool SendMessage(int64_t toID, std::string message) override; | |||||
| bool SendMessage(int64_t toID, std::string message, bool binary) override; | |||||
| bool HaveMessage() override; | bool HaveMessage() override; | ||||
| std::pair<int64_t, std::string> GetMessage() override; | std::pair<int64_t, std::string> GetMessage() override; | ||||
| @@ -172,6 +172,13 @@ namespace THUAI6 | |||||
| Opened = 2, | Opened = 2, | ||||
| }; | }; | ||||
| enum class NewsType : unsigned char | |||||
| { | |||||
| NullNewsType = 0, | |||||
| TextMessage = 1, | |||||
| BinaryMessage = 2, | |||||
| }; | |||||
| // 玩家类 | // 玩家类 | ||||
| struct Player | struct Player | ||||
| { | { | ||||
| @@ -206,6 +206,12 @@ namespace Proto2THUAI6 | |||||
| }; | }; | ||||
| inline std::map<protobuf::MessageOfNews::NewsCase, THUAI6::NewsType> newsTypeDict{ | |||||
| {protobuf::MessageOfNews::NewsCase::NEWS_NOT_SET, THUAI6::NewsType::NullNewsType}, | |||||
| {protobuf::MessageOfNews::NewsCase::kTextMessage, THUAI6::NewsType::TextMessage}, | |||||
| {protobuf::MessageOfNews::NewsCase::kBinaryMessage, THUAI6::NewsType::BinaryMessage}, | |||||
| }; | |||||
| // 用于将Protobuf中的类转换为THUAI6的类 | // 用于将Protobuf中的类转换为THUAI6的类 | ||||
| inline std::shared_ptr<THUAI6::Tricker> Protobuf2THUAI6Tricker(const protobuf::MessageOfTricker& trickerMsg) | inline std::shared_ptr<THUAI6::Tricker> Protobuf2THUAI6Tricker(const protobuf::MessageOfTricker& trickerMsg) | ||||
| { | { | ||||
| @@ -460,10 +466,13 @@ namespace THUAI62Proto | |||||
| return pickMsg; | return pickMsg; | ||||
| } | } | ||||
| inline protobuf::SendMsg THUAI62ProtobufSend(std::string msg, int64_t toID, int64_t id) | |||||
| inline protobuf::SendMsg THUAI62ProtobufSend(std::string msg, int64_t toID, bool binary, int64_t id) | |||||
| { | { | ||||
| protobuf::SendMsg sendMsg; | protobuf::SendMsg sendMsg; | ||||
| sendMsg.set_message(msg); | |||||
| if (binary) | |||||
| sendMsg.set_binary_message(msg); | |||||
| else | |||||
| sendMsg.set_text_message(msg); | |||||
| sendMsg.set_to_player_id(toID); | sendMsg.set_to_player_id(toID); | ||||
| sendMsg.set_player_id(id); | sendMsg.set_player_id(id); | ||||
| return sendMsg; | return sendMsg; | ||||
| @@ -190,16 +190,28 @@ std::future<bool> TrickerAPI::EndAllAction() | |||||
| { return logic.EndAllAction(); }); | { return logic.EndAllAction(); }); | ||||
| } | } | ||||
| std::future<bool> StudentAPI::SendMessage(int64_t toID, std::string message) | |||||
| std::future<bool> StudentAPI::SendTextMessage(int64_t toID, std::string message) | |||||
| { | { | ||||
| return std::async(std::launch::async, [=]() | return std::async(std::launch::async, [=]() | ||||
| { return logic.SendMessage(toID, message); }); | |||||
| { return logic.SendMessage(toID, message, false); }); | |||||
| } | } | ||||
| std::future<bool> TrickerAPI::SendMessage(int64_t toID, std::string message) | |||||
| std::future<bool> TrickerAPI::SendTextMessage(int64_t toID, std::string message) | |||||
| { | { | ||||
| return std::async(std::launch::async, [=]() | return std::async(std::launch::async, [=]() | ||||
| { return logic.SendMessage(toID, message); }); | |||||
| { return logic.SendMessage(toID, message, false); }); | |||||
| } | |||||
| std::future<bool> StudentAPI::SendBinaryMessage(int64_t toID, std::string message) | |||||
| { | |||||
| return std::async(std::launch::async, [=]() | |||||
| { return logic.SendMessage(toID, message, false); }); | |||||
| } | |||||
| std::future<bool> TrickerAPI::SendBinaryMessage(int64_t toID, std::string message) | |||||
| { | |||||
| return std::async(std::launch::async, [=]() | |||||
| { return logic.SendMessage(toID, message, false); }); | |||||
| } | } | ||||
| bool StudentAPI::HaveMessage() | bool StudentAPI::HaveMessage() | ||||
| @@ -78,11 +78,11 @@ bool Communication::UseSkill(int32_t skillID, int64_t playerID) | |||||
| return false; | return false; | ||||
| } | } | ||||
| bool Communication::SendMessage(int64_t toID, std::string message, int64_t playerID) | |||||
| bool Communication::SendMessage(int64_t toID, std::string message, bool binary, int64_t playerID) | |||||
| { | { | ||||
| protobuf::BoolRes sendMessageResult; | protobuf::BoolRes sendMessageResult; | ||||
| ClientContext context; | ClientContext context; | ||||
| auto request = THUAI62Proto::THUAI62ProtobufSend(message, toID, playerID); | |||||
| auto request = THUAI62Proto::THUAI62ProtobufSend(message, toID, binary, playerID); | |||||
| auto status = THUAI6Stub->SendMessage(&context, request, &sendMessageResult); | auto status = THUAI6Stub->SendMessage(&context, request, &sendMessageResult); | ||||
| if (status.ok()) | if (status.ok()) | ||||
| return sendMessageResult.act_success(); | return sendMessageResult.act_success(); | ||||
| @@ -352,23 +352,43 @@ std::future<bool> TrickerDebugAPI::EndAllAction() | |||||
| return result; }); | return result; }); | ||||
| } | } | ||||
| std::future<bool> StudentDebugAPI::SendMessage(int64_t toID, std::string message) | |||||
| std::future<bool> StudentDebugAPI::SendTextMessage(int64_t toID, std::string message) | |||||
| { | { | ||||
| logger->info("SendMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||||
| logger->info("SendTextMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||||
| return std::async(std::launch::async, [=]() | return std::async(std::launch::async, [=]() | ||||
| { auto result = logic.SendMessage(toID, message); | |||||
| { auto result = logic.SendMessage(toID, message, false); | |||||
| if (!result) | if (!result) | ||||
| logger->warn("SendMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||||
| logger->warn("SendTextMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||||
| return result; }); | return result; }); | ||||
| } | } | ||||
| std::future<bool> TrickerDebugAPI::SendMessage(int64_t toID, std::string message) | |||||
| std::future<bool> TrickerDebugAPI::SendTextMessage(int64_t toID, std::string message) | |||||
| { | { | ||||
| logger->info("SendMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||||
| logger->info("SendTextMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||||
| return std::async(std::launch::async, [=]() | return std::async(std::launch::async, [=]() | ||||
| { auto result = logic.SendMessage(toID, message); | |||||
| { auto result = logic.SendMessage(toID, message, false); | |||||
| if (!result) | if (!result) | ||||
| logger->warn("SendMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||||
| logger->warn("SendTextMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||||
| return result; }); | |||||
| } | |||||
| std::future<bool> StudentDebugAPI::SendBinaryMessage(int64_t toID, std::string message) | |||||
| { | |||||
| logger->info("SendBinaryMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||||
| return std::async(std::launch::async, [=]() | |||||
| { auto result = logic.SendMessage(toID, message, true); | |||||
| if (!result) | |||||
| logger->warn("SendBinaryMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||||
| return result; }); | |||||
| } | |||||
| std::future<bool> TrickerDebugAPI::SendBinaryMessage(int64_t toID, std::string message) | |||||
| { | |||||
| logger->info("SendBinaryMessage: toID = {}, message = {}, called at {}ms", toID, message, Time::TimeSinceStart(startPoint)); | |||||
| return std::async(std::launch::async, [=]() | |||||
| { auto result = logic.SendMessage(toID, message, true); | |||||
| if (!result) | |||||
| logger->warn("SendBinaryMessage: failed at {}ms", Time::TimeSinceStart(startPoint)); | |||||
| return result; }); | return result; }); | ||||
| } | } | ||||
| @@ -214,10 +214,10 @@ bool Logic::UseSkill(int32_t skill) | |||||
| return pComm->UseSkill(skill, playerID); | return pComm->UseSkill(skill, playerID); | ||||
| } | } | ||||
| bool Logic::SendMessage(int64_t toID, std::string message) | |||||
| bool Logic::SendMessage(int64_t toID, std::string message, bool binary) | |||||
| { | { | ||||
| logger->debug("Called SendMessage"); | logger->debug("Called SendMessage"); | ||||
| return pComm->SendMessage(toID, message, playerID); | |||||
| return pComm->SendMessage(toID, message, binary, playerID); | |||||
| } | } | ||||
| bool Logic::HaveMessage() | bool Logic::HaveMessage() | ||||
| @@ -315,68 +315,81 @@ void Logic::ProcessMessage() | |||||
| { | { | ||||
| auto messageThread = [this]() | auto messageThread = [this]() | ||||
| { | { | ||||
| logger->info("Message thread start!"); | |||||
| pComm->AddPlayer(playerID, playerType, studentType, trickerType); | |||||
| while (gameState != THUAI6::GameState::GameEnd) | |||||
| try | |||||
| { | { | ||||
| auto clientMsg = pComm->GetMessage2Client(); // 在获得新消息之前阻塞 | |||||
| logger->debug("Get message from server!"); | |||||
| gameState = Proto2THUAI6::gameStateDict[clientMsg.game_state()]; | |||||
| switch (gameState) | |||||
| logger->info("Message thread start!"); | |||||
| pComm->AddPlayer(playerID, playerType, studentType, trickerType); | |||||
| while (gameState != THUAI6::GameState::GameEnd) | |||||
| { | { | ||||
| case THUAI6::GameState::GameStart: | |||||
| logger->info("Game Start!"); | |||||
| auto clientMsg = pComm->GetMessage2Client(); // 在获得新消息之前阻塞 | |||||
| logger->debug("Get message from server!"); | |||||
| gameState = Proto2THUAI6::gameStateDict[clientMsg.game_state()]; | |||||
| switch (gameState) | |||||
| { | |||||
| case THUAI6::GameState::GameStart: | |||||
| logger->info("Game Start!"); | |||||
| // 读取地图 | |||||
| for (const auto& item : clientMsg.obj_message()) | |||||
| if (Proto2THUAI6::messageOfObjDict[item.message_of_obj_case()] == THUAI6::MessageOfObj::MapMessage) | |||||
| { | |||||
| auto map = std::vector<std::vector<THUAI6::PlaceType>>(); | |||||
| auto mapResult = item.map_message(); | |||||
| for (int i = 0; i < item.map_message().row_size(); i++) | |||||
| // 读取地图 | |||||
| for (const auto& item : clientMsg.obj_message()) | |||||
| if (Proto2THUAI6::messageOfObjDict[item.message_of_obj_case()] == THUAI6::MessageOfObj::MapMessage) | |||||
| { | { | ||||
| std::vector<THUAI6::PlaceType> row; | |||||
| for (int j = 0; j < mapResult.row(i).col_size(); j++) | |||||
| auto map = std::vector<std::vector<THUAI6::PlaceType>>(); | |||||
| auto mapResult = item.map_message(); | |||||
| for (int i = 0; i < item.map_message().row_size(); i++) | |||||
| { | { | ||||
| if (Proto2THUAI6::placeTypeDict.count(mapResult.row(i).col(j)) == 0) | |||||
| logger->error("Unknown place type!"); | |||||
| row.push_back(Proto2THUAI6::placeTypeDict[mapResult.row(i).col(j)]); | |||||
| std::vector<THUAI6::PlaceType> row; | |||||
| for (int j = 0; j < mapResult.row(i).col_size(); j++) | |||||
| { | |||||
| if (Proto2THUAI6::placeTypeDict.count(mapResult.row(i).col(j)) == 0) | |||||
| logger->error("Unknown place type!"); | |||||
| row.push_back(Proto2THUAI6::placeTypeDict[mapResult.row(i).col(j)]); | |||||
| } | |||||
| map.push_back(std::move(row)); | |||||
| } | } | ||||
| map.push_back(std::move(row)); | |||||
| bufferState->gameMap = std::move(map); | |||||
| currentState->gameMap = bufferState->gameMap; | |||||
| logger->info("Map loaded!"); | |||||
| break; | |||||
| } | } | ||||
| bufferState->gameMap = std::move(map); | |||||
| currentState->gameMap = bufferState->gameMap; | |||||
| logger->info("Map loaded!"); | |||||
| break; | |||||
| if (currentState->gameMap.empty()) | |||||
| { | |||||
| logger->error("Map not loaded!"); | |||||
| throw std::runtime_error("Map not loaded!"); | |||||
| } | } | ||||
| if (currentState->gameMap.empty()) | |||||
| { | |||||
| logger->error("Map not loaded!"); | |||||
| throw std::runtime_error("Map not loaded!"); | |||||
| } | |||||
| LoadBuffer(clientMsg); | |||||
| LoadBuffer(clientMsg); | |||||
| AILoop = true; | |||||
| UnBlockAI(); | |||||
| AILoop = true; | |||||
| UnBlockAI(); | |||||
| break; | |||||
| case THUAI6::GameState::GameRunning: | |||||
| break; | |||||
| case THUAI6::GameState::GameRunning: | |||||
| LoadBuffer(clientMsg); | |||||
| break; | |||||
| default: | |||||
| logger->debug("Unknown GameState!"); | |||||
| break; | |||||
| LoadBuffer(clientMsg); | |||||
| break; | |||||
| default: | |||||
| logger->debug("Unknown GameState!"); | |||||
| break; | |||||
| } | |||||
| } | |||||
| { | |||||
| std::lock_guard<std::mutex> lock(mtxBuffer); | |||||
| bufferUpdated = true; | |||||
| counterBuffer = -1; | |||||
| } | } | ||||
| cvBuffer.notify_one(); | |||||
| logger->info("Game End!"); | |||||
| AILoop = false; | |||||
| } | } | ||||
| AILoop = false; | |||||
| catch (const std::exception& e) | |||||
| { | |||||
| std::cerr << "C++ Exception: " << e.what() << std::endl; | |||||
| AILoop = false; | |||||
| } | |||||
| catch (...) | |||||
| { | { | ||||
| std::lock_guard<std::mutex> lock(mtxBuffer); | |||||
| bufferUpdated = true; | |||||
| counterBuffer = -1; | |||||
| std::cerr << "Unknown Exception!" << std::endl; | |||||
| AILoop = false; | |||||
| } | } | ||||
| cvBuffer.notify_one(); | |||||
| logger->info("Game End!"); | |||||
| }; | }; | ||||
| std::thread(messageThread).detach(); | std::thread(messageThread).detach(); | ||||
| } | } | ||||
| @@ -567,7 +580,20 @@ void Logic::LoadBufferCase(const protobuf::MessageOfObj& item) | |||||
| { | { | ||||
| auto news = item.news_message(); | auto news = item.news_message(); | ||||
| if (news.to_id() == playerID) | if (news.to_id() == playerID) | ||||
| messageQueue.emplace(std::make_pair(news.from_id(), news.news())); | |||||
| { | |||||
| if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::TextMessage) | |||||
| { | |||||
| messageQueue.emplace(std::make_pair(news.to_id(), news.text_message())); | |||||
| logger->debug("Add News!"); | |||||
| } | |||||
| else if (Proto2THUAI6::newsTypeDict[news.news_case()] == THUAI6::NewsType::BinaryMessage) | |||||
| { | |||||
| messageQueue.emplace(std::make_pair(news.to_id(), news.binary_message())); | |||||
| logger->debug("Add News!"); | |||||
| } | |||||
| else | |||||
| logger->error("Unknown NewsType!"); | |||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| case THUAI6::MessageOfObj::NullMessageOfObj: | case THUAI6::MessageOfObj::NullMessageOfObj: | ||||
| @@ -734,30 +760,41 @@ void Logic::Main(CreateAIFunc createAI, std::string IP, std::string port, bool f | |||||
| // 构造AI线程 | // 构造AI线程 | ||||
| auto AIThread = [&]() | auto AIThread = [&]() | ||||
| { | { | ||||
| try | |||||
| { | { | ||||
| std::unique_lock<std::mutex> lock(mtxAI); | |||||
| cvAI.wait(lock, [this]() | |||||
| { return AIStart; }); | |||||
| } | |||||
| auto ai = createAI(playerID); | |||||
| while (AILoop) | |||||
| { | |||||
| if (asynchronous) | |||||
| { | { | ||||
| Wait(); | |||||
| timer->StartTimer(); | |||||
| timer->Play(*ai); | |||||
| timer->EndTimer(); | |||||
| std::unique_lock<std::mutex> lock(mtxAI); | |||||
| cvAI.wait(lock, [this]() | |||||
| { return AIStart; }); | |||||
| } | } | ||||
| else | |||||
| auto ai = createAI(playerID); | |||||
| while (AILoop) | |||||
| { | { | ||||
| Update(); | |||||
| timer->StartTimer(); | |||||
| timer->Play(*ai); | |||||
| timer->EndTimer(); | |||||
| if (asynchronous) | |||||
| { | |||||
| Wait(); | |||||
| timer->StartTimer(); | |||||
| timer->Play(*ai); | |||||
| timer->EndTimer(); | |||||
| } | |||||
| else | |||||
| { | |||||
| Update(); | |||||
| timer->StartTimer(); | |||||
| timer->Play(*ai); | |||||
| timer->EndTimer(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| catch (const std::exception& e) | |||||
| { | |||||
| std::cerr << "C++ Exception: " << e.what() << std::endl; | |||||
| } | |||||
| catch (...) | |||||
| { | |||||
| std::cerr << "Unknown Exception!" << std::endl; | |||||
| } | |||||
| }; | }; | ||||
| // 连接服务器 | // 连接服务器 | ||||
| @@ -20,7 +20,7 @@ static constexpr std::string_view welcomeString = R"welcome( | |||||
| _____ _ _ _ _ _ ___ __ | _____ _ _ _ _ _ ___ __ | ||||
| |_ _| | | | | | | / \ |_ _/ /_ | |_ _| | | | | | | / \ |_ _/ /_ | ||||
| | | | |_| | | | |/ _ \ | | '_ \ | |||||
| | | | |_| | | | |/ _ \ | | '_ \ | |||||
| | | | _ | |_| / ___ \ | | (_) | | | | | _ | |_| / ___ \ | | (_) | | ||||
| |_| |_| |_|\___/_/ \_\___\___/ | |_| |_| |_|\___/_/ \_\___\___/ | ||||
| @@ -115,7 +115,11 @@ int THUAI6Main(int argc, char** argv, CreateAIFunc AIBuilder) | |||||
| } | } | ||||
| catch (const std::exception& e) | catch (const std::exception& e) | ||||
| { | { | ||||
| std::cerr << e.what() << '\n'; | |||||
| std::cerr << "C++ Exception: " << e.what() << '\n'; | |||||
| } | |||||
| catch (...) | |||||
| { | |||||
| std::cerr << "Unknown Exception\n"; | |||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| @@ -312,7 +312,7 @@ namespace protobuf | |||||
| ::_pbi::ConstantInitialized | ::_pbi::ConstantInitialized | ||||
| ) : | ) : | ||||
| _impl_{ | _impl_{ | ||||
| /*decltype(_impl_.news_)*/ {&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}, /*decltype(_impl_.from_id_)*/ int64_t{0}, /*decltype(_impl_.to_id_)*/ int64_t{0}, /*decltype(_impl_._cached_size_)*/ {}} | |||||
| /*decltype(_impl_. from_id_)*/ int64_t{0}, /*decltype(_impl_.to_id_)*/ int64_t{0}, /*decltype(_impl_.news_)*/ {}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}} |
|||||
| { | { | ||||
| } | } | ||||
| struct MessageOfNewsDefaultTypeInternal | struct MessageOfNewsDefaultTypeInternal | ||||
| @@ -612,12 +612,14 @@ const uint32_t TableStruct_Message2Clients_2eproto::offsets[] PROTOBUF_SECTION_V | |||||
| ~0u, // no _has_bits_ | ~0u, // no _has_bits_ | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _internal_metadata_), | PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _internal_metadata_), | ||||
| ~0u, // no _extensions_ | ~0u, // no _extensions_ | ||||
| ~0u, // no _oneof_case_ | |||||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_._oneof_case_[0]), | |||||
| ~0u, // no _weak_field_map_ | ~0u, // no _weak_field_map_ | ||||
| ~0u, // no _inlined_string_donated_ | ~0u, // no _inlined_string_donated_ | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.news_), | |||||
| ::_pbi::kInvalidFieldOffsetTag, | |||||
| ::_pbi::kInvalidFieldOffsetTag, | |||||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.from_id_), | PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.from_id_), | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.to_id_), | PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.to_id_), | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfNews, _impl_.news_), | |||||
| ~0u, // no _has_bits_ | ~0u, // no _has_bits_ | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfObj, _internal_metadata_), | PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfObj, _internal_metadata_), | ||||
| ~0u, // no _extensions_ | ~0u, // no _extensions_ | ||||
| @@ -690,11 +692,11 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode | |||||
| {149, -1, -1, sizeof(::protobuf::MessageOfMap_Row)}, | {149, -1, -1, sizeof(::protobuf::MessageOfMap_Row)}, | ||||
| {156, -1, -1, sizeof(::protobuf::MessageOfMap)}, | {156, -1, -1, sizeof(::protobuf::MessageOfMap)}, | ||||
| {163, -1, -1, sizeof(::protobuf::MessageOfNews)}, | {163, -1, -1, sizeof(::protobuf::MessageOfNews)}, | ||||
| {172, -1, -1, sizeof(::protobuf::MessageOfObj)}, | |||||
| {191, -1, -1, sizeof(::protobuf::MessageOfAll)}, | |||||
| {203, -1, -1, sizeof(::protobuf::MessageToClient)}, | |||||
| {212, -1, -1, sizeof(::protobuf::MoveRes)}, | |||||
| {221, -1, -1, sizeof(::protobuf::BoolRes)}, | |||||
| {174, -1, -1, sizeof(::protobuf::MessageOfObj)}, | |||||
| {193, -1, -1, sizeof(::protobuf::MessageOfAll)}, | |||||
| {205, -1, -1, sizeof(::protobuf::MessageToClient)}, | |||||
| {214, -1, -1, sizeof(::protobuf::MoveRes)}, | |||||
| {223, -1, -1, sizeof(::protobuf::BoolRes)}, | |||||
| }; | }; | ||||
| static const ::_pb::Message* const file_default_instances[] = { | static const ::_pb::Message* const file_default_instances[] = { | ||||
| @@ -775,36 +777,37 @@ const char descriptor_table_protodef_Message2Clients_2eproto[] PROTOBUF_SECTION_ | |||||
| "\001(\005\022\t\n\001y\030\002 \001(\005\022\020\n\010progress\030\003 \001(\005\"`\n\014Mess" | "\001(\005\022\t\n\001y\030\002 \001(\005\022\020\n\010progress\030\003 \001(\005\"`\n\014Mess" | ||||
| "ageOfMap\022\'\n\003row\030\002 \003(\0132\032.protobuf.Message" | "ageOfMap\022\'\n\003row\030\002 \003(\0132\032.protobuf.Message" | ||||
| "OfMap.Row\032\'\n\003Row\022 \n\003col\030\001 \003(\0162\023.protobuf" | "OfMap.Row\032\'\n\003Row\022 \n\003col\030\001 \003(\0162\023.protobuf" | ||||
| ".PlaceType\"=\n\rMessageOfNews\022\014\n\004news\030\001 \001(" | |||||
| "\t\022\017\n\007from_id\030\002 \001(\003\022\r\n\005to_id\030\003 \001(\003\"\244\005\n\014Me" | |||||
| "ssageOfObj\0225\n\017student_message\030\001 \001(\0132\032.pr" | |||||
| "otobuf.MessageOfStudentH\000\0225\n\017tricker_mes" | |||||
| "sage\030\002 \001(\0132\032.protobuf.MessageOfTrickerH\000" | |||||
| "\022/\n\014prop_message\030\003 \001(\0132\027.protobuf.Messag" | |||||
| "eOfPropH\000\0223\n\016bullet_message\030\004 \001(\0132\031.prot" | |||||
| "obuf.MessageOfBulletH\000\022@\n\025bombed_bullet_" | |||||
| "message\030\005 \001(\0132\037.protobuf.MessageOfBombed" | |||||
| "BulletH\000\0229\n\021classroom_message\030\006 \001(\0132\034.pr" | |||||
| "otobuf.MessageOfClassroomH\000\022/\n\014door_mess" | |||||
| "age\030\007 \001(\0132\027.protobuf.MessageOfDoorH\000\022/\n\014" | |||||
| "gate_message\030\010 \001(\0132\027.protobuf.MessageOfG" | |||||
| "ateH\000\0221\n\rchest_message\030\t \001(\0132\030.protobuf." | |||||
| "MessageOfChestH\000\022<\n\023hidden_gate_message\030" | |||||
| "\n \001(\0132\035.protobuf.MessageOfHiddenGateH\000\022/" | |||||
| "\n\014news_message\030\013 \001(\0132\027.protobuf.MessageO" | |||||
| "fNewsH\000\022-\n\013map_message\030\014 \001(\0132\026.protobuf." | |||||
| "MessageOfMapH\000B\020\n\016message_of_obj\"\234\001\n\014Mes" | |||||
| "sageOfAll\022\021\n\tgame_time\030\001 \001(\005\022\030\n\020subject_" | |||||
| "finished\030\002 \001(\005\022\031\n\021student_graduated\030\003 \001(" | |||||
| "\005\022\026\n\016student_quited\030\004 \001(\005\022\025\n\rstudent_sco" | |||||
| "re\030\005 \001(\005\022\025\n\rtricker_score\030\006 \001(\005\"\224\001\n\017Mess" | |||||
| "ageToClient\022+\n\013obj_message\030\001 \003(\0132\026.proto" | |||||
| "buf.MessageOfObj\022\'\n\ngame_state\030\002 \001(\0162\023.p" | |||||
| "rotobuf.GameState\022+\n\013all_message\030\003 \001(\0132\026" | |||||
| ".protobuf.MessageOfAll\"J\n\007MoveRes\022\024\n\014act" | |||||
| "ual_speed\030\001 \001(\003\022\024\n\014actual_angle\030\002 \001(\001\022\023\n" | |||||
| "\013act_success\030\003 \001(\010\"\036\n\007BoolRes\022\023\n\013act_suc" | |||||
| "cess\030\001 \001(\010b\006proto3"; | |||||
| ".PlaceType\"i\n\rMessageOfNews\022\026\n\014text_mess" | |||||
| "age\030\001 \001(\tH\000\022\030\n\016binary_message\030\004 \001(\014H\000\022\017\n" | |||||
| "\007from_id\030\002 \001(\003\022\r\n\005to_id\030\003 \001(\003B\006\n\004news\"\244\005" | |||||
| "\n\014MessageOfObj\0225\n\017student_message\030\001 \001(\0132" | |||||
| "\032.protobuf.MessageOfStudentH\000\0225\n\017tricker" | |||||
| "_message\030\002 \001(\0132\032.protobuf.MessageOfTrick" | |||||
| "erH\000\022/\n\014prop_message\030\003 \001(\0132\027.protobuf.Me" | |||||
| "ssageOfPropH\000\0223\n\016bullet_message\030\004 \001(\0132\031." | |||||
| "protobuf.MessageOfBulletH\000\022@\n\025bombed_bul" | |||||
| "let_message\030\005 \001(\0132\037.protobuf.MessageOfBo" | |||||
| "mbedBulletH\000\0229\n\021classroom_message\030\006 \001(\0132" | |||||
| "\034.protobuf.MessageOfClassroomH\000\022/\n\014door_" | |||||
| "message\030\007 \001(\0132\027.protobuf.MessageOfDoorH\000" | |||||
| "\022/\n\014gate_message\030\010 \001(\0132\027.protobuf.Messag" | |||||
| "eOfGateH\000\0221\n\rchest_message\030\t \001(\0132\030.proto" | |||||
| "buf.MessageOfChestH\000\022<\n\023hidden_gate_mess" | |||||
| "age\030\n \001(\0132\035.protobuf.MessageOfHiddenGate" | |||||
| "H\000\022/\n\014news_message\030\013 \001(\0132\027.protobuf.Mess" | |||||
| "ageOfNewsH\000\022-\n\013map_message\030\014 \001(\0132\026.proto" | |||||
| "buf.MessageOfMapH\000B\020\n\016message_of_obj\"\234\001\n" | |||||
| "\014MessageOfAll\022\021\n\tgame_time\030\001 \001(\005\022\030\n\020subj" | |||||
| "ect_finished\030\002 \001(\005\022\031\n\021student_graduated\030" | |||||
| "\003 \001(\005\022\026\n\016student_quited\030\004 \001(\005\022\025\n\rstudent" | |||||
| "_score\030\005 \001(\005\022\025\n\rtricker_score\030\006 \001(\005\"\224\001\n\017" | |||||
| "MessageToClient\022+\n\013obj_message\030\001 \003(\0132\026.p" | |||||
| "rotobuf.MessageOfObj\022\'\n\ngame_state\030\002 \001(\016" | |||||
| "2\023.protobuf.GameState\022+\n\013all_message\030\003 \001" | |||||
| "(\0132\026.protobuf.MessageOfAll\"J\n\007MoveRes\022\024\n" | |||||
| "\014actual_speed\030\001 \001(\003\022\024\n\014actual_angle\030\002 \001(" | |||||
| "\001\022\023\n\013act_success\030\003 \001(\010\"\036\n\007BoolRes\022\023\n\013act" | |||||
| "_success\030\001 \001(\010b\006proto3"; | |||||
| static const ::_pbi::DescriptorTable* const descriptor_table_Message2Clients_2eproto_deps[1] = { | static const ::_pbi::DescriptorTable* const descriptor_table_Message2Clients_2eproto_deps[1] = { | ||||
| &::descriptor_table_MessageType_2eproto, | &::descriptor_table_MessageType_2eproto, | ||||
| }; | }; | ||||
| @@ -812,7 +815,7 @@ static ::_pbi::once_flag descriptor_table_Message2Clients_2eproto_once; | |||||
| const ::_pbi::DescriptorTable descriptor_table_Message2Clients_2eproto = { | const ::_pbi::DescriptorTable descriptor_table_Message2Clients_2eproto = { | ||||
| false, | false, | ||||
| false, | false, | ||||
| 3378, | |||||
| 3422, | |||||
| descriptor_table_protodef_Message2Clients_2eproto, | descriptor_table_protodef_Message2Clients_2eproto, | ||||
| "Message2Clients.proto", | "Message2Clients.proto", | ||||
| &descriptor_table_Message2Clients_2eproto_once, | &descriptor_table_Message2Clients_2eproto_once, | ||||
| @@ -5927,18 +5930,28 @@ namespace protobuf | |||||
| MessageOfNews* const _this = this; | MessageOfNews* const _this = this; | ||||
| (void)_this; | (void)_this; | ||||
| new (&_impl_) Impl_{ | new (&_impl_) Impl_{ | ||||
| decltype(_impl_.news_){}, decltype(_impl_.from_id_){}, decltype(_impl_.to_id_){}, /*decltype(_impl_._cached_size_)*/ {}}; | |||||
| decltype(_impl_.from_id_){}, decltype(_impl_.to_id_){}, decltype(_impl_.news_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||||
| _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | ||||
| _impl_.news_.InitDefault(); | |||||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| _impl_.news_.Set("", GetArenaForAllocation()); | |||||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| if (!from._internal_news().empty()) | |||||
| ::memcpy(&_impl_.from_id_, &from._impl_.from_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_id_) - reinterpret_cast<char*>(&_impl_.from_id_)) + sizeof(_impl_.to_id_)); | |||||
| clear_has_news(); | |||||
| switch (from.news_case()) | |||||
| { | { | ||||
| _this->_impl_.news_.Set(from._internal_news(), _this->GetArenaForAllocation()); | |||||
| case kTextMessage: | |||||
| { | |||||
| _this->_internal_set_text_message(from._internal_text_message()); | |||||
| break; | |||||
| } | |||||
| case kBinaryMessage: | |||||
| { | |||||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||||
| break; | |||||
| } | |||||
| case NEWS_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| ::memcpy(&_impl_.from_id_, &from._impl_.from_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_id_) - reinterpret_cast<char*>(&_impl_.from_id_)) + sizeof(_impl_.to_id_)); | |||||
| // @@protoc_insertion_point(copy_constructor:protobuf.MessageOfNews) | // @@protoc_insertion_point(copy_constructor:protobuf.MessageOfNews) | ||||
| } | } | ||||
| @@ -5949,11 +5962,8 @@ namespace protobuf | |||||
| (void)arena; | (void)arena; | ||||
| (void)is_message_owned; | (void)is_message_owned; | ||||
| new (&_impl_) Impl_{ | new (&_impl_) Impl_{ | ||||
| decltype(_impl_.news_){}, decltype(_impl_.from_id_){int64_t{0}}, decltype(_impl_.to_id_){int64_t{0}}, /*decltype(_impl_._cached_size_)*/ {}}; | |||||
| _impl_.news_.InitDefault(); | |||||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| _impl_.news_.Set("", GetArenaForAllocation()); | |||||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| decltype(_impl_.from_id_){int64_t{0}}, decltype(_impl_.to_id_){int64_t{0}}, decltype(_impl_.news_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||||
| clear_has_news(); | |||||
| } | } | ||||
| MessageOfNews::~MessageOfNews() | MessageOfNews::~MessageOfNews() | ||||
| @@ -5970,7 +5980,10 @@ namespace protobuf | |||||
| inline void MessageOfNews::SharedDtor() | inline void MessageOfNews::SharedDtor() | ||||
| { | { | ||||
| GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); | GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); | ||||
| _impl_.news_.Destroy(); | |||||
| if (has_news()) | |||||
| { | |||||
| clear_news(); | |||||
| } | |||||
| } | } | ||||
| void MessageOfNews::SetCachedSize(int size) const | void MessageOfNews::SetCachedSize(int size) const | ||||
| @@ -5978,6 +5991,29 @@ namespace protobuf | |||||
| _impl_._cached_size_.Set(size); | _impl_._cached_size_.Set(size); | ||||
| } | } | ||||
| void MessageOfNews::clear_news() | |||||
| { | |||||
| // @@protoc_insertion_point(one_of_clear_start:protobuf.MessageOfNews) | |||||
| switch (news_case()) | |||||
| { | |||||
| case kTextMessage: | |||||
| { | |||||
| _impl_.news_.text_message_.Destroy(); | |||||
| break; | |||||
| } | |||||
| case kBinaryMessage: | |||||
| { | |||||
| _impl_.news_.binary_message_.Destroy(); | |||||
| break; | |||||
| } | |||||
| case NEWS_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| _impl_._oneof_case_[0] = NEWS_NOT_SET; | |||||
| } | |||||
| void MessageOfNews::Clear() | void MessageOfNews::Clear() | ||||
| { | { | ||||
| // @@protoc_insertion_point(message_clear_start:protobuf.MessageOfNews) | // @@protoc_insertion_point(message_clear_start:protobuf.MessageOfNews) | ||||
| @@ -5985,8 +6021,8 @@ namespace protobuf | |||||
| // Prevent compiler warnings about cached_has_bits being unused | // Prevent compiler warnings about cached_has_bits being unused | ||||
| (void)cached_has_bits; | (void)cached_has_bits; | ||||
| _impl_.news_.ClearToEmpty(); | |||||
| ::memset(&_impl_.from_id_, 0, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_id_) - reinterpret_cast<char*>(&_impl_.from_id_)) + sizeof(_impl_.to_id_)); | ::memset(&_impl_.from_id_, 0, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_id_) - reinterpret_cast<char*>(&_impl_.from_id_)) + sizeof(_impl_.to_id_)); | ||||
| clear_news(); | |||||
| _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); | _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); | ||||
| } | } | ||||
| @@ -6001,14 +6037,14 @@ namespace protobuf | |||||
| ptr = ::_pbi::ReadTag(ptr, &tag); | ptr = ::_pbi::ReadTag(ptr, &tag); | ||||
| switch (tag >> 3) | switch (tag >> 3) | ||||
| { | { | ||||
| // string news = 1; | |||||
| // string text_message = 1; | |||||
| case 1: | case 1: | ||||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) | if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 10)) | ||||
| { | { | ||||
| auto str = _internal_mutable_news(); | |||||
| auto str = _internal_mutable_text_message(); | |||||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | ||||
| CHK_(ptr); | CHK_(ptr); | ||||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.MessageOfNews.news")); | |||||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.MessageOfNews.text_message")); | |||||
| } | } | ||||
| else | else | ||||
| goto handle_unusual; | goto handle_unusual; | ||||
| @@ -6033,6 +6069,17 @@ namespace protobuf | |||||
| else | else | ||||
| goto handle_unusual; | goto handle_unusual; | ||||
| continue; | continue; | ||||
| // bytes binary_message = 4; | |||||
| case 4: | |||||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) | |||||
| { | |||||
| auto str = _internal_mutable_binary_message(); | |||||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | |||||
| CHK_(ptr); | |||||
| } | |||||
| else | |||||
| goto handle_unusual; | |||||
| continue; | |||||
| default: | default: | ||||
| goto handle_unusual; | goto handle_unusual; | ||||
| } // switch | } // switch | ||||
| @@ -6067,14 +6114,14 @@ namespace protobuf | |||||
| uint32_t cached_has_bits = 0; | uint32_t cached_has_bits = 0; | ||||
| (void)cached_has_bits; | (void)cached_has_bits; | ||||
| // string news = 1; | |||||
| if (!this->_internal_news().empty()) | |||||
| // string text_message = 1; | |||||
| if (_internal_has_text_message()) | |||||
| { | { | ||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( | ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( | ||||
| this->_internal_news().data(), static_cast<int>(this->_internal_news().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.MessageOfNews.news" | |||||
| this->_internal_text_message().data(), static_cast<int>(this->_internal_text_message().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.MessageOfNews.text_message" | |||||
| ); | ); | ||||
| target = stream->WriteStringMaybeAliased( | target = stream->WriteStringMaybeAliased( | ||||
| 1, this->_internal_news(), target | |||||
| 1, this->_internal_text_message(), target | |||||
| ); | ); | ||||
| } | } | ||||
| @@ -6092,6 +6139,14 @@ namespace protobuf | |||||
| target = ::_pbi::WireFormatLite::WriteInt64ToArray(3, this->_internal_to_id(), target); | target = ::_pbi::WireFormatLite::WriteInt64ToArray(3, this->_internal_to_id(), target); | ||||
| } | } | ||||
| // bytes binary_message = 4; | |||||
| if (_internal_has_binary_message()) | |||||
| { | |||||
| target = stream->WriteBytesMaybeAliased( | |||||
| 4, this->_internal_binary_message(), target | |||||
| ); | |||||
| } | |||||
| if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) | if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) | ||||
| { | { | ||||
| target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( | target = ::_pbi::WireFormat::InternalSerializeUnknownFieldsToArray( | ||||
| @@ -6111,15 +6166,6 @@ namespace protobuf | |||||
| // Prevent compiler warnings about cached_has_bits being unused | // Prevent compiler warnings about cached_has_bits being unused | ||||
| (void)cached_has_bits; | (void)cached_has_bits; | ||||
| // string news = 1; | |||||
| if (!this->_internal_news().empty()) | |||||
| { | |||||
| total_size += 1 + | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||||
| this->_internal_news() | |||||
| ); | |||||
| } | |||||
| // int64 from_id = 2; | // int64 from_id = 2; | ||||
| if (this->_internal_from_id() != 0) | if (this->_internal_from_id() != 0) | ||||
| { | { | ||||
| @@ -6132,6 +6178,31 @@ namespace protobuf | |||||
| total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_to_id()); | total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_to_id()); | ||||
| } | } | ||||
| switch (news_case()) | |||||
| { | |||||
| // string text_message = 1; | |||||
| case kTextMessage: | |||||
| { | |||||
| total_size += 1 + | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||||
| this->_internal_text_message() | |||||
| ); | |||||
| break; | |||||
| } | |||||
| // bytes binary_message = 4; | |||||
| case kBinaryMessage: | |||||
| { | |||||
| total_size += 1 + | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( | |||||
| this->_internal_binary_message() | |||||
| ); | |||||
| break; | |||||
| } | |||||
| case NEWS_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); | return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); | ||||
| } | } | ||||
| @@ -6152,10 +6223,6 @@ namespace protobuf | |||||
| uint32_t cached_has_bits = 0; | uint32_t cached_has_bits = 0; | ||||
| (void)cached_has_bits; | (void)cached_has_bits; | ||||
| if (!from._internal_news().empty()) | |||||
| { | |||||
| _this->_internal_set_news(from._internal_news()); | |||||
| } | |||||
| if (from._internal_from_id() != 0) | if (from._internal_from_id() != 0) | ||||
| { | { | ||||
| _this->_internal_set_from_id(from._internal_from_id()); | _this->_internal_set_from_id(from._internal_from_id()); | ||||
| @@ -6164,6 +6231,23 @@ namespace protobuf | |||||
| { | { | ||||
| _this->_internal_set_to_id(from._internal_to_id()); | _this->_internal_set_to_id(from._internal_to_id()); | ||||
| } | } | ||||
| switch (from.news_case()) | |||||
| { | |||||
| case kTextMessage: | |||||
| { | |||||
| _this->_internal_set_text_message(from._internal_text_message()); | |||||
| break; | |||||
| } | |||||
| case kBinaryMessage: | |||||
| { | |||||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||||
| break; | |||||
| } | |||||
| case NEWS_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | ||||
| } | } | ||||
| @@ -6184,17 +6268,14 @@ namespace protobuf | |||||
| void MessageOfNews::InternalSwap(MessageOfNews* other) | void MessageOfNews::InternalSwap(MessageOfNews* other) | ||||
| { | { | ||||
| using std::swap; | using std::swap; | ||||
| auto* lhs_arena = GetArenaForAllocation(); | |||||
| auto* rhs_arena = other->GetArenaForAllocation(); | |||||
| _internal_metadata_.InternalSwap(&other->_internal_metadata_); | _internal_metadata_.InternalSwap(&other->_internal_metadata_); | ||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( | |||||
| &_impl_.news_, lhs_arena, &other->_impl_.news_, rhs_arena | |||||
| ); | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::memswap< | ::PROTOBUF_NAMESPACE_ID::internal::memswap< | ||||
| PROTOBUF_FIELD_OFFSET(MessageOfNews, _impl_.to_id_) + sizeof(MessageOfNews::_impl_.to_id_) - PROTOBUF_FIELD_OFFSET(MessageOfNews, _impl_.from_id_)>( | PROTOBUF_FIELD_OFFSET(MessageOfNews, _impl_.to_id_) + sizeof(MessageOfNews::_impl_.to_id_) - PROTOBUF_FIELD_OFFSET(MessageOfNews, _impl_.from_id_)>( | ||||
| reinterpret_cast<char*>(&_impl_.from_id_), | reinterpret_cast<char*>(&_impl_.from_id_), | ||||
| reinterpret_cast<char*>(&other->_impl_.from_id_) | reinterpret_cast<char*>(&other->_impl_.from_id_) | ||||
| ); | ); | ||||
| swap(_impl_.news_, other->_impl_.news_); | |||||
| swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); | |||||
| } | } | ||||
| ::PROTOBUF_NAMESPACE_ID::Metadata MessageOfNews::GetMetadata() const | ::PROTOBUF_NAMESPACE_ID::Metadata MessageOfNews::GetMetadata() const | ||||
| @@ -3677,6 +3677,13 @@ namespace protobuf | |||||
| { | { | ||||
| return *internal_default_instance(); | return *internal_default_instance(); | ||||
| } | } | ||||
| enum NewsCase | |||||
| { | |||||
| kTextMessage = 1, | |||||
| kBinaryMessage = 4, | |||||
| NEWS_NOT_SET = 0, | |||||
| }; | |||||
| static inline const MessageOfNews* internal_default_instance() | static inline const MessageOfNews* internal_default_instance() | ||||
| { | { | ||||
| return reinterpret_cast<const MessageOfNews*>( | return reinterpret_cast<const MessageOfNews*>( | ||||
| @@ -3776,25 +3783,11 @@ namespace protobuf | |||||
| enum : int | enum : int | ||||
| { | { | ||||
| kNewsFieldNumber = 1, | |||||
| kFromIdFieldNumber = 2, | kFromIdFieldNumber = 2, | ||||
| kToIdFieldNumber = 3, | kToIdFieldNumber = 3, | ||||
| kTextMessageFieldNumber = 1, | |||||
| kBinaryMessageFieldNumber = 4, | |||||
| }; | }; | ||||
| // string news = 1; | |||||
| void clear_news(); | |||||
| const std::string& news() const; | |||||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||||
| void set_news(ArgT0&& arg0, ArgT... args); | |||||
| std::string* mutable_news(); | |||||
| PROTOBUF_NODISCARD std::string* release_news(); | |||||
| void set_allocated_news(std::string* news); | |||||
| private: | |||||
| const std::string& _internal_news() const; | |||||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_news(const std::string& value); | |||||
| std::string* _internal_mutable_news(); | |||||
| public: | |||||
| // int64 from_id = 2; | // int64 from_id = 2; | ||||
| void clear_from_id(); | void clear_from_id(); | ||||
| int64_t from_id() const; | int64_t from_id() const; | ||||
| @@ -3815,10 +3808,59 @@ namespace protobuf | |||||
| void _internal_set_to_id(int64_t value); | void _internal_set_to_id(int64_t value); | ||||
| public: | public: | ||||
| // string text_message = 1; | |||||
| bool has_text_message() const; | |||||
| private: | |||||
| bool _internal_has_text_message() const; | |||||
| public: | |||||
| void clear_text_message(); | |||||
| const std::string& text_message() const; | |||||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||||
| void set_text_message(ArgT0&& arg0, ArgT... args); | |||||
| std::string* mutable_text_message(); | |||||
| PROTOBUF_NODISCARD std::string* release_text_message(); | |||||
| void set_allocated_text_message(std::string* text_message); | |||||
| private: | |||||
| const std::string& _internal_text_message() const; | |||||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_text_message(const std::string& value); | |||||
| std::string* _internal_mutable_text_message(); | |||||
| public: | |||||
| // bytes binary_message = 4; | |||||
| bool has_binary_message() const; | |||||
| private: | |||||
| bool _internal_has_binary_message() const; | |||||
| public: | |||||
| void clear_binary_message(); | |||||
| const std::string& binary_message() const; | |||||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||||
| void set_binary_message(ArgT0&& arg0, ArgT... args); | |||||
| std::string* mutable_binary_message(); | |||||
| PROTOBUF_NODISCARD std::string* release_binary_message(); | |||||
| void set_allocated_binary_message(std::string* binary_message); | |||||
| private: | |||||
| const std::string& _internal_binary_message() const; | |||||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_binary_message(const std::string& value); | |||||
| std::string* _internal_mutable_binary_message(); | |||||
| public: | |||||
| void clear_news(); | |||||
| NewsCase news_case() const; | |||||
| // @@protoc_insertion_point(class_scope:protobuf.MessageOfNews) | // @@protoc_insertion_point(class_scope:protobuf.MessageOfNews) | ||||
| private: | private: | ||||
| class _Internal; | class _Internal; | ||||
| void set_has_text_message(); | |||||
| void set_has_binary_message(); | |||||
| inline bool has_news() const; | |||||
| inline void clear_has_news(); | |||||
| template<typename T> | template<typename T> | ||||
| friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; | friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; | ||||
| @@ -3826,10 +3868,20 @@ namespace protobuf | |||||
| typedef void DestructorSkippable_; | typedef void DestructorSkippable_; | ||||
| struct Impl_ | struct Impl_ | ||||
| { | { | ||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr news_; | |||||
| int64_t from_id_; | int64_t from_id_; | ||||
| int64_t to_id_; | int64_t to_id_; | ||||
| union NewsUnion | |||||
| { | |||||
| constexpr NewsUnion() : | |||||
| _constinit_{} | |||||
| { | |||||
| } | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_message_; | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr binary_message_; | |||||
| } news_; | |||||
| mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; | mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; | ||||
| uint32_t _oneof_case_[1]; | |||||
| }; | }; | ||||
| union | union | ||||
| { | { | ||||
| @@ -7609,61 +7661,202 @@ namespace protobuf | |||||
| // MessageOfNews | // MessageOfNews | ||||
| // string news = 1; | |||||
| inline void MessageOfNews::clear_news() | |||||
| // string text_message = 1; | |||||
| inline bool MessageOfNews::_internal_has_text_message() const | |||||
| { | |||||
| return news_case() == kTextMessage; | |||||
| } | |||||
| inline bool MessageOfNews::has_text_message() const | |||||
| { | { | ||||
| _impl_.news_.ClearToEmpty(); | |||||
| return _internal_has_text_message(); | |||||
| } | } | ||||
| inline const std::string& MessageOfNews::news() const | |||||
| inline void MessageOfNews::set_has_text_message() | |||||
| { | { | ||||
| // @@protoc_insertion_point(field_get:protobuf.MessageOfNews.news) | |||||
| return _internal_news(); | |||||
| _impl_._oneof_case_[0] = kTextMessage; | |||||
| } | |||||
| inline void MessageOfNews::clear_text_message() | |||||
| { | |||||
| if (_internal_has_text_message()) | |||||
| { | |||||
| _impl_.news_.text_message_.Destroy(); | |||||
| clear_has_news(); | |||||
| } | |||||
| } | |||||
| inline const std::string& MessageOfNews::text_message() const | |||||
| { | |||||
| // @@protoc_insertion_point(field_get:protobuf.MessageOfNews.text_message) | |||||
| return _internal_text_message(); | |||||
| } | } | ||||
| template<typename ArgT0, typename... ArgT> | template<typename ArgT0, typename... ArgT> | ||||
| inline PROTOBUF_ALWAYS_INLINE void MessageOfNews::set_news(ArgT0&& arg0, ArgT... args) | |||||
| inline void MessageOfNews::set_text_message(ArgT0&& arg0, ArgT... args) | |||||
| { | { | ||||
| _impl_.news_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.news) | |||||
| if (!_internal_has_text_message()) | |||||
| { | |||||
| clear_news(); | |||||
| set_has_text_message(); | |||||
| _impl_.news_.text_message_.InitDefault(); | |||||
| } | |||||
| _impl_.news_.text_message_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.text_message) | |||||
| } | } | ||||
| inline std::string* MessageOfNews::mutable_news() | |||||
| inline std::string* MessageOfNews::mutable_text_message() | |||||
| { | { | ||||
| std::string* _s = _internal_mutable_news(); | |||||
| // @@protoc_insertion_point(field_mutable:protobuf.MessageOfNews.news) | |||||
| std::string* _s = _internal_mutable_text_message(); | |||||
| // @@protoc_insertion_point(field_mutable:protobuf.MessageOfNews.text_message) | |||||
| return _s; | return _s; | ||||
| } | } | ||||
| inline const std::string& MessageOfNews::_internal_news() const | |||||
| inline const std::string& MessageOfNews::_internal_text_message() const | |||||
| { | { | ||||
| return _impl_.news_.Get(); | |||||
| if (_internal_has_text_message()) | |||||
| { | |||||
| return _impl_.news_.text_message_.Get(); | |||||
| } | |||||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||||
| } | } | ||||
| inline void MessageOfNews::_internal_set_news(const std::string& value) | |||||
| inline void MessageOfNews::_internal_set_text_message(const std::string& value) | |||||
| { | { | ||||
| _impl_.news_.Set(value, GetArenaForAllocation()); | |||||
| if (!_internal_has_text_message()) | |||||
| { | |||||
| clear_news(); | |||||
| set_has_text_message(); | |||||
| _impl_.news_.text_message_.InitDefault(); | |||||
| } | |||||
| _impl_.news_.text_message_.Set(value, GetArenaForAllocation()); | |||||
| } | } | ||||
| inline std::string* MessageOfNews::_internal_mutable_news() | |||||
| inline std::string* MessageOfNews::_internal_mutable_text_message() | |||||
| { | { | ||||
| return _impl_.news_.Mutable(GetArenaForAllocation()); | |||||
| if (!_internal_has_text_message()) | |||||
| { | |||||
| clear_news(); | |||||
| set_has_text_message(); | |||||
| _impl_.news_.text_message_.InitDefault(); | |||||
| } | |||||
| return _impl_.news_.text_message_.Mutable(GetArenaForAllocation()); | |||||
| } | } | ||||
| inline std::string* MessageOfNews::release_news() | |||||
| inline std::string* MessageOfNews::release_text_message() | |||||
| { | { | ||||
| // @@protoc_insertion_point(field_release:protobuf.MessageOfNews.news) | |||||
| return _impl_.news_.Release(); | |||||
| // @@protoc_insertion_point(field_release:protobuf.MessageOfNews.text_message) | |||||
| if (_internal_has_text_message()) | |||||
| { | |||||
| clear_has_news(); | |||||
| return _impl_.news_.text_message_.Release(); | |||||
| } | |||||
| else | |||||
| { | |||||
| return nullptr; | |||||
| } | |||||
| } | } | ||||
| inline void MessageOfNews::set_allocated_news(std::string* news) | |||||
| inline void MessageOfNews::set_allocated_text_message(std::string* text_message) | |||||
| { | { | ||||
| if (news != nullptr) | |||||
| if (has_news()) | |||||
| { | { | ||||
| clear_news(); | |||||
| } | |||||
| if (text_message != nullptr) | |||||
| { | |||||
| set_has_text_message(); | |||||
| _impl_.news_.text_message_.InitAllocated(text_message, GetArenaForAllocation()); | |||||
| } | |||||
| // @@protoc_insertion_point(field_set_allocated:protobuf.MessageOfNews.text_message) | |||||
| } | |||||
| // bytes binary_message = 4; | |||||
| inline bool MessageOfNews::_internal_has_binary_message() const | |||||
| { | |||||
| return news_case() == kBinaryMessage; | |||||
| } | |||||
| inline bool MessageOfNews::has_binary_message() const | |||||
| { | |||||
| return _internal_has_binary_message(); | |||||
| } | |||||
| inline void MessageOfNews::set_has_binary_message() | |||||
| { | |||||
| _impl_._oneof_case_[0] = kBinaryMessage; | |||||
| } | |||||
| inline void MessageOfNews::clear_binary_message() | |||||
| { | |||||
| if (_internal_has_binary_message()) | |||||
| { | |||||
| _impl_.news_.binary_message_.Destroy(); | |||||
| clear_has_news(); | |||||
| } | |||||
| } | |||||
| inline const std::string& MessageOfNews::binary_message() const | |||||
| { | |||||
| // @@protoc_insertion_point(field_get:protobuf.MessageOfNews.binary_message) | |||||
| return _internal_binary_message(); | |||||
| } | |||||
| template<typename ArgT0, typename... ArgT> | |||||
| inline void MessageOfNews::set_binary_message(ArgT0&& arg0, ArgT... args) | |||||
| { | |||||
| if (!_internal_has_binary_message()) | |||||
| { | |||||
| clear_news(); | |||||
| set_has_binary_message(); | |||||
| _impl_.news_.binary_message_.InitDefault(); | |||||
| } | |||||
| _impl_.news_.binary_message_.SetBytes(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.binary_message) | |||||
| } | |||||
| inline std::string* MessageOfNews::mutable_binary_message() | |||||
| { | |||||
| std::string* _s = _internal_mutable_binary_message(); | |||||
| // @@protoc_insertion_point(field_mutable:protobuf.MessageOfNews.binary_message) | |||||
| return _s; | |||||
| } | |||||
| inline const std::string& MessageOfNews::_internal_binary_message() const | |||||
| { | |||||
| if (_internal_has_binary_message()) | |||||
| { | |||||
| return _impl_.news_.binary_message_.Get(); | |||||
| } | |||||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||||
| } | |||||
| inline void MessageOfNews::_internal_set_binary_message(const std::string& value) | |||||
| { | |||||
| if (!_internal_has_binary_message()) | |||||
| { | |||||
| clear_news(); | |||||
| set_has_binary_message(); | |||||
| _impl_.news_.binary_message_.InitDefault(); | |||||
| } | |||||
| _impl_.news_.binary_message_.Set(value, GetArenaForAllocation()); | |||||
| } | |||||
| inline std::string* MessageOfNews::_internal_mutable_binary_message() | |||||
| { | |||||
| if (!_internal_has_binary_message()) | |||||
| { | |||||
| clear_news(); | |||||
| set_has_binary_message(); | |||||
| _impl_.news_.binary_message_.InitDefault(); | |||||
| } | |||||
| return _impl_.news_.binary_message_.Mutable(GetArenaForAllocation()); | |||||
| } | |||||
| inline std::string* MessageOfNews::release_binary_message() | |||||
| { | |||||
| // @@protoc_insertion_point(field_release:protobuf.MessageOfNews.binary_message) | |||||
| if (_internal_has_binary_message()) | |||||
| { | |||||
| clear_has_news(); | |||||
| return _impl_.news_.binary_message_.Release(); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| return nullptr; | |||||
| } | |||||
| } | |||||
| inline void MessageOfNews::set_allocated_binary_message(std::string* binary_message) | |||||
| { | |||||
| if (has_news()) | |||||
| { | |||||
| clear_news(); | |||||
| } | } | ||||
| _impl_.news_.SetAllocated(news, GetArenaForAllocation()); | |||||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| if (_impl_.news_.IsDefault()) | |||||
| if (binary_message != nullptr) | |||||
| { | { | ||||
| _impl_.news_.Set("", GetArenaForAllocation()); | |||||
| set_has_binary_message(); | |||||
| _impl_.news_.binary_message_.InitAllocated(binary_message, GetArenaForAllocation()); | |||||
| } | } | ||||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| // @@protoc_insertion_point(field_set_allocated:protobuf.MessageOfNews.news) | |||||
| // @@protoc_insertion_point(field_set_allocated:protobuf.MessageOfNews.binary_message) | |||||
| } | } | ||||
| // int64 from_id = 2; | // int64 from_id = 2; | ||||
| @@ -7714,6 +7907,18 @@ namespace protobuf | |||||
| // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.to_id) | // @@protoc_insertion_point(field_set:protobuf.MessageOfNews.to_id) | ||||
| } | } | ||||
| inline bool MessageOfNews::has_news() const | |||||
| { | |||||
| return news_case() != NEWS_NOT_SET; | |||||
| } | |||||
| inline void MessageOfNews::clear_has_news() | |||||
| { | |||||
| _impl_._oneof_case_[0] = NEWS_NOT_SET; | |||||
| } | |||||
| inline MessageOfNews::NewsCase MessageOfNews::news_case() const | |||||
| { | |||||
| return MessageOfNews::NewsCase(_impl_._oneof_case_[0]); | |||||
| } | |||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| // MessageOfObj | // MessageOfObj | ||||
| @@ -92,7 +92,7 @@ namespace protobuf | |||||
| ::_pbi::ConstantInitialized | ::_pbi::ConstantInitialized | ||||
| ) : | ) : | ||||
| _impl_{ | _impl_{ | ||||
| /*decltype(_impl_.message_)*/ {&::_pbi::fixed_address_empty_string, ::_pbi::ConstantInitialized{}}, /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.to_player_id_)*/ int64_t{0}, /*decltype(_impl_._cached_size_)*/ {}} | |||||
| /*decltype(_impl_. player_id_)*/ int64_t{0}, /*decltype(_impl_.to_player_id_)*/ int64_t{0}, /*decltype(_impl_.message_)*/ {}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}} |
|||||
| { | { | ||||
| } | } | ||||
| struct SendMsgDefaultTypeInternal | struct SendMsgDefaultTypeInternal | ||||
| @@ -235,11 +235,13 @@ const uint32_t TableStruct_Message2Server_2eproto::offsets[] PROTOBUF_SECTION_VA | |||||
| ~0u, // no _has_bits_ | ~0u, // no _has_bits_ | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _internal_metadata_), | PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _internal_metadata_), | ||||
| ~0u, // no _extensions_ | ~0u, // no _extensions_ | ||||
| ~0u, // no _oneof_case_ | |||||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_._oneof_case_[0]), | |||||
| ~0u, // no _weak_field_map_ | ~0u, // no _weak_field_map_ | ||||
| ~0u, // no _inlined_string_donated_ | ~0u, // no _inlined_string_donated_ | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.player_id_), | PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.player_id_), | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.to_player_id_), | PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.to_player_id_), | ||||
| ::_pbi::kInvalidFieldOffsetTag, | |||||
| ::_pbi::kInvalidFieldOffsetTag, | |||||
| PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.message_), | PROTOBUF_FIELD_OFFSET(::protobuf::SendMsg, _impl_.message_), | ||||
| ~0u, // no _has_bits_ | ~0u, // no _has_bits_ | ||||
| PROTOBUF_FIELD_OFFSET(::protobuf::AttackMsg, _internal_metadata_), | PROTOBUF_FIELD_OFFSET(::protobuf::AttackMsg, _internal_metadata_), | ||||
| @@ -278,10 +280,10 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode | |||||
| {11, -1, -1, sizeof(::protobuf::MoveMsg)}, | {11, -1, -1, sizeof(::protobuf::MoveMsg)}, | ||||
| {20, -1, -1, sizeof(::protobuf::PropMsg)}, | {20, -1, -1, sizeof(::protobuf::PropMsg)}, | ||||
| {28, -1, -1, sizeof(::protobuf::SendMsg)}, | {28, -1, -1, sizeof(::protobuf::SendMsg)}, | ||||
| {37, -1, -1, sizeof(::protobuf::AttackMsg)}, | |||||
| {45, -1, -1, sizeof(::protobuf::IDMsg)}, | |||||
| {52, -1, -1, sizeof(::protobuf::TreatAndRescueMsg)}, | |||||
| {60, -1, -1, sizeof(::protobuf::SkillMsg)}, | |||||
| {39, -1, -1, sizeof(::protobuf::AttackMsg)}, | |||||
| {47, -1, -1, sizeof(::protobuf::IDMsg)}, | |||||
| {54, -1, -1, sizeof(::protobuf::TreatAndRescueMsg)}, | |||||
| {62, -1, -1, sizeof(::protobuf::SkillMsg)}, | |||||
| }; | }; | ||||
| static const ::_pb::Message* const file_default_instances[] = { | static const ::_pb::Message* const file_default_instances[] = { | ||||
| @@ -305,13 +307,15 @@ const char descriptor_table_protodef_Message2Server_2eproto[] PROTOBUF_SECTION_V | |||||
| "eMsg\022\021\n\tplayer_id\030\001 \001(\003\022\r\n\005angle\030\002 \001(\001\022\034" | "eMsg\022\021\n\tplayer_id\030\001 \001(\003\022\r\n\005angle\030\002 \001(\001\022\034" | ||||
| "\n\024time_in_milliseconds\030\003 \001(\003\"C\n\007PropMsg\022" | "\n\024time_in_milliseconds\030\003 \001(\003\"C\n\007PropMsg\022" | ||||
| "\021\n\tplayer_id\030\001 \001(\003\022%\n\tprop_type\030\002 \001(\0162\022." | "\021\n\tplayer_id\030\001 \001(\003\022%\n\tprop_type\030\002 \001(\0162\022." | ||||
| "protobuf.PropType\"C\n\007SendMsg\022\021\n\tplayer_i" | |||||
| "d\030\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\022\017\n\007message" | |||||
| "\030\003 \001(\t\"-\n\tAttackMsg\022\021\n\tplayer_id\030\001 \001(\003\022\r" | |||||
| "\n\005angle\030\002 \001(\001\"\032\n\005IDMsg\022\021\n\tplayer_id\030\001 \001(" | |||||
| "\003\"<\n\021TreatAndRescueMsg\022\021\n\tplayer_id\030\001 \001(" | |||||
| "\003\022\024\n\014to_player_id\030\002 \001(\003\"/\n\010SkillMsg\022\021\n\tp" | |||||
| "layer_id\030\001 \001(\003\022\020\n\010skill_id\030\002 \001(\005b\006proto3"; | |||||
| "protobuf.PropType\"o\n\007SendMsg\022\021\n\tplayer_i" | |||||
| "d\030\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\022\026\n\014text_me" | |||||
| "ssage\030\003 \001(\tH\000\022\030\n\016binary_message\030\004 \001(\014H\000B" | |||||
| "\t\n\007message\"-\n\tAttackMsg\022\021\n\tplayer_id\030\001 \001" | |||||
| "(\003\022\r\n\005angle\030\002 \001(\001\"\032\n\005IDMsg\022\021\n\tplayer_id\030" | |||||
| "\001 \001(\003\"<\n\021TreatAndRescueMsg\022\021\n\tplayer_id\030" | |||||
| "\001 \001(\003\022\024\n\014to_player_id\030\002 \001(\003\"/\n\010SkillMsg\022" | |||||
| "\021\n\tplayer_id\030\001 \001(\003\022\020\n\010skill_id\030\002 \001(\005b\006pr" | |||||
| "oto3"; | |||||
| static const ::_pbi::DescriptorTable* const descriptor_table_Message2Server_2eproto_deps[1] = { | static const ::_pbi::DescriptorTable* const descriptor_table_Message2Server_2eproto_deps[1] = { | ||||
| &::descriptor_table_MessageType_2eproto, | &::descriptor_table_MessageType_2eproto, | ||||
| }; | }; | ||||
| @@ -319,7 +323,7 @@ static ::_pbi::once_flag descriptor_table_Message2Server_2eproto_once; | |||||
| const ::_pbi::DescriptorTable descriptor_table_Message2Server_2eproto = { | const ::_pbi::DescriptorTable descriptor_table_Message2Server_2eproto = { | ||||
| false, | false, | ||||
| false, | false, | ||||
| 640, | |||||
| 684, | |||||
| descriptor_table_protodef_Message2Server_2eproto, | descriptor_table_protodef_Message2Server_2eproto, | ||||
| "Message2Server.proto", | "Message2Server.proto", | ||||
| &descriptor_table_Message2Server_2eproto_once, | &descriptor_table_Message2Server_2eproto_once, | ||||
| @@ -1259,18 +1263,28 @@ namespace protobuf | |||||
| SendMsg* const _this = this; | SendMsg* const _this = this; | ||||
| (void)_this; | (void)_this; | ||||
| new (&_impl_) Impl_{ | new (&_impl_) Impl_{ | ||||
| decltype(_impl_.message_){}, decltype(_impl_.player_id_){}, decltype(_impl_.to_player_id_){}, /*decltype(_impl_._cached_size_)*/ {}}; | |||||
| decltype(_impl_.player_id_){}, decltype(_impl_.to_player_id_){}, decltype(_impl_.message_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||||
| _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | ||||
| _impl_.message_.InitDefault(); | |||||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| _impl_.message_.Set("", GetArenaForAllocation()); | |||||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| if (!from._internal_message().empty()) | |||||
| ::memcpy(&_impl_.player_id_, &from._impl_.player_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_player_id_) - reinterpret_cast<char*>(&_impl_.player_id_)) + sizeof(_impl_.to_player_id_)); | |||||
| clear_has_message(); | |||||
| switch (from.message_case()) | |||||
| { | { | ||||
| _this->_impl_.message_.Set(from._internal_message(), _this->GetArenaForAllocation()); | |||||
| case kTextMessage: | |||||
| { | |||||
| _this->_internal_set_text_message(from._internal_text_message()); | |||||
| break; | |||||
| } | |||||
| case kBinaryMessage: | |||||
| { | |||||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||||
| break; | |||||
| } | |||||
| case MESSAGE_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | } | ||||
| ::memcpy(&_impl_.player_id_, &from._impl_.player_id_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_player_id_) - reinterpret_cast<char*>(&_impl_.player_id_)) + sizeof(_impl_.to_player_id_)); | |||||
| // @@protoc_insertion_point(copy_constructor:protobuf.SendMsg) | // @@protoc_insertion_point(copy_constructor:protobuf.SendMsg) | ||||
| } | } | ||||
| @@ -1281,11 +1295,8 @@ namespace protobuf | |||||
| (void)arena; | (void)arena; | ||||
| (void)is_message_owned; | (void)is_message_owned; | ||||
| new (&_impl_) Impl_{ | new (&_impl_) Impl_{ | ||||
| decltype(_impl_.message_){}, decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.to_player_id_){int64_t{0}}, /*decltype(_impl_._cached_size_)*/ {}}; | |||||
| _impl_.message_.InitDefault(); | |||||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| _impl_.message_.Set("", GetArenaForAllocation()); | |||||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.to_player_id_){int64_t{0}}, decltype(_impl_.message_){}, /*decltype(_impl_._cached_size_)*/ {}, /*decltype(_impl_._oneof_case_)*/ {}}; | |||||
| clear_has_message(); | |||||
| } | } | ||||
| SendMsg::~SendMsg() | SendMsg::~SendMsg() | ||||
| @@ -1302,7 +1313,10 @@ namespace protobuf | |||||
| inline void SendMsg::SharedDtor() | inline void SendMsg::SharedDtor() | ||||
| { | { | ||||
| GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); | GOOGLE_DCHECK(GetArenaForAllocation() == nullptr); | ||||
| _impl_.message_.Destroy(); | |||||
| if (has_message()) | |||||
| { | |||||
| clear_message(); | |||||
| } | |||||
| } | } | ||||
| void SendMsg::SetCachedSize(int size) const | void SendMsg::SetCachedSize(int size) const | ||||
| @@ -1310,6 +1324,29 @@ namespace protobuf | |||||
| _impl_._cached_size_.Set(size); | _impl_._cached_size_.Set(size); | ||||
| } | } | ||||
| void SendMsg::clear_message() | |||||
| { | |||||
| // @@protoc_insertion_point(one_of_clear_start:protobuf.SendMsg) | |||||
| switch (message_case()) | |||||
| { | |||||
| case kTextMessage: | |||||
| { | |||||
| _impl_.message_.text_message_.Destroy(); | |||||
| break; | |||||
| } | |||||
| case kBinaryMessage: | |||||
| { | |||||
| _impl_.message_.binary_message_.Destroy(); | |||||
| break; | |||||
| } | |||||
| case MESSAGE_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| _impl_._oneof_case_[0] = MESSAGE_NOT_SET; | |||||
| } | |||||
| void SendMsg::Clear() | void SendMsg::Clear() | ||||
| { | { | ||||
| // @@protoc_insertion_point(message_clear_start:protobuf.SendMsg) | // @@protoc_insertion_point(message_clear_start:protobuf.SendMsg) | ||||
| @@ -1317,8 +1354,8 @@ namespace protobuf | |||||
| // Prevent compiler warnings about cached_has_bits being unused | // Prevent compiler warnings about cached_has_bits being unused | ||||
| (void)cached_has_bits; | (void)cached_has_bits; | ||||
| _impl_.message_.ClearToEmpty(); | |||||
| ::memset(&_impl_.player_id_, 0, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_player_id_) - reinterpret_cast<char*>(&_impl_.player_id_)) + sizeof(_impl_.to_player_id_)); | ::memset(&_impl_.player_id_, 0, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.to_player_id_) - reinterpret_cast<char*>(&_impl_.player_id_)) + sizeof(_impl_.to_player_id_)); | ||||
| clear_message(); | |||||
| _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); | _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); | ||||
| } | } | ||||
| @@ -1353,14 +1390,25 @@ namespace protobuf | |||||
| else | else | ||||
| goto handle_unusual; | goto handle_unusual; | ||||
| continue; | continue; | ||||
| // string message = 3; | |||||
| // string text_message = 3; | |||||
| case 3: | case 3: | ||||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) | if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 26)) | ||||
| { | { | ||||
| auto str = _internal_mutable_message(); | |||||
| auto str = _internal_mutable_text_message(); | |||||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | |||||
| CHK_(ptr); | |||||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.SendMsg.text_message")); | |||||
| } | |||||
| else | |||||
| goto handle_unusual; | |||||
| continue; | |||||
| // bytes binary_message = 4; | |||||
| case 4: | |||||
| if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 34)) | |||||
| { | |||||
| auto str = _internal_mutable_binary_message(); | |||||
| ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | ptr = ::_pbi::InlineGreedyStringParser(str, ptr, ctx); | ||||
| CHK_(ptr); | CHK_(ptr); | ||||
| CHK_(::_pbi::VerifyUTF8(str, "protobuf.SendMsg.message")); | |||||
| } | } | ||||
| else | else | ||||
| goto handle_unusual; | goto handle_unusual; | ||||
| @@ -1413,14 +1461,22 @@ namespace protobuf | |||||
| target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_to_player_id(), target); | target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_to_player_id(), target); | ||||
| } | } | ||||
| // string message = 3; | |||||
| if (!this->_internal_message().empty()) | |||||
| // string text_message = 3; | |||||
| if (_internal_has_text_message()) | |||||
| { | { | ||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( | ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::VerifyUtf8String( | ||||
| this->_internal_message().data(), static_cast<int>(this->_internal_message().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.SendMsg.message" | |||||
| this->_internal_text_message().data(), static_cast<int>(this->_internal_text_message().length()), ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::SERIALIZE, "protobuf.SendMsg.text_message" | |||||
| ); | ); | ||||
| target = stream->WriteStringMaybeAliased( | target = stream->WriteStringMaybeAliased( | ||||
| 3, this->_internal_message(), target | |||||
| 3, this->_internal_text_message(), target | |||||
| ); | |||||
| } | |||||
| // bytes binary_message = 4; | |||||
| if (_internal_has_binary_message()) | |||||
| { | |||||
| target = stream->WriteBytesMaybeAliased( | |||||
| 4, this->_internal_binary_message(), target | |||||
| ); | ); | ||||
| } | } | ||||
| @@ -1443,15 +1499,6 @@ namespace protobuf | |||||
| // Prevent compiler warnings about cached_has_bits being unused | // Prevent compiler warnings about cached_has_bits being unused | ||||
| (void)cached_has_bits; | (void)cached_has_bits; | ||||
| // string message = 3; | |||||
| if (!this->_internal_message().empty()) | |||||
| { | |||||
| total_size += 1 + | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||||
| this->_internal_message() | |||||
| ); | |||||
| } | |||||
| // int64 player_id = 1; | // int64 player_id = 1; | ||||
| if (this->_internal_player_id() != 0) | if (this->_internal_player_id() != 0) | ||||
| { | { | ||||
| @@ -1464,6 +1511,31 @@ namespace protobuf | |||||
| total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_to_player_id()); | total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_to_player_id()); | ||||
| } | } | ||||
| switch (message_case()) | |||||
| { | |||||
| // string text_message = 3; | |||||
| case kTextMessage: | |||||
| { | |||||
| total_size += 1 + | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize( | |||||
| this->_internal_text_message() | |||||
| ); | |||||
| break; | |||||
| } | |||||
| // bytes binary_message = 4; | |||||
| case kBinaryMessage: | |||||
| { | |||||
| total_size += 1 + | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::BytesSize( | |||||
| this->_internal_binary_message() | |||||
| ); | |||||
| break; | |||||
| } | |||||
| case MESSAGE_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); | return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); | ||||
| } | } | ||||
| @@ -1484,10 +1556,6 @@ namespace protobuf | |||||
| uint32_t cached_has_bits = 0; | uint32_t cached_has_bits = 0; | ||||
| (void)cached_has_bits; | (void)cached_has_bits; | ||||
| if (!from._internal_message().empty()) | |||||
| { | |||||
| _this->_internal_set_message(from._internal_message()); | |||||
| } | |||||
| if (from._internal_player_id() != 0) | if (from._internal_player_id() != 0) | ||||
| { | { | ||||
| _this->_internal_set_player_id(from._internal_player_id()); | _this->_internal_set_player_id(from._internal_player_id()); | ||||
| @@ -1496,6 +1564,23 @@ namespace protobuf | |||||
| { | { | ||||
| _this->_internal_set_to_player_id(from._internal_to_player_id()); | _this->_internal_set_to_player_id(from._internal_to_player_id()); | ||||
| } | } | ||||
| switch (from.message_case()) | |||||
| { | |||||
| case kTextMessage: | |||||
| { | |||||
| _this->_internal_set_text_message(from._internal_text_message()); | |||||
| break; | |||||
| } | |||||
| case kBinaryMessage: | |||||
| { | |||||
| _this->_internal_set_binary_message(from._internal_binary_message()); | |||||
| break; | |||||
| } | |||||
| case MESSAGE_NOT_SET: | |||||
| { | |||||
| break; | |||||
| } | |||||
| } | |||||
| _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); | ||||
| } | } | ||||
| @@ -1516,17 +1601,14 @@ namespace protobuf | |||||
| void SendMsg::InternalSwap(SendMsg* other) | void SendMsg::InternalSwap(SendMsg* other) | ||||
| { | { | ||||
| using std::swap; | using std::swap; | ||||
| auto* lhs_arena = GetArenaForAllocation(); | |||||
| auto* rhs_arena = other->GetArenaForAllocation(); | |||||
| _internal_metadata_.InternalSwap(&other->_internal_metadata_); | _internal_metadata_.InternalSwap(&other->_internal_metadata_); | ||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::InternalSwap( | |||||
| &_impl_.message_, lhs_arena, &other->_impl_.message_, rhs_arena | |||||
| ); | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::memswap< | ::PROTOBUF_NAMESPACE_ID::internal::memswap< | ||||
| PROTOBUF_FIELD_OFFSET(SendMsg, _impl_.to_player_id_) + sizeof(SendMsg::_impl_.to_player_id_) - PROTOBUF_FIELD_OFFSET(SendMsg, _impl_.player_id_)>( | PROTOBUF_FIELD_OFFSET(SendMsg, _impl_.to_player_id_) + sizeof(SendMsg::_impl_.to_player_id_) - PROTOBUF_FIELD_OFFSET(SendMsg, _impl_.player_id_)>( | ||||
| reinterpret_cast<char*>(&_impl_.player_id_), | reinterpret_cast<char*>(&_impl_.player_id_), | ||||
| reinterpret_cast<char*>(&other->_impl_.player_id_) | reinterpret_cast<char*>(&other->_impl_.player_id_) | ||||
| ); | ); | ||||
| swap(_impl_.message_, other->_impl_.message_); | |||||
| swap(_impl_._oneof_case_[0], other->_impl_._oneof_case_[0]); | |||||
| } | } | ||||
| ::PROTOBUF_NAMESPACE_ID::Metadata SendMsg::GetMetadata() const | ::PROTOBUF_NAMESPACE_ID::Metadata SendMsg::GetMetadata() const | ||||
| @@ -839,6 +839,13 @@ namespace protobuf | |||||
| { | { | ||||
| return *internal_default_instance(); | return *internal_default_instance(); | ||||
| } | } | ||||
| enum MessageCase | |||||
| { | |||||
| kTextMessage = 3, | |||||
| kBinaryMessage = 4, | |||||
| MESSAGE_NOT_SET = 0, | |||||
| }; | |||||
| static inline const SendMsg* internal_default_instance() | static inline const SendMsg* internal_default_instance() | ||||
| { | { | ||||
| return reinterpret_cast<const SendMsg*>( | return reinterpret_cast<const SendMsg*>( | ||||
| @@ -938,25 +945,11 @@ namespace protobuf | |||||
| enum : int | enum : int | ||||
| { | { | ||||
| kMessageFieldNumber = 3, | |||||
| kPlayerIdFieldNumber = 1, | kPlayerIdFieldNumber = 1, | ||||
| kToPlayerIdFieldNumber = 2, | kToPlayerIdFieldNumber = 2, | ||||
| kTextMessageFieldNumber = 3, | |||||
| kBinaryMessageFieldNumber = 4, | |||||
| }; | }; | ||||
| // string message = 3; | |||||
| void clear_message(); | |||||
| const std::string& message() const; | |||||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||||
| void set_message(ArgT0&& arg0, ArgT... args); | |||||
| std::string* mutable_message(); | |||||
| PROTOBUF_NODISCARD std::string* release_message(); | |||||
| void set_allocated_message(std::string* message); | |||||
| private: | |||||
| const std::string& _internal_message() const; | |||||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_message(const std::string& value); | |||||
| std::string* _internal_mutable_message(); | |||||
| public: | |||||
| // int64 player_id = 1; | // int64 player_id = 1; | ||||
| void clear_player_id(); | void clear_player_id(); | ||||
| int64_t player_id() const; | int64_t player_id() const; | ||||
| @@ -977,10 +970,59 @@ namespace protobuf | |||||
| void _internal_set_to_player_id(int64_t value); | void _internal_set_to_player_id(int64_t value); | ||||
| public: | public: | ||||
| // string text_message = 3; | |||||
| bool has_text_message() const; | |||||
| private: | |||||
| bool _internal_has_text_message() const; | |||||
| public: | |||||
| void clear_text_message(); | |||||
| const std::string& text_message() const; | |||||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||||
| void set_text_message(ArgT0&& arg0, ArgT... args); | |||||
| std::string* mutable_text_message(); | |||||
| PROTOBUF_NODISCARD std::string* release_text_message(); | |||||
| void set_allocated_text_message(std::string* text_message); | |||||
| private: | |||||
| const std::string& _internal_text_message() const; | |||||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_text_message(const std::string& value); | |||||
| std::string* _internal_mutable_text_message(); | |||||
| public: | |||||
| // bytes binary_message = 4; | |||||
| bool has_binary_message() const; | |||||
| private: | |||||
| bool _internal_has_binary_message() const; | |||||
| public: | |||||
| void clear_binary_message(); | |||||
| const std::string& binary_message() const; | |||||
| template<typename ArgT0 = const std::string&, typename... ArgT> | |||||
| void set_binary_message(ArgT0&& arg0, ArgT... args); | |||||
| std::string* mutable_binary_message(); | |||||
| PROTOBUF_NODISCARD std::string* release_binary_message(); | |||||
| void set_allocated_binary_message(std::string* binary_message); | |||||
| private: | |||||
| const std::string& _internal_binary_message() const; | |||||
| inline PROTOBUF_ALWAYS_INLINE void _internal_set_binary_message(const std::string& value); | |||||
| std::string* _internal_mutable_binary_message(); | |||||
| public: | |||||
| void clear_message(); | |||||
| MessageCase message_case() const; | |||||
| // @@protoc_insertion_point(class_scope:protobuf.SendMsg) | // @@protoc_insertion_point(class_scope:protobuf.SendMsg) | ||||
| private: | private: | ||||
| class _Internal; | class _Internal; | ||||
| void set_has_text_message(); | |||||
| void set_has_binary_message(); | |||||
| inline bool has_message() const; | |||||
| inline void clear_has_message(); | |||||
| template<typename T> | template<typename T> | ||||
| friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; | friend class ::PROTOBUF_NAMESPACE_ID::Arena::InternalHelper; | ||||
| @@ -988,10 +1030,20 @@ namespace protobuf | |||||
| typedef void DestructorSkippable_; | typedef void DestructorSkippable_; | ||||
| struct Impl_ | struct Impl_ | ||||
| { | { | ||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr message_; | |||||
| int64_t player_id_; | int64_t player_id_; | ||||
| int64_t to_player_id_; | int64_t to_player_id_; | ||||
| union MessageUnion | |||||
| { | |||||
| constexpr MessageUnion() : | |||||
| _constinit_{} | |||||
| { | |||||
| } | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized _constinit_; | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr text_message_; | |||||
| ::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr binary_message_; | |||||
| } message_; | |||||
| mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; | mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; | ||||
| uint32_t _oneof_case_[1]; | |||||
| }; | }; | ||||
| union | union | ||||
| { | { | ||||
| @@ -2151,63 +2203,216 @@ namespace protobuf | |||||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.to_player_id) | // @@protoc_insertion_point(field_set:protobuf.SendMsg.to_player_id) | ||||
| } | } | ||||
| // string message = 3; | |||||
| inline void SendMsg::clear_message() | |||||
| // string text_message = 3; | |||||
| inline bool SendMsg::_internal_has_text_message() const | |||||
| { | |||||
| return message_case() == kTextMessage; | |||||
| } | |||||
| inline bool SendMsg::has_text_message() const | |||||
| { | |||||
| return _internal_has_text_message(); | |||||
| } | |||||
| inline void SendMsg::set_has_text_message() | |||||
| { | |||||
| _impl_._oneof_case_[0] = kTextMessage; | |||||
| } | |||||
| inline void SendMsg::clear_text_message() | |||||
| { | { | ||||
| _impl_.message_.ClearToEmpty(); | |||||
| if (_internal_has_text_message()) | |||||
| { | |||||
| _impl_.message_.text_message_.Destroy(); | |||||
| clear_has_message(); | |||||
| } | |||||
| } | } | ||||
| inline const std::string& SendMsg::message() const | |||||
| inline const std::string& SendMsg::text_message() const | |||||
| { | { | ||||
| // @@protoc_insertion_point(field_get:protobuf.SendMsg.message) | |||||
| return _internal_message(); | |||||
| // @@protoc_insertion_point(field_get:protobuf.SendMsg.text_message) | |||||
| return _internal_text_message(); | |||||
| } | } | ||||
| template<typename ArgT0, typename... ArgT> | template<typename ArgT0, typename... ArgT> | ||||
| inline PROTOBUF_ALWAYS_INLINE void SendMsg::set_message(ArgT0&& arg0, ArgT... args) | |||||
| inline void SendMsg::set_text_message(ArgT0&& arg0, ArgT... args) | |||||
| { | { | ||||
| _impl_.message_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.message) | |||||
| if (!_internal_has_text_message()) | |||||
| { | |||||
| clear_message(); | |||||
| set_has_text_message(); | |||||
| _impl_.message_.text_message_.InitDefault(); | |||||
| } | |||||
| _impl_.message_.text_message_.Set(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.text_message) | |||||
| } | } | ||||
| inline std::string* SendMsg::mutable_message() | |||||
| inline std::string* SendMsg::mutable_text_message() | |||||
| { | { | ||||
| std::string* _s = _internal_mutable_message(); | |||||
| // @@protoc_insertion_point(field_mutable:protobuf.SendMsg.message) | |||||
| std::string* _s = _internal_mutable_text_message(); | |||||
| // @@protoc_insertion_point(field_mutable:protobuf.SendMsg.text_message) | |||||
| return _s; | return _s; | ||||
| } | } | ||||
| inline const std::string& SendMsg::_internal_message() const | |||||
| inline const std::string& SendMsg::_internal_text_message() const | |||||
| { | { | ||||
| return _impl_.message_.Get(); | |||||
| if (_internal_has_text_message()) | |||||
| { | |||||
| return _impl_.message_.text_message_.Get(); | |||||
| } | |||||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||||
| } | } | ||||
| inline void SendMsg::_internal_set_message(const std::string& value) | |||||
| inline void SendMsg::_internal_set_text_message(const std::string& value) | |||||
| { | { | ||||
| _impl_.message_.Set(value, GetArenaForAllocation()); | |||||
| if (!_internal_has_text_message()) | |||||
| { | |||||
| clear_message(); | |||||
| set_has_text_message(); | |||||
| _impl_.message_.text_message_.InitDefault(); | |||||
| } | |||||
| _impl_.message_.text_message_.Set(value, GetArenaForAllocation()); | |||||
| } | } | ||||
| inline std::string* SendMsg::_internal_mutable_message() | |||||
| inline std::string* SendMsg::_internal_mutable_text_message() | |||||
| { | { | ||||
| return _impl_.message_.Mutable(GetArenaForAllocation()); | |||||
| if (!_internal_has_text_message()) | |||||
| { | |||||
| clear_message(); | |||||
| set_has_text_message(); | |||||
| _impl_.message_.text_message_.InitDefault(); | |||||
| } | |||||
| return _impl_.message_.text_message_.Mutable(GetArenaForAllocation()); | |||||
| } | } | ||||
| inline std::string* SendMsg::release_message() | |||||
| inline std::string* SendMsg::release_text_message() | |||||
| { | { | ||||
| // @@protoc_insertion_point(field_release:protobuf.SendMsg.message) | |||||
| return _impl_.message_.Release(); | |||||
| // @@protoc_insertion_point(field_release:protobuf.SendMsg.text_message) | |||||
| if (_internal_has_text_message()) | |||||
| { | |||||
| clear_has_message(); | |||||
| return _impl_.message_.text_message_.Release(); | |||||
| } | |||||
| else | |||||
| { | |||||
| return nullptr; | |||||
| } | |||||
| } | |||||
| inline void SendMsg::set_allocated_text_message(std::string* text_message) | |||||
| { | |||||
| if (has_message()) | |||||
| { | |||||
| clear_message(); | |||||
| } | |||||
| if (text_message != nullptr) | |||||
| { | |||||
| set_has_text_message(); | |||||
| _impl_.message_.text_message_.InitAllocated(text_message, GetArenaForAllocation()); | |||||
| } | |||||
| // @@protoc_insertion_point(field_set_allocated:protobuf.SendMsg.text_message) | |||||
| } | |||||
| // bytes binary_message = 4; | |||||
| inline bool SendMsg::_internal_has_binary_message() const | |||||
| { | |||||
| return message_case() == kBinaryMessage; | |||||
| } | |||||
| inline bool SendMsg::has_binary_message() const | |||||
| { | |||||
| return _internal_has_binary_message(); | |||||
| } | |||||
| inline void SendMsg::set_has_binary_message() | |||||
| { | |||||
| _impl_._oneof_case_[0] = kBinaryMessage; | |||||
| } | |||||
| inline void SendMsg::clear_binary_message() | |||||
| { | |||||
| if (_internal_has_binary_message()) | |||||
| { | |||||
| _impl_.message_.binary_message_.Destroy(); | |||||
| clear_has_message(); | |||||
| } | |||||
| } | |||||
| inline const std::string& SendMsg::binary_message() const | |||||
| { | |||||
| // @@protoc_insertion_point(field_get:protobuf.SendMsg.binary_message) | |||||
| return _internal_binary_message(); | |||||
| } | |||||
| template<typename ArgT0, typename... ArgT> | |||||
| inline void SendMsg::set_binary_message(ArgT0&& arg0, ArgT... args) | |||||
| { | |||||
| if (!_internal_has_binary_message()) | |||||
| { | |||||
| clear_message(); | |||||
| set_has_binary_message(); | |||||
| _impl_.message_.binary_message_.InitDefault(); | |||||
| } | |||||
| _impl_.message_.binary_message_.SetBytes(static_cast<ArgT0&&>(arg0), args..., GetArenaForAllocation()); | |||||
| // @@protoc_insertion_point(field_set:protobuf.SendMsg.binary_message) | |||||
| } | |||||
| inline std::string* SendMsg::mutable_binary_message() | |||||
| { | |||||
| std::string* _s = _internal_mutable_binary_message(); | |||||
| // @@protoc_insertion_point(field_mutable:protobuf.SendMsg.binary_message) | |||||
| return _s; | |||||
| } | |||||
| inline const std::string& SendMsg::_internal_binary_message() const | |||||
| { | |||||
| if (_internal_has_binary_message()) | |||||
| { | |||||
| return _impl_.message_.binary_message_.Get(); | |||||
| } | |||||
| return ::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(); | |||||
| } | |||||
| inline void SendMsg::_internal_set_binary_message(const std::string& value) | |||||
| { | |||||
| if (!_internal_has_binary_message()) | |||||
| { | |||||
| clear_message(); | |||||
| set_has_binary_message(); | |||||
| _impl_.message_.binary_message_.InitDefault(); | |||||
| } | |||||
| _impl_.message_.binary_message_.Set(value, GetArenaForAllocation()); | |||||
| } | |||||
| inline std::string* SendMsg::_internal_mutable_binary_message() | |||||
| { | |||||
| if (!_internal_has_binary_message()) | |||||
| { | |||||
| clear_message(); | |||||
| set_has_binary_message(); | |||||
| _impl_.message_.binary_message_.InitDefault(); | |||||
| } | |||||
| return _impl_.message_.binary_message_.Mutable(GetArenaForAllocation()); | |||||
| } | } | ||||
| inline void SendMsg::set_allocated_message(std::string* message) | |||||
| inline std::string* SendMsg::release_binary_message() | |||||
| { | { | ||||
| if (message != nullptr) | |||||
| // @@protoc_insertion_point(field_release:protobuf.SendMsg.binary_message) | |||||
| if (_internal_has_binary_message()) | |||||
| { | { | ||||
| clear_has_message(); | |||||
| return _impl_.message_.binary_message_.Release(); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| return nullptr; | |||||
| } | |||||
| } | |||||
| inline void SendMsg::set_allocated_binary_message(std::string* binary_message) | |||||
| { | |||||
| if (has_message()) | |||||
| { | |||||
| clear_message(); | |||||
| } | } | ||||
| _impl_.message_.SetAllocated(message, GetArenaForAllocation()); | |||||
| #ifdef PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| if (_impl_.message_.IsDefault()) | |||||
| if (binary_message != nullptr) | |||||
| { | { | ||||
| _impl_.message_.Set("", GetArenaForAllocation()); | |||||
| set_has_binary_message(); | |||||
| _impl_.message_.binary_message_.InitAllocated(binary_message, GetArenaForAllocation()); | |||||
| } | } | ||||
| #endif // PROTOBUF_FORCE_COPY_DEFAULT_STRING | |||||
| // @@protoc_insertion_point(field_set_allocated:protobuf.SendMsg.message) | |||||
| // @@protoc_insertion_point(field_set_allocated:protobuf.SendMsg.binary_message) | |||||
| } | } | ||||
| inline bool SendMsg::has_message() const | |||||
| { | |||||
| return message_case() != MESSAGE_NOT_SET; | |||||
| } | |||||
| inline void SendMsg::clear_has_message() | |||||
| { | |||||
| _impl_._oneof_case_[0] = MESSAGE_NOT_SET; | |||||
| } | |||||
| inline SendMsg::MessageCase SendMsg::message_case() const | |||||
| { | |||||
| return SendMsg::MessageCase(_impl_._oneof_case_[0]); | |||||
| } | |||||
| // ------------------------------------------------------------------- | // ------------------------------------------------------------------- | ||||
| // AttackMsg | // AttackMsg | ||||
| @@ -25,8 +25,6 @@ | |||||
| #include <grpcpp/impl/codegen/stub_options.h> | #include <grpcpp/impl/codegen/stub_options.h> | ||||
| #include <grpcpp/impl/codegen/sync_stream.h> | #include <grpcpp/impl/codegen/sync_stream.h> | ||||
| #undef SendMessage | |||||
| namespace protobuf | namespace protobuf | ||||
| { | { | ||||
| @@ -2,7 +2,7 @@ import PyAPI.structures as THUAI6 | |||||
| from PyAPI.Interface import ILogic, IStudentAPI, ITrickerAPI, IGameTimer, IAI | from PyAPI.Interface import ILogic, IStudentAPI, ITrickerAPI, IGameTimer, IAI | ||||
| from math import pi | from math import pi | ||||
| from concurrent.futures import ThreadPoolExecutor, Future | from concurrent.futures import ThreadPoolExecutor, Future | ||||
| from typing import List, cast, Tuple | |||||
| from typing import List, cast, Tuple, Union | |||||
| class StudentAPI(IStudentAPI, IGameTimer): | class StudentAPI(IStudentAPI, IGameTimer): | ||||
| @@ -68,13 +68,13 @@ class StudentAPI(IStudentAPI, IGameTimer): | |||||
| # 消息相关,接收消息时无消息则返回(-1, '') | # 消息相关,接收消息时无消息则返回(-1, '') | ||||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||||
| return self.__pool.submit(self.__logic.SendMessage, toID, message) | return self.__pool.submit(self.__logic.SendMessage, toID, message) | ||||
| def HaveMessage(self) -> bool: | def HaveMessage(self) -> bool: | ||||
| return self.__logic.HaveMessage() | return self.__logic.HaveMessage() | ||||
| def GetMessage(self) -> Tuple[int, str]: | |||||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||||
| return self.__logic.GetMessage() | return self.__logic.GetMessage() | ||||
| # 等待下一帧 | # 等待下一帧 | ||||
| @@ -244,13 +244,13 @@ class TrickerAPI(ITrickerAPI, IGameTimer): | |||||
| # 消息相关,接收消息时无消息则返回(-1, '') | # 消息相关,接收消息时无消息则返回(-1, '') | ||||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||||
| return self.__pool.submit(self.__logic.SendMessage, toID, message) | return self.__pool.submit(self.__logic.SendMessage, toID, message) | ||||
| def HaveMessage(self) -> bool: | def HaveMessage(self) -> bool: | ||||
| return self.__logic.HaveMessage() | return self.__logic.HaveMessage() | ||||
| def GetMessage(self) -> Tuple[int, str]: | |||||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||||
| return self.__logic.GetMessage() | return self.__logic.GetMessage() | ||||
| # 等待下一帧 | # 等待下一帧 | ||||
| @@ -7,6 +7,8 @@ import proto.Message2Clients_pb2 as Message2Clients | |||||
| import threading | import threading | ||||
| import grpc | import grpc | ||||
| from typing import Union | |||||
| # 使用gRPC的异步来减少通信对于选手而言损失的时间,而gRPC的return值有result()方法,故若连接错误时也应当返回一个具有result()方法的对象,使用此处的ErrorHandler类来实现 | # 使用gRPC的异步来减少通信对于选手而言损失的时间,而gRPC的return值有result()方法,故若连接错误时也应当返回一个具有result()方法的对象,使用此处的ErrorHandler类来实现 | ||||
| class BoolErrorHandler(IErrorHandler): | class BoolErrorHandler(IErrorHandler): | ||||
| @@ -69,7 +71,7 @@ class Communication: | |||||
| else: | else: | ||||
| return useResult.act_success | return useResult.act_success | ||||
| def SendMessage(self, toID: int, message: str, playerID: int) -> bool: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes], playerID: int) -> bool: | |||||
| try: | try: | ||||
| sendResult = self.__THUAI6Stub.SendMessage( | sendResult = self.__THUAI6Stub.SendMessage( | ||||
| THUAI62Proto.THUAI62ProtobufSend(message, toID, playerID)) | THUAI62Proto.THUAI62ProtobufSend(message, toID, playerID)) | ||||
| @@ -1,6 +1,6 @@ | |||||
| from math import pi | from math import pi | ||||
| from concurrent.futures import ThreadPoolExecutor, Future | from concurrent.futures import ThreadPoolExecutor, Future | ||||
| from typing import List, cast, Tuple | |||||
| from typing import List, cast, Tuple, Union | |||||
| import logging | import logging | ||||
| import os | import os | ||||
| import datetime | import datetime | ||||
| @@ -216,7 +216,7 @@ class StudentDebugAPI(IStudentAPI, IGameTimer): | |||||
| # 消息相关,接收消息时无消息则返回(-1, '') | # 消息相关,接收消息时无消息则返回(-1, '') | ||||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||||
| self.__logger.info( | self.__logger.info( | ||||
| f"SendMessage: toID = {toID}, message = {message}, called at {self.__GetTime()}ms") | f"SendMessage: toID = {toID}, message = {message}, called at {self.__GetTime()}ms") | ||||
| @@ -238,7 +238,7 @@ class StudentDebugAPI(IStudentAPI, IGameTimer): | |||||
| f"HaveMessage: failed at {self.__GetTime()}ms") | f"HaveMessage: failed at {self.__GetTime()}ms") | ||||
| return result | return result | ||||
| def GetMessage(self) -> Tuple[int, str]: | |||||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||||
| self.__logger.info( | self.__logger.info( | ||||
| f"GetMessage: called at {self.__GetTime()}ms") | f"GetMessage: called at {self.__GetTime()}ms") | ||||
| result = self.__logic.GetMessage() | result = self.__logic.GetMessage() | ||||
| @@ -671,7 +671,7 @@ class TrickerDebugAPI(ITrickerAPI, IGameTimer): | |||||
| # 消息相关,接收消息时无消息则返回(-1, '') | # 消息相关,接收消息时无消息则返回(-1, '') | ||||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||||
| self.__logger.info( | self.__logger.info( | ||||
| f"SendMessage: toID = {toID}, message = {message}, called at {self.__GetTime()}ms") | f"SendMessage: toID = {toID}, message = {message}, called at {self.__GetTime()}ms") | ||||
| @@ -693,7 +693,7 @@ class TrickerDebugAPI(ITrickerAPI, IGameTimer): | |||||
| f"HaveMessage: failed at {self.__GetTime()}ms") | f"HaveMessage: failed at {self.__GetTime()}ms") | ||||
| return result | return result | ||||
| def GetMessage(self) -> Tuple[int, str]: | |||||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||||
| self.__logger.info( | self.__logger.info( | ||||
| f"GetMessage: called at {self.__GetTime()}ms") | f"GetMessage: called at {self.__GetTime()}ms") | ||||
| result = self.__logic.GetMessage() | result = self.__logic.GetMessage() | ||||
| @@ -85,7 +85,7 @@ class ILogic(metaclass=ABCMeta): | |||||
| pass | pass | ||||
| @abstractmethod | @abstractmethod | ||||
| def SendMessage(self, toID: int, message: str) -> bool: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> bool: | |||||
| pass | pass | ||||
| @abstractmethod | @abstractmethod | ||||
| @@ -235,7 +235,7 @@ class IAPI(metaclass=ABCMeta): | |||||
| # 消息相关,接收消息时无消息则返回(-1, '') | # 消息相关,接收消息时无消息则返回(-1, '') | ||||
| @abstractmethod | @abstractmethod | ||||
| def SendMessage(self, toID: int, message: str) -> Future[bool]: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> Future[bool]: | |||||
| pass | pass | ||||
| @abstractmethod | @abstractmethod | ||||
| @@ -188,7 +188,7 @@ class Logic(ILogic): | |||||
| self.__logger.debug("Called UseSkill") | self.__logger.debug("Called UseSkill") | ||||
| return self.__comm.UseSkill(skillID, self.__playerID) | return self.__comm.UseSkill(skillID, self.__playerID) | ||||
| def SendMessage(self, toID: int, message: str) -> bool: | |||||
| def SendMessage(self, toID: int, message: Union[str, bytes]) -> bool: | |||||
| self.__logger.debug("Called SendMessage") | self.__logger.debug("Called SendMessage") | ||||
| return self.__comm.SendMessage(toID, message, self.__playerID) | return self.__comm.SendMessage(toID, message, self.__playerID) | ||||
| @@ -196,7 +196,7 @@ class Logic(ILogic): | |||||
| self.__logger.debug("Called HaveMessage") | self.__logger.debug("Called HaveMessage") | ||||
| return not self.__messageQueue.empty() | return not self.__messageQueue.empty() | ||||
| def GetMessage(self) -> Tuple[int, str]: | |||||
| def GetMessage(self) -> Tuple[int, Union[str, bytes]]: | |||||
| self.__logger.debug("Called GetMessage") | self.__logger.debug("Called GetMessage") | ||||
| if self.__messageQueue.empty(): | if self.__messageQueue.empty(): | ||||
| self.__logger.warning("Message queue is empty!") | self.__logger.warning("Message queue is empty!") | ||||
| @@ -314,13 +314,13 @@ class Logic(ILogic): | |||||
| else: | else: | ||||
| self.__logger.error("Unknown GameState!") | self.__logger.error("Unknown GameState!") | ||||
| continue | continue | ||||
| self.__AILoop = False | |||||
| with self.__cvBuffer: | with self.__cvBuffer: | ||||
| self.__bufferUpdated = True | self.__bufferUpdated = True | ||||
| self.__counterBuffer = -1 | self.__counterBuffer = -1 | ||||
| self.__cvBuffer.notify() | self.__cvBuffer.notify() | ||||
| self.__logger.info("Game End!") | self.__logger.info("Game End!") | ||||
| self.__logger.info("Message thread end!") | self.__logger.info("Message thread end!") | ||||
| self.__AILoop = False | |||||
| threading.Thread(target=messageThread).start() | threading.Thread(target=messageThread).start() | ||||
| @@ -438,9 +438,16 @@ class Logic(ILogic): | |||||
| self.__logger.debug("Update Gate!") | self.__logger.debug("Update Gate!") | ||||
| elif item.WhichOneof("message_of_obj") == "news_message": | elif item.WhichOneof("message_of_obj") == "news_message": | ||||
| if item.news_message.to_id == self.__playerID: | if item.news_message.to_id == self.__playerID: | ||||
| self.__messageQueue.put( | |||||
| (item.news_message.from_id, item.news_message.news)) | |||||
| self.__logger.debug("Add News!") | |||||
| if item.news_message.WhichOneof("news") == "text_message": | |||||
| self.__messageQueue.put( | |||||
| (item.news_message.from_id, item.news_message.text_message)) | |||||
| self.__logger.debug("Add News!") | |||||
| elif item.news_message.WhichOneof("news") == "binary_message": | |||||
| self.__messageQueue.put( | |||||
| (item.news_message.from_id, item.news_message.binary_message)) | |||||
| self.__logger.debug("Add News!") | |||||
| else: | |||||
| self.__logger.error("Unknown News!") | |||||
| else: | else: | ||||
| self.__logger.debug( | self.__logger.debug( | ||||
| "Unknown Message!") | "Unknown Message!") | ||||
| @@ -12,6 +12,7 @@ import argparse | |||||
| import platform | import platform | ||||
| import PyAPI.structures as THUAI6 | import PyAPI.structures as THUAI6 | ||||
| def PrintWelcomeString() -> None: | def PrintWelcomeString() -> None: | ||||
| # Generated by http://www.network-science.de/ascii/ with font "standard" | # Generated by http://www.network-science.de/ascii/ with font "standard" | ||||
| welcomeString = """ | welcomeString = """ | ||||
| @@ -32,6 +33,7 @@ def PrintWelcomeString() -> None: | |||||
| """ | """ | ||||
| print(welcomeString) | print(welcomeString) | ||||
| def THUAI6Main(argv: List[str], AIBuilder: Callable) -> None: | def THUAI6Main(argv: List[str], AIBuilder: Callable) -> None: | ||||
| pID: int = 0 | pID: int = 0 | ||||
| sIP: str = "127.0.0.1" | sIP: str = "127.0.0.1" | ||||
| @@ -2,7 +2,7 @@ import proto.MessageType_pb2 as MessageType | |||||
| import proto.Message2Server_pb2 as Message2Server | import proto.Message2Server_pb2 as Message2Server | ||||
| import proto.Message2Clients_pb2 as Message2Clients | import proto.Message2Clients_pb2 as Message2Clients | ||||
| import PyAPI.structures as THUAI6 | import PyAPI.structures as THUAI6 | ||||
| from typing import Final, List | |||||
| from typing import Final, List, Union | |||||
| numOfGridPerCell: Final[int] = 1000 | numOfGridPerCell: Final[int] = 1000 | ||||
| @@ -350,8 +350,11 @@ class THUAI62Proto(NoInstance): | |||||
| return Message2Server.PropMsg(player_id=id, prop_type=THUAI62Proto.propTypeDict[prop]) | return Message2Server.PropMsg(player_id=id, prop_type=THUAI62Proto.propTypeDict[prop]) | ||||
| @ staticmethod | @ staticmethod | ||||
| def THUAI62ProtobufSend(msg: str, toID: int, id: int) -> Message2Server.SendMsg: | |||||
| return Message2Server.SendMsg(player_id=id, to_player_id=toID, message=msg) | |||||
| def THUAI62ProtobufSend(msg: Union[str, bytes], toID: int, id: int) -> Message2Server.SendMsg: | |||||
| if isinstance(msg, str): | |||||
| return Message2Server.SendMsg(player_id=id, to_player_id=toID, text_message=msg) | |||||
| elif isinstance(msg, bytes): | |||||
| return Message2Server.SendMsg(player_id=id, to_player_id=toID, binary_message=msg) | |||||
| @ staticmethod | @ staticmethod | ||||
| def THUAI62ProtobufAttack(angle: float, id: int) -> Message2Server.AttackMsg: | def THUAI62ProtobufAttack(angle: float, id: int) -> Message2Server.AttackMsg: | ||||
| @@ -1,3 +1,3 @@ | |||||
| grpcio==1.52.0 | |||||
| grpcio-tools==1.52.0 | |||||
| grpcio==1.54.0 | |||||
| grpcio-tools==1.54.0 | |||||
| numpy | numpy | ||||
| @@ -1,7 +1,7 @@ | |||||
| #!/usr/bin/env bash | #!/usr/bin/env bash | ||||
| python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 0& | |||||
| python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 0 -d -o& | |||||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 1 -o& | # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 1 -o& | ||||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 2& | # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 2& | ||||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 3& | # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 3& | ||||
| python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 4 -d& | |||||
| # python PyAPI/main.py -I 172.22.32.1 -P 8888 -p 4& | |||||
| @@ -143,7 +143,11 @@ message MessageOfMap | |||||
| message MessageOfNews | message MessageOfNews | ||||
| { | { | ||||
| string news = 1; | |||||
| oneof news // 一条新闻 | |||||
| { | |||||
| string text_message = 1; | |||||
| bytes binary_message = 4; | |||||
| } | |||||
| int64 from_id = 2; | int64 from_id = 2; | ||||
| int64 to_id = 3; | int64 to_id = 3; | ||||
| } | } | ||||
| @@ -32,7 +32,12 @@ message SendMsg | |||||
| { | { | ||||
| int64 player_id = 1; | int64 player_id = 1; | ||||
| int64 to_player_id = 2; | int64 to_player_id = 2; | ||||
| string message = 3; | |||||
| oneof message | |||||
| { | |||||
| string text_message = 3; | |||||
| bytes binary_message = 4; | |||||
| } | |||||
| } | } | ||||
| message AttackMsg // 相当于攻击 | message AttackMsg // 相当于攻击 | ||||
| @@ -18,7 +18,7 @@ | |||||
| <PackageReference Include="Google.Protobuf.Tools" Version="3.22.3" /> | <PackageReference Include="Google.Protobuf.Tools" Version="3.22.3" /> | ||||
| <PackageReference Include="Grpc" Version="2.46.6" /> | <PackageReference Include="Grpc" Version="2.46.6" /> | ||||
| <PackageReference Include="Grpc.Core" Version="2.46.6" /> | <PackageReference Include="Grpc.Core" Version="2.46.6" /> | ||||
| <PackageReference Include="Grpc.Tools" Version="2.53.0"> | |||||
| <PackageReference Include="Grpc.Tools" Version="2.54.0"> | |||||
| <PrivateAssets>all</PrivateAssets> | <PrivateAssets>all</PrivateAssets> | ||||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||||
| </PackageReference> | </PackageReference> | ||||
| @@ -0,0 +1,205 @@ | |||||
| import os | |||||
| import json | |||||
| import re | |||||
| winGamesMap = {} | |||||
| totalGamesMap = {} | |||||
| studentTotalGame = {} | |||||
| trickerTotalGame = {} | |||||
| winRateMap = {} | |||||
| studentWinMap = {} | |||||
| trickerWinMap = {} | |||||
| studentWinRateMap = {} | |||||
| trickerWinRateMap = {} | |||||
| winGamesMap1 = {} | |||||
| totalGamesMap1 = {} | |||||
| studentTotalGame1 = {} | |||||
| trickerTotalGame1 = {} | |||||
| winRateMap1 = {} | |||||
| studentWinMap1 = {} | |||||
| trickerWinMap1 = {} | |||||
| studentWinRateMap1 = {} | |||||
| trickerWinRateMap1 = {} | |||||
| studentWinNum = 0 | |||||
| trickerWinNum = 0 | |||||
| totalGameNum = 0 | |||||
| studentWinNum1 = 0 | |||||
| trickerWinNum1 = 0 | |||||
| totalGameNum1 = 0 | |||||
| teamIDtoName = { | |||||
| "951c89eb-aa9c-45d4-af10-ad9785a047d6": "无名万物之始", "2e504ec6-50b1-4985-b2fd-995927ea9717": "LQ说什么都队", "fb472ad6-65e0-494b-a7be-f6f25ecda018": "是啊我诶", | |||||
| "3376909b-5ddb-41ab-994c-3c5b5ba60158": "叛逃者联盟", | |||||
| "9b0f2257-734c-42e2-8061-c267e3d0d231": "ChatGPA", | |||||
| "2de908c9-1b99-4811-ae00-68140d1c4527": "昊天上帝和他的三个神父", | |||||
| "94866510-af51-439c-a41a-b4cb42596e25": "少年毕不了业", | |||||
| "4613ef48-4988-4508-a258-66857a3250b8": "PKT48TeamTS", | |||||
| "8e14b2a3-fc37-4fb6-b8ac-a722a10707d7": "京ICP备2022019669号-1 2022 EESAST", | |||||
| "e8db213c-a636-483f-a6ed-84310b3093a4": "拉拉队", | |||||
| "04abd472-ed7a-4840-8680-87d20db52721": "努力少女戏尔危", | |||||
| "2bc1b761-ace3-4403-af83-e46ca328bcd0": "测试", | |||||
| "4c1d6333-e25c-4b0f-bc06-9851db446bd7": "摆烂吧,少女", | |||||
| "7f819704-99c0-41d8-bc61-26eec0bd73bb": "一会吃萤火虫", | |||||
| "de915bbf-0751-4a9d-ab30-a470807406b2": "小小做题家", | |||||
| "28baa2bf-5130-4a1e-ab9c-36e8faf87f84": "数析少女队", | |||||
| "5c868c42-3b07-4280-a825-a6f80e0d5a2c": "沙壁北京", | |||||
| "ed03d1ac-810a-4547-b54a-d56cd5213364": "我会出手队", | |||||
| "5d59e45f-cb0e-4294-90f4-282adb1d476d": "闪电骑士团", | |||||
| "637e20c1-a904-4f6f-b706-2cea7c4daf5e": "Mukava Poikaa", | |||||
| "7185eb49-0cb0-43c0-a469-a39e636d66d4": "劝退吧,少女", | |||||
| "d2a7ba71-4a86-4278-a362-8a8953a368f8": "纵火犯在何方", | |||||
| "4e266301-7749-4699-b2de-511d458cf537": "土木清华没有水", | |||||
| "454f37bd-2f54-4463-94d9-2df9aedb4f21": "电电做不队", | |||||
| "a2573713-28e4-4af7-8c53-ab21f385f789": "王牌飞行队", | |||||
| "194c3ddf-6846-47ec-a262-ca24f5639531": "快乐Debug", | |||||
| "97cf5969-e8ff-410e-b85c-0c8359923289": "卷动量守恒", | |||||
| "4646739a-9ff5-4854-a3b2-27d5b85ea504": "龙井队", | |||||
| "c431d105-a2b3-4659-b713-6bc97132ec7f": "疯狂Thurs队", | |||||
| "9ee48de1-a76a-40eb-b267-59c985bbe6cb": "蒸馍", | |||||
| "5ef8ffbb-0776-4a74-a84f-3d80d5b4c2ae": "你说什么都队", | |||||
| "65f94306-69c7-42a2-8c68-44cb45749aae": "closeAI", | |||||
| "ab0406ae-6a0e-4c1e-9d36-eb14115de076": "N/A", | |||||
| "82cbff06-9ed1-429b-afc3-7e050318bf93": "代码一行都不队", | |||||
| "6b52346c-4528-424b-ac75-22fa573ebaad": "pqfobj", | |||||
| "93e7f3f1-d47f-4588-b433-72877089f0bd": "你说得队", | |||||
| "2f6f9ce3-f2d3-4799-b291-38dc04d048a0": "少女终末旅行", | |||||
| "07c0ad6c-f612-4375-9b79-52bb89c79d76": "大括号换行委员会", | |||||
| "bdf5b1c5-4dbc-4589-a6bc-8c5932c04de7": "孤客若风", | |||||
| "f0d75eee-34a6-4484-8e23-720d26db747d": "/", | |||||
| "acea715f-d5b0-4113-b6c3-9f6d7822f2e9": "难崩" | |||||
| } | |||||
| dirs = os.listdir(".") | |||||
| for dir in dirs: | |||||
| if dir.startswith("Team"): | |||||
| dirdir = dir.replace("Team_", "") | |||||
| dirdir = dirdir.split("--vs--") | |||||
| try: | |||||
| with open(f"{dir}/result.json", 'r') as f: | |||||
| result = json.load(f) | |||||
| for i in (0, 1): | |||||
| if dirdir[i] not in winGamesMap: | |||||
| winGamesMap[dirdir[i]] = 0 | |||||
| if dirdir[i] not in totalGamesMap: | |||||
| totalGamesMap[dirdir[i]] = 0 | |||||
| if dirdir[i] not in studentWinMap: | |||||
| studentWinMap[dirdir[i]] = 0 | |||||
| if dirdir[i] not in trickerWinMap: | |||||
| trickerWinMap[dirdir[i]] = 0 | |||||
| if dirdir[i] not in studentTotalGame: | |||||
| studentTotalGame[dirdir[i]] = 0 | |||||
| if dirdir[i] not in trickerTotalGame: | |||||
| trickerTotalGame[dirdir[i]] = 0 | |||||
| if dirdir[i] not in winGamesMap1: | |||||
| winGamesMap1[dirdir[i]] = 0 | |||||
| if dirdir[i] not in totalGamesMap1: | |||||
| totalGamesMap1[dirdir[i]] = 0 | |||||
| if dirdir[i] not in studentWinMap1: | |||||
| studentWinMap1[dirdir[i]] = 0 | |||||
| if dirdir[i] not in trickerWinMap1: | |||||
| trickerWinMap1[dirdir[i]] = 0 | |||||
| if dirdir[i] not in studentTotalGame1: | |||||
| studentTotalGame1[dirdir[i]] = 0 | |||||
| if dirdir[i] not in trickerTotalGame1: | |||||
| trickerTotalGame1[dirdir[i]] = 0 | |||||
| totalGamesMap[dirdir[0]] += 1 | |||||
| totalGamesMap[dirdir[1]] += 1 | |||||
| studentTotalGame[dirdir[0]] += 1 | |||||
| trickerTotalGame[dirdir[1]] += 1 | |||||
| totalGameNum += 1 | |||||
| if result["Student"] < result["Tricker"]: | |||||
| winGamesMap[dirdir[1]] += 1 | |||||
| trickerWinMap[dirdir[1]] += 1 | |||||
| trickerWinNum += 1 | |||||
| elif result["Student"] > result["Tricker"]: | |||||
| winGamesMap[dirdir[0]] += 1 | |||||
| studentWinMap[dirdir[0]] += 1 | |||||
| studentWinNum += 1 | |||||
| else: | |||||
| winGamesMap[dirdir[0]] += 0.5 | |||||
| winGamesMap[dirdir[1]] += 0.5 | |||||
| if result["Student"] != 0 and result["Tricker"] != 0: | |||||
| totalGameNum1 += 1 | |||||
| totalGamesMap1[dirdir[0]] += 1 | |||||
| totalGamesMap1[dirdir[1]] += 1 | |||||
| studentTotalGame1[dirdir[0]] += 1 | |||||
| trickerTotalGame1[dirdir[1]] += 1 | |||||
| if result["Student"] < result["Tricker"]: | |||||
| winGamesMap1[dirdir[1]] += 1 | |||||
| trickerWinMap1[dirdir[1]] += 1 | |||||
| trickerWinNum1 += 1 | |||||
| elif result["Student"] > result["Tricker"]: | |||||
| winGamesMap1[dirdir[0]] += 1 | |||||
| studentWinMap1[dirdir[0]] += 1 | |||||
| studentWinNum1 += 1 | |||||
| else: | |||||
| winGamesMap1[dirdir[0]] += 0.5 | |||||
| winGamesMap1[dirdir[1]] += 0.5 | |||||
| except: | |||||
| pass | |||||
| for i in totalGamesMap: | |||||
| winRateMap[i] = winGamesMap[i] / totalGamesMap[i] | |||||
| if studentTotalGame[i] == 0: | |||||
| studentWinRateMap[i] = 0 | |||||
| else: | |||||
| studentWinRateMap[i] = studentWinMap[i] / studentTotalGame[i] | |||||
| if trickerTotalGame[i] == 0: | |||||
| trickerWinRateMap[i] = 0 | |||||
| else: | |||||
| trickerWinRateMap[i] = trickerWinMap[i] / trickerTotalGame[i] | |||||
| sortedMap = sorted(winRateMap.items(), key=lambda kv: ( | |||||
| kv[1], kv[0]), reverse=True) | |||||
| print("************************ALL GAMES(with 0 player)************************") | |||||
| for i in sortedMap: | |||||
| width = 33 - len(re.findall('([\u4e00-\u9fa5])', teamIDtoName[i[0]])) | |||||
| print( | |||||
| f"Team {teamIDtoName[i[0]]:{width}}({i[0]}) wins {winGamesMap[i[0]]:4}/{totalGamesMap[i[0]]:<2} games({i[1]:.3f}), student wins {studentWinMap[i[0]]:2}/{studentTotalGame[i[0]]:<2}({studentWinRateMap[i[0]]:.3f}), tricker wins {trickerWinMap[i[0]]:2}/{trickerTotalGame[i[0]]:<2}({trickerWinRateMap[i[0]]:.3f})") | |||||
| print( | |||||
| f"Total games: {totalGameNum}, student wins {studentWinNum}, tricker wins {trickerWinNum}") | |||||
| for i in totalGamesMap1: | |||||
| if totalGamesMap1[i] == 0: | |||||
| winRateMap1[i] = 0 | |||||
| else: | |||||
| winRateMap1[i] = winGamesMap1[i] / totalGamesMap1[i] | |||||
| if studentTotalGame1[i] == 0: | |||||
| studentWinRateMap1[i] = 0 | |||||
| else: | |||||
| studentWinRateMap1[i] = studentWinMap1[i] / studentTotalGame1[i] | |||||
| if trickerTotalGame1[i] == 0: | |||||
| trickerWinRateMap1[i] = 0 | |||||
| else: | |||||
| trickerWinRateMap1[i] = trickerWinMap1[i] / trickerTotalGame1[i] | |||||
| sortedMap1 = sorted(winRateMap1.items(), key=lambda kv: ( | |||||
| kv[1], kv[0]), reverse=True) | |||||
| print("************************NON-0 GAMES(no 0 player)************************") | |||||
| for i in sortedMap1: | |||||
| width = 33 - len(re.findall('([\u4e00-\u9fa5])', teamIDtoName[i[0]])) | |||||
| print(f"Team {teamIDtoName[i[0]]:{width}}({i[0]}) wins {winGamesMap1[i[0]]:4}/{totalGamesMap1[i[0]]:<2} games({i[1]:.3f}), student wins {studentWinMap1[i[0]]:2}/{studentTotalGame1[i[0]]:<2}({studentWinRateMap1[i[0]]:.3f}), tricker wins {trickerWinMap1[i[0]]:2}/{trickerTotalGame1[i[0]]:<2}({trickerWinRateMap1[i[0]]:.3f})") | |||||
| print( | |||||
| f"Total games: {totalGameNum1}, student wins {studentWinNum1}, tricker wins {trickerWinNum1}") | |||||
| @@ -51,7 +51,7 @@ if [ -f $playback_dir/start.lock ]; then | |||||
| while [ $? -eq 0 ] | while [ $? -eq 0 ] | ||||
| do | do | ||||
| sleep 1 | sleep 1 | ||||
| ps -p $server_pid | |||||
| ps -p $server_pid > /dev/null 2>&1 | |||||
| done | done | ||||
| touch $playback_dir/finish.lock | touch $playback_dir/finish.lock | ||||
| echo "Finish" | echo "Finish" | ||||
| @@ -170,7 +170,7 @@ start cmd /k win64\Client.exe --cl --playbackFile .\video.thuaipb --playbackSpee | |||||
| ## WPF简易调试界面 | ## WPF简易调试界面 | ||||
|  | |||||
|  | |||||
| ### 界面介绍 | ### 界面介绍 | ||||
| @@ -10,8 +10,17 @@ | |||||
| <Window.Resources> | <Window.Resources> | ||||
| <ImageBrush x:Key="Logo" ImageSource="Logo.png"/> | <ImageBrush x:Key="Logo" ImageSource="Logo.png"/> | ||||
| <RoutedUICommand x:Key="maximize_Pressed" Text="maximize_Pressed"/> | |||||
| </Window.Resources> | </Window.Resources> | ||||
| <Window.CommandBindings> | |||||
| <CommandBinding Command="{StaticResource maximize_Pressed}" Executed="ClickToMaxmize"/> | |||||
| </Window.CommandBindings> | |||||
| <Window.InputBindings> | |||||
| <KeyBinding Key="F11" Command="{StaticResource maximize_Pressed}"/> | |||||
| </Window.InputBindings> | |||||
| <Grid Name="MainGrid" Margin="0,0,0,0"> | <Grid Name="MainGrid" Margin="0,0,0,0"> | ||||
| <!--Title行删去了两个赋值语句,等之后补回来--> | <!--Title行删去了两个赋值语句,等之后补回来--> | ||||
| <Grid.RowDefinitions> | <Grid.RowDefinitions> | ||||
| @@ -48,7 +48,7 @@ namespace Gaming | |||||
| { | { | ||||
| case GameObjType.Character: | case GameObjType.Character: | ||||
| if ((!(((Character)objBeingShot).IsGhost())) && bullet.Parent.IsGhost()) | |||||
| if ((!(((Character)objBeingShot).IsGhost())) && bullet.Parent!.IsGhost()) | |||||
| { | { | ||||
| characterManager.BeAttacked((Student)objBeingShot, bullet); | characterManager.BeAttacked((Student)objBeingShot, bullet); | ||||
| } | } | ||||
| @@ -57,7 +57,7 @@ namespace Gaming | |||||
| break; | break; | ||||
| case GameObjType.Generator: | case GameObjType.Generator: | ||||
| if (bullet.CanBeBombed(GameObjType.Generator)) | if (bullet.CanBeBombed(GameObjType.Generator)) | ||||
| ((Generator)objBeingShot).Repair(-bullet.AP * GameData.factorDamageGenerator, (Character)bullet.Parent); | |||||
| ((Generator)objBeingShot).Repair(-bullet.AP * GameData.factorDamageGenerator, (Character)bullet.Parent!); | |||||
| break; | break; | ||||
| default: | default: | ||||
| break; | break; | ||||
| @@ -101,12 +101,12 @@ namespace Gaming | |||||
| { | { | ||||
| if (objBeingShot == null) | if (objBeingShot == null) | ||||
| { | { | ||||
| characterManager.BackSwing((Character)bullet.Parent, bullet.Backswing); | |||||
| characterManager.BackSwing((Character)bullet.Parent!, bullet.Backswing); | |||||
| return; | return; | ||||
| } | } | ||||
| BombObj(bullet, objBeingShot); | BombObj(bullet, objBeingShot); | ||||
| characterManager.BackSwing((Character)bullet.Parent, bullet.RecoveryFromHit); | |||||
| characterManager.BackSwing((Character)bullet.Parent!, bullet.RecoveryFromHit); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -122,7 +122,7 @@ namespace Gaming | |||||
| if (bullet.TypeOfBullet == BulletType.BombBomb && objBeingShot != null) | if (bullet.TypeOfBullet == BulletType.BombBomb && objBeingShot != null) | ||||
| { | { | ||||
| bullet.Parent.BulletOfPlayer = BulletType.JumpyDumpty; | |||||
| bullet.Parent!.BulletOfPlayer = BulletType.JumpyDumpty; | |||||
| Debugger.Output(bullet.Parent, bullet.Parent.CharacterType.ToString() + " " + bullet.Parent.BulletNum.ToString()); | Debugger.Output(bullet.Parent, bullet.Parent.CharacterType.ToString() + " " + bullet.Parent.BulletNum.ToString()); | ||||
| Attack((Character)bullet.Parent, bullet.FacingDirection.Angle() + Math.PI / 2.0); | Attack((Character)bullet.Parent, bullet.FacingDirection.Angle() + Math.PI / 2.0); | ||||
| Attack((Character)bullet.Parent, bullet.FacingDirection.Angle() + Math.PI * 3.0 / 2.0); | Attack((Character)bullet.Parent, bullet.FacingDirection.Angle() + Math.PI * 3.0 / 2.0); | ||||
| @@ -159,10 +159,10 @@ namespace Gaming | |||||
| if (objBeingShot == null) | if (objBeingShot == null) | ||||
| { | { | ||||
| characterManager.BackSwing((Character)bullet.Parent, bullet.Backswing); | |||||
| characterManager.BackSwing((Character)bullet.Parent!, bullet.Backswing); | |||||
| } | } | ||||
| else | else | ||||
| characterManager.BackSwing((Character)bullet.Parent, bullet.RecoveryFromHit); | |||||
| characterManager.BackSwing((Character)bullet.Parent!, bullet.RecoveryFromHit); | |||||
| } | } | ||||
| public bool Attack(Character player, double angle) | public bool Attack(Character player, double angle) | ||||
| @@ -25,11 +25,11 @@ namespace Gaming | |||||
| switch (player.PlayerState) | switch (player.PlayerState) | ||||
| { | { | ||||
| case PlayerStateType.OpeningTheChest: | case PlayerStateType.OpeningTheChest: | ||||
| ((Chest)player.WhatInteractingWith).StopOpen(); | |||||
| ((Chest)player.WhatInteractingWith!).StopOpen(); | |||||
| player.ChangePlayerState(value, gameObj); | player.ChangePlayerState(value, gameObj); | ||||
| break; | break; | ||||
| case PlayerStateType.OpeningTheDoorway: | case PlayerStateType.OpeningTheDoorway: | ||||
| Doorway doorway = (Doorway)player.WhatInteractingWith; | |||||
| Doorway doorway = (Doorway)player.WhatInteractingWith!; | |||||
| doorway.OpenDegree += gameMap.Timer.nowTime() - doorway.OpenStartTime; | doorway.OpenDegree += gameMap.Timer.nowTime() - doorway.OpenStartTime; | ||||
| doorway.OpenStartTime = 0; | doorway.OpenStartTime = 0; | ||||
| player.ChangePlayerState(value, gameObj); | player.ChangePlayerState(value, gameObj); | ||||
| @@ -302,7 +302,7 @@ namespace Gaming | |||||
| if (character.CanBeAwed()) | if (character.CanBeAwed()) | ||||
| { | { | ||||
| if (BeStunned(character, GameData.basicStunnedTimeOfStudent)) | if (BeStunned(character, GameData.basicStunnedTimeOfStudent)) | ||||
| bullet.Parent.AddScore(GameData.TrickerScoreStudentBeStunned(GameData.basicStunnedTimeOfStudent)); | |||||
| bullet.Parent!.AddScore(GameData.TrickerScoreStudentBeStunned(GameData.basicStunnedTimeOfStudent)); | |||||
| return true; | return true; | ||||
| } | } | ||||
| return false; | return false; | ||||
| @@ -321,7 +321,7 @@ namespace Gaming | |||||
| Debugger.Output(student, "is being shot!"); | Debugger.Output(student, "is being shot!"); | ||||
| #endif | #endif | ||||
| if (student.NoHp()) return; // 原来已经死了 | if (student.NoHp()) return; // 原来已经死了 | ||||
| if (!bullet.Parent.IsGhost()) return; | |||||
| if (!bullet.Parent!.IsGhost()) return; | |||||
| if (student.CharacterType == CharacterType.StraightAStudent) | if (student.CharacterType == CharacterType.StraightAStudent) | ||||
| { | { | ||||
| @@ -413,9 +413,10 @@ namespace Gaming | |||||
| } | } | ||||
| if (player.CharacterType == CharacterType.Robot) | if (player.CharacterType == CharacterType.Robot) | ||||
| { | { | ||||
| if (((Golem)player).Parent != null && ((Golem)player).Parent.CharacterType == CharacterType.TechOtaku) | |||||
| var parent = ((Golem)player).Parent; | |||||
| if (parent != null && parent.CharacterType == CharacterType.TechOtaku) | |||||
| { | { | ||||
| ((SummonGolem)(((Golem)player).Parent.FindIActiveSkill(ActiveSkillType.SummonGolem))).GolemSummoned = null; | |||||
| ((SummonGolem)(parent.FindIActiveSkill(ActiveSkillType.SummonGolem))).GolemSummoned = null; | |||||
| player.FindIActiveSkill(ActiveSkillType.UseRobot).IsBeingUsed = false; | player.FindIActiveSkill(ActiveSkillType.UseRobot).IsBeingUsed = false; | ||||
| } | } | ||||
| return; | return; | ||||
| @@ -224,30 +224,67 @@ namespace Server | |||||
| boolRes.ActSuccess = false; | boolRes.ActSuccess = false; | ||||
| return Task.FromResult(boolRes); | return Task.FromResult(boolRes); | ||||
| } | } | ||||
| if (request.Message.Length > 256) | |||||
| switch (request.MessageCase) | |||||
| { | { | ||||
| case SendMsg.MessageOneofCase.TextMessage: | |||||
| { | |||||
| if (request.TextMessage.Length > 256) | |||||
| { | |||||
| #if DEBUG | #if DEBUG | ||||
| Console.WriteLine("Message string is too long!"); | |||||
| Console.WriteLine("Text message string is too long!"); | |||||
| #endif | #endif | ||||
| boolRes.ActSuccess = false; | |||||
| return Task.FromResult(boolRes); | |||||
| } | |||||
| else | |||||
| { | |||||
| MessageOfNews news = new(); | |||||
| news.News = request.Message; | |||||
| news.FromId = request.PlayerId; | |||||
| news.ToId = request.ToPlayerId; | |||||
| lock (newsLock) | |||||
| { | |||||
| currentNews.Add(news); | |||||
| } | |||||
| boolRes.ActSuccess = false; | |||||
| return Task.FromResult(boolRes); | |||||
| } | |||||
| MessageOfNews news = new(); | |||||
| news.TextMessage = request.TextMessage; | |||||
| news.FromId = request.PlayerId; | |||||
| news.ToId = request.ToPlayerId; | |||||
| lock (newsLock) | |||||
| { | |||||
| currentNews.Add(news); | |||||
| } | |||||
| #if DEBUG | #if DEBUG | ||||
| Console.WriteLine(news.News); | |||||
| Console.WriteLine(news.TextMessage); | |||||
| #endif | #endif | ||||
| boolRes.ActSuccess = true; | |||||
| return Task.FromResult(boolRes); | |||||
| } | |||||
| case SendMsg.MessageOneofCase.BinaryMessage: | |||||
| { | |||||
| if (request.BinaryMessage.Length > 256) | |||||
| { | |||||
| #if DEBUG | |||||
| Console.WriteLine("Binary message string is too long!"); | |||||
| #endif | |||||
| boolRes.ActSuccess = false; | |||||
| return Task.FromResult(boolRes); | |||||
| } | |||||
| MessageOfNews news = new(); | |||||
| news.BinaryMessage = request.BinaryMessage; | |||||
| news.FromId = request.PlayerId; | |||||
| news.ToId = request.ToPlayerId; | |||||
| lock (newsLock) | |||||
| { | |||||
| currentNews.Add(news); | |||||
| } | |||||
| #if DEBUG | |||||
| Console.Write("BinaryMessageLength: "); | |||||
| Console.WriteLine(news.BinaryMessage.Length); | |||||
| #endif | |||||
| boolRes.ActSuccess = true; | |||||
| return Task.FromResult(boolRes); | |||||
| } | |||||
| default: | |||||
| { | |||||
| boolRes.ActSuccess = false; | |||||
| return Task.FromResult(boolRes); | |||||
| } | |||||
| } | } | ||||
| boolRes.ActSuccess = true; | |||||
| return Task.FromResult(boolRes); | |||||
| } | } | ||||
| public override Task<BoolRes> PickProp(PropMsg request, ServerCallContext context) | public override Task<BoolRes> PickProp(PropMsg request, ServerCallContext context) | ||||
| { | { | ||||
| @@ -13,7 +13,7 @@ | |||||
| <PackageReference Include="Google.Protobuf" Version="3.22.3" /> | <PackageReference Include="Google.Protobuf" Version="3.22.3" /> | ||||
| <PackageReference Include="Grpc" Version="2.46.6" /> | <PackageReference Include="Grpc" Version="2.46.6" /> | ||||
| <PackageReference Include="Grpc.Core" Version="2.46.6" /> | <PackageReference Include="Grpc.Core" Version="2.46.6" /> | ||||
| <PackageReference Include="Grpc.Tools" Version="2.53.0"> | |||||
| <PackageReference Include="Grpc.Tools" Version="2.54.0"> | |||||
| <PrivateAssets>all</PrivateAssets> | <PrivateAssets>all</PrivateAssets> | ||||
| <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||||
| </PackageReference> | </PackageReference> | ||||