fix item ID inconsistencies between server and client due to shops and tekker in BB

This commit is contained in:
Martin Michelsen
2023-11-15 17:18:46 -08:00
parent 8ae6500fb5
commit 6aef245eab
7 changed files with 102 additions and 101 deletions
+8 -1
View File
@@ -2180,11 +2180,18 @@ void send_pick_up_item(shared_ptr<Client> c, uint32_t item_id, uint8_t floor) {
send_command_t(l, 0x60, 0x00, cmd);
}
void send_create_inventory_item(shared_ptr<Client> c, const ItemData& item) {
void send_create_inventory_item(shared_ptr<Client> c, const ItemData& item, bool has_newest_item_id) {
auto l = c->require_lobby();
if (c->version() != GameVersion::BB) {
throw logic_error("6xBE can only be sent to BB clients");
}
// This command consumes an item ID on the client even though it's never used,
// because the passed-in item's ID overwrites it. If the passed-in ID was just
// generated by calling l->generate_item_id, then we shouldn't waste one here,
// but if not, we should (to keep our state in sync with the client).
if (!has_newest_item_id) {
l->generate_item_id(c->lobby_client_id);
}
uint16_t client_id = c->lobby_client_id;
G_CreateInventoryItem_BB_6xBE cmd = {{0xBE, 0x07, client_id}, item, 0};
send_command_t(l, 0x60, 0x00, cmd);