From 0139fbc8c636b240c97be24fd5cd3641f3241fed Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 9 May 2025 19:30:37 -0400 Subject: [PATCH] Remove the now unused ToServer::ActorDespawned This is handled in the much-better-named LeftZone message. --- src/bin/kawari-world.rs | 4 ++-- src/world/connection.rs | 1 - src/world/server.rs | 39 --------------------------------------- 3 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index 9a926b2..7d44e81 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -708,9 +708,9 @@ async fn client_loop( if actor.hp == 0 { tracing::info!("Despawning {} because they died!", actor.id.0); // if the actor died, despawn them - connection.handle + /*connection.handle .send(ToServer::ActorDespawned(connection.id, actor.id.0)) - .await; + .await;*/ } } } diff --git a/src/world/connection.rs b/src/world/connection.rs index eb66e7a..351d2b9 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -112,7 +112,6 @@ pub enum ToServer { // TODO: ditto, zone id should not be here ActorSpawned(ClientId, u16, Actor, CommonSpawn), ActorMoved(ClientId, u32, Position, f32), - ActorDespawned(ClientId, u32), ClientTrigger(ClientId, u32, ClientTrigger), // TODO: the connection should not be in charge and telling the global server what zone they just loaded in! but this will work for now ZoneLoaded(ClientId, u16), diff --git a/src/world/server.rs b/src/world/server.rs index 1297bbe..e6867a6 100644 --- a/src/world/server.rs +++ b/src/world/server.rs @@ -12,7 +12,6 @@ use super::{Actor, ClientHandle, ClientId, FromServer, ToServer}; #[derive(Default, Debug, Clone)] struct Instance { - zone_id: u16, // structure temporary, of course actors: HashMap, } @@ -45,16 +44,6 @@ impl WorldServer { } } - /// Finds the instance associated with an actor, or returns None if they are not found. - fn find_actor_instance(&self, actor_id: u32) -> Option<&Instance> { - for (_, instance) in &self.instances { - if instance.actors.contains_key(&ObjectId(actor_id)) { - return Some(instance); - } - } - None - } - /// Finds the instance associated with an actor, or returns None if they are not found. fn find_actor_instance_mut(&mut self, actor_id: u32) -> Option<&mut Instance> { for (_, instance) in &mut self.instances { @@ -175,34 +164,6 @@ pub async fn server_main_loop(mut recv: Receiver) -> Result<(), std::i } } } - ToServer::ActorDespawned(from_id, actor_id) => { - // NOTE: the order of operations here is very intentional - // the client will send actordespawn before we get a ZoneLoaded from the server - let current_instance = data.find_actor_instance_mut(actor_id).unwrap(); - let instance = current_instance.clone(); - current_instance.actors.remove(&ObjectId(actor_id)); - - // Then tell any clients in the zone that we left - for (id, (handle, state)) in &mut data.clients { - let id = *id; - - // don't bother telling the client who told us - if id == from_id { - continue; - } - - // skip any clients not in our zone - if state.zone_id != instance.zone_id { - continue; - } - - let msg = FromServer::ActorDespawn(actor_id); - - if handle.send(msg).is_err() { - to_remove.push(id); - } - } - } ToServer::ActorMoved(from_id, actor_id, position, rotation) => { if let Some(instance) = data.find_actor_instance_mut(actor_id) { if let Some((_, common)) = instance