57 if (optarg[len-1] == 's') { |
57 if (optarg[len-1] == 's') { |
58 optarg[len-1] = '\0'; |
58 optarg[len-1] = '\0'; |
59 timeunit = 1; |
59 timeunit = 1; |
60 } |
60 } |
61 |
61 |
62 if ((time = strtoul(optarg, &valid, 10)) > TIME_MAX |
62 if ((time = strtoul(optarg, &valid, 10))*timeunit > UINT16_MAX |
63 || *valid != '\0') { |
63 || *valid != '\0') { |
64 fprintf(stderr, "Specified time is invalid (%s)\n", optarg); |
64 fprintf(stderr, "Specified time is invalid (%s)" |
|
65 "- Maximum: 65535 seconds (1092 minutes)\n", optarg); |
65 return 1; |
66 return 1; |
66 } else { |
67 } else { |
|
68 settings->gameinfo.timecontrol = 1; |
67 if (opt=='t') { |
69 if (opt=='t') { |
68 settings->gameinfo.time = timeunit * time; |
70 settings->gameinfo.time = timeunit * time; |
69 } else { |
71 } else { |
70 settings->gameinfo.addtime = time; |
72 settings->gameinfo.addtime = time; |
71 } |
73 } |
106 settings.gameinfo.servercolor = WHITE; |
108 settings.gameinfo.servercolor = WHITE; |
107 settings.port = "27015"; |
109 settings.port = "27015"; |
108 return settings; |
110 return settings; |
109 } |
111 } |
110 |
112 |
111 void dump_gameinfo(Gameinfo *gameinfo) { |
113 void dump_gameinfo(GameInfo *gameinfo) { |
112 int serverwhite = gameinfo->servercolor == WHITE; |
114 int serverwhite = gameinfo->servercolor == WHITE; |
113 attron(A_UNDERLINE); |
115 attron(A_UNDERLINE); |
114 printw("Game details\n"); |
116 printw("Game details\n"); |
115 attroff(A_UNDERLINE); |
117 attroff(A_UNDERLINE); |
116 printw(" Server: %s\n Client: %s\n", |
118 printw(" Server: %s\n Client: %s\n", |
117 serverwhite?"white":"black", serverwhite?"black":"White" |
119 serverwhite?"white":"black", serverwhite?"black":"White" |
118 ); |
120 ); |
119 if (gameinfo->time > 0) { |
121 if (gameinfo->timecontrol) { |
120 if (gameinfo->time % 60) { |
122 if (gameinfo->time % 60) { |
121 printw(" Time limit: %ds + %ds\n", |
123 printw(" Time limit: %ds + %ds\n", |
122 gameinfo->time, gameinfo->addtime); |
124 gameinfo->time, gameinfo->addtime); |
123 } else { |
125 } else { |
124 printw(" Time limit: %dm + %ds\n", |
126 printw(" Time limit: %dm + %ds\n", |