From 6cb353a41683ed32ce88dca6ee1ca4fcdaff21ff Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Sat, 10 Dec 2022 08:35:21 +0300 Subject: [PATCH] Consolidate client GTV commands into single command. --- src/client/gtv.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/client/gtv.c b/src/client/gtv.c index 32f9c88f2..75e347b13 100644 --- a/src/client/gtv.c +++ b/src/client/gtv.c @@ -569,11 +569,37 @@ static void CL_GTV_Status_f(void) NET_AdrToString(&cls.gtv.stream.address), cls.gtv.state); } +static void CL_GTV_Cmd_g(genctx_t *ctx, int argnum) +{ + if (argnum == 1) { + Prompt_AddMatch(ctx, "start"); + Prompt_AddMatch(ctx, "stop"); + Prompt_AddMatch(ctx, "status"); + } +} + +static void CL_GTV_Cmd_f(void) +{ + const char *cmd = Cmd_Argv(1); + + if (!strcmp(cmd, "start")) + CL_GTV_Start_f(); + else if (!strcmp(cmd, "stop")) + CL_GTV_Stop_f(); + else if (!strcmp(cmd, "status")) + CL_GTV_Status_f(); + else + Com_Printf("Usage: %s \n", Cmd_Argv(0)); +} + +static const cmdreg_t c_gtv[] = { + { "gtv", CL_GTV_Cmd_f, CL_GTV_Cmd_g }, + { NULL } +}; + void CL_GTV_Init(void) { - Cmd_AddCommand("client_gtv_start", CL_GTV_Start_f); - Cmd_AddCommand("client_gtv_stop", CL_GTV_Stop_f); - Cmd_AddCommand("client_gtv_status", CL_GTV_Status_f); + Cmd_Register(c_gtv); } void CL_GTV_Shutdown(void)