summaryrefslogtreecommitdiff
path: root/network_gui.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-04-07 08:27:43 +0000
committertron <tron@openttd.org>2006-04-07 08:27:43 +0000
commit98b51c36e201904a9b4ac8ca25ef9a257bdf172e (patch)
tree5ef7d3d086717c162ceb7115664be731f27eaa8f /network_gui.c
parenta251b9373f2b272d2891ddc7bcaafd0f176b2120 (diff)
downloadopenttd-98b51c36e201904a9b4ac8ca25ef9a257bdf172e.tar.xz
(svn r4309) The initial string of the chat box is always the empty string, so don't jump through hoops to check if nothing was entered and simplify the code
Diffstat (limited to 'network_gui.c')
-rw-r--r--network_gui.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/network_gui.c b/network_gui.c
index c1a3abe72..92444572d 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -51,7 +51,7 @@ typedef struct NetworkGameSorting {
/* Global to remember sorting after window has been closed */
static NetworkGameSorting _ng_sorting;
-static char _edit_str_buf[MAX_QUERYSTR_LEN*2];
+static char _edit_str_buf[MAX_QUERYSTR_LEN];
static void ShowNetworkStartServerWindow(void);
static void ShowNetworkLobbyWindow(NetworkGameList *ngl);
@@ -1463,9 +1463,6 @@ void ShowJoinStatusWindowAfterJoin(void)
}
-
-#define MAX_QUERYSTR_LEN 64
-
/* uses querystr_d WP macro */
static void ChatWindowWndProc(Window *w, WindowEvent *e)
{
@@ -1485,7 +1482,7 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
case 3: DeleteWindow(w); break; // Cancel
case 2: // Send
press_ok:;
- if (strcmp(WP(w, querystr_d).text.buf, WP(w, querystr_d).text.buf + MAX_QUERYSTR_LEN) == 0) {
+ if (WP(w, querystr_d).text.buf[0] == '\0') {
DeleteWindow(w);
} else {
char *buf = WP(w, querystr_d).text.buf;
@@ -1548,19 +1545,13 @@ static const WindowDesc _chat_window_desc = {
ChatWindowWndProc
};
-void ShowChatWindow(StringID str, StringID caption, int maxlen, int maxwidth, WindowClass window_class, WindowNumber window_number)
+void ShowChatWindow(StringID caption, int maxlen, int maxwidth, WindowClass window_class, WindowNumber window_number)
{
Window *w;
-#define _orig_edit_str_buf (_edit_str_buf+MAX_QUERYSTR_LEN)
-
DeleteWindowById(WC_SEND_NETWORK_MSG, 0);
- GetString(_orig_edit_str_buf, str);
-
- _orig_edit_str_buf[maxlen] = '\0';
-
- memcpy(_edit_str_buf, _orig_edit_str_buf, MAX_QUERYSTR_LEN);
+ _edit_str_buf[0] = '\0';
w = AllocateWindowDesc(&_chat_window_desc);