This is poorly designed. You are iterating a list of players on the map, having valid pointers to them, storing their guids in a temporary container, selecting one guid randomly and then after that immediately looking up the player by guid to obtain pointer. There is no problem with this method simply returning Player* because you are not storing the pointer for a later use (later means at any point in future other than current update tick)