diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -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); diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp --- a/src/stringfilter.cpp +++ b/src/stringfilter.cpp @@ -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() diff --git a/src/stringfilter_type.h b/src/stringfilter_type.h --- a/src/stringfilter_type.h +++ b/src/stringfilter_type.h @@ -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.