mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 08:09:41 +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:
commit
49db6cbcc2
1 changed files with 11 additions and 10 deletions
|
@ -709,20 +709,21 @@ 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");
|
||||||
|
|
||||||
std::ifstream historyFile(filePath);
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
// Read the previous session's commands from the file
|
// Read the previous session's commands from the file
|
||||||
while (std::getline(historyFile, line))
|
if (retrievalLimit > 0)
|
||||||
{
|
{
|
||||||
// Truncate the list if it exceeds the retrieval limit
|
std::ifstream historyFile(filePath);
|
||||||
if (mCommandHistory.size() >= retrievalLimit)
|
std::string line;
|
||||||
mCommandHistory.pop_front();
|
while (std::getline(historyFile, line))
|
||||||
mCommandHistory.push_back(line);
|
{
|
||||||
|
// Truncate the list if it exceeds the retrieval limit
|
||||||
|
if (mCommandHistory.size() >= retrievalLimit)
|
||||||
|
mCommandHistory.pop_front();
|
||||||
|
mCommandHistory.push_back(line);
|
||||||
|
}
|
||||||
|
historyFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
historyFile.close();
|
|
||||||
|
|
||||||
mCurrent = mCommandHistory.end();
|
mCurrent = mCommandHistory.end();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue