1
0
forked from mirrors/0ad

Don't store consecutive console commands twice

This adds an option to disable storing consecutive console commands
twice and enables it by default.
This commit is contained in:
Dunedan
2025-05-16 08:38:51 +02:00
parent d549cbeeaa
commit 45340a2e32
3 changed files with 9 additions and 3 deletions
+1
View File
@@ -192,6 +192,7 @@ server.threads = "6" ; Enough for the browser's parallel co
[console]
font = "mono-10"
history.size = 200
history.ignore_duplicates = true ; Don't store consecutive identical commands twice
[hotkey]
; Each one of the specified keys will trigger the action on the left
+7 -3
View File
@@ -85,6 +85,7 @@ void CConsole::Init()
{
// Initialise console history file
m_MaxHistoryLines = g_ConfigDB.Get("console.history.size", 200);
m_HistoryIgnoreDuplicates = g_ConfigDB.Get("console.history.ignore_duplicates", true);
m_consoleFont = g_ConfigDB.Get("console.font", std::string{"mono-10"});
m_HistoryFile = L"config/console.txt";
@@ -577,9 +578,12 @@ void CConsole::ProcessBuffer(const wchar_t* szLine)
ENSURE(wcslen(szLine) < CONSOLE_BUFFER_SIZE);
m_BufHistory.push_front(szLine);
SaveHistory(); // Do this each line for the moment; if a script causes
// a crash it's a useful record.
if (!m_HistoryIgnoreDuplicates || m_BufHistory.front() != szLine)
{
m_BufHistory.push_front(szLine);
SaveHistory(); // Do this each line for the moment; if a script causes
// a crash it's a useful record.
}
// Process it as JavaScript
std::shared_ptr<ScriptInterface> pScriptInterface = g_GUI->GetActiveGUI()->GetScriptInterface();
+1
View File
@@ -103,6 +103,7 @@ private:
VfsPath m_HistoryFile;
int m_MaxHistoryLines;
bool m_HistoryIgnoreDuplicates;
std::string m_consoleFont;
bool m_Visible; // console is to be drawn