SAGA2: Fix player iterator access in player.cpp

This commit is contained in:
a/ 2021-06-19 17:47:16 +09:00 committed by Eugene Sandulenko
parent 8aca55e10b
commit 291add3cd6
No known key found for this signature in database
GPG Key ID: 014D387312D34F08

View File

@ -1112,14 +1112,18 @@ PlayerActor *LivingPlayerActorIterator::first(void) {
}
PlayerActor *LivingPlayerActorIterator::next(void) {
if (index >= playerActors)
return nullptr;
Actor *a = playerList[index].getActor();
while (a == NULL || a->isDead()) {
if (++index >= playerActors) break;
while (a == nullptr || a->isDead()) {
if (++index >= playerActors)
break;
a = playerList[index].getActor();
}
return (index < playerActors) ? &playerList[index++] : NULL;
return (index < playerActors) ? &playerList[index++] : nullptr;
}
} // end of namespace Saga2