diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/game/client/clientsteamcontext.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/game/client/clientsteamcontext.cpp')
| -rw-r--r-- | mp/src/game/client/clientsteamcontext.cpp | 260 |
1 files changed, 130 insertions, 130 deletions
diff --git a/mp/src/game/client/clientsteamcontext.cpp b/mp/src/game/client/clientsteamcontext.cpp index ecd52d36..df1f921d 100644 --- a/mp/src/game/client/clientsteamcontext.cpp +++ b/mp/src/game/client/clientsteamcontext.cpp @@ -1,131 +1,131 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-#include "cbase.h"
-#include "clientsteamcontext.h"
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-static CClientSteamContext g_ClientSteamContext;
-CClientSteamContext &ClientSteamContext()
-{
- return g_ClientSteamContext;
-}
-
-CSteamAPIContext *steamapicontext = &g_ClientSteamContext;
-
-//-----------------------------------------------------------------------------
-CClientSteamContext::CClientSteamContext()
-#if !defined(NO_STEAM)
-:
- m_CallbackSteamServersDisconnected( this, &CClientSteamContext::OnSteamServersDisconnected ),
- m_CallbackSteamServerConnectFailure( this, &CClientSteamContext::OnSteamServerConnectFailure ),
- m_CallbackSteamServersConnected( this, &CClientSteamContext::OnSteamServersConnected )
-#endif
-{
- m_bActive = false;
- m_bLoggedOn = false;
- m_nAppID = 0;
-}
-
-
-//-----------------------------------------------------------------------------
-CClientSteamContext::~CClientSteamContext()
-{
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Unload the steam3 engine
-//-----------------------------------------------------------------------------
-void CClientSteamContext::Shutdown()
-{
- if ( !m_bActive )
- return;
-
- m_bActive = false;
- m_bLoggedOn = false;
-#if !defined( NO_STEAM )
- Clear(); // Steam API context shutdown
-#endif
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Initialize the steam3 connection
-//-----------------------------------------------------------------------------
-void CClientSteamContext::Activate()
-{
- if ( m_bActive )
- return;
-
- m_bActive = true;
-
-#if !defined( NO_STEAM )
- SteamAPI_InitSafe(); // ignore failure, that will fall out later when they don't get a valid logon cookie
- SteamAPI_SetTryCatchCallbacks( false ); // We don't use exceptions, so tell steam not to use try/catch in callback handlers
- Init(); // Steam API context init
-
- UpdateLoggedOnState();
- Msg( "CClientSteamContext logged on = %d\n", m_bLoggedOn );
-#endif
-}
-
-void CClientSteamContext::UpdateLoggedOnState()
-{
- bool bPreviousLoggedOn = m_bLoggedOn;
- m_bLoggedOn = ( SteamUser() && SteamUtils() && SteamUser()->BLoggedOn() );
-
- if ( !bPreviousLoggedOn && m_bLoggedOn )
- {
- // update Steam info
- m_SteamIDLocalPlayer = SteamUser()->GetSteamID();
- m_nUniverse = SteamUtils()->GetConnectedUniverse();
- m_nAppID = SteamUtils()->GetAppID();
- }
-
- if ( bPreviousLoggedOn != m_bLoggedOn )
- {
- // Notify any listeners of the change in logged on state
- SteamLoggedOnChange_t loggedOnChange;
- loggedOnChange.bPreviousLoggedOn = bPreviousLoggedOn;
- loggedOnChange.bLoggedOn = m_bLoggedOn;
- InvokeCallbacks( loggedOnChange );
- }
-}
-
-#if !defined(NO_STEAM)
-void CClientSteamContext::OnSteamServersDisconnected( SteamServersDisconnected_t *pDisconnected )
-{
- UpdateLoggedOnState();
- Msg( "CClientSteamContext OnSteamServersDisconnected logged on = %d\n", m_bLoggedOn );
-}
-
-void CClientSteamContext::OnSteamServerConnectFailure( SteamServerConnectFailure_t *pConnectFailure )
-{
- UpdateLoggedOnState();
- Msg( "CClientSteamContext OnSteamServerConnectFailure logged on = %d\n", m_bLoggedOn );
-}
-
-void CClientSteamContext::OnSteamServersConnected( SteamServersConnected_t *pConnected )
-{
- UpdateLoggedOnState();
- Msg( "CClientSteamContext OnSteamServersConnected logged on = %d\n", m_bLoggedOn );
-}
-#endif // !defined(NO_STEAM)
-
-void CClientSteamContext::InstallCallback( CUtlDelegate< void ( const SteamLoggedOnChange_t & ) > delegate )
-{
- m_LoggedOnCallbacks.AddToTail( delegate );
-}
-
-void CClientSteamContext::RemoveCallback( CUtlDelegate< void ( const SteamLoggedOnChange_t & ) > delegate )
-{
- m_LoggedOnCallbacks.FindAndRemove( delegate );
-}
-
-void CClientSteamContext::InvokeCallbacks( const SteamLoggedOnChange_t &loggedOnStatus )
-{
- for ( int i = 0; i < m_LoggedOnCallbacks.Count(); ++i )
- {
- m_LoggedOnCallbacks[i]( loggedOnStatus );
- }
+//========= Copyright Valve Corporation, All rights reserved. ============// +#include "cbase.h" +#include "clientsteamcontext.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +static CClientSteamContext g_ClientSteamContext; +CClientSteamContext &ClientSteamContext() +{ + return g_ClientSteamContext; +} + +CSteamAPIContext *steamapicontext = &g_ClientSteamContext; + +//----------------------------------------------------------------------------- +CClientSteamContext::CClientSteamContext() +#if !defined(NO_STEAM) +: + m_CallbackSteamServersDisconnected( this, &CClientSteamContext::OnSteamServersDisconnected ), + m_CallbackSteamServerConnectFailure( this, &CClientSteamContext::OnSteamServerConnectFailure ), + m_CallbackSteamServersConnected( this, &CClientSteamContext::OnSteamServersConnected ) +#endif +{ + m_bActive = false; + m_bLoggedOn = false; + m_nAppID = 0; +} + + +//----------------------------------------------------------------------------- +CClientSteamContext::~CClientSteamContext() +{ +} + + +//----------------------------------------------------------------------------- +// Purpose: Unload the steam3 engine +//----------------------------------------------------------------------------- +void CClientSteamContext::Shutdown() +{ + if ( !m_bActive ) + return; + + m_bActive = false; + m_bLoggedOn = false; +#if !defined( NO_STEAM ) + Clear(); // Steam API context shutdown +#endif +} + +//----------------------------------------------------------------------------- +// Purpose: Initialize the steam3 connection +//----------------------------------------------------------------------------- +void CClientSteamContext::Activate() +{ + if ( m_bActive ) + return; + + m_bActive = true; + +#if !defined( NO_STEAM ) + SteamAPI_InitSafe(); // ignore failure, that will fall out later when they don't get a valid logon cookie + SteamAPI_SetTryCatchCallbacks( false ); // We don't use exceptions, so tell steam not to use try/catch in callback handlers + Init(); // Steam API context init + + UpdateLoggedOnState(); + Msg( "CClientSteamContext logged on = %d\n", m_bLoggedOn ); +#endif +} + +void CClientSteamContext::UpdateLoggedOnState() +{ + bool bPreviousLoggedOn = m_bLoggedOn; + m_bLoggedOn = ( SteamUser() && SteamUtils() && SteamUser()->BLoggedOn() ); + + if ( !bPreviousLoggedOn && m_bLoggedOn ) + { + // update Steam info + m_SteamIDLocalPlayer = SteamUser()->GetSteamID(); + m_nUniverse = SteamUtils()->GetConnectedUniverse(); + m_nAppID = SteamUtils()->GetAppID(); + } + + if ( bPreviousLoggedOn != m_bLoggedOn ) + { + // Notify any listeners of the change in logged on state + SteamLoggedOnChange_t loggedOnChange; + loggedOnChange.bPreviousLoggedOn = bPreviousLoggedOn; + loggedOnChange.bLoggedOn = m_bLoggedOn; + InvokeCallbacks( loggedOnChange ); + } +} + +#if !defined(NO_STEAM) +void CClientSteamContext::OnSteamServersDisconnected( SteamServersDisconnected_t *pDisconnected ) +{ + UpdateLoggedOnState(); + Msg( "CClientSteamContext OnSteamServersDisconnected logged on = %d\n", m_bLoggedOn ); +} + +void CClientSteamContext::OnSteamServerConnectFailure( SteamServerConnectFailure_t *pConnectFailure ) +{ + UpdateLoggedOnState(); + Msg( "CClientSteamContext OnSteamServerConnectFailure logged on = %d\n", m_bLoggedOn ); +} + +void CClientSteamContext::OnSteamServersConnected( SteamServersConnected_t *pConnected ) +{ + UpdateLoggedOnState(); + Msg( "CClientSteamContext OnSteamServersConnected logged on = %d\n", m_bLoggedOn ); +} +#endif // !defined(NO_STEAM) + +void CClientSteamContext::InstallCallback( CUtlDelegate< void ( const SteamLoggedOnChange_t & ) > delegate ) +{ + m_LoggedOnCallbacks.AddToTail( delegate ); +} + +void CClientSteamContext::RemoveCallback( CUtlDelegate< void ( const SteamLoggedOnChange_t & ) > delegate ) +{ + m_LoggedOnCallbacks.FindAndRemove( delegate ); +} + +void CClientSteamContext::InvokeCallbacks( const SteamLoggedOnChange_t &loggedOnStatus ) +{ + for ( int i = 0; i < m_LoggedOnCallbacks.Count(); ++i ) + { + m_LoggedOnCallbacks[i]( loggedOnStatus ); + } }
\ No newline at end of file |