mirror of https://github.com/OpenTTD/OpenTTD
(svn r9719) -Fix: in-game private messages did not work for clients with a Client ID > 255.
parent
4d0483b650
commit
b469c443e9
|
@ -184,7 +184,7 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_CHAT)(NetworkAction action, DestType
|
||||||
// Data:
|
// Data:
|
||||||
// uint8: ActionID (see network_data.h, NetworkAction)
|
// uint8: ActionID (see network_data.h, NetworkAction)
|
||||||
// uint8: Destination Type (see network_data.h, DestType);
|
// uint8: Destination Type (see network_data.h, DestType);
|
||||||
// uint8: Destination Player (1..MAX_PLAYERS)
|
// uint16: Destination Player
|
||||||
// String: Message (max MAX_TEXT_MSG_LEN)
|
// 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 (action);
|
||||||
p->Send_uint8 (type);
|
p->Send_uint8 (type);
|
||||||
p->Send_uint8 (dest);
|
p->Send_uint16(dest);
|
||||||
p->Send_string(msg);
|
p->Send_string(msg);
|
||||||
MY_CLIENT->Send_Packet(p);
|
MY_CLIENT->Send_Packet(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1469,7 +1469,7 @@ void ShowJoinStatusWindow()
|
||||||
if (w != NULL) w->parent = FindWindowById(WC_NETWORK_WINDOW, 0);
|
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 (buf[0] == '\0') return;
|
||||||
if (!_network_server) {
|
if (!_network_server) {
|
||||||
|
@ -1533,7 +1533,7 @@ static char *ChatTabCompletionFindText(char *buf)
|
||||||
static void ChatTabCompletion(Window *w)
|
static void ChatTabCompletion(Window *w)
|
||||||
{
|
{
|
||||||
static char _chat_tab_completion_buf[lengthof(_edit_str_buf)];
|
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 len, tb_len;
|
||||||
uint item;
|
uint item;
|
||||||
char *tb_buf, *pre_buf;
|
char *tb_buf, *pre_buf;
|
||||||
|
@ -1591,7 +1591,7 @@ static void ChatTabCompletion(Window *w)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the textbuffer */
|
/* Update the textbuffer */
|
||||||
UpdateTextBufferSize(&WP(w, querystr_d).text);
|
UpdateTextBufferSize(&WP(w, chatquerystr_d).text);
|
||||||
|
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
free(pre_buf);
|
free(pre_buf);
|
||||||
|
@ -1605,17 +1605,17 @@ static void ChatTabCompletion(Window *w)
|
||||||
_chat_tab_completion_active = false;
|
_chat_tab_completion_active = false;
|
||||||
|
|
||||||
/* Update the textbuffer */
|
/* Update the textbuffer */
|
||||||
UpdateTextBufferSize(&WP(w, querystr_d).text);
|
UpdateTextBufferSize(&WP(w, chatquerystr_d).text);
|
||||||
|
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
free(pre_buf);
|
free(pre_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* uses querystr_d WP macro
|
/*
|
||||||
* uses querystr_d->caption to store
|
* uses chatquerystr_d WP macro
|
||||||
* - type of chat message (Private/Team/All) in bytes 0-7
|
* uses chatquerystr_d->caption to store type of chat message (Private/Team/All)
|
||||||
* - destination of chat message in the case of Team/Private in bytes 8-15 */
|
*/
|
||||||
static void ChatWindowWndProc(Window *w, WindowEvent *e)
|
static void ChatWindowWndProc(Window *w, WindowEvent *e)
|
||||||
{
|
{
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
|
@ -1634,25 +1634,25 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
|
|
||||||
assert(GB(WP(w, querystr_d).caption, 0, 8) < lengthof(chat_captions));
|
assert(WP(w, chatquerystr_d).caption < lengthof(chat_captions));
|
||||||
msg = chat_captions[GB(WP(w, querystr_d).caption, 0, 8)];
|
msg = chat_captions[WP(w, chatquerystr_d).caption];
|
||||||
DrawStringRightAligned(w->widget[2].left - 2, w->widget[2].top + 1, msg, 16);
|
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;
|
} break;
|
||||||
|
|
||||||
case WE_CLICK:
|
case WE_CLICK:
|
||||||
switch (e->we.click.widget) {
|
switch (e->we.click.widget) {
|
||||||
case 3: { /* Send */
|
case 3: { /* Send */
|
||||||
DestType type = (DestType)GB(WP(w, querystr_d).caption, 0, 8);
|
DestType type = (DestType)WP(w, chatquerystr_d).caption;
|
||||||
byte dest = GB(WP(w, querystr_d).caption, 8, 8);
|
int dest = WP(w, chatquerystr_d).dest;
|
||||||
SendChat(WP(w, querystr_d).text.buf, type, dest);
|
SendChat(WP(w, chatquerystr_d).text.buf, type, dest);
|
||||||
} /* FALLTHROUGH */
|
} /* FALLTHROUGH */
|
||||||
case 0: /* Cancel */ DeleteWindow(w); break;
|
case 0: /* Cancel */ DeleteWindow(w); break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_MOUSELOOP:
|
case WE_MOUSELOOP:
|
||||||
HandleEditBox(w, &WP(w, querystr_d), 2);
|
HandleEditBox(w, &WP(w, chatquerystr_d), 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_KEYPRESS:
|
case WE_KEYPRESS:
|
||||||
|
@ -1660,11 +1660,11 @@ static void ChatWindowWndProc(Window *w, WindowEvent *e)
|
||||||
ChatTabCompletion(w);
|
ChatTabCompletion(w);
|
||||||
} else {
|
} else {
|
||||||
_chat_tab_completion_active = false;
|
_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 */
|
case 1: { /* Return */
|
||||||
DestType type = (DestType)GB(WP(w, querystr_d).caption, 0, 8);
|
DestType type = (DestType)WP(w, chatquerystr_d).caption;
|
||||||
byte dest = GB(WP(w, querystr_d).caption, 8, 8);
|
int dest = WP(w, chatquerystr_d).dest;
|
||||||
SendChat(WP(w, querystr_d).text.buf, type, dest);
|
SendChat(WP(w, chatquerystr_d).text.buf, type, dest);
|
||||||
} /* FALLTHROUGH */
|
} /* FALLTHROUGH */
|
||||||
case 2: /* Escape */ DeleteWindow(w); break;
|
case 2: /* Escape */ DeleteWindow(w); break;
|
||||||
}
|
}
|
||||||
|
@ -1694,7 +1694,7 @@ static const WindowDesc _chat_window_desc = {
|
||||||
ChatWindowWndProc
|
ChatWindowWndProc
|
||||||
};
|
};
|
||||||
|
|
||||||
void ShowNetworkChatQueryWindow(DestType type, byte dest)
|
void ShowNetworkChatQueryWindow(DestType type, int dest)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
|
|
||||||
|
@ -1706,9 +1706,10 @@ void ShowNetworkChatQueryWindow(DestType type, byte dest)
|
||||||
w = AllocateWindowDesc(&_chat_window_desc);
|
w = AllocateWindowDesc(&_chat_window_desc);
|
||||||
|
|
||||||
LowerWindowWidget(w, 2);
|
LowerWindowWidget(w, 2);
|
||||||
WP(w, querystr_d).caption = GB(type, 0, 8) | (dest << 8); // Misuse of caption
|
WP(w, chatquerystr_d).caption = type; // Misuse of caption
|
||||||
WP(w, querystr_d).afilter = CS_ALPHANUMERAL;
|
WP(w, chatquerystr_d).dest = dest;
|
||||||
InitializeTextBuffer(&WP(w, querystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0);
|
WP(w, chatquerystr_d).afilter = CS_ALPHANUMERAL;
|
||||||
|
InitializeTextBuffer(&WP(w, chatquerystr_d).text, _edit_str_buf, lengthof(_edit_str_buf), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
void ShowNetworkNeedPassword(NetworkPasswordType npt);
|
void ShowNetworkNeedPassword(NetworkPasswordType npt);
|
||||||
void ShowNetworkGiveMoneyWindow(PlayerID player); // PlayerID
|
void ShowNetworkGiveMoneyWindow(PlayerID player); // PlayerID
|
||||||
void ShowNetworkChatQueryWindow(DestType type, byte dest);
|
void ShowNetworkChatQueryWindow(DestType type, int dest);
|
||||||
void ShowJoinStatusWindow();
|
void ShowJoinStatusWindow();
|
||||||
void ShowNetworkGameWindow();
|
void ShowNetworkGameWindow();
|
||||||
void ShowClientList();
|
void ShowClientList();
|
||||||
|
@ -17,7 +17,7 @@ void ShowClientList();
|
||||||
#else /* ENABLE_NETWORK */
|
#else /* ENABLE_NETWORK */
|
||||||
/* Network function stubs when networking is disabled */
|
/* 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 ShowClientList() {}
|
||||||
static inline void ShowNetworkGameWindow() {}
|
static inline void ShowNetworkGameWindow() {}
|
||||||
|
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_CHAT)
|
||||||
{
|
{
|
||||||
NetworkAction action = (NetworkAction)p->Recv_uint8();
|
NetworkAction action = (NetworkAction)p->Recv_uint8();
|
||||||
DestType desttype = (DestType)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];
|
char msg[MAX_TEXT_MSG_LEN];
|
||||||
|
|
||||||
p->Recv_string(msg, MAX_TEXT_MSG_LEN);
|
p->Recv_string(msg, MAX_TEXT_MSG_LEN);
|
||||||
|
|
|
@ -280,6 +280,11 @@ struct querystr_d {
|
||||||
};
|
};
|
||||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(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 {
|
struct menu_d {
|
||||||
byte item_count; ///< follow_vehicle
|
byte item_count; ///< follow_vehicle
|
||||||
byte sel_index; ///< scrollpos_x
|
byte sel_index; ///< scrollpos_x
|
||||||
|
|
Loading…
Reference in New Issue