~ubuntu-branches/ubuntu/quantal/xshisen/quantal

« back to all changes in this revision

Viewing changes to score.C

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2011-11-24 21:40:40 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20111124214040-fv65k9t6s2co4i8k
Tags: 1:1.51-3.2
* Non-maintainer upload.
* Fix "ftbfs with gcc-4.5 and gcc-4.6": new patch 40_format_security.patch:
  Fix format string use. Based on Daniel T Chen's patch in the BTS.
  (Closes: #565064)

Show diffs side-by-side

added added

removed removed

Lines of Context:
337
337
    }
338
338
    // Always read the latest high score
339
339
    readfile();
340
 
    snprintf(format, sizeof(format)-1, "%s", res_strings[0]);
 
340
    sprintf(format, res_strings[0]);
341
341
    prev_time = -1;
342
342
    for(int i=0; i<SCORENUM; i++) {
343
343
        this_time = rec[i].hour * 3600 + rec[i].min * 60 + rec[i].sec;
372
372
    time_t t;
373
373
    struct tm *tp;
374
374
    struct passwd *pw;
375
 
    char   namebuf[142], myname[NAMELEN+1], gecos[128], *po;
376
 
 
377
 
#ifndef NO_GLOBAL_HIGHSCORE
 
375
    char   namebuf[128], myname[NAMELEN+1], gecos[128], *po;
378
376
 
379
377
    s1 = scoreToRegister / 1000;
380
378
    ms_to_hms(scoreToRegister, h, m, s);
381
379
    pw = getpwuid(getuid());
382
 
    strncpy(gecos, pw->pw_gecos, sizeof(gecos));
383
 
    gecos[sizeof(gecos) - 1] = '\0';
 
380
    strcpy(gecos, pw->pw_gecos);
384
381
    if ((po = strchr(gecos, ',')) != NULL)
385
382
        *po = 0;
386
383
    sprintf(namebuf, "%-8.8s (%s)", pw->pw_name, gecos);
427
424
    sprintf(rec[i].time, "%2.2d:%2.2d:%2.2d", tp->tm_hour, tp->tm_min, tp->tm_sec);
428
425
    if (writefile() == 0)
429
426
        DisplayScore(game);
430
 
#endif /* NO_GLOBAL_HIGHSCORE */
431
427
}
432
428
 
433
429
void
670
666
        bp += strlen(bp);
671
667
    }
672
668
    if (rcount[0]) {
673
 
        x = rtime[0] / rcount[0];
674
 
        y = (double)rlev[0] / (double)rcount[0];
675
 
        ms_to_hms(x, t1, t2, t3);
 
669
        x = rtime[0] / rcount[0];
 
670
        y = (double)rlev[0] / (double)rcount[0];
 
671
        ms_to_hms(x, t1, t2, t3);
676
672
        bp += strlen(bp);
677
673
        sprintf(bp, "    %-14.14s: %2.2d:%2.2d:%2.2d (%4.1f) %6d %s\n",
678
674
                res_strings[8], t1, t2, t3, y, rcount[0], res_strings[11]);