From 377ab97b886cf984f8488c27fd39068a1b6985fa Mon Sep 17 00:00:00 2001 From: Til Tjardes Date: Sat, 7 Dec 2024 22:18:46 -0700 Subject: [PATCH] get default avatar instead of not showing anything --- 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;