game: make special storage cells reachable through GetItem

CHARACTER::IsValidItemPosition had no case for windows 8-12, so GetItem
returned NULL for every special storage cell. ClearItem never freed those
items on logout; the next login of the same character failed with
ITEM_ID_DUP and the items went missing (dangling owner pointer). The
MoveItem routing for these windows was unreachable for the same reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-24 15:30:38 +09:00
co-authored by Claude Opus 5.5
parent 3058ad6002
commit f5b8424266
+27
View File
@@ -699,6 +699,23 @@ void CHARACTER::ClearItem()
M2_DESTROY_ITEM(item);
}
}
#ifdef ENABLE_SPECIAL_STORAGE
// PORT: special storage items outlived logout (dangling owner, ITEM_ID_DUP on the next login)
for (BYTE window = UPGRADE_INVENTORY; window <= COSTUME_INVENTORY; ++window)
{
for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
{
if ((item = GetItem(TItemPos(window, i))))
{
item->SetSkipSave(true);
ITEM_MANAGER::instance().FlushDelayedSave(item);
item->RemoveFromCharacter();
M2_DESTROY_ITEM(item);
}
}
}
#endif
}
bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) const
@@ -8630,6 +8647,16 @@ bool CHARACTER::IsValidItemPosition(TItemPos Pos) const
case SWITCHBOT:
return cell < SWITCHBOT_SLOT_COUNT;
#ifdef ENABLE_SPECIAL_STORAGE
// PORT: without these GetItem() returned NULL for every special storage cell
case UPGRADE_INVENTORY:
case BOOK_INVENTORY:
case STONE_INVENTORY:
case CHANGE_INVENTORY:
case COSTUME_INVENTORY:
return cell < SPECIAL_INVENTORY_MAX_NUM;
#endif
case SAFEBOX:
if (NULL != m_pkSafebox)
return m_pkSafebox->IsValidPosition(cell);