From 48cbee5972a0e5ee69f9ee2903181dc42df399f6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 19 Dec 2024 18:41:14 +0300 Subject: final code cleaning + version bump --- protocols/Steam/src/protobuf-c/protobuf-c-text.cpp | 8 ++++---- protocols/Steam/src/steam_contacts.cpp | 12 ++++++------ protocols/Steam/src/steam_history.cpp | 2 +- protocols/Steam/src/steam_messages.cpp | 3 --- protocols/Steam/src/steam_proto.cpp | 2 +- protocols/Steam/src/steam_proto.h | 4 ++-- protocols/Steam/src/steam_server.cpp | 8 ++++---- protocols/Steam/src/steam_ws.cpp | 6 +++--- protocols/Steam/src/version.h | 2 +- 9 files changed, 22 insertions(+), 25 deletions(-) (limited to 'protocols/Steam/src') diff --git a/protocols/Steam/src/protobuf-c/protobuf-c-text.cpp b/protocols/Steam/src/protobuf-c/protobuf-c-text.cpp index 44fa0b7232..1a4a858218 100644 --- a/protocols/Steam/src/protobuf-c/protobuf-c-text.cpp +++ b/protocols/Steam/src/protobuf-c/protobuf-c-text.cpp @@ -202,14 +202,14 @@ static void protobuf_c_text_to_string_internal( if (f[i].label == PROTOBUF_C_LABEL_REPEATED) { for (j = 0; j < quantifier_offset; j++) { str.AppendFormat( - "%*s%s: %lu\n", + "%*s%s: %lld\n", level, "", f[i].name, STRUCT_MEMBER(uint64_t *, m, f[i].offset)[j]); } } else { str.AppendFormat( - "%*s%s: %lu\n", + "%*s%s: %lld\n", level, "", f[i].name, STRUCT_MEMBER(uint64_t, m, f[i].offset)); } @@ -219,14 +219,14 @@ static void protobuf_c_text_to_string_internal( if (f[i].label == PROTOBUF_C_LABEL_REPEATED) { for (j = 0; j < quantifier_offset; j++) { str.AppendFormat( - "%*s%s: %ld\n", + "%*s%s: %lld\n", level, "", f[i].name, STRUCT_MEMBER(int64_t *, m, f[i].offset)[j]); } } else { str.AppendFormat( - "%*s%s: %ld\n", + "%*s%s: %lld\n", level, "", f[i].name, STRUCT_MEMBER(int64_t, m, f[i].offset)); } diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp index ce62518054..9a0cd603a6 100644 --- a/protocols/Steam/src/steam_contacts.cpp +++ b/protocols/Steam/src/steam_contacts.cpp @@ -259,7 +259,7 @@ void CSteamProto::ContactIsAskingAuth(MCONTACT hContact) // create auth request event uint64_t id(GetId(hContact, DBKEY_STEAM_ID)); - SendUserInfoRequest(id, true); + SendUserInfoRequest(id); char steamId[100]; _i64toa(id, steamId, 10); @@ -363,12 +363,12 @@ void CSteamProto::OnGotFriendList(const CMsgClientFriendsList &reply, const CMsg std::map friendsMap; for (int i = 0; i < reply.n_friends; i++) { auto *F = reply.friends[i]; - friendsMap[F->ulfriendid | 0x110000100000000ll] = FriendRelationship(F->efriendrelationship); + friendsMap[F->ulfriendid] = FriendRelationship(F->efriendrelationship); } // Comma-separated list of steam ids to update summaries std::vector ids; - ids.push_back(GetId(DBKEY_STEAM_ID) & 0xFFFFFFFFll); + ids.push_back(GetId(DBKEY_STEAM_ID)); // Check and update contacts in database for (auto &hContact : AccContacts()) { @@ -389,7 +389,7 @@ void CSteamProto::OnGotFriendList(const CMsgClientFriendsList &reply, const CMsg // Do not update summary for non friends if (it->second == FriendRelationship::Friend) - ids.push_back(it->first & 0xFFFFFFFFll); + ids.push_back(it->first); friendsMap.erase(it); } @@ -401,12 +401,12 @@ void CSteamProto::OnGotFriendList(const CMsgClientFriendsList &reply, const CMsg UpdateContactRelationship(hContact, it.second); if (it.second == FriendRelationship::Friend) - ids.push_back(it.first & 0xFFFFFFFFll); + ids.push_back(it.first); } friendsMap.clear(); if (!ids.empty()) - SendUserInfoRequest(ids, true); + SendUserInfoRequest(ids); // Load last conversations SendFriendActiveSessions(); diff --git a/protocols/Steam/src/steam_history.cpp b/protocols/Steam/src/steam_history.cpp index bbb1239aa1..8158c9e4c6 100644 --- a/protocols/Steam/src/steam_history.cpp +++ b/protocols/Steam/src/steam_history.cpp @@ -8,7 +8,7 @@ void CSteamProto::OnGotConversations(const CFriendsMessagesGetActiveMessageSessi for (int i=0; i < reply.n_message_sessions; i++) { auto *session = reply.message_sessions[i]; - uint64_t steamId = AccountIdToSteamId(session->accountid_friend); + uint64_t steamId = session->accountid_friend; MCONTACT hContact = GetContact(steamId); if (!hContact) continue; diff --git a/protocols/Steam/src/steam_messages.cpp b/protocols/Steam/src/steam_messages.cpp index 47a7504088..b6a4ee7bc3 100644 --- a/protocols/Steam/src/steam_messages.cpp +++ b/protocols/Steam/src/steam_messages.cpp @@ -2,11 +2,8 @@ void CSteamProto::SendFriendMessage(uint32_t msgId, int64_t steamId, const char *pszMessage) { - CMStringA szId(FORMAT, "%d", msgId); - CFriendMessagesSendMessageRequest request; request.chat_entry_type = (int)EChatEntryType::ChatMsg; request.has_chat_entry_type = true; - request.client_message_id = szId.GetBuffer(); request.contains_bbcode = request.has_contains_bbcode = true; request.steamid = steamId; request.has_steamid = true; request.message = (char *)pszMessage; diff --git a/protocols/Steam/src/steam_proto.cpp b/protocols/Steam/src/steam_proto.cpp index 4c9ce15628..c61ba628cd 100644 --- a/protocols/Steam/src/steam_proto.cpp +++ b/protocols/Steam/src/steam_proto.cpp @@ -89,7 +89,7 @@ MCONTACT CSteamProto::AddToList(int, PROTOSEARCHRESULT *psr) uint64_t id = _wtoi64(psr->id.w); MCONTACT hContact = AddContact(id, psr->nick.w, true); - SendUserInfoRequest(id, true); + SendUserInfoRequest(id); return hContact; } diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h index 45f829197b..17d62c3a75 100644 --- a/protocols/Steam/src/steam_proto.h +++ b/protocols/Steam/src/steam_proto.h @@ -191,8 +191,8 @@ class CSteamProto : public PROTO void SetAllContactStatuses(int status); void SetContactStatus(MCONTACT hContact, uint16_t status); - void SendUserInfoRequest(uint64_t id, bool bRetrieveState); - void SendUserInfoRequest(const std::vector &ids, bool bRetrieveState); + void SendUserInfoRequest(uint64_t id); + void SendUserInfoRequest(const std::vector &ids); void SendUserAddRequest(uint64_t id); void SendUserRemoveRequest(MCONTACT hContact); diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp index 91ad4762f9..3efa43764b 100644 --- a/protocols/Steam/src/steam_server.cpp +++ b/protocols/Steam/src/steam_server.cpp @@ -51,17 +51,17 @@ void CSteamProto::SendFriendActiveSessions() ///////////////////////////////////////////////////////////////////////////////////////// -void CSteamProto::SendUserInfoRequest(uint64_t id, bool bRetrieveState) +void CSteamProto::SendUserInfoRequest(uint64_t id) { std::vector ids; ids.push_back(id & 0xFFFFFFFFll); - SendUserInfoRequest(ids, bRetrieveState); + SendUserInfoRequest(ids); } -void CSteamProto::SendUserInfoRequest(const std::vector &ids, bool bRetrieveState) +void CSteamProto::SendUserInfoRequest(const std::vector &ids) { CMsgClientRequestFriendData request; - request.persona_state_requested = bRetrieveState; request.has_persona_state_requested = true; + request.persona_state_requested = -1; request.has_persona_state_requested = true; request.n_friends = ids.size(); request.friends = (uint64_t*)&*ids.begin(); WSSend(EMsg::ClientRequestFriendData, request); diff --git a/protocols/Steam/src/steam_ws.cpp b/protocols/Steam/src/steam_ws.cpp index d9a90adeab..c4994c0041 100644 --- a/protocols/Steam/src/steam_ws.cpp +++ b/protocols/Steam/src/steam_ws.cpp @@ -274,7 +274,7 @@ void CSteamProto::WSSendHeader(EMsg msgType, const CMsgProtoBufHeader &hdr, cons uint32_t hdrLen = (uint32_t)protobuf_c_message_get_packed_size(&hdr); MBinBuffer hdrbuf(hdrLen); - protobuf_c_message_pack(&hdr, (uint8_t *)hdrbuf.data()); + protobuf_c_message_pack(&hdr, hdrbuf.data()); hdrbuf.appendBefore(&hdrLen, sizeof(hdrLen)); uint32_t type = (uint32_t)msgType; @@ -292,11 +292,11 @@ int64_t CSteamProto::WSSendService(const char *pszServiceName, const ProtobufCpp { CMsgProtoBufHeader hdr; hdr.has_client_sessionid = hdr.has_steamid = hdr.has_jobid_source = hdr.has_jobid_target = true; - hdr.client_sessionid = bAnon ? 0 : m_iSessionId; + if (!bAnon) + hdr.steamid = m_iSteamId, hdr.client_sessionid = m_iSessionId; hdr.jobid_source = getRandomInt(); hdr.jobid_target = -1; hdr.target_job_name = (char *)pszServiceName; - hdr.realm = 1; hdr.has_realm = true; WSSendHeader(bAnon ? EMsg::ServiceMethodCallFromClientNonAuthed : EMsg::ServiceMethodCallFromClient, hdr, msg); return hdr.jobid_source; diff --git a/protocols/Steam/src/version.h b/protocols/Steam/src/version.h index a6ea2cad32..1b4c2a16c8 100644 --- a/protocols/Steam/src/version.h +++ b/protocols/Steam/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 96 #define __RELEASE_NUM 1 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3