mirror of
https://github.com/redstrate/Kawari.git
synced 2025-05-13 15:17:45 +00:00
Remove the now unused ToServer::ActorDespawned
This is handled in the much-better-named LeftZone message.
This commit is contained in:
parent
cbeaa83307
commit
0139fbc8c6
3 changed files with 2 additions and 42 deletions
|
@ -708,9 +708,9 @@ async fn client_loop(
|
||||||
if actor.hp == 0 {
|
if actor.hp == 0 {
|
||||||
tracing::info!("Despawning {} because they died!", actor.id.0);
|
tracing::info!("Despawning {} because they died!", actor.id.0);
|
||||||
// if the actor died, despawn them
|
// if the actor died, despawn them
|
||||||
connection.handle
|
/*connection.handle
|
||||||
.send(ToServer::ActorDespawned(connection.id, actor.id.0))
|
.send(ToServer::ActorDespawned(connection.id, actor.id.0))
|
||||||
.await;
|
.await;*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,6 @@ pub enum ToServer {
|
||||||
// TODO: ditto, zone id should not be here
|
// TODO: ditto, zone id should not be here
|
||||||
ActorSpawned(ClientId, u16, Actor, CommonSpawn),
|
ActorSpawned(ClientId, u16, Actor, CommonSpawn),
|
||||||
ActorMoved(ClientId, u32, Position, f32),
|
ActorMoved(ClientId, u32, Position, f32),
|
||||||
ActorDespawned(ClientId, u32),
|
|
||||||
ClientTrigger(ClientId, u32, ClientTrigger),
|
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
|
// 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),
|
ZoneLoaded(ClientId, u16),
|
||||||
|
|
|
@ -12,7 +12,6 @@ use super::{Actor, ClientHandle, ClientId, FromServer, ToServer};
|
||||||
|
|
||||||
#[derive(Default, Debug, Clone)]
|
#[derive(Default, Debug, Clone)]
|
||||||
struct Instance {
|
struct Instance {
|
||||||
zone_id: u16,
|
|
||||||
// structure temporary, of course
|
// structure temporary, of course
|
||||||
actors: HashMap<ObjectId, CommonSpawn>,
|
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.
|
/// 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> {
|
fn find_actor_instance_mut(&mut self, actor_id: u32) -> Option<&mut Instance> {
|
||||||
for (_, instance) in &mut self.instances {
|
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) => {
|
ToServer::ActorMoved(from_id, actor_id, position, rotation) => {
|
||||||
if let Some(instance) = data.find_actor_instance_mut(actor_id) {
|
if let Some(instance) = data.find_actor_instance_mut(actor_id) {
|
||||||
if let Some((_, common)) = instance
|
if let Some((_, common)) = instance
|
||||||
|
|
Loading…
Add table
Reference in a new issue