bank_withdraw_fix2 #44

Merged
jake merged 4 commits from bank_withdraw_fix2 into master 4 years ago
  1. 4
      src/ship/packet/handler/direct_message.rs
  2. 32
      tests/test_bank.rs

4
src/ship/packet/handler/direct_message.rs

@ -249,7 +249,7 @@ where
{
let client = clients.get_mut(&id).ok_or(ShipError::ClientNotFound(id))?;
let area_client = client_location.get_local_client(id).map_err(|err| -> ClientLocationError { err.into() })?;
let other_clients_in_area = client_location.get_client_neighbors(id).map_err(|err| -> ClientLocationError { err.into() })?;
let other_clients_in_area = client_location.get_all_clients_by_client(id).map_err(|err| -> ClientLocationError { err.into() })?;
let bank_action_pkts = match bank_interaction.action {
BANK_ACTION_DEPOSIT => {
if bank_interaction.item_id == 0xFFFFFFFF {
@ -281,7 +281,7 @@ where
vec![SendShipPacket::Message(Message::new(GameMessage::CreateItem(item_created)))]
}
},
_ => {
_ => { // TODO: error?
Vec::new()
}
};

32
tests/test_bank.rs

@ -293,8 +293,8 @@ async fn test_deposit_individual_item() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
if player_no_longer_has_item.item_id == 0x10001
&& player_no_longer_has_item.amount == 0
));
@ -356,8 +356,8 @@ async fn test_deposit_stacked_item() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
if player_no_longer_has_item.item_id == 0x10000
&& player_no_longer_has_item.amount == 3
));
@ -420,8 +420,8 @@ async fn test_deposit_partial_stacked_item() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
if player_no_longer_has_item.item_id == 0x10000
&& player_no_longer_has_item.amount == 2
));
@ -508,8 +508,8 @@ async fn test_deposit_stacked_item_with_stack_already_in_bank() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::PlayerNoLongerHasItem(player_no_longer_has_item)}))
if player_no_longer_has_item.item_id == 0x10000
&& player_no_longer_has_item.amount == 2
));
@ -1024,8 +1024,8 @@ async fn test_withdraw_individual_item() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
if create_item.item_id == 0x20000
));
@ -1088,8 +1088,8 @@ async fn test_withdraw_stacked_item() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
if create_item.item_id == 0x10002
));
@ -1151,8 +1151,8 @@ async fn test_withdraw_partial_stacked_item() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
if create_item.item_id == 0x10002
));
@ -1236,8 +1236,8 @@ async fn test_withdraw_stacked_item_with_stack_already_in_inventory() {
unknown: 0,
})))).await.unwrap().collect::<Vec<_>>();
assert!(packets.len() == 1);
assert!(matches!(&packets[0], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
assert!(packets.len() == 2);
assert!(matches!(&packets[1], (ClientId(2), SendShipPacket::Message(Message {msg: GameMessage::CreateItem(create_item)}))
if create_item.item_id == 0x10000
));

Loading…
Cancel
Save