uking/ui: Clean up PauseMenuDataMgr::getItemByIndex

Deduplicate the nullptr checks.
This commit is contained in:
Léo Lam 2021-01-21 18:17:37 +01:00
parent 620eb2b39e
commit 3e31611d2a
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
1 changed files with 4 additions and 17 deletions

View File

@ -2138,13 +2138,9 @@ const PouchItem* PauseMenuDataMgr::getItemByIndex(PouchItemType type, int index)
switch (type) { switch (type) {
case PouchItemType::Sword: case PouchItemType::Sword:
item = getItemHead(PouchCategory::Sword); item = getItemHead(PouchCategory::Sword);
if (!item)
return nullptr;
break; break;
case PouchItemType::Bow: case PouchItemType::Bow:
item = getItemHead(PouchCategory::Bow); item = getItemHead(PouchCategory::Bow);
if (!item)
return nullptr;
break; break;
case PouchItemType::Arrow: case PouchItemType::Arrow:
for (auto* item_ = getItemHead(PouchCategory::Bow); for (auto* item_ = getItemHead(PouchCategory::Bow);
@ -2154,40 +2150,31 @@ const PouchItem* PauseMenuDataMgr::getItemByIndex(PouchItemType type, int index)
break; break;
} }
} }
if (!item)
return nullptr;
break; break;
case PouchItemType::Shield: case PouchItemType::Shield:
item = getItemHead(PouchCategory::Shield); item = getItemHead(PouchCategory::Shield);
if (!item)
return nullptr;
break; break;
case PouchItemType::ArmorHead: case PouchItemType::ArmorHead:
case PouchItemType::ArmorUpper: case PouchItemType::ArmorUpper:
case PouchItemType::ArmorLower: case PouchItemType::ArmorLower:
item = getItemHead(PouchCategory::Armor); item = getItemHead(PouchCategory::Armor);
if (!item)
return nullptr;
break; break;
case PouchItemType::Material: case PouchItemType::Material:
item = getItemHead(PouchCategory::Material); item = getItemHead(PouchCategory::Material);
if (!item)
return nullptr;
break; break;
case PouchItemType::Food: case PouchItemType::Food:
item = getItemHead(PouchCategory::Food); item = getItemHead(PouchCategory::Food);
if (!item)
return nullptr;
break; break;
case PouchItemType::KeyItem: case PouchItemType::KeyItem:
item = getItemHead(PouchCategory::KeyItem); item = getItemHead(PouchCategory::KeyItem);
if (!item)
return nullptr;
break; break;
case PouchItemType::Invalid: case PouchItemType::Invalid:
return nullptr; break;
} }
if (!item)
return nullptr;
for (int i = 0; i < index; ++i) { for (int i = 0; i < index; ++i) {
if (!item) if (!item)
return nullptr; return nullptr;