diff --git a/317360_loc_all.vdf b/317360_loc_all.vdf new file mode 100644 index 000000000..e4fb6b841 --- /dev/null +++ b/317360_loc_all.vdf @@ -0,0 +1,25 @@ +"lang" { + "english" { + "tokens" { + "#Status" "{#Verb} on %mapname%" + "#Verb" "{#Verb_SuperFall_%superfalling%}" + "#Verb_SuperFall_true" "Falling" + "#Verb_SuperFall_false" "{#Verb_Objective_%miniobjective%}" + "#Verb_Objective_Briefcase_Carrying" "Carrying" + "#Verb_Objective_Briefcase_Hunting" "Acquiring" + "#Verb_Objective_Bounty_Hunted" "Wanted" + "#Verb_Objective_Bounty_Hunting" "Hunting" + "#Verb_Objective_RatRace_Leading" "Leading" + "#Verb_Objective_RatRace_Racing" "Racing" + "#Verb_Objective_None" "{#Verb_SuperSkill_%superskill%}" + "#Verb_SuperSkill_true" "Styling" + "#Verb_SuperSkill_false" "{#Verb_Skill_%skill%}" + "#Verb_Skill_bouncer" "Brawling" + "#Verb_Skill_athletic" "Stunting" + "#Verb_Skill_reflexes" "Slowing time" + "#Verb_Skill_marksman" "Camping" + "#Verb_Skill_troll" "Exploding" + "#Verb_Skill_none" "Playing" + } + } +} diff --git a/mp/src/game/client/recvproxy.cpp b/mp/src/game/client/recvproxy.cpp index 24779dafa..6a3d5527c 100644 --- a/mp/src/game/client/recvproxy.cpp +++ b/mp/src/game/client/recvproxy.cpp @@ -107,10 +107,11 @@ RecvProp RecvPropEHandle( RecvProp RecvPropBool( const char *pVarName, int offset, - int sizeofVar ) + int sizeofVar, + RecvVarProxyFn proxyFn ) { Assert( sizeofVar == sizeof( bool ) ); - return RecvPropInt( pVarName, offset, sizeofVar ); + return RecvPropInt( pVarName, offset, sizeofVar, 0, proxyFn ); } diff --git a/mp/src/game/client/recvproxy.h b/mp/src/game/client/recvproxy.h index 67d5d52e0..80477b34a 100644 --- a/mp/src/game/client/recvproxy.h +++ b/mp/src/game/client/recvproxy.h @@ -46,7 +46,8 @@ RecvProp RecvPropEHandle( RecvProp RecvPropBool( const char *pVarName, int offset, - int sizeofVar ); + int sizeofVar, + RecvVarProxyFn proxyFn=0 ); RecvProp RecvPropIntWithMinusOneFlag( const char *pVarName, diff --git a/mp/src/game/client/sdk/c_sdk_player.cpp b/mp/src/game/client/sdk/c_sdk_player.cpp index d767738bb..773c8914a 100644 --- a/mp/src/game/client/sdk/c_sdk_player.cpp +++ b/mp/src/game/client/sdk/c_sdk_player.cpp @@ -38,6 +38,7 @@ #include "materialsystem/imaterial.h" #include "materialsystem/imaterialvar.h" #include "functionproxy.h" +#include "clientsteamcontext.h" #include "da_buymenu.h" #include "sdk_teammenu.h" @@ -56,6 +57,19 @@ ConVar cl_ragdoll_physics_enable( "cl_ragdoll_physics_enable", "1", 0, "Enable/d #undef CSDKPlayer #endif +static void RecvCallback_UpdateRichPresence(const CRecvProxyData *pData) { + if (!pData) + return; + + C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); + if (!pPlayer) + return; + + if (pData->m_ObjectID != pPlayer->entindex()) + return; + + pPlayer->UpdateRichPresence(); +} @@ -154,9 +168,9 @@ BEGIN_RECV_TABLE_NOBASE( CSDKPlayerShared, DT_SDKPlayerShared ) RecvPropBool( RECVINFO( m_bAimedIn ) ), RecvPropFloat( RECVINFO( m_flAimIn ) ), RecvPropFloat( RECVINFO( m_flSlowAimIn ) ), - RecvPropInt( RECVINFO( m_iStyleSkill ) ), + RecvPropInt( RECVINFO( m_iStyleSkill ), 0, RECVCALLBACKPROXY(RecvProxy_Int32ToInt8, RecvCallback_UpdateRichPresence) ), RecvPropInt( RECVINFO( m_iStyleSkillAfterRespawn ), 0, RecvProxy_Skill ), - RecvPropBool( RECVINFO( m_bSuperSkill ) ), + RecvPropBool( RECVINFO( m_bSuperSkill ), RECVCALLBACKPROXY(RecvProxy_Int32ToInt32, RecvCallback_UpdateRichPresence) ), RecvPropDataTable( "sdksharedlocaldata", 0, 0, &REFERENCE_RECV_TABLE(DT_SDKSharedLocalPlayerExclusive) ), RecvPropInt (RECVINFO (m_iWallFlipCount)), @@ -164,8 +178,7 @@ BEGIN_RECV_TABLE_NOBASE( CSDKPlayerShared, DT_SDKPlayerShared ) RecvPropFloat (RECVINFO (m_flWallFlipEndTime)), RecvPropBool (RECVINFO (m_bIsManteling)), RecvPropVector (RECVINFO (m_vecMantelWallNormal)), - - RecvPropBool( RECVINFO( m_bSuperFalling ) ), + RecvPropBool( RECVINFO( m_bSuperFalling ), RECVCALLBACKPROXY(RecvProxy_Int32ToInt8, RecvCallback_UpdateRichPresence) ), RecvPropBool( RECVINFO( m_bSuperFallOthersVisible ) ), RecvPropTime( RECVINFO( m_flSuperFallOthersNextCheck ) ), END_RECV_TABLE() @@ -240,7 +253,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_SDKPlayer, DT_SDKPlayer, CSDKPlayer ) RecvPropString( RECVINFO( m_iszCharacter ), 0, RecvProxy_Character ), - RecvPropEHandle( RECVINFO( m_hBriefcase ) ), + RecvPropEHandle( RECVINFO( m_hBriefcase ), RECVCALLBACKPROXY(RecvProxy_IntToEHandle, RecvCallback_UpdateRichPresence) ), RecvPropInt( RECVINFO( m_iRaceWaypoint ) ), RecvPropBool( RECVINFO( m_bCoderHacks ) ), @@ -946,6 +959,8 @@ void C_SDKPlayer::LocalPlayerRespawn( void ) #else #error ! #endif + + UpdateRichPresence(); } void C_SDKPlayer::OnDataChanged( DataUpdateType_t type ) @@ -2296,6 +2311,47 @@ bool C_SDKPlayer::UseVRHUD() const return UseVR() || da_vr_hud.GetBool(); } +void C_SDKPlayer::UpdateRichPresence() +{ + Msg("Updating Rich Presence...\n"); + + steamapicontext->SteamFriends()->SetRichPresence("steam_display", "#Status"); + steamapicontext->SteamFriends()->SetRichPresence("superfalling", m_Shared.IsSuperFalling() ? "true" : "false"); + steamapicontext->SteamFriends()->SetRichPresence("mapname", SDKGameRules()->MapName()); + steamapicontext->SteamFriends()->SetRichPresence("superskill", m_Shared.m_bSuperSkill ? "true" : "false"); + steamapicontext->SteamFriends()->SetRichPresence("skill", SkillIDToAlias((SkillID)m_Shared.m_iStyleSkill.Get())); + + const char * miniobjective; + switch (SDKGameRules()->GetCurrentMiniObjective()) + { + case MINIOBJECTIVE_BRIEFCASE: + miniobjective = HasBriefcase() ? "Briefcase_Carrying" : "Briefcase_Hunting"; + break; + + case MINIOBJECTIVE_BOUNTY: + miniobjective = SDKGameRules()->GetBountyPlayer() == this ? "Bounty_Hunted" : "Bounty_Hunting"; + break; + + case MINIOBJECTIVE_RATRACE: + if (SDKGameRules()->GetLeader() == this) + { + miniobjective = "RatRace_Leading"; + } + else + { + miniobjective = "RatRace_Racing"; + } + + break; + + default: + miniobjective = "None"; + break; + } + + steamapicontext->SteamFriends()->SetRichPresence("miniobjective", miniobjective); +} + class CSlowIntensityProxy : public CResultProxy { public: diff --git a/mp/src/game/client/sdk/c_sdk_player.h b/mp/src/game/client/sdk/c_sdk_player.h index fd2450659..97527d892 100644 --- a/mp/src/game/client/sdk/c_sdk_player.h +++ b/mp/src/game/client/sdk/c_sdk_player.h @@ -294,6 +294,8 @@ class C_SDKPlayer : public C_BasePlayer bool UseVRHUD() const; + void UpdateRichPresence(); + public: // Public Variables CSDKPlayerAnimState *m_PlayerAnimState; #if defined ( SDK_USE_PRONE ) diff --git a/mp/src/game/client/sdk/clientmode_sdk.cpp b/mp/src/game/client/sdk/clientmode_sdk.cpp index e678b0707..264b270e8 100644 --- a/mp/src/game/client/sdk/clientmode_sdk.cpp +++ b/mp/src/game/client/sdk/clientmode_sdk.cpp @@ -42,6 +42,7 @@ #include "da_credits.h" #include "hud_macros.h" #include "sourcevr/isourcevirtualreality.h" +#include "clientsteamcontext.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -162,6 +163,13 @@ void ClientModeSDKNormal::InitViewport() m_pViewport->Start( gameuifuncs, gameeventmanager ); } +void ClientModeSDKNormal::LevelShutdown() +{ + BaseClass::LevelShutdown(); + + steamapicontext->SteamFriends()->ClearRichPresence(); +} + ClientModeSDKNormal g_ClientModeNormal; IClientMode *GetClientModeNormal() diff --git a/mp/src/game/client/sdk/clientmode_sdk.h b/mp/src/game/client/sdk/clientmode_sdk.h index 9b853e943..c0c39a539 100644 --- a/mp/src/game/client/sdk/clientmode_sdk.h +++ b/mp/src/game/client/sdk/clientmode_sdk.h @@ -27,6 +27,7 @@ DECLARE_CLASS( ClientModeSDKNormal, ClientModeShared ); virtual ~ClientModeSDKNormal(); virtual void InitViewport(); + virtual void LevelShutdown(); virtual float GetViewModelFOV( void ); diff --git a/mp/src/game/shared/sdk/sdk_gamerules.cpp b/mp/src/game/shared/sdk/sdk_gamerules.cpp index 6aaa0ee16..7d910e411 100644 --- a/mp/src/game/shared/sdk/sdk_gamerules.cpp +++ b/mp/src/game/shared/sdk/sdk_gamerules.cpp @@ -75,21 +75,34 @@ END_DATADESC(); #endif +#if defined ( CLIENT_DLL ) +static void RecvCallback_UpdateRichPresence(const CRecvProxyData *pData) { + if (!pData) + return; + + C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); + if (!pPlayer) + return; + + pPlayer->UpdateRichPresence(); +} +#endif + REGISTER_GAMERULES_CLASS( CSDKGameRules ); BEGIN_NETWORK_TABLE_NOBASE( CSDKGameRules, DT_SDKGameRules ) #if defined ( CLIENT_DLL ) - RecvPropInt( RECVINFO( m_eCurrentMiniObjective ) ), + RecvPropInt( RECVINFO( m_eCurrentMiniObjective ), 0, RECVCALLBACKPROXY(RecvProxy_Int32ToInt32, RecvCallback_UpdateRichPresence) ), RecvPropFloat( RECVINFO( m_flGameStartTime ) ), RecvPropBool( RECVINFO( m_bIsTeamplay ) ), RecvPropBool( RECVINFO( m_bCoderHacks ) ), RecvPropEHandle( RECVINFO( m_hBriefcase ) ), RecvPropEHandle( RECVINFO( m_hCaptureZone ) ), - RecvPropEHandle( RECVINFO( m_hBountyPlayer ) ), + RecvPropEHandle( RECVINFO( m_hBountyPlayer ), RECVCALLBACKPROXY(RecvProxy_IntToEHandle, RecvCallback_UpdateRichPresence) ), RecvPropVector( RECVINFO( m_vecLowestSpawnPoint ) ), - RecvPropArray3( RECVINFO_ARRAY(m_ahWaypoint1RaceLeaders), RecvPropEHandle( RECVINFO(m_ahWaypoint1RaceLeaders[0]))), - RecvPropArray3( RECVINFO_ARRAY(m_ahWaypoint2RaceLeaders), RecvPropEHandle( RECVINFO(m_ahWaypoint2RaceLeaders[0]))), + RecvPropArray3( RECVINFO_ARRAY(m_ahWaypoint1RaceLeaders), RecvPropEHandle( RECVINFO(m_ahWaypoint1RaceLeaders[0]), RECVCALLBACKPROXY(RecvProxy_IntToEHandle, RecvCallback_UpdateRichPresence))), + RecvPropArray3( RECVINFO_ARRAY(m_ahWaypoint2RaceLeaders), RecvPropEHandle( RECVINFO(m_ahWaypoint2RaceLeaders[0]), RECVCALLBACKPROXY(RecvProxy_IntToEHandle, RecvCallback_UpdateRichPresence))), RecvPropEHandle( RECVINFO( m_hRaceWaypoint1 ) ), RecvPropEHandle( RECVINFO( m_hRaceWaypoint2 ) ), RecvPropEHandle( RECVINFO( m_hRaceWaypoint3 ) ), @@ -2512,8 +2525,10 @@ bool CSDKGameRules::SetupMiniObjective_Bounty() if (!pPlayer->IsAlive()) continue; +#ifndef _DEBUG if (pPlayer->m_iDeaths + pPlayer->m_iKills < 5) continue; +#endif if (pPlayer->m_Shared.m_bSuperFalling) continue; diff --git a/mp/src/game/shared/sdk/sdk_gamerules.h b/mp/src/game/shared/sdk/sdk_gamerules.h index 1122a11e6..a2c99286e 100644 --- a/mp/src/game/shared/sdk/sdk_gamerules.h +++ b/mp/src/game/shared/sdk/sdk_gamerules.h @@ -239,6 +239,7 @@ class CSDKGameRules : public CTeamplayRules public: void StartMiniObjective(const char* pszObjective = NULL); + miniobjective_t GetCurrentMiniObjective() { return m_eCurrentMiniObjective; } notice_t GetNoticeForMiniObjective(miniobjective_t eObjective); void MaintainMiniObjective(); void CleanupMiniObjective(); diff --git a/mp/src/public/dt_recv.h b/mp/src/public/dt_recv.h index 883b8f753..1388ef8e6 100644 --- a/mp/src/public/dt_recv.h +++ b/mp/src/public/dt_recv.h @@ -295,6 +295,8 @@ inline bool RecvTable::IsInMainList() const #define RECVINFO_DT(varName) RECVINFO_NOSIZE(varName) #define RECVINFO_DTNAME(varName,remoteVarName) #remoteVarName, offsetof(currentRecvDTClass, varName) +#define RECVCALLBACKPROXY(proxyFn, callbackFn) [](const CRecvProxyData *pData, void *pStruct, void *pOut) { (proxyFn)(pData, pStruct, pOut); (callbackFn)(pData); } + void RecvProxy_FloatToFloat ( const CRecvProxyData *pData, void *pStruct, void *pOut ); void RecvProxy_VectorToVector( const CRecvProxyData *pData, void *pStruct, void *pOut );