diff options
author | rubidium <rubidium@openttd.org> | 2007-04-26 07:41:24 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-04-26 07:41:24 +0000 |
commit | b469c443e91c8ef65ddce61944338eba4287f337 (patch) | |
tree | 99cba1dcaf20249c870289b0f68c42bfd10836e5 | |
parent | 4d0483b650c7625c6ea579eb880cbb9bede06d54 (diff) | |
download | openttd-b469c443e91c8ef65ddce61944338eba4287f337.tar.xz |
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
-rw-r--r-- | src/network/network_client.cpp | 4 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 47 | ||||
-rw-r--r-- | src/network/network_gui.h | 4 | ||||
-rw-r--r-- | src/network/network_server.cpp | 2 | ||||
-rw-r--r-- | src/window.h | 5 |
5 files changed, 34 insertions, 28 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 24e1f2163..1bfaa0402 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -184,7 +184,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType // Data: // uint8: ActionID (see network_data.h, NetworkAction) // uint8: Destination Type (see network_data.h, DestType); - // uint8: Destination Player (1..MAX_PLAYERS) + // uint16: Destination Player // String: Message (max MAX_TEXT_MSG_LEN) // @@ -192,7 +192,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType p->Send_uint8 (action); p->Send_uint8 (type); - p->Send_uint8 (dest); + p->Send_uint16(dest); p->Send_string(msg); MY_CLIENT->Send_Packet(p); } diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 86bb801aa..96c9a9181 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1469,7 +1469,7 @@ void ShowJoinStatusWindow() if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0); } -static void SendChat(const char *buf, DestType type, byte dest) +static void SendChat(const char *buf, DestType type, int dest) { if (buf[0] == '\0') return; if (!_network_server) { @@ -1533,7 +1533,7 @@ static char *ChatTabCompletionFindText(char *buf) static void ChatTabCompletion(Window *w) { static char _chat_tab_completion_buf[lengthof(_edit_str_buf)]; - Textbuf *tb = &WP(w, querystr_d).text; + Textbuf *tb = &WP(w, chatquerystr_d).text; uint len, tb_len; uint item; char *tb_buf, *pre_buf; @@ -1591,7 +1591,7 @@ static void ChatTabCompletion(Window *w) } /* Update the textbuffer */ - UpdateTextBufferSize(&WP(w, querystr_d).text); + UpdateTextBufferSize(&WP(w, chatquerystr_d).text); SetWindowDirty(w); free(pre_buf); @@ -1605,17 +1605,17 @@ static void ChatTabCompletion(Window *w) _chat_tab_completion_active = false; /* Update the textbuffer */ - UpdateTextBufferSize(&WP(w, querystr_d).text); + UpdateTextBufferSize(&WP(w, chatquerystr_d).text); SetWindowDirty(w); } free(pre_buf); } -/* uses querystr_d WP macro - * uses querystr_d->caption to store - * - type of chat message (Private/Team/All) in bytes 0-7 - * - destination of chat message in the case of Team/Private in bytes 8-15 */ +/* + * uses chatquerystr_d WP macro + * uses chatquerystr_d->caption to store type of chat message (Private/Team/All) + */ static void ChatWindowWndProc(Window *w, WindowEvent *e) { switch (e->event) { @@ -1634,25 +1634,25 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e) DrawWindowWidgets(w); - assert(GB(WP(w, querystr_d).caption, 0, 8) < lengthof(chat_captions)); - msg = chat_captions[GB(WP(w, querystr_d).caption, 0, 8)]; + assert(WP(w, chatquerystr_d).caption < lengthof(chat_captions)); + msg = chat_captions[WP(w, chatquerystr_d).caption]; DrawStringRightAligned(w->widget[2].left - 2, w->widget[2].top + 1, msg, 16); - DrawEditBox(w, &WP(w, querystr_d), 2); + DrawEditBox(w, &WP(w, chatquerystr_d), 2); } break; case WE_CLICK: switch (e->we.click.widget) { case 3: { /* Send */ - DestType type = (DestType)GB(WP(w, querystr_d).caption, 0, 8); - byte dest = GB(WP(w, querystr_d).caption, 8, 8); - SendChat(WP(w, querystr_d).text.buf, type, dest); + DestType type = (DestType)WP(w, chatquerystr_d).caption; + int dest = WP(w, chatquerystr_d).dest; + SendChat(WP(w, chatquerystr_d).text.buf, type, dest); } /* FALLTHROUGH */ case 0: /* Cancel */ DeleteWindow(w); break; } break; case WE_MOUSELOOP: - HandleEditBox(w, &WP(w, querystr_d), 2); + HandleEditBox(w, &WP(w, chatquerystr_d), 2); break; case WE_KEYPRESS: @@ -1660,11 +1660,11 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e) ChatTabCompletion(w); } else { _chat_tab_completion_active = false; - switch (HandleEditBoxKey(w, &WP(w, querystr_d), 2, e)) { + switch (HandleEditBoxKey(w, &WP(w, chatquerystr_d), 2, e)) { case 1: { /* Return */ - DestType type = (DestType)GB(WP(w, querystr_d).caption, 0, 8); - byte dest = GB(WP(w, querystr_d).caption, 8, 8); - SendChat(WP(w, querystr_d).text.buf, type, dest); + DestType type = (DestType)WP(w, chatquerystr_d).caption; + int dest = WP(w, chatquerystr_d).dest; + SendChat(WP(w, chatquerystr_d).text.buf, type, dest); } /* FALLTHROUGH */ case 2: /* Escape */ DeleteWindow(w); break; } @@ -1694,7 +1694,7 @@ static const WindowDesc _chat_window_desc = { ChatWindowWndProc }; -void ShowNetworkChatQueryWindow(DestType type, byte dest) +void ShowNetworkChatQueryWindow(DestType type, int dest) { Window *w; @@ -1706,9 +1706,10 @@ void ShowNetworkChatQueryWindow(DestType type, byte dest) w = AllocateWindowDesc(&_chat_window_desc); LowerWindowWidget(w, 2); - WP(w, querystr_d).caption = GB(type, 0, 8) | (dest << 8); // Misuse of caption - WP(w, querystr_d).afilter = CS_ALPHANUMERAL; - InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0); + WP(w, chatquerystr_d).caption = type; // Misuse of caption + WP(w, chatquerystr_d).dest = dest; + WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL; + InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0); } #endif /* ENABLE_NETWORK */ diff --git a/src/network/network_gui.h b/src/network/network_gui.h index 06c5eee1c..d71b0a339 100644 --- a/src/network/network_gui.h +++ b/src/network/network_gui.h @@ -9,7 +9,7 @@ void ShowNetworkNeedPassword(NetworkPasswordType npt); void ShowNetworkGiveMoneyWindow(PlayerID player); // PlayerID -void ShowNetworkChatQueryWindow(DestType type, byte dest); +void ShowNetworkChatQueryWindow(DestType type, int dest); void ShowJoinStatusWindow(); void ShowNetworkGameWindow(); void ShowClientList(); @@ -17,7 +17,7 @@ void ShowClientList(); #else /* ENABLE_NETWORK */ /* Network function stubs when networking is disabled */ -static inline void ShowNetworkChatQueryWindow(byte desttype, byte dest) {} +static inline void ShowNetworkChatQueryWindow(byte desttype, int dest) {} static inline void ShowClientList() {} static inline void ShowNetworkGameWindow() {} diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 110fb4bd6..dfcf8de86 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1115,7 +1115,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT) { NetworkAction action = (NetworkAction)p->Recv_uint8(); DestType desttype = (DestType)p->Recv_uint8(); - int dest = p->Recv_uint8(); + int dest = p->Recv_uint16(); char msg[MAX_TEXT_MSG_LEN]; p->Recv_string(msg, MAX_TEXT_MSG_LEN); diff --git a/src/window.h b/src/window.h index 597c6e363..1f74df9b0 100644 --- a/src/window.h +++ b/src/window.h @@ -280,6 +280,11 @@ struct querystr_d { }; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d)); +struct chatquerystr_d : public querystr_d { + int dest; +}; +assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d)); + struct menu_d { byte item_count; ///< follow_vehicle byte sel_index; ///< scrollpos_x |