Skip to content

Commit

Permalink
add scoreboard, help, team and spare button binding hooks + disable a…
Browse files Browse the repository at this point in the history
…ssert for SetPoseParameter on invalid param
  • Loading branch information
luttje committed Sep 29, 2024
1 parent 4741662 commit 64b1e57
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/game/client/in_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,14 @@ void IN_ScoreDown( const CCommand &args )
KeyDown( &in_score, args[1] );
if ( gViewPortInterface )
{
if ( L )
{
LUA_CALL_HOOK_BEGIN( "ScoreboardShow" );
LUA_CALL_HOOK_END( 0, 1 );

LUA_RETURN_NONE_IF_TRUE();
}

gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, true );
}
}
Expand All @@ -716,6 +724,12 @@ void IN_ScoreUp( const CCommand &args )
KeyUp( &in_score, args[1] );
if ( gViewPortInterface )
{
if ( L )
{
LUA_CALL_HOOK_BEGIN( "ScoreboardHide" );
LUA_CALL_HOOK_END( 0, 0 );
}

gViewPortInterface->ShowPanel( PANEL_SCOREBOARD, false );
GetClientVoiceMgr()->StopSquelchMode();
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/server/baseanimating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1222,8 +1222,8 @@ void CBaseAnimating::HandleAnimEvent( animevent_t *pEvent )
float CBaseAnimating::SetPoseParameter( CStudioHdr *pStudioHdr, const char *szName, float flValue )
{
int poseParam = LookupPoseParameter( pStudioHdr, szName );
// Experiment; TODO: Note that the model we are currently using doesn't have a move_yaw parameter. Hence we're getting this assert (ignore it for now). The same assert is also spammed in gmod for this model I believe.
AssertMsg2( poseParam >= 0, "SetPoseParameter called with invalid argument %s by %s", szName, GetDebugName() );
// Experiment; TODO: Note that the model we are currently using doesn't have a move_yaw parameter. Hence we're getting this assert. For gmod compat we just commented this, since gmod doesnt complain either and does nothing
// AssertMsg2( poseParam >= 0, "SetPoseParameter called with invalid argument %s by %s", szName, GetDebugName() );
return SetPoseParameter( pStudioHdr, poseParam, flValue );
}

Expand Down
63 changes: 63 additions & 0 deletions src/game/server/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,69 @@ void CC_Player_Use( const CCommand &args )
}
static ConCommand use( "use", CC_Player_Use, "Use a particular weapon\t\nArguments: <weapon_name>" );

// For Garry's Mod compatibility we implement gm_showhelp (F1), gm_showteam (F2), gm_showspare1 (F3), gm_showspare2 (F4)
#ifdef EXPERIMENT_SOURCE
void CC_ShowHelp( const CCommand &args )
{
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );

if ( !pPlayer || !L )
{
return;
}

LUA_CALL_HOOK_BEGIN( "ShowHelp" );
CBasePlayer::PushLuaInstanceSafe( L, pPlayer );
LUA_CALL_HOOK_END( 1, 0 );
}
static ConCommand gm_showhelp( "gm_showhelp", CC_ShowHelp );

void CC_ShowTeam( const CCommand &args )
{
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );

if ( !pPlayer || !L )
{
return;
}

LUA_CALL_HOOK_BEGIN( "ShowTeam" );
CBasePlayer::PushLuaInstanceSafe( L, pPlayer );
LUA_CALL_HOOK_END( 1, 0 );
}
static ConCommand gm_showteam( "gm_showteam", CC_ShowTeam );

void CC_ShowSpare1( const CCommand &args )
{
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );

if ( !pPlayer || !L )
{
return;
}

LUA_CALL_HOOK_BEGIN( "ShowSpare1" );
CBasePlayer::PushLuaInstanceSafe( L, pPlayer );
LUA_CALL_HOOK_END( 1, 0 );
}
static ConCommand gm_showspare1( "gm_showspare1", CC_ShowSpare1 );

void CC_ShowSpare2( const CCommand &args )
{
CBasePlayer *pPlayer = ToBasePlayer( UTIL_GetCommandClient() );

if ( !pPlayer || !L )
{
return;
}

LUA_CALL_HOOK_BEGIN( "ShowSpare2" );
CBasePlayer::PushLuaInstanceSafe( L, pPlayer );
LUA_CALL_HOOK_END( 1, 0 );
}
static ConCommand gm_showspare2( "gm_showspare2", CC_ShowSpare2 );
#endif

//------------------------------------------------------------------------------
// A small wrapper around SV_Move that never clips against the supplied entity.
//------------------------------------------------------------------------------
Expand Down

0 comments on commit 64b1e57

Please sign in to comment.