mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-17 12:03:07 +01:00
Fix out of bounds access opening the in-game console at startup (#10197)
This commit is contained in:
committed by
Michał Janiszewski
parent
fef1906d0d
commit
7e279d37cd
@@ -127,7 +127,11 @@ void InGameConsole::HistoryAdd(const utf8* src)
|
||||
|
||||
void InGameConsole::ScrollToEnd()
|
||||
{
|
||||
_consoleScrollPos = std::max<int32_t>(0, (int32_t)_consoleLines.size() - GetNumVisibleLines());
|
||||
const int32_t maxLines = GetNumVisibleLines();
|
||||
if (maxLines == 0)
|
||||
_consoleScrollPos = 0;
|
||||
else
|
||||
_consoleScrollPos = std::max<int32_t>(0, (int32_t)_consoleLines.size() - maxLines);
|
||||
}
|
||||
|
||||
void InGameConsole::RefreshCaret()
|
||||
@@ -349,6 +353,8 @@ int32_t InGameConsole::GetNumVisibleLines() const
|
||||
{
|
||||
const int32_t lineHeight = font_get_line_height(gCurrentFontSpriteBase);
|
||||
const int32_t consoleHeight = _consoleBottom - _consoleTop;
|
||||
if (consoleHeight == 0)
|
||||
return 0;
|
||||
const int32_t drawableHeight = consoleHeight - 2 * lineHeight - 4; // input line, separator - padding
|
||||
return drawableHeight / lineHeight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user