Repository navigation
Expand file tree
/
Copy pathswforwards.cpp
More file actions
113 lines (93 loc) · 3.55 KB
/
Copy pathswforwards.cpp
File metadata and controls
113 lines (93 loc) · 3.55 KB
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
112
113
/*
This file is part of SourcePawn SteamWorks.
SourcePawn SteamWorks is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SourcePawn SteamWorks is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SourcePawn SteamWorks. If not, see <http://www.gnu.org/licenses/>.
Author: Kyle Sanderson (KyleS).
*/
#include "swforwards.h"
SteamWorksForwards::SteamWorksForwards() :
m_CallbackGSClientApprove(this, &SteamWorksForwards::OnGSClientApprove),
m_CallbackValidateTicket(this, &SteamWorksForwards::OnValidateTicket)
/*m_CallbackSteamConnected(this, &SteamWorksForwards::OnSteamServersConnected),
m_CallbackSteamConnectFailure(this, &SteamWorksForwards::OnSteamServersConnectFailure),
m_CallbackSteamDisconnected(this, &SteamWorksForwards::OnSteamServersDisconnected)*/
{
//this->pFOSSC = forwards->CreateForward("Steamworks_OnServersConnected", ET_Ignore, 0, NULL);
//this->pFOSSCF = forwards->CreateForward("Steamworks_OnServersConnectFailure", ET_Ignore, 1, NULL, Param_Cell);
//this->pFOSSD = forwards->CreateForward("Steamworks_OnServersDisconnected", ET_Ignore, 1, NULL, Param_Cell);
this->pFOVC = forwards->CreateForward("SteamWorksL4D2_OnFamilySharingDetected", ET_Ignore, 2, NULL, Param_String, Param_String);
}
SteamWorksForwards::~SteamWorksForwards()
{
forwards->ReleaseForward(this->pFOVC);
//forwards->ReleaseForward(this->pFOSSC);
//forwards->ReleaseForward(this->pFOSSCF);
//forwards->ReleaseForward(this->pFOSSD);
}
// workaround for compatibility
inline const char *RenderSteamID(CSteamID steamID)
{
char* pchBuf;
static char rgchBuf[4][30];
static int nBuf = 0;
pchBuf = rgchBuf[nBuf++];
nBuf %= 4;
AccountID_t steamid32 = steamID.GetAccountID();
sprintf(pchBuf, "STEAM_1:%u:%u", (steamid32 % 2) ? 1 : 0, (uint32)steamid32 / 2);
return pchBuf;
}
void SteamWorksForwards::NotifyPawnValidateClient(CSteamID child, CSteamID parent)
{
if (this->pFOVC->GetFunctionCount() == 0)
{
return;
}
if (child.GetAccountID() != parent.GetAccountID())
{
this->pFOVC->PushString(RenderSteamID(child));
this->pFOVC->PushString(RenderSteamID(parent));
this->pFOVC->Execute(NULL);
}
}
void SteamWorksForwards::OnGSClientApprove(GSClientApprove_t *pApprove)
{
this->NotifyPawnValidateClient(pApprove->m_SteamID, pApprove->m_OwnerSteamID);
}
void SteamWorksForwards::OnValidateTicket(ValidateAuthTicketResponse_t *pTicket)
{
this->NotifyPawnValidateClient(pTicket->m_SteamID, pTicket->m_OwnerSteamID);
}
/*void SteamWorksForwards::OnSteamServersConnected(SteamServersConnected_t *pResponse)
{
if (this->pFOSSC->GetFunctionCount() == 0)
{
return;
}
this->pFOSSC->Execute(NULL);
}
void SteamWorksForwards::OnSteamServersConnectFailure(SteamServerConnectFailure_t *pResponse)
{
if (this->pFOSSCF->GetFunctionCount() == 0)
{
return;
}
this->pFOSSCF->PushCell(pResponse->m_eResult);
this->pFOSSCF->Execute(NULL);
}
void SteamWorksForwards::OnSteamServersDisconnected(SteamServersDisconnected_t *pResponse)
{
if (this->pFOSSD->GetFunctionCount() == 0)
{
return;
}
this->pFOSSD->PushCell(pResponse->m_eResult);
this->pFOSSD->Execute(NULL);
}*/