Browse Source

Merge branch 'eesast:dev' into new

tags/0.1.0
shangfengh GitHub 3 years ago
parent
commit
9f4b5ac18b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 730 additions and 140 deletions
  1. +3
    -0
      .github/FUNDING.yaml
  2. +0
    -13
      .github/workflows/clang-format.yml
  3. +34
    -0
      .github/workflows/format.yml
  4. +2
    -3
      CAPI/API/include/structures.h
  5. +10
    -2
      CAPI/API/include/utils.hpp
  6. +14
    -14
      CAPI/proto/Services.grpc.pb.cc
  7. +57
    -57
      CAPI/proto/Services.grpc.pb.h
  8. +12
    -12
      CAPI/proto/Services.pb.cc
  9. +34
    -0
      dependency/proto/Protos.csproj
  10. +1
    -1
      dependency/proto/Services.proto
  11. +13
    -3
      dependency/shell/format.sh
  12. +1
    -1
      installer/Installer/AssemblyInfo.cs
  13. +169
    -8
      installer/Installer/Model.cs
  14. +29
    -23
      installer/Installer/ViewModel.cs
  15. +1
    -1
      launcher/Launcher/AssemblyInfo.cs
  16. +20
    -0
      logic/ClientTest/ClientTest.csproj
  17. +36
    -0
      logic/ClientTest/Program.cs
  18. +105
    -0
      logic/Server/Game.cs
  19. +120
    -0
      logic/Server/GameServer.cs
  20. +35
    -2
      logic/Server/Program.cs
  21. +15
    -0
      logic/Server/Server.csproj
  22. +7
    -0
      logic/cmd/test.cmd
  23. +12
    -0
      logic/logic.sln

+ 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@v3
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

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

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

//人类状态枚举
// 人类状态枚举
enum class HumanState : unsigned char
{
NullHumanState = 0,
@@ -118,8 +118,7 @@ namespace THUAI6

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



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

@@ -76,6 +76,15 @@ namespace Proto2THUAI6
{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的类
inline std::shared_ptr<THUAI6::Butcher> Protobuf2THUAI6Butcher(const protobuf::MessageOfButcher& butcherMsg)
{
@@ -115,8 +124,7 @@ namespace Proto2THUAI6
human->playerType = THUAI6::PlayerType::HumanPlayer;
human->prop = propTypeDict[humanMsg.prop()];
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->hangedTime = humanMsg.hanged_time();
human->humanType = humanTypeDict[humanMsg.human_type()];


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

@@ -34,7 +34,7 @@ namespace protobuf
"/protobuf.AvailableService/GetMessage",
"/protobuf.AvailableService/StartFixMachine",
"/protobuf.AvailableService/EndFixMachine",
"/protobuf.AvailableService/SaveHuman",
"/protobuf.AvailableService/StartSaveHuman",
"/protobuf.AvailableService/EndSaveHuman",
"/protobuf.AvailableService/Attack",
"/protobuf.AvailableService/CarryHuman",
@@ -63,7 +63,7 @@ namespace protobuf
rpcmethod_GetMessage_(AvailableService_method_names[8], 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_SaveHuman_(AvailableService_method_names[11], 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),
@@ -373,30 +373,30 @@ namespace protobuf
return result;
}

::grpc::Status AvailableService::Stub::SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response)
::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_SaveHuman_, context, request, 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::SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)> f)
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_SaveHuman_, context, request, response, std::move(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::SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor)
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_SaveHuman_, context, request, response, 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::PrepareAsyncSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
::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_SaveHuman_, context, request);
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::AsyncSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AvailableService::Stub::AsyncStartSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
auto* result =
this->PrepareAsyncSaveHumanRaw(context, request, cq);
this->PrepareAsyncStartSaveHumanRaw(context, request, cq);
result->StartCall();
return result;
}
@@ -734,7 +734,7 @@ namespace protobuf
const ::protobuf::IDMsg* req,
::protobuf::BoolRes* resp)
{
return service->SaveHuman(ctx, req, resp);
return service->StartSaveHuman(ctx, req, resp);
},
this
)
@@ -917,7 +917,7 @@ namespace protobuf
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}

::grpc::Status AvailableService::Service::SaveHuman(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response)
::grpc::Status AvailableService::Service::StartSaveHuman(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response)
{
(void)context;
(void)request;


+ 57
- 57
CAPI/proto/Services.grpc.pb.h View File

@@ -148,14 +148,14 @@ namespace protobuf
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>>(PrepareAsyncEndFixMachineRaw(context, request, cq));
}
// 主动停止修复
virtual ::grpc::Status SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response) = 0;
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>> AsyncSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
virtual ::grpc::Status StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response) = 0;
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>> AsyncStartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>>(AsyncSaveHumanRaw(context, request, cq));
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>>(AsyncStartSaveHumanRaw(context, request, cq));
}
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>> PrepareAsyncSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>> PrepareAsyncStartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>>(PrepareAsyncSaveHumanRaw(context, request, cq));
return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>>(PrepareAsyncStartSaveHumanRaw(context, request, cq));
}
// 开始救人
virtual ::grpc::Status EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response) = 0;
@@ -245,8 +245,8 @@ namespace protobuf
virtual void EndFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) = 0;
virtual void EndFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) = 0;
// 主动停止修复
virtual void SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) = 0;
virtual void SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) = 0;
virtual void StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) = 0;
virtual void StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) = 0;
// 开始救人
virtual void EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) = 0;
virtual void EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) = 0;
@@ -296,8 +296,8 @@ namespace protobuf
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* PrepareAsyncStartFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* AsyncEndFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* PrepareAsyncEndFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* AsyncSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* PrepareAsyncSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* AsyncStartSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* PrepareAsyncStartSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* AsyncEndSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* PrepareAsyncEndSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) = 0;
virtual ::grpc::ClientAsyncResponseReaderInterface<::protobuf::BoolRes>* AsyncAttackRaw(::grpc::ClientContext* context, const ::protobuf::AttackMsg& request, ::grpc::CompletionQueue* cq) = 0;
@@ -417,14 +417,14 @@ namespace protobuf
{
return std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>>(PrepareAsyncEndFixMachineRaw(context, request, cq));
}
::grpc::Status SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response) override;
std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>> AsyncSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
::grpc::Status StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response) override;
std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>> AsyncStartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
return std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>>(AsyncSaveHumanRaw(context, request, cq));
return std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>>(AsyncStartSaveHumanRaw(context, request, cq));
}
std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>> PrepareAsyncSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>> PrepareAsyncStartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
{
return std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>>(PrepareAsyncSaveHumanRaw(context, request, cq));
return std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>>(PrepareAsyncStartSaveHumanRaw(context, request, cq));
}
::grpc::Status EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::protobuf::BoolRes* response) override;
std::unique_ptr<::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>> AsyncEndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq)
@@ -505,8 +505,8 @@ namespace protobuf
void StartFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) override;
void EndFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) override;
void EndFixMachine(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) override;
void SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) override;
void SaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) override;
void StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) override;
void StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) override;
void EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) override;
void EndSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, ::grpc::ClientUnaryReactor* reactor) override;
void Attack(::grpc::ClientContext* context, const ::protobuf::AttackMsg* request, ::protobuf::BoolRes* response, std::function<void(::grpc::Status)>) override;
@@ -566,8 +566,8 @@ namespace protobuf
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* PrepareAsyncStartFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AsyncEndFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* PrepareAsyncEndFixMachineRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AsyncSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* PrepareAsyncSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AsyncStartSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* PrepareAsyncStartSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AsyncEndSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* PrepareAsyncEndSaveHumanRaw(::grpc::ClientContext* context, const ::protobuf::IDMsg& request, ::grpc::CompletionQueue* cq) override;
::grpc::ClientAsyncResponseReader<::protobuf::BoolRes>* AsyncAttackRaw(::grpc::ClientContext* context, const ::protobuf::AttackMsg& request, ::grpc::CompletionQueue* cq) override;
@@ -591,7 +591,7 @@ namespace protobuf
const ::grpc::internal::RpcMethod rpcmethod_GetMessage_;
const ::grpc::internal::RpcMethod rpcmethod_StartFixMachine_;
const ::grpc::internal::RpcMethod rpcmethod_EndFixMachine_;
const ::grpc::internal::RpcMethod rpcmethod_SaveHuman_;
const ::grpc::internal::RpcMethod rpcmethod_StartSaveHuman_;
const ::grpc::internal::RpcMethod rpcmethod_EndSaveHuman_;
const ::grpc::internal::RpcMethod rpcmethod_Attack_;
const ::grpc::internal::RpcMethod rpcmethod_CarryHuman_;
@@ -622,7 +622,7 @@ namespace protobuf
// 开始修理机器
virtual ::grpc::Status EndFixMachine(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response);
// 主动停止修复
virtual ::grpc::Status SaveHuman(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response);
virtual ::grpc::Status StartSaveHuman(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response);
// 开始救人
virtual ::grpc::Status EndSaveHuman(::grpc::ServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response);
// 主动停止救人
@@ -941,7 +941,7 @@ namespace protobuf
}
};
template<class BaseClass>
class WithAsyncMethod_SaveHuman : public BaseClass
class WithAsyncMethod_StartSaveHuman : public BaseClass
{
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/)
@@ -949,21 +949,21 @@ namespace protobuf
}

public:
WithAsyncMethod_SaveHuman()
WithAsyncMethod_StartSaveHuman()
{
::grpc::Service::MarkMethodAsync(11);
}
~WithAsyncMethod_SaveHuman() override
~WithAsyncMethod_StartSaveHuman() override
{
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status SaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
::grpc::Status StartSaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
{
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestSaveHuman(::grpc::ServerContext* context, ::protobuf::IDMsg* request, ::grpc::ServerAsyncResponseWriter<::protobuf::BoolRes>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag)
void RequestStartSaveHuman(::grpc::ServerContext* context, ::protobuf::IDMsg* request, ::grpc::ServerAsyncResponseWriter<::protobuf::BoolRes>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag)
{
::grpc::Service::RequestAsyncUnary(11, context, request, response, new_call_cq, notification_cq, tag);
}
@@ -1136,7 +1136,7 @@ namespace protobuf
::grpc::Service::RequestAsyncUnary(17, context, request, response, new_call_cq, notification_cq, tag);
}
};
typedef WithAsyncMethod_TryConnection<WithAsyncMethod_AddPlayer<WithAsyncMethod_Move<WithAsyncMethod_PickProp<WithAsyncMethod_UseProp<WithAsyncMethod_UseSkill<WithAsyncMethod_SendMessage<WithAsyncMethod_HaveMessage<WithAsyncMethod_GetMessage<WithAsyncMethod_StartFixMachine<WithAsyncMethod_EndFixMachine<WithAsyncMethod_SaveHuman<WithAsyncMethod_EndSaveHuman<WithAsyncMethod_Attack<WithAsyncMethod_CarryHuman<WithAsyncMethod_ReleaseHuman<WithAsyncMethod_HangHuman<WithAsyncMethod_Escape<Service>>>>>>>>>>>>>>>>>> AsyncService;
typedef WithAsyncMethod_TryConnection<WithAsyncMethod_AddPlayer<WithAsyncMethod_Move<WithAsyncMethod_PickProp<WithAsyncMethod_UseProp<WithAsyncMethod_UseSkill<WithAsyncMethod_SendMessage<WithAsyncMethod_HaveMessage<WithAsyncMethod_GetMessage<WithAsyncMethod_StartFixMachine<WithAsyncMethod_EndFixMachine<WithAsyncMethod_StartSaveHuman<WithAsyncMethod_EndSaveHuman<WithAsyncMethod_Attack<WithAsyncMethod_CarryHuman<WithAsyncMethod_ReleaseHuman<WithAsyncMethod_HangHuman<WithAsyncMethod_Escape<Service>>>>>>>>>>>>>>>>>> AsyncService;
template<class BaseClass>
class WithCallbackMethod_TryConnection : public BaseClass
{
@@ -1559,7 +1559,7 @@ namespace protobuf
}
};
template<class BaseClass>
class WithCallbackMethod_SaveHuman : public BaseClass
class WithCallbackMethod_StartSaveHuman : public BaseClass
{
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/)
@@ -1567,12 +1567,12 @@ namespace protobuf
}

public:
WithCallbackMethod_SaveHuman()
WithCallbackMethod_StartSaveHuman()
{
::grpc::Service::MarkMethodCallback(11, new ::grpc::internal::CallbackUnaryHandler<::protobuf::IDMsg, ::protobuf::BoolRes>([this](::grpc::CallbackServerContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response)
{ return this->SaveHuman(context, request, response); }));
{ return this->StartSaveHuman(context, request, response); }));
}
void SetMessageAllocatorFor_SaveHuman(
void SetMessageAllocatorFor_StartSaveHuman(
::grpc::MessageAllocator<::protobuf::IDMsg, ::protobuf::BoolRes>* allocator
)
{
@@ -1580,17 +1580,17 @@ namespace protobuf
static_cast<::grpc::internal::CallbackUnaryHandler<::protobuf::IDMsg, ::protobuf::BoolRes>*>(handler)
->SetMessageAllocator(allocator);
}
~WithCallbackMethod_SaveHuman() override
~WithCallbackMethod_StartSaveHuman() override
{
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status SaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
::grpc::Status StartSaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
{
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* SaveHuman(
virtual ::grpc::ServerUnaryReactor* StartSaveHuman(
::grpc::CallbackServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/
)
{
@@ -1831,7 +1831,7 @@ namespace protobuf
return nullptr;
}
};
typedef WithCallbackMethod_TryConnection<WithCallbackMethod_AddPlayer<WithCallbackMethod_Move<WithCallbackMethod_PickProp<WithCallbackMethod_UseProp<WithCallbackMethod_UseSkill<WithCallbackMethod_SendMessage<WithCallbackMethod_HaveMessage<WithCallbackMethod_GetMessage<WithCallbackMethod_StartFixMachine<WithCallbackMethod_EndFixMachine<WithCallbackMethod_SaveHuman<WithCallbackMethod_EndSaveHuman<WithCallbackMethod_Attack<WithCallbackMethod_CarryHuman<WithCallbackMethod_ReleaseHuman<WithCallbackMethod_HangHuman<WithCallbackMethod_Escape<Service>>>>>>>>>>>>>>>>>> CallbackService;
typedef WithCallbackMethod_TryConnection<WithCallbackMethod_AddPlayer<WithCallbackMethod_Move<WithCallbackMethod_PickProp<WithCallbackMethod_UseProp<WithCallbackMethod_UseSkill<WithCallbackMethod_SendMessage<WithCallbackMethod_HaveMessage<WithCallbackMethod_GetMessage<WithCallbackMethod_StartFixMachine<WithCallbackMethod_EndFixMachine<WithCallbackMethod_StartSaveHuman<WithCallbackMethod_EndSaveHuman<WithCallbackMethod_Attack<WithCallbackMethod_CarryHuman<WithCallbackMethod_ReleaseHuman<WithCallbackMethod_HangHuman<WithCallbackMethod_Escape<Service>>>>>>>>>>>>>>>>>> CallbackService;
typedef CallbackService ExperimentalCallbackService;
template<class BaseClass>
class WithGenericMethod_TryConnection : public BaseClass
@@ -2098,7 +2098,7 @@ namespace protobuf
}
};
template<class BaseClass>
class WithGenericMethod_SaveHuman : public BaseClass
class WithGenericMethod_StartSaveHuman : public BaseClass
{
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/)
@@ -2106,16 +2106,16 @@ namespace protobuf
}

public:
WithGenericMethod_SaveHuman()
WithGenericMethod_StartSaveHuman()
{
::grpc::Service::MarkMethodGeneric(11);
}
~WithGenericMethod_SaveHuman() override
~WithGenericMethod_StartSaveHuman() override
{
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status SaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
::grpc::Status StartSaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
{
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
@@ -2574,7 +2574,7 @@ namespace protobuf
}
};
template<class BaseClass>
class WithRawMethod_SaveHuman : public BaseClass
class WithRawMethod_StartSaveHuman : public BaseClass
{
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/)
@@ -2582,21 +2582,21 @@ namespace protobuf
}

public:
WithRawMethod_SaveHuman()
WithRawMethod_StartSaveHuman()
{
::grpc::Service::MarkMethodRaw(11);
}
~WithRawMethod_SaveHuman() override
~WithRawMethod_StartSaveHuman() override
{
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status SaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
::grpc::Status StartSaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
{
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
void RequestSaveHuman(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter<::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag)
void RequestStartSaveHuman(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter<::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag)
{
::grpc::Service::RequestAsyncUnary(11, context, request, response, new_call_cq, notification_cq, tag);
}
@@ -3111,7 +3111,7 @@ namespace protobuf
}
};
template<class BaseClass>
class WithRawCallbackMethod_SaveHuman : public BaseClass
class WithRawCallbackMethod_StartSaveHuman : public BaseClass
{
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/)
@@ -3119,22 +3119,22 @@ namespace protobuf
}

public:
WithRawCallbackMethod_SaveHuman()
WithRawCallbackMethod_StartSaveHuman()
{
::grpc::Service::MarkMethodRawCallback(11, new ::grpc::internal::CallbackUnaryHandler<::grpc::ByteBuffer, ::grpc::ByteBuffer>([this](::grpc::CallbackServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response)
{ return this->SaveHuman(context, request, response); }));
{ return this->StartSaveHuman(context, request, response); }));
}
~WithRawCallbackMethod_SaveHuman() override
~WithRawCallbackMethod_StartSaveHuman() override
{
BaseClassMustBeDerivedFromService(this);
}
// disable synchronous version of this method
::grpc::Status SaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
::grpc::Status StartSaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
{
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
virtual ::grpc::ServerUnaryReactor* SaveHuman(
virtual ::grpc::ServerUnaryReactor* StartSaveHuman(
::grpc::CallbackServerContext* /*context*/, const ::grpc::ByteBuffer* /*request*/, ::grpc::ByteBuffer* /*response*/
)
{
@@ -3598,7 +3598,7 @@ namespace protobuf
virtual ::grpc::Status StreamedEndFixMachine(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer<::protobuf::IDMsg, ::protobuf::BoolRes>* server_unary_streamer) = 0;
};
template<class BaseClass>
class WithStreamedUnaryMethod_SaveHuman : public BaseClass
class WithStreamedUnaryMethod_StartSaveHuman : public BaseClass
{
private:
void BaseClassMustBeDerivedFromService(const Service* /*service*/)
@@ -3606,23 +3606,23 @@ namespace protobuf
}

public:
WithStreamedUnaryMethod_SaveHuman()
WithStreamedUnaryMethod_StartSaveHuman()
{
::grpc::Service::MarkMethodStreamed(11, new ::grpc::internal::StreamedUnaryHandler<::protobuf::IDMsg, ::protobuf::BoolRes>([this](::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer<::protobuf::IDMsg, ::protobuf::BoolRes>* streamer)
{ return this->StreamedSaveHuman(context, streamer); }));
{ return this->StreamedStartSaveHuman(context, streamer); }));
}
~WithStreamedUnaryMethod_SaveHuman() override
~WithStreamedUnaryMethod_StartSaveHuman() override
{
BaseClassMustBeDerivedFromService(this);
}
// disable regular version of this method
::grpc::Status SaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
::grpc::Status StartSaveHuman(::grpc::ServerContext* /*context*/, const ::protobuf::IDMsg* /*request*/, ::protobuf::BoolRes* /*response*/) override
{
abort();
return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "");
}
// replace default version of method with streamed unary
virtual ::grpc::Status StreamedSaveHuman(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer<::protobuf::IDMsg, ::protobuf::BoolRes>* server_unary_streamer) = 0;
virtual ::grpc::Status StreamedStartSaveHuman(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer<::protobuf::IDMsg, ::protobuf::BoolRes>* server_unary_streamer) = 0;
};
template<class BaseClass>
class WithStreamedUnaryMethod_EndSaveHuman : public BaseClass
@@ -3786,7 +3786,7 @@ namespace protobuf
// replace default version of method with streamed unary
virtual ::grpc::Status StreamedEscape(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer<::protobuf::IDMsg, ::protobuf::BoolRes>* server_unary_streamer) = 0;
};
typedef WithStreamedUnaryMethod_TryConnection<WithStreamedUnaryMethod_Move<WithStreamedUnaryMethod_PickProp<WithStreamedUnaryMethod_UseProp<WithStreamedUnaryMethod_UseSkill<WithStreamedUnaryMethod_SendMessage<WithStreamedUnaryMethod_HaveMessage<WithStreamedUnaryMethod_GetMessage<WithStreamedUnaryMethod_StartFixMachine<WithStreamedUnaryMethod_EndFixMachine<WithStreamedUnaryMethod_SaveHuman<WithStreamedUnaryMethod_EndSaveHuman<WithStreamedUnaryMethod_Attack<WithStreamedUnaryMethod_CarryHuman<WithStreamedUnaryMethod_ReleaseHuman<WithStreamedUnaryMethod_HangHuman<WithStreamedUnaryMethod_Escape<Service>>>>>>>>>>>>>>>>> StreamedUnaryService;
typedef WithStreamedUnaryMethod_TryConnection<WithStreamedUnaryMethod_Move<WithStreamedUnaryMethod_PickProp<WithStreamedUnaryMethod_UseProp<WithStreamedUnaryMethod_UseSkill<WithStreamedUnaryMethod_SendMessage<WithStreamedUnaryMethod_HaveMessage<WithStreamedUnaryMethod_GetMessage<WithStreamedUnaryMethod_StartFixMachine<WithStreamedUnaryMethod_EndFixMachine<WithStreamedUnaryMethod_StartSaveHuman<WithStreamedUnaryMethod_EndSaveHuman<WithStreamedUnaryMethod_Attack<WithStreamedUnaryMethod_CarryHuman<WithStreamedUnaryMethod_ReleaseHuman<WithStreamedUnaryMethod_HangHuman<WithStreamedUnaryMethod_Escape<Service>>>>>>>>>>>>>>>>> StreamedUnaryService;
template<class BaseClass>
class WithSplitStreamingMethod_AddPlayer : public BaseClass
{
@@ -3815,7 +3815,7 @@ namespace protobuf
virtual ::grpc::Status StreamedAddPlayer(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer<::protobuf::PlayerMsg, ::protobuf::MessageToClient>* server_split_streamer) = 0;
};
typedef WithSplitStreamingMethod_AddPlayer<Service> SplitStreamedService;
typedef WithStreamedUnaryMethod_TryConnection<WithSplitStreamingMethod_AddPlayer<WithStreamedUnaryMethod_Move<WithStreamedUnaryMethod_PickProp<WithStreamedUnaryMethod_UseProp<WithStreamedUnaryMethod_UseSkill<WithStreamedUnaryMethod_SendMessage<WithStreamedUnaryMethod_HaveMessage<WithStreamedUnaryMethod_GetMessage<WithStreamedUnaryMethod_StartFixMachine<WithStreamedUnaryMethod_EndFixMachine<WithStreamedUnaryMethod_SaveHuman<WithStreamedUnaryMethod_EndSaveHuman<WithStreamedUnaryMethod_Attack<WithStreamedUnaryMethod_CarryHuman<WithStreamedUnaryMethod_ReleaseHuman<WithStreamedUnaryMethod_HangHuman<WithStreamedUnaryMethod_Escape<Service>>>>>>>>>>>>>>>>>> StreamedService;
typedef WithStreamedUnaryMethod_TryConnection<WithSplitStreamingMethod_AddPlayer<WithStreamedUnaryMethod_Move<WithStreamedUnaryMethod_PickProp<WithStreamedUnaryMethod_UseProp<WithStreamedUnaryMethod_UseSkill<WithStreamedUnaryMethod_SendMessage<WithStreamedUnaryMethod_HaveMessage<WithStreamedUnaryMethod_GetMessage<WithStreamedUnaryMethod_StartFixMachine<WithStreamedUnaryMethod_EndFixMachine<WithStreamedUnaryMethod_StartSaveHuman<WithStreamedUnaryMethod_EndSaveHuman<WithStreamedUnaryMethod_Attack<WithStreamedUnaryMethod_CarryHuman<WithStreamedUnaryMethod_ReleaseHuman<WithStreamedUnaryMethod_HangHuman<WithStreamedUnaryMethod_Escape<Service>>>>>>>>>>>>>>>>>> StreamedService;
};

} // namespace protobuf


+ 12
- 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) =
"\n\016Services.proto\022\010protobuf\032\025Message2Clie"
"nts.proto\032\024Message2Server.proto2\246\007\n\020Avai"
"nts.proto\032\024Message2Server.proto2\253\007\n\020Avai"
"lableService\0223\n\rTryConnection\022\017.protobuf"
".IDMsg\032\021.protobuf.BoolRes\022=\n\tAddPlayer\022\023"
".protobuf.PlayerMsg\032\031.protobuf.MessageTo"
@@ -46,16 +46,16 @@ const char descriptor_table_protodef_Services_2eproto[] PROTOBUF_SECTION_VARIABL
"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\022/\n\tSaveHuman\022\017.prot"
"obuf.IDMsg\032\021.protobuf.BoolRes\0222\n\014EndSave"
"Human\022\017.protobuf.IDMsg\032\021.protobuf.BoolRe"
"s\0220\n\006Attack\022\023.protobuf.AttackMsg\032\021.proto"
"buf.BoolRes\0220\n\nCarryHuman\022\017.protobuf.IDM"
"sg\032\021.protobuf.BoolRes\0222\n\014ReleaseHuman\022\017."
"protobuf.IDMsg\032\021.protobuf.BoolRes\022/\n\tHan"
"gHuman\022\017.protobuf.IDMsg\032\021.protobuf.BoolR"
"es\022,\n\006Escape\022\017.protobuf.IDMsg\032\021.protobuf"
".BoolResb\006proto3";
"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] = {
&::descriptor_table_Message2Clients_2eproto,
&::descriptor_table_Message2Server_2eproto,
@@ -64,7 +64,7 @@ static ::_pbi::once_flag descriptor_table_Services_2eproto_once;
const ::_pbi::DescriptorTable descriptor_table_Services_2eproto = {
false,
false,
1016,
1021,
descriptor_table_protodef_Services_2eproto,
"Services.proto",
&descriptor_table_Services_2eproto_once,


+ 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>

+ 1
- 1
dependency/proto/Services.proto View File

@@ -21,7 +21,7 @@ service AvailableService
rpc GetMessage(IDMsg) returns (MsgRes);
rpc StartFixMachine(IDMsg) returns (BoolRes); // 开始修理机器
rpc EndFixMachine(IDMsg) returns (BoolRes); // 主动停止修复
rpc SaveHuman(IDMsg) returns (BoolRes); // 开始救人
rpc StartSaveHuman(IDMsg) returns (BoolRes); // 开始救人
rpc EndSaveHuman(IDMsg) returns (BoolRes); // 主动停止救人
rpc Attack (AttackMsg) returns (BoolRes);
rpc CarryHuman (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
find . -iname "*.cs" \
-or -iname "*.c" \
find . -iname "*.c" \
-or -iname "*.h" \
-or -iname "*.C" \
-or -iname "*.H" \
@@ -19,3 +22,10 @@ find . -iname "*.cs" \
-or -iname "*.i++" \
| xargs clang-format -i
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;

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


+ 169
- 8
installer/Installer/Model.cs View File

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

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));
});
// 执行请求
@@ -680,4 +687,158 @@ namespace Downloader
}
}
}
}
}

namespace WebConnect
{
class Web
{
public static string logintoken = "";
async public Task LoginToEEsast(HttpClient client, string useremail, string password)
{
string token = "";
using (var response = await client.PostAsync("https://api.eesast.com/users/login", JsonContent.Create(new
{
email = useremail,
password = password,
})))
{
switch (response.StatusCode)
{
case System.Net.HttpStatusCode.OK:
Console.WriteLine("Success login");
token = (System.Text.Json.JsonSerializer.Deserialize(await response.Content.ReadAsStreamAsync(), typeof(LoginResponse), new JsonSerializerOptions()
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
}) as LoginResponse)?.Token ?? throw new Exception("no token!");
logintoken = token;
SaveToken();
break;

default:
int code = ((int)response.StatusCode);
Console.WriteLine(code);
if (code == 401)
{
Console.WriteLine("邮箱或密码错误!");
}
return;
}
}
}

async public Task UserDetails(HttpClient client) //用来测试访问网站
{
if (!ReadToken()) //读取token失败
{
return;
}
try
{
client.DefaultRequestHeaders.Authorization = new("Bearer", logintoken);
Console.WriteLine(logintoken);
using (var response = await client.GetAsync("https://api.eesast.com/application/info")) //JsonContent.Create(new
//{

//})))
{
switch (response.StatusCode)
{
case System.Net.HttpStatusCode.OK:
Console.WriteLine("Require OK");
Console.WriteLine(await response.Content.ReadAsStringAsync());
break;
default:
int code = ((int)response.StatusCode);
if (code == 401)
{
Console.WriteLine("您未登录或登录过期,请先登录");
}
return;
}
}
}
catch
{
Console.WriteLine("请求错误!请检查网络连接!");
}
}

public void SaveToken()//保存token
{
string savepath = Path.Combine(Data.dataPath, "Token.dat");
try
{
FileStream fs = new FileStream(savepath, FileMode.OpenOrCreate, FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs);
fs.SetLength(0);
sw.Write(logintoken); //将token写入文件
sw.Close();
fs.Close();
}
catch (DirectoryNotFoundException)
{
Console.WriteLine("保存token时未找到下载器地址!请检查下载器是否被移动!");
}
catch (PathTooLongException)
{
Console.WriteLine("下载器的路径名太长!请尝试移动下载器!");
}
catch (ArgumentNullException)
{
Console.WriteLine("下载器路径初始化失败!");
}
catch (IOException)
{
Console.WriteLine("写入token.dat发生冲突!请检查token.dat是否被其它程序占用!");
}
}
public bool ReadToken()//读取token
{
try
{
string savepath = Path.Combine(Data.dataPath, "Token.dat");
FileStream fs = new FileStream(savepath, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
logintoken = sr.ReadLine();
sr.Close();
fs.Close();
return true;
}
catch (DirectoryNotFoundException)
{
Console.WriteLine("读取token时未找到下载器地址!请检查下载器是否被移动!");
return false;
}
catch (FileNotFoundException)
{
//没有登陆
Console.WriteLine("请先登陆!");
return false;
}
catch (PathTooLongException)
{
Console.WriteLine("下载器的路径名太长!请尝试移动下载器!");
return false;
}
catch (ArgumentNullException)
{
Console.WriteLine("下载器路径初始化失败!");
return false;
}
catch (IOException)
{
Console.WriteLine("写入token.dat发生冲突!请检查token.dat是否被其它程序占用!");
return false;
}
}
}
[Serializable]
record LoginResponse
{
// Map `Token` to `token` when serializing

public string Token { get; set; } = "";
}

}

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

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

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

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

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

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

[assembly:ThemeInfo(
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// 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>
</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>

+ 7
- 0
logic/cmd/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

+ 12
- 0
logic/logic.sln View File

@@ -5,6 +5,10 @@ VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "Server\Server.csproj", "{D033B809-2FB7-4340-B8B4-DDA30D6CA6FF}"
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
GlobalSection(SolutionConfigurationPlatforms) = preSolution
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}.Release|Any CPU.ActiveCfg = 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
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


Loading…
Cancel
Save