mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
disallow trading dead entities
This commit is contained in:
parent
8285162967
commit
e225da7a75
@ -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 {
|
||||
@ -92,8 +94,11 @@ impl ServerEvent for InitiateInviteEvent {
|
||||
}
|
||||
|
||||
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)) {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user