mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Install more robust 'map' completion callback
This one will list all maps, as maps should have a vpk file to be loaded correctly due to the way rpak files are formatted internally to be loaded/parsed.
This commit is contained in:
parent
116d2acae8
commit
ddba8cf9b8
@ -11,6 +11,7 @@
|
||||
#include "tier1/cmd.h"
|
||||
#include "tier1/cvar.h"
|
||||
#include "tier1/characterset.h"
|
||||
#include "vstdlib/completion.h"
|
||||
#include "vstdlib/callback.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -393,9 +394,12 @@ void ConCommand::InitShipped(void)
|
||||
///------------------------------------------------------ [ CALLBACK SWAP ]
|
||||
//-------------------------------------------------------------------------
|
||||
// ENGINE DLL |
|
||||
ConCommand* changelevel = g_pCVar->FindCommand("changelevel");
|
||||
ConCommand* map = g_pCVar->FindCommand("map");
|
||||
ConCommand* map_background = g_pCVar->FindCommand("map_background");
|
||||
ConCommand* ss_map = g_pCVar->FindCommand("ss_map");
|
||||
ConCommand* migrateme = g_pCVar->FindCommand("migrateme");
|
||||
ConCommand* help = g_pCVar->FindCommand("help");
|
||||
ConCommand* changelevel = g_pCVar->FindCommand("changelevel");
|
||||
ConCommand* convar_list = g_pCVar->FindCommand("convar_list");
|
||||
ConCommand* convar_differences = g_pCVar->FindCommand("convar_differences");
|
||||
ConCommand* convar_findByFlags = g_pCVar->FindCommand("convar_findByFlags");
|
||||
@ -407,13 +411,16 @@ void ConCommand::InitShipped(void)
|
||||
#endif // !DEDICATED
|
||||
|
||||
help->m_fnCommandCallback = CVHelp_f;
|
||||
#ifndef CLIENT_DLL
|
||||
changelevel->m_fnCommandCallback = Host_Changelevel_f;
|
||||
#endif // !CLIENT_DLL
|
||||
convar_list->m_fnCommandCallback = CVList_f;
|
||||
convar_differences->m_fnCommandCallback = CVDiff_f;
|
||||
convar_findByFlags->m_fnCommandCallback = CVFlag_f;
|
||||
|
||||
map->m_fnCompletionCallback = Host_Map_f_CompletionFunc;
|
||||
map_background->m_fnCompletionCallback = Host_Background_f_CompletionFunc;
|
||||
ss_map->m_fnCompletionCallback = Host_SSMap_f_CompletionFunc;
|
||||
changelevel->m_fnCompletionCallback = Host_Changelevel_f_CompletionFunc;
|
||||
|
||||
/// ------------------------------------------------------ [ FLAG REMOVAL ]
|
||||
//-------------------------------------------------------------------------
|
||||
if (!CommandLine()->CheckParm("-devsdk"))
|
||||
@ -428,8 +435,6 @@ void ConCommand::InitShipped(void)
|
||||
"set",
|
||||
"ping",
|
||||
#endif // !DEDICATED
|
||||
"map",
|
||||
"map_background",
|
||||
"launchplaylist",
|
||||
"quit",
|
||||
"exit",
|
||||
@ -447,12 +452,14 @@ void ConCommand::InitShipped(void)
|
||||
}
|
||||
}
|
||||
|
||||
migrateme->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
help->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
changelevel->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
convar_list->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
convar_differences->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
convar_findByFlags->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
help->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
map->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
map_background->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
migrateme->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,5 +3,106 @@
|
||||
// Purpose: Completion functions for ConCommand callbacks.
|
||||
//
|
||||
//=============================================================================//
|
||||
|
||||
#include "core/stdafx.h"
|
||||
#include "public/iconvar.h"
|
||||
#include "engine/cmodel_bsp.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "completion.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *partial -
|
||||
// context -
|
||||
// longest -
|
||||
// maxcommands -
|
||||
// **commands -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int _Host_Map_f_CompletionFunc(char const* cmdname, char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
{
|
||||
char* substring = (char*)partial;
|
||||
if (strstr(partial, cmdname))
|
||||
{
|
||||
substring = (char*)partial + strlen(cmdname);
|
||||
}
|
||||
|
||||
const size_t mapcount = g_vAllMaps.size();
|
||||
const size_t longest = COMMAND_COMPLETION_ITEM_LENGTH;
|
||||
const size_t count = MIN(mapcount, COMMAND_COMPLETION_MAXITEMS);
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
strncpy(commands[i], g_vAllMaps[i].c_str(), longest);
|
||||
|
||||
char old[COMMAND_COMPLETION_ITEM_LENGTH];
|
||||
strncpy(old, commands[i], sizeof(old));
|
||||
|
||||
snprintf(commands[i], sizeof(commands[i]), "%s%s", cmdname, old);
|
||||
commands[i][strlen(commands[i])] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *partial -
|
||||
// context -
|
||||
// longest -
|
||||
// maxcommands -
|
||||
// **commands -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int Host_SSMap_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
{
|
||||
char const* cmdname = "ss_map ";
|
||||
return _Host_Map_f_CompletionFunc(cmdname, partial, commands);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *partial -
|
||||
// context -
|
||||
// longest -
|
||||
// maxcommands -
|
||||
// **commands -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int Host_Map_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
{
|
||||
char const* cmdname = "map ";
|
||||
return _Host_Map_f_CompletionFunc(cmdname, partial, commands);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *partial -
|
||||
// context -
|
||||
// longest -
|
||||
// maxcommands -
|
||||
// **commands -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int Host_Background_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
{
|
||||
char const* cmdname = "map_background ";
|
||||
return _Host_Map_f_CompletionFunc(cmdname, partial, commands);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input : *partial -
|
||||
// context -
|
||||
// longest -
|
||||
// maxcommands -
|
||||
// **commands -
|
||||
// Output : int
|
||||
//-----------------------------------------------------------------------------
|
||||
int Host_Changelevel_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
{
|
||||
char const* cmdname = "changelevel ";
|
||||
return _Host_Map_f_CompletionFunc(cmdname, partial, commands);
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
#pragma once
|
||||
#include "public/iconvar.h"
|
||||
|
||||
int Host_SSMap_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
|
||||
int Host_Map_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
|
||||
int Host_Background_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
|
||||
int Host_Changelevel_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class VCompletion : public IDetour
|
||||
|
Loading…
x
Reference in New Issue
Block a user