From e5d916366d308162b3efd0696635aca08ada57c8 Mon Sep 17 00:00:00 2001 From: uri_ba Date: Tue, 11 Jul 2023 16:30:18 +0300 Subject: [PATCH 1/2] add guard agains nil group from dead unit --- lua/DCS-gRPC/exporters/object.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/DCS-gRPC/exporters/object.lua b/lua/DCS-gRPC/exporters/object.lua index cc791e45..44696908 100644 --- a/lua/DCS-gRPC/exporters/object.lua +++ b/lua/DCS-gRPC/exporters/object.lua @@ -45,6 +45,7 @@ GRPC.exporters.rawTransform = function(object) end GRPC.exporters.group = function(group) + if type(group) ~= "table" and getmetatable(group) ~= Group then return {} end return { id = tonumber(group:getID()), name = group:getName(), From f147f402b7181a253b5935e0a3aaa5619c7195ef Mon Sep 17 00:00:00 2001 From: uri_ba Date: Wed, 12 Jul 2023 20:33:10 +0300 Subject: [PATCH 2/2] return nil for dead unit group --- lua/DCS-gRPC/exporters/object.lua | 2 +- protos/dcs/common/v0/common.proto | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/DCS-gRPC/exporters/object.lua b/lua/DCS-gRPC/exporters/object.lua index 44696908..ebc3ad34 100644 --- a/lua/DCS-gRPC/exporters/object.lua +++ b/lua/DCS-gRPC/exporters/object.lua @@ -45,7 +45,7 @@ GRPC.exporters.rawTransform = function(object) end GRPC.exporters.group = function(group) - if type(group) ~= "table" and getmetatable(group) ~= Group then return {} end + if type(group) ~= "table" and getmetatable(group) ~= Group then return nil end return { id = tonumber(group:getID()), name = group:getName(), diff --git a/protos/dcs/common/v0/common.proto b/protos/dcs/common/v0/common.proto index c9e13f79..5c33bbdf 100644 --- a/protos/dcs/common/v0/common.proto +++ b/protos/dcs/common/v0/common.proto @@ -231,8 +231,8 @@ message Unit { Velocity velocity = 8; // The name of the player if one is in control of the unit optional string player_name = 9; - // The group that the unit belongs to - Group group = 10; + // The group that the unit belongs to (dead units have no group) + optional Group group = 10; // The number of this unit in the group. Does not change as units are // destroyed uint32 number_in_group = 11;