mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
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:
commit
1daa2ce3db
@ -6,7 +6,7 @@ version = "0.10.0"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
simd = ["vek/platform_intrinsics"]
|
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"]
|
default = ["simd"]
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ tar = { version = "0.4.37", optional = true }
|
|||||||
bincode = { workspace = true, optional = true }
|
bincode = { workspace = true, optional = true }
|
||||||
timer-queue = "0.1.0"
|
timer-queue = "0.1.0"
|
||||||
wasmtime = { version = "17.0.0", optional = true , features = ["component-model", "async"] }
|
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 }
|
async-trait = { workspace = true }
|
||||||
bytes = "^1"
|
bytes = "^1"
|
||||||
futures = "0.3.30"
|
futures = "0.3.30"
|
||||||
|
@ -597,14 +597,12 @@ impl ServerEvent for DestroyEvent {
|
|||||||
{
|
{
|
||||||
// Only drop loot if entity has agency (not a player),
|
// Only drop loot if entity has agency (not a player),
|
||||||
// and if it is not owned by another entity (not a pet)
|
// and if it is not owned by another entity (not a pet)
|
||||||
if !matches!(alignment, Some(Alignment::Owned(_))) {
|
if !matches!(alignment, Some(Alignment::Owned(_)))
|
||||||
let Some(items) = data
|
&& let Some(items) = data
|
||||||
.item_drops
|
.item_drops
|
||||||
.remove(ev.entity)
|
.remove(ev.entity)
|
||||||
.map(|comp::ItemDrops(item)| item)
|
.map(|comp::ItemDrops(item)| item)
|
||||||
else {
|
{
|
||||||
continue;
|
|
||||||
};
|
|
||||||
// Remove entries where zero exp was awarded - this happens because some
|
// Remove entries where zero exp was awarded - this happens because some
|
||||||
// entities like Object bodies don't give EXP.
|
// entities like Object bodies don't give EXP.
|
||||||
let mut item_receivers = HashMap::new();
|
let mut item_receivers = HashMap::new();
|
||||||
|
@ -10,9 +10,13 @@ use common::{
|
|||||||
uid::{IdMaps, Uid},
|
uid::{IdMaps, Uid},
|
||||||
};
|
};
|
||||||
use common_net::msg::ServerGeneral;
|
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(
|
pub fn can_invite(
|
||||||
clients: &ReadStorage<'_, Client>,
|
clients: &ReadStorage<'_, Client>,
|
||||||
@ -159,7 +163,7 @@ impl ServerEvent for GroupManipEvent {
|
|||||||
"Kick failed, target does not exist.",
|
"Kick failed, target does not exist.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return;
|
continue;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -172,7 +176,7 @@ impl ServerEvent for GroupManipEvent {
|
|||||||
"Kick failed, you can't kick pets.",
|
"Kick failed, you can't kick pets.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
// Can't kick yourself
|
// Can't kick yourself
|
||||||
if uids.get(entity).map_or(false, |u| *u == uid) {
|
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.",
|
"Kick failed, you can't kick yourself.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure kicker is the group leader
|
// Make sure kicker is the group leader
|
||||||
@ -264,7 +268,7 @@ impl ServerEvent for GroupManipEvent {
|
|||||||
"Leadership transfer failed, target does not exist",
|
"Leadership transfer failed, target does not exist",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return;
|
continue;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// Make sure assigner is the group leader
|
// Make sure assigner is the group leader
|
||||||
|
@ -1,11 +1,15 @@
|
|||||||
use crate::client::Client;
|
use crate::client::Client;
|
||||||
use common::event::RequestSiteInfoEvent;
|
use common::event::RequestSiteInfoEvent;
|
||||||
use common_net::msg::{world_msg::EconomyInfo, ServerGeneral};
|
use common_net::msg::{world_msg::EconomyInfo, ServerGeneral};
|
||||||
use specs::{ReadExpect, ReadStorage};
|
use specs::{DispatcherBuilder, ReadExpect, ReadStorage};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use world::IndexOwned;
|
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"))]
|
#[cfg(not(feature = "worldgen"))]
|
||||||
impl ServerEvent for RequestSiteInfoEvent {
|
impl ServerEvent for RequestSiteInfoEvent {
|
||||||
|
@ -167,7 +167,7 @@ impl ServerEvent for InventoryManipEvent {
|
|||||||
// of the world from the first pickup
|
// of the world from the first pickup
|
||||||
// attempt was processed.
|
// attempt was processed.
|
||||||
debug!("Failed to get entity for item Uid: {}", pickup_uid);
|
debug!("Failed to get entity for item Uid: {}", pickup_uid);
|
||||||
return;
|
continue;
|
||||||
};
|
};
|
||||||
let entity_cylinder = get_cylinder(entity);
|
let entity_cylinder = get_cylinder(entity);
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ impl ServerEvent for InventoryManipEvent {
|
|||||||
?entity_cylinder,
|
?entity_cylinder,
|
||||||
"Failed to pick up item as not within range, Uid: {}", pickup_uid
|
"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
|
// 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 {
|
if !ownership_check_passed {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// First, we remove the item, assuming picking it up will succeed (we do this to
|
// 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: {}",
|
"Failed to delete item component for entity, Uid: {}",
|
||||||
pickup_uid
|
pickup_uid
|
||||||
);
|
);
|
||||||
return;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: We dup the item for message purposes.
|
// 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(source_item) = inventory.get(source_inv_slot_id) {
|
||||||
if let Some(target_item) = inventory.get(target_inv_slot_id) {
|
if let Some(target_item) = inventory.get(target_inv_slot_id) {
|
||||||
if source_item != target_item {
|
if source_item != target_item {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use common::{
|
|||||||
agent::{Agent, AgentEvent},
|
agent::{Agent, AgentEvent},
|
||||||
group::GroupManager,
|
group::GroupManager,
|
||||||
invite::{Invite, InviteKind, InviteResponse, PendingInvites},
|
invite::{Invite, InviteKind, InviteResponse, PendingInvites},
|
||||||
ChatType, Group, Pos,
|
ChatType, Group, Health, Pos,
|
||||||
},
|
},
|
||||||
consts::MAX_TRADE_RANGE,
|
consts::MAX_TRADE_RANGE,
|
||||||
event::{InitiateInviteEvent, InviteResponseEvent},
|
event::{InitiateInviteEvent, InviteResponseEvent},
|
||||||
@ -48,6 +48,7 @@ impl ServerEvent for InitiateInviteEvent {
|
|||||||
ReadStorage<'a, Client>,
|
ReadStorage<'a, Client>,
|
||||||
ReadStorage<'a, Pos>,
|
ReadStorage<'a, Pos>,
|
||||||
ReadStorage<'a, Group>,
|
ReadStorage<'a, Group>,
|
||||||
|
ReadStorage<'a, Health>,
|
||||||
);
|
);
|
||||||
|
|
||||||
fn handle(
|
fn handle(
|
||||||
@ -64,6 +65,7 @@ impl ServerEvent for InitiateInviteEvent {
|
|||||||
clients,
|
clients,
|
||||||
positions,
|
positions,
|
||||||
groups,
|
groups,
|
||||||
|
healths,
|
||||||
): Self::SystemData<'_>,
|
): Self::SystemData<'_>,
|
||||||
) {
|
) {
|
||||||
for InitiateInviteEvent(inviter, invitee_uid, kind) in events {
|
for InitiateInviteEvent(inviter, invitee_uid, kind) in events {
|
||||||
@ -78,7 +80,7 @@ impl ServerEvent for InitiateInviteEvent {
|
|||||||
"Invite failed, target does not exist.",
|
"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)
|
.map_or(false, |inviter_uid| *inviter_uid == invitee_uid)
|
||||||
{
|
{
|
||||||
warn!("Entity tried to invite themselves into a group/trade");
|
warn!("Entity tried to invite themselves into a group/trade");
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(kind, InviteKind::Trade) {
|
if matches!(kind, InviteKind::Trade) {
|
||||||
// Check whether the inviter is in range of the invitee
|
// Check whether the inviter is in range of the invitee or dead
|
||||||
if !within_trading_range(positions.get(inviter), positions.get(invitee)) {
|
if !within_trading_range(positions.get(inviter), positions.get(invitee))
|
||||||
return;
|
|| 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,
|
inviter,
|
||||||
invitee,
|
invitee,
|
||||||
) {
|
) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// cancel current trades for inviter before inviting someone else to trade
|
// 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.",
|
"This player already has a pending invite.",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut invite_sent = false;
|
let mut invite_sent = false;
|
||||||
|
@ -93,6 +93,8 @@ pub fn register_event_systems(builder: &mut DispatcherBuilder) {
|
|||||||
entity_manipulation::register_event_systems(builder);
|
entity_manipulation::register_event_systems(builder);
|
||||||
interaction::register_event_systems(builder);
|
interaction::register_event_systems(builder);
|
||||||
invite::register_event_systems(builder);
|
invite::register_event_systems(builder);
|
||||||
|
group_manip::register_event_systems(builder);
|
||||||
|
information::register_event_systems(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user