From b41cb478e7ef484b4406ef64ee83b2731c19d871 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 22 Jun 2025 10:08:29 -0400 Subject: [PATCH] Display unsheathed weapon to other players It doesn't play the animation correctly, yet. --- src/ipc/zone/actor_control.rs | 7 +++++++ src/ipc/zone/client_trigger.rs | 9 +++++++++ src/world/server.rs | 12 ++++++++++++ 3 files changed, 28 insertions(+) diff --git a/src/ipc/zone/actor_control.rs b/src/ipc/zone/actor_control.rs index d811de7..942f1f0 100644 --- a/src/ipc/zone/actor_control.rs +++ b/src/ipc/zone/actor_control.rs @@ -10,6 +10,13 @@ use super::OnlineStatus; #[binrw] #[derive(Debug, Eq, PartialEq, Clone)] pub enum ActorControlCategory { + #[brw(magic = 0x0u16)] + ToggleWeapon { + #[brw(pad_before = 2)] + #[br(map = read_bool_from::)] + #[bw(map = write_bool_as::)] + shown: bool, + }, #[brw(magic = 0x26u16)] ToggleInvisibility { #[brw(pad_before = 2)] diff --git a/src/ipc/zone/client_trigger.rs b/src/ipc/zone/client_trigger.rs index d08a710..a6e9f06 100644 --- a/src/ipc/zone/client_trigger.rs +++ b/src/ipc/zone/client_trigger.rs @@ -1,8 +1,17 @@ use binrw::binrw; +use crate::common::{read_bool_from, write_bool_as}; + #[binrw] #[derive(Debug, Eq, PartialEq, Clone)] pub enum ClientTriggerCommand { + #[brw(magic = 0x1u16)] + ToggleWeapon { + #[brw(pad_before = 2)] + #[br(map = read_bool_from::)] + #[bw(map = write_bool_as::)] + shown: bool, + }, #[brw(magic = 0x3u16)] SetTarget { #[brw(pad_before = 2)] diff --git a/src/world/server.rs b/src/world/server.rs index 275e15d..2aea12f 100644 --- a/src/world/server.rs +++ b/src/world/server.rs @@ -388,6 +388,18 @@ pub async fn server_main_loop(mut recv: Receiver) -> Result<(), std::i to_remove.push(id); } } + ClientTriggerCommand::ToggleWeapon { shown } => { + let msg = FromServer::ActorControl( + from_actor_id, + ActorControl { + category: ActorControlCategory::ToggleWeapon { shown: *shown }, + }, + ); + + if handle.send(msg).is_err() { + to_remove.push(id); + } + } _ => tracing::warn!("Server doesn't know what to do with {:#?}", trigger), } }