fixed cv/callvote completion handlers getting removed at cg shutdown and never added back

This commit is contained in:
myT 2018-09-26 05:28:40 +02:00
parent 067ae10ab5
commit a9e7bc7226
3 changed files with 26 additions and 17 deletions

View file

@ -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 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 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 12 Feb 18 - 1.50

View file

@ -32,6 +32,27 @@ static byte* interopBufferOut;
static int interopBufferOutSize; 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 ) static void CL_GetGameState( gameState_t* gs )
{ {
*gs = cl.gameState; *gs = cl.gameState;
@ -285,6 +306,7 @@ void CL_ShutdownCGame()
cls.cgameStarted = qfalse; cls.cgameStarted = qfalse;
cls.cgameForwardInput = 0; cls.cgameForwardInput = 0;
CL_MapDownload_Cancel(); CL_MapDownload_Cancel();
Cmd_UnregisterArray( cl_cmds );
if ( !cgvm ) { if ( !cgvm ) {
return; return;
} }
@ -652,6 +674,8 @@ void CL_InitCGame()
} }
cls.state = CA_LOADING; cls.state = CA_LOADING;
Cmd_RegisterArray( cl_cmds, MODULE_CLIENT );
// init for this gamestate // init for this gamestate
// use the lastExecutedServerCommand instead of the serverCommandSequence // use the lastExecutedServerCommand instead of the serverCommandSequence
// otherwise server commands sent just before a gamestate are dropped // otherwise server commands sent just before a gamestate are dropped

View file

@ -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() static void CL_PrintDownloadPakUsage()
{ {
Com_Printf( "Usage: %s checksum (signed decimal, '0x' or '0X' prefix for hex)\n", Cmd_Argv(0) ); 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" }, { "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" }, { "dlmapf", CL_ForceDownloadMap_f, NULL, "start a pk3 download by map name" },
{ "dlstop", CL_CancelDownload_f, NULL, "stops the current pk3 download" }, { "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" }
}; };