Patches #1189

Merge in xonotic/xonotic-data.pk3dir.git: terencehill/cmd_fixes

Added by git-manager over 2 years ago. Updated over 1 year ago.

Status:ResolvedStart date:04/28/2012
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:-

Description

Purpose of the branch:

It fixes some commands, see branch log

Repository: xonotic/xonotic-data.pk3dir.git
Commit: 3618a0f2000f064d6f59b99c7b79d7a3c25f77b9
Branch: terencehill/cmd_fixes

Merge commands:

cd data/xonotic-data.pk3dir
git checkout master
git reset --hard origin/master
git pull && git diff '3618a0f2000f064d6f59b99c7b79d7a3c25f77b9'..'origin/terencehill/cmd_fixes'

# please check that the diff you just saw did not contain anything complex that
# needs a new merge request, and review these changes

git merge --no-ff 'origin/terencehill/cmd_fixes'

# please make sure this merge worked, and if not, fix merge conflicts and git
# commit BEFORE the next command
#
# also, THIS is the point to do final pre-merge testing
#
# use git reset --hard origin/master to bail out

git push && git push --delete origin 'terencehill/cmd_fixes'

Diffstat:

 _hud_common.cfg                 |    6 +++---
 qcsrc/client/command/cl_cmd.qc  |    5 ++++-
 qcsrc/client/scoreboard.qc      |   10 +++++-----
 qcsrc/common/command/generic.qc |   14 ++++++++------
 qcsrc/common/util.qc            |   28 ++++++++++++++++++++--------
 qcsrc/menu/command/menu_cmd.qc  |    5 ++++-
 qcsrc/server/command/sv_cmd.qc  |    3 ++-
 qcsrc/server/g_world.qc         |    4 +++-
 8 files changed, 49 insertions(+), 26 deletions(-)

Revision log:

commit 3618a0f2000f064d6f59b99c7b79d7a3c25f77b9
Merge: a709836 a4ccbd7
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Merge branch 'master' into terencehill/cmd_fixes

    Conflicts:
        qcsrc/common/util.qc

commit a70983634480bcf28eb61077253af85cb5fa6165
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix "sv_cmd settemp mycvar" wrongly warning "Already had a tracker for mycvar ..." when the tracker cannot be created (e.g. nonexistent cvar)

commit 77a2ed27aa0be22848ec3abbe0f7068c838044cb
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix cvar_settemp_restore not counting the number of restored cvars

commit 43bb6b7fd1b328e8652d1023082d90860add8b8a
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Error out if a cvar doesn't exist in cvar_settemp_restore and in cvar_settemp avoiding to spawn a new entity with meaningless info

commit 40e42dd592f93be737afa0f2b314610c03749fbf
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Add missing \n in some usage messages

commit 1d7e49d061ce2904d1896d5460452af4f7e1f0b0
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix "sv_cmd records" printing an empty line for every missing record, up to 10

commit 5126e5dd224f98bf243d9ebcab25a8424bc97244
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    sv_cmd warp [level] not sv_cmd level

commit 1d6cf29a215a8d11e44b41e7be7a3ab58b855f82
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix cl_cmd hud scoreboard_columns_set deafult and all ignoring the first field in the presets default and all, actually hiding the ping column. Basically this together with the previous commit fixes the missing ping column already fixed by Samual (commit c4dc7659) but the right way

commit 41f0628654eb23b5e13360dd556e0bfc4a103147
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix command cl_cmd hud scoreboard_columns_set <fields> showing the error "unknown score field: 'scoreboard_columns_set'" 

commit 5643f670aaa1cef52ee8b46d7756c5dfeba3dd4f
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix hud_panel_radar_maximized aliases not working for 2 reasons: the aliases call inexistent (outdated) commands, and the code to set hud_panel_radar_maximized doesn't work as expected (FTEQCC bug? when argv(2) is true hud_panel_radar_maximized doesn't change)

commit 0e4a456da000d70542eee0fea5d59cbafbcb1a4b
Author: terencehill <piuntn@gmail.com>
Commit: terencehill <piuntn@gmail.com>

    Fix menu_cmd help not listing the shared commands (message is not translatable on purpose as the same message is not translatable in cl_cmd.qc too)

User agreed to the GPLv2+.

Diff:

diff --git a/_hud_common.cfg b/_hud_common.cfg
index f246ab7..5179bb2 100644
--- a/_hud_common.cfg
+++ b/_hud_common.cfg
@@ -28,9 +28,9 @@ seta hud_panel_engineinfo_framecounter_exponentialmovingaverage_instantupdate_ch

 // hud panel aliases
 alias hud_panel_radar_rotate "toggle hud_panel_radar_rotation 0 1 2 3 4" 
-alias +hud_panel_radar_maximized "cl_cmd hud_panel_radar_maximized 1" 
-alias -hud_panel_radar_maximized "cl_cmd hud_panel_radar_maximized 0" 
-alias hud_panel_radar_maximized "cl_cmd hud_panel_radar_maximized" 
+alias +hud_panel_radar_maximized "cl_cmd hud radar 1" 
+alias -hud_panel_radar_maximized "cl_cmd hud radar 0" 
+alias hud_panel_radar_maximized "cl_cmd hud radar" 

 // other hud cvars
 seta hud_showbinds 1    "what to show in the HUD to indicate certain keys to press: 0 display commands, 1 bound keys, 2 both" 
diff --git a/qcsrc/client/command/cl_cmd.qc b/qcsrc/client/command/cl_cmd.qc
index 638b7f9..f4f0dbd 100644
--- a/qcsrc/client/command/cl_cmd.qc
+++ b/qcsrc/client/command/cl_cmd.qc
@@ -175,7 +175,10 @@ void LocalCommand_hud(float request, float argc)

                 case "radar":
                 {
-                    hud_panel_radar_maximized = (argv(2) ? InterpretBoolean(argv(2)) : !hud_panel_radar_maximized);
+                    if(argv(2))
+                        hud_panel_radar_maximized = InterpretBoolean(argv(2));
+                    else
+                        hud_panel_radar_maximized = !hud_panel_radar_maximized;
                     return;
                 }
             }
diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc
index 935a027..4aaefb0 100644
--- a/qcsrc/client/scoreboard.qc
+++ b/qcsrc/client/scoreboard.qc
@@ -309,15 +309,15 @@ void Cmd_HUD_SetFields(float argc)

     // TODO: re enable with gametype dependant cvars?
     if(argc < 3) // no arguments provided
-        argc = tokenizebyseparator(strcat("x ", autocvar_scoreboard_columns), " ");
+        argc = tokenizebyseparator(strcat("0 1 ", autocvar_scoreboard_columns), " ");

     if(argc < 3)
-        argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
+        argc = tokenizebyseparator(strcat("0 1 ", HUD_DefaultColumnLayout()), " ");

     if(argc == 3)
     {
         if(argv(2) == "default")
-            argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
+            argc = tokenizebyseparator(strcat("0 1 ", HUD_DefaultColumnLayout()), " ");
         else if(argv(2) == "all")
         {
             string s;
@@ -332,7 +332,7 @@ void Cmd_HUD_SetFields(float argc)
             if(ps_secondary != ps_primary)
                 s = strcat(s, " ", scores_label[ps_secondary]);
             s = strcat(s, " ", scores_label[ps_primary]);
-            argc = tokenizebyseparator(strcat("x ", s), " ");
+            argc = tokenizebyseparator(strcat("0 1 ", s), " ");
         }
     }

@@ -341,7 +341,7 @@ void Cmd_HUD_SetFields(float argc)

     hud_fontsize = HUD_GetFontsize("hud_fontsize");    

-    for(i = 0; i < argc - 1; ++i)
+    for(i = 1; i < argc - 1; ++i)
     {
         float nocomplain;
         str = argv(i+1);
diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc
index b7b8da0..07998d0 100644
--- a/qcsrc/common/command/generic.qc
+++ b/qcsrc/common/command/generic.qc
@@ -84,7 +84,7 @@ void GenericCommand_addtolist(float request, float argc)
             print("Incorrect parameters for ^2addtolist^7\n");
         case CMD_REQUEST_USAGE:
         {
-            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " addtolist variable value"));
+            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " addtolist variable value\n"));
             print("  Where 'variable' is what to add 'value' to.\n");
             print("See also: ^2removefromlist^7\n");
             return;
@@ -307,7 +307,7 @@ void GenericCommand_maplist(float request, float argc)
             print("Incorrect parameters for ^2maplist^7\n");
         case CMD_REQUEST_USAGE:
         {
-            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " maplist action [map]"));
+            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " maplist action [map]\n"));
             print("  Where 'action' is the command to complete,\n");
             print("  and 'map' is what it acts upon (if required).\n");
             print("  Full list of commands here: \"add, cleanup, remove, shuffle.\"\n");
@@ -329,7 +329,7 @@ void GenericCommand_nextframe(float request, float arguments, string command)
         default:
         case CMD_REQUEST_USAGE:
         {
-            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " nextframe command..."));
+            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " nextframe command...\n"));
             print("  Where command will be executed next frame of this VM\n");
             return;
         }
@@ -367,7 +367,7 @@ void GenericCommand_removefromlist(float request, float argc)
             print("Incorrect parameters for ^2removefromlist^7\n");
         case CMD_REQUEST_USAGE:
         {
-            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " removefromlist variable value"));
+            print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " removefromlist variable value\n"));
             print("  Where 'variable' is what cvar to remove 'value' from.\n");
             print("See also: ^2addtolist^7\n");
             return;
@@ -383,10 +383,12 @@ void GenericCommand_settemp(float request, float argc)
         {
             if(argc >= 3)
             {
-                if(cvar_settemp(argv(1), argv(2)))
+                float f = cvar_settemp(argv(1), argv(2));
+                if(f == 1)
                     dprint("Creating new settemp tracker for ", argv(1), " and setting it to \"", argv(2), "\" temporarily.\n"); 
-                else
+                else if(f == -1)
                     dprint("Already had a tracker for ", argv(1), ", updating it to \"", argv(2), "\".\n");
+                // else cvar_settemp itself errors out

                 return;
             }
diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc
index a1e0595..020cfd7 100644
--- a/qcsrc/common/util.qc
+++ b/qcsrc/common/util.qc
@@ -860,27 +860,33 @@ float cvar_settemp(string tmp_cvar, string tmp_value)
     float created_saved_value;
     entity e;

-    created_saved_value = FALSE;
+    created_saved_value = 0;

     if not(tmp_cvar || tmp_value)
     {
         dprint("Error: Invalid usage of cvar_settemp(string, string); !\n");
-        return FALSE;
+        return 0;
+    }
+
+    if(!cvar_type(tmp_cvar))
+    {
+        print(sprintf("Error: cvar %s doesn't exist!\n", tmp_cvar));
+        return 0;
     }

     for(e = world; (e = find(e, classname, "saved_cvar_value")); )
         if(e.netname == tmp_cvar)
-            goto saved; // skip creation
+            created_saved_value = -1; // skip creation

+    if(created_saved_value != -1)
+    {
     // creating a new entity to keep track of this cvar
     e = spawn();
     e.classname = "saved_cvar_value";
     e.netname = strzone(tmp_cvar);
     e.message = strzone(cvar_string(tmp_cvar));
-    created_saved_value = TRUE;
-    
-    // an entity for this cvar already exists
-    :saved
+        created_saved_value = 1;
+    }

     // update the cvar to the value given
     cvar_set(tmp_cvar, tmp_value);
@@ -892,10 +898,16 @@ float cvar_settemp_restore()
 {
     float i;
     entity e;
-    while((e = find(world, classname, "saved_cvar_value")))
+    while((e = find(e, classname, "saved_cvar_value")))
+    {
+        if(cvar_type(e.netname))
     {
         cvar_set(e.netname, e.message);
         remove(e);
+            ++i;
+        }
+        else
+            print(sprintf("Error: cvar %s doesn't exist anymore! It can still be restored once it's manually recreated.\n", e.netname));
     }

     return i;
diff --git a/qcsrc/menu/command/menu_cmd.qc b/qcsrc/menu/command/menu_cmd.qc
index f631293..9d99c5c 100644
--- a/qcsrc/menu/command/menu_cmd.qc
+++ b/qcsrc/menu/command/menu_cmd.qc
@@ -35,7 +35,10 @@ void GameCommand(string theCommand)
         print(_("Usage: menu_cmd command..., where possible commands are:\n"));
         print(_("  sync - reloads all cvars on the current menu page\n"));
         print(_("  directmenu ITEM - select a menu item as main item\n"));
-        GenericCommand("help");
+
+        print("\nGeneric commands shared by all programs:\n");
+        GenericCommand_macro_help();
+
         return;
     }

diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc
index 10f725f..6703afc 100644
--- a/qcsrc/server/command/sv_cmd.qc
+++ b/qcsrc/server/command/sv_cmd.qc
@@ -1617,8 +1617,9 @@ void GameCommand_warp(float request, float argc)
         default:
         case CMD_REQUEST_USAGE:
         {
-            print("\nUsage:^3 sv_cmd level\n");
+            print("\nUsage:^3 sv_cmd warp [level]\n");
             print("  'level' is the level to change campaign mode to.\n");
+            print("  if 'level' is not provided it will change to the next level.\n");
             return;
         }
     }
diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc
index f2ce297..b3aff84 100644
--- a/qcsrc/server/g_world.qc
+++ b/qcsrc/server/g_world.qc
@@ -867,7 +867,9 @@ void spawnfunc_worldspawn (void)

     for(i = 0; i < 10; ++i)
     {
-        records_reply[i] = strzone(getrecords(i));
+        s = getrecords(i);
+        if (s)
+            records_reply[i] = strzone(s);
     }

     ladder_reply = strzone(getladder());

History

#1 Updated by terencehill almost 2 years ago

Samual, will you review these bug fixes, one day? You worked a lot on commands, I thought you were interested....

#2 Updated by Samual over 1 year ago

  • Status changed from New to Resolved

Also available in: Atom PDF