2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-29 08:05:36 +03:00

player.h: fix ForEachItem() items iteration

This commit is contained in:
Sergey Shorokhov 2021-09-13 23:47:59 +03:00
parent b49bf798ec
commit 37e7b12ba0

View File

@ -383,10 +383,11 @@ public:
auto item = m_rgpPlayerItems[ slot ]; auto item = m_rgpPlayerItems[ slot ];
while (item) while (item)
{ {
auto next = item->m_pNext;
if (func(static_cast<T *>(item))) if (func(static_cast<T *>(item)))
return static_cast<T *>(item); return static_cast<T *>(item);
item = item->m_pNext; item = next;
} }
return nullptr; return nullptr;
} }
@ -397,10 +398,11 @@ public:
{ {
while (item) while (item)
{ {
auto next = item->m_pNext;
if (func(static_cast<T *>(item))) if (func(static_cast<T *>(item)))
return static_cast<T *>(item); return static_cast<T *>(item);
item = item->m_pNext; item = next;
} }
} }
return nullptr; return nullptr;