@@ -70,6 +70,7 @@ POSSIBILITY OF SUCH DAMAGE.
7070 " When no PID given, requests gamemode and pauses\n" \
7171 " -s[PID], --status=[PID] Query the status of gamemode for process\n" \
7272 " When no PID given, queries the status globally\n" \
73+ " -R, --reset If gamemode is currently running, stop it, then restart\n" \
7374 " -d, --daemonize Daemonize self after launch\n" \
7475 " -l, --log-to-syslog Log to syslog\n" \
7576 " -t, --test Run tests\n" \
@@ -158,12 +159,17 @@ int main(int argc, char *argv[])
158159
159160 /* Options struct for getopt_long */
160161 static struct option long_options [] = {
161- { "daemonize" , no_argument , 0 , 'd' }, { "log-to-syslog" , no_argument , 0 , 'l' },
162- { "request" , optional_argument , 0 , 'r' }, { "test" , no_argument , 0 , 't' },
163- { "status" , optional_argument , 0 , 's' }, { "help" , no_argument , 0 , 'h' },
164- { "version" , no_argument , 0 , 'v' }, { NULL , 0 , NULL , 0 },
162+ { "daemonize" , no_argument , 0 , 'd' },
163+ { "log-to-syslog" , no_argument , 0 , 'l' },
164+ { "request" , optional_argument , 0 , 'r' },
165+ { "test" , no_argument , 0 , 't' },
166+ { "status" , optional_argument , 0 , 's' },
167+ { "reset" , no_argument , 0 , 'R' },
168+ { "help" , no_argument , 0 , 'h' },
169+ { "version" , no_argument , 0 , 'v' },
170+ { NULL , 0 , NULL , 0 },
165171 };
166- static const char * short_options = "dls::r::tvh " ;
172+ static const char * short_options = "dls::r::tvhR " ;
167173
168174 while ((opt = getopt_long (argc , argv , short_options , long_options , 0 )) != -1 ) {
169175 switch (opt ) {
@@ -289,6 +295,20 @@ int main(int argc, char *argv[])
289295
290296 exit (EXIT_SUCCESS );
291297
298+ case 'R' :
299+ switch (gamemode_request_restart ()) {
300+ case 0 : /* success */
301+ LOG_MSG ("gamemode restart succeeded\n" );
302+ exit (EXIT_SUCCESS );
303+ case 1 : /* already off */
304+ LOG_ERROR ("gamemode was already deactivated\n" );
305+ break ;
306+ case -1 : /* error */
307+ LOG_ERROR ("gamemode_request_restart failed: %s\n" , gamemode_error_string ());
308+ break ;
309+ }
310+ exit (EXIT_FAILURE );
311+
292312 case 't' : {
293313 int status = game_mode_run_client_tests ();
294314 exit (status );
0 commit comments