Fixed if we do not call obtained (potential of removing item) we skip the item_deleted task because the item could not have been deleted (and there is no lua data to validate it anyway since the runitemscript failed)

This commit is contained in:
Emagi 2025-08-08 19:46:36 -04:00
parent dded41a000
commit 1c61c95f4a

View File

@ -8152,10 +8152,12 @@ bool Client::AddItem(Item* item, bool* item_deleted, AddItemType type) {
*/ */
} }
CheckPlayerQuestsItemUpdate(item); CheckPlayerQuestsItemUpdate(item);
bool skipItemDeleted = true;
if (item->GetItemScript() && lua_interface) if (item->GetItemScript() && lua_interface)
lua_interface->RunItemScript(item->GetItemScript(), "obtained", item, player); if(lua_interface->RunItemScript(item->GetItemScript(), "obtained", item, player))
skipItemDeleted = false; // we called "obtained" properly, check ptr to make sure it is valid
if(!lua_interface->IsLuaUserDataValid(item) && item_deleted) if(!skipItemDeleted && !lua_interface->IsLuaUserDataValid(item) && item_deleted)
*item_deleted = true; *item_deleted = true;
} }
else { else {