]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
change menu_cmd isdemo
authordrjaska <drjaska83@gmail.com>
Fri, 22 Dec 2023 17:12:29 +0000 (19:12 +0200)
committerdrjaska <drjaska83@gmail.com>
Fri, 22 Dec 2023 17:15:37 +0000 (19:15 +0200)
Now it requires a cvar intake for value to be saved into a cvar,
otherwise it prints it.

qcsrc/menu/command/menu_cmd.qc

index b6f471fbfc373ab41f14c995979179a377b666e3..9c1b9d0c6f7280a0e2deed526302f3bb204d8902 100644 (file)
@@ -55,7 +55,7 @@ void GameCommand(string theCommand)
                LOG_HELP("   if <item> is not specified it shows the list of available items in the console");
                LOG_HELP("  'dumptree' dumps the state of the menu as a tree to the console");
                LOG_HELP("  'isdemo' checks if engine is currently running a demo. If given an <item> then 1 / 0 is placed");
-               LOG_HELP("   in a cvar with that name. Otherwise _menu_isdemo cvar is written to.");
+               LOG_HELP("   in the cvar with that name. Otherwise without an argument the result is printed to console.");
 
                LOG_HELP("\nGeneric commands shared by all programs:");
                GenericCommand_macro_help();
@@ -205,20 +205,17 @@ void GameCommand(string theCommand)
 
        if (argv(0) == "isdemo")
        {
-               if (isdemo())
+               int value = isdemo();
+
+               if (argv(1) != "")
                {
-                       if (argv(1) != "")
-                               cvar_set(argv(1), "1");
-                       else
-                               localcmd("\nset _menu_isdemo 1\n");
+                       cvar_set(argv(1), ftos(value));
                }
                else
                {
-                       if (argv(1) != "")
-                               cvar_set(argv(1), "0");
-                       else
-                               localcmd("\nset _menu_isdemo 0\n");
+                       print(sprintf("%d\n", value));
                }
+
                return;
        }