From fa3f98923a3eb5bca533484e307fe2fd9641f3e6 Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Tue, 19 Mar 2024 19:24:26 +0800 Subject: [PATCH 1/7] feat: :sparkles: BuildSweeper --- dependency/proto/Message2Server.proto | 7 ----- dependency/proto/Services.proto | 1 - logic/Server/RpcServices.cs | 45 +++++++++++++++------------ 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/dependency/proto/Message2Server.proto b/dependency/proto/Message2Server.proto index e79f3c81..d3c788e1 100755 --- a/dependency/proto/Message2Server.proto +++ b/dependency/proto/Message2Server.proto @@ -17,13 +17,6 @@ message PlayerMsg SweeperType sweeper_type = 3; } -message ActivateMsg -{ - int64 player_id = 1; - int64 team_id = 2; - SweeperType sweeper_type = 3; -} - message MoveMsg { int64 player_id = 1; diff --git a/dependency/proto/Services.proto b/dependency/proto/Services.proto index 8b07b939..0680c364 100755 --- a/dependency/proto/Services.proto +++ b/dependency/proto/Services.proto @@ -12,7 +12,6 @@ service AvailableService rpc GetMap(NullRequest) returns (MessageOfMap); // 游戏过程中玩家执行操作的服务 // 船 - rpc Activate(ActivateMsg) returns (BoolRes); // 激活 rpc Move(MoveMsg) returns (MoveRes); // 移动 rpc Recover(RecoverMsg) returns (BoolRes); // 回复 rpc Produce(IDMsg) returns (BoolRes); // 开采 diff --git a/logic/Server/RpcServices.cs b/logic/Server/RpcServices.cs index f479f90d..322e1454 100755 --- a/logic/Server/RpcServices.cs +++ b/logic/Server/RpcServices.cs @@ -208,26 +208,6 @@ public override Task GetMap(NullRequest request, ServerCallContext #region 船 - public override Task Activate(ActivateMsg request, ServerCallContext context) - { -#if DEBUG - Console.WriteLine($"TRY Activate: Player {request.PlayerId} from Team {request.TeamId}"); -#endif - BoolRes boolRes = new(); - if (request.PlayerId >= spectatorMinPlayerID) - { - boolRes.ActSuccess = false; - return Task.FromResult(boolRes); - } - // var gameID = communicationToGameID[request.TeamId][request.PlayerId]; - boolRes.ActSuccess = game.ActivateShip(request.TeamId, Transformation.ShipTypeFromProto(request.SweeperType)); - if (!game.GameMap.Timer.IsGaming) boolRes.ActSuccess = false; -#if DEBUG - Console.WriteLine($"END Activate: {boolRes.ActSuccess}"); -#endif - return Task.FromResult(boolRes); - } - public override Task Move(MoveMsg request, ServerCallContext context) { #if DEBUG @@ -483,6 +463,31 @@ public override Task Recycle(IDMsg request, ServerCallContext context) return Task.FromResult(boolRes); } + public override Task BuildSweeper(BuildSweeperMsg request, ServerCallContext context) + { +#if DEBUG + Console.WriteLine($"TRY BuildSweeper: SweeperType {request.SweeperType} from Team {request.TeamId}"); +#endif + BoolRes boolRes = new(); + int teamID = (int)request.TeamId; + int playerID = (int)request.SweeperType; + if (game.TeamList[teamID].GetShip(playerID) == null) + { + boolRes.ActSuccess = false; + return Task.FromResult(boolRes); + } + else if (game.TeamList[teamID].GetShip(playerID).IsRemoved == false) + { + boolRes.ActSuccess = false; + return Task.FromResult(boolRes); + } + boolRes.ActSuccess = game.ActivateShip(request.TeamId, Transformation.ShipTypeFromProto(request.SweeperType)); +#if DEBUG + Console.WriteLine("END BuildSweeper"); +#endif + return Task.FromResult(boolRes); + } + public override Task EndAllAction(IDMsg request, ServerCallContext context) { #if DEBUG From 34240a79e05d508849a963001248447e817c5660 Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Tue, 19 Mar 2024 20:01:15 +0800 Subject: [PATCH 2/7] refactor: :sparkles: modify activate --- dependency/proto/Message2Server.proto | 6 +++--- logic/GameClass/GameObj/Team.cs | 21 --------------------- logic/Gaming/Game.cs | 6 ++++-- logic/Server/RpcServices.cs | 9 ++++----- 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/dependency/proto/Message2Server.proto b/dependency/proto/Message2Server.proto index d3c788e1..686c389e 100755 --- a/dependency/proto/Message2Server.proto +++ b/dependency/proto/Message2Server.proto @@ -67,8 +67,8 @@ message InstallMsg } message BuildSweeperMsg { - int32 x = 1; - int32 y = 2; + int64 team_id = 1; + int64 player_id = 2; SweeperType sweeper_type = 3; - int64 team_id = 4; + int32 birthpoint_index = 4; } \ No newline at end of file diff --git a/logic/GameClass/GameObj/Team.cs b/logic/GameClass/GameObj/Team.cs index 783bc93f..a0d76426 100755 --- a/logic/GameClass/GameObj/Team.cs +++ b/logic/GameClass/GameObj/Team.cs @@ -152,26 +152,5 @@ public int GetNewFlagShipIndex() } return -1; } - public void RemoveShip(Ship ship) - { - int i; - for (i = 0; i < shipList.Count; i++) - { - if (shipList[i] == ship) - break; - } - if (i < shipList.Count) - shipList.RemoveAt(i); - } - public long[] GetShipIDs() - { - long[] shipIDs = new long[shipList.Count]; - int i = 0; - foreach (Ship ship in shipList) - { - shipIDs[i++] = ship.PlayerID; - } - return shipIDs; - } } } diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index 8822bf03..b2ddbab5 100755 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -46,11 +46,13 @@ public long AddPlayer(PlayerInitInfo playerInitInfo) return playerInitInfo.playerID; } } - public bool ActivateShip(long teamID, ShipType shipType, int birthPointIndex = 0) + public bool ActivateShip(long teamID, long playerID, ShipType shipType, int birthPointIndex = 0) { - Ship? ship = teamList[(int)teamID].GetNewShip(shipType); + Ship? ship = teamList[(int)teamID].GetShip(playerID); if (ship == null) return false; + else if (ship.IsRemoved == false) + return false; if (birthPointIndex < 0) birthPointIndex = 0; if (birthPointIndex >= teamList[(int)teamID].BirthPointList.Count) diff --git a/logic/Server/RpcServices.cs b/logic/Server/RpcServices.cs index 322e1454..6eed52d7 100755 --- a/logic/Server/RpcServices.cs +++ b/logic/Server/RpcServices.cs @@ -469,19 +469,18 @@ public override Task BuildSweeper(BuildSweeperMsg request, ServerCallCo Console.WriteLine($"TRY BuildSweeper: SweeperType {request.SweeperType} from Team {request.TeamId}"); #endif BoolRes boolRes = new(); - int teamID = (int)request.TeamId; - int playerID = (int)request.SweeperType; - if (game.TeamList[teamID].GetShip(playerID) == null) + + if (game.TeamList[(int)request.TeamId].GetShip(request.PlayerId) == null) { boolRes.ActSuccess = false; return Task.FromResult(boolRes); } - else if (game.TeamList[teamID].GetShip(playerID).IsRemoved == false) + else if (game.TeamList[(int)request.TeamId].GetShip(request.PlayerId).IsRemoved == false) { boolRes.ActSuccess = false; return Task.FromResult(boolRes); } - boolRes.ActSuccess = game.ActivateShip(request.TeamId, Transformation.ShipTypeFromProto(request.SweeperType)); + boolRes.ActSuccess = game.ActivateShip(request.TeamId, request.PlayerId, Transformation.ShipTypeFromProto(request.SweeperType), request.BirthpointIndex); #if DEBUG Console.WriteLine("END BuildSweeper"); #endif From cbbe08079bc3012b3e150001ebe090910c0c8500 Mon Sep 17 00:00:00 2001 From: sigureling <1678348940@qq.com> Date: Sat, 23 Mar 2024 13:44:23 +0800 Subject: [PATCH 3/7] feat: :zap: Add just the way to BuildShip in CAPI --- CAPI/cpp/API/include/API.h | 8 +- CAPI/cpp/API/include/Communication.h | 2 +- CAPI/cpp/API/include/logic.h | 2 +- CAPI/cpp/API/include/utils.hpp | 4 +- CAPI/cpp/API/src/API.cpp | 4 +- CAPI/cpp/API/src/Communication.cpp | 4 +- CAPI/cpp/API/src/DebugAPI.cpp | 4 +- CAPI/cpp/API/src/logic.cpp | 4 +- CAPI/cpp/proto/Message2Clients.pb.cc | 155 +++++++++++---------------- CAPI/cpp/proto/Message2Clients.pb.h | 84 +++++---------- CAPI/cpp/proto/Message2Server.pb.cc | 100 ++++------------- CAPI/cpp/proto/Message2Server.pb.h | 84 ++------------- 12 files changed, 130 insertions(+), 325 deletions(-) diff --git a/CAPI/cpp/API/include/API.h b/CAPI/cpp/API/include/API.h index e46c66cd..ceec05c5 100755 --- a/CAPI/cpp/API/include/API.h +++ b/CAPI/cpp/API/include/API.h @@ -72,7 +72,7 @@ class ILogic // Team使用的部分 virtual bool Recycle(int64_t playerID) = 0; virtual bool InstallModule(int64_t playerID, THUAI7::ModuleType moduleType) = 0; - virtual bool BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) = 0; + virtual bool BuildSweeper(THUAI7::SweeperType SweeperType) = 0; }; class IAPI @@ -151,7 +151,7 @@ class ITeamAPI : public IAPI [[nodiscard]] virtual std::shared_ptr GetSelfInfo() const = 0; virtual std::future InstallModule(int64_t playerID, THUAI7::ModuleType moduletype) = 0; virtual std::future Recycle(int64_t playerID) = 0; - virtual std::future BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) = 0; + virtual std::future BuildSweeper(THUAI7::SweeperType SweeperType) = 0; }; class IGameTimer @@ -271,7 +271,7 @@ class TeamAPI : public ITeamAPI, public IGameTimer [[nodiscard]] int32_t GetEnergy() const override; std::future InstallModule(int64_t playerID, THUAI7::ModuleType moduleType) override; std::future Recycle(int64_t playerID) override; - std::future BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) override; + std::future BuildSweeper(THUAI7::SweeperType SweeperType) override; void Print(std::string str) const { } @@ -378,7 +378,7 @@ class TeamDebugAPI : public ITeamAPI, public IGameTimer [[nodiscard]] int32_t GetEnergy() const override; std::future InstallModule(int64_t playerID, THUAI7::ModuleType moduleType) override; std::future Recycle(int64_t playerID) override; - std::future BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY) override; + std::future BuildSweeper(THUAI7::SweeperType SweeperType) override; void Print(std::string str) const override; void PrintSelfInfo() const override; // TODO diff --git a/CAPI/cpp/API/include/Communication.h b/CAPI/cpp/API/include/Communication.h index 649503c7..df3fc3e2 100755 --- a/CAPI/cpp/API/include/Communication.h +++ b/CAPI/cpp/API/include/Communication.h @@ -41,7 +41,7 @@ class Communication bool Send(int64_t playerID, int64_t toPlayerID, int64_t teamID, std::string message, bool binary); // Team bool InstallModule(int64_t playerID, int64_t teamID, THUAI7::ModuleType moduleType); - bool BuildSweeper(int64_t teamID, THUAI7::SweeperType SweeperType, int32_t x, int32_t y); + bool BuildSweeper(int64_t teamID, THUAI7::SweeperType SweeperType); bool Recycle(int64_t playerID, int64_t teamID); private: diff --git a/CAPI/cpp/API/include/logic.h b/CAPI/cpp/API/include/logic.h index a0fa47bc..a09e814c 100755 --- a/CAPI/cpp/API/include/logic.h +++ b/CAPI/cpp/API/include/logic.h @@ -125,7 +125,7 @@ class Logic : public ILogic // ITeamAPI bool Recycle(int64_t playerID); bool InstallModule(int64_t playerID, THUAI7::ModuleType moduleType); - bool BuildSweeper(THUAI7::SweeperType SweeperType, int32_t cellX, int32_t cellY); + bool BuildSweeper(THUAI7::SweeperType SweeperType); bool TryConnection(); void ProcessMessage(); diff --git a/CAPI/cpp/API/include/utils.hpp b/CAPI/cpp/API/include/utils.hpp index 9fae134d..5279d05b 100755 --- a/CAPI/cpp/API/include/utils.hpp +++ b/CAPI/cpp/API/include/utils.hpp @@ -520,12 +520,10 @@ namespace THUAI72Proto return installMsg; } - inline protobuf::BuildSweeperMsg THUAI72ProtobufBuildSweeperMsg(int64_t teamID, THUAI7::SweeperType SweeperType, int32_t x, int32_t y) + inline protobuf::BuildSweeperMsg THUAI72ProtobufBuildSweeperMsg(int64_t teamID, THUAI7::SweeperType SweeperType) { protobuf::BuildSweeperMsg buildSweeperMsg; buildSweeperMsg.set_team_id(teamID); - buildSweeperMsg.set_x(x); - buildSweeperMsg.set_y(y); buildSweeperMsg.set_sweeper_type(THUAI72Proto::sweeperTypeDict[SweeperType]); return buildSweeperMsg; } diff --git a/CAPI/cpp/API/src/API.cpp b/CAPI/cpp/API/src/API.cpp index 1d0cc7ce..ae602da7 100755 --- a/CAPI/cpp/API/src/API.cpp +++ b/CAPI/cpp/API/src/API.cpp @@ -306,10 +306,10 @@ std::future TeamAPI::Recycle(int64_t playerID) { return logic.Recycle(playerID); }); } -std::future TeamAPI::BuildSweeper(THUAI7::SweeperType SweeperType, int32_t x, int32_t y) +std::future TeamAPI::BuildSweeper(THUAI7::SweeperType SweeperType) { return std::async(std::launch::async, [=]() - { return logic.BuildSweeper(SweeperType, x, y); }); + { return logic.BuildSweeper(SweeperType); }); } void SweeperAPI::Play(IAI& ai) diff --git a/CAPI/cpp/API/src/Communication.cpp b/CAPI/cpp/API/src/Communication.cpp index dcb2503d..db207f9d 100755 --- a/CAPI/cpp/API/src/Communication.cpp +++ b/CAPI/cpp/API/src/Communication.cpp @@ -187,11 +187,11 @@ bool Communication::Attack(int64_t playerID, int64_t teamID, double angle) return false; } -bool Communication::BuildSweeper(int64_t teamID, THUAI7::SweeperType SweeperType, int32_t x, int32_t y) +bool Communication::BuildSweeper(int64_t teamID, THUAI7::SweeperType SweeperType) { protobuf::BoolRes reply; ClientContext context; - auto request = THUAI72Proto::THUAI72ProtobufBuildSweeperMsg(teamID, SweeperType, x, y); + auto request = THUAI72Proto::THUAI72ProtobufBuildSweeperMsg(teamID, SweeperType); auto status = THUAI7Stub->BuildSweeper(&context, request, &reply); if (status.ok()) return true; diff --git a/CAPI/cpp/API/src/DebugAPI.cpp b/CAPI/cpp/API/src/DebugAPI.cpp index 64412d33..e775f271 100755 --- a/CAPI/cpp/API/src/DebugAPI.cpp +++ b/CAPI/cpp/API/src/DebugAPI.cpp @@ -436,10 +436,10 @@ std::future TeamDebugAPI::Recycle(int64_t playerID) { return logic.Recycle(playerID); }); } -std::future TeamDebugAPI::BuildSweeper(THUAI7::SweeperType SweeperType, int32_t x, int32_t y) +std::future TeamDebugAPI::BuildSweeper(THUAI7::SweeperType SweeperType) { return std::async(std::launch::async, [=]() - { return logic.BuildSweeper(SweeperType, x, y); }); + { return logic.BuildSweeper(SweeperType); }); } void TeamDebugAPI::PrintSelfInfo() const diff --git a/CAPI/cpp/API/src/logic.cpp b/CAPI/cpp/API/src/logic.cpp index 85e9f6af..4420e382 100755 --- a/CAPI/cpp/API/src/logic.cpp +++ b/CAPI/cpp/API/src/logic.cpp @@ -242,10 +242,10 @@ bool Logic::Construct(THUAI7::ConstructionType constructiontype) return pComm->Construct(playerID, teamID, constructiontype); } -bool Logic::BuildSweeper(THUAI7::SweeperType Sweepertype, int32_t x, int32_t y) +bool Logic::BuildSweeper(THUAI7::SweeperType Sweepertype) { logger->debug("Called BuildSweeper"); - return pComm->BuildSweeper(teamID, Sweepertype, x, y); + return pComm->BuildSweeper(teamID, Sweepertype); } // 等待完成 diff --git a/CAPI/cpp/proto/Message2Clients.pb.cc b/CAPI/cpp/proto/Message2Clients.pb.cc index 1d5d702c..696293e9 100644 --- a/CAPI/cpp/proto/Message2Clients.pb.cc +++ b/CAPI/cpp/proto/Message2Clients.pb.cc @@ -268,7 +268,7 @@ namespace protobuf ::_pbi::ConstantInitialized ) : _impl_{ - /*decltype(_impl_.team_id_)*/ int64_t{0}, /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.score_)*/ 0, /*decltype(_impl_.energy_)*/ 0, /*decltype(_impl_.guid_)*/ int64_t{0}, /*decltype(_impl_._cached_size_)*/ {}} + /*decltype(_impl_.team_id_)*/ int64_t{0}, /*decltype(_impl_.player_id_)*/ int64_t{0}, /*decltype(_impl_.score_)*/ int64_t{0}, /*decltype(_impl_.energy_)*/ int64_t{0}, /*decltype(_impl_._cached_size_)*/ {}} { } struct MessageOfTeamDefaultTypeInternal @@ -603,7 +603,6 @@ const uint32_t TableStruct_Message2Clients_2eproto::offsets[] PROTOBUF_SECTION_V PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfTeam, _impl_.player_id_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfTeam, _impl_.score_), PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfTeam, _impl_.energy_), - PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfTeam, _impl_.guid_), ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::protobuf::MessageOfObj, _internal_metadata_), ~0u, // no _extensions_ @@ -700,14 +699,14 @@ static const ::_pbi::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protode {109, -1, -1, sizeof(::protobuf::MessageOfMap_Row)}, {116, -1, -1, sizeof(::protobuf::MessageOfMap)}, {125, -1, -1, sizeof(::protobuf::MessageOfTeam)}, - {136, -1, -1, sizeof(::protobuf::MessageOfObj)}, - {155, -1, -1, sizeof(::protobuf::MessageOfAll)}, - {168, -1, -1, sizeof(::protobuf::MessageToClient)}, - {177, -1, -1, sizeof(::protobuf::MoveRes)}, - {186, -1, -1, sizeof(::protobuf::BoolRes)}, - {193, -1, -1, sizeof(::protobuf::SweeperInfoRes)}, - {200, -1, -1, sizeof(::protobuf::EcoRes)}, - {207, -1, -1, sizeof(::protobuf::MessageOfNews)}, + {135, -1, -1, sizeof(::protobuf::MessageOfObj)}, + {154, -1, -1, sizeof(::protobuf::MessageOfAll)}, + {167, -1, -1, sizeof(::protobuf::MessageToClient)}, + {176, -1, -1, sizeof(::protobuf::MoveRes)}, + {185, -1, -1, sizeof(::protobuf::BoolRes)}, + {192, -1, -1, sizeof(::protobuf::SweeperInfoRes)}, + {199, -1, -1, sizeof(::protobuf::EcoRes)}, + {206, -1, -1, sizeof(::protobuf::MessageOfNews)}, }; static const ::_pb::Message* const file_default_instances[] = { @@ -770,43 +769,42 @@ const char descriptor_table_protodef_Message2Clients_2eproto[] PROTOBUF_SECTION_ "sageOfMap\022\016\n\006height\030\001 \001(\r\022\r\n\005width\030\002 \001(\r" "\022(\n\004rows\030\003 \003(\0132\032.protobuf.MessageOfMap.R" "ow\032(\n\003Row\022!\n\004cols\030\001 \003(\0162\023.protobuf.Place" - "Type\"`\n\rMessageOfTeam\022\017\n\007team_id\030\001 \001(\003\022\021" - "\n\tplayer_id\030\002 \001(\003\022\r\n\005score\030\003 \001(\005\022\016\n\006ener" - "gy\030\004 \001(\005\022\014\n\004guid\030\005 \001(\003\"\275\005\n\014MessageOfObj\022" - "5\n\017sweeper_message\030\001 \001(\0132\032.protobuf.Mess" - "ageOfSweeperH\000\0223\n\016bullet_message\030\002 \001(\0132\031" - ".protobuf.MessageOfBulletH\000\022=\n\023recycleba" - "nk_message\030\003 \001(\0132\036.protobuf.MessageOfRec" - "ycleBankH\000\022A\n\025chargestation_message\030\004 \001(" - "\0132 .protobuf.MessageOfChargeStationH\000\022=\n" - "\023signaltower_message\030\005 \001(\0132\036.protobuf.Me" - "ssageOfSignalTowerH\000\0223\n\016bridge_message\030\006" - " \001(\0132\031.protobuf.MessageOfBridgeH\000\022/\n\014hom" - "e_message\030\007 \001(\0132\027.protobuf.MessageOfHome" - "H\000\0225\n\017garbage_message\030\010 \001(\0132\032.protobuf.M" - "essageOfGarbageH\000\022-\n\013map_message\030\t \001(\0132\026" - ".protobuf.MessageOfMapH\000\022/\n\014news_message" - "\030\n \001(\0132\027.protobuf.MessageOfNewsH\000\022@\n\025bom" - "bed_bullet_message\030\013 \001(\0132\037.protobuf.Mess" - "ageOfBombedBulletH\000\022/\n\014team_message\030\014 \001(" - "\0132\027.protobuf.MessageOfTeamH\000B\020\n\016message_" - "of_obj\"\260\001\n\014MessageOfAll\022\021\n\tgame_time\030\001 \001" - "(\005\022\026\n\016red_team_score\030\002 \001(\005\022\027\n\017blue_team_" - "score\030\003 \001(\005\022\027\n\017red_team_energy\030\004 \001(\005\022\030\n\020" - "blue_team_energy\030\005 \001(\005\022\023\n\013red_home_hp\030\006 " - "\001(\005\022\024\n\014blue_home_hp\030\007 \001(\005\"\224\001\n\017MessageToC" - "lient\022+\n\013obj_message\030\001 \003(\0132\026.protobuf.Me" - "ssageOfObj\022\'\n\ngame_state\030\002 \001(\0162\023.protobu" - "f.GameState\022+\n\013all_message\030\003 \001(\0132\026.proto" - "buf.MessageOfAll\"J\n\007MoveRes\022\024\n\014actual_sp" - "eed\030\001 \001(\003\022\024\n\014actual_angle\030\002 \001(\001\022\023\n\013act_s" - "uccess\030\003 \001(\010\"\036\n\007BoolRes\022\023\n\013act_success\030\001" - " \001(\010\"B\n\016SweeperInfoRes\0220\n\014sweeper_info\030\001" - " \003(\0132\032.protobuf.MessageOfSweeper\"\031\n\006EcoR" - "es\022\017\n\007economy\030\001 \001(\003\"i\n\rMessageOfNews\022\026\n\014" - "text_message\030\001 \001(\tH\000\022\030\n\016binary_message\030\004" - " \001(\014H\000\022\017\n\007from_id\030\002 \001(\003\022\r\n\005to_id\030\003 \001(\003B\006" - "\n\004newsb\006proto3"; + "Type\"R\n\rMessageOfTeam\022\017\n\007team_id\030\001 \001(\003\022\021" + "\n\tplayer_id\030\002 \001(\003\022\r\n\005score\030\003 \001(\003\022\016\n\006ener" + "gy\030\004 \001(\003\"\275\005\n\014MessageOfObj\0225\n\017sweeper_mes" + "sage\030\001 \001(\0132\032.protobuf.MessageOfSweeperH\000" + "\0223\n\016bullet_message\030\002 \001(\0132\031.protobuf.Mess" + "ageOfBulletH\000\022=\n\023recyclebank_message\030\003 \001" + "(\0132\036.protobuf.MessageOfRecycleBankH\000\022A\n\025" + "chargestation_message\030\004 \001(\0132 .protobuf.M" + "essageOfChargeStationH\000\022=\n\023signaltower_m" + "essage\030\005 \001(\0132\036.protobuf.MessageOfSignalT" + "owerH\000\0223\n\016bridge_message\030\006 \001(\0132\031.protobu" + "f.MessageOfBridgeH\000\022/\n\014home_message\030\007 \001(" + "\0132\027.protobuf.MessageOfHomeH\000\0225\n\017garbage_" + "message\030\010 \001(\0132\032.protobuf.MessageOfGarbag" + "eH\000\022-\n\013map_message\030\t \001(\0132\026.protobuf.Mess" + "ageOfMapH\000\022/\n\014news_message\030\n \001(\0132\027.proto" + "buf.MessageOfNewsH\000\022@\n\025bombed_bullet_mes" + "sage\030\013 \001(\0132\037.protobuf.MessageOfBombedBul" + "letH\000\022/\n\014team_message\030\014 \001(\0132\027.protobuf.M" + "essageOfTeamH\000B\020\n\016message_of_obj\"\260\001\n\014Mes" + "sageOfAll\022\021\n\tgame_time\030\001 \001(\005\022\026\n\016red_team" + "_score\030\002 \001(\005\022\027\n\017blue_team_score\030\003 \001(\005\022\027\n" + "\017red_team_energy\030\004 \001(\005\022\030\n\020blue_team_ener" + "gy\030\005 \001(\005\022\023\n\013red_home_hp\030\006 \001(\005\022\024\n\014blue_ho" + "me_hp\030\007 \001(\005\"\224\001\n\017MessageToClient\022+\n\013obj_m" + "essage\030\001 \003(\0132\026.protobuf.MessageOfObj\022\'\n\n" + "game_state\030\002 \001(\0162\023.protobuf.GameState\022+\n" + "\013all_message\030\003 \001(\0132\026.protobuf.MessageOfA" + "ll\"J\n\007MoveRes\022\024\n\014actual_speed\030\001 \001(\003\022\024\n\014a" + "ctual_angle\030\002 \001(\001\022\023\n\013act_success\030\003 \001(\010\"\036" + "\n\007BoolRes\022\023\n\013act_success\030\001 \001(\010\"B\n\016Sweepe" + "rInfoRes\0220\n\014sweeper_info\030\001 \003(\0132\032.protobu" + "f.MessageOfSweeper\"\031\n\006EcoRes\022\017\n\007economy\030" + "\001 \001(\003\"i\n\rMessageOfNews\022\026\n\014text_message\030\001" + " \001(\tH\000\022\030\n\016binary_message\030\004 \001(\014H\000\022\017\n\007from" + "_id\030\002 \001(\003\022\r\n\005to_id\030\003 \001(\003B\006\n\004newsb\006proto3"; static const ::_pbi::DescriptorTable* const descriptor_table_Message2Clients_2eproto_deps[1] = { &::descriptor_table_MessageType_2eproto, }; @@ -814,7 +812,7 @@ static ::_pbi::once_flag descriptor_table_Message2Clients_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_Message2Clients_2eproto = { false, false, - 2894, + 2880, descriptor_table_protodef_Message2Clients_2eproto, "Message2Clients.proto", &descriptor_table_Message2Clients_2eproto_once, @@ -4633,10 +4631,10 @@ namespace protobuf MessageOfTeam* const _this = this; (void)_this; new (&_impl_) Impl_{ - decltype(_impl_.team_id_){}, decltype(_impl_.player_id_){}, decltype(_impl_.score_){}, decltype(_impl_.energy_){}, decltype(_impl_.guid_){}, /*decltype(_impl_._cached_size_)*/ {}}; + decltype(_impl_.team_id_){}, decltype(_impl_.player_id_){}, decltype(_impl_.score_){}, decltype(_impl_.energy_){}, /*decltype(_impl_._cached_size_)*/ {}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&_impl_.team_id_, &from._impl_.team_id_, static_cast(reinterpret_cast(&_impl_.guid_) - reinterpret_cast(&_impl_.team_id_)) + sizeof(_impl_.guid_)); + ::memcpy(&_impl_.team_id_, &from._impl_.team_id_, static_cast(reinterpret_cast(&_impl_.energy_) - reinterpret_cast(&_impl_.team_id_)) + sizeof(_impl_.energy_)); // @@protoc_insertion_point(copy_constructor:protobuf.MessageOfTeam) } @@ -4647,7 +4645,7 @@ namespace protobuf (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ - decltype(_impl_.team_id_){int64_t{0}}, decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.score_){0}, decltype(_impl_.energy_){0}, decltype(_impl_.guid_){int64_t{0}}, /*decltype(_impl_._cached_size_)*/ {}}; + decltype(_impl_.team_id_){int64_t{0}}, decltype(_impl_.player_id_){int64_t{0}}, decltype(_impl_.score_){int64_t{0}}, decltype(_impl_.energy_){int64_t{0}}, /*decltype(_impl_._cached_size_)*/ {}}; } MessageOfTeam::~MessageOfTeam() @@ -4678,7 +4676,7 @@ namespace protobuf // Prevent compiler warnings about cached_has_bits being unused (void)cached_has_bits; - ::memset(&_impl_.team_id_, 0, static_cast(reinterpret_cast(&_impl_.guid_) - reinterpret_cast(&_impl_.team_id_)) + sizeof(_impl_.guid_)); + ::memset(&_impl_.team_id_, 0, static_cast(reinterpret_cast(&_impl_.energy_) - reinterpret_cast(&_impl_.team_id_)) + sizeof(_impl_.energy_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -4713,31 +4711,21 @@ namespace protobuf else goto handle_unusual; continue; - // int32 score = 3; + // int64 score = 3; case 3: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { - _impl_.score_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); + _impl_.score_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else goto handle_unusual; continue; - // int32 energy = 4; + // int64 energy = 4; case 4: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) { - _impl_.energy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } - else - goto handle_unusual; - continue; - // int64 guid = 5; - case 5: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 40)) - { - _impl_.guid_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); + _impl_.energy_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); } else @@ -4791,25 +4779,18 @@ namespace protobuf target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_player_id(), target); } - // int32 score = 3; + // int64 score = 3; if (this->_internal_score() != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(3, this->_internal_score(), target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(3, this->_internal_score(), target); } - // int32 energy = 4; + // int64 energy = 4; if (this->_internal_energy() != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(4, this->_internal_energy(), target); - } - - // int64 guid = 5; - if (this->_internal_guid() != 0) - { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt64ToArray(5, this->_internal_guid(), target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(4, this->_internal_energy(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) @@ -4843,22 +4824,16 @@ namespace protobuf total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_player_id()); } - // int32 score = 3; + // int64 score = 3; if (this->_internal_score() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_score()); + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_score()); } - // int32 energy = 4; + // int64 energy = 4; if (this->_internal_energy() != 0) { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_energy()); - } - - // int64 guid = 5; - if (this->_internal_guid() != 0) - { - total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_guid()); + total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_energy()); } return MaybeComputeUnknownFieldsSize(total_size, &_impl_._cached_size_); @@ -4897,10 +4872,6 @@ namespace protobuf { _this->_internal_set_energy(from._internal_energy()); } - if (from._internal_guid() != 0) - { - _this->_internal_set_guid(from._internal_guid()); - } _this->_internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); } @@ -4923,7 +4894,7 @@ namespace protobuf using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(MessageOfTeam, _impl_.guid_) + sizeof(MessageOfTeam::_impl_.guid_) - PROTOBUF_FIELD_OFFSET(MessageOfTeam, _impl_.team_id_)>( + PROTOBUF_FIELD_OFFSET(MessageOfTeam, _impl_.energy_) + sizeof(MessageOfTeam::_impl_.energy_) - PROTOBUF_FIELD_OFFSET(MessageOfTeam, _impl_.team_id_)>( reinterpret_cast(&_impl_.team_id_), reinterpret_cast(&other->_impl_.team_id_) ); diff --git a/CAPI/cpp/proto/Message2Clients.pb.h b/CAPI/cpp/proto/Message2Clients.pb.h index 200accd3..9c38a007 100644 --- a/CAPI/cpp/proto/Message2Clients.pb.h +++ b/CAPI/cpp/proto/Message2Clients.pb.h @@ -3033,7 +3033,6 @@ namespace protobuf kPlayerIdFieldNumber = 2, kScoreFieldNumber = 3, kEnergyFieldNumber = 4, - kGuidFieldNumber = 5, }; // int64 team_id = 1; void clear_team_id(); @@ -3055,34 +3054,24 @@ namespace protobuf void _internal_set_player_id(int64_t value); public: - // int32 score = 3; + // int64 score = 3; void clear_score(); - int32_t score() const; - void set_score(int32_t value); + int64_t score() const; + void set_score(int64_t value); private: - int32_t _internal_score() const; - void _internal_set_score(int32_t value); + int64_t _internal_score() const; + void _internal_set_score(int64_t value); public: - // int32 energy = 4; + // int64 energy = 4; void clear_energy(); - int32_t energy() const; - void set_energy(int32_t value); + int64_t energy() const; + void set_energy(int64_t value); private: - int32_t _internal_energy() const; - void _internal_set_energy(int32_t value); - - public: - // int64 guid = 5; - void clear_guid(); - int64_t guid() const; - void set_guid(int64_t value); - - private: - int64_t _internal_guid() const; - void _internal_set_guid(int64_t value); + int64_t _internal_energy() const; + void _internal_set_energy(int64_t value); public: // @@protoc_insertion_point(class_scope:protobuf.MessageOfTeam) @@ -3098,9 +3087,8 @@ namespace protobuf { int64_t team_id_; int64_t player_id_; - int32_t score_; - int32_t energy_; - int64_t guid_; + int64_t score_; + int64_t energy_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; }; union @@ -6788,78 +6776,54 @@ namespace protobuf // @@protoc_insertion_point(field_set:protobuf.MessageOfTeam.player_id) } - // int32 score = 3; + // int64 score = 3; inline void MessageOfTeam::clear_score() { - _impl_.score_ = 0; + _impl_.score_ = int64_t{0}; } - inline int32_t MessageOfTeam::_internal_score() const + inline int64_t MessageOfTeam::_internal_score() const { return _impl_.score_; } - inline int32_t MessageOfTeam::score() const + inline int64_t MessageOfTeam::score() const { // @@protoc_insertion_point(field_get:protobuf.MessageOfTeam.score) return _internal_score(); } - inline void MessageOfTeam::_internal_set_score(int32_t value) + inline void MessageOfTeam::_internal_set_score(int64_t value) { _impl_.score_ = value; } - inline void MessageOfTeam::set_score(int32_t value) + inline void MessageOfTeam::set_score(int64_t value) { _internal_set_score(value); // @@protoc_insertion_point(field_set:protobuf.MessageOfTeam.score) } - // int32 energy = 4; + // int64 energy = 4; inline void MessageOfTeam::clear_energy() { - _impl_.energy_ = 0; + _impl_.energy_ = int64_t{0}; } - inline int32_t MessageOfTeam::_internal_energy() const + inline int64_t MessageOfTeam::_internal_energy() const { return _impl_.energy_; } - inline int32_t MessageOfTeam::energy() const + inline int64_t MessageOfTeam::energy() const { // @@protoc_insertion_point(field_get:protobuf.MessageOfTeam.energy) return _internal_energy(); } - inline void MessageOfTeam::_internal_set_energy(int32_t value) + inline void MessageOfTeam::_internal_set_energy(int64_t value) { _impl_.energy_ = value; } - inline void MessageOfTeam::set_energy(int32_t value) + inline void MessageOfTeam::set_energy(int64_t value) { _internal_set_energy(value); // @@protoc_insertion_point(field_set:protobuf.MessageOfTeam.energy) } - // int64 guid = 5; - inline void MessageOfTeam::clear_guid() - { - _impl_.guid_ = int64_t{0}; - } - inline int64_t MessageOfTeam::_internal_guid() const - { - return _impl_.guid_; - } - inline int64_t MessageOfTeam::guid() const - { - // @@protoc_insertion_point(field_get:protobuf.MessageOfTeam.guid) - return _internal_guid(); - } - inline void MessageOfTeam::_internal_set_guid(int64_t value) - { - _impl_.guid_ = value; - } - inline void MessageOfTeam::set_guid(int64_t value) - { - _internal_set_guid(value); - // @@protoc_insertion_point(field_set:protobuf.MessageOfTeam.guid) - } - // ------------------------------------------------------------------- // MessageOfObj diff --git a/CAPI/cpp/proto/Message2Server.pb.cc b/CAPI/cpp/proto/Message2Server.pb.cc index 45954d56..2f28e47d 100644 --- a/CAPI/cpp/proto/Message2Server.pb.cc +++ b/CAPI/cpp/proto/Message2Server.pb.cc @@ -222,7 +222,7 @@ namespace protobuf ::_pbi::ConstantInitialized ) : _impl_{ - /*decltype(_impl_.x_)*/ 0, /*decltype(_impl_.y_)*/ 0, /*decltype(_impl_.team_id_)*/ int64_t{0}, /*decltype(_impl_.sweeper_type_)*/ 0, /*decltype(_impl_._cached_size_)*/ {}} + /*decltype(_impl_.team_id_)*/ int64_t{0}, /*decltype(_impl_.sweeper_type_)*/ 0, /*decltype(_impl_._cached_size_)*/ {}} { } struct BuildSweeperMsgDefaultTypeInternal @@ -333,8 +333,6 @@ const uint32_t TableStruct_Message2Server_2eproto::offsets[] PROTOBUF_SECTION_VA ~0u, // no _oneof_case_ ~0u, // no _weak_field_map_ ~0u, // no _inlined_string_donated_ - PROTOBUF_FIELD_OFFSET(::protobuf::BuildSweeperMsg, _impl_.x_), - PROTOBUF_FIELD_OFFSET(::protobuf::BuildSweeperMsg, _impl_.y_), PROTOBUF_FIELD_OFFSET(::protobuf::BuildSweeperMsg, _impl_.sweeper_type_), PROTOBUF_FIELD_OFFSET(::protobuf::BuildSweeperMsg, _impl_.team_id_), }; @@ -384,9 +382,9 @@ const char descriptor_table_protodef_Message2Server_2eproto[] PROTOBUF_SECTION_V "ver\030\002 \001(\003\022\017\n\007team_id\030\003 \001(\003\"[\n\nInstallMsg" "\022)\n\013module_type\030\001 \001(\0162\024.protobuf.ModuleT" "ype\022\021\n\tplayer_id\030\002 \001(\003\022\017\n\007team_id\030\003 \001(\003\"" - "e\n\017BuildSweeperMsg\022\t\n\001x\030\001 \001(\005\022\t\n\001y\030\002 \001(\005" - "\022+\n\014sweeper_type\030\003 \001(\0162\025.protobuf.Sweepe" - "rType\022\017\n\007team_id\030\004 \001(\003b\006proto3"; + "O\n\017BuildSweeperMsg\022+\n\014sweeper_type\030\001 \001(\016" + "2\025.protobuf.SweeperType\022\017\n\007team_id\030\002 \001(\003" + "b\006proto3"; static const ::_pbi::DescriptorTable* const descriptor_table_Message2Server_2eproto_deps[1] = { &::descriptor_table_MessageType_2eproto, }; @@ -394,7 +392,7 @@ static ::_pbi::once_flag descriptor_table_Message2Server_2eproto_once; const ::_pbi::DescriptorTable descriptor_table_Message2Server_2eproto = { false, false, - 870, + 848, descriptor_table_protodef_Message2Server_2eproto, "Message2Server.proto", &descriptor_table_Message2Server_2eproto_once, @@ -2787,10 +2785,10 @@ namespace protobuf BuildSweeperMsg* const _this = this; (void)_this; new (&_impl_) Impl_{ - decltype(_impl_.x_){}, decltype(_impl_.y_){}, decltype(_impl_.team_id_){}, decltype(_impl_.sweeper_type_){}, /*decltype(_impl_._cached_size_)*/ {}}; + decltype(_impl_.team_id_){}, decltype(_impl_.sweeper_type_){}, /*decltype(_impl_._cached_size_)*/ {}}; _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_); - ::memcpy(&_impl_.x_, &from._impl_.x_, static_cast(reinterpret_cast(&_impl_.sweeper_type_) - reinterpret_cast(&_impl_.x_)) + sizeof(_impl_.sweeper_type_)); + ::memcpy(&_impl_.team_id_, &from._impl_.team_id_, static_cast(reinterpret_cast(&_impl_.sweeper_type_) - reinterpret_cast(&_impl_.team_id_)) + sizeof(_impl_.sweeper_type_)); // @@protoc_insertion_point(copy_constructor:protobuf.BuildSweeperMsg) } @@ -2801,7 +2799,7 @@ namespace protobuf (void)arena; (void)is_message_owned; new (&_impl_) Impl_{ - decltype(_impl_.x_){0}, decltype(_impl_.y_){0}, decltype(_impl_.team_id_){int64_t{0}}, decltype(_impl_.sweeper_type_){0}, /*decltype(_impl_._cached_size_)*/ {}}; + decltype(_impl_.team_id_){int64_t{0}}, decltype(_impl_.sweeper_type_){0}, /*decltype(_impl_._cached_size_)*/ {}}; } BuildSweeperMsg::~BuildSweeperMsg() @@ -2832,7 +2830,7 @@ namespace protobuf // Prevent compiler warnings about cached_has_bits being unused (void)cached_has_bits; - ::memset(&_impl_.x_, 0, static_cast(reinterpret_cast(&_impl_.sweeper_type_) - reinterpret_cast(&_impl_.x_)) + sizeof(_impl_.sweeper_type_)); + ::memset(&_impl_.team_id_, 0, static_cast(reinterpret_cast(&_impl_.sweeper_type_) - reinterpret_cast(&_impl_.team_id_)) + sizeof(_impl_.sweeper_type_)); _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(); } @@ -2847,29 +2845,9 @@ namespace protobuf ptr = ::_pbi::ReadTag(ptr, &tag); switch (tag >> 3) { - // int32 x = 1; + // .protobuf.SweeperType sweeper_type = 1; case 1: if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 8)) - { - _impl_.x_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } - else - goto handle_unusual; - continue; - // int32 y = 2; - case 2: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) - { - _impl_.y_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr); - CHK_(ptr); - } - else - goto handle_unusual; - continue; - // .protobuf.SweeperType sweeper_type = 3; - case 3: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 24)) { uint64_t val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); @@ -2878,9 +2856,9 @@ namespace protobuf else goto handle_unusual; continue; - // int64 team_id = 4; - case 4: - if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 32)) + // int64 team_id = 2; + case 2: + if (PROTOBUF_PREDICT_TRUE(static_cast(tag) == 16)) { _impl_.team_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr); CHK_(ptr); @@ -2922,34 +2900,20 @@ namespace protobuf uint32_t cached_has_bits = 0; (void)cached_has_bits; - // int32 x = 1; - if (this->_internal_x() != 0) - { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(1, this->_internal_x(), target); - } - - // int32 y = 2; - if (this->_internal_y() != 0) - { - target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt32ToArray(2, this->_internal_y(), target); - } - - // .protobuf.SweeperType sweeper_type = 3; + // .protobuf.SweeperType sweeper_type = 1; if (this->_internal_sweeper_type() != 0) { target = stream->EnsureSpace(target); target = ::_pbi::WireFormatLite::WriteEnumToArray( - 3, this->_internal_sweeper_type(), target + 1, this->_internal_sweeper_type(), target ); } - // int64 team_id = 4; + // int64 team_id = 2; if (this->_internal_team_id() != 0) { target = stream->EnsureSpace(target); - target = ::_pbi::WireFormatLite::WriteInt64ToArray(4, this->_internal_team_id(), target); + target = ::_pbi::WireFormatLite::WriteInt64ToArray(2, this->_internal_team_id(), target); } if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) @@ -2971,25 +2935,13 @@ namespace protobuf // Prevent compiler warnings about cached_has_bits being unused (void)cached_has_bits; - // int32 x = 1; - if (this->_internal_x() != 0) - { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_x()); - } - - // int32 y = 2; - if (this->_internal_y() != 0) - { - total_size += ::_pbi::WireFormatLite::Int32SizePlusOne(this->_internal_y()); - } - - // int64 team_id = 4; + // int64 team_id = 2; if (this->_internal_team_id() != 0) { total_size += ::_pbi::WireFormatLite::Int64SizePlusOne(this->_internal_team_id()); } - // .protobuf.SweeperType sweeper_type = 3; + // .protobuf.SweeperType sweeper_type = 1; if (this->_internal_sweeper_type() != 0) { total_size += 1 + @@ -3016,14 +2968,6 @@ namespace protobuf uint32_t cached_has_bits = 0; (void)cached_has_bits; - if (from._internal_x() != 0) - { - _this->_internal_set_x(from._internal_x()); - } - if (from._internal_y() != 0) - { - _this->_internal_set_y(from._internal_y()); - } if (from._internal_team_id() != 0) { _this->_internal_set_team_id(from._internal_team_id()); @@ -3054,9 +2998,9 @@ namespace protobuf using std::swap; _internal_metadata_.InternalSwap(&other->_internal_metadata_); ::PROTOBUF_NAMESPACE_ID::internal::memswap< - PROTOBUF_FIELD_OFFSET(BuildSweeperMsg, _impl_.sweeper_type_) + sizeof(BuildSweeperMsg::_impl_.sweeper_type_) - PROTOBUF_FIELD_OFFSET(BuildSweeperMsg, _impl_.x_)>( - reinterpret_cast(&_impl_.x_), - reinterpret_cast(&other->_impl_.x_) + PROTOBUF_FIELD_OFFSET(BuildSweeperMsg, _impl_.sweeper_type_) + sizeof(BuildSweeperMsg::_impl_.sweeper_type_) - PROTOBUF_FIELD_OFFSET(BuildSweeperMsg, _impl_.team_id_)>( + reinterpret_cast(&_impl_.team_id_), + reinterpret_cast(&other->_impl_.team_id_) ); } diff --git a/CAPI/cpp/proto/Message2Server.pb.h b/CAPI/cpp/proto/Message2Server.pb.h index 7165a7bc..4e903b72 100644 --- a/CAPI/cpp/proto/Message2Server.pb.h +++ b/CAPI/cpp/proto/Message2Server.pb.h @@ -2216,32 +2216,10 @@ namespace protobuf enum : int { - kXFieldNumber = 1, - kYFieldNumber = 2, - kTeamIdFieldNumber = 4, - kSweeperTypeFieldNumber = 3, + kTeamIdFieldNumber = 2, + kSweeperTypeFieldNumber = 1, }; - // int32 x = 1; - void clear_x(); - int32_t x() const; - void set_x(int32_t value); - - private: - int32_t _internal_x() const; - void _internal_set_x(int32_t value); - - public: - // int32 y = 2; - void clear_y(); - int32_t y() const; - void set_y(int32_t value); - - private: - int32_t _internal_y() const; - void _internal_set_y(int32_t value); - - public: - // int64 team_id = 4; + // int64 team_id = 2; void clear_team_id(); int64_t team_id() const; void set_team_id(int64_t value); @@ -2251,7 +2229,7 @@ namespace protobuf void _internal_set_team_id(int64_t value); public: - // .protobuf.SweeperType sweeper_type = 3; + // .protobuf.SweeperType sweeper_type = 1; void clear_sweeper_type(); ::protobuf::SweeperType sweeper_type() const; void set_sweeper_type(::protobuf::SweeperType value); @@ -2272,8 +2250,6 @@ namespace protobuf typedef void DestructorSkippable_; struct Impl_ { - int32_t x_; - int32_t y_; int64_t team_id_; int sweeper_type_; mutable ::PROTOBUF_NAMESPACE_ID::internal::CachedSize _cached_size_; @@ -3116,55 +3092,7 @@ namespace protobuf // BuildSweeperMsg - // int32 x = 1; - inline void BuildSweeperMsg::clear_x() - { - _impl_.x_ = 0; - } - inline int32_t BuildSweeperMsg::_internal_x() const - { - return _impl_.x_; - } - inline int32_t BuildSweeperMsg::x() const - { - // @@protoc_insertion_point(field_get:protobuf.BuildSweeperMsg.x) - return _internal_x(); - } - inline void BuildSweeperMsg::_internal_set_x(int32_t value) - { - _impl_.x_ = value; - } - inline void BuildSweeperMsg::set_x(int32_t value) - { - _internal_set_x(value); - // @@protoc_insertion_point(field_set:protobuf.BuildSweeperMsg.x) - } - - // int32 y = 2; - inline void BuildSweeperMsg::clear_y() - { - _impl_.y_ = 0; - } - inline int32_t BuildSweeperMsg::_internal_y() const - { - return _impl_.y_; - } - inline int32_t BuildSweeperMsg::y() const - { - // @@protoc_insertion_point(field_get:protobuf.BuildSweeperMsg.y) - return _internal_y(); - } - inline void BuildSweeperMsg::_internal_set_y(int32_t value) - { - _impl_.y_ = value; - } - inline void BuildSweeperMsg::set_y(int32_t value) - { - _internal_set_y(value); - // @@protoc_insertion_point(field_set:protobuf.BuildSweeperMsg.y) - } - - // .protobuf.SweeperType sweeper_type = 3; + // .protobuf.SweeperType sweeper_type = 1; inline void BuildSweeperMsg::clear_sweeper_type() { _impl_.sweeper_type_ = 0; @@ -3188,7 +3116,7 @@ namespace protobuf // @@protoc_insertion_point(field_set:protobuf.BuildSweeperMsg.sweeper_type) } - // int64 team_id = 4; + // int64 team_id = 2; inline void BuildSweeperMsg::clear_team_id() { _impl_.team_id_ = int64_t{0}; From 79aa7b4f6de8700819b66d319c88015834518c76 Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Sat, 23 Mar 2024 21:34:31 +0800 Subject: [PATCH 4/7] feat: :sparkles: implement money --- logic/GameClass/GameObj/Areas/Construction.cs | 11 ++- logic/GameClass/GameObj/Areas/Wormhole.cs | 7 +- logic/GameClass/GameObj/MoneyPool.cs | 7 +- logic/GameClass/GameObj/Ship.cs | 24 ++++++ logic/Gaming/Game.cs | 9 +- logic/Gaming/ShipManager.cs | 2 + logic/Preparation/Interface/IMoneyPool.cs | 2 +- logic/Preparation/Interface/IShip.cs | 1 + logic/Preparation/Utility/GameData.cs | 84 +++++++++---------- 9 files changed, 97 insertions(+), 50 deletions(-) diff --git a/logic/GameClass/GameObj/Areas/Construction.cs b/logic/GameClass/GameObj/Areas/Construction.cs index d1a0a8fc..0e131c95 100755 --- a/logic/GameClass/GameObj/Areas/Construction.cs +++ b/logic/GameClass/GameObj/Areas/Construction.cs @@ -54,7 +54,12 @@ public bool Construct(int constructSpeed, ConstructionType constructionType, Shi return false; } } - return HP.AddV(constructSpeed) > 0; + var addHP = HP.GetMaxV() - HP > constructSpeed ? constructSpeed : HP.GetMaxV() - HP; + if (ship.MoneyPool.Money < addHP / 10) + { + return false; + } + return ship.MoneyPool.SubMoney(HP.AddV(addHP) / 10) > 0; } public void BeAttacked(Bullet bullet) { @@ -63,6 +68,10 @@ public void BeAttacked(Bullet bullet) long subHP = bullet.AP; HP.SubPositiveV(subHP); } + if (HP == 0) + { + constructionType = ConstructionType.Null; + } } public void AddConstructNum(int add = 1) { diff --git a/logic/GameClass/GameObj/Areas/Wormhole.cs b/logic/GameClass/GameObj/Areas/Wormhole.cs index 47153773..04f0d015 100755 --- a/logic/GameClass/GameObj/Areas/Wormhole.cs +++ b/logic/GameClass/GameObj/Areas/Wormhole.cs @@ -16,7 +16,12 @@ public class Wormhole(XY initPos, List grids) public AtomicInt RepairNum { get; } = new AtomicInt(0); public bool Repair(int constructSpeed, Ship ship) { - return HP.AddV(constructSpeed) > 0; + var addHP = HP.GetMaxV() - HP > constructSpeed ? constructSpeed : HP.GetMaxV() - HP; + if (ship.MoneyPool.Money < addHP / 10) + { + return false; + } + return ship.MoneyPool.SubMoney(HP.AddV(addHP) / 10) > 0; } public void BeAttacked(Bullet bullet) { diff --git a/logic/GameClass/GameObj/MoneyPool.cs b/logic/GameClass/GameObj/MoneyPool.cs index b1b9e021..5a26de36 100644 --- a/logic/GameClass/GameObj/MoneyPool.cs +++ b/logic/GameClass/GameObj/MoneyPool.cs @@ -13,11 +13,10 @@ public MoneyPool() } public long AddMoney(long add) { - Money.Add(add); - return add; + return Money.Add(add); } - public void SubMoney(long sub) + public long SubMoney(long sub) { - Money.Sub(sub); + return Money.Sub(sub); } } \ No newline at end of file diff --git a/logic/GameClass/GameObj/Ship.cs b/logic/GameClass/GameObj/Ship.cs index 95991da8..0af4bff7 100755 --- a/logic/GameClass/GameObj/Ship.cs +++ b/logic/GameClass/GameObj/Ship.cs @@ -266,6 +266,30 @@ public void SubMoney(long sub) { MoneyPool.Money.Sub(sub); } + public long GetCost() + { + var cost = 0; + switch (ShipType) + { + case ShipType.CivilShip: + cost += GameData.CivilShipCost; + break; + case ShipType.WarShip: + cost += GameData.WarShipCost; + break; + case ShipType.FlagShip: + cost += GameData.FlagShipCost; + break; + default: + return 0; + } + cost += producer.Cost; + cost += constructor.Cost; + cost += armor.Cost; + cost += shield.Cost; + cost += weapon.Cost; + return cost; + } private long ChangeShipState(RunningStateType running, ShipStateType value = ShipStateType.Null, GameObj? gameObj = null) { //只能被SetShipState引用 diff --git a/logic/Gaming/Game.cs b/logic/Gaming/Game.cs index b2ddbab5..26165738 100755 --- a/logic/Gaming/Game.cs +++ b/logic/Gaming/Game.cs @@ -111,7 +111,14 @@ public bool Construct(long teamID, long shipID, ConstructionType constructionTyp return false; Ship? ship = gameMap.FindShipInPlayerID(teamID, shipID); if (ship != null) - return actionManager.Construct(ship, constructionType); + { + var flag = actionManager.Construct(ship, constructionType); + if (constructionType == ConstructionType.Community && flag) + { + UpdateBirthPoint(); + } + return flag; + } return false; } public bool InstallModule(long teamID, long shipID, ModuleType moduleType) diff --git a/logic/Gaming/ShipManager.cs b/logic/Gaming/ShipManager.cs index 870e8c85..11c77ebe 100755 --- a/logic/Gaming/ShipManager.cs +++ b/logic/Gaming/ShipManager.cs @@ -51,6 +51,8 @@ public void BeAttacked(Ship ship, Bullet bullet) } if (ship.HP == 0) { + var money = ship.GetCost(); + bullet.Parent.AddMoney(money); Remove(ship); } } diff --git a/logic/Preparation/Interface/IMoneyPool.cs b/logic/Preparation/Interface/IMoneyPool.cs index 3e9ae255..0827bf12 100644 --- a/logic/Preparation/Interface/IMoneyPool.cs +++ b/logic/Preparation/Interface/IMoneyPool.cs @@ -7,6 +7,6 @@ public interface IMoneyPool public AtomicLongOnlyAddScore Money { get; } public AtomicLong Score { get; } public long AddMoney(long add); - public void SubMoney(long sub); + public long SubMoney(long sub); } } diff --git a/logic/Preparation/Interface/IShip.cs b/logic/Preparation/Interface/IShip.cs index 9c063e2c..664be40b 100755 --- a/logic/Preparation/Interface/IShip.cs +++ b/logic/Preparation/Interface/IShip.cs @@ -10,6 +10,7 @@ public interface IShip : IMovable, IPlayer public ShipType ShipType { get; } public ShipStateType ShipState { get; } public IntNumUpdateEachCD BulletNum { get; } + public void AddMoney(long add); public long SetShipState(RunningStateType running, ShipStateType value = ShipStateType.Null, IGameObj? obj = null); public bool ResetShipState(long state, RunningStateType running = RunningStateType.Null, ShipStateType value = ShipStateType.Null, IGameObj? obj = null); } diff --git a/logic/Preparation/Utility/GameData.cs b/logic/Preparation/Utility/GameData.cs index 78a7beff..151a403b 100755 --- a/logic/Preparation/Utility/GameData.cs +++ b/logic/Preparation/Utility/GameData.cs @@ -24,7 +24,7 @@ public static class GameData public const int MapRows = 50; // 行数 public const int MapCols = 50; // 列数 - public const int InitialMoney = 50; // 初始金钱 + public const int InitialMoney = 500; // 初始金钱 public static bool IsGameObjMap(GameObjType gameObjType) => (uint)gameObjType > 3; public static bool NeedCopy(GameObjType gameObjType) @@ -105,73 +105,73 @@ public static bool ApproachToInteractInACross(XY pos1, XY pos2) public const int ArcCastTime = 600; // 电弧前摇时间 public const int ArcSwingTime = 600; // 电弧后摇时间 - public const int CivilShipCost = 40; + public const int CivilShipCost = 400; public const int CivilShipMaxHP = 3000; public const int CivilShipMoveSpeed = 3000; public const int CivilShipViewRange = 8000; public const int CivilShipBaseArmor = 0; public const int CivilShipBaseShield = 0; public const int CivilShipProducer1Cost = 0; - public const int CivilShipProducer2Cost = 40; - public const int CivilShipProducer3Cost = 80; + public const int CivilShipProducer2Cost = 400; + public const int CivilShipProducer3Cost = 800; public const int CivilShipConstructor1Cost = 0; - public const int CivilShipConstructor2Cost = 40; - public const int CivilShipConstructor3Cost = 80; - public const int CivilShipArmor1Cost = 60; - public const int CivilShipShield1Cost = 60; - public const int CivilShipLaserGunCost = 100; + public const int CivilShipConstructor2Cost = 400; + public const int CivilShipConstructor3Cost = 800; + public const int CivilShipArmor1Cost = 600; + public const int CivilShipShield1Cost = 600; + public const int CivilShipLaserGunCost = 1000; - public const int WarShipCost = 120; + public const int WarShipCost = 1200; public const int WarShipMaxHP = 4000; public const int WarShipMoveSpeed = 2800; public const int WarShipViewRange = 8000; public const int WarShipBaseArmor = 400; public const int WarShipBaseShield = 400; - public const int WarShipArmor1Cost = 60; - public const int WarShipArmor2Cost = 120; - public const int WarShipArmor3Cost = 180; - public const int WarShipShield1Cost = 60; - public const int WarShipShield2Cost = 120; - public const int WarShipShield3Cost = 180; + public const int WarShipArmor1Cost = 600; + public const int WarShipArmor2Cost = 1200; + public const int WarShipArmor3Cost = 1800; + public const int WarShipShield1Cost = 600; + public const int WarShipShield2Cost = 1200; + public const int WarShipShield3Cost = 1800; public const int WarShipLaserGunCost = 0; - public const int WarShipPlasmaGunCost = 120; - public const int WarShipShellGunCost = 130; - public const int WarShipMissileGunCost = 180; - public const int WarShipArcGunCost = 240; + public const int WarShipPlasmaGunCost = 1200; + public const int WarShipShellGunCost = 1300; + public const int WarShipMissileGunCost = 1800; + public const int WarShipArcGunCost = 2400; - public const int FlagShipCost = 500; + public const int FlagShipCost = 5000; public const int FlagShipMaxHP = 12000; public const int FlagShipMoveSpeed = 2700; public const int FlagShipViewRange = 8000; public const int FlagShipBaseArmor = 800; public const int FlagShipBaseShield = 800; - public const int FlagShipProducer1Cost = 40; - public const int FlagShipConstructor1Cost = 40; - public const int FlagShipArmor1Cost = 60; - public const int FlagShipArmor2Cost = 120; - public const int FlagShipArmor3Cost = 180; - public const int FlagShipShield1Cost = 60; - public const int FlagShipShield2Cost = 120; - public const int FlagShipShield3Cost = 180; + public const int FlagShipProducer1Cost = 400; + public const int FlagShipConstructor1Cost = 400; + public const int FlagShipArmor1Cost = 600; + public const int FlagShipArmor2Cost = 1200; + public const int FlagShipArmor3Cost = 1800; + public const int FlagShipShield1Cost = 600; + public const int FlagShipShield2Cost = 1200; + public const int FlagShipShield3Cost = 1800; public const int FlagShipLaserGunCost = 0; - public const int FlagShipPlasmaGunCost = 120; - public const int FlagShipShellGunCost = 130; - public const int FlagShipMissileGunCost = 180; - public const int FlagShipArcGunCost = 240; - - public const int ScoreHomePerSecond = 1; - public const int ScoreFactoryPerSecond = 3; - public const int ScoreProducer1PerSecond = 5; - public const int ScoreProducer2PerSecond = 7; - public const int ScoreProducer3PerSecond = 10; + public const int FlagShipPlasmaGunCost = 1200; + public const int FlagShipShellGunCost = 1300; + public const int FlagShipMissileGunCost = 1800; + public const int FlagShipArcGunCost = 2400; + + public const int ScoreHomePerSecond = 20; + public const int ScoreFactoryPerSecond = 50; + public const int ScoreProducer1PerSecond = 20; + public const int ScoreProducer2PerSecond = 30; + public const int ScoreProducer3PerSecond = 40; public const int ScoreConstructionDamaged = 200; public static int ScoreShipKilled(int totalScore) => totalScore / 5; public static int ScoreShipRecovered(int totalRecovery) => totalRecovery * 6 / 5; public static int ScoreShipRecycled(int remainingHP) => remainingHP / 2; - public const int Constructor1Speed = 500; - public const int Constructor2Speed = 750; - public const int Constructor3Speed = 1000; + public const int Constructor1Speed = 300; + public const int Constructor2Speed = 400; + public const int Constructor3Speed = 500; public const int Armor1 = 2000; public const int Armor2 = 3000; public const int Armor3 = 4000; From c77e96675ac44378a69ccbd9a79c24f27ce9597a Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Sat, 23 Mar 2024 21:43:19 +0800 Subject: [PATCH 5/7] fix: :bug: activate --- dependency/proto/Message2Server.proto | 2 ++ logic/Gaming/ShipManager.cs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/dependency/proto/Message2Server.proto b/dependency/proto/Message2Server.proto index 9c7722e7..35050d90 100755 --- a/dependency/proto/Message2Server.proto +++ b/dependency/proto/Message2Server.proto @@ -70,4 +70,6 @@ message BuildSweeperMsg { SweeperType sweeper_type = 1; int64 team_id = 2; + int64 player_id = 3; + int64 birthpoint_index = 4; } \ No newline at end of file diff --git a/logic/Gaming/ShipManager.cs b/logic/Gaming/ShipManager.cs index 11c77ebe..9551c064 100755 --- a/logic/Gaming/ShipManager.cs +++ b/logic/Gaming/ShipManager.cs @@ -20,6 +20,17 @@ private class ShipManager(Map gameMap) } public bool ActivateShip(Ship ship, XY pos) { + var activateCost = ship.ShipType switch + { + ShipType.CivilShip => GameData.CivilShipCost, + ShipType.WarShip => GameData.WarShipCost, + ShipType.FlagShip => GameData.FlagShipCost, + _ => int.MaxValue + }; + if (activateCost > ship.MoneyPool.Money) + { + return false; + } if (ship.ShipState != ShipStateType.Deceased) { return false; From 314b01f68c4e88004fd366af386395cf520ef60b Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Sat, 23 Mar 2024 21:48:08 +0800 Subject: [PATCH 6/7] Update Message2Server.proto --- dependency/proto/Message2Server.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependency/proto/Message2Server.proto b/dependency/proto/Message2Server.proto index 35050d90..0fd246e0 100755 --- a/dependency/proto/Message2Server.proto +++ b/dependency/proto/Message2Server.proto @@ -71,5 +71,5 @@ message BuildSweeperMsg SweeperType sweeper_type = 1; int64 team_id = 2; int64 player_id = 3; - int64 birthpoint_index = 4; + int32 birthpoint_index = 4; } \ No newline at end of file From 244d67f7b2dc0446b43a24d5b75a2b82bf3b7690 Mon Sep 17 00:00:00 2001 From: Xuc Pan Date: Sat, 23 Mar 2024 21:54:28 +0800 Subject: [PATCH 7/7] fix: :bug: money --- logic/GameClass/GameObj/Ship.cs | 9 ++++----- logic/Preparation/Interface/IShip.cs | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/logic/GameClass/GameObj/Ship.cs b/logic/GameClass/GameObj/Ship.cs index 0af4bff7..00a87411 100755 --- a/logic/GameClass/GameObj/Ship.cs +++ b/logic/GameClass/GameObj/Ship.cs @@ -257,14 +257,13 @@ public GameObj? WhatInteractingWith } } } - public void AddMoney(long add) + public long AddMoney(long add) { - MoneyPool.Money.Add(add); - MoneyPool.Score.Add(add); + return MoneyPool.AddMoney(add); } - public void SubMoney(long sub) + public long SubMoney(long sub) { - MoneyPool.Money.Sub(sub); + return MoneyPool.SubMoney(sub); } public long GetCost() { diff --git a/logic/Preparation/Interface/IShip.cs b/logic/Preparation/Interface/IShip.cs index 664be40b..3044a845 100755 --- a/logic/Preparation/Interface/IShip.cs +++ b/logic/Preparation/Interface/IShip.cs @@ -10,7 +10,8 @@ public interface IShip : IMovable, IPlayer public ShipType ShipType { get; } public ShipStateType ShipState { get; } public IntNumUpdateEachCD BulletNum { get; } - public void AddMoney(long add); + public long AddMoney(long add); + public long SubMoney(long sub); public long SetShipState(RunningStateType running, ShipStateType value = ShipStateType.Null, IGameObj? obj = null); public bool ResetShipState(long state, RunningStateType running = RunningStateType.Null, ShipStateType value = ShipStateType.Null, IGameObj? obj = null); }