src/main.c

changeset 26
e0a76ee1bb2b
parent 23
824c9522ce66
child 29
c6a1ad6cf749
     1.1 --- a/src/main.c	Tue Apr 01 12:30:25 2014 +0200
     1.2 +++ b/src/main.c	Tue Apr 01 14:04:00 2014 +0200
     1.3 @@ -40,7 +40,7 @@
     1.4      uint8_t timeunit = 60;
     1.5      size_t len;
     1.6      
     1.7 -    for (char opt ; (opt = getopt(argc, argv, "a:bhp:rt:")) != -1 ;) {
     1.8 +    for (char opt ; (opt = getopt(argc, argv, "a:bhp:rst:")) != -1 ;) {
     1.9          switch (opt) {
    1.10          case 'b':
    1.11              settings->gameinfo.servercolor = BLACK;
    1.12 @@ -48,6 +48,9 @@
    1.13          case 'r':
    1.14              settings->gameinfo.servercolor = rand() & 1 ? WHITE : BLACK;
    1.15              break;
    1.16 +        case 's':
    1.17 +            settings->singlemachine = 1;
    1.18 +            break;
    1.19          case 't':
    1.20          case 'a':
    1.21              len = strlen(optarg);
    1.22 @@ -150,10 +153,9 @@
    1.23              "  -a <time>     Specifies the time to add after each move\n"
    1.24              "  -b            Server plays black pieces (default: white)\n"
    1.25              "  -r            Distribute color randomly\n"
    1.26 +            "  -s            Single machine mode\n"
    1.27              "  -t <time>     Specifies time limit (default: no limit)\n"
    1.28              "\nNotes\n"
    1.29 -            "White pieces are displayed as uppercase and black pieces as "
    1.30 -            "lowercase letters.\n"
    1.31              "The time unit for -a is seconds and for -t minutes by default. To "
    1.32              "specify\nseconds for the -t option, use the s suffix.\n"
    1.33              "Example: -t 150s\n"
    1.34 @@ -173,6 +175,11 @@
    1.35      }
    1.36      atexit(leavescr);
    1.37      
    1.38 -    return is_server(&settings) ? server_run(&settings) : client_run(&settings);
    1.39 +    if (settings.singlemachine) {
    1.40 +        game_start_singlemachine(&settings);
    1.41 +    } else {
    1.42 +        return is_server(&settings) ?
    1.43 +            server_run(&settings) : client_run(&settings);
    1.44 +    }
    1.45  }
    1.46  

mercurial