Skip to content

Commit 6729406

Browse files
committed
fix: super-rare toast disappearing bug
don't know why it was so rare / somehow config dependent? but here we are
1 parent aec0063 commit 6729406

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Features/Hud/Toasts.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ struct Toast {
4848
static std::deque<Toast> g_toasts;
4949

5050
static std::chrono::time_point<std::chrono::steady_clock> g_slideOffTime;
51-
static int g_slideOffStart;
52-
static int g_slideOff;
51+
static int g_slideOffStart = 0;
52+
static int g_slideOff = 0;
5353

5454
#define STR(s) #s
5555
#define EXP_STR(s) STR(s)
@@ -364,10 +364,18 @@ void ToastHud::Update() {
364364
int screenWidth, screenHeight;
365365
engine->GetScreenSize(nullptr, screenWidth, screenHeight);
366366

367-
g_slideOff = g_slideOffStart - SLIDE_RATE * std::chrono::duration_cast<std::chrono::milliseconds>(now - g_slideOffTime).count() * screenHeight / 1000 / 1000;
368-
if (g_slideOff < 0) {
367+
if (g_slideOffStart != 0) {
368+
g_slideOff = g_slideOffStart - SLIDE_RATE * std::chrono::duration_cast<std::chrono::milliseconds>(now - g_slideOffTime).count() * screenHeight / 1000 / 1000;
369+
if (g_slideOff < 0) {
370+
g_slideOff = 0;
371+
}
372+
} else {
369373
g_slideOff = 0;
370374
}
375+
if (g_slideOff > 2 * screenHeight) {
376+
console->Print("Safety check triggered on toast slide\n");
377+
g_slideOff = 2 * screenHeight; // Stupid BUG!
378+
}
371379
}
372380

373381
void ToastHud::Paint(int slot) {

0 commit comments

Comments
 (0)