summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp2
-rw-r--r--src/fios_gui.cpp2
-rw-r--r--src/genworld_gui.cpp2
-rw-r--r--src/misc_gui.cpp10
-rw-r--r--src/network/network_chat_gui.cpp2
-rw-r--r--src/network/network_content_gui.cpp2
-rw-r--r--src/network/network_gui.cpp8
-rw-r--r--src/newgrf_gui.cpp2
-rw-r--r--src/querystring_gui.h6
-rw-r--r--src/settings_gui.cpp2
-rw-r--r--src/town_gui.cpp6
11 files changed, 20 insertions, 24 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 303b08f17..214c4eb81 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -1356,7 +1356,7 @@ struct AIDebugWindow : public QueryStringBaseWindow {
{
if (wid == WID_AID_BREAK_STR_EDIT_BOX) {
/* Save the current string to static member so it can be restored next time the window is opened. */
- strecpy(this->break_string, this->edit_str_buf, lastof(this->break_string));
+ strecpy(this->break_string, this->text.buf, lastof(this->break_string));
break_string_filter.SetFilterTerm(this->break_string);
}
}
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index 1a8b49935..9880fd187 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -238,7 +238,7 @@ public:
/** Generate a default save filename. */
void GenerateFileName()
{
- GenerateDefaultSaveName(this->edit_str_buf, &this->edit_str_buf[this->edit_str_size - 1]);
+ GenerateDefaultSaveName(this->text.buf, &this->text.buf[this->text.max_bytes - 1]);
this->text.UpdateSize();
}
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index a9fb68a05..36b785b3e 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -698,7 +698,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
* As UINT32_MAX is a 'magic' value (use random seed) it
* should not be possible to be entered into the input
* field; the generate seed button can be used instead. */
- _settings_newgame.game_creation.generation_seed = minu(strtoul(this->edit_str_buf, NULL, 10), UINT32_MAX - 1);
+ _settings_newgame.game_creation.generation_seed = minu(strtoul(this->text.buf, NULL, 10), UINT32_MAX - 1);
}
}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index a933fb7da..01b991fa4 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -819,18 +819,18 @@ struct QueryStringWindow : public QueryStringBaseWindow
QueryStringWindow(StringID str, StringID caption, uint max_bytes, uint max_chars, const WindowDesc *desc, Window *parent, CharSetFilter afilter, QueryStringFlags flags) :
QueryStringBaseWindow(max_bytes, max_chars)
{
- GetString(this->edit_str_buf, str, &this->edit_str_buf[max_bytes - 1]);
- str_validate(this->edit_str_buf, &this->edit_str_buf[max_bytes - 1], SVS_NONE);
+ GetString(this->text.buf, str, &this->text.buf[this->text.max_bytes - 1]);
+ str_validate(this->text.buf, &this->text.buf[this->text.max_bytes - 1], SVS_NONE);
/* Make sure the name isn't too long for the text buffer in the number of
* characters (not bytes). max_chars also counts the '\0' characters. */
- while (Utf8StringLength(this->edit_str_buf) + 1 > max_chars) {
- *Utf8PrevChar(this->edit_str_buf + strlen(this->edit_str_buf)) = '\0';
+ while (Utf8StringLength(this->text.buf) + 1 > this->text.max_chars) {
+ *Utf8PrevChar(this->text.buf + strlen(this->text.buf)) = '\0';
}
this->text.UpdateSize();
- if ((flags & QSF_ACCEPT_UNCHANGED) == 0) this->orig = strdup(this->edit_str_buf);
+ if ((flags & QSF_ACCEPT_UNCHANGED) == 0) this->orig = strdup(this->text.buf);
this->caption = caption;
this->cancel_button = WID_QS_CANCEL;
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index d3caed015..36eb9a68d 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -383,7 +383,7 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
void ChatTabCompletion()
{
static char _chat_tab_completion_buf[NETWORK_CHAT_LENGTH];
- assert(this->edit_str_size == lengthof(_chat_tab_completion_buf));
+ assert(this->text.max_bytes == lengthof(_chat_tab_completion_buf));
Textbuf *tb = &this->text;
size_t len, tb_len;
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 5aa4818f5..2e68c540c 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -780,7 +780,7 @@ public:
virtual void OnEditboxChanged(int wid)
{
if (wid == WID_NCL_FILTER) {
- this->string_filter.SetFilterTerm(this->edit_str_buf);
+ this->string_filter.SetFilterTerm(this->text.buf);
this->content.SetFilterState(!this->string_filter.IsEmpty());
this->content.ForceRebuild();
this->InvalidateData();
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index b5e48c4b0..8daf7c93e 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -850,8 +850,8 @@ public:
{
if (wid == WID_NG_CLIENT) {
/* The name is only allowed when it starts with a letter! */
- if (!StrEmpty(this->edit_str_buf) && this->edit_str_buf[0] != ' ') {
- strecpy(_settings_client.network.client_name, this->edit_str_buf, lastof(_settings_client.network.client_name));
+ if (!StrEmpty(this->text.buf) && this->text.buf[0] != ' ') {
+ strecpy(_settings_client.network.client_name, this->text.buf, lastof(_settings_client.network.client_name));
} else {
strecpy(_settings_client.network.client_name, "Player", lastof(_settings_client.network.client_name));
}
@@ -2116,10 +2116,10 @@ struct NetworkCompanyPasswordWindow : public QueryStringBaseWindow {
void OnOk()
{
if (this->IsWidgetLowered(WID_NCP_SAVE_AS_DEFAULT_PASSWORD)) {
- snprintf(_settings_client.network.default_company_pass, lengthof(_settings_client.network.default_company_pass), "%s", this->edit_str_buf);
+ strecpy(_settings_client.network.default_company_pass, this->text.buf, lastof(_settings_client.network.default_company_pass));
}
- NetworkChangeCompanyPassword(_local_company, this->edit_str_buf);
+ NetworkChangeCompanyPassword(_local_company, this->text.buf);
}
virtual void OnClick(Point pt, int widget, int click_count)
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index e83259d4e..1fa6d47e3 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -1279,7 +1279,7 @@ struct NewGRFWindow : public QueryStringBaseWindow, NewGRFScanCallback {
{
if (!this->editable) return;
- string_filter.SetFilterTerm(this->edit_str_buf);
+ string_filter.SetFilterTerm(this->text.buf);
this->avails.SetFilterState(!string_filter.IsEmpty());
this->avails.ForceRebuild();
this->InvalidateData(0);
diff --git a/src/querystring_gui.h b/src/querystring_gui.h
index 1ce9b93f7..1e0896a2b 100644
--- a/src/querystring_gui.h
+++ b/src/querystring_gui.h
@@ -65,11 +65,7 @@ public:
};
struct QueryStringBaseWindow : public Window, public QueryString {
- char *edit_str_buf; ///< Buffer for string.
- const uint16 edit_str_size; ///< Maximum length of string (in bytes), including terminating '\0'.
- const uint16 max_chars; ///< Maximum length of string (in characters), including terminating '\0'.
-
- QueryStringBaseWindow(uint16 size, uint16 chars = UINT16_MAX) : Window(), QueryString(size, chars), edit_str_buf(text.buf), edit_str_size(text.max_bytes), max_chars(text.max_chars)
+ QueryStringBaseWindow(uint16 size, uint16 chars = UINT16_MAX) : Window(), QueryString(size, chars)
{
}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index cf2981418..30225f5b0 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -2408,7 +2408,7 @@ struct GameSettingsWindow : QueryStringBaseWindow {
virtual void OnEditboxChanged(int wid)
{
if (wid == WID_GS_FILTER) {
- string_filter.SetFilterTerm(this->edit_str_buf);
+ string_filter.SetFilterTerm(this->text.buf);
if (!string_filter.IsEmpty() && !this->manually_changed_folding) {
/* User never expanded/collapsed single pages and entered a filter term.
* Expand everything, to save weird expand clicks, */
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index d34013eca..b029f0fa0 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -1006,7 +1006,7 @@ public:
if (!this->townnamevalid) {
this->text.DeleteAll();
} else {
- GetTownName(this->edit_str_buf, &this->params, this->townnameparts, &this->edit_str_buf[this->edit_str_size - 1]);
+ GetTownName(this->text.buf, &this->params, this->townnameparts, &this->text.buf[this->text.max_bytes - 1]);
this->text.UpdateSize();
}
UpdateOSKOriginalText(this, WID_TF_TOWN_NAME_EDITBOX);
@@ -1041,12 +1041,12 @@ public:
const char *name = NULL;
if (!this->townnamevalid) {
- name = this->edit_str_buf;
+ name = this->text.buf;
} else {
/* If user changed the name, send it */
char buf[MAX_LENGTH_TOWN_NAME_CHARS * MAX_CHAR_LENGTH];
GetTownName(buf, &this->params, this->townnameparts, lastof(buf));
- if (strcmp(buf, this->edit_str_buf) != 0) name = this->edit_str_buf;
+ if (strcmp(buf, this->text.buf) != 0) name = this->text.buf;
}
bool success = DoCommandP(tile, this->town_size | this->city << 2 | this->town_layout << 3 | random << 6,