From 96e7444c772a93cd5466bda97bfc7161af46a9c4 Mon Sep 17 00:00:00 2001 From: TechnikTil <89487150+TechnikTil@users.noreply.github.com> Date: Sun, 8 Dec 2024 04:14:23 -0700 Subject: [PATCH] get default avatar instead of not showing anything (#88) --- source/online/network/FunkinNetwork.hx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/online/network/FunkinNetwork.hx b/source/online/network/FunkinNetwork.hx index 0591479d..eafb9692 100644 --- a/source/online/network/FunkinNetwork.hx +++ b/source/online/network/FunkinNetwork.hx @@ -262,13 +262,31 @@ class FunkinNetwork { }); if (avatarResponse == null) - return null; + return getDefaultAvatar(); try { var bytes = output.getBytes(); cacheAvatar.set(user, bytes); return BitmapData.fromBytes(bytes); } + catch (exc) { + trace(exc); + return getDefaultAvatar(); + } + } + + public static function getDefaultAvatar():BitmapData + { + var output = new BytesOutput(); + var avatarResponse = FunkinNetwork.requestAPI({ + path: 'images/bf' + FlxG.random.int(1, 2) + ".png", + bodyOutput: output + }); + + try { + var bytes = output.getBytes(); + return BitmapData.fromBytes(bytes); + } catch (exc) { trace(exc); return null;