]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Merge the sendcvar command into one. Call the old functions using hooks.
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 27 Oct 2020 14:50:19 +0000 (14:50 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 27 Oct 2020 14:50:19 +0000 (14:50 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13034 d7cf8633-e32d-0410-b094-e92efae38249

cl_cmd.c
host.c
host.h
sv_ccmds.c

index 37ecbaa40d2c87f87461a84dbf745fe8af3b2af7..4f844a821f25981c9f86d9053885871e20713f6f 100644 (file)
--- a/cl_cmd.c
+++ b/cl_cmd.c
@@ -744,8 +744,8 @@ void CL_InitCommands(void)
        Cmd_AddCommand(CF_CLIENT, "packet", CL_Packet_f, "send a packet to the specified address:port containing a text string");
        Cmd_AddCommand(CF_CLIENT, "fullinfo", CL_FullInfo_f, "allows client to modify their userinfo");
        Cmd_AddCommand(CF_CLIENT, "setinfo", CL_SetInfo_f, "modifies your userinfo");
-       Cmd_AddCommand(CF_CLIENT, "sendcvar", CL_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
        Cmd_AddCommand(CF_CLIENT, "fixtrans", Image_FixTransparentPixels_f, "change alpha-zero pixels in an image file to sensible values, and write out a new TGA (warning: SLOW)");
+       host.hook.CL_SendCvar = CL_SendCvar_f;
 
        // commands that are only sent by server to client for execution
        Cmd_AddCommand(CF_CLIENT_FROM_SERVER, "pingplreport", CL_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)");
diff --git a/host.c b/host.c
index 8cf8593d5836b0e6b9242dfe26417097cb0a3c0b..268c1467ee2ba715baa6e62c900da2ec411b353b 100644 (file)
--- a/host.c
+++ b/host.c
@@ -167,6 +167,21 @@ static void Host_Framerate_c(cvar_t *var)
                Cvar_SetValueQuick(var, 0);
 }
 
+// TODO: Find a better home for this.
+static void SendCvar_f(cmd_state_t *cmd)
+{
+       if(cmd->source == src_local && host.hook.SV_SendCvar)
+       {
+               host.hook.SV_SendCvar(cmd);
+               return;
+       }
+       if(cmd->source == src_client && host.hook.CL_SendCvar)
+       {
+               host.hook.CL_SendCvar(cmd);
+               return;
+       }
+}
+
 /*
 =======================
 Host_InitLocal
@@ -182,6 +197,7 @@ static void Host_InitLocal (void)
        Cmd_AddCommand(CF_SHARED, "version", Host_Version_f, "print engine version");
        Cmd_AddCommand(CF_SHARED, "saveconfig", Host_SaveConfig_f, "save settings to config.cfg (or a specified filename) immediately (also automatic when quitting)");
        Cmd_AddCommand(CF_SHARED, "loadconfig", Host_LoadConfig_f, "reset everything and reload configs");
+       Cmd_AddCommand(CF_SHARED, "sendcvar", SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
        Cvar_RegisterVariable (&cl_maxphysicsframesperserverframe);
        Cvar_RegisterVariable (&host_framerate);
        Cvar_RegisterCallback (&host_framerate, Host_Framerate_c);
diff --git a/host.h b/host.h
index 9def0939602ac3062f76b1f564acb33a9d6df8c5..0fcbb71427b1dd3890ee7f35eedf3901077ff476 100644 (file)
--- a/host.h
+++ b/host.h
@@ -6,6 +6,8 @@
 #include "qdefs.h"
 #include "cmd.h"
 
+struct cmd_state_s;
+
 typedef enum host_state_e
 {
        host_shutdown,
@@ -33,6 +35,8 @@ typedef struct host_s
                void (*ToggleMenu)(void);
                qbool (*CL_Intermission)(void); // Quake compatibility
                qbool (*SV_CanSave)(void); // Quake compatibility
+               void (*CL_SendCvar)(struct cmd_state_s *);
+               void (*SV_SendCvar)(struct cmd_state_s *);
        } hook;
 } host_t;
 
index 78954aa8b37e25d249c76f5eb1b059134869615a..d9e08c045008e2828b9aec013c67808dc56c28f5 100644 (file)
@@ -1633,7 +1633,7 @@ void SV_InitOperatorCommands(void)
        Cmd_AddCommand(CF_SHARED, "viewnext", SV_Viewnext_f, "change to next animation frame of viewthing entity in current level");
        Cmd_AddCommand(CF_SHARED, "viewprev", SV_Viewprev_f, "change to previous animation frame of viewthing entity in current level");
        Cmd_AddCommand(CF_SHARED, "maxplayers", SV_MaxPlayers_f, "sets limit on how many players (or bots) may be connected to the server at once");
-       Cmd_AddCommand(CF_SERVER, "sendcvar", SV_SendCvar_f, "sends the value of a cvar to the server as a sentcvar command, for use by QuakeC");
+       host.hook.SV_SendCvar = SV_SendCvar_f;
 
        // commands that do not have automatic forwarding from cmd_client, these are internal details of the network protocol and not of interest to users (if they know what they are doing they can still use a generic "cmd prespawn" or similar)
        Cmd_AddCommand(CF_SERVER_FROM_CLIENT, "prespawn", SV_PreSpawn_f, "internal use - signon 1 (client acknowledges that server information has been received)");