From fa4def23ccab18c2f0d26a125cbb47237609c2ae Mon Sep 17 00:00:00 2001 From: flowtron Date: Sun, 17 Apr 2011 16:19:53 +0000 Subject: [PATCH] revised setfollowplayer function - shorter, faster, cleaner - thanks for the hint tempest git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6269 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index cf9ce8c1..18078158 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -1492,16 +1492,12 @@ playerent *updatefollowplayer(int shiftdirection) void setfollowplayer(int cn) { // silently ignores invalid player-cn value passed - loopv(players) if(players[i]) - { - if(player1->team != TEAM_SPECT && !watchingdemo && m_teammode && team_base(players[i]->team) != team_base(player1->team)) continue; - if(players[i]->clientnum == cn) - { - if(player1->followplayercn != players[i]->clientnum) addmsg(SV_SPECTCN, "ri", cn); - player1->followplayercn = cn; - } - } + if(players.inrange(cn)) + { + if(player1->followplayercn != players[cn]->clientnum) addmsg(SV_SPECTCN, "ri", cn); + player1->followplayercn = cn; + } } // set new spect mode