Skip to content

Commit 37e7b12

Browse files
committed
player.h: fix ForEachItem() items iteration
1 parent b49bf79 commit 37e7b12

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

reapi/include/cssdk/dlls/player.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,11 @@ class CBasePlayer: public CBaseMonster
383383
auto item = m_rgpPlayerItems[ slot ];
384384
while (item)
385385
{
386+
auto next = item->m_pNext;
386387
if (func(static_cast<T *>(item)))
387388
return static_cast<T *>(item);
388389

389-
item = item->m_pNext;
390+
item = next;
390391
}
391392
return nullptr;
392393
}
@@ -397,10 +398,11 @@ class CBasePlayer: public CBaseMonster
397398
{
398399
while (item)
399400
{
401+
auto next = item->m_pNext;
400402
if (func(static_cast<T *>(item)))
401403
return static_cast<T *>(item);
402404

403-
item = item->m_pNext;
405+
item = next;
404406
}
405407
}
406408
return nullptr;

0 commit comments

Comments
 (0)