From b8a8c1c175a1ad472c7a66ac3ea7a5669f20ad3c Mon Sep 17 00:00:00 2001 From: ehouse Date: Thu, 15 Jun 2006 13:05:56 +0000 Subject: [PATCH] Fix juggle so it works for 3 players too. --- xwords4/common/nwgamest.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xwords4/common/nwgamest.c b/xwords4/common/nwgamest.c index 1ec12a352..897eba7ef 100644 --- a/xwords4/common/nwgamest.c +++ b/xwords4/common/nwgamest.c @@ -229,9 +229,10 @@ randIntArray( XP_U16* rnums, XP_U16 count ) } do { - for ( i = 1; i < count; ++i ) { + for ( i = count; i > 0 ; ) { XP_U16 rIndex = ((XP_U16)XP_RANDOM()) % i; XP_U16 tmp = rnums[rIndex]; + --i; rnums[rIndex] = rnums[i]; rnums[i] = tmp; } @@ -312,8 +313,7 @@ newg_juggle( NewGameCtx* ngc ) (*ngc->getColProc)(closure, pos[0], col, deepCopy, &tmpValues[col] ); } - cur = 0; - while ( ++cur < nPlayers ) { + for ( cur = 0; ++cur < nPlayers; ) { XP_LOGF( "%s: copying player %d to player %d", __FUNCTION__, pos[cur], pos[cur-1] ); copyFromTo( ngc, pos[cur], pos[cur-1] );