]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/command/cl_cmd.qc
Merge branch 'master' into Mario/monsters
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / command / cl_cmd.qc
index f16de6ea3ccb06147d175a596cdac354b2a9d505..acac8b3121574d22a2ec706a9f78849b5a404712 100644 (file)
@@ -57,6 +57,45 @@ void LocalCommand_blurtest(float request)
        #endif
 }
 
+void LocalCommand_create_scrshot_ent(float request)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       float fh;
+                       string filename = strcat(MapInfo_Map_bspname, "_scrshot_ent.txt");
+                       fh = fopen(filename, FILE_WRITE);
+                       
+                       if(fh >= 0)
+                       {
+                               fputs(fh, "{\n");
+                               fputs(fh, strcat("\"classname\" \"info_autoscreenshot\"\n"));
+                               fputs(fh, strcat("\"origin\" \"", strcat(ftos(view_origin_x), " ", ftos(view_origin_y), " ", ftos(view_origin_z)), "\"\n"));
+                               fputs(fh, strcat("\"angles\" \"", strcat(ftos(view_angles_x), " ", ftos(view_angles_y), " ", ftos(view_angles_z)), "\"\n"));
+                               fputs(fh, "}\n");
+                               
+                               print("Completed screenshot entity dump in ^2data/data/", MapInfo_Map_bspname, "_scrshot_ent.txt^7.\n");
+                               
+                               fclose(fh);
+                       }
+                       else
+                       {
+                               print("^1Error: ^7Could not dump to file!\n");
+                       }
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print("\nUsage:^3 cl_cmd create_scrshot_ent\n");
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
 void LocalCommand_debugmodel(float request, float argc)
 {
        switch(request)
@@ -175,7 +214,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;
                                }
                        }
@@ -226,11 +268,15 @@ void LocalCommand_mv_download(float request, float argc)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       Cmd_MapVote_MapDownload(argc);
-                       return; 
+                       if(argv(1))
+                       {
+                               Cmd_MapVote_MapDownload(argc);
+                               return; 
+                       }
                }
                        
                default:
+                       print("Incorrect parameters for ^2mv_download^7\n");
                case CMD_REQUEST_USAGE:
                {
                        print("\nUsage:^3 cl_cmd mv_download mapid\n");
@@ -246,21 +292,25 @@ void LocalCommand_sendcvar(float request, float argc)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       // W_FixWeaponOrder will trash argv, so save what we need.
-                       string thiscvar = strzone(argv(1));
-                       string s = cvar_string(thiscvar);
-                       
-                       if(thiscvar == "cl_weaponpriority")
-                               s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
-                       else if(substring(thiscvar, 0, 17) == "cl_weaponpriority" && strlen(thiscvar) == 18)
-                               s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
+                       if(argv(1))
+                       {
+                               // W_FixWeaponOrder will trash argv, so save what we need.
+                               string thiscvar = strzone(argv(1));
+                               string s = cvar_string(thiscvar);
                                
-                       localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n");
-                       strunzone(thiscvar);
-                       return; 
+                               if(thiscvar == "cl_weaponpriority")
+                                       s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 1);
+                               else if(substring(thiscvar, 0, 17) == "cl_weaponpriority" && strlen(thiscvar) == 18)
+                                       s = W_FixWeaponOrder(W_NumberWeaponOrder(s), 0);
+                                       
+                               localcmd("cmd sentcvar ", thiscvar, " \"", s, "\"\n");
+                               strunzone(thiscvar);
+                               return; 
+                       }
                }
                        
                default:
+                       print("Incorrect parameters for ^2sendcvar^7\n");
                case CMD_REQUEST_USAGE:
                {
                        print("\nUsage:^3 cl_cmd sendcvar <cvar>\n");
@@ -298,21 +348,25 @@ void LocalCommand_(float request)
 //  Macro system for client commands
 // ==================================
 
-// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
+// Normally do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
+// but for 0.5 compat, we need vyes and vno here as they were replaced... REMOVE THEM AFTER 0.6 RELEASE!!!!
 #define CLIENT_COMMANDS(request,arguments) \
        CLIENT_COMMAND("blurtest", LocalCommand_blurtest(request), "Feature for testing blur postprocessing") \
+       CLIENT_COMMAND("create_scrshot_ent", LocalCommand_create_scrshot_ent(request), "Create an entity at this location for automatic screenshots") \
        CLIENT_COMMAND("debugmodel", LocalCommand_debugmodel(request, arguments), "Spawn a debug model manually") \
        CLIENT_COMMAND("handlevote", LocalCommand_handlevote(request, arguments), "System to handle selecting a vote or option") \
        CLIENT_COMMAND("hud", LocalCommand_hud(request, arguments), "Commands regarding/controlling the HUD system") \
        CLIENT_COMMAND("localprint", LocalCommand_localprint(request, arguments), "Create your own centerprint sent to yourself") \
        CLIENT_COMMAND("mv_download", LocalCommand_mv_download(request, arguments), "Retrieve mapshot picture from the server") \
        CLIENT_COMMAND("sendcvar", LocalCommand_sendcvar(request, arguments), "Send a cvar to the server (like weaponpriority)") \
+       CLIENT_COMMAND("vyes", LocalCommand_handlevote(request, tokenize_console("handlevote yes")), "") \
+       CLIENT_COMMAND("vno", LocalCommand_handlevote(request, tokenize_console("handlevote no")), "") \
        /* nothing */
        
 void LocalCommand_macro_help()
 {
        #define CLIENT_COMMAND(name,function,description) \
-               { print("  ^2", name, "^7: ", description, "\n"); }
+               { if(strtolower(description) != "") { print("  ^2", name, "^7: ", description, "\n"); } }
                
        CLIENT_COMMANDS(0, 0)
        #undef CLIENT_COMMAND
@@ -345,7 +399,7 @@ float LocalCommand_macro_usage(float argc)
 void LocalCommand_macro_write_aliases(float fh)
 {
        #define CLIENT_COMMAND(name,function,description) \
-               { CMD_Write_Alias("cl_cmd", name, description); }
+               { if(strtolower(description) != "") { CMD_Write_Alias("qc_cmd_cl", name, description); } }
                
        CLIENT_COMMANDS(0, 0)
        #undef CLIENT_COMMAND
@@ -513,4 +567,4 @@ float CSQC_ConsoleCommand(string command)
        // Return value should be 1 if CSQC handled the command, otherwise return 0 to have the engine handle it.
 
        return FALSE;
-}
\ No newline at end of file
+}