From a9e7bc72263ac7cc673ba3660b70d575aa408b26 Mon Sep 17 00:00:00 2001 From: myT Date: Wed, 26 Sep 2018 05:28:40 +0200 Subject: [PATCH] fixed cv/callvote completion handlers getting removed at cg shutdown and never added back --- changelog.txt | 2 ++ code/client/cl_cgame.cpp | 24 ++++++++++++++++++++++++ code/client/cl_main.cpp | 17 ----------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/changelog.txt b/changelog.txt index 9211d39..ad2aca4 100644 --- a/changelog.txt +++ b/changelog.txt @@ -10,6 +10,8 @@ add: /toggle can now accept a value sequence (2 or more entries) to loop through if the cvar's current value is in the sequence and not in the last spot, the next one is used otherwise, the first value in the sequence is used +fix: /cv and /callvote auto-completion were disabled after cgame was shut down at least once + 12 Feb 18 - 1.50 diff --git a/code/client/cl_cgame.cpp b/code/client/cl_cgame.cpp index 8d53ece..be88f42 100644 --- a/code/client/cl_cgame.cpp +++ b/code/client/cl_cgame.cpp @@ -32,6 +32,27 @@ static byte* interopBufferOut; static int interopBufferOutSize; +static void CL_CallVote_f() +{ + CL_ForwardCommandToServer( Cmd_Cmd() ); +} + + +static void CL_CompleteCallVote_f( int startArg, int compArg ) +{ + if ( compArg == startArg + 2 && !Q_stricmp( Cmd_Argv( startArg + 1 ), "map" ) ) + Field_AutoCompleteCustom( startArg, compArg, &Field_AutoCompleteMapName ); +} + + +static const cmdTableItem_t cl_cmds[] = +{ + // we use these until we get proper handling on the mod side + { "cv", CL_CallVote_f, CL_CompleteCallVote_f, "calls a vote" }, + { "callvote", CL_CallVote_f, CL_CompleteCallVote_f, "calls a vote" } +}; + + static void CL_GetGameState( gameState_t* gs ) { *gs = cl.gameState; @@ -285,6 +306,7 @@ void CL_ShutdownCGame() cls.cgameStarted = qfalse; cls.cgameForwardInput = 0; CL_MapDownload_Cancel(); + Cmd_UnregisterArray( cl_cmds ); if ( !cgvm ) { return; } @@ -652,6 +674,8 @@ void CL_InitCGame() } cls.state = CA_LOADING; + Cmd_RegisterArray( cl_cmds, MODULE_CLIENT ); + // init for this gamestate // use the lastExecutedServerCommand instead of the serverCommandSequence // otherwise server commands sent just before a gamestate are dropped diff --git a/code/client/cl_main.cpp b/code/client/cl_main.cpp index 6a03a89..e21c4dc 100644 --- a/code/client/cl_main.cpp +++ b/code/client/cl_main.cpp @@ -1908,19 +1908,6 @@ qbool CL_CDKeyValidate( const char *key, const char *checksum ) } -static void CL_CallVote_f() -{ - CL_ForwardCommandToServer( Cmd_Cmd() ); -} - - -static void CL_CompleteCallVote_f( int startArg, int compArg ) -{ - if ( compArg == startArg + 2 && !Q_stricmp( Cmd_Argv( startArg + 1 ), "map" ) ) - Field_AutoCompleteCustom( startArg, compArg, &Field_AutoCompleteMapName ); -} - - static void CL_PrintDownloadPakUsage() { Com_Printf( "Usage: %s checksum (signed decimal, '0x' or '0X' prefix for hex)\n", Cmd_Argv(0) ); @@ -2056,10 +2043,6 @@ static const cmdTableItem_t cl_cmds[] = { "dlmap", CL_DownloadMap_f, NULL, "starts a pk3 download by map name if not existing" }, { "dlmapf", CL_ForceDownloadMap_f, NULL, "start a pk3 download by map name" }, { "dlstop", CL_CancelDownload_f, NULL, "stops the current pk3 download" }, - - // we use these until we get proper handling on the mod side - { "cv", CL_CallVote_f, CL_CompleteCallVote_f, "calls a vote" }, - { "callvote", CL_CallVote_f, CL_CompleteCallVote_f, "calls a vote" } };