mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Add completion logic for 'give' command
* Implemented class 'CAutoCompleteFileList' (features engine's implementation for 'AutoCompletionFunc'). * Added completion callback for 'give' command.
This commit is contained in:
parent
d93e5f9d97
commit
836839e6a5
@ -394,10 +394,12 @@ void ConCommand::InitShipped(void)
|
||||
///------------------------------------------------------ [ CALLBACK SWAP ]
|
||||
//-------------------------------------------------------------------------
|
||||
// ENGINE DLL |
|
||||
#ifndef CLIENT_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");
|
||||
#endif // !CLIENT_DLL
|
||||
ConCommand* migrateme = g_pCVar->FindCommand("migrateme");
|
||||
ConCommand* help = g_pCVar->FindCommand("help");
|
||||
ConCommand* convar_list = g_pCVar->FindCommand("convar_list");
|
||||
@ -407,19 +409,29 @@ void ConCommand::InitShipped(void)
|
||||
//-------------------------------------------------------------------------
|
||||
// MATERIAL SYSTEM
|
||||
ConCommand* mat_crosshair = g_pCVar->FindCommand("mat_crosshair"); // Patch callback function to working callback.
|
||||
mat_crosshair->m_fnCommandCallback = Mat_CrossHair_f;
|
||||
//-------------------------------------------------------------------------
|
||||
// CLIENT DLL |
|
||||
ConCommand* give = g_pCVar->FindCommand("give");
|
||||
#endif // !DEDICATED
|
||||
|
||||
help->m_fnCommandCallback = CVHelp_f;
|
||||
changelevel->m_fnCommandCallback = Host_Changelevel_f;
|
||||
convar_list->m_fnCommandCallback = CVList_f;
|
||||
convar_differences->m_fnCommandCallback = CVDiff_f;
|
||||
convar_findByFlags->m_fnCommandCallback = CVFlag_f;
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
changelevel->m_fnCommandCallback = Host_Changelevel_f;
|
||||
changelevel->m_fnCompletionCallback = Host_Changelevel_f_CompletionFunc;
|
||||
|
||||
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;
|
||||
#endif // !CLIENT_DLL
|
||||
|
||||
#ifndef DEDICATED
|
||||
mat_crosshair->m_fnCommandCallback = Mat_CrossHair_f;
|
||||
give->m_fnCompletionCallback = Game_Give_f_CompletionFunc;
|
||||
#endif // !DEDICATED
|
||||
|
||||
/// ------------------------------------------------------ [ FLAG REMOVAL ]
|
||||
//-------------------------------------------------------------------------
|
||||
@ -452,14 +464,17 @@ void ConCommand::InitShipped(void)
|
||||
}
|
||||
}
|
||||
|
||||
changelevel->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
convar_list->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
convar_differences->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
convar_findByFlags->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
help->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
migrateme->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
#ifndef CLIENT_DLL
|
||||
changelevel->RemoveFlags(FCVAR_DEVELOPMENTONLY);
|
||||
map->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
map_background->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
migrateme->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
ss_map->RemoveFlags(FCVAR_SERVER_CAN_EXECUTE);
|
||||
#endif // !CLIENT_DLL
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,6 +159,7 @@
|
||||
<ClCompile Include="..\vphysics\physics_collide.cpp" />
|
||||
<ClCompile Include="..\vphysics\QHull.cpp" />
|
||||
<ClCompile Include="..\vpklib\packedstore.cpp" />
|
||||
<ClCompile Include="..\vstdlib\autocompletefilelist.cpp" />
|
||||
<ClCompile Include="..\vstdlib\callback.cpp" />
|
||||
<ClCompile Include="..\vstdlib\completion.cpp" />
|
||||
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp" />
|
||||
@ -597,6 +598,7 @@
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h" />
|
||||
<ClInclude Include="..\vphysics\QHull.h" />
|
||||
<ClInclude Include="..\vpklib\packedstore.h" />
|
||||
<ClInclude Include="..\vstdlib\autocompletefilelist.h" />
|
||||
<ClInclude Include="..\vstdlib\callback.h" />
|
||||
<ClInclude Include="..\vstdlib\completion.h" />
|
||||
<ClInclude Include="..\vstdlib\concommandhash.h" />
|
||||
|
@ -681,6 +681,9 @@
|
||||
<ClCompile Include="..\tier0\crashhandler.cpp">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\vstdlib\autocompletefilelist.cpp">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -1994,6 +1997,9 @@
|
||||
<ClInclude Include="..\tier0\crashhandler.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\vstdlib\autocompletefilelist.h">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
@ -512,6 +512,7 @@
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h" />
|
||||
<ClInclude Include="..\vphysics\QHull.h" />
|
||||
<ClInclude Include="..\vpklib\packedstore.h" />
|
||||
<ClInclude Include="..\vstdlib\autocompletefilelist.h" />
|
||||
<ClInclude Include="..\vstdlib\callback.h" />
|
||||
<ClInclude Include="..\vstdlib\completion.h" />
|
||||
<ClInclude Include="..\vstdlib\concommandhash.h" />
|
||||
@ -654,6 +655,7 @@
|
||||
<ClCompile Include="..\vphysics\physics_collide.cpp" />
|
||||
<ClCompile Include="..\vphysics\QHull.cpp" />
|
||||
<ClCompile Include="..\vpklib\packedstore.cpp" />
|
||||
<ClCompile Include="..\vstdlib\autocompletefilelist.cpp" />
|
||||
<ClCompile Include="..\vstdlib\callback.cpp" />
|
||||
<ClCompile Include="..\vstdlib\completion.cpp" />
|
||||
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp" />
|
||||
|
@ -1380,6 +1380,9 @@
|
||||
<ClInclude Include="..\tier0\crashhandler.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\vstdlib\autocompletefilelist.h">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\common\opcodes.cpp">
|
||||
@ -1763,6 +1766,9 @@
|
||||
<ClCompile Include="..\tier0\crashhandler.cpp">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\vstdlib\autocompletefilelist.cpp">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Dedicated.def" />
|
||||
|
@ -178,6 +178,7 @@
|
||||
<ClCompile Include="..\vphysics\physics_collide.cpp" />
|
||||
<ClCompile Include="..\vphysics\QHull.cpp" />
|
||||
<ClCompile Include="..\vpklib\packedstore.cpp" />
|
||||
<ClCompile Include="..\vstdlib\autocompletefilelist.cpp" />
|
||||
<ClCompile Include="..\vstdlib\callback.cpp" />
|
||||
<ClCompile Include="..\vstdlib\completion.cpp" />
|
||||
<ClCompile Include="..\vstdlib\keyvaluessystem.cpp" />
|
||||
@ -651,6 +652,7 @@
|
||||
<ClInclude Include="..\vpc\kvleaktrace.h" />
|
||||
<ClInclude Include="..\vphysics\QHull.h" />
|
||||
<ClInclude Include="..\vpklib\packedstore.h" />
|
||||
<ClInclude Include="..\vstdlib\autocompletefilelist.h" />
|
||||
<ClInclude Include="..\vstdlib\callback.h" />
|
||||
<ClInclude Include="..\vstdlib\completion.h" />
|
||||
<ClInclude Include="..\vstdlib\concommandhash.h" />
|
||||
|
@ -747,6 +747,9 @@
|
||||
<ClCompile Include="..\tier0\crashhandler.cpp">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\vstdlib\autocompletefilelist.cpp">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\client\cdll_engine_int.h">
|
||||
@ -2165,6 +2168,9 @@
|
||||
<ClInclude Include="..\tier0\crashhandler.h">
|
||||
<Filter>sdk\tier0</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\vstdlib\autocompletefilelist.h">
|
||||
<Filter>sdk\vstdlib</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="..\shared\resource\lockedserver.png">
|
||||
|
20
r5dev/vstdlib/autocompletefilelist.cpp
Normal file
20
r5dev/vstdlib/autocompletefilelist.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
#include "core/stdafx.h"
|
||||
#include "completion.h"
|
||||
#include "autocompletefilelist.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Fills in a list of commands based on specified subdirectory and extension into the format:
|
||||
// commandname subdir/filename.ext
|
||||
// commandname subdir/filename2.ext
|
||||
// Returns number of files in list for autocompletion
|
||||
//-----------------------------------------------------------------------------
|
||||
int CAutoCompleteFileList::AutoCompletionFunc(const char* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
{
|
||||
return v_CAutoCompleteFileList_AutoCompletionFunc(this, partial, commands);
|
||||
}
|
36
r5dev/vstdlib/autocompletefilelist.h
Normal file
36
r5dev/vstdlib/autocompletefilelist.h
Normal file
@ -0,0 +1,36 @@
|
||||
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//===========================================================================//
|
||||
|
||||
#ifndef AUTOCOMPLETEFILELIST_H
|
||||
#define AUTOCOMPLETEFILELIST_H
|
||||
#ifdef _WIN32
|
||||
#pragma once
|
||||
#endif
|
||||
#include "public/iconvar.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Simple helper class for doing autocompletion of all files in a specific directory by extension
|
||||
//-----------------------------------------------------------------------------
|
||||
class CAutoCompleteFileList
|
||||
{
|
||||
public:
|
||||
CAutoCompleteFileList(const char* cmdname, const char* subdir, const char* extension)
|
||||
{
|
||||
m_pszCommandName = cmdname;
|
||||
m_pszSubDir = subdir;
|
||||
m_pszExtension = extension;
|
||||
}
|
||||
|
||||
int AutoCompletionFunc(const char* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
|
||||
|
||||
private:
|
||||
const char* m_pszCommandName;
|
||||
const char* m_pszSubDir;
|
||||
const char* m_pszExtension;
|
||||
};
|
||||
|
||||
#endif // AUTOCOMPLETEFILELIST_H
|
@ -8,6 +8,7 @@
|
||||
#include "engine/cmodel_bsp.h"
|
||||
#include "tier1/strtools.h"
|
||||
#include "completion.h"
|
||||
#include "autocompletefilelist.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -106,3 +107,10 @@ int Host_Changelevel_f_CompletionFunc(char const* partial, char commands[COMMAND
|
||||
char const* cmdname = "changelevel ";
|
||||
return _Host_Map_f_CompletionFunc(cmdname, partial, commands);
|
||||
}
|
||||
|
||||
static CAutoCompleteFileList s_GiveAutoFileList("give", "scripts/weapons", "txt");
|
||||
int Game_Give_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])
|
||||
{
|
||||
return s_GiveAutoFileList.AutoCompletionFunc(partial, commands);
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,35 @@
|
||||
#pragma once
|
||||
#include "public/iconvar.h"
|
||||
#include "autocompletefilelist.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]);
|
||||
|
||||
int Game_Give_f_CompletionFunc(char const* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH]);
|
||||
|
||||
inline CMemory p_CAutoCompleteFileList_AutoCompletionFunc;
|
||||
inline auto v_CAutoCompleteFileList_AutoCompletionFunc = p_CAutoCompleteFileList_AutoCompletionFunc.RCast<int(*)(
|
||||
CAutoCompleteFileList* thisp, const char* partial, char commands[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])>();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
class VCompletion : public IDetour
|
||||
{
|
||||
virtual void GetAdr(void) const { }
|
||||
virtual void GetFun(void) const { }
|
||||
virtual void GetAdr(void) const
|
||||
{
|
||||
LogFunAdr("CAutoCompleteFileList::AutoCompletionFunc", p_CAutoCompleteFileList_AutoCompletionFunc.GetPtr());
|
||||
}
|
||||
virtual void GetFun(void) const
|
||||
{
|
||||
#if defined (GAMEDLL_S0) || defined (GAMEDLL_S1)
|
||||
p_CBaseAutoCompleteFileList_AutoCompletionFunc = g_GameDll.FindPatternSIMD("40 55 53 57 41 54 41 55 41 56 41 57 48 8D 6C 24 ?? 48 81 EC ?? ?? ?? ?? 48 8B 39");
|
||||
#elif defined (GAMEDLL_S2) || defined (GAMEDLL_S3)
|
||||
p_CAutoCompleteFileList_AutoCompletionFunc = g_GameDll.FindPatternSIMD("48 8B C4 4C 89 40 18 55 41 54");
|
||||
#endif
|
||||
v_CAutoCompleteFileList_AutoCompletionFunc = p_CAutoCompleteFileList_AutoCompletionFunc.RCast<int(*)(
|
||||
CAutoCompleteFileList*, const char*, char[COMMAND_COMPLETION_MAXITEMS][COMMAND_COMPLETION_ITEM_LENGTH])>();
|
||||
}
|
||||
virtual void GetVar(void) const { }
|
||||
virtual void GetCon(void) const { }
|
||||
virtual void Attach(void) const { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user