1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-30 11:47:45 +00:00

Address warnings:

warning: usage of `contains_key` followed by `insert` on a `HashMap`
warning: you seem to want to iterate on the values of a map
This commit is contained in:
The Dax 2025-06-23 14:42:20 -04:00 committed by Joshua Goins
parent 5b5e998286
commit 86310c7c22

View file

@ -93,17 +93,12 @@ impl WorldServer {
/// Finds the instance associated with a zone, or creates it if it doesn't exist yet /// Finds the instance associated with a zone, or creates it if it doesn't exist yet
fn find_instance_mut(&mut self, zone_id: u16) -> &mut Instance { fn find_instance_mut(&mut self, zone_id: u16) -> &mut Instance {
if self.instances.contains_key(&zone_id) { self.instances.entry(zone_id).or_insert(Instance::default())
self.instances.get_mut(&zone_id).unwrap()
} else {
self.instances.insert(zone_id, Instance::default());
self.instances.get_mut(&zone_id).unwrap()
}
} }
/// 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 self.instances.values_mut() {
if instance.actors.contains_key(&ObjectId(actor_id)) { if instance.actors.contains_key(&ObjectId(actor_id)) {
return Some(instance); return Some(instance);
} }