summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-12-27 19:49:45 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-12-27 19:49:45 +0300
commit1b9a0663b03e8225afe0f5f40a4949dbd4adc798 (patch)
tree8ad74daaa962cb07d0466a203ad758cf39506c0d /protocols/Steam/src
parent02260169dc542a2134438ec5d24eda2eb146d486 (diff)
Steam: fix for avatars fetching
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/api/avatar.h13
-rw-r--r--protocols/Steam/src/stdafx.h1
-rw-r--r--protocols/Steam/src/steam_avatars.cpp7
-rw-r--r--protocols/Steam/src/steam_contacts.cpp11
-rw-r--r--protocols/Steam/src/steam_utils.cpp11
-rw-r--r--protocols/Steam/src/steam_utils.h2
6 files changed, 24 insertions, 21 deletions
diff --git a/protocols/Steam/src/api/avatar.h b/protocols/Steam/src/api/avatar.h
deleted file mode 100644
index 4140583ead..0000000000
--- a/protocols/Steam/src/api/avatar.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _STEAM_REQUEST_AVATAR_H_
-#define _STEAM_REQUEST_AVATAR_H_
-
-struct GetAvatarRequest : public HttpRequest
-{
- GetAvatarRequest(const char *url) :
- HttpRequest(REQUEST_GET, url)
- {
- flags = NLHRF_HTTP11 | NLHRF_NODUMP;
- }
-};
-
-#endif //_STEAM_REQUEST_AVATAR_H_
diff --git a/protocols/Steam/src/stdafx.h b/protocols/Steam/src/stdafx.h
index 7dbc349381..48b7ac38d1 100644
--- a/protocols/Steam/src/stdafx.h
+++ b/protocols/Steam/src/stdafx.h
@@ -75,7 +75,6 @@ extern HANDLE hExtraXStatus;
#include "steam_proto.h"
#include "steam_utils.h"
-#include "api/avatar.h"
#include "api/captcha.h"
#include "api/friend.h"
#include "api/pending.h"
diff --git a/protocols/Steam/src/steam_avatars.cpp b/protocols/Steam/src/steam_avatars.cpp
index 022ec914c5..762a06d368 100644
--- a/protocols/Steam/src/steam_avatars.cpp
+++ b/protocols/Steam/src/steam_avatars.cpp
@@ -54,8 +54,8 @@ INT_PTR CSteamProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
PROTO_AVATAR_INFORMATION *pai = (PROTO_AVATAR_INFORMATION *)lParam;
- ptrA avatarUrl(getStringA(pai->hContact, "AvatarUrl"));
- if (!avatarUrl)
+ ptrA avatarHash(getStringA(pai->hContact, "AvatarHash"));
+ if (!avatarHash)
return GAIR_NOAVATAR;
if (GetDbAvatarInfo(*pai)) {
@@ -68,7 +68,8 @@ INT_PTR CSteamProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
needLoad = (wParam & GAIF_FORCE) || !fileExist;
if (needLoad) {
- SendRequest(new GetAvatarRequest(avatarUrl), &CSteamProto::OnGotAvatar, (void *)pai->hContact);
+ CMStringA szUrl(FORMAT, "https://avatars.steamstatic.com/%s_full.jpg", avatarHash.get());
+ SendRequest(new HttpRequest(REQUEST_GET, szUrl), &CSteamProto::OnGotAvatar, (void *)pai->hContact);
return GAIR_WAITFOR;
}
if (fileExist)
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index da654dfa3e..901ea8d771 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -102,10 +102,13 @@ void CSteamProto::OnGotFriendInfo(const CMsgClientPersonaState &reply, const CMs
// avatar
if (F->avatar_hash.len != 0) {
- CMStringA szHash;
- szHash.Truncate(int(F->avatar_hash.len) * 2 + 1);
- bin2hex(F->avatar_hash.data, F->avatar_hash.len, szHash.GetBuffer());
- CheckAvatarChange(hContact, szHash);
+ if (!IsNull(F->avatar_hash)) {
+ CMStringA szHash;
+ szHash.Truncate(int(F->avatar_hash.len) * 2 + 1);
+ bin2hex(F->avatar_hash.data, F->avatar_hash.len, szHash.GetBuffer());
+ CheckAvatarChange(hContact, szHash);
+ }
+ else CheckAvatarChange(hContact, 0);
}
else CheckAvatarChange(hContact, 0);
diff --git a/protocols/Steam/src/steam_utils.cpp b/protocols/Steam/src/steam_utils.cpp
index 9666316ceb..b8b15f5db8 100644
--- a/protocols/Steam/src/steam_utils.cpp
+++ b/protocols/Steam/src/steam_utils.cpp
@@ -9,6 +9,17 @@ uint64_t getRandomInt()
/////////////////////////////////////////////////////////////////////////////////////////
+bool IsNull(const ProtobufCBinaryData &buf)
+{
+ for (auto i = 0; i < buf.len; i++)
+ if (buf.data[i] != 0)
+ return false;
+
+ return true;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MBinBuffer createMachineID(const char *accName)
{
uint8_t hashOut[MIR_SHA1_HASH_SIZE];
diff --git a/protocols/Steam/src/steam_utils.h b/protocols/Steam/src/steam_utils.h
index 29ac97b1e2..6762f89f99 100644
--- a/protocols/Steam/src/steam_utils.h
+++ b/protocols/Steam/src/steam_utils.h
@@ -12,6 +12,8 @@ MBinBuffer createMachineID(const char *accName);
#define now() time(0)
+bool IsNull(const ProtobufCBinaryData &buf);
+
uint64_t getRandomInt();
CMStringA protobuf_c_text_to_string(const ProtobufCMessage &msg);