blob: b7128c07eb3c021d2b66b5e40d20cddfd498b170 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//
//
//=============================================================================
#ifndef GC_CLIENTSYSTEM_H
#define GC_CLIENTSYSTEM_H
#ifdef _WIN32
#pragma once
#endif
#ifdef CLIENT_DLL
#include "clientsteamcontext.h"
#endif
//=============================================================================
//
// Client GC System.
//
//=============================================================================
class CGCClientSystem : public CAutoGameSystemPerFrame
{
DECLARE_CLASS_GAMEROOT( CGCClientSystem, CAutoGameSystem );
public:
// Constructor/Destructor.
CGCClientSystem();
~CGCClientSystem();
// Init/Shutdown.
virtual void PostInit() OVERRIDE;
virtual void LevelInitPreEntity() OVERRIDE;
virtual void LevelShutdownPostEntity() OVERRIDE;
virtual void Shutdown() OVERRIDE;
// Updates. Gameservers do this at a slightly different place than clients
#ifdef CLIENT_DLL
virtual void Update( float frametime ) OVERRIDE;
#else
virtual void PreClientUpdate() OVERRIDE;
#endif
// Connection status
bool BConnectedtoGC() const { return m_bConnectedToGC; }
// GC Messages
bool BSendMessage( uint32 unMsgType, const uint8 *pubData, uint32 cubData );
bool BSendMessage( const GCSDK::CGCMsgBase& msg );
bool BSendMessage( const GCSDK::CProtoBufMsgBase& msg );
// GC SOCache
GCSDK::CGCClientSharedObjectCache *GetSOCache( const CSteamID &steamID );
GCSDK::CGCClientSharedObjectCache *FindOrAddSOCache( const CSteamID &steamID );
// GC Client
GCSDK::CGCClient *GetGCClient();
// Steam
#ifndef CLIENT_DLL
void GameServerActivate();
#endif
protected:
void SetupGC();
virtual void InitGC();
virtual void PreInitGC() {}
virtual void PostInitGC() {}
#ifdef CLIENT_DLL
friend class CGCClientJobClientWelcome;
virtual void ReceivedClientWelcome( const CMsgClientWelcome &msg );
friend class CGCClientJobClientGoodbye;
virtual void ReceivedClientGoodbye( const CMsgClientGoodbye &msg );
#else
friend class CGCClientJobServerWelcome;
virtual void ReceivedServerWelcome( const CMsgServerWelcome &msg );
friend class CGCClientJobServerGoodbye;
virtual void ReceivedServerGoodbye( const CMsgServerGoodbye &msg );
#endif
void SetConnectedToGC( bool bConnected ) { m_bConnectedToGC = bConnected; }
private:
#ifdef CLIENT_DLL
void SteamLoggedOnCallback( const SteamLoggedOnChange_t &loggedOnState );
#else
STEAM_GAMESERVER_CALLBACK( CGCClientSystem, OnLogonSuccess, SteamServersConnected_t, m_CallbackLogonSuccess );
#endif
bool m_bInittedGC;
bool m_bConnectedToGC;
bool m_bLoggedOn;
GCSDK::CGCClient m_GCClient;
double m_timeLastSendHello;
void ThinkConnection();
friend class CGCClientSystemJob;
};
void SetGCClientSystem( CGCClientSystem* pGCClientSystem );
CGCClientSystem *GCClientSystem();
#endif // GC_CLIENTSYSTEM_H
|