diff --git a/game/ht.h b/game/ht.h index 8d29502..19b9591 100644 --- a/game/ht.h +++ b/game/ht.h @@ -471,6 +471,7 @@ public: dword cPlayers, dword cGames) = 0; virtual void OnRemoveRoom(dword roomid) = 0; virtual void OnUpdateRoom(dword roomid, dword cPlayers, dword cGames) = 0; + virtual void OnReceiveChat(const char *player, const char *chat) = 0; }; class ITransportCallback { diff --git a/game/lobbyform.cpp b/game/lobbyform.cpp index 709da41..0cd180b 100644 --- a/game/lobbyform.cpp +++ b/game/lobbyform.cpp @@ -380,4 +380,9 @@ bool LobbyForm::OnFilterEvent(Event *pevt) { return false; } +void LobbyForm::OnReceiveChat(const char *player, const char *chat) { + const char *s = base::Format::ToString("%s: %s", player, chat); + HtMessageBox(kfMbWhiteBorder | kfMbKeepTimersEnabled, player, s); +} + } // namespace wi diff --git a/game/lobbyform.h b/game/lobbyform.h index 2d45690..9d7ebdb 100644 --- a/game/lobbyform.h +++ b/game/lobbyform.h @@ -69,6 +69,7 @@ private: dword cPlayers, dword cGames); virtual void OnRemoveRoom(dword roomid); virtual void OnUpdateRoom(dword roomid, dword cPlayers, dword cGames); + virtual void OnReceiveChat(const char *player, const char *chat); // ITransportCallback virtual void OnStatusUpdate(char *pszStatus); diff --git a/game/xtransport.cpp b/game/xtransport.cpp index 804693a..0fa543f 100644 --- a/game/xtransport.cpp +++ b/game/xtransport.cpp @@ -522,6 +522,12 @@ void XTransport::OnLobbyLurkerCount(dword count) { } } +void XTransport::OnLobbyReceiveChat(const char *player, const char *chat) { + if (m_plcb != NULL) { + m_plcb->OnReceiveChat(player, chat); + } +} + dword XTransport::JoinRoom(dword roomid, const char *password, IRoomCallback *prcb) { // Synchronously join a room. It may fail. diff --git a/game/xtransport.h b/game/xtransport.h index c6b378f..3323352 100644 --- a/game/xtransport.h +++ b/game/xtransport.h @@ -99,6 +99,7 @@ private: dword cPlayers, dword cGames); virtual void OnLobbyRemoveRoom(dword idRoom); virtual void OnLobbyUpdateRoom(dword idRoom, dword cPlayers, dword cGames); + virtual void OnLobbyReceiveChat(const char *player, const char *chat); virtual void OnRoomJoinResult(dword result); virtual void OnRoomAddPlayer(const char *player); virtual void OnRoomRemovePlayer(dword hint, const char *player); diff --git a/mpshared/constants.h b/mpshared/constants.h index 6d23e1b..bc22ffd 100644 --- a/mpshared/constants.h +++ b/mpshared/constants.h @@ -30,6 +30,7 @@ const byte XMSG_LOBBYREMOVEROOM = 0xa8; const byte XMSG_LOBBYUPDATEROOM = 0xa9; const byte XMSG_LOBBYLEAVE = 0xaa; const byte XMSG_LOBBYLEAVERESULT = 0xab; +const byte XMSG_LOBBYRECEIVECHAT = 0xac; const byte XMSG_ROOMJOIN = 0xb0; const byte XMSG_ROOMJOINRESULT = 0xb1; const byte XMSG_ROOMADDPLAYER = 0xb2; @@ -81,6 +82,7 @@ STARTLABEL(XMsgLabels) LABEL(XMSG_LOBBYADDROOM) LABEL(XMSG_LOBBYREMOVEROOM) LABEL(XMSG_LOBBYUPDATEROOM) + LABEL(XMSG_LOBBYRECEIVECHAT) LABEL(XMSG_LOBBYLEAVE) LABEL(XMSG_LOBBYLEAVERESULT) LABEL(XMSG_ROOMJOIN) diff --git a/mpshared/messages.h b/mpshared/messages.h index 6991f2c..215d43e 100644 --- a/mpshared/messages.h +++ b/mpshared/messages.h @@ -163,6 +163,7 @@ typedef XMsg1 XMsgLobbyRemoveRoom; typedef XMsg3 XMsgLobbyUpdateRoom; typedef XMsg0 XMsgLobbyLeave; typedef XMsg1 XMsgLobbyLeaveResult; +typedef XMsgS2 XMsgLobbyReceiveChat; typedef XMsgDS XMsgRoomJoin; typedef XMsg1 XMsgRoomJoinResult; typedef XMsgS1 XMsgRoomAddPlayer; diff --git a/mpshared/xpump.cpp b/mpshared/xpump.cpp index b705a14..1ae547e 100644 --- a/mpshared/xpump.cpp +++ b/mpshared/xpump.cpp @@ -242,6 +242,9 @@ XMsg *XPump::XMsgFromBuffer(base::ByteBuffer& bb, dword cb) { case XMSG_LOBBYLEAVERESULT: return XMsgLobbyLeaveResult::FromBuffer(bb, cb); + case XMSG_LOBBYRECEIVECHAT: + return XMsgLobbyReceiveChat::FromBuffer(bb, cb); + case XMSG_ROOMJOIN: return XMsgRoomJoin::FromBuffer(bb, cb); @@ -498,6 +501,14 @@ void XPump::DispatchXMsg(XMsg *pmsg) { } break; + case XMSG_LOBBYRECEIVECHAT: + { + XMsgLobbyReceiveChat *pmsgT = (XMsgLobbyReceiveChat *)pmsg; + // player, chat + notify_->OnLobbyReceiveChat(pmsgT->s0_, pmsgT->s1_); + } + break; + case XMSG_ROOMJOIN: { XMsgRoomJoin *pmsgT = (XMsgRoomJoin *)pmsg; diff --git a/mpshared/xpump.h b/mpshared/xpump.h index 7aee4be..2c4dc50 100644 --- a/mpshared/xpump.h +++ b/mpshared/xpump.h @@ -41,6 +41,8 @@ public: { Assert(); } virtual void OnLobbyLeave() { Assert(); } virtual void OnLobbyLeaveResult(dword result) { Assert(); } + virtual void OnLobbyReceiveChat(const char *player, const char *chat) + { Assert(); } virtual void OnRoomJoin(dword roomid, const char *password) { Assert(); } virtual void OnRoomJoinResult(dword result) { Assert(); } virtual void OnRoomAddPlayer(const char *player) { Assert(); }