Get all (faction) players in zone.

Currently, im using this to get a list of all players in the map, it’s faction specific.


                Map::PlayerList const& players = me->GetMap()->GetPlayers();

                if (!players.isEmpty())

                {

                    for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)

                    {

                        if (Player* plr = itr->getSource())

                        {

                            if (plr->GetTeam() == ALLIANCE)

                                {

As you can see, it gets the list of all players, and then only continues if the player being handled is alliance.

My question is, is there a way to optimize this code to only make a list of Alliance players to begin with?

Thanks,

-Lan

No

Alright, thanks.

You might be able to simplify it by removing the if (!players.isEmpty()) block. The iteration should catch the case that the players Map::PlayerList is empty.