]> skyeroc.xyz Git - dgamelaunch/commitdiff
When selecting a random game to watch, try to avoid idle games and games with too...
authorPasi Kallinen <paxed@alt.org>
Sun, 9 May 2010 08:41:29 +0000 (08:41 +0000)
committerPasi Kallinen <paxed@alt.org>
Sun, 9 May 2010 08:41:29 +0000 (08:41 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@564 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

dgamelaunch.c

index 385c044c7b6813e00b739d51c4141ee32544aefa..8cb2ddd27de941f6f9b66205e655900b3b2b4530 100644 (file)
@@ -775,7 +775,14 @@ inprogressmenu (int gameid)
            break;
        case '*':
            if (len > 0) {
-               idx = random() % len;
+               int cnt = 20;
+               (void) time(&ctime);
+               do {
+                   idx = random() % len;
+               } while ((--cnt > 0) ||
+                        ((games[idx]->ws_col <= COLS) &&
+                         (games[idx]->ws_row <= LINES) &&
+                         ((ctime - games[idx]->idle_time) < 15)));
                selected = idx;
                goto watchgame;
            }