Browse Source

Use filtered command buffer when string came from network (#241)

* cdll_int: add undocumented FilteredClientCmd function to client interface

* client: use filtered command buffer where we have to execute command from server

* client: use normal pfnClientCmd in place of pfnFilteredClientCmd in case of engine doesn't supports it

* client: don't read out of bounds if engine interface is old and don't have pfnFilteredClientCmd

* client: fix incorrect cvar pointer comparison
pull/252/head
a1batross 4 months ago
committed by GitHub
parent
commit
808be9442f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      cl_dll/cdll_int.cpp
  2. 2
      cl_dll/hud_spectator.cpp
  3. 2
      cl_dll/vgui_TeamFortressViewport.h
  4. 3
      engine/cdll_int.h

12
cl_dll/cdll_int.cpp

@ -167,7 +167,17 @@ int DLLEXPORT Initialize( cl_enginefunc_t *pEnginefuncs, int iVersion )
if( iVersion != CLDLL_INTERFACE_VERSION )
return 0;
memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) );
// for now filterstuffcmd is last in the engine interface
memcpy( &gEngfuncs, pEnginefuncs, sizeof(cl_enginefunc_t) - sizeof( void * ) );
if( gEngfuncs.pfnGetCvarPointer( "cl_filterstuffcmd" ) == 0 )
{
gEngfuncs.pfnFilteredClientCmd = gEngfuncs.pfnClientCmd;
}
else
{
gEngfuncs.pfnFilteredClientCmd = pEnginefuncs->pfnFilteredClientCmd;
}
EV_HookEvents();

2
cl_dll/hud_spectator.cpp

@ -577,7 +577,7 @@ void CHudSpectator::DirectorMessage( int iSize, void *pbuf )
case DRC_CMD_FADE:
break;
case DRC_CMD_STUFFTEXT:
ClientCmd( READ_STRING() );
gEngfuncs.pfnFilteredClientCmd( READ_STRING() );
break;
default:
gEngfuncs.Con_DPrintf( "CHudSpectator::DirectorMessage: unknown command %i.\n", cmd );

2
cl_dll/vgui_TeamFortressViewport.h

@ -667,7 +667,7 @@ public:
virtual void actionPerformed(Panel *panel)
{
gEngfuncs.pfnClientCmd( m_pszCommand );
gEngfuncs.pfnFilteredClientCmd( m_pszCommand );
if( m_iCloseVGUIMenu )
gViewPort->HideTopMenu();

3
engine/cdll_int.h

@ -303,6 +303,9 @@ typedef struct cl_enginefuncs_s
int (*pfnGetAppID)( void );
cmdalias_t *(*pfnGetAliases)( void );
void (*pfnVguiWrap2_GetMouseDelta)( int *x, int *y );
// added in 2019 update, not documented yet
int (*pfnFilteredClientCmd)( const char *cmd );
} cl_enginefunc_t;
#define CLDLL_INTERFACE_VERSION 7

Loading…
Cancel
Save