1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-03 01:11:32 +00:00

Merge branch 'retrievallimitcheck' into 'master'

Fixes Game crash when "console history buffer size" is set to 0

Closes #7276

See merge request OpenMW/openmw!2833
This commit is contained in:
psi29a 2023-03-15 10:26:40 +00:00
commit 49db6cbcc2

View file

@ -709,10 +709,11 @@ namespace MWGui
const auto filePath = mCfgMgr.getUserConfigPath() / "console_history.txt"; const auto filePath = mCfgMgr.getUserConfigPath() / "console_history.txt";
const size_t retrievalLimit = Settings::Manager::getSize("console history buffer size", "General"); const size_t retrievalLimit = Settings::Manager::getSize("console history buffer size", "General");
// Read the previous session's commands from the file
if (retrievalLimit > 0)
{
std::ifstream historyFile(filePath); std::ifstream historyFile(filePath);
std::string line; std::string line;
// Read the previous session's commands from the file
while (std::getline(historyFile, line)) while (std::getline(historyFile, line))
{ {
// Truncate the list if it exceeds the retrieval limit // Truncate the list if it exceeds the retrieval limit
@ -720,8 +721,8 @@ namespace MWGui
mCommandHistory.pop_front(); mCommandHistory.pop_front();
mCommandHistory.push_back(line); mCommandHistory.push_back(line);
} }
historyFile.close(); historyFile.close();
}
mCurrent = mCommandHistory.end(); mCurrent = mCommandHistory.end();
try try