]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
add a gamecommand "nextframe" to help automate map screenshots
authorRudolf Polzer <divverent@alientrap.org>
Sun, 15 Jan 2012 17:10:06 +0000 (18:10 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 15 Jan 2012 17:29:14 +0000 (18:29 +0100)
commands.cfg
qcsrc/client/Main.qc
qcsrc/client/View.qc
qcsrc/client/command/cl_cmd.qc
qcsrc/common/command/generic.qc
qcsrc/common/command/generic.qh
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/menu/menu.qc
qcsrc/server/sv_main.qc

index 1f7e684588770a6e8554d6c9cc4162daabfe2899..b23a1e8474575e2f3c4a11222bac087a5e16aa5f 100644 (file)
@@ -53,6 +53,7 @@ alias who                  "qc_cmd_svcmd  who                  ${* ?}" // Displa
 alias addtolist            "qc_cmd_svmenu addtolist            ${* ?}" // Add a string to a cvar
 alias dumpcommands         "qc_cmd_svmenu dumpcommands         ${* ?}" // Dump all commands on the program to *_cmd_dump.txt
 alias maplist              "qc_cmd_svmenu maplist              ${* ?}" // Automatic control of maplist
+alias nextframe            "qc_cmd_svmenu nextframe            ${* ?}" // do something next frame
 alias removefromlist       "qc_cmd_svmenu removefromlist       ${* ?}" // Remove a string from a cvar
 alias rpn                  "qc_cmd_svmenu rpn                  ${* ?}" // RPN calculator
 //alias settemp            "qc_cmd_svmenu settemp              ${* ?}" // Temporarily set a value to a cvar which is restored later
@@ -289,4 +290,4 @@ alias vdoend "vdo endmatch"
 //  rcon server commands
 // ======================
 rcon_secure 1
-set rcon_restricted_commands "restart fraglimit chmap gotomap endmatch reducematchtime extendmatchtime allready kick kickban \"sv_cmd bans\" \"sv_cmd unban *\" status \"sv_cmd teamstatus\" movetoauto movetored movetoblue movetoyellow movetopink"
\ No newline at end of file
+set rcon_restricted_commands "restart fraglimit chmap gotomap endmatch reducematchtime extendmatchtime allready kick kickban \"sv_cmd bans\" \"sv_cmd unban *\" status \"sv_cmd teamstatus\" movetoauto movetored movetoblue movetoyellow movetopink"
index 8facbf500ff9a8e2b28567b7b96bd85c88c85ebf..81c1369a0e61e45b660d73dd82130eeaf33388c7 100644 (file)
@@ -787,7 +787,8 @@ void Gamemode_Init()
 {
        if not(isdemo())
        {
-               localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
+               if(!(calledhooks & HOOK_START))
+                       localcmd("\n_cl_hook_gamestart ", MapInfo_Type_ToString(gametype), "\n");
                calledhooks |= HOOK_START;
        }
 }
index 5ab52d5f19ae51c602e624d10609e13f4067df32..afccaf45dc6ab6f217fb0503381ed1ca2a17148b 100644 (file)
@@ -372,6 +372,8 @@ void CSQC_UpdateView(float w, float h)
        vector vf_size, vf_min;
        float a;
 
+       execute_next_frame();
+
        ++framecount;
 
        hud = getstati(STAT_HUD);
index 95032dce7bd4b013ab22701cda09ebf3521486aa..638b7f996ce042c578b8dabaa6ff370a0ae4afeb 100644 (file)
@@ -524,4 +524,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
+}
index 8cf7f5aa52b5777e4533396e25f9688070714b9c..01660ba62384dfee1228f067ec704cbe84de8584 100644 (file)
@@ -208,6 +208,26 @@ void GenericCommand_maplist(float request, float argc)
        }
 }
 
+void GenericCommand_nextframe(float request, float arguments, string command)
+{
+       switch(request)
+       {
+               case CMD_REQUEST_COMMAND:
+               {
+                       queue_to_execute_next_frame(substring(command, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)));
+                       return;
+               }
+                       
+               default:
+               case CMD_REQUEST_USAGE:
+               {
+                       print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " command..."));
+                       print("  Where command will be executed next frame of this VM\n");
+                       return;
+               }
+       }
+}
+
 void GenericCommand_removefromlist(float request, float argc)
 {
        switch(request)
@@ -334,6 +354,7 @@ void GenericCommand_(float request)
        GENERIC_COMMAND("addtolist", GenericCommand_addtolist(request, arguments), "Add a string to a cvar") \
        GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \
        GENERIC_COMMAND("maplist", GenericCommand_maplist(request, arguments), "Automatic control of maplist") \
+       GENERIC_COMMAND("nextframe", GenericCommand_nextframe(request, arguments, command), "Execute the given command next frame of this VM") \
        GENERIC_COMMAND("removefromlist", GenericCommand_removefromlist(request, arguments), "Remove a string from a cvar") \
        GENERIC_COMMAND("rpn", GenericCommand_rpn(request, arguments, command), "RPN calculator") \
        GENERIC_COMMAND("settemp", GenericCommand_settemp(request, arguments), "Temporarily set a value to a cvar which is restored later") \
index 3078a0f05439af3fcad58b2ac96a808f08b6e64e..6fa7d382209bd66f10c5e12e667fb59d941ac80e 100644 (file)
@@ -14,4 +14,4 @@ string GetProgramCommandPrefix(void);
 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
 #define CMD_Write(s) fputs(fh, s)
 #define CMD_Write_Alias(execute,command,description) CMD_Write(sprintf("alias %-20s \"%-13s %-20s ${* ?}\" // %s\n", command, execute, command, description))
-void GenericCommand_macro_write_aliases(float fh);
\ No newline at end of file
+void GenericCommand_macro_write_aliases(float fh);
index 57e653113235c27ac3babe72102a286a1c249366..09a58c0997bc9a312b3cdd12307e814200562453 100644 (file)
@@ -2212,3 +2212,23 @@ float ReadApproxPastTime()
        return servertime - dt;
 }
 #endif
+
+string to_execute_next_frame;
+void execute_next_frame()
+{
+       if(to_execute_next_frame)
+       {
+               localcmd("\n", to_execute_next_frame, "\n");
+               strunzone(to_execute_next_frame);
+               to_execute_next_frame = string_null;
+       }
+}
+void queue_to_execute_next_frame(string s)
+{
+       if(to_execute_next_frame)
+       {
+               s = strcat(s, "\n", to_execute_next_frame);
+               strunzone(to_execute_next_frame);
+       }
+       to_execute_next_frame = strzone(s);
+}
index 4b0526815d65763eb11f2cbe7b51e2596a060ec4..485e190b9e47b0550a4e5cbaf3e809357f7548b8 100644 (file)
@@ -297,3 +297,7 @@ void WriteApproxPastTime(float dst, float t);
 #ifdef CSQC
 float ReadApproxPastTime();
 #endif
+
+// execute-stuff-next-frame subsystem
+void execute_next_frame();
+void queue_to_execute_next_frame(string s);
index 536295fc2f479f66dbdd08641c10a4a49330bac6..c097f99b963833366276363fffc9aebebcf8d3c5 100644 (file)
@@ -616,6 +616,8 @@ void m_draw()
        float t;
        float realFrametime;
 
+       execute_next_frame();
+
        menuMouseMode = cvar("menu_mouse_absolute");
 
        if (anim)
index 73c444afec7b8637e0481ecb18ba133d01f471a1..66579bc9c92807ef2cfc11cbf3164b47ee20c2e1 100644 (file)
@@ -151,6 +151,8 @@ float RedirectionThink();
 entity SelectSpawnPoint (float anypoint);
 void StartFrame (void)
 {
+       execute_next_frame();
+
        remove = remove_unsafely; // not during spawning!
        serverprevtime = servertime;
        servertime = time;