From da2267c723308d34b0a3525e577a89f0c0c31d3f Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 11 May 2021 00:44:01 +0000 Subject: [PATCH 1/4] tell neighbours we are banking --- src/ship/packet/handler/direct_message.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ship/packet/handler/direct_message.rs b/src/ship/packet/handler/direct_message.rs index f66fca6..9c32a84 100644 --- a/src/ship/packet/handler/direct_message.rs +++ b/src/ship/packet/handler/direct_message.rs @@ -249,7 +249,8 @@ 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_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 { From 32326a91f876cac92aea48f96499b4b9905d2bd7 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 11 May 2021 01:50:36 +0000 Subject: [PATCH 2/4] fix asserts in bank tests --- tests/test_bank.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/test_bank.rs b/tests/test_bank.rs index 2c1be0e..c0a1d64 100644 --- a/tests/test_bank.rs +++ b/tests/test_bank.rs @@ -293,8 +293,8 @@ async fn test_deposit_individual_item() { unknown: 0, })))).await.unwrap().collect::>(); - 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::>(); - 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::>(); - 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::>(); - 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::>(); - 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::>(); - 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::>(); - 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::>(); - 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 )); From a65afc4123124b89efd2e57c948e924d673da8f0 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 13 May 2021 02:15:17 +0000 Subject: [PATCH 3/4] todo error? --- src/ship/packet/handler/direct_message.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ship/packet/handler/direct_message.rs b/src/ship/packet/handler/direct_message.rs index 9c32a84..148cf0c 100644 --- a/src/ship/packet/handler/direct_message.rs +++ b/src/ship/packet/handler/direct_message.rs @@ -282,7 +282,7 @@ where vec![SendShipPacket::Message(Message::new(GameMessage::CreateItem(item_created)))] } }, - _ => { + _ => { // TODO: error? Vec::new() } }; From 89ae918a2f5185c7f991c133a9bd81db675ec217 Mon Sep 17 00:00:00 2001 From: andy Date: Sun, 20 Jun 2021 19:10:14 +0000 Subject: [PATCH 4/4] remove unused line --- src/ship/packet/handler/direct_message.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ship/packet/handler/direct_message.rs b/src/ship/packet/handler/direct_message.rs index 148cf0c..b2cb864 100644 --- a/src/ship/packet/handler/direct_message.rs +++ b/src/ship/packet/handler/direct_message.rs @@ -249,7 +249,6 @@ 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 => {