Browse Source

Merge branch 'dev' of github.com:sendssf/THUAI6 into dev

tags/0.1.0
sky 3 years ago
parent
commit
279d6e87e9
35 changed files with 1867 additions and 619 deletions
  1. +3
    -0
      .github/FUNDING.yaml
  2. +0
    -13
      .github/workflows/clang-format.yml
  3. +34
    -0
      .github/workflows/format.yml
  4. +38
    -82
      CAPI/API/include/API.h
  5. +20
    -1
      CAPI/API/include/Communication.h
  6. +14
    -33
      CAPI/API/include/logic.h
  7. +12
    -2
      CAPI/API/include/structures.h
  8. +18
    -2
      CAPI/API/include/utils.hpp
  9. +142
    -16
      CAPI/API/src/API.cpp
  10. +122
    -4
      CAPI/API/src/Communication.cpp
  11. +57
    -84
      CAPI/API/src/logic.cpp
  12. +30
    -54
      CAPI/proto/Message2Clients.pb.cc
  13. +21
    -57
      CAPI/proto/Message2Clients.pb.h
  14. +40
    -17
      CAPI/proto/MessageType.pb.cc
  15. +42
    -0
      CAPI/proto/MessageType.pb.h
  16. +165
    -41
      CAPI/proto/Services.grpc.pb.cc
  17. +637
    -160
      CAPI/proto/Services.grpc.pb.h
  18. +15
    -12
      CAPI/proto/Services.pb.cc
  19. +1
    -2
      dependency/proto/Message2Clients.proto
  20. +10
    -0
      dependency/proto/MessageType.proto
  21. +34
    -0
      dependency/proto/Protos.csproj
  22. +4
    -2
      dependency/proto/Services.proto
  23. +13
    -3
      dependency/shell/format.sh
  24. +1
    -1
      installer/Installer/AssemblyInfo.cs
  25. +14
    -7
      installer/Installer/Model.cs
  26. +29
    -23
      installer/Installer/ViewModel.cs
  27. +1
    -1
      launcher/Launcher/AssemblyInfo.cs
  28. +20
    -0
      logic/ClientTest/ClientTest.csproj
  29. +36
    -0
      logic/ClientTest/Program.cs
  30. +105
    -0
      logic/Server/Game.cs
  31. +120
    -0
      logic/Server/GameServer.cs
  32. +35
    -2
      logic/Server/Program.cs
  33. +15
    -0
      logic/Server/Server.csproj
  34. +12
    -0
      logic/logic.sln
  35. +7
    -0
      logic/test.cmd

+ 3
- 0
.github/FUNDING.yaml View File

@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [TCL606]

+ 0
- 13
.github/workflows/clang-format.yml View File

@@ -1,13 +0,0 @@
name: clang-format
on: [push, pull_request]
jobs:
clang-format-checking:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.14
with:
source: '.'
extensions: 'cs,c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx,i,ixx,ipp,i++'
clangFormatVersion: 14
inplace: False

+ 34
- 0
.github/workflows/format.yml View File

@@ -0,0 +1,34 @@
name: format
on: [push, pull_request]
jobs:
clang-format-checking:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DoozyX/clang-format-lint-action@v0.14
with:
source: '.'
extensions: 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx,i,ixx,ipp,i++'
clangFormatVersion: 14
inplace: False
dotnet-format-checking:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Check Logic
run: dotnet format "./logic/logic.sln" --severity error --no-restore
- name: Check Installer
run: dotnet format "./installer/installer.sln" --severity error --no-restore
- name: Check Launcher
run: dotnet format "./launcher/launcher.sln" --severity error --no-restore
- name: Check Playback
run: dotnet format "./playback/playback.sln" --severity error --no-restore

+ 38
- 82
CAPI/API/include/API.h View File

@@ -34,6 +34,7 @@ public:
virtual std::shared_ptr<const THUAI6::Butcher> ButcherGetSelfInfo() const = 0; virtual std::shared_ptr<const THUAI6::Butcher> ButcherGetSelfInfo() const = 0;


virtual std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const = 0; virtual std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const = 0;
virtual THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const = 0;


// 供IAPI使用的操作相关的部分 // 供IAPI使用的操作相关的部分
virtual bool Move(int64_t time, double angle) = 0; virtual bool Move(int64_t time, double angle) = 0;
@@ -42,17 +43,17 @@ public:
virtual bool UseSkill() = 0; virtual bool UseSkill() = 0;
virtual bool SendMessage(int64_t toID, std::string message) = 0; virtual bool SendMessage(int64_t toID, std::string message) = 0;
virtual bool HaveMessage() = 0; virtual bool HaveMessage() = 0;
virtual std::pair<std::string, int64_t> GetMessage() = 0;
virtual std::pair<int64_t, std::string> GetMessage() = 0;


virtual bool Escape() = 0; virtual bool Escape() = 0;


// 说明:双向stream由三个函数共同实现,两个记录开始和结束,结果由Logic里的私有的成员变量记录,获得返回值则另调函数 // 说明:双向stream由三个函数共同实现,两个记录开始和结束,结果由Logic里的私有的成员变量记录,获得返回值则另调函数
virtual bool StartFixMachine() = 0;
virtual bool EndFixMachine() = 0;
virtual void StartFixMachine() = 0;
virtual void EndFixMachine() = 0;
virtual bool GetFixStatus() = 0; virtual bool GetFixStatus() = 0;


virtual bool StartSaveHuman() = 0;
virtual bool EndSaveHuman() = 0;
virtual void StartSaveHuman() = 0;
virtual void EndSaveHuman() = 0;
virtual bool GetSaveStatus() = 0; virtual bool GetSaveStatus() = 0;


virtual bool Attack(double angle) = 0; virtual bool Attack(double angle) = 0;
@@ -128,11 +129,11 @@ class IHumanAPI : public IAPI
public: public:
/*****人类阵营的特定函数*****/ /*****人类阵营的特定函数*****/


virtual std::future<bool> StartFixMachine() = 0;
virtual std::future<bool> EndFixMachine() = 0;
virtual void StartFixMachine() = 0;
virtual void EndFixMachine() = 0;
virtual std::future<bool> GetFixStatus() = 0; virtual std::future<bool> GetFixStatus() = 0;
virtual std::future<bool> StartSaveHuman() = 0;
virtual std::future<bool> EndSaveHuman() = 0;
virtual void StartSaveHuman() = 0;
virtual void EndSaveHuman() = 0;
virtual std::future<bool> GetSaveStatus() = 0; virtual std::future<bool> GetSaveStatus() = 0;
virtual std::future<bool> Escape() = 0; virtual std::future<bool> Escape() = 0;
[[nodiscard]] virtual std::shared_ptr<const THUAI6::Human> GetSelfInfo() const = 0; [[nodiscard]] virtual std::shared_ptr<const THUAI6::Human> GetSelfInfo() const = 0;
@@ -189,12 +190,8 @@ public:
std::future<bool> UseSkill() override; std::future<bool> UseSkill() override;


std::future<bool> SendMessage(int64_t, std::string) override; std::future<bool> SendMessage(int64_t, std::string) override;
[[nodiscard]] std::future<bool> HaveMessage() override
{
}
[[nodiscard]] std::future<std::pair<int64_t, std::string>> GetMessage() override
{
}
[[nodiscard]] std::future<bool> HaveMessage() override;
[[nodiscard]] std::future<std::pair<int64_t, std::string>> GetMessage() override;


std::future<bool> Wait() override std::future<bool> Wait() override
{ {
@@ -206,38 +203,20 @@ public:
[[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Prop>> GetProps() const override; [[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Prop>> GetProps() const override;


[[nodiscard]] std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const override; [[nodiscard]] std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const override;
[[nodiscard]] THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const override
{
}
[[nodiscard]] THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const override;


[[nodiscard]] const std::vector<int64_t> GetPlayerGUIDs() const override [[nodiscard]] const std::vector<int64_t> GetPlayerGUIDs() const override
{ {
} }


std::future<bool> StartFixMachine() override
{
}
std::future<bool> EndFixMachine() override
{
}
std::future<bool> GetFixStatus() override
{
}
std::future<bool> StartSaveHuman() override
{
}
std::future<bool> EndSaveHuman() override
{
}
std::future<bool> GetSaveStatus() override
{
}
std::future<bool> Escape() override
{
}
[[nodiscard]] virtual std::shared_ptr<const THUAI6::Human> GetSelfInfo() const override
{
}
void StartFixMachine() override;
void EndFixMachine() override;
std::future<bool> GetFixStatus() override;
void StartSaveHuman() override;
void EndSaveHuman() override;
std::future<bool> GetSaveStatus() override;
std::future<bool> Escape() override;
[[nodiscard]] std::shared_ptr<const THUAI6::Human> GetSelfInfo() const override;


private: private:
ILogic& logic; ILogic& logic;
@@ -268,59 +247,36 @@ public:
std::future<bool> MoveUp(int64_t timeInMilliseconds) override; std::future<bool> MoveUp(int64_t timeInMilliseconds) override;
std::future<bool> MoveLeft(int64_t timeInMilliseconds) override; std::future<bool> MoveLeft(int64_t timeInMilliseconds) override;
std::future<bool> MoveDown(int64_t timeInMilliseconds) override; std::future<bool> MoveDown(int64_t timeInMilliseconds) override;

std::future<bool> PickProp(THUAI6::PropType prop) override; std::future<bool> PickProp(THUAI6::PropType prop) override;
std::future<bool> UseProp() override; std::future<bool> UseProp() override;
std::future<bool> UseSkill() override; std::future<bool> UseSkill() override;


std::future<bool> SendMessage(int64_t, std::string) override; std::future<bool> SendMessage(int64_t, std::string) override;
[[nodiscard]] std::future<bool> HaveMessage() override
{
}
[[nodiscard]] std::future<std::pair<int64_t, std::string>> GetMessage() override
{
}
[[nodiscard]] std::future<bool> HaveMessage() override;
[[nodiscard]] std::future<std::pair<int64_t, std::string>> GetMessage() override;


std::future<bool> Wait() override std::future<bool> Wait() override
{ {
} }


[[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Human>> GetHuman() const override
{
}
[[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Butcher>> GetButcher() const override
{
}
[[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Human>> GetHuman() const override;
[[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Butcher>> GetButcher() const override;


[[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Prop>> GetProps() const override
{
}
[[nodiscard]] std::vector<std::shared_ptr<const THUAI6::Prop>> GetProps() const override;


[[nodiscard]] std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const override
{
}
[[nodiscard]] THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const override
{
}
[[nodiscard]] std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const override;
[[nodiscard]] THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const override;


[[nodiscard]] const std::vector<int64_t> GetPlayerGUIDs() const override [[nodiscard]] const std::vector<int64_t> GetPlayerGUIDs() const override
{ {
} }


std::future<bool> Attack(double angleInRadian) override
{
}
std::future<bool> CarryHuman() override
{
}
std::future<bool> ReleaseHuman() override
{
}
std::future<bool> HangHuman() override
{
}
[[nodiscard]] std::shared_ptr<const THUAI6::Butcher> GetSelfInfo() const override
{
}
std::future<bool> Attack(double angleInRadian) override;
std::future<bool> CarryHuman() override;
std::future<bool> ReleaseHuman() override;
std::future<bool> HangHuman() override;
[[nodiscard]] std::shared_ptr<const THUAI6::Butcher> GetSelfInfo() const override;


private: private:
ILogic& logic; ILogic& logic;
@@ -408,19 +364,19 @@ public:
{ {
} }


std::future<bool> StartFixMachine() override
void StartFixMachine() override
{ {
} }
std::future<bool> EndFixMachine() override
void EndFixMachine() override
{ {
} }
std::future<bool> GetFixStatus() override std::future<bool> GetFixStatus() override
{ {
} }
std::future<bool> StartSaveHuman() override
void StartSaveHuman() override
{ {
} }
std::future<bool> EndSaveHuman() override
void EndSaveHuman() override
{ {
} }
std::future<bool> GetSaveStatus() override std::future<bool> GetSaveStatus() override


+ 20
- 1
CAPI/API/include/Communication.h View File

@@ -8,6 +8,7 @@
#include "Services.pb.h" #include "Services.pb.h"
#include <grpcpp/grpcpp.h> #include <grpcpp/grpcpp.h>
#include "structures.h" #include "structures.h"
#include <thread>


class Logic; class Logic;


@@ -24,17 +25,35 @@ public:
bool UseSkill(int64_t playerID); bool UseSkill(int64_t playerID);
bool SendMessage(int64_t toID, std::string message, int64_t playerID); bool SendMessage(int64_t toID, std::string message, int64_t playerID);
bool HaveMessage(int64_t playerID); bool HaveMessage(int64_t playerID);
std::pair<std::string, int64_t> GetMessage(int64_t playerID);
std::pair<int64_t, std::string> GetMessage(int64_t playerID);
bool Escape(int64_t playerID); bool Escape(int64_t playerID);

void StartFixMachine(int64_t playerID);
void EndFixMachine();
bool GetFixStatus();
void StartSaveHuman(int64_t playerID);
void EndSaveHuman();
bool GetSaveStatus();

bool Attack(double angle, int64_t playerID);

bool CarryHuman(int64_t playerID);
bool ReleaseHuman(int64_t playerID);
bool HangHuman(int64_t playerID);

bool TryConnection(int64_t playerID); bool TryConnection(int64_t playerID);
protobuf::MessageToClient GetMessage2Client(); protobuf::MessageToClient GetMessage2Client();
bool HaveMessage2Client(); bool HaveMessage2Client();
void AddPlayer(int64_t playerID, THUAI6::PlayerType playerType, THUAI6::HumanType humanType, THUAI6::ButcherType butcherType); void AddPlayer(int64_t playerID, THUAI6::PlayerType playerType, THUAI6::HumanType humanType, THUAI6::ButcherType butcherType);


private: private:
void FixMachine(int64_t playerID);
void SaveHuman(int64_t playerID);
std::unique_ptr<protobuf::AvailableService::Stub> THUAI6Stub; std::unique_ptr<protobuf::AvailableService::Stub> THUAI6Stub;
bool haveNewMessage = false; bool haveNewMessage = false;
protobuf::MessageToClient message2Client; protobuf::MessageToClient message2Client;
bool isFixing = false;
bool isSaving = false;
}; };


#endif #endif

+ 14
- 33
CAPI/API/include/logic.h View File

@@ -90,6 +90,7 @@ private:
std::shared_ptr<const THUAI6::Butcher> ButcherGetSelfInfo() const override; std::shared_ptr<const THUAI6::Butcher> ButcherGetSelfInfo() const override;


std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const override; std::vector<std::vector<THUAI6::PlaceType>> GetFullMap() const override;
THUAI6::PlaceType GetPlaceType(int32_t CellX, int32_t CellY) const override;


// 供IAPI使用的操作相关的部分 // 供IAPI使用的操作相关的部分
bool Move(int64_t time, double angle) override; bool Move(int64_t time, double angle) override;
@@ -98,43 +99,23 @@ private:
bool UseSkill() override; bool UseSkill() override;
bool SendMessage(int64_t toID, std::string message) override; bool SendMessage(int64_t toID, std::string message) override;
bool HaveMessage() override; bool HaveMessage() override;
std::pair<std::string, int64_t> GetMessage() override;
std::pair<int64_t, std::string> GetMessage() override;


bool Escape() override; bool Escape() override;


// 说明:双向stream由三个函数共同实现,两个记录开始和结束,结果由Logic里的私有的成员变量记录,获得返回值则另调函数 // 说明:双向stream由三个函数共同实现,两个记录开始和结束,结果由Logic里的私有的成员变量记录,获得返回值则另调函数
bool StartFixMachine() override
{
}
bool EndFixMachine() override
{
}
bool GetFixStatus() override
{
}

bool StartSaveHuman() override
{
}
bool EndSaveHuman() override
{
}
bool GetSaveStatus() override
{
}

bool Attack(double angle) override
{
}
bool CarryHuman() override
{
}
bool ReleaseHuman() override
{
}
bool HangHuman() override
{
}
void StartFixMachine() override;
void EndFixMachine() override;
bool GetFixStatus() override;

void StartSaveHuman() override;
void EndSaveHuman() override;
bool GetSaveStatus() override;

bool Attack(double angle) override;
bool CarryHuman() override;
bool ReleaseHuman() override;
bool HangHuman() override;


bool WaitThread() override bool WaitThread() override
{ {


+ 12
- 2
CAPI/API/include/structures.h View File

@@ -87,6 +87,17 @@ namespace THUAI6
ButcherBuffType4 = 4, ButcherBuffType4 = 4,
}; };


// 人类状态枚举
enum class HumanState : unsigned char
{
NullHumanState = 0,
Idle = 1,
Fixing = 2,
Dying = 3,
OnChair = 4,
Dead = 5,
};

// 玩家类 // 玩家类
struct Player struct Player
{ {
@@ -107,8 +118,7 @@ namespace THUAI6


struct Human : public Player struct Human : public Player
{ {
bool onChair; // 是否被挂
bool onGround; // 是否倒地
HumanState state; // 人类状态
int32_t life; // 剩余生命(本次倒地之前还能承受的伤害) int32_t life; // 剩余生命(本次倒地之前还能承受的伤害)
int32_t hangedTime; // 被挂的次数 int32_t hangedTime; // 被挂的次数




+ 18
- 2
CAPI/API/include/utils.hpp View File

@@ -76,6 +76,15 @@ namespace Proto2THUAI6
{protobuf::ButcherBuffType::BBUFFTYPE4, THUAI6::ButcherBuffType::ButcherBuffType4}, {protobuf::ButcherBuffType::BBUFFTYPE4, THUAI6::ButcherBuffType::ButcherBuffType4},
}; };


inline std::map<protobuf::HumanState, THUAI6::HumanState> humanStateDict{
{protobuf::HumanState::NULL_STATUS, THUAI6::HumanState::NullHumanState},
{protobuf::HumanState::IDLE, THUAI6::HumanState::Idle},
{protobuf::HumanState::FIXING, THUAI6::HumanState::Fixing},
{protobuf::HumanState::DYING, THUAI6::HumanState::Dying},
{protobuf::HumanState::ON_CHAIR, THUAI6::HumanState::OnChair},
{protobuf::HumanState::DEAD, THUAI6::HumanState::Dead},
};

// 用于将Protobuf中的类转换为THUAI6的类 // 用于将Protobuf中的类转换为THUAI6的类
inline std::shared_ptr<THUAI6::Butcher> Protobuf2THUAI6Butcher(const protobuf::MessageOfButcher& butcherMsg) inline std::shared_ptr<THUAI6::Butcher> Protobuf2THUAI6Butcher(const protobuf::MessageOfButcher& butcherMsg)
{ {
@@ -115,8 +124,7 @@ namespace Proto2THUAI6
human->playerType = THUAI6::PlayerType::HumanPlayer; human->playerType = THUAI6::PlayerType::HumanPlayer;
human->prop = propTypeDict[humanMsg.prop()]; human->prop = propTypeDict[humanMsg.prop()];
human->place = placeTypeDict[humanMsg.place()]; human->place = placeTypeDict[humanMsg.place()];
human->onChair = humanMsg.on_chair();
human->onGround = humanMsg.on_ground();
human->state = humanStateDict[humanMsg.state()];
human->life = humanMsg.life(); human->life = humanMsg.life();
human->hangedTime = humanMsg.hanged_time(); human->hangedTime = humanMsg.hanged_time();
human->humanType = humanTypeDict[humanMsg.human_type()]; human->humanType = humanTypeDict[humanMsg.human_type()];
@@ -272,6 +280,14 @@ namespace THUAI62Proto
sendMsg.set_player_id(id); sendMsg.set_player_id(id);
return sendMsg; return sendMsg;
} }

inline protobuf::AttackMsg THUAI62ProtobufAttack(double angle, int64_t id)
{
protobuf::AttackMsg attackMsg;
attackMsg.set_angle(angle);
attackMsg.set_player_id(id);
return attackMsg;
}
} // namespace THUAI62Proto } // namespace THUAI62Proto


#endif #endif

+ 142
- 16
CAPI/API/src/API.cpp View File

@@ -10,26 +10,22 @@ std::future<bool> HumanAPI::Move(int64_t timeInMilliseconds, double angleInRadia


std::future<bool> HumanAPI::MoveDown(int64_t timeInMilliseconds) std::future<bool> HumanAPI::MoveDown(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, 0); });
return Move(timeInMilliseconds, 0);
} }


std::future<bool> HumanAPI::MoveRight(int64_t timeInMilliseconds) std::future<bool> HumanAPI::MoveRight(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, PI * 0.5); });
return Move(timeInMilliseconds, PI * 0.5);
} }


std::future<bool> HumanAPI::MoveUp(int64_t timeInMilliseconds) std::future<bool> HumanAPI::MoveUp(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, PI); });
return Move(timeInMilliseconds, PI);
} }


std::future<bool> HumanAPI::MoveLeft(int64_t timeInMilliseconds) std::future<bool> HumanAPI::MoveLeft(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, PI * 1.5); });
return Move(timeInMilliseconds, PI * 1.5);
} }


std::future<bool> ButcherAPI::Move(int64_t timeInMilliseconds, double angleInRadian) std::future<bool> ButcherAPI::Move(int64_t timeInMilliseconds, double angleInRadian)
@@ -40,26 +36,22 @@ std::future<bool> ButcherAPI::Move(int64_t timeInMilliseconds, double angleInRad


std::future<bool> ButcherAPI::MoveDown(int64_t timeInMilliseconds) std::future<bool> ButcherAPI::MoveDown(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, 0); });
return Move(timeInMilliseconds, 0);
} }


std::future<bool> ButcherAPI::MoveRight(int64_t timeInMilliseconds) std::future<bool> ButcherAPI::MoveRight(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, PI * 0.5); });
return Move(timeInMilliseconds, PI * 0.5);
} }


std::future<bool> ButcherAPI::MoveUp(int64_t timeInMilliseconds) std::future<bool> ButcherAPI::MoveUp(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, PI); });
return Move(timeInMilliseconds, PI);
} }


std::future<bool> ButcherAPI::MoveLeft(int64_t timeInMilliseconds) std::future<bool> ButcherAPI::MoveLeft(int64_t timeInMilliseconds)
{ {
return std::async(std::launch::async, [&]()
{ return logic.Move(timeInMilliseconds, PI * 1.5); });
return Move(timeInMilliseconds, PI * 1.5);
} }


std::future<bool> HumanAPI::PickProp(THUAI6::PropType prop) std::future<bool> HumanAPI::PickProp(THUAI6::PropType prop)
@@ -110,6 +102,30 @@ std::future<bool> ButcherAPI::SendMessage(int64_t toID, std::string message)
{ return logic.SendMessage(toID, message); }); { return logic.SendMessage(toID, message); });
} }


std::future<bool> HumanAPI::HaveMessage()
{
return std::async(std::launch::async, [&]()
{ return logic.HaveMessage(); });
}

std::future<bool> ButcherAPI::HaveMessage()
{
return std::async(std::launch::async, [&]()
{ return logic.HaveMessage(); });
}

std::future<std::pair<int64_t, std::string>> HumanAPI::GetMessage()
{
return std::async(std::launch::async, [&]()
{ return logic.GetMessage(); });
}

std::future<std::pair<int64_t, std::string>> ButcherAPI::GetMessage()
{
return std::async(std::launch::async, [&]()
{ return logic.GetMessage(); });
}

std::vector<std::shared_ptr<const THUAI6::Butcher>> HumanAPI::GetButcher() const std::vector<std::shared_ptr<const THUAI6::Butcher>> HumanAPI::GetButcher() const
{ {
return logic.GetButchers(); return logic.GetButchers();
@@ -120,16 +136,126 @@ std::vector<std::shared_ptr<const THUAI6::Human>> HumanAPI::GetHuman() const
return logic.GetHumans(); return logic.GetHumans();
} }


std::vector<std::shared_ptr<const THUAI6::Butcher>> ButcherAPI::GetButcher() const
{
return logic.GetButchers();
}

std::vector<std::shared_ptr<const THUAI6::Human>> ButcherAPI::GetHuman() const
{
return logic.GetHumans();
}

std::vector<std::shared_ptr<const THUAI6::Prop>> HumanAPI::GetProps() const std::vector<std::shared_ptr<const THUAI6::Prop>> HumanAPI::GetProps() const
{ {
return logic.GetProps(); return logic.GetProps();
} }


std::vector<std::shared_ptr<const THUAI6::Prop>> ButcherAPI::GetProps() const
{
return logic.GetProps();
}

std::vector<std::vector<THUAI6::PlaceType>> HumanAPI::GetFullMap() const std::vector<std::vector<THUAI6::PlaceType>> HumanAPI::GetFullMap() const
{ {
return logic.GetFullMap(); return logic.GetFullMap();
} }


THUAI6::PlaceType HumanAPI::GetPlaceType(int32_t CellX, int32_t CellY) const
{
return logic.GetPlaceType(CellX, CellY);
}

THUAI6::PlaceType ButcherAPI::GetPlaceType(int32_t CellX, int32_t CellY) const
{
return logic.GetPlaceType(CellX, CellY);
}

std::vector<std::vector<THUAI6::PlaceType>> ButcherAPI::GetFullMap() const
{
return logic.GetFullMap();
}

void HumanAPI::StartFixMachine()
{
std::thread([&]()
{ logic.StartFixMachine(); })
.detach();
}

void HumanAPI::EndFixMachine()
{
std::thread([&]()
{ logic.EndFixMachine(); })
.detach();
}

std::future<bool> HumanAPI::GetFixStatus()
{
return std::async(std::launch::async, [&]()
{ return logic.GetFixStatus(); });
}

void HumanAPI::StartSaveHuman()
{
std::thread([&]()
{ logic.StartSaveHuman(); })
.detach();
}

void HumanAPI::EndSaveHuman()
{
std::thread([&]()
{ logic.EndSaveHuman(); })
.detach();
}

std::future<bool> HumanAPI::GetSaveStatus()
{
return std::async(std::launch::async, [&]()
{ return logic.GetSaveStatus(); });
}

std::future<bool> HumanAPI::Escape()
{
return std::async(std::launch::async, [&]()
{ return logic.Escape(); });
}

std::shared_ptr<const THUAI6::Human> HumanAPI::GetSelfInfo() const
{
return logic.HumanGetSelfInfo();
}

std::future<bool> ButcherAPI::Attack(double angleInRadian)
{
return std::async(std::launch::async, [&]()
{ return logic.Attack(angleInRadian); });
}

std::future<bool> ButcherAPI::CarryHuman()
{
return std::async(std::launch::async, [&]()
{ return logic.CarryHuman(); });
}

std::future<bool> ButcherAPI::ReleaseHuman()
{
return std::async(std::launch::async, [&]()
{ return logic.ReleaseHuman(); });
}

std::future<bool> ButcherAPI::HangHuman()
{
return std::async(std::launch::async, [&]()
{ return logic.HangHuman(); });
}

std::shared_ptr<const THUAI6::Butcher> ButcherAPI::GetSelfInfo() const
{
return logic.ButcherGetSelfInfo();
}

void HumanAPI::Play(IAI& ai) void HumanAPI::Play(IAI& ai)
{ {
ai.play(*this); ai.play(*this);


+ 122
- 4
CAPI/API/src/Communication.cpp View File

@@ -85,7 +85,7 @@ bool Communication::HaveMessage(int64_t playerID)
return false; return false;
} }


std::pair<std::string, int64_t> Communication::GetMessage(int64_t playerID)
std::pair<int64_t, std::string> Communication::GetMessage(int64_t playerID)
{ {
protobuf::MsgRes getMessageResult; protobuf::MsgRes getMessageResult;
ClientContext context; ClientContext context;
@@ -94,12 +94,12 @@ std::pair<std::string, int64_t> Communication::GetMessage(int64_t playerID)
if (status.ok()) if (status.ok())
{ {
if (getMessageResult.have_message()) if (getMessageResult.have_message())
return std::make_pair(getMessageResult.message_received(), getMessageResult.from_player_id());
return std::make_pair(getMessageResult.from_player_id(), getMessageResult.message_received());
else else
return std::make_pair("", -1);
return std::make_pair(-1, "");
} }
else else
return std::make_pair("", -1);
return std::make_pair(-1, "");
} }


bool Communication::Escape(int64_t playerID) bool Communication::Escape(int64_t playerID)
@@ -114,6 +114,124 @@ bool Communication::Escape(int64_t playerID)
return false; return false;
} }


void Communication::FixMachine(int64_t playerID)
{
protobuf::BoolRes fixMachineResult;
auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
ClientContext context;
while (isFixing)
{
auto fixStream = THUAI6Stub->FixMachine(&context);
fixStream->Write(request);
fixStream->Read(&fixMachineResult);
if (!fixMachineResult.act_success())
{
isFixing = false;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // 防止巨量发信
}
}

void Communication::StartFixMachine(int64_t playerID)
{
isFixing = true;
FixMachine(playerID);
}

void Communication::EndFixMachine()
{
isFixing = false;
}

bool Communication::GetFixStatus()
{
return isFixing;
}

void Communication::SaveHuman(int64_t playerID)
{
protobuf::BoolRes saveHumanResult;
auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
ClientContext context;
while (isSaving)
{
auto saveStream = THUAI6Stub->SaveHuman(&context);
saveStream->Write(request);
saveStream->Read(&saveHumanResult);
if (!saveHumanResult.act_success())
{
isSaving = false;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(10)); // 防止巨量发信
}
}

void Communication::StartSaveHuman(int64_t playerID)
{
isSaving = true;
SaveHuman(playerID);
}

void Communication::EndSaveHuman()
{
isSaving = false;
}

bool Communication::GetSaveStatus()
{
return isSaving;
}

bool Communication::Attack(double angle, int64_t playerID)
{
protobuf::BoolRes attackResult;
ClientContext context;
auto request = THUAI62Proto::THUAI62ProtobufAttack(angle, playerID);
auto status = THUAI6Stub->Attack(&context, request, &attackResult);
if (status.ok())
return attackResult.act_success();
else
return false;
}

bool Communication::CarryHuman(int64_t playerID)
{
protobuf::BoolRes carryHumanResult;
ClientContext context;
auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
auto status = THUAI6Stub->CarryHuman(&context, request, &carryHumanResult);
if (status.ok())
return carryHumanResult.act_success();
else
return false;
}

bool Communication::ReleaseHuman(int64_t playerID)
{
protobuf::BoolRes releaseHumanResult;
ClientContext context;
auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
auto status = THUAI6Stub->ReleaseHuman(&context, request, &releaseHumanResult);
if (status.ok())
return releaseHumanResult.act_success();
else
return false;
}

bool Communication::HangHuman(int64_t playerID)
{
protobuf::BoolRes hangHumanResult;
ClientContext context;
auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
auto status = THUAI6Stub->HangHuman(&context, request, &hangHumanResult);
if (status.ok())
return hangHumanResult.act_success();
else
return false;
}

bool Communication::TryConnection(int64_t playerID) bool Communication::TryConnection(int64_t playerID)
{ {
protobuf::BoolRes reply; protobuf::BoolRes reply;


+ 57
- 84
CAPI/API/src/logic.cpp View File

@@ -62,121 +62,102 @@ std::vector<std::vector<THUAI6::PlaceType>> Logic::GetFullMap() const
return currentState->gamemap; return currentState->gamemap;
} }


THUAI6::PlaceType Logic::GetPlaceType(int32_t CellX, int32_t CellY) const
{
std::lock_guard<std::mutex> lock(mtxState);
return currentState->gamemap[CellX][CellY];
}

bool Logic::Move(int64_t time, double angle) bool Logic::Move(int64_t time, double angle)
{ {
// protobuf::MoveRes moveResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufMove(time, angle, playerID);
// auto status = THUAI6Stub->Move(&context, request, &moveResult);
// if (status.ok())
// return moveResult.act_success();
// else
// return false;
return pComm->Move(time, angle, playerID); return pComm->Move(time, angle, playerID);
} }


bool Logic::PickProp(THUAI6::PropType prop) bool Logic::PickProp(THUAI6::PropType prop)
{ {
// protobuf::BoolRes pickPropResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufPick(prop, playerID);
// auto status = THUAI6Stub->PickProp(&context, request, &pickPropResult);
// if (status.ok())
// return pickPropResult.act_success();
// else
// return false;

return pComm->PickProp(prop, playerID); return pComm->PickProp(prop, playerID);
} }


bool Logic::UseProp() bool Logic::UseProp()
{ {
// protobuf::BoolRes usePropResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
// auto status = THUAI6Stub->UseProp(&context, request, &usePropResult);
// if (status.ok())
// return usePropResult.act_success();
// else
// return false;
return pComm->UseProp(playerID); return pComm->UseProp(playerID);
} }


bool Logic::UseSkill() bool Logic::UseSkill()
{ {
// protobuf::BoolRes useSkillResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
// auto status = THUAI6Stub->UseSkill(&context, request, &useSkillResult);
// if (status.ok())
// return useSkillResult.act_success();
// else
// return false;

return pComm->UseSkill(playerID); return pComm->UseSkill(playerID);
} }


bool Logic::SendMessage(int64_t toID, std::string message) bool Logic::SendMessage(int64_t toID, std::string message)
{ {
// protobuf::BoolRes sendMessageResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufSend(message, toID, playerID);
// auto status = THUAI6Stub->SendMessage(&context, request, &sendMessageResult);
// if (status.ok())
// return sendMessageResult.act_success();
// else
// return false;

return pComm->SendMessage(toID, message, playerID); return pComm->SendMessage(toID, message, playerID);
} }


bool Logic::HaveMessage() bool Logic::HaveMessage()
{ {
// protobuf::BoolRes haveMessageResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
// auto status = THUAI6Stub->HaveMessage(&context, request, &haveMessageResult);
// if (status.ok())
// return haveMessageResult.act_success();
// else
// return false;

return pComm->HaveMessage(playerID); return pComm->HaveMessage(playerID);
} }


std::pair<std::string, int64_t> Logic::GetMessage()
std::pair<int64_t, std::string> Logic::GetMessage()
{ {
// protobuf::MsgRes getMessageResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
// auto status = THUAI6Stub->GetMessage(&context, request, &getMessageResult);
// if (status.ok())
// {
// if (getMessageResult.have_message())
// return std::make_pair(getMessageResult.message_received(), getMessageResult.from_player_id());
// else
// return std::make_pair("", -1);
// }
// else
// return std::make_pair("", -1);

return pComm->GetMessage(playerID); return pComm->GetMessage(playerID);
} }


bool Logic::Escape() bool Logic::Escape()
{ {
// protobuf::BoolRes escapeResult;
// ClientContext context;
// auto request = THUAI62Proto::THUAI62ProtobufID(playerID);
// auto status = THUAI6Stub->Escape(&context, request, &escapeResult);
// if (status.ok())
// return escapeResult.act_success();
// else
// return false;

return pComm->Escape(playerID); return pComm->Escape(playerID);
} }


void Logic::StartFixMachine()
{
pComm->StartFixMachine(playerID);
}

void Logic::EndFixMachine()
{
pComm->EndFixMachine();
}

bool Logic::GetFixStatus()
{
return pComm->GetFixStatus();
}

void Logic::StartSaveHuman()
{
pComm->StartSaveHuman(playerID);
}

void Logic::EndSaveHuman()
{
pComm->EndSaveHuman();
}

bool Logic::GetSaveStatus()
{
return pComm->GetSaveStatus();
}

bool Logic::Attack(double angle)
{
return pComm->Attack(angle, playerID);
}

bool Logic::CarryHuman()
{
return pComm->CarryHuman(playerID);
}

bool Logic::ReleaseHuman()
{
return pComm->ReleaseHuman(playerID);
}

bool Logic::HangHuman()
{
return pComm->HangHuman(playerID);
}

void Logic::ProcessMessage() void Logic::ProcessMessage()
{ {
auto messageThread = [&]() auto messageThread = [&]()
@@ -268,14 +249,6 @@ void Logic::PlayerWrapper(std::function<void()> player)


bool Logic::TryConnection() bool Logic::TryConnection()
{ {
// IDMsg request = THUAI62Proto::THUAI62ProtobufID(playerID);
// BoolRes reply;
// ClientContext context;
// auto status = THUAI6Stub->TryConnection(&context, request, &reply);
// if (status.ok())
// return true;
// else
// return false;
return pComm->TryConnection(playerID); return pComm->TryConnection(playerID);
} }




+ 30
- 54
CAPI/proto/Message2Clients.pb.cc View File

@@ -26,7 +26,7 @@ namespace protobuf
::_pbi::ConstantInitialized ::_pbi::ConstantInitialized
) : ) :
_impl_{ _impl_{
/*decltype(_impl_.buff_)*/ {}, /*decltype(_impl_._buff_cached_byte_size_)*/ {0}, /*decltype(_impl_.x_)*/ 0, /*decltype(_impl_.y_)*/ 0, /*decltype(_impl_.speed_)*/ 0, /*decltype(_impl_.life_)*/ 0, /*decltype(_impl_.time_until_skill_available_)*/ 0, /*decltype(_impl_.hanged_time_)*/ 0, /*decltype(_impl_.place_)*/ 0, /*decltype(_impl_.prop_)*/ 0, /*decltype(_impl_.human_type_)*/ 0, /*decltype(_impl_.guid_)*/ int64_t{0}, /*decltype(_impl_.chair_time_)*/ 0, /*decltype(_impl_.on_chair_)*/ false, /*decltype(_impl_.on_ground_)*/ false, /*decltype(_impl_.view_range_)*/ 0, /*decltype(_impl_.ground_time_)*/ 0, /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.radius_)*/ 0, /*decltype(_impl_._cached_size_)*/ {}}
/*decltype(_impl_.buff_)*/ {}, /*decltype(_impl_._buff_cached_byte_size_)*/ {0}, /*decltype(_impl_.x_)*/ 0, /*decltype(_impl_.y_)*/ 0, /*decltype(_impl_.speed_)*/ 0, /*decltype(_impl_.life_)*/ 0, /*decltype(_impl_.time_until_skill_available_)*/ 0, /*decltype(_impl_.hanged_time_)*/ 0, /*decltype(_impl_.place_)*/ 0, /*decltype(_impl_.prop_)*/ 0, /*decltype(_impl_.human_type_)*/ 0, /*decltype(_impl_.guid_)*/ int64_t{0}, /*decltype(_impl_.chair_time_)*/ 0, /*decltype(_impl_.state_)*/ 0, /*decltype(_impl_.view_range_)*/ 0, /*decltype(_impl_.ground_time_)*/ 0, /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.radius_)*/ 0, /*decltype(_impl_._cached_size_)*/ {}}
{ {
} }
struct MessageOfHumanDefaultTypeInternal struct MessageOfHumanDefaultTypeInternal
@@ -264,9 +264,8 @@ const uint32_t TableStruct_Message2Clients_2eproto::offsets[] PROTOBUF_SECTION_V
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.prop_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.prop_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.human_type_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.human_type_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.guid_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.guid_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.on_chair_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.state_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.chair_time_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.chair_time_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.on_ground_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.ground_time_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.ground_time_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.player_id_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.player_id_),
PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.view_range_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfHuman, _impl_.view_range_),
@@ -369,15 +368,15 @@ const uint32_t TableStruct_Message2Clients_2eproto::offsets[] PROTOBUF_SECTION_V
}; };
static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
{0, -1, -1, sizeof(::protobuf::MessageOfHuman)}, {0, -1, -1, sizeof(::protobuf::MessageOfHuman)},
{24, -1, -1, sizeof(::protobuf::MessageOfButcher)},
{44, -1, -1, sizeof(::protobuf::MessageOfProp)},
{58, -1, -1, sizeof(::protobuf::MessageOfPickedProp)},
{69, -1, -1, sizeof(::protobuf::MessageOfMap_Row)},
{76, -1, -1, sizeof(::protobuf::MessageOfMap)},
{83, -1, -1, sizeof(::protobuf::MessageToClient)},
{93, -1, -1, sizeof(::protobuf::MoveRes)},
{102, -1, -1, sizeof(::protobuf::BoolRes)},
{109, -1, -1, sizeof(::protobuf::MsgRes)},
{23, -1, -1, sizeof(::protobuf::MessageOfButcher)},
{43, -1, -1, sizeof(::protobuf::MessageOfProp)},
{57, -1, -1, sizeof(::protobuf::MessageOfPickedProp)},
{68, -1, -1, sizeof(::protobuf::MessageOfMap_Row)},
{75, -1, -1, sizeof(::protobuf::MessageOfMap)},
{82, -1, -1, sizeof(::protobuf::MessageToClient)},
{92, -1, -1, sizeof(::protobuf::MoveRes)},
{101, -1, -1, sizeof(::protobuf::BoolRes)},
{108, -1, -1, sizeof(::protobuf::MsgRes)},
}; };


static const ::_pb::Message* const file_default_instances[] = { static const ::_pb::Message* const file_default_instances[] = {
@@ -401,9 +400,9 @@ const char descriptor_table_protodef_Message2Clients_2eproto[] PROTOBUF_SECTION_
"ill_available\030\006 \001(\001\022\"\n\005place\030\007 \001(\0162\023.pro" "ill_available\030\006 \001(\001\022\"\n\005place\030\007 \001(\0162\023.pro"
"tobuf.PlaceType\022 \n\004prop\030\010 \001(\0162\022.protobuf" "tobuf.PlaceType\022 \n\004prop\030\010 \001(\0162\022.protobuf"
".PropType\022\'\n\nhuman_type\030\t \001(\0162\023.protobuf" ".PropType\022\'\n\nhuman_type\030\t \001(\0162\023.protobuf"
".HumanType\022\014\n\004guid\030\n \001(\003\022\020\n\010on_chair\030\013 \001"
"(\010\022\022\n\nchair_time\030\014 \001(\001\022\021\n\ton_ground\030\r \001("
"\010\022\023\n\013ground_time\030\016 \001(\001\022\021\n\tplayer_id\030\017 \001("
".HumanType\022\014\n\004guid\030\n \001(\003\022#\n\005state\030\013 \001(\0162"
"\024.protobuf.HumanState\022\022\n\nchair_time\030\014 \001("
"\001\022\023\n\013ground_time\030\016 \001(\001\022\021\n\tplayer_id\030\017 \001("
"\003\022\022\n\nview_range\030\020 \001(\005\022\016\n\006radius\030\021 \001(\005\022%\n" "\003\022\022\n\nview_range\030\020 \001(\005\022\016\n\006radius\030\021 \001(\005\022%\n"
"\004buff\030\022 \003(\0162\027.protobuf.HumanBuffType\"\335\002\n" "\004buff\030\022 \003(\0162\027.protobuf.HumanBuffType\"\335\002\n"
"\020MessageOfButcher\022\t\n\001x\030\001 \001(\005\022\t\n\001y\030\002 \001(\005\022" "\020MessageOfButcher\022\t\n\001x\030\001 \001(\005\022\t\n\001y\030\002 \001(\005\022"
@@ -486,7 +485,7 @@ namespace protobuf
MessageOfHuman* const _this = this; MessageOfHuman* const _this = this;
(void)_this; (void)_this;
new (&_impl_) Impl_{ new (&_impl_) Impl_{
decltype(_impl_.buff_){from._impl_.buff_}, /*decltype(_impl_._buff_cached_byte_size_)*/ {0}, decltype(_impl_.x_){}, decltype(_impl_.y_){}, decltype(_impl_.speed_){}, decltype(_impl_.life_){}, decltype(_impl_.time_until_skill_available_){}, decltype(_impl_.hanged_time_){}, decltype(_impl_.place_){}, decltype(_impl_.prop_){}, decltype(_impl_.human_type_){}, decltype(_impl_.guid_){}, decltype(_impl_.chair_time_){}, decltype(_impl_.on_chair_){}, decltype(_impl_.on_ground_){}, decltype(_impl_.view_range_){}, decltype(_impl_.ground_time_){}, decltype(_impl_.player_id_){}, decltype(_impl_.radius_){}, /*decltype(_impl_._cached_size_)*/ {}};
decltype(_impl_.buff_){from._impl_.buff_}, /*decltype(_impl_._buff_cached_byte_size_)*/ {0}, decltype(_impl_.x_){}, decltype(_impl_.y_){}, decltype(_impl_.speed_){}, decltype(_impl_.life_){}, decltype(_impl_.time_until_skill_available_){}, decltype(_impl_.hanged_time_){}, decltype(_impl_.place_){}, decltype(_impl_.prop_){}, decltype(_impl_.human_type_){}, decltype(_impl_.guid_){}, decltype(_impl_.chair_time_){}, decltype(_impl_.state_){}, decltype(_impl_.view_range_){}, decltype(_impl_.ground_time_){}, decltype(_impl_.player_id_){}, decltype(_impl_.radius_){}, /*decltype(_impl_._cached_size_)*/ {}};


_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
::memcpy(&_impl_.x_, &from._impl_.x_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.radius_) - reinterpret_cast<char*>(&_impl_.x_)) + sizeof(_impl_.radius_)); ::memcpy(&_impl_.x_, &from._impl_.x_, static_cast<size_t>(reinterpret_cast<char*>(&_impl_.radius_) - reinterpret_cast<char*>(&_impl_.x_)) + sizeof(_impl_.radius_));
@@ -500,7 +499,7 @@ namespace protobuf
(void)arena; (void)arena;
(void)is_message_owned; (void)is_message_owned;
new (&_impl_) Impl_{ new (&_impl_) Impl_{
decltype(_impl_.buff_){arena}, /*decltype(_impl_._buff_cached_byte_size_)*/ {0}, decltype(_impl_.x_){0}, decltype(_impl_.y_){0}, decltype(_impl_.speed_){0}, decltype(_impl_.life_){0}, decltype(_impl_.time_until_skill_available_){0}, decltype(_impl_.hanged_time_){0}, decltype(_impl_.place_){0}, decltype(_impl_.prop_){0}, decltype(_impl_.human_type_){0}, decltype(_impl_.guid_){int64_t{0}}, decltype(_impl_.chair_time_){0}, decltype(_impl_.on_chair_){false}, decltype(_impl_.on_ground_){false}, decltype(_impl_.view_range_){0}, decltype(_impl_.ground_time_){0}, decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.radius_){0}, /*decltype(_impl_._cached_size_)*/ {}};
decltype(_impl_.buff_){arena}, /*decltype(_impl_._buff_cached_byte_size_)*/ {0}, decltype(_impl_.x_){0}, decltype(_impl_.y_){0}, decltype(_impl_.speed_){0}, decltype(_impl_.life_){0}, decltype(_impl_.time_until_skill_available_){0}, decltype(_impl_.hanged_time_){0}, decltype(_impl_.place_){0}, decltype(_impl_.prop_){0}, decltype(_impl_.human_type_){0}, decltype(_impl_.guid_){int64_t{0}}, decltype(_impl_.chair_time_){0}, decltype(_impl_.state_){0}, decltype(_impl_.view_range_){0}, decltype(_impl_.ground_time_){0}, decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.radius_){0}, /*decltype(_impl_._cached_size_)*/ {}};
} }


MessageOfHuman::~MessageOfHuman() MessageOfHuman::~MessageOfHuman()
@@ -651,12 +650,13 @@ namespace protobuf
else else
goto handle_unusual; goto handle_unusual;
continue; continue;
// bool on_chair = 11;
// .protobuf.HumanState state = 11;
case 11: case 11:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 88)) if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 88))
{ {
_impl_.on_chair_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr); CHK_(ptr);
_internal_set_state(static_cast<::protobuf::HumanState>(val));
} }
else else
goto handle_unusual; goto handle_unusual;
@@ -671,16 +671,6 @@ namespace protobuf
else else
goto handle_unusual; goto handle_unusual;
continue; continue;
// bool on_ground = 13;
case 13:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 104))
{
_impl_.on_ground_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
CHK_(ptr);
}
else
goto handle_unusual;
continue;
// double ground_time = 14; // double ground_time = 14;
case 14: case 14:
if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 113)) if (PROTOBUF_PREDICT_TRUE(static_cast<uint8_t>(tag) == 113))
@@ -851,11 +841,13 @@ namespace protobuf
target = ::_pbi::WireFormatLite::WriteInt64ToArray(10, this->_internal_guid(), target); target = ::_pbi::WireFormatLite::WriteInt64ToArray(10, this->_internal_guid(), target);
} }


// bool on_chair = 11;
if (this->_internal_on_chair() != 0)
// .protobuf.HumanState state = 11;
if (this->_internal_state() != 0)
{ {
target = stream->EnsureSpace(target); target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteBoolToArray(11, this->_internal_on_chair(), target);
target = ::_pbi::WireFormatLite::WriteEnumToArray(
11, this->_internal_state(), target
);
} }


// double chair_time = 12; // double chair_time = 12;
@@ -869,13 +861,6 @@ namespace protobuf
target = ::_pbi::WireFormatLite::WriteDoubleToArray(12, this->_internal_chair_time(), target); target = ::_pbi::WireFormatLite::WriteDoubleToArray(12, this->_internal_chair_time(), target);
} }


// bool on_ground = 13;
if (this->_internal_on_ground() != 0)
{
target = stream->EnsureSpace(target);
target = ::_pbi::WireFormatLite::WriteBoolToArray(13, this->_internal_on_ground(), target);
}

// double ground_time = 14; // double ground_time = 14;
static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size."); static_assert(sizeof(uint64_t) == sizeof(double), "Code assumes uint64_t and double are the same size.");
double tmp_ground_time = this->_internal_ground_time(); double tmp_ground_time = this->_internal_ground_time();
@@ -1035,16 +1020,11 @@ namespace protobuf
total_size += 1 + 8; total_size += 1 + 8;
} }


// bool on_chair = 11;
if (this->_internal_on_chair() != 0)
// .protobuf.HumanState state = 11;
if (this->_internal_state() != 0)
{ {
total_size += 1 + 1;
}

// bool on_ground = 13;
if (this->_internal_on_ground() != 0)
{
total_size += 1 + 1;
total_size += 1 +
::_pbi::WireFormatLite::EnumSize(this->_internal_state());
} }


// int32 view_range = 16; // int32 view_range = 16;
@@ -1154,13 +1134,9 @@ namespace protobuf
{ {
_this->_internal_set_chair_time(from._internal_chair_time()); _this->_internal_set_chair_time(from._internal_chair_time());
} }
if (from._internal_on_chair() != 0)
{
_this->_internal_set_on_chair(from._internal_on_chair());
}
if (from._internal_on_ground() != 0)
if (from._internal_state() != 0)
{ {
_this->_internal_set_on_ground(from._internal_on_ground());
_this->_internal_set_state(from._internal_state());
} }
if (from._internal_view_range() != 0) if (from._internal_view_range() != 0)
{ {


+ 21
- 57
CAPI/proto/Message2Clients.pb.h View File

@@ -277,8 +277,7 @@ namespace protobuf
kHumanTypeFieldNumber = 9, kHumanTypeFieldNumber = 9,
kGuidFieldNumber = 10, kGuidFieldNumber = 10,
kChairTimeFieldNumber = 12, kChairTimeFieldNumber = 12,
kOnChairFieldNumber = 11,
kOnGroundFieldNumber = 13,
kStateFieldNumber = 11,
kViewRangeFieldNumber = 16, kViewRangeFieldNumber = 16,
kGroundTimeFieldNumber = 14, kGroundTimeFieldNumber = 14,
kPlayerIdFieldNumber = 15, kPlayerIdFieldNumber = 15,
@@ -415,24 +414,14 @@ namespace protobuf
void _internal_set_chair_time(double value); void _internal_set_chair_time(double value);


public: public:
// bool on_chair = 11;
void clear_on_chair();
bool on_chair() const;
void set_on_chair(bool value);
// .protobuf.HumanState state = 11;
void clear_state();
::protobuf::HumanState state() const;
void set_state(::protobuf::HumanState value);


private: private:
bool _internal_on_chair() const;
void _internal_set_on_chair(bool value);

public:
// bool on_ground = 13;
void clear_on_ground();
bool on_ground() const;
void set_on_ground(bool value);

private:
bool _internal_on_ground() const;
void _internal_set_on_ground(bool value);
::protobuf::HumanState _internal_state() const;
void _internal_set_state(::protobuf::HumanState value);


public: public:
// int32 view_range = 16; // int32 view_range = 16;
@@ -499,8 +488,7 @@ namespace protobuf
int human_type_; int human_type_;
int64_t guid_; int64_t guid_;
double chair_time_; double chair_time_;
bool on_chair_;
bool on_ground_;
int state_;
int32_t view_range_; int32_t view_range_;
double ground_time_; double ground_time_;
int64_t player_id_; int64_t player_id_;
@@ -2955,28 +2943,28 @@ namespace protobuf
// @@protoc_insertion_point(field_set:protobuf.MessageOfHuman.guid) // @@protoc_insertion_point(field_set:protobuf.MessageOfHuman.guid)
} }


// bool on_chair = 11;
inline void MessageOfHuman::clear_on_chair()
// .protobuf.HumanState state = 11;
inline void MessageOfHuman::clear_state()
{ {
_impl_.on_chair_ = false;
_impl_.state_ = 0;
} }
inline bool MessageOfHuman::_internal_on_chair() const
inline ::protobuf::HumanState MessageOfHuman::_internal_state() const
{ {
return _impl_.on_chair_;
return static_cast<::protobuf::HumanState>(_impl_.state_);
} }
inline bool MessageOfHuman::on_chair() const
inline ::protobuf::HumanState MessageOfHuman::state() const
{ {
// @@protoc_insertion_point(field_get:protobuf.MessageOfHuman.on_chair)
return _internal_on_chair();
// @@protoc_insertion_point(field_get:protobuf.MessageOfHuman.state)
return _internal_state();
} }
inline void MessageOfHuman::_internal_set_on_chair(bool value)
inline void MessageOfHuman::_internal_set_state(::protobuf::HumanState value)
{ {
_impl_.on_chair_ = value;
_impl_.state_ = value;
} }
inline void MessageOfHuman::set_on_chair(bool value)
inline void MessageOfHuman::set_state(::protobuf::HumanState value)
{ {
_internal_set_on_chair(value);
// @@protoc_insertion_point(field_set:protobuf.MessageOfHuman.on_chair)
_internal_set_state(value);
// @@protoc_insertion_point(field_set:protobuf.MessageOfHuman.state)
} }


// double chair_time = 12; // double chair_time = 12;
@@ -3003,30 +2991,6 @@ namespace protobuf
// @@protoc_insertion_point(field_set:protobuf.MessageOfHuman.chair_time) // @@protoc_insertion_point(field_set:protobuf.MessageOfHuman.chair_time)
} }


// bool on_ground = 13;
inline void MessageOfHuman::clear_on_ground()
{
_impl_.on_ground_ = false;
}
inline bool MessageOfHuman::_internal_on_ground() const
{
return _impl_.on_ground_;
}
inline bool MessageOfHuman::on_ground() const
{
// @@protoc_insertion_point(field_get:protobuf.MessageOfHuman.on_ground)
return _internal_on_ground();
}
inline void MessageOfHuman::_internal_set_on_ground(bool value)
{
_impl_.on_ground_ = value;
}
inline void MessageOfHuman::set_on_ground(bool value)
{
_internal_set_on_ground(value);
// @@protoc_insertion_point(field_set:protobuf.MessageOfHuman.on_ground)
}

// double ground_time = 14; // double ground_time = 14;
inline void MessageOfHuman::clear_ground_time() inline void MessageOfHuman::clear_ground_time()
{ {


+ 40
- 17
CAPI/proto/MessageType.pb.cc View File

@@ -23,7 +23,7 @@ namespace _pbi = _pb::internal;
namespace protobuf namespace protobuf
{ {
} // namespace protobuf } // namespace protobuf
static const ::_pb::EnumDescriptor* file_level_enum_descriptors_MessageType_2eproto[8];
static const ::_pb::EnumDescriptor* file_level_enum_descriptors_MessageType_2eproto[9];
static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_MessageType_2eproto = nullptr; static constexpr ::_pb::ServiceDescriptor const** file_level_service_descriptors_MessageType_2eproto = nullptr;
const uint32_t TableStruct_MessageType_2eproto::offsets[1] = {}; const uint32_t TableStruct_MessageType_2eproto::offsets[1] = {};
static constexpr ::_pbi::MigrationSchema* schemas = nullptr; static constexpr ::_pbi::MigrationSchema* schemas = nullptr;
@@ -39,22 +39,24 @@ const char descriptor_table_protodef_MessageType_2eproto[] PROTOBUF_SECTION_VARI
"PTYPE2\020\002\022\n\n\006PTYPE3\020\003\022\n\n\006PTYPE4\020\004*d\n\rHuma" "PTYPE2\020\002\022\n\n\006PTYPE3\020\003\022\n\n\006PTYPE4\020\004*d\n\rHuma"
"nBuffType\022\023\n\017NULL_HBUFF_TYPE\020\000\022\016\n\nHBUFFT" "nBuffType\022\023\n\017NULL_HBUFF_TYPE\020\000\022\016\n\nHBUFFT"
"YPE1\020\001\022\016\n\nHBUFFTYPE2\020\002\022\016\n\nHBUFFTYPE3\020\003\022\016" "YPE1\020\001\022\016\n\nHBUFFTYPE2\020\002\022\016\n\nHBUFFTYPE3\020\003\022\016"
"\n\nHBUFFTYPE4\020\004*f\n\017ButcherBuffType\022\023\n\017NUL"
"L_BBUFF_TYPE\020\000\022\016\n\nBBUFFTYPE1\020\001\022\016\n\nBBUFFT"
"YPE2\020\002\022\016\n\nBBUFFTYPE3\020\003\022\016\n\nBBUFFTYPE4\020\004*H"
"\n\nPlayerType\022\024\n\020NULL_PLAYER_TYPE\020\000\022\020\n\014HU"
"MAN_PLAYER\020\001\022\022\n\016BUTCHER_PLAYER\020\002*`\n\tHuma"
"nType\022\023\n\017NULL_HUMAN_TYPE\020\000\022\016\n\nHUMANTYPE1"
"\020\001\022\016\n\nHUMANTYPE2\020\002\022\016\n\nHUMANTYPE3\020\003\022\016\n\nHU"
"MANTYPE4\020\004*l\n\013ButcherType\022\025\n\021NULL_BUTCHE"
"R_TYPE\020\000\022\020\n\014BUTCHERTYPE1\020\001\022\020\n\014BUTCHERTYP"
"E2\020\002\022\020\n\014BUTCHERTYPE3\020\003\022\020\n\014BUTCHERTYPE4\020\004"
"b\006proto3";
"\n\nHBUFFTYPE4\020\004*V\n\nHumanState\022\017\n\013NULL_STA"
"TUS\020\000\022\010\n\004IDLE\020\001\022\n\n\006FIXING\020\002\022\t\n\005DYING\020\003\022\014"
"\n\010ON_CHAIR\020\004\022\010\n\004DEAD\020\005*f\n\017ButcherBuffTyp"
"e\022\023\n\017NULL_BBUFF_TYPE\020\000\022\016\n\nBBUFFTYPE1\020\001\022\016"
"\n\nBBUFFTYPE2\020\002\022\016\n\nBBUFFTYPE3\020\003\022\016\n\nBBUFFT"
"YPE4\020\004*H\n\nPlayerType\022\024\n\020NULL_PLAYER_TYPE"
"\020\000\022\020\n\014HUMAN_PLAYER\020\001\022\022\n\016BUTCHER_PLAYER\020\002"
"*`\n\tHumanType\022\023\n\017NULL_HUMAN_TYPE\020\000\022\016\n\nHU"
"MANTYPE1\020\001\022\016\n\nHUMANTYPE2\020\002\022\016\n\nHUMANTYPE3"
"\020\003\022\016\n\nHUMANTYPE4\020\004*l\n\013ButcherType\022\025\n\021NUL"
"L_BUTCHER_TYPE\020\000\022\020\n\014BUTCHERTYPE1\020\001\022\020\n\014BU"
"TCHERTYPE2\020\002\022\020\n\014BUTCHERTYPE3\020\003\022\020\n\014BUTCHE"
"RTYPE4\020\004b\006proto3";
static ::_pbi::once_flag descriptor_table_MessageType_2eproto_once; static ::_pbi::once_flag descriptor_table_MessageType_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_MessageType_2eproto = { const ::_pbi::DescriptorTable descriptor_table_MessageType_2eproto = {
false, false,
false, false,
768,
856,
descriptor_table_protodef_MessageType_2eproto, descriptor_table_protodef_MessageType_2eproto,
"MessageType.proto", "MessageType.proto",
&descriptor_table_MessageType_2eproto_once, &descriptor_table_MessageType_2eproto_once,
@@ -157,11 +159,32 @@ namespace protobuf
} }
} }


const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ButcherBuffType_descriptor()
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* HumanState_descriptor()
{ {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto); ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto);
return file_level_enum_descriptors_MessageType_2eproto[4]; return file_level_enum_descriptors_MessageType_2eproto[4];
} }
bool HumanState_IsValid(int value)
{
switch (value)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
return true;
default:
return false;
}
}

const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ButcherBuffType_descriptor()
{
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto);
return file_level_enum_descriptors_MessageType_2eproto[5];
}
bool ButcherBuffType_IsValid(int value) bool ButcherBuffType_IsValid(int value)
{ {
switch (value) switch (value)
@@ -180,7 +203,7 @@ namespace protobuf
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* PlayerType_descriptor() const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* PlayerType_descriptor()
{ {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto); ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto);
return file_level_enum_descriptors_MessageType_2eproto[5];
return file_level_enum_descriptors_MessageType_2eproto[6];
} }
bool PlayerType_IsValid(int value) bool PlayerType_IsValid(int value)
{ {
@@ -198,7 +221,7 @@ namespace protobuf
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* HumanType_descriptor() const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* HumanType_descriptor()
{ {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto); ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto);
return file_level_enum_descriptors_MessageType_2eproto[6];
return file_level_enum_descriptors_MessageType_2eproto[7];
} }
bool HumanType_IsValid(int value) bool HumanType_IsValid(int value)
{ {
@@ -218,7 +241,7 @@ namespace protobuf
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ButcherType_descriptor() const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* ButcherType_descriptor()
{ {
::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto); ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_MessageType_2eproto);
return file_level_enum_descriptors_MessageType_2eproto[7];
return file_level_enum_descriptors_MessageType_2eproto[8];
} }
bool ButcherType_IsValid(int value) bool ButcherType_IsValid(int value)
{ {


+ 42
- 0
CAPI/proto/MessageType.pb.h View File

@@ -178,6 +178,39 @@ namespace protobuf
HumanBuffType_descriptor(), name, value HumanBuffType_descriptor(), name, value
); );
} }
enum HumanState : int
{
NULL_STATUS = 0,
IDLE = 1,
FIXING = 2,
DYING = 3,
ON_CHAIR = 4,
DEAD = 5,
HumanState_INT_MIN_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::min(),
HumanState_INT_MAX_SENTINEL_DO_NOT_USE_ = std::numeric_limits<int32_t>::max()
};
bool HumanState_IsValid(int value);
constexpr HumanState HumanState_MIN = NULL_STATUS;
constexpr HumanState HumanState_MAX = DEAD;
constexpr int HumanState_ARRAYSIZE = HumanState_MAX + 1;

const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* HumanState_descriptor();
template<typename T>
inline const std::string& HumanState_Name(T enum_t_value)
{
static_assert(::std::is_same<T, HumanState>::value || ::std::is_integral<T>::value, "Incorrect type passed to function HumanState_Name.");
return ::PROTOBUF_NAMESPACE_ID::internal::NameOfEnum(
HumanState_descriptor(), enum_t_value
);
}
inline bool HumanState_Parse(
::PROTOBUF_NAMESPACE_ID::ConstStringParam name, HumanState* value
)
{
return ::PROTOBUF_NAMESPACE_ID::internal::ParseNamedEnum<HumanState>(
HumanState_descriptor(), name, value
);
}
enum ButcherBuffType : int enum ButcherBuffType : int
{ {
NULL_BBUFF_TYPE = 0, NULL_BBUFF_TYPE = 0,
@@ -361,6 +394,15 @@ inline const EnumDescriptor* GetEnumDescriptor<::protobuf::HumanBuffType>()
return ::protobuf::HumanBuffType_descriptor(); return ::protobuf::HumanBuffType_descriptor();
} }
template<> template<>
struct is_proto_enum<::protobuf::HumanState> : ::std::true_type
{
};
template<>
inline const EnumDescriptor* GetEnumDescriptor<::protobuf::HumanState>()
{
return ::protobuf::HumanState_descriptor();
}
template<>
struct is_proto_enum<::protobuf::ButcherBuffType> : ::std::true_type struct is_proto_enum<::protobuf::ButcherBuffType> : ::std::true_type
{ {
}; };


+ 165
- 41
CAPI/proto/Services.grpc.pb.cc View File

@@ -32,8 +32,10 @@ namespace protobuf
"/protobuf.AvailableService/SendMessage", "/protobuf.AvailableService/SendMessage",
"/protobuf.AvailableService/HaveMessage", "/protobuf.AvailableService/HaveMessage",
"/protobuf.AvailableService/GetMessage", "/protobuf.AvailableService/GetMessage",
"/protobuf.AvailableService/FixMachine",
"/protobuf.AvailableService/SaveHuman",
"/protobuf.AvailableService/StartFixMachine",
"/protobuf.AvailableService/EndFixMachine",
"/protobuf.AvailableService/StartSaveHuman",
"/protobuf.AvailableService/EndSaveHuman",
"/protobuf.AvailableService/Attack", "/protobuf.AvailableService/Attack",
"/protobuf.AvailableService/CarryHuman", "/protobuf.AvailableService/CarryHuman",
"/protobuf.AvailableService/ReleaseHuman", "/protobuf.AvailableService/ReleaseHuman",
@@ -59,13 +61,15 @@ namespace protobuf
rpcmethod_SendMessage_(AvailableService_method_names[6], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel), rpcmethod_SendMessage_(AvailableService_method_names[6], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_HaveMessage_(AvailableService_method_names[7], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel), rpcmethod_HaveMessage_(AvailableService_method_names[7], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_GetMessage_(AvailableService_method_names[8], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel), rpcmethod_GetMessage_(AvailableService_method_names[8], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_FixMachine_(AvailableService_method_names[9], options.suffix_for_stats(), ::grpc::internal::RpcMethod::BIDI_STREAMING, channel),
rpcmethod_SaveHuman_(AvailableService_method_names[10], options.suffix_for_stats(), ::grpc::internal::RpcMethod::BIDI_STREAMING, channel),
rpcmethod_Attack_(AvailableService_method_names[11], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_CarryHuman_(AvailableService_method_names[12], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_ReleaseHuman_(AvailableService_method_names[13], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_HangHuman_(AvailableService_method_names[14], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_Escape_(AvailableService_method_names[15], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
rpcmethod_StartFixMachine_(AvailableService_method_names[9], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_EndFixMachine_(AvailableService_method_names[10], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_StartSaveHuman_(AvailableService_method_names[11], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_EndSaveHuman_(AvailableService_method_names[12], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_Attack_(AvailableService_method_names[13], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_CarryHuman_(AvailableService_method_names[14], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_ReleaseHuman_(AvailableService_method_names[15], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_HangHuman_(AvailableService_method_names[16], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel),
rpcmethod_Escape_(AvailableService_method_names[17], options.suffix_for_stats(), ::grpc::internal::RpcMethod::NORMAL_RPC, channel)
{ {
} }


@@ -313,44 +317,116 @@ namespace protobuf
return result; return result;
} }


::grpc::ClientReaderWriter<::protobuf::IDMsg, ::protobuf::BoolRes>* AvailableService::Stub::FixMachineRaw(::grpc::ClientContext* context)
::grpc::Status AvailableService::Stub::StartFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response)
{ {
return ::grpc::internal::ClientReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(channel_.get(), rpcmethod_FixMachine_, context);
return ::grpc::internal::BlockingUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_StartFixMachine_, context, request, response);
} }


void AvailableService::Stub::async::FixMachine(::grpc::ClientContext* context, ::grpc::ClientBidiReactor<::protobuf::IDMsg, ::protobuf::BoolRes>* reactor)
void AvailableService::Stub::async::StartFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)> f)
{ {
::grpc::internal::ClientCallbackReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(stub_->channel_.get(), stub_->rpcmethod_FixMachine_, context, reactor);
::grpc::internal::CallbackUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_StartFixMachine_, context, request, response, std::move(f));
} }


::grpc::ClientAsyncReaderWriter<::protobuf::IDMsg, ::protobuf::BoolRes>* AvailableService::Stub::AsyncFixMachineRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag)
void AvailableService::Stub::async::StartFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor)
{ {
return ::grpc::internal::ClientAsyncReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(channel_.get(), cq, rpcmethod_FixMachine_, context, true, tag);
::grpc::internal::ClientCallbackUnaryFactory::Create<::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_StartFixMachine_, context, request, response, reactor);
} }


::grpc::ClientAsyncReaderWriter<::protobuf::IDMsg, ::protobuf::BoolRes>* AvailableService::Stub::PrepareAsyncFixMachineRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq)
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::PrepareAsyncStartFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{ {
return ::grpc::internal::ClientAsyncReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(channel_.get(), cq, rpcmethod_FixMachine_, context, false, nullptr);
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create<::protobuf::BoolRes, ::protobuf::IDMsg, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_StartFixMachine_, context, request);
} }


::grpc::ClientReaderWriter<::protobuf::IDMsg, ::protobuf::BoolRes>* AvailableService::Stub::SaveHumanRaw(::grpc::ClientContext* context)
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::AsyncStartFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{ {
return ::grpc::internal::ClientReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(channel_.get(), rpcmethod_SaveHuman_, context);
auto* result =
this->PrepareAsyncStartFixMachineRaw(context, request, cq);
result->StartCall();
return result;
}

::grpc::Status AvailableService::Stub::EndFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response)
{
return ::grpc::internal::BlockingUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_EndFixMachine_, context, request, response);
}

void AvailableService::Stub::async::EndFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)> f)
{
::grpc::internal::CallbackUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_EndFixMachine_, context, request, response, std::move(f));
} }


void AvailableService::Stub::async::SaveHuman(::grpc::ClientContext* context, ::grpc::ClientBidiReactor<::protobuf::IDMsg, ::protobuf::BoolRes>* reactor)
void AvailableService::Stub::async::EndFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor)
{ {
::grpc::internal::ClientCallbackReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(stub_->channel_.get(), stub_->rpcmethod_SaveHuman_, context, reactor);
::grpc::internal::ClientCallbackUnaryFactory::Create<::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_EndFixMachine_, context, request, response, reactor);
} }


::grpc::ClientAsyncReaderWriter<::protobuf::IDMsg, ::protobuf::BoolRes>* AvailableService::Stub::AsyncSaveHumanRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag)
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::PrepareAsyncEndFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{ {
return ::grpc::internal::ClientAsyncReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(channel_.get(), cq, rpcmethod_SaveHuman_, context, true, tag);
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create<::protobuf::BoolRes, ::protobuf::IDMsg, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_EndFixMachine_, context, request);
} }


::grpc::ClientAsyncReaderWriter<::protobuf::IDMsg, ::protobuf::BoolRes>* AvailableService::Stub::PrepareAsyncSaveHumanRaw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq)
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::AsyncEndFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{ {
return ::grpc::internal::ClientAsyncReaderWriterFactory<::protobuf::IDMsg, ::protobuf::BoolRes>::Create(channel_.get(), cq, rpcmethod_SaveHuman_, context, false, nullptr);
auto* result =
this->PrepareAsyncEndFixMachineRaw(context, request, cq);
result->StartCall();
return result;
}

::grpc::Status AvailableService::Stub::StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response)
{
return ::grpc::internal::BlockingUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_StartSaveHuman_, context, request, response);
}

void AvailableService::Stub::async::StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)> f)
{
::grpc::internal::CallbackUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_StartSaveHuman_, context, request, response, std::move(f));
}

void AvailableService::Stub::async::StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor)
{
::grpc::internal::ClientCallbackUnaryFactory::Create<::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_StartSaveHuman_, context, request, response, reactor);
}

::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::PrepareAsyncStartSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create<::protobuf::BoolRes, ::protobuf::IDMsg, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_StartSaveHuman_, context, request);
}

::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::AsyncStartSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
auto* result =
this->PrepareAsyncStartSaveHumanRaw(context, request, cq);
result->StartCall();
return result;
}

::grpc::Status AvailableService::Stub::EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response)
{
return ::grpc::internal::BlockingUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), rpcmethod_EndSaveHuman_, context, request, response);
}

void AvailableService::Stub::async::EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)> f)
{
::grpc::internal::CallbackUnaryCall<::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_EndSaveHuman_, context, request, response, std::move(f));
}

void AvailableService::Stub::async::EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor)
{
::grpc::internal::ClientCallbackUnaryFactory::Create<::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(stub_->channel_.get(), stub_->rpcmethod_EndSaveHuman_, context, request, response, reactor);
}

::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::PrepareAsyncEndSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
return ::grpc::internal::ClientAsyncResponseReaderHelper::Create<::protobuf::BoolRes, ::protobuf::IDMsg, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(channel_.get(), cq, rpcmethod_EndSaveHuman_, context, request);
}

::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::AsyncEndSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
auto* result =
this->PrepareAsyncEndSaveHumanRaw(context, request, cq);
result->StartCall();
return result;
} }


::grpc::Status AvailableService::Stub::Attack(::grpc::ClientContext* context, const ::protobuf::AttackMsg& request, ::protobuf::BoolRes* response) ::grpc::Status AvailableService::Stub::Attack(::grpc::ClientContext* context, const ::protobuf::AttackMsg& request, ::protobuf::BoolRes* response)
@@ -623,26 +699,28 @@ namespace protobuf
)); ));
AddMethod(new ::grpc::internal::RpcServiceMethod( AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[9], AvailableService_method_names[9],
::grpc::internal::RpcMethod::BIDI_STREAMING,
new ::grpc::internal::BidiStreamingHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes>(
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service, [](AvailableService::Service* service,
::grpc::ServerContext* ctx, ::grpc::ServerContext* ctx,
::grpc::ServerReaderWriter<::protobuf::BoolRes, ::protobuf::IDMsg>* stream)
const ::protobuf::IDMsg* req,
::protobuf::BoolRes* resp)
{ {
return service->FixMachine(ctx, stream);
return service->StartFixMachine(ctx, req, resp);
}, },
this this
) )
)); ));
AddMethod(new ::grpc::internal::RpcServiceMethod( AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[10], AvailableService_method_names[10],
::grpc::internal::RpcMethod::BIDI_STREAMING,
new ::grpc::internal::BidiStreamingHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes>(
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service, [](AvailableService::Service* service,
::grpc::ServerContext* ctx, ::grpc::ServerContext* ctx,
::grpc::ServerReaderWriter<::protobuf::BoolRes, ::protobuf::IDMsg>* stream)
const ::protobuf::IDMsg* req,
::protobuf::BoolRes* resp)
{ {
return service->SaveHuman(ctx, stream);
return service->EndFixMachine(ctx, req, resp);
}, },
this this
) )
@@ -650,6 +728,34 @@ namespace protobuf
AddMethod(new ::grpc::internal::RpcServiceMethod( AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[11], AvailableService_method_names[11],
::grpc::internal::RpcMethod::NORMAL_RPC, ::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service,
::grpc::ServerContext* ctx,
const ::protobuf::IDMsg* req,
::protobuf::BoolRes* resp)
{
return service->StartSaveHuman(ctx, req, resp);
},
this
)
));
AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[12],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service,
::grpc::ServerContext* ctx,
const ::protobuf::IDMsg* req,
::protobuf::BoolRes* resp)
{
return service->EndSaveHuman(ctx, req, resp);
},
this
)
));
AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[13],
::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::AttackMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::AttackMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service, [](AvailableService::Service* service,
::grpc::ServerContext* ctx, ::grpc::ServerContext* ctx,
@@ -662,7 +768,7 @@ namespace protobuf
) )
)); ));
AddMethod(new ::grpc::internal::RpcServiceMethod( AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[12],
AvailableService_method_names[14],
::grpc::internal::RpcMethod::NORMAL_RPC, ::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service, [](AvailableService::Service* service,
@@ -676,7 +782,7 @@ namespace protobuf
) )
)); ));
AddMethod(new ::grpc::internal::RpcServiceMethod( AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[13],
AvailableService_method_names[15],
::grpc::internal::RpcMethod::NORMAL_RPC, ::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service, [](AvailableService::Service* service,
@@ -690,7 +796,7 @@ namespace protobuf
) )
)); ));
AddMethod(new ::grpc::internal::RpcServiceMethod( AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[14],
AvailableService_method_names[16],
::grpc::internal::RpcMethod::NORMAL_RPC, ::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service, [](AvailableService::Service* service,
@@ -704,7 +810,7 @@ namespace protobuf
) )
)); ));
AddMethod(new ::grpc::internal::RpcServiceMethod( AddMethod(new ::grpc::internal::RpcServiceMethod(
AvailableService_method_names[15],
AvailableService_method_names[17],
::grpc::internal::RpcMethod::NORMAL_RPC, ::grpc::internal::RpcMethod::NORMAL_RPC,
new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>( new ::grpc::internal::RpcMethodHandler<AvailableService::Service, ::protobuf::IDMsg, ::protobuf::BoolRes, ::grpc::protobuf::MessageLite, ::grpc::protobuf::MessageLite>(
[](AvailableService::Service* service, [](AvailableService::Service* service,
@@ -795,17 +901,35 @@ namespace protobuf
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }


::grpc::Status AvailableService::Service::FixMachine(::grpc::ServerContext* context, ::grpc::ServerReaderWriter<::protobuf::BoolRes, ::protobuf::IDMsg>* stream)
::grpc::Status AvailableService::Service::StartFixMachine(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response)
{
(void)context;
(void)request;
(void)response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}

::grpc::Status AvailableService::Service::EndFixMachine(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response)
{ {
(void)context; (void)context;
(void)stream;
(void)request;
(void)response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }


::grpc::Status AvailableService::Service::SaveHuman(::grpc::ServerContext* context, ::grpc::ServerReaderWriter<::protobuf::BoolRes, ::protobuf::IDMsg>* stream)
::grpc::Status AvailableService::Service::StartSaveHuman(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response)
{ {
(void)context; (void)context;
(void)stream;
(void)request;
(void)response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}

::grpc::Status AvailableService::Service::EndSaveHuman(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response)
{
(void)context;
(void)request;
(void)response;
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
} }




+ 637
- 160
CAPI/proto/Services.grpc.pb.h
File diff suppressed because it is too large
View File


+ 15
- 12
CAPI/proto/Services.pb.cc View File

@@ -31,7 +31,7 @@ static constexpr ::_pb::Message* const* file_default_instances = nullptr;


const char descriptor_table_protodef_Services_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = const char descriptor_table_protodef_Services_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
"\n\016Services.proto\022\010protobuf\032\025Message2Clie" "\n\016Services.proto\022\010protobuf\032\025Message2Clie"
"nts.proto\032\024Message2Server.proto2\300\006\n\020Avai"
"nts.proto\032\024Message2Server.proto2\253\007\n\020Avai"
"lableService\0223\n\rTryConnection\022\017.protobuf" "lableService\0223\n\rTryConnection\022\017.protobuf"
".IDMsg\032\021.protobuf.BoolRes\022=\n\tAddPlayer\022\023" ".IDMsg\032\021.protobuf.BoolRes\022=\n\tAddPlayer\022\023"
".protobuf.PlayerMsg\032\031.protobuf.MessageTo" ".protobuf.PlayerMsg\032\031.protobuf.MessageTo"
@@ -43,16 +43,19 @@ const char descriptor_table_protodef_Services_2eproto[] PROTOBUF_SECTION_VARIABL
"3\n\013SendMessage\022\021.protobuf.SendMsg\032\021.prot" "3\n\013SendMessage\022\021.protobuf.SendMsg\032\021.prot"
"obuf.BoolRes\0221\n\013HaveMessage\022\017.protobuf.I" "obuf.BoolRes\0221\n\013HaveMessage\022\017.protobuf.I"
"DMsg\032\021.protobuf.BoolRes\022/\n\nGetMessage\022\017." "DMsg\032\021.protobuf.BoolRes\022/\n\nGetMessage\022\017."
"protobuf.IDMsg\032\020.protobuf.MsgRes\0224\n\nFixM"
"achine\022\017.protobuf.IDMsg\032\021.protobuf.BoolR"
"es(\0010\001\0223\n\tSaveHuman\022\017.protobuf.IDMsg\032\021.p"
"rotobuf.BoolRes(\0010\001\0220\n\006Attack\022\023.protobuf"
".AttackMsg\032\021.protobuf.BoolRes\0220\n\nCarryHu"
"man\022\017.protobuf.IDMsg\032\021.protobuf.BoolRes\022"
"2\n\014ReleaseHuman\022\017.protobuf.IDMsg\032\021.proto"
"buf.BoolRes\022/\n\tHangHuman\022\017.protobuf.IDMs"
"g\032\021.protobuf.BoolRes\022,\n\006Escape\022\017.protobu"
"f.IDMsg\032\021.protobuf.BoolResb\006proto3";
"protobuf.IDMsg\032\020.protobuf.MsgRes\0225\n\017Star"
"tFixMachine\022\017.protobuf.IDMsg\032\021.protobuf."
"BoolRes\0223\n\rEndFixMachine\022\017.protobuf.IDMs"
"g\032\021.protobuf.BoolRes\0224\n\016StartSaveHuman\022\017"
".protobuf.IDMsg\032\021.protobuf.BoolRes\0222\n\014En"
"dSaveHuman\022\017.protobuf.IDMsg\032\021.protobuf.B"
"oolRes\0220\n\006Attack\022\023.protobuf.AttackMsg\032\021."
"protobuf.BoolRes\0220\n\nCarryHuman\022\017.protobu"
"f.IDMsg\032\021.protobuf.BoolRes\0222\n\014ReleaseHum"
"an\022\017.protobuf.IDMsg\032\021.protobuf.BoolRes\022/"
"\n\tHangHuman\022\017.protobuf.IDMsg\032\021.protobuf."
"BoolRes\022,\n\006Escape\022\017.protobuf.IDMsg\032\021.pro"
"tobuf.BoolResb\006proto3";
static const ::_pbi::DescriptorTable* const descriptor_table_Services_2eproto_deps[2] = { static const ::_pbi::DescriptorTable* const descriptor_table_Services_2eproto_deps[2] = {
&::descriptor_table_Message2Clients_2eproto, &::descriptor_table_Message2Clients_2eproto,
&::descriptor_table_Message2Server_2eproto, &::descriptor_table_Message2Server_2eproto,
@@ -61,7 +64,7 @@ static ::_pbi::once_flag descriptor_table_Services_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_Services_2eproto = { const ::_pbi::DescriptorTable descriptor_table_Services_2eproto = {
false, false,
false, false,
914,
1021,
descriptor_table_protodef_Services_2eproto, descriptor_table_protodef_Services_2eproto,
"Services.proto", "Services.proto",
&descriptor_table_Services_2eproto_once, &descriptor_table_Services_2eproto_once,


+ 1
- 2
dependency/proto/Message2Clients.proto View File

@@ -16,9 +16,8 @@ message MessageOfHuman
PropType prop = 8; PropType prop = 8;
HumanType human_type = 9; HumanType human_type = 9;
int64 guid = 10; int64 guid = 10;
bool on_chair = 11; // 是否被挂
HumanState state = 11;
double chair_time = 12; // 被挂的时间 double chair_time = 12; // 被挂的时间
bool on_ground = 13; // 是否倒地
double ground_time = 14; // 倒地时间 double ground_time = 14; // 倒地时间
int64 player_id = 15; int64 player_id = 15;
int32 view_range = 16; // 视野距离 int32 view_range = 16; // 视野距离


+ 10
- 0
dependency/proto/MessageType.proto View File

@@ -43,6 +43,16 @@ enum HumanBuffType // 人类可用的增益效果类型
HBUFFTYPE4 = 4; HBUFFTYPE4 = 4;
} }


enum HumanState
{
NULL_STATUS = 0;
IDLE = 1; // 正常状态
FIXING = 2; // 修理状态
DYING = 3; // 濒死状态
ON_CHAIR = 4; // 被挂
DEAD = 5; // 死亡状态
}

enum ButcherBuffType // 屠夫可用的增益效果类型 enum ButcherBuffType // 屠夫可用的增益效果类型
{ {
NULL_BBUFF_TYPE = 0; NULL_BBUFF_TYPE = 0;


+ 34
- 0
dependency/proto/Protos.csproj View File

@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<None Remove="Message2Clients.proto" />
<None Remove="Message2Server.proto" />
<None Remove="MessageType.proto" />
<None Remove="Services.proto" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.9" />
<PackageReference Include="Google.Protobuf.Tools" Version="3.21.9" />
<PackageReference Include="Grpc" Version="2.46.5" />
<PackageReference Include="Grpc.Core" Version="2.46.5" />
<PackageReference Include="Grpc.Tools" Version="2.50.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<Protobuf Include="Message2Clients.proto" />
<Protobuf Include="Message2Server.proto" />
<Protobuf Include="MessageType.proto" />
<Protobuf Include="Services.proto" />
</ItemGroup>

</Project>

+ 4
- 2
dependency/proto/Services.proto View File

@@ -19,8 +19,10 @@ service AvailableService
rpc SendMessage(SendMsg) returns (BoolRes); rpc SendMessage(SendMsg) returns (BoolRes);
rpc HaveMessage(IDMsg) returns (BoolRes); rpc HaveMessage(IDMsg) returns (BoolRes);
rpc GetMessage(IDMsg) returns (MsgRes); rpc GetMessage(IDMsg) returns (MsgRes);
rpc FixMachine(stream IDMsg) returns (stream BoolRes); // 若正常修复且未被打断则返回修复成功,位置错误/被打断则返回修复失败,下同
rpc SaveHuman(stream IDMsg) returns (stream BoolRes);
rpc StartFixMachine(IDMsg) returns (BoolRes); // 开始修理机器
rpc EndFixMachine(IDMsg) returns (BoolRes); // 主动停止修复
rpc StartSaveHuman(IDMsg) returns (BoolRes); // 开始救人
rpc EndSaveHuman(IDMsg) returns (BoolRes); // 主动停止救人
rpc Attack (AttackMsg) returns (BoolRes); rpc Attack (AttackMsg) returns (BoolRes);
rpc CarryHuman (IDMsg) returns (BoolRes); rpc CarryHuman (IDMsg) returns (BoolRes);
rpc ReleaseHuman (IDMsg) returns (BoolRes); rpc ReleaseHuman (IDMsg) returns (BoolRes);


+ 13
- 3
dependency/shell/format.sh View File

@@ -1,7 +1,10 @@
for i in {1..10}
SHELL_FOLDER=$(dirname $(readlink -f "$0"))
cd $SHELL_FOLDER
cd ../..

for i in {1..3}
do do
find . -iname "*.cs" \
-or -iname "*.c" \
find . -iname "*.c" \
-or -iname "*.h" \ -or -iname "*.h" \
-or -iname "*.C" \ -or -iname "*.C" \
-or -iname "*.H" \ -or -iname "*.H" \
@@ -19,3 +22,10 @@ find . -iname "*.cs" \
-or -iname "*.i++" \ -or -iname "*.i++" \
| xargs clang-format -i | xargs clang-format -i
done done

cd logic && dotnet format && cd ..
cd installer && dotnet format && cd ..
cd launcher && dotnet format && cd ..
cd playback && dotnet format && cd ..

echo "Done!"

+ 1
- 1
installer/Installer/AssemblyInfo.cs View File

@@ -1,6 +1,6 @@
using System.Windows; using System.Windows;


[assembly:ThemeInfo(
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)


+ 14
- 7
installer/Installer/Model.cs View File

@@ -26,15 +26,21 @@ namespace starter.viewmodel.settings
/// <summary> /// <summary>
/// Route of files /// Route of files
/// </summary> /// </summary>
public string Route {
get; set; }
public string Route
{
get; set;
}
/// <summary> /// <summary>
/// if the route was set or is under editing /// if the route was set or is under editing
/// </summary> /// </summary>
public bool HaveRoute {
get; set; }
public bool EditingRoute {
get; set; }
public bool HaveRoute
{
get; set;
}
public bool EditingRoute
{
get; set;
}
/// <summary> /// <summary>
/// downloader function /// downloader function
/// </summary> /// </summary>
@@ -144,7 +150,8 @@ namespace Downloader
GetObjectRequest request = new GetObjectRequest(bucket, key, localDir, localFileName); GetObjectRequest request = new GetObjectRequest(bucket, key, localDir, localFileName);


Dictionary<string, string> test = request.GetRequestHeaders(); Dictionary<string, string> test = request.GetRequestHeaders();
request.SetCosProgressCallback(delegate(long completed, long total) {
request.SetCosProgressCallback(delegate (long completed, long total)
{
Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total)); Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total));
}); });
// 执行请求 // 执行请求


+ 29
- 23
installer/Installer/ViewModel.cs View File

@@ -22,10 +22,12 @@ namespace starter.viewmodel.settings


public string Route public string Route
{ {
get {
get
{
return obj.Route; return obj.Route;
} }
set {
set
{
obj.Route = value; obj.Route = value;
this.RaisePropertyChanged("Route"); this.RaisePropertyChanged("Route");
} }
@@ -33,10 +35,12 @@ namespace starter.viewmodel.settings


public bool CanEditRoute // if the user can still edit install route public bool CanEditRoute // if the user can still edit install route
{ {
get {
get
{
return !obj.HaveRoute; return !obj.HaveRoute;
} }
set {
set
{
obj.HaveRoute = !value; obj.HaveRoute = !value;
obj.EditingRoute = value; obj.EditingRoute = value;
this.RaisePropertyChanged("CanEditRoute"); this.RaisePropertyChanged("CanEditRoute");
@@ -46,7 +50,8 @@ namespace starter.viewmodel.settings
private BaseCommand clickBrowseCommand; private BaseCommand clickBrowseCommand;
public BaseCommand ClickBrowseCommand public BaseCommand ClickBrowseCommand
{ {
get {
get
{
if (clickBrowseCommand == null) if (clickBrowseCommand == null)
{ {
clickBrowseCommand = new BaseCommand(new Action<object>(o => clickBrowseCommand = new BaseCommand(new Action<object>(o =>
@@ -54,28 +59,29 @@ namespace starter.viewmodel.settings
using (FolderBrowserDialog dialog = new FolderBrowserDialog()) using (FolderBrowserDialog dialog = new FolderBrowserDialog())
{ {
_ = dialog.ShowDialog(); _ = dialog.ShowDialog();
if (dialog.SelectedPath != String.Empty)
Route = dialog.SelectedPath;
if (dialog.SelectedPath != String.Empty)
Route = dialog.SelectedPath;
}
}));
} }
}));
}
return clickBrowseCommand;
}
}
private BaseCommand clickConfirmCommand;
public BaseCommand ClickConfirmCommand
{
get {
if (clickConfirmCommand == null)
return clickBrowseCommand;
}
}
private BaseCommand clickConfirmCommand;
public BaseCommand ClickConfirmCommand
{ {
get
{
if (clickConfirmCommand == null)
{
clickConfirmCommand = new BaseCommand(new Action<object>(o => clickConfirmCommand = new BaseCommand(new Action<object>(o =>
{ {
CanEditRoute = false; CanEditRoute = false;
obj.install();
}));
}
obj.install();
}));
}
return clickConfirmCommand; return clickConfirmCommand;
} }
}
}
}
}
}
}

+ 1
- 1
launcher/Launcher/AssemblyInfo.cs View File

@@ -1,6 +1,6 @@
using System.Windows; using System.Windows;


[assembly:ThemeInfo(
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located
//(used if a resource is not found in the page, //(used if a resource is not found in the page,
// or application resource dictionaries) // or application resource dictionaries)


+ 20
- 0
logic/ClientTest/ClientTest.csproj View File

@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.9" />
<PackageReference Include="Grpc" Version="2.46.5" />
<PackageReference Include="Grpc.Core" Version="2.46.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\dependency\proto\Protos.csproj" />
</ItemGroup>

</Project>

+ 36
- 0
logic/ClientTest/Program.cs View File

@@ -0,0 +1,36 @@
using Grpc.Core;
using Protobuf;

namespace ClientTest
{
public class Program
{
public static async Task Main(string[] args)
{
Channel channel = new Channel("0.0.0.0:8888", ChannelCredentials.Insecure);
var client = new AvailableService.AvailableServiceClient(channel);
PlayerMsg playerInfo = new();
playerInfo.PlayerId = Convert.ToInt32(args[0]);
playerInfo.PlayerType = (PlayerType)Convert.ToInt32(args[1]);
var call = client.AddPlayer(playerInfo);
while (await call.ResponseStream.MoveNext())
{
var currentGameInfo = call.ResponseStream.Current;
if (playerInfo.PlayerType == PlayerType.HumanPlayer)
{
for (int i = 0; i < currentGameInfo.HumanMessage.Count; i++)
{
Console.WriteLine($"Human is at ({currentGameInfo.HumanMessage[i].X}, {currentGameInfo.HumanMessage[i].Y})");
}
}
if (playerInfo.PlayerType == PlayerType.ButcherPlayer)
{
for (int i = 0; i < currentGameInfo.ButcherMessage.Count; i++)
{
Console.WriteLine($"Butcher is at ({currentGameInfo.ButcherMessage[i].X}, {currentGameInfo.ButcherMessage[i].Y})");
}
}
}
}
}
}

+ 105
- 0
logic/Server/Game.cs View File

@@ -0,0 +1,105 @@
using Grpc.Core;
using Protobuf;
using System.Threading;
using Timothy.FrameRateTask;
using System;
using System.Net.Http.Headers;

namespace Server
{
public class Game
{
private const int gameTime = 3000;
public int GameTime => gameTime;

private MessageToClient gameInfo = new();
private object gameInfoLock = new();
private int isGaming = 0;
public bool IsGaming
{
get => Interlocked.CompareExchange(ref isGaming, 0, 0) != 0;
set => Interlocked.Exchange(ref isGaming, value ? 1 : 0);
}

public MessageToClient GetCopiedGameInfo()
{
lock (gameInfoLock)
{
return gameInfo.Clone();
}
}
public void AddPlayer(PlayerMsg player)
{
lock (gameInfoLock)
{
if (player.PlayerType == PlayerType.NullPlayerType)
return;
if (player.PlayerType == PlayerType.HumanPlayer)
{
gameInfo.HumanMessage.Add(new MessageOfHuman()
{
PlayerId = player.PlayerId
});
return;
}
if (player.PlayerType == PlayerType.ButcherPlayer)
{
gameInfo.ButcherMessage.Add(new MessageOfButcher()
{
PlayerID = player.PlayerId
});
return;
}
}
}

public SemaphoreSlim StartGame()
{
IsGaming = true;
var waitHandle = new SemaphoreSlim(0);

new Thread
(
() =>
{
new FrameRateTaskExecutor<int>
(
() => IsGaming,
() =>
{
lock (gameInfo)
{
for (int i = 0; i < gameInfo.HumanMessage.Count; i++)
{
if (gameInfo.HumanMessage[i] != null)
{
gameInfo.HumanMessage[i].X++;
gameInfo.HumanMessage[i].Y--;
}
}
for (int i = 0; i < gameInfo.ButcherMessage.Count; i++)
{
if (gameInfo.ButcherMessage[i] != null)
{
gameInfo.ButcherMessage[i].X--;
gameInfo.ButcherMessage[i].Y++;
}
}
}
},
100,
() =>
{
IsGaming = false;
waitHandle.Release();
return 0;
},
gameTime
).Start();
}
)
{ IsBackground = true }.Start();
return waitHandle;
}
}
}

+ 120
- 0
logic/Server/GameServer.cs View File

@@ -0,0 +1,120 @@
using Grpc.Core;
using Protobuf;
using System.Threading;
using Timothy.FrameRateTask;
using System;
using System.Net.Http.Headers;

namespace Server
{
public class GameServer : AvailableService.AvailableServiceBase
{
private Dictionary<long, (SemaphoreSlim, SemaphoreSlim)> semaDict = new();
private object gameLock = new();
private const int playerNum = 1;
private MessageToClient currentGameInfo = new();
private Game game = new();
public int GameTime => game.GameTime;
private SemaphoreSlim endGameSem = new(0);

public override Task<BoolRes> TryConnection(IDMsg request, ServerCallContext context)
{
var onConnection = new BoolRes();
lock (gameLock)
{
// if (0 <= request.PlayerId && request.PlayerId < playerNum)
{
onConnection.ActSuccess = true;
return Task.FromResult(onConnection);
}
}
onConnection.ActSuccess = false;
return Task.FromResult(onConnection);
}

public override async Task AddPlayer(PlayerMsg request, IServerStreamWriter<MessageToClient> responseStream, ServerCallContext context)
{
lock (gameLock)
{
if (game.IsGaming)
return;
game.AddPlayer(request);
var temp = (new SemaphoreSlim(0, 1), new SemaphoreSlim(0, 1));

bool start = false;
Console.WriteLine($"Id: {request.PlayerId} joins.");
lock (semaDict)
{
semaDict.Add(request.PlayerId, temp);
start = semaDict.Count == playerNum;
}

if (start)
{
Console.WriteLine("Game starts!");
StartGame();
}
}

do
{
semaDict[request.PlayerId].Item1.Wait();
if (currentGameInfo != null)
{
await responseStream.WriteAsync(currentGameInfo);
Console.WriteLine("Send!");
}
semaDict[request.PlayerId].Item2.Release();
} while (game.IsGaming);
}
public void StartGame()
{
var waitHandle = game.StartGame();
new Thread(() =>
{
new FrameRateTaskExecutor<int>
(
() => game.IsGaming,
ReportGame,
1000,
() =>
{
ReportGame(); // 最后发一次消息,唤醒发消息的线程,防止发消息的线程由于有概率处在 Wait 状态而卡住
return 0;
}
).Start();
})
{ IsBackground = true }.Start();
new Thread(() =>
{
waitHandle.Wait();
this.endGameSem.Release();
})
{ IsBackground = true }.Start();

}
public void WaitForEnd()
{
this.endGameSem.Wait();
}

public void ReportGame()
{
currentGameInfo = game.GetCopiedGameInfo();

foreach (var kvp in semaDict)
{
kvp.Value.Item1.Release();
}

foreach (var kvp in semaDict)
{
kvp.Value.Item2.Wait();
}
}

public GameServer()
{
}
}
}

+ 35
- 2
logic/Server/Program.cs View File

@@ -1,2 +1,35 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
using Grpc.Core;
using Protobuf;
using System.Threading;
using Timothy.FrameRateTask;
using System;
using System.Net.Http.Headers;

namespace Server
{
public class Program
{
public static void Main()
{
try
{
GameServer gameServer = new();
Grpc.Core.Server server = new Grpc.Core.Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) })
{
Services = { AvailableService.BindService(gameServer) },
Ports = { new ServerPort("0.0.0.0", 8888, ServerCredentials.Insecure) }
};
server.Start();

Console.WriteLine("Server begins to listen!");
gameServer.WaitForEnd();
Console.WriteLine("Server end!");
server.ShutdownAsync().Wait();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}

+ 15
- 0
logic/Server/Server.csproj View File

@@ -7,4 +7,19 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>


<ItemGroup>
<PackageReference Include="FrameRateTask" Version="1.1.2" />
<PackageReference Include="Google.Protobuf" Version="3.21.9" />
<PackageReference Include="Grpc" Version="2.46.5" />
<PackageReference Include="Grpc.Core" Version="2.46.5" />
<PackageReference Include="Grpc.Tools" Version="2.50.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\dependency\proto\Protos.csproj" />
</ItemGroup>

</Project> </Project>

+ 12
- 0
logic/logic.sln View File

@@ -5,6 +5,10 @@ VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientTest", "ClientTest\ClientTest.csproj", "{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protos", "..\dependency\proto\Protos.csproj", "{9ADA1EF8-DF2F-4C2E-9DE2-BC94DF89B44D}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -15,6 +19,14 @@ Global
{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Debug|Any CPU.Build.0 = Debug|Any CPU {D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Release|Any CPU.ActiveCfg = Release|Any CPU {D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Release|Any CPU.Build.0 = Release|Any CPU {D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}.Release|Any CPU.Build.0 = Release|Any CPU
{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}.Release|Any CPU.Build.0 = Release|Any CPU
{9ADA1EF8-DF2F-4C2E-9DE2-BC94DF89B44D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9ADA1EF8-DF2F-4C2E-9DE2-BC94DF89B44D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9ADA1EF8-DF2F-4C2E-9DE2-BC94DF89B44D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9ADA1EF8-DF2F-4C2E-9DE2-BC94DF89B44D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE


+ 7
- 0
logic/test.cmd View File

@@ -0,0 +1,7 @@
@echo off

start cmd /k .\Server\bin\Debug\net6.0\Server.exe

start cmd /k .\ClientTest\bin\Debug\net6.0\ClientTest.exe 0 1

start cmd /k .\ClientTest\bin\Debug\net6.0\ClientTest.exe 1 2

Loading…
Cancel
Save