From 1841f1886a4667a6cf26ee14ebc98a2be56ee07c Mon Sep 17 00:00:00 2001 From: Misa Date: Fri, 6 Aug 2021 21:06:04 -0700 Subject: [PATCH] Do not close game if fallback character is missing It's quite rude to close the game. Especially if the user does not use the console. They won't know why the game closed. Instead, just return -1. All usages of font_idx() should be and are bounds checked anyways. This will result in missing characters, but, it's not like the characters had a font image in the first place, otherwise we wouldn't be here. And if the user sees a bunch of characters missing in their font, they'll probably work out what the problem is even without having a console. And it's still far better than abruptly closing the game. And use WHINE_ONCE to prevent spamming the console. --- desktop_version/src/Graphics.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 73e25e8e..02c38b8d 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -258,8 +258,8 @@ int Graphics::font_idx(uint32_t ch) iter = font_positions.find('?'); if (iter == font_positions.end()) { - puts("font.txt missing fallback character!"); - VVV_exit(1); + WHINE_ONCE("font.txt missing fallback character!"); + return -1; } } return iter->second;