Forum

> > CS2D > General > USGN Avatar won't load
Forums overviewCS2D overviewGeneral overviewLog in to reply

English USGN Avatar won't load

13 replies
To the start Previous 1 Next To the start

old USGN Avatar won't load

Ratatatat OP
User Off Offline

Quote
Even when I faced the thread where question already answered but, when I tried both two ways from that thread,nothing has worked and I wrote this to meet someone,who can help me with this that's what kind of problem it is: Always when I start game on my CS2D server my avatar looks like that us ,despite that I changed my avatar,it won't load my avatar from USGN

Please answer this question

old Re: USGN Avatar won't load

DC
Admin Off Offline

Quote
In-game UnrealSoftware.de avatar download is currently broken because I switched to HTTPS. Will try to fix it.

old Re: USGN Avatar won't load

DC
Admin Off Offline

Quote
Should work again

Edit:
Okay, no. It doesn't work.

Edit²:
Okay... finally fixed it.
I looked at the wrong code in CS2D. The relevant parts do not set "CS2D" as user agent. They don't set a user agent at all. Therefore my webserver setting which checks the user agent had no effect and kept redirecting to HTTPS.

I now adjusted the webserver rule for UnrealSoftware.de to only redirect to HTTPS if any user agent is set. If no user agent HTTP header is set the automatic HTTPS-redirect won't take place, allowing CS2D to access unrealsoftware.de data via plain old HTTP.

Hooray!

If you STILL experience problems with this please let me know!
edited 3×, last 08.08.20 09:43:37 am

old Maybe slightly off topic

saint-
User Off Offline

Quote
I experienced a similar problem with the spraylogo. On my screen the spraylogo would be my custom spraylogo, but others see my spray logo as the standard U spraylogo.

Wrote it here because reading this thread reminded me of that and maybe it could be a similar problem.

old Re: USGN Avatar won't load

gloryS
User Off Offline

Quote
Me too i have this bug with avatar and from my steam account. i change steam avatar but in game is don't change is keeping old avatar

old Re: USGN Avatar won't load

DC
Admin Off Offline

Quote
@user gloryS: That's another issue. CS2D caches all avatars and never loads them twice. So if someone changes an avatar you already loaded, it won't be changed for you.

You can manually enforce a reload by deleting the following folder and all of its contents:
sys/cache/avatars/steam

it's relative to the folder where you installed CS2D.

@user saint-: The spray logo is transferred directly via the game server using UDP. So this certainly isn't related to the HTTPS problems.
edited 1×, last 08.09.20 06:15:46 pm

old Re: USGN Avatar won't load

mrc
User Off Offline

Quote
is possible to add a button or something in the options>net tab to clear/delete avatars cache? I would also suggest an option to clear minimaps cache.

old Re: USGN Avatar won't load

mrc
User Off Offline

Quote
@user DC: ,
By any chance, did the in-game (USGN) avatar download break after this:
https://unrealsoftware.de/news.php?show=433764

I noticed another issue regarding the Steam avatar JSON files.

The references inside the JSON files appear to be correct, and the avatar URLs listed in them are accessible and working. However, when I try to open the downloaded JPG avatar files, Windows reports that the file format is not supported.

Specifically, when opening the image, I get the message:

"This file format is not supported."

And when I try to open it with Paint, I get:

"Paint can't read this file. This is not a valid bitmap file, or its format is not currently supported."

Because of this, it seems that the avatar files themselves may be corrupted or not being downloaded correctly, even though the URLs referenced in the JSON files are valid and accessible.

Also, could the Steam installation path have any influence on this issue? For example, would installing Steam in a custom directory instead of the default location affect avatar downloading or processing in any way?

old Re: USGN Avatar won't load

DC
Admin Off Offline

Quote
@user mrc: It is very possible that the server move broke it. The problem is that the avatar download needs to work via HTTP not via HTTPS because CS2D doesn't support HTTPS at all. The web server is still configured to allow HTTP if it's the CS2D client but maybe it broke something with that config.

What happens if you open the broken file with a text editor? Wouldn't surprise me if it would just contain a HTTP response code / error.

Edit:
I deleted my avatar cache (whole sys/cache/avatars folder) and it just re-downloaded and displayed my avatar without any issues. So it's working in general.

@user Gennadiy: you may have to delete your sys/cache/avatars
@user mrc: Not sure what happens on your system. like I said would be interesting to see the actual content of the cached files

old Re: USGN Avatar won't load

mrc
User Off Offline

Quote
@user DC: ,

I've fully isolated the issue. There are two separate problems – one on Steam's server side, and one in the game's engine logic.

1. The 404 error when downloading the Steam avatar (HTTPS issue):
The Steam JSON downloads correctly, but when the game tries to download the actual JPG image (e.g., https://avatars.steamstatic.com/...), CS2D forces the HTTP protocol. Valve's server (Nginx) does not serve these images over plain HTTP – it returns a 404 Not Found HTML page instead.

Proof: I opened the cached .jpg file (sys/cache/avatars/steam) with Notepad++, and its content is exactly this:
1
2
3
4
5
6
7
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
So the game is saving an HTML error page as if it were a JPG, which is why Windows/Paint says the format is unsupported.

2. The engine's fallback skips the USGN download step (logic flaw):
When I'm logged in only with USGN, the game downloads my USGN avatar perfectly and caches it as u_ava/u956_65863bf3.jpg.

However, when I'm logged in with Steam + USGN, the game tries Steam, fails (due to the 404), and instead of checking the USGN cache or attempting to download the USGN avatar, it jumps straight to the default (generic) UnrealSoftware icon.

Current (wrong) flow:
1
Try Steam -> Fail (404) -> Show default USGN icon
(completely ignores USGN).

Correct flow (should be):
1
Try Steam -> Fail (404) -> Check if USGN cache exists -> If yes, load it; if not, DOWNLOAD from USGN -> If USGN download also fails, then show default icon.

In short: when Steam is logged in, the engine prevents the USGN avatar from ever being used — it neither checks for an existing cache nor attempts to download it, jumping straight to the default icon.

---

Suggested fixes:

A) Server-side (HTTP → HTTPS proxy):
Create an endpoint on the UnrealSoftware server that receives only the avatar hash (e.g., http://unrealsoftware.de/steam_avatar.php?hash=...), internally fetches the image via HTTPS using cURL, and returns the raw JPG bytes over plain HTTP to CS2D.

I already have a ready‑to‑use script for this, which also includes local disk caching to avoid hammering Steam or your server:

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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/**
 * Steam Avatar Proxy for CS2D
 * 
 * Usage: http://unrealsoftware.de/steam_avatar.php?hash=AVATAR_HASH
 * Example: http://unrealsoftware.de/steam_avatar.php?hash=dca845a92112987f3b20426cb4169b1cec15eb7e
 * 
 * Returns the JPG avatar image (full size) over plain HTTP.
 */

// ============================================================
// CONFIGURATION
// ============================================================

// Maximum execution time (seconds)
$timeout = 10;

// Local cache directory (create with write permissions)
$cache_dir = __DIR__ . '/cache_steam_avatars/';

// Avatar size: 'full' (default), 'medium', or 'small'
$avatar_size = 'full';

// ============================================================
// HASH VALIDATION
// ============================================================

if (!isset($_GET['hash'])) {
    http_response_code(400);
    die('Missing hash parameter');
}

$hash = $_GET['hash'];

// Remove any non-hexadecimal characters (security)
$hash = preg_replace('/[^a-f0-9]/', '', strtolower($hash));

// Steam hashes are 40-character hex strings (SHA1)
if (strlen($hash) !== 40) {
    http_response_code(400);
    die('Invalid hash format');
}

// ============================================================
// BUILD STEAM URL (FIXED AND SECURE DOMAIN)
// ============================================================

$avatar_url = "https://avatars.steamstatic.com/" . $hash . '_' . $avatar_size . '.jpg';

// ============================================================
// LOCAL CACHE
// ============================================================

if ($cache_dir) {
    if (!is_dir($cache_dir)) {
        mkdir($cache_dir, 0755, true);
    }

    $cache_file = $cache_dir . $hash . '_' . $avatar_size . '.jpg';

    // If cached file exists and is younger than 7 days, serve it directly
    if (file_exists($cache_file) && (time() - filemtime($cache_file) < 604800)) {
        $image_data = file_get_contents($cache_file);
        if ($image_data !== false) {
            header('Content-Type: image/jpeg');
            header('X-Cache: HIT');
            http_response_code(200);
            echo $image_data;
            exit;
        }
    }
}

// ============================================================
// DOWNLOAD VIA CURL (HTTPS)
// ============================================================

$ch = curl_init($avatar_url);

curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_CONNECTTIMEOUT => $timeout,
    CURLOPT_TIMEOUT        => $timeout,
    CURLOPT_USERAGENT      => 'CS2D-Steam-Avatar-Proxy/1.0 (+https://unrealsoftware.de)',
    CURLOPT_SSL_VERIFYPEER => true,
    CURLOPT_SSL_VERIFYHOST => 2,
]);

$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);

if ($response === false) {
    http_response_code(502);
    die('Curl error: ' . curl_error($ch));
}
curl_close($ch);

// ============================================================
// VALIDATE STEAM RESPONSE
// ============================================================

if ($http_code !== 200) {
    http_response_code($http_code);
    die('Steam returned HTTP ' . $http_code);
}

// Ensure Steam returned an actual image, not an error page
if (!str_starts_with($content_type, 'image/')) {
    http_response_code(502);
    die('Steam returned non-image content: ' . $content_type);
}

// ============================================================
// SAVE TO LOCAL CACHE
// ============================================================

if ($cache_dir && isset($cache_file)) {
    file_put_contents($cache_file, $response);
}

// ============================================================
// RETURN IMAGE TO CLIENT (CS2D)
// ============================================================

header('Content-Type: ' . $content_type);
header('X-Cache: MISS');
http_response_code(200);
echo $response;
exit;

B) Client-side (CS2D engine):
Adjust the fallback order. If the Steam avatar download/decoding fails (or returns HTML), the game must run the normal USGN routine (check cache + download from USGN if needed) before giving up and showing the default icon.

---

With the proxy deployed and that engine tweak, the issue should be completely solved.

What do you think? If you'd like, I can test the proxy as soon as you put it up on the server.
edited 2×, last 23.06.26 07:40:39 pm

old Re: USGN Avatar won't load

DC
Admin Off Offline

Quote
That the file just contains the error is exactly what I expected. Steam must have dropped HTTP support then. Which makes sense. Nobody really uses it anymore. I don't really want to setup a proxy script for Steam avatars and cache all the avatars on my server.

I guess the best option is to entirely disable Steam avatar support for now.

Thank you for your support and input though.

old Re: USGN Avatar won't load

mrc
User Off Offline

Quote
No problems, I think I can use reqhttp and hosting the proxy myself for now.

@edit Yes, it works! Fixed avatars once and for all (but in my server only).
edited 2×, last 24.06.26 12:35:23 am
To the start Previous 1 Next To the start
Log in to replyGeneral overviewCS2D overviewForums overview