mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Denies any active trades on exit to char select.
This commit is contained in:
parent
9289feee23
commit
883977a42f
@ -60,6 +60,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Social window no longer moves when group is open
|
- Social window no longer moves when group is open
|
||||||
- Combat rating no longer takes buffs into account
|
- Combat rating no longer takes buffs into account
|
||||||
- Minimap icons are now displayed in both map modes
|
- Minimap icons are now displayed in both map modes
|
||||||
|
- Server now denies any running trades when a user exits to the character selection screen.
|
||||||
|
|
||||||
## [0.9.0] - 2021-03-20
|
## [0.9.0] - 2021-03-20
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ use inventory_manip::handle_inventory;
|
|||||||
use invite::{handle_invite, handle_invite_response};
|
use invite::{handle_invite, handle_invite_response};
|
||||||
use player::{handle_client_disconnect, handle_exit_ingame};
|
use player::{handle_client_disconnect, handle_exit_ingame};
|
||||||
use specs::{Entity as EcsEntity, WorldExt};
|
use specs::{Entity as EcsEntity, WorldExt};
|
||||||
use trade::handle_process_trade_action;
|
use trade::{cancel_trade_for, handle_process_trade_action};
|
||||||
|
|
||||||
mod entity_creation;
|
mod entity_creation;
|
||||||
mod entity_manipulation;
|
mod entity_manipulation;
|
||||||
@ -133,7 +133,10 @@ impl Server {
|
|||||||
ServerEvent::UpdateCharacterData { entity, components } => {
|
ServerEvent::UpdateCharacterData { entity, components } => {
|
||||||
handle_loaded_character_data(self, entity, components);
|
handle_loaded_character_data(self, entity, components);
|
||||||
},
|
},
|
||||||
ServerEvent::ExitIngame { entity } => handle_exit_ingame(self, entity),
|
ServerEvent::ExitIngame { entity } => {
|
||||||
|
cancel_trade_for(self, entity);
|
||||||
|
handle_exit_ingame(self, entity);
|
||||||
|
},
|
||||||
ServerEvent::CreateNpc {
|
ServerEvent::CreateNpc {
|
||||||
pos,
|
pos,
|
||||||
stats,
|
stats,
|
||||||
|
@ -156,6 +156,32 @@ pub fn handle_process_trade_action(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Cancel all trades registered for a given UID.
|
||||||
|
pub fn cancel_trade_for(server: &mut Server, entity: EcsEntity) {
|
||||||
|
if let Some(uid) = server.state().ecs().uid_from_entity(entity) {
|
||||||
|
let mut trades = server.state.ecs().write_resource::<Trades>();
|
||||||
|
|
||||||
|
let active_trade = match trades.entity_trades.get(&uid) {
|
||||||
|
Some(n) => *n,
|
||||||
|
None => {
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let to_notify = trades.decline_trade(active_trade, uid);
|
||||||
|
to_notify
|
||||||
|
.and_then(|u| server.state.ecs().entity_from_uid(u.0))
|
||||||
|
.map(|e| {
|
||||||
|
server.notify_client(e, ServerGeneral::FinishedTrade(TradeResult::Declined));
|
||||||
|
notify_agent_simple(
|
||||||
|
server.state.ecs().write_storage::<Agent>(),
|
||||||
|
e,
|
||||||
|
AgentEvent::FinishedTrade(TradeResult::Declined),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Commit a trade that both parties have agreed to, modifying their respective
|
/// Commit a trade that both parties have agreed to, modifying their respective
|
||||||
/// inventories
|
/// inventories
|
||||||
fn commit_trade(ecs: &specs::World, trade: &PendingTrade) -> TradeResult {
|
fn commit_trade(ecs: &specs::World, trade: &PendingTrade) -> TradeResult {
|
||||||
|
Loading…
Reference in New Issue
Block a user