Fixed inventory full message when pressing the pickup item key in quick succession (#651)

This commit is contained in:
Ben Wallis 2020-06-29 07:29:46 +01:00
parent 807df57f64
commit 48a23e5f4c

View File

@ -11,7 +11,7 @@ use common::{
};
use rand::Rng;
use specs::{join::Join, world::WorldExt, Builder, Entity as EcsEntity, WriteStorage};
use tracing::{debug, error, warn};
use tracing::{debug, error};
use vek::Vec3;
pub fn swap_lantern(
@ -36,7 +36,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
match manip {
comp::InventoryManip::Pickup(uid) => {
let mut picked_up_item: Option<comp::Item> = None;
let picked_up_item: Option<comp::Item>;
let item_entity = if let (Some((item, item_entity)), Some(inv)) = (
state
.ecs()
@ -68,8 +68,11 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
Some(_) => None, // Inventory was full
}
} else {
warn!("Failed to get entity/component for item Uid: {}", uid);
None
// Item entity/component could not be found - most likely because the player
// attempted to pick up the same item very quickly before its deletion of the
// world from the first pickup attempt was processed.
debug!("Failed to get entity/component for item Uid: {}", uid);
return;
};
let event = if let Some(item_entity) = item_entity {