diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -671,6 +671,28 @@ NetworkRecvStatus ServerNetworkGameSocke } /** + * Send a chat message from external source. + * @param source Name of the source this message came from. + * @param colour TextColour to use for the message. + * @param user Name of the user who sent the messsage. + * @param msg The actual message. + */ +NetworkRecvStatus ServerNetworkGameSocketHandler::SendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg) +{ + if (this->status < STATUS_PRE_ACTIVE) return NETWORK_RECV_STATUS_OKAY; + + Packet *p = new Packet(PACKET_SERVER_EXTERNAL_CHAT); + + p->Send_string(source); + p->Send_uint16(colour); + p->Send_string(user); + p->Send_string(msg); + + this->SendPacket(p); + return NETWORK_RECV_STATUS_OKAY; +} + +/** * Tell the client another client quit with an error. * @param client_id The client that quit. * @param errorno The reason the client quit. @@ -1262,12 +1284,27 @@ void NetworkServerSendChat(NetworkAction ci = NetworkClientInfo::GetByClientID(from_id); if (ci != nullptr) { - NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data); + NetworkTextMessage(action, GetDrawStringCompanyColour(ci->client_playas), false, ci->client_name, msg, data, ""); } break; } } +/** + * Send a chat message from external source. + * @param source Name of the source this message came from. + * @param colour TextColour to use for the message. + * @param user Name of the user who sent the messsage. + * @param msg The actual message. + */ +void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg) +{ + for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) { + cs->SendExternalChat(source, colour, user, msg); + } + NetworkTextMessage(NETWORK_ACTION_EXTERNAL_CHAT, colour, false, user, msg, 0, source); +} + NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet *p) { if (this->status < STATUS_PRE_ACTIVE) {