1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-05-13 07:07:45 +00:00

Remove the now unused ToServer::ActorDespawned

This is handled in the much-better-named LeftZone message.
This commit is contained in:
Joshua Goins 2025-05-09 19:30:37 -04:00
parent cbeaa83307
commit 0139fbc8c6
3 changed files with 2 additions and 42 deletions

View file

@ -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;*/
}
}
}

View file

@ -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),

View file

@ -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<ObjectId, CommonSpawn>,
}
@ -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<ToServer>) -> 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