From 041d540c6f5f5b6720341486dca840fe48c647c0 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 9 Feb 2020 01:39:48 +0000 Subject: [PATCH] Fix credit lines pop-in +1 should +2 (+1 for rounding-up and +1 for an extra line) Fixes #585 --- SourceX/DiabloUI/credits.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SourceX/DiabloUI/credits.cpp b/SourceX/DiabloUI/credits.cpp index 1ddce964d..485c67cae 100644 --- a/SourceX/DiabloUI/credits.cpp +++ b/SourceX/DiabloUI/credits.cpp @@ -21,6 +21,11 @@ constexpr int SHADOW_OFFSET_X = 2; constexpr int SHADOW_OFFSET_Y = 2; constexpr int LINE_H = 22; +// The maximum number of visible lines is the number of whole lines +// (VIEWPORT.h / LINE_H) rounded up, plus one extra line for when +// a line is leaving the screen while another one is entering. +#define MAX_VISIBLE_LINES ((VIEWPORT.h - 1) / LINE_H + 2) + struct SurfaceDeleter { void operator()(SDL_Surface *surface) { @@ -162,7 +167,7 @@ class CreditsRenderer { public: CreditsRenderer() - : lines_(VIEWPORT.h / LINE_H + 1) + : lines_(MAX_VISIBLE_LINES) , finished_(false) , prev_offset_y_(0) @@ -204,7 +209,7 @@ void CreditsRenderer::Render() return; const std::size_t lines_begin = std::max(offset_y / LINE_H, 0); - const std::size_t lines_end = std::min(lines_begin + (VIEWPORT.h - 1) / LINE_H + 1, CREDITS_LINES_SIZE); + const std::size_t lines_end = std::min(lines_begin + MAX_VISIBLE_LINES, CREDITS_LINES_SIZE); if (lines_begin >= lines_end) { if (lines_end == CREDITS_LINES_SIZE)