mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-10 09:28:06 +00:00
fix: regenerated proxy items dont need new ids and fix equip item ids (#1897)
* fix: changed item ids not reflected in equipped items * dont do it for proxy items
This commit is contained in:
@@ -324,10 +324,14 @@ Inventory::~Inventory() {
|
|||||||
void Inventory::RegenerateItemIDs() {
|
void Inventory::RegenerateItemIDs() {
|
||||||
std::map<LWOOBJID, Item*> newItems{};
|
std::map<LWOOBJID, Item*> newItems{};
|
||||||
for (auto* const item : items | std::views::values) {
|
for (auto* const item : items | std::views::values) {
|
||||||
|
if (item->GetParent() != LWOOBJID_EMPTY) continue; // temp items dont need new ids
|
||||||
|
const bool equipped = item->IsEquipped();
|
||||||
|
if (equipped) item->UnEquip();
|
||||||
const auto oldID = item->GetId();
|
const auto oldID = item->GetId();
|
||||||
const auto newID = item->GenerateID();
|
const auto newID = item->GenerateID();
|
||||||
LOG("Updating item ID from %llu to %llu", oldID, newID);
|
LOG("Updating item ID from %llu to %llu", oldID, newID);
|
||||||
newItems.insert_or_assign(newID, item);
|
newItems.insert_or_assign(newID, item);
|
||||||
|
if (equipped) item->Equip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't want to delete the item pointers, we're just moving from map to map
|
// We don't want to delete the item pointers, we're just moving from map to map
|
||||||
|
Reference in New Issue
Block a user