Changeset - r27360:a9bafd45feb6
[Not reviewed]
master
0 3 0
Rubidium - 13 months ago 2023-05-06 10:49:28
rubidium@openttd.org
Codechange: use std::string to store script GUI's break string
3 files changed with 13 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/script/script_gui.cpp
Show inline comments
 
@@ -696,7 +696,7 @@ struct ScriptDebugWindow : public Window
 
	bool autoscroll;                                       ///< Whether automatically scrolling should be enabled or not.
 
	bool show_break_box;                                   ///< Whether the break/debug box is visible.
 
	static bool break_check_enabled;                       ///< Stop an AI when it prints a matching string
 
	static char break_string[MAX_BREAK_STR_STRING_LENGTH]; ///< The string to match to the AI output
 
	static std::string break_string;                       ///< The string to match to the AI output
 
	QueryString break_editbox;                             ///< Break editbox
 
	static StringFilter break_string_filter;               ///< Log filter for break.
 
	static bool case_sensitive_break_check;                ///< Is the matching done case-sensitive
 
@@ -1022,7 +1022,7 @@ struct ScriptDebugWindow : public Window
 
		if (wid != WID_SCRD_BREAK_STR_EDIT_BOX) return;
 

	
 
		/* Save the current string to static member so it can be restored next time the window is opened. */
 
		strecpy(this->break_string, this->break_editbox.text.buf, lastof(this->break_string));
 
		this->break_string = this->break_editbox.text.buf;
 
		break_string_filter.SetFilterTerm(this->break_string);
 
	}
 

	
 
@@ -1098,7 +1098,7 @@ struct ScriptDebugWindow : public Window
 
};
 

	
 
CompanyID ScriptDebugWindow::script_debug_company = INVALID_COMPANY;
 
char ScriptDebugWindow::break_string[MAX_BREAK_STR_STRING_LENGTH] = "";
 
std::string ScriptDebugWindow::break_string;
 
bool ScriptDebugWindow::break_check_enabled = true;
 
bool ScriptDebugWindow::case_sensitive_break_check = false;
 
StringFilter ScriptDebugWindow::break_string_filter(&ScriptDebugWindow::case_sensitive_break_check);
src/stringfilter.cpp
Show inline comments
 
@@ -84,6 +84,15 @@ void StringFilter::SetFilterTerm(const c
 
}
 

	
 
/**
 
 * Set the term to filter on.
 
 * @param str Filter term
 
 */
 
void StringFilter::SetFilterTerm(const std::string &str)
 
{
 
	this->SetFilterTerm(str.c_str());
 
}
 

	
 
/**
 
 * Reset the matching state to process a new item.
 
 */
 
void StringFilter::ResetState()
src/stringfilter_type.h
Show inline comments
 
@@ -51,6 +51,7 @@ public:
 
	~StringFilter() { free(this->filter_buffer); }
 

	
 
	void SetFilterTerm(const char *str);
 
	void SetFilterTerm(const std::string &str);
 

	
 
	/**
 
	 * Check whether any filter words were entered.
0 comments (0 inline, 0 general)