mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'ubruntu/trade-fix-part3' into 'master'
Trade fix (with hashmap awareness) See merge request veloren/veloren!2877
This commit is contained in:
commit
396604f6d8
@ -218,6 +218,18 @@ pub fn handle_invite_accept(server: &mut Server, entity: specs::Entity) {
|
|||||||
(uids.get(inviter).copied(), uids.get(entity).copied())
|
(uids.get(inviter).copied(), uids.get(entity).copied())
|
||||||
{
|
{
|
||||||
let mut trades = state.ecs().write_resource::<Trades>();
|
let mut trades = state.ecs().write_resource::<Trades>();
|
||||||
|
// check if the person that invited me has started a new trade since the
|
||||||
|
// invitation was sent
|
||||||
|
if trades.entity_trades.get(&inviter_uid).copied().is_some() {
|
||||||
|
for client in clients.get(entity).into_iter().chain(clients.get(inviter)) {
|
||||||
|
client.send_fallible(ServerGeneral::server_msg(
|
||||||
|
ChatType::Meta,
|
||||||
|
"Trade failed, inviter initiated new trade since sending trade \
|
||||||
|
request.",
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
let id = trades.begin_trade(inviter_uid, invitee_uid);
|
let id = trades.begin_trade(inviter_uid, invitee_uid);
|
||||||
let trade = trades.trades[&id].clone();
|
let trade = trades.trades[&id].clone();
|
||||||
if let Some(agent) = agents.get_mut(inviter) {
|
if let Some(agent) = agents.get_mut(inviter) {
|
||||||
|
@ -102,6 +102,7 @@ pub fn handle_process_trade_action(
|
|||||||
AgentEvent::FinishedTrade(result.clone()),
|
AgentEvent::FinishedTrade(result.clone()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
trades.entity_trades.remove_entry(party);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut entities: [Option<specs::Entity>; 2] = [None, None];
|
let mut entities: [Option<specs::Entity>; 2] = [None, None];
|
||||||
|
Loading…
Reference in New Issue
Block a user