From 2f4d57f8756948aa3cf9028864355de53c656441 Mon Sep 17 00:00:00 2001
From: gsy1519 <614054460@qq.com>
Date: Tue, 8 Nov 2022 14:08:57 +0800
Subject: [PATCH 01/17] chore: start
---
logic/ClientTest/ClientTest.csproj | 20 +++++
logic/ClientTest/Program.cs | 36 +++++++++
logic/Protos/Message2Clients.proto | 125 +++++++++++++++++++++++++++++
logic/Protos/Message2Server.proto | 62 ++++++++++++++
logic/Protos/MessageType.proto | 110 +++++++++++++++++++++++++
logic/Protos/Protos.csproj | 32 ++++++++
logic/Server/Game.cs | 104 ++++++++++++++++++++++++
logic/Server/GameServer.cs | 123 ++++++++++++++++++++++++++++
logic/Server/Program.cs | 37 ++++++++-
logic/Server/Server.csproj | 15 ++++
logic/logic.sln | 12 +++
logic/test.cmd | 7 ++
12 files changed, 681 insertions(+), 2 deletions(-)
create mode 100644 logic/ClientTest/ClientTest.csproj
create mode 100644 logic/ClientTest/Program.cs
create mode 100644 logic/Protos/Message2Clients.proto
create mode 100644 logic/Protos/Message2Server.proto
create mode 100644 logic/Protos/MessageType.proto
create mode 100644 logic/Protos/Protos.csproj
create mode 100644 logic/Server/Game.cs
create mode 100644 logic/Server/GameServer.cs
create mode 100644 logic/test.cmd
diff --git a/logic/ClientTest/ClientTest.csproj b/logic/ClientTest/ClientTest.csproj
new file mode 100644
index 0000000..e9bbb1e
--- /dev/null
+++ b/logic/ClientTest/ClientTest.csproj
@@ -0,0 +1,20 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/logic/ClientTest/Program.cs b/logic/ClientTest/Program.cs
new file mode 100644
index 0000000..529dce3
--- /dev/null
+++ b/logic/ClientTest/Program.cs
@@ -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("127.0.0.1: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})");
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/logic/Protos/Message2Clients.proto b/logic/Protos/Message2Clients.proto
new file mode 100644
index 0000000..edae464
--- /dev/null
+++ b/logic/Protos/Message2Clients.proto
@@ -0,0 +1,125 @@
+// Message2Client
+syntax = "proto3";
+package protobuf;
+
+import "MessageType.proto";
+import "Message2Server.proto";
+
+message MessageOfHuman
+{
+ int32 x = 1;
+ int32 y = 2;
+ int32 speed = 3;
+ int32 life = 4; // 本次未倒地前的血量,也即还可以受的伤害
+ int32 hanged_time = 5; // 被挂上的次数
+ double time_until_skill_available = 6;
+ PlaceType place = 7;
+ PropType prop = 8;
+ HumanType human_type = 9;
+ int64 guid = 10;
+ bool on_chair = 11; // 是否被挂
+ double chair_time = 12; // 被挂的时间
+ bool on_ground = 13; // 是否倒地
+ double ground_time = 14; // 倒地时间
+ int64 player_id = 15;
+ int32 view_range = 16; // 视野距离
+ repeated HumanBuffType buff = 17;
+}
+
+message MessageOfButcher
+{
+ int32 x = 1;
+ int32 y = 2;
+ int32 speed = 3;
+ int32 damage = 4;
+ double time_until_skill_available = 5;
+ PlaceType place = 6;
+ PropType prop = 7;
+ ButcherType butcher_type = 8;
+ int64 guid = 9;
+ bool movable = 10; // 是否进入了攻击后摇
+ int64 playerID = 11;
+ int32 view_range = 12; // 视野距离
+ repeated ButcherBuffType buff = 13;
+}
+
+message MessageOfProp // 可拾取道具的信息
+{
+ PropType type = 1;
+ int32 x = 2;
+ int32 y = 3;
+ double facing_direction = 4;
+ int64 guid = 5;
+ PlaceType place = 6;
+ int32 size = 7;
+ bool is_moving = 8;
+}
+
+message MessageOfPickedProp //for Unity,直接继承自THUAI5
+{
+ PropType type = 1;
+ int32 x = 2;
+ int32 y = 3;
+ double facing_direction = 4;
+ int64 mapping_id = 5;
+}
+
+message MessageOfMap
+{
+ message Row
+ {
+ repeated PlaceType col = 1;
+ }
+ repeated Row row = 2;
+}
+
+message MessageToClient
+{
+ repeated MessageOfHuman human_message = 1;
+ repeated MessageOfButcher butcher_message = 2; // 是否真正repeated待定
+ repeated MessageOfProp prop_message = 3;
+ MessageOfMap map_massage = 4;
+}
+
+message MoveRes // 如果打算设计撞墙保留平行速度分量,且需要返回值则可用这个(大概没啥用)
+{
+ int64 actual_speed = 1;
+ double actual_angle = 2;
+}
+
+message BoolRes // 用于只需要判断执行操作是否成功的行为,如捡起道具、使用道具
+{
+ bool act_success = 1;
+}
+
+message MsgRes // 用于获取队友发来的消息
+{
+ bool have_message = 1; // 是否有待接收的消息
+ int64 from_player_id = 2;
+ string message_received = 3;
+}
+
+service AvailableService
+{
+ rpc TryConnection(IDMsg) returns(BoolRes);
+
+ // 游戏开局调用一次的服务
+ rpc AddPlayer(PlayerMsg) returns(stream MessageToClient); // 连接上后等待游戏开始,server会定时通过该服务向所有client发送消息。
+
+ // 游戏过程中玩家执行操作的服务
+ rpc Move(MoveMsg) returns (MoveRes);
+ rpc PickProp(PickMsg) returns (BoolRes);
+ rpc UseProp(IDMsg) returns (BoolRes);
+ rpc UseSkill(IDMsg) returns (BoolRes);
+ rpc SendMessage(SendMsg) returns (BoolRes);
+ rpc HaveMessage(IDMsg) returns (BoolRes);
+ rpc GetMessage(IDMsg) returns (MsgRes);
+ rpc FixMachine(stream IDMsg) returns (stream BoolRes); // 若正常修复且未被打断则返回修复成功,位置错误/被打断则返回修复失败,下同
+ rpc SaveHuman(stream IDMsg) returns (stream BoolRes);
+ rpc Attack (AttackMsg) returns (BoolRes);
+ rpc CarryHuman (IDMsg) returns (BoolRes);
+ rpc ReleaseHuman (IDMsg) returns (BoolRes);
+ rpc HangHuman (IDMsg) returns (BoolRes);
+ rpc Escape (IDMsg) returns (BoolRes);
+
+}
\ No newline at end of file
diff --git a/logic/Protos/Message2Server.proto b/logic/Protos/Message2Server.proto
new file mode 100644
index 0000000..b3891b6
--- /dev/null
+++ b/logic/Protos/Message2Server.proto
@@ -0,0 +1,62 @@
+// Message2Server
+syntax = "proto3";
+package protobuf;
+
+import "MessageType.proto";
+
+message PlayerMsg
+{
+ int64 player_id = 1;
+ PlayerType player_type = 2;
+ oneof job_type
+ {
+ HumanType human_type = 3;
+ ButcherType butcher_type = 4;
+ }
+}
+
+message MoveMsg
+{
+ int64 player_id = 1;
+ double angle = 2;
+ int64 time_in_milliseconds = 3;
+}
+
+message PickMsg
+{
+ int64 player_id = 1;
+ PropType prop_type = 2;
+}
+
+message SendMsg
+{
+ int64 player_id = 1;
+ int64 to_player_id = 2;
+ string message = 3;
+}
+
+message AttackMsg
+{
+ int64 player_id = 1;
+ double angle = 2;
+}
+
+message IDMsg
+{
+ int64 player_id = 1;
+}
+
+// 基本继承于THUAI5,为了使发送的信息尽可能不被浪费,暂定不发这类大包。
+// message MessageToServer
+// {
+// MessageType messageType = 1;
+// int64 playerID = 2; // 消息发送者的playerID
+// PlayerType playerType = 3;
+// HumanType humanType= 4;
+// ButcherType butcherType = 5;
+// double angle = 6; // messageType为Move, Attack时的角度
+// PropType propType = 7; // messageType为PickProp时要捡起的道具类型,防止多个道具堆叠时出现问题
+// int64 timeInMilliseconds = 8;//时间参数
+// int64 ToPlayerID = 9; // messageType为Send时要发送的对象的ID
+// string message = 10; // messageType为Send时发送的消息内容
+// }
\ No newline at end of file
diff --git a/logic/Protos/MessageType.proto b/logic/Protos/MessageType.proto
new file mode 100644
index 0000000..2041fe0
--- /dev/null
+++ b/logic/Protos/MessageType.proto
@@ -0,0 +1,110 @@
+// MessageType
+syntax = "proto3";
+package protobuf;
+
+enum PlaceType // 地图中的所有物件类型
+{
+ NULL_PLACE_TYPE = 0;
+
+ // 地图情况,其中Gate是总体的大门,HiddenGate是地窖
+ LAND = 1;
+ WALL = 2;
+ GRASS = 3;
+ MACHINE = 4;
+ GATE = 5;
+ HIDDEN_GATE = 6;
+ // 待补充有特殊效果的地形
+
+}
+
+enum ShapeType // 形状类型
+{
+ NULL_SHAPE_TYPE = 0;
+ CIRCLE = 1; // 人类、屠夫、可拾取道具等为圆形
+ SQUARE = 2; // 地形均为方形
+}
+
+enum PropType // 地图中的可拾取道具类型
+{
+ NULL_PROP_TYPE = 0;
+ PTYPE1 = 1;
+ PTYPE2 = 2;
+ PTYPE3 = 3;
+ PTYPE4 = 4;
+
+}
+
+enum HumanBuffType // 人类可用的增益效果类型
+{
+ NULL_HBUFF_TYPE = 0;
+ HBUFFTYPE1 = 1;
+ HBUFFTYPE2 = 2;
+ HBUFFTYPE3 = 3;
+ HBUFFTYPE4 = 4;
+}
+
+enum ButcherBuffType // 屠夫可用的增益效果类型
+{
+ NULL_BBUFF_TYPE = 0;
+ BBUFFTYPE1 = 1;
+ BBUFFTYPE2 = 2;
+ BBUFFTYPE3 = 3;
+ BBUFFTYPE4 = 4;
+}
+
+// 特别说明:由于Human阵营和Butcher阵营有显著的隔离,且暂定职业、主动技能和被动效果相互绑定,故不按照THUAI5的方式区分ActiveSkillType和PassiveSkillType,而是选择了按照阵营来给不同阵营赋予不同的职业(及技能)。
+
+enum PlayerType
+{
+ NULL_PLAYER_TYPE = 0;
+ HUMAN_PLAYER = 1;
+ BUTCHER_PLAYER = 2;
+}
+
+enum HumanType
+{
+ NULL_HUMAN_TYPE = 0;
+ HUMANTYPE1 = 1;
+ HUMANTYPE2 = 2;
+ HUMANTYPE3 = 3;
+ HUMANTYPE4 = 4;
+}
+
+enum ButcherType
+{
+ NULL_BUTCHER_TYPE = 0;
+ BUTCHERTYPE1 = 1;
+ BUTCHERTYPE2 = 2;
+ BUTCHERTYPE3 = 3;
+ BUTCHERTYPE4 = 4;
+}
+
+// 取消了大包之后,MessageType的枚举是否有必要保留还有待商榷
+// enum MessageType
+// {
+// // 公共信息类型
+// Move = 0;
+// PickProp = 1;
+// UseProp = 2;
+// UseSkill = 3;
+// Map = 4;
+// Send = 5;
+
+// // 人类限定信息类型
+// FixMachine = 6;
+// SaveHuman = 7;
+
+// // 屠夫限定信息类型
+// Attack = 8;
+// CarryHuman = 9;
+// ReleaseHuman = 10;
+// HangHuman = 11;
+
+// // 游戏相关信息类型
+// AddPlayer = 12;
+// InvalidPlayer = 13;
+// ValidPlayer = 14;
+// StartGame = 15;
+// Gaming = 16;
+// EndGame = 17;
+// }
diff --git a/logic/Protos/Protos.csproj b/logic/Protos/Protos.csproj
new file mode 100644
index 0000000..e6fac69
--- /dev/null
+++ b/logic/Protos/Protos.csproj
@@ -0,0 +1,32 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
diff --git a/logic/Server/Game.cs b/logic/Server/Game.cs
new file mode 100644
index 0000000..96e7680
--- /dev/null
+++ b/logic/Server/Game.cs
@@ -0,0 +1,104 @@
+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
+ (
+ () => 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;
+ }
+ }
+}
diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs
new file mode 100644
index 0000000..c31d611
--- /dev/null
+++ b/logic/Server/GameServer.cs
@@ -0,0 +1,123 @@
+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 semaDict = new();
+ private object gameLock = new();
+ private const int playerNum = 2;
+ private MessageToClient currentGameInfo = new();
+ private Game game = new();
+ public int GameTime => game.GameTime;
+ private SemaphoreSlim endGameSem = new(0);
+
+ public override Task 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 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
+ (
+ () => 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()
+ {
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/logic/Server/Program.cs b/logic/Server/Program.cs
index 3751555..155a97b 100644
--- a/logic/Server/Program.cs
+++ b/logic/Server/Program.cs
@@ -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());
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/logic/Server/Server.csproj b/logic/Server/Server.csproj
index 74abf5c..b87aa89 100644
--- a/logic/Server/Server.csproj
+++ b/logic/Server/Server.csproj
@@ -7,4 +7,19 @@
enable
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
diff --git a/logic/logic.sln b/logic/logic.sln
index 51f61b6..2fc1991 100644
--- a/logic/logic.sln
+++ b/logic/logic.sln
@@ -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}") = "Protos", "Protos\Protos.csproj", "{EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientTest", "ClientTest\ClientTest.csproj", "{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}"
+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
+ {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/logic/test.cmd b/logic/test.cmd
new file mode 100644
index 0000000..0ea590e
--- /dev/null
+++ b/logic/test.cmd
@@ -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
From d20065bca5922911d0d616589a8714a2bfdf0861 Mon Sep 17 00:00:00 2001
From: gsy1519 <614054460@qq.com>
Date: Tue, 8 Nov 2022 15:24:53 +0800
Subject: [PATCH 02/17] chore: start
---
logic/ClientTest/Program.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/logic/ClientTest/Program.cs b/logic/ClientTest/Program.cs
index 529dce3..cc4c95d 100644
--- a/logic/ClientTest/Program.cs
+++ b/logic/ClientTest/Program.cs
@@ -16,14 +16,14 @@ namespace ClientTest
while (await call.ResponseStream.MoveNext())
{
var currentGameInfo = call.ResponseStream.Current;
- if (playerInfo.PlayerType == PlayerType.HumanPlayer)
+ //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)
+ //if (playerInfo.PlayerType == PlayerType.ButcherPlayer)
{
for (int i = 0; i < currentGameInfo.ButcherMessage.Count; i++)
{
From 84c540f00fbe3e840611d069f5823dc51370156f Mon Sep 17 00:00:00 2001
From: gsy1519 <614054460@qq.com>
Date: Tue, 8 Nov 2022 19:43:42 +0800
Subject: [PATCH 03/17] chore: :sparkles: start server
server
---
logic/ClientTest/Program.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/logic/ClientTest/Program.cs b/logic/ClientTest/Program.cs
index cc4c95d..529dce3 100644
--- a/logic/ClientTest/Program.cs
+++ b/logic/ClientTest/Program.cs
@@ -16,14 +16,14 @@ namespace ClientTest
while (await call.ResponseStream.MoveNext())
{
var currentGameInfo = call.ResponseStream.Current;
- //if (playerInfo.PlayerType == PlayerType.HumanPlayer)
+ 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)
+ if (playerInfo.PlayerType == PlayerType.ButcherPlayer)
{
for (int i = 0; i < currentGameInfo.ButcherMessage.Count; i++)
{
From 8caa092d877ffc311df8dd28c8b0a2a9f48d7344 Mon Sep 17 00:00:00 2001
From: sky <2336526392@qq.com>
Date: Sun, 13 Nov 2022 10:32:08 +0800
Subject: [PATCH 04/17] update
---
installer/Installer/MainWindow.xaml.cs | 682 +------------------------
1 file changed, 1 insertion(+), 681 deletions(-)
diff --git a/installer/Installer/MainWindow.xaml.cs b/installer/Installer/MainWindow.xaml.cs
index 7aa67c0..5f28270 100644
--- a/installer/Installer/MainWindow.xaml.cs
+++ b/installer/Installer/MainWindow.xaml.cs
@@ -1,681 +1 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-using COSXML;
-using COSXML.Auth;
-using COSXML.Model.Object;
-using COSXML.Model.Bucket;
-using COSXML.CosException;
-using System.IO;
-using Newtonsoft.Json;
-using System.Runtime.InteropServices;
-using System.Security.Cryptography;
-using System.Text.Json.Nodes;
-using System.Diagnostics;
-
-namespace Installer
-{
- ///
- /// Interaction logic for MainWindow.xaml
- ///
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- }
-}
-
-namespace Downloader
-{
- class Program
- {
- static List newFileName = new List(); //新文件名
- static List updateFileName = new List(); //更新文件名
- static string ProgramName = "THUAI6"; //要运行或下载的程序名称
- static string playerFolder = "player"; //选手代码保存文件夹路径
- static string startName = "maintest.exe"; //启动的程序名
-
- public class Data
- {
- public static string path = ""; //标记路径记录文件THUAI6.dat的路径
- public static string FilePath = ""; //最后一级为THUAI6文件夹所在目录
- public static string dataPath = ""; // C盘的文档文件夹
- public Data(string path)
- {
- // dataPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
- dataPath = new DirectoryInfo(".").FullName;
- Data.path = System.IO.Path.Combine(dataPath, "THUAI6.dat");
- if (File.Exists(Data.path))
- {
- using (StreamReader r = new StreamReader(Data.path))
- FilePath = r.ReadLine().Replace('\\', '/'); //读取THUAI6.dat文件的第一行
- }
- else
- {
- FilePath = System.IO.Path.GetDirectoryName(@path);
-
- //将dat文件写入程序运行路径
- FileStream fs = new FileStream(Data.path, FileMode.Create, FileAccess.ReadWrite);
- StreamWriter sw = new StreamWriter(fs);
- sw.Write(path);
- sw.Flush();
- sw.Close();
- }
- }
-
- public static void ChangeData(string newLine)
- {
- if (Directory.Exists(@newLine)) //判断文件夹是否存在
- {
- Console.Write($"是否创建新路径 {newLine}?y/n:");
- if (Console.Read() != 'y')
- {
- Console.WriteLine("创建取消!");
- return;
- }
-
- using (StreamWriter w = new StreamWriter(path))
- w.WriteLine(@newLine.Trim('\r').Trim('\n'));
- Console.WriteLine($"当前下载路径为{newLine}");
- }
- }
-
- public static void ResetFilepath(string newPath)
- {
- FilePath = newPath.Replace('\\', '/');
- path = System.IO.Path.Combine(dataPath, "THUAI6.dat");
- FileStream fs = new FileStream(Data.path, FileMode.Create, FileAccess.ReadWrite);
- StreamWriter sw = new StreamWriter(fs);
- fs.SetLength(0);
- sw.Write(newPath);
- sw.Flush();
- sw.Close();
- fs.Close();
- }
- }
- public class Tencent_cos_download
- {
- public void download(string download_dir, string key)
- {
- // download_dir标记根文件夹路径,key为相对根文件夹的路径(不带./)
- //初始化CosXmlConfig(提供配置SDK接口)
- string appid = "1314234950"; //设置腾讯云账户的账户标识(APPID)
- string region = "ap-beijing"; //设置一个默认的存储桶地域
- CosXmlConfig config = new CosXmlConfig.Builder()
- .IsHttps(true) //设置默认 HTTPS 请求
- .SetAppid(appid) //设置腾讯云账户的账户标识 APPID
- .SetRegion(region) //设置一个默认的存储桶地域
- .SetDebugLog(true) //显示日志
- .Build(); //创建 CosXmlConfig 对象
-
- //永久密钥访问凭证
- string secretId = "***"; //"云 API 密钥 SecretId";
- string secretKey = "***"; //"云 API 密钥 SecretKey";
-
- long durationSecond = 1000; //每次请求签名有效时长,单位为秒
- QCloudCredentialProvider cosCredentialProvider = new DefaultQCloudCredentialProvider(
- secretId, secretKey, durationSecond
- );
- //初始化 CosXmlServer
- CosXmlServer cosXml = new CosXmlServer(config, cosCredentialProvider);
-
- //创建存储桶
- try
- {
- string bucket = "thuai6-1314234950"; //格式:BucketName-APPID
- string localDir = System.IO.Path.GetDirectoryName(download_dir); //本地文件夹
- string localFileName = System.IO.Path.GetFileName(download_dir); //指定本地保存的文件名
- string localFileName = System.IO.Path.GetFileName(download_dir); //指定本地保存的文件名
- GetObjectRequest request = new GetObjectRequest(bucket, key, localDir, localFileName);
-
- Dictionary test = request.GetRequestHeaders();
- request.SetCosProgressCallback(delegate(long completed, long total) {
- Console.WriteLine(String.Format("progress = {0:##.##}%", completed * 100.0 / total));
- });
- //执行请求
- GetObjectResult result = cosXml.GetObject(request);
- //请求成功
- }
- catch (CosClientException clientEx)
- {
- throw clientEx;
- }
- catch (CosServerException serverEx)
- {
- throw serverEx;
- }
- }
-
- public static void GetNewHash()
- {
- Tencent_cos_download Downloader = new Tencent_cos_download();
- Downloader.download(System.IO.Path.Combine(Data.FilePath, "hash.json"), "hash.json");
- }
-
- public static string GetFileMd5Hash(string strFileFullPath)
- {
- FileStream fst = null;
- try
- {
- fst = new FileStream(strFileFullPath, FileMode.Open);
- byte[] data = MD5.Create().ComputeHash(fst);
-
- StringBuilder sBuilder = new StringBuilder();
-
- for (int i = 0; i < data.Length; i++)
- {
- sBuilder.Append(data[i].ToString("x2"));
- }
-
- fst.Close();
- return sBuilder.ToString().ToLower();
- }
- catch (Exception)
- {
- if (fst != null)
- fst.Close();
- return "";
- }
- finally
- {
- }
- }
-
- private static void Check()
- {
- string json, MD5, jsonName;
- int newFile = 0, updateFile = 0;
- newFileName.Clear();
- updateFileName.Clear();
- jsonName = "hash.json";
-
- Tencent_cos_download Downloader = new Tencent_cos_download();
- try
- {
- //如果json存在就删了重新下
- if (File.Exists(System.IO.Path.Combine(Data.FilePath, jsonName)))
- {
- File.Delete(System.IO.Path.Combine(Data.FilePath, jsonName));
- Downloader.download(System.IO.Path.Combine(Data.FilePath, jsonName), jsonName);
- }
- else
- {
- Downloader.download(System.IO.Path.Combine(Data.FilePath, jsonName), jsonName);
- }
- }
- catch (CosClientException clientEx)
- {
- //请求失败
- Console.WriteLine("CosClientException: " + clientEx.ToString() + Environment.NewLine);
- return;
- }
- catch (CosServerException serverEx)
- {
- //请求失败
- Console.WriteLine("CosClientException: " + serverEx.ToString() + Environment.NewLine);
- return;
- }
-
- using (StreamReader r = new StreamReader(System.IO.Path.Combine(Data.FilePath, jsonName)))
- json = r.ReadToEnd();
- json = json.Replace("\r", string.Empty).Replace("\n", string.Empty);
- Dictionary jsonDict = JsonConvert.DeserializeObject>(json);
- foreach (KeyValuePair pair in jsonDict)
- {
- MD5 = GetFileMd5Hash(System.IO.Path.Combine(Data.FilePath, pair.Key));
- if (MD5.Length == 0) //文档不存在
- newFileName.Add(pair.Key);
- else if (MD5 != pair.Value) // MD5不匹配
- updateFileName.Add(pair.Key);
- }
-
- newFile = newFileName.Count;
- updateFile = updateFileName.Count;
- Console.WriteLine("----------------------" + Environment.NewLine);
-
- if (newFile + updateFile == 0)
- {
- Console.WriteLine("当前平台已是最新版本!" + Environment.NewLine);
- newFileName.Clear();
- updateFileName.Clear();
- }
- else
- {
- Console.WriteLine($"发现{newFile}个新文件" + Environment.NewLine);
- foreach (string filename in newFileName)
- {
- Console.WriteLine(filename);
- }
- Console.WriteLine(Environment.NewLine + $"发现{updateFile}个文件更新" + Environment.NewLine);
- foreach (string filename in updateFileName)
- {
- Console.WriteLine(filename);
- }
- Console.Write(Environment.NewLine + "是否下载新文件? y/n:");
- if (Console.Read() != 'y')
- Console.WriteLine("下载取消!");
- else
- Download();
- }
- }
- private static void Download()
- {
- Tencent_cos_download Downloader = new Tencent_cos_download();
-
- int newFile = 0, updateFile = 0;
- int totalnew = newFileName.Count, totalupdate = updateFileName.Count;
-
- if (newFileName.Count > 0 || updateFileName.Count > 0)
- {
- try
- {
- foreach (string filename in newFileName)
- {
- Console.WriteLine(newFile + 1 + "/" + totalnew + ":开始下载" + filename);
- Downloader.download(System.IO.Path.Combine(@Data.FilePath, filename), filename);
- Console.WriteLine(filename + "下载完毕!" + Environment.NewLine);
- newFile++;
- }
- foreach (string filename in updateFileName)
- {
- Console.WriteLine(updateFile + 1 + "/" + totalupdate + ":开始下载" + filename);
- File.Delete(System.IO.Path.Combine(@Data.FilePath, filename));
- Downloader.download(System.IO.Path.Combine(@Data.FilePath, filename), filename);
- Console.WriteLine(filename + "下载完毕!" + Environment.NewLine);
- updateFile++;
- }
- }
- catch (CosClientException clientEx)
- {
- //请求失败
- Console.WriteLine("CosClientException: " + clientEx.ToString() + Environment.NewLine);
- return;
- }
- catch (CosServerException serverEx)
- {
- //请求失败
- Console.WriteLine("CosClientException: " + serverEx.ToString() + Environment.NewLine);
- return;
- }
- catch (Exception)
- {
- throw;
- }
- }
- else
- Console.WriteLine("当前平台已是最新版本!" + Environment.NewLine);
- newFileName.Clear();
- updateFileName.Clear();
- }
-
- public static bool CheckAlreadyDownload() //检查是否已经下载
- {
- string existpath = System.IO.Path.Combine(Data.dataPath, "Exists.txt");
- if (!File.Exists(existpath)) //文件不存在
- {
- FileStream fs = new FileStream(existpath, FileMode.Create, FileAccess.ReadWrite);
- fs.Close();
- return false;
- }
- else //文件存在
- {
- FileStream fs = new FileStream(existpath, FileMode.Open, FileAccess.Read);
- StreamReader sr = new StreamReader(fs);
- if ("true" == sr.ReadLine())
- {
- sr.Close();
- fs.Close();
- return true;
- }
- else
- {
- sr.Close();
- fs.Close();
- return false;
- }
- }
- }
-
- public static void DownloadAll() //下载全部文件
- {
- string jsonName = "hash.json";
- string json;
- Tencent_cos_download Downloader = new Tencent_cos_download();
-
- try
- {
- //如果json存在就删了重新下
- if (File.Exists(System.IO.Path.Combine(Data.FilePath, jsonName)))
- {
- File.Delete(System.IO.Path.Combine(Data.FilePath, jsonName));
- Downloader.download(System.IO.Path.Combine(Data.FilePath, jsonName), jsonName);
- }
- else
- {
- Downloader.download(System.IO.Path.Combine(Data.FilePath, jsonName), jsonName);
- }
- }
- catch (CosClientException clientEx)
- {
- //请求失败
- Console.WriteLine("CosClientException: " + clientEx.ToString() + Environment.NewLine);
- return;
- }
- catch (CosServerException serverEx)
- {
- //请求失败
- Console.WriteLine("CosClientException: " + serverEx.ToString() + Environment.NewLine);
- return;
- }
- using (StreamReader r = new StreamReader(System.IO.Path.Combine(Data.FilePath, jsonName)))
- json = r.ReadToEnd();
- json = json.Replace("\r", string.Empty).Replace("\n", string.Empty);
- Dictionary jsonDict = JsonConvert.DeserializeObject>(json);
-
- newFileName.Clear();
- updateFileName.Clear();
- foreach (KeyValuePair pair in jsonDict)
- {
- newFileName.Add(pair.Key);
- }
- Download();
-
- string existpath = System.IO.Path.Combine(Data.dataPath, "Exists.txt");
- FileStream fs = new FileStream(existpath, FileMode.Open, FileAccess.ReadWrite);
- StreamWriter sw = new StreamWriter(fs);
- fs.SetLength(0);
- sw.Write("true");
- sw.Close();
- fs.Close();
- }
-
- public static void Change_all_hash(string topDir, Dictionary jsonDict) //更改HASH
- {
- DirectoryInfo theFolder = new DirectoryInfo(@topDir);
- bool ifexist = false;
-
- //遍历文件
- foreach (FileInfo NextFile in theFolder.GetFiles())
- {
- string filepath = topDir + @"/" + NextFile.Name; //文件路径
- Console.WriteLine(filepath);
- foreach (KeyValuePair pair in jsonDict)
- {
- if (System.IO.Path.Equals(filepath, System.IO.Path.Combine(Data.FilePath, pair.Key).Replace('\\', '/')))
- {
- ifexist = true;
- string MD5 = GetFileMd5Hash(filepath);
- jsonDict[pair.Key] = MD5;
- }
- }
- if (!ifexist && NextFile.Name != "hash.json")
- {
- string MD5 = GetFileMd5Hash(filepath);
- string relapath = filepath.Replace(Data.FilePath + '/', string.Empty);
- jsonDict.Add(relapath, MD5);
- }
- ifexist = false;
- }
-
- //遍历文件夹
- foreach (DirectoryInfo NextFolder in theFolder.GetDirectories())
- {
- if (System.IO.Path.Equals(NextFolder.FullName, System.IO.Path.GetFullPath(System.IO.Path.Combine(Data.FilePath, playerFolder))))
- {
- foreach (FileInfo NextFile in NextFolder.GetFiles())
- {
- if (NextFile.Name == "README.md")
- {
- string MD5 = GetFileMd5Hash(NextFile.FullName);
- string relapath = NextFile.FullName.Replace('\\', '/').Replace(Data.FilePath + '/', string.Empty);
- jsonDict.Add(relapath, MD5);
- }
- }
- continue; //如果是选手文件夹就忽略
- }
- Change_all_hash(NextFolder.FullName.Replace('\\', '/'), jsonDict);
- }
- }
- public static void UpdateHash()
- {
- while (true)
- {
- if (Directory.Exists(Data.FilePath))
- {
- string json;
- if (!File.Exists(System.IO.Path.Combine(Data.FilePath, "hash.json")))
- {
- Console.WriteLine("hash.json文件丢失!即将重新下载该文件!");
- GetNewHash();
- }
- using (StreamReader r = new StreamReader(System.IO.Path.Combine(Data.FilePath, "hash.json")))
- json = r.ReadToEnd();
- json = json.Replace("\r", string.Empty).Replace("\n", string.Empty).Replace("/", @"\\");
- Dictionary jsonDict = JsonConvert.DeserializeObject>(json);
- Change_all_hash(Data.FilePath, jsonDict);
- OverwriteHash(jsonDict);
- break;
- }
- else
- {
- Console.WriteLine("读取路径失败!请重新输入文件路径:");
- Data.ResetFilepath(Console.ReadLine());
- }
- }
- }
-
- public static void DeleteAll()
- {
- DirectoryInfo di = new DirectoryInfo(Data.FilePath);
- DirectoryInfo player = new DirectoryInfo(System.IO.Path.GetFullPath(System.IO.Path.Combine(Data.FilePath, playerFolder)));
- try
- {
- foreach (FileInfo file in di.GetFiles())
- {
- file.Delete();
- }
- foreach (FileInfo file in player.GetFiles())
- {
- if (file.Name == "README.md")
- {
- continue;
- }
- string filename = System.IO.Path.GetFileName(file.FullName);
- file.MoveTo(System.IO.Path.Combine(Data.FilePath, filename));
- }
- foreach (DirectoryInfo subdi in di.GetDirectories())
- {
- subdi.Delete(true);
- }
- }
- catch (UnauthorizedAccessException)
- {
- Console.WriteLine("权限不足,无法删除!");
- return;
- }
- catch (DirectoryNotFoundException)
- {
- Console.WriteLine("文件夹没有找到,请检查是否已经手动更改路径");
- return;
- }
- catch (IOException)
- {
- Console.WriteLine("文件已经打开,请关闭后再删除");
- return;
- }
-
- string existpath = System.IO.Path.Combine(Data.dataPath, "Exists.txt");
- FileStream fs = new FileStream(existpath, FileMode.Open, FileAccess.ReadWrite);
- StreamWriter sw = new StreamWriter(fs);
- fs.SetLength(0);
- sw.Write("false");
- sw.Close();
- fs.Close();
-
- try
- {
- File.Delete(Data.path);
- }
- catch (UnauthorizedAccessException)
- {
- Console.WriteLine("权限不足,无法删除!");
- return;
- }
- catch (DirectoryNotFoundException)
- {
- Console.WriteLine("文件夹没有找到,请检查是否已经手动更改路径");
- return;
- }
- catch (IOException)
- {
- Console.WriteLine("文件已经打开,请关闭后再删除");
- return;
- }
- Console.WriteLine($"删除成功!player文件夹中的文件已经放在{ProgramName}的根目录下");
- }
-
- public static void OverwriteHash(Dictionary jsonDict)
- {
- string Contentjson = JsonConvert.SerializeObject(jsonDict);
- Contentjson = Contentjson.Replace("\r", String.Empty).Replace("\n", String.Empty).Replace(@"\\", "/");
- File.WriteAllText(@System.IO.Path.Combine(Data.FilePath, "hash.json"), Contentjson);
- }
-
- public static void MoveProgram()
- {
- string newPath = Console.ReadLine();
- DirectoryInfo newdi = new DirectoryInfo(newPath);
- DirectoryInfo olddi = new DirectoryInfo(Data.FilePath);
- try
- {
- foreach (DirectoryInfo direct in olddi.GetDirectories())
- {
- direct.MoveTo(System.IO.Path.Combine(newPath, direct.Name));
- }
- foreach (FileInfo file in olddi.GetFiles())
- {
- file.MoveTo(System.IO.Path.Combine(newPath, file.Name));
- }
- }
- catch (DirectoryNotFoundException)
- {
- Console.WriteLine("原路径未找到!请检查文件是否损坏");
- foreach (DirectoryInfo newdirect in newdi.GetDirectories())
- {
- newdirect.MoveTo(System.IO.Path.Combine(Data.FilePath, newdirect.Name));
- }
- foreach (FileInfo file in newdi.GetFiles())
- {
- file.MoveTo(System.IO.Path.Combine(Data.FilePath, file.Name));
- }
- Console.WriteLine("移动失败!");
- }
- catch (IOException)
- {
- Console.WriteLine("文件已打开或者目标路径下有同名文件!");
- foreach (DirectoryInfo newdirect in newdi.GetDirectories())
- {
- newdirect.MoveTo(System.IO.Path.Combine(Data.FilePath, newdirect.Name));
- }
- foreach (FileInfo file in newdi.GetFiles())
- {
- file.MoveTo(System.IO.Path.Combine(Data.FilePath, file.Name));
- }
- Console.WriteLine("移动失败!");
- }
- Data.ResetFilepath(newPath);
- Console.WriteLine("更改路径成功!");
- }
- public static void main(string[] args)
- {
- Data date = new Data("");
- while (true)
- {
- Console.WriteLine($"1. 更新hash.json 2. 检查更新 3.下载{ProgramName} 4.删除{ProgramName} 5.启动进程 6.移动{ProgramName}到其它路径");
- string choose = Console.ReadLine();
- if (choose == "1")
- {
- if (!CheckAlreadyDownload())
- {
- Console.WriteLine($"未下载{ProgramName},请先执行下载操作!");
- continue;
- }
- UpdateHash();
- }
- else if (choose == "2")
- {
- if (!CheckAlreadyDownload())
- {
- Console.WriteLine($"未下载{ProgramName},请先执行下载操作!");
- continue;
- }
- while (true)
- {
- if (Data.FilePath != null && Directory.Exists(Data.FilePath))
- {
- Check();
- break;
- }
- else
- {
- Console.WriteLine("读取路径失败!请重新输入文件路径:");
- Data.ResetFilepath(Console.ReadLine());
- }
- }
- }
- else if (choose == "3")
- {
- if (CheckAlreadyDownload())
- {
- Console.WriteLine($"已经将{ProgramName}下载到{Data.FilePath}!若要重新下载请先完成删除操作!");
- }
- else
- {
- string newpath;
- Console.WriteLine("请输入下载路径:");
- newpath = Console.ReadLine();
- Data.ResetFilepath(newpath);
- DownloadAll();
- }
- }
- else if (choose == "4")
- {
- DeleteAll();
- }
- else if (choose == "5")
- {
- if (CheckAlreadyDownload())
- {
- Process.Start(System.IO.Path.Combine(Data.FilePath, startName));
- }
- else
- {
- Console.WriteLine($"未下载{ProgramName},请先执行下载操作!");
- }
- }
- else if (choose == "6")
- {
- MoveProgram();
- }
- else if (choose == "exit")
- {
- return;
- }
- }
- }
- }
- }
-}
\ No newline at end of file
+
\ No newline at end of file
From bc12e302fe10898aebc3f3b672d5d1f94710bbf1 Mon Sep 17 00:00:00 2001
From: gsy1519 <614054460@qq.com>
Date: Sat, 19 Nov 2022 22:46:00 +0800
Subject: [PATCH 05/17] chore: :rocket: start
start
---
.../Protos => dependency/proto}/Protos.csproj | 4 +-
logic/ClientTest/ClientTest.csproj | 2 +-
logic/ClientTest/Program.cs | 2 +-
logic/Protos/Message2Clients.proto | 125 ------------------
logic/Protos/Message2Server.proto | 62 ---------
logic/Protos/MessageType.proto | 110 ---------------
logic/Server/Game.cs | 59 ++++-----
logic/Server/GameServer.cs | 63 +++++----
logic/Server/Program.cs | 3 +-
logic/Server/Server.csproj | 2 +-
logic/logic.sln | 12 +-
11 files changed, 72 insertions(+), 372 deletions(-)
rename {logic/Protos => dependency/proto}/Protos.csproj (86%)
delete mode 100644 logic/Protos/Message2Clients.proto
delete mode 100644 logic/Protos/Message2Server.proto
delete mode 100644 logic/Protos/MessageType.proto
diff --git a/logic/Protos/Protos.csproj b/dependency/proto/Protos.csproj
similarity index 86%
rename from logic/Protos/Protos.csproj
rename to dependency/proto/Protos.csproj
index e6fac69..8c98b0a 100644
--- a/logic/Protos/Protos.csproj
+++ b/dependency/proto/Protos.csproj
@@ -10,11 +10,12 @@
+
-
+
@@ -27,6 +28,7 @@
+
diff --git a/logic/ClientTest/ClientTest.csproj b/logic/ClientTest/ClientTest.csproj
index e9bbb1e..075a2ce 100644
--- a/logic/ClientTest/ClientTest.csproj
+++ b/logic/ClientTest/ClientTest.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/logic/ClientTest/Program.cs b/logic/ClientTest/Program.cs
index 529dce3..ef30dc9 100644
--- a/logic/ClientTest/Program.cs
+++ b/logic/ClientTest/Program.cs
@@ -7,7 +7,7 @@ namespace ClientTest
{
public static async Task Main(string[] args)
{
- Channel channel = new Channel("127.0.0.1:8888", ChannelCredentials.Insecure);
+ 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]);
diff --git a/logic/Protos/Message2Clients.proto b/logic/Protos/Message2Clients.proto
deleted file mode 100644
index edae464..0000000
--- a/logic/Protos/Message2Clients.proto
+++ /dev/null
@@ -1,125 +0,0 @@
-// Message2Client
-syntax = "proto3";
-package protobuf;
-
-import "MessageType.proto";
-import "Message2Server.proto";
-
-message MessageOfHuman
-{
- int32 x = 1;
- int32 y = 2;
- int32 speed = 3;
- int32 life = 4; // 本次未倒地前的血量,也即还可以受的伤害
- int32 hanged_time = 5; // 被挂上的次数
- double time_until_skill_available = 6;
- PlaceType place = 7;
- PropType prop = 8;
- HumanType human_type = 9;
- int64 guid = 10;
- bool on_chair = 11; // 是否被挂
- double chair_time = 12; // 被挂的时间
- bool on_ground = 13; // 是否倒地
- double ground_time = 14; // 倒地时间
- int64 player_id = 15;
- int32 view_range = 16; // 视野距离
- repeated HumanBuffType buff = 17;
-}
-
-message MessageOfButcher
-{
- int32 x = 1;
- int32 y = 2;
- int32 speed = 3;
- int32 damage = 4;
- double time_until_skill_available = 5;
- PlaceType place = 6;
- PropType prop = 7;
- ButcherType butcher_type = 8;
- int64 guid = 9;
- bool movable = 10; // 是否进入了攻击后摇
- int64 playerID = 11;
- int32 view_range = 12; // 视野距离
- repeated ButcherBuffType buff = 13;
-}
-
-message MessageOfProp // 可拾取道具的信息
-{
- PropType type = 1;
- int32 x = 2;
- int32 y = 3;
- double facing_direction = 4;
- int64 guid = 5;
- PlaceType place = 6;
- int32 size = 7;
- bool is_moving = 8;
-}
-
-message MessageOfPickedProp //for Unity,直接继承自THUAI5
-{
- PropType type = 1;
- int32 x = 2;
- int32 y = 3;
- double facing_direction = 4;
- int64 mapping_id = 5;
-}
-
-message MessageOfMap
-{
- message Row
- {
- repeated PlaceType col = 1;
- }
- repeated Row row = 2;
-}
-
-message MessageToClient
-{
- repeated MessageOfHuman human_message = 1;
- repeated MessageOfButcher butcher_message = 2; // 是否真正repeated待定
- repeated MessageOfProp prop_message = 3;
- MessageOfMap map_massage = 4;
-}
-
-message MoveRes // 如果打算设计撞墙保留平行速度分量,且需要返回值则可用这个(大概没啥用)
-{
- int64 actual_speed = 1;
- double actual_angle = 2;
-}
-
-message BoolRes // 用于只需要判断执行操作是否成功的行为,如捡起道具、使用道具
-{
- bool act_success = 1;
-}
-
-message MsgRes // 用于获取队友发来的消息
-{
- bool have_message = 1; // 是否有待接收的消息
- int64 from_player_id = 2;
- string message_received = 3;
-}
-
-service AvailableService
-{
- rpc TryConnection(IDMsg) returns(BoolRes);
-
- // 游戏开局调用一次的服务
- rpc AddPlayer(PlayerMsg) returns(stream MessageToClient); // 连接上后等待游戏开始,server会定时通过该服务向所有client发送消息。
-
- // 游戏过程中玩家执行操作的服务
- rpc Move(MoveMsg) returns (MoveRes);
- rpc PickProp(PickMsg) returns (BoolRes);
- rpc UseProp(IDMsg) returns (BoolRes);
- rpc UseSkill(IDMsg) returns (BoolRes);
- rpc SendMessage(SendMsg) returns (BoolRes);
- rpc HaveMessage(IDMsg) returns (BoolRes);
- rpc GetMessage(IDMsg) returns (MsgRes);
- rpc FixMachine(stream IDMsg) returns (stream BoolRes); // 若正常修复且未被打断则返回修复成功,位置错误/被打断则返回修复失败,下同
- rpc SaveHuman(stream IDMsg) returns (stream BoolRes);
- rpc Attack (AttackMsg) returns (BoolRes);
- rpc CarryHuman (IDMsg) returns (BoolRes);
- rpc ReleaseHuman (IDMsg) returns (BoolRes);
- rpc HangHuman (IDMsg) returns (BoolRes);
- rpc Escape (IDMsg) returns (BoolRes);
-
-}
\ No newline at end of file
diff --git a/logic/Protos/Message2Server.proto b/logic/Protos/Message2Server.proto
deleted file mode 100644
index b3891b6..0000000
--- a/logic/Protos/Message2Server.proto
+++ /dev/null
@@ -1,62 +0,0 @@
-// Message2Server
-syntax = "proto3";
-package protobuf;
-
-import "MessageType.proto";
-
-message PlayerMsg
-{
- int64 player_id = 1;
- PlayerType player_type = 2;
- oneof job_type
- {
- HumanType human_type = 3;
- ButcherType butcher_type = 4;
- }
-}
-
-message MoveMsg
-{
- int64 player_id = 1;
- double angle = 2;
- int64 time_in_milliseconds = 3;
-}
-
-message PickMsg
-{
- int64 player_id = 1;
- PropType prop_type = 2;
-}
-
-message SendMsg
-{
- int64 player_id = 1;
- int64 to_player_id = 2;
- string message = 3;
-}
-
-message AttackMsg
-{
- int64 player_id = 1;
- double angle = 2;
-}
-
-message IDMsg
-{
- int64 player_id = 1;
-}
-
-// 基本继承于THUAI5,为了使发送的信息尽可能不被浪费,暂定不发这类大包。
-// message MessageToServer
-// {
-// MessageType messageType = 1;
-// int64 playerID = 2; // 消息发送者的playerID
-// PlayerType playerType = 3;
-// HumanType humanType= 4;
-// ButcherType butcherType = 5;
-// double angle = 6; // messageType为Move, Attack时的角度
-// PropType propType = 7; // messageType为PickProp时要捡起的道具类型,防止多个道具堆叠时出现问题
-// int64 timeInMilliseconds = 8;//时间参数
-// int64 ToPlayerID = 9; // messageType为Send时要发送的对象的ID
-// string message = 10; // messageType为Send时发送的消息内容
-// }
\ No newline at end of file
diff --git a/logic/Protos/MessageType.proto b/logic/Protos/MessageType.proto
deleted file mode 100644
index 2041fe0..0000000
--- a/logic/Protos/MessageType.proto
+++ /dev/null
@@ -1,110 +0,0 @@
-// MessageType
-syntax = "proto3";
-package protobuf;
-
-enum PlaceType // 地图中的所有物件类型
-{
- NULL_PLACE_TYPE = 0;
-
- // 地图情况,其中Gate是总体的大门,HiddenGate是地窖
- LAND = 1;
- WALL = 2;
- GRASS = 3;
- MACHINE = 4;
- GATE = 5;
- HIDDEN_GATE = 6;
- // 待补充有特殊效果的地形
-
-}
-
-enum ShapeType // 形状类型
-{
- NULL_SHAPE_TYPE = 0;
- CIRCLE = 1; // 人类、屠夫、可拾取道具等为圆形
- SQUARE = 2; // 地形均为方形
-}
-
-enum PropType // 地图中的可拾取道具类型
-{
- NULL_PROP_TYPE = 0;
- PTYPE1 = 1;
- PTYPE2 = 2;
- PTYPE3 = 3;
- PTYPE4 = 4;
-
-}
-
-enum HumanBuffType // 人类可用的增益效果类型
-{
- NULL_HBUFF_TYPE = 0;
- HBUFFTYPE1 = 1;
- HBUFFTYPE2 = 2;
- HBUFFTYPE3 = 3;
- HBUFFTYPE4 = 4;
-}
-
-enum ButcherBuffType // 屠夫可用的增益效果类型
-{
- NULL_BBUFF_TYPE = 0;
- BBUFFTYPE1 = 1;
- BBUFFTYPE2 = 2;
- BBUFFTYPE3 = 3;
- BBUFFTYPE4 = 4;
-}
-
-// 特别说明:由于Human阵营和Butcher阵营有显著的隔离,且暂定职业、主动技能和被动效果相互绑定,故不按照THUAI5的方式区分ActiveSkillType和PassiveSkillType,而是选择了按照阵营来给不同阵营赋予不同的职业(及技能)。
-
-enum PlayerType
-{
- NULL_PLAYER_TYPE = 0;
- HUMAN_PLAYER = 1;
- BUTCHER_PLAYER = 2;
-}
-
-enum HumanType
-{
- NULL_HUMAN_TYPE = 0;
- HUMANTYPE1 = 1;
- HUMANTYPE2 = 2;
- HUMANTYPE3 = 3;
- HUMANTYPE4 = 4;
-}
-
-enum ButcherType
-{
- NULL_BUTCHER_TYPE = 0;
- BUTCHERTYPE1 = 1;
- BUTCHERTYPE2 = 2;
- BUTCHERTYPE3 = 3;
- BUTCHERTYPE4 = 4;
-}
-
-// 取消了大包之后,MessageType的枚举是否有必要保留还有待商榷
-// enum MessageType
-// {
-// // 公共信息类型
-// Move = 0;
-// PickProp = 1;
-// UseProp = 2;
-// UseSkill = 3;
-// Map = 4;
-// Send = 5;
-
-// // 人类限定信息类型
-// FixMachine = 6;
-// SaveHuman = 7;
-
-// // 屠夫限定信息类型
-// Attack = 8;
-// CarryHuman = 9;
-// ReleaseHuman = 10;
-// HangHuman = 11;
-
-// // 游戏相关信息类型
-// AddPlayer = 12;
-// InvalidPlayer = 13;
-// ValidPlayer = 14;
-// StartGame = 15;
-// Gaming = 16;
-// EndGame = 17;
-// }
diff --git a/logic/Server/Game.cs b/logic/Server/Game.cs
index 96e7680..9eef516 100644
--- a/logic/Server/Game.cs
+++ b/logic/Server/Game.cs
@@ -18,7 +18,7 @@ namespace Server
public bool IsGaming
{
get => Interlocked.CompareExchange(ref isGaming, 0, 0) != 0;
- set => Interlocked.Exchange(ref isGaming, value ? 1 : 0);
+ set => Interlocked.Exchange(ref isGaming, value? 1: 0);
}
public MessageToClient GetCopiedGameInfo()
@@ -32,19 +32,18 @@ namespace Server
{
lock (gameInfoLock)
{
- if (player.PlayerType == PlayerType.NullPlayerType) return;
+ if (player.PlayerType == PlayerType.NullPlayerType)
+ return;
if (player.PlayerType == PlayerType.HumanPlayer)
{
- gameInfo.HumanMessage.Add(new MessageOfHuman()
- {
+ gameInfo.HumanMessage.Add(new MessageOfHuman() {
PlayerId = player.PlayerId
});
return;
}
if (player.PlayerType == PlayerType.ButcherPlayer)
{
- gameInfo.ButcherMessage.Add(new MessageOfButcher()
- {
+ gameInfo.ButcherMessage.Add(new MessageOfButcher() {
PlayerID = player.PlayerId
});
return;
@@ -66,39 +65,39 @@ namespace Server
() => 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++;
- }
- }
- }
+ 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;
+ IsGaming = false;
+ waitHandle.Release();
+ return 0;
},
gameTime
).Start();
- }
+ }
)
{ IsBackground = true }.Start();
return waitHandle;
- }
}
}
+}
diff --git a/logic/Server/GameServer.cs b/logic/Server/GameServer.cs
index c31d611..f97a06f 100644
--- a/logic/Server/GameServer.cs
+++ b/logic/Server/GameServer.cs
@@ -11,7 +11,7 @@ namespace Server
{
private Dictionary semaDict = new();
private object gameLock = new();
- private const int playerNum = 2;
+ private const int playerNum = 1;
private MessageToClient currentGameInfo = new();
private Game game = new();
public int GameTime => game.GameTime;
@@ -22,11 +22,11 @@ namespace Server
var onConnection = new BoolRes();
lock (gameLock)
{
- if (0 <= request.PlayerId && request.PlayerId < playerNum)
+ // if (0 <= request.PlayerId && request.PlayerId < playerNum)
{
onConnection.ActSuccess = true;
return Task.FromResult(onConnection);
- }
+ }
}
onConnection.ActSuccess = false;
return Task.FromResult(onConnection);
@@ -53,13 +53,12 @@ namespace Server
{
Console.WriteLine("Game starts!");
StartGame();
- }
+ }
}
do
{
semaDict[request.PlayerId].Item1.Wait();
-
if (currentGameInfo != null)
{
await responseStream.WriteAsync(currentGameInfo);
@@ -80,44 +79,42 @@ namespace Server
1000,
() =>
{
- ReportGame(); // 最后发一次消息,唤醒发消息的线程,防止发消息的线程由于有概率处在 Wait 状态而卡住
- return 0;
+ ReportGame(); // 最后发一次消息,唤醒发消息的线程,防止发消息的线程由于有概率处在 Wait 状态而卡住
+ return 0;
}
).Start();
- })
+ })
{ IsBackground = true }.Start();
new Thread(() =>
{
waitHandle.Wait();
- this.endGameSem.Release();
- })
+ this.endGameSem.Release();
+ })
{ IsBackground = true }.Start();
+}
+public void WaitForEnd()
+{
+ this.endGameSem.Wait();
+}
- }
- public void WaitForEnd()
- {
- this.endGameSem.Wait();
- }
-
- public void ReportGame()
- {
- currentGameInfo = game.GetCopiedGameInfo();
-
- foreach (var kvp in semaDict)
- {
- kvp.Value.Item1.Release();
- }
+public void ReportGame()
+{
+ currentGameInfo = game.GetCopiedGameInfo();
- foreach (var kvp in semaDict)
- {
- kvp.Value.Item2.Wait();
- }
- }
+ foreach (var kvp in semaDict)
+ {
+ kvp.Value.Item1.Release();
+ }
- public GameServer()
- {
+ foreach (var kvp in semaDict)
+ {
+ kvp.Value.Item2.Wait();
+ }
+}
- }
- }
+public GameServer()
+{
+}
+}
}
\ No newline at end of file
diff --git a/logic/Server/Program.cs b/logic/Server/Program.cs
index 155a97b..080ac4d 100644
--- a/logic/Server/Program.cs
+++ b/logic/Server/Program.cs
@@ -14,8 +14,7 @@ namespace Server
try
{
GameServer gameServer = new();
- Grpc.Core.Server server = new Grpc.Core.Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) })
- {
+ 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) }
};
diff --git a/logic/Server/Server.csproj b/logic/Server/Server.csproj
index b87aa89..62045cf 100644
--- a/logic/Server/Server.csproj
+++ b/logic/Server/Server.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/logic/logic.sln b/logic/logic.sln
index 2fc1991..d95a3b7 100644
--- a/logic/logic.sln
+++ b/logic/logic.sln
@@ -5,9 +5,9 @@ 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}") = "Protos", "Protos\Protos.csproj", "{EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientTest", "ClientTest\ClientTest.csproj", "{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientTest", "ClientTest\ClientTest.csproj", "{F3C98717-DD4F-45B8-B0F0-C217E7E2B5D4}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Protos", "..\dependency\proto\Protos.csproj", "{9ADA1EF8-DF2F-4C2E-9DE2-BC94DF89B44D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -19,14 +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
- {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {EA81EE05-A0E3-4D3E-8D7A-C5CD0C9255CD}.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
From 1894e9a546eebb26b8f1adab008b8cc7a9cbae36 Mon Sep 17 00:00:00 2001
From: DragonAura
Date: Sat, 19 Nov 2022 23:11:16 +0800
Subject: [PATCH 06/17] fix(proto): :bug: fix wrong service name
---
CAPI/proto/Services.grpc.pb.cc | 28 ++++----
CAPI/proto/Services.grpc.pb.h | 114 ++++++++++++++++----------------
CAPI/proto/Services.pb.cc | 24 +++----
dependency/proto/Services.proto | 2 +-
4 files changed, 84 insertions(+), 84 deletions(-)
diff --git a/CAPI/proto/Services.grpc.pb.cc b/CAPI/proto/Services.grpc.pb.cc
index b5edb79..3fdfba7 100644
--- a/CAPI/proto/Services.grpc.pb.cc
+++ b/CAPI/proto/Services.grpc.pb.cc
@@ -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 f)
+ void AvailableService::Stub::async::StartSaveHuman(::grpc::ClientContext* context, const ::protobuf::IDMsg* request, ::protobuf::BoolRes* response, std::function 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;
diff --git a/CAPI/proto/Services.grpc.pb.h b/CAPI/proto/Services.grpc.pb.h
index bb709c6..209e0e4 100644
--- a/CAPI/proto/Services.grpc.pb.h
+++ b/CAPI/proto/Services.grpc.pb.h
@@ -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) = 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) = 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) = 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) = 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) 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) 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) 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) 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) 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 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>>>>>>>>>>>>>>>>> AsyncService;
+ typedef WithAsyncMethod_TryConnection>>>>>>>>>>>>>>>>> AsyncService;
template
class WithCallbackMethod_TryConnection : public BaseClass
{
@@ -1559,7 +1559,7 @@ namespace protobuf
}
};
template
- 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>>>>>>>>>>>>>>>>> CallbackService;
+ typedef WithCallbackMethod_TryConnection>>>>>>>>>>>>>>>>> CallbackService;
typedef CallbackService ExperimentalCallbackService;
template
class WithGenericMethod_TryConnection : public BaseClass
@@ -2098,7 +2098,7 @@ namespace protobuf
}
};
template
- 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 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 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 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 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>>>>>>>>>>>>>>>> StreamedUnaryService;
+ typedef WithStreamedUnaryMethod_TryConnection>>>>>>>>>>>>>>>> StreamedUnaryService;
template
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 SplitStreamedService;
- typedef WithStreamedUnaryMethod_TryConnection>>>>>>>>>>>>>>>>> StreamedService;
+ typedef WithStreamedUnaryMethod_TryConnection>>>>>>>>>>>>>>>>> StreamedService;
};
} // namespace protobuf
diff --git a/CAPI/proto/Services.pb.cc b/CAPI/proto/Services.pb.cc
index e5cc936..cbe66f5 100644
--- a/CAPI/proto/Services.pb.cc
+++ b/CAPI/proto/Services.pb.cc
@@ -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,
diff --git a/dependency/proto/Services.proto b/dependency/proto/Services.proto
index d903045..018fdad 100755
--- a/dependency/proto/Services.proto
+++ b/dependency/proto/Services.proto
@@ -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);
From 0b43a2cd393ce7f8177d8ad16d310c523f476c2b Mon Sep 17 00:00:00 2001
From: DragonAura
Date: Sat, 19 Nov 2022 23:17:19 +0800
Subject: [PATCH 07/17] feat(CAPI): :sparkles: commits with state
---
CAPI/API/include/structures.h | 5 ++---
CAPI/API/include/utils.hpp | 12 ++++++++++--
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/CAPI/API/include/structures.h b/CAPI/API/include/structures.h
index bdeab2e..436e1e7 100644
--- a/CAPI/API/include/structures.h
+++ b/CAPI/API/include/structures.h
@@ -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; // 被挂的次数
diff --git a/CAPI/API/include/utils.hpp b/CAPI/API/include/utils.hpp
index 1f5a5f9..d73d333 100644
--- a/CAPI/API/include/utils.hpp
+++ b/CAPI/API/include/utils.hpp
@@ -76,6 +76,15 @@ namespace Proto2THUAI6
{protobuf::ButcherBuffType::BBUFFTYPE4, THUAI6::ButcherBuffType::ButcherBuffType4},
};
+ inline std::map 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 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()];
From 4949e72fa58a46d0be13b11f1da1aaa7078a46fa Mon Sep 17 00:00:00 2001
From: TCL <84725343+TCL606@users.noreply.github.com>
Date: Sun, 20 Nov 2022 00:14:17 +0800
Subject: [PATCH 08/17] ci: remove cs format
---
.github/workflows/clang-format.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml
index a21aed8..a095836 100644
--- a/.github/workflows/clang-format.yml
+++ b/.github/workflows/clang-format.yml
@@ -8,6 +8,6 @@ jobs:
- 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++'
+ extensions: 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx,i,ixx,ipp,i++'
clangFormatVersion: 14
inplace: False
From 714c7986c8b98dd33204eb00d5d75044fc5582da Mon Sep 17 00:00:00 2001
From: TCL <84725343+TCL606@users.noreply.github.com>
Date: Sun, 20 Nov 2022 00:18:18 +0800
Subject: [PATCH 09/17] Create FUNDING.yaml
---
.github/FUNDING.yaml | 3 +++
1 file changed, 3 insertions(+)
create mode 100644 .github/FUNDING.yaml
diff --git a/.github/FUNDING.yaml b/.github/FUNDING.yaml
new file mode 100644
index 0000000..87df536
--- /dev/null
+++ b/.github/FUNDING.yaml
@@ -0,0 +1,3 @@
+# These are supported funding model platforms
+
+github: [TCL606]
From 79805297b116f8d6956e00d9fc95fbf121cb5ca2 Mon Sep 17 00:00:00 2001
From: TCL <84725343+TCL606@users.noreply.github.com>
Date: Wed, 23 Nov 2022 14:34:50 +0800
Subject: [PATCH 10/17] ci: add dotnet format
---
.github/workflows/clang-format.yml | 13 ------------
.github/workflows/format.yml | 34 ++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+), 13 deletions(-)
delete mode 100644 .github/workflows/clang-format.yml
create mode 100644 .github/workflows/format.yml
diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml
deleted file mode 100644
index a095836..0000000
--- a/.github/workflows/clang-format.yml
+++ /dev/null
@@ -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: 'c,h,C,H,cpp,hpp,cc,hh,c++,h++,cxx,hxx,i,ixx,ipp,i++'
- clangFormatVersion: 14
- inplace: False
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
new file mode 100644
index 0000000..53be775
--- /dev/null
+++ b/.github/workflows/format.yml
@@ -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
+
+ - name: Check Installer
+ run: dotnet format "./installer/installer.sln" --severity error
+
+ - name: Check Launcher
+ run: dotnet format "./launcher/launcher.sln" --severity error
+
+ - name: Check Playback
+ run: dotnet format "./playback/playback.sln" --severity error
From f490e4d389351df65d853f3aacc3c7b8e5a054c4 Mon Sep 17 00:00:00 2001
From: TCL <1620508360@qq.com>
Date: Wed, 23 Nov 2022 14:38:33 +0800
Subject: [PATCH 11/17] chore: format cs with dotnet format
---
installer/Installer/AssemblyInfo.cs | 2 +-
installer/Installer/Model.cs | 21 ++++++++----
installer/Installer/ViewModel.cs | 52 ++++++++++++++++-------------
launcher/Launcher/AssemblyInfo.cs | 2 +-
4 files changed, 45 insertions(+), 32 deletions(-)
diff --git a/installer/Installer/AssemblyInfo.cs b/installer/Installer/AssemblyInfo.cs
index 87c30a8..746c6a3 100644
--- a/installer/Installer/AssemblyInfo.cs
+++ b/installer/Installer/AssemblyInfo.cs
@@ -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)
diff --git a/installer/Installer/Model.cs b/installer/Installer/Model.cs
index 03ffad1..3982b69 100644
--- a/installer/Installer/Model.cs
+++ b/installer/Installer/Model.cs
@@ -26,15 +26,21 @@ namespace starter.viewmodel.settings
///
/// Route of files
///
- public string Route {
- get; set; }
+ public string Route
+ {
+ get; set;
+ }
///
/// if the route was set or is under editing
///
- public bool HaveRoute {
- get; set; }
- public bool EditingRoute {
- get; set; }
+ public bool HaveRoute
+ {
+ get; set;
+ }
+ public bool EditingRoute
+ {
+ get; set;
+ }
///
/// downloader function
///
@@ -144,7 +150,8 @@ namespace Downloader
GetObjectRequest request = new GetObjectRequest(bucket, key, localDir, localFileName);
Dictionary 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));
});
// 执行请求
diff --git a/installer/Installer/ViewModel.cs b/installer/Installer/ViewModel.cs
index 291dbac..12c9842 100644
--- a/installer/Installer/ViewModel.cs
+++ b/installer/Installer/ViewModel.cs
@@ -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