mirror of
https://github.com/spiffcode/hostile-takeover.git
synced 2025-12-16 12:08:36 +00:00
Add server feature for clients to receive chats while in lobby
Clients can receive chats while in lobby state by having the shell form present a HtMessageBox with the chat and the player is it from. This feature was designed to be used with the moderator whisper command.
This commit is contained in:
parent
abb1823956
commit
72566c33bd
@ -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 {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -163,6 +163,7 @@ typedef XMsg1<XMSG_LOBBYREMOVEROOM> XMsgLobbyRemoveRoom;
|
||||
typedef XMsg3<XMSG_LOBBYUPDATEROOM> XMsgLobbyUpdateRoom;
|
||||
typedef XMsg0<XMSG_LOBBYLEAVE> XMsgLobbyLeave;
|
||||
typedef XMsg1<XMSG_LOBBYLEAVERESULT> XMsgLobbyLeaveResult;
|
||||
typedef XMsgS2<XMSG_LOBBYRECEIVECHAT, kcbPlayerName, kcbChatMax> XMsgLobbyReceiveChat;
|
||||
typedef XMsgDS<XMSG_ROOMJOIN, kcbPassword> XMsgRoomJoin;
|
||||
typedef XMsg1<XMSG_ROOMJOINRESULT> XMsgRoomJoinResult;
|
||||
typedef XMsgS1<XMSG_ROOMADDPLAYER, kcbPlayerName> XMsgRoomAddPlayer;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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(); }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user