mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-11-27 14:08:39 +01:00
Make auth stuff behave more like real steam.
This commit is contained in:
parent
0677b8e2ff
commit
e252f83e8a
3 changed files with 22 additions and 11 deletions
28
dll/base.cpp
28
dll/base.cpp
|
@ -256,13 +256,15 @@ Auth_Ticket_Manager::Auth_Ticket_Manager(class Settings *settings, class Network
|
|||
this->network->setCallback(CALLBACK_ID_USER_STATUS, settings->get_local_steam_id(), &steam_auth_ticket_callback, this);
|
||||
}
|
||||
|
||||
void Auth_Ticket_Manager::launch_callback(CSteamID id, EAuthSessionResponse resp)
|
||||
#define STEAM_TICKET_PROCESS_TIME 0.02
|
||||
|
||||
void Auth_Ticket_Manager::launch_callback(CSteamID id, EAuthSessionResponse resp, double delay)
|
||||
{
|
||||
ValidateAuthTicketResponse_t data;
|
||||
data.m_SteamID = id;
|
||||
data.m_eAuthSessionResponse = resp;
|
||||
data.m_OwnerSteamID = id;
|
||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), delay);
|
||||
}
|
||||
|
||||
void Auth_Ticket_Manager::launch_callback_gs(CSteamID id, bool approved)
|
||||
|
@ -383,15 +385,16 @@ EBeginAuthSessionResult Auth_Ticket_Manager::beginAuth(const void *pAuthTicket,
|
|||
memcpy(&number, ((char *)pAuthTicket) + sizeof(uint64), sizeof(number));
|
||||
data.id = CSteamID(id);
|
||||
data.number = number;
|
||||
data.created = std::chrono::high_resolution_clock::now();
|
||||
|
||||
for (auto & t : inbound) {
|
||||
if (t.id == data.id) {
|
||||
if (t.id == data.id && !check_timedout(t.created, STEAM_TICKET_PROCESS_TIME)) {
|
||||
return k_EBeginAuthSessionResultDuplicateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
inbound.push_back(data);
|
||||
launch_callback(steamID, k_EAuthSessionResponseOK);
|
||||
launch_callback(steamID, k_EAuthSessionResponseOK, STEAM_TICKET_PROCESS_TIME);
|
||||
return k_EBeginAuthSessionResultOK;
|
||||
}
|
||||
|
||||
|
@ -402,12 +405,18 @@ uint32 Auth_Ticket_Manager::countInboundAuth()
|
|||
|
||||
bool Auth_Ticket_Manager::endAuth(CSteamID id)
|
||||
{
|
||||
auto ticket = std::find_if(inbound.begin(), inbound.end(), [&id](Auth_Ticket_Data const& item) { return item.id == id; });
|
||||
if (inbound.end() == ticket)
|
||||
return false;
|
||||
bool erased = false;
|
||||
auto t = std::begin(inbound);
|
||||
while (t != std::end(inbound)) {
|
||||
if (t->id == id) {
|
||||
erased = true;
|
||||
t = inbound.erase(t);
|
||||
} else {
|
||||
++t;
|
||||
}
|
||||
}
|
||||
|
||||
inbound.erase(ticket);
|
||||
return true;
|
||||
return erased;
|
||||
}
|
||||
|
||||
void Auth_Ticket_Manager::Callback(Common_Message *msg)
|
||||
|
@ -438,6 +447,7 @@ void Auth_Ticket_Manager::Callback(Common_Message *msg)
|
|||
auto t = std::begin(inbound);
|
||||
while (t != std::end(inbound)) {
|
||||
if (t->id.ConvertToUint64() == msg->source_id() && t->number == number) {
|
||||
PRINT_DEBUG("TICKET CANCELED\n");
|
||||
launch_callback(t->id, k_EAuthSessionResponseAuthTicketCanceled);
|
||||
t = inbound.erase(t);
|
||||
} else {
|
||||
|
|
|
@ -413,6 +413,7 @@ public:
|
|||
struct Auth_Ticket_Data {
|
||||
CSteamID id;
|
||||
uint64 number;
|
||||
std::chrono::high_resolution_clock::time_point created;
|
||||
};
|
||||
|
||||
class Auth_Ticket_Manager {
|
||||
|
@ -420,7 +421,7 @@ class Auth_Ticket_Manager {
|
|||
class Networking *network;
|
||||
class SteamCallBacks *callbacks;
|
||||
|
||||
void launch_callback(CSteamID id, EAuthSessionResponse resp);
|
||||
void launch_callback(CSteamID id, EAuthSessionResponse resp, double delay=0);
|
||||
void launch_callback_gs(CSteamID id, bool approved);
|
||||
std::vector<struct Auth_Ticket_Data> inbound, outbound;
|
||||
public:
|
||||
|
|
|
@ -760,7 +760,7 @@ const char *GetLobbyData( CSteamID steamIDLobby, const char *pchKey )
|
|||
// other users in the lobby will receive notification of the lobby data change via a LobbyDataUpdate_t callback
|
||||
bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue )
|
||||
{
|
||||
PRINT_DEBUG("SetLobbyData %s %s\n", pchKey, pchValue);
|
||||
PRINT_DEBUG("SetLobbyData %llu %s %s\n", steamIDLobby.ConvertToUint64(), pchKey, pchValue);
|
||||
if (!pchKey) return false;
|
||||
char empty_string[] = "";
|
||||
if (!pchValue) pchValue = empty_string;
|
||||
|
|
Loading…
Reference in a new issue