1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

Fix read keyboard config error

Do not try to read more keyboard shortcuts than there actually are.
This commit is contained in:
Ted John
2017-06-30 19:11:32 +01:00
parent 0224ca5ca0
commit 9b2777bc56

View File

@@ -53,6 +53,7 @@ void KeyboardShortcuts::Reset()
bool KeyboardShortcuts::Load()
{
bool result = false;
Reset();
try
{
std::string path = _env->GetFilePath(PATHID::CONFIG_KEYBOARD);
@@ -62,7 +63,9 @@ bool KeyboardShortcuts::Load()
uint16 version = fs.ReadValue<uint16>();
if (version == KeyboardShortcuts::CURRENT_FILE_VERSION)
{
for (sint32 i = 0; i < SHORTCUT_COUNT; i++)
sint32 numShortcutsInFile = (fs.GetLength() - sizeof(uint16)) / sizeof(uint16);
sint32 numShortcutsToRead = std::min<sint32>(SHORTCUT_COUNT, numShortcutsInFile);
for (sint32 i = 0; i < numShortcutsToRead; i++)
{
_keys[i] = fs.ReadValue<uint16>();
}