Made GetSpawnOccupants more robust against invalid list queries

I hope this fixes #5588.

> Index was out of range. Must be non-negative and less than the size of the collection.