From b1d39063f844f176ef619185db99200f6f1f3d43 Mon Sep 17 00:00:00 2001 From: Justin Lovell Date: Sat, 15 Jan 2022 23:42:32 +1100 Subject: [PATCH] Fixing `GroupCategory` Motivated by work in progress with PR #111. Communicating breaking changes and configuring to change log and updating behavior --- CHANGELOG.md | 3 +++ lua/DCS-gRPC/methods/coalitions.lua | 5 ++++- protos/dcs/coalition/v0/coalition.proto | 2 +- protos/dcs/common/v0/common.proto | 11 ++++++----- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fbb813b..fa05dd65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `net.proto` - `GetPlayerInfo.remote_address` - `mission.proto` - `PlayerSendChatEvent.player_id` +### Breaking Changes +- Added `GROUP_CATEGORY_UNSPECIFIED` to `dcs.v0.common.GroupCategory`; breaking change as all indexes have changed. + ## [0.3.0] - 2022-01-14 ### Added - Generated scaffolding for the `net.*` scope into `NetService` diff --git a/lua/DCS-gRPC/methods/coalitions.lua b/lua/DCS-gRPC/methods/coalitions.lua index da3c27f5..9cbe00b9 100644 --- a/lua/DCS-gRPC/methods/coalitions.lua +++ b/lua/DCS-gRPC/methods/coalitions.lua @@ -106,13 +106,16 @@ local createGroundGroupTemplate = function(groupTemplate) end GRPC.methods.addGroup = function(params) + if params.groupCategory == 0 then + return GRPC.errorInvalidArgument("group category must be specified") + end if params.country_id == 0 or params.country_id == 15 then return GRPC.errorInvalidArgument("invalid country code") end local template = createGroundGroupTemplate(params.template.groundTemplate) - coalition.addGroup(params.country - 1, params.groupCategory, template) -- Decrement for non zero-indexed gRPC enum + coalition.addGroup(params.country - 1, params.groupCategory - 1, template) -- Decrement for non zero-indexed gRPC enum return GRPC.success({group = GRPC.exporters.group(Group.getByName(template.name))}) end diff --git a/protos/dcs/coalition/v0/coalition.proto b/protos/dcs/coalition/v0/coalition.proto index 099dcc44..5e71349a 100644 --- a/protos/dcs/coalition/v0/coalition.proto +++ b/protos/dcs/coalition/v0/coalition.proto @@ -112,7 +112,7 @@ message AddGroupResponse { message GetGroupsRequest { dcs.common.v0.Coalition coalition = 1; - optional dcs.common.v0.GroupCategory category = 2; + dcs.common.v0.GroupCategory category = 2; } message GetGroupsResponse { diff --git a/protos/dcs/common/v0/common.proto b/protos/dcs/common/v0/common.proto index 9b0565c6..94823c7d 100644 --- a/protos/dcs/common/v0/common.proto +++ b/protos/dcs/common/v0/common.proto @@ -231,11 +231,12 @@ message Group { * Group category enumerator. */ enum GroupCategory { - GROUP_CATEGORY_AIRPLANE = 0; - GROUP_CATEGORY_HELICOPTER = 1; - GROUP_CATEGORY_GROUND = 2; - GROUP_CATEGORY_SHIP = 3; - GROUP_CATEGORY_TRAIN = 4; + GROUP_CATEGORY_UNSPECIFIED = 0; + GROUP_CATEGORY_AIRPLANE = 1; + GROUP_CATEGORY_HELICOPTER = 2; + GROUP_CATEGORY_GROUND = 3; + GROUP_CATEGORY_SHIP = 4; + GROUP_CATEGORY_TRAIN = 5; } /**