Merge branch 'entity-delete-fix' into 'master'

Fix a few event system and death related bugs

See merge request veloren/veloren!4323
This commit is contained in:
crabman 2024-02-13 18:09:17 +00:00
commit 1daa2ce3db
7 changed files with 41 additions and 28 deletions

View File

@ -6,7 +6,7 @@ version = "0.10.0"
[features]
simd = ["vek/platform_intrinsics"]
plugins = ["common-assets/plugins", "toml", "wasmtime", "tar", "bincode", "serde"]
plugins = ["common-assets/plugins", "toml", "wasmtime", "wasmtime-wasi", "tar", "bincode", "serde"]
default = ["simd"]
@ -36,7 +36,7 @@ tar = { version = "0.4.37", optional = true }
bincode = { workspace = true, optional = true }
timer-queue = "0.1.0"
wasmtime = { version = "17.0.0", optional = true , features = ["component-model", "async"] }
wasmtime-wasi = "17.0.0"
wasmtime-wasi = { version = "17.0.0", optional = true }
async-trait = { workspace = true }
bytes = "^1"
futures = "0.3.30"

View File

@ -597,14 +597,12 @@ impl ServerEvent for DestroyEvent {
{
// Only drop loot if entity has agency (not a player),
// and if it is not owned by another entity (not a pet)
if !matches!(alignment, Some(Alignment::Owned(_))) {
let Some(items) = data
if !matches!(alignment, Some(Alignment::Owned(_)))
&& let Some(items) = data
.item_drops
.remove(ev.entity)
.map(|comp::ItemDrops(item)| item)
else {
continue;
};
{
// Remove entries where zero exp was awarded - this happens because some
// entities like Object bodies don't give EXP.
let mut item_receivers = HashMap::new();

View File

@ -10,9 +10,13 @@ use common::{
uid::{IdMaps, Uid},
};
use common_net::msg::ServerGeneral;
use specs::{world::Entity, Entities, Read, ReadStorage, Write, WriteStorage};
use specs::{world::Entity, DispatcherBuilder, Entities, Read, ReadStorage, Write, WriteStorage};
use super::ServerEvent;
use super::{event_dispatch, ServerEvent};
pub(super) fn register_event_systems(builder: &mut DispatcherBuilder) {
event_dispatch::<GroupManipEvent>(builder);
}
pub fn can_invite(
clients: &ReadStorage<'_, Client>,
@ -159,7 +163,7 @@ impl ServerEvent for GroupManipEvent {
"Kick failed, target does not exist.",
));
}
return;
continue;
},
};
@ -172,7 +176,7 @@ impl ServerEvent for GroupManipEvent {
"Kick failed, you can't kick pets.",
));
}
return;
continue;
}
// Can't kick yourself
if uids.get(entity).map_or(false, |u| *u == uid) {
@ -182,7 +186,7 @@ impl ServerEvent for GroupManipEvent {
"Kick failed, you can't kick yourself.",
));
}
return;
continue;
}
// Make sure kicker is the group leader
@ -264,7 +268,7 @@ impl ServerEvent for GroupManipEvent {
"Leadership transfer failed, target does not exist",
));
}
return;
continue;
},
};
// Make sure assigner is the group leader

View File

@ -1,11 +1,15 @@
use crate::client::Client;
use common::event::RequestSiteInfoEvent;
use common_net::msg::{world_msg::EconomyInfo, ServerGeneral};
use specs::{ReadExpect, ReadStorage};
use specs::{DispatcherBuilder, ReadExpect, ReadStorage};
use std::collections::HashMap;
use world::IndexOwned;
use super::ServerEvent;
use super::{event_dispatch, ServerEvent};
pub(super) fn register_event_systems(builder: &mut DispatcherBuilder) {
event_dispatch::<RequestSiteInfoEvent>(builder);
}
#[cfg(not(feature = "worldgen"))]
impl ServerEvent for RequestSiteInfoEvent {

View File

@ -167,7 +167,7 @@ impl ServerEvent for InventoryManipEvent {
// of the world from the first pickup
// attempt was processed.
debug!("Failed to get entity for item Uid: {}", pickup_uid);
return;
continue;
};
let entity_cylinder = get_cylinder(entity);
@ -177,7 +177,7 @@ impl ServerEvent for InventoryManipEvent {
?entity_cylinder,
"Failed to pick up item as not within range, Uid: {}", pickup_uid
);
return;
continue;
}
// If there's a loot owner for the item being picked up, then
@ -214,7 +214,7 @@ impl ServerEvent for InventoryManipEvent {
});
if !ownership_check_passed {
return;
continue;
}
// First, we remove the item, assuming picking it up will succeed (we do this to
@ -231,7 +231,7 @@ impl ServerEvent for InventoryManipEvent {
"Failed to delete item component for entity, Uid: {}",
pickup_uid
);
return;
continue;
};
// NOTE: We dup the item for message purposes.
@ -700,7 +700,7 @@ impl ServerEvent for InventoryManipEvent {
if let Some(source_item) = inventory.get(source_inv_slot_id) {
if let Some(target_item) = inventory.get(target_inv_slot_id) {
if source_item != target_item {
return;
continue;
}
}
}

View File

@ -10,7 +10,7 @@ use common::{
agent::{Agent, AgentEvent},
group::GroupManager,
invite::{Invite, InviteKind, InviteResponse, PendingInvites},
ChatType, Group, Pos,
ChatType, Group, Health, Pos,
},
consts::MAX_TRADE_RANGE,
event::{InitiateInviteEvent, InviteResponseEvent},
@ -48,6 +48,7 @@ impl ServerEvent for InitiateInviteEvent {
ReadStorage<'a, Client>,
ReadStorage<'a, Pos>,
ReadStorage<'a, Group>,
ReadStorage<'a, Health>,
);
fn handle(
@ -64,6 +65,7 @@ impl ServerEvent for InitiateInviteEvent {
clients,
positions,
groups,
healths,
): Self::SystemData<'_>,
) {
for InitiateInviteEvent(inviter, invitee_uid, kind) in events {
@ -78,7 +80,7 @@ impl ServerEvent for InitiateInviteEvent {
"Invite failed, target does not exist.",
));
}
return;
continue;
},
};
@ -88,13 +90,16 @@ impl ServerEvent for InitiateInviteEvent {
.map_or(false, |inviter_uid| *inviter_uid == invitee_uid)
{
warn!("Entity tried to invite themselves into a group/trade");
return;
continue;
}
if matches!(kind, InviteKind::Trade) {
// Check whether the inviter is in range of the invitee
if !within_trading_range(positions.get(inviter), positions.get(invitee)) {
return;
// Check whether the inviter is in range of the invitee or dead
if !within_trading_range(positions.get(inviter), positions.get(invitee))
|| healths.get(inviter).is_some_and(|h| h.is_dead)
|| healths.get(invitee).is_some_and(|h| h.is_dead)
{
continue;
}
}
@ -108,7 +113,7 @@ impl ServerEvent for InitiateInviteEvent {
inviter,
invitee,
) {
return;
continue;
}
} else {
// cancel current trades for inviter before inviting someone else to trade
@ -141,7 +146,7 @@ impl ServerEvent for InitiateInviteEvent {
"This player already has a pending invite.",
));
}
return;
continue;
}
let mut invite_sent = false;

View File

@ -93,6 +93,8 @@ pub fn register_event_systems(builder: &mut DispatcherBuilder) {
entity_manipulation::register_event_systems(builder);
interaction::register_event_systems(builder);
invite::register_event_systems(builder);
group_manip::register_event_systems(builder);
information::register_event_systems(builder);
}
pub enum Event {