From c68181e8c08d7879777ab00baa66ea435e2ccb45 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Tue, 19 Dec 2023 13:33:51 -0800 Subject: [PATCH] don't use drop command to change item visibility --- src/CommandFormats.hh | 2 +- src/ReceiveSubcommands.cc | 5 +---- src/SendCommands.cc | 20 +++++++++++++------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index c9fe3f5d..30c41f52 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -4066,7 +4066,7 @@ struct G_CreateInventoryItem_DC_6x2B { struct G_CreateInventoryItem_PC_V3_BB_6x2B : G_CreateInventoryItem_DC_6x2B { uint8_t unused1 = 0; uint8_t unknown_a2 = 0; - le_uint16_t unused2 = 0; + parray unused2 = 0; } __packed__; // 6x2C: Talk to NPC diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index b829cf32..08df5fe8 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -1216,11 +1216,8 @@ static void on_pick_up_item_generic( } if (fi->visible_to_client(z)) { send_pick_up_item_to_client(lc, client_id, item_id, floor); - } else if (lc->version() == Version::BB_V4) { - send_create_inventory_item_to_client(lc, client_id, fi->data); } else { - send_drop_item_to_channel(s, lc->channel, fi->data, false, lc->floor, lc->x, lc->z, 0xFFFF); - send_pick_up_item_to_client(lc, client_id, item_id, floor); + send_create_inventory_item_to_client(lc, client_id, fi->data); } } } diff --git a/src/SendCommands.cc b/src/SendCommands.cc index ae8a2604..7cedaa3a 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -2465,11 +2465,20 @@ void send_pick_up_item_to_client(shared_ptr c, uint8_t client_id, uint32 } void send_create_inventory_item_to_client(shared_ptr c, uint8_t client_id, const ItemData& item) { - if (c->version() != Version::BB_V4) { - throw logic_error("6xBE can only be sent to BB clients"); + if (c->version() == Version::BB_V4) { + G_CreateInventoryItem_BB_6xBE cmd = {{0xBE, 0x07, client_id}, item, 0}; + send_command_t(c, 0x60, 0x00, cmd); + } else { + G_CreateInventoryItem_PC_V3_BB_6x2B cmd; + cmd.header.subcommand = 0x2B; + cmd.header.size = sizeof(cmd) >> 2; + cmd.header.client_id = client_id; + cmd.item_data = item; + cmd.unused1 = 0; + cmd.unknown_a2 = 0; + cmd.unused2.clear(0); + send_command_t(c, 0x60, 0x00, cmd); } - G_CreateInventoryItem_BB_6xBE cmd = {{0xBE, 0x07, client_id}, item, 0}; - send_command_t(c, 0x60, 0x00, cmd); } void send_create_inventory_item_to_lobby(shared_ptr c, uint8_t client_id, const ItemData& item, bool exclude_c) { @@ -2478,9 +2487,6 @@ void send_create_inventory_item_to_lobby(shared_ptr c, uint8_t client_id if (!lc) { continue; } - if (lc->version() != Version::BB_V4) { - throw logic_error("6xBE can only be sent to BB clients"); - } if ((lc != c) || !exclude_c) { send_create_inventory_item_to_client(lc, client_id, item); }