Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the server sets Steamids to clients after the validation by Steam servers #1031

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rehlds/engine/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ void SV_DropClient_internal(client_t *cl, qboolean crash, const char *string)

if (!cl->fakeclient)
Netchan_Transmit(&cl->netchan, i, final);

cl->network_userid.m_SteamIDValidated = 0;
host_client->network_userid.m_SteamIDValidated = 0;
}

connection_time = realtime - cl->netchan.connect_time;
Expand Down
10 changes: 5 additions & 5 deletions rehlds/engine/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,7 @@ void EXT_FUNC SV_ConnectClient_internal(void)
host_client->userinfo[MAX_INFO_STRING - 1] = 0;

SV_ExtractFromUserinfo(host_client);
Info_SetValueForStarKey(host_client->userinfo, "*sid", va("%lld", host_client->network_userid.m_SteamID), MAX_INFO_STRING);
Info_SetValueForStarKey(host_client->userinfo, "*sid", va("%lld", host_client->network_userid.m_SteamIDValidated), MAX_INFO_STRING);

host_client->datagram.flags = SIZEBUF_ALLOW_OVERFLOW;
host_client->datagram.data = (byte *)host_client->datagram_buf;
Expand Down Expand Up @@ -8411,13 +8411,13 @@ char* EXT_FUNC SV_GetIDString_internal(USERID_t *id)
{
Q_strncpy(idstr, "STEAM_ID_LAN", ARRAYSIZE(idstr) - 1);
}
else if (!id->m_SteamID)
else if (!id->m_SteamIDValidated)
{
Q_strncpy(idstr, "STEAM_ID_PENDING", ARRAYSIZE(idstr) - 1);
}
else
{
TSteamGlobalUserID steam2ID = Steam_Steam3IDtoSteam2(id->m_SteamID);
TSteamGlobalUserID steam2ID = Steam_Steam3IDtoSteam2(id->m_SteamIDValidated);
Q_snprintf(idstr, ARRAYSIZE(idstr) - 1, "STEAM_%u:%u:%u", steam2ID.m_SteamInstanceID, steam2ID.m_SteamLocalUserID.Split.High32bits, steam2ID.m_SteamLocalUserID.Split.Low32bits);
}
break;
Expand All @@ -8426,13 +8426,13 @@ char* EXT_FUNC SV_GetIDString_internal(USERID_t *id)
{
Q_strncpy(idstr, "VALVE_ID_LAN", ARRAYSIZE(idstr) - 1);
}
else if (!id->m_SteamID)
else if (!id->m_SteamIDValidated)
{
Q_strncpy(idstr, "VALVE_ID_PENDING", ARRAYSIZE(idstr) - 1);
}
else
{
TSteamGlobalUserID steam2ID = Steam_Steam3IDtoSteam2(id->m_SteamID);
TSteamGlobalUserID steam2ID = Steam_Steam3IDtoSteam2(id->m_SteamIDValidated);
Q_snprintf(idstr, ARRAYSIZE(idstr) - 1, "VALVE_%u:%u:%u", steam2ID.m_SteamInstanceID, steam2ID.m_SteamLocalUserID.Split.High32bits, steam2ID.m_SteamLocalUserID.Split.Low32bits);
}
break;
Expand Down
10 changes: 9 additions & 1 deletion rehlds/engine/sv_steam3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ void CSteam3Server::OnGSClientDenyHelper(client_t *cl, EDenyReason eDenyReason,
break;

case k_EDenySteamValidationStalled:
if (m_bLanOnly)
if (!m_bLanOnly)
SV_DropClient(cl, 0, "STEAM verification failed");
else
cl->network_userid.m_SteamID = 1;
break;

Expand All @@ -172,6 +174,12 @@ void CSteam3Server::OnGSClientApprove(GSClientApprove_t *pGSClientSteam2Accept)
if (!cl)
return;

cl->network_userid.m_SteamIDValidated = pGSClientSteam2Accept->m_SteamID.ConvertToUint64();
host_client->network_userid.m_SteamIDValidated = pGSClientSteam2Accept->m_SteamID.ConvertToUint64();

Info_SetValueForStarKey(cl->userinfo, "*sid", va("%lld", cl->network_userid.m_SteamIDValidated), MAX_INFO_STRING);
Info_SetValueForStarKey(host_client->userinfo, "*sid", va("%lld", host_client->network_userid.m_SteamIDValidated), MAX_INFO_STRING);

if (SV_FilterUser(&cl->network_userid))
{
char msg[256];
Expand Down
1 change: 1 addition & 0 deletions rehlds/public/rehlds/userid_rehlds.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ typedef struct USERID_s
{
int idtype;
uint64 m_SteamID;
uint64 m_SteamIDValidated;
unsigned int clientip;
} USERID_t;
4 changes: 2 additions & 2 deletions rehlds/rehlds/structSizeCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ void check_size() {


void checkSizesStatic() {
CHECK_TYPE_SIZE(client_t, 0x5018, 0x4EF4);
CHECK_TYPE_SIZE(userfilter_t, 0x20, 0x18);
CHECK_TYPE_SIZE(client_t, 0x5020, 0x4EFC);
CHECK_TYPE_SIZE(userfilter_t, 0x28, 0x20);
#ifndef REHLDS_FIXES
CHECK_TYPE_SIZE(CSteam3Server, 0x90, 0xA8);
#endif
Expand Down
4 changes: 2 additions & 2 deletions rehlds/unittests/struct_offsets_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ TEST(StructOffsets, ReversingChecks, 5000)
CHECK_STRUCT_OFFSET(client_t, active, 0, 0);
CHECK_STRUCT_OFFSET(client_t, chokecount, 0x2540, 0x2430);
CHECK_STRUCT_OFFSET(client_t, datagram, 0x25C0, 0x24AC);
CHECK_STRUCT_OFFSET(client_t, m_VoiceStreams, 0x5000, 0x4EE0);
CHECK_STRUCT_OFFSET(client_t, m_lastvoicetime, 0x5008, 0x4EE8);
CHECK_STRUCT_OFFSET(client_t, m_VoiceStreams, 0x5008, 0x4EE8);
CHECK_STRUCT_OFFSET(client_t, m_lastvoicetime, 0x5010, 0x4EF0);
CHECK_STRUCT_OFFSET(client_t, datagram_buf, 0x25D4, 0x24C0);
CHECK_STRUCT_OFFSET(client_t, connection_started, 0x3578, 0x3460);

Expand Down
Loading