(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
authortron
Fri, 07 Apr 2006 08:27:43 +0000
changeset 3464 6e01708de019
parent 3463 efc2db302555
child 3465 a7ee131a9114
(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
gui.h
main_gui.c
network_gui.c
--- a/gui.h	Fri Apr 07 07:40:44 2006 +0000
+++ b/gui.h	Fri Apr 07 08:27:43 2006 +0000
@@ -124,7 +124,7 @@
 
 /* network gui */
 void ShowNetworkGameWindow(void);
-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);
 
 /* bridge_gui.c */
 void ShowBuildBridgeWindow(uint start, uint end, byte type);
--- a/main_gui.c	Fri Apr 07 07:40:44 2006 +0000
+++ b/main_gui.c	Fri Apr 07 08:27:43 2006 +0000
@@ -332,7 +332,7 @@
 {
 	_rename_id = desttype + (dest << 8);
 	_rename_what = 2;
-	ShowChatWindow(STR_EMPTY, STR_NETWORK_CHAT_QUERY_CAPTION, 150, 338, 1, 0);
+	ShowChatWindow(STR_NETWORK_CHAT_QUERY_CAPTION, 150, 338, 1, 0);
 }
 
 void ShowNetworkGiveMoneyWindow(byte player)
--- a/network_gui.c	Fri Apr 07 07:40:44 2006 +0000
+++ b/network_gui.c	Fri Apr 07 08:27:43 2006 +0000
@@ -51,7 +51,7 @@
 /* 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 @@
 }
 
 
-
-#define MAX_QUERYSTR_LEN 64
-
 /* uses querystr_d WP macro */
 static void ChatWindowWndProc(Window *w, WindowEvent *e)
 {
@@ -1485,7 +1482,7 @@
 		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 @@
 	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);