From d7ae4da6bc2bcc5cb79527862572ba31145a9904 Mon Sep 17 00:00:00 2001 From: mobot-gh Date: Wed, 9 Jul 2025 13:38:36 +0100 Subject: [PATCH 1/4] Add coalition and name to sendchat event --- lua/DCS-gRPC/grpc-hook.lua | 14 ++++++++++---- protos/dcs/mission/v0/mission.proto | 6 ++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lua/DCS-gRPC/grpc-hook.lua b/lua/DCS-gRPC/grpc-hook.lua index 419a7f4..0e59f26 100644 --- a/lua/DCS-gRPC/grpc-hook.lua +++ b/lua/DCS-gRPC/grpc-hook.lua @@ -45,19 +45,25 @@ end -- None of these methods should return anything as doing so breaks other scripts attempting to -- react to the hook as well. -function handler.onPlayerTrySendChat(playerID, msg) +function handler.onPlayerTrySendChat(playerID, msg, all) -- note: currently `all` (third parameter) will always `=true` regardless if the target is to the coalition/team -- or to everybody. When ED fixes this, implementation should determine the dcs.common.v0.Coalition - + local coalition = net.get_player_info(playerID, "side") + local playerName = net.get_player_info(playerID, "name") + local toAll = true + if coalition ~= nil then coalition = coalition + 1 end + if all == -2 then toAll = false end grpc.event({ time = DCS.getModelTime(), event = { type = "playerSendChat", playerId = playerID, - message = msg + message = msg, + coalition = coalition, + playerName = playerName, + toAll = toAll }, }) - end function handler.onPlayerTryConnect(addr, name, ucid, id) diff --git a/protos/dcs/mission/v0/mission.proto b/protos/dcs/mission/v0/mission.proto index 11ed890..beada7c 100644 --- a/protos/dcs/mission/v0/mission.proto +++ b/protos/dcs/mission/v0/mission.proto @@ -387,6 +387,12 @@ message StreamEventsResponse { uint32 player_id = 1; // what was typed string message = 2; + // player's coalition + dcs.common.v0.Coalition coalition = 3; + // player's name + string player_name = 4; + // sent to all chat + bool to_all = 5; } // fired when the player changes across to a slot From b0edb287b0beb9f25314585acf46c25394c05e98 Mon Sep 17 00:00:00 2001 From: mobot-gh Date: Tue, 5 May 2026 13:22:42 +0100 Subject: [PATCH 2/4] adjustments for linter --- src/authentication.rs | 11 ++++++----- src/rpc/custom.rs | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/authentication.rs b/src/authentication.rs index 5c37db9..66299b4 100644 --- a/src/authentication.rs +++ b/src/authentication.rs @@ -26,11 +26,12 @@ impl RequestInterceptor for AuthInterceptor { } } - if client.is_some() { - log::debug!("Authenticated client: {}", client.unwrap()); - Ok(req) - } else { - Err(Status::unauthenticated("Unauthenticated")) + match client { + Some(client_name) => { + log::debug!("Authenticated client: {}", client_name); + Ok(req) + } + _ => Err(Status::unauthenticated("Unauthenticated")), } } _ => Err(Status::unauthenticated("Unauthenticated")), diff --git a/src/rpc/custom.rs b/src/rpc/custom.rs index 336c3a6..1acfe7a 100644 --- a/src/rpc/custom.rs +++ b/src/rpc/custom.rs @@ -52,6 +52,7 @@ impl CustomService for MissionRpc { Ok(Response::new(custom::v0::EvalResponse { json })) } + #[allow(clippy::result_large_err)] async fn get_magnetic_declination( &self, request: Request, From ba54d29dd27b99d7eb0e869e4238875b5879457d Mon Sep 17 00:00:00 2001 From: mobot-gh Date: Fri, 15 May 2026 22:35:25 +0100 Subject: [PATCH 3/4] Add nil guard to onPlayerTrySendChat --- lua/DCS-gRPC/grpc-hook.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/DCS-gRPC/grpc-hook.lua b/lua/DCS-gRPC/grpc-hook.lua index 0e59f26..0295c64 100644 --- a/lua/DCS-gRPC/grpc-hook.lua +++ b/lua/DCS-gRPC/grpc-hook.lua @@ -48,8 +48,12 @@ end function handler.onPlayerTrySendChat(playerID, msg, all) -- note: currently `all` (third parameter) will always `=true` regardless if the target is to the coalition/team -- or to everybody. When ED fixes this, implementation should determine the dcs.common.v0.Coalition - local coalition = net.get_player_info(playerID, "side") - local playerName = net.get_player_info(playerID, "name") + local playerInfo = net.get_player_info(playerID) + local coalition, playerName + if playerInfo ~= nil then + coalition = net.get_player_info(playerID, "side") + playerName = net.get_player_info(playerID, "name") + end local toAll = true if coalition ~= nil then coalition = coalition + 1 end if all == -2 then toAll = false end From ec531e6677740bd6db615f1726300a7375266c7e Mon Sep 17 00:00:00 2001 From: mobot-gh Date: Mon, 18 May 2026 21:18:23 +0100 Subject: [PATCH 4/4] add entry for CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index be50302..1439dad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Request uses `dcs.common.v0.ObjectCategory[]` and `SearchVolume` (with `InputPosition` for geo points). - Response returns `dcs.common.v0.Target[]` for consistent object union across services. - Lua implementation unwraps grpcui oneof wrapper (`volume.shape`) and supports both wrapped and flattened shapes. +- Added `coalition`, `player_name`, and `to_all` fields to `PlayerSendChatEvent`. ## [0.8.1] 2024-11-05