From 3081bb8c5d9137b274b7452aff609f75b7c66a75 Mon Sep 17 00:00:00 2001 From: driAn Date: Sat, 10 May 2008 19:14:46 +0000 Subject: [PATCH] rewrote followplayer selection git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1916 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 19f581ff..72e78c80 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -828,10 +828,17 @@ playerent *findfollowplayer(int shiftdirection) playerent *f = players.inrange(player1->followplayercn) ? players[player1->followplayercn] : NULL; if(f) return f; } + vector available; loopv(players) if(players[i]) available.add(players[i]); if(!available.length()) return NULL; - player1->followplayercn = (player1->followplayercn+shiftdirection) % available.length(); + + int oldidx = available.find(players[player1->followplayercn]); + if(oldidx<0) oldidx = 0; + int idx = (oldidx+shiftdirection) % available.length(); + if(idx<0) idx += available.length(); + + player1->followplayercn = available[idx]->clientnum; return players[player1->followplayercn]; }