handle inventory extension data properly

This commit is contained in:
Martin Michelsen
2023-10-07 18:17:54 -07:00
parent 9fd90ee324
commit d5cc91a9bf
15 changed files with 309 additions and 290 deletions
+5 -5
View File
@@ -257,20 +257,20 @@ uint8_t Lobby::game_event_for_lobby_event(uint8_t lobby_event) {
return lobby_event;
}
void Lobby::add_item(const PlayerInventoryItem& item, uint8_t area, float x, float z) {
auto& fi = this->item_id_to_floor_item[item.data.id];
fi.inv_item = item;
void Lobby::add_item(const ItemData& data, uint8_t area, float x, float z) {
auto& fi = this->item_id_to_floor_item[data.id];
fi.data = data;
fi.area = area;
fi.x = x;
fi.z = z;
}
PlayerInventoryItem Lobby::remove_item(uint32_t item_id) {
ItemData Lobby::remove_item(uint32_t item_id) {
auto item_it = this->item_id_to_floor_item.find(item_id);
if (item_it == this->item_id_to_floor_item.end()) {
throw out_of_range("item not present");
}
PlayerInventoryItem ret = std::move(item_it->second.inv_item);
ItemData ret = item_it->second.data;
this->item_id_to_floor_item.erase(item_it);
return ret;
}